diff --git a/.editorconfig b/.editorconfig index eebdfb046db52d..17797dd96f8526 100644 --- a/.editorconfig +++ b/.editorconfig @@ -23,5 +23,5 @@ indent_size = unset indent_style = unset trim_trailing_whitespace = unset -[{test/fixtures,deps,tools/eslint/node_modules,tools/gyp,tools/icu,tools/msvs}/**] +[{test/fixtures,deps,tools/gyp,tools/icu,tools/msvs}/**] insert_final_newline = false diff --git a/.github/workflows/tools.yml b/.github/workflows/tools.yml index 891ab1e1bda6f4..2b765d870080f3 100644 --- a/.github/workflows/tools.yml +++ b/.github/workflows/tools.yml @@ -21,7 +21,6 @@ on: - cjs-module-lexer - corepack - doc - - eslint - github_reporter - googletest - gyp-next @@ -128,14 +127,6 @@ jobs: npm install --ignore-scripts $NEW_VERSION npm install --ignore-scripts fi - - id: eslint - subsystem: tools - label: tools - run: | - ./tools/dep_updaters/update-eslint.sh > temp-output - cat temp-output - tail -n1 temp-output | grep "NEW_VERSION=" >> "$GITHUB_ENV" || true - rm temp-output - id: github_reporter subsystem: tools label: tools diff --git a/.gitignore b/.gitignore index fad2496b978066..08a9e6e24e7e85 100644 --- a/.gitignore +++ b/.gitignore @@ -112,6 +112,7 @@ tools/*/*.i.tmp /node_modules /tools/doc/node_modules /tools/clang-format/node_modules +/tools/eslint/node_modules # === Rules for test artifacts === /*.tap diff --git a/LICENSE b/LICENSE index 64b2e7f734b3f2..dfa328b7402fef 100644 --- a/LICENSE +++ b/LICENSE @@ -2003,29 +2003,6 @@ The externally maintained libraries used by Node.js are: OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. """ -- ESLint, located at tools/eslint/node_modules/eslint, is licensed as follows: - """ - Copyright OpenJS Foundation and other contributors, - - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated documentation files (the "Software"), to deal - in the Software without restriction, including without limitation the rights - to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in - all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - THE SOFTWARE. - """ - - gtest, located at deps/googletest, is licensed as follows: """ Copyright 2008, Google Inc. diff --git a/Makefile b/Makefile index 861b3410fb5a64..5681660905b8b1 100644 --- a/Makefile +++ b/Makefile @@ -1193,7 +1193,6 @@ $(TARBALL): release-only doc-only $(RM) -r $(TARNAME)/tools/eslint $(RM) -r $(TARNAME)/tools/eslint-rules $(RM) -r $(TARNAME)/tools/license-builder.sh - $(RM) -r $(TARNAME)/tools/eslint/node_modules $(RM) -r $(TARNAME)/tools/osx-* $(RM) -r $(TARNAME)/tools/osx-pkg.pmdoc find $(TARNAME)/deps/v8/test/* -type d ! -regex '.*/test/torque$$' | xargs $(RM) -r @@ -1389,10 +1388,15 @@ lint-js-fix: .PHONY: lint-js .PHONY: lint-js-doc +.PHONY: lint-js-build + +lint-js-build: + cd tools/eslint && $(call available-node,$(run-npm-ci)) + # Note that on the CI `lint-js-ci` is run instead. # Lints the JavaScript code with eslint. lint-js-doc: LINT_JS_TARGETS=doc -lint-js lint-js-doc: +lint-js lint-js-doc: lint-js-build @if [ "$(shell $(node_use_openssl))" != "true" ]; then \ echo "Skipping $@ (no crypto)"; \ else \ @@ -1409,7 +1413,7 @@ run-lint-js-ci = tools/eslint/node_modules/eslint/bin/eslint.js \ .PHONY: lint-js-ci # On the CI the output is emitted in the TAP format. -lint-js-ci: +lint-js-ci: lint-js-build $(info Running JS linter...) @$(call available-node,$(run-lint-js-ci)) @@ -1563,7 +1567,6 @@ lint-yaml: .PHONY: lint .PHONY: lint-ci -ifneq ("","$(wildcard tools/eslint/node_modules/eslint/)") lint: ## Run JS, C++, MD and doc linters. @EXIT_STATUS=0 ; \ $(MAKE) lint-js || EXIT_STATUS=$$? ; \ @@ -1584,11 +1587,6 @@ lint-ci: lint-js-ci lint-cpp lint-py lint-md lint-addon-docs lint-yaml-build lin echo "Conflict marker detected in one or more files. Please fix them first." >&2 ; \ exit 1 ; \ fi -else -lint lint-ci: - $(info Linting is not available through the source tarball.) - $(info Use the git repo instead: $$ git clone https://github.com/nodejs/node.git) -endif .PHONY: lint-clean lint-clean: diff --git a/pyproject.toml b/pyproject.toml index 23edd575d87bf5..53403931e6e919 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,6 @@ exclude = [ "tools/cpplint.py", "tools/gyp", "tools/inspector_protocol", - "tools/eslint/node_modules", ] line-length = 172 target-version = "py37" diff --git a/tools/dep_updaters/update-eslint.sh b/tools/dep_updaters/update-eslint.sh deleted file mode 100755 index 755aea3bbaef9e..00000000000000 --- a/tools/dep_updaters/update-eslint.sh +++ /dev/null @@ -1,49 +0,0 @@ -#!/bin/sh - -# Shell script to update ESLint in the source tree to the latest release. - -# This script must be in the tools directory when it runs because it uses the -# script source file path to determine directories to work in. - -set -ex - -ROOT=$(cd "$(dirname "$0")/../.." && pwd) - -[ -z "$NODE" ] && NODE="$ROOT/out/Release/node" -[ -x "$NODE" ] || NODE=$(command -v node) -NPM="$ROOT/deps/npm/bin/npm-cli.js" - -# shellcheck disable=SC1091 -. "$ROOT/tools/dep_updaters/utils.sh" - -NEW_VERSION=$("$NODE" "$NPM" view eslint dist-tags.latest) -CURRENT_VERSION=$("$NODE" -p "require('./tools/eslint/node_modules/eslint/package.json').version") - -# This function exit with 0 if new version and current version are the same -compare_dependency_version "eslint" "$NEW_VERSION" "$CURRENT_VERSION" - -cd "$( dirname "$0" )" || exit -rm -rf ../eslint/node_modules ../eslint/package-lock.json - -cd ../eslint -"$NODE" "$NPM" install \ - --ignore-scripts \ - --no-bin-links \ - "eslint@$NEW_VERSION" \ - eslint-formatter-tap \ - eslint-plugin-jsdoc \ - eslint-plugin-markdown \ - globals \ - @babel/core \ - @babel/eslint-parser \ - @babel/plugin-syntax-import-attributes \ - @stylistic/eslint-plugin-js - -# Use dmn to remove some unneeded files. -"$NODE" "$NPM" exec --package=dmn@3.0.1 --yes -- dmn -f clean -# TODO: Get this into dmn. -find node_modules \( -name .package-lock.json -or -name 'README*' \) -exec rm {} \; - -# The last line of the script should always print the new version, -# as we need to add it to $GITHUB_ENV variable. -echo "NEW_VERSION=$NEW_VERSION" diff --git a/tools/eslint/node_modules/@ampproject/remapping/LICENSE b/tools/eslint/node_modules/@ampproject/remapping/LICENSE deleted file mode 100644 index d645695673349e..00000000000000 --- a/tools/eslint/node_modules/@ampproject/remapping/LICENSE +++ /dev/null @@ -1,202 +0,0 @@ - - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright [yyyy] [name of copyright owner] - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. diff --git a/tools/eslint/node_modules/@ampproject/remapping/dist/remapping.mjs b/tools/eslint/node_modules/@ampproject/remapping/dist/remapping.mjs deleted file mode 100644 index f3875999c027f7..00000000000000 --- a/tools/eslint/node_modules/@ampproject/remapping/dist/remapping.mjs +++ /dev/null @@ -1,197 +0,0 @@ -import { decodedMappings, traceSegment, TraceMap } from '@jridgewell/trace-mapping'; -import { GenMapping, maybeAddSegment, setSourceContent, setIgnore, toDecodedMap, toEncodedMap } from '@jridgewell/gen-mapping'; - -const SOURCELESS_MAPPING = /* #__PURE__ */ SegmentObject('', -1, -1, '', null, false); -const EMPTY_SOURCES = []; -function SegmentObject(source, line, column, name, content, ignore) { - return { source, line, column, name, content, ignore }; -} -function Source(map, sources, source, content, ignore) { - return { - map, - sources, - source, - content, - ignore, - }; -} -/** - * MapSource represents a single sourcemap, with the ability to trace mappings into its child nodes - * (which may themselves be SourceMapTrees). - */ -function MapSource(map, sources) { - return Source(map, sources, '', null, false); -} -/** - * A "leaf" node in the sourcemap tree, representing an original, unmodified source file. Recursive - * segment tracing ends at the `OriginalSource`. - */ -function OriginalSource(source, content, ignore) { - return Source(null, EMPTY_SOURCES, source, content, ignore); -} -/** - * traceMappings is only called on the root level SourceMapTree, and begins the process of - * resolving each mapping in terms of the original source files. - */ -function traceMappings(tree) { - // TODO: Eventually support sourceRoot, which has to be removed because the sources are already - // fully resolved. We'll need to make sources relative to the sourceRoot before adding them. - const gen = new GenMapping({ file: tree.map.file }); - const { sources: rootSources, map } = tree; - const rootNames = map.names; - const rootMappings = decodedMappings(map); - for (let i = 0; i < rootMappings.length; i++) { - const segments = rootMappings[i]; - for (let j = 0; j < segments.length; j++) { - const segment = segments[j]; - const genCol = segment[0]; - let traced = SOURCELESS_MAPPING; - // 1-length segments only move the current generated column, there's no source information - // to gather from it. - if (segment.length !== 1) { - const source = rootSources[segment[1]]; - traced = originalPositionFor(source, segment[2], segment[3], segment.length === 5 ? rootNames[segment[4]] : ''); - // If the trace is invalid, then the trace ran into a sourcemap that doesn't contain a - // respective segment into an original source. - if (traced == null) - continue; - } - const { column, line, name, content, source, ignore } = traced; - maybeAddSegment(gen, i, genCol, source, line, column, name); - if (source && content != null) - setSourceContent(gen, source, content); - if (ignore) - setIgnore(gen, source, true); - } - } - return gen; -} -/** - * originalPositionFor is only called on children SourceMapTrees. It recurses down into its own - * child SourceMapTrees, until we find the original source map. - */ -function originalPositionFor(source, line, column, name) { - if (!source.map) { - return SegmentObject(source.source, line, column, name, source.content, source.ignore); - } - const segment = traceSegment(source.map, line, column); - // If we couldn't find a segment, then this doesn't exist in the sourcemap. - if (segment == null) - return null; - // 1-length segments only move the current generated column, there's no source information - // to gather from it. - if (segment.length === 1) - return SOURCELESS_MAPPING; - return originalPositionFor(source.sources[segment[1]], segment[2], segment[3], segment.length === 5 ? source.map.names[segment[4]] : name); -} - -function asArray(value) { - if (Array.isArray(value)) - return value; - return [value]; -} -/** - * Recursively builds a tree structure out of sourcemap files, with each node - * being either an `OriginalSource` "leaf" or a `SourceMapTree` composed of - * `OriginalSource`s and `SourceMapTree`s. - * - * Every sourcemap is composed of a collection of source files and mappings - * into locations of those source files. When we generate a `SourceMapTree` for - * the sourcemap, we attempt to load each source file's own sourcemap. If it - * does not have an associated sourcemap, it is considered an original, - * unmodified source file. - */ -function buildSourceMapTree(input, loader) { - const maps = asArray(input).map((m) => new TraceMap(m, '')); - const map = maps.pop(); - for (let i = 0; i < maps.length; i++) { - if (maps[i].sources.length > 1) { - throw new Error(`Transformation map ${i} must have exactly one source file.\n` + - 'Did you specify these with the most recent transformation maps first?'); - } - } - let tree = build(map, loader, '', 0); - for (let i = maps.length - 1; i >= 0; i--) { - tree = MapSource(maps[i], [tree]); - } - return tree; -} -function build(map, loader, importer, importerDepth) { - const { resolvedSources, sourcesContent, ignoreList } = map; - const depth = importerDepth + 1; - const children = resolvedSources.map((sourceFile, i) => { - // The loading context gives the loader more information about why this file is being loaded - // (eg, from which importer). It also allows the loader to override the location of the loaded - // sourcemap/original source, or to override the content in the sourcesContent field if it's - // an unmodified source file. - const ctx = { - importer, - depth, - source: sourceFile || '', - content: undefined, - ignore: undefined, - }; - // Use the provided loader callback to retrieve the file's sourcemap. - // TODO: We should eventually support async loading of sourcemap files. - const sourceMap = loader(ctx.source, ctx); - const { source, content, ignore } = ctx; - // If there is a sourcemap, then we need to recurse into it to load its source files. - if (sourceMap) - return build(new TraceMap(sourceMap, source), loader, source, depth); - // Else, it's an unmodified source file. - // The contents of this unmodified source file can be overridden via the loader context, - // allowing it to be explicitly null or a string. If it remains undefined, we fall back to - // the importing sourcemap's `sourcesContent` field. - const sourceContent = content !== undefined ? content : sourcesContent ? sourcesContent[i] : null; - const ignored = ignore !== undefined ? ignore : ignoreList ? ignoreList.includes(i) : false; - return OriginalSource(source, sourceContent, ignored); - }); - return MapSource(map, children); -} - -/** - * A SourceMap v3 compatible sourcemap, which only includes fields that were - * provided to it. - */ -class SourceMap { - constructor(map, options) { - const out = options.decodedMappings ? toDecodedMap(map) : toEncodedMap(map); - this.version = out.version; // SourceMap spec says this should be first. - this.file = out.file; - this.mappings = out.mappings; - this.names = out.names; - this.ignoreList = out.ignoreList; - this.sourceRoot = out.sourceRoot; - this.sources = out.sources; - if (!options.excludeContent) { - this.sourcesContent = out.sourcesContent; - } - } - toString() { - return JSON.stringify(this); - } -} - -/** - * Traces through all the mappings in the root sourcemap, through the sources - * (and their sourcemaps), all the way back to the original source location. - * - * `loader` will be called every time we encounter a source file. If it returns - * a sourcemap, we will recurse into that sourcemap to continue the trace. If - * it returns a falsey value, that source file is treated as an original, - * unmodified source file. - * - * Pass `excludeContent` to exclude any self-containing source file content - * from the output sourcemap. - * - * Pass `decodedMappings` to receive a SourceMap with decoded (instead of - * VLQ encoded) mappings. - */ -function remapping(input, loader, options) { - const opts = typeof options === 'object' ? options : { excludeContent: !!options, decodedMappings: false }; - const tree = buildSourceMapTree(input, loader); - return new SourceMap(traceMappings(tree), opts); -} - -export { remapping as default }; -//# sourceMappingURL=remapping.mjs.map diff --git a/tools/eslint/node_modules/@ampproject/remapping/dist/remapping.umd.js b/tools/eslint/node_modules/@ampproject/remapping/dist/remapping.umd.js deleted file mode 100644 index 6b7b3bb520a45d..00000000000000 --- a/tools/eslint/node_modules/@ampproject/remapping/dist/remapping.umd.js +++ /dev/null @@ -1,202 +0,0 @@ -(function (global, factory) { - typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('@jridgewell/trace-mapping'), require('@jridgewell/gen-mapping')) : - typeof define === 'function' && define.amd ? define(['@jridgewell/trace-mapping', '@jridgewell/gen-mapping'], factory) : - (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.remapping = factory(global.traceMapping, global.genMapping)); -})(this, (function (traceMapping, genMapping) { 'use strict'; - - const SOURCELESS_MAPPING = /* #__PURE__ */ SegmentObject('', -1, -1, '', null, false); - const EMPTY_SOURCES = []; - function SegmentObject(source, line, column, name, content, ignore) { - return { source, line, column, name, content, ignore }; - } - function Source(map, sources, source, content, ignore) { - return { - map, - sources, - source, - content, - ignore, - }; - } - /** - * MapSource represents a single sourcemap, with the ability to trace mappings into its child nodes - * (which may themselves be SourceMapTrees). - */ - function MapSource(map, sources) { - return Source(map, sources, '', null, false); - } - /** - * A "leaf" node in the sourcemap tree, representing an original, unmodified source file. Recursive - * segment tracing ends at the `OriginalSource`. - */ - function OriginalSource(source, content, ignore) { - return Source(null, EMPTY_SOURCES, source, content, ignore); - } - /** - * traceMappings is only called on the root level SourceMapTree, and begins the process of - * resolving each mapping in terms of the original source files. - */ - function traceMappings(tree) { - // TODO: Eventually support sourceRoot, which has to be removed because the sources are already - // fully resolved. We'll need to make sources relative to the sourceRoot before adding them. - const gen = new genMapping.GenMapping({ file: tree.map.file }); - const { sources: rootSources, map } = tree; - const rootNames = map.names; - const rootMappings = traceMapping.decodedMappings(map); - for (let i = 0; i < rootMappings.length; i++) { - const segments = rootMappings[i]; - for (let j = 0; j < segments.length; j++) { - const segment = segments[j]; - const genCol = segment[0]; - let traced = SOURCELESS_MAPPING; - // 1-length segments only move the current generated column, there's no source information - // to gather from it. - if (segment.length !== 1) { - const source = rootSources[segment[1]]; - traced = originalPositionFor(source, segment[2], segment[3], segment.length === 5 ? rootNames[segment[4]] : ''); - // If the trace is invalid, then the trace ran into a sourcemap that doesn't contain a - // respective segment into an original source. - if (traced == null) - continue; - } - const { column, line, name, content, source, ignore } = traced; - genMapping.maybeAddSegment(gen, i, genCol, source, line, column, name); - if (source && content != null) - genMapping.setSourceContent(gen, source, content); - if (ignore) - genMapping.setIgnore(gen, source, true); - } - } - return gen; - } - /** - * originalPositionFor is only called on children SourceMapTrees. It recurses down into its own - * child SourceMapTrees, until we find the original source map. - */ - function originalPositionFor(source, line, column, name) { - if (!source.map) { - return SegmentObject(source.source, line, column, name, source.content, source.ignore); - } - const segment = traceMapping.traceSegment(source.map, line, column); - // If we couldn't find a segment, then this doesn't exist in the sourcemap. - if (segment == null) - return null; - // 1-length segments only move the current generated column, there's no source information - // to gather from it. - if (segment.length === 1) - return SOURCELESS_MAPPING; - return originalPositionFor(source.sources[segment[1]], segment[2], segment[3], segment.length === 5 ? source.map.names[segment[4]] : name); - } - - function asArray(value) { - if (Array.isArray(value)) - return value; - return [value]; - } - /** - * Recursively builds a tree structure out of sourcemap files, with each node - * being either an `OriginalSource` "leaf" or a `SourceMapTree` composed of - * `OriginalSource`s and `SourceMapTree`s. - * - * Every sourcemap is composed of a collection of source files and mappings - * into locations of those source files. When we generate a `SourceMapTree` for - * the sourcemap, we attempt to load each source file's own sourcemap. If it - * does not have an associated sourcemap, it is considered an original, - * unmodified source file. - */ - function buildSourceMapTree(input, loader) { - const maps = asArray(input).map((m) => new traceMapping.TraceMap(m, '')); - const map = maps.pop(); - for (let i = 0; i < maps.length; i++) { - if (maps[i].sources.length > 1) { - throw new Error(`Transformation map ${i} must have exactly one source file.\n` + - 'Did you specify these with the most recent transformation maps first?'); - } - } - let tree = build(map, loader, '', 0); - for (let i = maps.length - 1; i >= 0; i--) { - tree = MapSource(maps[i], [tree]); - } - return tree; - } - function build(map, loader, importer, importerDepth) { - const { resolvedSources, sourcesContent, ignoreList } = map; - const depth = importerDepth + 1; - const children = resolvedSources.map((sourceFile, i) => { - // The loading context gives the loader more information about why this file is being loaded - // (eg, from which importer). It also allows the loader to override the location of the loaded - // sourcemap/original source, or to override the content in the sourcesContent field if it's - // an unmodified source file. - const ctx = { - importer, - depth, - source: sourceFile || '', - content: undefined, - ignore: undefined, - }; - // Use the provided loader callback to retrieve the file's sourcemap. - // TODO: We should eventually support async loading of sourcemap files. - const sourceMap = loader(ctx.source, ctx); - const { source, content, ignore } = ctx; - // If there is a sourcemap, then we need to recurse into it to load its source files. - if (sourceMap) - return build(new traceMapping.TraceMap(sourceMap, source), loader, source, depth); - // Else, it's an unmodified source file. - // The contents of this unmodified source file can be overridden via the loader context, - // allowing it to be explicitly null or a string. If it remains undefined, we fall back to - // the importing sourcemap's `sourcesContent` field. - const sourceContent = content !== undefined ? content : sourcesContent ? sourcesContent[i] : null; - const ignored = ignore !== undefined ? ignore : ignoreList ? ignoreList.includes(i) : false; - return OriginalSource(source, sourceContent, ignored); - }); - return MapSource(map, children); - } - - /** - * A SourceMap v3 compatible sourcemap, which only includes fields that were - * provided to it. - */ - class SourceMap { - constructor(map, options) { - const out = options.decodedMappings ? genMapping.toDecodedMap(map) : genMapping.toEncodedMap(map); - this.version = out.version; // SourceMap spec says this should be first. - this.file = out.file; - this.mappings = out.mappings; - this.names = out.names; - this.ignoreList = out.ignoreList; - this.sourceRoot = out.sourceRoot; - this.sources = out.sources; - if (!options.excludeContent) { - this.sourcesContent = out.sourcesContent; - } - } - toString() { - return JSON.stringify(this); - } - } - - /** - * Traces through all the mappings in the root sourcemap, through the sources - * (and their sourcemaps), all the way back to the original source location. - * - * `loader` will be called every time we encounter a source file. If it returns - * a sourcemap, we will recurse into that sourcemap to continue the trace. If - * it returns a falsey value, that source file is treated as an original, - * unmodified source file. - * - * Pass `excludeContent` to exclude any self-containing source file content - * from the output sourcemap. - * - * Pass `decodedMappings` to receive a SourceMap with decoded (instead of - * VLQ encoded) mappings. - */ - function remapping(input, loader, options) { - const opts = typeof options === 'object' ? options : { excludeContent: !!options, decodedMappings: false }; - const tree = buildSourceMapTree(input, loader); - return new SourceMap(traceMappings(tree), opts); - } - - return remapping; - -})); -//# sourceMappingURL=remapping.umd.js.map diff --git a/tools/eslint/node_modules/@ampproject/remapping/package.json b/tools/eslint/node_modules/@ampproject/remapping/package.json deleted file mode 100644 index 091224c6730b07..00000000000000 --- a/tools/eslint/node_modules/@ampproject/remapping/package.json +++ /dev/null @@ -1,75 +0,0 @@ -{ - "name": "@ampproject/remapping", - "version": "2.3.0", - "description": "Remap sequential sourcemaps through transformations to point at the original source code", - "keywords": [ - "source", - "map", - "remap" - ], - "main": "dist/remapping.umd.js", - "module": "dist/remapping.mjs", - "types": "dist/types/remapping.d.ts", - "exports": { - ".": [ - { - "types": "./dist/types/remapping.d.ts", - "browser": "./dist/remapping.umd.js", - "require": "./dist/remapping.umd.js", - "import": "./dist/remapping.mjs" - }, - "./dist/remapping.umd.js" - ], - "./package.json": "./package.json" - }, - "files": [ - "dist" - ], - "author": "Justin Ridgewell ", - "repository": { - "type": "git", - "url": "git+https://github.com/ampproject/remapping.git" - }, - "license": "Apache-2.0", - "engines": { - "node": ">=6.0.0" - }, - "scripts": { - "build": "run-s -n build:*", - "build:rollup": "rollup -c rollup.config.js", - "build:ts": "tsc --project tsconfig.build.json", - "lint": "run-s -n lint:*", - "lint:prettier": "npm run test:lint:prettier -- --write", - "lint:ts": "npm run test:lint:ts -- --fix", - "prebuild": "rm -rf dist", - "prepublishOnly": "npm run preversion", - "preversion": "run-s test build", - "test": "run-s -n test:lint test:only", - "test:debug": "node --inspect-brk node_modules/.bin/jest --runInBand", - "test:lint": "run-s -n test:lint:*", - "test:lint:prettier": "prettier --check '{src,test}/**/*.ts'", - "test:lint:ts": "eslint '{src,test}/**/*.ts'", - "test:only": "jest --coverage", - "test:watch": "jest --coverage --watch" - }, - "devDependencies": { - "@rollup/plugin-typescript": "8.3.2", - "@types/jest": "27.4.1", - "@typescript-eslint/eslint-plugin": "5.20.0", - "@typescript-eslint/parser": "5.20.0", - "eslint": "8.14.0", - "eslint-config-prettier": "8.5.0", - "jest": "27.5.1", - "jest-config": "27.5.1", - "npm-run-all": "4.1.5", - "prettier": "2.6.2", - "rollup": "2.70.2", - "ts-jest": "27.1.4", - "tslib": "2.4.0", - "typescript": "4.6.3" - }, - "dependencies": { - "@jridgewell/gen-mapping": "^0.3.5", - "@jridgewell/trace-mapping": "^0.3.24" - } -} diff --git a/tools/eslint/node_modules/@babel/code-frame/LICENSE b/tools/eslint/node_modules/@babel/code-frame/LICENSE deleted file mode 100644 index f31575ec773bb1..00000000000000 --- a/tools/eslint/node_modules/@babel/code-frame/LICENSE +++ /dev/null @@ -1,22 +0,0 @@ -MIT License - -Copyright (c) 2014-present Sebastian McKenzie and other contributors - -Permission is hereby granted, free of charge, to any person obtaining -a copy of this software and associated documentation files (the -"Software"), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sublicense, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/tools/eslint/node_modules/@babel/code-frame/lib/index.js b/tools/eslint/node_modules/@babel/code-frame/lib/index.js deleted file mode 100644 index 53461aa13f9cbc..00000000000000 --- a/tools/eslint/node_modules/@babel/code-frame/lib/index.js +++ /dev/null @@ -1,156 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.codeFrameColumns = codeFrameColumns; -exports.default = _default; -var _highlight = require("@babel/highlight"); -var _picocolors = _interopRequireWildcard(require("picocolors"), true); -function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); } -function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; } -const colors = typeof process === "object" && (process.env.FORCE_COLOR === "0" || process.env.FORCE_COLOR === "false") ? (0, _picocolors.createColors)(false) : _picocolors.default; -const compose = (f, g) => v => f(g(v)); -let pcWithForcedColor = undefined; -function getColors(forceColor) { - if (forceColor) { - var _pcWithForcedColor; - (_pcWithForcedColor = pcWithForcedColor) != null ? _pcWithForcedColor : pcWithForcedColor = (0, _picocolors.createColors)(true); - return pcWithForcedColor; - } - return colors; -} -let deprecationWarningShown = false; -function getDefs(colors) { - return { - gutter: colors.gray, - marker: compose(colors.red, colors.bold), - message: compose(colors.red, colors.bold) - }; -} -const NEWLINE = /\r\n|[\n\r\u2028\u2029]/; -function getMarkerLines(loc, source, opts) { - const startLoc = Object.assign({ - column: 0, - line: -1 - }, loc.start); - const endLoc = Object.assign({}, startLoc, loc.end); - const { - linesAbove = 2, - linesBelow = 3 - } = opts || {}; - const startLine = startLoc.line; - const startColumn = startLoc.column; - const endLine = endLoc.line; - const endColumn = endLoc.column; - let start = Math.max(startLine - (linesAbove + 1), 0); - let end = Math.min(source.length, endLine + linesBelow); - if (startLine === -1) { - start = 0; - } - if (endLine === -1) { - end = source.length; - } - const lineDiff = endLine - startLine; - const markerLines = {}; - if (lineDiff) { - for (let i = 0; i <= lineDiff; i++) { - const lineNumber = i + startLine; - if (!startColumn) { - markerLines[lineNumber] = true; - } else if (i === 0) { - const sourceLength = source[lineNumber - 1].length; - markerLines[lineNumber] = [startColumn, sourceLength - startColumn + 1]; - } else if (i === lineDiff) { - markerLines[lineNumber] = [0, endColumn]; - } else { - const sourceLength = source[lineNumber - i].length; - markerLines[lineNumber] = [0, sourceLength]; - } - } - } else { - if (startColumn === endColumn) { - if (startColumn) { - markerLines[startLine] = [startColumn, 0]; - } else { - markerLines[startLine] = true; - } - } else { - markerLines[startLine] = [startColumn, endColumn - startColumn]; - } - } - return { - start, - end, - markerLines - }; -} -function codeFrameColumns(rawLines, loc, opts = {}) { - const highlighted = (opts.highlightCode || opts.forceColor) && (0, _highlight.shouldHighlight)(opts); - const colors = getColors(opts.forceColor); - const defs = getDefs(colors); - const maybeHighlight = (fmt, string) => { - return highlighted ? fmt(string) : string; - }; - const lines = rawLines.split(NEWLINE); - const { - start, - end, - markerLines - } = getMarkerLines(loc, lines, opts); - const hasColumns = loc.start && typeof loc.start.column === "number"; - const numberMaxWidth = String(end).length; - const highlightedLines = highlighted ? (0, _highlight.default)(rawLines, opts) : rawLines; - let frame = highlightedLines.split(NEWLINE, end).slice(start, end).map((line, index) => { - const number = start + 1 + index; - const paddedNumber = ` ${number}`.slice(-numberMaxWidth); - const gutter = ` ${paddedNumber} |`; - const hasMarker = markerLines[number]; - const lastMarkerLine = !markerLines[number + 1]; - if (hasMarker) { - let markerLine = ""; - if (Array.isArray(hasMarker)) { - const markerSpacing = line.slice(0, Math.max(hasMarker[0] - 1, 0)).replace(/[^\t]/g, " "); - const numberOfMarkers = hasMarker[1] || 1; - markerLine = ["\n ", maybeHighlight(defs.gutter, gutter.replace(/\d/g, " ")), " ", markerSpacing, maybeHighlight(defs.marker, "^").repeat(numberOfMarkers)].join(""); - if (lastMarkerLine && opts.message) { - markerLine += " " + maybeHighlight(defs.message, opts.message); - } - } - return [maybeHighlight(defs.marker, ">"), maybeHighlight(defs.gutter, gutter), line.length > 0 ? ` ${line}` : "", markerLine].join(""); - } else { - return ` ${maybeHighlight(defs.gutter, gutter)}${line.length > 0 ? ` ${line}` : ""}`; - } - }).join("\n"); - if (opts.message && !hasColumns) { - frame = `${" ".repeat(numberMaxWidth + 1)}${opts.message}\n${frame}`; - } - if (highlighted) { - return colors.reset(frame); - } else { - return frame; - } -} -function _default(rawLines, lineNumber, colNumber, opts = {}) { - if (!deprecationWarningShown) { - deprecationWarningShown = true; - const message = "Passing lineNumber and colNumber is deprecated to @babel/code-frame. Please use `codeFrameColumns`."; - if (process.emitWarning) { - process.emitWarning(message, "DeprecationWarning"); - } else { - const deprecationError = new Error(message); - deprecationError.name = "DeprecationWarning"; - console.warn(new Error(message)); - } - } - colNumber = Math.max(colNumber, 0); - const location = { - start: { - column: colNumber, - line: lineNumber - } - }; - return codeFrameColumns(rawLines, location, opts); -} - -//# sourceMappingURL=index.js.map diff --git a/tools/eslint/node_modules/@babel/code-frame/package.json b/tools/eslint/node_modules/@babel/code-frame/package.json deleted file mode 100644 index 9e672b764c8759..00000000000000 --- a/tools/eslint/node_modules/@babel/code-frame/package.json +++ /dev/null @@ -1,30 +0,0 @@ -{ - "name": "@babel/code-frame", - "version": "7.24.7", - "description": "Generate errors that contain a code frame that point to source locations.", - "author": "The Babel Team (https://babel.dev/team)", - "homepage": "https://babel.dev/docs/en/next/babel-code-frame", - "bugs": "https://github.com/babel/babel/issues?utf8=%E2%9C%93&q=is%3Aissue+is%3Aopen", - "license": "MIT", - "publishConfig": { - "access": "public" - }, - "repository": { - "type": "git", - "url": "https://github.com/babel/babel.git", - "directory": "packages/babel-code-frame" - }, - "main": "./lib/index.js", - "dependencies": { - "@babel/highlight": "^7.24.7", - "picocolors": "^1.0.0" - }, - "devDependencies": { - "import-meta-resolve": "^4.1.0", - "strip-ansi": "^4.0.0" - }, - "engines": { - "node": ">=6.9.0" - }, - "type": "commonjs" -} \ No newline at end of file diff --git a/tools/eslint/node_modules/@babel/compat-data/LICENSE b/tools/eslint/node_modules/@babel/compat-data/LICENSE deleted file mode 100644 index f31575ec773bb1..00000000000000 --- a/tools/eslint/node_modules/@babel/compat-data/LICENSE +++ /dev/null @@ -1,22 +0,0 @@ -MIT License - -Copyright (c) 2014-present Sebastian McKenzie and other contributors - -Permission is hereby granted, free of charge, to any person obtaining -a copy of this software and associated documentation files (the -"Software"), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sublicense, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/tools/eslint/node_modules/@babel/compat-data/corejs2-built-ins.js b/tools/eslint/node_modules/@babel/compat-data/corejs2-built-ins.js deleted file mode 100644 index ed19e0b8a4ffd6..00000000000000 --- a/tools/eslint/node_modules/@babel/compat-data/corejs2-built-ins.js +++ /dev/null @@ -1,2 +0,0 @@ -// Todo (Babel 8): remove this file as Babel 8 drop support of core-js 2 -module.exports = require("./data/corejs2-built-ins.json"); diff --git a/tools/eslint/node_modules/@babel/compat-data/corejs3-shipped-proposals.js b/tools/eslint/node_modules/@babel/compat-data/corejs3-shipped-proposals.js deleted file mode 100644 index 7909b8c46d3717..00000000000000 --- a/tools/eslint/node_modules/@babel/compat-data/corejs3-shipped-proposals.js +++ /dev/null @@ -1,2 +0,0 @@ -// Todo (Babel 8): remove this file now that it is included in babel-plugin-polyfill-corejs3 -module.exports = require("./data/corejs3-shipped-proposals.json"); diff --git a/tools/eslint/node_modules/@babel/compat-data/data/corejs2-built-ins.json b/tools/eslint/node_modules/@babel/compat-data/data/corejs2-built-ins.json deleted file mode 100644 index 5fe8ca8dd141df..00000000000000 --- a/tools/eslint/node_modules/@babel/compat-data/data/corejs2-built-ins.json +++ /dev/null @@ -1,2090 +0,0 @@ -{ - "es6.array.copy-within": { - "chrome": "45", - "opera": "32", - "edge": "12", - "firefox": "32", - "safari": "9", - "node": "4", - "deno": "1", - "ios": "9", - "samsung": "5", - "rhino": "1.7.13", - "opera_mobile": "32", - "electron": "0.31" - }, - "es6.array.every": { - "chrome": "5", - "opera": "10.10", - "edge": "12", - "firefox": "2", - "safari": "3.1", - "node": "0.4", - "deno": "1", - "ie": "9", - "android": "4", - "ios": "6", - "phantom": "1.9", - "samsung": "1", - "rhino": "1.7.13", - "opera_mobile": "10.1", - "electron": "0.20" - }, - "es6.array.fill": { - "chrome": "45", - "opera": "32", - "edge": "12", - "firefox": "31", - "safari": "7.1", - "node": "4", - "deno": "1", - "ios": "8", - "samsung": "5", - "rhino": "1.7.13", - "opera_mobile": "32", - "electron": "0.31" - }, - "es6.array.filter": { - "chrome": "51", - "opera": "38", - "edge": "13", - "firefox": "48", - "safari": "10", - "node": "6.5", - "deno": "1", - "ios": "10", - "samsung": "5", - "opera_mobile": "41", - "electron": "1.2" - }, - "es6.array.find": { - "chrome": "45", - "opera": "32", - "edge": "12", - "firefox": "25", - "safari": "7.1", - "node": "4", - "deno": "1", - "ios": "8", - "samsung": "5", - "rhino": "1.7.13", - "opera_mobile": "32", - "electron": "0.31" - }, - "es6.array.find-index": { - "chrome": "45", - "opera": "32", - "edge": "12", - "firefox": "25", - "safari": "7.1", - "node": "4", - "deno": "1", - "ios": "8", - "samsung": "5", - "rhino": "1.7.13", - "opera_mobile": "32", - "electron": "0.31" - }, - "es7.array.flat-map": { - "chrome": "69", - "opera": "56", - "edge": "79", - "firefox": "62", - "safari": "12", - "node": "11", - "deno": "1", - "ios": "12", - "samsung": "10", - "rhino": "1.7.15", - "opera_mobile": "48", - "electron": "4.0" - }, - "es6.array.for-each": { - "chrome": "5", - "opera": "10.10", - "edge": "12", - "firefox": "2", - "safari": "3.1", - "node": "0.4", - "deno": "1", - "ie": "9", - "android": "4", - "ios": "6", - "phantom": "1.9", - "samsung": "1", - "rhino": "1.7.13", - "opera_mobile": "10.1", - "electron": "0.20" - }, - "es6.array.from": { - "chrome": "51", - "opera": "38", - "edge": "15", - "firefox": "36", - "safari": "10", - "node": "6.5", - "deno": "1", - "ios": "10", - "samsung": "5", - "rhino": "1.7.15", - "opera_mobile": "41", - "electron": "1.2" - }, - "es7.array.includes": { - "chrome": "47", - "opera": "34", - "edge": "14", - "firefox": "102", - "safari": "10", - "node": "6", - "deno": "1", - "ios": "10", - "samsung": "5", - "opera_mobile": "34", - "electron": "0.36" - }, - "es6.array.index-of": { - "chrome": "5", - "opera": "10.10", - "edge": "12", - "firefox": "2", - "safari": "3.1", - "node": "0.4", - "deno": "1", - "ie": "9", - "android": "4", - "ios": "6", - "phantom": "1.9", - "samsung": "1", - "rhino": "1.7.13", - "opera_mobile": "10.1", - "electron": "0.20" - }, - "es6.array.is-array": { - "chrome": "5", - "opera": "10.50", - "edge": "12", - "firefox": "4", - "safari": "4", - "node": "0.4", - "deno": "1", - "ie": "9", - "android": "4", - "ios": "6", - "phantom": "1.9", - "samsung": "1", - "rhino": "1.7.13", - "opera_mobile": "10.1", - "electron": "0.20" - }, - "es6.array.iterator": { - "chrome": "66", - "opera": "53", - "edge": "12", - "firefox": "60", - "safari": "9", - "node": "10", - "deno": "1", - "ios": "9", - "samsung": "9", - "rhino": "1.7.13", - "opera_mobile": "47", - "electron": "3.0" - }, - "es6.array.last-index-of": { - "chrome": "5", - "opera": "10.10", - "edge": "12", - "firefox": "2", - "safari": "3.1", - "node": "0.4", - "deno": "1", - "ie": "9", - "android": "4", - "ios": "6", - "phantom": "1.9", - "samsung": "1", - "rhino": "1.7.13", - "opera_mobile": "10.1", - "electron": "0.20" - }, - "es6.array.map": { - "chrome": "51", - "opera": "38", - "edge": "13", - "firefox": "48", - "safari": "10", - "node": "6.5", - "deno": "1", - "ios": "10", - "samsung": "5", - "opera_mobile": "41", - "electron": "1.2" - }, - "es6.array.of": { - "chrome": "45", - "opera": "32", - "edge": "12", - "firefox": "25", - "safari": "9", - "node": "4", - "deno": "1", - "ios": "9", - "samsung": "5", - "rhino": "1.7.13", - "opera_mobile": "32", - "electron": "0.31" - }, - "es6.array.reduce": { - "chrome": "5", - "opera": "10.50", - "edge": "12", - "firefox": "3", - "safari": "4", - "node": "0.4", - "deno": "1", - "ie": "9", - "android": "4", - "ios": "6", - "phantom": "1.9", - "samsung": "1", - "rhino": "1.7.13", - "opera_mobile": "10.1", - "electron": "0.20" - }, - "es6.array.reduce-right": { - "chrome": "5", - "opera": "10.50", - "edge": "12", - "firefox": "3", - "safari": "4", - "node": "0.4", - "deno": "1", - "ie": "9", - "android": "4", - "ios": "6", - "phantom": "1.9", - "samsung": "1", - "rhino": "1.7.13", - "opera_mobile": "10.1", - "electron": "0.20" - }, - "es6.array.slice": { - "chrome": "51", - "opera": "38", - "edge": "13", - "firefox": "48", - "safari": "10", - "node": "6.5", - "deno": "1", - "ios": "10", - "samsung": "5", - "opera_mobile": "41", - "electron": "1.2" - }, - "es6.array.some": { - "chrome": "5", - "opera": "10.10", - "edge": "12", - "firefox": "2", - "safari": "3.1", - "node": "0.4", - "deno": "1", - "ie": "9", - "android": "4", - "ios": "6", - "phantom": "1.9", - "samsung": "1", - "rhino": "1.7.13", - "opera_mobile": "10.1", - "electron": "0.20" - }, - "es6.array.sort": { - "chrome": "63", - "opera": "50", - "edge": "12", - "firefox": "5", - "safari": "12", - "node": "10", - "deno": "1", - "ie": "9", - "ios": "12", - "samsung": "8", - "rhino": "1.7.13", - "opera_mobile": "46", - "electron": "3.0" - }, - "es6.array.species": { - "chrome": "51", - "opera": "38", - "edge": "13", - "firefox": "48", - "safari": "10", - "node": "6.5", - "deno": "1", - "ios": "10", - "samsung": "5", - "rhino": "1.7.15", - "opera_mobile": "41", - "electron": "1.2" - }, - "es6.date.now": { - "chrome": "5", - "opera": "10.50", - "edge": "12", - "firefox": "2", - "safari": "4", - "node": "0.4", - "deno": "1", - "ie": "9", - "android": "4", - "ios": "6", - "phantom": "1.9", - "samsung": "1", - "rhino": "1.7.13", - "opera_mobile": "10.1", - "electron": "0.20" - }, - "es6.date.to-iso-string": { - "chrome": "5", - "opera": "10.50", - "edge": "12", - "firefox": "3.5", - "safari": "4", - "node": "0.4", - "deno": "1", - "ie": "9", - "android": "4", - "ios": "6", - "phantom": "1.9", - "samsung": "1", - "rhino": "1.7.13", - "opera_mobile": "10.1", - "electron": "0.20" - }, - "es6.date.to-json": { - "chrome": "5", - "opera": "12.10", - "edge": "12", - "firefox": "4", - "safari": "10", - "node": "0.4", - "deno": "1", - "ie": "9", - "android": "4", - "ios": "10", - "samsung": "1", - "rhino": "1.7.13", - "opera_mobile": "12.1", - "electron": "0.20" - }, - "es6.date.to-primitive": { - "chrome": "47", - "opera": "34", - "edge": "15", - "firefox": "44", - "safari": "10", - "node": "6", - "deno": "1", - "ios": "10", - "samsung": "5", - "opera_mobile": "34", - "electron": "0.36" - }, - "es6.date.to-string": { - "chrome": "5", - "opera": "10.50", - "edge": "12", - "firefox": "2", - "safari": "3.1", - "node": "0.4", - "deno": "1", - "ie": "10", - "android": "4", - "ios": "6", - "phantom": "1.9", - "samsung": "1", - "rhino": "1.7.13", - "opera_mobile": "10.1", - "electron": "0.20" - }, - "es6.function.bind": { - "chrome": "7", - "opera": "12", - "edge": "12", - "firefox": "4", - "safari": "5.1", - "node": "0.4", - "deno": "1", - "ie": "9", - "android": "4", - "ios": "6", - "phantom": "1.9", - "samsung": "1", - "rhino": "1.7.13", - "opera_mobile": "12", - "electron": "0.20" - }, - "es6.function.has-instance": { - "chrome": "51", - "opera": "38", - "edge": "15", - "firefox": "50", - "safari": "10", - "node": "6.5", - "deno": "1", - "ios": "10", - "samsung": "5", - "opera_mobile": "41", - "electron": "1.2" - }, - "es6.function.name": { - "chrome": "5", - "opera": "10.50", - "edge": "14", - "firefox": "2", - "safari": "4", - "node": "0.4", - "deno": "1", - "android": "4", - "ios": "6", - "phantom": "1.9", - "samsung": "1", - "rhino": "1.7.13", - "opera_mobile": "10.1", - "electron": "0.20" - }, - "es6.map": { - "chrome": "51", - "opera": "38", - "edge": "15", - "firefox": "53", - "safari": "10", - "node": "6.5", - "deno": "1", - "ios": "10", - "samsung": "5", - "opera_mobile": "41", - "electron": "1.2" - }, - "es6.math.acosh": { - "chrome": "38", - "opera": "25", - "edge": "12", - "firefox": "25", - "safari": "7.1", - "node": "0.12", - "deno": "1", - "ios": "8", - "samsung": "3", - "rhino": "1.7.13", - "opera_mobile": "25", - "electron": "0.20" - }, - "es6.math.asinh": { - "chrome": "38", - "opera": "25", - "edge": "12", - "firefox": "25", - "safari": "7.1", - "node": "0.12", - "deno": "1", - "ios": "8", - "samsung": "3", - "rhino": "1.7.13", - "opera_mobile": "25", - "electron": "0.20" - }, - "es6.math.atanh": { - "chrome": "38", - "opera": "25", - "edge": "12", - "firefox": "25", - "safari": "7.1", - "node": "0.12", - "deno": "1", - "ios": "8", - "samsung": "3", - "rhino": "1.7.13", - "opera_mobile": "25", - "electron": "0.20" - }, - "es6.math.cbrt": { - "chrome": "38", - "opera": "25", - "edge": "12", - "firefox": "25", - "safari": "7.1", - "node": "0.12", - "deno": "1", - "ios": "8", - "samsung": "3", - "rhino": "1.7.13", - "opera_mobile": "25", - "electron": "0.20" - }, - "es6.math.clz32": { - "chrome": "38", - "opera": "25", - "edge": "12", - "firefox": "31", - "safari": "9", - "node": "0.12", - "deno": "1", - "ios": "9", - "samsung": "3", - "rhino": "1.7.13", - "opera_mobile": "25", - "electron": "0.20" - }, - "es6.math.cosh": { - "chrome": "38", - "opera": "25", - "edge": "12", - "firefox": "25", - "safari": "7.1", - "node": "0.12", - "deno": "1", - "ios": "8", - "samsung": "3", - "rhino": "1.7.13", - "opera_mobile": "25", - "electron": "0.20" - }, - "es6.math.expm1": { - "chrome": "38", - "opera": "25", - "edge": "12", - "firefox": "25", - "safari": "7.1", - "node": "0.12", - "deno": "1", - "ios": "8", - "samsung": "3", - "rhino": "1.7.13", - "opera_mobile": "25", - "electron": "0.20" - }, - "es6.math.fround": { - "chrome": "38", - "opera": "25", - "edge": "12", - "firefox": "26", - "safari": "7.1", - "node": "0.12", - "deno": "1", - "ios": "8", - "samsung": "3", - "rhino": "1.7.13", - "opera_mobile": "25", - "electron": "0.20" - }, - "es6.math.hypot": { - "chrome": "38", - "opera": "25", - "edge": "12", - "firefox": "27", - "safari": "7.1", - "node": "0.12", - "deno": "1", - "ios": "8", - "samsung": "3", - "rhino": "1.7.13", - "opera_mobile": "25", - "electron": "0.20" - }, - "es6.math.imul": { - "chrome": "30", - "opera": "17", - "edge": "12", - "firefox": "23", - "safari": "7", - "node": "0.12", - "deno": "1", - "android": "4.4", - "ios": "7", - "samsung": "2", - "rhino": "1.7.13", - "opera_mobile": "18", - "electron": "0.20" - }, - "es6.math.log1p": { - "chrome": "38", - "opera": "25", - "edge": "12", - "firefox": "25", - "safari": "7.1", - "node": "0.12", - "deno": "1", - "ios": "8", - "samsung": "3", - "rhino": "1.7.13", - "opera_mobile": "25", - "electron": "0.20" - }, - "es6.math.log10": { - "chrome": "38", - "opera": "25", - "edge": "12", - "firefox": "25", - "safari": "7.1", - "node": "0.12", - "deno": "1", - "ios": "8", - "samsung": "3", - "rhino": "1.7.13", - "opera_mobile": "25", - "electron": "0.20" - }, - "es6.math.log2": { - "chrome": "38", - "opera": "25", - "edge": "12", - "firefox": "25", - "safari": "7.1", - "node": "0.12", - "deno": "1", - "ios": "8", - "samsung": "3", - "rhino": "1.7.13", - "opera_mobile": "25", - "electron": "0.20" - }, - "es6.math.sign": { - "chrome": "38", - "opera": "25", - "edge": "12", - "firefox": "25", - "safari": "9", - "node": "0.12", - "deno": "1", - "ios": "9", - "samsung": "3", - "rhino": "1.7.13", - "opera_mobile": "25", - "electron": "0.20" - }, - "es6.math.sinh": { - "chrome": "38", - "opera": "25", - "edge": "12", - "firefox": "25", - "safari": "7.1", - "node": "0.12", - "deno": "1", - "ios": "8", - "samsung": "3", - "rhino": "1.7.13", - "opera_mobile": "25", - "electron": "0.20" - }, - "es6.math.tanh": { - "chrome": "38", - "opera": "25", - "edge": "12", - "firefox": "25", - "safari": "7.1", - "node": "0.12", - "deno": "1", - "ios": "8", - "samsung": "3", - "rhino": "1.7.13", - "opera_mobile": "25", - "electron": "0.20" - }, - "es6.math.trunc": { - "chrome": "38", - "opera": "25", - "edge": "12", - "firefox": "25", - "safari": "7.1", - "node": "0.12", - "deno": "1", - "ios": "8", - "samsung": "3", - "rhino": "1.7.13", - "opera_mobile": "25", - "electron": "0.20" - }, - "es6.number.constructor": { - "chrome": "41", - "opera": "28", - "edge": "12", - "firefox": "36", - "safari": "9", - "node": "4", - "deno": "1", - "ios": "9", - "samsung": "3.4", - "rhino": "1.7.13", - "opera_mobile": "28", - "electron": "0.21" - }, - "es6.number.epsilon": { - "chrome": "34", - "opera": "21", - "edge": "12", - "firefox": "25", - "safari": "9", - "node": "0.12", - "deno": "1", - "ios": "9", - "samsung": "2", - "rhino": "1.7.14", - "opera_mobile": "21", - "electron": "0.20" - }, - "es6.number.is-finite": { - "chrome": "19", - "opera": "15", - "edge": "12", - "firefox": "16", - "safari": "9", - "node": "0.8", - "deno": "1", - "android": "4.1", - "ios": "9", - "samsung": "1.5", - "rhino": "1.7.13", - "opera_mobile": "14", - "electron": "0.20" - }, - "es6.number.is-integer": { - "chrome": "34", - "opera": "21", - "edge": "12", - "firefox": "16", - "safari": "9", - "node": "0.12", - "deno": "1", - "ios": "9", - "samsung": "2", - "rhino": "1.7.13", - "opera_mobile": "21", - "electron": "0.20" - }, - "es6.number.is-nan": { - "chrome": "19", - "opera": "15", - "edge": "12", - "firefox": "15", - "safari": "9", - "node": "0.8", - "deno": "1", - "android": "4.1", - "ios": "9", - "samsung": "1.5", - "rhino": "1.7.13", - "opera_mobile": "14", - "electron": "0.20" - }, - "es6.number.is-safe-integer": { - "chrome": "34", - "opera": "21", - "edge": "12", - "firefox": "32", - "safari": "9", - "node": "0.12", - "deno": "1", - "ios": "9", - "samsung": "2", - "rhino": "1.7.13", - "opera_mobile": "21", - "electron": "0.20" - }, - "es6.number.max-safe-integer": { - "chrome": "34", - "opera": "21", - "edge": "12", - "firefox": "31", - "safari": "9", - "node": "0.12", - "deno": "1", - "ios": "9", - "samsung": "2", - "rhino": "1.7.13", - "opera_mobile": "21", - "electron": "0.20" - }, - "es6.number.min-safe-integer": { - "chrome": "34", - "opera": "21", - "edge": "12", - "firefox": "31", - "safari": "9", - "node": "0.12", - "deno": "1", - "ios": "9", - "samsung": "2", - "rhino": "1.7.13", - "opera_mobile": "21", - "electron": "0.20" - }, - "es6.number.parse-float": { - "chrome": "34", - "opera": "21", - "edge": "12", - "firefox": "25", - "safari": "9", - "node": "0.12", - "deno": "1", - "ios": "9", - "samsung": "2", - "rhino": "1.7.14", - "opera_mobile": "21", - "electron": "0.20" - }, - "es6.number.parse-int": { - "chrome": "34", - "opera": "21", - "edge": "12", - "firefox": "25", - "safari": "9", - "node": "0.12", - "deno": "1", - "ios": "9", - "samsung": "2", - "rhino": "1.7.14", - "opera_mobile": "21", - "electron": "0.20" - }, - "es6.object.assign": { - "chrome": "49", - "opera": "36", - "edge": "13", - "firefox": "36", - "safari": "10", - "node": "6", - "deno": "1", - "ios": "10", - "samsung": "5", - "opera_mobile": "36", - "electron": "0.37" - }, - "es6.object.create": { - "chrome": "5", - "opera": "12", - "edge": "12", - "firefox": "4", - "safari": "4", - "node": "0.4", - "deno": "1", - "ie": "9", - "android": "4", - "ios": "6", - "phantom": "1.9", - "samsung": "1", - "rhino": "1.7.13", - "opera_mobile": "12", - "electron": "0.20" - }, - "es7.object.define-getter": { - "chrome": "62", - "opera": "49", - "edge": "16", - "firefox": "48", - "safari": "9", - "node": "8.10", - "deno": "1", - "ios": "9", - "samsung": "8", - "opera_mobile": "46", - "electron": "3.0" - }, - "es7.object.define-setter": { - "chrome": "62", - "opera": "49", - "edge": "16", - "firefox": "48", - "safari": "9", - "node": "8.10", - "deno": "1", - "ios": "9", - "samsung": "8", - "opera_mobile": "46", - "electron": "3.0" - }, - "es6.object.define-property": { - "chrome": "5", - "opera": "12", - "edge": "12", - "firefox": "4", - "safari": "5.1", - "node": "0.4", - "deno": "1", - "ie": "9", - "android": "4", - "ios": "6", - "phantom": "1.9", - "samsung": "1", - "rhino": "1.7.13", - "opera_mobile": "12", - "electron": "0.20" - }, - "es6.object.define-properties": { - "chrome": "5", - "opera": "12", - "edge": "12", - "firefox": "4", - "safari": "4", - "node": "0.4", - "deno": "1", - "ie": "9", - "android": "4", - "ios": "6", - "phantom": "1.9", - "samsung": "1", - "rhino": "1.7.13", - "opera_mobile": "12", - "electron": "0.20" - }, - "es7.object.entries": { - "chrome": "54", - "opera": "41", - "edge": "14", - "firefox": "47", - "safari": "10.1", - "node": "7", - "deno": "1", - "ios": "10.3", - "samsung": "6", - "rhino": "1.7.14", - "opera_mobile": "41", - "electron": "1.4" - }, - "es6.object.freeze": { - "chrome": "44", - "opera": "31", - "edge": "12", - "firefox": "35", - "safari": "9", - "node": "4", - "deno": "1", - "ios": "9", - "samsung": "4", - "rhino": "1.7.13", - "opera_mobile": "32", - "electron": "0.30" - }, - "es6.object.get-own-property-descriptor": { - "chrome": "44", - "opera": "31", - "edge": "12", - "firefox": "35", - "safari": "9", - "node": "4", - "deno": "1", - "ios": "9", - "samsung": "4", - "rhino": "1.7.13", - "opera_mobile": "32", - "electron": "0.30" - }, - "es7.object.get-own-property-descriptors": { - "chrome": "54", - "opera": "41", - "edge": "15", - "firefox": "50", - "safari": "10.1", - "node": "7", - "deno": "1", - "ios": "10.3", - "samsung": "6", - "opera_mobile": "41", - "electron": "1.4" - }, - "es6.object.get-own-property-names": { - "chrome": "40", - "opera": "27", - "edge": "12", - "firefox": "33", - "safari": "9", - "node": "4", - "deno": "1", - "ios": "9", - "samsung": "3.4", - "rhino": "1.7.13", - "opera_mobile": "27", - "electron": "0.21" - }, - "es6.object.get-prototype-of": { - "chrome": "44", - "opera": "31", - "edge": "12", - "firefox": "35", - "safari": "9", - "node": "4", - "deno": "1", - "ios": "9", - "samsung": "4", - "rhino": "1.7.13", - "opera_mobile": "32", - "electron": "0.30" - }, - "es7.object.lookup-getter": { - "chrome": "62", - "opera": "49", - "edge": "79", - "firefox": "36", - "safari": "9", - "node": "8.10", - "deno": "1", - "ios": "9", - "samsung": "8", - "opera_mobile": "46", - "electron": "3.0" - }, - "es7.object.lookup-setter": { - "chrome": "62", - "opera": "49", - "edge": "79", - "firefox": "36", - "safari": "9", - "node": "8.10", - "deno": "1", - "ios": "9", - "samsung": "8", - "opera_mobile": "46", - "electron": "3.0" - }, - "es6.object.prevent-extensions": { - "chrome": "44", - "opera": "31", - "edge": "12", - "firefox": "35", - "safari": "9", - "node": "4", - "deno": "1", - "ios": "9", - "samsung": "4", - "rhino": "1.7.13", - "opera_mobile": "32", - "electron": "0.30" - }, - "es6.object.to-string": { - "chrome": "57", - "opera": "44", - "edge": "15", - "firefox": "51", - "safari": "10", - "node": "8", - "deno": "1", - "ios": "10", - "samsung": "7", - "opera_mobile": "43", - "electron": "1.7" - }, - "es6.object.is": { - "chrome": "19", - "opera": "15", - "edge": "12", - "firefox": "22", - "safari": "9", - "node": "0.8", - "deno": "1", - "android": "4.1", - "ios": "9", - "samsung": "1.5", - "rhino": "1.7.13", - "opera_mobile": "14", - "electron": "0.20" - }, - "es6.object.is-frozen": { - "chrome": "44", - "opera": "31", - "edge": "12", - "firefox": "35", - "safari": "9", - "node": "4", - "deno": "1", - "ios": "9", - "samsung": "4", - "rhino": "1.7.13", - "opera_mobile": "32", - "electron": "0.30" - }, - "es6.object.is-sealed": { - "chrome": "44", - "opera": "31", - "edge": "12", - "firefox": "35", - "safari": "9", - "node": "4", - "deno": "1", - "ios": "9", - "samsung": "4", - "rhino": "1.7.13", - "opera_mobile": "32", - "electron": "0.30" - }, - "es6.object.is-extensible": { - "chrome": "44", - "opera": "31", - "edge": "12", - "firefox": "35", - "safari": "9", - "node": "4", - "deno": "1", - "ios": "9", - "samsung": "4", - "rhino": "1.7.13", - "opera_mobile": "32", - "electron": "0.30" - }, - "es6.object.keys": { - "chrome": "40", - "opera": "27", - "edge": "12", - "firefox": "35", - "safari": "9", - "node": "4", - "deno": "1", - "ios": "9", - "samsung": "3.4", - "rhino": "1.7.13", - "opera_mobile": "27", - "electron": "0.21" - }, - "es6.object.seal": { - "chrome": "44", - "opera": "31", - "edge": "12", - "firefox": "35", - "safari": "9", - "node": "4", - "deno": "1", - "ios": "9", - "samsung": "4", - "rhino": "1.7.13", - "opera_mobile": "32", - "electron": "0.30" - }, - "es6.object.set-prototype-of": { - "chrome": "34", - "opera": "21", - "edge": "12", - "firefox": "31", - "safari": "9", - "node": "0.12", - "deno": "1", - "ie": "11", - "ios": "9", - "samsung": "2", - "rhino": "1.7.13", - "opera_mobile": "21", - "electron": "0.20" - }, - "es7.object.values": { - "chrome": "54", - "opera": "41", - "edge": "14", - "firefox": "47", - "safari": "10.1", - "node": "7", - "deno": "1", - "ios": "10.3", - "samsung": "6", - "rhino": "1.7.14", - "opera_mobile": "41", - "electron": "1.4" - }, - "es6.promise": { - "chrome": "51", - "opera": "38", - "edge": "14", - "firefox": "45", - "safari": "10", - "node": "6.5", - "deno": "1", - "ios": "10", - "samsung": "5", - "rhino": "1.7.15", - "opera_mobile": "41", - "electron": "1.2" - }, - "es7.promise.finally": { - "chrome": "63", - "opera": "50", - "edge": "18", - "firefox": "58", - "safari": "11.1", - "node": "10", - "deno": "1", - "ios": "11.3", - "samsung": "8", - "rhino": "1.7.15", - "opera_mobile": "46", - "electron": "3.0" - }, - "es6.reflect.apply": { - "chrome": "49", - "opera": "36", - "edge": "12", - "firefox": "42", - "safari": "10", - "node": "6", - "deno": "1", - "ios": "10", - "samsung": "5", - "opera_mobile": "36", - "electron": "0.37" - }, - "es6.reflect.construct": { - "chrome": "49", - "opera": "36", - "edge": "13", - "firefox": "49", - "safari": "10", - "node": "6", - "deno": "1", - "ios": "10", - "samsung": "5", - "opera_mobile": "36", - "electron": "0.37" - }, - "es6.reflect.define-property": { - "chrome": "49", - "opera": "36", - "edge": "13", - "firefox": "42", - "safari": "10", - "node": "6", - "deno": "1", - "ios": "10", - "samsung": "5", - "opera_mobile": "36", - "electron": "0.37" - }, - "es6.reflect.delete-property": { - "chrome": "49", - "opera": "36", - "edge": "12", - "firefox": "42", - "safari": "10", - "node": "6", - "deno": "1", - "ios": "10", - "samsung": "5", - "opera_mobile": "36", - "electron": "0.37" - }, - "es6.reflect.get": { - "chrome": "49", - "opera": "36", - "edge": "12", - "firefox": "42", - "safari": "10", - "node": "6", - "deno": "1", - "ios": "10", - "samsung": "5", - "opera_mobile": "36", - "electron": "0.37" - }, - "es6.reflect.get-own-property-descriptor": { - "chrome": "49", - "opera": "36", - "edge": "12", - "firefox": "42", - "safari": "10", - "node": "6", - "deno": "1", - "ios": "10", - "samsung": "5", - "opera_mobile": "36", - "electron": "0.37" - }, - "es6.reflect.get-prototype-of": { - "chrome": "49", - "opera": "36", - "edge": "12", - "firefox": "42", - "safari": "10", - "node": "6", - "deno": "1", - "ios": "10", - "samsung": "5", - "opera_mobile": "36", - "electron": "0.37" - }, - "es6.reflect.has": { - "chrome": "49", - "opera": "36", - "edge": "12", - "firefox": "42", - "safari": "10", - "node": "6", - "deno": "1", - "ios": "10", - "samsung": "5", - "opera_mobile": "36", - "electron": "0.37" - }, - "es6.reflect.is-extensible": { - "chrome": "49", - "opera": "36", - "edge": "12", - "firefox": "42", - "safari": "10", - "node": "6", - "deno": "1", - "ios": "10", - "samsung": "5", - "opera_mobile": "36", - "electron": "0.37" - }, - "es6.reflect.own-keys": { - "chrome": "49", - "opera": "36", - "edge": "12", - "firefox": "42", - "safari": "10", - "node": "6", - "deno": "1", - "ios": "10", - "samsung": "5", - "opera_mobile": "36", - "electron": "0.37" - }, - "es6.reflect.prevent-extensions": { - "chrome": "49", - "opera": "36", - "edge": "12", - "firefox": "42", - "safari": "10", - "node": "6", - "deno": "1", - "ios": "10", - "samsung": "5", - "opera_mobile": "36", - "electron": "0.37" - }, - "es6.reflect.set": { - "chrome": "49", - "opera": "36", - "edge": "12", - "firefox": "42", - "safari": "10", - "node": "6", - "deno": "1", - "ios": "10", - "samsung": "5", - "opera_mobile": "36", - "electron": "0.37" - }, - "es6.reflect.set-prototype-of": { - "chrome": "49", - "opera": "36", - "edge": "12", - "firefox": "42", - "safari": "10", - "node": "6", - "deno": "1", - "ios": "10", - "samsung": "5", - "opera_mobile": "36", - "electron": "0.37" - }, - "es6.regexp.constructor": { - "chrome": "50", - "opera": "37", - "edge": "79", - "firefox": "40", - "safari": "10", - "node": "6", - "deno": "1", - "ios": "10", - "samsung": "5", - "opera_mobile": "37", - "electron": "1.1" - }, - "es6.regexp.flags": { - "chrome": "49", - "opera": "36", - "edge": "79", - "firefox": "37", - "safari": "9", - "node": "6", - "deno": "1", - "ios": "9", - "samsung": "5", - "rhino": "1.7.15", - "opera_mobile": "36", - "electron": "0.37" - }, - "es6.regexp.match": { - "chrome": "50", - "opera": "37", - "edge": "79", - "firefox": "49", - "safari": "10", - "node": "6", - "deno": "1", - "ios": "10", - "samsung": "5", - "rhino": "1.7.13", - "opera_mobile": "37", - "electron": "1.1" - }, - "es6.regexp.replace": { - "chrome": "50", - "opera": "37", - "edge": "79", - "firefox": "49", - "safari": "10", - "node": "6", - "deno": "1", - "ios": "10", - "samsung": "5", - "opera_mobile": "37", - "electron": "1.1" - }, - "es6.regexp.split": { - "chrome": "50", - "opera": "37", - "edge": "79", - "firefox": "49", - "safari": "10", - "node": "6", - "deno": "1", - "ios": "10", - "samsung": "5", - "opera_mobile": "37", - "electron": "1.1" - }, - "es6.regexp.search": { - "chrome": "50", - "opera": "37", - "edge": "79", - "firefox": "49", - "safari": "10", - "node": "6", - "deno": "1", - "ios": "10", - "samsung": "5", - "rhino": "1.7.13", - "opera_mobile": "37", - "electron": "1.1" - }, - "es6.regexp.to-string": { - "chrome": "50", - "opera": "37", - "edge": "79", - "firefox": "39", - "safari": "10", - "node": "6", - "deno": "1", - "ios": "10", - "samsung": "5", - "rhino": "1.7.15", - "opera_mobile": "37", - "electron": "1.1" - }, - "es6.set": { - "chrome": "51", - "opera": "38", - "edge": "15", - "firefox": "53", - "safari": "10", - "node": "6.5", - "deno": "1", - "ios": "10", - "samsung": "5", - "opera_mobile": "41", - "electron": "1.2" - }, - "es6.symbol": { - "chrome": "51", - "opera": "38", - "edge": "79", - "firefox": "51", - "safari": "10", - "node": "6.5", - "deno": "1", - "ios": "10", - "samsung": "5", - "opera_mobile": "41", - "electron": "1.2" - }, - "es7.symbol.async-iterator": { - "chrome": "63", - "opera": "50", - "edge": "79", - "firefox": "57", - "safari": "12", - "node": "10", - "deno": "1", - "ios": "12", - "samsung": "8", - "opera_mobile": "46", - "electron": "3.0" - }, - "es6.string.anchor": { - "chrome": "5", - "opera": "15", - "edge": "12", - "firefox": "17", - "safari": "6", - "node": "0.4", - "deno": "1", - "android": "4", - "ios": "7", - "phantom": "1.9", - "samsung": "1", - "rhino": "1.7.14", - "opera_mobile": "14", - "electron": "0.20" - }, - "es6.string.big": { - "chrome": "5", - "opera": "15", - "edge": "12", - "firefox": "17", - "safari": "6", - "node": "0.4", - "deno": "1", - "android": "4", - "ios": "7", - "phantom": "1.9", - "samsung": "1", - "rhino": "1.7.14", - "opera_mobile": "14", - "electron": "0.20" - }, - "es6.string.blink": { - "chrome": "5", - "opera": "15", - "edge": "12", - "firefox": "17", - "safari": "6", - "node": "0.4", - "deno": "1", - "android": "4", - "ios": "7", - "phantom": "1.9", - "samsung": "1", - "rhino": "1.7.14", - "opera_mobile": "14", - "electron": "0.20" - }, - "es6.string.bold": { - "chrome": "5", - "opera": "15", - "edge": "12", - "firefox": "17", - "safari": "6", - "node": "0.4", - "deno": "1", - "android": "4", - "ios": "7", - "phantom": "1.9", - "samsung": "1", - "rhino": "1.7.14", - "opera_mobile": "14", - "electron": "0.20" - }, - "es6.string.code-point-at": { - "chrome": "41", - "opera": "28", - "edge": "12", - "firefox": "29", - "safari": "9", - "node": "4", - "deno": "1", - "ios": "9", - "samsung": "3.4", - "rhino": "1.7.13", - "opera_mobile": "28", - "electron": "0.21" - }, - "es6.string.ends-with": { - "chrome": "41", - "opera": "28", - "edge": "12", - "firefox": "29", - "safari": "9", - "node": "4", - "deno": "1", - "ios": "9", - "samsung": "3.4", - "rhino": "1.7.13", - "opera_mobile": "28", - "electron": "0.21" - }, - "es6.string.fixed": { - "chrome": "5", - "opera": "15", - "edge": "12", - "firefox": "17", - "safari": "6", - "node": "0.4", - "deno": "1", - "android": "4", - "ios": "7", - "phantom": "1.9", - "samsung": "1", - "rhino": "1.7.14", - "opera_mobile": "14", - "electron": "0.20" - }, - "es6.string.fontcolor": { - "chrome": "5", - "opera": "15", - "edge": "12", - "firefox": "17", - "safari": "6", - "node": "0.4", - "deno": "1", - "android": "4", - "ios": "7", - "phantom": "1.9", - "samsung": "1", - "rhino": "1.7.14", - "opera_mobile": "14", - "electron": "0.20" - }, - "es6.string.fontsize": { - "chrome": "5", - "opera": "15", - "edge": "12", - "firefox": "17", - "safari": "6", - "node": "0.4", - "deno": "1", - "android": "4", - "ios": "7", - "phantom": "1.9", - "samsung": "1", - "rhino": "1.7.14", - "opera_mobile": "14", - "electron": "0.20" - }, - "es6.string.from-code-point": { - "chrome": "41", - "opera": "28", - "edge": "12", - "firefox": "29", - "safari": "9", - "node": "4", - "deno": "1", - "ios": "9", - "samsung": "3.4", - "rhino": "1.7.13", - "opera_mobile": "28", - "electron": "0.21" - }, - "es6.string.includes": { - "chrome": "41", - "opera": "28", - "edge": "12", - "firefox": "40", - "safari": "9", - "node": "4", - "deno": "1", - "ios": "9", - "samsung": "3.4", - "rhino": "1.7.13", - "opera_mobile": "28", - "electron": "0.21" - }, - "es6.string.italics": { - "chrome": "5", - "opera": "15", - "edge": "12", - "firefox": "17", - "safari": "6", - "node": "0.4", - "deno": "1", - "android": "4", - "ios": "7", - "phantom": "1.9", - "samsung": "1", - "rhino": "1.7.14", - "opera_mobile": "14", - "electron": "0.20" - }, - "es6.string.iterator": { - "chrome": "38", - "opera": "25", - "edge": "12", - "firefox": "36", - "safari": "9", - "node": "0.12", - "deno": "1", - "ios": "9", - "samsung": "3", - "rhino": "1.7.13", - "opera_mobile": "25", - "electron": "0.20" - }, - "es6.string.link": { - "chrome": "5", - "opera": "15", - "edge": "12", - "firefox": "17", - "safari": "6", - "node": "0.4", - "deno": "1", - "android": "4", - "ios": "7", - "phantom": "1.9", - "samsung": "1", - "rhino": "1.7.14", - "opera_mobile": "14", - "electron": "0.20" - }, - "es7.string.pad-start": { - "chrome": "57", - "opera": "44", - "edge": "15", - "firefox": "48", - "safari": "10", - "node": "8", - "deno": "1", - "ios": "10", - "samsung": "7", - "rhino": "1.7.13", - "opera_mobile": "43", - "electron": "1.7" - }, - "es7.string.pad-end": { - "chrome": "57", - "opera": "44", - "edge": "15", - "firefox": "48", - "safari": "10", - "node": "8", - "deno": "1", - "ios": "10", - "samsung": "7", - "rhino": "1.7.13", - "opera_mobile": "43", - "electron": "1.7" - }, - "es6.string.raw": { - "chrome": "41", - "opera": "28", - "edge": "12", - "firefox": "34", - "safari": "9", - "node": "4", - "deno": "1", - "ios": "9", - "samsung": "3.4", - "rhino": "1.7.14", - "opera_mobile": "28", - "electron": "0.21" - }, - "es6.string.repeat": { - "chrome": "41", - "opera": "28", - "edge": "12", - "firefox": "24", - "safari": "9", - "node": "4", - "deno": "1", - "ios": "9", - "samsung": "3.4", - "rhino": "1.7.13", - "opera_mobile": "28", - "electron": "0.21" - }, - "es6.string.small": { - "chrome": "5", - "opera": "15", - "edge": "12", - "firefox": "17", - "safari": "6", - "node": "0.4", - "deno": "1", - "android": "4", - "ios": "7", - "phantom": "1.9", - "samsung": "1", - "rhino": "1.7.14", - "opera_mobile": "14", - "electron": "0.20" - }, - "es6.string.starts-with": { - "chrome": "41", - "opera": "28", - "edge": "12", - "firefox": "29", - "safari": "9", - "node": "4", - "deno": "1", - "ios": "9", - "samsung": "3.4", - "rhino": "1.7.13", - "opera_mobile": "28", - "electron": "0.21" - }, - "es6.string.strike": { - "chrome": "5", - "opera": "15", - "edge": "12", - "firefox": "17", - "safari": "6", - "node": "0.4", - "deno": "1", - "android": "4", - "ios": "7", - "phantom": "1.9", - "samsung": "1", - "rhino": "1.7.14", - "opera_mobile": "14", - "electron": "0.20" - }, - "es6.string.sub": { - "chrome": "5", - "opera": "15", - "edge": "12", - "firefox": "17", - "safari": "6", - "node": "0.4", - "deno": "1", - "android": "4", - "ios": "7", - "phantom": "1.9", - "samsung": "1", - "rhino": "1.7.14", - "opera_mobile": "14", - "electron": "0.20" - }, - "es6.string.sup": { - "chrome": "5", - "opera": "15", - "edge": "12", - "firefox": "17", - "safari": "6", - "node": "0.4", - "deno": "1", - "android": "4", - "ios": "7", - "phantom": "1.9", - "samsung": "1", - "rhino": "1.7.14", - "opera_mobile": "14", - "electron": "0.20" - }, - "es6.string.trim": { - "chrome": "5", - "opera": "10.50", - "edge": "12", - "firefox": "3.5", - "safari": "4", - "node": "0.4", - "deno": "1", - "ie": "9", - "android": "4", - "ios": "6", - "phantom": "1.9", - "samsung": "1", - "rhino": "1.7.13", - "opera_mobile": "10.1", - "electron": "0.20" - }, - "es7.string.trim-left": { - "chrome": "66", - "opera": "53", - "edge": "79", - "firefox": "61", - "safari": "12", - "node": "10", - "deno": "1", - "ios": "12", - "samsung": "9", - "rhino": "1.7.13", - "opera_mobile": "47", - "electron": "3.0" - }, - "es7.string.trim-right": { - "chrome": "66", - "opera": "53", - "edge": "79", - "firefox": "61", - "safari": "12", - "node": "10", - "deno": "1", - "ios": "12", - "samsung": "9", - "rhino": "1.7.13", - "opera_mobile": "47", - "electron": "3.0" - }, - "es6.typed.array-buffer": { - "chrome": "51", - "opera": "38", - "edge": "13", - "firefox": "48", - "safari": "10", - "node": "6.5", - "deno": "1", - "ios": "10", - "samsung": "5", - "opera_mobile": "41", - "electron": "1.2" - }, - "es6.typed.data-view": { - "chrome": "5", - "opera": "12", - "edge": "12", - "firefox": "15", - "safari": "5.1", - "node": "0.4", - "deno": "1", - "ie": "10", - "android": "4", - "ios": "6", - "phantom": "1.9", - "samsung": "1", - "rhino": "1.7.13", - "opera_mobile": "12", - "electron": "0.20" - }, - "es6.typed.int8-array": { - "chrome": "51", - "opera": "38", - "edge": "13", - "firefox": "48", - "safari": "10", - "node": "6.5", - "deno": "1", - "ios": "10", - "samsung": "5", - "opera_mobile": "41", - "electron": "1.2" - }, - "es6.typed.uint8-array": { - "chrome": "51", - "opera": "38", - "edge": "13", - "firefox": "48", - "safari": "10", - "node": "6.5", - "deno": "1", - "ios": "10", - "samsung": "5", - "opera_mobile": "41", - "electron": "1.2" - }, - "es6.typed.uint8-clamped-array": { - "chrome": "51", - "opera": "38", - "edge": "13", - "firefox": "48", - "safari": "10", - "node": "6.5", - "deno": "1", - "ios": "10", - "samsung": "5", - "opera_mobile": "41", - "electron": "1.2" - }, - "es6.typed.int16-array": { - "chrome": "51", - "opera": "38", - "edge": "13", - "firefox": "48", - "safari": "10", - "node": "6.5", - "deno": "1", - "ios": "10", - "samsung": "5", - "opera_mobile": "41", - "electron": "1.2" - }, - "es6.typed.uint16-array": { - "chrome": "51", - "opera": "38", - "edge": "13", - "firefox": "48", - "safari": "10", - "node": "6.5", - "deno": "1", - "ios": "10", - "samsung": "5", - "opera_mobile": "41", - "electron": "1.2" - }, - "es6.typed.int32-array": { - "chrome": "51", - "opera": "38", - "edge": "13", - "firefox": "48", - "safari": "10", - "node": "6.5", - "deno": "1", - "ios": "10", - "samsung": "5", - "opera_mobile": "41", - "electron": "1.2" - }, - "es6.typed.uint32-array": { - "chrome": "51", - "opera": "38", - "edge": "13", - "firefox": "48", - "safari": "10", - "node": "6.5", - "deno": "1", - "ios": "10", - "samsung": "5", - "opera_mobile": "41", - "electron": "1.2" - }, - "es6.typed.float32-array": { - "chrome": "51", - "opera": "38", - "edge": "13", - "firefox": "48", - "safari": "10", - "node": "6.5", - "deno": "1", - "ios": "10", - "samsung": "5", - "opera_mobile": "41", - "electron": "1.2" - }, - "es6.typed.float64-array": { - "chrome": "51", - "opera": "38", - "edge": "13", - "firefox": "48", - "safari": "10", - "node": "6.5", - "deno": "1", - "ios": "10", - "samsung": "5", - "opera_mobile": "41", - "electron": "1.2" - }, - "es6.weak-map": { - "chrome": "51", - "opera": "38", - "edge": "15", - "firefox": "53", - "safari": "9", - "node": "6.5", - "deno": "1", - "ios": "9", - "samsung": "5", - "rhino": "1.7.15", - "opera_mobile": "41", - "electron": "1.2" - }, - "es6.weak-set": { - "chrome": "51", - "opera": "38", - "edge": "15", - "firefox": "53", - "safari": "9", - "node": "6.5", - "deno": "1", - "ios": "9", - "samsung": "5", - "rhino": "1.7.15", - "opera_mobile": "41", - "electron": "1.2" - } -} diff --git a/tools/eslint/node_modules/@babel/compat-data/data/corejs3-shipped-proposals.json b/tools/eslint/node_modules/@babel/compat-data/data/corejs3-shipped-proposals.json deleted file mode 100644 index d03b698ff0c18a..00000000000000 --- a/tools/eslint/node_modules/@babel/compat-data/data/corejs3-shipped-proposals.json +++ /dev/null @@ -1,5 +0,0 @@ -[ - "esnext.promise.all-settled", - "esnext.string.match-all", - "esnext.global-this" -] diff --git a/tools/eslint/node_modules/@babel/compat-data/data/native-modules.json b/tools/eslint/node_modules/@babel/compat-data/data/native-modules.json deleted file mode 100644 index 2328d2138bd513..00000000000000 --- a/tools/eslint/node_modules/@babel/compat-data/data/native-modules.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "es6.module": { - "chrome": "61", - "and_chr": "61", - "edge": "16", - "firefox": "60", - "and_ff": "60", - "node": "13.2.0", - "opera": "48", - "op_mob": "45", - "safari": "10.1", - "ios": "10.3", - "samsung": "8.2", - "android": "61", - "electron": "2.0", - "ios_saf": "10.3" - } -} diff --git a/tools/eslint/node_modules/@babel/compat-data/data/overlapping-plugins.json b/tools/eslint/node_modules/@babel/compat-data/data/overlapping-plugins.json deleted file mode 100644 index 0722826136b239..00000000000000 --- a/tools/eslint/node_modules/@babel/compat-data/data/overlapping-plugins.json +++ /dev/null @@ -1,33 +0,0 @@ -{ - "transform-async-to-generator": [ - "bugfix/transform-async-arrows-in-class" - ], - "transform-parameters": [ - "bugfix/transform-edge-default-parameters", - "bugfix/transform-safari-id-destructuring-collision-in-function-expression" - ], - "transform-function-name": [ - "bugfix/transform-edge-function-name" - ], - "transform-block-scoping": [ - "bugfix/transform-safari-block-shadowing", - "bugfix/transform-safari-for-shadowing" - ], - "transform-template-literals": [ - "bugfix/transform-tagged-template-caching" - ], - "transform-optional-chaining": [ - "bugfix/transform-v8-spread-parameters-in-optional-chaining" - ], - "proposal-optional-chaining": [ - "bugfix/transform-v8-spread-parameters-in-optional-chaining" - ], - "transform-class-properties": [ - "bugfix/transform-v8-static-class-fields-redefine-readonly", - "bugfix/transform-firefox-class-in-computed-class-key" - ], - "proposal-class-properties": [ - "bugfix/transform-v8-static-class-fields-redefine-readonly", - "bugfix/transform-firefox-class-in-computed-class-key" - ] -} diff --git a/tools/eslint/node_modules/@babel/compat-data/data/plugin-bugfixes.json b/tools/eslint/node_modules/@babel/compat-data/data/plugin-bugfixes.json deleted file mode 100644 index 55b56021388532..00000000000000 --- a/tools/eslint/node_modules/@babel/compat-data/data/plugin-bugfixes.json +++ /dev/null @@ -1,213 +0,0 @@ -{ - "bugfix/transform-async-arrows-in-class": { - "chrome": "55", - "opera": "42", - "edge": "15", - "firefox": "52", - "safari": "11", - "node": "7.6", - "deno": "1", - "ios": "11", - "samsung": "6", - "opera_mobile": "42", - "electron": "1.6" - }, - "bugfix/transform-edge-default-parameters": { - "chrome": "49", - "opera": "36", - "edge": "18", - "firefox": "52", - "safari": "10", - "node": "6", - "deno": "1", - "ios": "10", - "samsung": "5", - "opera_mobile": "36", - "electron": "0.37" - }, - "bugfix/transform-edge-function-name": { - "chrome": "51", - "opera": "38", - "edge": "79", - "firefox": "53", - "safari": "10", - "node": "6.5", - "deno": "1", - "ios": "10", - "samsung": "5", - "opera_mobile": "41", - "electron": "1.2" - }, - "bugfix/transform-safari-block-shadowing": { - "chrome": "49", - "opera": "36", - "edge": "12", - "firefox": "44", - "safari": "11", - "node": "6", - "deno": "1", - "ie": "11", - "ios": "11", - "samsung": "5", - "opera_mobile": "36", - "electron": "0.37" - }, - "bugfix/transform-safari-for-shadowing": { - "chrome": "49", - "opera": "36", - "edge": "12", - "firefox": "4", - "safari": "11", - "node": "6", - "deno": "1", - "ie": "11", - "ios": "11", - "samsung": "5", - "rhino": "1.7.13", - "opera_mobile": "36", - "electron": "0.37" - }, - "bugfix/transform-safari-id-destructuring-collision-in-function-expression": { - "chrome": "49", - "opera": "36", - "edge": "14", - "firefox": "2", - "safari": "16.3", - "node": "6", - "deno": "1", - "ios": "16.3", - "samsung": "5", - "opera_mobile": "36", - "electron": "0.37" - }, - "bugfix/transform-tagged-template-caching": { - "chrome": "41", - "opera": "28", - "edge": "12", - "firefox": "34", - "safari": "13", - "node": "4", - "deno": "1", - "ios": "13", - "samsung": "3.4", - "rhino": "1.7.14", - "opera_mobile": "28", - "electron": "0.21" - }, - "bugfix/transform-v8-spread-parameters-in-optional-chaining": { - "chrome": "91", - "opera": "77", - "edge": "91", - "firefox": "74", - "safari": "13.1", - "node": "16.9", - "deno": "1.9", - "ios": "13.4", - "samsung": "16", - "opera_mobile": "64", - "electron": "13.0" - }, - "bugfix/transform-firefox-class-in-computed-class-key": { - "chrome": "74", - "opera": "62", - "edge": "79", - "safari": "14.1", - "node": "12", - "deno": "1", - "ios": "14.5", - "samsung": "11", - "opera_mobile": "53", - "electron": "6.0" - }, - "transform-optional-chaining": { - "chrome": "80", - "opera": "67", - "edge": "80", - "firefox": "74", - "safari": "13.1", - "node": "14", - "deno": "1", - "ios": "13.4", - "samsung": "13", - "opera_mobile": "57", - "electron": "8.0" - }, - "proposal-optional-chaining": { - "chrome": "80", - "opera": "67", - "edge": "80", - "firefox": "74", - "safari": "13.1", - "node": "14", - "deno": "1", - "ios": "13.4", - "samsung": "13", - "opera_mobile": "57", - "electron": "8.0" - }, - "transform-parameters": { - "chrome": "49", - "opera": "36", - "edge": "15", - "firefox": "53", - "safari": "10", - "node": "6", - "deno": "1", - "ios": "10", - "samsung": "5", - "opera_mobile": "36", - "electron": "0.37" - }, - "transform-async-to-generator": { - "chrome": "55", - "opera": "42", - "edge": "15", - "firefox": "52", - "safari": "10.1", - "node": "7.6", - "deno": "1", - "ios": "10.3", - "samsung": "6", - "opera_mobile": "42", - "electron": "1.6" - }, - "transform-template-literals": { - "chrome": "41", - "opera": "28", - "edge": "13", - "firefox": "34", - "safari": "9", - "node": "4", - "deno": "1", - "ios": "9", - "samsung": "3.4", - "opera_mobile": "28", - "electron": "0.21" - }, - "transform-function-name": { - "chrome": "51", - "opera": "38", - "edge": "14", - "firefox": "53", - "safari": "10", - "node": "6.5", - "deno": "1", - "ios": "10", - "samsung": "5", - "opera_mobile": "41", - "electron": "1.2" - }, - "transform-block-scoping": { - "chrome": "50", - "opera": "37", - "edge": "14", - "firefox": "53", - "safari": "10", - "node": "6", - "deno": "1", - "ios": "10", - "samsung": "5", - "opera_mobile": "37", - "electron": "1.1" - } -} diff --git a/tools/eslint/node_modules/@babel/compat-data/data/plugins.json b/tools/eslint/node_modules/@babel/compat-data/data/plugins.json deleted file mode 100644 index 937ddd4fd93981..00000000000000 --- a/tools/eslint/node_modules/@babel/compat-data/data/plugins.json +++ /dev/null @@ -1,794 +0,0 @@ -{ - "transform-unicode-sets-regex": { - "chrome": "112", - "opera": "98", - "edge": "112", - "firefox": "116", - "safari": "17", - "node": "20", - "deno": "1.32", - "ios": "17", - "opera_mobile": "75", - "electron": "24.0" - }, - "bugfix/transform-v8-static-class-fields-redefine-readonly": { - "chrome": "98", - "opera": "84", - "edge": "98", - "firefox": "95", - "safari": "15", - "node": "12", - "deno": "1.18", - "ios": "15", - "samsung": "11", - "opera_mobile": "52", - "electron": "17.0" - }, - "bugfix/transform-firefox-class-in-computed-class-key": { - "chrome": "74", - "opera": "62", - "edge": "79", - "safari": "14.1", - "node": "12", - "deno": "1", - "ios": "14.5", - "samsung": "11", - "opera_mobile": "53", - "electron": "6.0" - }, - "transform-class-static-block": { - "chrome": "94", - "opera": "80", - "edge": "94", - "firefox": "93", - "safari": "16.4", - "node": "16.11", - "deno": "1.14", - "ios": "16.4", - "samsung": "17", - "opera_mobile": "66", - "electron": "15.0" - }, - "proposal-class-static-block": { - "chrome": "94", - "opera": "80", - "edge": "94", - "firefox": "93", - "safari": "16.4", - "node": "16.11", - "deno": "1.14", - "ios": "16.4", - "samsung": "17", - "opera_mobile": "66", - "electron": "15.0" - }, - "transform-private-property-in-object": { - "chrome": "91", - "opera": "77", - "edge": "91", - "firefox": "90", - "safari": "15", - "node": "16.9", - "deno": "1.9", - "ios": "15", - "samsung": "16", - "opera_mobile": "64", - "electron": "13.0" - }, - "proposal-private-property-in-object": { - "chrome": "91", - "opera": "77", - "edge": "91", - "firefox": "90", - "safari": "15", - "node": "16.9", - "deno": "1.9", - "ios": "15", - "samsung": "16", - "opera_mobile": "64", - "electron": "13.0" - }, - "transform-class-properties": { - "chrome": "74", - "opera": "62", - "edge": "79", - "firefox": "90", - "safari": "14.1", - "node": "12", - "deno": "1", - "ios": "14.5", - "samsung": "11", - "opera_mobile": "53", - "electron": "6.0" - }, - "proposal-class-properties": { - "chrome": "74", - "opera": "62", - "edge": "79", - "firefox": "90", - "safari": "14.1", - "node": "12", - "deno": "1", - "ios": "14.5", - "samsung": "11", - "opera_mobile": "53", - "electron": "6.0" - }, - "transform-private-methods": { - "chrome": "84", - "opera": "70", - "edge": "84", - "firefox": "90", - "safari": "15", - "node": "14.6", - "deno": "1", - "ios": "15", - "samsung": "14", - "opera_mobile": "60", - "electron": "10.0" - }, - "proposal-private-methods": { - "chrome": "84", - "opera": "70", - "edge": "84", - "firefox": "90", - "safari": "15", - "node": "14.6", - "deno": "1", - "ios": "15", - "samsung": "14", - "opera_mobile": "60", - "electron": "10.0" - }, - "transform-numeric-separator": { - "chrome": "75", - "opera": "62", - "edge": "79", - "firefox": "70", - "safari": "13", - "node": "12.5", - "deno": "1", - "ios": "13", - "samsung": "11", - "rhino": "1.7.14", - "opera_mobile": "54", - "electron": "6.0" - }, - "proposal-numeric-separator": { - "chrome": "75", - "opera": "62", - "edge": "79", - "firefox": "70", - "safari": "13", - "node": "12.5", - "deno": "1", - "ios": "13", - "samsung": "11", - "rhino": "1.7.14", - "opera_mobile": "54", - "electron": "6.0" - }, - "transform-logical-assignment-operators": { - "chrome": "85", - "opera": "71", - "edge": "85", - "firefox": "79", - "safari": "14", - "node": "15", - "deno": "1.2", - "ios": "14", - "samsung": "14", - "opera_mobile": "60", - "electron": "10.0" - }, - "proposal-logical-assignment-operators": { - "chrome": "85", - "opera": "71", - "edge": "85", - "firefox": "79", - "safari": "14", - "node": "15", - "deno": "1.2", - "ios": "14", - "samsung": "14", - "opera_mobile": "60", - "electron": "10.0" - }, - "transform-nullish-coalescing-operator": { - "chrome": "80", - "opera": "67", - "edge": "80", - "firefox": "72", - "safari": "13.1", - "node": "14", - "deno": "1", - "ios": "13.4", - "samsung": "13", - "opera_mobile": "57", - "electron": "8.0" - }, - "proposal-nullish-coalescing-operator": { - "chrome": "80", - "opera": "67", - "edge": "80", - "firefox": "72", - "safari": "13.1", - "node": "14", - "deno": "1", - "ios": "13.4", - "samsung": "13", - "opera_mobile": "57", - "electron": "8.0" - }, - "transform-optional-chaining": { - "chrome": "91", - "opera": "77", - "edge": "91", - "firefox": "74", - "safari": "13.1", - "node": "16.9", - "deno": "1.9", - "ios": "13.4", - "samsung": "16", - "opera_mobile": "64", - "electron": "13.0" - }, - "proposal-optional-chaining": { - "chrome": "91", - "opera": "77", - "edge": "91", - "firefox": "74", - "safari": "13.1", - "node": "16.9", - "deno": "1.9", - "ios": "13.4", - "samsung": "16", - "opera_mobile": "64", - "electron": "13.0" - }, - "transform-json-strings": { - "chrome": "66", - "opera": "53", - "edge": "79", - "firefox": "62", - "safari": "12", - "node": "10", - "deno": "1", - "ios": "12", - "samsung": "9", - "rhino": "1.7.14", - "opera_mobile": "47", - "electron": "3.0" - }, - "proposal-json-strings": { - "chrome": "66", - "opera": "53", - "edge": "79", - "firefox": "62", - "safari": "12", - "node": "10", - "deno": "1", - "ios": "12", - "samsung": "9", - "rhino": "1.7.14", - "opera_mobile": "47", - "electron": "3.0" - }, - "transform-optional-catch-binding": { - "chrome": "66", - "opera": "53", - "edge": "79", - "firefox": "58", - "safari": "11.1", - "node": "10", - "deno": "1", - "ios": "11.3", - "samsung": "9", - "opera_mobile": "47", - "electron": "3.0" - }, - "proposal-optional-catch-binding": { - "chrome": "66", - "opera": "53", - "edge": "79", - "firefox": "58", - "safari": "11.1", - "node": "10", - "deno": "1", - "ios": "11.3", - "samsung": "9", - "opera_mobile": "47", - "electron": "3.0" - }, - "transform-parameters": { - "chrome": "49", - "opera": "36", - "edge": "18", - "firefox": "53", - "safari": "16.3", - "node": "6", - "deno": "1", - "ios": "16.3", - "samsung": "5", - "opera_mobile": "36", - "electron": "0.37" - }, - "transform-async-generator-functions": { - "chrome": "63", - "opera": "50", - "edge": "79", - "firefox": "57", - "safari": "12", - "node": "10", - "deno": "1", - "ios": "12", - "samsung": "8", - "opera_mobile": "46", - "electron": "3.0" - }, - "proposal-async-generator-functions": { - "chrome": "63", - "opera": "50", - "edge": "79", - "firefox": "57", - "safari": "12", - "node": "10", - "deno": "1", - "ios": "12", - "samsung": "8", - "opera_mobile": "46", - "electron": "3.0" - }, - "transform-object-rest-spread": { - "chrome": "60", - "opera": "47", - "edge": "79", - "firefox": "55", - "safari": "11.1", - "node": "8.3", - "deno": "1", - "ios": "11.3", - "samsung": "8", - "opera_mobile": "44", - "electron": "2.0" - }, - "proposal-object-rest-spread": { - "chrome": "60", - "opera": "47", - "edge": "79", - "firefox": "55", - "safari": "11.1", - "node": "8.3", - "deno": "1", - "ios": "11.3", - "samsung": "8", - "opera_mobile": "44", - "electron": "2.0" - }, - "transform-dotall-regex": { - "chrome": "62", - "opera": "49", - "edge": "79", - "firefox": "78", - "safari": "11.1", - "node": "8.10", - "deno": "1", - "ios": "11.3", - "samsung": "8", - "rhino": "1.7.15", - "opera_mobile": "46", - "electron": "3.0" - }, - "transform-unicode-property-regex": { - "chrome": "64", - "opera": "51", - "edge": "79", - "firefox": "78", - "safari": "11.1", - "node": "10", - "deno": "1", - "ios": "11.3", - "samsung": "9", - "opera_mobile": "47", - "electron": "3.0" - }, - "proposal-unicode-property-regex": { - "chrome": "64", - "opera": "51", - "edge": "79", - "firefox": "78", - "safari": "11.1", - "node": "10", - "deno": "1", - "ios": "11.3", - "samsung": "9", - "opera_mobile": "47", - "electron": "3.0" - }, - "transform-named-capturing-groups-regex": { - "chrome": "64", - "opera": "51", - "edge": "79", - "firefox": "78", - "safari": "11.1", - "node": "10", - "deno": "1", - "ios": "11.3", - "samsung": "9", - "opera_mobile": "47", - "electron": "3.0" - }, - "transform-async-to-generator": { - "chrome": "55", - "opera": "42", - "edge": "15", - "firefox": "52", - "safari": "11", - "node": "7.6", - "deno": "1", - "ios": "11", - "samsung": "6", - "opera_mobile": "42", - "electron": "1.6" - }, - "transform-exponentiation-operator": { - "chrome": "52", - "opera": "39", - "edge": "14", - "firefox": "52", - "safari": "10.1", - "node": "7", - "deno": "1", - "ios": "10.3", - "samsung": "6", - "rhino": "1.7.14", - "opera_mobile": "41", - "electron": "1.3" - }, - "transform-template-literals": { - "chrome": "41", - "opera": "28", - "edge": "13", - "firefox": "34", - "safari": "13", - "node": "4", - "deno": "1", - "ios": "13", - "samsung": "3.4", - "opera_mobile": "28", - "electron": "0.21" - }, - "transform-literals": { - "chrome": "44", - "opera": "31", - "edge": "12", - "firefox": "53", - "safari": "9", - "node": "4", - "deno": "1", - "ios": "9", - "samsung": "4", - "rhino": "1.7.15", - "opera_mobile": "32", - "electron": "0.30" - }, - "transform-function-name": { - "chrome": "51", - "opera": "38", - "edge": "79", - "firefox": "53", - "safari": "10", - "node": "6.5", - "deno": "1", - "ios": "10", - "samsung": "5", - "opera_mobile": "41", - "electron": "1.2" - }, - "transform-arrow-functions": { - "chrome": "47", - "opera": "34", - "edge": "13", - "firefox": "43", - "safari": "10", - "node": "6", - "deno": "1", - "ios": "10", - "samsung": "5", - "rhino": "1.7.13", - "opera_mobile": "34", - "electron": "0.36" - }, - "transform-block-scoped-functions": { - "chrome": "41", - "opera": "28", - "edge": "12", - "firefox": "46", - "safari": "10", - "node": "4", - "deno": "1", - "ie": "11", - "ios": "10", - "samsung": "3.4", - "opera_mobile": "28", - "electron": "0.21" - }, - "transform-classes": { - "chrome": "46", - "opera": "33", - "edge": "13", - "firefox": "45", - "safari": "10", - "node": "5", - "deno": "1", - "ios": "10", - "samsung": "5", - "opera_mobile": "33", - "electron": "0.36" - }, - "transform-object-super": { - "chrome": "46", - "opera": "33", - "edge": "13", - "firefox": "45", - "safari": "10", - "node": "5", - "deno": "1", - "ios": "10", - "samsung": "5", - "opera_mobile": "33", - "electron": "0.36" - }, - "transform-shorthand-properties": { - "chrome": "43", - "opera": "30", - "edge": "12", - "firefox": "33", - "safari": "9", - "node": "4", - "deno": "1", - "ios": "9", - "samsung": "4", - "rhino": "1.7.14", - "opera_mobile": "30", - "electron": "0.27" - }, - "transform-duplicate-keys": { - "chrome": "42", - "opera": "29", - "edge": "12", - "firefox": "34", - "safari": "9", - "node": "4", - "deno": "1", - "ios": "9", - "samsung": "3.4", - "opera_mobile": "29", - "electron": "0.25" - }, - "transform-computed-properties": { - "chrome": "44", - "opera": "31", - "edge": "12", - "firefox": "34", - "safari": "7.1", - "node": "4", - "deno": "1", - "ios": "8", - "samsung": "4", - "opera_mobile": "32", - "electron": "0.30" - }, - "transform-for-of": { - "chrome": "51", - "opera": "38", - "edge": "15", - "firefox": "53", - "safari": "10", - "node": "6.5", - "deno": "1", - "ios": "10", - "samsung": "5", - "opera_mobile": "41", - "electron": "1.2" - }, - "transform-sticky-regex": { - "chrome": "49", - "opera": "36", - "edge": "13", - "firefox": "3", - "safari": "10", - "node": "6", - "deno": "1", - "ios": "10", - "samsung": "5", - "rhino": "1.7.15", - "opera_mobile": "36", - "electron": "0.37" - }, - "transform-unicode-escapes": { - "chrome": "44", - "opera": "31", - "edge": "12", - "firefox": "53", - "safari": "9", - "node": "4", - "deno": "1", - "ios": "9", - "samsung": "4", - "rhino": "1.7.15", - "opera_mobile": "32", - "electron": "0.30" - }, - "transform-unicode-regex": { - "chrome": "50", - "opera": "37", - "edge": "13", - "firefox": "46", - "safari": "12", - "node": "6", - "deno": "1", - "ios": "12", - "samsung": "5", - "opera_mobile": "37", - "electron": "1.1" - }, - "transform-spread": { - "chrome": "46", - "opera": "33", - "edge": "13", - "firefox": "45", - "safari": "10", - "node": "5", - "deno": "1", - "ios": "10", - "samsung": "5", - "opera_mobile": "33", - "electron": "0.36" - }, - "transform-destructuring": { - "chrome": "51", - "opera": "38", - "edge": "15", - "firefox": "53", - "safari": "10", - "node": "6.5", - "deno": "1", - "ios": "10", - "samsung": "5", - "opera_mobile": "41", - "electron": "1.2" - }, - "transform-block-scoping": { - "chrome": "50", - "opera": "37", - "edge": "14", - "firefox": "53", - "safari": "11", - "node": "6", - "deno": "1", - "ios": "11", - "samsung": "5", - "opera_mobile": "37", - "electron": "1.1" - }, - "transform-typeof-symbol": { - "chrome": "38", - "opera": "25", - "edge": "12", - "firefox": "36", - "safari": "9", - "node": "0.12", - "deno": "1", - "ios": "9", - "samsung": "3", - "rhino": "1.7.13", - "opera_mobile": "25", - "electron": "0.20" - }, - "transform-new-target": { - "chrome": "46", - "opera": "33", - "edge": "14", - "firefox": "41", - "safari": "10", - "node": "5", - "deno": "1", - "ios": "10", - "samsung": "5", - "opera_mobile": "33", - "electron": "0.36" - }, - "transform-regenerator": { - "chrome": "50", - "opera": "37", - "edge": "13", - "firefox": "53", - "safari": "10", - "node": "6", - "deno": "1", - "ios": "10", - "samsung": "5", - "opera_mobile": "37", - "electron": "1.1" - }, - "transform-member-expression-literals": { - "chrome": "7", - "opera": "12", - "edge": "12", - "firefox": "2", - "safari": "5.1", - "node": "0.4", - "deno": "1", - "ie": "9", - "android": "4", - "ios": "6", - "phantom": "1.9", - "samsung": "1", - "rhino": "1.7.13", - "opera_mobile": "12", - "electron": "0.20" - }, - "transform-property-literals": { - "chrome": "7", - "opera": "12", - "edge": "12", - "firefox": "2", - "safari": "5.1", - "node": "0.4", - "deno": "1", - "ie": "9", - "android": "4", - "ios": "6", - "phantom": "1.9", - "samsung": "1", - "rhino": "1.7.13", - "opera_mobile": "12", - "electron": "0.20" - }, - "transform-reserved-words": { - "chrome": "13", - "opera": "10.50", - "edge": "12", - "firefox": "2", - "safari": "3.1", - "node": "0.6", - "deno": "1", - "ie": "9", - "android": "4.4", - "ios": "6", - "phantom": "1.9", - "samsung": "1", - "rhino": "1.7.13", - "opera_mobile": "10.1", - "electron": "0.20" - }, - "transform-export-namespace-from": { - "chrome": "72", - "deno": "1.0", - "edge": "79", - "firefox": "80", - "node": "13.2", - "opera": "60", - "opera_mobile": "51", - "safari": "14.1", - "ios": "14.5", - "samsung": "11.0", - "android": "72", - "electron": "5.0" - }, - "proposal-export-namespace-from": { - "chrome": "72", - "deno": "1.0", - "edge": "79", - "firefox": "80", - "node": "13.2", - "opera": "60", - "opera_mobile": "51", - "safari": "14.1", - "ios": "14.5", - "samsung": "11.0", - "android": "72", - "electron": "5.0" - } -} diff --git a/tools/eslint/node_modules/@babel/compat-data/native-modules.js b/tools/eslint/node_modules/@babel/compat-data/native-modules.js deleted file mode 100644 index 8e97da4bcfde87..00000000000000 --- a/tools/eslint/node_modules/@babel/compat-data/native-modules.js +++ /dev/null @@ -1 +0,0 @@ -module.exports = require("./data/native-modules.json"); diff --git a/tools/eslint/node_modules/@babel/compat-data/overlapping-plugins.js b/tools/eslint/node_modules/@babel/compat-data/overlapping-plugins.js deleted file mode 100644 index 88242e467810d4..00000000000000 --- a/tools/eslint/node_modules/@babel/compat-data/overlapping-plugins.js +++ /dev/null @@ -1 +0,0 @@ -module.exports = require("./data/overlapping-plugins.json"); diff --git a/tools/eslint/node_modules/@babel/compat-data/package.json b/tools/eslint/node_modules/@babel/compat-data/package.json deleted file mode 100644 index a99f496af8ef47..00000000000000 --- a/tools/eslint/node_modules/@babel/compat-data/package.json +++ /dev/null @@ -1,40 +0,0 @@ -{ - "name": "@babel/compat-data", - "version": "7.24.8", - "author": "The Babel Team (https://babel.dev/team)", - "license": "MIT", - "description": "", - "repository": { - "type": "git", - "url": "https://github.com/babel/babel.git", - "directory": "packages/babel-compat-data" - }, - "publishConfig": { - "access": "public" - }, - "exports": { - "./plugins": "./plugins.js", - "./native-modules": "./native-modules.js", - "./corejs2-built-ins": "./corejs2-built-ins.js", - "./corejs3-shipped-proposals": "./corejs3-shipped-proposals.js", - "./overlapping-plugins": "./overlapping-plugins.js", - "./plugin-bugfixes": "./plugin-bugfixes.js" - }, - "scripts": { - "build-data": "./scripts/download-compat-table.sh && node ./scripts/build-data.js && node ./scripts/build-modules-support.js && node ./scripts/build-bugfixes-targets.js" - }, - "keywords": [ - "babel", - "compat-table", - "compat-data" - ], - "devDependencies": { - "@mdn/browser-compat-data": "^5.5.36", - "core-js-compat": "^3.37.1", - "electron-to-chromium": "^1.4.816" - }, - "engines": { - "node": ">=6.9.0" - }, - "type": "commonjs" -} \ No newline at end of file diff --git a/tools/eslint/node_modules/@babel/compat-data/plugin-bugfixes.js b/tools/eslint/node_modules/@babel/compat-data/plugin-bugfixes.js deleted file mode 100644 index f390181a6302ef..00000000000000 --- a/tools/eslint/node_modules/@babel/compat-data/plugin-bugfixes.js +++ /dev/null @@ -1 +0,0 @@ -module.exports = require("./data/plugin-bugfixes.json"); diff --git a/tools/eslint/node_modules/@babel/compat-data/plugins.js b/tools/eslint/node_modules/@babel/compat-data/plugins.js deleted file mode 100644 index 42646edce6dc93..00000000000000 --- a/tools/eslint/node_modules/@babel/compat-data/plugins.js +++ /dev/null @@ -1 +0,0 @@ -module.exports = require("./data/plugins.json"); diff --git a/tools/eslint/node_modules/@babel/core/LICENSE b/tools/eslint/node_modules/@babel/core/LICENSE deleted file mode 100644 index f31575ec773bb1..00000000000000 --- a/tools/eslint/node_modules/@babel/core/LICENSE +++ /dev/null @@ -1,22 +0,0 @@ -MIT License - -Copyright (c) 2014-present Sebastian McKenzie and other contributors - -Permission is hereby granted, free of charge, to any person obtaining -a copy of this software and associated documentation files (the -"Software"), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sublicense, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/tools/eslint/node_modules/@babel/core/cjs-proxy.cjs b/tools/eslint/node_modules/@babel/core/cjs-proxy.cjs deleted file mode 100644 index 17dac4a9f430f2..00000000000000 --- a/tools/eslint/node_modules/@babel/core/cjs-proxy.cjs +++ /dev/null @@ -1,59 +0,0 @@ -"use strict"; - -const babelP = import("./lib/index.js"); -let babel = null; -Object.defineProperty(exports, "__ initialize @babel/core cjs proxy __", { - set(val) { - babel = val; - }, -}); - -exports.version = require("./package.json").version; - -const functionNames = [ - "createConfigItem", - "loadPartialConfig", - "loadOptions", - "transform", - "transformFile", - "transformFromAst", - "parse", -]; -const propertyNames = [ - "buildExternalHelpers", - "types", - "tokTypes", - "traverse", - "template", -]; - -for (const name of functionNames) { - exports[name] = function (...args) { - babelP.then(babel => { - babel[name](...args); - }); - }; - exports[`${name}Async`] = function (...args) { - return babelP.then(babel => babel[`${name}Async`](...args)); - }; - exports[`${name}Sync`] = function (...args) { - if (!babel) throw notLoadedError(`${name}Sync`, "callable"); - return babel[`${name}Sync`](...args); - }; -} - -for (const name of propertyNames) { - Object.defineProperty(exports, name, { - get() { - if (!babel) throw notLoadedError(name, "accessible"); - return babel[name]; - }, - }); -} - -function notLoadedError(name, keyword) { - return new Error( - `The \`${name}\` export of @babel/core is only ${keyword}` + - ` from the CommonJS version after that the ESM version is loaded.` - ); -} diff --git a/tools/eslint/node_modules/@babel/core/lib/config/cache-contexts.js b/tools/eslint/node_modules/@babel/core/lib/config/cache-contexts.js deleted file mode 100644 index d7c091273bd4e1..00000000000000 --- a/tools/eslint/node_modules/@babel/core/lib/config/cache-contexts.js +++ /dev/null @@ -1,3 +0,0 @@ -0 && 0; - -//# sourceMappingURL=cache-contexts.js.map diff --git a/tools/eslint/node_modules/@babel/core/lib/config/caching.js b/tools/eslint/node_modules/@babel/core/lib/config/caching.js deleted file mode 100644 index 344c8390e3d054..00000000000000 --- a/tools/eslint/node_modules/@babel/core/lib/config/caching.js +++ /dev/null @@ -1,261 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.assertSimpleType = assertSimpleType; -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.js"); -var _util = require("./util.js"); -const synchronize = gen => { - return _gensync()(gen).sync; -}; -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)); -} -function makeCachedFunction(CallCache, handler) { - const callCacheSync = new CallCache(); - const callCacheAsync = new CallCache(); - const futureCache = new CallCache(); - return function* cachedFunction(arg, data) { - const asyncContext = yield* (0, _async.isAsync)(); - const callCache = asyncContext ? callCacheAsync : callCacheSync; - const cached = yield* getCachedValueOrWait(asyncContext, callCache, futureCache, arg, data); - if (cached.valid) return cached.value; - const cache = new CacheConfigurator(data); - 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); - }); - } 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, - valid - } of cachedValue) { - if (yield* valid(data)) return { - valid: true, - value - }; - } - } - 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 { - valid: true, - value - }; - } - } - 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 = [{ - value, - valid: genTrue - }]; - cache.set(arg, cachedValue); - break; - case "invalidate": - cachedValue = [{ - value, - valid: config.validator() - }]; - cache.set(arg, cachedValue); - break; - case "valid": - if (cachedValue) { - cachedValue.push({ - value, - valid: config.validator() - }); - } else { - cachedValue = [{ - value, - valid: config.validator() - }]; - cache.set(arg, cachedValue); - } - } -} -class CacheConfigurator { - constructor(data) { - this._active = true; - this._never = false; - this._forever = false; - this._invalidate = false; - this._configured = false; - this._pairs = []; - 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; -} -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; - this.promise = void 0; - this._resolve = void 0; - this.promise = new Promise(resolve => { - this._resolve = resolve; - }); - } - release(value) { - this.released = true; - this._resolve(value); - } -} -0 && 0; - -//# sourceMappingURL=caching.js.map diff --git a/tools/eslint/node_modules/@babel/core/lib/config/config-chain.js b/tools/eslint/node_modules/@babel/core/lib/config/config-chain.js deleted file mode 100644 index 591de0c9861373..00000000000000 --- a/tools/eslint/node_modules/@babel/core/lib/config/config-chain.js +++ /dev/null @@ -1,469 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -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.js"); -var _patternToRegex = require("./pattern-to-regex.js"); -var _printer = require("./printer.js"); -var _rewriteStackTrace = require("../errors/rewrite-stack-trace.js"); -var _configError = require("../errors/config-error.js"); -var _index = require("./files/index.js"); -var _caching = require("./caching.js"); -var _configDescriptors = require("./config-descriptors.js"); -const debug = _debug()("babel:config:config-chain"); -function* buildPresetChain(arg, context) { - const chain = yield* buildPresetChainWalker(arg, context); - if (!chain) return null; - return { - plugins: dedupDescriptors(chain.plugins), - presets: dedupDescriptors(chain.presets), - options: chain.options.map(o => normalizeOptions(o)), - files: new Set() - }; -} -const buildPresetChainWalker = exports.buildPresetChainWalker = makeChainWalker({ - root: preset => loadPresetDescriptors(preset), - env: (preset, envName) => loadPresetEnvDescriptors(preset)(envName), - overrides: (preset, index) => loadPresetOverridesDescriptors(preset)(index), - overridesEnv: (preset, index, envName) => loadPresetOverridesEnvDescriptors(preset)(index)(envName), - createLogger: () => () => {} -}); -const loadPresetDescriptors = (0, _caching.makeWeakCacheSync)(preset => buildRootDescriptors(preset, preset.alias, _configDescriptors.createUncachedDescriptors)); -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(); - const programmaticChain = yield* loadProgrammaticChain({ - options: opts, - dirname: context.cwd - }, context, undefined, programmaticLogger); - if (!programmaticChain) return null; - const programmaticReport = yield* programmaticLogger.output(); - let configFile; - if (typeof opts.configFile === "string") { - configFile = yield* (0, _index.loadConfig)(opts.configFile, context.cwd, context.envName, context.caller); - } else if (opts.configFile !== false) { - configFile = yield* (0, _index.findRootConfig)(context.root, context.envName, context.caller); - } - let { - babelrc, - babelrcRoots - } = opts; - 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); - if (!result) return null; - configReport = yield* configFileLogger.output(); - 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, _index.findPackageData)(context.filename); - if (pkgData && babelrcLoadEnabled(context, pkgData, babelrcRoots, babelrcRootsDirectory)) { - ({ - ignore: ignoreFile, - config: babelrcFile - } = yield* (0, _index.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 { - babelRcReport = yield* babelrcLogger.output(); - 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-----"); - } - const chain = mergeChain(mergeChain(mergeChain(emptyChain(), configFileChain), fileChain), programmaticChain); - return { - plugins: isIgnored ? [] : dedupDescriptors(chain.plugins), - presets: isIgnored ? [] : dedupDescriptors(chain.presets), - options: isIgnored ? [] : chain.options.map(o => normalizeOptions(o)), - fileHandling: isIgnored ? "ignored" : "transpile", - ignore: ignoreFile || undefined, - babelrc: babelrcFile || undefined, - config: configFile || undefined, - files: chain.files - }; -} -function babelrcLoadEnabled(context, pkgData, babelrcRoots, babelrcRootsDirectory) { - if (typeof babelrcRoots === "boolean") return babelrcRoots; - const absoluteRoot = context.root; - if (babelrcRoots === undefined) { - return pkgData.directories.includes(absoluteRoot); - } - let babelrcPatterns = babelrcRoots; - if (!Array.isArray(babelrcPatterns)) { - babelrcPatterns = [babelrcPatterns]; - } - babelrcPatterns = babelrcPatterns.map(pat => { - return typeof pat === "string" ? _path().resolve(babelrcRootsDirectory, pat) : pat; - }); - if (babelrcPatterns.length === 1 && babelrcPatterns[0] === absoluteRoot) { - return pkgData.directories.includes(absoluteRoot); - } - 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, - options: (0, _options.validate)("configfile", file.options, file.filepath) -})); -const validateBabelrcFile = (0, _caching.makeWeakCacheSync)(file => ({ - filepath: file.filepath, - dirname: file.dirname, - options: (0, _options.validate)("babelrcfile", file.options, file.filepath) -})); -const validateExtendFile = (0, _caching.makeWeakCacheSync)(file => ({ - filepath: file.filepath, - 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), - overrides: (input, index) => buildOverrideDescriptors(input, "base", _configDescriptors.createCachedDescriptors, index), - 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), - overrides: (file, index) => loadFileOverridesDescriptors(file)(index), - 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); - chain == null || 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 -}, alias, descriptors, envName) { - var _options$env; - const opts = (_options$env = options.env) == null ? void 0 : _options$env[envName]; - return opts ? descriptors(dirname, opts, `${alias}.env["${envName}"]`) : null; -} -function buildOverrideDescriptors({ - dirname, - options -}, alias, descriptors, index) { - var _options$overrides; - const opts = (_options$overrides = options.overrides) == null ? void 0 : _options$overrides[index]; - if (!opts) throw new Error("Assertion failure - missing override"); - return descriptors(dirname, opts, `${alias}.overrides[${index}]`); -} -function buildOverrideEnvDescriptors({ - dirname, - options -}, alias, descriptors, index, envName) { - var _options$overrides2, _override$env; - const override = (_options$overrides2 = options.overrides) == null ? void 0 : _options$overrides2[index]; - if (!override) throw new Error("Assertion failure - missing override"); - const opts = (_override$env = override.env) == null ? void 0 : _override$env[envName]; - return opts ? descriptors(dirname, opts, `${alias}.overrides[${index}].env["${envName}"]`) : null; -} -function makeChainWalker({ - root, - env, - overrides, - overridesEnv, - createLogger -}) { - return function* chainWalker(input, context, files = new Set(), baseLogger) { - const { - dirname - } = input; - const flattenedConfigs = []; - const rootOpts = root(input); - if (configIsApplicable(rootOpts, dirname, context, input.filepath)) { - flattenedConfigs.push({ - config: rootOpts, - envName: undefined, - index: undefined - }); - const envOpts = env(input, context.envName); - if (envOpts && configIsApplicable(envOpts, dirname, context, input.filepath)) { - flattenedConfigs.push({ - config: envOpts, - envName: context.envName, - index: undefined - }); - } - (rootOpts.options.overrides || []).forEach((_, index) => { - const overrideOps = overrides(input, index); - if (configIsApplicable(overrideOps, dirname, context, input.filepath)) { - flattenedConfigs.push({ - config: overrideOps, - index, - envName: undefined - }); - const overrideEnvOpts = overridesEnv(input, index, context.envName); - if (overrideEnvOpts && configIsApplicable(overrideEnvOpts, dirname, context, input.filepath)) { - flattenedConfigs.push({ - config: overrideEnvOpts, - index, - envName: context.envName - }); - } - } - }); - } - if (flattenedConfigs.some(({ - config: { - options: { - ignore, - only - } - } - }) => shouldIgnore(context, ignore, only, dirname))) { - return null; - } - const chain = emptyChain(); - const logger = createLogger(input, context, baseLogger); - for (const { - config, - index, - envName - } of flattenedConfigs) { - 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, _index.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); - if (!fileChain) return false; - 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, - presets -}) { - target.options.push(options); - target.plugins.push(...(yield* plugins())); - target.presets.push(...(yield* presets())); - return target; -} -function emptyChain() { - return { - options: [], - presets: [], - plugins: [], - files: new Set() - }; -} -function normalizeOptions(opts) { - const options = Object.assign({}, opts); - delete options.extends; - delete options.env; - delete options.overrides; - delete options.plugins; - delete options.presets; - delete options.passPerPreset; - delete options.ignore; - delete options.only; - delete options.test; - delete options.include; - delete options.exclude; - if (hasOwnProperty.call(options, "sourceMap")) { - 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; - } - } else { - descriptors.push({ - value: item - }); - } - } - 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); -} -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, { - dirname, - envName: context.envName, - 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 diff --git a/tools/eslint/node_modules/@babel/core/lib/config/config-descriptors.js b/tools/eslint/node_modules/@babel/core/lib/config/config-descriptors.js deleted file mode 100644 index 21fb4146b7f3dc..00000000000000 --- a/tools/eslint/node_modules/@babel/core/lib/config/config-descriptors.js +++ /dev/null @@ -1,190 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -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.js"); -var _index = require("./files/index.js"); -var _item = require("./item.js"); -var _caching = require("./caching.js"); -var _resolveTargets = require("./resolve-targets.js"); -function isEqualDescriptor(a, b) { - var _a$file, _b$file, _a$file2, _b$file2; - 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) == null ? void 0 : _a$file.request) === ((_b$file = b.file) == null ? void 0 : _b$file.request) && ((_a$file2 = a.file) == null ? void 0 : _a$file2.resolved) === ((_b$file2 = b.file) == null ? void 0 : _b$file2.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; -} -function createCachedDescriptors(dirname, options, alias) { - const { - plugins, - presets, - passPerPreset - } = options; - return { - options: optionsWithResolvedBrowserslistConfigFile(options, dirname), - plugins: plugins ? () => createCachedPluginDescriptors(plugins, dirname)(alias) : () => handlerOf([]), - presets: presets ? () => createCachedPresetDescriptors(presets, dirname)(alias)(!!passPerPreset) : () => handlerOf([]) - }; -} -function createUncachedDescriptors(dirname, options, alias) { - return { - options: optionsWithResolvedBrowserslistConfigFile(options, dirname), - plugins: (0, _functional.once)(() => createPluginDescriptors(options.plugins || [], dirname, 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)); - })); -}); -const PLUGIN_DESCRIPTOR_CACHE = new WeakMap(); -const createCachedPluginDescriptors = (0, _caching.makeWeakCacheSync)((items, cache) => { - 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)); - }); -}); -const DEFAULT_OPTIONS = {}; -function loadCachedDescriptor(cache, desc) { - const { - value, - options = DEFAULT_OPTIONS - } = 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.includes(desc)) { - 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, - alias: `${alias}$${index}`, - ownPass: !!ownPass - }))); - assertNoDuplicates(descriptors); - return descriptors; -} -function* createDescriptor(pair, dirname, { - type, - alias, - 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; - } else { - [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" ? _index.loadPlugin : _index.loadPreset; - const request = value; - ({ - filepath, - value - } = yield* resolver(value, dirname)); - file = { - request, - resolved: filepath - }; - } - if (!value) { - throw new Error(`Unexpected falsy value: ${String(value)}`); - } - if (typeof value === "object" && value.__esModule) { - if (value.default) { - value = value.default; - } else { - 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, - value, - options, - dirname, - ownPass, - 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 diff --git a/tools/eslint/node_modules/@babel/core/lib/config/files/configuration.js b/tools/eslint/node_modules/@babel/core/lib/config/files/configuration.js deleted file mode 100644 index 50adfd86dea6d6..00000000000000 --- a/tools/eslint/node_modules/@babel/core/lib/config/files/configuration.js +++ /dev/null @@ -1,286 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.ROOT_CONFIG_FILENAMES = void 0; -exports.findConfigUpwards = findConfigUpwards; -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.js"); -var _configApi = require("../helpers/config-api.js"); -var _utils = require("./utils.js"); -var _moduleTypes = require("./module-types.js"); -var _patternToRegex = require("../pattern-to-regex.js"); -var _configError = require("../../errors/config-error.js"); -var fs = require("../../gensync-utils/fs.js"); -var _rewriteStackTrace = require("../../errors/rewrite-stack-trace.js"); -const debug = _debug()("babel:config:loading:files:configuration"); -const ROOT_CONFIG_FILENAMES = exports.ROOT_CONFIG_FILENAMES = ["babel.config.js", "babel.config.cjs", "babel.config.mjs", "babel.config.json", "babel.config.cts"]; -const RELATIVE_CONFIG_FILENAMES = [".babelrc", ".babelrc.js", ".babelrc.cjs", ".babelrc.mjs", ".babelrc.json", ".babelrc.cts"]; -const BABELIGNORE_FILENAME = ".babelignore"; -const runConfig = (0, _caching.makeWeakCache)(function* runConfig(options, cache) { - yield* []; - return { - options: (0, _rewriteStackTrace.endHiddenCallStack)(options)((0, _configApi.makeConfigAPI)(cache)), - cacheNeedsConfiguration: !cache.configured() - }; -}); -function* readConfigCode(filepath, data) { - if (!_fs().existsSync(filepath)) return null; - let 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."); - let cacheNeedsConfiguration = false; - if (typeof options === "function") { - ({ - options, - cacheNeedsConfiguration - } = yield* runConfig(options, data)); - } - if (!options || typeof options !== "object" || Array.isArray(options)) { - throw new _configError.default(`Configuration should be an exported JavaScript object.`, filepath); - } - if (typeof options.then === "function") { - options.catch == null || options.catch(() => {}); - 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 (cacheNeedsConfiguration) throwConfigError(filepath); - return buildConfigFileObject(options, filepath); -} -const cfboaf = new WeakMap(); -function buildConfigFileObject(options, filepath) { - let configFilesByFilepath = cfboaf.get(options); - if (!configFilesByFilepath) { - cfboaf.set(options, configFilesByFilepath = new Map()); - } - let configFile = configFilesByFilepath.get(filepath); - if (!configFile) { - configFile = { - filepath, - dirname: _path().dirname(filepath), - options - }; - configFilesByFilepath.set(filepath, configFile); - } - return configFile; -} -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, - options: babel - }; -}); -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, - dirname: _path().dirname(filepath), - options - }; -}); -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); - switch (ext) { - case ".js": - case ".cjs": - case ".mjs": - case ".cts": - return readConfigCode(filepath, { - envName, - caller - }); - default: - return 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 -for various types of caching, using the first param of their handler functions: - -module.exports = function(api) { - // The API exposes the following: - - // Cache the returned value forever and don't call this function again. - api.cache(true); - - // Don't cache at all. Not recommended because it will be very slow. - api.cache(false); - - // Cached based on the value of some function. If this function returns a value different from - // a previously-encountered value, the plugins will re-evaluate. - var env = api.cache(() => process.env.NODE_ENV); - - // If testing for a specific env, we recommend specifics to avoid instantiating a plugin for - // any possible NODE_ENV value that might come up during plugin execution. - var isProd = api.cache(() => process.env.NODE_ENV === "production"); - - // .cache(fn) will perform a linear search though instances to find the matching plugin based - // based on previous instantiated plugins. If you want to recreate the plugin and discard the - // previous instance whenever something changes, you may use: - var isProd = api.cache.invalidate(() => process.env.NODE_ENV === "production"); - - // Note, we also expose the following more-verbose versions of the above examples: - api.cache.forever(); // api.cache(true) - api.cache.never(); // api.cache(false) - api.cache.using(fn); // api.cache(fn) - - // Return the value that will be cached. - return { }; -};`, filepath); -} -0 && 0; - -//# sourceMappingURL=configuration.js.map diff --git a/tools/eslint/node_modules/@babel/core/lib/config/files/import.cjs b/tools/eslint/node_modules/@babel/core/lib/config/files/import.cjs deleted file mode 100644 index 46fa5d5cfc41c4..00000000000000 --- a/tools/eslint/node_modules/@babel/core/lib/config/files/import.cjs +++ /dev/null @@ -1,6 +0,0 @@ -module.exports = function import_(filepath) { - return import(filepath); -}; -0 && 0; - -//# sourceMappingURL=import.cjs.map diff --git a/tools/eslint/node_modules/@babel/core/lib/config/files/index-browser.js b/tools/eslint/node_modules/@babel/core/lib/config/files/index-browser.js deleted file mode 100644 index d8ba7dbc8d7e96..00000000000000 --- a/tools/eslint/node_modules/@babel/core/lib/config/files/index-browser.js +++ /dev/null @@ -1,58 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.ROOT_CONFIG_FILENAMES = void 0; -exports.findConfigUpwards = findConfigUpwards; -exports.findPackageData = findPackageData; -exports.findRelativeConfig = findRelativeConfig; -exports.findRootConfig = findRootConfig; -exports.loadConfig = loadConfig; -exports.loadPlugin = loadPlugin; -exports.loadPreset = loadPreset; -exports.resolvePlugin = resolvePlugin; -exports.resolvePreset = resolvePreset; -exports.resolveShowConfigPath = resolveShowConfigPath; -function findConfigUpwards(rootDir) { - return null; -} -function* findPackageData(filepath) { - return { - filepath, - directories: [], - pkg: null, - isPackage: false - }; -} -function* findRelativeConfig(pkgData, envName, caller) { - return { - config: null, - ignore: null - }; -} -function* findRootConfig(dirname, envName, caller) { - return null; -} -function* loadConfig(name, dirname, envName, caller) { - throw new Error(`Cannot load ${name} relative to ${dirname} in a browser`); -} -function* resolveShowConfigPath(dirname) { - return null; -} -const ROOT_CONFIG_FILENAMES = exports.ROOT_CONFIG_FILENAMES = []; -function resolvePlugin(name, dirname) { - return null; -} -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 diff --git a/tools/eslint/node_modules/@babel/core/lib/config/files/index.js b/tools/eslint/node_modules/@babel/core/lib/config/files/index.js deleted file mode 100644 index 8750f40a9c80b2..00000000000000 --- a/tools/eslint/node_modules/@babel/core/lib/config/files/index.js +++ /dev/null @@ -1,78 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -Object.defineProperty(exports, "ROOT_CONFIG_FILENAMES", { - enumerable: true, - get: function () { - return _configuration.ROOT_CONFIG_FILENAMES; - } -}); -Object.defineProperty(exports, "findConfigUpwards", { - enumerable: true, - get: function () { - return _configuration.findConfigUpwards; - } -}); -Object.defineProperty(exports, "findPackageData", { - enumerable: true, - get: function () { - return _package.findPackageData; - } -}); -Object.defineProperty(exports, "findRelativeConfig", { - enumerable: true, - get: function () { - return _configuration.findRelativeConfig; - } -}); -Object.defineProperty(exports, "findRootConfig", { - enumerable: true, - get: function () { - return _configuration.findRootConfig; - } -}); -Object.defineProperty(exports, "loadConfig", { - enumerable: true, - get: function () { - return _configuration.loadConfig; - } -}); -Object.defineProperty(exports, "loadPlugin", { - enumerable: true, - get: function () { - return _plugins.loadPlugin; - } -}); -Object.defineProperty(exports, "loadPreset", { - enumerable: true, - get: function () { - return _plugins.loadPreset; - } -}); -Object.defineProperty(exports, "resolvePlugin", { - enumerable: true, - get: function () { - return _plugins.resolvePlugin; - } -}); -Object.defineProperty(exports, "resolvePreset", { - enumerable: true, - get: function () { - return _plugins.resolvePreset; - } -}); -Object.defineProperty(exports, "resolveShowConfigPath", { - enumerable: true, - get: function () { - return _configuration.resolveShowConfigPath; - } -}); -var _package = require("./package.js"); -var _configuration = require("./configuration.js"); -var _plugins = require("./plugins.js"); -({}); -0 && 0; - -//# sourceMappingURL=index.js.map diff --git a/tools/eslint/node_modules/@babel/core/lib/config/files/module-types.js b/tools/eslint/node_modules/@babel/core/lib/config/files/module-types.js deleted file mode 100644 index f728f1cddb09e6..00000000000000 --- a/tools/eslint/node_modules/@babel/core/lib/config/files/module-types.js +++ /dev/null @@ -1,176 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.default = loadCodeDefault; -exports.supportsESM = void 0; -var _async = require("../../gensync-utils/async.js"); -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 _semver() { - const data = require("semver"); - _semver = function () { - return data; - }; - return data; -} -function _debug() { - const data = require("debug"); - _debug = function () { - return data; - }; - return data; -} -var _rewriteStackTrace = require("../../errors/rewrite-stack-trace.js"); -var _configError = require("../../errors/config-error.js"); -var _transformFile = require("../../transform-file.js"); -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:module-types"); -{ - try { - var import_ = require("./import.cjs"); - } catch (_unused) {} -} -const supportsESM = exports.supportsESM = _semver().satisfies(process.versions.node, "^12.17 || >=13.2"); -function* loadCodeDefault(filepath, asyncError) { - switch (_path().extname(filepath)) { - case ".cjs": - { - return loadCjsDefault(filepath, arguments[2]); - } - case ".mjs": - break; - case ".cts": - return loadCtsDefault(filepath); - default: - try { - { - return loadCjsDefault(filepath, arguments[2]); - } - } catch (e) { - if (e.code !== "ERR_REQUIRE_ESM") throw e; - } - } - if (yield* (0, _async.isAsync)()) { - return yield* (0, _async.waitFor)(loadMjsDefault(filepath)); - } - throw new _configError.default(asyncError, filepath); -} -function loadCtsDefault(filepath) { - const ext = ".cts"; - const hasTsSupport = !!(require.extensions[".ts"] || require.extensions[".cts"] || require.extensions[".mts"]); - let handler; - if (!hasTsSupport) { - const opts = { - babelrc: false, - configFile: false, - sourceType: "unambiguous", - sourceMaps: "inline", - sourceFileName: _path().basename(filepath), - presets: [[getTSPreset(filepath), Object.assign({ - onlyRemoveTypeImports: true, - optimizeConstEnums: true - }, { - allowDeclareFields: true - })]] - }; - handler = function (m, filename) { - if (handler && filename.endsWith(ext)) { - try { - return m._compile((0, _transformFile.transformFileSync)(filename, Object.assign({}, opts, { - filename - })).code, filename); - } catch (error) { - if (!hasTsSupport) { - const packageJson = require("@babel/preset-typescript/package.json"); - if (_semver().lt(packageJson.version, "7.21.4")) { - console.error("`.cts` configuration file failed to load, please try to update `@babel/preset-typescript`."); - } - } - throw error; - } - } - return require.extensions[".js"](m, filename); - }; - require.extensions[ext] = handler; - } - try { - return loadCjsDefault(filepath); - } finally { - if (!hasTsSupport) { - if (require.extensions[ext] === handler) delete require.extensions[ext]; - handler = undefined; - } - } -} -const LOADING_CJS_FILES = new Set(); -function loadCjsDefault(filepath) { - if (LOADING_CJS_FILES.has(filepath)) { - debug("Auto-ignoring usage of config %o.", filepath); - return {}; - } - let module; - try { - LOADING_CJS_FILES.add(filepath); - module = (0, _rewriteStackTrace.endHiddenCallStack)(require)(filepath); - } finally { - LOADING_CJS_FILES.delete(filepath); - } - { - var _module; - return (_module = module) != null && _module.__esModule ? module.default || (arguments[1] ? module : undefined) : module; - } -} -const loadMjsDefault = (0, _rewriteStackTrace.endHiddenCallStack)(function () { - var _loadMjsDefault = _asyncToGenerator(function* (filepath) { - const url = (0, _url().pathToFileURL)(filepath).toString(); - { - if (!import_) { - throw new _configError.default("Internal error: Native ECMAScript modules aren't supported by this platform.\n", filepath); - } - return (yield import_(url)).default; - } - }); - function loadMjsDefault(_x) { - return _loadMjsDefault.apply(this, arguments); - } - return loadMjsDefault; -}()); -function getTSPreset(filepath) { - try { - return require("@babel/preset-typescript"); - } catch (error) { - if (error.code !== "MODULE_NOT_FOUND") throw error; - let message = "You appear to be using a .cts file as Babel configuration, but the `@babel/preset-typescript` package was not found: please install it!"; - { - if (process.versions.pnp) { - message += ` -If you are using Yarn Plug'n'Play, you may also need to add the following configuration to your .yarnrc.yml file: - -packageExtensions: -\t"@babel/core@*": -\t\tpeerDependencies: -\t\t\t"@babel/preset-typescript": "*" -`; - } - } - throw new _configError.default(message, filepath); - } -} -0 && 0; - -//# sourceMappingURL=module-types.js.map diff --git a/tools/eslint/node_modules/@babel/core/lib/config/files/package.js b/tools/eslint/node_modules/@babel/core/lib/config/files/package.js deleted file mode 100644 index eed8ab82fac64e..00000000000000 --- a/tools/eslint/node_modules/@babel/core/lib/config/files/package.js +++ /dev/null @@ -1,61 +0,0 @@ -"use strict"; - -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.js"); -var _configError = require("../../errors/config-error.js"); -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, - pkg, - isPackage - }; -} -0 && 0; - -//# sourceMappingURL=package.js.map diff --git a/tools/eslint/node_modules/@babel/core/lib/config/files/plugins.js b/tools/eslint/node_modules/@babel/core/lib/config/files/plugins.js deleted file mode 100644 index 25435ae424af77..00000000000000 --- a/tools/eslint/node_modules/@babel/core/lib/config/files/plugins.js +++ /dev/null @@ -1,217 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.loadPlugin = loadPlugin; -exports.loadPreset = loadPreset; -exports.resolvePreset = exports.resolvePlugin = void 0; -function _debug() { - const data = require("debug"); - _debug = function () { - return data; - }; - return data; -} -function _path() { - const data = require("path"); - _path = function () { - return data; - }; - return data; -} -var _async = require("../../gensync-utils/async.js"); -var _moduleTypes = require("./module-types.js"); -function _url() { - const data = require("url"); - _url = function () { - return data; - }; - return data; -} -var _importMetaResolve = require("../../vendor/import-meta-resolve.js"); -function _fs() { - const data = require("fs"); - _fs = function () { - return data; - }; - return data; -} -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-)/; -const BABEL_PLUGIN_ORG_RE = /^(@babel\/)(?!plugin-|[^/]+\/)/; -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$)[^/]+)$/; -const resolvePlugin = exports.resolvePlugin = resolveStandardizedName.bind(null, "plugin"); -const resolvePreset = exports.resolvePreset = resolveStandardizedName.bind(null, "preset"); -function* loadPlugin(name, dirname) { - const filepath = resolvePlugin(name, dirname, yield* (0, _async.isAsync)()); - const value = yield* requireModule("plugin", filepath); - debug("Loaded plugin %o from %o.", name, dirname); - return { - filepath, - value - }; -} -function* loadPreset(name, dirname) { - const filepath = resolvePreset(name, dirname, yield* (0, _async.isAsync)()); - const value = yield* requireModule("preset", filepath); - debug("Loaded preset %o from %o.", name, dirname); - return { - filepath, - 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, ""); -} -function* resolveAlternativesHelper(type, name) { - const standardizedName = standardizeName(type, name); - const { - error, - value - } = yield standardizedName; - if (!error) return value; - 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}?`; - } - if (type === "plugin") { - const transformName = standardizedName.replace("-proposal-", "-transform-"); - if (transformName !== standardizedName && !(yield transformName).error) { - error.message += `\n- Did you mean "${transformName}"?`; - } - } - error.message += `\n -Make sure that all the Babel plugins and presets you are using -are defined as dependencies or devDependencies in your package.json -file. It's possible that the missing plugin is loaded by a preset -you are using that forgot to add the plugin to its dependencies: you -can workaround this problem by explicitly adding the missing package -to your top-level package.json. -`; - throw error; -} -function tryRequireResolve(id, dirname) { - try { - if (dirname) { - return { - error: null, - value: (((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; - })(id, { - paths: [dirname] - }) - }; - } else { - return { - error: null, - value: require.resolve(id) - }; - } - } catch (error) { - return { - error, - value: null - }; - } -} -function tryImportMetaResolve(id, options) { - try { - return { - error: null, - value: (0, _importMetaResolve.resolve)(id, options) - }; - } catch (error) { - return { - error, - value: null - }; - } -} -function resolveStandardizedNameForRequire(type, name, dirname) { - const it = resolveAlternativesHelper(type, name); - let res = it.next(); - while (!res.done) { - res = it.next(tryRequireResolve(res.value, dirname)); - } - return res.value; -} -function resolveStandardizedNameForImport(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(tryImportMetaResolve(res.value, parentUrl)); - } - return (0, _url().fileURLToPath)(res.value); -} -function resolveStandardizedName(type, name, dirname, resolveESM) { - if (!_moduleTypes.supportsESM || !resolveESM) { - return resolveStandardizedNameForRequire(type, name, dirname); - } - try { - const resolved = resolveStandardizedNameForImport(type, name, dirname); - if (!(0, _fs().existsSync)(resolved)) { - throw Object.assign(new Error(`Could not resolve "${name}" in file ${dirname}.`), { - type: "MODULE_NOT_FOUND" - }); - } - return resolved; - } catch (e) { - try { - return resolveStandardizedNameForRequire(type, name, dirname); - } catch (e2) { - if (e.type === "MODULE_NOT_FOUND") throw e; - if (e2.type === "MODULE_NOT_FOUND") throw e2; - throw e; - } - } -} -{ - 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); - } - } catch (err) { - err.message = `[BABEL]: ${err.message} (While processing: ${name})`; - throw err; - } finally { - { - LOADING_MODULES.delete(name); - } - } -} -0 && 0; - -//# sourceMappingURL=plugins.js.map diff --git a/tools/eslint/node_modules/@babel/core/lib/config/files/types.js b/tools/eslint/node_modules/@babel/core/lib/config/files/types.js deleted file mode 100644 index c03b5a6fd8311f..00000000000000 --- a/tools/eslint/node_modules/@babel/core/lib/config/files/types.js +++ /dev/null @@ -1,3 +0,0 @@ -0 && 0; - -//# sourceMappingURL=types.js.map diff --git a/tools/eslint/node_modules/@babel/core/lib/config/files/utils.js b/tools/eslint/node_modules/@babel/core/lib/config/files/utils.js deleted file mode 100644 index 406aab9fc08a42..00000000000000 --- a/tools/eslint/node_modules/@babel/core/lib/config/files/utils.js +++ /dev/null @@ -1,36 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.makeStaticFileCache = makeStaticFileCache; -var _caching = require("../caching.js"); -var fs = require("../../gensync-utils/fs.js"); -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 diff --git a/tools/eslint/node_modules/@babel/core/lib/config/full.js b/tools/eslint/node_modules/@babel/core/lib/config/full.js deleted file mode 100644 index 6b8c2959dea179..00000000000000 --- a/tools/eslint/node_modules/@babel/core/lib/config/full.js +++ /dev/null @@ -1,310 +0,0 @@ -"use strict"; - -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.js"); -var _util = require("./util.js"); -var context = require("../index.js"); -var _plugin = require("./plugin.js"); -var _item = require("./item.js"); -var _configChain = require("./config-chain.js"); -var _deepArray = require("./helpers/deep-array.js"); -function _traverse() { - const data = require("@babel/traverse"); - _traverse = function () { - return data; - }; - return data; -} -var _caching = require("./caching.js"); -var _options = require("./validation/options.js"); -var _plugins = require("./validation/plugins.js"); -var _configApi = require("./helpers/config-api.js"); -var _partial = require("./partial.js"); -var _configError = require("../errors/config-error.js"); -var _default = exports.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 = [[]]; - const passes = []; - 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); - } catch (e) { - if (e.code === "BABEL_UNKNOWN_OPTION") { - (0, _options.checkNoUnwrappedItemOptionPairs)(rawPresets, i, "preset", e); - } - throw e; - } - externalDependencies.push(preset.externalDependencies); - if (descriptor.ownPass) { - presets.push({ - preset: preset.chain, - pass: [] - }); - } else { - presets.unshift({ - preset: preset.chain, - pass: pluginDescriptorsPass - }); - } - } - } - if (presets.length > 0) { - pluginDescriptorsByPass.splice(1, 0, ...presets.map(o => o.pass).filter(p => p !== pluginDescriptorsPass)); - for (const { - preset, - pass - } of presets) { - if (!preset) return true; - pass.push(...preset.plugins); - const ignored = yield* recursePresetDescriptors(preset.presets, pass); - if (ignored) return true; - preset.options.forEach(opts => { - (0, _util.mergeOptions)(optionDefaults, opts); - }); - } - } - })(presetsDescriptors, pluginDescriptorsByPass[0]); - if (ignored) return null; - const opts = optionDefaults; - (0, _util.mergeOptions)(opts, options); - const pluginContext = Object.assign({}, presetContext, { - assumptions: (_opts$assumptions = opts.assumptions) != null ? _opts$assumptions : {} - }); - 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); - } catch (e) { - if (e.code === "BABEL_UNKNOWN_PLUGIN_PROPERTY") { - (0, _options.checkNoUnwrappedItemOptionPairs)(descs, i, "plugin", e); - } - throw e; - } - pass.push(plugin); - externalDependencies.push(plugin.externalDependencies); - } - } - } - })(); - opts.plugins = passes[0]; - opts.presets = passes.slice(1).filter(plugins => plugins.length > 0).map(plugins => ({ - plugins - })); - opts.passPerPreset = opts.presets.length > 0; - return { - options: opts, - passes: passes, - externalDependencies: (0, _deepArray.finalize)(externalDependencies) - }; -}); -function enhanceError(context, fn) { - return function* (arg1, arg2) { - try { - return yield* fn(arg1, arg2); - } 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; - } - }; -} -const makeDescriptorLoader = apiFactory => (0, _caching.makeWeakCache)(function* ({ - value, - options, - dirname, - alias -}, cache) { - if (options === false) throw new Error("Assertion failure"); - 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, - dirname, - alias, - externalDependencies: (0, _deepArray.finalize)(externalDependencies) - }; -}); -const pluginDescriptorLoader = makeDescriptorLoader(_configApi.makePluginAPI); -const presetDescriptorLoader = makeDescriptorLoader(_configApi.makePresetAPI); -const instantiatePlugin = (0, _caching.makeWeakCache)(function* ({ - value, - options, - dirname, - alias, - externalDependencies -}, 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, - alias: `${alias}$inherits`, - value: plugin.inherits, - options, - dirname - }; - const inherits = yield* (0, _async.forwardAsync)(loadPluginDescriptor, run => { - return cache.invalidate(data => run(inheritsDescriptor, data)); - }); - plugin.pre = chain(inherits.pre, plugin.pre); - 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; - } else { - externalDependencies = (0, _deepArray.finalize)([externalDependencies, inherits.externalDependencies]); - } - } - } - 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) { - var _options$overrides; - const { - options - } = preset; - validateIfOptionNeedsFilename(options, descriptor); - (_options$overrides = options.overrides) == null || _options$overrides.forEach(overrideOptions => validateIfOptionNeedsFilename(overrideOptions, descriptor)); - } -}; -const instantiatePreset = (0, _caching.makeWeakCacheSync)(({ - value, - dirname, - alias, - externalDependencies -}) => { - return { - options: (0, _options.validate)("preset", value), - alias, - dirname, - externalDependencies - }; -}); -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]; - return function (...args) { - for (const fn of fns) { - fn.apply(this, args); - } - }; -} -0 && 0; - -//# sourceMappingURL=full.js.map diff --git a/tools/eslint/node_modules/@babel/core/lib/config/helpers/config-api.js b/tools/eslint/node_modules/@babel/core/lib/config/helpers/config-api.js deleted file mode 100644 index 3a80653ef72637..00000000000000 --- a/tools/eslint/node_modules/@babel/core/lib/config/helpers/config-api.js +++ /dev/null @@ -1,84 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.makeConfigAPI = makeConfigAPI; -exports.makePluginAPI = makePluginAPI; -exports.makePresetAPI = makePresetAPI; -function _semver() { - const data = require("semver"); - _semver = function () { - return data; - }; - return data; -} -var _index = require("../../index.js"); -var _caching = require("../caching.js"); -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: _index.version, - cache: cache.simple(), - env, - async: () => false, - caller, - assertVersion - }; -} -function makePresetAPI(cache, externalDependencies) { - 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 (range === "*" || _semver().satisfies(_index.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 "${_index.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: _index.version, - range - }); -} -0 && 0; - -//# sourceMappingURL=config-api.js.map diff --git a/tools/eslint/node_modules/@babel/core/lib/config/helpers/deep-array.js b/tools/eslint/node_modules/@babel/core/lib/config/helpers/deep-array.js deleted file mode 100644 index c611db20ed599a..00000000000000 --- a/tools/eslint/node_modules/@babel/core/lib/config/helpers/deep-array.js +++ /dev/null @@ -1,23 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.finalize = finalize; -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 diff --git a/tools/eslint/node_modules/@babel/core/lib/config/helpers/environment.js b/tools/eslint/node_modules/@babel/core/lib/config/helpers/environment.js deleted file mode 100644 index a23b80bec04c08..00000000000000 --- a/tools/eslint/node_modules/@babel/core/lib/config/helpers/environment.js +++ /dev/null @@ -1,12 +0,0 @@ -"use strict"; - -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 diff --git a/tools/eslint/node_modules/@babel/core/lib/config/index.js b/tools/eslint/node_modules/@babel/core/lib/config/index.js deleted file mode 100644 index b2262b27571a55..00000000000000 --- a/tools/eslint/node_modules/@babel/core/lib/config/index.js +++ /dev/null @@ -1,93 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.createConfigItem = createConfigItem; -exports.createConfigItemAsync = createConfigItemAsync; -exports.createConfigItemSync = createConfigItemSync; -Object.defineProperty(exports, "default", { - enumerable: true, - get: function () { - return _full.default; - } -}); -exports.loadOptions = loadOptions; -exports.loadOptionsAsync = loadOptionsAsync; -exports.loadOptionsSync = loadOptionsSync; -exports.loadPartialConfig = loadPartialConfig; -exports.loadPartialConfigAsync = loadPartialConfigAsync; -exports.loadPartialConfigSync = loadPartialConfigSync; -function _gensync() { - const data = require("gensync"); - _gensync = function () { - return data; - }; - return data; -} -var _full = require("./full.js"); -var _partial = require("./partial.js"); -var _item = require("./item.js"); -var _rewriteStackTrace = require("../errors/rewrite-stack-trace.js"); -const loadPartialConfigRunner = _gensync()(_partial.loadPartialConfig); -function loadPartialConfigAsync(...args) { - return (0, _rewriteStackTrace.beginHiddenCallStack)(loadPartialConfigRunner.async)(...args); -} -function loadPartialConfigSync(...args) { - return (0, _rewriteStackTrace.beginHiddenCallStack)(loadPartialConfigRunner.sync)(...args); -} -function loadPartialConfig(opts, callback) { - if (callback !== undefined) { - (0, _rewriteStackTrace.beginHiddenCallStack)(loadPartialConfigRunner.errback)(opts, callback); - } else if (typeof opts === "function") { - (0, _rewriteStackTrace.beginHiddenCallStack)(loadPartialConfigRunner.errback)(undefined, opts); - } else { - { - return loadPartialConfigSync(opts); - } - } -} -function* loadOptionsImpl(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 loadOptionsRunner = _gensync()(loadOptionsImpl); -function loadOptionsAsync(...args) { - return (0, _rewriteStackTrace.beginHiddenCallStack)(loadOptionsRunner.async)(...args); -} -function loadOptionsSync(...args) { - return (0, _rewriteStackTrace.beginHiddenCallStack)(loadOptionsRunner.sync)(...args); -} -function loadOptions(opts, callback) { - if (callback !== undefined) { - (0, _rewriteStackTrace.beginHiddenCallStack)(loadOptionsRunner.errback)(opts, callback); - } else if (typeof opts === "function") { - (0, _rewriteStackTrace.beginHiddenCallStack)(loadOptionsRunner.errback)(undefined, opts); - } else { - { - return loadOptionsSync(opts); - } - } -} -const createConfigItemRunner = _gensync()(_item.createConfigItem); -function createConfigItemAsync(...args) { - return (0, _rewriteStackTrace.beginHiddenCallStack)(createConfigItemRunner.async)(...args); -} -function createConfigItemSync(...args) { - return (0, _rewriteStackTrace.beginHiddenCallStack)(createConfigItemRunner.sync)(...args); -} -function createConfigItem(target, options, callback) { - if (callback !== undefined) { - (0, _rewriteStackTrace.beginHiddenCallStack)(createConfigItemRunner.errback)(target, options, callback); - } else if (typeof options === "function") { - (0, _rewriteStackTrace.beginHiddenCallStack)(createConfigItemRunner.errback)(target, undefined, callback); - } else { - { - return createConfigItemSync(target, options); - } - } -} -0 && 0; - -//# sourceMappingURL=index.js.map diff --git a/tools/eslint/node_modules/@babel/core/lib/config/item.js b/tools/eslint/node_modules/@babel/core/lib/config/item.js deleted file mode 100644 index 69cf01ff1ac74b..00000000000000 --- a/tools/eslint/node_modules/@babel/core/lib/config/item.js +++ /dev/null @@ -1,67 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -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.js"); -function createItemFromDescriptor(desc) { - return new ConfigItem(desc); -} -function* createConfigItem(value, { - dirname = ".", - type -} = {}) { - const descriptor = yield* (0, _configDescriptors.createDescriptor)(value, _path().resolve(dirname), { - type, - alias: "programmatic item" - }); - 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; -} -class ConfigItem { - constructor(descriptor) { - this._descriptor = void 0; - this[CONFIG_ITEM_BRAND] = true; - this.value = void 0; - this.options = void 0; - this.dirname = void 0; - this.name = void 0; - this.file = void 0; - this._descriptor = descriptor; - Object.defineProperty(this, "_descriptor", { - enumerable: false - }); - Object.defineProperty(this, CONFIG_ITEM_BRAND, { - enumerable: false - }); - this.value = this._descriptor.value; - this.options = this._descriptor.options; - this.dirname = this._descriptor.dirname; - this.name = this._descriptor.name; - this.file = this._descriptor.file ? { - request: this._descriptor.file.request, - resolved: this._descriptor.file.resolved - } : undefined; - Object.freeze(this); - } -} -Object.freeze(ConfigItem.prototype); -0 && 0; - -//# sourceMappingURL=item.js.map diff --git a/tools/eslint/node_modules/@babel/core/lib/config/partial.js b/tools/eslint/node_modules/@babel/core/lib/config/partial.js deleted file mode 100644 index 5874ad99b9437f..00000000000000 --- a/tools/eslint/node_modules/@babel/core/lib/config/partial.js +++ /dev/null @@ -1,158 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.default = loadPrivatePartialConfig; -exports.loadPartialConfig = loadPartialConfig; -function _path() { - const data = require("path"); - _path = function () { - return data; - }; - return data; -} -var _plugin = require("./plugin.js"); -var _util = require("./util.js"); -var _item = require("./item.js"); -var _configChain = require("./config-chain.js"); -var _environment = require("./helpers/environment.js"); -var _options = require("./validation/options.js"); -var _index = require("./files/index.js"); -var _resolveTargets = require("./resolve-targets.js"); -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, _index.findConfigUpwards)(rootDir); - return upwardRootDir === null ? rootDir : upwardRootDir; - } - case "upward": - { - const upwardRootDir = (0, _index.findConfigUpwards)(rootDir); - if (upwardRootDir !== null) return upwardRootDir; - throw Object.assign(new Error(`Babel was run with rootMode:"upward" but a root could not ` + `be found when searching upward from "${rootDir}".\n` + `One of the following config files must be in the directory tree: ` + `"${_index.ROOT_CONFIG_FILENAMES.join(", ")}".`), { - code: "BABEL_ROOT_NOT_FOUND", - 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)(), - cwd = ".", - root: rootDir = ".", - rootMode = "root", - 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, _index.resolveShowConfigPath)(absoluteCwd); - const context = { - filename, - cwd: absoluteCwd, - root: absoluteRootDir, - envName, - caller, - showConfig: showConfigPath === filename - }; - const configChain = yield* (0, _configChain.buildRootChain)(args, context); - if (!configChain) return null; - const merged = { - assumptions: {} - }; - configChain.options.forEach(opts => { - (0, _util.mergeOptions)(merged, opts); - }); - const options = Object.assign({}, merged, { - targets: (0, _resolveTargets.resolveTargets)(merged, absoluteRootDir), - cloneInputAst, - babelrc: false, - configFile: false, - browserslistConfigFile: false, - passPerPreset: false, - envName: context.envName, - cwd: context.cwd, - root: context.root, - rootMode: "root", - filename: typeof context.filename === "string" ? context.filename : undefined, - plugins: configChain.plugins.map(descriptor => (0, _item.createItemFromDescriptor)(descriptor)), - presets: configChain.presets.map(descriptor => (0, _item.createItemFromDescriptor)(descriptor)) - }); - return { - options, - context, - fileHandling: configChain.fileHandling, - ignore: configChain.ignore, - babelrc: configChain.babelrc, - config: configChain.config, - files: configChain.files - }; -} -function* loadPartialConfig(opts) { - let showIgnoredFiles = false; - if (typeof opts === "object" && opts !== null && !Array.isArray(opts)) { - var _opts = opts; - ({ - showIgnoredFiles - } = _opts); - opts = _objectWithoutPropertiesLoose(_opts, _excluded); - _opts; - } - const result = yield* loadPrivatePartialConfig(opts); - if (!result) return null; - const { - options, - babelrc, - ignore, - config, - 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()"); - } - }); - return new PartialConfig(options, babelrc ? babelrc.filepath : undefined, ignore ? ignore.filepath : undefined, config ? config.filepath : undefined, fileHandling, files); -} -class PartialConfig { - constructor(options, babelrc, ignore, config, fileHandling, files) { - this.options = void 0; - this.babelrc = void 0; - this.babelignore = void 0; - this.config = void 0; - this.fileHandling = void 0; - this.files = void 0; - this.options = options; - this.babelignore = ignore; - this.babelrc = babelrc; - 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; - -//# sourceMappingURL=partial.js.map diff --git a/tools/eslint/node_modules/@babel/core/lib/config/pattern-to-regex.js b/tools/eslint/node_modules/@babel/core/lib/config/pattern-to-regex.js deleted file mode 100644 index e061f79350264d..00000000000000 --- a/tools/eslint/node_modules/@babel/core/lib/config/pattern-to-regex.js +++ /dev/null @@ -1,38 +0,0 @@ -"use strict"; - -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}]+`; -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) { - return substitution + escapeRegExp(part.slice(1)) + (last ? endSep : sep); - } - return escapeRegExp(part) + (last ? endSep : sep); - })].join("")); -} -0 && 0; - -//# sourceMappingURL=pattern-to-regex.js.map diff --git a/tools/eslint/node_modules/@babel/core/lib/config/plugin.js b/tools/eslint/node_modules/@babel/core/lib/config/plugin.js deleted file mode 100644 index 21a28cd5a54219..00000000000000 --- a/tools/eslint/node_modules/@babel/core/lib/config/plugin.js +++ /dev/null @@ -1,33 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.default = void 0; -var _deepArray = require("./helpers/deep-array.js"); -class Plugin { - constructor(plugin, options, key, externalDependencies = (0, _deepArray.finalize)([])) { - this.key = void 0; - this.manipulateOptions = void 0; - this.post = void 0; - this.pre = void 0; - this.visitor = void 0; - this.parserOverride = void 0; - this.generatorOverride = void 0; - this.options = void 0; - this.externalDependencies = void 0; - this.key = plugin.name || key; - this.manipulateOptions = plugin.manipulateOptions; - this.post = plugin.post; - this.pre = plugin.pre; - this.visitor = plugin.visitor || {}; - this.parserOverride = plugin.parserOverride; - this.generatorOverride = plugin.generatorOverride; - this.options = options; - this.externalDependencies = externalDependencies; - } -} -exports.default = Plugin; -0 && 0; - -//# sourceMappingURL=plugin.js.map diff --git a/tools/eslint/node_modules/@babel/core/lib/config/printer.js b/tools/eslint/node_modules/@babel/core/lib/config/printer.js deleted file mode 100644 index 3ac2c0753db363..00000000000000 --- a/tools/eslint/node_modules/@babel/core/lib/config/printer.js +++ /dev/null @@ -1,113 +0,0 @@ -"use strict"; - -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 = exports.ChainFormatter = { - Programmatic: 0, - Config: 1 -}; -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; - } else if (typeof d.value === "function") { - name = `[Function: ${d.value.toString().slice(0, 50)} ... ]`; - } - } - if (name == null) { - name = "[Unknown]"; - } - if (d.options === undefined) { - return name; - } else if (d.name == null) { - return [name, d.options]; - } else { - return [name, d.options, d.name]; - } -} -class ConfigPrinter { - constructor() { - this._stack = []; - } - configure(enabled, type, { - callerName, - filepath - }) { - if (!enabled) return () => {}; - return (content, index, envName) => { - this._stack.push({ - type, - callerName, - filepath, - content, - index, - envName - }); - }; - } - static *format(config) { - let title = Formatter.title(config.type, config.callerName, config.filepath); - const loc = Formatter.loc(config.index, config.envName); - if (loc) title += ` ${loc}`; - 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; - -//# sourceMappingURL=printer.js.map diff --git a/tools/eslint/node_modules/@babel/core/lib/config/resolve-targets-browser.js b/tools/eslint/node_modules/@babel/core/lib/config/resolve-targets-browser.js deleted file mode 100644 index 3fdbd882671640..00000000000000 --- a/tools/eslint/node_modules/@babel/core/lib/config/resolve-targets-browser.js +++ /dev/null @@ -1,41 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -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) { - return undefined; -} -function resolveTargets(options, root) { - const optTargets = options.targets; - let targets; - if (typeof optTargets === "string" || Array.isArray(optTargets)) { - targets = { - browsers: optTargets - }; - } else if (optTargets) { - if ("esmodules" in optTargets) { - targets = Object.assign({}, optTargets, { - esmodules: "intersect" - }); - } else { - targets = optTargets; - } - } - return (0, _helperCompilationTargets().default)(targets, { - ignoreBrowserslistConfig: true, - browserslistEnv: options.browserslistEnv - }); -} -0 && 0; - -//# sourceMappingURL=resolve-targets-browser.js.map diff --git a/tools/eslint/node_modules/@babel/core/lib/config/resolve-targets.js b/tools/eslint/node_modules/@babel/core/lib/config/resolve-targets.js deleted file mode 100644 index 1fc539a770cf4c..00000000000000 --- a/tools/eslint/node_modules/@babel/core/lib/config/resolve-targets.js +++ /dev/null @@ -1,61 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -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 - }; - } else if (optTargets) { - if ("esmodules" in optTargets) { - targets = Object.assign({}, optTargets, { - esmodules: "intersect" - }); - } else { - 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, - configPath: root, - browserslistEnv: options.browserslistEnv - }); -} -0 && 0; - -//# sourceMappingURL=resolve-targets.js.map diff --git a/tools/eslint/node_modules/@babel/core/lib/config/util.js b/tools/eslint/node_modules/@babel/core/lib/config/util.js deleted file mode 100644 index 077f1af8cd116c..00000000000000 --- a/tools/eslint/node_modules/@babel/core/lib/config/util.js +++ /dev/null @@ -1,31 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -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]) { - const parserOpts = source[k]; - const targetObj = target[k] || (target[k] = {}); - mergeDefaultFields(targetObj, parserOpts); - } else { - const val = source[k]; - if (val !== undefined) target[k] = val; - } - } -} -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 diff --git a/tools/eslint/node_modules/@babel/core/lib/config/validation/option-assertions.js b/tools/eslint/node_modules/@babel/core/lib/config/validation/option-assertions.js deleted file mode 100644 index 73d577c585ca99..00000000000000 --- a/tools/eslint/node_modules/@babel/core/lib/config/validation/option-assertions.js +++ /dev/null @@ -1,277 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.access = access; -exports.assertArray = assertArray; -exports.assertAssumptions = assertAssumptions; -exports.assertBabelrcSearch = assertBabelrcSearch; -exports.assertBoolean = assertBoolean; -exports.assertCallerMetadata = assertCallerMetadata; -exports.assertCompact = assertCompact; -exports.assertConfigApplicableTest = assertConfigApplicableTest; -exports.assertConfigFileSearch = assertConfigFileSearch; -exports.assertFunction = assertFunction; -exports.assertIgnoreList = assertIgnoreList; -exports.assertInputSourceMap = assertInputSourceMap; -exports.assertObject = assertObject; -exports.assertPluginList = assertPluginList; -exports.assertRootMode = assertRootMode; -exports.assertSourceMaps = assertSourceMaps; -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.js"); -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", - 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); - arr == null || 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)) { - throw new Error(`${msg(access(loc, i))} must be a string/Function/RegExp.`); - } - }); - } 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)) { - throw new Error(`${msg(access(loc, i))} must be a string/Function/RegExp.`); - } - }); - } 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`); - } - } - } else { - assertPluginTarget(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); - if (key === "esmodules") assertBoolean(subLoc, val);else if (key === "browsers") assertBrowsersList(subLoc, val);else if (!hasOwnProperty.call(_helperCompilationTargets().TargetNames, key)) { - const validTargets = Object.keys(_helperCompilationTargets().TargetNames).join(", "); - 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.`); - } - } - return value; -} -0 && 0; - -//# sourceMappingURL=option-assertions.js.map diff --git a/tools/eslint/node_modules/@babel/core/lib/config/validation/options.js b/tools/eslint/node_modules/@babel/core/lib/config/validation/options.js deleted file mode 100644 index 3b78adac66724c..00000000000000 --- a/tools/eslint/node_modules/@babel/core/lib/config/validation/options.js +++ /dev/null @@ -1,189 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.assumptionsNames = void 0; -exports.checkNoUnwrappedItemOptionPairs = checkNoUnwrappedItemOptionPairs; -exports.validate = validate; -var _removed = require("./removed.js"); -var _optionAssertions = require("./option-assertions.js"); -var _configError = require("../../errors/config-error.js"); -const ROOT_VALIDATORS = { - cwd: _optionAssertions.assertString, - root: _optionAssertions.assertString, - rootMode: _optionAssertions.assertRootMode, - configFile: _optionAssertions.assertConfigFileSearch, - caller: _optionAssertions.assertCallerMetadata, - filename: _optionAssertions.assertString, - filenameRelative: _optionAssertions.assertString, - code: _optionAssertions.assertBoolean, - ast: _optionAssertions.assertBoolean, - cloneInputAst: _optionAssertions.assertBoolean, - envName: _optionAssertions.assertString -}; -const BABELRC_VALIDATORS = { - babelrc: _optionAssertions.assertBoolean, - babelrcRoots: _optionAssertions.assertBabelrcSearch -}; -const NONPRESET_VALIDATORS = { - extends: _optionAssertions.assertString, - ignore: _optionAssertions.assertIgnoreList, - only: _optionAssertions.assertIgnoreList, - targets: _optionAssertions.assertTargets, - browserslistConfigFile: _optionAssertions.assertConfigFileSearch, - browserslistEnv: _optionAssertions.assertString -}; -const COMMON_VALIDATORS = { - inputSourceMap: _optionAssertions.assertInputSourceMap, - presets: _optionAssertions.assertPluginList, - plugins: _optionAssertions.assertPluginList, - passPerPreset: _optionAssertions.assertBoolean, - assumptions: _optionAssertions.assertAssumptions, - env: assertEnvSet, - overrides: assertOverridesList, - test: _optionAssertions.assertConfigApplicableTest, - include: _optionAssertions.assertConfigApplicableTest, - exclude: _optionAssertions.assertConfigApplicableTest, - retainLines: _optionAssertions.assertBoolean, - comments: _optionAssertions.assertBoolean, - shouldPrintComment: _optionAssertions.assertFunction, - compact: _optionAssertions.assertCompact, - minified: _optionAssertions.assertBoolean, - auxiliaryCommentBefore: _optionAssertions.assertString, - auxiliaryCommentAfter: _optionAssertions.assertString, - sourceType: _optionAssertions.assertSourceType, - wrapPluginVisitorMethod: _optionAssertions.assertFunction, - highlightCode: _optionAssertions.assertBoolean, - sourceMaps: _optionAssertions.assertSourceMaps, - sourceMap: _optionAssertions.assertSourceMaps, - sourceFileName: _optionAssertions.assertString, - sourceRoot: _optionAssertions.assertString, - parserOpts: _optionAssertions.assertObject, - generatorOpts: _optionAssertions.assertObject -}; -{ - Object.assign(COMMON_VALIDATORS, { - getModuleId: _optionAssertions.assertFunction, - moduleRoot: _optionAssertions.assertString, - moduleIds: _optionAssertions.assertBoolean, - moduleId: _optionAssertions.assertString - }); -} -const knownAssumptions = ["arrayLikeIsIterable", "constantReexports", "constantSuper", "enumerableModuleMeta", "ignoreFunctionLength", "ignoreToPrimitiveHint", "iterableIsArray", "mutableTemplateObject", "noClassCalls", "noDocumentAll", "noIncompleteNsImportDetection", "noNewArrows", "noUninitializedPrivateFieldAccess", "objectRestNoSymbols", "privateFieldsAsSymbols", "privateFieldsAsProperties", "pureGetters", "setClassMethods", "setComputedProperties", "setPublicClassFields", "setSpreadProperties", "skipForOfIteratorClosing", "superIsCallableConstructor"]; -const assumptionsNames = exports.assumptionsNames = new Set(knownAssumptions); -function getSource(loc) { - return loc.type === "root" ? loc.source : getSource(loc.parent); -} -function validate(type, opts, filename) { - try { - return validateNested({ - type: "root", - source: type - }, opts); - } catch (error) { - const configError = new _configError.default(error.message, filename); - if (error.code) configError.code = error.code; - throw configError; - } -} -function validateNested(loc, opts) { - const type = getSource(loc); - assertNoDuplicateSourcemap(opts); - Object.keys(opts).forEach(key => { - const optLoc = { - type: "option", - 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, - version = 5 - } = _removed.default[key]; - throw new Error(`Using removed Babel ${version} option: ${(0, _optionAssertions.msg)(loc)} - ${message}`); - } else { - const unknownOptErr = new Error(`Unknown option: ${(0, _optionAssertions.msg)(loc)}. Check out https://babeljs.io/docs/en/babel-core/#options for more information about options.`); - unknownOptErr.code = "BABEL_UNKNOWN_OPTION"; - throw unknownOptErr; - } -} -function assertNoDuplicateSourcemap(opts) { - if (hasOwnProperty.call(opts, "sourceMap") && hasOwnProperty.call(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]); - if (!env) continue; - const envLoc = { - type: "env", - name: envName, - parent - }; - 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); - const env = (0, _optionAssertions.assertObject)(objLoc, item); - if (!env) throw new Error(`${(0, _optionAssertions.msg)(objLoc)} must be an object`); - const overridesLoc = { - type: "overrides", - index, - parent - }; - 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 diff --git a/tools/eslint/node_modules/@babel/core/lib/config/validation/plugins.js b/tools/eslint/node_modules/@babel/core/lib/config/validation/plugins.js deleted file mode 100644 index d744eccc4c5904..00000000000000 --- a/tools/eslint/node_modules/@babel/core/lib/config/validation/plugins.js +++ /dev/null @@ -1,67 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.validatePluginObject = validatePluginObject; -var _optionAssertions = require("./option-assertions.js"); -const VALIDATORS = { - name: _optionAssertions.assertString, - manipulateOptions: _optionAssertions.assertFunction, - pre: _optionAssertions.assertFunction, - post: _optionAssertions.assertFunction, - inherits: _optionAssertions.assertFunction, - visitor: assertVisitorMap, - parserOverride: _optionAssertions.assertFunction, - generatorOverride: _optionAssertions.assertFunction -}; -function assertVisitorMap(loc, value) { - const obj = (0, _optionAssertions.assertObject)(loc, value); - if (obj) { - Object.keys(obj).forEach(prop => { - if (prop !== "_exploded" && prop !== "_verified") { - 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 => { - if (handler !== "enter" && handler !== "exit") { - throw new Error(`.visitor["${key}"] may only have .enter and/or .exit handlers.`); - } - }); - } else if (typeof value !== "function") { - throw new Error(`.visitor["${key}"] must be a function`); - } -} -function validatePluginObject(obj) { - const rootPath = { - type: "root", - source: "plugin" - }; - Object.keys(obj).forEach(key => { - const validator = VALIDATORS[key]; - if (validator) { - const optLoc = { - type: "option", - name: key, - parent: rootPath - }; - validator(optLoc, obj[key]); - } else { - const invalidPluginPropertyError = new Error(`.${key} is not a valid Plugin property`); - invalidPluginPropertyError.code = "BABEL_UNKNOWN_PLUGIN_PROPERTY"; - throw invalidPluginPropertyError; - } - }); - return obj; -} -0 && 0; - -//# sourceMappingURL=plugins.js.map diff --git a/tools/eslint/node_modules/@babel/core/lib/config/validation/removed.js b/tools/eslint/node_modules/@babel/core/lib/config/validation/removed.js deleted file mode 100644 index 9bd436e88cd92b..00000000000000 --- a/tools/eslint/node_modules/@babel/core/lib/config/validation/removed.js +++ /dev/null @@ -1,68 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.default = void 0; -var _default = exports.default = { - auxiliaryComment: { - message: "Use `auxiliaryCommentBefore` or `auxiliaryCommentAfter`" - }, - blacklist: { - message: "Put the specific transforms you want in the `plugins` option" - }, - breakConfig: { - message: "This is not a necessary option in Babel 6" - }, - experimental: { - message: "Put the specific transforms you want in the `plugins` option" - }, - externalHelpers: { - message: "Use the `external-helpers` plugin instead. " + "Check out http://babeljs.io/docs/plugins/external-helpers/" - }, - extra: { - message: "" - }, - jsxPragma: { - message: "use the `pragma` option in the `react-jsx` plugin. " + "Check out http://babeljs.io/docs/plugins/transform-react-jsx/" - }, - loose: { - message: "Specify the `loose` option for the relevant plugin you are using " + "or use a preset that sets the option." - }, - metadataUsedHelpers: { - message: "Not required anymore as this is enabled by default" - }, - modules: { - message: "Use the corresponding module transform plugin in the `plugins` option. " + "Check out http://babeljs.io/docs/plugins/#modules" - }, - nonStandard: { - message: "Use the `react-jsx` and `flow-strip-types` plugins to support JSX and Flow. " + "Also check out the react preset http://babeljs.io/docs/plugins/preset-react/" - }, - optional: { - message: "Put the specific transforms you want in the `plugins` option" - }, - sourceMapName: { - message: "The `sourceMapName` option has been removed because it makes more sense for the " + "tooling that calls Babel to assign `map.file` themselves." - }, - stage: { - message: "Check out the corresponding stage-x presets http://babeljs.io/docs/plugins/#presets" - }, - whitelist: { - message: "Put the specific transforms you want in the `plugins` option" - }, - resolveModuleSource: { - version: 6, - message: "Use `babel-plugin-module-resolver@3`'s 'resolvePath' options" - }, - metadata: { - version: 6, - message: "Generated plugin metadata is always included in the output result" - }, - sourceMapTarget: { - version: 6, - message: "The `sourceMapTarget` option has been removed because it makes more sense for the tooling " + "that calls Babel to assign `map.file` themselves." - } -}; -0 && 0; - -//# sourceMappingURL=removed.js.map diff --git a/tools/eslint/node_modules/@babel/core/lib/errors/config-error.js b/tools/eslint/node_modules/@babel/core/lib/errors/config-error.js deleted file mode 100644 index c290804789dbf8..00000000000000 --- a/tools/eslint/node_modules/@babel/core/lib/errors/config-error.js +++ /dev/null @@ -1,18 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.default = void 0; -var _rewriteStackTrace = require("./rewrite-stack-trace.js"); -class ConfigError extends Error { - constructor(message, filename) { - super(message); - (0, _rewriteStackTrace.expectedError)(this); - if (filename) (0, _rewriteStackTrace.injectVirtualStackFrame)(this, filename); - } -} -exports.default = ConfigError; -0 && 0; - -//# sourceMappingURL=config-error.js.map diff --git a/tools/eslint/node_modules/@babel/core/lib/errors/rewrite-stack-trace.js b/tools/eslint/node_modules/@babel/core/lib/errors/rewrite-stack-trace.js deleted file mode 100644 index 68896d38347a23..00000000000000 --- a/tools/eslint/node_modules/@babel/core/lib/errors/rewrite-stack-trace.js +++ /dev/null @@ -1,98 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.beginHiddenCallStack = beginHiddenCallStack; -exports.endHiddenCallStack = endHiddenCallStack; -exports.expectedError = expectedError; -exports.injectVirtualStackFrame = injectVirtualStackFrame; -var _Object$getOwnPropert; -const ErrorToString = Function.call.bind(Error.prototype.toString); -const SUPPORTED = !!Error.captureStackTrace && ((_Object$getOwnPropert = Object.getOwnPropertyDescriptor(Error, "stackTraceLimit")) == null ? void 0 : _Object$getOwnPropert.writable) === true; -const START_HIDING = "startHiding - secret - don't use this - v1"; -const STOP_HIDING = "stopHiding - secret - don't use this - v1"; -const expectedErrors = new WeakSet(); -const virtualFrames = new WeakMap(); -function CallSite(filename) { - return Object.create({ - isNative: () => false, - isConstructor: () => false, - isToplevel: () => true, - getFileName: () => filename, - getLineNumber: () => undefined, - getColumnNumber: () => undefined, - getFunctionName: () => undefined, - getMethodName: () => undefined, - getTypeName: () => undefined, - toString: () => filename - }); -} -function injectVirtualStackFrame(error, filename) { - if (!SUPPORTED) return; - let frames = virtualFrames.get(error); - if (!frames) virtualFrames.set(error, frames = []); - 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) { - setupPrepareStackTrace(); - return fn(...args); - }, "name", { - value: STOP_HIDING - }); -} -function endHiddenCallStack(fn) { - if (!SUPPORTED) return fn; - return Object.defineProperty(function (...args) { - return fn(...args); - }, "name", { - value: START_HIDING - }); -} -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_HIDING) { - status = "hiding"; - } else if (name === STOP_HIDING) { - if (status === "hiding") { - status = "showing"; - if (virtualFrames.has(err)) { - newTrace.unshift(...virtualFrames.get(err)); - } - } else if (status === "unknown") { - newTrace = trace; - break; - } - } else if (status !== "hiding") { - 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 diff --git a/tools/eslint/node_modules/@babel/core/lib/gensync-utils/async.js b/tools/eslint/node_modules/@babel/core/lib/gensync-utils/async.js deleted file mode 100644 index 9e00fde8b5f47e..00000000000000 --- a/tools/eslint/node_modules/@babel/core/lib/gensync-utils/async.js +++ /dev/null @@ -1,90 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.forwardAsync = forwardAsync; -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; -}); -const isAsync = exports.isAsync = _gensync()({ - sync: () => false, - errback: cb => cb(null, true) -}); -function maybeAsync(fn, message) { - return _gensync()({ - sync(...args) { - const result = fn.apply(this, args); - 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); - }; - }() -}); -function forwardAsync(action, cb) { - const g = _gensync()(action); - return withKind(kind => { - const adapted = g[kind]; - return cb(adapted); - }); -} -const onFirstPause = exports.onFirstPause = _gensync()({ - name: "onFirstPause", - arity: 2, - sync: function (item) { - return runGenerator.sync(item); - }, - errback: function (item, firstPause, cb) { - let completed = false; - runGenerator.errback(item, (err, value) => { - completed = true; - cb(err, value); - }); - if (!completed) { - firstPause(); - } - } -}); -const waitFor = exports.waitFor = _gensync()({ - sync: x => x, - async: function () { - var _ref2 = _asyncToGenerator(function* (x) { - return x; - }); - return function async(_x2) { - return _ref2.apply(this, arguments); - }; - }() -}); -function isThenable(val) { - return !!val && (typeof val === "object" || typeof val === "function") && !!val.then && typeof val.then === "function"; -} -0 && 0; - -//# sourceMappingURL=async.js.map diff --git a/tools/eslint/node_modules/@babel/core/lib/gensync-utils/fs.js b/tools/eslint/node_modules/@babel/core/lib/gensync-utils/fs.js deleted file mode 100644 index b842df84d9d815..00000000000000 --- a/tools/eslint/node_modules/@babel/core/lib/gensync-utils/fs.js +++ /dev/null @@ -1,31 +0,0 @@ -"use strict"; - -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 = exports.readFile = _gensync()({ - sync: _fs().readFileSync, - errback: _fs().readFile -}); -const stat = exports.stat = _gensync()({ - sync: _fs().statSync, - errback: _fs().stat -}); -0 && 0; - -//# sourceMappingURL=fs.js.map diff --git a/tools/eslint/node_modules/@babel/core/lib/gensync-utils/functional.js b/tools/eslint/node_modules/@babel/core/lib/gensync-utils/functional.js deleted file mode 100644 index d7f77554fb0b9f..00000000000000 --- a/tools/eslint/node_modules/@babel/core/lib/gensync-utils/functional.js +++ /dev/null @@ -1,58 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.once = once; -var _async = require("./async.js"); -function once(fn) { - let result; - let resultP; - let promiseReferenced = false; - return function* () { - if (!result) { - if (resultP) { - promiseReferenced = true; - return yield* (0, _async.waitFor)(resultP); - } - if (!(yield* (0, _async.isAsync)())) { - try { - result = { - ok: true, - value: yield* fn() - }; - } catch (error) { - result = { - ok: false, - value: error - }; - } - } else { - let resolve, reject; - resultP = new Promise((res, rej) => { - resolve = res; - reject = rej; - }); - try { - result = { - ok: true, - value: yield* fn() - }; - resultP = null; - if (promiseReferenced) resolve(result.value); - } catch (error) { - result = { - ok: false, - value: error - }; - resultP = null; - if (promiseReferenced) reject(error); - } - } - } - if (result.ok) return result.value;else throw result.value; - }; -} -0 && 0; - -//# sourceMappingURL=functional.js.map diff --git a/tools/eslint/node_modules/@babel/core/lib/index.js b/tools/eslint/node_modules/@babel/core/lib/index.js deleted file mode 100644 index b2f551ccf397ac..00000000000000 --- a/tools/eslint/node_modules/@babel/core/lib/index.js +++ /dev/null @@ -1,242 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.DEFAULT_EXTENSIONS = void 0; -Object.defineProperty(exports, "File", { - enumerable: true, - get: function () { - return _file.default; - } -}); -Object.defineProperty(exports, "buildExternalHelpers", { - enumerable: true, - get: function () { - return _buildExternalHelpers.default; - } -}); -Object.defineProperty(exports, "createConfigItem", { - enumerable: true, - get: function () { - return _index2.createConfigItem; - } -}); -Object.defineProperty(exports, "createConfigItemAsync", { - enumerable: true, - get: function () { - return _index2.createConfigItemAsync; - } -}); -Object.defineProperty(exports, "createConfigItemSync", { - enumerable: true, - get: function () { - return _index2.createConfigItemSync; - } -}); -Object.defineProperty(exports, "getEnv", { - enumerable: true, - get: function () { - return _environment.getEnv; - } -}); -Object.defineProperty(exports, "loadOptions", { - enumerable: true, - get: function () { - return _index2.loadOptions; - } -}); -Object.defineProperty(exports, "loadOptionsAsync", { - enumerable: true, - get: function () { - return _index2.loadOptionsAsync; - } -}); -Object.defineProperty(exports, "loadOptionsSync", { - enumerable: true, - get: function () { - return _index2.loadOptionsSync; - } -}); -Object.defineProperty(exports, "loadPartialConfig", { - enumerable: true, - get: function () { - return _index2.loadPartialConfig; - } -}); -Object.defineProperty(exports, "loadPartialConfigAsync", { - enumerable: true, - get: function () { - return _index2.loadPartialConfigAsync; - } -}); -Object.defineProperty(exports, "loadPartialConfigSync", { - enumerable: true, - get: function () { - return _index2.loadPartialConfigSync; - } -}); -Object.defineProperty(exports, "parse", { - enumerable: true, - get: function () { - return _parse.parse; - } -}); -Object.defineProperty(exports, "parseAsync", { - enumerable: true, - get: function () { - return _parse.parseAsync; - } -}); -Object.defineProperty(exports, "parseSync", { - enumerable: true, - get: function () { - return _parse.parseSync; - } -}); -Object.defineProperty(exports, "resolvePlugin", { - enumerable: true, - get: function () { - return _index.resolvePlugin; - } -}); -Object.defineProperty(exports, "resolvePreset", { - enumerable: true, - get: function () { - return _index.resolvePreset; - } -}); -Object.defineProperty((0, exports), "template", { - enumerable: true, - get: function () { - return _template().default; - } -}); -Object.defineProperty((0, exports), "tokTypes", { - enumerable: true, - get: function () { - return _parser().tokTypes; - } -}); -Object.defineProperty(exports, "transform", { - enumerable: true, - get: function () { - return _transform.transform; - } -}); -Object.defineProperty(exports, "transformAsync", { - enumerable: true, - get: function () { - return _transform.transformAsync; - } -}); -Object.defineProperty(exports, "transformFile", { - enumerable: true, - get: function () { - return _transformFile.transformFile; - } -}); -Object.defineProperty(exports, "transformFileAsync", { - enumerable: true, - get: function () { - return _transformFile.transformFileAsync; - } -}); -Object.defineProperty(exports, "transformFileSync", { - enumerable: true, - get: function () { - return _transformFile.transformFileSync; - } -}); -Object.defineProperty(exports, "transformFromAst", { - enumerable: true, - get: function () { - return _transformAst.transformFromAst; - } -}); -Object.defineProperty(exports, "transformFromAstAsync", { - enumerable: true, - get: function () { - return _transformAst.transformFromAstAsync; - } -}); -Object.defineProperty(exports, "transformFromAstSync", { - enumerable: true, - get: function () { - return _transformAst.transformFromAstSync; - } -}); -Object.defineProperty(exports, "transformSync", { - enumerable: true, - get: function () { - return _transform.transformSync; - } -}); -Object.defineProperty((0, exports), "traverse", { - enumerable: true, - get: function () { - return _traverse().default; - } -}); -exports.version = exports.types = void 0; -var _file = require("./transformation/file/file.js"); -var _buildExternalHelpers = require("./tools/build-external-helpers.js"); -var _index = require("./config/files/index.js"); -var _environment = require("./config/helpers/environment.js"); -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 _index2 = require("./config/index.js"); -var _transform = require("./transform.js"); -var _transformFile = require("./transform-file.js"); -var _transformAst = require("./transform-ast.js"); -var _parse = require("./parse.js"); -var thisFile = require("./index.js"); -; -const version = exports.version = "7.24.8"; -const DEFAULT_EXTENSIONS = exports.DEFAULT_EXTENSIONS = Object.freeze([".js", ".jsx", ".es6", ".es", ".mjs", ".cjs"]); -; -{ - exports.OptionManager = class OptionManager { - init(opts) { - return (0, _index2.loadOptionsSync)(opts); - } - }; - exports.Plugin = 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 diff --git a/tools/eslint/node_modules/@babel/core/lib/parse.js b/tools/eslint/node_modules/@babel/core/lib/parse.js deleted file mode 100644 index 7e4114245f7cd2..00000000000000 --- a/tools/eslint/node_modules/@babel/core/lib/parse.js +++ /dev/null @@ -1,47 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.parse = void 0; -exports.parseAsync = parseAsync; -exports.parseSync = parseSync; -function _gensync() { - const data = require("gensync"); - _gensync = function () { - return data; - }; - return data; -} -var _index = require("./config/index.js"); -var _index2 = require("./parser/index.js"); -var _normalizeOpts = require("./transformation/normalize-opts.js"); -var _rewriteStackTrace = require("./errors/rewrite-stack-trace.js"); -const parseRunner = _gensync()(function* parse(code, opts) { - const config = yield* (0, _index.default)(opts); - if (config === null) { - return null; - } - return yield* (0, _index2.default)(config.passes, (0, _normalizeOpts.default)(config), code); -}); -const parse = exports.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); -}; -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 diff --git a/tools/eslint/node_modules/@babel/core/lib/parser/index.js b/tools/eslint/node_modules/@babel/core/lib/parser/index.js deleted file mode 100644 index d198bb21d55b20..00000000000000 --- a/tools/eslint/node_modules/@babel/core/lib/parser/index.js +++ /dev/null @@ -1,79 +0,0 @@ -"use strict"; - -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.js"); -function* parser(pluginPasses, { - parserOpts, - highlightCode = true, - filename = "unknown" -}, 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") { - err.message += "\nConsider renaming the file to '.mjs', or setting sourceType:module " + "or sourceType:unambiguous in your Babel config for this file."; - } - const { - loc, - missingPlugin - } = err; - if (loc) { - const codeFrame = (0, _codeFrame().codeFrameColumns)(code, { - start: { - line: loc.line, - column: loc.column + 1 - } - }, { - highlightCode - }); - if (missingPlugin) { - err.message = `${filename}: ` + (0, _missingPluginHelper.default)(missingPlugin[0], loc, codeFrame, filename); - } else { - err.message = `${filename}: ${err.message}\n\n` + codeFrame; - } - err.code = "BABEL_PARSE_ERROR"; - } - throw err; - } -} -0 && 0; - -//# sourceMappingURL=index.js.map diff --git a/tools/eslint/node_modules/@babel/core/lib/parser/util/missing-plugin-helper.js b/tools/eslint/node_modules/@babel/core/lib/parser/util/missing-plugin-helper.js deleted file mode 100644 index 166e9738bde75a..00000000000000 --- a/tools/eslint/node_modules/@babel/core/lib/parser/util/missing-plugin-helper.js +++ /dev/null @@ -1,339 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.default = generateMissingPluginMessage; -const pluginNameMap = { - asyncDoExpressions: { - syntax: { - name: "@babel/plugin-syntax-async-do-expressions", - url: "https://github.com/babel/babel/tree/main/packages/babel-plugin-syntax-async-do-expressions" - } - }, - decimal: { - syntax: { - name: "@babel/plugin-syntax-decimal", - url: "https://github.com/babel/babel/tree/main/packages/babel-plugin-syntax-decimal" - } - }, - decorators: { - syntax: { - name: "@babel/plugin-syntax-decorators", - url: "https://github.com/babel/babel/tree/main/packages/babel-plugin-syntax-decorators" - }, - transform: { - name: "@babel/plugin-proposal-decorators", - url: "https://github.com/babel/babel/tree/main/packages/babel-plugin-proposal-decorators" - } - }, - doExpressions: { - syntax: { - name: "@babel/plugin-syntax-do-expressions", - url: "https://github.com/babel/babel/tree/main/packages/babel-plugin-syntax-do-expressions" - }, - transform: { - name: "@babel/plugin-proposal-do-expressions", - url: "https://github.com/babel/babel/tree/main/packages/babel-plugin-proposal-do-expressions" - } - }, - exportDefaultFrom: { - syntax: { - name: "@babel/plugin-syntax-export-default-from", - url: "https://github.com/babel/babel/tree/main/packages/babel-plugin-syntax-export-default-from" - }, - transform: { - name: "@babel/plugin-proposal-export-default-from", - url: "https://github.com/babel/babel/tree/main/packages/babel-plugin-proposal-export-default-from" - } - }, - flow: { - syntax: { - name: "@babel/plugin-syntax-flow", - url: "https://github.com/babel/babel/tree/main/packages/babel-plugin-syntax-flow" - }, - transform: { - name: "@babel/preset-flow", - url: "https://github.com/babel/babel/tree/main/packages/babel-preset-flow" - } - }, - functionBind: { - syntax: { - name: "@babel/plugin-syntax-function-bind", - url: "https://github.com/babel/babel/tree/main/packages/babel-plugin-syntax-function-bind" - }, - transform: { - name: "@babel/plugin-proposal-function-bind", - url: "https://github.com/babel/babel/tree/main/packages/babel-plugin-proposal-function-bind" - } - }, - functionSent: { - syntax: { - name: "@babel/plugin-syntax-function-sent", - url: "https://github.com/babel/babel/tree/main/packages/babel-plugin-syntax-function-sent" - }, - transform: { - name: "@babel/plugin-proposal-function-sent", - url: "https://github.com/babel/babel/tree/main/packages/babel-plugin-proposal-function-sent" - } - }, - jsx: { - syntax: { - name: "@babel/plugin-syntax-jsx", - url: "https://github.com/babel/babel/tree/main/packages/babel-plugin-syntax-jsx" - }, - transform: { - name: "@babel/preset-react", - url: "https://github.com/babel/babel/tree/main/packages/babel-preset-react" - } - }, - importAttributes: { - syntax: { - name: "@babel/plugin-syntax-import-attributes", - url: "https://github.com/babel/babel/tree/main/packages/babel-plugin-syntax-import-attributes" - } - }, - pipelineOperator: { - syntax: { - name: "@babel/plugin-syntax-pipeline-operator", - url: "https://github.com/babel/babel/tree/main/packages/babel-plugin-syntax-pipeline-operator" - }, - transform: { - name: "@babel/plugin-proposal-pipeline-operator", - url: "https://github.com/babel/babel/tree/main/packages/babel-plugin-proposal-pipeline-operator" - } - }, - recordAndTuple: { - syntax: { - name: "@babel/plugin-syntax-record-and-tuple", - url: "https://github.com/babel/babel/tree/main/packages/babel-plugin-syntax-record-and-tuple" - } - }, - throwExpressions: { - syntax: { - name: "@babel/plugin-syntax-throw-expressions", - url: "https://github.com/babel/babel/tree/main/packages/babel-plugin-syntax-throw-expressions" - }, - transform: { - name: "@babel/plugin-proposal-throw-expressions", - url: "https://github.com/babel/babel/tree/main/packages/babel-plugin-proposal-throw-expressions" - } - }, - typescript: { - syntax: { - name: "@babel/plugin-syntax-typescript", - url: "https://github.com/babel/babel/tree/main/packages/babel-plugin-syntax-typescript" - }, - transform: { - name: "@babel/preset-typescript", - url: "https://github.com/babel/babel/tree/main/packages/babel-preset-typescript" - } - } -}; -{ - Object.assign(pluginNameMap, { - asyncGenerators: { - syntax: { - name: "@babel/plugin-syntax-async-generators", - url: "https://github.com/babel/babel/tree/main/packages/babel-plugin-syntax-async-generators" - }, - transform: { - name: "@babel/plugin-transform-async-generator-functions", - url: "https://github.com/babel/babel/tree/main/packages/babel-plugin-transform-async-generator-functions" - } - }, - classProperties: { - syntax: { - name: "@babel/plugin-syntax-class-properties", - url: "https://github.com/babel/babel/tree/main/packages/babel-plugin-syntax-class-properties" - }, - transform: { - name: "@babel/plugin-transform-class-properties", - url: "https://github.com/babel/babel/tree/main/packages/babel-plugin-transform-class-properties" - } - }, - classPrivateProperties: { - syntax: { - name: "@babel/plugin-syntax-class-properties", - url: "https://github.com/babel/babel/tree/main/packages/babel-plugin-syntax-class-properties" - }, - transform: { - name: "@babel/plugin-transform-class-properties", - url: "https://github.com/babel/babel/tree/main/packages/babel-plugin-transform-class-properties" - } - }, - classPrivateMethods: { - syntax: { - name: "@babel/plugin-syntax-class-properties", - url: "https://github.com/babel/babel/tree/main/packages/babel-plugin-syntax-class-properties" - }, - transform: { - name: "@babel/plugin-transform-private-methods", - url: "https://github.com/babel/babel/tree/main/packages/babel-plugin-transform-private-methods" - } - }, - classStaticBlock: { - syntax: { - name: "@babel/plugin-syntax-class-static-block", - url: "https://github.com/babel/babel/tree/HEAD/packages/babel-plugin-syntax-class-static-block" - }, - transform: { - name: "@babel/plugin-transform-class-static-block", - url: "https://github.com/babel/babel/tree/HEAD/packages/babel-plugin-transform-class-static-block" - } - }, - dynamicImport: { - syntax: { - name: "@babel/plugin-syntax-dynamic-import", - url: "https://github.com/babel/babel/tree/main/packages/babel-plugin-syntax-dynamic-import" - } - }, - exportNamespaceFrom: { - syntax: { - name: "@babel/plugin-syntax-export-namespace-from", - url: "https://github.com/babel/babel/tree/main/packages/babel-plugin-syntax-export-namespace-from" - }, - transform: { - name: "@babel/plugin-transform-export-namespace-from", - url: "https://github.com/babel/babel/tree/main/packages/babel-plugin-transform-export-namespace-from" - } - }, - importAssertions: { - syntax: { - name: "@babel/plugin-syntax-import-assertions", - url: "https://github.com/babel/babel/tree/main/packages/babel-plugin-syntax-import-assertions" - } - }, - importMeta: { - syntax: { - name: "@babel/plugin-syntax-import-meta", - url: "https://github.com/babel/babel/tree/main/packages/babel-plugin-syntax-import-meta" - } - }, - logicalAssignment: { - syntax: { - name: "@babel/plugin-syntax-logical-assignment-operators", - url: "https://github.com/babel/babel/tree/main/packages/babel-plugin-syntax-logical-assignment-operators" - }, - transform: { - name: "@babel/plugin-transform-logical-assignment-operators", - url: "https://github.com/babel/babel/tree/main/packages/babel-plugin-transform-logical-assignment-operators" - } - }, - moduleStringNames: { - syntax: { - name: "@babel/plugin-syntax-module-string-names", - url: "https://github.com/babel/babel/tree/main/packages/babel-plugin-syntax-module-string-names" - } - }, - numericSeparator: { - syntax: { - name: "@babel/plugin-syntax-numeric-separator", - url: "https://github.com/babel/babel/tree/main/packages/babel-plugin-syntax-numeric-separator" - }, - transform: { - name: "@babel/plugin-transform-numeric-separator", - url: "https://github.com/babel/babel/tree/main/packages/babel-plugin-transform-numeric-separator" - } - }, - nullishCoalescingOperator: { - syntax: { - name: "@babel/plugin-syntax-nullish-coalescing-operator", - url: "https://github.com/babel/babel/tree/main/packages/babel-plugin-syntax-nullish-coalescing-operator" - }, - transform: { - name: "@babel/plugin-transform-nullish-coalescing-operator", - url: "https://github.com/babel/babel/tree/main/packages/babel-plugin-transform-nullish-coalescing-opearator" - } - }, - objectRestSpread: { - syntax: { - name: "@babel/plugin-syntax-object-rest-spread", - url: "https://github.com/babel/babel/tree/main/packages/babel-plugin-syntax-object-rest-spread" - }, - transform: { - name: "@babel/plugin-transform-object-rest-spread", - url: "https://github.com/babel/babel/tree/main/packages/babel-plugin-transform-object-rest-spread" - } - }, - optionalCatchBinding: { - syntax: { - name: "@babel/plugin-syntax-optional-catch-binding", - url: "https://github.com/babel/babel/tree/main/packages/babel-plugin-syntax-optional-catch-binding" - }, - transform: { - name: "@babel/plugin-transform-optional-catch-binding", - url: "https://github.com/babel/babel/tree/main/packages/babel-plugin-transform-optional-catch-binding" - } - }, - optionalChaining: { - syntax: { - name: "@babel/plugin-syntax-optional-chaining", - url: "https://github.com/babel/babel/tree/main/packages/babel-plugin-syntax-optional-chaining" - }, - transform: { - name: "@babel/plugin-transform-optional-chaining", - url: "https://github.com/babel/babel/tree/main/packages/babel-plugin-transform-optional-chaining" - } - }, - privateIn: { - syntax: { - name: "@babel/plugin-syntax-private-property-in-object", - url: "https://github.com/babel/babel/tree/main/packages/babel-plugin-syntax-private-property-in-object" - }, - transform: { - name: "@babel/plugin-transform-private-property-in-object", - url: "https://github.com/babel/babel/tree/main/packages/babel-plugin-transform-private-property-in-object" - } - }, - regexpUnicodeSets: { - syntax: { - name: "@babel/plugin-syntax-unicode-sets-regex", - url: "https://github.com/babel/babel/blob/main/packages/babel-plugin-syntax-unicode-sets-regex/README.md" - }, - transform: { - name: "@babel/plugin-transform-unicode-sets-regex", - url: "https://github.com/babel/babel/blob/main/packages/babel-plugin-proposalunicode-sets-regex/README.md" - } - } - }); -} -const getNameURLCombination = ({ - name, - url -}) => `${name} (${url})`; -function generateMissingPluginMessage(missingPluginName, loc, codeFrame, filename) { - 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"; - helpMessage += `\n\nAdd ${transformPluginInfo} to the '${sectionType}' section of your Babel config to enable transformation. -If you want to leave it as-is, add ${syntaxPluginInfo} to the 'plugins' section to enable parsing.`; - } else { - helpMessage += `\n\nAdd ${syntaxPluginInfo} to the 'plugins' section of your Babel config ` + `to enable parsing.`; - } - } - } - const msgFilename = filename === "unknown" ? "" : filename; - helpMessage += ` - -If you already added the plugin for this syntax to your config, it's possible that your config \ -isn't being loaded. -You can re-run Babel with the BABEL_SHOW_CONFIG_FOR environment variable to show the loaded \ -configuration: -\tnpx cross-env BABEL_SHOW_CONFIG_FOR=${msgFilename} -See https://babeljs.io/docs/configuration#print-effective-configs for more info. -`; - return helpMessage; -} -0 && 0; - -//# sourceMappingURL=missing-plugin-helper.js.map diff --git a/tools/eslint/node_modules/@babel/core/lib/tools/build-external-helpers.js b/tools/eslint/node_modules/@babel/core/lib/tools/build-external-helpers.js deleted file mode 100644 index 88c90dccf573ac..00000000000000 --- a/tools/eslint/node_modules/@babel/core/lib/tools/build-external-helpers.js +++ /dev/null @@ -1,144 +0,0 @@ -"use strict"; - -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; -} -const { - arrayExpression, - assignmentExpression, - binaryExpression, - blockStatement, - callExpression, - cloneNode, - conditionalExpression, - exportNamedDeclaration, - exportSpecifier, - expressionStatement, - functionExpression, - identifier, - memberExpression, - objectExpression, - program, - stringLiteral, - unaryExpression, - variableDeclaration, - variableDeclarator -} = _t(); -const buildUmdWrapper = replacements => _template().default.statement` - (function (root, factory) { - if (typeof define === "function" && define.amd) { - define(AMD_ARGUMENTS, factory); - } else if (typeof exports === "object") { - factory(COMMON_ARGUMENTS); - } else { - factory(BROWSER_ARGUMENTS); - } - })(UMD_ROOT, function (FACTORY_PARAMETERS) { - 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"))]))]); - 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); - body.unshift(exportNamedDeclaration(null, Object.keys(refs).map(name => { - return exportSpecifier(cloneNode(refs[name]), identifier(name)); - }))); - return program(body, [], "module"); -} -function buildUmd(allowlist) { - const namespace = identifier("babelHelpers"); - const body = []; - body.push(variableDeclaration("var", [variableDeclarator(namespace, identifier("global"))])); - buildHelpers(body, namespace, allowlist); - return program([buildUmdWrapper({ - FACTORY_PARAMETERS: identifier("global"), - BROWSER_ARGUMENTS: assignmentExpression("=", memberExpression(identifier("root"), namespace), objectExpression([])), - COMMON_ARGUMENTS: identifier("exports"), - AMD_ARGUMENTS: arrayExpression([stringLiteral("exports")]), - FACTORY_BODY: body, - UMD_ROOT: identifier("this") - })]); -} -function buildVar(allowlist) { - const namespace = identifier("babelHelpers"); - const body = []; - body.push(variableDeclaration("var", [variableDeclarator(namespace, objectExpression([]))])); - const tree = program(body); - buildHelpers(body, namespace, 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.includes(name)) return; - const ref = refs[name] = getHelperReference(name); - const { - nodes - } = helpers().get(name, getHelperReference, namespace ? null : `_${name}`, [], namespace ? (ast, exportName, mapExportBindingAssignments) => { - mapExportBindingAssignments(node => assignmentExpression("=", ref, node)); - ast.body.push(expressionStatement(assignmentExpression("=", ref, identifier(exportName)))); - } : null); - body.push(...nodes); - }); - return refs; -} -function _default(allowlist, outputType = "global") { - let tree; - const build = { - global: buildGlobal, - module: buildModule, - 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 diff --git a/tools/eslint/node_modules/@babel/core/lib/transform-ast.js b/tools/eslint/node_modules/@babel/core/lib/transform-ast.js deleted file mode 100644 index 0a86cd10d4dd93..00000000000000 --- a/tools/eslint/node_modules/@babel/core/lib/transform-ast.js +++ /dev/null @@ -1,50 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.transformFromAst = void 0; -exports.transformFromAstAsync = transformFromAstAsync; -exports.transformFromAstSync = transformFromAstSync; -function _gensync() { - const data = require("gensync"); - _gensync = function () { - return data; - }; - return data; -} -var _index = require("./config/index.js"); -var _index2 = require("./transformation/index.js"); -var _rewriteStackTrace = require("./errors/rewrite-stack-trace.js"); -const transformFromAstRunner = _gensync()(function* (ast, code, opts) { - const config = yield* (0, _index.default)(opts); - if (config === null) return null; - if (!ast) throw new Error("No AST given"); - return yield* (0, _index2.run)(config, code, ast); -}); -const transformFromAst = exports.transformFromAst = function transformFromAst(ast, code, optsOrCallback, maybeCallback) { - let opts; - let callback; - if (typeof optsOrCallback === "function") { - callback = optsOrCallback; - opts = undefined; - } else { - 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); -}; -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 diff --git a/tools/eslint/node_modules/@babel/core/lib/transform-file-browser.js b/tools/eslint/node_modules/@babel/core/lib/transform-file-browser.js deleted file mode 100644 index 85768097927851..00000000000000 --- a/tools/eslint/node_modules/@babel/core/lib/transform-file-browser.js +++ /dev/null @@ -1,23 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.transformFile = void 0; -exports.transformFileAsync = transformFileAsync; -exports.transformFileSync = transformFileSync; -const transformFile = exports.transformFile = function transformFile(filename, opts, callback) { - if (typeof opts === "function") { - callback = opts; - } - callback(new Error("Transforming files is not supported in browsers"), null); -}; -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 diff --git a/tools/eslint/node_modules/@babel/core/lib/transform-file.js b/tools/eslint/node_modules/@babel/core/lib/transform-file.js deleted file mode 100644 index ce7f9f97c025cd..00000000000000 --- a/tools/eslint/node_modules/@babel/core/lib/transform-file.js +++ /dev/null @@ -1,40 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.transformFile = transformFile; -exports.transformFileAsync = transformFileAsync; -exports.transformFileSync = transformFileSync; -function _gensync() { - const data = require("gensync"); - _gensync = function () { - return data; - }; - return data; -} -var _index = require("./config/index.js"); -var _index2 = require("./transformation/index.js"); -var fs = require("./gensync-utils/fs.js"); -({}); -const transformFileRunner = _gensync()(function* (filename, opts) { - const options = Object.assign({}, opts, { - filename - }); - const config = yield* (0, _index.default)(options); - if (config === null) return null; - const code = yield* fs.readFile(filename, "utf8"); - return yield* (0, _index2.run)(config, code); -}); -function transformFile(...args) { - transformFileRunner.errback(...args); -} -function transformFileSync(...args) { - return transformFileRunner.sync(...args); -} -function transformFileAsync(...args) { - return transformFileRunner.async(...args); -} -0 && 0; - -//# sourceMappingURL=transform-file.js.map diff --git a/tools/eslint/node_modules/@babel/core/lib/transform.js b/tools/eslint/node_modules/@babel/core/lib/transform.js deleted file mode 100644 index be5570553dac22..00000000000000 --- a/tools/eslint/node_modules/@babel/core/lib/transform.js +++ /dev/null @@ -1,49 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.transform = void 0; -exports.transformAsync = transformAsync; -exports.transformSync = transformSync; -function _gensync() { - const data = require("gensync"); - _gensync = function () { - return data; - }; - return data; -} -var _index = require("./config/index.js"); -var _index2 = require("./transformation/index.js"); -var _rewriteStackTrace = require("./errors/rewrite-stack-trace.js"); -const transformRunner = _gensync()(function* transform(code, opts) { - const config = yield* (0, _index.default)(opts); - if (config === null) return null; - return yield* (0, _index2.run)(config, code); -}); -const transform = exports.transform = function transform(code, optsOrCallback, maybeCallback) { - let opts; - let callback; - if (typeof optsOrCallback === "function") { - callback = optsOrCallback; - opts = undefined; - } else { - opts = optsOrCallback; - callback = maybeCallback; - } - if (callback === undefined) { - { - return (0, _rewriteStackTrace.beginHiddenCallStack)(transformRunner.sync)(code, opts); - } - } - (0, _rewriteStackTrace.beginHiddenCallStack)(transformRunner.errback)(code, opts, callback); -}; -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 diff --git a/tools/eslint/node_modules/@babel/core/lib/transformation/block-hoist-plugin.js b/tools/eslint/node_modules/@babel/core/lib/transformation/block-hoist-plugin.js deleted file mode 100644 index ec22ee3b0c5bbe..00000000000000 --- a/tools/eslint/node_modules/@babel/core/lib/transformation/block-hoist-plugin.js +++ /dev/null @@ -1,84 +0,0 @@ -"use strict"; - -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.js"); -let LOADED_PLUGIN; -const blockHoistPlugin = { - name: "internal.blockHoist", - visitor: { - Block: { - exit({ - node - }) { - node.body = performHoisting(node.body); - } - }, - SwitchCase: { - exit({ - node - }) { - node.consequent = performHoisting(node.consequent); - } - } - } -}; -function performHoisting(body) { - 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 body; - return 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 diff --git a/tools/eslint/node_modules/@babel/core/lib/transformation/file/file.js b/tools/eslint/node_modules/@babel/core/lib/transformation/file/file.js deleted file mode 100644 index 987d9618378033..00000000000000 --- a/tools/eslint/node_modules/@babel/core/lib/transformation/file/file.js +++ /dev/null @@ -1,211 +0,0 @@ -"use strict"; - -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 _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, - ast, - inputMap - }) { - this._map = new Map(); - this.opts = void 0; - this.declarations = {}; - this.path = void 0; - this.ast = void 0; - this.scope = void 0; - this.metadata = {}; - this.code = ""; - this.inputMap = void 0; - this.hub = { - file: this, - getCode: () => this.code, - getScope: () => this.scope, - addHelper: this.addHelper.bind(this), - buildError: this.buildCodeFrameError.bind(this) - }; - this.opts = options; - this.code = code; - this.ast = ast; - this.inputMap = inputMap; - this.path = _traverse().NodePath.get({ - hub: this.hub, - parentPath: null, - parent: this.ast, - container: this.ast, - key: "program" - }).setContext(); - this.scope = this.path.scope; - } - get shebang() { - const { - interpreter - } = this.path.node; - return interpreter ? interpreter.value : ""; - } - set shebang(value) { - if (value) { - this.path.get("interpreter").replaceWith(interpreterDirective(value)); - } else { - 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); - } - 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; - } - helpers().minVersion(name); - 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 - } = helpers().get(name, dep => dependencies[dep], uid.name, Object.keys(this.scope.getAllBindings())); - globals.forEach(name => { - if (this.path.scope.hasBinding(name, true)) { - this.path.scope.rename(name); - } - }); - nodes.forEach(node => { - node._compact = true; - }); - const added = this.path.unshiftContainer("body", nodes); - for (const path of added) { - if (path.isVariableDeclaration()) this.scope.registerDeclaration(path); - } - return uid; - } - buildCodeFrameError(node, msg, _Error = SyntaxError) { - let loc = node == null ? void 0 : node.loc; - if (!loc && node) { - const state = { - loc: null - }; - (0, _traverse().default)(node, errorVisitor, this.scope, state); - loc = state.loc; - let txt = "This is an error on an internal node. Probably an internal error."; - if (loc) txt += " Location has been estimated."; - msg += ` (${txt})`; - } - if (loc) { - const { - highlightCode = true - } = this.opts; - msg += "\n" + (0, _codeFrame().codeFrameColumns)(this.code, { - start: { - line: loc.start.line, - column: loc.start.column + 1 - }, - end: loc.end && loc.start.line === loc.end.line ? { - line: loc.end.line, - column: loc.end.column + 1 - } : undefined - }, { - highlightCode - }); - } - return new _Error(msg); - } -} -exports.default = File; -{ - File.prototype.addImport = function 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'."); - }; - File.prototype.addTemplateObject = function addTemplateObject() { - throw new Error("This function has been moved into the template literal transform itself."); - }; - { - File.prototype.getModuleName = function getModuleName() { - return require("@babel/helper-module-transforms").getModuleName(this.opts, this.opts); - }; - } -} -0 && 0; - -//# sourceMappingURL=file.js.map diff --git a/tools/eslint/node_modules/@babel/core/lib/transformation/file/generate.js b/tools/eslint/node_modules/@babel/core/lib/transformation/file/generate.js deleted file mode 100644 index 10b5b29fb7c1ea..00000000000000 --- a/tools/eslint/node_modules/@babel/core/lib/transformation/file/generate.js +++ /dev/null @@ -1,84 +0,0 @@ -"use strict"; - -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.js"); -function generateCode(pluginPasses, file) { - const { - opts, - ast, - code, - inputMap - } = file; - const { - generatorOpts - } = opts; - generatorOpts.inputSourceMap = inputMap == null ? void 0 : inputMap.toObject(); - 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.`); - } - } else { - throw new Error("More than one plugin attempted to override codegen."); - } - let { - code: outputCode, - decodedMap: outputMap = result.map - } = result; - if (result.__mergedMap) { - outputMap = Object.assign({}, result.map); - } else { - if (outputMap) { - if (inputMap) { - outputMap = (0, _mergeMap.default)(inputMap.toObject(), outputMap, generatorOpts.sourceFileName); - } else { - 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 diff --git a/tools/eslint/node_modules/@babel/core/lib/transformation/file/merge-map.js b/tools/eslint/node_modules/@babel/core/lib/transformation/file/merge-map.js deleted file mode 100644 index cf3971b2acac1c..00000000000000 --- a/tools/eslint/node_modules/@babel/core/lib/transformation/file/merge-map.js +++ /dev/null @@ -1,37 +0,0 @@ -"use strict"; - -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; - 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 diff --git a/tools/eslint/node_modules/@babel/core/lib/transformation/index.js b/tools/eslint/node_modules/@babel/core/lib/transformation/index.js deleted file mode 100644 index 7d3247fc8a93ea..00000000000000 --- a/tools/eslint/node_modules/@babel/core/lib/transformation/index.js +++ /dev/null @@ -1,101 +0,0 @@ -"use strict"; - -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.js"); -var _blockHoistPlugin = require("./block-hoist-plugin.js"); -var _normalizeOpts = require("./normalize-opts.js"); -var _normalizeFile = require("./normalize-file.js"); -var _generate = require("./file/generate.js"); -var _deepArray = require("../config/helpers/deep-array.js"); -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) { - ({ - outputCode, - outputMap - } = (0, _generate.default)(config.passes, file)); - } - } 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, - ast: opts.ast === true ? file.ast : null, - code: outputCode === undefined ? null : outputCode, - map: outputMap === undefined ? null : outputMap, - sourceType: file.ast.program.sourceType, - 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* []; - 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.`); - } - } - } - 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* []; - 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.`); - } - } - } - } -} -function isThenable(val) { - return !!val && (typeof val === "object" || typeof val === "function") && !!val.then && typeof val.then === "function"; -} -0 && 0; - -//# sourceMappingURL=index.js.map diff --git a/tools/eslint/node_modules/@babel/core/lib/transformation/normalize-file.js b/tools/eslint/node_modules/@babel/core/lib/transformation/normalize-file.js deleted file mode 100644 index 74986d9b64999e..00000000000000 --- a/tools/eslint/node_modules/@babel/core/lib/transformation/normalize-file.js +++ /dev/null @@ -1,129 +0,0 @@ -"use strict"; - -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.js"); -var _index = require("../parser/index.js"); -var _cloneDeep = require("./util/clone-deep.js"); -const { - file, - traverseFast -} = _t(); -const debug = _debug()("babel:transform:file"); -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, _index.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); - } catch (err) { - { - debug("discarding unknown inline input sourcemap"); - } - } - } - } - 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]), "utf8"); - inputMap = _convertSourceMap().fromJSON(inputMapContent); - } catch (err) { - debug("discarding unknown file input sourcemap", err); - } - } else if (lastComment) { - debug("discarding un-loadable file input sourcemap"); - } - } - } - return new _file.default(options, { - code, - ast: ast, - inputMap - }); -} -function extractCommentsFromList(regex, comments, lastComment) { - if (comments) { - comments = comments.filter(({ - value - }) => { - if (regex.test(value)) { - lastComment = value; - return false; - } - return true; - }); - } - return [comments, lastComment]; -} -function extractComments(regex, ast) { - let lastComment = null; - traverseFast(ast, node => { - [node.leadingComments, lastComment] = extractCommentsFromList(regex, node.leadingComments, lastComment); - [node.innerComments, lastComment] = extractCommentsFromList(regex, node.innerComments, lastComment); - [node.trailingComments, lastComment] = extractCommentsFromList(regex, node.trailingComments, lastComment); - }); - return lastComment; -} -0 && 0; - -//# sourceMappingURL=normalize-file.js.map diff --git a/tools/eslint/node_modules/@babel/core/lib/transformation/normalize-opts.js b/tools/eslint/node_modules/@babel/core/lib/transformation/normalize-opts.js deleted file mode 100644 index 20826fc208e9a5..00000000000000 --- a/tools/eslint/node_modules/@babel/core/lib/transformation/normalize-opts.js +++ /dev/null @@ -1,59 +0,0 @@ -"use strict"; - -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, - cwd, - filenameRelative = typeof filename === "string" ? _path().relative(cwd, filename) : "unknown", - sourceType = "module", - inputSourceMap, - sourceMaps = !!inputSourceMap, - sourceRoot = config.options.moduleRoot, - sourceFileName = _path().basename(filenameRelative), - comments = true, - compact = "auto" - } = config.options; - const opts = config.options; - const options = Object.assign({}, opts, { - parserOpts: Object.assign({ - sourceType: _path().extname(filenameRelative) === ".mjs" ? "module" : sourceType, - sourceFileName: filename, - plugins: [] - }, opts.parserOpts), - generatorOpts: Object.assign({ - filename, - auxiliaryCommentBefore: opts.auxiliaryCommentBefore, - auxiliaryCommentAfter: opts.auxiliaryCommentAfter, - retainLines: opts.retainLines, - comments, - shouldPrintComment: opts.shouldPrintComment, - compact, - minified: opts.minified, - sourceMaps, - sourceRoot, - sourceFileName - }, opts.generatorOpts) - }); - for (const plugins of config.passes) { - for (const plugin of plugins) { - if (plugin.manipulateOptions) { - plugin.manipulateOptions(options, options.parserOpts); - } - } - } - return options; -} -0 && 0; - -//# sourceMappingURL=normalize-opts.js.map diff --git a/tools/eslint/node_modules/@babel/core/lib/transformation/plugin-pass.js b/tools/eslint/node_modules/@babel/core/lib/transformation/plugin-pass.js deleted file mode 100644 index e39c8854288d7d..00000000000000 --- a/tools/eslint/node_modules/@babel/core/lib/transformation/plugin-pass.js +++ /dev/null @@ -1,48 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.default = void 0; -class PluginPass { - constructor(file, key, options) { - this._map = new Map(); - this.key = void 0; - this.file = void 0; - this.opts = void 0; - this.cwd = void 0; - this.filename = void 0; - this.key = key; - this.file = file; - this.opts = options || {}; - 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); - } - buildCodeFrameError(node, msg, _Error) { - return this.file.buildCodeFrameError(node, msg, _Error); - } -} -exports.default = PluginPass; -{ - PluginPass.prototype.getModuleName = function getModuleName() { - return this.file.getModuleName(); - }; - PluginPass.prototype.addImport = function addImport() { - this.file.addImport(); - }; -} -0 && 0; - -//# sourceMappingURL=plugin-pass.js.map diff --git a/tools/eslint/node_modules/@babel/core/lib/transformation/util/clone-deep.js b/tools/eslint/node_modules/@babel/core/lib/transformation/util/clone-deep.js deleted file mode 100644 index fc4148fc6ad6e9..00000000000000 --- a/tools/eslint/node_modules/@babel/core/lib/transformation/util/clone-deep.js +++ /dev/null @@ -1,36 +0,0 @@ -"use strict"; - -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); - cache.set(value, cloned); - for (let i = 0; i < value.length; i++) { - cloned[i] = typeof value[i] !== "object" ? value[i] : deepClone(value[i], cache); - } - } else { - cloned = {}; - cache.set(value, 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); - } - } - 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 diff --git a/tools/eslint/node_modules/@babel/core/lib/vendor/import-meta-resolve.js b/tools/eslint/node_modules/@babel/core/lib/vendor/import-meta-resolve.js deleted file mode 100644 index 73d05ae02859a8..00000000000000 --- a/tools/eslint/node_modules/@babel/core/lib/vendor/import-meta-resolve.js +++ /dev/null @@ -1,1043 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.moduleResolve = moduleResolve; -exports.resolve = resolve; -function _assert() { - const data = require("assert"); - _assert = function () { - return data; - }; - return data; -} -function _fs() { - const data = _interopRequireWildcard(require("fs"), true); - _fs = function () { - return data; - }; - return data; -} -function _process() { - const data = require("process"); - _process = function () { - return data; - }; - return data; -} -function _url() { - const data = require("url"); - _url = function () { - return data; - }; - return data; -} -function _path() { - const data = require("path"); - _path = function () { - return data; - }; - return data; -} -function _module() { - const data = require("module"); - _module = function () { - return data; - }; - return data; -} -function _v() { - const data = require("v8"); - _v = function () { - return data; - }; - return data; -} -function _util() { - const data = require("util"); - _util = function () { - return data; - }; - return data; -} -function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); } -function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; } -const own$1 = {}.hasOwnProperty; -const classRegExp = /^([A-Z][a-z\d]*)+$/; -const kTypes = new Set(['string', 'function', 'number', 'object', 'Function', 'Object', 'boolean', 'bigint', 'symbol']); -const codes = {}; -function formatList(array, type = 'and') { - return array.length < 3 ? array.join(` ${type} `) : `${array.slice(0, -1).join(', ')}, ${type} ${array[array.length - 1]}`; -} -const messages = new Map(); -const nodeInternalPrefix = '__node_internal_'; -let userStackTraceLimit; -codes.ERR_INVALID_ARG_TYPE = createError('ERR_INVALID_ARG_TYPE', (name, expected, actual) => { - _assert()(typeof name === 'string', "'name' must be a string"); - if (!Array.isArray(expected)) { - expected = [expected]; - } - let message = 'The '; - if (name.endsWith(' argument')) { - message += `${name} `; - } else { - const type = name.includes('.') ? 'property' : 'argument'; - message += `"${name}" ${type} `; - } - message += 'must be '; - const types = []; - const instances = []; - const other = []; - for (const value of expected) { - _assert()(typeof value === 'string', 'All expected entries have to be of type string'); - if (kTypes.has(value)) { - types.push(value.toLowerCase()); - } else if (classRegExp.exec(value) === null) { - _assert()(value !== 'object', 'The value "object" should be written as "Object"'); - other.push(value); - } else { - instances.push(value); - } - } - if (instances.length > 0) { - const pos = types.indexOf('object'); - if (pos !== -1) { - types.slice(pos, 1); - instances.push('Object'); - } - } - if (types.length > 0) { - message += `${types.length > 1 ? 'one of type' : 'of type'} ${formatList(types, 'or')}`; - if (instances.length > 0 || other.length > 0) message += ' or '; - } - if (instances.length > 0) { - message += `an instance of ${formatList(instances, 'or')}`; - if (other.length > 0) message += ' or '; - } - if (other.length > 0) { - if (other.length > 1) { - message += `one of ${formatList(other, 'or')}`; - } else { - if (other[0].toLowerCase() !== other[0]) message += 'an '; - message += `${other[0]}`; - } - } - message += `. Received ${determineSpecificType(actual)}`; - return message; -}, TypeError); -codes.ERR_INVALID_MODULE_SPECIFIER = createError('ERR_INVALID_MODULE_SPECIFIER', (request, reason, base = undefined) => { - return `Invalid module "${request}" ${reason}${base ? ` imported from ${base}` : ''}`; -}, TypeError); -codes.ERR_INVALID_PACKAGE_CONFIG = createError('ERR_INVALID_PACKAGE_CONFIG', (path, base, message) => { - return `Invalid package config ${path}${base ? ` while importing ${base}` : ''}${message ? `. ${message}` : ''}`; -}, Error); -codes.ERR_INVALID_PACKAGE_TARGET = createError('ERR_INVALID_PACKAGE_TARGET', (packagePath, key, target, isImport = false, base = undefined) => { - const relatedError = typeof target === 'string' && !isImport && target.length > 0 && !target.startsWith('./'); - if (key === '.') { - _assert()(isImport === false); - return `Invalid "exports" main target ${JSON.stringify(target)} defined ` + `in the package config ${packagePath}package.json${base ? ` imported from ${base}` : ''}${relatedError ? '; targets must start with "./"' : ''}`; - } - return `Invalid "${isImport ? 'imports' : 'exports'}" target ${JSON.stringify(target)} defined for '${key}' in the package config ${packagePath}package.json${base ? ` imported from ${base}` : ''}${relatedError ? '; targets must start with "./"' : ''}`; -}, Error); -codes.ERR_MODULE_NOT_FOUND = createError('ERR_MODULE_NOT_FOUND', (path, base, exactUrl = false) => { - return `Cannot find ${exactUrl ? 'module' : 'package'} '${path}' imported from ${base}`; -}, Error); -codes.ERR_NETWORK_IMPORT_DISALLOWED = createError('ERR_NETWORK_IMPORT_DISALLOWED', "import of '%s' by %s is not supported: %s", Error); -codes.ERR_PACKAGE_IMPORT_NOT_DEFINED = createError('ERR_PACKAGE_IMPORT_NOT_DEFINED', (specifier, packagePath, base) => { - return `Package import specifier "${specifier}" is not defined${packagePath ? ` in package ${packagePath}package.json` : ''} imported from ${base}`; -}, TypeError); -codes.ERR_PACKAGE_PATH_NOT_EXPORTED = createError('ERR_PACKAGE_PATH_NOT_EXPORTED', (packagePath, subpath, base = undefined) => { - if (subpath === '.') return `No "exports" main defined in ${packagePath}package.json${base ? ` imported from ${base}` : ''}`; - return `Package subpath '${subpath}' is not defined by "exports" in ${packagePath}package.json${base ? ` imported from ${base}` : ''}`; -}, Error); -codes.ERR_UNSUPPORTED_DIR_IMPORT = createError('ERR_UNSUPPORTED_DIR_IMPORT', "Directory import '%s' is not supported " + 'resolving ES modules imported from %s', Error); -codes.ERR_UNSUPPORTED_RESOLVE_REQUEST = createError('ERR_UNSUPPORTED_RESOLVE_REQUEST', 'Failed to resolve module specifier "%s" from "%s": Invalid relative URL or base scheme is not hierarchical.', TypeError); -codes.ERR_UNKNOWN_FILE_EXTENSION = createError('ERR_UNKNOWN_FILE_EXTENSION', (extension, path) => { - return `Unknown file extension "${extension}" for ${path}`; -}, TypeError); -codes.ERR_INVALID_ARG_VALUE = createError('ERR_INVALID_ARG_VALUE', (name, value, reason = 'is invalid') => { - let inspected = (0, _util().inspect)(value); - if (inspected.length > 128) { - inspected = `${inspected.slice(0, 128)}...`; - } - const type = name.includes('.') ? 'property' : 'argument'; - return `The ${type} '${name}' ${reason}. Received ${inspected}`; -}, TypeError); -function createError(sym, value, constructor) { - messages.set(sym, value); - return makeNodeErrorWithCode(constructor, sym); -} -function makeNodeErrorWithCode(Base, key) { - return NodeError; - function NodeError(...parameters) { - const limit = Error.stackTraceLimit; - if (isErrorStackTraceLimitWritable()) Error.stackTraceLimit = 0; - const error = new Base(); - if (isErrorStackTraceLimitWritable()) Error.stackTraceLimit = limit; - const message = getMessage(key, parameters, error); - Object.defineProperties(error, { - message: { - value: message, - enumerable: false, - writable: true, - configurable: true - }, - toString: { - value() { - return `${this.name} [${key}]: ${this.message}`; - }, - enumerable: false, - writable: true, - configurable: true - } - }); - captureLargerStackTrace(error); - error.code = key; - return error; - } -} -function isErrorStackTraceLimitWritable() { - try { - if (_v().startupSnapshot.isBuildingSnapshot()) { - return false; - } - } catch (_unused) {} - const desc = Object.getOwnPropertyDescriptor(Error, 'stackTraceLimit'); - if (desc === undefined) { - return Object.isExtensible(Error); - } - return own$1.call(desc, 'writable') && desc.writable !== undefined ? desc.writable : desc.set !== undefined; -} -function hideStackFrames(wrappedFunction) { - const hidden = nodeInternalPrefix + wrappedFunction.name; - Object.defineProperty(wrappedFunction, 'name', { - value: hidden - }); - return wrappedFunction; -} -const captureLargerStackTrace = hideStackFrames(function (error) { - const stackTraceLimitIsWritable = isErrorStackTraceLimitWritable(); - if (stackTraceLimitIsWritable) { - userStackTraceLimit = Error.stackTraceLimit; - Error.stackTraceLimit = Number.POSITIVE_INFINITY; - } - Error.captureStackTrace(error); - if (stackTraceLimitIsWritable) Error.stackTraceLimit = userStackTraceLimit; - return error; -}); -function getMessage(key, parameters, self) { - const message = messages.get(key); - _assert()(message !== undefined, 'expected `message` to be found'); - if (typeof message === 'function') { - _assert()(message.length <= parameters.length, `Code: ${key}; The provided arguments length (${parameters.length}) does not ` + `match the required ones (${message.length}).`); - return Reflect.apply(message, self, parameters); - } - const regex = /%[dfijoOs]/g; - let expectedLength = 0; - while (regex.exec(message) !== null) expectedLength++; - _assert()(expectedLength === parameters.length, `Code: ${key}; The provided arguments length (${parameters.length}) does not ` + `match the required ones (${expectedLength}).`); - if (parameters.length === 0) return message; - parameters.unshift(message); - return Reflect.apply(_util().format, null, parameters); -} -function determineSpecificType(value) { - if (value === null || value === undefined) { - return String(value); - } - if (typeof value === 'function' && value.name) { - return `function ${value.name}`; - } - if (typeof value === 'object') { - if (value.constructor && value.constructor.name) { - return `an instance of ${value.constructor.name}`; - } - return `${(0, _util().inspect)(value, { - depth: -1 - })}`; - } - let inspected = (0, _util().inspect)(value, { - colors: false - }); - if (inspected.length > 28) { - inspected = `${inspected.slice(0, 25)}...`; - } - return `type ${typeof value} (${inspected})`; -} -const hasOwnProperty$1 = {}.hasOwnProperty; -const { - ERR_INVALID_PACKAGE_CONFIG: ERR_INVALID_PACKAGE_CONFIG$1 -} = codes; -const cache = new Map(); -function read(jsonPath, { - base, - specifier -}) { - const existing = cache.get(jsonPath); - if (existing) { - return existing; - } - let string; - try { - string = _fs().default.readFileSync(_path().toNamespacedPath(jsonPath), 'utf8'); - } catch (error) { - const exception = error; - if (exception.code !== 'ENOENT') { - throw exception; - } - } - const result = { - exists: false, - pjsonPath: jsonPath, - main: undefined, - name: undefined, - type: 'none', - exports: undefined, - imports: undefined - }; - if (string !== undefined) { - let parsed; - try { - parsed = JSON.parse(string); - } catch (error_) { - const cause = error_; - const error = new ERR_INVALID_PACKAGE_CONFIG$1(jsonPath, (base ? `"${specifier}" from ` : '') + (0, _url().fileURLToPath)(base || specifier), cause.message); - error.cause = cause; - throw error; - } - result.exists = true; - if (hasOwnProperty$1.call(parsed, 'name') && typeof parsed.name === 'string') { - result.name = parsed.name; - } - if (hasOwnProperty$1.call(parsed, 'main') && typeof parsed.main === 'string') { - result.main = parsed.main; - } - if (hasOwnProperty$1.call(parsed, 'exports')) { - result.exports = parsed.exports; - } - if (hasOwnProperty$1.call(parsed, 'imports')) { - result.imports = parsed.imports; - } - if (hasOwnProperty$1.call(parsed, 'type') && (parsed.type === 'commonjs' || parsed.type === 'module')) { - result.type = parsed.type; - } - } - cache.set(jsonPath, result); - return result; -} -function getPackageScopeConfig(resolved) { - let packageJSONUrl = new URL('package.json', resolved); - while (true) { - const packageJSONPath = packageJSONUrl.pathname; - if (packageJSONPath.endsWith('node_modules/package.json')) { - break; - } - const packageConfig = read((0, _url().fileURLToPath)(packageJSONUrl), { - specifier: resolved - }); - if (packageConfig.exists) { - return packageConfig; - } - const lastPackageJSONUrl = packageJSONUrl; - packageJSONUrl = new URL('../package.json', packageJSONUrl); - if (packageJSONUrl.pathname === lastPackageJSONUrl.pathname) { - break; - } - } - const packageJSONPath = (0, _url().fileURLToPath)(packageJSONUrl); - return { - pjsonPath: packageJSONPath, - exists: false, - type: 'none' - }; -} -function getPackageType(url) { - return getPackageScopeConfig(url).type; -} -const { - ERR_UNKNOWN_FILE_EXTENSION -} = codes; -const hasOwnProperty = {}.hasOwnProperty; -const extensionFormatMap = { - __proto__: null, - '.cjs': 'commonjs', - '.js': 'module', - '.json': 'json', - '.mjs': 'module' -}; -function mimeToFormat(mime) { - if (mime && /\s*(text|application)\/javascript\s*(;\s*charset=utf-?8\s*)?/i.test(mime)) return 'module'; - if (mime === 'application/json') return 'json'; - return null; -} -const protocolHandlers = { - __proto__: null, - 'data:': getDataProtocolModuleFormat, - 'file:': getFileProtocolModuleFormat, - 'http:': getHttpProtocolModuleFormat, - 'https:': getHttpProtocolModuleFormat, - 'node:'() { - return 'builtin'; - } -}; -function getDataProtocolModuleFormat(parsed) { - const { - 1: mime - } = /^([^/]+\/[^;,]+)[^,]*?(;base64)?,/.exec(parsed.pathname) || [null, null, null]; - return mimeToFormat(mime); -} -function extname(url) { - const pathname = url.pathname; - let index = pathname.length; - while (index--) { - const code = pathname.codePointAt(index); - if (code === 47) { - return ''; - } - if (code === 46) { - return pathname.codePointAt(index - 1) === 47 ? '' : pathname.slice(index); - } - } - return ''; -} -function getFileProtocolModuleFormat(url, _context, ignoreErrors) { - const value = extname(url); - if (value === '.js') { - const packageType = getPackageType(url); - if (packageType !== 'none') { - return packageType; - } - return 'commonjs'; - } - if (value === '') { - const packageType = getPackageType(url); - if (packageType === 'none' || packageType === 'commonjs') { - return 'commonjs'; - } - return 'module'; - } - const format = extensionFormatMap[value]; - if (format) return format; - if (ignoreErrors) { - return undefined; - } - const filepath = (0, _url().fileURLToPath)(url); - throw new ERR_UNKNOWN_FILE_EXTENSION(value, filepath); -} -function getHttpProtocolModuleFormat() {} -function defaultGetFormatWithoutErrors(url, context) { - const protocol = url.protocol; - if (!hasOwnProperty.call(protocolHandlers, protocol)) { - return null; - } - return protocolHandlers[protocol](url, context, true) || null; -} -const { - ERR_INVALID_ARG_VALUE -} = codes; -const DEFAULT_CONDITIONS = Object.freeze(['node', 'import']); -const DEFAULT_CONDITIONS_SET = new Set(DEFAULT_CONDITIONS); -function getDefaultConditions() { - return DEFAULT_CONDITIONS; -} -function getDefaultConditionsSet() { - return DEFAULT_CONDITIONS_SET; -} -function getConditionsSet(conditions) { - if (conditions !== undefined && conditions !== getDefaultConditions()) { - if (!Array.isArray(conditions)) { - throw new ERR_INVALID_ARG_VALUE('conditions', conditions, 'expected an array'); - } - return new Set(conditions); - } - return getDefaultConditionsSet(); -} -const RegExpPrototypeSymbolReplace = RegExp.prototype[Symbol.replace]; -const { - ERR_NETWORK_IMPORT_DISALLOWED, - ERR_INVALID_MODULE_SPECIFIER, - ERR_INVALID_PACKAGE_CONFIG, - ERR_INVALID_PACKAGE_TARGET, - ERR_MODULE_NOT_FOUND, - ERR_PACKAGE_IMPORT_NOT_DEFINED, - ERR_PACKAGE_PATH_NOT_EXPORTED, - ERR_UNSUPPORTED_DIR_IMPORT, - ERR_UNSUPPORTED_RESOLVE_REQUEST -} = codes; -const own = {}.hasOwnProperty; -const invalidSegmentRegEx = /(^|\\|\/)((\.|%2e)(\.|%2e)?|(n|%6e|%4e)(o|%6f|%4f)(d|%64|%44)(e|%65|%45)(_|%5f)(m|%6d|%4d)(o|%6f|%4f)(d|%64|%44)(u|%75|%55)(l|%6c|%4c)(e|%65|%45)(s|%73|%53))?(\\|\/|$)/i; -const deprecatedInvalidSegmentRegEx = /(^|\\|\/)((\.|%2e)(\.|%2e)?|(n|%6e|%4e)(o|%6f|%4f)(d|%64|%44)(e|%65|%45)(_|%5f)(m|%6d|%4d)(o|%6f|%4f)(d|%64|%44)(u|%75|%55)(l|%6c|%4c)(e|%65|%45)(s|%73|%53))(\\|\/|$)/i; -const invalidPackageNameRegEx = /^\.|%|\\/; -const patternRegEx = /\*/g; -const encodedSeparatorRegEx = /%2f|%5c/i; -const emittedPackageWarnings = new Set(); -const doubleSlashRegEx = /[/\\]{2}/; -function emitInvalidSegmentDeprecation(target, request, match, packageJsonUrl, internal, base, isTarget) { - if (_process().noDeprecation) { - return; - } - const pjsonPath = (0, _url().fileURLToPath)(packageJsonUrl); - const double = doubleSlashRegEx.exec(isTarget ? target : request) !== null; - _process().emitWarning(`Use of deprecated ${double ? 'double slash' : 'leading or trailing slash matching'} resolving "${target}" for module ` + `request "${request}" ${request === match ? '' : `matched to "${match}" `}in the "${internal ? 'imports' : 'exports'}" field module resolution of the package at ${pjsonPath}${base ? ` imported from ${(0, _url().fileURLToPath)(base)}` : ''}.`, 'DeprecationWarning', 'DEP0166'); -} -function emitLegacyIndexDeprecation(url, packageJsonUrl, base, main) { - if (_process().noDeprecation) { - return; - } - const format = defaultGetFormatWithoutErrors(url, { - parentURL: base.href - }); - if (format !== 'module') return; - const urlPath = (0, _url().fileURLToPath)(url.href); - const packagePath = (0, _url().fileURLToPath)(new (_url().URL)('.', packageJsonUrl)); - const basePath = (0, _url().fileURLToPath)(base); - if (!main) { - _process().emitWarning(`No "main" or "exports" field defined in the package.json for ${packagePath} resolving the main entry point "${urlPath.slice(packagePath.length)}", imported from ${basePath}.\nDefault "index" lookups for the main are deprecated for ES modules.`, 'DeprecationWarning', 'DEP0151'); - } else if (_path().resolve(packagePath, main) !== urlPath) { - _process().emitWarning(`Package ${packagePath} has a "main" field set to "${main}", ` + `excluding the full filename and extension to the resolved file at "${urlPath.slice(packagePath.length)}", imported from ${basePath}.\n Automatic extension resolution of the "main" field is ` + 'deprecated for ES modules.', 'DeprecationWarning', 'DEP0151'); - } -} -function tryStatSync(path) { - try { - return (0, _fs().statSync)(path); - } catch (_unused2) {} -} -function fileExists(url) { - const stats = (0, _fs().statSync)(url, { - throwIfNoEntry: false - }); - const isFile = stats ? stats.isFile() : undefined; - return isFile === null || isFile === undefined ? false : isFile; -} -function legacyMainResolve(packageJsonUrl, packageConfig, base) { - let guess; - if (packageConfig.main !== undefined) { - guess = new (_url().URL)(packageConfig.main, packageJsonUrl); - if (fileExists(guess)) return guess; - const tries = [`./${packageConfig.main}.js`, `./${packageConfig.main}.json`, `./${packageConfig.main}.node`, `./${packageConfig.main}/index.js`, `./${packageConfig.main}/index.json`, `./${packageConfig.main}/index.node`]; - let i = -1; - while (++i < tries.length) { - guess = new (_url().URL)(tries[i], packageJsonUrl); - if (fileExists(guess)) break; - guess = undefined; - } - if (guess) { - emitLegacyIndexDeprecation(guess, packageJsonUrl, base, packageConfig.main); - return guess; - } - } - const tries = ['./index.js', './index.json', './index.node']; - let i = -1; - while (++i < tries.length) { - guess = new (_url().URL)(tries[i], packageJsonUrl); - if (fileExists(guess)) break; - guess = undefined; - } - if (guess) { - emitLegacyIndexDeprecation(guess, packageJsonUrl, base, packageConfig.main); - return guess; - } - throw new ERR_MODULE_NOT_FOUND((0, _url().fileURLToPath)(new (_url().URL)('.', packageJsonUrl)), (0, _url().fileURLToPath)(base)); -} -function finalizeResolution(resolved, base, preserveSymlinks) { - if (encodedSeparatorRegEx.exec(resolved.pathname) !== null) { - throw new ERR_INVALID_MODULE_SPECIFIER(resolved.pathname, 'must not include encoded "/" or "\\" characters', (0, _url().fileURLToPath)(base)); - } - let filePath; - try { - filePath = (0, _url().fileURLToPath)(resolved); - } catch (error) { - const cause = error; - Object.defineProperty(cause, 'input', { - value: String(resolved) - }); - Object.defineProperty(cause, 'module', { - value: String(base) - }); - throw cause; - } - const stats = tryStatSync(filePath.endsWith('/') ? filePath.slice(-1) : filePath); - if (stats && stats.isDirectory()) { - const error = new ERR_UNSUPPORTED_DIR_IMPORT(filePath, (0, _url().fileURLToPath)(base)); - error.url = String(resolved); - throw error; - } - if (!stats || !stats.isFile()) { - const error = new ERR_MODULE_NOT_FOUND(filePath || resolved.pathname, base && (0, _url().fileURLToPath)(base), true); - error.url = String(resolved); - throw error; - } - if (!preserveSymlinks) { - const real = (0, _fs().realpathSync)(filePath); - const { - search, - hash - } = resolved; - resolved = (0, _url().pathToFileURL)(real + (filePath.endsWith(_path().sep) ? '/' : '')); - resolved.search = search; - resolved.hash = hash; - } - return resolved; -} -function importNotDefined(specifier, packageJsonUrl, base) { - return new ERR_PACKAGE_IMPORT_NOT_DEFINED(specifier, packageJsonUrl && (0, _url().fileURLToPath)(new (_url().URL)('.', packageJsonUrl)), (0, _url().fileURLToPath)(base)); -} -function exportsNotFound(subpath, packageJsonUrl, base) { - return new ERR_PACKAGE_PATH_NOT_EXPORTED((0, _url().fileURLToPath)(new (_url().URL)('.', packageJsonUrl)), subpath, base && (0, _url().fileURLToPath)(base)); -} -function throwInvalidSubpath(request, match, packageJsonUrl, internal, base) { - const reason = `request is not a valid match in pattern "${match}" for the "${internal ? 'imports' : 'exports'}" resolution of ${(0, _url().fileURLToPath)(packageJsonUrl)}`; - throw new ERR_INVALID_MODULE_SPECIFIER(request, reason, base && (0, _url().fileURLToPath)(base)); -} -function invalidPackageTarget(subpath, target, packageJsonUrl, internal, base) { - target = typeof target === 'object' && target !== null ? JSON.stringify(target, null, '') : `${target}`; - return new ERR_INVALID_PACKAGE_TARGET((0, _url().fileURLToPath)(new (_url().URL)('.', packageJsonUrl)), subpath, target, internal, base && (0, _url().fileURLToPath)(base)); -} -function resolvePackageTargetString(target, subpath, match, packageJsonUrl, base, pattern, internal, isPathMap, conditions) { - if (subpath !== '' && !pattern && target[target.length - 1] !== '/') throw invalidPackageTarget(match, target, packageJsonUrl, internal, base); - if (!target.startsWith('./')) { - if (internal && !target.startsWith('../') && !target.startsWith('/')) { - let isURL = false; - try { - new (_url().URL)(target); - isURL = true; - } catch (_unused3) {} - if (!isURL) { - const exportTarget = pattern ? RegExpPrototypeSymbolReplace.call(patternRegEx, target, () => subpath) : target + subpath; - return packageResolve(exportTarget, packageJsonUrl, conditions); - } - } - throw invalidPackageTarget(match, target, packageJsonUrl, internal, base); - } - if (invalidSegmentRegEx.exec(target.slice(2)) !== null) { - if (deprecatedInvalidSegmentRegEx.exec(target.slice(2)) === null) { - if (!isPathMap) { - const request = pattern ? match.replace('*', () => subpath) : match + subpath; - const resolvedTarget = pattern ? RegExpPrototypeSymbolReplace.call(patternRegEx, target, () => subpath) : target; - emitInvalidSegmentDeprecation(resolvedTarget, request, match, packageJsonUrl, internal, base, true); - } - } else { - throw invalidPackageTarget(match, target, packageJsonUrl, internal, base); - } - } - const resolved = new (_url().URL)(target, packageJsonUrl); - const resolvedPath = resolved.pathname; - const packagePath = new (_url().URL)('.', packageJsonUrl).pathname; - if (!resolvedPath.startsWith(packagePath)) throw invalidPackageTarget(match, target, packageJsonUrl, internal, base); - if (subpath === '') return resolved; - if (invalidSegmentRegEx.exec(subpath) !== null) { - const request = pattern ? match.replace('*', () => subpath) : match + subpath; - if (deprecatedInvalidSegmentRegEx.exec(subpath) === null) { - if (!isPathMap) { - const resolvedTarget = pattern ? RegExpPrototypeSymbolReplace.call(patternRegEx, target, () => subpath) : target; - emitInvalidSegmentDeprecation(resolvedTarget, request, match, packageJsonUrl, internal, base, false); - } - } else { - throwInvalidSubpath(request, match, packageJsonUrl, internal, base); - } - } - if (pattern) { - return new (_url().URL)(RegExpPrototypeSymbolReplace.call(patternRegEx, resolved.href, () => subpath)); - } - return new (_url().URL)(subpath, resolved); -} -function isArrayIndex(key) { - const keyNumber = Number(key); - if (`${keyNumber}` !== key) return false; - return keyNumber >= 0 && keyNumber < 0xffffffff; -} -function resolvePackageTarget(packageJsonUrl, target, subpath, packageSubpath, base, pattern, internal, isPathMap, conditions) { - if (typeof target === 'string') { - return resolvePackageTargetString(target, subpath, packageSubpath, packageJsonUrl, base, pattern, internal, isPathMap, conditions); - } - if (Array.isArray(target)) { - const targetList = target; - if (targetList.length === 0) return null; - let lastException; - let i = -1; - while (++i < targetList.length) { - const targetItem = targetList[i]; - let resolveResult; - try { - resolveResult = resolvePackageTarget(packageJsonUrl, targetItem, subpath, packageSubpath, base, pattern, internal, isPathMap, conditions); - } catch (error) { - const exception = error; - lastException = exception; - if (exception.code === 'ERR_INVALID_PACKAGE_TARGET') continue; - throw error; - } - if (resolveResult === undefined) continue; - if (resolveResult === null) { - lastException = null; - continue; - } - return resolveResult; - } - if (lastException === undefined || lastException === null) { - return null; - } - throw lastException; - } - if (typeof target === 'object' && target !== null) { - const keys = Object.getOwnPropertyNames(target); - let i = -1; - while (++i < keys.length) { - const key = keys[i]; - if (isArrayIndex(key)) { - throw new ERR_INVALID_PACKAGE_CONFIG((0, _url().fileURLToPath)(packageJsonUrl), base, '"exports" cannot contain numeric property keys.'); - } - } - i = -1; - while (++i < keys.length) { - const key = keys[i]; - if (key === 'default' || conditions && conditions.has(key)) { - const conditionalTarget = target[key]; - const resolveResult = resolvePackageTarget(packageJsonUrl, conditionalTarget, subpath, packageSubpath, base, pattern, internal, isPathMap, conditions); - if (resolveResult === undefined) continue; - return resolveResult; - } - } - return null; - } - if (target === null) { - return null; - } - throw invalidPackageTarget(packageSubpath, target, packageJsonUrl, internal, base); -} -function isConditionalExportsMainSugar(exports, packageJsonUrl, base) { - if (typeof exports === 'string' || Array.isArray(exports)) return true; - if (typeof exports !== 'object' || exports === null) return false; - const keys = Object.getOwnPropertyNames(exports); - let isConditionalSugar = false; - let i = 0; - let keyIndex = -1; - while (++keyIndex < keys.length) { - const key = keys[keyIndex]; - const currentIsConditionalSugar = key === '' || key[0] !== '.'; - if (i++ === 0) { - isConditionalSugar = currentIsConditionalSugar; - } else if (isConditionalSugar !== currentIsConditionalSugar) { - throw new ERR_INVALID_PACKAGE_CONFIG((0, _url().fileURLToPath)(packageJsonUrl), base, '"exports" cannot contain some keys starting with \'.\' and some not.' + ' The exports object must either be an object of package subpath keys' + ' or an object of main entry condition name keys only.'); - } - } - return isConditionalSugar; -} -function emitTrailingSlashPatternDeprecation(match, pjsonUrl, base) { - if (_process().noDeprecation) { - return; - } - const pjsonPath = (0, _url().fileURLToPath)(pjsonUrl); - if (emittedPackageWarnings.has(pjsonPath + '|' + match)) return; - emittedPackageWarnings.add(pjsonPath + '|' + match); - _process().emitWarning(`Use of deprecated trailing slash pattern mapping "${match}" in the ` + `"exports" field module resolution of the package at ${pjsonPath}${base ? ` imported from ${(0, _url().fileURLToPath)(base)}` : ''}. Mapping specifiers ending in "/" is no longer supported.`, 'DeprecationWarning', 'DEP0155'); -} -function packageExportsResolve(packageJsonUrl, packageSubpath, packageConfig, base, conditions) { - let exports = packageConfig.exports; - if (isConditionalExportsMainSugar(exports, packageJsonUrl, base)) { - exports = { - '.': exports - }; - } - if (own.call(exports, packageSubpath) && !packageSubpath.includes('*') && !packageSubpath.endsWith('/')) { - const target = exports[packageSubpath]; - const resolveResult = resolvePackageTarget(packageJsonUrl, target, '', packageSubpath, base, false, false, false, conditions); - if (resolveResult === null || resolveResult === undefined) { - throw exportsNotFound(packageSubpath, packageJsonUrl, base); - } - return resolveResult; - } - let bestMatch = ''; - let bestMatchSubpath = ''; - const keys = Object.getOwnPropertyNames(exports); - let i = -1; - while (++i < keys.length) { - const key = keys[i]; - const patternIndex = key.indexOf('*'); - if (patternIndex !== -1 && packageSubpath.startsWith(key.slice(0, patternIndex))) { - if (packageSubpath.endsWith('/')) { - emitTrailingSlashPatternDeprecation(packageSubpath, packageJsonUrl, base); - } - const patternTrailer = key.slice(patternIndex + 1); - if (packageSubpath.length >= key.length && packageSubpath.endsWith(patternTrailer) && patternKeyCompare(bestMatch, key) === 1 && key.lastIndexOf('*') === patternIndex) { - bestMatch = key; - bestMatchSubpath = packageSubpath.slice(patternIndex, packageSubpath.length - patternTrailer.length); - } - } - } - if (bestMatch) { - const target = exports[bestMatch]; - const resolveResult = resolvePackageTarget(packageJsonUrl, target, bestMatchSubpath, bestMatch, base, true, false, packageSubpath.endsWith('/'), conditions); - if (resolveResult === null || resolveResult === undefined) { - throw exportsNotFound(packageSubpath, packageJsonUrl, base); - } - return resolveResult; - } - throw exportsNotFound(packageSubpath, packageJsonUrl, base); -} -function patternKeyCompare(a, b) { - const aPatternIndex = a.indexOf('*'); - const bPatternIndex = b.indexOf('*'); - const baseLengthA = aPatternIndex === -1 ? a.length : aPatternIndex + 1; - const baseLengthB = bPatternIndex === -1 ? b.length : bPatternIndex + 1; - if (baseLengthA > baseLengthB) return -1; - if (baseLengthB > baseLengthA) return 1; - if (aPatternIndex === -1) return 1; - if (bPatternIndex === -1) return -1; - if (a.length > b.length) return -1; - if (b.length > a.length) return 1; - return 0; -} -function packageImportsResolve(name, base, conditions) { - if (name === '#' || name.startsWith('#/') || name.endsWith('/')) { - const reason = 'is not a valid internal imports specifier name'; - throw new ERR_INVALID_MODULE_SPECIFIER(name, reason, (0, _url().fileURLToPath)(base)); - } - let packageJsonUrl; - const packageConfig = getPackageScopeConfig(base); - if (packageConfig.exists) { - packageJsonUrl = (0, _url().pathToFileURL)(packageConfig.pjsonPath); - const imports = packageConfig.imports; - if (imports) { - if (own.call(imports, name) && !name.includes('*')) { - const resolveResult = resolvePackageTarget(packageJsonUrl, imports[name], '', name, base, false, true, false, conditions); - if (resolveResult !== null && resolveResult !== undefined) { - return resolveResult; - } - } else { - let bestMatch = ''; - let bestMatchSubpath = ''; - const keys = Object.getOwnPropertyNames(imports); - let i = -1; - while (++i < keys.length) { - const key = keys[i]; - const patternIndex = key.indexOf('*'); - if (patternIndex !== -1 && name.startsWith(key.slice(0, -1))) { - const patternTrailer = key.slice(patternIndex + 1); - if (name.length >= key.length && name.endsWith(patternTrailer) && patternKeyCompare(bestMatch, key) === 1 && key.lastIndexOf('*') === patternIndex) { - bestMatch = key; - bestMatchSubpath = name.slice(patternIndex, name.length - patternTrailer.length); - } - } - } - if (bestMatch) { - const target = imports[bestMatch]; - const resolveResult = resolvePackageTarget(packageJsonUrl, target, bestMatchSubpath, bestMatch, base, true, true, false, conditions); - if (resolveResult !== null && resolveResult !== undefined) { - return resolveResult; - } - } - } - } - } - throw importNotDefined(name, packageJsonUrl, base); -} -function parsePackageName(specifier, base) { - let separatorIndex = specifier.indexOf('/'); - let validPackageName = true; - let isScoped = false; - if (specifier[0] === '@') { - isScoped = true; - if (separatorIndex === -1 || specifier.length === 0) { - validPackageName = false; - } else { - separatorIndex = specifier.indexOf('/', separatorIndex + 1); - } - } - const packageName = separatorIndex === -1 ? specifier : specifier.slice(0, separatorIndex); - if (invalidPackageNameRegEx.exec(packageName) !== null) { - validPackageName = false; - } - if (!validPackageName) { - throw new ERR_INVALID_MODULE_SPECIFIER(specifier, 'is not a valid package name', (0, _url().fileURLToPath)(base)); - } - const packageSubpath = '.' + (separatorIndex === -1 ? '' : specifier.slice(separatorIndex)); - return { - packageName, - packageSubpath, - isScoped - }; -} -function packageResolve(specifier, base, conditions) { - if (_module().builtinModules.includes(specifier)) { - return new (_url().URL)('node:' + specifier); - } - const { - packageName, - packageSubpath, - isScoped - } = parsePackageName(specifier, base); - const packageConfig = getPackageScopeConfig(base); - if (packageConfig.exists) { - const packageJsonUrl = (0, _url().pathToFileURL)(packageConfig.pjsonPath); - if (packageConfig.name === packageName && packageConfig.exports !== undefined && packageConfig.exports !== null) { - return packageExportsResolve(packageJsonUrl, packageSubpath, packageConfig, base, conditions); - } - } - let packageJsonUrl = new (_url().URL)('./node_modules/' + packageName + '/package.json', base); - let packageJsonPath = (0, _url().fileURLToPath)(packageJsonUrl); - let lastPath; - do { - const stat = tryStatSync(packageJsonPath.slice(0, -13)); - if (!stat || !stat.isDirectory()) { - lastPath = packageJsonPath; - packageJsonUrl = new (_url().URL)((isScoped ? '../../../../node_modules/' : '../../../node_modules/') + packageName + '/package.json', packageJsonUrl); - packageJsonPath = (0, _url().fileURLToPath)(packageJsonUrl); - continue; - } - const packageConfig = read(packageJsonPath, { - base, - specifier - }); - if (packageConfig.exports !== undefined && packageConfig.exports !== null) { - return packageExportsResolve(packageJsonUrl, packageSubpath, packageConfig, base, conditions); - } - if (packageSubpath === '.') { - return legacyMainResolve(packageJsonUrl, packageConfig, base); - } - return new (_url().URL)(packageSubpath, packageJsonUrl); - } while (packageJsonPath.length !== lastPath.length); - throw new ERR_MODULE_NOT_FOUND(packageName, (0, _url().fileURLToPath)(base), false); -} -function isRelativeSpecifier(specifier) { - if (specifier[0] === '.') { - if (specifier.length === 1 || specifier[1] === '/') return true; - if (specifier[1] === '.' && (specifier.length === 2 || specifier[2] === '/')) { - return true; - } - } - return false; -} -function shouldBeTreatedAsRelativeOrAbsolutePath(specifier) { - if (specifier === '') return false; - if (specifier[0] === '/') return true; - return isRelativeSpecifier(specifier); -} -function moduleResolve(specifier, base, conditions, preserveSymlinks) { - const protocol = base.protocol; - const isData = protocol === 'data:'; - const isRemote = isData || protocol === 'http:' || protocol === 'https:'; - let resolved; - if (shouldBeTreatedAsRelativeOrAbsolutePath(specifier)) { - try { - resolved = new (_url().URL)(specifier, base); - } catch (error_) { - const error = new ERR_UNSUPPORTED_RESOLVE_REQUEST(specifier, base); - error.cause = error_; - throw error; - } - } else if (protocol === 'file:' && specifier[0] === '#') { - resolved = packageImportsResolve(specifier, base, conditions); - } else { - try { - resolved = new (_url().URL)(specifier); - } catch (error_) { - if (isRemote && !_module().builtinModules.includes(specifier)) { - const error = new ERR_UNSUPPORTED_RESOLVE_REQUEST(specifier, base); - error.cause = error_; - throw error; - } - resolved = packageResolve(specifier, base, conditions); - } - } - _assert()(resolved !== undefined, 'expected to be defined'); - if (resolved.protocol !== 'file:') { - return resolved; - } - return finalizeResolution(resolved, base, preserveSymlinks); -} -function checkIfDisallowedImport(specifier, parsed, parsedParentURL) { - if (parsedParentURL) { - const parentProtocol = parsedParentURL.protocol; - if (parentProtocol === 'http:' || parentProtocol === 'https:') { - if (shouldBeTreatedAsRelativeOrAbsolutePath(specifier)) { - const parsedProtocol = parsed == null ? void 0 : parsed.protocol; - if (parsedProtocol && parsedProtocol !== 'https:' && parsedProtocol !== 'http:') { - throw new ERR_NETWORK_IMPORT_DISALLOWED(specifier, parsedParentURL, 'remote imports cannot import from a local location.'); - } - return { - url: (parsed == null ? void 0 : parsed.href) || '' - }; - } - if (_module().builtinModules.includes(specifier)) { - throw new ERR_NETWORK_IMPORT_DISALLOWED(specifier, parsedParentURL, 'remote imports cannot import from a local location.'); - } - throw new ERR_NETWORK_IMPORT_DISALLOWED(specifier, parsedParentURL, 'only relative and absolute specifiers are supported.'); - } - } -} -function isURL(self) { - return Boolean(self && typeof self === 'object' && 'href' in self && typeof self.href === 'string' && 'protocol' in self && typeof self.protocol === 'string' && self.href && self.protocol); -} -function throwIfInvalidParentURL(parentURL) { - if (parentURL === undefined) { - return; - } - if (typeof parentURL !== 'string' && !isURL(parentURL)) { - throw new codes.ERR_INVALID_ARG_TYPE('parentURL', ['string', 'URL'], parentURL); - } -} -function defaultResolve(specifier, context = {}) { - const { - parentURL - } = context; - _assert()(parentURL !== undefined, 'expected `parentURL` to be defined'); - throwIfInvalidParentURL(parentURL); - let parsedParentURL; - if (parentURL) { - try { - parsedParentURL = new (_url().URL)(parentURL); - } catch (_unused4) {} - } - let parsed; - let protocol; - try { - parsed = shouldBeTreatedAsRelativeOrAbsolutePath(specifier) ? new (_url().URL)(specifier, parsedParentURL) : new (_url().URL)(specifier); - protocol = parsed.protocol; - if (protocol === 'data:') { - return { - url: parsed.href, - format: null - }; - } - } catch (_unused5) {} - const maybeReturn = checkIfDisallowedImport(specifier, parsed, parsedParentURL); - if (maybeReturn) return maybeReturn; - if (protocol === undefined && parsed) { - protocol = parsed.protocol; - } - if (protocol === 'node:') { - return { - url: specifier - }; - } - if (parsed && parsed.protocol === 'node:') return { - url: specifier - }; - const conditions = getConditionsSet(context.conditions); - const url = moduleResolve(specifier, new (_url().URL)(parentURL), conditions, false); - return { - url: url.href, - format: defaultGetFormatWithoutErrors(url, { - parentURL - }) - }; -} -function resolve(specifier, parent) { - if (!parent) { - throw new Error('Please pass `parent`: `import-meta-resolve` cannot ponyfill that'); - } - try { - return defaultResolve(specifier, { - parentURL: parent - }).url; - } catch (error) { - const exception = error; - if ((exception.code === 'ERR_UNSUPPORTED_DIR_IMPORT' || exception.code === 'ERR_MODULE_NOT_FOUND') && typeof exception.url === 'string') { - return exception.url; - } - throw error; - } -} -0 && 0; - -//# sourceMappingURL=import-meta-resolve.js.map diff --git a/tools/eslint/node_modules/@babel/core/package.json b/tools/eslint/node_modules/@babel/core/package.json deleted file mode 100644 index 1c36a52b59e3d8..00000000000000 --- a/tools/eslint/node_modules/@babel/core/package.json +++ /dev/null @@ -1,82 +0,0 @@ -{ - "name": "@babel/core", - "version": "7.24.8", - "description": "Babel compiler core.", - "main": "./lib/index.js", - "author": "The Babel Team (https://babel.dev/team)", - "license": "MIT", - "publishConfig": { - "access": "public" - }, - "repository": { - "type": "git", - "url": "https://github.com/babel/babel.git", - "directory": "packages/babel-core" - }, - "homepage": "https://babel.dev/docs/en/next/babel-core", - "bugs": "https://github.com/babel/babel/issues?utf8=%E2%9C%93&q=is%3Aissue+label%3A%22pkg%3A%20core%22+is%3Aopen", - "keywords": [ - "6to5", - "babel", - "classes", - "const", - "es6", - "harmony", - "let", - "modules", - "transpile", - "transpiler", - "var", - "babel-core", - "compiler" - ], - "engines": { - "node": ">=6.9.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/babel" - }, - "browser": { - "./lib/config/files/index.js": "./lib/config/files/index-browser.js", - "./lib/config/resolve-targets.js": "./lib/config/resolve-targets-browser.js", - "./lib/transform-file.js": "./lib/transform-file-browser.js", - "./src/config/files/index.ts": "./src/config/files/index-browser.ts", - "./src/config/resolve-targets.ts": "./src/config/resolve-targets-browser.ts", - "./src/transform-file.ts": "./src/transform-file-browser.ts" - }, - "dependencies": { - "@ampproject/remapping": "^2.2.0", - "@babel/code-frame": "^7.24.7", - "@babel/generator": "^7.24.8", - "@babel/helper-compilation-targets": "^7.24.8", - "@babel/helper-module-transforms": "^7.24.8", - "@babel/helpers": "^7.24.8", - "@babel/parser": "^7.24.8", - "@babel/template": "^7.24.7", - "@babel/traverse": "^7.24.8", - "@babel/types": "^7.24.8", - "convert-source-map": "^2.0.0", - "debug": "^4.1.0", - "gensync": "^1.0.0-beta.2", - "json5": "^2.2.3", - "semver": "^6.3.1" - }, - "devDependencies": { - "@babel/helper-transform-fixture-test-runner": "^7.24.8", - "@babel/plugin-syntax-flow": "^7.24.7", - "@babel/plugin-transform-flow-strip-types": "^7.24.7", - "@babel/plugin-transform-modules-commonjs": "^7.24.8", - "@babel/preset-env": "^7.24.8", - "@babel/preset-typescript": "^7.24.7", - "@jridgewell/trace-mapping": "^0.3.25", - "@types/convert-source-map": "^2.0.0", - "@types/debug": "^4.1.0", - "@types/gensync": "^1.0.0", - "@types/resolve": "^1.3.2", - "@types/semver": "^5.4.0", - "rimraf": "^3.0.0", - "ts-node": "^11.0.0-beta.1" - }, - "type": "commonjs" -} \ No newline at end of file diff --git a/tools/eslint/node_modules/@babel/eslint-parser/LICENSE b/tools/eslint/node_modules/@babel/eslint-parser/LICENSE deleted file mode 100644 index f31575ec773bb1..00000000000000 --- a/tools/eslint/node_modules/@babel/eslint-parser/LICENSE +++ /dev/null @@ -1,22 +0,0 @@ -MIT License - -Copyright (c) 2014-present Sebastian McKenzie and other contributors - -Permission is hereby granted, free of charge, to any person obtaining -a copy of this software and associated documentation files (the -"Software"), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sublicense, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/tools/eslint/node_modules/@babel/eslint-parser/lib/analyze-scope.cjs b/tools/eslint/node_modules/@babel/eslint-parser/lib/analyze-scope.cjs deleted file mode 100644 index cd184beeb368a0..00000000000000 --- a/tools/eslint/node_modules/@babel/eslint-parser/lib/analyze-scope.cjs +++ /dev/null @@ -1,319 +0,0 @@ -"use strict"; - -function _classPrivateFieldInitSpec(obj, privateMap, value) { _checkPrivateRedeclaration(obj, privateMap); privateMap.set(obj, value); } -function _checkPrivateRedeclaration(obj, privateCollection) { if (privateCollection.has(obj)) { throw new TypeError("Cannot initialize the same private elements twice on an object"); } } -function _classPrivateFieldGet(s, a) { return s.get(_assertClassBrand(s, a)); } -function _classPrivateFieldSet(s, a, r) { return s.set(_assertClassBrand(s, a), r), r; } -function _assertClassBrand(e, t, n) { if ("function" == typeof e ? e === t : e.has(t)) return arguments.length < 3 ? t : n; throw new TypeError("Private element is not present on this object"); } -const { - Definition, - PatternVisitor: OriginalPatternVisitor, - Referencer: OriginalReferencer, - Scope, - ScopeManager -} = require("@nicolo-ribaudo/eslint-scope-5-internals"); -const { - getKeys: fallback -} = require("eslint-visitor-keys"); -let visitorKeysMap; -function getVisitorValues(nodeType, client) { - if (visitorKeysMap) return visitorKeysMap[nodeType]; - const { - FLOW_FLIPPED_ALIAS_KEYS, - VISITOR_KEYS - } = client.getTypesInfo(); - const flowFlippedAliasKeys = FLOW_FLIPPED_ALIAS_KEYS.concat(["ArrayPattern", "ClassDeclaration", "ClassExpression", "FunctionDeclaration", "FunctionExpression", "Identifier", "ObjectPattern", "RestElement"]); - visitorKeysMap = (Object.entries || (o => Object.keys(o).map(k => [k, o[k]])))(VISITOR_KEYS).reduce((acc, [key, value]) => { - if (!flowFlippedAliasKeys.includes(value)) { - acc[key] = value; - } - return acc; - }, {}); - return visitorKeysMap[nodeType]; -} -const propertyTypes = { - callProperties: { - type: "loop", - values: ["value"] - }, - indexers: { - type: "loop", - values: ["key", "value"] - }, - properties: { - type: "loop", - values: ["argument", "value"] - }, - types: { - type: "loop" - }, - params: { - type: "loop" - }, - argument: { - type: "single" - }, - elementType: { - type: "single" - }, - qualification: { - type: "single" - }, - rest: { - type: "single" - }, - returnType: { - type: "single" - }, - typeAnnotation: { - type: "typeAnnotation" - }, - typeParameters: { - type: "typeParameters" - }, - id: { - type: "id" - } -}; -class PatternVisitor extends OriginalPatternVisitor { - ArrayPattern(node) { - node.elements.forEach(this.visit, this); - } - ObjectPattern(node) { - node.properties.forEach(this.visit, this); - } -} -var _client = new WeakMap(); -class Referencer extends OriginalReferencer { - constructor(options, scopeManager, client) { - super(options, scopeManager); - _classPrivateFieldInitSpec(this, _client, void 0); - _classPrivateFieldSet(_client, this, client); - } - visitPattern(node, options, callback) { - if (!node) { - return; - } - this._checkIdentifierOrVisit(node.typeAnnotation); - if (node.type === "AssignmentPattern") { - this._checkIdentifierOrVisit(node.left.typeAnnotation); - } - if (typeof options === "function") { - callback = options; - options = { - processRightHandNodes: false - }; - } - const visitor = new PatternVisitor(this.options, node, callback); - visitor.visit(node); - if (options.processRightHandNodes) { - visitor.rightHandNodes.forEach(this.visit, this); - } - } - visitClass(node) { - var _node$superTypeParame; - this._visitArray(node.decorators); - const typeParamScope = this._nestTypeParamScope(node); - this._visitTypeAnnotation(node.implements); - this._visitTypeAnnotation((_node$superTypeParame = node.superTypeParameters) == null ? void 0 : _node$superTypeParame.params); - super.visitClass(node); - if (typeParamScope) { - this.close(node); - } - } - visitFunction(node) { - const typeParamScope = this._nestTypeParamScope(node); - this._checkIdentifierOrVisit(node.returnType); - super.visitFunction(node); - if (typeParamScope) { - this.close(node); - } - } - visitProperty(node) { - var _node$value; - if (((_node$value = node.value) == null ? void 0 : _node$value.type) === "TypeCastExpression") { - this._visitTypeAnnotation(node.value); - } - this._visitArray(node.decorators); - super.visitProperty(node); - } - InterfaceDeclaration(node) { - this._createScopeVariable(node, node.id); - const typeParamScope = this._nestTypeParamScope(node); - this._visitArray(node.extends); - this.visit(node.body); - if (typeParamScope) { - this.close(node); - } - } - TypeAlias(node) { - this._createScopeVariable(node, node.id); - const typeParamScope = this._nestTypeParamScope(node); - this.visit(node.right); - if (typeParamScope) { - this.close(node); - } - } - ClassProperty(node) { - this._visitClassProperty(node); - } - ClassPrivateProperty(node) { - this._visitClassProperty(node); - } - PropertyDefinition(node) { - this._visitClassProperty(node); - } - ClassPrivateMethod(node) { - super.MethodDefinition(node); - } - DeclareModule(node) { - this._visitDeclareX(node); - } - DeclareFunction(node) { - this._visitDeclareX(node); - } - DeclareVariable(node) { - this._visitDeclareX(node); - } - DeclareClass(node) { - this._visitDeclareX(node); - } - OptionalMemberExpression(node) { - super.MemberExpression(node); - } - _visitClassProperty(node) { - const { - computed, - key, - typeAnnotation, - decorators, - value - } = node; - this._visitArray(decorators); - if (computed) this.visit(key); - this._visitTypeAnnotation(typeAnnotation); - if (value) { - if (this.scopeManager.__nestClassFieldInitializerScope) { - this.scopeManager.__nestClassFieldInitializerScope(value); - } else { - this.scopeManager.__nestScope(new Scope(this.scopeManager, "function", this.scopeManager.__currentScope, value, true)); - } - this.visit(value); - this.close(value); - } - } - _visitDeclareX(node) { - if (node.id) { - this._createScopeVariable(node, node.id); - } - const typeParamScope = this._nestTypeParamScope(node); - if (typeParamScope) { - this.close(node); - } - } - _createScopeVariable(node, name) { - this.currentScope().variableScope.__define(name, new Definition("Variable", name, node, null, null, null)); - } - _nestTypeParamScope(node) { - if (!node.typeParameters) { - return null; - } - const parentScope = this.scopeManager.__currentScope; - const scope = new Scope(this.scopeManager, "type-parameters", parentScope, node, false); - this.scopeManager.__nestScope(scope); - for (let j = 0; j < node.typeParameters.params.length; j++) { - const name = node.typeParameters.params[j]; - scope.__define(name, new Definition("TypeParameter", name, name)); - if (name.typeAnnotation) { - this._checkIdentifierOrVisit(name); - } - } - scope.__define = parentScope.__define.bind(parentScope); - return scope; - } - _visitTypeAnnotation(node) { - if (!node) { - return; - } - if (Array.isArray(node)) { - node.forEach(this._visitTypeAnnotation, this); - return; - } - const visitorValues = getVisitorValues(node.type, _classPrivateFieldGet(_client, this)); - if (!visitorValues) { - return; - } - for (let i = 0; i < visitorValues.length; i++) { - const visitorValue = visitorValues[i]; - const propertyType = propertyTypes[visitorValue]; - const nodeProperty = node[visitorValue]; - if (propertyType == null || nodeProperty == null) { - continue; - } - if (propertyType.type === "loop") { - for (let j = 0; j < nodeProperty.length; j++) { - if (Array.isArray(propertyType.values)) { - for (let k = 0; k < propertyType.values.length; k++) { - const loopPropertyNode = nodeProperty[j][propertyType.values[k]]; - if (loopPropertyNode) { - this._checkIdentifierOrVisit(loopPropertyNode); - } - } - } else { - this._checkIdentifierOrVisit(nodeProperty[j]); - } - } - } else if (propertyType.type === "single") { - this._checkIdentifierOrVisit(nodeProperty); - } else if (propertyType.type === "typeAnnotation") { - this._visitTypeAnnotation(node.typeAnnotation); - } else if (propertyType.type === "typeParameters") { - for (let l = 0; l < node.typeParameters.params.length; l++) { - this._checkIdentifierOrVisit(node.typeParameters.params[l]); - } - } else if (propertyType.type === "id") { - if (node.id.type === "Identifier") { - this._checkIdentifierOrVisit(node.id); - } else { - this._visitTypeAnnotation(node.id); - } - } - } - } - _checkIdentifierOrVisit(node) { - if (node != null && node.typeAnnotation) { - this._visitTypeAnnotation(node.typeAnnotation); - } else if ((node == null ? void 0 : node.type) === "Identifier") { - this.visit(node); - } else { - this._visitTypeAnnotation(node); - } - } - _visitArray(nodeList) { - if (nodeList) { - for (const node of nodeList) { - this.visit(node); - } - } - } -} -module.exports = function analyzeScope(ast, parserOptions, client) { - var _parserOptions$ecmaFe; - const options = { - ignoreEval: true, - optimistic: false, - directive: false, - nodejsScope: ast.sourceType === "script" && ((_parserOptions$ecmaFe = parserOptions.ecmaFeatures) == null ? void 0 : _parserOptions$ecmaFe.globalReturn) === true, - impliedStrict: false, - sourceType: ast.sourceType, - ecmaVersion: parserOptions.ecmaVersion, - fallback, - childVisitorKeys: client.getVisitorKeys() - }; - const scopeManager = new ScopeManager(options); - const referencer = new Referencer(options, scopeManager, client); - referencer.visit(ast); - return scopeManager; -}; - -//# sourceMappingURL=analyze-scope.cjs.map diff --git a/tools/eslint/node_modules/@babel/eslint-parser/lib/client.cjs b/tools/eslint/node_modules/@babel/eslint-parser/lib/client.cjs deleted file mode 100644 index 3c2ed386702d73..00000000000000 --- a/tools/eslint/node_modules/@babel/eslint-parser/lib/client.cjs +++ /dev/null @@ -1,106 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.WorkerClient = exports.Client = exports.ACTIONS = void 0; -function _classPrivateFieldInitSpec(obj, privateMap, value) { _checkPrivateRedeclaration(obj, privateMap); privateMap.set(obj, value); } -function _checkPrivateRedeclaration(obj, privateCollection) { if (privateCollection.has(obj)) { throw new TypeError("Cannot initialize the same private elements twice on an object"); } } -function _classPrivateFieldGet(s, a) { return s.get(_assertClassBrand(s, a)); } -function _classPrivateFieldSet(s, a, r) { return s.set(_assertClassBrand(s, a), r), r; } -function _assertClassBrand(e, t, n) { if ("function" == typeof e ? e === t : e.has(t)) return arguments.length < 3 ? t : n; throw new TypeError("Private element is not present on this object"); } -const path = require("path"); -const ACTIONS = exports.ACTIONS = { - GET_VERSION: "GET_VERSION", - GET_TYPES_INFO: "GET_TYPES_INFO", - GET_VISITOR_KEYS: "GET_VISITOR_KEYS", - GET_TOKEN_LABELS: "GET_TOKEN_LABELS", - MAYBE_PARSE: "MAYBE_PARSE", - MAYBE_PARSE_SYNC: "MAYBE_PARSE_SYNC" -}; -var _send = new WeakMap(); -var _vCache = new WeakMap(); -var _tiCache = new WeakMap(); -var _vkCache = new WeakMap(); -var _tlCache = new WeakMap(); -class Client { - constructor(send) { - _classPrivateFieldInitSpec(this, _send, void 0); - _classPrivateFieldInitSpec(this, _vCache, void 0); - _classPrivateFieldInitSpec(this, _tiCache, void 0); - _classPrivateFieldInitSpec(this, _vkCache, void 0); - _classPrivateFieldInitSpec(this, _tlCache, void 0); - _classPrivateFieldSet(_send, this, send); - } - getVersion() { - var _classPrivateFieldGet2; - return (_classPrivateFieldGet2 = _classPrivateFieldGet(_vCache, this)) != null ? _classPrivateFieldGet2 : _classPrivateFieldSet(_vCache, this, _classPrivateFieldGet(_send, this).call(this, ACTIONS.GET_VERSION, undefined)); - } - getTypesInfo() { - var _classPrivateFieldGet3; - return (_classPrivateFieldGet3 = _classPrivateFieldGet(_tiCache, this)) != null ? _classPrivateFieldGet3 : _classPrivateFieldSet(_tiCache, this, _classPrivateFieldGet(_send, this).call(this, ACTIONS.GET_TYPES_INFO, undefined)); - } - getVisitorKeys() { - var _classPrivateFieldGet4; - return (_classPrivateFieldGet4 = _classPrivateFieldGet(_vkCache, this)) != null ? _classPrivateFieldGet4 : _classPrivateFieldSet(_vkCache, this, _classPrivateFieldGet(_send, this).call(this, ACTIONS.GET_VISITOR_KEYS, undefined)); - } - getTokLabels() { - var _classPrivateFieldGet5; - return (_classPrivateFieldGet5 = _classPrivateFieldGet(_tlCache, this)) != null ? _classPrivateFieldGet5 : _classPrivateFieldSet(_tlCache, this, _classPrivateFieldGet(_send, this).call(this, ACTIONS.GET_TOKEN_LABELS, undefined)); - } - maybeParse(code, options) { - return _classPrivateFieldGet(_send, this).call(this, ACTIONS.MAYBE_PARSE, { - code, - options - }); - } -} -exports.Client = Client; -var _worker = new WeakMap(); -class WorkerClient extends Client { - constructor() { - super((action, payload) => { - const signal = new Int32Array(new SharedArrayBuffer(8)); - const subChannel = new (_get_worker_threads(WorkerClient).MessageChannel)(); - _classPrivateFieldGet(_worker, this).postMessage({ - signal, - port: subChannel.port1, - action, - payload - }, [subChannel.port1]); - Atomics.wait(signal, 0, 0); - const { - message - } = _get_worker_threads(WorkerClient).receiveMessageOnPort(subChannel.port2); - if (message.error) throw Object.assign(message.error, message.errorData);else return message.result; - }); - _classPrivateFieldInitSpec(this, _worker, new (_get_worker_threads(WorkerClient).Worker)(path.resolve(__dirname, "../lib/worker/index.cjs"), { - env: _get_worker_threads(WorkerClient).SHARE_ENV - })); - _classPrivateFieldGet(_worker, this).unref(); - } -} -exports.WorkerClient = WorkerClient; -function _get_worker_threads(_this) { - var _worker_threads_cache2; - return (_worker_threads_cache2 = _worker_threads_cache._) != null ? _worker_threads_cache2 : _worker_threads_cache._ = require("worker_threads"); -} -var _worker_threads_cache = { - _: void 0 -}; -{ - var _LocalClient, _handleMessage; - exports.LocalClient = (_LocalClient = class LocalClient extends Client { - constructor() { - var _assertClassBrand$_; - (_assertClassBrand$_ = _assertClassBrand(_LocalClient, LocalClient, _handleMessage)._) != null ? _assertClassBrand$_ : _handleMessage._ = _assertClassBrand(_LocalClient, LocalClient, require("./worker/handle-message.cjs")); - super((action, payload) => { - return _assertClassBrand(_LocalClient, LocalClient, _handleMessage)._.call(LocalClient, action === ACTIONS.MAYBE_PARSE ? ACTIONS.MAYBE_PARSE_SYNC : action, payload); - }); - } - }, _handleMessage = { - _: void 0 - }, _LocalClient); -} - -//# sourceMappingURL=client.cjs.map diff --git a/tools/eslint/node_modules/@babel/eslint-parser/lib/configuration.cjs b/tools/eslint/node_modules/@babel/eslint-parser/lib/configuration.cjs deleted file mode 100644 index e956a79743e646..00000000000000 --- a/tools/eslint/node_modules/@babel/eslint-parser/lib/configuration.cjs +++ /dev/null @@ -1,23 +0,0 @@ -"use strict"; - -const _excluded = ["babelOptions", "ecmaVersion", "sourceType", "requireConfigFile"]; -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; } -module.exports = function normalizeESLintConfig(options) { - const { - babelOptions = {}, - ecmaVersion = 2020, - sourceType = "module", - requireConfigFile = true - } = options, - otherOptions = _objectWithoutPropertiesLoose(options, _excluded); - return Object.assign({ - babelOptions: Object.assign({ - cwd: process.cwd() - }, babelOptions), - ecmaVersion: ecmaVersion === "latest" ? 1e8 : ecmaVersion, - sourceType, - requireConfigFile - }, otherOptions); -}; - -//# sourceMappingURL=configuration.cjs.map diff --git a/tools/eslint/node_modules/@babel/eslint-parser/lib/convert/convertAST.cjs b/tools/eslint/node_modules/@babel/eslint-parser/lib/convert/convertAST.cjs deleted file mode 100644 index 3509550d22968e..00000000000000 --- a/tools/eslint/node_modules/@babel/eslint-parser/lib/convert/convertAST.cjs +++ /dev/null @@ -1,134 +0,0 @@ -"use strict"; - -const ESLINT_VERSION = require("../utils/eslint-version.cjs"); -function* it(children) { - if (Array.isArray(children)) yield* children;else yield children; -} -function traverse(node, visitorKeys, visitor) { - const { - type - } = node; - if (!type) return; - const keys = visitorKeys[type]; - if (!keys) return; - for (const key of keys) { - for (const child of it(node[key])) { - if (child && typeof child === "object") { - visitor.enter(child); - traverse(child, visitorKeys, visitor); - visitor.exit(child); - } - } - } -} -const convertNodesVisitor = { - enter(node) { - if (node.innerComments) { - delete node.innerComments; - } - if (node.trailingComments) { - delete node.trailingComments; - } - if (node.leadingComments) { - delete node.leadingComments; - } - }, - exit(node) { - if (node.extra) { - delete node.extra; - } - if (node.loc.identifierName) { - delete node.loc.identifierName; - } - if (node.type === "TypeParameter") { - node.type = "Identifier"; - node.typeAnnotation = node.bound; - delete node.bound; - } - if (node.type === "QualifiedTypeIdentifier") { - delete node.id; - } - if (node.type === "ObjectTypeProperty") { - delete node.key; - } - if (node.type === "ObjectTypeIndexer") { - delete node.id; - } - if (node.type === "FunctionTypeParam") { - delete node.name; - } - if (node.type === "ImportDeclaration") { - delete node.isType; - } - if (node.type === "TemplateLiteral") { - for (let i = 0; i < node.quasis.length; i++) { - const q = node.quasis[i]; - q.range[0] -= 1; - if (q.tail) { - q.range[1] += 1; - } else { - q.range[1] += 2; - } - q.loc.start.column -= 1; - if (q.tail) { - q.loc.end.column += 1; - } else { - q.loc.end.column += 2; - } - if (ESLINT_VERSION >= 8) { - q.start -= 1; - if (q.tail) { - q.end += 1; - } else { - q.end += 2; - } - } - } - } - } -}; -function convertNodes(ast, visitorKeys) { - traverse(ast, visitorKeys, convertNodesVisitor); -} -function convertProgramNode(ast) { - const body = ast.program.body; - Object.assign(ast, { - type: "Program", - sourceType: ast.program.sourceType, - body - }); - delete ast.program; - delete ast.errors; - if (ast.comments.length) { - const lastComment = ast.comments[ast.comments.length - 1]; - if (ast.tokens.length) { - const lastToken = ast.tokens[ast.tokens.length - 1]; - if (lastComment.end > lastToken.end) { - ast.range[1] = lastToken.end; - ast.loc.end.line = lastToken.loc.end.line; - ast.loc.end.column = lastToken.loc.end.column; - if (ESLINT_VERSION >= 8) { - ast.end = lastToken.end; - } - } - } - } else { - if (!ast.tokens.length) { - ast.loc.start.line = 1; - ast.loc.end.line = 1; - } - } - if (body != null && body.length) { - ast.loc.start.line = body[0].loc.start.line; - ast.range[0] = body[0].start; - if (ESLINT_VERSION >= 8) { - ast.start = body[0].start; - } - } -} -module.exports = function convertAST(ast, visitorKeys) { - convertNodes(ast, visitorKeys); - convertProgramNode(ast); -}; - -//# sourceMappingURL=convertAST.cjs.map diff --git a/tools/eslint/node_modules/@babel/eslint-parser/lib/convert/convertComments.cjs b/tools/eslint/node_modules/@babel/eslint-parser/lib/convert/convertComments.cjs deleted file mode 100644 index 63245bd5ac5066..00000000000000 --- a/tools/eslint/node_modules/@babel/eslint-parser/lib/convert/convertComments.cjs +++ /dev/null @@ -1,10 +0,0 @@ -"use strict"; - -module.exports = function convertComments(comments) { - for (const comment of comments) { - comment.type = comment.type === "CommentBlock" ? "Block" : "Line"; - comment.range || (comment.range = [comment.start, comment.end]); - } -}; - -//# sourceMappingURL=convertComments.cjs.map diff --git a/tools/eslint/node_modules/@babel/eslint-parser/lib/convert/convertTokens.cjs b/tools/eslint/node_modules/@babel/eslint-parser/lib/convert/convertTokens.cjs deleted file mode 100644 index 267fb9e9ee915a..00000000000000 --- a/tools/eslint/node_modules/@babel/eslint-parser/lib/convert/convertTokens.cjs +++ /dev/null @@ -1,159 +0,0 @@ -"use strict"; - -const ESLINT_VERSION = require("../utils/eslint-version.cjs"); -function convertTemplateType(tokens, tl) { - let curlyBrace = null; - let templateTokens = []; - const result = []; - function addTemplateType() { - const start = templateTokens[0]; - const end = templateTokens[templateTokens.length - 1]; - const value = templateTokens.reduce((result, token) => { - if (token.value) { - result += token.value; - } else if (token.type.label !== tl.template) { - result += token.type.label; - } - return result; - }, ""); - result.push({ - type: "Template", - value: value, - start: start.start, - end: end.end, - loc: { - start: start.loc.start, - end: end.loc.end - } - }); - templateTokens = []; - } - tokens.forEach(token => { - switch (token.type.label) { - case tl.backQuote: - if (curlyBrace) { - result.push(curlyBrace); - curlyBrace = null; - } - templateTokens.push(token); - if (templateTokens.length > 1) { - addTemplateType(); - } - break; - case tl.dollarBraceL: - templateTokens.push(token); - addTemplateType(); - break; - case tl.braceR: - if (curlyBrace) { - result.push(curlyBrace); - } - curlyBrace = token; - break; - case tl.template: - if (curlyBrace) { - templateTokens.push(curlyBrace); - curlyBrace = null; - } - templateTokens.push(token); - break; - default: - if (curlyBrace) { - result.push(curlyBrace); - curlyBrace = null; - } - result.push(token); - } - }); - return result; -} -function convertToken(token, source, tl) { - const { - type - } = token; - const { - label - } = type; - const newToken = token; - newToken.range = [token.start, token.end]; - if (label === tl.name) { - if (token.value === "static") { - newToken.type = "Keyword"; - } else { - newToken.type = "Identifier"; - } - } else if (label === tl.semi || label === tl.comma || label === tl.parenL || label === tl.parenR || label === tl.braceL || label === tl.braceR || label === tl.slash || label === tl.dot || label === tl.bracketL || label === tl.bracketR || label === tl.ellipsis || label === tl.arrow || label === tl.pipeline || label === tl.star || label === tl.incDec || label === tl.colon || label === tl.question || label === tl.template || label === tl.backQuote || label === tl.dollarBraceL || label === tl.at || label === tl.logicalOR || label === tl.logicalAND || label === tl.nullishCoalescing || label === tl.bitwiseOR || label === tl.bitwiseXOR || label === tl.bitwiseAND || label === tl.equality || label === tl.relational || label === tl.bitShift || label === tl.plusMin || label === tl.modulo || label === tl.exponent || label === tl.bang || label === tl.tilde || label === tl.doubleColon || label === tl.hash || label === tl.questionDot || label === tl.braceHashL || label === tl.braceBarL || label === tl.braceBarR || label === tl.bracketHashL || label === tl.bracketBarL || label === tl.bracketBarR || label === tl.doubleCaret || label === tl.doubleAt || type.isAssign) { - var _newToken$value; - newToken.type = "Punctuator"; - (_newToken$value = newToken.value) != null ? _newToken$value : newToken.value = label; - } else if (label === tl.jsxTagStart) { - newToken.type = "Punctuator"; - newToken.value = "<"; - } else if (label === tl.jsxTagEnd) { - newToken.type = "Punctuator"; - newToken.value = ">"; - } else if (label === tl.jsxName) { - newToken.type = "JSXIdentifier"; - } else if (label === tl.jsxText) { - newToken.type = "JSXText"; - } else if (type.keyword === "null") { - newToken.type = "Null"; - } else if (type.keyword === "false" || type.keyword === "true") { - newToken.type = "Boolean"; - } else if (type.keyword) { - newToken.type = "Keyword"; - } else if (label === tl.num) { - newToken.type = "Numeric"; - newToken.value = source.slice(token.start, token.end); - } else if (label === tl.string) { - newToken.type = "String"; - newToken.value = source.slice(token.start, token.end); - } else if (label === tl.regexp) { - newToken.type = "RegularExpression"; - const value = token.value; - newToken.regex = { - pattern: value.pattern, - flags: value.flags - }; - newToken.value = `/${value.pattern}/${value.flags}`; - } else if (label === tl.bigint) { - newToken.type = "Numeric"; - newToken.value = `${token.value}n`; - } else if (label === tl.privateName) { - newToken.type = "PrivateIdentifier"; - } else if (label === tl.templateNonTail || label === tl.templateTail || label === tl.Template) { - newToken.type = "Template"; - } - return newToken; -} -module.exports = function convertTokens(tokens, code, tokLabels) { - const result = []; - const templateTypeMergedTokens = convertTemplateType(tokens, tokLabels); - for (let i = 0, { - length - } = templateTypeMergedTokens; i < length - 1; i++) { - const token = templateTypeMergedTokens[i]; - const tokenType = token.type; - if (tokenType === "CommentLine" || tokenType === "CommentBlock") { - continue; - } - { - if (ESLINT_VERSION >= 8 && i + 1 < length && tokenType.label === tokLabels.hash) { - const nextToken = templateTypeMergedTokens[i + 1]; - if (nextToken.type.label === tokLabels.name && token.end === nextToken.start) { - i++; - nextToken.type = "PrivateIdentifier"; - nextToken.start -= 1; - nextToken.loc.start.column -= 1; - nextToken.range = [nextToken.start, nextToken.end]; - result.push(nextToken); - continue; - } - } - } - result.push(convertToken(token, code, tokLabels)); - } - return result; -}; - -//# sourceMappingURL=convertTokens.cjs.map diff --git a/tools/eslint/node_modules/@babel/eslint-parser/lib/convert/index.cjs b/tools/eslint/node_modules/@babel/eslint-parser/lib/convert/index.cjs deleted file mode 100644 index f8483add73f72b..00000000000000 --- a/tools/eslint/node_modules/@babel/eslint-parser/lib/convert/index.cjs +++ /dev/null @@ -1,25 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.convertError = convertError; -exports.convertFile = convertFile; -const convertTokens = require("./convertTokens.cjs"); -const convertComments = require("./convertComments.cjs"); -const convertAST = require("./convertAST.cjs"); -function convertFile(ast, code, tokLabels, visitorKeys) { - ast.tokens = convertTokens(ast.tokens, code, tokLabels); - convertComments(ast.comments); - convertAST(ast, visitorKeys); - return ast; -} -function convertError(err) { - if (err instanceof SyntaxError) { - err.lineNumber = err.loc.line; - err.column = err.loc.column; - } - return err; -} - -//# sourceMappingURL=index.cjs.map diff --git a/tools/eslint/node_modules/@babel/eslint-parser/lib/experimental-worker.cjs b/tools/eslint/node_modules/@babel/eslint-parser/lib/experimental-worker.cjs deleted file mode 100644 index d7119150d76f13..00000000000000 --- a/tools/eslint/node_modules/@babel/eslint-parser/lib/experimental-worker.cjs +++ /dev/null @@ -1,32 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.meta = void 0; -exports.parseForESLint = parseForESLint; -const [major, minor] = process.versions.node.split(".").map(Number); -if (major < 12 || major === 12 && minor < 3) { - throw new Error("@babel/eslint-parser/experimental-worker requires Node.js >= 12.3.0"); -} -const normalizeESLintConfig = require("./configuration.cjs"); -const analyzeScope = require("./analyze-scope.cjs"); -const baseParse = require("./parse.cjs"); -const Clients = require("./client.cjs"); -const client = new Clients.WorkerClient(); -const meta = exports.meta = { - name: "@babel/eslint-parser/experimental-worker", - version: "7.24.8" -}; -function parseForESLint(code, options = {}) { - const normalizedOptions = normalizeESLintConfig(options); - const ast = baseParse(code, normalizedOptions, client); - const scopeManager = analyzeScope(ast, normalizedOptions, client); - return { - ast, - scopeManager, - visitorKeys: client.getVisitorKeys() - }; -} - -//# sourceMappingURL=experimental-worker.cjs.map diff --git a/tools/eslint/node_modules/@babel/eslint-parser/lib/index.cjs b/tools/eslint/node_modules/@babel/eslint-parser/lib/index.cjs deleted file mode 100644 index cbf7166b741d9d..00000000000000 --- a/tools/eslint/node_modules/@babel/eslint-parser/lib/index.cjs +++ /dev/null @@ -1,32 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.meta = void 0; -exports.parse = parse; -exports.parseForESLint = parseForESLint; -var _client = require("./client.cjs"); -const normalizeESLintConfig = require("./configuration.cjs"); -const analyzeScope = require("./analyze-scope.cjs"); -const baseParse = require("./parse.cjs"); -const client = new _client.LocalClient(); -const meta = exports.meta = { - name: "@babel/eslint-parser", - version: "7.24.8" -}; -function parse(code, options = {}) { - return baseParse(code, normalizeESLintConfig(options), client); -} -function parseForESLint(code, options = {}) { - const normalizedOptions = normalizeESLintConfig(options); - const ast = baseParse(code, normalizedOptions, client); - const scopeManager = analyzeScope(ast, normalizedOptions, client); - return { - ast, - scopeManager, - visitorKeys: client.getVisitorKeys() - }; -} - -//# sourceMappingURL=index.cjs.map diff --git a/tools/eslint/node_modules/@babel/eslint-parser/lib/parse.cjs b/tools/eslint/node_modules/@babel/eslint-parser/lib/parse.cjs deleted file mode 100644 index be776e2923c196..00000000000000 --- a/tools/eslint/node_modules/@babel/eslint-parser/lib/parse.cjs +++ /dev/null @@ -1,37 +0,0 @@ -"use strict"; - -const semver = require("semver"); -const convert = require("./convert/index.cjs"); -const babelParser = require((((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; -})("@babel/parser", { - paths: [require.resolve("@babel/core/package.json")] -})); -let isRunningMinSupportedCoreVersion = null; -module.exports = function parse(code, options, client) { - const minSupportedCoreVersion = ">=7.2.0"; - if (typeof isRunningMinSupportedCoreVersion !== "boolean") { - isRunningMinSupportedCoreVersion = semver.satisfies(client.getVersion(), minSupportedCoreVersion); - } - if (!isRunningMinSupportedCoreVersion) { - throw new Error(`@babel/eslint-parser@${"7.24.8"} does not support @babel/core@${client.getVersion()}. Please upgrade to @babel/core@${minSupportedCoreVersion}.`); - } - const { - ast, - parserOptions - } = client.maybeParse(code, options); - if (ast) return ast; - try { - return convert.convertFile(babelParser.parse(code, parserOptions), code, client.getTokLabels(), client.getVisitorKeys()); - } catch (err) { - throw convert.convertError(err); - } -}; - -//# sourceMappingURL=parse.cjs.map diff --git a/tools/eslint/node_modules/@babel/eslint-parser/lib/utils/eslint-version.cjs b/tools/eslint/node_modules/@babel/eslint-parser/lib/utils/eslint-version.cjs deleted file mode 100644 index 697839e3462507..00000000000000 --- a/tools/eslint/node_modules/@babel/eslint-parser/lib/utils/eslint-version.cjs +++ /dev/null @@ -1,5 +0,0 @@ -"use strict"; - -module.exports = parseInt(require("eslint/package.json").version, 10); - -//# sourceMappingURL=eslint-version.cjs.map diff --git a/tools/eslint/node_modules/@babel/eslint-parser/lib/worker/ast-info.cjs b/tools/eslint/node_modules/@babel/eslint-parser/lib/worker/ast-info.cjs deleted file mode 100644 index 02164723d0c3ef..00000000000000 --- a/tools/eslint/node_modules/@babel/eslint-parser/lib/worker/ast-info.cjs +++ /dev/null @@ -1,37 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.getTokLabels = getTokLabels; -exports.getVisitorKeys = getVisitorKeys; -const _ESLINT_VISITOR_KEYS = require("eslint-visitor-keys"); -const babel = require("./babel-core.cjs"); -const ESLINT_VISITOR_KEYS = _ESLINT_VISITOR_KEYS.KEYS; -let visitorKeys; -function getVisitorKeys() { - if (!visitorKeys) { - const newTypes = { - ChainExpression: ESLINT_VISITOR_KEYS.ChainExpression, - ImportExpression: ESLINT_VISITOR_KEYS.ImportExpression, - Literal: ESLINT_VISITOR_KEYS.Literal, - MethodDefinition: ["decorators"].concat(ESLINT_VISITOR_KEYS.MethodDefinition), - Property: ["decorators"].concat(ESLINT_VISITOR_KEYS.Property), - PropertyDefinition: ["decorators", "typeAnnotation"].concat(ESLINT_VISITOR_KEYS.PropertyDefinition) - }; - const conflictTypes = { - ClassPrivateMethod: ["decorators"].concat(ESLINT_VISITOR_KEYS.MethodDefinition), - ExportAllDeclaration: ESLINT_VISITOR_KEYS.ExportAllDeclaration - }; - visitorKeys = Object.assign({}, newTypes, babel.types.VISITOR_KEYS, conflictTypes); - } - return visitorKeys; -} -let tokLabels; -function getTokLabels() { - return tokLabels || (tokLabels = (p => p.reduce((o, [k, v]) => Object.assign({}, o, { - [k]: v - }), {}))((Object.entries || (o => Object.keys(o).map(k => [k, o[k]])))(babel.tokTypes).map(([key, tok]) => [key, tok.label]))); -} - -//# sourceMappingURL=ast-info.cjs.map diff --git a/tools/eslint/node_modules/@babel/eslint-parser/lib/worker/babel-core.cjs b/tools/eslint/node_modules/@babel/eslint-parser/lib/worker/babel-core.cjs deleted file mode 100644 index 29ba8fca944ba1..00000000000000 --- a/tools/eslint/node_modules/@babel/eslint-parser/lib/worker/babel-core.cjs +++ /dev/null @@ -1,21 +0,0 @@ -"use strict"; - -module.exports = exports; -function initialize(babel) { - exports.init = null; - exports.version = babel.version; - exports.traverse = babel.traverse; - exports.types = babel.types; - exports.tokTypes = babel.tokTypes; - exports.parseSync = babel.parseSync; - exports.loadPartialConfigSync = babel.loadPartialConfigSync; - exports.loadPartialConfigAsync = babel.loadPartialConfigAsync; - { - exports.createConfigItemSync = babel.createConfigItemSync || babel.createConfigItem; - } -} -{ - initialize(require("@babel/core")); -} - -//# sourceMappingURL=babel-core.cjs.map diff --git a/tools/eslint/node_modules/@babel/eslint-parser/lib/worker/configuration.cjs b/tools/eslint/node_modules/@babel/eslint-parser/lib/worker/configuration.cjs deleted file mode 100644 index 057e3e6bcee614..00000000000000 --- a/tools/eslint/node_modules/@babel/eslint-parser/lib/worker/configuration.cjs +++ /dev/null @@ -1,91 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.normalizeBabelParseConfig = normalizeBabelParseConfig; -exports.normalizeBabelParseConfigSync = normalizeBabelParseConfigSync; -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 babel = require("./babel-core.cjs"); -const ESLINT_VERSION = require("../utils/eslint-version.cjs"); -function getParserPlugins(babelOptions) { - var _babelOptions$parserO, _babelOptions$parserO2; - const babelParserPlugins = (_babelOptions$parserO = (_babelOptions$parserO2 = babelOptions.parserOpts) == null ? void 0 : _babelOptions$parserO2.plugins) != null ? _babelOptions$parserO : []; - const estreeOptions = { - classFeatures: ESLINT_VERSION >= 8 - }; - for (const plugin of babelParserPlugins) { - if (Array.isArray(plugin) && plugin[0] === "estree") { - Object.assign(estreeOptions, plugin[1]); - break; - } - } - return [["estree", estreeOptions], ...babelParserPlugins]; -} -function normalizeParserOptions(options) { - var _options$allowImportE, _options$ecmaFeatures, _options$ecmaFeatures2; - return Object.assign({ - sourceType: options.sourceType, - filename: options.filePath - }, options.babelOptions, { - parserOpts: Object.assign({}, { - allowImportExportEverywhere: (_options$allowImportE = options.allowImportExportEverywhere) != null ? _options$allowImportE : false, - allowSuperOutsideMethod: true - }, { - allowReturnOutsideFunction: (_options$ecmaFeatures = (_options$ecmaFeatures2 = options.ecmaFeatures) == null ? void 0 : _options$ecmaFeatures2.globalReturn) != null ? _options$ecmaFeatures : true - }, options.babelOptions.parserOpts, { - plugins: getParserPlugins(options.babelOptions), - attachComment: false, - ranges: true, - tokens: true - }), - caller: Object.assign({ - name: "@babel/eslint-parser" - }, options.babelOptions.caller) - }); -} -function validateResolvedConfig(config, options, parseOptions) { - if (config !== null) { - if (options.requireConfigFile !== false) { - if (!config.hasFilesystemConfig()) { - let error = `No Babel config file detected for ${config.options.filename}. Either disable config file checking with requireConfigFile: false, or configure Babel so that it can find the config files.`; - if (config.options.filename.includes("node_modules")) { - error += `\nIf you have a .babelrc.js file or use package.json#babel, keep in mind that it's not used when parsing dependencies. If you want your config to be applied to your whole app, consider using babel.config.js or babel.config.json instead.`; - } - throw new Error(error); - } - } - if (config.options) return config.options; - } - return getDefaultParserOptions(parseOptions); -} -function getDefaultParserOptions(options) { - return Object.assign({ - plugins: [] - }, options, { - babelrc: false, - configFile: false, - browserslistConfigFile: false, - ignore: null, - only: null - }); -} -function normalizeBabelParseConfig(_x) { - return _normalizeBabelParseConfig.apply(this, arguments); -} -function _normalizeBabelParseConfig() { - _normalizeBabelParseConfig = _asyncToGenerator(function* (options) { - const parseOptions = normalizeParserOptions(options); - const config = yield babel.loadPartialConfigAsync(parseOptions); - return validateResolvedConfig(config, options, parseOptions); - }); - return _normalizeBabelParseConfig.apply(this, arguments); -} -function normalizeBabelParseConfigSync(options) { - const parseOptions = normalizeParserOptions(options); - const config = babel.loadPartialConfigSync(parseOptions); - return validateResolvedConfig(config, options, parseOptions); -} - -//# sourceMappingURL=configuration.cjs.map diff --git a/tools/eslint/node_modules/@babel/eslint-parser/lib/worker/extract-parser-options-plugin.cjs b/tools/eslint/node_modules/@babel/eslint-parser/lib/worker/extract-parser-options-plugin.cjs deleted file mode 100644 index 7b86f268dad3d1..00000000000000 --- a/tools/eslint/node_modules/@babel/eslint-parser/lib/worker/extract-parser-options-plugin.cjs +++ /dev/null @@ -1,11 +0,0 @@ -"use strict"; - -module.exports = function extractParserOptionsPlugin() { - return { - parserOverride(code, opts) { - return opts; - } - }; -}; - -//# sourceMappingURL=extract-parser-options-plugin.cjs.map diff --git a/tools/eslint/node_modules/@babel/eslint-parser/lib/worker/handle-message.cjs b/tools/eslint/node_modules/@babel/eslint-parser/lib/worker/handle-message.cjs deleted file mode 100644 index 7e2d1c67a7fcea..00000000000000 --- a/tools/eslint/node_modules/@babel/eslint-parser/lib/worker/handle-message.cjs +++ /dev/null @@ -1,32 +0,0 @@ -"use strict"; - -const babel = require("./babel-core.cjs"); -const maybeParse = require("./maybeParse.cjs"); -const astInfo = require("./ast-info.cjs"); -const config = require("./configuration.cjs"); -const Clients = require("../client.cjs"); -var ACTIONS = Clients.ACTIONS; -module.exports = function handleMessage(action, payload) { - switch (action) { - case ACTIONS.GET_VERSION: - return babel.version; - case ACTIONS.GET_TYPES_INFO: - return { - FLOW_FLIPPED_ALIAS_KEYS: babel.types.FLIPPED_ALIAS_KEYS.Flow, - VISITOR_KEYS: babel.types.VISITOR_KEYS - }; - case ACTIONS.GET_TOKEN_LABELS: - return astInfo.getTokLabels(); - case ACTIONS.GET_VISITOR_KEYS: - return astInfo.getVisitorKeys(); - case ACTIONS.MAYBE_PARSE: - return config.normalizeBabelParseConfig(payload.options).then(options => maybeParse(payload.code, options)); - case ACTIONS.MAYBE_PARSE_SYNC: - { - return maybeParse(payload.code, config.normalizeBabelParseConfigSync(payload.options)); - } - } - throw new Error(`Unknown internal parser worker action: ${action}`); -}; - -//# sourceMappingURL=handle-message.cjs.map diff --git a/tools/eslint/node_modules/@babel/eslint-parser/lib/worker/index.cjs b/tools/eslint/node_modules/@babel/eslint-parser/lib/worker/index.cjs deleted file mode 100644 index 746644abb7ec5d..00000000000000 --- a/tools/eslint/node_modules/@babel/eslint-parser/lib/worker/index.cjs +++ /dev/null @@ -1,39 +0,0 @@ -"use strict"; - -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 babel = require("./babel-core.cjs"); -const handleMessage = require("./handle-message.cjs"); -const worker_threads = require("worker_threads"); -worker_threads.parentPort.addListener("message", _asyncToGenerator(function* ({ - signal, - port, - action, - payload -}) { - let response; - try { - if (babel.init) yield babel.init; - response = { - result: yield handleMessage(action, payload) - }; - } catch (error) { - response = { - error, - errorData: Object.assign({}, error) - }; - } - try { - port.postMessage(response); - } catch (_unused) { - port.postMessage({ - error: new Error("Cannot serialize worker response") - }); - } finally { - port.close(); - Atomics.store(signal, 0, 1); - Atomics.notify(signal, 0); - } -})); - -//# sourceMappingURL=index.cjs.map diff --git a/tools/eslint/node_modules/@babel/eslint-parser/lib/worker/maybeParse.cjs b/tools/eslint/node_modules/@babel/eslint-parser/lib/worker/maybeParse.cjs deleted file mode 100644 index b04e4b2ae99902..00000000000000 --- a/tools/eslint/node_modules/@babel/eslint-parser/lib/worker/maybeParse.cjs +++ /dev/null @@ -1,48 +0,0 @@ -"use strict"; - -const babel = require("./babel-core.cjs"); -const convert = require("../convert/index.cjs"); -const astInfo = require("./ast-info.cjs"); -const extractParserOptionsPlugin = require("./extract-parser-options-plugin.cjs"); -const { - getVisitorKeys, - getTokLabels -} = astInfo; -const ref = {}; -let extractParserOptionsConfigItem; -const MULTIPLE_OVERRIDES = /More than one plugin attempted to override parsing/; -module.exports = function maybeParse(code, options) { - if (!extractParserOptionsConfigItem) { - extractParserOptionsConfigItem = babel.createConfigItemSync([extractParserOptionsPlugin, ref], { - dirname: __dirname, - type: "plugin" - }); - } - const { - plugins - } = options; - options.plugins = plugins.concat(extractParserOptionsConfigItem); - let ast; - try { - return { - parserOptions: babel.parseSync(code, options), - ast: null - }; - } catch (err) { - if (!MULTIPLE_OVERRIDES.test(err.message)) { - throw err; - } - } - options.plugins = plugins; - try { - ast = babel.parseSync(code, options); - } catch (err) { - throw convert.convertError(err); - } - return { - ast: convert.convertFile(ast, code, getTokLabels(), getVisitorKeys()), - parserOptions: null - }; -}; - -//# sourceMappingURL=maybeParse.cjs.map diff --git a/tools/eslint/node_modules/@babel/eslint-parser/package.json b/tools/eslint/node_modules/@babel/eslint-parser/package.json deleted file mode 100644 index 0a9b91f5fecd6f..00000000000000 --- a/tools/eslint/node_modules/@babel/eslint-parser/package.json +++ /dev/null @@ -1,46 +0,0 @@ -{ - "name": "@babel/eslint-parser", - "version": "7.24.8", - "description": "ESLint parser that allows for linting of experimental syntax transformed by Babel", - "author": "The Babel Team (https://babel.dev/team)", - "license": "MIT", - "repository": { - "type": "git", - "url": "https://github.com/babel/babel.git", - "directory": "eslint/babel-eslint-parser" - }, - "publishConfig": { - "access": "public" - }, - "bugs": { - "url": "https://github.com/babel/babel/issues" - }, - "homepage": "https://babel.dev/", - "engines": { - "node": "^10.13.0 || ^12.13.0 || >=14.0.0" - }, - "main": "./lib/index.cjs", - "type": "module", - "exports": { - ".": "./lib/index.cjs", - "./experimental-worker": "./lib/experimental-worker.cjs", - "./package.json": "./package.json" - }, - "peerDependencies": { - "@babel/core": "^7.11.0", - "eslint": "^7.5.0 || ^8.0.0 || ^9.0.0" - }, - "dependencies": { - "@nicolo-ribaudo/eslint-scope-5-internals": "5.1.1-v1", - "eslint-visitor-keys": "^2.1.0", - "semver": "^6.3.1" - }, - "devDependencies": { - "@babel/core": "^7.24.8", - "@types/eslint": "^8.56.2", - "@types/estree": "^1.0.5", - "@typescript-eslint/scope-manager": "^6.19.0", - "dedent": "^0.7.0", - "eslint": "^9.0.0" - } -} \ No newline at end of file diff --git a/tools/eslint/node_modules/@babel/eslint-parser/tsconfig.tsbuildinfo b/tools/eslint/node_modules/@babel/eslint-parser/tsconfig.tsbuildinfo deleted file mode 100644 index db6da18a821b97..00000000000000 --- a/tools/eslint/node_modules/@babel/eslint-parser/tsconfig.tsbuildinfo +++ /dev/null @@ -1 +0,0 @@ -{"program":{"fileNames":["../../node_modules/typescript/lib/lib.es5.d.ts","../../node_modules/typescript/lib/lib.es2015.d.ts","../../node_modules/typescript/lib/lib.es2016.d.ts","../../node_modules/typescript/lib/lib.es2017.d.ts","../../node_modules/typescript/lib/lib.es2018.d.ts","../../node_modules/typescript/lib/lib.es2019.d.ts","../../node_modules/typescript/lib/lib.es2020.d.ts","../../node_modules/typescript/lib/lib.es2021.d.ts","../../node_modules/typescript/lib/lib.es2022.d.ts","../../node_modules/typescript/lib/lib.es2023.d.ts","../../node_modules/typescript/lib/lib.esnext.d.ts","../../node_modules/typescript/lib/lib.es2015.core.d.ts","../../node_modules/typescript/lib/lib.es2015.collection.d.ts","../../node_modules/typescript/lib/lib.es2015.generator.d.ts","../../node_modules/typescript/lib/lib.es2015.iterable.d.ts","../../node_modules/typescript/lib/lib.es2015.promise.d.ts","../../node_modules/typescript/lib/lib.es2015.proxy.d.ts","../../node_modules/typescript/lib/lib.es2015.reflect.d.ts","../../node_modules/typescript/lib/lib.es2015.symbol.d.ts","../../node_modules/typescript/lib/lib.es2015.symbol.wellknown.d.ts","../../node_modules/typescript/lib/lib.es2016.array.include.d.ts","../../node_modules/typescript/lib/lib.es2016.intl.d.ts","../../node_modules/typescript/lib/lib.es2017.date.d.ts","../../node_modules/typescript/lib/lib.es2017.object.d.ts","../../node_modules/typescript/lib/lib.es2017.sharedmemory.d.ts","../../node_modules/typescript/lib/lib.es2017.string.d.ts","../../node_modules/typescript/lib/lib.es2017.intl.d.ts","../../node_modules/typescript/lib/lib.es2017.typedarrays.d.ts","../../node_modules/typescript/lib/lib.es2018.asyncgenerator.d.ts","../../node_modules/typescript/lib/lib.es2018.asynciterable.d.ts","../../node_modules/typescript/lib/lib.es2018.intl.d.ts","../../node_modules/typescript/lib/lib.es2018.promise.d.ts","../../node_modules/typescript/lib/lib.es2018.regexp.d.ts","../../node_modules/typescript/lib/lib.es2019.array.d.ts","../../node_modules/typescript/lib/lib.es2019.object.d.ts","../../node_modules/typescript/lib/lib.es2019.string.d.ts","../../node_modules/typescript/lib/lib.es2019.symbol.d.ts","../../node_modules/typescript/lib/lib.es2019.intl.d.ts","../../node_modules/typescript/lib/lib.es2020.bigint.d.ts","../../node_modules/typescript/lib/lib.es2020.date.d.ts","../../node_modules/typescript/lib/lib.es2020.promise.d.ts","../../node_modules/typescript/lib/lib.es2020.sharedmemory.d.ts","../../node_modules/typescript/lib/lib.es2020.string.d.ts","../../node_modules/typescript/lib/lib.es2020.symbol.wellknown.d.ts","../../node_modules/typescript/lib/lib.es2020.intl.d.ts","../../node_modules/typescript/lib/lib.es2020.number.d.ts","../../node_modules/typescript/lib/lib.es2021.promise.d.ts","../../node_modules/typescript/lib/lib.es2021.string.d.ts","../../node_modules/typescript/lib/lib.es2021.weakref.d.ts","../../node_modules/typescript/lib/lib.es2021.intl.d.ts","../../node_modules/typescript/lib/lib.es2022.array.d.ts","../../node_modules/typescript/lib/lib.es2022.error.d.ts","../../node_modules/typescript/lib/lib.es2022.intl.d.ts","../../node_modules/typescript/lib/lib.es2022.object.d.ts","../../node_modules/typescript/lib/lib.es2022.sharedmemory.d.ts","../../node_modules/typescript/lib/lib.es2022.string.d.ts","../../node_modules/typescript/lib/lib.es2022.regexp.d.ts","../../node_modules/typescript/lib/lib.es2023.array.d.ts","../../node_modules/typescript/lib/lib.es2023.collection.d.ts","../../node_modules/typescript/lib/lib.es2023.intl.d.ts","../../node_modules/typescript/lib/lib.esnext.array.d.ts","../../node_modules/typescript/lib/lib.esnext.collection.d.ts","../../node_modules/typescript/lib/lib.esnext.intl.d.ts","../../node_modules/typescript/lib/lib.esnext.disposable.d.ts","../../node_modules/typescript/lib/lib.esnext.string.d.ts","../../node_modules/typescript/lib/lib.esnext.promise.d.ts","../../node_modules/typescript/lib/lib.esnext.decorators.d.ts","../../node_modules/typescript/lib/lib.esnext.object.d.ts","../../node_modules/typescript/lib/lib.esnext.regexp.d.ts","../../node_modules/typescript/lib/lib.decorators.d.ts","../../node_modules/typescript/lib/lib.decorators.legacy.d.ts","../../node_modules/@types/eslint/helpers.d.ts","../../node_modules/@types/estree/index.d.ts","../../node_modules/@types/json-schema/index.d.ts","../../node_modules/@types/eslint/index.d.ts","../../dts/packages/babel-types/src/validators/react/isCompatTag.d.ts","../../dts/packages/babel-types/src/builders/react/buildChildren.d.ts","../../dts/packages/babel-types/src/asserts/assertNode.d.ts","../../dts/packages/babel-types/src/asserts/generated/index.d.ts","../../dts/packages/babel-types/src/builders/flow/createTypeAnnotationBasedOnTypeof.d.ts","../../dts/packages/babel-types/src/builders/flow/createFlowUnionType.d.ts","../../dts/packages/babel-types/src/builders/typescript/createTSUnionType.d.ts","../../dts/packages/babel-types/src/builders/generated/index.d.ts","../../packages/babel-types/src/builders/generated/uppercase.d.ts","../../dts/packages/babel-types/src/builders/productions.d.ts","../../dts/packages/babel-types/src/clone/cloneNode.d.ts","../../dts/packages/babel-types/src/clone/clone.d.ts","../../dts/packages/babel-types/src/clone/cloneDeep.d.ts","../../dts/packages/babel-types/src/clone/cloneDeepWithoutLoc.d.ts","../../dts/packages/babel-types/src/clone/cloneWithoutLoc.d.ts","../../dts/packages/babel-types/src/comments/addComment.d.ts","../../dts/packages/babel-types/src/comments/addComments.d.ts","../../dts/packages/babel-types/src/comments/inheritInnerComments.d.ts","../../dts/packages/babel-types/src/comments/inheritLeadingComments.d.ts","../../dts/packages/babel-types/src/comments/inheritsComments.d.ts","../../dts/packages/babel-types/src/comments/inheritTrailingComments.d.ts","../../dts/packages/babel-types/src/comments/removeComments.d.ts","../../dts/packages/babel-types/src/constants/generated/index.d.ts","../../dts/packages/babel-types/src/constants/index.d.ts","../../dts/packages/babel-types/src/converters/ensureBlock.d.ts","../../dts/packages/babel-types/src/converters/toBindingIdentifierName.d.ts","../../dts/packages/babel-types/src/converters/toBlock.d.ts","../../dts/packages/babel-types/src/converters/toComputedKey.d.ts","../../dts/packages/babel-types/src/converters/toExpression.d.ts","../../dts/packages/babel-types/src/converters/toIdentifier.d.ts","../../dts/packages/babel-types/src/converters/toKeyAlias.d.ts","../../dts/packages/babel-types/src/converters/toStatement.d.ts","../../dts/packages/babel-types/src/converters/valueToNode.d.ts","../../dts/packages/babel-types/src/definitions/utils.d.ts","../../dts/packages/babel-types/src/definitions/core.d.ts","../../dts/packages/babel-types/src/definitions/flow.d.ts","../../dts/packages/babel-types/src/definitions/jsx.d.ts","../../dts/packages/babel-types/src/definitions/misc.d.ts","../../dts/packages/babel-types/src/definitions/experimental.d.ts","../../dts/packages/babel-types/src/definitions/typescript.d.ts","../../dts/packages/babel-types/src/definitions/placeholders.d.ts","../../dts/packages/babel-types/src/definitions/deprecated-aliases.d.ts","../../dts/packages/babel-types/src/definitions/index.d.ts","../../dts/packages/babel-types/src/modifications/appendToMemberExpression.d.ts","../../dts/packages/babel-types/src/modifications/inherits.d.ts","../../dts/packages/babel-types/src/modifications/prependToMemberExpression.d.ts","../../dts/packages/babel-types/src/modifications/removeProperties.d.ts","../../dts/packages/babel-types/src/modifications/removePropertiesDeep.d.ts","../../dts/packages/babel-types/src/modifications/flow/removeTypeDuplicates.d.ts","../../dts/packages/babel-types/src/retrievers/getBindingIdentifiers.d.ts","../../dts/packages/babel-types/src/retrievers/getOuterBindingIdentifiers.d.ts","../../dts/packages/babel-types/src/traverse/traverse.d.ts","../../dts/packages/babel-types/src/traverse/traverseFast.d.ts","../../dts/packages/babel-types/src/utils/shallowEqual.d.ts","../../dts/packages/babel-types/src/validators/is.d.ts","../../dts/packages/babel-types/src/validators/isBinding.d.ts","../../dts/packages/babel-types/src/validators/isBlockScoped.d.ts","../../dts/packages/babel-types/src/validators/isImmutable.d.ts","../../dts/packages/babel-types/src/validators/isLet.d.ts","../../dts/packages/babel-types/src/validators/isNode.d.ts","../../dts/packages/babel-types/src/validators/isNodesEquivalent.d.ts","../../dts/packages/babel-types/src/validators/isPlaceholderType.d.ts","../../dts/packages/babel-types/src/validators/isReferenced.d.ts","../../dts/packages/babel-types/src/validators/isScope.d.ts","../../dts/packages/babel-types/src/validators/isSpecifierDefault.d.ts","../../dts/packages/babel-types/src/validators/isType.d.ts","../../dts/packages/babel-types/src/validators/isValidES3Identifier.d.ts","../../dts/packages/babel-types/src/validators/isValidIdentifier.d.ts","../../dts/packages/babel-types/src/validators/isVar.d.ts","../../dts/packages/babel-types/src/validators/matchesPattern.d.ts","../../dts/packages/babel-types/src/validators/validate.d.ts","../../dts/packages/babel-types/src/validators/buildMatchMemberExpression.d.ts","../../dts/packages/babel-types/src/validators/generated/index.d.ts","../../dts/packages/babel-types/src/ast-types/generated/index.d.ts","../../dts/packages/babel-types/src/utils/deprecationWarning.d.ts","../../dts/packages/babel-types/src/index.d.ts","../../dts/packages/babel-traverse/src/path/lib/virtual-types.d.ts","../../packages/babel-traverse/src/generated/visitor-types.d.ts","../../dts/packages/babel-traverse/src/types.d.ts","../../dts/packages/babel-traverse/src/visitors.d.ts","../../dts/packages/babel-traverse/src/scope/binding.d.ts","../../dts/packages/babel-traverse/src/scope/index.d.ts","../../dts/packages/babel-traverse/src/hub.d.ts","../../dts/packages/babel-traverse/src/context.d.ts","../../dts/packages/babel-traverse/src/path/ancestry.d.ts","../../dts/packages/babel-traverse/src/path/inference/index.d.ts","../../dts/packages/babel-traverse/src/path/replacement.d.ts","../../dts/packages/babel-traverse/src/path/evaluation.d.ts","../../dts/packages/babel-traverse/src/path/conversion.d.ts","../../dts/packages/babel-traverse/src/path/introspection.d.ts","../../dts/packages/babel-traverse/src/path/context.d.ts","../../dts/packages/babel-traverse/src/path/removal.d.ts","../../dts/packages/babel-traverse/src/path/modification.d.ts","../../dts/packages/babel-traverse/src/path/family.d.ts","../../dts/packages/babel-traverse/src/path/comments.d.ts","../../packages/babel-traverse/src/path/generated/asserts.d.ts","../../dts/packages/babel-traverse/src/path/lib/virtual-types-validator.d.ts","../../packages/babel-traverse/src/path/generated/validators.d.ts","../../dts/packages/babel-traverse/src/path/index.d.ts","../../dts/packages/babel-traverse/src/cache.d.ts","../../dts/packages/babel-traverse/src/index.d.ts","../../node_modules/@types/gensync/index.d.ts","../../dts/packages/babel-core/src/config/helpers/deep-array.d.ts","../../dts/packages/babel-parser/src/util/location.d.ts","../../dts/packages/babel-parser/src/tokenizer/context.d.ts","../../dts/packages/babel-parser/src/tokenizer/types.d.ts","../../dts/packages/babel-parser/src/parse-error/standard-errors.d.ts","../../dts/packages/babel-parser/src/parse-error/pipeline-operator-errors.d.ts","../../dts/packages/babel-parser/src/parse-error.d.ts","../../dts/packages/babel-parser/src/tokenizer/state.d.ts","../../dts/packages/babel-parser/src/util/scopeflags.d.ts","../../dts/packages/babel-parser/src/util/scope.d.ts","../../dts/packages/babel-parser/src/util/expression-scope.d.ts","../../dts/packages/babel-parser/src/util/class-scope.d.ts","../../dts/packages/babel-parser/src/util/production-parameter.d.ts","../../packages/babel-parser/src/typings.d.ts","../../dts/packages/babel-parser/src/parser/base.d.ts","../../dts/packages/babel-parser/src/parser/util.d.ts","../../dts/packages/babel-parser/src/parser/node.d.ts","../../dts/packages/babel-parser/src/parser/comments.d.ts","../../dts/packages/babel-helper-string-parser/src/index.d.ts","../../dts/packages/babel-parser/src/tokenizer/index.d.ts","../../node_modules/@types/charcodes/index.d.ts","../../dts/packages/babel-parser/src/parser/lval.d.ts","../../dts/packages/babel-parser/src/parser/expression.d.ts","../../dts/packages/babel-parser/src/parser/statement.d.ts","../../dts/packages/babel-parser/src/plugins/placeholders.d.ts","../../dts/packages/babel-parser/src/types.d.ts","../../dts/packages/babel-parser/src/parser/index.d.ts","../../dts/packages/babel-parser/src/plugins/flow/scope.d.ts","../../dts/packages/babel-parser/src/plugins/jsx/index.d.ts","../../dts/packages/babel-parser/src/plugins/typescript/scope.d.ts","../../dts/packages/babel-parser/src/plugin-utils.d.ts","../../dts/packages/babel-parser/src/options.d.ts","../../dts/packages/babel-parser/src/index.d.ts","../../dts/packages/babel-helper-compilation-targets/src/options.d.ts","../../dts/packages/babel-helper-compilation-targets/src/targets.d.ts","../../packages/babel-helper-compilation-targets/src/types.d.ts","../../dts/packages/babel-helper-compilation-targets/src/pretty.d.ts","../../dts/packages/babel-helper-compilation-targets/src/debug.d.ts","../../dts/packages/babel-helper-compilation-targets/src/filter-items.d.ts","../../dts/packages/babel-helper-compilation-targets/src/index.d.ts","../../dts/packages/babel-core/src/config/caching.d.ts","../../dts/packages/babel-core/src/config/printer.d.ts","../../dts/packages/babel-core/src/config/files/types.d.ts","../../dts/packages/babel-core/src/config/files/package.d.ts","../../dts/packages/babel-core/src/config/files/configuration.d.ts","../../dts/packages/babel-core/src/config/files/plugins.d.ts","../../dts/packages/babel-core/src/config/files/index.d.ts","../../dts/packages/babel-core/src/config/config-chain.d.ts","../../dts/packages/babel-core/src/config/cache-contexts.d.ts","../../dts/packages/babel-core/src/config/helpers/config-api.d.ts","../../dts/packages/babel-core/src/config/config-descriptors.d.ts","../../dts/packages/babel-core/src/config/item.d.ts","../../node_modules/@types/jsesc/index.d.ts","../../node_modules/@jridgewell/trace-mapping/dist/types/sourcemap-segment.d.ts","../../node_modules/@jridgewell/trace-mapping/dist/types/types.d.ts","../../node_modules/@jridgewell/trace-mapping/dist/types/any-map.d.ts","../../node_modules/@jridgewell/trace-mapping/dist/types/trace-mapping.d.ts","../../node_modules/@jridgewell/gen-mapping/dist/types/sourcemap-segment.d.ts","../../node_modules/@jridgewell/gen-mapping/dist/types/types.d.ts","../../node_modules/@jridgewell/gen-mapping/dist/types/gen-mapping.d.ts","../../dts/packages/babel-generator/src/index.d.ts","../../dts/packages/babel-core/src/config/validation/options.d.ts","../../dts/packages/babel-core/src/config/validation/plugins.d.ts","../../dts/packages/babel-core/src/config/plugin.d.ts","../../dts/packages/babel-core/src/config/full.d.ts","../../dts/packages/babel-core/src/config/partial.d.ts","../../dts/packages/babel-core/src/config/index.d.ts","../../node_modules/@types/convert-source-map/index.d.ts","../../dts/packages/babel-core/src/transformation/normalize-file.d.ts","../../dts/packages/babel-core/src/transformation/file/file.d.ts","../../dts/packages/babel-core/src/transformation/plugin-pass.d.ts","../../dts/packages/babel-core/src/tools/build-external-helpers.d.ts","../../dts/packages/babel-core/src/config/helpers/environment.d.ts","../../dts/packages/babel-template/src/options.d.ts","../../dts/packages/babel-template/src/formatters.d.ts","../../dts/packages/babel-template/src/builder.d.ts","../../dts/packages/babel-template/src/index.d.ts","../../dts/packages/babel-core/src/transformation/index.d.ts","../../dts/packages/babel-core/src/transform.d.ts","../../dts/packages/babel-core/src/transform-file.d.ts","../../dts/packages/babel-core/src/transform-ast.d.ts","../../dts/packages/babel-core/src/parser/index.d.ts","../../dts/packages/babel-core/src/parse.d.ts","../../dts/packages/babel-core/src/index.d.ts","../../node_modules/typescript/lib/typescript.d.ts","../../node_modules/@typescript-eslint/scope-manager/node_modules/@typescript-eslint/types/dist/generated/ast-spec.d.ts","../../node_modules/@typescript-eslint/scope-manager/node_modules/@typescript-eslint/types/dist/lib.d.ts","../../node_modules/@typescript-eslint/scope-manager/node_modules/@typescript-eslint/types/dist/parser-options.d.ts","../../node_modules/@typescript-eslint/scope-manager/node_modules/@typescript-eslint/types/dist/ts-estree.d.ts","../../node_modules/@typescript-eslint/scope-manager/node_modules/@typescript-eslint/types/dist/index.d.ts","../../node_modules/@typescript-eslint/scope-manager/dist/definition/DefinitionType.d.ts","../../node_modules/@typescript-eslint/scope-manager/dist/definition/DefinitionBase.d.ts","../../node_modules/@typescript-eslint/scope-manager/dist/definition/CatchClauseDefinition.d.ts","../../node_modules/@typescript-eslint/scope-manager/dist/definition/ClassNameDefinition.d.ts","../../node_modules/@typescript-eslint/scope-manager/dist/definition/FunctionNameDefinition.d.ts","../../node_modules/@typescript-eslint/scope-manager/dist/definition/ImplicitGlobalVariableDefinition.d.ts","../../node_modules/@typescript-eslint/scope-manager/dist/definition/ImportBindingDefinition.d.ts","../../node_modules/@typescript-eslint/scope-manager/dist/definition/ParameterDefinition.d.ts","../../node_modules/@typescript-eslint/scope-manager/dist/definition/TSEnumMemberDefinition.d.ts","../../node_modules/@typescript-eslint/scope-manager/dist/definition/TSEnumNameDefinition.d.ts","../../node_modules/@typescript-eslint/scope-manager/dist/definition/TSModuleNameDefinition.d.ts","../../node_modules/@typescript-eslint/scope-manager/dist/definition/TypeDefinition.d.ts","../../node_modules/@typescript-eslint/scope-manager/dist/definition/VariableDefinition.d.ts","../../node_modules/@typescript-eslint/scope-manager/dist/definition/Definition.d.ts","../../node_modules/@typescript-eslint/scope-manager/dist/definition/index.d.ts","../../node_modules/@typescript-eslint/scope-manager/dist/variable/VariableBase.d.ts","../../node_modules/@typescript-eslint/scope-manager/dist/variable/ESLintScopeVariable.d.ts","../../node_modules/@typescript-eslint/scope-manager/dist/variable/Variable.d.ts","../../node_modules/@typescript-eslint/scope-manager/dist/variable/ImplicitLibVariable.d.ts","../../node_modules/@typescript-eslint/scope-manager/dist/variable/index.d.ts","../../node_modules/@typescript-eslint/scope-manager/dist/referencer/Reference.d.ts","../../node_modules/@typescript-eslint/scope-manager/dist/scope/ScopeType.d.ts","../../node_modules/@typescript-eslint/scope-manager/dist/scope/FunctionScope.d.ts","../../node_modules/@typescript-eslint/scope-manager/dist/scope/GlobalScope.d.ts","../../node_modules/@typescript-eslint/scope-manager/dist/scope/ModuleScope.d.ts","../../node_modules/@typescript-eslint/scope-manager/dist/scope/TSModuleScope.d.ts","../../node_modules/@typescript-eslint/scope-manager/dist/scope/ScopeBase.d.ts","../../node_modules/@typescript-eslint/scope-manager/dist/scope/CatchScope.d.ts","../../node_modules/@typescript-eslint/scope-manager/dist/scope/ClassScope.d.ts","../../node_modules/@typescript-eslint/scope-manager/dist/scope/ClassStaticBlockScope.d.ts","../../node_modules/@typescript-eslint/scope-manager/dist/scope/ConditionalTypeScope.d.ts","../../node_modules/@typescript-eslint/scope-manager/dist/scope/ForScope.d.ts","../../node_modules/@typescript-eslint/scope-manager/dist/scope/FunctionExpressionNameScope.d.ts","../../node_modules/@typescript-eslint/scope-manager/dist/scope/FunctionTypeScope.d.ts","../../node_modules/@typescript-eslint/scope-manager/dist/scope/MappedTypeScope.d.ts","../../node_modules/@typescript-eslint/scope-manager/dist/scope/SwitchScope.d.ts","../../node_modules/@typescript-eslint/scope-manager/dist/scope/TSEnumScope.d.ts","../../node_modules/@typescript-eslint/scope-manager/dist/scope/TypeScope.d.ts","../../node_modules/@typescript-eslint/scope-manager/dist/scope/WithScope.d.ts","../../node_modules/@typescript-eslint/scope-manager/dist/scope/Scope.d.ts","../../node_modules/@typescript-eslint/scope-manager/dist/scope/ClassFieldInitializerScope.d.ts","../../node_modules/@typescript-eslint/scope-manager/dist/ScopeManager.d.ts","../../node_modules/@typescript-eslint/scope-manager/dist/scope/BlockScope.d.ts","../../node_modules/@typescript-eslint/scope-manager/dist/scope/index.d.ts","../../node_modules/@typescript-eslint/scope-manager/node_modules/@typescript-eslint/visitor-keys/dist/get-keys.d.ts","../../node_modules/@typescript-eslint/scope-manager/node_modules/@typescript-eslint/visitor-keys/dist/visitor-keys.d.ts","../../node_modules/@typescript-eslint/scope-manager/node_modules/@typescript-eslint/visitor-keys/dist/index.d.ts","../../node_modules/@typescript-eslint/scope-manager/dist/referencer/VisitorBase.d.ts","../../node_modules/@typescript-eslint/scope-manager/dist/referencer/PatternVisitor.d.ts","../../node_modules/@typescript-eslint/scope-manager/dist/referencer/Visitor.d.ts","../../node_modules/@typescript-eslint/scope-manager/dist/referencer/Referencer.d.ts","../../node_modules/@typescript-eslint/scope-manager/dist/referencer/index.d.ts","../../node_modules/@typescript-eslint/scope-manager/dist/analyze.d.ts","../../node_modules/@typescript-eslint/scope-manager/dist/index.d.ts","./src/types.d.cts","./src/client.cts","./src/analyze-scope.cts","./src/configuration.cts","../../node_modules/@types/semver/classes/semver.d.ts","../../node_modules/@types/semver/functions/parse.d.ts","../../node_modules/@types/semver/functions/valid.d.ts","../../node_modules/@types/semver/functions/clean.d.ts","../../node_modules/@types/semver/functions/inc.d.ts","../../node_modules/@types/semver/functions/diff.d.ts","../../node_modules/@types/semver/functions/major.d.ts","../../node_modules/@types/semver/functions/minor.d.ts","../../node_modules/@types/semver/functions/patch.d.ts","../../node_modules/@types/semver/functions/prerelease.d.ts","../../node_modules/@types/semver/functions/compare.d.ts","../../node_modules/@types/semver/functions/rcompare.d.ts","../../node_modules/@types/semver/functions/compare-loose.d.ts","../../node_modules/@types/semver/functions/compare-build.d.ts","../../node_modules/@types/semver/functions/sort.d.ts","../../node_modules/@types/semver/functions/rsort.d.ts","../../node_modules/@types/semver/functions/gt.d.ts","../../node_modules/@types/semver/functions/lt.d.ts","../../node_modules/@types/semver/functions/eq.d.ts","../../node_modules/@types/semver/functions/neq.d.ts","../../node_modules/@types/semver/functions/gte.d.ts","../../node_modules/@types/semver/functions/lte.d.ts","../../node_modules/@types/semver/functions/cmp.d.ts","../../node_modules/@types/semver/functions/coerce.d.ts","../../node_modules/@types/semver/classes/comparator.d.ts","../../node_modules/@types/semver/classes/range.d.ts","../../node_modules/@types/semver/functions/satisfies.d.ts","../../node_modules/@types/semver/ranges/max-satisfying.d.ts","../../node_modules/@types/semver/ranges/min-satisfying.d.ts","../../node_modules/@types/semver/ranges/to-comparators.d.ts","../../node_modules/@types/semver/ranges/min-version.d.ts","../../node_modules/@types/semver/ranges/valid.d.ts","../../node_modules/@types/semver/ranges/outside.d.ts","../../node_modules/@types/semver/ranges/gtr.d.ts","../../node_modules/@types/semver/ranges/ltr.d.ts","../../node_modules/@types/semver/ranges/intersects.d.ts","../../node_modules/@types/semver/ranges/simplify.d.ts","../../node_modules/@types/semver/ranges/subset.d.ts","../../node_modules/@types/semver/internals/identifiers.d.ts","../../node_modules/@types/semver/index.d.ts","./src/utils/eslint-version.cts","./src/convert/convertTokens.cts","./src/convert/convertComments.cts","./src/convert/convertAST.cts","./src/convert/index.cts","./src/parse.cts","./src/experimental-worker.cts","./src/index.cts","./src/worker/babel-core.cts","./src/worker/ast-info.cts","./src/worker/configuration.cts","./src/worker/extract-parser-options-plugin.cts","./src/worker/maybeParse.cts","./src/worker/handle-message.cts","./src/worker/index.cts","../../lib/globals.d.ts","../../node_modules/@types/color-name/index.d.ts","../../node_modules/@types/debug/index.d.ts","../../node_modules/@types/eslint-scope/index.d.ts","../../node_modules/@types/fs-readdir-recursive/index.d.ts","../../node_modules/@types/node/assert.d.ts","../../node_modules/@types/node/assert/strict.d.ts","../../node_modules/buffer/index.d.ts","../../node_modules/undici-types/header.d.ts","../../node_modules/undici-types/readable.d.ts","../../node_modules/undici-types/file.d.ts","../../node_modules/undici-types/fetch.d.ts","../../node_modules/undici-types/formdata.d.ts","../../node_modules/undici-types/connector.d.ts","../../node_modules/undici-types/client.d.ts","../../node_modules/undici-types/errors.d.ts","../../node_modules/undici-types/dispatcher.d.ts","../../node_modules/undici-types/global-dispatcher.d.ts","../../node_modules/undici-types/global-origin.d.ts","../../node_modules/undici-types/pool-stats.d.ts","../../node_modules/undici-types/pool.d.ts","../../node_modules/undici-types/handlers.d.ts","../../node_modules/undici-types/balanced-pool.d.ts","../../node_modules/undici-types/agent.d.ts","../../node_modules/undici-types/mock-interceptor.d.ts","../../node_modules/undici-types/mock-agent.d.ts","../../node_modules/undici-types/mock-client.d.ts","../../node_modules/undici-types/mock-pool.d.ts","../../node_modules/undici-types/mock-errors.d.ts","../../node_modules/undici-types/proxy-agent.d.ts","../../node_modules/undici-types/api.d.ts","../../node_modules/undici-types/cookies.d.ts","../../node_modules/undici-types/patch.d.ts","../../node_modules/undici-types/filereader.d.ts","../../node_modules/undici-types/diagnostics-channel.d.ts","../../node_modules/undici-types/websocket.d.ts","../../node_modules/undici-types/content-type.d.ts","../../node_modules/undici-types/cache.d.ts","../../node_modules/undici-types/interceptors.d.ts","../../node_modules/undici-types/index.d.ts","../../node_modules/@types/node/globals.d.ts","../../node_modules/@types/node/async_hooks.d.ts","../../node_modules/@types/node/buffer.d.ts","../../node_modules/@types/node/child_process.d.ts","../../node_modules/@types/node/cluster.d.ts","../../node_modules/@types/node/console.d.ts","../../node_modules/@types/node/constants.d.ts","../../node_modules/@types/node/crypto.d.ts","../../node_modules/@types/node/dgram.d.ts","../../node_modules/@types/node/diagnostics_channel.d.ts","../../node_modules/@types/node/dns.d.ts","../../node_modules/@types/node/dns/promises.d.ts","../../node_modules/@types/node/domain.d.ts","../../node_modules/@types/node/dom-events.d.ts","../../node_modules/@types/node/events.d.ts","../../node_modules/@types/node/fs.d.ts","../../node_modules/@types/node/fs/promises.d.ts","../../node_modules/@types/node/http.d.ts","../../node_modules/@types/node/http2.d.ts","../../node_modules/@types/node/https.d.ts","../../node_modules/@types/node/inspector.d.ts","../../node_modules/@types/node/module.d.ts","../../node_modules/@types/node/net.d.ts","../../node_modules/@types/node/os.d.ts","../../node_modules/@types/node/path.d.ts","../../node_modules/@types/node/perf_hooks.d.ts","../../node_modules/@types/node/process.d.ts","../../node_modules/@types/node/punycode.d.ts","../../node_modules/@types/node/querystring.d.ts","../../node_modules/@types/node/readline.d.ts","../../node_modules/@types/node/readline/promises.d.ts","../../node_modules/@types/node/repl.d.ts","../../node_modules/@types/node/sea.d.ts","../../node_modules/@types/node/stream.d.ts","../../node_modules/@types/node/stream/promises.d.ts","../../node_modules/@types/node/stream/consumers.d.ts","../../node_modules/@types/node/stream/web.d.ts","../../node_modules/@types/node/string_decoder.d.ts","../../node_modules/@types/node/test.d.ts","../../node_modules/@types/node/timers.d.ts","../../node_modules/@types/node/timers/promises.d.ts","../../node_modules/@types/node/tls.d.ts","../../node_modules/@types/node/trace_events.d.ts","../../node_modules/@types/node/tty.d.ts","../../node_modules/@types/node/url.d.ts","../../node_modules/@types/node/util.d.ts","../../node_modules/@types/node/v8.d.ts","../../node_modules/@types/node/vm.d.ts","../../node_modules/@types/node/wasi.d.ts","../../node_modules/@types/node/worker_threads.d.ts","../../node_modules/@types/node/zlib.d.ts","../../node_modules/@types/node/globals.global.d.ts","../../node_modules/@types/node/index.d.ts","../../node_modules/@types/minimatch/index.d.ts","../../node_modules/@types/glob/index.d.ts","../../node_modules/@types/istanbul-lib-coverage/index.d.ts","../../node_modules/@types/istanbul-lib-report/index.d.ts","../../node_modules/@types/istanbul-reports/index.d.ts","../../node_modules/@types/jest/node_modules/@jest/expect-utils/build/index.d.ts","../../node_modules/@types/jest/node_modules/chalk/index.d.ts","../../node_modules/@sinclair/typebox/typebox.d.ts","../../node_modules/@jest/schemas/build/index.d.ts","../../node_modules/jest-diff/node_modules/pretty-format/build/index.d.ts","../../node_modules/jest-diff/build/index.d.ts","../../node_modules/@types/jest/node_modules/jest-matcher-utils/build/index.d.ts","../../node_modules/@types/jest/node_modules/expect/build/index.d.ts","../../node_modules/@types/jest/node_modules/pretty-format/build/index.d.ts","../../node_modules/@types/jest/index.d.ts","../../node_modules/@types/json5/index.d.ts","../../node_modules/@types/lru-cache/index.d.ts","../../node_modules/@types/resolve/index.d.ts","../../node_modules/@types/stack-utils/index.d.ts","../../node_modules/@types/v8flags/index.d.ts","../../node_modules/@types/yargs-parser/index.d.ts","../../node_modules/@types/yargs/index.d.ts"],"fileInfos":[{"version":"44e584d4f6444f58791784f1d530875970993129442a847597db702a073ca68c","affectsGlobalScope":true},"45b7ab580deca34ae9729e97c13cfd999df04416a79116c3bfb483804f85ded4","3facaf05f0c5fc569c5649dd359892c98a85557e3e0c847964caeb67076f4d75","9a68c0c07ae2fa71b44384a839b7b8d81662a236d4b9ac30916718f7510b1b2d","5e1c4c362065a6b95ff952c0eab010f04dcd2c3494e813b493ecfd4fcb9fc0d8","68d73b4a11549f9c0b7d352d10e91e5dca8faa3322bfb77b661839c42b1ddec7","5efce4fc3c29ea84e8928f97adec086e3dc876365e0982cc8479a07954a3efd4","feecb1be483ed332fad555aff858affd90a48ab19ba7272ee084704eb7167569","5514e54f17d6d74ecefedc73c504eadffdeda79c7ea205cf9febead32d45c4bc","27bdc30a0e32783366a5abeda841bc22757c1797de8681bbe81fbc735eeb1c10","17edc026abf73c5c2dd508652d63f68ec4efd9d4856e3469890d27598209feb5",{"version":"6920e1448680767498a0b77c6a00a8e77d14d62c3da8967b171f1ddffa3c18e4","affectsGlobalScope":true},{"version":"dc2df20b1bcdc8c2d34af4926e2c3ab15ffe1160a63e58b7e09833f616efff44","affectsGlobalScope":true},{"version":"4443e68b35f3332f753eacc66a04ac1d2053b8b035a0e0ac1d455392b5e243b3","affectsGlobalScope":true},{"version":"bc47685641087c015972a3f072480889f0d6c65515f12bd85222f49a98952ed7","affectsGlobalScope":true},{"version":"0dc1e7ceda9b8b9b455c3a2d67b0412feab00bd2f66656cd8850e8831b08b537","affectsGlobalScope":true},{"version":"ce691fb9e5c64efb9547083e4a34091bcbe5bdb41027e310ebba8f7d96a98671","affectsGlobalScope":true},{"version":"8d697a2a929a5fcb38b7a65594020fcef05ec1630804a33748829c5ff53640d0","affectsGlobalScope":true},{"version":"4ff2a353abf8a80ee399af572debb8faab2d33ad38c4b4474cff7f26e7653b8d","affectsGlobalScope":true},{"version":"93495ff27b8746f55d19fcbcdbaccc99fd95f19d057aed1bd2c0cafe1335fbf0","affectsGlobalScope":true},{"version":"6fc23bb8c3965964be8c597310a2878b53a0306edb71d4b5a4dfe760186bcc01","affectsGlobalScope":true},{"version":"ea011c76963fb15ef1cdd7ce6a6808b46322c527de2077b6cfdf23ae6f5f9ec7","affectsGlobalScope":true},{"version":"38f0219c9e23c915ef9790ab1d680440d95419ad264816fa15009a8851e79119","affectsGlobalScope":true},{"version":"bb42a7797d996412ecdc5b2787720de477103a0b2e53058569069a0e2bae6c7e","affectsGlobalScope":true},{"version":"4738f2420687fd85629c9efb470793bb753709c2379e5f85bc1815d875ceadcd","affectsGlobalScope":true},{"version":"2f11ff796926e0832f9ae148008138ad583bd181899ab7dd768a2666700b1893","affectsGlobalScope":true},{"version":"4de680d5bb41c17f7f68e0419412ca23c98d5749dcaaea1896172f06435891fc","affectsGlobalScope":true},{"version":"9fc46429fbe091ac5ad2608c657201eb68b6f1b8341bd6d670047d32ed0a88fa","affectsGlobalScope":true},{"version":"61c37c1de663cf4171e1192466e52c7a382afa58da01b1dc75058f032ddf0839","affectsGlobalScope":true},{"version":"b541a838a13f9234aba650a825393ffc2292dc0fc87681a5d81ef0c96d281e7a","affectsGlobalScope":true},{"version":"9e9fbd7030c440b33d021da145d3232984c8bb7916f277e8ffd3dc2e3eae2bdb","affectsGlobalScope":true},{"version":"811ec78f7fefcabbda4bfa93b3eb67d9ae166ef95f9bff989d964061cbf81a0c","affectsGlobalScope":true},{"version":"717937616a17072082152a2ef351cb51f98802fb4b2fdabd32399843875974ca","affectsGlobalScope":true},{"version":"d7e7d9b7b50e5f22c915b525acc5a49a7a6584cf8f62d0569e557c5cfc4b2ac2","affectsGlobalScope":true},{"version":"71c37f4c9543f31dfced6c7840e068c5a5aacb7b89111a4364b1d5276b852557","affectsGlobalScope":true},{"version":"576711e016cf4f1804676043e6a0a5414252560eb57de9faceee34d79798c850","affectsGlobalScope":true},{"version":"89c1b1281ba7b8a96efc676b11b264de7a8374c5ea1e6617f11880a13fc56dc6","affectsGlobalScope":true},{"version":"74f7fa2d027d5b33eb0471c8e82a6c87216223181ec31247c357a3e8e2fddc5b","affectsGlobalScope":true},{"version":"ae37d6ccd1560b0203ab88d46987393adaaa78c919e51acf32fb82c86502e98c","affectsGlobalScope":true},{"version":"063600664504610fe3e99b717a1223f8b1900087fab0b4cad1496a114744f8df","affectsGlobalScope":true},{"version":"934019d7e3c81950f9a8426d093458b65d5aff2c7c1511233c0fd5b941e608ab","affectsGlobalScope":true},{"version":"bf14a426dbbf1022d11bd08d6b8e709a2e9d246f0c6c1032f3b2edb9a902adbe","affectsGlobalScope":true},{"version":"5e07ed3809d48205d5b985642a59f2eba47c402374a7cf8006b686f79efadcbd","affectsGlobalScope":true},{"version":"2b72d528b2e2fe3c57889ca7baef5e13a56c957b946906d03767c642f386bbc3","affectsGlobalScope":true},{"version":"479553e3779be7d4f68e9f40cdb82d038e5ef7592010100410723ceced22a0f7","affectsGlobalScope":true},{"version":"368af93f74c9c932edd84c58883e736c9e3d53cec1fe24c0b0ff451f529ceab1","affectsGlobalScope":true},{"version":"af3dd424cf267428f30ccfc376f47a2c0114546b55c44d8c0f1d57d841e28d74","affectsGlobalScope":true},{"version":"995c005ab91a498455ea8dfb63aa9f83fa2ea793c3d8aa344be4a1678d06d399","affectsGlobalScope":true},{"version":"d3d7b04b45033f57351c8434f60b6be1ea71a2dfec2d0a0c3c83badbb0e3e693","affectsGlobalScope":true},{"version":"956d27abdea9652e8368ce029bb1e0b9174e9678a273529f426df4b3d90abd60","affectsGlobalScope":true},{"version":"4fa6ed14e98aa80b91f61b9805c653ee82af3502dc21c9da5268d3857772ca05","affectsGlobalScope":true},{"version":"e6633e05da3ff36e6da2ec170d0d03ccf33de50ca4dc6f5aeecb572cedd162fb","affectsGlobalScope":true},{"version":"d8670852241d4c6e03f2b89d67497a4bbefe29ecaa5a444e2c11a9b05e6fccc6","affectsGlobalScope":true},{"version":"8444af78980e3b20b49324f4a16ba35024fef3ee069a0eb67616ea6ca821c47a","affectsGlobalScope":true},{"version":"caccc56c72713969e1cfe5c3d44e5bab151544d9d2b373d7dbe5a1e4166652be","affectsGlobalScope":true},{"version":"3287d9d085fbd618c3971944b65b4be57859f5415f495b33a6adc994edd2f004","affectsGlobalScope":true},{"version":"b4b67b1a91182421f5df999988c690f14d813b9850b40acd06ed44691f6727ad","affectsGlobalScope":true},{"version":"08a58483392df5fcc1db57d782e87734f77ae9eab42516028acbfe46f29a3ef7","affectsGlobalScope":true},{"version":"436aaf437562f276ec2ddbee2f2cdedac7664c1e4c1d2c36839ddd582eeb3d0a","affectsGlobalScope":true},{"version":"8e3c06ea092138bf9fa5e874a1fdbc9d54805d074bee1de31b99a11e2fec239d","affectsGlobalScope":true},{"version":"0b11f3ca66aa33124202c80b70cd203219c3d4460cfc165e0707aa9ec710fc53","affectsGlobalScope":true},{"version":"6a3f5a0129cc80cf439ab71164334d649b47059a4f5afca90282362407d0c87f","affectsGlobalScope":true},{"version":"811c71eee4aa0ac5f7adf713323a5c41b0cf6c4e17367a34fbce379e12bbf0a4","affectsGlobalScope":true},{"version":"15b98a533864d324e5f57cd3cfc0579b231df58c1c0f6063ea0fcb13c3c74ff9","affectsGlobalScope":true},{"version":"0a6282c8827e4b9a95f4bf4f5c205673ada31b982f50572d27103df8ceb8013c","affectsGlobalScope":true},{"version":"ac77cb3e8c6d3565793eb90a8373ee8033146315a3dbead3bde8db5eaf5e5ec6","affectsGlobalScope":true},{"version":"d4b1d2c51d058fc21ec2629fff7a76249dec2e36e12960ea056e3ef89174080f","affectsGlobalScope":true},{"version":"2fef54945a13095fdb9b84f705f2b5994597640c46afeb2ce78352fab4cb3279","affectsGlobalScope":true},{"version":"56e4ed5aab5f5920980066a9409bfaf53e6d21d3f8d020c17e4de584d29600ad","affectsGlobalScope":true},{"version":"33358442698bb565130f52ba79bfd3d4d484ac85fe33f3cb1759c54d18201393","affectsGlobalScope":true},{"version":"782dec38049b92d4e85c1585fbea5474a219c6984a35b004963b00beb1aab538","affectsGlobalScope":true},{"version":"64d4b35c5456adf258d2cf56c341e203a073253f229ef3208fc0d5020253b241","affectsGlobalScope":true},"ee7d8894904b465b072be0d2e4b45cf6b887cdba16a467645c4e200982ece7ea","f3d8c757e148ad968f0d98697987db363070abada5f503da3c06aefd9d4248c1","0c5a621a8cf10464c2020f05c99a86d8ac6875d9e17038cb8522cc2f604d539f","b360236d3b226a56126f9f071d68fccd10eba34e4b6831efc39e8a3277380523","a73bd08ca8f85d9c1f0307ae7abb246e38cb618f452e15fd3612464e846665b0","9b1b103c34f4c56ab0c40c87a85ffd36002295d8fbe17b493509e63a383f5814","e4a023723ff5cfdc22880b572dd15876d0bc4bb4f2a555d71d226a2578786ad3","3aa0ae0c3636319f9bc6e5c2a4bd484f9b2b4e78623b33131056a95fb59c954c","dc25e664429b44c379d4d3cf988b2cce06116ae94f5c6f1a0cf73245b4282a93","e59daf03ff2d76dee4726e48556aba1d105fd1c7a7a9cbf3e74ec4a1f91a6bea","250bb1ea2d799ecf488834fe20efa611063ab79b35639b7b3024f05e1b6641ee","a0fbfc839fefc3d41a12c5a8631e6543135ff18fd516cd06c5a09f84cb81578c","9ce376fdbe50ed84260f0dc45cc1f242916f2c0c91da6464df63df0ba2baae7c","c3e41c24eb14414b6995d4bbac99d16ce2e609282c9b53d1333b7b423e0f7d02","b555d22a622ea0565d08a340e5c19f6f439f40d4451a2f13fe6a33a39b3d761c","9f29212a64599c6c5563b78746bf85f709d5437f18dac77502a53af63dadb850","6b714d7db731bb6da813dfa3d88ded4ce0bc9b627464e86315468e1be9adadff","5ebd0c7b976b7cbe390e381d27ec9dc5adde1a02cf9ecfb2a7caed7a822a5cae","4171247c72f90ac86a3cd3cdb0f372214a556aa8b94aa92b28bf6d21dad5f7ee","b8b9aae5a37c0d3dec11813d992b893ed55a080289466ade6c1bc47e3987f53a","eb69d4cd5875c471c0dd30988bf8a4816f9b8fab1e71a8c39096e483411faa00","48225779dd7b1b7b384389e325ed6aa271a6745239d8193c2fc161cacbf3dac5","c6fd0f9d777f11f972b4decc52beeeae6aad9f2aa949184e8f9984a5c36e4448","3f4487628af3e52556d6f33151740876b29a5355b8a5ccf8e56d1b3ae7cbcc0e","2b4ca439136421892cc80ebf6f6ea641a0306e58bd12ed61ae7f20becb2ee15f","6296c7ce17d3115c72d6757513e79ea0f74b76f49e0138f78f37685fc1bc83f8","ce8fe0d07c32e6786203b5a3b93468afc6b1fcf57481dc9673e16fb119312c19","dfa94dabc1567d2b882222947f5c181adc89a3af5b6a2b730b1c3b85d4cfe48f","c33fa94c2e88d70a2e98a33474d3cf477d959477236323a748f638b3ca1e2af0","058e39e6fe02e97ddc18b2952a67d0dfb71f1f60f86405480fec569b602f5284","8c5dbef5fc0eb113d94132a5ba440d75e33eb85e9497a1f7e3bdb29a3fcd3469","0d9808e1f0d2bd4c45462c7e2f20c0cf08b700c6964e7eda5e10d1f6b707deb8","9f3f8ff5d06c5d5583e891d3bb98489d58e358e49bda2827f3f7819cdb632ad0","6978b8fc2f45108c4bc2788bd7053f2917d7efa28f74ddf52182dc9ab59d03cf","e127a8fb319d5978d73d966a5a68b85915848f8f96267fff2f0dbe9bc92373e9","77adbafe67e2bf42d578d82d2fb994530cce5b9eaa28a2a5b24aca70a008c3d9","3642221f795abb677078c1d4673adc4932ac93effa865bf7d85d2f418acb5b1b","7d2a0764991446f121b01e690edcb502ce40fd02145613d1d349d9e46be3782a","8e609bb71c20b858c77f0e9f90bb1319db8477b13f9f965f1a1e18524bf50881","8e609bb71c20b858c77f0e9f90bb1319db8477b13f9f965f1a1e18524bf50881","8e609bb71c20b858c77f0e9f90bb1319db8477b13f9f965f1a1e18524bf50881","8e609bb71c20b858c77f0e9f90bb1319db8477b13f9f965f1a1e18524bf50881","8e609bb71c20b858c77f0e9f90bb1319db8477b13f9f965f1a1e18524bf50881","513e4a7dd68f60782a39d5ae4ce6f0a19ccc4c51808b359560ad1f689f0ce93d","519157309e4f7c98b6067933db2a849961eaa0e5dec4a2ce5d2fc92ace85dcfd","c5f8672c8c39b8f9251a57fc2dab217ce20ac4a9d71c0a498b733cb922ff5e4e","82590ca2dfa968af29be579c534733406fd9c5c4a726213eef9f2308cbb04d23","e88043fb3ae0a6e33be31d45927494ed42c3263bfb318b024b9dab027f09dc2d","3f7e6d7b1d7155d68b5ec0f8e021f10075c785b29171d1d520d0b9b0dd617aa0","7571f6e856945cea6771a2985e008daff8785c6632f9dc1dc9f24f795f84444d","2ff5e66c8448d86302ef11ceeb27cbbd43d3af41aba05c2fc3a48cd0f1d8627f","a73d8151dd40ff705eebd2989e703ba14874574f5fe4f195babe74b6ef93ac59","1a910bff4e17d0f855bd00ef0dadc3ad8e7656499c099d19603f8bb0dbe8853e","23996dceac72973064c9643fff1ca0cf585b642d715c56ed3512703f2b280c5e","95a1a8e1e7777214b2d970c3426819e976abf9120f2824b571e0ae51d1dd465b","3b6aafb284a9943503546844726c7ecea9ae91fc46f1d8e8cbe233f6d8b16a30","e1bb914c06cc75205fae8713e349dff14bdfd2d36c784d0d2f2b7b5d37e035e0","a5e89e63c809c01f8e8175c9d63da68ce734ddf15b7efd98b1eb262d8e4d05ec","466c63574f0654a81f7d760ccb32570f642b6b46e83b6fdc288c2e52bcef287c","c6526b7ad3213f40e40d617f0a150c8a9dcf0e8f868594ef4aa060b994fd11ce","b5e0565b7ca3ba4c129ed4e1788d4dc1bb30dcdeb14a37df1071c3881507e295","08cdf95dfc59101c1e7c23865951151455ee7f77f1bf7e257034aae8ba332972","4924f889957ee69dfd66643c7e60a5feee526c18b16d10985804c669fe1b6ce4","2c95044092cad1398b593b47290306d73513d163c61e85ebbc39715af4b15578","66612e3b3315adf8702a39830ad8690d6f4293f89193737c604f4b44a51e42ad","1d3f6521348f5d591d4da3408457a553274b024c79ecde88054361040967c211","03a629914760ae9bb64a05e72ad0f4e6aeefb1e7c7b6ae3d7836bb46f69ae23e","95017b0f25bb3cd6782853c14303c20b5099b866ef1491c57fc436add8183f14","989f035cd0c3acf51639b2ff4fb3cb8ccce3d7ef0103a1d32ca5e5f1cfd19387","9dfbdb5529d2be1c9e77112f7e0e20fba7518865f31501b9aa09c3965ee91f6a","9ba02d6560cc8cf8063172ba05b5368a24fb236a97c1c852665372be78143592","cafadd60cda0c63471975430893f7c0ac981f268ec719f08f131e41d8404c4db","6a7a221f94f9547a86feaa3c2ce81b8556c71ffb12057a43c54fc975bca83cde","156d025e006f7df4df1bcf7ce53cd3e3780a0190dfb03c65288f07b372e79843","e34a316302189537858d6d20d5d77d8f0351ed977da8947a401ad9986cdf147f","243665975c1af5dc7b51b10f52e76d3cb8b7676ccc23a6503977526d94b3cdde","3a91334c3409e173cafb3af175d8a4a3ae835851df7015c8f0fc5c117ad46c80","bfe8f5184c00e9c24f8bb40ec929097b2cafc50cc968bc1604501cb6c4a1440c","98c7850cf7a5bca4267e71403e8a2788c29543b15ac7354d1211a7accba496c8","f31ab9295985d01c5837c9bdc422643f6f73293cfd103738774b7cfb340566cc","99392e1e600259c50f21f691f136a4ecbee42839dbb9523384f09645c8756503","5c5d100793c0fb9b34076189904df18f3321e82cadf6f69815926104029c215b","051191f8664727f9b9caa72166559b734e126d18ef377c3f4c3343672ea4d307","1079472c5e1f65ce739fb777054e2f539e9b50a97b438c0d6e56c4ee23be8bff","d0b3a40cbe16c8852d1327fb804995193fb853d7da9c7ab9c02cce85090e0637","c67208e9da4af7a50bfb75d07691326052d6ed8f3b577ece8b02cd425c9d632f","4f9a4bb30bc97017c72a600c0161962d8f74488d1cd93669e4adbce7e611e0de","8dec4b9028cc8905caa6b52a395786d7f49a10d61f6be869b59ae007dc5e0cdf","f952c9c19048db8b25e3fa8e48e2213c18d3fdbef6ac168e9fae6632ed58245f","5b8807a3d3cad7abc8f1c067dea5df20373446b89bb4f0aa73fee801deed46b8","866c1b69a53d80383cb5eef0ce2760ad8d028c771fa45776426a583c56a23746","8b433fd18d5bac931c1d7c07c17a830475e0fcb224d144cfeb3ba4d1da198687","e772bc828730ee913e19f58bb18b7733ebce8a3f06cdce847cb33275343a6ecd","466f4f5da14b6046570025129a7e5ea168164572c9b2da45bdc7274e0e303dbd","00222577eecd6c1fc72150006351fc6e1b5bb3aaf78097e40ecac8b8343a7598","39e2d8b839ebf811234d4a2e54998229aa1353e19e1199be87b6fa530136aee5","3b1765aafca023ad58d5aa017800e1f2e7ee95130c9a1e7d86d5019f45c756bc","e675dc45ca604b7a6fea16448050b34cf0fe86c2f9fa50f3911fb4153b42c186","d3e56e0f84e1d1843369533f50918cce5925129e99e9ca14c7cc35ad94b2a052","dfedb6704555de21c30e98a8decf8a6d31dde1d8403b9b95944a1d317379c7ae","7102463bc898ac4cfd90675e679cdd8e1a1b6f44702b280f9c99b93f206ae570","098a096f7f67356b98031a7c45cf7e0d49733cee8ef9b7230f881fcf5fe75a2f","57e73f1c6da39bcf9429f52c39b6fc34eef11547fbb5a2be91836517ec746957","8e4e3a2b6abfb27e146543a86b61deb0b088a62db1ddf32151d115ccdf30c3a2","bde8c75c442f701f7c428265ecad3da98023b6152db9ca49552304fd19fdba38","81af40a2264a5a56f71b8c45ff1717b50c5f0c00dd091410b12dc970ee340120","b10974251ad16a97b357ec50f87455c4430e7f0790f7b399564c900e4ebf87f1","234123959236555e336e4efcd7aa203ac1d5370ee5d891dcfc5828d996b28f59","b59756cf12284e6136e042f322af2e22664e1fd46f713b1dd3abb1740719b732","62b65c635a282ea4855cd6a9b968527cbab364c38410ea432f63c5c591db9072","a382df4ff5c36b5a1f042f310ee52dc547da679b92066ececaa0f00bf76e35e4","8771cebcc7bab42179738c744b09d2ba6d5f3a1238fc8a981cf21a8842c38f51","cbe5a7a02fb93f47d7948fb8dea8792f962b51657b63532ba3c67036d3c0a618","6131967512c4d205c32f126ef7415453f0c715bf53c7175d6deecb72d76a75b5","4e38f7bd172e7549c323610cfede12644c116581dfc4d751998d301eda9573e6","0d1adbde28307411dae5e1cc8cc316130653bfc6ad8feb4b59063f60efdfd693","d8288a8eb14187b0df133ce467216d61d9ffe838ae5930471f476a5c36141828","70ae92a852a67db5b841a7ee3e9d16df7c06320ab86dbf2d5dbd9d76f3c98faa","e58a0a0add3feea2c936af4933dae5710f6c41e91468e22d880054afaa47b782","ead85b2d6cd6e6deb144a0995896c0ca7423820c66cc00e416e66733d2932985","5893d8b87ce06846556d2460e2eaf2aa8388f2179ed151d302ab7d711a75c7e4","6b4d9c91ed03e7afd40fa045042fcb7a6250b8dbe242154f3c4b948a99c74a9d","8b37c18f85644a1c666705bb5c233850cac84d8863c19870a8ed5f8d69c68800","186139eb9963554412f6fb33b35aabee1acdaa644b365de5c38fbd9123bdbe45","429e18739687877b761b4b6574a45a9e51111a6a71cd63711440cb0f9c602e87","b7589677bd27b038f8aae8afeb030e554f1d5ff29dc4f45854e2cb7e5095d59a","220bc2f85b04326fd70de47faaa003666bc864e55f00543fdffa7b7f75d4dcdd","4a554afd8a11ad65a0f8878ebeddf6793c6775b1edbb14360bd47252840e051c","431fa08179e6ec652924f1f0788e213db388b0dbebdbfd392477772c5f199573","d0178d8099f50a868a3c6a8f82d7dc98b121c552d865e11a83e1d0d4374109cf","9e51bdbcfcbbe857bea0999bafc786cf85a07ace21f8493112f962cd76e32618","852bee3ca49f48477ef77e392aa31a260b82cabc1bbf42da56800b6e10a5c341","e4aa4e8d3eb4c67b64962344ef3388a8cd607821ba619c9379b36316db65c9ac","4dbfa68f729bd8e052c9a8916a1e828007ed3c9f50b24e7eb65e6556ea7fe315","635ca94290fa45a56e53ffadd3b897a42650fd4ab0ddc241392e4dc729bf496b","75a5c390f494828bb3dfd3e31ef3a8cc573184f4176166b6d3c1d67f69539b9c","02519cdd247317de0bfdc78d88b5497d9747e1b9d1297283a0fea8ab3787f6ab","53989e09bc0b6b46a3c4597e5147a9b989f1f66f33ce7375b92d28139977e748","abae244b376437bfe2f0fdd1bd8925e2c235d10336ba08aec4330b800582ccbb","7da12c50edd45d08ae7f93183d0f88ab9753386ce060d1765926ffbe7c6491c2","1a8397f1c9125fc54db823eb6509221b841dd6f0c82a78997033a4a09fb1c86d","176d3525152384c3f7312b308c8af7b17690f8ec34e0788e6aaae548180f1941","6b34e6bdec80f7af4912497afb8455cd88ae1d6442d042c6663176b9927b69d4","41113f7f4529f81a16bae03c06bbd3c95146a4f7c8173ecafd6869fd1e97ed0b","c980191d2838b122a340074b58c566fddbc29a44bb57170671ac5034373c49a1","378871d06cbd514fe945b69a7be3cabe210139a5b2b3917a306ef8102afdd5bd","3bf0df1a6a59b16d43f97efd5bddcb376a3a3d66ecbe92a4dd80a0f81be6a009","49bf06ea475ae5c78e69f7af3c7e09e00af57750aa1e37c120aaad92fd8a8ab2","f8fc87c8c6822986fa509a62a0caed5cbf05f3f84d82fbbdb01a9e94aebfb2ec","60c51e31434ccc777c3d67ccc96892dd7e634816fb9fa5dc86e15d72de96ab3d","0737161a05160e848162b2abba07c4e867f415362187b810f4b6764d2626d021","69815e9eb00baef2634457bcf4952f69062d764211914619c6922dfa7760f8d2","444399b4f2fead080a55b82f86bf653a072a9f117042edc9a0fa69366672b418","d6ab7f2b45d4aa62ad21199fbb3105151a9dd4830d138a3bb3eab1e76eef9e45","56827baba9ab2b370c919b1858068e11f10a73d80dca8cb2467d2d1446fab073","551cbc9796c3629084a987a84a1a0e9957fcfb6fdfe1ee807dfe56f5a11a4148","eded5d62b954b7937089cfb84926bb40d60b8bf0d4ef03bbe92cf08404afc808","84a805c22a49922085dc337ca71ac0b85aad6d4dba6b01cee5bd5776ff54df39","971f12a5fc236419ced0b7b9f23a53c1758233713f565635bbf4b85e2b23f55a","9d670bb3be18ea59cea824e3bb07d576b55c9542f5bc24aacc2a3c1ebd889de6","695b586df2d8c78b78cdd7cc6943594f3f4bc52948f13b31cdedfa3ce8d97c31","0771a93ef5e3b2a29f929c20f7ad232829341a671c9d1e96e93ef3fc42ef7bc2","cadb68b67b80b14a9a5bb64cce3093168fb2bfe2c7b10096d230df5203218de1","0b3c75be13f930b46117e205d900ee9c4f2ad6c7317655bca5364958ba1e34f0","5af161220fdf46730477706e8c431ccbd1b4ff50223cb32450bc20513f50bfbd","be797449825edee1716d3e0c8d7ae53955b8944437cb4d0b4123a32778621228","7167f98cada53080c300815de1e24f5eda5e9511caf5dfba8d1e3aaf6fe6d49e","83a3a4f21e36ee920e819ac865badd30bf258361e7a224d1fb134a5524f55a0f","a09c9ad7765dde81c65319b317af29e10f0a8e38f197c2e657ed7130d67c73dd","db18c2ffebf4c7f8d5ebb8f2541bc30bbb4f6cacebb42a5a9742ae883fd583e1","a22722f2344d703cdcc5ada42cbf84890ef527a2a6e9154fab5ddb362e64b955","866041185b44ade1456dc03de3dc85aad9c2b02dfd92d7f2068d46e28ea66201","13d94ac3ee5780f99988ae4cce0efd139598ca159553bc0100811eba74fc2351","48864a43f6c1032cb3fb5bfac020d4b2919791f49d8f31ff18f2dd3d4816005f","e9114172414f9836d9fab7346122951be30b66719d8277aa5f7a25580b9e21c7","5db896a650fb0c4ec892de19b7b98b92ccae9bb5a3e03731050f3db0d3183bd6","220c93cd694e27d77b91f874f31e92d7514aa808fd95768b64552693043d00b9","380543b1b41b88e3a6294b8419d5ed323c5da3a3051ab4a1d5677f525ee30698","269ee735294e8c328681830ae7fdf4aea6c24032f0541d76c914aac9afadda5c","23a790e87430f6bcf8dfbc4d3560e8b3d7441f9cfbe509bcf932b4608c60c9e3","7a8b858660503a4af876541f456b2cbc3d89b164ab842c7434ac0fb87ec0e026","024653e8296d821c2332e1e8fe13eb86f4d50f0be82478c958890e92d1f2ca0e","f571e28d70c04d1ce72673771010febae11d2c907a71d027550d986ee424951d","ae4f0f443b828f28aaf843856dd25a8ab5e400f99581778f8977011c4a72d70d","cf5ba84fd9488f0ba7e302d54d1db6452b513d8573df389dd05f4153f5edfc26","64ec4840e09c2f03bc97e86f6fbc5aac99bb6a067f20e06dc186a3784aba2862","640331bbaecab0948b9a40fc903666f103e94764cdfb0822d4124c147246c19a","dc29fe834b87d0d015c40a9f294ec7e1f2b7b322f102264e34374c8ea5ecffe6","46ab6033b2f210e498f5147c87b465aa564d1b9f64a431dd70b3f4f7cc5d6647","8eb142d9d0e29220c562296bdbed6b2c228df84589ce5d0c74ed7c333c1ba6cd","38738b94918d3119aa7006a143ec3f1552726348c80ee9b2de3606b9d78be223","ac5c6aefe784ae554ccef97ab165378535dc055402198667b75a4909387e7e8a","530ad38028745590e3792e0570b96d063a5039dff59119d4b686673094d2e9e7","fcf764882c18b958c2a487ad1093d6c9630df63f1e90995b157fe052e9fcc632","92ebc3261b20037c4e078cd3d26bccedb719b3eec653925e103b6ced4a936c0d","857864124c3a81507e55dcd7ed8cfa3f0c0f14dcee7acf94ed598cb25526d278","0fa6d3bf24b1d056c43e7c1c8f27819b6bad234c647a78e6ce70f8ff5615c70d","55e5a83c57e75329952d4138a50cf1564ac2dfd0669c2e01fa9f50ee68196ced","50b410acd8c96105e69d93826137269413e120758411ba1dbb992b901e6a2e55","0d4e5400743b35d420d83f1a33add04e1be352d45c98f2777708ca40cbb525e6","a49a99c6fc351fa5491d7b7efa0dc5666f1400b57f2063ed8f362a93f2f98797","e4f5face52c9781d20d2127cf405288a8007cf2e15e87574f677916e534e706a","892bf5856b242f0769a7a87c05ca17a7f2075450cbaa0ab589b8944b03804a93","34bc4ae02c19ebf98cefa8f4505bcb87413a60fd2544d7d4e6193acbc4108dda","5eee4649c790eaab36ab3e1aa60c807ce0e8aaf9a025c90fb40e60b5f5684e6c","30d6dc9b525dd82df213f2ce4a2aa0b2935b3ae5366ea164f96e6c08f0968ac2","ebe7db5bd9df714d7dddaf077a0a5ab6cf33740c1e39ca0274beeb96bc86828c","4a091e7847acab6fe0536b507db54b71270d22fe98513728658e446b08941c8e","c467f362b3da83f87dff5bae2f330f17c8086eba5f8eb5240b12b049a7f77db5","ad42060f3e0f92a294748f19d9490a8a6a980fb40dda0fd4627991d1361862cc","ecbfb361d752394a3728d319a93d0a208c5a00960ec1e5763d23b5944a00e35d","60a6e14c616a9977e7e0e196977721232e6977952d0324be4fb932a07d1679e1","bd76bdc3263ffb0ca3353fb6a525e8d14323768e48b91927f9ba87183d20fff1","2d94e74a3f71bbafeab55ec22b10151b89ae85587bc65f00b83344899ee52e2c","711789984a100da43d3e498c17ae14d9702f03fa0fc32cb07bd789a405bf4ab6","281d01063c2dd246078dd4079bd7827d2680e74cfc19490d3705675022336683","1a9cdf3bfd9f257233439cb40238352fe1c6128005290ecabf5c09633d58e1bd","f92d1a32779136c5707ea3a9bfcaa66c719598b7221da13d7b4843d60b7cb1ce","abc44e24a9e4d448c16be0592efe21c226348f2cabc4a29baaca1a9d20603e48","6d6a44413b5561347e604b9136c09074efd84fac96f105b9e1b65ce2e1c4a105","0471d30e55be2eca003ccde4240963c61ed191ef664704aa9d714f66518004ae","d1a685ef40d9553092a6da3f019344e9555808f8c79cd837a2b1479a89aff86e","78febe79c300eb4e36b21a5f92c64b55659f9b1b4fdac3cccb9481b28e2572a2","9a0dbf7e661a3dc3d1842bd0fa64e001037e9086b5c6c3d46c34400afb9c8689","b8dffdc3b519083310f3405512c60e673170dd0cef15407f65f9e82790091b1a","0cf8620ca1bb4e8b07545a3ae165f49db3daf0fd184e435e0eb1aa16ba512174","3c72d7ec3a861bfbc632454bf0bfc514aa965ed26ec1f9450108258a3b6430a7","024e0a74ebd335b4c675747eee99453b53813d5ff3ad6cbaa81942a4f4ed57da","1eee1bcd570bda3524753ec72a47e4b1597d5fc362a6a83ec4bdc3195320f281","3416ba78c03a35b340a9f76647353292a656110f5327c2145fec97ff71f61ba6","0e0be8210df9c573b64f81f18a1c284c83d72b472abdfc840cf40cc0a1db3465","5199370d76f8fcb993ce69295f10a287d633de43a64a78fd5d2a367a31c4b258","aae56a4211c19ab565a4377a606ed2ff444264399560aa9f52b308e650880ecb","5b717f6f0f351120cdf828e55537e3e61ea96f82a1a160faa5b9ae39a75c6f68","083ae29c6fb50d676b29fd5965144fa7950ac4e3ee4fdf57c587bb3194013ae8","7c6b13ae7496db0387dea584ed361ed5ad7f9ee3426da3305a1526c4eedf8c5e","6f2c76b59c81a19f72c57ec4b9e2830a10c4b9534ff6e9cd418ddcd38b6fdc0c","16bb3683a72c89bbc51886628bbd22522148d2aa3615422eba481bcade151df7","55fa234a04eacdf253e0b46d72f6e3bd8a044339c43547a29cf3b9f29ccd050d","b181ff38cfb4c79fb7aa7ef163c06e84fe5b0c3b7a286848a0eaa5b2ec38c706","a8c65d6931f57824f95012e902b3c4aaed39aa655183d13a7f7487dcb1bcbf00","9a5cece9b6895a117590afa088b6b91db167e25b00e5de1cb5885898fad0a270","0d2b5656e6ee0ccde2ff5025a6230130598609e6ee351ffdfa9a468459c69fa6","f7a240307887227c5dafbea0de4e10ec4726f75b95704965853c7101fcd7e741","d2312207819e8646ffd59367976ee611f0865c5b1d1518269a005f58eaf1ccf2","0e002469c8f37a8eb2cb874bdbddd2099f0fd0b2f8cd8eec879740d1c1fae256","20173928a097871e7ce47443e237a9b34c38f80d62e025d831699ea7671458a0","c3639c4aeae045ed963d564f77672b64304ad903bd106c5f2e679c0a9ce276db","ae826fd8f6c1c292b6134b449344f2d2ef7af2386b067293396e6f10435d256c","5614f93461a8346a573402b6d8654d7208b6b250b57a076a607c71bb0ab4d13e",{"version":"841d7b5a086d152df7d7343e0c89beda8baf3c89f35797d91619bda9e2c44959","signature":"42aed41188d1b01c644a520a6863c7dd2c7557e853b71ea56506755da1c4970c"},{"version":"9e9149f1d84802e66a884b6fa1b60879433cd5acda253d64237211fd1e46cfce","signature":"4c3fa51ee748283e0b5d3f6c5e51d9884db0619f8d5ac0cee5669c72f1bd2249"},{"version":"f19e129e633db41f714bda92a5bcdf9ae728ed9a3093e9838e6c852700e07e28","signature":"47ad46f52ee10a34df7dc31f5634d9c95b729b816140cb6b7a784f9b99e1a0b6"},"cf3d384d082b933d987c4e2fe7bfb8710adfd9dc8155190056ed6695a25a559e","9871b7ee672bc16c78833bdab3052615834b08375cb144e4d2cba74473f4a589","c863198dae89420f3c552b5a03da6ed6d0acfa3807a64772b895db624b0de707","8b03a5e327d7db67112ebbc93b4f744133eda2c1743dbb0a990c61a8007823ef","86c73f2ee1752bac8eeeece234fd05dfcf0637a4fbd8032e4f5f43102faa8eec","42fad1f540271e35ca37cecda12c4ce2eef27f0f5cf0f8dd761d723c744d3159","ff3743a5de32bee10906aff63d1de726f6a7fd6ee2da4b8229054dfa69de2c34","83acd370f7f84f203e71ebba33ba61b7f1291ca027d7f9a662c6307d74e4ac22","1445cec898f90bdd18b2949b9590b3c012f5b7e1804e6e329fb0fe053946d5ec","0e5318ec2275d8da858b541920d9306650ae6ac8012f0e872fe66eb50321a669","cf530297c3fb3a92ec9591dd4fa229d58b5981e45fe6702a0bd2bea53a5e59be","c1f6f7d08d42148ddfe164d36d7aba91f467dbcb3caa715966ff95f55048b3a4","f4e9bf9103191ef3b3612d3ec0044ca4044ca5be27711fe648ada06fad4bcc85","0c1ee27b8f6a00097c2d6d91a21ee4d096ab52c1e28350f6362542b55380059a","7677d5b0db9e020d3017720f853ba18f415219fb3a9597343b1b1012cfd699f7","bc1c6bc119c1784b1a2be6d9c47addec0d83ef0d52c8fbe1f14a51b4dfffc675","52cf2ce99c2a23de70225e252e9822a22b4e0adb82643ab0b710858810e00bf1","770625067bb27a20b9826255a8d47b6b5b0a2d3dfcbd21f89904c731f671ba77","d1ed6765f4d7906a05968fb5cd6d1db8afa14dbe512a4884e8ea5c0f5e142c80","799c0f1b07c092626cf1efd71d459997635911bb5f7fc1196efe449bba87e965","2a184e4462b9914a30b1b5c41cf80c6d3428f17b20d3afb711fff3f0644001fd","9eabde32a3aa5d80de34af2c2206cdc3ee094c6504a8d0c2d6d20c7c179503cc","397c8051b6cfcb48aa22656f0faca2553c5f56187262135162ee79d2b2f6c966","a8ead142e0c87dcd5dc130eba1f8eeed506b08952d905c47621dc2f583b1bff9","a02f10ea5f73130efca046429254a4e3c06b5475baecc8f7b99a0014731be8b3","c2576a4083232b0e2d9bd06875dd43d371dee2e090325a9eac0133fd5650c1cb","4c9a0564bb317349de6a24eb4efea8bb79898fa72ad63a1809165f5bd42970dd","f40ac11d8859092d20f953aae14ba967282c3bb056431a37fced1866ec7a2681","cc11e9e79d4746cc59e0e17473a59d6f104692fd0eeea1bdb2e206eabed83b03","b444a410d34fb5e98aa5ee2b381362044f4884652e8bc8a11c8fe14bbd85518e","c35808c1f5e16d2c571aa65067e3cb95afeff843b259ecfa2fc107a9519b5392","14d5dc055143e941c8743c6a21fa459f961cbc3deedf1bfe47b11587ca4b3ef5","a3ad4e1fc542751005267d50a6298e6765928c0c3a8dce1572f2ba6ca518661c","f237e7c97a3a89f4591afd49ecb3bd8d14f51a1c4adc8fcae3430febedff5eb6","3ffdfbec93b7aed71082af62b8c3e0cc71261cc68d796665faa1e91604fbae8f","662201f943ed45b1ad600d03a90dffe20841e725203ced8b708c91fcd7f9379a","c9ef74c64ed051ea5b958621e7fb853fe3b56e8787c1587aefc6ea988b3c7e79","2462ccfac5f3375794b861abaa81da380f1bbd9401de59ffa43119a0b644253d","34baf65cfee92f110d6653322e2120c2d368ee64b3c7981dff08ed105c4f19b0","7d8ddf0f021c53099e34ee831a06c394d50371816caa98684812f089b4c6b3d4",{"version":"fa6189dc847e90c971c9548be2ed7b32389b0eeb129edfe0c25fdc93c566ac2a","signature":"719d65997519f2fd2eea7b268baeb311831112b244f2d86a8ac9742f04263795"},{"version":"277c00b30562c300176bb053dc1fdcee9ac3ae59deecf98af248f9ab4149696a","signature":"e48e303e26e0bc9e0d7a7d8c38246a1c623c703245bf2d8f2d6b72941921e270"},{"version":"ae82ceff809f16f62a14b54dc547daffb22abc0e0b090e3f88186488e2b31a72","signature":"15249481a994cd78e290a923fcca909b7b5a75877b5b9353cf1845ba4dae9c86"},{"version":"863cb5638970b4eee5029f8d97d5309a304cf8f53584f1ca18cad1062ce5e17f","signature":"55b55a2ef7a1de73d8c18f90d7ab8b2d473083e9c303ff7e0cd6cd118021ca15"},{"version":"8d0fd256f05720cd8eb02927523ae032da6cb6fefa1f66a42098b8ff069eee09","signature":"b392ed5946bf4843ffcc0be5822fc32a1aa1552b48017eef35badd2b55ce1a4f"},{"version":"cd4d3a428e962eaf8c7b76cfa9d844622d7dddb09c60168b79d83bafaec2a94a","signature":"cb2d6f4374a68d53445e2a471a1d85c88fc8f3bfe295b571a0e34e12c9ec4772"},{"version":"cf60154fa1c4720a82cd2a8856c2c821e3a83e2026d26a46f806c5f6ea3fd94e","signature":"d1b5c98f1a3530ea8ff760d0a322ece85529e7bb274a4569090e76c9ab9d3ca6"},{"version":"bfac1dc6936bf670596dbf881f8bf4f97e18058a7823829afc7e0db6af6cbf44","signature":"0c8d17485cdffdc3f3038daef9082d0642d708282a34924ce0de4f472c0175dc"},{"version":"d20265e2d34833d5ae1a914b6c0244e15d6040883b115c0bf278c4accdc9b854","signature":"ba68fe7b0eaccfc8d92474bd1b5fa169930252520e17db91109e86f92f873b23"},{"version":"be5337338fe7887c758327adda80264f6b0ed100c62bfd6b7b61c20aba0044b3","signature":"a3d838be6c76ff238cc1e9e2a5e408475aa92ceb8855992b91f6891c1b657b5c"},{"version":"c67e5774c9283852e80bfcb3b299533c0072ede5c2fe0e623cc70adb877d19f1","signature":"a7f5d7bc973b48d9620a6829c48a307e58baf274d7c30b85625eadf8e63a9089"},{"version":"838c44ea85eadc8c04c6d96503098f528ca299742b6437713ddef2bb87ccf1bb","signature":"7b3b0c1abda4c77abc90448a21bcf0c6ec9137aeaa3a4c059c1d87995ce76987"},{"version":"cd78139c95fe8e8a52cdad08a10c4e1b9c87c5c29366cff3743c91ae1c3b5260","signature":"364ecd330350d7765d162e1e888465fe2cd748c27ef9a8e3276d75f86c002b61"},{"version":"7c78732ad9660634c786321db7aa42d6fb2318083112c180917e081596a79b32","signature":"4988f0e7dbae146ac44b99029857652f01bd7d92926edfb0ad2c15a09bff64a3"},{"version":"fd01df8f881f1de90c489acfcb1000aac5e7dd8b6a809359bec1591ba86bdd4e","signature":"8e609bb71c20b858c77f0e9f90bb1319db8477b13f9f965f1a1e18524bf50881"},{"version":"f0b6690984c3a44b15740ac24bfb63853617731c0f40c87a956ce537c4b50969","affectsGlobalScope":true},"f0cb4b3ab88193e3e51e9e2622e4c375955003f1f81239d72c5b7a95415dad3e","3cf5f191d75bbe7c92f921e5ae12004ac672266e2be2ece69f40b1d6b1b678f9","e050a0afcdbb269720a900c85076d18e0c1ab73e580202a2bf6964978181222a","1d78c35b7e8ce86a188e3e5528cc5d1edfc85187a85177458d26e17c8b48105f","acdc9fb9638a235a69bd270003d8db4d6153ada2b7ccbea741ade36b295e431e","7394959e5a741b185456e1ef5d64599c36c60a323207450991e7a42e08911419","818f832a8e29ca7e128dcde810a9ff8cbc3754010474e29fff0a5ed95adae032","5929864ce17fba74232584d90cb721a89b7ad277220627cc97054ba15a98ea8f","7180c03fd3cb6e22f911ce9ba0f8a7008b1a6ddbe88ccf16a9c8140ef9ac1686","25c8056edf4314820382a5fdb4bb7816999acdcb929c8f75e3f39473b87e85bc","54cb85a47d760da1c13c00add10d26b5118280d44d58e6908d8e89abbd9d7725","3e4825171442666d31c845aeb47fcd34b62e14041bb353ae2b874285d78482aa","c6fd2c5a395f2432786c9cb8deb870b9b0e8ff7e22c029954fabdd692bff6195","a967bfe3ad4e62243eb604bf956101e4c740f5921277c60debaf325c1320bf88","e9775e97ac4877aebf963a0289c81abe76d1ec9a2a7778dbe637e5151f25c5f3","471e1da5a78350bc55ef8cef24eb3aca6174143c281b8b214ca2beda51f5e04a","cadc8aced301244057c4e7e73fbcae534b0f5b12a37b150d80e5a45aa4bebcbd","385aab901643aa54e1c36f5ef3107913b10d1b5bb8cbcd933d4263b80a0d7f20","9670d44354bab9d9982eca21945686b5c24a3f893db73c0dae0fd74217a4c219","db3435f3525cd785bf21ec6769bf8da7e8a776be1a99e2e7efb5f244a2ef5fee","c3b170c45fc031db31f782e612adf7314b167e60439d304b49e704010e7bafe5","40383ebef22b943d503c6ce2cb2e060282936b952a01bea5f9f493d5fb487cc7","4893a895ea92c85345017a04ed427cbd6a1710453338df26881a6019432febdd","3a84b7cb891141824bd00ef8a50b6a44596aded4075da937f180c90e362fe5f6","13f6f39e12b1518c6650bbb220c8985999020fe0f21d818e28f512b7771d00f9","9b5369969f6e7175740bf51223112ff209f94ba43ecd3bb09eefff9fd675624a","4fe9e626e7164748e8769bbf74b538e09607f07ed17c2f20af8d680ee49fc1da","24515859bc0b836719105bb6cc3d68255042a9f02a6022b3187948b204946bd2","33203609eba548914dc83ddf6cadbc0bcb6e8ef89f6d648ca0908ae887f9fcc5","0db18c6e78ea846316c012478888f33c11ffadab9efd1cc8bcc12daded7a60b6","89167d696a849fce5ca508032aabfe901c0868f833a8625d5a9c6e861ef935d2","e53a3c2a9f624d90f24bf4588aacd223e7bec1b9d0d479b68d2f4a9e6011147f","339dc5265ee5ed92e536a93a04c4ebbc2128f45eeec6ed29f379e0085283542c","9f0a92164925aa37d4a5d9dd3e0134cff8177208dba55fd2310cd74beea40ee2","8bfdb79bf1a9d435ec48d9372dc93291161f152c0865b81fc0b2694aedb4578d","2e85db9e6fd73cfa3d7f28e0ab6b55417ea18931423bd47b409a96e4a169e8e6","c46e079fe54c76f95c67fb89081b3e399da2c7d109e7dca8e4b58d83e332e605","d32275be3546f252e3ad33976caf8c5e842c09cb87d468cb40d5f4cf092d1acc","4a0c3504813a3289f7fb1115db13967c8e004aa8e4f8a9021b95285502221bd1",{"version":"a14ed46fa3f5ffc7a8336b497cd07b45c2084213aaca933a22443fcb2eef0d07","affectsGlobalScope":true},"cce1f5f86974c1e916ec4a8cab6eec9aa8e31e8148845bf07fbaa8e1d97b1a2c",{"version":"7fd7fcbf021a5845bdd9397d4649fcf2fe17152d2098140fc723099a215d19ad","affectsGlobalScope":true},"df3389f71a71a38bc931aaf1ef97a65fada98f0a27f19dd12f8b8de2b0f4e461","d69a3298a197fe5d59edba0ec23b4abf2c8e7b8c6718eac97833633cd664e4c9",{"version":"a9544f6f8af0d046565e8dde585502698ebc99eef28b715bad7c2bded62e4a32","affectsGlobalScope":true},"a40826e8476694e90da94aa008283a7de50d1dafd37beada623863f1901cb7fb",{"version":"8b809082dfeffc8cc4f3b9c59f55c0ff52ba12f5ae0766cb5c35deee83b8552e","affectsGlobalScope":true},"bd3f5d05b6b5e4bfcea7739a45f3ffb4a7f4a3442ba7baf93e0200799285b8f1","4c775c2fccabf49483c03cd5e3673f87c1ffb6079d98e7b81089c3def79e29c6","d4f9d3ae2fe1ae199e1c832cca2c44f45e0b305dfa2808afdd51249b6f4a5163","7525257b4aa35efc7a1bbc00f205a9a96c4e4ab791da90db41b77938c4e0c18e","b7fe70be794e13d1b7940e318b8770cd1fb3eced7707805318a2e3aaac2c3e9e",{"version":"ee1ee365d88c4c6c0c0a5a5701d66ebc27ccd0bcfcfaa482c6e2e7fe7b98edf7","affectsGlobalScope":true},{"version":"9c611eff81287837680c1f4496daf9e737d6f3a1ff17752207814b8f8e1265af","affectsGlobalScope":true},"fe1fd6afdfe77976d4c702f3746c05fb05a7e566845c890e0e970fe9376d6a90","b5d4e3e524f2eead4519c8e819eaf7fa44a27c22418eff1b7b2d0ebc5fdc510d","afb1701fd4be413a8a5a88df6befdd4510c30a31372c07a4138facf61594c66d","9bd8e5984676cf28ebffcc65620b4ab5cb38ab2ec0aac0825df8568856895653","396a8939b5e177542bdf9b5262b4eee85d29851b2d57681fa9d7eae30e225830","5e8dc64e7e68b2b3ea52ed685cf85239e0d5fb9df31aabc94370c6bc7e19077b",{"version":"ea455cc68871b049bcecd9f56d4cf27b852d6dafd5e3b54468ca87cc11604e4d","affectsGlobalScope":true},"c07146dbbbd8b347241b5df250a51e48f2d7bef19b1e187b1a3f20c849988ff1","45b1053e691c5af9bfe85060a3e1542835f8d84a7e6e2e77ca305251eda0cb3c","0f05c06ff6196958d76b865ae17245b52d8fe01773626ac3c43214a2458ea7b7",{"version":"ae5507fc333d637dec9f37c6b3f4d423105421ea2820a64818de55db85214d66","affectsGlobalScope":true},{"version":"46755a4afc53df75f0bfce72259fb971daac826b0cdd8c4eaccad2755a817403","affectsGlobalScope":true},"8abd0566d2854c4bd1c5e48e05df5c74927187f1541e6770001d9637ac41542e","54e854615c4eafbdd3fd7688bd02a3aafd0ccf0e87c98f79d3e9109f047ce6b8","d8dba11dc34d50cb4202de5effa9a1b296d7a2f4a029eec871f894bddfb6430d","8b71dd18e7e63b6f991b511a201fad7c3bf8d1e0dd98acb5e3d844f335a73634","01d8e1419c84affad359cc240b2b551fb9812b450b4d3d456b64cda8102d4f60","9eece5e586312581ccd106d4853e861aaaa1a39f8e3ea672b8c3847eedd12f6e","8221b00f271cf7f535a8eeec03b0f80f0929c7a16116e2d2df089b41066de69b","269929a24b2816343a178008ac9ae9248304d92a8ba8e233055e0ed6dbe6ef71","93452d394fdd1dc551ec62f5042366f011a00d342d36d50793b3529bfc9bd633","7fa32887f8a97909fca35ebba3740f8caf8df146618d8fff957a3f89f67a2f6a","9a9634296cca836c3308923ba7aa094fa6ed76bb1e366d8ddcf5c65888ab1024",{"version":"bddce945d552a963c9733db106b17a25474eefcab7fc990157a2134ef55d4954","affectsGlobalScope":true},{"version":"7052b7b0c3829df3b4985bab2fd74531074b4835d5a7b263b75c82f0916ad62f","affectsGlobalScope":true},"aa34c3aa493d1c699601027c441b9664547c3024f9dbab1639df7701d63d18fa","4b55240c2a03b2c71e98a7fc528b16136faa762211c92e781a01c37821915ea6","7c651f8dce91a927ab62925e73f190763574c46098f2b11fb8ddc1b147a6709a","7440ab60f4cb031812940cc38166b8bb6fbf2540cfe599f87c41c08011f0c1df",{"version":"94c086dff8dbc5998749326bc69b520e8e4273fb5b7b58b50e0210e0885dfcde","affectsGlobalScope":true},{"version":"f5b5dc128973498b75f52b1b8c2d5f8629869104899733ae485100c2309b4c12","affectsGlobalScope":true},"ebe5facd12fd7745cda5f4bc3319f91fb29dc1f96e57e9c6f8b260a7cc5b67ee","79bad8541d5779c85e82a9fb119c1fe06af77a71cc40f869d62ad379473d4b75","21c56c6e8eeacef15f63f373a29fab6a2b36e4705be7a528aae8c51469e2737b",{"version":"629d20681ca284d9e38c0a019f647108f5fe02f9c59ac164d56f5694fc3faf4d","affectsGlobalScope":true},"e7dbf5716d76846c7522e910896c5747b6df1abd538fee8f5291bdc843461795",{"version":"ab9b9a36e5284fd8d3bf2f7d5fcbc60052f25f27e4d20954782099282c60d23e","affectsGlobalScope":true},"a42be67ed1ddaec743582f41fc219db96a1b69719fccac6d1464321178d610fc","8841e2aa774b89bd23302dede20663306dc1b9902431ac64b24be8b8d0e3f649","fd326577c62145816fe1acc306c734c2396487f76719d3785d4e825b34540b33","9e951ec338c4232d611552a1be7b4ecec79a8c2307a893ce39701316fe2374bd","70c61ff569aabdf2b36220da6c06caaa27e45cd7acac81a1966ab4ee2eadc4f2","905c3e8f7ddaa6c391b60c05b2f4c3931d7127ad717a080359db3df510b7bdab","6c1e688f95fcaf53b1e41c0fdadf2c1cfc96fa924eaf7f9fdb60f96deb0a4986","0d14fa22c41fdc7277e6f71473b20ebc07f40f00e38875142335d5b63cdfc9d2","c085e9aa62d1ae1375794c1fb927a445fa105fed891a7e24edbb1c3300f7384a","f315e1e65a1f80992f0509e84e4ae2df15ecd9ef73df975f7c98813b71e4c8da","5b9586e9b0b6322e5bfbd2c29bd3b8e21ab9d871f82346cb71020e3d84bae73e","3e70a7e67c2cb16f8cd49097360c0309fe9d1e3210ff9222e9dac1f8df9d4fb6","ab68d2a3e3e8767c3fba8f80de099a1cfc18c0de79e42cb02ae66e22dfe14a66","6d969939c4a63f70f2aa49e88da6f64b655c8e6799612807bef41ccff6ea0da9","5b9586e9b0b6322e5bfbd2c29bd3b8e21ab9d871f82346cb71020e3d84bae73e",{"version":"46894b2a21a60f8449ca6b2b7223b7179bba846a61b1434bed77b34b2902c306","affectsGlobalScope":true},"96d14f21b7652903852eef49379d04dbda28c16ed36468f8c9fa08f7c14c9538","6d727c1f6a7122c04e4f7c164c5e6f460c21ada618856894cdaa6ac25e95f38c","8baa5d0febc68db886c40bf341e5c90dc215a90cd64552e47e8184be6b7e3358","c6c4fea9acc55d5e38ff2b70d57ab0b5cdbd08f8bc5d7a226e322cea128c5b57","9ad8802fd8850d22277c08f5653e69e551a2e003a376ce0afb3fe28474b51d65","fdfbe321c556c39a2ecf791d537b999591d0849e971dd938d88f460fea0186f6","105b9a2234dcb06ae922f2cd8297201136d416503ff7d16c72bfc8791e9895c1"],"root":[[322,325],[366,381]],"options":{"allowImportingTsExtensions":true,"composite":true,"declaration":true,"declarationDir":"../../dts","declarationMap":true,"emitDeclarationOnly":true,"esModuleInterop":true,"module":200,"noImplicitAny":true,"noImplicitThis":true,"rootDir":"../..","skipLibCheck":true,"strictBindCallApply":true,"target":99},"fileIdsList":[[217,225,239],[177],[177,178,219,224,227,228,239],[177,227,239],[177,220,239],[220,221,222,223],[177,220],[244],[177,178,239,241],[217,218,226,239],[177,227,229,239,240,242,243,261],[177,228,239],[177,224,225,239],[178,240],[177,228],[210,217,227,228,229,238,241],[176,210,239,261],[151,176,210,224,244,247,248,249,250,254,256,257,258,260],[177,239,244,259],[177,210,244],[151,177,244,255,261],[177,244,255,261],[151,176,246],[151,177,238,244],[151,177,244,245,247],[151,247],[151,230,237],[213],[211,212,213,214,215,216],[181,191,203,209],[208],[179,182,183,184],[185,187,188,189,190,191,203,204,209],[192,194,203],[179,181,184,193,194,199,203,204,209],[187,201,203,209],[179,181,184,186,193,194,198,203,204],[179,193,203],[179,181,186,194,200,203,204,209],[179,181,184,185,187,197,203,204],[179,180,181,184,185,186,187,188,189,190,191,193,194,195,196,197,198,199,201,202,203,204,205,206,207,209],[179,186,187,203],[179,180,181,184,185,186,187,188,189,190,191,193,194,195,196,197,198,199,201,203,204,209],[179,180,181,184,185,191,194,195,196,203,209],[179,180,181,184,195,209],[180],[179,184,197,202,209],[179,186,197],[179,184,197,203],[179,186,197,203],[251,252],[151],[151,251,253],[210],[151,157,158,174],[151,157,174,176],[151,157],[151,154,155,157,158,174,175],[151,174],[151,154,159,174],[174],[151,159,174],[151,154,157,158,159,160,161,162,163,164,165,166,167,168,169,170,171,173,176],[151,152,174],[151,157,174],[151,156,158,174,176],[151,152,153,176],[151,154,176],[109],[109,110,111,112,113,114,115,116,117],[76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,118,119,120,121,122,123,124,125,126,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151],[118,151],[322,323],[322,445,470],[322],[151,322,366],[322,366],[322,367,368,369],[323,324,325,371],[322,323,365,370],[73,75,181,197,259,261,321],[374],[261],[244,261,322,366,374],[323,374,375,376,378],[374,379,470],[261,322,370,374,375,377],[481],[234,236],[235],[232,234],[231,232,233],[231,234],[73,75],[72,73,74],[435,436,473,474],[476],[477],[483,486],[422,473,479,485],[480,484],[482],[386],[422],[423,428,457],[424,435,436,443,454,465],[424,425,435,443],[426,466],[427,428,436,444],[428,454,462],[429,431,435,443],[422,430],[431,432],[435],[433,435],[422,435],[435,436,437,454,465],[435,436,437,450,454,457],[420,423,470],[431,435,438,443,454,465],[435,436,438,439,443,454,462,465],[438,440,454,462,465],[386,387,421,422,423,424,425,426,427,428,429,430,431,432,433,434,435,436,437,438,439,440,441,442,443,444,445,446,447,448,449,450,451,452,453,454,455,456,457,458,459,460,461,462,463,464,465,466,467,468,469,470,471,472],[435,441],[442,465,470],[431,435,443,454],[444],[445],[422,446],[447,464,470],[448],[449],[435,450,451],[450,452,466,468],[423,435,454,455,456,457],[423,454,456],[454,455],[457],[458],[422,454],[435,460,461],[460,461],[428,443,454,462],[463],[443,464],[423,438,449,465],[428,466],[454,467],[442,468],[469],[423,428,435,437,446,454,465,468,470],[454,471],[326,365],[326,350,365],[365],[326],[326,351,365],[326,327,328,329,330,331,332,333,334,335,336,337,338,339,340,341,342,343,344,345,346,347,348,349,350,351,352,353,354,355,356,357,358,359,360,361,362,363,364],[351,365],[494],[267,287,297,308,311],[267,309,319],[267,268,269],[270,271,272,273,274,275,276,277,278,279,280],[267,268],[268,270,271,272,273,274,275,276,277,278,279,280,281],[282,287,288,309,311,316,317,320],[267,315],[267,287,311],[267,288,309,311,317],[267,315,316],[267,314],[318],[267,289,294,307,309],[267,287,288,289,294,307,309],[267,287,289,294,307,309],[290,291,292,293,295,296,297,298,299,300,301,302,303,304,305,306,308,310],[267,282,287,288,289,290,291,292,293,307,309],[289,290,291,292,293,295,296,298,299,300,301,302,303,304,305,306,307,308,310],[267,283],[284,285,311],[283],[267,282,288,311],[284,285,286],[262],[263,264,265,266],[262,264],[263,266],[267],[312,313],[483],[397,401,465],[397,454,465],[392],[394,397,462,465],[443,462],[473],[392,473],[394,397,443,465],[389,390,393,396,423,435,454,465],[389,395],[393,397,423,457,465,473],[423,473],[413,423,473],[391,392,473],[397],[391,392,393,394,395,396,397,398,399,401,402,403,404,405,406,407,408,409,410,411,412,414,415,416,417,418,419],[397,404,405],[395,397,405,406],[396],[389,392,397],[397,401,405,406],[401],[395,397,400,465],[389,394,395,397,401,404],[423,454],[392,397,413,423,470,473],[212],[151,154],[151,172,174]],"referencedMap":[[226,1],[218,2],[225,3],[228,4],[222,5],[224,6],[221,7],[223,2],[220,8],[242,9],[227,10],[244,11],[229,12],[243,13],[241,14],[219,15],[239,16],[240,17],[261,18],[260,19],[259,20],[258,21],[257,22],[256,22],[247,23],[255,24],[246,25],[248,26],[238,27],[215,28],[216,28],[217,29],[214,28],[210,30],[209,31],[184,32],[192,33],[195,34],[200,35],[204,36],[199,37],[194,38],[201,39],[193,40],[208,41],[205,42],[206,43],[202,43],[207,42],[197,44],[185,45],[181,46],[203,47],[189,48],[188,49],[187,50],[253,51],[252,52],[254,53],[251,54],[175,55],[159,56],[158,57],[176,58],[160,59],[170,59],[166,60],[164,59],[163,61],[169,62],[174,63],[161,59],[165,59],[172,64],[152,52],[168,65],[167,61],[162,59],[156,65],[157,66],[154,67],[155,68],[78,52],[79,52],[81,52],[80,52],[83,52],[85,52],[77,52],[82,52],[87,52],[88,52],[89,52],[86,52],[90,52],[91,52],[92,52],[93,52],[94,52],[96,52],[95,52],[97,52],[98,52],[100,52],[102,52],[103,52],[104,52],[106,52],[107,52],[108,52],[110,69],[118,70],[109,52],[151,71],[119,52],[124,52],[120,52],[121,52],[122,52],[123,52],[125,52],[126,52],[127,52],[128,52],[147,52],[148,52],[130,52],[131,52],[132,52],[133,52],[134,52],[135,52],[136,52],[138,52],[139,52],[140,52],[141,52],[144,52],[145,52],[146,72],[324,73],[323,74],[325,75],[369,76],[368,52],[367,77],[370,78],[372,79],[373,79],[371,80],[322,81],[375,82],[374,83],[376,84],[379,85],[380,86],[378,87],[482,88],[237,89],[236,90],[233,91],[234,92],[232,93],[384,94],[75,95],[475,96],[477,97],[478,98],[488,99],[486,100],[485,101],[487,102],[386,103],[387,103],[422,104],[423,105],[424,106],[425,107],[426,108],[427,109],[428,110],[429,111],[430,112],[431,113],[432,113],[434,114],[433,115],[435,116],[436,117],[437,118],[421,119],[438,120],[439,121],[440,122],[473,123],[441,124],[442,125],[443,126],[444,127],[445,128],[446,129],[447,130],[448,131],[449,132],[450,133],[451,133],[452,134],[454,135],[456,136],[455,137],[457,138],[458,139],[459,140],[460,141],[461,142],[462,143],[463,144],[464,145],[465,146],[466,147],[467,148],[468,149],[469,150],[470,151],[471,152],[350,153],[351,154],[326,155],[329,155],[348,153],[349,153],[339,153],[338,156],[336,153],[331,153],[344,153],[342,153],[346,153],[330,153],[343,153],[347,153],[332,153],[333,153],[345,153],[327,153],[334,153],[335,153],[337,153],[341,153],[352,157],[340,153],[328,153],[365,158],[359,157],[361,159],[360,157],[353,157],[354,157],[356,157],[358,157],[362,159],[363,159],[355,159],[357,159],[495,160],[309,161],[320,162],[270,163],[271,163],[281,164],[269,165],[272,163],[273,163],[274,163],[275,163],[276,163],[277,163],[278,163],[279,163],[280,163],[282,166],[321,167],[316,168],[288,169],[318,170],[317,171],[315,172],[319,173],[310,174],[295,174],[308,174],[296,174],[297,174],[298,174],[299,174],[300,174],[290,175],[301,174],[291,176],[302,174],[292,174],[307,177],[294,178],[303,174],[304,174],[293,174],[305,174],[306,174],[311,179],[284,180],[286,181],[285,182],[283,183],[287,184],[263,185],[267,186],[265,187],[266,188],[312,189],[314,190],[484,191],[483,102],[404,192],[411,193],[403,192],[418,194],[395,195],[394,196],[417,197],[412,198],[415,199],[397,200],[396,201],[392,202],[391,203],[414,204],[393,205],[398,206],[402,206],[420,207],[419,206],[406,208],[407,209],[409,210],[405,211],[408,212],[413,197],[400,213],[401,214],[410,215],[390,216],[416,217],[213,218],[153,219],[171,59],[173,220]],"latestChangedDtsFile":"../../dts/eslint/babel-eslint-parser/src/worker/index.d.cts"},"version":"5.5.3"} \ No newline at end of file diff --git a/tools/eslint/node_modules/@babel/generator/LICENSE b/tools/eslint/node_modules/@babel/generator/LICENSE deleted file mode 100644 index f31575ec773bb1..00000000000000 --- a/tools/eslint/node_modules/@babel/generator/LICENSE +++ /dev/null @@ -1,22 +0,0 @@ -MIT License - -Copyright (c) 2014-present Sebastian McKenzie and other contributors - -Permission is hereby granted, free of charge, to any person obtaining -a copy of this software and associated documentation files (the -"Software"), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sublicense, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/tools/eslint/node_modules/@babel/generator/lib/buffer.js b/tools/eslint/node_modules/@babel/generator/lib/buffer.js deleted file mode 100644 index 23bedfa742d3e5..00000000000000 --- a/tools/eslint/node_modules/@babel/generator/lib/buffer.js +++ /dev/null @@ -1,317 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.default = void 0; -class Buffer { - constructor(map, indentChar) { - this._map = null; - this._buf = ""; - this._str = ""; - this._appendCount = 0; - this._last = 0; - this._queue = []; - this._queueCursor = 0; - this._canMarkIdName = true; - this._indentChar = ""; - this._fastIndentations = []; - this._position = { - line: 1, - column: 0 - }; - this._sourcePosition = { - identifierName: undefined, - identifierNamePos: undefined, - line: undefined, - column: undefined, - filename: undefined - }; - this._map = map; - this._indentChar = indentChar; - for (let i = 0; i < 64; i++) { - this._fastIndentations.push(indentChar.repeat(i)); - } - this._allocQueue(); - } - _allocQueue() { - const queue = this._queue; - for (let i = 0; i < 16; i++) { - queue.push({ - char: 0, - repeat: 1, - line: undefined, - column: undefined, - identifierName: undefined, - identifierNamePos: undefined, - filename: "" - }); - } - } - _pushQueue(char, repeat, line, column, filename) { - const cursor = this._queueCursor; - if (cursor === this._queue.length) { - this._allocQueue(); - } - const item = this._queue[cursor]; - item.char = char; - item.repeat = repeat; - item.line = line; - item.column = column; - 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 __mergedMap() { - return this.map; - }, - 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); - } - queue(char) { - 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.filename); - } - queueIndentation(repeat) { - if (repeat === 0) return; - this._pushQueue(-1, repeat, 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; - if (char === -1) { - const fastIndentation = this._fastIndentations[repeat]; - if (fastIndentation !== undefined) { - this._str += fastIndentation; - } else { - this._str += repeat > 1 ? this._indentChar.repeat(repeat) : this._indentChar; - } - } else { - this._str += repeat > 1 ? String.fromCharCode(char).repeat(repeat) : String.fromCharCode(char); - } - if (char !== 10) { - this._mark(sourcePos.line, sourcePos.column, sourcePos.identifierName, sourcePos.identifierNamePos, sourcePos.filename); - this._position.column += repeat; - } else { - this._position.line++; - this._position.column = 0; - } - if (this._canMarkIdName) { - sourcePos.identifierName = undefined; - sourcePos.identifierNamePos = undefined; - } - } - _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; - this._str = str; - this._appendCount = 0; - } else { - this._str += str; - } - if (!maybeNewline && !this._map) { - position.column += len; - return; - } - const { - column, - identifierName, - identifierNamePos, - filename - } = sourcePos; - let line = sourcePos.line; - if ((identifierName != null || identifierNamePos != null) && this._canMarkIdName) { - sourcePos.identifierName = undefined; - sourcePos.identifierNamePos = undefined; - } - let i = str.indexOf("\n"); - let last = 0; - if (i !== 0) { - this._mark(line, column, identifierName, identifierNamePos, filename); - } - while (i !== -1) { - position.line++; - position.column = 0; - last = i + 1; - if (last < len && line !== undefined) { - this._mark(++line, 0, null, null, filename); - } - i = str.indexOf("\n", last); - } - position.column += len - last; - } - _mark(line, column, identifierName, identifierNamePos, filename) { - var _this$_map; - (_this$_map = this._map) == null || _this$_map.mark(this._position, line, column, identifierName, identifierNamePos, 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; - } - getNewlineCount() { - const queueCursor = this._queueCursor; - let count = 0; - if (queueCursor === 0) return this._last === 10 ? 1 : 0; - for (let i = queueCursor - 1; i >= 0; i--) { - if (this._queue[i].char !== 10) { - break; - } - count++; - } - return count === queueCursor && this._last === 10 ? count + 1 : count; - } - endsWithCharAndNewline() { - const queue = this._queue; - const queueCursor = this._queueCursor; - if (queueCursor !== 0) { - const lastCp = queue[queueCursor - 1].char; - if (lastCp !== 10) return; - if (queueCursor > 1) { - return queue[queueCursor - 2].char; - } else { - return this._last; - } - } - } - hasContent() { - return this._queueCursor !== 0 || !!this._last; - } - exactSource(loc, cb) { - if (!this._map) { - cb(); - return; - } - this.source("start", loc); - const identifierName = loc.identifierName; - const sourcePos = this._sourcePosition; - if (identifierName) { - this._canMarkIdName = false; - sourcePos.identifierName = identifierName; - } - cb(); - if (identifierName) { - this._canMarkIdName = true; - sourcePos.identifierName = undefined; - sourcePos.identifierNamePos = undefined; - } - this.source("end", loc); - } - source(prop, loc) { - if (!this._map) return; - this._normalizePosition(prop, loc, 0); - } - sourceWithOffset(prop, loc, columnOffset) { - if (!this._map) return; - this._normalizePosition(prop, loc, columnOffset); - } - _normalizePosition(prop, loc, columnOffset) { - const pos = loc[prop]; - const target = this._sourcePosition; - if (pos) { - target.line = pos.line; - target.column = Math.max(pos.column + columnOffset, 0); - 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 diff --git a/tools/eslint/node_modules/@babel/generator/lib/generators/base.js b/tools/eslint/node_modules/@babel/generator/lib/generators/base.js deleted file mode 100644 index 60dfc68d99fc3c..00000000000000 --- a/tools/eslint/node_modules/@babel/generator/lib/generators/base.js +++ /dev/null @@ -1,94 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.BlockStatement = BlockStatement; -exports.Directive = Directive; -exports.DirectiveLiteral = DirectiveLiteral; -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.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); - 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); - } - } - const exit = this.enterForStatementInit(false); - this.printSequence(node.body, node, { - indent: true - }); - exit(); - this.rightBrace(node); -} -function Directive(node) { - this.print(node.value, node); - this.semicolon(); -} -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; - if (!unescapedDoubleQuoteRE.test(value)) { - this.token(`"${value}"`); - } else if (!unescapedSingleQuoteRE.test(value)) { - this.token(`'${value}'`); - } else { - 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(); - } -} - -//# sourceMappingURL=base.js.map diff --git a/tools/eslint/node_modules/@babel/generator/lib/generators/classes.js b/tools/eslint/node_modules/@babel/generator/lib/generators/classes.js deleted file mode 100644 index 2b33bd4ae62164..00000000000000 --- a/tools/eslint/node_modules/@babel/generator/lib/generators/classes.js +++ /dev/null @@ -1,179 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.ClassAccessorProperty = ClassAccessorProperty; -exports.ClassBody = ClassBody; -exports.ClassExpression = exports.ClassDeclaration = ClassDeclaration; -exports.ClassMethod = ClassMethod; -exports.ClassPrivateMethod = ClassPrivateMethod; -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) { - const inExport = isExportDefaultDeclaration(parent) || isExportNamedDeclaration(parent); - if (!inExport || !this._shouldPrintDecoratorsBeforeExport(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"); - if (node.id) { - this.space(); - this.print(node.id, node); - } - this.print(node.typeParameters, node); - if (node.superClass) { - this.space(); - this.word("extends"); - this.space(); - 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); - if (node.body.length === 0) { - this.tokenChar(125); - } else { - this.newline(); - const exit = this.enterForStatementInit(false); - this.printSequence(node.body, node, { - indent: true - }); - exit(); - if (!this.endsWith(10)) this.newline(); - this.rightBrace(node); - } -} -function ClassProperty(node) { - var _node$key$loc; - this.printJoin(node.decorators, node); - const endLine = (_node$key$loc = node.key.loc) == null || (_node$key$loc = _node$key$loc.end) == null ? void 0 : _node$key$loc.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; - this.printJoin(node.decorators, node); - const endLine = (_node$key$loc2 = node.key.loc) == null || (_node$key$loc2 = _node$key$loc2.end) == null ? void 0 : _node$key$loc2.line; - if (endLine) this.catchUp(endLine); - 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; - this.printJoin(node.decorators, node); - const endLine = (_node$key$loc3 = node.key.loc) == null || (_node$key$loc3 = _node$key$loc3.end) == null ? void 0 : _node$key$loc3.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 { - this.newline(); - this.printSequence(node.body, node, { - indent: true - }); - this.rightBrace(node); - } -} - -//# sourceMappingURL=classes.js.map diff --git a/tools/eslint/node_modules/@babel/generator/lib/generators/expressions.js b/tools/eslint/node_modules/@babel/generator/lib/generators/expressions.js deleted file mode 100644 index 686ee902e433d4..00000000000000 --- a/tools/eslint/node_modules/@babel/generator/lib/generators/expressions.js +++ /dev/null @@ -1,284 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.LogicalExpression = exports.BinaryExpression = exports.AssignmentExpression = AssignmentExpression; -exports.AssignmentPattern = AssignmentPattern; -exports.AwaitExpression = AwaitExpression; -exports.BindExpression = BindExpression; -exports.CallExpression = CallExpression; -exports.ConditionalExpression = ConditionalExpression; -exports.Decorator = Decorator; -exports.DoExpression = DoExpression; -exports.EmptyStatement = EmptyStatement; -exports.ExpressionStatement = ExpressionStatement; -exports.Import = Import; -exports.MemberExpression = MemberExpression; -exports.MetaProperty = MetaProperty; -exports.ModuleExpression = ModuleExpression; -exports.NewExpression = NewExpression; -exports.OptionalCallExpression = OptionalCallExpression; -exports.OptionalMemberExpression = OptionalMemberExpression; -exports.ParenthesizedExpression = ParenthesizedExpression; -exports.PrivateName = PrivateName; -exports.SequenceExpression = SequenceExpression; -exports.Super = Super; -exports.ThisExpression = ThisExpression; -exports.UnaryExpression = UnaryExpression; -exports.UpdateExpression = UpdateExpression; -exports.V8IntrinsicIdentifier = V8IntrinsicIdentifier; -exports.YieldExpression = YieldExpression; -exports._shouldPrintDecoratorsBeforeExport = _shouldPrintDecoratorsBeforeExport; -var _t = require("@babel/types"); -const { - isCallExpression, - isLiteral, - isMemberExpression, - isNewExpression -} = _t; -function UnaryExpression(node) { - const { - operator - } = node; - if (operator === "void" || operator === "delete" || operator === "typeof" || operator === "throw") { - this.word(operator); - this.space(); - } else { - this.token(operator); - } - this.print(node.argument, node); -} -function DoExpression(node) { - if (node.async) { - 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.rightParens(node); -} -function UpdateExpression(node) { - if (node.prefix) { - this.token(node.operator); - this.print(node.argument, node); - } else { - this.printTerminatorless(node.argument, node, true); - this.token(node.operator); - } -} -function ConditionalExpression(node) { - this.print(node.test, node); - this.space(); - this.tokenChar(63); - this.space(); - this.print(node.consequent, node); - this.space(); - this.tokenChar(58); - 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); - const exit = this.enterForStatementInit(false); - this.printList(node.arguments, node); - exit(); - this.rightParens(node); -} -function SequenceExpression(node) { - this.printList(node.expressions, node); -} -function ThisExpression() { - this.word("this"); -} -function Super() { - this.word("super"); -} -function _shouldPrintDecoratorsBeforeExport(node) { - if (typeof this.format.decoratorsBeforeExport === "boolean") { - return this.format.decoratorsBeforeExport; - } - return typeof node.start === "number" && node.start === node.declaration.start; -} -function Decorator(node) { - this.tokenChar(64); - this.print(node.expression, node); - this.newline(); -} -function OptionalMemberExpression(node) { - let { - computed - } = node; - const { - optional, - property - } = node; - this.print(node.object, node); - if (!computed && isMemberExpression(property)) { - throw new TypeError("Got a MemberExpression for MemberExpression property"); - } - if (isLiteral(property) && typeof property.value === "number") { - computed = true; - } - if (optional) { - this.token("?."); - } - if (computed) { - this.tokenChar(91); - this.print(property, node); - this.tokenChar(93); - } else { - if (!optional) { - this.tokenChar(46); - } - this.print(property, node); - } -} -function OptionalCallExpression(node) { - this.print(node.callee, node); - this.print(node.typeParameters, node); - if (node.optional) { - this.token("?."); - } - this.print(node.typeArguments, node); - this.tokenChar(40); - const exit = this.enterForStatementInit(false); - this.printList(node.arguments, node); - exit(); - this.rightParens(node); -} -function CallExpression(node) { - this.print(node.callee, node); - this.print(node.typeArguments, node); - this.print(node.typeParameters, node); - this.tokenChar(40); - const exit = this.enterForStatementInit(false); - this.printList(node.arguments, node); - exit(); - this.rightParens(node); -} -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", true); - if (node.delegate) { - this.tokenChar(42); - if (node.argument) { - this.space(); - this.print(node.argument, node); - } - } else { - if (node.argument) { - this.space(); - this.printTerminatorless(node.argument, node, false); - } - } -} -function EmptyStatement() { - this.semicolon(true); -} -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); - this.print(node.left.typeAnnotation, node); - this.space(); - this.tokenChar(61); - this.space(); - this.print(node.right, node); -} -function AssignmentExpression(node) { - 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); -} -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) { - const exit = this.enterForStatementInit(false); - this.tokenChar(91); - this.print(node.property, node); - this.tokenChar(93); - exit(); - } else { - this.tokenChar(46); - 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", 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.rightBrace(node); -} - -//# sourceMappingURL=expressions.js.map diff --git a/tools/eslint/node_modules/@babel/generator/lib/generators/flow.js b/tools/eslint/node_modules/@babel/generator/lib/generators/flow.js deleted file mode 100644 index 18c170097440ca..00000000000000 --- a/tools/eslint/node_modules/@babel/generator/lib/generators/flow.js +++ /dev/null @@ -1,668 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.AnyTypeAnnotation = AnyTypeAnnotation; -exports.ArrayTypeAnnotation = ArrayTypeAnnotation; -exports.BooleanLiteralTypeAnnotation = BooleanLiteralTypeAnnotation; -exports.BooleanTypeAnnotation = BooleanTypeAnnotation; -exports.DeclareClass = DeclareClass; -exports.DeclareExportAllDeclaration = DeclareExportAllDeclaration; -exports.DeclareExportDeclaration = DeclareExportDeclaration; -exports.DeclareFunction = DeclareFunction; -exports.DeclareInterface = DeclareInterface; -exports.DeclareModule = DeclareModule; -exports.DeclareModuleExports = DeclareModuleExports; -exports.DeclareOpaqueType = DeclareOpaqueType; -exports.DeclareTypeAlias = DeclareTypeAlias; -exports.DeclareVariable = DeclareVariable; -exports.DeclaredPredicate = DeclaredPredicate; -exports.EmptyTypeAnnotation = EmptyTypeAnnotation; -exports.EnumBooleanBody = EnumBooleanBody; -exports.EnumBooleanMember = EnumBooleanMember; -exports.EnumDeclaration = EnumDeclaration; -exports.EnumDefaultedMember = EnumDefaultedMember; -exports.EnumNumberBody = EnumNumberBody; -exports.EnumNumberMember = EnumNumberMember; -exports.EnumStringBody = EnumStringBody; -exports.EnumStringMember = EnumStringMember; -exports.EnumSymbolBody = EnumSymbolBody; -exports.ExistsTypeAnnotation = ExistsTypeAnnotation; -exports.FunctionTypeAnnotation = FunctionTypeAnnotation; -exports.FunctionTypeParam = FunctionTypeParam; -exports.IndexedAccessType = IndexedAccessType; -exports.InferredPredicate = InferredPredicate; -exports.InterfaceDeclaration = InterfaceDeclaration; -exports.GenericTypeAnnotation = exports.ClassImplements = exports.InterfaceExtends = InterfaceExtends; -exports.InterfaceTypeAnnotation = InterfaceTypeAnnotation; -exports.IntersectionTypeAnnotation = IntersectionTypeAnnotation; -exports.MixedTypeAnnotation = MixedTypeAnnotation; -exports.NullLiteralTypeAnnotation = NullLiteralTypeAnnotation; -exports.NullableTypeAnnotation = NullableTypeAnnotation; -Object.defineProperty(exports, "NumberLiteralTypeAnnotation", { - enumerable: true, - get: function () { - return _types2.NumericLiteral; - } -}); -exports.NumberTypeAnnotation = NumberTypeAnnotation; -exports.ObjectTypeAnnotation = ObjectTypeAnnotation; -exports.ObjectTypeCallProperty = ObjectTypeCallProperty; -exports.ObjectTypeIndexer = ObjectTypeIndexer; -exports.ObjectTypeInternalSlot = ObjectTypeInternalSlot; -exports.ObjectTypeProperty = ObjectTypeProperty; -exports.ObjectTypeSpreadProperty = ObjectTypeSpreadProperty; -exports.OpaqueType = OpaqueType; -exports.OptionalIndexedAccessType = OptionalIndexedAccessType; -exports.QualifiedTypeIdentifier = QualifiedTypeIdentifier; -Object.defineProperty(exports, "StringLiteralTypeAnnotation", { - enumerable: true, - get: function () { - return _types2.StringLiteral; - } -}); -exports.StringTypeAnnotation = StringTypeAnnotation; -exports.SymbolTypeAnnotation = SymbolTypeAnnotation; -exports.ThisTypeAnnotation = ThisTypeAnnotation; -exports.TupleTypeAnnotation = TupleTypeAnnotation; -exports.TypeAlias = TypeAlias; -exports.TypeAnnotation = TypeAnnotation; -exports.TypeCastExpression = TypeCastExpression; -exports.TypeParameter = TypeParameter; -exports.TypeParameterDeclaration = exports.TypeParameterInstantiation = TypeParameterInstantiation; -exports.TypeofTypeAnnotation = TypeofTypeAnnotation; -exports.UnionTypeAnnotation = UnionTypeAnnotation; -exports.Variance = Variance; -exports.VoidTypeAnnotation = VoidTypeAnnotation; -exports._interfaceish = _interfaceish; -exports._variance = _variance; -var _t = require("@babel/types"); -var _modules = require("./modules.js"); -var _types2 = require("./types.js"); -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"); - this.tokenChar(40); - 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(); - this.word("module"); - this.space(); - this.print(node.id, node); - this.space(); - this.print(node.body, node); -} -function DeclareModuleExports(node) { - this.word("declare"); - this.space(); - this.word("module"); - this.tokenChar(46); - 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, - body - } = node; - this.word("enum"); - this.space(); - this.print(id, node); - this.print(body, node); -} -function enumExplicitType(context, name, hasExplicitType) { - if (hasExplicitType) { - context.space(); - context.word("of"); - context.space(); - context.word(name); - } - context.space(); -} -function enumBody(context, node) { - const { - members - } = 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 - } = node; - enumExplicitType(this, "boolean", explicitType); - enumBody(this, node); -} -function EnumNumberBody(node) { - const { - explicitType - } = node; - enumExplicitType(this, "number", explicitType); - enumBody(this, node); -} -function EnumStringBody(node) { - const { - explicitType - } = node; - enumExplicitType(this, "string", explicitType); - enumBody(this, node); -} -function EnumSymbolBody(node) { - enumExplicitType(this, "symbol", true); - enumBody(this, node); -} -function EnumDefaultedMember(node) { - const { - id - } = node; - this.print(id, node); - this.tokenChar(44); -} -function enumInitializedMember(context, node) { - const { - id, - init - } = node; - context.print(id, node); - context.space(); - context.token("="); - context.space(); - 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; - this.print(declar, 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); - const type = parent == null ? void 0 : parent.type; - if (type != null && (type === "ObjectTypeCallProperty" || type === "ObjectTypeInternalSlot" || type === "DeclareFunction" || type === "ObjectTypeProperty" && parent.method)) { - this.tokenChar(58); - } else { - 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.type === "DeclareClass") { - var _node$mixins, _node$implements; - if ((_node$mixins = node.mixins) != null && _node$mixins.length) { - this.space(); - this.word("mixins"); - this.space(); - this.printList(node.mixins, node); - } - if ((_node$implements = node.implements) != null && _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) { - var _node$variance; - const kind = (_node$variance = node.variance) == null ? void 0 : _node$variance.kind; - if (kind != null) { - if (kind === "plus") { - this.tokenChar(43); - } else if (kind === "minus") { - this.tokenChar(45); - } - } -} -function InterfaceDeclaration(node) { - this.word("interface"); - this.space(); - this._interfaceish(node); -} -function andSeparator() { - this.space(); - this.tokenChar(38); - this.space(); -} -function InterfaceTypeAnnotation(node) { - var _node$extends2; - this.word("interface"); - if ((_node$extends2 = node.extends) != null && _node$extends2.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(); - this.print(node.id, node); - this.print(node.typeParameters, node); - this.space(); - this.tokenChar(61); - this.space(); - 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); - this.space(); - this.print(node.default, node); - } -} -function OpaqueType(node) { - this.word("opaque"); - this.space(); - this.word("type"); - 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("{|"); - } else { - this.tokenChar(123); - } - const props = [...node.properties, ...(node.callProperties || []), ...(node.indexers || []), ...(node.internalSlots || [])]; - if (props.length) { - this.newline(); - this.space(); - this.printJoin(props, node, { - addNewlines(leading) { - if (leading && !props[0]) return 1; - }, - indent: true, - statement: true, - iterator: () => { - if (props.length !== 1 || node.inexact) { - this.tokenChar(44); - this.space(); - } - } - }); - 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); - } else { - 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); -} - -//# sourceMappingURL=flow.js.map diff --git a/tools/eslint/node_modules/@babel/generator/lib/generators/index.js b/tools/eslint/node_modules/@babel/generator/lib/generators/index.js deleted file mode 100644 index 331c73f7e6a07a..00000000000000 --- a/tools/eslint/node_modules/@babel/generator/lib/generators/index.js +++ /dev/null @@ -1,128 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -var _templateLiterals = require("./template-literals.js"); -Object.keys(_templateLiterals).forEach(function (key) { - if (key === "default" || key === "__esModule") return; - if (key in exports && exports[key] === _templateLiterals[key]) return; - Object.defineProperty(exports, key, { - enumerable: true, - get: function () { - return _templateLiterals[key]; - } - }); -}); -var _expressions = require("./expressions.js"); -Object.keys(_expressions).forEach(function (key) { - if (key === "default" || key === "__esModule") return; - if (key in exports && exports[key] === _expressions[key]) return; - Object.defineProperty(exports, key, { - enumerable: true, - get: function () { - return _expressions[key]; - } - }); -}); -var _statements = require("./statements.js"); -Object.keys(_statements).forEach(function (key) { - if (key === "default" || key === "__esModule") return; - if (key in exports && exports[key] === _statements[key]) return; - Object.defineProperty(exports, key, { - enumerable: true, - get: function () { - return _statements[key]; - } - }); -}); -var _classes = require("./classes.js"); -Object.keys(_classes).forEach(function (key) { - if (key === "default" || key === "__esModule") return; - if (key in exports && exports[key] === _classes[key]) return; - Object.defineProperty(exports, key, { - enumerable: true, - get: function () { - return _classes[key]; - } - }); -}); -var _methods = require("./methods.js"); -Object.keys(_methods).forEach(function (key) { - if (key === "default" || key === "__esModule") return; - if (key in exports && exports[key] === _methods[key]) return; - Object.defineProperty(exports, key, { - enumerable: true, - get: function () { - return _methods[key]; - } - }); -}); -var _modules = require("./modules.js"); -Object.keys(_modules).forEach(function (key) { - if (key === "default" || key === "__esModule") return; - if (key in exports && exports[key] === _modules[key]) return; - Object.defineProperty(exports, key, { - enumerable: true, - get: function () { - return _modules[key]; - } - }); -}); -var _types = require("./types.js"); -Object.keys(_types).forEach(function (key) { - if (key === "default" || key === "__esModule") return; - if (key in exports && exports[key] === _types[key]) return; - Object.defineProperty(exports, key, { - enumerable: true, - get: function () { - return _types[key]; - } - }); -}); -var _flow = require("./flow.js"); -Object.keys(_flow).forEach(function (key) { - if (key === "default" || key === "__esModule") return; - if (key in exports && exports[key] === _flow[key]) return; - Object.defineProperty(exports, key, { - enumerable: true, - get: function () { - return _flow[key]; - } - }); -}); -var _base = require("./base.js"); -Object.keys(_base).forEach(function (key) { - if (key === "default" || key === "__esModule") return; - if (key in exports && exports[key] === _base[key]) return; - Object.defineProperty(exports, key, { - enumerable: true, - get: function () { - return _base[key]; - } - }); -}); -var _jsx = require("./jsx.js"); -Object.keys(_jsx).forEach(function (key) { - if (key === "default" || key === "__esModule") return; - if (key in exports && exports[key] === _jsx[key]) return; - Object.defineProperty(exports, key, { - enumerable: true, - get: function () { - return _jsx[key]; - } - }); -}); -var _typescript = require("./typescript.js"); -Object.keys(_typescript).forEach(function (key) { - if (key === "default" || key === "__esModule") return; - if (key in exports && exports[key] === _typescript[key]) return; - Object.defineProperty(exports, key, { - enumerable: true, - get: function () { - return _typescript[key]; - } - }); -}); - -//# sourceMappingURL=index.js.map diff --git a/tools/eslint/node_modules/@babel/generator/lib/generators/jsx.js b/tools/eslint/node_modules/@babel/generator/lib/generators/jsx.js deleted file mode 100644 index 4b8dd7a76140cb..00000000000000 --- a/tools/eslint/node_modules/@babel/generator/lib/generators/jsx.js +++ /dev/null @@ -1,123 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.JSXAttribute = JSXAttribute; -exports.JSXClosingElement = JSXClosingElement; -exports.JSXClosingFragment = JSXClosingFragment; -exports.JSXElement = JSXElement; -exports.JSXEmptyExpression = JSXEmptyExpression; -exports.JSXExpressionContainer = JSXExpressionContainer; -exports.JSXFragment = JSXFragment; -exports.JSXIdentifier = JSXIdentifier; -exports.JSXMemberExpression = JSXMemberExpression; -exports.JSXNamespacedName = JSXNamespacedName; -exports.JSXOpeningElement = JSXOpeningElement; -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("/>"); - } else { - this.tokenChar(62); - } -} -function JSXClosingElement(node) { - 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); -} -function _getFuncIdName(idNode, parent) { - let id = idNode; - if (!id && parent) { - const parentType = parent.type; - if (parentType === "VariableDeclarator") { - id = parent.id; - } else if (parentType === "AssignmentExpression" || parentType === "AssignmentPattern") { - id = parent.left; - } else if (parentType === "ObjectProperty" || parentType === "ClassProperty") { - if (!parent.computed || parent.key.type === "StringLiteral") { - id = parent.key; - } - } else if (parentType === "ClassPrivateProperty" || parentType === "ClassAccessorProperty") { - id = parent.key; - } - } - if (!id) return; - let nameInfo; - if (id.type === "Identifier") { - var _id$loc, _id$loc2; - nameInfo = { - pos: (_id$loc = id.loc) == null ? void 0 : _id$loc.start, - name: ((_id$loc2 = id.loc) == null ? void 0 : _id$loc2.identifierName) || id.name - }; - } else if (id.type === "PrivateName") { - var _id$loc3; - nameInfo = { - pos: (_id$loc3 = id.loc) == null ? void 0 : _id$loc3.start, - name: "#" + id.id.name - }; - } else if (id.type === "StringLiteral") { - var _id$loc4; - nameInfo = { - pos: (_id$loc4 = id.loc) == null ? void 0 : _id$loc4.start, - name: id.value - }; - } - return nameInfo; -} - -//# sourceMappingURL=methods.js.map diff --git a/tools/eslint/node_modules/@babel/generator/lib/generators/modules.js b/tools/eslint/node_modules/@babel/generator/lib/generators/modules.js deleted file mode 100644 index 8e77f32a3b0804..00000000000000 --- a/tools/eslint/node_modules/@babel/generator/lib/generators/modules.js +++ /dev/null @@ -1,274 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.ExportAllDeclaration = ExportAllDeclaration; -exports.ExportDefaultDeclaration = ExportDefaultDeclaration; -exports.ExportDefaultSpecifier = ExportDefaultSpecifier; -exports.ExportNamedDeclaration = ExportNamedDeclaration; -exports.ExportNamespaceSpecifier = ExportNamespaceSpecifier; -exports.ExportSpecifier = ExportSpecifier; -exports.ImportAttribute = ImportAttribute; -exports.ImportDeclaration = ImportDeclaration; -exports.ImportDefaultSpecifier = ImportDefaultSpecifier; -exports.ImportExpression = ImportExpression; -exports.ImportNamespaceSpecifier = ImportNamespaceSpecifier; -exports.ImportSpecifier = ImportSpecifier; -exports._printAttributes = _printAttributes; -var _t = require("@babel/types"); -const { - isClassDeclaration, - isExportDefaultSpecifier, - isExportNamespaceSpecifier, - isImportDefaultSpecifier, - 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"); - this.space(); - 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"); - this.space(); - this.print(node.exported, node); - } -} -function ExportNamespaceSpecifier(node) { - this.tokenChar(42); - this.space(); - this.word("as"); - this.space(); - this.print(node.exported, node); -} -let warningShown = false; -function _printAttributes(node) { - const { - importAttributesKeyword - } = this.format; - const { - attributes, - assertions - } = node; - if (attributes && !importAttributesKeyword && !warningShown) { - warningShown = true; - console.warn(`\ -You are using import attributes, without specifying the desired output syntax. -Please specify the "importAttributesKeyword" generator option, whose value can be one of: - - "with" : \`import { a } from "b" with { type: "json" };\` - - "assert" : \`import { a } from "b" assert { type: "json" };\` - - "with-legacy" : \`import { a } from "b" with type: "json";\` -`); - } - const useAssertKeyword = importAttributesKeyword === "assert" || !importAttributesKeyword && assertions; - this.word(useAssertKeyword ? "assert" : "with"); - this.space(); - if (!useAssertKeyword && importAttributesKeyword !== "with") { - this.printList(attributes || assertions, node); - return; - } - this.tokenChar(123); - this.space(); - this.printList(attributes || assertions, node); - this.space(); - this.tokenChar(125); -} -function ExportAllDeclaration(node) { - var _node$attributes, _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$attributes = node.attributes) != null && _node$attributes.length || (_node$assertions = node.assertions) != null && _node$assertions.length) { - this.print(node.source, node, true); - this.space(); - this._printAttributes(node); - } else { - this.print(node.source, node); - } - this.semicolon(); -} -function maybePrintDecoratorsBeforeExport(printer, node) { - if (isClassDeclaration(node.declaration) && printer._shouldPrintDecoratorsBeforeExport(node)) { - printer.printJoin(node.declaration.decorators, node); - } -} -function ExportNamedDeclaration(node) { - maybePrintDecoratorsBeforeExport(this, node); - this.word("export"); - this.space(); - if (node.declaration) { - const declar = node.declaration; - this.print(declar, node); - if (!isStatement(declar)) this.semicolon(); - } else { - if (node.exportKind === "type") { - this.word("type"); - this.space(); - } - const specifiers = node.specifiers.slice(0); - 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(); - } - } else { - 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$attributes2, _node$assertions2; - this.space(); - this.word("from"); - this.space(); - if ((_node$attributes2 = node.attributes) != null && _node$attributes2.length || (_node$assertions2 = node.assertions) != null && _node$assertions2.length) { - this.print(node.source, node, true); - this.space(); - this._printAttributes(node); - } else { - this.print(node.source, node); - } - } - this.semicolon(); - } -} -function ExportDefaultDeclaration(node) { - maybePrintDecoratorsBeforeExport(this, node); - this.word("export"); - this.noIndentInnerCommentsHere(); - this.space(); - this.word("default"); - this.space(); - const declar = node.declaration; - this.print(declar, node); - if (!isStatement(declar)) this.semicolon(); -} -function ImportDeclaration(node) { - var _node$attributes3, _node$assertions3; - this.word("import"); - this.space(); - const isTypeKind = node.importKind === "type" || node.importKind === "typeof"; - if (isTypeKind) { - this.noIndentInnerCommentsHere(); - this.word(node.importKind); - this.space(); - } else if (node.module) { - this.noIndentInnerCommentsHere(); - this.word("module"); - this.space(); - } else if (node.phase) { - this.noIndentInnerCommentsHere(); - this.word(node.phase); - 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(); - } - } else { - break; - } - } - if (specifiers.length) { - this.tokenChar(123); - this.space(); - this.printList(specifiers, node); - this.space(); - this.tokenChar(125); - } else if (isTypeKind && !hasSpecifiers) { - this.tokenChar(123); - this.tokenChar(125); - } - if (hasSpecifiers || isTypeKind) { - this.space(); - this.word("from"); - this.space(); - } - if ((_node$attributes3 = node.attributes) != null && _node$attributes3.length || (_node$assertions3 = node.assertions) != null && _node$assertions3.length) { - this.print(node.source, node, true); - this.space(); - this._printAttributes(node); - } else { - this.print(node.source, 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(); - this.word("as"); - this.space(); - this.print(node.local, node); -} -function ImportExpression(node) { - this.word("import"); - if (node.phase) { - this.tokenChar(46); - this.word(node.phase); - } - this.tokenChar(40); - this.print(node.source, node); - if (node.options != null) { - this.tokenChar(44); - this.space(); - this.print(node.options, node); - } - this.tokenChar(41); -} - -//# sourceMappingURL=modules.js.map diff --git a/tools/eslint/node_modules/@babel/generator/lib/generators/statements.js b/tools/eslint/node_modules/@babel/generator/lib/generators/statements.js deleted file mode 100644 index ca0c662a14ae81..00000000000000 --- a/tools/eslint/node_modules/@babel/generator/lib/generators/statements.js +++ /dev/null @@ -1,287 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.BreakStatement = BreakStatement; -exports.CatchClause = CatchClause; -exports.ContinueStatement = ContinueStatement; -exports.DebuggerStatement = DebuggerStatement; -exports.DoWhileStatement = DoWhileStatement; -exports.ForOfStatement = exports.ForInStatement = void 0; -exports.ForStatement = ForStatement; -exports.IfStatement = IfStatement; -exports.LabeledStatement = LabeledStatement; -exports.ReturnStatement = ReturnStatement; -exports.SwitchCase = SwitchCase; -exports.SwitchStatement = SwitchStatement; -exports.ThrowStatement = ThrowStatement; -exports.TryStatement = TryStatement; -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(); - this.tokenChar(40); - this.print(node.object, node); - this.tokenChar(41); - this.printBlock(node); -} -function IfStatement(node) { - this.word("if"); - this.space(); - this.tokenChar(40); - this.print(node.test, 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"); - this.space(); - this.printAndIndentOnComments(node.alternate, node); - } -} -function getLastStatement(statement) { - const { - body - } = statement; - if (isStatement(body) === false) { - return statement; - } - return getLastStatement(body); -} -function ForStatement(node) { - this.word("for"); - this.space(); - this.tokenChar(40); - { - const exit = this.enterForStatementInit(true); - this.print(node.init, node); - exit(); - } - 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(); - this.tokenChar(40); - this.print(node.test, 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.noIndentInnerCommentsHere(); - this.tokenChar(40); - { - const exit = isForOf ? null : this.enterForStatementInit(true); - this.print(node.left, node); - exit == null || exit(); - } - this.space(); - this.word(isForOf ? "of" : "in"); - this.space(); - this.print(node.right, node); - this.tokenChar(41); - this.printBlock(node); -} -const ForInStatement = exports.ForInStatement = ForXStatement; -const ForOfStatement = exports.ForOfStatement = ForXStatement; -function DoWhileStatement(node) { - this.word("do"); - this.space(); - this.print(node.body, node); - this.space(); - this.word("while"); - this.space(); - this.tokenChar(40); - this.print(node.test, 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(); - this.print(node.block, node); - this.space(); - if (node.handlers) { - this.print(node.handlers[0], node); - } else { - this.print(node.handler, node); - } - if (node.finalizer) { - this.space(); - this.word("finally"); - this.space(); - this.print(node.finalizer, node); - } -} -function CatchClause(node) { - this.word("catch"); - this.space(); - if (node.param) { - this.tokenChar(40); - this.print(node.param, node); - this.print(node.param.typeAnnotation, node); - this.tokenChar(41); - this.space(); - } - this.print(node.body, node); -} -function SwitchStatement(node) { - this.word("switch"); - this.space(); - this.tokenChar(40); - this.print(node.discriminant, node); - this.tokenChar(41); - this.space(); - 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.rightBrace(node); -} -function SwitchCase(node) { - if (node.test) { - this.word("case"); - this.space(); - this.print(node.test, node); - this.tokenChar(58); - } else { - this.word("default"); - this.tokenChar(58); - } - if (node.consequent.length) { - this.newline(); - this.printSequence(node.consequent, node, { - indent: true - }); - } -} -function DebuggerStatement() { - this.word("debugger"); - this.semicolon(); -} -function VariableDeclaration(node, parent) { - if (node.declare) { - this.word("declare"); - this.space(); - } - const { - kind - } = node; - if (kind === "await using") { - this.word("await"); - this.space(); - this.word("using", true); - } else { - this.word(kind, kind === "using"); - } - this.space(); - let hasInits = false; - if (!isFor(parent)) { - for (const declar of node.declarations) { - if (declar.init) { - hasInits = true; - } - } - } - this.printList(node.declarations, node, { - separator: hasInits ? function () { - this.tokenChar(44); - this.newline(); - } : undefined, - indent: node.declarations.length > 1 ? true : false - }); - if (isFor(parent)) { - if (isForStatement(parent)) { - if (parent.init === node) return; - } else { - 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); - this.space(); - this.print(node.init, node); - } -} - -//# sourceMappingURL=statements.js.map diff --git a/tools/eslint/node_modules/@babel/generator/lib/generators/template-literals.js b/tools/eslint/node_modules/@babel/generator/lib/generators/template-literals.js deleted file mode 100644 index a5f02d412bc635..00000000000000 --- a/tools/eslint/node_modules/@babel/generator/lib/generators/template-literals.js +++ /dev/null @@ -1,31 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -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() { - throw new Error("TemplateElement printing is handled in TemplateLiteral"); -} -function TemplateLiteral(node) { - const quasis = node.quasis; - let partRaw = "`"; - for (let i = 0; i < quasis.length; i++) { - partRaw += quasis[i].value.raw; - if (i + 1 < quasis.length) { - this.token(partRaw + "${", true); - this.print(node.expressions[i], node); - partRaw = "}"; - } - } - this.token(partRaw + "`", true); -} - -//# sourceMappingURL=template-literals.js.map diff --git a/tools/eslint/node_modules/@babel/generator/lib/generators/types.js b/tools/eslint/node_modules/@babel/generator/lib/generators/types.js deleted file mode 100644 index 7b9eb1d21e79da..00000000000000 --- a/tools/eslint/node_modules/@babel/generator/lib/generators/types.js +++ /dev/null @@ -1,229 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.ArgumentPlaceholder = ArgumentPlaceholder; -exports.ArrayPattern = exports.ArrayExpression = ArrayExpression; -exports.BigIntLiteral = BigIntLiteral; -exports.BooleanLiteral = BooleanLiteral; -exports.DecimalLiteral = DecimalLiteral; -exports.Identifier = Identifier; -exports.NullLiteral = NullLiteral; -exports.NumericLiteral = NumericLiteral; -exports.ObjectPattern = exports.ObjectExpression = ObjectExpression; -exports.ObjectMethod = ObjectMethod; -exports.ObjectProperty = ObjectProperty; -exports.PipelineBareFunction = PipelineBareFunction; -exports.PipelinePrimaryTopicReference = PipelinePrimaryTopicReference; -exports.PipelineTopicExpression = PipelineTopicExpression; -exports.RecordExpression = RecordExpression; -exports.RegExpLiteral = RegExpLiteral; -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) { - var _node$loc; - this.sourceIdentifierName(((_node$loc = node.loc) == null ? void 0 : _node$loc.identifierName) || node.name); - 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); - if (props.length) { - const exit = this.enterForStatementInit(false); - this.space(); - this.printList(props, node, { - indent: true, - statement: true - }); - this.space(); - exit(); - } - this.sourceWithOffset("end", node.loc, -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) { - 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); - const exit = this.enterForStatementInit(false); - 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); - } else { - this.tokenChar(44); - } - } - exit(); - this.tokenChar(93); -} -function RecordExpression(node) { - const props = node.properties; - let startToken; - let endToken; - { - if (this.format.recordAndTupleSyntaxType === "bar") { - startToken = "{|"; - endToken = "|}"; - } else if (this.format.recordAndTupleSyntaxType !== "hash" && this.format.recordAndTupleSyntaxType != null) { - throw new Error(`The "recordAndTupleSyntaxType" generator option must be "bar" or "hash" (${JSON.stringify(this.format.recordAndTupleSyntaxType)} received).`); - } else { - startToken = "#{"; - endToken = "}"; - } - } - this.token(startToken); - if (props.length) { - this.space(); - this.printList(props, node, { - indent: true, - statement: true - }); - 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 = "|]"; - } else if (this.format.recordAndTupleSyntaxType === "hash") { - startToken = "#["; - endToken = "]"; - } else { - throw new Error(`${this.format.recordAndTupleSyntaxType} is not a valid recordAndTuple syntax type`); - } - } - this.token(startToken); - 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; - const str = value + ""; - if (opts.numbers) { - this.number(_jsesc(value, opts), value); - } else if (raw == null) { - this.number(str, value); - } else if (this.format.minified) { - this.number(raw.length < str.length ? raw : str, value); - } else { - this.number(raw, value); - } -} -function StringLiteral(node) { - const raw = this.getPossibleRaw(node); - if (!this.format.minified && raw !== undefined) { - this.token(raw); - return; - } - const val = _jsesc(node.value, this.format.jsescOption); - 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 { - const givenTopicTokenJSON = JSON.stringify(topicToken); - const validTopics = Array.from(validTopicTokenSet, v => JSON.stringify(v)); - throw new Error(`The "topicToken" generator option must be one of ` + `${validTopics.join(", ")} (${givenTopicTokenJSON} received instead).`); - } -} -function PipelineTopicExpression(node) { - this.print(node.expression, node); -} -function PipelineBareFunction(node) { - this.print(node.callee, node); -} -function PipelinePrimaryTopicReference() { - this.tokenChar(35); -} - -//# sourceMappingURL=types.js.map diff --git a/tools/eslint/node_modules/@babel/generator/lib/generators/typescript.js b/tools/eslint/node_modules/@babel/generator/lib/generators/typescript.js deleted file mode 100644 index 5d57e58edeb739..00000000000000 --- a/tools/eslint/node_modules/@babel/generator/lib/generators/typescript.js +++ /dev/null @@ -1,690 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.TSAnyKeyword = TSAnyKeyword; -exports.TSArrayType = TSArrayType; -exports.TSSatisfiesExpression = exports.TSAsExpression = TSTypeExpression; -exports.TSBigIntKeyword = TSBigIntKeyword; -exports.TSBooleanKeyword = TSBooleanKeyword; -exports.TSCallSignatureDeclaration = TSCallSignatureDeclaration; -exports.TSConditionalType = TSConditionalType; -exports.TSConstructSignatureDeclaration = TSConstructSignatureDeclaration; -exports.TSConstructorType = TSConstructorType; -exports.TSDeclareFunction = TSDeclareFunction; -exports.TSDeclareMethod = TSDeclareMethod; -exports.TSEnumDeclaration = TSEnumDeclaration; -exports.TSEnumMember = TSEnumMember; -exports.TSExportAssignment = TSExportAssignment; -exports.TSExpressionWithTypeArguments = TSExpressionWithTypeArguments; -exports.TSExternalModuleReference = TSExternalModuleReference; -exports.TSFunctionType = TSFunctionType; -exports.TSImportEqualsDeclaration = TSImportEqualsDeclaration; -exports.TSImportType = TSImportType; -exports.TSIndexSignature = TSIndexSignature; -exports.TSIndexedAccessType = TSIndexedAccessType; -exports.TSInferType = TSInferType; -exports.TSInstantiationExpression = TSInstantiationExpression; -exports.TSInterfaceBody = TSInterfaceBody; -exports.TSInterfaceDeclaration = TSInterfaceDeclaration; -exports.TSIntersectionType = TSIntersectionType; -exports.TSIntrinsicKeyword = TSIntrinsicKeyword; -exports.TSLiteralType = TSLiteralType; -exports.TSMappedType = TSMappedType; -exports.TSMethodSignature = TSMethodSignature; -exports.TSModuleBlock = TSModuleBlock; -exports.TSModuleDeclaration = TSModuleDeclaration; -exports.TSNamedTupleMember = TSNamedTupleMember; -exports.TSNamespaceExportDeclaration = TSNamespaceExportDeclaration; -exports.TSNeverKeyword = TSNeverKeyword; -exports.TSNonNullExpression = TSNonNullExpression; -exports.TSNullKeyword = TSNullKeyword; -exports.TSNumberKeyword = TSNumberKeyword; -exports.TSObjectKeyword = TSObjectKeyword; -exports.TSOptionalType = TSOptionalType; -exports.TSParameterProperty = TSParameterProperty; -exports.TSParenthesizedType = TSParenthesizedType; -exports.TSPropertySignature = TSPropertySignature; -exports.TSQualifiedName = TSQualifiedName; -exports.TSRestType = TSRestType; -exports.TSStringKeyword = TSStringKeyword; -exports.TSSymbolKeyword = TSSymbolKeyword; -exports.TSThisType = TSThisType; -exports.TSTupleType = TSTupleType; -exports.TSTypeAliasDeclaration = TSTypeAliasDeclaration; -exports.TSTypeAnnotation = TSTypeAnnotation; -exports.TSTypeAssertion = TSTypeAssertion; -exports.TSTypeLiteral = TSTypeLiteral; -exports.TSTypeOperator = TSTypeOperator; -exports.TSTypeParameter = TSTypeParameter; -exports.TSTypeParameterDeclaration = exports.TSTypeParameterInstantiation = TSTypeParameterInstantiation; -exports.TSTypePredicate = TSTypePredicate; -exports.TSTypeQuery = TSTypeQuery; -exports.TSTypeReference = TSTypeReference; -exports.TSUndefinedKeyword = TSUndefinedKeyword; -exports.TSUnionType = TSUnionType; -exports.TSUnknownKeyword = TSUnknownKeyword; -exports.TSVoidKeyword = TSVoidKeyword; -exports.tsPrintClassMemberModifiers = tsPrintClassMemberModifiers; -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); - this.space(); - 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, parent) { - if (node.declare) { - this.word("declare"); - this.space(); - } - this._functionHead(node, parent); - 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 - } = node; - if (readonly) { - this.word("readonly"); - this.space(); - } - this.tsPrintPropertyOrMethodName(node); - this.print(node.typeAnnotation, 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; - this.print(typeParameters, node); - this.tokenChar(40); - this._parameters(parameters, node); - this.tokenChar(41); - this.space(); - this.token("=>"); - this.space(); - 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"); - this.space(); - 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.rightBrace(node); -} -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); - this.tokenChar(58); - 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() { - this.space(); - this.token(sep); - this.space(); - } - }); -} -function TSConditionalType(node) { - this.print(node.checkType); - this.space(); - this.word("extends"); - this.space(); - this.print(node.extendsType); - this.space(); - this.tokenChar(63); - this.space(); - this.print(node.trueType); - this.space(); - this.tokenChar(58); - 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, - optional, - readonly, - typeParameter, - typeAnnotation - } = 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); - } - if (typeAnnotation) { - this.tokenChar(58); - this.space(); - this.print(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, - id, - typeParameters, - 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, - id, - typeParameters, - typeAnnotation - } = node; - if (declare) { - this.word("declare"); - this.space(); - } - this.word("type"); - this.space(); - this.print(id, node); - this.print(typeParameters, node); - this.space(); - this.tokenChar(61); - this.space(); - this.print(typeAnnotation, node); - this.tokenChar(59); -} -function TSTypeExpression(node) { - var _expression$trailingC; - const { - type, - expression, - typeAnnotation - } = node; - const forceParens = !!((_expression$trailingC = expression.trailingComments) != null && _expression$trailingC.length); - this.print(expression, node, true, undefined, forceParens); - this.space(); - this.word(type === "TSAsExpression" ? "as" : "satisfies"); - this.space(); - this.print(typeAnnotation, node); -} -function TSTypeAssertion(node) { - const { - typeAnnotation, - expression - } = node; - this.tokenChar(60); - this.print(typeAnnotation, node); - this.tokenChar(62); - this.space(); - this.print(expression, node); -} -function TSInstantiationExpression(node) { - this.print(node.expression, node); - this.print(node.typeParameters, node); -} -function TSEnumDeclaration(node) { - const { - declare, - const: isConst, - 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, - qualifier, - typeParameters - } = node; - this.word("import"); - 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); - this.space(); - this.tokenChar(61); - this.space(); - 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(); - this.tokenChar(61); - this.space(); - this.print(node.expression, node); - this.tokenChar(59); -} -function TSNamespaceExportDeclaration(node) { - this.word("export"); - this.space(); - this.word("as"); - this.space(); - this.word("namespace"); - this.space(); - this.print(node.id, node); -} -function tsPrintSignatureDeclarationBase(node) { - const { - typeParameters - } = 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(); - } -} - -//# sourceMappingURL=typescript.js.map diff --git a/tools/eslint/node_modules/@babel/generator/lib/index.js b/tools/eslint/node_modules/@babel/generator/lib/index.js deleted file mode 100644 index 2678931b9da326..00000000000000 --- a/tools/eslint/node_modules/@babel/generator/lib/index.js +++ /dev/null @@ -1,89 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.default = generate; -var _sourceMap = require("./source-map.js"); -var _printer = require("./printer.js"); -function normalizeOptions(code, opts) { - const format = { - auxiliaryCommentBefore: opts.auxiliaryCommentBefore, - auxiliaryCommentAfter: opts.auxiliaryCommentAfter, - shouldPrintComment: opts.shouldPrintComment, - retainLines: opts.retainLines, - retainFunctionParens: opts.retainFunctionParens, - comments: opts.comments == null || opts.comments, - compact: opts.compact, - minified: opts.minified, - concise: opts.concise, - indent: { - adjustMultilineComment: true, - style: " " - }, - jsescOption: Object.assign({ - quotes: "double", - wrap: true, - minimal: false - }, opts.jsescOption), - topicToken: opts.topicToken, - importAttributesKeyword: opts.importAttributesKeyword - }; - { - var _opts$recordAndTupleS; - format.decoratorsBeforeExport = opts.decoratorsBeforeExport; - format.jsescOption.json = opts.jsonCompatibleStrings; - format.recordAndTupleSyntaxType = (_opts$recordAndTupleS = opts.recordAndTupleSyntaxType) != null ? _opts$recordAndTupleS : "hash"; - } - 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 = typeof code === "string" && code.length > 500000; - if (format.compact) { - 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; - } - const { - auxiliaryCommentBefore, - auxiliaryCommentAfter, - shouldPrintComment - } = format; - if (auxiliaryCommentBefore && !shouldPrintComment(auxiliaryCommentBefore)) { - format.auxiliaryCommentBefore = undefined; - } - if (auxiliaryCommentAfter && !shouldPrintComment(auxiliaryCommentAfter)) { - format.auxiliaryCommentAfter = undefined; - } - return format; -} -{ - exports.CodeGenerator = class CodeGenerator { - constructor(ast, opts = {}, code) { - this._ast = void 0; - this._format = void 0; - this._map = void 0; - this._ast = ast; - this._format = normalizeOptions(code, opts); - this._map = opts.sourceMaps ? new _sourceMap.default(opts, code) : null; - } - generate() { - const printer = new _printer.default(this._format, this._map); - return printer.generate(this._ast); - } - }; -} -function generate(ast, opts = {}, code) { - const format = normalizeOptions(code, opts); - const map = opts.sourceMaps ? new _sourceMap.default(opts, code) : null; - const printer = new _printer.default(format, map); - return printer.generate(ast); -} - -//# sourceMappingURL=index.js.map diff --git a/tools/eslint/node_modules/@babel/generator/lib/node/index.js b/tools/eslint/node_modules/@babel/generator/lib/node/index.js deleted file mode 100644 index 984850c7d182f6..00000000000000 --- a/tools/eslint/node_modules/@babel/generator/lib/node/index.js +++ /dev/null @@ -1,91 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.needsParens = needsParens; -exports.needsWhitespace = needsWhitespace; -exports.needsWhitespaceAfter = needsWhitespaceAfter; -exports.needsWhitespaceBefore = needsWhitespaceBefore; -var whitespace = require("./whitespace.js"); -var parens = require("./parentheses.js"); -var _t = require("@babel/types"); -const { - FLIPPED_ALIAS_KEYS, - isCallExpression, - isDecorator, - isExpressionStatement, - isMemberExpression, - isNewExpression, - isParenthesizedExpression -} = _t; -function expandAliases(obj) { - const map = new Map(); - function add(type, func) { - const fn = map.get(type); - map.set(type, fn ? function (node, parent, stack, inForInit) { - var _fn; - return (_fn = fn(node, parent, stack, inForInit)) != null ? _fn : func(node, parent, stack, inForInit); - } : 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]); - } - } else { - add(type, obj[type]); - } - } - return map; -} -const expandedParens = expandAliases(parens); -const expandedWhitespaceNodes = expandAliases(whitespace.nodes); -function isOrHasCallExpression(node) { - if (isCallExpression(node)) { - return true; - } - return isMemberExpression(node) && isOrHasCallExpression(node.object); -} -function needsWhitespace(node, parent, type) { - var _expandedWhitespaceNo; - if (!node) return false; - if (isExpressionStatement(node)) { - node = node.expression; - } - const flag = (_expandedWhitespaceNo = expandedWhitespaceNodes.get(node.type)) == null ? void 0 : _expandedWhitespaceNo(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, inForInit) { - var _expandedParens$get; - if (!parent) return false; - if (isNewExpression(parent) && parent.callee === node) { - if (isOrHasCallExpression(node)) return true; - } - if (isDecorator(parent)) { - return !isDecoratorMemberExpression(node) && !(isCallExpression(node) && isDecoratorMemberExpression(node.callee)) && !isParenthesizedExpression(node); - } - return (_expandedParens$get = expandedParens.get(node.type)) == null ? void 0 : _expandedParens$get(node, parent, printStack, inForInit); -} -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; - } -} - -//# sourceMappingURL=index.js.map diff --git a/tools/eslint/node_modules/@babel/generator/lib/node/parentheses.js b/tools/eslint/node_modules/@babel/generator/lib/node/parentheses.js deleted file mode 100644 index c6916013cbe88b..00000000000000 --- a/tools/eslint/node_modules/@babel/generator/lib/node/parentheses.js +++ /dev/null @@ -1,224 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.ArrowFunctionExpression = ArrowFunctionExpression; -exports.AssignmentExpression = AssignmentExpression; -exports.Binary = Binary; -exports.BinaryExpression = BinaryExpression; -exports.ClassExpression = ClassExpression; -exports.ConditionalExpression = ConditionalExpression; -exports.DoExpression = DoExpression; -exports.FunctionExpression = FunctionExpression; -exports.FunctionTypeAnnotation = FunctionTypeAnnotation; -exports.Identifier = Identifier; -exports.LogicalExpression = LogicalExpression; -exports.NullableTypeAnnotation = NullableTypeAnnotation; -exports.ObjectExpression = ObjectExpression; -exports.OptionalIndexedAccessType = OptionalIndexedAccessType; -exports.OptionalCallExpression = exports.OptionalMemberExpression = OptionalMemberExpression; -exports.SequenceExpression = SequenceExpression; -exports.TSTypeAssertion = exports.TSSatisfiesExpression = exports.TSAsExpression = TSAsExpression; -exports.TSInferType = TSInferType; -exports.TSInstantiationExpression = TSInstantiationExpression; -exports.TSIntersectionType = exports.TSUnionType = TSUnionType; -exports.UnaryLike = UnaryLike; -exports.IntersectionTypeAnnotation = exports.UnionTypeAnnotation = UnionTypeAnnotation; -exports.UpdateExpression = UpdateExpression; -exports.AwaitExpression = exports.YieldExpression = YieldExpression; -var _t = require("@babel/types"); -const { - isArrayTypeAnnotation, - isArrowFunctionExpression, - isBinaryExpression, - isCallExpression, - isExportDeclaration, - isForOfStatement, - isIndexedAccessType, - isMemberExpression, - isObjectPattern, - isOptionalMemberExpression, - isYieldExpression -} = _t; -const PRECEDENCE = new Map([["||", 0], ["??", 0], ["|>", 0], ["&&", 1], ["|", 2], ["^", 3], ["&", 4], ["==", 5], ["===", 5], ["!=", 5], ["!==", 5], ["<", 6], [">", 6], ["<=", 6], [">=", 6], ["in", 6], ["instanceof", 6], [">>", 7], ["<<", 7], [">>>", 7], ["+", 8], ["-", 8], ["*", 9], ["/", 9], ["%", 9], ["**", 10]]); -function isTSTypeExpression(nodeType) { - return nodeType === "TSAsExpression" || nodeType === "TSSatisfiesExpression" || nodeType === "TSTypeAssertion"; -} -const isClassExtendsClause = (node, parent) => { - const parentType = parent.type; - return (parentType === "ClassDeclaration" || parentType === "ClassExpression") && parent.superClass === node; -}; -const hasPostfixPart = (node, parent) => { - const parentType = parent.type; - return (parentType === "MemberExpression" || parentType === "OptionalMemberExpression") && parent.object === node || (parentType === "CallExpression" || parentType === "OptionalCallExpression" || parentType === "NewExpression") && parent.callee === node || parentType === "TaggedTemplateExpression" && parent.tag === node || parentType === "TSNonNullExpression"; -}; -function NullableTypeAnnotation(node, parent) { - return isArrayTypeAnnotation(parent); -} -function FunctionTypeAnnotation(node, parent, printStack) { - if (printStack.length < 3) return; - const parentType = parent.type; - return parentType === "UnionTypeAnnotation" || parentType === "IntersectionTypeAnnotation" || parentType === "ArrayTypeAnnotation" || parentType === "TypeAnnotation" && 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) { - const parentType = parent.type; - if (node.operator === "**" && parentType === "BinaryExpression" && parent.operator === "**") { - return parent.left === node; - } - if (isClassExtendsClause(node, parent)) { - return true; - } - if (hasPostfixPart(node, parent) || parentType === "UnaryExpression" || parentType === "SpreadElement" || parentType === "AwaitExpression") { - return true; - } - if (parentType === "BinaryExpression" || parentType === "LogicalExpression") { - const parentPos = PRECEDENCE.get(parent.operator); - const nodePos = PRECEDENCE.get(node.operator); - if (parentPos === nodePos && parent.right === node && parentType !== "LogicalExpression" || parentPos > nodePos) { - return true; - } - } - return undefined; -} -function UnionTypeAnnotation(node, parent) { - const parentType = parent.type; - return parentType === "ArrayTypeAnnotation" || parentType === "NullableTypeAnnotation" || parentType === "IntersectionTypeAnnotation" || parentType === "UnionTypeAnnotation"; -} -function OptionalIndexedAccessType(node, parent) { - return isIndexedAccessType(parent) && parent.objectType === node; -} -function TSAsExpression() { - return true; -} -function TSUnionType(node, parent) { - const parentType = parent.type; - return parentType === "TSArrayType" || parentType === "TSOptionalType" || parentType === "TSIntersectionType" || parentType === "TSUnionType" || parentType === "TSRestType"; -} -function TSInferType(node, parent) { - const parentType = parent.type; - return parentType === "TSArrayType" || parentType === "TSOptionalType"; -} -function TSInstantiationExpression(node, parent) { - const parentType = parent.type; - return (parentType === "CallExpression" || parentType === "OptionalCallExpression" || parentType === "NewExpression" || parentType === "TSInstantiationExpression") && !!parent.typeParameters; -} -function BinaryExpression(node, parent, stack, inForStatementInit) { - return node.operator === "in" && inForStatementInit; -} -function SequenceExpression(node, parent) { - const parentType = parent.type; - if (parentType === "ForStatement" || parentType === "ThrowStatement" || parentType === "ReturnStatement" || parentType === "IfStatement" && parent.test === node || parentType === "WhileStatement" && parent.test === node || parentType === "ForInStatement" && parent.right === node || parentType === "SwitchStatement" && parent.discriminant === node || parentType === "ExpressionStatement" && parent.expression === node) { - return false; - } - return true; -} -function YieldExpression(node, parent) { - const parentType = parent.type; - return parentType === "BinaryExpression" || parentType === "LogicalExpression" || parentType === "UnaryExpression" || parentType === "SpreadElement" || hasPostfixPart(node, parent) || parentType === "AwaitExpression" && isYieldExpression(node) || parentType === "ConditionalExpression" && node === parent.test || isClassExtendsClause(node, parent) || isTSTypeExpression(parentType); -} -function ClassExpression(node, parent, printStack) { - return isFirstInContext(printStack, 1 | 4); -} -function UnaryLike(node, parent) { - return hasPostfixPart(node, parent) || isBinaryExpression(parent) && parent.operator === "**" && parent.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) { - const parentType = parent.type; - if (parentType === "UnaryExpression" || parentType === "SpreadElement" || parentType === "BinaryExpression" || parentType === "LogicalExpression" || parentType === "ConditionalExpression" && parent.test === node || parentType === "AwaitExpression" || isTSTypeExpression(parentType)) { - return true; - } - return UnaryLike(node, parent); -} -function OptionalMemberExpression(node, parent) { - return isCallExpression(parent) && parent.callee === node || isMemberExpression(parent) && parent.object === node; -} -function AssignmentExpression(node, parent) { - if (isObjectPattern(node.left)) { - return true; - } else { - return ConditionalExpression(node, parent); - } -} -function LogicalExpression(node, parent) { - const parentType = parent.type; - if (isTSTypeExpression(parentType)) return true; - if (parentType !== "LogicalExpression") return false; - switch (node.operator) { - case "||": - return parent.operator === "??" || parent.operator === "&&"; - case "&&": - return parent.operator === "??"; - case "??": - return parent.operator !== "??"; - } -} -function Identifier(node, parent, printStack) { - var _node$extra; - const parentType = parent.type; - if ((_node$extra = node.extra) != null && _node$extra.parenthesized && parentType === "AssignmentExpression" && parent.left === node) { - const rightType = parent.right.type; - if ((rightType === "FunctionExpression" || rightType === "ClassExpression") && parent.right.id == null) { - return true; - } - } - if (node.name === "let") { - const isFollowedByBracket = isMemberExpression(parent, { - object: node, - computed: true - }) || isOptionalMemberExpression(parent, { - object: node, - computed: true, - optional: false - }); - return isFirstInContext(printStack, isFollowedByBracket ? 1 | 8 | 16 | 32 : 32); - } - return node.name === "async" && isForOfStatement(parent, { - left: node, - await: false - }); -} -function isFirstInContext(printStack, checkParam) { - const expressionStatement = checkParam & 1; - const arrowBody = checkParam & 2; - const exportDefault = checkParam & 4; - const forHead = checkParam & 8; - const forInHead = checkParam & 16; - const forOfHead = checkParam & 32; - let i = printStack.length - 1; - if (i <= 0) return; - let node = printStack[i]; - i--; - let parent = printStack[i]; - while (i >= 0) { - const parentType = parent.type; - if (expressionStatement && parentType === "ExpressionStatement" && parent.expression === node || exportDefault && parentType === "ExportDefaultDeclaration" && node === parent.declaration || arrowBody && parentType === "ArrowFunctionExpression" && parent.body === node || forHead && parentType === "ForStatement" && parent.init === node || forInHead && parentType === "ForInStatement" && parent.left === node || forOfHead && parentType === "ForOfStatement" && parent.left === node) { - return true; - } - if (i > 0 && (hasPostfixPart(node, parent) && parentType !== "NewExpression" || parentType === "SequenceExpression" && parent.expressions[0] === node || parentType === "UpdateExpression" && !parent.prefix || parentType === "ConditionalExpression" && parent.test === node || (parentType === "BinaryExpression" || parentType === "LogicalExpression") && parent.left === node || parentType === "AssignmentExpression" && parent.left === node)) { - node = parent; - i--; - parent = printStack[i]; - } else { - return false; - } - } - return false; -} - -//# sourceMappingURL=parentheses.js.map diff --git a/tools/eslint/node_modules/@babel/generator/lib/node/whitespace.js b/tools/eslint/node_modules/@babel/generator/lib/node/whitespace.js deleted file mode 100644 index 181b9566099e13..00000000000000 --- a/tools/eslint/node_modules/@babel/generator/lib/node/whitespace.js +++ /dev/null @@ -1,145 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.nodes = void 0; -var _t = require("@babel/types"); -const { - FLIPPED_ALIAS_KEYS, - isArrayExpression, - isAssignmentExpression, - isBinary, - isBlockStatement, - isCallExpression, - isFunction, - isIdentifier, - isLiteral, - isMemberExpression, - isObjectExpression, - isOptionalCallExpression, - 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); - } else if (isBinary(node) || isAssignmentExpression(node)) { - crawlInternal(node.left, state); - crawlInternal(node.right, state); - } else if (isCallExpression(node) || isOptionalCallExpression(node)) { - state.hasCall = true; - crawlInternal(node.callee, state); - } else if (isFunction(node)) { - state.hasFunction = true; - } else if (isIdentifier(node)) { - state.hasHelper = state.hasHelper || node.callee && isHelper(node.callee); - } - return state; -} -function crawl(node) { - return crawlInternal(node, { - hasCall: false, - hasFunction: false, - hasHelper: false - }); -} -function isHelper(node) { - if (!node) return false; - if (isMemberExpression(node)) { - return isHelper(node.object) || isHelper(node.property); - } else if (isIdentifier(node)) { - return node.name === "require" || node.name.charCodeAt(0) === 95; - } else if (isCallExpression(node)) { - return isHelper(node.callee); - } else if (isBinary(node) || isAssignmentExpression(node)) { - return isIdentifier(node.left) && isHelper(node.left) || isHelper(node.right); - } else { - return false; - } -} -function isType(node) { - return isLiteral(node) || isObjectExpression(node) || isArrayExpression(node) || isIdentifier(node) || isMemberExpression(node); -} -const nodes = exports.nodes = { - AssignmentExpression(node) { - const state = crawl(node.right); - if (state.hasCall && state.hasHelper || state.hasFunction) { - return state.hasFunction ? 1 | 2 : 2; - } - }, - SwitchCase(node, parent) { - return (!!node.consequent.length || parent.cases[0] === node ? 1 : 0) | (!node.consequent.length && parent.cases[parent.cases.length - 1] === node ? 2 : 0); - }, - LogicalExpression(node) { - if (isFunction(node.left) || isFunction(node.right)) { - return 2; - } - }, - Literal(node) { - if (isStringLiteral(node) && node.value === "use strict") { - return 2; - } - }, - CallExpression(node) { - if (isFunction(node.callee) || isHelper(node)) { - return 1 | 2; - } - }, - OptionalCallExpression(node) { - if (isFunction(node.callee)) { - return 1 | 2; - } - }, - VariableDeclaration(node) { - 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; - } - } - }, - IfStatement(node) { - if (isBlockStatement(node.consequent)) { - return 1 | 2; - } - } -}; -nodes.ObjectProperty = nodes.ObjectTypeProperty = nodes.ObjectMethod = function (node, parent) { - if (parent.properties[0] === node) { - 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; - } -}; -[["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; - }); -}); - -//# sourceMappingURL=whitespace.js.map diff --git a/tools/eslint/node_modules/@babel/generator/lib/printer.js b/tools/eslint/node_modules/@babel/generator/lib/printer.js deleted file mode 100644 index 5e825fb078252a..00000000000000 --- a/tools/eslint/node_modules/@babel/generator/lib/printer.js +++ /dev/null @@ -1,687 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.default = void 0; -var _buffer = require("./buffer.js"); -var n = require("./node/index.js"); -var _t = require("@babel/types"); -var generatorFunctions = require("./generators/index.js"); -const { - isFunction, - isStatement, - isClassBody, - isTSInterfaceBody, - isTSEnumDeclaration -} = _t; -const SCIENTIFIC_NOTATION = /e/i; -const ZERO_DECIMAL_INTEGER = /\.0+$/; -const HAS_NEWLINE = /[\n\r\u2028\u2029]/; -const HAS_NEWLINE_OR_BlOCK_COMMENT_END = /[\n\r\u2028\u2029]|\*\//; -const { - needsParens -} = n; -class Printer { - constructor(format, map) { - this.inForStatementInit = false; - this._printStack = []; - this._indent = 0; - this._indentRepeat = 0; - this._insideAux = false; - this._parenPushNewlineState = null; - this._noLineTerminator = false; - this._printAuxAfterOnNextUserNode = false; - this._printedComments = new Set(); - this._endsWithInteger = false; - this._endsWithWord = false; - this._lastCommentLine = 0; - this._endsWithInnerRaw = false; - this._indentInnerComments = true; - this.format = format; - this._indentRepeat = format.indent.style.length; - this._inputMap = map == null ? void 0 : map._inputMap; - this._buf = new _buffer.default(map, format.indent.style[0]); - } - enterForStatementInit(val) { - const old = this.inForStatementInit; - if (old === val) return () => {}; - this.inForStatementInit = val; - return () => { - this.inForStatementInit = old; - }; - } - generate(ast) { - this.print(ast); - this._maybeAddAuxComment(); - return this._buf.get(); - } - indent() { - if (this.format.compact || this.format.concise) return; - this._indent++; - } - dedent() { - if (this.format.compact || this.format.concise) return; - this._indent--; - } - semicolon(force = false) { - this._maybeAddAuxComment(); - if (force) { - this._appendChar(59); - } else { - this._queue(59); - } - this._noLineTerminator = false; - } - rightBrace(node) { - if (this.format.minified) { - this._buf.removeLastSemicolon(); - } - this.sourceWithOffset("end", node.loc, -1); - this.tokenChar(125); - } - rightParens(node) { - this.sourceWithOffset("end", node.loc, -1); - this.tokenChar(41); - } - 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, 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, number) { - function isNonDecimalLiteral(str) { - if (str.length > 2 && str.charCodeAt(0) === 48) { - const secondChar = str.charCodeAt(1); - return secondChar === 98 || secondChar === 111 || secondChar === 120; - } - return false; - } - this.word(str); - this._endsWithInteger = Number.isInteger(number) && !isNonDecimalLiteral(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 === 61) || 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) { - this._maybePrintInnerComments(); - 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(); - 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) { - cb(); - return; - } - 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, columnOffset) { - if (!loc) return; - this._catchUp(prop, loc); - this._buf.sourceWithOffset(prop, loc, columnOffset); - } - sourceIdentifierName(identifierName, pos) { - if (!this._buf._canMarkIdName) return; - const sourcePosition = this._buf._sourcePosition; - sourcePosition.identifierNamePos = pos; - sourcePosition.identifierName = identifierName; - } - _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._getIndent()); - } - } - _shouldIndent(firstChar) { - if (this._indent && firstChar !== 10 && this.endsWith(10)) { - return true; - } - } - _maybeAddParenChar(char) { - const parenPushNewlineState = this._parenPushNewlineState; - if (!parenPushNewlineState) return; - if (char === 32) { - return; - } - if (char !== 10) { - 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) { - this._parenPushNewlineState = null; - return; - } - const chaPost = str.charCodeAt(i + 1); - if (chaPost === 42) { - 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) { - var _loc$prop; - if (!this.format.retainLines) return; - const line = loc == null || (_loc$prop = loc[prop]) == null ? void 0 : _loc$prop.line; - if (line != null) { - const count = line - this._buf.getCurrentLine(); - for (let i = 0; i < count; i++) { - this._newline(); - } - } - } - _getIndent() { - return this._indentRepeat * this._indent; - } - printTerminatorless(node, parent, isLabel) { - if (isLabel) { - 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(); - this.tokenChar(41); - } - } - } - print(node, parent, noLineTerminatorAfter, trailingCommentsLineOffset, forceParens) { - var _node$extra, _node$leadingComments; - if (!node) return; - this._endsWithInnerRaw = false; - const nodeType = node.type; - const format = this.format; - const oldConcise = format.concise; - 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 == null; - this._maybeAddAuxComment(this._insideAux && !oldInAux); - const parenthesized = (_node$extra = node.extra) == null ? void 0 : _node$extra.parenthesized; - let shouldPrintParens = forceParens || parenthesized && format.retainFunctionParens && nodeType === "FunctionExpression" || needsParens(node, parent, this._printStack, this.inForStatementInit); - if (!shouldPrintParens && parenthesized && (_node$leadingComments = node.leadingComments) != null && _node$leadingComments.length && node.leadingComments[0].type === "CommentBlock") { - const parentType = parent == null ? void 0 : parent.type; - switch (parentType) { - case "ExpressionStatement": - case "VariableDeclarator": - case "AssignmentExpression": - case "ReturnStatement": - break; - case "CallExpression": - case "OptionalCallExpression": - case "NewExpression": - if (parent.callee !== node) break; - default: - shouldPrintParens = true; - } - } - let exitInForStatementInit; - if (shouldPrintParens) { - this.tokenChar(40); - this._endsWithInnerRaw = false; - exitInForStatementInit = this.enterForStatementInit(false); - } - 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 (shouldPrintParens) { - this._printTrailingComments(node, parent); - this.tokenChar(41); - this._noLineTerminator = noLineTerminatorAfter; - exitInForStatementInit(); - } else if (noLineTerminatorAfter && !this._noLineTerminator) { - this._noLineTerminator = true; - this._printTrailingComments(node, parent); - } else { - this._printTrailingComments(node, parent, trailingCommentsLineOffset); - } - 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", - value: comment - }, 0); - } - } - _printAuxAfterComment() { - if (!this._printAuxAfterOnNextUserNode) return; - this._printAuxAfterOnNextUserNode = false; - const comment = this.format.auxiliaryCommentAfter; - if (comment) { - this._printComment({ - type: "CommentBlock", - value: comment - }, 0); - } - } - getPossibleRaw(node) { - const extra = node.extra; - if ((extra == null ? void 0 : extra.raw) != null && extra.rawValue != null && node.value === extra.rawValue) { - return extra.raw; - } - } - printJoin(nodes, parent, opts = {}) { - if (!(nodes != null && nodes.length)) return; - let { - indent - } = opts; - if (indent == null && this.format.retainLines) { - var _nodes$0$loc; - const startLine = (_nodes$0$loc = nodes[0].loc) == null ? void 0 : _nodes$0$loc.start.line; - if (startLine != null && startLine !== this._buf.getCurrentLine()) { - indent = true; - } - } - if (indent) this.indent(); - const newlineOpts = { - addNewlines: opts.addNewlines, - nextNodeStartLine: 0 - }; - const separator = opts.separator ? opts.separator.bind(this) : null; - const len = nodes.length; - for (let i = 0; i < len; i++) { - const node = nodes[i]; - if (!node) continue; - if (opts.statement) this._printNewline(i === 0, newlineOpts); - this.print(node, parent, undefined, opts.trailingCommentsLineOffset || 0); - opts.iterator == null || opts.iterator(node, i); - if (i < len - 1) separator == null || separator(); - if (opts.statement) { - var _node$trailingComment; - if (!((_node$trailingComment = node.trailingComments) != null && _node$trailingComment.length)) { - this._lastCommentLine = 0; - } - 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 (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 { - innerComments, - trailingComments - } = node; - if (innerComments != null && innerComments.length) { - this._printComments(2, innerComments, node, parent, lineOffset); - } - if (trailingComments != null && trailingComments.length) { - this._printComments(2, trailingComments, node, parent, lineOffset); - } - } - _printLeadingComments(node, parent) { - const comments = node.leadingComments; - if (!(comments != null && comments.length)) return; - this._printComments(0, comments, node, parent); - } - _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, comments, node); - if (hasSpace && printedCommentsCount !== this._printedComments.size) { - this.space(); - } - if (indent) this.dedent(); - } - noIndentInnerCommentsHere() { - this._indentInnerComments = false; - } - printSequence(nodes, parent, opts = {}) { - var _opts$indent; - opts.statement = true; - (_opts$indent = opts.indent) != null ? _opts$indent : opts.indent = false; - this.printJoin(nodes, parent, opts); - } - printList(items, parent, opts = {}) { - if (opts.separator == null) { - opts.separator = commaSeparator; - } - this.printJoin(items, parent, opts); - } - _printNewline(newLine, opts) { - const format = this.format; - if (format.retainLines || format.compact) return; - if (format.concise) { - 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; - } - } - if (this._buf.hasContent()) { - this.newline(1); - } - } - _shouldPrintComment(comment) { - if (comment.ignore) return 0; - if (this._printedComments.has(comment)) return 0; - if (this._noLineTerminator && HAS_NEWLINE_OR_BlOCK_COMMENT_END.test(comment.value)) { - return 2; - } - this._printedComments.add(comment); - if (!this.format.shouldPrintComment(comment.value)) { - return 0; - } - return 1; - } - _printComment(comment, skipNewLines) { - const noLineTerminator = this._noLineTerminator; - const isBlockComment = comment.type === "CommentBlock"; - 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) { - const { - _parenPushNewlineState - } = this; - if ((_parenPushNewlineState == null ? void 0 : _parenPushNewlineState.printed) === false && HAS_NEWLINE.test(comment.value)) { - this.tokenChar(40); - this.indent(); - _parenPushNewlineState.printed = true; - } - 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"); - } - if (this.format.concise) { - val = val.replace(/\n(?!$)/g, `\n`); - } else { - 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 (!noLineTerminator) { - val = `//${comment.value}`; - } else { - val = `/*${comment.value}*/`; - } - if (this.endsWith(47)) this._space(); - this.source("start", comment.loc); - this._append(val, isBlockComment); - if (!isBlockComment && !noLineTerminator) { - this.newline(1, true); - } - if (printNewLines && skipNewLines !== 3) { - this.newline(1); - } - } - _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; - const maybeNewline = this._noLineTerminator ? function () {} : this.newline.bind(this); - for (let i = 0; i < len; i++) { - const comment = comments[i]; - const shouldPrint = this._shouldPrintComment(comment); - if (shouldPrint === 2) { - hasLoc = false; - break; - } - if (hasLoc && comment.loc && shouldPrint === 1) { - 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; - maybeNewline(offset); - this._printComment(comment, 1); - if (i + 1 === len) { - maybeNewline(Math.max(nodeStartLine - lastLine, leadingCommentNewline)); - lastLine = nodeStartLine; - } - } else if (type === 1) { - const offset = commentStartLine - (i === 0 ? nodeStartLine : lastLine); - lastLine = commentEndLine; - maybeNewline(offset); - this._printComment(comment, 1); - if (i + 1 === len) { - maybeNewline(Math.min(1, nodeEndLine - lastLine)); - lastLine = nodeEndLine; - } - } else { - const offset = commentStartLine - (i === 0 ? nodeEndLine - lineOffset : lastLine); - lastLine = commentEndLine; - maybeNewline(offset); - this._printComment(comment, 1); - } - } else { - hasLoc = false; - if (shouldPrint !== 1) { - continue; - } - if (len === 1) { - const singleLine = comment.loc ? comment.loc.start.line === comment.loc.end.line : !HAS_NEWLINE.test(comment.value); - const shouldSkipNewline = singleLine && !isStatement(node) && !isClassBody(parent) && !isTSInterfaceBody(parent) && !isTSEnumDeclaration(parent); - if (type === 0) { - this._printComment(comment, shouldSkipNewline && node.type !== "ObjectExpression" || singleLine && isFunction(parent, { - body: node - }) ? 1 : 0); - } else if (shouldSkipNewline && type === 2) { - this._printComment(comment, 1); - } else { - this._printComment(comment, 0); - } - } else if (type === 1 && !(node.type === "ObjectExpression" && node.properties.length > 1) && node.type !== "ClassBody" && node.type !== "TSInterfaceBody") { - this._printComment(comment, i === 0 ? 2 : i === len - 1 ? 3 : 0); - } else { - this._printComment(comment, 0); - } - } - } - if (type === 2 && hasLoc && lastLine) { - this._lastCommentLine = lastLine; - } - } -} -Object.assign(Printer.prototype, generatorFunctions); -{ - Printer.prototype.Noop = function Noop() {}; -} -var _default = exports.default = Printer; -function commaSeparator() { - this.tokenChar(44); - this.space(); -} - -//# sourceMappingURL=printer.js.map diff --git a/tools/eslint/node_modules/@babel/generator/lib/source-map.js b/tools/eslint/node_modules/@babel/generator/lib/source-map.js deleted file mode 100644 index 54da13772a246c..00000000000000 --- a/tools/eslint/node_modules/@babel/generator/lib/source-map.js +++ /dev/null @@ -1,85 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.default = void 0; -var _genMapping = require("@jridgewell/gen-mapping"); -var _traceMapping = require("@jridgewell/trace-mapping"); -class SourceMap { - constructor(opts, code) { - var _opts$sourceFileName; - this._map = void 0; - this._rawMappings = void 0; - this._sourceFileName = void 0; - this._lastGenLine = 0; - this._lastSourceLine = 0; - this._lastSourceColumn = 0; - this._inputMap = void 0; - const map = this._map = new _genMapping.GenMapping({ - sourceRoot: opts.sourceRoot - }); - this._sourceFileName = (_opts$sourceFileName = opts.sourceFileName) == null ? void 0 : _opts$sourceFileName.replace(/\\/g, "/"); - this._rawMappings = undefined; - if (opts.inputSourceMap) { - this._inputMap = new _traceMapping.TraceMap(opts.inputSourceMap); - const resolvedSources = this._inputMap.resolvedSources; - if (resolvedSources.length) { - for (let i = 0; i < resolvedSources.length; i++) { - var _this$_inputMap$sourc; - (0, _genMapping.setSourceContent)(map, resolvedSources[i], (_this$_inputMap$sourc = this._inputMap.sourcesContent) == null ? void 0 : _this$_inputMap$sourc[i]); - } - } - } - if (typeof code === "string" && !opts.inputSourceMap) { - (0, _genMapping.setSourceContent)(map, this._sourceFileName, code); - } else if (typeof code === "object") { - for (const sourceFileName of Object.keys(code)) { - (0, _genMapping.setSourceContent)(map, sourceFileName.replace(/\\/g, "/"), code[sourceFileName]); - } - } - } - 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)); - } - mark(generated, line, column, identifierName, identifierNamePos, filename) { - var _originalMapping; - this._rawMappings = undefined; - let originalMapping; - if (line != null) { - if (this._inputMap) { - originalMapping = (0, _traceMapping.originalPositionFor)(this._inputMap, { - line, - column - }); - if (!originalMapping.name && identifierNamePos) { - const originalIdentifierMapping = (0, _traceMapping.originalPositionFor)(this._inputMap, identifierNamePos); - if (originalIdentifierMapping.name) { - identifierName = originalIdentifierMapping.name; - } - } - } else { - originalMapping = { - source: (filename == null ? void 0 : filename.replace(/\\/g, "/")) || this._sourceFileName, - line: line, - column: column - }; - } - } - (0, _genMapping.maybeAddMapping)(this._map, { - name: identifierName, - generated, - source: (_originalMapping = originalMapping) == null ? void 0 : _originalMapping.source, - original: originalMapping - }); - } -} -exports.default = SourceMap; - -//# sourceMappingURL=source-map.js.map diff --git a/tools/eslint/node_modules/@babel/generator/package.json b/tools/eslint/node_modules/@babel/generator/package.json deleted file mode 100644 index dd8262c54550dd..00000000000000 --- a/tools/eslint/node_modules/@babel/generator/package.json +++ /dev/null @@ -1,38 +0,0 @@ -{ - "name": "@babel/generator", - "version": "7.24.8", - "description": "Turns an AST into code.", - "author": "The Babel Team (https://babel.dev/team)", - "license": "MIT", - "publishConfig": { - "access": "public" - }, - "repository": { - "type": "git", - "url": "https://github.com/babel/babel.git", - "directory": "packages/babel-generator" - }, - "homepage": "https://babel.dev/docs/en/next/babel-generator", - "bugs": "https://github.com/babel/babel/issues?utf8=%E2%9C%93&q=is%3Aissue+label%3A%22pkg%3A%20generator%22+is%3Aopen", - "main": "./lib/index.js", - "files": [ - "lib" - ], - "dependencies": { - "@babel/types": "^7.24.8", - "@jridgewell/gen-mapping": "^0.3.5", - "@jridgewell/trace-mapping": "^0.3.25", - "jsesc": "^2.5.1" - }, - "devDependencies": { - "@babel/helper-fixtures": "^7.24.8", - "@babel/parser": "^7.24.8", - "@jridgewell/sourcemap-codec": "^1.4.15", - "@types/jsesc": "^2.5.0", - "charcodes": "^0.2.0" - }, - "engines": { - "node": ">=6.9.0" - }, - "type": "commonjs" -} \ No newline at end of file diff --git a/tools/eslint/node_modules/@babel/helper-compilation-targets/LICENSE b/tools/eslint/node_modules/@babel/helper-compilation-targets/LICENSE deleted file mode 100644 index f31575ec773bb1..00000000000000 --- a/tools/eslint/node_modules/@babel/helper-compilation-targets/LICENSE +++ /dev/null @@ -1,22 +0,0 @@ -MIT License - -Copyright (c) 2014-present Sebastian McKenzie and other contributors - -Permission is hereby granted, free of charge, to any person obtaining -a copy of this software and associated documentation files (the -"Software"), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sublicense, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/tools/eslint/node_modules/@babel/helper-compilation-targets/lib/debug.js b/tools/eslint/node_modules/@babel/helper-compilation-targets/lib/debug.js deleted file mode 100644 index 372e6868260ac9..00000000000000 --- a/tools/eslint/node_modules/@babel/helper-compilation-targets/lib/debug.js +++ /dev/null @@ -1,28 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.getInclusionReasons = getInclusionReasons; -var _semver = require("semver"); -var _pretty = require("./pretty.js"); -var _utils = require("./utils.js"); -function getInclusionReasons(item, targetVersions, list) { - const minVersions = list[item] || {}; - return Object.keys(targetVersions).reduce((result, env) => { - const minVersion = (0, _utils.getLowestImplementedVersion)(minVersions, env); - const targetVersion = targetVersions[env]; - if (!minVersion) { - result[env] = (0, _pretty.prettifyVersion)(targetVersion); - } else { - const minIsUnreleased = (0, _utils.isUnreleasedVersion)(minVersion, env); - const targetIsUnreleased = (0, _utils.isUnreleasedVersion)(targetVersion, env); - if (!targetIsUnreleased && (minIsUnreleased || _semver.lt(targetVersion.toString(), (0, _utils.semverify)(minVersion)))) { - result[env] = (0, _pretty.prettifyVersion)(targetVersion); - } - } - return result; - }, {}); -} - -//# sourceMappingURL=debug.js.map diff --git a/tools/eslint/node_modules/@babel/helper-compilation-targets/lib/filter-items.js b/tools/eslint/node_modules/@babel/helper-compilation-targets/lib/filter-items.js deleted file mode 100644 index d898c950a58829..00000000000000 --- a/tools/eslint/node_modules/@babel/helper-compilation-targets/lib/filter-items.js +++ /dev/null @@ -1,67 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.default = filterItems; -exports.isRequired = isRequired; -exports.targetsSupported = targetsSupported; -var _semver = require("semver"); -var _plugins = require("@babel/compat-data/plugins"); -var _utils = require("./utils.js"); -function targetsSupported(target, support) { - const targetEnvironments = Object.keys(target); - if (targetEnvironments.length === 0) { - return false; - } - const unsupportedEnvironments = targetEnvironments.filter(environment => { - const lowestImplementedVersion = (0, _utils.getLowestImplementedVersion)(support, environment); - if (!lowestImplementedVersion) { - return true; - } - const lowestTargetedVersion = target[environment]; - if ((0, _utils.isUnreleasedVersion)(lowestTargetedVersion, environment)) { - return false; - } - if ((0, _utils.isUnreleasedVersion)(lowestImplementedVersion, environment)) { - return true; - } - if (!_semver.valid(lowestTargetedVersion.toString())) { - throw new Error(`Invalid version passed for target "${environment}": "${lowestTargetedVersion}". ` + "Versions must be in semver format (major.minor.patch)"); - } - return _semver.gt((0, _utils.semverify)(lowestImplementedVersion), lowestTargetedVersion.toString()); - }); - return unsupportedEnvironments.length === 0; -} -function isRequired(name, targets, { - compatData = _plugins, - includes, - excludes -} = {}) { - if (excludes != null && excludes.has(name)) return false; - if (includes != null && includes.has(name)) return true; - return !targetsSupported(targets, compatData[name]); -} -function filterItems(list, includes, excludes, targets, defaultIncludes, defaultExcludes, pluginSyntaxMap) { - const result = new Set(); - const options = { - compatData: list, - includes, - excludes - }; - for (const item in list) { - if (isRequired(item, targets, options)) { - result.add(item); - } else if (pluginSyntaxMap) { - const shippedProposalsSyntax = pluginSyntaxMap.get(item); - if (shippedProposalsSyntax) { - result.add(shippedProposalsSyntax); - } - } - } - defaultIncludes == null || defaultIncludes.forEach(item => !excludes.has(item) && result.add(item)); - defaultExcludes == null || defaultExcludes.forEach(item => !includes.has(item) && result.delete(item)); - return result; -} - -//# sourceMappingURL=filter-items.js.map diff --git a/tools/eslint/node_modules/@babel/helper-compilation-targets/lib/index.js b/tools/eslint/node_modules/@babel/helper-compilation-targets/lib/index.js deleted file mode 100644 index 145a38443d8b43..00000000000000 --- a/tools/eslint/node_modules/@babel/helper-compilation-targets/lib/index.js +++ /dev/null @@ -1,224 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -Object.defineProperty(exports, "TargetNames", { - enumerable: true, - get: function () { - return _options.TargetNames; - } -}); -exports.default = getTargets; -Object.defineProperty(exports, "filterItems", { - enumerable: true, - get: function () { - return _filterItems.default; - } -}); -Object.defineProperty(exports, "getInclusionReasons", { - enumerable: true, - get: function () { - return _debug.getInclusionReasons; - } -}); -exports.isBrowsersQueryValid = isBrowsersQueryValid; -Object.defineProperty(exports, "isRequired", { - enumerable: true, - get: function () { - return _filterItems.isRequired; - } -}); -Object.defineProperty(exports, "prettifyTargets", { - enumerable: true, - get: function () { - return _pretty.prettifyTargets; - } -}); -Object.defineProperty(exports, "unreleasedLabels", { - enumerable: true, - get: function () { - return _targets.unreleasedLabels; - } -}); -var _browserslist = require("browserslist"); -var _helperValidatorOption = require("@babel/helper-validator-option"); -var _nativeModules = require("@babel/compat-data/native-modules"); -var _lruCache = require("lru-cache"); -var _utils = require("./utils.js"); -var _targets = require("./targets.js"); -var _options = require("./options.js"); -var _pretty = require("./pretty.js"); -var _debug = require("./debug.js"); -var _filterItems = require("./filter-items.js"); -const ESM_SUPPORT = _nativeModules["es6.module"]; -const v = new _helperValidatorOption.OptionValidator("@babel/helper-compilation-targets"); -function validateTargetNames(targets) { - const validTargets = Object.keys(_options.TargetNames); - for (const target of Object.keys(targets)) { - if (!(target in _options.TargetNames)) { - throw new Error(v.formatMessage(`'${target}' is not a valid target -- Did you mean '${(0, _helperValidatorOption.findSuggestion)(target, validTargets)}'?`)); - } - } - return targets; -} -function isBrowsersQueryValid(browsers) { - return typeof browsers === "string" || Array.isArray(browsers) && browsers.every(b => typeof b === "string"); -} -function validateBrowsers(browsers) { - v.invariant(browsers === undefined || isBrowsersQueryValid(browsers), `'${String(browsers)}' is not a valid browserslist query`); - return browsers; -} -function getLowestVersions(browsers) { - return browsers.reduce((all, browser) => { - const [browserName, browserVersion] = browser.split(" "); - const target = _targets.browserNameMap[browserName]; - if (!target) { - return all; - } - try { - const splitVersion = browserVersion.split("-")[0].toLowerCase(); - const isSplitUnreleased = (0, _utils.isUnreleasedVersion)(splitVersion, target); - if (!all[target]) { - all[target] = isSplitUnreleased ? splitVersion : (0, _utils.semverify)(splitVersion); - return all; - } - const version = all[target]; - const isUnreleased = (0, _utils.isUnreleasedVersion)(version, target); - if (isUnreleased && isSplitUnreleased) { - all[target] = (0, _utils.getLowestUnreleased)(version, splitVersion, target); - } else if (isUnreleased) { - all[target] = (0, _utils.semverify)(splitVersion); - } else if (!isUnreleased && !isSplitUnreleased) { - const parsedBrowserVersion = (0, _utils.semverify)(splitVersion); - all[target] = (0, _utils.semverMin)(version, parsedBrowserVersion); - } - } catch (_) {} - return all; - }, {}); -} -function outputDecimalWarning(decimalTargets) { - if (!decimalTargets.length) { - return; - } - console.warn("Warning, the following targets are using a decimal version:\n"); - decimalTargets.forEach(({ - target, - value - }) => console.warn(` ${target}: ${value}`)); - console.warn(` -We recommend using a string for minor/patch versions to avoid numbers like 6.10 -getting parsed as 6.1, which can lead to unexpected behavior. -`); -} -function semverifyTarget(target, value) { - try { - return (0, _utils.semverify)(value); - } catch (_) { - throw new Error(v.formatMessage(`'${value}' is not a valid value for 'targets.${target}'.`)); - } -} -function nodeTargetParser(value) { - const parsed = value === true || value === "current" ? process.versions.node : semverifyTarget("node", value); - return ["node", parsed]; -} -function defaultTargetParser(target, value) { - const version = (0, _utils.isUnreleasedVersion)(value, target) ? value.toLowerCase() : semverifyTarget(target, value); - return [target, version]; -} -function generateTargets(inputTargets) { - const input = Object.assign({}, inputTargets); - delete input.esmodules; - delete input.browsers; - return input; -} -function resolveTargets(queries, env) { - const resolved = _browserslist(queries, { - mobileToDesktop: true, - env - }); - return getLowestVersions(resolved); -} -const targetsCache = new _lruCache({ - max: 64 -}); -function resolveTargetsCached(queries, env) { - const cacheKey = typeof queries === "string" ? queries : queries.join() + env; - let cached = targetsCache.get(cacheKey); - if (!cached) { - cached = resolveTargets(queries, env); - targetsCache.set(cacheKey, cached); - } - return Object.assign({}, cached); -} -function getTargets(inputTargets = {}, options = {}) { - var _browsers, _browsers2; - let { - browsers, - esmodules - } = inputTargets; - const { - configPath = "." - } = options; - validateBrowsers(browsers); - const input = generateTargets(inputTargets); - let targets = validateTargetNames(input); - const shouldParseBrowsers = !!browsers; - const hasTargets = shouldParseBrowsers || Object.keys(targets).length > 0; - const shouldSearchForConfig = !options.ignoreBrowserslistConfig && !hasTargets; - if (!browsers && shouldSearchForConfig) { - browsers = _browserslist.loadConfig({ - config: options.configFile, - path: configPath, - env: options.browserslistEnv - }); - if (browsers == null) { - { - browsers = []; - } - } - } - if (esmodules && (esmodules !== "intersect" || !((_browsers = browsers) != null && _browsers.length))) { - browsers = Object.keys(ESM_SUPPORT).map(browser => `${browser} >= ${ESM_SUPPORT[browser]}`).join(", "); - esmodules = false; - } - if ((_browsers2 = browsers) != null && _browsers2.length) { - const queryBrowsers = resolveTargetsCached(browsers, options.browserslistEnv); - if (esmodules === "intersect") { - for (const browser of Object.keys(queryBrowsers)) { - if (browser !== "deno" && browser !== "ie") { - const esmSupportVersion = ESM_SUPPORT[browser === "opera_mobile" ? "op_mob" : browser]; - if (esmSupportVersion) { - const version = queryBrowsers[browser]; - queryBrowsers[browser] = (0, _utils.getHighestUnreleased)(version, (0, _utils.semverify)(esmSupportVersion), browser); - } else { - delete queryBrowsers[browser]; - } - } else { - delete queryBrowsers[browser]; - } - } - } - targets = Object.assign(queryBrowsers, targets); - } - const result = {}; - const decimalWarnings = []; - for (const target of Object.keys(targets).sort()) { - const value = targets[target]; - if (typeof value === "number" && value % 1 !== 0) { - decimalWarnings.push({ - target, - value - }); - } - const [parsedTarget, parsedValue] = target === "node" ? nodeTargetParser(value) : defaultTargetParser(target, value); - if (parsedValue) { - result[parsedTarget] = parsedValue; - } - } - outputDecimalWarning(decimalWarnings); - return result; -} - -//# sourceMappingURL=index.js.map diff --git a/tools/eslint/node_modules/@babel/helper-compilation-targets/lib/options.js b/tools/eslint/node_modules/@babel/helper-compilation-targets/lib/options.js deleted file mode 100644 index cdb7c00d6403d5..00000000000000 --- a/tools/eslint/node_modules/@babel/helper-compilation-targets/lib/options.js +++ /dev/null @@ -1,24 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.TargetNames = void 0; -const TargetNames = exports.TargetNames = { - node: "node", - deno: "deno", - chrome: "chrome", - opera: "opera", - edge: "edge", - firefox: "firefox", - safari: "safari", - ie: "ie", - ios: "ios", - android: "android", - electron: "electron", - samsung: "samsung", - rhino: "rhino", - opera_mobile: "opera_mobile" -}; - -//# sourceMappingURL=options.js.map diff --git a/tools/eslint/node_modules/@babel/helper-compilation-targets/lib/pretty.js b/tools/eslint/node_modules/@babel/helper-compilation-targets/lib/pretty.js deleted file mode 100644 index f7c195dffd4e3a..00000000000000 --- a/tools/eslint/node_modules/@babel/helper-compilation-targets/lib/pretty.js +++ /dev/null @@ -1,40 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.prettifyTargets = prettifyTargets; -exports.prettifyVersion = prettifyVersion; -var _semver = require("semver"); -var _targets = require("./targets.js"); -function prettifyVersion(version) { - if (typeof version !== "string") { - return version; - } - const { - major, - minor, - patch - } = _semver.parse(version); - const parts = [major]; - if (minor || patch) { - parts.push(minor); - } - if (patch) { - parts.push(patch); - } - return parts.join("."); -} -function prettifyTargets(targets) { - return Object.keys(targets).reduce((results, target) => { - let value = targets[target]; - const unreleasedLabel = _targets.unreleasedLabels[target]; - if (typeof value === "string" && unreleasedLabel !== value) { - value = prettifyVersion(value); - } - results[target] = value; - return results; - }, {}); -} - -//# sourceMappingURL=pretty.js.map diff --git a/tools/eslint/node_modules/@babel/helper-compilation-targets/lib/targets.js b/tools/eslint/node_modules/@babel/helper-compilation-targets/lib/targets.js deleted file mode 100644 index d4d5e06cbba58c..00000000000000 --- a/tools/eslint/node_modules/@babel/helper-compilation-targets/lib/targets.js +++ /dev/null @@ -1,28 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.unreleasedLabels = exports.browserNameMap = void 0; -const unreleasedLabels = exports.unreleasedLabels = { - safari: "tp" -}; -const browserNameMap = exports.browserNameMap = { - and_chr: "chrome", - and_ff: "firefox", - android: "android", - chrome: "chrome", - edge: "edge", - firefox: "firefox", - ie: "ie", - ie_mob: "ie", - ios_saf: "ios", - node: "node", - deno: "deno", - op_mob: "opera_mobile", - opera: "opera", - safari: "safari", - samsung: "samsung" -}; - -//# sourceMappingURL=targets.js.map diff --git a/tools/eslint/node_modules/@babel/helper-compilation-targets/lib/utils.js b/tools/eslint/node_modules/@babel/helper-compilation-targets/lib/utils.js deleted file mode 100644 index cc52bf247cc03d..00000000000000 --- a/tools/eslint/node_modules/@babel/helper-compilation-targets/lib/utils.js +++ /dev/null @@ -1,58 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.getHighestUnreleased = getHighestUnreleased; -exports.getLowestImplementedVersion = getLowestImplementedVersion; -exports.getLowestUnreleased = getLowestUnreleased; -exports.isUnreleasedVersion = isUnreleasedVersion; -exports.semverMin = semverMin; -exports.semverify = semverify; -var _semver = require("semver"); -var _helperValidatorOption = require("@babel/helper-validator-option"); -var _targets = require("./targets.js"); -const versionRegExp = /^(\d+|\d+.\d+)$/; -const v = new _helperValidatorOption.OptionValidator("@babel/helper-compilation-targets"); -function semverMin(first, second) { - return first && _semver.lt(first, second) ? first : second; -} -function semverify(version) { - if (typeof version === "string" && _semver.valid(version)) { - return version; - } - v.invariant(typeof version === "number" || typeof version === "string" && versionRegExp.test(version), `'${version}' is not a valid version`); - version = version.toString(); - let pos = 0; - let num = 0; - while ((pos = version.indexOf(".", pos + 1)) > 0) { - num++; - } - return version + ".0".repeat(2 - num); -} -function isUnreleasedVersion(version, env) { - const unreleasedLabel = _targets.unreleasedLabels[env]; - return !!unreleasedLabel && unreleasedLabel === version.toString().toLowerCase(); -} -function getLowestUnreleased(a, b, env) { - const unreleasedLabel = _targets.unreleasedLabels[env]; - if (a === unreleasedLabel) { - return b; - } - if (b === unreleasedLabel) { - return a; - } - return semverMin(a, b); -} -function getHighestUnreleased(a, b, env) { - return getLowestUnreleased(a, b, env) === a ? b : a; -} -function getLowestImplementedVersion(plugin, environment) { - const result = plugin[environment]; - if (!result && environment === "android") { - return plugin.chrome; - } - return result; -} - -//# sourceMappingURL=utils.js.map diff --git a/tools/eslint/node_modules/@babel/helper-compilation-targets/package.json b/tools/eslint/node_modules/@babel/helper-compilation-targets/package.json deleted file mode 100644 index c1369339f206cc..00000000000000 --- a/tools/eslint/node_modules/@babel/helper-compilation-targets/package.json +++ /dev/null @@ -1,43 +0,0 @@ -{ - "name": "@babel/helper-compilation-targets", - "version": "7.24.8", - "author": "The Babel Team (https://babel.dev/team)", - "license": "MIT", - "description": "Helper functions on Babel compilation targets", - "repository": { - "type": "git", - "url": "https://github.com/babel/babel.git", - "directory": "packages/babel-helper-compilation-targets" - }, - "main": "./lib/index.js", - "exports": { - ".": { - "types": "./lib/index.d.ts", - "default": "./lib/index.js" - }, - "./package.json": "./package.json" - }, - "publishConfig": { - "access": "public" - }, - "keywords": [ - "babel", - "babel-plugin" - ], - "dependencies": { - "@babel/compat-data": "^7.24.8", - "@babel/helper-validator-option": "^7.24.8", - "browserslist": "^4.23.1", - "lru-cache": "^5.1.1", - "semver": "^6.3.1" - }, - "devDependencies": { - "@babel/helper-plugin-test-runner": "^7.24.7", - "@types/lru-cache": "^5.1.1", - "@types/semver": "^5.5.0" - }, - "engines": { - "node": ">=6.9.0" - }, - "type": "commonjs" -} \ No newline at end of file diff --git a/tools/eslint/node_modules/@babel/helper-environment-visitor/LICENSE b/tools/eslint/node_modules/@babel/helper-environment-visitor/LICENSE deleted file mode 100644 index f31575ec773bb1..00000000000000 --- a/tools/eslint/node_modules/@babel/helper-environment-visitor/LICENSE +++ /dev/null @@ -1,22 +0,0 @@ -MIT License - -Copyright (c) 2014-present Sebastian McKenzie and other contributors - -Permission is hereby granted, free of charge, to any person obtaining -a copy of this software and associated documentation files (the -"Software"), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sublicense, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/tools/eslint/node_modules/@babel/helper-environment-visitor/lib/index.js b/tools/eslint/node_modules/@babel/helper-environment-visitor/lib/index.js deleted file mode 100644 index fb796ca3e15956..00000000000000 --- a/tools/eslint/node_modules/@babel/helper-environment-visitor/lib/index.js +++ /dev/null @@ -1,51 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.default = void 0; -exports.requeueComputedKeyAndDecorators = requeueComputedKeyAndDecorators; -{ - exports.skipAllButComputedKey = function skipAllButComputedKey(path) { - path.skip(); - if (path.node.computed) { - path.context.maybeQueue(path.get("key")); - } - }; -} -function requeueComputedKeyAndDecorators(path) { - const { - context, - node - } = path; - if (node.computed) { - context.maybeQueue(path.get("key")); - } - if (node.decorators) { - for (const decorator of path.get("decorators")) { - context.maybeQueue(decorator); - } - } -} -const visitor = { - FunctionParent(path) { - if (path.isArrowFunctionExpression()) { - return; - } else { - path.skip(); - if (path.isMethod()) { - requeueComputedKeyAndDecorators(path); - } - } - }, - Property(path) { - if (path.isObjectProperty()) { - return; - } - path.skip(); - requeueComputedKeyAndDecorators(path); - } -}; -var _default = exports.default = visitor; - -//# sourceMappingURL=index.js.map diff --git a/tools/eslint/node_modules/@babel/helper-environment-visitor/package.json b/tools/eslint/node_modules/@babel/helper-environment-visitor/package.json deleted file mode 100644 index 2938602b4358c5..00000000000000 --- a/tools/eslint/node_modules/@babel/helper-environment-visitor/package.json +++ /dev/null @@ -1,34 +0,0 @@ -{ - "name": "@babel/helper-environment-visitor", - "version": "7.24.7", - "description": "Helper visitor to only visit nodes in the current 'this' context", - "repository": { - "type": "git", - "url": "https://github.com/babel/babel.git", - "directory": "packages/babel-helper-environment-visitor" - }, - "homepage": "https://babel.dev/docs/en/next/babel-helper-environment-visitor", - "license": "MIT", - "publishConfig": { - "access": "public" - }, - "main": "./lib/index.js", - "exports": { - ".": { - "types": "./lib/index.d.ts", - "default": "./lib/index.js" - }, - "./package.json": "./package.json" - }, - "dependencies": { - "@babel/types": "^7.24.7" - }, - "devDependencies": { - "@babel/traverse": "^7.24.7" - }, - "engines": { - "node": ">=6.9.0" - }, - "author": "The Babel Team (https://babel.dev/team)", - "type": "commonjs" -} \ No newline at end of file diff --git a/tools/eslint/node_modules/@babel/helper-function-name/LICENSE b/tools/eslint/node_modules/@babel/helper-function-name/LICENSE deleted file mode 100644 index f31575ec773bb1..00000000000000 --- a/tools/eslint/node_modules/@babel/helper-function-name/LICENSE +++ /dev/null @@ -1,22 +0,0 @@ -MIT License - -Copyright (c) 2014-present Sebastian McKenzie and other contributors - -Permission is hereby granted, free of charge, to any person obtaining -a copy of this software and associated documentation files (the -"Software"), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sublicense, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/tools/eslint/node_modules/@babel/helper-function-name/lib/index.js b/tools/eslint/node_modules/@babel/helper-function-name/lib/index.js deleted file mode 100644 index 2f0ead7ff43424..00000000000000 --- a/tools/eslint/node_modules/@babel/helper-function-name/lib/index.js +++ /dev/null @@ -1,170 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.default = _default; -var _template = require("@babel/template"); -var _t = require("@babel/types"); -const { - NOT_LOCAL_BINDING, - cloneNode, - identifier, - isAssignmentExpression, - isAssignmentPattern, - isFunction, - isIdentifier, - isLiteral, - isNullLiteral, - isObjectMethod, - isObjectProperty, - isRegExpLiteral, - isRestElement, - isTemplateLiteral, - isVariableDeclarator, - toBindingIdentifierName -} = _t; -function getFunctionArity(node) { - const count = node.params.findIndex(param => isAssignmentPattern(param) || isRestElement(param)); - return count === -1 ? node.params.length : count; -} -const buildPropertyMethodAssignmentWrapper = _template.default.statement(` - (function (FUNCTION_KEY) { - function FUNCTION_ID() { - return FUNCTION_KEY.apply(this, arguments); - } - - FUNCTION_ID.toString = function () { - return FUNCTION_KEY.toString(); - } - - return FUNCTION_ID; - })(FUNCTION) -`); -const buildGeneratorPropertyMethodAssignmentWrapper = _template.default.statement(` - (function (FUNCTION_KEY) { - function* FUNCTION_ID() { - return yield* FUNCTION_KEY.apply(this, arguments); - } - - FUNCTION_ID.toString = function () { - return FUNCTION_KEY.toString(); - }; - - return FUNCTION_ID; - })(FUNCTION) -`); -const visitor = { - "ReferencedIdentifier|BindingIdentifier"(path, state) { - if (path.node.name !== state.name) return; - const localDeclar = path.scope.getBindingIdentifier(state.name); - if (localDeclar !== state.outerDeclar) return; - state.selfReference = true; - path.stop(); - } -}; -function getNameFromLiteralId(id) { - if (isNullLiteral(id)) { - return "null"; - } - if (isRegExpLiteral(id)) { - return `_${id.pattern}_${id.flags}`; - } - if (isTemplateLiteral(id)) { - return id.quasis.map(quasi => quasi.value.raw).join(""); - } - if (id.value !== undefined) { - return id.value + ""; - } - return ""; -} -function wrap(state, method, id, scope) { - if (state.selfReference) { - if (scope.hasBinding(id.name) && !scope.hasGlobal(id.name)) { - scope.rename(id.name); - } else { - if (!isFunction(method)) return; - let build = buildPropertyMethodAssignmentWrapper; - if (method.generator) { - build = buildGeneratorPropertyMethodAssignmentWrapper; - } - const template = build({ - FUNCTION: method, - FUNCTION_ID: id, - FUNCTION_KEY: scope.generateUidIdentifier(id.name) - }).expression; - const params = template.callee.body.body[0].params; - for (let i = 0, len = getFunctionArity(method); i < len; i++) { - params.push(scope.generateUidIdentifier("x")); - } - return template; - } - } - method.id = id; - scope.getProgramParent().references[id.name] = true; -} -function visit(node, name, scope) { - const state = { - selfAssignment: false, - selfReference: false, - outerDeclar: scope.getBindingIdentifier(name), - name: name - }; - const binding = scope.getOwnBinding(name); - if (binding) { - if (binding.kind === "param") { - state.selfReference = true; - } else {} - } else if (state.outerDeclar || scope.hasGlobal(name)) { - scope.traverse(node, visitor, state); - } - return state; -} -function _default({ - node, - parent, - scope, - id -}, localBinding = false, supportUnicodeId = false) { - if (node.id) return; - if ((isObjectProperty(parent) || isObjectMethod(parent, { - kind: "method" - })) && (!parent.computed || isLiteral(parent.key))) { - id = parent.key; - } else if (isVariableDeclarator(parent)) { - id = parent.id; - if (isIdentifier(id) && !localBinding) { - const binding = scope.parent.getBinding(id.name); - if (binding && binding.constant && scope.getBinding(id.name) === binding) { - node.id = cloneNode(id); - node.id[NOT_LOCAL_BINDING] = true; - return; - } - } - } else if (isAssignmentExpression(parent, { - operator: "=" - })) { - id = parent.left; - } else if (!id) { - return; - } - let name; - if (id && isLiteral(id)) { - name = getNameFromLiteralId(id); - } else if (id && isIdentifier(id)) { - name = id.name; - } - if (name === undefined) { - return; - } - if (!supportUnicodeId && isFunction(node) && /[\uD800-\uDFFF]/.test(name)) { - return; - } - name = toBindingIdentifierName(name); - const newId = identifier(name); - newId[NOT_LOCAL_BINDING] = true; - const state = visit(node, name, scope); - return wrap(state, node, newId, scope) || node; -} - -//# sourceMappingURL=index.js.map diff --git a/tools/eslint/node_modules/@babel/helper-function-name/package.json b/tools/eslint/node_modules/@babel/helper-function-name/package.json deleted file mode 100644 index 0015ea8bfadab2..00000000000000 --- a/tools/eslint/node_modules/@babel/helper-function-name/package.json +++ /dev/null @@ -1,28 +0,0 @@ -{ - "name": "@babel/helper-function-name", - "version": "7.24.7", - "description": "Helper function to change the property 'name' of every function", - "repository": { - "type": "git", - "url": "https://github.com/babel/babel.git", - "directory": "packages/babel-helper-function-name" - }, - "homepage": "https://babel.dev/docs/en/next/babel-helper-function-name", - "license": "MIT", - "publishConfig": { - "access": "public" - }, - "main": "./lib/index.js", - "dependencies": { - "@babel/template": "^7.24.7", - "@babel/types": "^7.24.7" - }, - "devDependencies": { - "@babel/traverse": "^7.24.7" - }, - "engines": { - "node": ">=6.9.0" - }, - "author": "The Babel Team (https://babel.dev/team)", - "type": "commonjs" -} \ No newline at end of file diff --git a/tools/eslint/node_modules/@babel/helper-hoist-variables/LICENSE b/tools/eslint/node_modules/@babel/helper-hoist-variables/LICENSE deleted file mode 100644 index f31575ec773bb1..00000000000000 --- a/tools/eslint/node_modules/@babel/helper-hoist-variables/LICENSE +++ /dev/null @@ -1,22 +0,0 @@ -MIT License - -Copyright (c) 2014-present Sebastian McKenzie and other contributors - -Permission is hereby granted, free of charge, to any person obtaining -a copy of this software and associated documentation files (the -"Software"), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sublicense, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/tools/eslint/node_modules/@babel/helper-hoist-variables/lib/index.js b/tools/eslint/node_modules/@babel/helper-hoist-variables/lib/index.js deleted file mode 100644 index 06c4d5c8d49ff0..00000000000000 --- a/tools/eslint/node_modules/@babel/helper-hoist-variables/lib/index.js +++ /dev/null @@ -1,50 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.default = hoistVariables; -var _t = require("@babel/types"); -const { - assignmentExpression, - expressionStatement, - identifier -} = _t; -const visitor = { - Scope(path, state) { - if (state.kind === "let") path.skip(); - }, - FunctionParent(path) { - path.skip(); - }, - VariableDeclaration(path, state) { - if (state.kind && path.node.kind !== state.kind) return; - const nodes = []; - const declarations = path.get("declarations"); - let firstId; - for (const declar of declarations) { - firstId = declar.node.id; - if (declar.node.init) { - nodes.push(expressionStatement(assignmentExpression("=", declar.node.id, declar.node.init))); - } - for (const name of Object.keys(declar.getBindingIdentifiers())) { - state.emit(identifier(name), name, declar.node.init !== null); - } - } - if (path.parentPath.isFor({ - left: path.node - })) { - path.replaceWith(firstId); - } else { - path.replaceWithMultiple(nodes); - } - } -}; -function hoistVariables(path, emit, kind = "var") { - path.traverse(visitor, { - kind, - emit - }); -} - -//# sourceMappingURL=index.js.map diff --git a/tools/eslint/node_modules/@babel/helper-hoist-variables/package.json b/tools/eslint/node_modules/@babel/helper-hoist-variables/package.json deleted file mode 100644 index a9ae264d1adfb5..00000000000000 --- a/tools/eslint/node_modules/@babel/helper-hoist-variables/package.json +++ /dev/null @@ -1,27 +0,0 @@ -{ - "name": "@babel/helper-hoist-variables", - "version": "7.24.7", - "description": "Helper function to hoist variables", - "repository": { - "type": "git", - "url": "https://github.com/babel/babel.git", - "directory": "packages/babel-helper-hoist-variables" - }, - "homepage": "https://babel.dev/docs/en/next/babel-helper-hoist-variables", - "license": "MIT", - "publishConfig": { - "access": "public" - }, - "main": "./lib/index.js", - "dependencies": { - "@babel/types": "^7.24.7" - }, - "devDependencies": { - "@babel/traverse": "^7.24.7" - }, - "engines": { - "node": ">=6.9.0" - }, - "author": "The Babel Team (https://babel.dev/team)", - "type": "commonjs" -} \ No newline at end of file diff --git a/tools/eslint/node_modules/@babel/helper-module-imports/LICENSE b/tools/eslint/node_modules/@babel/helper-module-imports/LICENSE deleted file mode 100644 index f31575ec773bb1..00000000000000 --- a/tools/eslint/node_modules/@babel/helper-module-imports/LICENSE +++ /dev/null @@ -1,22 +0,0 @@ -MIT License - -Copyright (c) 2014-present Sebastian McKenzie and other contributors - -Permission is hereby granted, free of charge, to any person obtaining -a copy of this software and associated documentation files (the -"Software"), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sublicense, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/tools/eslint/node_modules/@babel/helper-module-imports/lib/import-builder.js b/tools/eslint/node_modules/@babel/helper-module-imports/lib/import-builder.js deleted file mode 100644 index b01187f9f4602b..00000000000000 --- a/tools/eslint/node_modules/@babel/helper-module-imports/lib/import-builder.js +++ /dev/null @@ -1,122 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.default = void 0; -var _assert = require("assert"); -var _t = require("@babel/types"); -const { - callExpression, - cloneNode, - expressionStatement, - identifier, - importDeclaration, - importDefaultSpecifier, - importNamespaceSpecifier, - importSpecifier, - memberExpression, - stringLiteral, - variableDeclaration, - variableDeclarator -} = _t; -class ImportBuilder { - constructor(importedSource, scope, hub) { - this._statements = []; - this._resultName = null; - this._importedSource = void 0; - this._scope = scope; - this._hub = hub; - this._importedSource = importedSource; - } - done() { - return { - statements: this._statements, - resultName: this._resultName - }; - } - import() { - this._statements.push(importDeclaration([], stringLiteral(this._importedSource))); - return this; - } - require() { - this._statements.push(expressionStatement(callExpression(identifier("require"), [stringLiteral(this._importedSource)]))); - return this; - } - namespace(name = "namespace") { - const local = this._scope.generateUidIdentifier(name); - const statement = this._statements[this._statements.length - 1]; - _assert(statement.type === "ImportDeclaration"); - _assert(statement.specifiers.length === 0); - statement.specifiers = [importNamespaceSpecifier(local)]; - this._resultName = cloneNode(local); - return this; - } - default(name) { - const id = this._scope.generateUidIdentifier(name); - const statement = this._statements[this._statements.length - 1]; - _assert(statement.type === "ImportDeclaration"); - _assert(statement.specifiers.length === 0); - statement.specifiers = [importDefaultSpecifier(id)]; - this._resultName = cloneNode(id); - return this; - } - named(name, importName) { - if (importName === "default") return this.default(name); - const id = this._scope.generateUidIdentifier(name); - const statement = this._statements[this._statements.length - 1]; - _assert(statement.type === "ImportDeclaration"); - _assert(statement.specifiers.length === 0); - statement.specifiers = [importSpecifier(id, identifier(importName))]; - this._resultName = cloneNode(id); - return this; - } - var(name) { - const id = this._scope.generateUidIdentifier(name); - let statement = this._statements[this._statements.length - 1]; - if (statement.type !== "ExpressionStatement") { - _assert(this._resultName); - statement = expressionStatement(this._resultName); - this._statements.push(statement); - } - this._statements[this._statements.length - 1] = variableDeclaration("var", [variableDeclarator(id, statement.expression)]); - this._resultName = cloneNode(id); - return this; - } - defaultInterop() { - return this._interop(this._hub.addHelper("interopRequireDefault")); - } - wildcardInterop() { - return this._interop(this._hub.addHelper("interopRequireWildcard")); - } - _interop(callee) { - const statement = this._statements[this._statements.length - 1]; - if (statement.type === "ExpressionStatement") { - statement.expression = callExpression(callee, [statement.expression]); - } else if (statement.type === "VariableDeclaration") { - _assert(statement.declarations.length === 1); - statement.declarations[0].init = callExpression(callee, [statement.declarations[0].init]); - } else { - _assert.fail("Unexpected type."); - } - return this; - } - prop(name) { - const statement = this._statements[this._statements.length - 1]; - if (statement.type === "ExpressionStatement") { - statement.expression = memberExpression(statement.expression, identifier(name)); - } else if (statement.type === "VariableDeclaration") { - _assert(statement.declarations.length === 1); - statement.declarations[0].init = memberExpression(statement.declarations[0].init, identifier(name)); - } else { - _assert.fail("Unexpected type:" + statement.type); - } - return this; - } - read(name) { - this._resultName = memberExpression(this._resultName, identifier(name)); - } -} -exports.default = ImportBuilder; - -//# sourceMappingURL=import-builder.js.map diff --git a/tools/eslint/node_modules/@babel/helper-module-imports/lib/import-injector.js b/tools/eslint/node_modules/@babel/helper-module-imports/lib/import-injector.js deleted file mode 100644 index 0c61c565a2c411..00000000000000 --- a/tools/eslint/node_modules/@babel/helper-module-imports/lib/import-injector.js +++ /dev/null @@ -1,304 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.default = void 0; -var _assert = require("assert"); -var _t = require("@babel/types"); -var _importBuilder = require("./import-builder.js"); -var _isModule = require("./is-module.js"); -const { - identifier, - importSpecifier, - numericLiteral, - sequenceExpression, - isImportDeclaration -} = _t; -class ImportInjector { - constructor(path, importedSource, opts) { - this._defaultOpts = { - importedSource: null, - importedType: "commonjs", - importedInterop: "babel", - importingInterop: "babel", - ensureLiveReference: false, - ensureNoContext: false, - importPosition: "before" - }; - const programPath = path.find(p => p.isProgram()); - this._programPath = programPath; - this._programScope = programPath.scope; - this._hub = programPath.hub; - this._defaultOpts = this._applyDefaults(importedSource, opts, true); - } - addDefault(importedSourceIn, opts) { - return this.addNamed("default", importedSourceIn, opts); - } - addNamed(importName, importedSourceIn, opts) { - _assert(typeof importName === "string"); - return this._generateImport(this._applyDefaults(importedSourceIn, opts), importName); - } - addNamespace(importedSourceIn, opts) { - return this._generateImport(this._applyDefaults(importedSourceIn, opts), null); - } - addSideEffect(importedSourceIn, opts) { - return this._generateImport(this._applyDefaults(importedSourceIn, opts), void 0); - } - _applyDefaults(importedSource, opts, isInit = false) { - let newOpts; - if (typeof importedSource === "string") { - newOpts = Object.assign({}, this._defaultOpts, { - importedSource - }, opts); - } else { - _assert(!opts, "Unexpected secondary arguments."); - newOpts = Object.assign({}, this._defaultOpts, importedSource); - } - if (!isInit && opts) { - if (opts.nameHint !== undefined) newOpts.nameHint = opts.nameHint; - if (opts.blockHoist !== undefined) newOpts.blockHoist = opts.blockHoist; - } - return newOpts; - } - _generateImport(opts, importName) { - const isDefault = importName === "default"; - const isNamed = !!importName && !isDefault; - const isNamespace = importName === null; - const { - importedSource, - importedType, - importedInterop, - importingInterop, - ensureLiveReference, - ensureNoContext, - nameHint, - importPosition, - blockHoist - } = opts; - let name = nameHint || importName; - const isMod = (0, _isModule.default)(this._programPath); - const isModuleForNode = isMod && importingInterop === "node"; - const isModuleForBabel = isMod && importingInterop === "babel"; - if (importPosition === "after" && !isMod) { - throw new Error(`"importPosition": "after" is only supported in modules`); - } - const builder = new _importBuilder.default(importedSource, this._programScope, this._hub); - if (importedType === "es6") { - if (!isModuleForNode && !isModuleForBabel) { - throw new Error("Cannot import an ES6 module from CommonJS"); - } - builder.import(); - if (isNamespace) { - builder.namespace(nameHint || importedSource); - } else if (isDefault || isNamed) { - builder.named(name, importName); - } - } else if (importedType !== "commonjs") { - throw new Error(`Unexpected interopType "${importedType}"`); - } else if (importedInterop === "babel") { - if (isModuleForNode) { - name = name !== "default" ? name : importedSource; - const es6Default = `${importedSource}$es6Default`; - builder.import(); - if (isNamespace) { - builder.default(es6Default).var(name || importedSource).wildcardInterop(); - } else if (isDefault) { - if (ensureLiveReference) { - builder.default(es6Default).var(name || importedSource).defaultInterop().read("default"); - } else { - builder.default(es6Default).var(name).defaultInterop().prop(importName); - } - } else if (isNamed) { - builder.default(es6Default).read(importName); - } - } else if (isModuleForBabel) { - builder.import(); - if (isNamespace) { - builder.namespace(name || importedSource); - } else if (isDefault || isNamed) { - builder.named(name, importName); - } - } else { - builder.require(); - if (isNamespace) { - builder.var(name || importedSource).wildcardInterop(); - } else if ((isDefault || isNamed) && ensureLiveReference) { - if (isDefault) { - name = name !== "default" ? name : importedSource; - builder.var(name).read(importName); - builder.defaultInterop(); - } else { - builder.var(importedSource).read(importName); - } - } else if (isDefault) { - builder.var(name).defaultInterop().prop(importName); - } else if (isNamed) { - builder.var(name).prop(importName); - } - } - } else if (importedInterop === "compiled") { - if (isModuleForNode) { - builder.import(); - if (isNamespace) { - builder.default(name || importedSource); - } else if (isDefault || isNamed) { - builder.default(importedSource).read(name); - } - } else if (isModuleForBabel) { - builder.import(); - if (isNamespace) { - builder.namespace(name || importedSource); - } else if (isDefault || isNamed) { - builder.named(name, importName); - } - } else { - builder.require(); - if (isNamespace) { - builder.var(name || importedSource); - } else if (isDefault || isNamed) { - if (ensureLiveReference) { - builder.var(importedSource).read(name); - } else { - builder.prop(importName).var(name); - } - } - } - } else if (importedInterop === "uncompiled") { - if (isDefault && ensureLiveReference) { - throw new Error("No live reference for commonjs default"); - } - if (isModuleForNode) { - builder.import(); - if (isNamespace) { - builder.default(name || importedSource); - } else if (isDefault) { - builder.default(name); - } else if (isNamed) { - builder.default(importedSource).read(name); - } - } else if (isModuleForBabel) { - builder.import(); - if (isNamespace) { - builder.default(name || importedSource); - } else if (isDefault) { - builder.default(name); - } else if (isNamed) { - builder.named(name, importName); - } - } else { - builder.require(); - if (isNamespace) { - builder.var(name || importedSource); - } else if (isDefault) { - builder.var(name); - } else if (isNamed) { - if (ensureLiveReference) { - builder.var(importedSource).read(name); - } else { - builder.var(name).prop(importName); - } - } - } - } else { - throw new Error(`Unknown importedInterop "${importedInterop}".`); - } - const { - statements, - resultName - } = builder.done(); - this._insertStatements(statements, importPosition, blockHoist); - if ((isDefault || isNamed) && ensureNoContext && resultName.type !== "Identifier") { - return sequenceExpression([numericLiteral(0), resultName]); - } - return resultName; - } - _insertStatements(statements, importPosition = "before", blockHoist = 3) { - if (importPosition === "after") { - if (this._insertStatementsAfter(statements)) return; - } else { - if (this._insertStatementsBefore(statements, blockHoist)) return; - } - this._programPath.unshiftContainer("body", statements); - } - _insertStatementsBefore(statements, blockHoist) { - if (statements.length === 1 && isImportDeclaration(statements[0]) && isValueImport(statements[0])) { - const firstImportDecl = this._programPath.get("body").find(p => { - return p.isImportDeclaration() && isValueImport(p.node); - }); - if ((firstImportDecl == null ? void 0 : firstImportDecl.node.source.value) === statements[0].source.value && maybeAppendImportSpecifiers(firstImportDecl.node, statements[0])) { - return true; - } - } - statements.forEach(node => { - node._blockHoist = blockHoist; - }); - const targetPath = this._programPath.get("body").find(p => { - const val = p.node._blockHoist; - return Number.isFinite(val) && val < 4; - }); - if (targetPath) { - targetPath.insertBefore(statements); - return true; - } - return false; - } - _insertStatementsAfter(statements) { - const statementsSet = new Set(statements); - const importDeclarations = new Map(); - for (const statement of statements) { - if (isImportDeclaration(statement) && isValueImport(statement)) { - const source = statement.source.value; - if (!importDeclarations.has(source)) importDeclarations.set(source, []); - importDeclarations.get(source).push(statement); - } - } - let lastImportPath = null; - for (const bodyStmt of this._programPath.get("body")) { - if (bodyStmt.isImportDeclaration() && isValueImport(bodyStmt.node)) { - lastImportPath = bodyStmt; - const source = bodyStmt.node.source.value; - const newImports = importDeclarations.get(source); - if (!newImports) continue; - for (const decl of newImports) { - if (!statementsSet.has(decl)) continue; - if (maybeAppendImportSpecifiers(bodyStmt.node, decl)) { - statementsSet.delete(decl); - } - } - } - } - if (statementsSet.size === 0) return true; - if (lastImportPath) lastImportPath.insertAfter(Array.from(statementsSet)); - return !!lastImportPath; - } -} -exports.default = ImportInjector; -function isValueImport(node) { - return node.importKind !== "type" && node.importKind !== "typeof"; -} -function hasNamespaceImport(node) { - return node.specifiers.length === 1 && node.specifiers[0].type === "ImportNamespaceSpecifier" || node.specifiers.length === 2 && node.specifiers[1].type === "ImportNamespaceSpecifier"; -} -function hasDefaultImport(node) { - return node.specifiers.length > 0 && node.specifiers[0].type === "ImportDefaultSpecifier"; -} -function maybeAppendImportSpecifiers(target, source) { - if (!target.specifiers.length) { - target.specifiers = source.specifiers; - return true; - } - if (!source.specifiers.length) return true; - if (hasNamespaceImport(target) || hasNamespaceImport(source)) return false; - if (hasDefaultImport(source)) { - if (hasDefaultImport(target)) { - source.specifiers[0] = importSpecifier(source.specifiers[0].local, identifier("default")); - } else { - target.specifiers.unshift(source.specifiers.shift()); - } - } - target.specifiers.push(...source.specifiers); - return true; -} - -//# sourceMappingURL=import-injector.js.map diff --git a/tools/eslint/node_modules/@babel/helper-module-imports/lib/index.js b/tools/eslint/node_modules/@babel/helper-module-imports/lib/index.js deleted file mode 100644 index 84f97fc5869778..00000000000000 --- a/tools/eslint/node_modules/@babel/helper-module-imports/lib/index.js +++ /dev/null @@ -1,37 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -Object.defineProperty(exports, "ImportInjector", { - enumerable: true, - get: function () { - return _importInjector.default; - } -}); -exports.addDefault = addDefault; -exports.addNamed = addNamed; -exports.addNamespace = addNamespace; -exports.addSideEffect = addSideEffect; -Object.defineProperty(exports, "isModule", { - enumerable: true, - get: function () { - return _isModule.default; - } -}); -var _importInjector = require("./import-injector.js"); -var _isModule = require("./is-module.js"); -function addDefault(path, importedSource, opts) { - return new _importInjector.default(path).addDefault(importedSource, opts); -} -function addNamed(path, name, importedSource, opts) { - return new _importInjector.default(path).addNamed(name, importedSource, opts); -} -function addNamespace(path, importedSource, opts) { - return new _importInjector.default(path).addNamespace(importedSource, opts); -} -function addSideEffect(path, importedSource, opts) { - return new _importInjector.default(path).addSideEffect(importedSource, opts); -} - -//# sourceMappingURL=index.js.map diff --git a/tools/eslint/node_modules/@babel/helper-module-imports/lib/is-module.js b/tools/eslint/node_modules/@babel/helper-module-imports/lib/is-module.js deleted file mode 100644 index 0bbda0139f95ef..00000000000000 --- a/tools/eslint/node_modules/@babel/helper-module-imports/lib/is-module.js +++ /dev/null @@ -1,11 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.default = isModule; -function isModule(path) { - return path.node.sourceType === "module"; -} - -//# sourceMappingURL=is-module.js.map diff --git a/tools/eslint/node_modules/@babel/helper-module-imports/package.json b/tools/eslint/node_modules/@babel/helper-module-imports/package.json deleted file mode 100644 index 005b2cb4e72dd7..00000000000000 --- a/tools/eslint/node_modules/@babel/helper-module-imports/package.json +++ /dev/null @@ -1,28 +0,0 @@ -{ - "name": "@babel/helper-module-imports", - "version": "7.24.7", - "description": "Babel helper functions for inserting module loads", - "author": "The Babel Team (https://babel.dev/team)", - "homepage": "https://babel.dev/docs/en/next/babel-helper-module-imports", - "license": "MIT", - "publishConfig": { - "access": "public" - }, - "repository": { - "type": "git", - "url": "https://github.com/babel/babel.git", - "directory": "packages/babel-helper-module-imports" - }, - "main": "./lib/index.js", - "dependencies": { - "@babel/traverse": "^7.24.7", - "@babel/types": "^7.24.7" - }, - "devDependencies": { - "@babel/core": "^7.24.7" - }, - "engines": { - "node": ">=6.9.0" - }, - "type": "commonjs" -} \ No newline at end of file diff --git a/tools/eslint/node_modules/@babel/helper-module-transforms/LICENSE b/tools/eslint/node_modules/@babel/helper-module-transforms/LICENSE deleted file mode 100644 index f31575ec773bb1..00000000000000 --- a/tools/eslint/node_modules/@babel/helper-module-transforms/LICENSE +++ /dev/null @@ -1,22 +0,0 @@ -MIT License - -Copyright (c) 2014-present Sebastian McKenzie and other contributors - -Permission is hereby granted, free of charge, to any person obtaining -a copy of this software and associated documentation files (the -"Software"), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sublicense, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/tools/eslint/node_modules/@babel/helper-module-transforms/lib/dynamic-import.js b/tools/eslint/node_modules/@babel/helper-module-transforms/lib/dynamic-import.js deleted file mode 100644 index 90fcea61419276..00000000000000 --- a/tools/eslint/node_modules/@babel/helper-module-transforms/lib/dynamic-import.js +++ /dev/null @@ -1,48 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.buildDynamicImport = buildDynamicImport; -var _core = require("@babel/core"); -{ - exports.getDynamicImportSource = function getDynamicImportSource(node) { - const [source] = node.arguments; - return _core.types.isStringLiteral(source) || _core.types.isTemplateLiteral(source) ? source : _core.template.expression.ast`\`\${${source}}\``; - }; -} -function buildDynamicImport(node, deferToThen, wrapWithPromise, builder) { - const specifier = _core.types.isCallExpression(node) ? node.arguments[0] : node.source; - if (_core.types.isStringLiteral(specifier) || _core.types.isTemplateLiteral(specifier) && specifier.quasis.length === 0) { - if (deferToThen) { - return _core.template.expression.ast` - Promise.resolve().then(() => ${builder(specifier)}) - `; - } else return builder(specifier); - } - const specifierToString = _core.types.isTemplateLiteral(specifier) ? _core.types.identifier("specifier") : _core.types.templateLiteral([_core.types.templateElement({ - raw: "" - }), _core.types.templateElement({ - raw: "" - })], [_core.types.identifier("specifier")]); - if (deferToThen) { - return _core.template.expression.ast` - (specifier => - new Promise(r => r(${specifierToString})) - .then(s => ${builder(_core.types.identifier("s"))}) - )(${specifier}) - `; - } else if (wrapWithPromise) { - return _core.template.expression.ast` - (specifier => - new Promise(r => r(${builder(specifierToString)})) - )(${specifier}) - `; - } else { - return _core.template.expression.ast` - (specifier => ${builder(specifierToString)})(${specifier}) - `; - } -} - -//# sourceMappingURL=dynamic-import.js.map diff --git a/tools/eslint/node_modules/@babel/helper-module-transforms/lib/get-module-name.js b/tools/eslint/node_modules/@babel/helper-module-transforms/lib/get-module-name.js deleted file mode 100644 index ee1307929f0347..00000000000000 --- a/tools/eslint/node_modules/@babel/helper-module-transforms/lib/get-module-name.js +++ /dev/null @@ -1,48 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.default = getModuleName; -{ - const originalGetModuleName = 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, - getModuleId: (_pluginOpts$getModule = pluginOpts.getModuleId) != null ? _pluginOpts$getModule : rootOpts.getModuleId, - moduleRoot: (_pluginOpts$moduleRoo = pluginOpts.moduleRoot) != null ? _pluginOpts$moduleRoo : rootOpts.moduleRoot - }); - }; -} -function getModuleName(rootOpts, pluginOpts) { - const { - filename, - filenameRelative = filename, - sourceRoot = pluginOpts.moduleRoot - } = rootOpts; - const { - moduleId, - moduleIds = !!moduleId, - getModuleId, - moduleRoot = sourceRoot - } = pluginOpts; - if (!moduleIds) return null; - 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 = moduleName.replace(/\\/g, "/"); - if (getModuleId) { - return getModuleId(moduleName) || moduleName; - } else { - return moduleName; - } -} - -//# sourceMappingURL=get-module-name.js.map diff --git a/tools/eslint/node_modules/@babel/helper-module-transforms/lib/index.js b/tools/eslint/node_modules/@babel/helper-module-transforms/lib/index.js deleted file mode 100644 index 35a44be5890fb5..00000000000000 --- a/tools/eslint/node_modules/@babel/helper-module-transforms/lib/index.js +++ /dev/null @@ -1,380 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -Object.defineProperty(exports, "buildDynamicImport", { - enumerable: true, - get: function () { - return _dynamicImport.buildDynamicImport; - } -}); -exports.buildNamespaceInitStatements = buildNamespaceInitStatements; -exports.ensureStatementsHoisted = ensureStatementsHoisted; -Object.defineProperty(exports, "getModuleName", { - enumerable: true, - get: function () { - return _getModuleName.default; - } -}); -Object.defineProperty(exports, "hasExports", { - enumerable: true, - get: function () { - return _normalizeAndLoadMetadata.hasExports; - } -}); -Object.defineProperty(exports, "isModule", { - enumerable: true, - get: function () { - return _helperModuleImports.isModule; - } -}); -Object.defineProperty(exports, "isSideEffectImport", { - enumerable: true, - get: function () { - return _normalizeAndLoadMetadata.isSideEffectImport; - } -}); -exports.rewriteModuleStatementsAndPrepareHeader = rewriteModuleStatementsAndPrepareHeader; -Object.defineProperty(exports, "rewriteThis", { - enumerable: true, - get: function () { - return _rewriteThis.default; - } -}); -exports.wrapInterop = wrapInterop; -var _assert = require("assert"); -var _core = require("@babel/core"); -var _helperModuleImports = require("@babel/helper-module-imports"); -var _rewriteThis = require("./rewrite-this.js"); -var _rewriteLiveReferences = require("./rewrite-live-references.js"); -var _normalizeAndLoadMetadata = require("./normalize-and-load-metadata.js"); -var Lazy = require("./lazy-modules.js"); -var _dynamicImport = require("./dynamic-import.js"); -var _getModuleName = require("./get-module-name.js"); -const { - booleanLiteral, - callExpression, - cloneNode, - directive, - directiveLiteral, - expressionStatement, - identifier, - isIdentifier, - memberExpression, - stringLiteral, - valueToNode, - variableDeclaration, - variableDeclarator -} = _core.types; -{ - exports.getDynamicImportSource = require("./dynamic-import").getDynamicImportSource; -} -function rewriteModuleStatementsAndPrepareHeader(path, { - exportName, - strict, - allowTopLevelThis, - strictMode, - noInterop, - importInterop = noInterop ? "none" : "babel", - lazy, - getWrapperPayload = Lazy.toGetWrapperPayload(lazy != null ? lazy : false), - wrapReference = Lazy.wrapReference, - esNamespaceOnly, - filename, - constantReexports = arguments[1].loose, - enumerableModuleMeta = arguments[1].loose, - 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, - initializeReexports: constantReexports, - getWrapperPayload, - esNamespaceOnly, - filename - }); - if (!allowTopLevelThis) { - (0, _rewriteThis.default)(path); - } - (0, _rewriteLiveReferences.default)(path, meta, wrapReference); - 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); - } - headers.push(...buildExportInitializationStatements(path, meta, wrapReference, constantReexports, noIncompleteNsImportDetection)); - return { - meta, - headers - }; -} -function ensureStatementsHoisted(statements) { - statements.forEach(header => { - header._blockHoist = 3; - }); -} -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") { - helper = "interopRequireWildcard"; - } else { - throw new Error(`Unknown interop: ${type}`); - } - return callExpression(programPath.hub.addHelper(helper), [expr]); -} -function buildNamespaceInitStatements(metadata, sourceMetadata, constantReexports = false, wrapReference = Lazy.wrapReference) { - var _wrapReference; - const statements = []; - const srcNamespaceId = identifier(sourceMetadata.name); - for (const localName of sourceMetadata.importsNamespace) { - if (localName === sourceMetadata.name) continue; - statements.push(_core.template.statement`var NAME = SOURCE;`({ - NAME: localName, - SOURCE: cloneNode(srcNamespaceId) - })); - } - const srcNamespace = (_wrapReference = wrapReference(srcNamespaceId, sourceMetadata.wrap)) != null ? _wrapReference : srcNamespaceId; - if (constantReexports) { - statements.push(...buildReexportsFromMeta(metadata, sourceMetadata, true, wrapReference)); - } - for (const exportName of sourceMetadata.reexportNamespace) { - statements.push((!_core.types.isIdentifier(srcNamespace) ? _core.template.statement` - Object.defineProperty(EXPORTS, "NAME", { - enumerable: true, - get: function() { - return NAMESPACE; - } - }); - ` : _core.template.statement`EXPORTS.NAME = NAMESPACE;`)({ - EXPORTS: metadata.exportName, - NAME: exportName, - 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: _core.template.statement`EXPORTS.EXPORT_NAME = NAMESPACE_IMPORT;`, - constantComputed: _core.template.statement`EXPORTS["EXPORT_NAME"] = NAMESPACE_IMPORT;`, - spec: _core.template.statement` - Object.defineProperty(EXPORTS, "EXPORT_NAME", { - enumerable: true, - get: function() { - return NAMESPACE_IMPORT; - }, - }); - ` -}; -function buildReexportsFromMeta(meta, metadata, constantReexports, wrapReference) { - var _wrapReference2; - let namespace = identifier(metadata.name); - namespace = (_wrapReference2 = wrapReference(namespace, metadata.wrap)) != null ? _wrapReference2 : namespace; - 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)) { - 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); - } else { - return ReexportTemplate.constant(astNodes); - } - } else { - return ReexportTemplate.spec(astNodes); - } - }); -} -function buildESModuleHeader(metadata, enumerableModuleMeta = false) { - return (enumerableModuleMeta ? _core.template.statement` - EXPORTS.__esModule = true; - ` : _core.template.statement` - Object.defineProperty(EXPORTS, "__esModule", { - value: true, - }); - `)({ - EXPORTS: metadata.exportName - }); -} -function buildNamespaceReexport(metadata, namespace, constantReexports) { - return (constantReexports ? _core.template.statement` - Object.keys(NAMESPACE).forEach(function(key) { - if (key === "default" || key === "__esModule") return; - VERIFY_NAME_LIST; - if (key in EXPORTS && EXPORTS[key] === NAMESPACE[key]) return; - - EXPORTS[key] = NAMESPACE[key]; - }); - ` : _core.template.statement` - Object.keys(NAMESPACE).forEach(function(key) { - if (key === "default" || key === "__esModule") return; - VERIFY_NAME_LIST; - if (key in EXPORTS && EXPORTS[key] === NAMESPACE[key]) return; - - Object.defineProperty(EXPORTS, key, { - enumerable: true, - get: function() { - return NAMESPACE[key]; - }, - }); - }); - `)({ - NAMESPACE: namespace, - EXPORTS: metadata.exportName, - VERIFY_NAME_LIST: metadata.exportNameListName ? (0, _core.template)` - if (Object.prototype.hasOwnProperty.call(EXPORTS_LIST, key)) return; - `({ - EXPORTS_LIST: metadata.exportNameListName - }) : null - }); -} -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; - return { - name: name.name, - statement: variableDeclaration("var", [variableDeclarator(name, valueToNode(exportedVars))]) - }; -} -function buildExportInitializationStatements(programPath, metadata, wrapReference, 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))]); - } 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, wrapReference); - 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]); - } - } - } - initStatements.sort(([a], [b]) => { - if (a < b) return -1; - if (b < a) return 1; - 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; -} -const InitTemplate = { - computed: _core.template.expression`EXPORTS["NAME"] = VALUE`, - default: _core.template.expression`EXPORTS.NAME = VALUE`, - define: _core.template.expression`Object.defineProperty(EXPORTS, "NAME", { enumerable:true, value: void 0, writable: true })["NAME"] = VALUE` -}; -function buildInitStatement(metadata, exportNames, initExpr) { - const { - stringSpecifiers, - exportName: EXPORTS - } = metadata; - return expressionStatement(exportNames.reduce((acc, exportName) => { - const params = { - EXPORTS, - NAME: exportName, - VALUE: acc - }; - if (exportName === "__proto__") { - return InitTemplate.define(params); - } - if (stringSpecifiers.has(exportName)) { - return InitTemplate.computed(params); - } - return InitTemplate.default(params); - }, initExpr)); -} - -//# sourceMappingURL=index.js.map diff --git a/tools/eslint/node_modules/@babel/helper-module-transforms/lib/lazy-modules.js b/tools/eslint/node_modules/@babel/helper-module-transforms/lib/lazy-modules.js deleted file mode 100644 index acc89fff266d2d..00000000000000 --- a/tools/eslint/node_modules/@babel/helper-module-transforms/lib/lazy-modules.js +++ /dev/null @@ -1,31 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.toGetWrapperPayload = toGetWrapperPayload; -exports.wrapReference = wrapReference; -var _core = require("@babel/core"); -var _normalizeAndLoadMetadata = require("./normalize-and-load-metadata.js"); -function toGetWrapperPayload(lazy) { - return (source, metadata) => { - if (lazy === false) return null; - if ((0, _normalizeAndLoadMetadata.isSideEffectImport)(metadata) || metadata.reexportAll) return null; - if (lazy === true) { - return source.includes(".") ? null : "lazy"; - } - if (Array.isArray(lazy)) { - return !lazy.includes(source) ? null : "lazy"; - } - if (typeof lazy === "function") { - return lazy(source) ? "lazy" : null; - } - throw new Error(`.lazy must be a boolean, string array, or function`); - }; -} -function wrapReference(ref, payload) { - if (payload === "lazy") return _core.types.callExpression(ref, []); - return null; -} - -//# sourceMappingURL=lazy-modules.js.map diff --git a/tools/eslint/node_modules/@babel/helper-module-transforms/lib/normalize-and-load-metadata.js b/tools/eslint/node_modules/@babel/helper-module-transforms/lib/normalize-and-load-metadata.js deleted file mode 100644 index 35d6757d24a69c..00000000000000 --- a/tools/eslint/node_modules/@babel/helper-module-transforms/lib/normalize-and-load-metadata.js +++ /dev/null @@ -1,358 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -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; -} -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; -} -function normalizeModuleAndLoadMetadata(programPath, exportName, { - importInterop, - initializeReexports = false, - getWrapperPayload, - esNamespaceOnly = false, - filename -}) { - if (!exportName) { - exportName = programPath.scope.generateUidIdentifier("exports").name; - } - const stringSpecifiers = new Set(); - nameAnonymousExports(programPath); - const { - local, - sources, - hasExports - } = getModuleMetadata(programPath, { - initializeReexports, - getWrapperPayload - }, stringSpecifiers); - removeImportExportDeclarations(programPath); - for (const [source, metadata] of sources) { - const { - importsNamespace, - imports - } = metadata; - if (importsNamespace.size > 0 && imports.size === 0) { - const [nameOfnamespace] = importsNamespace; - metadata.name = nameOfnamespace; - } - const resolvedInterop = resolveImportInterop(importInterop, source, filename); - if (resolvedInterop === "none") { - metadata.interop = "none"; - } else if (resolvedInterop === "node" && metadata.interop === "namespace") { - metadata.interop = "node-namespace"; - } else if (resolvedInterop === "node" && metadata.interop === "default") { - metadata.interop = "node-default"; - } else if (esNamespaceOnly && metadata.interop === "namespace") { - metadata.interop = "default"; - } - } - return { - exportName, - exportNameListName: null, - hasExports, - local, - source: sources, - 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; - } else if (path.isExportNamespaceSpecifier()) { - throw path.buildCodeFrameError("Export namespace should be first transformed by `@babel/plugin-transform-export-namespace-from`."); - } else { - throw path.buildCodeFrameError("Unexpected export specifier type"); - } -} -function getModuleMetadata(programPath, { - getWrapperPayload, - initializeReexports -}, stringSpecifiers) { - const localData = getLocalExportMetadata(programPath, initializeReexports, stringSpecifiers); - const importNodes = new Map(); - const sourceData = new Map(); - const getData = (sourceNode, node) => { - 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, - interop: "none", - loc: null, - imports: new Map(), - importsNamespace: new Set(), - reexports: new Map(), - reexportNamespace: new Set(), - reexportAll: null, - wrap: null, - get lazy() { - return this.wrap === "lazy"; - }, - referenced: false - }; - sourceData.set(source, data); - importNodes.set(source, [node]); - } else { - importNodes.get(source).push(node); - } - return data; - }; - let hasExports = false; - programPath.get("body").forEach(child => { - if (child.isImportDeclaration()) { - const data = getData(child.node.source, child.node); - if (!data.loc) data.loc = child.node.loc; - child.get("specifiers").forEach(spec => { - if (spec.isImportDefaultSpecifier()) { - 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 => { - data.reexports.set(name, "default"); - }); - data.referenced = true; - } - } else if (spec.isImportNamespaceSpecifier()) { - 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 => { - data.reexportNamespace.add(name); - }); - data.referenced = true; - } - } else if (spec.isImportSpecifier()) { - const importName = getExportSpecifierName(spec.get("imported"), stringSpecifiers); - 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 => { - data.reexports.set(name, importName); - }); - data.referenced = true; - } - } - }); - } else if (child.isExportAllDeclaration()) { - hasExports = true; - const data = getData(child.node.source, child.node); - if (!data.loc) data.loc = child.node.loc; - data.reexportAll = { - loc: child.node.loc - }; - data.referenced = true; - } else if (child.isExportNamedDeclaration() && child.node.source) { - hasExports = true; - const data = getData(child.node.source, child.node); - if (!data.loc) data.loc = child.node.loc; - child.get("specifiers").forEach(spec => { - assertExportSpecifier(spec); - const importName = getExportSpecifierName(spec.get("local"), stringSpecifiers); - const exportName = getExportSpecifierName(spec.get("exported"), stringSpecifiers); - data.reexports.set(exportName, importName); - data.referenced = true; - if (exportName === "__esModule") { - throw spec.get("exported").buildCodeFrameError('Illegal export "__esModule".'); - } - }); - } else if (child.isExportNamedDeclaration() || child.isExportDefaultDeclaration()) { - 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"; - } - } - if (getWrapperPayload) { - for (const [source, metadata] of sourceData) { - metadata.wrap = getWrapperPayload(source, metadata, importNodes.get(source)); - } - } - return { - hasExports, - local: localData, - sources: 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"); - } else if (initializeReexports && child.node.source && child.get("source").isStringLiteral()) { - child.get("specifiers").forEach(spec => { - assertExportSpecifier(spec); - bindingKindLookup.set(spec.get("local").node.name, "block"); - }); - return; - } - } - if (child.isFunctionDeclaration()) { - kind = "hoisted"; - } else if (child.isClassDeclaration()) { - kind = "block"; - } else if (child.isVariableDeclaration({ - kind: "var" - })) { - kind = "var"; - } else if (child.isVariableDeclaration()) { - kind = "block"; - } else { - 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) { - const declaration = child.get("declaration"); - const ids = declaration.getOuterBindingIdentifierPaths(); - Object.keys(ids).forEach(name => { - if (name === "__esModule") { - throw declaration.buildCodeFrameError('Illegal export "__esModule".'); - } - getLocalMetadata(ids[name]).names.push(name); - }); - } else { - child.get("specifiers").forEach(spec => { - const local = spec.get("local"); - 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 { - throw declaration.buildCodeFrameError("Unexpected default expression export."); - } - } - }); - return localMetadata; -} -function nameAnonymousExports(programPath) { - programPath.get("body").forEach(child => { - if (!child.isExportDefaultDeclaration()) return; - (0, _helperSplitExportDeclaration.default)(child); - }); -} -function removeImportExportDeclarations(programPath) { - programPath.get("body").forEach(child => { - if (child.isImportDeclaration()) { - child.remove(); - } else if (child.isExportNamedDeclaration()) { - if (child.node.declaration) { - child.node.declaration._blockHoist = child.node._blockHoist; - child.replaceWith(child.node.declaration); - } else { - child.remove(); - } - } else if (child.isExportDefaultDeclaration()) { - const declaration = child.get("declaration"); - if (declaration.isFunctionDeclaration() || declaration.isClassDeclaration()) { - declaration._blockHoist = child.node._blockHoist; - child.replaceWith(declaration); - } else { - throw declaration.buildCodeFrameError("Unexpected default expression export."); - } - } else if (child.isExportAllDeclaration()) { - child.remove(); - } - }); -} - -//# sourceMappingURL=normalize-and-load-metadata.js.map diff --git a/tools/eslint/node_modules/@babel/helper-module-transforms/lib/rewrite-live-references.js b/tools/eslint/node_modules/@babel/helper-module-transforms/lib/rewrite-live-references.js deleted file mode 100644 index 6ada457a4db5c5..00000000000000 --- a/tools/eslint/node_modules/@babel/helper-module-transforms/lib/rewrite-live-references.js +++ /dev/null @@ -1,376 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.default = rewriteLiveReferences; -var _assert = require("assert"); -var _core = require("@babel/core"); -var _helperSimpleAccess = require("@babel/helper-simple-access"); -const { - assignmentExpression, - cloneNode, - expressionStatement, - getOuterBindingIdentifiers, - identifier, - isArrowFunctionExpression, - isClassExpression, - isFunctionExpression, - isIdentifier, - isMemberExpression, - isVariableDeclaration, - jsxIdentifier, - jsxMemberExpression, - memberExpression, - numericLiteral, - sequenceExpression, - stringLiteral, - variableDeclaration, - variableDeclarator -} = _core.types; -function isInType(path) { - do { - switch (path.parent.type) { - case "TSTypeAnnotation": - case "TSTypeAliasDeclaration": - case "TSTypeReference": - 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, wrapReference) { - 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); - } - const rewriteBindingInitVisitorState = { - metadata, - requeueInParent, - scope: programPath.scope, - exported - }; - programPath.traverse(rewriteBindingInitVisitor, rewriteBindingInitVisitorState); - const bindingNames = new Set([...Array.from(imported.keys()), ...Array.from(exported.keys())]); - { - (0, _helperSimpleAccess.default)(programPath, bindingNames, false); - } - const rewriteReferencesVisitorState = { - seen: new WeakSet(), - metadata, - requeueInParent, - scope: programPath.scope, - imported, - exported, - buildImportReference([source, importName, localName], identNode) { - const meta = metadata.source.get(source); - meta.referenced = true; - if (localName) { - if (meta.wrap) { - var _wrapReference; - identNode = (_wrapReference = wrapReference(identNode, meta.wrap)) != null ? _wrapReference : identNode; - } - return identNode; - } - let namespace = identifier(meta.name); - if (meta.wrap) { - var _wrapReference2; - namespace = (_wrapReference2 = wrapReference(namespace, meta.wrap)) != null ? _wrapReference2 : 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); - } - }; - programPath.traverse(rewriteReferencesVisitor, rewriteReferencesVisitorState); -} -const rewriteBindingInitVisitor = { - Scope(path) { - path.skip(); - }, - ClassDeclaration(path) { - const { - requeueInParent, - exported, - metadata - } = this; - const { - id - } = path.node; - 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)); - statement._blockHoist = path.node._blockHoist; - requeueInParent(path.insertAfter(statement)[0]); - } - }, - VariableDeclaration(path) { - const { - requeueInParent, - exported, - metadata - } = this; - const isVar = path.node.kind === "var"; - for (const decl of path.get("declarations")) { - const { - id - } = decl.node; - let { - init - } = decl.node; - if (isIdentifier(id) && exported.has(id.name) && !isArrowFunctionExpression(init) && (!isFunctionExpression(init) || init.id) && (!isClassExpression(init) || init.id)) { - if (!init) { - if (isVar) { - continue; - } else { - init = path.scope.buildUndefinedNode(); - } - } - decl.node.init = buildBindingExportAssignmentExpression(metadata, exported.get(id.name), init, path.scope); - requeueInParent(decl.get("init")); - } else { - for (const localName of Object.keys(decl.getOuterBindingIdentifiers())) { - if (exported.has(localName)) { - const statement = expressionStatement(buildBindingExportAssignmentExpression(metadata, exported.get(localName), 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 - } = metadata; - const computed = stringSpecifiers.has(exportName); - return assignmentExpression("=", memberExpression(identifier(exportsObjectName), computed ? stringLiteral(exportName) : identifier(exportName), computed), expr); - }, localExpr); -}; -const buildImportThrow = localName => { - return _core.template.expression.ast` - (function() { - throw new Error('"' + '${localName}' + '" is read-only.'); - })() - `; -}; -const rewriteReferencesVisitor = { - ReferencedIdentifier(path) { - const { - seen, - buildImportReference, - scope, - imported, - requeueInParent - } = this; - if (seen.has(path.node)) return; - 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; - if ((path.parentPath.isCallExpression({ - callee: path.node - }) || path.parentPath.isOptionalCallExpression({ - callee: path.node - }) || path.parentPath.isTaggedTemplateExpression({ - tag: path.node - })) && isMemberExpression(ref)) { - path.replaceWith(sequenceExpression([numericLiteral(0), ref])); - } else if (path.isJSXIdentifier() && isMemberExpression(ref)) { - const { - object, - property - } = ref; - path.replaceWith(jsxMemberExpression(jsxIdentifier(object.name), jsxIdentifier(property.name))); - } else { - path.replaceWith(ref); - } - requeueInParent(path); - path.skip(); - } - }, - UpdateExpression(path) { - const { - scope, - seen, - imported, - exported, - requeueInParent, - buildImportReference - } = this; - 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))); - } else if (update.prefix) { - path.replaceWith(buildBindingExportAssignmentExpression(this.metadata, exportedNames, cloneNode(update), path.scope)); - } else { - const ref = scope.generateDeclaredUidIdentifier(localName); - path.replaceWith(sequenceExpression([assignmentExpression("=", cloneNode(ref), cloneNode(update)), buildBindingExportAssignmentExpression(this.metadata, exportedNames, identifier(localName), path.scope), cloneNode(ref)])); - } - } - } - requeueInParent(path); - path.skip(); - }, - AssignmentExpression: { - exit(path) { - const { - scope, - seen, - imported, - exported, - requeueInParent, - buildImportReference - } = this; - if (seen.has(path.node)) return; - seen.add(path.node); - const left = path.get("left"); - 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); - } - } else { - 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)]); - } - 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, - node - } = path; - const { - left - } = node; - const { - exported, - imported, - scope: programScope - } = this; - if (!isVariableDeclaration(left)) { - let didTransformExport = false, - 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 diff --git a/tools/eslint/node_modules/@babel/helper-module-transforms/lib/rewrite-this.js b/tools/eslint/node_modules/@babel/helper-module-transforms/lib/rewrite-this.js deleted file mode 100644 index e79d9d1b96d601..00000000000000 --- a/tools/eslint/node_modules/@babel/helper-module-transforms/lib/rewrite-this.js +++ /dev/null @@ -1,24 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.default = rewriteThis; -var _helperEnvironmentVisitor = require("@babel/helper-environment-visitor"); -var _core = require("@babel/core"); -const { - numericLiteral, - unaryExpression -} = _core.types; -const rewriteThisVisitor = _core.traverse.visitors.merge([_helperEnvironmentVisitor.default, { - ThisExpression(path) { - path.replaceWith(unaryExpression("void", numericLiteral(0), true)); - } -}]); -function rewriteThis(programPath) { - (0, _core.traverse)(programPath.node, Object.assign({}, rewriteThisVisitor, { - noScope: true - })); -} - -//# sourceMappingURL=rewrite-this.js.map diff --git a/tools/eslint/node_modules/@babel/helper-module-transforms/package.json b/tools/eslint/node_modules/@babel/helper-module-transforms/package.json deleted file mode 100644 index 778cc453a52273..00000000000000 --- a/tools/eslint/node_modules/@babel/helper-module-transforms/package.json +++ /dev/null @@ -1,34 +0,0 @@ -{ - "name": "@babel/helper-module-transforms", - "version": "7.24.8", - "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", - "license": "MIT", - "publishConfig": { - "access": "public" - }, - "repository": { - "type": "git", - "url": "https://github.com/babel/babel.git", - "directory": "packages/babel-helper-module-transforms" - }, - "main": "./lib/index.js", - "dependencies": { - "@babel/helper-environment-visitor": "^7.24.7", - "@babel/helper-module-imports": "^7.24.7", - "@babel/helper-simple-access": "^7.24.7", - "@babel/helper-split-export-declaration": "^7.24.7", - "@babel/helper-validator-identifier": "^7.24.7" - }, - "devDependencies": { - "@babel/core": "^7.24.8" - }, - "peerDependencies": { - "@babel/core": "^7.0.0" - }, - "engines": { - "node": ">=6.9.0" - }, - "type": "commonjs" -} \ No newline at end of file diff --git a/tools/eslint/node_modules/@babel/helper-plugin-utils/LICENSE b/tools/eslint/node_modules/@babel/helper-plugin-utils/LICENSE deleted file mode 100644 index f31575ec773bb1..00000000000000 --- a/tools/eslint/node_modules/@babel/helper-plugin-utils/LICENSE +++ /dev/null @@ -1,22 +0,0 @@ -MIT License - -Copyright (c) 2014-present Sebastian McKenzie and other contributors - -Permission is hereby granted, free of charge, to any person obtaining -a copy of this software and associated documentation files (the -"Software"), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sublicense, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/tools/eslint/node_modules/@babel/helper-plugin-utils/lib/index.js b/tools/eslint/node_modules/@babel/helper-plugin-utils/lib/index.js deleted file mode 100644 index b8b736624fc532..00000000000000 --- a/tools/eslint/node_modules/@babel/helper-plugin-utils/lib/index.js +++ /dev/null @@ -1,77 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.declare = declare; -exports.declarePreset = void 0; -const apiPolyfills = { - assertVersion: api => range => { - throwVersionError(range, api.version); - } -}; -{ - Object.assign(apiPolyfills, { - targets: () => () => { - return {}; - }, - assumption: () => () => { - 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) != null ? _clonedApi : clonedApi = copyApiObject(api); - clonedApi[name] = apiPolyfills[name](clonedApi); - } - return builder((_clonedApi2 = clonedApi) != null ? _clonedApi2 : api, options || {}, dirname); - }; -} -const declarePreset = exports.declarePreset = declare; -function copyApiObject(api) { - let proto = null; - if (typeof api.version === "string" && /^7\./.test(api.version)) { - proto = Object.getPrototypeOf(api); - if (proto && (!hasOwnProperty.call(proto, "version") || !hasOwnProperty.call(proto, "transform") || !hasOwnProperty.call(proto, "template") || !hasOwnProperty.call(proto, "types"))) { - proto = null; - } - } - return Object.assign({}, proto, api); -} -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, - range - }); -} - -//# sourceMappingURL=index.js.map diff --git a/tools/eslint/node_modules/@babel/helper-plugin-utils/package.json b/tools/eslint/node_modules/@babel/helper-plugin-utils/package.json deleted file mode 100644 index 1a25302665ad6b..00000000000000 --- a/tools/eslint/node_modules/@babel/helper-plugin-utils/package.json +++ /dev/null @@ -1,24 +0,0 @@ -{ - "name": "@babel/helper-plugin-utils", - "version": "7.24.8", - "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", - "license": "MIT", - "publishConfig": { - "access": "public" - }, - "repository": { - "type": "git", - "url": "https://github.com/babel/babel.git", - "directory": "packages/babel-helper-plugin-utils" - }, - "main": "./lib/index.js", - "engines": { - "node": ">=6.9.0" - }, - "devDependencies": { - "@babel/core": "^7.24.8" - }, - "type": "commonjs" -} \ No newline at end of file diff --git a/tools/eslint/node_modules/@babel/helper-plugin-utils/tsconfig.tsbuildinfo b/tools/eslint/node_modules/@babel/helper-plugin-utils/tsconfig.tsbuildinfo deleted file mode 100644 index 5b2b84458a8af5..00000000000000 --- a/tools/eslint/node_modules/@babel/helper-plugin-utils/tsconfig.tsbuildinfo +++ /dev/null @@ -1 +0,0 @@ -{"program":{"fileNames":["../../node_modules/typescript/lib/lib.es5.d.ts","../../node_modules/typescript/lib/lib.es2015.d.ts","../../node_modules/typescript/lib/lib.es2016.d.ts","../../node_modules/typescript/lib/lib.es2017.d.ts","../../node_modules/typescript/lib/lib.es2018.d.ts","../../node_modules/typescript/lib/lib.es2019.d.ts","../../node_modules/typescript/lib/lib.es2020.d.ts","../../node_modules/typescript/lib/lib.es2021.d.ts","../../node_modules/typescript/lib/lib.es2022.d.ts","../../node_modules/typescript/lib/lib.es2023.d.ts","../../node_modules/typescript/lib/lib.esnext.d.ts","../../node_modules/typescript/lib/lib.es2015.core.d.ts","../../node_modules/typescript/lib/lib.es2015.collection.d.ts","../../node_modules/typescript/lib/lib.es2015.generator.d.ts","../../node_modules/typescript/lib/lib.es2015.iterable.d.ts","../../node_modules/typescript/lib/lib.es2015.promise.d.ts","../../node_modules/typescript/lib/lib.es2015.proxy.d.ts","../../node_modules/typescript/lib/lib.es2015.reflect.d.ts","../../node_modules/typescript/lib/lib.es2015.symbol.d.ts","../../node_modules/typescript/lib/lib.es2015.symbol.wellknown.d.ts","../../node_modules/typescript/lib/lib.es2016.array.include.d.ts","../../node_modules/typescript/lib/lib.es2016.intl.d.ts","../../node_modules/typescript/lib/lib.es2017.date.d.ts","../../node_modules/typescript/lib/lib.es2017.object.d.ts","../../node_modules/typescript/lib/lib.es2017.sharedmemory.d.ts","../../node_modules/typescript/lib/lib.es2017.string.d.ts","../../node_modules/typescript/lib/lib.es2017.intl.d.ts","../../node_modules/typescript/lib/lib.es2017.typedarrays.d.ts","../../node_modules/typescript/lib/lib.es2018.asyncgenerator.d.ts","../../node_modules/typescript/lib/lib.es2018.asynciterable.d.ts","../../node_modules/typescript/lib/lib.es2018.intl.d.ts","../../node_modules/typescript/lib/lib.es2018.promise.d.ts","../../node_modules/typescript/lib/lib.es2018.regexp.d.ts","../../node_modules/typescript/lib/lib.es2019.array.d.ts","../../node_modules/typescript/lib/lib.es2019.object.d.ts","../../node_modules/typescript/lib/lib.es2019.string.d.ts","../../node_modules/typescript/lib/lib.es2019.symbol.d.ts","../../node_modules/typescript/lib/lib.es2019.intl.d.ts","../../node_modules/typescript/lib/lib.es2020.bigint.d.ts","../../node_modules/typescript/lib/lib.es2020.date.d.ts","../../node_modules/typescript/lib/lib.es2020.promise.d.ts","../../node_modules/typescript/lib/lib.es2020.sharedmemory.d.ts","../../node_modules/typescript/lib/lib.es2020.string.d.ts","../../node_modules/typescript/lib/lib.es2020.symbol.wellknown.d.ts","../../node_modules/typescript/lib/lib.es2020.intl.d.ts","../../node_modules/typescript/lib/lib.es2020.number.d.ts","../../node_modules/typescript/lib/lib.es2021.promise.d.ts","../../node_modules/typescript/lib/lib.es2021.string.d.ts","../../node_modules/typescript/lib/lib.es2021.weakref.d.ts","../../node_modules/typescript/lib/lib.es2021.intl.d.ts","../../node_modules/typescript/lib/lib.es2022.array.d.ts","../../node_modules/typescript/lib/lib.es2022.error.d.ts","../../node_modules/typescript/lib/lib.es2022.intl.d.ts","../../node_modules/typescript/lib/lib.es2022.object.d.ts","../../node_modules/typescript/lib/lib.es2022.sharedmemory.d.ts","../../node_modules/typescript/lib/lib.es2022.string.d.ts","../../node_modules/typescript/lib/lib.es2022.regexp.d.ts","../../node_modules/typescript/lib/lib.es2023.array.d.ts","../../node_modules/typescript/lib/lib.es2023.collection.d.ts","../../node_modules/typescript/lib/lib.es2023.intl.d.ts","../../node_modules/typescript/lib/lib.esnext.array.d.ts","../../node_modules/typescript/lib/lib.esnext.collection.d.ts","../../node_modules/typescript/lib/lib.esnext.intl.d.ts","../../node_modules/typescript/lib/lib.esnext.disposable.d.ts","../../node_modules/typescript/lib/lib.esnext.string.d.ts","../../node_modules/typescript/lib/lib.esnext.promise.d.ts","../../node_modules/typescript/lib/lib.esnext.decorators.d.ts","../../node_modules/typescript/lib/lib.esnext.object.d.ts","../../node_modules/typescript/lib/lib.esnext.regexp.d.ts","../../node_modules/typescript/lib/lib.decorators.d.ts","../../node_modules/typescript/lib/lib.decorators.legacy.d.ts","../../node_modules/js-tokens-BABEL_8_BREAKING-true/index.d.ts","../../node_modules/@types/charcodes/index.d.ts","../babel-helper-validator-identifier/src/identifier.ts","../babel-helper-validator-identifier/src/keyword.ts","../babel-helper-validator-identifier/src/index.ts","../../node_modules/picocolors/types.ts","../../node_modules/picocolors/picocolors.d.ts","../babel-highlight/src/index.ts","../babel-code-frame/src/index.ts","../babel-types/src/utils/shallowEqual.ts","../babel-types/src/utils/deprecationWarning.ts","../babel-types/src/validators/generated/index.ts","../babel-types/src/validators/matchesPattern.ts","../babel-types/src/validators/buildMatchMemberExpression.ts","../babel-types/src/validators/react/isReactComponent.ts","../babel-types/src/validators/react/isCompatTag.ts","../../node_modules/to-fast-properties-BABEL_8_BREAKING-true/index.d.ts","../babel-types/src/validators/isType.ts","../babel-types/src/validators/isPlaceholderType.ts","../babel-types/src/validators/is.ts","../babel-types/src/validators/isValidIdentifier.ts","../babel-helper-string-parser/src/index.ts","../babel-types/src/constants/index.ts","../babel-types/src/definitions/utils.ts","../babel-types/src/definitions/core.ts","../babel-types/src/definitions/flow.ts","../babel-types/src/definitions/jsx.ts","../babel-types/src/definitions/placeholders.ts","../babel-types/src/definitions/misc.ts","../babel-types/src/definitions/experimental.ts","../babel-types/src/definitions/typescript.ts","../babel-types/src/definitions/deprecated-aliases.ts","../babel-types/src/definitions/index.ts","../babel-types/src/validators/validate.ts","../babel-types/src/builders/validateNode.ts","../babel-types/src/builders/generated/index.ts","../babel-types/src/utils/react/cleanJSXElementLiteralChild.ts","../babel-types/src/builders/react/buildChildren.ts","../babel-types/src/validators/isNode.ts","../babel-types/src/asserts/assertNode.ts","../babel-types/src/asserts/generated/index.ts","../babel-types/src/builders/flow/createTypeAnnotationBasedOnTypeof.ts","../babel-types/src/modifications/flow/removeTypeDuplicates.ts","../babel-types/src/builders/flow/createFlowUnionType.ts","../babel-types/src/modifications/typescript/removeTypeDuplicates.ts","../babel-types/src/builders/typescript/createTSUnionType.ts","../babel-types/src/builders/generated/uppercase.d.ts","../babel-types/src/builders/productions.ts","../babel-types/src/clone/cloneNode.ts","../babel-types/src/clone/clone.ts","../babel-types/src/clone/cloneDeep.ts","../babel-types/src/clone/cloneDeepWithoutLoc.ts","../babel-types/src/clone/cloneWithoutLoc.ts","../babel-types/src/comments/addComments.ts","../babel-types/src/comments/addComment.ts","../babel-types/src/utils/inherit.ts","../babel-types/src/comments/inheritInnerComments.ts","../babel-types/src/comments/inheritLeadingComments.ts","../babel-types/src/comments/inheritTrailingComments.ts","../babel-types/src/comments/inheritsComments.ts","../babel-types/src/comments/removeComments.ts","../babel-types/src/constants/generated/index.ts","../babel-types/src/converters/toBlock.ts","../babel-types/src/converters/ensureBlock.ts","../babel-types/src/converters/toIdentifier.ts","../babel-types/src/converters/toBindingIdentifierName.ts","../babel-types/src/converters/toComputedKey.ts","../babel-types/src/converters/toExpression.ts","../babel-types/src/traverse/traverseFast.ts","../babel-types/src/modifications/removeProperties.ts","../babel-types/src/modifications/removePropertiesDeep.ts","../babel-types/src/converters/toKeyAlias.ts","../babel-types/src/converters/toStatement.ts","../babel-types/src/converters/valueToNode.ts","../babel-types/src/modifications/appendToMemberExpression.ts","../babel-types/src/modifications/inherits.ts","../babel-types/src/modifications/prependToMemberExpression.ts","../babel-types/src/retrievers/getBindingIdentifiers.ts","../babel-types/src/retrievers/getOuterBindingIdentifiers.ts","../babel-types/src/traverse/traverse.ts","../babel-types/src/validators/isBinding.ts","../babel-types/src/validators/isLet.ts","../babel-types/src/validators/isBlockScoped.ts","../babel-types/src/validators/isImmutable.ts","../babel-types/src/validators/isNodesEquivalent.ts","../babel-types/src/validators/isReferenced.ts","../babel-types/src/validators/isScope.ts","../babel-types/src/validators/isSpecifierDefault.ts","../babel-types/src/validators/isValidES3Identifier.ts","../babel-types/src/validators/isVar.ts","../babel-types/src/ast-types/generated/index.ts","../babel-types/src/index.ts","../babel-template/src/formatters.ts","../babel-parser/src/util/location.ts","../babel-parser/src/tokenizer/context.ts","../babel-parser/src/tokenizer/types.ts","../babel-parser/src/parse-error/module-errors.ts","../babel-parser/src/parse-error/to-node-description.ts","../babel-parser/src/parse-error/standard-errors.ts","../babel-parser/src/parse-error/strict-mode-errors.ts","../babel-parser/src/parse-error/pipeline-operator-errors.ts","../babel-parser/src/parse-error.ts","../../scripts/babel-plugin-bit-decorator/types.d.ts","../babel-parser/src/tokenizer/state.ts","../babel-parser/src/util/scopeflags.ts","../babel-parser/src/util/scope.ts","../babel-parser/src/util/expression-scope.ts","../babel-parser/src/util/class-scope.ts","../babel-parser/src/util/production-parameter.ts","../babel-parser/src/typings.d.ts","../babel-parser/src/parser/base.ts","../babel-parser/src/util/whitespace.ts","../babel-parser/src/util/identifier.ts","../babel-parser/src/parser/util.ts","../babel-parser/src/parser/node.ts","../babel-parser/src/parser/comments.ts","../babel-parser/src/tokenizer/index.ts","../babel-parser/src/plugins/placeholders.ts","../babel-parser/src/types.ts","../babel-parser/src/parser/lval.ts","../babel-parser/src/parser/expression.ts","../babel-parser/src/parser/statement.ts","../babel-parser/src/parser/index.ts","../babel-parser/src/plugins/estree.ts","../babel-parser/src/plugins/flow/scope.ts","../babel-parser/src/plugins/flow/index.ts","../babel-parser/src/plugins/jsx/xhtml.ts","../babel-parser/src/plugins/jsx/index.ts","../babel-parser/src/plugins/typescript/scope.ts","../babel-parser/src/plugins/typescript/index.ts","../babel-parser/src/plugins/v8intrinsic.ts","../babel-parser/src/plugin-utils.ts","../babel-parser/src/options.ts","../babel-parser/src/index.ts","../babel-template/src/options.ts","../babel-template/src/parse.ts","../babel-template/src/populate.ts","../babel-template/src/string.ts","../babel-template/src/literal.ts","../babel-template/src/builder.ts","../babel-template/src/index.ts","../babel-helpers/src/helpers-generated.ts","../babel-helpers/src/index.ts","../babel-traverse/src/path/lib/virtual-types.ts","../babel-traverse/src/scope/binding.ts","../babel-helper-split-export-declaration/src/index.ts","../babel-helper-environment-visitor/src/index.ts","../babel-traverse/src/generated/visitor-types.d.ts","../babel-traverse/src/types.ts","../babel-traverse/src/context.ts","../babel-traverse/src/traverse-node.ts","../babel-traverse/src/scope/lib/renamer.ts","../../node_modules/globals-BABEL_8_BREAKING-true/index.d.ts","../babel-traverse/src/cache.ts","../babel-traverse/src/scope/index.ts","../babel-traverse/src/hub.ts","../../node_modules/@types/debug/index.d.ts","../../node_modules/@jridgewell/trace-mapping/dist/types/sourcemap-segment.d.ts","../../node_modules/@jridgewell/trace-mapping/dist/types/types.d.ts","../../node_modules/@jridgewell/trace-mapping/dist/types/any-map.d.ts","../../node_modules/@jridgewell/trace-mapping/dist/types/trace-mapping.d.ts","../../node_modules/@jridgewell/gen-mapping/dist/types/sourcemap-segment.d.ts","../../node_modules/@jridgewell/gen-mapping/dist/types/types.d.ts","../../node_modules/@jridgewell/gen-mapping/dist/types/gen-mapping.d.ts","../babel-generator/src/source-map.ts","../babel-generator/src/buffer.ts","../babel-generator/src/node/whitespace.ts","../babel-generator/src/node/parentheses.ts","../babel-generator/src/node/index.ts","../../node_modules/@types/jsesc/index.d.ts","../babel-generator/src/generators/template-literals.ts","../babel-generator/src/generators/expressions.ts","../babel-generator/src/generators/statements.ts","../babel-generator/src/generators/classes.ts","../babel-generator/src/generators/methods.ts","../babel-generator/src/generators/modules.ts","../babel-generator/src/generators/types.ts","../babel-generator/src/generators/flow.ts","../babel-generator/src/generators/base.ts","../babel-generator/src/generators/jsx.ts","../babel-generator/src/generators/typescript.ts","../babel-generator/src/generators/index.ts","../babel-generator/src/printer.ts","../babel-generator/src/index.ts","../babel-traverse/src/path/ancestry.ts","../babel-traverse/src/path/inference/util.ts","../babel-traverse/src/path/inference/inferer-reference.ts","../babel-traverse/src/path/inference/inferers.ts","../babel-traverse/src/path/inference/index.ts","../babel-traverse/src/path/lib/hoister.ts","../babel-traverse/src/path/lib/removal-hooks.ts","../babel-traverse/src/path/removal.ts","../babel-traverse/src/path/context.ts","../babel-traverse/src/path/modification.ts","../babel-helper-hoist-variables/src/index.ts","../babel-traverse/src/path/replacement.ts","../babel-traverse/src/path/evaluation.ts","../babel-helper-function-name/src/index.ts","../babel-traverse/src/path/conversion.ts","../babel-traverse/src/path/introspection.ts","../babel-traverse/src/path/family.ts","../babel-traverse/src/path/comments.ts","../babel-traverse/src/path/generated/asserts.d.ts","../babel-traverse/src/path/generated/validators.d.ts","../babel-traverse/src/path/index.ts","../babel-traverse/src/path/lib/virtual-types-validator.ts","../babel-traverse/src/visitors.ts","../babel-traverse/src/index.ts","../babel-core/node_modules/@types/semver/index.d.ts","../../node_modules/@types/gensync/index.d.ts","../babel-core/src/gensync-utils/async.ts","../../node_modules/browserslist/index.d.ts","../babel-helper-validator-option/src/find-suggestion.ts","../babel-helper-validator-option/src/validator.ts","../babel-helper-validator-option/src/index.ts","../babel-compat-data/data/native-modules.json","../../node_modules/@types/lru-cache/index.d.ts","../babel-helper-compilation-targets/node_modules/@types/semver/index.d.ts","../babel-helper-compilation-targets/src/targets.ts","../babel-helper-compilation-targets/src/types.d.ts","../babel-helper-compilation-targets/src/utils.ts","../babel-helper-compilation-targets/src/options.ts","../babel-helper-compilation-targets/src/pretty.ts","../babel-helper-compilation-targets/src/debug.ts","../babel-compat-data/data/plugins.json","../babel-helper-compilation-targets/src/filter-items.ts","../babel-helper-compilation-targets/src/index.ts","../babel-core/src/gensync-utils/functional.ts","../babel-core/src/config/caching.ts","../babel-core/src/gensync-utils/fs.ts","../babel-core/src/config/files/utils.ts","../babel-core/src/config/files/types.ts","../babel-core/src/errors/rewrite-stack-trace.ts","../babel-core/src/errors/config-error.ts","../babel-core/src/config/files/package.ts","../../node_modules/json5/lib/parse.d.ts","../../node_modules/json5/lib/stringify.d.ts","../../node_modules/json5/lib/index.d.ts","../babel-core/src/config/pattern-to-regex.ts","../babel-core/src/config/printer.ts","../babel-core/src/config/helpers/deep-array.ts","../babel-core/src/config/config-chain.ts","../babel-core/src/config/cache-contexts.ts","../babel-core/src/config/helpers/config-api.ts","../babel-core/src/transformation/plugin-pass.ts","../babel-core/src/config/validation/option-assertions.ts","../babel-core/src/config/validation/plugins.ts","../babel-core/src/config/plugin.ts","../babel-core/src/transformation/block-hoist-plugin.ts","../babel-core/src/transformation/normalize-opts.ts","../../node_modules/@types/convert-source-map/index.d.ts","../../node_modules/@ampproject/remapping/dist/types/types.d.ts","../../node_modules/@ampproject/remapping/dist/types/source-map.d.ts","../../node_modules/@ampproject/remapping/dist/types/remapping.d.ts","../babel-core/src/transformation/file/merge-map.ts","../babel-core/src/transformation/file/generate.ts","../babel-core/src/transformation/index.ts","../babel-core/src/transform-file-browser.ts","../babel-core/src/transform-file.ts","../babel-core/src/config/files/module-types.ts","../babel-core/src/config/files/configuration.ts","../babel-core/src/vendor/import-meta-resolve.d.ts","../babel-core/src/config/files/plugins.ts","../babel-core/src/config/files/index-browser.ts","../babel-core/src/config/files/index.ts","../babel-core/src/config/resolve-targets-browser.ts","../babel-core/src/config/resolve-targets.ts","../babel-core/src/config/config-descriptors.ts","../babel-core/src/config/item.ts","../babel-core/src/config/validation/removed.ts","../babel-core/src/config/validation/options.ts","../babel-core/src/config/util.ts","../babel-core/src/config/helpers/environment.ts","../babel-core/src/config/partial.ts","../babel-core/src/config/full.ts","../babel-core/src/config/index.ts","../babel-core/src/parser/util/missing-plugin-helper.ts","../babel-core/src/parser/index.ts","../babel-core/src/transformation/util/clone-deep.ts","../babel-core/src/transformation/normalize-file.ts","../babel-core/src/transformation/file/file.ts","../babel-core/src/tools/build-external-helpers.ts","../babel-core/src/transform.ts","../babel-core/src/transform-ast.ts","../babel-core/src/parse.ts","../babel-core/src/index.ts","../babel-helper-check-duplicate-nodes/src/index.ts","../../node_modules/@types/semver/classes/semver.d.ts","../../node_modules/@types/semver/functions/parse.d.ts","../../node_modules/@types/semver/functions/valid.d.ts","../../node_modules/@types/semver/functions/clean.d.ts","../../node_modules/@types/semver/functions/inc.d.ts","../../node_modules/@types/semver/functions/diff.d.ts","../../node_modules/@types/semver/functions/major.d.ts","../../node_modules/@types/semver/functions/minor.d.ts","../../node_modules/@types/semver/functions/patch.d.ts","../../node_modules/@types/semver/functions/prerelease.d.ts","../../node_modules/@types/semver/functions/compare.d.ts","../../node_modules/@types/semver/functions/rcompare.d.ts","../../node_modules/@types/semver/functions/compare-loose.d.ts","../../node_modules/@types/semver/functions/compare-build.d.ts","../../node_modules/@types/semver/functions/sort.d.ts","../../node_modules/@types/semver/functions/rsort.d.ts","../../node_modules/@types/semver/functions/gt.d.ts","../../node_modules/@types/semver/functions/lt.d.ts","../../node_modules/@types/semver/functions/eq.d.ts","../../node_modules/@types/semver/functions/neq.d.ts","../../node_modules/@types/semver/functions/gte.d.ts","../../node_modules/@types/semver/functions/lte.d.ts","../../node_modules/@types/semver/functions/cmp.d.ts","../../node_modules/@types/semver/functions/coerce.d.ts","../../node_modules/@types/semver/classes/comparator.d.ts","../../node_modules/@types/semver/classes/range.d.ts","../../node_modules/@types/semver/functions/satisfies.d.ts","../../node_modules/@types/semver/ranges/max-satisfying.d.ts","../../node_modules/@types/semver/ranges/min-satisfying.d.ts","../../node_modules/@types/semver/ranges/to-comparators.d.ts","../../node_modules/@types/semver/ranges/min-version.d.ts","../../node_modules/@types/semver/ranges/valid.d.ts","../../node_modules/@types/semver/ranges/outside.d.ts","../../node_modules/@types/semver/ranges/gtr.d.ts","../../node_modules/@types/semver/ranges/ltr.d.ts","../../node_modules/@types/semver/ranges/intersects.d.ts","../../node_modules/@types/semver/ranges/simplify.d.ts","../../node_modules/@types/semver/ranges/subset.d.ts","../../node_modules/@types/semver/internals/identifiers.d.ts","../../node_modules/@types/semver/index.d.ts","../babel-helper-fixtures/src/index.ts","../babel-helper-module-imports/src/import-builder.ts","../babel-helper-module-imports/src/is-module.ts","../babel-helper-module-imports/src/import-injector.ts","../babel-helper-module-imports/src/index.ts","../babel-helper-module-transforms/src/dynamic-import.ts","../babel-helper-module-transforms/src/get-module-name.ts","../babel-helper-module-transforms/src/rewrite-this.ts","../babel-helper-simple-access/src/index.ts","../babel-helper-module-transforms/src/normalize-and-load-metadata.ts","../babel-helper-module-transforms/src/rewrite-live-references.ts","../babel-helper-module-transforms/src/lazy-modules.ts","../babel-helper-module-transforms/src/index.ts","../babel-helper-transform-fixture-test-runner/src/helpers.ts","../babel-helper-transform-fixture-test-runner/src/source-map-visualizer.ts","../../node_modules/@sinclair/typebox/typebox.d.ts","../../node_modules/@jest/schemas/build/index.d.ts","../../node_modules/jest-diff/node_modules/pretty-format/build/index.d.ts","../../node_modules/jest-diff/build/index.d.ts","../../node_modules/@types/fs-readdir-recursive/index.d.ts","../babel-helper-transform-fixture-test-runner/src/index.ts","../babel-helper-plugin-test-runner/src/index.ts","./src/index.ts","../babel-types/src/converters/gatherSequenceExpressions.ts","../babel-types/src/converters/toSequenceExpression.ts","../../lib/globals.d.ts","../babel-parser/typings/babel-parser.d.ts","../babel-parser/typings/babel-parser.source.d.ts","../../node_modules/@types/color-name/index.d.ts","../../node_modules/@types/eslint/helpers.d.ts","../../node_modules/@types/estree/index.d.ts","../../node_modules/@types/json-schema/index.d.ts","../../node_modules/@types/eslint/index.d.ts","../../node_modules/@types/eslint-scope/index.d.ts","../../node_modules/@types/node/assert.d.ts","../../node_modules/@types/node/assert/strict.d.ts","../../node_modules/buffer/index.d.ts","../../node_modules/undici-types/header.d.ts","../../node_modules/undici-types/readable.d.ts","../../node_modules/undici-types/file.d.ts","../../node_modules/undici-types/fetch.d.ts","../../node_modules/undici-types/formdata.d.ts","../../node_modules/undici-types/connector.d.ts","../../node_modules/undici-types/client.d.ts","../../node_modules/undici-types/errors.d.ts","../../node_modules/undici-types/dispatcher.d.ts","../../node_modules/undici-types/global-dispatcher.d.ts","../../node_modules/undici-types/global-origin.d.ts","../../node_modules/undici-types/pool-stats.d.ts","../../node_modules/undici-types/pool.d.ts","../../node_modules/undici-types/handlers.d.ts","../../node_modules/undici-types/balanced-pool.d.ts","../../node_modules/undici-types/agent.d.ts","../../node_modules/undici-types/mock-interceptor.d.ts","../../node_modules/undici-types/mock-agent.d.ts","../../node_modules/undici-types/mock-client.d.ts","../../node_modules/undici-types/mock-pool.d.ts","../../node_modules/undici-types/mock-errors.d.ts","../../node_modules/undici-types/proxy-agent.d.ts","../../node_modules/undici-types/api.d.ts","../../node_modules/undici-types/cookies.d.ts","../../node_modules/undici-types/patch.d.ts","../../node_modules/undici-types/filereader.d.ts","../../node_modules/undici-types/diagnostics-channel.d.ts","../../node_modules/undici-types/websocket.d.ts","../../node_modules/undici-types/content-type.d.ts","../../node_modules/undici-types/cache.d.ts","../../node_modules/undici-types/interceptors.d.ts","../../node_modules/undici-types/index.d.ts","../../node_modules/@types/node/globals.d.ts","../../node_modules/@types/node/async_hooks.d.ts","../../node_modules/@types/node/buffer.d.ts","../../node_modules/@types/node/child_process.d.ts","../../node_modules/@types/node/cluster.d.ts","../../node_modules/@types/node/console.d.ts","../../node_modules/@types/node/constants.d.ts","../../node_modules/@types/node/crypto.d.ts","../../node_modules/@types/node/dgram.d.ts","../../node_modules/@types/node/diagnostics_channel.d.ts","../../node_modules/@types/node/dns.d.ts","../../node_modules/@types/node/dns/promises.d.ts","../../node_modules/@types/node/domain.d.ts","../../node_modules/@types/node/dom-events.d.ts","../../node_modules/@types/node/events.d.ts","../../node_modules/@types/node/fs.d.ts","../../node_modules/@types/node/fs/promises.d.ts","../../node_modules/@types/node/http.d.ts","../../node_modules/@types/node/http2.d.ts","../../node_modules/@types/node/https.d.ts","../../node_modules/@types/node/inspector.d.ts","../../node_modules/@types/node/module.d.ts","../../node_modules/@types/node/net.d.ts","../../node_modules/@types/node/os.d.ts","../../node_modules/@types/node/path.d.ts","../../node_modules/@types/node/perf_hooks.d.ts","../../node_modules/@types/node/process.d.ts","../../node_modules/@types/node/punycode.d.ts","../../node_modules/@types/node/querystring.d.ts","../../node_modules/@types/node/readline.d.ts","../../node_modules/@types/node/readline/promises.d.ts","../../node_modules/@types/node/repl.d.ts","../../node_modules/@types/node/sea.d.ts","../../node_modules/@types/node/stream.d.ts","../../node_modules/@types/node/stream/promises.d.ts","../../node_modules/@types/node/stream/consumers.d.ts","../../node_modules/@types/node/stream/web.d.ts","../../node_modules/@types/node/string_decoder.d.ts","../../node_modules/@types/node/test.d.ts","../../node_modules/@types/node/timers.d.ts","../../node_modules/@types/node/timers/promises.d.ts","../../node_modules/@types/node/tls.d.ts","../../node_modules/@types/node/trace_events.d.ts","../../node_modules/@types/node/tty.d.ts","../../node_modules/@types/node/url.d.ts","../../node_modules/@types/node/util.d.ts","../../node_modules/@types/node/v8.d.ts","../../node_modules/@types/node/vm.d.ts","../../node_modules/@types/node/wasi.d.ts","../../node_modules/@types/node/worker_threads.d.ts","../../node_modules/@types/node/zlib.d.ts","../../node_modules/@types/node/globals.global.d.ts","../../node_modules/@types/node/index.d.ts","../../node_modules/@types/minimatch/index.d.ts","../../node_modules/@types/glob/index.d.ts","../../node_modules/@types/istanbul-lib-coverage/index.d.ts","../../node_modules/@types/istanbul-lib-report/index.d.ts","../../node_modules/@types/istanbul-reports/index.d.ts","../../node_modules/@types/jest/node_modules/@jest/expect-utils/build/index.d.ts","../../node_modules/@types/jest/node_modules/chalk/index.d.ts","../../node_modules/@types/jest/node_modules/jest-matcher-utils/build/index.d.ts","../../node_modules/@types/jest/node_modules/expect/build/index.d.ts","../../node_modules/@types/jest/node_modules/pretty-format/build/index.d.ts","../../node_modules/@types/jest/index.d.ts","../../node_modules/@types/json5/index.d.ts","../../node_modules/@types/resolve/index.d.ts","../../node_modules/@types/stack-utils/index.d.ts","../../node_modules/@types/v8flags/index.d.ts","../../node_modules/@types/yargs-parser/index.d.ts","../../node_modules/@types/yargs/index.d.ts"],"fileInfos":[{"version":"44e584d4f6444f58791784f1d530875970993129442a847597db702a073ca68c","affectsGlobalScope":true},"45b7ab580deca34ae9729e97c13cfd999df04416a79116c3bfb483804f85ded4","3facaf05f0c5fc569c5649dd359892c98a85557e3e0c847964caeb67076f4d75","9a68c0c07ae2fa71b44384a839b7b8d81662a236d4b9ac30916718f7510b1b2d","5e1c4c362065a6b95ff952c0eab010f04dcd2c3494e813b493ecfd4fcb9fc0d8","68d73b4a11549f9c0b7d352d10e91e5dca8faa3322bfb77b661839c42b1ddec7","5efce4fc3c29ea84e8928f97adec086e3dc876365e0982cc8479a07954a3efd4","feecb1be483ed332fad555aff858affd90a48ab19ba7272ee084704eb7167569","5514e54f17d6d74ecefedc73c504eadffdeda79c7ea205cf9febead32d45c4bc","27bdc30a0e32783366a5abeda841bc22757c1797de8681bbe81fbc735eeb1c10","17edc026abf73c5c2dd508652d63f68ec4efd9d4856e3469890d27598209feb5",{"version":"6920e1448680767498a0b77c6a00a8e77d14d62c3da8967b171f1ddffa3c18e4","affectsGlobalScope":true},{"version":"dc2df20b1bcdc8c2d34af4926e2c3ab15ffe1160a63e58b7e09833f616efff44","affectsGlobalScope":true},{"version":"4443e68b35f3332f753eacc66a04ac1d2053b8b035a0e0ac1d455392b5e243b3","affectsGlobalScope":true},{"version":"bc47685641087c015972a3f072480889f0d6c65515f12bd85222f49a98952ed7","affectsGlobalScope":true},{"version":"0dc1e7ceda9b8b9b455c3a2d67b0412feab00bd2f66656cd8850e8831b08b537","affectsGlobalScope":true},{"version":"ce691fb9e5c64efb9547083e4a34091bcbe5bdb41027e310ebba8f7d96a98671","affectsGlobalScope":true},{"version":"8d697a2a929a5fcb38b7a65594020fcef05ec1630804a33748829c5ff53640d0","affectsGlobalScope":true},{"version":"4ff2a353abf8a80ee399af572debb8faab2d33ad38c4b4474cff7f26e7653b8d","affectsGlobalScope":true},{"version":"93495ff27b8746f55d19fcbcdbaccc99fd95f19d057aed1bd2c0cafe1335fbf0","affectsGlobalScope":true},{"version":"6fc23bb8c3965964be8c597310a2878b53a0306edb71d4b5a4dfe760186bcc01","affectsGlobalScope":true},{"version":"ea011c76963fb15ef1cdd7ce6a6808b46322c527de2077b6cfdf23ae6f5f9ec7","affectsGlobalScope":true},{"version":"38f0219c9e23c915ef9790ab1d680440d95419ad264816fa15009a8851e79119","affectsGlobalScope":true},{"version":"bb42a7797d996412ecdc5b2787720de477103a0b2e53058569069a0e2bae6c7e","affectsGlobalScope":true},{"version":"4738f2420687fd85629c9efb470793bb753709c2379e5f85bc1815d875ceadcd","affectsGlobalScope":true},{"version":"2f11ff796926e0832f9ae148008138ad583bd181899ab7dd768a2666700b1893","affectsGlobalScope":true},{"version":"4de680d5bb41c17f7f68e0419412ca23c98d5749dcaaea1896172f06435891fc","affectsGlobalScope":true},{"version":"9fc46429fbe091ac5ad2608c657201eb68b6f1b8341bd6d670047d32ed0a88fa","affectsGlobalScope":true},{"version":"61c37c1de663cf4171e1192466e52c7a382afa58da01b1dc75058f032ddf0839","affectsGlobalScope":true},{"version":"b541a838a13f9234aba650a825393ffc2292dc0fc87681a5d81ef0c96d281e7a","affectsGlobalScope":true},{"version":"9e9fbd7030c440b33d021da145d3232984c8bb7916f277e8ffd3dc2e3eae2bdb","affectsGlobalScope":true},{"version":"811ec78f7fefcabbda4bfa93b3eb67d9ae166ef95f9bff989d964061cbf81a0c","affectsGlobalScope":true},{"version":"717937616a17072082152a2ef351cb51f98802fb4b2fdabd32399843875974ca","affectsGlobalScope":true},{"version":"d7e7d9b7b50e5f22c915b525acc5a49a7a6584cf8f62d0569e557c5cfc4b2ac2","affectsGlobalScope":true},{"version":"71c37f4c9543f31dfced6c7840e068c5a5aacb7b89111a4364b1d5276b852557","affectsGlobalScope":true},{"version":"576711e016cf4f1804676043e6a0a5414252560eb57de9faceee34d79798c850","affectsGlobalScope":true},{"version":"89c1b1281ba7b8a96efc676b11b264de7a8374c5ea1e6617f11880a13fc56dc6","affectsGlobalScope":true},{"version":"74f7fa2d027d5b33eb0471c8e82a6c87216223181ec31247c357a3e8e2fddc5b","affectsGlobalScope":true},{"version":"ae37d6ccd1560b0203ab88d46987393adaaa78c919e51acf32fb82c86502e98c","affectsGlobalScope":true},{"version":"063600664504610fe3e99b717a1223f8b1900087fab0b4cad1496a114744f8df","affectsGlobalScope":true},{"version":"934019d7e3c81950f9a8426d093458b65d5aff2c7c1511233c0fd5b941e608ab","affectsGlobalScope":true},{"version":"bf14a426dbbf1022d11bd08d6b8e709a2e9d246f0c6c1032f3b2edb9a902adbe","affectsGlobalScope":true},{"version":"5e07ed3809d48205d5b985642a59f2eba47c402374a7cf8006b686f79efadcbd","affectsGlobalScope":true},{"version":"2b72d528b2e2fe3c57889ca7baef5e13a56c957b946906d03767c642f386bbc3","affectsGlobalScope":true},{"version":"479553e3779be7d4f68e9f40cdb82d038e5ef7592010100410723ceced22a0f7","affectsGlobalScope":true},{"version":"368af93f74c9c932edd84c58883e736c9e3d53cec1fe24c0b0ff451f529ceab1","affectsGlobalScope":true},{"version":"af3dd424cf267428f30ccfc376f47a2c0114546b55c44d8c0f1d57d841e28d74","affectsGlobalScope":true},{"version":"995c005ab91a498455ea8dfb63aa9f83fa2ea793c3d8aa344be4a1678d06d399","affectsGlobalScope":true},{"version":"d3d7b04b45033f57351c8434f60b6be1ea71a2dfec2d0a0c3c83badbb0e3e693","affectsGlobalScope":true},{"version":"956d27abdea9652e8368ce029bb1e0b9174e9678a273529f426df4b3d90abd60","affectsGlobalScope":true},{"version":"4fa6ed14e98aa80b91f61b9805c653ee82af3502dc21c9da5268d3857772ca05","affectsGlobalScope":true},{"version":"e6633e05da3ff36e6da2ec170d0d03ccf33de50ca4dc6f5aeecb572cedd162fb","affectsGlobalScope":true},{"version":"d8670852241d4c6e03f2b89d67497a4bbefe29ecaa5a444e2c11a9b05e6fccc6","affectsGlobalScope":true},{"version":"8444af78980e3b20b49324f4a16ba35024fef3ee069a0eb67616ea6ca821c47a","affectsGlobalScope":true},{"version":"caccc56c72713969e1cfe5c3d44e5bab151544d9d2b373d7dbe5a1e4166652be","affectsGlobalScope":true},{"version":"3287d9d085fbd618c3971944b65b4be57859f5415f495b33a6adc994edd2f004","affectsGlobalScope":true},{"version":"b4b67b1a91182421f5df999988c690f14d813b9850b40acd06ed44691f6727ad","affectsGlobalScope":true},{"version":"08a58483392df5fcc1db57d782e87734f77ae9eab42516028acbfe46f29a3ef7","affectsGlobalScope":true},{"version":"436aaf437562f276ec2ddbee2f2cdedac7664c1e4c1d2c36839ddd582eeb3d0a","affectsGlobalScope":true},{"version":"8e3c06ea092138bf9fa5e874a1fdbc9d54805d074bee1de31b99a11e2fec239d","affectsGlobalScope":true},{"version":"0b11f3ca66aa33124202c80b70cd203219c3d4460cfc165e0707aa9ec710fc53","affectsGlobalScope":true},{"version":"6a3f5a0129cc80cf439ab71164334d649b47059a4f5afca90282362407d0c87f","affectsGlobalScope":true},{"version":"811c71eee4aa0ac5f7adf713323a5c41b0cf6c4e17367a34fbce379e12bbf0a4","affectsGlobalScope":true},{"version":"15b98a533864d324e5f57cd3cfc0579b231df58c1c0f6063ea0fcb13c3c74ff9","affectsGlobalScope":true},{"version":"0a6282c8827e4b9a95f4bf4f5c205673ada31b982f50572d27103df8ceb8013c","affectsGlobalScope":true},{"version":"ac77cb3e8c6d3565793eb90a8373ee8033146315a3dbead3bde8db5eaf5e5ec6","affectsGlobalScope":true},{"version":"d4b1d2c51d058fc21ec2629fff7a76249dec2e36e12960ea056e3ef89174080f","affectsGlobalScope":true},{"version":"2fef54945a13095fdb9b84f705f2b5994597640c46afeb2ce78352fab4cb3279","affectsGlobalScope":true},{"version":"56e4ed5aab5f5920980066a9409bfaf53e6d21d3f8d020c17e4de584d29600ad","affectsGlobalScope":true},{"version":"33358442698bb565130f52ba79bfd3d4d484ac85fe33f3cb1759c54d18201393","affectsGlobalScope":true},{"version":"782dec38049b92d4e85c1585fbea5474a219c6984a35b004963b00beb1aab538","affectsGlobalScope":true},"9b178631a934bd5e4832b478d4f74083d4dc357615a0d1a632357dfafe898cdb","b7589677bd27b038f8aae8afeb030e554f1d5ff29dc4f45854e2cb7e5095d59a",{"version":"9ff3d2e726a3e7c6603a01e9781dd27495be40611229af445eac342568359b51","signature":"603a6a23fb575101f92bb7c9d9f70e149b923b0b64b8da3bff10b76dad968f73"},{"version":"ba047e49d1eac4a6da39da7b05c2cd77e498a771b1bddd35760742bf93aa4d0e","signature":"a04503349c00a0421942bb14d5e9eea391fa1633d867b13fe5125f7df8355962"},{"version":"cef698f00f85277f0b2d4beb2fd7a69e9d223afa7c259daf47c4c4c392772473","signature":"e81bb81b21289ef6653935d1dbadedd907b857ada80f9221b260a33e311c9ea1"},"576d63ef3a0408e9044ab3855ea0877b5f0c674752d4a339d79b8ed6bb88b02a","8c5f0739f00f89f89b03a1fe6658c6d78000d7ebd7f556f0f8d6908fa679de35",{"version":"966193e44bc086f29bb1f8c6b602063fd0bb6f8a90275fbf6355cc0c56ac6378","signature":"e42016f3651c7e6a261bd594eca02d675da320f18a3814570397a9858c1935ab"},{"version":"7fd4381ff9526f000a26c861d47c64f00897e11882a688502ec04e8e7263122f","signature":"0879634ab66ba30092b8a65128cb6ce93af668c9994895d5be68f10621fd453d"},{"version":"8fcfeade248c2db0d29c967805f6a6d70ddc13a81f867fb2ba1cdfeedba2ad7d","signature":"e1bb914c06cc75205fae8713e349dff14bdfd2d36c784d0d2f2b7b5d37e035e0"},{"version":"4a6273a446ec1a2e1c611d2442d4205297c2b9f34ef7ebcfb3a1c2ff7cd76320","signature":"bfe8f5184c00e9c24f8bb40ec929097b2cafc50cc968bc1604501cb6c4a1440c"},{"version":"c0546f26640bd54a27df096202c4007bb308089dd2392f59da120574a8c9fc58","signature":"243665975c1af5dc7b51b10f52e76d3cb8b7676ccc23a6503977526d94b3cdde"},{"version":"aac28eeaa76e34b6ced7c5b001ed6e80b8b1f8f0816eb592555daf1ec2f4d7bb","signature":"6a7a221f94f9547a86feaa3c2ce81b8556c71ffb12057a43c54fc975bca83cde"},{"version":"3f0a83b294ddd8b8075870cc0cbd7754fedeca16e56bd4cdb7e9313c218c2e65","signature":"e34a316302189537858d6d20d5d77d8f0351ed977da8947a401ad9986cdf147f"},{"version":"afd3d7a25f7ad12ce91561c34ffc674c84ac3249919df4940856c6c6491462ea","signature":"c4fed2ac667845f4fe7863bbd478df921793eada16941b666bcfe161f40caef1"},{"version":"171a63d115fb2e1f18ea8a0a9229809e3441b8024346e8f6eb6f71da2acb0fb5","signature":"b360236d3b226a56126f9f071d68fccd10eba34e4b6831efc39e8a3277380523"},"d252563303cbd2c3f385c83b550b84b6c5a112da78050ad8922c428d38f63d6b",{"version":"cdae18a2e7912f1ce695077b914ad1c14078e4ca70cdd3ef8c4c3d1caea07f7a","signature":"989f035cd0c3acf51639b2ff4fb3cb8ccce3d7ef0103a1d32ca5e5f1cfd19387"},{"version":"357c8c1eedefe4572a845d2fbf39504afcf63900427de0f25780adaab29023cd","signature":"66612e3b3315adf8702a39830ad8690d6f4293f89193737c604f4b44a51e42ad"},{"version":"1af5af5e448bf69819c821acc50cc5b7a8eac66d0ba3c4ed471847612fc39062","signature":"a5e89e63c809c01f8e8175c9d63da68ce734ddf15b7efd98b1eb262d8e4d05ec"},{"version":"6effa8e58111946b0a830032546674f1254b1e4217d8558460071aff6acc4237","signature":"9ba02d6560cc8cf8063172ba05b5368a24fb236a97c1c852665372be78143592"},{"version":"aa0aa9c785df8942a0c0474ea22e93925d81a79310daec3990a747011e4b5bdd","signature":"186139eb9963554412f6fb33b35aabee1acdaa644b365de5c38fbd9123bdbe45"},{"version":"52050c18a38ecd88e094441b24e00d4c09be722fd4010716dd3482c99b0e3118","signature":"ce8fe0d07c32e6786203b5a3b93468afc6b1fcf57481dc9673e16fb119312c19"},{"version":"e99b0507b7478a5d42aa76ff2f256aa233c4d0dfee11d433f15a4a73feafd187","signature":"3642221f795abb677078c1d4673adc4932ac93effa865bf7d85d2f418acb5b1b"},{"version":"692e36a1eadcd9ed42bbe4fc3cf1853c61ba1e2dfefd7bf749bede5d301e0ea5","signature":"7d2a0764991446f121b01e690edcb502ce40fd02145613d1d349d9e46be3782a"},{"version":"7dd8fd4908173a37bd688b37cc6da6d424a7d95c24c16f9b80e4a4392554c02c","signature":"8e609bb71c20b858c77f0e9f90bb1319db8477b13f9f965f1a1e18524bf50881"},{"version":"ecedc0b9f905ae08952b3e86b8f049a0d28071b80431a59a7fd9980bae5a2cc7","signature":"8e609bb71c20b858c77f0e9f90bb1319db8477b13f9f965f1a1e18524bf50881"},{"version":"bddeccbea54a281dff4c47c0a6fb0044631989d863025fda8438959e439e86ac","signature":"513e4a7dd68f60782a39d5ae4ce6f0a19ccc4c51808b359560ad1f689f0ce93d"},{"version":"c825ca3f05c6e25f236f8e8762b44fbbf66f709b3a8d3ca0e42146ebe1581a9a","signature":"8e609bb71c20b858c77f0e9f90bb1319db8477b13f9f965f1a1e18524bf50881"},{"version":"c2adbec387364f5d73dde7780a3cc1dcfdcca50c64008212eb78da6977f8e2e1","signature":"8e609bb71c20b858c77f0e9f90bb1319db8477b13f9f965f1a1e18524bf50881"},{"version":"531ae897693e06c39fa774e7d5efebe99dc25eb315d28dc9868cf5d66caa6b4e","signature":"8e609bb71c20b858c77f0e9f90bb1319db8477b13f9f965f1a1e18524bf50881"},{"version":"1d980ffa590cf05dd111bc619f46a3b22d733f28e53dd43c0ed7c04086a27db0","signature":"519157309e4f7c98b6067933db2a849961eaa0e5dec4a2ce5d2fc92ace85dcfd"},{"version":"8d5646f46ffd5da015100bc01b95cb9bd7865608a2b9f9de49f70574da948299","signature":"c5f8672c8c39b8f9251a57fc2dab217ce20ac4a9d71c0a498b733cb922ff5e4e"},{"version":"d8ebfc0205cf426841c3f0b464ed1ba7eae8c3e8c5ceda630bad2f902044e2d2","signature":"156d025e006f7df4df1bcf7ce53cd3e3780a0190dfb03c65288f07b372e79843"},{"version":"bc154d30e8b9d4dbf8a3209a4a0fc3c374935d3f550b90e6499a25397c8f7dce","signature":"e181a4a2b4612772f2fe5a2fc18135d1c1df3f50e6c4884163117c650a495e20"},{"version":"8697dae129484c754357221381228d92160263db3f8e0aebb368998410bdd0b4","signature":"250bb1ea2d799ecf488834fe20efa611063ab79b35639b7b3024f05e1b6641ee"},{"version":"c492c5988297ad9251d2a9071c52894d6eda724f00e1599f35a3988b7c4aed19","signature":"b1fd1f3a57d18737a7792630d476f230f4eda06a2e3afa85a1725830d912b1cf"},{"version":"a6b289321f7db8293d68955fa596e46dfbcbef03e15612828f6a244e770de6ee","signature":"a73bd08ca8f85d9c1f0307ae7abb246e38cb618f452e15fd3612464e846665b0"},{"version":"226c3a35bba8947d4296e3b1d38dd17d4b16688c580357672a696091479b980a","signature":"4924f889957ee69dfd66643c7e60a5feee526c18b16d10985804c669fe1b6ce4"},{"version":"0d6d17c452ec87c53738e449f61d0642144827b747aa47eada063024e6a114b3","signature":"9b1b103c34f4c56ab0c40c87a85ffd36002295d8fbe17b493509e63a383f5814"},{"version":"edd51847a7bb071792713662c868ef3e68b46db5735d8303dc6c2c22340d1490","signature":"e4a023723ff5cfdc22880b572dd15876d0bc4bb4f2a555d71d226a2578786ad3"},{"version":"be08025002e28149f50ac7814003f38c04bc27532868e7f1e5b308e0772bb7c4","signature":"3aa0ae0c3636319f9bc6e5c2a4bd484f9b2b4e78623b33131056a95fb59c954c"},{"version":"32554cf6a4e226119f09b7f834f7ebb066c78b5c50c04d1bffab36d0b0af7e86","signature":"a73d8151dd40ff705eebd2989e703ba14874574f5fe4f195babe74b6ef93ac59"},{"version":"a029e1c4b13d11618865d30254ff2762481ba33613ec180de6ee6190f75afa86","signature":"dc25e664429b44c379d4d3cf988b2cce06116ae94f5c6f1a0cf73245b4282a93"},{"version":"3c52b0d34d0d2449c0c8266f76c213d038f9d049ef7de02e6db09965588d578b","signature":"f32fa5785766bba7c9c8dd0b2c822abdd6e6df528ac2512786b87103a03628b4"},{"version":"6470630dba76968b44e9fd031270da3f3e39852e9b4af3b63eaa56633120ebdf","signature":"e59daf03ff2d76dee4726e48556aba1d105fd1c7a7a9cbf3e74ec4a1f91a6bea"},"a0fbfc839fefc3d41a12c5a8631e6543135ff18fd516cd06c5a09f84cb81578c",{"version":"33166ad3efe9a4e610e12af338b7a5ea56e0b41b064ed509e40f901ddcc458e6","signature":"9ce376fdbe50ed84260f0dc45cc1f242916f2c0c91da6464df63df0ba2baae7c"},{"version":"548643195692cae832ccfcc7d6aac0582460eabeacb3d66907c7b6fddbd68103","signature":"c3e41c24eb14414b6995d4bbac99d16ce2e609282c9b53d1333b7b423e0f7d02"},{"version":"0b54bc2b799d87aa1177e909d465f54c6bef360ba83af93005e5ed227d19dab6","signature":"b555d22a622ea0565d08a340e5c19f6f439f40d4451a2f13fe6a33a39b3d761c"},{"version":"764f73212be29948c4fcd78f507088fc7e6defa31e7197c0bb75b6f4347bb1e4","signature":"9f29212a64599c6c5563b78746bf85f709d5437f18dac77502a53af63dadb850"},{"version":"47d2fe1d53745d28b017cf0e222e1d4a4f4227f7dd0a581bd92b113335531e88","signature":"6b714d7db731bb6da813dfa3d88ded4ce0bc9b627464e86315468e1be9adadff"},{"version":"be7e96cd9390cdaef4671d6035bbdaf562ede5e8c0a1276109d8e0bdd6ea6c3d","signature":"5ebd0c7b976b7cbe390e381d27ec9dc5adde1a02cf9ecfb2a7caed7a822a5cae"},{"version":"90ff25e6450736895d78029bff4fbe1ed9e4716ace55d7d68c69629a8b1cee1a","signature":"b8b9aae5a37c0d3dec11813d992b893ed55a080289466ade6c1bc47e3987f53a"},{"version":"c500cb69aa5cf5f562b1494e6094854b4179d1800351d2413da092b6be0abb4f","signature":"4171247c72f90ac86a3cd3cdb0f372214a556aa8b94aa92b28bf6d21dad5f7ee"},{"version":"d60d7a09651839c6bd24d23dd861c6d7bb6db5cef12499d31ec7c70dcd704e82","signature":"a9cb234a7e1c11097b0d897a52a82d54b51545d32863c0e7d026f70309a10eb4"},{"version":"15d3b873cf25203b8d3bde2fdf2290ff0c3bc56fcad31661838f8ddf455a084d","signature":"eb69d4cd5875c471c0dd30988bf8a4816f9b8fab1e71a8c39096e483411faa00"},{"version":"a4b304456b23b28cc0a552fe9a59ccd81b19c92a316071ed6e16b4f52ec77544","signature":"48225779dd7b1b7b384389e325ed6aa271a6745239d8193c2fc161cacbf3dac5"},{"version":"e823b7c5c5284a0915c664ba5116fa0935e1818de3cc34abca01282b017ec8ab","signature":"3f4487628af3e52556d6f33151740876b29a5355b8a5ccf8e56d1b3ae7cbcc0e"},{"version":"f1ef69cbcfb53cde7b93395b8c8e08a27700a153299a2af6eded4ef6f96dcdb1","signature":"c6fd0f9d777f11f972b4decc52beeeae6aad9f2aa949184e8f9984a5c36e4448"},{"version":"769de8be7004cefe640665543efa370ae48b6d6e2010297e2b5b22a8eaf2e939","signature":"2b4ca439136421892cc80ebf6f6ea641a0306e58bd12ed61ae7f20becb2ee15f"},{"version":"0b7052f1b0ffb904374e01198404cac8c4931bfdd7f87e550be5f48b425e9319","signature":"6296c7ce17d3115c72d6757513e79ea0f74b76f49e0138f78f37685fc1bc83f8"},{"version":"3b4274e19bf0b5551ad7f0190902eaf651a88d213d80e156ee158c8a3d68acd0","signature":"058e39e6fe02e97ddc18b2952a67d0dfb71f1f60f86405480fec569b602f5284"},{"version":"924473fe3db09406d721c813e1d9a9e932ac42de6526cbbf19fcc4b86a5f09d7","signature":"dfa94dabc1567d2b882222947f5c181adc89a3af5b6a2b730b1c3b85d4cfe48f"},{"version":"a030f8b58759c806d7a2ec11a0ae694035182ea7dcb2a93f969dbbe187535118","signature":"9f3f8ff5d06c5d5583e891d3bb98489d58e358e49bda2827f3f7819cdb632ad0"},{"version":"b60bfab426a779fe9bd50b8d19995564654b10b83c592dd00b9a7605bb12f329","signature":"c33fa94c2e88d70a2e98a33474d3cf477d959477236323a748f638b3ca1e2af0"},{"version":"7c676dde7b7864996d974adfa5c57f1ac22d4abd75f60f75c1e18c57ed842763","signature":"8c5dbef5fc0eb113d94132a5ba440d75e33eb85e9497a1f7e3bdb29a3fcd3469"},{"version":"2effc0f6de7a36ef7f347cc9965e0c064d40bd0a4b37e163a07db488809e9667","signature":"0d9808e1f0d2bd4c45462c7e2f20c0cf08b700c6964e7eda5e10d1f6b707deb8"},{"version":"ae29dd93357ed3d406b2ee4c877ce166f55ef9822bebb4f55642a08381bf9073","signature":"3b6aafb284a9943503546844726c7ecea9ae91fc46f1d8e8cbe233f6d8b16a30"},{"version":"88100c31b99360b9a517196944e1a9b509a588be609ddf7498e81ea04c7857f7","signature":"7571f6e856945cea6771a2985e008daff8785c6632f9dc1dc9f24f795f84444d"},{"version":"c690d242a9b796a6632297f61a7030ff914715883601a1f06ce7d06b3a726ca7","signature":"2ff5e66c8448d86302ef11ceeb27cbbd43d3af41aba05c2fc3a48cd0f1d8627f"},{"version":"52b637792df11dd64a7acc6d31ba77ca5ac3b65e2eac6a39f0adf0aa52f49051","signature":"6978b8fc2f45108c4bc2788bd7053f2917d7efa28f74ddf52182dc9ab59d03cf"},{"version":"0814686d7a7474b9c3072198413393be949e3c358587acb6d81fa987faa13bcc","signature":"e127a8fb319d5978d73d966a5a68b85915848f8f96267fff2f0dbe9bc92373e9"},{"version":"52dff4c7cba4c4943679193e437a0191640454ecbc64b5ca8bd7debfbb3824bb","signature":"77adbafe67e2bf42d578d82d2fb994530cce5b9eaa28a2a5b24aca70a008c3d9"},{"version":"0926c32fe1c110a3d7f1d7dc9341c6ced58a237bc894293d144782ca336595e0","signature":"82590ca2dfa968af29be579c534733406fd9c5c4a726213eef9f2308cbb04d23"},{"version":"82b86e1638a2b839335bda260e9f5ff8864c7be8a7ae4749626807eb82f77c09","signature":"e88043fb3ae0a6e33be31d45927494ed42c3263bfb318b024b9dab027f09dc2d"},{"version":"1705c872aaf610b945fe927e224dfd1d186a182c7e65740f1a52ea9ab5178388","signature":"3f7e6d7b1d7155d68b5ec0f8e021f10075c785b29171d1d520d0b9b0dd617aa0"},{"version":"4623bcaa845b85cdf21d1594313554a95bec68d1770b4087020cf78868dbdf43","signature":"1a910bff4e17d0f855bd00ef0dadc3ad8e7656499c099d19603f8bb0dbe8853e"},{"version":"54ccf8f7da67b45fb7a69c09d0313c4c6475e918f100fad0088a19f200dc57b3","signature":"23996dceac72973064c9643fff1ca0cf585b642d715c56ed3512703f2b280c5e"},{"version":"e0c730d1cef48b39c0ea78bbece9a770062d40b87f8fbb46dba3b91a39f5e8ae","signature":"95a1a8e1e7777214b2d970c3426819e976abf9120f2824b571e0ae51d1dd465b"},{"version":"bd41bf4f473276c2c3d6ac75a510b82e2a0c171fe6605aa9d6e4aef70b0fc5e2","signature":"466c63574f0654a81f7d760ccb32570f642b6b46e83b6fdc288c2e52bcef287c"},{"version":"ded09790fe023c6a76e3b52f8a37778d89fa0ac82703aa92d294b83a13b10a93","signature":"08cdf95dfc59101c1e7c23865951151455ee7f77f1bf7e257034aae8ba332972"},{"version":"8e6f85f2acce1e4132756c0b3f928a5102abcf9f8bcd6f19f759664cde9fc75c","signature":"c6526b7ad3213f40e40d617f0a150c8a9dcf0e8f868594ef4aa060b994fd11ce"},{"version":"3542d64a563b0efef64ff2553cbeace4e7635d2e9fefa9719ce14b9453b56843","signature":"b5e0565b7ca3ba4c129ed4e1788d4dc1bb30dcdeb14a37df1071c3881507e295"},{"version":"f1e46fa426072281a31a60bb2c50854397f9bc95a8a4efc7cb40824c286b100f","signature":"2c95044092cad1398b593b47290306d73513d163c61e85ebbc39715af4b15578"},{"version":"ea097853cb731b90f8da5b56d5c65dba3d6defcd42c6206753622ec6a51e6ebb","signature":"1d3f6521348f5d591d4da3408457a553274b024c79ecde88054361040967c211"},{"version":"fdf67ae033c8bd49182fef927461ea75acfb741c615820047bcaed083ff3b3f4","signature":"03a629914760ae9bb64a05e72ad0f4e6aeefb1e7c7b6ae3d7836bb46f69ae23e"},{"version":"d757c6a733cf1e7101672c61cd52d3c964fe19a4370bf4e2fa96fde3989ec76f","signature":"95017b0f25bb3cd6782853c14303c20b5099b866ef1491c57fc436add8183f14"},{"version":"ac81e071ce704acdc83cf7155ea62306f105a5d53010308cae52cef8b2eda5af","signature":"9dfbdb5529d2be1c9e77112f7e0e20fba7518865f31501b9aa09c3965ee91f6a"},{"version":"1bce4319db89c0eaebaac319159b604c707fb9f2ae4530c4a9d333263b1168e3","signature":"cafadd60cda0c63471975430893f7c0ac981f268ec719f08f131e41d8404c4db"},{"version":"3d3b5460f76a29a0ca48739d4a0ba58ba9ad7f7c82860fc3a6d39c2e14feb4b5","signature":"3a91334c3409e173cafb3af175d8a4a3ae835851df7015c8f0fc5c117ad46c80"},{"version":"bd6f370ce77154839f8bbabf421d4cafae387b210e0f640a0f1b80a3c11c0be3","signature":"98c7850cf7a5bca4267e71403e8a2788c29543b15ac7354d1211a7accba496c8"},{"version":"3206dd506869621a904b05e4c4efbc617b5aafd60a44ef1d0b1c774ea846a888","signature":"23a790e87430f6bcf8dfbc4d3560e8b3d7441f9cfbe509bcf932b4608c60c9e3"},{"version":"cf770a90e28cd62999528b61f8e997eaae027ddae2d95e29a20fe02447636e14","signature":"b10974251ad16a97b357ec50f87455c4430e7f0790f7b399564c900e4ebf87f1"},{"version":"88d9572cc89ab1512ecc4867a2b88bedf149fc7fc64f8b85d57ea6ba3226651f","signature":"234123959236555e336e4efcd7aa203ac1d5370ee5d891dcfc5828d996b28f59"},{"version":"2bd6aa5dc587db0e7546fffa74d651ea920696016fdaee66f601cc7c1c52eac9","signature":"b59756cf12284e6136e042f322af2e22664e1fd46f713b1dd3abb1740719b732"},{"version":"69d8195c4173277fd77cd75049b208000446a150025f9967aa520ff0c3df84e2","signature":"b7c164b46f7ddbdbc7ac32357100a1d569acd9c885cc511b827ebf51af5adcb0"},{"version":"cdce15930d610b1100f2196287010cff98875b0919e1c2adb23cac7abe4da0f0","signature":"cf3a0eb31aa449df0754f60f8be9622aeeaa4c985291cdaa9563788180260fd6"},{"version":"775ea9c6265a56d51b29938382e6ad9e4fc244f7a99391d005f70b747ecc94bb","signature":"62b65c635a282ea4855cd6a9b968527cbab364c38410ea432f63c5c591db9072"},{"version":"e3431330ec4ba8175669ad0130e248dd81afd939cd9f373d47b8fd1edae598e4","signature":"922fca8caceda4299b0184e2f68de6948e826a764f6f33d25126b53ec94c0ed1"},{"version":"94486bc1816e6577a9b4711a793b94323ae5d5969fc0391623aeff28158b868b","signature":"a382df4ff5c36b5a1f042f310ee52dc547da679b92066ececaa0f00bf76e35e4"},{"version":"f848fa1e793b685b9ad61f7f6d10a51fc7529cf04e36585818af8a1e147e1a04","signature":"8771cebcc7bab42179738c744b09d2ba6d5f3a1238fc8a981cf21a8842c38f51"},"6263e78a0998878d3007c407b5ba9d548a369b2dd1da8399114cb0320baa6078",{"version":"5c4ad473cb62ee09d47a449b5cadc7bd6d6c156353f7e4ffafbeac0715e60475","signature":"cbe5a7a02fb93f47d7948fb8dea8792f962b51657b63532ba3c67036d3c0a618"},{"version":"31fa9fa5bea525150abfa6a34ea8b831148d524c7fd97217eeb945a87cca52dd","signature":"6131967512c4d205c32f126ef7415453f0c715bf53c7175d6deecb72d76a75b5"},{"version":"1856bfb4336411e9591469cfc980a00a216f03acdd152ed741287021e2127cd9","signature":"4e38f7bd172e7549c323610cfede12644c116581dfc4d751998d301eda9573e6"},{"version":"45a9a6323ef93e8c4e5f83bb5a031e31b27b20f436533a637e0aa8d03020ae09","signature":"0d1adbde28307411dae5e1cc8cc316130653bfc6ad8feb4b59063f60efdfd693"},{"version":"bc098722e4d6b9b99661cb3c596a569f38c94cdc8ed67efa098b0189251eab3c","signature":"d8288a8eb14187b0df133ce467216d61d9ffe838ae5930471f476a5c36141828"},{"version":"0eb74b906b79f3f93cb2ab8e03d1996daa83098332a551f2ecf9520f617e420d","signature":"70ae92a852a67db5b841a7ee3e9d16df7c06320ab86dbf2d5dbd9d76f3c98faa"},"e58a0a0add3feea2c936af4933dae5710f6c41e91468e22d880054afaa47b782",{"version":"b85379fc70458bedef43253c21e40d0eb5772899996a28bb5791010570a53549","signature":"ead85b2d6cd6e6deb144a0995896c0ca7423820c66cc00e416e66733d2932985"},{"version":"969debe0a34414d4192edac2bff8573e0de7b398516d830a3dd977c11a54713e","signature":"2c66e853b459b5354429e957b3bc64a66479153e31df1def46fa0c7ff343d9b6"},{"version":"e4fd41129789f0d42c83925ecf0b187e2e3d6c55ab8a75b3ad97193e22e80f51","signature":"f8cfa2723700e6651de70b62b08d6536a7d6a1a1fb4e28914e0164741caa7755"},{"version":"329bb06b9bad13beac47188891165d19e6737b3161b66b1b00ce820e8ff823a7","signature":"5893d8b87ce06846556d2460e2eaf2aa8388f2179ed151d302ab7d711a75c7e4"},{"version":"0736d521e7f68fb1d6c06b28a3c0ab18d00c61c4c02ef78731d34f20ed3b7ccb","signature":"6b4d9c91ed03e7afd40fa045042fcb7a6250b8dbe242154f3c4b948a99c74a9d"},{"version":"9b710dd9ee172a08cdb6913901aaf7d9d3555897688577acbdcceea22ebbf639","signature":"8b37c18f85644a1c666705bb5c233850cac84d8863c19870a8ed5f8d69c68800"},{"version":"c8477d578081dbfc8daa84d6da3dc67389a46820e0545251cc74ad881663426f","signature":"429e18739687877b761b4b6574a45a9e51111a6a71cd63711440cb0f9c602e87"},{"version":"91d5a8782c544c374e3fa45b2968df021fc7564e2aebdd3109e54d658047ae0e","signature":"d0178d8099f50a868a3c6a8f82d7dc98b121c552d865e11a83e1d0d4374109cf"},{"version":"aff2b79c89bbfea4ab8a1615fdce238fc026a7e8240d6a533aecacb13ccc5634","signature":"9e51bdbcfcbbe857bea0999bafc786cf85a07ace21f8493112f962cd76e32618"},{"version":"caa16ba6e11913caa7dc5de9380131f2fe716f9fa0d57c353d710eb264a7847c","signature":"220bc2f85b04326fd70de47faaa003666bc864e55f00543fdffa7b7f75d4dcdd"},{"version":"12b83896f323f2aeba3f9a035d35a9a2571dc690df4cdeab8e5b12223692e652","signature":"4a554afd8a11ad65a0f8878ebeddf6793c6775b1edbb14360bd47252840e051c"},{"version":"6e95f95e765707c6331a2e9df3c4a94b352e26e91d9c9714f84879fd75826357","signature":"431fa08179e6ec652924f1f0788e213db388b0dbebdbfd392477772c5f199573"},{"version":"ef21cd892023cb32ef60a2fa3fd2f598975395fb6ffd64272a3f698afa134d4b","signature":"852bee3ca49f48477ef77e392aa31a260b82cabc1bbf42da56800b6e10a5c341"},{"version":"959f0d52d25f1e9e8842377359a32394cd5e7c8664674191cca73b1e1e529368","signature":"c850bbb5c78efd30556f39d7af1a4d649282038dd8835de3654587fb51cd3eb2"},{"version":"a679f0ba59fd4967efa69a289527ca730065ed5335bbcf43578026ef4fd45638","signature":"e4aa4e8d3eb4c67b64962344ef3388a8cd607821ba619c9379b36316db65c9ac"},{"version":"6b6fc0d409950335b50dfc9dd240decaadaccb31f4f01118d31563fb4f4b6076","signature":"fe04102233530017353cf165f35aa2d141435a465d5dd2ce9e395b8d007cd717"},{"version":"57669050e66a5d3ef5e559802fd86545028ecbe5582fed49de9944fb537b8dbb","signature":"9b94792c88485a63a47c60f14a06a24fbed8882a03f0c399497957dacf2f24c2"},{"version":"1228aa1caf9080cc851622f1b307c98c87ac12c7fb258f78f99686d40b6ee169","signature":"4dbfa68f729bd8e052c9a8916a1e828007ed3c9f50b24e7eb65e6556ea7fe315"},{"version":"37d83a587db9cf28d7e244be681dcef0b6f3ff2c526dfaa3a81dea9b00134b31","signature":"635ca94290fa45a56e53ffadd3b897a42650fd4ab0ddc241392e4dc729bf496b"},{"version":"a330918f51cd1fc96a80a02e87272acfb9689066a9ba1599ac71788ddf8c96ad","signature":"31bcdc4dd0dc48656c9cb11c9912a937ae6e78c87071856a9e480f7db6d1b219"},{"version":"a62829e45d9d641ad609286af9013b5133a754e312e58d432bebf0735e69a815","signature":"eabae622cedff1fac0fe3a8a1baeaba3626faab93cd5bacea072a7e7b34d5245"},{"version":"6a687fb7a6d8539481b3ee928b57330dec44dbd3a5a5e34c2cfce09237219642","signature":"75a5c390f494828bb3dfd3e31ef3a8cc573184f4176166b6d3c1d67f69539b9c"},{"version":"86240e0cf0126e85d92f418f62742afe67a17eef6923d58ca2cb02671986daa9","signature":"02519cdd247317de0bfdc78d88b5497d9747e1b9d1297283a0fea8ab3787f6ab"},{"version":"7491fa16c8e8b3e52f6c65fdad11a4441277532d2b81fd2b058b1e3735db6c56","signature":"53989e09bc0b6b46a3c4597e5147a9b989f1f66f33ce7375b92d28139977e748"},{"version":"9eff35a7b656773bc91ebbc0b4f5034e6bb1a761b016c9bac49cad0e4754910f","signature":"269ee735294e8c328681830ae7fdf4aea6c24032f0541d76c914aac9afadda5c"},{"version":"be43c99620df23cd01c8940ca91fd1aa913a5839f02910ea291b66dcb24e6b87","signature":"f64d84c7d26c46fbe74a320adbbffc5f4f136c97b495ff051a8d439643774e6a"},{"version":"2d7af83da7a8e13dd097ea32365d7dd4711e9657f9d31e483c98a3a62cfc3249","signature":"d3b2b753db518c14961367b5435d512352b5e3ad72a85de6aa18038ea6c480df"},{"version":"e7d189b934e2c1eccbb725caa53d594536ab02c027661474af648de2829a1a6b","signature":"18d3a2cc651905a61088a56f684783699a3c66541568a5a458cf75c8638de2ac"},{"version":"f7d12b498acff33492c82d062e62fe1909ebc22f9c49ca28e76a9b85cd81e63a","signature":"6a7820891908f3e6dfbdf5d9b3c8ede00967a3a8bf51e90a70f6560733334809"},{"version":"8510b88d197c5c9225986baa88fccb4a419a7423242a1324210e3129d059ba49","signature":"7a8b858660503a4af876541f456b2cbc3d89b164ab842c7434ac0fb87ec0e026"},{"version":"61e5ee63cbc96733816e921073edad91ec4a943229b15b34134ae2293fd4e476","signature":"024653e8296d821c2332e1e8fe13eb86f4d50f0be82478c958890e92d1f2ca0e"},{"version":"cd093c33e37530b20651935e5b156a971a8643379807170da46d436b837c52aa","signature":"02cf2596d27195cbb9dba82697a3dc32900459781195302991f777d1d32f5d35"},{"version":"53f5fe2443f579c7b45221298a1700dddc2b3bfb5b4ef43df12eca3e9f05266d","signature":"af2cde32ac3543e8c8312c7983b3fc72b06b4c8a154db71cacb5255ef609bd5a"},{"version":"f8fa15710b26507fe7a17ee1dac9e831dd99b42694607338938f213ec9431e25","signature":"f31ab9295985d01c5837c9bdc422643f6f73293cfd103738774b7cfb340566cc"},{"version":"afbd2ea68fd116593555b8b1fc0285b41850a89bd9a9bdd745ad5112d0d81525","signature":"1079472c5e1f65ce739fb777054e2f539e9b50a97b438c0d6e56c4ee23be8bff"},{"version":"ad9412e95dd32f485a424fb9b30fee6fd5b642d24fcc307837f82066cad2d4bf","signature":"60033f2f6324491b9129d3e4df3818434ab6997e7cb1e386597ee08275d1d935"},{"version":"104a8033a6a23155aadb6e3c76294813c8e495190c7cf8c2003e6305a595294c","signature":"692328e8946fb1762788901188e290d17a95cd6676388cbf94f6794b60333e88"},"99392e1e600259c50f21f691f136a4ecbee42839dbb9523384f09645c8756503",{"version":"816b5e57cf6e493b499767f2b2272d939f1fe7e30256fac7ddacfbcd3de9cd10","signature":"5c5d100793c0fb9b34076189904df18f3321e82cadf6f69815926104029c215b"},{"version":"f7e00b63bc596030913bd3ab6033b587eeffdceacf87fee8b96c36b9c0e6d4d7","signature":"4f9a4bb30bc97017c72a600c0161962d8f74488d1cd93669e4adbce7e611e0de"},{"version":"d0ab323d291d5643e25726d0f1ea22f9903d74081bede5f50ca65f3b49eeec62","signature":"6f5e1adbd8ecb5ca09948ea08ddb357362a459ad3c1e3b682695559058c067d4"},{"version":"e7d20258143895e9d96d3701189b9ba69e2e386938a226e96762e885bb0470c2","signature":"d9ea1d16fdd5778b962ead323e028a70358574d18c8d80695a8c2d94e1b29401"},"caf6fbd0b4a4590b61808dc671ba18f3f482d82402e2c7285aeb2beb56051718",{"version":"f48bc40fd4214e7ccceee1c29bd2f2e547e1fddb63551c36870df7f0196d4e20","signature":"57e73f1c6da39bcf9429f52c39b6fc34eef11547fbb5a2be91836517ec746957"},{"version":"0a200728883705af17f06c0ccce1f6cb2c22846e68398f6efcfe06add18ec460","signature":"d0b3a40cbe16c8852d1327fb804995193fb853d7da9c7ab9c02cce85090e0637"},{"version":"e663c71ede6c0ad637e91b25269c014fc6f86d276b63da4215b6d2998ea87284","signature":"c67208e9da4af7a50bfb75d07691326052d6ed8f3b577ece8b02cd425c9d632f"},"3cf5f191d75bbe7c92f921e5ae12004ac672266e2be2ece69f40b1d6b1b678f9","971f12a5fc236419ced0b7b9f23a53c1758233713f565635bbf4b85e2b23f55a","9d670bb3be18ea59cea824e3bb07d576b55c9542f5bc24aacc2a3c1ebd889de6","695b586df2d8c78b78cdd7cc6943594f3f4bc52948f13b31cdedfa3ce8d97c31","0771a93ef5e3b2a29f929c20f7ad232829341a671c9d1e96e93ef3fc42ef7bc2","cadb68b67b80b14a9a5bb64cce3093168fb2bfe2c7b10096d230df5203218de1","0b3c75be13f930b46117e205d900ee9c4f2ad6c7317655bca5364958ba1e34f0","5af161220fdf46730477706e8c431ccbd1b4ff50223cb32450bc20513f50bfbd",{"version":"5995a97cd70877231d44397b301edd3f8b9504808960d75e09877cd34d3bb91e","signature":"183c86a7e101184b772b247e43c5ed3b37d756b72770db07e371d64728bfb182"},{"version":"b144d0a2abe8834511067aaffac9f8b4c655aced991630e0e8d92e31f876e0b8","signature":"ed1072a38230be53741107cc7b18c9a2b8033cc859d79aa50001fb818f21b7a3"},{"version":"59d5e906b476813062d6f5d17e9fbc8ad1259050d3a267ca2324d05b321844c8","signature":"d1b22f8a95370f6cefb5799b523142d1fe0364c97d40d2b905b91c8bbc3350ef"},{"version":"e3b721388cf28c0236da384697f276f4fc4bb75f83d16d0a84d64c8ce39c0f55","signature":"4c3bc0e4e21c1878b04cb119e0cd3be5ee45181afe31cf6234ab72547efff7de"},{"version":"1747f4838485a1d224015d46a6f5cf58aad06bde9780db13e7bb25b9348a23ae","signature":"0af33ccd0c82c1b2d5f17d7e1a854df6dcd6ca60026b837205ef47e19def1a9f"},"84a805c22a49922085dc337ca71ac0b85aad6d4dba6b01cee5bd5776ff54df39",{"version":"0bbdb3ba183b2670a7a78d30ba4166c3889f3f643b44cf965cd209eb618c25b5","signature":"1a0c3d493fd15fe287b968599c4316f020570815d86498386b7722d05c0f65eb"},{"version":"15aae52a2a791ffdb7f6383a5c860a5dab68c52058c7546f7d3bfcca507a65cf","signature":"78cb7a8355342bbbfe28a3444f691be65a56c19e42e0906030e2a6511f018296"},{"version":"2400845cdb7416bfbc07d7562dfbdc52bdb8f17b3aca79e38bcdc419cbe3b251","signature":"a47f912628fb74dd979b579736f213d66b912b0c76cc9efe54c63602ab2fb18c"},{"version":"50bf32e7d5ebe30e3d7f4f64e718cffee6b0b853ff90eeb18ab6f883f4164a0a","signature":"9b7df65f0234bc2fbcddb49a36961fc297136af5557557d61c852b65a086247f"},{"version":"e4767ec749f3d7790f31a6b6edc1136900275e2386d539e8a8aa620926970627","signature":"261cb81bd0515eebb1a438a7d3362dfc9369dc34152d4c99cdfc5077e27f215f"},{"version":"649c88afac65accea627402ebbcc0f071e282b1871a8e0e0a34524ebce19f090","signature":"b89934651144ee9eb80d3afecde1a161d6c393aa7de5020136428e4407dd19cb"},{"version":"46c42546bd310c4bd7ead522695597734c54ea4f24e1e0e76b041dce36648946","signature":"bd022c5652e49f61d58a9f15255e3889005566bc5aa87c37398307057859e6ed"},{"version":"ddbfaebef06b18fed3b5931b3d38761a5ab536fd9b94d91beedd80da8eb3ad32","signature":"2157ac459fb9cd60da3288de0870a51d07be5c9244c37f6c1d860a60bc336753"},{"version":"b4ebbdd62191836cb6de8f50fbf6bab445a842cbf41026aa0a101850fe6783da","signature":"2e7db7d4a7f75fdc68fd5fceac391b0337e305d30e37970d5d349404abba0eb6"},{"version":"10830946c54d35ab071b137893607f429b8e1753f1ff07941b9628a42843d66f","signature":"a9d413dcf89b3cbab1c138ea77edcdebe6ca46a7d687f5d61d991cdf780936dc"},{"version":"a5428d0b1ae15d32c8c7766018637b89e58d2844a4a44a039653c2fb5cf90109","signature":"768b0149121c79e9f5e6d27e1d676bd1f9a06942ad2139d01ece46f9f80e0469"},"6e3555b72390516ce90bdc2a97827dd44218547d073b2d97074a7d43eb5577ee",{"version":"6a11e2c4fce82575d2360641ac6315bbb81200051aa68bc8066ac4ca35f36327","signature":"a8babc23710785fbe370e3541e11a4d517dce4789eedf32ff73e9f2e595f799a"},{"version":"0321d98c2f6be3eaa4f4b4e5b5d91039f38895d1d62ded82c090ad7a543b1912","signature":"be797449825edee1716d3e0c8d7ae53955b8944437cb4d0b4123a32778621228"},{"version":"b00061cd6daf1b9c8da6306f2dbb36d516e9cdaca048b0aa4f934eb4a794917c","signature":"8dec4b9028cc8905caa6b52a395786d7f49a10d61f6be869b59ae007dc5e0cdf"},{"version":"33d3b5f1ca2007f0cf4724a8dfe7fee1916ecccca64986a7f7b961c7fdc39fbf","signature":"e43763a155cb34a76ce267f5191c47481fe45e8e6780446086d4af429204a6d7"},{"version":"248fd2e94a9abba6f0a7e8457d10aefa3ebb2d6f758d48fc5d65c1ffea85db35","signature":"dea3318275e8028e114e4a929ce48a338596d4024877d18888e1fc279fa3ffa0"},{"version":"f871672cb541e369a0affab5b66bc6cf3238509a025e0866f45e4ecd736cb250","signature":"c78898140fe8e75fd9a40e9fba228c6792e1bfadb1980ba3e4d8d465ee44c147"},{"version":"e44c7ddd77cedfee8e181db7309c9d9f240ee85ba437bf5eaacad389033338d5","signature":"f952c9c19048db8b25e3fa8e48e2213c18d3fdbef6ac168e9fae6632ed58245f"},{"version":"194efc090d69a16ac0ecdf2d87a5c0298d397f4d671571a49d1ff1cdb820e268","signature":"a9347f177e175bde3461b0d847b84183e6b3dfb5acc93e2d818641ca59be4dc5"},{"version":"835ca304ae6473d6dc6702532d9df515b920c613a0f1384a04b7dde28dfa2f34","signature":"37aca357a14fab8a174e0f2cffcc155721f9c9e0f1abaeff0e21972597a2a676"},{"version":"e5da847df6da0e77ee2328f4cdfe5b2f764a3da271c314c455829f16f0c6d24f","signature":"00222577eecd6c1fc72150006351fc6e1b5bb3aaf78097e40ecac8b8343a7598"},{"version":"52aece1e2788b7c63806088caf2b77f7d9c09a5a210fd19f1d9b5a57c49f1b10","signature":"466f4f5da14b6046570025129a7e5ea168164572c9b2da45bdc7274e0e303dbd"},{"version":"8bd66e5d64b04531ff7b3428f53750a245b1ecbede7f8092bb8ea24343cfdf93","signature":"39e2d8b839ebf811234d4a2e54998229aa1353e19e1199be87b6fa530136aee5"},{"version":"822f4d628ea5c9a389cdfe150a67be60d66c2c0a9734b69f0300d98ca24fc302","signature":"063f53d5fd391537f7b4e14e376a67930b80684c72f2e8780df33eb5596cf5e9"},{"version":"5cf94e93c5670675afd0787e2704e6a8c5b3a5775fe6591fcfb380762cc72909","signature":"5b8807a3d3cad7abc8f1c067dea5df20373446b89bb4f0aa73fee801deed46b8"},{"version":"16e8c882b00d9c01c42ed6814b975b7b490ea61571049901a99677fb3916971b","signature":"866c1b69a53d80383cb5eef0ce2760ad8d028c771fa45776426a583c56a23746"},{"version":"001711441f64d7ffca31a1d9d51795120b80ab7a5ae78559c8452ba3aafd6159","signature":"2da7fcd097f2f40ebcc4fde1e512477e1092dd97dc206a46bb2bbd5028230fa8"},{"version":"62c00b648e2b2938934147ffe3d4fd05ae519c208dd03415ed8adcf6fb2c6e78","signature":"8b433fd18d5bac931c1d7c07c17a830475e0fcb224d144cfeb3ba4d1da198687"},{"version":"cf3b666adeeb3656ac3d5573983af1378eaf976868183222129b1eae9d44395a","signature":"e772bc828730ee913e19f58bb18b7733ebce8a3f06cdce847cb33275343a6ecd"},{"version":"bc8c59a8f99dedcb62760601297bb49027a7c50cdb9cc5d6bffcf3e547e5c42f","signature":"3b1765aafca023ad58d5aa017800e1f2e7ee95130c9a1e7d86d5019f45c756bc"},{"version":"30ccad241aceeca940e9ac504b55613d533d0f47655c2a74b83677b7ed895214","signature":"e675dc45ca604b7a6fea16448050b34cf0fe86c2f9fa50f3911fb4153b42c186"},"d3e56e0f84e1d1843369533f50918cce5925129e99e9ca14c7cc35ad94b2a052","7102463bc898ac4cfd90675e679cdd8e1a1b6f44702b280f9c99b93f206ae570",{"version":"c4636667aef2678a60095c91cf472e9b2311339d277c987f28639a642819b6cb","signature":"098a096f7f67356b98031a7c45cf7e0d49733cee8ef9b7230f881fcf5fe75a2f"},{"version":"3e6e265e5c100e90cc2186128dd32a3eaeaf0f1b83367b36f78243f08693c942","signature":"dfedb6704555de21c30e98a8decf8a6d31dde1d8403b9b95944a1d317379c7ae"},{"version":"4c0b0beec0a7773d05e41b7f052b6a3ba191e492ff3f8ae267f8cd7c046c125e","signature":"051191f8664727f9b9caa72166559b734e126d18ef377c3f4c3343672ea4d307"},{"version":"1353758c9ba5ff781fbf1025de5aa39a3751376a60b3dbfb2834435de8fb7786","signature":"8e4e3a2b6abfb27e146543a86b61deb0b088a62db1ddf32151d115ccdf30c3a2"},"bb95470284971cf0cce66a339224fa5db412729bf3e22c2c02a1c343fd4444ab","bde8c75c442f701f7c428265ecad3da98023b6152db9ca49552304fd19fdba38",{"version":"33d4500982be117ce4fce7f35b2e12059dba61165e932334e9572bec748d334a","signature":"e1b86105546b28e74d49d3b2c5209ef49b34a725824cc7e27540ff11fb01f328"},{"version":"59663736656c9403dc474c0616330a39552b3d90c4b67d26666a8e87023b51e2","affectsGlobalScope":true},{"version":"19ad665731c15e2afd4091c6f46b4311825d296dd46e2cd0952c868489e7a74c","signature":"67683bd79e22a3d29785b4ca1c342c8c49b9512865d1b8c7210f2af822ec0285"},{"version":"4a8b3ced76fdf10adf3ece20853a5d19d5079eeafb7553a75d19e4adbf965480","signature":"42412c4a46f75e4d490cc5f6bb3cffc6b328ddeed62128af7b9703d655c2377b"},"6fe47ea5e29ef669f97b7eb05d5068cb2af451d06a50f7bfec26d7c06d151953","1b14cf74b090ffe8def9013ca4bb448b4c76e98fbfe20c58a06e439b9e4e6438","6d727c1f6a7122c04e4f7c164c5e6f460c21ada618856894cdaa6ac25e95f38c","bb95470284971cf0cce66a339224fa5db412729bf3e22c2c02a1c343fd4444ab",{"version":"7c66f9660bb7be90b270553734b22cdc94c41c3896529a9772912180edf8dcfa","signature":"7da12c50edd45d08ae7f93183d0f88ab9753386ce060d1765926ffbe7c6491c2"},"1a8397f1c9125fc54db823eb6509221b841dd6f0c82a78997033a4a09fb1c86d",{"version":"80a6bb9643d4a76565e4b7c885419f4b1a3f315ea028659b5336250c49f26fd3","signature":"4250615fd2a4a426b0f644655b50b69506f4bf47a158f024f9890c01a7eccd44"},{"version":"7746909bdcf5f6b660a182dfd6ba7c91dc1d9e89713db851cd25475be9e0153e","signature":"abae244b376437bfe2f0fdd1bd8925e2c235d10336ba08aec4330b800582ccbb"},{"version":"2638ce60797fa9b9cd7fa2bcf16492318c003e7e20964fec77ba43b0d9aa463c","signature":"176d3525152384c3f7312b308c8af7b17690f8ec34e0788e6aaae548180f1941"},{"version":"425ab9db767452e4f46efa9a9cf0a1d021e6155083adef8b66caf815a2996ff8","signature":"6b34e6bdec80f7af4912497afb8455cd88ae1d6442d042c6663176b9927b69d4"},"7b39f800e12236b4875b9be5de5821bcd95f6d0edb4f7e76a6e4f37f95ffe854",{"version":"eb8d5e9b5765a7fc11be0310b32de385e72783b7d7b0de6e630f94c2913c238e","signature":"41113f7f4529f81a16bae03c06bbd3c95146a4f7c8173ecafd6869fd1e97ed0b"},{"version":"a3058b7f77415c84604895ff41926cd564881bfd4756efc5d19b21860a5ced09","signature":"c980191d2838b122a340074b58c566fddbc29a44bb57170671ac5034373c49a1"},{"version":"b587d71c7d5e2c47f637f35295e51e76ae42d45424f6817896bbd872e133fe4d","signature":"67fbb5e2cab94fd680040182fb83908f93a378ac1dbe67ff0e98db1ddb4fd4dd"},{"version":"3d193d6646e3119eafbc295545583699b8a709b21eacd804c26f7c6d6376eb01","signature":"378871d06cbd514fe945b69a7be3cabe210139a5b2b3917a306ef8102afdd5bd"},{"version":"e13db61fe8c1ddb74b0515cbcb847782b5db4a8f4b64b21d77eabefbad2f65af","signature":"cc63c79f287e3deab7f25927de83c4b200e66d71f5d3f3b4f0b3957bb76ae79d"},{"version":"07a4860d1b590f24eaeb64985162bfbac3475b4f8ea43e26459cd99855d8461a","signature":"250de328744a943a8d2cf471e57728f5f87d5cabe1fcfd8f06b5e6b2acd11b53"},{"version":"a6538870e6c3de07a0f1b01e61409c45ef1a836442d76736f35f1e641c48ce78","signature":"49bf06ea475ae5c78e69f7af3c7e09e00af57750aa1e37c120aaad92fd8a8ab2"},{"version":"c365d727a34172b2ae523230c710e461136c418e140304d4564773b9ed1761c9","signature":"1d215e671d8b299143261397510d03de1f106148e1fc763134320aae5c7452e7"},{"version":"15e73a579573f500b4757cc86a449927255b5644620d8c94389e68b57a3405b5","signature":"104a8a35d9ec11fb958c23fadb5430f7992eafaaf0f34040da858f183d16807f"},{"version":"d60ff304aafddb81ce202db89cc8a173ffc7f53bcca828b9976fb0eda750dcc4","signature":"f8fc87c8c6822986fa509a62a0caed5cbf05f3f84d82fbbdb01a9e94aebfb2ec"},"88a3a6f8c2a1640d8d5fd30d8d86462f8babd86a1e52fab0e8b7f7c141fb348e","345f76c854da724803c96f727a3f9c75e26cf95c6e7b8c1064dbc4e7727b74e6","ab7b7a15a5d73eb0cfc2b973e580f357f07492bff6608669d7e899e2d49ac9a3",{"version":"f872698db4601b7ae2883a7651c0630d6e4db9e94a2ad4634497c34648236595","signature":"f33651b8aa26111e69efe968cc3ae68dbccf6a017f1d462f7780b26db8bd4d22"},{"version":"c0b3b5cb24572ee660dc76f82c73848c266c262fb5357c8cae1a99347a33b90c","signature":"3bf0df1a6a59b16d43f97efd5bddcb376a3a3d66ecbe92a4dd80a0f81be6a009"},{"version":"31091075ef7e87af6418543fb9be2f800a7a907733e0b4267207c5f047c36047","signature":"81af40a2264a5a56f71b8c45ff1717b50c5f0c00dd091410b12dc970ee340120"},{"version":"f9bed150d5b760cd8505f24bec8acb4d904d561c715cf91e860c36dcb06ad95e","signature":"444399b4f2fead080a55b82f86bf653a072a9f117042edc9a0fa69366672b418"},{"version":"dbabf31278e50677041de6eb4d712e5d4a91418b3f67aef421ade26867ad7cf0","signature":"d6ab7f2b45d4aa62ad21199fbb3105151a9dd4830d138a3bb3eab1e76eef9e45"},{"version":"ec3e9c0e1c940881f99da6ff05e80f4fbc72cc41f256a389911b138506e9c223","signature":"56827baba9ab2b370c919b1858068e11f10a73d80dca8cb2467d2d1446fab073"},{"version":"951fbd1d285601377ee6e8ba14c27006c109a2d929ee722b1be2d1a7dbdb3557","signature":"5db896a650fb0c4ec892de19b7b98b92ccae9bb5a3e03731050f3db0d3183bd6"},{"version":"3694c4d634872d6693d7d01d91d91dde9708cbbdbd79993433e679d043372736","signature":"235689831a81b3caa5b067b460b8bd52a00be85b7b047296ee3287ae85b1df6c"},{"version":"7920c58580baa54730a4221b3d3e159e2554bd78b38a0ce50fdc915d9570ef83","signature":"83a3a4f21e36ee920e819ac865badd30bf258361e7a224d1fb134a5524f55a0f"},{"version":"ac502dfe399d54c5db83153ca63a19125f92044f5c38f2d0e64881030d24103b","signature":"a09c9ad7765dde81c65319b317af29e10f0a8e38f197c2e657ed7130d67c73dd"},{"version":"3408cefaecd51b8803c55740f3cc30f1e8cf7f61dfec03f761b4fb08614cce6a","signature":"507fade66a323b65e5bc8351844fb9c69f4466eb081a0e95fadea3b7ec6373f0"},{"version":"cb72e268199a695153b5c39159a31022c596543ba2284031c783e758885fa777","signature":"d9a71b6d72208aa7f30a5f8d645bb8fdb6e31bdb9da1a748aee44de1d9ba65cf"},"13d94ac3ee5780f99988ae4cce0efd139598ca159553bc0100811eba74fc2351","ab5b379e400dd9ae9546e1f691c38e5aaafc6363225ea8ac65d3c07bca6825bf","5d028f3e82de0a8e972fd4509e63357871ba4162a50289f84e54394fa4291210","0b6762a36839eeea42b8713f8ed16da01366799c686632522e5ff932456c1ed2",{"version":"43b27291c6e9c5626d6cffea62d423a1a1bf69bfdab7dc1ed372dc47653dd1cb","signature":"4bf574cec6ba20c0ded65c7a94954c17fd6595809fa40fa224f456ea70540bae"},{"version":"94640cc4366ce86a0402018f568011d192b008fe74db0308012e4a61163a0432","signature":"cf25fb6383c748c38223a9a156e1299dd15c7ff9f0f01fb411f500ef4dd71879"},{"version":"cbcada412eb0effd56eb06352136e2c70750b5a70377f806a94f2d47ac8adc2c","signature":"f571e28d70c04d1ce72673771010febae11d2c907a71d027550d986ee424951d"},{"version":"13602d62f5e390351afc91292eed65d37d839142ed843143a285c978cb28d9ee","signature":"5fde1b40052163df65f8e55904024dfffc3a130721305aa6aee682fbdc048c75"},{"version":"07e88f0a9754531c1083621d40ea62f12cd52c6ba2a91449ee12207fb3d53081","signature":"cf5ba84fd9488f0ba7e302d54d1db6452b513d8573df389dd05f4153f5edfc26"},{"version":"f1e2bd48913a33eef16376ee1e91e96ebf2e739278d514f496d6e7c7654af619","signature":"f88563bf0a7f4bbe3fc3a6839a8eb3e5f1aecce7dde29d380fbdd64a9e26e68e"},{"version":"7000f75dc3278de47fe168b83b89c96f054e394fbb1161a633329c34f990a0e3","signature":"60c51e31434ccc777c3d67ccc96892dd7e634816fb9fa5dc86e15d72de96ab3d"},"fa3b395916dbea25a701332418c116006d03842dbace79b3b27ff9e931926170",{"version":"9cccd72204546b7dd7b358c08f4eededfa632d159f2611ca1a1e83501272a5a0","signature":"0737161a05160e848162b2abba07c4e867f415362187b810f4b6764d2626d021"},{"version":"29f20688fd18bc5e0e65651280d8e1362a0e612e880085b4af756be6d6d294e3","signature":"8365c52f24004e601e9a8f7446cd7d233994b2fd73d544d1a0337f760c42b698"},{"version":"266666ccbe816528b98259123dc7b3697881a38781dd1e567943fb0e76569fca","signature":"69815e9eb00baef2634457bcf4952f69062d764211914619c6922dfa7760f8d2"},{"version":"5c04de864e7026516a04b45dc258ca7cf90d312836dc5ebd0d7b3f6905c24497","signature":"8223dfd33af509e0f333c678996f92d751a44a403a300a03faed958b462ebcaa"},{"version":"c6bc112265af45202ac2e8942dcfe771d2a5a528ed7254d296e5203b80093302","signature":"89c1eedc94aed52dad83eae64f48461643530a6ab1c2dcf3ae37ae42d118075b"},{"version":"3c04be6f8e434d09b095b6d4f670dab19c281484cc6dfb2aa59cd7303230ad20","signature":"551cbc9796c3629084a987a84a1a0e9957fcfb6fdfe1ee807dfe56f5a11a4148"},{"version":"363ccf04437a909a6cc34c81b5c9dd528fcee9b324d27e99d773a95e49e4cd19","signature":"eded5d62b954b7937089cfb84926bb40d60b8bf0d4ef03bbe92cf08404afc808"},{"version":"6fc3120606dd309e6fa17a5de730baeba2174a2db6c84419084423567beb6509","signature":"a22d45c921934e292071f5e249c804ad65f5b16280913aeee925a3530254a060"},{"version":"0071d503b52c36c9eb7cdb5f6a378ef6115a554745f030bec637514882dfa135","signature":"7167f98cada53080c300815de1e24f5eda5e9511caf5dfba8d1e3aaf6fe6d49e"},{"version":"b95cebc3e35171f497535e7b562ee282f7dd468afd639deefd0b3bb7e4bfa064","signature":"6a1267bfb8ba3b79837edf9b72418763a658156e2d09a0aa07382f4eb918aa29"},{"version":"ad04a322aa0effd6506ddd22bd24f5e7cb88b0fe3961907ba4623481adba8bb4","signature":"380543b1b41b88e3a6294b8419d5ed323c5da3a3051ab4a1d5677f525ee30698"},{"version":"7f6c2a054f6f87debc4478029218b57050245fa4e9cc2496e82b77d45b0a9d14","signature":"a22722f2344d703cdcc5ada42cbf84890ef527a2a6e9154fab5ddb362e64b955"},{"version":"da2dcb26b86cf2e4bc6f0c3e2c15c5f311d3dc2d8cd21913eb61e88a44f2b255","signature":"db18c2ffebf4c7f8d5ebb8f2541bc30bbb4f6cacebb42a5a9742ae883fd583e1"},{"version":"cc12f598e054d6d2c2723b25c45f61d4b226fd84c2fbb61305786e1898d3247a","signature":"866041185b44ade1456dc03de3dc85aad9c2b02dfd92d7f2068d46e28ea66201"},{"version":"5b22d5ff0e523683ea2397fe8b87dd5dd7fa240c533fffc7fdb7896e6105f958","signature":"088957f364ff2b9d3d76fbcb8f1ede5fc95c585854fedc09247c28e2a001f1d3"},{"version":"ba4a9c2c2f7f6154f687947a8994493802140518c0c95aaf3130b2ef79f661eb","signature":"640331bbaecab0948b9a40fc903666f103e94764cdfb0822d4124c147246c19a"},{"version":"e431b4039db512a65cbc0059caae4b5c0950f75cf24fdaeebdf1ff0d8d1008ea","signature":"e555e5752db30397ac4a0e61253faf77d77fc697f7312b20a0d0b3dbe28149f1"},{"version":"353045edf32c209a9a1a50acf4efd48c66e9c0ba99a8d9cb142a0af2b42874e6","signature":"48864a43f6c1032cb3fb5bfac020d4b2919791f49d8f31ff18f2dd3d4816005f"},{"version":"1a380f26ac98e86e4e1ffeff2ca67d1a80f9098110ba7d7b20696c7f1727564f","signature":"e9114172414f9836d9fab7346122951be30b66719d8277aa5f7a25580b9e21c7"},{"version":"7f28df7fb0b05e4793754d3b99b4d6e652177f90e38e954566971f267f2d50b9","signature":"220c93cd694e27d77b91f874f31e92d7514aa808fd95768b64552693043d00b9"},{"version":"28b2bd4084e4b54db3401bc743f130f2dec2b1cb90226c96ab11f8bd7552b265","signature":"ae4f0f443b828f28aaf843856dd25a8ab5e400f99581778f8977011c4a72d70d"},{"version":"1ab11dc560e48362f462254eecefcb58737d4dac59a3a1bf8a908b676231bb95","signature":"64ec4840e09c2f03bc97e86f6fbc5aac99bb6a067f20e06dc186a3784aba2862"},{"version":"ba16b4cfd7377e2f2bd55e8419fccb5d61b4174794de61a6b6def386f82ef644","signature":"dc29fe834b87d0d015c40a9f294ec7e1f2b7b322f102264e34374c8ea5ecffe6"},{"version":"1c88b77a700d3a0acf32a16b5e522fac68ae5ea7529ed51a320a479f0aaf7d29","signature":"46ab6033b2f210e498f5147c87b465aa564d1b9f64a431dd70b3f4f7cc5d6647"},{"version":"fa3030f1629a274031d5875bb61b5150ff78fccc0ea808c36a5450ab06e1f5f8","signature":"d369e126bb461a972a33aa3389dbfe011eecb71570c4b6706af17e99de4b95c8"},"cf3d384d082b933d987c4e2fe7bfb8710adfd9dc8155190056ed6695a25a559e","9871b7ee672bc16c78833bdab3052615834b08375cb144e4d2cba74473f4a589","c863198dae89420f3c552b5a03da6ed6d0acfa3807a64772b895db624b0de707","8b03a5e327d7db67112ebbc93b4f744133eda2c1743dbb0a990c61a8007823ef","86c73f2ee1752bac8eeeece234fd05dfcf0637a4fbd8032e4f5f43102faa8eec","42fad1f540271e35ca37cecda12c4ce2eef27f0f5cf0f8dd761d723c744d3159","ff3743a5de32bee10906aff63d1de726f6a7fd6ee2da4b8229054dfa69de2c34","83acd370f7f84f203e71ebba33ba61b7f1291ca027d7f9a662c6307d74e4ac22","1445cec898f90bdd18b2949b9590b3c012f5b7e1804e6e329fb0fe053946d5ec","0e5318ec2275d8da858b541920d9306650ae6ac8012f0e872fe66eb50321a669","cf530297c3fb3a92ec9591dd4fa229d58b5981e45fe6702a0bd2bea53a5e59be","c1f6f7d08d42148ddfe164d36d7aba91f467dbcb3caa715966ff95f55048b3a4","f4e9bf9103191ef3b3612d3ec0044ca4044ca5be27711fe648ada06fad4bcc85","0c1ee27b8f6a00097c2d6d91a21ee4d096ab52c1e28350f6362542b55380059a","7677d5b0db9e020d3017720f853ba18f415219fb3a9597343b1b1012cfd699f7","bc1c6bc119c1784b1a2be6d9c47addec0d83ef0d52c8fbe1f14a51b4dfffc675","52cf2ce99c2a23de70225e252e9822a22b4e0adb82643ab0b710858810e00bf1","770625067bb27a20b9826255a8d47b6b5b0a2d3dfcbd21f89904c731f671ba77","d1ed6765f4d7906a05968fb5cd6d1db8afa14dbe512a4884e8ea5c0f5e142c80","799c0f1b07c092626cf1efd71d459997635911bb5f7fc1196efe449bba87e965","2a184e4462b9914a30b1b5c41cf80c6d3428f17b20d3afb711fff3f0644001fd","9eabde32a3aa5d80de34af2c2206cdc3ee094c6504a8d0c2d6d20c7c179503cc","397c8051b6cfcb48aa22656f0faca2553c5f56187262135162ee79d2b2f6c966","a8ead142e0c87dcd5dc130eba1f8eeed506b08952d905c47621dc2f583b1bff9","a02f10ea5f73130efca046429254a4e3c06b5475baecc8f7b99a0014731be8b3","c2576a4083232b0e2d9bd06875dd43d371dee2e090325a9eac0133fd5650c1cb","4c9a0564bb317349de6a24eb4efea8bb79898fa72ad63a1809165f5bd42970dd","f40ac11d8859092d20f953aae14ba967282c3bb056431a37fced1866ec7a2681","cc11e9e79d4746cc59e0e17473a59d6f104692fd0eeea1bdb2e206eabed83b03","b444a410d34fb5e98aa5ee2b381362044f4884652e8bc8a11c8fe14bbd85518e","c35808c1f5e16d2c571aa65067e3cb95afeff843b259ecfa2fc107a9519b5392","14d5dc055143e941c8743c6a21fa459f961cbc3deedf1bfe47b11587ca4b3ef5","a3ad4e1fc542751005267d50a6298e6765928c0c3a8dce1572f2ba6ca518661c","f237e7c97a3a89f4591afd49ecb3bd8d14f51a1c4adc8fcae3430febedff5eb6","3ffdfbec93b7aed71082af62b8c3e0cc71261cc68d796665faa1e91604fbae8f","662201f943ed45b1ad600d03a90dffe20841e725203ced8b708c91fcd7f9379a","c9ef74c64ed051ea5b958621e7fb853fe3b56e8787c1587aefc6ea988b3c7e79","2462ccfac5f3375794b861abaa81da380f1bbd9401de59ffa43119a0b644253d","34baf65cfee92f110d6653322e2120c2d368ee64b3c7981dff08ed105c4f19b0","7d8ddf0f021c53099e34ee831a06c394d50371816caa98684812f089b4c6b3d4",{"version":"35c47f409790387f3373b9fbb9bbd43b0be78bd5906dae495cf5e736cc398e90","signature":"09a8bac36b99937410dc09bddc2f1144784b37effe18554d731553fae3b0216a"},{"version":"780e7c33e0bc102f7e9b819cf1bdbd89435cf02f4e8d22c6950f284947e8b615","signature":"3b06c402b4e046164c41bca77c95f2ff7708a95c5442767ab8876eae10ba3a90"},{"version":"c8c092918088e9c82b5001c0804dea101afc6c61baf49420285f0b8f0a89e228","signature":"20098686bca193d64e2f384f8ce794e275ec75b788f975aefe30aac93597aed9"},{"version":"a1cf8c0c26c533a71536334b487410616d5ebdd416a1175fa883a28d56fbbc59","signature":"84283c240848dfaafd987ef84c4208f9eb9b50af151237bb51168f7477385193"},{"version":"a5edef8ce8d9fd76e83525359c0a7e163c5583438c0f09bc5233a742b78ce344","signature":"2da21460c23a576317e17d761fb928310775dd7115ce2463899ce5656bd5589c"},{"version":"70f6dc27bb7014e784b1f9dd808342bba9442a9d1acb3eaf06e3d342baf8a5c0","signature":"53ae81158213a813fc41d57cd037c7df30a45cc0639c6b32fb391488b6d3ffdb"},{"version":"fbdd8f4a8d4107bf9c7d97b67696abad830c887f30695350b6319745a985ba79","signature":"cf51488c3fcb865bc0588815d68af871c3562b3530292846177e7181c7a89dd0"},{"version":"85d0b4ca6e678baaee4d8699bea97b60ddfc4bb1b4f5a0cef3333da9b917c382","signature":"4f816b7823609272ba222031811c03106ee7d873712cba494515837e391abfc8"},{"version":"dde47c07d6ba393c72f19f230579965ff5fbd87f35a755e15a921a84f9c017d6","signature":"f92ff82fe862ded7739daa830e8a764db480e82930432b4b391f4de0f230e059"},{"version":"3076ca45fc41fce046b251cb1aa3bffe3b2c1b9c095fe330a017677cd9ab10b0","signature":"64e05b5990564ffd9d7fe0568edcb986d4317a279f657aba834258b57b7dad87"},{"version":"28d95d6d76c7071130a02db2886ab766a1ca4f5beb17a04d974b91d4eb13b14d","signature":"992d7f3683734a9b695e87e3a3deac54ccc3955963002ab98f04fc22c721cf37"},{"version":"52ae32c232c0acac1aa061de017dea38c775a108a007811ebb2c49fd1e30ae6f","signature":"e683a3e3f5a4d6f88e4163c192941fea916529a6d7407bfe4f15b5de3855a367"},{"version":"ac75dd629410743a12a2169363d3f44eb81bfe67c54b4292b93d37f8901c57ac","signature":"00a5cac0ee58d07c5950c0c99de702d62d5717aadf753003d99154e8cfe854ec"},{"version":"8e0ebc83b6a12b08bb79e7c5215729c06f35ac2a9bffcfe227bd988f7beab63c","signature":"af7c971613fcae247e8a539c57c0418612f66a9d4b4a8de5055f9044925cad81"},{"version":"5b807e5990dd6a6994d025362dd3ec85e825508bbe58a73c578998d1a6a6a0d9","signature":"b132a8bac53c561fde537f5371abc0fa5d1e9ecaa26240ee27cbe9d5f1a036d0"},"c085e9aa62d1ae1375794c1fb927a445fa105fed891a7e24edbb1c3300f7384a","f315e1e65a1f80992f0509e84e4ae2df15ecd9ef73df975f7c98813b71e4c8da","5b9586e9b0b6322e5bfbd2c29bd3b8e21ab9d871f82346cb71020e3d84bae73e","3e70a7e67c2cb16f8cd49097360c0309fe9d1e3210ff9222e9dac1f8df9d4fb6","1d78c35b7e8ce86a188e3e5528cc5d1edfc85187a85177458d26e17c8b48105f",{"version":"bc32536f9ad4b87b9c7840d7792963325f79d2aa9d796245b45536ec8602e880","signature":"f83e5427150cc2ff63fef0a72e63f42fad416dd5d571a137ac0c4ee39f0628fc"},{"version":"dcb5ca825b61620db786da0dd9afaaece8a0224f66e1e82fa908d999aaef9035","signature":"b486c2aceca4ee80987a8ab93f57a2f28966efee141b9f80afd5d66b68552f1f"},{"version":"c6bd06f4e2d2e48e82a560f64c4993047d1029f6a337b876644d9946c97976ea","signature":"9e41f39e9240202cfe3f061b1d2743265de6aad2d2f5e9bcc13ccd26a64e70d6"},{"version":"224f6e7ef7c2300442d6b99c77ea4b34458362c08123f711478f6f618a5e3b2f","signature":"b84dbfef60c47b0b4a429d2a07ea7fe1f961eebdb32af9bdd7a66110c013a0b3"},{"version":"eb287c1b37052f20b1f0ddb4688aa6f723f38c013af83cd6f1561e0b477c739e","signature":"968ffdb87c470d380b6ea8db40761a2908278156c836f42c6e0c310b400a580a"},{"version":"f0b6690984c3a44b15740ac24bfb63853617731c0f40c87a956ce537c4b50969","affectsGlobalScope":true},"5f02abbb1b17e3d1e68c5eea14adf4705696e6255e2982b010c0dc2a5417b606","4eb1446ed6af6046fb8401915e08dd4453befdfd4aa4f5248576fd473ae89835","f0cb4b3ab88193e3e51e9e2622e4c375955003f1f81239d72c5b7a95415dad3e",{"version":"64d4b35c5456adf258d2cf56c341e203a073253f229ef3208fc0d5020253b241","affectsGlobalScope":true},"ee7d8894904b465b072be0d2e4b45cf6b887cdba16a467645c4e200982ece7ea","f3d8c757e148ad968f0d98697987db363070abada5f503da3c06aefd9d4248c1","0c5a621a8cf10464c2020f05c99a86d8ac6875d9e17038cb8522cc2f604d539f","e050a0afcdbb269720a900c85076d18e0c1ab73e580202a2bf6964978181222a","acdc9fb9638a235a69bd270003d8db4d6153ada2b7ccbea741ade36b295e431e","7394959e5a741b185456e1ef5d64599c36c60a323207450991e7a42e08911419","818f832a8e29ca7e128dcde810a9ff8cbc3754010474e29fff0a5ed95adae032","5929864ce17fba74232584d90cb721a89b7ad277220627cc97054ba15a98ea8f","7180c03fd3cb6e22f911ce9ba0f8a7008b1a6ddbe88ccf16a9c8140ef9ac1686","25c8056edf4314820382a5fdb4bb7816999acdcb929c8f75e3f39473b87e85bc","54cb85a47d760da1c13c00add10d26b5118280d44d58e6908d8e89abbd9d7725","3e4825171442666d31c845aeb47fcd34b62e14041bb353ae2b874285d78482aa","c6fd2c5a395f2432786c9cb8deb870b9b0e8ff7e22c029954fabdd692bff6195","a967bfe3ad4e62243eb604bf956101e4c740f5921277c60debaf325c1320bf88","e9775e97ac4877aebf963a0289c81abe76d1ec9a2a7778dbe637e5151f25c5f3","471e1da5a78350bc55ef8cef24eb3aca6174143c281b8b214ca2beda51f5e04a","cadc8aced301244057c4e7e73fbcae534b0f5b12a37b150d80e5a45aa4bebcbd","385aab901643aa54e1c36f5ef3107913b10d1b5bb8cbcd933d4263b80a0d7f20","9670d44354bab9d9982eca21945686b5c24a3f893db73c0dae0fd74217a4c219","db3435f3525cd785bf21ec6769bf8da7e8a776be1a99e2e7efb5f244a2ef5fee","c3b170c45fc031db31f782e612adf7314b167e60439d304b49e704010e7bafe5","40383ebef22b943d503c6ce2cb2e060282936b952a01bea5f9f493d5fb487cc7","4893a895ea92c85345017a04ed427cbd6a1710453338df26881a6019432febdd","3a84b7cb891141824bd00ef8a50b6a44596aded4075da937f180c90e362fe5f6","13f6f39e12b1518c6650bbb220c8985999020fe0f21d818e28f512b7771d00f9","9b5369969f6e7175740bf51223112ff209f94ba43ecd3bb09eefff9fd675624a","4fe9e626e7164748e8769bbf74b538e09607f07ed17c2f20af8d680ee49fc1da","24515859bc0b836719105bb6cc3d68255042a9f02a6022b3187948b204946bd2","33203609eba548914dc83ddf6cadbc0bcb6e8ef89f6d648ca0908ae887f9fcc5","0db18c6e78ea846316c012478888f33c11ffadab9efd1cc8bcc12daded7a60b6","89167d696a849fce5ca508032aabfe901c0868f833a8625d5a9c6e861ef935d2","e53a3c2a9f624d90f24bf4588aacd223e7bec1b9d0d479b68d2f4a9e6011147f","339dc5265ee5ed92e536a93a04c4ebbc2128f45eeec6ed29f379e0085283542c","9f0a92164925aa37d4a5d9dd3e0134cff8177208dba55fd2310cd74beea40ee2","8bfdb79bf1a9d435ec48d9372dc93291161f152c0865b81fc0b2694aedb4578d","2e85db9e6fd73cfa3d7f28e0ab6b55417ea18931423bd47b409a96e4a169e8e6","c46e079fe54c76f95c67fb89081b3e399da2c7d109e7dca8e4b58d83e332e605","d32275be3546f252e3ad33976caf8c5e842c09cb87d468cb40d5f4cf092d1acc","4a0c3504813a3289f7fb1115db13967c8e004aa8e4f8a9021b95285502221bd1",{"version":"a14ed46fa3f5ffc7a8336b497cd07b45c2084213aaca933a22443fcb2eef0d07","affectsGlobalScope":true},"cce1f5f86974c1e916ec4a8cab6eec9aa8e31e8148845bf07fbaa8e1d97b1a2c",{"version":"7fd7fcbf021a5845bdd9397d4649fcf2fe17152d2098140fc723099a215d19ad","affectsGlobalScope":true},"df3389f71a71a38bc931aaf1ef97a65fada98f0a27f19dd12f8b8de2b0f4e461","d69a3298a197fe5d59edba0ec23b4abf2c8e7b8c6718eac97833633cd664e4c9",{"version":"a9544f6f8af0d046565e8dde585502698ebc99eef28b715bad7c2bded62e4a32","affectsGlobalScope":true},"a40826e8476694e90da94aa008283a7de50d1dafd37beada623863f1901cb7fb",{"version":"8b809082dfeffc8cc4f3b9c59f55c0ff52ba12f5ae0766cb5c35deee83b8552e","affectsGlobalScope":true},"bd3f5d05b6b5e4bfcea7739a45f3ffb4a7f4a3442ba7baf93e0200799285b8f1","4c775c2fccabf49483c03cd5e3673f87c1ffb6079d98e7b81089c3def79e29c6","d4f9d3ae2fe1ae199e1c832cca2c44f45e0b305dfa2808afdd51249b6f4a5163","7525257b4aa35efc7a1bbc00f205a9a96c4e4ab791da90db41b77938c4e0c18e","b7fe70be794e13d1b7940e318b8770cd1fb3eced7707805318a2e3aaac2c3e9e",{"version":"ee1ee365d88c4c6c0c0a5a5701d66ebc27ccd0bcfcfaa482c6e2e7fe7b98edf7","affectsGlobalScope":true},{"version":"9c611eff81287837680c1f4496daf9e737d6f3a1ff17752207814b8f8e1265af","affectsGlobalScope":true},"fe1fd6afdfe77976d4c702f3746c05fb05a7e566845c890e0e970fe9376d6a90","b5d4e3e524f2eead4519c8e819eaf7fa44a27c22418eff1b7b2d0ebc5fdc510d","afb1701fd4be413a8a5a88df6befdd4510c30a31372c07a4138facf61594c66d","9bd8e5984676cf28ebffcc65620b4ab5cb38ab2ec0aac0825df8568856895653","396a8939b5e177542bdf9b5262b4eee85d29851b2d57681fa9d7eae30e225830","5e8dc64e7e68b2b3ea52ed685cf85239e0d5fb9df31aabc94370c6bc7e19077b",{"version":"ea455cc68871b049bcecd9f56d4cf27b852d6dafd5e3b54468ca87cc11604e4d","affectsGlobalScope":true},"c07146dbbbd8b347241b5df250a51e48f2d7bef19b1e187b1a3f20c849988ff1","45b1053e691c5af9bfe85060a3e1542835f8d84a7e6e2e77ca305251eda0cb3c","0f05c06ff6196958d76b865ae17245b52d8fe01773626ac3c43214a2458ea7b7",{"version":"ae5507fc333d637dec9f37c6b3f4d423105421ea2820a64818de55db85214d66","affectsGlobalScope":true},{"version":"46755a4afc53df75f0bfce72259fb971daac826b0cdd8c4eaccad2755a817403","affectsGlobalScope":true},"8abd0566d2854c4bd1c5e48e05df5c74927187f1541e6770001d9637ac41542e","54e854615c4eafbdd3fd7688bd02a3aafd0ccf0e87c98f79d3e9109f047ce6b8","d8dba11dc34d50cb4202de5effa9a1b296d7a2f4a029eec871f894bddfb6430d","8b71dd18e7e63b6f991b511a201fad7c3bf8d1e0dd98acb5e3d844f335a73634","01d8e1419c84affad359cc240b2b551fb9812b450b4d3d456b64cda8102d4f60","9eece5e586312581ccd106d4853e861aaaa1a39f8e3ea672b8c3847eedd12f6e","8221b00f271cf7f535a8eeec03b0f80f0929c7a16116e2d2df089b41066de69b","269929a24b2816343a178008ac9ae9248304d92a8ba8e233055e0ed6dbe6ef71","93452d394fdd1dc551ec62f5042366f011a00d342d36d50793b3529bfc9bd633","7fa32887f8a97909fca35ebba3740f8caf8df146618d8fff957a3f89f67a2f6a","9a9634296cca836c3308923ba7aa094fa6ed76bb1e366d8ddcf5c65888ab1024",{"version":"bddce945d552a963c9733db106b17a25474eefcab7fc990157a2134ef55d4954","affectsGlobalScope":true},{"version":"7052b7b0c3829df3b4985bab2fd74531074b4835d5a7b263b75c82f0916ad62f","affectsGlobalScope":true},"aa34c3aa493d1c699601027c441b9664547c3024f9dbab1639df7701d63d18fa","4b55240c2a03b2c71e98a7fc528b16136faa762211c92e781a01c37821915ea6","7c651f8dce91a927ab62925e73f190763574c46098f2b11fb8ddc1b147a6709a","7440ab60f4cb031812940cc38166b8bb6fbf2540cfe599f87c41c08011f0c1df",{"version":"94c086dff8dbc5998749326bc69b520e8e4273fb5b7b58b50e0210e0885dfcde","affectsGlobalScope":true},{"version":"f5b5dc128973498b75f52b1b8c2d5f8629869104899733ae485100c2309b4c12","affectsGlobalScope":true},"ebe5facd12fd7745cda5f4bc3319f91fb29dc1f96e57e9c6f8b260a7cc5b67ee","79bad8541d5779c85e82a9fb119c1fe06af77a71cc40f869d62ad379473d4b75","21c56c6e8eeacef15f63f373a29fab6a2b36e4705be7a528aae8c51469e2737b",{"version":"629d20681ca284d9e38c0a019f647108f5fe02f9c59ac164d56f5694fc3faf4d","affectsGlobalScope":true},"e7dbf5716d76846c7522e910896c5747b6df1abd538fee8f5291bdc843461795",{"version":"ab9b9a36e5284fd8d3bf2f7d5fcbc60052f25f27e4d20954782099282c60d23e","affectsGlobalScope":true},"a42be67ed1ddaec743582f41fc219db96a1b69719fccac6d1464321178d610fc","8841e2aa774b89bd23302dede20663306dc1b9902431ac64b24be8b8d0e3f649","fd326577c62145816fe1acc306c734c2396487f76719d3785d4e825b34540b33","9e951ec338c4232d611552a1be7b4ecec79a8c2307a893ce39701316fe2374bd","70c61ff569aabdf2b36220da6c06caaa27e45cd7acac81a1966ab4ee2eadc4f2","905c3e8f7ddaa6c391b60c05b2f4c3931d7127ad717a080359db3df510b7bdab","6c1e688f95fcaf53b1e41c0fdadf2c1cfc96fa924eaf7f9fdb60f96deb0a4986","0d14fa22c41fdc7277e6f71473b20ebc07f40f00e38875142335d5b63cdfc9d2","ab68d2a3e3e8767c3fba8f80de099a1cfc18c0de79e42cb02ae66e22dfe14a66","6d969939c4a63f70f2aa49e88da6f64b655c8e6799612807bef41ccff6ea0da9","5b9586e9b0b6322e5bfbd2c29bd3b8e21ab9d871f82346cb71020e3d84bae73e",{"version":"46894b2a21a60f8449ca6b2b7223b7179bba846a61b1434bed77b34b2902c306","affectsGlobalScope":true},"96d14f21b7652903852eef49379d04dbda28c16ed36468f8c9fa08f7c14c9538","8baa5d0febc68db886c40bf341e5c90dc215a90cd64552e47e8184be6b7e3358","c6c4fea9acc55d5e38ff2b70d57ab0b5cdbd08f8bc5d7a226e322cea128c5b57","9ad8802fd8850d22277c08f5653e69e551a2e003a376ce0afb3fe28474b51d65","fdfbe321c556c39a2ecf791d537b999591d0849e971dd938d88f460fea0186f6","105b9a2234dcb06ae922f2cd8297201136d416503ff7d16c72bfc8791e9895c1"],"root":[[74,76],[79,87],[89,173],[175,223],[225,227],[236,240],[242,279],282,[284,286],[290,295],[297,306],[310,321],[326,358],[399,413],[419,426]],"options":{"allowImportingTsExtensions":true,"composite":true,"declaration":true,"declarationDir":"../../dts","declarationMap":true,"emitDeclarationOnly":true,"esModuleInterop":true,"module":200,"noImplicitAny":true,"noImplicitThis":true,"rootDir":"../..","skipLibCheck":true,"strictBindCallApply":true,"target":99},"fileIdsList":[[323,324],[235,323],[232],[414],[232,234],[233],[230,232],[229,230,231],[229,232],[429,431],[428,429,430],[482,483,520,521],[523],[524],[416,529],[469,520,526,528],[417,527],[415],[433],[469],[470,475,504],[471,482,483,490,501,512],[471,472,482,490],[473,513],[474,475,483,491],[475,501,509],[476,478,482,490],[469,477],[478,479],[482],[480,482],[469,482],[482,483,484,501,512],[482,483,484,497,501,504],[467,470,517],[478,482,485,490,501,512],[482,483,485,486,490,501,509,512],[485,487,501,509,512],[433,434,468,469,470,471,472,473,474,475,476,477,478,479,480,481,482,483,484,485,486,487,488,489,490,491,492,493,494,495,496,497,498,499,500,501,502,503,504,505,506,507,508,509,510,511,512,513,514,515,516,517,518,519],[482,488],[489,512,517],[478,482,490,501],[491],[492],[469,493],[494,511,517],[495],[496],[482,497,498],[497,499,513,515],[470,482,501,502,503,504],[470,501,503],[501,502],[504],[505],[469,501],[482,507,508],[507,508],[475,490,501,509],[510],[490,511],[470,485,496,512],[475,513],[501,514],[489,515],[516],[470,475,482,484,493,501,512,515,517],[501,518],[359,398],[359,383,398],[398],[359],[359,384,398],[359,360,361,362,363,364,365,366,367,368,369,370,371,372,373,374,375,376,377,378,379,380,381,382,383,384,385,386,387,388,389,390,391,392,393,394,395,396,397],[384,398],[536],[416],[307,308],[77],[444,448,512],[444,501,512],[439],[441,444,509,512],[490,509],[520],[439,520],[441,444,490,512],[436,437,440,443,470,482,501,512],[436,442],[440,444,470,504,512,520],[470,520],[460,470,520],[438,439,520],[444],[438,439,440,441,442,443,444,445,446,448,449,450,451,452,453,454,455,456,457,458,459,461,462,463,464,465,466],[444,451,452],[442,444,452,453],[443],[436,439,444],[444,448,452,453],[448],[442,444,447,512],[436,441,442,444,448,451],[470,501],[439,444,460,470,517,520],[77,78,79],[298,313,342],[281,282,343],[228,281,300,304,305,310,311,312,315,336,339,342,492],[281,299,300,315,336,338,340,342],[228,281,300,301,302,303,304,305,309,310,315,331,342,483,489,492],[281,303,342],[303,306,332,334,335,336],[228,280,281,282,304,305,330,347,489,492,512],[281,302,303,305,492],[228,281,282,331,333,483,489,492,512],[347],[281,300,301,483],[279,281,282,300,305,312,313,314,315,318,319,339,340,342,343,345,357],[280,298,300,314,342,357],[281,304,315,318,340,342,345,346,357],[281,339,342,492],[281,313,319,336,338,340,342,343,344,492],[312,318],[281,339],[298,342],[298,337,338,342,492],[342],[205,255,298,305,315,317,319,339,340,341],[205,279,317,342,357],[304],[281],[281,483],[281,282],[163,205,212,279,316,330,336,344,347,352,353,354,355,356,357,489],[281,304,321,342,347,349],[80,205,281,347,348],[163,212,214,255],[163,281,304,328,347],[281,301,328,329,330,347],[281,304,328,347],[163,279,319,347],[80,163,214,279,280,351],[255,322,326,347,352],[325],[163,255,279,281,312,316,320,321,327,347,351,352],[163,228,281,322,347,349,350,352,483,492],[347,492],[163,352],[73,236],[163,254],[73,163,254],[163,247,248,254],[242,243,244,245,246,247,248,249,250,251,252],[163,241,254],[163,235,236,241,254],[163,238,239],[163],[73,163,240],[73,163,232,236,237,240,241,253,255],[232,235],[280,291,292,294],[280,291,292,296],[283,286,287,288,290,291,292,293,294,295,297],[280,290,291],[290],[280,286,290,291],[163,279],[235,357,398,483,489,492,512],[163,212,279],[163,279,433],[163,279,400,401,433],[163,279,401,402],[357],[357,403,404,405,406,408,409,410,433],[357,408],[76,217,357,492],[357,407,408,433],[218,357],[419,492,512],[73],[80,288,357,358,399,412,413,417,418,433,471,475,483,489,491,492,512,515],[74,75],[284,285],[284],[163,212],[163,213],[72,76,77,78],[167,181,190,194,203,204],[203],[165,168,170,171,172],[173],[169,173],[175,177,178,179,180,181,190,194,204],[73,182,186,190],[73,165,167,172,173,176,178,180,184,185,186,187,190,191,194,204],[177,190,193,203,204],[73,165,167,173,176,184,185,186,190,194],[165,185,190],[73,165,167,173,175,176,178,180,184,185,186,188,190,191,192,194,204],[165,167,173,175,176,177,178,179,180,183,184,188,190,194],[181,189,194,195,197,199,201,202],[165,167,173,176,185,186,190,194],[73,165,166,167,173,176,184,185,186,190,193,194,196],[165,176,177,190],[73,165,166,167,173,183,184,185,186,190,194,198],[73,165,167,173,176,185,186,190,194],[73,165,166,167,173,175,176,180,185,186,190,191,193,194,199,200],[165,173,176,177,190],[167,185,190,194],[73,93,165,166,167,173,175,181,183,184,186,187,190,204],[165,166,167,173,174,187,204],[166],[165,173,188,189,204],[165,173,176,188],[165,173,188,190],[73,76],[165,173,176,188,190],[163,181],[164,206,209,210],[164,206,211],[164,206,207,208],[205],[80,163,164,205,206],[163,206,207],[163,226,227,276],[163,220,226,276,279],[163,220],[163,226],[163,220,222,225,226,227,276,278],[163,276],[163,220,221,222,263,276],[163,218,269,276,278],[163,221,276],[163,276,277],[163,174,215,220,221,225,226,227,228,255,256,260,263,264,265,267,268,270,271,272,273,274,275,277,279],[163,259,276],[163,216,257,276],[163,257,258,276],[163,216,220,226,276],[163,215,276],[163,225,226,261,263,264,276],[163,225,262,267,276],[80,163,205,225,265,266,276,279],[163,226,276],[163,216,220,223,224,225,276,278,279],[163,216,217,218,222,278,279],[163,221,226,276,279],[163,215,219,279],[163,215,220,277,279],[110,163],[82,91,163],[107,114,163],[107,163],[82,106,163],[107],[83,108,163],[83,107,116,163],[105,163],[120,163],[83,104,163],[125,163],[127,163],[128,129,130,163],[94,163],[104],[134,163],[83,107,119,120,149,163],[136],[83,107,163],[83,163],[76,92],[83,120,142,163],[163,422],[92,107,163],[76,91,92,93,94,95,163],[95],[88,95,96,97,98,99,100,101,102,103],[95,99],[91,95,96],[91,105,163],[81,82,83,84,85,86,87,89,90,91,92,94,104,105,107,109,110,111,112,113,114,115,117,118,119,120,121,122,123,124,125,126,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,161,162],[94,131,163],[140,141,163],[149,163],[104,163],[84,163],[81,82,163],[81,89,90,104,163],[83,153,163],[83,89,163],[83,94,163],[92],[76],[85]],"referencedMap":[[325,1],[324,2],[323,3],[415,4],[235,5],[234,6],[231,7],[232,8],[230,9],[432,10],[431,11],[522,12],[524,13],[525,14],[531,15],[529,16],[528,17],[530,18],[433,19],[434,19],[469,20],[470,21],[471,22],[472,23],[473,24],[474,25],[475,26],[476,27],[477,28],[478,29],[479,29],[481,30],[480,31],[482,32],[483,33],[484,34],[468,35],[485,36],[486,37],[487,38],[520,39],[488,40],[489,41],[490,42],[491,43],[492,44],[493,45],[494,46],[495,47],[496,48],[497,49],[498,49],[499,50],[501,51],[503,52],[502,53],[504,54],[505,55],[506,56],[507,57],[508,58],[509,59],[510,60],[511,61],[512,62],[513,63],[514,64],[515,65],[516,66],[517,67],[518,68],[383,69],[384,70],[359,71],[362,71],[381,69],[382,69],[372,69],[371,72],[369,69],[364,69],[377,69],[375,69],[379,69],[363,69],[376,69],[380,69],[365,69],[366,69],[378,69],[360,69],[367,69],[368,69],[370,69],[374,69],[385,73],[373,69],[361,69],[398,74],[392,73],[394,75],[393,73],[386,73],[387,73],[389,73],[391,73],[395,75],[396,75],[388,75],[390,75],[537,76],[417,77],[416,18],[309,78],[78,79],[451,80],[458,81],[450,80],[465,82],[442,83],[441,84],[464,85],[459,86],[462,87],[444,88],[443,89],[439,90],[438,91],[461,92],[440,93],[445,94],[449,94],[467,95],[466,94],[453,96],[454,97],[456,98],[452,99],[455,100],[460,85],[447,101],[448,102],[457,103],[437,104],[463,105],[80,106],[314,107],[300,108],[313,109],[339,110],[332,111],[335,112],[336,113],[331,114],[306,115],[334,116],[303,117],[302,118],[346,119],[315,120],[347,121],[340,122],[345,123],[310,44],[319,124],[311,125],[337,126],[338,127],[343,128],[317,126],[342,129],[318,130],[305,131],[282,132],[301,133],[299,134],[357,135],[356,136],[349,137],[353,138],[355,139],[330,140],[354,141],[320,142],[352,143],[327,144],[326,145],[328,146],[351,147],[321,148],[316,149],[237,150],[250,151],[245,152],[243,151],[249,153],[253,154],[251,151],[246,151],[247,151],[244,152],[242,151],[248,155],[252,151],[255,156],[240,157],[239,158],[238,159],[254,160],[236,161],[358,158],[295,162],[297,163],[298,164],[294,165],[291,166],[292,167],[218,168],[399,169],[269,170],[266,168],[400,171],[402,172],[403,173],[401,168],[404,174],[411,175],[410,176],[408,177],[409,178],[406,179],[420,180],[421,174],[407,168],[217,168],[93,181],[419,182],[413,3],[74,181],[76,183],[286,184],[285,185],[213,186],[214,187],[79,188],[205,189],[204,190],[173,191],[168,192],[172,193],[170,193],[171,192],[182,194],[187,195],[192,196],[194,197],[191,198],[186,199],[193,200],[185,201],[203,202],[195,203],[197,204],[196,205],[199,206],[189,207],[201,208],[200,209],[202,210],[188,211],[175,212],[167,213],[190,214],[179,215],[178,216],[184,217],[177,218],[183,181],[425,158],[426,219],[211,220],[164,158],[212,221],[210,222],[206,223],[207,224],[208,225],[209,222],[225,226],[221,227],[219,228],[227,229],[279,230],[256,231],[273,231],[264,232],[270,233],[268,231],[272,234],[274,231],[275,235],[276,236],[260,237],[258,238],[259,239],[257,158],[271,231],[261,240],[262,231],[277,241],[215,158],[265,242],[263,243],[267,244],[216,245],[226,246],[223,247],[222,248],[220,249],[278,250],[111,251],[112,252],[115,253],[113,254],[107,255],[119,256],[109,257],[117,258],[106,259],[121,260],[122,260],[123,260],[120,261],[124,260],[126,262],[125,158],[128,263],[129,263],[130,263],[131,264],[132,265],[133,266],[135,267],[422,268],[137,269],[134,270],[138,270],[139,271],[136,272],[143,273],[423,274],[144,270],[145,275],[96,276],[101,277],[97,277],[104,278],[98,277],[100,279],[99,277],[102,280],[95,281],[163,282],[146,254],[114,271],[147,283],[148,254],[141,265],[142,284],[116,271],[149,271],[150,285],[151,286],[140,286],[127,158],[108,254],[85,287],[83,288],[91,289],[152,285],[154,290],[155,291],[153,292],[110,286],[156,286],[90,266],[157,158],[158,271],[159,271],[89,286],[160,293],[92,294],[161,292],[84,271],[86,295],[105,286]],"latestChangedDtsFile":"../../dts/packages/babel-types/src/converters/toSequenceExpression.d.ts"},"version":"5.5.3"} \ No newline at end of file diff --git a/tools/eslint/node_modules/@babel/helper-simple-access/LICENSE b/tools/eslint/node_modules/@babel/helper-simple-access/LICENSE deleted file mode 100644 index f31575ec773bb1..00000000000000 --- a/tools/eslint/node_modules/@babel/helper-simple-access/LICENSE +++ /dev/null @@ -1,22 +0,0 @@ -MIT License - -Copyright (c) 2014-present Sebastian McKenzie and other contributors - -Permission is hereby granted, free of charge, to any person obtaining -a copy of this software and associated documentation files (the -"Software"), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sublicense, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/tools/eslint/node_modules/@babel/helper-simple-access/lib/index.js b/tools/eslint/node_modules/@babel/helper-simple-access/lib/index.js deleted file mode 100644 index 8965ab42c63694..00000000000000 --- a/tools/eslint/node_modules/@babel/helper-simple-access/lib/index.js +++ /dev/null @@ -1,91 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.default = simplifyAccess; -var _t = require("@babel/types"); -const { - LOGICAL_OPERATORS, - assignmentExpression, - binaryExpression, - cloneNode, - identifier, - logicalExpression, - numericLiteral, - sequenceExpression, - unaryExpression -} = _t; -const simpleAssignmentVisitor = { - AssignmentExpression: { - exit(path) { - const { - scope, - seen, - bindingNames - } = this; - if (path.node.operator === "=") return; - if (seen.has(path.node)) return; - 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))); - } else { - path.node.right = binaryExpression(operator, cloneNode(path.node.left), path.node.right); - path.node.operator = "="; - } - } - } -}; -{ - simpleAssignmentVisitor.UpdateExpression = { - exit(path) { - if (!this.includeUpdateExpression) return; - const { - scope, - bindingNames - } = this; - const arg = path.get("argument"); - if (!arg.isIdentifier()) return; - const localName = arg.node.name; - if (!bindingNames.has(localName)) return; - 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))); - } else if (path.node.prefix) { - path.replaceWith(assignmentExpression("=", identifier(localName), binaryExpression(path.node.operator[0], unaryExpression("+", arg.node), numericLiteral(1)))); - } else { - const old = path.scope.generateUidIdentifierBasedOnNode(arg.node, "old"); - const varName = old.name; - path.scope.push({ - id: old - }); - 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)])); - } - } - }; -} -function simplifyAccess(path, bindingNames) { - { - var _arguments$; - path.traverse(simpleAssignmentVisitor, { - scope: path.scope, - bindingNames, - seen: new WeakSet(), - includeUpdateExpression: (_arguments$ = arguments[2]) != null ? _arguments$ : true - }); - } -} - -//# sourceMappingURL=index.js.map diff --git a/tools/eslint/node_modules/@babel/helper-simple-access/package.json b/tools/eslint/node_modules/@babel/helper-simple-access/package.json deleted file mode 100644 index 852aabb3e20b9f..00000000000000 --- a/tools/eslint/node_modules/@babel/helper-simple-access/package.json +++ /dev/null @@ -1,28 +0,0 @@ -{ - "name": "@babel/helper-simple-access", - "version": "7.24.7", - "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", - "license": "MIT", - "publishConfig": { - "access": "public" - }, - "repository": { - "type": "git", - "url": "https://github.com/babel/babel.git", - "directory": "packages/babel-helper-simple-access" - }, - "main": "./lib/index.js", - "dependencies": { - "@babel/traverse": "^7.24.7", - "@babel/types": "^7.24.7" - }, - "devDependencies": { - "@babel/core": "^7.24.7" - }, - "engines": { - "node": ">=6.9.0" - }, - "type": "commonjs" -} \ No newline at end of file diff --git a/tools/eslint/node_modules/@babel/helper-split-export-declaration/LICENSE b/tools/eslint/node_modules/@babel/helper-split-export-declaration/LICENSE deleted file mode 100644 index f31575ec773bb1..00000000000000 --- a/tools/eslint/node_modules/@babel/helper-split-export-declaration/LICENSE +++ /dev/null @@ -1,22 +0,0 @@ -MIT License - -Copyright (c) 2014-present Sebastian McKenzie and other contributors - -Permission is hereby granted, free of charge, to any person obtaining -a copy of this software and associated documentation files (the -"Software"), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sublicense, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/tools/eslint/node_modules/@babel/helper-split-export-declaration/lib/index.js b/tools/eslint/node_modules/@babel/helper-split-export-declaration/lib/index.js deleted file mode 100644 index 1bbc01d6defe9d..00000000000000 --- a/tools/eslint/node_modules/@babel/helper-split-export-declaration/lib/index.js +++ /dev/null @@ -1,59 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.default = splitExportDeclaration; -var _t = require("@babel/types"); -const { - cloneNode, - exportNamedDeclaration, - exportSpecifier, - identifier, - variableDeclaration, - variableDeclarator -} = _t; -function splitExportDeclaration(exportDeclaration) { - if (!exportDeclaration.isExportDeclaration() || exportDeclaration.isExportAllDeclaration()) { - throw new Error("Only default and named export declarations can be split."); - } - if (exportDeclaration.isExportDefaultDeclaration()) { - const declaration = exportDeclaration.get("declaration"); - const standaloneDeclaration = declaration.isFunctionDeclaration() || declaration.isClassDeclaration(); - const exportExpr = declaration.isFunctionExpression() || declaration.isClassExpression(); - const scope = declaration.isScope() ? declaration.scope.parent : declaration.scope; - let id = declaration.node.id; - let needBindingRegistration = false; - if (!id) { - needBindingRegistration = true; - id = scope.generateUidIdentifier("default"); - if (standaloneDeclaration || exportExpr) { - declaration.node.id = cloneNode(id); - } - } else if (exportExpr && scope.hasBinding(id.name)) { - needBindingRegistration = true; - id = scope.generateUidIdentifier(id.name); - } - const updatedDeclaration = standaloneDeclaration ? declaration.node : variableDeclaration("var", [variableDeclarator(cloneNode(id), declaration.node)]); - const updatedExportDeclaration = exportNamedDeclaration(null, [exportSpecifier(cloneNode(id), identifier("default"))]); - exportDeclaration.insertAfter(updatedExportDeclaration); - exportDeclaration.replaceWith(updatedDeclaration); - if (needBindingRegistration) { - scope.registerDeclaration(exportDeclaration); - } - return exportDeclaration; - } else if (exportDeclaration.get("specifiers").length > 0) { - throw new Error("It doesn't make sense to split exported specifiers."); - } - const declaration = exportDeclaration.get("declaration"); - const bindingIdentifiers = declaration.getOuterBindingIdentifiers(); - const specifiers = Object.keys(bindingIdentifiers).map(name => { - return exportSpecifier(identifier(name), identifier(name)); - }); - const aliasDeclar = exportNamedDeclaration(null, specifiers); - exportDeclaration.insertAfter(aliasDeclar); - exportDeclaration.replaceWith(declaration.node); - return exportDeclaration; -} - -//# sourceMappingURL=index.js.map diff --git a/tools/eslint/node_modules/@babel/helper-split-export-declaration/package.json b/tools/eslint/node_modules/@babel/helper-split-export-declaration/package.json deleted file mode 100644 index f03c754dbd960c..00000000000000 --- a/tools/eslint/node_modules/@babel/helper-split-export-declaration/package.json +++ /dev/null @@ -1,27 +0,0 @@ -{ - "name": "@babel/helper-split-export-declaration", - "version": "7.24.7", - "description": "", - "repository": { - "type": "git", - "url": "https://github.com/babel/babel.git", - "directory": "packages/babel-helper-split-export-declaration" - }, - "homepage": "https://babel.dev/docs/en/next/babel-helper-split-export-declaration", - "license": "MIT", - "publishConfig": { - "access": "public" - }, - "main": "./lib/index.js", - "dependencies": { - "@babel/types": "^7.24.7" - }, - "devDependencies": { - "@babel/traverse": "^7.24.7" - }, - "engines": { - "node": ">=6.9.0" - }, - "author": "The Babel Team (https://babel.dev/team)", - "type": "commonjs" -} \ No newline at end of file diff --git a/tools/eslint/node_modules/@babel/helper-string-parser/LICENSE b/tools/eslint/node_modules/@babel/helper-string-parser/LICENSE deleted file mode 100644 index f31575ec773bb1..00000000000000 --- a/tools/eslint/node_modules/@babel/helper-string-parser/LICENSE +++ /dev/null @@ -1,22 +0,0 @@ -MIT License - -Copyright (c) 2014-present Sebastian McKenzie and other contributors - -Permission is hereby granted, free of charge, to any person obtaining -a copy of this software and associated documentation files (the -"Software"), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sublicense, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/tools/eslint/node_modules/@babel/helper-string-parser/lib/index.js b/tools/eslint/node_modules/@babel/helper-string-parser/lib/index.js deleted file mode 100644 index 2d9411552aa5c2..00000000000000 --- a/tools/eslint/node_modules/@babel/helper-string-parser/lib/index.js +++ /dev/null @@ -1,295 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.readCodePoint = readCodePoint; -exports.readInt = readInt; -exports.readStringContents = readStringContents; -var _isDigit = function isDigit(code) { - return code >= 48 && code <= 57; -}; -const forbiddenNumericSeparatorSiblings = { - decBinOct: new Set([46, 66, 69, 79, 95, 98, 101, 111]), - hex: new Set([46, 88, 95, 120]) -}; -const isAllowedNumericSeparatorSibling = { - bin: ch => ch === 48 || ch === 49, - oct: ch => ch >= 48 && ch <= 55, - dec: ch => ch >= 48 && ch <= 57, - hex: ch => ch >= 48 && ch <= 57 || ch >= 65 && ch <= 70 || ch >= 97 && ch <= 102 -}; -function readStringContents(type, input, pos, lineStart, curLine, errors) { - const initialPos = pos; - const initialLineStart = lineStart; - const initialCurLine = curLine; - let out = ""; - let firstInvalidLoc = null; - let chunkStart = pos; - const { - length - } = input; - for (;;) { - if (pos >= length) { - errors.unterminated(initialPos, initialLineStart, initialCurLine); - out += input.slice(chunkStart, pos); - break; - } - const ch = input.charCodeAt(pos); - if (isStringEnd(type, ch, input, pos)) { - out += input.slice(chunkStart, pos); - break; - } - if (ch === 92) { - out += input.slice(chunkStart, pos); - const res = readEscapedChar(input, pos, lineStart, curLine, type === "template", errors); - if (res.ch === null && !firstInvalidLoc) { - firstInvalidLoc = { - pos, - lineStart, - curLine - }; - } else { - out += res.ch; - } - ({ - pos, - lineStart, - curLine - } = res); - chunkStart = pos; - } else if (ch === 8232 || ch === 8233) { - ++pos; - ++curLine; - lineStart = pos; - } else if (ch === 10 || ch === 13) { - if (type === "template") { - out += input.slice(chunkStart, pos) + "\n"; - ++pos; - if (ch === 13 && input.charCodeAt(pos) === 10) { - ++pos; - } - ++curLine; - chunkStart = lineStart = pos; - } else { - errors.unterminated(initialPos, initialLineStart, initialCurLine); - } - } else { - ++pos; - } - } - return { - pos, - str: out, - firstInvalidLoc, - lineStart, - curLine, - containsInvalid: !!firstInvalidLoc - }; -} -function isStringEnd(type, ch, input, pos) { - if (type === "template") { - return ch === 96 || ch === 36 && input.charCodeAt(pos + 1) === 123; - } - return ch === (type === "double" ? 34 : 39); -} -function readEscapedChar(input, pos, lineStart, curLine, inTemplate, errors) { - const throwOnInvalid = !inTemplate; - pos++; - const res = ch => ({ - pos, - ch, - lineStart, - curLine - }); - const ch = input.charCodeAt(pos++); - switch (ch) { - case 110: - return res("\n"); - case 114: - return res("\r"); - case 120: - { - let code; - ({ - code, - pos - } = readHexChar(input, pos, lineStart, curLine, 2, false, throwOnInvalid, errors)); - return res(code === null ? null : String.fromCharCode(code)); - } - case 117: - { - let code; - ({ - code, - pos - } = readCodePoint(input, pos, lineStart, curLine, throwOnInvalid, errors)); - return res(code === null ? null : String.fromCodePoint(code)); - } - case 116: - return res("\t"); - case 98: - return res("\b"); - case 118: - return res("\u000b"); - case 102: - return res("\f"); - case 13: - if (input.charCodeAt(pos) === 10) { - ++pos; - } - case 10: - lineStart = pos; - ++curLine; - case 8232: - case 8233: - return res(""); - case 56: - case 57: - if (inTemplate) { - return res(null); - } else { - errors.strictNumericEscape(pos - 1, lineStart, curLine); - } - default: - if (ch >= 48 && ch <= 55) { - const startPos = pos - 1; - const match = /^[0-7]+/.exec(input.slice(startPos, pos + 2)); - let octalStr = match[0]; - let octal = parseInt(octalStr, 8); - if (octal > 255) { - octalStr = octalStr.slice(0, -1); - octal = parseInt(octalStr, 8); - } - pos += octalStr.length - 1; - const next = input.charCodeAt(pos); - if (octalStr !== "0" || next === 56 || next === 57) { - if (inTemplate) { - return res(null); - } else { - errors.strictNumericEscape(startPos, lineStart, curLine); - } - } - return res(String.fromCharCode(octal)); - } - return res(String.fromCharCode(ch)); - } -} -function readHexChar(input, pos, lineStart, curLine, len, forceLen, throwOnInvalid, errors) { - const initialPos = pos; - let n; - ({ - n, - pos - } = readInt(input, pos, lineStart, curLine, 16, len, forceLen, false, errors, !throwOnInvalid)); - if (n === null) { - if (throwOnInvalid) { - errors.invalidEscapeSequence(initialPos, lineStart, curLine); - } else { - pos = initialPos - 1; - } - } - return { - code: n, - pos - }; -} -function readInt(input, pos, lineStart, curLine, radix, len, forceLen, allowNumSeparator, errors, bailOnError) { - const start = pos; - const forbiddenSiblings = radix === 16 ? forbiddenNumericSeparatorSiblings.hex : forbiddenNumericSeparatorSiblings.decBinOct; - const isAllowedSibling = radix === 16 ? isAllowedNumericSeparatorSibling.hex : radix === 10 ? isAllowedNumericSeparatorSibling.dec : radix === 8 ? isAllowedNumericSeparatorSibling.oct : isAllowedNumericSeparatorSibling.bin; - let invalid = false; - let total = 0; - for (let i = 0, e = len == null ? Infinity : len; i < e; ++i) { - const code = input.charCodeAt(pos); - let val; - if (code === 95 && allowNumSeparator !== "bail") { - const prev = input.charCodeAt(pos - 1); - const next = input.charCodeAt(pos + 1); - if (!allowNumSeparator) { - if (bailOnError) return { - n: null, - pos - }; - errors.numericSeparatorInEscapeSequence(pos, lineStart, curLine); - } else if (Number.isNaN(next) || !isAllowedSibling(next) || forbiddenSiblings.has(prev) || forbiddenSiblings.has(next)) { - if (bailOnError) return { - n: null, - pos - }; - errors.unexpectedNumericSeparator(pos, lineStart, curLine); - } - ++pos; - continue; - } - if (code >= 97) { - val = code - 97 + 10; - } else if (code >= 65) { - val = code - 65 + 10; - } else if (_isDigit(code)) { - val = code - 48; - } else { - val = Infinity; - } - if (val >= radix) { - if (val <= 9 && bailOnError) { - return { - n: null, - pos - }; - } else if (val <= 9 && errors.invalidDigit(pos, lineStart, curLine, radix)) { - val = 0; - } else if (forceLen) { - val = 0; - invalid = true; - } else { - break; - } - } - ++pos; - total = total * radix + val; - } - if (pos === start || len != null && pos - start !== len || invalid) { - return { - n: null, - pos - }; - } - return { - n: total, - pos - }; -} -function readCodePoint(input, pos, lineStart, curLine, throwOnInvalid, errors) { - const ch = input.charCodeAt(pos); - let code; - if (ch === 123) { - ++pos; - ({ - code, - pos - } = readHexChar(input, pos, lineStart, curLine, input.indexOf("}", pos) - pos, true, throwOnInvalid, errors)); - ++pos; - if (code !== null && code > 0x10ffff) { - if (throwOnInvalid) { - errors.invalidCodePoint(pos, lineStart, curLine); - } else { - return { - code: null, - pos - }; - } - } - } else { - ({ - code, - pos - } = readHexChar(input, pos, lineStart, curLine, 4, false, throwOnInvalid, errors)); - } - return { - code, - pos - }; -} - -//# sourceMappingURL=index.js.map diff --git a/tools/eslint/node_modules/@babel/helper-string-parser/package.json b/tools/eslint/node_modules/@babel/helper-string-parser/package.json deleted file mode 100644 index 8c7e067bcfcd98..00000000000000 --- a/tools/eslint/node_modules/@babel/helper-string-parser/package.json +++ /dev/null @@ -1,31 +0,0 @@ -{ - "name": "@babel/helper-string-parser", - "version": "7.24.8", - "description": "A utility package to parse strings", - "repository": { - "type": "git", - "url": "https://github.com/babel/babel.git", - "directory": "packages/babel-helper-string-parser" - }, - "homepage": "https://babel.dev/docs/en/next/babel-helper-string-parser", - "license": "MIT", - "publishConfig": { - "access": "public" - }, - "main": "./lib/index.js", - "devDependencies": { - "charcodes": "^0.2.0" - }, - "engines": { - "node": ">=6.9.0" - }, - "author": "The Babel Team (https://babel.dev/team)", - "exports": { - ".": { - "types": "./lib/index.d.ts", - "default": "./lib/index.js" - }, - "./package.json": "./package.json" - }, - "type": "commonjs" -} \ No newline at end of file diff --git a/tools/eslint/node_modules/@babel/helper-validator-identifier/LICENSE b/tools/eslint/node_modules/@babel/helper-validator-identifier/LICENSE deleted file mode 100644 index f31575ec773bb1..00000000000000 --- a/tools/eslint/node_modules/@babel/helper-validator-identifier/LICENSE +++ /dev/null @@ -1,22 +0,0 @@ -MIT License - -Copyright (c) 2014-present Sebastian McKenzie and other contributors - -Permission is hereby granted, free of charge, to any person obtaining -a copy of this software and associated documentation files (the -"Software"), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sublicense, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/tools/eslint/node_modules/@babel/helper-validator-identifier/lib/identifier.js b/tools/eslint/node_modules/@babel/helper-validator-identifier/lib/identifier.js deleted file mode 100644 index 8ef8303613598e..00000000000000 --- a/tools/eslint/node_modules/@babel/helper-validator-identifier/lib/identifier.js +++ /dev/null @@ -1,70 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.isIdentifierChar = isIdentifierChar; -exports.isIdentifierName = isIdentifierName; -exports.isIdentifierStart = isIdentifierStart; -let nonASCIIidentifierStartChars = "\xaa\xb5\xba\xc0-\xd6\xd8-\xf6\xf8-\u02c1\u02c6-\u02d1\u02e0-\u02e4\u02ec\u02ee\u0370-\u0374\u0376\u0377\u037a-\u037d\u037f\u0386\u0388-\u038a\u038c\u038e-\u03a1\u03a3-\u03f5\u03f7-\u0481\u048a-\u052f\u0531-\u0556\u0559\u0560-\u0588\u05d0-\u05ea\u05ef-\u05f2\u0620-\u064a\u066e\u066f\u0671-\u06d3\u06d5\u06e5\u06e6\u06ee\u06ef\u06fa-\u06fc\u06ff\u0710\u0712-\u072f\u074d-\u07a5\u07b1\u07ca-\u07ea\u07f4\u07f5\u07fa\u0800-\u0815\u081a\u0824\u0828\u0840-\u0858\u0860-\u086a\u0870-\u0887\u0889-\u088e\u08a0-\u08c9\u0904-\u0939\u093d\u0950\u0958-\u0961\u0971-\u0980\u0985-\u098c\u098f\u0990\u0993-\u09a8\u09aa-\u09b0\u09b2\u09b6-\u09b9\u09bd\u09ce\u09dc\u09dd\u09df-\u09e1\u09f0\u09f1\u09fc\u0a05-\u0a0a\u0a0f\u0a10\u0a13-\u0a28\u0a2a-\u0a30\u0a32\u0a33\u0a35\u0a36\u0a38\u0a39\u0a59-\u0a5c\u0a5e\u0a72-\u0a74\u0a85-\u0a8d\u0a8f-\u0a91\u0a93-\u0aa8\u0aaa-\u0ab0\u0ab2\u0ab3\u0ab5-\u0ab9\u0abd\u0ad0\u0ae0\u0ae1\u0af9\u0b05-\u0b0c\u0b0f\u0b10\u0b13-\u0b28\u0b2a-\u0b30\u0b32\u0b33\u0b35-\u0b39\u0b3d\u0b5c\u0b5d\u0b5f-\u0b61\u0b71\u0b83\u0b85-\u0b8a\u0b8e-\u0b90\u0b92-\u0b95\u0b99\u0b9a\u0b9c\u0b9e\u0b9f\u0ba3\u0ba4\u0ba8-\u0baa\u0bae-\u0bb9\u0bd0\u0c05-\u0c0c\u0c0e-\u0c10\u0c12-\u0c28\u0c2a-\u0c39\u0c3d\u0c58-\u0c5a\u0c5d\u0c60\u0c61\u0c80\u0c85-\u0c8c\u0c8e-\u0c90\u0c92-\u0ca8\u0caa-\u0cb3\u0cb5-\u0cb9\u0cbd\u0cdd\u0cde\u0ce0\u0ce1\u0cf1\u0cf2\u0d04-\u0d0c\u0d0e-\u0d10\u0d12-\u0d3a\u0d3d\u0d4e\u0d54-\u0d56\u0d5f-\u0d61\u0d7a-\u0d7f\u0d85-\u0d96\u0d9a-\u0db1\u0db3-\u0dbb\u0dbd\u0dc0-\u0dc6\u0e01-\u0e30\u0e32\u0e33\u0e40-\u0e46\u0e81\u0e82\u0e84\u0e86-\u0e8a\u0e8c-\u0ea3\u0ea5\u0ea7-\u0eb0\u0eb2\u0eb3\u0ebd\u0ec0-\u0ec4\u0ec6\u0edc-\u0edf\u0f00\u0f40-\u0f47\u0f49-\u0f6c\u0f88-\u0f8c\u1000-\u102a\u103f\u1050-\u1055\u105a-\u105d\u1061\u1065\u1066\u106e-\u1070\u1075-\u1081\u108e\u10a0-\u10c5\u10c7\u10cd\u10d0-\u10fa\u10fc-\u1248\u124a-\u124d\u1250-\u1256\u1258\u125a-\u125d\u1260-\u1288\u128a-\u128d\u1290-\u12b0\u12b2-\u12b5\u12b8-\u12be\u12c0\u12c2-\u12c5\u12c8-\u12d6\u12d8-\u1310\u1312-\u1315\u1318-\u135a\u1380-\u138f\u13a0-\u13f5\u13f8-\u13fd\u1401-\u166c\u166f-\u167f\u1681-\u169a\u16a0-\u16ea\u16ee-\u16f8\u1700-\u1711\u171f-\u1731\u1740-\u1751\u1760-\u176c\u176e-\u1770\u1780-\u17b3\u17d7\u17dc\u1820-\u1878\u1880-\u18a8\u18aa\u18b0-\u18f5\u1900-\u191e\u1950-\u196d\u1970-\u1974\u1980-\u19ab\u19b0-\u19c9\u1a00-\u1a16\u1a20-\u1a54\u1aa7\u1b05-\u1b33\u1b45-\u1b4c\u1b83-\u1ba0\u1bae\u1baf\u1bba-\u1be5\u1c00-\u1c23\u1c4d-\u1c4f\u1c5a-\u1c7d\u1c80-\u1c88\u1c90-\u1cba\u1cbd-\u1cbf\u1ce9-\u1cec\u1cee-\u1cf3\u1cf5\u1cf6\u1cfa\u1d00-\u1dbf\u1e00-\u1f15\u1f18-\u1f1d\u1f20-\u1f45\u1f48-\u1f4d\u1f50-\u1f57\u1f59\u1f5b\u1f5d\u1f5f-\u1f7d\u1f80-\u1fb4\u1fb6-\u1fbc\u1fbe\u1fc2-\u1fc4\u1fc6-\u1fcc\u1fd0-\u1fd3\u1fd6-\u1fdb\u1fe0-\u1fec\u1ff2-\u1ff4\u1ff6-\u1ffc\u2071\u207f\u2090-\u209c\u2102\u2107\u210a-\u2113\u2115\u2118-\u211d\u2124\u2126\u2128\u212a-\u2139\u213c-\u213f\u2145-\u2149\u214e\u2160-\u2188\u2c00-\u2ce4\u2ceb-\u2cee\u2cf2\u2cf3\u2d00-\u2d25\u2d27\u2d2d\u2d30-\u2d67\u2d6f\u2d80-\u2d96\u2da0-\u2da6\u2da8-\u2dae\u2db0-\u2db6\u2db8-\u2dbe\u2dc0-\u2dc6\u2dc8-\u2dce\u2dd0-\u2dd6\u2dd8-\u2dde\u3005-\u3007\u3021-\u3029\u3031-\u3035\u3038-\u303c\u3041-\u3096\u309b-\u309f\u30a1-\u30fa\u30fc-\u30ff\u3105-\u312f\u3131-\u318e\u31a0-\u31bf\u31f0-\u31ff\u3400-\u4dbf\u4e00-\ua48c\ua4d0-\ua4fd\ua500-\ua60c\ua610-\ua61f\ua62a\ua62b\ua640-\ua66e\ua67f-\ua69d\ua6a0-\ua6ef\ua717-\ua71f\ua722-\ua788\ua78b-\ua7ca\ua7d0\ua7d1\ua7d3\ua7d5-\ua7d9\ua7f2-\ua801\ua803-\ua805\ua807-\ua80a\ua80c-\ua822\ua840-\ua873\ua882-\ua8b3\ua8f2-\ua8f7\ua8fb\ua8fd\ua8fe\ua90a-\ua925\ua930-\ua946\ua960-\ua97c\ua984-\ua9b2\ua9cf\ua9e0-\ua9e4\ua9e6-\ua9ef\ua9fa-\ua9fe\uaa00-\uaa28\uaa40-\uaa42\uaa44-\uaa4b\uaa60-\uaa76\uaa7a\uaa7e-\uaaaf\uaab1\uaab5\uaab6\uaab9-\uaabd\uaac0\uaac2\uaadb-\uaadd\uaae0-\uaaea\uaaf2-\uaaf4\uab01-\uab06\uab09-\uab0e\uab11-\uab16\uab20-\uab26\uab28-\uab2e\uab30-\uab5a\uab5c-\uab69\uab70-\uabe2\uac00-\ud7a3\ud7b0-\ud7c6\ud7cb-\ud7fb\uf900-\ufa6d\ufa70-\ufad9\ufb00-\ufb06\ufb13-\ufb17\ufb1d\ufb1f-\ufb28\ufb2a-\ufb36\ufb38-\ufb3c\ufb3e\ufb40\ufb41\ufb43\ufb44\ufb46-\ufbb1\ufbd3-\ufd3d\ufd50-\ufd8f\ufd92-\ufdc7\ufdf0-\ufdfb\ufe70-\ufe74\ufe76-\ufefc\uff21-\uff3a\uff41-\uff5a\uff66-\uffbe\uffc2-\uffc7\uffca-\uffcf\uffd2-\uffd7\uffda-\uffdc"; -let nonASCIIidentifierChars = "\u200c\u200d\xb7\u0300-\u036f\u0387\u0483-\u0487\u0591-\u05bd\u05bf\u05c1\u05c2\u05c4\u05c5\u05c7\u0610-\u061a\u064b-\u0669\u0670\u06d6-\u06dc\u06df-\u06e4\u06e7\u06e8\u06ea-\u06ed\u06f0-\u06f9\u0711\u0730-\u074a\u07a6-\u07b0\u07c0-\u07c9\u07eb-\u07f3\u07fd\u0816-\u0819\u081b-\u0823\u0825-\u0827\u0829-\u082d\u0859-\u085b\u0898-\u089f\u08ca-\u08e1\u08e3-\u0903\u093a-\u093c\u093e-\u094f\u0951-\u0957\u0962\u0963\u0966-\u096f\u0981-\u0983\u09bc\u09be-\u09c4\u09c7\u09c8\u09cb-\u09cd\u09d7\u09e2\u09e3\u09e6-\u09ef\u09fe\u0a01-\u0a03\u0a3c\u0a3e-\u0a42\u0a47\u0a48\u0a4b-\u0a4d\u0a51\u0a66-\u0a71\u0a75\u0a81-\u0a83\u0abc\u0abe-\u0ac5\u0ac7-\u0ac9\u0acb-\u0acd\u0ae2\u0ae3\u0ae6-\u0aef\u0afa-\u0aff\u0b01-\u0b03\u0b3c\u0b3e-\u0b44\u0b47\u0b48\u0b4b-\u0b4d\u0b55-\u0b57\u0b62\u0b63\u0b66-\u0b6f\u0b82\u0bbe-\u0bc2\u0bc6-\u0bc8\u0bca-\u0bcd\u0bd7\u0be6-\u0bef\u0c00-\u0c04\u0c3c\u0c3e-\u0c44\u0c46-\u0c48\u0c4a-\u0c4d\u0c55\u0c56\u0c62\u0c63\u0c66-\u0c6f\u0c81-\u0c83\u0cbc\u0cbe-\u0cc4\u0cc6-\u0cc8\u0cca-\u0ccd\u0cd5\u0cd6\u0ce2\u0ce3\u0ce6-\u0cef\u0cf3\u0d00-\u0d03\u0d3b\u0d3c\u0d3e-\u0d44\u0d46-\u0d48\u0d4a-\u0d4d\u0d57\u0d62\u0d63\u0d66-\u0d6f\u0d81-\u0d83\u0dca\u0dcf-\u0dd4\u0dd6\u0dd8-\u0ddf\u0de6-\u0def\u0df2\u0df3\u0e31\u0e34-\u0e3a\u0e47-\u0e4e\u0e50-\u0e59\u0eb1\u0eb4-\u0ebc\u0ec8-\u0ece\u0ed0-\u0ed9\u0f18\u0f19\u0f20-\u0f29\u0f35\u0f37\u0f39\u0f3e\u0f3f\u0f71-\u0f84\u0f86\u0f87\u0f8d-\u0f97\u0f99-\u0fbc\u0fc6\u102b-\u103e\u1040-\u1049\u1056-\u1059\u105e-\u1060\u1062-\u1064\u1067-\u106d\u1071-\u1074\u1082-\u108d\u108f-\u109d\u135d-\u135f\u1369-\u1371\u1712-\u1715\u1732-\u1734\u1752\u1753\u1772\u1773\u17b4-\u17d3\u17dd\u17e0-\u17e9\u180b-\u180d\u180f-\u1819\u18a9\u1920-\u192b\u1930-\u193b\u1946-\u194f\u19d0-\u19da\u1a17-\u1a1b\u1a55-\u1a5e\u1a60-\u1a7c\u1a7f-\u1a89\u1a90-\u1a99\u1ab0-\u1abd\u1abf-\u1ace\u1b00-\u1b04\u1b34-\u1b44\u1b50-\u1b59\u1b6b-\u1b73\u1b80-\u1b82\u1ba1-\u1bad\u1bb0-\u1bb9\u1be6-\u1bf3\u1c24-\u1c37\u1c40-\u1c49\u1c50-\u1c59\u1cd0-\u1cd2\u1cd4-\u1ce8\u1ced\u1cf4\u1cf7-\u1cf9\u1dc0-\u1dff\u200c\u200d\u203f\u2040\u2054\u20d0-\u20dc\u20e1\u20e5-\u20f0\u2cef-\u2cf1\u2d7f\u2de0-\u2dff\u302a-\u302f\u3099\u309a\u30fb\ua620-\ua629\ua66f\ua674-\ua67d\ua69e\ua69f\ua6f0\ua6f1\ua802\ua806\ua80b\ua823-\ua827\ua82c\ua880\ua881\ua8b4-\ua8c5\ua8d0-\ua8d9\ua8e0-\ua8f1\ua8ff-\ua909\ua926-\ua92d\ua947-\ua953\ua980-\ua983\ua9b3-\ua9c0\ua9d0-\ua9d9\ua9e5\ua9f0-\ua9f9\uaa29-\uaa36\uaa43\uaa4c\uaa4d\uaa50-\uaa59\uaa7b-\uaa7d\uaab0\uaab2-\uaab4\uaab7\uaab8\uaabe\uaabf\uaac1\uaaeb-\uaaef\uaaf5\uaaf6\uabe3-\uabea\uabec\uabed\uabf0-\uabf9\ufb1e\ufe00-\ufe0f\ufe20-\ufe2f\ufe33\ufe34\ufe4d-\ufe4f\uff10-\uff19\uff3f\uff65"; -const nonASCIIidentifierStart = new RegExp("[" + nonASCIIidentifierStartChars + "]"); -const nonASCIIidentifier = new RegExp("[" + nonASCIIidentifierStartChars + nonASCIIidentifierChars + "]"); -nonASCIIidentifierStartChars = nonASCIIidentifierChars = null; -const astralIdentifierStartCodes = [0, 11, 2, 25, 2, 18, 2, 1, 2, 14, 3, 13, 35, 122, 70, 52, 268, 28, 4, 48, 48, 31, 14, 29, 6, 37, 11, 29, 3, 35, 5, 7, 2, 4, 43, 157, 19, 35, 5, 35, 5, 39, 9, 51, 13, 10, 2, 14, 2, 6, 2, 1, 2, 10, 2, 14, 2, 6, 2, 1, 68, 310, 10, 21, 11, 7, 25, 5, 2, 41, 2, 8, 70, 5, 3, 0, 2, 43, 2, 1, 4, 0, 3, 22, 11, 22, 10, 30, 66, 18, 2, 1, 11, 21, 11, 25, 71, 55, 7, 1, 65, 0, 16, 3, 2, 2, 2, 28, 43, 28, 4, 28, 36, 7, 2, 27, 28, 53, 11, 21, 11, 18, 14, 17, 111, 72, 56, 50, 14, 50, 14, 35, 349, 41, 7, 1, 79, 28, 11, 0, 9, 21, 43, 17, 47, 20, 28, 22, 13, 52, 58, 1, 3, 0, 14, 44, 33, 24, 27, 35, 30, 0, 3, 0, 9, 34, 4, 0, 13, 47, 15, 3, 22, 0, 2, 0, 36, 17, 2, 24, 20, 1, 64, 6, 2, 0, 2, 3, 2, 14, 2, 9, 8, 46, 39, 7, 3, 1, 3, 21, 2, 6, 2, 1, 2, 4, 4, 0, 19, 0, 13, 4, 159, 52, 19, 3, 21, 2, 31, 47, 21, 1, 2, 0, 185, 46, 42, 3, 37, 47, 21, 0, 60, 42, 14, 0, 72, 26, 38, 6, 186, 43, 117, 63, 32, 7, 3, 0, 3, 7, 2, 1, 2, 23, 16, 0, 2, 0, 95, 7, 3, 38, 17, 0, 2, 0, 29, 0, 11, 39, 8, 0, 22, 0, 12, 45, 20, 0, 19, 72, 264, 8, 2, 36, 18, 0, 50, 29, 113, 6, 2, 1, 2, 37, 22, 0, 26, 5, 2, 1, 2, 31, 15, 0, 328, 18, 16, 0, 2, 12, 2, 33, 125, 0, 80, 921, 103, 110, 18, 195, 2637, 96, 16, 1071, 18, 5, 4026, 582, 8634, 568, 8, 30, 18, 78, 18, 29, 19, 47, 17, 3, 32, 20, 6, 18, 689, 63, 129, 74, 6, 0, 67, 12, 65, 1, 2, 0, 29, 6135, 9, 1237, 43, 8, 8936, 3, 2, 6, 2, 1, 2, 290, 16, 0, 30, 2, 3, 0, 15, 3, 9, 395, 2309, 106, 6, 12, 4, 8, 8, 9, 5991, 84, 2, 70, 2, 1, 3, 0, 3, 1, 3, 3, 2, 11, 2, 0, 2, 6, 2, 64, 2, 3, 3, 7, 2, 6, 2, 27, 2, 3, 2, 4, 2, 0, 4, 6, 2, 339, 3, 24, 2, 24, 2, 30, 2, 24, 2, 30, 2, 24, 2, 30, 2, 24, 2, 30, 2, 24, 2, 7, 1845, 30, 7, 5, 262, 61, 147, 44, 11, 6, 17, 0, 322, 29, 19, 43, 485, 27, 757, 6, 2, 3, 2, 1, 2, 14, 2, 196, 60, 67, 8, 0, 1205, 3, 2, 26, 2, 1, 2, 0, 3, 0, 2, 9, 2, 3, 2, 0, 2, 0, 7, 0, 5, 0, 2, 0, 2, 0, 2, 2, 2, 1, 2, 0, 3, 0, 2, 0, 2, 0, 2, 0, 2, 0, 2, 1, 2, 0, 3, 3, 2, 6, 2, 3, 2, 3, 2, 0, 2, 9, 2, 16, 6, 2, 2, 4, 2, 16, 4421, 42719, 33, 4153, 7, 221, 3, 5761, 15, 7472, 16, 621, 2467, 541, 1507, 4938, 6, 4191]; -const astralIdentifierCodes = [509, 0, 227, 0, 150, 4, 294, 9, 1368, 2, 2, 1, 6, 3, 41, 2, 5, 0, 166, 1, 574, 3, 9, 9, 370, 1, 81, 2, 71, 10, 50, 3, 123, 2, 54, 14, 32, 10, 3, 1, 11, 3, 46, 10, 8, 0, 46, 9, 7, 2, 37, 13, 2, 9, 6, 1, 45, 0, 13, 2, 49, 13, 9, 3, 2, 11, 83, 11, 7, 0, 3, 0, 158, 11, 6, 9, 7, 3, 56, 1, 2, 6, 3, 1, 3, 2, 10, 0, 11, 1, 3, 6, 4, 4, 193, 17, 10, 9, 5, 0, 82, 19, 13, 9, 214, 6, 3, 8, 28, 1, 83, 16, 16, 9, 82, 12, 9, 9, 84, 14, 5, 9, 243, 14, 166, 9, 71, 5, 2, 1, 3, 3, 2, 0, 2, 1, 13, 9, 120, 6, 3, 6, 4, 0, 29, 9, 41, 6, 2, 3, 9, 0, 10, 10, 47, 15, 406, 7, 2, 7, 17, 9, 57, 21, 2, 13, 123, 5, 4, 0, 2, 1, 2, 6, 2, 0, 9, 9, 49, 4, 2, 1, 2, 4, 9, 9, 330, 3, 10, 1, 2, 0, 49, 6, 4, 4, 14, 9, 5351, 0, 7, 14, 13835, 9, 87, 9, 39, 4, 60, 6, 26, 9, 1014, 0, 2, 54, 8, 3, 82, 0, 12, 1, 19628, 1, 4706, 45, 3, 22, 543, 4, 4, 5, 9, 7, 3, 6, 31, 3, 149, 2, 1418, 49, 513, 54, 5, 49, 9, 0, 15, 0, 23, 4, 2, 14, 1361, 6, 2, 16, 3, 6, 2, 1, 2, 4, 101, 0, 161, 6, 10, 9, 357, 0, 62, 13, 499, 13, 983, 6, 110, 6, 6, 9, 4759, 9, 787719, 239]; -function isInAstralSet(code, set) { - let pos = 0x10000; - for (let i = 0, length = set.length; i < length; i += 2) { - pos += set[i]; - if (pos > code) return false; - pos += set[i + 1]; - if (pos >= code) return true; - } - return false; -} -function isIdentifierStart(code) { - if (code < 65) return code === 36; - if (code <= 90) return true; - if (code < 97) return code === 95; - if (code <= 122) return true; - if (code <= 0xffff) { - return code >= 0xaa && nonASCIIidentifierStart.test(String.fromCharCode(code)); - } - return isInAstralSet(code, astralIdentifierStartCodes); -} -function isIdentifierChar(code) { - if (code < 48) return code === 36; - if (code < 58) return true; - if (code < 65) return false; - if (code <= 90) return true; - if (code < 97) return code === 95; - if (code <= 122) return true; - if (code <= 0xffff) { - return code >= 0xaa && nonASCIIidentifier.test(String.fromCharCode(code)); - } - return isInAstralSet(code, astralIdentifierStartCodes) || isInAstralSet(code, astralIdentifierCodes); -} -function isIdentifierName(name) { - let isFirst = true; - for (let i = 0; i < name.length; i++) { - let cp = name.charCodeAt(i); - if ((cp & 0xfc00) === 0xd800 && i + 1 < name.length) { - const trail = name.charCodeAt(++i); - if ((trail & 0xfc00) === 0xdc00) { - cp = 0x10000 + ((cp & 0x3ff) << 10) + (trail & 0x3ff); - } - } - if (isFirst) { - isFirst = false; - if (!isIdentifierStart(cp)) { - return false; - } - } else if (!isIdentifierChar(cp)) { - return false; - } - } - return !isFirst; -} - -//# sourceMappingURL=identifier.js.map diff --git a/tools/eslint/node_modules/@babel/helper-validator-identifier/lib/index.js b/tools/eslint/node_modules/@babel/helper-validator-identifier/lib/index.js deleted file mode 100644 index 76b22822cc4de3..00000000000000 --- a/tools/eslint/node_modules/@babel/helper-validator-identifier/lib/index.js +++ /dev/null @@ -1,57 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -Object.defineProperty(exports, "isIdentifierChar", { - enumerable: true, - get: function () { - return _identifier.isIdentifierChar; - } -}); -Object.defineProperty(exports, "isIdentifierName", { - enumerable: true, - get: function () { - return _identifier.isIdentifierName; - } -}); -Object.defineProperty(exports, "isIdentifierStart", { - enumerable: true, - get: function () { - return _identifier.isIdentifierStart; - } -}); -Object.defineProperty(exports, "isKeyword", { - enumerable: true, - get: function () { - return _keyword.isKeyword; - } -}); -Object.defineProperty(exports, "isReservedWord", { - enumerable: true, - get: function () { - return _keyword.isReservedWord; - } -}); -Object.defineProperty(exports, "isStrictBindOnlyReservedWord", { - enumerable: true, - get: function () { - return _keyword.isStrictBindOnlyReservedWord; - } -}); -Object.defineProperty(exports, "isStrictBindReservedWord", { - enumerable: true, - get: function () { - return _keyword.isStrictBindReservedWord; - } -}); -Object.defineProperty(exports, "isStrictReservedWord", { - enumerable: true, - get: function () { - return _keyword.isStrictReservedWord; - } -}); -var _identifier = require("./identifier.js"); -var _keyword = require("./keyword.js"); - -//# sourceMappingURL=index.js.map diff --git a/tools/eslint/node_modules/@babel/helper-validator-identifier/lib/keyword.js b/tools/eslint/node_modules/@babel/helper-validator-identifier/lib/keyword.js deleted file mode 100644 index 054cf847426e8a..00000000000000 --- a/tools/eslint/node_modules/@babel/helper-validator-identifier/lib/keyword.js +++ /dev/null @@ -1,35 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.isKeyword = isKeyword; -exports.isReservedWord = isReservedWord; -exports.isStrictBindOnlyReservedWord = isStrictBindOnlyReservedWord; -exports.isStrictBindReservedWord = isStrictBindReservedWord; -exports.isStrictReservedWord = isStrictReservedWord; -const reservedWords = { - keyword: ["break", "case", "catch", "continue", "debugger", "default", "do", "else", "finally", "for", "function", "if", "return", "switch", "throw", "try", "var", "const", "while", "with", "new", "this", "super", "class", "extends", "export", "import", "null", "true", "false", "in", "instanceof", "typeof", "void", "delete"], - strict: ["implements", "interface", "let", "package", "private", "protected", "public", "static", "yield"], - strictBind: ["eval", "arguments"] -}; -const keywords = new Set(reservedWords.keyword); -const reservedWordsStrictSet = new Set(reservedWords.strict); -const reservedWordsStrictBindSet = new Set(reservedWords.strictBind); -function isReservedWord(word, inModule) { - return inModule && word === "await" || word === "enum"; -} -function isStrictReservedWord(word, inModule) { - return isReservedWord(word, inModule) || reservedWordsStrictSet.has(word); -} -function isStrictBindOnlyReservedWord(word) { - return reservedWordsStrictBindSet.has(word); -} -function isStrictBindReservedWord(word, inModule) { - return isStrictReservedWord(word, inModule) || isStrictBindOnlyReservedWord(word); -} -function isKeyword(word) { - return keywords.has(word); -} - -//# sourceMappingURL=keyword.js.map diff --git a/tools/eslint/node_modules/@babel/helper-validator-identifier/package.json b/tools/eslint/node_modules/@babel/helper-validator-identifier/package.json deleted file mode 100644 index 0e2e01b1b13344..00000000000000 --- a/tools/eslint/node_modules/@babel/helper-validator-identifier/package.json +++ /dev/null @@ -1,31 +0,0 @@ -{ - "name": "@babel/helper-validator-identifier", - "version": "7.24.7", - "description": "Validate identifier/keywords name", - "repository": { - "type": "git", - "url": "https://github.com/babel/babel.git", - "directory": "packages/babel-helper-validator-identifier" - }, - "license": "MIT", - "publishConfig": { - "access": "public" - }, - "main": "./lib/index.js", - "exports": { - ".": { - "types": "./lib/index.d.ts", - "default": "./lib/index.js" - }, - "./package.json": "./package.json" - }, - "devDependencies": { - "@unicode/unicode-15.1.0": "^1.5.2", - "charcodes": "^0.2.0" - }, - "engines": { - "node": ">=6.9.0" - }, - "author": "The Babel Team (https://babel.dev/team)", - "type": "commonjs" -} \ No newline at end of file diff --git a/tools/eslint/node_modules/@babel/helper-validator-identifier/scripts/generate-identifier-regex.js b/tools/eslint/node_modules/@babel/helper-validator-identifier/scripts/generate-identifier-regex.js deleted file mode 100644 index f3fd9e9adab85f..00000000000000 --- a/tools/eslint/node_modules/@babel/helper-validator-identifier/scripts/generate-identifier-regex.js +++ /dev/null @@ -1,73 +0,0 @@ -"use strict"; - -// Always use the latest available version of Unicode! -// https://tc39.github.io/ecma262/#sec-conformance -const version = "15.1.0"; - -const start = require( - "@unicode/unicode-" + version + "/Binary_Property/ID_Start/code-points.js" -).filter(function (ch) { - return ch > 0x7f; -}); -let last = -1; -const cont = require( - "@unicode/unicode-" + version + "/Binary_Property/ID_Continue/code-points.js" -).filter(function (ch) { - return ch > 0x7f && search(start, ch, last + 1) === -1; -}); - -function search(arr, ch, starting) { - for (let i = starting; arr[i] <= ch && i < arr.length; last = i++) { - if (arr[i] === ch) return i; - } - return -1; -} - -function pad(str, width) { - while (str.length < width) str = "0" + str; - return str; -} - -function esc(code) { - const hex = code.toString(16); - if (hex.length <= 2) return "\\x" + pad(hex, 2); - else return "\\u" + pad(hex, 4); -} - -function generate(chars) { - const astral = []; - let re = ""; - for (let i = 0, at = 0x10000; i < chars.length; i++) { - const from = chars[i]; - let to = from; - while (i < chars.length - 1 && chars[i + 1] === to + 1) { - i++; - to++; - } - if (to <= 0xffff) { - if (from === to) re += esc(from); - else if (from + 1 === to) re += esc(from) + esc(to); - else re += esc(from) + "-" + esc(to); - } else { - astral.push(from - at, to - from); - at = to; - } - } - return { nonASCII: re, astral: astral }; -} - -const startData = generate(start); -const contData = generate(cont); - -console.log("/* prettier-ignore */"); -console.log('let nonASCIIidentifierStartChars = "' + startData.nonASCII + '";'); -console.log("/* prettier-ignore */"); -console.log('let nonASCIIidentifierChars = "' + contData.nonASCII + '";'); -console.log("/* prettier-ignore */"); -console.log( - "const astralIdentifierStartCodes = " + JSON.stringify(startData.astral) + ";" -); -console.log("/* prettier-ignore */"); -console.log( - "const astralIdentifierCodes = " + JSON.stringify(contData.astral) + ";" -); diff --git a/tools/eslint/node_modules/@babel/helper-validator-option/LICENSE b/tools/eslint/node_modules/@babel/helper-validator-option/LICENSE deleted file mode 100644 index f31575ec773bb1..00000000000000 --- a/tools/eslint/node_modules/@babel/helper-validator-option/LICENSE +++ /dev/null @@ -1,22 +0,0 @@ -MIT License - -Copyright (c) 2014-present Sebastian McKenzie and other contributors - -Permission is hereby granted, free of charge, to any person obtaining -a copy of this software and associated documentation files (the -"Software"), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sublicense, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/tools/eslint/node_modules/@babel/helper-validator-option/lib/find-suggestion.js b/tools/eslint/node_modules/@babel/helper-validator-option/lib/find-suggestion.js deleted file mode 100644 index beada9a7fadc35..00000000000000 --- a/tools/eslint/node_modules/@babel/helper-validator-option/lib/find-suggestion.js +++ /dev/null @@ -1,39 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.findSuggestion = findSuggestion; -const { - min -} = Math; -function levenshtein(a, b) { - let t = [], - u = [], - i, - j; - const m = a.length, - n = b.length; - if (!m) { - return n; - } - if (!n) { - return m; - } - for (j = 0; j <= n; j++) { - t[j] = j; - } - for (i = 1; i <= m; i++) { - for (u = [i], j = 1; j <= n; j++) { - u[j] = a[i - 1] === b[j - 1] ? t[j - 1] : min(t[j - 1], t[j], u[j - 1]) + 1; - } - t = u; - } - return u[n]; -} -function findSuggestion(str, arr) { - const distances = arr.map(el => levenshtein(el, str)); - return arr[distances.indexOf(min(...distances))]; -} - -//# sourceMappingURL=find-suggestion.js.map diff --git a/tools/eslint/node_modules/@babel/helper-validator-option/lib/index.js b/tools/eslint/node_modules/@babel/helper-validator-option/lib/index.js deleted file mode 100644 index 533eb4547339db..00000000000000 --- a/tools/eslint/node_modules/@babel/helper-validator-option/lib/index.js +++ /dev/null @@ -1,21 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -Object.defineProperty(exports, "OptionValidator", { - enumerable: true, - get: function () { - return _validator.OptionValidator; - } -}); -Object.defineProperty(exports, "findSuggestion", { - enumerable: true, - get: function () { - return _findSuggestion.findSuggestion; - } -}); -var _validator = require("./validator.js"); -var _findSuggestion = require("./find-suggestion.js"); - -//# sourceMappingURL=index.js.map diff --git a/tools/eslint/node_modules/@babel/helper-validator-option/lib/validator.js b/tools/eslint/node_modules/@babel/helper-validator-option/lib/validator.js deleted file mode 100644 index 5c9312e290bd26..00000000000000 --- a/tools/eslint/node_modules/@babel/helper-validator-option/lib/validator.js +++ /dev/null @@ -1,48 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.OptionValidator = void 0; -var _findSuggestion = require("./find-suggestion.js"); -class OptionValidator { - constructor(descriptor) { - this.descriptor = descriptor; - } - validateTopLevelOptions(options, TopLevelOptionShape) { - const validOptionNames = Object.keys(TopLevelOptionShape); - for (const option of Object.keys(options)) { - if (!validOptionNames.includes(option)) { - throw new Error(this.formatMessage(`'${option}' is not a valid top-level option. -- Did you mean '${(0, _findSuggestion.findSuggestion)(option, validOptionNames)}'?`)); - } - } - } - validateBooleanOption(name, value, defaultValue) { - if (value === undefined) { - return defaultValue; - } else { - this.invariant(typeof value === "boolean", `'${name}' option must be a boolean.`); - } - return value; - } - validateStringOption(name, value, defaultValue) { - if (value === undefined) { - return defaultValue; - } else { - this.invariant(typeof value === "string", `'${name}' option must be a string.`); - } - return value; - } - invariant(condition, message) { - if (!condition) { - throw new Error(this.formatMessage(message)); - } - } - formatMessage(message) { - return `${this.descriptor}: ${message}`; - } -} -exports.OptionValidator = OptionValidator; - -//# sourceMappingURL=validator.js.map diff --git a/tools/eslint/node_modules/@babel/helper-validator-option/package.json b/tools/eslint/node_modules/@babel/helper-validator-option/package.json deleted file mode 100644 index 667a00718cff7c..00000000000000 --- a/tools/eslint/node_modules/@babel/helper-validator-option/package.json +++ /dev/null @@ -1,27 +0,0 @@ -{ - "name": "@babel/helper-validator-option", - "version": "7.24.8", - "description": "Validate plugin/preset options", - "repository": { - "type": "git", - "url": "https://github.com/babel/babel.git", - "directory": "packages/babel-helper-validator-option" - }, - "license": "MIT", - "publishConfig": { - "access": "public" - }, - "main": "./lib/index.js", - "exports": { - ".": { - "types": "./lib/index.d.ts", - "default": "./lib/index.js" - }, - "./package.json": "./package.json" - }, - "engines": { - "node": ">=6.9.0" - }, - "author": "The Babel Team (https://babel.dev/team)", - "type": "commonjs" -} \ No newline at end of file diff --git a/tools/eslint/node_modules/@babel/helpers/LICENSE b/tools/eslint/node_modules/@babel/helpers/LICENSE deleted file mode 100644 index f31575ec773bb1..00000000000000 --- a/tools/eslint/node_modules/@babel/helpers/LICENSE +++ /dev/null @@ -1,22 +0,0 @@ -MIT License - -Copyright (c) 2014-present Sebastian McKenzie and other contributors - -Permission is hereby granted, free of charge, to any person obtaining -a copy of this software and associated documentation files (the -"Software"), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sublicense, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/tools/eslint/node_modules/@babel/helpers/lib/helpers-generated.js b/tools/eslint/node_modules/@babel/helpers/lib/helpers-generated.js deleted file mode 100644 index 0c8c4a90ce13a1..00000000000000 --- a/tools/eslint/node_modules/@babel/helpers/lib/helpers-generated.js +++ /dev/null @@ -1,1207 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.default = void 0; -var _template = require("@babel/template"); -function helper(minVersion, source, metadata) { - return Object.freeze({ - minVersion, - ast: () => _template.default.program.ast(source, { - preserveComments: true - }), - metadata - }); -} -const helpers = exports.default = { - __proto__: null, - OverloadYield: helper("7.18.14", "function _OverloadYield(e,d){this.v=e,this.k=d}", { - globals: [], - locals: { - _OverloadYield: ["body.0.id"] - }, - exportBindingAssignments: [], - exportName: "_OverloadYield", - dependencies: {} - }), - applyDecoratedDescriptor: helper("7.0.0-beta.0", 'function _applyDecoratedDescriptor(i,e,r,n,l){var a={};return Object.keys(n).forEach((function(i){a[i]=n[i]})),a.enumerable=!!a.enumerable,a.configurable=!!a.configurable,("value"in a||a.initializer)&&(a.writable=!0),a=r.slice().reverse().reduce((function(r,n){return n(i,e,r)||r}),a),l&&void 0!==a.initializer&&(a.value=a.initializer?a.initializer.call(l):void 0,a.initializer=void 0),void 0===a.initializer?(Object.defineProperty(i,e,a),null):a}', { - globals: ["Object"], - locals: { - _applyDecoratedDescriptor: ["body.0.id"] - }, - exportBindingAssignments: [], - exportName: "_applyDecoratedDescriptor", - dependencies: {} - }), - applyDecs2311: helper("7.24.0", 'function applyDecs2311(e,t,n,r,o,i){var a,c,u,s,f,l,p,d=Symbol.metadata||Symbol.for("Symbol.metadata"),m=Object.defineProperty,h=Object.create,y=[h(null),h(null)],v=t.length;function g(t,n,r){return function(o,i){n&&(i=o,o=e);for(var a=0;a=0;O-=n?2:1){var T=b(h[O],"A decorator","be",!0),z=n?h[O-1]:void 0,A={},H={kind:["field","accessor","method","getter","setter","class"][o],name:r,metadata:a,addInitializer:function(e,t){if(e.v)throw new TypeError("attempted to call addInitializer after decoration was finished");b(t,"An initializer","be",!0),i.push(t)}.bind(null,A)};if(w)c=T.call(z,N,H),A.v=1,b(c,"class decorators","return")&&(N=c);else if(H.static=s,H.private=f,c=H.access={has:f?p.bind():function(e){return r in e}},j||(c.get=f?E?function(e){return d(e),P.value}:I("get",0,d):function(e){return e[r]}),E||S||(c.set=f?I("set",0,d):function(e,t){e[r]=t}),N=T.call(z,D?{get:P.get,set:P.set}:P[F],H),A.v=1,D){if("object"==typeof N&&N)(c=b(N.get,"accessor.get"))&&(P.get=c),(c=b(N.set,"accessor.set"))&&(P.set=c),(c=b(N.init,"accessor.init"))&&k.unshift(c);else if(void 0!==N)throw new TypeError("accessor decorators must return an object with get, set, or init properties or undefined")}else b(N,(l?"field":"method")+" decorators","return")&&(l?k.unshift(N):P[F]=N)}return o<2&&u.push(g(k,s,1),g(i,s,0)),l||w||(f?D?u.splice(-1,0,I("get",s),I("set",s)):u.push(E?P[F]:b.call.bind(P[F])):m(e,r,P)),N}function w(e){return m(e,d,{configurable:!0,enumerable:!0,value:a})}return void 0!==i&&(a=i[d]),a=h(null==a?null:a),f=[],l=function(e){e&&f.push(g(e))},p=function(t,r){for(var i=0;ir.length)&&(a=r.length);for(var e=0,n=Array(a);e=r.length?{done:!0}:{done:!1,value:r[n++]}},e:function(r){throw r},f:F}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,a=!0,u=!1;return{s:function(){t=t.call(r)},n:function(){var r=t.next();return a=r.done,r},e:function(r){u=!0,o=r},f:function(){try{a||null==t.return||t.return()}finally{if(u)throw o}}}}', { - globals: ["Symbol", "Array", "TypeError"], - locals: { - _createForOfIteratorHelper: ["body.0.id"] - }, - exportBindingAssignments: [], - exportName: "_createForOfIteratorHelper", - dependencies: { - unsupportedIterableToArray: ["body.0.body.body.1.consequent.body.0.test.left.right.right.callee"] - } - }), - createForOfIteratorHelperLoose: helper("7.9.0", 'function _createForOfIteratorHelperLoose(r,e){var t="undefined"!=typeof Symbol&&r[Symbol.iterator]||r["@@iterator"];if(t)return(t=t.call(r)).next.bind(t);if(Array.isArray(r)||(t=unsupportedIterableToArray(r))||e&&r&&"number"==typeof r.length){t&&(r=t);var o=0;return function(){return o>=r.length?{done:!0}:{done:!1,value:r[o++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}', { - globals: ["Symbol", "Array", "TypeError"], - locals: { - _createForOfIteratorHelperLoose: ["body.0.id"] - }, - exportBindingAssignments: [], - exportName: "_createForOfIteratorHelperLoose", - dependencies: { - unsupportedIterableToArray: ["body.0.body.body.2.test.left.right.right.callee"] - } - }), - createSuper: helper("7.9.0", "function _createSuper(t){var r=isNativeReflectConstruct();return function(){var e,o=getPrototypeOf(t);if(r){var s=getPrototypeOf(this).constructor;e=Reflect.construct(o,arguments,s)}else e=o.apply(this,arguments);return possibleConstructorReturn(this,e)}}", { - globals: ["Reflect"], - locals: { - _createSuper: ["body.0.id"] - }, - exportBindingAssignments: [], - exportName: "_createSuper", - dependencies: { - getPrototypeOf: ["body.0.body.body.1.argument.body.body.0.declarations.1.init.callee", "body.0.body.body.1.argument.body.body.1.consequent.body.0.declarations.0.init.object.callee"], - isNativeReflectConstruct: ["body.0.body.body.0.declarations.0.init.callee"], - possibleConstructorReturn: ["body.0.body.body.1.argument.body.body.2.argument.callee"] - } - }), - decorate: helper("7.1.5", 'function _decorate(e,r,t,i){var o=_getDecoratorsApi();if(i)for(var n=0;n=0;n--){var s=r[e.placement];s.splice(s.indexOf(e.key),1);var a=this.fromElementDescriptor(e),l=this.toElementFinisherExtras((0,o[n])(a)||a);e=l.element,this.addElementPlacement(e,r),l.finisher&&i.push(l.finisher);var c=l.extras;if(c){for(var p=0;p=0;i--){var o=this.fromClassDescriptor(e),n=this.toClassDescriptor((0,r[i])(o)||o);if(void 0!==n.finisher&&t.push(n.finisher),void 0!==n.elements){e=n.elements;for(var s=0;s1){for(var t=Array(n),f=0;f=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return handle("end");if(i.tryLoc<=this.prev){var c=n.call(i,"catchLoc"),u=n.call(i,"finallyLoc");if(c&&u){if(this.prev=0;--r){var o=this.tryEntries[r];if(o.tryLoc<=this.prev&&n.call(o,"finallyLoc")&&this.prev=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),resetTryEntry(r),y}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;resetTryEntry(r)}return o}}throw Error("illegal catch attempt")},delegateYield:function(e,r,n){return this.delegate={iterator:values(e),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=t),y}},e}', { - globals: ["Object", "Symbol", "Error", "TypeError", "isNaN", "Promise"], - locals: { - _regeneratorRuntime: ["body.0.id", "body.0.body.body.0.expression.left"] - }, - exportBindingAssignments: ["body.0.body.body.0.expression"], - exportName: "_regeneratorRuntime", - dependencies: {} - }), - set: helper("7.0.0-beta.0", 'function set(e,r,t,o){return set="undefined"!=typeof Reflect&&Reflect.set?Reflect.set:function(e,r,t,o){var f,i=superPropBase(e,r);if(i){if((f=Object.getOwnPropertyDescriptor(i,r)).set)return f.set.call(o,t),!0;if(!f.writable)return!1}if(f=Object.getOwnPropertyDescriptor(o,r)){if(!f.writable)return!1;f.value=t,Object.defineProperty(o,r,f)}else defineProperty(o,r,t);return!0},set(e,r,t,o)}function _set(e,r,t,o,f){if(!set(e,r,t,o||e)&&f)throw new TypeError("failed to set property");return t}', { - globals: ["Reflect", "Object", "TypeError"], - locals: { - set: ["body.0.id", "body.0.body.body.0.argument.expressions.1.callee", "body.1.body.body.0.test.left.argument.callee", "body.0.body.body.0.argument.expressions.0.left"], - _set: ["body.1.id"] - }, - exportBindingAssignments: [], - exportName: "_set", - dependencies: { - superPropBase: ["body.0.body.body.0.argument.expressions.0.right.alternate.body.body.0.declarations.1.init.callee"], - defineProperty: ["body.0.body.body.0.argument.expressions.0.right.alternate.body.body.2.alternate.expression.callee"] - } - }), - setFunctionName: helper("7.23.6", 'function setFunctionName(e,t,n){"symbol"==typeof t&&(t=(t=t.description)?"["+t+"]":"");try{Object.defineProperty(e,"name",{configurable:!0,value:n?n+" "+t:t})}catch(e){}return e}', { - globals: ["Object"], - locals: { - setFunctionName: ["body.0.id"] - }, - exportBindingAssignments: [], - exportName: "setFunctionName", - dependencies: {} - }), - setPrototypeOf: helper("7.0.0-beta.0", "function _setPrototypeOf(t,e){return _setPrototypeOf=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},_setPrototypeOf(t,e)}", { - globals: ["Object"], - locals: { - _setPrototypeOf: ["body.0.id", "body.0.body.body.0.argument.expressions.1.callee", "body.0.body.body.0.argument.expressions.0.left"] - }, - exportBindingAssignments: ["body.0.body.body.0.argument.expressions.0"], - exportName: "_setPrototypeOf", - dependencies: {} - }), - skipFirstGeneratorNext: helper("7.0.0-beta.0", "function _skipFirstGeneratorNext(t){return function(){var r=t.apply(this,arguments);return r.next(),r}}", { - globals: [], - locals: { - _skipFirstGeneratorNext: ["body.0.id"] - }, - exportBindingAssignments: [], - exportName: "_skipFirstGeneratorNext", - dependencies: {} - }), - slicedToArray: helper("7.0.0-beta.0", "function _slicedToArray(r,e){return arrayWithHoles(r)||iterableToArrayLimit(r,e)||unsupportedIterableToArray(r,e)||nonIterableRest()}", { - globals: [], - locals: { - _slicedToArray: ["body.0.id"] - }, - exportBindingAssignments: [], - exportName: "_slicedToArray", - dependencies: { - arrayWithHoles: ["body.0.body.body.0.argument.left.left.left.callee"], - iterableToArrayLimit: ["body.0.body.body.0.argument.left.left.right.callee"], - unsupportedIterableToArray: ["body.0.body.body.0.argument.left.right.callee"], - nonIterableRest: ["body.0.body.body.0.argument.right.callee"] - } - }), - superPropBase: helper("7.0.0-beta.0", "function _superPropBase(t,o){for(;!{}.hasOwnProperty.call(t,o)&&null!==(t=getPrototypeOf(t)););return t}", { - globals: [], - locals: { - _superPropBase: ["body.0.id"] - }, - exportBindingAssignments: [], - exportName: "_superPropBase", - dependencies: { - getPrototypeOf: ["body.0.body.body.0.test.right.right.right.callee"] - } - }), - taggedTemplateLiteral: helper("7.0.0-beta.0", "function _taggedTemplateLiteral(e,t){return t||(t=e.slice(0)),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(t)}}))}", { - globals: ["Object"], - locals: { - _taggedTemplateLiteral: ["body.0.id"] - }, - exportBindingAssignments: [], - exportName: "_taggedTemplateLiteral", - dependencies: {} - }), - taggedTemplateLiteralLoose: helper("7.0.0-beta.0", "function _taggedTemplateLiteralLoose(e,t){return t||(t=e.slice(0)),e.raw=t,e}", { - globals: [], - locals: { - _taggedTemplateLiteralLoose: ["body.0.id"] - }, - exportBindingAssignments: [], - exportName: "_taggedTemplateLiteralLoose", - dependencies: {} - }), - tdz: helper("7.5.5", 'function _tdzError(e){throw new ReferenceError(e+" is not defined - temporal dead zone")}', { - globals: ["ReferenceError"], - locals: { - _tdzError: ["body.0.id"] - }, - exportBindingAssignments: [], - exportName: "_tdzError", - dependencies: {} - }), - temporalRef: helper("7.0.0-beta.0", "function _temporalRef(r,e){return r===undef?err(e):r}", { - globals: [], - locals: { - _temporalRef: ["body.0.id"] - }, - exportBindingAssignments: [], - exportName: "_temporalRef", - dependencies: { - temporalUndefined: ["body.0.body.body.0.argument.test.right"], - tdz: ["body.0.body.body.0.argument.consequent.callee"] - } - }), - temporalUndefined: helper("7.0.0-beta.0", "function _temporalUndefined(){}", { - globals: [], - locals: { - _temporalUndefined: ["body.0.id"] - }, - exportBindingAssignments: [], - exportName: "_temporalUndefined", - dependencies: {} - }), - toArray: helper("7.0.0-beta.0", "function _toArray(r){return arrayWithHoles(r)||iterableToArray(r)||unsupportedIterableToArray(r)||nonIterableRest()}", { - globals: [], - locals: { - _toArray: ["body.0.id"] - }, - exportBindingAssignments: [], - exportName: "_toArray", - dependencies: { - arrayWithHoles: ["body.0.body.body.0.argument.left.left.left.callee"], - iterableToArray: ["body.0.body.body.0.argument.left.left.right.callee"], - unsupportedIterableToArray: ["body.0.body.body.0.argument.left.right.callee"], - nonIterableRest: ["body.0.body.body.0.argument.right.callee"] - } - }), - toConsumableArray: helper("7.0.0-beta.0", "function _toConsumableArray(r){return arrayWithoutHoles(r)||iterableToArray(r)||unsupportedIterableToArray(r)||nonIterableSpread()}", { - globals: [], - locals: { - _toConsumableArray: ["body.0.id"] - }, - exportBindingAssignments: [], - exportName: "_toConsumableArray", - dependencies: { - arrayWithoutHoles: ["body.0.body.body.0.argument.left.left.left.callee"], - iterableToArray: ["body.0.body.body.0.argument.left.left.right.callee"], - unsupportedIterableToArray: ["body.0.body.body.0.argument.left.right.callee"], - nonIterableSpread: ["body.0.body.body.0.argument.right.callee"] - } - }), - toPrimitive: helper("7.1.5", 'function toPrimitive(t,r){if("object"!=typeof t||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var i=e.call(t,r||"default");if("object"!=typeof i)return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===r?String:Number)(t)}', { - globals: ["Symbol", "TypeError", "String", "Number"], - locals: { - toPrimitive: ["body.0.id"] - }, - exportBindingAssignments: [], - exportName: "toPrimitive", - dependencies: {} - }), - toPropertyKey: helper("7.1.5", 'function toPropertyKey(t){var i=toPrimitive(t,"string");return"symbol"==typeof i?i:i+""}', { - globals: [], - locals: { - toPropertyKey: ["body.0.id"] - }, - exportBindingAssignments: [], - exportName: "toPropertyKey", - dependencies: { - toPrimitive: ["body.0.body.body.0.declarations.0.init.callee"] - } - }), - toSetter: helper("7.24.0", 'function _toSetter(t,e,n){e||(e=[]);var r=e.length++;return Object.defineProperty({},"_",{set:function(o){e[r]=o,t.apply(n,e)}})}', { - globals: ["Object"], - locals: { - _toSetter: ["body.0.id"] - }, - exportBindingAssignments: [], - exportName: "_toSetter", - dependencies: {} - }), - typeof: helper("7.0.0-beta.0", 'function _typeof(o){"@babel/helpers - typeof";return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(o){return typeof o}:function(o){return o&&"function"==typeof Symbol&&o.constructor===Symbol&&o!==Symbol.prototype?"symbol":typeof o},_typeof(o)}', { - globals: ["Symbol"], - locals: { - _typeof: ["body.0.id", "body.0.body.body.0.argument.expressions.1.callee", "body.0.body.body.0.argument.expressions.0.left"] - }, - exportBindingAssignments: ["body.0.body.body.0.argument.expressions.0"], - exportName: "_typeof", - dependencies: {} - }), - unsupportedIterableToArray: helper("7.9.0", 'function _unsupportedIterableToArray(r,a){if(r){if("string"==typeof r)return arrayLikeToArray(r,a);var t={}.toString.call(r).slice(8,-1);return"Object"===t&&r.constructor&&(t=r.constructor.name),"Map"===t||"Set"===t?Array.from(r):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?arrayLikeToArray(r,a):void 0}}', { - globals: ["Array"], - locals: { - _unsupportedIterableToArray: ["body.0.id"] - }, - exportBindingAssignments: [], - exportName: "_unsupportedIterableToArray", - dependencies: { - arrayLikeToArray: ["body.0.body.body.0.consequent.body.0.consequent.argument.callee", "body.0.body.body.0.consequent.body.2.argument.expressions.1.alternate.consequent.callee"] - } - }), - usingCtx: helper("7.23.9", 'function _usingCtx(){var r="function"==typeof SuppressedError?SuppressedError:function(r,n){var e=Error();return e.name="SuppressedError",e.error=r,e.suppressed=n,e},n={},e=[];function using(r,n){if(null!=n){if(Object(n)!==n)throw new TypeError("using declarations can only be used with objects, functions, null, or undefined.");if(r)var o=n[Symbol.asyncDispose||Symbol.for("Symbol.asyncDispose")];if(null==o&&(o=n[Symbol.dispose||Symbol.for("Symbol.dispose")]),"function"!=typeof o)throw new TypeError("Property [Symbol.dispose] is not a function.");e.push({v:n,d:o,a:r})}else r&&e.push({d:n,a:r});return n}return{e:n,u:using.bind(null,!1),a:using.bind(null,!0),d:function(){var o=this.e;function next(){for(;r=e.pop();)try{var r,t=r.d&&r.d.call(r.v);if(r.a)return Promise.resolve(t).then(next,err)}catch(r){return err(r)}if(o!==n)throw o}function err(e){return o=o!==n?new r(e,o):e,next()}return next()}}}', { - globals: ["SuppressedError", "Error", "Object", "TypeError", "Symbol", "Promise"], - locals: { - _usingCtx: ["body.0.id"] - }, - exportBindingAssignments: [], - exportName: "_usingCtx", - dependencies: {} - }), - wrapAsyncGenerator: helper("7.0.0-beta.0", 'function _wrapAsyncGenerator(e){return function(){return new AsyncGenerator(e.apply(this,arguments))}}function AsyncGenerator(e){var r,t;function resume(r,t){try{var n=e[r](t),o=n.value,u=o instanceof OverloadYield;Promise.resolve(u?o.v:o).then((function(t){if(u){var i="return"===r?"return":"next";if(!o.k||t.done)return resume(i,t);t=e[i](t).value}settle(n.done?"return":"normal",t)}),(function(e){resume("throw",e)}))}catch(e){settle("throw",e)}}function settle(e,n){switch(e){case"return":r.resolve({value:n,done:!0});break;case"throw":r.reject(n);break;default:r.resolve({value:n,done:!1})}(r=r.next)?resume(r.key,r.arg):t=null}this._invoke=function(e,n){return new Promise((function(o,u){var i={key:e,arg:n,resolve:o,reject:u,next:null};t?t=t.next=i:(r=t=i,resume(e,n))}))},"function"!=typeof e.return&&(this.return=void 0)}AsyncGenerator.prototype["function"==typeof Symbol&&Symbol.asyncIterator||"@@asyncIterator"]=function(){return this},AsyncGenerator.prototype.next=function(e){return this._invoke("next",e)},AsyncGenerator.prototype.throw=function(e){return this._invoke("throw",e)},AsyncGenerator.prototype.return=function(e){return this._invoke("return",e)};', { - globals: ["Promise", "Symbol"], - locals: { - _wrapAsyncGenerator: ["body.0.id"], - AsyncGenerator: ["body.1.id", "body.0.body.body.0.argument.body.body.0.argument.callee", "body.2.expression.expressions.0.left.object.object", "body.2.expression.expressions.1.left.object.object", "body.2.expression.expressions.2.left.object.object", "body.2.expression.expressions.3.left.object.object"] - }, - exportBindingAssignments: [], - exportName: "_wrapAsyncGenerator", - dependencies: { - OverloadYield: ["body.1.body.body.1.body.body.0.block.body.0.declarations.2.init.right"] - } - }), - wrapNativeSuper: helper("7.0.0-beta.0", 'function _wrapNativeSuper(t){var r="function"==typeof Map?new Map:void 0;return _wrapNativeSuper=function(t){if(null===t||!isNativeFunction(t))return t;if("function"!=typeof t)throw new TypeError("Super expression must either be null or a function");if(void 0!==r){if(r.has(t))return r.get(t);r.set(t,Wrapper)}function Wrapper(){return construct(t,arguments,getPrototypeOf(this).constructor)}return Wrapper.prototype=Object.create(t.prototype,{constructor:{value:Wrapper,enumerable:!1,writable:!0,configurable:!0}}),setPrototypeOf(Wrapper,t)},_wrapNativeSuper(t)}', { - globals: ["Map", "TypeError", "Object"], - locals: { - _wrapNativeSuper: ["body.0.id", "body.0.body.body.1.argument.expressions.1.callee", "body.0.body.body.1.argument.expressions.0.left"] - }, - exportBindingAssignments: ["body.0.body.body.1.argument.expressions.0"], - exportName: "_wrapNativeSuper", - dependencies: { - getPrototypeOf: ["body.0.body.body.1.argument.expressions.0.right.body.body.3.body.body.0.argument.arguments.2.object.callee"], - setPrototypeOf: ["body.0.body.body.1.argument.expressions.0.right.body.body.4.argument.expressions.1.callee"], - isNativeFunction: ["body.0.body.body.1.argument.expressions.0.right.body.body.0.test.right.argument.callee"], - construct: ["body.0.body.body.1.argument.expressions.0.right.body.body.3.body.body.0.argument.callee"] - } - }), - wrapRegExp: helper("7.19.0", 'function _wrapRegExp(){_wrapRegExp=function(e,r){return new BabelRegExp(e,void 0,r)};var e=RegExp.prototype,r=new WeakMap;function BabelRegExp(e,t,p){var o=RegExp(e,t);return r.set(o,p||r.get(e)),setPrototypeOf(o,BabelRegExp.prototype)}function buildGroups(e,t){var p=r.get(t);return Object.keys(p).reduce((function(r,t){var o=p[t];if("number"==typeof o)r[t]=e[o];else{for(var i=0;void 0===e[o[i]]&&i+1]+)>/g,(function(e,r){var t=o[r];return"$"+(Array.isArray(t)?t.join("$"):t)})))}if("function"==typeof p){var i=this;return e[Symbol.replace].call(this,t,(function(){var e=arguments;return"object"!=typeof e[e.length-1]&&(e=[].slice.call(e)).push(buildGroups(e,i)),p.apply(this,e)}))}return e[Symbol.replace].call(this,t,p)},_wrapRegExp.apply(this,arguments)}', { - globals: ["RegExp", "WeakMap", "Object", "Symbol", "Array"], - locals: { - _wrapRegExp: ["body.0.id", "body.0.body.body.4.argument.expressions.3.callee.object", "body.0.body.body.0.expression.left"] - }, - exportBindingAssignments: ["body.0.body.body.0.expression"], - exportName: "_wrapRegExp", - dependencies: { - setPrototypeOf: ["body.0.body.body.2.body.body.1.argument.expressions.1.callee"], - inherits: ["body.0.body.body.4.argument.expressions.0.callee"] - } - }), - writeOnlyError: helper("7.12.13", "function _writeOnlyError(r){throw new TypeError('\"'+r+'\" is write-only')}", { - globals: ["TypeError"], - locals: { - _writeOnlyError: ["body.0.id"] - }, - exportBindingAssignments: [], - exportName: "_writeOnlyError", - dependencies: {} - }) -}; -{ - Object.assign(helpers, { - AwaitValue: helper("7.0.0-beta.0", "function _AwaitValue(t){this.wrapped=t}", { - globals: [], - locals: { - _AwaitValue: ["body.0.id"] - }, - exportBindingAssignments: [], - exportName: "_AwaitValue", - dependencies: {} - }), - applyDecs: helper("7.17.8", 'function old_createMetadataMethodsForProperty(e,t,a,r){return{getMetadata:function(o){old_assertNotFinished(r,"getMetadata"),old_assertMetadataKey(o);var i=e[o];if(void 0!==i)if(1===t){var n=i.public;if(void 0!==n)return n[a]}else if(2===t){var l=i.private;if(void 0!==l)return l.get(a)}else if(Object.hasOwnProperty.call(i,"constructor"))return i.constructor},setMetadata:function(o,i){old_assertNotFinished(r,"setMetadata"),old_assertMetadataKey(o);var n=e[o];if(void 0===n&&(n=e[o]={}),1===t){var l=n.public;void 0===l&&(l=n.public={}),l[a]=i}else if(2===t){var s=n.priv;void 0===s&&(s=n.private=new Map),s.set(a,i)}else n.constructor=i}}}function old_convertMetadataMapToFinal(e,t){var a=e[Symbol.metadata||Symbol.for("Symbol.metadata")],r=Object.getOwnPropertySymbols(t);if(0!==r.length){for(var o=0;o=0;m--){var b;void 0!==(p=old_memberDec(h[m],r,c,l,s,o,i,n,f))&&(old_assertValidReturnValue(o,p),0===o?b=p:1===o?(b=old_getInit(p),v=p.get||f.get,y=p.set||f.set,f={get:v,set:y}):f=p,void 0!==b&&(void 0===d?d=b:"function"==typeof d?d=[d,b]:d.push(b)))}if(0===o||1===o){if(void 0===d)d=function(e,t){return t};else if("function"!=typeof d){var g=d;d=function(e,t){for(var a=t,r=0;r3,m=v>=5;if(m?(u=t,f=r,0!=(v-=5)&&(p=n=n||[])):(u=t.prototype,f=a,0!==v&&(p=i=i||[])),0!==v&&!h){var b=m?s:l,g=b.get(y)||0;if(!0===g||3===g&&4!==v||4===g&&3!==v)throw 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: "+y);!g&&v>2?b.set(y,v):b.set(y,!0)}old_applyMemberDec(e,u,d,y,v,m,h,f,p)}}old_pushInitializers(e,i),old_pushInitializers(e,n)}function old_pushInitializers(e,t){t&&e.push((function(e){for(var a=0;a0){for(var o=[],i=t,n=t.name,l=r.length-1;l>=0;l--){var s={v:!1};try{var c=Object.assign({kind:"class",name:n,addInitializer:old_createAddInitializerMethod(o,s)},old_createMetadataMethodsForProperty(a,0,n,s)),d=r[l](i,c)}finally{s.v=!0}void 0!==d&&(old_assertValidReturnValue(10,d),i=d)}e.push(i,(function(){for(var e=0;e=0;v--){var g;void 0!==(f=memberDec(h[v],a,c,o,n,i,s,u))&&(assertValidReturnValue(n,f),0===n?g=f:1===n?(g=f.init,p=f.get||u.get,d=f.set||u.set,u={get:p,set:d}):u=f,void 0!==g&&(void 0===l?l=g:"function"==typeof l?l=[l,g]:l.push(g)))}if(0===n||1===n){if(void 0===l)l=function(e,t){return t};else if("function"!=typeof l){var y=l;l=function(e,t){for(var r=t,a=0;a3,h=f>=5;if(h?(l=t,0!=(f-=5)&&(u=n=n||[])):(l=t.prototype,0!==f&&(u=a=a||[])),0!==f&&!d){var v=h?s:i,g=v.get(p)||0;if(!0===g||3===g&&4!==f||4===g&&3!==f)throw 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: "+p);!g&&f>2?v.set(p,f):v.set(p,!0)}applyMemberDec(e,l,c,p,f,h,d,u)}}pushInitializers(e,a),pushInitializers(e,n)}(a,e,t),function(e,t,r){if(r.length>0){for(var a=[],n=t,i=t.name,s=r.length-1;s>=0;s--){var o={v:!1};try{var c=r[s](n,{kind:"class",name:i,addInitializer:createAddInitializerMethod(a,o)})}finally{o.v=!0}void 0!==c&&(assertValidReturnValue(10,c),n=c)}e.push(n,(function(){for(var e=0;e=0;g--){var y;void 0!==(p=memberDec(v[g],n,c,s,a,i,o,f))&&(assertValidReturnValue(a,p),0===a?y=p:1===a?(y=p.init,d=p.get||f.get,h=p.set||f.set,f={get:d,set:h}):f=p,void 0!==y&&(void 0===l?l=y:"function"==typeof l?l=[l,y]:l.push(y)))}if(0===a||1===a){if(void 0===l)l=function(e,t){return t};else if("function"!=typeof l){var m=l;l=function(e,t){for(var r=t,n=0;n3,h=f>=5;if(h?(l=e,0!=(f-=5)&&(u=n=n||[])):(l=e.prototype,0!==f&&(u=r=r||[])),0!==f&&!d){var v=h?o:i,g=v.get(p)||0;if(!0===g||3===g&&4!==f||4===g&&3!==f)throw 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: "+p);!g&&f>2?v.set(p,f):v.set(p,!0)}applyMemberDec(a,l,c,p,f,h,d,u)}}return pushInitializers(a,r),pushInitializers(a,n),a}function pushInitializers(e,t){t&&e.push((function(e){for(var r=0;r0){for(var r=[],n=e,a=e.name,i=t.length-1;i>=0;i--){var o={v:!1};try{var s=t[i](n,{kind:"class",name:a,addInitializer:createAddInitializerMethod(r,o)})}finally{o.v=!0}void 0!==s&&(assertValidReturnValue(10,s),n=s)}return[n,function(){for(var e=0;e=0;m--){var b;void 0!==(h=memberDec(g[m],n,u,o,a,i,s,p,c))&&(assertValidReturnValue(a,h),0===a?b=h:1===a?(b=h.init,v=h.get||p.get,y=h.set||p.set,p={get:v,set:y}):p=h,void 0!==b&&(void 0===l?l=b:"function"==typeof l?l=[l,b]:l.push(b)))}if(0===a||1===a){if(void 0===l)l=function(e,t){return t};else if("function"!=typeof l){var I=l;l=function(e,t){for(var r=t,n=0;n3,y=d>=5,g=r;if(y?(f=e,0!=(d-=5)&&(p=a=a||[]),v&&!i&&(i=function(t){return checkInRHS(t)===e}),g=i):(f=e.prototype,0!==d&&(p=n=n||[])),0!==d&&!v){var m=y?c:o,b=m.get(h)||0;if(!0===b||3===b&&4!==d||4===b&&3!==d)throw 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: "+h);!b&&d>2?m.set(h,d):m.set(h,!0)}applyMemberDec(s,f,l,h,d,y,v,p,g)}}return pushInitializers(s,n),pushInitializers(s,a),s}function pushInitializers(e,t){t&&e.push((function(e){for(var r=0;r0){for(var r=[],n=e,a=e.name,i=t.length-1;i>=0;i--){var s={v:!1};try{var o=t[i](n,{kind:"class",name:a,addInitializer:createAddInitializerMethod(r,s)})}finally{s.v=!0}void 0!==o&&(assertValidReturnValue(10,o),n=o)}return[n,function(){for(var e=0;e=0;j-=r?2:1){var D=v[j],E=r?v[j-1]:void 0,I={},O={kind:["field","accessor","method","getter","setter","class"][o],name:n,metadata:a,addInitializer:function(e,t){if(e.v)throw Error("attempted to call addInitializer after decoration was finished");s(t,"An initializer","be",!0),c.push(t)}.bind(null,I)};try{if(b)(y=s(D.call(E,P,O),"class decorators","return"))&&(P=y);else{var k,F;O.static=l,O.private=f,f?2===o?k=function(e){return m(e),w.value}:(o<4&&(k=i(w,"get",m)),3!==o&&(F=i(w,"set",m))):(k=function(e){return e[n]},(o<2||4===o)&&(F=function(e,t){e[n]=t}));var N=O.access={has:f?h.bind():function(e){return n in e}};if(k&&(N.get=k),F&&(N.set=F),P=D.call(E,d?{get:w.get,set:w.set}:w[A],O),d){if("object"==typeof P&&P)(y=s(P.get,"accessor.get"))&&(w.get=y),(y=s(P.set,"accessor.set"))&&(w.set=y),(y=s(P.init,"accessor.init"))&&S.push(y);else if(void 0!==P)throw new TypeError("accessor decorators must return an object with get, set, or init properties or void 0")}else s(P,(p?"field":"method")+" decorators","return")&&(p?S.push(P):w[A]=P)}}finally{I.v=!0}}return(p||d)&&u.push((function(e,t){for(var r=S.length-1;r>=0;r--)t=S[r].call(e,t);return t})),p||b||(f?d?u.push(i(w,"get"),i(w,"set")):u.push(2===o?w[A]:i.call.bind(w[A])):Object.defineProperty(e,n,w)),P}function u(e,t){return Object.defineProperty(e,Symbol.metadata||Symbol.for("Symbol.metadata"),{configurable:!0,enumerable:!0,value:t})}if(arguments.length>=6)var l=a[Symbol.metadata||Symbol.for("Symbol.metadata")];var f=Object.create(null==l?null:l),p=function(e,t,r,n){var o,a,i=[],s=function(t){return checkInRHS(t)===e},u=new Map;function l(e){e&&i.push(c.bind(null,e))}for(var f=0;f3,y=16&d,v=!!(8&d),g=0==(d&=7),b=h+"/"+v;if(!g&&!m){var w=u.get(b);if(!0===w||3===w&&4!==d||4===w&&3!==d)throw 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: "+h);u.set(b,!(d>2)||d)}applyDec(v?e:e.prototype,p,y,m?"#"+h:toPropertyKey(h),d,n,v?a=a||[]:o=o||[],i,v,m,g,1===d,v&&m?s:r)}}return l(o),l(a),i}(e,t,o,f);return r.length||u(e,f),{e:p,get c(){var t=[];return r.length&&[u(applyDec(e,[r],n,e.name,5,f,t),f),c.bind(null,t,e)]}}}', { - globals: ["TypeError", "Array", "Object", "Error", "Symbol", "Map"], - locals: { - applyDecs2305: ["body.0.id"] - }, - exportBindingAssignments: [], - exportName: "applyDecs2305", - dependencies: { - checkInRHS: ["body.0.body.body.6.declarations.1.init.callee.body.body.0.declarations.3.init.body.body.0.argument.left.callee"], - setFunctionName: ["body.0.body.body.3.body.body.2.consequent.body.2.expression.consequent.expressions.0.consequent.right.properties.0.value.callee", "body.0.body.body.3.body.body.2.consequent.body.2.expression.consequent.expressions.1.right.callee"], - toPropertyKey: ["body.0.body.body.6.declarations.1.init.callee.body.body.2.body.body.1.consequent.body.2.expression.arguments.3.alternate.callee"] - } - }), - classApplyDescriptorDestructureSet: helper("7.13.10", 'function _classApplyDescriptorDestructureSet(e,t){if(t.set)return"__destrObj"in t||(t.__destrObj={set value(r){t.set.call(e,r)}}),t.__destrObj;if(!t.writable)throw new TypeError("attempted to set read only private field");return t}', { - globals: ["TypeError"], - locals: { - _classApplyDescriptorDestructureSet: ["body.0.id"] - }, - exportBindingAssignments: [], - exportName: "_classApplyDescriptorDestructureSet", - dependencies: {} - }), - classApplyDescriptorGet: helper("7.13.10", "function _classApplyDescriptorGet(e,t){return t.get?t.get.call(e):t.value}", { - globals: [], - locals: { - _classApplyDescriptorGet: ["body.0.id"] - }, - exportBindingAssignments: [], - exportName: "_classApplyDescriptorGet", - dependencies: {} - }), - classApplyDescriptorSet: helper("7.13.10", 'function _classApplyDescriptorSet(e,t,l){if(t.set)t.set.call(e,l);else{if(!t.writable)throw new TypeError("attempted to set read only private field");t.value=l}}', { - globals: ["TypeError"], - locals: { - _classApplyDescriptorSet: ["body.0.id"] - }, - exportBindingAssignments: [], - exportName: "_classApplyDescriptorSet", - dependencies: {} - }), - classCheckPrivateStaticAccess: helper("7.13.10", "function _classCheckPrivateStaticAccess(s,a,r){return assertClassBrand(a,s,r)}", { - globals: [], - locals: { - _classCheckPrivateStaticAccess: ["body.0.id"] - }, - exportBindingAssignments: [], - exportName: "_classCheckPrivateStaticAccess", - dependencies: { - assertClassBrand: ["body.0.body.body.0.argument.callee"] - } - }), - classCheckPrivateStaticFieldDescriptor: helper("7.13.10", 'function _classCheckPrivateStaticFieldDescriptor(t,e){if(void 0===t)throw new TypeError("attempted to "+e+" private static field before its declaration")}', { - globals: ["TypeError"], - locals: { - _classCheckPrivateStaticFieldDescriptor: ["body.0.id"] - }, - exportBindingAssignments: [], - exportName: "_classCheckPrivateStaticFieldDescriptor", - dependencies: {} - }), - classExtractFieldDescriptor: helper("7.13.10", "function _classExtractFieldDescriptor(e,t){return classPrivateFieldGet2(t,e)}", { - globals: [], - locals: { - _classExtractFieldDescriptor: ["body.0.id"] - }, - exportBindingAssignments: [], - exportName: "_classExtractFieldDescriptor", - dependencies: { - classPrivateFieldGet2: ["body.0.body.body.0.argument.callee"] - } - }), - classPrivateFieldDestructureSet: helper("7.4.4", "function _classPrivateFieldDestructureSet(e,t){var r=classPrivateFieldGet2(t,e);return classApplyDescriptorDestructureSet(e,r)}", { - globals: [], - locals: { - _classPrivateFieldDestructureSet: ["body.0.id"] - }, - exportBindingAssignments: [], - exportName: "_classPrivateFieldDestructureSet", - dependencies: { - classApplyDescriptorDestructureSet: ["body.0.body.body.1.argument.callee"], - classPrivateFieldGet2: ["body.0.body.body.0.declarations.0.init.callee"] - } - }), - classPrivateFieldGet: helper("7.0.0-beta.0", "function _classPrivateFieldGet(e,t){var r=classPrivateFieldGet2(t,e);return classApplyDescriptorGet(e,r)}", { - globals: [], - locals: { - _classPrivateFieldGet: ["body.0.id"] - }, - exportBindingAssignments: [], - exportName: "_classPrivateFieldGet", - dependencies: { - classApplyDescriptorGet: ["body.0.body.body.1.argument.callee"], - classPrivateFieldGet2: ["body.0.body.body.0.declarations.0.init.callee"] - } - }), - classPrivateFieldSet: helper("7.0.0-beta.0", "function _classPrivateFieldSet(e,t,r){var s=classPrivateFieldGet2(t,e);return classApplyDescriptorSet(e,s,r),r}", { - globals: [], - locals: { - _classPrivateFieldSet: ["body.0.id"] - }, - exportBindingAssignments: [], - exportName: "_classPrivateFieldSet", - dependencies: { - classApplyDescriptorSet: ["body.0.body.body.1.argument.expressions.0.callee"], - classPrivateFieldGet2: ["body.0.body.body.0.declarations.0.init.callee"] - } - }), - classPrivateMethodGet: helper("7.1.6", "function _classPrivateMethodGet(s,a,r){return assertClassBrand(a,s),r}", { - globals: [], - locals: { - _classPrivateMethodGet: ["body.0.id"] - }, - exportBindingAssignments: [], - exportName: "_classPrivateMethodGet", - dependencies: { - assertClassBrand: ["body.0.body.body.0.argument.expressions.0.callee"] - } - }), - classPrivateMethodSet: helper("7.1.6", 'function _classPrivateMethodSet(){throw new TypeError("attempted to reassign private method")}', { - globals: ["TypeError"], - locals: { - _classPrivateMethodSet: ["body.0.id"] - }, - exportBindingAssignments: [], - exportName: "_classPrivateMethodSet", - dependencies: {} - }), - classStaticPrivateFieldDestructureSet: helper("7.13.10", 'function _classStaticPrivateFieldDestructureSet(t,r,s){return assertClassBrand(r,t),classCheckPrivateStaticFieldDescriptor(s,"set"),classApplyDescriptorDestructureSet(t,s)}', { - globals: [], - locals: { - _classStaticPrivateFieldDestructureSet: ["body.0.id"] - }, - exportBindingAssignments: [], - exportName: "_classStaticPrivateFieldDestructureSet", - dependencies: { - classApplyDescriptorDestructureSet: ["body.0.body.body.0.argument.expressions.2.callee"], - assertClassBrand: ["body.0.body.body.0.argument.expressions.0.callee"], - classCheckPrivateStaticFieldDescriptor: ["body.0.body.body.0.argument.expressions.1.callee"] - } - }), - classStaticPrivateFieldSpecGet: helper("7.0.2", 'function _classStaticPrivateFieldSpecGet(t,s,r){return assertClassBrand(s,t),classCheckPrivateStaticFieldDescriptor(r,"get"),classApplyDescriptorGet(t,r)}', { - globals: [], - locals: { - _classStaticPrivateFieldSpecGet: ["body.0.id"] - }, - exportBindingAssignments: [], - exportName: "_classStaticPrivateFieldSpecGet", - dependencies: { - classApplyDescriptorGet: ["body.0.body.body.0.argument.expressions.2.callee"], - assertClassBrand: ["body.0.body.body.0.argument.expressions.0.callee"], - classCheckPrivateStaticFieldDescriptor: ["body.0.body.body.0.argument.expressions.1.callee"] - } - }), - classStaticPrivateFieldSpecSet: helper("7.0.2", 'function _classStaticPrivateFieldSpecSet(s,t,r,e){return assertClassBrand(t,s),classCheckPrivateStaticFieldDescriptor(r,"set"),classApplyDescriptorSet(s,r,e),e}', { - globals: [], - locals: { - _classStaticPrivateFieldSpecSet: ["body.0.id"] - }, - exportBindingAssignments: [], - exportName: "_classStaticPrivateFieldSpecSet", - dependencies: { - classApplyDescriptorSet: ["body.0.body.body.0.argument.expressions.2.callee"], - assertClassBrand: ["body.0.body.body.0.argument.expressions.0.callee"], - classCheckPrivateStaticFieldDescriptor: ["body.0.body.body.0.argument.expressions.1.callee"] - } - }), - classStaticPrivateMethodSet: helper("7.3.2", 'function _classStaticPrivateMethodSet(){throw new TypeError("attempted to set read only static private field")}', { - globals: ["TypeError"], - locals: { - _classStaticPrivateMethodSet: ["body.0.id"] - }, - exportBindingAssignments: [], - exportName: "_classStaticPrivateMethodSet", - dependencies: {} - }), - defineEnumerableProperties: helper("7.0.0-beta.0", 'function _defineEnumerableProperties(e,r){for(var t in r){var n=r[t];n.configurable=n.enumerable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,t,n)}if(Object.getOwnPropertySymbols)for(var a=Object.getOwnPropertySymbols(r),b=0;b0;)try{var o=r.pop(),p=o.d.call(o.v);if(o.a)return Promise.resolve(p).then(next,err)}catch(r){return err(r)}if(s)throw e}function err(r){return e=s?new dispose_SuppressedError(e,r):r,s=!0,next()}return next()}', { - globals: ["SuppressedError", "Error", "Object", "Promise"], - locals: { - dispose_SuppressedError: ["body.0.id", "body.0.body.body.0.argument.expressions.0.alternate.expressions.1.left.object", "body.0.body.body.0.argument.expressions.0.alternate.expressions.1.right.arguments.1.properties.0.value.properties.0.value", "body.0.body.body.0.argument.expressions.1.callee", "body.1.body.body.1.body.body.0.argument.expressions.0.right.consequent.callee", "body.0.body.body.0.argument.expressions.0.consequent.left", "body.0.body.body.0.argument.expressions.0.alternate.expressions.0.left"], - _dispose: ["body.1.id"] - }, - exportBindingAssignments: [], - exportName: "_dispose", - dependencies: {} - }), - objectSpread: helper("7.0.0-beta.0", 'function _objectSpread(e){for(var r=1;r= 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) { - newInit = old_getInit(newValue); - get = newValue.get || value.get; - set = newValue.set || value.set; - value = { - get: get, - set: set - }; - } else { - value = newValue; - } - if (newInit !== void 0) { - if (initializer === void 0) { - initializer = newInit; - } else if (typeof initializer === "function") { - initializer = [initializer, newInit]; - } else { - initializer.push(newInit); - } - } - } - } - } - if (kind === 0 || kind === 1) { - if (initializer === void 0) { - initializer = function (instance, init) { - return init; - }; - } 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; - desc.set = value.set; - } else if (kind === 2) { - desc.value = value; - } else if (kind === 3) { - desc.get = value; - } else if (kind === 4) { - desc.set = value; - } - if (isPrivate) { - if (kind === 1) { - ret.push(function (instance, args) { - return value.get.call(instance, args); - }); - ret.push(function (instance, args) { - return value.set.call(instance, args); - }); - } else if (kind === 2) { - ret.push(value); - } else { - ret.push(function (instance, args) { - return value.call(instance, args); - }); - } - } else { - Object.defineProperty(base, name, desc); - } - } -} -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]; - var isPrivate = decInfo.length > 3; - var isStatic = kind >= 5; - var base; - var metadataMap; - var initializers; - if (isStatic) { - base = Class; - metadataMap = staticMetadataMap; - kind = kind - 5; - if (kind !== 0) { - staticInitializers = staticInitializers || []; - initializers = staticInitializers; - } - } 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) { - existingNonFields.set(name, kind); - } else { - 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", - name: name, - addInitializer: old_createAddInitializerMethod(initializers, decoratorFinishedRef) - }, old_createMetadataMethodsForProperty(metadataMap, 0, name, decoratorFinishedRef)); - var nextNewClass = classDecs[i](newClass, ctx); - } 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); - } - }); - } -} -function applyDecs(targetClass, memberDecs, classDecs) { - var ret = []; - var staticMetadataMap = {}; - var protoMetadataMap = {}; - old_applyMemberDecs(ret, targetClass, protoMetadataMap, staticMetadataMap, memberDecs); - old_convertMetadataMapToFinal(targetClass.prototype, protoMetadataMap); - old_applyClassDecs(ret, targetClass, staticMetadataMap, classDecs); - old_convertMetadataMapToFinal(targetClass, staticMetadataMap); - return ret; -} - -//# sourceMappingURL=applyDecs.js.map diff --git a/tools/eslint/node_modules/@babel/helpers/lib/helpers/applyDecs2203.js b/tools/eslint/node_modules/@babel/helpers/lib/helpers/applyDecs2203.js deleted file mode 100644 index d61a4c42e454e9..00000000000000 --- a/tools/eslint/node_modules/@babel/helpers/lib/helpers/applyDecs2203.js +++ /dev/null @@ -1,363 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.default = applyDecs2203; -function applyDecs2203Factory() { - function createAddInitializerMethod(initializers, decoratorFinishedRef) { - return function addInitializer(initializer) { - assertNotFinished(decoratorFinishedRef, "addInitializer"); - assertCallable(initializer, "An initializer"); - initializers.push(initializer); - }; - } - function memberDec(dec, name, desc, 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, - static: isStatic, - private: isPrivate - }; - var decoratorFinishedRef = { - v: false - }; - if (kind !== 0) { - ctx.addInitializer = createAddInitializerMethod(initializers, decoratorFinishedRef); - } - var get, set; - if (kind === 0) { - if (isPrivate) { - get = desc.get; - set = desc.set; - } else { - get = function () { - return this[name]; - }; - set = function (v) { - this[name] = v; - }; - } - } else if (kind === 2) { - get = function () { - return desc.value; - }; - } else { - if (kind === 1 || kind === 3) { - get = function () { - return desc.get.call(this); - }; - } - if (kind === 1 || kind === 4) { - set = function (v) { - desc.set.call(this, v); - }; - } - } - ctx.access = get && set ? { - get: get, - set: set - } : get ? { - get: get - } : { - set: set - }; - try { - return dec(value, ctx); - } finally { - decoratorFinishedRef.v = true; - } - } - function assertNotFinished(decoratorFinishedRef, fnName) { - if (decoratorFinishedRef.v) { - throw new Error("attempted to call " + fnName + " after decoration was finished"); - } - } - function assertCallable(fn, hint) { - if (typeof fn !== "function") { - throw new TypeError(hint + " must be a function"); - } - } - function 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) { - assertCallable(value.get, "accessor.get"); - } - if (value.set !== undefined) { - assertCallable(value.set, "accessor.set"); - } - if (value.init !== undefined) { - assertCallable(value.init, "accessor.init"); - } - } else if (type !== "function") { - var hint; - if (kind === 0) { - hint = "field"; - } else if (kind === 10) { - hint = "class"; - } else { - hint = "method"; - } - throw new TypeError(hint + " decorators must return a function or void 0"); - } - } - function applyMemberDec(ret, base, decInfo, name, kind, isStatic, isPrivate, initializers) { - var decs = decInfo[0]; - var desc, init, value; - if (isPrivate) { - if (kind === 0 || kind === 1) { - desc = { - get: decInfo[3], - set: decInfo[4] - }; - } else if (kind === 3) { - desc = { - get: decInfo[3] - }; - } else if (kind === 4) { - desc = { - set: decInfo[3] - }; - } else { - desc = { - value: decInfo[3] - }; - } - } else if (kind !== 0) { - desc = Object.getOwnPropertyDescriptor(base, name); - } - if (kind === 1) { - value = { - get: desc.get, - set: desc.set - }; - } else if (kind === 2) { - value = desc.value; - } else if (kind === 3) { - value = desc.get; - } else if (kind === 4) { - value = desc.set; - } - var newValue, get, set; - if (typeof decs === "function") { - newValue = memberDec(decs, name, desc, initializers, kind, isStatic, isPrivate, value); - if (newValue !== void 0) { - assertValidReturnValue(kind, newValue); - if (kind === 0) { - init = newValue; - } else if (kind === 1) { - init = newValue.init; - get = newValue.get || value.get; - set = newValue.set || value.set; - value = { - get: get, - set: set - }; - } else { - value = newValue; - } - } - } else { - for (var i = decs.length - 1; i >= 0; i--) { - var dec = decs[i]; - newValue = memberDec(dec, name, desc, initializers, kind, isStatic, isPrivate, value); - if (newValue !== void 0) { - assertValidReturnValue(kind, newValue); - var newInit; - if (kind === 0) { - newInit = newValue; - } else if (kind === 1) { - newInit = newValue.init; - get = newValue.get || value.get; - set = newValue.set || value.set; - value = { - get: get, - set: set - }; - } else { - value = newValue; - } - if (newInit !== void 0) { - if (init === void 0) { - init = newInit; - } else if (typeof init === "function") { - init = [init, newInit]; - } else { - init.push(newInit); - } - } - } - } - } - if (kind === 0 || kind === 1) { - if (init === void 0) { - init = function (instance, init) { - return init; - }; - } else if (typeof init !== "function") { - var ownInitializers = init; - init = 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 = init; - init = function (instance, init) { - return originalInitializer.call(instance, init); - }; - } - ret.push(init); - } - if (kind !== 0) { - if (kind === 1) { - desc.get = value.get; - desc.set = value.set; - } else if (kind === 2) { - desc.value = value; - } else if (kind === 3) { - desc.get = value; - } else if (kind === 4) { - desc.set = value; - } - if (isPrivate) { - if (kind === 1) { - ret.push(function (instance, args) { - return value.get.call(instance, args); - }); - ret.push(function (instance, args) { - return value.set.call(instance, args); - }); - } else if (kind === 2) { - ret.push(value); - } else { - ret.push(function (instance, args) { - return value.call(instance, args); - }); - } - } else { - Object.defineProperty(base, name, desc); - } - } - } - function applyMemberDecs(ret, Class, 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]; - var isPrivate = decInfo.length > 3; - var isStatic = kind >= 5; - var base; - var initializers; - if (isStatic) { - base = Class; - kind = kind - 5; - if (kind !== 0) { - staticInitializers = staticInitializers || []; - initializers = staticInitializers; - } - } else { - base = Class.prototype; - 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) { - existingNonFields.set(name, kind); - } else { - existingNonFields.set(name, true); - } - } - applyMemberDec(ret, base, decInfo, name, kind, isStatic, isPrivate, initializers); - } - pushInitializers(ret, protoInitializers); - pushInitializers(ret, staticInitializers); - } - function pushInitializers(ret, initializers) { - if (initializers) { - ret.push(function (instance) { - for (var i = 0; i < initializers.length; i++) { - initializers[i].call(instance); - } - return instance; - }); - } - } - function applyClassDecs(ret, targetClass, 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 nextNewClass = classDecs[i](newClass, { - kind: "class", - name: name, - addInitializer: createAddInitializerMethod(initializers, decoratorFinishedRef) - }); - } finally { - decoratorFinishedRef.v = true; - } - if (nextNewClass !== undefined) { - assertValidReturnValue(10, nextNewClass); - newClass = nextNewClass; - } - } - ret.push(newClass, function () { - for (var i = 0; i < initializers.length; i++) { - initializers[i].call(newClass); - } - }); - } - } - return function applyDecs2203Impl(targetClass, memberDecs, classDecs) { - var ret = []; - applyMemberDecs(ret, targetClass, memberDecs); - applyClassDecs(ret, targetClass, classDecs); - return ret; - }; -} -var applyDecs2203Impl; -function applyDecs2203(targetClass, memberDecs, classDecs) { - applyDecs2203Impl = applyDecs2203Impl || applyDecs2203Factory(); - return applyDecs2203Impl(targetClass, memberDecs, classDecs); -} - -//# sourceMappingURL=applyDecs2203.js.map diff --git a/tools/eslint/node_modules/@babel/helpers/lib/helpers/applyDecs2203R.js b/tools/eslint/node_modules/@babel/helpers/lib/helpers/applyDecs2203R.js deleted file mode 100644 index 8f2750d4f31759..00000000000000 --- a/tools/eslint/node_modules/@babel/helpers/lib/helpers/applyDecs2203R.js +++ /dev/null @@ -1,376 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.default = applyDecs2203R; -var _setFunctionName = require("setFunctionName"); -var _toPropertyKey = require("toPropertyKey"); -function applyDecs2203RFactory() { - function createAddInitializerMethod(initializers, decoratorFinishedRef) { - return function addInitializer(initializer) { - assertNotFinished(decoratorFinishedRef, "addInitializer"); - assertCallable(initializer, "An initializer"); - initializers.push(initializer); - }; - } - function memberDec(dec, name, desc, 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 : _toPropertyKey(name), - static: isStatic, - private: isPrivate - }; - var decoratorFinishedRef = { - v: false - }; - if (kind !== 0) { - ctx.addInitializer = createAddInitializerMethod(initializers, decoratorFinishedRef); - } - var get, set; - if (kind === 0) { - if (isPrivate) { - get = desc.get; - set = desc.set; - } else { - get = function () { - return this[name]; - }; - set = function (v) { - this[name] = v; - }; - } - } else if (kind === 2) { - get = function () { - return desc.value; - }; - } else { - if (kind === 1 || kind === 3) { - get = function () { - return desc.get.call(this); - }; - } - if (kind === 1 || kind === 4) { - set = function (v) { - desc.set.call(this, v); - }; - } - } - ctx.access = get && set ? { - get: get, - set: set - } : get ? { - get: get - } : { - set: set - }; - try { - return dec(value, ctx); - } finally { - decoratorFinishedRef.v = true; - } - } - function assertNotFinished(decoratorFinishedRef, fnName) { - if (decoratorFinishedRef.v) { - throw new Error("attempted to call " + fnName + " after decoration was finished"); - } - } - function assertCallable(fn, hint) { - if (typeof fn !== "function") { - throw new TypeError(hint + " must be a function"); - } - } - function 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) { - assertCallable(value.get, "accessor.get"); - } - if (value.set !== undefined) { - assertCallable(value.set, "accessor.set"); - } - if (value.init !== undefined) { - assertCallable(value.init, "accessor.init"); - } - } else if (type !== "function") { - var hint; - if (kind === 0) { - hint = "field"; - } else if (kind === 10) { - hint = "class"; - } else { - hint = "method"; - } - throw new TypeError(hint + " decorators must return a function or void 0"); - } - } - function applyMemberDec(ret, base, decInfo, name, kind, isStatic, isPrivate, initializers) { - var decs = decInfo[0]; - var desc, init, prefix, value; - if (isPrivate) { - if (kind === 0 || kind === 1) { - desc = { - get: decInfo[3], - set: decInfo[4] - }; - prefix = "get"; - } else if (kind === 3) { - desc = { - get: decInfo[3] - }; - prefix = "get"; - } else if (kind === 4) { - desc = { - set: decInfo[3] - }; - prefix = "set"; - } else { - desc = { - value: decInfo[3] - }; - } - if (kind !== 0) { - if (kind === 1) { - _setFunctionName(decInfo[4], "#" + name, "set"); - } - _setFunctionName(decInfo[3], "#" + name, prefix); - } - } else if (kind !== 0) { - desc = Object.getOwnPropertyDescriptor(base, name); - } - if (kind === 1) { - value = { - get: desc.get, - set: desc.set - }; - } else if (kind === 2) { - value = desc.value; - } else if (kind === 3) { - value = desc.get; - } else if (kind === 4) { - value = desc.set; - } - var newValue, get, set; - if (typeof decs === "function") { - newValue = memberDec(decs, name, desc, initializers, kind, isStatic, isPrivate, value); - if (newValue !== void 0) { - assertValidReturnValue(kind, newValue); - if (kind === 0) { - init = newValue; - } else if (kind === 1) { - init = newValue.init; - get = newValue.get || value.get; - set = newValue.set || value.set; - value = { - get: get, - set: set - }; - } else { - value = newValue; - } - } - } else { - for (var i = decs.length - 1; i >= 0; i--) { - var dec = decs[i]; - newValue = memberDec(dec, name, desc, initializers, kind, isStatic, isPrivate, value); - if (newValue !== void 0) { - assertValidReturnValue(kind, newValue); - var newInit; - if (kind === 0) { - newInit = newValue; - } else if (kind === 1) { - newInit = newValue.init; - get = newValue.get || value.get; - set = newValue.set || value.set; - value = { - get: get, - set: set - }; - } else { - value = newValue; - } - if (newInit !== void 0) { - if (init === void 0) { - init = newInit; - } else if (typeof init === "function") { - init = [init, newInit]; - } else { - init.push(newInit); - } - } - } - } - } - if (kind === 0 || kind === 1) { - if (init === void 0) { - init = function (instance, init) { - return init; - }; - } else if (typeof init !== "function") { - var ownInitializers = init; - init = 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 = init; - init = function (instance, init) { - return originalInitializer.call(instance, init); - }; - } - ret.push(init); - } - if (kind !== 0) { - if (kind === 1) { - desc.get = value.get; - desc.set = value.set; - } else if (kind === 2) { - desc.value = value; - } else if (kind === 3) { - desc.get = value; - } else if (kind === 4) { - desc.set = value; - } - if (isPrivate) { - if (kind === 1) { - ret.push(function (instance, args) { - return value.get.call(instance, args); - }); - ret.push(function (instance, args) { - return value.set.call(instance, args); - }); - } else if (kind === 2) { - ret.push(value); - } else { - ret.push(function (instance, args) { - return value.call(instance, args); - }); - } - } else { - Object.defineProperty(base, name, desc); - } - } - } - function applyMemberDecs(Class, decInfos) { - var ret = []; - 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]; - var isPrivate = decInfo.length > 3; - var isStatic = kind >= 5; - var base; - var initializers; - if (isStatic) { - base = Class; - kind = kind - 5; - if (kind !== 0) { - staticInitializers = staticInitializers || []; - initializers = staticInitializers; - } - } else { - base = Class.prototype; - 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) { - existingNonFields.set(name, kind); - } else { - existingNonFields.set(name, true); - } - } - applyMemberDec(ret, base, decInfo, name, kind, isStatic, isPrivate, initializers); - } - pushInitializers(ret, protoInitializers); - pushInitializers(ret, staticInitializers); - return ret; - } - function pushInitializers(ret, initializers) { - if (initializers) { - ret.push(function (instance) { - for (var i = 0; i < initializers.length; i++) { - initializers[i].call(instance); - } - return instance; - }); - } - } - function applyClassDecs(targetClass, 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 nextNewClass = classDecs[i](newClass, { - kind: "class", - name: name, - addInitializer: createAddInitializerMethod(initializers, decoratorFinishedRef) - }); - } finally { - decoratorFinishedRef.v = true; - } - if (nextNewClass !== undefined) { - assertValidReturnValue(10, nextNewClass); - newClass = nextNewClass; - } - } - return [newClass, function () { - for (var i = 0; i < initializers.length; i++) { - initializers[i].call(newClass); - } - }]; - } - } - return function applyDecs2203R(targetClass, memberDecs, classDecs) { - return { - e: applyMemberDecs(targetClass, memberDecs), - get c() { - return applyClassDecs(targetClass, classDecs); - } - }; - }; -} -function applyDecs2203R(targetClass, memberDecs, classDecs) { - return (exports.default = applyDecs2203R = applyDecs2203RFactory())(targetClass, memberDecs, classDecs); -} - -//# sourceMappingURL=applyDecs2203R.js.map diff --git a/tools/eslint/node_modules/@babel/helpers/lib/helpers/applyDecs2301.js b/tools/eslint/node_modules/@babel/helpers/lib/helpers/applyDecs2301.js deleted file mode 100644 index aebfbff66eb9b2..00000000000000 --- a/tools/eslint/node_modules/@babel/helpers/lib/helpers/applyDecs2301.js +++ /dev/null @@ -1,421 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.default = applyDecs2301; -var _checkInRHS = require("checkInRHS"); -var _setFunctionName = require("setFunctionName"); -var _toPropertyKey = require("toPropertyKey"); -function applyDecs2301Factory() { - function createAddInitializerMethod(initializers, decoratorFinishedRef) { - return function addInitializer(initializer) { - assertNotFinished(decoratorFinishedRef, "addInitializer"); - assertCallable(initializer, "An initializer"); - initializers.push(initializer); - }; - } - function assertInstanceIfPrivate(has, target) { - if (!has(target)) { - throw new TypeError("Attempted to access private element on non-instance"); - } - } - function memberDec(dec, name, desc, initializers, kind, isStatic, isPrivate, value, hasPrivateBrand) { - 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 : _toPropertyKey(name), - static: isStatic, - private: isPrivate - }; - var decoratorFinishedRef = { - v: false - }; - if (kind !== 0) { - ctx.addInitializer = createAddInitializerMethod(initializers, decoratorFinishedRef); - } - var get, set; - if (!isPrivate && (kind === 0 || kind === 2)) { - get = function (target) { - return target[name]; - }; - if (kind === 0) { - set = function (target, v) { - target[name] = v; - }; - } - } else if (kind === 2) { - get = function (target) { - assertInstanceIfPrivate(hasPrivateBrand, target); - return desc.value; - }; - } else { - var t = kind === 0 || kind === 1; - if (t || kind === 3) { - if (isPrivate) { - get = function (target) { - assertInstanceIfPrivate(hasPrivateBrand, target); - return desc.get.call(target); - }; - } else { - get = function (target) { - return desc.get.call(target); - }; - } - } - if (t || kind === 4) { - if (isPrivate) { - set = function (target, value) { - assertInstanceIfPrivate(hasPrivateBrand, target); - desc.set.call(target, value); - }; - } else { - set = function (target, value) { - desc.set.call(target, value); - }; - } - } - } - var has = isPrivate ? hasPrivateBrand.bind() : function (target) { - return name in target; - }; - ctx.access = get && set ? { - get: get, - set: set, - has: has - } : get ? { - get: get, - has: has - } : { - set: set, - has: has - }; - try { - return dec(value, ctx); - } finally { - decoratorFinishedRef.v = true; - } - } - function assertNotFinished(decoratorFinishedRef, fnName) { - if (decoratorFinishedRef.v) { - throw new Error("attempted to call " + fnName + " after decoration was finished"); - } - } - function assertCallable(fn, hint) { - if (typeof fn !== "function") { - throw new TypeError(hint + " must be a function"); - } - } - function 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) { - assertCallable(value.get, "accessor.get"); - } - if (value.set !== undefined) { - assertCallable(value.set, "accessor.set"); - } - if (value.init !== undefined) { - assertCallable(value.init, "accessor.init"); - } - } else if (type !== "function") { - var hint; - if (kind === 0) { - hint = "field"; - } else if (kind === 10) { - hint = "class"; - } else { - hint = "method"; - } - throw new TypeError(hint + " decorators must return a function or void 0"); - } - } - function curryThis1(fn) { - return function () { - return fn(this); - }; - } - function curryThis2(fn) { - return function (value) { - fn(this, value); - }; - } - function applyMemberDec(ret, base, decInfo, name, kind, isStatic, isPrivate, initializers, hasPrivateBrand) { - var decs = decInfo[0]; - var desc, init, prefix, value; - if (isPrivate) { - if (kind === 0 || kind === 1) { - desc = { - get: curryThis1(decInfo[3]), - set: curryThis2(decInfo[4]) - }; - prefix = "get"; - } else { - if (kind === 3) { - desc = { - get: decInfo[3] - }; - prefix = "get"; - } else if (kind === 4) { - desc = { - set: decInfo[3] - }; - prefix = "set"; - } else { - desc = { - value: decInfo[3] - }; - } - } - if (kind !== 0) { - if (kind === 1) { - _setFunctionName(desc.set, "#" + name, "set"); - } - _setFunctionName(desc[prefix || "value"], "#" + name, prefix); - } - } else if (kind !== 0) { - desc = Object.getOwnPropertyDescriptor(base, name); - } - if (kind === 1) { - value = { - get: desc.get, - set: desc.set - }; - } else if (kind === 2) { - value = desc.value; - } else if (kind === 3) { - value = desc.get; - } else if (kind === 4) { - value = desc.set; - } - var newValue, get, set; - if (typeof decs === "function") { - newValue = memberDec(decs, name, desc, initializers, kind, isStatic, isPrivate, value, hasPrivateBrand); - if (newValue !== void 0) { - assertValidReturnValue(kind, newValue); - if (kind === 0) { - init = newValue; - } else if (kind === 1) { - init = newValue.init; - get = newValue.get || value.get; - set = newValue.set || value.set; - value = { - get: get, - set: set - }; - } else { - value = newValue; - } - } - } else { - for (var i = decs.length - 1; i >= 0; i--) { - var dec = decs[i]; - newValue = memberDec(dec, name, desc, initializers, kind, isStatic, isPrivate, value, hasPrivateBrand); - if (newValue !== void 0) { - assertValidReturnValue(kind, newValue); - var newInit; - if (kind === 0) { - newInit = newValue; - } else if (kind === 1) { - newInit = newValue.init; - get = newValue.get || value.get; - set = newValue.set || value.set; - value = { - get: get, - set: set - }; - } else { - value = newValue; - } - if (newInit !== void 0) { - if (init === void 0) { - init = newInit; - } else if (typeof init === "function") { - init = [init, newInit]; - } else { - init.push(newInit); - } - } - } - } - } - if (kind === 0 || kind === 1) { - if (init === void 0) { - init = function (instance, init) { - return init; - }; - } else if (typeof init !== "function") { - var ownInitializers = init; - init = 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 = init; - init = function (instance, init) { - return originalInitializer.call(instance, init); - }; - } - ret.push(init); - } - if (kind !== 0) { - if (kind === 1) { - desc.get = value.get; - desc.set = value.set; - } else if (kind === 2) { - desc.value = value; - } else if (kind === 3) { - desc.get = value; - } else if (kind === 4) { - desc.set = value; - } - if (isPrivate) { - if (kind === 1) { - ret.push(function (instance, args) { - return value.get.call(instance, args); - }); - ret.push(function (instance, args) { - return value.set.call(instance, args); - }); - } else if (kind === 2) { - ret.push(value); - } else { - ret.push(function (instance, args) { - return value.call(instance, args); - }); - } - } else { - Object.defineProperty(base, name, desc); - } - } - } - function applyMemberDecs(Class, decInfos, instanceBrand) { - var ret = []; - var protoInitializers; - var staticInitializers; - var staticBrand; - 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]; - var isPrivate = decInfo.length > 3; - var isStatic = kind >= 5; - var base; - var initializers; - var hasPrivateBrand = instanceBrand; - if (isStatic) { - base = Class; - kind = kind - 5; - if (kind !== 0) { - staticInitializers = staticInitializers || []; - initializers = staticInitializers; - } - if (isPrivate && !staticBrand) { - staticBrand = function (_) { - return _checkInRHS(_) === Class; - }; - } - hasPrivateBrand = staticBrand; - } else { - base = Class.prototype; - 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) { - existingNonFields.set(name, kind); - } else { - existingNonFields.set(name, true); - } - } - applyMemberDec(ret, base, decInfo, name, kind, isStatic, isPrivate, initializers, hasPrivateBrand); - } - pushInitializers(ret, protoInitializers); - pushInitializers(ret, staticInitializers); - return ret; - } - function pushInitializers(ret, initializers) { - if (initializers) { - ret.push(function (instance) { - for (var i = 0; i < initializers.length; i++) { - initializers[i].call(instance); - } - return instance; - }); - } - } - function applyClassDecs(targetClass, 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 nextNewClass = classDecs[i](newClass, { - kind: "class", - name: name, - addInitializer: createAddInitializerMethod(initializers, decoratorFinishedRef) - }); - } finally { - decoratorFinishedRef.v = true; - } - if (nextNewClass !== undefined) { - assertValidReturnValue(10, nextNewClass); - newClass = nextNewClass; - } - } - return [newClass, function () { - for (var i = 0; i < initializers.length; i++) { - initializers[i].call(newClass); - } - }]; - } - } - return function applyDecs2301(targetClass, memberDecs, classDecs, instanceBrand) { - return { - e: applyMemberDecs(targetClass, memberDecs, instanceBrand), - get c() { - return applyClassDecs(targetClass, classDecs); - } - }; - }; -} -function applyDecs2301(targetClass, memberDecs, classDecs, instanceBrand) { - return (exports.default = applyDecs2301 = applyDecs2301Factory())(targetClass, memberDecs, classDecs, instanceBrand); -} - -//# sourceMappingURL=applyDecs2301.js.map diff --git a/tools/eslint/node_modules/@babel/helpers/lib/helpers/applyDecs2305.js b/tools/eslint/node_modules/@babel/helpers/lib/helpers/applyDecs2305.js deleted file mode 100644 index 3c71f50cc6749c..00000000000000 --- a/tools/eslint/node_modules/@babel/helpers/lib/helpers/applyDecs2305.js +++ /dev/null @@ -1,235 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.default = applyDecs2305; -var _checkInRHS = require("./checkInRHS.js"); -var _setFunctionName = require("./setFunctionName.js"); -var _toPropertyKey = require("./toPropertyKey.js"); -function applyDecs2305(targetClass, memberDecs, classDecs, classDecsHaveThis, instanceBrand, parentClass) { - function _bindPropCall(obj, name, before) { - return function (_this, value) { - if (before) { - before(_this); - } - return obj[name].call(_this, value); - }; - } - function runInitializers(initializers, value) { - for (var i = 0; i < initializers.length; i++) { - initializers[i].call(value); - } - return value; - } - function assertCallable(fn, hint1, hint2, throwUndefined) { - if (typeof fn !== "function") { - if (throwUndefined || fn !== void 0) { - throw new TypeError(hint1 + " must " + (hint2 || "be") + " a function" + (throwUndefined ? "" : " or undefined")); - } - } - return fn; - } - function applyDec(Class, decInfo, decoratorsHaveThis, name, kind, metadata, initializers, ret, isStatic, isPrivate, isField, isAccessor, hasPrivateBrand) { - function assertInstanceIfPrivate(target) { - if (!hasPrivateBrand(target)) { - throw new TypeError("Attempted to access private element on non-instance"); - } - } - var decs = decInfo[0], - decVal = decInfo[3], - _, - isClass = !ret; - if (!isClass) { - if (!decoratorsHaveThis && !Array.isArray(decs)) { - decs = [decs]; - } - var desc = {}, - init = [], - key = kind === 3 ? "get" : kind === 4 || isAccessor ? "set" : "value"; - if (isPrivate) { - if (isField || isAccessor) { - desc = { - get: (0, _setFunctionName.default)(function () { - return decVal(this); - }, name, "get"), - set: function (value) { - decInfo[4](this, value); - } - }; - } else { - desc[key] = decVal; - } - if (!isField) { - (0, _setFunctionName.default)(desc[key], name, kind === 2 ? "" : key); - } - } else if (!isField) { - desc = Object.getOwnPropertyDescriptor(Class, name); - } - } - var newValue = Class; - for (var i = decs.length - 1; i >= 0; i -= decoratorsHaveThis ? 2 : 1) { - var dec = decs[i], - decThis = decoratorsHaveThis ? decs[i - 1] : void 0; - var decoratorFinishedRef = {}; - var ctx = { - kind: ["field", "accessor", "method", "getter", "setter", "class"][kind], - name: name, - metadata: metadata, - addInitializer: function (decoratorFinishedRef, initializer) { - if (decoratorFinishedRef.v) { - throw new Error("attempted to call addInitializer after decoration was finished"); - } - assertCallable(initializer, "An initializer", "be", true); - initializers.push(initializer); - }.bind(null, decoratorFinishedRef) - }; - try { - if (isClass) { - if (_ = assertCallable(dec.call(decThis, newValue, ctx), "class decorators", "return")) { - newValue = _; - } - } else { - ctx.static = isStatic; - ctx.private = isPrivate; - var get, set; - if (!isPrivate) { - get = function (target) { - return target[name]; - }; - if (kind < 2 || kind === 4) { - set = function (target, v) { - target[name] = v; - }; - } - } else if (kind === 2) { - get = function (_this) { - assertInstanceIfPrivate(_this); - return desc.value; - }; - } else { - if (kind < 4) { - get = _bindPropCall(desc, "get", assertInstanceIfPrivate); - } - if (kind !== 3) { - set = _bindPropCall(desc, "set", assertInstanceIfPrivate); - } - } - var access = ctx.access = { - has: isPrivate ? hasPrivateBrand.bind() : function (target) { - return name in target; - } - }; - if (get) access.get = get; - if (set) access.set = set; - newValue = dec.call(decThis, isAccessor ? { - get: desc.get, - set: desc.set - } : desc[key], ctx); - if (isAccessor) { - if (typeof newValue === "object" && newValue) { - if (_ = assertCallable(newValue.get, "accessor.get")) { - desc.get = _; - } - if (_ = assertCallable(newValue.set, "accessor.set")) { - desc.set = _; - } - if (_ = assertCallable(newValue.init, "accessor.init")) { - init.push(_); - } - } else if (newValue !== void 0) { - throw new TypeError("accessor decorators must return an object with get, set, or init properties or void 0"); - } - } else if (assertCallable(newValue, (isField ? "field" : "method") + " decorators", "return")) { - if (isField) { - init.push(newValue); - } else { - desc[key] = newValue; - } - } - } - } finally { - decoratorFinishedRef.v = true; - } - } - if (isField || isAccessor) { - ret.push(function (instance, value) { - for (var i = init.length - 1; i >= 0; i--) { - value = init[i].call(instance, value); - } - return value; - }); - } - if (!isField && !isClass) { - if (isPrivate) { - if (isAccessor) { - ret.push(_bindPropCall(desc, "get"), _bindPropCall(desc, "set")); - } else { - ret.push(kind === 2 ? desc[key] : _bindPropCall.call.bind(desc[key])); - } - } else { - Object.defineProperty(Class, name, desc); - } - } - return newValue; - } - function applyMemberDecs(Class, decInfos, instanceBrand, metadata) { - var ret = []; - var protoInitializers; - var staticInitializers; - var staticBrand = function (_) { - return (0, _checkInRHS.default)(_) === Class; - }; - var existingNonFields = new Map(); - function pushInitializers(initializers) { - if (initializers) { - ret.push(runInitializers.bind(null, initializers)); - } - } - 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]; - var isPrivate = decInfo.length > 3; - var decoratorsHaveThis = kind & 16; - var isStatic = !!(kind & 8); - kind &= 7; - var isField = kind === 0; - var key = name + "/" + isStatic; - if (!isField && !isPrivate) { - var existingKind = existingNonFields.get(key); - 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); - } - existingNonFields.set(key, kind > 2 ? kind : true); - } - applyDec(isStatic ? Class : Class.prototype, decInfo, decoratorsHaveThis, isPrivate ? "#" + name : (0, _toPropertyKey.default)(name), kind, metadata, isStatic ? staticInitializers = staticInitializers || [] : protoInitializers = protoInitializers || [], ret, isStatic, isPrivate, isField, kind === 1, isStatic && isPrivate ? staticBrand : instanceBrand); - } - pushInitializers(protoInitializers); - pushInitializers(staticInitializers); - return ret; - } - function defineMetadata(Class, metadata) { - return Object.defineProperty(Class, Symbol.metadata || Symbol.for("Symbol.metadata"), { - configurable: true, - enumerable: true, - value: metadata - }); - } - if (arguments.length >= 6) { - var parentMetadata = parentClass[Symbol.metadata || Symbol.for("Symbol.metadata")]; - } - var metadata = Object.create(parentMetadata == null ? null : parentMetadata); - var e = applyMemberDecs(targetClass, memberDecs, instanceBrand, metadata); - if (!classDecs.length) defineMetadata(targetClass, metadata); - return { - e: e, - get c() { - var initializers = []; - return classDecs.length && [defineMetadata(applyDec(targetClass, [classDecs], classDecsHaveThis, targetClass.name, 5, metadata, initializers), metadata), runInitializers.bind(null, initializers, targetClass)]; - } - }; -} - -//# sourceMappingURL=applyDecs2305.js.map diff --git a/tools/eslint/node_modules/@babel/helpers/lib/helpers/applyDecs2311.js b/tools/eslint/node_modules/@babel/helpers/lib/helpers/applyDecs2311.js deleted file mode 100644 index faaaf14cd5fb3c..00000000000000 --- a/tools/eslint/node_modules/@babel/helpers/lib/helpers/applyDecs2311.js +++ /dev/null @@ -1,236 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.default = applyDecs2311; -var _checkInRHS = require("./checkInRHS.js"); -var _setFunctionName = require("./setFunctionName.js"); -var _toPropertyKey = require("./toPropertyKey.js"); -function applyDecs2311(targetClass, classDecs, memberDecs, classDecsHaveThis, instanceBrand, parentClass) { - var symbolMetadata = Symbol.metadata || Symbol.for("Symbol.metadata"); - var defineProperty = Object.defineProperty; - var create = Object.create; - var metadata; - var existingNonFields = [create(null), create(null)]; - var hasClassDecs = classDecs.length; - var _; - function createRunInitializers(initializers, useStaticThis, hasValue) { - return function (thisArg, value) { - if (useStaticThis) { - value = thisArg; - thisArg = targetClass; - } - for (var i = 0; i < initializers.length; i++) { - value = initializers[i].apply(thisArg, hasValue ? [value] : []); - } - return hasValue ? value : thisArg; - }; - } - function assertCallable(fn, hint1, hint2, throwUndefined) { - if (typeof fn !== "function") { - if (throwUndefined || fn !== void 0) { - throw new TypeError(hint1 + " must " + (hint2 || "be") + " a function" + (throwUndefined ? "" : " or undefined")); - } - } - return fn; - } - function applyDec(Class, decInfo, decoratorsHaveThis, name, kind, initializers, ret, isStatic, isPrivate, isField, hasPrivateBrand) { - function assertInstanceIfPrivate(target) { - if (!hasPrivateBrand(target)) { - throw new TypeError("Attempted to access private element on non-instance"); - } - } - var decs = [].concat(decInfo[0]), - decVal = decInfo[3], - isClass = !ret; - var isAccessor = kind === 1; - var isGetter = kind === 3; - var isSetter = kind === 4; - var isMethod = kind === 2; - function _bindPropCall(name, useStaticThis, before) { - return function (_this, value) { - if (useStaticThis) { - value = _this; - _this = Class; - } - if (before) { - before(_this); - } - return desc[name].call(_this, value); - }; - } - if (!isClass) { - var desc = {}, - init = [], - key = isGetter ? "get" : isSetter || isAccessor ? "set" : "value"; - if (isPrivate) { - if (isField || isAccessor) { - desc = { - get: (0, _setFunctionName.default)(function () { - return decVal(this); - }, name, "get"), - set: function (value) { - decInfo[4](this, value); - } - }; - } else { - desc[key] = decVal; - } - if (!isField) { - (0, _setFunctionName.default)(desc[key], name, isMethod ? "" : key); - } - } else if (!isField) { - desc = Object.getOwnPropertyDescriptor(Class, name); - } - if (!isField && !isPrivate) { - _ = existingNonFields[+isStatic][name]; - if (_ && (_ ^ kind) !== 7) { - throw new Error("Decorating two elements with the same name (" + desc[key].name + ") is not supported yet"); - } - existingNonFields[+isStatic][name] = kind < 3 ? 1 : kind; - } - } - var newValue = Class; - for (var i = decs.length - 1; i >= 0; i -= decoratorsHaveThis ? 2 : 1) { - var dec = assertCallable(decs[i], "A decorator", "be", true), - decThis = decoratorsHaveThis ? decs[i - 1] : void 0; - var decoratorFinishedRef = {}; - var ctx = { - kind: ["field", "accessor", "method", "getter", "setter", "class"][kind], - name: name, - metadata: metadata, - addInitializer: function (decoratorFinishedRef, initializer) { - if (decoratorFinishedRef.v) { - throw new TypeError("attempted to call addInitializer after decoration was finished"); - } - assertCallable(initializer, "An initializer", "be", true); - initializers.push(initializer); - }.bind(null, decoratorFinishedRef) - }; - if (isClass) { - _ = dec.call(decThis, newValue, ctx); - decoratorFinishedRef.v = 1; - if (assertCallable(_, "class decorators", "return")) { - newValue = _; - } - } else { - ctx.static = isStatic; - ctx.private = isPrivate; - _ = ctx.access = { - has: isPrivate ? hasPrivateBrand.bind() : function (target) { - return name in target; - } - }; - if (!isSetter) { - _.get = isPrivate ? isMethod ? function (_this) { - assertInstanceIfPrivate(_this); - return desc.value; - } : _bindPropCall("get", 0, assertInstanceIfPrivate) : function (target) { - return target[name]; - }; - } - if (!isMethod && !isGetter) { - _.set = isPrivate ? _bindPropCall("set", 0, assertInstanceIfPrivate) : function (target, v) { - target[name] = v; - }; - } - newValue = dec.call(decThis, isAccessor ? { - get: desc.get, - set: desc.set - } : desc[key], ctx); - decoratorFinishedRef.v = 1; - if (isAccessor) { - if (typeof newValue === "object" && newValue) { - if (_ = assertCallable(newValue.get, "accessor.get")) { - desc.get = _; - } - if (_ = assertCallable(newValue.set, "accessor.set")) { - desc.set = _; - } - if (_ = assertCallable(newValue.init, "accessor.init")) { - init.unshift(_); - } - } else if (newValue !== void 0) { - throw new TypeError("accessor decorators must return an object with get, set, or init properties or undefined"); - } - } else if (assertCallable(newValue, (isField ? "field" : "method") + " decorators", "return")) { - if (isField) { - init.unshift(newValue); - } else { - desc[key] = newValue; - } - } - } - } - if (kind < 2) { - ret.push(createRunInitializers(init, isStatic, 1), createRunInitializers(initializers, isStatic, 0)); - } - if (!isField && !isClass) { - if (isPrivate) { - if (isAccessor) { - ret.splice(-1, 0, _bindPropCall("get", isStatic), _bindPropCall("set", isStatic)); - } else { - ret.push(isMethod ? desc[key] : assertCallable.call.bind(desc[key])); - } - } else { - defineProperty(Class, name, desc); - } - } - return newValue; - } - function applyMemberDecs() { - var ret = []; - var protoInitializers; - var staticInitializers; - var pushInitializers = function (initializers) { - if (initializers) { - ret.push(createRunInitializers(initializers)); - } - }; - var applyMemberDecsOfKind = function (isStatic, isField) { - for (var i = 0; i < memberDecs.length; i++) { - var decInfo = memberDecs[i]; - var kind = decInfo[1]; - var kindOnly = kind & 7; - if ((kind & 8) == isStatic && !kindOnly == isField) { - var name = decInfo[2]; - var isPrivate = !!decInfo[3]; - var decoratorsHaveThis = kind & 16; - applyDec(isStatic ? targetClass : targetClass.prototype, decInfo, decoratorsHaveThis, isPrivate ? "#" + name : (0, _toPropertyKey.default)(name), kindOnly, kindOnly < 2 ? [] : isStatic ? staticInitializers = staticInitializers || [] : protoInitializers = protoInitializers || [], ret, !!isStatic, isPrivate, isField, isStatic && isPrivate ? function (_) { - return (0, _checkInRHS.default)(_) === targetClass; - } : instanceBrand); - } - } - }; - applyMemberDecsOfKind(8, 0); - applyMemberDecsOfKind(0, 0); - applyMemberDecsOfKind(8, 1); - applyMemberDecsOfKind(0, 1); - pushInitializers(protoInitializers); - pushInitializers(staticInitializers); - return ret; - } - function defineMetadata(Class) { - return defineProperty(Class, symbolMetadata, { - configurable: true, - enumerable: true, - value: metadata - }); - } - if (parentClass !== undefined) { - metadata = parentClass[symbolMetadata]; - } - metadata = create(metadata == null ? null : metadata); - _ = applyMemberDecs(); - if (!hasClassDecs) defineMetadata(targetClass); - return { - e: _, - get c() { - var initializers = []; - return hasClassDecs && [defineMetadata(targetClass = applyDec(targetClass, [classDecs], classDecsHaveThis, targetClass.name, 5, initializers)), createRunInitializers(initializers, 1)]; - } - }; -} - -//# sourceMappingURL=applyDecs2311.js.map diff --git a/tools/eslint/node_modules/@babel/helpers/lib/helpers/arrayLikeToArray.js b/tools/eslint/node_modules/@babel/helpers/lib/helpers/arrayLikeToArray.js deleted file mode 100644 index 2a4161251f9af9..00000000000000 --- a/tools/eslint/node_modules/@babel/helpers/lib/helpers/arrayLikeToArray.js +++ /dev/null @@ -1,13 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.default = _arrayLikeToArray; -function _arrayLikeToArray(arr, len) { - if (len == null || len > arr.length) len = arr.length; - for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; - return arr2; -} - -//# sourceMappingURL=arrayLikeToArray.js.map diff --git a/tools/eslint/node_modules/@babel/helpers/lib/helpers/arrayWithHoles.js b/tools/eslint/node_modules/@babel/helpers/lib/helpers/arrayWithHoles.js deleted file mode 100644 index 89e2b9051a3fb1..00000000000000 --- a/tools/eslint/node_modules/@babel/helpers/lib/helpers/arrayWithHoles.js +++ /dev/null @@ -1,11 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.default = _arrayWithHoles; -function _arrayWithHoles(arr) { - if (Array.isArray(arr)) return arr; -} - -//# sourceMappingURL=arrayWithHoles.js.map diff --git a/tools/eslint/node_modules/@babel/helpers/lib/helpers/arrayWithoutHoles.js b/tools/eslint/node_modules/@babel/helpers/lib/helpers/arrayWithoutHoles.js deleted file mode 100644 index 5c9f4aee22ddff..00000000000000 --- a/tools/eslint/node_modules/@babel/helpers/lib/helpers/arrayWithoutHoles.js +++ /dev/null @@ -1,12 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.default = _arrayWithoutHoles; -var _arrayLikeToArray = require("./arrayLikeToArray.js"); -function _arrayWithoutHoles(arr) { - if (Array.isArray(arr)) return (0, _arrayLikeToArray.default)(arr); -} - -//# sourceMappingURL=arrayWithoutHoles.js.map diff --git a/tools/eslint/node_modules/@babel/helpers/lib/helpers/assertClassBrand.js b/tools/eslint/node_modules/@babel/helpers/lib/helpers/assertClassBrand.js deleted file mode 100644 index 8d88e439ea724e..00000000000000 --- a/tools/eslint/node_modules/@babel/helpers/lib/helpers/assertClassBrand.js +++ /dev/null @@ -1,14 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.default = _assertClassBrand; -function _assertClassBrand(brand, receiver, returnValue) { - if (typeof brand === "function" ? brand === receiver : brand.has(receiver)) { - return arguments.length < 3 ? receiver : returnValue; - } - throw new TypeError("Private element is not present on this object"); -} - -//# sourceMappingURL=assertClassBrand.js.map diff --git a/tools/eslint/node_modules/@babel/helpers/lib/helpers/assertThisInitialized.js b/tools/eslint/node_modules/@babel/helpers/lib/helpers/assertThisInitialized.js deleted file mode 100644 index d8a4a5937b6067..00000000000000 --- a/tools/eslint/node_modules/@babel/helpers/lib/helpers/assertThisInitialized.js +++ /dev/null @@ -1,14 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.default = _assertThisInitialized; -function _assertThisInitialized(self) { - if (self === void 0) { - throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); - } - return self; -} - -//# sourceMappingURL=assertThisInitialized.js.map diff --git a/tools/eslint/node_modules/@babel/helpers/lib/helpers/asyncGeneratorDelegate.js b/tools/eslint/node_modules/@babel/helpers/lib/helpers/asyncGeneratorDelegate.js deleted file mode 100644 index 8e3ddaf7b97b8e..00000000000000 --- a/tools/eslint/node_modules/@babel/helpers/lib/helpers/asyncGeneratorDelegate.js +++ /dev/null @@ -1,52 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.default = _asyncGeneratorDelegate; -var _OverloadYield = require("./OverloadYield.js"); -function _asyncGeneratorDelegate(inner) { - var iter = {}, - waiting = false; - function pump(key, value) { - waiting = true; - value = new Promise(function (resolve) { - resolve(inner[key](value)); - }); - return { - done: false, - value: new _OverloadYield.default(value, 1) - }; - } - iter[typeof Symbol !== "undefined" && Symbol.iterator || "@@iterator"] = function () { - return this; - }; - iter.next = function (value) { - if (waiting) { - waiting = false; - return value; - } - return pump("next", value); - }; - if (typeof inner.throw === "function") { - iter.throw = function (value) { - if (waiting) { - waiting = false; - throw value; - } - return pump("throw", value); - }; - } - if (typeof inner.return === "function") { - iter.return = function (value) { - if (waiting) { - waiting = false; - return value; - } - return pump("return", value); - }; - } - return iter; -} - -//# sourceMappingURL=asyncGeneratorDelegate.js.map diff --git a/tools/eslint/node_modules/@babel/helpers/lib/helpers/asyncIterator.js b/tools/eslint/node_modules/@babel/helpers/lib/helpers/asyncIterator.js deleted file mode 100644 index 64bd6f184fc1e4..00000000000000 --- a/tools/eslint/node_modules/@babel/helpers/lib/helpers/asyncIterator.js +++ /dev/null @@ -1,72 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.default = _asyncIterator; -function _asyncIterator(iterable) { - var method, - async, - sync, - retry = 2; - if (typeof Symbol !== "undefined") { - async = Symbol.asyncIterator; - sync = Symbol.iterator; - } - while (retry--) { - if (async && (method = iterable[async]) != null) { - return method.call(iterable); - } - if (sync && (method = iterable[sync]) != null) { - return new AsyncFromSyncIterator(method.call(iterable)); - } - async = "@@asyncIterator"; - sync = "@@iterator"; - } - throw new TypeError("Object is not async iterable"); -} -function AsyncFromSyncIterator(s) { - AsyncFromSyncIterator = function (s) { - this.s = s; - this.n = s.next; - }; - AsyncFromSyncIterator.prototype = { - s: null, - n: null, - next: function () { - return AsyncFromSyncIteratorContinuation(this.n.apply(this.s, arguments)); - }, - return: function (value) { - var ret = this.s.return; - if (ret === undefined) { - return Promise.resolve({ - value: value, - done: true - }); - } - return AsyncFromSyncIteratorContinuation(ret.apply(this.s, arguments)); - }, - throw: function (maybeError) { - var thr = this.s.return; - if (thr === undefined) { - return Promise.reject(maybeError); - } - return AsyncFromSyncIteratorContinuation(thr.apply(this.s, arguments)); - } - }; - function AsyncFromSyncIteratorContinuation(r) { - if (Object(r) !== r) { - return Promise.reject(new TypeError(r + " is not an object.")); - } - var done = r.done; - return Promise.resolve(r.value).then(function (value) { - return { - value: value, - done: done - }; - }); - } - return new AsyncFromSyncIterator(s); -} - -//# sourceMappingURL=asyncIterator.js.map diff --git a/tools/eslint/node_modules/@babel/helpers/lib/helpers/asyncToGenerator.js b/tools/eslint/node_modules/@babel/helpers/lib/helpers/asyncToGenerator.js deleted file mode 100644 index 9fec08d1d6fa71..00000000000000 --- a/tools/eslint/node_modules/@babel/helpers/lib/helpers/asyncToGenerator.js +++ /dev/null @@ -1,38 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.default = _asyncToGenerator; -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); - }); - }; -} - -//# sourceMappingURL=asyncToGenerator.js.map diff --git a/tools/eslint/node_modules/@babel/helpers/lib/helpers/awaitAsyncGenerator.js b/tools/eslint/node_modules/@babel/helpers/lib/helpers/awaitAsyncGenerator.js deleted file mode 100644 index 1338393f05a694..00000000000000 --- a/tools/eslint/node_modules/@babel/helpers/lib/helpers/awaitAsyncGenerator.js +++ /dev/null @@ -1,12 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.default = _awaitAsyncGenerator; -var _OverloadYield = require("./OverloadYield.js"); -function _awaitAsyncGenerator(value) { - return new _OverloadYield.default(value, 0); -} - -//# sourceMappingURL=awaitAsyncGenerator.js.map diff --git a/tools/eslint/node_modules/@babel/helpers/lib/helpers/callSuper.js b/tools/eslint/node_modules/@babel/helpers/lib/helpers/callSuper.js deleted file mode 100644 index 2be00ab64098ac..00000000000000 --- a/tools/eslint/node_modules/@babel/helpers/lib/helpers/callSuper.js +++ /dev/null @@ -1,15 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.default = _callSuper; -var _getPrototypeOf = require("./getPrototypeOf.js"); -var _isNativeReflectConstruct = require("./isNativeReflectConstruct.js"); -var _possibleConstructorReturn = require("./possibleConstructorReturn.js"); -function _callSuper(_this, derived, args) { - derived = (0, _getPrototypeOf.default)(derived); - return (0, _possibleConstructorReturn.default)(_this, (0, _isNativeReflectConstruct.default)() ? Reflect.construct(derived, args || [], (0, _getPrototypeOf.default)(_this).constructor) : derived.apply(_this, args)); -} - -//# sourceMappingURL=callSuper.js.map diff --git a/tools/eslint/node_modules/@babel/helpers/lib/helpers/checkInRHS.js b/tools/eslint/node_modules/@babel/helpers/lib/helpers/checkInRHS.js deleted file mode 100644 index 0a6d3c74af2843..00000000000000 --- a/tools/eslint/node_modules/@babel/helpers/lib/helpers/checkInRHS.js +++ /dev/null @@ -1,14 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.default = _checkInRHS; -function _checkInRHS(value) { - if (Object(value) !== value) { - throw TypeError("right-hand side of 'in' should be an object, got " + (value !== null ? typeof value : "null")); - } - return value; -} - -//# sourceMappingURL=checkInRHS.js.map diff --git a/tools/eslint/node_modules/@babel/helpers/lib/helpers/checkPrivateRedeclaration.js b/tools/eslint/node_modules/@babel/helpers/lib/helpers/checkPrivateRedeclaration.js deleted file mode 100644 index b14520ea385659..00000000000000 --- a/tools/eslint/node_modules/@babel/helpers/lib/helpers/checkPrivateRedeclaration.js +++ /dev/null @@ -1,13 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.default = _checkPrivateRedeclaration; -function _checkPrivateRedeclaration(obj, privateCollection) { - if (privateCollection.has(obj)) { - throw new TypeError("Cannot initialize the same private elements twice on an object"); - } -} - -//# sourceMappingURL=checkPrivateRedeclaration.js.map diff --git a/tools/eslint/node_modules/@babel/helpers/lib/helpers/classApplyDescriptorDestructureSet.js b/tools/eslint/node_modules/@babel/helpers/lib/helpers/classApplyDescriptorDestructureSet.js deleted file mode 100644 index 0159ce6ce0abcc..00000000000000 --- a/tools/eslint/node_modules/@babel/helpers/lib/helpers/classApplyDescriptorDestructureSet.js +++ /dev/null @@ -1,25 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.default = _classApplyDescriptorDestructureSet; -function _classApplyDescriptorDestructureSet(receiver, descriptor) { - if (descriptor.set) { - if (!("__destrObj" in descriptor)) { - descriptor.__destrObj = { - set value(v) { - descriptor.set.call(receiver, v); - } - }; - } - return descriptor.__destrObj; - } else { - if (!descriptor.writable) { - throw new TypeError("attempted to set read only private field"); - } - return descriptor; - } -} - -//# sourceMappingURL=classApplyDescriptorDestructureSet.js.map diff --git a/tools/eslint/node_modules/@babel/helpers/lib/helpers/classApplyDescriptorGet.js b/tools/eslint/node_modules/@babel/helpers/lib/helpers/classApplyDescriptorGet.js deleted file mode 100644 index 0730734dd06655..00000000000000 --- a/tools/eslint/node_modules/@babel/helpers/lib/helpers/classApplyDescriptorGet.js +++ /dev/null @@ -1,14 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.default = _classApplyDescriptorGet; -function _classApplyDescriptorGet(receiver, descriptor) { - if (descriptor.get) { - return descriptor.get.call(receiver); - } - return descriptor.value; -} - -//# sourceMappingURL=classApplyDescriptorGet.js.map diff --git a/tools/eslint/node_modules/@babel/helpers/lib/helpers/classApplyDescriptorSet.js b/tools/eslint/node_modules/@babel/helpers/lib/helpers/classApplyDescriptorSet.js deleted file mode 100644 index a0ffc8a8b6842b..00000000000000 --- a/tools/eslint/node_modules/@babel/helpers/lib/helpers/classApplyDescriptorSet.js +++ /dev/null @@ -1,18 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.default = _classApplyDescriptorSet; -function _classApplyDescriptorSet(receiver, descriptor, value) { - if (descriptor.set) { - descriptor.set.call(receiver, value); - } else { - if (!descriptor.writable) { - throw new TypeError("attempted to set read only private field"); - } - descriptor.value = value; - } -} - -//# sourceMappingURL=classApplyDescriptorSet.js.map diff --git a/tools/eslint/node_modules/@babel/helpers/lib/helpers/classCallCheck.js b/tools/eslint/node_modules/@babel/helpers/lib/helpers/classCallCheck.js deleted file mode 100644 index 9b56e55374bc39..00000000000000 --- a/tools/eslint/node_modules/@babel/helpers/lib/helpers/classCallCheck.js +++ /dev/null @@ -1,13 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.default = _classCallCheck; -function _classCallCheck(instance, Constructor) { - if (!(instance instanceof Constructor)) { - throw new TypeError("Cannot call a class as a function"); - } -} - -//# sourceMappingURL=classCallCheck.js.map diff --git a/tools/eslint/node_modules/@babel/helpers/lib/helpers/classCheckPrivateStaticAccess.js b/tools/eslint/node_modules/@babel/helpers/lib/helpers/classCheckPrivateStaticAccess.js deleted file mode 100644 index d6adf1869a70bf..00000000000000 --- a/tools/eslint/node_modules/@babel/helpers/lib/helpers/classCheckPrivateStaticAccess.js +++ /dev/null @@ -1,12 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.default = _classCheckPrivateStaticAccess; -var _assertClassBrand = require("assertClassBrand"); -function _classCheckPrivateStaticAccess(receiver, classConstructor, returnValue) { - return _assertClassBrand(classConstructor, receiver, returnValue); -} - -//# sourceMappingURL=classCheckPrivateStaticAccess.js.map diff --git a/tools/eslint/node_modules/@babel/helpers/lib/helpers/classCheckPrivateStaticFieldDescriptor.js b/tools/eslint/node_modules/@babel/helpers/lib/helpers/classCheckPrivateStaticFieldDescriptor.js deleted file mode 100644 index 6d96b72815a798..00000000000000 --- a/tools/eslint/node_modules/@babel/helpers/lib/helpers/classCheckPrivateStaticFieldDescriptor.js +++ /dev/null @@ -1,13 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.default = _classCheckPrivateStaticFieldDescriptor; -function _classCheckPrivateStaticFieldDescriptor(descriptor, action) { - if (descriptor === undefined) { - throw new TypeError("attempted to " + action + " private static field before its declaration"); - } -} - -//# sourceMappingURL=classCheckPrivateStaticFieldDescriptor.js.map diff --git a/tools/eslint/node_modules/@babel/helpers/lib/helpers/classExtractFieldDescriptor.js b/tools/eslint/node_modules/@babel/helpers/lib/helpers/classExtractFieldDescriptor.js deleted file mode 100644 index aee037e9f6a271..00000000000000 --- a/tools/eslint/node_modules/@babel/helpers/lib/helpers/classExtractFieldDescriptor.js +++ /dev/null @@ -1,12 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.default = _classExtractFieldDescriptor; -var _classPrivateFieldGet = require("classPrivateFieldGet2"); -function _classExtractFieldDescriptor(receiver, privateMap) { - return _classPrivateFieldGet(privateMap, receiver); -} - -//# sourceMappingURL=classExtractFieldDescriptor.js.map diff --git a/tools/eslint/node_modules/@babel/helpers/lib/helpers/classNameTDZError.js b/tools/eslint/node_modules/@babel/helpers/lib/helpers/classNameTDZError.js deleted file mode 100644 index 6adfc09c1a837b..00000000000000 --- a/tools/eslint/node_modules/@babel/helpers/lib/helpers/classNameTDZError.js +++ /dev/null @@ -1,11 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.default = _classNameTDZError; -function _classNameTDZError(name) { - throw new ReferenceError('Class "' + name + '" cannot be referenced in computed property keys.'); -} - -//# sourceMappingURL=classNameTDZError.js.map diff --git a/tools/eslint/node_modules/@babel/helpers/lib/helpers/classPrivateFieldDestructureSet.js b/tools/eslint/node_modules/@babel/helpers/lib/helpers/classPrivateFieldDestructureSet.js deleted file mode 100644 index caeb8a5b3ec818..00000000000000 --- a/tools/eslint/node_modules/@babel/helpers/lib/helpers/classPrivateFieldDestructureSet.js +++ /dev/null @@ -1,14 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.default = _classPrivateFieldDestructureSet; -var _classApplyDescriptorDestructureSet = require("classApplyDescriptorDestructureSet"); -var _classPrivateFieldGet = require("classPrivateFieldGet2"); -function _classPrivateFieldDestructureSet(receiver, privateMap) { - var descriptor = _classPrivateFieldGet(privateMap, receiver); - return _classApplyDescriptorDestructureSet(receiver, descriptor); -} - -//# sourceMappingURL=classPrivateFieldDestructureSet.js.map diff --git a/tools/eslint/node_modules/@babel/helpers/lib/helpers/classPrivateFieldGet.js b/tools/eslint/node_modules/@babel/helpers/lib/helpers/classPrivateFieldGet.js deleted file mode 100644 index 225733fb2ca93a..00000000000000 --- a/tools/eslint/node_modules/@babel/helpers/lib/helpers/classPrivateFieldGet.js +++ /dev/null @@ -1,14 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.default = _classPrivateFieldGet; -var _classApplyDescriptorGet = require("classApplyDescriptorGet"); -var _classPrivateFieldGet2 = require("classPrivateFieldGet2"); -function _classPrivateFieldGet(receiver, privateMap) { - var descriptor = _classPrivateFieldGet2(privateMap, receiver); - return _classApplyDescriptorGet(receiver, descriptor); -} - -//# sourceMappingURL=classPrivateFieldGet.js.map diff --git a/tools/eslint/node_modules/@babel/helpers/lib/helpers/classPrivateFieldGet2.js b/tools/eslint/node_modules/@babel/helpers/lib/helpers/classPrivateFieldGet2.js deleted file mode 100644 index 655c90379bf565..00000000000000 --- a/tools/eslint/node_modules/@babel/helpers/lib/helpers/classPrivateFieldGet2.js +++ /dev/null @@ -1,12 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.default = _classPrivateFieldGet2; -var _assertClassBrand = require("./assertClassBrand.js"); -function _classPrivateFieldGet2(privateMap, receiver) { - return privateMap.get((0, _assertClassBrand.default)(privateMap, receiver)); -} - -//# sourceMappingURL=classPrivateFieldGet2.js.map diff --git a/tools/eslint/node_modules/@babel/helpers/lib/helpers/classPrivateFieldInitSpec.js b/tools/eslint/node_modules/@babel/helpers/lib/helpers/classPrivateFieldInitSpec.js deleted file mode 100644 index db6806baff5c82..00000000000000 --- a/tools/eslint/node_modules/@babel/helpers/lib/helpers/classPrivateFieldInitSpec.js +++ /dev/null @@ -1,13 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.default = _classPrivateFieldInitSpec; -var _checkPrivateRedeclaration = require("./checkPrivateRedeclaration.js"); -function _classPrivateFieldInitSpec(obj, privateMap, value) { - (0, _checkPrivateRedeclaration.default)(obj, privateMap); - privateMap.set(obj, value); -} - -//# sourceMappingURL=classPrivateFieldInitSpec.js.map diff --git a/tools/eslint/node_modules/@babel/helpers/lib/helpers/classPrivateFieldLooseBase.js b/tools/eslint/node_modules/@babel/helpers/lib/helpers/classPrivateFieldLooseBase.js deleted file mode 100644 index d89790b817a465..00000000000000 --- a/tools/eslint/node_modules/@babel/helpers/lib/helpers/classPrivateFieldLooseBase.js +++ /dev/null @@ -1,14 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.default = _classPrivateFieldBase; -function _classPrivateFieldBase(receiver, privateKey) { - if (!Object.prototype.hasOwnProperty.call(receiver, privateKey)) { - throw new TypeError("attempted to use private field on non-instance"); - } - return receiver; -} - -//# sourceMappingURL=classPrivateFieldLooseBase.js.map diff --git a/tools/eslint/node_modules/@babel/helpers/lib/helpers/classPrivateFieldLooseKey.js b/tools/eslint/node_modules/@babel/helpers/lib/helpers/classPrivateFieldLooseKey.js deleted file mode 100644 index 5c3dac43f6f31d..00000000000000 --- a/tools/eslint/node_modules/@babel/helpers/lib/helpers/classPrivateFieldLooseKey.js +++ /dev/null @@ -1,12 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.default = _classPrivateFieldKey; -var id = 0; -function _classPrivateFieldKey(name) { - return "__private_" + id++ + "_" + name; -} - -//# sourceMappingURL=classPrivateFieldLooseKey.js.map diff --git a/tools/eslint/node_modules/@babel/helpers/lib/helpers/classPrivateFieldSet.js b/tools/eslint/node_modules/@babel/helpers/lib/helpers/classPrivateFieldSet.js deleted file mode 100644 index f2466197c02a5a..00000000000000 --- a/tools/eslint/node_modules/@babel/helpers/lib/helpers/classPrivateFieldSet.js +++ /dev/null @@ -1,15 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.default = _classPrivateFieldSet; -var _classApplyDescriptorSet = require("classApplyDescriptorSet"); -var _classPrivateFieldGet = require("classPrivateFieldGet2"); -function _classPrivateFieldSet(receiver, privateMap, value) { - var descriptor = _classPrivateFieldGet(privateMap, receiver); - _classApplyDescriptorSet(receiver, descriptor, value); - return value; -} - -//# sourceMappingURL=classPrivateFieldSet.js.map diff --git a/tools/eslint/node_modules/@babel/helpers/lib/helpers/classPrivateFieldSet2.js b/tools/eslint/node_modules/@babel/helpers/lib/helpers/classPrivateFieldSet2.js deleted file mode 100644 index 19cfe7f7a1f1c0..00000000000000 --- a/tools/eslint/node_modules/@babel/helpers/lib/helpers/classPrivateFieldSet2.js +++ /dev/null @@ -1,13 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.default = _classPrivateFieldSet2; -var _assertClassBrand = require("./assertClassBrand.js"); -function _classPrivateFieldSet2(privateMap, receiver, value) { - privateMap.set((0, _assertClassBrand.default)(privateMap, receiver), value); - return value; -} - -//# sourceMappingURL=classPrivateFieldSet2.js.map diff --git a/tools/eslint/node_modules/@babel/helpers/lib/helpers/classPrivateGetter.js b/tools/eslint/node_modules/@babel/helpers/lib/helpers/classPrivateGetter.js deleted file mode 100644 index ed413e0ee43bfa..00000000000000 --- a/tools/eslint/node_modules/@babel/helpers/lib/helpers/classPrivateGetter.js +++ /dev/null @@ -1,12 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.default = _classPrivateGetter; -var _assertClassBrand = require("./assertClassBrand.js"); -function _classPrivateGetter(privateMap, receiver, getter) { - return getter((0, _assertClassBrand.default)(privateMap, receiver)); -} - -//# sourceMappingURL=classPrivateGetter.js.map diff --git a/tools/eslint/node_modules/@babel/helpers/lib/helpers/classPrivateMethodGet.js b/tools/eslint/node_modules/@babel/helpers/lib/helpers/classPrivateMethodGet.js deleted file mode 100644 index a42ba7a97840e6..00000000000000 --- a/tools/eslint/node_modules/@babel/helpers/lib/helpers/classPrivateMethodGet.js +++ /dev/null @@ -1,13 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.default = _classPrivateMethodGet; -var _assertClassBrand = require("assertClassBrand"); -function _classPrivateMethodGet(receiver, privateSet, fn) { - _assertClassBrand(privateSet, receiver); - return fn; -} - -//# sourceMappingURL=classPrivateMethodGet.js.map diff --git a/tools/eslint/node_modules/@babel/helpers/lib/helpers/classPrivateMethodInitSpec.js b/tools/eslint/node_modules/@babel/helpers/lib/helpers/classPrivateMethodInitSpec.js deleted file mode 100644 index efc950294f746b..00000000000000 --- a/tools/eslint/node_modules/@babel/helpers/lib/helpers/classPrivateMethodInitSpec.js +++ /dev/null @@ -1,13 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.default = _classPrivateMethodInitSpec; -var _checkPrivateRedeclaration = require("./checkPrivateRedeclaration.js"); -function _classPrivateMethodInitSpec(obj, privateSet) { - (0, _checkPrivateRedeclaration.default)(obj, privateSet); - privateSet.add(obj); -} - -//# sourceMappingURL=classPrivateMethodInitSpec.js.map diff --git a/tools/eslint/node_modules/@babel/helpers/lib/helpers/classPrivateMethodSet.js b/tools/eslint/node_modules/@babel/helpers/lib/helpers/classPrivateMethodSet.js deleted file mode 100644 index 49490587323ddc..00000000000000 --- a/tools/eslint/node_modules/@babel/helpers/lib/helpers/classPrivateMethodSet.js +++ /dev/null @@ -1,11 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.default = _classPrivateMethodSet; -function _classPrivateMethodSet() { - throw new TypeError("attempted to reassign private method"); -} - -//# sourceMappingURL=classPrivateMethodSet.js.map diff --git a/tools/eslint/node_modules/@babel/helpers/lib/helpers/classPrivateSetter.js b/tools/eslint/node_modules/@babel/helpers/lib/helpers/classPrivateSetter.js deleted file mode 100644 index f02ce7a92eae23..00000000000000 --- a/tools/eslint/node_modules/@babel/helpers/lib/helpers/classPrivateSetter.js +++ /dev/null @@ -1,13 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.default = _classPrivateSetter; -var _assertClassBrand = require("./assertClassBrand.js"); -function _classPrivateSetter(privateMap, setter, receiver, value) { - setter((0, _assertClassBrand.default)(privateMap, receiver), value); - return value; -} - -//# sourceMappingURL=classPrivateSetter.js.map diff --git a/tools/eslint/node_modules/@babel/helpers/lib/helpers/classStaticPrivateFieldDestructureSet.js b/tools/eslint/node_modules/@babel/helpers/lib/helpers/classStaticPrivateFieldDestructureSet.js deleted file mode 100644 index 2a60646b717f03..00000000000000 --- a/tools/eslint/node_modules/@babel/helpers/lib/helpers/classStaticPrivateFieldDestructureSet.js +++ /dev/null @@ -1,16 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.default = _classStaticPrivateFieldDestructureSet; -var _classApplyDescriptorDestructureSet = require("classApplyDescriptorDestructureSet"); -var _assertClassBrand = require("assertClassBrand"); -var _classCheckPrivateStaticFieldDescriptor = require("classCheckPrivateStaticFieldDescriptor"); -function _classStaticPrivateFieldDestructureSet(receiver, classConstructor, descriptor) { - _assertClassBrand(classConstructor, receiver); - _classCheckPrivateStaticFieldDescriptor(descriptor, "set"); - return _classApplyDescriptorDestructureSet(receiver, descriptor); -} - -//# sourceMappingURL=classStaticPrivateFieldDestructureSet.js.map diff --git a/tools/eslint/node_modules/@babel/helpers/lib/helpers/classStaticPrivateFieldSpecGet.js b/tools/eslint/node_modules/@babel/helpers/lib/helpers/classStaticPrivateFieldSpecGet.js deleted file mode 100644 index 4e12ada10e462e..00000000000000 --- a/tools/eslint/node_modules/@babel/helpers/lib/helpers/classStaticPrivateFieldSpecGet.js +++ /dev/null @@ -1,16 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.default = _classStaticPrivateFieldSpecGet; -var _classApplyDescriptorGet = require("classApplyDescriptorGet"); -var _assertClassBrand = require("assertClassBrand"); -var _classCheckPrivateStaticFieldDescriptor = require("classCheckPrivateStaticFieldDescriptor"); -function _classStaticPrivateFieldSpecGet(receiver, classConstructor, descriptor) { - _assertClassBrand(classConstructor, receiver); - _classCheckPrivateStaticFieldDescriptor(descriptor, "get"); - return _classApplyDescriptorGet(receiver, descriptor); -} - -//# sourceMappingURL=classStaticPrivateFieldSpecGet.js.map diff --git a/tools/eslint/node_modules/@babel/helpers/lib/helpers/classStaticPrivateFieldSpecSet.js b/tools/eslint/node_modules/@babel/helpers/lib/helpers/classStaticPrivateFieldSpecSet.js deleted file mode 100644 index b0aa7944fcd1bf..00000000000000 --- a/tools/eslint/node_modules/@babel/helpers/lib/helpers/classStaticPrivateFieldSpecSet.js +++ /dev/null @@ -1,17 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.default = _classStaticPrivateFieldSpecSet; -var _classApplyDescriptorSet = require("classApplyDescriptorSet"); -var _assertClassBrand = require("assertClassBrand"); -var _classCheckPrivateStaticFieldDescriptor = require("classCheckPrivateStaticFieldDescriptor"); -function _classStaticPrivateFieldSpecSet(receiver, classConstructor, descriptor, value) { - _assertClassBrand(classConstructor, receiver); - _classCheckPrivateStaticFieldDescriptor(descriptor, "set"); - _classApplyDescriptorSet(receiver, descriptor, value); - return value; -} - -//# sourceMappingURL=classStaticPrivateFieldSpecSet.js.map diff --git a/tools/eslint/node_modules/@babel/helpers/lib/helpers/classStaticPrivateMethodGet.js b/tools/eslint/node_modules/@babel/helpers/lib/helpers/classStaticPrivateMethodGet.js deleted file mode 100644 index 21003ce6d4ccb7..00000000000000 --- a/tools/eslint/node_modules/@babel/helpers/lib/helpers/classStaticPrivateMethodGet.js +++ /dev/null @@ -1,13 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.default = _classStaticPrivateMethodGet; -var _assertClassBrand = require("./assertClassBrand.js"); -function _classStaticPrivateMethodGet(receiver, classConstructor, method) { - (0, _assertClassBrand.default)(classConstructor, receiver); - return method; -} - -//# sourceMappingURL=classStaticPrivateMethodGet.js.map diff --git a/tools/eslint/node_modules/@babel/helpers/lib/helpers/classStaticPrivateMethodSet.js b/tools/eslint/node_modules/@babel/helpers/lib/helpers/classStaticPrivateMethodSet.js deleted file mode 100644 index a983dfc7d093c0..00000000000000 --- a/tools/eslint/node_modules/@babel/helpers/lib/helpers/classStaticPrivateMethodSet.js +++ /dev/null @@ -1,11 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.default = _classStaticPrivateMethodSet; -function _classStaticPrivateMethodSet() { - throw new TypeError("attempted to set read only static private field"); -} - -//# sourceMappingURL=classStaticPrivateMethodSet.js.map diff --git a/tools/eslint/node_modules/@babel/helpers/lib/helpers/construct.js b/tools/eslint/node_modules/@babel/helpers/lib/helpers/construct.js deleted file mode 100644 index e32d400b7e2d49..00000000000000 --- a/tools/eslint/node_modules/@babel/helpers/lib/helpers/construct.js +++ /dev/null @@ -1,20 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.default = _construct; -var _isNativeReflectConstruct = require("./isNativeReflectConstruct.js"); -var _setPrototypeOf = require("./setPrototypeOf.js"); -function _construct(Parent, args, Class) { - if ((0, _isNativeReflectConstruct.default)()) { - return Reflect.construct.apply(null, arguments); - } - var a = [null]; - a.push.apply(a, args); - var instance = new (Parent.bind.apply(Parent, a))(); - if (Class) (0, _setPrototypeOf.default)(instance, Class.prototype); - return instance; -} - -//# sourceMappingURL=construct.js.map diff --git a/tools/eslint/node_modules/@babel/helpers/lib/helpers/createClass.js b/tools/eslint/node_modules/@babel/helpers/lib/helpers/createClass.js deleted file mode 100644 index c10839cd77166a..00000000000000 --- a/tools/eslint/node_modules/@babel/helpers/lib/helpers/createClass.js +++ /dev/null @@ -1,26 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.default = _createClass; -var _toPropertyKey = require("./toPropertyKey.js"); -function _defineProperties(target, props) { - for (var i = 0; i < props.length; i++) { - var descriptor = props[i]; - descriptor.enumerable = descriptor.enumerable || false; - descriptor.configurable = true; - if ("value" in descriptor) descriptor.writable = true; - Object.defineProperty(target, (0, _toPropertyKey.default)(descriptor.key), descriptor); - } -} -function _createClass(Constructor, protoProps, staticProps) { - if (protoProps) _defineProperties(Constructor.prototype, protoProps); - if (staticProps) _defineProperties(Constructor, staticProps); - Object.defineProperty(Constructor, "prototype", { - writable: false - }); - return Constructor; -} - -//# sourceMappingURL=createClass.js.map diff --git a/tools/eslint/node_modules/@babel/helpers/lib/helpers/createForOfIteratorHelper.js b/tools/eslint/node_modules/@babel/helpers/lib/helpers/createForOfIteratorHelper.js deleted file mode 100644 index e55f4bb559eaf7..00000000000000 --- a/tools/eslint/node_modules/@babel/helpers/lib/helpers/createForOfIteratorHelper.js +++ /dev/null @@ -1,64 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.default = _createForOfIteratorHelper; -var _unsupportedIterableToArray = require("./unsupportedIterableToArray.js"); -function _createForOfIteratorHelper(o, allowArrayLike) { - var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; - if (!it) { - if (Array.isArray(o) || (it = (0, _unsupportedIterableToArray.default)(o)) || allowArrayLike && o && typeof o.length === "number") { - if (it) o = it; - var i = 0; - var F = function () {}; - return { - s: F, - n: function () { - if (i >= o.length) { - return { - done: true - }; - } - return { - done: false, - value: o[i++] - }; - }, - e: function (e) { - throw e; - }, - f: F - }; - } - throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); - } - var normalCompletion = true, - didErr = false, - err; - return { - s: function () { - it = it.call(o); - }, - n: function () { - var step = it.next(); - normalCompletion = step.done; - return step; - }, - e: function (e) { - didErr = true; - err = e; - }, - f: function () { - try { - if (!normalCompletion && it.return != null) { - it.return(); - } - } finally { - if (didErr) throw err; - } - } - }; -} - -//# sourceMappingURL=createForOfIteratorHelper.js.map diff --git a/tools/eslint/node_modules/@babel/helpers/lib/helpers/createForOfIteratorHelperLoose.js b/tools/eslint/node_modules/@babel/helpers/lib/helpers/createForOfIteratorHelperLoose.js deleted file mode 100644 index 71b0d5056ceb66..00000000000000 --- a/tools/eslint/node_modules/@babel/helpers/lib/helpers/createForOfIteratorHelperLoose.js +++ /dev/null @@ -1,29 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.default = _createForOfIteratorHelperLoose; -var _unsupportedIterableToArray = require("./unsupportedIterableToArray.js"); -function _createForOfIteratorHelperLoose(o, allowArrayLike) { - var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; - if (it) return (it = it.call(o)).next.bind(it); - if (Array.isArray(o) || (it = (0, _unsupportedIterableToArray.default)(o)) || allowArrayLike && o && typeof o.length === "number") { - if (it) o = it; - var i = 0; - return function () { - if (i >= o.length) { - return { - done: true - }; - } - return { - done: false, - value: o[i++] - }; - }; - } - throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); -} - -//# sourceMappingURL=createForOfIteratorHelperLoose.js.map diff --git a/tools/eslint/node_modules/@babel/helpers/lib/helpers/createSuper.js b/tools/eslint/node_modules/@babel/helpers/lib/helpers/createSuper.js deleted file mode 100644 index 03b94bd22b3efa..00000000000000 --- a/tools/eslint/node_modules/@babel/helpers/lib/helpers/createSuper.js +++ /dev/null @@ -1,25 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.default = _createSuper; -var _getPrototypeOf = require("getPrototypeOf"); -var _isNativeReflectConstruct = require("isNativeReflectConstruct"); -var _possibleConstructorReturn = require("possibleConstructorReturn"); -function _createSuper(Derived) { - var hasNativeReflectConstruct = _isNativeReflectConstruct(); - return function _createSuperInternal() { - var Super = _getPrototypeOf(Derived), - result; - if (hasNativeReflectConstruct) { - var NewTarget = _getPrototypeOf(this).constructor; - result = Reflect.construct(Super, arguments, NewTarget); - } else { - result = Super.apply(this, arguments); - } - return _possibleConstructorReturn(this, result); - }; -} - -//# sourceMappingURL=createSuper.js.map diff --git a/tools/eslint/node_modules/@babel/helpers/lib/helpers/decorate.js b/tools/eslint/node_modules/@babel/helpers/lib/helpers/decorate.js deleted file mode 100644 index 63e0c41ab7d4cb..00000000000000 --- a/tools/eslint/node_modules/@babel/helpers/lib/helpers/decorate.js +++ /dev/null @@ -1,350 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.default = _decorate; -var _toArray = require("toArray"); -var _toPropertyKey = require("toPropertyKey"); -function _decorate(decorators, factory, superClass, mixins) { - var api = _getDecoratorsApi(); - if (mixins) { - for (var i = 0; i < mixins.length; i++) { - api = mixins[i](api); - } - } - var r = factory(function initialize(O) { - api.initializeInstanceElements(O, decorated.elements); - }, superClass); - var decorated = api.decorateClass(_coalesceClassElements(r.d.map(_createElementDescriptor)), decorators); - api.initializeClassElements(r.F, decorated.elements); - return api.runClassFinishers(r.F, decorated.finishers); -} -function _getDecoratorsApi() { - _getDecoratorsApi = function () { - return api; - }; - var api = { - elementsDefinitionOrder: [["method"], ["field"]], - initializeInstanceElements: function (O, elements) { - ["method", "field"].forEach(function (kind) { - elements.forEach(function (element) { - if (element.kind === kind && element.placement === "own") { - this.defineClassElement(O, element); - } - }, this); - }, this); - }, - initializeClassElements: function (F, elements) { - var proto = F.prototype; - ["method", "field"].forEach(function (kind) { - elements.forEach(function (element) { - var placement = element.placement; - if (element.kind === kind && (placement === "static" || placement === "prototype")) { - var receiver = placement === "static" ? F : proto; - this.defineClassElement(receiver, element); - } - }, this); - }, this); - }, - defineClassElement: function (receiver, element) { - var descriptor = element.descriptor; - if (element.kind === "field") { - var initializer = element.initializer; - descriptor = { - enumerable: descriptor.enumerable, - writable: descriptor.writable, - configurable: descriptor.configurable, - value: initializer === void 0 ? void 0 : initializer.call(receiver) - }; - } - Object.defineProperty(receiver, element.key, descriptor); - }, - decorateClass: function (elements, decorators) { - var newElements = []; - var finishers = []; - var placements = { - static: [], - prototype: [], - own: [] - }; - elements.forEach(function (element) { - this.addElementPlacement(element, placements); - }, this); - elements.forEach(function (element) { - if (!_hasDecorators(element)) return newElements.push(element); - var elementFinishersExtras = this.decorateElement(element, placements); - newElements.push(elementFinishersExtras.element); - newElements.push.apply(newElements, elementFinishersExtras.extras); - finishers.push.apply(finishers, elementFinishersExtras.finishers); - }, this); - if (!decorators) { - return { - elements: newElements, - finishers: finishers - }; - } - var result = this.decorateConstructor(newElements, decorators); - finishers.push.apply(finishers, result.finishers); - result.finishers = finishers; - return result; - }, - addElementPlacement: function (element, placements, silent) { - var keys = placements[element.placement]; - if (!silent && keys.indexOf(element.key) !== -1) { - throw new TypeError("Duplicated element (" + element.key + ")"); - } - keys.push(element.key); - }, - decorateElement: function (element, placements) { - var extras = []; - var finishers = []; - for (var decorators = element.decorators, i = decorators.length - 1; i >= 0; i--) { - var keys = placements[element.placement]; - keys.splice(keys.indexOf(element.key), 1); - var elementObject = this.fromElementDescriptor(element); - var elementFinisherExtras = this.toElementFinisherExtras((0, decorators[i])(elementObject) || elementObject); - element = elementFinisherExtras.element; - this.addElementPlacement(element, placements); - if (elementFinisherExtras.finisher) { - finishers.push(elementFinisherExtras.finisher); - } - var newExtras = elementFinisherExtras.extras; - if (newExtras) { - for (var j = 0; j < newExtras.length; j++) { - this.addElementPlacement(newExtras[j], placements); - } - extras.push.apply(extras, newExtras); - } - } - return { - element: element, - finishers: finishers, - extras: extras - }; - }, - decorateConstructor: function (elements, decorators) { - var finishers = []; - for (var i = decorators.length - 1; i >= 0; i--) { - var obj = this.fromClassDescriptor(elements); - var elementsAndFinisher = this.toClassDescriptor((0, decorators[i])(obj) || obj); - if (elementsAndFinisher.finisher !== undefined) { - finishers.push(elementsAndFinisher.finisher); - } - if (elementsAndFinisher.elements !== undefined) { - elements = elementsAndFinisher.elements; - for (var j = 0; j < elements.length - 1; j++) { - for (var k = j + 1; k < elements.length; k++) { - if (elements[j].key === elements[k].key && elements[j].placement === elements[k].placement) { - throw new TypeError("Duplicated element (" + elements[j].key + ")"); - } - } - } - } - } - return { - elements: elements, - finishers: finishers - }; - }, - fromElementDescriptor: function (element) { - var obj = { - kind: element.kind, - key: element.key, - placement: element.placement, - descriptor: element.descriptor - }; - var desc = { - value: "Descriptor", - configurable: true - }; - Object.defineProperty(obj, Symbol.toStringTag, desc); - if (element.kind === "field") obj.initializer = element.initializer; - return obj; - }, - toElementDescriptors: function (elementObjects) { - if (elementObjects === undefined) return; - return _toArray(elementObjects).map(function (elementObject) { - var element = this.toElementDescriptor(elementObject); - this.disallowProperty(elementObject, "finisher", "An element descriptor"); - this.disallowProperty(elementObject, "extras", "An element descriptor"); - return element; - }, this); - }, - toElementDescriptor: function (elementObject) { - var kind = String(elementObject.kind); - if (kind !== "method" && kind !== "field") { - throw new TypeError('An element descriptor\'s .kind property must be either "method" or' + ' "field", but a decorator created an element descriptor with' + ' .kind "' + kind + '"'); - } - var key = _toPropertyKey(elementObject.key); - var placement = String(elementObject.placement); - if (placement !== "static" && placement !== "prototype" && placement !== "own") { - throw new TypeError('An element descriptor\'s .placement property must be one of "static",' + ' "prototype" or "own", but a decorator created an element descriptor' + ' with .placement "' + placement + '"'); - } - var descriptor = elementObject.descriptor; - this.disallowProperty(elementObject, "elements", "An element descriptor"); - var element = { - kind: kind, - key: key, - placement: placement, - descriptor: Object.assign({}, descriptor) - }; - if (kind !== "field") { - this.disallowProperty(elementObject, "initializer", "A method descriptor"); - } else { - this.disallowProperty(descriptor, "get", "The property descriptor of a field descriptor"); - this.disallowProperty(descriptor, "set", "The property descriptor of a field descriptor"); - this.disallowProperty(descriptor, "value", "The property descriptor of a field descriptor"); - element.initializer = elementObject.initializer; - } - return element; - }, - toElementFinisherExtras: function (elementObject) { - var element = this.toElementDescriptor(elementObject); - var finisher = _optionalCallableProperty(elementObject, "finisher"); - var extras = this.toElementDescriptors(elementObject.extras); - return { - element: element, - finisher: finisher, - extras: extras - }; - }, - fromClassDescriptor: function (elements) { - var obj = { - kind: "class", - elements: elements.map(this.fromElementDescriptor, this) - }; - var desc = { - value: "Descriptor", - configurable: true - }; - Object.defineProperty(obj, Symbol.toStringTag, desc); - return obj; - }, - toClassDescriptor: function (obj) { - var kind = String(obj.kind); - if (kind !== "class") { - throw new TypeError('A class descriptor\'s .kind property must be "class", but a decorator' + ' created a class descriptor with .kind "' + kind + '"'); - } - this.disallowProperty(obj, "key", "A class descriptor"); - this.disallowProperty(obj, "placement", "A class descriptor"); - this.disallowProperty(obj, "descriptor", "A class descriptor"); - this.disallowProperty(obj, "initializer", "A class descriptor"); - this.disallowProperty(obj, "extras", "A class descriptor"); - var finisher = _optionalCallableProperty(obj, "finisher"); - var elements = this.toElementDescriptors(obj.elements); - return { - elements: elements, - finisher: finisher - }; - }, - runClassFinishers: function (constructor, finishers) { - for (var i = 0; i < finishers.length; i++) { - var newConstructor = (0, finishers[i])(constructor); - if (newConstructor !== undefined) { - if (typeof newConstructor !== "function") { - throw new TypeError("Finishers must return a constructor."); - } - constructor = newConstructor; - } - } - return constructor; - }, - disallowProperty: function (obj, name, objectType) { - if (obj[name] !== undefined) { - throw new TypeError(objectType + " can't have a ." + name + " property."); - } - } - }; - return api; -} -function _createElementDescriptor(def) { - var key = _toPropertyKey(def.key); - var descriptor; - if (def.kind === "method") { - descriptor = { - value: def.value, - writable: true, - configurable: true, - enumerable: false - }; - } else if (def.kind === "get") { - descriptor = { - get: def.value, - configurable: true, - enumerable: false - }; - } else if (def.kind === "set") { - descriptor = { - set: def.value, - configurable: true, - enumerable: false - }; - } else if (def.kind === "field") { - descriptor = { - configurable: true, - writable: true, - enumerable: true - }; - } - var element = { - kind: def.kind === "field" ? "field" : "method", - key: key, - placement: def.static ? "static" : def.kind === "field" ? "own" : "prototype", - descriptor: descriptor - }; - if (def.decorators) element.decorators = def.decorators; - if (def.kind === "field") element.initializer = def.value; - return element; -} -function _coalesceGetterSetter(element, other) { - if (element.descriptor.get !== undefined) { - other.descriptor.get = element.descriptor.get; - } else { - other.descriptor.set = element.descriptor.set; - } -} -function _coalesceClassElements(elements) { - var newElements = []; - var isSameElement = function (other) { - return other.kind === "method" && other.key === element.key && other.placement === element.placement; - }; - for (var i = 0; i < elements.length; i++) { - var element = elements[i]; - var other; - if (element.kind === "method" && (other = newElements.find(isSameElement))) { - if (_isDataDescriptor(element.descriptor) || _isDataDescriptor(other.descriptor)) { - if (_hasDecorators(element) || _hasDecorators(other)) { - throw new ReferenceError("Duplicated methods (" + element.key + ") can't be decorated."); - } - other.descriptor = element.descriptor; - } else { - if (_hasDecorators(element)) { - if (_hasDecorators(other)) { - throw new ReferenceError("Decorators can't be placed on different accessors with for " + "the same property (" + element.key + ")."); - } - other.decorators = element.decorators; - } - _coalesceGetterSetter(element, other); - } - } else { - newElements.push(element); - } - } - return newElements; -} -function _hasDecorators(element) { - return element.decorators && element.decorators.length; -} -function _isDataDescriptor(desc) { - return desc !== undefined && !(desc.value === undefined && desc.writable === undefined); -} -function _optionalCallableProperty(obj, name) { - var value = obj[name]; - if (value !== undefined && typeof value !== "function") { - throw new TypeError("Expected '" + name + "' to be a function"); - } - return value; -} - -//# sourceMappingURL=decorate.js.map diff --git a/tools/eslint/node_modules/@babel/helpers/lib/helpers/defaults.js b/tools/eslint/node_modules/@babel/helpers/lib/helpers/defaults.js deleted file mode 100644 index d0406560c4a7c6..00000000000000 --- a/tools/eslint/node_modules/@babel/helpers/lib/helpers/defaults.js +++ /dev/null @@ -1,18 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.default = _defaults; -function _defaults(obj, defaults) { - for (var keys = Object.getOwnPropertyNames(defaults), i = 0; i < keys.length; i++) { - var key = keys[i], - value = Object.getOwnPropertyDescriptor(defaults, key); - if (value && value.configurable && obj[key] === undefined) { - Object.defineProperty(obj, key, value); - } - } - return obj; -} - -//# sourceMappingURL=defaults.js.map diff --git a/tools/eslint/node_modules/@babel/helpers/lib/helpers/defineAccessor.js b/tools/eslint/node_modules/@babel/helpers/lib/helpers/defineAccessor.js deleted file mode 100644 index fc5f8bcdb6b11b..00000000000000 --- a/tools/eslint/node_modules/@babel/helpers/lib/helpers/defineAccessor.js +++ /dev/null @@ -1,16 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.default = _defineAccessor; -function _defineAccessor(type, obj, key, fn) { - var desc = { - configurable: true, - enumerable: true - }; - desc[type] = fn; - return Object.defineProperty(obj, key, desc); -} - -//# sourceMappingURL=defineAccessor.js.map diff --git a/tools/eslint/node_modules/@babel/helpers/lib/helpers/defineEnumerableProperties.js b/tools/eslint/node_modules/@babel/helpers/lib/helpers/defineEnumerableProperties.js deleted file mode 100644 index a497e1d20ccb16..00000000000000 --- a/tools/eslint/node_modules/@babel/helpers/lib/helpers/defineEnumerableProperties.js +++ /dev/null @@ -1,27 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.default = _defineEnumerableProperties; -function _defineEnumerableProperties(obj, descs) { - for (var key in descs) { - var desc = descs[key]; - desc.configurable = desc.enumerable = true; - if ("value" in desc) desc.writable = true; - Object.defineProperty(obj, key, desc); - } - if (Object.getOwnPropertySymbols) { - var objectSymbols = Object.getOwnPropertySymbols(descs); - for (var i = 0; i < objectSymbols.length; i++) { - var sym = objectSymbols[i]; - desc = descs[sym]; - desc.configurable = desc.enumerable = true; - if ("value" in desc) desc.writable = true; - Object.defineProperty(obj, sym, desc); - } - } - return obj; -} - -//# sourceMappingURL=defineEnumerableProperties.js.map diff --git a/tools/eslint/node_modules/@babel/helpers/lib/helpers/defineProperty.js b/tools/eslint/node_modules/@babel/helpers/lib/helpers/defineProperty.js deleted file mode 100644 index 989df3a438bbb0..00000000000000 --- a/tools/eslint/node_modules/@babel/helpers/lib/helpers/defineProperty.js +++ /dev/null @@ -1,23 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.default = _defineProperty; -var _toPropertyKey = require("./toPropertyKey.js"); -function _defineProperty(obj, key, value) { - key = (0, _toPropertyKey.default)(key); - if (key in obj) { - Object.defineProperty(obj, key, { - value: value, - enumerable: true, - configurable: true, - writable: true - }); - } else { - obj[key] = value; - } - return obj; -} - -//# sourceMappingURL=defineProperty.js.map diff --git a/tools/eslint/node_modules/@babel/helpers/lib/helpers/dispose.js b/tools/eslint/node_modules/@babel/helpers/lib/helpers/dispose.js deleted file mode 100644 index 3093b47df29de7..00000000000000 --- a/tools/eslint/node_modules/@babel/helpers/lib/helpers/dispose.js +++ /dev/null @@ -1,47 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.default = _dispose; -function dispose_SuppressedError(error, suppressed) { - if (typeof SuppressedError !== "undefined") { - dispose_SuppressedError = SuppressedError; - } else { - dispose_SuppressedError = function SuppressedError(error, suppressed) { - this.suppressed = suppressed; - this.error = error; - this.stack = new Error().stack; - }; - dispose_SuppressedError.prototype = Object.create(Error.prototype, { - constructor: { - value: dispose_SuppressedError, - writable: true, - configurable: true - } - }); - } - return new dispose_SuppressedError(error, suppressed); -} -function _dispose(stack, error, hasError) { - function next() { - while (stack.length > 0) { - try { - var r = stack.pop(); - var p = r.d.call(r.v); - if (r.a) return Promise.resolve(p).then(next, err); - } catch (e) { - return err(e); - } - } - if (hasError) throw error; - } - function err(e) { - error = hasError ? new dispose_SuppressedError(error, e) : e; - hasError = true; - return next(); - } - return next(); -} - -//# sourceMappingURL=dispose.js.map diff --git a/tools/eslint/node_modules/@babel/helpers/lib/helpers/extends.js b/tools/eslint/node_modules/@babel/helpers/lib/helpers/extends.js deleted file mode 100644 index bb9d07d4a18525..00000000000000 --- a/tools/eslint/node_modules/@babel/helpers/lib/helpers/extends.js +++ /dev/null @@ -1,22 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.default = _extends; -function _extends() { - exports.default = _extends = Object.assign ? Object.assign.bind() : function (target) { - for (var i = 1; i < arguments.length; i++) { - var source = arguments[i]; - for (var key in source) { - if (Object.prototype.hasOwnProperty.call(source, key)) { - target[key] = source[key]; - } - } - } - return target; - }; - return _extends.apply(null, arguments); -} - -//# sourceMappingURL=extends.js.map diff --git a/tools/eslint/node_modules/@babel/helpers/lib/helpers/get.js b/tools/eslint/node_modules/@babel/helpers/lib/helpers/get.js deleted file mode 100644 index a2d37966e7106c..00000000000000 --- a/tools/eslint/node_modules/@babel/helpers/lib/helpers/get.js +++ /dev/null @@ -1,25 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.default = _get; -var _superPropBase = require("./superPropBase.js"); -function _get() { - if (typeof Reflect !== "undefined" && Reflect.get) { - exports.default = _get = Reflect.get.bind(); - } else { - exports.default = _get = function _get(target, property, receiver) { - var base = (0, _superPropBase.default)(target, property); - if (!base) return; - var desc = Object.getOwnPropertyDescriptor(base, property); - if (desc.get) { - return desc.get.call(arguments.length < 3 ? target : receiver); - } - return desc.value; - }; - } - return _get.apply(null, arguments); -} - -//# sourceMappingURL=get.js.map diff --git a/tools/eslint/node_modules/@babel/helpers/lib/helpers/getPrototypeOf.js b/tools/eslint/node_modules/@babel/helpers/lib/helpers/getPrototypeOf.js deleted file mode 100644 index 6fc2df933fb3e3..00000000000000 --- a/tools/eslint/node_modules/@babel/helpers/lib/helpers/getPrototypeOf.js +++ /dev/null @@ -1,14 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.default = _getPrototypeOf; -function _getPrototypeOf(o) { - exports.default = _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { - return o.__proto__ || Object.getPrototypeOf(o); - }; - return _getPrototypeOf(o); -} - -//# sourceMappingURL=getPrototypeOf.js.map diff --git a/tools/eslint/node_modules/@babel/helpers/lib/helpers/identity.js b/tools/eslint/node_modules/@babel/helpers/lib/helpers/identity.js deleted file mode 100644 index 7a5f5f4ff2e1cd..00000000000000 --- a/tools/eslint/node_modules/@babel/helpers/lib/helpers/identity.js +++ /dev/null @@ -1,11 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.default = _identity; -function _identity(x) { - return x; -} - -//# sourceMappingURL=identity.js.map diff --git a/tools/eslint/node_modules/@babel/helpers/lib/helpers/importDeferProxy.js b/tools/eslint/node_modules/@babel/helpers/lib/helpers/importDeferProxy.js deleted file mode 100644 index 1529609ccad976..00000000000000 --- a/tools/eslint/node_modules/@babel/helpers/lib/helpers/importDeferProxy.js +++ /dev/null @@ -1,35 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.default = _importDeferProxy; -function _importDeferProxy(init) { - var ns = null; - var constValue = function (v) { - return function () { - return v; - }; - }; - var proxy = function (run) { - return function (_target, p, receiver) { - if (ns === null) ns = init(); - return run(ns, p, receiver); - }; - }; - return new Proxy({}, { - defineProperty: constValue(false), - deleteProperty: constValue(false), - get: proxy(Reflect.get), - getOwnPropertyDescriptor: proxy(Reflect.getOwnPropertyDescriptor), - getPrototypeOf: constValue(null), - isExtensible: constValue(false), - has: proxy(Reflect.has), - ownKeys: proxy(Reflect.ownKeys), - preventExtensions: constValue(true), - set: constValue(false), - setPrototypeOf: constValue(false) - }); -} - -//# sourceMappingURL=importDeferProxy.js.map diff --git a/tools/eslint/node_modules/@babel/helpers/lib/helpers/inherits.js b/tools/eslint/node_modules/@babel/helpers/lib/helpers/inherits.js deleted file mode 100644 index 6039a8e72508af..00000000000000 --- a/tools/eslint/node_modules/@babel/helpers/lib/helpers/inherits.js +++ /dev/null @@ -1,25 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.default = _inherits; -var _setPrototypeOf = require("./setPrototypeOf.js"); -function _inherits(subClass, superClass) { - if (typeof superClass !== "function" && superClass !== null) { - throw new TypeError("Super expression must either be null or a function"); - } - subClass.prototype = Object.create(superClass && superClass.prototype, { - constructor: { - value: subClass, - writable: true, - configurable: true - } - }); - Object.defineProperty(subClass, "prototype", { - writable: false - }); - if (superClass) (0, _setPrototypeOf.default)(subClass, superClass); -} - -//# sourceMappingURL=inherits.js.map diff --git a/tools/eslint/node_modules/@babel/helpers/lib/helpers/inheritsLoose.js b/tools/eslint/node_modules/@babel/helpers/lib/helpers/inheritsLoose.js deleted file mode 100644 index 0de50d70189e7e..00000000000000 --- a/tools/eslint/node_modules/@babel/helpers/lib/helpers/inheritsLoose.js +++ /dev/null @@ -1,14 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.default = _inheritsLoose; -var _setPrototypeOf = require("./setPrototypeOf.js"); -function _inheritsLoose(subClass, superClass) { - subClass.prototype = Object.create(superClass.prototype); - subClass.prototype.constructor = subClass; - (0, _setPrototypeOf.default)(subClass, superClass); -} - -//# sourceMappingURL=inheritsLoose.js.map diff --git a/tools/eslint/node_modules/@babel/helpers/lib/helpers/initializerDefineProperty.js b/tools/eslint/node_modules/@babel/helpers/lib/helpers/initializerDefineProperty.js deleted file mode 100644 index c0daf6d515abf3..00000000000000 --- a/tools/eslint/node_modules/@babel/helpers/lib/helpers/initializerDefineProperty.js +++ /dev/null @@ -1,17 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.default = _initializerDefineProperty; -function _initializerDefineProperty(target, property, descriptor, context) { - if (!descriptor) return; - Object.defineProperty(target, property, { - enumerable: descriptor.enumerable, - configurable: descriptor.configurable, - writable: descriptor.writable, - value: descriptor.initializer ? descriptor.initializer.call(context) : void 0 - }); -} - -//# sourceMappingURL=initializerDefineProperty.js.map diff --git a/tools/eslint/node_modules/@babel/helpers/lib/helpers/initializerWarningHelper.js b/tools/eslint/node_modules/@babel/helpers/lib/helpers/initializerWarningHelper.js deleted file mode 100644 index 4d8e5aad06c045..00000000000000 --- a/tools/eslint/node_modules/@babel/helpers/lib/helpers/initializerWarningHelper.js +++ /dev/null @@ -1,11 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.default = _initializerWarningHelper; -function _initializerWarningHelper(descriptor, context) { - throw new Error("Decorating class property failed. Please ensure that " + "transform-class-properties is enabled and runs after the decorators transform."); -} - -//# sourceMappingURL=initializerWarningHelper.js.map diff --git a/tools/eslint/node_modules/@babel/helpers/lib/helpers/instanceof.js b/tools/eslint/node_modules/@babel/helpers/lib/helpers/instanceof.js deleted file mode 100644 index ff8272da6a2fc1..00000000000000 --- a/tools/eslint/node_modules/@babel/helpers/lib/helpers/instanceof.js +++ /dev/null @@ -1,15 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.default = _instanceof; -function _instanceof(left, right) { - if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) { - return !!right[Symbol.hasInstance](left); - } else { - return left instanceof right; - } -} - -//# sourceMappingURL=instanceof.js.map diff --git a/tools/eslint/node_modules/@babel/helpers/lib/helpers/interopRequireDefault.js b/tools/eslint/node_modules/@babel/helpers/lib/helpers/interopRequireDefault.js deleted file mode 100644 index 8c2873d44a1dcb..00000000000000 --- a/tools/eslint/node_modules/@babel/helpers/lib/helpers/interopRequireDefault.js +++ /dev/null @@ -1,13 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.default = _interopRequireDefault; -function _interopRequireDefault(obj) { - return obj && obj.__esModule ? obj : { - default: obj - }; -} - -//# sourceMappingURL=interopRequireDefault.js.map diff --git a/tools/eslint/node_modules/@babel/helpers/lib/helpers/interopRequireWildcard.js b/tools/eslint/node_modules/@babel/helpers/lib/helpers/interopRequireWildcard.js deleted file mode 100644 index 6d3d60330cb9d5..00000000000000 --- a/tools/eslint/node_modules/@babel/helpers/lib/helpers/interopRequireWildcard.js +++ /dev/null @@ -1,49 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.default = _interopRequireWildcard; -function _getRequireWildcardCache(nodeInterop) { - if (typeof WeakMap !== "function") return null; - var cacheBabelInterop = new WeakMap(); - var cacheNodeInterop = new WeakMap(); - return (_getRequireWildcardCache = function (nodeInterop) { - return nodeInterop ? cacheNodeInterop : cacheBabelInterop; - })(nodeInterop); -} -function _interopRequireWildcard(obj, nodeInterop) { - if (!nodeInterop && obj && obj.__esModule) { - return obj; - } - if (obj === null || typeof obj !== "object" && typeof obj !== "function") { - return { - default: obj - }; - } - var cache = _getRequireWildcardCache(nodeInterop); - if (cache && cache.has(obj)) { - return cache.get(obj); - } - var newObj = { - __proto__: null - }; - var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; - for (var key in obj) { - if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { - var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; - if (desc && (desc.get || desc.set)) { - Object.defineProperty(newObj, key, desc); - } else { - newObj[key] = obj[key]; - } - } - } - newObj.default = obj; - if (cache) { - cache.set(obj, newObj); - } - return newObj; -} - -//# sourceMappingURL=interopRequireWildcard.js.map diff --git a/tools/eslint/node_modules/@babel/helpers/lib/helpers/isNativeFunction.js b/tools/eslint/node_modules/@babel/helpers/lib/helpers/isNativeFunction.js deleted file mode 100644 index 2d3c70ceada5ad..00000000000000 --- a/tools/eslint/node_modules/@babel/helpers/lib/helpers/isNativeFunction.js +++ /dev/null @@ -1,15 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.default = _isNativeFunction; -function _isNativeFunction(fn) { - try { - return Function.toString.call(fn).indexOf("[native code]") !== -1; - } catch (_e) { - return typeof fn === "function"; - } -} - -//# sourceMappingURL=isNativeFunction.js.map diff --git a/tools/eslint/node_modules/@babel/helpers/lib/helpers/isNativeReflectConstruct.js b/tools/eslint/node_modules/@babel/helpers/lib/helpers/isNativeReflectConstruct.js deleted file mode 100644 index dbf66cd5d22a99..00000000000000 --- a/tools/eslint/node_modules/@babel/helpers/lib/helpers/isNativeReflectConstruct.js +++ /dev/null @@ -1,16 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.default = _isNativeReflectConstruct; -function _isNativeReflectConstruct() { - try { - var result = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); - } catch (_) {} - return (exports.default = _isNativeReflectConstruct = function () { - return !!result; - })(); -} - -//# sourceMappingURL=isNativeReflectConstruct.js.map diff --git a/tools/eslint/node_modules/@babel/helpers/lib/helpers/iterableToArray.js b/tools/eslint/node_modules/@babel/helpers/lib/helpers/iterableToArray.js deleted file mode 100644 index 07ea96fe046e66..00000000000000 --- a/tools/eslint/node_modules/@babel/helpers/lib/helpers/iterableToArray.js +++ /dev/null @@ -1,13 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.default = _iterableToArray; -function _iterableToArray(iter) { - if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) { - return Array.from(iter); - } -} - -//# sourceMappingURL=iterableToArray.js.map diff --git a/tools/eslint/node_modules/@babel/helpers/lib/helpers/iterableToArrayLimit.js b/tools/eslint/node_modules/@babel/helpers/lib/helpers/iterableToArrayLimit.js deleted file mode 100644 index 9d351854c36866..00000000000000 --- a/tools/eslint/node_modules/@babel/helpers/lib/helpers/iterableToArrayLimit.js +++ /dev/null @@ -1,41 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.default = _iterableToArrayLimit; -function _iterableToArrayLimit(arr, i) { - var iterator = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; - if (iterator == null) return; - var _arr = []; - var iteratorNormalCompletion = true; - var didIteratorError = false; - var step, iteratorError, next, _return; - try { - next = (iterator = iterator.call(arr)).next; - if (i === 0) { - if (Object(iterator) !== iterator) return; - iteratorNormalCompletion = false; - } else { - for (; !(iteratorNormalCompletion = (step = next.call(iterator)).done); iteratorNormalCompletion = true) { - _arr.push(step.value); - if (_arr.length === i) break; - } - } - } catch (err) { - didIteratorError = true; - iteratorError = err; - } finally { - try { - if (!iteratorNormalCompletion && iterator["return"] != null) { - _return = iterator["return"](); - if (Object(_return) !== _return) return; - } - } finally { - if (didIteratorError) throw iteratorError; - } - } - return _arr; -} - -//# sourceMappingURL=iterableToArrayLimit.js.map diff --git a/tools/eslint/node_modules/@babel/helpers/lib/helpers/jsx.js b/tools/eslint/node_modules/@babel/helpers/lib/helpers/jsx.js deleted file mode 100644 index ca5a957d3d2078..00000000000000 --- a/tools/eslint/node_modules/@babel/helpers/lib/helpers/jsx.js +++ /dev/null @@ -1,47 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.default = _createRawReactElement; -var REACT_ELEMENT_TYPE; -function _createRawReactElement(type, props, key, children) { - if (!REACT_ELEMENT_TYPE) { - REACT_ELEMENT_TYPE = typeof Symbol === "function" && Symbol["for"] && Symbol["for"]("react.element") || 0xeac7; - } - var defaultProps = type && type.defaultProps; - var childrenLength = arguments.length - 3; - if (!props && childrenLength !== 0) { - props = { - children: void 0 - }; - } - if (childrenLength === 1) { - props.children = children; - } else if (childrenLength > 1) { - var childArray = new Array(childrenLength); - for (var i = 0; i < childrenLength; i++) { - childArray[i] = arguments[i + 3]; - } - props.children = childArray; - } - if (props && defaultProps) { - for (var propName in defaultProps) { - if (props[propName] === void 0) { - props[propName] = defaultProps[propName]; - } - } - } else if (!props) { - props = defaultProps || {}; - } - return { - $$typeof: REACT_ELEMENT_TYPE, - type: type, - key: key === undefined ? null : "" + key, - ref: null, - props: props, - _owner: null - }; -} - -//# sourceMappingURL=jsx.js.map diff --git a/tools/eslint/node_modules/@babel/helpers/lib/helpers/maybeArrayLike.js b/tools/eslint/node_modules/@babel/helpers/lib/helpers/maybeArrayLike.js deleted file mode 100644 index 572bbb0d40ae91..00000000000000 --- a/tools/eslint/node_modules/@babel/helpers/lib/helpers/maybeArrayLike.js +++ /dev/null @@ -1,16 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.default = _maybeArrayLike; -var _arrayLikeToArray = require("./arrayLikeToArray.js"); -function _maybeArrayLike(orElse, arr, i) { - if (arr && !Array.isArray(arr) && typeof arr.length === "number") { - var len = arr.length; - return (0, _arrayLikeToArray.default)(arr, i !== void 0 && i < len ? i : len); - } - return orElse(arr, i); -} - -//# sourceMappingURL=maybeArrayLike.js.map diff --git a/tools/eslint/node_modules/@babel/helpers/lib/helpers/newArrowCheck.js b/tools/eslint/node_modules/@babel/helpers/lib/helpers/newArrowCheck.js deleted file mode 100644 index d750092f78a939..00000000000000 --- a/tools/eslint/node_modules/@babel/helpers/lib/helpers/newArrowCheck.js +++ /dev/null @@ -1,13 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.default = _newArrowCheck; -function _newArrowCheck(innerThis, boundThis) { - if (innerThis !== boundThis) { - throw new TypeError("Cannot instantiate an arrow function"); - } -} - -//# sourceMappingURL=newArrowCheck.js.map diff --git a/tools/eslint/node_modules/@babel/helpers/lib/helpers/nonIterableRest.js b/tools/eslint/node_modules/@babel/helpers/lib/helpers/nonIterableRest.js deleted file mode 100644 index 391972fd9ec09a..00000000000000 --- a/tools/eslint/node_modules/@babel/helpers/lib/helpers/nonIterableRest.js +++ /dev/null @@ -1,11 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.default = _nonIterableRest; -function _nonIterableRest() { - throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); -} - -//# sourceMappingURL=nonIterableRest.js.map diff --git a/tools/eslint/node_modules/@babel/helpers/lib/helpers/nonIterableSpread.js b/tools/eslint/node_modules/@babel/helpers/lib/helpers/nonIterableSpread.js deleted file mode 100644 index 6a8bc3f5ab35db..00000000000000 --- a/tools/eslint/node_modules/@babel/helpers/lib/helpers/nonIterableSpread.js +++ /dev/null @@ -1,11 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.default = _nonIterableSpread; -function _nonIterableSpread() { - throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); -} - -//# sourceMappingURL=nonIterableSpread.js.map diff --git a/tools/eslint/node_modules/@babel/helpers/lib/helpers/nullishReceiverError.js b/tools/eslint/node_modules/@babel/helpers/lib/helpers/nullishReceiverError.js deleted file mode 100644 index 741d3528805aa6..00000000000000 --- a/tools/eslint/node_modules/@babel/helpers/lib/helpers/nullishReceiverError.js +++ /dev/null @@ -1,11 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.default = _nullishReceiverError; -function _nullishReceiverError(r) { - throw new TypeError("Cannot set property of null or undefined."); -} - -//# sourceMappingURL=nullishReceiverError.js.map diff --git a/tools/eslint/node_modules/@babel/helpers/lib/helpers/objectDestructuringEmpty.js b/tools/eslint/node_modules/@babel/helpers/lib/helpers/objectDestructuringEmpty.js deleted file mode 100644 index 30a045a58f04bc..00000000000000 --- a/tools/eslint/node_modules/@babel/helpers/lib/helpers/objectDestructuringEmpty.js +++ /dev/null @@ -1,11 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.default = _objectDestructuringEmpty; -function _objectDestructuringEmpty(obj) { - if (obj == null) throw new TypeError("Cannot destructure " + obj); -} - -//# sourceMappingURL=objectDestructuringEmpty.js.map diff --git a/tools/eslint/node_modules/@babel/helpers/lib/helpers/objectSpread.js b/tools/eslint/node_modules/@babel/helpers/lib/helpers/objectSpread.js deleted file mode 100644 index e65ac316691f53..00000000000000 --- a/tools/eslint/node_modules/@babel/helpers/lib/helpers/objectSpread.js +++ /dev/null @@ -1,24 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.default = _objectSpread; -var _defineProperty = require("./defineProperty.js"); -function _objectSpread(target) { - for (var i = 1; i < arguments.length; i++) { - var source = arguments[i] != null ? Object(arguments[i]) : {}; - var ownKeys = Object.keys(source); - if (typeof Object.getOwnPropertySymbols === "function") { - ownKeys.push.apply(ownKeys, Object.getOwnPropertySymbols(source).filter(function (sym) { - return Object.getOwnPropertyDescriptor(source, sym).enumerable; - })); - } - ownKeys.forEach(function (key) { - (0, _defineProperty.default)(target, key, source[key]); - }); - } - return target; -} - -//# sourceMappingURL=objectSpread.js.map diff --git a/tools/eslint/node_modules/@babel/helpers/lib/helpers/objectSpread2.js b/tools/eslint/node_modules/@babel/helpers/lib/helpers/objectSpread2.js deleted file mode 100644 index be4e56a778488f..00000000000000 --- a/tools/eslint/node_modules/@babel/helpers/lib/helpers/objectSpread2.js +++ /dev/null @@ -1,39 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.default = _objectSpread2; -var _defineProperty = require("./defineProperty.js"); -function ownKeys(object, enumerableOnly) { - var keys = Object.keys(object); - if (Object.getOwnPropertySymbols) { - var symbols = Object.getOwnPropertySymbols(object); - if (enumerableOnly) { - symbols = symbols.filter(function (sym) { - return Object.getOwnPropertyDescriptor(object, sym).enumerable; - }); - } - keys.push.apply(keys, symbols); - } - return keys; -} -function _objectSpread2(target) { - for (var i = 1; i < arguments.length; i++) { - var source = arguments[i] != null ? arguments[i] : {}; - if (i % 2) { - ownKeys(Object(source), true).forEach(function (key) { - (0, _defineProperty.default)(target, key, source[key]); - }); - } else if (Object.getOwnPropertyDescriptors) { - Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); - } else { - ownKeys(Object(source)).forEach(function (key) { - Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); - }); - } - } - return target; -} - -//# sourceMappingURL=objectSpread2.js.map diff --git a/tools/eslint/node_modules/@babel/helpers/lib/helpers/objectWithoutProperties.js b/tools/eslint/node_modules/@babel/helpers/lib/helpers/objectWithoutProperties.js deleted file mode 100644 index 08e198e05bcd31..00000000000000 --- a/tools/eslint/node_modules/@babel/helpers/lib/helpers/objectWithoutProperties.js +++ /dev/null @@ -1,24 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.default = _objectWithoutProperties; -var _objectWithoutPropertiesLoose = require("./objectWithoutPropertiesLoose.js"); -function _objectWithoutProperties(source, excluded) { - if (source == null) return {}; - var target = (0, _objectWithoutPropertiesLoose.default)(source, excluded); - var key, i; - if (Object.getOwnPropertySymbols) { - var sourceSymbolKeys = Object.getOwnPropertySymbols(source); - for (i = 0; i < sourceSymbolKeys.length; i++) { - key = sourceSymbolKeys[i]; - if (excluded.includes(key)) continue; - if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; - target[key] = source[key]; - } - } - return target; -} - -//# sourceMappingURL=objectWithoutProperties.js.map diff --git a/tools/eslint/node_modules/@babel/helpers/lib/helpers/objectWithoutPropertiesLoose.js b/tools/eslint/node_modules/@babel/helpers/lib/helpers/objectWithoutPropertiesLoose.js deleted file mode 100644 index ef42b7943e2f3e..00000000000000 --- a/tools/eslint/node_modules/@babel/helpers/lib/helpers/objectWithoutPropertiesLoose.js +++ /dev/null @@ -1,19 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.default = _objectWithoutPropertiesLoose; -function _objectWithoutPropertiesLoose(source, excluded) { - if (source == null) return {}; - var target = {}; - for (var key in source) { - if (Object.prototype.hasOwnProperty.call(source, key)) { - if (excluded.includes(key)) continue; - target[key] = source[key]; - } - } - return target; -} - -//# sourceMappingURL=objectWithoutPropertiesLoose.js.map diff --git a/tools/eslint/node_modules/@babel/helpers/lib/helpers/possibleConstructorReturn.js b/tools/eslint/node_modules/@babel/helpers/lib/helpers/possibleConstructorReturn.js deleted file mode 100644 index 6350d0699808c4..00000000000000 --- a/tools/eslint/node_modules/@babel/helpers/lib/helpers/possibleConstructorReturn.js +++ /dev/null @@ -1,17 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.default = _possibleConstructorReturn; -var _assertThisInitialized = require("./assertThisInitialized.js"); -function _possibleConstructorReturn(self, value) { - if (value && (typeof value === "object" || typeof value === "function")) { - return value; - } else if (value !== void 0) { - throw new TypeError("Derived constructors may only return object or undefined"); - } - return (0, _assertThisInitialized.default)(self); -} - -//# sourceMappingURL=possibleConstructorReturn.js.map diff --git a/tools/eslint/node_modules/@babel/helpers/lib/helpers/readOnlyError.js b/tools/eslint/node_modules/@babel/helpers/lib/helpers/readOnlyError.js deleted file mode 100644 index e96906f0327fea..00000000000000 --- a/tools/eslint/node_modules/@babel/helpers/lib/helpers/readOnlyError.js +++ /dev/null @@ -1,11 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.default = _readOnlyError; -function _readOnlyError(name) { - throw new TypeError('"' + name + '" is read-only'); -} - -//# sourceMappingURL=readOnlyError.js.map diff --git a/tools/eslint/node_modules/@babel/helpers/lib/helpers/regeneratorRuntime.js b/tools/eslint/node_modules/@babel/helpers/lib/helpers/regeneratorRuntime.js deleted file mode 100644 index cdb477368fe517..00000000000000 --- a/tools/eslint/node_modules/@babel/helpers/lib/helpers/regeneratorRuntime.js +++ /dev/null @@ -1,499 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.default = _regeneratorRuntime; -function _regeneratorRuntime() { - "use strict"; - exports.default = _regeneratorRuntime = function () { - return _exports; - }; - var _exports = {}; - var Op = Object.prototype; - var hasOwn = Op.hasOwnProperty; - var defineProperty = Object.defineProperty || function (obj, key, desc) { - obj[key] = desc.value; - }; - var undefined; - var $Symbol = typeof Symbol === "function" ? Symbol : {}; - var iteratorSymbol = $Symbol.iterator || "@@iterator"; - var asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator"; - var toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag"; - function define(obj, key, value) { - Object.defineProperty(obj, key, { - value: value, - enumerable: true, - configurable: true, - writable: true - }); - return obj[key]; - } - try { - define({}, ""); - } catch (err) { - define = function (obj, key, value) { - return obj[key] = value; - }; - } - function wrap(innerFn, outerFn, self, tryLocsList) { - var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator; - var generator = Object.create(protoGenerator.prototype); - var context = new Context(tryLocsList || []); - defineProperty(generator, "_invoke", { - value: makeInvokeMethod(innerFn, self, context) - }); - return generator; - } - _exports.wrap = wrap; - function tryCatch(fn, obj, arg) { - try { - return { - type: "normal", - arg: fn.call(obj, arg) - }; - } catch (err) { - return { - type: "throw", - arg: err - }; - } - } - var GenStateSuspendedStart = "suspendedStart"; - var GenStateSuspendedYield = "suspendedYield"; - var GenStateExecuting = "executing"; - var GenStateCompleted = "completed"; - var ContinueSentinel = {}; - function Generator() {} - function GeneratorFunction() {} - function GeneratorFunctionPrototype() {} - var IteratorPrototype = {}; - define(IteratorPrototype, iteratorSymbol, function () { - return this; - }); - var getProto = Object.getPrototypeOf; - var NativeIteratorPrototype = getProto && getProto(getProto(values([]))); - if (NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol)) { - IteratorPrototype = NativeIteratorPrototype; - } - var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype); - GeneratorFunction.prototype = GeneratorFunctionPrototype; - defineProperty(Gp, "constructor", { - value: GeneratorFunctionPrototype, - configurable: true - }); - defineProperty(GeneratorFunctionPrototype, "constructor", { - value: GeneratorFunction, - configurable: true - }); - GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"); - function defineIteratorMethods(prototype) { - ["next", "throw", "return"].forEach(function (method) { - define(prototype, method, function (arg) { - return this._invoke(method, arg); - }); - }); - } - _exports.isGeneratorFunction = function (genFun) { - var ctor = typeof genFun === "function" && genFun.constructor; - return ctor ? ctor === GeneratorFunction || (ctor.displayName || ctor.name) === "GeneratorFunction" : false; - }; - _exports.mark = function (genFun) { - if (Object.setPrototypeOf) { - Object.setPrototypeOf(genFun, GeneratorFunctionPrototype); - } else { - genFun.__proto__ = GeneratorFunctionPrototype; - define(genFun, toStringTagSymbol, "GeneratorFunction"); - } - genFun.prototype = Object.create(Gp); - return genFun; - }; - _exports.awrap = function (arg) { - return { - __await: arg - }; - }; - function AsyncIterator(generator, PromiseImpl) { - function invoke(method, arg, resolve, reject) { - var record = tryCatch(generator[method], generator, arg); - if (record.type === "throw") { - reject(record.arg); - } else { - var result = record.arg; - var value = result.value; - if (value && typeof value === "object" && hasOwn.call(value, "__await")) { - return PromiseImpl.resolve(value.__await).then(function (value) { - invoke("next", value, resolve, reject); - }, function (err) { - invoke("throw", err, resolve, reject); - }); - } - return PromiseImpl.resolve(value).then(function (unwrapped) { - result.value = unwrapped; - resolve(result); - }, function (error) { - return invoke("throw", error, resolve, reject); - }); - } - } - var previousPromise; - function enqueue(method, arg) { - function callInvokeWithMethodAndArg() { - return new PromiseImpl(function (resolve, reject) { - invoke(method, arg, resolve, reject); - }); - } - return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); - } - defineProperty(this, "_invoke", { - value: enqueue - }); - } - defineIteratorMethods(AsyncIterator.prototype); - define(AsyncIterator.prototype, asyncIteratorSymbol, function () { - return this; - }); - _exports.AsyncIterator = AsyncIterator; - _exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) { - if (PromiseImpl === void 0) PromiseImpl = Promise; - var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl); - return _exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) { - return result.done ? result.value : iter.next(); - }); - }; - function makeInvokeMethod(innerFn, self, context) { - var state = GenStateSuspendedStart; - return function invoke(method, arg) { - if (state === GenStateExecuting) { - throw new Error("Generator is already running"); - } - if (state === GenStateCompleted) { - if (method === "throw") { - throw arg; - } - return doneResult(); - } - context.method = method; - context.arg = arg; - while (true) { - var delegate = context.delegate; - if (delegate) { - var delegateResult = maybeInvokeDelegate(delegate, context); - if (delegateResult) { - if (delegateResult === ContinueSentinel) continue; - return delegateResult; - } - } - if (context.method === "next") { - context.sent = context._sent = context.arg; - } else if (context.method === "throw") { - if (state === GenStateSuspendedStart) { - state = GenStateCompleted; - throw context.arg; - } - context.dispatchException(context.arg); - } else if (context.method === "return") { - context.abrupt("return", context.arg); - } - state = GenStateExecuting; - var record = tryCatch(innerFn, self, context); - if (record.type === "normal") { - state = context.done ? GenStateCompleted : GenStateSuspendedYield; - if (record.arg === ContinueSentinel) { - continue; - } - return { - value: record.arg, - done: context.done - }; - } else if (record.type === "throw") { - state = GenStateCompleted; - context.method = "throw"; - context.arg = record.arg; - } - } - }; - } - function maybeInvokeDelegate(delegate, context) { - var methodName = context.method; - var method = delegate.iterator[methodName]; - if (method === undefined) { - context.delegate = null; - if (methodName === "throw" && delegate.iterator["return"]) { - context.method = "return"; - context.arg = undefined; - maybeInvokeDelegate(delegate, context); - if (context.method === "throw") { - return ContinueSentinel; - } - } - if (methodName !== "return") { - context.method = "throw"; - context.arg = new TypeError("The iterator does not provide a '" + methodName + "' method"); - } - return ContinueSentinel; - } - var record = tryCatch(method, delegate.iterator, context.arg); - if (record.type === "throw") { - context.method = "throw"; - context.arg = record.arg; - context.delegate = null; - return ContinueSentinel; - } - var info = record.arg; - if (!info) { - context.method = "throw"; - context.arg = new TypeError("iterator result is not an object"); - context.delegate = null; - return ContinueSentinel; - } - if (info.done) { - context[delegate.resultName] = info.value; - context.next = delegate.nextLoc; - if (context.method !== "return") { - context.method = "next"; - context.arg = undefined; - } - } else { - return info; - } - context.delegate = null; - return ContinueSentinel; - } - defineIteratorMethods(Gp); - define(Gp, toStringTagSymbol, "Generator"); - define(Gp, iteratorSymbol, function () { - return this; - }); - define(Gp, "toString", function () { - return "[object Generator]"; - }); - function pushTryEntry(locs) { - var entry = { - tryLoc: locs[0] - }; - if (1 in locs) { - entry.catchLoc = locs[1]; - } - if (2 in locs) { - entry.finallyLoc = locs[2]; - entry.afterLoc = locs[3]; - } - this.tryEntries.push(entry); - } - function resetTryEntry(entry) { - var record = entry.completion || {}; - record.type = "normal"; - delete record.arg; - entry.completion = record; - } - function Context(tryLocsList) { - this.tryEntries = [{ - tryLoc: "root" - }]; - tryLocsList.forEach(pushTryEntry, this); - this.reset(true); - } - _exports.keys = function (val) { - var object = Object(val); - var keys = []; - for (var key in object) { - keys.push(key); - } - keys.reverse(); - return function next() { - while (keys.length) { - var key = keys.pop(); - if (key in object) { - next.value = key; - next.done = false; - return next; - } - } - next.done = true; - return next; - }; - }; - function values(iterable) { - if (iterable || iterable === "") { - var iteratorMethod = iterable[iteratorSymbol]; - if (iteratorMethod) { - return iteratorMethod.call(iterable); - } - if (typeof iterable.next === "function") { - return iterable; - } - if (!isNaN(iterable.length)) { - var i = -1, - next = function next() { - while (++i < iterable.length) { - if (hasOwn.call(iterable, i)) { - next.value = iterable[i]; - next.done = false; - return next; - } - } - next.value = undefined; - next.done = true; - return next; - }; - return next.next = next; - } - } - throw new TypeError(typeof iterable + " is not iterable"); - } - _exports.values = values; - function doneResult() { - return { - value: undefined, - done: true - }; - } - Context.prototype = { - constructor: Context, - reset: function (skipTempReset) { - this.prev = 0; - this.next = 0; - this.sent = this._sent = undefined; - this.done = false; - this.delegate = null; - this.method = "next"; - this.arg = undefined; - this.tryEntries.forEach(resetTryEntry); - if (!skipTempReset) { - for (var name in this) { - if (name.charAt(0) === "t" && hasOwn.call(this, name) && !isNaN(+name.slice(1))) { - this[name] = undefined; - } - } - } - }, - stop: function () { - this.done = true; - var rootEntry = this.tryEntries[0]; - var rootRecord = rootEntry.completion; - if (rootRecord.type === "throw") { - throw rootRecord.arg; - } - return this.rval; - }, - dispatchException: function (exception) { - if (this.done) { - throw exception; - } - var context = this; - function handle(loc, caught) { - record.type = "throw"; - record.arg = exception; - context.next = loc; - if (caught) { - context.method = "next"; - context.arg = undefined; - } - return !!caught; - } - for (var i = this.tryEntries.length - 1; i >= 0; --i) { - var entry = this.tryEntries[i]; - var record = entry.completion; - if (entry.tryLoc === "root") { - return handle("end"); - } - if (entry.tryLoc <= this.prev) { - var hasCatch = hasOwn.call(entry, "catchLoc"); - var hasFinally = hasOwn.call(entry, "finallyLoc"); - if (hasCatch && hasFinally) { - if (this.prev < entry.catchLoc) { - return handle(entry.catchLoc, true); - } else if (this.prev < entry.finallyLoc) { - return handle(entry.finallyLoc); - } - } else if (hasCatch) { - if (this.prev < entry.catchLoc) { - return handle(entry.catchLoc, true); - } - } else if (hasFinally) { - if (this.prev < entry.finallyLoc) { - return handle(entry.finallyLoc); - } - } else { - throw new Error("try statement without catch or finally"); - } - } - } - }, - abrupt: function (type, arg) { - for (var i = this.tryEntries.length - 1; i >= 0; --i) { - var entry = this.tryEntries[i]; - if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) { - var finallyEntry = entry; - break; - } - } - if (finallyEntry && (type === "break" || type === "continue") && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc) { - finallyEntry = null; - } - var record = finallyEntry ? finallyEntry.completion : {}; - record.type = type; - record.arg = arg; - if (finallyEntry) { - this.method = "next"; - this.next = finallyEntry.finallyLoc; - return ContinueSentinel; - } - return this.complete(record); - }, - complete: function (record, afterLoc) { - if (record.type === "throw") { - throw record.arg; - } - if (record.type === "break" || record.type === "continue") { - this.next = record.arg; - } else if (record.type === "return") { - this.rval = this.arg = record.arg; - this.method = "return"; - this.next = "end"; - } else if (record.type === "normal" && afterLoc) { - this.next = afterLoc; - } - return ContinueSentinel; - }, - finish: function (finallyLoc) { - for (var i = this.tryEntries.length - 1; i >= 0; --i) { - var entry = this.tryEntries[i]; - if (entry.finallyLoc === finallyLoc) { - this.complete(entry.completion, entry.afterLoc); - resetTryEntry(entry); - return ContinueSentinel; - } - } - }, - catch: function (tryLoc) { - for (var i = this.tryEntries.length - 1; i >= 0; --i) { - var entry = this.tryEntries[i]; - if (entry.tryLoc === tryLoc) { - var record = entry.completion; - if (record.type === "throw") { - var thrown = record.arg; - resetTryEntry(entry); - } - return thrown; - } - } - throw new Error("illegal catch attempt"); - }, - delegateYield: function (iterable, resultName, nextLoc) { - this.delegate = { - iterator: values(iterable), - resultName: resultName, - nextLoc: nextLoc - }; - if (this.method === "next") { - this.arg = undefined; - } - return ContinueSentinel; - } - }; - return _exports; -} - -//# sourceMappingURL=regeneratorRuntime.js.map diff --git a/tools/eslint/node_modules/@babel/helpers/lib/helpers/set.js b/tools/eslint/node_modules/@babel/helpers/lib/helpers/set.js deleted file mode 100644 index 3cc8d6dcea4a8c..00000000000000 --- a/tools/eslint/node_modules/@babel/helpers/lib/helpers/set.js +++ /dev/null @@ -1,48 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.default = _set; -var _superPropBase = require("./superPropBase.js"); -var _defineProperty = require("./defineProperty.js"); -function set(target, property, value, receiver) { - if (typeof Reflect !== "undefined" && Reflect.set) { - set = Reflect.set; - } else { - set = function set(target, property, value, receiver) { - var base = (0, _superPropBase.default)(target, property); - var desc; - if (base) { - desc = Object.getOwnPropertyDescriptor(base, property); - if (desc.set) { - desc.set.call(receiver, value); - return true; - } else if (!desc.writable) { - return false; - } - } - desc = Object.getOwnPropertyDescriptor(receiver, property); - if (desc) { - if (!desc.writable) { - return false; - } - desc.value = value; - Object.defineProperty(receiver, property, desc); - } else { - (0, _defineProperty.default)(receiver, property, value); - } - return true; - }; - } - return set(target, property, value, receiver); -} -function _set(target, property, value, receiver, isStrict) { - var s = set(target, property, value, receiver || target); - if (!s && isStrict) { - throw new TypeError("failed to set property"); - } - return value; -} - -//# sourceMappingURL=set.js.map diff --git a/tools/eslint/node_modules/@babel/helpers/lib/helpers/setFunctionName.js b/tools/eslint/node_modules/@babel/helpers/lib/helpers/setFunctionName.js deleted file mode 100644 index f711baf14aecc8..00000000000000 --- a/tools/eslint/node_modules/@babel/helpers/lib/helpers/setFunctionName.js +++ /dev/null @@ -1,21 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.default = setFunctionName; -function setFunctionName(fn, name, prefix) { - if (typeof name === "symbol") { - name = name.description; - name = name ? "[" + name + "]" : ""; - } - try { - Object.defineProperty(fn, "name", { - configurable: true, - value: prefix ? prefix + " " + name : name - }); - } catch (_) {} - return fn; -} - -//# sourceMappingURL=setFunctionName.js.map diff --git a/tools/eslint/node_modules/@babel/helpers/lib/helpers/setPrototypeOf.js b/tools/eslint/node_modules/@babel/helpers/lib/helpers/setPrototypeOf.js deleted file mode 100644 index 359c5cca0ff559..00000000000000 --- a/tools/eslint/node_modules/@babel/helpers/lib/helpers/setPrototypeOf.js +++ /dev/null @@ -1,15 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.default = _setPrototypeOf; -function _setPrototypeOf(o, p) { - exports.default = _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { - o.__proto__ = p; - return o; - }; - return _setPrototypeOf(o, p); -} - -//# sourceMappingURL=setPrototypeOf.js.map diff --git a/tools/eslint/node_modules/@babel/helpers/lib/helpers/skipFirstGeneratorNext.js b/tools/eslint/node_modules/@babel/helpers/lib/helpers/skipFirstGeneratorNext.js deleted file mode 100644 index a72ba920d844ea..00000000000000 --- a/tools/eslint/node_modules/@babel/helpers/lib/helpers/skipFirstGeneratorNext.js +++ /dev/null @@ -1,15 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.default = _skipFirstGeneratorNext; -function _skipFirstGeneratorNext(fn) { - return function () { - var it = fn.apply(this, arguments); - it.next(); - return it; - }; -} - -//# sourceMappingURL=skipFirstGeneratorNext.js.map diff --git a/tools/eslint/node_modules/@babel/helpers/lib/helpers/slicedToArray.js b/tools/eslint/node_modules/@babel/helpers/lib/helpers/slicedToArray.js deleted file mode 100644 index a56f68d6b9c5ef..00000000000000 --- a/tools/eslint/node_modules/@babel/helpers/lib/helpers/slicedToArray.js +++ /dev/null @@ -1,15 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.default = _slicedToArray; -var _arrayWithHoles = require("./arrayWithHoles.js"); -var _iterableToArrayLimit = require("./iterableToArrayLimit.js"); -var _unsupportedIterableToArray = require("./unsupportedIterableToArray.js"); -var _nonIterableRest = require("./nonIterableRest.js"); -function _slicedToArray(arr, i) { - return (0, _arrayWithHoles.default)(arr) || (0, _iterableToArrayLimit.default)(arr, i) || (0, _unsupportedIterableToArray.default)(arr, i) || (0, _nonIterableRest.default)(); -} - -//# sourceMappingURL=slicedToArray.js.map diff --git a/tools/eslint/node_modules/@babel/helpers/lib/helpers/superPropBase.js b/tools/eslint/node_modules/@babel/helpers/lib/helpers/superPropBase.js deleted file mode 100644 index 0763ce1524a69a..00000000000000 --- a/tools/eslint/node_modules/@babel/helpers/lib/helpers/superPropBase.js +++ /dev/null @@ -1,16 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.default = _superPropBase; -var _getPrototypeOf = require("./getPrototypeOf.js"); -function _superPropBase(object, property) { - while (!Object.prototype.hasOwnProperty.call(object, property)) { - object = (0, _getPrototypeOf.default)(object); - if (object === null) break; - } - return object; -} - -//# sourceMappingURL=superPropBase.js.map diff --git a/tools/eslint/node_modules/@babel/helpers/lib/helpers/taggedTemplateLiteral.js b/tools/eslint/node_modules/@babel/helpers/lib/helpers/taggedTemplateLiteral.js deleted file mode 100644 index c68ece6924ed79..00000000000000 --- a/tools/eslint/node_modules/@babel/helpers/lib/helpers/taggedTemplateLiteral.js +++ /dev/null @@ -1,18 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.default = _taggedTemplateLiteral; -function _taggedTemplateLiteral(strings, raw) { - if (!raw) { - raw = strings.slice(0); - } - return Object.freeze(Object.defineProperties(strings, { - raw: { - value: Object.freeze(raw) - } - })); -} - -//# sourceMappingURL=taggedTemplateLiteral.js.map diff --git a/tools/eslint/node_modules/@babel/helpers/lib/helpers/taggedTemplateLiteralLoose.js b/tools/eslint/node_modules/@babel/helpers/lib/helpers/taggedTemplateLiteralLoose.js deleted file mode 100644 index 42416c6f10bd73..00000000000000 --- a/tools/eslint/node_modules/@babel/helpers/lib/helpers/taggedTemplateLiteralLoose.js +++ /dev/null @@ -1,15 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.default = _taggedTemplateLiteralLoose; -function _taggedTemplateLiteralLoose(strings, raw) { - if (!raw) { - raw = strings.slice(0); - } - strings.raw = raw; - return strings; -} - -//# sourceMappingURL=taggedTemplateLiteralLoose.js.map diff --git a/tools/eslint/node_modules/@babel/helpers/lib/helpers/tdz.js b/tools/eslint/node_modules/@babel/helpers/lib/helpers/tdz.js deleted file mode 100644 index 1d371b1bc436f0..00000000000000 --- a/tools/eslint/node_modules/@babel/helpers/lib/helpers/tdz.js +++ /dev/null @@ -1,11 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.default = _tdzError; -function _tdzError(name) { - throw new ReferenceError(name + " is not defined - temporal dead zone"); -} - -//# sourceMappingURL=tdz.js.map diff --git a/tools/eslint/node_modules/@babel/helpers/lib/helpers/temporalRef.js b/tools/eslint/node_modules/@babel/helpers/lib/helpers/temporalRef.js deleted file mode 100644 index 431b9af8a37604..00000000000000 --- a/tools/eslint/node_modules/@babel/helpers/lib/helpers/temporalRef.js +++ /dev/null @@ -1,13 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.default = _temporalRef; -var _temporalUndefined = require("./temporalUndefined.js"); -var _tdz = require("./tdz.js"); -function _temporalRef(val, name) { - return val === _temporalUndefined.default ? (0, _tdz.default)(name) : val; -} - -//# sourceMappingURL=temporalRef.js.map diff --git a/tools/eslint/node_modules/@babel/helpers/lib/helpers/temporalUndefined.js b/tools/eslint/node_modules/@babel/helpers/lib/helpers/temporalUndefined.js deleted file mode 100644 index e826773581f1ca..00000000000000 --- a/tools/eslint/node_modules/@babel/helpers/lib/helpers/temporalUndefined.js +++ /dev/null @@ -1,9 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.default = _temporalUndefined; -function _temporalUndefined() {} - -//# sourceMappingURL=temporalUndefined.js.map diff --git a/tools/eslint/node_modules/@babel/helpers/lib/helpers/toArray.js b/tools/eslint/node_modules/@babel/helpers/lib/helpers/toArray.js deleted file mode 100644 index d6ffd85eddd58d..00000000000000 --- a/tools/eslint/node_modules/@babel/helpers/lib/helpers/toArray.js +++ /dev/null @@ -1,15 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.default = _toArray; -var _arrayWithHoles = require("./arrayWithHoles.js"); -var _iterableToArray = require("./iterableToArray.js"); -var _unsupportedIterableToArray = require("./unsupportedIterableToArray.js"); -var _nonIterableRest = require("./nonIterableRest.js"); -function _toArray(arr) { - return (0, _arrayWithHoles.default)(arr) || (0, _iterableToArray.default)(arr) || (0, _unsupportedIterableToArray.default)(arr) || (0, _nonIterableRest.default)(); -} - -//# sourceMappingURL=toArray.js.map diff --git a/tools/eslint/node_modules/@babel/helpers/lib/helpers/toConsumableArray.js b/tools/eslint/node_modules/@babel/helpers/lib/helpers/toConsumableArray.js deleted file mode 100644 index 97734be95d984b..00000000000000 --- a/tools/eslint/node_modules/@babel/helpers/lib/helpers/toConsumableArray.js +++ /dev/null @@ -1,15 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.default = _toConsumableArray; -var _arrayWithoutHoles = require("./arrayWithoutHoles.js"); -var _iterableToArray = require("./iterableToArray.js"); -var _unsupportedIterableToArray = require("./unsupportedIterableToArray.js"); -var _nonIterableSpread = require("./nonIterableSpread.js"); -function _toConsumableArray(arr) { - return (0, _arrayWithoutHoles.default)(arr) || (0, _iterableToArray.default)(arr) || (0, _unsupportedIterableToArray.default)(arr) || (0, _nonIterableSpread.default)(); -} - -//# sourceMappingURL=toConsumableArray.js.map diff --git a/tools/eslint/node_modules/@babel/helpers/lib/helpers/toPrimitive.js b/tools/eslint/node_modules/@babel/helpers/lib/helpers/toPrimitive.js deleted file mode 100644 index f56a3abf509624..00000000000000 --- a/tools/eslint/node_modules/@babel/helpers/lib/helpers/toPrimitive.js +++ /dev/null @@ -1,18 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.default = toPrimitive; -function toPrimitive(input, hint) { - if (typeof input !== "object" || !input) return input; - var prim = input[Symbol.toPrimitive]; - if (prim !== undefined) { - var res = prim.call(input, hint || "default"); - if (typeof res !== "object") return res; - throw new TypeError("@@toPrimitive must return a primitive value."); - } - return (hint === "string" ? String : Number)(input); -} - -//# sourceMappingURL=toPrimitive.js.map diff --git a/tools/eslint/node_modules/@babel/helpers/lib/helpers/toPropertyKey.js b/tools/eslint/node_modules/@babel/helpers/lib/helpers/toPropertyKey.js deleted file mode 100644 index 92493ff174c3b2..00000000000000 --- a/tools/eslint/node_modules/@babel/helpers/lib/helpers/toPropertyKey.js +++ /dev/null @@ -1,13 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.default = toPropertyKey; -var _toPrimitive = require("./toPrimitive.js"); -function toPropertyKey(arg) { - var key = (0, _toPrimitive.default)(arg, "string"); - return typeof key === "symbol" ? key : String(key); -} - -//# sourceMappingURL=toPropertyKey.js.map diff --git a/tools/eslint/node_modules/@babel/helpers/lib/helpers/toSetter.js b/tools/eslint/node_modules/@babel/helpers/lib/helpers/toSetter.js deleted file mode 100644 index e18e7cda871248..00000000000000 --- a/tools/eslint/node_modules/@babel/helpers/lib/helpers/toSetter.js +++ /dev/null @@ -1,18 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.default = _toSetter; -function _toSetter(fn, args, thisArg) { - if (!args) args = []; - var l = args.length++; - return Object.defineProperty({}, "_", { - set: function (v) { - args[l] = v; - fn.apply(thisArg, args); - } - }); -} - -//# sourceMappingURL=toSetter.js.map diff --git a/tools/eslint/node_modules/@babel/helpers/lib/helpers/typeof.js b/tools/eslint/node_modules/@babel/helpers/lib/helpers/typeof.js deleted file mode 100644 index 2d066d248dc037..00000000000000 --- a/tools/eslint/node_modules/@babel/helpers/lib/helpers/typeof.js +++ /dev/null @@ -1,22 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.default = _typeof; -function _typeof(obj) { - "@babel/helpers - typeof"; - - if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { - exports.default = _typeof = function (obj) { - return typeof obj; - }; - } else { - exports.default = _typeof = function (obj) { - return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; - }; - } - return _typeof(obj); -} - -//# sourceMappingURL=typeof.js.map diff --git a/tools/eslint/node_modules/@babel/helpers/lib/helpers/unsupportedIterableToArray.js b/tools/eslint/node_modules/@babel/helpers/lib/helpers/unsupportedIterableToArray.js deleted file mode 100644 index f23883a00ad428..00000000000000 --- a/tools/eslint/node_modules/@babel/helpers/lib/helpers/unsupportedIterableToArray.js +++ /dev/null @@ -1,19 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.default = _unsupportedIterableToArray; -var _arrayLikeToArray = require("./arrayLikeToArray.js"); -function _unsupportedIterableToArray(o, minLen) { - if (!o) return; - if (typeof o === "string") return (0, _arrayLikeToArray.default)(o, minLen); - var name = Object.prototype.toString.call(o).slice(8, -1); - if (name === "Object" && o.constructor) name = o.constructor.name; - if (name === "Map" || name === "Set") return Array.from(o); - if (name === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(name)) { - return (0, _arrayLikeToArray.default)(o, minLen); - } -} - -//# sourceMappingURL=unsupportedIterableToArray.js.map diff --git a/tools/eslint/node_modules/@babel/helpers/lib/helpers/using.js b/tools/eslint/node_modules/@babel/helpers/lib/helpers/using.js deleted file mode 100644 index b98a85d9a9dd9a..00000000000000 --- a/tools/eslint/node_modules/@babel/helpers/lib/helpers/using.js +++ /dev/null @@ -1,29 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.default = _using; -function _using(stack, value, isAwait) { - if (value === null || value === void 0) return value; - if (Object(value) !== value) { - throw new TypeError("using declarations can only be used with objects, functions, null, or undefined."); - } - if (isAwait) { - var dispose = value[Symbol.asyncDispose || Symbol.for("Symbol.asyncDispose")]; - } - if (dispose === null || dispose === void 0) { - dispose = value[Symbol.dispose || Symbol.for("Symbol.dispose")]; - } - if (typeof dispose !== "function") { - throw new TypeError(`Property [Symbol.dispose] is not a function.`); - } - stack.push({ - v: value, - d: dispose, - a: isAwait - }); - return value; -} - -//# sourceMappingURL=using.js.map diff --git a/tools/eslint/node_modules/@babel/helpers/lib/helpers/usingCtx.js b/tools/eslint/node_modules/@babel/helpers/lib/helpers/usingCtx.js deleted file mode 100644 index b5265394d846e0..00000000000000 --- a/tools/eslint/node_modules/@babel/helpers/lib/helpers/usingCtx.js +++ /dev/null @@ -1,73 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.default = _usingCtx; -function _usingCtx() { - var _disposeSuppressedError = typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed) { - var err = new Error(); - err.name = "SuppressedError"; - err.error = error; - err.suppressed = suppressed; - return err; - }, - empty = {}, - stack = []; - function using(isAwait, value) { - if (value != null) { - if (Object(value) !== value) { - throw new TypeError("using declarations can only be used with objects, functions, null, or undefined."); - } - if (isAwait) { - var dispose = value[Symbol.asyncDispose || Symbol.for("Symbol.asyncDispose")]; - } - if (dispose == null) { - dispose = value[Symbol.dispose || Symbol.for("Symbol.dispose")]; - } - if (typeof dispose !== "function") { - throw new TypeError(`Property [Symbol.dispose] is not a function.`); - } - stack.push({ - v: value, - d: dispose, - a: isAwait - }); - } else if (isAwait) { - stack.push({ - d: value, - a: isAwait - }); - } - return value; - } - return { - e: empty, - u: using.bind(null, false), - a: using.bind(null, true), - d: function () { - var error = this.e; - function next() { - while (resource = stack.pop()) { - try { - var resource, - disposalResult = resource.d && resource.d.call(resource.v); - if (resource.a) { - return Promise.resolve(disposalResult).then(next, err); - } - } catch (e) { - return err(e); - } - } - if (error !== empty) throw error; - } - function err(e) { - error = error !== empty ? new _disposeSuppressedError(e, error) : e; - return next(); - } - return next(); - } - }; -} - -//# sourceMappingURL=usingCtx.js.map diff --git a/tools/eslint/node_modules/@babel/helpers/lib/helpers/wrapAsyncGenerator.js b/tools/eslint/node_modules/@babel/helpers/lib/helpers/wrapAsyncGenerator.js deleted file mode 100644 index 398486c887b642..00000000000000 --- a/tools/eslint/node_modules/@babel/helpers/lib/helpers/wrapAsyncGenerator.js +++ /dev/null @@ -1,97 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.default = _wrapAsyncGenerator; -var _OverloadYield = require("./OverloadYield.js"); -function _wrapAsyncGenerator(fn) { - return function () { - return new AsyncGenerator(fn.apply(this, arguments)); - }; -} -function AsyncGenerator(gen) { - var front, back; - function send(key, arg) { - return new Promise(function (resolve, reject) { - var request = { - key: key, - arg: arg, - resolve: resolve, - reject: reject, - next: null - }; - if (back) { - back = back.next = request; - } else { - front = back = request; - resume(key, arg); - } - }); - } - function resume(key, arg) { - try { - var result = gen[key](arg); - var value = result.value; - var overloaded = value instanceof _OverloadYield.default; - 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); - }); - } catch (err) { - settle("throw", err); - } - } - function settle(type, value) { - switch (type) { - case "return": - front.resolve({ - value: value, - done: true - }); - break; - case "throw": - front.reject(value); - break; - default: - front.resolve({ - value: value, - done: false - }); - 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); -}; - -//# sourceMappingURL=wrapAsyncGenerator.js.map diff --git a/tools/eslint/node_modules/@babel/helpers/lib/helpers/wrapNativeSuper.js b/tools/eslint/node_modules/@babel/helpers/lib/helpers/wrapNativeSuper.js deleted file mode 100644 index cc944e9eeaba02..00000000000000 --- a/tools/eslint/node_modules/@babel/helpers/lib/helpers/wrapNativeSuper.js +++ /dev/null @@ -1,38 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.default = _wrapNativeSuper; -var _getPrototypeOf = require("./getPrototypeOf.js"); -var _setPrototypeOf = require("./setPrototypeOf.js"); -var _isNativeFunction = require("./isNativeFunction.js"); -var _construct = require("./construct.js"); -function _wrapNativeSuper(Class) { - var _cache = typeof Map === "function" ? new Map() : undefined; - exports.default = _wrapNativeSuper = function _wrapNativeSuper(Class) { - if (Class === null || !(0, _isNativeFunction.default)(Class)) return Class; - if (typeof Class !== "function") { - throw new TypeError("Super expression must either be null or a function"); - } - if (typeof _cache !== "undefined") { - if (_cache.has(Class)) return _cache.get(Class); - _cache.set(Class, Wrapper); - } - function Wrapper() { - return (0, _construct.default)(Class, arguments, (0, _getPrototypeOf.default)(this).constructor); - } - Wrapper.prototype = Object.create(Class.prototype, { - constructor: { - value: Wrapper, - enumerable: false, - writable: true, - configurable: true - } - }); - return (0, _setPrototypeOf.default)(Wrapper, Class); - }; - return _wrapNativeSuper(Class); -} - -//# sourceMappingURL=wrapNativeSuper.js.map diff --git a/tools/eslint/node_modules/@babel/helpers/lib/helpers/wrapRegExp.js b/tools/eslint/node_modules/@babel/helpers/lib/helpers/wrapRegExp.js deleted file mode 100644 index df20584a8e1821..00000000000000 --- a/tools/eslint/node_modules/@babel/helpers/lib/helpers/wrapRegExp.js +++ /dev/null @@ -1,68 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.default = _wrapRegExp; -var _setPrototypeOf = require("./setPrototypeOf.js"); -var _inherits = require("./inherits.js"); -function _wrapRegExp() { - exports.default = _wrapRegExp = function (re, groups) { - return new BabelRegExp(re, undefined, groups); - }; - var _super = RegExp.prototype; - var _groups = new WeakMap(); - function BabelRegExp(re, flags, groups) { - var _this = new RegExp(re, flags); - _groups.set(_this, groups || _groups.get(re)); - return (0, _setPrototypeOf.default)(_this, BabelRegExp.prototype); - } - (0, _inherits.default)(BabelRegExp, RegExp); - BabelRegExp.prototype.exec = function (str) { - var result = _super.exec.call(this, str); - if (result) { - result.groups = buildGroups(result, this); - var indices = result.indices; - if (indices) indices.groups = buildGroups(indices, this); - } - return result; - }; - BabelRegExp.prototype[Symbol.replace] = function (str, substitution) { - if (typeof substitution === "string") { - var groups = _groups.get(this); - return _super[Symbol.replace].call(this, str, substitution.replace(/\$<([^>]+)>/g, function (_, name) { - var group = groups[name]; - return "$" + (Array.isArray(group) ? group.join("$") : group); - })); - } else if (typeof substitution === "function") { - var _this = this; - return _super[Symbol.replace].call(this, str, function () { - var args = arguments; - if (typeof args[args.length - 1] !== "object") { - args = [].slice.call(args); - args.push(buildGroups(args, _this)); - } - return substitution.apply(this, args); - }); - } else { - return _super[Symbol.replace].call(this, str, substitution); - } - }; - function buildGroups(result, re) { - var g = _groups.get(re); - return Object.keys(g).reduce(function (groups, name) { - var i = g[name]; - if (typeof i === "number") groups[name] = result[i];else { - var k = 0; - while (result[i[k]] === undefined && k + 1 < i.length) { - k++; - } - groups[name] = result[i[k]]; - } - return groups; - }, Object.create(null)); - } - return _wrapRegExp.apply(this, arguments); -} - -//# sourceMappingURL=wrapRegExp.js.map diff --git a/tools/eslint/node_modules/@babel/helpers/lib/helpers/writeOnlyError.js b/tools/eslint/node_modules/@babel/helpers/lib/helpers/writeOnlyError.js deleted file mode 100644 index d7e5248384d71a..00000000000000 --- a/tools/eslint/node_modules/@babel/helpers/lib/helpers/writeOnlyError.js +++ /dev/null @@ -1,11 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.default = _writeOnlyError; -function _writeOnlyError(name) { - throw new TypeError('"' + name + '" is write-only'); -} - -//# sourceMappingURL=writeOnlyError.js.map diff --git a/tools/eslint/node_modules/@babel/helpers/lib/index.js b/tools/eslint/node_modules/@babel/helpers/lib/index.js deleted file mode 100644 index 224d7905216afb..00000000000000 --- a/tools/eslint/node_modules/@babel/helpers/lib/index.js +++ /dev/null @@ -1,121 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.default = void 0; -exports.get = get; -exports.getDependencies = getDependencies; -exports.list = void 0; -exports.minVersion = minVersion; -var _t = require("@babel/types"); -var _helpersGenerated = require("./helpers-generated.js"); -const { - cloneNode, - identifier -} = _t; -function deep(obj, path, value) { - try { - const parts = path.split("."); - let last = parts.shift(); - while (parts.length > 0) { - obj = obj[last]; - last = parts.shift(); - } - if (arguments.length > 2) { - obj[last] = value; - } else { - return obj[last]; - } - } catch (e) { - e.message += ` (when accessing ${path})`; - throw e; - } -} -function permuteHelperAST(ast, metadata, bindingName, localBindings, getDependency, adjustAst) { - const { - locals, - dependencies, - exportBindingAssignments, - exportName - } = metadata; - const bindings = new Set(localBindings || []); - if (bindingName) bindings.add(bindingName); - for (const [name, paths] of (Object.entries || (o => Object.keys(o).map(k => [k, o[k]])))(locals)) { - let newName = name; - if (bindingName && name === exportName) { - newName = bindingName; - } else { - while (bindings.has(newName)) newName = "_" + newName; - } - if (newName !== name) { - for (const path of paths) { - deep(ast, path, identifier(newName)); - } - } - } - for (const [name, paths] of (Object.entries || (o => Object.keys(o).map(k => [k, o[k]])))(dependencies)) { - const ref = typeof getDependency === "function" && getDependency(name) || identifier(name); - for (const path of paths) { - deep(ast, path, cloneNode(ref)); - } - } - adjustAst == null || adjustAst(ast, exportName, map => { - exportBindingAssignments.forEach(p => deep(ast, p, map(deep(ast, p)))); - }); -} -const helperData = Object.create(null); -function loadHelper(name) { - if (!helperData[name]) { - const helper = _helpersGenerated.default[name]; - if (!helper) { - throw Object.assign(new ReferenceError(`Unknown helper ${name}`), { - code: "BABEL_HELPER_UNKNOWN", - helper: name - }); - } - helperData[name] = { - minVersion: helper.minVersion, - build(getDependency, bindingName, localBindings, adjustAst) { - const ast = helper.ast(); - permuteHelperAST(ast, helper.metadata, bindingName, localBindings, getDependency, adjustAst); - return { - nodes: ast.body, - globals: helper.metadata.globals - }; - }, - getDependencies() { - return Object.keys(helper.metadata.dependencies); - } - }; - } - return helperData[name]; -} -function get(name, getDependency, bindingName, localBindings, adjustAst) { - { - if (typeof bindingName === "object") { - const id = bindingName; - if ((id == null ? void 0 : id.type) === "Identifier") { - bindingName = id.name; - } else { - bindingName = undefined; - } - } - } - return loadHelper(name).build(getDependency, bindingName, localBindings, adjustAst); -} -function minVersion(name) { - return loadHelper(name).minVersion; -} -function getDependencies(name) { - return loadHelper(name).getDependencies(); -} -{ - exports.ensure = name => { - loadHelper(name); - }; -} -const list = exports.list = Object.keys(_helpersGenerated.default).map(name => name.replace(/^_/, "")); -var _default = exports.default = get; - -//# sourceMappingURL=index.js.map diff --git a/tools/eslint/node_modules/@babel/helpers/package.json b/tools/eslint/node_modules/@babel/helpers/package.json deleted file mode 100644 index df6f70c20bc747..00000000000000 --- a/tools/eslint/node_modules/@babel/helpers/package.json +++ /dev/null @@ -1,31 +0,0 @@ -{ - "name": "@babel/helpers", - "version": "7.24.8", - "description": "Collection of helper functions used by Babel transforms.", - "author": "The Babel Team (https://babel.dev/team)", - "homepage": "https://babel.dev/docs/en/next/babel-helpers", - "license": "MIT", - "publishConfig": { - "access": "public" - }, - "repository": { - "type": "git", - "url": "https://github.com/babel/babel.git", - "directory": "packages/babel-helpers" - }, - "main": "./lib/index.js", - "dependencies": { - "@babel/template": "^7.24.7", - "@babel/types": "^7.24.8" - }, - "devDependencies": { - "@babel/generator": "^7.24.8", - "@babel/helper-plugin-test-runner": "^7.24.7", - "@babel/parser": "^7.24.8", - "regenerator-runtime": "^0.14.0" - }, - "engines": { - "node": ">=6.9.0" - }, - "type": "commonjs" -} \ No newline at end of file diff --git a/tools/eslint/node_modules/@babel/helpers/scripts/build-helper-metadata.js b/tools/eslint/node_modules/@babel/helpers/scripts/build-helper-metadata.js deleted file mode 100644 index 6a54fa0e961a33..00000000000000 --- a/tools/eslint/node_modules/@babel/helpers/scripts/build-helper-metadata.js +++ /dev/null @@ -1,209 +0,0 @@ -// NOTE: This file must be compatible with old Node.js versions, since it runs -// during testing. - -/** - * @typedef {Object} HelperMetadata - * @property {string[]} globals - * @property {{ [name: string]: string[] }} locals - * @property {{ [name: string]: string[] }} dependencies - * @property {string[]} exportBindingAssignments - * @property {string} exportName - */ - -/** - * Given a file AST for a given helper, get a bunch of metadata about it so that Babel can quickly render - * the helper is whatever context it is needed in. - * - * @param {typeof import("@babel/core")} babel - * - * @returns {HelperMetadata} - */ -export function getHelperMetadata(babel, code, helperName) { - const globals = new Set(); - // Maps imported identifier name -> helper name - const dependenciesBindings = new Map(); - - let exportName; - const exportBindingAssignments = []; - // helper name -> reference paths - const dependencies = new Map(); - // local variable name -> reference paths - const locals = new Map(); - - const spansToRemove = []; - - const validateDefaultExport = decl => { - if (exportName) { - throw new Error( - `Helpers can have only one default export (in ${helperName})` - ); - } - - if (!decl.isFunctionDeclaration() || !decl.node.id) { - throw new Error( - `Helpers can only export named function declarations (in ${helperName})` - ); - } - }; - - /** @type {import("@babel/traverse").Visitor} */ - const dependencyVisitor = { - Program(path) { - for (const child of path.get("body")) { - if (child.isImportDeclaration()) { - if ( - child.get("specifiers").length !== 1 || - !child.get("specifiers.0").isImportDefaultSpecifier() - ) { - throw new Error( - `Helpers can only import a default value (in ${helperName})` - ); - } - dependenciesBindings.set( - child.node.specifiers[0].local.name, - child.node.source.value - ); - dependencies.set(child.node.source.value, []); - spansToRemove.push([child.node.start, child.node.end]); - child.remove(); - } - } - for (const child of path.get("body")) { - if (child.isExportDefaultDeclaration()) { - const decl = child.get("declaration"); - validateDefaultExport(decl); - - exportName = decl.node.id.name; - spansToRemove.push([child.node.start, decl.node.start]); - child.replaceWith(decl.node); - } else if ( - child.isExportNamedDeclaration() && - child.node.specifiers.length === 1 && - child.get("specifiers.0.exported").isIdentifier({ name: "default" }) - ) { - const { name } = child.node.specifiers[0].local; - - validateDefaultExport(child.scope.getBinding(name).path); - - exportName = name; - spansToRemove.push([child.node.start, child.node.end]); - child.remove(); - } else if ( - process.env.IS_BABEL_OLD_E2E && - child.isExportNamedDeclaration() && - child.node.specifiers.length === 0 - ) { - spansToRemove.push([child.node.start, child.node.end]); - child.remove(); - } else if ( - child.isExportAllDeclaration() || - child.isExportNamedDeclaration() - ) { - throw new Error(`Helpers can only export default (in ${helperName})`); - } - } - - path.scope.crawl(); - - const bindings = path.scope.getAllBindings(); - Object.keys(bindings).forEach(name => { - if (dependencies.has(name)) return; - - const binding = bindings[name]; - - const references = [ - ...binding.path.getBindingIdentifierPaths(true)[name].map(makePath), - ...binding.referencePaths.map(makePath), - ]; - for (const violation of binding.constantViolations) { - violation.getBindingIdentifierPaths(true)[name].forEach(path => { - references.push(makePath(path)); - }); - } - - locals.set(name, references); - }); - }, - ReferencedIdentifier(child) { - const name = child.node.name; - const binding = child.scope.getBinding(name); - if (!binding) { - if (dependenciesBindings.has(name)) { - dependencies - .get(dependenciesBindings.get(name)) - .push(makePath(child)); - } else if (name !== "arguments" || child.scope.path.isProgram()) { - globals.add(name); - } - } - }, - AssignmentExpression(child) { - const left = child.get("left"); - - if (!(exportName in left.getBindingIdentifiers())) return; - - if (!left.isIdentifier()) { - throw new Error( - `Only simple assignments to exports are allowed in helpers (in ${helperName})` - ); - } - - const binding = child.scope.getBinding(exportName); - - if (binding && binding.scope.path.isProgram()) { - exportBindingAssignments.push(makePath(child)); - } - }, - }; - - babel.transformSync(code, { - configFile: false, - babelrc: false, - plugins: [() => ({ visitor: dependencyVisitor })], - }); - - if (!exportName) throw new Error("Helpers must have a named default export."); - - // Process these in reverse so that mutating the references does not invalidate any later paths in - // the list. - exportBindingAssignments.reverse(); - - spansToRemove.sort(([start1], [start2]) => start2 - start1); - for (const [start, end] of spansToRemove) { - code = code.slice(0, start) + code.slice(end); - } - - return [ - code, - { - globals: Array.from(globals), - locals: Object.fromEntries(locals), - dependencies: Object.fromEntries(dependencies), - exportBindingAssignments, - exportName, - }, - ]; -} - -function makePath(path) { - const parts = []; - - for (; path.parentPath; path = path.parentPath) { - parts.push(path.key); - if (path.inList) parts.push(path.listKey); - } - - return parts.reverse().join("."); -} - -export function stringifyMetadata(metadata) { - return `\ - { - globals: ${JSON.stringify(metadata.globals)}, - locals: ${JSON.stringify(metadata.locals)}, - exportBindingAssignments: ${JSON.stringify(metadata.exportBindingAssignments)}, - exportName: ${JSON.stringify(metadata.exportName)}, - dependencies: ${JSON.stringify(metadata.dependencies)}, - } - `; -} diff --git a/tools/eslint/node_modules/@babel/helpers/scripts/generate-helpers.js b/tools/eslint/node_modules/@babel/helpers/scripts/generate-helpers.js deleted file mode 100644 index 9eeb95a2e375a1..00000000000000 --- a/tools/eslint/node_modules/@babel/helpers/scripts/generate-helpers.js +++ /dev/null @@ -1,207 +0,0 @@ -/* eslint-disable import/no-extraneous-dependencies */ -import fs from "fs"; -import { join } from "path"; -import { URL, fileURLToPath } from "url"; -import { minify } from "terser"; -import { babel, presetTypescript } from "$repo-utils/babel-top-level"; -import { IS_BABEL_8 } from "$repo-utils"; -import { gzipSync } from "zlib"; - -import { - getHelperMetadata, - stringifyMetadata, -} from "./build-helper-metadata.js"; - -const HELPERS_FOLDER = new URL("../src/helpers", import.meta.url); -const IGNORED_FILES = new Set(["package.json", "tsconfig.json"]); - -export default async function generateHelpers() { - let output = `/* - * This file is auto-generated! Do not modify it directly. - * To re-generate run 'yarn gulp generate-runtime-helpers' - */ - -import template from "@babel/template"; -import type * as t from "@babel/types"; - -interface Helper { - minVersion: string; - ast: () => t.Program; - metadata: HelperMetadata; -} - -export interface HelperMetadata { - globals: string[]; - locals: { [name: string]: string[] }; - dependencies: { [name: string]: string[] }; - exportBindingAssignments: string[]; - exportName: string; -} - -function helper(minVersion: string, source: string, metadata: HelperMetadata): Helper { - return Object.freeze({ - minVersion, - ast: () => template.program.ast(source, { preserveComments: true }), - metadata, - }) -} - -export { helpers as default }; -const helpers: Record = { - __proto__: null, -`; - - let babel7extraOutput = ""; - - for (const file of (await fs.promises.readdir(HELPERS_FOLDER)).sort()) { - if (IGNORED_FILES.has(file)) continue; - if (file.startsWith(".")) continue; // ignore e.g. vim swap files - - const [helperName] = file.split("."); - - const isTs = file.endsWith(".ts"); - - const filePath = join(fileURLToPath(HELPERS_FOLDER), file); - if (!file.endsWith(".js") && !isTs) { - console.error("ignoring", filePath); - continue; - } - - let code = await fs.promises.readFile(filePath, "utf8"); - const minVersionMatch = code.match( - /^\s*\/\*\s*@minVersion\s+(?\S+)\s*\*\/\s*$/m - ); - if (!minVersionMatch) { - throw new Error(`@minVersion number missing in ${filePath}`); - } - const { minVersion } = minVersionMatch.groups; - - const onlyBabel7 = code.includes("@onlyBabel7"); - const mangleFns = code.includes("@mangleFns"); - const noMangleFns = []; - - code = babel.transformSync(code, { - configFile: false, - babelrc: false, - filename: filePath, - presets: [ - [ - presetTypescript, - { - onlyRemoveTypeImports: true, - optimizeConstEnums: true, - }, - ], - ], - plugins: [ - /** - * @type {import("@babel/core").PluginObj} - */ - ({ types: t }) => ({ - // These pre/post hooks are needed because the TS transform is, - // when building in the old Babel e2e test, removing the - // `export { OverloadYield as default }` in the OverloadYield helper. - // TODO: Remove in Babel 8. - pre(file) { - if (!process.env.IS_BABEL_OLD_E2E) return; - file.metadata.exportName = null; - file.path.traverse({ - ExportSpecifier(path) { - if (path.node.exported.name === "default") { - file.metadata.exportName = path.node.local.name; - } - }, - }); - }, - post(file) { - if (!process.env.IS_BABEL_OLD_E2E) return; - if (!file.metadata.exportName) return; - file.path.traverse({ - ExportNamedDeclaration(path) { - if ( - !path.node.declaration && - path.node.specifiers.length === 0 - ) { - path.node.specifiers.push( - t.exportSpecifier( - t.identifier(file.metadata.exportName), - t.identifier("default") - ) - ); - } - }, - }); - }, - visitor: { - ImportDeclaration(path) { - const source = path.node.source; - source.value = source.value - .replace(/\.ts$/, "") - .replace(/^\.\//, ""); - }, - FunctionDeclaration(path) { - if ( - mangleFns && - path.node.leadingComments?.find(c => - c.value.includes("@no-mangle") - ) - ) { - const name = path.node.id.name; - if (name) noMangleFns.push(name); - } - }, - }, - }), - ], - }).code; - code = ( - await minify(code, { - ecma: 5, - mangle: { - keep_fnames: mangleFns ? new RegExp(noMangleFns.join("|")) : true, - }, - // The _typeof helper has a custom directive that we must keep - compress: { - directives: false, - passes: 10, - unsafe: true, - unsafe_proto: true, - }, - }) - ).code; - - let metadata; - // eslint-disable-next-line prefer-const - [code, metadata] = getHelperMetadata(babel, code, helperName); - - const helperStr = `\ - // size: ${code.length}, gzip size: ${gzipSync(code).length} - ${JSON.stringify(helperName)}: helper( - ${JSON.stringify(minVersion)}, - ${JSON.stringify(code)}, - ${stringifyMetadata(metadata)} - ), -`; - - if (onlyBabel7) { - if (!IS_BABEL_8()) babel7extraOutput += helperStr; - } else { - output += helperStr; - } - } - - output += "};"; - - if (babel7extraOutput) { - output += ` - -if (!process.env.BABEL_8_BREAKING) { - Object.assign(helpers, { - ${babel7extraOutput} - }); -} -`; - } - - return output; -} diff --git a/tools/eslint/node_modules/@babel/helpers/scripts/generate-regenerator-runtime.js b/tools/eslint/node_modules/@babel/helpers/scripts/generate-regenerator-runtime.js deleted file mode 100644 index 73c301ce6271ac..00000000000000 --- a/tools/eslint/node_modules/@babel/helpers/scripts/generate-regenerator-runtime.js +++ /dev/null @@ -1,61 +0,0 @@ -import fs from "fs"; -import { createRequire } from "module"; - -const [parse, generate] = await Promise.all([ - import("@babel/parser").then(ns => ns.parse), - import("@babel/generator").then(ns => ns.default.default || ns.default), -]).catch(error => { - console.error(error); - throw new Error( - "Before running generate-helpers.js you must compile @babel/parser and @babel/generator.", - { cause: error } - ); -}); - -const REGENERATOR_RUNTIME_IN_FILE = fs.readFileSync( - createRequire(import.meta.url).resolve("regenerator-runtime"), - "utf8" -); - -const MIN_VERSION = "7.18.0"; - -const HEADER = `/* @minVersion ${MIN_VERSION} */ -/* - * This file is auto-generated! Do not modify it directly. - * To re-generate, update the regenerator-runtime dependency of - * @babel/helpers and run 'yarn gulp generate-runtime-helpers'. - */ - -/* eslint-disable */ -`; - -const COPYRIGHT = `/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */`; - -export default function generateRegeneratorRuntimeHelper() { - const ast = parse(REGENERATOR_RUNTIME_IN_FILE, { sourceType: "script" }); - - const factoryFunction = ast.program.body[0].declarations[0].init.callee; - factoryFunction.type = "FunctionDeclaration"; - factoryFunction.id = { type: "Identifier", name: "_regeneratorRuntime" }; - factoryFunction.params = []; - factoryFunction.body.body.unshift( - ...stmts(` - ${COPYRIGHT} - _regeneratorRuntime = function () { return exports; }; - var exports = {}; - `) - ); - - const { code } = generate({ - type: "ExportDefaultDeclaration", - declaration: factoryFunction, - }); - - return HEADER + code; -} - -function stmts(code) { - return parse(`function _() { ${code} }`, { - sourceType: "script", - }).program.body[0].body.body; -} diff --git a/tools/eslint/node_modules/@babel/highlight/LICENSE b/tools/eslint/node_modules/@babel/highlight/LICENSE deleted file mode 100644 index f31575ec773bb1..00000000000000 --- a/tools/eslint/node_modules/@babel/highlight/LICENSE +++ /dev/null @@ -1,22 +0,0 @@ -MIT License - -Copyright (c) 2014-present Sebastian McKenzie and other contributors - -Permission is hereby granted, free of charge, to any person obtaining -a copy of this software and associated documentation files (the -"Software"), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sublicense, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/tools/eslint/node_modules/@babel/highlight/lib/index.js b/tools/eslint/node_modules/@babel/highlight/lib/index.js deleted file mode 100644 index 944a0433f1094b..00000000000000 --- a/tools/eslint/node_modules/@babel/highlight/lib/index.js +++ /dev/null @@ -1,119 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.default = highlight; -exports.shouldHighlight = shouldHighlight; -var _jsTokens = require("js-tokens"); -var _helperValidatorIdentifier = require("@babel/helper-validator-identifier"); -var _picocolors = _interopRequireWildcard(require("picocolors"), true); -function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); } -function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; } -const colors = typeof process === "object" && (process.env.FORCE_COLOR === "0" || process.env.FORCE_COLOR === "false") ? (0, _picocolors.createColors)(false) : _picocolors.default; -const compose = (f, g) => v => f(g(v)); -const sometimesKeywords = new Set(["as", "async", "from", "get", "of", "set"]); -function getDefs(colors) { - return { - keyword: colors.cyan, - capitalized: colors.yellow, - jsxIdentifier: colors.yellow, - punctuator: colors.yellow, - number: colors.magenta, - string: colors.green, - regex: colors.magenta, - comment: colors.gray, - invalid: compose(compose(colors.white, colors.bgRed), colors.bold) - }; -} -const NEWLINE = /\r\n|[\n\r\u2028\u2029]/; -const BRACKET = /^[()[\]{}]$/; -let tokenize; -{ - const JSX_TAG = /^[a-z][\w-]*$/i; - const getTokenType = function (token, offset, text) { - if (token.type === "name") { - if ((0, _helperValidatorIdentifier.isKeyword)(token.value) || (0, _helperValidatorIdentifier.isStrictReservedWord)(token.value, true) || sometimesKeywords.has(token.value)) { - return "keyword"; - } - if (JSX_TAG.test(token.value) && (text[offset - 1] === "<" || text.slice(offset - 2, offset) === " colorize(str)).join("\n"); - } else { - highlighted += value; - } - } - return highlighted; -} -function shouldHighlight(options) { - return colors.isColorSupported || options.forceColor; -} -let pcWithForcedColor = undefined; -function getColors(forceColor) { - if (forceColor) { - var _pcWithForcedColor; - (_pcWithForcedColor = pcWithForcedColor) != null ? _pcWithForcedColor : pcWithForcedColor = (0, _picocolors.createColors)(true); - return pcWithForcedColor; - } - return colors; -} -function highlight(code, options = {}) { - if (code !== "" && shouldHighlight(options)) { - const defs = getDefs(getColors(options.forceColor)); - return highlightTokens(defs, code); - } else { - return code; - } -} -{ - let chalk, chalkWithForcedColor; - exports.getChalk = ({ - forceColor - }) => { - var _chalk; - (_chalk = chalk) != null ? _chalk : chalk = require("chalk"); - if (forceColor) { - var _chalkWithForcedColor; - (_chalkWithForcedColor = chalkWithForcedColor) != null ? _chalkWithForcedColor : chalkWithForcedColor = new chalk.constructor({ - enabled: true, - level: 1 - }); - return chalkWithForcedColor; - } - return chalk; - }; -} - -//# sourceMappingURL=index.js.map diff --git a/tools/eslint/node_modules/@babel/highlight/package.json b/tools/eslint/node_modules/@babel/highlight/package.json deleted file mode 100644 index 935bfb55d7805d..00000000000000 --- a/tools/eslint/node_modules/@babel/highlight/package.json +++ /dev/null @@ -1,30 +0,0 @@ -{ - "name": "@babel/highlight", - "version": "7.24.7", - "description": "Syntax highlight JavaScript strings for output in terminals.", - "author": "The Babel Team (https://babel.dev/team)", - "homepage": "https://babel.dev/docs/en/next/babel-highlight", - "license": "MIT", - "publishConfig": { - "access": "public" - }, - "repository": { - "type": "git", - "url": "https://github.com/babel/babel.git", - "directory": "packages/babel-highlight" - }, - "main": "./lib/index.js", - "dependencies": { - "@babel/helper-validator-identifier": "^7.24.7", - "chalk": "^2.4.2", - "js-tokens": "^4.0.0", - "picocolors": "^1.0.0" - }, - "devDependencies": { - "strip-ansi": "^4.0.0" - }, - "engines": { - "node": ">=6.9.0" - }, - "type": "commonjs" -} \ No newline at end of file diff --git a/tools/eslint/node_modules/@babel/parser/LICENSE b/tools/eslint/node_modules/@babel/parser/LICENSE deleted file mode 100644 index d4c7fc583804df..00000000000000 --- a/tools/eslint/node_modules/@babel/parser/LICENSE +++ /dev/null @@ -1,19 +0,0 @@ -Copyright (C) 2012-2014 by various contributors (see AUTHORS) - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. diff --git a/tools/eslint/node_modules/@babel/parser/bin/babel-parser.js b/tools/eslint/node_modules/@babel/parser/bin/babel-parser.js deleted file mode 100755 index 3aca314533b3d3..00000000000000 --- a/tools/eslint/node_modules/@babel/parser/bin/babel-parser.js +++ /dev/null @@ -1,15 +0,0 @@ -#!/usr/bin/env node -/* eslint no-var: 0 */ - -var parser = require(".."); -var fs = require("fs"); - -var filename = process.argv[2]; -if (!filename) { - console.error("no filename specified"); -} else { - var file = fs.readFileSync(filename, "utf8"); - var ast = parser.parse(file); - - console.log(JSON.stringify(ast, null, " ")); -} diff --git a/tools/eslint/node_modules/@babel/parser/index.cjs b/tools/eslint/node_modules/@babel/parser/index.cjs deleted file mode 100644 index 89863a9f36589c..00000000000000 --- a/tools/eslint/node_modules/@babel/parser/index.cjs +++ /dev/null @@ -1,5 +0,0 @@ -try { - module.exports = require("./lib/index.cjs"); -} catch { - module.exports = require("./lib/index.js"); -} diff --git a/tools/eslint/node_modules/@babel/parser/lib/index.js b/tools/eslint/node_modules/@babel/parser/lib/index.js deleted file mode 100644 index e792db234d6f9d..00000000000000 --- a/tools/eslint/node_modules/@babel/parser/lib/index.js +++ /dev/null @@ -1,14007 +0,0 @@ -'use strict'; - -Object.defineProperty(exports, '__esModule', { - value: true -}); -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; -} -class Position { - constructor(line, col, index) { - this.line = void 0; - this.column = void 0; - this.index = void 0; - this.line = line; - this.column = col; - this.index = index; - } -} -class SourceLocation { - constructor(start, end) { - this.start = void 0; - this.end = void 0; - this.filename = void 0; - this.identifierName = void 0; - this.start = start; - this.end = end; - } -} -function createPositionWithColumnOffset(position, columnOffset) { - const { - line, - column, - index - } = position; - return new Position(line, column + columnOffset, index + columnOffset); -} -const code = "BABEL_PARSER_SOURCETYPE_MODULE_REQUIRED"; -var ModuleErrors = { - ImportMetaOutsideModule: { - message: `import.meta may appear only with 'sourceType: "module"'`, - code - }, - ImportOutsideModule: { - message: `'import' and 'export' may appear only with 'sourceType: "module"'`, - code - } -}; -const NodeDescriptions = { - ArrayPattern: "array destructuring pattern", - AssignmentExpression: "assignment expression", - AssignmentPattern: "assignment expression", - ArrowFunctionExpression: "arrow function expression", - ConditionalExpression: "conditional expression", - CatchClause: "catch clause", - ForOfStatement: "for-of statement", - ForInStatement: "for-in statement", - ForStatement: "for-loop", - FormalParameters: "function parameter list", - Identifier: "identifier", - ImportSpecifier: "import specifier", - ImportDefaultSpecifier: "import default specifier", - ImportNamespaceSpecifier: "import namespace specifier", - ObjectPattern: "object destructuring pattern", - ParenthesizedExpression: "parenthesized expression", - RestElement: "rest element", - UpdateExpression: { - true: "prefix operation", - false: "postfix operation" - }, - VariableDeclarator: "variable declaration", - YieldExpression: "yield expression" -}; -const toNodeDescription = node => node.type === "UpdateExpression" ? NodeDescriptions.UpdateExpression[`${node.prefix}`] : NodeDescriptions[node.type]; -var StandardErrors = { - AccessorIsGenerator: ({ - kind - }) => `A ${kind}ter cannot be a generator.`, - ArgumentsInClass: "'arguments' is only allowed in functions and class methods.", - AsyncFunctionInSingleStatementContext: "Async functions can only be declared at the top level or inside a block.", - AwaitBindingIdentifier: "Can not use 'await' as identifier inside an async function.", - AwaitBindingIdentifierInStaticBlock: "Can not use 'await' as identifier inside a static block.", - AwaitExpressionFormalParameter: "'await' is not allowed in async function parameters.", - AwaitUsingNotInAsyncContext: "'await using' is only allowed within async functions and at the top levels of modules.", - AwaitNotInAsyncContext: "'await' is only allowed within async functions and at the top levels of modules.", - AwaitNotInAsyncFunction: "'await' is only allowed within async functions.", - BadGetterArity: "A 'get' accessor must not have any formal parameters.", - BadSetterArity: "A 'set' accessor must have exactly one formal parameter.", - BadSetterRestParameter: "A 'set' accessor function argument must not be a rest parameter.", - ConstructorClassField: "Classes may not have a field named 'constructor'.", - ConstructorClassPrivateField: "Classes may not have a private field named '#constructor'.", - ConstructorIsAccessor: "Class constructor may not be an accessor.", - ConstructorIsAsync: "Constructor can't be an async function.", - ConstructorIsGenerator: "Constructor can't be a generator.", - DeclarationMissingInitializer: ({ - kind - }) => `Missing initializer in ${kind} declaration.`, - DecoratorArgumentsOutsideParentheses: "Decorator arguments must be moved inside parentheses: use '@(decorator(args))' instead of '@(decorator)(args)'.", - DecoratorBeforeExport: "Decorators must be placed *before* the 'export' keyword. Remove the 'decoratorsBeforeExport: true' option to use the 'export @decorator class {}' syntax.", - DecoratorsBeforeAfterExport: "Decorators can be placed *either* before or after the 'export' keyword, but not in both locations at the same time.", - DecoratorConstructor: "Decorators can't be used with a constructor. Did you mean '@dec class { ... }'?", - DecoratorExportClass: "Decorators must be placed *after* the 'export' keyword. Remove the 'decoratorsBeforeExport: false' option to use the '@decorator export class {}' syntax.", - DecoratorSemicolon: "Decorators must not be followed by a semicolon.", - DecoratorStaticBlock: "Decorators can't be used with a static block.", - DeferImportRequiresNamespace: 'Only `import defer * as x from "./module"` is valid.', - DeletePrivateField: "Deleting a private field is not allowed.", - DestructureNamedImport: "ES2015 named imports do not destructure. Use another statement for destructuring after the import.", - DuplicateConstructor: "Duplicate constructor in the same class.", - DuplicateDefaultExport: "Only one default export allowed per module.", - DuplicateExport: ({ - exportName - }) => `\`${exportName}\` has already been exported. Exported identifiers must be unique.`, - DuplicateProto: "Redefinition of __proto__ property.", - DuplicateRegExpFlags: "Duplicate regular expression flag.", - DynamicImportPhaseRequiresImportExpressions: ({ - phase - }) => `'import.${phase}(...)' can only be parsed when using the 'createImportExpressions' option.`, - ElementAfterRest: "Rest element must be last element.", - EscapedCharNotAnIdentifier: "Invalid Unicode escape.", - ExportBindingIsString: ({ - localName, - exportName - }) => `A string literal cannot be used as an exported binding without \`from\`.\n- Did you mean \`export { '${localName}' as '${exportName}' } from 'some-module'\`?`, - ExportDefaultFromAsIdentifier: "'from' is not allowed as an identifier after 'export default'.", - ForInOfLoopInitializer: ({ - type - }) => `'${type === "ForInStatement" ? "for-in" : "for-of"}' loop variable declaration may not have an initializer.`, - ForInUsing: "For-in loop may not start with 'using' declaration.", - ForOfAsync: "The left-hand side of a for-of loop may not be 'async'.", - ForOfLet: "The left-hand side of a for-of loop may not start with 'let'.", - GeneratorInSingleStatementContext: "Generators can only be declared at the top level or inside a block.", - IllegalBreakContinue: ({ - type - }) => `Unsyntactic ${type === "BreakStatement" ? "break" : "continue"}.`, - IllegalLanguageModeDirective: "Illegal 'use strict' directive in function with non-simple parameter list.", - IllegalReturn: "'return' outside of function.", - ImportAttributesUseAssert: "The `assert` keyword in import attributes is deprecated and it has been replaced by the `with` keyword. You can enable the `deprecatedAssertSyntax: true` option in the import attributes plugin to suppress this error.", - ImportBindingIsString: ({ - importName - }) => `A string literal cannot be used as an imported binding.\n- Did you mean \`import { "${importName}" as foo }\`?`, - ImportCallArgumentTrailingComma: "Trailing comma is disallowed inside import(...) arguments.", - ImportCallArity: ({ - maxArgumentCount - }) => `\`import()\` requires exactly ${maxArgumentCount === 1 ? "one argument" : "one or two arguments"}.`, - ImportCallNotNewExpression: "Cannot use new with import(...).", - ImportCallSpreadArgument: "`...` is not allowed in `import()`.", - ImportJSONBindingNotDefault: "A JSON module can only be imported with `default`.", - ImportReflectionHasAssertion: "`import module x` cannot have assertions.", - ImportReflectionNotBinding: 'Only `import module x from "./module"` is valid.', - IncompatibleRegExpUVFlags: "The 'u' and 'v' regular expression flags cannot be enabled at the same time.", - InvalidBigIntLiteral: "Invalid BigIntLiteral.", - InvalidCodePoint: "Code point out of bounds.", - InvalidCoverInitializedName: "Invalid shorthand property initializer.", - InvalidDecimal: "Invalid decimal.", - InvalidDigit: ({ - radix - }) => `Expected number in radix ${radix}.`, - InvalidEscapeSequence: "Bad character escape sequence.", - InvalidEscapeSequenceTemplate: "Invalid escape sequence in template.", - InvalidEscapedReservedWord: ({ - reservedWord - }) => `Escape sequence in keyword ${reservedWord}.`, - InvalidIdentifier: ({ - identifierName - }) => `Invalid identifier ${identifierName}.`, - InvalidLhs: ({ - ancestor - }) => `Invalid left-hand side in ${toNodeDescription(ancestor)}.`, - InvalidLhsBinding: ({ - ancestor - }) => `Binding invalid left-hand side in ${toNodeDescription(ancestor)}.`, - InvalidLhsOptionalChaining: ({ - ancestor - }) => `Invalid optional chaining in the left-hand side of ${toNodeDescription(ancestor)}.`, - InvalidNumber: "Invalid number.", - InvalidOrMissingExponent: "Floating-point numbers require a valid exponent after the 'e'.", - InvalidOrUnexpectedToken: ({ - unexpected - }) => `Unexpected character '${unexpected}'.`, - InvalidParenthesizedAssignment: "Invalid parenthesized assignment pattern.", - InvalidPrivateFieldResolution: ({ - identifierName - }) => `Private name #${identifierName} is not defined.`, - InvalidPropertyBindingPattern: "Binding member expression.", - InvalidRecordProperty: "Only properties and spread elements are allowed in record definitions.", - InvalidRestAssignmentPattern: "Invalid rest operator's argument.", - LabelRedeclaration: ({ - labelName - }) => `Label '${labelName}' is already declared.`, - LetInLexicalBinding: "'let' is disallowed as a lexically bound name.", - LineTerminatorBeforeArrow: "No line break is allowed before '=>'.", - MalformedRegExpFlags: "Invalid regular expression flag.", - MissingClassName: "A class name is required.", - MissingEqInAssignment: "Only '=' operator can be used for specifying default value.", - MissingSemicolon: "Missing semicolon.", - MissingPlugin: ({ - missingPlugin - }) => `This experimental syntax requires enabling the parser plugin: ${missingPlugin.map(name => JSON.stringify(name)).join(", ")}.`, - MissingOneOfPlugins: ({ - missingPlugin - }) => `This experimental syntax requires enabling one of the following parser plugin(s): ${missingPlugin.map(name => JSON.stringify(name)).join(", ")}.`, - MissingUnicodeEscape: "Expecting Unicode escape sequence \\uXXXX.", - MixingCoalesceWithLogical: "Nullish coalescing operator(??) requires parens when mixing with logical operators.", - ModuleAttributeDifferentFromType: "The only accepted module attribute is `type`.", - ModuleAttributeInvalidValue: "Only string literals are allowed as module attribute values.", - ModuleAttributesWithDuplicateKeys: ({ - key - }) => `Duplicate key "${key}" is not allowed in module attributes.`, - ModuleExportNameHasLoneSurrogate: ({ - surrogateCharCode - }) => `An export name cannot include a lone surrogate, found '\\u${surrogateCharCode.toString(16)}'.`, - ModuleExportUndefined: ({ - localName - }) => `Export '${localName}' is not defined.`, - MultipleDefaultsInSwitch: "Multiple default clauses.", - NewlineAfterThrow: "Illegal newline after throw.", - NoCatchOrFinally: "Missing catch or finally clause.", - NumberIdentifier: "Identifier directly after number.", - NumericSeparatorInEscapeSequence: "Numeric separators are not allowed inside unicode escape sequences or hex escape sequences.", - ObsoleteAwaitStar: "'await*' has been removed from the async functions proposal. Use Promise.all() instead.", - OptionalChainingNoNew: "Constructors in/after an Optional Chain are not allowed.", - OptionalChainingNoTemplate: "Tagged Template Literals are not allowed in optionalChain.", - OverrideOnConstructor: "'override' modifier cannot appear on a constructor declaration.", - ParamDupe: "Argument name clash.", - PatternHasAccessor: "Object pattern can't contain getter or setter.", - PatternHasMethod: "Object pattern can't contain methods.", - PrivateInExpectedIn: ({ - identifierName - }) => `Private names are only allowed in property accesses (\`obj.#${identifierName}\`) or in \`in\` expressions (\`#${identifierName} in obj\`).`, - PrivateNameRedeclaration: ({ - identifierName - }) => `Duplicate private name #${identifierName}.`, - RecordExpressionBarIncorrectEndSyntaxType: "Record expressions ending with '|}' are only allowed when the 'syntaxType' option of the 'recordAndTuple' plugin is set to 'bar'.", - RecordExpressionBarIncorrectStartSyntaxType: "Record expressions starting with '{|' are only allowed when the 'syntaxType' option of the 'recordAndTuple' plugin is set to 'bar'.", - RecordExpressionHashIncorrectStartSyntaxType: "Record expressions starting with '#{' are only allowed when the 'syntaxType' option of the 'recordAndTuple' plugin is set to 'hash'.", - RecordNoProto: "'__proto__' is not allowed in Record expressions.", - RestTrailingComma: "Unexpected trailing comma after rest element.", - SloppyFunction: "In non-strict mode code, functions can only be declared at top level or inside a block.", - SloppyFunctionAnnexB: "In non-strict mode code, functions can only be declared at top level, inside a block, or as the body of an if statement.", - SourcePhaseImportRequiresDefault: 'Only `import source x from "./module"` is valid.', - StaticPrototype: "Classes may not have static property named prototype.", - SuperNotAllowed: "`super()` is only valid inside a class constructor of a subclass. Maybe a typo in the method name ('constructor') or not extending another class?", - SuperPrivateField: "Private fields can't be accessed on super.", - TrailingDecorator: "Decorators must be attached to a class element.", - TupleExpressionBarIncorrectEndSyntaxType: "Tuple expressions ending with '|]' are only allowed when the 'syntaxType' option of the 'recordAndTuple' plugin is set to 'bar'.", - TupleExpressionBarIncorrectStartSyntaxType: "Tuple expressions starting with '[|' are only allowed when the 'syntaxType' option of the 'recordAndTuple' plugin is set to 'bar'.", - TupleExpressionHashIncorrectStartSyntaxType: "Tuple expressions starting with '#[' are only allowed when the 'syntaxType' option of the 'recordAndTuple' plugin is set to 'hash'.", - UnexpectedArgumentPlaceholder: "Unexpected argument placeholder.", - UnexpectedAwaitAfterPipelineBody: 'Unexpected "await" after pipeline body; await must have parentheses in minimal proposal.', - UnexpectedDigitAfterHash: "Unexpected digit after hash token.", - UnexpectedImportExport: "'import' and 'export' may only appear at the top level.", - UnexpectedKeyword: ({ - keyword - }) => `Unexpected keyword '${keyword}'.`, - UnexpectedLeadingDecorator: "Leading decorators must be attached to a class declaration.", - UnexpectedLexicalDeclaration: "Lexical declaration cannot appear in a single-statement context.", - UnexpectedNewTarget: "`new.target` can only be used in functions or class properties.", - UnexpectedNumericSeparator: "A numeric separator is only allowed between two digits.", - UnexpectedPrivateField: "Unexpected private name.", - UnexpectedReservedWord: ({ - reservedWord - }) => `Unexpected reserved word '${reservedWord}'.`, - UnexpectedSuper: "'super' is only allowed in object methods and classes.", - UnexpectedToken: ({ - expected, - unexpected - }) => `Unexpected token${unexpected ? ` '${unexpected}'.` : ""}${expected ? `, expected "${expected}"` : ""}`, - UnexpectedTokenUnaryExponentiation: "Illegal expression. Wrap left hand side or entire exponentiation in parentheses.", - UnexpectedUsingDeclaration: "Using declaration cannot appear in the top level when source type is `script`.", - UnsupportedBind: "Binding should be performed on object property.", - UnsupportedDecoratorExport: "A decorated export must export a class declaration.", - UnsupportedDefaultExport: "Only expressions, functions or classes are allowed as the `default` export.", - UnsupportedImport: "`import` can only be used in `import()` or `import.meta`.", - UnsupportedMetaProperty: ({ - target, - onlyValidPropertyName - }) => `The only valid meta property for ${target} is ${target}.${onlyValidPropertyName}.`, - UnsupportedParameterDecorator: "Decorators cannot be used to decorate parameters.", - UnsupportedPropertyDecorator: "Decorators cannot be used to decorate object literal properties.", - UnsupportedSuper: "'super' can only be used with function calls (i.e. super()) or in property accesses (i.e. super.prop or super[prop]).", - UnterminatedComment: "Unterminated comment.", - UnterminatedRegExp: "Unterminated regular expression.", - UnterminatedString: "Unterminated string constant.", - UnterminatedTemplate: "Unterminated template.", - UsingDeclarationExport: "Using declaration cannot be exported.", - UsingDeclarationHasBindingPattern: "Using declaration cannot have destructuring patterns.", - VarRedeclaration: ({ - identifierName - }) => `Identifier '${identifierName}' has already been declared.`, - YieldBindingIdentifier: "Can not use 'yield' as identifier inside a generator.", - YieldInParameter: "Yield expression is not allowed in formal parameters.", - ZeroDigitNumericSeparator: "Numeric separator can not be used after leading 0." -}; -var StrictModeErrors = { - StrictDelete: "Deleting local variable in strict mode.", - StrictEvalArguments: ({ - referenceName - }) => `Assigning to '${referenceName}' in strict mode.`, - StrictEvalArgumentsBinding: ({ - bindingName - }) => `Binding '${bindingName}' in strict mode.`, - StrictFunction: "In strict mode code, functions can only be declared at top level or inside a block.", - StrictNumericEscape: "The only valid numeric escape in strict mode is '\\0'.", - StrictOctalLiteral: "Legacy octal literals are not allowed in strict mode.", - StrictWith: "'with' in strict mode." -}; -const UnparenthesizedPipeBodyDescriptions = new Set(["ArrowFunctionExpression", "AssignmentExpression", "ConditionalExpression", "YieldExpression"]); -var PipelineOperatorErrors = { - PipeBodyIsTighter: "Unexpected yield after pipeline body; any yield expression acting as Hack-style pipe body must be parenthesized due to its loose operator precedence.", - PipeTopicRequiresHackPipes: 'Topic reference is used, but the pipelineOperator plugin was not passed a "proposal": "hack" or "smart" option.', - PipeTopicUnbound: "Topic reference is unbound; it must be inside a pipe body.", - PipeTopicUnconfiguredToken: ({ - token - }) => `Invalid topic token ${token}. In order to use ${token} as a topic reference, the pipelineOperator plugin must be configured with { "proposal": "hack", "topicToken": "${token}" }.`, - PipeTopicUnused: "Hack-style pipe body does not contain a topic reference; Hack-style pipes must use topic at least once.", - PipeUnparenthesizedBody: ({ - type - }) => `Hack-style pipe body cannot be an unparenthesized ${toNodeDescription({ - type - })}; please wrap it in parentheses.`, - PipelineBodyNoArrow: 'Unexpected arrow "=>" after pipeline body; arrow function in pipeline body must be parenthesized.', - PipelineBodySequenceExpression: "Pipeline body may not be a comma-separated sequence expression.", - PipelineHeadSequenceExpression: "Pipeline head should not be a comma-separated sequence expression.", - PipelineTopicUnused: "Pipeline is in topic style but does not use topic reference.", - PrimaryTopicNotAllowed: "Topic reference was used in a lexical context without topic binding.", - PrimaryTopicRequiresSmartPipeline: 'Topic reference is used, but the pipelineOperator plugin was not passed a "proposal": "hack" or "smart" option.' -}; -const _excluded = ["toMessage"], - _excluded2 = ["message"]; -function defineHidden(obj, key, value) { - Object.defineProperty(obj, key, { - enumerable: false, - configurable: true, - value - }); -} -function toParseErrorConstructor(_ref) { - let { - toMessage - } = _ref, - properties = _objectWithoutPropertiesLoose(_ref, _excluded); - return function constructor(loc, details) { - const error = new SyntaxError(); - Object.assign(error, properties, { - loc, - pos: loc.index - }); - if ("missingPlugin" in details) { - Object.assign(error, { - missingPlugin: details.missingPlugin - }); - } - defineHidden(error, "clone", function clone(overrides = {}) { - var _overrides$loc; - const { - line, - column, - index - } = (_overrides$loc = overrides.loc) != null ? _overrides$loc : loc; - return constructor(new Position(line, column, index), Object.assign({}, details, overrides.details)); - }); - defineHidden(error, "details", details); - Object.defineProperty(error, "message", { - configurable: true, - get() { - const message = `${toMessage(details)} (${loc.line}:${loc.column})`; - this.message = message; - return message; - }, - set(value) { - Object.defineProperty(this, "message", { - value, - writable: true - }); - } - }); - return error; - }; -} -function ParseErrorEnum(argument, syntaxPlugin) { - if (Array.isArray(argument)) { - return parseErrorTemplates => ParseErrorEnum(parseErrorTemplates, argument[0]); - } - const ParseErrorConstructors = {}; - for (const reasonCode of Object.keys(argument)) { - const template = argument[reasonCode]; - const _ref2 = typeof template === "string" ? { - message: () => template - } : typeof template === "function" ? { - message: template - } : template, - { - message - } = _ref2, - rest = _objectWithoutPropertiesLoose(_ref2, _excluded2); - const toMessage = typeof message === "string" ? () => message : message; - ParseErrorConstructors[reasonCode] = toParseErrorConstructor(Object.assign({ - code: "BABEL_PARSER_SYNTAX_ERROR", - reasonCode, - toMessage - }, syntaxPlugin ? { - syntaxPlugin - } : {}, rest)); - } - return ParseErrorConstructors; -} -const Errors = Object.assign({}, ParseErrorEnum(ModuleErrors), ParseErrorEnum(StandardErrors), ParseErrorEnum(StrictModeErrors), ParseErrorEnum`pipelineOperator`(PipelineOperatorErrors)); -const { - defineProperty -} = Object; -const toUnenumerable = (object, key) => { - if (object) { - defineProperty(object, key, { - enumerable: false, - value: object[key] - }); - } -}; -function toESTreeLocation(node) { - toUnenumerable(node.loc.start, "index"); - toUnenumerable(node.loc.end, "index"); - return node; -} -var estree = superClass => class ESTreeParserMixin extends superClass { - parse() { - const file = toESTreeLocation(super.parse()); - if (this.options.tokens) { - file.tokens = file.tokens.map(toESTreeLocation); - } - return file; - } - parseRegExpLiteral({ - pattern, - flags - }) { - let regex = null; - try { - regex = new RegExp(pattern, flags); - } catch (_) {} - const node = this.estreeParseLiteral(regex); - node.regex = { - pattern, - flags - }; - return node; - } - parseBigIntLiteral(value) { - let bigInt; - try { - bigInt = BigInt(value); - } catch (_unused) { - bigInt = null; - } - const node = this.estreeParseLiteral(bigInt); - node.bigint = String(node.value || value); - return node; - } - parseDecimalLiteral(value) { - const decimal = null; - const node = this.estreeParseLiteral(decimal); - node.decimal = String(node.value || value); - return node; - } - estreeParseLiteral(value) { - return this.parseLiteral(value, "Literal"); - } - parseStringLiteral(value) { - return this.estreeParseLiteral(value); - } - parseNumericLiteral(value) { - return this.estreeParseLiteral(value); - } - parseNullLiteral() { - return this.estreeParseLiteral(null); - } - parseBooleanLiteral(value) { - return this.estreeParseLiteral(value); - } - directiveToStmt(directive) { - const expression = directive.value; - delete directive.value; - expression.type = "Literal"; - expression.raw = expression.extra.raw; - expression.value = expression.extra.expressionValue; - const stmt = directive; - stmt.type = "ExpressionStatement"; - stmt.expression = expression; - stmt.directive = expression.extra.rawValue; - delete expression.extra; - return stmt; - } - initFunction(node, isAsync) { - super.initFunction(node, isAsync); - node.expression = false; - } - checkDeclaration(node) { - if (node != null && this.isObjectProperty(node)) { - this.checkDeclaration(node.value); - } else { - super.checkDeclaration(node); - } - } - getObjectOrClassMethodParams(method) { - return method.value.params; - } - isValidDirective(stmt) { - var _stmt$expression$extr; - return stmt.type === "ExpressionStatement" && stmt.expression.type === "Literal" && typeof stmt.expression.value === "string" && !((_stmt$expression$extr = stmt.expression.extra) != null && _stmt$expression$extr.parenthesized); - } - parseBlockBody(node, allowDirectives, topLevel, end, afterBlockParse) { - super.parseBlockBody(node, allowDirectives, topLevel, end, afterBlockParse); - const directiveStatements = node.directives.map(d => this.directiveToStmt(d)); - node.body = directiveStatements.concat(node.body); - delete node.directives; - } - pushClassMethod(classBody, method, isGenerator, isAsync, isConstructor, allowsDirectSuper) { - this.parseMethod(method, isGenerator, isAsync, isConstructor, allowsDirectSuper, "ClassMethod", true); - if (method.typeParameters) { - method.value.typeParameters = method.typeParameters; - delete method.typeParameters; - } - classBody.body.push(method); - } - parsePrivateName() { - const node = super.parsePrivateName(); - { - if (!this.getPluginOption("estree", "classFeatures")) { - return node; - } - } - return this.convertPrivateNameToPrivateIdentifier(node); - } - convertPrivateNameToPrivateIdentifier(node) { - const name = super.getPrivateNameSV(node); - node = node; - delete node.id; - node.name = name; - node.type = "PrivateIdentifier"; - return node; - } - isPrivateName(node) { - { - if (!this.getPluginOption("estree", "classFeatures")) { - return super.isPrivateName(node); - } - } - return node.type === "PrivateIdentifier"; - } - getPrivateNameSV(node) { - { - if (!this.getPluginOption("estree", "classFeatures")) { - return super.getPrivateNameSV(node); - } - } - return node.name; - } - parseLiteral(value, type) { - const node = super.parseLiteral(value, type); - node.raw = node.extra.raw; - delete node.extra; - return node; - } - parseFunctionBody(node, allowExpression, isMethod = false) { - super.parseFunctionBody(node, allowExpression, isMethod); - node.expression = node.body.type !== "BlockStatement"; - } - parseMethod(node, isGenerator, isAsync, isConstructor, allowDirectSuper, type, inClassScope = false) { - let funcNode = this.startNode(); - funcNode.kind = node.kind; - funcNode = super.parseMethod(funcNode, isGenerator, isAsync, isConstructor, allowDirectSuper, type, inClassScope); - funcNode.type = "FunctionExpression"; - delete funcNode.kind; - node.value = funcNode; - if (type === "ClassPrivateMethod") { - node.computed = false; - } - return this.finishNode(node, "MethodDefinition"); - } - nameIsConstructor(key) { - if (key.type === "Literal") return key.value === "constructor"; - return super.nameIsConstructor(key); - } - parseClassProperty(...args) { - const propertyNode = super.parseClassProperty(...args); - { - if (!this.getPluginOption("estree", "classFeatures")) { - return propertyNode; - } - } - propertyNode.type = "PropertyDefinition"; - return propertyNode; - } - parseClassPrivateProperty(...args) { - const propertyNode = super.parseClassPrivateProperty(...args); - { - if (!this.getPluginOption("estree", "classFeatures")) { - return propertyNode; - } - } - propertyNode.type = "PropertyDefinition"; - propertyNode.computed = false; - return propertyNode; - } - parseObjectMethod(prop, isGenerator, isAsync, isPattern, isAccessor) { - const node = super.parseObjectMethod(prop, isGenerator, isAsync, isPattern, isAccessor); - if (node) { - node.type = "Property"; - if (node.kind === "method") { - node.kind = "init"; - } - node.shorthand = false; - } - return node; - } - parseObjectProperty(prop, startLoc, isPattern, refExpressionErrors) { - const node = super.parseObjectProperty(prop, startLoc, isPattern, refExpressionErrors); - if (node) { - node.kind = "init"; - node.type = "Property"; - } - return node; - } - isValidLVal(type, isUnparenthesizedInAssign, binding) { - return type === "Property" ? "value" : super.isValidLVal(type, isUnparenthesizedInAssign, binding); - } - isAssignable(node, isBinding) { - if (node != null && this.isObjectProperty(node)) { - return this.isAssignable(node.value, isBinding); - } - return super.isAssignable(node, isBinding); - } - toAssignable(node, isLHS = false) { - if (node != null && this.isObjectProperty(node)) { - const { - key, - value - } = node; - if (this.isPrivateName(key)) { - this.classScope.usePrivateName(this.getPrivateNameSV(key), key.loc.start); - } - this.toAssignable(value, isLHS); - } else { - super.toAssignable(node, isLHS); - } - } - toAssignableObjectExpressionProp(prop, isLast, isLHS) { - if (prop.type === "Property" && (prop.kind === "get" || prop.kind === "set")) { - this.raise(Errors.PatternHasAccessor, prop.key); - } else if (prop.type === "Property" && prop.method) { - this.raise(Errors.PatternHasMethod, prop.key); - } else { - super.toAssignableObjectExpressionProp(prop, isLast, isLHS); - } - } - finishCallExpression(unfinished, optional) { - const node = super.finishCallExpression(unfinished, optional); - if (node.callee.type === "Import") { - node.type = "ImportExpression"; - node.source = node.arguments[0]; - if (this.hasPlugin("importAttributes") || this.hasPlugin("importAssertions")) { - var _ref, _ref2; - node.options = (_ref = node.arguments[1]) != null ? _ref : null; - node.attributes = (_ref2 = node.arguments[1]) != null ? _ref2 : null; - } - delete node.arguments; - delete node.callee; - } - return node; - } - toReferencedArguments(node) { - if (node.type === "ImportExpression") { - return; - } - super.toReferencedArguments(node); - } - parseExport(unfinished, decorators) { - const exportStartLoc = this.state.lastTokStartLoc; - const node = super.parseExport(unfinished, decorators); - switch (node.type) { - case "ExportAllDeclaration": - node.exported = null; - break; - case "ExportNamedDeclaration": - if (node.specifiers.length === 1 && node.specifiers[0].type === "ExportNamespaceSpecifier") { - node.type = "ExportAllDeclaration"; - node.exported = node.specifiers[0].exported; - delete node.specifiers; - } - case "ExportDefaultDeclaration": - { - var _declaration$decorato; - const { - declaration - } = node; - if ((declaration == null ? void 0 : declaration.type) === "ClassDeclaration" && ((_declaration$decorato = declaration.decorators) == null ? void 0 : _declaration$decorato.length) > 0 && declaration.start === node.start) { - this.resetStartLocation(node, exportStartLoc); - } - } - break; - } - return node; - } - parseSubscript(base, startLoc, noCalls, state) { - const node = super.parseSubscript(base, startLoc, noCalls, state); - if (state.optionalChainMember) { - if (node.type === "OptionalMemberExpression" || node.type === "OptionalCallExpression") { - node.type = node.type.substring(8); - } - if (state.stop) { - const chain = this.startNodeAtNode(node); - chain.expression = node; - return this.finishNode(chain, "ChainExpression"); - } - } else if (node.type === "MemberExpression" || node.type === "CallExpression") { - node.optional = false; - } - return node; - } - isOptionalMemberExpression(node) { - if (node.type === "ChainExpression") { - return node.expression.type === "MemberExpression"; - } - return super.isOptionalMemberExpression(node); - } - hasPropertyAsPrivateName(node) { - if (node.type === "ChainExpression") { - node = node.expression; - } - return super.hasPropertyAsPrivateName(node); - } - isObjectProperty(node) { - return node.type === "Property" && node.kind === "init" && !node.method; - } - isObjectMethod(node) { - return node.type === "Property" && (node.method || node.kind === "get" || node.kind === "set"); - } - finishNodeAt(node, type, endLoc) { - return toESTreeLocation(super.finishNodeAt(node, type, endLoc)); - } - resetStartLocation(node, startLoc) { - super.resetStartLocation(node, startLoc); - toESTreeLocation(node); - } - resetEndLocation(node, endLoc = this.state.lastTokEndLoc) { - super.resetEndLocation(node, endLoc); - toESTreeLocation(node); - } -}; -class TokContext { - constructor(token, preserveSpace) { - this.token = void 0; - this.preserveSpace = void 0; - this.token = token; - this.preserveSpace = !!preserveSpace; - } -} -const types = { - brace: new TokContext("{"), - j_oTag: new TokContext("...", true) -}; -{ - types.template = new TokContext("`", true); -} -const beforeExpr = true; -const startsExpr = true; -const isLoop = true; -const isAssign = true; -const prefix = true; -const postfix = true; -class ExportedTokenType { - constructor(label, conf = {}) { - this.label = void 0; - this.keyword = void 0; - this.beforeExpr = void 0; - this.startsExpr = void 0; - this.rightAssociative = void 0; - this.isLoop = void 0; - this.isAssign = void 0; - this.prefix = void 0; - this.postfix = void 0; - this.binop = void 0; - this.label = label; - this.keyword = conf.keyword; - this.beforeExpr = !!conf.beforeExpr; - this.startsExpr = !!conf.startsExpr; - this.rightAssociative = !!conf.rightAssociative; - this.isLoop = !!conf.isLoop; - this.isAssign = !!conf.isAssign; - this.prefix = !!conf.prefix; - this.postfix = !!conf.postfix; - this.binop = conf.binop != null ? conf.binop : null; - { - this.updateContext = null; - } - } -} -const keywords$1 = new Map(); -function createKeyword(name, options = {}) { - options.keyword = name; - const token = createToken(name, options); - keywords$1.set(name, token); - return token; -} -function createBinop(name, binop) { - return createToken(name, { - beforeExpr, - binop - }); -} -let tokenTypeCounter = -1; -const tokenTypes = []; -const tokenLabels = []; -const tokenBinops = []; -const tokenBeforeExprs = []; -const tokenStartsExprs = []; -const tokenPrefixes = []; -function createToken(name, options = {}) { - var _options$binop, _options$beforeExpr, _options$startsExpr, _options$prefix; - ++tokenTypeCounter; - tokenLabels.push(name); - tokenBinops.push((_options$binop = options.binop) != null ? _options$binop : -1); - tokenBeforeExprs.push((_options$beforeExpr = options.beforeExpr) != null ? _options$beforeExpr : false); - tokenStartsExprs.push((_options$startsExpr = options.startsExpr) != null ? _options$startsExpr : false); - tokenPrefixes.push((_options$prefix = options.prefix) != null ? _options$prefix : false); - tokenTypes.push(new ExportedTokenType(name, options)); - return tokenTypeCounter; -} -function createKeywordLike(name, options = {}) { - var _options$binop2, _options$beforeExpr2, _options$startsExpr2, _options$prefix2; - ++tokenTypeCounter; - keywords$1.set(name, tokenTypeCounter); - tokenLabels.push(name); - tokenBinops.push((_options$binop2 = options.binop) != null ? _options$binop2 : -1); - tokenBeforeExprs.push((_options$beforeExpr2 = options.beforeExpr) != null ? _options$beforeExpr2 : false); - tokenStartsExprs.push((_options$startsExpr2 = options.startsExpr) != null ? _options$startsExpr2 : false); - tokenPrefixes.push((_options$prefix2 = options.prefix) != null ? _options$prefix2 : false); - tokenTypes.push(new ExportedTokenType("name", options)); - return tokenTypeCounter; -} -const tt = { - bracketL: createToken("[", { - beforeExpr, - startsExpr - }), - bracketHashL: createToken("#[", { - beforeExpr, - startsExpr - }), - bracketBarL: createToken("[|", { - beforeExpr, - startsExpr - }), - bracketR: createToken("]"), - bracketBarR: createToken("|]"), - braceL: createToken("{", { - beforeExpr, - startsExpr - }), - braceBarL: createToken("{|", { - beforeExpr, - startsExpr - }), - braceHashL: createToken("#{", { - beforeExpr, - startsExpr - }), - braceR: createToken("}"), - braceBarR: createToken("|}"), - parenL: createToken("(", { - beforeExpr, - startsExpr - }), - parenR: createToken(")"), - comma: createToken(",", { - beforeExpr - }), - semi: createToken(";", { - beforeExpr - }), - colon: createToken(":", { - beforeExpr - }), - doubleColon: createToken("::", { - beforeExpr - }), - dot: createToken("."), - question: createToken("?", { - beforeExpr - }), - questionDot: createToken("?."), - arrow: createToken("=>", { - beforeExpr - }), - template: createToken("template"), - ellipsis: createToken("...", { - beforeExpr - }), - backQuote: createToken("`", { - startsExpr - }), - dollarBraceL: createToken("${", { - beforeExpr, - startsExpr - }), - templateTail: createToken("...`", { - startsExpr - }), - templateNonTail: createToken("...${", { - beforeExpr, - startsExpr - }), - at: createToken("@"), - hash: createToken("#", { - startsExpr - }), - interpreterDirective: createToken("#!..."), - eq: createToken("=", { - beforeExpr, - isAssign - }), - assign: createToken("_=", { - beforeExpr, - isAssign - }), - slashAssign: createToken("_=", { - beforeExpr, - isAssign - }), - xorAssign: createToken("_=", { - beforeExpr, - isAssign - }), - moduloAssign: createToken("_=", { - beforeExpr, - isAssign - }), - incDec: createToken("++/--", { - prefix, - postfix, - startsExpr - }), - bang: createToken("!", { - beforeExpr, - prefix, - startsExpr - }), - tilde: createToken("~", { - beforeExpr, - prefix, - startsExpr - }), - doubleCaret: createToken("^^", { - startsExpr - }), - doubleAt: createToken("@@", { - startsExpr - }), - pipeline: createBinop("|>", 0), - nullishCoalescing: createBinop("??", 1), - logicalOR: createBinop("||", 1), - logicalAND: createBinop("&&", 2), - bitwiseOR: createBinop("|", 3), - bitwiseXOR: createBinop("^", 4), - bitwiseAND: createBinop("&", 5), - equality: createBinop("==/!=/===/!==", 6), - lt: createBinop("/<=/>=", 7), - gt: createBinop("/<=/>=", 7), - relational: createBinop("/<=/>=", 7), - bitShift: createBinop("<>/>>>", 8), - bitShiftL: createBinop("<>/>>>", 8), - bitShiftR: createBinop("<>/>>>", 8), - plusMin: createToken("+/-", { - beforeExpr, - binop: 9, - prefix, - startsExpr - }), - modulo: createToken("%", { - binop: 10, - startsExpr - }), - star: createToken("*", { - binop: 10 - }), - slash: createBinop("/", 10), - exponent: createToken("**", { - beforeExpr, - binop: 11, - rightAssociative: true - }), - _in: createKeyword("in", { - beforeExpr, - binop: 7 - }), - _instanceof: createKeyword("instanceof", { - beforeExpr, - binop: 7 - }), - _break: createKeyword("break"), - _case: createKeyword("case", { - beforeExpr - }), - _catch: createKeyword("catch"), - _continue: createKeyword("continue"), - _debugger: createKeyword("debugger"), - _default: createKeyword("default", { - beforeExpr - }), - _else: createKeyword("else", { - beforeExpr - }), - _finally: createKeyword("finally"), - _function: createKeyword("function", { - startsExpr - }), - _if: createKeyword("if"), - _return: createKeyword("return", { - beforeExpr - }), - _switch: createKeyword("switch"), - _throw: createKeyword("throw", { - beforeExpr, - prefix, - startsExpr - }), - _try: createKeyword("try"), - _var: createKeyword("var"), - _const: createKeyword("const"), - _with: createKeyword("with"), - _new: createKeyword("new", { - beforeExpr, - startsExpr - }), - _this: createKeyword("this", { - startsExpr - }), - _super: createKeyword("super", { - startsExpr - }), - _class: createKeyword("class", { - startsExpr - }), - _extends: createKeyword("extends", { - beforeExpr - }), - _export: createKeyword("export"), - _import: createKeyword("import", { - startsExpr - }), - _null: createKeyword("null", { - startsExpr - }), - _true: createKeyword("true", { - startsExpr - }), - _false: createKeyword("false", { - startsExpr - }), - _typeof: createKeyword("typeof", { - beforeExpr, - prefix, - startsExpr - }), - _void: createKeyword("void", { - beforeExpr, - prefix, - startsExpr - }), - _delete: createKeyword("delete", { - beforeExpr, - prefix, - startsExpr - }), - _do: createKeyword("do", { - isLoop, - beforeExpr - }), - _for: createKeyword("for", { - isLoop - }), - _while: createKeyword("while", { - isLoop - }), - _as: createKeywordLike("as", { - startsExpr - }), - _assert: createKeywordLike("assert", { - startsExpr - }), - _async: createKeywordLike("async", { - startsExpr - }), - _await: createKeywordLike("await", { - startsExpr - }), - _defer: createKeywordLike("defer", { - startsExpr - }), - _from: createKeywordLike("from", { - startsExpr - }), - _get: createKeywordLike("get", { - startsExpr - }), - _let: createKeywordLike("let", { - startsExpr - }), - _meta: createKeywordLike("meta", { - startsExpr - }), - _of: createKeywordLike("of", { - startsExpr - }), - _sent: createKeywordLike("sent", { - startsExpr - }), - _set: createKeywordLike("set", { - startsExpr - }), - _source: createKeywordLike("source", { - startsExpr - }), - _static: createKeywordLike("static", { - startsExpr - }), - _using: createKeywordLike("using", { - startsExpr - }), - _yield: createKeywordLike("yield", { - startsExpr - }), - _asserts: createKeywordLike("asserts", { - startsExpr - }), - _checks: createKeywordLike("checks", { - startsExpr - }), - _exports: createKeywordLike("exports", { - startsExpr - }), - _global: createKeywordLike("global", { - startsExpr - }), - _implements: createKeywordLike("implements", { - startsExpr - }), - _intrinsic: createKeywordLike("intrinsic", { - startsExpr - }), - _infer: createKeywordLike("infer", { - startsExpr - }), - _is: createKeywordLike("is", { - startsExpr - }), - _mixins: createKeywordLike("mixins", { - startsExpr - }), - _proto: createKeywordLike("proto", { - startsExpr - }), - _require: createKeywordLike("require", { - startsExpr - }), - _satisfies: createKeywordLike("satisfies", { - startsExpr - }), - _keyof: createKeywordLike("keyof", { - startsExpr - }), - _readonly: createKeywordLike("readonly", { - startsExpr - }), - _unique: createKeywordLike("unique", { - startsExpr - }), - _abstract: createKeywordLike("abstract", { - startsExpr - }), - _declare: createKeywordLike("declare", { - startsExpr - }), - _enum: createKeywordLike("enum", { - startsExpr - }), - _module: createKeywordLike("module", { - startsExpr - }), - _namespace: createKeywordLike("namespace", { - startsExpr - }), - _interface: createKeywordLike("interface", { - startsExpr - }), - _type: createKeywordLike("type", { - startsExpr - }), - _opaque: createKeywordLike("opaque", { - startsExpr - }), - name: createToken("name", { - startsExpr - }), - string: createToken("string", { - startsExpr - }), - num: createToken("num", { - startsExpr - }), - bigint: createToken("bigint", { - startsExpr - }), - decimal: createToken("decimal", { - startsExpr - }), - regexp: createToken("regexp", { - startsExpr - }), - privateName: createToken("#name", { - startsExpr - }), - eof: createToken("eof"), - jsxName: createToken("jsxName"), - jsxText: createToken("jsxText", { - beforeExpr: true - }), - jsxTagStart: createToken("jsxTagStart", { - startsExpr: true - }), - jsxTagEnd: createToken("jsxTagEnd"), - placeholder: createToken("%%", { - startsExpr: true - }) -}; -function tokenIsIdentifier(token) { - return token >= 93 && token <= 132; -} -function tokenKeywordOrIdentifierIsKeyword(token) { - return token <= 92; -} -function tokenIsKeywordOrIdentifier(token) { - return token >= 58 && token <= 132; -} -function tokenIsLiteralPropertyName(token) { - return token >= 58 && token <= 136; -} -function tokenComesBeforeExpression(token) { - return tokenBeforeExprs[token]; -} -function tokenCanStartExpression(token) { - return tokenStartsExprs[token]; -} -function tokenIsAssignment(token) { - return token >= 29 && token <= 33; -} -function tokenIsFlowInterfaceOrTypeOrOpaque(token) { - return token >= 129 && token <= 131; -} -function tokenIsLoop(token) { - return token >= 90 && token <= 92; -} -function tokenIsKeyword(token) { - return token >= 58 && token <= 92; -} -function tokenIsOperator(token) { - return token >= 39 && token <= 59; -} -function tokenIsPostfix(token) { - return token === 34; -} -function tokenIsPrefix(token) { - return tokenPrefixes[token]; -} -function tokenIsTSTypeOperator(token) { - return token >= 121 && token <= 123; -} -function tokenIsTSDeclarationStart(token) { - return token >= 124 && token <= 130; -} -function tokenLabelName(token) { - return tokenLabels[token]; -} -function tokenOperatorPrecedence(token) { - return tokenBinops[token]; -} -function tokenIsRightAssociative(token) { - return token === 57; -} -function tokenIsTemplate(token) { - return token >= 24 && token <= 25; -} -function getExportedToken(token) { - return tokenTypes[token]; -} -{ - tokenTypes[8].updateContext = context => { - context.pop(); - }; - tokenTypes[5].updateContext = tokenTypes[7].updateContext = tokenTypes[23].updateContext = context => { - context.push(types.brace); - }; - tokenTypes[22].updateContext = context => { - if (context[context.length - 1] === types.template) { - context.pop(); - } else { - context.push(types.template); - } - }; - tokenTypes[142].updateContext = context => { - context.push(types.j_expr, types.j_oTag); - }; -} -let nonASCIIidentifierStartChars = "\xaa\xb5\xba\xc0-\xd6\xd8-\xf6\xf8-\u02c1\u02c6-\u02d1\u02e0-\u02e4\u02ec\u02ee\u0370-\u0374\u0376\u0377\u037a-\u037d\u037f\u0386\u0388-\u038a\u038c\u038e-\u03a1\u03a3-\u03f5\u03f7-\u0481\u048a-\u052f\u0531-\u0556\u0559\u0560-\u0588\u05d0-\u05ea\u05ef-\u05f2\u0620-\u064a\u066e\u066f\u0671-\u06d3\u06d5\u06e5\u06e6\u06ee\u06ef\u06fa-\u06fc\u06ff\u0710\u0712-\u072f\u074d-\u07a5\u07b1\u07ca-\u07ea\u07f4\u07f5\u07fa\u0800-\u0815\u081a\u0824\u0828\u0840-\u0858\u0860-\u086a\u0870-\u0887\u0889-\u088e\u08a0-\u08c9\u0904-\u0939\u093d\u0950\u0958-\u0961\u0971-\u0980\u0985-\u098c\u098f\u0990\u0993-\u09a8\u09aa-\u09b0\u09b2\u09b6-\u09b9\u09bd\u09ce\u09dc\u09dd\u09df-\u09e1\u09f0\u09f1\u09fc\u0a05-\u0a0a\u0a0f\u0a10\u0a13-\u0a28\u0a2a-\u0a30\u0a32\u0a33\u0a35\u0a36\u0a38\u0a39\u0a59-\u0a5c\u0a5e\u0a72-\u0a74\u0a85-\u0a8d\u0a8f-\u0a91\u0a93-\u0aa8\u0aaa-\u0ab0\u0ab2\u0ab3\u0ab5-\u0ab9\u0abd\u0ad0\u0ae0\u0ae1\u0af9\u0b05-\u0b0c\u0b0f\u0b10\u0b13-\u0b28\u0b2a-\u0b30\u0b32\u0b33\u0b35-\u0b39\u0b3d\u0b5c\u0b5d\u0b5f-\u0b61\u0b71\u0b83\u0b85-\u0b8a\u0b8e-\u0b90\u0b92-\u0b95\u0b99\u0b9a\u0b9c\u0b9e\u0b9f\u0ba3\u0ba4\u0ba8-\u0baa\u0bae-\u0bb9\u0bd0\u0c05-\u0c0c\u0c0e-\u0c10\u0c12-\u0c28\u0c2a-\u0c39\u0c3d\u0c58-\u0c5a\u0c5d\u0c60\u0c61\u0c80\u0c85-\u0c8c\u0c8e-\u0c90\u0c92-\u0ca8\u0caa-\u0cb3\u0cb5-\u0cb9\u0cbd\u0cdd\u0cde\u0ce0\u0ce1\u0cf1\u0cf2\u0d04-\u0d0c\u0d0e-\u0d10\u0d12-\u0d3a\u0d3d\u0d4e\u0d54-\u0d56\u0d5f-\u0d61\u0d7a-\u0d7f\u0d85-\u0d96\u0d9a-\u0db1\u0db3-\u0dbb\u0dbd\u0dc0-\u0dc6\u0e01-\u0e30\u0e32\u0e33\u0e40-\u0e46\u0e81\u0e82\u0e84\u0e86-\u0e8a\u0e8c-\u0ea3\u0ea5\u0ea7-\u0eb0\u0eb2\u0eb3\u0ebd\u0ec0-\u0ec4\u0ec6\u0edc-\u0edf\u0f00\u0f40-\u0f47\u0f49-\u0f6c\u0f88-\u0f8c\u1000-\u102a\u103f\u1050-\u1055\u105a-\u105d\u1061\u1065\u1066\u106e-\u1070\u1075-\u1081\u108e\u10a0-\u10c5\u10c7\u10cd\u10d0-\u10fa\u10fc-\u1248\u124a-\u124d\u1250-\u1256\u1258\u125a-\u125d\u1260-\u1288\u128a-\u128d\u1290-\u12b0\u12b2-\u12b5\u12b8-\u12be\u12c0\u12c2-\u12c5\u12c8-\u12d6\u12d8-\u1310\u1312-\u1315\u1318-\u135a\u1380-\u138f\u13a0-\u13f5\u13f8-\u13fd\u1401-\u166c\u166f-\u167f\u1681-\u169a\u16a0-\u16ea\u16ee-\u16f8\u1700-\u1711\u171f-\u1731\u1740-\u1751\u1760-\u176c\u176e-\u1770\u1780-\u17b3\u17d7\u17dc\u1820-\u1878\u1880-\u18a8\u18aa\u18b0-\u18f5\u1900-\u191e\u1950-\u196d\u1970-\u1974\u1980-\u19ab\u19b0-\u19c9\u1a00-\u1a16\u1a20-\u1a54\u1aa7\u1b05-\u1b33\u1b45-\u1b4c\u1b83-\u1ba0\u1bae\u1baf\u1bba-\u1be5\u1c00-\u1c23\u1c4d-\u1c4f\u1c5a-\u1c7d\u1c80-\u1c88\u1c90-\u1cba\u1cbd-\u1cbf\u1ce9-\u1cec\u1cee-\u1cf3\u1cf5\u1cf6\u1cfa\u1d00-\u1dbf\u1e00-\u1f15\u1f18-\u1f1d\u1f20-\u1f45\u1f48-\u1f4d\u1f50-\u1f57\u1f59\u1f5b\u1f5d\u1f5f-\u1f7d\u1f80-\u1fb4\u1fb6-\u1fbc\u1fbe\u1fc2-\u1fc4\u1fc6-\u1fcc\u1fd0-\u1fd3\u1fd6-\u1fdb\u1fe0-\u1fec\u1ff2-\u1ff4\u1ff6-\u1ffc\u2071\u207f\u2090-\u209c\u2102\u2107\u210a-\u2113\u2115\u2118-\u211d\u2124\u2126\u2128\u212a-\u2139\u213c-\u213f\u2145-\u2149\u214e\u2160-\u2188\u2c00-\u2ce4\u2ceb-\u2cee\u2cf2\u2cf3\u2d00-\u2d25\u2d27\u2d2d\u2d30-\u2d67\u2d6f\u2d80-\u2d96\u2da0-\u2da6\u2da8-\u2dae\u2db0-\u2db6\u2db8-\u2dbe\u2dc0-\u2dc6\u2dc8-\u2dce\u2dd0-\u2dd6\u2dd8-\u2dde\u3005-\u3007\u3021-\u3029\u3031-\u3035\u3038-\u303c\u3041-\u3096\u309b-\u309f\u30a1-\u30fa\u30fc-\u30ff\u3105-\u312f\u3131-\u318e\u31a0-\u31bf\u31f0-\u31ff\u3400-\u4dbf\u4e00-\ua48c\ua4d0-\ua4fd\ua500-\ua60c\ua610-\ua61f\ua62a\ua62b\ua640-\ua66e\ua67f-\ua69d\ua6a0-\ua6ef\ua717-\ua71f\ua722-\ua788\ua78b-\ua7ca\ua7d0\ua7d1\ua7d3\ua7d5-\ua7d9\ua7f2-\ua801\ua803-\ua805\ua807-\ua80a\ua80c-\ua822\ua840-\ua873\ua882-\ua8b3\ua8f2-\ua8f7\ua8fb\ua8fd\ua8fe\ua90a-\ua925\ua930-\ua946\ua960-\ua97c\ua984-\ua9b2\ua9cf\ua9e0-\ua9e4\ua9e6-\ua9ef\ua9fa-\ua9fe\uaa00-\uaa28\uaa40-\uaa42\uaa44-\uaa4b\uaa60-\uaa76\uaa7a\uaa7e-\uaaaf\uaab1\uaab5\uaab6\uaab9-\uaabd\uaac0\uaac2\uaadb-\uaadd\uaae0-\uaaea\uaaf2-\uaaf4\uab01-\uab06\uab09-\uab0e\uab11-\uab16\uab20-\uab26\uab28-\uab2e\uab30-\uab5a\uab5c-\uab69\uab70-\uabe2\uac00-\ud7a3\ud7b0-\ud7c6\ud7cb-\ud7fb\uf900-\ufa6d\ufa70-\ufad9\ufb00-\ufb06\ufb13-\ufb17\ufb1d\ufb1f-\ufb28\ufb2a-\ufb36\ufb38-\ufb3c\ufb3e\ufb40\ufb41\ufb43\ufb44\ufb46-\ufbb1\ufbd3-\ufd3d\ufd50-\ufd8f\ufd92-\ufdc7\ufdf0-\ufdfb\ufe70-\ufe74\ufe76-\ufefc\uff21-\uff3a\uff41-\uff5a\uff66-\uffbe\uffc2-\uffc7\uffca-\uffcf\uffd2-\uffd7\uffda-\uffdc"; -let nonASCIIidentifierChars = "\u200c\u200d\xb7\u0300-\u036f\u0387\u0483-\u0487\u0591-\u05bd\u05bf\u05c1\u05c2\u05c4\u05c5\u05c7\u0610-\u061a\u064b-\u0669\u0670\u06d6-\u06dc\u06df-\u06e4\u06e7\u06e8\u06ea-\u06ed\u06f0-\u06f9\u0711\u0730-\u074a\u07a6-\u07b0\u07c0-\u07c9\u07eb-\u07f3\u07fd\u0816-\u0819\u081b-\u0823\u0825-\u0827\u0829-\u082d\u0859-\u085b\u0898-\u089f\u08ca-\u08e1\u08e3-\u0903\u093a-\u093c\u093e-\u094f\u0951-\u0957\u0962\u0963\u0966-\u096f\u0981-\u0983\u09bc\u09be-\u09c4\u09c7\u09c8\u09cb-\u09cd\u09d7\u09e2\u09e3\u09e6-\u09ef\u09fe\u0a01-\u0a03\u0a3c\u0a3e-\u0a42\u0a47\u0a48\u0a4b-\u0a4d\u0a51\u0a66-\u0a71\u0a75\u0a81-\u0a83\u0abc\u0abe-\u0ac5\u0ac7-\u0ac9\u0acb-\u0acd\u0ae2\u0ae3\u0ae6-\u0aef\u0afa-\u0aff\u0b01-\u0b03\u0b3c\u0b3e-\u0b44\u0b47\u0b48\u0b4b-\u0b4d\u0b55-\u0b57\u0b62\u0b63\u0b66-\u0b6f\u0b82\u0bbe-\u0bc2\u0bc6-\u0bc8\u0bca-\u0bcd\u0bd7\u0be6-\u0bef\u0c00-\u0c04\u0c3c\u0c3e-\u0c44\u0c46-\u0c48\u0c4a-\u0c4d\u0c55\u0c56\u0c62\u0c63\u0c66-\u0c6f\u0c81-\u0c83\u0cbc\u0cbe-\u0cc4\u0cc6-\u0cc8\u0cca-\u0ccd\u0cd5\u0cd6\u0ce2\u0ce3\u0ce6-\u0cef\u0cf3\u0d00-\u0d03\u0d3b\u0d3c\u0d3e-\u0d44\u0d46-\u0d48\u0d4a-\u0d4d\u0d57\u0d62\u0d63\u0d66-\u0d6f\u0d81-\u0d83\u0dca\u0dcf-\u0dd4\u0dd6\u0dd8-\u0ddf\u0de6-\u0def\u0df2\u0df3\u0e31\u0e34-\u0e3a\u0e47-\u0e4e\u0e50-\u0e59\u0eb1\u0eb4-\u0ebc\u0ec8-\u0ece\u0ed0-\u0ed9\u0f18\u0f19\u0f20-\u0f29\u0f35\u0f37\u0f39\u0f3e\u0f3f\u0f71-\u0f84\u0f86\u0f87\u0f8d-\u0f97\u0f99-\u0fbc\u0fc6\u102b-\u103e\u1040-\u1049\u1056-\u1059\u105e-\u1060\u1062-\u1064\u1067-\u106d\u1071-\u1074\u1082-\u108d\u108f-\u109d\u135d-\u135f\u1369-\u1371\u1712-\u1715\u1732-\u1734\u1752\u1753\u1772\u1773\u17b4-\u17d3\u17dd\u17e0-\u17e9\u180b-\u180d\u180f-\u1819\u18a9\u1920-\u192b\u1930-\u193b\u1946-\u194f\u19d0-\u19da\u1a17-\u1a1b\u1a55-\u1a5e\u1a60-\u1a7c\u1a7f-\u1a89\u1a90-\u1a99\u1ab0-\u1abd\u1abf-\u1ace\u1b00-\u1b04\u1b34-\u1b44\u1b50-\u1b59\u1b6b-\u1b73\u1b80-\u1b82\u1ba1-\u1bad\u1bb0-\u1bb9\u1be6-\u1bf3\u1c24-\u1c37\u1c40-\u1c49\u1c50-\u1c59\u1cd0-\u1cd2\u1cd4-\u1ce8\u1ced\u1cf4\u1cf7-\u1cf9\u1dc0-\u1dff\u200c\u200d\u203f\u2040\u2054\u20d0-\u20dc\u20e1\u20e5-\u20f0\u2cef-\u2cf1\u2d7f\u2de0-\u2dff\u302a-\u302f\u3099\u309a\u30fb\ua620-\ua629\ua66f\ua674-\ua67d\ua69e\ua69f\ua6f0\ua6f1\ua802\ua806\ua80b\ua823-\ua827\ua82c\ua880\ua881\ua8b4-\ua8c5\ua8d0-\ua8d9\ua8e0-\ua8f1\ua8ff-\ua909\ua926-\ua92d\ua947-\ua953\ua980-\ua983\ua9b3-\ua9c0\ua9d0-\ua9d9\ua9e5\ua9f0-\ua9f9\uaa29-\uaa36\uaa43\uaa4c\uaa4d\uaa50-\uaa59\uaa7b-\uaa7d\uaab0\uaab2-\uaab4\uaab7\uaab8\uaabe\uaabf\uaac1\uaaeb-\uaaef\uaaf5\uaaf6\uabe3-\uabea\uabec\uabed\uabf0-\uabf9\ufb1e\ufe00-\ufe0f\ufe20-\ufe2f\ufe33\ufe34\ufe4d-\ufe4f\uff10-\uff19\uff3f\uff65"; -const nonASCIIidentifierStart = new RegExp("[" + nonASCIIidentifierStartChars + "]"); -const nonASCIIidentifier = new RegExp("[" + nonASCIIidentifierStartChars + nonASCIIidentifierChars + "]"); -nonASCIIidentifierStartChars = nonASCIIidentifierChars = null; -const astralIdentifierStartCodes = [0, 11, 2, 25, 2, 18, 2, 1, 2, 14, 3, 13, 35, 122, 70, 52, 268, 28, 4, 48, 48, 31, 14, 29, 6, 37, 11, 29, 3, 35, 5, 7, 2, 4, 43, 157, 19, 35, 5, 35, 5, 39, 9, 51, 13, 10, 2, 14, 2, 6, 2, 1, 2, 10, 2, 14, 2, 6, 2, 1, 68, 310, 10, 21, 11, 7, 25, 5, 2, 41, 2, 8, 70, 5, 3, 0, 2, 43, 2, 1, 4, 0, 3, 22, 11, 22, 10, 30, 66, 18, 2, 1, 11, 21, 11, 25, 71, 55, 7, 1, 65, 0, 16, 3, 2, 2, 2, 28, 43, 28, 4, 28, 36, 7, 2, 27, 28, 53, 11, 21, 11, 18, 14, 17, 111, 72, 56, 50, 14, 50, 14, 35, 349, 41, 7, 1, 79, 28, 11, 0, 9, 21, 43, 17, 47, 20, 28, 22, 13, 52, 58, 1, 3, 0, 14, 44, 33, 24, 27, 35, 30, 0, 3, 0, 9, 34, 4, 0, 13, 47, 15, 3, 22, 0, 2, 0, 36, 17, 2, 24, 20, 1, 64, 6, 2, 0, 2, 3, 2, 14, 2, 9, 8, 46, 39, 7, 3, 1, 3, 21, 2, 6, 2, 1, 2, 4, 4, 0, 19, 0, 13, 4, 159, 52, 19, 3, 21, 2, 31, 47, 21, 1, 2, 0, 185, 46, 42, 3, 37, 47, 21, 0, 60, 42, 14, 0, 72, 26, 38, 6, 186, 43, 117, 63, 32, 7, 3, 0, 3, 7, 2, 1, 2, 23, 16, 0, 2, 0, 95, 7, 3, 38, 17, 0, 2, 0, 29, 0, 11, 39, 8, 0, 22, 0, 12, 45, 20, 0, 19, 72, 264, 8, 2, 36, 18, 0, 50, 29, 113, 6, 2, 1, 2, 37, 22, 0, 26, 5, 2, 1, 2, 31, 15, 0, 328, 18, 16, 0, 2, 12, 2, 33, 125, 0, 80, 921, 103, 110, 18, 195, 2637, 96, 16, 1071, 18, 5, 4026, 582, 8634, 568, 8, 30, 18, 78, 18, 29, 19, 47, 17, 3, 32, 20, 6, 18, 689, 63, 129, 74, 6, 0, 67, 12, 65, 1, 2, 0, 29, 6135, 9, 1237, 43, 8, 8936, 3, 2, 6, 2, 1, 2, 290, 16, 0, 30, 2, 3, 0, 15, 3, 9, 395, 2309, 106, 6, 12, 4, 8, 8, 9, 5991, 84, 2, 70, 2, 1, 3, 0, 3, 1, 3, 3, 2, 11, 2, 0, 2, 6, 2, 64, 2, 3, 3, 7, 2, 6, 2, 27, 2, 3, 2, 4, 2, 0, 4, 6, 2, 339, 3, 24, 2, 24, 2, 30, 2, 24, 2, 30, 2, 24, 2, 30, 2, 24, 2, 30, 2, 24, 2, 7, 1845, 30, 7, 5, 262, 61, 147, 44, 11, 6, 17, 0, 322, 29, 19, 43, 485, 27, 757, 6, 2, 3, 2, 1, 2, 14, 2, 196, 60, 67, 8, 0, 1205, 3, 2, 26, 2, 1, 2, 0, 3, 0, 2, 9, 2, 3, 2, 0, 2, 0, 7, 0, 5, 0, 2, 0, 2, 0, 2, 2, 2, 1, 2, 0, 3, 0, 2, 0, 2, 0, 2, 0, 2, 0, 2, 1, 2, 0, 3, 3, 2, 6, 2, 3, 2, 3, 2, 0, 2, 9, 2, 16, 6, 2, 2, 4, 2, 16, 4421, 42719, 33, 4153, 7, 221, 3, 5761, 15, 7472, 16, 621, 2467, 541, 1507, 4938, 6, 4191]; -const astralIdentifierCodes = [509, 0, 227, 0, 150, 4, 294, 9, 1368, 2, 2, 1, 6, 3, 41, 2, 5, 0, 166, 1, 574, 3, 9, 9, 370, 1, 81, 2, 71, 10, 50, 3, 123, 2, 54, 14, 32, 10, 3, 1, 11, 3, 46, 10, 8, 0, 46, 9, 7, 2, 37, 13, 2, 9, 6, 1, 45, 0, 13, 2, 49, 13, 9, 3, 2, 11, 83, 11, 7, 0, 3, 0, 158, 11, 6, 9, 7, 3, 56, 1, 2, 6, 3, 1, 3, 2, 10, 0, 11, 1, 3, 6, 4, 4, 193, 17, 10, 9, 5, 0, 82, 19, 13, 9, 214, 6, 3, 8, 28, 1, 83, 16, 16, 9, 82, 12, 9, 9, 84, 14, 5, 9, 243, 14, 166, 9, 71, 5, 2, 1, 3, 3, 2, 0, 2, 1, 13, 9, 120, 6, 3, 6, 4, 0, 29, 9, 41, 6, 2, 3, 9, 0, 10, 10, 47, 15, 406, 7, 2, 7, 17, 9, 57, 21, 2, 13, 123, 5, 4, 0, 2, 1, 2, 6, 2, 0, 9, 9, 49, 4, 2, 1, 2, 4, 9, 9, 330, 3, 10, 1, 2, 0, 49, 6, 4, 4, 14, 9, 5351, 0, 7, 14, 13835, 9, 87, 9, 39, 4, 60, 6, 26, 9, 1014, 0, 2, 54, 8, 3, 82, 0, 12, 1, 19628, 1, 4706, 45, 3, 22, 543, 4, 4, 5, 9, 7, 3, 6, 31, 3, 149, 2, 1418, 49, 513, 54, 5, 49, 9, 0, 15, 0, 23, 4, 2, 14, 1361, 6, 2, 16, 3, 6, 2, 1, 2, 4, 101, 0, 161, 6, 10, 9, 357, 0, 62, 13, 499, 13, 983, 6, 110, 6, 6, 9, 4759, 9, 787719, 239]; -function isInAstralSet(code, set) { - let pos = 0x10000; - for (let i = 0, length = set.length; i < length; i += 2) { - pos += set[i]; - if (pos > code) return false; - pos += set[i + 1]; - if (pos >= code) return true; - } - return false; -} -function isIdentifierStart(code) { - if (code < 65) return code === 36; - if (code <= 90) return true; - if (code < 97) return code === 95; - if (code <= 122) return true; - if (code <= 0xffff) { - return code >= 0xaa && nonASCIIidentifierStart.test(String.fromCharCode(code)); - } - return isInAstralSet(code, astralIdentifierStartCodes); -} -function isIdentifierChar(code) { - if (code < 48) return code === 36; - if (code < 58) return true; - if (code < 65) return false; - if (code <= 90) return true; - if (code < 97) return code === 95; - if (code <= 122) return true; - if (code <= 0xffff) { - return code >= 0xaa && nonASCIIidentifier.test(String.fromCharCode(code)); - } - return isInAstralSet(code, astralIdentifierStartCodes) || isInAstralSet(code, astralIdentifierCodes); -} -const reservedWords = { - keyword: ["break", "case", "catch", "continue", "debugger", "default", "do", "else", "finally", "for", "function", "if", "return", "switch", "throw", "try", "var", "const", "while", "with", "new", "this", "super", "class", "extends", "export", "import", "null", "true", "false", "in", "instanceof", "typeof", "void", "delete"], - strict: ["implements", "interface", "let", "package", "private", "protected", "public", "static", "yield"], - strictBind: ["eval", "arguments"] -}; -const keywords = new Set(reservedWords.keyword); -const reservedWordsStrictSet = new Set(reservedWords.strict); -const reservedWordsStrictBindSet = new Set(reservedWords.strictBind); -function isReservedWord(word, inModule) { - return inModule && word === "await" || word === "enum"; -} -function isStrictReservedWord(word, inModule) { - return isReservedWord(word, inModule) || reservedWordsStrictSet.has(word); -} -function isStrictBindOnlyReservedWord(word) { - return reservedWordsStrictBindSet.has(word); -} -function isStrictBindReservedWord(word, inModule) { - return isStrictReservedWord(word, inModule) || isStrictBindOnlyReservedWord(word); -} -function isKeyword(word) { - return keywords.has(word); -} -function isIteratorStart(current, next, next2) { - return current === 64 && next === 64 && isIdentifierStart(next2); -} -const reservedWordLikeSet = new Set(["break", "case", "catch", "continue", "debugger", "default", "do", "else", "finally", "for", "function", "if", "return", "switch", "throw", "try", "var", "const", "while", "with", "new", "this", "super", "class", "extends", "export", "import", "null", "true", "false", "in", "instanceof", "typeof", "void", "delete", "implements", "interface", "let", "package", "private", "protected", "public", "static", "yield", "eval", "arguments", "enum", "await"]); -function canBeReservedWord(word) { - return reservedWordLikeSet.has(word); -} -class Scope { - constructor(flags) { - this.flags = 0; - this.names = new Map(); - this.firstLexicalName = ""; - this.flags = flags; - } -} -class ScopeHandler { - constructor(parser, inModule) { - this.parser = void 0; - this.scopeStack = []; - this.inModule = void 0; - this.undefinedExports = new Map(); - this.parser = parser; - this.inModule = inModule; - } - get inTopLevel() { - return (this.currentScope().flags & 1) > 0; - } - get inFunction() { - return (this.currentVarScopeFlags() & 2) > 0; - } - get allowSuper() { - return (this.currentThisScopeFlags() & 16) > 0; - } - get allowDirectSuper() { - return (this.currentThisScopeFlags() & 32) > 0; - } - get inClass() { - return (this.currentThisScopeFlags() & 64) > 0; - } - get inClassAndNotInNonArrowFunction() { - const flags = this.currentThisScopeFlags(); - return (flags & 64) > 0 && (flags & 2) === 0; - } - get inStaticBlock() { - for (let i = this.scopeStack.length - 1;; i--) { - const { - flags - } = this.scopeStack[i]; - if (flags & 128) { - return true; - } - if (flags & (387 | 64)) { - return false; - } - } - } - get inNonArrowFunction() { - return (this.currentThisScopeFlags() & 2) > 0; - } - get treatFunctionsAsVar() { - return this.treatFunctionsAsVarInScope(this.currentScope()); - } - createScope(flags) { - return new Scope(flags); - } - enter(flags) { - this.scopeStack.push(this.createScope(flags)); - } - exit() { - const scope = this.scopeStack.pop(); - return scope.flags; - } - treatFunctionsAsVarInScope(scope) { - return !!(scope.flags & (2 | 128) || !this.parser.inModule && scope.flags & 1); - } - declareName(name, bindingType, loc) { - let scope = this.currentScope(); - if (bindingType & 8 || bindingType & 16) { - this.checkRedeclarationInScope(scope, name, bindingType, loc); - let type = scope.names.get(name) || 0; - if (bindingType & 16) { - type = type | 4; - } else { - if (!scope.firstLexicalName) { - scope.firstLexicalName = name; - } - type = type | 2; - } - scope.names.set(name, type); - if (bindingType & 8) { - this.maybeExportDefined(scope, name); - } - } else if (bindingType & 4) { - for (let i = this.scopeStack.length - 1; i >= 0; --i) { - scope = this.scopeStack[i]; - this.checkRedeclarationInScope(scope, name, bindingType, loc); - scope.names.set(name, (scope.names.get(name) || 0) | 1); - this.maybeExportDefined(scope, name); - if (scope.flags & 387) break; - } - } - if (this.parser.inModule && scope.flags & 1) { - this.undefinedExports.delete(name); - } - } - maybeExportDefined(scope, name) { - if (this.parser.inModule && scope.flags & 1) { - this.undefinedExports.delete(name); - } - } - checkRedeclarationInScope(scope, name, bindingType, loc) { - if (this.isRedeclaredInScope(scope, name, bindingType)) { - this.parser.raise(Errors.VarRedeclaration, loc, { - identifierName: name - }); - } - } - isRedeclaredInScope(scope, name, bindingType) { - if (!(bindingType & 1)) return false; - if (bindingType & 8) { - return scope.names.has(name); - } - const type = scope.names.get(name); - if (bindingType & 16) { - return (type & 2) > 0 || !this.treatFunctionsAsVarInScope(scope) && (type & 1) > 0; - } - return (type & 2) > 0 && !(scope.flags & 8 && scope.firstLexicalName === name) || !this.treatFunctionsAsVarInScope(scope) && (type & 4) > 0; - } - checkLocalExport(id) { - const { - name - } = id; - const topLevelScope = this.scopeStack[0]; - if (!topLevelScope.names.has(name)) { - this.undefinedExports.set(name, id.loc.start); - } - } - currentScope() { - return this.scopeStack[this.scopeStack.length - 1]; - } - currentVarScopeFlags() { - for (let i = this.scopeStack.length - 1;; i--) { - const { - flags - } = this.scopeStack[i]; - if (flags & 387) { - return flags; - } - } - } - currentThisScopeFlags() { - for (let i = this.scopeStack.length - 1;; i--) { - const { - flags - } = this.scopeStack[i]; - if (flags & (387 | 64) && !(flags & 4)) { - return flags; - } - } - } -} -class FlowScope extends Scope { - constructor(...args) { - super(...args); - this.declareFunctions = new Set(); - } -} -class FlowScopeHandler extends ScopeHandler { - createScope(flags) { - return new FlowScope(flags); - } - declareName(name, bindingType, loc) { - const scope = this.currentScope(); - if (bindingType & 2048) { - this.checkRedeclarationInScope(scope, name, bindingType, loc); - this.maybeExportDefined(scope, name); - scope.declareFunctions.add(name); - return; - } - super.declareName(name, bindingType, loc); - } - isRedeclaredInScope(scope, name, bindingType) { - if (super.isRedeclaredInScope(scope, name, bindingType)) return true; - if (bindingType & 2048 && !scope.declareFunctions.has(name)) { - const type = scope.names.get(name); - return (type & 4) > 0 || (type & 2) > 0; - } - return false; - } - checkLocalExport(id) { - if (!this.scopeStack[0].declareFunctions.has(id.name)) { - super.checkLocalExport(id); - } - } -} -class BaseParser { - constructor() { - this.sawUnambiguousESM = false; - this.ambiguousScriptDifferentAst = false; - } - hasPlugin(pluginConfig) { - if (typeof pluginConfig === "string") { - return this.plugins.has(pluginConfig); - } else { - const [pluginName, pluginOptions] = pluginConfig; - if (!this.hasPlugin(pluginName)) { - return false; - } - const actualOptions = this.plugins.get(pluginName); - for (const key of Object.keys(pluginOptions)) { - if ((actualOptions == null ? void 0 : actualOptions[key]) !== pluginOptions[key]) { - return false; - } - } - return true; - } - } - getPluginOption(plugin, name) { - var _this$plugins$get; - return (_this$plugins$get = this.plugins.get(plugin)) == null ? void 0 : _this$plugins$get[name]; - } -} -function setTrailingComments(node, comments) { - if (node.trailingComments === undefined) { - node.trailingComments = comments; - } else { - node.trailingComments.unshift(...comments); - } -} -function setLeadingComments(node, comments) { - if (node.leadingComments === undefined) { - node.leadingComments = comments; - } else { - node.leadingComments.unshift(...comments); - } -} -function setInnerComments(node, comments) { - if (node.innerComments === undefined) { - node.innerComments = comments; - } else { - node.innerComments.unshift(...comments); - } -} -function adjustInnerComments(node, elements, commentWS) { - let lastElement = null; - let i = elements.length; - while (lastElement === null && i > 0) { - lastElement = elements[--i]; - } - if (lastElement === null || lastElement.start > commentWS.start) { - setInnerComments(node, commentWS.comments); - } else { - setTrailingComments(lastElement, commentWS.comments); - } -} -class CommentsParser extends BaseParser { - addComment(comment) { - if (this.filename) comment.loc.filename = this.filename; - const { - commentsLen - } = this.state; - if (this.comments.length !== commentsLen) { - this.comments.length = commentsLen; - } - this.comments.push(comment); - this.state.commentsLen++; - } - processComment(node) { - const { - commentStack - } = this.state; - const commentStackLength = commentStack.length; - if (commentStackLength === 0) return; - let i = commentStackLength - 1; - const lastCommentWS = commentStack[i]; - if (lastCommentWS.start === node.end) { - lastCommentWS.leadingNode = node; - i--; - } - const { - start: nodeStart - } = node; - for (; i >= 0; i--) { - const commentWS = commentStack[i]; - const commentEnd = commentWS.end; - if (commentEnd > nodeStart) { - commentWS.containingNode = node; - this.finalizeComment(commentWS); - commentStack.splice(i, 1); - } else { - if (commentEnd === nodeStart) { - commentWS.trailingNode = node; - } - break; - } - } - } - finalizeComment(commentWS) { - const { - comments - } = commentWS; - if (commentWS.leadingNode !== null || commentWS.trailingNode !== null) { - if (commentWS.leadingNode !== null) { - setTrailingComments(commentWS.leadingNode, comments); - } - if (commentWS.trailingNode !== null) { - setLeadingComments(commentWS.trailingNode, comments); - } - } else { - const { - containingNode: node, - start: commentStart - } = commentWS; - if (this.input.charCodeAt(commentStart - 1) === 44) { - switch (node.type) { - case "ObjectExpression": - case "ObjectPattern": - case "RecordExpression": - adjustInnerComments(node, node.properties, commentWS); - break; - case "CallExpression": - case "OptionalCallExpression": - adjustInnerComments(node, node.arguments, commentWS); - break; - case "FunctionDeclaration": - case "FunctionExpression": - case "ArrowFunctionExpression": - case "ObjectMethod": - case "ClassMethod": - case "ClassPrivateMethod": - adjustInnerComments(node, node.params, commentWS); - break; - case "ArrayExpression": - case "ArrayPattern": - case "TupleExpression": - adjustInnerComments(node, node.elements, commentWS); - break; - case "ExportNamedDeclaration": - case "ImportDeclaration": - adjustInnerComments(node, node.specifiers, commentWS); - break; - default: - { - setInnerComments(node, comments); - } - } - } else { - setInnerComments(node, comments); - } - } - } - finalizeRemainingComments() { - const { - commentStack - } = this.state; - for (let i = commentStack.length - 1; i >= 0; i--) { - this.finalizeComment(commentStack[i]); - } - this.state.commentStack = []; - } - resetPreviousNodeTrailingComments(node) { - const { - commentStack - } = this.state; - const { - length - } = commentStack; - if (length === 0) return; - const commentWS = commentStack[length - 1]; - if (commentWS.leadingNode === node) { - commentWS.leadingNode = null; - } - } - resetPreviousIdentifierLeadingComments(node) { - const { - commentStack - } = this.state; - const { - length - } = commentStack; - if (length === 0) return; - if (commentStack[length - 1].trailingNode === node) { - commentStack[length - 1].trailingNode = null; - } else if (length >= 2 && commentStack[length - 2].trailingNode === node) { - commentStack[length - 2].trailingNode = null; - } - } - takeSurroundingComments(node, start, end) { - const { - commentStack - } = this.state; - const commentStackLength = commentStack.length; - if (commentStackLength === 0) return; - let i = commentStackLength - 1; - for (; i >= 0; i--) { - const commentWS = commentStack[i]; - const commentEnd = commentWS.end; - const commentStart = commentWS.start; - if (commentStart === end) { - commentWS.leadingNode = node; - } else if (commentEnd === start) { - commentWS.trailingNode = node; - } else if (commentEnd < start) { - break; - } - } - } -} -const lineBreak = /\r\n?|[\n\u2028\u2029]/; -const lineBreakG = new RegExp(lineBreak.source, "g"); -function isNewLine(code) { - switch (code) { - case 10: - case 13: - case 8232: - case 8233: - return true; - default: - return false; - } -} -const skipWhiteSpace = /(?:\s|\/\/.*|\/\*[^]*?\*\/)*/g; -const skipWhiteSpaceInLine = /(?:[^\S\n\r\u2028\u2029]|\/\/.*|\/\*.*?\*\/)*/g; -const skipWhiteSpaceToLineBreak = new RegExp("(?=(" + skipWhiteSpaceInLine.source + "))\\1" + /(?=[\n\r\u2028\u2029]|\/\*(?!.*?\*\/)|$)/.source, "y"); -function isWhitespace(code) { - switch (code) { - case 0x0009: - case 0x000b: - case 0x000c: - case 32: - case 160: - case 5760: - case 0x2000: - case 0x2001: - case 0x2002: - case 0x2003: - case 0x2004: - case 0x2005: - case 0x2006: - case 0x2007: - case 0x2008: - case 0x2009: - case 0x200a: - case 0x202f: - case 0x205f: - case 0x3000: - case 0xfeff: - return true; - default: - return false; - } -} -class State { - constructor() { - this.flags = 1024; - this.curLine = void 0; - this.lineStart = void 0; - this.startLoc = void 0; - this.endLoc = void 0; - this.errors = []; - this.potentialArrowAt = -1; - this.noArrowAt = []; - this.noArrowParamsConversionAt = []; - this.topicContext = { - maxNumOfResolvableTopics: 0, - maxTopicIndex: null - }; - this.labels = []; - this.commentsLen = 0; - this.commentStack = []; - this.pos = 0; - this.type = 139; - this.value = null; - this.start = 0; - this.end = 0; - this.lastTokEndLoc = null; - this.lastTokStartLoc = null; - this.context = [types.brace]; - this.firstInvalidTemplateEscapePos = null; - this.strictErrors = new Map(); - this.tokensLength = 0; - } - get strict() { - return (this.flags & 1) > 0; - } - set strict(v) { - if (v) this.flags |= 1;else this.flags &= -2; - } - init({ - strictMode, - sourceType, - startLine, - startColumn - }) { - this.strict = strictMode === false ? false : strictMode === true ? true : sourceType === "module"; - this.curLine = startLine; - this.lineStart = -startColumn; - this.startLoc = this.endLoc = new Position(startLine, startColumn, 0); - } - get maybeInArrowParameters() { - return (this.flags & 2) > 0; - } - set maybeInArrowParameters(v) { - if (v) this.flags |= 2;else this.flags &= -3; - } - get inType() { - return (this.flags & 4) > 0; - } - set inType(v) { - if (v) this.flags |= 4;else this.flags &= -5; - } - get noAnonFunctionType() { - return (this.flags & 8) > 0; - } - set noAnonFunctionType(v) { - if (v) this.flags |= 8;else this.flags &= -9; - } - get hasFlowComment() { - return (this.flags & 16) > 0; - } - set hasFlowComment(v) { - if (v) this.flags |= 16;else this.flags &= -17; - } - get isAmbientContext() { - return (this.flags & 32) > 0; - } - set isAmbientContext(v) { - if (v) this.flags |= 32;else this.flags &= -33; - } - get inAbstractClass() { - return (this.flags & 64) > 0; - } - set inAbstractClass(v) { - if (v) this.flags |= 64;else this.flags &= -65; - } - get inDisallowConditionalTypesContext() { - return (this.flags & 128) > 0; - } - set inDisallowConditionalTypesContext(v) { - if (v) this.flags |= 128;else this.flags &= -129; - } - get soloAwait() { - return (this.flags & 256) > 0; - } - set soloAwait(v) { - if (v) this.flags |= 256;else this.flags &= -257; - } - get inFSharpPipelineDirectBody() { - return (this.flags & 512) > 0; - } - set inFSharpPipelineDirectBody(v) { - if (v) this.flags |= 512;else this.flags &= -513; - } - get canStartJSXElement() { - return (this.flags & 1024) > 0; - } - set canStartJSXElement(v) { - if (v) this.flags |= 1024;else this.flags &= -1025; - } - get containsEsc() { - return (this.flags & 2048) > 0; - } - set containsEsc(v) { - if (v) this.flags |= 2048;else this.flags &= -2049; - } - curPosition() { - return new Position(this.curLine, this.pos - this.lineStart, this.pos); - } - clone() { - const state = new State(); - state.flags = this.flags; - state.curLine = this.curLine; - state.lineStart = this.lineStart; - state.startLoc = this.startLoc; - state.endLoc = this.endLoc; - state.errors = this.errors.slice(); - state.potentialArrowAt = this.potentialArrowAt; - state.noArrowAt = this.noArrowAt.slice(); - state.noArrowParamsConversionAt = this.noArrowParamsConversionAt.slice(); - state.topicContext = this.topicContext; - state.labels = this.labels.slice(); - state.commentsLen = this.commentsLen; - state.commentStack = this.commentStack.slice(); - state.pos = this.pos; - state.type = this.type; - state.value = this.value; - state.start = this.start; - state.end = this.end; - state.lastTokEndLoc = this.lastTokEndLoc; - state.lastTokStartLoc = this.lastTokStartLoc; - state.context = this.context.slice(); - state.firstInvalidTemplateEscapePos = this.firstInvalidTemplateEscapePos; - state.strictErrors = this.strictErrors; - state.tokensLength = this.tokensLength; - return state; - } -} -var _isDigit = function isDigit(code) { - return code >= 48 && code <= 57; -}; -const forbiddenNumericSeparatorSiblings = { - decBinOct: new Set([46, 66, 69, 79, 95, 98, 101, 111]), - hex: new Set([46, 88, 95, 120]) -}; -const isAllowedNumericSeparatorSibling = { - bin: ch => ch === 48 || ch === 49, - oct: ch => ch >= 48 && ch <= 55, - dec: ch => ch >= 48 && ch <= 57, - hex: ch => ch >= 48 && ch <= 57 || ch >= 65 && ch <= 70 || ch >= 97 && ch <= 102 -}; -function readStringContents(type, input, pos, lineStart, curLine, errors) { - const initialPos = pos; - const initialLineStart = lineStart; - const initialCurLine = curLine; - let out = ""; - let firstInvalidLoc = null; - let chunkStart = pos; - const { - length - } = input; - for (;;) { - if (pos >= length) { - errors.unterminated(initialPos, initialLineStart, initialCurLine); - out += input.slice(chunkStart, pos); - break; - } - const ch = input.charCodeAt(pos); - if (isStringEnd(type, ch, input, pos)) { - out += input.slice(chunkStart, pos); - break; - } - if (ch === 92) { - out += input.slice(chunkStart, pos); - const res = readEscapedChar(input, pos, lineStart, curLine, type === "template", errors); - if (res.ch === null && !firstInvalidLoc) { - firstInvalidLoc = { - pos, - lineStart, - curLine - }; - } else { - out += res.ch; - } - ({ - pos, - lineStart, - curLine - } = res); - chunkStart = pos; - } else if (ch === 8232 || ch === 8233) { - ++pos; - ++curLine; - lineStart = pos; - } else if (ch === 10 || ch === 13) { - if (type === "template") { - out += input.slice(chunkStart, pos) + "\n"; - ++pos; - if (ch === 13 && input.charCodeAt(pos) === 10) { - ++pos; - } - ++curLine; - chunkStart = lineStart = pos; - } else { - errors.unterminated(initialPos, initialLineStart, initialCurLine); - } - } else { - ++pos; - } - } - return { - pos, - str: out, - firstInvalidLoc, - lineStart, - curLine, - containsInvalid: !!firstInvalidLoc - }; -} -function isStringEnd(type, ch, input, pos) { - if (type === "template") { - return ch === 96 || ch === 36 && input.charCodeAt(pos + 1) === 123; - } - return ch === (type === "double" ? 34 : 39); -} -function readEscapedChar(input, pos, lineStart, curLine, inTemplate, errors) { - const throwOnInvalid = !inTemplate; - pos++; - const res = ch => ({ - pos, - ch, - lineStart, - curLine - }); - const ch = input.charCodeAt(pos++); - switch (ch) { - case 110: - return res("\n"); - case 114: - return res("\r"); - case 120: - { - let code; - ({ - code, - pos - } = readHexChar(input, pos, lineStart, curLine, 2, false, throwOnInvalid, errors)); - return res(code === null ? null : String.fromCharCode(code)); - } - case 117: - { - let code; - ({ - code, - pos - } = readCodePoint(input, pos, lineStart, curLine, throwOnInvalid, errors)); - return res(code === null ? null : String.fromCodePoint(code)); - } - case 116: - return res("\t"); - case 98: - return res("\b"); - case 118: - return res("\u000b"); - case 102: - return res("\f"); - case 13: - if (input.charCodeAt(pos) === 10) { - ++pos; - } - case 10: - lineStart = pos; - ++curLine; - case 8232: - case 8233: - return res(""); - case 56: - case 57: - if (inTemplate) { - return res(null); - } else { - errors.strictNumericEscape(pos - 1, lineStart, curLine); - } - default: - if (ch >= 48 && ch <= 55) { - const startPos = pos - 1; - const match = /^[0-7]+/.exec(input.slice(startPos, pos + 2)); - let octalStr = match[0]; - let octal = parseInt(octalStr, 8); - if (octal > 255) { - octalStr = octalStr.slice(0, -1); - octal = parseInt(octalStr, 8); - } - pos += octalStr.length - 1; - const next = input.charCodeAt(pos); - if (octalStr !== "0" || next === 56 || next === 57) { - if (inTemplate) { - return res(null); - } else { - errors.strictNumericEscape(startPos, lineStart, curLine); - } - } - return res(String.fromCharCode(octal)); - } - return res(String.fromCharCode(ch)); - } -} -function readHexChar(input, pos, lineStart, curLine, len, forceLen, throwOnInvalid, errors) { - const initialPos = pos; - let n; - ({ - n, - pos - } = readInt(input, pos, lineStart, curLine, 16, len, forceLen, false, errors, !throwOnInvalid)); - if (n === null) { - if (throwOnInvalid) { - errors.invalidEscapeSequence(initialPos, lineStart, curLine); - } else { - pos = initialPos - 1; - } - } - return { - code: n, - pos - }; -} -function readInt(input, pos, lineStart, curLine, radix, len, forceLen, allowNumSeparator, errors, bailOnError) { - const start = pos; - const forbiddenSiblings = radix === 16 ? forbiddenNumericSeparatorSiblings.hex : forbiddenNumericSeparatorSiblings.decBinOct; - const isAllowedSibling = radix === 16 ? isAllowedNumericSeparatorSibling.hex : radix === 10 ? isAllowedNumericSeparatorSibling.dec : radix === 8 ? isAllowedNumericSeparatorSibling.oct : isAllowedNumericSeparatorSibling.bin; - let invalid = false; - let total = 0; - for (let i = 0, e = len == null ? Infinity : len; i < e; ++i) { - const code = input.charCodeAt(pos); - let val; - if (code === 95 && allowNumSeparator !== "bail") { - const prev = input.charCodeAt(pos - 1); - const next = input.charCodeAt(pos + 1); - if (!allowNumSeparator) { - if (bailOnError) return { - n: null, - pos - }; - errors.numericSeparatorInEscapeSequence(pos, lineStart, curLine); - } else if (Number.isNaN(next) || !isAllowedSibling(next) || forbiddenSiblings.has(prev) || forbiddenSiblings.has(next)) { - if (bailOnError) return { - n: null, - pos - }; - errors.unexpectedNumericSeparator(pos, lineStart, curLine); - } - ++pos; - continue; - } - if (code >= 97) { - val = code - 97 + 10; - } else if (code >= 65) { - val = code - 65 + 10; - } else if (_isDigit(code)) { - val = code - 48; - } else { - val = Infinity; - } - if (val >= radix) { - if (val <= 9 && bailOnError) { - return { - n: null, - pos - }; - } else if (val <= 9 && errors.invalidDigit(pos, lineStart, curLine, radix)) { - val = 0; - } else if (forceLen) { - val = 0; - invalid = true; - } else { - break; - } - } - ++pos; - total = total * radix + val; - } - if (pos === start || len != null && pos - start !== len || invalid) { - return { - n: null, - pos - }; - } - return { - n: total, - pos - }; -} -function readCodePoint(input, pos, lineStart, curLine, throwOnInvalid, errors) { - const ch = input.charCodeAt(pos); - let code; - if (ch === 123) { - ++pos; - ({ - code, - pos - } = readHexChar(input, pos, lineStart, curLine, input.indexOf("}", pos) - pos, true, throwOnInvalid, errors)); - ++pos; - if (code !== null && code > 0x10ffff) { - if (throwOnInvalid) { - errors.invalidCodePoint(pos, lineStart, curLine); - } else { - return { - code: null, - pos - }; - } - } - } else { - ({ - code, - pos - } = readHexChar(input, pos, lineStart, curLine, 4, false, throwOnInvalid, errors)); - } - return { - code, - pos - }; -} -function buildPosition(pos, lineStart, curLine) { - return new Position(curLine, pos - lineStart, pos); -} -const VALID_REGEX_FLAGS = new Set([103, 109, 115, 105, 121, 117, 100, 118]); -class Token { - constructor(state) { - this.type = state.type; - this.value = state.value; - this.start = state.start; - this.end = state.end; - this.loc = new SourceLocation(state.startLoc, state.endLoc); - } -} -class Tokenizer extends CommentsParser { - constructor(options, input) { - super(); - this.isLookahead = void 0; - this.tokens = []; - this.errorHandlers_readInt = { - invalidDigit: (pos, lineStart, curLine, radix) => { - if (!this.options.errorRecovery) return false; - this.raise(Errors.InvalidDigit, buildPosition(pos, lineStart, curLine), { - radix - }); - return true; - }, - numericSeparatorInEscapeSequence: this.errorBuilder(Errors.NumericSeparatorInEscapeSequence), - unexpectedNumericSeparator: this.errorBuilder(Errors.UnexpectedNumericSeparator) - }; - this.errorHandlers_readCodePoint = Object.assign({}, this.errorHandlers_readInt, { - invalidEscapeSequence: this.errorBuilder(Errors.InvalidEscapeSequence), - invalidCodePoint: this.errorBuilder(Errors.InvalidCodePoint) - }); - this.errorHandlers_readStringContents_string = Object.assign({}, this.errorHandlers_readCodePoint, { - strictNumericEscape: (pos, lineStart, curLine) => { - this.recordStrictModeErrors(Errors.StrictNumericEscape, buildPosition(pos, lineStart, curLine)); - }, - unterminated: (pos, lineStart, curLine) => { - throw this.raise(Errors.UnterminatedString, buildPosition(pos - 1, lineStart, curLine)); - } - }); - this.errorHandlers_readStringContents_template = Object.assign({}, this.errorHandlers_readCodePoint, { - strictNumericEscape: this.errorBuilder(Errors.StrictNumericEscape), - unterminated: (pos, lineStart, curLine) => { - throw this.raise(Errors.UnterminatedTemplate, buildPosition(pos, lineStart, curLine)); - } - }); - this.state = new State(); - this.state.init(options); - this.input = input; - this.length = input.length; - this.comments = []; - this.isLookahead = false; - } - pushToken(token) { - this.tokens.length = this.state.tokensLength; - this.tokens.push(token); - ++this.state.tokensLength; - } - next() { - this.checkKeywordEscapes(); - if (this.options.tokens) { - this.pushToken(new Token(this.state)); - } - this.state.lastTokEndLoc = this.state.endLoc; - this.state.lastTokStartLoc = this.state.startLoc; - this.nextToken(); - } - eat(type) { - if (this.match(type)) { - this.next(); - return true; - } else { - return false; - } - } - match(type) { - return this.state.type === type; - } - createLookaheadState(state) { - return { - pos: state.pos, - value: null, - type: state.type, - start: state.start, - end: state.end, - context: [this.curContext()], - inType: state.inType, - startLoc: state.startLoc, - lastTokEndLoc: state.lastTokEndLoc, - curLine: state.curLine, - lineStart: state.lineStart, - curPosition: state.curPosition - }; - } - lookahead() { - const old = this.state; - this.state = this.createLookaheadState(old); - this.isLookahead = true; - this.nextToken(); - this.isLookahead = false; - const curr = this.state; - this.state = old; - return curr; - } - nextTokenStart() { - return this.nextTokenStartSince(this.state.pos); - } - nextTokenStartSince(pos) { - skipWhiteSpace.lastIndex = pos; - return skipWhiteSpace.test(this.input) ? skipWhiteSpace.lastIndex : pos; - } - lookaheadCharCode() { - return this.input.charCodeAt(this.nextTokenStart()); - } - nextTokenInLineStart() { - return this.nextTokenInLineStartSince(this.state.pos); - } - nextTokenInLineStartSince(pos) { - skipWhiteSpaceInLine.lastIndex = pos; - return skipWhiteSpaceInLine.test(this.input) ? skipWhiteSpaceInLine.lastIndex : pos; - } - lookaheadInLineCharCode() { - return this.input.charCodeAt(this.nextTokenInLineStart()); - } - codePointAtPos(pos) { - let cp = this.input.charCodeAt(pos); - if ((cp & 0xfc00) === 0xd800 && ++pos < this.input.length) { - const trail = this.input.charCodeAt(pos); - if ((trail & 0xfc00) === 0xdc00) { - cp = 0x10000 + ((cp & 0x3ff) << 10) + (trail & 0x3ff); - } - } - return cp; - } - setStrict(strict) { - this.state.strict = strict; - if (strict) { - this.state.strictErrors.forEach(([toParseError, at]) => this.raise(toParseError, at)); - this.state.strictErrors.clear(); - } - } - curContext() { - return this.state.context[this.state.context.length - 1]; - } - nextToken() { - this.skipSpace(); - this.state.start = this.state.pos; - if (!this.isLookahead) this.state.startLoc = this.state.curPosition(); - if (this.state.pos >= this.length) { - this.finishToken(139); - return; - } - this.getTokenFromCode(this.codePointAtPos(this.state.pos)); - } - skipBlockComment(commentEnd) { - let startLoc; - if (!this.isLookahead) startLoc = this.state.curPosition(); - const start = this.state.pos; - const end = this.input.indexOf(commentEnd, start + 2); - if (end === -1) { - throw this.raise(Errors.UnterminatedComment, this.state.curPosition()); - } - this.state.pos = end + commentEnd.length; - lineBreakG.lastIndex = start + 2; - while (lineBreakG.test(this.input) && lineBreakG.lastIndex <= end) { - ++this.state.curLine; - this.state.lineStart = lineBreakG.lastIndex; - } - if (this.isLookahead) return; - const comment = { - type: "CommentBlock", - value: this.input.slice(start + 2, end), - start, - end: end + commentEnd.length, - loc: new SourceLocation(startLoc, this.state.curPosition()) - }; - if (this.options.tokens) this.pushToken(comment); - return comment; - } - skipLineComment(startSkip) { - const start = this.state.pos; - let startLoc; - if (!this.isLookahead) startLoc = this.state.curPosition(); - let ch = this.input.charCodeAt(this.state.pos += startSkip); - if (this.state.pos < this.length) { - while (!isNewLine(ch) && ++this.state.pos < this.length) { - ch = this.input.charCodeAt(this.state.pos); - } - } - if (this.isLookahead) return; - const end = this.state.pos; - const value = this.input.slice(start + startSkip, end); - const comment = { - type: "CommentLine", - value, - start, - end, - loc: new SourceLocation(startLoc, this.state.curPosition()) - }; - if (this.options.tokens) this.pushToken(comment); - return comment; - } - skipSpace() { - const spaceStart = this.state.pos; - const comments = []; - loop: while (this.state.pos < this.length) { - const ch = this.input.charCodeAt(this.state.pos); - switch (ch) { - case 32: - case 160: - case 9: - ++this.state.pos; - break; - case 13: - if (this.input.charCodeAt(this.state.pos + 1) === 10) { - ++this.state.pos; - } - case 10: - case 8232: - case 8233: - ++this.state.pos; - ++this.state.curLine; - this.state.lineStart = this.state.pos; - break; - case 47: - switch (this.input.charCodeAt(this.state.pos + 1)) { - case 42: - { - const comment = this.skipBlockComment("*/"); - if (comment !== undefined) { - this.addComment(comment); - if (this.options.attachComment) comments.push(comment); - } - break; - } - case 47: - { - const comment = this.skipLineComment(2); - if (comment !== undefined) { - this.addComment(comment); - if (this.options.attachComment) comments.push(comment); - } - break; - } - default: - break loop; - } - break; - default: - if (isWhitespace(ch)) { - ++this.state.pos; - } else if (ch === 45 && !this.inModule && this.options.annexB) { - const pos = this.state.pos; - if (this.input.charCodeAt(pos + 1) === 45 && this.input.charCodeAt(pos + 2) === 62 && (spaceStart === 0 || this.state.lineStart > spaceStart)) { - const comment = this.skipLineComment(3); - if (comment !== undefined) { - this.addComment(comment); - if (this.options.attachComment) comments.push(comment); - } - } else { - break loop; - } - } else if (ch === 60 && !this.inModule && this.options.annexB) { - const pos = this.state.pos; - if (this.input.charCodeAt(pos + 1) === 33 && this.input.charCodeAt(pos + 2) === 45 && this.input.charCodeAt(pos + 3) === 45) { - const comment = this.skipLineComment(4); - if (comment !== undefined) { - this.addComment(comment); - if (this.options.attachComment) comments.push(comment); - } - } else { - break loop; - } - } else { - break loop; - } - } - } - if (comments.length > 0) { - const end = this.state.pos; - const commentWhitespace = { - start: spaceStart, - end, - comments, - leadingNode: null, - trailingNode: null, - containingNode: null - }; - this.state.commentStack.push(commentWhitespace); - } - } - finishToken(type, val) { - this.state.end = this.state.pos; - this.state.endLoc = this.state.curPosition(); - const prevType = this.state.type; - this.state.type = type; - this.state.value = val; - if (!this.isLookahead) { - this.updateContext(prevType); - } - } - replaceToken(type) { - this.state.type = type; - this.updateContext(); - } - readToken_numberSign() { - if (this.state.pos === 0 && this.readToken_interpreter()) { - return; - } - const nextPos = this.state.pos + 1; - const next = this.codePointAtPos(nextPos); - if (next >= 48 && next <= 57) { - throw this.raise(Errors.UnexpectedDigitAfterHash, this.state.curPosition()); - } - if (next === 123 || next === 91 && this.hasPlugin("recordAndTuple")) { - this.expectPlugin("recordAndTuple"); - if (this.getPluginOption("recordAndTuple", "syntaxType") === "bar") { - throw this.raise(next === 123 ? Errors.RecordExpressionHashIncorrectStartSyntaxType : Errors.TupleExpressionHashIncorrectStartSyntaxType, this.state.curPosition()); - } - this.state.pos += 2; - if (next === 123) { - this.finishToken(7); - } else { - this.finishToken(1); - } - } else if (isIdentifierStart(next)) { - ++this.state.pos; - this.finishToken(138, this.readWord1(next)); - } else if (next === 92) { - ++this.state.pos; - this.finishToken(138, this.readWord1()); - } else { - this.finishOp(27, 1); - } - } - readToken_dot() { - const next = this.input.charCodeAt(this.state.pos + 1); - if (next >= 48 && next <= 57) { - this.readNumber(true); - return; - } - if (next === 46 && this.input.charCodeAt(this.state.pos + 2) === 46) { - this.state.pos += 3; - this.finishToken(21); - } else { - ++this.state.pos; - this.finishToken(16); - } - } - readToken_slash() { - const next = this.input.charCodeAt(this.state.pos + 1); - if (next === 61) { - this.finishOp(31, 2); - } else { - this.finishOp(56, 1); - } - } - readToken_interpreter() { - if (this.state.pos !== 0 || this.length < 2) return false; - let ch = this.input.charCodeAt(this.state.pos + 1); - if (ch !== 33) return false; - const start = this.state.pos; - this.state.pos += 1; - while (!isNewLine(ch) && ++this.state.pos < this.length) { - ch = this.input.charCodeAt(this.state.pos); - } - const value = this.input.slice(start + 2, this.state.pos); - this.finishToken(28, value); - return true; - } - readToken_mult_modulo(code) { - let type = code === 42 ? 55 : 54; - let width = 1; - let next = this.input.charCodeAt(this.state.pos + 1); - if (code === 42 && next === 42) { - width++; - next = this.input.charCodeAt(this.state.pos + 2); - type = 57; - } - if (next === 61 && !this.state.inType) { - width++; - type = code === 37 ? 33 : 30; - } - this.finishOp(type, width); - } - readToken_pipe_amp(code) { - const next = this.input.charCodeAt(this.state.pos + 1); - if (next === code) { - if (this.input.charCodeAt(this.state.pos + 2) === 61) { - this.finishOp(30, 3); - } else { - this.finishOp(code === 124 ? 41 : 42, 2); - } - return; - } - if (code === 124) { - if (next === 62) { - this.finishOp(39, 2); - return; - } - if (this.hasPlugin("recordAndTuple") && next === 125) { - if (this.getPluginOption("recordAndTuple", "syntaxType") !== "bar") { - throw this.raise(Errors.RecordExpressionBarIncorrectEndSyntaxType, this.state.curPosition()); - } - this.state.pos += 2; - this.finishToken(9); - return; - } - if (this.hasPlugin("recordAndTuple") && next === 93) { - if (this.getPluginOption("recordAndTuple", "syntaxType") !== "bar") { - throw this.raise(Errors.TupleExpressionBarIncorrectEndSyntaxType, this.state.curPosition()); - } - this.state.pos += 2; - this.finishToken(4); - return; - } - } - if (next === 61) { - this.finishOp(30, 2); - return; - } - this.finishOp(code === 124 ? 43 : 45, 1); - } - readToken_caret() { - const next = this.input.charCodeAt(this.state.pos + 1); - if (next === 61 && !this.state.inType) { - this.finishOp(32, 2); - } else if (next === 94 && this.hasPlugin(["pipelineOperator", { - proposal: "hack", - topicToken: "^^" - }])) { - this.finishOp(37, 2); - const lookaheadCh = this.input.codePointAt(this.state.pos); - if (lookaheadCh === 94) { - this.unexpected(); - } - } else { - this.finishOp(44, 1); - } - } - readToken_atSign() { - const next = this.input.charCodeAt(this.state.pos + 1); - if (next === 64 && this.hasPlugin(["pipelineOperator", { - proposal: "hack", - topicToken: "@@" - }])) { - this.finishOp(38, 2); - } else { - this.finishOp(26, 1); - } - } - readToken_plus_min(code) { - const next = this.input.charCodeAt(this.state.pos + 1); - if (next === code) { - this.finishOp(34, 2); - return; - } - if (next === 61) { - this.finishOp(30, 2); - } else { - this.finishOp(53, 1); - } - } - readToken_lt() { - const { - pos - } = this.state; - const next = this.input.charCodeAt(pos + 1); - if (next === 60) { - if (this.input.charCodeAt(pos + 2) === 61) { - this.finishOp(30, 3); - return; - } - this.finishOp(51, 2); - return; - } - if (next === 61) { - this.finishOp(49, 2); - return; - } - this.finishOp(47, 1); - } - readToken_gt() { - const { - pos - } = this.state; - const next = this.input.charCodeAt(pos + 1); - if (next === 62) { - const size = this.input.charCodeAt(pos + 2) === 62 ? 3 : 2; - if (this.input.charCodeAt(pos + size) === 61) { - this.finishOp(30, size + 1); - return; - } - this.finishOp(52, size); - return; - } - if (next === 61) { - this.finishOp(49, 2); - return; - } - this.finishOp(48, 1); - } - readToken_eq_excl(code) { - const next = this.input.charCodeAt(this.state.pos + 1); - if (next === 61) { - this.finishOp(46, this.input.charCodeAt(this.state.pos + 2) === 61 ? 3 : 2); - return; - } - if (code === 61 && next === 62) { - this.state.pos += 2; - this.finishToken(19); - return; - } - this.finishOp(code === 61 ? 29 : 35, 1); - } - readToken_question() { - const next = this.input.charCodeAt(this.state.pos + 1); - const next2 = this.input.charCodeAt(this.state.pos + 2); - if (next === 63) { - if (next2 === 61) { - this.finishOp(30, 3); - } else { - this.finishOp(40, 2); - } - } else if (next === 46 && !(next2 >= 48 && next2 <= 57)) { - this.state.pos += 2; - this.finishToken(18); - } else { - ++this.state.pos; - this.finishToken(17); - } - } - getTokenFromCode(code) { - switch (code) { - case 46: - this.readToken_dot(); - return; - case 40: - ++this.state.pos; - this.finishToken(10); - return; - case 41: - ++this.state.pos; - this.finishToken(11); - return; - case 59: - ++this.state.pos; - this.finishToken(13); - return; - case 44: - ++this.state.pos; - this.finishToken(12); - return; - case 91: - if (this.hasPlugin("recordAndTuple") && this.input.charCodeAt(this.state.pos + 1) === 124) { - if (this.getPluginOption("recordAndTuple", "syntaxType") !== "bar") { - throw this.raise(Errors.TupleExpressionBarIncorrectStartSyntaxType, this.state.curPosition()); - } - this.state.pos += 2; - this.finishToken(2); - } else { - ++this.state.pos; - this.finishToken(0); - } - return; - case 93: - ++this.state.pos; - this.finishToken(3); - return; - case 123: - if (this.hasPlugin("recordAndTuple") && this.input.charCodeAt(this.state.pos + 1) === 124) { - if (this.getPluginOption("recordAndTuple", "syntaxType") !== "bar") { - throw this.raise(Errors.RecordExpressionBarIncorrectStartSyntaxType, this.state.curPosition()); - } - this.state.pos += 2; - this.finishToken(6); - } else { - ++this.state.pos; - this.finishToken(5); - } - return; - case 125: - ++this.state.pos; - this.finishToken(8); - return; - case 58: - if (this.hasPlugin("functionBind") && this.input.charCodeAt(this.state.pos + 1) === 58) { - this.finishOp(15, 2); - } else { - ++this.state.pos; - this.finishToken(14); - } - return; - case 63: - this.readToken_question(); - return; - case 96: - this.readTemplateToken(); - return; - case 48: - { - const next = this.input.charCodeAt(this.state.pos + 1); - if (next === 120 || next === 88) { - this.readRadixNumber(16); - return; - } - if (next === 111 || next === 79) { - this.readRadixNumber(8); - return; - } - if (next === 98 || next === 66) { - this.readRadixNumber(2); - return; - } - } - case 49: - case 50: - case 51: - case 52: - case 53: - case 54: - case 55: - case 56: - case 57: - this.readNumber(false); - return; - case 34: - case 39: - this.readString(code); - return; - case 47: - this.readToken_slash(); - return; - case 37: - case 42: - this.readToken_mult_modulo(code); - return; - case 124: - case 38: - this.readToken_pipe_amp(code); - return; - case 94: - this.readToken_caret(); - return; - case 43: - case 45: - this.readToken_plus_min(code); - return; - case 60: - this.readToken_lt(); - return; - case 62: - this.readToken_gt(); - return; - case 61: - case 33: - this.readToken_eq_excl(code); - return; - case 126: - this.finishOp(36, 1); - return; - case 64: - this.readToken_atSign(); - return; - case 35: - this.readToken_numberSign(); - return; - case 92: - this.readWord(); - return; - default: - if (isIdentifierStart(code)) { - this.readWord(code); - return; - } - } - throw this.raise(Errors.InvalidOrUnexpectedToken, this.state.curPosition(), { - unexpected: String.fromCodePoint(code) - }); - } - finishOp(type, size) { - const str = this.input.slice(this.state.pos, this.state.pos + size); - this.state.pos += size; - this.finishToken(type, str); - } - readRegexp() { - const startLoc = this.state.startLoc; - const start = this.state.start + 1; - let escaped, inClass; - let { - pos - } = this.state; - for (;; ++pos) { - if (pos >= this.length) { - throw this.raise(Errors.UnterminatedRegExp, createPositionWithColumnOffset(startLoc, 1)); - } - const ch = this.input.charCodeAt(pos); - if (isNewLine(ch)) { - throw this.raise(Errors.UnterminatedRegExp, createPositionWithColumnOffset(startLoc, 1)); - } - if (escaped) { - escaped = false; - } else { - if (ch === 91) { - inClass = true; - } else if (ch === 93 && inClass) { - inClass = false; - } else if (ch === 47 && !inClass) { - break; - } - escaped = ch === 92; - } - } - const content = this.input.slice(start, pos); - ++pos; - let mods = ""; - const nextPos = () => createPositionWithColumnOffset(startLoc, pos + 2 - start); - while (pos < this.length) { - const cp = this.codePointAtPos(pos); - const char = String.fromCharCode(cp); - if (VALID_REGEX_FLAGS.has(cp)) { - if (cp === 118) { - if (mods.includes("u")) { - this.raise(Errors.IncompatibleRegExpUVFlags, nextPos()); - } - } else if (cp === 117) { - if (mods.includes("v")) { - this.raise(Errors.IncompatibleRegExpUVFlags, nextPos()); - } - } - if (mods.includes(char)) { - this.raise(Errors.DuplicateRegExpFlags, nextPos()); - } - } else if (isIdentifierChar(cp) || cp === 92) { - this.raise(Errors.MalformedRegExpFlags, nextPos()); - } else { - break; - } - ++pos; - mods += char; - } - this.state.pos = pos; - this.finishToken(137, { - pattern: content, - flags: mods - }); - } - readInt(radix, len, forceLen = false, allowNumSeparator = true) { - const { - n, - pos - } = readInt(this.input, this.state.pos, this.state.lineStart, this.state.curLine, radix, len, forceLen, allowNumSeparator, this.errorHandlers_readInt, false); - this.state.pos = pos; - return n; - } - readRadixNumber(radix) { - const startLoc = this.state.curPosition(); - let isBigInt = false; - this.state.pos += 2; - const val = this.readInt(radix); - if (val == null) { - this.raise(Errors.InvalidDigit, createPositionWithColumnOffset(startLoc, 2), { - radix - }); - } - const next = this.input.charCodeAt(this.state.pos); - if (next === 110) { - ++this.state.pos; - isBigInt = true; - } else if (next === 109) { - throw this.raise(Errors.InvalidDecimal, startLoc); - } - if (isIdentifierStart(this.codePointAtPos(this.state.pos))) { - throw this.raise(Errors.NumberIdentifier, this.state.curPosition()); - } - if (isBigInt) { - const str = this.input.slice(startLoc.index, this.state.pos).replace(/[_n]/g, ""); - this.finishToken(135, str); - return; - } - this.finishToken(134, val); - } - readNumber(startsWithDot) { - const start = this.state.pos; - const startLoc = this.state.curPosition(); - let isFloat = false; - let isBigInt = false; - let isDecimal = false; - let hasExponent = false; - let isOctal = false; - if (!startsWithDot && this.readInt(10) === null) { - this.raise(Errors.InvalidNumber, this.state.curPosition()); - } - const hasLeadingZero = this.state.pos - start >= 2 && this.input.charCodeAt(start) === 48; - if (hasLeadingZero) { - const integer = this.input.slice(start, this.state.pos); - this.recordStrictModeErrors(Errors.StrictOctalLiteral, startLoc); - if (!this.state.strict) { - const underscorePos = integer.indexOf("_"); - if (underscorePos > 0) { - this.raise(Errors.ZeroDigitNumericSeparator, createPositionWithColumnOffset(startLoc, underscorePos)); - } - } - isOctal = hasLeadingZero && !/[89]/.test(integer); - } - let next = this.input.charCodeAt(this.state.pos); - if (next === 46 && !isOctal) { - ++this.state.pos; - this.readInt(10); - isFloat = true; - next = this.input.charCodeAt(this.state.pos); - } - if ((next === 69 || next === 101) && !isOctal) { - next = this.input.charCodeAt(++this.state.pos); - if (next === 43 || next === 45) { - ++this.state.pos; - } - if (this.readInt(10) === null) { - this.raise(Errors.InvalidOrMissingExponent, startLoc); - } - isFloat = true; - hasExponent = true; - next = this.input.charCodeAt(this.state.pos); - } - if (next === 110) { - if (isFloat || hasLeadingZero) { - this.raise(Errors.InvalidBigIntLiteral, startLoc); - } - ++this.state.pos; - isBigInt = true; - } - if (next === 109) { - this.expectPlugin("decimal", this.state.curPosition()); - if (hasExponent || hasLeadingZero) { - this.raise(Errors.InvalidDecimal, startLoc); - } - ++this.state.pos; - isDecimal = true; - } - if (isIdentifierStart(this.codePointAtPos(this.state.pos))) { - throw this.raise(Errors.NumberIdentifier, this.state.curPosition()); - } - const str = this.input.slice(start, this.state.pos).replace(/[_mn]/g, ""); - if (isBigInt) { - this.finishToken(135, str); - return; - } - if (isDecimal) { - this.finishToken(136, str); - return; - } - const val = isOctal ? parseInt(str, 8) : parseFloat(str); - this.finishToken(134, val); - } - readCodePoint(throwOnInvalid) { - const { - code, - pos - } = readCodePoint(this.input, this.state.pos, this.state.lineStart, this.state.curLine, throwOnInvalid, this.errorHandlers_readCodePoint); - this.state.pos = pos; - return code; - } - readString(quote) { - const { - str, - pos, - curLine, - lineStart - } = readStringContents(quote === 34 ? "double" : "single", this.input, this.state.pos + 1, this.state.lineStart, this.state.curLine, this.errorHandlers_readStringContents_string); - this.state.pos = pos + 1; - this.state.lineStart = lineStart; - this.state.curLine = curLine; - this.finishToken(133, str); - } - readTemplateContinuation() { - if (!this.match(8)) { - this.unexpected(null, 8); - } - this.state.pos--; - this.readTemplateToken(); - } - readTemplateToken() { - const opening = this.input[this.state.pos]; - const { - str, - firstInvalidLoc, - pos, - curLine, - lineStart - } = readStringContents("template", this.input, this.state.pos + 1, this.state.lineStart, this.state.curLine, this.errorHandlers_readStringContents_template); - this.state.pos = pos + 1; - this.state.lineStart = lineStart; - this.state.curLine = curLine; - if (firstInvalidLoc) { - this.state.firstInvalidTemplateEscapePos = new Position(firstInvalidLoc.curLine, firstInvalidLoc.pos - firstInvalidLoc.lineStart, firstInvalidLoc.pos); - } - if (this.input.codePointAt(pos) === 96) { - this.finishToken(24, firstInvalidLoc ? null : opening + str + "`"); - } else { - this.state.pos++; - this.finishToken(25, firstInvalidLoc ? null : opening + str + "${"); - } - } - recordStrictModeErrors(toParseError, at) { - const index = at.index; - if (this.state.strict && !this.state.strictErrors.has(index)) { - this.raise(toParseError, at); - } else { - this.state.strictErrors.set(index, [toParseError, at]); - } - } - readWord1(firstCode) { - this.state.containsEsc = false; - let word = ""; - const start = this.state.pos; - let chunkStart = this.state.pos; - if (firstCode !== undefined) { - this.state.pos += firstCode <= 0xffff ? 1 : 2; - } - while (this.state.pos < this.length) { - const ch = this.codePointAtPos(this.state.pos); - if (isIdentifierChar(ch)) { - this.state.pos += ch <= 0xffff ? 1 : 2; - } else if (ch === 92) { - this.state.containsEsc = true; - word += this.input.slice(chunkStart, this.state.pos); - const escStart = this.state.curPosition(); - const identifierCheck = this.state.pos === start ? isIdentifierStart : isIdentifierChar; - if (this.input.charCodeAt(++this.state.pos) !== 117) { - this.raise(Errors.MissingUnicodeEscape, this.state.curPosition()); - chunkStart = this.state.pos - 1; - continue; - } - ++this.state.pos; - const esc = this.readCodePoint(true); - if (esc !== null) { - if (!identifierCheck(esc)) { - this.raise(Errors.EscapedCharNotAnIdentifier, escStart); - } - word += String.fromCodePoint(esc); - } - chunkStart = this.state.pos; - } else { - break; - } - } - return word + this.input.slice(chunkStart, this.state.pos); - } - readWord(firstCode) { - const word = this.readWord1(firstCode); - const type = keywords$1.get(word); - if (type !== undefined) { - this.finishToken(type, tokenLabelName(type)); - } else { - this.finishToken(132, word); - } - } - checkKeywordEscapes() { - const { - type - } = this.state; - if (tokenIsKeyword(type) && this.state.containsEsc) { - this.raise(Errors.InvalidEscapedReservedWord, this.state.startLoc, { - reservedWord: tokenLabelName(type) - }); - } - } - raise(toParseError, at, details = {}) { - const loc = at instanceof Position ? at : at.loc.start; - const error = toParseError(loc, details); - if (!this.options.errorRecovery) throw error; - if (!this.isLookahead) this.state.errors.push(error); - return error; - } - raiseOverwrite(toParseError, at, details = {}) { - const loc = at instanceof Position ? at : at.loc.start; - const pos = loc.index; - const errors = this.state.errors; - for (let i = errors.length - 1; i >= 0; i--) { - const error = errors[i]; - if (error.loc.index === pos) { - return errors[i] = toParseError(loc, details); - } - if (error.loc.index < pos) break; - } - return this.raise(toParseError, at, details); - } - updateContext(prevType) {} - unexpected(loc, type) { - throw this.raise(Errors.UnexpectedToken, loc != null ? loc : this.state.startLoc, { - expected: type ? tokenLabelName(type) : null - }); - } - expectPlugin(pluginName, loc) { - if (this.hasPlugin(pluginName)) { - return true; - } - throw this.raise(Errors.MissingPlugin, loc != null ? loc : this.state.startLoc, { - missingPlugin: [pluginName] - }); - } - expectOnePlugin(pluginNames) { - if (!pluginNames.some(name => this.hasPlugin(name))) { - throw this.raise(Errors.MissingOneOfPlugins, this.state.startLoc, { - missingPlugin: pluginNames - }); - } - } - errorBuilder(error) { - return (pos, lineStart, curLine) => { - this.raise(error, buildPosition(pos, lineStart, curLine)); - }; - } -} -class ClassScope { - constructor() { - this.privateNames = new Set(); - this.loneAccessors = new Map(); - this.undefinedPrivateNames = new Map(); - } -} -class ClassScopeHandler { - constructor(parser) { - this.parser = void 0; - this.stack = []; - this.undefinedPrivateNames = new Map(); - this.parser = parser; - } - current() { - return this.stack[this.stack.length - 1]; - } - enter() { - this.stack.push(new ClassScope()); - } - exit() { - const oldClassScope = this.stack.pop(); - const current = this.current(); - for (const [name, loc] of Array.from(oldClassScope.undefinedPrivateNames)) { - if (current) { - if (!current.undefinedPrivateNames.has(name)) { - current.undefinedPrivateNames.set(name, loc); - } - } else { - this.parser.raise(Errors.InvalidPrivateFieldResolution, loc, { - identifierName: name - }); - } - } - } - declarePrivateName(name, elementType, loc) { - const { - privateNames, - loneAccessors, - undefinedPrivateNames - } = this.current(); - let redefined = privateNames.has(name); - if (elementType & 3) { - const accessor = redefined && loneAccessors.get(name); - if (accessor) { - const oldStatic = accessor & 4; - const newStatic = elementType & 4; - const oldKind = accessor & 3; - const newKind = elementType & 3; - redefined = oldKind === newKind || oldStatic !== newStatic; - if (!redefined) loneAccessors.delete(name); - } else if (!redefined) { - loneAccessors.set(name, elementType); - } - } - if (redefined) { - this.parser.raise(Errors.PrivateNameRedeclaration, loc, { - identifierName: name - }); - } - privateNames.add(name); - undefinedPrivateNames.delete(name); - } - usePrivateName(name, loc) { - let classScope; - for (classScope of this.stack) { - if (classScope.privateNames.has(name)) return; - } - if (classScope) { - classScope.undefinedPrivateNames.set(name, loc); - } else { - this.parser.raise(Errors.InvalidPrivateFieldResolution, loc, { - identifierName: name - }); - } - } -} -class ExpressionScope { - constructor(type = 0) { - this.type = type; - } - canBeArrowParameterDeclaration() { - return this.type === 2 || this.type === 1; - } - isCertainlyParameterDeclaration() { - return this.type === 3; - } -} -class ArrowHeadParsingScope extends ExpressionScope { - constructor(type) { - super(type); - this.declarationErrors = new Map(); - } - recordDeclarationError(ParsingErrorClass, at) { - const index = at.index; - this.declarationErrors.set(index, [ParsingErrorClass, at]); - } - clearDeclarationError(index) { - this.declarationErrors.delete(index); - } - iterateErrors(iterator) { - this.declarationErrors.forEach(iterator); - } -} -class ExpressionScopeHandler { - constructor(parser) { - this.parser = void 0; - this.stack = [new ExpressionScope()]; - this.parser = parser; - } - enter(scope) { - this.stack.push(scope); - } - exit() { - this.stack.pop(); - } - recordParameterInitializerError(toParseError, node) { - const origin = node.loc.start; - const { - stack - } = this; - let i = stack.length - 1; - let scope = stack[i]; - while (!scope.isCertainlyParameterDeclaration()) { - if (scope.canBeArrowParameterDeclaration()) { - scope.recordDeclarationError(toParseError, origin); - } else { - return; - } - scope = stack[--i]; - } - this.parser.raise(toParseError, origin); - } - recordArrowParameterBindingError(error, node) { - const { - stack - } = this; - const scope = stack[stack.length - 1]; - const origin = node.loc.start; - if (scope.isCertainlyParameterDeclaration()) { - this.parser.raise(error, origin); - } else if (scope.canBeArrowParameterDeclaration()) { - scope.recordDeclarationError(error, origin); - } else { - return; - } - } - recordAsyncArrowParametersError(at) { - const { - stack - } = this; - let i = stack.length - 1; - let scope = stack[i]; - while (scope.canBeArrowParameterDeclaration()) { - if (scope.type === 2) { - scope.recordDeclarationError(Errors.AwaitBindingIdentifier, at); - } - scope = stack[--i]; - } - } - validateAsPattern() { - const { - stack - } = this; - const currentScope = stack[stack.length - 1]; - if (!currentScope.canBeArrowParameterDeclaration()) return; - currentScope.iterateErrors(([toParseError, loc]) => { - this.parser.raise(toParseError, loc); - let i = stack.length - 2; - let scope = stack[i]; - while (scope.canBeArrowParameterDeclaration()) { - scope.clearDeclarationError(loc.index); - scope = stack[--i]; - } - }); - } -} -function newParameterDeclarationScope() { - return new ExpressionScope(3); -} -function newArrowHeadScope() { - return new ArrowHeadParsingScope(1); -} -function newAsyncArrowScope() { - return new ArrowHeadParsingScope(2); -} -function newExpressionScope() { - return new ExpressionScope(); -} -class ProductionParameterHandler { - constructor() { - this.stacks = []; - } - enter(flags) { - this.stacks.push(flags); - } - exit() { - this.stacks.pop(); - } - currentFlags() { - return this.stacks[this.stacks.length - 1]; - } - get hasAwait() { - return (this.currentFlags() & 2) > 0; - } - get hasYield() { - return (this.currentFlags() & 1) > 0; - } - get hasReturn() { - return (this.currentFlags() & 4) > 0; - } - get hasIn() { - return (this.currentFlags() & 8) > 0; - } -} -function functionFlags(isAsync, isGenerator) { - return (isAsync ? 2 : 0) | (isGenerator ? 1 : 0); -} -class UtilParser extends Tokenizer { - addExtra(node, key, value, enumerable = true) { - if (!node) return; - const extra = node.extra = node.extra || {}; - if (enumerable) { - extra[key] = value; - } else { - Object.defineProperty(extra, key, { - enumerable, - value - }); - } - } - isContextual(token) { - return this.state.type === token && !this.state.containsEsc; - } - isUnparsedContextual(nameStart, name) { - const nameEnd = nameStart + name.length; - if (this.input.slice(nameStart, nameEnd) === name) { - const nextCh = this.input.charCodeAt(nameEnd); - return !(isIdentifierChar(nextCh) || (nextCh & 0xfc00) === 0xd800); - } - return false; - } - isLookaheadContextual(name) { - const next = this.nextTokenStart(); - return this.isUnparsedContextual(next, name); - } - eatContextual(token) { - if (this.isContextual(token)) { - this.next(); - return true; - } - return false; - } - expectContextual(token, toParseError) { - if (!this.eatContextual(token)) { - if (toParseError != null) { - throw this.raise(toParseError, this.state.startLoc); - } - this.unexpected(null, token); - } - } - canInsertSemicolon() { - return this.match(139) || this.match(8) || this.hasPrecedingLineBreak(); - } - hasPrecedingLineBreak() { - return lineBreak.test(this.input.slice(this.state.lastTokEndLoc.index, this.state.start)); - } - hasFollowingLineBreak() { - skipWhiteSpaceToLineBreak.lastIndex = this.state.end; - return skipWhiteSpaceToLineBreak.test(this.input); - } - isLineTerminator() { - return this.eat(13) || this.canInsertSemicolon(); - } - semicolon(allowAsi = true) { - if (allowAsi ? this.isLineTerminator() : this.eat(13)) return; - this.raise(Errors.MissingSemicolon, this.state.lastTokEndLoc); - } - expect(type, loc) { - if (!this.eat(type)) { - this.unexpected(loc, type); - } - } - tryParse(fn, oldState = this.state.clone()) { - const abortSignal = { - node: null - }; - try { - const node = fn((node = null) => { - abortSignal.node = node; - throw abortSignal; - }); - if (this.state.errors.length > oldState.errors.length) { - const failState = this.state; - this.state = oldState; - this.state.tokensLength = failState.tokensLength; - return { - node, - error: failState.errors[oldState.errors.length], - thrown: false, - aborted: false, - failState - }; - } - return { - node, - error: null, - thrown: false, - aborted: false, - failState: null - }; - } catch (error) { - const failState = this.state; - this.state = oldState; - if (error instanceof SyntaxError) { - return { - node: null, - error, - thrown: true, - aborted: false, - failState - }; - } - if (error === abortSignal) { - return { - node: abortSignal.node, - error: null, - thrown: false, - aborted: true, - failState - }; - } - throw error; - } - } - checkExpressionErrors(refExpressionErrors, andThrow) { - if (!refExpressionErrors) return false; - const { - shorthandAssignLoc, - doubleProtoLoc, - privateKeyLoc, - optionalParametersLoc - } = refExpressionErrors; - const hasErrors = !!shorthandAssignLoc || !!doubleProtoLoc || !!optionalParametersLoc || !!privateKeyLoc; - if (!andThrow) { - return hasErrors; - } - if (shorthandAssignLoc != null) { - this.raise(Errors.InvalidCoverInitializedName, shorthandAssignLoc); - } - if (doubleProtoLoc != null) { - this.raise(Errors.DuplicateProto, doubleProtoLoc); - } - if (privateKeyLoc != null) { - this.raise(Errors.UnexpectedPrivateField, privateKeyLoc); - } - if (optionalParametersLoc != null) { - this.unexpected(optionalParametersLoc); - } - } - isLiteralPropertyName() { - return tokenIsLiteralPropertyName(this.state.type); - } - isPrivateName(node) { - return node.type === "PrivateName"; - } - getPrivateNameSV(node) { - return node.id.name; - } - hasPropertyAsPrivateName(node) { - return (node.type === "MemberExpression" || node.type === "OptionalMemberExpression") && this.isPrivateName(node.property); - } - isObjectProperty(node) { - return node.type === "ObjectProperty"; - } - isObjectMethod(node) { - return node.type === "ObjectMethod"; - } - initializeScopes(inModule = this.options.sourceType === "module") { - const oldLabels = this.state.labels; - this.state.labels = []; - const oldExportedIdentifiers = this.exportedIdentifiers; - this.exportedIdentifiers = new Set(); - const oldInModule = this.inModule; - this.inModule = inModule; - const oldScope = this.scope; - const ScopeHandler = this.getScopeHandler(); - this.scope = new ScopeHandler(this, inModule); - const oldProdParam = this.prodParam; - this.prodParam = new ProductionParameterHandler(); - const oldClassScope = this.classScope; - this.classScope = new ClassScopeHandler(this); - const oldExpressionScope = this.expressionScope; - this.expressionScope = new ExpressionScopeHandler(this); - return () => { - this.state.labels = oldLabels; - this.exportedIdentifiers = oldExportedIdentifiers; - this.inModule = oldInModule; - this.scope = oldScope; - this.prodParam = oldProdParam; - this.classScope = oldClassScope; - this.expressionScope = oldExpressionScope; - }; - } - enterInitialScopes() { - let paramFlags = 0; - if (this.inModule) { - paramFlags |= 2; - } - this.scope.enter(1); - this.prodParam.enter(paramFlags); - } - checkDestructuringPrivate(refExpressionErrors) { - const { - privateKeyLoc - } = refExpressionErrors; - if (privateKeyLoc !== null) { - this.expectPlugin("destructuringPrivate", privateKeyLoc); - } - } -} -class ExpressionErrors { - constructor() { - this.shorthandAssignLoc = null; - this.doubleProtoLoc = null; - this.privateKeyLoc = null; - this.optionalParametersLoc = null; - } -} -class Node { - constructor(parser, pos, loc) { - this.type = ""; - this.start = pos; - this.end = 0; - this.loc = new SourceLocation(loc); - if (parser != null && parser.options.ranges) this.range = [pos, 0]; - if (parser != null && parser.filename) this.loc.filename = parser.filename; - } -} -const NodePrototype = Node.prototype; -{ - NodePrototype.__clone = function () { - const newNode = new Node(undefined, this.start, this.loc.start); - const keys = Object.keys(this); - for (let i = 0, length = keys.length; i < length; i++) { - const key = keys[i]; - if (key !== "leadingComments" && key !== "trailingComments" && key !== "innerComments") { - newNode[key] = this[key]; - } - } - return newNode; - }; -} -function clonePlaceholder(node) { - return cloneIdentifier(node); -} -function cloneIdentifier(node) { - const { - type, - start, - end, - loc, - range, - extra, - name - } = node; - const cloned = Object.create(NodePrototype); - cloned.type = type; - cloned.start = start; - cloned.end = end; - cloned.loc = loc; - cloned.range = range; - cloned.extra = extra; - cloned.name = name; - if (type === "Placeholder") { - cloned.expectedNode = node.expectedNode; - } - return cloned; -} -function cloneStringLiteral(node) { - const { - type, - start, - end, - loc, - range, - extra - } = node; - if (type === "Placeholder") { - return clonePlaceholder(node); - } - const cloned = Object.create(NodePrototype); - cloned.type = type; - cloned.start = start; - cloned.end = end; - cloned.loc = loc; - cloned.range = range; - if (node.raw !== undefined) { - cloned.raw = node.raw; - } else { - cloned.extra = extra; - } - cloned.value = node.value; - return cloned; -} -class NodeUtils extends UtilParser { - startNode() { - const loc = this.state.startLoc; - return new Node(this, loc.index, loc); - } - startNodeAt(loc) { - return new Node(this, loc.index, loc); - } - startNodeAtNode(type) { - return this.startNodeAt(type.loc.start); - } - finishNode(node, type) { - return this.finishNodeAt(node, type, this.state.lastTokEndLoc); - } - finishNodeAt(node, type, endLoc) { - node.type = type; - node.end = endLoc.index; - node.loc.end = endLoc; - if (this.options.ranges) node.range[1] = endLoc.index; - if (this.options.attachComment) this.processComment(node); - return node; - } - resetStartLocation(node, startLoc) { - node.start = startLoc.index; - node.loc.start = startLoc; - if (this.options.ranges) node.range[0] = startLoc.index; - } - resetEndLocation(node, endLoc = this.state.lastTokEndLoc) { - node.end = endLoc.index; - node.loc.end = endLoc; - if (this.options.ranges) node.range[1] = endLoc.index; - } - resetStartLocationFromNode(node, locationNode) { - this.resetStartLocation(node, locationNode.loc.start); - } -} -const reservedTypes = new Set(["_", "any", "bool", "boolean", "empty", "extends", "false", "interface", "mixed", "null", "number", "static", "string", "true", "typeof", "void"]); -const FlowErrors = ParseErrorEnum`flow`({ - AmbiguousConditionalArrow: "Ambiguous expression: wrap the arrow functions in parentheses to disambiguate.", - AmbiguousDeclareModuleKind: "Found both `declare module.exports` and `declare export` in the same module. Modules can only have 1 since they are either an ES module or they are a CommonJS module.", - AssignReservedType: ({ - reservedType - }) => `Cannot overwrite reserved type ${reservedType}.`, - DeclareClassElement: "The `declare` modifier can only appear on class fields.", - DeclareClassFieldInitializer: "Initializers are not allowed in fields with the `declare` modifier.", - DuplicateDeclareModuleExports: "Duplicate `declare module.exports` statement.", - EnumBooleanMemberNotInitialized: ({ - memberName, - enumName - }) => `Boolean enum members need to be initialized. Use either \`${memberName} = true,\` or \`${memberName} = false,\` in enum \`${enumName}\`.`, - EnumDuplicateMemberName: ({ - memberName, - enumName - }) => `Enum member names need to be unique, but the name \`${memberName}\` has already been used before in enum \`${enumName}\`.`, - EnumInconsistentMemberValues: ({ - enumName - }) => `Enum \`${enumName}\` has inconsistent member initializers. Either use no initializers, or consistently use literals (either booleans, numbers, or strings) for all member initializers.`, - EnumInvalidExplicitType: ({ - invalidEnumType, - enumName - }) => `Enum type \`${invalidEnumType}\` is not valid. Use one of \`boolean\`, \`number\`, \`string\`, or \`symbol\` in enum \`${enumName}\`.`, - EnumInvalidExplicitTypeUnknownSupplied: ({ - enumName - }) => `Supplied enum type is not valid. Use one of \`boolean\`, \`number\`, \`string\`, or \`symbol\` in enum \`${enumName}\`.`, - EnumInvalidMemberInitializerPrimaryType: ({ - enumName, - memberName, - explicitType - }) => `Enum \`${enumName}\` has type \`${explicitType}\`, so the initializer of \`${memberName}\` needs to be a ${explicitType} literal.`, - EnumInvalidMemberInitializerSymbolType: ({ - enumName, - memberName - }) => `Symbol enum members cannot be initialized. Use \`${memberName},\` in enum \`${enumName}\`.`, - EnumInvalidMemberInitializerUnknownType: ({ - enumName, - memberName - }) => `The enum member initializer for \`${memberName}\` needs to be a literal (either a boolean, number, or string) in enum \`${enumName}\`.`, - EnumInvalidMemberName: ({ - enumName, - memberName, - suggestion - }) => `Enum member names cannot start with lowercase 'a' through 'z'. Instead of using \`${memberName}\`, consider using \`${suggestion}\`, in enum \`${enumName}\`.`, - EnumNumberMemberNotInitialized: ({ - enumName, - memberName - }) => `Number enum members need to be initialized, e.g. \`${memberName} = 1\` in enum \`${enumName}\`.`, - EnumStringMemberInconsistentlyInitialized: ({ - enumName - }) => `String enum members need to consistently either all use initializers, or use no initializers, in enum \`${enumName}\`.`, - GetterMayNotHaveThisParam: "A getter cannot have a `this` parameter.", - ImportReflectionHasImportType: "An `import module` declaration can not use `type` or `typeof` keyword.", - ImportTypeShorthandOnlyInPureImport: "The `type` and `typeof` keywords on named imports can only be used on regular `import` statements. It cannot be used with `import type` or `import typeof` statements.", - InexactInsideExact: "Explicit inexact syntax cannot appear inside an explicit exact object type.", - InexactInsideNonObject: "Explicit inexact syntax cannot appear in class or interface definitions.", - InexactVariance: "Explicit inexact syntax cannot have variance.", - InvalidNonTypeImportInDeclareModule: "Imports within a `declare module` body must always be `import type` or `import typeof`.", - MissingTypeParamDefault: "Type parameter declaration needs a default, since a preceding type parameter declaration has a default.", - NestedDeclareModule: "`declare module` cannot be used inside another `declare module`.", - NestedFlowComment: "Cannot have a flow comment inside another flow comment.", - PatternIsOptional: Object.assign({ - message: "A binding pattern parameter cannot be optional in an implementation signature." - }, { - reasonCode: "OptionalBindingPattern" - }), - SetterMayNotHaveThisParam: "A setter cannot have a `this` parameter.", - SpreadVariance: "Spread properties cannot have variance.", - ThisParamAnnotationRequired: "A type annotation is required for the `this` parameter.", - ThisParamBannedInConstructor: "Constructors cannot have a `this` parameter; constructors don't bind `this` like other functions.", - ThisParamMayNotBeOptional: "The `this` parameter cannot be optional.", - ThisParamMustBeFirst: "The `this` parameter must be the first function parameter.", - ThisParamNoDefault: "The `this` parameter may not have a default value.", - TypeBeforeInitializer: "Type annotations must come before default assignments, e.g. instead of `age = 25: number` use `age: number = 25`.", - TypeCastInPattern: "The type cast expression is expected to be wrapped with parenthesis.", - UnexpectedExplicitInexactInObject: "Explicit inexact syntax must appear at the end of an inexact object.", - UnexpectedReservedType: ({ - reservedType - }) => `Unexpected reserved type ${reservedType}.`, - UnexpectedReservedUnderscore: "`_` is only allowed as a type argument to call or new.", - UnexpectedSpaceBetweenModuloChecks: "Spaces between `%` and `checks` are not allowed here.", - UnexpectedSpreadType: "Spread operator cannot appear in class or interface definitions.", - UnexpectedSubtractionOperand: 'Unexpected token, expected "number" or "bigint".', - UnexpectedTokenAfterTypeParameter: "Expected an arrow function after this type parameter declaration.", - UnexpectedTypeParameterBeforeAsyncArrowFunction: "Type parameters must come after the async keyword, e.g. instead of ` async () => {}`, use `async () => {}`.", - UnsupportedDeclareExportKind: ({ - unsupportedExportKind, - suggestion - }) => `\`declare export ${unsupportedExportKind}\` is not supported. Use \`${suggestion}\` instead.`, - UnsupportedStatementInDeclareModule: "Only declares and type imports are allowed inside declare module.", - UnterminatedFlowComment: "Unterminated flow-comment." -}); -function isEsModuleType(bodyElement) { - return bodyElement.type === "DeclareExportAllDeclaration" || bodyElement.type === "DeclareExportDeclaration" && (!bodyElement.declaration || bodyElement.declaration.type !== "TypeAlias" && bodyElement.declaration.type !== "InterfaceDeclaration"); -} -function hasTypeImportKind(node) { - return node.importKind === "type" || node.importKind === "typeof"; -} -const exportSuggestions = { - const: "declare export var", - let: "declare export var", - type: "export type", - interface: "export interface" -}; -function partition(list, test) { - const list1 = []; - const list2 = []; - for (let i = 0; i < list.length; i++) { - (test(list[i], i, list) ? list1 : list2).push(list[i]); - } - return [list1, list2]; -} -const FLOW_PRAGMA_REGEX = /\*?\s*@((?:no)?flow)\b/; -var flow = superClass => class FlowParserMixin extends superClass { - constructor(...args) { - super(...args); - this.flowPragma = undefined; - } - getScopeHandler() { - return FlowScopeHandler; - } - shouldParseTypes() { - return this.getPluginOption("flow", "all") || this.flowPragma === "flow"; - } - shouldParseEnums() { - return !!this.getPluginOption("flow", "enums"); - } - finishToken(type, val) { - if (type !== 133 && type !== 13 && type !== 28) { - if (this.flowPragma === undefined) { - this.flowPragma = null; - } - } - super.finishToken(type, val); - } - addComment(comment) { - if (this.flowPragma === undefined) { - const matches = FLOW_PRAGMA_REGEX.exec(comment.value); - if (!matches) ;else if (matches[1] === "flow") { - this.flowPragma = "flow"; - } else if (matches[1] === "noflow") { - this.flowPragma = "noflow"; - } else { - throw new Error("Unexpected flow pragma"); - } - } - super.addComment(comment); - } - flowParseTypeInitialiser(tok) { - const oldInType = this.state.inType; - this.state.inType = true; - this.expect(tok || 14); - const type = this.flowParseType(); - this.state.inType = oldInType; - return type; - } - flowParsePredicate() { - const node = this.startNode(); - const moduloLoc = this.state.startLoc; - this.next(); - this.expectContextual(110); - if (this.state.lastTokStartLoc.index > moduloLoc.index + 1) { - this.raise(FlowErrors.UnexpectedSpaceBetweenModuloChecks, moduloLoc); - } - if (this.eat(10)) { - node.value = super.parseExpression(); - this.expect(11); - return this.finishNode(node, "DeclaredPredicate"); - } else { - return this.finishNode(node, "InferredPredicate"); - } - } - flowParseTypeAndPredicateInitialiser() { - const oldInType = this.state.inType; - this.state.inType = true; - this.expect(14); - let type = null; - let predicate = null; - if (this.match(54)) { - this.state.inType = oldInType; - predicate = this.flowParsePredicate(); - } else { - type = this.flowParseType(); - this.state.inType = oldInType; - if (this.match(54)) { - predicate = this.flowParsePredicate(); - } - } - return [type, predicate]; - } - flowParseDeclareClass(node) { - this.next(); - this.flowParseInterfaceish(node, true); - return this.finishNode(node, "DeclareClass"); - } - flowParseDeclareFunction(node) { - this.next(); - const id = node.id = this.parseIdentifier(); - const typeNode = this.startNode(); - const typeContainer = this.startNode(); - if (this.match(47)) { - typeNode.typeParameters = this.flowParseTypeParameterDeclaration(); - } else { - typeNode.typeParameters = null; - } - this.expect(10); - const tmp = this.flowParseFunctionTypeParams(); - typeNode.params = tmp.params; - typeNode.rest = tmp.rest; - typeNode.this = tmp._this; - this.expect(11); - [typeNode.returnType, node.predicate] = this.flowParseTypeAndPredicateInitialiser(); - typeContainer.typeAnnotation = this.finishNode(typeNode, "FunctionTypeAnnotation"); - id.typeAnnotation = this.finishNode(typeContainer, "TypeAnnotation"); - this.resetEndLocation(id); - this.semicolon(); - this.scope.declareName(node.id.name, 2048, node.id.loc.start); - return this.finishNode(node, "DeclareFunction"); - } - flowParseDeclare(node, insideModule) { - if (this.match(80)) { - return this.flowParseDeclareClass(node); - } else if (this.match(68)) { - return this.flowParseDeclareFunction(node); - } else if (this.match(74)) { - return this.flowParseDeclareVariable(node); - } else if (this.eatContextual(127)) { - if (this.match(16)) { - return this.flowParseDeclareModuleExports(node); - } else { - if (insideModule) { - this.raise(FlowErrors.NestedDeclareModule, this.state.lastTokStartLoc); - } - return this.flowParseDeclareModule(node); - } - } else if (this.isContextual(130)) { - return this.flowParseDeclareTypeAlias(node); - } else if (this.isContextual(131)) { - return this.flowParseDeclareOpaqueType(node); - } else if (this.isContextual(129)) { - return this.flowParseDeclareInterface(node); - } else if (this.match(82)) { - return this.flowParseDeclareExportDeclaration(node, insideModule); - } else { - this.unexpected(); - } - } - flowParseDeclareVariable(node) { - this.next(); - node.id = this.flowParseTypeAnnotatableIdentifier(true); - this.scope.declareName(node.id.name, 5, node.id.loc.start); - this.semicolon(); - return this.finishNode(node, "DeclareVariable"); - } - flowParseDeclareModule(node) { - this.scope.enter(0); - if (this.match(133)) { - node.id = super.parseExprAtom(); - } else { - node.id = this.parseIdentifier(); - } - const bodyNode = node.body = this.startNode(); - const body = bodyNode.body = []; - this.expect(5); - while (!this.match(8)) { - let bodyNode = this.startNode(); - if (this.match(83)) { - this.next(); - if (!this.isContextual(130) && !this.match(87)) { - this.raise(FlowErrors.InvalidNonTypeImportInDeclareModule, this.state.lastTokStartLoc); - } - super.parseImport(bodyNode); - } else { - this.expectContextual(125, FlowErrors.UnsupportedStatementInDeclareModule); - bodyNode = this.flowParseDeclare(bodyNode, true); - } - body.push(bodyNode); - } - this.scope.exit(); - this.expect(8); - this.finishNode(bodyNode, "BlockStatement"); - let kind = null; - let hasModuleExport = false; - body.forEach(bodyElement => { - if (isEsModuleType(bodyElement)) { - if (kind === "CommonJS") { - this.raise(FlowErrors.AmbiguousDeclareModuleKind, bodyElement); - } - kind = "ES"; - } else if (bodyElement.type === "DeclareModuleExports") { - if (hasModuleExport) { - this.raise(FlowErrors.DuplicateDeclareModuleExports, bodyElement); - } - if (kind === "ES") { - this.raise(FlowErrors.AmbiguousDeclareModuleKind, bodyElement); - } - kind = "CommonJS"; - hasModuleExport = true; - } - }); - node.kind = kind || "CommonJS"; - return this.finishNode(node, "DeclareModule"); - } - flowParseDeclareExportDeclaration(node, insideModule) { - this.expect(82); - if (this.eat(65)) { - if (this.match(68) || this.match(80)) { - node.declaration = this.flowParseDeclare(this.startNode()); - } else { - node.declaration = this.flowParseType(); - this.semicolon(); - } - node.default = true; - return this.finishNode(node, "DeclareExportDeclaration"); - } else { - if (this.match(75) || this.isLet() || (this.isContextual(130) || this.isContextual(129)) && !insideModule) { - const label = this.state.value; - throw this.raise(FlowErrors.UnsupportedDeclareExportKind, this.state.startLoc, { - unsupportedExportKind: label, - suggestion: exportSuggestions[label] - }); - } - if (this.match(74) || this.match(68) || this.match(80) || this.isContextual(131)) { - node.declaration = this.flowParseDeclare(this.startNode()); - node.default = false; - return this.finishNode(node, "DeclareExportDeclaration"); - } else if (this.match(55) || this.match(5) || this.isContextual(129) || this.isContextual(130) || this.isContextual(131)) { - node = this.parseExport(node, null); - if (node.type === "ExportNamedDeclaration") { - node.type = "ExportDeclaration"; - node.default = false; - delete node.exportKind; - } - node.type = "Declare" + node.type; - return node; - } - } - this.unexpected(); - } - flowParseDeclareModuleExports(node) { - this.next(); - this.expectContextual(111); - node.typeAnnotation = this.flowParseTypeAnnotation(); - this.semicolon(); - return this.finishNode(node, "DeclareModuleExports"); - } - flowParseDeclareTypeAlias(node) { - this.next(); - const finished = this.flowParseTypeAlias(node); - finished.type = "DeclareTypeAlias"; - return finished; - } - flowParseDeclareOpaqueType(node) { - this.next(); - const finished = this.flowParseOpaqueType(node, true); - finished.type = "DeclareOpaqueType"; - return finished; - } - flowParseDeclareInterface(node) { - this.next(); - this.flowParseInterfaceish(node, false); - return this.finishNode(node, "DeclareInterface"); - } - flowParseInterfaceish(node, isClass) { - node.id = this.flowParseRestrictedIdentifier(!isClass, true); - this.scope.declareName(node.id.name, isClass ? 17 : 8201, node.id.loc.start); - if (this.match(47)) { - node.typeParameters = this.flowParseTypeParameterDeclaration(); - } else { - node.typeParameters = null; - } - node.extends = []; - if (this.eat(81)) { - do { - node.extends.push(this.flowParseInterfaceExtends()); - } while (!isClass && this.eat(12)); - } - if (isClass) { - node.implements = []; - node.mixins = []; - if (this.eatContextual(117)) { - do { - node.mixins.push(this.flowParseInterfaceExtends()); - } while (this.eat(12)); - } - if (this.eatContextual(113)) { - do { - node.implements.push(this.flowParseInterfaceExtends()); - } while (this.eat(12)); - } - } - node.body = this.flowParseObjectType({ - allowStatic: isClass, - allowExact: false, - allowSpread: false, - allowProto: isClass, - allowInexact: false - }); - } - flowParseInterfaceExtends() { - const node = this.startNode(); - node.id = this.flowParseQualifiedTypeIdentifier(); - if (this.match(47)) { - node.typeParameters = this.flowParseTypeParameterInstantiation(); - } else { - node.typeParameters = null; - } - return this.finishNode(node, "InterfaceExtends"); - } - flowParseInterface(node) { - this.flowParseInterfaceish(node, false); - return this.finishNode(node, "InterfaceDeclaration"); - } - checkNotUnderscore(word) { - if (word === "_") { - this.raise(FlowErrors.UnexpectedReservedUnderscore, this.state.startLoc); - } - } - checkReservedType(word, startLoc, declaration) { - if (!reservedTypes.has(word)) return; - this.raise(declaration ? FlowErrors.AssignReservedType : FlowErrors.UnexpectedReservedType, startLoc, { - reservedType: word - }); - } - flowParseRestrictedIdentifier(liberal, declaration) { - this.checkReservedType(this.state.value, this.state.startLoc, declaration); - return this.parseIdentifier(liberal); - } - flowParseTypeAlias(node) { - node.id = this.flowParseRestrictedIdentifier(false, true); - this.scope.declareName(node.id.name, 8201, node.id.loc.start); - if (this.match(47)) { - node.typeParameters = this.flowParseTypeParameterDeclaration(); - } else { - node.typeParameters = null; - } - node.right = this.flowParseTypeInitialiser(29); - this.semicolon(); - return this.finishNode(node, "TypeAlias"); - } - flowParseOpaqueType(node, declare) { - this.expectContextual(130); - node.id = this.flowParseRestrictedIdentifier(true, true); - this.scope.declareName(node.id.name, 8201, node.id.loc.start); - if (this.match(47)) { - node.typeParameters = this.flowParseTypeParameterDeclaration(); - } else { - node.typeParameters = null; - } - node.supertype = null; - if (this.match(14)) { - node.supertype = this.flowParseTypeInitialiser(14); - } - node.impltype = null; - if (!declare) { - node.impltype = this.flowParseTypeInitialiser(29); - } - this.semicolon(); - return this.finishNode(node, "OpaqueType"); - } - flowParseTypeParameter(requireDefault = false) { - const nodeStartLoc = this.state.startLoc; - const node = this.startNode(); - const variance = this.flowParseVariance(); - const ident = this.flowParseTypeAnnotatableIdentifier(); - node.name = ident.name; - node.variance = variance; - node.bound = ident.typeAnnotation; - if (this.match(29)) { - this.eat(29); - node.default = this.flowParseType(); - } else { - if (requireDefault) { - this.raise(FlowErrors.MissingTypeParamDefault, nodeStartLoc); - } - } - return this.finishNode(node, "TypeParameter"); - } - flowParseTypeParameterDeclaration() { - const oldInType = this.state.inType; - const node = this.startNode(); - node.params = []; - this.state.inType = true; - if (this.match(47) || this.match(142)) { - this.next(); - } else { - this.unexpected(); - } - let defaultRequired = false; - do { - const typeParameter = this.flowParseTypeParameter(defaultRequired); - node.params.push(typeParameter); - if (typeParameter.default) { - defaultRequired = true; - } - if (!this.match(48)) { - this.expect(12); - } - } while (!this.match(48)); - this.expect(48); - this.state.inType = oldInType; - return this.finishNode(node, "TypeParameterDeclaration"); - } - flowParseTypeParameterInstantiation() { - const node = this.startNode(); - const oldInType = this.state.inType; - node.params = []; - this.state.inType = true; - this.expect(47); - const oldNoAnonFunctionType = this.state.noAnonFunctionType; - this.state.noAnonFunctionType = false; - while (!this.match(48)) { - node.params.push(this.flowParseType()); - if (!this.match(48)) { - this.expect(12); - } - } - this.state.noAnonFunctionType = oldNoAnonFunctionType; - this.expect(48); - this.state.inType = oldInType; - return this.finishNode(node, "TypeParameterInstantiation"); - } - flowParseTypeParameterInstantiationCallOrNew() { - const node = this.startNode(); - const oldInType = this.state.inType; - node.params = []; - this.state.inType = true; - this.expect(47); - while (!this.match(48)) { - node.params.push(this.flowParseTypeOrImplicitInstantiation()); - if (!this.match(48)) { - this.expect(12); - } - } - this.expect(48); - this.state.inType = oldInType; - return this.finishNode(node, "TypeParameterInstantiation"); - } - flowParseInterfaceType() { - const node = this.startNode(); - this.expectContextual(129); - node.extends = []; - if (this.eat(81)) { - do { - node.extends.push(this.flowParseInterfaceExtends()); - } while (this.eat(12)); - } - node.body = this.flowParseObjectType({ - allowStatic: false, - allowExact: false, - allowSpread: false, - allowProto: false, - allowInexact: false - }); - return this.finishNode(node, "InterfaceTypeAnnotation"); - } - flowParseObjectPropertyKey() { - return this.match(134) || this.match(133) ? super.parseExprAtom() : this.parseIdentifier(true); - } - flowParseObjectTypeIndexer(node, isStatic, variance) { - node.static = isStatic; - if (this.lookahead().type === 14) { - node.id = this.flowParseObjectPropertyKey(); - node.key = this.flowParseTypeInitialiser(); - } else { - node.id = null; - node.key = this.flowParseType(); - } - this.expect(3); - node.value = this.flowParseTypeInitialiser(); - node.variance = variance; - return this.finishNode(node, "ObjectTypeIndexer"); - } - flowParseObjectTypeInternalSlot(node, isStatic) { - node.static = isStatic; - node.id = this.flowParseObjectPropertyKey(); - this.expect(3); - this.expect(3); - if (this.match(47) || this.match(10)) { - node.method = true; - node.optional = false; - node.value = this.flowParseObjectTypeMethodish(this.startNodeAt(node.loc.start)); - } else { - node.method = false; - if (this.eat(17)) { - node.optional = true; - } - node.value = this.flowParseTypeInitialiser(); - } - return this.finishNode(node, "ObjectTypeInternalSlot"); - } - flowParseObjectTypeMethodish(node) { - node.params = []; - node.rest = null; - node.typeParameters = null; - node.this = null; - if (this.match(47)) { - node.typeParameters = this.flowParseTypeParameterDeclaration(); - } - this.expect(10); - if (this.match(78)) { - node.this = this.flowParseFunctionTypeParam(true); - node.this.name = null; - if (!this.match(11)) { - this.expect(12); - } - } - while (!this.match(11) && !this.match(21)) { - node.params.push(this.flowParseFunctionTypeParam(false)); - if (!this.match(11)) { - this.expect(12); - } - } - if (this.eat(21)) { - node.rest = this.flowParseFunctionTypeParam(false); - } - this.expect(11); - node.returnType = this.flowParseTypeInitialiser(); - return this.finishNode(node, "FunctionTypeAnnotation"); - } - flowParseObjectTypeCallProperty(node, isStatic) { - const valueNode = this.startNode(); - node.static = isStatic; - node.value = this.flowParseObjectTypeMethodish(valueNode); - return this.finishNode(node, "ObjectTypeCallProperty"); - } - flowParseObjectType({ - allowStatic, - allowExact, - allowSpread, - allowProto, - allowInexact - }) { - const oldInType = this.state.inType; - this.state.inType = true; - const nodeStart = this.startNode(); - nodeStart.callProperties = []; - nodeStart.properties = []; - nodeStart.indexers = []; - nodeStart.internalSlots = []; - let endDelim; - let exact; - let inexact = false; - if (allowExact && this.match(6)) { - this.expect(6); - endDelim = 9; - exact = true; - } else { - this.expect(5); - endDelim = 8; - exact = false; - } - nodeStart.exact = exact; - while (!this.match(endDelim)) { - let isStatic = false; - let protoStartLoc = null; - let inexactStartLoc = null; - const node = this.startNode(); - if (allowProto && this.isContextual(118)) { - const lookahead = this.lookahead(); - if (lookahead.type !== 14 && lookahead.type !== 17) { - this.next(); - protoStartLoc = this.state.startLoc; - allowStatic = false; - } - } - if (allowStatic && this.isContextual(106)) { - const lookahead = this.lookahead(); - if (lookahead.type !== 14 && lookahead.type !== 17) { - this.next(); - isStatic = true; - } - } - const variance = this.flowParseVariance(); - if (this.eat(0)) { - if (protoStartLoc != null) { - this.unexpected(protoStartLoc); - } - if (this.eat(0)) { - if (variance) { - this.unexpected(variance.loc.start); - } - nodeStart.internalSlots.push(this.flowParseObjectTypeInternalSlot(node, isStatic)); - } else { - nodeStart.indexers.push(this.flowParseObjectTypeIndexer(node, isStatic, variance)); - } - } else if (this.match(10) || this.match(47)) { - if (protoStartLoc != null) { - this.unexpected(protoStartLoc); - } - if (variance) { - this.unexpected(variance.loc.start); - } - nodeStart.callProperties.push(this.flowParseObjectTypeCallProperty(node, isStatic)); - } else { - let kind = "init"; - if (this.isContextual(99) || this.isContextual(104)) { - const lookahead = this.lookahead(); - if (tokenIsLiteralPropertyName(lookahead.type)) { - kind = this.state.value; - this.next(); - } - } - const propOrInexact = this.flowParseObjectTypeProperty(node, isStatic, protoStartLoc, variance, kind, allowSpread, allowInexact != null ? allowInexact : !exact); - if (propOrInexact === null) { - inexact = true; - inexactStartLoc = this.state.lastTokStartLoc; - } else { - nodeStart.properties.push(propOrInexact); - } - } - this.flowObjectTypeSemicolon(); - if (inexactStartLoc && !this.match(8) && !this.match(9)) { - this.raise(FlowErrors.UnexpectedExplicitInexactInObject, inexactStartLoc); - } - } - this.expect(endDelim); - if (allowSpread) { - nodeStart.inexact = inexact; - } - const out = this.finishNode(nodeStart, "ObjectTypeAnnotation"); - this.state.inType = oldInType; - return out; - } - flowParseObjectTypeProperty(node, isStatic, protoStartLoc, variance, kind, allowSpread, allowInexact) { - if (this.eat(21)) { - const isInexactToken = this.match(12) || this.match(13) || this.match(8) || this.match(9); - if (isInexactToken) { - if (!allowSpread) { - this.raise(FlowErrors.InexactInsideNonObject, this.state.lastTokStartLoc); - } else if (!allowInexact) { - this.raise(FlowErrors.InexactInsideExact, this.state.lastTokStartLoc); - } - if (variance) { - this.raise(FlowErrors.InexactVariance, variance); - } - return null; - } - if (!allowSpread) { - this.raise(FlowErrors.UnexpectedSpreadType, this.state.lastTokStartLoc); - } - if (protoStartLoc != null) { - this.unexpected(protoStartLoc); - } - if (variance) { - this.raise(FlowErrors.SpreadVariance, variance); - } - node.argument = this.flowParseType(); - return this.finishNode(node, "ObjectTypeSpreadProperty"); - } else { - node.key = this.flowParseObjectPropertyKey(); - node.static = isStatic; - node.proto = protoStartLoc != null; - node.kind = kind; - let optional = false; - if (this.match(47) || this.match(10)) { - node.method = true; - if (protoStartLoc != null) { - this.unexpected(protoStartLoc); - } - if (variance) { - this.unexpected(variance.loc.start); - } - node.value = this.flowParseObjectTypeMethodish(this.startNodeAt(node.loc.start)); - if (kind === "get" || kind === "set") { - this.flowCheckGetterSetterParams(node); - } - if (!allowSpread && node.key.name === "constructor" && node.value.this) { - this.raise(FlowErrors.ThisParamBannedInConstructor, node.value.this); - } - } else { - if (kind !== "init") this.unexpected(); - node.method = false; - if (this.eat(17)) { - optional = true; - } - node.value = this.flowParseTypeInitialiser(); - node.variance = variance; - } - node.optional = optional; - return this.finishNode(node, "ObjectTypeProperty"); - } - } - flowCheckGetterSetterParams(property) { - const paramCount = property.kind === "get" ? 0 : 1; - const length = property.value.params.length + (property.value.rest ? 1 : 0); - if (property.value.this) { - this.raise(property.kind === "get" ? FlowErrors.GetterMayNotHaveThisParam : FlowErrors.SetterMayNotHaveThisParam, property.value.this); - } - if (length !== paramCount) { - this.raise(property.kind === "get" ? Errors.BadGetterArity : Errors.BadSetterArity, property); - } - if (property.kind === "set" && property.value.rest) { - this.raise(Errors.BadSetterRestParameter, property); - } - } - flowObjectTypeSemicolon() { - if (!this.eat(13) && !this.eat(12) && !this.match(8) && !this.match(9)) { - this.unexpected(); - } - } - flowParseQualifiedTypeIdentifier(startLoc, id) { - var _startLoc; - (_startLoc = startLoc) != null ? _startLoc : startLoc = this.state.startLoc; - let node = id || this.flowParseRestrictedIdentifier(true); - while (this.eat(16)) { - const node2 = this.startNodeAt(startLoc); - node2.qualification = node; - node2.id = this.flowParseRestrictedIdentifier(true); - node = this.finishNode(node2, "QualifiedTypeIdentifier"); - } - return node; - } - flowParseGenericType(startLoc, id) { - const node = this.startNodeAt(startLoc); - node.typeParameters = null; - node.id = this.flowParseQualifiedTypeIdentifier(startLoc, id); - if (this.match(47)) { - node.typeParameters = this.flowParseTypeParameterInstantiation(); - } - return this.finishNode(node, "GenericTypeAnnotation"); - } - flowParseTypeofType() { - const node = this.startNode(); - this.expect(87); - node.argument = this.flowParsePrimaryType(); - return this.finishNode(node, "TypeofTypeAnnotation"); - } - flowParseTupleType() { - const node = this.startNode(); - node.types = []; - this.expect(0); - while (this.state.pos < this.length && !this.match(3)) { - node.types.push(this.flowParseType()); - if (this.match(3)) break; - this.expect(12); - } - this.expect(3); - return this.finishNode(node, "TupleTypeAnnotation"); - } - flowParseFunctionTypeParam(first) { - let name = null; - let optional = false; - let typeAnnotation = null; - const node = this.startNode(); - const lh = this.lookahead(); - const isThis = this.state.type === 78; - if (lh.type === 14 || lh.type === 17) { - if (isThis && !first) { - this.raise(FlowErrors.ThisParamMustBeFirst, node); - } - name = this.parseIdentifier(isThis); - if (this.eat(17)) { - optional = true; - if (isThis) { - this.raise(FlowErrors.ThisParamMayNotBeOptional, node); - } - } - typeAnnotation = this.flowParseTypeInitialiser(); - } else { - typeAnnotation = this.flowParseType(); - } - node.name = name; - node.optional = optional; - node.typeAnnotation = typeAnnotation; - return this.finishNode(node, "FunctionTypeParam"); - } - reinterpretTypeAsFunctionTypeParam(type) { - const node = this.startNodeAt(type.loc.start); - node.name = null; - node.optional = false; - node.typeAnnotation = type; - return this.finishNode(node, "FunctionTypeParam"); - } - flowParseFunctionTypeParams(params = []) { - let rest = null; - let _this = null; - if (this.match(78)) { - _this = this.flowParseFunctionTypeParam(true); - _this.name = null; - if (!this.match(11)) { - this.expect(12); - } - } - while (!this.match(11) && !this.match(21)) { - params.push(this.flowParseFunctionTypeParam(false)); - if (!this.match(11)) { - this.expect(12); - } - } - if (this.eat(21)) { - rest = this.flowParseFunctionTypeParam(false); - } - return { - params, - rest, - _this - }; - } - flowIdentToTypeAnnotation(startLoc, node, id) { - switch (id.name) { - case "any": - return this.finishNode(node, "AnyTypeAnnotation"); - case "bool": - case "boolean": - return this.finishNode(node, "BooleanTypeAnnotation"); - case "mixed": - return this.finishNode(node, "MixedTypeAnnotation"); - case "empty": - return this.finishNode(node, "EmptyTypeAnnotation"); - case "number": - return this.finishNode(node, "NumberTypeAnnotation"); - case "string": - return this.finishNode(node, "StringTypeAnnotation"); - case "symbol": - return this.finishNode(node, "SymbolTypeAnnotation"); - default: - this.checkNotUnderscore(id.name); - return this.flowParseGenericType(startLoc, id); - } - } - flowParsePrimaryType() { - const startLoc = this.state.startLoc; - const node = this.startNode(); - let tmp; - let type; - let isGroupedType = false; - const oldNoAnonFunctionType = this.state.noAnonFunctionType; - switch (this.state.type) { - case 5: - return this.flowParseObjectType({ - allowStatic: false, - allowExact: false, - allowSpread: true, - allowProto: false, - allowInexact: true - }); - case 6: - return this.flowParseObjectType({ - allowStatic: false, - allowExact: true, - allowSpread: true, - allowProto: false, - allowInexact: false - }); - case 0: - this.state.noAnonFunctionType = false; - type = this.flowParseTupleType(); - this.state.noAnonFunctionType = oldNoAnonFunctionType; - return type; - case 47: - { - const node = this.startNode(); - node.typeParameters = this.flowParseTypeParameterDeclaration(); - this.expect(10); - tmp = this.flowParseFunctionTypeParams(); - node.params = tmp.params; - node.rest = tmp.rest; - node.this = tmp._this; - this.expect(11); - this.expect(19); - node.returnType = this.flowParseType(); - return this.finishNode(node, "FunctionTypeAnnotation"); - } - case 10: - { - const node = this.startNode(); - this.next(); - if (!this.match(11) && !this.match(21)) { - if (tokenIsIdentifier(this.state.type) || this.match(78)) { - const token = this.lookahead().type; - isGroupedType = token !== 17 && token !== 14; - } else { - isGroupedType = true; - } - } - if (isGroupedType) { - this.state.noAnonFunctionType = false; - type = this.flowParseType(); - this.state.noAnonFunctionType = oldNoAnonFunctionType; - if (this.state.noAnonFunctionType || !(this.match(12) || this.match(11) && this.lookahead().type === 19)) { - this.expect(11); - return type; - } else { - this.eat(12); - } - } - if (type) { - tmp = this.flowParseFunctionTypeParams([this.reinterpretTypeAsFunctionTypeParam(type)]); - } else { - tmp = this.flowParseFunctionTypeParams(); - } - node.params = tmp.params; - node.rest = tmp.rest; - node.this = tmp._this; - this.expect(11); - this.expect(19); - node.returnType = this.flowParseType(); - node.typeParameters = null; - return this.finishNode(node, "FunctionTypeAnnotation"); - } - case 133: - return this.parseLiteral(this.state.value, "StringLiteralTypeAnnotation"); - case 85: - case 86: - node.value = this.match(85); - this.next(); - return this.finishNode(node, "BooleanLiteralTypeAnnotation"); - case 53: - if (this.state.value === "-") { - this.next(); - if (this.match(134)) { - return this.parseLiteralAtNode(-this.state.value, "NumberLiteralTypeAnnotation", node); - } - if (this.match(135)) { - return this.parseLiteralAtNode(-this.state.value, "BigIntLiteralTypeAnnotation", node); - } - throw this.raise(FlowErrors.UnexpectedSubtractionOperand, this.state.startLoc); - } - this.unexpected(); - return; - case 134: - return this.parseLiteral(this.state.value, "NumberLiteralTypeAnnotation"); - case 135: - return this.parseLiteral(this.state.value, "BigIntLiteralTypeAnnotation"); - case 88: - this.next(); - return this.finishNode(node, "VoidTypeAnnotation"); - case 84: - this.next(); - return this.finishNode(node, "NullLiteralTypeAnnotation"); - case 78: - this.next(); - return this.finishNode(node, "ThisTypeAnnotation"); - case 55: - this.next(); - return this.finishNode(node, "ExistsTypeAnnotation"); - case 87: - return this.flowParseTypeofType(); - default: - if (tokenIsKeyword(this.state.type)) { - const label = tokenLabelName(this.state.type); - this.next(); - return super.createIdentifier(node, label); - } else if (tokenIsIdentifier(this.state.type)) { - if (this.isContextual(129)) { - return this.flowParseInterfaceType(); - } - return this.flowIdentToTypeAnnotation(startLoc, node, this.parseIdentifier()); - } - } - this.unexpected(); - } - flowParsePostfixType() { - const startLoc = this.state.startLoc; - let type = this.flowParsePrimaryType(); - let seenOptionalIndexedAccess = false; - while ((this.match(0) || this.match(18)) && !this.canInsertSemicolon()) { - const node = this.startNodeAt(startLoc); - const optional = this.eat(18); - seenOptionalIndexedAccess = seenOptionalIndexedAccess || optional; - this.expect(0); - if (!optional && this.match(3)) { - node.elementType = type; - this.next(); - type = this.finishNode(node, "ArrayTypeAnnotation"); - } else { - node.objectType = type; - node.indexType = this.flowParseType(); - this.expect(3); - if (seenOptionalIndexedAccess) { - node.optional = optional; - type = this.finishNode(node, "OptionalIndexedAccessType"); - } else { - type = this.finishNode(node, "IndexedAccessType"); - } - } - } - return type; - } - flowParsePrefixType() { - const node = this.startNode(); - if (this.eat(17)) { - node.typeAnnotation = this.flowParsePrefixType(); - return this.finishNode(node, "NullableTypeAnnotation"); - } else { - return this.flowParsePostfixType(); - } - } - flowParseAnonFunctionWithoutParens() { - const param = this.flowParsePrefixType(); - if (!this.state.noAnonFunctionType && this.eat(19)) { - const node = this.startNodeAt(param.loc.start); - node.params = [this.reinterpretTypeAsFunctionTypeParam(param)]; - node.rest = null; - node.this = null; - node.returnType = this.flowParseType(); - node.typeParameters = null; - return this.finishNode(node, "FunctionTypeAnnotation"); - } - return param; - } - flowParseIntersectionType() { - const node = this.startNode(); - this.eat(45); - const type = this.flowParseAnonFunctionWithoutParens(); - node.types = [type]; - while (this.eat(45)) { - node.types.push(this.flowParseAnonFunctionWithoutParens()); - } - return node.types.length === 1 ? type : this.finishNode(node, "IntersectionTypeAnnotation"); - } - flowParseUnionType() { - const node = this.startNode(); - this.eat(43); - const type = this.flowParseIntersectionType(); - node.types = [type]; - while (this.eat(43)) { - node.types.push(this.flowParseIntersectionType()); - } - return node.types.length === 1 ? type : this.finishNode(node, "UnionTypeAnnotation"); - } - flowParseType() { - const oldInType = this.state.inType; - this.state.inType = true; - const type = this.flowParseUnionType(); - this.state.inType = oldInType; - return type; - } - flowParseTypeOrImplicitInstantiation() { - if (this.state.type === 132 && this.state.value === "_") { - const startLoc = this.state.startLoc; - const node = this.parseIdentifier(); - return this.flowParseGenericType(startLoc, node); - } else { - return this.flowParseType(); - } - } - flowParseTypeAnnotation() { - const node = this.startNode(); - node.typeAnnotation = this.flowParseTypeInitialiser(); - return this.finishNode(node, "TypeAnnotation"); - } - flowParseTypeAnnotatableIdentifier(allowPrimitiveOverride) { - const ident = allowPrimitiveOverride ? this.parseIdentifier() : this.flowParseRestrictedIdentifier(); - if (this.match(14)) { - ident.typeAnnotation = this.flowParseTypeAnnotation(); - this.resetEndLocation(ident); - } - return ident; - } - typeCastToParameter(node) { - node.expression.typeAnnotation = node.typeAnnotation; - this.resetEndLocation(node.expression, node.typeAnnotation.loc.end); - return node.expression; - } - flowParseVariance() { - let variance = null; - if (this.match(53)) { - variance = this.startNode(); - if (this.state.value === "+") { - variance.kind = "plus"; - } else { - variance.kind = "minus"; - } - this.next(); - return this.finishNode(variance, "Variance"); - } - return variance; - } - parseFunctionBody(node, allowExpressionBody, isMethod = false) { - if (allowExpressionBody) { - this.forwardNoArrowParamsConversionAt(node, () => super.parseFunctionBody(node, true, isMethod)); - return; - } - super.parseFunctionBody(node, false, isMethod); - } - parseFunctionBodyAndFinish(node, type, isMethod = false) { - if (this.match(14)) { - const typeNode = this.startNode(); - [typeNode.typeAnnotation, node.predicate] = this.flowParseTypeAndPredicateInitialiser(); - node.returnType = typeNode.typeAnnotation ? this.finishNode(typeNode, "TypeAnnotation") : null; - } - return super.parseFunctionBodyAndFinish(node, type, isMethod); - } - parseStatementLike(flags) { - if (this.state.strict && this.isContextual(129)) { - const lookahead = this.lookahead(); - if (tokenIsKeywordOrIdentifier(lookahead.type)) { - const node = this.startNode(); - this.next(); - return this.flowParseInterface(node); - } - } else if (this.shouldParseEnums() && this.isContextual(126)) { - const node = this.startNode(); - this.next(); - return this.flowParseEnumDeclaration(node); - } - const stmt = super.parseStatementLike(flags); - if (this.flowPragma === undefined && !this.isValidDirective(stmt)) { - this.flowPragma = null; - } - return stmt; - } - parseExpressionStatement(node, expr, decorators) { - if (expr.type === "Identifier") { - if (expr.name === "declare") { - if (this.match(80) || tokenIsIdentifier(this.state.type) || this.match(68) || this.match(74) || this.match(82)) { - return this.flowParseDeclare(node); - } - } else if (tokenIsIdentifier(this.state.type)) { - if (expr.name === "interface") { - return this.flowParseInterface(node); - } else if (expr.name === "type") { - return this.flowParseTypeAlias(node); - } else if (expr.name === "opaque") { - return this.flowParseOpaqueType(node, false); - } - } - } - return super.parseExpressionStatement(node, expr, decorators); - } - shouldParseExportDeclaration() { - const { - type - } = this.state; - if (tokenIsFlowInterfaceOrTypeOrOpaque(type) || this.shouldParseEnums() && type === 126) { - return !this.state.containsEsc; - } - return super.shouldParseExportDeclaration(); - } - isExportDefaultSpecifier() { - const { - type - } = this.state; - if (tokenIsFlowInterfaceOrTypeOrOpaque(type) || this.shouldParseEnums() && type === 126) { - return this.state.containsEsc; - } - return super.isExportDefaultSpecifier(); - } - parseExportDefaultExpression() { - if (this.shouldParseEnums() && this.isContextual(126)) { - const node = this.startNode(); - this.next(); - return this.flowParseEnumDeclaration(node); - } - return super.parseExportDefaultExpression(); - } - parseConditional(expr, startLoc, refExpressionErrors) { - if (!this.match(17)) return expr; - if (this.state.maybeInArrowParameters) { - const nextCh = this.lookaheadCharCode(); - if (nextCh === 44 || nextCh === 61 || nextCh === 58 || nextCh === 41) { - this.setOptionalParametersError(refExpressionErrors); - return expr; - } - } - this.expect(17); - const state = this.state.clone(); - const originalNoArrowAt = this.state.noArrowAt; - const node = this.startNodeAt(startLoc); - let { - consequent, - failed - } = this.tryParseConditionalConsequent(); - let [valid, invalid] = this.getArrowLikeExpressions(consequent); - if (failed || invalid.length > 0) { - const noArrowAt = [...originalNoArrowAt]; - if (invalid.length > 0) { - this.state = state; - this.state.noArrowAt = noArrowAt; - for (let i = 0; i < invalid.length; i++) { - noArrowAt.push(invalid[i].start); - } - ({ - consequent, - failed - } = this.tryParseConditionalConsequent()); - [valid, invalid] = this.getArrowLikeExpressions(consequent); - } - if (failed && valid.length > 1) { - this.raise(FlowErrors.AmbiguousConditionalArrow, state.startLoc); - } - if (failed && valid.length === 1) { - this.state = state; - noArrowAt.push(valid[0].start); - this.state.noArrowAt = noArrowAt; - ({ - consequent, - failed - } = this.tryParseConditionalConsequent()); - } - } - this.getArrowLikeExpressions(consequent, true); - this.state.noArrowAt = originalNoArrowAt; - this.expect(14); - node.test = expr; - node.consequent = consequent; - node.alternate = this.forwardNoArrowParamsConversionAt(node, () => this.parseMaybeAssign(undefined, undefined)); - return this.finishNode(node, "ConditionalExpression"); - } - tryParseConditionalConsequent() { - this.state.noArrowParamsConversionAt.push(this.state.start); - const consequent = this.parseMaybeAssignAllowIn(); - const failed = !this.match(14); - this.state.noArrowParamsConversionAt.pop(); - return { - consequent, - failed - }; - } - getArrowLikeExpressions(node, disallowInvalid) { - const stack = [node]; - const arrows = []; - while (stack.length !== 0) { - const node = stack.pop(); - if (node.type === "ArrowFunctionExpression" && node.body.type !== "BlockStatement") { - if (node.typeParameters || !node.returnType) { - this.finishArrowValidation(node); - } else { - arrows.push(node); - } - stack.push(node.body); - } else if (node.type === "ConditionalExpression") { - stack.push(node.consequent); - stack.push(node.alternate); - } - } - if (disallowInvalid) { - arrows.forEach(node => this.finishArrowValidation(node)); - return [arrows, []]; - } - return partition(arrows, node => node.params.every(param => this.isAssignable(param, true))); - } - finishArrowValidation(node) { - var _node$extra; - this.toAssignableList(node.params, (_node$extra = node.extra) == null ? void 0 : _node$extra.trailingCommaLoc, false); - this.scope.enter(2 | 4); - super.checkParams(node, false, true); - this.scope.exit(); - } - forwardNoArrowParamsConversionAt(node, parse) { - let result; - if (this.state.noArrowParamsConversionAt.includes(node.start)) { - this.state.noArrowParamsConversionAt.push(this.state.start); - result = parse(); - this.state.noArrowParamsConversionAt.pop(); - } else { - result = parse(); - } - return result; - } - parseParenItem(node, startLoc) { - const newNode = super.parseParenItem(node, startLoc); - if (this.eat(17)) { - newNode.optional = true; - this.resetEndLocation(node); - } - if (this.match(14)) { - const typeCastNode = this.startNodeAt(startLoc); - typeCastNode.expression = newNode; - typeCastNode.typeAnnotation = this.flowParseTypeAnnotation(); - return this.finishNode(typeCastNode, "TypeCastExpression"); - } - return newNode; - } - assertModuleNodeAllowed(node) { - if (node.type === "ImportDeclaration" && (node.importKind === "type" || node.importKind === "typeof") || node.type === "ExportNamedDeclaration" && node.exportKind === "type" || node.type === "ExportAllDeclaration" && node.exportKind === "type") { - return; - } - super.assertModuleNodeAllowed(node); - } - parseExportDeclaration(node) { - if (this.isContextual(130)) { - node.exportKind = "type"; - const declarationNode = this.startNode(); - this.next(); - if (this.match(5)) { - node.specifiers = this.parseExportSpecifiers(true); - super.parseExportFrom(node); - return null; - } else { - return this.flowParseTypeAlias(declarationNode); - } - } else if (this.isContextual(131)) { - node.exportKind = "type"; - const declarationNode = this.startNode(); - this.next(); - return this.flowParseOpaqueType(declarationNode, false); - } else if (this.isContextual(129)) { - node.exportKind = "type"; - const declarationNode = this.startNode(); - this.next(); - return this.flowParseInterface(declarationNode); - } else if (this.shouldParseEnums() && this.isContextual(126)) { - node.exportKind = "value"; - const declarationNode = this.startNode(); - this.next(); - return this.flowParseEnumDeclaration(declarationNode); - } else { - return super.parseExportDeclaration(node); - } - } - eatExportStar(node) { - if (super.eatExportStar(node)) return true; - if (this.isContextual(130) && this.lookahead().type === 55) { - node.exportKind = "type"; - this.next(); - this.next(); - return true; - } - return false; - } - maybeParseExportNamespaceSpecifier(node) { - const { - startLoc - } = this.state; - const hasNamespace = super.maybeParseExportNamespaceSpecifier(node); - if (hasNamespace && node.exportKind === "type") { - this.unexpected(startLoc); - } - return hasNamespace; - } - parseClassId(node, isStatement, optionalId) { - super.parseClassId(node, isStatement, optionalId); - if (this.match(47)) { - node.typeParameters = this.flowParseTypeParameterDeclaration(); - } - } - parseClassMember(classBody, member, state) { - const { - startLoc - } = this.state; - if (this.isContextual(125)) { - if (super.parseClassMemberFromModifier(classBody, member)) { - return; - } - member.declare = true; - } - super.parseClassMember(classBody, member, state); - if (member.declare) { - if (member.type !== "ClassProperty" && member.type !== "ClassPrivateProperty" && member.type !== "PropertyDefinition") { - this.raise(FlowErrors.DeclareClassElement, startLoc); - } else if (member.value) { - this.raise(FlowErrors.DeclareClassFieldInitializer, member.value); - } - } - } - isIterator(word) { - return word === "iterator" || word === "asyncIterator"; - } - readIterator() { - const word = super.readWord1(); - const fullWord = "@@" + word; - if (!this.isIterator(word) || !this.state.inType) { - this.raise(Errors.InvalidIdentifier, this.state.curPosition(), { - identifierName: fullWord - }); - } - this.finishToken(132, fullWord); - } - getTokenFromCode(code) { - const next = this.input.charCodeAt(this.state.pos + 1); - if (code === 123 && next === 124) { - this.finishOp(6, 2); - } else if (this.state.inType && (code === 62 || code === 60)) { - this.finishOp(code === 62 ? 48 : 47, 1); - } else if (this.state.inType && code === 63) { - if (next === 46) { - this.finishOp(18, 2); - } else { - this.finishOp(17, 1); - } - } else if (isIteratorStart(code, next, this.input.charCodeAt(this.state.pos + 2))) { - this.state.pos += 2; - this.readIterator(); - } else { - super.getTokenFromCode(code); - } - } - isAssignable(node, isBinding) { - if (node.type === "TypeCastExpression") { - return this.isAssignable(node.expression, isBinding); - } else { - return super.isAssignable(node, isBinding); - } - } - toAssignable(node, isLHS = false) { - if (!isLHS && node.type === "AssignmentExpression" && node.left.type === "TypeCastExpression") { - node.left = this.typeCastToParameter(node.left); - } - super.toAssignable(node, isLHS); - } - toAssignableList(exprList, trailingCommaLoc, isLHS) { - for (let i = 0; i < exprList.length; i++) { - const expr = exprList[i]; - if ((expr == null ? void 0 : expr.type) === "TypeCastExpression") { - exprList[i] = this.typeCastToParameter(expr); - } - } - super.toAssignableList(exprList, trailingCommaLoc, isLHS); - } - toReferencedList(exprList, isParenthesizedExpr) { - for (let i = 0; i < exprList.length; i++) { - var _expr$extra; - const expr = exprList[i]; - if (expr && expr.type === "TypeCastExpression" && !((_expr$extra = expr.extra) != null && _expr$extra.parenthesized) && (exprList.length > 1 || !isParenthesizedExpr)) { - this.raise(FlowErrors.TypeCastInPattern, expr.typeAnnotation); - } - } - return exprList; - } - parseArrayLike(close, canBePattern, isTuple, refExpressionErrors) { - const node = super.parseArrayLike(close, canBePattern, isTuple, refExpressionErrors); - if (canBePattern && !this.state.maybeInArrowParameters) { - this.toReferencedList(node.elements); - } - return node; - } - isValidLVal(type, isParenthesized, binding) { - return type === "TypeCastExpression" || super.isValidLVal(type, isParenthesized, binding); - } - parseClassProperty(node) { - if (this.match(14)) { - node.typeAnnotation = this.flowParseTypeAnnotation(); - } - return super.parseClassProperty(node); - } - parseClassPrivateProperty(node) { - if (this.match(14)) { - node.typeAnnotation = this.flowParseTypeAnnotation(); - } - return super.parseClassPrivateProperty(node); - } - isClassMethod() { - return this.match(47) || super.isClassMethod(); - } - isClassProperty() { - return this.match(14) || super.isClassProperty(); - } - isNonstaticConstructor(method) { - return !this.match(14) && super.isNonstaticConstructor(method); - } - pushClassMethod(classBody, method, isGenerator, isAsync, isConstructor, allowsDirectSuper) { - if (method.variance) { - this.unexpected(method.variance.loc.start); - } - delete method.variance; - if (this.match(47)) { - method.typeParameters = this.flowParseTypeParameterDeclaration(); - } - super.pushClassMethod(classBody, method, isGenerator, isAsync, isConstructor, allowsDirectSuper); - if (method.params && isConstructor) { - const params = method.params; - if (params.length > 0 && this.isThisParam(params[0])) { - this.raise(FlowErrors.ThisParamBannedInConstructor, method); - } - } else if (method.type === "MethodDefinition" && isConstructor && method.value.params) { - const params = method.value.params; - if (params.length > 0 && this.isThisParam(params[0])) { - this.raise(FlowErrors.ThisParamBannedInConstructor, method); - } - } - } - pushClassPrivateMethod(classBody, method, isGenerator, isAsync) { - if (method.variance) { - this.unexpected(method.variance.loc.start); - } - delete method.variance; - if (this.match(47)) { - method.typeParameters = this.flowParseTypeParameterDeclaration(); - } - super.pushClassPrivateMethod(classBody, method, isGenerator, isAsync); - } - parseClassSuper(node) { - super.parseClassSuper(node); - if (node.superClass && this.match(47)) { - node.superTypeParameters = this.flowParseTypeParameterInstantiation(); - } - if (this.isContextual(113)) { - this.next(); - const implemented = node.implements = []; - do { - const node = this.startNode(); - node.id = this.flowParseRestrictedIdentifier(true); - if (this.match(47)) { - node.typeParameters = this.flowParseTypeParameterInstantiation(); - } else { - node.typeParameters = null; - } - implemented.push(this.finishNode(node, "ClassImplements")); - } while (this.eat(12)); - } - } - checkGetterSetterParams(method) { - super.checkGetterSetterParams(method); - const params = this.getObjectOrClassMethodParams(method); - if (params.length > 0) { - const param = params[0]; - if (this.isThisParam(param) && method.kind === "get") { - this.raise(FlowErrors.GetterMayNotHaveThisParam, param); - } else if (this.isThisParam(param)) { - this.raise(FlowErrors.SetterMayNotHaveThisParam, param); - } - } - } - parsePropertyNamePrefixOperator(node) { - node.variance = this.flowParseVariance(); - } - parseObjPropValue(prop, startLoc, isGenerator, isAsync, isPattern, isAccessor, refExpressionErrors) { - if (prop.variance) { - this.unexpected(prop.variance.loc.start); - } - delete prop.variance; - let typeParameters; - if (this.match(47) && !isAccessor) { - typeParameters = this.flowParseTypeParameterDeclaration(); - if (!this.match(10)) this.unexpected(); - } - const result = super.parseObjPropValue(prop, startLoc, isGenerator, isAsync, isPattern, isAccessor, refExpressionErrors); - if (typeParameters) { - (result.value || result).typeParameters = typeParameters; - } - return result; - } - parseAssignableListItemTypes(param) { - if (this.eat(17)) { - if (param.type !== "Identifier") { - this.raise(FlowErrors.PatternIsOptional, param); - } - if (this.isThisParam(param)) { - this.raise(FlowErrors.ThisParamMayNotBeOptional, param); - } - param.optional = true; - } - if (this.match(14)) { - param.typeAnnotation = this.flowParseTypeAnnotation(); - } else if (this.isThisParam(param)) { - this.raise(FlowErrors.ThisParamAnnotationRequired, param); - } - if (this.match(29) && this.isThisParam(param)) { - this.raise(FlowErrors.ThisParamNoDefault, param); - } - this.resetEndLocation(param); - return param; - } - parseMaybeDefault(startLoc, left) { - const node = super.parseMaybeDefault(startLoc, left); - if (node.type === "AssignmentPattern" && node.typeAnnotation && node.right.start < node.typeAnnotation.start) { - this.raise(FlowErrors.TypeBeforeInitializer, node.typeAnnotation); - } - return node; - } - checkImportReflection(node) { - super.checkImportReflection(node); - if (node.module && node.importKind !== "value") { - this.raise(FlowErrors.ImportReflectionHasImportType, node.specifiers[0].loc.start); - } - } - parseImportSpecifierLocal(node, specifier, type) { - specifier.local = hasTypeImportKind(node) ? this.flowParseRestrictedIdentifier(true, true) : this.parseIdentifier(); - node.specifiers.push(this.finishImportSpecifier(specifier, type)); - } - isPotentialImportPhase(isExport) { - if (super.isPotentialImportPhase(isExport)) return true; - if (this.isContextual(130)) { - if (!isExport) return true; - const ch = this.lookaheadCharCode(); - return ch === 123 || ch === 42; - } - return !isExport && this.isContextual(87); - } - applyImportPhase(node, isExport, phase, loc) { - super.applyImportPhase(node, isExport, phase, loc); - if (isExport) { - if (!phase && this.match(65)) { - return; - } - node.exportKind = phase === "type" ? phase : "value"; - } else { - if (phase === "type" && this.match(55)) this.unexpected(); - node.importKind = phase === "type" || phase === "typeof" ? phase : "value"; - } - } - parseImportSpecifier(specifier, importedIsString, isInTypeOnlyImport, isMaybeTypeOnly, bindingType) { - const firstIdent = specifier.imported; - let specifierTypeKind = null; - if (firstIdent.type === "Identifier") { - if (firstIdent.name === "type") { - specifierTypeKind = "type"; - } else if (firstIdent.name === "typeof") { - specifierTypeKind = "typeof"; - } - } - let isBinding = false; - if (this.isContextual(93) && !this.isLookaheadContextual("as")) { - const as_ident = this.parseIdentifier(true); - if (specifierTypeKind !== null && !tokenIsKeywordOrIdentifier(this.state.type)) { - specifier.imported = as_ident; - specifier.importKind = specifierTypeKind; - specifier.local = cloneIdentifier(as_ident); - } else { - specifier.imported = firstIdent; - specifier.importKind = null; - specifier.local = this.parseIdentifier(); - } - } else { - if (specifierTypeKind !== null && tokenIsKeywordOrIdentifier(this.state.type)) { - specifier.imported = this.parseIdentifier(true); - specifier.importKind = specifierTypeKind; - } else { - if (importedIsString) { - throw this.raise(Errors.ImportBindingIsString, specifier, { - importName: firstIdent.value - }); - } - specifier.imported = firstIdent; - specifier.importKind = null; - } - if (this.eatContextual(93)) { - specifier.local = this.parseIdentifier(); - } else { - isBinding = true; - specifier.local = cloneIdentifier(specifier.imported); - } - } - const specifierIsTypeImport = hasTypeImportKind(specifier); - if (isInTypeOnlyImport && specifierIsTypeImport) { - this.raise(FlowErrors.ImportTypeShorthandOnlyInPureImport, specifier); - } - if (isInTypeOnlyImport || specifierIsTypeImport) { - this.checkReservedType(specifier.local.name, specifier.local.loc.start, true); - } - if (isBinding && !isInTypeOnlyImport && !specifierIsTypeImport) { - this.checkReservedWord(specifier.local.name, specifier.loc.start, true, true); - } - return this.finishImportSpecifier(specifier, "ImportSpecifier"); - } - parseBindingAtom() { - switch (this.state.type) { - case 78: - return this.parseIdentifier(true); - default: - return super.parseBindingAtom(); - } - } - parseFunctionParams(node, isConstructor) { - const kind = node.kind; - if (kind !== "get" && kind !== "set" && this.match(47)) { - node.typeParameters = this.flowParseTypeParameterDeclaration(); - } - super.parseFunctionParams(node, isConstructor); - } - parseVarId(decl, kind) { - super.parseVarId(decl, kind); - if (this.match(14)) { - decl.id.typeAnnotation = this.flowParseTypeAnnotation(); - this.resetEndLocation(decl.id); - } - } - parseAsyncArrowFromCallExpression(node, call) { - if (this.match(14)) { - const oldNoAnonFunctionType = this.state.noAnonFunctionType; - this.state.noAnonFunctionType = true; - node.returnType = this.flowParseTypeAnnotation(); - this.state.noAnonFunctionType = oldNoAnonFunctionType; - } - return super.parseAsyncArrowFromCallExpression(node, call); - } - shouldParseAsyncArrow() { - return this.match(14) || super.shouldParseAsyncArrow(); - } - parseMaybeAssign(refExpressionErrors, afterLeftParse) { - var _jsx; - let state = null; - let jsx; - if (this.hasPlugin("jsx") && (this.match(142) || this.match(47))) { - state = this.state.clone(); - jsx = this.tryParse(() => super.parseMaybeAssign(refExpressionErrors, afterLeftParse), state); - if (!jsx.error) return jsx.node; - const { - context - } = this.state; - const currentContext = context[context.length - 1]; - if (currentContext === types.j_oTag || currentContext === types.j_expr) { - context.pop(); - } - } - if ((_jsx = jsx) != null && _jsx.error || this.match(47)) { - var _jsx2, _jsx3; - state = state || this.state.clone(); - let typeParameters; - const arrow = this.tryParse(abort => { - var _arrowExpression$extr; - typeParameters = this.flowParseTypeParameterDeclaration(); - const arrowExpression = this.forwardNoArrowParamsConversionAt(typeParameters, () => { - const result = super.parseMaybeAssign(refExpressionErrors, afterLeftParse); - this.resetStartLocationFromNode(result, typeParameters); - return result; - }); - if ((_arrowExpression$extr = arrowExpression.extra) != null && _arrowExpression$extr.parenthesized) abort(); - const expr = this.maybeUnwrapTypeCastExpression(arrowExpression); - if (expr.type !== "ArrowFunctionExpression") abort(); - expr.typeParameters = typeParameters; - this.resetStartLocationFromNode(expr, typeParameters); - return arrowExpression; - }, state); - let arrowExpression = null; - if (arrow.node && this.maybeUnwrapTypeCastExpression(arrow.node).type === "ArrowFunctionExpression") { - if (!arrow.error && !arrow.aborted) { - if (arrow.node.async) { - this.raise(FlowErrors.UnexpectedTypeParameterBeforeAsyncArrowFunction, typeParameters); - } - return arrow.node; - } - arrowExpression = arrow.node; - } - if ((_jsx2 = jsx) != null && _jsx2.node) { - this.state = jsx.failState; - return jsx.node; - } - if (arrowExpression) { - this.state = arrow.failState; - return arrowExpression; - } - if ((_jsx3 = jsx) != null && _jsx3.thrown) throw jsx.error; - if (arrow.thrown) throw arrow.error; - throw this.raise(FlowErrors.UnexpectedTokenAfterTypeParameter, typeParameters); - } - return super.parseMaybeAssign(refExpressionErrors, afterLeftParse); - } - parseArrow(node) { - if (this.match(14)) { - const result = this.tryParse(() => { - const oldNoAnonFunctionType = this.state.noAnonFunctionType; - this.state.noAnonFunctionType = true; - const typeNode = this.startNode(); - [typeNode.typeAnnotation, node.predicate] = this.flowParseTypeAndPredicateInitialiser(); - this.state.noAnonFunctionType = oldNoAnonFunctionType; - if (this.canInsertSemicolon()) this.unexpected(); - if (!this.match(19)) this.unexpected(); - return typeNode; - }); - if (result.thrown) return null; - if (result.error) this.state = result.failState; - node.returnType = result.node.typeAnnotation ? this.finishNode(result.node, "TypeAnnotation") : null; - } - return super.parseArrow(node); - } - shouldParseArrow(params) { - return this.match(14) || super.shouldParseArrow(params); - } - setArrowFunctionParameters(node, params) { - if (this.state.noArrowParamsConversionAt.includes(node.start)) { - node.params = params; - } else { - super.setArrowFunctionParameters(node, params); - } - } - checkParams(node, allowDuplicates, isArrowFunction, strictModeChanged = true) { - if (isArrowFunction && this.state.noArrowParamsConversionAt.includes(node.start)) { - return; - } - for (let i = 0; i < node.params.length; i++) { - if (this.isThisParam(node.params[i]) && i > 0) { - this.raise(FlowErrors.ThisParamMustBeFirst, node.params[i]); - } - } - super.checkParams(node, allowDuplicates, isArrowFunction, strictModeChanged); - } - parseParenAndDistinguishExpression(canBeArrow) { - return super.parseParenAndDistinguishExpression(canBeArrow && !this.state.noArrowAt.includes(this.state.start)); - } - parseSubscripts(base, startLoc, noCalls) { - if (base.type === "Identifier" && base.name === "async" && this.state.noArrowAt.includes(startLoc.index)) { - this.next(); - const node = this.startNodeAt(startLoc); - node.callee = base; - node.arguments = super.parseCallExpressionArguments(11, false); - base = this.finishNode(node, "CallExpression"); - } else if (base.type === "Identifier" && base.name === "async" && this.match(47)) { - const state = this.state.clone(); - const arrow = this.tryParse(abort => this.parseAsyncArrowWithTypeParameters(startLoc) || abort(), state); - if (!arrow.error && !arrow.aborted) return arrow.node; - const result = this.tryParse(() => super.parseSubscripts(base, startLoc, noCalls), state); - if (result.node && !result.error) return result.node; - if (arrow.node) { - this.state = arrow.failState; - return arrow.node; - } - if (result.node) { - this.state = result.failState; - return result.node; - } - throw arrow.error || result.error; - } - return super.parseSubscripts(base, startLoc, noCalls); - } - parseSubscript(base, startLoc, noCalls, subscriptState) { - if (this.match(18) && this.isLookaheadToken_lt()) { - subscriptState.optionalChainMember = true; - if (noCalls) { - subscriptState.stop = true; - return base; - } - this.next(); - const node = this.startNodeAt(startLoc); - node.callee = base; - node.typeArguments = this.flowParseTypeParameterInstantiation(); - this.expect(10); - node.arguments = this.parseCallExpressionArguments(11, false); - node.optional = true; - return this.finishCallExpression(node, true); - } else if (!noCalls && this.shouldParseTypes() && this.match(47)) { - const node = this.startNodeAt(startLoc); - node.callee = base; - const result = this.tryParse(() => { - node.typeArguments = this.flowParseTypeParameterInstantiationCallOrNew(); - this.expect(10); - node.arguments = super.parseCallExpressionArguments(11, false); - if (subscriptState.optionalChainMember) { - node.optional = false; - } - return this.finishCallExpression(node, subscriptState.optionalChainMember); - }); - if (result.node) { - if (result.error) this.state = result.failState; - return result.node; - } - } - return super.parseSubscript(base, startLoc, noCalls, subscriptState); - } - parseNewCallee(node) { - super.parseNewCallee(node); - let targs = null; - if (this.shouldParseTypes() && this.match(47)) { - targs = this.tryParse(() => this.flowParseTypeParameterInstantiationCallOrNew()).node; - } - node.typeArguments = targs; - } - parseAsyncArrowWithTypeParameters(startLoc) { - const node = this.startNodeAt(startLoc); - this.parseFunctionParams(node, false); - if (!this.parseArrow(node)) return; - return super.parseArrowExpression(node, undefined, true); - } - readToken_mult_modulo(code) { - const next = this.input.charCodeAt(this.state.pos + 1); - if (code === 42 && next === 47 && this.state.hasFlowComment) { - this.state.hasFlowComment = false; - this.state.pos += 2; - this.nextToken(); - return; - } - super.readToken_mult_modulo(code); - } - readToken_pipe_amp(code) { - const next = this.input.charCodeAt(this.state.pos + 1); - if (code === 124 && next === 125) { - this.finishOp(9, 2); - return; - } - super.readToken_pipe_amp(code); - } - parseTopLevel(file, program) { - const fileNode = super.parseTopLevel(file, program); - if (this.state.hasFlowComment) { - this.raise(FlowErrors.UnterminatedFlowComment, this.state.curPosition()); - } - return fileNode; - } - skipBlockComment() { - if (this.hasPlugin("flowComments") && this.skipFlowComment()) { - if (this.state.hasFlowComment) { - throw this.raise(FlowErrors.NestedFlowComment, this.state.startLoc); - } - this.hasFlowCommentCompletion(); - const commentSkip = this.skipFlowComment(); - if (commentSkip) { - this.state.pos += commentSkip; - this.state.hasFlowComment = true; - } - return; - } - return super.skipBlockComment(this.state.hasFlowComment ? "*-/" : "*/"); - } - skipFlowComment() { - const { - pos - } = this.state; - let shiftToFirstNonWhiteSpace = 2; - while ([32, 9].includes(this.input.charCodeAt(pos + shiftToFirstNonWhiteSpace))) { - shiftToFirstNonWhiteSpace++; - } - const ch2 = this.input.charCodeAt(shiftToFirstNonWhiteSpace + pos); - const ch3 = this.input.charCodeAt(shiftToFirstNonWhiteSpace + pos + 1); - if (ch2 === 58 && ch3 === 58) { - return shiftToFirstNonWhiteSpace + 2; - } - if (this.input.slice(shiftToFirstNonWhiteSpace + pos, shiftToFirstNonWhiteSpace + pos + 12) === "flow-include") { - return shiftToFirstNonWhiteSpace + 12; - } - if (ch2 === 58 && ch3 !== 58) { - return shiftToFirstNonWhiteSpace; - } - return false; - } - hasFlowCommentCompletion() { - const end = this.input.indexOf("*/", this.state.pos); - if (end === -1) { - throw this.raise(Errors.UnterminatedComment, this.state.curPosition()); - } - } - flowEnumErrorBooleanMemberNotInitialized(loc, { - enumName, - memberName - }) { - this.raise(FlowErrors.EnumBooleanMemberNotInitialized, loc, { - memberName, - enumName - }); - } - flowEnumErrorInvalidMemberInitializer(loc, enumContext) { - return this.raise(!enumContext.explicitType ? FlowErrors.EnumInvalidMemberInitializerUnknownType : enumContext.explicitType === "symbol" ? FlowErrors.EnumInvalidMemberInitializerSymbolType : FlowErrors.EnumInvalidMemberInitializerPrimaryType, loc, enumContext); - } - flowEnumErrorNumberMemberNotInitialized(loc, details) { - this.raise(FlowErrors.EnumNumberMemberNotInitialized, loc, details); - } - flowEnumErrorStringMemberInconsistentlyInitialized(node, details) { - this.raise(FlowErrors.EnumStringMemberInconsistentlyInitialized, node, details); - } - flowEnumMemberInit() { - const startLoc = this.state.startLoc; - const endOfInit = () => this.match(12) || this.match(8); - switch (this.state.type) { - case 134: - { - const literal = this.parseNumericLiteral(this.state.value); - if (endOfInit()) { - return { - type: "number", - loc: literal.loc.start, - value: literal - }; - } - return { - type: "invalid", - loc: startLoc - }; - } - case 133: - { - const literal = this.parseStringLiteral(this.state.value); - if (endOfInit()) { - return { - type: "string", - loc: literal.loc.start, - value: literal - }; - } - return { - type: "invalid", - loc: startLoc - }; - } - case 85: - case 86: - { - const literal = this.parseBooleanLiteral(this.match(85)); - if (endOfInit()) { - return { - type: "boolean", - loc: literal.loc.start, - value: literal - }; - } - return { - type: "invalid", - loc: startLoc - }; - } - default: - return { - type: "invalid", - loc: startLoc - }; - } - } - flowEnumMemberRaw() { - const loc = this.state.startLoc; - const id = this.parseIdentifier(true); - const init = this.eat(29) ? this.flowEnumMemberInit() : { - type: "none", - loc - }; - return { - id, - init - }; - } - flowEnumCheckExplicitTypeMismatch(loc, context, expectedType) { - const { - explicitType - } = context; - if (explicitType === null) { - return; - } - if (explicitType !== expectedType) { - this.flowEnumErrorInvalidMemberInitializer(loc, context); - } - } - flowEnumMembers({ - enumName, - explicitType - }) { - const seenNames = new Set(); - const members = { - booleanMembers: [], - numberMembers: [], - stringMembers: [], - defaultedMembers: [] - }; - let hasUnknownMembers = false; - while (!this.match(8)) { - if (this.eat(21)) { - hasUnknownMembers = true; - break; - } - const memberNode = this.startNode(); - const { - id, - init - } = this.flowEnumMemberRaw(); - const memberName = id.name; - if (memberName === "") { - continue; - } - if (/^[a-z]/.test(memberName)) { - this.raise(FlowErrors.EnumInvalidMemberName, id, { - memberName, - suggestion: memberName[0].toUpperCase() + memberName.slice(1), - enumName - }); - } - if (seenNames.has(memberName)) { - this.raise(FlowErrors.EnumDuplicateMemberName, id, { - memberName, - enumName - }); - } - seenNames.add(memberName); - const context = { - enumName, - explicitType, - memberName - }; - memberNode.id = id; - switch (init.type) { - case "boolean": - { - this.flowEnumCheckExplicitTypeMismatch(init.loc, context, "boolean"); - memberNode.init = init.value; - members.booleanMembers.push(this.finishNode(memberNode, "EnumBooleanMember")); - break; - } - case "number": - { - this.flowEnumCheckExplicitTypeMismatch(init.loc, context, "number"); - memberNode.init = init.value; - members.numberMembers.push(this.finishNode(memberNode, "EnumNumberMember")); - break; - } - case "string": - { - this.flowEnumCheckExplicitTypeMismatch(init.loc, context, "string"); - memberNode.init = init.value; - members.stringMembers.push(this.finishNode(memberNode, "EnumStringMember")); - break; - } - case "invalid": - { - throw this.flowEnumErrorInvalidMemberInitializer(init.loc, context); - } - case "none": - { - switch (explicitType) { - case "boolean": - this.flowEnumErrorBooleanMemberNotInitialized(init.loc, context); - break; - case "number": - this.flowEnumErrorNumberMemberNotInitialized(init.loc, context); - break; - default: - members.defaultedMembers.push(this.finishNode(memberNode, "EnumDefaultedMember")); - } - } - } - if (!this.match(8)) { - this.expect(12); - } - } - return { - members, - hasUnknownMembers - }; - } - flowEnumStringMembers(initializedMembers, defaultedMembers, { - enumName - }) { - if (initializedMembers.length === 0) { - return defaultedMembers; - } else if (defaultedMembers.length === 0) { - return initializedMembers; - } else if (defaultedMembers.length > initializedMembers.length) { - for (const member of initializedMembers) { - this.flowEnumErrorStringMemberInconsistentlyInitialized(member, { - enumName - }); - } - return defaultedMembers; - } else { - for (const member of defaultedMembers) { - this.flowEnumErrorStringMemberInconsistentlyInitialized(member, { - enumName - }); - } - return initializedMembers; - } - } - flowEnumParseExplicitType({ - enumName - }) { - if (!this.eatContextual(102)) return null; - if (!tokenIsIdentifier(this.state.type)) { - throw this.raise(FlowErrors.EnumInvalidExplicitTypeUnknownSupplied, this.state.startLoc, { - enumName - }); - } - const { - value - } = this.state; - this.next(); - if (value !== "boolean" && value !== "number" && value !== "string" && value !== "symbol") { - this.raise(FlowErrors.EnumInvalidExplicitType, this.state.startLoc, { - enumName, - invalidEnumType: value - }); - } - return value; - } - flowEnumBody(node, id) { - const enumName = id.name; - const nameLoc = id.loc.start; - const explicitType = this.flowEnumParseExplicitType({ - enumName - }); - this.expect(5); - const { - members, - hasUnknownMembers - } = this.flowEnumMembers({ - enumName, - explicitType - }); - node.hasUnknownMembers = hasUnknownMembers; - switch (explicitType) { - case "boolean": - node.explicitType = true; - node.members = members.booleanMembers; - this.expect(8); - return this.finishNode(node, "EnumBooleanBody"); - case "number": - node.explicitType = true; - node.members = members.numberMembers; - this.expect(8); - return this.finishNode(node, "EnumNumberBody"); - case "string": - node.explicitType = true; - node.members = this.flowEnumStringMembers(members.stringMembers, members.defaultedMembers, { - enumName - }); - this.expect(8); - return this.finishNode(node, "EnumStringBody"); - case "symbol": - node.members = members.defaultedMembers; - this.expect(8); - return this.finishNode(node, "EnumSymbolBody"); - default: - { - const empty = () => { - node.members = []; - this.expect(8); - return this.finishNode(node, "EnumStringBody"); - }; - node.explicitType = false; - const boolsLen = members.booleanMembers.length; - const numsLen = members.numberMembers.length; - const strsLen = members.stringMembers.length; - const defaultedLen = members.defaultedMembers.length; - if (!boolsLen && !numsLen && !strsLen && !defaultedLen) { - return empty(); - } else if (!boolsLen && !numsLen) { - node.members = this.flowEnumStringMembers(members.stringMembers, members.defaultedMembers, { - enumName - }); - this.expect(8); - return this.finishNode(node, "EnumStringBody"); - } else if (!numsLen && !strsLen && boolsLen >= defaultedLen) { - for (const member of members.defaultedMembers) { - this.flowEnumErrorBooleanMemberNotInitialized(member.loc.start, { - enumName, - memberName: member.id.name - }); - } - node.members = members.booleanMembers; - this.expect(8); - return this.finishNode(node, "EnumBooleanBody"); - } else if (!boolsLen && !strsLen && numsLen >= defaultedLen) { - for (const member of members.defaultedMembers) { - this.flowEnumErrorNumberMemberNotInitialized(member.loc.start, { - enumName, - memberName: member.id.name - }); - } - node.members = members.numberMembers; - this.expect(8); - return this.finishNode(node, "EnumNumberBody"); - } else { - this.raise(FlowErrors.EnumInconsistentMemberValues, nameLoc, { - enumName - }); - return empty(); - } - } - } - } - flowParseEnumDeclaration(node) { - const id = this.parseIdentifier(); - node.id = id; - node.body = this.flowEnumBody(this.startNode(), id); - return this.finishNode(node, "EnumDeclaration"); - } - isLookaheadToken_lt() { - const next = this.nextTokenStart(); - if (this.input.charCodeAt(next) === 60) { - const afterNext = this.input.charCodeAt(next + 1); - return afterNext !== 60 && afterNext !== 61; - } - return false; - } - maybeUnwrapTypeCastExpression(node) { - return node.type === "TypeCastExpression" ? node.expression : node; - } -}; -const entities = { - __proto__: null, - quot: "\u0022", - amp: "&", - apos: "\u0027", - lt: "<", - gt: ">", - nbsp: "\u00A0", - iexcl: "\u00A1", - cent: "\u00A2", - pound: "\u00A3", - curren: "\u00A4", - yen: "\u00A5", - brvbar: "\u00A6", - sect: "\u00A7", - uml: "\u00A8", - copy: "\u00A9", - ordf: "\u00AA", - laquo: "\u00AB", - not: "\u00AC", - shy: "\u00AD", - reg: "\u00AE", - macr: "\u00AF", - deg: "\u00B0", - plusmn: "\u00B1", - sup2: "\u00B2", - sup3: "\u00B3", - acute: "\u00B4", - micro: "\u00B5", - para: "\u00B6", - middot: "\u00B7", - cedil: "\u00B8", - sup1: "\u00B9", - ordm: "\u00BA", - raquo: "\u00BB", - frac14: "\u00BC", - frac12: "\u00BD", - frac34: "\u00BE", - iquest: "\u00BF", - Agrave: "\u00C0", - Aacute: "\u00C1", - Acirc: "\u00C2", - Atilde: "\u00C3", - Auml: "\u00C4", - Aring: "\u00C5", - AElig: "\u00C6", - Ccedil: "\u00C7", - Egrave: "\u00C8", - Eacute: "\u00C9", - Ecirc: "\u00CA", - Euml: "\u00CB", - Igrave: "\u00CC", - Iacute: "\u00CD", - Icirc: "\u00CE", - Iuml: "\u00CF", - ETH: "\u00D0", - Ntilde: "\u00D1", - Ograve: "\u00D2", - Oacute: "\u00D3", - Ocirc: "\u00D4", - Otilde: "\u00D5", - Ouml: "\u00D6", - times: "\u00D7", - Oslash: "\u00D8", - Ugrave: "\u00D9", - Uacute: "\u00DA", - Ucirc: "\u00DB", - Uuml: "\u00DC", - Yacute: "\u00DD", - THORN: "\u00DE", - szlig: "\u00DF", - agrave: "\u00E0", - aacute: "\u00E1", - acirc: "\u00E2", - atilde: "\u00E3", - auml: "\u00E4", - aring: "\u00E5", - aelig: "\u00E6", - ccedil: "\u00E7", - egrave: "\u00E8", - eacute: "\u00E9", - ecirc: "\u00EA", - euml: "\u00EB", - igrave: "\u00EC", - iacute: "\u00ED", - icirc: "\u00EE", - iuml: "\u00EF", - eth: "\u00F0", - ntilde: "\u00F1", - ograve: "\u00F2", - oacute: "\u00F3", - ocirc: "\u00F4", - otilde: "\u00F5", - ouml: "\u00F6", - divide: "\u00F7", - oslash: "\u00F8", - ugrave: "\u00F9", - uacute: "\u00FA", - ucirc: "\u00FB", - uuml: "\u00FC", - yacute: "\u00FD", - thorn: "\u00FE", - yuml: "\u00FF", - OElig: "\u0152", - oelig: "\u0153", - Scaron: "\u0160", - scaron: "\u0161", - Yuml: "\u0178", - fnof: "\u0192", - circ: "\u02C6", - tilde: "\u02DC", - Alpha: "\u0391", - Beta: "\u0392", - Gamma: "\u0393", - Delta: "\u0394", - Epsilon: "\u0395", - Zeta: "\u0396", - Eta: "\u0397", - Theta: "\u0398", - Iota: "\u0399", - Kappa: "\u039A", - Lambda: "\u039B", - Mu: "\u039C", - Nu: "\u039D", - Xi: "\u039E", - Omicron: "\u039F", - Pi: "\u03A0", - Rho: "\u03A1", - Sigma: "\u03A3", - Tau: "\u03A4", - Upsilon: "\u03A5", - Phi: "\u03A6", - Chi: "\u03A7", - Psi: "\u03A8", - Omega: "\u03A9", - alpha: "\u03B1", - beta: "\u03B2", - gamma: "\u03B3", - delta: "\u03B4", - epsilon: "\u03B5", - zeta: "\u03B6", - eta: "\u03B7", - theta: "\u03B8", - iota: "\u03B9", - kappa: "\u03BA", - lambda: "\u03BB", - mu: "\u03BC", - nu: "\u03BD", - xi: "\u03BE", - omicron: "\u03BF", - pi: "\u03C0", - rho: "\u03C1", - sigmaf: "\u03C2", - sigma: "\u03C3", - tau: "\u03C4", - upsilon: "\u03C5", - phi: "\u03C6", - chi: "\u03C7", - psi: "\u03C8", - omega: "\u03C9", - thetasym: "\u03D1", - upsih: "\u03D2", - piv: "\u03D6", - ensp: "\u2002", - emsp: "\u2003", - thinsp: "\u2009", - zwnj: "\u200C", - zwj: "\u200D", - lrm: "\u200E", - rlm: "\u200F", - ndash: "\u2013", - mdash: "\u2014", - lsquo: "\u2018", - rsquo: "\u2019", - sbquo: "\u201A", - ldquo: "\u201C", - rdquo: "\u201D", - bdquo: "\u201E", - dagger: "\u2020", - Dagger: "\u2021", - bull: "\u2022", - hellip: "\u2026", - permil: "\u2030", - prime: "\u2032", - Prime: "\u2033", - lsaquo: "\u2039", - rsaquo: "\u203A", - oline: "\u203E", - frasl: "\u2044", - euro: "\u20AC", - image: "\u2111", - weierp: "\u2118", - real: "\u211C", - trade: "\u2122", - alefsym: "\u2135", - larr: "\u2190", - uarr: "\u2191", - rarr: "\u2192", - darr: "\u2193", - harr: "\u2194", - crarr: "\u21B5", - lArr: "\u21D0", - uArr: "\u21D1", - rArr: "\u21D2", - dArr: "\u21D3", - hArr: "\u21D4", - forall: "\u2200", - part: "\u2202", - exist: "\u2203", - empty: "\u2205", - nabla: "\u2207", - isin: "\u2208", - notin: "\u2209", - ni: "\u220B", - prod: "\u220F", - sum: "\u2211", - minus: "\u2212", - lowast: "\u2217", - radic: "\u221A", - prop: "\u221D", - infin: "\u221E", - ang: "\u2220", - and: "\u2227", - or: "\u2228", - cap: "\u2229", - cup: "\u222A", - int: "\u222B", - there4: "\u2234", - sim: "\u223C", - cong: "\u2245", - asymp: "\u2248", - ne: "\u2260", - equiv: "\u2261", - le: "\u2264", - ge: "\u2265", - sub: "\u2282", - sup: "\u2283", - nsub: "\u2284", - sube: "\u2286", - supe: "\u2287", - oplus: "\u2295", - otimes: "\u2297", - perp: "\u22A5", - sdot: "\u22C5", - lceil: "\u2308", - rceil: "\u2309", - lfloor: "\u230A", - rfloor: "\u230B", - lang: "\u2329", - rang: "\u232A", - loz: "\u25CA", - spades: "\u2660", - clubs: "\u2663", - hearts: "\u2665", - diams: "\u2666" -}; -const JsxErrors = ParseErrorEnum`jsx`({ - AttributeIsEmpty: "JSX attributes must only be assigned a non-empty expression.", - MissingClosingTagElement: ({ - openingTagName - }) => `Expected corresponding JSX closing tag for <${openingTagName}>.`, - MissingClosingTagFragment: "Expected corresponding JSX closing tag for <>.", - UnexpectedSequenceExpression: "Sequence expressions cannot be directly nested inside JSX. Did you mean to wrap it in parentheses (...)?", - UnexpectedToken: ({ - unexpected, - HTMLEntity - }) => `Unexpected token \`${unexpected}\`. Did you mean \`${HTMLEntity}\` or \`{'${unexpected}'}\`?`, - UnsupportedJsxValue: "JSX value should be either an expression or a quoted JSX text.", - UnterminatedJsxContent: "Unterminated JSX contents.", - UnwrappedAdjacentJSXElements: "Adjacent JSX elements must be wrapped in an enclosing tag. Did you want a JSX fragment <>...?" -}); -function isFragment(object) { - return object ? object.type === "JSXOpeningFragment" || object.type === "JSXClosingFragment" : false; -} -function getQualifiedJSXName(object) { - if (object.type === "JSXIdentifier") { - return object.name; - } - if (object.type === "JSXNamespacedName") { - return object.namespace.name + ":" + object.name.name; - } - if (object.type === "JSXMemberExpression") { - return getQualifiedJSXName(object.object) + "." + getQualifiedJSXName(object.property); - } - throw new Error("Node had unexpected type: " + object.type); -} -var jsx = superClass => class JSXParserMixin extends superClass { - jsxReadToken() { - let out = ""; - let chunkStart = this.state.pos; - for (;;) { - if (this.state.pos >= this.length) { - throw this.raise(JsxErrors.UnterminatedJsxContent, this.state.startLoc); - } - const ch = this.input.charCodeAt(this.state.pos); - switch (ch) { - case 60: - case 123: - if (this.state.pos === this.state.start) { - if (ch === 60 && this.state.canStartJSXElement) { - ++this.state.pos; - this.finishToken(142); - } else { - super.getTokenFromCode(ch); - } - return; - } - out += this.input.slice(chunkStart, this.state.pos); - this.finishToken(141, out); - return; - case 38: - out += this.input.slice(chunkStart, this.state.pos); - out += this.jsxReadEntity(); - chunkStart = this.state.pos; - break; - case 62: - case 125: - default: - if (isNewLine(ch)) { - out += this.input.slice(chunkStart, this.state.pos); - out += this.jsxReadNewLine(true); - chunkStart = this.state.pos; - } else { - ++this.state.pos; - } - } - } - } - jsxReadNewLine(normalizeCRLF) { - const ch = this.input.charCodeAt(this.state.pos); - let out; - ++this.state.pos; - if (ch === 13 && this.input.charCodeAt(this.state.pos) === 10) { - ++this.state.pos; - out = normalizeCRLF ? "\n" : "\r\n"; - } else { - out = String.fromCharCode(ch); - } - ++this.state.curLine; - this.state.lineStart = this.state.pos; - return out; - } - jsxReadString(quote) { - let out = ""; - let chunkStart = ++this.state.pos; - for (;;) { - if (this.state.pos >= this.length) { - throw this.raise(Errors.UnterminatedString, this.state.startLoc); - } - const ch = this.input.charCodeAt(this.state.pos); - if (ch === quote) break; - if (ch === 38) { - out += this.input.slice(chunkStart, this.state.pos); - out += this.jsxReadEntity(); - chunkStart = this.state.pos; - } else if (isNewLine(ch)) { - out += this.input.slice(chunkStart, this.state.pos); - out += this.jsxReadNewLine(false); - chunkStart = this.state.pos; - } else { - ++this.state.pos; - } - } - out += this.input.slice(chunkStart, this.state.pos++); - this.finishToken(133, out); - } - jsxReadEntity() { - const startPos = ++this.state.pos; - if (this.codePointAtPos(this.state.pos) === 35) { - ++this.state.pos; - let radix = 10; - if (this.codePointAtPos(this.state.pos) === 120) { - radix = 16; - ++this.state.pos; - } - const codePoint = this.readInt(radix, undefined, false, "bail"); - if (codePoint !== null && this.codePointAtPos(this.state.pos) === 59) { - ++this.state.pos; - return String.fromCodePoint(codePoint); - } - } else { - let count = 0; - let semi = false; - while (count++ < 10 && this.state.pos < this.length && !(semi = this.codePointAtPos(this.state.pos) === 59)) { - ++this.state.pos; - } - if (semi) { - const desc = this.input.slice(startPos, this.state.pos); - const entity = entities[desc]; - ++this.state.pos; - if (entity) { - return entity; - } - } - } - this.state.pos = startPos; - return "&"; - } - jsxReadWord() { - let ch; - const start = this.state.pos; - do { - ch = this.input.charCodeAt(++this.state.pos); - } while (isIdentifierChar(ch) || ch === 45); - this.finishToken(140, this.input.slice(start, this.state.pos)); - } - jsxParseIdentifier() { - const node = this.startNode(); - if (this.match(140)) { - node.name = this.state.value; - } else if (tokenIsKeyword(this.state.type)) { - node.name = tokenLabelName(this.state.type); - } else { - this.unexpected(); - } - this.next(); - return this.finishNode(node, "JSXIdentifier"); - } - jsxParseNamespacedName() { - const startLoc = this.state.startLoc; - const name = this.jsxParseIdentifier(); - if (!this.eat(14)) return name; - const node = this.startNodeAt(startLoc); - node.namespace = name; - node.name = this.jsxParseIdentifier(); - return this.finishNode(node, "JSXNamespacedName"); - } - jsxParseElementName() { - const startLoc = this.state.startLoc; - let node = this.jsxParseNamespacedName(); - if (node.type === "JSXNamespacedName") { - return node; - } - while (this.eat(16)) { - const newNode = this.startNodeAt(startLoc); - newNode.object = node; - newNode.property = this.jsxParseIdentifier(); - node = this.finishNode(newNode, "JSXMemberExpression"); - } - return node; - } - jsxParseAttributeValue() { - let node; - switch (this.state.type) { - case 5: - node = this.startNode(); - this.setContext(types.brace); - this.next(); - node = this.jsxParseExpressionContainer(node, types.j_oTag); - if (node.expression.type === "JSXEmptyExpression") { - this.raise(JsxErrors.AttributeIsEmpty, node); - } - return node; - case 142: - case 133: - return this.parseExprAtom(); - default: - throw this.raise(JsxErrors.UnsupportedJsxValue, this.state.startLoc); - } - } - jsxParseEmptyExpression() { - const node = this.startNodeAt(this.state.lastTokEndLoc); - return this.finishNodeAt(node, "JSXEmptyExpression", this.state.startLoc); - } - jsxParseSpreadChild(node) { - this.next(); - node.expression = this.parseExpression(); - this.setContext(types.j_expr); - this.state.canStartJSXElement = true; - this.expect(8); - return this.finishNode(node, "JSXSpreadChild"); - } - jsxParseExpressionContainer(node, previousContext) { - if (this.match(8)) { - node.expression = this.jsxParseEmptyExpression(); - } else { - const expression = this.parseExpression(); - node.expression = expression; - } - this.setContext(previousContext); - this.state.canStartJSXElement = true; - this.expect(8); - return this.finishNode(node, "JSXExpressionContainer"); - } - jsxParseAttribute() { - const node = this.startNode(); - if (this.match(5)) { - this.setContext(types.brace); - this.next(); - this.expect(21); - node.argument = this.parseMaybeAssignAllowIn(); - this.setContext(types.j_oTag); - this.state.canStartJSXElement = true; - this.expect(8); - return this.finishNode(node, "JSXSpreadAttribute"); - } - node.name = this.jsxParseNamespacedName(); - node.value = this.eat(29) ? this.jsxParseAttributeValue() : null; - return this.finishNode(node, "JSXAttribute"); - } - jsxParseOpeningElementAt(startLoc) { - const node = this.startNodeAt(startLoc); - if (this.eat(143)) { - return this.finishNode(node, "JSXOpeningFragment"); - } - node.name = this.jsxParseElementName(); - return this.jsxParseOpeningElementAfterName(node); - } - jsxParseOpeningElementAfterName(node) { - const attributes = []; - while (!this.match(56) && !this.match(143)) { - attributes.push(this.jsxParseAttribute()); - } - node.attributes = attributes; - node.selfClosing = this.eat(56); - this.expect(143); - return this.finishNode(node, "JSXOpeningElement"); - } - jsxParseClosingElementAt(startLoc) { - const node = this.startNodeAt(startLoc); - if (this.eat(143)) { - return this.finishNode(node, "JSXClosingFragment"); - } - node.name = this.jsxParseElementName(); - this.expect(143); - return this.finishNode(node, "JSXClosingElement"); - } - jsxParseElementAt(startLoc) { - const node = this.startNodeAt(startLoc); - const children = []; - const openingElement = this.jsxParseOpeningElementAt(startLoc); - let closingElement = null; - if (!openingElement.selfClosing) { - contents: for (;;) { - switch (this.state.type) { - case 142: - startLoc = this.state.startLoc; - this.next(); - if (this.eat(56)) { - closingElement = this.jsxParseClosingElementAt(startLoc); - break contents; - } - children.push(this.jsxParseElementAt(startLoc)); - break; - case 141: - children.push(this.parseLiteral(this.state.value, "JSXText")); - break; - case 5: - { - const node = this.startNode(); - this.setContext(types.brace); - this.next(); - if (this.match(21)) { - children.push(this.jsxParseSpreadChild(node)); - } else { - children.push(this.jsxParseExpressionContainer(node, types.j_expr)); - } - break; - } - default: - this.unexpected(); - } - } - if (isFragment(openingElement) && !isFragment(closingElement) && closingElement !== null) { - this.raise(JsxErrors.MissingClosingTagFragment, closingElement); - } else if (!isFragment(openingElement) && isFragment(closingElement)) { - this.raise(JsxErrors.MissingClosingTagElement, closingElement, { - openingTagName: getQualifiedJSXName(openingElement.name) - }); - } else if (!isFragment(openingElement) && !isFragment(closingElement)) { - if (getQualifiedJSXName(closingElement.name) !== getQualifiedJSXName(openingElement.name)) { - this.raise(JsxErrors.MissingClosingTagElement, closingElement, { - openingTagName: getQualifiedJSXName(openingElement.name) - }); - } - } - } - if (isFragment(openingElement)) { - node.openingFragment = openingElement; - node.closingFragment = closingElement; - } else { - node.openingElement = openingElement; - node.closingElement = closingElement; - } - node.children = children; - if (this.match(47)) { - throw this.raise(JsxErrors.UnwrappedAdjacentJSXElements, this.state.startLoc); - } - return isFragment(openingElement) ? this.finishNode(node, "JSXFragment") : this.finishNode(node, "JSXElement"); - } - jsxParseElement() { - const startLoc = this.state.startLoc; - this.next(); - return this.jsxParseElementAt(startLoc); - } - setContext(newContext) { - const { - context - } = this.state; - context[context.length - 1] = newContext; - } - parseExprAtom(refExpressionErrors) { - if (this.match(142)) { - return this.jsxParseElement(); - } else if (this.match(47) && this.input.charCodeAt(this.state.pos) !== 33) { - this.replaceToken(142); - return this.jsxParseElement(); - } else { - return super.parseExprAtom(refExpressionErrors); - } - } - skipSpace() { - const curContext = this.curContext(); - if (!curContext.preserveSpace) super.skipSpace(); - } - getTokenFromCode(code) { - const context = this.curContext(); - if (context === types.j_expr) { - this.jsxReadToken(); - return; - } - if (context === types.j_oTag || context === types.j_cTag) { - if (isIdentifierStart(code)) { - this.jsxReadWord(); - return; - } - if (code === 62) { - ++this.state.pos; - this.finishToken(143); - return; - } - if ((code === 34 || code === 39) && context === types.j_oTag) { - this.jsxReadString(code); - return; - } - } - if (code === 60 && this.state.canStartJSXElement && this.input.charCodeAt(this.state.pos + 1) !== 33) { - ++this.state.pos; - this.finishToken(142); - return; - } - super.getTokenFromCode(code); - } - updateContext(prevType) { - const { - context, - type - } = this.state; - if (type === 56 && prevType === 142) { - context.splice(-2, 2, types.j_cTag); - this.state.canStartJSXElement = false; - } else if (type === 142) { - context.push(types.j_oTag); - } else if (type === 143) { - const out = context[context.length - 1]; - if (out === types.j_oTag && prevType === 56 || out === types.j_cTag) { - context.pop(); - this.state.canStartJSXElement = context[context.length - 1] === types.j_expr; - } else { - this.setContext(types.j_expr); - this.state.canStartJSXElement = true; - } - } else { - this.state.canStartJSXElement = tokenComesBeforeExpression(type); - } - } -}; -class TypeScriptScope extends Scope { - constructor(...args) { - super(...args); - this.tsNames = new Map(); - } -} -class TypeScriptScopeHandler extends ScopeHandler { - constructor(...args) { - super(...args); - this.importsStack = []; - } - createScope(flags) { - this.importsStack.push(new Set()); - return new TypeScriptScope(flags); - } - enter(flags) { - if (flags === 256) { - this.importsStack.push(new Set()); - } - super.enter(flags); - } - exit() { - const flags = super.exit(); - if (flags === 256) { - this.importsStack.pop(); - } - return flags; - } - hasImport(name, allowShadow) { - const len = this.importsStack.length; - if (this.importsStack[len - 1].has(name)) { - return true; - } - if (!allowShadow && len > 1) { - for (let i = 0; i < len - 1; i++) { - if (this.importsStack[i].has(name)) return true; - } - } - return false; - } - declareName(name, bindingType, loc) { - if (bindingType & 4096) { - if (this.hasImport(name, true)) { - this.parser.raise(Errors.VarRedeclaration, loc, { - identifierName: name - }); - } - this.importsStack[this.importsStack.length - 1].add(name); - return; - } - const scope = this.currentScope(); - let type = scope.tsNames.get(name) || 0; - if (bindingType & 1024) { - this.maybeExportDefined(scope, name); - scope.tsNames.set(name, type | 16); - return; - } - super.declareName(name, bindingType, loc); - if (bindingType & 2) { - if (!(bindingType & 1)) { - this.checkRedeclarationInScope(scope, name, bindingType, loc); - this.maybeExportDefined(scope, name); - } - type = type | 1; - } - if (bindingType & 256) { - type = type | 2; - } - if (bindingType & 512) { - type = type | 4; - } - if (bindingType & 128) { - type = type | 8; - } - if (type) scope.tsNames.set(name, type); - } - isRedeclaredInScope(scope, name, bindingType) { - const type = scope.tsNames.get(name); - if ((type & 2) > 0) { - if (bindingType & 256) { - const isConst = !!(bindingType & 512); - const wasConst = (type & 4) > 0; - return isConst !== wasConst; - } - return true; - } - if (bindingType & 128 && (type & 8) > 0) { - if (scope.names.get(name) & 2) { - return !!(bindingType & 1); - } else { - return false; - } - } - if (bindingType & 2 && (type & 1) > 0) { - return true; - } - return super.isRedeclaredInScope(scope, name, bindingType); - } - checkLocalExport(id) { - const { - name - } = id; - if (this.hasImport(name)) return; - const len = this.scopeStack.length; - for (let i = len - 1; i >= 0; i--) { - const scope = this.scopeStack[i]; - const type = scope.tsNames.get(name); - if ((type & 1) > 0 || (type & 16) > 0) { - return; - } - } - super.checkLocalExport(id); - } -} -const getOwn$1 = (object, key) => hasOwnProperty.call(object, key) && object[key]; -const unwrapParenthesizedExpression = node => { - return node.type === "ParenthesizedExpression" ? unwrapParenthesizedExpression(node.expression) : node; -}; -class LValParser extends NodeUtils { - toAssignable(node, isLHS = false) { - var _node$extra, _node$extra3; - let parenthesized = undefined; - if (node.type === "ParenthesizedExpression" || (_node$extra = node.extra) != null && _node$extra.parenthesized) { - parenthesized = unwrapParenthesizedExpression(node); - if (isLHS) { - if (parenthesized.type === "Identifier") { - this.expressionScope.recordArrowParameterBindingError(Errors.InvalidParenthesizedAssignment, node); - } else if (parenthesized.type !== "MemberExpression" && !this.isOptionalMemberExpression(parenthesized)) { - this.raise(Errors.InvalidParenthesizedAssignment, node); - } - } else { - this.raise(Errors.InvalidParenthesizedAssignment, node); - } - } - switch (node.type) { - case "Identifier": - case "ObjectPattern": - case "ArrayPattern": - case "AssignmentPattern": - case "RestElement": - break; - case "ObjectExpression": - node.type = "ObjectPattern"; - for (let i = 0, length = node.properties.length, last = length - 1; i < length; i++) { - var _node$extra2; - const prop = node.properties[i]; - const isLast = i === last; - this.toAssignableObjectExpressionProp(prop, isLast, isLHS); - if (isLast && prop.type === "RestElement" && (_node$extra2 = node.extra) != null && _node$extra2.trailingCommaLoc) { - this.raise(Errors.RestTrailingComma, node.extra.trailingCommaLoc); - } - } - break; - case "ObjectProperty": - { - const { - key, - value - } = node; - if (this.isPrivateName(key)) { - this.classScope.usePrivateName(this.getPrivateNameSV(key), key.loc.start); - } - this.toAssignable(value, isLHS); - break; - } - case "SpreadElement": - { - throw new Error("Internal @babel/parser error (this is a bug, please report it)." + " SpreadElement should be converted by .toAssignable's caller."); - } - case "ArrayExpression": - node.type = "ArrayPattern"; - this.toAssignableList(node.elements, (_node$extra3 = node.extra) == null ? void 0 : _node$extra3.trailingCommaLoc, isLHS); - break; - case "AssignmentExpression": - if (node.operator !== "=") { - this.raise(Errors.MissingEqInAssignment, node.left.loc.end); - } - node.type = "AssignmentPattern"; - delete node.operator; - this.toAssignable(node.left, isLHS); - break; - case "ParenthesizedExpression": - this.toAssignable(parenthesized, isLHS); - break; - } - } - toAssignableObjectExpressionProp(prop, isLast, isLHS) { - if (prop.type === "ObjectMethod") { - this.raise(prop.kind === "get" || prop.kind === "set" ? Errors.PatternHasAccessor : Errors.PatternHasMethod, prop.key); - } else if (prop.type === "SpreadElement") { - prop.type = "RestElement"; - const arg = prop.argument; - this.checkToRestConversion(arg, false); - this.toAssignable(arg, isLHS); - if (!isLast) { - this.raise(Errors.RestTrailingComma, prop); - } - } else { - this.toAssignable(prop, isLHS); - } - } - toAssignableList(exprList, trailingCommaLoc, isLHS) { - const end = exprList.length - 1; - for (let i = 0; i <= end; i++) { - const elt = exprList[i]; - if (!elt) continue; - if (elt.type === "SpreadElement") { - elt.type = "RestElement"; - const arg = elt.argument; - this.checkToRestConversion(arg, true); - this.toAssignable(arg, isLHS); - } else { - this.toAssignable(elt, isLHS); - } - if (elt.type === "RestElement") { - if (i < end) { - this.raise(Errors.RestTrailingComma, elt); - } else if (trailingCommaLoc) { - this.raise(Errors.RestTrailingComma, trailingCommaLoc); - } - } - } - } - isAssignable(node, isBinding) { - switch (node.type) { - case "Identifier": - case "ObjectPattern": - case "ArrayPattern": - case "AssignmentPattern": - case "RestElement": - return true; - case "ObjectExpression": - { - const last = node.properties.length - 1; - return node.properties.every((prop, i) => { - return prop.type !== "ObjectMethod" && (i === last || prop.type !== "SpreadElement") && this.isAssignable(prop); - }); - } - case "ObjectProperty": - return this.isAssignable(node.value); - case "SpreadElement": - return this.isAssignable(node.argument); - case "ArrayExpression": - return node.elements.every(element => element === null || this.isAssignable(element)); - case "AssignmentExpression": - return node.operator === "="; - case "ParenthesizedExpression": - return this.isAssignable(node.expression); - case "MemberExpression": - case "OptionalMemberExpression": - return !isBinding; - default: - return false; - } - } - toReferencedList(exprList, isParenthesizedExpr) { - return exprList; - } - toReferencedListDeep(exprList, isParenthesizedExpr) { - this.toReferencedList(exprList, isParenthesizedExpr); - for (const expr of exprList) { - if ((expr == null ? void 0 : expr.type) === "ArrayExpression") { - this.toReferencedListDeep(expr.elements); - } - } - } - parseSpread(refExpressionErrors) { - const node = this.startNode(); - this.next(); - node.argument = this.parseMaybeAssignAllowIn(refExpressionErrors, undefined); - return this.finishNode(node, "SpreadElement"); - } - parseRestBinding() { - const node = this.startNode(); - this.next(); - node.argument = this.parseBindingAtom(); - return this.finishNode(node, "RestElement"); - } - parseBindingAtom() { - switch (this.state.type) { - case 0: - { - const node = this.startNode(); - this.next(); - node.elements = this.parseBindingList(3, 93, 1); - return this.finishNode(node, "ArrayPattern"); - } - case 5: - return this.parseObjectLike(8, true); - } - return this.parseIdentifier(); - } - parseBindingList(close, closeCharCode, flags) { - const allowEmpty = flags & 1; - const elts = []; - let first = true; - while (!this.eat(close)) { - if (first) { - first = false; - } else { - this.expect(12); - } - if (allowEmpty && this.match(12)) { - elts.push(null); - } else if (this.eat(close)) { - break; - } else if (this.match(21)) { - elts.push(this.parseAssignableListItemTypes(this.parseRestBinding(), flags)); - if (!this.checkCommaAfterRest(closeCharCode)) { - this.expect(close); - break; - } - } else { - const decorators = []; - if (this.match(26) && this.hasPlugin("decorators")) { - this.raise(Errors.UnsupportedParameterDecorator, this.state.startLoc); - } - while (this.match(26)) { - decorators.push(this.parseDecorator()); - } - elts.push(this.parseAssignableListItem(flags, decorators)); - } - } - return elts; - } - parseBindingRestProperty(prop) { - this.next(); - prop.argument = this.parseIdentifier(); - this.checkCommaAfterRest(125); - return this.finishNode(prop, "RestElement"); - } - parseBindingProperty() { - const { - type, - startLoc - } = this.state; - if (type === 21) { - return this.parseBindingRestProperty(this.startNode()); - } - const prop = this.startNode(); - if (type === 138) { - this.expectPlugin("destructuringPrivate", startLoc); - this.classScope.usePrivateName(this.state.value, startLoc); - prop.key = this.parsePrivateName(); - } else { - this.parsePropertyName(prop); - } - prop.method = false; - return this.parseObjPropValue(prop, startLoc, false, false, true, false); - } - parseAssignableListItem(flags, decorators) { - const left = this.parseMaybeDefault(); - this.parseAssignableListItemTypes(left, flags); - const elt = this.parseMaybeDefault(left.loc.start, left); - if (decorators.length) { - left.decorators = decorators; - } - return elt; - } - parseAssignableListItemTypes(param, flags) { - return param; - } - parseMaybeDefault(startLoc, left) { - var _startLoc, _left; - (_startLoc = startLoc) != null ? _startLoc : startLoc = this.state.startLoc; - left = (_left = left) != null ? _left : this.parseBindingAtom(); - if (!this.eat(29)) return left; - const node = this.startNodeAt(startLoc); - node.left = left; - node.right = this.parseMaybeAssignAllowIn(); - return this.finishNode(node, "AssignmentPattern"); - } - isValidLVal(type, isUnparenthesizedInAssign, binding) { - return getOwn$1({ - AssignmentPattern: "left", - RestElement: "argument", - ObjectProperty: "value", - ParenthesizedExpression: "expression", - ArrayPattern: "elements", - ObjectPattern: "properties" - }, type); - } - isOptionalMemberExpression(expression) { - return expression.type === "OptionalMemberExpression"; - } - checkLVal(expression, { - in: ancestor, - binding = 64, - checkClashes = false, - strictModeChanged = false, - hasParenthesizedAncestor = false - }) { - var _expression$extra; - const type = expression.type; - if (this.isObjectMethod(expression)) return; - const isOptionalMemberExpression = this.isOptionalMemberExpression(expression); - if (isOptionalMemberExpression || type === "MemberExpression") { - if (isOptionalMemberExpression) { - this.expectPlugin("optionalChainingAssign", expression.loc.start); - if (ancestor.type !== "AssignmentExpression") { - this.raise(Errors.InvalidLhsOptionalChaining, expression, { - ancestor - }); - } - } - if (binding !== 64) { - this.raise(Errors.InvalidPropertyBindingPattern, expression); - } - return; - } - if (type === "Identifier") { - this.checkIdentifier(expression, binding, strictModeChanged); - const { - name - } = expression; - if (checkClashes) { - if (checkClashes.has(name)) { - this.raise(Errors.ParamDupe, expression); - } else { - checkClashes.add(name); - } - } - return; - } - const validity = this.isValidLVal(type, !(hasParenthesizedAncestor || (_expression$extra = expression.extra) != null && _expression$extra.parenthesized) && ancestor.type === "AssignmentExpression", binding); - if (validity === true) return; - if (validity === false) { - const ParseErrorClass = binding === 64 ? Errors.InvalidLhs : Errors.InvalidLhsBinding; - this.raise(ParseErrorClass, expression, { - ancestor - }); - return; - } - const [key, isParenthesizedExpression] = Array.isArray(validity) ? validity : [validity, type === "ParenthesizedExpression"]; - const nextAncestor = type === "ArrayPattern" || type === "ObjectPattern" ? { - type - } : ancestor; - for (const child of [].concat(expression[key])) { - if (child) { - this.checkLVal(child, { - in: nextAncestor, - binding, - checkClashes, - strictModeChanged, - hasParenthesizedAncestor: isParenthesizedExpression - }); - } - } - } - checkIdentifier(at, bindingType, strictModeChanged = false) { - if (this.state.strict && (strictModeChanged ? isStrictBindReservedWord(at.name, this.inModule) : isStrictBindOnlyReservedWord(at.name))) { - if (bindingType === 64) { - this.raise(Errors.StrictEvalArguments, at, { - referenceName: at.name - }); - } else { - this.raise(Errors.StrictEvalArgumentsBinding, at, { - bindingName: at.name - }); - } - } - if (bindingType & 8192 && at.name === "let") { - this.raise(Errors.LetInLexicalBinding, at); - } - if (!(bindingType & 64)) { - this.declareNameFromIdentifier(at, bindingType); - } - } - declareNameFromIdentifier(identifier, binding) { - this.scope.declareName(identifier.name, binding, identifier.loc.start); - } - checkToRestConversion(node, allowPattern) { - switch (node.type) { - case "ParenthesizedExpression": - this.checkToRestConversion(node.expression, allowPattern); - break; - case "Identifier": - case "MemberExpression": - break; - case "ArrayExpression": - case "ObjectExpression": - if (allowPattern) break; - default: - this.raise(Errors.InvalidRestAssignmentPattern, node); - } - } - checkCommaAfterRest(close) { - if (!this.match(12)) { - return false; - } - this.raise(this.lookaheadCharCode() === close ? Errors.RestTrailingComma : Errors.ElementAfterRest, this.state.startLoc); - return true; - } -} -const getOwn = (object, key) => hasOwnProperty.call(object, key) && object[key]; -function nonNull(x) { - if (x == null) { - throw new Error(`Unexpected ${x} value.`); - } - return x; -} -function assert(x) { - if (!x) { - throw new Error("Assert fail"); - } -} -const TSErrors = ParseErrorEnum`typescript`({ - AbstractMethodHasImplementation: ({ - methodName - }) => `Method '${methodName}' cannot have an implementation because it is marked abstract.`, - AbstractPropertyHasInitializer: ({ - propertyName - }) => `Property '${propertyName}' cannot have an initializer because it is marked abstract.`, - AccesorCannotDeclareThisParameter: "'get' and 'set' accessors cannot declare 'this' parameters.", - AccesorCannotHaveTypeParameters: "An accessor cannot have type parameters.", - AccessorCannotBeOptional: "An 'accessor' property cannot be declared optional.", - ClassMethodHasDeclare: "Class methods cannot have the 'declare' modifier.", - ClassMethodHasReadonly: "Class methods cannot have the 'readonly' modifier.", - ConstInitiailizerMustBeStringOrNumericLiteralOrLiteralEnumReference: "A 'const' initializer in an ambient context must be a string or numeric literal or literal enum reference.", - ConstructorHasTypeParameters: "Type parameters cannot appear on a constructor declaration.", - DeclareAccessor: ({ - kind - }) => `'declare' is not allowed in ${kind}ters.`, - DeclareClassFieldHasInitializer: "Initializers are not allowed in ambient contexts.", - DeclareFunctionHasImplementation: "An implementation cannot be declared in ambient contexts.", - DuplicateAccessibilityModifier: ({ - modifier - }) => `Accessibility modifier already seen.`, - DuplicateModifier: ({ - modifier - }) => `Duplicate modifier: '${modifier}'.`, - EmptyHeritageClauseType: ({ - token - }) => `'${token}' list cannot be empty.`, - EmptyTypeArguments: "Type argument list cannot be empty.", - EmptyTypeParameters: "Type parameter list cannot be empty.", - ExpectedAmbientAfterExportDeclare: "'export declare' must be followed by an ambient declaration.", - ImportAliasHasImportType: "An import alias can not use 'import type'.", - ImportReflectionHasImportType: "An `import module` declaration can not use `type` modifier", - IncompatibleModifiers: ({ - modifiers - }) => `'${modifiers[0]}' modifier cannot be used with '${modifiers[1]}' modifier.`, - IndexSignatureHasAbstract: "Index signatures cannot have the 'abstract' modifier.", - IndexSignatureHasAccessibility: ({ - modifier - }) => `Index signatures cannot have an accessibility modifier ('${modifier}').`, - IndexSignatureHasDeclare: "Index signatures cannot have the 'declare' modifier.", - IndexSignatureHasOverride: "'override' modifier cannot appear on an index signature.", - IndexSignatureHasStatic: "Index signatures cannot have the 'static' modifier.", - InitializerNotAllowedInAmbientContext: "Initializers are not allowed in ambient contexts.", - InvalidModifierOnTypeMember: ({ - modifier - }) => `'${modifier}' modifier cannot appear on a type member.`, - InvalidModifierOnTypeParameter: ({ - modifier - }) => `'${modifier}' modifier cannot appear on a type parameter.`, - InvalidModifierOnTypeParameterPositions: ({ - modifier - }) => `'${modifier}' modifier can only appear on a type parameter of a class, interface or type alias.`, - InvalidModifiersOrder: ({ - orderedModifiers - }) => `'${orderedModifiers[0]}' modifier must precede '${orderedModifiers[1]}' modifier.`, - InvalidPropertyAccessAfterInstantiationExpression: "Invalid property access after an instantiation expression. " + "You can either wrap the instantiation expression in parentheses, or delete the type arguments.", - InvalidTupleMemberLabel: "Tuple members must be labeled with a simple identifier.", - MissingInterfaceName: "'interface' declarations must be followed by an identifier.", - NonAbstractClassHasAbstractMethod: "Abstract methods can only appear within an abstract class.", - NonClassMethodPropertyHasAbstractModifer: "'abstract' modifier can only appear on a class, method, or property declaration.", - OptionalTypeBeforeRequired: "A required element cannot follow an optional element.", - OverrideNotInSubClass: "This member cannot have an 'override' modifier because its containing class does not extend another class.", - PatternIsOptional: "A binding pattern parameter cannot be optional in an implementation signature.", - PrivateElementHasAbstract: "Private elements cannot have the 'abstract' modifier.", - PrivateElementHasAccessibility: ({ - modifier - }) => `Private elements cannot have an accessibility modifier ('${modifier}').`, - ReadonlyForMethodSignature: "'readonly' modifier can only appear on a property declaration or index signature.", - ReservedArrowTypeParam: "This syntax is reserved in files with the .mts or .cts extension. Add a trailing comma, as in `() => ...`.", - ReservedTypeAssertion: "This syntax is reserved in files with the .mts or .cts extension. Use an `as` expression instead.", - SetAccesorCannotHaveOptionalParameter: "A 'set' accessor cannot have an optional parameter.", - SetAccesorCannotHaveRestParameter: "A 'set' accessor cannot have rest parameter.", - SetAccesorCannotHaveReturnType: "A 'set' accessor cannot have a return type annotation.", - SingleTypeParameterWithoutTrailingComma: ({ - typeParameterName - }) => `Single type parameter ${typeParameterName} should have a trailing comma. Example usage: <${typeParameterName},>.`, - StaticBlockCannotHaveModifier: "Static class blocks cannot have any modifier.", - TupleOptionalAfterType: "A labeled tuple optional element must be declared using a question mark after the name and before the colon (`name?: type`), rather than after the type (`name: type?`).", - TypeAnnotationAfterAssign: "Type annotations must come before default assignments, e.g. instead of `age = 25: number` use `age: number = 25`.", - TypeImportCannotSpecifyDefaultAndNamed: "A type-only import can specify a default import or named bindings, but not both.", - TypeModifierIsUsedInTypeExports: "The 'type' modifier cannot be used on a named export when 'export type' is used on its export statement.", - TypeModifierIsUsedInTypeImports: "The 'type' modifier cannot be used on a named import when 'import type' is used on its import statement.", - UnexpectedParameterModifier: "A parameter property is only allowed in a constructor implementation.", - UnexpectedReadonly: "'readonly' type modifier is only permitted on array and tuple literal types.", - UnexpectedTypeAnnotation: "Did not expect a type annotation here.", - UnexpectedTypeCastInParameter: "Unexpected type cast in parameter position.", - UnsupportedImportTypeArgument: "Argument in a type import must be a string literal.", - UnsupportedParameterPropertyKind: "A parameter property may not be declared using a binding pattern.", - UnsupportedSignatureParameterKind: ({ - type - }) => `Name in a signature must be an Identifier, ObjectPattern or ArrayPattern, instead got ${type}.` -}); -function keywordTypeFromName(value) { - switch (value) { - case "any": - return "TSAnyKeyword"; - case "boolean": - return "TSBooleanKeyword"; - case "bigint": - return "TSBigIntKeyword"; - case "never": - return "TSNeverKeyword"; - case "number": - return "TSNumberKeyword"; - case "object": - return "TSObjectKeyword"; - case "string": - return "TSStringKeyword"; - case "symbol": - return "TSSymbolKeyword"; - case "undefined": - return "TSUndefinedKeyword"; - case "unknown": - return "TSUnknownKeyword"; - default: - return undefined; - } -} -function tsIsAccessModifier(modifier) { - return modifier === "private" || modifier === "public" || modifier === "protected"; -} -function tsIsVarianceAnnotations(modifier) { - return modifier === "in" || modifier === "out"; -} -var typescript = superClass => class TypeScriptParserMixin extends superClass { - constructor(...args) { - super(...args); - this.tsParseInOutModifiers = this.tsParseModifiers.bind(this, { - allowedModifiers: ["in", "out"], - disallowedModifiers: ["const", "public", "private", "protected", "readonly", "declare", "abstract", "override"], - errorTemplate: TSErrors.InvalidModifierOnTypeParameter - }); - this.tsParseConstModifier = this.tsParseModifiers.bind(this, { - allowedModifiers: ["const"], - disallowedModifiers: ["in", "out"], - errorTemplate: TSErrors.InvalidModifierOnTypeParameterPositions - }); - this.tsParseInOutConstModifiers = this.tsParseModifiers.bind(this, { - allowedModifiers: ["in", "out", "const"], - disallowedModifiers: ["public", "private", "protected", "readonly", "declare", "abstract", "override"], - errorTemplate: TSErrors.InvalidModifierOnTypeParameter - }); - } - getScopeHandler() { - return TypeScriptScopeHandler; - } - tsIsIdentifier() { - return tokenIsIdentifier(this.state.type); - } - tsTokenCanFollowModifier() { - return (this.match(0) || this.match(5) || this.match(55) || this.match(21) || this.match(138) || this.isLiteralPropertyName()) && !this.hasPrecedingLineBreak(); - } - tsNextTokenCanFollowModifier() { - this.next(); - return this.tsTokenCanFollowModifier(); - } - tsParseModifier(allowedModifiers, stopOnStartOfClassStaticBlock) { - if (!tokenIsIdentifier(this.state.type) && this.state.type !== 58 && this.state.type !== 75) { - return undefined; - } - const modifier = this.state.value; - if (allowedModifiers.includes(modifier)) { - if (stopOnStartOfClassStaticBlock && this.tsIsStartOfStaticBlocks()) { - return undefined; - } - if (this.tsTryParse(this.tsNextTokenCanFollowModifier.bind(this))) { - return modifier; - } - } - return undefined; - } - tsParseModifiers({ - allowedModifiers, - disallowedModifiers, - stopOnStartOfClassStaticBlock, - errorTemplate = TSErrors.InvalidModifierOnTypeMember - }, modified) { - const enforceOrder = (loc, modifier, before, after) => { - if (modifier === before && modified[after]) { - this.raise(TSErrors.InvalidModifiersOrder, loc, { - orderedModifiers: [before, after] - }); - } - }; - const incompatible = (loc, modifier, mod1, mod2) => { - if (modified[mod1] && modifier === mod2 || modified[mod2] && modifier === mod1) { - this.raise(TSErrors.IncompatibleModifiers, loc, { - modifiers: [mod1, mod2] - }); - } - }; - for (;;) { - const { - startLoc - } = this.state; - const modifier = this.tsParseModifier(allowedModifiers.concat(disallowedModifiers != null ? disallowedModifiers : []), stopOnStartOfClassStaticBlock); - if (!modifier) break; - if (tsIsAccessModifier(modifier)) { - if (modified.accessibility) { - this.raise(TSErrors.DuplicateAccessibilityModifier, startLoc, { - modifier - }); - } else { - enforceOrder(startLoc, modifier, modifier, "override"); - enforceOrder(startLoc, modifier, modifier, "static"); - enforceOrder(startLoc, modifier, modifier, "readonly"); - modified.accessibility = modifier; - } - } else if (tsIsVarianceAnnotations(modifier)) { - if (modified[modifier]) { - this.raise(TSErrors.DuplicateModifier, startLoc, { - modifier - }); - } - modified[modifier] = true; - enforceOrder(startLoc, modifier, "in", "out"); - } else { - if (hasOwnProperty.call(modified, modifier)) { - this.raise(TSErrors.DuplicateModifier, startLoc, { - modifier - }); - } else { - enforceOrder(startLoc, modifier, "static", "readonly"); - enforceOrder(startLoc, modifier, "static", "override"); - enforceOrder(startLoc, modifier, "override", "readonly"); - enforceOrder(startLoc, modifier, "abstract", "override"); - incompatible(startLoc, modifier, "declare", "override"); - incompatible(startLoc, modifier, "static", "abstract"); - } - modified[modifier] = true; - } - if (disallowedModifiers != null && disallowedModifiers.includes(modifier)) { - this.raise(errorTemplate, startLoc, { - modifier - }); - } - } - } - tsIsListTerminator(kind) { - switch (kind) { - case "EnumMembers": - case "TypeMembers": - return this.match(8); - case "HeritageClauseElement": - return this.match(5); - case "TupleElementTypes": - return this.match(3); - case "TypeParametersOrArguments": - return this.match(48); - } - } - tsParseList(kind, parseElement) { - const result = []; - while (!this.tsIsListTerminator(kind)) { - result.push(parseElement()); - } - return result; - } - tsParseDelimitedList(kind, parseElement, refTrailingCommaPos) { - return nonNull(this.tsParseDelimitedListWorker(kind, parseElement, true, refTrailingCommaPos)); - } - tsParseDelimitedListWorker(kind, parseElement, expectSuccess, refTrailingCommaPos) { - const result = []; - let trailingCommaPos = -1; - for (;;) { - if (this.tsIsListTerminator(kind)) { - break; - } - trailingCommaPos = -1; - const element = parseElement(); - if (element == null) { - return undefined; - } - result.push(element); - if (this.eat(12)) { - trailingCommaPos = this.state.lastTokStartLoc.index; - continue; - } - if (this.tsIsListTerminator(kind)) { - break; - } - if (expectSuccess) { - this.expect(12); - } - return undefined; - } - if (refTrailingCommaPos) { - refTrailingCommaPos.value = trailingCommaPos; - } - return result; - } - tsParseBracketedList(kind, parseElement, bracket, skipFirstToken, refTrailingCommaPos) { - if (!skipFirstToken) { - if (bracket) { - this.expect(0); - } else { - this.expect(47); - } - } - const result = this.tsParseDelimitedList(kind, parseElement, refTrailingCommaPos); - if (bracket) { - this.expect(3); - } else { - this.expect(48); - } - return result; - } - tsParseImportType() { - const node = this.startNode(); - this.expect(83); - this.expect(10); - if (!this.match(133)) { - this.raise(TSErrors.UnsupportedImportTypeArgument, this.state.startLoc); - } - node.argument = super.parseExprAtom(); - if (this.hasPlugin("importAttributes") || this.hasPlugin("importAssertions")) { - node.options = null; - } - if (this.eat(12)) { - this.expectImportAttributesPlugin(); - if (!this.match(11)) { - node.options = super.parseMaybeAssignAllowIn(); - this.eat(12); - } - } - this.expect(11); - if (this.eat(16)) { - node.qualifier = this.tsParseEntityName(); - } - if (this.match(47)) { - node.typeParameters = this.tsParseTypeArguments(); - } - return this.finishNode(node, "TSImportType"); - } - tsParseEntityName(allowReservedWords = true) { - let entity = this.parseIdentifier(allowReservedWords); - while (this.eat(16)) { - const node = this.startNodeAtNode(entity); - node.left = entity; - node.right = this.parseIdentifier(allowReservedWords); - entity = this.finishNode(node, "TSQualifiedName"); - } - return entity; - } - tsParseTypeReference() { - const node = this.startNode(); - node.typeName = this.tsParseEntityName(); - if (!this.hasPrecedingLineBreak() && this.match(47)) { - node.typeParameters = this.tsParseTypeArguments(); - } - return this.finishNode(node, "TSTypeReference"); - } - tsParseThisTypePredicate(lhs) { - this.next(); - const node = this.startNodeAtNode(lhs); - node.parameterName = lhs; - node.typeAnnotation = this.tsParseTypeAnnotation(false); - node.asserts = false; - return this.finishNode(node, "TSTypePredicate"); - } - tsParseThisTypeNode() { - const node = this.startNode(); - this.next(); - return this.finishNode(node, "TSThisType"); - } - tsParseTypeQuery() { - const node = this.startNode(); - this.expect(87); - if (this.match(83)) { - node.exprName = this.tsParseImportType(); - } else { - node.exprName = this.tsParseEntityName(); - } - if (!this.hasPrecedingLineBreak() && this.match(47)) { - node.typeParameters = this.tsParseTypeArguments(); - } - return this.finishNode(node, "TSTypeQuery"); - } - tsParseTypeParameter(parseModifiers) { - const node = this.startNode(); - parseModifiers(node); - node.name = this.tsParseTypeParameterName(); - node.constraint = this.tsEatThenParseType(81); - node.default = this.tsEatThenParseType(29); - return this.finishNode(node, "TSTypeParameter"); - } - tsTryParseTypeParameters(parseModifiers) { - if (this.match(47)) { - return this.tsParseTypeParameters(parseModifiers); - } - } - tsParseTypeParameters(parseModifiers) { - const node = this.startNode(); - if (this.match(47) || this.match(142)) { - this.next(); - } else { - this.unexpected(); - } - const refTrailingCommaPos = { - value: -1 - }; - node.params = this.tsParseBracketedList("TypeParametersOrArguments", this.tsParseTypeParameter.bind(this, parseModifiers), false, true, refTrailingCommaPos); - if (node.params.length === 0) { - this.raise(TSErrors.EmptyTypeParameters, node); - } - if (refTrailingCommaPos.value !== -1) { - this.addExtra(node, "trailingComma", refTrailingCommaPos.value); - } - return this.finishNode(node, "TSTypeParameterDeclaration"); - } - tsFillSignature(returnToken, signature) { - const returnTokenRequired = returnToken === 19; - const paramsKey = "parameters"; - const returnTypeKey = "typeAnnotation"; - signature.typeParameters = this.tsTryParseTypeParameters(this.tsParseConstModifier); - this.expect(10); - signature[paramsKey] = this.tsParseBindingListForSignature(); - if (returnTokenRequired) { - signature[returnTypeKey] = this.tsParseTypeOrTypePredicateAnnotation(returnToken); - } else if (this.match(returnToken)) { - signature[returnTypeKey] = this.tsParseTypeOrTypePredicateAnnotation(returnToken); - } - } - tsParseBindingListForSignature() { - const list = super.parseBindingList(11, 41, 2); - for (const pattern of list) { - const { - type - } = pattern; - if (type === "AssignmentPattern" || type === "TSParameterProperty") { - this.raise(TSErrors.UnsupportedSignatureParameterKind, pattern, { - type - }); - } - } - return list; - } - tsParseTypeMemberSemicolon() { - if (!this.eat(12) && !this.isLineTerminator()) { - this.expect(13); - } - } - tsParseSignatureMember(kind, node) { - this.tsFillSignature(14, node); - this.tsParseTypeMemberSemicolon(); - return this.finishNode(node, kind); - } - tsIsUnambiguouslyIndexSignature() { - this.next(); - if (tokenIsIdentifier(this.state.type)) { - this.next(); - return this.match(14); - } - return false; - } - tsTryParseIndexSignature(node) { - if (!(this.match(0) && this.tsLookAhead(this.tsIsUnambiguouslyIndexSignature.bind(this)))) { - return; - } - this.expect(0); - const id = this.parseIdentifier(); - id.typeAnnotation = this.tsParseTypeAnnotation(); - this.resetEndLocation(id); - this.expect(3); - node.parameters = [id]; - const type = this.tsTryParseTypeAnnotation(); - if (type) node.typeAnnotation = type; - this.tsParseTypeMemberSemicolon(); - return this.finishNode(node, "TSIndexSignature"); - } - tsParsePropertyOrMethodSignature(node, readonly) { - if (this.eat(17)) node.optional = true; - const nodeAny = node; - if (this.match(10) || this.match(47)) { - if (readonly) { - this.raise(TSErrors.ReadonlyForMethodSignature, node); - } - const method = nodeAny; - if (method.kind && this.match(47)) { - this.raise(TSErrors.AccesorCannotHaveTypeParameters, this.state.curPosition()); - } - this.tsFillSignature(14, method); - this.tsParseTypeMemberSemicolon(); - const paramsKey = "parameters"; - const returnTypeKey = "typeAnnotation"; - if (method.kind === "get") { - if (method[paramsKey].length > 0) { - this.raise(Errors.BadGetterArity, this.state.curPosition()); - if (this.isThisParam(method[paramsKey][0])) { - this.raise(TSErrors.AccesorCannotDeclareThisParameter, this.state.curPosition()); - } - } - } else if (method.kind === "set") { - if (method[paramsKey].length !== 1) { - this.raise(Errors.BadSetterArity, this.state.curPosition()); - } else { - const firstParameter = method[paramsKey][0]; - if (this.isThisParam(firstParameter)) { - this.raise(TSErrors.AccesorCannotDeclareThisParameter, this.state.curPosition()); - } - if (firstParameter.type === "Identifier" && firstParameter.optional) { - this.raise(TSErrors.SetAccesorCannotHaveOptionalParameter, this.state.curPosition()); - } - if (firstParameter.type === "RestElement") { - this.raise(TSErrors.SetAccesorCannotHaveRestParameter, this.state.curPosition()); - } - } - if (method[returnTypeKey]) { - this.raise(TSErrors.SetAccesorCannotHaveReturnType, method[returnTypeKey]); - } - } else { - method.kind = "method"; - } - return this.finishNode(method, "TSMethodSignature"); - } else { - const property = nodeAny; - if (readonly) property.readonly = true; - const type = this.tsTryParseTypeAnnotation(); - if (type) property.typeAnnotation = type; - this.tsParseTypeMemberSemicolon(); - return this.finishNode(property, "TSPropertySignature"); - } - } - tsParseTypeMember() { - const node = this.startNode(); - if (this.match(10) || this.match(47)) { - return this.tsParseSignatureMember("TSCallSignatureDeclaration", node); - } - if (this.match(77)) { - const id = this.startNode(); - this.next(); - if (this.match(10) || this.match(47)) { - return this.tsParseSignatureMember("TSConstructSignatureDeclaration", node); - } else { - node.key = this.createIdentifier(id, "new"); - return this.tsParsePropertyOrMethodSignature(node, false); - } - } - this.tsParseModifiers({ - allowedModifiers: ["readonly"], - disallowedModifiers: ["declare", "abstract", "private", "protected", "public", "static", "override"] - }, node); - const idx = this.tsTryParseIndexSignature(node); - if (idx) { - return idx; - } - super.parsePropertyName(node); - if (!node.computed && node.key.type === "Identifier" && (node.key.name === "get" || node.key.name === "set") && this.tsTokenCanFollowModifier()) { - node.kind = node.key.name; - super.parsePropertyName(node); - } - return this.tsParsePropertyOrMethodSignature(node, !!node.readonly); - } - tsParseTypeLiteral() { - const node = this.startNode(); - node.members = this.tsParseObjectTypeMembers(); - return this.finishNode(node, "TSTypeLiteral"); - } - tsParseObjectTypeMembers() { - this.expect(5); - const members = this.tsParseList("TypeMembers", this.tsParseTypeMember.bind(this)); - this.expect(8); - return members; - } - tsIsStartOfMappedType() { - this.next(); - if (this.eat(53)) { - return this.isContextual(122); - } - if (this.isContextual(122)) { - this.next(); - } - if (!this.match(0)) { - return false; - } - this.next(); - if (!this.tsIsIdentifier()) { - return false; - } - this.next(); - return this.match(58); - } - tsParseMappedTypeParameter() { - const node = this.startNode(); - node.name = this.tsParseTypeParameterName(); - node.constraint = this.tsExpectThenParseType(58); - return this.finishNode(node, "TSTypeParameter"); - } - tsParseMappedType() { - const node = this.startNode(); - this.expect(5); - if (this.match(53)) { - node.readonly = this.state.value; - this.next(); - this.expectContextual(122); - } else if (this.eatContextual(122)) { - node.readonly = true; - } - this.expect(0); - node.typeParameter = this.tsParseMappedTypeParameter(); - node.nameType = this.eatContextual(93) ? this.tsParseType() : null; - this.expect(3); - if (this.match(53)) { - node.optional = this.state.value; - this.next(); - this.expect(17); - } else if (this.eat(17)) { - node.optional = true; - } - node.typeAnnotation = this.tsTryParseType(); - this.semicolon(); - this.expect(8); - return this.finishNode(node, "TSMappedType"); - } - tsParseTupleType() { - const node = this.startNode(); - node.elementTypes = this.tsParseBracketedList("TupleElementTypes", this.tsParseTupleElementType.bind(this), true, false); - let seenOptionalElement = false; - node.elementTypes.forEach(elementNode => { - const { - type - } = elementNode; - if (seenOptionalElement && type !== "TSRestType" && type !== "TSOptionalType" && !(type === "TSNamedTupleMember" && elementNode.optional)) { - this.raise(TSErrors.OptionalTypeBeforeRequired, elementNode); - } - seenOptionalElement || (seenOptionalElement = type === "TSNamedTupleMember" && elementNode.optional || type === "TSOptionalType"); - }); - return this.finishNode(node, "TSTupleType"); - } - tsParseTupleElementType() { - const { - startLoc - } = this.state; - const rest = this.eat(21); - let labeled; - let label; - let optional; - let type; - const isWord = tokenIsKeywordOrIdentifier(this.state.type); - const chAfterWord = isWord ? this.lookaheadCharCode() : null; - if (chAfterWord === 58) { - labeled = true; - optional = false; - label = this.parseIdentifier(true); - this.expect(14); - type = this.tsParseType(); - } else if (chAfterWord === 63) { - optional = true; - const startLoc = this.state.startLoc; - const wordName = this.state.value; - const typeOrLabel = this.tsParseNonArrayType(); - if (this.lookaheadCharCode() === 58) { - labeled = true; - label = this.createIdentifier(this.startNodeAt(startLoc), wordName); - this.expect(17); - this.expect(14); - type = this.tsParseType(); - } else { - labeled = false; - type = typeOrLabel; - this.expect(17); - } - } else { - type = this.tsParseType(); - optional = this.eat(17); - labeled = this.eat(14); - } - if (labeled) { - let labeledNode; - if (label) { - labeledNode = this.startNodeAtNode(label); - labeledNode.optional = optional; - labeledNode.label = label; - labeledNode.elementType = type; - if (this.eat(17)) { - labeledNode.optional = true; - this.raise(TSErrors.TupleOptionalAfterType, this.state.lastTokStartLoc); - } - } else { - labeledNode = this.startNodeAtNode(type); - labeledNode.optional = optional; - this.raise(TSErrors.InvalidTupleMemberLabel, type); - labeledNode.label = type; - labeledNode.elementType = this.tsParseType(); - } - type = this.finishNode(labeledNode, "TSNamedTupleMember"); - } else if (optional) { - const optionalTypeNode = this.startNodeAtNode(type); - optionalTypeNode.typeAnnotation = type; - type = this.finishNode(optionalTypeNode, "TSOptionalType"); - } - if (rest) { - const restNode = this.startNodeAt(startLoc); - restNode.typeAnnotation = type; - type = this.finishNode(restNode, "TSRestType"); - } - return type; - } - tsParseParenthesizedType() { - const node = this.startNode(); - this.expect(10); - node.typeAnnotation = this.tsParseType(); - this.expect(11); - return this.finishNode(node, "TSParenthesizedType"); - } - tsParseFunctionOrConstructorType(type, abstract) { - const node = this.startNode(); - if (type === "TSConstructorType") { - node.abstract = !!abstract; - if (abstract) this.next(); - this.next(); - } - this.tsInAllowConditionalTypesContext(() => this.tsFillSignature(19, node)); - return this.finishNode(node, type); - } - tsParseLiteralTypeNode() { - const node = this.startNode(); - switch (this.state.type) { - case 134: - case 135: - case 133: - case 85: - case 86: - node.literal = super.parseExprAtom(); - break; - default: - this.unexpected(); - } - return this.finishNode(node, "TSLiteralType"); - } - tsParseTemplateLiteralType() { - const node = this.startNode(); - node.literal = super.parseTemplate(false); - return this.finishNode(node, "TSLiteralType"); - } - parseTemplateSubstitution() { - if (this.state.inType) return this.tsParseType(); - return super.parseTemplateSubstitution(); - } - tsParseThisTypeOrThisTypePredicate() { - const thisKeyword = this.tsParseThisTypeNode(); - if (this.isContextual(116) && !this.hasPrecedingLineBreak()) { - return this.tsParseThisTypePredicate(thisKeyword); - } else { - return thisKeyword; - } - } - tsParseNonArrayType() { - switch (this.state.type) { - case 133: - case 134: - case 135: - case 85: - case 86: - return this.tsParseLiteralTypeNode(); - case 53: - if (this.state.value === "-") { - const node = this.startNode(); - const nextToken = this.lookahead(); - if (nextToken.type !== 134 && nextToken.type !== 135) { - this.unexpected(); - } - node.literal = this.parseMaybeUnary(); - return this.finishNode(node, "TSLiteralType"); - } - break; - case 78: - return this.tsParseThisTypeOrThisTypePredicate(); - case 87: - return this.tsParseTypeQuery(); - case 83: - return this.tsParseImportType(); - case 5: - return this.tsLookAhead(this.tsIsStartOfMappedType.bind(this)) ? this.tsParseMappedType() : this.tsParseTypeLiteral(); - case 0: - return this.tsParseTupleType(); - case 10: - return this.tsParseParenthesizedType(); - case 25: - case 24: - return this.tsParseTemplateLiteralType(); - default: - { - const { - type - } = this.state; - if (tokenIsIdentifier(type) || type === 88 || type === 84) { - const nodeType = type === 88 ? "TSVoidKeyword" : type === 84 ? "TSNullKeyword" : keywordTypeFromName(this.state.value); - if (nodeType !== undefined && this.lookaheadCharCode() !== 46) { - const node = this.startNode(); - this.next(); - return this.finishNode(node, nodeType); - } - return this.tsParseTypeReference(); - } - } - } - this.unexpected(); - } - tsParseArrayTypeOrHigher() { - let type = this.tsParseNonArrayType(); - while (!this.hasPrecedingLineBreak() && this.eat(0)) { - if (this.match(3)) { - const node = this.startNodeAtNode(type); - node.elementType = type; - this.expect(3); - type = this.finishNode(node, "TSArrayType"); - } else { - const node = this.startNodeAtNode(type); - node.objectType = type; - node.indexType = this.tsParseType(); - this.expect(3); - type = this.finishNode(node, "TSIndexedAccessType"); - } - } - return type; - } - tsParseTypeOperator() { - const node = this.startNode(); - const operator = this.state.value; - this.next(); - node.operator = operator; - node.typeAnnotation = this.tsParseTypeOperatorOrHigher(); - if (operator === "readonly") { - this.tsCheckTypeAnnotationForReadOnly(node); - } - return this.finishNode(node, "TSTypeOperator"); - } - tsCheckTypeAnnotationForReadOnly(node) { - switch (node.typeAnnotation.type) { - case "TSTupleType": - case "TSArrayType": - return; - default: - this.raise(TSErrors.UnexpectedReadonly, node); - } - } - tsParseInferType() { - const node = this.startNode(); - this.expectContextual(115); - const typeParameter = this.startNode(); - typeParameter.name = this.tsParseTypeParameterName(); - typeParameter.constraint = this.tsTryParse(() => this.tsParseConstraintForInferType()); - node.typeParameter = this.finishNode(typeParameter, "TSTypeParameter"); - return this.finishNode(node, "TSInferType"); - } - tsParseConstraintForInferType() { - if (this.eat(81)) { - const constraint = this.tsInDisallowConditionalTypesContext(() => this.tsParseType()); - if (this.state.inDisallowConditionalTypesContext || !this.match(17)) { - return constraint; - } - } - } - tsParseTypeOperatorOrHigher() { - const isTypeOperator = tokenIsTSTypeOperator(this.state.type) && !this.state.containsEsc; - return isTypeOperator ? this.tsParseTypeOperator() : this.isContextual(115) ? this.tsParseInferType() : this.tsInAllowConditionalTypesContext(() => this.tsParseArrayTypeOrHigher()); - } - tsParseUnionOrIntersectionType(kind, parseConstituentType, operator) { - const node = this.startNode(); - const hasLeadingOperator = this.eat(operator); - const types = []; - do { - types.push(parseConstituentType()); - } while (this.eat(operator)); - if (types.length === 1 && !hasLeadingOperator) { - return types[0]; - } - node.types = types; - return this.finishNode(node, kind); - } - tsParseIntersectionTypeOrHigher() { - return this.tsParseUnionOrIntersectionType("TSIntersectionType", this.tsParseTypeOperatorOrHigher.bind(this), 45); - } - tsParseUnionTypeOrHigher() { - return this.tsParseUnionOrIntersectionType("TSUnionType", this.tsParseIntersectionTypeOrHigher.bind(this), 43); - } - tsIsStartOfFunctionType() { - if (this.match(47)) { - return true; - } - return this.match(10) && this.tsLookAhead(this.tsIsUnambiguouslyStartOfFunctionType.bind(this)); - } - tsSkipParameterStart() { - if (tokenIsIdentifier(this.state.type) || this.match(78)) { - this.next(); - return true; - } - if (this.match(5)) { - const { - errors - } = this.state; - const previousErrorCount = errors.length; - try { - this.parseObjectLike(8, true); - return errors.length === previousErrorCount; - } catch (_unused) { - return false; - } - } - if (this.match(0)) { - this.next(); - const { - errors - } = this.state; - const previousErrorCount = errors.length; - try { - super.parseBindingList(3, 93, 1); - return errors.length === previousErrorCount; - } catch (_unused2) { - return false; - } - } - return false; - } - tsIsUnambiguouslyStartOfFunctionType() { - this.next(); - if (this.match(11) || this.match(21)) { - return true; - } - if (this.tsSkipParameterStart()) { - if (this.match(14) || this.match(12) || this.match(17) || this.match(29)) { - return true; - } - if (this.match(11)) { - this.next(); - if (this.match(19)) { - return true; - } - } - } - return false; - } - tsParseTypeOrTypePredicateAnnotation(returnToken) { - return this.tsInType(() => { - const t = this.startNode(); - this.expect(returnToken); - const node = this.startNode(); - const asserts = !!this.tsTryParse(this.tsParseTypePredicateAsserts.bind(this)); - if (asserts && this.match(78)) { - let thisTypePredicate = this.tsParseThisTypeOrThisTypePredicate(); - if (thisTypePredicate.type === "TSThisType") { - node.parameterName = thisTypePredicate; - node.asserts = true; - node.typeAnnotation = null; - thisTypePredicate = this.finishNode(node, "TSTypePredicate"); - } else { - this.resetStartLocationFromNode(thisTypePredicate, node); - thisTypePredicate.asserts = true; - } - t.typeAnnotation = thisTypePredicate; - return this.finishNode(t, "TSTypeAnnotation"); - } - const typePredicateVariable = this.tsIsIdentifier() && this.tsTryParse(this.tsParseTypePredicatePrefix.bind(this)); - if (!typePredicateVariable) { - if (!asserts) { - return this.tsParseTypeAnnotation(false, t); - } - node.parameterName = this.parseIdentifier(); - node.asserts = asserts; - node.typeAnnotation = null; - t.typeAnnotation = this.finishNode(node, "TSTypePredicate"); - return this.finishNode(t, "TSTypeAnnotation"); - } - const type = this.tsParseTypeAnnotation(false); - node.parameterName = typePredicateVariable; - node.typeAnnotation = type; - node.asserts = asserts; - t.typeAnnotation = this.finishNode(node, "TSTypePredicate"); - return this.finishNode(t, "TSTypeAnnotation"); - }); - } - tsTryParseTypeOrTypePredicateAnnotation() { - if (this.match(14)) { - return this.tsParseTypeOrTypePredicateAnnotation(14); - } - } - tsTryParseTypeAnnotation() { - if (this.match(14)) { - return this.tsParseTypeAnnotation(); - } - } - tsTryParseType() { - return this.tsEatThenParseType(14); - } - tsParseTypePredicatePrefix() { - const id = this.parseIdentifier(); - if (this.isContextual(116) && !this.hasPrecedingLineBreak()) { - this.next(); - return id; - } - } - tsParseTypePredicateAsserts() { - if (this.state.type !== 109) { - return false; - } - const containsEsc = this.state.containsEsc; - this.next(); - if (!tokenIsIdentifier(this.state.type) && !this.match(78)) { - return false; - } - if (containsEsc) { - this.raise(Errors.InvalidEscapedReservedWord, this.state.lastTokStartLoc, { - reservedWord: "asserts" - }); - } - return true; - } - tsParseTypeAnnotation(eatColon = true, t = this.startNode()) { - this.tsInType(() => { - if (eatColon) this.expect(14); - t.typeAnnotation = this.tsParseType(); - }); - return this.finishNode(t, "TSTypeAnnotation"); - } - tsParseType() { - assert(this.state.inType); - const type = this.tsParseNonConditionalType(); - if (this.state.inDisallowConditionalTypesContext || this.hasPrecedingLineBreak() || !this.eat(81)) { - return type; - } - const node = this.startNodeAtNode(type); - node.checkType = type; - node.extendsType = this.tsInDisallowConditionalTypesContext(() => this.tsParseNonConditionalType()); - this.expect(17); - node.trueType = this.tsInAllowConditionalTypesContext(() => this.tsParseType()); - this.expect(14); - node.falseType = this.tsInAllowConditionalTypesContext(() => this.tsParseType()); - return this.finishNode(node, "TSConditionalType"); - } - isAbstractConstructorSignature() { - return this.isContextual(124) && this.lookahead().type === 77; - } - tsParseNonConditionalType() { - if (this.tsIsStartOfFunctionType()) { - return this.tsParseFunctionOrConstructorType("TSFunctionType"); - } - if (this.match(77)) { - return this.tsParseFunctionOrConstructorType("TSConstructorType"); - } else if (this.isAbstractConstructorSignature()) { - return this.tsParseFunctionOrConstructorType("TSConstructorType", true); - } - return this.tsParseUnionTypeOrHigher(); - } - tsParseTypeAssertion() { - if (this.getPluginOption("typescript", "disallowAmbiguousJSXLike")) { - this.raise(TSErrors.ReservedTypeAssertion, this.state.startLoc); - } - const node = this.startNode(); - node.typeAnnotation = this.tsInType(() => { - this.next(); - return this.match(75) ? this.tsParseTypeReference() : this.tsParseType(); - }); - this.expect(48); - node.expression = this.parseMaybeUnary(); - return this.finishNode(node, "TSTypeAssertion"); - } - tsParseHeritageClause(token) { - const originalStartLoc = this.state.startLoc; - const delimitedList = this.tsParseDelimitedList("HeritageClauseElement", () => { - const node = this.startNode(); - node.expression = this.tsParseEntityName(); - if (this.match(47)) { - node.typeParameters = this.tsParseTypeArguments(); - } - return this.finishNode(node, "TSExpressionWithTypeArguments"); - }); - if (!delimitedList.length) { - this.raise(TSErrors.EmptyHeritageClauseType, originalStartLoc, { - token - }); - } - return delimitedList; - } - tsParseInterfaceDeclaration(node, properties = {}) { - if (this.hasFollowingLineBreak()) return null; - this.expectContextual(129); - if (properties.declare) node.declare = true; - if (tokenIsIdentifier(this.state.type)) { - node.id = this.parseIdentifier(); - this.checkIdentifier(node.id, 130); - } else { - node.id = null; - this.raise(TSErrors.MissingInterfaceName, this.state.startLoc); - } - node.typeParameters = this.tsTryParseTypeParameters(this.tsParseInOutConstModifiers); - if (this.eat(81)) { - node.extends = this.tsParseHeritageClause("extends"); - } - const body = this.startNode(); - body.body = this.tsInType(this.tsParseObjectTypeMembers.bind(this)); - node.body = this.finishNode(body, "TSInterfaceBody"); - return this.finishNode(node, "TSInterfaceDeclaration"); - } - tsParseTypeAliasDeclaration(node) { - node.id = this.parseIdentifier(); - this.checkIdentifier(node.id, 2); - node.typeAnnotation = this.tsInType(() => { - node.typeParameters = this.tsTryParseTypeParameters(this.tsParseInOutModifiers); - this.expect(29); - if (this.isContextual(114) && this.lookahead().type !== 16) { - const node = this.startNode(); - this.next(); - return this.finishNode(node, "TSIntrinsicKeyword"); - } - return this.tsParseType(); - }); - this.semicolon(); - return this.finishNode(node, "TSTypeAliasDeclaration"); - } - tsInNoContext(cb) { - const oldContext = this.state.context; - this.state.context = [oldContext[0]]; - try { - return cb(); - } finally { - this.state.context = oldContext; - } - } - tsInType(cb) { - const oldInType = this.state.inType; - this.state.inType = true; - try { - return cb(); - } finally { - this.state.inType = oldInType; - } - } - tsInDisallowConditionalTypesContext(cb) { - const oldInDisallowConditionalTypesContext = this.state.inDisallowConditionalTypesContext; - this.state.inDisallowConditionalTypesContext = true; - try { - return cb(); - } finally { - this.state.inDisallowConditionalTypesContext = oldInDisallowConditionalTypesContext; - } - } - tsInAllowConditionalTypesContext(cb) { - const oldInDisallowConditionalTypesContext = this.state.inDisallowConditionalTypesContext; - this.state.inDisallowConditionalTypesContext = false; - try { - return cb(); - } finally { - this.state.inDisallowConditionalTypesContext = oldInDisallowConditionalTypesContext; - } - } - tsEatThenParseType(token) { - if (this.match(token)) { - return this.tsNextThenParseType(); - } - } - tsExpectThenParseType(token) { - return this.tsInType(() => { - this.expect(token); - return this.tsParseType(); - }); - } - tsNextThenParseType() { - return this.tsInType(() => { - this.next(); - return this.tsParseType(); - }); - } - tsParseEnumMember() { - const node = this.startNode(); - node.id = this.match(133) ? super.parseStringLiteral(this.state.value) : this.parseIdentifier(true); - if (this.eat(29)) { - node.initializer = super.parseMaybeAssignAllowIn(); - } - return this.finishNode(node, "TSEnumMember"); - } - tsParseEnumDeclaration(node, properties = {}) { - if (properties.const) node.const = true; - if (properties.declare) node.declare = true; - this.expectContextual(126); - node.id = this.parseIdentifier(); - this.checkIdentifier(node.id, node.const ? 8971 : 8459); - this.expect(5); - node.members = this.tsParseDelimitedList("EnumMembers", this.tsParseEnumMember.bind(this)); - this.expect(8); - return this.finishNode(node, "TSEnumDeclaration"); - } - tsParseModuleBlock() { - const node = this.startNode(); - this.scope.enter(0); - this.expect(5); - super.parseBlockOrModuleBlockBody(node.body = [], undefined, true, 8); - this.scope.exit(); - return this.finishNode(node, "TSModuleBlock"); - } - tsParseModuleOrNamespaceDeclaration(node, nested = false) { - node.id = this.parseIdentifier(); - if (!nested) { - this.checkIdentifier(node.id, 1024); - } - if (this.eat(16)) { - const inner = this.startNode(); - this.tsParseModuleOrNamespaceDeclaration(inner, true); - node.body = inner; - } else { - this.scope.enter(256); - this.prodParam.enter(0); - node.body = this.tsParseModuleBlock(); - this.prodParam.exit(); - this.scope.exit(); - } - return this.finishNode(node, "TSModuleDeclaration"); - } - tsParseAmbientExternalModuleDeclaration(node) { - if (this.isContextual(112)) { - node.global = true; - node.id = this.parseIdentifier(); - } else if (this.match(133)) { - node.id = super.parseStringLiteral(this.state.value); - } else { - this.unexpected(); - } - if (this.match(5)) { - this.scope.enter(256); - this.prodParam.enter(0); - node.body = this.tsParseModuleBlock(); - this.prodParam.exit(); - this.scope.exit(); - } else { - this.semicolon(); - } - return this.finishNode(node, "TSModuleDeclaration"); - } - tsParseImportEqualsDeclaration(node, maybeDefaultIdentifier, isExport) { - node.isExport = isExport || false; - node.id = maybeDefaultIdentifier || this.parseIdentifier(); - this.checkIdentifier(node.id, 4096); - this.expect(29); - const moduleReference = this.tsParseModuleReference(); - if (node.importKind === "type" && moduleReference.type !== "TSExternalModuleReference") { - this.raise(TSErrors.ImportAliasHasImportType, moduleReference); - } - node.moduleReference = moduleReference; - this.semicolon(); - return this.finishNode(node, "TSImportEqualsDeclaration"); - } - tsIsExternalModuleReference() { - return this.isContextual(119) && this.lookaheadCharCode() === 40; - } - tsParseModuleReference() { - return this.tsIsExternalModuleReference() ? this.tsParseExternalModuleReference() : this.tsParseEntityName(false); - } - tsParseExternalModuleReference() { - const node = this.startNode(); - this.expectContextual(119); - this.expect(10); - if (!this.match(133)) { - this.unexpected(); - } - node.expression = super.parseExprAtom(); - this.expect(11); - this.sawUnambiguousESM = true; - return this.finishNode(node, "TSExternalModuleReference"); - } - tsLookAhead(f) { - const state = this.state.clone(); - const res = f(); - this.state = state; - return res; - } - tsTryParseAndCatch(f) { - const result = this.tryParse(abort => f() || abort()); - if (result.aborted || !result.node) return; - if (result.error) this.state = result.failState; - return result.node; - } - tsTryParse(f) { - const state = this.state.clone(); - const result = f(); - if (result !== undefined && result !== false) { - return result; - } - this.state = state; - } - tsTryParseDeclare(nany) { - if (this.isLineTerminator()) { - return; - } - let startType = this.state.type; - let kind; - if (this.isContextual(100)) { - startType = 74; - kind = "let"; - } - return this.tsInAmbientContext(() => { - switch (startType) { - case 68: - nany.declare = true; - return super.parseFunctionStatement(nany, false, false); - case 80: - nany.declare = true; - return this.parseClass(nany, true, false); - case 126: - return this.tsParseEnumDeclaration(nany, { - declare: true - }); - case 112: - return this.tsParseAmbientExternalModuleDeclaration(nany); - case 75: - case 74: - if (!this.match(75) || !this.isLookaheadContextual("enum")) { - nany.declare = true; - return this.parseVarStatement(nany, kind || this.state.value, true); - } - this.expect(75); - return this.tsParseEnumDeclaration(nany, { - const: true, - declare: true - }); - case 129: - { - const result = this.tsParseInterfaceDeclaration(nany, { - declare: true - }); - if (result) return result; - } - default: - if (tokenIsIdentifier(startType)) { - return this.tsParseDeclaration(nany, this.state.value, true, null); - } - } - }); - } - tsTryParseExportDeclaration() { - return this.tsParseDeclaration(this.startNode(), this.state.value, true, null); - } - tsParseExpressionStatement(node, expr, decorators) { - switch (expr.name) { - case "declare": - { - const declaration = this.tsTryParseDeclare(node); - if (declaration) { - declaration.declare = true; - } - return declaration; - } - case "global": - if (this.match(5)) { - this.scope.enter(256); - this.prodParam.enter(0); - const mod = node; - mod.global = true; - mod.id = expr; - mod.body = this.tsParseModuleBlock(); - this.scope.exit(); - this.prodParam.exit(); - return this.finishNode(mod, "TSModuleDeclaration"); - } - break; - default: - return this.tsParseDeclaration(node, expr.name, false, decorators); - } - } - tsParseDeclaration(node, value, next, decorators) { - switch (value) { - case "abstract": - if (this.tsCheckLineTerminator(next) && (this.match(80) || tokenIsIdentifier(this.state.type))) { - return this.tsParseAbstractDeclaration(node, decorators); - } - break; - case "module": - if (this.tsCheckLineTerminator(next)) { - if (this.match(133)) { - return this.tsParseAmbientExternalModuleDeclaration(node); - } else if (tokenIsIdentifier(this.state.type)) { - return this.tsParseModuleOrNamespaceDeclaration(node); - } - } - break; - case "namespace": - if (this.tsCheckLineTerminator(next) && tokenIsIdentifier(this.state.type)) { - return this.tsParseModuleOrNamespaceDeclaration(node); - } - break; - case "type": - if (this.tsCheckLineTerminator(next) && tokenIsIdentifier(this.state.type)) { - return this.tsParseTypeAliasDeclaration(node); - } - break; - } - } - tsCheckLineTerminator(next) { - if (next) { - if (this.hasFollowingLineBreak()) return false; - this.next(); - return true; - } - return !this.isLineTerminator(); - } - tsTryParseGenericAsyncArrowFunction(startLoc) { - if (!this.match(47)) return; - const oldMaybeInArrowParameters = this.state.maybeInArrowParameters; - this.state.maybeInArrowParameters = true; - const res = this.tsTryParseAndCatch(() => { - const node = this.startNodeAt(startLoc); - node.typeParameters = this.tsParseTypeParameters(this.tsParseConstModifier); - super.parseFunctionParams(node); - node.returnType = this.tsTryParseTypeOrTypePredicateAnnotation(); - this.expect(19); - return node; - }); - this.state.maybeInArrowParameters = oldMaybeInArrowParameters; - if (!res) return; - return super.parseArrowExpression(res, null, true); - } - tsParseTypeArgumentsInExpression() { - if (this.reScan_lt() !== 47) return; - return this.tsParseTypeArguments(); - } - tsParseTypeArguments() { - const node = this.startNode(); - node.params = this.tsInType(() => this.tsInNoContext(() => { - this.expect(47); - return this.tsParseDelimitedList("TypeParametersOrArguments", this.tsParseType.bind(this)); - })); - if (node.params.length === 0) { - this.raise(TSErrors.EmptyTypeArguments, node); - } else if (!this.state.inType && this.curContext() === types.brace) { - this.reScan_lt_gt(); - } - this.expect(48); - return this.finishNode(node, "TSTypeParameterInstantiation"); - } - tsIsDeclarationStart() { - return tokenIsTSDeclarationStart(this.state.type); - } - isExportDefaultSpecifier() { - if (this.tsIsDeclarationStart()) return false; - return super.isExportDefaultSpecifier(); - } - parseAssignableListItem(flags, decorators) { - const startLoc = this.state.startLoc; - const modified = {}; - this.tsParseModifiers({ - allowedModifiers: ["public", "private", "protected", "override", "readonly"] - }, modified); - const accessibility = modified.accessibility; - const override = modified.override; - const readonly = modified.readonly; - if (!(flags & 4) && (accessibility || readonly || override)) { - this.raise(TSErrors.UnexpectedParameterModifier, startLoc); - } - const left = this.parseMaybeDefault(); - this.parseAssignableListItemTypes(left, flags); - const elt = this.parseMaybeDefault(left.loc.start, left); - if (accessibility || readonly || override) { - const pp = this.startNodeAt(startLoc); - if (decorators.length) { - pp.decorators = decorators; - } - if (accessibility) pp.accessibility = accessibility; - if (readonly) pp.readonly = readonly; - if (override) pp.override = override; - if (elt.type !== "Identifier" && elt.type !== "AssignmentPattern") { - this.raise(TSErrors.UnsupportedParameterPropertyKind, pp); - } - pp.parameter = elt; - return this.finishNode(pp, "TSParameterProperty"); - } - if (decorators.length) { - left.decorators = decorators; - } - return elt; - } - isSimpleParameter(node) { - return node.type === "TSParameterProperty" && super.isSimpleParameter(node.parameter) || super.isSimpleParameter(node); - } - tsDisallowOptionalPattern(node) { - for (const param of node.params) { - if (param.type !== "Identifier" && param.optional && !this.state.isAmbientContext) { - this.raise(TSErrors.PatternIsOptional, param); - } - } - } - setArrowFunctionParameters(node, params, trailingCommaLoc) { - super.setArrowFunctionParameters(node, params, trailingCommaLoc); - this.tsDisallowOptionalPattern(node); - } - parseFunctionBodyAndFinish(node, type, isMethod = false) { - if (this.match(14)) { - node.returnType = this.tsParseTypeOrTypePredicateAnnotation(14); - } - const bodilessType = type === "FunctionDeclaration" ? "TSDeclareFunction" : type === "ClassMethod" || type === "ClassPrivateMethod" ? "TSDeclareMethod" : undefined; - if (bodilessType && !this.match(5) && this.isLineTerminator()) { - return this.finishNode(node, bodilessType); - } - if (bodilessType === "TSDeclareFunction" && this.state.isAmbientContext) { - this.raise(TSErrors.DeclareFunctionHasImplementation, node); - if (node.declare) { - return super.parseFunctionBodyAndFinish(node, bodilessType, isMethod); - } - } - this.tsDisallowOptionalPattern(node); - return super.parseFunctionBodyAndFinish(node, type, isMethod); - } - registerFunctionStatementId(node) { - if (!node.body && node.id) { - this.checkIdentifier(node.id, 1024); - } else { - super.registerFunctionStatementId(node); - } - } - tsCheckForInvalidTypeCasts(items) { - items.forEach(node => { - if ((node == null ? void 0 : node.type) === "TSTypeCastExpression") { - this.raise(TSErrors.UnexpectedTypeAnnotation, node.typeAnnotation); - } - }); - } - toReferencedList(exprList, isInParens) { - this.tsCheckForInvalidTypeCasts(exprList); - return exprList; - } - parseArrayLike(close, canBePattern, isTuple, refExpressionErrors) { - const node = super.parseArrayLike(close, canBePattern, isTuple, refExpressionErrors); - if (node.type === "ArrayExpression") { - this.tsCheckForInvalidTypeCasts(node.elements); - } - return node; - } - parseSubscript(base, startLoc, noCalls, state) { - if (!this.hasPrecedingLineBreak() && this.match(35)) { - this.state.canStartJSXElement = false; - this.next(); - const nonNullExpression = this.startNodeAt(startLoc); - nonNullExpression.expression = base; - return this.finishNode(nonNullExpression, "TSNonNullExpression"); - } - let isOptionalCall = false; - if (this.match(18) && this.lookaheadCharCode() === 60) { - if (noCalls) { - state.stop = true; - return base; - } - state.optionalChainMember = isOptionalCall = true; - this.next(); - } - if (this.match(47) || this.match(51)) { - let missingParenErrorLoc; - const result = this.tsTryParseAndCatch(() => { - if (!noCalls && this.atPossibleAsyncArrow(base)) { - const asyncArrowFn = this.tsTryParseGenericAsyncArrowFunction(startLoc); - if (asyncArrowFn) { - return asyncArrowFn; - } - } - const typeArguments = this.tsParseTypeArgumentsInExpression(); - if (!typeArguments) return; - if (isOptionalCall && !this.match(10)) { - missingParenErrorLoc = this.state.curPosition(); - return; - } - if (tokenIsTemplate(this.state.type)) { - const result = super.parseTaggedTemplateExpression(base, startLoc, state); - result.typeParameters = typeArguments; - return result; - } - if (!noCalls && this.eat(10)) { - const node = this.startNodeAt(startLoc); - node.callee = base; - node.arguments = this.parseCallExpressionArguments(11, false); - this.tsCheckForInvalidTypeCasts(node.arguments); - node.typeParameters = typeArguments; - if (state.optionalChainMember) { - node.optional = isOptionalCall; - } - return this.finishCallExpression(node, state.optionalChainMember); - } - const tokenType = this.state.type; - if (tokenType === 48 || tokenType === 52 || tokenType !== 10 && tokenCanStartExpression(tokenType) && !this.hasPrecedingLineBreak()) { - return; - } - const node = this.startNodeAt(startLoc); - node.expression = base; - node.typeParameters = typeArguments; - return this.finishNode(node, "TSInstantiationExpression"); - }); - if (missingParenErrorLoc) { - this.unexpected(missingParenErrorLoc, 10); - } - if (result) { - if (result.type === "TSInstantiationExpression" && (this.match(16) || this.match(18) && this.lookaheadCharCode() !== 40)) { - this.raise(TSErrors.InvalidPropertyAccessAfterInstantiationExpression, this.state.startLoc); - } - return result; - } - } - return super.parseSubscript(base, startLoc, noCalls, state); - } - parseNewCallee(node) { - var _callee$extra; - super.parseNewCallee(node); - const { - callee - } = node; - if (callee.type === "TSInstantiationExpression" && !((_callee$extra = callee.extra) != null && _callee$extra.parenthesized)) { - node.typeParameters = callee.typeParameters; - node.callee = callee.expression; - } - } - parseExprOp(left, leftStartLoc, minPrec) { - let isSatisfies; - if (tokenOperatorPrecedence(58) > minPrec && !this.hasPrecedingLineBreak() && (this.isContextual(93) || (isSatisfies = this.isContextual(120)))) { - const node = this.startNodeAt(leftStartLoc); - node.expression = left; - node.typeAnnotation = this.tsInType(() => { - this.next(); - if (this.match(75)) { - if (isSatisfies) { - this.raise(Errors.UnexpectedKeyword, this.state.startLoc, { - keyword: "const" - }); - } - return this.tsParseTypeReference(); - } - return this.tsParseType(); - }); - this.finishNode(node, isSatisfies ? "TSSatisfiesExpression" : "TSAsExpression"); - this.reScan_lt_gt(); - return this.parseExprOp(node, leftStartLoc, minPrec); - } - return super.parseExprOp(left, leftStartLoc, minPrec); - } - checkReservedWord(word, startLoc, checkKeywords, isBinding) { - if (!this.state.isAmbientContext) { - super.checkReservedWord(word, startLoc, checkKeywords, isBinding); - } - } - checkImportReflection(node) { - super.checkImportReflection(node); - if (node.module && node.importKind !== "value") { - this.raise(TSErrors.ImportReflectionHasImportType, node.specifiers[0].loc.start); - } - } - checkDuplicateExports() {} - isPotentialImportPhase(isExport) { - if (super.isPotentialImportPhase(isExport)) return true; - if (this.isContextual(130)) { - const ch = this.lookaheadCharCode(); - return isExport ? ch === 123 || ch === 42 : ch !== 61; - } - return !isExport && this.isContextual(87); - } - applyImportPhase(node, isExport, phase, loc) { - super.applyImportPhase(node, isExport, phase, loc); - if (isExport) { - node.exportKind = phase === "type" ? "type" : "value"; - } else { - node.importKind = phase === "type" || phase === "typeof" ? phase : "value"; - } - } - parseImport(node) { - if (this.match(133)) { - node.importKind = "value"; - return super.parseImport(node); - } - let importNode; - if (tokenIsIdentifier(this.state.type) && this.lookaheadCharCode() === 61) { - node.importKind = "value"; - return this.tsParseImportEqualsDeclaration(node); - } else if (this.isContextual(130)) { - const maybeDefaultIdentifier = this.parseMaybeImportPhase(node, false); - if (this.lookaheadCharCode() === 61) { - return this.tsParseImportEqualsDeclaration(node, maybeDefaultIdentifier); - } else { - importNode = super.parseImportSpecifiersAndAfter(node, maybeDefaultIdentifier); - } - } else { - importNode = super.parseImport(node); - } - if (importNode.importKind === "type" && importNode.specifiers.length > 1 && importNode.specifiers[0].type === "ImportDefaultSpecifier") { - this.raise(TSErrors.TypeImportCannotSpecifyDefaultAndNamed, importNode); - } - return importNode; - } - parseExport(node, decorators) { - if (this.match(83)) { - this.next(); - const nodeImportEquals = node; - let maybeDefaultIdentifier = null; - if (this.isContextual(130) && this.isPotentialImportPhase(false)) { - maybeDefaultIdentifier = this.parseMaybeImportPhase(nodeImportEquals, false); - } else { - nodeImportEquals.importKind = "value"; - } - return this.tsParseImportEqualsDeclaration(nodeImportEquals, maybeDefaultIdentifier, true); - } else if (this.eat(29)) { - const assign = node; - assign.expression = super.parseExpression(); - this.semicolon(); - this.sawUnambiguousESM = true; - return this.finishNode(assign, "TSExportAssignment"); - } else if (this.eatContextual(93)) { - const decl = node; - this.expectContextual(128); - decl.id = this.parseIdentifier(); - this.semicolon(); - return this.finishNode(decl, "TSNamespaceExportDeclaration"); - } else { - return super.parseExport(node, decorators); - } - } - isAbstractClass() { - return this.isContextual(124) && this.lookahead().type === 80; - } - parseExportDefaultExpression() { - if (this.isAbstractClass()) { - const cls = this.startNode(); - this.next(); - cls.abstract = true; - return this.parseClass(cls, true, true); - } - if (this.match(129)) { - const result = this.tsParseInterfaceDeclaration(this.startNode()); - if (result) return result; - } - return super.parseExportDefaultExpression(); - } - parseVarStatement(node, kind, allowMissingInitializer = false) { - const { - isAmbientContext - } = this.state; - const declaration = super.parseVarStatement(node, kind, allowMissingInitializer || isAmbientContext); - if (!isAmbientContext) return declaration; - for (const { - id, - init - } of declaration.declarations) { - if (!init) continue; - if (kind !== "const" || !!id.typeAnnotation) { - this.raise(TSErrors.InitializerNotAllowedInAmbientContext, init); - } else if (!isValidAmbientConstInitializer(init, this.hasPlugin("estree"))) { - this.raise(TSErrors.ConstInitiailizerMustBeStringOrNumericLiteralOrLiteralEnumReference, init); - } - } - return declaration; - } - parseStatementContent(flags, decorators) { - if (this.match(75) && this.isLookaheadContextual("enum")) { - const node = this.startNode(); - this.expect(75); - return this.tsParseEnumDeclaration(node, { - const: true - }); - } - if (this.isContextual(126)) { - return this.tsParseEnumDeclaration(this.startNode()); - } - if (this.isContextual(129)) { - const result = this.tsParseInterfaceDeclaration(this.startNode()); - if (result) return result; - } - return super.parseStatementContent(flags, decorators); - } - parseAccessModifier() { - return this.tsParseModifier(["public", "protected", "private"]); - } - tsHasSomeModifiers(member, modifiers) { - return modifiers.some(modifier => { - if (tsIsAccessModifier(modifier)) { - return member.accessibility === modifier; - } - return !!member[modifier]; - }); - } - tsIsStartOfStaticBlocks() { - return this.isContextual(106) && this.lookaheadCharCode() === 123; - } - parseClassMember(classBody, member, state) { - const modifiers = ["declare", "private", "public", "protected", "override", "abstract", "readonly", "static"]; - this.tsParseModifiers({ - allowedModifiers: modifiers, - disallowedModifiers: ["in", "out"], - stopOnStartOfClassStaticBlock: true, - errorTemplate: TSErrors.InvalidModifierOnTypeParameterPositions - }, member); - const callParseClassMemberWithIsStatic = () => { - if (this.tsIsStartOfStaticBlocks()) { - this.next(); - this.next(); - if (this.tsHasSomeModifiers(member, modifiers)) { - this.raise(TSErrors.StaticBlockCannotHaveModifier, this.state.curPosition()); - } - super.parseClassStaticBlock(classBody, member); - } else { - this.parseClassMemberWithIsStatic(classBody, member, state, !!member.static); - } - }; - if (member.declare) { - this.tsInAmbientContext(callParseClassMemberWithIsStatic); - } else { - callParseClassMemberWithIsStatic(); - } - } - parseClassMemberWithIsStatic(classBody, member, state, isStatic) { - const idx = this.tsTryParseIndexSignature(member); - if (idx) { - classBody.body.push(idx); - if (member.abstract) { - this.raise(TSErrors.IndexSignatureHasAbstract, member); - } - if (member.accessibility) { - this.raise(TSErrors.IndexSignatureHasAccessibility, member, { - modifier: member.accessibility - }); - } - if (member.declare) { - this.raise(TSErrors.IndexSignatureHasDeclare, member); - } - if (member.override) { - this.raise(TSErrors.IndexSignatureHasOverride, member); - } - return; - } - if (!this.state.inAbstractClass && member.abstract) { - this.raise(TSErrors.NonAbstractClassHasAbstractMethod, member); - } - if (member.override) { - if (!state.hadSuperClass) { - this.raise(TSErrors.OverrideNotInSubClass, member); - } - } - super.parseClassMemberWithIsStatic(classBody, member, state, isStatic); - } - parsePostMemberNameModifiers(methodOrProp) { - const optional = this.eat(17); - if (optional) methodOrProp.optional = true; - if (methodOrProp.readonly && this.match(10)) { - this.raise(TSErrors.ClassMethodHasReadonly, methodOrProp); - } - if (methodOrProp.declare && this.match(10)) { - this.raise(TSErrors.ClassMethodHasDeclare, methodOrProp); - } - } - parseExpressionStatement(node, expr, decorators) { - const decl = expr.type === "Identifier" ? this.tsParseExpressionStatement(node, expr, decorators) : undefined; - return decl || super.parseExpressionStatement(node, expr, decorators); - } - shouldParseExportDeclaration() { - if (this.tsIsDeclarationStart()) return true; - return super.shouldParseExportDeclaration(); - } - parseConditional(expr, startLoc, refExpressionErrors) { - if (!this.state.maybeInArrowParameters || !this.match(17)) { - return super.parseConditional(expr, startLoc, refExpressionErrors); - } - const result = this.tryParse(() => super.parseConditional(expr, startLoc)); - if (!result.node) { - if (result.error) { - super.setOptionalParametersError(refExpressionErrors, result.error); - } - return expr; - } - if (result.error) this.state = result.failState; - return result.node; - } - parseParenItem(node, startLoc) { - const newNode = super.parseParenItem(node, startLoc); - if (this.eat(17)) { - newNode.optional = true; - this.resetEndLocation(node); - } - if (this.match(14)) { - const typeCastNode = this.startNodeAt(startLoc); - typeCastNode.expression = node; - typeCastNode.typeAnnotation = this.tsParseTypeAnnotation(); - return this.finishNode(typeCastNode, "TSTypeCastExpression"); - } - return node; - } - parseExportDeclaration(node) { - if (!this.state.isAmbientContext && this.isContextual(125)) { - return this.tsInAmbientContext(() => this.parseExportDeclaration(node)); - } - const startLoc = this.state.startLoc; - const isDeclare = this.eatContextual(125); - if (isDeclare && (this.isContextual(125) || !this.shouldParseExportDeclaration())) { - throw this.raise(TSErrors.ExpectedAmbientAfterExportDeclare, this.state.startLoc); - } - const isIdentifier = tokenIsIdentifier(this.state.type); - const declaration = isIdentifier && this.tsTryParseExportDeclaration() || super.parseExportDeclaration(node); - if (!declaration) return null; - if (declaration.type === "TSInterfaceDeclaration" || declaration.type === "TSTypeAliasDeclaration" || isDeclare) { - node.exportKind = "type"; - } - if (isDeclare) { - this.resetStartLocation(declaration, startLoc); - declaration.declare = true; - } - return declaration; - } - parseClassId(node, isStatement, optionalId, bindingType) { - if ((!isStatement || optionalId) && this.isContextual(113)) { - return; - } - super.parseClassId(node, isStatement, optionalId, node.declare ? 1024 : 8331); - const typeParameters = this.tsTryParseTypeParameters(this.tsParseInOutConstModifiers); - if (typeParameters) node.typeParameters = typeParameters; - } - parseClassPropertyAnnotation(node) { - if (!node.optional) { - if (this.eat(35)) { - node.definite = true; - } else if (this.eat(17)) { - node.optional = true; - } - } - const type = this.tsTryParseTypeAnnotation(); - if (type) node.typeAnnotation = type; - } - parseClassProperty(node) { - this.parseClassPropertyAnnotation(node); - if (this.state.isAmbientContext && !(node.readonly && !node.typeAnnotation) && this.match(29)) { - this.raise(TSErrors.DeclareClassFieldHasInitializer, this.state.startLoc); - } - if (node.abstract && this.match(29)) { - const { - key - } = node; - this.raise(TSErrors.AbstractPropertyHasInitializer, this.state.startLoc, { - propertyName: key.type === "Identifier" && !node.computed ? key.name : `[${this.input.slice(key.start, key.end)}]` - }); - } - return super.parseClassProperty(node); - } - parseClassPrivateProperty(node) { - if (node.abstract) { - this.raise(TSErrors.PrivateElementHasAbstract, node); - } - if (node.accessibility) { - this.raise(TSErrors.PrivateElementHasAccessibility, node, { - modifier: node.accessibility - }); - } - this.parseClassPropertyAnnotation(node); - return super.parseClassPrivateProperty(node); - } - parseClassAccessorProperty(node) { - this.parseClassPropertyAnnotation(node); - if (node.optional) { - this.raise(TSErrors.AccessorCannotBeOptional, node); - } - return super.parseClassAccessorProperty(node); - } - pushClassMethod(classBody, method, isGenerator, isAsync, isConstructor, allowsDirectSuper) { - const typeParameters = this.tsTryParseTypeParameters(this.tsParseConstModifier); - if (typeParameters && isConstructor) { - this.raise(TSErrors.ConstructorHasTypeParameters, typeParameters); - } - const { - declare = false, - kind - } = method; - if (declare && (kind === "get" || kind === "set")) { - this.raise(TSErrors.DeclareAccessor, method, { - kind - }); - } - if (typeParameters) method.typeParameters = typeParameters; - super.pushClassMethod(classBody, method, isGenerator, isAsync, isConstructor, allowsDirectSuper); - } - pushClassPrivateMethod(classBody, method, isGenerator, isAsync) { - const typeParameters = this.tsTryParseTypeParameters(this.tsParseConstModifier); - if (typeParameters) method.typeParameters = typeParameters; - super.pushClassPrivateMethod(classBody, method, isGenerator, isAsync); - } - declareClassPrivateMethodInScope(node, kind) { - if (node.type === "TSDeclareMethod") return; - if (node.type === "MethodDefinition" && !hasOwnProperty.call(node.value, "body")) { - return; - } - super.declareClassPrivateMethodInScope(node, kind); - } - parseClassSuper(node) { - super.parseClassSuper(node); - if (node.superClass && (this.match(47) || this.match(51))) { - node.superTypeParameters = this.tsParseTypeArgumentsInExpression(); - } - if (this.eatContextual(113)) { - node.implements = this.tsParseHeritageClause("implements"); - } - } - parseObjPropValue(prop, startLoc, isGenerator, isAsync, isPattern, isAccessor, refExpressionErrors) { - const typeParameters = this.tsTryParseTypeParameters(this.tsParseConstModifier); - if (typeParameters) prop.typeParameters = typeParameters; - return super.parseObjPropValue(prop, startLoc, isGenerator, isAsync, isPattern, isAccessor, refExpressionErrors); - } - parseFunctionParams(node, isConstructor) { - const typeParameters = this.tsTryParseTypeParameters(this.tsParseConstModifier); - if (typeParameters) node.typeParameters = typeParameters; - super.parseFunctionParams(node, isConstructor); - } - parseVarId(decl, kind) { - super.parseVarId(decl, kind); - if (decl.id.type === "Identifier" && !this.hasPrecedingLineBreak() && this.eat(35)) { - decl.definite = true; - } - const type = this.tsTryParseTypeAnnotation(); - if (type) { - decl.id.typeAnnotation = type; - this.resetEndLocation(decl.id); - } - } - parseAsyncArrowFromCallExpression(node, call) { - if (this.match(14)) { - node.returnType = this.tsParseTypeAnnotation(); - } - return super.parseAsyncArrowFromCallExpression(node, call); - } - parseMaybeAssign(refExpressionErrors, afterLeftParse) { - var _jsx, _jsx2, _typeCast, _jsx3, _typeCast2; - let state; - let jsx; - let typeCast; - if (this.hasPlugin("jsx") && (this.match(142) || this.match(47))) { - state = this.state.clone(); - jsx = this.tryParse(() => super.parseMaybeAssign(refExpressionErrors, afterLeftParse), state); - if (!jsx.error) return jsx.node; - const { - context - } = this.state; - const currentContext = context[context.length - 1]; - if (currentContext === types.j_oTag || currentContext === types.j_expr) { - context.pop(); - } - } - if (!((_jsx = jsx) != null && _jsx.error) && !this.match(47)) { - return super.parseMaybeAssign(refExpressionErrors, afterLeftParse); - } - if (!state || state === this.state) state = this.state.clone(); - let typeParameters; - const arrow = this.tryParse(abort => { - var _expr$extra, _typeParameters; - typeParameters = this.tsParseTypeParameters(this.tsParseConstModifier); - const expr = super.parseMaybeAssign(refExpressionErrors, afterLeftParse); - if (expr.type !== "ArrowFunctionExpression" || (_expr$extra = expr.extra) != null && _expr$extra.parenthesized) { - abort(); - } - if (((_typeParameters = typeParameters) == null ? void 0 : _typeParameters.params.length) !== 0) { - this.resetStartLocationFromNode(expr, typeParameters); - } - expr.typeParameters = typeParameters; - return expr; - }, state); - if (!arrow.error && !arrow.aborted) { - if (typeParameters) this.reportReservedArrowTypeParam(typeParameters); - return arrow.node; - } - if (!jsx) { - assert(!this.hasPlugin("jsx")); - typeCast = this.tryParse(() => super.parseMaybeAssign(refExpressionErrors, afterLeftParse), state); - if (!typeCast.error) return typeCast.node; - } - if ((_jsx2 = jsx) != null && _jsx2.node) { - this.state = jsx.failState; - return jsx.node; - } - if (arrow.node) { - this.state = arrow.failState; - if (typeParameters) this.reportReservedArrowTypeParam(typeParameters); - return arrow.node; - } - if ((_typeCast = typeCast) != null && _typeCast.node) { - this.state = typeCast.failState; - return typeCast.node; - } - throw ((_jsx3 = jsx) == null ? void 0 : _jsx3.error) || arrow.error || ((_typeCast2 = typeCast) == null ? void 0 : _typeCast2.error); - } - reportReservedArrowTypeParam(node) { - var _node$extra; - if (node.params.length === 1 && !node.params[0].constraint && !((_node$extra = node.extra) != null && _node$extra.trailingComma) && this.getPluginOption("typescript", "disallowAmbiguousJSXLike")) { - this.raise(TSErrors.ReservedArrowTypeParam, node); - } - } - parseMaybeUnary(refExpressionErrors, sawUnary) { - if (!this.hasPlugin("jsx") && this.match(47)) { - return this.tsParseTypeAssertion(); - } - return super.parseMaybeUnary(refExpressionErrors, sawUnary); - } - parseArrow(node) { - if (this.match(14)) { - const result = this.tryParse(abort => { - const returnType = this.tsParseTypeOrTypePredicateAnnotation(14); - if (this.canInsertSemicolon() || !this.match(19)) abort(); - return returnType; - }); - if (result.aborted) return; - if (!result.thrown) { - if (result.error) this.state = result.failState; - node.returnType = result.node; - } - } - return super.parseArrow(node); - } - parseAssignableListItemTypes(param, flags) { - if (!(flags & 2)) return param; - if (this.eat(17)) { - param.optional = true; - } - const type = this.tsTryParseTypeAnnotation(); - if (type) param.typeAnnotation = type; - this.resetEndLocation(param); - return param; - } - isAssignable(node, isBinding) { - switch (node.type) { - case "TSTypeCastExpression": - return this.isAssignable(node.expression, isBinding); - case "TSParameterProperty": - return true; - default: - return super.isAssignable(node, isBinding); - } - } - toAssignable(node, isLHS = false) { - switch (node.type) { - case "ParenthesizedExpression": - this.toAssignableParenthesizedExpression(node, isLHS); - break; - case "TSAsExpression": - case "TSSatisfiesExpression": - case "TSNonNullExpression": - case "TSTypeAssertion": - if (isLHS) { - this.expressionScope.recordArrowParameterBindingError(TSErrors.UnexpectedTypeCastInParameter, node); - } else { - this.raise(TSErrors.UnexpectedTypeCastInParameter, node); - } - this.toAssignable(node.expression, isLHS); - break; - case "AssignmentExpression": - if (!isLHS && node.left.type === "TSTypeCastExpression") { - node.left = this.typeCastToParameter(node.left); - } - default: - super.toAssignable(node, isLHS); - } - } - toAssignableParenthesizedExpression(node, isLHS) { - switch (node.expression.type) { - case "TSAsExpression": - case "TSSatisfiesExpression": - case "TSNonNullExpression": - case "TSTypeAssertion": - case "ParenthesizedExpression": - this.toAssignable(node.expression, isLHS); - break; - default: - super.toAssignable(node, isLHS); - } - } - checkToRestConversion(node, allowPattern) { - switch (node.type) { - case "TSAsExpression": - case "TSSatisfiesExpression": - case "TSTypeAssertion": - case "TSNonNullExpression": - this.checkToRestConversion(node.expression, false); - break; - default: - super.checkToRestConversion(node, allowPattern); - } - } - isValidLVal(type, isUnparenthesizedInAssign, binding) { - return getOwn({ - TSTypeCastExpression: true, - TSParameterProperty: "parameter", - TSNonNullExpression: "expression", - TSInstantiationExpression: "expression", - TSAsExpression: (binding !== 64 || !isUnparenthesizedInAssign) && ["expression", true], - TSSatisfiesExpression: (binding !== 64 || !isUnparenthesizedInAssign) && ["expression", true], - TSTypeAssertion: (binding !== 64 || !isUnparenthesizedInAssign) && ["expression", true] - }, type) || super.isValidLVal(type, isUnparenthesizedInAssign, binding); - } - parseBindingAtom() { - if (this.state.type === 78) { - return this.parseIdentifier(true); - } - return super.parseBindingAtom(); - } - parseMaybeDecoratorArguments(expr) { - if (this.match(47) || this.match(51)) { - const typeArguments = this.tsParseTypeArgumentsInExpression(); - if (this.match(10)) { - const call = super.parseMaybeDecoratorArguments(expr); - call.typeParameters = typeArguments; - return call; - } - this.unexpected(null, 10); - } - return super.parseMaybeDecoratorArguments(expr); - } - checkCommaAfterRest(close) { - if (this.state.isAmbientContext && this.match(12) && this.lookaheadCharCode() === close) { - this.next(); - return false; - } - return super.checkCommaAfterRest(close); - } - isClassMethod() { - return this.match(47) || super.isClassMethod(); - } - isClassProperty() { - return this.match(35) || this.match(14) || super.isClassProperty(); - } - parseMaybeDefault(startLoc, left) { - const node = super.parseMaybeDefault(startLoc, left); - if (node.type === "AssignmentPattern" && node.typeAnnotation && node.right.start < node.typeAnnotation.start) { - this.raise(TSErrors.TypeAnnotationAfterAssign, node.typeAnnotation); - } - return node; - } - getTokenFromCode(code) { - if (this.state.inType) { - if (code === 62) { - this.finishOp(48, 1); - return; - } - if (code === 60) { - this.finishOp(47, 1); - return; - } - } - super.getTokenFromCode(code); - } - reScan_lt_gt() { - const { - type - } = this.state; - if (type === 47) { - this.state.pos -= 1; - this.readToken_lt(); - } else if (type === 48) { - this.state.pos -= 1; - this.readToken_gt(); - } - } - reScan_lt() { - const { - type - } = this.state; - if (type === 51) { - this.state.pos -= 2; - this.finishOp(47, 1); - return 47; - } - return type; - } - toAssignableList(exprList, trailingCommaLoc, isLHS) { - for (let i = 0; i < exprList.length; i++) { - const expr = exprList[i]; - if ((expr == null ? void 0 : expr.type) === "TSTypeCastExpression") { - exprList[i] = this.typeCastToParameter(expr); - } - } - super.toAssignableList(exprList, trailingCommaLoc, isLHS); - } - typeCastToParameter(node) { - node.expression.typeAnnotation = node.typeAnnotation; - this.resetEndLocation(node.expression, node.typeAnnotation.loc.end); - return node.expression; - } - shouldParseArrow(params) { - if (this.match(14)) { - return params.every(expr => this.isAssignable(expr, true)); - } - return super.shouldParseArrow(params); - } - shouldParseAsyncArrow() { - return this.match(14) || super.shouldParseAsyncArrow(); - } - canHaveLeadingDecorator() { - return super.canHaveLeadingDecorator() || this.isAbstractClass(); - } - jsxParseOpeningElementAfterName(node) { - if (this.match(47) || this.match(51)) { - const typeArguments = this.tsTryParseAndCatch(() => this.tsParseTypeArgumentsInExpression()); - if (typeArguments) node.typeParameters = typeArguments; - } - return super.jsxParseOpeningElementAfterName(node); - } - getGetterSetterExpectedParamCount(method) { - const baseCount = super.getGetterSetterExpectedParamCount(method); - const params = this.getObjectOrClassMethodParams(method); - const firstParam = params[0]; - const hasContextParam = firstParam && this.isThisParam(firstParam); - return hasContextParam ? baseCount + 1 : baseCount; - } - parseCatchClauseParam() { - const param = super.parseCatchClauseParam(); - const type = this.tsTryParseTypeAnnotation(); - if (type) { - param.typeAnnotation = type; - this.resetEndLocation(param); - } - return param; - } - tsInAmbientContext(cb) { - const { - isAmbientContext: oldIsAmbientContext, - strict: oldStrict - } = this.state; - this.state.isAmbientContext = true; - this.state.strict = false; - try { - return cb(); - } finally { - this.state.isAmbientContext = oldIsAmbientContext; - this.state.strict = oldStrict; - } - } - parseClass(node, isStatement, optionalId) { - const oldInAbstractClass = this.state.inAbstractClass; - this.state.inAbstractClass = !!node.abstract; - try { - return super.parseClass(node, isStatement, optionalId); - } finally { - this.state.inAbstractClass = oldInAbstractClass; - } - } - tsParseAbstractDeclaration(node, decorators) { - if (this.match(80)) { - node.abstract = true; - return this.maybeTakeDecorators(decorators, this.parseClass(node, true, false)); - } else if (this.isContextual(129)) { - if (!this.hasFollowingLineBreak()) { - node.abstract = true; - this.raise(TSErrors.NonClassMethodPropertyHasAbstractModifer, node); - return this.tsParseInterfaceDeclaration(node); - } - } else { - this.unexpected(null, 80); - } - } - parseMethod(node, isGenerator, isAsync, isConstructor, allowDirectSuper, type, inClassScope) { - const method = super.parseMethod(node, isGenerator, isAsync, isConstructor, allowDirectSuper, type, inClassScope); - if (method.abstract) { - const hasBody = this.hasPlugin("estree") ? !!method.value.body : !!method.body; - if (hasBody) { - const { - key - } = method; - this.raise(TSErrors.AbstractMethodHasImplementation, method, { - methodName: key.type === "Identifier" && !method.computed ? key.name : `[${this.input.slice(key.start, key.end)}]` - }); - } - } - return method; - } - tsParseTypeParameterName() { - const typeName = this.parseIdentifier(); - return typeName.name; - } - shouldParseAsAmbientContext() { - return !!this.getPluginOption("typescript", "dts"); - } - parse() { - if (this.shouldParseAsAmbientContext()) { - this.state.isAmbientContext = true; - } - return super.parse(); - } - getExpression() { - if (this.shouldParseAsAmbientContext()) { - this.state.isAmbientContext = true; - } - return super.getExpression(); - } - parseExportSpecifier(node, isString, isInTypeExport, isMaybeTypeOnly) { - if (!isString && isMaybeTypeOnly) { - this.parseTypeOnlyImportExportSpecifier(node, false, isInTypeExport); - return this.finishNode(node, "ExportSpecifier"); - } - node.exportKind = "value"; - return super.parseExportSpecifier(node, isString, isInTypeExport, isMaybeTypeOnly); - } - parseImportSpecifier(specifier, importedIsString, isInTypeOnlyImport, isMaybeTypeOnly, bindingType) { - if (!importedIsString && isMaybeTypeOnly) { - this.parseTypeOnlyImportExportSpecifier(specifier, true, isInTypeOnlyImport); - return this.finishNode(specifier, "ImportSpecifier"); - } - specifier.importKind = "value"; - return super.parseImportSpecifier(specifier, importedIsString, isInTypeOnlyImport, isMaybeTypeOnly, isInTypeOnlyImport ? 4098 : 4096); - } - parseTypeOnlyImportExportSpecifier(node, isImport, isInTypeOnlyImportExport) { - const leftOfAsKey = isImport ? "imported" : "local"; - const rightOfAsKey = isImport ? "local" : "exported"; - let leftOfAs = node[leftOfAsKey]; - let rightOfAs; - let hasTypeSpecifier = false; - let canParseAsKeyword = true; - const loc = leftOfAs.loc.start; - if (this.isContextual(93)) { - const firstAs = this.parseIdentifier(); - if (this.isContextual(93)) { - const secondAs = this.parseIdentifier(); - if (tokenIsKeywordOrIdentifier(this.state.type)) { - hasTypeSpecifier = true; - leftOfAs = firstAs; - rightOfAs = isImport ? this.parseIdentifier() : this.parseModuleExportName(); - canParseAsKeyword = false; - } else { - rightOfAs = secondAs; - canParseAsKeyword = false; - } - } else if (tokenIsKeywordOrIdentifier(this.state.type)) { - canParseAsKeyword = false; - rightOfAs = isImport ? this.parseIdentifier() : this.parseModuleExportName(); - } else { - hasTypeSpecifier = true; - leftOfAs = firstAs; - } - } else if (tokenIsKeywordOrIdentifier(this.state.type)) { - hasTypeSpecifier = true; - if (isImport) { - leftOfAs = this.parseIdentifier(true); - if (!this.isContextual(93)) { - this.checkReservedWord(leftOfAs.name, leftOfAs.loc.start, true, true); - } - } else { - leftOfAs = this.parseModuleExportName(); - } - } - if (hasTypeSpecifier && isInTypeOnlyImportExport) { - this.raise(isImport ? TSErrors.TypeModifierIsUsedInTypeImports : TSErrors.TypeModifierIsUsedInTypeExports, loc); - } - node[leftOfAsKey] = leftOfAs; - node[rightOfAsKey] = rightOfAs; - const kindKey = isImport ? "importKind" : "exportKind"; - node[kindKey] = hasTypeSpecifier ? "type" : "value"; - if (canParseAsKeyword && this.eatContextual(93)) { - node[rightOfAsKey] = isImport ? this.parseIdentifier() : this.parseModuleExportName(); - } - if (!node[rightOfAsKey]) { - node[rightOfAsKey] = cloneIdentifier(node[leftOfAsKey]); - } - if (isImport) { - this.checkIdentifier(node[rightOfAsKey], hasTypeSpecifier ? 4098 : 4096); - } - } -}; -function isPossiblyLiteralEnum(expression) { - if (expression.type !== "MemberExpression") return false; - const { - computed, - property - } = expression; - if (computed && property.type !== "StringLiteral" && (property.type !== "TemplateLiteral" || property.expressions.length > 0)) { - return false; - } - return isUncomputedMemberExpressionChain(expression.object); -} -function isValidAmbientConstInitializer(expression, estree) { - var _expression$extra; - const { - type - } = expression; - if ((_expression$extra = expression.extra) != null && _expression$extra.parenthesized) { - return false; - } - if (estree) { - if (type === "Literal") { - const { - value - } = expression; - if (typeof value === "string" || typeof value === "boolean") { - return true; - } - } - } else { - if (type === "StringLiteral" || type === "BooleanLiteral") { - return true; - } - } - if (isNumber(expression, estree) || isNegativeNumber(expression, estree)) { - return true; - } - if (type === "TemplateLiteral" && expression.expressions.length === 0) { - return true; - } - if (isPossiblyLiteralEnum(expression)) { - return true; - } - return false; -} -function isNumber(expression, estree) { - if (estree) { - return expression.type === "Literal" && (typeof expression.value === "number" || "bigint" in expression); - } - return expression.type === "NumericLiteral" || expression.type === "BigIntLiteral"; -} -function isNegativeNumber(expression, estree) { - if (expression.type === "UnaryExpression") { - const { - operator, - argument - } = expression; - if (operator === "-" && isNumber(argument, estree)) { - return true; - } - } - return false; -} -function isUncomputedMemberExpressionChain(expression) { - if (expression.type === "Identifier") return true; - if (expression.type !== "MemberExpression" || expression.computed) { - return false; - } - return isUncomputedMemberExpressionChain(expression.object); -} -const PlaceholderErrors = ParseErrorEnum`placeholders`({ - ClassNameIsRequired: "A class name is required.", - UnexpectedSpace: "Unexpected space in placeholder." -}); -var placeholders = superClass => class PlaceholdersParserMixin extends superClass { - parsePlaceholder(expectedNode) { - if (this.match(144)) { - const node = this.startNode(); - this.next(); - this.assertNoSpace(); - node.name = super.parseIdentifier(true); - this.assertNoSpace(); - this.expect(144); - return this.finishPlaceholder(node, expectedNode); - } - } - finishPlaceholder(node, expectedNode) { - let placeholder = node; - if (!placeholder.expectedNode || !placeholder.type) { - placeholder = this.finishNode(placeholder, "Placeholder"); - } - placeholder.expectedNode = expectedNode; - return placeholder; - } - getTokenFromCode(code) { - if (code === 37 && this.input.charCodeAt(this.state.pos + 1) === 37) { - this.finishOp(144, 2); - } else { - super.getTokenFromCode(code); - } - } - parseExprAtom(refExpressionErrors) { - return this.parsePlaceholder("Expression") || super.parseExprAtom(refExpressionErrors); - } - parseIdentifier(liberal) { - return this.parsePlaceholder("Identifier") || super.parseIdentifier(liberal); - } - checkReservedWord(word, startLoc, checkKeywords, isBinding) { - if (word !== undefined) { - super.checkReservedWord(word, startLoc, checkKeywords, isBinding); - } - } - parseBindingAtom() { - return this.parsePlaceholder("Pattern") || super.parseBindingAtom(); - } - isValidLVal(type, isParenthesized, binding) { - return type === "Placeholder" || super.isValidLVal(type, isParenthesized, binding); - } - toAssignable(node, isLHS) { - if (node && node.type === "Placeholder" && node.expectedNode === "Expression") { - node.expectedNode = "Pattern"; - } else { - super.toAssignable(node, isLHS); - } - } - chStartsBindingIdentifier(ch, pos) { - if (super.chStartsBindingIdentifier(ch, pos)) { - return true; - } - const nextToken = this.lookahead(); - if (nextToken.type === 144) { - return true; - } - return false; - } - verifyBreakContinue(node, isBreak) { - if (node.label && node.label.type === "Placeholder") return; - super.verifyBreakContinue(node, isBreak); - } - parseExpressionStatement(node, expr) { - var _expr$extra; - if (expr.type !== "Placeholder" || (_expr$extra = expr.extra) != null && _expr$extra.parenthesized) { - return super.parseExpressionStatement(node, expr); - } - if (this.match(14)) { - const stmt = node; - stmt.label = this.finishPlaceholder(expr, "Identifier"); - this.next(); - stmt.body = super.parseStatementOrSloppyAnnexBFunctionDeclaration(); - return this.finishNode(stmt, "LabeledStatement"); - } - this.semicolon(); - const stmtPlaceholder = node; - stmtPlaceholder.name = expr.name; - return this.finishPlaceholder(stmtPlaceholder, "Statement"); - } - parseBlock(allowDirectives, createNewLexicalScope, afterBlockParse) { - return this.parsePlaceholder("BlockStatement") || super.parseBlock(allowDirectives, createNewLexicalScope, afterBlockParse); - } - parseFunctionId(requireId) { - return this.parsePlaceholder("Identifier") || super.parseFunctionId(requireId); - } - parseClass(node, isStatement, optionalId) { - const type = isStatement ? "ClassDeclaration" : "ClassExpression"; - this.next(); - const oldStrict = this.state.strict; - const placeholder = this.parsePlaceholder("Identifier"); - if (placeholder) { - if (this.match(81) || this.match(144) || this.match(5)) { - node.id = placeholder; - } else if (optionalId || !isStatement) { - node.id = null; - node.body = this.finishPlaceholder(placeholder, "ClassBody"); - return this.finishNode(node, type); - } else { - throw this.raise(PlaceholderErrors.ClassNameIsRequired, this.state.startLoc); - } - } else { - this.parseClassId(node, isStatement, optionalId); - } - super.parseClassSuper(node); - node.body = this.parsePlaceholder("ClassBody") || super.parseClassBody(!!node.superClass, oldStrict); - return this.finishNode(node, type); - } - parseExport(node, decorators) { - const placeholder = this.parsePlaceholder("Identifier"); - if (!placeholder) return super.parseExport(node, decorators); - const node2 = node; - if (!this.isContextual(98) && !this.match(12)) { - node2.specifiers = []; - node2.source = null; - node2.declaration = this.finishPlaceholder(placeholder, "Declaration"); - return this.finishNode(node2, "ExportNamedDeclaration"); - } - this.expectPlugin("exportDefaultFrom"); - const specifier = this.startNode(); - specifier.exported = placeholder; - node2.specifiers = [this.finishNode(specifier, "ExportDefaultSpecifier")]; - return super.parseExport(node2, decorators); - } - isExportDefaultSpecifier() { - if (this.match(65)) { - const next = this.nextTokenStart(); - if (this.isUnparsedContextual(next, "from")) { - if (this.input.startsWith(tokenLabelName(144), this.nextTokenStartSince(next + 4))) { - return true; - } - } - } - return super.isExportDefaultSpecifier(); - } - maybeParseExportDefaultSpecifier(node, maybeDefaultIdentifier) { - var _specifiers; - if ((_specifiers = node.specifiers) != null && _specifiers.length) { - return true; - } - return super.maybeParseExportDefaultSpecifier(node, maybeDefaultIdentifier); - } - checkExport(node) { - const { - specifiers - } = node; - if (specifiers != null && specifiers.length) { - node.specifiers = specifiers.filter(node => node.exported.type === "Placeholder"); - } - super.checkExport(node); - node.specifiers = specifiers; - } - parseImport(node) { - const placeholder = this.parsePlaceholder("Identifier"); - if (!placeholder) return super.parseImport(node); - node.specifiers = []; - if (!this.isContextual(98) && !this.match(12)) { - node.source = this.finishPlaceholder(placeholder, "StringLiteral"); - this.semicolon(); - return this.finishNode(node, "ImportDeclaration"); - } - const specifier = this.startNodeAtNode(placeholder); - specifier.local = placeholder; - node.specifiers.push(this.finishNode(specifier, "ImportDefaultSpecifier")); - if (this.eat(12)) { - const hasStarImport = this.maybeParseStarImportSpecifier(node); - if (!hasStarImport) this.parseNamedImportSpecifiers(node); - } - this.expectContextual(98); - node.source = this.parseImportSource(); - this.semicolon(); - return this.finishNode(node, "ImportDeclaration"); - } - parseImportSource() { - return this.parsePlaceholder("StringLiteral") || super.parseImportSource(); - } - assertNoSpace() { - if (this.state.start > this.state.lastTokEndLoc.index) { - this.raise(PlaceholderErrors.UnexpectedSpace, this.state.lastTokEndLoc); - } - } -}; -var v8intrinsic = superClass => class V8IntrinsicMixin extends superClass { - parseV8Intrinsic() { - if (this.match(54)) { - const v8IntrinsicStartLoc = this.state.startLoc; - const node = this.startNode(); - this.next(); - if (tokenIsIdentifier(this.state.type)) { - const name = this.parseIdentifierName(); - const identifier = this.createIdentifier(node, name); - identifier.type = "V8IntrinsicIdentifier"; - if (this.match(10)) { - return identifier; - } - } - this.unexpected(v8IntrinsicStartLoc); - } - } - parseExprAtom(refExpressionErrors) { - return this.parseV8Intrinsic() || super.parseExprAtom(refExpressionErrors); - } -}; -function hasPlugin(plugins, expectedConfig) { - const [expectedName, expectedOptions] = typeof expectedConfig === "string" ? [expectedConfig, {}] : expectedConfig; - const expectedKeys = Object.keys(expectedOptions); - const expectedOptionsIsEmpty = expectedKeys.length === 0; - return plugins.some(p => { - if (typeof p === "string") { - return expectedOptionsIsEmpty && p === expectedName; - } else { - const [pluginName, pluginOptions] = p; - if (pluginName !== expectedName) { - return false; - } - for (const key of expectedKeys) { - if (pluginOptions[key] !== expectedOptions[key]) { - return false; - } - } - return true; - } - }); -} -function getPluginOption(plugins, name, option) { - const plugin = plugins.find(plugin => { - if (Array.isArray(plugin)) { - return plugin[0] === name; - } else { - return plugin === name; - } - }); - if (plugin && Array.isArray(plugin) && plugin.length > 1) { - return plugin[1][option]; - } - return null; -} -const PIPELINE_PROPOSALS = ["minimal", "fsharp", "hack", "smart"]; -const TOPIC_TOKENS = ["^^", "@@", "^", "%", "#"]; -function validatePlugins(plugins) { - if (hasPlugin(plugins, "decorators")) { - if (hasPlugin(plugins, "decorators-legacy")) { - throw new Error("Cannot use the decorators and decorators-legacy plugin together"); - } - const decoratorsBeforeExport = getPluginOption(plugins, "decorators", "decoratorsBeforeExport"); - if (decoratorsBeforeExport != null && typeof decoratorsBeforeExport !== "boolean") { - throw new Error("'decoratorsBeforeExport' must be a boolean, if specified."); - } - const allowCallParenthesized = getPluginOption(plugins, "decorators", "allowCallParenthesized"); - if (allowCallParenthesized != null && typeof allowCallParenthesized !== "boolean") { - throw new Error("'allowCallParenthesized' must be a boolean."); - } - } - if (hasPlugin(plugins, "flow") && hasPlugin(plugins, "typescript")) { - throw new Error("Cannot combine flow and typescript plugins."); - } - if (hasPlugin(plugins, "placeholders") && hasPlugin(plugins, "v8intrinsic")) { - throw new Error("Cannot combine placeholders and v8intrinsic plugins."); - } - if (hasPlugin(plugins, "pipelineOperator")) { - const proposal = getPluginOption(plugins, "pipelineOperator", "proposal"); - if (!PIPELINE_PROPOSALS.includes(proposal)) { - const proposalList = PIPELINE_PROPOSALS.map(p => `"${p}"`).join(", "); - throw new Error(`"pipelineOperator" requires "proposal" option whose value must be one of: ${proposalList}.`); - } - const recordAndTupleConfigItem = ["recordAndTuple", { - syntaxType: "hash" - }]; - const tupleSyntaxIsHash = hasPlugin(plugins, recordAndTupleConfigItem); - if (proposal === "hack") { - if (hasPlugin(plugins, "placeholders")) { - throw new Error("Cannot combine placeholders plugin and Hack-style pipes."); - } - if (hasPlugin(plugins, "v8intrinsic")) { - throw new Error("Cannot combine v8intrinsic plugin and Hack-style pipes."); - } - const topicToken = getPluginOption(plugins, "pipelineOperator", "topicToken"); - if (!TOPIC_TOKENS.includes(topicToken)) { - const tokenList = TOPIC_TOKENS.map(t => `"${t}"`).join(", "); - throw new Error(`"pipelineOperator" in "proposal": "hack" mode also requires a "topicToken" option whose value must be one of: ${tokenList}.`); - } - if (topicToken === "#" && tupleSyntaxIsHash) { - throw new Error(`Plugin conflict between \`["pipelineOperator", { proposal: "hack", topicToken: "#" }]\` and \`${JSON.stringify(recordAndTupleConfigItem)}\`.`); - } - } else if (proposal === "smart" && tupleSyntaxIsHash) { - throw new Error(`Plugin conflict between \`["pipelineOperator", { proposal: "smart" }]\` and \`${JSON.stringify(recordAndTupleConfigItem)}\`.`); - } - } - if (hasPlugin(plugins, "moduleAttributes")) { - { - if (hasPlugin(plugins, "importAssertions") || hasPlugin(plugins, "importAttributes")) { - throw new Error("Cannot combine importAssertions, importAttributes and moduleAttributes plugins."); - } - const moduleAttributesVersionPluginOption = getPluginOption(plugins, "moduleAttributes", "version"); - if (moduleAttributesVersionPluginOption !== "may-2020") { - throw new Error("The 'moduleAttributes' plugin requires a 'version' option," + " representing the last proposal update. Currently, the" + " only supported value is 'may-2020'."); - } - } - } - if (hasPlugin(plugins, "importAssertions") && hasPlugin(plugins, "importAttributes")) { - throw new Error("Cannot combine importAssertions and importAttributes plugins."); - } - if (hasPlugin(plugins, "recordAndTuple")) { - const syntaxType = getPluginOption(plugins, "recordAndTuple", "syntaxType"); - if (syntaxType != null) { - { - const RECORD_AND_TUPLE_SYNTAX_TYPES = ["hash", "bar"]; - if (!RECORD_AND_TUPLE_SYNTAX_TYPES.includes(syntaxType)) { - throw new Error("The 'syntaxType' option of the 'recordAndTuple' plugin must be one of: " + RECORD_AND_TUPLE_SYNTAX_TYPES.map(p => `'${p}'`).join(", ")); - } - } - } - } - if (hasPlugin(plugins, "asyncDoExpressions") && !hasPlugin(plugins, "doExpressions")) { - const error = new Error("'asyncDoExpressions' requires 'doExpressions', please add 'doExpressions' to parser plugins."); - error.missingPlugins = "doExpressions"; - throw error; - } - if (hasPlugin(plugins, "optionalChainingAssign") && getPluginOption(plugins, "optionalChainingAssign", "version") !== "2023-07") { - throw new Error("The 'optionalChainingAssign' plugin requires a 'version' option," + " representing the last proposal update. Currently, the" + " only supported value is '2023-07'."); - } -} -const mixinPlugins = { - estree, - jsx, - flow, - typescript, - v8intrinsic, - placeholders -}; -const mixinPluginNames = Object.keys(mixinPlugins); -const defaultOptions = { - sourceType: "script", - sourceFilename: undefined, - startColumn: 0, - startLine: 1, - allowAwaitOutsideFunction: false, - allowReturnOutsideFunction: false, - allowNewTargetOutsideFunction: false, - allowImportExportEverywhere: false, - allowSuperOutsideMethod: false, - allowUndeclaredExports: false, - plugins: [], - strictMode: null, - ranges: false, - tokens: false, - createImportExpressions: false, - createParenthesizedExpressions: false, - errorRecovery: false, - attachComment: true, - annexB: true -}; -function getOptions(opts) { - if (opts == null) { - return Object.assign({}, defaultOptions); - } - if (opts.annexB != null && opts.annexB !== false) { - throw new Error("The `annexB` option can only be set to `false`."); - } - const options = {}; - for (const key of Object.keys(defaultOptions)) { - var _opts$key; - options[key] = (_opts$key = opts[key]) != null ? _opts$key : defaultOptions[key]; - } - return options; -} -class ExpressionParser extends LValParser { - checkProto(prop, isRecord, protoRef, refExpressionErrors) { - if (prop.type === "SpreadElement" || this.isObjectMethod(prop) || prop.computed || prop.shorthand) { - return; - } - const key = prop.key; - const name = key.type === "Identifier" ? key.name : key.value; - if (name === "__proto__") { - if (isRecord) { - this.raise(Errors.RecordNoProto, key); - return; - } - if (protoRef.used) { - if (refExpressionErrors) { - if (refExpressionErrors.doubleProtoLoc === null) { - refExpressionErrors.doubleProtoLoc = key.loc.start; - } - } else { - this.raise(Errors.DuplicateProto, key); - } - } - protoRef.used = true; - } - } - shouldExitDescending(expr, potentialArrowAt) { - return expr.type === "ArrowFunctionExpression" && expr.start === potentialArrowAt; - } - getExpression() { - this.enterInitialScopes(); - this.nextToken(); - const expr = this.parseExpression(); - if (!this.match(139)) { - this.unexpected(); - } - this.finalizeRemainingComments(); - expr.comments = this.comments; - expr.errors = this.state.errors; - if (this.options.tokens) { - expr.tokens = this.tokens; - } - return expr; - } - parseExpression(disallowIn, refExpressionErrors) { - if (disallowIn) { - return this.disallowInAnd(() => this.parseExpressionBase(refExpressionErrors)); - } - return this.allowInAnd(() => this.parseExpressionBase(refExpressionErrors)); - } - parseExpressionBase(refExpressionErrors) { - const startLoc = this.state.startLoc; - const expr = this.parseMaybeAssign(refExpressionErrors); - if (this.match(12)) { - const node = this.startNodeAt(startLoc); - node.expressions = [expr]; - while (this.eat(12)) { - node.expressions.push(this.parseMaybeAssign(refExpressionErrors)); - } - this.toReferencedList(node.expressions); - return this.finishNode(node, "SequenceExpression"); - } - return expr; - } - parseMaybeAssignDisallowIn(refExpressionErrors, afterLeftParse) { - return this.disallowInAnd(() => this.parseMaybeAssign(refExpressionErrors, afterLeftParse)); - } - parseMaybeAssignAllowIn(refExpressionErrors, afterLeftParse) { - return this.allowInAnd(() => this.parseMaybeAssign(refExpressionErrors, afterLeftParse)); - } - setOptionalParametersError(refExpressionErrors, resultError) { - var _resultError$loc; - refExpressionErrors.optionalParametersLoc = (_resultError$loc = resultError == null ? void 0 : resultError.loc) != null ? _resultError$loc : this.state.startLoc; - } - parseMaybeAssign(refExpressionErrors, afterLeftParse) { - const startLoc = this.state.startLoc; - if (this.isContextual(108)) { - if (this.prodParam.hasYield) { - let left = this.parseYield(); - if (afterLeftParse) { - left = afterLeftParse.call(this, left, startLoc); - } - return left; - } - } - let ownExpressionErrors; - if (refExpressionErrors) { - ownExpressionErrors = false; - } else { - refExpressionErrors = new ExpressionErrors(); - ownExpressionErrors = true; - } - const { - type - } = this.state; - if (type === 10 || tokenIsIdentifier(type)) { - this.state.potentialArrowAt = this.state.start; - } - let left = this.parseMaybeConditional(refExpressionErrors); - if (afterLeftParse) { - left = afterLeftParse.call(this, left, startLoc); - } - if (tokenIsAssignment(this.state.type)) { - const node = this.startNodeAt(startLoc); - const operator = this.state.value; - node.operator = operator; - if (this.match(29)) { - this.toAssignable(left, true); - node.left = left; - const startIndex = startLoc.index; - if (refExpressionErrors.doubleProtoLoc != null && refExpressionErrors.doubleProtoLoc.index >= startIndex) { - refExpressionErrors.doubleProtoLoc = null; - } - if (refExpressionErrors.shorthandAssignLoc != null && refExpressionErrors.shorthandAssignLoc.index >= startIndex) { - refExpressionErrors.shorthandAssignLoc = null; - } - if (refExpressionErrors.privateKeyLoc != null && refExpressionErrors.privateKeyLoc.index >= startIndex) { - this.checkDestructuringPrivate(refExpressionErrors); - refExpressionErrors.privateKeyLoc = null; - } - } else { - node.left = left; - } - this.next(); - node.right = this.parseMaybeAssign(); - this.checkLVal(left, { - in: this.finishNode(node, "AssignmentExpression") - }); - return node; - } else if (ownExpressionErrors) { - this.checkExpressionErrors(refExpressionErrors, true); - } - return left; - } - parseMaybeConditional(refExpressionErrors) { - const startLoc = this.state.startLoc; - const potentialArrowAt = this.state.potentialArrowAt; - const expr = this.parseExprOps(refExpressionErrors); - if (this.shouldExitDescending(expr, potentialArrowAt)) { - return expr; - } - return this.parseConditional(expr, startLoc, refExpressionErrors); - } - parseConditional(expr, startLoc, refExpressionErrors) { - if (this.eat(17)) { - const node = this.startNodeAt(startLoc); - node.test = expr; - node.consequent = this.parseMaybeAssignAllowIn(); - this.expect(14); - node.alternate = this.parseMaybeAssign(); - return this.finishNode(node, "ConditionalExpression"); - } - return expr; - } - parseMaybeUnaryOrPrivate(refExpressionErrors) { - return this.match(138) ? this.parsePrivateName() : this.parseMaybeUnary(refExpressionErrors); - } - parseExprOps(refExpressionErrors) { - const startLoc = this.state.startLoc; - const potentialArrowAt = this.state.potentialArrowAt; - const expr = this.parseMaybeUnaryOrPrivate(refExpressionErrors); - if (this.shouldExitDescending(expr, potentialArrowAt)) { - return expr; - } - return this.parseExprOp(expr, startLoc, -1); - } - parseExprOp(left, leftStartLoc, minPrec) { - if (this.isPrivateName(left)) { - const value = this.getPrivateNameSV(left); - if (minPrec >= tokenOperatorPrecedence(58) || !this.prodParam.hasIn || !this.match(58)) { - this.raise(Errors.PrivateInExpectedIn, left, { - identifierName: value - }); - } - this.classScope.usePrivateName(value, left.loc.start); - } - const op = this.state.type; - if (tokenIsOperator(op) && (this.prodParam.hasIn || !this.match(58))) { - let prec = tokenOperatorPrecedence(op); - if (prec > minPrec) { - if (op === 39) { - this.expectPlugin("pipelineOperator"); - if (this.state.inFSharpPipelineDirectBody) { - return left; - } - this.checkPipelineAtInfixOperator(left, leftStartLoc); - } - const node = this.startNodeAt(leftStartLoc); - node.left = left; - node.operator = this.state.value; - const logical = op === 41 || op === 42; - const coalesce = op === 40; - if (coalesce) { - prec = tokenOperatorPrecedence(42); - } - this.next(); - if (op === 39 && this.hasPlugin(["pipelineOperator", { - proposal: "minimal" - }])) { - if (this.state.type === 96 && this.prodParam.hasAwait) { - throw this.raise(Errors.UnexpectedAwaitAfterPipelineBody, this.state.startLoc); - } - } - node.right = this.parseExprOpRightExpr(op, prec); - const finishedNode = this.finishNode(node, logical || coalesce ? "LogicalExpression" : "BinaryExpression"); - const nextOp = this.state.type; - if (coalesce && (nextOp === 41 || nextOp === 42) || logical && nextOp === 40) { - throw this.raise(Errors.MixingCoalesceWithLogical, this.state.startLoc); - } - return this.parseExprOp(finishedNode, leftStartLoc, minPrec); - } - } - return left; - } - parseExprOpRightExpr(op, prec) { - const startLoc = this.state.startLoc; - switch (op) { - case 39: - switch (this.getPluginOption("pipelineOperator", "proposal")) { - case "hack": - return this.withTopicBindingContext(() => { - return this.parseHackPipeBody(); - }); - case "smart": - return this.withTopicBindingContext(() => { - if (this.prodParam.hasYield && this.isContextual(108)) { - throw this.raise(Errors.PipeBodyIsTighter, this.state.startLoc); - } - return this.parseSmartPipelineBodyInStyle(this.parseExprOpBaseRightExpr(op, prec), startLoc); - }); - case "fsharp": - return this.withSoloAwaitPermittingContext(() => { - return this.parseFSharpPipelineBody(prec); - }); - } - default: - return this.parseExprOpBaseRightExpr(op, prec); - } - } - parseExprOpBaseRightExpr(op, prec) { - const startLoc = this.state.startLoc; - return this.parseExprOp(this.parseMaybeUnaryOrPrivate(), startLoc, tokenIsRightAssociative(op) ? prec - 1 : prec); - } - parseHackPipeBody() { - var _body$extra; - const { - startLoc - } = this.state; - const body = this.parseMaybeAssign(); - const requiredParentheses = UnparenthesizedPipeBodyDescriptions.has(body.type); - if (requiredParentheses && !((_body$extra = body.extra) != null && _body$extra.parenthesized)) { - this.raise(Errors.PipeUnparenthesizedBody, startLoc, { - type: body.type - }); - } - if (!this.topicReferenceWasUsedInCurrentContext()) { - this.raise(Errors.PipeTopicUnused, startLoc); - } - return body; - } - checkExponentialAfterUnary(node) { - if (this.match(57)) { - this.raise(Errors.UnexpectedTokenUnaryExponentiation, node.argument); - } - } - parseMaybeUnary(refExpressionErrors, sawUnary) { - const startLoc = this.state.startLoc; - const isAwait = this.isContextual(96); - if (isAwait && this.isAwaitAllowed()) { - this.next(); - const expr = this.parseAwait(startLoc); - if (!sawUnary) this.checkExponentialAfterUnary(expr); - return expr; - } - const update = this.match(34); - const node = this.startNode(); - if (tokenIsPrefix(this.state.type)) { - node.operator = this.state.value; - node.prefix = true; - if (this.match(72)) { - this.expectPlugin("throwExpressions"); - } - const isDelete = this.match(89); - this.next(); - node.argument = this.parseMaybeUnary(null, true); - this.checkExpressionErrors(refExpressionErrors, true); - if (this.state.strict && isDelete) { - const arg = node.argument; - if (arg.type === "Identifier") { - this.raise(Errors.StrictDelete, node); - } else if (this.hasPropertyAsPrivateName(arg)) { - this.raise(Errors.DeletePrivateField, node); - } - } - if (!update) { - if (!sawUnary) { - this.checkExponentialAfterUnary(node); - } - return this.finishNode(node, "UnaryExpression"); - } - } - const expr = this.parseUpdate(node, update, refExpressionErrors); - if (isAwait) { - const { - type - } = this.state; - const startsExpr = this.hasPlugin("v8intrinsic") ? tokenCanStartExpression(type) : tokenCanStartExpression(type) && !this.match(54); - if (startsExpr && !this.isAmbiguousAwait()) { - this.raiseOverwrite(Errors.AwaitNotInAsyncContext, startLoc); - return this.parseAwait(startLoc); - } - } - return expr; - } - parseUpdate(node, update, refExpressionErrors) { - if (update) { - const updateExpressionNode = node; - this.checkLVal(updateExpressionNode.argument, { - in: this.finishNode(updateExpressionNode, "UpdateExpression") - }); - return node; - } - const startLoc = this.state.startLoc; - let expr = this.parseExprSubscripts(refExpressionErrors); - if (this.checkExpressionErrors(refExpressionErrors, false)) return expr; - while (tokenIsPostfix(this.state.type) && !this.canInsertSemicolon()) { - const node = this.startNodeAt(startLoc); - node.operator = this.state.value; - node.prefix = false; - node.argument = expr; - this.next(); - this.checkLVal(expr, { - in: expr = this.finishNode(node, "UpdateExpression") - }); - } - return expr; - } - parseExprSubscripts(refExpressionErrors) { - const startLoc = this.state.startLoc; - const potentialArrowAt = this.state.potentialArrowAt; - const expr = this.parseExprAtom(refExpressionErrors); - if (this.shouldExitDescending(expr, potentialArrowAt)) { - return expr; - } - return this.parseSubscripts(expr, startLoc); - } - parseSubscripts(base, startLoc, noCalls) { - const state = { - optionalChainMember: false, - maybeAsyncArrow: this.atPossibleAsyncArrow(base), - stop: false - }; - do { - base = this.parseSubscript(base, startLoc, noCalls, state); - state.maybeAsyncArrow = false; - } while (!state.stop); - return base; - } - parseSubscript(base, startLoc, noCalls, state) { - const { - type - } = this.state; - if (!noCalls && type === 15) { - return this.parseBind(base, startLoc, noCalls, state); - } else if (tokenIsTemplate(type)) { - return this.parseTaggedTemplateExpression(base, startLoc, state); - } - let optional = false; - if (type === 18) { - if (noCalls) { - this.raise(Errors.OptionalChainingNoNew, this.state.startLoc); - if (this.lookaheadCharCode() === 40) { - state.stop = true; - return base; - } - } - state.optionalChainMember = optional = true; - this.next(); - } - if (!noCalls && this.match(10)) { - return this.parseCoverCallAndAsyncArrowHead(base, startLoc, state, optional); - } else { - const computed = this.eat(0); - if (computed || optional || this.eat(16)) { - return this.parseMember(base, startLoc, state, computed, optional); - } else { - state.stop = true; - return base; - } - } - } - parseMember(base, startLoc, state, computed, optional) { - const node = this.startNodeAt(startLoc); - node.object = base; - node.computed = computed; - if (computed) { - node.property = this.parseExpression(); - this.expect(3); - } else if (this.match(138)) { - if (base.type === "Super") { - this.raise(Errors.SuperPrivateField, startLoc); - } - this.classScope.usePrivateName(this.state.value, this.state.startLoc); - node.property = this.parsePrivateName(); - } else { - node.property = this.parseIdentifier(true); - } - if (state.optionalChainMember) { - node.optional = optional; - return this.finishNode(node, "OptionalMemberExpression"); - } else { - return this.finishNode(node, "MemberExpression"); - } - } - parseBind(base, startLoc, noCalls, state) { - const node = this.startNodeAt(startLoc); - node.object = base; - this.next(); - node.callee = this.parseNoCallExpr(); - state.stop = true; - return this.parseSubscripts(this.finishNode(node, "BindExpression"), startLoc, noCalls); - } - parseCoverCallAndAsyncArrowHead(base, startLoc, state, optional) { - const oldMaybeInArrowParameters = this.state.maybeInArrowParameters; - let refExpressionErrors = null; - this.state.maybeInArrowParameters = true; - this.next(); - const node = this.startNodeAt(startLoc); - node.callee = base; - const { - maybeAsyncArrow, - optionalChainMember - } = state; - if (maybeAsyncArrow) { - this.expressionScope.enter(newAsyncArrowScope()); - refExpressionErrors = new ExpressionErrors(); - } - if (optionalChainMember) { - node.optional = optional; - } - if (optional) { - node.arguments = this.parseCallExpressionArguments(11); - } else { - node.arguments = this.parseCallExpressionArguments(11, base.type === "Import", base.type !== "Super", node, refExpressionErrors); - } - let finishedNode = this.finishCallExpression(node, optionalChainMember); - if (maybeAsyncArrow && this.shouldParseAsyncArrow() && !optional) { - state.stop = true; - this.checkDestructuringPrivate(refExpressionErrors); - this.expressionScope.validateAsPattern(); - this.expressionScope.exit(); - finishedNode = this.parseAsyncArrowFromCallExpression(this.startNodeAt(startLoc), finishedNode); - } else { - if (maybeAsyncArrow) { - this.checkExpressionErrors(refExpressionErrors, true); - this.expressionScope.exit(); - } - this.toReferencedArguments(finishedNode); - } - this.state.maybeInArrowParameters = oldMaybeInArrowParameters; - return finishedNode; - } - toReferencedArguments(node, isParenthesizedExpr) { - this.toReferencedListDeep(node.arguments, isParenthesizedExpr); - } - parseTaggedTemplateExpression(base, startLoc, state) { - const node = this.startNodeAt(startLoc); - node.tag = base; - node.quasi = this.parseTemplate(true); - if (state.optionalChainMember) { - this.raise(Errors.OptionalChainingNoTemplate, startLoc); - } - return this.finishNode(node, "TaggedTemplateExpression"); - } - atPossibleAsyncArrow(base) { - return base.type === "Identifier" && base.name === "async" && this.state.lastTokEndLoc.index === base.end && !this.canInsertSemicolon() && base.end - base.start === 5 && base.start === this.state.potentialArrowAt; - } - expectImportAttributesPlugin() { - if (!this.hasPlugin("importAssertions")) { - this.expectPlugin("importAttributes"); - } - } - finishCallExpression(node, optional) { - if (node.callee.type === "Import") { - if (node.arguments.length === 2) { - { - if (!this.hasPlugin("moduleAttributes")) { - this.expectImportAttributesPlugin(); - } - } - } - if (node.arguments.length === 0 || node.arguments.length > 2) { - this.raise(Errors.ImportCallArity, node, { - maxArgumentCount: this.hasPlugin("importAttributes") || this.hasPlugin("importAssertions") || this.hasPlugin("moduleAttributes") ? 2 : 1 - }); - } else { - for (const arg of node.arguments) { - if (arg.type === "SpreadElement") { - this.raise(Errors.ImportCallSpreadArgument, arg); - } - } - } - } - return this.finishNode(node, optional ? "OptionalCallExpression" : "CallExpression"); - } - parseCallExpressionArguments(close, dynamicImport, allowPlaceholder, nodeForExtra, refExpressionErrors) { - const elts = []; - let first = true; - const oldInFSharpPipelineDirectBody = this.state.inFSharpPipelineDirectBody; - this.state.inFSharpPipelineDirectBody = false; - while (!this.eat(close)) { - if (first) { - first = false; - } else { - this.expect(12); - if (this.match(close)) { - if (dynamicImport && !this.hasPlugin("importAttributes") && !this.hasPlugin("importAssertions") && !this.hasPlugin("moduleAttributes")) { - this.raise(Errors.ImportCallArgumentTrailingComma, this.state.lastTokStartLoc); - } - if (nodeForExtra) { - this.addTrailingCommaExtraToNode(nodeForExtra); - } - this.next(); - break; - } - } - elts.push(this.parseExprListItem(false, refExpressionErrors, allowPlaceholder)); - } - this.state.inFSharpPipelineDirectBody = oldInFSharpPipelineDirectBody; - return elts; - } - shouldParseAsyncArrow() { - return this.match(19) && !this.canInsertSemicolon(); - } - parseAsyncArrowFromCallExpression(node, call) { - var _call$extra; - this.resetPreviousNodeTrailingComments(call); - this.expect(19); - this.parseArrowExpression(node, call.arguments, true, (_call$extra = call.extra) == null ? void 0 : _call$extra.trailingCommaLoc); - if (call.innerComments) { - setInnerComments(node, call.innerComments); - } - if (call.callee.trailingComments) { - setInnerComments(node, call.callee.trailingComments); - } - return node; - } - parseNoCallExpr() { - const startLoc = this.state.startLoc; - return this.parseSubscripts(this.parseExprAtom(), startLoc, true); - } - parseExprAtom(refExpressionErrors) { - let node; - let decorators = null; - const { - type - } = this.state; - switch (type) { - case 79: - return this.parseSuper(); - case 83: - node = this.startNode(); - this.next(); - if (this.match(16)) { - return this.parseImportMetaProperty(node); - } - if (this.match(10)) { - if (this.options.createImportExpressions) { - return this.parseImportCall(node); - } else { - return this.finishNode(node, "Import"); - } - } else { - this.raise(Errors.UnsupportedImport, this.state.lastTokStartLoc); - return this.finishNode(node, "Import"); - } - case 78: - node = this.startNode(); - this.next(); - return this.finishNode(node, "ThisExpression"); - case 90: - { - return this.parseDo(this.startNode(), false); - } - case 56: - case 31: - { - this.readRegexp(); - return this.parseRegExpLiteral(this.state.value); - } - case 134: - return this.parseNumericLiteral(this.state.value); - case 135: - return this.parseBigIntLiteral(this.state.value); - case 136: - return this.parseDecimalLiteral(this.state.value); - case 133: - return this.parseStringLiteral(this.state.value); - case 84: - return this.parseNullLiteral(); - case 85: - return this.parseBooleanLiteral(true); - case 86: - return this.parseBooleanLiteral(false); - case 10: - { - const canBeArrow = this.state.potentialArrowAt === this.state.start; - return this.parseParenAndDistinguishExpression(canBeArrow); - } - case 2: - case 1: - { - return this.parseArrayLike(this.state.type === 2 ? 4 : 3, false, true); - } - case 0: - { - return this.parseArrayLike(3, true, false, refExpressionErrors); - } - case 6: - case 7: - { - return this.parseObjectLike(this.state.type === 6 ? 9 : 8, false, true); - } - case 5: - { - return this.parseObjectLike(8, false, false, refExpressionErrors); - } - case 68: - return this.parseFunctionOrFunctionSent(); - case 26: - decorators = this.parseDecorators(); - case 80: - return this.parseClass(this.maybeTakeDecorators(decorators, this.startNode()), false); - case 77: - return this.parseNewOrNewTarget(); - case 25: - case 24: - return this.parseTemplate(false); - case 15: - { - node = this.startNode(); - this.next(); - node.object = null; - const callee = node.callee = this.parseNoCallExpr(); - if (callee.type === "MemberExpression") { - return this.finishNode(node, "BindExpression"); - } else { - throw this.raise(Errors.UnsupportedBind, callee); - } - } - case 138: - { - this.raise(Errors.PrivateInExpectedIn, this.state.startLoc, { - identifierName: this.state.value - }); - return this.parsePrivateName(); - } - case 33: - { - return this.parseTopicReferenceThenEqualsSign(54, "%"); - } - case 32: - { - return this.parseTopicReferenceThenEqualsSign(44, "^"); - } - case 37: - case 38: - { - return this.parseTopicReference("hack"); - } - case 44: - case 54: - case 27: - { - const pipeProposal = this.getPluginOption("pipelineOperator", "proposal"); - if (pipeProposal) { - return this.parseTopicReference(pipeProposal); - } - this.unexpected(); - break; - } - case 47: - { - const lookaheadCh = this.input.codePointAt(this.nextTokenStart()); - if (isIdentifierStart(lookaheadCh) || lookaheadCh === 62) { - this.expectOnePlugin(["jsx", "flow", "typescript"]); - } else { - this.unexpected(); - } - break; - } - default: - if (tokenIsIdentifier(type)) { - if (this.isContextual(127) && this.lookaheadInLineCharCode() === 123) { - return this.parseModuleExpression(); - } - const canBeArrow = this.state.potentialArrowAt === this.state.start; - const containsEsc = this.state.containsEsc; - const id = this.parseIdentifier(); - if (!containsEsc && id.name === "async" && !this.canInsertSemicolon()) { - const { - type - } = this.state; - if (type === 68) { - this.resetPreviousNodeTrailingComments(id); - this.next(); - return this.parseAsyncFunctionExpression(this.startNodeAtNode(id)); - } else if (tokenIsIdentifier(type)) { - if (this.lookaheadCharCode() === 61) { - return this.parseAsyncArrowUnaryFunction(this.startNodeAtNode(id)); - } else { - return id; - } - } else if (type === 90) { - this.resetPreviousNodeTrailingComments(id); - return this.parseDo(this.startNodeAtNode(id), true); - } - } - if (canBeArrow && this.match(19) && !this.canInsertSemicolon()) { - this.next(); - return this.parseArrowExpression(this.startNodeAtNode(id), [id], false); - } - return id; - } else { - this.unexpected(); - } - } - } - parseTopicReferenceThenEqualsSign(topicTokenType, topicTokenValue) { - const pipeProposal = this.getPluginOption("pipelineOperator", "proposal"); - if (pipeProposal) { - this.state.type = topicTokenType; - this.state.value = topicTokenValue; - this.state.pos--; - this.state.end--; - this.state.endLoc = createPositionWithColumnOffset(this.state.endLoc, -1); - return this.parseTopicReference(pipeProposal); - } else { - this.unexpected(); - } - } - parseTopicReference(pipeProposal) { - const node = this.startNode(); - const startLoc = this.state.startLoc; - const tokenType = this.state.type; - this.next(); - return this.finishTopicReference(node, startLoc, pipeProposal, tokenType); - } - finishTopicReference(node, startLoc, pipeProposal, tokenType) { - if (this.testTopicReferenceConfiguration(pipeProposal, startLoc, tokenType)) { - const nodeType = pipeProposal === "smart" ? "PipelinePrimaryTopicReference" : "TopicReference"; - if (!this.topicReferenceIsAllowedInCurrentContext()) { - this.raise(pipeProposal === "smart" ? Errors.PrimaryTopicNotAllowed : Errors.PipeTopicUnbound, startLoc); - } - this.registerTopicReference(); - return this.finishNode(node, nodeType); - } else { - throw this.raise(Errors.PipeTopicUnconfiguredToken, startLoc, { - token: tokenLabelName(tokenType) - }); - } - } - testTopicReferenceConfiguration(pipeProposal, startLoc, tokenType) { - switch (pipeProposal) { - case "hack": - { - return this.hasPlugin(["pipelineOperator", { - topicToken: tokenLabelName(tokenType) - }]); - } - case "smart": - return tokenType === 27; - default: - throw this.raise(Errors.PipeTopicRequiresHackPipes, startLoc); - } - } - parseAsyncArrowUnaryFunction(node) { - this.prodParam.enter(functionFlags(true, this.prodParam.hasYield)); - const params = [this.parseIdentifier()]; - this.prodParam.exit(); - if (this.hasPrecedingLineBreak()) { - this.raise(Errors.LineTerminatorBeforeArrow, this.state.curPosition()); - } - this.expect(19); - return this.parseArrowExpression(node, params, true); - } - parseDo(node, isAsync) { - this.expectPlugin("doExpressions"); - if (isAsync) { - this.expectPlugin("asyncDoExpressions"); - } - node.async = isAsync; - this.next(); - const oldLabels = this.state.labels; - this.state.labels = []; - if (isAsync) { - this.prodParam.enter(2); - node.body = this.parseBlock(); - this.prodParam.exit(); - } else { - node.body = this.parseBlock(); - } - this.state.labels = oldLabels; - return this.finishNode(node, "DoExpression"); - } - parseSuper() { - const node = this.startNode(); - this.next(); - if (this.match(10) && !this.scope.allowDirectSuper && !this.options.allowSuperOutsideMethod) { - this.raise(Errors.SuperNotAllowed, node); - } else if (!this.scope.allowSuper && !this.options.allowSuperOutsideMethod) { - this.raise(Errors.UnexpectedSuper, node); - } - if (!this.match(10) && !this.match(0) && !this.match(16)) { - this.raise(Errors.UnsupportedSuper, node); - } - return this.finishNode(node, "Super"); - } - parsePrivateName() { - const node = this.startNode(); - const id = this.startNodeAt(createPositionWithColumnOffset(this.state.startLoc, 1)); - const name = this.state.value; - this.next(); - node.id = this.createIdentifier(id, name); - return this.finishNode(node, "PrivateName"); - } - parseFunctionOrFunctionSent() { - const node = this.startNode(); - this.next(); - if (this.prodParam.hasYield && this.match(16)) { - const meta = this.createIdentifier(this.startNodeAtNode(node), "function"); - this.next(); - if (this.match(103)) { - this.expectPlugin("functionSent"); - } else if (!this.hasPlugin("functionSent")) { - this.unexpected(); - } - return this.parseMetaProperty(node, meta, "sent"); - } - return this.parseFunction(node); - } - parseMetaProperty(node, meta, propertyName) { - node.meta = meta; - const containsEsc = this.state.containsEsc; - node.property = this.parseIdentifier(true); - if (node.property.name !== propertyName || containsEsc) { - this.raise(Errors.UnsupportedMetaProperty, node.property, { - target: meta.name, - onlyValidPropertyName: propertyName - }); - } - return this.finishNode(node, "MetaProperty"); - } - parseImportMetaProperty(node) { - const id = this.createIdentifier(this.startNodeAtNode(node), "import"); - this.next(); - if (this.isContextual(101)) { - if (!this.inModule) { - this.raise(Errors.ImportMetaOutsideModule, id); - } - this.sawUnambiguousESM = true; - } else if (this.isContextual(105) || this.isContextual(97)) { - const isSource = this.isContextual(105); - if (!isSource) this.unexpected(); - this.expectPlugin(isSource ? "sourcePhaseImports" : "deferredImportEvaluation"); - if (!this.options.createImportExpressions) { - throw this.raise(Errors.DynamicImportPhaseRequiresImportExpressions, this.state.startLoc, { - phase: this.state.value - }); - } - this.next(); - node.phase = isSource ? "source" : "defer"; - return this.parseImportCall(node); - } - return this.parseMetaProperty(node, id, "meta"); - } - parseLiteralAtNode(value, type, node) { - this.addExtra(node, "rawValue", value); - this.addExtra(node, "raw", this.input.slice(node.start, this.state.end)); - node.value = value; - this.next(); - return this.finishNode(node, type); - } - parseLiteral(value, type) { - const node = this.startNode(); - return this.parseLiteralAtNode(value, type, node); - } - parseStringLiteral(value) { - return this.parseLiteral(value, "StringLiteral"); - } - parseNumericLiteral(value) { - return this.parseLiteral(value, "NumericLiteral"); - } - parseBigIntLiteral(value) { - return this.parseLiteral(value, "BigIntLiteral"); - } - parseDecimalLiteral(value) { - return this.parseLiteral(value, "DecimalLiteral"); - } - parseRegExpLiteral(value) { - const node = this.startNode(); - this.addExtra(node, "raw", this.input.slice(node.start, this.state.end)); - node.pattern = value.pattern; - node.flags = value.flags; - this.next(); - return this.finishNode(node, "RegExpLiteral"); - } - parseBooleanLiteral(value) { - const node = this.startNode(); - node.value = value; - this.next(); - return this.finishNode(node, "BooleanLiteral"); - } - parseNullLiteral() { - const node = this.startNode(); - this.next(); - return this.finishNode(node, "NullLiteral"); - } - parseParenAndDistinguishExpression(canBeArrow) { - const startLoc = this.state.startLoc; - let val; - this.next(); - this.expressionScope.enter(newArrowHeadScope()); - const oldMaybeInArrowParameters = this.state.maybeInArrowParameters; - const oldInFSharpPipelineDirectBody = this.state.inFSharpPipelineDirectBody; - this.state.maybeInArrowParameters = true; - this.state.inFSharpPipelineDirectBody = false; - const innerStartLoc = this.state.startLoc; - const exprList = []; - const refExpressionErrors = new ExpressionErrors(); - let first = true; - let spreadStartLoc; - let optionalCommaStartLoc; - while (!this.match(11)) { - if (first) { - first = false; - } else { - this.expect(12, refExpressionErrors.optionalParametersLoc === null ? null : refExpressionErrors.optionalParametersLoc); - if (this.match(11)) { - optionalCommaStartLoc = this.state.startLoc; - break; - } - } - if (this.match(21)) { - const spreadNodeStartLoc = this.state.startLoc; - spreadStartLoc = this.state.startLoc; - exprList.push(this.parseParenItem(this.parseRestBinding(), spreadNodeStartLoc)); - if (!this.checkCommaAfterRest(41)) { - break; - } - } else { - exprList.push(this.parseMaybeAssignAllowIn(refExpressionErrors, this.parseParenItem)); - } - } - const innerEndLoc = this.state.lastTokEndLoc; - this.expect(11); - this.state.maybeInArrowParameters = oldMaybeInArrowParameters; - this.state.inFSharpPipelineDirectBody = oldInFSharpPipelineDirectBody; - let arrowNode = this.startNodeAt(startLoc); - if (canBeArrow && this.shouldParseArrow(exprList) && (arrowNode = this.parseArrow(arrowNode))) { - this.checkDestructuringPrivate(refExpressionErrors); - this.expressionScope.validateAsPattern(); - this.expressionScope.exit(); - this.parseArrowExpression(arrowNode, exprList, false); - return arrowNode; - } - this.expressionScope.exit(); - if (!exprList.length) { - this.unexpected(this.state.lastTokStartLoc); - } - if (optionalCommaStartLoc) this.unexpected(optionalCommaStartLoc); - if (spreadStartLoc) this.unexpected(spreadStartLoc); - this.checkExpressionErrors(refExpressionErrors, true); - this.toReferencedListDeep(exprList, true); - if (exprList.length > 1) { - val = this.startNodeAt(innerStartLoc); - val.expressions = exprList; - this.finishNode(val, "SequenceExpression"); - this.resetEndLocation(val, innerEndLoc); - } else { - val = exprList[0]; - } - return this.wrapParenthesis(startLoc, val); - } - wrapParenthesis(startLoc, expression) { - if (!this.options.createParenthesizedExpressions) { - this.addExtra(expression, "parenthesized", true); - this.addExtra(expression, "parenStart", startLoc.index); - this.takeSurroundingComments(expression, startLoc.index, this.state.lastTokEndLoc.index); - return expression; - } - const parenExpression = this.startNodeAt(startLoc); - parenExpression.expression = expression; - return this.finishNode(parenExpression, "ParenthesizedExpression"); - } - shouldParseArrow(params) { - return !this.canInsertSemicolon(); - } - parseArrow(node) { - if (this.eat(19)) { - return node; - } - } - parseParenItem(node, startLoc) { - return node; - } - parseNewOrNewTarget() { - const node = this.startNode(); - this.next(); - if (this.match(16)) { - const meta = this.createIdentifier(this.startNodeAtNode(node), "new"); - this.next(); - const metaProp = this.parseMetaProperty(node, meta, "target"); - if (!this.scope.inNonArrowFunction && !this.scope.inClass && !this.options.allowNewTargetOutsideFunction) { - this.raise(Errors.UnexpectedNewTarget, metaProp); - } - return metaProp; - } - return this.parseNew(node); - } - parseNew(node) { - this.parseNewCallee(node); - if (this.eat(10)) { - const args = this.parseExprList(11); - this.toReferencedList(args); - node.arguments = args; - } else { - node.arguments = []; - } - return this.finishNode(node, "NewExpression"); - } - parseNewCallee(node) { - const isImport = this.match(83); - const callee = this.parseNoCallExpr(); - node.callee = callee; - if (isImport && (callee.type === "Import" || callee.type === "ImportExpression")) { - this.raise(Errors.ImportCallNotNewExpression, callee); - } - } - parseTemplateElement(isTagged) { - const { - start, - startLoc, - end, - value - } = this.state; - const elemStart = start + 1; - const elem = this.startNodeAt(createPositionWithColumnOffset(startLoc, 1)); - if (value === null) { - if (!isTagged) { - this.raise(Errors.InvalidEscapeSequenceTemplate, createPositionWithColumnOffset(this.state.firstInvalidTemplateEscapePos, 1)); - } - } - const isTail = this.match(24); - const endOffset = isTail ? -1 : -2; - const elemEnd = end + endOffset; - elem.value = { - raw: this.input.slice(elemStart, elemEnd).replace(/\r\n?/g, "\n"), - cooked: value === null ? null : value.slice(1, endOffset) - }; - elem.tail = isTail; - this.next(); - const finishedNode = this.finishNode(elem, "TemplateElement"); - this.resetEndLocation(finishedNode, createPositionWithColumnOffset(this.state.lastTokEndLoc, endOffset)); - return finishedNode; - } - parseTemplate(isTagged) { - const node = this.startNode(); - let curElt = this.parseTemplateElement(isTagged); - const quasis = [curElt]; - const substitutions = []; - while (!curElt.tail) { - substitutions.push(this.parseTemplateSubstitution()); - this.readTemplateContinuation(); - quasis.push(curElt = this.parseTemplateElement(isTagged)); - } - node.expressions = substitutions; - node.quasis = quasis; - return this.finishNode(node, "TemplateLiteral"); - } - parseTemplateSubstitution() { - return this.parseExpression(); - } - parseObjectLike(close, isPattern, isRecord, refExpressionErrors) { - if (isRecord) { - this.expectPlugin("recordAndTuple"); - } - const oldInFSharpPipelineDirectBody = this.state.inFSharpPipelineDirectBody; - this.state.inFSharpPipelineDirectBody = false; - const propHash = Object.create(null); - let first = true; - const node = this.startNode(); - node.properties = []; - this.next(); - while (!this.match(close)) { - if (first) { - first = false; - } else { - this.expect(12); - if (this.match(close)) { - this.addTrailingCommaExtraToNode(node); - break; - } - } - let prop; - if (isPattern) { - prop = this.parseBindingProperty(); - } else { - prop = this.parsePropertyDefinition(refExpressionErrors); - this.checkProto(prop, isRecord, propHash, refExpressionErrors); - } - if (isRecord && !this.isObjectProperty(prop) && prop.type !== "SpreadElement") { - this.raise(Errors.InvalidRecordProperty, prop); - } - { - if (prop.shorthand) { - this.addExtra(prop, "shorthand", true); - } - } - node.properties.push(prop); - } - this.next(); - this.state.inFSharpPipelineDirectBody = oldInFSharpPipelineDirectBody; - let type = "ObjectExpression"; - if (isPattern) { - type = "ObjectPattern"; - } else if (isRecord) { - type = "RecordExpression"; - } - return this.finishNode(node, type); - } - addTrailingCommaExtraToNode(node) { - this.addExtra(node, "trailingComma", this.state.lastTokStartLoc.index); - this.addExtra(node, "trailingCommaLoc", this.state.lastTokStartLoc, false); - } - maybeAsyncOrAccessorProp(prop) { - return !prop.computed && prop.key.type === "Identifier" && (this.isLiteralPropertyName() || this.match(0) || this.match(55)); - } - parsePropertyDefinition(refExpressionErrors) { - let decorators = []; - if (this.match(26)) { - if (this.hasPlugin("decorators")) { - this.raise(Errors.UnsupportedPropertyDecorator, this.state.startLoc); - } - while (this.match(26)) { - decorators.push(this.parseDecorator()); - } - } - const prop = this.startNode(); - let isAsync = false; - let isAccessor = false; - let startLoc; - if (this.match(21)) { - if (decorators.length) this.unexpected(); - return this.parseSpread(); - } - if (decorators.length) { - prop.decorators = decorators; - decorators = []; - } - prop.method = false; - if (refExpressionErrors) { - startLoc = this.state.startLoc; - } - let isGenerator = this.eat(55); - this.parsePropertyNamePrefixOperator(prop); - const containsEsc = this.state.containsEsc; - this.parsePropertyName(prop, refExpressionErrors); - if (!isGenerator && !containsEsc && this.maybeAsyncOrAccessorProp(prop)) { - const { - key - } = prop; - const keyName = key.name; - if (keyName === "async" && !this.hasPrecedingLineBreak()) { - isAsync = true; - this.resetPreviousNodeTrailingComments(key); - isGenerator = this.eat(55); - this.parsePropertyName(prop); - } - if (keyName === "get" || keyName === "set") { - isAccessor = true; - this.resetPreviousNodeTrailingComments(key); - prop.kind = keyName; - if (this.match(55)) { - isGenerator = true; - this.raise(Errors.AccessorIsGenerator, this.state.curPosition(), { - kind: keyName - }); - this.next(); - } - this.parsePropertyName(prop); - } - } - return this.parseObjPropValue(prop, startLoc, isGenerator, isAsync, false, isAccessor, refExpressionErrors); - } - getGetterSetterExpectedParamCount(method) { - return method.kind === "get" ? 0 : 1; - } - getObjectOrClassMethodParams(method) { - return method.params; - } - checkGetterSetterParams(method) { - var _params; - const paramCount = this.getGetterSetterExpectedParamCount(method); - const params = this.getObjectOrClassMethodParams(method); - if (params.length !== paramCount) { - this.raise(method.kind === "get" ? Errors.BadGetterArity : Errors.BadSetterArity, method); - } - if (method.kind === "set" && ((_params = params[params.length - 1]) == null ? void 0 : _params.type) === "RestElement") { - this.raise(Errors.BadSetterRestParameter, method); - } - } - parseObjectMethod(prop, isGenerator, isAsync, isPattern, isAccessor) { - if (isAccessor) { - const finishedProp = this.parseMethod(prop, isGenerator, false, false, false, "ObjectMethod"); - this.checkGetterSetterParams(finishedProp); - return finishedProp; - } - if (isAsync || isGenerator || this.match(10)) { - if (isPattern) this.unexpected(); - prop.kind = "method"; - prop.method = true; - return this.parseMethod(prop, isGenerator, isAsync, false, false, "ObjectMethod"); - } - } - parseObjectProperty(prop, startLoc, isPattern, refExpressionErrors) { - prop.shorthand = false; - if (this.eat(14)) { - prop.value = isPattern ? this.parseMaybeDefault(this.state.startLoc) : this.parseMaybeAssignAllowIn(refExpressionErrors); - return this.finishNode(prop, "ObjectProperty"); - } - if (!prop.computed && prop.key.type === "Identifier") { - this.checkReservedWord(prop.key.name, prop.key.loc.start, true, false); - if (isPattern) { - prop.value = this.parseMaybeDefault(startLoc, cloneIdentifier(prop.key)); - } else if (this.match(29)) { - const shorthandAssignLoc = this.state.startLoc; - if (refExpressionErrors != null) { - if (refExpressionErrors.shorthandAssignLoc === null) { - refExpressionErrors.shorthandAssignLoc = shorthandAssignLoc; - } - } else { - this.raise(Errors.InvalidCoverInitializedName, shorthandAssignLoc); - } - prop.value = this.parseMaybeDefault(startLoc, cloneIdentifier(prop.key)); - } else { - prop.value = cloneIdentifier(prop.key); - } - prop.shorthand = true; - return this.finishNode(prop, "ObjectProperty"); - } - } - parseObjPropValue(prop, startLoc, isGenerator, isAsync, isPattern, isAccessor, refExpressionErrors) { - const node = this.parseObjectMethod(prop, isGenerator, isAsync, isPattern, isAccessor) || this.parseObjectProperty(prop, startLoc, isPattern, refExpressionErrors); - if (!node) this.unexpected(); - return node; - } - parsePropertyName(prop, refExpressionErrors) { - if (this.eat(0)) { - prop.computed = true; - prop.key = this.parseMaybeAssignAllowIn(); - this.expect(3); - } else { - const { - type, - value - } = this.state; - let key; - if (tokenIsKeywordOrIdentifier(type)) { - key = this.parseIdentifier(true); - } else { - switch (type) { - case 134: - key = this.parseNumericLiteral(value); - break; - case 133: - key = this.parseStringLiteral(value); - break; - case 135: - key = this.parseBigIntLiteral(value); - break; - case 136: - key = this.parseDecimalLiteral(value); - break; - case 138: - { - const privateKeyLoc = this.state.startLoc; - if (refExpressionErrors != null) { - if (refExpressionErrors.privateKeyLoc === null) { - refExpressionErrors.privateKeyLoc = privateKeyLoc; - } - } else { - this.raise(Errors.UnexpectedPrivateField, privateKeyLoc); - } - key = this.parsePrivateName(); - break; - } - default: - this.unexpected(); - } - } - prop.key = key; - if (type !== 138) { - prop.computed = false; - } - } - } - initFunction(node, isAsync) { - node.id = null; - node.generator = false; - node.async = isAsync; - } - parseMethod(node, isGenerator, isAsync, isConstructor, allowDirectSuper, type, inClassScope = false) { - this.initFunction(node, isAsync); - node.generator = isGenerator; - this.scope.enter(2 | 16 | (inClassScope ? 64 : 0) | (allowDirectSuper ? 32 : 0)); - this.prodParam.enter(functionFlags(isAsync, node.generator)); - this.parseFunctionParams(node, isConstructor); - const finishedNode = this.parseFunctionBodyAndFinish(node, type, true); - this.prodParam.exit(); - this.scope.exit(); - return finishedNode; - } - parseArrayLike(close, canBePattern, isTuple, refExpressionErrors) { - if (isTuple) { - this.expectPlugin("recordAndTuple"); - } - const oldInFSharpPipelineDirectBody = this.state.inFSharpPipelineDirectBody; - this.state.inFSharpPipelineDirectBody = false; - const node = this.startNode(); - this.next(); - node.elements = this.parseExprList(close, !isTuple, refExpressionErrors, node); - this.state.inFSharpPipelineDirectBody = oldInFSharpPipelineDirectBody; - return this.finishNode(node, isTuple ? "TupleExpression" : "ArrayExpression"); - } - parseArrowExpression(node, params, isAsync, trailingCommaLoc) { - this.scope.enter(2 | 4); - let flags = functionFlags(isAsync, false); - if (!this.match(5) && this.prodParam.hasIn) { - flags |= 8; - } - this.prodParam.enter(flags); - this.initFunction(node, isAsync); - const oldMaybeInArrowParameters = this.state.maybeInArrowParameters; - if (params) { - this.state.maybeInArrowParameters = true; - this.setArrowFunctionParameters(node, params, trailingCommaLoc); - } - this.state.maybeInArrowParameters = false; - this.parseFunctionBody(node, true); - this.prodParam.exit(); - this.scope.exit(); - this.state.maybeInArrowParameters = oldMaybeInArrowParameters; - return this.finishNode(node, "ArrowFunctionExpression"); - } - setArrowFunctionParameters(node, params, trailingCommaLoc) { - this.toAssignableList(params, trailingCommaLoc, false); - node.params = params; - } - parseFunctionBodyAndFinish(node, type, isMethod = false) { - this.parseFunctionBody(node, false, isMethod); - return this.finishNode(node, type); - } - parseFunctionBody(node, allowExpression, isMethod = false) { - const isExpression = allowExpression && !this.match(5); - this.expressionScope.enter(newExpressionScope()); - if (isExpression) { - node.body = this.parseMaybeAssign(); - this.checkParams(node, false, allowExpression, false); - } else { - const oldStrict = this.state.strict; - const oldLabels = this.state.labels; - this.state.labels = []; - this.prodParam.enter(this.prodParam.currentFlags() | 4); - node.body = this.parseBlock(true, false, hasStrictModeDirective => { - const nonSimple = !this.isSimpleParamList(node.params); - if (hasStrictModeDirective && nonSimple) { - this.raise(Errors.IllegalLanguageModeDirective, (node.kind === "method" || node.kind === "constructor") && !!node.key ? node.key.loc.end : node); - } - const strictModeChanged = !oldStrict && this.state.strict; - this.checkParams(node, !this.state.strict && !allowExpression && !isMethod && !nonSimple, allowExpression, strictModeChanged); - if (this.state.strict && node.id) { - this.checkIdentifier(node.id, 65, strictModeChanged); - } - }); - this.prodParam.exit(); - this.state.labels = oldLabels; - } - this.expressionScope.exit(); - } - isSimpleParameter(node) { - return node.type === "Identifier"; - } - isSimpleParamList(params) { - for (let i = 0, len = params.length; i < len; i++) { - if (!this.isSimpleParameter(params[i])) return false; - } - return true; - } - checkParams(node, allowDuplicates, isArrowFunction, strictModeChanged = true) { - const checkClashes = !allowDuplicates && new Set(); - const formalParameters = { - type: "FormalParameters" - }; - for (const param of node.params) { - this.checkLVal(param, { - in: formalParameters, - binding: 5, - checkClashes, - strictModeChanged - }); - } - } - parseExprList(close, allowEmpty, refExpressionErrors, nodeForExtra) { - const elts = []; - let first = true; - while (!this.eat(close)) { - if (first) { - first = false; - } else { - this.expect(12); - if (this.match(close)) { - if (nodeForExtra) { - this.addTrailingCommaExtraToNode(nodeForExtra); - } - this.next(); - break; - } - } - elts.push(this.parseExprListItem(allowEmpty, refExpressionErrors)); - } - return elts; - } - parseExprListItem(allowEmpty, refExpressionErrors, allowPlaceholder) { - let elt; - if (this.match(12)) { - if (!allowEmpty) { - this.raise(Errors.UnexpectedToken, this.state.curPosition(), { - unexpected: "," - }); - } - elt = null; - } else if (this.match(21)) { - const spreadNodeStartLoc = this.state.startLoc; - elt = this.parseParenItem(this.parseSpread(refExpressionErrors), spreadNodeStartLoc); - } else if (this.match(17)) { - this.expectPlugin("partialApplication"); - if (!allowPlaceholder) { - this.raise(Errors.UnexpectedArgumentPlaceholder, this.state.startLoc); - } - const node = this.startNode(); - this.next(); - elt = this.finishNode(node, "ArgumentPlaceholder"); - } else { - elt = this.parseMaybeAssignAllowIn(refExpressionErrors, this.parseParenItem); - } - return elt; - } - parseIdentifier(liberal) { - const node = this.startNode(); - const name = this.parseIdentifierName(liberal); - return this.createIdentifier(node, name); - } - createIdentifier(node, name) { - node.name = name; - node.loc.identifierName = name; - return this.finishNode(node, "Identifier"); - } - parseIdentifierName(liberal) { - let name; - const { - startLoc, - type - } = this.state; - if (tokenIsKeywordOrIdentifier(type)) { - name = this.state.value; - } else { - this.unexpected(); - } - const tokenIsKeyword = tokenKeywordOrIdentifierIsKeyword(type); - if (liberal) { - if (tokenIsKeyword) { - this.replaceToken(132); - } - } else { - this.checkReservedWord(name, startLoc, tokenIsKeyword, false); - } - this.next(); - return name; - } - checkReservedWord(word, startLoc, checkKeywords, isBinding) { - if (word.length > 10) { - return; - } - if (!canBeReservedWord(word)) { - return; - } - if (checkKeywords && isKeyword(word)) { - this.raise(Errors.UnexpectedKeyword, startLoc, { - keyword: word - }); - return; - } - const reservedTest = !this.state.strict ? isReservedWord : isBinding ? isStrictBindReservedWord : isStrictReservedWord; - if (reservedTest(word, this.inModule)) { - this.raise(Errors.UnexpectedReservedWord, startLoc, { - reservedWord: word - }); - return; - } else if (word === "yield") { - if (this.prodParam.hasYield) { - this.raise(Errors.YieldBindingIdentifier, startLoc); - return; - } - } else if (word === "await") { - if (this.prodParam.hasAwait) { - this.raise(Errors.AwaitBindingIdentifier, startLoc); - return; - } - if (this.scope.inStaticBlock) { - this.raise(Errors.AwaitBindingIdentifierInStaticBlock, startLoc); - return; - } - this.expressionScope.recordAsyncArrowParametersError(startLoc); - } else if (word === "arguments") { - if (this.scope.inClassAndNotInNonArrowFunction) { - this.raise(Errors.ArgumentsInClass, startLoc); - return; - } - } - } - isAwaitAllowed() { - if (this.prodParam.hasAwait) return true; - if (this.options.allowAwaitOutsideFunction && !this.scope.inFunction) { - return true; - } - return false; - } - parseAwait(startLoc) { - const node = this.startNodeAt(startLoc); - this.expressionScope.recordParameterInitializerError(Errors.AwaitExpressionFormalParameter, node); - if (this.eat(55)) { - this.raise(Errors.ObsoleteAwaitStar, node); - } - if (!this.scope.inFunction && !this.options.allowAwaitOutsideFunction) { - if (this.isAmbiguousAwait()) { - this.ambiguousScriptDifferentAst = true; - } else { - this.sawUnambiguousESM = true; - } - } - if (!this.state.soloAwait) { - node.argument = this.parseMaybeUnary(null, true); - } - return this.finishNode(node, "AwaitExpression"); - } - isAmbiguousAwait() { - if (this.hasPrecedingLineBreak()) return true; - const { - type - } = this.state; - return type === 53 || type === 10 || type === 0 || tokenIsTemplate(type) || type === 102 && !this.state.containsEsc || type === 137 || type === 56 || this.hasPlugin("v8intrinsic") && type === 54; - } - parseYield() { - const node = this.startNode(); - this.expressionScope.recordParameterInitializerError(Errors.YieldInParameter, node); - this.next(); - let delegating = false; - let argument = null; - if (!this.hasPrecedingLineBreak()) { - delegating = this.eat(55); - switch (this.state.type) { - case 13: - case 139: - case 8: - case 11: - case 3: - case 9: - case 14: - case 12: - if (!delegating) break; - default: - argument = this.parseMaybeAssign(); - } - } - node.delegate = delegating; - node.argument = argument; - return this.finishNode(node, "YieldExpression"); - } - parseImportCall(node) { - this.next(); - node.source = this.parseMaybeAssignAllowIn(); - if (this.hasPlugin("importAttributes") || this.hasPlugin("importAssertions")) { - node.options = null; - } - if (this.eat(12)) { - this.expectImportAttributesPlugin(); - if (!this.match(11)) { - node.options = this.parseMaybeAssignAllowIn(); - this.eat(12); - } - } - this.expect(11); - return this.finishNode(node, "ImportExpression"); - } - checkPipelineAtInfixOperator(left, leftStartLoc) { - if (this.hasPlugin(["pipelineOperator", { - proposal: "smart" - }])) { - if (left.type === "SequenceExpression") { - this.raise(Errors.PipelineHeadSequenceExpression, leftStartLoc); - } - } - } - parseSmartPipelineBodyInStyle(childExpr, startLoc) { - if (this.isSimpleReference(childExpr)) { - const bodyNode = this.startNodeAt(startLoc); - bodyNode.callee = childExpr; - return this.finishNode(bodyNode, "PipelineBareFunction"); - } else { - const bodyNode = this.startNodeAt(startLoc); - this.checkSmartPipeTopicBodyEarlyErrors(startLoc); - bodyNode.expression = childExpr; - return this.finishNode(bodyNode, "PipelineTopicExpression"); - } - } - isSimpleReference(expression) { - switch (expression.type) { - case "MemberExpression": - return !expression.computed && this.isSimpleReference(expression.object); - case "Identifier": - return true; - default: - return false; - } - } - checkSmartPipeTopicBodyEarlyErrors(startLoc) { - if (this.match(19)) { - throw this.raise(Errors.PipelineBodyNoArrow, this.state.startLoc); - } - if (!this.topicReferenceWasUsedInCurrentContext()) { - this.raise(Errors.PipelineTopicUnused, startLoc); - } - } - withTopicBindingContext(callback) { - const outerContextTopicState = this.state.topicContext; - this.state.topicContext = { - maxNumOfResolvableTopics: 1, - maxTopicIndex: null - }; - try { - return callback(); - } finally { - this.state.topicContext = outerContextTopicState; - } - } - withSmartMixTopicForbiddingContext(callback) { - if (this.hasPlugin(["pipelineOperator", { - proposal: "smart" - }])) { - const outerContextTopicState = this.state.topicContext; - this.state.topicContext = { - maxNumOfResolvableTopics: 0, - maxTopicIndex: null - }; - try { - return callback(); - } finally { - this.state.topicContext = outerContextTopicState; - } - } else { - return callback(); - } - } - withSoloAwaitPermittingContext(callback) { - const outerContextSoloAwaitState = this.state.soloAwait; - this.state.soloAwait = true; - try { - return callback(); - } finally { - this.state.soloAwait = outerContextSoloAwaitState; - } - } - allowInAnd(callback) { - const flags = this.prodParam.currentFlags(); - const prodParamToSet = 8 & ~flags; - if (prodParamToSet) { - this.prodParam.enter(flags | 8); - try { - return callback(); - } finally { - this.prodParam.exit(); - } - } - return callback(); - } - disallowInAnd(callback) { - const flags = this.prodParam.currentFlags(); - const prodParamToClear = 8 & flags; - if (prodParamToClear) { - this.prodParam.enter(flags & ~8); - try { - return callback(); - } finally { - this.prodParam.exit(); - } - } - return callback(); - } - registerTopicReference() { - this.state.topicContext.maxTopicIndex = 0; - } - topicReferenceIsAllowedInCurrentContext() { - return this.state.topicContext.maxNumOfResolvableTopics >= 1; - } - topicReferenceWasUsedInCurrentContext() { - return this.state.topicContext.maxTopicIndex != null && this.state.topicContext.maxTopicIndex >= 0; - } - parseFSharpPipelineBody(prec) { - const startLoc = this.state.startLoc; - this.state.potentialArrowAt = this.state.start; - const oldInFSharpPipelineDirectBody = this.state.inFSharpPipelineDirectBody; - this.state.inFSharpPipelineDirectBody = true; - const ret = this.parseExprOp(this.parseMaybeUnaryOrPrivate(), startLoc, prec); - this.state.inFSharpPipelineDirectBody = oldInFSharpPipelineDirectBody; - return ret; - } - parseModuleExpression() { - this.expectPlugin("moduleBlocks"); - const node = this.startNode(); - this.next(); - if (!this.match(5)) { - this.unexpected(null, 5); - } - const program = this.startNodeAt(this.state.endLoc); - this.next(); - const revertScopes = this.initializeScopes(true); - this.enterInitialScopes(); - try { - node.body = this.parseProgram(program, 8, "module"); - } finally { - revertScopes(); - } - return this.finishNode(node, "ModuleExpression"); - } - parsePropertyNamePrefixOperator(prop) {} -} -const loopLabel = { - kind: 1 - }, - switchLabel = { - kind: 2 - }; -const loneSurrogate = /[\uD800-\uDFFF]/u; -const keywordRelationalOperator = /in(?:stanceof)?/y; -function babel7CompatTokens(tokens, input) { - for (let i = 0; i < tokens.length; i++) { - const token = tokens[i]; - const { - type - } = token; - if (typeof type === "number") { - { - if (type === 138) { - const { - loc, - start, - value, - end - } = token; - const hashEndPos = start + 1; - const hashEndLoc = createPositionWithColumnOffset(loc.start, 1); - tokens.splice(i, 1, new Token({ - type: getExportedToken(27), - value: "#", - start: start, - end: hashEndPos, - startLoc: loc.start, - endLoc: hashEndLoc - }), new Token({ - type: getExportedToken(132), - value: value, - start: hashEndPos, - end: end, - startLoc: hashEndLoc, - endLoc: loc.end - })); - i++; - continue; - } - if (tokenIsTemplate(type)) { - const { - loc, - start, - value, - end - } = token; - const backquoteEnd = start + 1; - const backquoteEndLoc = createPositionWithColumnOffset(loc.start, 1); - let startToken; - if (input.charCodeAt(start) === 96) { - startToken = new Token({ - type: getExportedToken(22), - value: "`", - start: start, - end: backquoteEnd, - startLoc: loc.start, - endLoc: backquoteEndLoc - }); - } else { - startToken = new Token({ - type: getExportedToken(8), - value: "}", - start: start, - end: backquoteEnd, - startLoc: loc.start, - endLoc: backquoteEndLoc - }); - } - let templateValue, templateElementEnd, templateElementEndLoc, endToken; - if (type === 24) { - templateElementEnd = end - 1; - templateElementEndLoc = createPositionWithColumnOffset(loc.end, -1); - templateValue = value === null ? null : value.slice(1, -1); - endToken = new Token({ - type: getExportedToken(22), - value: "`", - start: templateElementEnd, - end: end, - startLoc: templateElementEndLoc, - endLoc: loc.end - }); - } else { - templateElementEnd = end - 2; - templateElementEndLoc = createPositionWithColumnOffset(loc.end, -2); - templateValue = value === null ? null : value.slice(1, -2); - endToken = new Token({ - type: getExportedToken(23), - value: "${", - start: templateElementEnd, - end: end, - startLoc: templateElementEndLoc, - endLoc: loc.end - }); - } - tokens.splice(i, 1, startToken, new Token({ - type: getExportedToken(20), - value: templateValue, - start: backquoteEnd, - end: templateElementEnd, - startLoc: backquoteEndLoc, - endLoc: templateElementEndLoc - }), endToken); - i += 2; - continue; - } - } - token.type = getExportedToken(type); - } - } - return tokens; -} -class StatementParser extends ExpressionParser { - parseTopLevel(file, program) { - file.program = this.parseProgram(program); - file.comments = this.comments; - if (this.options.tokens) { - file.tokens = babel7CompatTokens(this.tokens, this.input); - } - return this.finishNode(file, "File"); - } - parseProgram(program, end = 139, sourceType = this.options.sourceType) { - program.sourceType = sourceType; - program.interpreter = this.parseInterpreterDirective(); - this.parseBlockBody(program, true, true, end); - if (this.inModule && !this.options.allowUndeclaredExports && this.scope.undefinedExports.size > 0) { - for (const [localName, at] of Array.from(this.scope.undefinedExports)) { - this.raise(Errors.ModuleExportUndefined, at, { - localName - }); - } - } - let finishedProgram; - if (end === 139) { - finishedProgram = this.finishNode(program, "Program"); - } else { - finishedProgram = this.finishNodeAt(program, "Program", createPositionWithColumnOffset(this.state.startLoc, -1)); - } - return finishedProgram; - } - stmtToDirective(stmt) { - const directive = stmt; - directive.type = "Directive"; - directive.value = directive.expression; - delete directive.expression; - const directiveLiteral = directive.value; - const expressionValue = directiveLiteral.value; - const raw = this.input.slice(directiveLiteral.start, directiveLiteral.end); - const val = directiveLiteral.value = raw.slice(1, -1); - this.addExtra(directiveLiteral, "raw", raw); - this.addExtra(directiveLiteral, "rawValue", val); - this.addExtra(directiveLiteral, "expressionValue", expressionValue); - directiveLiteral.type = "DirectiveLiteral"; - return directive; - } - parseInterpreterDirective() { - if (!this.match(28)) { - return null; - } - const node = this.startNode(); - node.value = this.state.value; - this.next(); - return this.finishNode(node, "InterpreterDirective"); - } - isLet() { - if (!this.isContextual(100)) { - return false; - } - return this.hasFollowingBindingAtom(); - } - chStartsBindingIdentifier(ch, pos) { - if (isIdentifierStart(ch)) { - keywordRelationalOperator.lastIndex = pos; - if (keywordRelationalOperator.test(this.input)) { - const endCh = this.codePointAtPos(keywordRelationalOperator.lastIndex); - if (!isIdentifierChar(endCh) && endCh !== 92) { - return false; - } - } - return true; - } else if (ch === 92) { - return true; - } else { - return false; - } - } - chStartsBindingPattern(ch) { - return ch === 91 || ch === 123; - } - hasFollowingBindingAtom() { - const next = this.nextTokenStart(); - const nextCh = this.codePointAtPos(next); - return this.chStartsBindingPattern(nextCh) || this.chStartsBindingIdentifier(nextCh, next); - } - hasInLineFollowingBindingIdentifierOrBrace() { - const next = this.nextTokenInLineStart(); - const nextCh = this.codePointAtPos(next); - return nextCh === 123 || this.chStartsBindingIdentifier(nextCh, next); - } - startsUsingForOf() { - const { - type, - containsEsc - } = this.lookahead(); - if (type === 102 && !containsEsc) { - return false; - } else if (tokenIsIdentifier(type) && !this.hasFollowingLineBreak()) { - this.expectPlugin("explicitResourceManagement"); - return true; - } - } - startsAwaitUsing() { - let next = this.nextTokenInLineStart(); - if (this.isUnparsedContextual(next, "using")) { - next = this.nextTokenInLineStartSince(next + 5); - const nextCh = this.codePointAtPos(next); - if (this.chStartsBindingIdentifier(nextCh, next)) { - this.expectPlugin("explicitResourceManagement"); - return true; - } - } - return false; - } - parseModuleItem() { - return this.parseStatementLike(1 | 2 | 4 | 8); - } - parseStatementListItem() { - return this.parseStatementLike(2 | 4 | (!this.options.annexB || this.state.strict ? 0 : 8)); - } - parseStatementOrSloppyAnnexBFunctionDeclaration(allowLabeledFunction = false) { - let flags = 0; - if (this.options.annexB && !this.state.strict) { - flags |= 4; - if (allowLabeledFunction) { - flags |= 8; - } - } - return this.parseStatementLike(flags); - } - parseStatement() { - return this.parseStatementLike(0); - } - parseStatementLike(flags) { - let decorators = null; - if (this.match(26)) { - decorators = this.parseDecorators(true); - } - return this.parseStatementContent(flags, decorators); - } - parseStatementContent(flags, decorators) { - const starttype = this.state.type; - const node = this.startNode(); - const allowDeclaration = !!(flags & 2); - const allowFunctionDeclaration = !!(flags & 4); - const topLevel = flags & 1; - switch (starttype) { - case 60: - return this.parseBreakContinueStatement(node, true); - case 63: - return this.parseBreakContinueStatement(node, false); - case 64: - return this.parseDebuggerStatement(node); - case 90: - return this.parseDoWhileStatement(node); - case 91: - return this.parseForStatement(node); - case 68: - if (this.lookaheadCharCode() === 46) break; - if (!allowFunctionDeclaration) { - this.raise(this.state.strict ? Errors.StrictFunction : this.options.annexB ? Errors.SloppyFunctionAnnexB : Errors.SloppyFunction, this.state.startLoc); - } - return this.parseFunctionStatement(node, false, !allowDeclaration && allowFunctionDeclaration); - case 80: - if (!allowDeclaration) this.unexpected(); - return this.parseClass(this.maybeTakeDecorators(decorators, node), true); - case 69: - return this.parseIfStatement(node); - case 70: - return this.parseReturnStatement(node); - case 71: - return this.parseSwitchStatement(node); - case 72: - return this.parseThrowStatement(node); - case 73: - return this.parseTryStatement(node); - case 96: - if (!this.state.containsEsc && this.startsAwaitUsing()) { - if (!this.isAwaitAllowed()) { - this.raise(Errors.AwaitUsingNotInAsyncContext, node); - } else if (!allowDeclaration) { - this.raise(Errors.UnexpectedLexicalDeclaration, node); - } - this.next(); - return this.parseVarStatement(node, "await using"); - } - break; - case 107: - if (this.state.containsEsc || !this.hasInLineFollowingBindingIdentifierOrBrace()) { - break; - } - this.expectPlugin("explicitResourceManagement"); - if (!this.scope.inModule && this.scope.inTopLevel) { - this.raise(Errors.UnexpectedUsingDeclaration, this.state.startLoc); - } else if (!allowDeclaration) { - this.raise(Errors.UnexpectedLexicalDeclaration, this.state.startLoc); - } - return this.parseVarStatement(node, "using"); - case 100: - { - if (this.state.containsEsc) { - break; - } - const next = this.nextTokenStart(); - const nextCh = this.codePointAtPos(next); - if (nextCh !== 91) { - if (!allowDeclaration && this.hasFollowingLineBreak()) break; - if (!this.chStartsBindingIdentifier(nextCh, next) && nextCh !== 123) { - break; - } - } - } - case 75: - { - if (!allowDeclaration) { - this.raise(Errors.UnexpectedLexicalDeclaration, this.state.startLoc); - } - } - case 74: - { - const kind = this.state.value; - return this.parseVarStatement(node, kind); - } - case 92: - return this.parseWhileStatement(node); - case 76: - return this.parseWithStatement(node); - case 5: - return this.parseBlock(); - case 13: - return this.parseEmptyStatement(node); - case 83: - { - const nextTokenCharCode = this.lookaheadCharCode(); - if (nextTokenCharCode === 40 || nextTokenCharCode === 46) { - break; - } - } - case 82: - { - if (!this.options.allowImportExportEverywhere && !topLevel) { - this.raise(Errors.UnexpectedImportExport, this.state.startLoc); - } - this.next(); - let result; - if (starttype === 83) { - result = this.parseImport(node); - if (result.type === "ImportDeclaration" && (!result.importKind || result.importKind === "value")) { - this.sawUnambiguousESM = true; - } - } else { - result = this.parseExport(node, decorators); - if (result.type === "ExportNamedDeclaration" && (!result.exportKind || result.exportKind === "value") || result.type === "ExportAllDeclaration" && (!result.exportKind || result.exportKind === "value") || result.type === "ExportDefaultDeclaration") { - this.sawUnambiguousESM = true; - } - } - this.assertModuleNodeAllowed(result); - return result; - } - default: - { - if (this.isAsyncFunction()) { - if (!allowDeclaration) { - this.raise(Errors.AsyncFunctionInSingleStatementContext, this.state.startLoc); - } - this.next(); - return this.parseFunctionStatement(node, true, !allowDeclaration && allowFunctionDeclaration); - } - } - } - const maybeName = this.state.value; - const expr = this.parseExpression(); - if (tokenIsIdentifier(starttype) && expr.type === "Identifier" && this.eat(14)) { - return this.parseLabeledStatement(node, maybeName, expr, flags); - } else { - return this.parseExpressionStatement(node, expr, decorators); - } - } - assertModuleNodeAllowed(node) { - if (!this.options.allowImportExportEverywhere && !this.inModule) { - this.raise(Errors.ImportOutsideModule, node); - } - } - decoratorsEnabledBeforeExport() { - if (this.hasPlugin("decorators-legacy")) return true; - return this.hasPlugin("decorators") && this.getPluginOption("decorators", "decoratorsBeforeExport") !== false; - } - maybeTakeDecorators(maybeDecorators, classNode, exportNode) { - if (maybeDecorators) { - if (classNode.decorators && classNode.decorators.length > 0) { - if (typeof this.getPluginOption("decorators", "decoratorsBeforeExport") !== "boolean") { - this.raise(Errors.DecoratorsBeforeAfterExport, classNode.decorators[0]); - } - classNode.decorators.unshift(...maybeDecorators); - } else { - classNode.decorators = maybeDecorators; - } - this.resetStartLocationFromNode(classNode, maybeDecorators[0]); - if (exportNode) this.resetStartLocationFromNode(exportNode, classNode); - } - return classNode; - } - canHaveLeadingDecorator() { - return this.match(80); - } - parseDecorators(allowExport) { - const decorators = []; - do { - decorators.push(this.parseDecorator()); - } while (this.match(26)); - if (this.match(82)) { - if (!allowExport) { - this.unexpected(); - } - if (!this.decoratorsEnabledBeforeExport()) { - this.raise(Errors.DecoratorExportClass, this.state.startLoc); - } - } else if (!this.canHaveLeadingDecorator()) { - throw this.raise(Errors.UnexpectedLeadingDecorator, this.state.startLoc); - } - return decorators; - } - parseDecorator() { - this.expectOnePlugin(["decorators", "decorators-legacy"]); - const node = this.startNode(); - this.next(); - if (this.hasPlugin("decorators")) { - const startLoc = this.state.startLoc; - let expr; - if (this.match(10)) { - const startLoc = this.state.startLoc; - this.next(); - expr = this.parseExpression(); - this.expect(11); - expr = this.wrapParenthesis(startLoc, expr); - const paramsStartLoc = this.state.startLoc; - node.expression = this.parseMaybeDecoratorArguments(expr); - if (this.getPluginOption("decorators", "allowCallParenthesized") === false && node.expression !== expr) { - this.raise(Errors.DecoratorArgumentsOutsideParentheses, paramsStartLoc); - } - } else { - expr = this.parseIdentifier(false); - while (this.eat(16)) { - const node = this.startNodeAt(startLoc); - node.object = expr; - if (this.match(138)) { - this.classScope.usePrivateName(this.state.value, this.state.startLoc); - node.property = this.parsePrivateName(); - } else { - node.property = this.parseIdentifier(true); - } - node.computed = false; - expr = this.finishNode(node, "MemberExpression"); - } - node.expression = this.parseMaybeDecoratorArguments(expr); - } - } else { - node.expression = this.parseExprSubscripts(); - } - return this.finishNode(node, "Decorator"); - } - parseMaybeDecoratorArguments(expr) { - if (this.eat(10)) { - const node = this.startNodeAtNode(expr); - node.callee = expr; - node.arguments = this.parseCallExpressionArguments(11, false); - this.toReferencedList(node.arguments); - return this.finishNode(node, "CallExpression"); - } - return expr; - } - parseBreakContinueStatement(node, isBreak) { - this.next(); - if (this.isLineTerminator()) { - node.label = null; - } else { - node.label = this.parseIdentifier(); - this.semicolon(); - } - this.verifyBreakContinue(node, isBreak); - return this.finishNode(node, isBreak ? "BreakStatement" : "ContinueStatement"); - } - verifyBreakContinue(node, isBreak) { - let i; - for (i = 0; i < this.state.labels.length; ++i) { - const lab = this.state.labels[i]; - if (node.label == null || lab.name === node.label.name) { - if (lab.kind != null && (isBreak || lab.kind === 1)) { - break; - } - if (node.label && isBreak) break; - } - } - if (i === this.state.labels.length) { - const type = isBreak ? "BreakStatement" : "ContinueStatement"; - this.raise(Errors.IllegalBreakContinue, node, { - type - }); - } - } - parseDebuggerStatement(node) { - this.next(); - this.semicolon(); - return this.finishNode(node, "DebuggerStatement"); - } - parseHeaderExpression() { - this.expect(10); - const val = this.parseExpression(); - this.expect(11); - return val; - } - parseDoWhileStatement(node) { - this.next(); - this.state.labels.push(loopLabel); - node.body = this.withSmartMixTopicForbiddingContext(() => this.parseStatement()); - this.state.labels.pop(); - this.expect(92); - node.test = this.parseHeaderExpression(); - this.eat(13); - return this.finishNode(node, "DoWhileStatement"); - } - parseForStatement(node) { - this.next(); - this.state.labels.push(loopLabel); - let awaitAt = null; - if (this.isAwaitAllowed() && this.eatContextual(96)) { - awaitAt = this.state.lastTokStartLoc; - } - this.scope.enter(0); - this.expect(10); - if (this.match(13)) { - if (awaitAt !== null) { - this.unexpected(awaitAt); - } - return this.parseFor(node, null); - } - const startsWithLet = this.isContextual(100); - { - const startsWithAwaitUsing = this.isContextual(96) && this.startsAwaitUsing(); - const starsWithUsingDeclaration = startsWithAwaitUsing || this.isContextual(107) && this.startsUsingForOf(); - const isLetOrUsing = startsWithLet && this.hasFollowingBindingAtom() || starsWithUsingDeclaration; - if (this.match(74) || this.match(75) || isLetOrUsing) { - const initNode = this.startNode(); - let kind; - if (startsWithAwaitUsing) { - kind = "await using"; - if (!this.isAwaitAllowed()) { - this.raise(Errors.AwaitUsingNotInAsyncContext, this.state.startLoc); - } - this.next(); - } else { - kind = this.state.value; - } - this.next(); - this.parseVar(initNode, true, kind); - const init = this.finishNode(initNode, "VariableDeclaration"); - const isForIn = this.match(58); - if (isForIn && starsWithUsingDeclaration) { - this.raise(Errors.ForInUsing, init); - } - if ((isForIn || this.isContextual(102)) && init.declarations.length === 1) { - return this.parseForIn(node, init, awaitAt); - } - if (awaitAt !== null) { - this.unexpected(awaitAt); - } - return this.parseFor(node, init); - } - } - const startsWithAsync = this.isContextual(95); - const refExpressionErrors = new ExpressionErrors(); - const init = this.parseExpression(true, refExpressionErrors); - const isForOf = this.isContextual(102); - if (isForOf) { - if (startsWithLet) { - this.raise(Errors.ForOfLet, init); - } - if (awaitAt === null && startsWithAsync && init.type === "Identifier") { - this.raise(Errors.ForOfAsync, init); - } - } - if (isForOf || this.match(58)) { - this.checkDestructuringPrivate(refExpressionErrors); - this.toAssignable(init, true); - const type = isForOf ? "ForOfStatement" : "ForInStatement"; - this.checkLVal(init, { - in: { - type - } - }); - return this.parseForIn(node, init, awaitAt); - } else { - this.checkExpressionErrors(refExpressionErrors, true); - } - if (awaitAt !== null) { - this.unexpected(awaitAt); - } - return this.parseFor(node, init); - } - parseFunctionStatement(node, isAsync, isHangingDeclaration) { - this.next(); - return this.parseFunction(node, 1 | (isHangingDeclaration ? 2 : 0) | (isAsync ? 8 : 0)); - } - parseIfStatement(node) { - this.next(); - node.test = this.parseHeaderExpression(); - node.consequent = this.parseStatementOrSloppyAnnexBFunctionDeclaration(); - node.alternate = this.eat(66) ? this.parseStatementOrSloppyAnnexBFunctionDeclaration() : null; - return this.finishNode(node, "IfStatement"); - } - parseReturnStatement(node) { - if (!this.prodParam.hasReturn && !this.options.allowReturnOutsideFunction) { - this.raise(Errors.IllegalReturn, this.state.startLoc); - } - this.next(); - if (this.isLineTerminator()) { - node.argument = null; - } else { - node.argument = this.parseExpression(); - this.semicolon(); - } - return this.finishNode(node, "ReturnStatement"); - } - parseSwitchStatement(node) { - this.next(); - node.discriminant = this.parseHeaderExpression(); - const cases = node.cases = []; - this.expect(5); - this.state.labels.push(switchLabel); - this.scope.enter(0); - let cur; - for (let sawDefault; !this.match(8);) { - if (this.match(61) || this.match(65)) { - const isCase = this.match(61); - if (cur) this.finishNode(cur, "SwitchCase"); - cases.push(cur = this.startNode()); - cur.consequent = []; - this.next(); - if (isCase) { - cur.test = this.parseExpression(); - } else { - if (sawDefault) { - this.raise(Errors.MultipleDefaultsInSwitch, this.state.lastTokStartLoc); - } - sawDefault = true; - cur.test = null; - } - this.expect(14); - } else { - if (cur) { - cur.consequent.push(this.parseStatementListItem()); - } else { - this.unexpected(); - } - } - } - this.scope.exit(); - if (cur) this.finishNode(cur, "SwitchCase"); - this.next(); - this.state.labels.pop(); - return this.finishNode(node, "SwitchStatement"); - } - parseThrowStatement(node) { - this.next(); - if (this.hasPrecedingLineBreak()) { - this.raise(Errors.NewlineAfterThrow, this.state.lastTokEndLoc); - } - node.argument = this.parseExpression(); - this.semicolon(); - return this.finishNode(node, "ThrowStatement"); - } - parseCatchClauseParam() { - const param = this.parseBindingAtom(); - this.scope.enter(this.options.annexB && param.type === "Identifier" ? 8 : 0); - this.checkLVal(param, { - in: { - type: "CatchClause" - }, - binding: 9 - }); - return param; - } - parseTryStatement(node) { - this.next(); - node.block = this.parseBlock(); - node.handler = null; - if (this.match(62)) { - const clause = this.startNode(); - this.next(); - if (this.match(10)) { - this.expect(10); - clause.param = this.parseCatchClauseParam(); - this.expect(11); - } else { - clause.param = null; - this.scope.enter(0); - } - clause.body = this.withSmartMixTopicForbiddingContext(() => this.parseBlock(false, false)); - this.scope.exit(); - node.handler = this.finishNode(clause, "CatchClause"); - } - node.finalizer = this.eat(67) ? this.parseBlock() : null; - if (!node.handler && !node.finalizer) { - this.raise(Errors.NoCatchOrFinally, node); - } - return this.finishNode(node, "TryStatement"); - } - parseVarStatement(node, kind, allowMissingInitializer = false) { - this.next(); - this.parseVar(node, false, kind, allowMissingInitializer); - this.semicolon(); - return this.finishNode(node, "VariableDeclaration"); - } - parseWhileStatement(node) { - this.next(); - node.test = this.parseHeaderExpression(); - this.state.labels.push(loopLabel); - node.body = this.withSmartMixTopicForbiddingContext(() => this.parseStatement()); - this.state.labels.pop(); - return this.finishNode(node, "WhileStatement"); - } - parseWithStatement(node) { - if (this.state.strict) { - this.raise(Errors.StrictWith, this.state.startLoc); - } - this.next(); - node.object = this.parseHeaderExpression(); - node.body = this.withSmartMixTopicForbiddingContext(() => this.parseStatement()); - return this.finishNode(node, "WithStatement"); - } - parseEmptyStatement(node) { - this.next(); - return this.finishNode(node, "EmptyStatement"); - } - parseLabeledStatement(node, maybeName, expr, flags) { - for (const label of this.state.labels) { - if (label.name === maybeName) { - this.raise(Errors.LabelRedeclaration, expr, { - labelName: maybeName - }); - } - } - const kind = tokenIsLoop(this.state.type) ? 1 : this.match(71) ? 2 : null; - for (let i = this.state.labels.length - 1; i >= 0; i--) { - const label = this.state.labels[i]; - if (label.statementStart === node.start) { - label.statementStart = this.state.start; - label.kind = kind; - } else { - break; - } - } - this.state.labels.push({ - name: maybeName, - kind: kind, - statementStart: this.state.start - }); - node.body = flags & 8 ? this.parseStatementOrSloppyAnnexBFunctionDeclaration(true) : this.parseStatement(); - this.state.labels.pop(); - node.label = expr; - return this.finishNode(node, "LabeledStatement"); - } - parseExpressionStatement(node, expr, decorators) { - node.expression = expr; - this.semicolon(); - return this.finishNode(node, "ExpressionStatement"); - } - parseBlock(allowDirectives = false, createNewLexicalScope = true, afterBlockParse) { - const node = this.startNode(); - if (allowDirectives) { - this.state.strictErrors.clear(); - } - this.expect(5); - if (createNewLexicalScope) { - this.scope.enter(0); - } - this.parseBlockBody(node, allowDirectives, false, 8, afterBlockParse); - if (createNewLexicalScope) { - this.scope.exit(); - } - return this.finishNode(node, "BlockStatement"); - } - isValidDirective(stmt) { - return stmt.type === "ExpressionStatement" && stmt.expression.type === "StringLiteral" && !stmt.expression.extra.parenthesized; - } - parseBlockBody(node, allowDirectives, topLevel, end, afterBlockParse) { - const body = node.body = []; - const directives = node.directives = []; - this.parseBlockOrModuleBlockBody(body, allowDirectives ? directives : undefined, topLevel, end, afterBlockParse); - } - parseBlockOrModuleBlockBody(body, directives, topLevel, end, afterBlockParse) { - const oldStrict = this.state.strict; - let hasStrictModeDirective = false; - let parsedNonDirective = false; - while (!this.match(end)) { - const stmt = topLevel ? this.parseModuleItem() : this.parseStatementListItem(); - if (directives && !parsedNonDirective) { - if (this.isValidDirective(stmt)) { - const directive = this.stmtToDirective(stmt); - directives.push(directive); - if (!hasStrictModeDirective && directive.value.value === "use strict") { - hasStrictModeDirective = true; - this.setStrict(true); - } - continue; - } - parsedNonDirective = true; - this.state.strictErrors.clear(); - } - body.push(stmt); - } - afterBlockParse == null || afterBlockParse.call(this, hasStrictModeDirective); - if (!oldStrict) { - this.setStrict(false); - } - this.next(); - } - parseFor(node, init) { - node.init = init; - this.semicolon(false); - node.test = this.match(13) ? null : this.parseExpression(); - this.semicolon(false); - node.update = this.match(11) ? null : this.parseExpression(); - this.expect(11); - node.body = this.withSmartMixTopicForbiddingContext(() => this.parseStatement()); - this.scope.exit(); - this.state.labels.pop(); - return this.finishNode(node, "ForStatement"); - } - parseForIn(node, init, awaitAt) { - const isForIn = this.match(58); - this.next(); - if (isForIn) { - if (awaitAt !== null) this.unexpected(awaitAt); - } else { - node.await = awaitAt !== null; - } - if (init.type === "VariableDeclaration" && init.declarations[0].init != null && (!isForIn || !this.options.annexB || this.state.strict || init.kind !== "var" || init.declarations[0].id.type !== "Identifier")) { - this.raise(Errors.ForInOfLoopInitializer, init, { - type: isForIn ? "ForInStatement" : "ForOfStatement" - }); - } - if (init.type === "AssignmentPattern") { - this.raise(Errors.InvalidLhs, init, { - ancestor: { - type: "ForStatement" - } - }); - } - node.left = init; - node.right = isForIn ? this.parseExpression() : this.parseMaybeAssignAllowIn(); - this.expect(11); - node.body = this.withSmartMixTopicForbiddingContext(() => this.parseStatement()); - this.scope.exit(); - this.state.labels.pop(); - return this.finishNode(node, isForIn ? "ForInStatement" : "ForOfStatement"); - } - parseVar(node, isFor, kind, allowMissingInitializer = false) { - const declarations = node.declarations = []; - node.kind = kind; - for (;;) { - const decl = this.startNode(); - this.parseVarId(decl, kind); - decl.init = !this.eat(29) ? null : isFor ? this.parseMaybeAssignDisallowIn() : this.parseMaybeAssignAllowIn(); - if (decl.init === null && !allowMissingInitializer) { - if (decl.id.type !== "Identifier" && !(isFor && (this.match(58) || this.isContextual(102)))) { - this.raise(Errors.DeclarationMissingInitializer, this.state.lastTokEndLoc, { - kind: "destructuring" - }); - } else if ((kind === "const" || kind === "using" || kind === "await using") && !(this.match(58) || this.isContextual(102))) { - this.raise(Errors.DeclarationMissingInitializer, this.state.lastTokEndLoc, { - kind - }); - } - } - declarations.push(this.finishNode(decl, "VariableDeclarator")); - if (!this.eat(12)) break; - } - return node; - } - parseVarId(decl, kind) { - const id = this.parseBindingAtom(); - if (kind === "using" || kind === "await using") { - if (id.type === "ArrayPattern" || id.type === "ObjectPattern") { - this.raise(Errors.UsingDeclarationHasBindingPattern, id.loc.start); - } - } - this.checkLVal(id, { - in: { - type: "VariableDeclarator" - }, - binding: kind === "var" ? 5 : 8201 - }); - decl.id = id; - } - parseAsyncFunctionExpression(node) { - return this.parseFunction(node, 8); - } - parseFunction(node, flags = 0) { - const hangingDeclaration = flags & 2; - const isDeclaration = !!(flags & 1); - const requireId = isDeclaration && !(flags & 4); - const isAsync = !!(flags & 8); - this.initFunction(node, isAsync); - if (this.match(55)) { - if (hangingDeclaration) { - this.raise(Errors.GeneratorInSingleStatementContext, this.state.startLoc); - } - this.next(); - node.generator = true; - } - if (isDeclaration) { - node.id = this.parseFunctionId(requireId); - } - const oldMaybeInArrowParameters = this.state.maybeInArrowParameters; - this.state.maybeInArrowParameters = false; - this.scope.enter(2); - this.prodParam.enter(functionFlags(isAsync, node.generator)); - if (!isDeclaration) { - node.id = this.parseFunctionId(); - } - this.parseFunctionParams(node, false); - this.withSmartMixTopicForbiddingContext(() => { - this.parseFunctionBodyAndFinish(node, isDeclaration ? "FunctionDeclaration" : "FunctionExpression"); - }); - this.prodParam.exit(); - this.scope.exit(); - if (isDeclaration && !hangingDeclaration) { - this.registerFunctionStatementId(node); - } - this.state.maybeInArrowParameters = oldMaybeInArrowParameters; - return node; - } - parseFunctionId(requireId) { - return requireId || tokenIsIdentifier(this.state.type) ? this.parseIdentifier() : null; - } - parseFunctionParams(node, isConstructor) { - this.expect(10); - this.expressionScope.enter(newParameterDeclarationScope()); - node.params = this.parseBindingList(11, 41, 2 | (isConstructor ? 4 : 0)); - this.expressionScope.exit(); - } - registerFunctionStatementId(node) { - if (!node.id) return; - this.scope.declareName(node.id.name, !this.options.annexB || this.state.strict || node.generator || node.async ? this.scope.treatFunctionsAsVar ? 5 : 8201 : 17, node.id.loc.start); - } - parseClass(node, isStatement, optionalId) { - this.next(); - const oldStrict = this.state.strict; - this.state.strict = true; - this.parseClassId(node, isStatement, optionalId); - this.parseClassSuper(node); - node.body = this.parseClassBody(!!node.superClass, oldStrict); - return this.finishNode(node, isStatement ? "ClassDeclaration" : "ClassExpression"); - } - isClassProperty() { - return this.match(29) || this.match(13) || this.match(8); - } - isClassMethod() { - return this.match(10); - } - nameIsConstructor(key) { - return key.type === "Identifier" && key.name === "constructor" || key.type === "StringLiteral" && key.value === "constructor"; - } - isNonstaticConstructor(method) { - return !method.computed && !method.static && this.nameIsConstructor(method.key); - } - parseClassBody(hadSuperClass, oldStrict) { - this.classScope.enter(); - const state = { - hadConstructor: false, - hadSuperClass - }; - let decorators = []; - const classBody = this.startNode(); - classBody.body = []; - this.expect(5); - this.withSmartMixTopicForbiddingContext(() => { - while (!this.match(8)) { - if (this.eat(13)) { - if (decorators.length > 0) { - throw this.raise(Errors.DecoratorSemicolon, this.state.lastTokEndLoc); - } - continue; - } - if (this.match(26)) { - decorators.push(this.parseDecorator()); - continue; - } - const member = this.startNode(); - if (decorators.length) { - member.decorators = decorators; - this.resetStartLocationFromNode(member, decorators[0]); - decorators = []; - } - this.parseClassMember(classBody, member, state); - if (member.kind === "constructor" && member.decorators && member.decorators.length > 0) { - this.raise(Errors.DecoratorConstructor, member); - } - } - }); - this.state.strict = oldStrict; - this.next(); - if (decorators.length) { - throw this.raise(Errors.TrailingDecorator, this.state.startLoc); - } - this.classScope.exit(); - return this.finishNode(classBody, "ClassBody"); - } - parseClassMemberFromModifier(classBody, member) { - const key = this.parseIdentifier(true); - if (this.isClassMethod()) { - const method = member; - method.kind = "method"; - method.computed = false; - method.key = key; - method.static = false; - this.pushClassMethod(classBody, method, false, false, false, false); - return true; - } else if (this.isClassProperty()) { - const prop = member; - prop.computed = false; - prop.key = key; - prop.static = false; - classBody.body.push(this.parseClassProperty(prop)); - return true; - } - this.resetPreviousNodeTrailingComments(key); - return false; - } - parseClassMember(classBody, member, state) { - const isStatic = this.isContextual(106); - if (isStatic) { - if (this.parseClassMemberFromModifier(classBody, member)) { - return; - } - if (this.eat(5)) { - this.parseClassStaticBlock(classBody, member); - return; - } - } - this.parseClassMemberWithIsStatic(classBody, member, state, isStatic); - } - parseClassMemberWithIsStatic(classBody, member, state, isStatic) { - const publicMethod = member; - const privateMethod = member; - const publicProp = member; - const privateProp = member; - const accessorProp = member; - const method = publicMethod; - const publicMember = publicMethod; - member.static = isStatic; - this.parsePropertyNamePrefixOperator(member); - if (this.eat(55)) { - method.kind = "method"; - const isPrivateName = this.match(138); - this.parseClassElementName(method); - if (isPrivateName) { - this.pushClassPrivateMethod(classBody, privateMethod, true, false); - return; - } - if (this.isNonstaticConstructor(publicMethod)) { - this.raise(Errors.ConstructorIsGenerator, publicMethod.key); - } - this.pushClassMethod(classBody, publicMethod, true, false, false, false); - return; - } - const isContextual = !this.state.containsEsc && tokenIsIdentifier(this.state.type); - const key = this.parseClassElementName(member); - const maybeContextualKw = isContextual ? key.name : null; - const isPrivate = this.isPrivateName(key); - const maybeQuestionTokenStartLoc = this.state.startLoc; - this.parsePostMemberNameModifiers(publicMember); - if (this.isClassMethod()) { - method.kind = "method"; - if (isPrivate) { - this.pushClassPrivateMethod(classBody, privateMethod, false, false); - return; - } - const isConstructor = this.isNonstaticConstructor(publicMethod); - let allowsDirectSuper = false; - if (isConstructor) { - publicMethod.kind = "constructor"; - if (state.hadConstructor && !this.hasPlugin("typescript")) { - this.raise(Errors.DuplicateConstructor, key); - } - if (isConstructor && this.hasPlugin("typescript") && member.override) { - this.raise(Errors.OverrideOnConstructor, key); - } - state.hadConstructor = true; - allowsDirectSuper = state.hadSuperClass; - } - this.pushClassMethod(classBody, publicMethod, false, false, isConstructor, allowsDirectSuper); - } else if (this.isClassProperty()) { - if (isPrivate) { - this.pushClassPrivateProperty(classBody, privateProp); - } else { - this.pushClassProperty(classBody, publicProp); - } - } else if (maybeContextualKw === "async" && !this.isLineTerminator()) { - this.resetPreviousNodeTrailingComments(key); - const isGenerator = this.eat(55); - if (publicMember.optional) { - this.unexpected(maybeQuestionTokenStartLoc); - } - method.kind = "method"; - const isPrivate = this.match(138); - this.parseClassElementName(method); - this.parsePostMemberNameModifiers(publicMember); - if (isPrivate) { - this.pushClassPrivateMethod(classBody, privateMethod, isGenerator, true); - } else { - if (this.isNonstaticConstructor(publicMethod)) { - this.raise(Errors.ConstructorIsAsync, publicMethod.key); - } - this.pushClassMethod(classBody, publicMethod, isGenerator, true, false, false); - } - } else if ((maybeContextualKw === "get" || maybeContextualKw === "set") && !(this.match(55) && this.isLineTerminator())) { - this.resetPreviousNodeTrailingComments(key); - method.kind = maybeContextualKw; - const isPrivate = this.match(138); - this.parseClassElementName(publicMethod); - if (isPrivate) { - this.pushClassPrivateMethod(classBody, privateMethod, false, false); - } else { - if (this.isNonstaticConstructor(publicMethod)) { - this.raise(Errors.ConstructorIsAccessor, publicMethod.key); - } - this.pushClassMethod(classBody, publicMethod, false, false, false, false); - } - this.checkGetterSetterParams(publicMethod); - } else if (maybeContextualKw === "accessor" && !this.isLineTerminator()) { - this.expectPlugin("decoratorAutoAccessors"); - this.resetPreviousNodeTrailingComments(key); - const isPrivate = this.match(138); - this.parseClassElementName(publicProp); - this.pushClassAccessorProperty(classBody, accessorProp, isPrivate); - } else if (this.isLineTerminator()) { - if (isPrivate) { - this.pushClassPrivateProperty(classBody, privateProp); - } else { - this.pushClassProperty(classBody, publicProp); - } - } else { - this.unexpected(); - } - } - parseClassElementName(member) { - const { - type, - value - } = this.state; - if ((type === 132 || type === 133) && member.static && value === "prototype") { - this.raise(Errors.StaticPrototype, this.state.startLoc); - } - if (type === 138) { - if (value === "constructor") { - this.raise(Errors.ConstructorClassPrivateField, this.state.startLoc); - } - const key = this.parsePrivateName(); - member.key = key; - return key; - } - this.parsePropertyName(member); - return member.key; - } - parseClassStaticBlock(classBody, member) { - var _member$decorators; - this.scope.enter(64 | 128 | 16); - const oldLabels = this.state.labels; - this.state.labels = []; - this.prodParam.enter(0); - const body = member.body = []; - this.parseBlockOrModuleBlockBody(body, undefined, false, 8); - this.prodParam.exit(); - this.scope.exit(); - this.state.labels = oldLabels; - classBody.body.push(this.finishNode(member, "StaticBlock")); - if ((_member$decorators = member.decorators) != null && _member$decorators.length) { - this.raise(Errors.DecoratorStaticBlock, member); - } - } - pushClassProperty(classBody, prop) { - if (!prop.computed && this.nameIsConstructor(prop.key)) { - this.raise(Errors.ConstructorClassField, prop.key); - } - classBody.body.push(this.parseClassProperty(prop)); - } - pushClassPrivateProperty(classBody, prop) { - const node = this.parseClassPrivateProperty(prop); - classBody.body.push(node); - this.classScope.declarePrivateName(this.getPrivateNameSV(node.key), 0, node.key.loc.start); - } - pushClassAccessorProperty(classBody, prop, isPrivate) { - if (!isPrivate && !prop.computed && this.nameIsConstructor(prop.key)) { - this.raise(Errors.ConstructorClassField, prop.key); - } - const node = this.parseClassAccessorProperty(prop); - classBody.body.push(node); - if (isPrivate) { - this.classScope.declarePrivateName(this.getPrivateNameSV(node.key), 0, node.key.loc.start); - } - } - pushClassMethod(classBody, method, isGenerator, isAsync, isConstructor, allowsDirectSuper) { - classBody.body.push(this.parseMethod(method, isGenerator, isAsync, isConstructor, allowsDirectSuper, "ClassMethod", true)); - } - pushClassPrivateMethod(classBody, method, isGenerator, isAsync) { - const node = this.parseMethod(method, isGenerator, isAsync, false, false, "ClassPrivateMethod", true); - classBody.body.push(node); - const kind = node.kind === "get" ? node.static ? 6 : 2 : node.kind === "set" ? node.static ? 5 : 1 : 0; - this.declareClassPrivateMethodInScope(node, kind); - } - declareClassPrivateMethodInScope(node, kind) { - this.classScope.declarePrivateName(this.getPrivateNameSV(node.key), kind, node.key.loc.start); - } - parsePostMemberNameModifiers(methodOrProp) {} - parseClassPrivateProperty(node) { - this.parseInitializer(node); - this.semicolon(); - return this.finishNode(node, "ClassPrivateProperty"); - } - parseClassProperty(node) { - this.parseInitializer(node); - this.semicolon(); - return this.finishNode(node, "ClassProperty"); - } - parseClassAccessorProperty(node) { - this.parseInitializer(node); - this.semicolon(); - return this.finishNode(node, "ClassAccessorProperty"); - } - parseInitializer(node) { - this.scope.enter(64 | 16); - this.expressionScope.enter(newExpressionScope()); - this.prodParam.enter(0); - node.value = this.eat(29) ? this.parseMaybeAssignAllowIn() : null; - this.expressionScope.exit(); - this.prodParam.exit(); - this.scope.exit(); - } - parseClassId(node, isStatement, optionalId, bindingType = 8331) { - if (tokenIsIdentifier(this.state.type)) { - node.id = this.parseIdentifier(); - if (isStatement) { - this.declareNameFromIdentifier(node.id, bindingType); - } - } else { - if (optionalId || !isStatement) { - node.id = null; - } else { - throw this.raise(Errors.MissingClassName, this.state.startLoc); - } - } - } - parseClassSuper(node) { - node.superClass = this.eat(81) ? this.parseExprSubscripts() : null; - } - parseExport(node, decorators) { - const maybeDefaultIdentifier = this.parseMaybeImportPhase(node, true); - const hasDefault = this.maybeParseExportDefaultSpecifier(node, maybeDefaultIdentifier); - const parseAfterDefault = !hasDefault || this.eat(12); - const hasStar = parseAfterDefault && this.eatExportStar(node); - const hasNamespace = hasStar && this.maybeParseExportNamespaceSpecifier(node); - const parseAfterNamespace = parseAfterDefault && (!hasNamespace || this.eat(12)); - const isFromRequired = hasDefault || hasStar; - if (hasStar && !hasNamespace) { - if (hasDefault) this.unexpected(); - if (decorators) { - throw this.raise(Errors.UnsupportedDecoratorExport, node); - } - this.parseExportFrom(node, true); - return this.finishNode(node, "ExportAllDeclaration"); - } - const hasSpecifiers = this.maybeParseExportNamedSpecifiers(node); - if (hasDefault && parseAfterDefault && !hasStar && !hasSpecifiers) { - this.unexpected(null, 5); - } - if (hasNamespace && parseAfterNamespace) { - this.unexpected(null, 98); - } - let hasDeclaration; - if (isFromRequired || hasSpecifiers) { - hasDeclaration = false; - if (decorators) { - throw this.raise(Errors.UnsupportedDecoratorExport, node); - } - this.parseExportFrom(node, isFromRequired); - } else { - hasDeclaration = this.maybeParseExportDeclaration(node); - } - if (isFromRequired || hasSpecifiers || hasDeclaration) { - var _node2$declaration; - const node2 = node; - this.checkExport(node2, true, false, !!node2.source); - if (((_node2$declaration = node2.declaration) == null ? void 0 : _node2$declaration.type) === "ClassDeclaration") { - this.maybeTakeDecorators(decorators, node2.declaration, node2); - } else if (decorators) { - throw this.raise(Errors.UnsupportedDecoratorExport, node); - } - return this.finishNode(node2, "ExportNamedDeclaration"); - } - if (this.eat(65)) { - const node2 = node; - const decl = this.parseExportDefaultExpression(); - node2.declaration = decl; - if (decl.type === "ClassDeclaration") { - this.maybeTakeDecorators(decorators, decl, node2); - } else if (decorators) { - throw this.raise(Errors.UnsupportedDecoratorExport, node); - } - this.checkExport(node2, true, true); - return this.finishNode(node2, "ExportDefaultDeclaration"); - } - this.unexpected(null, 5); - } - eatExportStar(node) { - return this.eat(55); - } - maybeParseExportDefaultSpecifier(node, maybeDefaultIdentifier) { - if (maybeDefaultIdentifier || this.isExportDefaultSpecifier()) { - this.expectPlugin("exportDefaultFrom", maybeDefaultIdentifier == null ? void 0 : maybeDefaultIdentifier.loc.start); - const id = maybeDefaultIdentifier || this.parseIdentifier(true); - const specifier = this.startNodeAtNode(id); - specifier.exported = id; - node.specifiers = [this.finishNode(specifier, "ExportDefaultSpecifier")]; - return true; - } - return false; - } - maybeParseExportNamespaceSpecifier(node) { - if (this.isContextual(93)) { - var _ref, _ref$specifiers; - (_ref$specifiers = (_ref = node).specifiers) != null ? _ref$specifiers : _ref.specifiers = []; - const specifier = this.startNodeAt(this.state.lastTokStartLoc); - this.next(); - specifier.exported = this.parseModuleExportName(); - node.specifiers.push(this.finishNode(specifier, "ExportNamespaceSpecifier")); - return true; - } - return false; - } - maybeParseExportNamedSpecifiers(node) { - if (this.match(5)) { - const node2 = node; - if (!node2.specifiers) node2.specifiers = []; - const isTypeExport = node2.exportKind === "type"; - node2.specifiers.push(...this.parseExportSpecifiers(isTypeExport)); - node2.source = null; - node2.declaration = null; - if (this.hasPlugin("importAssertions")) { - node2.assertions = []; - } - return true; - } - return false; - } - maybeParseExportDeclaration(node) { - if (this.shouldParseExportDeclaration()) { - node.specifiers = []; - node.source = null; - if (this.hasPlugin("importAssertions")) { - node.assertions = []; - } - node.declaration = this.parseExportDeclaration(node); - return true; - } - return false; - } - isAsyncFunction() { - if (!this.isContextual(95)) return false; - const next = this.nextTokenInLineStart(); - return this.isUnparsedContextual(next, "function"); - } - parseExportDefaultExpression() { - const expr = this.startNode(); - if (this.match(68)) { - this.next(); - return this.parseFunction(expr, 1 | 4); - } else if (this.isAsyncFunction()) { - this.next(); - this.next(); - return this.parseFunction(expr, 1 | 4 | 8); - } - if (this.match(80)) { - return this.parseClass(expr, true, true); - } - if (this.match(26)) { - if (this.hasPlugin("decorators") && this.getPluginOption("decorators", "decoratorsBeforeExport") === true) { - this.raise(Errors.DecoratorBeforeExport, this.state.startLoc); - } - return this.parseClass(this.maybeTakeDecorators(this.parseDecorators(false), this.startNode()), true, true); - } - if (this.match(75) || this.match(74) || this.isLet()) { - throw this.raise(Errors.UnsupportedDefaultExport, this.state.startLoc); - } - const res = this.parseMaybeAssignAllowIn(); - this.semicolon(); - return res; - } - parseExportDeclaration(node) { - if (this.match(80)) { - const node = this.parseClass(this.startNode(), true, false); - return node; - } - return this.parseStatementListItem(); - } - isExportDefaultSpecifier() { - const { - type - } = this.state; - if (tokenIsIdentifier(type)) { - if (type === 95 && !this.state.containsEsc || type === 100) { - return false; - } - if ((type === 130 || type === 129) && !this.state.containsEsc) { - const { - type: nextType - } = this.lookahead(); - if (tokenIsIdentifier(nextType) && nextType !== 98 || nextType === 5) { - this.expectOnePlugin(["flow", "typescript"]); - return false; - } - } - } else if (!this.match(65)) { - return false; - } - const next = this.nextTokenStart(); - const hasFrom = this.isUnparsedContextual(next, "from"); - if (this.input.charCodeAt(next) === 44 || tokenIsIdentifier(this.state.type) && hasFrom) { - return true; - } - if (this.match(65) && hasFrom) { - const nextAfterFrom = this.input.charCodeAt(this.nextTokenStartSince(next + 4)); - return nextAfterFrom === 34 || nextAfterFrom === 39; - } - return false; - } - parseExportFrom(node, expect) { - if (this.eatContextual(98)) { - node.source = this.parseImportSource(); - this.checkExport(node); - this.maybeParseImportAttributes(node); - this.checkJSONModuleImport(node); - } else if (expect) { - this.unexpected(); - } - this.semicolon(); - } - shouldParseExportDeclaration() { - const { - type - } = this.state; - if (type === 26) { - this.expectOnePlugin(["decorators", "decorators-legacy"]); - if (this.hasPlugin("decorators")) { - if (this.getPluginOption("decorators", "decoratorsBeforeExport") === true) { - this.raise(Errors.DecoratorBeforeExport, this.state.startLoc); - } - return true; - } - } - if (this.isContextual(107)) { - this.raise(Errors.UsingDeclarationExport, this.state.startLoc); - return true; - } - if (this.isContextual(96) && this.startsAwaitUsing()) { - this.raise(Errors.UsingDeclarationExport, this.state.startLoc); - return true; - } - return type === 74 || type === 75 || type === 68 || type === 80 || this.isLet() || this.isAsyncFunction(); - } - checkExport(node, checkNames, isDefault, isFrom) { - if (checkNames) { - var _node$specifiers; - if (isDefault) { - this.checkDuplicateExports(node, "default"); - if (this.hasPlugin("exportDefaultFrom")) { - var _declaration$extra; - const declaration = node.declaration; - if (declaration.type === "Identifier" && declaration.name === "from" && declaration.end - declaration.start === 4 && !((_declaration$extra = declaration.extra) != null && _declaration$extra.parenthesized)) { - this.raise(Errors.ExportDefaultFromAsIdentifier, declaration); - } - } - } else if ((_node$specifiers = node.specifiers) != null && _node$specifiers.length) { - for (const specifier of node.specifiers) { - const { - exported - } = specifier; - const exportName = exported.type === "Identifier" ? exported.name : exported.value; - this.checkDuplicateExports(specifier, exportName); - if (!isFrom && specifier.local) { - const { - local - } = specifier; - if (local.type !== "Identifier") { - this.raise(Errors.ExportBindingIsString, specifier, { - localName: local.value, - exportName - }); - } else { - this.checkReservedWord(local.name, local.loc.start, true, false); - this.scope.checkLocalExport(local); - } - } - } - } else if (node.declaration) { - const decl = node.declaration; - if (decl.type === "FunctionDeclaration" || decl.type === "ClassDeclaration") { - const { - id - } = decl; - if (!id) throw new Error("Assertion failure"); - this.checkDuplicateExports(node, id.name); - } else if (decl.type === "VariableDeclaration") { - for (const declaration of decl.declarations) { - this.checkDeclaration(declaration.id); - } - } - } - } - } - checkDeclaration(node) { - if (node.type === "Identifier") { - this.checkDuplicateExports(node, node.name); - } else if (node.type === "ObjectPattern") { - for (const prop of node.properties) { - this.checkDeclaration(prop); - } - } else if (node.type === "ArrayPattern") { - for (const elem of node.elements) { - if (elem) { - this.checkDeclaration(elem); - } - } - } else if (node.type === "ObjectProperty") { - this.checkDeclaration(node.value); - } else if (node.type === "RestElement") { - this.checkDeclaration(node.argument); - } else if (node.type === "AssignmentPattern") { - this.checkDeclaration(node.left); - } - } - checkDuplicateExports(node, exportName) { - if (this.exportedIdentifiers.has(exportName)) { - if (exportName === "default") { - this.raise(Errors.DuplicateDefaultExport, node); - } else { - this.raise(Errors.DuplicateExport, node, { - exportName - }); - } - } - this.exportedIdentifiers.add(exportName); - } - parseExportSpecifiers(isInTypeExport) { - const nodes = []; - let first = true; - this.expect(5); - while (!this.eat(8)) { - if (first) { - first = false; - } else { - this.expect(12); - if (this.eat(8)) break; - } - const isMaybeTypeOnly = this.isContextual(130); - const isString = this.match(133); - const node = this.startNode(); - node.local = this.parseModuleExportName(); - nodes.push(this.parseExportSpecifier(node, isString, isInTypeExport, isMaybeTypeOnly)); - } - return nodes; - } - parseExportSpecifier(node, isString, isInTypeExport, isMaybeTypeOnly) { - if (this.eatContextual(93)) { - node.exported = this.parseModuleExportName(); - } else if (isString) { - node.exported = cloneStringLiteral(node.local); - } else if (!node.exported) { - node.exported = cloneIdentifier(node.local); - } - return this.finishNode(node, "ExportSpecifier"); - } - parseModuleExportName() { - if (this.match(133)) { - const result = this.parseStringLiteral(this.state.value); - const surrogate = loneSurrogate.exec(result.value); - if (surrogate) { - this.raise(Errors.ModuleExportNameHasLoneSurrogate, result, { - surrogateCharCode: surrogate[0].charCodeAt(0) - }); - } - return result; - } - return this.parseIdentifier(true); - } - isJSONModuleImport(node) { - if (node.assertions != null) { - return node.assertions.some(({ - key, - value - }) => { - return value.value === "json" && (key.type === "Identifier" ? key.name === "type" : key.value === "type"); - }); - } - return false; - } - checkImportReflection(node) { - const { - specifiers - } = node; - const singleBindingType = specifiers.length === 1 ? specifiers[0].type : null; - if (node.phase === "source") { - if (singleBindingType !== "ImportDefaultSpecifier") { - this.raise(Errors.SourcePhaseImportRequiresDefault, specifiers[0].loc.start); - } - } else if (node.phase === "defer") { - if (singleBindingType !== "ImportNamespaceSpecifier") { - this.raise(Errors.DeferImportRequiresNamespace, specifiers[0].loc.start); - } - } else if (node.module) { - var _node$assertions; - if (singleBindingType !== "ImportDefaultSpecifier") { - this.raise(Errors.ImportReflectionNotBinding, specifiers[0].loc.start); - } - if (((_node$assertions = node.assertions) == null ? void 0 : _node$assertions.length) > 0) { - this.raise(Errors.ImportReflectionHasAssertion, specifiers[0].loc.start); - } - } - } - checkJSONModuleImport(node) { - if (this.isJSONModuleImport(node) && node.type !== "ExportAllDeclaration") { - const { - specifiers - } = node; - if (specifiers != null) { - const nonDefaultNamedSpecifier = specifiers.find(specifier => { - let imported; - if (specifier.type === "ExportSpecifier") { - imported = specifier.local; - } else if (specifier.type === "ImportSpecifier") { - imported = specifier.imported; - } - if (imported !== undefined) { - return imported.type === "Identifier" ? imported.name !== "default" : imported.value !== "default"; - } - }); - if (nonDefaultNamedSpecifier !== undefined) { - this.raise(Errors.ImportJSONBindingNotDefault, nonDefaultNamedSpecifier.loc.start); - } - } - } - } - isPotentialImportPhase(isExport) { - if (isExport) return false; - return this.isContextual(105) || this.isContextual(97) || this.isContextual(127); - } - applyImportPhase(node, isExport, phase, loc) { - if (isExport) { - return; - } - if (phase === "module") { - this.expectPlugin("importReflection", loc); - node.module = true; - } else if (this.hasPlugin("importReflection")) { - node.module = false; - } - if (phase === "source") { - this.expectPlugin("sourcePhaseImports", loc); - node.phase = "source"; - } else if (phase === "defer") { - this.expectPlugin("deferredImportEvaluation", loc); - node.phase = "defer"; - } else if (this.hasPlugin("sourcePhaseImports")) { - node.phase = null; - } - } - parseMaybeImportPhase(node, isExport) { - if (!this.isPotentialImportPhase(isExport)) { - this.applyImportPhase(node, isExport, null); - return null; - } - const phaseIdentifier = this.parseIdentifier(true); - const { - type - } = this.state; - const isImportPhase = tokenIsKeywordOrIdentifier(type) ? type !== 98 || this.lookaheadCharCode() === 102 : type !== 12; - if (isImportPhase) { - this.resetPreviousIdentifierLeadingComments(phaseIdentifier); - this.applyImportPhase(node, isExport, phaseIdentifier.name, phaseIdentifier.loc.start); - return null; - } else { - this.applyImportPhase(node, isExport, null); - return phaseIdentifier; - } - } - isPrecedingIdImportPhase(phase) { - const { - type - } = this.state; - return tokenIsIdentifier(type) ? type !== 98 || this.lookaheadCharCode() === 102 : type !== 12; - } - parseImport(node) { - if (this.match(133)) { - return this.parseImportSourceAndAttributes(node); - } - return this.parseImportSpecifiersAndAfter(node, this.parseMaybeImportPhase(node, false)); - } - parseImportSpecifiersAndAfter(node, maybeDefaultIdentifier) { - node.specifiers = []; - const hasDefault = this.maybeParseDefaultImportSpecifier(node, maybeDefaultIdentifier); - const parseNext = !hasDefault || this.eat(12); - const hasStar = parseNext && this.maybeParseStarImportSpecifier(node); - if (parseNext && !hasStar) this.parseNamedImportSpecifiers(node); - this.expectContextual(98); - return this.parseImportSourceAndAttributes(node); - } - parseImportSourceAndAttributes(node) { - var _node$specifiers2; - (_node$specifiers2 = node.specifiers) != null ? _node$specifiers2 : node.specifiers = []; - node.source = this.parseImportSource(); - this.maybeParseImportAttributes(node); - this.checkImportReflection(node); - this.checkJSONModuleImport(node); - this.semicolon(); - return this.finishNode(node, "ImportDeclaration"); - } - parseImportSource() { - if (!this.match(133)) this.unexpected(); - return this.parseExprAtom(); - } - parseImportSpecifierLocal(node, specifier, type) { - specifier.local = this.parseIdentifier(); - node.specifiers.push(this.finishImportSpecifier(specifier, type)); - } - finishImportSpecifier(specifier, type, bindingType = 8201) { - this.checkLVal(specifier.local, { - in: { - type - }, - binding: bindingType - }); - return this.finishNode(specifier, type); - } - parseImportAttributes() { - this.expect(5); - const attrs = []; - const attrNames = new Set(); - do { - if (this.match(8)) { - break; - } - const node = this.startNode(); - const keyName = this.state.value; - if (attrNames.has(keyName)) { - this.raise(Errors.ModuleAttributesWithDuplicateKeys, this.state.startLoc, { - key: keyName - }); - } - attrNames.add(keyName); - if (this.match(133)) { - node.key = this.parseStringLiteral(keyName); - } else { - node.key = this.parseIdentifier(true); - } - this.expect(14); - if (!this.match(133)) { - throw this.raise(Errors.ModuleAttributeInvalidValue, this.state.startLoc); - } - node.value = this.parseStringLiteral(this.state.value); - attrs.push(this.finishNode(node, "ImportAttribute")); - } while (this.eat(12)); - this.expect(8); - return attrs; - } - parseModuleAttributes() { - const attrs = []; - const attributes = new Set(); - do { - const node = this.startNode(); - node.key = this.parseIdentifier(true); - if (node.key.name !== "type") { - this.raise(Errors.ModuleAttributeDifferentFromType, node.key); - } - if (attributes.has(node.key.name)) { - this.raise(Errors.ModuleAttributesWithDuplicateKeys, node.key, { - key: node.key.name - }); - } - attributes.add(node.key.name); - this.expect(14); - if (!this.match(133)) { - throw this.raise(Errors.ModuleAttributeInvalidValue, this.state.startLoc); - } - node.value = this.parseStringLiteral(this.state.value); - attrs.push(this.finishNode(node, "ImportAttribute")); - } while (this.eat(12)); - return attrs; - } - maybeParseImportAttributes(node) { - let attributes; - let useWith = false; - if (this.match(76)) { - if (this.hasPrecedingLineBreak() && this.lookaheadCharCode() === 40) { - return; - } - this.next(); - { - if (this.hasPlugin("moduleAttributes")) { - attributes = this.parseModuleAttributes(); - } else { - this.expectImportAttributesPlugin(); - attributes = this.parseImportAttributes(); - } - } - useWith = true; - } else if (this.isContextual(94) && !this.hasPrecedingLineBreak()) { - if (this.hasPlugin("importAttributes")) { - if (this.getPluginOption("importAttributes", "deprecatedAssertSyntax") !== true) { - this.raise(Errors.ImportAttributesUseAssert, this.state.startLoc); - } - this.addExtra(node, "deprecatedAssertSyntax", true); - } else { - this.expectOnePlugin(["importAttributes", "importAssertions"]); - } - this.next(); - attributes = this.parseImportAttributes(); - } else if (this.hasPlugin("importAttributes") || this.hasPlugin("importAssertions")) { - attributes = []; - } else { - if (this.hasPlugin("moduleAttributes")) { - attributes = []; - } else return; - } - if (!useWith && this.hasPlugin("importAssertions")) { - node.assertions = attributes; - } else { - node.attributes = attributes; - } - } - maybeParseDefaultImportSpecifier(node, maybeDefaultIdentifier) { - if (maybeDefaultIdentifier) { - const specifier = this.startNodeAtNode(maybeDefaultIdentifier); - specifier.local = maybeDefaultIdentifier; - node.specifiers.push(this.finishImportSpecifier(specifier, "ImportDefaultSpecifier")); - return true; - } else if (tokenIsKeywordOrIdentifier(this.state.type)) { - this.parseImportSpecifierLocal(node, this.startNode(), "ImportDefaultSpecifier"); - return true; - } - return false; - } - maybeParseStarImportSpecifier(node) { - if (this.match(55)) { - const specifier = this.startNode(); - this.next(); - this.expectContextual(93); - this.parseImportSpecifierLocal(node, specifier, "ImportNamespaceSpecifier"); - return true; - } - return false; - } - parseNamedImportSpecifiers(node) { - let first = true; - this.expect(5); - while (!this.eat(8)) { - if (first) { - first = false; - } else { - if (this.eat(14)) { - throw this.raise(Errors.DestructureNamedImport, this.state.startLoc); - } - this.expect(12); - if (this.eat(8)) break; - } - const specifier = this.startNode(); - const importedIsString = this.match(133); - const isMaybeTypeOnly = this.isContextual(130); - specifier.imported = this.parseModuleExportName(); - const importSpecifier = this.parseImportSpecifier(specifier, importedIsString, node.importKind === "type" || node.importKind === "typeof", isMaybeTypeOnly, undefined); - node.specifiers.push(importSpecifier); - } - } - parseImportSpecifier(specifier, importedIsString, isInTypeOnlyImport, isMaybeTypeOnly, bindingType) { - if (this.eatContextual(93)) { - specifier.local = this.parseIdentifier(); - } else { - const { - imported - } = specifier; - if (importedIsString) { - throw this.raise(Errors.ImportBindingIsString, specifier, { - importName: imported.value - }); - } - this.checkReservedWord(imported.name, specifier.loc.start, true, true); - if (!specifier.local) { - specifier.local = cloneIdentifier(imported); - } - } - return this.finishImportSpecifier(specifier, "ImportSpecifier", bindingType); - } - isThisParam(param) { - return param.type === "Identifier" && param.name === "this"; - } -} -class Parser extends StatementParser { - constructor(options, input) { - options = getOptions(options); - super(options, input); - this.options = options; - this.initializeScopes(); - this.plugins = pluginsMap(this.options.plugins); - this.filename = options.sourceFilename; - } - getScopeHandler() { - return ScopeHandler; - } - parse() { - this.enterInitialScopes(); - const file = this.startNode(); - const program = this.startNode(); - this.nextToken(); - file.errors = null; - this.parseTopLevel(file, program); - file.errors = this.state.errors; - file.comments.length = this.state.commentsLen; - return file; - } -} -function pluginsMap(plugins) { - const pluginMap = new Map(); - for (const plugin of plugins) { - const [name, options] = Array.isArray(plugin) ? plugin : [plugin, {}]; - if (!pluginMap.has(name)) pluginMap.set(name, options || {}); - } - return pluginMap; -} -function parse(input, options) { - var _options; - if (((_options = options) == null ? void 0 : _options.sourceType) === "unambiguous") { - options = Object.assign({}, options); - try { - options.sourceType = "module"; - const parser = getParser(options, input); - const ast = parser.parse(); - if (parser.sawUnambiguousESM) { - return ast; - } - if (parser.ambiguousScriptDifferentAst) { - try { - options.sourceType = "script"; - return getParser(options, input).parse(); - } catch (_unused) {} - } else { - ast.program.sourceType = "script"; - } - return ast; - } catch (moduleError) { - try { - options.sourceType = "script"; - return getParser(options, input).parse(); - } catch (_unused2) {} - throw moduleError; - } - } else { - return getParser(options, input).parse(); - } -} -function parseExpression(input, options) { - const parser = getParser(options, input); - if (parser.options.strictMode) { - parser.state.strict = true; - } - return parser.getExpression(); -} -function generateExportedTokenTypes(internalTokenTypes) { - const tokenTypes = {}; - for (const typeName of Object.keys(internalTokenTypes)) { - tokenTypes[typeName] = getExportedToken(internalTokenTypes[typeName]); - } - return tokenTypes; -} -const tokTypes = generateExportedTokenTypes(tt); -function getParser(options, input) { - let cls = Parser; - if (options != null && options.plugins) { - validatePlugins(options.plugins); - cls = getParserClass(options.plugins); - } - return new cls(options, input); -} -const parserClassCache = {}; -function getParserClass(pluginsFromOptions) { - const pluginList = mixinPluginNames.filter(name => hasPlugin(pluginsFromOptions, name)); - const key = pluginList.join("/"); - let cls = parserClassCache[key]; - if (!cls) { - cls = Parser; - for (const plugin of pluginList) { - cls = mixinPlugins[plugin](cls); - } - parserClassCache[key] = cls; - } - return cls; -} -exports.parse = parse; -exports.parseExpression = parseExpression; -exports.tokTypes = tokTypes; -//# sourceMappingURL=index.js.map diff --git a/tools/eslint/node_modules/@babel/parser/package.json b/tools/eslint/node_modules/@babel/parser/package.json deleted file mode 100644 index 0bcae8fcb07161..00000000000000 --- a/tools/eslint/node_modules/@babel/parser/package.json +++ /dev/null @@ -1,47 +0,0 @@ -{ - "name": "@babel/parser", - "version": "7.24.8", - "description": "A JavaScript parser", - "author": "The Babel Team (https://babel.dev/team)", - "homepage": "https://babel.dev/docs/en/next/babel-parser", - "bugs": "https://github.com/babel/babel/issues?utf8=%E2%9C%93&q=is%3Aissue+label%3A%22pkg%3A+parser+%28babylon%29%22+is%3Aopen", - "license": "MIT", - "publishConfig": { - "access": "public" - }, - "keywords": [ - "babel", - "javascript", - "parser", - "tc39", - "ecmascript", - "@babel/parser" - ], - "repository": { - "type": "git", - "url": "https://github.com/babel/babel.git", - "directory": "packages/babel-parser" - }, - "main": "./lib/index.js", - "types": "./typings/babel-parser.d.ts", - "files": [ - "bin", - "lib", - "typings/babel-parser.d.ts", - "index.cjs" - ], - "engines": { - "node": ">=6.0.0" - }, - "devDependencies": { - "@babel/code-frame": "^7.24.7", - "@babel/helper-check-duplicate-nodes": "^7.24.7", - "@babel/helper-fixtures": "^7.24.8", - "@babel/helper-string-parser": "^7.24.8", - "@babel/helper-validator-identifier": "^7.24.7", - "@babel/types": "^7.24.8", - "charcodes": "^0.2.0" - }, - "bin": "./bin/babel-parser.js", - "type": "commonjs" -} \ No newline at end of file diff --git a/tools/eslint/node_modules/@babel/plugin-syntax-import-attributes/LICENSE b/tools/eslint/node_modules/@babel/plugin-syntax-import-attributes/LICENSE deleted file mode 100644 index f31575ec773bb1..00000000000000 --- a/tools/eslint/node_modules/@babel/plugin-syntax-import-attributes/LICENSE +++ /dev/null @@ -1,22 +0,0 @@ -MIT License - -Copyright (c) 2014-present Sebastian McKenzie and other contributors - -Permission is hereby granted, free of charge, to any person obtaining -a copy of this software and associated documentation files (the -"Software"), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sublicense, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/tools/eslint/node_modules/@babel/plugin-syntax-import-attributes/lib/index.js b/tools/eslint/node_modules/@babel/plugin-syntax-import-attributes/lib/index.js deleted file mode 100644 index 000edfbc0af37e..00000000000000 --- a/tools/eslint/node_modules/@babel/plugin-syntax-import-attributes/lib/index.js +++ /dev/null @@ -1,30 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.default = void 0; -var _helperPluginUtils = require("@babel/helper-plugin-utils"); -var _default = exports.default = (0, _helperPluginUtils.declare)((api, { - deprecatedAssertSyntax -}) => { - api.assertVersion("^7.22.0 || >8.0.0-alpha <8.0.0-beta"); - if (deprecatedAssertSyntax != null && typeof deprecatedAssertSyntax !== "boolean") { - throw new Error("'deprecatedAssertSyntax' must be a boolean, if specified."); - } - return { - name: "syntax-import-attributes", - manipulateOptions({ - parserOpts, - generatorOpts - }) { - var _generatorOpts$import; - (_generatorOpts$import = generatorOpts.importAttributesKeyword) != null ? _generatorOpts$import : generatorOpts.importAttributesKeyword = "with"; - parserOpts.plugins.push(["importAttributes", { - deprecatedAssertSyntax: Boolean(deprecatedAssertSyntax) - }]); - } - }; -}); - -//# sourceMappingURL=index.js.map diff --git a/tools/eslint/node_modules/@babel/plugin-syntax-import-attributes/package.json b/tools/eslint/node_modules/@babel/plugin-syntax-import-attributes/package.json deleted file mode 100644 index ea04e2a2ba459e..00000000000000 --- a/tools/eslint/node_modules/@babel/plugin-syntax-import-attributes/package.json +++ /dev/null @@ -1,39 +0,0 @@ -{ - "name": "@babel/plugin-syntax-import-attributes", - "version": "7.24.7", - "description": "Allow parsing of the module attributes in the import statement", - "repository": { - "type": "git", - "url": "https://github.com/babel/babel.git", - "directory": "packages/babel-plugin-syntax-import-attributes" - }, - "license": "MIT", - "publishConfig": { - "access": "public" - }, - "main": "./lib/index.js", - "keywords": [ - "babel-plugin" - ], - "dependencies": { - "@babel/helper-plugin-utils": "^7.24.7" - }, - "peerDependencies": { - "@babel/core": "^7.0.0-0" - }, - "devDependencies": { - "@babel/core": "^7.24.7" - }, - "engines": { - "node": ">=6.9.0" - }, - "author": "The Babel Team (https://babel.dev/team)", - "exports": { - ".": { - "types": "./lib/index.d.ts", - "default": "./lib/index.js" - }, - "./package.json": "./package.json" - }, - "type": "commonjs" -} \ No newline at end of file diff --git a/tools/eslint/node_modules/@babel/plugin-syntax-import-attributes/tsconfig.tsbuildinfo b/tools/eslint/node_modules/@babel/plugin-syntax-import-attributes/tsconfig.tsbuildinfo deleted file mode 100644 index da698bb25bb16e..00000000000000 --- a/tools/eslint/node_modules/@babel/plugin-syntax-import-attributes/tsconfig.tsbuildinfo +++ /dev/null @@ -1 +0,0 @@ -{"program":{"fileNames":["../../node_modules/typescript/lib/lib.es5.d.ts","../../node_modules/typescript/lib/lib.es2015.d.ts","../../node_modules/typescript/lib/lib.es2016.d.ts","../../node_modules/typescript/lib/lib.es2017.d.ts","../../node_modules/typescript/lib/lib.es2018.d.ts","../../node_modules/typescript/lib/lib.es2019.d.ts","../../node_modules/typescript/lib/lib.es2020.d.ts","../../node_modules/typescript/lib/lib.es2021.d.ts","../../node_modules/typescript/lib/lib.es2022.d.ts","../../node_modules/typescript/lib/lib.es2023.d.ts","../../node_modules/typescript/lib/lib.esnext.d.ts","../../node_modules/typescript/lib/lib.es2015.core.d.ts","../../node_modules/typescript/lib/lib.es2015.collection.d.ts","../../node_modules/typescript/lib/lib.es2015.generator.d.ts","../../node_modules/typescript/lib/lib.es2015.iterable.d.ts","../../node_modules/typescript/lib/lib.es2015.promise.d.ts","../../node_modules/typescript/lib/lib.es2015.proxy.d.ts","../../node_modules/typescript/lib/lib.es2015.reflect.d.ts","../../node_modules/typescript/lib/lib.es2015.symbol.d.ts","../../node_modules/typescript/lib/lib.es2015.symbol.wellknown.d.ts","../../node_modules/typescript/lib/lib.es2016.array.include.d.ts","../../node_modules/typescript/lib/lib.es2016.intl.d.ts","../../node_modules/typescript/lib/lib.es2017.date.d.ts","../../node_modules/typescript/lib/lib.es2017.object.d.ts","../../node_modules/typescript/lib/lib.es2017.sharedmemory.d.ts","../../node_modules/typescript/lib/lib.es2017.string.d.ts","../../node_modules/typescript/lib/lib.es2017.intl.d.ts","../../node_modules/typescript/lib/lib.es2017.typedarrays.d.ts","../../node_modules/typescript/lib/lib.es2018.asyncgenerator.d.ts","../../node_modules/typescript/lib/lib.es2018.asynciterable.d.ts","../../node_modules/typescript/lib/lib.es2018.intl.d.ts","../../node_modules/typescript/lib/lib.es2018.promise.d.ts","../../node_modules/typescript/lib/lib.es2018.regexp.d.ts","../../node_modules/typescript/lib/lib.es2019.array.d.ts","../../node_modules/typescript/lib/lib.es2019.object.d.ts","../../node_modules/typescript/lib/lib.es2019.string.d.ts","../../node_modules/typescript/lib/lib.es2019.symbol.d.ts","../../node_modules/typescript/lib/lib.es2019.intl.d.ts","../../node_modules/typescript/lib/lib.es2020.bigint.d.ts","../../node_modules/typescript/lib/lib.es2020.date.d.ts","../../node_modules/typescript/lib/lib.es2020.promise.d.ts","../../node_modules/typescript/lib/lib.es2020.sharedmemory.d.ts","../../node_modules/typescript/lib/lib.es2020.string.d.ts","../../node_modules/typescript/lib/lib.es2020.symbol.wellknown.d.ts","../../node_modules/typescript/lib/lib.es2020.intl.d.ts","../../node_modules/typescript/lib/lib.es2020.number.d.ts","../../node_modules/typescript/lib/lib.es2021.promise.d.ts","../../node_modules/typescript/lib/lib.es2021.string.d.ts","../../node_modules/typescript/lib/lib.es2021.weakref.d.ts","../../node_modules/typescript/lib/lib.es2021.intl.d.ts","../../node_modules/typescript/lib/lib.es2022.array.d.ts","../../node_modules/typescript/lib/lib.es2022.error.d.ts","../../node_modules/typescript/lib/lib.es2022.intl.d.ts","../../node_modules/typescript/lib/lib.es2022.object.d.ts","../../node_modules/typescript/lib/lib.es2022.sharedmemory.d.ts","../../node_modules/typescript/lib/lib.es2022.string.d.ts","../../node_modules/typescript/lib/lib.es2022.regexp.d.ts","../../node_modules/typescript/lib/lib.es2023.array.d.ts","../../node_modules/typescript/lib/lib.es2023.collection.d.ts","../../node_modules/typescript/lib/lib.esnext.collection.d.ts","../../node_modules/typescript/lib/lib.esnext.intl.d.ts","../../node_modules/typescript/lib/lib.esnext.disposable.d.ts","../../node_modules/typescript/lib/lib.esnext.promise.d.ts","../../node_modules/typescript/lib/lib.esnext.decorators.d.ts","../../node_modules/typescript/lib/lib.esnext.object.d.ts","../../node_modules/typescript/lib/lib.decorators.d.ts","../../node_modules/typescript/lib/lib.decorators.legacy.d.ts","../../dts/packages/babel-types/src/validators/react/isCompatTag.d.ts","../../dts/packages/babel-types/src/builders/react/buildChildren.d.ts","../../dts/packages/babel-types/src/asserts/assertNode.d.ts","../../dts/packages/babel-types/src/asserts/generated/index.d.ts","../../dts/packages/babel-types/src/builders/flow/createTypeAnnotationBasedOnTypeof.d.ts","../../dts/packages/babel-types/src/builders/flow/createFlowUnionType.d.ts","../../dts/packages/babel-types/src/builders/typescript/createTSUnionType.d.ts","../../dts/packages/babel-types/src/builders/generated/index.d.ts","../babel-types/src/builders/generated/uppercase.d.ts","../../dts/packages/babel-types/src/builders/productions.d.ts","../../dts/packages/babel-types/src/clone/cloneNode.d.ts","../../dts/packages/babel-types/src/clone/clone.d.ts","../../dts/packages/babel-types/src/clone/cloneDeep.d.ts","../../dts/packages/babel-types/src/clone/cloneDeepWithoutLoc.d.ts","../../dts/packages/babel-types/src/clone/cloneWithoutLoc.d.ts","../../dts/packages/babel-types/src/comments/addComment.d.ts","../../dts/packages/babel-types/src/comments/addComments.d.ts","../../dts/packages/babel-types/src/comments/inheritInnerComments.d.ts","../../dts/packages/babel-types/src/comments/inheritLeadingComments.d.ts","../../dts/packages/babel-types/src/comments/inheritsComments.d.ts","../../dts/packages/babel-types/src/comments/inheritTrailingComments.d.ts","../../dts/packages/babel-types/src/comments/removeComments.d.ts","../../dts/packages/babel-types/src/constants/generated/index.d.ts","../../dts/packages/babel-types/src/constants/index.d.ts","../../dts/packages/babel-types/src/converters/ensureBlock.d.ts","../../dts/packages/babel-types/src/converters/toBindingIdentifierName.d.ts","../../dts/packages/babel-types/src/converters/toBlock.d.ts","../../dts/packages/babel-types/src/converters/toComputedKey.d.ts","../../dts/packages/babel-types/src/converters/toExpression.d.ts","../../dts/packages/babel-types/src/converters/toIdentifier.d.ts","../../dts/packages/babel-types/src/converters/toKeyAlias.d.ts","../../dts/packages/babel-types/src/converters/toStatement.d.ts","../../dts/packages/babel-types/src/converters/valueToNode.d.ts","../../dts/packages/babel-types/src/definitions/utils.d.ts","../../dts/packages/babel-types/src/definitions/core.d.ts","../../dts/packages/babel-types/src/definitions/flow.d.ts","../../dts/packages/babel-types/src/definitions/jsx.d.ts","../../dts/packages/babel-types/src/definitions/misc.d.ts","../../dts/packages/babel-types/src/definitions/experimental.d.ts","../../dts/packages/babel-types/src/definitions/typescript.d.ts","../../dts/packages/babel-types/src/definitions/placeholders.d.ts","../../dts/packages/babel-types/src/definitions/deprecated-aliases.d.ts","../../dts/packages/babel-types/src/definitions/index.d.ts","../../dts/packages/babel-types/src/modifications/appendToMemberExpression.d.ts","../../dts/packages/babel-types/src/modifications/inherits.d.ts","../../dts/packages/babel-types/src/modifications/prependToMemberExpression.d.ts","../../dts/packages/babel-types/src/modifications/removeProperties.d.ts","../../dts/packages/babel-types/src/modifications/removePropertiesDeep.d.ts","../../dts/packages/babel-types/src/modifications/flow/removeTypeDuplicates.d.ts","../../dts/packages/babel-types/src/retrievers/getBindingIdentifiers.d.ts","../../dts/packages/babel-types/src/retrievers/getOuterBindingIdentifiers.d.ts","../../dts/packages/babel-types/src/traverse/traverse.d.ts","../../dts/packages/babel-types/src/traverse/traverseFast.d.ts","../../dts/packages/babel-types/src/utils/shallowEqual.d.ts","../../dts/packages/babel-types/src/validators/is.d.ts","../../dts/packages/babel-types/src/validators/isBinding.d.ts","../../dts/packages/babel-types/src/validators/isBlockScoped.d.ts","../../dts/packages/babel-types/src/validators/isImmutable.d.ts","../../dts/packages/babel-types/src/validators/isLet.d.ts","../../dts/packages/babel-types/src/validators/isNode.d.ts","../../dts/packages/babel-types/src/validators/isNodesEquivalent.d.ts","../../dts/packages/babel-types/src/validators/isPlaceholderType.d.ts","../../dts/packages/babel-types/src/validators/isReferenced.d.ts","../../dts/packages/babel-types/src/validators/isScope.d.ts","../../dts/packages/babel-types/src/validators/isSpecifierDefault.d.ts","../../dts/packages/babel-types/src/validators/isType.d.ts","../../dts/packages/babel-types/src/validators/isValidES3Identifier.d.ts","../../dts/packages/babel-types/src/validators/isValidIdentifier.d.ts","../../dts/packages/babel-types/src/validators/isVar.d.ts","../../dts/packages/babel-types/src/validators/matchesPattern.d.ts","../../dts/packages/babel-types/src/validators/validate.d.ts","../../dts/packages/babel-types/src/validators/buildMatchMemberExpression.d.ts","../../dts/packages/babel-types/src/validators/generated/index.d.ts","../../dts/packages/babel-types/src/ast-types/generated/index.d.ts","../../dts/packages/babel-types/src/utils/deprecationWarning.d.ts","../../dts/packages/babel-types/src/index.d.ts","../../dts/packages/babel-traverse/src/path/lib/virtual-types.d.ts","../babel-traverse/src/generated/visitor-types.d.ts","../../dts/packages/babel-traverse/src/types.d.ts","../../dts/packages/babel-traverse/src/visitors.d.ts","../../dts/packages/babel-traverse/src/scope/binding.d.ts","../../dts/packages/babel-traverse/src/scope/index.d.ts","../../dts/packages/babel-traverse/src/hub.d.ts","../../dts/packages/babel-traverse/src/context.d.ts","../../dts/packages/babel-traverse/src/path/ancestry.d.ts","../../dts/packages/babel-traverse/src/path/inference/index.d.ts","../../dts/packages/babel-traverse/src/path/replacement.d.ts","../../dts/packages/babel-traverse/src/path/evaluation.d.ts","../../dts/packages/babel-traverse/src/path/conversion.d.ts","../../dts/packages/babel-traverse/src/path/introspection.d.ts","../../dts/packages/babel-traverse/src/path/context.d.ts","../../dts/packages/babel-traverse/src/path/removal.d.ts","../../dts/packages/babel-traverse/src/path/modification.d.ts","../../dts/packages/babel-traverse/src/path/family.d.ts","../../dts/packages/babel-traverse/src/path/comments.d.ts","../babel-traverse/src/path/generated/asserts.d.ts","../../dts/packages/babel-traverse/src/path/lib/virtual-types-validator.d.ts","../babel-traverse/src/path/generated/validators.d.ts","../../dts/packages/babel-traverse/src/path/index.d.ts","../../dts/packages/babel-traverse/src/cache.d.ts","../../dts/packages/babel-traverse/src/index.d.ts","../../node_modules/@types/gensync/index.d.ts","../../dts/packages/babel-core/src/config/helpers/deep-array.d.ts","../../dts/packages/babel-parser/src/util/location.d.ts","../../dts/packages/babel-parser/src/tokenizer/context.d.ts","../../dts/packages/babel-parser/src/tokenizer/types.d.ts","../../dts/packages/babel-parser/src/parse-error/standard-errors.d.ts","../../dts/packages/babel-parser/src/parse-error.d.ts","../../dts/packages/babel-parser/src/tokenizer/state.d.ts","../../dts/packages/babel-parser/src/util/scopeflags.d.ts","../../dts/packages/babel-parser/src/util/scope.d.ts","../../dts/packages/babel-parser/src/util/expression-scope.d.ts","../../dts/packages/babel-parser/src/util/class-scope.d.ts","../../dts/packages/babel-parser/src/util/production-parameter.d.ts","../babel-parser/src/typings.d.ts","../../dts/packages/babel-parser/src/parser/base.d.ts","../../dts/packages/babel-parser/src/parser/util.d.ts","../../dts/packages/babel-parser/src/parser/node.d.ts","../../dts/packages/babel-parser/src/parser/comments.d.ts","../../dts/packages/babel-helper-string-parser/src/index.d.ts","../../dts/packages/babel-parser/src/tokenizer/index.d.ts","../../node_modules/@types/charcodes/index.d.ts","../../dts/packages/babel-parser/src/parser/lval.d.ts","../../dts/packages/babel-parser/src/parser/expression.d.ts","../../dts/packages/babel-parser/src/parser/statement.d.ts","../../dts/packages/babel-parser/src/plugins/placeholders.d.ts","../../dts/packages/babel-parser/src/types.d.ts","../../dts/packages/babel-parser/src/parser/index.d.ts","../../dts/packages/babel-parser/src/plugins/flow/scope.d.ts","../../dts/packages/babel-parser/src/plugins/jsx/index.d.ts","../../dts/packages/babel-parser/src/plugins/typescript/scope.d.ts","../../dts/packages/babel-parser/src/plugin-utils.d.ts","../../dts/packages/babel-parser/src/options.d.ts","../../dts/packages/babel-parser/src/index.d.ts","../../dts/packages/babel-helper-compilation-targets/src/options.d.ts","../../dts/packages/babel-helper-compilation-targets/src/targets.d.ts","../babel-helper-compilation-targets/src/types.d.ts","../../dts/packages/babel-helper-compilation-targets/src/pretty.d.ts","../../dts/packages/babel-helper-compilation-targets/src/debug.d.ts","../../dts/packages/babel-helper-compilation-targets/src/filter-items.d.ts","../../dts/packages/babel-helper-compilation-targets/src/index.d.ts","../../dts/packages/babel-core/src/config/caching.d.ts","../../dts/packages/babel-core/src/config/printer.d.ts","../../dts/packages/babel-core/src/config/files/types.d.ts","../../dts/packages/babel-core/src/config/files/package.d.ts","../../dts/packages/babel-core/src/config/files/configuration.d.ts","../../dts/packages/babel-core/src/config/files/plugins.d.ts","../../dts/packages/babel-core/src/config/files/index.d.ts","../../dts/packages/babel-core/src/config/config-chain.d.ts","../../dts/packages/babel-core/src/config/cache-contexts.d.ts","../../dts/packages/babel-core/src/config/helpers/config-api.d.ts","../../dts/packages/babel-core/src/config/config-descriptors.d.ts","../../dts/packages/babel-core/src/config/item.d.ts","../../node_modules/@types/jsesc/index.d.ts","../../node_modules/@jridgewell/trace-mapping/dist/types/sourcemap-segment.d.ts","../../node_modules/@jridgewell/trace-mapping/dist/types/types.d.ts","../../node_modules/@jridgewell/trace-mapping/dist/types/any-map.d.ts","../../node_modules/@jridgewell/trace-mapping/dist/types/trace-mapping.d.ts","../../node_modules/@jridgewell/gen-mapping/dist/types/sourcemap-segment.d.ts","../../node_modules/@jridgewell/gen-mapping/dist/types/types.d.ts","../../node_modules/@jridgewell/gen-mapping/dist/types/gen-mapping.d.ts","../../dts/packages/babel-generator/src/index.d.ts","../../dts/packages/babel-core/src/config/validation/options.d.ts","../../dts/packages/babel-core/src/config/validation/plugins.d.ts","../../dts/packages/babel-core/src/config/plugin.d.ts","../../dts/packages/babel-core/src/config/full.d.ts","../../dts/packages/babel-core/src/config/partial.d.ts","../../dts/packages/babel-core/src/config/index.d.ts","../../node_modules/@types/convert-source-map/index.d.ts","../../dts/packages/babel-core/src/transformation/normalize-file.d.ts","../../dts/packages/babel-core/src/transformation/file/file.d.ts","../../dts/packages/babel-core/src/transformation/plugin-pass.d.ts","../../dts/packages/babel-core/src/tools/build-external-helpers.d.ts","../../dts/packages/babel-core/src/config/helpers/environment.d.ts","../../dts/packages/babel-template/src/options.d.ts","../../dts/packages/babel-template/src/formatters.d.ts","../../dts/packages/babel-template/src/builder.d.ts","../../dts/packages/babel-template/src/index.d.ts","../../dts/packages/babel-core/src/transformation/index.d.ts","../../dts/packages/babel-core/src/transform.d.ts","../../dts/packages/babel-core/src/transform-file.d.ts","../../dts/packages/babel-core/src/transform-ast.d.ts","../../dts/packages/babel-core/src/parser/index.d.ts","../../dts/packages/babel-core/src/parse.d.ts","../../dts/packages/babel-core/src/index.d.ts","../../dts/packages/babel-helper-plugin-utils/src/index.d.ts","./src/index.ts","../../lib/globals.d.ts","../../scripts/repo-utils/index.d.ts","../../node_modules/@types/color-name/index.d.ts","../../node_modules/@types/debug/index.d.ts","../../node_modules/@types/eslint/helpers.d.ts","../../node_modules/@types/estree/index.d.ts","../../node_modules/@types/json-schema/index.d.ts","../../node_modules/@types/eslint/index.d.ts","../../node_modules/@types/eslint-scope/index.d.ts","../../node_modules/@types/fs-readdir-recursive/index.d.ts","../../node_modules/@types/node/assert.d.ts","../../node_modules/@types/node/assert/strict.d.ts","../../node_modules/buffer/index.d.ts","../../node_modules/undici-types/header.d.ts","../../node_modules/undici-types/readable.d.ts","../../node_modules/undici-types/file.d.ts","../../node_modules/undici-types/fetch.d.ts","../../node_modules/undici-types/formdata.d.ts","../../node_modules/undici-types/connector.d.ts","../../node_modules/undici-types/client.d.ts","../../node_modules/undici-types/errors.d.ts","../../node_modules/undici-types/dispatcher.d.ts","../../node_modules/undici-types/global-dispatcher.d.ts","../../node_modules/undici-types/global-origin.d.ts","../../node_modules/undici-types/pool-stats.d.ts","../../node_modules/undici-types/pool.d.ts","../../node_modules/undici-types/handlers.d.ts","../../node_modules/undici-types/balanced-pool.d.ts","../../node_modules/undici-types/agent.d.ts","../../node_modules/undici-types/mock-interceptor.d.ts","../../node_modules/undici-types/mock-agent.d.ts","../../node_modules/undici-types/mock-client.d.ts","../../node_modules/undici-types/mock-pool.d.ts","../../node_modules/undici-types/mock-errors.d.ts","../../node_modules/undici-types/proxy-agent.d.ts","../../node_modules/undici-types/api.d.ts","../../node_modules/undici-types/cookies.d.ts","../../node_modules/undici-types/patch.d.ts","../../node_modules/undici-types/filereader.d.ts","../../node_modules/undici-types/diagnostics-channel.d.ts","../../node_modules/undici-types/websocket.d.ts","../../node_modules/undici-types/content-type.d.ts","../../node_modules/undici-types/cache.d.ts","../../node_modules/undici-types/interceptors.d.ts","../../node_modules/undici-types/index.d.ts","../../node_modules/@types/node/globals.d.ts","../../node_modules/@types/node/async_hooks.d.ts","../../node_modules/@types/node/buffer.d.ts","../../node_modules/@types/node/child_process.d.ts","../../node_modules/@types/node/cluster.d.ts","../../node_modules/@types/node/console.d.ts","../../node_modules/@types/node/constants.d.ts","../../node_modules/@types/node/crypto.d.ts","../../node_modules/@types/node/dgram.d.ts","../../node_modules/@types/node/diagnostics_channel.d.ts","../../node_modules/@types/node/dns.d.ts","../../node_modules/@types/node/dns/promises.d.ts","../../node_modules/@types/node/domain.d.ts","../../node_modules/@types/node/dom-events.d.ts","../../node_modules/@types/node/events.d.ts","../../node_modules/@types/node/fs.d.ts","../../node_modules/@types/node/fs/promises.d.ts","../../node_modules/@types/node/http.d.ts","../../node_modules/@types/node/http2.d.ts","../../node_modules/@types/node/https.d.ts","../../node_modules/@types/node/inspector.d.ts","../../node_modules/@types/node/module.d.ts","../../node_modules/@types/node/net.d.ts","../../node_modules/@types/node/os.d.ts","../../node_modules/@types/node/path.d.ts","../../node_modules/@types/node/perf_hooks.d.ts","../../node_modules/@types/node/process.d.ts","../../node_modules/@types/node/punycode.d.ts","../../node_modules/@types/node/querystring.d.ts","../../node_modules/@types/node/readline.d.ts","../../node_modules/@types/node/readline/promises.d.ts","../../node_modules/@types/node/repl.d.ts","../../node_modules/@types/node/sea.d.ts","../../node_modules/@types/node/stream.d.ts","../../node_modules/@types/node/stream/promises.d.ts","../../node_modules/@types/node/stream/consumers.d.ts","../../node_modules/@types/node/stream/web.d.ts","../../node_modules/@types/node/string_decoder.d.ts","../../node_modules/@types/node/test.d.ts","../../node_modules/@types/node/timers.d.ts","../../node_modules/@types/node/timers/promises.d.ts","../../node_modules/@types/node/tls.d.ts","../../node_modules/@types/node/trace_events.d.ts","../../node_modules/@types/node/tty.d.ts","../../node_modules/@types/node/url.d.ts","../../node_modules/@types/node/util.d.ts","../../node_modules/@types/node/v8.d.ts","../../node_modules/@types/node/vm.d.ts","../../node_modules/@types/node/wasi.d.ts","../../node_modules/@types/node/worker_threads.d.ts","../../node_modules/@types/node/zlib.d.ts","../../node_modules/@types/node/globals.global.d.ts","../../node_modules/@types/node/index.d.ts","../../node_modules/@types/minimatch/index.d.ts","../../node_modules/@types/glob/index.d.ts","../../node_modules/@types/istanbul-lib-coverage/index.d.ts","../../node_modules/@types/istanbul-lib-report/index.d.ts","../../node_modules/@types/istanbul-reports/index.d.ts","../../node_modules/@types/jest/node_modules/@jest/expect-utils/build/index.d.ts","../../node_modules/@types/jest/node_modules/chalk/index.d.ts","../../node_modules/@sinclair/typebox/typebox.d.ts","../../node_modules/@jest/schemas/build/index.d.ts","../../node_modules/jest-diff/node_modules/pretty-format/build/index.d.ts","../../node_modules/jest-diff/build/index.d.ts","../../node_modules/@types/jest/node_modules/jest-matcher-utils/build/index.d.ts","../../node_modules/@types/jest/node_modules/expect/build/index.d.ts","../../node_modules/@types/jest/node_modules/pretty-format/build/index.d.ts","../../node_modules/@types/jest/index.d.ts","../../node_modules/@types/json5/index.d.ts","../../node_modules/@types/lru-cache/index.d.ts","../../node_modules/@types/resolve/index.d.ts","../../node_modules/@types/semver/classes/semver.d.ts","../../node_modules/@types/semver/functions/parse.d.ts","../../node_modules/@types/semver/functions/valid.d.ts","../../node_modules/@types/semver/functions/clean.d.ts","../../node_modules/@types/semver/functions/inc.d.ts","../../node_modules/@types/semver/functions/diff.d.ts","../../node_modules/@types/semver/functions/major.d.ts","../../node_modules/@types/semver/functions/minor.d.ts","../../node_modules/@types/semver/functions/patch.d.ts","../../node_modules/@types/semver/functions/prerelease.d.ts","../../node_modules/@types/semver/functions/compare.d.ts","../../node_modules/@types/semver/functions/rcompare.d.ts","../../node_modules/@types/semver/functions/compare-loose.d.ts","../../node_modules/@types/semver/functions/compare-build.d.ts","../../node_modules/@types/semver/functions/sort.d.ts","../../node_modules/@types/semver/functions/rsort.d.ts","../../node_modules/@types/semver/functions/gt.d.ts","../../node_modules/@types/semver/functions/lt.d.ts","../../node_modules/@types/semver/functions/eq.d.ts","../../node_modules/@types/semver/functions/neq.d.ts","../../node_modules/@types/semver/functions/gte.d.ts","../../node_modules/@types/semver/functions/lte.d.ts","../../node_modules/@types/semver/functions/cmp.d.ts","../../node_modules/@types/semver/functions/coerce.d.ts","../../node_modules/@types/semver/classes/comparator.d.ts","../../node_modules/@types/semver/classes/range.d.ts","../../node_modules/@types/semver/functions/satisfies.d.ts","../../node_modules/@types/semver/ranges/max-satisfying.d.ts","../../node_modules/@types/semver/ranges/min-satisfying.d.ts","../../node_modules/@types/semver/ranges/to-comparators.d.ts","../../node_modules/@types/semver/ranges/min-version.d.ts","../../node_modules/@types/semver/ranges/valid.d.ts","../../node_modules/@types/semver/ranges/outside.d.ts","../../node_modules/@types/semver/ranges/gtr.d.ts","../../node_modules/@types/semver/ranges/ltr.d.ts","../../node_modules/@types/semver/ranges/intersects.d.ts","../../node_modules/@types/semver/ranges/simplify.d.ts","../../node_modules/@types/semver/ranges/subset.d.ts","../../node_modules/@types/semver/internals/identifiers.d.ts","../../node_modules/@types/semver/index.d.ts","../../node_modules/@types/stack-utils/index.d.ts","../../node_modules/@types/v8flags/index.d.ts","../../node_modules/@types/yargs-parser/index.d.ts","../../node_modules/@types/yargs/index.d.ts"],"fileInfos":[{"version":"824cb491a40f7e8fdeb56f1df5edf91b23f3e3ee6b4cde84d4a99be32338faee","affectsGlobalScope":true},"45b7ab580deca34ae9729e97c13cfd999df04416a79116c3bfb483804f85ded4","3facaf05f0c5fc569c5649dd359892c98a85557e3e0c847964caeb67076f4d75","9a68c0c07ae2fa71b44384a839b7b8d81662a236d4b9ac30916718f7510b1b2d","5e1c4c362065a6b95ff952c0eab010f04dcd2c3494e813b493ecfd4fcb9fc0d8","68d73b4a11549f9c0b7d352d10e91e5dca8faa3322bfb77b661839c42b1ddec7","5efce4fc3c29ea84e8928f97adec086e3dc876365e0982cc8479a07954a3efd4","feecb1be483ed332fad555aff858affd90a48ab19ba7272ee084704eb7167569","5514e54f17d6d74ecefedc73c504eadffdeda79c7ea205cf9febead32d45c4bc","1c0cdb8dc619bc549c3e5020643e7cf7ae7940058e8c7e5aefa5871b6d86f44b","886e50ef125efb7878f744e86908884c0133e7a6d9d80013f421b0cd8fb2af94",{"version":"138fb588d26538783b78d1e3b2c2cc12d55840b97bf5e08bca7f7a174fbe2f17","affectsGlobalScope":true},{"version":"dc2df20b1bcdc8c2d34af4926e2c3ab15ffe1160a63e58b7e09833f616efff44","affectsGlobalScope":true},{"version":"4443e68b35f3332f753eacc66a04ac1d2053b8b035a0e0ac1d455392b5e243b3","affectsGlobalScope":true},{"version":"bc47685641087c015972a3f072480889f0d6c65515f12bd85222f49a98952ed7","affectsGlobalScope":true},{"version":"0dc1e7ceda9b8b9b455c3a2d67b0412feab00bd2f66656cd8850e8831b08b537","affectsGlobalScope":true},{"version":"ce691fb9e5c64efb9547083e4a34091bcbe5bdb41027e310ebba8f7d96a98671","affectsGlobalScope":true},{"version":"8d697a2a929a5fcb38b7a65594020fcef05ec1630804a33748829c5ff53640d0","affectsGlobalScope":true},{"version":"4ff2a353abf8a80ee399af572debb8faab2d33ad38c4b4474cff7f26e7653b8d","affectsGlobalScope":true},{"version":"93495ff27b8746f55d19fcbcdbaccc99fd95f19d057aed1bd2c0cafe1335fbf0","affectsGlobalScope":true},{"version":"6fc23bb8c3965964be8c597310a2878b53a0306edb71d4b5a4dfe760186bcc01","affectsGlobalScope":true},{"version":"ea011c76963fb15ef1cdd7ce6a6808b46322c527de2077b6cfdf23ae6f5f9ec7","affectsGlobalScope":true},{"version":"38f0219c9e23c915ef9790ab1d680440d95419ad264816fa15009a8851e79119","affectsGlobalScope":true},{"version":"bb42a7797d996412ecdc5b2787720de477103a0b2e53058569069a0e2bae6c7e","affectsGlobalScope":true},{"version":"4738f2420687fd85629c9efb470793bb753709c2379e5f85bc1815d875ceadcd","affectsGlobalScope":true},{"version":"2f11ff796926e0832f9ae148008138ad583bd181899ab7dd768a2666700b1893","affectsGlobalScope":true},{"version":"4de680d5bb41c17f7f68e0419412ca23c98d5749dcaaea1896172f06435891fc","affectsGlobalScope":true},{"version":"9fc46429fbe091ac5ad2608c657201eb68b6f1b8341bd6d670047d32ed0a88fa","affectsGlobalScope":true},{"version":"61c37c1de663cf4171e1192466e52c7a382afa58da01b1dc75058f032ddf0839","affectsGlobalScope":true},{"version":"b541a838a13f9234aba650a825393ffc2292dc0fc87681a5d81ef0c96d281e7a","affectsGlobalScope":true},{"version":"b20fe0eca9a4e405f1a5ae24a2b3290b37cf7f21eba6cbe4fc3fab979237d4f3","affectsGlobalScope":true},{"version":"811ec78f7fefcabbda4bfa93b3eb67d9ae166ef95f9bff989d964061cbf81a0c","affectsGlobalScope":true},{"version":"717937616a17072082152a2ef351cb51f98802fb4b2fdabd32399843875974ca","affectsGlobalScope":true},{"version":"d7e7d9b7b50e5f22c915b525acc5a49a7a6584cf8f62d0569e557c5cfc4b2ac2","affectsGlobalScope":true},{"version":"71c37f4c9543f31dfced6c7840e068c5a5aacb7b89111a4364b1d5276b852557","affectsGlobalScope":true},{"version":"576711e016cf4f1804676043e6a0a5414252560eb57de9faceee34d79798c850","affectsGlobalScope":true},{"version":"89c1b1281ba7b8a96efc676b11b264de7a8374c5ea1e6617f11880a13fc56dc6","affectsGlobalScope":true},{"version":"49ed889be54031e1044af0ad2c603d627b8bda8b50c1a68435fe85583901d072","affectsGlobalScope":true},{"version":"e93d098658ce4f0c8a0779e6cab91d0259efb88a318137f686ad76f8410ca270","affectsGlobalScope":true},{"version":"063600664504610fe3e99b717a1223f8b1900087fab0b4cad1496a114744f8df","affectsGlobalScope":true},{"version":"934019d7e3c81950f9a8426d093458b65d5aff2c7c1511233c0fd5b941e608ab","affectsGlobalScope":true},{"version":"bf14a426dbbf1022d11bd08d6b8e709a2e9d246f0c6c1032f3b2edb9a902adbe","affectsGlobalScope":true},{"version":"5e07ed3809d48205d5b985642a59f2eba47c402374a7cf8006b686f79efadcbd","affectsGlobalScope":true},{"version":"2b72d528b2e2fe3c57889ca7baef5e13a56c957b946906d03767c642f386bbc3","affectsGlobalScope":true},{"version":"8073890e29d2f46fdbc19b8d6d2eb9ea58db9a2052f8640af20baff9afbc8640","affectsGlobalScope":true},{"version":"368af93f74c9c932edd84c58883e736c9e3d53cec1fe24c0b0ff451f529ceab1","affectsGlobalScope":true},{"version":"af3dd424cf267428f30ccfc376f47a2c0114546b55c44d8c0f1d57d841e28d74","affectsGlobalScope":true},{"version":"995c005ab91a498455ea8dfb63aa9f83fa2ea793c3d8aa344be4a1678d06d399","affectsGlobalScope":true},{"version":"51e547984877a62227042850456de71a5c45e7fe86b7c975c6e68896c86fa23b","affectsGlobalScope":true},{"version":"956d27abdea9652e8368ce029bb1e0b9174e9678a273529f426df4b3d90abd60","affectsGlobalScope":true},{"version":"4fa6ed14e98aa80b91f61b9805c653ee82af3502dc21c9da5268d3857772ca05","affectsGlobalScope":true},{"version":"e6633e05da3ff36e6da2ec170d0d03ccf33de50ca4dc6f5aeecb572cedd162fb","affectsGlobalScope":true},{"version":"d8670852241d4c6e03f2b89d67497a4bbefe29ecaa5a444e2c11a9b05e6fccc6","affectsGlobalScope":true},{"version":"8444af78980e3b20b49324f4a16ba35024fef3ee069a0eb67616ea6ca821c47a","affectsGlobalScope":true},{"version":"caccc56c72713969e1cfe5c3d44e5bab151544d9d2b373d7dbe5a1e4166652be","affectsGlobalScope":true},{"version":"3287d9d085fbd618c3971944b65b4be57859f5415f495b33a6adc994edd2f004","affectsGlobalScope":true},{"version":"50d53ccd31f6667aff66e3d62adf948879a3a16f05d89882d1188084ee415bbc","affectsGlobalScope":true},{"version":"08a58483392df5fcc1db57d782e87734f77ae9eab42516028acbfe46f29a3ef7","affectsGlobalScope":true},{"version":"436aaf437562f276ec2ddbee2f2cdedac7664c1e4c1d2c36839ddd582eeb3d0a","affectsGlobalScope":true},{"version":"b1cb28af0c891c8c96b2d6b7be76bd394fddcfdb4709a20ba05a7c1605eea0f9","affectsGlobalScope":true},{"version":"13f6e6380c78e15e140243dc4be2fa546c287c6d61f4729bc2dd7cf449605471","affectsGlobalScope":true},{"version":"15b98a533864d324e5f57cd3cfc0579b231df58c1c0f6063ea0fcb13c3c74ff9","affectsGlobalScope":true},{"version":"ac77cb3e8c6d3565793eb90a8373ee8033146315a3dbead3bde8db5eaf5e5ec6","affectsGlobalScope":true},{"version":"d4b1d2c51d058fc21ec2629fff7a76249dec2e36e12960ea056e3ef89174080f","affectsGlobalScope":true},{"version":"2fef54945a13095fdb9b84f705f2b5994597640c46afeb2ce78352fab4cb3279","affectsGlobalScope":true},{"version":"33358442698bb565130f52ba79bfd3d4d484ac85fe33f3cb1759c54d18201393","affectsGlobalScope":true},{"version":"782dec38049b92d4e85c1585fbea5474a219c6984a35b004963b00beb1aab538","affectsGlobalScope":true},"b360236d3b226a56126f9f071d68fccd10eba34e4b6831efc39e8a3277380523","a73bd08ca8f85d9c1f0307ae7abb246e38cb618f452e15fd3612464e846665b0","9b1b103c34f4c56ab0c40c87a85ffd36002295d8fbe17b493509e63a383f5814","e4a023723ff5cfdc22880b572dd15876d0bc4bb4f2a555d71d226a2578786ad3","3aa0ae0c3636319f9bc6e5c2a4bd484f9b2b4e78623b33131056a95fb59c954c","dc25e664429b44c379d4d3cf988b2cce06116ae94f5c6f1a0cf73245b4282a93","e59daf03ff2d76dee4726e48556aba1d105fd1c7a7a9cbf3e74ec4a1f91a6bea","250bb1ea2d799ecf488834fe20efa611063ab79b35639b7b3024f05e1b6641ee","a0fbfc839fefc3d41a12c5a8631e6543135ff18fd516cd06c5a09f84cb81578c","9ce376fdbe50ed84260f0dc45cc1f242916f2c0c91da6464df63df0ba2baae7c","c3e41c24eb14414b6995d4bbac99d16ce2e609282c9b53d1333b7b423e0f7d02","b555d22a622ea0565d08a340e5c19f6f439f40d4451a2f13fe6a33a39b3d761c","9f29212a64599c6c5563b78746bf85f709d5437f18dac77502a53af63dadb850","6b714d7db731bb6da813dfa3d88ded4ce0bc9b627464e86315468e1be9adadff","5ebd0c7b976b7cbe390e381d27ec9dc5adde1a02cf9ecfb2a7caed7a822a5cae","4171247c72f90ac86a3cd3cdb0f372214a556aa8b94aa92b28bf6d21dad5f7ee","b8b9aae5a37c0d3dec11813d992b893ed55a080289466ade6c1bc47e3987f53a","eb69d4cd5875c471c0dd30988bf8a4816f9b8fab1e71a8c39096e483411faa00","48225779dd7b1b7b384389e325ed6aa271a6745239d8193c2fc161cacbf3dac5","c6fd0f9d777f11f972b4decc52beeeae6aad9f2aa949184e8f9984a5c36e4448","3f4487628af3e52556d6f33151740876b29a5355b8a5ccf8e56d1b3ae7cbcc0e","2b4ca439136421892cc80ebf6f6ea641a0306e58bd12ed61ae7f20becb2ee15f","6296c7ce17d3115c72d6757513e79ea0f74b76f49e0138f78f37685fc1bc83f8","ce8fe0d07c32e6786203b5a3b93468afc6b1fcf57481dc9673e16fb119312c19","dfa94dabc1567d2b882222947f5c181adc89a3af5b6a2b730b1c3b85d4cfe48f","c33fa94c2e88d70a2e98a33474d3cf477d959477236323a748f638b3ca1e2af0","058e39e6fe02e97ddc18b2952a67d0dfb71f1f60f86405480fec569b602f5284","8c5dbef5fc0eb113d94132a5ba440d75e33eb85e9497a1f7e3bdb29a3fcd3469","0d9808e1f0d2bd4c45462c7e2f20c0cf08b700c6964e7eda5e10d1f6b707deb8","9f3f8ff5d06c5d5583e891d3bb98489d58e358e49bda2827f3f7819cdb632ad0","6978b8fc2f45108c4bc2788bd7053f2917d7efa28f74ddf52182dc9ab59d03cf","f4e40380711ea1048d9e9654dcf25cde7301571a98c9aceef4d3c71c02fd9d14","77adbafe67e2bf42d578d82d2fb994530cce5b9eaa28a2a5b24aca70a008c3d9","1cf9b232eeb34d97f2f27f3dac1a0164bcc852a4b7b86a1d7ebc1c9807e3a2cf","7d2a0764991446f121b01e690edcb502ce40fd02145613d1d349d9e46be3782a","8e609bb71c20b858c77f0e9f90bb1319db8477b13f9f965f1a1e18524bf50881","8e609bb71c20b858c77f0e9f90bb1319db8477b13f9f965f1a1e18524bf50881","8e609bb71c20b858c77f0e9f90bb1319db8477b13f9f965f1a1e18524bf50881","8e609bb71c20b858c77f0e9f90bb1319db8477b13f9f965f1a1e18524bf50881","8e609bb71c20b858c77f0e9f90bb1319db8477b13f9f965f1a1e18524bf50881","513e4a7dd68f60782a39d5ae4ce6f0a19ccc4c51808b359560ad1f689f0ce93d","519157309e4f7c98b6067933db2a849961eaa0e5dec4a2ce5d2fc92ace85dcfd","c5f8672c8c39b8f9251a57fc2dab217ce20ac4a9d71c0a498b733cb922ff5e4e","82590ca2dfa968af29be579c534733406fd9c5c4a726213eef9f2308cbb04d23","e88043fb3ae0a6e33be31d45927494ed42c3263bfb318b024b9dab027f09dc2d","3f7e6d7b1d7155d68b5ec0f8e021f10075c785b29171d1d520d0b9b0dd617aa0","7571f6e856945cea6771a2985e008daff8785c6632f9dc1dc9f24f795f84444d","2ff5e66c8448d86302ef11ceeb27cbbd43d3af41aba05c2fc3a48cd0f1d8627f","a73d8151dd40ff705eebd2989e703ba14874574f5fe4f195babe74b6ef93ac59","1577b898eb3bebb6cebf1e5228552c8cc68fa010cb7b035ffe8eb5b558d35434","23996dceac72973064c9643fff1ca0cf585b642d715c56ed3512703f2b280c5e","95a1a8e1e7777214b2d970c3426819e976abf9120f2824b571e0ae51d1dd465b","11f45261b54dd91ac1dea5f299945e70225b4cf7a756f03190e88660aa310673","e1bb914c06cc75205fae8713e349dff14bdfd2d36c784d0d2f2b7b5d37e035e0","a5e89e63c809c01f8e8175c9d63da68ce734ddf15b7efd98b1eb262d8e4d05ec","466c63574f0654a81f7d760ccb32570f642b6b46e83b6fdc288c2e52bcef287c","c6526b7ad3213f40e40d617f0a150c8a9dcf0e8f868594ef4aa060b994fd11ce","b5e0565b7ca3ba4c129ed4e1788d4dc1bb30dcdeb14a37df1071c3881507e295","08cdf95dfc59101c1e7c23865951151455ee7f77f1bf7e257034aae8ba332972","4924f889957ee69dfd66643c7e60a5feee526c18b16d10985804c669fe1b6ce4","2c95044092cad1398b593b47290306d73513d163c61e85ebbc39715af4b15578","66612e3b3315adf8702a39830ad8690d6f4293f89193737c604f4b44a51e42ad","1d3f6521348f5d591d4da3408457a553274b024c79ecde88054361040967c211","03a629914760ae9bb64a05e72ad0f4e6aeefb1e7c7b6ae3d7836bb46f69ae23e","95017b0f25bb3cd6782853c14303c20b5099b866ef1491c57fc436add8183f14","989f035cd0c3acf51639b2ff4fb3cb8ccce3d7ef0103a1d32ca5e5f1cfd19387","9dfbdb5529d2be1c9e77112f7e0e20fba7518865f31501b9aa09c3965ee91f6a","9ba02d6560cc8cf8063172ba05b5368a24fb236a97c1c852665372be78143592","cafadd60cda0c63471975430893f7c0ac981f268ec719f08f131e41d8404c4db","6a7a221f94f9547a86feaa3c2ce81b8556c71ffb12057a43c54fc975bca83cde","156d025e006f7df4df1bcf7ce53cd3e3780a0190dfb03c65288f07b372e79843","e34a316302189537858d6d20d5d77d8f0351ed977da8947a401ad9986cdf147f","243665975c1af5dc7b51b10f52e76d3cb8b7676ccc23a6503977526d94b3cdde","3a91334c3409e173cafb3af175d8a4a3ae835851df7015c8f0fc5c117ad46c80","bfe8f5184c00e9c24f8bb40ec929097b2cafc50cc968bc1604501cb6c4a1440c","98c7850cf7a5bca4267e71403e8a2788c29543b15ac7354d1211a7accba496c8","f31ab9295985d01c5837c9bdc422643f6f73293cfd103738774b7cfb340566cc","99392e1e600259c50f21f691f136a4ecbee42839dbb9523384f09645c8756503","5c5d100793c0fb9b34076189904df18f3321e82cadf6f69815926104029c215b","051191f8664727f9b9caa72166559b734e126d18ef377c3f4c3343672ea4d307","1079472c5e1f65ce739fb777054e2f539e9b50a97b438c0d6e56c4ee23be8bff","d0b3a40cbe16c8852d1327fb804995193fb853d7da9c7ab9c02cce85090e0637","c67208e9da4af7a50bfb75d07691326052d6ed8f3b577ece8b02cd425c9d632f","4f9a4bb30bc97017c72a600c0161962d8f74488d1cd93669e4adbce7e611e0de","8dec4b9028cc8905caa6b52a395786d7f49a10d61f6be869b59ae007dc5e0cdf","f952c9c19048db8b25e3fa8e48e2213c18d3fdbef6ac168e9fae6632ed58245f","92438df2330b4b55da8e9b7d66e77258a090d67388e3f649b43f81685fecc788","866c1b69a53d80383cb5eef0ce2760ad8d028c771fa45776426a583c56a23746","8b433fd18d5bac931c1d7c07c17a830475e0fcb224d144cfeb3ba4d1da198687","e772bc828730ee913e19f58bb18b7733ebce8a3f06cdce847cb33275343a6ecd","466f4f5da14b6046570025129a7e5ea168164572c9b2da45bdc7274e0e303dbd","00222577eecd6c1fc72150006351fc6e1b5bb3aaf78097e40ecac8b8343a7598","b398ff53792dee3ca93e1f96cee63fc123811631f3c99f1c22cd01b3b2e4d6c5","3b1765aafca023ad58d5aa017800e1f2e7ee95130c9a1e7d86d5019f45c756bc","e675dc45ca604b7a6fea16448050b34cf0fe86c2f9fa50f3911fb4153b42c186","d3e56e0f84e1d1843369533f50918cce5925129e99e9ca14c7cc35ad94b2a052","dfedb6704555de21c30e98a8decf8a6d31dde1d8403b9b95944a1d317379c7ae","7102463bc898ac4cfd90675e679cdd8e1a1b6f44702b280f9c99b93f206ae570","9e32769c1c227890877cc9df961c4c7c9d839af6719e30496511b102483ac266","57e73f1c6da39bcf9429f52c39b6fc34eef11547fbb5a2be91836517ec746957","c639f1bf7b898c8fdc3bd5c05c25254f2bbf363d5fac0a5379ead6c7733be40e","bde8c75c442f701f7c428265ecad3da98023b6152db9ca49552304fd19fdba38","81af40a2264a5a56f71b8c45ff1717b50c5f0c00dd091410b12dc970ee340120","b10974251ad16a97b357ec50f87455c4430e7f0790f7b399564c900e4ebf87f1","234123959236555e336e4efcd7aa203ac1d5370ee5d891dcfc5828d996b28f59","b59756cf12284e6136e042f322af2e22664e1fd46f713b1dd3abb1740719b732","62b65c635a282ea4855cd6a9b968527cbab364c38410ea432f63c5c591db9072","2fe38d259b120889a148c6080d3c265dc8ee9579e4152b42f625fd0440fea92d","cbe5a7a02fb93f47d7948fb8dea8792f962b51657b63532ba3c67036d3c0a618","6131967512c4d205c32f126ef7415453f0c715bf53c7175d6deecb72d76a75b5","4e38f7bd172e7549c323610cfede12644c116581dfc4d751998d301eda9573e6","5b6b2f9d19c9e7f105f95aa0fbddd9b267d120f5c5e7d0ca3ae507fe2a7e4690","d8288a8eb14187b0df133ce467216d61d9ffe838ae5930471f476a5c36141828","70ae92a852a67db5b841a7ee3e9d16df7c06320ab86dbf2d5dbd9d76f3c98faa","e58a0a0add3feea2c936af4933dae5710f6c41e91468e22d880054afaa47b782","ead85b2d6cd6e6deb144a0995896c0ca7423820c66cc00e416e66733d2932985","63ac518dfd7a9ebe99c2dd882e06f9e42100365d0a7bbed4a505251205f836ef","6b4d9c91ed03e7afd40fa045042fcb7a6250b8dbe242154f3c4b948a99c74a9d","8b37c18f85644a1c666705bb5c233850cac84d8863c19870a8ed5f8d69c68800","186139eb9963554412f6fb33b35aabee1acdaa644b365de5c38fbd9123bdbe45","efd01e5afd2db9bafe6b8c1a20cff2f3c5a4870b3bf80a64c08b7d95aafba558","b7589677bd27b038f8aae8afeb030e554f1d5ff29dc4f45854e2cb7e5095d59a","220bc2f85b04326fd70de47faaa003666bc864e55f00543fdffa7b7f75d4dcdd","4a554afd8a11ad65a0f8878ebeddf6793c6775b1edbb14360bd47252840e051c","0b8d888249c93a341fc1b943a67e969e8b75f83684a042cf30643043b843a16c","514fd813d204c862172075c7fce693e3ecceeca29892ac03bd7eb73d8b15922b","bf927c7f866e845e082d906b2b18aa2a9c1c309f404dbf9794c9acb0f30dbcdd","46016bfbc77b4f13e3d6730535d9943f42575c3a228190cecaffa891999a87de","e4aa4e8d3eb4c67b64962344ef3388a8cd607821ba619c9379b36316db65c9ac","b2acd3819265517bba0edf9110e2835abb366fe28ebc378d32a2781cd459f261","635ca94290fa45a56e53ffadd3b897a42650fd4ab0ddc241392e4dc729bf496b","6aeba9874c3b08a3aa917efcbe1c5aea742dbac78b59a6a2089e092208806e8d","02519cdd247317de0bfdc78d88b5497d9747e1b9d1297283a0fea8ab3787f6ab","53989e09bc0b6b46a3c4597e5147a9b989f1f66f33ce7375b92d28139977e748","abae244b376437bfe2f0fdd1bd8925e2c235d10336ba08aec4330b800582ccbb","7da12c50edd45d08ae7f93183d0f88ab9753386ce060d1765926ffbe7c6491c2","1a8397f1c9125fc54db823eb6509221b841dd6f0c82a78997033a4a09fb1c86d","176d3525152384c3f7312b308c8af7b17690f8ec34e0788e6aaae548180f1941","6b34e6bdec80f7af4912497afb8455cd88ae1d6442d042c6663176b9927b69d4","41113f7f4529f81a16bae03c06bbd3c95146a4f7c8173ecafd6869fd1e97ed0b","c980191d2838b122a340074b58c566fddbc29a44bb57170671ac5034373c49a1","378871d06cbd514fe945b69a7be3cabe210139a5b2b3917a306ef8102afdd5bd","3bf0df1a6a59b16d43f97efd5bddcb376a3a3d66ecbe92a4dd80a0f81be6a009","49bf06ea475ae5c78e69f7af3c7e09e00af57750aa1e37c120aaad92fd8a8ab2","f8fc87c8c6822986fa509a62a0caed5cbf05f3f84d82fbbdb01a9e94aebfb2ec","60c51e31434ccc777c3d67ccc96892dd7e634816fb9fa5dc86e15d72de96ab3d","0737161a05160e848162b2abba07c4e867f415362187b810f4b6764d2626d021","69815e9eb00baef2634457bcf4952f69062d764211914619c6922dfa7760f8d2","444399b4f2fead080a55b82f86bf653a072a9f117042edc9a0fa69366672b418","d6ab7f2b45d4aa62ad21199fbb3105151a9dd4830d138a3bb3eab1e76eef9e45","56827baba9ab2b370c919b1858068e11f10a73d80dca8cb2467d2d1446fab073","14e8ace73d1c323c91aba5ac952d348943e753119ca8aed37b57c10eca3dab0b","1f689148e10f8b1a418c3f7f27496bd172e77009921b1f668cb701a8ffad8e0c","84a805c22a49922085dc337ca71ac0b85aad6d4dba6b01cee5bd5776ff54df39","971f12a5fc236419ced0b7b9f23a53c1758233713f565635bbf4b85e2b23f55a","9d670bb3be18ea59cea824e3bb07d576b55c9542f5bc24aacc2a3c1ebd889de6","695b586df2d8c78b78cdd7cc6943594f3f4bc52948f13b31cdedfa3ce8d97c31","0771a93ef5e3b2a29f929c20f7ad232829341a671c9d1e96e93ef3fc42ef7bc2","cadb68b67b80b14a9a5bb64cce3093168fb2bfe2c7b10096d230df5203218de1","0b3c75be13f930b46117e205d900ee9c4f2ad6c7317655bca5364958ba1e34f0","5af161220fdf46730477706e8c431ccbd1b4ff50223cb32450bc20513f50bfbd","be797449825edee1716d3e0c8d7ae53955b8944437cb4d0b4123a32778621228","ba9c10476a9a3d9a88b68877c12f58d35b10c1146e1ec20d397cc88699d09153","83a3a4f21e36ee920e819ac865badd30bf258361e7a224d1fb134a5524f55a0f","0e444a71d6132e54059d824b0aec770d24b467ec7380f64fb030a538ddf0f913","db18c2ffebf4c7f8d5ebb8f2541bc30bbb4f6cacebb42a5a9742ae883fd583e1","a22722f2344d703cdcc5ada42cbf84890ef527a2a6e9154fab5ddb362e64b955","866041185b44ade1456dc03de3dc85aad9c2b02dfd92d7f2068d46e28ea66201","13d94ac3ee5780f99988ae4cce0efd139598ca159553bc0100811eba74fc2351","48864a43f6c1032cb3fb5bfac020d4b2919791f49d8f31ff18f2dd3d4816005f","975a13b0ded262c522be36ed51dfd394434acd410f642bc269d0a1d7feb6b7dd","838447eba0348ee8d9801eaeff74def53d41e681a387cb2278c9f369a4fba8f2","220c93cd694e27d77b91f874f31e92d7514aa808fd95768b64552693043d00b9","380543b1b41b88e3a6294b8419d5ed323c5da3a3051ab4a1d5677f525ee30698","269ee735294e8c328681830ae7fdf4aea6c24032f0541d76c914aac9afadda5c","23a790e87430f6bcf8dfbc4d3560e8b3d7441f9cfbe509bcf932b4608c60c9e3","7a8b858660503a4af876541f456b2cbc3d89b164ab842c7434ac0fb87ec0e026","eb1e3b36ed3aac2811786d5716a16c1f8bd1fcb62b524a3bb3d602db9f55e75a","f571e28d70c04d1ce72673771010febae11d2c907a71d027550d986ee424951d","ae4f0f443b828f28aaf843856dd25a8ab5e400f99581778f8977011c4a72d70d","cf5ba84fd9488f0ba7e302d54d1db6452b513d8573df389dd05f4153f5edfc26","64ec4840e09c2f03bc97e86f6fbc5aac99bb6a067f20e06dc186a3784aba2862","640331bbaecab0948b9a40fc903666f103e94764cdfb0822d4124c147246c19a","dc29fe834b87d0d015c40a9f294ec7e1f2b7b322f102264e34374c8ea5ecffe6","46ab6033b2f210e498f5147c87b465aa564d1b9f64a431dd70b3f4f7cc5d6647","8f5173c0244c0e24737a51b649a07df75416d93a7cd9aa1ee3753c9b7825e423",{"version":"1fb0958978b61b4df146b392d377df53b1f89e564881077250107e35405a344e","signature":"79dc93e6e3b4e942b93ce5227e79a1c2c8284582d144d361cf5c09a87de4c71f"},{"version":"f0b6690984c3a44b15740ac24bfb63853617731c0f40c87a956ce537c4b50969","affectsGlobalScope":true},"77ac76cd081746189b8a6c047e0b5b40c8bfb5747fe1baea8550b4f3b9c9fd3d","f0cb4b3ab88193e3e51e9e2622e4c375955003f1f81239d72c5b7a95415dad3e","3cf5f191d75bbe7c92f921e5ae12004ac672266e2be2ece69f40b1d6b1b678f9",{"version":"64d4b35c5456adf258d2cf56c341e203a073253f229ef3208fc0d5020253b241","affectsGlobalScope":true},"ee7d8894904b465b072be0d2e4b45cf6b887cdba16a467645c4e200982ece7ea","f3d8c757e148ad968f0d98697987db363070abada5f503da3c06aefd9d4248c1","0c5a621a8cf10464c2020f05c99a86d8ac6875d9e17038cb8522cc2f604d539f","e050a0afcdbb269720a900c85076d18e0c1ab73e580202a2bf6964978181222a","1d78c35b7e8ce86a188e3e5528cc5d1edfc85187a85177458d26e17c8b48105f","acdc9fb9638a235a69bd270003d8db4d6153ada2b7ccbea741ade36b295e431e","7394959e5a741b185456e1ef5d64599c36c60a323207450991e7a42e08911419","818f832a8e29ca7e128dcde810a9ff8cbc3754010474e29fff0a5ed95adae032","5929864ce17fba74232584d90cb721a89b7ad277220627cc97054ba15a98ea8f","7180c03fd3cb6e22f911ce9ba0f8a7008b1a6ddbe88ccf16a9c8140ef9ac1686","25c8056edf4314820382a5fdb4bb7816999acdcb929c8f75e3f39473b87e85bc","54cb85a47d760da1c13c00add10d26b5118280d44d58e6908d8e89abbd9d7725","3e4825171442666d31c845aeb47fcd34b62e14041bb353ae2b874285d78482aa","c6fd2c5a395f2432786c9cb8deb870b9b0e8ff7e22c029954fabdd692bff6195","a967bfe3ad4e62243eb604bf956101e4c740f5921277c60debaf325c1320bf88","e9775e97ac4877aebf963a0289c81abe76d1ec9a2a7778dbe637e5151f25c5f3","471e1da5a78350bc55ef8cef24eb3aca6174143c281b8b214ca2beda51f5e04a","cadc8aced301244057c4e7e73fbcae534b0f5b12a37b150d80e5a45aa4bebcbd","385aab901643aa54e1c36f5ef3107913b10d1b5bb8cbcd933d4263b80a0d7f20","9670d44354bab9d9982eca21945686b5c24a3f893db73c0dae0fd74217a4c219","db3435f3525cd785bf21ec6769bf8da7e8a776be1a99e2e7efb5f244a2ef5fee","c3b170c45fc031db31f782e612adf7314b167e60439d304b49e704010e7bafe5","40383ebef22b943d503c6ce2cb2e060282936b952a01bea5f9f493d5fb487cc7","4893a895ea92c85345017a04ed427cbd6a1710453338df26881a6019432febdd","3a84b7cb891141824bd00ef8a50b6a44596aded4075da937f180c90e362fe5f6","13f6f39e12b1518c6650bbb220c8985999020fe0f21d818e28f512b7771d00f9","9b5369969f6e7175740bf51223112ff209f94ba43ecd3bb09eefff9fd675624a","4fe9e626e7164748e8769bbf74b538e09607f07ed17c2f20af8d680ee49fc1da","24515859bc0b836719105bb6cc3d68255042a9f02a6022b3187948b204946bd2","33203609eba548914dc83ddf6cadbc0bcb6e8ef89f6d648ca0908ae887f9fcc5","0db18c6e78ea846316c012478888f33c11ffadab9efd1cc8bcc12daded7a60b6","89167d696a849fce5ca508032aabfe901c0868f833a8625d5a9c6e861ef935d2","e53a3c2a9f624d90f24bf4588aacd223e7bec1b9d0d479b68d2f4a9e6011147f","339dc5265ee5ed92e536a93a04c4ebbc2128f45eeec6ed29f379e0085283542c","9f0a92164925aa37d4a5d9dd3e0134cff8177208dba55fd2310cd74beea40ee2","8bfdb79bf1a9d435ec48d9372dc93291161f152c0865b81fc0b2694aedb4578d","2e85db9e6fd73cfa3d7f28e0ab6b55417ea18931423bd47b409a96e4a169e8e6","c46e079fe54c76f95c67fb89081b3e399da2c7d109e7dca8e4b58d83e332e605","d32275be3546f252e3ad33976caf8c5e842c09cb87d468cb40d5f4cf092d1acc","4a0c3504813a3289f7fb1115db13967c8e004aa8e4f8a9021b95285502221bd1",{"version":"a14ed46fa3f5ffc7a8336b497cd07b45c2084213aaca933a22443fcb2eef0d07","affectsGlobalScope":true},"cce1f5f86974c1e916ec4a8cab6eec9aa8e31e8148845bf07fbaa8e1d97b1a2c",{"version":"7fd7fcbf021a5845bdd9397d4649fcf2fe17152d2098140fc723099a215d19ad","affectsGlobalScope":true},"df3389f71a71a38bc931aaf1ef97a65fada98f0a27f19dd12f8b8de2b0f4e461","d69a3298a197fe5d59edba0ec23b4abf2c8e7b8c6718eac97833633cd664e4c9",{"version":"a9544f6f8af0d046565e8dde585502698ebc99eef28b715bad7c2bded62e4a32","affectsGlobalScope":true},"a40826e8476694e90da94aa008283a7de50d1dafd37beada623863f1901cb7fb",{"version":"8b809082dfeffc8cc4f3b9c59f55c0ff52ba12f5ae0766cb5c35deee83b8552e","affectsGlobalScope":true},"bd3f5d05b6b5e4bfcea7739a45f3ffb4a7f4a3442ba7baf93e0200799285b8f1","4c775c2fccabf49483c03cd5e3673f87c1ffb6079d98e7b81089c3def79e29c6","d4f9d3ae2fe1ae199e1c832cca2c44f45e0b305dfa2808afdd51249b6f4a5163","7525257b4aa35efc7a1bbc00f205a9a96c4e4ab791da90db41b77938c4e0c18e","b7fe70be794e13d1b7940e318b8770cd1fb3eced7707805318a2e3aaac2c3e9e",{"version":"ee1ee365d88c4c6c0c0a5a5701d66ebc27ccd0bcfcfaa482c6e2e7fe7b98edf7","affectsGlobalScope":true},{"version":"9c611eff81287837680c1f4496daf9e737d6f3a1ff17752207814b8f8e1265af","affectsGlobalScope":true},"fe1fd6afdfe77976d4c702f3746c05fb05a7e566845c890e0e970fe9376d6a90","b5d4e3e524f2eead4519c8e819eaf7fa44a27c22418eff1b7b2d0ebc5fdc510d","afb1701fd4be413a8a5a88df6befdd4510c30a31372c07a4138facf61594c66d","9bd8e5984676cf28ebffcc65620b4ab5cb38ab2ec0aac0825df8568856895653","396a8939b5e177542bdf9b5262b4eee85d29851b2d57681fa9d7eae30e225830","5e8dc64e7e68b2b3ea52ed685cf85239e0d5fb9df31aabc94370c6bc7e19077b",{"version":"ea455cc68871b049bcecd9f56d4cf27b852d6dafd5e3b54468ca87cc11604e4d","affectsGlobalScope":true},"c07146dbbbd8b347241b5df250a51e48f2d7bef19b1e187b1a3f20c849988ff1","45b1053e691c5af9bfe85060a3e1542835f8d84a7e6e2e77ca305251eda0cb3c","0f05c06ff6196958d76b865ae17245b52d8fe01773626ac3c43214a2458ea7b7",{"version":"ae5507fc333d637dec9f37c6b3f4d423105421ea2820a64818de55db85214d66","affectsGlobalScope":true},{"version":"46755a4afc53df75f0bfce72259fb971daac826b0cdd8c4eaccad2755a817403","affectsGlobalScope":true},"8abd0566d2854c4bd1c5e48e05df5c74927187f1541e6770001d9637ac41542e","54e854615c4eafbdd3fd7688bd02a3aafd0ccf0e87c98f79d3e9109f047ce6b8","d8dba11dc34d50cb4202de5effa9a1b296d7a2f4a029eec871f894bddfb6430d","8b71dd18e7e63b6f991b511a201fad7c3bf8d1e0dd98acb5e3d844f335a73634","01d8e1419c84affad359cc240b2b551fb9812b450b4d3d456b64cda8102d4f60","9eece5e586312581ccd106d4853e861aaaa1a39f8e3ea672b8c3847eedd12f6e","8221b00f271cf7f535a8eeec03b0f80f0929c7a16116e2d2df089b41066de69b","269929a24b2816343a178008ac9ae9248304d92a8ba8e233055e0ed6dbe6ef71","93452d394fdd1dc551ec62f5042366f011a00d342d36d50793b3529bfc9bd633","7fa32887f8a97909fca35ebba3740f8caf8df146618d8fff957a3f89f67a2f6a","9a9634296cca836c3308923ba7aa094fa6ed76bb1e366d8ddcf5c65888ab1024",{"version":"bddce945d552a963c9733db106b17a25474eefcab7fc990157a2134ef55d4954","affectsGlobalScope":true},{"version":"7052b7b0c3829df3b4985bab2fd74531074b4835d5a7b263b75c82f0916ad62f","affectsGlobalScope":true},"aa34c3aa493d1c699601027c441b9664547c3024f9dbab1639df7701d63d18fa","4b55240c2a03b2c71e98a7fc528b16136faa762211c92e781a01c37821915ea6","7c651f8dce91a927ab62925e73f190763574c46098f2b11fb8ddc1b147a6709a","7440ab60f4cb031812940cc38166b8bb6fbf2540cfe599f87c41c08011f0c1df",{"version":"94c086dff8dbc5998749326bc69b520e8e4273fb5b7b58b50e0210e0885dfcde","affectsGlobalScope":true},{"version":"f5b5dc128973498b75f52b1b8c2d5f8629869104899733ae485100c2309b4c12","affectsGlobalScope":true},"ebe5facd12fd7745cda5f4bc3319f91fb29dc1f96e57e9c6f8b260a7cc5b67ee","79bad8541d5779c85e82a9fb119c1fe06af77a71cc40f869d62ad379473d4b75","21c56c6e8eeacef15f63f373a29fab6a2b36e4705be7a528aae8c51469e2737b",{"version":"629d20681ca284d9e38c0a019f647108f5fe02f9c59ac164d56f5694fc3faf4d","affectsGlobalScope":true},"e7dbf5716d76846c7522e910896c5747b6df1abd538fee8f5291bdc843461795",{"version":"ab9b9a36e5284fd8d3bf2f7d5fcbc60052f25f27e4d20954782099282c60d23e","affectsGlobalScope":true},"a42be67ed1ddaec743582f41fc219db96a1b69719fccac6d1464321178d610fc","8841e2aa774b89bd23302dede20663306dc1b9902431ac64b24be8b8d0e3f649","fd326577c62145816fe1acc306c734c2396487f76719d3785d4e825b34540b33","9e951ec338c4232d611552a1be7b4ecec79a8c2307a893ce39701316fe2374bd","70c61ff569aabdf2b36220da6c06caaa27e45cd7acac81a1966ab4ee2eadc4f2","905c3e8f7ddaa6c391b60c05b2f4c3931d7127ad717a080359db3df510b7bdab","6c1e688f95fcaf53b1e41c0fdadf2c1cfc96fa924eaf7f9fdb60f96deb0a4986","0d14fa22c41fdc7277e6f71473b20ebc07f40f00e38875142335d5b63cdfc9d2","c085e9aa62d1ae1375794c1fb927a445fa105fed891a7e24edbb1c3300f7384a","f315e1e65a1f80992f0509e84e4ae2df15ecd9ef73df975f7c98813b71e4c8da","5b9586e9b0b6322e5bfbd2c29bd3b8e21ab9d871f82346cb71020e3d84bae73e","3e70a7e67c2cb16f8cd49097360c0309fe9d1e3210ff9222e9dac1f8df9d4fb6","ab68d2a3e3e8767c3fba8f80de099a1cfc18c0de79e42cb02ae66e22dfe14a66","6d969939c4a63f70f2aa49e88da6f64b655c8e6799612807bef41ccff6ea0da9","5b9586e9b0b6322e5bfbd2c29bd3b8e21ab9d871f82346cb71020e3d84bae73e",{"version":"46894b2a21a60f8449ca6b2b7223b7179bba846a61b1434bed77b34b2902c306","affectsGlobalScope":true},"96d14f21b7652903852eef49379d04dbda28c16ed36468f8c9fa08f7c14c9538","6d727c1f6a7122c04e4f7c164c5e6f460c21ada618856894cdaa6ac25e95f38c","8baa5d0febc68db886c40bf341e5c90dc215a90cd64552e47e8184be6b7e3358","cf3d384d082b933d987c4e2fe7bfb8710adfd9dc8155190056ed6695a25a559e","9871b7ee672bc16c78833bdab3052615834b08375cb144e4d2cba74473f4a589","c863198dae89420f3c552b5a03da6ed6d0acfa3807a64772b895db624b0de707","8b03a5e327d7db67112ebbc93b4f744133eda2c1743dbb0a990c61a8007823ef","86c73f2ee1752bac8eeeece234fd05dfcf0637a4fbd8032e4f5f43102faa8eec","42fad1f540271e35ca37cecda12c4ce2eef27f0f5cf0f8dd761d723c744d3159","ff3743a5de32bee10906aff63d1de726f6a7fd6ee2da4b8229054dfa69de2c34","83acd370f7f84f203e71ebba33ba61b7f1291ca027d7f9a662c6307d74e4ac22","1445cec898f90bdd18b2949b9590b3c012f5b7e1804e6e329fb0fe053946d5ec","0e5318ec2275d8da858b541920d9306650ae6ac8012f0e872fe66eb50321a669","cf530297c3fb3a92ec9591dd4fa229d58b5981e45fe6702a0bd2bea53a5e59be","c1f6f7d08d42148ddfe164d36d7aba91f467dbcb3caa715966ff95f55048b3a4","f4e9bf9103191ef3b3612d3ec0044ca4044ca5be27711fe648ada06fad4bcc85","0c1ee27b8f6a00097c2d6d91a21ee4d096ab52c1e28350f6362542b55380059a","7677d5b0db9e020d3017720f853ba18f415219fb3a9597343b1b1012cfd699f7","bc1c6bc119c1784b1a2be6d9c47addec0d83ef0d52c8fbe1f14a51b4dfffc675","52cf2ce99c2a23de70225e252e9822a22b4e0adb82643ab0b710858810e00bf1","770625067bb27a20b9826255a8d47b6b5b0a2d3dfcbd21f89904c731f671ba77","d1ed6765f4d7906a05968fb5cd6d1db8afa14dbe512a4884e8ea5c0f5e142c80","799c0f1b07c092626cf1efd71d459997635911bb5f7fc1196efe449bba87e965","2a184e4462b9914a30b1b5c41cf80c6d3428f17b20d3afb711fff3f0644001fd","9eabde32a3aa5d80de34af2c2206cdc3ee094c6504a8d0c2d6d20c7c179503cc","397c8051b6cfcb48aa22656f0faca2553c5f56187262135162ee79d2b2f6c966","a8ead142e0c87dcd5dc130eba1f8eeed506b08952d905c47621dc2f583b1bff9","a02f10ea5f73130efca046429254a4e3c06b5475baecc8f7b99a0014731be8b3","c2576a4083232b0e2d9bd06875dd43d371dee2e090325a9eac0133fd5650c1cb","4c9a0564bb317349de6a24eb4efea8bb79898fa72ad63a1809165f5bd42970dd","f40ac11d8859092d20f953aae14ba967282c3bb056431a37fced1866ec7a2681","cc11e9e79d4746cc59e0e17473a59d6f104692fd0eeea1bdb2e206eabed83b03","b444a410d34fb5e98aa5ee2b381362044f4884652e8bc8a11c8fe14bbd85518e","c35808c1f5e16d2c571aa65067e3cb95afeff843b259ecfa2fc107a9519b5392","14d5dc055143e941c8743c6a21fa459f961cbc3deedf1bfe47b11587ca4b3ef5","a3ad4e1fc542751005267d50a6298e6765928c0c3a8dce1572f2ba6ca518661c","f237e7c97a3a89f4591afd49ecb3bd8d14f51a1c4adc8fcae3430febedff5eb6","3ffdfbec93b7aed71082af62b8c3e0cc71261cc68d796665faa1e91604fbae8f","662201f943ed45b1ad600d03a90dffe20841e725203ced8b708c91fcd7f9379a","c9ef74c64ed051ea5b958621e7fb853fe3b56e8787c1587aefc6ea988b3c7e79","2462ccfac5f3375794b861abaa81da380f1bbd9401de59ffa43119a0b644253d","34baf65cfee92f110d6653322e2120c2d368ee64b3c7981dff08ed105c4f19b0","7d8ddf0f021c53099e34ee831a06c394d50371816caa98684812f089b4c6b3d4","c6c4fea9acc55d5e38ff2b70d57ab0b5cdbd08f8bc5d7a226e322cea128c5b57","9ad8802fd8850d22277c08f5653e69e551a2e003a376ce0afb3fe28474b51d65","fdfbe321c556c39a2ecf791d537b999591d0849e971dd938d88f460fea0186f6","105b9a2234dcb06ae922f2cd8297201136d416503ff7d16c72bfc8791e9895c1"],"root":[[254,256]],"options":{"allowImportingTsExtensions":true,"composite":true,"declaration":true,"declarationDir":"../../dts","declarationMap":true,"emitDeclarationOnly":true,"esModuleInterop":true,"module":200,"noImplicitAny":true,"noImplicitThis":true,"rootDir":"../..","skipLibCheck":true,"strictBindCallApply":true,"target":99},"fileIdsList":[[208,216,230],[169],[169,170,210,215,218,219,230],[169,218,230],[169,211,230],[211,212,213,214],[169,211],[235],[169,170,230,232],[208,209,217,230],[169,218,220,230,231,233,234,252],[169,219,230],[169,215,216,230],[170,231],[169,219],[201,208,218,219,220,229,232],[168,201,230,252],[143,168,201,215,235,238,239,240,241,245,247,248,249,251],[169,230,235,250],[169,201,235],[143,169,235,246,252],[169,235,246,252],[143,168,237],[143,169,229,235],[143,169,235,236,238],[143,238],[143,221,228],[204],[202,203,204,205,206,207],[252],[173,182,194,200],[199],[171,174,175],[176,178,179,180,181,182,194,195,200],[183,185,194],[171,173,175,184,185,190,194,195,200],[178,192,194,200],[171,173,175,177,184,185,189,194,195],[171,184,194],[171,173,177,185,191,194,195,200],[171,173,175,176,178,188,194,195],[171,172,175,176,177,178,179,180,181,182,184,185,186,187,188,189,190,192,194,195,196,197,198,200],[171,177,178,194],[171,172,173,175,176,177,178,179,180,181,182,184,185,186,187,188,189,190,192,194,195,200],[171,172,175,176,177,178,179,180,181,182,184,185,186,187,188,189,190,192,194,195,200],[171,172,173,175,176,182,185,186,187,194,200],[171,172,173,175,186,200],[172],[171,175,188,193,200],[171,177,188],[171,175,188,194],[171,177,188,194],[242,243],[143],[143,242,244],[201],[143,149,150,166],[143,149,166,168],[143,149],[143,146,147,149,150,166,167],[143,166],[143,146,151,166],[166],[143,151,166],[143,146,149,150,151,152,153,154,155,156,157,158,159,160,161,162,163,165,168],[143,144,166],[143,149,166],[143,148,150,166,168],[143,144,145,168],[143,146,168],[101],[101,102,103,104,105,106,107,108,109],[68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143],[110,143],[360],[225,227],[226],[223,225],[222,223,224],[222,225],[260,262],[259,260,261],[314,315,352,353],[355],[356],[362,365],[301,352,358,364],[359,363],[361],[265],[301],[302,307,336],[303,314,315,322,333,344],[303,304,314,322],[305,345],[306,307,315,323],[307,333,341],[308,310,314,322],[301,309],[310,311],[314],[312,314],[301,314],[314,315,316,333,344],[314,315,316,329,333,336],[299,302,349],[310,314,317,322,333,344],[314,315,317,318,322,333,341,344],[317,319,333,341,344],[265,266,300,301,302,303,304,305,306,307,308,309,310,311,312,313,314,315,316,317,318,319,320,321,322,323,324,325,326,327,328,329,330,331,332,333,334,335,336,337,338,339,340,341,342,343,344,345,346,347,348,349,350,351],[314,320],[321,344,349],[310,314,322,333],[323],[324],[301,325],[326,343,349],[327],[328],[314,329,330],[329,331,345,347],[302,314,333,334,335,336],[302,333,335],[333,334],[336],[337],[301,333],[314,339,340],[339,340],[307,322,333,341],[342],[322,343],[302,317,328,344],[307,345],[333,346],[321,347],[348],[302,307,314,316,325,333,344,347,349],[333,350],[371,410],[371,395,410],[410],[371],[371,396,410],[371,372,373,374,375,376,377,378,379,380,381,382,383,384,385,386,387,388,389,390,391,392,393,394,395,396,397,398,399,400,401,402,403,404,405,406,407,408,409],[396,410],[413],[362],[276,280,344],[276,333,344],[271],[273,276,341,344],[322,341],[352],[271,352],[273,276,322,344],[268,269,272,275,302,314,333,344],[268,274],[272,276,302,336,344,352],[302,352],[292,302,352],[270,271,352],[276],[270,271,272,273,274,275,276,277,278,280,281,282,283,284,285,286,287,288,289,290,291,293,294,295,296,297,298],[276,283,284],[274,276,284,285],[275],[268,271,276],[276,280,284,285],[280],[274,276,279,344],[268,273,274,276,280,283],[302,333],[271,276,292,302,349,352],[203],[253],[143,146],[143,164,166]],"referencedMap":[[217,1],[209,2],[216,3],[219,4],[213,5],[215,6],[212,7],[214,2],[211,8],[233,9],[218,10],[235,11],[220,12],[234,13],[232,14],[210,15],[230,16],[231,17],[252,18],[251,19],[250,20],[249,21],[248,22],[247,22],[238,23],[246,24],[237,25],[239,26],[229,27],[206,28],[207,28],[208,29],[205,28],[253,30],[201,31],[200,32],[175,33],[183,34],[186,35],[191,36],[195,37],[190,38],[185,39],[192,40],[184,41],[199,42],[196,43],[197,44],[193,45],[198,43],[188,46],[176,47],[173,48],[194,49],[180,50],[179,51],[178,52],[244,53],[243,54],[245,55],[242,56],[167,57],[151,58],[150,59],[168,60],[152,61],[162,61],[158,62],[156,61],[155,63],[161,64],[166,65],[153,61],[157,61],[164,66],[144,54],[160,67],[159,63],[154,61],[148,67],[149,68],[146,69],[147,70],[70,54],[71,54],[73,54],[72,54],[75,54],[77,54],[69,54],[74,54],[79,54],[80,54],[81,54],[78,54],[82,54],[83,54],[84,54],[85,54],[86,54],[88,54],[87,54],[89,54],[90,54],[92,54],[94,54],[95,54],[96,54],[98,54],[99,54],[100,54],[102,71],[110,72],[101,54],[143,73],[111,54],[116,54],[112,54],[113,54],[114,54],[115,54],[117,54],[118,54],[119,54],[120,54],[139,54],[140,54],[122,54],[123,54],[124,54],[125,54],[126,54],[127,54],[128,54],[130,54],[131,54],[132,54],[133,54],[136,54],[137,54],[138,74],[361,75],[228,76],[227,77],[224,78],[225,79],[223,80],[263,81],[262,82],[354,83],[356,84],[357,85],[367,86],[365,87],[364,88],[366,89],[265,90],[266,90],[301,91],[302,92],[303,93],[304,94],[305,95],[306,96],[307,97],[308,98],[309,99],[310,100],[311,100],[313,101],[312,102],[314,103],[315,104],[316,105],[300,106],[317,107],[318,108],[319,109],[352,110],[320,111],[321,112],[322,113],[323,114],[324,115],[325,116],[326,117],[327,118],[328,119],[329,120],[330,120],[331,121],[333,122],[335,123],[334,124],[336,125],[337,126],[338,127],[339,128],[340,129],[341,130],[342,131],[343,132],[344,133],[345,134],[346,135],[347,136],[348,137],[349,138],[350,139],[395,140],[396,141],[371,142],[374,142],[393,140],[394,140],[384,140],[383,143],[381,140],[376,140],[389,140],[387,140],[391,140],[375,140],[388,140],[392,140],[377,140],[378,140],[390,140],[372,140],[379,140],[380,140],[382,140],[386,140],[397,144],[385,140],[373,140],[410,145],[404,144],[406,146],[405,144],[398,144],[399,144],[401,144],[403,144],[407,146],[408,146],[400,146],[402,146],[414,147],[363,148],[362,89],[283,149],[290,150],[282,149],[297,151],[274,152],[273,153],[296,154],[291,155],[294,156],[276,157],[275,158],[271,159],[270,160],[293,161],[272,162],[277,163],[281,163],[299,164],[298,163],[285,165],[286,166],[288,167],[284,168],[287,169],[292,154],[279,170],[280,171],[289,172],[269,173],[295,174],[204,175],[254,176],[145,177],[163,61],[165,178]],"exportedModulesMap":[[217,1],[209,2],[216,3],[219,4],[213,5],[215,6],[212,7],[214,2],[211,8],[233,9],[218,10],[235,11],[220,12],[234,13],[232,14],[210,15],[230,16],[231,17],[252,18],[251,19],[250,20],[249,21],[248,22],[247,22],[238,23],[246,24],[237,25],[239,26],[229,27],[206,28],[207,28],[208,29],[205,28],[253,30],[201,31],[200,32],[175,33],[183,34],[186,35],[191,36],[195,37],[190,38],[185,39],[192,40],[184,41],[199,42],[196,43],[197,44],[193,45],[198,43],[188,46],[176,47],[173,48],[194,49],[180,50],[179,51],[178,52],[244,53],[243,54],[245,55],[242,56],[167,57],[151,58],[150,59],[168,60],[152,61],[162,61],[158,62],[156,61],[155,63],[161,64],[166,65],[153,61],[157,61],[164,66],[144,54],[160,67],[159,63],[154,61],[148,67],[149,68],[146,69],[147,70],[70,54],[71,54],[73,54],[72,54],[75,54],[77,54],[69,54],[74,54],[79,54],[80,54],[81,54],[78,54],[82,54],[83,54],[84,54],[85,54],[86,54],[88,54],[87,54],[89,54],[90,54],[92,54],[94,54],[95,54],[96,54],[98,54],[99,54],[100,54],[102,71],[110,72],[101,54],[143,73],[111,54],[116,54],[112,54],[113,54],[114,54],[115,54],[117,54],[118,54],[119,54],[120,54],[139,54],[140,54],[122,54],[123,54],[124,54],[125,54],[126,54],[127,54],[128,54],[130,54],[131,54],[132,54],[133,54],[136,54],[137,54],[138,74],[361,75],[228,76],[227,77],[224,78],[225,79],[223,80],[263,81],[262,82],[354,83],[356,84],[357,85],[367,86],[365,87],[364,88],[366,89],[265,90],[266,90],[301,91],[302,92],[303,93],[304,94],[305,95],[306,96],[307,97],[308,98],[309,99],[310,100],[311,100],[313,101],[312,102],[314,103],[315,104],[316,105],[300,106],[317,107],[318,108],[319,109],[352,110],[320,111],[321,112],[322,113],[323,114],[324,115],[325,116],[326,117],[327,118],[328,119],[329,120],[330,120],[331,121],[333,122],[335,123],[334,124],[336,125],[337,126],[338,127],[339,128],[340,129],[341,130],[342,131],[343,132],[344,133],[345,134],[346,135],[347,136],[348,137],[349,138],[350,139],[395,140],[396,141],[371,142],[374,142],[393,140],[394,140],[384,140],[383,143],[381,140],[376,140],[389,140],[387,140],[391,140],[375,140],[388,140],[392,140],[377,140],[378,140],[390,140],[372,140],[379,140],[380,140],[382,140],[386,140],[397,144],[385,140],[373,140],[410,145],[404,144],[406,146],[405,144],[398,144],[399,144],[401,144],[403,144],[407,146],[408,146],[400,146],[402,146],[414,147],[363,148],[362,89],[283,149],[290,150],[282,149],[297,151],[274,152],[273,153],[296,154],[291,155],[294,156],[276,157],[275,158],[271,159],[270,160],[293,161],[272,162],[277,163],[281,163],[299,164],[298,163],[285,165],[286,166],[288,167],[284,168],[287,169],[292,154],[279,170],[280,171],[289,172],[269,173],[295,174],[204,175],[254,30],[145,177],[163,61],[165,178]],"semanticDiagnosticsPerFile":[217,209,216,219,213,215,212,214,211,233,218,170,241,235,220,234,232,210,230,231,252,251,250,240,249,248,247,238,246,237,239,229,206,207,208,202,205,203,253,187,201,200,175,174,183,186,191,195,190,185,192,184,199,196,197,193,198,172,188,176,173,194,180,179,171,181,178,177,244,243,245,242,167,151,150,168,152,162,158,156,155,161,166,153,157,164,144,160,159,154,148,149,146,147,70,71,141,73,72,75,77,69,74,79,80,81,78,82,83,84,85,86,88,87,89,90,91,92,93,94,95,96,97,98,99,100,102,109,106,103,110,104,105,108,107,101,143,111,116,112,113,114,115,117,118,119,120,142,121,139,140,122,123,124,125,126,127,128,129,130,131,132,133,134,135,136,137,68,138,255,361,228,226,227,224,222,225,223,360,189,257,236,258,263,259,262,260,264,169,354,355,356,357,367,358,359,365,364,366,221,261,368,369,353,265,266,301,302,303,304,305,306,307,308,309,310,311,313,312,314,315,316,300,351,317,318,319,352,320,321,322,323,324,325,326,327,328,329,330,331,332,333,335,334,336,337,338,339,340,341,342,343,344,345,346,347,348,349,350,370,395,396,371,374,393,394,384,383,381,376,389,387,391,375,388,392,377,378,390,372,379,380,382,386,397,385,373,410,409,404,406,405,398,399,401,403,407,408,400,402,411,412,413,414,267,363,362,66,67,13,12,2,14,15,16,17,18,19,20,21,3,22,4,23,27,24,25,26,28,29,30,5,31,32,33,34,6,38,35,36,37,39,7,40,45,46,41,42,43,44,8,50,47,48,49,51,9,52,53,54,57,55,56,58,59,10,1,60,11,64,62,61,65,63,283,290,282,297,274,273,296,291,294,276,275,271,270,293,272,277,278,281,268,299,298,285,286,288,284,287,292,279,280,289,269,295,204,182,254,145,163,165,76,256],"latestChangedDtsFile":"../../dts/packages/babel-plugin-syntax-import-attributes/src/index.d.ts"},"version":"5.4.5"} \ No newline at end of file diff --git a/tools/eslint/node_modules/@babel/template/LICENSE b/tools/eslint/node_modules/@babel/template/LICENSE deleted file mode 100644 index f31575ec773bb1..00000000000000 --- a/tools/eslint/node_modules/@babel/template/LICENSE +++ /dev/null @@ -1,22 +0,0 @@ -MIT License - -Copyright (c) 2014-present Sebastian McKenzie and other contributors - -Permission is hereby granted, free of charge, to any person obtaining -a copy of this software and associated documentation files (the -"Software"), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sublicense, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/tools/eslint/node_modules/@babel/template/lib/builder.js b/tools/eslint/node_modules/@babel/template/lib/builder.js deleted file mode 100644 index 38cb2eb272b35c..00000000000000 --- a/tools/eslint/node_modules/@babel/template/lib/builder.js +++ /dev/null @@ -1,69 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.default = createTemplateBuilder; -var _options = require("./options.js"); -var _string = require("./string.js"); -var _literal = require("./literal.js"); -const NO_PLACEHOLDER = (0, _options.validate)({ - placeholderPattern: false -}); -function createTemplateBuilder(formatter, defaultOpts) { - const templateFnCache = new WeakMap(); - const templateAstCache = new WeakMap(); - const cachedOpts = defaultOpts || (0, _options.validate)(null); - return Object.assign((tpl, ...args) => { - if (typeof tpl === "string") { - if (args.length > 1) throw new Error("Unexpected extra params."); - return extendedTrace((0, _string.default)(formatter, tpl, (0, _options.merge)(cachedOpts, (0, _options.validate)(args[0])))); - } else if (Array.isArray(tpl)) { - let builder = templateFnCache.get(tpl); - if (!builder) { - builder = (0, _literal.default)(formatter, tpl, cachedOpts); - templateFnCache.set(tpl, builder); - } - return extendedTrace(builder(args)); - } else if (typeof tpl === "object" && tpl) { - if (args.length > 0) throw new Error("Unexpected extra params."); - return createTemplateBuilder(formatter, (0, _options.merge)(cachedOpts, (0, _options.validate)(tpl))); - } - throw new Error(`Unexpected template param ${typeof tpl}`); - }, { - ast: (tpl, ...args) => { - if (typeof tpl === "string") { - if (args.length > 1) throw new Error("Unexpected extra params."); - return (0, _string.default)(formatter, tpl, (0, _options.merge)((0, _options.merge)(cachedOpts, (0, _options.validate)(args[0])), NO_PLACEHOLDER))(); - } else if (Array.isArray(tpl)) { - let builder = templateAstCache.get(tpl); - if (!builder) { - builder = (0, _literal.default)(formatter, tpl, (0, _options.merge)(cachedOpts, NO_PLACEHOLDER)); - templateAstCache.set(tpl, builder); - } - return builder(args)(); - } - throw new Error(`Unexpected template param ${typeof tpl}`); - } - }); -} -function extendedTrace(fn) { - let rootStack = ""; - try { - throw new Error(); - } catch (error) { - if (error.stack) { - rootStack = error.stack.split("\n").slice(3).join("\n"); - } - } - return arg => { - try { - return fn(arg); - } catch (err) { - err.stack += `\n =============\n${rootStack}`; - throw err; - } - }; -} - -//# sourceMappingURL=builder.js.map diff --git a/tools/eslint/node_modules/@babel/template/lib/formatters.js b/tools/eslint/node_modules/@babel/template/lib/formatters.js deleted file mode 100644 index 3e284d193d94d1..00000000000000 --- a/tools/eslint/node_modules/@babel/template/lib/formatters.js +++ /dev/null @@ -1,61 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.statements = exports.statement = exports.smart = exports.program = exports.expression = void 0; -var _t = require("@babel/types"); -const { - assertExpressionStatement -} = _t; -function makeStatementFormatter(fn) { - return { - code: str => `/* @babel/template */;\n${str}`, - validate: () => {}, - unwrap: ast => { - return fn(ast.program.body.slice(1)); - } - }; -} -const smart = exports.smart = makeStatementFormatter(body => { - if (body.length > 1) { - return body; - } else { - return body[0]; - } -}); -const statements = exports.statements = makeStatementFormatter(body => body); -const statement = exports.statement = makeStatementFormatter(body => { - if (body.length === 0) { - throw new Error("Found nothing to return."); - } - if (body.length > 1) { - throw new Error("Found multiple statements but wanted one"); - } - return body[0]; -}); -const expression = exports.expression = { - code: str => `(\n${str}\n)`, - validate: ast => { - if (ast.program.body.length > 1) { - throw new Error("Found multiple statements but wanted one"); - } - if (expression.unwrap(ast).start === 0) { - throw new Error("Parse result included parens."); - } - }, - unwrap: ({ - program - }) => { - const [stmt] = program.body; - assertExpressionStatement(stmt); - return stmt.expression; - } -}; -const program = exports.program = { - code: str => str, - validate: () => {}, - unwrap: ast => ast.program -}; - -//# sourceMappingURL=formatters.js.map diff --git a/tools/eslint/node_modules/@babel/template/lib/index.js b/tools/eslint/node_modules/@babel/template/lib/index.js deleted file mode 100644 index 7028cc59d28963..00000000000000 --- a/tools/eslint/node_modules/@babel/template/lib/index.js +++ /dev/null @@ -1,23 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.statements = exports.statement = exports.smart = exports.program = exports.expression = exports.default = void 0; -var formatters = require("./formatters.js"); -var _builder = require("./builder.js"); -const smart = exports.smart = (0, _builder.default)(formatters.smart); -const statement = exports.statement = (0, _builder.default)(formatters.statement); -const statements = exports.statements = (0, _builder.default)(formatters.statements); -const expression = exports.expression = (0, _builder.default)(formatters.expression); -const program = exports.program = (0, _builder.default)(formatters.program); -var _default = exports.default = Object.assign(smart.bind(undefined), { - smart, - statement, - statements, - expression, - program, - ast: smart.ast -}); - -//# sourceMappingURL=index.js.map diff --git a/tools/eslint/node_modules/@babel/template/lib/literal.js b/tools/eslint/node_modules/@babel/template/lib/literal.js deleted file mode 100644 index 58beffb4358168..00000000000000 --- a/tools/eslint/node_modules/@babel/template/lib/literal.js +++ /dev/null @@ -1,69 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.default = literalTemplate; -var _options = require("./options.js"); -var _parse = require("./parse.js"); -var _populate = require("./populate.js"); -function literalTemplate(formatter, tpl, opts) { - const { - metadata, - names - } = buildLiteralData(formatter, tpl, opts); - return arg => { - const defaultReplacements = {}; - arg.forEach((replacement, i) => { - defaultReplacements[names[i]] = replacement; - }); - return arg => { - const replacements = (0, _options.normalizeReplacements)(arg); - if (replacements) { - Object.keys(replacements).forEach(key => { - if (hasOwnProperty.call(defaultReplacements, key)) { - throw new Error("Unexpected replacement overlap."); - } - }); - } - return formatter.unwrap((0, _populate.default)(metadata, replacements ? Object.assign(replacements, defaultReplacements) : defaultReplacements)); - }; - }; -} -function buildLiteralData(formatter, tpl, opts) { - let prefix = "BABEL_TPL$"; - const raw = tpl.join(""); - do { - prefix = "$$" + prefix; - } while (raw.includes(prefix)); - const { - names, - code - } = buildTemplateCode(tpl, prefix); - const metadata = (0, _parse.default)(formatter, formatter.code(code), { - parser: opts.parser, - placeholderWhitelist: new Set(names.concat(opts.placeholderWhitelist ? Array.from(opts.placeholderWhitelist) : [])), - placeholderPattern: opts.placeholderPattern, - preserveComments: opts.preserveComments, - syntacticPlaceholders: opts.syntacticPlaceholders - }); - return { - metadata, - names - }; -} -function buildTemplateCode(tpl, prefix) { - const names = []; - let code = tpl[0]; - for (let i = 1; i < tpl.length; i++) { - const value = `${prefix}${i - 1}`; - names.push(value); - code += value + tpl[i]; - } - return { - names, - code - }; -} - -//# sourceMappingURL=literal.js.map diff --git a/tools/eslint/node_modules/@babel/template/lib/options.js b/tools/eslint/node_modules/@babel/template/lib/options.js deleted file mode 100644 index 7ec7fb5a0b56a0..00000000000000 --- a/tools/eslint/node_modules/@babel/template/lib/options.js +++ /dev/null @@ -1,73 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.merge = merge; -exports.normalizeReplacements = normalizeReplacements; -exports.validate = validate; -const _excluded = ["placeholderWhitelist", "placeholderPattern", "preserveComments", "syntacticPlaceholders"]; -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 merge(a, b) { - const { - placeholderWhitelist = a.placeholderWhitelist, - placeholderPattern = a.placeholderPattern, - preserveComments = a.preserveComments, - syntacticPlaceholders = a.syntacticPlaceholders - } = b; - return { - parser: Object.assign({}, a.parser, b.parser), - placeholderWhitelist, - placeholderPattern, - preserveComments, - syntacticPlaceholders - }; -} -function validate(opts) { - if (opts != null && typeof opts !== "object") { - throw new Error("Unknown template options."); - } - const _ref = opts || {}, - { - placeholderWhitelist, - placeholderPattern, - preserveComments, - syntacticPlaceholders - } = _ref, - parser = _objectWithoutPropertiesLoose(_ref, _excluded); - if (placeholderWhitelist != null && !(placeholderWhitelist instanceof Set)) { - throw new Error("'.placeholderWhitelist' must be a Set, null, or undefined"); - } - if (placeholderPattern != null && !(placeholderPattern instanceof RegExp) && placeholderPattern !== false) { - throw new Error("'.placeholderPattern' must be a RegExp, false, null, or undefined"); - } - if (preserveComments != null && typeof preserveComments !== "boolean") { - throw new Error("'.preserveComments' must be a boolean, null, or undefined"); - } - if (syntacticPlaceholders != null && typeof syntacticPlaceholders !== "boolean") { - throw new Error("'.syntacticPlaceholders' must be a boolean, null, or undefined"); - } - if (syntacticPlaceholders === true && (placeholderWhitelist != null || placeholderPattern != null)) { - throw new Error("'.placeholderWhitelist' and '.placeholderPattern' aren't compatible" + " with '.syntacticPlaceholders: true'"); - } - return { - parser, - placeholderWhitelist: placeholderWhitelist || undefined, - placeholderPattern: placeholderPattern == null ? undefined : placeholderPattern, - preserveComments: preserveComments == null ? undefined : preserveComments, - syntacticPlaceholders: syntacticPlaceholders == null ? undefined : syntacticPlaceholders - }; -} -function normalizeReplacements(replacements) { - if (Array.isArray(replacements)) { - return replacements.reduce((acc, replacement, i) => { - acc["$" + i] = replacement; - return acc; - }, {}); - } else if (typeof replacements === "object" || replacements == null) { - return replacements || undefined; - } - throw new Error("Template replacements must be an array, object, null, or undefined"); -} - -//# sourceMappingURL=options.js.map diff --git a/tools/eslint/node_modules/@babel/template/lib/parse.js b/tools/eslint/node_modules/@babel/template/lib/parse.js deleted file mode 100644 index 9c34407e21e8d3..00000000000000 --- a/tools/eslint/node_modules/@babel/template/lib/parse.js +++ /dev/null @@ -1,160 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.default = parseAndBuildMetadata; -var _t = require("@babel/types"); -var _parser = require("@babel/parser"); -var _codeFrame = require("@babel/code-frame"); -const { - isCallExpression, - isExpressionStatement, - isFunction, - isIdentifier, - isJSXIdentifier, - isNewExpression, - isPlaceholder, - isStatement, - isStringLiteral, - removePropertiesDeep, - traverse -} = _t; -const PATTERN = /^[_$A-Z0-9]+$/; -function parseAndBuildMetadata(formatter, code, opts) { - const { - placeholderWhitelist, - placeholderPattern, - preserveComments, - syntacticPlaceholders - } = opts; - const ast = parseWithCodeFrame(code, opts.parser, syntacticPlaceholders); - removePropertiesDeep(ast, { - preserveComments - }); - formatter.validate(ast); - const state = { - syntactic: { - placeholders: [], - placeholderNames: new Set() - }, - legacy: { - placeholders: [], - placeholderNames: new Set() - }, - placeholderWhitelist, - placeholderPattern, - syntacticPlaceholders - }; - traverse(ast, placeholderVisitorHandler, state); - return Object.assign({ - ast - }, state.syntactic.placeholders.length ? state.syntactic : state.legacy); -} -function placeholderVisitorHandler(node, ancestors, state) { - var _state$placeholderWhi; - let name; - let hasSyntacticPlaceholders = state.syntactic.placeholders.length > 0; - if (isPlaceholder(node)) { - if (state.syntacticPlaceholders === false) { - throw new Error("%%foo%%-style placeholders can't be used when " + "'.syntacticPlaceholders' is false."); - } - name = node.name.name; - hasSyntacticPlaceholders = true; - } else if (hasSyntacticPlaceholders || state.syntacticPlaceholders) { - return; - } else if (isIdentifier(node) || isJSXIdentifier(node)) { - name = node.name; - } else if (isStringLiteral(node)) { - name = node.value; - } else { - return; - } - if (hasSyntacticPlaceholders && (state.placeholderPattern != null || state.placeholderWhitelist != null)) { - throw new Error("'.placeholderWhitelist' and '.placeholderPattern' aren't compatible" + " with '.syntacticPlaceholders: true'"); - } - if (!hasSyntacticPlaceholders && (state.placeholderPattern === false || !(state.placeholderPattern || PATTERN).test(name)) && !((_state$placeholderWhi = state.placeholderWhitelist) != null && _state$placeholderWhi.has(name))) { - return; - } - ancestors = ancestors.slice(); - const { - node: parent, - key - } = ancestors[ancestors.length - 1]; - let type; - if (isStringLiteral(node) || isPlaceholder(node, { - expectedNode: "StringLiteral" - })) { - type = "string"; - } else if (isNewExpression(parent) && key === "arguments" || isCallExpression(parent) && key === "arguments" || isFunction(parent) && key === "params") { - type = "param"; - } else if (isExpressionStatement(parent) && !isPlaceholder(node)) { - type = "statement"; - ancestors = ancestors.slice(0, -1); - } else if (isStatement(node) && isPlaceholder(node)) { - type = "statement"; - } else { - type = "other"; - } - const { - placeholders, - placeholderNames - } = !hasSyntacticPlaceholders ? state.legacy : state.syntactic; - placeholders.push({ - name, - type, - resolve: ast => resolveAncestors(ast, ancestors), - isDuplicate: placeholderNames.has(name) - }); - placeholderNames.add(name); -} -function resolveAncestors(ast, ancestors) { - let parent = ast; - for (let i = 0; i < ancestors.length - 1; i++) { - const { - key, - index - } = ancestors[i]; - if (index === undefined) { - parent = parent[key]; - } else { - parent = parent[key][index]; - } - } - const { - key, - index - } = ancestors[ancestors.length - 1]; - return { - parent, - key, - index - }; -} -function parseWithCodeFrame(code, parserOpts, syntacticPlaceholders) { - const plugins = (parserOpts.plugins || []).slice(); - if (syntacticPlaceholders !== false) { - plugins.push("placeholders"); - } - parserOpts = Object.assign({ - allowReturnOutsideFunction: true, - allowSuperOutsideMethod: true, - sourceType: "module" - }, parserOpts, { - plugins - }); - try { - return (0, _parser.parse)(code, parserOpts); - } catch (err) { - const loc = err.loc; - if (loc) { - err.message += "\n" + (0, _codeFrame.codeFrameColumns)(code, { - start: loc - }); - err.code = "BABEL_TEMPLATE_PARSE_ERROR"; - } - throw err; - } -} - -//# sourceMappingURL=parse.js.map diff --git a/tools/eslint/node_modules/@babel/template/lib/populate.js b/tools/eslint/node_modules/@babel/template/lib/populate.js deleted file mode 100644 index fb67269f060d2b..00000000000000 --- a/tools/eslint/node_modules/@babel/template/lib/populate.js +++ /dev/null @@ -1,122 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.default = populatePlaceholders; -var _t = require("@babel/types"); -const { - blockStatement, - cloneNode, - emptyStatement, - expressionStatement, - identifier, - isStatement, - isStringLiteral, - stringLiteral, - validate -} = _t; -function populatePlaceholders(metadata, replacements) { - const ast = cloneNode(metadata.ast); - if (replacements) { - metadata.placeholders.forEach(placeholder => { - if (!hasOwnProperty.call(replacements, placeholder.name)) { - const placeholderName = placeholder.name; - throw new Error(`Error: No substitution given for "${placeholderName}". If this is not meant to be a - placeholder you may want to consider passing one of the following options to @babel/template: - - { placeholderPattern: false, placeholderWhitelist: new Set(['${placeholderName}'])} - - { placeholderPattern: /^${placeholderName}$/ }`); - } - }); - Object.keys(replacements).forEach(key => { - if (!metadata.placeholderNames.has(key)) { - throw new Error(`Unknown substitution "${key}" given`); - } - }); - } - metadata.placeholders.slice().reverse().forEach(placeholder => { - try { - applyReplacement(placeholder, ast, replacements && replacements[placeholder.name] || null); - } catch (e) { - e.message = `@babel/template placeholder "${placeholder.name}": ${e.message}`; - throw e; - } - }); - return ast; -} -function applyReplacement(placeholder, ast, replacement) { - if (placeholder.isDuplicate) { - if (Array.isArray(replacement)) { - replacement = replacement.map(node => cloneNode(node)); - } else if (typeof replacement === "object") { - replacement = cloneNode(replacement); - } - } - const { - parent, - key, - index - } = placeholder.resolve(ast); - if (placeholder.type === "string") { - if (typeof replacement === "string") { - replacement = stringLiteral(replacement); - } - if (!replacement || !isStringLiteral(replacement)) { - throw new Error("Expected string substitution"); - } - } else if (placeholder.type === "statement") { - if (index === undefined) { - if (!replacement) { - replacement = emptyStatement(); - } else if (Array.isArray(replacement)) { - replacement = blockStatement(replacement); - } else if (typeof replacement === "string") { - replacement = expressionStatement(identifier(replacement)); - } else if (!isStatement(replacement)) { - replacement = expressionStatement(replacement); - } - } else { - if (replacement && !Array.isArray(replacement)) { - if (typeof replacement === "string") { - replacement = identifier(replacement); - } - if (!isStatement(replacement)) { - replacement = expressionStatement(replacement); - } - } - } - } else if (placeholder.type === "param") { - if (typeof replacement === "string") { - replacement = identifier(replacement); - } - if (index === undefined) throw new Error("Assertion failure."); - } else { - if (typeof replacement === "string") { - replacement = identifier(replacement); - } - if (Array.isArray(replacement)) { - throw new Error("Cannot replace single expression with an array."); - } - } - if (index === undefined) { - validate(parent, key, replacement); - parent[key] = replacement; - } else { - const items = parent[key].slice(); - if (placeholder.type === "statement" || placeholder.type === "param") { - if (replacement == null) { - items.splice(index, 1); - } else if (Array.isArray(replacement)) { - items.splice(index, 1, ...replacement); - } else { - items[index] = replacement; - } - } else { - items[index] = replacement; - } - validate(parent, key, items); - parent[key] = items; - } -} - -//# sourceMappingURL=populate.js.map diff --git a/tools/eslint/node_modules/@babel/template/lib/string.js b/tools/eslint/node_modules/@babel/template/lib/string.js deleted file mode 100644 index e29914d047ea71..00000000000000 --- a/tools/eslint/node_modules/@babel/template/lib/string.js +++ /dev/null @@ -1,20 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.default = stringTemplate; -var _options = require("./options.js"); -var _parse = require("./parse.js"); -var _populate = require("./populate.js"); -function stringTemplate(formatter, code, opts) { - code = formatter.code(code); - let metadata; - return arg => { - const replacements = (0, _options.normalizeReplacements)(arg); - if (!metadata) metadata = (0, _parse.default)(formatter, code, opts); - return formatter.unwrap((0, _populate.default)(metadata, replacements)); - }; -} - -//# sourceMappingURL=string.js.map diff --git a/tools/eslint/node_modules/@babel/template/package.json b/tools/eslint/node_modules/@babel/template/package.json deleted file mode 100644 index dd388169537f1b..00000000000000 --- a/tools/eslint/node_modules/@babel/template/package.json +++ /dev/null @@ -1,27 +0,0 @@ -{ - "name": "@babel/template", - "version": "7.24.7", - "description": "Generate an AST from a string template.", - "author": "The Babel Team (https://babel.dev/team)", - "homepage": "https://babel.dev/docs/en/next/babel-template", - "bugs": "https://github.com/babel/babel/issues?utf8=%E2%9C%93&q=is%3Aissue+label%3A%22pkg%3A%20template%22+is%3Aopen", - "license": "MIT", - "publishConfig": { - "access": "public" - }, - "repository": { - "type": "git", - "url": "https://github.com/babel/babel.git", - "directory": "packages/babel-template" - }, - "main": "./lib/index.js", - "dependencies": { - "@babel/code-frame": "^7.24.7", - "@babel/parser": "^7.24.7", - "@babel/types": "^7.24.7" - }, - "engines": { - "node": ">=6.9.0" - }, - "type": "commonjs" -} \ No newline at end of file diff --git a/tools/eslint/node_modules/@babel/traverse/LICENSE b/tools/eslint/node_modules/@babel/traverse/LICENSE deleted file mode 100644 index f31575ec773bb1..00000000000000 --- a/tools/eslint/node_modules/@babel/traverse/LICENSE +++ /dev/null @@ -1,22 +0,0 @@ -MIT License - -Copyright (c) 2014-present Sebastian McKenzie and other contributors - -Permission is hereby granted, free of charge, to any person obtaining -a copy of this software and associated documentation files (the -"Software"), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sublicense, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/tools/eslint/node_modules/@babel/traverse/lib/cache.js b/tools/eslint/node_modules/@babel/traverse/lib/cache.js deleted file mode 100644 index 79a41b9cf9bc42..00000000000000 --- a/tools/eslint/node_modules/@babel/traverse/lib/cache.js +++ /dev/null @@ -1,44 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.clear = clear; -exports.clearPath = clearPath; -exports.clearScope = clearScope; -exports.getCachedPaths = getCachedPaths; -exports.getOrCreateCachedPaths = getOrCreateCachedPaths; -exports.scope = exports.path = void 0; -let pathsCache = exports.path = new WeakMap(); -let scope = exports.scope = new WeakMap(); -function clear() { - clearPath(); - clearScope(); -} -function clearPath() { - exports.path = pathsCache = new WeakMap(); -} -function clearScope() { - exports.scope = scope = new WeakMap(); -} -const nullHub = Object.freeze({}); -function getCachedPaths(hub, parent) { - var _pathsCache$get, _hub; - { - hub = null; - } - return (_pathsCache$get = pathsCache.get((_hub = hub) != null ? _hub : nullHub)) == null ? void 0 : _pathsCache$get.get(parent); -} -function getOrCreateCachedPaths(hub, parent) { - var _hub2, _hub3; - { - hub = null; - } - let parents = pathsCache.get((_hub2 = hub) != null ? _hub2 : nullHub); - if (!parents) pathsCache.set((_hub3 = hub) != null ? _hub3 : nullHub, parents = new WeakMap()); - let paths = parents.get(parent); - if (!paths) parents.set(parent, paths = new Map()); - return paths; -} - -//# sourceMappingURL=cache.js.map diff --git a/tools/eslint/node_modules/@babel/traverse/lib/context.js b/tools/eslint/node_modules/@babel/traverse/lib/context.js deleted file mode 100644 index fc9a067a373796..00000000000000 --- a/tools/eslint/node_modules/@babel/traverse/lib/context.js +++ /dev/null @@ -1,118 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.default = void 0; -var _index = require("./path/index.js"); -var _t = require("@babel/types"); -const { - VISITOR_KEYS -} = _t; -class TraversalContext { - constructor(scope, opts, state, parentPath) { - this.queue = null; - this.priorityQueue = null; - this.parentPath = parentPath; - this.scope = scope; - this.state = state; - this.opts = opts; - } - shouldVisit(node) { - const opts = this.opts; - if (opts.enter || opts.exit) return true; - if (opts[node.type]) return true; - const keys = VISITOR_KEYS[node.type]; - if (!(keys != null && keys.length)) return false; - for (const key of keys) { - if (node[key]) { - return true; - } - } - return false; - } - create(node, container, key, listKey) { - return _index.default.get({ - parentPath: this.parentPath, - parent: node, - container, - key: key, - listKey - }); - } - maybeQueue(path, notPriority) { - if (this.queue) { - if (notPriority) { - this.queue.push(path); - } else { - this.priorityQueue.push(path); - } - } - } - visitMultiple(container, parent, listKey) { - if (container.length === 0) return false; - const queue = []; - for (let key = 0; key < container.length; key++) { - const node = container[key]; - if (node && this.shouldVisit(node)) { - queue.push(this.create(parent, container, key, listKey)); - } - } - return this.visitQueue(queue); - } - visitSingle(node, key) { - if (this.shouldVisit(node[key])) { - return this.visitQueue([this.create(node, node, key)]); - } else { - return false; - } - } - visitQueue(queue) { - this.queue = queue; - this.priorityQueue = []; - const visited = new WeakSet(); - let stop = false; - let visitIndex = 0; - for (; visitIndex < queue.length;) { - const path = queue[visitIndex]; - visitIndex++; - path.resync(); - if (path.contexts.length === 0 || path.contexts[path.contexts.length - 1] !== this) { - path.pushContext(this); - } - if (path.key === null) continue; - const { - node - } = path; - if (visited.has(node)) continue; - if (node) visited.add(node); - if (path.visit()) { - stop = true; - break; - } - if (this.priorityQueue.length) { - stop = this.visitQueue(this.priorityQueue); - this.priorityQueue = []; - this.queue = queue; - if (stop) break; - } - } - for (let i = 0; i < visitIndex; i++) { - queue[i].popContext(); - } - this.queue = null; - return stop; - } - visit(node, key) { - const nodes = node[key]; - if (!nodes) return false; - if (Array.isArray(nodes)) { - return this.visitMultiple(nodes, node, key); - } else { - return this.visitSingle(node, key); - } - } -} -exports.default = TraversalContext; - -//# sourceMappingURL=context.js.map diff --git a/tools/eslint/node_modules/@babel/traverse/lib/hub.js b/tools/eslint/node_modules/@babel/traverse/lib/hub.js deleted file mode 100644 index a36b9972f7c35e..00000000000000 --- a/tools/eslint/node_modules/@babel/traverse/lib/hub.js +++ /dev/null @@ -1,19 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.default = void 0; -class Hub { - getCode() {} - getScope() {} - addHelper() { - throw new Error("Helpers are not supported by the default hub."); - } - buildError(node, msg, Error = TypeError) { - return new Error(msg); - } -} -exports.default = Hub; - -//# sourceMappingURL=hub.js.map diff --git a/tools/eslint/node_modules/@babel/traverse/lib/index.js b/tools/eslint/node_modules/@babel/traverse/lib/index.js deleted file mode 100644 index 566296c0092103..00000000000000 --- a/tools/eslint/node_modules/@babel/traverse/lib/index.js +++ /dev/null @@ -1,94 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -Object.defineProperty(exports, "Hub", { - enumerable: true, - get: function () { - return _hub.default; - } -}); -Object.defineProperty(exports, "NodePath", { - enumerable: true, - get: function () { - return _index.default; - } -}); -Object.defineProperty(exports, "Scope", { - enumerable: true, - get: function () { - return _index2.default; - } -}); -exports.visitors = exports.default = void 0; -var visitors = require("./visitors.js"); -exports.visitors = visitors; -var _t = require("@babel/types"); -var cache = require("./cache.js"); -var _traverseNode = require("./traverse-node.js"); -var _index = require("./path/index.js"); -var _index2 = require("./scope/index.js"); -var _hub = require("./hub.js"); -const { - VISITOR_KEYS, - removeProperties, - traverseFast -} = _t; -function traverse(parent, opts = {}, scope, state, parentPath, visitSelf) { - if (!parent) return; - if (!opts.noScope && !scope) { - if (parent.type !== "Program" && parent.type !== "File") { - throw new Error("You must pass a scope and parentPath unless traversing a Program/File. " + `Instead of that you tried to traverse a ${parent.type} node without ` + "passing scope and parentPath."); - } - } - if (!parentPath && visitSelf) { - throw new Error("visitSelf can only be used when providing a NodePath."); - } - if (!VISITOR_KEYS[parent.type]) { - return; - } - visitors.explode(opts); - (0, _traverseNode.traverseNode)(parent, opts, scope, state, parentPath, null, visitSelf); -} -var _default = exports.default = traverse; -traverse.visitors = visitors; -traverse.verify = visitors.verify; -traverse.explode = visitors.explode; -traverse.cheap = function (node, enter) { - traverseFast(node, enter); - return; -}; -traverse.node = function (node, opts, scope, state, path, skipKeys) { - (0, _traverseNode.traverseNode)(node, opts, scope, state, path, skipKeys); -}; -traverse.clearNode = function (node, opts) { - removeProperties(node, opts); -}; -traverse.removeProperties = function (tree, opts) { - traverseFast(tree, traverse.clearNode, opts); - return tree; -}; -function hasDenylistedType(path, state) { - if (path.node.type === state.type) { - state.has = true; - path.stop(); - } -} -traverse.hasType = function (tree, type, denylistTypes) { - if (denylistTypes != null && denylistTypes.includes(tree.type)) return false; - if (tree.type === type) return true; - const state = { - has: false, - type: type - }; - traverse(tree, { - noScope: true, - denylist: denylistTypes, - enter: hasDenylistedType - }, null, state); - return state.has; -}; -traverse.cache = cache; - -//# sourceMappingURL=index.js.map diff --git a/tools/eslint/node_modules/@babel/traverse/lib/path/ancestry.js b/tools/eslint/node_modules/@babel/traverse/lib/path/ancestry.js deleted file mode 100644 index c2871712fb199c..00000000000000 --- a/tools/eslint/node_modules/@babel/traverse/lib/path/ancestry.js +++ /dev/null @@ -1,141 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.find = find; -exports.findParent = findParent; -exports.getAncestry = getAncestry; -exports.getDeepestCommonAncestorFrom = getDeepestCommonAncestorFrom; -exports.getEarliestCommonAncestorFrom = getEarliestCommonAncestorFrom; -exports.getFunctionParent = getFunctionParent; -exports.getStatementParent = getStatementParent; -exports.inType = inType; -exports.isAncestor = isAncestor; -exports.isDescendant = isDescendant; -var _t = require("@babel/types"); -const { - VISITOR_KEYS -} = _t; -function findParent(callback) { - let path = this; - while (path = path.parentPath) { - if (callback(path)) return path; - } - return null; -} -function find(callback) { - let path = this; - do { - if (callback(path)) return path; - } while (path = path.parentPath); - return null; -} -function getFunctionParent() { - return this.findParent(p => p.isFunction()); -} -function getStatementParent() { - let path = this; - do { - if (!path.parentPath || Array.isArray(path.container) && path.isStatement()) { - break; - } else { - path = path.parentPath; - } - } while (path); - if (path && (path.isProgram() || path.isFile())) { - throw new Error("File/Program node, we can't possibly find a statement parent to this"); - } - return path; -} -function getEarliestCommonAncestorFrom(paths) { - return this.getDeepestCommonAncestorFrom(paths, function (deepest, i, ancestries) { - let earliest; - const keys = VISITOR_KEYS[deepest.type]; - for (const ancestry of ancestries) { - const path = ancestry[i + 1]; - if (!earliest) { - earliest = path; - continue; - } - if (path.listKey && earliest.listKey === path.listKey) { - if (path.key < earliest.key) { - earliest = path; - continue; - } - } - const earliestKeyIndex = keys.indexOf(earliest.parentKey); - const currentKeyIndex = keys.indexOf(path.parentKey); - if (earliestKeyIndex > currentKeyIndex) { - earliest = path; - } - } - return earliest; - }); -} -function getDeepestCommonAncestorFrom(paths, filter) { - if (!paths.length) { - return this; - } - if (paths.length === 1) { - return paths[0]; - } - let minDepth = Infinity; - let lastCommonIndex, lastCommon; - const ancestries = paths.map(path => { - const ancestry = []; - do { - ancestry.unshift(path); - } while ((path = path.parentPath) && path !== this); - if (ancestry.length < minDepth) { - minDepth = ancestry.length; - } - return ancestry; - }); - const first = ancestries[0]; - depthLoop: for (let i = 0; i < minDepth; i++) { - const shouldMatch = first[i]; - for (const ancestry of ancestries) { - if (ancestry[i] !== shouldMatch) { - break depthLoop; - } - } - lastCommonIndex = i; - lastCommon = shouldMatch; - } - if (lastCommon) { - if (filter) { - return filter(lastCommon, lastCommonIndex, ancestries); - } else { - return lastCommon; - } - } else { - throw new Error("Couldn't find intersection"); - } -} -function getAncestry() { - let path = this; - const paths = []; - do { - paths.push(path); - } while (path = path.parentPath); - return paths; -} -function isAncestor(maybeDescendant) { - return maybeDescendant.isDescendant(this); -} -function isDescendant(maybeAncestor) { - return !!this.findParent(parent => parent === maybeAncestor); -} -function inType(...candidateTypes) { - let path = this; - while (path) { - for (const type of candidateTypes) { - if (path.node.type === type) return true; - } - path = path.parentPath; - } - return false; -} - -//# sourceMappingURL=ancestry.js.map diff --git a/tools/eslint/node_modules/@babel/traverse/lib/path/comments.js b/tools/eslint/node_modules/@babel/traverse/lib/path/comments.js deleted file mode 100644 index 43b3b72acdd502..00000000000000 --- a/tools/eslint/node_modules/@babel/traverse/lib/path/comments.js +++ /dev/null @@ -1,52 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.addComment = addComment; -exports.addComments = addComments; -exports.shareCommentsWithSiblings = shareCommentsWithSiblings; -var _t = require("@babel/types"); -const { - addComment: _addComment, - addComments: _addComments -} = _t; -function shareCommentsWithSiblings() { - if (typeof this.key === "string") return; - const node = this.node; - if (!node) return; - const trailing = node.trailingComments; - const leading = node.leadingComments; - if (!trailing && !leading) return; - const prev = this.getSibling(this.key - 1); - const next = this.getSibling(this.key + 1); - const hasPrev = Boolean(prev.node); - const hasNext = Boolean(next.node); - if (hasPrev) { - if (leading) { - prev.addComments("trailing", removeIfExisting(leading, prev.node.trailingComments)); - } - if (trailing && !hasNext) prev.addComments("trailing", trailing); - } - if (hasNext) { - if (trailing) { - next.addComments("leading", removeIfExisting(trailing, next.node.leadingComments)); - } - if (leading && !hasPrev) next.addComments("leading", leading); - } -} -function removeIfExisting(list, toRemove) { - if (!(toRemove != null && toRemove.length)) return list; - const set = new Set(toRemove); - return list.filter(el => { - return !set.has(el); - }); -} -function addComment(type, content, line) { - _addComment(this.node, type, content, line); -} -function addComments(type, comments) { - _addComments(this.node, type, comments); -} - -//# sourceMappingURL=comments.js.map diff --git a/tools/eslint/node_modules/@babel/traverse/lib/path/context.js b/tools/eslint/node_modules/@babel/traverse/lib/path/context.js deleted file mode 100644 index 929bdc65b4f5e5..00000000000000 --- a/tools/eslint/node_modules/@babel/traverse/lib/path/context.js +++ /dev/null @@ -1,223 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports._call = _call; -exports._getQueueContexts = _getQueueContexts; -exports._resyncKey = _resyncKey; -exports._resyncList = _resyncList; -exports._resyncParent = _resyncParent; -exports._resyncRemoved = _resyncRemoved; -exports.call = call; -exports.isBlacklisted = exports.isDenylisted = isDenylisted; -exports.popContext = popContext; -exports.pushContext = pushContext; -exports.requeue = requeue; -exports.resync = resync; -exports.setContext = setContext; -exports.setKey = setKey; -exports.setScope = setScope; -exports.setup = setup; -exports.skip = skip; -exports.skipKey = skipKey; -exports.stop = stop; -exports.visit = visit; -var _traverseNode = require("../traverse-node.js"); -var _index = require("./index.js"); -var _removal = require("./removal.js"); -function call(key) { - const opts = this.opts; - this.debug(key); - if (this.node) { - if (_call.call(this, opts[key])) return true; - } - if (this.node) { - var _opts$this$node$type; - return _call.call(this, (_opts$this$node$type = opts[this.node.type]) == null ? void 0 : _opts$this$node$type[key]); - } - return false; -} -function _call(fns) { - if (!fns) return false; - for (const fn of fns) { - if (!fn) continue; - const node = this.node; - if (!node) return true; - const ret = fn.call(this.state, this, this.state); - if (ret && typeof ret === "object" && typeof ret.then === "function") { - throw new Error(`You appear to be using a plugin with an async traversal visitor, ` + `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.`); - } - if (ret) { - throw new Error(`Unexpected return value from visitor method ${fn}`); - } - if (this.node !== node) return true; - if (this._traverseFlags > 0) return true; - } - return false; -} -function isDenylisted() { - var _this$opts$denylist; - const denylist = (_this$opts$denylist = this.opts.denylist) != null ? _this$opts$denylist : this.opts.blacklist; - return denylist && denylist.indexOf(this.node.type) > -1; -} -function restoreContext(path, context) { - if (path.context !== context) { - path.context = context; - path.state = context.state; - path.opts = context.opts; - } -} -function visit() { - var _this$opts$shouldSkip, _this$opts; - if (!this.node) { - return false; - } - if (this.isDenylisted()) { - return false; - } - if ((_this$opts$shouldSkip = (_this$opts = this.opts).shouldSkip) != null && _this$opts$shouldSkip.call(_this$opts, this)) { - return false; - } - const currentContext = this.context; - if (this.shouldSkip || this.call("enter")) { - this.debug("Skip..."); - return this.shouldStop; - } - restoreContext(this, currentContext); - this.debug("Recursing into..."); - this.shouldStop = (0, _traverseNode.traverseNode)(this.node, this.opts, this.scope, this.state, this, this.skipKeys); - restoreContext(this, currentContext); - this.call("exit"); - return this.shouldStop; -} -function skip() { - this.shouldSkip = true; -} -function skipKey(key) { - if (this.skipKeys == null) { - this.skipKeys = {}; - } - this.skipKeys[key] = true; -} -function stop() { - this._traverseFlags |= _index.SHOULD_SKIP | _index.SHOULD_STOP; -} -function setScope() { - var _this$opts2, _this$scope; - if ((_this$opts2 = this.opts) != null && _this$opts2.noScope) return; - let path = this.parentPath; - if ((this.key === "key" || this.listKey === "decorators") && path.isMethod() || this.key === "discriminant" && path.isSwitchStatement()) { - path = path.parentPath; - } - let target; - while (path && !target) { - var _path$opts; - if ((_path$opts = path.opts) != null && _path$opts.noScope) return; - target = path.scope; - path = path.parentPath; - } - this.scope = this.getScope(target); - (_this$scope = this.scope) == null || _this$scope.init(); -} -function setContext(context) { - if (this.skipKeys != null) { - this.skipKeys = {}; - } - this._traverseFlags = 0; - if (context) { - this.context = context; - this.state = context.state; - this.opts = context.opts; - } - this.setScope(); - return this; -} -function resync() { - if (this.removed) return; - _resyncParent.call(this); - _resyncList.call(this); - _resyncKey.call(this); -} -function _resyncParent() { - if (this.parentPath) { - this.parent = this.parentPath.node; - } -} -function _resyncKey() { - if (!this.container) return; - if (this.node === this.container[this.key]) { - return; - } - if (Array.isArray(this.container)) { - for (let i = 0; i < this.container.length; i++) { - if (this.container[i] === this.node) { - this.setKey(i); - return; - } - } - } else { - for (const key of Object.keys(this.container)) { - if (this.container[key] === this.node) { - this.setKey(key); - return; - } - } - } - this.key = null; -} -function _resyncList() { - if (!this.parent || !this.inList) return; - const newContainer = this.parent[this.listKey]; - if (this.container === newContainer) return; - this.container = newContainer || null; -} -function _resyncRemoved() { - if (this.key == null || !this.container || this.container[this.key] !== this.node) { - _removal._markRemoved.call(this); - } -} -function popContext() { - this.contexts.pop(); - if (this.contexts.length > 0) { - this.setContext(this.contexts[this.contexts.length - 1]); - } else { - this.setContext(undefined); - } -} -function pushContext(context) { - this.contexts.push(context); - this.setContext(context); -} -function setup(parentPath, container, listKey, key) { - this.listKey = listKey; - this.container = container; - this.parentPath = parentPath || this.parentPath; - this.setKey(key); -} -function setKey(key) { - var _this$node; - this.key = key; - this.node = this.container[this.key]; - this.type = (_this$node = this.node) == null ? void 0 : _this$node.type; -} -function requeue(pathToQueue = this) { - if (pathToQueue.removed) return; - ; - const contexts = this.contexts; - for (const context of contexts) { - context.maybeQueue(pathToQueue); - } -} -function _getQueueContexts() { - let path = this; - let contexts = this.contexts; - while (!contexts.length) { - path = path.parentPath; - if (!path) break; - contexts = path.contexts; - } - return contexts; -} - -//# sourceMappingURL=context.js.map diff --git a/tools/eslint/node_modules/@babel/traverse/lib/path/conversion.js b/tools/eslint/node_modules/@babel/traverse/lib/path/conversion.js deleted file mode 100644 index a7884c7ce0a3e3..00000000000000 --- a/tools/eslint/node_modules/@babel/traverse/lib/path/conversion.js +++ /dev/null @@ -1,468 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.arrowFunctionToExpression = arrowFunctionToExpression; -exports.ensureBlock = ensureBlock; -exports.toComputedKey = toComputedKey; -exports.unwrapFunctionEnvironment = unwrapFunctionEnvironment; -var _t = require("@babel/types"); -var _helperEnvironmentVisitor = require("@babel/helper-environment-visitor"); -var _helperFunctionName = require("@babel/helper-function-name"); -var _visitors = require("../visitors.js"); -const { - arrowFunctionExpression, - assignmentExpression, - binaryExpression, - blockStatement, - callExpression, - conditionalExpression, - expressionStatement, - identifier, - isIdentifier, - jsxIdentifier, - logicalExpression, - LOGICAL_OPERATORS, - memberExpression, - metaProperty, - numericLiteral, - objectExpression, - restElement, - returnStatement, - sequenceExpression, - spreadElement, - stringLiteral, - super: _super, - thisExpression, - toExpression, - unaryExpression -} = _t; -function toComputedKey() { - let key; - if (this.isMemberExpression()) { - key = this.node.property; - } else if (this.isProperty() || this.isMethod()) { - key = this.node.key; - } else { - throw new ReferenceError("todo"); - } - if (!this.node.computed) { - if (isIdentifier(key)) key = stringLiteral(key.name); - } - return key; -} -function ensureBlock() { - const body = this.get("body"); - const bodyNode = body.node; - if (Array.isArray(body)) { - throw new Error("Can't convert array path to a block statement"); - } - if (!bodyNode) { - throw new Error("Can't convert node without a body"); - } - if (body.isBlockStatement()) { - return bodyNode; - } - const statements = []; - let stringPath = "body"; - let key; - let listKey; - if (body.isStatement()) { - listKey = "body"; - key = 0; - statements.push(body.node); - } else { - stringPath += ".body.0"; - if (this.isFunction()) { - key = "argument"; - statements.push(returnStatement(body.node)); - } else { - key = "expression"; - statements.push(expressionStatement(body.node)); - } - } - this.node.body = blockStatement(statements); - const parentPath = this.get(stringPath); - body.setup(parentPath, listKey ? parentPath.node[listKey] : parentPath.node, listKey, key); - return this.node; -} -{ - exports.arrowFunctionToShadowed = function () { - if (!this.isArrowFunctionExpression()) return; - this.arrowFunctionToExpression(); - }; -} -function unwrapFunctionEnvironment() { - if (!this.isArrowFunctionExpression() && !this.isFunctionExpression() && !this.isFunctionDeclaration()) { - throw this.buildCodeFrameError("Can only unwrap the environment of a function."); - } - hoistFunctionEnvironment(this); -} -function setType(path, type) { - path.node.type = type; -} -function arrowFunctionToExpression({ - allowInsertArrow = true, - allowInsertArrowWithRest = allowInsertArrow, - noNewArrows = !(_arguments$ => (_arguments$ = arguments[0]) == null ? void 0 : _arguments$.specCompliant)() -} = {}) { - if (!this.isArrowFunctionExpression()) { - throw this.buildCodeFrameError("Cannot convert non-arrow function to a function expression."); - } - const { - thisBinding, - fnPath: fn - } = hoistFunctionEnvironment(this, noNewArrows, allowInsertArrow, allowInsertArrowWithRest); - fn.ensureBlock(); - setType(fn, "FunctionExpression"); - if (!noNewArrows) { - const checkBinding = thisBinding ? null : fn.scope.generateUidIdentifier("arrowCheckId"); - if (checkBinding) { - fn.parentPath.scope.push({ - id: checkBinding, - init: objectExpression([]) - }); - } - fn.get("body").unshiftContainer("body", expressionStatement(callExpression(this.hub.addHelper("newArrowCheck"), [thisExpression(), checkBinding ? identifier(checkBinding.name) : identifier(thisBinding)]))); - fn.replaceWith(callExpression(memberExpression((0, _helperFunctionName.default)(this, true) || fn.node, identifier("bind")), [checkBinding ? identifier(checkBinding.name) : thisExpression()])); - return fn.get("callee.object"); - } - return fn; -} -const getSuperCallsVisitor = (0, _visitors.merge)([{ - CallExpression(child, { - allSuperCalls - }) { - if (!child.get("callee").isSuper()) return; - allSuperCalls.push(child); - } -}, _helperEnvironmentVisitor.default]); -function hoistFunctionEnvironment(fnPath, noNewArrows = true, allowInsertArrow = true, allowInsertArrowWithRest = true) { - let arrowParent; - let thisEnvFn = fnPath.findParent(p => { - if (p.isArrowFunctionExpression()) { - var _arrowParent; - (_arrowParent = arrowParent) != null ? _arrowParent : arrowParent = p; - return false; - } - return p.isFunction() || p.isProgram() || p.isClassProperty({ - static: false - }) || p.isClassPrivateProperty({ - static: false - }); - }); - const inConstructor = thisEnvFn.isClassMethod({ - kind: "constructor" - }); - if (thisEnvFn.isClassProperty() || thisEnvFn.isClassPrivateProperty()) { - if (arrowParent) { - thisEnvFn = arrowParent; - } else if (allowInsertArrow) { - fnPath.replaceWith(callExpression(arrowFunctionExpression([], toExpression(fnPath.node)), [])); - thisEnvFn = fnPath.get("callee"); - fnPath = thisEnvFn.get("body"); - } else { - throw fnPath.buildCodeFrameError("Unable to transform arrow inside class property"); - } - } - const { - thisPaths, - argumentsPaths, - newTargetPaths, - superProps, - superCalls - } = getScopeInformation(fnPath); - if (inConstructor && superCalls.length > 0) { - if (!allowInsertArrow) { - throw superCalls[0].buildCodeFrameError("When using '@babel/plugin-transform-arrow-functions', " + "it's not possible to compile `super()` in an arrow function without compiling classes.\n" + "Please add '@babel/plugin-transform-classes' to your Babel configuration."); - } - if (!allowInsertArrowWithRest) { - throw superCalls[0].buildCodeFrameError("When using '@babel/plugin-transform-parameters', " + "it's not possible to compile `super()` in an arrow function with default or rest parameters without compiling classes.\n" + "Please add '@babel/plugin-transform-classes' to your Babel configuration."); - } - const allSuperCalls = []; - thisEnvFn.traverse(getSuperCallsVisitor, { - allSuperCalls - }); - const superBinding = getSuperBinding(thisEnvFn); - allSuperCalls.forEach(superCall => { - const callee = identifier(superBinding); - callee.loc = superCall.node.callee.loc; - superCall.get("callee").replaceWith(callee); - }); - } - if (argumentsPaths.length > 0) { - const argumentsBinding = getBinding(thisEnvFn, "arguments", () => { - const args = () => identifier("arguments"); - if (thisEnvFn.scope.path.isProgram()) { - return conditionalExpression(binaryExpression("===", unaryExpression("typeof", args()), stringLiteral("undefined")), thisEnvFn.scope.buildUndefinedNode(), args()); - } else { - return args(); - } - }); - argumentsPaths.forEach(argumentsChild => { - const argsRef = identifier(argumentsBinding); - argsRef.loc = argumentsChild.node.loc; - argumentsChild.replaceWith(argsRef); - }); - } - if (newTargetPaths.length > 0) { - const newTargetBinding = getBinding(thisEnvFn, "newtarget", () => metaProperty(identifier("new"), identifier("target"))); - newTargetPaths.forEach(targetChild => { - const targetRef = identifier(newTargetBinding); - targetRef.loc = targetChild.node.loc; - targetChild.replaceWith(targetRef); - }); - } - if (superProps.length > 0) { - if (!allowInsertArrow) { - throw superProps[0].buildCodeFrameError("When using '@babel/plugin-transform-arrow-functions', " + "it's not possible to compile `super.prop` in an arrow function without compiling classes.\n" + "Please add '@babel/plugin-transform-classes' to your Babel configuration."); - } - const flatSuperProps = superProps.reduce((acc, superProp) => acc.concat(standardizeSuperProperty(superProp)), []); - flatSuperProps.forEach(superProp => { - const key = superProp.node.computed ? "" : superProp.get("property").node.name; - const superParentPath = superProp.parentPath; - const isAssignment = superParentPath.isAssignmentExpression({ - left: superProp.node - }); - const isCall = superParentPath.isCallExpression({ - callee: superProp.node - }); - const isTaggedTemplate = superParentPath.isTaggedTemplateExpression({ - tag: superProp.node - }); - const superBinding = getSuperPropBinding(thisEnvFn, isAssignment, key); - const args = []; - if (superProp.node.computed) { - args.push(superProp.get("property").node); - } - if (isAssignment) { - const value = superParentPath.node.right; - args.push(value); - } - const call = callExpression(identifier(superBinding), args); - if (isCall) { - superParentPath.unshiftContainer("arguments", thisExpression()); - superProp.replaceWith(memberExpression(call, identifier("call"))); - thisPaths.push(superParentPath.get("arguments.0")); - } else if (isAssignment) { - superParentPath.replaceWith(call); - } else if (isTaggedTemplate) { - superProp.replaceWith(callExpression(memberExpression(call, identifier("bind"), false), [thisExpression()])); - thisPaths.push(superProp.get("arguments.0")); - } else { - superProp.replaceWith(call); - } - }); - } - let thisBinding; - if (thisPaths.length > 0 || !noNewArrows) { - thisBinding = getThisBinding(thisEnvFn, inConstructor); - if (noNewArrows || inConstructor && hasSuperClass(thisEnvFn)) { - thisPaths.forEach(thisChild => { - const thisRef = thisChild.isJSX() ? jsxIdentifier(thisBinding) : identifier(thisBinding); - thisRef.loc = thisChild.node.loc; - thisChild.replaceWith(thisRef); - }); - if (!noNewArrows) thisBinding = null; - } - } - return { - thisBinding, - fnPath - }; -} -function isLogicalOp(op) { - return LOGICAL_OPERATORS.includes(op); -} -function standardizeSuperProperty(superProp) { - if (superProp.parentPath.isAssignmentExpression() && superProp.parentPath.node.operator !== "=") { - const assignmentPath = superProp.parentPath; - const op = assignmentPath.node.operator.slice(0, -1); - const value = assignmentPath.node.right; - const isLogicalAssignment = isLogicalOp(op); - if (superProp.node.computed) { - const tmp = superProp.scope.generateDeclaredUidIdentifier("tmp"); - const object = superProp.node.object; - const property = superProp.node.property; - assignmentPath.get("left").replaceWith(memberExpression(object, assignmentExpression("=", tmp, property), true)); - assignmentPath.get("right").replaceWith(rightExpression(isLogicalAssignment ? "=" : op, memberExpression(object, identifier(tmp.name), true), value)); - } else { - const object = superProp.node.object; - const property = superProp.node.property; - assignmentPath.get("left").replaceWith(memberExpression(object, property)); - assignmentPath.get("right").replaceWith(rightExpression(isLogicalAssignment ? "=" : op, memberExpression(object, identifier(property.name)), value)); - } - if (isLogicalAssignment) { - assignmentPath.replaceWith(logicalExpression(op, assignmentPath.node.left, assignmentPath.node.right)); - } else { - assignmentPath.node.operator = "="; - } - return [assignmentPath.get("left"), assignmentPath.get("right").get("left")]; - } else if (superProp.parentPath.isUpdateExpression()) { - const updateExpr = superProp.parentPath; - const tmp = superProp.scope.generateDeclaredUidIdentifier("tmp"); - const computedKey = superProp.node.computed ? superProp.scope.generateDeclaredUidIdentifier("prop") : null; - const parts = [assignmentExpression("=", tmp, memberExpression(superProp.node.object, computedKey ? assignmentExpression("=", computedKey, superProp.node.property) : superProp.node.property, superProp.node.computed)), assignmentExpression("=", memberExpression(superProp.node.object, computedKey ? identifier(computedKey.name) : superProp.node.property, superProp.node.computed), binaryExpression(superProp.parentPath.node.operator[0], identifier(tmp.name), numericLiteral(1)))]; - if (!superProp.parentPath.node.prefix) { - parts.push(identifier(tmp.name)); - } - updateExpr.replaceWith(sequenceExpression(parts)); - const left = updateExpr.get("expressions.0.right"); - const right = updateExpr.get("expressions.1.left"); - return [left, right]; - } - return [superProp]; - function rightExpression(op, left, right) { - if (op === "=") { - return assignmentExpression("=", left, right); - } else { - return binaryExpression(op, left, right); - } - } -} -function hasSuperClass(thisEnvFn) { - return thisEnvFn.isClassMethod() && !!thisEnvFn.parentPath.parentPath.node.superClass; -} -const assignSuperThisVisitor = (0, _visitors.merge)([{ - CallExpression(child, { - supers, - thisBinding - }) { - if (!child.get("callee").isSuper()) return; - if (supers.has(child.node)) return; - supers.add(child.node); - child.replaceWithMultiple([child.node, assignmentExpression("=", identifier(thisBinding), identifier("this"))]); - } -}, _helperEnvironmentVisitor.default]); -function getThisBinding(thisEnvFn, inConstructor) { - return getBinding(thisEnvFn, "this", thisBinding => { - if (!inConstructor || !hasSuperClass(thisEnvFn)) return thisExpression(); - thisEnvFn.traverse(assignSuperThisVisitor, { - supers: new WeakSet(), - thisBinding - }); - }); -} -function getSuperBinding(thisEnvFn) { - return getBinding(thisEnvFn, "supercall", () => { - const argsBinding = thisEnvFn.scope.generateUidIdentifier("args"); - return arrowFunctionExpression([restElement(argsBinding)], callExpression(_super(), [spreadElement(identifier(argsBinding.name))])); - }); -} -function getSuperPropBinding(thisEnvFn, isAssignment, propName) { - const op = isAssignment ? "set" : "get"; - return getBinding(thisEnvFn, `superprop_${op}:${propName || ""}`, () => { - const argsList = []; - let fnBody; - if (propName) { - fnBody = memberExpression(_super(), identifier(propName)); - } else { - const method = thisEnvFn.scope.generateUidIdentifier("prop"); - argsList.unshift(method); - fnBody = memberExpression(_super(), identifier(method.name), true); - } - if (isAssignment) { - const valueIdent = thisEnvFn.scope.generateUidIdentifier("value"); - argsList.push(valueIdent); - fnBody = assignmentExpression("=", fnBody, identifier(valueIdent.name)); - } - return arrowFunctionExpression(argsList, fnBody); - }); -} -function getBinding(thisEnvFn, key, init) { - const cacheKey = "binding:" + key; - let data = thisEnvFn.getData(cacheKey); - if (!data) { - const id = thisEnvFn.scope.generateUidIdentifier(key); - data = id.name; - thisEnvFn.setData(cacheKey, data); - thisEnvFn.scope.push({ - id: id, - init: init(data) - }); - } - return data; -} -const getScopeInformationVisitor = (0, _visitors.merge)([{ - ThisExpression(child, { - thisPaths - }) { - thisPaths.push(child); - }, - JSXIdentifier(child, { - thisPaths - }) { - if (child.node.name !== "this") return; - if (!child.parentPath.isJSXMemberExpression({ - object: child.node - }) && !child.parentPath.isJSXOpeningElement({ - name: child.node - })) { - return; - } - thisPaths.push(child); - }, - CallExpression(child, { - superCalls - }) { - if (child.get("callee").isSuper()) superCalls.push(child); - }, - MemberExpression(child, { - superProps - }) { - if (child.get("object").isSuper()) superProps.push(child); - }, - Identifier(child, { - argumentsPaths - }) { - if (!child.isReferencedIdentifier({ - name: "arguments" - })) return; - let curr = child.scope; - do { - if (curr.hasOwnBinding("arguments")) { - curr.rename("arguments"); - return; - } - if (curr.path.isFunction() && !curr.path.isArrowFunctionExpression()) { - break; - } - } while (curr = curr.parent); - argumentsPaths.push(child); - }, - MetaProperty(child, { - newTargetPaths - }) { - if (!child.get("meta").isIdentifier({ - name: "new" - })) return; - if (!child.get("property").isIdentifier({ - name: "target" - })) return; - newTargetPaths.push(child); - } -}, _helperEnvironmentVisitor.default]); -function getScopeInformation(fnPath) { - const thisPaths = []; - const argumentsPaths = []; - const newTargetPaths = []; - const superProps = []; - const superCalls = []; - fnPath.traverse(getScopeInformationVisitor, { - thisPaths, - argumentsPaths, - newTargetPaths, - superProps, - superCalls - }); - return { - thisPaths, - argumentsPaths, - newTargetPaths, - superProps, - superCalls - }; -} - -//# sourceMappingURL=conversion.js.map diff --git a/tools/eslint/node_modules/@babel/traverse/lib/path/evaluation.js b/tools/eslint/node_modules/@babel/traverse/lib/path/evaluation.js deleted file mode 100644 index 7bbe82fbff6e66..00000000000000 --- a/tools/eslint/node_modules/@babel/traverse/lib/path/evaluation.js +++ /dev/null @@ -1,347 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.evaluate = evaluate; -exports.evaluateTruthy = evaluateTruthy; -const VALID_OBJECT_CALLEES = ["Number", "String", "Math"]; -const VALID_IDENTIFIER_CALLEES = ["isFinite", "isNaN", "parseFloat", "parseInt", "decodeURI", "decodeURIComponent", "encodeURI", "encodeURIComponent", null, null]; -const INVALID_METHODS = ["random"]; -function isValidObjectCallee(val) { - return VALID_OBJECT_CALLEES.includes(val); -} -function isValidIdentifierCallee(val) { - return VALID_IDENTIFIER_CALLEES.includes(val); -} -function isInvalidMethod(val) { - return INVALID_METHODS.includes(val); -} -function evaluateTruthy() { - const res = this.evaluate(); - if (res.confident) return !!res.value; -} -function deopt(path, state) { - if (!state.confident) return; - state.deoptPath = path; - state.confident = false; -} -const Globals = new Map([["undefined", undefined], ["Infinity", Infinity], ["NaN", NaN]]); -function evaluateCached(path, state) { - const { - node - } = path; - const { - seen - } = state; - if (seen.has(node)) { - const existing = seen.get(node); - if (existing.resolved) { - return existing.value; - } else { - deopt(path, state); - return; - } - } else { - const item = { - resolved: false - }; - seen.set(node, item); - const val = _evaluate(path, state); - if (state.confident) { - item.resolved = true; - item.value = val; - } - return val; - } -} -function _evaluate(path, state) { - if (!state.confident) return; - if (path.isSequenceExpression()) { - const exprs = path.get("expressions"); - return evaluateCached(exprs[exprs.length - 1], state); - } - if (path.isStringLiteral() || path.isNumericLiteral() || path.isBooleanLiteral()) { - return path.node.value; - } - if (path.isNullLiteral()) { - return null; - } - if (path.isTemplateLiteral()) { - return evaluateQuasis(path, path.node.quasis, state); - } - if (path.isTaggedTemplateExpression() && path.get("tag").isMemberExpression()) { - const object = path.get("tag.object"); - const { - node: { - name - } - } = object; - const property = path.get("tag.property"); - if (object.isIdentifier() && name === "String" && !path.scope.getBinding(name) && property.isIdentifier() && property.node.name === "raw") { - return evaluateQuasis(path, path.node.quasi.quasis, state, true); - } - } - if (path.isConditionalExpression()) { - const testResult = evaluateCached(path.get("test"), state); - if (!state.confident) return; - if (testResult) { - return evaluateCached(path.get("consequent"), state); - } else { - return evaluateCached(path.get("alternate"), state); - } - } - if (path.isExpressionWrapper()) { - return evaluateCached(path.get("expression"), state); - } - if (path.isMemberExpression() && !path.parentPath.isCallExpression({ - callee: path.node - })) { - const property = path.get("property"); - const object = path.get("object"); - if (object.isLiteral()) { - const value = object.node.value; - const type = typeof value; - let key = null; - if (path.node.computed) { - key = evaluateCached(property, state); - if (!state.confident) return; - } else if (property.isIdentifier()) { - key = property.node.name; - } - if ((type === "number" || type === "string") && key != null && (typeof key === "number" || typeof key === "string")) { - return value[key]; - } - } - } - if (path.isReferencedIdentifier()) { - const binding = path.scope.getBinding(path.node.name); - if (binding) { - if (binding.constantViolations.length > 0 || path.node.start < binding.path.node.end) { - deopt(binding.path, state); - return; - } - if (binding.hasValue) { - return binding.value; - } - } - const name = path.node.name; - if (Globals.has(name)) { - if (!binding) { - return Globals.get(name); - } - deopt(binding.path, state); - return; - } - const resolved = path.resolve(); - if (resolved === path) { - deopt(path, state); - return; - } else { - return evaluateCached(resolved, state); - } - } - if (path.isUnaryExpression({ - prefix: true - })) { - if (path.node.operator === "void") { - return undefined; - } - const argument = path.get("argument"); - if (path.node.operator === "typeof" && (argument.isFunction() || argument.isClass())) { - return "function"; - } - const arg = evaluateCached(argument, state); - if (!state.confident) return; - switch (path.node.operator) { - case "!": - return !arg; - case "+": - return +arg; - case "-": - return -arg; - case "~": - return ~arg; - case "typeof": - return typeof arg; - } - } - if (path.isArrayExpression()) { - const arr = []; - const elems = path.get("elements"); - for (const elem of elems) { - const elemValue = elem.evaluate(); - if (elemValue.confident) { - arr.push(elemValue.value); - } else { - deopt(elemValue.deopt, state); - return; - } - } - return arr; - } - if (path.isObjectExpression()) { - const obj = {}; - const props = path.get("properties"); - for (const prop of props) { - if (prop.isObjectMethod() || prop.isSpreadElement()) { - deopt(prop, state); - return; - } - const keyPath = prop.get("key"); - let key; - if (prop.node.computed) { - key = keyPath.evaluate(); - if (!key.confident) { - deopt(key.deopt, state); - return; - } - key = key.value; - } else if (keyPath.isIdentifier()) { - key = keyPath.node.name; - } else { - key = keyPath.node.value; - } - const valuePath = prop.get("value"); - let value = valuePath.evaluate(); - if (!value.confident) { - deopt(value.deopt, state); - return; - } - value = value.value; - obj[key] = value; - } - return obj; - } - if (path.isLogicalExpression()) { - const wasConfident = state.confident; - const left = evaluateCached(path.get("left"), state); - const leftConfident = state.confident; - state.confident = wasConfident; - const right = evaluateCached(path.get("right"), state); - const rightConfident = state.confident; - switch (path.node.operator) { - case "||": - state.confident = leftConfident && (!!left || rightConfident); - if (!state.confident) return; - return left || right; - case "&&": - state.confident = leftConfident && (!left || rightConfident); - if (!state.confident) return; - return left && right; - case "??": - state.confident = leftConfident && (left != null || rightConfident); - if (!state.confident) return; - return left != null ? left : right; - } - } - if (path.isBinaryExpression()) { - const left = evaluateCached(path.get("left"), state); - if (!state.confident) return; - const right = evaluateCached(path.get("right"), state); - if (!state.confident) return; - switch (path.node.operator) { - case "-": - return left - right; - case "+": - return left + right; - case "/": - return left / right; - case "*": - return left * right; - case "%": - return left % right; - case "**": - return Math.pow(left, right); - case "<": - return left < right; - case ">": - return left > right; - case "<=": - return left <= right; - case ">=": - return left >= right; - case "==": - return left == right; - case "!=": - return left != right; - case "===": - return left === right; - case "!==": - return left !== right; - case "|": - return left | right; - case "&": - return left & right; - case "^": - return left ^ right; - case "<<": - return left << right; - case ">>": - return left >> right; - case ">>>": - return left >>> right; - } - } - if (path.isCallExpression()) { - const callee = path.get("callee"); - let context; - let func; - if (callee.isIdentifier() && !path.scope.getBinding(callee.node.name) && (isValidObjectCallee(callee.node.name) || isValidIdentifierCallee(callee.node.name))) { - func = global[callee.node.name]; - } - if (callee.isMemberExpression()) { - const object = callee.get("object"); - const property = callee.get("property"); - if (object.isIdentifier() && property.isIdentifier() && isValidObjectCallee(object.node.name) && !isInvalidMethod(property.node.name)) { - context = global[object.node.name]; - const key = property.node.name; - if (hasOwnProperty.call(context, key)) { - func = context[key]; - } - } - if (object.isLiteral() && property.isIdentifier()) { - const type = typeof object.node.value; - if (type === "string" || type === "number") { - context = object.node.value; - func = context[property.node.name]; - } - } - } - if (func) { - const args = path.get("arguments").map(arg => evaluateCached(arg, state)); - if (!state.confident) return; - return func.apply(context, args); - } - } - deopt(path, state); -} -function evaluateQuasis(path, quasis, state, raw = false) { - let str = ""; - let i = 0; - const exprs = path.isTemplateLiteral() ? path.get("expressions") : path.get("quasi.expressions"); - for (const elem of quasis) { - if (!state.confident) break; - str += raw ? elem.value.raw : elem.value.cooked; - const expr = exprs[i++]; - if (expr) str += String(evaluateCached(expr, state)); - } - if (!state.confident) return; - return str; -} -function evaluate() { - const state = { - confident: true, - deoptPath: null, - seen: new Map() - }; - let value = evaluateCached(this, state); - if (!state.confident) value = undefined; - return { - confident: state.confident, - deopt: state.deoptPath, - value: value - }; -} - -//# sourceMappingURL=evaluation.js.map diff --git a/tools/eslint/node_modules/@babel/traverse/lib/path/family.js b/tools/eslint/node_modules/@babel/traverse/lib/path/family.js deleted file mode 100644 index 377a4642b7eb05..00000000000000 --- a/tools/eslint/node_modules/@babel/traverse/lib/path/family.js +++ /dev/null @@ -1,335 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports._getKey = _getKey; -exports._getPattern = _getPattern; -exports.get = get; -exports.getAllNextSiblings = getAllNextSiblings; -exports.getAllPrevSiblings = getAllPrevSiblings; -exports.getBindingIdentifierPaths = getBindingIdentifierPaths; -exports.getBindingIdentifiers = getBindingIdentifiers; -exports.getCompletionRecords = getCompletionRecords; -exports.getNextSibling = getNextSibling; -exports.getOpposite = getOpposite; -exports.getOuterBindingIdentifierPaths = getOuterBindingIdentifierPaths; -exports.getOuterBindingIdentifiers = getOuterBindingIdentifiers; -exports.getPrevSibling = getPrevSibling; -exports.getSibling = getSibling; -var _index = require("./index.js"); -var _t = require("@babel/types"); -const { - getBindingIdentifiers: _getBindingIdentifiers, - getOuterBindingIdentifiers: _getOuterBindingIdentifiers, - numericLiteral, - unaryExpression -} = _t; -const NORMAL_COMPLETION = 0; -const BREAK_COMPLETION = 1; -function NormalCompletion(path) { - return { - type: NORMAL_COMPLETION, - path - }; -} -function BreakCompletion(path) { - return { - type: BREAK_COMPLETION, - path - }; -} -function getOpposite() { - if (this.key === "left") { - return this.getSibling("right"); - } else if (this.key === "right") { - return this.getSibling("left"); - } - return null; -} -function addCompletionRecords(path, records, context) { - if (path) { - records.push(..._getCompletionRecords(path, context)); - } - return records; -} -function completionRecordForSwitch(cases, records, context) { - let lastNormalCompletions = []; - for (let i = 0; i < cases.length; i++) { - const casePath = cases[i]; - const caseCompletions = _getCompletionRecords(casePath, context); - const normalCompletions = []; - const breakCompletions = []; - for (const c of caseCompletions) { - if (c.type === NORMAL_COMPLETION) { - normalCompletions.push(c); - } - if (c.type === BREAK_COMPLETION) { - breakCompletions.push(c); - } - } - if (normalCompletions.length) { - lastNormalCompletions = normalCompletions; - } - records.push(...breakCompletions); - } - records.push(...lastNormalCompletions); - return records; -} -function normalCompletionToBreak(completions) { - completions.forEach(c => { - c.type = BREAK_COMPLETION; - }); -} -function replaceBreakStatementInBreakCompletion(completions, reachable) { - completions.forEach(c => { - if (c.path.isBreakStatement({ - label: null - })) { - if (reachable) { - c.path.replaceWith(unaryExpression("void", numericLiteral(0))); - } else { - c.path.remove(); - } - } - }); -} -function getStatementListCompletion(paths, context) { - const completions = []; - if (context.canHaveBreak) { - let lastNormalCompletions = []; - for (let i = 0; i < paths.length; i++) { - const path = paths[i]; - const newContext = Object.assign({}, context, { - inCaseClause: false - }); - if (path.isBlockStatement() && (context.inCaseClause || context.shouldPopulateBreak)) { - newContext.shouldPopulateBreak = true; - } else { - newContext.shouldPopulateBreak = false; - } - const statementCompletions = _getCompletionRecords(path, newContext); - if (statementCompletions.length > 0 && statementCompletions.every(c => c.type === BREAK_COMPLETION)) { - if (lastNormalCompletions.length > 0 && statementCompletions.every(c => c.path.isBreakStatement({ - label: null - }))) { - normalCompletionToBreak(lastNormalCompletions); - completions.push(...lastNormalCompletions); - if (lastNormalCompletions.some(c => c.path.isDeclaration())) { - completions.push(...statementCompletions); - replaceBreakStatementInBreakCompletion(statementCompletions, true); - } - replaceBreakStatementInBreakCompletion(statementCompletions, false); - } else { - completions.push(...statementCompletions); - if (!context.shouldPopulateBreak) { - replaceBreakStatementInBreakCompletion(statementCompletions, true); - } - } - break; - } - if (i === paths.length - 1) { - completions.push(...statementCompletions); - } else { - lastNormalCompletions = []; - for (let i = 0; i < statementCompletions.length; i++) { - const c = statementCompletions[i]; - if (c.type === BREAK_COMPLETION) { - completions.push(c); - } - if (c.type === NORMAL_COMPLETION) { - lastNormalCompletions.push(c); - } - } - } - } - } else if (paths.length) { - for (let i = paths.length - 1; i >= 0; i--) { - const pathCompletions = _getCompletionRecords(paths[i], context); - if (pathCompletions.length > 1 || pathCompletions.length === 1 && !pathCompletions[0].path.isVariableDeclaration()) { - completions.push(...pathCompletions); - break; - } - } - } - return completions; -} -function _getCompletionRecords(path, context) { - let records = []; - if (path.isIfStatement()) { - records = addCompletionRecords(path.get("consequent"), records, context); - records = addCompletionRecords(path.get("alternate"), records, context); - } else if (path.isDoExpression() || path.isFor() || path.isWhile() || path.isLabeledStatement()) { - return addCompletionRecords(path.get("body"), records, context); - } else if (path.isProgram() || path.isBlockStatement()) { - return getStatementListCompletion(path.get("body"), context); - } else if (path.isFunction()) { - return _getCompletionRecords(path.get("body"), context); - } else if (path.isTryStatement()) { - records = addCompletionRecords(path.get("block"), records, context); - records = addCompletionRecords(path.get("handler"), records, context); - } else if (path.isCatchClause()) { - return addCompletionRecords(path.get("body"), records, context); - } else if (path.isSwitchStatement()) { - return completionRecordForSwitch(path.get("cases"), records, context); - } else if (path.isSwitchCase()) { - return getStatementListCompletion(path.get("consequent"), { - canHaveBreak: true, - shouldPopulateBreak: false, - inCaseClause: true - }); - } else if (path.isBreakStatement()) { - records.push(BreakCompletion(path)); - } else { - records.push(NormalCompletion(path)); - } - return records; -} -function getCompletionRecords() { - const records = _getCompletionRecords(this, { - canHaveBreak: false, - shouldPopulateBreak: false, - inCaseClause: false - }); - return records.map(r => r.path); -} -function getSibling(key) { - return _index.default.get({ - parentPath: this.parentPath, - parent: this.parent, - container: this.container, - listKey: this.listKey, - key: key - }).setContext(this.context); -} -function getPrevSibling() { - return this.getSibling(this.key - 1); -} -function getNextSibling() { - return this.getSibling(this.key + 1); -} -function getAllNextSiblings() { - let _key = this.key; - let sibling = this.getSibling(++_key); - const siblings = []; - while (sibling.node) { - siblings.push(sibling); - sibling = this.getSibling(++_key); - } - return siblings; -} -function getAllPrevSiblings() { - let _key = this.key; - let sibling = this.getSibling(--_key); - const siblings = []; - while (sibling.node) { - siblings.push(sibling); - sibling = this.getSibling(--_key); - } - return siblings; -} -function get(key, context = true) { - if (context === true) context = this.context; - const parts = key.split("."); - if (parts.length === 1) { - return _getKey.call(this, key, context); - } else { - return _getPattern.call(this, parts, context); - } -} -function _getKey(key, context) { - const node = this.node; - const container = node[key]; - if (Array.isArray(container)) { - return container.map((_, i) => { - return _index.default.get({ - listKey: key, - parentPath: this, - parent: node, - container: container, - key: i - }).setContext(context); - }); - } else { - return _index.default.get({ - parentPath: this, - parent: node, - container: node, - key: key - }).setContext(context); - } -} -function _getPattern(parts, context) { - let path = this; - for (const part of parts) { - if (part === ".") { - path = path.parentPath; - } else { - if (Array.isArray(path)) { - path = path[part]; - } else { - path = path.get(part, context); - } - } - } - return path; -} -function getBindingIdentifiers(duplicates) { - return _getBindingIdentifiers(this.node, duplicates); -} -function getOuterBindingIdentifiers(duplicates) { - return _getOuterBindingIdentifiers(this.node, duplicates); -} -function getBindingIdentifierPaths(duplicates = false, outerOnly = false) { - const path = this; - const search = [path]; - const ids = Object.create(null); - while (search.length) { - const id = search.shift(); - if (!id) continue; - if (!id.node) continue; - const keys = _getBindingIdentifiers.keys[id.node.type]; - if (id.isIdentifier()) { - if (duplicates) { - const _ids = ids[id.node.name] = ids[id.node.name] || []; - _ids.push(id); - } else { - ids[id.node.name] = id; - } - continue; - } - if (id.isExportDeclaration()) { - const declaration = id.get("declaration"); - if (declaration.isDeclaration()) { - search.push(declaration); - } - continue; - } - if (outerOnly) { - if (id.isFunctionDeclaration()) { - search.push(id.get("id")); - continue; - } - if (id.isFunctionExpression()) { - continue; - } - } - if (keys) { - for (let i = 0; i < keys.length; i++) { - const key = keys[i]; - const child = id.get(key); - if (Array.isArray(child)) { - search.push(...child); - } else if (child.node) { - search.push(child); - } - } - } - } - return ids; -} -function getOuterBindingIdentifierPaths(duplicates = false) { - return this.getBindingIdentifierPaths(duplicates, true); -} - -//# sourceMappingURL=family.js.map diff --git a/tools/eslint/node_modules/@babel/traverse/lib/path/index.js b/tools/eslint/node_modules/@babel/traverse/lib/path/index.js deleted file mode 100644 index b40493f15d9007..00000000000000 --- a/tools/eslint/node_modules/@babel/traverse/lib/path/index.js +++ /dev/null @@ -1,287 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.default = exports.SHOULD_STOP = exports.SHOULD_SKIP = exports.REMOVED = void 0; -var virtualTypes = require("./lib/virtual-types.js"); -var _debug = require("debug"); -var _index = require("../index.js"); -var _index2 = require("../scope/index.js"); -var _t = require("@babel/types"); -var t = _t; -var cache = require("../cache.js"); -var _generator = require("@babel/generator"); -var NodePath_ancestry = require("./ancestry.js"); -var NodePath_inference = require("./inference/index.js"); -var NodePath_replacement = require("./replacement.js"); -var NodePath_evaluation = require("./evaluation.js"); -var NodePath_conversion = require("./conversion.js"); -var NodePath_introspection = require("./introspection.js"); -var NodePath_context = require("./context.js"); -var NodePath_removal = require("./removal.js"); -var NodePath_modification = require("./modification.js"); -var NodePath_family = require("./family.js"); -var NodePath_comments = require("./comments.js"); -var NodePath_virtual_types_validator = require("./lib/virtual-types-validator.js"); -const { - validate -} = _t; -const debug = _debug("babel"); -const REMOVED = exports.REMOVED = 1 << 0; -const SHOULD_STOP = exports.SHOULD_STOP = 1 << 1; -const SHOULD_SKIP = exports.SHOULD_SKIP = 1 << 2; -const NodePath_Final = exports.default = class NodePath { - constructor(hub, parent) { - this.contexts = []; - this.state = null; - this.opts = null; - this._traverseFlags = 0; - this.skipKeys = null; - this.parentPath = null; - this.container = null; - this.listKey = null; - this.key = null; - this.node = null; - this.type = null; - this.parent = parent; - this.hub = hub; - this.data = null; - this.context = null; - this.scope = null; - } - get removed() { - return (this._traverseFlags & 1) > 0; - } - set removed(v) { - if (v) this._traverseFlags |= 1;else this._traverseFlags &= -2; - } - get shouldStop() { - return (this._traverseFlags & 2) > 0; - } - set shouldStop(v) { - if (v) this._traverseFlags |= 2;else this._traverseFlags &= -3; - } - get shouldSkip() { - return (this._traverseFlags & 4) > 0; - } - set shouldSkip(v) { - if (v) this._traverseFlags |= 4;else this._traverseFlags &= -5; - } - static get({ - hub, - parentPath, - parent, - container, - listKey, - key - }) { - if (!hub && parentPath) { - hub = parentPath.hub; - } - if (!parent) { - throw new Error("To get a node path the parent needs to exist"); - } - const targetNode = container[key]; - const paths = cache.getOrCreateCachedPaths(hub, parent); - let path = paths.get(targetNode); - if (!path) { - path = new NodePath(hub, parent); - if (targetNode) paths.set(targetNode, path); - } - path.setup(parentPath, container, listKey, key); - return path; - } - getScope(scope) { - return this.isScope() ? new _index2.default(this) : scope; - } - setData(key, val) { - if (this.data == null) { - this.data = Object.create(null); - } - return this.data[key] = val; - } - getData(key, def) { - if (this.data == null) { - this.data = Object.create(null); - } - let val = this.data[key]; - if (val === undefined && def !== undefined) val = this.data[key] = def; - return val; - } - hasNode() { - return this.node != null; - } - buildCodeFrameError(msg, Error = SyntaxError) { - return this.hub.buildError(this.node, msg, Error); - } - traverse(visitor, state) { - (0, _index.default)(this.node, visitor, this.scope, state, this); - } - set(key, node) { - validate(this.node, key, node); - this.node[key] = node; - } - getPathLocation() { - const parts = []; - let path = this; - do { - let key = path.key; - if (path.inList) key = `${path.listKey}[${key}]`; - parts.unshift(key); - } while (path = path.parentPath); - return parts.join("."); - } - debug(message) { - if (!debug.enabled) return; - debug(`${this.getPathLocation()} ${this.type}: ${message}`); - } - toString() { - return (0, _generator.default)(this.node).code; - } - get inList() { - return !!this.listKey; - } - set inList(inList) { - if (!inList) { - this.listKey = null; - } - } - get parentKey() { - return this.listKey || this.key; - } -}; -const methods = { - findParent: NodePath_ancestry.findParent, - find: NodePath_ancestry.find, - getFunctionParent: NodePath_ancestry.getFunctionParent, - getStatementParent: NodePath_ancestry.getStatementParent, - getEarliestCommonAncestorFrom: NodePath_ancestry.getEarliestCommonAncestorFrom, - getDeepestCommonAncestorFrom: NodePath_ancestry.getDeepestCommonAncestorFrom, - getAncestry: NodePath_ancestry.getAncestry, - isAncestor: NodePath_ancestry.isAncestor, - isDescendant: NodePath_ancestry.isDescendant, - inType: NodePath_ancestry.inType, - getTypeAnnotation: NodePath_inference.getTypeAnnotation, - isBaseType: NodePath_inference.isBaseType, - couldBeBaseType: NodePath_inference.couldBeBaseType, - baseTypeStrictlyMatches: NodePath_inference.baseTypeStrictlyMatches, - isGenericType: NodePath_inference.isGenericType, - replaceWithMultiple: NodePath_replacement.replaceWithMultiple, - replaceWithSourceString: NodePath_replacement.replaceWithSourceString, - replaceWith: NodePath_replacement.replaceWith, - replaceExpressionWithStatements: NodePath_replacement.replaceExpressionWithStatements, - replaceInline: NodePath_replacement.replaceInline, - evaluateTruthy: NodePath_evaluation.evaluateTruthy, - evaluate: NodePath_evaluation.evaluate, - toComputedKey: NodePath_conversion.toComputedKey, - ensureBlock: NodePath_conversion.ensureBlock, - unwrapFunctionEnvironment: NodePath_conversion.unwrapFunctionEnvironment, - arrowFunctionToExpression: NodePath_conversion.arrowFunctionToExpression, - matchesPattern: NodePath_introspection.matchesPattern, - has: NodePath_introspection.has, - isStatic: NodePath_introspection.isStatic, - is: NodePath_introspection.is, - isnt: NodePath_introspection.isnt, - equals: NodePath_introspection.equals, - isNodeType: NodePath_introspection.isNodeType, - canHaveVariableDeclarationOrExpression: NodePath_introspection.canHaveVariableDeclarationOrExpression, - canSwapBetweenExpressionAndStatement: NodePath_introspection.canSwapBetweenExpressionAndStatement, - isCompletionRecord: NodePath_introspection.isCompletionRecord, - isStatementOrBlock: NodePath_introspection.isStatementOrBlock, - referencesImport: NodePath_introspection.referencesImport, - getSource: NodePath_introspection.getSource, - willIMaybeExecuteBefore: NodePath_introspection.willIMaybeExecuteBefore, - _guessExecutionStatusRelativeTo: NodePath_introspection._guessExecutionStatusRelativeTo, - resolve: NodePath_introspection.resolve, - isConstantExpression: NodePath_introspection.isConstantExpression, - isInStrictMode: NodePath_introspection.isInStrictMode, - call: NodePath_context.call, - isDenylisted: NodePath_context.isDenylisted, - isBlacklisted: NodePath_context.isBlacklisted, - visit: NodePath_context.visit, - skip: NodePath_context.skip, - skipKey: NodePath_context.skipKey, - stop: NodePath_context.stop, - setScope: NodePath_context.setScope, - setContext: NodePath_context.setContext, - resync: NodePath_context.resync, - popContext: NodePath_context.popContext, - pushContext: NodePath_context.pushContext, - setup: NodePath_context.setup, - setKey: NodePath_context.setKey, - requeue: NodePath_context.requeue, - remove: NodePath_removal.remove, - insertBefore: NodePath_modification.insertBefore, - insertAfter: NodePath_modification.insertAfter, - updateSiblingKeys: NodePath_modification.updateSiblingKeys, - unshiftContainer: NodePath_modification.unshiftContainer, - pushContainer: NodePath_modification.pushContainer, - hoist: NodePath_modification.hoist, - getOpposite: NodePath_family.getOpposite, - getCompletionRecords: NodePath_family.getCompletionRecords, - getSibling: NodePath_family.getSibling, - getPrevSibling: NodePath_family.getPrevSibling, - getNextSibling: NodePath_family.getNextSibling, - getAllNextSiblings: NodePath_family.getAllNextSiblings, - getAllPrevSiblings: NodePath_family.getAllPrevSiblings, - get: NodePath_family.get, - getBindingIdentifiers: NodePath_family.getBindingIdentifiers, - getOuterBindingIdentifiers: NodePath_family.getOuterBindingIdentifiers, - getBindingIdentifierPaths: NodePath_family.getBindingIdentifierPaths, - getOuterBindingIdentifierPaths: NodePath_family.getOuterBindingIdentifierPaths, - shareCommentsWithSiblings: NodePath_comments.shareCommentsWithSiblings, - addComment: NodePath_comments.addComment, - addComments: NodePath_comments.addComments -}; -Object.assign(NodePath_Final.prototype, methods); -{ - NodePath_Final.prototype.arrowFunctionToShadowed = NodePath_conversion[String("arrowFunctionToShadowed")]; -} -{ - NodePath_Final.prototype._guessExecutionStatusRelativeToDifferentFunctions = NodePath_introspection._guessExecutionStatusRelativeTo; -} -{ - NodePath_Final.prototype._guessExecutionStatusRelativeToDifferentFunctions = NodePath_introspection._guessExecutionStatusRelativeTo; - Object.assign(NodePath_Final.prototype, { - _getTypeAnnotation: NodePath_inference._getTypeAnnotation, - _replaceWith: NodePath_replacement._replaceWith, - _resolve: NodePath_introspection._resolve, - _call: NodePath_context._call, - _resyncParent: NodePath_context._resyncParent, - _resyncKey: NodePath_context._resyncKey, - _resyncList: NodePath_context._resyncList, - _resyncRemoved: NodePath_context._resyncRemoved, - _getQueueContexts: NodePath_context._getQueueContexts, - _removeFromScope: NodePath_removal._removeFromScope, - _callRemovalHooks: NodePath_removal._callRemovalHooks, - _remove: NodePath_removal._remove, - _markRemoved: NodePath_removal._markRemoved, - _assertUnremoved: NodePath_removal._assertUnremoved, - _containerInsert: NodePath_modification._containerInsert, - _containerInsertBefore: NodePath_modification._containerInsertBefore, - _containerInsertAfter: NodePath_modification._containerInsertAfter, - _verifyNodeList: NodePath_modification._verifyNodeList, - _getKey: NodePath_family._getKey, - _getPattern: NodePath_family._getPattern - }); -} -for (const type of t.TYPES) { - const typeKey = `is${type}`; - const fn = t[typeKey]; - NodePath_Final.prototype[typeKey] = function (opts) { - return fn(this.node, opts); - }; - NodePath_Final.prototype[`assert${type}`] = function (opts) { - if (!fn(this.node, opts)) { - throw new TypeError(`Expected node path of type ${type}`); - } - }; -} -Object.assign(NodePath_Final.prototype, NodePath_virtual_types_validator); -for (const type of Object.keys(virtualTypes)) { - if (type[0] === "_") continue; - if (!t.TYPES.includes(type)) t.TYPES.push(type); -} - -//# sourceMappingURL=index.js.map diff --git a/tools/eslint/node_modules/@babel/traverse/lib/path/inference/index.js b/tools/eslint/node_modules/@babel/traverse/lib/path/inference/index.js deleted file mode 100644 index c52eb7daa42cb8..00000000000000 --- a/tools/eslint/node_modules/@babel/traverse/lib/path/inference/index.js +++ /dev/null @@ -1,149 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports._getTypeAnnotation = _getTypeAnnotation; -exports.baseTypeStrictlyMatches = baseTypeStrictlyMatches; -exports.couldBeBaseType = couldBeBaseType; -exports.getTypeAnnotation = getTypeAnnotation; -exports.isBaseType = isBaseType; -exports.isGenericType = isGenericType; -var inferers = require("./inferers.js"); -var _t = require("@babel/types"); -const { - anyTypeAnnotation, - isAnyTypeAnnotation, - isArrayTypeAnnotation, - isBooleanTypeAnnotation, - isEmptyTypeAnnotation, - isFlowBaseAnnotation, - isGenericTypeAnnotation, - isIdentifier, - isMixedTypeAnnotation, - isNumberTypeAnnotation, - isStringTypeAnnotation, - isTSArrayType, - isTSTypeAnnotation, - isTSTypeReference, - isTupleTypeAnnotation, - isTypeAnnotation, - isUnionTypeAnnotation, - isVoidTypeAnnotation, - stringTypeAnnotation, - voidTypeAnnotation -} = _t; -function getTypeAnnotation() { - let type = this.getData("typeAnnotation"); - if (type != null) { - return type; - } - type = _getTypeAnnotation.call(this) || anyTypeAnnotation(); - if (isTypeAnnotation(type) || isTSTypeAnnotation(type)) { - type = type.typeAnnotation; - } - this.setData("typeAnnotation", type); - return type; -} -const typeAnnotationInferringNodes = new WeakSet(); -function _getTypeAnnotation() { - const node = this.node; - if (!node) { - if (this.key === "init" && this.parentPath.isVariableDeclarator()) { - const declar = this.parentPath.parentPath; - const declarParent = declar.parentPath; - if (declar.key === "left" && declarParent.isForInStatement()) { - return stringTypeAnnotation(); - } - if (declar.key === "left" && declarParent.isForOfStatement()) { - return anyTypeAnnotation(); - } - return voidTypeAnnotation(); - } else { - return; - } - } - if (node.typeAnnotation) { - return node.typeAnnotation; - } - if (typeAnnotationInferringNodes.has(node)) { - return; - } - typeAnnotationInferringNodes.add(node); - try { - var _inferer; - let inferer = inferers[node.type]; - if (inferer) { - return inferer.call(this, node); - } - inferer = inferers[this.parentPath.type]; - if ((_inferer = inferer) != null && _inferer.validParent) { - return this.parentPath.getTypeAnnotation(); - } - } finally { - typeAnnotationInferringNodes.delete(node); - } -} -function isBaseType(baseName, soft) { - return _isBaseType(baseName, this.getTypeAnnotation(), soft); -} -function _isBaseType(baseName, type, soft) { - if (baseName === "string") { - return isStringTypeAnnotation(type); - } else if (baseName === "number") { - return isNumberTypeAnnotation(type); - } else if (baseName === "boolean") { - return isBooleanTypeAnnotation(type); - } else if (baseName === "any") { - return isAnyTypeAnnotation(type); - } else if (baseName === "mixed") { - return isMixedTypeAnnotation(type); - } else if (baseName === "empty") { - return isEmptyTypeAnnotation(type); - } else if (baseName === "void") { - return isVoidTypeAnnotation(type); - } else { - if (soft) { - return false; - } else { - throw new Error(`Unknown base type ${baseName}`); - } - } -} -function couldBeBaseType(name) { - const type = this.getTypeAnnotation(); - if (isAnyTypeAnnotation(type)) return true; - if (isUnionTypeAnnotation(type)) { - for (const type2 of type.types) { - if (isAnyTypeAnnotation(type2) || _isBaseType(name, type2, true)) { - return true; - } - } - return false; - } else { - return _isBaseType(name, type, true); - } -} -function baseTypeStrictlyMatches(rightArg) { - const left = this.getTypeAnnotation(); - const right = rightArg.getTypeAnnotation(); - if (!isAnyTypeAnnotation(left) && isFlowBaseAnnotation(left)) { - return right.type === left.type; - } - return false; -} -function isGenericType(genericName) { - const type = this.getTypeAnnotation(); - if (genericName === "Array") { - if (isTSArrayType(type) || isArrayTypeAnnotation(type) || isTupleTypeAnnotation(type)) { - return true; - } - } - return isGenericTypeAnnotation(type) && isIdentifier(type.id, { - name: genericName - }) || isTSTypeReference(type) && isIdentifier(type.typeName, { - name: genericName - }); -} - -//# sourceMappingURL=index.js.map diff --git a/tools/eslint/node_modules/@babel/traverse/lib/path/inference/inferer-reference.js b/tools/eslint/node_modules/@babel/traverse/lib/path/inference/inferer-reference.js deleted file mode 100644 index b262faf0210453..00000000000000 --- a/tools/eslint/node_modules/@babel/traverse/lib/path/inference/inferer-reference.js +++ /dev/null @@ -1,151 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.default = _default; -var _t = require("@babel/types"); -var _util = require("./util.js"); -const { - BOOLEAN_NUMBER_BINARY_OPERATORS, - createTypeAnnotationBasedOnTypeof, - numberTypeAnnotation, - voidTypeAnnotation -} = _t; -function _default(node) { - if (!this.isReferenced()) return; - const binding = this.scope.getBinding(node.name); - if (binding) { - if (binding.identifier.typeAnnotation) { - return binding.identifier.typeAnnotation; - } else { - return getTypeAnnotationBindingConstantViolations(binding, this, node.name); - } - } - if (node.name === "undefined") { - return voidTypeAnnotation(); - } else if (node.name === "NaN" || node.name === "Infinity") { - return numberTypeAnnotation(); - } else if (node.name === "arguments") {} -} -function getTypeAnnotationBindingConstantViolations(binding, path, name) { - const types = []; - const functionConstantViolations = []; - let constantViolations = getConstantViolationsBefore(binding, path, functionConstantViolations); - const testType = getConditionalAnnotation(binding, path, name); - if (testType) { - const testConstantViolations = getConstantViolationsBefore(binding, testType.ifStatement); - constantViolations = constantViolations.filter(path => !testConstantViolations.includes(path)); - types.push(testType.typeAnnotation); - } - if (constantViolations.length) { - constantViolations.push(...functionConstantViolations); - for (const violation of constantViolations) { - types.push(violation.getTypeAnnotation()); - } - } - if (!types.length) { - return; - } - return (0, _util.createUnionType)(types); -} -function getConstantViolationsBefore(binding, path, functions) { - const violations = binding.constantViolations.slice(); - violations.unshift(binding.path); - return violations.filter(violation => { - violation = violation.resolve(); - const status = violation._guessExecutionStatusRelativeTo(path); - if (functions && status === "unknown") functions.push(violation); - return status === "before"; - }); -} -function inferAnnotationFromBinaryExpression(name, path) { - const operator = path.node.operator; - const right = path.get("right").resolve(); - const left = path.get("left").resolve(); - let target; - if (left.isIdentifier({ - name - })) { - target = right; - } else if (right.isIdentifier({ - name - })) { - target = left; - } - if (target) { - if (operator === "===") { - return target.getTypeAnnotation(); - } - if (BOOLEAN_NUMBER_BINARY_OPERATORS.includes(operator)) { - return numberTypeAnnotation(); - } - return; - } - if (operator !== "===" && operator !== "==") return; - let typeofPath; - let typePath; - if (left.isUnaryExpression({ - operator: "typeof" - })) { - typeofPath = left; - typePath = right; - } else if (right.isUnaryExpression({ - operator: "typeof" - })) { - typeofPath = right; - typePath = left; - } - if (!typeofPath) return; - if (!typeofPath.get("argument").isIdentifier({ - name - })) return; - typePath = typePath.resolve(); - if (!typePath.isLiteral()) return; - const typeValue = typePath.node.value; - if (typeof typeValue !== "string") return; - return createTypeAnnotationBasedOnTypeof(typeValue); -} -function getParentConditionalPath(binding, path, name) { - let parentPath; - while (parentPath = path.parentPath) { - if (parentPath.isIfStatement() || parentPath.isConditionalExpression()) { - if (path.key === "test") { - return; - } - return parentPath; - } - if (parentPath.isFunction()) { - if (parentPath.parentPath.scope.getBinding(name) !== binding) return; - } - path = parentPath; - } -} -function getConditionalAnnotation(binding, path, name) { - const ifStatement = getParentConditionalPath(binding, path, name); - if (!ifStatement) return; - const test = ifStatement.get("test"); - const paths = [test]; - const types = []; - for (let i = 0; i < paths.length; i++) { - const path = paths[i]; - if (path.isLogicalExpression()) { - if (path.node.operator === "&&") { - paths.push(path.get("left")); - paths.push(path.get("right")); - } - } else if (path.isBinaryExpression()) { - const type = inferAnnotationFromBinaryExpression(name, path); - if (type) types.push(type); - } - } - if (types.length) { - return { - typeAnnotation: (0, _util.createUnionType)(types), - ifStatement - }; - } - return getConditionalAnnotation(binding, ifStatement, name); -} - -//# sourceMappingURL=inferer-reference.js.map diff --git a/tools/eslint/node_modules/@babel/traverse/lib/path/inference/inferers.js b/tools/eslint/node_modules/@babel/traverse/lib/path/inference/inferers.js deleted file mode 100644 index a01249997eca1a..00000000000000 --- a/tools/eslint/node_modules/@babel/traverse/lib/path/inference/inferers.js +++ /dev/null @@ -1,207 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.ArrayExpression = ArrayExpression; -exports.AssignmentExpression = AssignmentExpression; -exports.BinaryExpression = BinaryExpression; -exports.BooleanLiteral = BooleanLiteral; -exports.CallExpression = CallExpression; -exports.ConditionalExpression = ConditionalExpression; -exports.ClassDeclaration = exports.ClassExpression = exports.FunctionDeclaration = exports.ArrowFunctionExpression = exports.FunctionExpression = Func; -Object.defineProperty(exports, "Identifier", { - enumerable: true, - get: function () { - return _infererReference.default; - } -}); -exports.LogicalExpression = LogicalExpression; -exports.NewExpression = NewExpression; -exports.NullLiteral = NullLiteral; -exports.NumericLiteral = NumericLiteral; -exports.ObjectExpression = ObjectExpression; -exports.ParenthesizedExpression = ParenthesizedExpression; -exports.RegExpLiteral = RegExpLiteral; -exports.RestElement = RestElement; -exports.SequenceExpression = SequenceExpression; -exports.StringLiteral = StringLiteral; -exports.TSAsExpression = TSAsExpression; -exports.TSNonNullExpression = TSNonNullExpression; -exports.TaggedTemplateExpression = TaggedTemplateExpression; -exports.TemplateLiteral = TemplateLiteral; -exports.TypeCastExpression = TypeCastExpression; -exports.UnaryExpression = UnaryExpression; -exports.UpdateExpression = UpdateExpression; -exports.VariableDeclarator = VariableDeclarator; -var _t = require("@babel/types"); -var _infererReference = require("./inferer-reference.js"); -var _util = require("./util.js"); -const { - BOOLEAN_BINARY_OPERATORS, - BOOLEAN_UNARY_OPERATORS, - NUMBER_BINARY_OPERATORS, - NUMBER_UNARY_OPERATORS, - STRING_UNARY_OPERATORS, - anyTypeAnnotation, - arrayTypeAnnotation, - booleanTypeAnnotation, - buildMatchMemberExpression, - genericTypeAnnotation, - identifier, - nullLiteralTypeAnnotation, - numberTypeAnnotation, - stringTypeAnnotation, - tupleTypeAnnotation, - unionTypeAnnotation, - voidTypeAnnotation, - isIdentifier -} = _t; -function VariableDeclarator() { - if (!this.get("id").isIdentifier()) return; - return this.get("init").getTypeAnnotation(); -} -function TypeCastExpression(node) { - return node.typeAnnotation; -} -TypeCastExpression.validParent = true; -function TSAsExpression(node) { - return node.typeAnnotation; -} -TSAsExpression.validParent = true; -function TSNonNullExpression() { - return this.get("expression").getTypeAnnotation(); -} -function NewExpression(node) { - if (node.callee.type === "Identifier") { - return genericTypeAnnotation(node.callee); - } -} -function TemplateLiteral() { - return stringTypeAnnotation(); -} -function UnaryExpression(node) { - const operator = node.operator; - if (operator === "void") { - return voidTypeAnnotation(); - } else if (NUMBER_UNARY_OPERATORS.includes(operator)) { - return numberTypeAnnotation(); - } else if (STRING_UNARY_OPERATORS.includes(operator)) { - return stringTypeAnnotation(); - } else if (BOOLEAN_UNARY_OPERATORS.includes(operator)) { - return booleanTypeAnnotation(); - } -} -function BinaryExpression(node) { - const operator = node.operator; - if (NUMBER_BINARY_OPERATORS.includes(operator)) { - return numberTypeAnnotation(); - } else if (BOOLEAN_BINARY_OPERATORS.includes(operator)) { - return booleanTypeAnnotation(); - } else if (operator === "+") { - const right = this.get("right"); - const left = this.get("left"); - if (left.isBaseType("number") && right.isBaseType("number")) { - return numberTypeAnnotation(); - } else if (left.isBaseType("string") || right.isBaseType("string")) { - return stringTypeAnnotation(); - } - return unionTypeAnnotation([stringTypeAnnotation(), numberTypeAnnotation()]); - } -} -function LogicalExpression() { - const argumentTypes = [this.get("left").getTypeAnnotation(), this.get("right").getTypeAnnotation()]; - return (0, _util.createUnionType)(argumentTypes); -} -function ConditionalExpression() { - const argumentTypes = [this.get("consequent").getTypeAnnotation(), this.get("alternate").getTypeAnnotation()]; - return (0, _util.createUnionType)(argumentTypes); -} -function SequenceExpression() { - return this.get("expressions").pop().getTypeAnnotation(); -} -function ParenthesizedExpression() { - return this.get("expression").getTypeAnnotation(); -} -function AssignmentExpression() { - return this.get("right").getTypeAnnotation(); -} -function UpdateExpression(node) { - const operator = node.operator; - if (operator === "++" || operator === "--") { - return numberTypeAnnotation(); - } -} -function StringLiteral() { - return stringTypeAnnotation(); -} -function NumericLiteral() { - return numberTypeAnnotation(); -} -function BooleanLiteral() { - return booleanTypeAnnotation(); -} -function NullLiteral() { - return nullLiteralTypeAnnotation(); -} -function RegExpLiteral() { - return genericTypeAnnotation(identifier("RegExp")); -} -function ObjectExpression() { - return genericTypeAnnotation(identifier("Object")); -} -function ArrayExpression() { - return genericTypeAnnotation(identifier("Array")); -} -function RestElement() { - return ArrayExpression(); -} -RestElement.validParent = true; -function Func() { - return genericTypeAnnotation(identifier("Function")); -} -const isArrayFrom = buildMatchMemberExpression("Array.from"); -const isObjectKeys = buildMatchMemberExpression("Object.keys"); -const isObjectValues = buildMatchMemberExpression("Object.values"); -const isObjectEntries = buildMatchMemberExpression("Object.entries"); -function CallExpression() { - const { - callee - } = this.node; - if (isObjectKeys(callee)) { - return arrayTypeAnnotation(stringTypeAnnotation()); - } else if (isArrayFrom(callee) || isObjectValues(callee) || isIdentifier(callee, { - name: "Array" - })) { - return arrayTypeAnnotation(anyTypeAnnotation()); - } else if (isObjectEntries(callee)) { - return arrayTypeAnnotation(tupleTypeAnnotation([stringTypeAnnotation(), anyTypeAnnotation()])); - } - return resolveCall(this.get("callee")); -} -function TaggedTemplateExpression() { - return resolveCall(this.get("tag")); -} -function resolveCall(callee) { - callee = callee.resolve(); - if (callee.isFunction()) { - const { - node - } = callee; - if (node.async) { - if (node.generator) { - return genericTypeAnnotation(identifier("AsyncIterator")); - } else { - return genericTypeAnnotation(identifier("Promise")); - } - } else { - if (node.generator) { - return genericTypeAnnotation(identifier("Iterator")); - } else if (callee.node.returnType) { - return callee.node.returnType; - } else {} - } - } -} - -//# sourceMappingURL=inferers.js.map diff --git a/tools/eslint/node_modules/@babel/traverse/lib/path/inference/util.js b/tools/eslint/node_modules/@babel/traverse/lib/path/inference/util.js deleted file mode 100644 index 6cc4312486cf78..00000000000000 --- a/tools/eslint/node_modules/@babel/traverse/lib/path/inference/util.js +++ /dev/null @@ -1,30 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.createUnionType = createUnionType; -var _t = require("@babel/types"); -const { - createFlowUnionType, - createTSUnionType, - createUnionTypeAnnotation, - isFlowType, - isTSType -} = _t; -function createUnionType(types) { - { - if (types.every(v => isFlowType(v))) { - if (createFlowUnionType) { - return createFlowUnionType(types); - } - return createUnionTypeAnnotation(types); - } else if (types.every(v => isTSType(v))) { - if (createTSUnionType) { - return createTSUnionType(types); - } - } - } -} - -//# sourceMappingURL=util.js.map diff --git a/tools/eslint/node_modules/@babel/traverse/lib/path/introspection.js b/tools/eslint/node_modules/@babel/traverse/lib/path/introspection.js deleted file mode 100644 index 07b17c350bd2f1..00000000000000 --- a/tools/eslint/node_modules/@babel/traverse/lib/path/introspection.js +++ /dev/null @@ -1,398 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports._guessExecutionStatusRelativeTo = _guessExecutionStatusRelativeTo; -exports._resolve = _resolve; -exports.canHaveVariableDeclarationOrExpression = canHaveVariableDeclarationOrExpression; -exports.canSwapBetweenExpressionAndStatement = canSwapBetweenExpressionAndStatement; -exports.equals = equals; -exports.getSource = getSource; -exports.has = has; -exports.is = void 0; -exports.isCompletionRecord = isCompletionRecord; -exports.isConstantExpression = isConstantExpression; -exports.isInStrictMode = isInStrictMode; -exports.isNodeType = isNodeType; -exports.isStatementOrBlock = isStatementOrBlock; -exports.isStatic = isStatic; -exports.isnt = isnt; -exports.matchesPattern = matchesPattern; -exports.referencesImport = referencesImport; -exports.resolve = resolve; -exports.willIMaybeExecuteBefore = willIMaybeExecuteBefore; -var _t = require("@babel/types"); -const { - STATEMENT_OR_BLOCK_KEYS, - VISITOR_KEYS, - isBlockStatement, - isExpression, - isIdentifier, - isLiteral, - isStringLiteral, - isType, - matchesPattern: _matchesPattern -} = _t; -function matchesPattern(pattern, allowPartial) { - return _matchesPattern(this.node, pattern, allowPartial); -} -function has(key) { - var _this$node; - const val = (_this$node = this.node) == null ? void 0 : _this$node[key]; - if (val && Array.isArray(val)) { - return !!val.length; - } else { - return !!val; - } -} -function isStatic() { - return this.scope.isStatic(this.node); -} -const is = exports.is = has; -function isnt(key) { - return !this.has(key); -} -function equals(key, value) { - return this.node[key] === value; -} -function isNodeType(type) { - return isType(this.type, type); -} -function canHaveVariableDeclarationOrExpression() { - return (this.key === "init" || this.key === "left") && this.parentPath.isFor(); -} -function canSwapBetweenExpressionAndStatement(replacement) { - if (this.key !== "body" || !this.parentPath.isArrowFunctionExpression()) { - return false; - } - if (this.isExpression()) { - return isBlockStatement(replacement); - } else if (this.isBlockStatement()) { - return isExpression(replacement); - } - return false; -} -function isCompletionRecord(allowInsideFunction) { - let path = this; - let first = true; - do { - const { - type, - container - } = path; - if (!first && (path.isFunction() || type === "StaticBlock")) { - return !!allowInsideFunction; - } - first = false; - if (Array.isArray(container) && path.key !== container.length - 1) { - return false; - } - } while ((path = path.parentPath) && !path.isProgram() && !path.isDoExpression()); - return true; -} -function isStatementOrBlock() { - if (this.parentPath.isLabeledStatement() || isBlockStatement(this.container)) { - return false; - } else { - return STATEMENT_OR_BLOCK_KEYS.includes(this.key); - } -} -function referencesImport(moduleSource, importName) { - if (!this.isReferencedIdentifier()) { - if (this.isJSXMemberExpression() && this.node.property.name === importName || (this.isMemberExpression() || this.isOptionalMemberExpression()) && (this.node.computed ? isStringLiteral(this.node.property, { - value: importName - }) : this.node.property.name === importName)) { - const object = this.get("object"); - return object.isReferencedIdentifier() && object.referencesImport(moduleSource, "*"); - } - return false; - } - const binding = this.scope.getBinding(this.node.name); - if (!binding || binding.kind !== "module") return false; - const path = binding.path; - const parent = path.parentPath; - if (!parent.isImportDeclaration()) return false; - if (parent.node.source.value === moduleSource) { - if (!importName) return true; - } else { - return false; - } - if (path.isImportDefaultSpecifier() && importName === "default") { - return true; - } - if (path.isImportNamespaceSpecifier() && importName === "*") { - return true; - } - if (path.isImportSpecifier() && isIdentifier(path.node.imported, { - name: importName - })) { - return true; - } - return false; -} -function getSource() { - const node = this.node; - if (node.end) { - const code = this.hub.getCode(); - if (code) return code.slice(node.start, node.end); - } - return ""; -} -function willIMaybeExecuteBefore(target) { - return this._guessExecutionStatusRelativeTo(target) !== "after"; -} -function getOuterFunction(path) { - return path.isProgram() ? path : (path.parentPath.scope.getFunctionParent() || path.parentPath.scope.getProgramParent()).path; -} -function isExecutionUncertain(type, key) { - switch (type) { - case "LogicalExpression": - return key === "right"; - case "ConditionalExpression": - case "IfStatement": - return key === "consequent" || key === "alternate"; - case "WhileStatement": - case "DoWhileStatement": - case "ForInStatement": - case "ForOfStatement": - return key === "body"; - case "ForStatement": - return key === "body" || key === "update"; - case "SwitchStatement": - return key === "cases"; - case "TryStatement": - return key === "handler"; - case "AssignmentPattern": - return key === "right"; - case "OptionalMemberExpression": - return key === "property"; - case "OptionalCallExpression": - return key === "arguments"; - default: - return false; - } -} -function isExecutionUncertainInList(paths, maxIndex) { - for (let i = 0; i < maxIndex; i++) { - const path = paths[i]; - if (isExecutionUncertain(path.parent.type, path.parentKey)) { - return true; - } - } - return false; -} -const SYMBOL_CHECKING = Symbol(); -function _guessExecutionStatusRelativeTo(target) { - return _guessExecutionStatusRelativeToCached(this, target, new Map()); -} -function _guessExecutionStatusRelativeToCached(base, target, cache) { - const funcParent = { - this: getOuterFunction(base), - target: getOuterFunction(target) - }; - if (funcParent.target.node !== funcParent.this.node) { - return _guessExecutionStatusRelativeToDifferentFunctionsCached(base, funcParent.target, cache); - } - const paths = { - target: target.getAncestry(), - this: base.getAncestry() - }; - if (paths.target.includes(base)) return "after"; - if (paths.this.includes(target)) return "before"; - let commonPath; - const commonIndex = { - target: 0, - this: 0 - }; - while (!commonPath && commonIndex.this < paths.this.length) { - const path = paths.this[commonIndex.this]; - commonIndex.target = paths.target.indexOf(path); - if (commonIndex.target >= 0) { - commonPath = path; - } else { - commonIndex.this++; - } - } - if (!commonPath) { - throw new Error("Internal Babel error - The two compared nodes" + " don't appear to belong to the same program."); - } - if (isExecutionUncertainInList(paths.this, commonIndex.this - 1) || isExecutionUncertainInList(paths.target, commonIndex.target - 1)) { - return "unknown"; - } - const divergence = { - this: paths.this[commonIndex.this - 1], - target: paths.target[commonIndex.target - 1] - }; - if (divergence.target.listKey && divergence.this.listKey && divergence.target.container === divergence.this.container) { - return divergence.target.key > divergence.this.key ? "before" : "after"; - } - const keys = VISITOR_KEYS[commonPath.type]; - const keyPosition = { - this: keys.indexOf(divergence.this.parentKey), - target: keys.indexOf(divergence.target.parentKey) - }; - return keyPosition.target > keyPosition.this ? "before" : "after"; -} -function _guessExecutionStatusRelativeToDifferentFunctionsInternal(base, target, cache) { - if (!target.isFunctionDeclaration()) { - if (_guessExecutionStatusRelativeToCached(base, target, cache) === "before") { - return "before"; - } - return "unknown"; - } else if (target.parentPath.isExportDeclaration()) { - return "unknown"; - } - const binding = target.scope.getBinding(target.node.id.name); - if (!binding.references) return "before"; - const referencePaths = binding.referencePaths; - let allStatus; - for (const path of referencePaths) { - const childOfFunction = !!path.find(path => path.node === target.node); - if (childOfFunction) continue; - if (path.key !== "callee" || !path.parentPath.isCallExpression()) { - return "unknown"; - } - const status = _guessExecutionStatusRelativeToCached(base, path, cache); - if (allStatus && allStatus !== status) { - return "unknown"; - } else { - allStatus = status; - } - } - return allStatus; -} -function _guessExecutionStatusRelativeToDifferentFunctionsCached(base, target, cache) { - let nodeMap = cache.get(base.node); - let cached; - if (!nodeMap) { - cache.set(base.node, nodeMap = new Map()); - } else if (cached = nodeMap.get(target.node)) { - if (cached === SYMBOL_CHECKING) { - return "unknown"; - } - return cached; - } - nodeMap.set(target.node, SYMBOL_CHECKING); - const result = _guessExecutionStatusRelativeToDifferentFunctionsInternal(base, target, cache); - nodeMap.set(target.node, result); - return result; -} -function resolve(dangerous, resolved) { - return _resolve.call(this, dangerous, resolved) || this; -} -function _resolve(dangerous, resolved) { - var _resolved; - if ((_resolved = resolved) != null && _resolved.includes(this)) return; - resolved = resolved || []; - resolved.push(this); - if (this.isVariableDeclarator()) { - if (this.get("id").isIdentifier()) { - return this.get("init").resolve(dangerous, resolved); - } else {} - } else if (this.isReferencedIdentifier()) { - const binding = this.scope.getBinding(this.node.name); - if (!binding) return; - if (!binding.constant) return; - if (binding.kind === "module") return; - if (binding.path !== this) { - const ret = binding.path.resolve(dangerous, resolved); - if (this.find(parent => parent.node === ret.node)) return; - return ret; - } - } else if (this.isTypeCastExpression()) { - return this.get("expression").resolve(dangerous, resolved); - } else if (dangerous && this.isMemberExpression()) { - const targetKey = this.toComputedKey(); - if (!isLiteral(targetKey)) return; - const targetName = targetKey.value; - const target = this.get("object").resolve(dangerous, resolved); - if (target.isObjectExpression()) { - const props = target.get("properties"); - for (const prop of props) { - if (!prop.isProperty()) continue; - const key = prop.get("key"); - let match = prop.isnt("computed") && key.isIdentifier({ - name: targetName - }); - match = match || key.isLiteral({ - value: targetName - }); - if (match) return prop.get("value").resolve(dangerous, resolved); - } - } else if (target.isArrayExpression() && !isNaN(+targetName)) { - const elems = target.get("elements"); - const elem = elems[targetName]; - if (elem) return elem.resolve(dangerous, resolved); - } - } -} -function isConstantExpression() { - if (this.isIdentifier()) { - const binding = this.scope.getBinding(this.node.name); - if (!binding) return false; - return binding.constant; - } - if (this.isLiteral()) { - if (this.isRegExpLiteral()) { - return false; - } - if (this.isTemplateLiteral()) { - return this.get("expressions").every(expression => expression.isConstantExpression()); - } - return true; - } - if (this.isUnaryExpression()) { - if (this.node.operator !== "void") { - return false; - } - return this.get("argument").isConstantExpression(); - } - if (this.isBinaryExpression()) { - const { - operator - } = this.node; - return operator !== "in" && operator !== "instanceof" && this.get("left").isConstantExpression() && this.get("right").isConstantExpression(); - } - if (this.isMemberExpression()) { - return !this.node.computed && this.get("object").isIdentifier({ - name: "Symbol" - }) && !this.scope.hasBinding("Symbol", { - noGlobals: true - }); - } - if (this.isCallExpression()) { - return this.node.arguments.length === 1 && this.get("callee").matchesPattern("Symbol.for") && !this.scope.hasBinding("Symbol", { - noGlobals: true - }) && this.get("arguments")[0].isStringLiteral(); - } - return false; -} -function isInStrictMode() { - const start = this.isProgram() ? this : this.parentPath; - const strictParent = start.find(path => { - if (path.isProgram({ - sourceType: "module" - })) return true; - if (path.isClass()) return true; - if (path.isArrowFunctionExpression() && !path.get("body").isBlockStatement()) { - return false; - } - let body; - if (path.isFunction()) { - body = path.node.body; - } else if (path.isProgram()) { - body = path.node; - } else { - return false; - } - for (const directive of body.directives) { - if (directive.value.value === "use strict") { - return true; - } - } - }); - return !!strictParent; -} - -//# sourceMappingURL=introspection.js.map diff --git a/tools/eslint/node_modules/@babel/traverse/lib/path/lib/hoister.js b/tools/eslint/node_modules/@babel/traverse/lib/path/lib/hoister.js deleted file mode 100644 index 4c4246fdbbea01..00000000000000 --- a/tools/eslint/node_modules/@babel/traverse/lib/path/lib/hoister.js +++ /dev/null @@ -1,171 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.default = void 0; -var _t = require("@babel/types"); -var _t2 = _t; -const { - react -} = _t; -const { - cloneNode, - jsxExpressionContainer, - variableDeclaration, - variableDeclarator -} = _t2; -const referenceVisitor = { - ReferencedIdentifier(path, state) { - if (path.isJSXIdentifier() && react.isCompatTag(path.node.name) && !path.parentPath.isJSXMemberExpression()) { - return; - } - if (path.node.name === "this") { - let scope = path.scope; - do { - if (scope.path.isFunction() && !scope.path.isArrowFunctionExpression()) { - break; - } - } while (scope = scope.parent); - if (scope) state.breakOnScopePaths.push(scope.path); - } - const binding = path.scope.getBinding(path.node.name); - if (!binding) return; - for (const violation of binding.constantViolations) { - if (violation.scope !== binding.path.scope) { - state.mutableBinding = true; - path.stop(); - return; - } - } - if (binding !== state.scope.getBinding(path.node.name)) return; - state.bindings[path.node.name] = binding; - } -}; -class PathHoister { - constructor(path, scope) { - this.breakOnScopePaths = void 0; - this.bindings = void 0; - this.mutableBinding = void 0; - this.scopes = void 0; - this.scope = void 0; - this.path = void 0; - this.attachAfter = void 0; - this.breakOnScopePaths = []; - this.bindings = {}; - this.mutableBinding = false; - this.scopes = []; - this.scope = scope; - this.path = path; - this.attachAfter = false; - } - isCompatibleScope(scope) { - for (const key of Object.keys(this.bindings)) { - const binding = this.bindings[key]; - if (!scope.bindingIdentifierEquals(key, binding.identifier)) { - return false; - } - } - return true; - } - getCompatibleScopes() { - let scope = this.path.scope; - do { - if (this.isCompatibleScope(scope)) { - this.scopes.push(scope); - } else { - break; - } - if (this.breakOnScopePaths.includes(scope.path)) { - break; - } - } while (scope = scope.parent); - } - getAttachmentPath() { - let path = this._getAttachmentPath(); - if (!path) return; - let targetScope = path.scope; - if (targetScope.path === path) { - targetScope = path.scope.parent; - } - if (targetScope.path.isProgram() || targetScope.path.isFunction()) { - for (const name of Object.keys(this.bindings)) { - if (!targetScope.hasOwnBinding(name)) continue; - const binding = this.bindings[name]; - if (binding.kind === "param" || binding.path.parentKey === "params") { - continue; - } - const bindingParentPath = this.getAttachmentParentForPath(binding.path); - if (bindingParentPath.key >= path.key) { - this.attachAfter = true; - path = binding.path; - for (const violationPath of binding.constantViolations) { - if (this.getAttachmentParentForPath(violationPath).key > path.key) { - path = violationPath; - } - } - } - } - } - return path; - } - _getAttachmentPath() { - const scopes = this.scopes; - const scope = scopes.pop(); - if (!scope) return; - if (scope.path.isFunction()) { - if (this.hasOwnParamBindings(scope)) { - if (this.scope === scope) return; - const bodies = scope.path.get("body").get("body"); - for (let i = 0; i < bodies.length; i++) { - if (bodies[i].node._blockHoist) continue; - return bodies[i]; - } - } else { - return this.getNextScopeAttachmentParent(); - } - } else if (scope.path.isProgram()) { - return this.getNextScopeAttachmentParent(); - } - } - getNextScopeAttachmentParent() { - const scope = this.scopes.pop(); - if (scope) return this.getAttachmentParentForPath(scope.path); - } - getAttachmentParentForPath(path) { - do { - if (!path.parentPath || Array.isArray(path.container) && path.isStatement()) { - return path; - } - } while (path = path.parentPath); - } - hasOwnParamBindings(scope) { - for (const name of Object.keys(this.bindings)) { - if (!scope.hasOwnBinding(name)) continue; - const binding = this.bindings[name]; - if (binding.kind === "param" && binding.constant) return true; - } - return false; - } - run() { - this.path.traverse(referenceVisitor, this); - if (this.mutableBinding) return; - this.getCompatibleScopes(); - const attachTo = this.getAttachmentPath(); - if (!attachTo) return; - if (attachTo.getFunctionParent() === this.path.getFunctionParent()) return; - let uid = attachTo.scope.generateUidIdentifier("ref"); - const declarator = variableDeclarator(uid, this.path.node); - const insertFn = this.attachAfter ? "insertAfter" : "insertBefore"; - const [attached] = attachTo[insertFn]([attachTo.isVariableDeclarator() ? declarator : variableDeclaration("var", [declarator])]); - const parent = this.path.parentPath; - if (parent.isJSXElement() && this.path.container === parent.node.children) { - uid = jsxExpressionContainer(uid); - } - this.path.replaceWith(cloneNode(uid)); - return attachTo.isVariableDeclarator() ? attached.get("init") : attached.get("declarations.0.init"); - } -} -exports.default = PathHoister; - -//# sourceMappingURL=hoister.js.map diff --git a/tools/eslint/node_modules/@babel/traverse/lib/path/lib/removal-hooks.js b/tools/eslint/node_modules/@babel/traverse/lib/path/lib/removal-hooks.js deleted file mode 100644 index 2d42536796dd21..00000000000000 --- a/tools/eslint/node_modules/@babel/traverse/lib/path/lib/removal-hooks.js +++ /dev/null @@ -1,37 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.hooks = void 0; -const hooks = exports.hooks = [function (self, parent) { - const removeParent = self.key === "test" && (parent.isWhile() || parent.isSwitchCase()) || self.key === "declaration" && parent.isExportDeclaration() || self.key === "body" && parent.isLabeledStatement() || self.listKey === "declarations" && parent.isVariableDeclaration() && parent.node.declarations.length === 1 || self.key === "expression" && parent.isExpressionStatement(); - if (removeParent) { - parent.remove(); - return true; - } -}, function (self, parent) { - if (parent.isSequenceExpression() && parent.node.expressions.length === 1) { - parent.replaceWith(parent.node.expressions[0]); - return true; - } -}, function (self, parent) { - if (parent.isBinary()) { - if (self.key === "left") { - parent.replaceWith(parent.node.right); - } else { - parent.replaceWith(parent.node.left); - } - return true; - } -}, function (self, parent) { - if (parent.isIfStatement() && self.key === "consequent" || self.key === "body" && (parent.isLoop() || parent.isArrowFunctionExpression())) { - self.replaceWith({ - type: "BlockStatement", - body: [] - }); - return true; - } -}]; - -//# sourceMappingURL=removal-hooks.js.map diff --git a/tools/eslint/node_modules/@babel/traverse/lib/path/lib/virtual-types-validator.js b/tools/eslint/node_modules/@babel/traverse/lib/path/lib/virtual-types-validator.js deleted file mode 100644 index f8a17add155ea7..00000000000000 --- a/tools/eslint/node_modules/@babel/traverse/lib/path/lib/virtual-types-validator.js +++ /dev/null @@ -1,163 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.isBindingIdentifier = isBindingIdentifier; -exports.isBlockScoped = isBlockScoped; -exports.isExpression = isExpression; -exports.isFlow = isFlow; -exports.isForAwaitStatement = isForAwaitStatement; -exports.isGenerated = isGenerated; -exports.isPure = isPure; -exports.isReferenced = isReferenced; -exports.isReferencedIdentifier = isReferencedIdentifier; -exports.isReferencedMemberExpression = isReferencedMemberExpression; -exports.isRestProperty = isRestProperty; -exports.isScope = isScope; -exports.isSpreadProperty = isSpreadProperty; -exports.isStatement = isStatement; -exports.isUser = isUser; -exports.isVar = isVar; -var _t = require("@babel/types"); -const { - isBinding, - isBlockScoped: nodeIsBlockScoped, - isExportDeclaration, - isExpression: nodeIsExpression, - isFlow: nodeIsFlow, - isForStatement, - isForXStatement, - isIdentifier, - isImportDeclaration, - isImportSpecifier, - isJSXIdentifier, - isJSXMemberExpression, - isMemberExpression, - isRestElement: nodeIsRestElement, - isReferenced: nodeIsReferenced, - isScope: nodeIsScope, - isStatement: nodeIsStatement, - isVar: nodeIsVar, - isVariableDeclaration, - react, - isForOfStatement -} = _t; -const { - isCompatTag -} = react; -function isReferencedIdentifier(opts) { - const { - node, - parent - } = this; - if (!isIdentifier(node, opts) && !isJSXMemberExpression(parent, opts)) { - if (isJSXIdentifier(node, opts)) { - if (isCompatTag(node.name)) return false; - } else { - return false; - } - } - return nodeIsReferenced(node, parent, this.parentPath.parent); -} -function isReferencedMemberExpression() { - const { - node, - parent - } = this; - return isMemberExpression(node) && nodeIsReferenced(node, parent); -} -function isBindingIdentifier() { - const { - node, - parent - } = this; - const grandparent = this.parentPath.parent; - return isIdentifier(node) && isBinding(node, parent, grandparent); -} -function isStatement() { - const { - node, - parent - } = this; - if (nodeIsStatement(node)) { - if (isVariableDeclaration(node)) { - if (isForXStatement(parent, { - left: node - })) return false; - if (isForStatement(parent, { - init: node - })) return false; - } - return true; - } else { - return false; - } -} -function isExpression() { - if (this.isIdentifier()) { - return this.isReferencedIdentifier(); - } else { - return nodeIsExpression(this.node); - } -} -function isScope() { - return nodeIsScope(this.node, this.parent); -} -function isReferenced() { - return nodeIsReferenced(this.node, this.parent); -} -function isBlockScoped() { - return nodeIsBlockScoped(this.node); -} -function isVar() { - return nodeIsVar(this.node); -} -function isUser() { - return this.node && !!this.node.loc; -} -function isGenerated() { - return !this.isUser(); -} -function isPure(constantsOnly) { - return this.scope.isPure(this.node, constantsOnly); -} -function isFlow() { - const { - node - } = this; - if (nodeIsFlow(node)) { - return true; - } else if (isImportDeclaration(node)) { - return node.importKind === "type" || node.importKind === "typeof"; - } else if (isExportDeclaration(node)) { - return node.exportKind === "type"; - } else if (isImportSpecifier(node)) { - return node.importKind === "type" || node.importKind === "typeof"; - } else { - return false; - } -} -function isRestProperty() { - var _this$parentPath; - return nodeIsRestElement(this.node) && ((_this$parentPath = this.parentPath) == null ? void 0 : _this$parentPath.isObjectPattern()); -} -function isSpreadProperty() { - var _this$parentPath2; - return nodeIsRestElement(this.node) && ((_this$parentPath2 = this.parentPath) == null ? void 0 : _this$parentPath2.isObjectExpression()); -} -function isForAwaitStatement() { - return isForOfStatement(this.node, { - await: true - }); -} -{ - exports.isExistentialTypeParam = function isExistentialTypeParam() { - throw new Error("`path.isExistentialTypeParam` has been renamed to `path.isExistsTypeAnnotation()` in Babel 7."); - }; - exports.isNumericLiteralTypeAnnotation = function isNumericLiteralTypeAnnotation() { - throw new Error("`path.isNumericLiteralTypeAnnotation()` has been renamed to `path.isNumberLiteralTypeAnnotation()` in Babel 7."); - }; -} - -//# sourceMappingURL=virtual-types-validator.js.map diff --git a/tools/eslint/node_modules/@babel/traverse/lib/path/lib/virtual-types.js b/tools/eslint/node_modules/@babel/traverse/lib/path/lib/virtual-types.js deleted file mode 100644 index 0322f091f973df..00000000000000 --- a/tools/eslint/node_modules/@babel/traverse/lib/path/lib/virtual-types.js +++ /dev/null @@ -1,26 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.Var = exports.User = exports.Statement = exports.SpreadProperty = exports.Scope = exports.RestProperty = exports.ReferencedMemberExpression = exports.ReferencedIdentifier = exports.Referenced = exports.Pure = exports.NumericLiteralTypeAnnotation = exports.Generated = exports.ForAwaitStatement = exports.Flow = exports.Expression = exports.ExistentialTypeParam = exports.BlockScoped = exports.BindingIdentifier = void 0; -const ReferencedIdentifier = exports.ReferencedIdentifier = ["Identifier", "JSXIdentifier"]; -const ReferencedMemberExpression = exports.ReferencedMemberExpression = ["MemberExpression"]; -const BindingIdentifier = exports.BindingIdentifier = ["Identifier"]; -const Statement = exports.Statement = ["Statement"]; -const Expression = exports.Expression = ["Expression"]; -const Scope = exports.Scope = ["Scopable", "Pattern"]; -const Referenced = exports.Referenced = null; -const BlockScoped = exports.BlockScoped = null; -const Var = exports.Var = ["VariableDeclaration"]; -const User = exports.User = null; -const Generated = exports.Generated = null; -const Pure = exports.Pure = null; -const Flow = exports.Flow = ["Flow", "ImportDeclaration", "ExportDeclaration", "ImportSpecifier"]; -const RestProperty = exports.RestProperty = ["RestElement"]; -const SpreadProperty = exports.SpreadProperty = ["RestElement"]; -const ExistentialTypeParam = exports.ExistentialTypeParam = ["ExistsTypeAnnotation"]; -const NumericLiteralTypeAnnotation = exports.NumericLiteralTypeAnnotation = ["NumberLiteralTypeAnnotation"]; -const ForAwaitStatement = exports.ForAwaitStatement = ["ForOfStatement"]; - -//# sourceMappingURL=virtual-types.js.map diff --git a/tools/eslint/node_modules/@babel/traverse/lib/path/modification.js b/tools/eslint/node_modules/@babel/traverse/lib/path/modification.js deleted file mode 100644 index 45ad4784bfcda7..00000000000000 --- a/tools/eslint/node_modules/@babel/traverse/lib/path/modification.js +++ /dev/null @@ -1,228 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports._containerInsert = _containerInsert; -exports._containerInsertAfter = _containerInsertAfter; -exports._containerInsertBefore = _containerInsertBefore; -exports._verifyNodeList = _verifyNodeList; -exports.hoist = hoist; -exports.insertAfter = insertAfter; -exports.insertBefore = insertBefore; -exports.pushContainer = pushContainer; -exports.unshiftContainer = unshiftContainer; -exports.updateSiblingKeys = updateSiblingKeys; -var _cache = require("../cache.js"); -var _hoister = require("./lib/hoister.js"); -var _index = require("./index.js"); -var _context = require("./context.js"); -var _removal = require("./removal.js"); -var _t = require("@babel/types"); -const { - arrowFunctionExpression, - assertExpression, - assignmentExpression, - blockStatement, - callExpression, - cloneNode, - expressionStatement, - isAssignmentExpression, - isCallExpression, - isExportNamedDeclaration, - isExpression, - isIdentifier, - isSequenceExpression, - isSuper, - thisExpression -} = _t; -function insertBefore(nodes_) { - _removal._assertUnremoved.call(this); - const nodes = _verifyNodeList.call(this, nodes_); - const { - parentPath, - parent - } = this; - if (parentPath.isExpressionStatement() || parentPath.isLabeledStatement() || isExportNamedDeclaration(parent) || parentPath.isExportDefaultDeclaration() && this.isDeclaration()) { - return parentPath.insertBefore(nodes); - } else if (this.isNodeType("Expression") && !this.isJSXElement() || parentPath.isForStatement() && this.key === "init") { - if (this.node) nodes.push(this.node); - return this.replaceExpressionWithStatements(nodes); - } else if (Array.isArray(this.container)) { - return _containerInsertBefore.call(this, nodes); - } else if (this.isStatementOrBlock()) { - const node = this.node; - const shouldInsertCurrentNode = node && (!this.isExpressionStatement() || node.expression != null); - this.replaceWith(blockStatement(shouldInsertCurrentNode ? [node] : [])); - return this.unshiftContainer("body", nodes); - } else { - throw new Error("We don't know what to do with this node type. " + "We were previously a Statement but we can't fit in here?"); - } -} -function _containerInsert(from, nodes) { - this.updateSiblingKeys(from, nodes.length); - const paths = []; - this.container.splice(from, 0, ...nodes); - for (let i = 0; i < nodes.length; i++) { - var _this$context; - const to = from + i; - const path = this.getSibling(to); - paths.push(path); - if ((_this$context = this.context) != null && _this$context.queue) { - path.pushContext(this.context); - } - } - const contexts = _context._getQueueContexts.call(this); - for (const path of paths) { - path.setScope(); - path.debug("Inserted."); - for (const context of contexts) { - context.maybeQueue(path, true); - } - } - return paths; -} -function _containerInsertBefore(nodes) { - return _containerInsert.call(this, this.key, nodes); -} -function _containerInsertAfter(nodes) { - return _containerInsert.call(this, this.key + 1, nodes); -} -const last = arr => arr[arr.length - 1]; -function isHiddenInSequenceExpression(path) { - return isSequenceExpression(path.parent) && (last(path.parent.expressions) !== path.node || isHiddenInSequenceExpression(path.parentPath)); -} -function isAlmostConstantAssignment(node, scope) { - if (!isAssignmentExpression(node) || !isIdentifier(node.left)) { - return false; - } - const blockScope = scope.getBlockParent(); - return blockScope.hasOwnBinding(node.left.name) && blockScope.getOwnBinding(node.left.name).constantViolations.length <= 1; -} -function insertAfter(nodes_) { - _removal._assertUnremoved.call(this); - if (this.isSequenceExpression()) { - return last(this.get("expressions")).insertAfter(nodes_); - } - const nodes = _verifyNodeList.call(this, nodes_); - const { - parentPath, - parent - } = this; - if (parentPath.isExpressionStatement() || parentPath.isLabeledStatement() || isExportNamedDeclaration(parent) || parentPath.isExportDefaultDeclaration() && this.isDeclaration()) { - return parentPath.insertAfter(nodes.map(node => { - return isExpression(node) ? expressionStatement(node) : node; - })); - } else if (this.isNodeType("Expression") && !this.isJSXElement() && !parentPath.isJSXElement() || parentPath.isForStatement() && this.key === "init") { - const self = this; - if (self.node) { - const node = self.node; - let { - scope - } = this; - if (scope.path.isPattern()) { - assertExpression(node); - self.replaceWith(callExpression(arrowFunctionExpression([], node), [])); - self.get("callee.body").insertAfter(nodes); - return [self]; - } - if (isHiddenInSequenceExpression(self)) { - nodes.unshift(node); - } else if (isCallExpression(node) && isSuper(node.callee)) { - nodes.unshift(node); - nodes.push(thisExpression()); - } else if (isAlmostConstantAssignment(node, scope)) { - nodes.unshift(node); - nodes.push(cloneNode(node.left)); - } else if (scope.isPure(node, true)) { - nodes.push(node); - } else { - if (parentPath.isMethod({ - computed: true, - key: node - })) { - scope = scope.parent; - } - const temp = scope.generateDeclaredUidIdentifier(); - nodes.unshift(expressionStatement(assignmentExpression("=", cloneNode(temp), node))); - nodes.push(expressionStatement(cloneNode(temp))); - } - } - return this.replaceExpressionWithStatements(nodes); - } else if (Array.isArray(this.container)) { - return _containerInsertAfter.call(this, nodes); - } else if (this.isStatementOrBlock()) { - const node = this.node; - const shouldInsertCurrentNode = node && (!this.isExpressionStatement() || node.expression != null); - this.replaceWith(blockStatement(shouldInsertCurrentNode ? [node] : [])); - return this.pushContainer("body", nodes); - } else { - throw new Error("We don't know what to do with this node type. " + "We were previously a Statement but we can't fit in here?"); - } -} -function updateSiblingKeys(fromIndex, incrementBy) { - if (!this.parent) return; - const paths = (0, _cache.getCachedPaths)(this.hub, this.parent) || []; - for (const [, path] of paths) { - if (typeof path.key === "number" && path.key >= fromIndex) { - path.key += incrementBy; - } - } -} -function _verifyNodeList(nodes) { - if (!nodes) { - return []; - } - if (!Array.isArray(nodes)) { - nodes = [nodes]; - } - for (let i = 0; i < nodes.length; i++) { - const node = nodes[i]; - let msg; - if (!node) { - msg = "has falsy node"; - } else if (typeof node !== "object") { - msg = "contains a non-object node"; - } else if (!node.type) { - msg = "without a type"; - } else if (node instanceof _index.default) { - msg = "has a NodePath when it expected a raw object"; - } - if (msg) { - const type = Array.isArray(node) ? "array" : typeof node; - throw new Error(`Node list ${msg} with the index of ${i} and type of ${type}`); - } - } - return nodes; -} -function unshiftContainer(listKey, nodes) { - _removal._assertUnremoved.call(this); - nodes = _verifyNodeList.call(this, nodes); - const path = _index.default.get({ - parentPath: this, - parent: this.node, - container: this.node[listKey], - listKey, - key: 0 - }).setContext(this.context); - return _containerInsertBefore.call(path, nodes); -} -function pushContainer(listKey, nodes) { - _removal._assertUnremoved.call(this); - const verifiedNodes = _verifyNodeList.call(this, nodes); - const container = this.node[listKey]; - const path = _index.default.get({ - parentPath: this, - parent: this.node, - container: container, - listKey, - key: container.length - }).setContext(this.context); - return path.replaceWithMultiple(verifiedNodes); -} -function hoist(scope = this.scope) { - const hoister = new _hoister.default(this, scope); - return hoister.run(); -} - -//# sourceMappingURL=modification.js.map diff --git a/tools/eslint/node_modules/@babel/traverse/lib/path/removal.js b/tools/eslint/node_modules/@babel/traverse/lib/path/removal.js deleted file mode 100644 index 74fe13df6d6e03..00000000000000 --- a/tools/eslint/node_modules/@babel/traverse/lib/path/removal.js +++ /dev/null @@ -1,67 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports._assertUnremoved = _assertUnremoved; -exports._callRemovalHooks = _callRemovalHooks; -exports._markRemoved = _markRemoved; -exports._remove = _remove; -exports._removeFromScope = _removeFromScope; -exports.remove = remove; -var _removalHooks = require("./lib/removal-hooks.js"); -var _cache = require("../cache.js"); -var _replacement = require("./replacement.js"); -var _index = require("./index.js"); -var _t = require("@babel/types"); -const { - getBindingIdentifiers -} = _t; -function remove() { - var _this$opts; - _assertUnremoved.call(this); - this.resync(); - if (!((_this$opts = this.opts) != null && _this$opts.noScope)) { - _removeFromScope.call(this); - } - if (_callRemovalHooks.call(this)) { - _markRemoved.call(this); - return; - } - this.shareCommentsWithSiblings(); - _remove.call(this); - _markRemoved.call(this); -} -function _removeFromScope() { - const bindings = getBindingIdentifiers(this.node, false, false, true); - Object.keys(bindings).forEach(name => this.scope.removeBinding(name)); -} -function _callRemovalHooks() { - if (this.parentPath) { - for (const fn of _removalHooks.hooks) { - if (fn(this, this.parentPath)) return true; - } - } -} -function _remove() { - if (Array.isArray(this.container)) { - this.container.splice(this.key, 1); - this.updateSiblingKeys(this.key, -1); - } else { - _replacement._replaceWith.call(this, null); - } -} -function _markRemoved() { - this._traverseFlags |= _index.SHOULD_SKIP | _index.REMOVED; - if (this.parent) { - (0, _cache.getCachedPaths)(this.hub, this.parent).delete(this.node); - } - this.node = null; -} -function _assertUnremoved() { - if (this.removed) { - throw this.buildCodeFrameError("NodePath has been removed so is read-only."); - } -} - -//# sourceMappingURL=removal.js.map diff --git a/tools/eslint/node_modules/@babel/traverse/lib/path/replacement.js b/tools/eslint/node_modules/@babel/traverse/lib/path/replacement.js deleted file mode 100644 index afcd8b7c4ea75d..00000000000000 --- a/tools/eslint/node_modules/@babel/traverse/lib/path/replacement.js +++ /dev/null @@ -1,265 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports._replaceWith = _replaceWith; -exports.replaceExpressionWithStatements = replaceExpressionWithStatements; -exports.replaceInline = replaceInline; -exports.replaceWith = replaceWith; -exports.replaceWithMultiple = replaceWithMultiple; -exports.replaceWithSourceString = replaceWithSourceString; -var _codeFrame = require("@babel/code-frame"); -var _index = require("../index.js"); -var _index2 = require("./index.js"); -var _cache = require("../cache.js"); -var _modification = require("./modification.js"); -var _parser = require("@babel/parser"); -var _t = require("@babel/types"); -var _helperHoistVariables = require("@babel/helper-hoist-variables"); -const { - FUNCTION_TYPES, - arrowFunctionExpression, - assignmentExpression, - awaitExpression, - blockStatement, - buildUndefinedNode, - callExpression, - cloneNode, - conditionalExpression, - expressionStatement, - getBindingIdentifiers, - identifier, - inheritLeadingComments, - inheritTrailingComments, - inheritsComments, - isBlockStatement, - isEmptyStatement, - isExpression, - isExpressionStatement, - isIfStatement, - isProgram, - isStatement, - isVariableDeclaration, - removeComments, - returnStatement, - sequenceExpression, - validate, - yieldExpression -} = _t; -function replaceWithMultiple(nodes) { - var _getCachedPaths; - this.resync(); - nodes = _modification._verifyNodeList.call(this, nodes); - inheritLeadingComments(nodes[0], this.node); - inheritTrailingComments(nodes[nodes.length - 1], this.node); - (_getCachedPaths = (0, _cache.getCachedPaths)(this.hub, this.parent)) == null || _getCachedPaths.delete(this.node); - this.node = this.container[this.key] = null; - const paths = this.insertAfter(nodes); - if (this.node) { - this.requeue(); - } else { - this.remove(); - } - return paths; -} -function replaceWithSourceString(replacement) { - this.resync(); - let ast; - try { - replacement = `(${replacement})`; - ast = (0, _parser.parse)(replacement); - } catch (err) { - const loc = err.loc; - if (loc) { - err.message += " - make sure this is an expression.\n" + (0, _codeFrame.codeFrameColumns)(replacement, { - start: { - line: loc.line, - column: loc.column + 1 - } - }); - err.code = "BABEL_REPLACE_SOURCE_ERROR"; - } - throw err; - } - const expressionAST = ast.program.body[0].expression; - _index.default.removeProperties(expressionAST); - return this.replaceWith(expressionAST); -} -function replaceWith(replacementPath) { - this.resync(); - if (this.removed) { - throw new Error("You can't replace this node, we've already removed it"); - } - let replacement = replacementPath instanceof _index2.default ? replacementPath.node : replacementPath; - if (!replacement) { - throw new Error("You passed `path.replaceWith()` a falsy node, use `path.remove()` instead"); - } - if (this.node === replacement) { - return [this]; - } - if (this.isProgram() && !isProgram(replacement)) { - throw new Error("You can only replace a Program root node with another Program node"); - } - if (Array.isArray(replacement)) { - throw new Error("Don't use `path.replaceWith()` with an array of nodes, use `path.replaceWithMultiple()`"); - } - if (typeof replacement === "string") { - throw new Error("Don't use `path.replaceWith()` with a source string, use `path.replaceWithSourceString()`"); - } - let nodePath = ""; - if (this.isNodeType("Statement") && isExpression(replacement)) { - if (!this.canHaveVariableDeclarationOrExpression() && !this.canSwapBetweenExpressionAndStatement(replacement) && !this.parentPath.isExportDefaultDeclaration()) { - replacement = expressionStatement(replacement); - nodePath = "expression"; - } - } - if (this.isNodeType("Expression") && isStatement(replacement)) { - if (!this.canHaveVariableDeclarationOrExpression() && !this.canSwapBetweenExpressionAndStatement(replacement)) { - return this.replaceExpressionWithStatements([replacement]); - } - } - const oldNode = this.node; - if (oldNode) { - inheritsComments(replacement, oldNode); - removeComments(oldNode); - } - _replaceWith.call(this, replacement); - this.type = replacement.type; - this.setScope(); - this.requeue(); - return [nodePath ? this.get(nodePath) : this]; -} -function _replaceWith(node) { - var _getCachedPaths2; - if (!this.container) { - throw new ReferenceError("Container is falsy"); - } - if (this.inList) { - validate(this.parent, this.key, [node]); - } else { - validate(this.parent, this.key, node); - } - this.debug(`Replace with ${node == null ? void 0 : node.type}`); - (_getCachedPaths2 = (0, _cache.getCachedPaths)(this.hub, this.parent)) == null || _getCachedPaths2.set(node, this).delete(this.node); - this.node = this.container[this.key] = node; -} -function replaceExpressionWithStatements(nodes) { - this.resync(); - const declars = []; - const nodesAsSingleExpression = gatherSequenceExpressions(nodes, declars); - if (nodesAsSingleExpression) { - for (const id of declars) this.scope.push({ - id - }); - return this.replaceWith(nodesAsSingleExpression)[0].get("expressions"); - } - const functionParent = this.getFunctionParent(); - const isParentAsync = functionParent == null ? void 0 : functionParent.is("async"); - const isParentGenerator = functionParent == null ? void 0 : functionParent.is("generator"); - const container = arrowFunctionExpression([], blockStatement(nodes)); - this.replaceWith(callExpression(container, [])); - const callee = this.get("callee"); - (0, _helperHoistVariables.default)(callee.get("body"), id => { - this.scope.push({ - id - }); - }, "var"); - const completionRecords = this.get("callee").getCompletionRecords(); - for (const path of completionRecords) { - if (!path.isExpressionStatement()) continue; - const loop = path.findParent(path => path.isLoop()); - if (loop) { - let uid = loop.getData("expressionReplacementReturnUid"); - if (!uid) { - uid = callee.scope.generateDeclaredUidIdentifier("ret"); - callee.get("body").pushContainer("body", returnStatement(cloneNode(uid))); - loop.setData("expressionReplacementReturnUid", uid); - } else { - uid = identifier(uid.name); - } - path.get("expression").replaceWith(assignmentExpression("=", cloneNode(uid), path.node.expression)); - } else { - path.replaceWith(returnStatement(path.node.expression)); - } - } - callee.arrowFunctionToExpression(); - const newCallee = callee; - const needToAwaitFunction = isParentAsync && _index.default.hasType(this.get("callee.body").node, "AwaitExpression", FUNCTION_TYPES); - const needToYieldFunction = isParentGenerator && _index.default.hasType(this.get("callee.body").node, "YieldExpression", FUNCTION_TYPES); - if (needToAwaitFunction) { - newCallee.set("async", true); - if (!needToYieldFunction) { - this.replaceWith(awaitExpression(this.node)); - } - } - if (needToYieldFunction) { - newCallee.set("generator", true); - this.replaceWith(yieldExpression(this.node, true)); - } - return newCallee.get("body.body"); -} -function gatherSequenceExpressions(nodes, declars) { - const exprs = []; - let ensureLastUndefined = true; - for (const node of nodes) { - if (!isEmptyStatement(node)) { - ensureLastUndefined = false; - } - if (isExpression(node)) { - exprs.push(node); - } else if (isExpressionStatement(node)) { - exprs.push(node.expression); - } else if (isVariableDeclaration(node)) { - if (node.kind !== "var") return; - for (const declar of node.declarations) { - const bindings = getBindingIdentifiers(declar); - for (const key of Object.keys(bindings)) { - declars.push(cloneNode(bindings[key])); - } - if (declar.init) { - exprs.push(assignmentExpression("=", declar.id, declar.init)); - } - } - ensureLastUndefined = true; - } else if (isIfStatement(node)) { - const consequent = node.consequent ? gatherSequenceExpressions([node.consequent], declars) : buildUndefinedNode(); - const alternate = node.alternate ? gatherSequenceExpressions([node.alternate], declars) : buildUndefinedNode(); - if (!consequent || !alternate) return; - exprs.push(conditionalExpression(node.test, consequent, alternate)); - } else if (isBlockStatement(node)) { - const body = gatherSequenceExpressions(node.body, declars); - if (!body) return; - exprs.push(body); - } else if (isEmptyStatement(node)) { - if (nodes.indexOf(node) === 0) { - ensureLastUndefined = true; - } - } else { - return; - } - } - if (ensureLastUndefined) exprs.push(buildUndefinedNode()); - if (exprs.length === 1) { - return exprs[0]; - } else { - return sequenceExpression(exprs); - } -} -function replaceInline(nodes) { - this.resync(); - if (Array.isArray(nodes)) { - if (Array.isArray(this.container)) { - nodes = _modification._verifyNodeList.call(this, nodes); - const paths = _modification._containerInsertAfter.call(this, nodes); - this.remove(); - return paths; - } else { - return this.replaceWithMultiple(nodes); - } - } else { - return this.replaceWith(nodes); - } -} - -//# sourceMappingURL=replacement.js.map diff --git a/tools/eslint/node_modules/@babel/traverse/lib/scope/binding.js b/tools/eslint/node_modules/@babel/traverse/lib/scope/binding.js deleted file mode 100644 index 90a6d9b8589327..00000000000000 --- a/tools/eslint/node_modules/@babel/traverse/lib/scope/binding.js +++ /dev/null @@ -1,83 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.default = void 0; -class Binding { - constructor({ - identifier, - scope, - path, - kind - }) { - this.identifier = void 0; - this.scope = void 0; - this.path = void 0; - this.kind = void 0; - this.constantViolations = []; - this.constant = true; - this.referencePaths = []; - this.referenced = false; - this.references = 0; - this.identifier = identifier; - this.scope = scope; - this.path = path; - this.kind = kind; - if ((kind === "var" || kind === "hoisted") && isDeclaredInLoop(path)) { - this.reassign(path); - } - this.clearValue(); - } - deoptValue() { - this.clearValue(); - this.hasDeoptedValue = true; - } - setValue(value) { - if (this.hasDeoptedValue) return; - this.hasValue = true; - this.value = value; - } - clearValue() { - this.hasDeoptedValue = false; - this.hasValue = false; - this.value = null; - } - reassign(path) { - this.constant = false; - if (this.constantViolations.includes(path)) { - return; - } - this.constantViolations.push(path); - } - reference(path) { - if (this.referencePaths.includes(path)) { - return; - } - this.referenced = true; - this.references++; - this.referencePaths.push(path); - } - dereference() { - this.references--; - this.referenced = !!this.references; - } -} -exports.default = Binding; -function isDeclaredInLoop(path) { - for (let { - parentPath, - key - } = path; parentPath; ({ - parentPath, - key - } = parentPath)) { - if (parentPath.isFunctionParent()) return false; - if (parentPath.isWhile() || parentPath.isForXStatement() || parentPath.isForStatement() && key === "body") { - return true; - } - } - return false; -} - -//# sourceMappingURL=binding.js.map diff --git a/tools/eslint/node_modules/@babel/traverse/lib/scope/index.js b/tools/eslint/node_modules/@babel/traverse/lib/scope/index.js deleted file mode 100644 index 350da1a39f8cc5..00000000000000 --- a/tools/eslint/node_modules/@babel/traverse/lib/scope/index.js +++ /dev/null @@ -1,910 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.default = void 0; -var _renamer = require("./lib/renamer.js"); -var _index = require("../index.js"); -var _binding = require("./binding.js"); -var _globals = require("globals"); -var _t = require("@babel/types"); -var t = _t; -var _cache = require("../cache.js"); -var _visitors = require("../visitors.js"); -const { - NOT_LOCAL_BINDING, - callExpression, - cloneNode, - getBindingIdentifiers, - identifier, - isArrayExpression, - isBinary, - isCallExpression, - isClass, - isClassBody, - isClassDeclaration, - isExportAllDeclaration, - isExportDefaultDeclaration, - isExportNamedDeclaration, - isFunctionDeclaration, - isIdentifier, - isImportDeclaration, - isLiteral, - isMemberExpression, - isMethod, - isModuleSpecifier, - isNullLiteral, - isObjectExpression, - isProperty, - isPureish, - isRegExpLiteral, - isSuper, - isTaggedTemplateExpression, - isTemplateLiteral, - isThisExpression, - isUnaryExpression, - isVariableDeclaration, - matchesPattern, - memberExpression, - numericLiteral, - toIdentifier, - variableDeclaration, - variableDeclarator, - isRecordExpression, - isTupleExpression, - isObjectProperty, - isTopicReference, - isMetaProperty, - isPrivateName, - isExportDeclaration, - buildUndefinedNode -} = _t; -function gatherNodeParts(node, parts) { - switch (node == null ? void 0 : node.type) { - default: - if (isImportDeclaration(node) || isExportDeclaration(node)) { - var _node$specifiers; - if ((isExportAllDeclaration(node) || isExportNamedDeclaration(node) || isImportDeclaration(node)) && node.source) { - gatherNodeParts(node.source, parts); - } else if ((isExportNamedDeclaration(node) || isImportDeclaration(node)) && (_node$specifiers = node.specifiers) != null && _node$specifiers.length) { - for (const e of node.specifiers) gatherNodeParts(e, parts); - } else if ((isExportDefaultDeclaration(node) || isExportNamedDeclaration(node)) && node.declaration) { - gatherNodeParts(node.declaration, parts); - } - } else if (isModuleSpecifier(node)) { - gatherNodeParts(node.local, parts); - } else if (isLiteral(node) && !isNullLiteral(node) && !isRegExpLiteral(node) && !isTemplateLiteral(node)) { - parts.push(node.value); - } - break; - case "MemberExpression": - case "OptionalMemberExpression": - case "JSXMemberExpression": - gatherNodeParts(node.object, parts); - gatherNodeParts(node.property, parts); - break; - case "Identifier": - case "JSXIdentifier": - parts.push(node.name); - break; - case "CallExpression": - case "OptionalCallExpression": - case "NewExpression": - gatherNodeParts(node.callee, parts); - break; - case "ObjectExpression": - case "ObjectPattern": - for (const e of node.properties) { - gatherNodeParts(e, parts); - } - break; - case "SpreadElement": - case "RestElement": - gatherNodeParts(node.argument, parts); - break; - case "ObjectProperty": - case "ObjectMethod": - case "ClassProperty": - case "ClassMethod": - case "ClassPrivateProperty": - case "ClassPrivateMethod": - gatherNodeParts(node.key, parts); - break; - case "ThisExpression": - parts.push("this"); - break; - case "Super": - parts.push("super"); - break; - case "Import": - parts.push("import"); - break; - case "DoExpression": - parts.push("do"); - break; - case "YieldExpression": - parts.push("yield"); - gatherNodeParts(node.argument, parts); - break; - case "AwaitExpression": - parts.push("await"); - gatherNodeParts(node.argument, parts); - break; - case "AssignmentExpression": - gatherNodeParts(node.left, parts); - break; - case "VariableDeclarator": - gatherNodeParts(node.id, parts); - break; - case "FunctionExpression": - case "FunctionDeclaration": - case "ClassExpression": - case "ClassDeclaration": - gatherNodeParts(node.id, parts); - break; - case "PrivateName": - gatherNodeParts(node.id, parts); - break; - case "ParenthesizedExpression": - gatherNodeParts(node.expression, parts); - break; - case "UnaryExpression": - case "UpdateExpression": - gatherNodeParts(node.argument, parts); - break; - case "MetaProperty": - gatherNodeParts(node.meta, parts); - gatherNodeParts(node.property, parts); - break; - case "JSXElement": - gatherNodeParts(node.openingElement, parts); - break; - case "JSXOpeningElement": - gatherNodeParts(node.name, parts); - break; - case "JSXFragment": - gatherNodeParts(node.openingFragment, parts); - break; - case "JSXOpeningFragment": - parts.push("Fragment"); - break; - case "JSXNamespacedName": - gatherNodeParts(node.namespace, parts); - gatherNodeParts(node.name, parts); - break; - } -} -const collectorVisitor = { - ForStatement(path) { - const declar = path.get("init"); - if (declar.isVar()) { - const { - scope - } = path; - const parentScope = scope.getFunctionParent() || scope.getProgramParent(); - parentScope.registerBinding("var", declar); - } - }, - Declaration(path) { - if (path.isBlockScoped()) return; - if (path.isImportDeclaration()) return; - if (path.isExportDeclaration()) return; - const parent = path.scope.getFunctionParent() || path.scope.getProgramParent(); - parent.registerDeclaration(path); - }, - ImportDeclaration(path) { - const parent = path.scope.getBlockParent(); - parent.registerDeclaration(path); - }, - ReferencedIdentifier(path, state) { - state.references.push(path); - }, - ForXStatement(path, state) { - const left = path.get("left"); - if (left.isPattern() || left.isIdentifier()) { - state.constantViolations.push(path); - } else if (left.isVar()) { - const { - scope - } = path; - const parentScope = scope.getFunctionParent() || scope.getProgramParent(); - parentScope.registerBinding("var", left); - } - }, - ExportDeclaration: { - exit(path) { - const { - node, - scope - } = path; - if (isExportAllDeclaration(node)) return; - const declar = node.declaration; - if (isClassDeclaration(declar) || isFunctionDeclaration(declar)) { - const id = declar.id; - if (!id) return; - const binding = scope.getBinding(id.name); - binding == null || binding.reference(path); - } else if (isVariableDeclaration(declar)) { - for (const decl of declar.declarations) { - for (const name of Object.keys(getBindingIdentifiers(decl))) { - const binding = scope.getBinding(name); - binding == null || binding.reference(path); - } - } - } - } - }, - LabeledStatement(path) { - path.scope.getBlockParent().registerDeclaration(path); - }, - AssignmentExpression(path, state) { - state.assignments.push(path); - }, - UpdateExpression(path, state) { - state.constantViolations.push(path); - }, - UnaryExpression(path, state) { - if (path.node.operator === "delete") { - state.constantViolations.push(path); - } - }, - BlockScoped(path) { - let scope = path.scope; - if (scope.path === path) scope = scope.parent; - const parent = scope.getBlockParent(); - parent.registerDeclaration(path); - if (path.isClassDeclaration() && path.node.id) { - const id = path.node.id; - const name = id.name; - path.scope.bindings[name] = path.scope.parent.getBinding(name); - } - }, - CatchClause(path) { - path.scope.registerBinding("let", path); - }, - Function(path) { - const params = path.get("params"); - for (const param of params) { - path.scope.registerBinding("param", param); - } - if (path.isFunctionExpression() && path.has("id") && !path.get("id").node[NOT_LOCAL_BINDING]) { - path.scope.registerBinding("local", path.get("id"), path); - } - }, - ClassExpression(path) { - if (path.has("id") && !path.get("id").node[NOT_LOCAL_BINDING]) { - path.scope.registerBinding("local", path.get("id"), path); - } - }, - TSTypeAnnotation(path) { - path.skip(); - } -}; -let uid = 0; -class Scope { - constructor(path) { - this.uid = void 0; - this.path = void 0; - this.block = void 0; - this.labels = void 0; - this.inited = void 0; - this.bindings = void 0; - this.references = void 0; - this.globals = void 0; - this.uids = void 0; - this.data = void 0; - this.crawling = void 0; - const { - node - } = path; - const cached = _cache.scope.get(node); - if ((cached == null ? void 0 : cached.path) === path) { - return cached; - } - _cache.scope.set(node, this); - this.uid = uid++; - this.block = node; - this.path = path; - this.labels = new Map(); - this.inited = false; - } - get parent() { - var _parent; - let parent, - path = this.path; - do { - var _path; - const shouldSkip = path.key === "key" || path.listKey === "decorators"; - path = path.parentPath; - if (shouldSkip && path.isMethod()) path = path.parentPath; - if ((_path = path) != null && _path.isScope()) parent = path; - } while (path && !parent); - return (_parent = parent) == null ? void 0 : _parent.scope; - } - get parentBlock() { - return this.path.parent; - } - get hub() { - return this.path.hub; - } - traverse(node, opts, state) { - (0, _index.default)(node, opts, this, state, this.path); - } - generateDeclaredUidIdentifier(name) { - const id = this.generateUidIdentifier(name); - this.push({ - id - }); - return cloneNode(id); - } - generateUidIdentifier(name) { - return identifier(this.generateUid(name)); - } - generateUid(name = "temp") { - name = toIdentifier(name).replace(/^_+/, "").replace(/[0-9]+$/g, ""); - let uid; - let i = 1; - do { - uid = this._generateUid(name, i); - i++; - } while (this.hasLabel(uid) || this.hasBinding(uid) || this.hasGlobal(uid) || this.hasReference(uid)); - const program = this.getProgramParent(); - program.references[uid] = true; - program.uids[uid] = true; - return uid; - } - _generateUid(name, i) { - let id = name; - if (i > 1) id += i; - return `_${id}`; - } - generateUidBasedOnNode(node, defaultName) { - const parts = []; - gatherNodeParts(node, parts); - let id = parts.join("$"); - id = id.replace(/^_/, "") || defaultName || "ref"; - return this.generateUid(id.slice(0, 20)); - } - generateUidIdentifierBasedOnNode(node, defaultName) { - return identifier(this.generateUidBasedOnNode(node, defaultName)); - } - isStatic(node) { - if (isThisExpression(node) || isSuper(node) || isTopicReference(node)) { - return true; - } - if (isIdentifier(node)) { - const binding = this.getBinding(node.name); - if (binding) { - return binding.constant; - } else { - return this.hasBinding(node.name); - } - } - return false; - } - maybeGenerateMemoised(node, dontPush) { - if (this.isStatic(node)) { - return null; - } else { - const id = this.generateUidIdentifierBasedOnNode(node); - if (!dontPush) { - this.push({ - id - }); - return cloneNode(id); - } - return id; - } - } - checkBlockScopedCollisions(local, kind, name, id) { - if (kind === "param") return; - if (local.kind === "local") return; - const duplicate = kind === "let" || local.kind === "let" || local.kind === "const" || local.kind === "module" || local.kind === "param" && kind === "const"; - if (duplicate) { - throw this.hub.buildError(id, `Duplicate declaration "${name}"`, TypeError); - } - } - rename(oldName, newName) { - const binding = this.getBinding(oldName); - if (binding) { - newName || (newName = this.generateUidIdentifier(oldName).name); - const renamer = new _renamer.default(binding, oldName, newName); - { - renamer.rename(arguments[2]); - } - } - } - _renameFromMap(map, oldName, newName, value) { - if (map[oldName]) { - map[newName] = value; - map[oldName] = null; - } - } - dump() { - const sep = "-".repeat(60); - console.log(sep); - let scope = this; - do { - console.log("#", scope.block.type); - for (const name of Object.keys(scope.bindings)) { - const binding = scope.bindings[name]; - console.log(" -", name, { - constant: binding.constant, - references: binding.references, - violations: binding.constantViolations.length, - kind: binding.kind - }); - } - } while (scope = scope.parent); - console.log(sep); - } - toArray(node, i, arrayLikeIsIterable) { - if (isIdentifier(node)) { - const binding = this.getBinding(node.name); - if (binding != null && binding.constant && binding.path.isGenericType("Array")) { - return node; - } - } - if (isArrayExpression(node)) { - return node; - } - if (isIdentifier(node, { - name: "arguments" - })) { - return callExpression(memberExpression(memberExpression(memberExpression(identifier("Array"), identifier("prototype")), identifier("slice")), identifier("call")), [node]); - } - let helperName; - const args = [node]; - if (i === true) { - helperName = "toConsumableArray"; - } else if (typeof i === "number") { - args.push(numericLiteral(i)); - helperName = "slicedToArray"; - } else { - helperName = "toArray"; - } - if (arrayLikeIsIterable) { - args.unshift(this.hub.addHelper(helperName)); - helperName = "maybeArrayLike"; - } - return callExpression(this.hub.addHelper(helperName), args); - } - hasLabel(name) { - return !!this.getLabel(name); - } - getLabel(name) { - return this.labels.get(name); - } - registerLabel(path) { - this.labels.set(path.node.label.name, path); - } - registerDeclaration(path) { - if (path.isLabeledStatement()) { - this.registerLabel(path); - } else if (path.isFunctionDeclaration()) { - this.registerBinding("hoisted", path.get("id"), path); - } else if (path.isVariableDeclaration()) { - const declarations = path.get("declarations"); - const { - kind - } = path.node; - for (const declar of declarations) { - this.registerBinding(kind === "using" || kind === "await using" ? "const" : kind, declar); - } - } else if (path.isClassDeclaration()) { - if (path.node.declare) return; - this.registerBinding("let", path); - } else if (path.isImportDeclaration()) { - const isTypeDeclaration = path.node.importKind === "type" || path.node.importKind === "typeof"; - const specifiers = path.get("specifiers"); - for (const specifier of specifiers) { - const isTypeSpecifier = isTypeDeclaration || specifier.isImportSpecifier() && (specifier.node.importKind === "type" || specifier.node.importKind === "typeof"); - this.registerBinding(isTypeSpecifier ? "unknown" : "module", specifier); - } - } else if (path.isExportDeclaration()) { - const declar = path.get("declaration"); - if (declar.isClassDeclaration() || declar.isFunctionDeclaration() || declar.isVariableDeclaration()) { - this.registerDeclaration(declar); - } - } else { - this.registerBinding("unknown", path); - } - } - buildUndefinedNode() { - return buildUndefinedNode(); - } - registerConstantViolation(path) { - const ids = path.getBindingIdentifiers(); - for (const name of Object.keys(ids)) { - var _this$getBinding; - (_this$getBinding = this.getBinding(name)) == null || _this$getBinding.reassign(path); - } - } - registerBinding(kind, path, bindingPath = path) { - if (!kind) throw new ReferenceError("no `kind`"); - if (path.isVariableDeclaration()) { - const declarators = path.get("declarations"); - for (const declar of declarators) { - this.registerBinding(kind, declar); - } - return; - } - const parent = this.getProgramParent(); - const ids = path.getOuterBindingIdentifiers(true); - for (const name of Object.keys(ids)) { - parent.references[name] = true; - for (const id of ids[name]) { - const local = this.getOwnBinding(name); - if (local) { - if (local.identifier === id) continue; - this.checkBlockScopedCollisions(local, kind, name, id); - } - if (local) { - local.reassign(bindingPath); - } else { - this.bindings[name] = new _binding.default({ - identifier: id, - scope: this, - path: bindingPath, - kind: kind - }); - } - } - } - } - addGlobal(node) { - this.globals[node.name] = node; - } - hasUid(name) { - let scope = this; - do { - if (scope.uids[name]) return true; - } while (scope = scope.parent); - return false; - } - hasGlobal(name) { - let scope = this; - do { - if (scope.globals[name]) return true; - } while (scope = scope.parent); - return false; - } - hasReference(name) { - return !!this.getProgramParent().references[name]; - } - isPure(node, constantsOnly) { - if (isIdentifier(node)) { - const binding = this.getBinding(node.name); - if (!binding) return false; - if (constantsOnly) return binding.constant; - return true; - } else if (isThisExpression(node) || isMetaProperty(node) || isTopicReference(node) || isPrivateName(node)) { - return true; - } else if (isClass(node)) { - var _node$decorators; - if (node.superClass && !this.isPure(node.superClass, constantsOnly)) { - return false; - } - if (((_node$decorators = node.decorators) == null ? void 0 : _node$decorators.length) > 0) { - return false; - } - return this.isPure(node.body, constantsOnly); - } else if (isClassBody(node)) { - for (const method of node.body) { - if (!this.isPure(method, constantsOnly)) return false; - } - return true; - } else if (isBinary(node)) { - return this.isPure(node.left, constantsOnly) && this.isPure(node.right, constantsOnly); - } else if (isArrayExpression(node) || isTupleExpression(node)) { - for (const elem of node.elements) { - if (elem !== null && !this.isPure(elem, constantsOnly)) return false; - } - return true; - } else if (isObjectExpression(node) || isRecordExpression(node)) { - for (const prop of node.properties) { - if (!this.isPure(prop, constantsOnly)) return false; - } - return true; - } else if (isMethod(node)) { - var _node$decorators2; - if (node.computed && !this.isPure(node.key, constantsOnly)) return false; - if (((_node$decorators2 = node.decorators) == null ? void 0 : _node$decorators2.length) > 0) { - return false; - } - return true; - } else if (isProperty(node)) { - var _node$decorators3; - if (node.computed && !this.isPure(node.key, constantsOnly)) return false; - if (((_node$decorators3 = node.decorators) == null ? void 0 : _node$decorators3.length) > 0) { - return false; - } - if (isObjectProperty(node) || node.static) { - if (node.value !== null && !this.isPure(node.value, constantsOnly)) { - return false; - } - } - return true; - } else if (isUnaryExpression(node)) { - return this.isPure(node.argument, constantsOnly); - } else if (isTemplateLiteral(node)) { - for (const expression of node.expressions) { - if (!this.isPure(expression, constantsOnly)) return false; - } - return true; - } else if (isTaggedTemplateExpression(node)) { - return matchesPattern(node.tag, "String.raw") && !this.hasBinding("String", { - noGlobals: true - }) && this.isPure(node.quasi, constantsOnly); - } else if (isMemberExpression(node)) { - return !node.computed && isIdentifier(node.object) && node.object.name === "Symbol" && isIdentifier(node.property) && node.property.name !== "for" && !this.hasBinding("Symbol", { - noGlobals: true - }); - } else if (isCallExpression(node)) { - return matchesPattern(node.callee, "Symbol.for") && !this.hasBinding("Symbol", { - noGlobals: true - }) && node.arguments.length === 1 && t.isStringLiteral(node.arguments[0]); - } else { - return isPureish(node); - } - } - setData(key, val) { - return this.data[key] = val; - } - getData(key) { - let scope = this; - do { - const data = scope.data[key]; - if (data != null) return data; - } while (scope = scope.parent); - } - removeData(key) { - let scope = this; - do { - const data = scope.data[key]; - if (data != null) scope.data[key] = null; - } while (scope = scope.parent); - } - init() { - if (!this.inited) { - this.inited = true; - this.crawl(); - } - } - crawl() { - const path = this.path; - this.references = Object.create(null); - this.bindings = Object.create(null); - this.globals = Object.create(null); - this.uids = Object.create(null); - this.data = Object.create(null); - const programParent = this.getProgramParent(); - if (programParent.crawling) return; - const state = { - references: [], - constantViolations: [], - assignments: [] - }; - this.crawling = true; - if (path.type !== "Program" && (0, _visitors.isExplodedVisitor)(collectorVisitor)) { - for (const visit of collectorVisitor.enter) { - visit.call(state, path, state); - } - const typeVisitors = collectorVisitor[path.type]; - if (typeVisitors) { - for (const visit of typeVisitors.enter) { - visit.call(state, path, state); - } - } - } - path.traverse(collectorVisitor, state); - this.crawling = false; - for (const path of state.assignments) { - const ids = path.getBindingIdentifiers(); - for (const name of Object.keys(ids)) { - if (path.scope.getBinding(name)) continue; - programParent.addGlobal(ids[name]); - } - path.scope.registerConstantViolation(path); - } - for (const ref of state.references) { - const binding = ref.scope.getBinding(ref.node.name); - if (binding) { - binding.reference(ref); - } else { - programParent.addGlobal(ref.node); - } - } - for (const path of state.constantViolations) { - path.scope.registerConstantViolation(path); - } - } - push(opts) { - let path = this.path; - if (path.isPattern()) { - path = this.getPatternParent().path; - } else if (!path.isBlockStatement() && !path.isProgram()) { - path = this.getBlockParent().path; - } - if (path.isSwitchStatement()) { - path = (this.getFunctionParent() || this.getProgramParent()).path; - } - const { - init, - unique, - kind = "var", - id - } = opts; - if (!init && !unique && (kind === "var" || kind === "let") && path.isFunction() && !path.node.name && isCallExpression(path.parent, { - callee: path.node - }) && path.parent.arguments.length <= path.node.params.length && isIdentifier(id)) { - path.pushContainer("params", id); - path.scope.registerBinding("param", path.get("params")[path.node.params.length - 1]); - return; - } - if (path.isLoop() || path.isCatchClause() || path.isFunction()) { - path.ensureBlock(); - path = path.get("body"); - } - const blockHoist = opts._blockHoist == null ? 2 : opts._blockHoist; - const dataKey = `declaration:${kind}:${blockHoist}`; - let declarPath = !unique && path.getData(dataKey); - if (!declarPath) { - const declar = variableDeclaration(kind, []); - declar._blockHoist = blockHoist; - [declarPath] = path.unshiftContainer("body", [declar]); - if (!unique) path.setData(dataKey, declarPath); - } - const declarator = variableDeclarator(id, init); - const len = declarPath.node.declarations.push(declarator); - path.scope.registerBinding(kind, declarPath.get("declarations")[len - 1]); - } - getProgramParent() { - let scope = this; - do { - if (scope.path.isProgram()) { - return scope; - } - } while (scope = scope.parent); - throw new Error("Couldn't find a Program"); - } - getFunctionParent() { - let scope = this; - do { - if (scope.path.isFunctionParent()) { - return scope; - } - } while (scope = scope.parent); - return null; - } - getBlockParent() { - let scope = this; - do { - if (scope.path.isBlockParent()) { - return scope; - } - } while (scope = scope.parent); - throw new Error("We couldn't find a BlockStatement, For, Switch, Function, Loop or Program..."); - } - getPatternParent() { - let scope = this; - do { - if (!scope.path.isPattern()) { - return scope.getBlockParent(); - } - } while (scope = scope.parent.parent); - throw new Error("We couldn't find a BlockStatement, For, Switch, Function, Loop or Program..."); - } - getAllBindings() { - const ids = Object.create(null); - let scope = this; - do { - for (const key of Object.keys(scope.bindings)) { - if (key in ids === false) { - ids[key] = scope.bindings[key]; - } - } - scope = scope.parent; - } while (scope); - return ids; - } - getAllBindingsOfKind(...kinds) { - const ids = Object.create(null); - for (const kind of kinds) { - let scope = this; - do { - for (const name of Object.keys(scope.bindings)) { - const binding = scope.bindings[name]; - if (binding.kind === kind) ids[name] = binding; - } - scope = scope.parent; - } while (scope); - } - return ids; - } - bindingIdentifierEquals(name, node) { - return this.getBindingIdentifier(name) === node; - } - getBinding(name) { - let scope = this; - let previousPath; - do { - const binding = scope.getOwnBinding(name); - if (binding) { - var _previousPath; - if ((_previousPath = previousPath) != null && _previousPath.isPattern() && binding.kind !== "param" && binding.kind !== "local") {} else { - return binding; - } - } else if (!binding && name === "arguments" && scope.path.isFunction() && !scope.path.isArrowFunctionExpression()) { - break; - } - previousPath = scope.path; - } while (scope = scope.parent); - } - getOwnBinding(name) { - return this.bindings[name]; - } - getBindingIdentifier(name) { - var _this$getBinding2; - return (_this$getBinding2 = this.getBinding(name)) == null ? void 0 : _this$getBinding2.identifier; - } - getOwnBindingIdentifier(name) { - const binding = this.bindings[name]; - return binding == null ? void 0 : binding.identifier; - } - hasOwnBinding(name) { - return !!this.getOwnBinding(name); - } - hasBinding(name, opts) { - if (!name) return false; - let scope = this; - do { - if (scope.hasOwnBinding(name)) { - return true; - } - } while (scope = scope.parent); - let noGlobals; - let noUids; - if (typeof opts === "object") { - noGlobals = opts.noGlobals; - noUids = opts.noUids; - } else if (typeof opts === "boolean") { - noGlobals = opts; - } - if (!noUids && this.hasUid(name)) return true; - if (!noGlobals && Scope.globals.includes(name)) return true; - if (!noGlobals && Scope.contextVariables.includes(name)) return true; - return false; - } - parentHasBinding(name, opts) { - var _this$parent; - return (_this$parent = this.parent) == null ? void 0 : _this$parent.hasBinding(name, opts); - } - moveBindingTo(name, scope) { - const info = this.getBinding(name); - if (info) { - info.scope.removeOwnBinding(name); - info.scope = scope; - scope.bindings[name] = info; - } - } - removeOwnBinding(name) { - delete this.bindings[name]; - } - removeBinding(name) { - var _this$getBinding3; - (_this$getBinding3 = this.getBinding(name)) == null || _this$getBinding3.scope.removeOwnBinding(name); - let scope = this; - do { - if (scope.uids[name]) { - scope.uids[name] = false; - } - } while (scope = scope.parent); - } -} -exports.default = Scope; -Scope.globals = Object.keys(_globals.builtin); -Scope.contextVariables = ["arguments", "undefined", "Infinity", "NaN"]; - -//# sourceMappingURL=index.js.map diff --git a/tools/eslint/node_modules/@babel/traverse/lib/scope/lib/renamer.js b/tools/eslint/node_modules/@babel/traverse/lib/scope/lib/renamer.js deleted file mode 100644 index 0c69566a776ae3..00000000000000 --- a/tools/eslint/node_modules/@babel/traverse/lib/scope/lib/renamer.js +++ /dev/null @@ -1,115 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.default = void 0; -var _helperSplitExportDeclaration = require("@babel/helper-split-export-declaration"); -var t = require("@babel/types"); -var _helperEnvironmentVisitor = require("@babel/helper-environment-visitor"); -var _traverseNode = require("../../traverse-node.js"); -var _visitors = require("../../visitors.js"); -const renameVisitor = { - ReferencedIdentifier({ - node - }, state) { - if (node.name === state.oldName) { - node.name = state.newName; - } - }, - Scope(path, state) { - if (!path.scope.bindingIdentifierEquals(state.oldName, state.binding.identifier)) { - path.skip(); - if (path.isMethod()) { - (0, _helperEnvironmentVisitor.requeueComputedKeyAndDecorators)(path); - } - } - }, - ObjectProperty({ - node, - scope - }, state) { - const { - name - } = node.key; - if (node.shorthand && (name === state.oldName || name === state.newName) && scope.getBindingIdentifier(name) === state.binding.identifier) { - node.shorthand = false; - { - var _node$extra; - if ((_node$extra = node.extra) != null && _node$extra.shorthand) node.extra.shorthand = false; - } - } - }, - "AssignmentExpression|Declaration|VariableDeclarator"(path, state) { - if (path.isVariableDeclaration()) return; - const ids = path.getOuterBindingIdentifiers(); - for (const name in ids) { - if (name === state.oldName) ids[name].name = state.newName; - } - } -}; -class Renamer { - constructor(binding, oldName, newName) { - this.newName = newName; - this.oldName = oldName; - this.binding = binding; - } - maybeConvertFromExportDeclaration(parentDeclar) { - const maybeExportDeclar = parentDeclar.parentPath; - if (!maybeExportDeclar.isExportDeclaration()) { - return; - } - if (maybeExportDeclar.isExportDefaultDeclaration()) { - const { - declaration - } = maybeExportDeclar.node; - if (t.isDeclaration(declaration) && !declaration.id) { - return; - } - } - if (maybeExportDeclar.isExportAllDeclaration()) { - return; - } - (0, _helperSplitExportDeclaration.default)(maybeExportDeclar); - } - maybeConvertFromClassFunctionDeclaration(path) { - return path; - } - maybeConvertFromClassFunctionExpression(path) { - return path; - } - rename() { - const { - binding, - oldName, - newName - } = this; - const { - scope, - path - } = binding; - const parentDeclar = path.find(path => path.isDeclaration() || path.isFunctionExpression() || path.isClassExpression()); - if (parentDeclar) { - const bindingIds = parentDeclar.getOuterBindingIdentifiers(); - if (bindingIds[oldName] === binding.identifier) { - this.maybeConvertFromExportDeclaration(parentDeclar); - } - } - const blockToTraverse = arguments[0] || scope.block; - (0, _traverseNode.traverseNode)(blockToTraverse, (0, _visitors.explode)(renameVisitor), scope, this, scope.path, { - discriminant: true - }); - if (!arguments[0]) { - scope.removeOwnBinding(oldName); - scope.bindings[newName] = binding; - this.binding.identifier.name = newName; - } - if (parentDeclar) { - this.maybeConvertFromClassFunctionDeclaration(path); - this.maybeConvertFromClassFunctionExpression(path); - } - } -} -exports.default = Renamer; - -//# sourceMappingURL=renamer.js.map diff --git a/tools/eslint/node_modules/@babel/traverse/lib/traverse-node.js b/tools/eslint/node_modules/@babel/traverse/lib/traverse-node.js deleted file mode 100644 index d3012328939db4..00000000000000 --- a/tools/eslint/node_modules/@babel/traverse/lib/traverse-node.js +++ /dev/null @@ -1,29 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.traverseNode = traverseNode; -var _context = require("./context.js"); -var _t = require("@babel/types"); -const { - VISITOR_KEYS -} = _t; -function traverseNode(node, opts, scope, state, path, skipKeys, visitSelf) { - const keys = VISITOR_KEYS[node.type]; - if (!keys) return false; - const context = new _context.default(scope, opts, state, path); - if (visitSelf) { - if (skipKeys != null && skipKeys[path.parentKey]) return false; - return context.visitQueue([path]); - } - for (const key of keys) { - if (skipKeys != null && skipKeys[key]) continue; - if (context.visit(node, key)) { - return true; - } - } - return false; -} - -//# sourceMappingURL=traverse-node.js.map diff --git a/tools/eslint/node_modules/@babel/traverse/lib/types.js b/tools/eslint/node_modules/@babel/traverse/lib/types.js deleted file mode 100644 index e1c8d91c2e25c4..00000000000000 --- a/tools/eslint/node_modules/@babel/traverse/lib/types.js +++ /dev/null @@ -1,3 +0,0 @@ - - -//# sourceMappingURL=types.js.map diff --git a/tools/eslint/node_modules/@babel/traverse/lib/visitors.js b/tools/eslint/node_modules/@babel/traverse/lib/visitors.js deleted file mode 100644 index 4ea6578fe058c4..00000000000000 --- a/tools/eslint/node_modules/@babel/traverse/lib/visitors.js +++ /dev/null @@ -1,221 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.explode = explode$1; -exports.isExplodedVisitor = isExplodedVisitor; -exports.merge = merge; -exports.verify = verify$1; -var virtualTypes = require("./path/lib/virtual-types.js"); -var virtualTypesValidators = require("./path/lib/virtual-types-validator.js"); -var _t = require("@babel/types"); -const { - DEPRECATED_KEYS, - DEPRECATED_ALIASES, - FLIPPED_ALIAS_KEYS, - TYPES, - __internal__deprecationWarning: deprecationWarning -} = _t; -function isVirtualType(type) { - return type in virtualTypes; -} -function isExplodedVisitor(visitor) { - return visitor == null ? void 0 : visitor._exploded; -} -function explode$1(visitor) { - if (isExplodedVisitor(visitor)) return visitor; - visitor._exploded = true; - for (const nodeType of Object.keys(visitor)) { - if (shouldIgnoreKey(nodeType)) continue; - const parts = nodeType.split("|"); - if (parts.length === 1) continue; - const fns = visitor[nodeType]; - delete visitor[nodeType]; - for (const part of parts) { - visitor[part] = fns; - } - } - verify$1(visitor); - delete visitor.__esModule; - ensureEntranceObjects(visitor); - ensureCallbackArrays(visitor); - for (const nodeType of Object.keys(visitor)) { - if (shouldIgnoreKey(nodeType)) continue; - if (!isVirtualType(nodeType)) continue; - const fns = visitor[nodeType]; - for (const type of Object.keys(fns)) { - fns[type] = wrapCheck(nodeType, fns[type]); - } - delete visitor[nodeType]; - const types = virtualTypes[nodeType]; - if (types !== null) { - for (const type of types) { - if (visitor[type]) { - mergePair(visitor[type], fns); - } else { - visitor[type] = fns; - } - } - } else { - mergePair(visitor, fns); - } - } - for (const nodeType of Object.keys(visitor)) { - if (shouldIgnoreKey(nodeType)) continue; - let aliases = FLIPPED_ALIAS_KEYS[nodeType]; - if (nodeType in DEPRECATED_KEYS) { - const deprecatedKey = DEPRECATED_KEYS[nodeType]; - deprecationWarning(nodeType, deprecatedKey, "Visitor "); - aliases = [deprecatedKey]; - } else if (nodeType in DEPRECATED_ALIASES) { - const deprecatedAlias = DEPRECATED_ALIASES[nodeType]; - deprecationWarning(nodeType, deprecatedAlias, "Visitor "); - aliases = FLIPPED_ALIAS_KEYS[deprecatedAlias]; - } - if (!aliases) continue; - const fns = visitor[nodeType]; - delete visitor[nodeType]; - for (const alias of aliases) { - const existing = visitor[alias]; - if (existing) { - mergePair(existing, fns); - } else { - visitor[alias] = Object.assign({}, fns); - } - } - } - for (const nodeType of Object.keys(visitor)) { - if (shouldIgnoreKey(nodeType)) continue; - ensureCallbackArrays(visitor[nodeType]); - } - return visitor; -} -function verify$1(visitor) { - if (visitor._verified) return; - if (typeof visitor === "function") { - throw new Error("You passed `traverse()` a function when it expected a visitor object, " + "are you sure you didn't mean `{ enter: Function }`?"); - } - for (const nodeType of Object.keys(visitor)) { - if (nodeType === "enter" || nodeType === "exit") { - validateVisitorMethods(nodeType, visitor[nodeType]); - } - if (shouldIgnoreKey(nodeType)) continue; - if (!TYPES.includes(nodeType)) { - throw new Error(`You gave us a visitor for the node type ${nodeType} but it's not a valid type`); - } - const visitors = visitor[nodeType]; - if (typeof visitors === "object") { - for (const visitorKey of Object.keys(visitors)) { - if (visitorKey === "enter" || visitorKey === "exit") { - validateVisitorMethods(`${nodeType}.${visitorKey}`, visitors[visitorKey]); - } else { - throw new Error("You passed `traverse()` a visitor object with the property " + `${nodeType} that has the invalid property ${visitorKey}`); - } - } - } - } - visitor._verified = true; -} -function validateVisitorMethods(path, val) { - const fns = [].concat(val); - for (const fn of fns) { - if (typeof fn !== "function") { - throw new TypeError(`Non-function found defined in ${path} with type ${typeof fn}`); - } - } -} -function merge(visitors, states = [], wrapper) { - const mergedVisitor = {}; - for (let i = 0; i < visitors.length; i++) { - const visitor = explode$1(visitors[i]); - const state = states[i]; - let topVisitor = visitor; - if (state || wrapper) { - topVisitor = wrapWithStateOrWrapper(topVisitor, state, wrapper); - } - mergePair(mergedVisitor, topVisitor); - for (const key of Object.keys(visitor)) { - if (shouldIgnoreKey(key)) continue; - let typeVisitor = visitor[key]; - if (state || wrapper) { - typeVisitor = wrapWithStateOrWrapper(typeVisitor, state, wrapper); - } - const nodeVisitor = mergedVisitor[key] || (mergedVisitor[key] = {}); - mergePair(nodeVisitor, typeVisitor); - } - } - ; - return mergedVisitor; -} -function wrapWithStateOrWrapper(oldVisitor, state, wrapper) { - const newVisitor = {}; - for (const phase of ["enter", "exit"]) { - let fns = oldVisitor[phase]; - if (!Array.isArray(fns)) continue; - fns = fns.map(function (fn) { - let newFn = fn; - if (state) { - newFn = function (path) { - fn.call(state, path, state); - }; - } - if (wrapper) { - newFn = wrapper(state == null ? void 0 : state.key, phase, newFn); - } - if (newFn !== fn) { - newFn.toString = () => fn.toString(); - } - return newFn; - }); - newVisitor[phase] = fns; - } - return newVisitor; -} -function ensureEntranceObjects(obj) { - for (const key of Object.keys(obj)) { - if (shouldIgnoreKey(key)) continue; - const fns = obj[key]; - if (typeof fns === "function") { - obj[key] = { - enter: fns - }; - } - } -} -function ensureCallbackArrays(obj) { - if (obj.enter && !Array.isArray(obj.enter)) obj.enter = [obj.enter]; - if (obj.exit && !Array.isArray(obj.exit)) obj.exit = [obj.exit]; -} -function wrapCheck(nodeType, fn) { - const fnKey = `is${nodeType}`; - const validator = virtualTypesValidators[fnKey]; - const newFn = function (path) { - if (validator.call(path)) { - return fn.apply(this, arguments); - } - }; - newFn.toString = () => fn.toString(); - return newFn; -} -function shouldIgnoreKey(key) { - if (key[0] === "_") return true; - if (key === "enter" || key === "exit" || key === "shouldSkip") return true; - if (key === "denylist" || key === "noScope" || key === "skipKeys") { - return true; - } - { - if (key === "blacklist") { - return true; - } - } - return false; -} -function mergePair(dest, src) { - for (const phase of ["enter", "exit"]) { - if (!src[phase]) continue; - dest[phase] = [].concat(dest[phase] || [], src[phase]); - } -} - -//# sourceMappingURL=visitors.js.map diff --git a/tools/eslint/node_modules/@babel/traverse/node_modules/globals/globals.json b/tools/eslint/node_modules/@babel/traverse/node_modules/globals/globals.json deleted file mode 100644 index 6f5ac02f1eace7..00000000000000 --- a/tools/eslint/node_modules/@babel/traverse/node_modules/globals/globals.json +++ /dev/null @@ -1,1563 +0,0 @@ -{ - "builtin": { - "Array": false, - "ArrayBuffer": false, - "Atomics": false, - "BigInt": false, - "BigInt64Array": false, - "BigUint64Array": false, - "Boolean": false, - "constructor": false, - "DataView": false, - "Date": false, - "decodeURI": false, - "decodeURIComponent": false, - "encodeURI": false, - "encodeURIComponent": false, - "Error": false, - "escape": false, - "eval": false, - "EvalError": false, - "Float32Array": false, - "Float64Array": false, - "Function": false, - "globalThis": false, - "hasOwnProperty": false, - "Infinity": false, - "Int16Array": false, - "Int32Array": false, - "Int8Array": false, - "isFinite": false, - "isNaN": false, - "isPrototypeOf": false, - "JSON": false, - "Map": false, - "Math": false, - "NaN": false, - "Number": false, - "Object": false, - "parseFloat": false, - "parseInt": false, - "Promise": false, - "propertyIsEnumerable": false, - "Proxy": false, - "RangeError": false, - "ReferenceError": false, - "Reflect": false, - "RegExp": false, - "Set": false, - "SharedArrayBuffer": false, - "String": false, - "Symbol": false, - "SyntaxError": false, - "toLocaleString": false, - "toString": false, - "TypeError": false, - "Uint16Array": false, - "Uint32Array": false, - "Uint8Array": false, - "Uint8ClampedArray": false, - "undefined": false, - "unescape": false, - "URIError": false, - "valueOf": false, - "WeakMap": false, - "WeakSet": false - }, - "es5": { - "Array": false, - "Boolean": false, - "constructor": false, - "Date": false, - "decodeURI": false, - "decodeURIComponent": false, - "encodeURI": false, - "encodeURIComponent": false, - "Error": false, - "escape": false, - "eval": false, - "EvalError": false, - "Function": false, - "hasOwnProperty": false, - "Infinity": false, - "isFinite": false, - "isNaN": false, - "isPrototypeOf": false, - "JSON": false, - "Math": false, - "NaN": false, - "Number": false, - "Object": false, - "parseFloat": false, - "parseInt": false, - "propertyIsEnumerable": false, - "RangeError": false, - "ReferenceError": false, - "RegExp": false, - "String": false, - "SyntaxError": false, - "toLocaleString": false, - "toString": false, - "TypeError": false, - "undefined": false, - "unescape": false, - "URIError": false, - "valueOf": false - }, - "es2015": { - "Array": false, - "ArrayBuffer": false, - "Boolean": false, - "constructor": false, - "DataView": false, - "Date": false, - "decodeURI": false, - "decodeURIComponent": false, - "encodeURI": false, - "encodeURIComponent": false, - "Error": false, - "escape": false, - "eval": false, - "EvalError": false, - "Float32Array": false, - "Float64Array": false, - "Function": false, - "hasOwnProperty": false, - "Infinity": false, - "Int16Array": false, - "Int32Array": false, - "Int8Array": false, - "isFinite": false, - "isNaN": false, - "isPrototypeOf": false, - "JSON": false, - "Map": false, - "Math": false, - "NaN": false, - "Number": false, - "Object": false, - "parseFloat": false, - "parseInt": false, - "Promise": false, - "propertyIsEnumerable": false, - "Proxy": false, - "RangeError": false, - "ReferenceError": false, - "Reflect": false, - "RegExp": false, - "Set": false, - "String": false, - "Symbol": false, - "SyntaxError": false, - "toLocaleString": false, - "toString": false, - "TypeError": false, - "Uint16Array": false, - "Uint32Array": false, - "Uint8Array": false, - "Uint8ClampedArray": false, - "undefined": false, - "unescape": false, - "URIError": false, - "valueOf": false, - "WeakMap": false, - "WeakSet": false - }, - "es2017": { - "Array": false, - "ArrayBuffer": false, - "Atomics": false, - "Boolean": false, - "constructor": false, - "DataView": false, - "Date": false, - "decodeURI": false, - "decodeURIComponent": false, - "encodeURI": false, - "encodeURIComponent": false, - "Error": false, - "escape": false, - "eval": false, - "EvalError": false, - "Float32Array": false, - "Float64Array": false, - "Function": false, - "hasOwnProperty": false, - "Infinity": false, - "Int16Array": false, - "Int32Array": false, - "Int8Array": false, - "isFinite": false, - "isNaN": false, - "isPrototypeOf": false, - "JSON": false, - "Map": false, - "Math": false, - "NaN": false, - "Number": false, - "Object": false, - "parseFloat": false, - "parseInt": false, - "Promise": false, - "propertyIsEnumerable": false, - "Proxy": false, - "RangeError": false, - "ReferenceError": false, - "Reflect": false, - "RegExp": false, - "Set": false, - "SharedArrayBuffer": false, - "String": false, - "Symbol": false, - "SyntaxError": false, - "toLocaleString": false, - "toString": false, - "TypeError": false, - "Uint16Array": false, - "Uint32Array": false, - "Uint8Array": false, - "Uint8ClampedArray": false, - "undefined": false, - "unescape": false, - "URIError": false, - "valueOf": false, - "WeakMap": false, - "WeakSet": false - }, - "browser": { - "AbortController": false, - "AbortSignal": false, - "addEventListener": false, - "alert": false, - "AnalyserNode": false, - "Animation": false, - "AnimationEffectReadOnly": false, - "AnimationEffectTiming": false, - "AnimationEffectTimingReadOnly": false, - "AnimationEvent": false, - "AnimationPlaybackEvent": false, - "AnimationTimeline": false, - "applicationCache": false, - "ApplicationCache": false, - "ApplicationCacheErrorEvent": false, - "atob": false, - "Attr": false, - "Audio": false, - "AudioBuffer": false, - "AudioBufferSourceNode": false, - "AudioContext": false, - "AudioDestinationNode": false, - "AudioListener": false, - "AudioNode": false, - "AudioParam": false, - "AudioProcessingEvent": false, - "AudioScheduledSourceNode": false, - "AudioWorkletGlobalScope ": false, - "AudioWorkletNode": false, - "AudioWorkletProcessor": false, - "BarProp": false, - "BaseAudioContext": false, - "BatteryManager": false, - "BeforeUnloadEvent": false, - "BiquadFilterNode": false, - "Blob": false, - "BlobEvent": false, - "blur": false, - "BroadcastChannel": false, - "btoa": false, - "BudgetService": false, - "ByteLengthQueuingStrategy": false, - "Cache": false, - "caches": false, - "CacheStorage": false, - "cancelAnimationFrame": false, - "cancelIdleCallback": false, - "CanvasCaptureMediaStreamTrack": false, - "CanvasGradient": false, - "CanvasPattern": false, - "CanvasRenderingContext2D": false, - "ChannelMergerNode": false, - "ChannelSplitterNode": false, - "CharacterData": false, - "clearInterval": false, - "clearTimeout": false, - "clientInformation": false, - "ClipboardEvent": false, - "close": false, - "closed": false, - "CloseEvent": false, - "Comment": false, - "CompositionEvent": false, - "confirm": false, - "console": false, - "ConstantSourceNode": false, - "ConvolverNode": false, - "CountQueuingStrategy": false, - "createImageBitmap": false, - "Credential": false, - "CredentialsContainer": false, - "crypto": false, - "Crypto": false, - "CryptoKey": false, - "CSS": false, - "CSSConditionRule": false, - "CSSFontFaceRule": false, - "CSSGroupingRule": false, - "CSSImportRule": false, - "CSSKeyframeRule": false, - "CSSKeyframesRule": false, - "CSSMediaRule": false, - "CSSNamespaceRule": false, - "CSSPageRule": false, - "CSSRule": false, - "CSSRuleList": false, - "CSSStyleDeclaration": false, - "CSSStyleRule": false, - "CSSStyleSheet": false, - "CSSSupportsRule": false, - "CustomElementRegistry": false, - "customElements": false, - "CustomEvent": false, - "DataTransfer": false, - "DataTransferItem": false, - "DataTransferItemList": false, - "defaultstatus": false, - "defaultStatus": false, - "DelayNode": false, - "DeviceMotionEvent": false, - "DeviceOrientationEvent": false, - "devicePixelRatio": false, - "dispatchEvent": false, - "document": false, - "Document": false, - "DocumentFragment": false, - "DocumentType": false, - "DOMError": false, - "DOMException": false, - "DOMImplementation": false, - "DOMMatrix": false, - "DOMMatrixReadOnly": false, - "DOMParser": false, - "DOMPoint": false, - "DOMPointReadOnly": false, - "DOMQuad": false, - "DOMRect": false, - "DOMRectReadOnly": false, - "DOMStringList": false, - "DOMStringMap": false, - "DOMTokenList": false, - "DragEvent": false, - "DynamicsCompressorNode": false, - "Element": false, - "ErrorEvent": false, - "event": false, - "Event": false, - "EventSource": false, - "EventTarget": false, - "external": false, - "fetch": false, - "File": false, - "FileList": false, - "FileReader": false, - "find": false, - "focus": false, - "FocusEvent": false, - "FontFace": false, - "FontFaceSetLoadEvent": false, - "FormData": false, - "frameElement": false, - "frames": false, - "GainNode": false, - "Gamepad": false, - "GamepadButton": false, - "GamepadEvent": false, - "getComputedStyle": false, - "getSelection": false, - "HashChangeEvent": false, - "Headers": false, - "history": false, - "History": false, - "HTMLAllCollection": false, - "HTMLAnchorElement": false, - "HTMLAreaElement": false, - "HTMLAudioElement": false, - "HTMLBaseElement": false, - "HTMLBodyElement": false, - "HTMLBRElement": false, - "HTMLButtonElement": false, - "HTMLCanvasElement": false, - "HTMLCollection": false, - "HTMLContentElement": false, - "HTMLDataElement": false, - "HTMLDataListElement": false, - "HTMLDetailsElement": false, - "HTMLDialogElement": false, - "HTMLDirectoryElement": false, - "HTMLDivElement": false, - "HTMLDListElement": false, - "HTMLDocument": false, - "HTMLElement": false, - "HTMLEmbedElement": false, - "HTMLFieldSetElement": false, - "HTMLFontElement": false, - "HTMLFormControlsCollection": false, - "HTMLFormElement": false, - "HTMLFrameElement": false, - "HTMLFrameSetElement": false, - "HTMLHeadElement": false, - "HTMLHeadingElement": false, - "HTMLHRElement": false, - "HTMLHtmlElement": false, - "HTMLIFrameElement": false, - "HTMLImageElement": false, - "HTMLInputElement": false, - "HTMLLabelElement": false, - "HTMLLegendElement": false, - "HTMLLIElement": false, - "HTMLLinkElement": false, - "HTMLMapElement": false, - "HTMLMarqueeElement": false, - "HTMLMediaElement": false, - "HTMLMenuElement": false, - "HTMLMetaElement": false, - "HTMLMeterElement": false, - "HTMLModElement": false, - "HTMLObjectElement": false, - "HTMLOListElement": false, - "HTMLOptGroupElement": false, - "HTMLOptionElement": false, - "HTMLOptionsCollection": false, - "HTMLOutputElement": false, - "HTMLParagraphElement": false, - "HTMLParamElement": false, - "HTMLPictureElement": false, - "HTMLPreElement": false, - "HTMLProgressElement": false, - "HTMLQuoteElement": false, - "HTMLScriptElement": false, - "HTMLSelectElement": false, - "HTMLShadowElement": false, - "HTMLSlotElement": false, - "HTMLSourceElement": false, - "HTMLSpanElement": false, - "HTMLStyleElement": false, - "HTMLTableCaptionElement": false, - "HTMLTableCellElement": false, - "HTMLTableColElement": false, - "HTMLTableElement": false, - "HTMLTableRowElement": false, - "HTMLTableSectionElement": false, - "HTMLTemplateElement": false, - "HTMLTextAreaElement": false, - "HTMLTimeElement": false, - "HTMLTitleElement": false, - "HTMLTrackElement": false, - "HTMLUListElement": false, - "HTMLUnknownElement": false, - "HTMLVideoElement": false, - "IDBCursor": false, - "IDBCursorWithValue": false, - "IDBDatabase": false, - "IDBFactory": false, - "IDBIndex": false, - "IDBKeyRange": false, - "IDBObjectStore": false, - "IDBOpenDBRequest": false, - "IDBRequest": false, - "IDBTransaction": false, - "IDBVersionChangeEvent": false, - "IdleDeadline": false, - "IIRFilterNode": false, - "Image": false, - "ImageBitmap": false, - "ImageBitmapRenderingContext": false, - "ImageCapture": false, - "ImageData": false, - "indexedDB": false, - "innerHeight": false, - "innerWidth": false, - "InputEvent": false, - "IntersectionObserver": false, - "IntersectionObserverEntry": false, - "Intl": false, - "isSecureContext": false, - "KeyboardEvent": false, - "KeyframeEffect": false, - "KeyframeEffectReadOnly": false, - "length": false, - "localStorage": false, - "location": true, - "Location": false, - "locationbar": false, - "matchMedia": false, - "MediaDeviceInfo": false, - "MediaDevices": false, - "MediaElementAudioSourceNode": false, - "MediaEncryptedEvent": false, - "MediaError": false, - "MediaKeyMessageEvent": false, - "MediaKeySession": false, - "MediaKeyStatusMap": false, - "MediaKeySystemAccess": false, - "MediaList": false, - "MediaQueryList": false, - "MediaQueryListEvent": false, - "MediaRecorder": false, - "MediaSettingsRange": false, - "MediaSource": false, - "MediaStream": false, - "MediaStreamAudioDestinationNode": false, - "MediaStreamAudioSourceNode": false, - "MediaStreamEvent": false, - "MediaStreamTrack": false, - "MediaStreamTrackEvent": false, - "menubar": false, - "MessageChannel": false, - "MessageEvent": false, - "MessagePort": false, - "MIDIAccess": false, - "MIDIConnectionEvent": false, - "MIDIInput": false, - "MIDIInputMap": false, - "MIDIMessageEvent": false, - "MIDIOutput": false, - "MIDIOutputMap": false, - "MIDIPort": false, - "MimeType": false, - "MimeTypeArray": false, - "MouseEvent": false, - "moveBy": false, - "moveTo": false, - "MutationEvent": false, - "MutationObserver": false, - "MutationRecord": false, - "name": false, - "NamedNodeMap": false, - "NavigationPreloadManager": false, - "navigator": false, - "Navigator": false, - "NetworkInformation": false, - "Node": false, - "NodeFilter": false, - "NodeIterator": false, - "NodeList": false, - "Notification": false, - "OfflineAudioCompletionEvent": false, - "OfflineAudioContext": false, - "offscreenBuffering": false, - "OffscreenCanvas": true, - "onabort": true, - "onafterprint": true, - "onanimationend": true, - "onanimationiteration": true, - "onanimationstart": true, - "onappinstalled": true, - "onauxclick": true, - "onbeforeinstallprompt": true, - "onbeforeprint": true, - "onbeforeunload": true, - "onblur": true, - "oncancel": true, - "oncanplay": true, - "oncanplaythrough": true, - "onchange": true, - "onclick": true, - "onclose": true, - "oncontextmenu": true, - "oncuechange": true, - "ondblclick": true, - "ondevicemotion": true, - "ondeviceorientation": true, - "ondeviceorientationabsolute": true, - "ondrag": true, - "ondragend": true, - "ondragenter": true, - "ondragleave": true, - "ondragover": true, - "ondragstart": true, - "ondrop": true, - "ondurationchange": true, - "onemptied": true, - "onended": true, - "onerror": true, - "onfocus": true, - "ongotpointercapture": true, - "onhashchange": true, - "oninput": true, - "oninvalid": true, - "onkeydown": true, - "onkeypress": true, - "onkeyup": true, - "onlanguagechange": true, - "onload": true, - "onloadeddata": true, - "onloadedmetadata": true, - "onloadstart": true, - "onlostpointercapture": true, - "onmessage": true, - "onmessageerror": true, - "onmousedown": true, - "onmouseenter": true, - "onmouseleave": true, - "onmousemove": true, - "onmouseout": true, - "onmouseover": true, - "onmouseup": true, - "onmousewheel": true, - "onoffline": true, - "ononline": true, - "onpagehide": true, - "onpageshow": true, - "onpause": true, - "onplay": true, - "onplaying": true, - "onpointercancel": true, - "onpointerdown": true, - "onpointerenter": true, - "onpointerleave": true, - "onpointermove": true, - "onpointerout": true, - "onpointerover": true, - "onpointerup": true, - "onpopstate": true, - "onprogress": true, - "onratechange": true, - "onrejectionhandled": true, - "onreset": true, - "onresize": true, - "onscroll": true, - "onsearch": true, - "onseeked": true, - "onseeking": true, - "onselect": true, - "onstalled": true, - "onstorage": true, - "onsubmit": true, - "onsuspend": true, - "ontimeupdate": true, - "ontoggle": true, - "ontransitionend": true, - "onunhandledrejection": true, - "onunload": true, - "onvolumechange": true, - "onwaiting": true, - "onwheel": true, - "open": false, - "openDatabase": false, - "opener": false, - "Option": false, - "origin": false, - "OscillatorNode": false, - "outerHeight": false, - "outerWidth": false, - "PageTransitionEvent": false, - "pageXOffset": false, - "pageYOffset": false, - "PannerNode": false, - "parent": false, - "Path2D": false, - "PaymentAddress": false, - "PaymentRequest": false, - "PaymentRequestUpdateEvent": false, - "PaymentResponse": false, - "performance": false, - "Performance": false, - "PerformanceEntry": false, - "PerformanceLongTaskTiming": false, - "PerformanceMark": false, - "PerformanceMeasure": false, - "PerformanceNavigation": false, - "PerformanceNavigationTiming": false, - "PerformanceObserver": false, - "PerformanceObserverEntryList": false, - "PerformancePaintTiming": false, - "PerformanceResourceTiming": false, - "PerformanceTiming": false, - "PeriodicWave": false, - "Permissions": false, - "PermissionStatus": false, - "personalbar": false, - "PhotoCapabilities": false, - "Plugin": false, - "PluginArray": false, - "PointerEvent": false, - "PopStateEvent": false, - "postMessage": false, - "Presentation": false, - "PresentationAvailability": false, - "PresentationConnection": false, - "PresentationConnectionAvailableEvent": false, - "PresentationConnectionCloseEvent": false, - "PresentationConnectionList": false, - "PresentationReceiver": false, - "PresentationRequest": false, - "print": false, - "ProcessingInstruction": false, - "ProgressEvent": false, - "PromiseRejectionEvent": false, - "prompt": false, - "PushManager": false, - "PushSubscription": false, - "PushSubscriptionOptions": false, - "queueMicrotask": false, - "RadioNodeList": false, - "Range": false, - "ReadableStream": false, - "registerProcessor": false, - "RemotePlayback": false, - "removeEventListener": false, - "Request": false, - "requestAnimationFrame": false, - "requestIdleCallback": false, - "resizeBy": false, - "ResizeObserver": false, - "ResizeObserverEntry": false, - "resizeTo": false, - "Response": false, - "RTCCertificate": false, - "RTCDataChannel": false, - "RTCDataChannelEvent": false, - "RTCDtlsTransport": false, - "RTCIceCandidate": false, - "RTCIceGatherer": false, - "RTCIceTransport": false, - "RTCPeerConnection": false, - "RTCPeerConnectionIceEvent": false, - "RTCRtpContributingSource": false, - "RTCRtpReceiver": false, - "RTCRtpSender": false, - "RTCSctpTransport": false, - "RTCSessionDescription": false, - "RTCStatsReport": false, - "RTCTrackEvent": false, - "screen": false, - "Screen": false, - "screenLeft": false, - "ScreenOrientation": false, - "screenTop": false, - "screenX": false, - "screenY": false, - "ScriptProcessorNode": false, - "scroll": false, - "scrollbars": false, - "scrollBy": false, - "scrollTo": false, - "scrollX": false, - "scrollY": false, - "SecurityPolicyViolationEvent": false, - "Selection": false, - "self": false, - "ServiceWorker": false, - "ServiceWorkerContainer": false, - "ServiceWorkerRegistration": false, - "sessionStorage": false, - "setInterval": false, - "setTimeout": false, - "ShadowRoot": false, - "SharedWorker": false, - "SourceBuffer": false, - "SourceBufferList": false, - "speechSynthesis": false, - "SpeechSynthesisEvent": false, - "SpeechSynthesisUtterance": false, - "StaticRange": false, - "status": false, - "statusbar": false, - "StereoPannerNode": false, - "stop": false, - "Storage": false, - "StorageEvent": false, - "StorageManager": false, - "styleMedia": false, - "StyleSheet": false, - "StyleSheetList": false, - "SubtleCrypto": false, - "SVGAElement": false, - "SVGAngle": false, - "SVGAnimatedAngle": false, - "SVGAnimatedBoolean": false, - "SVGAnimatedEnumeration": false, - "SVGAnimatedInteger": false, - "SVGAnimatedLength": false, - "SVGAnimatedLengthList": false, - "SVGAnimatedNumber": false, - "SVGAnimatedNumberList": false, - "SVGAnimatedPreserveAspectRatio": false, - "SVGAnimatedRect": false, - "SVGAnimatedString": false, - "SVGAnimatedTransformList": false, - "SVGAnimateElement": false, - "SVGAnimateMotionElement": false, - "SVGAnimateTransformElement": false, - "SVGAnimationElement": false, - "SVGCircleElement": false, - "SVGClipPathElement": false, - "SVGComponentTransferFunctionElement": false, - "SVGDefsElement": false, - "SVGDescElement": false, - "SVGDiscardElement": false, - "SVGElement": false, - "SVGEllipseElement": false, - "SVGFEBlendElement": false, - "SVGFEColorMatrixElement": false, - "SVGFEComponentTransferElement": false, - "SVGFECompositeElement": false, - "SVGFEConvolveMatrixElement": false, - "SVGFEDiffuseLightingElement": false, - "SVGFEDisplacementMapElement": false, - "SVGFEDistantLightElement": false, - "SVGFEDropShadowElement": false, - "SVGFEFloodElement": false, - "SVGFEFuncAElement": false, - "SVGFEFuncBElement": false, - "SVGFEFuncGElement": false, - "SVGFEFuncRElement": false, - "SVGFEGaussianBlurElement": false, - "SVGFEImageElement": false, - "SVGFEMergeElement": false, - "SVGFEMergeNodeElement": false, - "SVGFEMorphologyElement": false, - "SVGFEOffsetElement": false, - "SVGFEPointLightElement": false, - "SVGFESpecularLightingElement": false, - "SVGFESpotLightElement": false, - "SVGFETileElement": false, - "SVGFETurbulenceElement": false, - "SVGFilterElement": false, - "SVGForeignObjectElement": false, - "SVGGElement": false, - "SVGGeometryElement": false, - "SVGGradientElement": false, - "SVGGraphicsElement": false, - "SVGImageElement": false, - "SVGLength": false, - "SVGLengthList": false, - "SVGLinearGradientElement": false, - "SVGLineElement": false, - "SVGMarkerElement": false, - "SVGMaskElement": false, - "SVGMatrix": false, - "SVGMetadataElement": false, - "SVGMPathElement": false, - "SVGNumber": false, - "SVGNumberList": false, - "SVGPathElement": false, - "SVGPatternElement": false, - "SVGPoint": false, - "SVGPointList": false, - "SVGPolygonElement": false, - "SVGPolylineElement": false, - "SVGPreserveAspectRatio": false, - "SVGRadialGradientElement": false, - "SVGRect": false, - "SVGRectElement": false, - "SVGScriptElement": false, - "SVGSetElement": false, - "SVGStopElement": false, - "SVGStringList": false, - "SVGStyleElement": false, - "SVGSVGElement": false, - "SVGSwitchElement": false, - "SVGSymbolElement": false, - "SVGTextContentElement": false, - "SVGTextElement": false, - "SVGTextPathElement": false, - "SVGTextPositioningElement": false, - "SVGTitleElement": false, - "SVGTransform": false, - "SVGTransformList": false, - "SVGTSpanElement": false, - "SVGUnitTypes": false, - "SVGUseElement": false, - "SVGViewElement": false, - "TaskAttributionTiming": false, - "Text": false, - "TextDecoder": false, - "TextEncoder": false, - "TextEvent": false, - "TextMetrics": false, - "TextTrack": false, - "TextTrackCue": false, - "TextTrackCueList": false, - "TextTrackList": false, - "TimeRanges": false, - "toolbar": false, - "top": false, - "Touch": false, - "TouchEvent": false, - "TouchList": false, - "TrackEvent": false, - "TransitionEvent": false, - "TreeWalker": false, - "UIEvent": false, - "URL": false, - "URLSearchParams": false, - "ValidityState": false, - "visualViewport": false, - "VisualViewport": false, - "VTTCue": false, - "WaveShaperNode": false, - "WebAssembly": false, - "WebGL2RenderingContext": false, - "WebGLActiveInfo": false, - "WebGLBuffer": false, - "WebGLContextEvent": false, - "WebGLFramebuffer": false, - "WebGLProgram": false, - "WebGLQuery": false, - "WebGLRenderbuffer": false, - "WebGLRenderingContext": false, - "WebGLSampler": false, - "WebGLShader": false, - "WebGLShaderPrecisionFormat": false, - "WebGLSync": false, - "WebGLTexture": false, - "WebGLTransformFeedback": false, - "WebGLUniformLocation": false, - "WebGLVertexArrayObject": false, - "WebSocket": false, - "WheelEvent": false, - "window": false, - "Window": false, - "Worker": false, - "WritableStream": false, - "XMLDocument": false, - "XMLHttpRequest": false, - "XMLHttpRequestEventTarget": false, - "XMLHttpRequestUpload": false, - "XMLSerializer": false, - "XPathEvaluator": false, - "XPathExpression": false, - "XPathResult": false, - "XSLTProcessor": false - }, - "worker": { - "addEventListener": false, - "applicationCache": false, - "atob": false, - "Blob": false, - "BroadcastChannel": false, - "btoa": false, - "Cache": false, - "caches": false, - "clearInterval": false, - "clearTimeout": false, - "close": true, - "console": false, - "fetch": false, - "FileReaderSync": false, - "FormData": false, - "Headers": false, - "IDBCursor": false, - "IDBCursorWithValue": false, - "IDBDatabase": false, - "IDBFactory": false, - "IDBIndex": false, - "IDBKeyRange": false, - "IDBObjectStore": false, - "IDBOpenDBRequest": false, - "IDBRequest": false, - "IDBTransaction": false, - "IDBVersionChangeEvent": false, - "ImageData": false, - "importScripts": true, - "indexedDB": false, - "location": false, - "MessageChannel": false, - "MessagePort": false, - "name": false, - "navigator": false, - "Notification": false, - "onclose": true, - "onconnect": true, - "onerror": true, - "onlanguagechange": true, - "onmessage": true, - "onoffline": true, - "ononline": true, - "onrejectionhandled": true, - "onunhandledrejection": true, - "performance": false, - "Performance": false, - "PerformanceEntry": false, - "PerformanceMark": false, - "PerformanceMeasure": false, - "PerformanceNavigation": false, - "PerformanceResourceTiming": false, - "PerformanceTiming": false, - "postMessage": true, - "Promise": false, - "queueMicrotask": false, - "removeEventListener": false, - "Request": false, - "Response": false, - "self": true, - "ServiceWorkerRegistration": false, - "setInterval": false, - "setTimeout": false, - "TextDecoder": false, - "TextEncoder": false, - "URL": false, - "URLSearchParams": false, - "WebSocket": false, - "Worker": false, - "WorkerGlobalScope": false, - "XMLHttpRequest": false - }, - "node": { - "__dirname": false, - "__filename": false, - "Buffer": false, - "clearImmediate": false, - "clearInterval": false, - "clearTimeout": false, - "console": false, - "exports": true, - "global": false, - "Intl": false, - "module": false, - "process": false, - "queueMicrotask": false, - "require": false, - "setImmediate": false, - "setInterval": false, - "setTimeout": false, - "TextDecoder": false, - "TextEncoder": false, - "URL": false, - "URLSearchParams": false - }, - "commonjs": { - "exports": true, - "global": false, - "module": false, - "require": false - }, - "amd": { - "define": false, - "require": false - }, - "mocha": { - "after": false, - "afterEach": false, - "before": false, - "beforeEach": false, - "context": false, - "describe": false, - "it": false, - "mocha": false, - "run": false, - "setup": false, - "specify": false, - "suite": false, - "suiteSetup": false, - "suiteTeardown": false, - "teardown": false, - "test": false, - "xcontext": false, - "xdescribe": false, - "xit": false, - "xspecify": false - }, - "jasmine": { - "afterAll": false, - "afterEach": false, - "beforeAll": false, - "beforeEach": false, - "describe": false, - "expect": false, - "fail": false, - "fdescribe": false, - "fit": false, - "it": false, - "jasmine": false, - "pending": false, - "runs": false, - "spyOn": false, - "spyOnProperty": false, - "waits": false, - "waitsFor": false, - "xdescribe": false, - "xit": false - }, - "jest": { - "afterAll": false, - "afterEach": false, - "beforeAll": false, - "beforeEach": false, - "describe": false, - "expect": false, - "fdescribe": false, - "fit": false, - "it": false, - "jest": false, - "pit": false, - "require": false, - "test": false, - "xdescribe": false, - "xit": false, - "xtest": false - }, - "qunit": { - "asyncTest": false, - "deepEqual": false, - "equal": false, - "expect": false, - "module": false, - "notDeepEqual": false, - "notEqual": false, - "notOk": false, - "notPropEqual": false, - "notStrictEqual": false, - "ok": false, - "propEqual": false, - "QUnit": false, - "raises": false, - "start": false, - "stop": false, - "strictEqual": false, - "test": false, - "throws": false - }, - "phantomjs": { - "console": true, - "exports": true, - "phantom": true, - "require": true, - "WebPage": true - }, - "couch": { - "emit": false, - "exports": false, - "getRow": false, - "log": false, - "module": false, - "provides": false, - "require": false, - "respond": false, - "send": false, - "start": false, - "sum": false - }, - "rhino": { - "defineClass": false, - "deserialize": false, - "gc": false, - "help": false, - "importClass": false, - "importPackage": false, - "java": false, - "load": false, - "loadClass": false, - "Packages": false, - "print": false, - "quit": false, - "readFile": false, - "readUrl": false, - "runCommand": false, - "seal": false, - "serialize": false, - "spawn": false, - "sync": false, - "toint32": false, - "version": false - }, - "nashorn": { - "__DIR__": false, - "__FILE__": false, - "__LINE__": false, - "com": false, - "edu": false, - "exit": false, - "java": false, - "Java": false, - "javafx": false, - "JavaImporter": false, - "javax": false, - "JSAdapter": false, - "load": false, - "loadWithNewGlobal": false, - "org": false, - "Packages": false, - "print": false, - "quit": false - }, - "wsh": { - "ActiveXObject": true, - "Enumerator": true, - "GetObject": true, - "ScriptEngine": true, - "ScriptEngineBuildVersion": true, - "ScriptEngineMajorVersion": true, - "ScriptEngineMinorVersion": true, - "VBArray": true, - "WScript": true, - "WSH": true, - "XDomainRequest": true - }, - "jquery": { - "$": false, - "jQuery": false - }, - "yui": { - "YAHOO": false, - "YAHOO_config": false, - "YUI": false, - "YUI_config": false - }, - "shelljs": { - "cat": false, - "cd": false, - "chmod": false, - "config": false, - "cp": false, - "dirs": false, - "echo": false, - "env": false, - "error": false, - "exec": false, - "exit": false, - "find": false, - "grep": false, - "ln": false, - "ls": false, - "mkdir": false, - "mv": false, - "popd": false, - "pushd": false, - "pwd": false, - "rm": false, - "sed": false, - "set": false, - "target": false, - "tempdir": false, - "test": false, - "touch": false, - "which": false - }, - "prototypejs": { - "$": false, - "$$": false, - "$A": false, - "$break": false, - "$continue": false, - "$F": false, - "$H": false, - "$R": false, - "$w": false, - "Abstract": false, - "Ajax": false, - "Autocompleter": false, - "Builder": false, - "Class": false, - "Control": false, - "Draggable": false, - "Draggables": false, - "Droppables": false, - "Effect": false, - "Element": false, - "Enumerable": false, - "Event": false, - "Field": false, - "Form": false, - "Hash": false, - "Insertion": false, - "ObjectRange": false, - "PeriodicalExecuter": false, - "Position": false, - "Prototype": false, - "Scriptaculous": false, - "Selector": false, - "Sortable": false, - "SortableObserver": false, - "Sound": false, - "Template": false, - "Toggle": false, - "Try": false - }, - "meteor": { - "_": false, - "$": false, - "Accounts": false, - "AccountsClient": false, - "AccountsCommon": false, - "AccountsServer": false, - "App": false, - "Assets": false, - "Blaze": false, - "check": false, - "Cordova": false, - "DDP": false, - "DDPRateLimiter": false, - "DDPServer": false, - "Deps": false, - "EJSON": false, - "Email": false, - "HTTP": false, - "Log": false, - "Match": false, - "Meteor": false, - "Mongo": false, - "MongoInternals": false, - "Npm": false, - "Package": false, - "Plugin": false, - "process": false, - "Random": false, - "ReactiveDict": false, - "ReactiveVar": false, - "Router": false, - "ServiceConfiguration": false, - "Session": false, - "share": false, - "Spacebars": false, - "Template": false, - "Tinytest": false, - "Tracker": false, - "UI": false, - "Utils": false, - "WebApp": false, - "WebAppInternals": false - }, - "mongo": { - "_isWindows": false, - "_rand": false, - "BulkWriteResult": false, - "cat": false, - "cd": false, - "connect": false, - "db": false, - "getHostName": false, - "getMemInfo": false, - "hostname": false, - "ISODate": false, - "listFiles": false, - "load": false, - "ls": false, - "md5sumFile": false, - "mkdir": false, - "Mongo": false, - "NumberInt": false, - "NumberLong": false, - "ObjectId": false, - "PlanCache": false, - "print": false, - "printjson": false, - "pwd": false, - "quit": false, - "removeFile": false, - "rs": false, - "sh": false, - "UUID": false, - "version": false, - "WriteResult": false - }, - "applescript": { - "$": false, - "Application": false, - "Automation": false, - "console": false, - "delay": false, - "Library": false, - "ObjC": false, - "ObjectSpecifier": false, - "Path": false, - "Progress": false, - "Ref": false - }, - "serviceworker": { - "addEventListener": false, - "applicationCache": false, - "atob": false, - "Blob": false, - "BroadcastChannel": false, - "btoa": false, - "Cache": false, - "caches": false, - "CacheStorage": false, - "clearInterval": false, - "clearTimeout": false, - "Client": false, - "clients": false, - "Clients": false, - "close": true, - "console": false, - "ExtendableEvent": false, - "ExtendableMessageEvent": false, - "fetch": false, - "FetchEvent": false, - "FileReaderSync": false, - "FormData": false, - "Headers": false, - "IDBCursor": false, - "IDBCursorWithValue": false, - "IDBDatabase": false, - "IDBFactory": false, - "IDBIndex": false, - "IDBKeyRange": false, - "IDBObjectStore": false, - "IDBOpenDBRequest": false, - "IDBRequest": false, - "IDBTransaction": false, - "IDBVersionChangeEvent": false, - "ImageData": false, - "importScripts": false, - "indexedDB": false, - "location": false, - "MessageChannel": false, - "MessagePort": false, - "name": false, - "navigator": false, - "Notification": false, - "onclose": true, - "onconnect": true, - "onerror": true, - "onfetch": true, - "oninstall": true, - "onlanguagechange": true, - "onmessage": true, - "onmessageerror": true, - "onnotificationclick": true, - "onnotificationclose": true, - "onoffline": true, - "ononline": true, - "onpush": true, - "onpushsubscriptionchange": true, - "onrejectionhandled": true, - "onsync": true, - "onunhandledrejection": true, - "performance": false, - "Performance": false, - "PerformanceEntry": false, - "PerformanceMark": false, - "PerformanceMeasure": false, - "PerformanceNavigation": false, - "PerformanceResourceTiming": false, - "PerformanceTiming": false, - "postMessage": true, - "Promise": false, - "queueMicrotask": false, - "registration": false, - "removeEventListener": false, - "Request": false, - "Response": false, - "self": false, - "ServiceWorker": false, - "ServiceWorkerContainer": false, - "ServiceWorkerGlobalScope": false, - "ServiceWorkerMessageEvent": false, - "ServiceWorkerRegistration": false, - "setInterval": false, - "setTimeout": false, - "skipWaiting": false, - "TextDecoder": false, - "TextEncoder": false, - "URL": false, - "URLSearchParams": false, - "WebSocket": false, - "WindowClient": false, - "Worker": false, - "WorkerGlobalScope": false, - "XMLHttpRequest": false - }, - "atomtest": { - "advanceClock": false, - "fakeClearInterval": false, - "fakeClearTimeout": false, - "fakeSetInterval": false, - "fakeSetTimeout": false, - "resetTimeouts": false, - "waitsForPromise": false - }, - "embertest": { - "andThen": false, - "click": false, - "currentPath": false, - "currentRouteName": false, - "currentURL": false, - "fillIn": false, - "find": false, - "findAll": false, - "findWithAssert": false, - "keyEvent": false, - "pauseTest": false, - "resumeTest": false, - "triggerEvent": false, - "visit": false, - "wait": false - }, - "protractor": { - "$": false, - "$$": false, - "browser": false, - "by": false, - "By": false, - "DartObject": false, - "element": false, - "protractor": false - }, - "shared-node-browser": { - "clearInterval": false, - "clearTimeout": false, - "console": false, - "setInterval": false, - "setTimeout": false, - "URL": false, - "URLSearchParams": false - }, - "webextensions": { - "browser": false, - "chrome": false, - "opr": false - }, - "greasemonkey": { - "cloneInto": false, - "createObjectIn": false, - "exportFunction": false, - "GM": false, - "GM_addStyle": false, - "GM_deleteValue": false, - "GM_getResourceText": false, - "GM_getResourceURL": false, - "GM_getValue": false, - "GM_info": false, - "GM_listValues": false, - "GM_log": false, - "GM_openInTab": false, - "GM_registerMenuCommand": false, - "GM_setClipboard": false, - "GM_setValue": false, - "GM_xmlhttpRequest": false, - "unsafeWindow": false - }, - "devtools": { - "$": false, - "$_": false, - "$$": false, - "$0": false, - "$1": false, - "$2": false, - "$3": false, - "$4": false, - "$x": false, - "chrome": false, - "clear": false, - "copy": false, - "debug": false, - "dir": false, - "dirxml": false, - "getEventListeners": false, - "inspect": false, - "keys": false, - "monitor": false, - "monitorEvents": false, - "profile": false, - "profileEnd": false, - "queryObjects": false, - "table": false, - "undebug": false, - "unmonitor": false, - "unmonitorEvents": false, - "values": false - } -} diff --git a/tools/eslint/node_modules/@babel/traverse/node_modules/globals/index.js b/tools/eslint/node_modules/@babel/traverse/node_modules/globals/index.js deleted file mode 100644 index a951582e4176e8..00000000000000 --- a/tools/eslint/node_modules/@babel/traverse/node_modules/globals/index.js +++ /dev/null @@ -1,2 +0,0 @@ -'use strict'; -module.exports = require('./globals.json'); diff --git a/tools/eslint/node_modules/@babel/traverse/node_modules/globals/license b/tools/eslint/node_modules/@babel/traverse/node_modules/globals/license deleted file mode 100644 index e7af2f77107d73..00000000000000 --- a/tools/eslint/node_modules/@babel/traverse/node_modules/globals/license +++ /dev/null @@ -1,9 +0,0 @@ -MIT License - -Copyright (c) Sindre Sorhus (sindresorhus.com) - -Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/tools/eslint/node_modules/@babel/traverse/node_modules/globals/package.json b/tools/eslint/node_modules/@babel/traverse/node_modules/globals/package.json deleted file mode 100644 index dfe459b6fa6015..00000000000000 --- a/tools/eslint/node_modules/@babel/traverse/node_modules/globals/package.json +++ /dev/null @@ -1,41 +0,0 @@ -{ - "name": "globals", - "version": "11.12.0", - "description": "Global identifiers from different JavaScript environments", - "license": "MIT", - "repository": "sindresorhus/globals", - "author": { - "name": "Sindre Sorhus", - "email": "sindresorhus@gmail.com", - "url": "sindresorhus.com" - }, - "engines": { - "node": ">=4" - }, - "scripts": { - "test": "xo && ava" - }, - "files": [ - "index.js", - "globals.json" - ], - "keywords": [ - "globals", - "global", - "identifiers", - "variables", - "vars", - "jshint", - "eslint", - "environments" - ], - "devDependencies": { - "ava": "0.21.0", - "xo": "0.18.0" - }, - "xo": { - "ignores": [ - "get-browser-globals.js" - ] - } -} diff --git a/tools/eslint/node_modules/@babel/traverse/node_modules/globals/readme.md b/tools/eslint/node_modules/@babel/traverse/node_modules/globals/readme.md deleted file mode 100644 index 8c47855f34d900..00000000000000 --- a/tools/eslint/node_modules/@babel/traverse/node_modules/globals/readme.md +++ /dev/null @@ -1,41 +0,0 @@ -# globals [![Build Status](https://travis-ci.org/sindresorhus/globals.svg?branch=master)](https://travis-ci.org/sindresorhus/globals) - -> Global identifiers from different JavaScript environments - -Extracted from [JSHint](https://github.com/jshint/jshint/blob/3a8efa979dbb157bfb5c10b5826603a55a33b9ad/src/vars.js) and [ESLint](https://github.com/eslint/eslint/blob/b648406218f8a2d7302b98f5565e23199f44eb31/conf/environments.json) and merged. - -It's just a [JSON file](globals.json), so use it in whatever environment you like. - -**This module [no longer accepts](https://github.com/sindresorhus/globals/issues/82) new environments. If you need it for ESLint, just [create a plugin](http://eslint.org/docs/developer-guide/working-with-plugins#environments-in-plugins).** - - -## Install - -``` -$ npm install globals -``` - - -## Usage - -```js -const globals = require('globals'); - -console.log(globals.browser); -/* -{ - addEventListener: false, - applicationCache: false, - ArrayBuffer: false, - atob: false, - ... -} -*/ -``` - -Each global is given a value of `true` or `false`. A value of `true` indicates that the variable may be overwritten. A value of `false` indicates that the variable should be considered read-only. This information is used by static analysis tools to flag incorrect behavior. We assume all variables should be `false` unless we hear otherwise. - - -## License - -MIT ยฉ [Sindre Sorhus](https://sindresorhus.com) diff --git a/tools/eslint/node_modules/@babel/traverse/package.json b/tools/eslint/node_modules/@babel/traverse/package.json deleted file mode 100644 index 9d826f53bb40f2..00000000000000 --- a/tools/eslint/node_modules/@babel/traverse/package.json +++ /dev/null @@ -1,38 +0,0 @@ -{ - "name": "@babel/traverse", - "version": "7.24.8", - "description": "The Babel Traverse module maintains the overall tree state, and is responsible for replacing, removing, and adding nodes", - "author": "The Babel Team (https://babel.dev/team)", - "homepage": "https://babel.dev/docs/en/next/babel-traverse", - "bugs": "https://github.com/babel/babel/issues?utf8=%E2%9C%93&q=is%3Aissue+label%3A%22pkg%3A%20traverse%22+is%3Aopen", - "license": "MIT", - "publishConfig": { - "access": "public" - }, - "repository": { - "type": "git", - "url": "https://github.com/babel/babel.git", - "directory": "packages/babel-traverse" - }, - "main": "./lib/index.js", - "dependencies": { - "@babel/code-frame": "^7.24.7", - "@babel/generator": "^7.24.8", - "@babel/helper-environment-visitor": "^7.24.7", - "@babel/helper-function-name": "^7.24.7", - "@babel/helper-hoist-variables": "^7.24.7", - "@babel/helper-split-export-declaration": "^7.24.7", - "@babel/parser": "^7.24.8", - "@babel/types": "^7.24.8", - "debug": "^4.3.1", - "globals": "^11.1.0" - }, - "devDependencies": { - "@babel/core": "^7.24.8", - "@babel/helper-plugin-test-runner": "^7.24.7" - }, - "engines": { - "node": ">=6.9.0" - }, - "type": "commonjs" -} \ No newline at end of file diff --git a/tools/eslint/node_modules/@babel/types/LICENSE b/tools/eslint/node_modules/@babel/types/LICENSE deleted file mode 100644 index f31575ec773bb1..00000000000000 --- a/tools/eslint/node_modules/@babel/types/LICENSE +++ /dev/null @@ -1,22 +0,0 @@ -MIT License - -Copyright (c) 2014-present Sebastian McKenzie and other contributors - -Permission is hereby granted, free of charge, to any person obtaining -a copy of this software and associated documentation files (the -"Software"), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sublicense, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/tools/eslint/node_modules/@babel/types/lib/asserts/assertNode.js b/tools/eslint/node_modules/@babel/types/lib/asserts/assertNode.js deleted file mode 100644 index c43d9c476980fc..00000000000000 --- a/tools/eslint/node_modules/@babel/types/lib/asserts/assertNode.js +++ /dev/null @@ -1,16 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.default = assertNode; -var _isNode = require("../validators/isNode.js"); -function assertNode(node) { - if (!(0, _isNode.default)(node)) { - var _node$type; - const type = (_node$type = node == null ? void 0 : node.type) != null ? _node$type : JSON.stringify(node); - throw new TypeError(`Not a valid node of type "${type}"`); - } -} - -//# sourceMappingURL=assertNode.js.map diff --git a/tools/eslint/node_modules/@babel/types/lib/asserts/generated/index.js b/tools/eslint/node_modules/@babel/types/lib/asserts/generated/index.js deleted file mode 100644 index b2d40fa7cbb606..00000000000000 --- a/tools/eslint/node_modules/@babel/types/lib/asserts/generated/index.js +++ /dev/null @@ -1,1235 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.assertAccessor = assertAccessor; -exports.assertAnyTypeAnnotation = assertAnyTypeAnnotation; -exports.assertArgumentPlaceholder = assertArgumentPlaceholder; -exports.assertArrayExpression = assertArrayExpression; -exports.assertArrayPattern = assertArrayPattern; -exports.assertArrayTypeAnnotation = assertArrayTypeAnnotation; -exports.assertArrowFunctionExpression = assertArrowFunctionExpression; -exports.assertAssignmentExpression = assertAssignmentExpression; -exports.assertAssignmentPattern = assertAssignmentPattern; -exports.assertAwaitExpression = assertAwaitExpression; -exports.assertBigIntLiteral = assertBigIntLiteral; -exports.assertBinary = assertBinary; -exports.assertBinaryExpression = assertBinaryExpression; -exports.assertBindExpression = assertBindExpression; -exports.assertBlock = assertBlock; -exports.assertBlockParent = assertBlockParent; -exports.assertBlockStatement = assertBlockStatement; -exports.assertBooleanLiteral = assertBooleanLiteral; -exports.assertBooleanLiteralTypeAnnotation = assertBooleanLiteralTypeAnnotation; -exports.assertBooleanTypeAnnotation = assertBooleanTypeAnnotation; -exports.assertBreakStatement = assertBreakStatement; -exports.assertCallExpression = assertCallExpression; -exports.assertCatchClause = assertCatchClause; -exports.assertClass = assertClass; -exports.assertClassAccessorProperty = assertClassAccessorProperty; -exports.assertClassBody = assertClassBody; -exports.assertClassDeclaration = assertClassDeclaration; -exports.assertClassExpression = assertClassExpression; -exports.assertClassImplements = assertClassImplements; -exports.assertClassMethod = assertClassMethod; -exports.assertClassPrivateMethod = assertClassPrivateMethod; -exports.assertClassPrivateProperty = assertClassPrivateProperty; -exports.assertClassProperty = assertClassProperty; -exports.assertCompletionStatement = assertCompletionStatement; -exports.assertConditional = assertConditional; -exports.assertConditionalExpression = assertConditionalExpression; -exports.assertContinueStatement = assertContinueStatement; -exports.assertDebuggerStatement = assertDebuggerStatement; -exports.assertDecimalLiteral = assertDecimalLiteral; -exports.assertDeclaration = assertDeclaration; -exports.assertDeclareClass = assertDeclareClass; -exports.assertDeclareExportAllDeclaration = assertDeclareExportAllDeclaration; -exports.assertDeclareExportDeclaration = assertDeclareExportDeclaration; -exports.assertDeclareFunction = assertDeclareFunction; -exports.assertDeclareInterface = assertDeclareInterface; -exports.assertDeclareModule = assertDeclareModule; -exports.assertDeclareModuleExports = assertDeclareModuleExports; -exports.assertDeclareOpaqueType = assertDeclareOpaqueType; -exports.assertDeclareTypeAlias = assertDeclareTypeAlias; -exports.assertDeclareVariable = assertDeclareVariable; -exports.assertDeclaredPredicate = assertDeclaredPredicate; -exports.assertDecorator = assertDecorator; -exports.assertDirective = assertDirective; -exports.assertDirectiveLiteral = assertDirectiveLiteral; -exports.assertDoExpression = assertDoExpression; -exports.assertDoWhileStatement = assertDoWhileStatement; -exports.assertEmptyStatement = assertEmptyStatement; -exports.assertEmptyTypeAnnotation = assertEmptyTypeAnnotation; -exports.assertEnumBody = assertEnumBody; -exports.assertEnumBooleanBody = assertEnumBooleanBody; -exports.assertEnumBooleanMember = assertEnumBooleanMember; -exports.assertEnumDeclaration = assertEnumDeclaration; -exports.assertEnumDefaultedMember = assertEnumDefaultedMember; -exports.assertEnumMember = assertEnumMember; -exports.assertEnumNumberBody = assertEnumNumberBody; -exports.assertEnumNumberMember = assertEnumNumberMember; -exports.assertEnumStringBody = assertEnumStringBody; -exports.assertEnumStringMember = assertEnumStringMember; -exports.assertEnumSymbolBody = assertEnumSymbolBody; -exports.assertExistsTypeAnnotation = assertExistsTypeAnnotation; -exports.assertExportAllDeclaration = assertExportAllDeclaration; -exports.assertExportDeclaration = assertExportDeclaration; -exports.assertExportDefaultDeclaration = assertExportDefaultDeclaration; -exports.assertExportDefaultSpecifier = assertExportDefaultSpecifier; -exports.assertExportNamedDeclaration = assertExportNamedDeclaration; -exports.assertExportNamespaceSpecifier = assertExportNamespaceSpecifier; -exports.assertExportSpecifier = assertExportSpecifier; -exports.assertExpression = assertExpression; -exports.assertExpressionStatement = assertExpressionStatement; -exports.assertExpressionWrapper = assertExpressionWrapper; -exports.assertFile = assertFile; -exports.assertFlow = assertFlow; -exports.assertFlowBaseAnnotation = assertFlowBaseAnnotation; -exports.assertFlowDeclaration = assertFlowDeclaration; -exports.assertFlowPredicate = assertFlowPredicate; -exports.assertFlowType = assertFlowType; -exports.assertFor = assertFor; -exports.assertForInStatement = assertForInStatement; -exports.assertForOfStatement = assertForOfStatement; -exports.assertForStatement = assertForStatement; -exports.assertForXStatement = assertForXStatement; -exports.assertFunction = assertFunction; -exports.assertFunctionDeclaration = assertFunctionDeclaration; -exports.assertFunctionExpression = assertFunctionExpression; -exports.assertFunctionParent = assertFunctionParent; -exports.assertFunctionTypeAnnotation = assertFunctionTypeAnnotation; -exports.assertFunctionTypeParam = assertFunctionTypeParam; -exports.assertGenericTypeAnnotation = assertGenericTypeAnnotation; -exports.assertIdentifier = assertIdentifier; -exports.assertIfStatement = assertIfStatement; -exports.assertImmutable = assertImmutable; -exports.assertImport = assertImport; -exports.assertImportAttribute = assertImportAttribute; -exports.assertImportDeclaration = assertImportDeclaration; -exports.assertImportDefaultSpecifier = assertImportDefaultSpecifier; -exports.assertImportExpression = assertImportExpression; -exports.assertImportNamespaceSpecifier = assertImportNamespaceSpecifier; -exports.assertImportOrExportDeclaration = assertImportOrExportDeclaration; -exports.assertImportSpecifier = assertImportSpecifier; -exports.assertIndexedAccessType = assertIndexedAccessType; -exports.assertInferredPredicate = assertInferredPredicate; -exports.assertInterfaceDeclaration = assertInterfaceDeclaration; -exports.assertInterfaceExtends = assertInterfaceExtends; -exports.assertInterfaceTypeAnnotation = assertInterfaceTypeAnnotation; -exports.assertInterpreterDirective = assertInterpreterDirective; -exports.assertIntersectionTypeAnnotation = assertIntersectionTypeAnnotation; -exports.assertJSX = assertJSX; -exports.assertJSXAttribute = assertJSXAttribute; -exports.assertJSXClosingElement = assertJSXClosingElement; -exports.assertJSXClosingFragment = assertJSXClosingFragment; -exports.assertJSXElement = assertJSXElement; -exports.assertJSXEmptyExpression = assertJSXEmptyExpression; -exports.assertJSXExpressionContainer = assertJSXExpressionContainer; -exports.assertJSXFragment = assertJSXFragment; -exports.assertJSXIdentifier = assertJSXIdentifier; -exports.assertJSXMemberExpression = assertJSXMemberExpression; -exports.assertJSXNamespacedName = assertJSXNamespacedName; -exports.assertJSXOpeningElement = assertJSXOpeningElement; -exports.assertJSXOpeningFragment = assertJSXOpeningFragment; -exports.assertJSXSpreadAttribute = assertJSXSpreadAttribute; -exports.assertJSXSpreadChild = assertJSXSpreadChild; -exports.assertJSXText = assertJSXText; -exports.assertLVal = assertLVal; -exports.assertLabeledStatement = assertLabeledStatement; -exports.assertLiteral = assertLiteral; -exports.assertLogicalExpression = assertLogicalExpression; -exports.assertLoop = assertLoop; -exports.assertMemberExpression = assertMemberExpression; -exports.assertMetaProperty = assertMetaProperty; -exports.assertMethod = assertMethod; -exports.assertMiscellaneous = assertMiscellaneous; -exports.assertMixedTypeAnnotation = assertMixedTypeAnnotation; -exports.assertModuleDeclaration = assertModuleDeclaration; -exports.assertModuleExpression = assertModuleExpression; -exports.assertModuleSpecifier = assertModuleSpecifier; -exports.assertNewExpression = assertNewExpression; -exports.assertNoop = assertNoop; -exports.assertNullLiteral = assertNullLiteral; -exports.assertNullLiteralTypeAnnotation = assertNullLiteralTypeAnnotation; -exports.assertNullableTypeAnnotation = assertNullableTypeAnnotation; -exports.assertNumberLiteral = assertNumberLiteral; -exports.assertNumberLiteralTypeAnnotation = assertNumberLiteralTypeAnnotation; -exports.assertNumberTypeAnnotation = assertNumberTypeAnnotation; -exports.assertNumericLiteral = assertNumericLiteral; -exports.assertObjectExpression = assertObjectExpression; -exports.assertObjectMember = assertObjectMember; -exports.assertObjectMethod = assertObjectMethod; -exports.assertObjectPattern = assertObjectPattern; -exports.assertObjectProperty = assertObjectProperty; -exports.assertObjectTypeAnnotation = assertObjectTypeAnnotation; -exports.assertObjectTypeCallProperty = assertObjectTypeCallProperty; -exports.assertObjectTypeIndexer = assertObjectTypeIndexer; -exports.assertObjectTypeInternalSlot = assertObjectTypeInternalSlot; -exports.assertObjectTypeProperty = assertObjectTypeProperty; -exports.assertObjectTypeSpreadProperty = assertObjectTypeSpreadProperty; -exports.assertOpaqueType = assertOpaqueType; -exports.assertOptionalCallExpression = assertOptionalCallExpression; -exports.assertOptionalIndexedAccessType = assertOptionalIndexedAccessType; -exports.assertOptionalMemberExpression = assertOptionalMemberExpression; -exports.assertParenthesizedExpression = assertParenthesizedExpression; -exports.assertPattern = assertPattern; -exports.assertPatternLike = assertPatternLike; -exports.assertPipelineBareFunction = assertPipelineBareFunction; -exports.assertPipelinePrimaryTopicReference = assertPipelinePrimaryTopicReference; -exports.assertPipelineTopicExpression = assertPipelineTopicExpression; -exports.assertPlaceholder = assertPlaceholder; -exports.assertPrivate = assertPrivate; -exports.assertPrivateName = assertPrivateName; -exports.assertProgram = assertProgram; -exports.assertProperty = assertProperty; -exports.assertPureish = assertPureish; -exports.assertQualifiedTypeIdentifier = assertQualifiedTypeIdentifier; -exports.assertRecordExpression = assertRecordExpression; -exports.assertRegExpLiteral = assertRegExpLiteral; -exports.assertRegexLiteral = assertRegexLiteral; -exports.assertRestElement = assertRestElement; -exports.assertRestProperty = assertRestProperty; -exports.assertReturnStatement = assertReturnStatement; -exports.assertScopable = assertScopable; -exports.assertSequenceExpression = assertSequenceExpression; -exports.assertSpreadElement = assertSpreadElement; -exports.assertSpreadProperty = assertSpreadProperty; -exports.assertStandardized = assertStandardized; -exports.assertStatement = assertStatement; -exports.assertStaticBlock = assertStaticBlock; -exports.assertStringLiteral = assertStringLiteral; -exports.assertStringLiteralTypeAnnotation = assertStringLiteralTypeAnnotation; -exports.assertStringTypeAnnotation = assertStringTypeAnnotation; -exports.assertSuper = assertSuper; -exports.assertSwitchCase = assertSwitchCase; -exports.assertSwitchStatement = assertSwitchStatement; -exports.assertSymbolTypeAnnotation = assertSymbolTypeAnnotation; -exports.assertTSAnyKeyword = assertTSAnyKeyword; -exports.assertTSArrayType = assertTSArrayType; -exports.assertTSAsExpression = assertTSAsExpression; -exports.assertTSBaseType = assertTSBaseType; -exports.assertTSBigIntKeyword = assertTSBigIntKeyword; -exports.assertTSBooleanKeyword = assertTSBooleanKeyword; -exports.assertTSCallSignatureDeclaration = assertTSCallSignatureDeclaration; -exports.assertTSConditionalType = assertTSConditionalType; -exports.assertTSConstructSignatureDeclaration = assertTSConstructSignatureDeclaration; -exports.assertTSConstructorType = assertTSConstructorType; -exports.assertTSDeclareFunction = assertTSDeclareFunction; -exports.assertTSDeclareMethod = assertTSDeclareMethod; -exports.assertTSEntityName = assertTSEntityName; -exports.assertTSEnumDeclaration = assertTSEnumDeclaration; -exports.assertTSEnumMember = assertTSEnumMember; -exports.assertTSExportAssignment = assertTSExportAssignment; -exports.assertTSExpressionWithTypeArguments = assertTSExpressionWithTypeArguments; -exports.assertTSExternalModuleReference = assertTSExternalModuleReference; -exports.assertTSFunctionType = assertTSFunctionType; -exports.assertTSImportEqualsDeclaration = assertTSImportEqualsDeclaration; -exports.assertTSImportType = assertTSImportType; -exports.assertTSIndexSignature = assertTSIndexSignature; -exports.assertTSIndexedAccessType = assertTSIndexedAccessType; -exports.assertTSInferType = assertTSInferType; -exports.assertTSInstantiationExpression = assertTSInstantiationExpression; -exports.assertTSInterfaceBody = assertTSInterfaceBody; -exports.assertTSInterfaceDeclaration = assertTSInterfaceDeclaration; -exports.assertTSIntersectionType = assertTSIntersectionType; -exports.assertTSIntrinsicKeyword = assertTSIntrinsicKeyword; -exports.assertTSLiteralType = assertTSLiteralType; -exports.assertTSMappedType = assertTSMappedType; -exports.assertTSMethodSignature = assertTSMethodSignature; -exports.assertTSModuleBlock = assertTSModuleBlock; -exports.assertTSModuleDeclaration = assertTSModuleDeclaration; -exports.assertTSNamedTupleMember = assertTSNamedTupleMember; -exports.assertTSNamespaceExportDeclaration = assertTSNamespaceExportDeclaration; -exports.assertTSNeverKeyword = assertTSNeverKeyword; -exports.assertTSNonNullExpression = assertTSNonNullExpression; -exports.assertTSNullKeyword = assertTSNullKeyword; -exports.assertTSNumberKeyword = assertTSNumberKeyword; -exports.assertTSObjectKeyword = assertTSObjectKeyword; -exports.assertTSOptionalType = assertTSOptionalType; -exports.assertTSParameterProperty = assertTSParameterProperty; -exports.assertTSParenthesizedType = assertTSParenthesizedType; -exports.assertTSPropertySignature = assertTSPropertySignature; -exports.assertTSQualifiedName = assertTSQualifiedName; -exports.assertTSRestType = assertTSRestType; -exports.assertTSSatisfiesExpression = assertTSSatisfiesExpression; -exports.assertTSStringKeyword = assertTSStringKeyword; -exports.assertTSSymbolKeyword = assertTSSymbolKeyword; -exports.assertTSThisType = assertTSThisType; -exports.assertTSTupleType = assertTSTupleType; -exports.assertTSType = assertTSType; -exports.assertTSTypeAliasDeclaration = assertTSTypeAliasDeclaration; -exports.assertTSTypeAnnotation = assertTSTypeAnnotation; -exports.assertTSTypeAssertion = assertTSTypeAssertion; -exports.assertTSTypeElement = assertTSTypeElement; -exports.assertTSTypeLiteral = assertTSTypeLiteral; -exports.assertTSTypeOperator = assertTSTypeOperator; -exports.assertTSTypeParameter = assertTSTypeParameter; -exports.assertTSTypeParameterDeclaration = assertTSTypeParameterDeclaration; -exports.assertTSTypeParameterInstantiation = assertTSTypeParameterInstantiation; -exports.assertTSTypePredicate = assertTSTypePredicate; -exports.assertTSTypeQuery = assertTSTypeQuery; -exports.assertTSTypeReference = assertTSTypeReference; -exports.assertTSUndefinedKeyword = assertTSUndefinedKeyword; -exports.assertTSUnionType = assertTSUnionType; -exports.assertTSUnknownKeyword = assertTSUnknownKeyword; -exports.assertTSVoidKeyword = assertTSVoidKeyword; -exports.assertTaggedTemplateExpression = assertTaggedTemplateExpression; -exports.assertTemplateElement = assertTemplateElement; -exports.assertTemplateLiteral = assertTemplateLiteral; -exports.assertTerminatorless = assertTerminatorless; -exports.assertThisExpression = assertThisExpression; -exports.assertThisTypeAnnotation = assertThisTypeAnnotation; -exports.assertThrowStatement = assertThrowStatement; -exports.assertTopicReference = assertTopicReference; -exports.assertTryStatement = assertTryStatement; -exports.assertTupleExpression = assertTupleExpression; -exports.assertTupleTypeAnnotation = assertTupleTypeAnnotation; -exports.assertTypeAlias = assertTypeAlias; -exports.assertTypeAnnotation = assertTypeAnnotation; -exports.assertTypeCastExpression = assertTypeCastExpression; -exports.assertTypeParameter = assertTypeParameter; -exports.assertTypeParameterDeclaration = assertTypeParameterDeclaration; -exports.assertTypeParameterInstantiation = assertTypeParameterInstantiation; -exports.assertTypeScript = assertTypeScript; -exports.assertTypeofTypeAnnotation = assertTypeofTypeAnnotation; -exports.assertUnaryExpression = assertUnaryExpression; -exports.assertUnaryLike = assertUnaryLike; -exports.assertUnionTypeAnnotation = assertUnionTypeAnnotation; -exports.assertUpdateExpression = assertUpdateExpression; -exports.assertUserWhitespacable = assertUserWhitespacable; -exports.assertV8IntrinsicIdentifier = assertV8IntrinsicIdentifier; -exports.assertVariableDeclaration = assertVariableDeclaration; -exports.assertVariableDeclarator = assertVariableDeclarator; -exports.assertVariance = assertVariance; -exports.assertVoidTypeAnnotation = assertVoidTypeAnnotation; -exports.assertWhile = assertWhile; -exports.assertWhileStatement = assertWhileStatement; -exports.assertWithStatement = assertWithStatement; -exports.assertYieldExpression = assertYieldExpression; -var _is = require("../../validators/is.js"); -var _deprecationWarning = require("../../utils/deprecationWarning.js"); -function assert(type, node, opts) { - if (!(0, _is.default)(type, node, opts)) { - throw new Error(`Expected type "${type}" with option ${JSON.stringify(opts)}, ` + `but instead got "${node.type}".`); - } -} -function assertArrayExpression(node, opts) { - assert("ArrayExpression", node, opts); -} -function assertAssignmentExpression(node, opts) { - assert("AssignmentExpression", node, opts); -} -function assertBinaryExpression(node, opts) { - assert("BinaryExpression", node, opts); -} -function assertInterpreterDirective(node, opts) { - assert("InterpreterDirective", node, opts); -} -function assertDirective(node, opts) { - assert("Directive", node, opts); -} -function assertDirectiveLiteral(node, opts) { - assert("DirectiveLiteral", node, opts); -} -function assertBlockStatement(node, opts) { - assert("BlockStatement", node, opts); -} -function assertBreakStatement(node, opts) { - assert("BreakStatement", node, opts); -} -function assertCallExpression(node, opts) { - assert("CallExpression", node, opts); -} -function assertCatchClause(node, opts) { - assert("CatchClause", node, opts); -} -function assertConditionalExpression(node, opts) { - assert("ConditionalExpression", node, opts); -} -function assertContinueStatement(node, opts) { - assert("ContinueStatement", node, opts); -} -function assertDebuggerStatement(node, opts) { - assert("DebuggerStatement", node, opts); -} -function assertDoWhileStatement(node, opts) { - assert("DoWhileStatement", node, opts); -} -function assertEmptyStatement(node, opts) { - assert("EmptyStatement", node, opts); -} -function assertExpressionStatement(node, opts) { - assert("ExpressionStatement", node, opts); -} -function assertFile(node, opts) { - assert("File", node, opts); -} -function assertForInStatement(node, opts) { - assert("ForInStatement", node, opts); -} -function assertForStatement(node, opts) { - assert("ForStatement", node, opts); -} -function assertFunctionDeclaration(node, opts) { - assert("FunctionDeclaration", node, opts); -} -function assertFunctionExpression(node, opts) { - assert("FunctionExpression", node, opts); -} -function assertIdentifier(node, opts) { - assert("Identifier", node, opts); -} -function assertIfStatement(node, opts) { - assert("IfStatement", node, opts); -} -function assertLabeledStatement(node, opts) { - assert("LabeledStatement", node, opts); -} -function assertStringLiteral(node, opts) { - assert("StringLiteral", node, opts); -} -function assertNumericLiteral(node, opts) { - assert("NumericLiteral", node, opts); -} -function assertNullLiteral(node, opts) { - assert("NullLiteral", node, opts); -} -function assertBooleanLiteral(node, opts) { - assert("BooleanLiteral", node, opts); -} -function assertRegExpLiteral(node, opts) { - assert("RegExpLiteral", node, opts); -} -function assertLogicalExpression(node, opts) { - assert("LogicalExpression", node, opts); -} -function assertMemberExpression(node, opts) { - assert("MemberExpression", node, opts); -} -function assertNewExpression(node, opts) { - assert("NewExpression", node, opts); -} -function assertProgram(node, opts) { - assert("Program", node, opts); -} -function assertObjectExpression(node, opts) { - assert("ObjectExpression", node, opts); -} -function assertObjectMethod(node, opts) { - assert("ObjectMethod", node, opts); -} -function assertObjectProperty(node, opts) { - assert("ObjectProperty", node, opts); -} -function assertRestElement(node, opts) { - assert("RestElement", node, opts); -} -function assertReturnStatement(node, opts) { - assert("ReturnStatement", node, opts); -} -function assertSequenceExpression(node, opts) { - assert("SequenceExpression", node, opts); -} -function assertParenthesizedExpression(node, opts) { - assert("ParenthesizedExpression", node, opts); -} -function assertSwitchCase(node, opts) { - assert("SwitchCase", node, opts); -} -function assertSwitchStatement(node, opts) { - assert("SwitchStatement", node, opts); -} -function assertThisExpression(node, opts) { - assert("ThisExpression", node, opts); -} -function assertThrowStatement(node, opts) { - assert("ThrowStatement", node, opts); -} -function assertTryStatement(node, opts) { - assert("TryStatement", node, opts); -} -function assertUnaryExpression(node, opts) { - assert("UnaryExpression", node, opts); -} -function assertUpdateExpression(node, opts) { - assert("UpdateExpression", node, opts); -} -function assertVariableDeclaration(node, opts) { - assert("VariableDeclaration", node, opts); -} -function assertVariableDeclarator(node, opts) { - assert("VariableDeclarator", node, opts); -} -function assertWhileStatement(node, opts) { - assert("WhileStatement", node, opts); -} -function assertWithStatement(node, opts) { - assert("WithStatement", node, opts); -} -function assertAssignmentPattern(node, opts) { - assert("AssignmentPattern", node, opts); -} -function assertArrayPattern(node, opts) { - assert("ArrayPattern", node, opts); -} -function assertArrowFunctionExpression(node, opts) { - assert("ArrowFunctionExpression", node, opts); -} -function assertClassBody(node, opts) { - assert("ClassBody", node, opts); -} -function assertClassExpression(node, opts) { - assert("ClassExpression", node, opts); -} -function assertClassDeclaration(node, opts) { - assert("ClassDeclaration", node, opts); -} -function assertExportAllDeclaration(node, opts) { - assert("ExportAllDeclaration", node, opts); -} -function assertExportDefaultDeclaration(node, opts) { - assert("ExportDefaultDeclaration", node, opts); -} -function assertExportNamedDeclaration(node, opts) { - assert("ExportNamedDeclaration", node, opts); -} -function assertExportSpecifier(node, opts) { - assert("ExportSpecifier", node, opts); -} -function assertForOfStatement(node, opts) { - assert("ForOfStatement", node, opts); -} -function assertImportDeclaration(node, opts) { - assert("ImportDeclaration", node, opts); -} -function assertImportDefaultSpecifier(node, opts) { - assert("ImportDefaultSpecifier", node, opts); -} -function assertImportNamespaceSpecifier(node, opts) { - assert("ImportNamespaceSpecifier", node, opts); -} -function assertImportSpecifier(node, opts) { - assert("ImportSpecifier", node, opts); -} -function assertImportExpression(node, opts) { - assert("ImportExpression", node, opts); -} -function assertMetaProperty(node, opts) { - assert("MetaProperty", node, opts); -} -function assertClassMethod(node, opts) { - assert("ClassMethod", node, opts); -} -function assertObjectPattern(node, opts) { - assert("ObjectPattern", node, opts); -} -function assertSpreadElement(node, opts) { - assert("SpreadElement", node, opts); -} -function assertSuper(node, opts) { - assert("Super", node, opts); -} -function assertTaggedTemplateExpression(node, opts) { - assert("TaggedTemplateExpression", node, opts); -} -function assertTemplateElement(node, opts) { - assert("TemplateElement", node, opts); -} -function assertTemplateLiteral(node, opts) { - assert("TemplateLiteral", node, opts); -} -function assertYieldExpression(node, opts) { - assert("YieldExpression", node, opts); -} -function assertAwaitExpression(node, opts) { - assert("AwaitExpression", node, opts); -} -function assertImport(node, opts) { - assert("Import", node, opts); -} -function assertBigIntLiteral(node, opts) { - assert("BigIntLiteral", node, opts); -} -function assertExportNamespaceSpecifier(node, opts) { - assert("ExportNamespaceSpecifier", node, opts); -} -function assertOptionalMemberExpression(node, opts) { - assert("OptionalMemberExpression", node, opts); -} -function assertOptionalCallExpression(node, opts) { - assert("OptionalCallExpression", node, opts); -} -function assertClassProperty(node, opts) { - assert("ClassProperty", node, opts); -} -function assertClassAccessorProperty(node, opts) { - assert("ClassAccessorProperty", node, opts); -} -function assertClassPrivateProperty(node, opts) { - assert("ClassPrivateProperty", node, opts); -} -function assertClassPrivateMethod(node, opts) { - assert("ClassPrivateMethod", node, opts); -} -function assertPrivateName(node, opts) { - assert("PrivateName", node, opts); -} -function assertStaticBlock(node, opts) { - assert("StaticBlock", node, opts); -} -function assertAnyTypeAnnotation(node, opts) { - assert("AnyTypeAnnotation", node, opts); -} -function assertArrayTypeAnnotation(node, opts) { - assert("ArrayTypeAnnotation", node, opts); -} -function assertBooleanTypeAnnotation(node, opts) { - assert("BooleanTypeAnnotation", node, opts); -} -function assertBooleanLiteralTypeAnnotation(node, opts) { - assert("BooleanLiteralTypeAnnotation", node, opts); -} -function assertNullLiteralTypeAnnotation(node, opts) { - assert("NullLiteralTypeAnnotation", node, opts); -} -function assertClassImplements(node, opts) { - assert("ClassImplements", node, opts); -} -function assertDeclareClass(node, opts) { - assert("DeclareClass", node, opts); -} -function assertDeclareFunction(node, opts) { - assert("DeclareFunction", node, opts); -} -function assertDeclareInterface(node, opts) { - assert("DeclareInterface", node, opts); -} -function assertDeclareModule(node, opts) { - assert("DeclareModule", node, opts); -} -function assertDeclareModuleExports(node, opts) { - assert("DeclareModuleExports", node, opts); -} -function assertDeclareTypeAlias(node, opts) { - assert("DeclareTypeAlias", node, opts); -} -function assertDeclareOpaqueType(node, opts) { - assert("DeclareOpaqueType", node, opts); -} -function assertDeclareVariable(node, opts) { - assert("DeclareVariable", node, opts); -} -function assertDeclareExportDeclaration(node, opts) { - assert("DeclareExportDeclaration", node, opts); -} -function assertDeclareExportAllDeclaration(node, opts) { - assert("DeclareExportAllDeclaration", node, opts); -} -function assertDeclaredPredicate(node, opts) { - assert("DeclaredPredicate", node, opts); -} -function assertExistsTypeAnnotation(node, opts) { - assert("ExistsTypeAnnotation", node, opts); -} -function assertFunctionTypeAnnotation(node, opts) { - assert("FunctionTypeAnnotation", node, opts); -} -function assertFunctionTypeParam(node, opts) { - assert("FunctionTypeParam", node, opts); -} -function assertGenericTypeAnnotation(node, opts) { - assert("GenericTypeAnnotation", node, opts); -} -function assertInferredPredicate(node, opts) { - assert("InferredPredicate", node, opts); -} -function assertInterfaceExtends(node, opts) { - assert("InterfaceExtends", node, opts); -} -function assertInterfaceDeclaration(node, opts) { - assert("InterfaceDeclaration", node, opts); -} -function assertInterfaceTypeAnnotation(node, opts) { - assert("InterfaceTypeAnnotation", node, opts); -} -function assertIntersectionTypeAnnotation(node, opts) { - assert("IntersectionTypeAnnotation", node, opts); -} -function assertMixedTypeAnnotation(node, opts) { - assert("MixedTypeAnnotation", node, opts); -} -function assertEmptyTypeAnnotation(node, opts) { - assert("EmptyTypeAnnotation", node, opts); -} -function assertNullableTypeAnnotation(node, opts) { - assert("NullableTypeAnnotation", node, opts); -} -function assertNumberLiteralTypeAnnotation(node, opts) { - assert("NumberLiteralTypeAnnotation", node, opts); -} -function assertNumberTypeAnnotation(node, opts) { - assert("NumberTypeAnnotation", node, opts); -} -function assertObjectTypeAnnotation(node, opts) { - assert("ObjectTypeAnnotation", node, opts); -} -function assertObjectTypeInternalSlot(node, opts) { - assert("ObjectTypeInternalSlot", node, opts); -} -function assertObjectTypeCallProperty(node, opts) { - assert("ObjectTypeCallProperty", node, opts); -} -function assertObjectTypeIndexer(node, opts) { - assert("ObjectTypeIndexer", node, opts); -} -function assertObjectTypeProperty(node, opts) { - assert("ObjectTypeProperty", node, opts); -} -function assertObjectTypeSpreadProperty(node, opts) { - assert("ObjectTypeSpreadProperty", node, opts); -} -function assertOpaqueType(node, opts) { - assert("OpaqueType", node, opts); -} -function assertQualifiedTypeIdentifier(node, opts) { - assert("QualifiedTypeIdentifier", node, opts); -} -function assertStringLiteralTypeAnnotation(node, opts) { - assert("StringLiteralTypeAnnotation", node, opts); -} -function assertStringTypeAnnotation(node, opts) { - assert("StringTypeAnnotation", node, opts); -} -function assertSymbolTypeAnnotation(node, opts) { - assert("SymbolTypeAnnotation", node, opts); -} -function assertThisTypeAnnotation(node, opts) { - assert("ThisTypeAnnotation", node, opts); -} -function assertTupleTypeAnnotation(node, opts) { - assert("TupleTypeAnnotation", node, opts); -} -function assertTypeofTypeAnnotation(node, opts) { - assert("TypeofTypeAnnotation", node, opts); -} -function assertTypeAlias(node, opts) { - assert("TypeAlias", node, opts); -} -function assertTypeAnnotation(node, opts) { - assert("TypeAnnotation", node, opts); -} -function assertTypeCastExpression(node, opts) { - assert("TypeCastExpression", node, opts); -} -function assertTypeParameter(node, opts) { - assert("TypeParameter", node, opts); -} -function assertTypeParameterDeclaration(node, opts) { - assert("TypeParameterDeclaration", node, opts); -} -function assertTypeParameterInstantiation(node, opts) { - assert("TypeParameterInstantiation", node, opts); -} -function assertUnionTypeAnnotation(node, opts) { - assert("UnionTypeAnnotation", node, opts); -} -function assertVariance(node, opts) { - assert("Variance", node, opts); -} -function assertVoidTypeAnnotation(node, opts) { - assert("VoidTypeAnnotation", node, opts); -} -function assertEnumDeclaration(node, opts) { - assert("EnumDeclaration", node, opts); -} -function assertEnumBooleanBody(node, opts) { - assert("EnumBooleanBody", node, opts); -} -function assertEnumNumberBody(node, opts) { - assert("EnumNumberBody", node, opts); -} -function assertEnumStringBody(node, opts) { - assert("EnumStringBody", node, opts); -} -function assertEnumSymbolBody(node, opts) { - assert("EnumSymbolBody", node, opts); -} -function assertEnumBooleanMember(node, opts) { - assert("EnumBooleanMember", node, opts); -} -function assertEnumNumberMember(node, opts) { - assert("EnumNumberMember", node, opts); -} -function assertEnumStringMember(node, opts) { - assert("EnumStringMember", node, opts); -} -function assertEnumDefaultedMember(node, opts) { - assert("EnumDefaultedMember", node, opts); -} -function assertIndexedAccessType(node, opts) { - assert("IndexedAccessType", node, opts); -} -function assertOptionalIndexedAccessType(node, opts) { - assert("OptionalIndexedAccessType", node, opts); -} -function assertJSXAttribute(node, opts) { - assert("JSXAttribute", node, opts); -} -function assertJSXClosingElement(node, opts) { - assert("JSXClosingElement", node, opts); -} -function assertJSXElement(node, opts) { - assert("JSXElement", node, opts); -} -function assertJSXEmptyExpression(node, opts) { - assert("JSXEmptyExpression", node, opts); -} -function assertJSXExpressionContainer(node, opts) { - assert("JSXExpressionContainer", node, opts); -} -function assertJSXSpreadChild(node, opts) { - assert("JSXSpreadChild", node, opts); -} -function assertJSXIdentifier(node, opts) { - assert("JSXIdentifier", node, opts); -} -function assertJSXMemberExpression(node, opts) { - assert("JSXMemberExpression", node, opts); -} -function assertJSXNamespacedName(node, opts) { - assert("JSXNamespacedName", node, opts); -} -function assertJSXOpeningElement(node, opts) { - assert("JSXOpeningElement", node, opts); -} -function assertJSXSpreadAttribute(node, opts) { - assert("JSXSpreadAttribute", node, opts); -} -function assertJSXText(node, opts) { - assert("JSXText", node, opts); -} -function assertJSXFragment(node, opts) { - assert("JSXFragment", node, opts); -} -function assertJSXOpeningFragment(node, opts) { - assert("JSXOpeningFragment", node, opts); -} -function assertJSXClosingFragment(node, opts) { - assert("JSXClosingFragment", node, opts); -} -function assertNoop(node, opts) { - assert("Noop", node, opts); -} -function assertPlaceholder(node, opts) { - assert("Placeholder", node, opts); -} -function assertV8IntrinsicIdentifier(node, opts) { - assert("V8IntrinsicIdentifier", node, opts); -} -function assertArgumentPlaceholder(node, opts) { - assert("ArgumentPlaceholder", node, opts); -} -function assertBindExpression(node, opts) { - assert("BindExpression", node, opts); -} -function assertImportAttribute(node, opts) { - assert("ImportAttribute", node, opts); -} -function assertDecorator(node, opts) { - assert("Decorator", node, opts); -} -function assertDoExpression(node, opts) { - assert("DoExpression", node, opts); -} -function assertExportDefaultSpecifier(node, opts) { - assert("ExportDefaultSpecifier", node, opts); -} -function assertRecordExpression(node, opts) { - assert("RecordExpression", node, opts); -} -function assertTupleExpression(node, opts) { - assert("TupleExpression", node, opts); -} -function assertDecimalLiteral(node, opts) { - assert("DecimalLiteral", node, opts); -} -function assertModuleExpression(node, opts) { - assert("ModuleExpression", node, opts); -} -function assertTopicReference(node, opts) { - assert("TopicReference", node, opts); -} -function assertPipelineTopicExpression(node, opts) { - assert("PipelineTopicExpression", node, opts); -} -function assertPipelineBareFunction(node, opts) { - assert("PipelineBareFunction", node, opts); -} -function assertPipelinePrimaryTopicReference(node, opts) { - assert("PipelinePrimaryTopicReference", node, opts); -} -function assertTSParameterProperty(node, opts) { - assert("TSParameterProperty", node, opts); -} -function assertTSDeclareFunction(node, opts) { - assert("TSDeclareFunction", node, opts); -} -function assertTSDeclareMethod(node, opts) { - assert("TSDeclareMethod", node, opts); -} -function assertTSQualifiedName(node, opts) { - assert("TSQualifiedName", node, opts); -} -function assertTSCallSignatureDeclaration(node, opts) { - assert("TSCallSignatureDeclaration", node, opts); -} -function assertTSConstructSignatureDeclaration(node, opts) { - assert("TSConstructSignatureDeclaration", node, opts); -} -function assertTSPropertySignature(node, opts) { - assert("TSPropertySignature", node, opts); -} -function assertTSMethodSignature(node, opts) { - assert("TSMethodSignature", node, opts); -} -function assertTSIndexSignature(node, opts) { - assert("TSIndexSignature", node, opts); -} -function assertTSAnyKeyword(node, opts) { - assert("TSAnyKeyword", node, opts); -} -function assertTSBooleanKeyword(node, opts) { - assert("TSBooleanKeyword", node, opts); -} -function assertTSBigIntKeyword(node, opts) { - assert("TSBigIntKeyword", node, opts); -} -function assertTSIntrinsicKeyword(node, opts) { - assert("TSIntrinsicKeyword", node, opts); -} -function assertTSNeverKeyword(node, opts) { - assert("TSNeverKeyword", node, opts); -} -function assertTSNullKeyword(node, opts) { - assert("TSNullKeyword", node, opts); -} -function assertTSNumberKeyword(node, opts) { - assert("TSNumberKeyword", node, opts); -} -function assertTSObjectKeyword(node, opts) { - assert("TSObjectKeyword", node, opts); -} -function assertTSStringKeyword(node, opts) { - assert("TSStringKeyword", node, opts); -} -function assertTSSymbolKeyword(node, opts) { - assert("TSSymbolKeyword", node, opts); -} -function assertTSUndefinedKeyword(node, opts) { - assert("TSUndefinedKeyword", node, opts); -} -function assertTSUnknownKeyword(node, opts) { - assert("TSUnknownKeyword", node, opts); -} -function assertTSVoidKeyword(node, opts) { - assert("TSVoidKeyword", node, opts); -} -function assertTSThisType(node, opts) { - assert("TSThisType", node, opts); -} -function assertTSFunctionType(node, opts) { - assert("TSFunctionType", node, opts); -} -function assertTSConstructorType(node, opts) { - assert("TSConstructorType", node, opts); -} -function assertTSTypeReference(node, opts) { - assert("TSTypeReference", node, opts); -} -function assertTSTypePredicate(node, opts) { - assert("TSTypePredicate", node, opts); -} -function assertTSTypeQuery(node, opts) { - assert("TSTypeQuery", node, opts); -} -function assertTSTypeLiteral(node, opts) { - assert("TSTypeLiteral", node, opts); -} -function assertTSArrayType(node, opts) { - assert("TSArrayType", node, opts); -} -function assertTSTupleType(node, opts) { - assert("TSTupleType", node, opts); -} -function assertTSOptionalType(node, opts) { - assert("TSOptionalType", node, opts); -} -function assertTSRestType(node, opts) { - assert("TSRestType", node, opts); -} -function assertTSNamedTupleMember(node, opts) { - assert("TSNamedTupleMember", node, opts); -} -function assertTSUnionType(node, opts) { - assert("TSUnionType", node, opts); -} -function assertTSIntersectionType(node, opts) { - assert("TSIntersectionType", node, opts); -} -function assertTSConditionalType(node, opts) { - assert("TSConditionalType", node, opts); -} -function assertTSInferType(node, opts) { - assert("TSInferType", node, opts); -} -function assertTSParenthesizedType(node, opts) { - assert("TSParenthesizedType", node, opts); -} -function assertTSTypeOperator(node, opts) { - assert("TSTypeOperator", node, opts); -} -function assertTSIndexedAccessType(node, opts) { - assert("TSIndexedAccessType", node, opts); -} -function assertTSMappedType(node, opts) { - assert("TSMappedType", node, opts); -} -function assertTSLiteralType(node, opts) { - assert("TSLiteralType", node, opts); -} -function assertTSExpressionWithTypeArguments(node, opts) { - assert("TSExpressionWithTypeArguments", node, opts); -} -function assertTSInterfaceDeclaration(node, opts) { - assert("TSInterfaceDeclaration", node, opts); -} -function assertTSInterfaceBody(node, opts) { - assert("TSInterfaceBody", node, opts); -} -function assertTSTypeAliasDeclaration(node, opts) { - assert("TSTypeAliasDeclaration", node, opts); -} -function assertTSInstantiationExpression(node, opts) { - assert("TSInstantiationExpression", node, opts); -} -function assertTSAsExpression(node, opts) { - assert("TSAsExpression", node, opts); -} -function assertTSSatisfiesExpression(node, opts) { - assert("TSSatisfiesExpression", node, opts); -} -function assertTSTypeAssertion(node, opts) { - assert("TSTypeAssertion", node, opts); -} -function assertTSEnumDeclaration(node, opts) { - assert("TSEnumDeclaration", node, opts); -} -function assertTSEnumMember(node, opts) { - assert("TSEnumMember", node, opts); -} -function assertTSModuleDeclaration(node, opts) { - assert("TSModuleDeclaration", node, opts); -} -function assertTSModuleBlock(node, opts) { - assert("TSModuleBlock", node, opts); -} -function assertTSImportType(node, opts) { - assert("TSImportType", node, opts); -} -function assertTSImportEqualsDeclaration(node, opts) { - assert("TSImportEqualsDeclaration", node, opts); -} -function assertTSExternalModuleReference(node, opts) { - assert("TSExternalModuleReference", node, opts); -} -function assertTSNonNullExpression(node, opts) { - assert("TSNonNullExpression", node, opts); -} -function assertTSExportAssignment(node, opts) { - assert("TSExportAssignment", node, opts); -} -function assertTSNamespaceExportDeclaration(node, opts) { - assert("TSNamespaceExportDeclaration", node, opts); -} -function assertTSTypeAnnotation(node, opts) { - assert("TSTypeAnnotation", node, opts); -} -function assertTSTypeParameterInstantiation(node, opts) { - assert("TSTypeParameterInstantiation", node, opts); -} -function assertTSTypeParameterDeclaration(node, opts) { - assert("TSTypeParameterDeclaration", node, opts); -} -function assertTSTypeParameter(node, opts) { - assert("TSTypeParameter", node, opts); -} -function assertStandardized(node, opts) { - assert("Standardized", node, opts); -} -function assertExpression(node, opts) { - assert("Expression", node, opts); -} -function assertBinary(node, opts) { - assert("Binary", node, opts); -} -function assertScopable(node, opts) { - assert("Scopable", node, opts); -} -function assertBlockParent(node, opts) { - assert("BlockParent", node, opts); -} -function assertBlock(node, opts) { - assert("Block", node, opts); -} -function assertStatement(node, opts) { - assert("Statement", node, opts); -} -function assertTerminatorless(node, opts) { - assert("Terminatorless", node, opts); -} -function assertCompletionStatement(node, opts) { - assert("CompletionStatement", node, opts); -} -function assertConditional(node, opts) { - assert("Conditional", node, opts); -} -function assertLoop(node, opts) { - assert("Loop", node, opts); -} -function assertWhile(node, opts) { - assert("While", node, opts); -} -function assertExpressionWrapper(node, opts) { - assert("ExpressionWrapper", node, opts); -} -function assertFor(node, opts) { - assert("For", node, opts); -} -function assertForXStatement(node, opts) { - assert("ForXStatement", node, opts); -} -function assertFunction(node, opts) { - assert("Function", node, opts); -} -function assertFunctionParent(node, opts) { - assert("FunctionParent", node, opts); -} -function assertPureish(node, opts) { - assert("Pureish", node, opts); -} -function assertDeclaration(node, opts) { - assert("Declaration", node, opts); -} -function assertPatternLike(node, opts) { - assert("PatternLike", node, opts); -} -function assertLVal(node, opts) { - assert("LVal", node, opts); -} -function assertTSEntityName(node, opts) { - assert("TSEntityName", node, opts); -} -function assertLiteral(node, opts) { - assert("Literal", node, opts); -} -function assertImmutable(node, opts) { - assert("Immutable", node, opts); -} -function assertUserWhitespacable(node, opts) { - assert("UserWhitespacable", node, opts); -} -function assertMethod(node, opts) { - assert("Method", node, opts); -} -function assertObjectMember(node, opts) { - assert("ObjectMember", node, opts); -} -function assertProperty(node, opts) { - assert("Property", node, opts); -} -function assertUnaryLike(node, opts) { - assert("UnaryLike", node, opts); -} -function assertPattern(node, opts) { - assert("Pattern", node, opts); -} -function assertClass(node, opts) { - assert("Class", node, opts); -} -function assertImportOrExportDeclaration(node, opts) { - assert("ImportOrExportDeclaration", node, opts); -} -function assertExportDeclaration(node, opts) { - assert("ExportDeclaration", node, opts); -} -function assertModuleSpecifier(node, opts) { - assert("ModuleSpecifier", node, opts); -} -function assertAccessor(node, opts) { - assert("Accessor", node, opts); -} -function assertPrivate(node, opts) { - assert("Private", node, opts); -} -function assertFlow(node, opts) { - assert("Flow", node, opts); -} -function assertFlowType(node, opts) { - assert("FlowType", node, opts); -} -function assertFlowBaseAnnotation(node, opts) { - assert("FlowBaseAnnotation", node, opts); -} -function assertFlowDeclaration(node, opts) { - assert("FlowDeclaration", node, opts); -} -function assertFlowPredicate(node, opts) { - assert("FlowPredicate", node, opts); -} -function assertEnumBody(node, opts) { - assert("EnumBody", node, opts); -} -function assertEnumMember(node, opts) { - assert("EnumMember", node, opts); -} -function assertJSX(node, opts) { - assert("JSX", node, opts); -} -function assertMiscellaneous(node, opts) { - assert("Miscellaneous", node, opts); -} -function assertTypeScript(node, opts) { - assert("TypeScript", node, opts); -} -function assertTSTypeElement(node, opts) { - assert("TSTypeElement", node, opts); -} -function assertTSType(node, opts) { - assert("TSType", node, opts); -} -function assertTSBaseType(node, opts) { - assert("TSBaseType", node, opts); -} -function assertNumberLiteral(node, opts) { - (0, _deprecationWarning.default)("assertNumberLiteral", "assertNumericLiteral"); - assert("NumberLiteral", node, opts); -} -function assertRegexLiteral(node, opts) { - (0, _deprecationWarning.default)("assertRegexLiteral", "assertRegExpLiteral"); - assert("RegexLiteral", node, opts); -} -function assertRestProperty(node, opts) { - (0, _deprecationWarning.default)("assertRestProperty", "assertRestElement"); - assert("RestProperty", node, opts); -} -function assertSpreadProperty(node, opts) { - (0, _deprecationWarning.default)("assertSpreadProperty", "assertSpreadElement"); - assert("SpreadProperty", node, opts); -} -function assertModuleDeclaration(node, opts) { - (0, _deprecationWarning.default)("assertModuleDeclaration", "assertImportOrExportDeclaration"); - assert("ModuleDeclaration", node, opts); -} - -//# sourceMappingURL=index.js.map diff --git a/tools/eslint/node_modules/@babel/types/lib/ast-types/generated/index.js b/tools/eslint/node_modules/@babel/types/lib/ast-types/generated/index.js deleted file mode 100644 index d48e85e41dece3..00000000000000 --- a/tools/eslint/node_modules/@babel/types/lib/ast-types/generated/index.js +++ /dev/null @@ -1,3 +0,0 @@ - - -//# sourceMappingURL=index.js.map diff --git a/tools/eslint/node_modules/@babel/types/lib/builders/flow/createFlowUnionType.js b/tools/eslint/node_modules/@babel/types/lib/builders/flow/createFlowUnionType.js deleted file mode 100644 index b6848a03b08025..00000000000000 --- a/tools/eslint/node_modules/@babel/types/lib/builders/flow/createFlowUnionType.js +++ /dev/null @@ -1,18 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.default = createFlowUnionType; -var _index = require("../generated/index.js"); -var _removeTypeDuplicates = require("../../modifications/flow/removeTypeDuplicates.js"); -function createFlowUnionType(types) { - const flattened = (0, _removeTypeDuplicates.default)(types); - if (flattened.length === 1) { - return flattened[0]; - } else { - return (0, _index.unionTypeAnnotation)(flattened); - } -} - -//# sourceMappingURL=createFlowUnionType.js.map diff --git a/tools/eslint/node_modules/@babel/types/lib/builders/flow/createTypeAnnotationBasedOnTypeof.js b/tools/eslint/node_modules/@babel/types/lib/builders/flow/createTypeAnnotationBasedOnTypeof.js deleted file mode 100644 index 79d58becbb40e6..00000000000000 --- a/tools/eslint/node_modules/@babel/types/lib/builders/flow/createTypeAnnotationBasedOnTypeof.js +++ /dev/null @@ -1,31 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.default = void 0; -var _index = require("../generated/index.js"); -var _default = exports.default = createTypeAnnotationBasedOnTypeof; -function createTypeAnnotationBasedOnTypeof(type) { - switch (type) { - case "string": - return (0, _index.stringTypeAnnotation)(); - case "number": - return (0, _index.numberTypeAnnotation)(); - case "undefined": - return (0, _index.voidTypeAnnotation)(); - case "boolean": - return (0, _index.booleanTypeAnnotation)(); - case "function": - return (0, _index.genericTypeAnnotation)((0, _index.identifier)("Function")); - case "object": - return (0, _index.genericTypeAnnotation)((0, _index.identifier)("Object")); - case "symbol": - return (0, _index.genericTypeAnnotation)((0, _index.identifier)("Symbol")); - case "bigint": - return (0, _index.anyTypeAnnotation)(); - } - throw new Error("Invalid typeof value: " + type); -} - -//# sourceMappingURL=createTypeAnnotationBasedOnTypeof.js.map diff --git a/tools/eslint/node_modules/@babel/types/lib/builders/generated/index.js b/tools/eslint/node_modules/@babel/types/lib/builders/generated/index.js deleted file mode 100644 index 17c4239d2fb4b6..00000000000000 --- a/tools/eslint/node_modules/@babel/types/lib/builders/generated/index.js +++ /dev/null @@ -1,1991 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.anyTypeAnnotation = anyTypeAnnotation; -exports.argumentPlaceholder = argumentPlaceholder; -exports.arrayExpression = arrayExpression; -exports.arrayPattern = arrayPattern; -exports.arrayTypeAnnotation = arrayTypeAnnotation; -exports.arrowFunctionExpression = arrowFunctionExpression; -exports.assignmentExpression = assignmentExpression; -exports.assignmentPattern = assignmentPattern; -exports.awaitExpression = awaitExpression; -exports.bigIntLiteral = bigIntLiteral; -exports.binaryExpression = binaryExpression; -exports.bindExpression = bindExpression; -exports.blockStatement = blockStatement; -exports.booleanLiteral = booleanLiteral; -exports.booleanLiteralTypeAnnotation = booleanLiteralTypeAnnotation; -exports.booleanTypeAnnotation = booleanTypeAnnotation; -exports.breakStatement = breakStatement; -exports.callExpression = callExpression; -exports.catchClause = catchClause; -exports.classAccessorProperty = classAccessorProperty; -exports.classBody = classBody; -exports.classDeclaration = classDeclaration; -exports.classExpression = classExpression; -exports.classImplements = classImplements; -exports.classMethod = classMethod; -exports.classPrivateMethod = classPrivateMethod; -exports.classPrivateProperty = classPrivateProperty; -exports.classProperty = classProperty; -exports.conditionalExpression = conditionalExpression; -exports.continueStatement = continueStatement; -exports.debuggerStatement = debuggerStatement; -exports.decimalLiteral = decimalLiteral; -exports.declareClass = declareClass; -exports.declareExportAllDeclaration = declareExportAllDeclaration; -exports.declareExportDeclaration = declareExportDeclaration; -exports.declareFunction = declareFunction; -exports.declareInterface = declareInterface; -exports.declareModule = declareModule; -exports.declareModuleExports = declareModuleExports; -exports.declareOpaqueType = declareOpaqueType; -exports.declareTypeAlias = declareTypeAlias; -exports.declareVariable = declareVariable; -exports.declaredPredicate = declaredPredicate; -exports.decorator = decorator; -exports.directive = directive; -exports.directiveLiteral = directiveLiteral; -exports.doExpression = doExpression; -exports.doWhileStatement = doWhileStatement; -exports.emptyStatement = emptyStatement; -exports.emptyTypeAnnotation = emptyTypeAnnotation; -exports.enumBooleanBody = enumBooleanBody; -exports.enumBooleanMember = enumBooleanMember; -exports.enumDeclaration = enumDeclaration; -exports.enumDefaultedMember = enumDefaultedMember; -exports.enumNumberBody = enumNumberBody; -exports.enumNumberMember = enumNumberMember; -exports.enumStringBody = enumStringBody; -exports.enumStringMember = enumStringMember; -exports.enumSymbolBody = enumSymbolBody; -exports.existsTypeAnnotation = existsTypeAnnotation; -exports.exportAllDeclaration = exportAllDeclaration; -exports.exportDefaultDeclaration = exportDefaultDeclaration; -exports.exportDefaultSpecifier = exportDefaultSpecifier; -exports.exportNamedDeclaration = exportNamedDeclaration; -exports.exportNamespaceSpecifier = exportNamespaceSpecifier; -exports.exportSpecifier = exportSpecifier; -exports.expressionStatement = expressionStatement; -exports.file = file; -exports.forInStatement = forInStatement; -exports.forOfStatement = forOfStatement; -exports.forStatement = forStatement; -exports.functionDeclaration = functionDeclaration; -exports.functionExpression = functionExpression; -exports.functionTypeAnnotation = functionTypeAnnotation; -exports.functionTypeParam = functionTypeParam; -exports.genericTypeAnnotation = genericTypeAnnotation; -exports.identifier = identifier; -exports.ifStatement = ifStatement; -exports.import = _import; -exports.importAttribute = importAttribute; -exports.importDeclaration = importDeclaration; -exports.importDefaultSpecifier = importDefaultSpecifier; -exports.importExpression = importExpression; -exports.importNamespaceSpecifier = importNamespaceSpecifier; -exports.importSpecifier = importSpecifier; -exports.indexedAccessType = indexedAccessType; -exports.inferredPredicate = inferredPredicate; -exports.interfaceDeclaration = interfaceDeclaration; -exports.interfaceExtends = interfaceExtends; -exports.interfaceTypeAnnotation = interfaceTypeAnnotation; -exports.interpreterDirective = interpreterDirective; -exports.intersectionTypeAnnotation = intersectionTypeAnnotation; -exports.jSXAttribute = exports.jsxAttribute = jsxAttribute; -exports.jSXClosingElement = exports.jsxClosingElement = jsxClosingElement; -exports.jSXClosingFragment = exports.jsxClosingFragment = jsxClosingFragment; -exports.jSXElement = exports.jsxElement = jsxElement; -exports.jSXEmptyExpression = exports.jsxEmptyExpression = jsxEmptyExpression; -exports.jSXExpressionContainer = exports.jsxExpressionContainer = jsxExpressionContainer; -exports.jSXFragment = exports.jsxFragment = jsxFragment; -exports.jSXIdentifier = exports.jsxIdentifier = jsxIdentifier; -exports.jSXMemberExpression = exports.jsxMemberExpression = jsxMemberExpression; -exports.jSXNamespacedName = exports.jsxNamespacedName = jsxNamespacedName; -exports.jSXOpeningElement = exports.jsxOpeningElement = jsxOpeningElement; -exports.jSXOpeningFragment = exports.jsxOpeningFragment = jsxOpeningFragment; -exports.jSXSpreadAttribute = exports.jsxSpreadAttribute = jsxSpreadAttribute; -exports.jSXSpreadChild = exports.jsxSpreadChild = jsxSpreadChild; -exports.jSXText = exports.jsxText = jsxText; -exports.labeledStatement = labeledStatement; -exports.logicalExpression = logicalExpression; -exports.memberExpression = memberExpression; -exports.metaProperty = metaProperty; -exports.mixedTypeAnnotation = mixedTypeAnnotation; -exports.moduleExpression = moduleExpression; -exports.newExpression = newExpression; -exports.noop = noop; -exports.nullLiteral = nullLiteral; -exports.nullLiteralTypeAnnotation = nullLiteralTypeAnnotation; -exports.nullableTypeAnnotation = nullableTypeAnnotation; -exports.numberLiteral = NumberLiteral; -exports.numberLiteralTypeAnnotation = numberLiteralTypeAnnotation; -exports.numberTypeAnnotation = numberTypeAnnotation; -exports.numericLiteral = numericLiteral; -exports.objectExpression = objectExpression; -exports.objectMethod = objectMethod; -exports.objectPattern = objectPattern; -exports.objectProperty = objectProperty; -exports.objectTypeAnnotation = objectTypeAnnotation; -exports.objectTypeCallProperty = objectTypeCallProperty; -exports.objectTypeIndexer = objectTypeIndexer; -exports.objectTypeInternalSlot = objectTypeInternalSlot; -exports.objectTypeProperty = objectTypeProperty; -exports.objectTypeSpreadProperty = objectTypeSpreadProperty; -exports.opaqueType = opaqueType; -exports.optionalCallExpression = optionalCallExpression; -exports.optionalIndexedAccessType = optionalIndexedAccessType; -exports.optionalMemberExpression = optionalMemberExpression; -exports.parenthesizedExpression = parenthesizedExpression; -exports.pipelineBareFunction = pipelineBareFunction; -exports.pipelinePrimaryTopicReference = pipelinePrimaryTopicReference; -exports.pipelineTopicExpression = pipelineTopicExpression; -exports.placeholder = placeholder; -exports.privateName = privateName; -exports.program = program; -exports.qualifiedTypeIdentifier = qualifiedTypeIdentifier; -exports.recordExpression = recordExpression; -exports.regExpLiteral = regExpLiteral; -exports.regexLiteral = RegexLiteral; -exports.restElement = restElement; -exports.restProperty = RestProperty; -exports.returnStatement = returnStatement; -exports.sequenceExpression = sequenceExpression; -exports.spreadElement = spreadElement; -exports.spreadProperty = SpreadProperty; -exports.staticBlock = staticBlock; -exports.stringLiteral = stringLiteral; -exports.stringLiteralTypeAnnotation = stringLiteralTypeAnnotation; -exports.stringTypeAnnotation = stringTypeAnnotation; -exports.super = _super; -exports.switchCase = switchCase; -exports.switchStatement = switchStatement; -exports.symbolTypeAnnotation = symbolTypeAnnotation; -exports.taggedTemplateExpression = taggedTemplateExpression; -exports.templateElement = templateElement; -exports.templateLiteral = templateLiteral; -exports.thisExpression = thisExpression; -exports.thisTypeAnnotation = thisTypeAnnotation; -exports.throwStatement = throwStatement; -exports.topicReference = topicReference; -exports.tryStatement = tryStatement; -exports.tSAnyKeyword = exports.tsAnyKeyword = tsAnyKeyword; -exports.tSArrayType = exports.tsArrayType = tsArrayType; -exports.tSAsExpression = exports.tsAsExpression = tsAsExpression; -exports.tSBigIntKeyword = exports.tsBigIntKeyword = tsBigIntKeyword; -exports.tSBooleanKeyword = exports.tsBooleanKeyword = tsBooleanKeyword; -exports.tSCallSignatureDeclaration = exports.tsCallSignatureDeclaration = tsCallSignatureDeclaration; -exports.tSConditionalType = exports.tsConditionalType = tsConditionalType; -exports.tSConstructSignatureDeclaration = exports.tsConstructSignatureDeclaration = tsConstructSignatureDeclaration; -exports.tSConstructorType = exports.tsConstructorType = tsConstructorType; -exports.tSDeclareFunction = exports.tsDeclareFunction = tsDeclareFunction; -exports.tSDeclareMethod = exports.tsDeclareMethod = tsDeclareMethod; -exports.tSEnumDeclaration = exports.tsEnumDeclaration = tsEnumDeclaration; -exports.tSEnumMember = exports.tsEnumMember = tsEnumMember; -exports.tSExportAssignment = exports.tsExportAssignment = tsExportAssignment; -exports.tSExpressionWithTypeArguments = exports.tsExpressionWithTypeArguments = tsExpressionWithTypeArguments; -exports.tSExternalModuleReference = exports.tsExternalModuleReference = tsExternalModuleReference; -exports.tSFunctionType = exports.tsFunctionType = tsFunctionType; -exports.tSImportEqualsDeclaration = exports.tsImportEqualsDeclaration = tsImportEqualsDeclaration; -exports.tSImportType = exports.tsImportType = tsImportType; -exports.tSIndexSignature = exports.tsIndexSignature = tsIndexSignature; -exports.tSIndexedAccessType = exports.tsIndexedAccessType = tsIndexedAccessType; -exports.tSInferType = exports.tsInferType = tsInferType; -exports.tSInstantiationExpression = exports.tsInstantiationExpression = tsInstantiationExpression; -exports.tSInterfaceBody = exports.tsInterfaceBody = tsInterfaceBody; -exports.tSInterfaceDeclaration = exports.tsInterfaceDeclaration = tsInterfaceDeclaration; -exports.tSIntersectionType = exports.tsIntersectionType = tsIntersectionType; -exports.tSIntrinsicKeyword = exports.tsIntrinsicKeyword = tsIntrinsicKeyword; -exports.tSLiteralType = exports.tsLiteralType = tsLiteralType; -exports.tSMappedType = exports.tsMappedType = tsMappedType; -exports.tSMethodSignature = exports.tsMethodSignature = tsMethodSignature; -exports.tSModuleBlock = exports.tsModuleBlock = tsModuleBlock; -exports.tSModuleDeclaration = exports.tsModuleDeclaration = tsModuleDeclaration; -exports.tSNamedTupleMember = exports.tsNamedTupleMember = tsNamedTupleMember; -exports.tSNamespaceExportDeclaration = exports.tsNamespaceExportDeclaration = tsNamespaceExportDeclaration; -exports.tSNeverKeyword = exports.tsNeverKeyword = tsNeverKeyword; -exports.tSNonNullExpression = exports.tsNonNullExpression = tsNonNullExpression; -exports.tSNullKeyword = exports.tsNullKeyword = tsNullKeyword; -exports.tSNumberKeyword = exports.tsNumberKeyword = tsNumberKeyword; -exports.tSObjectKeyword = exports.tsObjectKeyword = tsObjectKeyword; -exports.tSOptionalType = exports.tsOptionalType = tsOptionalType; -exports.tSParameterProperty = exports.tsParameterProperty = tsParameterProperty; -exports.tSParenthesizedType = exports.tsParenthesizedType = tsParenthesizedType; -exports.tSPropertySignature = exports.tsPropertySignature = tsPropertySignature; -exports.tSQualifiedName = exports.tsQualifiedName = tsQualifiedName; -exports.tSRestType = exports.tsRestType = tsRestType; -exports.tSSatisfiesExpression = exports.tsSatisfiesExpression = tsSatisfiesExpression; -exports.tSStringKeyword = exports.tsStringKeyword = tsStringKeyword; -exports.tSSymbolKeyword = exports.tsSymbolKeyword = tsSymbolKeyword; -exports.tSThisType = exports.tsThisType = tsThisType; -exports.tSTupleType = exports.tsTupleType = tsTupleType; -exports.tSTypeAliasDeclaration = exports.tsTypeAliasDeclaration = tsTypeAliasDeclaration; -exports.tSTypeAnnotation = exports.tsTypeAnnotation = tsTypeAnnotation; -exports.tSTypeAssertion = exports.tsTypeAssertion = tsTypeAssertion; -exports.tSTypeLiteral = exports.tsTypeLiteral = tsTypeLiteral; -exports.tSTypeOperator = exports.tsTypeOperator = tsTypeOperator; -exports.tSTypeParameter = exports.tsTypeParameter = tsTypeParameter; -exports.tSTypeParameterDeclaration = exports.tsTypeParameterDeclaration = tsTypeParameterDeclaration; -exports.tSTypeParameterInstantiation = exports.tsTypeParameterInstantiation = tsTypeParameterInstantiation; -exports.tSTypePredicate = exports.tsTypePredicate = tsTypePredicate; -exports.tSTypeQuery = exports.tsTypeQuery = tsTypeQuery; -exports.tSTypeReference = exports.tsTypeReference = tsTypeReference; -exports.tSUndefinedKeyword = exports.tsUndefinedKeyword = tsUndefinedKeyword; -exports.tSUnionType = exports.tsUnionType = tsUnionType; -exports.tSUnknownKeyword = exports.tsUnknownKeyword = tsUnknownKeyword; -exports.tSVoidKeyword = exports.tsVoidKeyword = tsVoidKeyword; -exports.tupleExpression = tupleExpression; -exports.tupleTypeAnnotation = tupleTypeAnnotation; -exports.typeAlias = typeAlias; -exports.typeAnnotation = typeAnnotation; -exports.typeCastExpression = typeCastExpression; -exports.typeParameter = typeParameter; -exports.typeParameterDeclaration = typeParameterDeclaration; -exports.typeParameterInstantiation = typeParameterInstantiation; -exports.typeofTypeAnnotation = typeofTypeAnnotation; -exports.unaryExpression = unaryExpression; -exports.unionTypeAnnotation = unionTypeAnnotation; -exports.updateExpression = updateExpression; -exports.v8IntrinsicIdentifier = v8IntrinsicIdentifier; -exports.variableDeclaration = variableDeclaration; -exports.variableDeclarator = variableDeclarator; -exports.variance = variance; -exports.voidTypeAnnotation = voidTypeAnnotation; -exports.whileStatement = whileStatement; -exports.withStatement = withStatement; -exports.yieldExpression = yieldExpression; -var _validateNode = require("../validateNode.js"); -var _deprecationWarning = require("../../utils/deprecationWarning.js"); -function arrayExpression(elements = []) { - return (0, _validateNode.default)({ - type: "ArrayExpression", - elements - }); -} -function assignmentExpression(operator, left, right) { - return (0, _validateNode.default)({ - type: "AssignmentExpression", - operator, - left, - right - }); -} -function binaryExpression(operator, left, right) { - return (0, _validateNode.default)({ - type: "BinaryExpression", - operator, - left, - right - }); -} -function interpreterDirective(value) { - return (0, _validateNode.default)({ - type: "InterpreterDirective", - value - }); -} -function directive(value) { - return (0, _validateNode.default)({ - type: "Directive", - value - }); -} -function directiveLiteral(value) { - return (0, _validateNode.default)({ - type: "DirectiveLiteral", - value - }); -} -function blockStatement(body, directives = []) { - return (0, _validateNode.default)({ - type: "BlockStatement", - body, - directives - }); -} -function breakStatement(label = null) { - return (0, _validateNode.default)({ - type: "BreakStatement", - label - }); -} -function callExpression(callee, _arguments) { - return (0, _validateNode.default)({ - type: "CallExpression", - callee, - arguments: _arguments - }); -} -function catchClause(param = null, body) { - return (0, _validateNode.default)({ - type: "CatchClause", - param, - body - }); -} -function conditionalExpression(test, consequent, alternate) { - return (0, _validateNode.default)({ - type: "ConditionalExpression", - test, - consequent, - alternate - }); -} -function continueStatement(label = null) { - return (0, _validateNode.default)({ - type: "ContinueStatement", - label - }); -} -function debuggerStatement() { - return { - type: "DebuggerStatement" - }; -} -function doWhileStatement(test, body) { - return (0, _validateNode.default)({ - type: "DoWhileStatement", - test, - body - }); -} -function emptyStatement() { - return { - type: "EmptyStatement" - }; -} -function expressionStatement(expression) { - return (0, _validateNode.default)({ - type: "ExpressionStatement", - expression - }); -} -function file(program, comments = null, tokens = null) { - return (0, _validateNode.default)({ - type: "File", - program, - comments, - tokens - }); -} -function forInStatement(left, right, body) { - return (0, _validateNode.default)({ - type: "ForInStatement", - left, - right, - body - }); -} -function forStatement(init = null, test = null, update = null, body) { - return (0, _validateNode.default)({ - type: "ForStatement", - init, - test, - update, - body - }); -} -function functionDeclaration(id = null, params, body, generator = false, async = false) { - return (0, _validateNode.default)({ - type: "FunctionDeclaration", - id, - params, - body, - generator, - async - }); -} -function functionExpression(id = null, params, body, generator = false, async = false) { - return (0, _validateNode.default)({ - type: "FunctionExpression", - id, - params, - body, - generator, - async - }); -} -function identifier(name) { - return (0, _validateNode.default)({ - type: "Identifier", - name - }); -} -function ifStatement(test, consequent, alternate = null) { - return (0, _validateNode.default)({ - type: "IfStatement", - test, - consequent, - alternate - }); -} -function labeledStatement(label, body) { - return (0, _validateNode.default)({ - type: "LabeledStatement", - label, - body - }); -} -function stringLiteral(value) { - return (0, _validateNode.default)({ - type: "StringLiteral", - value - }); -} -function numericLiteral(value) { - return (0, _validateNode.default)({ - type: "NumericLiteral", - value - }); -} -function nullLiteral() { - return { - type: "NullLiteral" - }; -} -function booleanLiteral(value) { - return (0, _validateNode.default)({ - type: "BooleanLiteral", - value - }); -} -function regExpLiteral(pattern, flags = "") { - return (0, _validateNode.default)({ - type: "RegExpLiteral", - pattern, - flags - }); -} -function logicalExpression(operator, left, right) { - return (0, _validateNode.default)({ - type: "LogicalExpression", - operator, - left, - right - }); -} -function memberExpression(object, property, computed = false, optional = null) { - return (0, _validateNode.default)({ - type: "MemberExpression", - object, - property, - computed, - optional - }); -} -function newExpression(callee, _arguments) { - return (0, _validateNode.default)({ - type: "NewExpression", - callee, - arguments: _arguments - }); -} -function program(body, directives = [], sourceType = "script", interpreter = null) { - return (0, _validateNode.default)({ - type: "Program", - body, - directives, - sourceType, - interpreter - }); -} -function objectExpression(properties) { - return (0, _validateNode.default)({ - type: "ObjectExpression", - properties - }); -} -function objectMethod(kind = "method", key, params, body, computed = false, generator = false, async = false) { - return (0, _validateNode.default)({ - type: "ObjectMethod", - kind, - key, - params, - body, - computed, - generator, - async - }); -} -function objectProperty(key, value, computed = false, shorthand = false, decorators = null) { - return (0, _validateNode.default)({ - type: "ObjectProperty", - key, - value, - computed, - shorthand, - decorators - }); -} -function restElement(argument) { - return (0, _validateNode.default)({ - type: "RestElement", - argument - }); -} -function returnStatement(argument = null) { - return (0, _validateNode.default)({ - type: "ReturnStatement", - argument - }); -} -function sequenceExpression(expressions) { - return (0, _validateNode.default)({ - type: "SequenceExpression", - expressions - }); -} -function parenthesizedExpression(expression) { - return (0, _validateNode.default)({ - type: "ParenthesizedExpression", - expression - }); -} -function switchCase(test = null, consequent) { - return (0, _validateNode.default)({ - type: "SwitchCase", - test, - consequent - }); -} -function switchStatement(discriminant, cases) { - return (0, _validateNode.default)({ - type: "SwitchStatement", - discriminant, - cases - }); -} -function thisExpression() { - return { - type: "ThisExpression" - }; -} -function throwStatement(argument) { - return (0, _validateNode.default)({ - type: "ThrowStatement", - argument - }); -} -function tryStatement(block, handler = null, finalizer = null) { - return (0, _validateNode.default)({ - type: "TryStatement", - block, - handler, - finalizer - }); -} -function unaryExpression(operator, argument, prefix = true) { - return (0, _validateNode.default)({ - type: "UnaryExpression", - operator, - argument, - prefix - }); -} -function updateExpression(operator, argument, prefix = false) { - return (0, _validateNode.default)({ - type: "UpdateExpression", - operator, - argument, - prefix - }); -} -function variableDeclaration(kind, declarations) { - return (0, _validateNode.default)({ - type: "VariableDeclaration", - kind, - declarations - }); -} -function variableDeclarator(id, init = null) { - return (0, _validateNode.default)({ - type: "VariableDeclarator", - id, - init - }); -} -function whileStatement(test, body) { - return (0, _validateNode.default)({ - type: "WhileStatement", - test, - body - }); -} -function withStatement(object, body) { - return (0, _validateNode.default)({ - type: "WithStatement", - object, - body - }); -} -function assignmentPattern(left, right) { - return (0, _validateNode.default)({ - type: "AssignmentPattern", - left, - right - }); -} -function arrayPattern(elements) { - return (0, _validateNode.default)({ - type: "ArrayPattern", - elements - }); -} -function arrowFunctionExpression(params, body, async = false) { - return (0, _validateNode.default)({ - type: "ArrowFunctionExpression", - params, - body, - async, - expression: null - }); -} -function classBody(body) { - return (0, _validateNode.default)({ - type: "ClassBody", - body - }); -} -function classExpression(id = null, superClass = null, body, decorators = null) { - return (0, _validateNode.default)({ - type: "ClassExpression", - id, - superClass, - body, - decorators - }); -} -function classDeclaration(id = null, superClass = null, body, decorators = null) { - return (0, _validateNode.default)({ - type: "ClassDeclaration", - id, - superClass, - body, - decorators - }); -} -function exportAllDeclaration(source) { - return (0, _validateNode.default)({ - type: "ExportAllDeclaration", - source - }); -} -function exportDefaultDeclaration(declaration) { - return (0, _validateNode.default)({ - type: "ExportDefaultDeclaration", - declaration - }); -} -function exportNamedDeclaration(declaration = null, specifiers = [], source = null) { - return (0, _validateNode.default)({ - type: "ExportNamedDeclaration", - declaration, - specifiers, - source - }); -} -function exportSpecifier(local, exported) { - return (0, _validateNode.default)({ - type: "ExportSpecifier", - local, - exported - }); -} -function forOfStatement(left, right, body, _await = false) { - return (0, _validateNode.default)({ - type: "ForOfStatement", - left, - right, - body, - await: _await - }); -} -function importDeclaration(specifiers, source) { - return (0, _validateNode.default)({ - type: "ImportDeclaration", - specifiers, - source - }); -} -function importDefaultSpecifier(local) { - return (0, _validateNode.default)({ - type: "ImportDefaultSpecifier", - local - }); -} -function importNamespaceSpecifier(local) { - return (0, _validateNode.default)({ - type: "ImportNamespaceSpecifier", - local - }); -} -function importSpecifier(local, imported) { - return (0, _validateNode.default)({ - type: "ImportSpecifier", - local, - imported - }); -} -function importExpression(source, options = null) { - return (0, _validateNode.default)({ - type: "ImportExpression", - source, - options - }); -} -function metaProperty(meta, property) { - return (0, _validateNode.default)({ - type: "MetaProperty", - meta, - property - }); -} -function classMethod(kind = "method", key, params, body, computed = false, _static = false, generator = false, async = false) { - return (0, _validateNode.default)({ - type: "ClassMethod", - kind, - key, - params, - body, - computed, - static: _static, - generator, - async - }); -} -function objectPattern(properties) { - return (0, _validateNode.default)({ - type: "ObjectPattern", - properties - }); -} -function spreadElement(argument) { - return (0, _validateNode.default)({ - type: "SpreadElement", - argument - }); -} -function _super() { - return { - type: "Super" - }; -} -function taggedTemplateExpression(tag, quasi) { - return (0, _validateNode.default)({ - type: "TaggedTemplateExpression", - tag, - quasi - }); -} -function templateElement(value, tail = false) { - return (0, _validateNode.default)({ - type: "TemplateElement", - value, - tail - }); -} -function templateLiteral(quasis, expressions) { - return (0, _validateNode.default)({ - type: "TemplateLiteral", - quasis, - expressions - }); -} -function yieldExpression(argument = null, delegate = false) { - return (0, _validateNode.default)({ - type: "YieldExpression", - argument, - delegate - }); -} -function awaitExpression(argument) { - return (0, _validateNode.default)({ - type: "AwaitExpression", - argument - }); -} -function _import() { - return { - type: "Import" - }; -} -function bigIntLiteral(value) { - return (0, _validateNode.default)({ - type: "BigIntLiteral", - value - }); -} -function exportNamespaceSpecifier(exported) { - return (0, _validateNode.default)({ - type: "ExportNamespaceSpecifier", - exported - }); -} -function optionalMemberExpression(object, property, computed = false, optional) { - return (0, _validateNode.default)({ - type: "OptionalMemberExpression", - object, - property, - computed, - optional - }); -} -function optionalCallExpression(callee, _arguments, optional) { - return (0, _validateNode.default)({ - type: "OptionalCallExpression", - callee, - arguments: _arguments, - optional - }); -} -function classProperty(key, value = null, typeAnnotation = null, decorators = null, computed = false, _static = false) { - return (0, _validateNode.default)({ - type: "ClassProperty", - key, - value, - typeAnnotation, - decorators, - computed, - static: _static - }); -} -function classAccessorProperty(key, value = null, typeAnnotation = null, decorators = null, computed = false, _static = false) { - return (0, _validateNode.default)({ - type: "ClassAccessorProperty", - key, - value, - typeAnnotation, - decorators, - computed, - static: _static - }); -} -function classPrivateProperty(key, value = null, decorators = null, _static = false) { - return (0, _validateNode.default)({ - type: "ClassPrivateProperty", - key, - value, - decorators, - static: _static - }); -} -function classPrivateMethod(kind = "method", key, params, body, _static = false) { - return (0, _validateNode.default)({ - type: "ClassPrivateMethod", - kind, - key, - params, - body, - static: _static - }); -} -function privateName(id) { - return (0, _validateNode.default)({ - type: "PrivateName", - id - }); -} -function staticBlock(body) { - return (0, _validateNode.default)({ - type: "StaticBlock", - body - }); -} -function anyTypeAnnotation() { - return { - type: "AnyTypeAnnotation" - }; -} -function arrayTypeAnnotation(elementType) { - return (0, _validateNode.default)({ - type: "ArrayTypeAnnotation", - elementType - }); -} -function booleanTypeAnnotation() { - return { - type: "BooleanTypeAnnotation" - }; -} -function booleanLiteralTypeAnnotation(value) { - return (0, _validateNode.default)({ - type: "BooleanLiteralTypeAnnotation", - value - }); -} -function nullLiteralTypeAnnotation() { - return { - type: "NullLiteralTypeAnnotation" - }; -} -function classImplements(id, typeParameters = null) { - return (0, _validateNode.default)({ - type: "ClassImplements", - id, - typeParameters - }); -} -function declareClass(id, typeParameters = null, _extends = null, body) { - return (0, _validateNode.default)({ - type: "DeclareClass", - id, - typeParameters, - extends: _extends, - body - }); -} -function declareFunction(id) { - return (0, _validateNode.default)({ - type: "DeclareFunction", - id - }); -} -function declareInterface(id, typeParameters = null, _extends = null, body) { - return (0, _validateNode.default)({ - type: "DeclareInterface", - id, - typeParameters, - extends: _extends, - body - }); -} -function declareModule(id, body, kind = null) { - return (0, _validateNode.default)({ - type: "DeclareModule", - id, - body, - kind - }); -} -function declareModuleExports(typeAnnotation) { - return (0, _validateNode.default)({ - type: "DeclareModuleExports", - typeAnnotation - }); -} -function declareTypeAlias(id, typeParameters = null, right) { - return (0, _validateNode.default)({ - type: "DeclareTypeAlias", - id, - typeParameters, - right - }); -} -function declareOpaqueType(id, typeParameters = null, supertype = null) { - return (0, _validateNode.default)({ - type: "DeclareOpaqueType", - id, - typeParameters, - supertype - }); -} -function declareVariable(id) { - return (0, _validateNode.default)({ - type: "DeclareVariable", - id - }); -} -function declareExportDeclaration(declaration = null, specifiers = null, source = null) { - return (0, _validateNode.default)({ - type: "DeclareExportDeclaration", - declaration, - specifiers, - source - }); -} -function declareExportAllDeclaration(source) { - return (0, _validateNode.default)({ - type: "DeclareExportAllDeclaration", - source - }); -} -function declaredPredicate(value) { - return (0, _validateNode.default)({ - type: "DeclaredPredicate", - value - }); -} -function existsTypeAnnotation() { - return { - type: "ExistsTypeAnnotation" - }; -} -function functionTypeAnnotation(typeParameters = null, params, rest = null, returnType) { - return (0, _validateNode.default)({ - type: "FunctionTypeAnnotation", - typeParameters, - params, - rest, - returnType - }); -} -function functionTypeParam(name = null, typeAnnotation) { - return (0, _validateNode.default)({ - type: "FunctionTypeParam", - name, - typeAnnotation - }); -} -function genericTypeAnnotation(id, typeParameters = null) { - return (0, _validateNode.default)({ - type: "GenericTypeAnnotation", - id, - typeParameters - }); -} -function inferredPredicate() { - return { - type: "InferredPredicate" - }; -} -function interfaceExtends(id, typeParameters = null) { - return (0, _validateNode.default)({ - type: "InterfaceExtends", - id, - typeParameters - }); -} -function interfaceDeclaration(id, typeParameters = null, _extends = null, body) { - return (0, _validateNode.default)({ - type: "InterfaceDeclaration", - id, - typeParameters, - extends: _extends, - body - }); -} -function interfaceTypeAnnotation(_extends = null, body) { - return (0, _validateNode.default)({ - type: "InterfaceTypeAnnotation", - extends: _extends, - body - }); -} -function intersectionTypeAnnotation(types) { - return (0, _validateNode.default)({ - type: "IntersectionTypeAnnotation", - types - }); -} -function mixedTypeAnnotation() { - return { - type: "MixedTypeAnnotation" - }; -} -function emptyTypeAnnotation() { - return { - type: "EmptyTypeAnnotation" - }; -} -function nullableTypeAnnotation(typeAnnotation) { - return (0, _validateNode.default)({ - type: "NullableTypeAnnotation", - typeAnnotation - }); -} -function numberLiteralTypeAnnotation(value) { - return (0, _validateNode.default)({ - type: "NumberLiteralTypeAnnotation", - value - }); -} -function numberTypeAnnotation() { - return { - type: "NumberTypeAnnotation" - }; -} -function objectTypeAnnotation(properties, indexers = [], callProperties = [], internalSlots = [], exact = false) { - return (0, _validateNode.default)({ - type: "ObjectTypeAnnotation", - properties, - indexers, - callProperties, - internalSlots, - exact - }); -} -function objectTypeInternalSlot(id, value, optional, _static, method) { - return (0, _validateNode.default)({ - type: "ObjectTypeInternalSlot", - id, - value, - optional, - static: _static, - method - }); -} -function objectTypeCallProperty(value) { - return (0, _validateNode.default)({ - type: "ObjectTypeCallProperty", - value, - static: null - }); -} -function objectTypeIndexer(id = null, key, value, variance = null) { - return (0, _validateNode.default)({ - type: "ObjectTypeIndexer", - id, - key, - value, - variance, - static: null - }); -} -function objectTypeProperty(key, value, variance = null) { - return (0, _validateNode.default)({ - type: "ObjectTypeProperty", - key, - value, - variance, - kind: null, - method: null, - optional: null, - proto: null, - static: null - }); -} -function objectTypeSpreadProperty(argument) { - return (0, _validateNode.default)({ - type: "ObjectTypeSpreadProperty", - argument - }); -} -function opaqueType(id, typeParameters = null, supertype = null, impltype) { - return (0, _validateNode.default)({ - type: "OpaqueType", - id, - typeParameters, - supertype, - impltype - }); -} -function qualifiedTypeIdentifier(id, qualification) { - return (0, _validateNode.default)({ - type: "QualifiedTypeIdentifier", - id, - qualification - }); -} -function stringLiteralTypeAnnotation(value) { - return (0, _validateNode.default)({ - type: "StringLiteralTypeAnnotation", - value - }); -} -function stringTypeAnnotation() { - return { - type: "StringTypeAnnotation" - }; -} -function symbolTypeAnnotation() { - return { - type: "SymbolTypeAnnotation" - }; -} -function thisTypeAnnotation() { - return { - type: "ThisTypeAnnotation" - }; -} -function tupleTypeAnnotation(types) { - return (0, _validateNode.default)({ - type: "TupleTypeAnnotation", - types - }); -} -function typeofTypeAnnotation(argument) { - return (0, _validateNode.default)({ - type: "TypeofTypeAnnotation", - argument - }); -} -function typeAlias(id, typeParameters = null, right) { - return (0, _validateNode.default)({ - type: "TypeAlias", - id, - typeParameters, - right - }); -} -function typeAnnotation(typeAnnotation) { - return (0, _validateNode.default)({ - type: "TypeAnnotation", - typeAnnotation - }); -} -function typeCastExpression(expression, typeAnnotation) { - return (0, _validateNode.default)({ - type: "TypeCastExpression", - expression, - typeAnnotation - }); -} -function typeParameter(bound = null, _default = null, variance = null) { - return (0, _validateNode.default)({ - type: "TypeParameter", - bound, - default: _default, - variance, - name: null - }); -} -function typeParameterDeclaration(params) { - return (0, _validateNode.default)({ - type: "TypeParameterDeclaration", - params - }); -} -function typeParameterInstantiation(params) { - return (0, _validateNode.default)({ - type: "TypeParameterInstantiation", - params - }); -} -function unionTypeAnnotation(types) { - return (0, _validateNode.default)({ - type: "UnionTypeAnnotation", - types - }); -} -function variance(kind) { - return (0, _validateNode.default)({ - type: "Variance", - kind - }); -} -function voidTypeAnnotation() { - return { - type: "VoidTypeAnnotation" - }; -} -function enumDeclaration(id, body) { - return (0, _validateNode.default)({ - type: "EnumDeclaration", - id, - body - }); -} -function enumBooleanBody(members) { - return (0, _validateNode.default)({ - type: "EnumBooleanBody", - members, - explicitType: null, - hasUnknownMembers: null - }); -} -function enumNumberBody(members) { - return (0, _validateNode.default)({ - type: "EnumNumberBody", - members, - explicitType: null, - hasUnknownMembers: null - }); -} -function enumStringBody(members) { - return (0, _validateNode.default)({ - type: "EnumStringBody", - members, - explicitType: null, - hasUnknownMembers: null - }); -} -function enumSymbolBody(members) { - return (0, _validateNode.default)({ - type: "EnumSymbolBody", - members, - hasUnknownMembers: null - }); -} -function enumBooleanMember(id) { - return (0, _validateNode.default)({ - type: "EnumBooleanMember", - id, - init: null - }); -} -function enumNumberMember(id, init) { - return (0, _validateNode.default)({ - type: "EnumNumberMember", - id, - init - }); -} -function enumStringMember(id, init) { - return (0, _validateNode.default)({ - type: "EnumStringMember", - id, - init - }); -} -function enumDefaultedMember(id) { - return (0, _validateNode.default)({ - type: "EnumDefaultedMember", - id - }); -} -function indexedAccessType(objectType, indexType) { - return (0, _validateNode.default)({ - type: "IndexedAccessType", - objectType, - indexType - }); -} -function optionalIndexedAccessType(objectType, indexType) { - return (0, _validateNode.default)({ - type: "OptionalIndexedAccessType", - objectType, - indexType, - optional: null - }); -} -function jsxAttribute(name, value = null) { - return (0, _validateNode.default)({ - type: "JSXAttribute", - name, - value - }); -} -function jsxClosingElement(name) { - return (0, _validateNode.default)({ - type: "JSXClosingElement", - name - }); -} -function jsxElement(openingElement, closingElement = null, children, selfClosing = null) { - return (0, _validateNode.default)({ - type: "JSXElement", - openingElement, - closingElement, - children, - selfClosing - }); -} -function jsxEmptyExpression() { - return { - type: "JSXEmptyExpression" - }; -} -function jsxExpressionContainer(expression) { - return (0, _validateNode.default)({ - type: "JSXExpressionContainer", - expression - }); -} -function jsxSpreadChild(expression) { - return (0, _validateNode.default)({ - type: "JSXSpreadChild", - expression - }); -} -function jsxIdentifier(name) { - return (0, _validateNode.default)({ - type: "JSXIdentifier", - name - }); -} -function jsxMemberExpression(object, property) { - return (0, _validateNode.default)({ - type: "JSXMemberExpression", - object, - property - }); -} -function jsxNamespacedName(namespace, name) { - return (0, _validateNode.default)({ - type: "JSXNamespacedName", - namespace, - name - }); -} -function jsxOpeningElement(name, attributes, selfClosing = false) { - return (0, _validateNode.default)({ - type: "JSXOpeningElement", - name, - attributes, - selfClosing - }); -} -function jsxSpreadAttribute(argument) { - return (0, _validateNode.default)({ - type: "JSXSpreadAttribute", - argument - }); -} -function jsxText(value) { - return (0, _validateNode.default)({ - type: "JSXText", - value - }); -} -function jsxFragment(openingFragment, closingFragment, children) { - return (0, _validateNode.default)({ - type: "JSXFragment", - openingFragment, - closingFragment, - children - }); -} -function jsxOpeningFragment() { - return { - type: "JSXOpeningFragment" - }; -} -function jsxClosingFragment() { - return { - type: "JSXClosingFragment" - }; -} -function noop() { - return { - type: "Noop" - }; -} -function placeholder(expectedNode, name) { - return (0, _validateNode.default)({ - type: "Placeholder", - expectedNode, - name - }); -} -function v8IntrinsicIdentifier(name) { - return (0, _validateNode.default)({ - type: "V8IntrinsicIdentifier", - name - }); -} -function argumentPlaceholder() { - return { - type: "ArgumentPlaceholder" - }; -} -function bindExpression(object, callee) { - return (0, _validateNode.default)({ - type: "BindExpression", - object, - callee - }); -} -function importAttribute(key, value) { - return (0, _validateNode.default)({ - type: "ImportAttribute", - key, - value - }); -} -function decorator(expression) { - return (0, _validateNode.default)({ - type: "Decorator", - expression - }); -} -function doExpression(body, async = false) { - return (0, _validateNode.default)({ - type: "DoExpression", - body, - async - }); -} -function exportDefaultSpecifier(exported) { - return (0, _validateNode.default)({ - type: "ExportDefaultSpecifier", - exported - }); -} -function recordExpression(properties) { - return (0, _validateNode.default)({ - type: "RecordExpression", - properties - }); -} -function tupleExpression(elements = []) { - return (0, _validateNode.default)({ - type: "TupleExpression", - elements - }); -} -function decimalLiteral(value) { - return (0, _validateNode.default)({ - type: "DecimalLiteral", - value - }); -} -function moduleExpression(body) { - return (0, _validateNode.default)({ - type: "ModuleExpression", - body - }); -} -function topicReference() { - return { - type: "TopicReference" - }; -} -function pipelineTopicExpression(expression) { - return (0, _validateNode.default)({ - type: "PipelineTopicExpression", - expression - }); -} -function pipelineBareFunction(callee) { - return (0, _validateNode.default)({ - type: "PipelineBareFunction", - callee - }); -} -function pipelinePrimaryTopicReference() { - return { - type: "PipelinePrimaryTopicReference" - }; -} -function tsParameterProperty(parameter) { - return (0, _validateNode.default)({ - type: "TSParameterProperty", - parameter - }); -} -function tsDeclareFunction(id = null, typeParameters = null, params, returnType = null) { - return (0, _validateNode.default)({ - type: "TSDeclareFunction", - id, - typeParameters, - params, - returnType - }); -} -function tsDeclareMethod(decorators = null, key, typeParameters = null, params, returnType = null) { - return (0, _validateNode.default)({ - type: "TSDeclareMethod", - decorators, - key, - typeParameters, - params, - returnType - }); -} -function tsQualifiedName(left, right) { - return (0, _validateNode.default)({ - type: "TSQualifiedName", - left, - right - }); -} -function tsCallSignatureDeclaration(typeParameters = null, parameters, typeAnnotation = null) { - return (0, _validateNode.default)({ - type: "TSCallSignatureDeclaration", - typeParameters, - parameters, - typeAnnotation - }); -} -function tsConstructSignatureDeclaration(typeParameters = null, parameters, typeAnnotation = null) { - return (0, _validateNode.default)({ - type: "TSConstructSignatureDeclaration", - typeParameters, - parameters, - typeAnnotation - }); -} -function tsPropertySignature(key, typeAnnotation = null) { - return (0, _validateNode.default)({ - type: "TSPropertySignature", - key, - typeAnnotation, - kind: null - }); -} -function tsMethodSignature(key, typeParameters = null, parameters, typeAnnotation = null) { - return (0, _validateNode.default)({ - type: "TSMethodSignature", - key, - typeParameters, - parameters, - typeAnnotation, - kind: null - }); -} -function tsIndexSignature(parameters, typeAnnotation = null) { - return (0, _validateNode.default)({ - type: "TSIndexSignature", - parameters, - typeAnnotation - }); -} -function tsAnyKeyword() { - return { - type: "TSAnyKeyword" - }; -} -function tsBooleanKeyword() { - return { - type: "TSBooleanKeyword" - }; -} -function tsBigIntKeyword() { - return { - type: "TSBigIntKeyword" - }; -} -function tsIntrinsicKeyword() { - return { - type: "TSIntrinsicKeyword" - }; -} -function tsNeverKeyword() { - return { - type: "TSNeverKeyword" - }; -} -function tsNullKeyword() { - return { - type: "TSNullKeyword" - }; -} -function tsNumberKeyword() { - return { - type: "TSNumberKeyword" - }; -} -function tsObjectKeyword() { - return { - type: "TSObjectKeyword" - }; -} -function tsStringKeyword() { - return { - type: "TSStringKeyword" - }; -} -function tsSymbolKeyword() { - return { - type: "TSSymbolKeyword" - }; -} -function tsUndefinedKeyword() { - return { - type: "TSUndefinedKeyword" - }; -} -function tsUnknownKeyword() { - return { - type: "TSUnknownKeyword" - }; -} -function tsVoidKeyword() { - return { - type: "TSVoidKeyword" - }; -} -function tsThisType() { - return { - type: "TSThisType" - }; -} -function tsFunctionType(typeParameters = null, parameters, typeAnnotation = null) { - return (0, _validateNode.default)({ - type: "TSFunctionType", - typeParameters, - parameters, - typeAnnotation - }); -} -function tsConstructorType(typeParameters = null, parameters, typeAnnotation = null) { - return (0, _validateNode.default)({ - type: "TSConstructorType", - typeParameters, - parameters, - typeAnnotation - }); -} -function tsTypeReference(typeName, typeParameters = null) { - return (0, _validateNode.default)({ - type: "TSTypeReference", - typeName, - typeParameters - }); -} -function tsTypePredicate(parameterName, typeAnnotation = null, asserts = null) { - return (0, _validateNode.default)({ - type: "TSTypePredicate", - parameterName, - typeAnnotation, - asserts - }); -} -function tsTypeQuery(exprName, typeParameters = null) { - return (0, _validateNode.default)({ - type: "TSTypeQuery", - exprName, - typeParameters - }); -} -function tsTypeLiteral(members) { - return (0, _validateNode.default)({ - type: "TSTypeLiteral", - members - }); -} -function tsArrayType(elementType) { - return (0, _validateNode.default)({ - type: "TSArrayType", - elementType - }); -} -function tsTupleType(elementTypes) { - return (0, _validateNode.default)({ - type: "TSTupleType", - elementTypes - }); -} -function tsOptionalType(typeAnnotation) { - return (0, _validateNode.default)({ - type: "TSOptionalType", - typeAnnotation - }); -} -function tsRestType(typeAnnotation) { - return (0, _validateNode.default)({ - type: "TSRestType", - typeAnnotation - }); -} -function tsNamedTupleMember(label, elementType, optional = false) { - return (0, _validateNode.default)({ - type: "TSNamedTupleMember", - label, - elementType, - optional - }); -} -function tsUnionType(types) { - return (0, _validateNode.default)({ - type: "TSUnionType", - types - }); -} -function tsIntersectionType(types) { - return (0, _validateNode.default)({ - type: "TSIntersectionType", - types - }); -} -function tsConditionalType(checkType, extendsType, trueType, falseType) { - return (0, _validateNode.default)({ - type: "TSConditionalType", - checkType, - extendsType, - trueType, - falseType - }); -} -function tsInferType(typeParameter) { - return (0, _validateNode.default)({ - type: "TSInferType", - typeParameter - }); -} -function tsParenthesizedType(typeAnnotation) { - return (0, _validateNode.default)({ - type: "TSParenthesizedType", - typeAnnotation - }); -} -function tsTypeOperator(typeAnnotation) { - return (0, _validateNode.default)({ - type: "TSTypeOperator", - typeAnnotation, - operator: null - }); -} -function tsIndexedAccessType(objectType, indexType) { - return (0, _validateNode.default)({ - type: "TSIndexedAccessType", - objectType, - indexType - }); -} -function tsMappedType(typeParameter, typeAnnotation = null, nameType = null) { - return (0, _validateNode.default)({ - type: "TSMappedType", - typeParameter, - typeAnnotation, - nameType - }); -} -function tsLiteralType(literal) { - return (0, _validateNode.default)({ - type: "TSLiteralType", - literal - }); -} -function tsExpressionWithTypeArguments(expression, typeParameters = null) { - return (0, _validateNode.default)({ - type: "TSExpressionWithTypeArguments", - expression, - typeParameters - }); -} -function tsInterfaceDeclaration(id, typeParameters = null, _extends = null, body) { - return (0, _validateNode.default)({ - type: "TSInterfaceDeclaration", - id, - typeParameters, - extends: _extends, - body - }); -} -function tsInterfaceBody(body) { - return (0, _validateNode.default)({ - type: "TSInterfaceBody", - body - }); -} -function tsTypeAliasDeclaration(id, typeParameters = null, typeAnnotation) { - return (0, _validateNode.default)({ - type: "TSTypeAliasDeclaration", - id, - typeParameters, - typeAnnotation - }); -} -function tsInstantiationExpression(expression, typeParameters = null) { - return (0, _validateNode.default)({ - type: "TSInstantiationExpression", - expression, - typeParameters - }); -} -function tsAsExpression(expression, typeAnnotation) { - return (0, _validateNode.default)({ - type: "TSAsExpression", - expression, - typeAnnotation - }); -} -function tsSatisfiesExpression(expression, typeAnnotation) { - return (0, _validateNode.default)({ - type: "TSSatisfiesExpression", - expression, - typeAnnotation - }); -} -function tsTypeAssertion(typeAnnotation, expression) { - return (0, _validateNode.default)({ - type: "TSTypeAssertion", - typeAnnotation, - expression - }); -} -function tsEnumDeclaration(id, members) { - return (0, _validateNode.default)({ - type: "TSEnumDeclaration", - id, - members - }); -} -function tsEnumMember(id, initializer = null) { - return (0, _validateNode.default)({ - type: "TSEnumMember", - id, - initializer - }); -} -function tsModuleDeclaration(id, body) { - return (0, _validateNode.default)({ - type: "TSModuleDeclaration", - id, - body - }); -} -function tsModuleBlock(body) { - return (0, _validateNode.default)({ - type: "TSModuleBlock", - body - }); -} -function tsImportType(argument, qualifier = null, typeParameters = null) { - return (0, _validateNode.default)({ - type: "TSImportType", - argument, - qualifier, - typeParameters - }); -} -function tsImportEqualsDeclaration(id, moduleReference) { - return (0, _validateNode.default)({ - type: "TSImportEqualsDeclaration", - id, - moduleReference, - isExport: null - }); -} -function tsExternalModuleReference(expression) { - return (0, _validateNode.default)({ - type: "TSExternalModuleReference", - expression - }); -} -function tsNonNullExpression(expression) { - return (0, _validateNode.default)({ - type: "TSNonNullExpression", - expression - }); -} -function tsExportAssignment(expression) { - return (0, _validateNode.default)({ - type: "TSExportAssignment", - expression - }); -} -function tsNamespaceExportDeclaration(id) { - return (0, _validateNode.default)({ - type: "TSNamespaceExportDeclaration", - id - }); -} -function tsTypeAnnotation(typeAnnotation) { - return (0, _validateNode.default)({ - type: "TSTypeAnnotation", - typeAnnotation - }); -} -function tsTypeParameterInstantiation(params) { - return (0, _validateNode.default)({ - type: "TSTypeParameterInstantiation", - params - }); -} -function tsTypeParameterDeclaration(params) { - return (0, _validateNode.default)({ - type: "TSTypeParameterDeclaration", - params - }); -} -function tsTypeParameter(constraint = null, _default = null, name) { - return (0, _validateNode.default)({ - type: "TSTypeParameter", - constraint, - default: _default, - name - }); -} -function NumberLiteral(value) { - (0, _deprecationWarning.default)("NumberLiteral", "NumericLiteral", "The node type "); - return numericLiteral(value); -} -function RegexLiteral(pattern, flags = "") { - (0, _deprecationWarning.default)("RegexLiteral", "RegExpLiteral", "The node type "); - return regExpLiteral(pattern, flags); -} -function RestProperty(argument) { - (0, _deprecationWarning.default)("RestProperty", "RestElement", "The node type "); - return restElement(argument); -} -function SpreadProperty(argument) { - (0, _deprecationWarning.default)("SpreadProperty", "SpreadElement", "The node type "); - return spreadElement(argument); -} - -//# sourceMappingURL=index.js.map diff --git a/tools/eslint/node_modules/@babel/types/lib/builders/generated/uppercase.js b/tools/eslint/node_modules/@babel/types/lib/builders/generated/uppercase.js deleted file mode 100644 index 1d02118882bec0..00000000000000 --- a/tools/eslint/node_modules/@babel/types/lib/builders/generated/uppercase.js +++ /dev/null @@ -1,1532 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -Object.defineProperty(exports, "AnyTypeAnnotation", { - enumerable: true, - get: function () { - return _index.anyTypeAnnotation; - } -}); -Object.defineProperty(exports, "ArgumentPlaceholder", { - enumerable: true, - get: function () { - return _index.argumentPlaceholder; - } -}); -Object.defineProperty(exports, "ArrayExpression", { - enumerable: true, - get: function () { - return _index.arrayExpression; - } -}); -Object.defineProperty(exports, "ArrayPattern", { - enumerable: true, - get: function () { - return _index.arrayPattern; - } -}); -Object.defineProperty(exports, "ArrayTypeAnnotation", { - enumerable: true, - get: function () { - return _index.arrayTypeAnnotation; - } -}); -Object.defineProperty(exports, "ArrowFunctionExpression", { - enumerable: true, - get: function () { - return _index.arrowFunctionExpression; - } -}); -Object.defineProperty(exports, "AssignmentExpression", { - enumerable: true, - get: function () { - return _index.assignmentExpression; - } -}); -Object.defineProperty(exports, "AssignmentPattern", { - enumerable: true, - get: function () { - return _index.assignmentPattern; - } -}); -Object.defineProperty(exports, "AwaitExpression", { - enumerable: true, - get: function () { - return _index.awaitExpression; - } -}); -Object.defineProperty(exports, "BigIntLiteral", { - enumerable: true, - get: function () { - return _index.bigIntLiteral; - } -}); -Object.defineProperty(exports, "BinaryExpression", { - enumerable: true, - get: function () { - return _index.binaryExpression; - } -}); -Object.defineProperty(exports, "BindExpression", { - enumerable: true, - get: function () { - return _index.bindExpression; - } -}); -Object.defineProperty(exports, "BlockStatement", { - enumerable: true, - get: function () { - return _index.blockStatement; - } -}); -Object.defineProperty(exports, "BooleanLiteral", { - enumerable: true, - get: function () { - return _index.booleanLiteral; - } -}); -Object.defineProperty(exports, "BooleanLiteralTypeAnnotation", { - enumerable: true, - get: function () { - return _index.booleanLiteralTypeAnnotation; - } -}); -Object.defineProperty(exports, "BooleanTypeAnnotation", { - enumerable: true, - get: function () { - return _index.booleanTypeAnnotation; - } -}); -Object.defineProperty(exports, "BreakStatement", { - enumerable: true, - get: function () { - return _index.breakStatement; - } -}); -Object.defineProperty(exports, "CallExpression", { - enumerable: true, - get: function () { - return _index.callExpression; - } -}); -Object.defineProperty(exports, "CatchClause", { - enumerable: true, - get: function () { - return _index.catchClause; - } -}); -Object.defineProperty(exports, "ClassAccessorProperty", { - enumerable: true, - get: function () { - return _index.classAccessorProperty; - } -}); -Object.defineProperty(exports, "ClassBody", { - enumerable: true, - get: function () { - return _index.classBody; - } -}); -Object.defineProperty(exports, "ClassDeclaration", { - enumerable: true, - get: function () { - return _index.classDeclaration; - } -}); -Object.defineProperty(exports, "ClassExpression", { - enumerable: true, - get: function () { - return _index.classExpression; - } -}); -Object.defineProperty(exports, "ClassImplements", { - enumerable: true, - get: function () { - return _index.classImplements; - } -}); -Object.defineProperty(exports, "ClassMethod", { - enumerable: true, - get: function () { - return _index.classMethod; - } -}); -Object.defineProperty(exports, "ClassPrivateMethod", { - enumerable: true, - get: function () { - return _index.classPrivateMethod; - } -}); -Object.defineProperty(exports, "ClassPrivateProperty", { - enumerable: true, - get: function () { - return _index.classPrivateProperty; - } -}); -Object.defineProperty(exports, "ClassProperty", { - enumerable: true, - get: function () { - return _index.classProperty; - } -}); -Object.defineProperty(exports, "ConditionalExpression", { - enumerable: true, - get: function () { - return _index.conditionalExpression; - } -}); -Object.defineProperty(exports, "ContinueStatement", { - enumerable: true, - get: function () { - return _index.continueStatement; - } -}); -Object.defineProperty(exports, "DebuggerStatement", { - enumerable: true, - get: function () { - return _index.debuggerStatement; - } -}); -Object.defineProperty(exports, "DecimalLiteral", { - enumerable: true, - get: function () { - return _index.decimalLiteral; - } -}); -Object.defineProperty(exports, "DeclareClass", { - enumerable: true, - get: function () { - return _index.declareClass; - } -}); -Object.defineProperty(exports, "DeclareExportAllDeclaration", { - enumerable: true, - get: function () { - return _index.declareExportAllDeclaration; - } -}); -Object.defineProperty(exports, "DeclareExportDeclaration", { - enumerable: true, - get: function () { - return _index.declareExportDeclaration; - } -}); -Object.defineProperty(exports, "DeclareFunction", { - enumerable: true, - get: function () { - return _index.declareFunction; - } -}); -Object.defineProperty(exports, "DeclareInterface", { - enumerable: true, - get: function () { - return _index.declareInterface; - } -}); -Object.defineProperty(exports, "DeclareModule", { - enumerable: true, - get: function () { - return _index.declareModule; - } -}); -Object.defineProperty(exports, "DeclareModuleExports", { - enumerable: true, - get: function () { - return _index.declareModuleExports; - } -}); -Object.defineProperty(exports, "DeclareOpaqueType", { - enumerable: true, - get: function () { - return _index.declareOpaqueType; - } -}); -Object.defineProperty(exports, "DeclareTypeAlias", { - enumerable: true, - get: function () { - return _index.declareTypeAlias; - } -}); -Object.defineProperty(exports, "DeclareVariable", { - enumerable: true, - get: function () { - return _index.declareVariable; - } -}); -Object.defineProperty(exports, "DeclaredPredicate", { - enumerable: true, - get: function () { - return _index.declaredPredicate; - } -}); -Object.defineProperty(exports, "Decorator", { - enumerable: true, - get: function () { - return _index.decorator; - } -}); -Object.defineProperty(exports, "Directive", { - enumerable: true, - get: function () { - return _index.directive; - } -}); -Object.defineProperty(exports, "DirectiveLiteral", { - enumerable: true, - get: function () { - return _index.directiveLiteral; - } -}); -Object.defineProperty(exports, "DoExpression", { - enumerable: true, - get: function () { - return _index.doExpression; - } -}); -Object.defineProperty(exports, "DoWhileStatement", { - enumerable: true, - get: function () { - return _index.doWhileStatement; - } -}); -Object.defineProperty(exports, "EmptyStatement", { - enumerable: true, - get: function () { - return _index.emptyStatement; - } -}); -Object.defineProperty(exports, "EmptyTypeAnnotation", { - enumerable: true, - get: function () { - return _index.emptyTypeAnnotation; - } -}); -Object.defineProperty(exports, "EnumBooleanBody", { - enumerable: true, - get: function () { - return _index.enumBooleanBody; - } -}); -Object.defineProperty(exports, "EnumBooleanMember", { - enumerable: true, - get: function () { - return _index.enumBooleanMember; - } -}); -Object.defineProperty(exports, "EnumDeclaration", { - enumerable: true, - get: function () { - return _index.enumDeclaration; - } -}); -Object.defineProperty(exports, "EnumDefaultedMember", { - enumerable: true, - get: function () { - return _index.enumDefaultedMember; - } -}); -Object.defineProperty(exports, "EnumNumberBody", { - enumerable: true, - get: function () { - return _index.enumNumberBody; - } -}); -Object.defineProperty(exports, "EnumNumberMember", { - enumerable: true, - get: function () { - return _index.enumNumberMember; - } -}); -Object.defineProperty(exports, "EnumStringBody", { - enumerable: true, - get: function () { - return _index.enumStringBody; - } -}); -Object.defineProperty(exports, "EnumStringMember", { - enumerable: true, - get: function () { - return _index.enumStringMember; - } -}); -Object.defineProperty(exports, "EnumSymbolBody", { - enumerable: true, - get: function () { - return _index.enumSymbolBody; - } -}); -Object.defineProperty(exports, "ExistsTypeAnnotation", { - enumerable: true, - get: function () { - return _index.existsTypeAnnotation; - } -}); -Object.defineProperty(exports, "ExportAllDeclaration", { - enumerable: true, - get: function () { - return _index.exportAllDeclaration; - } -}); -Object.defineProperty(exports, "ExportDefaultDeclaration", { - enumerable: true, - get: function () { - return _index.exportDefaultDeclaration; - } -}); -Object.defineProperty(exports, "ExportDefaultSpecifier", { - enumerable: true, - get: function () { - return _index.exportDefaultSpecifier; - } -}); -Object.defineProperty(exports, "ExportNamedDeclaration", { - enumerable: true, - get: function () { - return _index.exportNamedDeclaration; - } -}); -Object.defineProperty(exports, "ExportNamespaceSpecifier", { - enumerable: true, - get: function () { - return _index.exportNamespaceSpecifier; - } -}); -Object.defineProperty(exports, "ExportSpecifier", { - enumerable: true, - get: function () { - return _index.exportSpecifier; - } -}); -Object.defineProperty(exports, "ExpressionStatement", { - enumerable: true, - get: function () { - return _index.expressionStatement; - } -}); -Object.defineProperty(exports, "File", { - enumerable: true, - get: function () { - return _index.file; - } -}); -Object.defineProperty(exports, "ForInStatement", { - enumerable: true, - get: function () { - return _index.forInStatement; - } -}); -Object.defineProperty(exports, "ForOfStatement", { - enumerable: true, - get: function () { - return _index.forOfStatement; - } -}); -Object.defineProperty(exports, "ForStatement", { - enumerable: true, - get: function () { - return _index.forStatement; - } -}); -Object.defineProperty(exports, "FunctionDeclaration", { - enumerable: true, - get: function () { - return _index.functionDeclaration; - } -}); -Object.defineProperty(exports, "FunctionExpression", { - enumerable: true, - get: function () { - return _index.functionExpression; - } -}); -Object.defineProperty(exports, "FunctionTypeAnnotation", { - enumerable: true, - get: function () { - return _index.functionTypeAnnotation; - } -}); -Object.defineProperty(exports, "FunctionTypeParam", { - enumerable: true, - get: function () { - return _index.functionTypeParam; - } -}); -Object.defineProperty(exports, "GenericTypeAnnotation", { - enumerable: true, - get: function () { - return _index.genericTypeAnnotation; - } -}); -Object.defineProperty(exports, "Identifier", { - enumerable: true, - get: function () { - return _index.identifier; - } -}); -Object.defineProperty(exports, "IfStatement", { - enumerable: true, - get: function () { - return _index.ifStatement; - } -}); -Object.defineProperty(exports, "Import", { - enumerable: true, - get: function () { - return _index.import; - } -}); -Object.defineProperty(exports, "ImportAttribute", { - enumerable: true, - get: function () { - return _index.importAttribute; - } -}); -Object.defineProperty(exports, "ImportDeclaration", { - enumerable: true, - get: function () { - return _index.importDeclaration; - } -}); -Object.defineProperty(exports, "ImportDefaultSpecifier", { - enumerable: true, - get: function () { - return _index.importDefaultSpecifier; - } -}); -Object.defineProperty(exports, "ImportExpression", { - enumerable: true, - get: function () { - return _index.importExpression; - } -}); -Object.defineProperty(exports, "ImportNamespaceSpecifier", { - enumerable: true, - get: function () { - return _index.importNamespaceSpecifier; - } -}); -Object.defineProperty(exports, "ImportSpecifier", { - enumerable: true, - get: function () { - return _index.importSpecifier; - } -}); -Object.defineProperty(exports, "IndexedAccessType", { - enumerable: true, - get: function () { - return _index.indexedAccessType; - } -}); -Object.defineProperty(exports, "InferredPredicate", { - enumerable: true, - get: function () { - return _index.inferredPredicate; - } -}); -Object.defineProperty(exports, "InterfaceDeclaration", { - enumerable: true, - get: function () { - return _index.interfaceDeclaration; - } -}); -Object.defineProperty(exports, "InterfaceExtends", { - enumerable: true, - get: function () { - return _index.interfaceExtends; - } -}); -Object.defineProperty(exports, "InterfaceTypeAnnotation", { - enumerable: true, - get: function () { - return _index.interfaceTypeAnnotation; - } -}); -Object.defineProperty(exports, "InterpreterDirective", { - enumerable: true, - get: function () { - return _index.interpreterDirective; - } -}); -Object.defineProperty(exports, "IntersectionTypeAnnotation", { - enumerable: true, - get: function () { - return _index.intersectionTypeAnnotation; - } -}); -Object.defineProperty(exports, "JSXAttribute", { - enumerable: true, - get: function () { - return _index.jsxAttribute; - } -}); -Object.defineProperty(exports, "JSXClosingElement", { - enumerable: true, - get: function () { - return _index.jsxClosingElement; - } -}); -Object.defineProperty(exports, "JSXClosingFragment", { - enumerable: true, - get: function () { - return _index.jsxClosingFragment; - } -}); -Object.defineProperty(exports, "JSXElement", { - enumerable: true, - get: function () { - return _index.jsxElement; - } -}); -Object.defineProperty(exports, "JSXEmptyExpression", { - enumerable: true, - get: function () { - return _index.jsxEmptyExpression; - } -}); -Object.defineProperty(exports, "JSXExpressionContainer", { - enumerable: true, - get: function () { - return _index.jsxExpressionContainer; - } -}); -Object.defineProperty(exports, "JSXFragment", { - enumerable: true, - get: function () { - return _index.jsxFragment; - } -}); -Object.defineProperty(exports, "JSXIdentifier", { - enumerable: true, - get: function () { - return _index.jsxIdentifier; - } -}); -Object.defineProperty(exports, "JSXMemberExpression", { - enumerable: true, - get: function () { - return _index.jsxMemberExpression; - } -}); -Object.defineProperty(exports, "JSXNamespacedName", { - enumerable: true, - get: function () { - return _index.jsxNamespacedName; - } -}); -Object.defineProperty(exports, "JSXOpeningElement", { - enumerable: true, - get: function () { - return _index.jsxOpeningElement; - } -}); -Object.defineProperty(exports, "JSXOpeningFragment", { - enumerable: true, - get: function () { - return _index.jsxOpeningFragment; - } -}); -Object.defineProperty(exports, "JSXSpreadAttribute", { - enumerable: true, - get: function () { - return _index.jsxSpreadAttribute; - } -}); -Object.defineProperty(exports, "JSXSpreadChild", { - enumerable: true, - get: function () { - return _index.jsxSpreadChild; - } -}); -Object.defineProperty(exports, "JSXText", { - enumerable: true, - get: function () { - return _index.jsxText; - } -}); -Object.defineProperty(exports, "LabeledStatement", { - enumerable: true, - get: function () { - return _index.labeledStatement; - } -}); -Object.defineProperty(exports, "LogicalExpression", { - enumerable: true, - get: function () { - return _index.logicalExpression; - } -}); -Object.defineProperty(exports, "MemberExpression", { - enumerable: true, - get: function () { - return _index.memberExpression; - } -}); -Object.defineProperty(exports, "MetaProperty", { - enumerable: true, - get: function () { - return _index.metaProperty; - } -}); -Object.defineProperty(exports, "MixedTypeAnnotation", { - enumerable: true, - get: function () { - return _index.mixedTypeAnnotation; - } -}); -Object.defineProperty(exports, "ModuleExpression", { - enumerable: true, - get: function () { - return _index.moduleExpression; - } -}); -Object.defineProperty(exports, "NewExpression", { - enumerable: true, - get: function () { - return _index.newExpression; - } -}); -Object.defineProperty(exports, "Noop", { - enumerable: true, - get: function () { - return _index.noop; - } -}); -Object.defineProperty(exports, "NullLiteral", { - enumerable: true, - get: function () { - return _index.nullLiteral; - } -}); -Object.defineProperty(exports, "NullLiteralTypeAnnotation", { - enumerable: true, - get: function () { - return _index.nullLiteralTypeAnnotation; - } -}); -Object.defineProperty(exports, "NullableTypeAnnotation", { - enumerable: true, - get: function () { - return _index.nullableTypeAnnotation; - } -}); -Object.defineProperty(exports, "NumberLiteral", { - enumerable: true, - get: function () { - return _index.numberLiteral; - } -}); -Object.defineProperty(exports, "NumberLiteralTypeAnnotation", { - enumerable: true, - get: function () { - return _index.numberLiteralTypeAnnotation; - } -}); -Object.defineProperty(exports, "NumberTypeAnnotation", { - enumerable: true, - get: function () { - return _index.numberTypeAnnotation; - } -}); -Object.defineProperty(exports, "NumericLiteral", { - enumerable: true, - get: function () { - return _index.numericLiteral; - } -}); -Object.defineProperty(exports, "ObjectExpression", { - enumerable: true, - get: function () { - return _index.objectExpression; - } -}); -Object.defineProperty(exports, "ObjectMethod", { - enumerable: true, - get: function () { - return _index.objectMethod; - } -}); -Object.defineProperty(exports, "ObjectPattern", { - enumerable: true, - get: function () { - return _index.objectPattern; - } -}); -Object.defineProperty(exports, "ObjectProperty", { - enumerable: true, - get: function () { - return _index.objectProperty; - } -}); -Object.defineProperty(exports, "ObjectTypeAnnotation", { - enumerable: true, - get: function () { - return _index.objectTypeAnnotation; - } -}); -Object.defineProperty(exports, "ObjectTypeCallProperty", { - enumerable: true, - get: function () { - return _index.objectTypeCallProperty; - } -}); -Object.defineProperty(exports, "ObjectTypeIndexer", { - enumerable: true, - get: function () { - return _index.objectTypeIndexer; - } -}); -Object.defineProperty(exports, "ObjectTypeInternalSlot", { - enumerable: true, - get: function () { - return _index.objectTypeInternalSlot; - } -}); -Object.defineProperty(exports, "ObjectTypeProperty", { - enumerable: true, - get: function () { - return _index.objectTypeProperty; - } -}); -Object.defineProperty(exports, "ObjectTypeSpreadProperty", { - enumerable: true, - get: function () { - return _index.objectTypeSpreadProperty; - } -}); -Object.defineProperty(exports, "OpaqueType", { - enumerable: true, - get: function () { - return _index.opaqueType; - } -}); -Object.defineProperty(exports, "OptionalCallExpression", { - enumerable: true, - get: function () { - return _index.optionalCallExpression; - } -}); -Object.defineProperty(exports, "OptionalIndexedAccessType", { - enumerable: true, - get: function () { - return _index.optionalIndexedAccessType; - } -}); -Object.defineProperty(exports, "OptionalMemberExpression", { - enumerable: true, - get: function () { - return _index.optionalMemberExpression; - } -}); -Object.defineProperty(exports, "ParenthesizedExpression", { - enumerable: true, - get: function () { - return _index.parenthesizedExpression; - } -}); -Object.defineProperty(exports, "PipelineBareFunction", { - enumerable: true, - get: function () { - return _index.pipelineBareFunction; - } -}); -Object.defineProperty(exports, "PipelinePrimaryTopicReference", { - enumerable: true, - get: function () { - return _index.pipelinePrimaryTopicReference; - } -}); -Object.defineProperty(exports, "PipelineTopicExpression", { - enumerable: true, - get: function () { - return _index.pipelineTopicExpression; - } -}); -Object.defineProperty(exports, "Placeholder", { - enumerable: true, - get: function () { - return _index.placeholder; - } -}); -Object.defineProperty(exports, "PrivateName", { - enumerable: true, - get: function () { - return _index.privateName; - } -}); -Object.defineProperty(exports, "Program", { - enumerable: true, - get: function () { - return _index.program; - } -}); -Object.defineProperty(exports, "QualifiedTypeIdentifier", { - enumerable: true, - get: function () { - return _index.qualifiedTypeIdentifier; - } -}); -Object.defineProperty(exports, "RecordExpression", { - enumerable: true, - get: function () { - return _index.recordExpression; - } -}); -Object.defineProperty(exports, "RegExpLiteral", { - enumerable: true, - get: function () { - return _index.regExpLiteral; - } -}); -Object.defineProperty(exports, "RegexLiteral", { - enumerable: true, - get: function () { - return _index.regexLiteral; - } -}); -Object.defineProperty(exports, "RestElement", { - enumerable: true, - get: function () { - return _index.restElement; - } -}); -Object.defineProperty(exports, "RestProperty", { - enumerable: true, - get: function () { - return _index.restProperty; - } -}); -Object.defineProperty(exports, "ReturnStatement", { - enumerable: true, - get: function () { - return _index.returnStatement; - } -}); -Object.defineProperty(exports, "SequenceExpression", { - enumerable: true, - get: function () { - return _index.sequenceExpression; - } -}); -Object.defineProperty(exports, "SpreadElement", { - enumerable: true, - get: function () { - return _index.spreadElement; - } -}); -Object.defineProperty(exports, "SpreadProperty", { - enumerable: true, - get: function () { - return _index.spreadProperty; - } -}); -Object.defineProperty(exports, "StaticBlock", { - enumerable: true, - get: function () { - return _index.staticBlock; - } -}); -Object.defineProperty(exports, "StringLiteral", { - enumerable: true, - get: function () { - return _index.stringLiteral; - } -}); -Object.defineProperty(exports, "StringLiteralTypeAnnotation", { - enumerable: true, - get: function () { - return _index.stringLiteralTypeAnnotation; - } -}); -Object.defineProperty(exports, "StringTypeAnnotation", { - enumerable: true, - get: function () { - return _index.stringTypeAnnotation; - } -}); -Object.defineProperty(exports, "Super", { - enumerable: true, - get: function () { - return _index.super; - } -}); -Object.defineProperty(exports, "SwitchCase", { - enumerable: true, - get: function () { - return _index.switchCase; - } -}); -Object.defineProperty(exports, "SwitchStatement", { - enumerable: true, - get: function () { - return _index.switchStatement; - } -}); -Object.defineProperty(exports, "SymbolTypeAnnotation", { - enumerable: true, - get: function () { - return _index.symbolTypeAnnotation; - } -}); -Object.defineProperty(exports, "TSAnyKeyword", { - enumerable: true, - get: function () { - return _index.tsAnyKeyword; - } -}); -Object.defineProperty(exports, "TSArrayType", { - enumerable: true, - get: function () { - return _index.tsArrayType; - } -}); -Object.defineProperty(exports, "TSAsExpression", { - enumerable: true, - get: function () { - return _index.tsAsExpression; - } -}); -Object.defineProperty(exports, "TSBigIntKeyword", { - enumerable: true, - get: function () { - return _index.tsBigIntKeyword; - } -}); -Object.defineProperty(exports, "TSBooleanKeyword", { - enumerable: true, - get: function () { - return _index.tsBooleanKeyword; - } -}); -Object.defineProperty(exports, "TSCallSignatureDeclaration", { - enumerable: true, - get: function () { - return _index.tsCallSignatureDeclaration; - } -}); -Object.defineProperty(exports, "TSConditionalType", { - enumerable: true, - get: function () { - return _index.tsConditionalType; - } -}); -Object.defineProperty(exports, "TSConstructSignatureDeclaration", { - enumerable: true, - get: function () { - return _index.tsConstructSignatureDeclaration; - } -}); -Object.defineProperty(exports, "TSConstructorType", { - enumerable: true, - get: function () { - return _index.tsConstructorType; - } -}); -Object.defineProperty(exports, "TSDeclareFunction", { - enumerable: true, - get: function () { - return _index.tsDeclareFunction; - } -}); -Object.defineProperty(exports, "TSDeclareMethod", { - enumerable: true, - get: function () { - return _index.tsDeclareMethod; - } -}); -Object.defineProperty(exports, "TSEnumDeclaration", { - enumerable: true, - get: function () { - return _index.tsEnumDeclaration; - } -}); -Object.defineProperty(exports, "TSEnumMember", { - enumerable: true, - get: function () { - return _index.tsEnumMember; - } -}); -Object.defineProperty(exports, "TSExportAssignment", { - enumerable: true, - get: function () { - return _index.tsExportAssignment; - } -}); -Object.defineProperty(exports, "TSExpressionWithTypeArguments", { - enumerable: true, - get: function () { - return _index.tsExpressionWithTypeArguments; - } -}); -Object.defineProperty(exports, "TSExternalModuleReference", { - enumerable: true, - get: function () { - return _index.tsExternalModuleReference; - } -}); -Object.defineProperty(exports, "TSFunctionType", { - enumerable: true, - get: function () { - return _index.tsFunctionType; - } -}); -Object.defineProperty(exports, "TSImportEqualsDeclaration", { - enumerable: true, - get: function () { - return _index.tsImportEqualsDeclaration; - } -}); -Object.defineProperty(exports, "TSImportType", { - enumerable: true, - get: function () { - return _index.tsImportType; - } -}); -Object.defineProperty(exports, "TSIndexSignature", { - enumerable: true, - get: function () { - return _index.tsIndexSignature; - } -}); -Object.defineProperty(exports, "TSIndexedAccessType", { - enumerable: true, - get: function () { - return _index.tsIndexedAccessType; - } -}); -Object.defineProperty(exports, "TSInferType", { - enumerable: true, - get: function () { - return _index.tsInferType; - } -}); -Object.defineProperty(exports, "TSInstantiationExpression", { - enumerable: true, - get: function () { - return _index.tsInstantiationExpression; - } -}); -Object.defineProperty(exports, "TSInterfaceBody", { - enumerable: true, - get: function () { - return _index.tsInterfaceBody; - } -}); -Object.defineProperty(exports, "TSInterfaceDeclaration", { - enumerable: true, - get: function () { - return _index.tsInterfaceDeclaration; - } -}); -Object.defineProperty(exports, "TSIntersectionType", { - enumerable: true, - get: function () { - return _index.tsIntersectionType; - } -}); -Object.defineProperty(exports, "TSIntrinsicKeyword", { - enumerable: true, - get: function () { - return _index.tsIntrinsicKeyword; - } -}); -Object.defineProperty(exports, "TSLiteralType", { - enumerable: true, - get: function () { - return _index.tsLiteralType; - } -}); -Object.defineProperty(exports, "TSMappedType", { - enumerable: true, - get: function () { - return _index.tsMappedType; - } -}); -Object.defineProperty(exports, "TSMethodSignature", { - enumerable: true, - get: function () { - return _index.tsMethodSignature; - } -}); -Object.defineProperty(exports, "TSModuleBlock", { - enumerable: true, - get: function () { - return _index.tsModuleBlock; - } -}); -Object.defineProperty(exports, "TSModuleDeclaration", { - enumerable: true, - get: function () { - return _index.tsModuleDeclaration; - } -}); -Object.defineProperty(exports, "TSNamedTupleMember", { - enumerable: true, - get: function () { - return _index.tsNamedTupleMember; - } -}); -Object.defineProperty(exports, "TSNamespaceExportDeclaration", { - enumerable: true, - get: function () { - return _index.tsNamespaceExportDeclaration; - } -}); -Object.defineProperty(exports, "TSNeverKeyword", { - enumerable: true, - get: function () { - return _index.tsNeverKeyword; - } -}); -Object.defineProperty(exports, "TSNonNullExpression", { - enumerable: true, - get: function () { - return _index.tsNonNullExpression; - } -}); -Object.defineProperty(exports, "TSNullKeyword", { - enumerable: true, - get: function () { - return _index.tsNullKeyword; - } -}); -Object.defineProperty(exports, "TSNumberKeyword", { - enumerable: true, - get: function () { - return _index.tsNumberKeyword; - } -}); -Object.defineProperty(exports, "TSObjectKeyword", { - enumerable: true, - get: function () { - return _index.tsObjectKeyword; - } -}); -Object.defineProperty(exports, "TSOptionalType", { - enumerable: true, - get: function () { - return _index.tsOptionalType; - } -}); -Object.defineProperty(exports, "TSParameterProperty", { - enumerable: true, - get: function () { - return _index.tsParameterProperty; - } -}); -Object.defineProperty(exports, "TSParenthesizedType", { - enumerable: true, - get: function () { - return _index.tsParenthesizedType; - } -}); -Object.defineProperty(exports, "TSPropertySignature", { - enumerable: true, - get: function () { - return _index.tsPropertySignature; - } -}); -Object.defineProperty(exports, "TSQualifiedName", { - enumerable: true, - get: function () { - return _index.tsQualifiedName; - } -}); -Object.defineProperty(exports, "TSRestType", { - enumerable: true, - get: function () { - return _index.tsRestType; - } -}); -Object.defineProperty(exports, "TSSatisfiesExpression", { - enumerable: true, - get: function () { - return _index.tsSatisfiesExpression; - } -}); -Object.defineProperty(exports, "TSStringKeyword", { - enumerable: true, - get: function () { - return _index.tsStringKeyword; - } -}); -Object.defineProperty(exports, "TSSymbolKeyword", { - enumerable: true, - get: function () { - return _index.tsSymbolKeyword; - } -}); -Object.defineProperty(exports, "TSThisType", { - enumerable: true, - get: function () { - return _index.tsThisType; - } -}); -Object.defineProperty(exports, "TSTupleType", { - enumerable: true, - get: function () { - return _index.tsTupleType; - } -}); -Object.defineProperty(exports, "TSTypeAliasDeclaration", { - enumerable: true, - get: function () { - return _index.tsTypeAliasDeclaration; - } -}); -Object.defineProperty(exports, "TSTypeAnnotation", { - enumerable: true, - get: function () { - return _index.tsTypeAnnotation; - } -}); -Object.defineProperty(exports, "TSTypeAssertion", { - enumerable: true, - get: function () { - return _index.tsTypeAssertion; - } -}); -Object.defineProperty(exports, "TSTypeLiteral", { - enumerable: true, - get: function () { - return _index.tsTypeLiteral; - } -}); -Object.defineProperty(exports, "TSTypeOperator", { - enumerable: true, - get: function () { - return _index.tsTypeOperator; - } -}); -Object.defineProperty(exports, "TSTypeParameter", { - enumerable: true, - get: function () { - return _index.tsTypeParameter; - } -}); -Object.defineProperty(exports, "TSTypeParameterDeclaration", { - enumerable: true, - get: function () { - return _index.tsTypeParameterDeclaration; - } -}); -Object.defineProperty(exports, "TSTypeParameterInstantiation", { - enumerable: true, - get: function () { - return _index.tsTypeParameterInstantiation; - } -}); -Object.defineProperty(exports, "TSTypePredicate", { - enumerable: true, - get: function () { - return _index.tsTypePredicate; - } -}); -Object.defineProperty(exports, "TSTypeQuery", { - enumerable: true, - get: function () { - return _index.tsTypeQuery; - } -}); -Object.defineProperty(exports, "TSTypeReference", { - enumerable: true, - get: function () { - return _index.tsTypeReference; - } -}); -Object.defineProperty(exports, "TSUndefinedKeyword", { - enumerable: true, - get: function () { - return _index.tsUndefinedKeyword; - } -}); -Object.defineProperty(exports, "TSUnionType", { - enumerable: true, - get: function () { - return _index.tsUnionType; - } -}); -Object.defineProperty(exports, "TSUnknownKeyword", { - enumerable: true, - get: function () { - return _index.tsUnknownKeyword; - } -}); -Object.defineProperty(exports, "TSVoidKeyword", { - enumerable: true, - get: function () { - return _index.tsVoidKeyword; - } -}); -Object.defineProperty(exports, "TaggedTemplateExpression", { - enumerable: true, - get: function () { - return _index.taggedTemplateExpression; - } -}); -Object.defineProperty(exports, "TemplateElement", { - enumerable: true, - get: function () { - return _index.templateElement; - } -}); -Object.defineProperty(exports, "TemplateLiteral", { - enumerable: true, - get: function () { - return _index.templateLiteral; - } -}); -Object.defineProperty(exports, "ThisExpression", { - enumerable: true, - get: function () { - return _index.thisExpression; - } -}); -Object.defineProperty(exports, "ThisTypeAnnotation", { - enumerable: true, - get: function () { - return _index.thisTypeAnnotation; - } -}); -Object.defineProperty(exports, "ThrowStatement", { - enumerable: true, - get: function () { - return _index.throwStatement; - } -}); -Object.defineProperty(exports, "TopicReference", { - enumerable: true, - get: function () { - return _index.topicReference; - } -}); -Object.defineProperty(exports, "TryStatement", { - enumerable: true, - get: function () { - return _index.tryStatement; - } -}); -Object.defineProperty(exports, "TupleExpression", { - enumerable: true, - get: function () { - return _index.tupleExpression; - } -}); -Object.defineProperty(exports, "TupleTypeAnnotation", { - enumerable: true, - get: function () { - return _index.tupleTypeAnnotation; - } -}); -Object.defineProperty(exports, "TypeAlias", { - enumerable: true, - get: function () { - return _index.typeAlias; - } -}); -Object.defineProperty(exports, "TypeAnnotation", { - enumerable: true, - get: function () { - return _index.typeAnnotation; - } -}); -Object.defineProperty(exports, "TypeCastExpression", { - enumerable: true, - get: function () { - return _index.typeCastExpression; - } -}); -Object.defineProperty(exports, "TypeParameter", { - enumerable: true, - get: function () { - return _index.typeParameter; - } -}); -Object.defineProperty(exports, "TypeParameterDeclaration", { - enumerable: true, - get: function () { - return _index.typeParameterDeclaration; - } -}); -Object.defineProperty(exports, "TypeParameterInstantiation", { - enumerable: true, - get: function () { - return _index.typeParameterInstantiation; - } -}); -Object.defineProperty(exports, "TypeofTypeAnnotation", { - enumerable: true, - get: function () { - return _index.typeofTypeAnnotation; - } -}); -Object.defineProperty(exports, "UnaryExpression", { - enumerable: true, - get: function () { - return _index.unaryExpression; - } -}); -Object.defineProperty(exports, "UnionTypeAnnotation", { - enumerable: true, - get: function () { - return _index.unionTypeAnnotation; - } -}); -Object.defineProperty(exports, "UpdateExpression", { - enumerable: true, - get: function () { - return _index.updateExpression; - } -}); -Object.defineProperty(exports, "V8IntrinsicIdentifier", { - enumerable: true, - get: function () { - return _index.v8IntrinsicIdentifier; - } -}); -Object.defineProperty(exports, "VariableDeclaration", { - enumerable: true, - get: function () { - return _index.variableDeclaration; - } -}); -Object.defineProperty(exports, "VariableDeclarator", { - enumerable: true, - get: function () { - return _index.variableDeclarator; - } -}); -Object.defineProperty(exports, "Variance", { - enumerable: true, - get: function () { - return _index.variance; - } -}); -Object.defineProperty(exports, "VoidTypeAnnotation", { - enumerable: true, - get: function () { - return _index.voidTypeAnnotation; - } -}); -Object.defineProperty(exports, "WhileStatement", { - enumerable: true, - get: function () { - return _index.whileStatement; - } -}); -Object.defineProperty(exports, "WithStatement", { - enumerable: true, - get: function () { - return _index.withStatement; - } -}); -Object.defineProperty(exports, "YieldExpression", { - enumerable: true, - get: function () { - return _index.yieldExpression; - } -}); -var _index = require("./index.js"); - -//# sourceMappingURL=uppercase.js.map diff --git a/tools/eslint/node_modules/@babel/types/lib/builders/productions.js b/tools/eslint/node_modules/@babel/types/lib/builders/productions.js deleted file mode 100644 index 6e64717f09c3c0..00000000000000 --- a/tools/eslint/node_modules/@babel/types/lib/builders/productions.js +++ /dev/null @@ -1,12 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.buildUndefinedNode = buildUndefinedNode; -var _index = require("./generated/index.js"); -function buildUndefinedNode() { - return (0, _index.unaryExpression)("void", (0, _index.numericLiteral)(0), true); -} - -//# sourceMappingURL=productions.js.map diff --git a/tools/eslint/node_modules/@babel/types/lib/builders/react/buildChildren.js b/tools/eslint/node_modules/@babel/types/lib/builders/react/buildChildren.js deleted file mode 100644 index 22dd95375348ec..00000000000000 --- a/tools/eslint/node_modules/@babel/types/lib/builders/react/buildChildren.js +++ /dev/null @@ -1,24 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.default = buildChildren; -var _index = require("../../validators/generated/index.js"); -var _cleanJSXElementLiteralChild = require("../../utils/react/cleanJSXElementLiteralChild.js"); -function buildChildren(node) { - const elements = []; - for (let i = 0; i < node.children.length; i++) { - let child = node.children[i]; - if ((0, _index.isJSXText)(child)) { - (0, _cleanJSXElementLiteralChild.default)(child, elements); - continue; - } - if ((0, _index.isJSXExpressionContainer)(child)) child = child.expression; - if ((0, _index.isJSXEmptyExpression)(child)) continue; - elements.push(child); - } - return elements; -} - -//# sourceMappingURL=buildChildren.js.map diff --git a/tools/eslint/node_modules/@babel/types/lib/builders/typescript/createTSUnionType.js b/tools/eslint/node_modules/@babel/types/lib/builders/typescript/createTSUnionType.js deleted file mode 100644 index 6a38530905abfe..00000000000000 --- a/tools/eslint/node_modules/@babel/types/lib/builders/typescript/createTSUnionType.js +++ /dev/null @@ -1,22 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.default = createTSUnionType; -var _index = require("../generated/index.js"); -var _removeTypeDuplicates = require("../../modifications/typescript/removeTypeDuplicates.js"); -var _index2 = require("../../validators/generated/index.js"); -function createTSUnionType(typeAnnotations) { - const types = typeAnnotations.map(type => { - return (0, _index2.isTSTypeAnnotation)(type) ? type.typeAnnotation : type; - }); - const flattened = (0, _removeTypeDuplicates.default)(types); - if (flattened.length === 1) { - return flattened[0]; - } else { - return (0, _index.tsUnionType)(flattened); - } -} - -//# sourceMappingURL=createTSUnionType.js.map diff --git a/tools/eslint/node_modules/@babel/types/lib/builders/validateNode.js b/tools/eslint/node_modules/@babel/types/lib/builders/validateNode.js deleted file mode 100644 index d7f6048c3a1d45..00000000000000 --- a/tools/eslint/node_modules/@babel/types/lib/builders/validateNode.js +++ /dev/null @@ -1,17 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.default = validateNode; -var _validate = require("../validators/validate.js"); -var _index = require("../index.js"); -function validateNode(node) { - const keys = _index.BUILDER_KEYS[node.type]; - for (const key of keys) { - (0, _validate.default)(node, key, node[key]); - } - return node; -} - -//# sourceMappingURL=validateNode.js.map diff --git a/tools/eslint/node_modules/@babel/types/lib/clone/clone.js b/tools/eslint/node_modules/@babel/types/lib/clone/clone.js deleted file mode 100644 index f6a31dcaa3ff8a..00000000000000 --- a/tools/eslint/node_modules/@babel/types/lib/clone/clone.js +++ /dev/null @@ -1,12 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.default = clone; -var _cloneNode = require("./cloneNode.js"); -function clone(node) { - return (0, _cloneNode.default)(node, false); -} - -//# sourceMappingURL=clone.js.map diff --git a/tools/eslint/node_modules/@babel/types/lib/clone/cloneDeep.js b/tools/eslint/node_modules/@babel/types/lib/clone/cloneDeep.js deleted file mode 100644 index a30a6e8d73ee00..00000000000000 --- a/tools/eslint/node_modules/@babel/types/lib/clone/cloneDeep.js +++ /dev/null @@ -1,12 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.default = cloneDeep; -var _cloneNode = require("./cloneNode.js"); -function cloneDeep(node) { - return (0, _cloneNode.default)(node); -} - -//# sourceMappingURL=cloneDeep.js.map diff --git a/tools/eslint/node_modules/@babel/types/lib/clone/cloneDeepWithoutLoc.js b/tools/eslint/node_modules/@babel/types/lib/clone/cloneDeepWithoutLoc.js deleted file mode 100644 index e2dfd7558516e8..00000000000000 --- a/tools/eslint/node_modules/@babel/types/lib/clone/cloneDeepWithoutLoc.js +++ /dev/null @@ -1,12 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.default = cloneDeepWithoutLoc; -var _cloneNode = require("./cloneNode.js"); -function cloneDeepWithoutLoc(node) { - return (0, _cloneNode.default)(node, true, true); -} - -//# sourceMappingURL=cloneDeepWithoutLoc.js.map diff --git a/tools/eslint/node_modules/@babel/types/lib/clone/cloneNode.js b/tools/eslint/node_modules/@babel/types/lib/clone/cloneNode.js deleted file mode 100644 index 851004806bc3af..00000000000000 --- a/tools/eslint/node_modules/@babel/types/lib/clone/cloneNode.js +++ /dev/null @@ -1,104 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.default = cloneNode; -var _index = require("../definitions/index.js"); -var _index2 = require("../validators/generated/index.js"); -const { - hasOwn -} = { - hasOwn: Function.call.bind(Object.prototype.hasOwnProperty) -}; -function cloneIfNode(obj, deep, withoutLoc, commentsCache) { - if (obj && typeof obj.type === "string") { - return cloneNodeInternal(obj, deep, withoutLoc, commentsCache); - } - return obj; -} -function cloneIfNodeOrArray(obj, deep, withoutLoc, commentsCache) { - if (Array.isArray(obj)) { - return obj.map(node => cloneIfNode(node, deep, withoutLoc, commentsCache)); - } - return cloneIfNode(obj, deep, withoutLoc, commentsCache); -} -function cloneNode(node, deep = true, withoutLoc = false) { - return cloneNodeInternal(node, deep, withoutLoc, new Map()); -} -function cloneNodeInternal(node, deep = true, withoutLoc = false, commentsCache) { - if (!node) return node; - const { - type - } = node; - const newNode = { - type: node.type - }; - if ((0, _index2.isIdentifier)(node)) { - newNode.name = node.name; - if (hasOwn(node, "optional") && typeof node.optional === "boolean") { - newNode.optional = node.optional; - } - if (hasOwn(node, "typeAnnotation")) { - newNode.typeAnnotation = deep ? cloneIfNodeOrArray(node.typeAnnotation, true, withoutLoc, commentsCache) : node.typeAnnotation; - } - } else if (!hasOwn(_index.NODE_FIELDS, type)) { - throw new Error(`Unknown node type: "${type}"`); - } else { - for (const field of Object.keys(_index.NODE_FIELDS[type])) { - if (hasOwn(node, field)) { - if (deep) { - newNode[field] = (0, _index2.isFile)(node) && field === "comments" ? maybeCloneComments(node.comments, deep, withoutLoc, commentsCache) : cloneIfNodeOrArray(node[field], true, withoutLoc, commentsCache); - } else { - newNode[field] = node[field]; - } - } - } - } - if (hasOwn(node, "loc")) { - if (withoutLoc) { - newNode.loc = null; - } else { - newNode.loc = node.loc; - } - } - if (hasOwn(node, "leadingComments")) { - newNode.leadingComments = maybeCloneComments(node.leadingComments, deep, withoutLoc, commentsCache); - } - if (hasOwn(node, "innerComments")) { - newNode.innerComments = maybeCloneComments(node.innerComments, deep, withoutLoc, commentsCache); - } - if (hasOwn(node, "trailingComments")) { - newNode.trailingComments = maybeCloneComments(node.trailingComments, deep, withoutLoc, commentsCache); - } - if (hasOwn(node, "extra")) { - newNode.extra = Object.assign({}, node.extra); - } - return newNode; -} -function maybeCloneComments(comments, deep, withoutLoc, commentsCache) { - if (!comments || !deep) { - return comments; - } - return comments.map(comment => { - const cache = commentsCache.get(comment); - if (cache) return cache; - const { - type, - value, - loc - } = comment; - const ret = { - type, - value, - loc - }; - if (withoutLoc) { - ret.loc = null; - } - commentsCache.set(comment, ret); - return ret; - }); -} - -//# sourceMappingURL=cloneNode.js.map diff --git a/tools/eslint/node_modules/@babel/types/lib/clone/cloneWithoutLoc.js b/tools/eslint/node_modules/@babel/types/lib/clone/cloneWithoutLoc.js deleted file mode 100644 index 95aeddc7c9f59f..00000000000000 --- a/tools/eslint/node_modules/@babel/types/lib/clone/cloneWithoutLoc.js +++ /dev/null @@ -1,12 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.default = cloneWithoutLoc; -var _cloneNode = require("./cloneNode.js"); -function cloneWithoutLoc(node) { - return (0, _cloneNode.default)(node, false, true); -} - -//# sourceMappingURL=cloneWithoutLoc.js.map diff --git a/tools/eslint/node_modules/@babel/types/lib/comments/addComment.js b/tools/eslint/node_modules/@babel/types/lib/comments/addComment.js deleted file mode 100644 index 4e4eb48c11fc9c..00000000000000 --- a/tools/eslint/node_modules/@babel/types/lib/comments/addComment.js +++ /dev/null @@ -1,15 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.default = addComment; -var _addComments = require("./addComments.js"); -function addComment(node, type, content, line) { - return (0, _addComments.default)(node, type, [{ - type: line ? "CommentLine" : "CommentBlock", - value: content - }]); -} - -//# sourceMappingURL=addComment.js.map diff --git a/tools/eslint/node_modules/@babel/types/lib/comments/addComments.js b/tools/eslint/node_modules/@babel/types/lib/comments/addComments.js deleted file mode 100644 index fce0bdaffa514b..00000000000000 --- a/tools/eslint/node_modules/@babel/types/lib/comments/addComments.js +++ /dev/null @@ -1,22 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.default = addComments; -function addComments(node, type, comments) { - if (!comments || !node) return node; - const key = `${type}Comments`; - if (node[key]) { - if (type === "leading") { - node[key] = comments.concat(node[key]); - } else { - node[key].push(...comments); - } - } else { - node[key] = comments; - } - return node; -} - -//# sourceMappingURL=addComments.js.map diff --git a/tools/eslint/node_modules/@babel/types/lib/comments/inheritInnerComments.js b/tools/eslint/node_modules/@babel/types/lib/comments/inheritInnerComments.js deleted file mode 100644 index 76f1d68b60fbd0..00000000000000 --- a/tools/eslint/node_modules/@babel/types/lib/comments/inheritInnerComments.js +++ /dev/null @@ -1,12 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.default = inheritInnerComments; -var _inherit = require("../utils/inherit.js"); -function inheritInnerComments(child, parent) { - (0, _inherit.default)("innerComments", child, parent); -} - -//# sourceMappingURL=inheritInnerComments.js.map diff --git a/tools/eslint/node_modules/@babel/types/lib/comments/inheritLeadingComments.js b/tools/eslint/node_modules/@babel/types/lib/comments/inheritLeadingComments.js deleted file mode 100644 index 8b476ba4c0beef..00000000000000 --- a/tools/eslint/node_modules/@babel/types/lib/comments/inheritLeadingComments.js +++ /dev/null @@ -1,12 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.default = inheritLeadingComments; -var _inherit = require("../utils/inherit.js"); -function inheritLeadingComments(child, parent) { - (0, _inherit.default)("leadingComments", child, parent); -} - -//# sourceMappingURL=inheritLeadingComments.js.map diff --git a/tools/eslint/node_modules/@babel/types/lib/comments/inheritTrailingComments.js b/tools/eslint/node_modules/@babel/types/lib/comments/inheritTrailingComments.js deleted file mode 100644 index 23574d4c2d88a0..00000000000000 --- a/tools/eslint/node_modules/@babel/types/lib/comments/inheritTrailingComments.js +++ /dev/null @@ -1,12 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.default = inheritTrailingComments; -var _inherit = require("../utils/inherit.js"); -function inheritTrailingComments(child, parent) { - (0, _inherit.default)("trailingComments", child, parent); -} - -//# sourceMappingURL=inheritTrailingComments.js.map diff --git a/tools/eslint/node_modules/@babel/types/lib/comments/inheritsComments.js b/tools/eslint/node_modules/@babel/types/lib/comments/inheritsComments.js deleted file mode 100644 index 6c9c61c581d4d1..00000000000000 --- a/tools/eslint/node_modules/@babel/types/lib/comments/inheritsComments.js +++ /dev/null @@ -1,17 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.default = inheritsComments; -var _inheritTrailingComments = require("./inheritTrailingComments.js"); -var _inheritLeadingComments = require("./inheritLeadingComments.js"); -var _inheritInnerComments = require("./inheritInnerComments.js"); -function inheritsComments(child, parent) { - (0, _inheritTrailingComments.default)(child, parent); - (0, _inheritLeadingComments.default)(child, parent); - (0, _inheritInnerComments.default)(child, parent); - return child; -} - -//# sourceMappingURL=inheritsComments.js.map diff --git a/tools/eslint/node_modules/@babel/types/lib/comments/removeComments.js b/tools/eslint/node_modules/@babel/types/lib/comments/removeComments.js deleted file mode 100644 index 36044119ce40e5..00000000000000 --- a/tools/eslint/node_modules/@babel/types/lib/comments/removeComments.js +++ /dev/null @@ -1,15 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.default = removeComments; -var _index = require("../constants/index.js"); -function removeComments(node) { - _index.COMMENT_KEYS.forEach(key => { - node[key] = null; - }); - return node; -} - -//# sourceMappingURL=removeComments.js.map diff --git a/tools/eslint/node_modules/@babel/types/lib/constants/generated/index.js b/tools/eslint/node_modules/@babel/types/lib/constants/generated/index.js deleted file mode 100644 index 9dbb33214b864f..00000000000000 --- a/tools/eslint/node_modules/@babel/types/lib/constants/generated/index.js +++ /dev/null @@ -1,59 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.WHILE_TYPES = exports.USERWHITESPACABLE_TYPES = exports.UNARYLIKE_TYPES = exports.TYPESCRIPT_TYPES = exports.TSTYPE_TYPES = exports.TSTYPEELEMENT_TYPES = exports.TSENTITYNAME_TYPES = exports.TSBASETYPE_TYPES = exports.TERMINATORLESS_TYPES = exports.STATEMENT_TYPES = exports.STANDARDIZED_TYPES = exports.SCOPABLE_TYPES = exports.PUREISH_TYPES = exports.PROPERTY_TYPES = exports.PRIVATE_TYPES = exports.PATTERN_TYPES = exports.PATTERNLIKE_TYPES = exports.OBJECTMEMBER_TYPES = exports.MODULESPECIFIER_TYPES = exports.MODULEDECLARATION_TYPES = exports.MISCELLANEOUS_TYPES = exports.METHOD_TYPES = exports.LVAL_TYPES = exports.LOOP_TYPES = exports.LITERAL_TYPES = exports.JSX_TYPES = exports.IMPORTOREXPORTDECLARATION_TYPES = exports.IMMUTABLE_TYPES = exports.FUNCTION_TYPES = exports.FUNCTIONPARENT_TYPES = exports.FOR_TYPES = exports.FORXSTATEMENT_TYPES = exports.FLOW_TYPES = exports.FLOWTYPE_TYPES = exports.FLOWPREDICATE_TYPES = exports.FLOWDECLARATION_TYPES = exports.FLOWBASEANNOTATION_TYPES = exports.EXPRESSION_TYPES = exports.EXPRESSIONWRAPPER_TYPES = exports.EXPORTDECLARATION_TYPES = exports.ENUMMEMBER_TYPES = exports.ENUMBODY_TYPES = exports.DECLARATION_TYPES = exports.CONDITIONAL_TYPES = exports.COMPLETIONSTATEMENT_TYPES = exports.CLASS_TYPES = exports.BLOCK_TYPES = exports.BLOCKPARENT_TYPES = exports.BINARY_TYPES = exports.ACCESSOR_TYPES = void 0; -var _index = require("../../definitions/index.js"); -const STANDARDIZED_TYPES = exports.STANDARDIZED_TYPES = _index.FLIPPED_ALIAS_KEYS["Standardized"]; -const EXPRESSION_TYPES = exports.EXPRESSION_TYPES = _index.FLIPPED_ALIAS_KEYS["Expression"]; -const BINARY_TYPES = exports.BINARY_TYPES = _index.FLIPPED_ALIAS_KEYS["Binary"]; -const SCOPABLE_TYPES = exports.SCOPABLE_TYPES = _index.FLIPPED_ALIAS_KEYS["Scopable"]; -const BLOCKPARENT_TYPES = exports.BLOCKPARENT_TYPES = _index.FLIPPED_ALIAS_KEYS["BlockParent"]; -const BLOCK_TYPES = exports.BLOCK_TYPES = _index.FLIPPED_ALIAS_KEYS["Block"]; -const STATEMENT_TYPES = exports.STATEMENT_TYPES = _index.FLIPPED_ALIAS_KEYS["Statement"]; -const TERMINATORLESS_TYPES = exports.TERMINATORLESS_TYPES = _index.FLIPPED_ALIAS_KEYS["Terminatorless"]; -const COMPLETIONSTATEMENT_TYPES = exports.COMPLETIONSTATEMENT_TYPES = _index.FLIPPED_ALIAS_KEYS["CompletionStatement"]; -const CONDITIONAL_TYPES = exports.CONDITIONAL_TYPES = _index.FLIPPED_ALIAS_KEYS["Conditional"]; -const LOOP_TYPES = exports.LOOP_TYPES = _index.FLIPPED_ALIAS_KEYS["Loop"]; -const WHILE_TYPES = exports.WHILE_TYPES = _index.FLIPPED_ALIAS_KEYS["While"]; -const EXPRESSIONWRAPPER_TYPES = exports.EXPRESSIONWRAPPER_TYPES = _index.FLIPPED_ALIAS_KEYS["ExpressionWrapper"]; -const FOR_TYPES = exports.FOR_TYPES = _index.FLIPPED_ALIAS_KEYS["For"]; -const FORXSTATEMENT_TYPES = exports.FORXSTATEMENT_TYPES = _index.FLIPPED_ALIAS_KEYS["ForXStatement"]; -const FUNCTION_TYPES = exports.FUNCTION_TYPES = _index.FLIPPED_ALIAS_KEYS["Function"]; -const FUNCTIONPARENT_TYPES = exports.FUNCTIONPARENT_TYPES = _index.FLIPPED_ALIAS_KEYS["FunctionParent"]; -const PUREISH_TYPES = exports.PUREISH_TYPES = _index.FLIPPED_ALIAS_KEYS["Pureish"]; -const DECLARATION_TYPES = exports.DECLARATION_TYPES = _index.FLIPPED_ALIAS_KEYS["Declaration"]; -const PATTERNLIKE_TYPES = exports.PATTERNLIKE_TYPES = _index.FLIPPED_ALIAS_KEYS["PatternLike"]; -const LVAL_TYPES = exports.LVAL_TYPES = _index.FLIPPED_ALIAS_KEYS["LVal"]; -const TSENTITYNAME_TYPES = exports.TSENTITYNAME_TYPES = _index.FLIPPED_ALIAS_KEYS["TSEntityName"]; -const LITERAL_TYPES = exports.LITERAL_TYPES = _index.FLIPPED_ALIAS_KEYS["Literal"]; -const IMMUTABLE_TYPES = exports.IMMUTABLE_TYPES = _index.FLIPPED_ALIAS_KEYS["Immutable"]; -const USERWHITESPACABLE_TYPES = exports.USERWHITESPACABLE_TYPES = _index.FLIPPED_ALIAS_KEYS["UserWhitespacable"]; -const METHOD_TYPES = exports.METHOD_TYPES = _index.FLIPPED_ALIAS_KEYS["Method"]; -const OBJECTMEMBER_TYPES = exports.OBJECTMEMBER_TYPES = _index.FLIPPED_ALIAS_KEYS["ObjectMember"]; -const PROPERTY_TYPES = exports.PROPERTY_TYPES = _index.FLIPPED_ALIAS_KEYS["Property"]; -const UNARYLIKE_TYPES = exports.UNARYLIKE_TYPES = _index.FLIPPED_ALIAS_KEYS["UnaryLike"]; -const PATTERN_TYPES = exports.PATTERN_TYPES = _index.FLIPPED_ALIAS_KEYS["Pattern"]; -const CLASS_TYPES = exports.CLASS_TYPES = _index.FLIPPED_ALIAS_KEYS["Class"]; -const IMPORTOREXPORTDECLARATION_TYPES = exports.IMPORTOREXPORTDECLARATION_TYPES = _index.FLIPPED_ALIAS_KEYS["ImportOrExportDeclaration"]; -const EXPORTDECLARATION_TYPES = exports.EXPORTDECLARATION_TYPES = _index.FLIPPED_ALIAS_KEYS["ExportDeclaration"]; -const MODULESPECIFIER_TYPES = exports.MODULESPECIFIER_TYPES = _index.FLIPPED_ALIAS_KEYS["ModuleSpecifier"]; -const ACCESSOR_TYPES = exports.ACCESSOR_TYPES = _index.FLIPPED_ALIAS_KEYS["Accessor"]; -const PRIVATE_TYPES = exports.PRIVATE_TYPES = _index.FLIPPED_ALIAS_KEYS["Private"]; -const FLOW_TYPES = exports.FLOW_TYPES = _index.FLIPPED_ALIAS_KEYS["Flow"]; -const FLOWTYPE_TYPES = exports.FLOWTYPE_TYPES = _index.FLIPPED_ALIAS_KEYS["FlowType"]; -const FLOWBASEANNOTATION_TYPES = exports.FLOWBASEANNOTATION_TYPES = _index.FLIPPED_ALIAS_KEYS["FlowBaseAnnotation"]; -const FLOWDECLARATION_TYPES = exports.FLOWDECLARATION_TYPES = _index.FLIPPED_ALIAS_KEYS["FlowDeclaration"]; -const FLOWPREDICATE_TYPES = exports.FLOWPREDICATE_TYPES = _index.FLIPPED_ALIAS_KEYS["FlowPredicate"]; -const ENUMBODY_TYPES = exports.ENUMBODY_TYPES = _index.FLIPPED_ALIAS_KEYS["EnumBody"]; -const ENUMMEMBER_TYPES = exports.ENUMMEMBER_TYPES = _index.FLIPPED_ALIAS_KEYS["EnumMember"]; -const JSX_TYPES = exports.JSX_TYPES = _index.FLIPPED_ALIAS_KEYS["JSX"]; -const MISCELLANEOUS_TYPES = exports.MISCELLANEOUS_TYPES = _index.FLIPPED_ALIAS_KEYS["Miscellaneous"]; -const TYPESCRIPT_TYPES = exports.TYPESCRIPT_TYPES = _index.FLIPPED_ALIAS_KEYS["TypeScript"]; -const TSTYPEELEMENT_TYPES = exports.TSTYPEELEMENT_TYPES = _index.FLIPPED_ALIAS_KEYS["TSTypeElement"]; -const TSTYPE_TYPES = exports.TSTYPE_TYPES = _index.FLIPPED_ALIAS_KEYS["TSType"]; -const TSBASETYPE_TYPES = exports.TSBASETYPE_TYPES = _index.FLIPPED_ALIAS_KEYS["TSBaseType"]; -const MODULEDECLARATION_TYPES = exports.MODULEDECLARATION_TYPES = IMPORTOREXPORTDECLARATION_TYPES; - -//# sourceMappingURL=index.js.map diff --git a/tools/eslint/node_modules/@babel/types/lib/constants/index.js b/tools/eslint/node_modules/@babel/types/lib/constants/index.js deleted file mode 100644 index 5045d01d2dcb0b..00000000000000 --- a/tools/eslint/node_modules/@babel/types/lib/constants/index.js +++ /dev/null @@ -1,31 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.UPDATE_OPERATORS = exports.UNARY_OPERATORS = exports.STRING_UNARY_OPERATORS = exports.STATEMENT_OR_BLOCK_KEYS = exports.NUMBER_UNARY_OPERATORS = exports.NUMBER_BINARY_OPERATORS = exports.NOT_LOCAL_BINDING = exports.LOGICAL_OPERATORS = exports.INHERIT_KEYS = exports.FOR_INIT_KEYS = exports.FLATTENABLE_KEYS = exports.EQUALITY_BINARY_OPERATORS = exports.COMPARISON_BINARY_OPERATORS = exports.COMMENT_KEYS = exports.BOOLEAN_UNARY_OPERATORS = exports.BOOLEAN_NUMBER_BINARY_OPERATORS = exports.BOOLEAN_BINARY_OPERATORS = exports.BLOCK_SCOPED_SYMBOL = exports.BINARY_OPERATORS = exports.ASSIGNMENT_OPERATORS = void 0; -const STATEMENT_OR_BLOCK_KEYS = exports.STATEMENT_OR_BLOCK_KEYS = ["consequent", "body", "alternate"]; -const FLATTENABLE_KEYS = exports.FLATTENABLE_KEYS = ["body", "expressions"]; -const FOR_INIT_KEYS = exports.FOR_INIT_KEYS = ["left", "init"]; -const COMMENT_KEYS = exports.COMMENT_KEYS = ["leadingComments", "trailingComments", "innerComments"]; -const LOGICAL_OPERATORS = exports.LOGICAL_OPERATORS = ["||", "&&", "??"]; -const UPDATE_OPERATORS = exports.UPDATE_OPERATORS = ["++", "--"]; -const BOOLEAN_NUMBER_BINARY_OPERATORS = exports.BOOLEAN_NUMBER_BINARY_OPERATORS = [">", "<", ">=", "<="]; -const EQUALITY_BINARY_OPERATORS = exports.EQUALITY_BINARY_OPERATORS = ["==", "===", "!=", "!=="]; -const COMPARISON_BINARY_OPERATORS = exports.COMPARISON_BINARY_OPERATORS = [...EQUALITY_BINARY_OPERATORS, "in", "instanceof"]; -const BOOLEAN_BINARY_OPERATORS = exports.BOOLEAN_BINARY_OPERATORS = [...COMPARISON_BINARY_OPERATORS, ...BOOLEAN_NUMBER_BINARY_OPERATORS]; -const NUMBER_BINARY_OPERATORS = exports.NUMBER_BINARY_OPERATORS = ["-", "/", "%", "*", "**", "&", "|", ">>", ">>>", "<<", "^"]; -const BINARY_OPERATORS = exports.BINARY_OPERATORS = ["+", ...NUMBER_BINARY_OPERATORS, ...BOOLEAN_BINARY_OPERATORS, "|>"]; -const ASSIGNMENT_OPERATORS = exports.ASSIGNMENT_OPERATORS = ["=", "+=", ...NUMBER_BINARY_OPERATORS.map(op => op + "="), ...LOGICAL_OPERATORS.map(op => op + "=")]; -const BOOLEAN_UNARY_OPERATORS = exports.BOOLEAN_UNARY_OPERATORS = ["delete", "!"]; -const NUMBER_UNARY_OPERATORS = exports.NUMBER_UNARY_OPERATORS = ["+", "-", "~"]; -const STRING_UNARY_OPERATORS = exports.STRING_UNARY_OPERATORS = ["typeof"]; -const UNARY_OPERATORS = exports.UNARY_OPERATORS = ["void", "throw", ...BOOLEAN_UNARY_OPERATORS, ...NUMBER_UNARY_OPERATORS, ...STRING_UNARY_OPERATORS]; -const INHERIT_KEYS = exports.INHERIT_KEYS = { - optional: ["typeAnnotation", "typeParameters", "returnType"], - force: ["start", "loc", "end"] -}; -const BLOCK_SCOPED_SYMBOL = exports.BLOCK_SCOPED_SYMBOL = Symbol.for("var used to be block scoped"); -const NOT_LOCAL_BINDING = exports.NOT_LOCAL_BINDING = Symbol.for("should not be considered a local binding"); - -//# sourceMappingURL=index.js.map diff --git a/tools/eslint/node_modules/@babel/types/lib/converters/ensureBlock.js b/tools/eslint/node_modules/@babel/types/lib/converters/ensureBlock.js deleted file mode 100644 index 8e641342d0d1bd..00000000000000 --- a/tools/eslint/node_modules/@babel/types/lib/converters/ensureBlock.js +++ /dev/null @@ -1,14 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.default = ensureBlock; -var _toBlock = require("./toBlock.js"); -function ensureBlock(node, key = "body") { - const result = (0, _toBlock.default)(node[key], node); - node[key] = result; - return result; -} - -//# sourceMappingURL=ensureBlock.js.map diff --git a/tools/eslint/node_modules/@babel/types/lib/converters/gatherSequenceExpressions.js b/tools/eslint/node_modules/@babel/types/lib/converters/gatherSequenceExpressions.js deleted file mode 100644 index 644cc1dd342fae..00000000000000 --- a/tools/eslint/node_modules/@babel/types/lib/converters/gatherSequenceExpressions.js +++ /dev/null @@ -1,66 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.default = gatherSequenceExpressions; -var _getBindingIdentifiers = require("../retrievers/getBindingIdentifiers.js"); -var _index = require("../validators/generated/index.js"); -var _index2 = require("../builders/generated/index.js"); -var _productions = require("../builders/productions.js"); -var _cloneNode = require("../clone/cloneNode.js"); -; -function gatherSequenceExpressions(nodes, declars) { - const exprs = []; - let ensureLastUndefined = true; - for (const node of nodes) { - if (!(0, _index.isEmptyStatement)(node)) { - ensureLastUndefined = false; - } - if ((0, _index.isExpression)(node)) { - exprs.push(node); - } else if ((0, _index.isExpressionStatement)(node)) { - exprs.push(node.expression); - } else if ((0, _index.isVariableDeclaration)(node)) { - if (node.kind !== "var") return; - for (const declar of node.declarations) { - const bindings = (0, _getBindingIdentifiers.default)(declar); - for (const key of Object.keys(bindings)) { - declars.push({ - kind: node.kind, - id: (0, _cloneNode.default)(bindings[key]) - }); - } - if (declar.init) { - exprs.push((0, _index2.assignmentExpression)("=", declar.id, declar.init)); - } - } - ensureLastUndefined = true; - } else if ((0, _index.isIfStatement)(node)) { - const consequent = node.consequent ? gatherSequenceExpressions([node.consequent], declars) : (0, _productions.buildUndefinedNode)(); - const alternate = node.alternate ? gatherSequenceExpressions([node.alternate], declars) : (0, _productions.buildUndefinedNode)(); - if (!consequent || !alternate) return; - exprs.push((0, _index2.conditionalExpression)(node.test, consequent, alternate)); - } else if ((0, _index.isBlockStatement)(node)) { - const body = gatherSequenceExpressions(node.body, declars); - if (!body) return; - exprs.push(body); - } else if ((0, _index.isEmptyStatement)(node)) { - if (nodes.indexOf(node) === 0) { - ensureLastUndefined = true; - } - } else { - return; - } - } - if (ensureLastUndefined) { - exprs.push((0, _productions.buildUndefinedNode)()); - } - if (exprs.length === 1) { - return exprs[0]; - } else { - return (0, _index2.sequenceExpression)(exprs); - } -} - -//# sourceMappingURL=gatherSequenceExpressions.js.map diff --git a/tools/eslint/node_modules/@babel/types/lib/converters/toBindingIdentifierName.js b/tools/eslint/node_modules/@babel/types/lib/converters/toBindingIdentifierName.js deleted file mode 100644 index c4cc176ca4be47..00000000000000 --- a/tools/eslint/node_modules/@babel/types/lib/converters/toBindingIdentifierName.js +++ /dev/null @@ -1,14 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.default = toBindingIdentifierName; -var _toIdentifier = require("./toIdentifier.js"); -function toBindingIdentifierName(name) { - name = (0, _toIdentifier.default)(name); - if (name === "eval" || name === "arguments") name = "_" + name; - return name; -} - -//# sourceMappingURL=toBindingIdentifierName.js.map diff --git a/tools/eslint/node_modules/@babel/types/lib/converters/toBlock.js b/tools/eslint/node_modules/@babel/types/lib/converters/toBlock.js deleted file mode 100644 index d884b1ee53a352..00000000000000 --- a/tools/eslint/node_modules/@babel/types/lib/converters/toBlock.js +++ /dev/null @@ -1,29 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.default = toBlock; -var _index = require("../validators/generated/index.js"); -var _index2 = require("../builders/generated/index.js"); -function toBlock(node, parent) { - if ((0, _index.isBlockStatement)(node)) { - return node; - } - let blockNodes = []; - if ((0, _index.isEmptyStatement)(node)) { - blockNodes = []; - } else { - if (!(0, _index.isStatement)(node)) { - if ((0, _index.isFunction)(parent)) { - node = (0, _index2.returnStatement)(node); - } else { - node = (0, _index2.expressionStatement)(node); - } - } - blockNodes = [node]; - } - return (0, _index2.blockStatement)(blockNodes); -} - -//# sourceMappingURL=toBlock.js.map diff --git a/tools/eslint/node_modules/@babel/types/lib/converters/toComputedKey.js b/tools/eslint/node_modules/@babel/types/lib/converters/toComputedKey.js deleted file mode 100644 index 41ed1ca04bc42e..00000000000000 --- a/tools/eslint/node_modules/@babel/types/lib/converters/toComputedKey.js +++ /dev/null @@ -1,14 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.default = toComputedKey; -var _index = require("../validators/generated/index.js"); -var _index2 = require("../builders/generated/index.js"); -function toComputedKey(node, key = node.key || node.property) { - if (!node.computed && (0, _index.isIdentifier)(key)) key = (0, _index2.stringLiteral)(key.name); - return key; -} - -//# sourceMappingURL=toComputedKey.js.map diff --git a/tools/eslint/node_modules/@babel/types/lib/converters/toExpression.js b/tools/eslint/node_modules/@babel/types/lib/converters/toExpression.js deleted file mode 100644 index bcb576fe2f057b..00000000000000 --- a/tools/eslint/node_modules/@babel/types/lib/converters/toExpression.js +++ /dev/null @@ -1,27 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.default = void 0; -var _index = require("../validators/generated/index.js"); -var _default = exports.default = toExpression; -function toExpression(node) { - if ((0, _index.isExpressionStatement)(node)) { - node = node.expression; - } - if ((0, _index.isExpression)(node)) { - return node; - } - if ((0, _index.isClass)(node)) { - node.type = "ClassExpression"; - } else if ((0, _index.isFunction)(node)) { - node.type = "FunctionExpression"; - } - if (!(0, _index.isExpression)(node)) { - throw new Error(`cannot turn ${node.type} to an expression`); - } - return node; -} - -//# sourceMappingURL=toExpression.js.map diff --git a/tools/eslint/node_modules/@babel/types/lib/converters/toIdentifier.js b/tools/eslint/node_modules/@babel/types/lib/converters/toIdentifier.js deleted file mode 100644 index 88037850dfac21..00000000000000 --- a/tools/eslint/node_modules/@babel/types/lib/converters/toIdentifier.js +++ /dev/null @@ -1,25 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.default = toIdentifier; -var _isValidIdentifier = require("../validators/isValidIdentifier.js"); -var _helperValidatorIdentifier = require("@babel/helper-validator-identifier"); -function toIdentifier(input) { - input = input + ""; - let name = ""; - for (const c of input) { - name += (0, _helperValidatorIdentifier.isIdentifierChar)(c.codePointAt(0)) ? c : "-"; - } - name = name.replace(/^[-0-9]+/, ""); - name = name.replace(/[-\s]+(.)?/g, function (match, c) { - return c ? c.toUpperCase() : ""; - }); - if (!(0, _isValidIdentifier.default)(name)) { - name = `_${name}`; - } - return name || "_"; -} - -//# sourceMappingURL=toIdentifier.js.map diff --git a/tools/eslint/node_modules/@babel/types/lib/converters/toKeyAlias.js b/tools/eslint/node_modules/@babel/types/lib/converters/toKeyAlias.js deleted file mode 100644 index ee73a0e926d216..00000000000000 --- a/tools/eslint/node_modules/@babel/types/lib/converters/toKeyAlias.js +++ /dev/null @@ -1,38 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.default = toKeyAlias; -var _index = require("../validators/generated/index.js"); -var _cloneNode = require("../clone/cloneNode.js"); -var _removePropertiesDeep = require("../modifications/removePropertiesDeep.js"); -function toKeyAlias(node, key = node.key) { - let alias; - if (node.kind === "method") { - return toKeyAlias.increment() + ""; - } else if ((0, _index.isIdentifier)(key)) { - alias = key.name; - } else if ((0, _index.isStringLiteral)(key)) { - alias = JSON.stringify(key.value); - } else { - alias = JSON.stringify((0, _removePropertiesDeep.default)((0, _cloneNode.default)(key))); - } - if (node.computed) { - alias = `[${alias}]`; - } - if (node.static) { - alias = `static:${alias}`; - } - return alias; -} -toKeyAlias.uid = 0; -toKeyAlias.increment = function () { - if (toKeyAlias.uid >= Number.MAX_SAFE_INTEGER) { - return toKeyAlias.uid = 0; - } else { - return toKeyAlias.uid++; - } -}; - -//# sourceMappingURL=toKeyAlias.js.map diff --git a/tools/eslint/node_modules/@babel/types/lib/converters/toSequenceExpression.js b/tools/eslint/node_modules/@babel/types/lib/converters/toSequenceExpression.js deleted file mode 100644 index 96fc4ea0cf954d..00000000000000 --- a/tools/eslint/node_modules/@babel/types/lib/converters/toSequenceExpression.js +++ /dev/null @@ -1,20 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.default = toSequenceExpression; -var _gatherSequenceExpressions = require("./gatherSequenceExpressions.js"); -; -function toSequenceExpression(nodes, scope) { - if (!(nodes != null && nodes.length)) return; - const declars = []; - const result = (0, _gatherSequenceExpressions.default)(nodes, declars); - if (!result) return; - for (const declar of declars) { - scope.push(declar); - } - return result; -} - -//# sourceMappingURL=toSequenceExpression.js.map diff --git a/tools/eslint/node_modules/@babel/types/lib/converters/toStatement.js b/tools/eslint/node_modules/@babel/types/lib/converters/toStatement.js deleted file mode 100644 index 92cfd96033aa69..00000000000000 --- a/tools/eslint/node_modules/@babel/types/lib/converters/toStatement.js +++ /dev/null @@ -1,39 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.default = void 0; -var _index = require("../validators/generated/index.js"); -var _index2 = require("../builders/generated/index.js"); -var _default = exports.default = toStatement; -function toStatement(node, ignore) { - if ((0, _index.isStatement)(node)) { - return node; - } - let mustHaveId = false; - let newType; - if ((0, _index.isClass)(node)) { - mustHaveId = true; - newType = "ClassDeclaration"; - } else if ((0, _index.isFunction)(node)) { - mustHaveId = true; - newType = "FunctionDeclaration"; - } else if ((0, _index.isAssignmentExpression)(node)) { - return (0, _index2.expressionStatement)(node); - } - if (mustHaveId && !node.id) { - newType = false; - } - if (!newType) { - if (ignore) { - return false; - } else { - throw new Error(`cannot turn ${node.type} to a statement`); - } - } - node.type = newType; - return node; -} - -//# sourceMappingURL=toStatement.js.map diff --git a/tools/eslint/node_modules/@babel/types/lib/converters/valueToNode.js b/tools/eslint/node_modules/@babel/types/lib/converters/valueToNode.js deleted file mode 100644 index 74806a00b80b5d..00000000000000 --- a/tools/eslint/node_modules/@babel/types/lib/converters/valueToNode.js +++ /dev/null @@ -1,76 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.default = void 0; -var _isValidIdentifier = require("../validators/isValidIdentifier.js"); -var _index = require("../builders/generated/index.js"); -var _default = exports.default = valueToNode; -const objectToString = Function.call.bind(Object.prototype.toString); -function isRegExp(value) { - return objectToString(value) === "[object RegExp]"; -} -function isPlainObject(value) { - if (typeof value !== "object" || value === null || Object.prototype.toString.call(value) !== "[object Object]") { - return false; - } - const proto = Object.getPrototypeOf(value); - return proto === null || Object.getPrototypeOf(proto) === null; -} -function valueToNode(value) { - if (value === undefined) { - return (0, _index.identifier)("undefined"); - } - if (value === true || value === false) { - return (0, _index.booleanLiteral)(value); - } - if (value === null) { - return (0, _index.nullLiteral)(); - } - if (typeof value === "string") { - return (0, _index.stringLiteral)(value); - } - if (typeof value === "number") { - let result; - if (Number.isFinite(value)) { - result = (0, _index.numericLiteral)(Math.abs(value)); - } else { - let numerator; - if (Number.isNaN(value)) { - numerator = (0, _index.numericLiteral)(0); - } else { - numerator = (0, _index.numericLiteral)(1); - } - result = (0, _index.binaryExpression)("/", numerator, (0, _index.numericLiteral)(0)); - } - if (value < 0 || Object.is(value, -0)) { - result = (0, _index.unaryExpression)("-", result); - } - return result; - } - if (isRegExp(value)) { - const pattern = value.source; - const flags = /\/([a-z]+|)$/.exec(value.toString())[1]; - return (0, _index.regExpLiteral)(pattern, flags); - } - if (Array.isArray(value)) { - return (0, _index.arrayExpression)(value.map(valueToNode)); - } - if (isPlainObject(value)) { - const props = []; - for (const key of Object.keys(value)) { - let nodeKey; - if ((0, _isValidIdentifier.default)(key)) { - nodeKey = (0, _index.identifier)(key); - } else { - nodeKey = (0, _index.stringLiteral)(key); - } - props.push((0, _index.objectProperty)(nodeKey, valueToNode(value[key]))); - } - return (0, _index.objectExpression)(props); - } - throw new Error("don't know how to turn this value into a node"); -} - -//# sourceMappingURL=valueToNode.js.map diff --git a/tools/eslint/node_modules/@babel/types/lib/definitions/core.js b/tools/eslint/node_modules/@babel/types/lib/definitions/core.js deleted file mode 100644 index ccc250811f88ab..00000000000000 --- a/tools/eslint/node_modules/@babel/types/lib/definitions/core.js +++ /dev/null @@ -1,1689 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.patternLikeCommon = exports.functionTypeAnnotationCommon = exports.functionDeclarationCommon = exports.functionCommon = exports.classMethodOrPropertyCommon = exports.classMethodOrDeclareMethodCommon = void 0; -var _is = require("../validators/is.js"); -var _isValidIdentifier = require("../validators/isValidIdentifier.js"); -var _helperValidatorIdentifier = require("@babel/helper-validator-identifier"); -var _helperStringParser = require("@babel/helper-string-parser"); -var _index = require("../constants/index.js"); -var _utils = require("./utils.js"); -const defineType = (0, _utils.defineAliasedType)("Standardized"); -defineType("ArrayExpression", { - fields: { - elements: { - validate: (0, _utils.chain)((0, _utils.assertValueType)("array"), (0, _utils.assertEach)((0, _utils.assertNodeOrValueType)("null", "Expression", "SpreadElement"))), - default: !process.env.BABEL_TYPES_8_BREAKING ? [] : undefined - } - }, - visitor: ["elements"], - aliases: ["Expression"] -}); -defineType("AssignmentExpression", { - fields: { - operator: { - validate: function () { - if (!process.env.BABEL_TYPES_8_BREAKING) { - return (0, _utils.assertValueType)("string"); - } - const identifier = (0, _utils.assertOneOf)(..._index.ASSIGNMENT_OPERATORS); - const pattern = (0, _utils.assertOneOf)("="); - return function (node, key, val) { - const validator = (0, _is.default)("Pattern", node.left) ? pattern : identifier; - validator(node, key, val); - }; - }() - }, - left: { - validate: !process.env.BABEL_TYPES_8_BREAKING ? (0, _utils.assertNodeType)("LVal", "OptionalMemberExpression") : (0, _utils.assertNodeType)("Identifier", "MemberExpression", "OptionalMemberExpression", "ArrayPattern", "ObjectPattern", "TSAsExpression", "TSSatisfiesExpression", "TSTypeAssertion", "TSNonNullExpression") - }, - right: { - validate: (0, _utils.assertNodeType)("Expression") - } - }, - builder: ["operator", "left", "right"], - visitor: ["left", "right"], - aliases: ["Expression"] -}); -defineType("BinaryExpression", { - builder: ["operator", "left", "right"], - fields: { - operator: { - validate: (0, _utils.assertOneOf)(..._index.BINARY_OPERATORS) - }, - left: { - validate: function () { - const expression = (0, _utils.assertNodeType)("Expression"); - const inOp = (0, _utils.assertNodeType)("Expression", "PrivateName"); - const validator = Object.assign(function (node, key, val) { - const validator = node.operator === "in" ? inOp : expression; - validator(node, key, val); - }, { - oneOfNodeTypes: ["Expression", "PrivateName"] - }); - return validator; - }() - }, - right: { - validate: (0, _utils.assertNodeType)("Expression") - } - }, - visitor: ["left", "right"], - aliases: ["Binary", "Expression"] -}); -defineType("InterpreterDirective", { - builder: ["value"], - fields: { - value: { - validate: (0, _utils.assertValueType)("string") - } - } -}); -defineType("Directive", { - visitor: ["value"], - fields: { - value: { - validate: (0, _utils.assertNodeType)("DirectiveLiteral") - } - } -}); -defineType("DirectiveLiteral", { - builder: ["value"], - fields: { - value: { - validate: (0, _utils.assertValueType)("string") - } - } -}); -defineType("BlockStatement", { - builder: ["body", "directives"], - visitor: ["directives", "body"], - fields: { - directives: { - validate: (0, _utils.chain)((0, _utils.assertValueType)("array"), (0, _utils.assertEach)((0, _utils.assertNodeType)("Directive"))), - default: [] - }, - body: { - validate: (0, _utils.chain)((0, _utils.assertValueType)("array"), (0, _utils.assertEach)((0, _utils.assertNodeType)("Statement"))) - } - }, - aliases: ["Scopable", "BlockParent", "Block", "Statement"] -}); -defineType("BreakStatement", { - visitor: ["label"], - fields: { - label: { - validate: (0, _utils.assertNodeType)("Identifier"), - optional: true - } - }, - aliases: ["Statement", "Terminatorless", "CompletionStatement"] -}); -defineType("CallExpression", { - visitor: ["callee", "arguments", "typeParameters", "typeArguments"], - builder: ["callee", "arguments"], - aliases: ["Expression"], - fields: Object.assign({ - callee: { - validate: (0, _utils.assertNodeType)("Expression", "Super", "V8IntrinsicIdentifier") - }, - arguments: { - validate: (0, _utils.chain)((0, _utils.assertValueType)("array"), (0, _utils.assertEach)((0, _utils.assertNodeType)("Expression", "SpreadElement", "ArgumentPlaceholder"))) - } - }, !process.env.BABEL_TYPES_8_BREAKING ? { - optional: { - validate: (0, _utils.assertOneOf)(true, false), - optional: true - } - } : {}, { - typeArguments: { - validate: (0, _utils.assertNodeType)("TypeParameterInstantiation"), - optional: true - }, - typeParameters: { - validate: (0, _utils.assertNodeType)("TSTypeParameterInstantiation"), - optional: true - } - }) -}); -defineType("CatchClause", { - visitor: ["param", "body"], - fields: { - param: { - validate: (0, _utils.assertNodeType)("Identifier", "ArrayPattern", "ObjectPattern"), - optional: true - }, - body: { - validate: (0, _utils.assertNodeType)("BlockStatement") - } - }, - aliases: ["Scopable", "BlockParent"] -}); -defineType("ConditionalExpression", { - visitor: ["test", "consequent", "alternate"], - fields: { - test: { - validate: (0, _utils.assertNodeType)("Expression") - }, - consequent: { - validate: (0, _utils.assertNodeType)("Expression") - }, - alternate: { - validate: (0, _utils.assertNodeType)("Expression") - } - }, - aliases: ["Expression", "Conditional"] -}); -defineType("ContinueStatement", { - visitor: ["label"], - fields: { - label: { - validate: (0, _utils.assertNodeType)("Identifier"), - optional: true - } - }, - aliases: ["Statement", "Terminatorless", "CompletionStatement"] -}); -defineType("DebuggerStatement", { - aliases: ["Statement"] -}); -defineType("DoWhileStatement", { - visitor: ["test", "body"], - fields: { - test: { - validate: (0, _utils.assertNodeType)("Expression") - }, - body: { - validate: (0, _utils.assertNodeType)("Statement") - } - }, - aliases: ["Statement", "BlockParent", "Loop", "While", "Scopable"] -}); -defineType("EmptyStatement", { - aliases: ["Statement"] -}); -defineType("ExpressionStatement", { - visitor: ["expression"], - fields: { - expression: { - validate: (0, _utils.assertNodeType)("Expression") - } - }, - aliases: ["Statement", "ExpressionWrapper"] -}); -defineType("File", { - builder: ["program", "comments", "tokens"], - visitor: ["program"], - fields: { - program: { - validate: (0, _utils.assertNodeType)("Program") - }, - comments: { - validate: !process.env.BABEL_TYPES_8_BREAKING ? Object.assign(() => {}, { - each: { - oneOfNodeTypes: ["CommentBlock", "CommentLine"] - } - }) : (0, _utils.assertEach)((0, _utils.assertNodeType)("CommentBlock", "CommentLine")), - optional: true - }, - tokens: { - validate: (0, _utils.assertEach)(Object.assign(() => {}, { - type: "any" - })), - optional: true - } - } -}); -defineType("ForInStatement", { - visitor: ["left", "right", "body"], - aliases: ["Scopable", "Statement", "For", "BlockParent", "Loop", "ForXStatement"], - fields: { - left: { - validate: !process.env.BABEL_TYPES_8_BREAKING ? (0, _utils.assertNodeType)("VariableDeclaration", "LVal") : (0, _utils.assertNodeType)("VariableDeclaration", "Identifier", "MemberExpression", "ArrayPattern", "ObjectPattern", "TSAsExpression", "TSSatisfiesExpression", "TSTypeAssertion", "TSNonNullExpression") - }, - right: { - validate: (0, _utils.assertNodeType)("Expression") - }, - body: { - validate: (0, _utils.assertNodeType)("Statement") - } - } -}); -defineType("ForStatement", { - visitor: ["init", "test", "update", "body"], - aliases: ["Scopable", "Statement", "For", "BlockParent", "Loop"], - fields: { - init: { - validate: (0, _utils.assertNodeType)("VariableDeclaration", "Expression"), - optional: true - }, - test: { - validate: (0, _utils.assertNodeType)("Expression"), - optional: true - }, - update: { - validate: (0, _utils.assertNodeType)("Expression"), - optional: true - }, - body: { - validate: (0, _utils.assertNodeType)("Statement") - } - } -}); -const functionCommon = () => ({ - params: { - validate: (0, _utils.chain)((0, _utils.assertValueType)("array"), (0, _utils.assertEach)((0, _utils.assertNodeType)("Identifier", "Pattern", "RestElement"))) - }, - generator: { - default: false - }, - async: { - default: false - } -}); -exports.functionCommon = functionCommon; -const functionTypeAnnotationCommon = () => ({ - returnType: { - validate: (0, _utils.assertNodeType)("TypeAnnotation", "TSTypeAnnotation", "Noop"), - optional: true - }, - typeParameters: { - validate: (0, _utils.assertNodeType)("TypeParameterDeclaration", "TSTypeParameterDeclaration", "Noop"), - optional: true - } -}); -exports.functionTypeAnnotationCommon = functionTypeAnnotationCommon; -const functionDeclarationCommon = () => Object.assign({}, functionCommon(), { - declare: { - validate: (0, _utils.assertValueType)("boolean"), - optional: true - }, - id: { - validate: (0, _utils.assertNodeType)("Identifier"), - optional: true - } -}); -exports.functionDeclarationCommon = functionDeclarationCommon; -defineType("FunctionDeclaration", { - builder: ["id", "params", "body", "generator", "async"], - visitor: ["id", "params", "body", "returnType", "typeParameters"], - fields: Object.assign({}, functionDeclarationCommon(), functionTypeAnnotationCommon(), { - body: { - validate: (0, _utils.assertNodeType)("BlockStatement") - }, - predicate: { - validate: (0, _utils.assertNodeType)("DeclaredPredicate", "InferredPredicate"), - optional: true - } - }), - aliases: ["Scopable", "Function", "BlockParent", "FunctionParent", "Statement", "Pureish", "Declaration"], - validate: function () { - if (!process.env.BABEL_TYPES_8_BREAKING) return () => {}; - const identifier = (0, _utils.assertNodeType)("Identifier"); - return function (parent, key, node) { - if (!(0, _is.default)("ExportDefaultDeclaration", parent)) { - identifier(node, "id", node.id); - } - }; - }() -}); -defineType("FunctionExpression", { - inherits: "FunctionDeclaration", - aliases: ["Scopable", "Function", "BlockParent", "FunctionParent", "Expression", "Pureish"], - fields: Object.assign({}, functionCommon(), functionTypeAnnotationCommon(), { - id: { - validate: (0, _utils.assertNodeType)("Identifier"), - optional: true - }, - body: { - validate: (0, _utils.assertNodeType)("BlockStatement") - }, - predicate: { - validate: (0, _utils.assertNodeType)("DeclaredPredicate", "InferredPredicate"), - optional: true - } - }) -}); -const patternLikeCommon = () => ({ - typeAnnotation: { - validate: (0, _utils.assertNodeType)("TypeAnnotation", "TSTypeAnnotation", "Noop"), - optional: true - }, - optional: { - validate: (0, _utils.assertValueType)("boolean"), - optional: true - }, - decorators: { - validate: (0, _utils.chain)((0, _utils.assertValueType)("array"), (0, _utils.assertEach)((0, _utils.assertNodeType)("Decorator"))), - optional: true - } -}); -exports.patternLikeCommon = patternLikeCommon; -defineType("Identifier", { - builder: ["name"], - visitor: ["typeAnnotation", "decorators"], - aliases: ["Expression", "PatternLike", "LVal", "TSEntityName"], - fields: Object.assign({}, patternLikeCommon(), { - name: { - validate: (0, _utils.chain)((0, _utils.assertValueType)("string"), Object.assign(function (node, key, val) { - if (!process.env.BABEL_TYPES_8_BREAKING) return; - if (!(0, _isValidIdentifier.default)(val, false)) { - throw new TypeError(`"${val}" is not a valid identifier name`); - } - }, { - type: "string" - })) - } - }), - validate(parent, key, node) { - if (!process.env.BABEL_TYPES_8_BREAKING) return; - const match = /\.(\w+)$/.exec(key); - if (!match) return; - const [, parentKey] = match; - const nonComp = { - computed: false - }; - if (parentKey === "property") { - if ((0, _is.default)("MemberExpression", parent, nonComp)) return; - if ((0, _is.default)("OptionalMemberExpression", parent, nonComp)) return; - } else if (parentKey === "key") { - if ((0, _is.default)("Property", parent, nonComp)) return; - if ((0, _is.default)("Method", parent, nonComp)) return; - } else if (parentKey === "exported") { - if ((0, _is.default)("ExportSpecifier", parent)) return; - } else if (parentKey === "imported") { - if ((0, _is.default)("ImportSpecifier", parent, { - imported: node - })) return; - } else if (parentKey === "meta") { - if ((0, _is.default)("MetaProperty", parent, { - meta: node - })) return; - } - if (((0, _helperValidatorIdentifier.isKeyword)(node.name) || (0, _helperValidatorIdentifier.isReservedWord)(node.name, false)) && node.name !== "this") { - throw new TypeError(`"${node.name}" is not a valid identifier`); - } - } -}); -defineType("IfStatement", { - visitor: ["test", "consequent", "alternate"], - aliases: ["Statement", "Conditional"], - fields: { - test: { - validate: (0, _utils.assertNodeType)("Expression") - }, - consequent: { - validate: (0, _utils.assertNodeType)("Statement") - }, - alternate: { - optional: true, - validate: (0, _utils.assertNodeType)("Statement") - } - } -}); -defineType("LabeledStatement", { - visitor: ["label", "body"], - aliases: ["Statement"], - fields: { - label: { - validate: (0, _utils.assertNodeType)("Identifier") - }, - body: { - validate: (0, _utils.assertNodeType)("Statement") - } - } -}); -defineType("StringLiteral", { - builder: ["value"], - fields: { - value: { - validate: (0, _utils.assertValueType)("string") - } - }, - aliases: ["Expression", "Pureish", "Literal", "Immutable"] -}); -defineType("NumericLiteral", { - builder: ["value"], - deprecatedAlias: "NumberLiteral", - fields: { - value: { - validate: (0, _utils.chain)((0, _utils.assertValueType)("number"), Object.assign(function (node, key, val) { - if (1 / val < 0 || !Number.isFinite(val)) { - const error = new Error("NumericLiterals must be non-negative finite numbers. " + `You can use t.valueToNode(${val}) instead.`); - {} - } - }, { - type: "number" - })) - } - }, - aliases: ["Expression", "Pureish", "Literal", "Immutable"] -}); -defineType("NullLiteral", { - aliases: ["Expression", "Pureish", "Literal", "Immutable"] -}); -defineType("BooleanLiteral", { - builder: ["value"], - fields: { - value: { - validate: (0, _utils.assertValueType)("boolean") - } - }, - aliases: ["Expression", "Pureish", "Literal", "Immutable"] -}); -defineType("RegExpLiteral", { - builder: ["pattern", "flags"], - deprecatedAlias: "RegexLiteral", - aliases: ["Expression", "Pureish", "Literal"], - fields: { - pattern: { - validate: (0, _utils.assertValueType)("string") - }, - flags: { - validate: (0, _utils.chain)((0, _utils.assertValueType)("string"), Object.assign(function (node, key, val) { - if (!process.env.BABEL_TYPES_8_BREAKING) return; - const invalid = /[^gimsuy]/.exec(val); - if (invalid) { - throw new TypeError(`"${invalid[0]}" is not a valid RegExp flag`); - } - }, { - type: "string" - })), - default: "" - } - } -}); -defineType("LogicalExpression", { - builder: ["operator", "left", "right"], - visitor: ["left", "right"], - aliases: ["Binary", "Expression"], - fields: { - operator: { - validate: (0, _utils.assertOneOf)(..._index.LOGICAL_OPERATORS) - }, - left: { - validate: (0, _utils.assertNodeType)("Expression") - }, - right: { - validate: (0, _utils.assertNodeType)("Expression") - } - } -}); -defineType("MemberExpression", { - builder: ["object", "property", "computed", ...(!process.env.BABEL_TYPES_8_BREAKING ? ["optional"] : [])], - visitor: ["object", "property"], - aliases: ["Expression", "LVal"], - fields: Object.assign({ - object: { - validate: (0, _utils.assertNodeType)("Expression", "Super") - }, - property: { - validate: function () { - const normal = (0, _utils.assertNodeType)("Identifier", "PrivateName"); - const computed = (0, _utils.assertNodeType)("Expression"); - const validator = function (node, key, val) { - const validator = node.computed ? computed : normal; - validator(node, key, val); - }; - validator.oneOfNodeTypes = ["Expression", "Identifier", "PrivateName"]; - return validator; - }() - }, - computed: { - default: false - } - }, !process.env.BABEL_TYPES_8_BREAKING ? { - optional: { - validate: (0, _utils.assertOneOf)(true, false), - optional: true - } - } : {}) -}); -defineType("NewExpression", { - inherits: "CallExpression" -}); -defineType("Program", { - visitor: ["directives", "body"], - builder: ["body", "directives", "sourceType", "interpreter"], - fields: { - sourceType: { - validate: (0, _utils.assertOneOf)("script", "module"), - default: "script" - }, - interpreter: { - validate: (0, _utils.assertNodeType)("InterpreterDirective"), - default: null, - optional: true - }, - directives: { - validate: (0, _utils.chain)((0, _utils.assertValueType)("array"), (0, _utils.assertEach)((0, _utils.assertNodeType)("Directive"))), - default: [] - }, - body: { - validate: (0, _utils.chain)((0, _utils.assertValueType)("array"), (0, _utils.assertEach)((0, _utils.assertNodeType)("Statement"))) - } - }, - aliases: ["Scopable", "BlockParent", "Block"] -}); -defineType("ObjectExpression", { - visitor: ["properties"], - aliases: ["Expression"], - fields: { - properties: { - validate: (0, _utils.chain)((0, _utils.assertValueType)("array"), (0, _utils.assertEach)((0, _utils.assertNodeType)("ObjectMethod", "ObjectProperty", "SpreadElement"))) - } - } -}); -defineType("ObjectMethod", { - builder: ["kind", "key", "params", "body", "computed", "generator", "async"], - fields: Object.assign({}, functionCommon(), functionTypeAnnotationCommon(), { - kind: Object.assign({ - validate: (0, _utils.assertOneOf)("method", "get", "set") - }, !process.env.BABEL_TYPES_8_BREAKING ? { - default: "method" - } : {}), - computed: { - default: false - }, - key: { - validate: function () { - const normal = (0, _utils.assertNodeType)("Identifier", "StringLiteral", "NumericLiteral", "BigIntLiteral"); - const computed = (0, _utils.assertNodeType)("Expression"); - const validator = function (node, key, val) { - const validator = node.computed ? computed : normal; - validator(node, key, val); - }; - validator.oneOfNodeTypes = ["Expression", "Identifier", "StringLiteral", "NumericLiteral", "BigIntLiteral"]; - return validator; - }() - }, - decorators: { - validate: (0, _utils.chain)((0, _utils.assertValueType)("array"), (0, _utils.assertEach)((0, _utils.assertNodeType)("Decorator"))), - optional: true - }, - body: { - validate: (0, _utils.assertNodeType)("BlockStatement") - } - }), - visitor: ["key", "params", "body", "decorators", "returnType", "typeParameters"], - aliases: ["UserWhitespacable", "Function", "Scopable", "BlockParent", "FunctionParent", "Method", "ObjectMember"] -}); -defineType("ObjectProperty", { - builder: ["key", "value", "computed", "shorthand", ...(!process.env.BABEL_TYPES_8_BREAKING ? ["decorators"] : [])], - fields: { - computed: { - default: false - }, - key: { - validate: function () { - const normal = (0, _utils.assertNodeType)("Identifier", "StringLiteral", "NumericLiteral", "BigIntLiteral", "DecimalLiteral", "PrivateName"); - const computed = (0, _utils.assertNodeType)("Expression"); - const validator = Object.assign(function (node, key, val) { - const validator = node.computed ? computed : normal; - validator(node, key, val); - }, { - oneOfNodeTypes: ["Expression", "Identifier", "StringLiteral", "NumericLiteral", "BigIntLiteral", "DecimalLiteral", "PrivateName"] - }); - return validator; - }() - }, - value: { - validate: (0, _utils.assertNodeType)("Expression", "PatternLike") - }, - shorthand: { - validate: (0, _utils.chain)((0, _utils.assertValueType)("boolean"), Object.assign(function (node, key, val) { - if (!process.env.BABEL_TYPES_8_BREAKING) return; - if (val && node.computed) { - throw new TypeError("Property shorthand of ObjectProperty cannot be true if computed is true"); - } - }, { - type: "boolean" - }), function (node, key, val) { - if (!process.env.BABEL_TYPES_8_BREAKING) return; - if (val && !(0, _is.default)("Identifier", node.key)) { - throw new TypeError("Property shorthand of ObjectProperty cannot be true if key is not an Identifier"); - } - }), - default: false - }, - decorators: { - validate: (0, _utils.chain)((0, _utils.assertValueType)("array"), (0, _utils.assertEach)((0, _utils.assertNodeType)("Decorator"))), - optional: true - } - }, - visitor: ["key", "value", "decorators"], - aliases: ["UserWhitespacable", "Property", "ObjectMember"], - validate: function () { - const pattern = (0, _utils.assertNodeType)("Identifier", "Pattern", "TSAsExpression", "TSSatisfiesExpression", "TSNonNullExpression", "TSTypeAssertion"); - const expression = (0, _utils.assertNodeType)("Expression"); - return function (parent, key, node) { - if (!process.env.BABEL_TYPES_8_BREAKING) return; - const validator = (0, _is.default)("ObjectPattern", parent) ? pattern : expression; - validator(node, "value", node.value); - }; - }() -}); -defineType("RestElement", { - visitor: ["argument", "typeAnnotation"], - builder: ["argument"], - aliases: ["LVal", "PatternLike"], - deprecatedAlias: "RestProperty", - fields: Object.assign({}, patternLikeCommon(), { - argument: { - validate: !process.env.BABEL_TYPES_8_BREAKING ? (0, _utils.assertNodeType)("LVal") : (0, _utils.assertNodeType)("Identifier", "ArrayPattern", "ObjectPattern", "MemberExpression", "TSAsExpression", "TSSatisfiesExpression", "TSTypeAssertion", "TSNonNullExpression") - } - }), - validate(parent, key) { - if (!process.env.BABEL_TYPES_8_BREAKING) return; - const match = /(\w+)\[(\d+)\]/.exec(key); - if (!match) throw new Error("Internal Babel error: malformed key."); - const [, listKey, index] = match; - if (parent[listKey].length > +index + 1) { - throw new TypeError(`RestElement must be last element of ${listKey}`); - } - } -}); -defineType("ReturnStatement", { - visitor: ["argument"], - aliases: ["Statement", "Terminatorless", "CompletionStatement"], - fields: { - argument: { - validate: (0, _utils.assertNodeType)("Expression"), - optional: true - } - } -}); -defineType("SequenceExpression", { - visitor: ["expressions"], - fields: { - expressions: { - validate: (0, _utils.chain)((0, _utils.assertValueType)("array"), (0, _utils.assertEach)((0, _utils.assertNodeType)("Expression"))) - } - }, - aliases: ["Expression"] -}); -defineType("ParenthesizedExpression", { - visitor: ["expression"], - aliases: ["Expression", "ExpressionWrapper"], - fields: { - expression: { - validate: (0, _utils.assertNodeType)("Expression") - } - } -}); -defineType("SwitchCase", { - visitor: ["test", "consequent"], - fields: { - test: { - validate: (0, _utils.assertNodeType)("Expression"), - optional: true - }, - consequent: { - validate: (0, _utils.chain)((0, _utils.assertValueType)("array"), (0, _utils.assertEach)((0, _utils.assertNodeType)("Statement"))) - } - } -}); -defineType("SwitchStatement", { - visitor: ["discriminant", "cases"], - aliases: ["Statement", "BlockParent", "Scopable"], - fields: { - discriminant: { - validate: (0, _utils.assertNodeType)("Expression") - }, - cases: { - validate: (0, _utils.chain)((0, _utils.assertValueType)("array"), (0, _utils.assertEach)((0, _utils.assertNodeType)("SwitchCase"))) - } - } -}); -defineType("ThisExpression", { - aliases: ["Expression"] -}); -defineType("ThrowStatement", { - visitor: ["argument"], - aliases: ["Statement", "Terminatorless", "CompletionStatement"], - fields: { - argument: { - validate: (0, _utils.assertNodeType)("Expression") - } - } -}); -defineType("TryStatement", { - visitor: ["block", "handler", "finalizer"], - aliases: ["Statement"], - fields: { - block: { - validate: (0, _utils.chain)((0, _utils.assertNodeType)("BlockStatement"), Object.assign(function (node) { - if (!process.env.BABEL_TYPES_8_BREAKING) return; - if (!node.handler && !node.finalizer) { - throw new TypeError("TryStatement expects either a handler or finalizer, or both"); - } - }, { - oneOfNodeTypes: ["BlockStatement"] - })) - }, - handler: { - optional: true, - validate: (0, _utils.assertNodeType)("CatchClause") - }, - finalizer: { - optional: true, - validate: (0, _utils.assertNodeType)("BlockStatement") - } - } -}); -defineType("UnaryExpression", { - builder: ["operator", "argument", "prefix"], - fields: { - prefix: { - default: true - }, - argument: { - validate: (0, _utils.assertNodeType)("Expression") - }, - operator: { - validate: (0, _utils.assertOneOf)(..._index.UNARY_OPERATORS) - } - }, - visitor: ["argument"], - aliases: ["UnaryLike", "Expression"] -}); -defineType("UpdateExpression", { - builder: ["operator", "argument", "prefix"], - fields: { - prefix: { - default: false - }, - argument: { - validate: !process.env.BABEL_TYPES_8_BREAKING ? (0, _utils.assertNodeType)("Expression") : (0, _utils.assertNodeType)("Identifier", "MemberExpression") - }, - operator: { - validate: (0, _utils.assertOneOf)(..._index.UPDATE_OPERATORS) - } - }, - visitor: ["argument"], - aliases: ["Expression"] -}); -defineType("VariableDeclaration", { - builder: ["kind", "declarations"], - visitor: ["declarations"], - aliases: ["Statement", "Declaration"], - fields: { - declare: { - validate: (0, _utils.assertValueType)("boolean"), - optional: true - }, - kind: { - validate: (0, _utils.assertOneOf)("var", "let", "const", "using", "await using") - }, - declarations: { - validate: (0, _utils.chain)((0, _utils.assertValueType)("array"), (0, _utils.assertEach)((0, _utils.assertNodeType)("VariableDeclarator"))) - } - }, - validate(parent, key, node) { - if (!process.env.BABEL_TYPES_8_BREAKING) return; - if (!(0, _is.default)("ForXStatement", parent, { - left: node - })) return; - if (node.declarations.length !== 1) { - throw new TypeError(`Exactly one VariableDeclarator is required in the VariableDeclaration of a ${parent.type}`); - } - } -}); -defineType("VariableDeclarator", { - visitor: ["id", "init"], - fields: { - id: { - validate: function () { - if (!process.env.BABEL_TYPES_8_BREAKING) { - return (0, _utils.assertNodeType)("LVal"); - } - const normal = (0, _utils.assertNodeType)("Identifier", "ArrayPattern", "ObjectPattern"); - const without = (0, _utils.assertNodeType)("Identifier"); - return function (node, key, val) { - const validator = node.init ? normal : without; - validator(node, key, val); - }; - }() - }, - definite: { - optional: true, - validate: (0, _utils.assertValueType)("boolean") - }, - init: { - optional: true, - validate: (0, _utils.assertNodeType)("Expression") - } - } -}); -defineType("WhileStatement", { - visitor: ["test", "body"], - aliases: ["Statement", "BlockParent", "Loop", "While", "Scopable"], - fields: { - test: { - validate: (0, _utils.assertNodeType)("Expression") - }, - body: { - validate: (0, _utils.assertNodeType)("Statement") - } - } -}); -defineType("WithStatement", { - visitor: ["object", "body"], - aliases: ["Statement"], - fields: { - object: { - validate: (0, _utils.assertNodeType)("Expression") - }, - body: { - validate: (0, _utils.assertNodeType)("Statement") - } - } -}); -defineType("AssignmentPattern", { - visitor: ["left", "right", "decorators"], - builder: ["left", "right"], - aliases: ["Pattern", "PatternLike", "LVal"], - fields: Object.assign({}, patternLikeCommon(), { - left: { - validate: (0, _utils.assertNodeType)("Identifier", "ObjectPattern", "ArrayPattern", "MemberExpression", "TSAsExpression", "TSSatisfiesExpression", "TSTypeAssertion", "TSNonNullExpression") - }, - right: { - validate: (0, _utils.assertNodeType)("Expression") - }, - decorators: { - validate: (0, _utils.chain)((0, _utils.assertValueType)("array"), (0, _utils.assertEach)((0, _utils.assertNodeType)("Decorator"))), - optional: true - } - }) -}); -defineType("ArrayPattern", { - visitor: ["elements", "typeAnnotation"], - builder: ["elements"], - aliases: ["Pattern", "PatternLike", "LVal"], - fields: Object.assign({}, patternLikeCommon(), { - elements: { - validate: (0, _utils.chain)((0, _utils.assertValueType)("array"), (0, _utils.assertEach)((0, _utils.assertNodeOrValueType)("null", "PatternLike", "LVal"))) - } - }) -}); -defineType("ArrowFunctionExpression", { - builder: ["params", "body", "async"], - visitor: ["params", "body", "returnType", "typeParameters"], - aliases: ["Scopable", "Function", "BlockParent", "FunctionParent", "Expression", "Pureish"], - fields: Object.assign({}, functionCommon(), functionTypeAnnotationCommon(), { - expression: { - validate: (0, _utils.assertValueType)("boolean") - }, - body: { - validate: (0, _utils.assertNodeType)("BlockStatement", "Expression") - }, - predicate: { - validate: (0, _utils.assertNodeType)("DeclaredPredicate", "InferredPredicate"), - optional: true - } - }) -}); -defineType("ClassBody", { - visitor: ["body"], - fields: { - body: { - validate: (0, _utils.chain)((0, _utils.assertValueType)("array"), (0, _utils.assertEach)((0, _utils.assertNodeType)("ClassMethod", "ClassPrivateMethod", "ClassProperty", "ClassPrivateProperty", "ClassAccessorProperty", "TSDeclareMethod", "TSIndexSignature", "StaticBlock"))) - } - } -}); -defineType("ClassExpression", { - builder: ["id", "superClass", "body", "decorators"], - visitor: ["id", "body", "superClass", "mixins", "typeParameters", "superTypeParameters", "implements", "decorators"], - aliases: ["Scopable", "Class", "Expression"], - fields: { - id: { - validate: (0, _utils.assertNodeType)("Identifier"), - optional: true - }, - typeParameters: { - validate: (0, _utils.assertNodeType)("TypeParameterDeclaration", "TSTypeParameterDeclaration", "Noop"), - optional: true - }, - body: { - validate: (0, _utils.assertNodeType)("ClassBody") - }, - superClass: { - optional: true, - validate: (0, _utils.assertNodeType)("Expression") - }, - superTypeParameters: { - validate: (0, _utils.assertNodeType)("TypeParameterInstantiation", "TSTypeParameterInstantiation"), - optional: true - }, - implements: { - validate: (0, _utils.chain)((0, _utils.assertValueType)("array"), (0, _utils.assertEach)((0, _utils.assertNodeType)("TSExpressionWithTypeArguments", "ClassImplements"))), - optional: true - }, - decorators: { - validate: (0, _utils.chain)((0, _utils.assertValueType)("array"), (0, _utils.assertEach)((0, _utils.assertNodeType)("Decorator"))), - optional: true - }, - mixins: { - validate: (0, _utils.assertNodeType)("InterfaceExtends"), - optional: true - } - } -}); -defineType("ClassDeclaration", { - inherits: "ClassExpression", - aliases: ["Scopable", "Class", "Statement", "Declaration"], - fields: { - id: { - validate: (0, _utils.assertNodeType)("Identifier"), - optional: true - }, - typeParameters: { - validate: (0, _utils.assertNodeType)("TypeParameterDeclaration", "TSTypeParameterDeclaration", "Noop"), - optional: true - }, - body: { - validate: (0, _utils.assertNodeType)("ClassBody") - }, - superClass: { - optional: true, - validate: (0, _utils.assertNodeType)("Expression") - }, - superTypeParameters: { - validate: (0, _utils.assertNodeType)("TypeParameterInstantiation", "TSTypeParameterInstantiation"), - optional: true - }, - implements: { - validate: (0, _utils.chain)((0, _utils.assertValueType)("array"), (0, _utils.assertEach)((0, _utils.assertNodeType)("TSExpressionWithTypeArguments", "ClassImplements"))), - optional: true - }, - decorators: { - validate: (0, _utils.chain)((0, _utils.assertValueType)("array"), (0, _utils.assertEach)((0, _utils.assertNodeType)("Decorator"))), - optional: true - }, - mixins: { - validate: (0, _utils.assertNodeType)("InterfaceExtends"), - optional: true - }, - declare: { - validate: (0, _utils.assertValueType)("boolean"), - optional: true - }, - abstract: { - validate: (0, _utils.assertValueType)("boolean"), - optional: true - } - }, - validate: function () { - const identifier = (0, _utils.assertNodeType)("Identifier"); - return function (parent, key, node) { - if (!process.env.BABEL_TYPES_8_BREAKING) return; - if (!(0, _is.default)("ExportDefaultDeclaration", parent)) { - identifier(node, "id", node.id); - } - }; - }() -}); -defineType("ExportAllDeclaration", { - builder: ["source"], - visitor: ["source", "attributes", "assertions"], - aliases: ["Statement", "Declaration", "ImportOrExportDeclaration", "ExportDeclaration"], - fields: { - source: { - validate: (0, _utils.assertNodeType)("StringLiteral") - }, - exportKind: (0, _utils.validateOptional)((0, _utils.assertOneOf)("type", "value")), - attributes: { - optional: true, - validate: (0, _utils.chain)((0, _utils.assertValueType)("array"), (0, _utils.assertEach)((0, _utils.assertNodeType)("ImportAttribute"))) - }, - assertions: { - optional: true, - validate: (0, _utils.chain)((0, _utils.assertValueType)("array"), (0, _utils.assertEach)((0, _utils.assertNodeType)("ImportAttribute"))) - } - } -}); -defineType("ExportDefaultDeclaration", { - visitor: ["declaration"], - aliases: ["Statement", "Declaration", "ImportOrExportDeclaration", "ExportDeclaration"], - fields: { - declaration: { - validate: (0, _utils.assertNodeType)("TSDeclareFunction", "FunctionDeclaration", "ClassDeclaration", "Expression") - }, - exportKind: (0, _utils.validateOptional)((0, _utils.assertOneOf)("value")) - } -}); -defineType("ExportNamedDeclaration", { - builder: ["declaration", "specifiers", "source"], - visitor: ["declaration", "specifiers", "source", "attributes", "assertions"], - aliases: ["Statement", "Declaration", "ImportOrExportDeclaration", "ExportDeclaration"], - fields: { - declaration: { - optional: true, - validate: (0, _utils.chain)((0, _utils.assertNodeType)("Declaration"), Object.assign(function (node, key, val) { - if (!process.env.BABEL_TYPES_8_BREAKING) return; - if (val && node.specifiers.length) { - throw new TypeError("Only declaration or specifiers is allowed on ExportNamedDeclaration"); - } - }, { - oneOfNodeTypes: ["Declaration"] - }), function (node, key, val) { - if (!process.env.BABEL_TYPES_8_BREAKING) return; - if (val && node.source) { - throw new TypeError("Cannot export a declaration from a source"); - } - }) - }, - attributes: { - optional: true, - validate: (0, _utils.chain)((0, _utils.assertValueType)("array"), (0, _utils.assertEach)((0, _utils.assertNodeType)("ImportAttribute"))) - }, - assertions: { - optional: true, - validate: (0, _utils.chain)((0, _utils.assertValueType)("array"), (0, _utils.assertEach)((0, _utils.assertNodeType)("ImportAttribute"))) - }, - specifiers: { - default: [], - validate: (0, _utils.chain)((0, _utils.assertValueType)("array"), (0, _utils.assertEach)(function () { - const sourced = (0, _utils.assertNodeType)("ExportSpecifier", "ExportDefaultSpecifier", "ExportNamespaceSpecifier"); - const sourceless = (0, _utils.assertNodeType)("ExportSpecifier"); - if (!process.env.BABEL_TYPES_8_BREAKING) return sourced; - return function (node, key, val) { - const validator = node.source ? sourced : sourceless; - validator(node, key, val); - }; - }())) - }, - source: { - validate: (0, _utils.assertNodeType)("StringLiteral"), - optional: true - }, - exportKind: (0, _utils.validateOptional)((0, _utils.assertOneOf)("type", "value")) - } -}); -defineType("ExportSpecifier", { - visitor: ["local", "exported"], - aliases: ["ModuleSpecifier"], - fields: { - local: { - validate: (0, _utils.assertNodeType)("Identifier") - }, - exported: { - validate: (0, _utils.assertNodeType)("Identifier", "StringLiteral") - }, - exportKind: { - validate: (0, _utils.assertOneOf)("type", "value"), - optional: true - } - } -}); -defineType("ForOfStatement", { - visitor: ["left", "right", "body"], - builder: ["left", "right", "body", "await"], - aliases: ["Scopable", "Statement", "For", "BlockParent", "Loop", "ForXStatement"], - fields: { - left: { - validate: function () { - if (!process.env.BABEL_TYPES_8_BREAKING) { - return (0, _utils.assertNodeType)("VariableDeclaration", "LVal"); - } - const declaration = (0, _utils.assertNodeType)("VariableDeclaration"); - const lval = (0, _utils.assertNodeType)("Identifier", "MemberExpression", "ArrayPattern", "ObjectPattern", "TSAsExpression", "TSSatisfiesExpression", "TSTypeAssertion", "TSNonNullExpression"); - return function (node, key, val) { - if ((0, _is.default)("VariableDeclaration", val)) { - declaration(node, key, val); - } else { - lval(node, key, val); - } - }; - }() - }, - right: { - validate: (0, _utils.assertNodeType)("Expression") - }, - body: { - validate: (0, _utils.assertNodeType)("Statement") - }, - await: { - default: false - } - } -}); -defineType("ImportDeclaration", { - builder: ["specifiers", "source"], - visitor: ["specifiers", "source", "attributes", "assertions"], - aliases: ["Statement", "Declaration", "ImportOrExportDeclaration"], - fields: { - attributes: { - optional: true, - validate: (0, _utils.chain)((0, _utils.assertValueType)("array"), (0, _utils.assertEach)((0, _utils.assertNodeType)("ImportAttribute"))) - }, - assertions: { - optional: true, - validate: (0, _utils.chain)((0, _utils.assertValueType)("array"), (0, _utils.assertEach)((0, _utils.assertNodeType)("ImportAttribute"))) - }, - module: { - optional: true, - validate: (0, _utils.assertValueType)("boolean") - }, - phase: { - default: null, - validate: (0, _utils.assertOneOf)("source", "defer") - }, - specifiers: { - validate: (0, _utils.chain)((0, _utils.assertValueType)("array"), (0, _utils.assertEach)((0, _utils.assertNodeType)("ImportSpecifier", "ImportDefaultSpecifier", "ImportNamespaceSpecifier"))) - }, - source: { - validate: (0, _utils.assertNodeType)("StringLiteral") - }, - importKind: { - validate: (0, _utils.assertOneOf)("type", "typeof", "value"), - optional: true - } - } -}); -defineType("ImportDefaultSpecifier", { - visitor: ["local"], - aliases: ["ModuleSpecifier"], - fields: { - local: { - validate: (0, _utils.assertNodeType)("Identifier") - } - } -}); -defineType("ImportNamespaceSpecifier", { - visitor: ["local"], - aliases: ["ModuleSpecifier"], - fields: { - local: { - validate: (0, _utils.assertNodeType)("Identifier") - } - } -}); -defineType("ImportSpecifier", { - visitor: ["local", "imported"], - aliases: ["ModuleSpecifier"], - fields: { - local: { - validate: (0, _utils.assertNodeType)("Identifier") - }, - imported: { - validate: (0, _utils.assertNodeType)("Identifier", "StringLiteral") - }, - importKind: { - validate: (0, _utils.assertOneOf)("type", "typeof", "value"), - optional: true - } - } -}); -defineType("ImportExpression", { - visitor: ["source", "options"], - aliases: ["Expression"], - fields: { - phase: { - default: null, - validate: (0, _utils.assertOneOf)("source", "defer") - }, - source: { - validate: (0, _utils.assertNodeType)("Expression") - }, - options: { - validate: (0, _utils.assertNodeType)("Expression"), - optional: true - } - } -}); -defineType("MetaProperty", { - visitor: ["meta", "property"], - aliases: ["Expression"], - fields: { - meta: { - validate: (0, _utils.chain)((0, _utils.assertNodeType)("Identifier"), Object.assign(function (node, key, val) { - if (!process.env.BABEL_TYPES_8_BREAKING) return; - let property; - switch (val.name) { - case "function": - property = "sent"; - break; - case "new": - property = "target"; - break; - case "import": - property = "meta"; - break; - } - if (!(0, _is.default)("Identifier", node.property, { - name: property - })) { - throw new TypeError("Unrecognised MetaProperty"); - } - }, { - oneOfNodeTypes: ["Identifier"] - })) - }, - property: { - validate: (0, _utils.assertNodeType)("Identifier") - } - } -}); -const classMethodOrPropertyCommon = () => ({ - abstract: { - validate: (0, _utils.assertValueType)("boolean"), - optional: true - }, - accessibility: { - validate: (0, _utils.assertOneOf)("public", "private", "protected"), - optional: true - }, - static: { - default: false - }, - override: { - default: false - }, - computed: { - default: false - }, - optional: { - validate: (0, _utils.assertValueType)("boolean"), - optional: true - }, - key: { - validate: (0, _utils.chain)(function () { - const normal = (0, _utils.assertNodeType)("Identifier", "StringLiteral", "NumericLiteral", "BigIntLiteral"); - const computed = (0, _utils.assertNodeType)("Expression"); - return function (node, key, val) { - const validator = node.computed ? computed : normal; - validator(node, key, val); - }; - }(), (0, _utils.assertNodeType)("Identifier", "StringLiteral", "NumericLiteral", "BigIntLiteral", "Expression")) - } -}); -exports.classMethodOrPropertyCommon = classMethodOrPropertyCommon; -const classMethodOrDeclareMethodCommon = () => Object.assign({}, functionCommon(), classMethodOrPropertyCommon(), { - params: { - validate: (0, _utils.chain)((0, _utils.assertValueType)("array"), (0, _utils.assertEach)((0, _utils.assertNodeType)("Identifier", "Pattern", "RestElement", "TSParameterProperty"))) - }, - kind: { - validate: (0, _utils.assertOneOf)("get", "set", "method", "constructor"), - default: "method" - }, - access: { - validate: (0, _utils.chain)((0, _utils.assertValueType)("string"), (0, _utils.assertOneOf)("public", "private", "protected")), - optional: true - }, - decorators: { - validate: (0, _utils.chain)((0, _utils.assertValueType)("array"), (0, _utils.assertEach)((0, _utils.assertNodeType)("Decorator"))), - optional: true - } -}); -exports.classMethodOrDeclareMethodCommon = classMethodOrDeclareMethodCommon; -defineType("ClassMethod", { - aliases: ["Function", "Scopable", "BlockParent", "FunctionParent", "Method"], - builder: ["kind", "key", "params", "body", "computed", "static", "generator", "async"], - visitor: ["key", "params", "body", "decorators", "returnType", "typeParameters"], - fields: Object.assign({}, classMethodOrDeclareMethodCommon(), functionTypeAnnotationCommon(), { - body: { - validate: (0, _utils.assertNodeType)("BlockStatement") - } - }) -}); -defineType("ObjectPattern", { - visitor: ["properties", "typeAnnotation", "decorators"], - builder: ["properties"], - aliases: ["Pattern", "PatternLike", "LVal"], - fields: Object.assign({}, patternLikeCommon(), { - properties: { - validate: (0, _utils.chain)((0, _utils.assertValueType)("array"), (0, _utils.assertEach)((0, _utils.assertNodeType)("RestElement", "ObjectProperty"))) - } - }) -}); -defineType("SpreadElement", { - visitor: ["argument"], - aliases: ["UnaryLike"], - deprecatedAlias: "SpreadProperty", - fields: { - argument: { - validate: (0, _utils.assertNodeType)("Expression") - } - } -}); -defineType("Super", { - aliases: ["Expression"] -}); -defineType("TaggedTemplateExpression", { - visitor: ["tag", "quasi", "typeParameters"], - builder: ["tag", "quasi"], - aliases: ["Expression"], - fields: { - tag: { - validate: (0, _utils.assertNodeType)("Expression") - }, - quasi: { - validate: (0, _utils.assertNodeType)("TemplateLiteral") - }, - typeParameters: { - validate: (0, _utils.assertNodeType)("TypeParameterInstantiation", "TSTypeParameterInstantiation"), - optional: true - } - } -}); -defineType("TemplateElement", { - builder: ["value", "tail"], - fields: { - value: { - validate: (0, _utils.chain)((0, _utils.assertShape)({ - raw: { - validate: (0, _utils.assertValueType)("string") - }, - cooked: { - validate: (0, _utils.assertValueType)("string"), - optional: true - } - }), function templateElementCookedValidator(node) { - const raw = node.value.raw; - let unterminatedCalled = false; - const error = () => { - throw new Error("Internal @babel/types error."); - }; - const { - str, - firstInvalidLoc - } = (0, _helperStringParser.readStringContents)("template", raw, 0, 0, 0, { - unterminated() { - unterminatedCalled = true; - }, - strictNumericEscape: error, - invalidEscapeSequence: error, - numericSeparatorInEscapeSequence: error, - unexpectedNumericSeparator: error, - invalidDigit: error, - invalidCodePoint: error - }); - if (!unterminatedCalled) throw new Error("Invalid raw"); - node.value.cooked = firstInvalidLoc ? null : str; - }) - }, - tail: { - default: false - } - } -}); -defineType("TemplateLiteral", { - visitor: ["quasis", "expressions"], - aliases: ["Expression", "Literal"], - fields: { - quasis: { - validate: (0, _utils.chain)((0, _utils.assertValueType)("array"), (0, _utils.assertEach)((0, _utils.assertNodeType)("TemplateElement"))) - }, - expressions: { - validate: (0, _utils.chain)((0, _utils.assertValueType)("array"), (0, _utils.assertEach)((0, _utils.assertNodeType)("Expression", "TSType")), function (node, key, val) { - if (node.quasis.length !== val.length + 1) { - throw new TypeError(`Number of ${node.type} quasis should be exactly one more than the number of expressions.\nExpected ${val.length + 1} quasis but got ${node.quasis.length}`); - } - }) - } - } -}); -defineType("YieldExpression", { - builder: ["argument", "delegate"], - visitor: ["argument"], - aliases: ["Expression", "Terminatorless"], - fields: { - delegate: { - validate: (0, _utils.chain)((0, _utils.assertValueType)("boolean"), Object.assign(function (node, key, val) { - if (!process.env.BABEL_TYPES_8_BREAKING) return; - if (val && !node.argument) { - throw new TypeError("Property delegate of YieldExpression cannot be true if there is no argument"); - } - }, { - type: "boolean" - })), - default: false - }, - argument: { - optional: true, - validate: (0, _utils.assertNodeType)("Expression") - } - } -}); -defineType("AwaitExpression", { - builder: ["argument"], - visitor: ["argument"], - aliases: ["Expression", "Terminatorless"], - fields: { - argument: { - validate: (0, _utils.assertNodeType)("Expression") - } - } -}); -defineType("Import", { - aliases: ["Expression"] -}); -defineType("BigIntLiteral", { - builder: ["value"], - fields: { - value: { - validate: (0, _utils.assertValueType)("string") - } - }, - aliases: ["Expression", "Pureish", "Literal", "Immutable"] -}); -defineType("ExportNamespaceSpecifier", { - visitor: ["exported"], - aliases: ["ModuleSpecifier"], - fields: { - exported: { - validate: (0, _utils.assertNodeType)("Identifier") - } - } -}); -defineType("OptionalMemberExpression", { - builder: ["object", "property", "computed", "optional"], - visitor: ["object", "property"], - aliases: ["Expression"], - fields: { - object: { - validate: (0, _utils.assertNodeType)("Expression") - }, - property: { - validate: function () { - const normal = (0, _utils.assertNodeType)("Identifier"); - const computed = (0, _utils.assertNodeType)("Expression"); - const validator = Object.assign(function (node, key, val) { - const validator = node.computed ? computed : normal; - validator(node, key, val); - }, { - oneOfNodeTypes: ["Expression", "Identifier"] - }); - return validator; - }() - }, - computed: { - default: false - }, - optional: { - validate: !process.env.BABEL_TYPES_8_BREAKING ? (0, _utils.assertValueType)("boolean") : (0, _utils.chain)((0, _utils.assertValueType)("boolean"), (0, _utils.assertOptionalChainStart)()) - } - } -}); -defineType("OptionalCallExpression", { - visitor: ["callee", "arguments", "typeParameters", "typeArguments"], - builder: ["callee", "arguments", "optional"], - aliases: ["Expression"], - fields: { - callee: { - validate: (0, _utils.assertNodeType)("Expression") - }, - arguments: { - validate: (0, _utils.chain)((0, _utils.assertValueType)("array"), (0, _utils.assertEach)((0, _utils.assertNodeType)("Expression", "SpreadElement", "ArgumentPlaceholder"))) - }, - optional: { - validate: !process.env.BABEL_TYPES_8_BREAKING ? (0, _utils.assertValueType)("boolean") : (0, _utils.chain)((0, _utils.assertValueType)("boolean"), (0, _utils.assertOptionalChainStart)()) - }, - typeArguments: { - validate: (0, _utils.assertNodeType)("TypeParameterInstantiation"), - optional: true - }, - typeParameters: { - validate: (0, _utils.assertNodeType)("TSTypeParameterInstantiation"), - optional: true - } - } -}); -defineType("ClassProperty", { - visitor: ["key", "value", "typeAnnotation", "decorators"], - builder: ["key", "value", "typeAnnotation", "decorators", "computed", "static"], - aliases: ["Property"], - fields: Object.assign({}, classMethodOrPropertyCommon(), { - value: { - validate: (0, _utils.assertNodeType)("Expression"), - optional: true - }, - definite: { - validate: (0, _utils.assertValueType)("boolean"), - optional: true - }, - typeAnnotation: { - validate: (0, _utils.assertNodeType)("TypeAnnotation", "TSTypeAnnotation", "Noop"), - optional: true - }, - decorators: { - validate: (0, _utils.chain)((0, _utils.assertValueType)("array"), (0, _utils.assertEach)((0, _utils.assertNodeType)("Decorator"))), - optional: true - }, - readonly: { - validate: (0, _utils.assertValueType)("boolean"), - optional: true - }, - declare: { - validate: (0, _utils.assertValueType)("boolean"), - optional: true - }, - variance: { - validate: (0, _utils.assertNodeType)("Variance"), - optional: true - } - }) -}); -defineType("ClassAccessorProperty", { - visitor: ["key", "value", "typeAnnotation", "decorators"], - builder: ["key", "value", "typeAnnotation", "decorators", "computed", "static"], - aliases: ["Property", "Accessor"], - fields: Object.assign({}, classMethodOrPropertyCommon(), { - key: { - validate: (0, _utils.chain)(function () { - const normal = (0, _utils.assertNodeType)("Identifier", "StringLiteral", "NumericLiteral", "BigIntLiteral", "PrivateName"); - const computed = (0, _utils.assertNodeType)("Expression"); - return function (node, key, val) { - const validator = node.computed ? computed : normal; - validator(node, key, val); - }; - }(), (0, _utils.assertNodeType)("Identifier", "StringLiteral", "NumericLiteral", "BigIntLiteral", "Expression", "PrivateName")) - }, - value: { - validate: (0, _utils.assertNodeType)("Expression"), - optional: true - }, - definite: { - validate: (0, _utils.assertValueType)("boolean"), - optional: true - }, - typeAnnotation: { - validate: (0, _utils.assertNodeType)("TypeAnnotation", "TSTypeAnnotation", "Noop"), - optional: true - }, - decorators: { - validate: (0, _utils.chain)((0, _utils.assertValueType)("array"), (0, _utils.assertEach)((0, _utils.assertNodeType)("Decorator"))), - optional: true - }, - readonly: { - validate: (0, _utils.assertValueType)("boolean"), - optional: true - }, - declare: { - validate: (0, _utils.assertValueType)("boolean"), - optional: true - }, - variance: { - validate: (0, _utils.assertNodeType)("Variance"), - optional: true - } - }) -}); -defineType("ClassPrivateProperty", { - visitor: ["key", "value", "decorators", "typeAnnotation"], - builder: ["key", "value", "decorators", "static"], - aliases: ["Property", "Private"], - fields: { - key: { - validate: (0, _utils.assertNodeType)("PrivateName") - }, - value: { - validate: (0, _utils.assertNodeType)("Expression"), - optional: true - }, - typeAnnotation: { - validate: (0, _utils.assertNodeType)("TypeAnnotation", "TSTypeAnnotation", "Noop"), - optional: true - }, - decorators: { - validate: (0, _utils.chain)((0, _utils.assertValueType)("array"), (0, _utils.assertEach)((0, _utils.assertNodeType)("Decorator"))), - optional: true - }, - static: { - validate: (0, _utils.assertValueType)("boolean"), - default: false - }, - readonly: { - validate: (0, _utils.assertValueType)("boolean"), - optional: true - }, - definite: { - validate: (0, _utils.assertValueType)("boolean"), - optional: true - }, - variance: { - validate: (0, _utils.assertNodeType)("Variance"), - optional: true - } - } -}); -defineType("ClassPrivateMethod", { - builder: ["kind", "key", "params", "body", "static"], - visitor: ["key", "params", "body", "decorators", "returnType", "typeParameters"], - aliases: ["Function", "Scopable", "BlockParent", "FunctionParent", "Method", "Private"], - fields: Object.assign({}, classMethodOrDeclareMethodCommon(), functionTypeAnnotationCommon(), { - kind: { - validate: (0, _utils.assertOneOf)("get", "set", "method"), - default: "method" - }, - key: { - validate: (0, _utils.assertNodeType)("PrivateName") - }, - body: { - validate: (0, _utils.assertNodeType)("BlockStatement") - } - }) -}); -defineType("PrivateName", { - visitor: ["id"], - aliases: ["Private"], - fields: { - id: { - validate: (0, _utils.assertNodeType)("Identifier") - } - } -}); -defineType("StaticBlock", { - visitor: ["body"], - fields: { - body: { - validate: (0, _utils.chain)((0, _utils.assertValueType)("array"), (0, _utils.assertEach)((0, _utils.assertNodeType)("Statement"))) - } - }, - aliases: ["Scopable", "BlockParent", "FunctionParent"] -}); - -//# sourceMappingURL=core.js.map diff --git a/tools/eslint/node_modules/@babel/types/lib/definitions/deprecated-aliases.js b/tools/eslint/node_modules/@babel/types/lib/definitions/deprecated-aliases.js deleted file mode 100644 index 03a375173239da..00000000000000 --- a/tools/eslint/node_modules/@babel/types/lib/definitions/deprecated-aliases.js +++ /dev/null @@ -1,11 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.DEPRECATED_ALIASES = void 0; -const DEPRECATED_ALIASES = exports.DEPRECATED_ALIASES = { - ModuleDeclaration: "ImportOrExportDeclaration" -}; - -//# sourceMappingURL=deprecated-aliases.js.map diff --git a/tools/eslint/node_modules/@babel/types/lib/definitions/experimental.js b/tools/eslint/node_modules/@babel/types/lib/definitions/experimental.js deleted file mode 100644 index 38e1fc1820bb19..00000000000000 --- a/tools/eslint/node_modules/@babel/types/lib/definitions/experimental.js +++ /dev/null @@ -1,134 +0,0 @@ -"use strict"; - -var _utils = require("./utils.js"); -(0, _utils.default)("ArgumentPlaceholder", {}); -(0, _utils.default)("BindExpression", { - visitor: ["object", "callee"], - aliases: ["Expression"], - fields: !process.env.BABEL_TYPES_8_BREAKING ? { - object: { - validate: Object.assign(() => {}, { - oneOfNodeTypes: ["Expression"] - }) - }, - callee: { - validate: Object.assign(() => {}, { - oneOfNodeTypes: ["Expression"] - }) - } - } : { - object: { - validate: (0, _utils.assertNodeType)("Expression") - }, - callee: { - validate: (0, _utils.assertNodeType)("Expression") - } - } -}); -(0, _utils.default)("ImportAttribute", { - visitor: ["key", "value"], - fields: { - key: { - validate: (0, _utils.assertNodeType)("Identifier", "StringLiteral") - }, - value: { - validate: (0, _utils.assertNodeType)("StringLiteral") - } - } -}); -(0, _utils.default)("Decorator", { - visitor: ["expression"], - fields: { - expression: { - validate: (0, _utils.assertNodeType)("Expression") - } - } -}); -(0, _utils.default)("DoExpression", { - visitor: ["body"], - builder: ["body", "async"], - aliases: ["Expression"], - fields: { - body: { - validate: (0, _utils.assertNodeType)("BlockStatement") - }, - async: { - validate: (0, _utils.assertValueType)("boolean"), - default: false - } - } -}); -(0, _utils.default)("ExportDefaultSpecifier", { - visitor: ["exported"], - aliases: ["ModuleSpecifier"], - fields: { - exported: { - validate: (0, _utils.assertNodeType)("Identifier") - } - } -}); -(0, _utils.default)("RecordExpression", { - visitor: ["properties"], - aliases: ["Expression"], - fields: { - properties: { - validate: (0, _utils.chain)((0, _utils.assertValueType)("array"), (0, _utils.assertEach)((0, _utils.assertNodeType)("ObjectProperty", "SpreadElement"))) - } - } -}); -(0, _utils.default)("TupleExpression", { - fields: { - elements: { - validate: (0, _utils.chain)((0, _utils.assertValueType)("array"), (0, _utils.assertEach)((0, _utils.assertNodeType)("Expression", "SpreadElement"))), - default: [] - } - }, - visitor: ["elements"], - aliases: ["Expression"] -}); -(0, _utils.default)("DecimalLiteral", { - builder: ["value"], - fields: { - value: { - validate: (0, _utils.assertValueType)("string") - } - }, - aliases: ["Expression", "Pureish", "Literal", "Immutable"] -}); -(0, _utils.default)("ModuleExpression", { - visitor: ["body"], - fields: { - body: { - validate: (0, _utils.assertNodeType)("Program") - } - }, - aliases: ["Expression"] -}); -(0, _utils.default)("TopicReference", { - aliases: ["Expression"] -}); -(0, _utils.default)("PipelineTopicExpression", { - builder: ["expression"], - visitor: ["expression"], - fields: { - expression: { - validate: (0, _utils.assertNodeType)("Expression") - } - }, - aliases: ["Expression"] -}); -(0, _utils.default)("PipelineBareFunction", { - builder: ["callee"], - visitor: ["callee"], - fields: { - callee: { - validate: (0, _utils.assertNodeType)("Expression") - } - }, - aliases: ["Expression"] -}); -(0, _utils.default)("PipelinePrimaryTopicReference", { - aliases: ["Expression"] -}); - -//# sourceMappingURL=experimental.js.map diff --git a/tools/eslint/node_modules/@babel/types/lib/definitions/flow.js b/tools/eslint/node_modules/@babel/types/lib/definitions/flow.js deleted file mode 100644 index 64ccefbc4b9853..00000000000000 --- a/tools/eslint/node_modules/@babel/types/lib/definitions/flow.js +++ /dev/null @@ -1,489 +0,0 @@ -"use strict"; - -var _utils = require("./utils.js"); -const defineType = (0, _utils.defineAliasedType)("Flow"); -const defineInterfaceishType = name => { - const isDeclareClass = name === "DeclareClass"; - defineType(name, { - builder: ["id", "typeParameters", "extends", "body"], - visitor: ["id", "typeParameters", "extends", ...(isDeclareClass ? ["mixins", "implements"] : []), "body"], - aliases: ["FlowDeclaration", "Statement", "Declaration"], - fields: Object.assign({ - id: (0, _utils.validateType)("Identifier"), - typeParameters: (0, _utils.validateOptionalType)("TypeParameterDeclaration"), - extends: (0, _utils.validateOptional)((0, _utils.arrayOfType)("InterfaceExtends")) - }, isDeclareClass ? { - mixins: (0, _utils.validateOptional)((0, _utils.arrayOfType)("InterfaceExtends")), - implements: (0, _utils.validateOptional)((0, _utils.arrayOfType)("ClassImplements")) - } : {}, { - body: (0, _utils.validateType)("ObjectTypeAnnotation") - }) - }); -}; -defineType("AnyTypeAnnotation", { - aliases: ["FlowType", "FlowBaseAnnotation"] -}); -defineType("ArrayTypeAnnotation", { - visitor: ["elementType"], - aliases: ["FlowType"], - fields: { - elementType: (0, _utils.validateType)("FlowType") - } -}); -defineType("BooleanTypeAnnotation", { - aliases: ["FlowType", "FlowBaseAnnotation"] -}); -defineType("BooleanLiteralTypeAnnotation", { - builder: ["value"], - aliases: ["FlowType"], - fields: { - value: (0, _utils.validate)((0, _utils.assertValueType)("boolean")) - } -}); -defineType("NullLiteralTypeAnnotation", { - aliases: ["FlowType", "FlowBaseAnnotation"] -}); -defineType("ClassImplements", { - visitor: ["id", "typeParameters"], - fields: { - id: (0, _utils.validateType)("Identifier"), - typeParameters: (0, _utils.validateOptionalType)("TypeParameterInstantiation") - } -}); -defineInterfaceishType("DeclareClass"); -defineType("DeclareFunction", { - visitor: ["id"], - aliases: ["FlowDeclaration", "Statement", "Declaration"], - fields: { - id: (0, _utils.validateType)("Identifier"), - predicate: (0, _utils.validateOptionalType)("DeclaredPredicate") - } -}); -defineInterfaceishType("DeclareInterface"); -defineType("DeclareModule", { - builder: ["id", "body", "kind"], - visitor: ["id", "body"], - aliases: ["FlowDeclaration", "Statement", "Declaration"], - fields: { - id: (0, _utils.validateType)(["Identifier", "StringLiteral"]), - body: (0, _utils.validateType)("BlockStatement"), - kind: (0, _utils.validateOptional)((0, _utils.assertOneOf)("CommonJS", "ES")) - } -}); -defineType("DeclareModuleExports", { - visitor: ["typeAnnotation"], - aliases: ["FlowDeclaration", "Statement", "Declaration"], - fields: { - typeAnnotation: (0, _utils.validateType)("TypeAnnotation") - } -}); -defineType("DeclareTypeAlias", { - visitor: ["id", "typeParameters", "right"], - aliases: ["FlowDeclaration", "Statement", "Declaration"], - fields: { - id: (0, _utils.validateType)("Identifier"), - typeParameters: (0, _utils.validateOptionalType)("TypeParameterDeclaration"), - right: (0, _utils.validateType)("FlowType") - } -}); -defineType("DeclareOpaqueType", { - visitor: ["id", "typeParameters", "supertype"], - aliases: ["FlowDeclaration", "Statement", "Declaration"], - fields: { - id: (0, _utils.validateType)("Identifier"), - typeParameters: (0, _utils.validateOptionalType)("TypeParameterDeclaration"), - supertype: (0, _utils.validateOptionalType)("FlowType"), - impltype: (0, _utils.validateOptionalType)("FlowType") - } -}); -defineType("DeclareVariable", { - visitor: ["id"], - aliases: ["FlowDeclaration", "Statement", "Declaration"], - fields: { - id: (0, _utils.validateType)("Identifier") - } -}); -defineType("DeclareExportDeclaration", { - visitor: ["declaration", "specifiers", "source"], - aliases: ["FlowDeclaration", "Statement", "Declaration"], - fields: { - declaration: (0, _utils.validateOptionalType)("Flow"), - specifiers: (0, _utils.validateOptional)((0, _utils.arrayOfType)(["ExportSpecifier", "ExportNamespaceSpecifier"])), - source: (0, _utils.validateOptionalType)("StringLiteral"), - default: (0, _utils.validateOptional)((0, _utils.assertValueType)("boolean")) - } -}); -defineType("DeclareExportAllDeclaration", { - visitor: ["source"], - aliases: ["FlowDeclaration", "Statement", "Declaration"], - fields: { - source: (0, _utils.validateType)("StringLiteral"), - exportKind: (0, _utils.validateOptional)((0, _utils.assertOneOf)("type", "value")) - } -}); -defineType("DeclaredPredicate", { - visitor: ["value"], - aliases: ["FlowPredicate"], - fields: { - value: (0, _utils.validateType)("Flow") - } -}); -defineType("ExistsTypeAnnotation", { - aliases: ["FlowType"] -}); -defineType("FunctionTypeAnnotation", { - visitor: ["typeParameters", "params", "rest", "returnType"], - aliases: ["FlowType"], - fields: { - typeParameters: (0, _utils.validateOptionalType)("TypeParameterDeclaration"), - params: (0, _utils.validate)((0, _utils.arrayOfType)("FunctionTypeParam")), - rest: (0, _utils.validateOptionalType)("FunctionTypeParam"), - this: (0, _utils.validateOptionalType)("FunctionTypeParam"), - returnType: (0, _utils.validateType)("FlowType") - } -}); -defineType("FunctionTypeParam", { - visitor: ["name", "typeAnnotation"], - fields: { - name: (0, _utils.validateOptionalType)("Identifier"), - typeAnnotation: (0, _utils.validateType)("FlowType"), - optional: (0, _utils.validateOptional)((0, _utils.assertValueType)("boolean")) - } -}); -defineType("GenericTypeAnnotation", { - visitor: ["id", "typeParameters"], - aliases: ["FlowType"], - fields: { - id: (0, _utils.validateType)(["Identifier", "QualifiedTypeIdentifier"]), - typeParameters: (0, _utils.validateOptionalType)("TypeParameterInstantiation") - } -}); -defineType("InferredPredicate", { - aliases: ["FlowPredicate"] -}); -defineType("InterfaceExtends", { - visitor: ["id", "typeParameters"], - fields: { - id: (0, _utils.validateType)(["Identifier", "QualifiedTypeIdentifier"]), - typeParameters: (0, _utils.validateOptionalType)("TypeParameterInstantiation") - } -}); -defineInterfaceishType("InterfaceDeclaration"); -defineType("InterfaceTypeAnnotation", { - visitor: ["extends", "body"], - aliases: ["FlowType"], - fields: { - extends: (0, _utils.validateOptional)((0, _utils.arrayOfType)("InterfaceExtends")), - body: (0, _utils.validateType)("ObjectTypeAnnotation") - } -}); -defineType("IntersectionTypeAnnotation", { - visitor: ["types"], - aliases: ["FlowType"], - fields: { - types: (0, _utils.validate)((0, _utils.arrayOfType)("FlowType")) - } -}); -defineType("MixedTypeAnnotation", { - aliases: ["FlowType", "FlowBaseAnnotation"] -}); -defineType("EmptyTypeAnnotation", { - aliases: ["FlowType", "FlowBaseAnnotation"] -}); -defineType("NullableTypeAnnotation", { - visitor: ["typeAnnotation"], - aliases: ["FlowType"], - fields: { - typeAnnotation: (0, _utils.validateType)("FlowType") - } -}); -defineType("NumberLiteralTypeAnnotation", { - builder: ["value"], - aliases: ["FlowType"], - fields: { - value: (0, _utils.validate)((0, _utils.assertValueType)("number")) - } -}); -defineType("NumberTypeAnnotation", { - aliases: ["FlowType", "FlowBaseAnnotation"] -}); -defineType("ObjectTypeAnnotation", { - visitor: ["properties", "indexers", "callProperties", "internalSlots"], - aliases: ["FlowType"], - builder: ["properties", "indexers", "callProperties", "internalSlots", "exact"], - fields: { - properties: (0, _utils.validate)((0, _utils.arrayOfType)(["ObjectTypeProperty", "ObjectTypeSpreadProperty"])), - indexers: { - validate: (0, _utils.arrayOfType)("ObjectTypeIndexer"), - optional: true, - default: [] - }, - callProperties: { - validate: (0, _utils.arrayOfType)("ObjectTypeCallProperty"), - optional: true, - default: [] - }, - internalSlots: { - validate: (0, _utils.arrayOfType)("ObjectTypeInternalSlot"), - optional: true, - default: [] - }, - exact: { - validate: (0, _utils.assertValueType)("boolean"), - default: false - }, - inexact: (0, _utils.validateOptional)((0, _utils.assertValueType)("boolean")) - } -}); -defineType("ObjectTypeInternalSlot", { - visitor: ["id", "value"], - builder: ["id", "value", "optional", "static", "method"], - aliases: ["UserWhitespacable"], - fields: { - id: (0, _utils.validateType)("Identifier"), - value: (0, _utils.validateType)("FlowType"), - optional: (0, _utils.validate)((0, _utils.assertValueType)("boolean")), - static: (0, _utils.validate)((0, _utils.assertValueType)("boolean")), - method: (0, _utils.validate)((0, _utils.assertValueType)("boolean")) - } -}); -defineType("ObjectTypeCallProperty", { - visitor: ["value"], - aliases: ["UserWhitespacable"], - fields: { - value: (0, _utils.validateType)("FlowType"), - static: (0, _utils.validate)((0, _utils.assertValueType)("boolean")) - } -}); -defineType("ObjectTypeIndexer", { - visitor: ["id", "key", "value", "variance"], - aliases: ["UserWhitespacable"], - fields: { - id: (0, _utils.validateOptionalType)("Identifier"), - key: (0, _utils.validateType)("FlowType"), - value: (0, _utils.validateType)("FlowType"), - static: (0, _utils.validate)((0, _utils.assertValueType)("boolean")), - variance: (0, _utils.validateOptionalType)("Variance") - } -}); -defineType("ObjectTypeProperty", { - visitor: ["key", "value", "variance"], - aliases: ["UserWhitespacable"], - fields: { - key: (0, _utils.validateType)(["Identifier", "StringLiteral"]), - value: (0, _utils.validateType)("FlowType"), - kind: (0, _utils.validate)((0, _utils.assertOneOf)("init", "get", "set")), - static: (0, _utils.validate)((0, _utils.assertValueType)("boolean")), - proto: (0, _utils.validate)((0, _utils.assertValueType)("boolean")), - optional: (0, _utils.validate)((0, _utils.assertValueType)("boolean")), - variance: (0, _utils.validateOptionalType)("Variance"), - method: (0, _utils.validate)((0, _utils.assertValueType)("boolean")) - } -}); -defineType("ObjectTypeSpreadProperty", { - visitor: ["argument"], - aliases: ["UserWhitespacable"], - fields: { - argument: (0, _utils.validateType)("FlowType") - } -}); -defineType("OpaqueType", { - visitor: ["id", "typeParameters", "supertype", "impltype"], - aliases: ["FlowDeclaration", "Statement", "Declaration"], - fields: { - id: (0, _utils.validateType)("Identifier"), - typeParameters: (0, _utils.validateOptionalType)("TypeParameterDeclaration"), - supertype: (0, _utils.validateOptionalType)("FlowType"), - impltype: (0, _utils.validateType)("FlowType") - } -}); -defineType("QualifiedTypeIdentifier", { - visitor: ["id", "qualification"], - fields: { - id: (0, _utils.validateType)("Identifier"), - qualification: (0, _utils.validateType)(["Identifier", "QualifiedTypeIdentifier"]) - } -}); -defineType("StringLiteralTypeAnnotation", { - builder: ["value"], - aliases: ["FlowType"], - fields: { - value: (0, _utils.validate)((0, _utils.assertValueType)("string")) - } -}); -defineType("StringTypeAnnotation", { - aliases: ["FlowType", "FlowBaseAnnotation"] -}); -defineType("SymbolTypeAnnotation", { - aliases: ["FlowType", "FlowBaseAnnotation"] -}); -defineType("ThisTypeAnnotation", { - aliases: ["FlowType", "FlowBaseAnnotation"] -}); -defineType("TupleTypeAnnotation", { - visitor: ["types"], - aliases: ["FlowType"], - fields: { - types: (0, _utils.validate)((0, _utils.arrayOfType)("FlowType")) - } -}); -defineType("TypeofTypeAnnotation", { - visitor: ["argument"], - aliases: ["FlowType"], - fields: { - argument: (0, _utils.validateType)("FlowType") - } -}); -defineType("TypeAlias", { - visitor: ["id", "typeParameters", "right"], - aliases: ["FlowDeclaration", "Statement", "Declaration"], - fields: { - id: (0, _utils.validateType)("Identifier"), - typeParameters: (0, _utils.validateOptionalType)("TypeParameterDeclaration"), - right: (0, _utils.validateType)("FlowType") - } -}); -defineType("TypeAnnotation", { - visitor: ["typeAnnotation"], - fields: { - typeAnnotation: (0, _utils.validateType)("FlowType") - } -}); -defineType("TypeCastExpression", { - visitor: ["expression", "typeAnnotation"], - aliases: ["ExpressionWrapper", "Expression"], - fields: { - expression: (0, _utils.validateType)("Expression"), - typeAnnotation: (0, _utils.validateType)("TypeAnnotation") - } -}); -defineType("TypeParameter", { - visitor: ["bound", "default", "variance"], - fields: { - name: (0, _utils.validate)((0, _utils.assertValueType)("string")), - bound: (0, _utils.validateOptionalType)("TypeAnnotation"), - default: (0, _utils.validateOptionalType)("FlowType"), - variance: (0, _utils.validateOptionalType)("Variance") - } -}); -defineType("TypeParameterDeclaration", { - visitor: ["params"], - fields: { - params: (0, _utils.validate)((0, _utils.arrayOfType)("TypeParameter")) - } -}); -defineType("TypeParameterInstantiation", { - visitor: ["params"], - fields: { - params: (0, _utils.validate)((0, _utils.arrayOfType)("FlowType")) - } -}); -defineType("UnionTypeAnnotation", { - visitor: ["types"], - aliases: ["FlowType"], - fields: { - types: (0, _utils.validate)((0, _utils.arrayOfType)("FlowType")) - } -}); -defineType("Variance", { - builder: ["kind"], - fields: { - kind: (0, _utils.validate)((0, _utils.assertOneOf)("minus", "plus")) - } -}); -defineType("VoidTypeAnnotation", { - aliases: ["FlowType", "FlowBaseAnnotation"] -}); -defineType("EnumDeclaration", { - aliases: ["Statement", "Declaration"], - visitor: ["id", "body"], - fields: { - id: (0, _utils.validateType)("Identifier"), - body: (0, _utils.validateType)(["EnumBooleanBody", "EnumNumberBody", "EnumStringBody", "EnumSymbolBody"]) - } -}); -defineType("EnumBooleanBody", { - aliases: ["EnumBody"], - visitor: ["members"], - fields: { - explicitType: (0, _utils.validate)((0, _utils.assertValueType)("boolean")), - members: (0, _utils.validateArrayOfType)("EnumBooleanMember"), - hasUnknownMembers: (0, _utils.validate)((0, _utils.assertValueType)("boolean")) - } -}); -defineType("EnumNumberBody", { - aliases: ["EnumBody"], - visitor: ["members"], - fields: { - explicitType: (0, _utils.validate)((0, _utils.assertValueType)("boolean")), - members: (0, _utils.validateArrayOfType)("EnumNumberMember"), - hasUnknownMembers: (0, _utils.validate)((0, _utils.assertValueType)("boolean")) - } -}); -defineType("EnumStringBody", { - aliases: ["EnumBody"], - visitor: ["members"], - fields: { - explicitType: (0, _utils.validate)((0, _utils.assertValueType)("boolean")), - members: (0, _utils.validateArrayOfType)(["EnumStringMember", "EnumDefaultedMember"]), - hasUnknownMembers: (0, _utils.validate)((0, _utils.assertValueType)("boolean")) - } -}); -defineType("EnumSymbolBody", { - aliases: ["EnumBody"], - visitor: ["members"], - fields: { - members: (0, _utils.validateArrayOfType)("EnumDefaultedMember"), - hasUnknownMembers: (0, _utils.validate)((0, _utils.assertValueType)("boolean")) - } -}); -defineType("EnumBooleanMember", { - aliases: ["EnumMember"], - visitor: ["id"], - fields: { - id: (0, _utils.validateType)("Identifier"), - init: (0, _utils.validateType)("BooleanLiteral") - } -}); -defineType("EnumNumberMember", { - aliases: ["EnumMember"], - visitor: ["id", "init"], - fields: { - id: (0, _utils.validateType)("Identifier"), - init: (0, _utils.validateType)("NumericLiteral") - } -}); -defineType("EnumStringMember", { - aliases: ["EnumMember"], - visitor: ["id", "init"], - fields: { - id: (0, _utils.validateType)("Identifier"), - init: (0, _utils.validateType)("StringLiteral") - } -}); -defineType("EnumDefaultedMember", { - aliases: ["EnumMember"], - visitor: ["id"], - fields: { - id: (0, _utils.validateType)("Identifier") - } -}); -defineType("IndexedAccessType", { - visitor: ["objectType", "indexType"], - aliases: ["FlowType"], - fields: { - objectType: (0, _utils.validateType)("FlowType"), - indexType: (0, _utils.validateType)("FlowType") - } -}); -defineType("OptionalIndexedAccessType", { - visitor: ["objectType", "indexType"], - aliases: ["FlowType"], - fields: { - objectType: (0, _utils.validateType)("FlowType"), - indexType: (0, _utils.validateType)("FlowType"), - optional: (0, _utils.validate)((0, _utils.assertValueType)("boolean")) - } -}); - -//# sourceMappingURL=flow.js.map diff --git a/tools/eslint/node_modules/@babel/types/lib/definitions/index.js b/tools/eslint/node_modules/@babel/types/lib/definitions/index.js deleted file mode 100644 index 1f9b95ca358416..00000000000000 --- a/tools/eslint/node_modules/@babel/types/lib/definitions/index.js +++ /dev/null @@ -1,96 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -Object.defineProperty(exports, "ALIAS_KEYS", { - enumerable: true, - get: function () { - return _utils.ALIAS_KEYS; - } -}); -Object.defineProperty(exports, "BUILDER_KEYS", { - enumerable: true, - get: function () { - return _utils.BUILDER_KEYS; - } -}); -Object.defineProperty(exports, "DEPRECATED_ALIASES", { - enumerable: true, - get: function () { - return _deprecatedAliases.DEPRECATED_ALIASES; - } -}); -Object.defineProperty(exports, "DEPRECATED_KEYS", { - enumerable: true, - get: function () { - return _utils.DEPRECATED_KEYS; - } -}); -Object.defineProperty(exports, "FLIPPED_ALIAS_KEYS", { - enumerable: true, - get: function () { - return _utils.FLIPPED_ALIAS_KEYS; - } -}); -Object.defineProperty(exports, "NODE_FIELDS", { - enumerable: true, - get: function () { - return _utils.NODE_FIELDS; - } -}); -Object.defineProperty(exports, "NODE_PARENT_VALIDATIONS", { - enumerable: true, - get: function () { - return _utils.NODE_PARENT_VALIDATIONS; - } -}); -Object.defineProperty(exports, "PLACEHOLDERS", { - enumerable: true, - get: function () { - return _placeholders.PLACEHOLDERS; - } -}); -Object.defineProperty(exports, "PLACEHOLDERS_ALIAS", { - enumerable: true, - get: function () { - return _placeholders.PLACEHOLDERS_ALIAS; - } -}); -Object.defineProperty(exports, "PLACEHOLDERS_FLIPPED_ALIAS", { - enumerable: true, - get: function () { - return _placeholders.PLACEHOLDERS_FLIPPED_ALIAS; - } -}); -exports.TYPES = void 0; -Object.defineProperty(exports, "VISITOR_KEYS", { - enumerable: true, - get: function () { - return _utils.VISITOR_KEYS; - } -}); -var _toFastProperties = require("to-fast-properties"); -require("./core.js"); -require("./flow.js"); -require("./jsx.js"); -require("./misc.js"); -require("./experimental.js"); -require("./typescript.js"); -var _utils = require("./utils.js"); -var _placeholders = require("./placeholders.js"); -var _deprecatedAliases = require("./deprecated-aliases.js"); -Object.keys(_deprecatedAliases.DEPRECATED_ALIASES).forEach(deprecatedAlias => { - _utils.FLIPPED_ALIAS_KEYS[deprecatedAlias] = _utils.FLIPPED_ALIAS_KEYS[_deprecatedAliases.DEPRECATED_ALIASES[deprecatedAlias]]; -}); -_toFastProperties(_utils.VISITOR_KEYS); -_toFastProperties(_utils.ALIAS_KEYS); -_toFastProperties(_utils.FLIPPED_ALIAS_KEYS); -_toFastProperties(_utils.NODE_FIELDS); -_toFastProperties(_utils.BUILDER_KEYS); -_toFastProperties(_utils.DEPRECATED_KEYS); -_toFastProperties(_placeholders.PLACEHOLDERS_ALIAS); -_toFastProperties(_placeholders.PLACEHOLDERS_FLIPPED_ALIAS); -const TYPES = exports.TYPES = [].concat(Object.keys(_utils.VISITOR_KEYS), Object.keys(_utils.FLIPPED_ALIAS_KEYS), Object.keys(_utils.DEPRECATED_KEYS)); - -//# sourceMappingURL=index.js.map diff --git a/tools/eslint/node_modules/@babel/types/lib/definitions/jsx.js b/tools/eslint/node_modules/@babel/types/lib/definitions/jsx.js deleted file mode 100644 index f83b0ee7db08d8..00000000000000 --- a/tools/eslint/node_modules/@babel/types/lib/definitions/jsx.js +++ /dev/null @@ -1,158 +0,0 @@ -"use strict"; - -var _utils = require("./utils.js"); -const defineType = (0, _utils.defineAliasedType)("JSX"); -defineType("JSXAttribute", { - visitor: ["name", "value"], - aliases: ["Immutable"], - fields: { - name: { - validate: (0, _utils.assertNodeType)("JSXIdentifier", "JSXNamespacedName") - }, - value: { - optional: true, - validate: (0, _utils.assertNodeType)("JSXElement", "JSXFragment", "StringLiteral", "JSXExpressionContainer") - } - } -}); -defineType("JSXClosingElement", { - visitor: ["name"], - aliases: ["Immutable"], - fields: { - name: { - validate: (0, _utils.assertNodeType)("JSXIdentifier", "JSXMemberExpression", "JSXNamespacedName") - } - } -}); -defineType("JSXElement", { - builder: ["openingElement", "closingElement", "children", "selfClosing"], - visitor: ["openingElement", "children", "closingElement"], - aliases: ["Immutable", "Expression"], - fields: Object.assign({ - openingElement: { - validate: (0, _utils.assertNodeType)("JSXOpeningElement") - }, - closingElement: { - optional: true, - validate: (0, _utils.assertNodeType)("JSXClosingElement") - }, - children: { - validate: (0, _utils.chain)((0, _utils.assertValueType)("array"), (0, _utils.assertEach)((0, _utils.assertNodeType)("JSXText", "JSXExpressionContainer", "JSXSpreadChild", "JSXElement", "JSXFragment"))) - } - }, { - selfClosing: { - validate: (0, _utils.assertValueType)("boolean"), - optional: true - } - }) -}); -defineType("JSXEmptyExpression", {}); -defineType("JSXExpressionContainer", { - visitor: ["expression"], - aliases: ["Immutable"], - fields: { - expression: { - validate: (0, _utils.assertNodeType)("Expression", "JSXEmptyExpression") - } - } -}); -defineType("JSXSpreadChild", { - visitor: ["expression"], - aliases: ["Immutable"], - fields: { - expression: { - validate: (0, _utils.assertNodeType)("Expression") - } - } -}); -defineType("JSXIdentifier", { - builder: ["name"], - fields: { - name: { - validate: (0, _utils.assertValueType)("string") - } - } -}); -defineType("JSXMemberExpression", { - visitor: ["object", "property"], - fields: { - object: { - validate: (0, _utils.assertNodeType)("JSXMemberExpression", "JSXIdentifier") - }, - property: { - validate: (0, _utils.assertNodeType)("JSXIdentifier") - } - } -}); -defineType("JSXNamespacedName", { - visitor: ["namespace", "name"], - fields: { - namespace: { - validate: (0, _utils.assertNodeType)("JSXIdentifier") - }, - name: { - validate: (0, _utils.assertNodeType)("JSXIdentifier") - } - } -}); -defineType("JSXOpeningElement", { - builder: ["name", "attributes", "selfClosing"], - visitor: ["name", "attributes"], - aliases: ["Immutable"], - fields: { - name: { - validate: (0, _utils.assertNodeType)("JSXIdentifier", "JSXMemberExpression", "JSXNamespacedName") - }, - selfClosing: { - default: false - }, - attributes: { - validate: (0, _utils.chain)((0, _utils.assertValueType)("array"), (0, _utils.assertEach)((0, _utils.assertNodeType)("JSXAttribute", "JSXSpreadAttribute"))) - }, - typeParameters: { - validate: (0, _utils.assertNodeType)("TypeParameterInstantiation", "TSTypeParameterInstantiation"), - optional: true - } - } -}); -defineType("JSXSpreadAttribute", { - visitor: ["argument"], - fields: { - argument: { - validate: (0, _utils.assertNodeType)("Expression") - } - } -}); -defineType("JSXText", { - aliases: ["Immutable"], - builder: ["value"], - fields: { - value: { - validate: (0, _utils.assertValueType)("string") - } - } -}); -defineType("JSXFragment", { - builder: ["openingFragment", "closingFragment", "children"], - visitor: ["openingFragment", "children", "closingFragment"], - aliases: ["Immutable", "Expression"], - fields: { - openingFragment: { - validate: (0, _utils.assertNodeType)("JSXOpeningFragment") - }, - closingFragment: { - validate: (0, _utils.assertNodeType)("JSXClosingFragment") - }, - children: { - validate: (0, _utils.chain)((0, _utils.assertValueType)("array"), (0, _utils.assertEach)((0, _utils.assertNodeType)("JSXText", "JSXExpressionContainer", "JSXSpreadChild", "JSXElement", "JSXFragment"))) - } - } -}); -defineType("JSXOpeningFragment", { - aliases: ["Immutable"] -}); -defineType("JSXClosingFragment", { - aliases: ["Immutable"] -}); - -//# sourceMappingURL=jsx.js.map diff --git a/tools/eslint/node_modules/@babel/types/lib/definitions/misc.js b/tools/eslint/node_modules/@babel/types/lib/definitions/misc.js deleted file mode 100644 index 850c1e404b1f71..00000000000000 --- a/tools/eslint/node_modules/@babel/types/lib/definitions/misc.js +++ /dev/null @@ -1,32 +0,0 @@ -"use strict"; - -var _utils = require("./utils.js"); -var _placeholders = require("./placeholders.js"); -const defineType = (0, _utils.defineAliasedType)("Miscellaneous"); -{ - defineType("Noop", { - visitor: [] - }); -} -defineType("Placeholder", { - visitor: [], - builder: ["expectedNode", "name"], - fields: { - name: { - validate: (0, _utils.assertNodeType)("Identifier") - }, - expectedNode: { - validate: (0, _utils.assertOneOf)(..._placeholders.PLACEHOLDERS) - } - } -}); -defineType("V8IntrinsicIdentifier", { - builder: ["name"], - fields: { - name: { - validate: (0, _utils.assertValueType)("string") - } - } -}); - -//# sourceMappingURL=misc.js.map diff --git a/tools/eslint/node_modules/@babel/types/lib/definitions/placeholders.js b/tools/eslint/node_modules/@babel/types/lib/definitions/placeholders.js deleted file mode 100644 index c4a4f552b9c8c5..00000000000000 --- a/tools/eslint/node_modules/@babel/types/lib/definitions/placeholders.js +++ /dev/null @@ -1,27 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.PLACEHOLDERS_FLIPPED_ALIAS = exports.PLACEHOLDERS_ALIAS = exports.PLACEHOLDERS = void 0; -var _utils = require("./utils.js"); -const PLACEHOLDERS = exports.PLACEHOLDERS = ["Identifier", "StringLiteral", "Expression", "Statement", "Declaration", "BlockStatement", "ClassBody", "Pattern"]; -const PLACEHOLDERS_ALIAS = exports.PLACEHOLDERS_ALIAS = { - Declaration: ["Statement"], - Pattern: ["PatternLike", "LVal"] -}; -for (const type of PLACEHOLDERS) { - const alias = _utils.ALIAS_KEYS[type]; - if (alias != null && alias.length) PLACEHOLDERS_ALIAS[type] = alias; -} -const PLACEHOLDERS_FLIPPED_ALIAS = exports.PLACEHOLDERS_FLIPPED_ALIAS = {}; -Object.keys(PLACEHOLDERS_ALIAS).forEach(type => { - PLACEHOLDERS_ALIAS[type].forEach(alias => { - if (!hasOwnProperty.call(PLACEHOLDERS_FLIPPED_ALIAS, alias)) { - PLACEHOLDERS_FLIPPED_ALIAS[alias] = []; - } - PLACEHOLDERS_FLIPPED_ALIAS[alias].push(type); - }); -}); - -//# sourceMappingURL=placeholders.js.map diff --git a/tools/eslint/node_modules/@babel/types/lib/definitions/typescript.js b/tools/eslint/node_modules/@babel/types/lib/definitions/typescript.js deleted file mode 100644 index 901a9c4cbd9dd7..00000000000000 --- a/tools/eslint/node_modules/@babel/types/lib/definitions/typescript.js +++ /dev/null @@ -1,493 +0,0 @@ -"use strict"; - -var _utils = require("./utils.js"); -var _core = require("./core.js"); -var _is = require("../validators/is.js"); -const defineType = (0, _utils.defineAliasedType)("TypeScript"); -const bool = (0, _utils.assertValueType)("boolean"); -const tSFunctionTypeAnnotationCommon = () => ({ - returnType: { - validate: (0, _utils.assertNodeType)("TSTypeAnnotation", "Noop"), - optional: true - }, - typeParameters: { - validate: (0, _utils.assertNodeType)("TSTypeParameterDeclaration", "Noop"), - optional: true - } -}); -defineType("TSParameterProperty", { - aliases: ["LVal"], - visitor: ["parameter"], - fields: { - accessibility: { - validate: (0, _utils.assertOneOf)("public", "private", "protected"), - optional: true - }, - readonly: { - validate: (0, _utils.assertValueType)("boolean"), - optional: true - }, - parameter: { - validate: (0, _utils.assertNodeType)("Identifier", "AssignmentPattern") - }, - override: { - validate: (0, _utils.assertValueType)("boolean"), - optional: true - }, - decorators: { - validate: (0, _utils.chain)((0, _utils.assertValueType)("array"), (0, _utils.assertEach)((0, _utils.assertNodeType)("Decorator"))), - optional: true - } - } -}); -defineType("TSDeclareFunction", { - aliases: ["Statement", "Declaration"], - visitor: ["id", "typeParameters", "params", "returnType"], - fields: Object.assign({}, (0, _core.functionDeclarationCommon)(), tSFunctionTypeAnnotationCommon()) -}); -defineType("TSDeclareMethod", { - visitor: ["decorators", "key", "typeParameters", "params", "returnType"], - fields: Object.assign({}, (0, _core.classMethodOrDeclareMethodCommon)(), tSFunctionTypeAnnotationCommon()) -}); -defineType("TSQualifiedName", { - aliases: ["TSEntityName"], - visitor: ["left", "right"], - fields: { - left: (0, _utils.validateType)("TSEntityName"), - right: (0, _utils.validateType)("Identifier") - } -}); -const signatureDeclarationCommon = () => ({ - typeParameters: (0, _utils.validateOptionalType)("TSTypeParameterDeclaration"), - ["parameters"]: (0, _utils.validateArrayOfType)(["ArrayPattern", "Identifier", "ObjectPattern", "RestElement"]), - ["typeAnnotation"]: (0, _utils.validateOptionalType)("TSTypeAnnotation") -}); -const callConstructSignatureDeclaration = { - aliases: ["TSTypeElement"], - visitor: ["typeParameters", "parameters", "typeAnnotation"], - fields: signatureDeclarationCommon() -}; -defineType("TSCallSignatureDeclaration", callConstructSignatureDeclaration); -defineType("TSConstructSignatureDeclaration", callConstructSignatureDeclaration); -const namedTypeElementCommon = () => ({ - key: (0, _utils.validateType)("Expression"), - computed: { - default: false - }, - optional: (0, _utils.validateOptional)(bool) -}); -defineType("TSPropertySignature", { - aliases: ["TSTypeElement"], - visitor: ["key", "typeAnnotation"], - fields: Object.assign({}, namedTypeElementCommon(), { - readonly: (0, _utils.validateOptional)(bool), - typeAnnotation: (0, _utils.validateOptionalType)("TSTypeAnnotation"), - kind: { - validate: (0, _utils.assertOneOf)("get", "set") - } - }) -}); -defineType("TSMethodSignature", { - aliases: ["TSTypeElement"], - visitor: ["key", "typeParameters", "parameters", "typeAnnotation"], - fields: Object.assign({}, signatureDeclarationCommon(), namedTypeElementCommon(), { - kind: { - validate: (0, _utils.assertOneOf)("method", "get", "set") - } - }) -}); -defineType("TSIndexSignature", { - aliases: ["TSTypeElement"], - visitor: ["parameters", "typeAnnotation"], - fields: { - readonly: (0, _utils.validateOptional)(bool), - static: (0, _utils.validateOptional)(bool), - parameters: (0, _utils.validateArrayOfType)("Identifier"), - typeAnnotation: (0, _utils.validateOptionalType)("TSTypeAnnotation") - } -}); -const tsKeywordTypes = ["TSAnyKeyword", "TSBooleanKeyword", "TSBigIntKeyword", "TSIntrinsicKeyword", "TSNeverKeyword", "TSNullKeyword", "TSNumberKeyword", "TSObjectKeyword", "TSStringKeyword", "TSSymbolKeyword", "TSUndefinedKeyword", "TSUnknownKeyword", "TSVoidKeyword"]; -for (const type of tsKeywordTypes) { - defineType(type, { - aliases: ["TSType", "TSBaseType"], - visitor: [], - fields: {} - }); -} -defineType("TSThisType", { - aliases: ["TSType", "TSBaseType"], - visitor: [], - fields: {} -}); -const fnOrCtrBase = { - aliases: ["TSType"], - visitor: ["typeParameters", "parameters", "typeAnnotation"] -}; -defineType("TSFunctionType", Object.assign({}, fnOrCtrBase, { - fields: signatureDeclarationCommon() -})); -defineType("TSConstructorType", Object.assign({}, fnOrCtrBase, { - fields: Object.assign({}, signatureDeclarationCommon(), { - abstract: (0, _utils.validateOptional)(bool) - }) -})); -defineType("TSTypeReference", { - aliases: ["TSType"], - visitor: ["typeName", "typeParameters"], - fields: { - typeName: (0, _utils.validateType)("TSEntityName"), - typeParameters: (0, _utils.validateOptionalType)("TSTypeParameterInstantiation") - } -}); -defineType("TSTypePredicate", { - aliases: ["TSType"], - visitor: ["parameterName", "typeAnnotation"], - builder: ["parameterName", "typeAnnotation", "asserts"], - fields: { - parameterName: (0, _utils.validateType)(["Identifier", "TSThisType"]), - typeAnnotation: (0, _utils.validateOptionalType)("TSTypeAnnotation"), - asserts: (0, _utils.validateOptional)(bool) - } -}); -defineType("TSTypeQuery", { - aliases: ["TSType"], - visitor: ["exprName", "typeParameters"], - fields: { - exprName: (0, _utils.validateType)(["TSEntityName", "TSImportType"]), - typeParameters: (0, _utils.validateOptionalType)("TSTypeParameterInstantiation") - } -}); -defineType("TSTypeLiteral", { - aliases: ["TSType"], - visitor: ["members"], - fields: { - members: (0, _utils.validateArrayOfType)("TSTypeElement") - } -}); -defineType("TSArrayType", { - aliases: ["TSType"], - visitor: ["elementType"], - fields: { - elementType: (0, _utils.validateType)("TSType") - } -}); -defineType("TSTupleType", { - aliases: ["TSType"], - visitor: ["elementTypes"], - fields: { - elementTypes: (0, _utils.validateArrayOfType)(["TSType", "TSNamedTupleMember"]) - } -}); -defineType("TSOptionalType", { - aliases: ["TSType"], - visitor: ["typeAnnotation"], - fields: { - typeAnnotation: (0, _utils.validateType)("TSType") - } -}); -defineType("TSRestType", { - aliases: ["TSType"], - visitor: ["typeAnnotation"], - fields: { - typeAnnotation: (0, _utils.validateType)("TSType") - } -}); -defineType("TSNamedTupleMember", { - visitor: ["label", "elementType"], - builder: ["label", "elementType", "optional"], - fields: { - label: (0, _utils.validateType)("Identifier"), - optional: { - validate: bool, - default: false - }, - elementType: (0, _utils.validateType)("TSType") - } -}); -const unionOrIntersection = { - aliases: ["TSType"], - visitor: ["types"], - fields: { - types: (0, _utils.validateArrayOfType)("TSType") - } -}; -defineType("TSUnionType", unionOrIntersection); -defineType("TSIntersectionType", unionOrIntersection); -defineType("TSConditionalType", { - aliases: ["TSType"], - visitor: ["checkType", "extendsType", "trueType", "falseType"], - fields: { - checkType: (0, _utils.validateType)("TSType"), - extendsType: (0, _utils.validateType)("TSType"), - trueType: (0, _utils.validateType)("TSType"), - falseType: (0, _utils.validateType)("TSType") - } -}); -defineType("TSInferType", { - aliases: ["TSType"], - visitor: ["typeParameter"], - fields: { - typeParameter: (0, _utils.validateType)("TSTypeParameter") - } -}); -defineType("TSParenthesizedType", { - aliases: ["TSType"], - visitor: ["typeAnnotation"], - fields: { - typeAnnotation: (0, _utils.validateType)("TSType") - } -}); -defineType("TSTypeOperator", { - aliases: ["TSType"], - visitor: ["typeAnnotation"], - fields: { - operator: (0, _utils.validate)((0, _utils.assertValueType)("string")), - typeAnnotation: (0, _utils.validateType)("TSType") - } -}); -defineType("TSIndexedAccessType", { - aliases: ["TSType"], - visitor: ["objectType", "indexType"], - fields: { - objectType: (0, _utils.validateType)("TSType"), - indexType: (0, _utils.validateType)("TSType") - } -}); -defineType("TSMappedType", { - aliases: ["TSType"], - visitor: ["typeParameter", "typeAnnotation", "nameType"], - fields: { - readonly: (0, _utils.validateOptional)((0, _utils.assertOneOf)(true, false, "+", "-")), - typeParameter: (0, _utils.validateType)("TSTypeParameter"), - optional: (0, _utils.validateOptional)((0, _utils.assertOneOf)(true, false, "+", "-")), - typeAnnotation: (0, _utils.validateOptionalType)("TSType"), - nameType: (0, _utils.validateOptionalType)("TSType") - } -}); -defineType("TSLiteralType", { - aliases: ["TSType", "TSBaseType"], - visitor: ["literal"], - fields: { - literal: { - validate: function () { - const unaryExpression = (0, _utils.assertNodeType)("NumericLiteral", "BigIntLiteral"); - const unaryOperator = (0, _utils.assertOneOf)("-"); - const literal = (0, _utils.assertNodeType)("NumericLiteral", "StringLiteral", "BooleanLiteral", "BigIntLiteral", "TemplateLiteral"); - function validator(parent, key, node) { - if ((0, _is.default)("UnaryExpression", node)) { - unaryOperator(node, "operator", node.operator); - unaryExpression(node, "argument", node.argument); - } else { - literal(parent, key, node); - } - } - validator.oneOfNodeTypes = ["NumericLiteral", "StringLiteral", "BooleanLiteral", "BigIntLiteral", "TemplateLiteral", "UnaryExpression"]; - return validator; - }() - } - } -}); -defineType("TSExpressionWithTypeArguments", { - aliases: ["TSType"], - visitor: ["expression", "typeParameters"], - fields: { - expression: (0, _utils.validateType)("TSEntityName"), - typeParameters: (0, _utils.validateOptionalType)("TSTypeParameterInstantiation") - } -}); -defineType("TSInterfaceDeclaration", { - aliases: ["Statement", "Declaration"], - visitor: ["id", "typeParameters", "extends", "body"], - fields: { - declare: (0, _utils.validateOptional)(bool), - id: (0, _utils.validateType)("Identifier"), - typeParameters: (0, _utils.validateOptionalType)("TSTypeParameterDeclaration"), - extends: (0, _utils.validateOptional)((0, _utils.arrayOfType)("TSExpressionWithTypeArguments")), - body: (0, _utils.validateType)("TSInterfaceBody") - } -}); -defineType("TSInterfaceBody", { - visitor: ["body"], - fields: { - body: (0, _utils.validateArrayOfType)("TSTypeElement") - } -}); -defineType("TSTypeAliasDeclaration", { - aliases: ["Statement", "Declaration"], - visitor: ["id", "typeParameters", "typeAnnotation"], - fields: { - declare: (0, _utils.validateOptional)(bool), - id: (0, _utils.validateType)("Identifier"), - typeParameters: (0, _utils.validateOptionalType)("TSTypeParameterDeclaration"), - typeAnnotation: (0, _utils.validateType)("TSType") - } -}); -defineType("TSInstantiationExpression", { - aliases: ["Expression"], - visitor: ["expression", "typeParameters"], - fields: { - expression: (0, _utils.validateType)("Expression"), - typeParameters: (0, _utils.validateOptionalType)("TSTypeParameterInstantiation") - } -}); -const TSTypeExpression = { - aliases: ["Expression", "LVal", "PatternLike"], - visitor: ["expression", "typeAnnotation"], - fields: { - expression: (0, _utils.validateType)("Expression"), - typeAnnotation: (0, _utils.validateType)("TSType") - } -}; -defineType("TSAsExpression", TSTypeExpression); -defineType("TSSatisfiesExpression", TSTypeExpression); -defineType("TSTypeAssertion", { - aliases: ["Expression", "LVal", "PatternLike"], - visitor: ["typeAnnotation", "expression"], - fields: { - typeAnnotation: (0, _utils.validateType)("TSType"), - expression: (0, _utils.validateType)("Expression") - } -}); -defineType("TSEnumDeclaration", { - aliases: ["Statement", "Declaration"], - visitor: ["id", "members"], - fields: { - declare: (0, _utils.validateOptional)(bool), - const: (0, _utils.validateOptional)(bool), - id: (0, _utils.validateType)("Identifier"), - members: (0, _utils.validateArrayOfType)("TSEnumMember"), - initializer: (0, _utils.validateOptionalType)("Expression") - } -}); -defineType("TSEnumMember", { - visitor: ["id", "initializer"], - fields: { - id: (0, _utils.validateType)(["Identifier", "StringLiteral"]), - initializer: (0, _utils.validateOptionalType)("Expression") - } -}); -defineType("TSModuleDeclaration", { - aliases: ["Statement", "Declaration"], - visitor: ["id", "body"], - fields: { - declare: (0, _utils.validateOptional)(bool), - global: (0, _utils.validateOptional)(bool), - id: (0, _utils.validateType)(["Identifier", "StringLiteral"]), - body: (0, _utils.validateType)(["TSModuleBlock", "TSModuleDeclaration"]) - } -}); -defineType("TSModuleBlock", { - aliases: ["Scopable", "Block", "BlockParent", "FunctionParent"], - visitor: ["body"], - fields: { - body: (0, _utils.validateArrayOfType)("Statement") - } -}); -defineType("TSImportType", { - aliases: ["TSType"], - visitor: ["argument", "qualifier", "typeParameters"], - fields: { - argument: (0, _utils.validateType)("StringLiteral"), - qualifier: (0, _utils.validateOptionalType)("TSEntityName"), - typeParameters: (0, _utils.validateOptionalType)("TSTypeParameterInstantiation"), - options: { - validate: (0, _utils.assertNodeType)("Expression"), - optional: true - } - } -}); -defineType("TSImportEqualsDeclaration", { - aliases: ["Statement"], - visitor: ["id", "moduleReference"], - fields: { - isExport: (0, _utils.validate)(bool), - id: (0, _utils.validateType)("Identifier"), - moduleReference: (0, _utils.validateType)(["TSEntityName", "TSExternalModuleReference"]), - importKind: { - validate: (0, _utils.assertOneOf)("type", "value"), - optional: true - } - } -}); -defineType("TSExternalModuleReference", { - visitor: ["expression"], - fields: { - expression: (0, _utils.validateType)("StringLiteral") - } -}); -defineType("TSNonNullExpression", { - aliases: ["Expression", "LVal", "PatternLike"], - visitor: ["expression"], - fields: { - expression: (0, _utils.validateType)("Expression") - } -}); -defineType("TSExportAssignment", { - aliases: ["Statement"], - visitor: ["expression"], - fields: { - expression: (0, _utils.validateType)("Expression") - } -}); -defineType("TSNamespaceExportDeclaration", { - aliases: ["Statement"], - visitor: ["id"], - fields: { - id: (0, _utils.validateType)("Identifier") - } -}); -defineType("TSTypeAnnotation", { - visitor: ["typeAnnotation"], - fields: { - typeAnnotation: { - validate: (0, _utils.assertNodeType)("TSType") - } - } -}); -defineType("TSTypeParameterInstantiation", { - visitor: ["params"], - fields: { - params: { - validate: (0, _utils.chain)((0, _utils.assertValueType)("array"), (0, _utils.assertEach)((0, _utils.assertNodeType)("TSType"))) - } - } -}); -defineType("TSTypeParameterDeclaration", { - visitor: ["params"], - fields: { - params: { - validate: (0, _utils.chain)((0, _utils.assertValueType)("array"), (0, _utils.assertEach)((0, _utils.assertNodeType)("TSTypeParameter"))) - } - } -}); -defineType("TSTypeParameter", { - builder: ["constraint", "default", "name"], - visitor: ["constraint", "default"], - fields: { - name: { - validate: (0, _utils.assertValueType)("string") - }, - in: { - validate: (0, _utils.assertValueType)("boolean"), - optional: true - }, - out: { - validate: (0, _utils.assertValueType)("boolean"), - optional: true - }, - const: { - validate: (0, _utils.assertValueType)("boolean"), - optional: true - }, - constraint: { - validate: (0, _utils.assertNodeType)("TSType"), - optional: true - }, - default: { - validate: (0, _utils.assertNodeType)("TSType"), - optional: true - } - } -}); - -//# sourceMappingURL=typescript.js.map diff --git a/tools/eslint/node_modules/@babel/types/lib/definitions/utils.js b/tools/eslint/node_modules/@babel/types/lib/definitions/utils.js deleted file mode 100644 index 5fa1ef75617add..00000000000000 --- a/tools/eslint/node_modules/@babel/types/lib/definitions/utils.js +++ /dev/null @@ -1,273 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.VISITOR_KEYS = exports.NODE_PARENT_VALIDATIONS = exports.NODE_FIELDS = exports.FLIPPED_ALIAS_KEYS = exports.DEPRECATED_KEYS = exports.BUILDER_KEYS = exports.ALIAS_KEYS = void 0; -exports.arrayOf = arrayOf; -exports.arrayOfType = arrayOfType; -exports.assertEach = assertEach; -exports.assertNodeOrValueType = assertNodeOrValueType; -exports.assertNodeType = assertNodeType; -exports.assertOneOf = assertOneOf; -exports.assertOptionalChainStart = assertOptionalChainStart; -exports.assertShape = assertShape; -exports.assertValueType = assertValueType; -exports.chain = chain; -exports.default = defineType; -exports.defineAliasedType = defineAliasedType; -exports.typeIs = typeIs; -exports.validate = validate; -exports.validateArrayOfType = validateArrayOfType; -exports.validateOptional = validateOptional; -exports.validateOptionalType = validateOptionalType; -exports.validateType = validateType; -var _is = require("../validators/is.js"); -var _validate = require("../validators/validate.js"); -const VISITOR_KEYS = exports.VISITOR_KEYS = {}; -const ALIAS_KEYS = exports.ALIAS_KEYS = {}; -const FLIPPED_ALIAS_KEYS = exports.FLIPPED_ALIAS_KEYS = {}; -const NODE_FIELDS = exports.NODE_FIELDS = {}; -const BUILDER_KEYS = exports.BUILDER_KEYS = {}; -const DEPRECATED_KEYS = exports.DEPRECATED_KEYS = {}; -const NODE_PARENT_VALIDATIONS = exports.NODE_PARENT_VALIDATIONS = {}; -function getType(val) { - if (Array.isArray(val)) { - return "array"; - } else if (val === null) { - return "null"; - } else { - return typeof val; - } -} -function validate(validate) { - return { - validate - }; -} -function typeIs(typeName) { - return typeof typeName === "string" ? assertNodeType(typeName) : assertNodeType(...typeName); -} -function validateType(typeName) { - return validate(typeIs(typeName)); -} -function validateOptional(validate) { - return { - validate, - optional: true - }; -} -function validateOptionalType(typeName) { - return { - validate: typeIs(typeName), - optional: true - }; -} -function arrayOf(elementType) { - return chain(assertValueType("array"), assertEach(elementType)); -} -function arrayOfType(typeName) { - return arrayOf(typeIs(typeName)); -} -function validateArrayOfType(typeName) { - return validate(arrayOfType(typeName)); -} -function assertEach(callback) { - function validator(node, key, val) { - if (!Array.isArray(val)) return; - for (let i = 0; i < val.length; i++) { - const subkey = `${key}[${i}]`; - const v = val[i]; - callback(node, subkey, v); - if (process.env.BABEL_TYPES_8_BREAKING) (0, _validate.validateChild)(node, subkey, v); - } - } - validator.each = callback; - return validator; -} -function assertOneOf(...values) { - function validate(node, key, val) { - if (!values.includes(val)) { - throw new TypeError(`Property ${key} expected value to be one of ${JSON.stringify(values)} but got ${JSON.stringify(val)}`); - } - } - validate.oneOf = values; - return validate; -} -function assertNodeType(...types) { - function validate(node, key, val) { - for (const type of types) { - if ((0, _is.default)(type, val)) { - (0, _validate.validateChild)(node, key, val); - return; - } - } - throw new TypeError(`Property ${key} of ${node.type} expected node to be of a type ${JSON.stringify(types)} but instead got ${JSON.stringify(val == null ? void 0 : val.type)}`); - } - validate.oneOfNodeTypes = types; - return validate; -} -function assertNodeOrValueType(...types) { - function validate(node, key, val) { - for (const type of types) { - if (getType(val) === type || (0, _is.default)(type, val)) { - (0, _validate.validateChild)(node, key, val); - return; - } - } - throw new TypeError(`Property ${key} of ${node.type} expected node to be of a type ${JSON.stringify(types)} but instead got ${JSON.stringify(val == null ? void 0 : val.type)}`); - } - validate.oneOfNodeOrValueTypes = types; - return validate; -} -function assertValueType(type) { - function validate(node, key, val) { - const valid = getType(val) === type; - if (!valid) { - throw new TypeError(`Property ${key} expected type of ${type} but got ${getType(val)}`); - } - } - validate.type = type; - return validate; -} -function assertShape(shape) { - function validate(node, key, val) { - const errors = []; - for (const property of Object.keys(shape)) { - try { - (0, _validate.validateField)(node, property, val[property], shape[property]); - } catch (error) { - if (error instanceof TypeError) { - errors.push(error.message); - continue; - } - throw error; - } - } - if (errors.length) { - throw new TypeError(`Property ${key} of ${node.type} expected to have the following:\n${errors.join("\n")}`); - } - } - validate.shapeOf = shape; - return validate; -} -function assertOptionalChainStart() { - function validate(node) { - var _current; - let current = node; - while (node) { - const { - type - } = current; - if (type === "OptionalCallExpression") { - if (current.optional) return; - current = current.callee; - continue; - } - if (type === "OptionalMemberExpression") { - if (current.optional) return; - current = current.object; - continue; - } - break; - } - throw new TypeError(`Non-optional ${node.type} must chain from an optional OptionalMemberExpression or OptionalCallExpression. Found chain from ${(_current = current) == null ? void 0 : _current.type}`); - } - return validate; -} -function chain(...fns) { - function validate(...args) { - for (const fn of fns) { - fn(...args); - } - } - validate.chainOf = fns; - if (fns.length >= 2 && "type" in fns[0] && fns[0].type === "array" && !("each" in fns[1])) { - throw new Error(`An assertValueType("array") validator can only be followed by an assertEach(...) validator.`); - } - return validate; -} -const validTypeOpts = ["aliases", "builder", "deprecatedAlias", "fields", "inherits", "visitor", "validate"]; -const validFieldKeys = ["default", "optional", "deprecated", "validate"]; -const store = {}; -function defineAliasedType(...aliases) { - return (type, opts = {}) => { - let defined = opts.aliases; - if (!defined) { - var _store$opts$inherits$, _defined; - if (opts.inherits) defined = (_store$opts$inherits$ = store[opts.inherits].aliases) == null ? void 0 : _store$opts$inherits$.slice(); - (_defined = defined) != null ? _defined : defined = []; - opts.aliases = defined; - } - const additional = aliases.filter(a => !defined.includes(a)); - defined.unshift(...additional); - defineType(type, opts); - }; -} -function defineType(type, opts = {}) { - const inherits = opts.inherits && store[opts.inherits] || {}; - let fields = opts.fields; - if (!fields) { - fields = {}; - if (inherits.fields) { - const keys = Object.getOwnPropertyNames(inherits.fields); - for (const key of keys) { - const field = inherits.fields[key]; - const def = field.default; - if (Array.isArray(def) ? def.length > 0 : def && typeof def === "object") { - throw new Error("field defaults can only be primitives or empty arrays currently"); - } - fields[key] = { - default: Array.isArray(def) ? [] : def, - optional: field.optional, - deprecated: field.deprecated, - validate: field.validate - }; - } - } - } - const visitor = opts.visitor || inherits.visitor || []; - const aliases = opts.aliases || inherits.aliases || []; - const builder = opts.builder || inherits.builder || opts.visitor || []; - for (const k of Object.keys(opts)) { - if (!validTypeOpts.includes(k)) { - throw new Error(`Unknown type option "${k}" on ${type}`); - } - } - if (opts.deprecatedAlias) { - DEPRECATED_KEYS[opts.deprecatedAlias] = type; - } - for (const key of visitor.concat(builder)) { - fields[key] = fields[key] || {}; - } - for (const key of Object.keys(fields)) { - const field = fields[key]; - if (field.default !== undefined && !builder.includes(key)) { - field.optional = true; - } - if (field.default === undefined) { - field.default = null; - } else if (!field.validate && field.default != null) { - field.validate = assertValueType(getType(field.default)); - } - for (const k of Object.keys(field)) { - if (!validFieldKeys.includes(k)) { - throw new Error(`Unknown field key "${k}" on ${type}.${key}`); - } - } - } - VISITOR_KEYS[type] = opts.visitor = visitor; - BUILDER_KEYS[type] = opts.builder = builder; - NODE_FIELDS[type] = opts.fields = fields; - ALIAS_KEYS[type] = opts.aliases = aliases; - aliases.forEach(alias => { - FLIPPED_ALIAS_KEYS[alias] = FLIPPED_ALIAS_KEYS[alias] || []; - FLIPPED_ALIAS_KEYS[alias].push(type); - }); - if (opts.validate) { - NODE_PARENT_VALIDATIONS[type] = opts.validate; - } - store[type] = opts; -} - -//# sourceMappingURL=utils.js.map diff --git a/tools/eslint/node_modules/@babel/types/lib/index.js b/tools/eslint/node_modules/@babel/types/lib/index.js deleted file mode 100644 index 84b756f0526f2e..00000000000000 --- a/tools/eslint/node_modules/@babel/types/lib/index.js +++ /dev/null @@ -1,576 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -var _exportNames = { - react: true, - assertNode: true, - createTypeAnnotationBasedOnTypeof: true, - createUnionTypeAnnotation: true, - createFlowUnionType: true, - createTSUnionType: true, - cloneNode: true, - clone: true, - cloneDeep: true, - cloneDeepWithoutLoc: true, - cloneWithoutLoc: true, - addComment: true, - addComments: true, - inheritInnerComments: true, - inheritLeadingComments: true, - inheritsComments: true, - inheritTrailingComments: true, - removeComments: true, - ensureBlock: true, - toBindingIdentifierName: true, - toBlock: true, - toComputedKey: true, - toExpression: true, - toIdentifier: true, - toKeyAlias: true, - toStatement: true, - valueToNode: true, - appendToMemberExpression: true, - inherits: true, - prependToMemberExpression: true, - removeProperties: true, - removePropertiesDeep: true, - removeTypeDuplicates: true, - getBindingIdentifiers: true, - getOuterBindingIdentifiers: true, - traverse: true, - traverseFast: true, - shallowEqual: true, - is: true, - isBinding: true, - isBlockScoped: true, - isImmutable: true, - isLet: true, - isNode: true, - isNodesEquivalent: true, - isPlaceholderType: true, - isReferenced: true, - isScope: true, - isSpecifierDefault: true, - isType: true, - isValidES3Identifier: true, - isValidIdentifier: true, - isVar: true, - matchesPattern: true, - validate: true, - buildMatchMemberExpression: true, - __internal__deprecationWarning: true -}; -Object.defineProperty(exports, "__internal__deprecationWarning", { - enumerable: true, - get: function () { - return _deprecationWarning.default; - } -}); -Object.defineProperty(exports, "addComment", { - enumerable: true, - get: function () { - return _addComment.default; - } -}); -Object.defineProperty(exports, "addComments", { - enumerable: true, - get: function () { - return _addComments.default; - } -}); -Object.defineProperty(exports, "appendToMemberExpression", { - enumerable: true, - get: function () { - return _appendToMemberExpression.default; - } -}); -Object.defineProperty(exports, "assertNode", { - enumerable: true, - get: function () { - return _assertNode.default; - } -}); -Object.defineProperty(exports, "buildMatchMemberExpression", { - enumerable: true, - get: function () { - return _buildMatchMemberExpression.default; - } -}); -Object.defineProperty(exports, "clone", { - enumerable: true, - get: function () { - return _clone.default; - } -}); -Object.defineProperty(exports, "cloneDeep", { - enumerable: true, - get: function () { - return _cloneDeep.default; - } -}); -Object.defineProperty(exports, "cloneDeepWithoutLoc", { - enumerable: true, - get: function () { - return _cloneDeepWithoutLoc.default; - } -}); -Object.defineProperty(exports, "cloneNode", { - enumerable: true, - get: function () { - return _cloneNode.default; - } -}); -Object.defineProperty(exports, "cloneWithoutLoc", { - enumerable: true, - get: function () { - return _cloneWithoutLoc.default; - } -}); -Object.defineProperty(exports, "createFlowUnionType", { - enumerable: true, - get: function () { - return _createFlowUnionType.default; - } -}); -Object.defineProperty(exports, "createTSUnionType", { - enumerable: true, - get: function () { - return _createTSUnionType.default; - } -}); -Object.defineProperty(exports, "createTypeAnnotationBasedOnTypeof", { - enumerable: true, - get: function () { - return _createTypeAnnotationBasedOnTypeof.default; - } -}); -Object.defineProperty(exports, "createUnionTypeAnnotation", { - enumerable: true, - get: function () { - return _createFlowUnionType.default; - } -}); -Object.defineProperty(exports, "ensureBlock", { - enumerable: true, - get: function () { - return _ensureBlock.default; - } -}); -Object.defineProperty(exports, "getBindingIdentifiers", { - enumerable: true, - get: function () { - return _getBindingIdentifiers.default; - } -}); -Object.defineProperty(exports, "getOuterBindingIdentifiers", { - enumerable: true, - get: function () { - return _getOuterBindingIdentifiers.default; - } -}); -Object.defineProperty(exports, "inheritInnerComments", { - enumerable: true, - get: function () { - return _inheritInnerComments.default; - } -}); -Object.defineProperty(exports, "inheritLeadingComments", { - enumerable: true, - get: function () { - return _inheritLeadingComments.default; - } -}); -Object.defineProperty(exports, "inheritTrailingComments", { - enumerable: true, - get: function () { - return _inheritTrailingComments.default; - } -}); -Object.defineProperty(exports, "inherits", { - enumerable: true, - get: function () { - return _inherits.default; - } -}); -Object.defineProperty(exports, "inheritsComments", { - enumerable: true, - get: function () { - return _inheritsComments.default; - } -}); -Object.defineProperty(exports, "is", { - enumerable: true, - get: function () { - return _is.default; - } -}); -Object.defineProperty(exports, "isBinding", { - enumerable: true, - get: function () { - return _isBinding.default; - } -}); -Object.defineProperty(exports, "isBlockScoped", { - enumerable: true, - get: function () { - return _isBlockScoped.default; - } -}); -Object.defineProperty(exports, "isImmutable", { - enumerable: true, - get: function () { - return _isImmutable.default; - } -}); -Object.defineProperty(exports, "isLet", { - enumerable: true, - get: function () { - return _isLet.default; - } -}); -Object.defineProperty(exports, "isNode", { - enumerable: true, - get: function () { - return _isNode.default; - } -}); -Object.defineProperty(exports, "isNodesEquivalent", { - enumerable: true, - get: function () { - return _isNodesEquivalent.default; - } -}); -Object.defineProperty(exports, "isPlaceholderType", { - enumerable: true, - get: function () { - return _isPlaceholderType.default; - } -}); -Object.defineProperty(exports, "isReferenced", { - enumerable: true, - get: function () { - return _isReferenced.default; - } -}); -Object.defineProperty(exports, "isScope", { - enumerable: true, - get: function () { - return _isScope.default; - } -}); -Object.defineProperty(exports, "isSpecifierDefault", { - enumerable: true, - get: function () { - return _isSpecifierDefault.default; - } -}); -Object.defineProperty(exports, "isType", { - enumerable: true, - get: function () { - return _isType.default; - } -}); -Object.defineProperty(exports, "isValidES3Identifier", { - enumerable: true, - get: function () { - return _isValidES3Identifier.default; - } -}); -Object.defineProperty(exports, "isValidIdentifier", { - enumerable: true, - get: function () { - return _isValidIdentifier.default; - } -}); -Object.defineProperty(exports, "isVar", { - enumerable: true, - get: function () { - return _isVar.default; - } -}); -Object.defineProperty(exports, "matchesPattern", { - enumerable: true, - get: function () { - return _matchesPattern.default; - } -}); -Object.defineProperty(exports, "prependToMemberExpression", { - enumerable: true, - get: function () { - return _prependToMemberExpression.default; - } -}); -exports.react = void 0; -Object.defineProperty(exports, "removeComments", { - enumerable: true, - get: function () { - return _removeComments.default; - } -}); -Object.defineProperty(exports, "removeProperties", { - enumerable: true, - get: function () { - return _removeProperties.default; - } -}); -Object.defineProperty(exports, "removePropertiesDeep", { - enumerable: true, - get: function () { - return _removePropertiesDeep.default; - } -}); -Object.defineProperty(exports, "removeTypeDuplicates", { - enumerable: true, - get: function () { - return _removeTypeDuplicates.default; - } -}); -Object.defineProperty(exports, "shallowEqual", { - enumerable: true, - get: function () { - return _shallowEqual.default; - } -}); -Object.defineProperty(exports, "toBindingIdentifierName", { - enumerable: true, - get: function () { - return _toBindingIdentifierName.default; - } -}); -Object.defineProperty(exports, "toBlock", { - enumerable: true, - get: function () { - return _toBlock.default; - } -}); -Object.defineProperty(exports, "toComputedKey", { - enumerable: true, - get: function () { - return _toComputedKey.default; - } -}); -Object.defineProperty(exports, "toExpression", { - enumerable: true, - get: function () { - return _toExpression.default; - } -}); -Object.defineProperty(exports, "toIdentifier", { - enumerable: true, - get: function () { - return _toIdentifier.default; - } -}); -Object.defineProperty(exports, "toKeyAlias", { - enumerable: true, - get: function () { - return _toKeyAlias.default; - } -}); -Object.defineProperty(exports, "toStatement", { - enumerable: true, - get: function () { - return _toStatement.default; - } -}); -Object.defineProperty(exports, "traverse", { - enumerable: true, - get: function () { - return _traverse.default; - } -}); -Object.defineProperty(exports, "traverseFast", { - enumerable: true, - get: function () { - return _traverseFast.default; - } -}); -Object.defineProperty(exports, "validate", { - enumerable: true, - get: function () { - return _validate.default; - } -}); -Object.defineProperty(exports, "valueToNode", { - enumerable: true, - get: function () { - return _valueToNode.default; - } -}); -var _isReactComponent = require("./validators/react/isReactComponent.js"); -var _isCompatTag = require("./validators/react/isCompatTag.js"); -var _buildChildren = require("./builders/react/buildChildren.js"); -var _assertNode = require("./asserts/assertNode.js"); -var _index = require("./asserts/generated/index.js"); -Object.keys(_index).forEach(function (key) { - if (key === "default" || key === "__esModule") return; - if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return; - if (key in exports && exports[key] === _index[key]) return; - Object.defineProperty(exports, key, { - enumerable: true, - get: function () { - return _index[key]; - } - }); -}); -var _createTypeAnnotationBasedOnTypeof = require("./builders/flow/createTypeAnnotationBasedOnTypeof.js"); -var _createFlowUnionType = require("./builders/flow/createFlowUnionType.js"); -var _createTSUnionType = require("./builders/typescript/createTSUnionType.js"); -var _index2 = require("./builders/generated/index.js"); -Object.keys(_index2).forEach(function (key) { - if (key === "default" || key === "__esModule") return; - if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return; - if (key in exports && exports[key] === _index2[key]) return; - Object.defineProperty(exports, key, { - enumerable: true, - get: function () { - return _index2[key]; - } - }); -}); -var _uppercase = require("./builders/generated/uppercase.js"); -Object.keys(_uppercase).forEach(function (key) { - if (key === "default" || key === "__esModule") return; - if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return; - if (key in exports && exports[key] === _uppercase[key]) return; - Object.defineProperty(exports, key, { - enumerable: true, - get: function () { - return _uppercase[key]; - } - }); -}); -var _productions = require("./builders/productions.js"); -Object.keys(_productions).forEach(function (key) { - if (key === "default" || key === "__esModule") return; - if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return; - if (key in exports && exports[key] === _productions[key]) return; - Object.defineProperty(exports, key, { - enumerable: true, - get: function () { - return _productions[key]; - } - }); -}); -var _cloneNode = require("./clone/cloneNode.js"); -var _clone = require("./clone/clone.js"); -var _cloneDeep = require("./clone/cloneDeep.js"); -var _cloneDeepWithoutLoc = require("./clone/cloneDeepWithoutLoc.js"); -var _cloneWithoutLoc = require("./clone/cloneWithoutLoc.js"); -var _addComment = require("./comments/addComment.js"); -var _addComments = require("./comments/addComments.js"); -var _inheritInnerComments = require("./comments/inheritInnerComments.js"); -var _inheritLeadingComments = require("./comments/inheritLeadingComments.js"); -var _inheritsComments = require("./comments/inheritsComments.js"); -var _inheritTrailingComments = require("./comments/inheritTrailingComments.js"); -var _removeComments = require("./comments/removeComments.js"); -var _index3 = require("./constants/generated/index.js"); -Object.keys(_index3).forEach(function (key) { - if (key === "default" || key === "__esModule") return; - if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return; - if (key in exports && exports[key] === _index3[key]) return; - Object.defineProperty(exports, key, { - enumerable: true, - get: function () { - return _index3[key]; - } - }); -}); -var _index4 = require("./constants/index.js"); -Object.keys(_index4).forEach(function (key) { - if (key === "default" || key === "__esModule") return; - if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return; - if (key in exports && exports[key] === _index4[key]) return; - Object.defineProperty(exports, key, { - enumerable: true, - get: function () { - return _index4[key]; - } - }); -}); -var _ensureBlock = require("./converters/ensureBlock.js"); -var _toBindingIdentifierName = require("./converters/toBindingIdentifierName.js"); -var _toBlock = require("./converters/toBlock.js"); -var _toComputedKey = require("./converters/toComputedKey.js"); -var _toExpression = require("./converters/toExpression.js"); -var _toIdentifier = require("./converters/toIdentifier.js"); -var _toKeyAlias = require("./converters/toKeyAlias.js"); -var _toStatement = require("./converters/toStatement.js"); -var _valueToNode = require("./converters/valueToNode.js"); -var _index5 = require("./definitions/index.js"); -Object.keys(_index5).forEach(function (key) { - if (key === "default" || key === "__esModule") return; - if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return; - if (key in exports && exports[key] === _index5[key]) return; - Object.defineProperty(exports, key, { - enumerable: true, - get: function () { - return _index5[key]; - } - }); -}); -var _appendToMemberExpression = require("./modifications/appendToMemberExpression.js"); -var _inherits = require("./modifications/inherits.js"); -var _prependToMemberExpression = require("./modifications/prependToMemberExpression.js"); -var _removeProperties = require("./modifications/removeProperties.js"); -var _removePropertiesDeep = require("./modifications/removePropertiesDeep.js"); -var _removeTypeDuplicates = require("./modifications/flow/removeTypeDuplicates.js"); -var _getBindingIdentifiers = require("./retrievers/getBindingIdentifiers.js"); -var _getOuterBindingIdentifiers = require("./retrievers/getOuterBindingIdentifiers.js"); -var _traverse = require("./traverse/traverse.js"); -Object.keys(_traverse).forEach(function (key) { - if (key === "default" || key === "__esModule") return; - if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return; - if (key in exports && exports[key] === _traverse[key]) return; - Object.defineProperty(exports, key, { - enumerable: true, - get: function () { - return _traverse[key]; - } - }); -}); -var _traverseFast = require("./traverse/traverseFast.js"); -var _shallowEqual = require("./utils/shallowEqual.js"); -var _is = require("./validators/is.js"); -var _isBinding = require("./validators/isBinding.js"); -var _isBlockScoped = require("./validators/isBlockScoped.js"); -var _isImmutable = require("./validators/isImmutable.js"); -var _isLet = require("./validators/isLet.js"); -var _isNode = require("./validators/isNode.js"); -var _isNodesEquivalent = require("./validators/isNodesEquivalent.js"); -var _isPlaceholderType = require("./validators/isPlaceholderType.js"); -var _isReferenced = require("./validators/isReferenced.js"); -var _isScope = require("./validators/isScope.js"); -var _isSpecifierDefault = require("./validators/isSpecifierDefault.js"); -var _isType = require("./validators/isType.js"); -var _isValidES3Identifier = require("./validators/isValidES3Identifier.js"); -var _isValidIdentifier = require("./validators/isValidIdentifier.js"); -var _isVar = require("./validators/isVar.js"); -var _matchesPattern = require("./validators/matchesPattern.js"); -var _validate = require("./validators/validate.js"); -var _buildMatchMemberExpression = require("./validators/buildMatchMemberExpression.js"); -var _index6 = require("./validators/generated/index.js"); -Object.keys(_index6).forEach(function (key) { - if (key === "default" || key === "__esModule") return; - if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return; - if (key in exports && exports[key] === _index6[key]) return; - Object.defineProperty(exports, key, { - enumerable: true, - get: function () { - return _index6[key]; - } - }); -}); -var _deprecationWarning = require("./utils/deprecationWarning.js"); -const react = exports.react = { - isReactComponent: _isReactComponent.default, - isCompatTag: _isCompatTag.default, - buildChildren: _buildChildren.default -}; -{ - exports.toSequenceExpression = require("./converters/toSequenceExpression.js").default; -} - -//# sourceMappingURL=index.js.map diff --git a/tools/eslint/node_modules/@babel/types/lib/index.js.flow b/tools/eslint/node_modules/@babel/types/lib/index.js.flow deleted file mode 100644 index d9cdf9ba5c8c3b..00000000000000 --- a/tools/eslint/node_modules/@babel/types/lib/index.js.flow +++ /dev/null @@ -1,2612 +0,0 @@ -// NOTE: This file is autogenerated. Do not modify. -// See packages/babel-types/scripts/generators/flow.js for script used. - -declare class BabelNodeComment { - value: string; - start: number; - end: number; - loc: BabelNodeSourceLocation; -} - -declare class BabelNodeCommentBlock extends BabelNodeComment { - type: "CommentBlock"; -} - -declare class BabelNodeCommentLine extends BabelNodeComment { - type: "CommentLine"; -} - -declare class BabelNodeSourceLocation { - start: { - line: number; - column: number; - }; - - end: { - line: number; - column: number; - }; -} - -declare class BabelNode { - leadingComments?: Array; - innerComments?: Array; - trailingComments?: Array; - start: ?number; - end: ?number; - loc: ?BabelNodeSourceLocation; - extra?: { [string]: mixed }; -} - -declare class BabelNodeArrayExpression extends BabelNode { - type: "ArrayExpression"; - elements?: Array; -} - -declare class BabelNodeAssignmentExpression extends BabelNode { - type: "AssignmentExpression"; - operator: string; - left: BabelNodeLVal | BabelNodeOptionalMemberExpression; - right: BabelNodeExpression; -} - -declare class BabelNodeBinaryExpression extends BabelNode { - type: "BinaryExpression"; - operator: "+" | "-" | "/" | "%" | "*" | "**" | "&" | "|" | ">>" | ">>>" | "<<" | "^" | "==" | "===" | "!=" | "!==" | "in" | "instanceof" | ">" | "<" | ">=" | "<=" | "|>"; - left: BabelNodeExpression | BabelNodePrivateName; - right: BabelNodeExpression; -} - -declare class BabelNodeInterpreterDirective extends BabelNode { - type: "InterpreterDirective"; - value: string; -} - -declare class BabelNodeDirective extends BabelNode { - type: "Directive"; - value: BabelNodeDirectiveLiteral; -} - -declare class BabelNodeDirectiveLiteral extends BabelNode { - type: "DirectiveLiteral"; - value: string; -} - -declare class BabelNodeBlockStatement extends BabelNode { - type: "BlockStatement"; - body: Array; - directives?: Array; -} - -declare class BabelNodeBreakStatement extends BabelNode { - type: "BreakStatement"; - label?: BabelNodeIdentifier; -} - -declare class BabelNodeCallExpression extends BabelNode { - type: "CallExpression"; - callee: BabelNodeExpression | BabelNodeSuper | BabelNodeV8IntrinsicIdentifier; - arguments: Array; - optional?: true | false; - typeArguments?: BabelNodeTypeParameterInstantiation; - typeParameters?: BabelNodeTSTypeParameterInstantiation; -} - -declare class BabelNodeCatchClause extends BabelNode { - type: "CatchClause"; - param?: BabelNodeIdentifier | BabelNodeArrayPattern | BabelNodeObjectPattern; - body: BabelNodeBlockStatement; -} - -declare class BabelNodeConditionalExpression extends BabelNode { - type: "ConditionalExpression"; - test: BabelNodeExpression; - consequent: BabelNodeExpression; - alternate: BabelNodeExpression; -} - -declare class BabelNodeContinueStatement extends BabelNode { - type: "ContinueStatement"; - label?: BabelNodeIdentifier; -} - -declare class BabelNodeDebuggerStatement extends BabelNode { - type: "DebuggerStatement"; -} - -declare class BabelNodeDoWhileStatement extends BabelNode { - type: "DoWhileStatement"; - test: BabelNodeExpression; - body: BabelNodeStatement; -} - -declare class BabelNodeEmptyStatement extends BabelNode { - type: "EmptyStatement"; -} - -declare class BabelNodeExpressionStatement extends BabelNode { - type: "ExpressionStatement"; - expression: BabelNodeExpression; -} - -declare class BabelNodeFile extends BabelNode { - type: "File"; - program: BabelNodeProgram; - comments?: Array; - tokens?: Array; -} - -declare class BabelNodeForInStatement extends BabelNode { - type: "ForInStatement"; - left: BabelNodeVariableDeclaration | BabelNodeLVal; - right: BabelNodeExpression; - body: BabelNodeStatement; -} - -declare class BabelNodeForStatement extends BabelNode { - type: "ForStatement"; - init?: BabelNodeVariableDeclaration | BabelNodeExpression; - test?: BabelNodeExpression; - update?: BabelNodeExpression; - body: BabelNodeStatement; -} - -declare class BabelNodeFunctionDeclaration extends BabelNode { - type: "FunctionDeclaration"; - id?: BabelNodeIdentifier; - params: Array; - body: BabelNodeBlockStatement; - generator?: boolean; - async?: boolean; - declare?: boolean; - predicate?: BabelNodeDeclaredPredicate | BabelNodeInferredPredicate; - returnType?: BabelNodeTypeAnnotation | BabelNodeTSTypeAnnotation | BabelNodeNoop; - typeParameters?: BabelNodeTypeParameterDeclaration | BabelNodeTSTypeParameterDeclaration | BabelNodeNoop; -} - -declare class BabelNodeFunctionExpression extends BabelNode { - type: "FunctionExpression"; - id?: BabelNodeIdentifier; - params: Array; - body: BabelNodeBlockStatement; - generator?: boolean; - async?: boolean; - predicate?: BabelNodeDeclaredPredicate | BabelNodeInferredPredicate; - returnType?: BabelNodeTypeAnnotation | BabelNodeTSTypeAnnotation | BabelNodeNoop; - typeParameters?: BabelNodeTypeParameterDeclaration | BabelNodeTSTypeParameterDeclaration | BabelNodeNoop; -} - -declare class BabelNodeIdentifier extends BabelNode { - type: "Identifier"; - name: string; - decorators?: Array; - optional?: boolean; - typeAnnotation?: BabelNodeTypeAnnotation | BabelNodeTSTypeAnnotation | BabelNodeNoop; -} - -declare class BabelNodeIfStatement extends BabelNode { - type: "IfStatement"; - test: BabelNodeExpression; - consequent: BabelNodeStatement; - alternate?: BabelNodeStatement; -} - -declare class BabelNodeLabeledStatement extends BabelNode { - type: "LabeledStatement"; - label: BabelNodeIdentifier; - body: BabelNodeStatement; -} - -declare class BabelNodeStringLiteral extends BabelNode { - type: "StringLiteral"; - value: string; -} - -declare class BabelNodeNumericLiteral extends BabelNode { - type: "NumericLiteral"; - value: number; -} - -declare class BabelNodeNullLiteral extends BabelNode { - type: "NullLiteral"; -} - -declare class BabelNodeBooleanLiteral extends BabelNode { - type: "BooleanLiteral"; - value: boolean; -} - -declare class BabelNodeRegExpLiteral extends BabelNode { - type: "RegExpLiteral"; - pattern: string; - flags?: string; -} - -declare class BabelNodeLogicalExpression extends BabelNode { - type: "LogicalExpression"; - operator: "||" | "&&" | "??"; - left: BabelNodeExpression; - right: BabelNodeExpression; -} - -declare class BabelNodeMemberExpression extends BabelNode { - type: "MemberExpression"; - object: BabelNodeExpression | BabelNodeSuper; - property: BabelNodeExpression | BabelNodeIdentifier | BabelNodePrivateName; - computed?: boolean; - optional?: true | false; -} - -declare class BabelNodeNewExpression extends BabelNode { - type: "NewExpression"; - callee: BabelNodeExpression | BabelNodeSuper | BabelNodeV8IntrinsicIdentifier; - arguments: Array; - optional?: true | false; - typeArguments?: BabelNodeTypeParameterInstantiation; - typeParameters?: BabelNodeTSTypeParameterInstantiation; -} - -declare class BabelNodeProgram extends BabelNode { - type: "Program"; - body: Array; - directives?: Array; - sourceType?: "script" | "module"; - interpreter?: BabelNodeInterpreterDirective; -} - -declare class BabelNodeObjectExpression extends BabelNode { - type: "ObjectExpression"; - properties: Array; -} - -declare class BabelNodeObjectMethod extends BabelNode { - type: "ObjectMethod"; - kind?: "method" | "get" | "set"; - key: BabelNodeExpression | BabelNodeIdentifier | BabelNodeStringLiteral | BabelNodeNumericLiteral | BabelNodeBigIntLiteral; - params: Array; - body: BabelNodeBlockStatement; - computed?: boolean; - generator?: boolean; - async?: boolean; - decorators?: Array; - returnType?: BabelNodeTypeAnnotation | BabelNodeTSTypeAnnotation | BabelNodeNoop; - typeParameters?: BabelNodeTypeParameterDeclaration | BabelNodeTSTypeParameterDeclaration | BabelNodeNoop; -} - -declare class BabelNodeObjectProperty extends BabelNode { - type: "ObjectProperty"; - key: BabelNodeExpression | BabelNodeIdentifier | BabelNodeStringLiteral | BabelNodeNumericLiteral | BabelNodeBigIntLiteral | BabelNodeDecimalLiteral | BabelNodePrivateName; - value: BabelNodeExpression | BabelNodePatternLike; - computed?: boolean; - shorthand?: boolean; - decorators?: Array; -} - -declare class BabelNodeRestElement extends BabelNode { - type: "RestElement"; - argument: BabelNodeLVal; - decorators?: Array; - optional?: boolean; - typeAnnotation?: BabelNodeTypeAnnotation | BabelNodeTSTypeAnnotation | BabelNodeNoop; -} - -declare class BabelNodeReturnStatement extends BabelNode { - type: "ReturnStatement"; - argument?: BabelNodeExpression; -} - -declare class BabelNodeSequenceExpression extends BabelNode { - type: "SequenceExpression"; - expressions: Array; -} - -declare class BabelNodeParenthesizedExpression extends BabelNode { - type: "ParenthesizedExpression"; - expression: BabelNodeExpression; -} - -declare class BabelNodeSwitchCase extends BabelNode { - type: "SwitchCase"; - test?: BabelNodeExpression; - consequent: Array; -} - -declare class BabelNodeSwitchStatement extends BabelNode { - type: "SwitchStatement"; - discriminant: BabelNodeExpression; - cases: Array; -} - -declare class BabelNodeThisExpression extends BabelNode { - type: "ThisExpression"; -} - -declare class BabelNodeThrowStatement extends BabelNode { - type: "ThrowStatement"; - argument: BabelNodeExpression; -} - -declare class BabelNodeTryStatement extends BabelNode { - type: "TryStatement"; - block: BabelNodeBlockStatement; - handler?: BabelNodeCatchClause; - finalizer?: BabelNodeBlockStatement; -} - -declare class BabelNodeUnaryExpression extends BabelNode { - type: "UnaryExpression"; - operator: "void" | "throw" | "delete" | "!" | "+" | "-" | "~" | "typeof"; - argument: BabelNodeExpression; - prefix?: boolean; -} - -declare class BabelNodeUpdateExpression extends BabelNode { - type: "UpdateExpression"; - operator: "++" | "--"; - argument: BabelNodeExpression; - prefix?: boolean; -} - -declare class BabelNodeVariableDeclaration extends BabelNode { - type: "VariableDeclaration"; - kind: "var" | "let" | "const" | "using" | "await using"; - declarations: Array; - declare?: boolean; -} - -declare class BabelNodeVariableDeclarator extends BabelNode { - type: "VariableDeclarator"; - id: BabelNodeLVal; - init?: BabelNodeExpression; - definite?: boolean; -} - -declare class BabelNodeWhileStatement extends BabelNode { - type: "WhileStatement"; - test: BabelNodeExpression; - body: BabelNodeStatement; -} - -declare class BabelNodeWithStatement extends BabelNode { - type: "WithStatement"; - object: BabelNodeExpression; - body: BabelNodeStatement; -} - -declare class BabelNodeAssignmentPattern extends BabelNode { - type: "AssignmentPattern"; - left: BabelNodeIdentifier | BabelNodeObjectPattern | BabelNodeArrayPattern | BabelNodeMemberExpression | BabelNodeTSAsExpression | BabelNodeTSSatisfiesExpression | BabelNodeTSTypeAssertion | BabelNodeTSNonNullExpression; - right: BabelNodeExpression; - decorators?: Array; - optional?: boolean; - typeAnnotation?: BabelNodeTypeAnnotation | BabelNodeTSTypeAnnotation | BabelNodeNoop; -} - -declare class BabelNodeArrayPattern extends BabelNode { - type: "ArrayPattern"; - elements: Array; - decorators?: Array; - optional?: boolean; - typeAnnotation?: BabelNodeTypeAnnotation | BabelNodeTSTypeAnnotation | BabelNodeNoop; -} - -declare class BabelNodeArrowFunctionExpression extends BabelNode { - type: "ArrowFunctionExpression"; - params: Array; - body: BabelNodeBlockStatement | BabelNodeExpression; - async?: boolean; - expression: boolean; - generator?: boolean; - predicate?: BabelNodeDeclaredPredicate | BabelNodeInferredPredicate; - returnType?: BabelNodeTypeAnnotation | BabelNodeTSTypeAnnotation | BabelNodeNoop; - typeParameters?: BabelNodeTypeParameterDeclaration | BabelNodeTSTypeParameterDeclaration | BabelNodeNoop; -} - -declare class BabelNodeClassBody extends BabelNode { - type: "ClassBody"; - body: Array; -} - -declare class BabelNodeClassExpression extends BabelNode { - type: "ClassExpression"; - id?: BabelNodeIdentifier; - superClass?: BabelNodeExpression; - body: BabelNodeClassBody; - decorators?: Array; - mixins?: BabelNodeInterfaceExtends; - superTypeParameters?: BabelNodeTypeParameterInstantiation | BabelNodeTSTypeParameterInstantiation; - typeParameters?: BabelNodeTypeParameterDeclaration | BabelNodeTSTypeParameterDeclaration | BabelNodeNoop; -} - -declare class BabelNodeClassDeclaration extends BabelNode { - type: "ClassDeclaration"; - id?: BabelNodeIdentifier; - superClass?: BabelNodeExpression; - body: BabelNodeClassBody; - decorators?: Array; - abstract?: boolean; - declare?: boolean; - mixins?: BabelNodeInterfaceExtends; - superTypeParameters?: BabelNodeTypeParameterInstantiation | BabelNodeTSTypeParameterInstantiation; - typeParameters?: BabelNodeTypeParameterDeclaration | BabelNodeTSTypeParameterDeclaration | BabelNodeNoop; -} - -declare class BabelNodeExportAllDeclaration extends BabelNode { - type: "ExportAllDeclaration"; - source: BabelNodeStringLiteral; - assertions?: Array; - attributes?: Array; - exportKind?: "type" | "value"; -} - -declare class BabelNodeExportDefaultDeclaration extends BabelNode { - type: "ExportDefaultDeclaration"; - declaration: BabelNodeTSDeclareFunction | BabelNodeFunctionDeclaration | BabelNodeClassDeclaration | BabelNodeExpression; - exportKind?: "value"; -} - -declare class BabelNodeExportNamedDeclaration extends BabelNode { - type: "ExportNamedDeclaration"; - declaration?: BabelNodeDeclaration; - specifiers?: Array; - source?: BabelNodeStringLiteral; - assertions?: Array; - attributes?: Array; - exportKind?: "type" | "value"; -} - -declare class BabelNodeExportSpecifier extends BabelNode { - type: "ExportSpecifier"; - local: BabelNodeIdentifier; - exported: BabelNodeIdentifier | BabelNodeStringLiteral; - exportKind?: "type" | "value"; -} - -declare class BabelNodeForOfStatement extends BabelNode { - type: "ForOfStatement"; - left: BabelNodeVariableDeclaration | BabelNodeLVal; - right: BabelNodeExpression; - body: BabelNodeStatement; -} - -declare class BabelNodeImportDeclaration extends BabelNode { - type: "ImportDeclaration"; - specifiers: Array; - source: BabelNodeStringLiteral; - assertions?: Array; - attributes?: Array; - importKind?: "type" | "typeof" | "value"; - module?: boolean; - phase?: "source" | "defer"; -} - -declare class BabelNodeImportDefaultSpecifier extends BabelNode { - type: "ImportDefaultSpecifier"; - local: BabelNodeIdentifier; -} - -declare class BabelNodeImportNamespaceSpecifier extends BabelNode { - type: "ImportNamespaceSpecifier"; - local: BabelNodeIdentifier; -} - -declare class BabelNodeImportSpecifier extends BabelNode { - type: "ImportSpecifier"; - local: BabelNodeIdentifier; - imported: BabelNodeIdentifier | BabelNodeStringLiteral; - importKind?: "type" | "typeof" | "value"; -} - -declare class BabelNodeImportExpression extends BabelNode { - type: "ImportExpression"; - source: BabelNodeExpression; - options?: BabelNodeExpression; - phase?: "source" | "defer"; -} - -declare class BabelNodeMetaProperty extends BabelNode { - type: "MetaProperty"; - meta: BabelNodeIdentifier; - property: BabelNodeIdentifier; -} - -declare class BabelNodeClassMethod extends BabelNode { - type: "ClassMethod"; - kind?: "get" | "set" | "method" | "constructor"; - key: BabelNodeIdentifier | BabelNodeStringLiteral | BabelNodeNumericLiteral | BabelNodeBigIntLiteral | BabelNodeExpression; - params: Array; - body: BabelNodeBlockStatement; - computed?: boolean; - generator?: boolean; - async?: boolean; - abstract?: boolean; - access?: "public" | "private" | "protected"; - accessibility?: "public" | "private" | "protected"; - decorators?: Array; - optional?: boolean; - override?: boolean; - returnType?: BabelNodeTypeAnnotation | BabelNodeTSTypeAnnotation | BabelNodeNoop; - typeParameters?: BabelNodeTypeParameterDeclaration | BabelNodeTSTypeParameterDeclaration | BabelNodeNoop; -} - -declare class BabelNodeObjectPattern extends BabelNode { - type: "ObjectPattern"; - properties: Array; - decorators?: Array; - optional?: boolean; - typeAnnotation?: BabelNodeTypeAnnotation | BabelNodeTSTypeAnnotation | BabelNodeNoop; -} - -declare class BabelNodeSpreadElement extends BabelNode { - type: "SpreadElement"; - argument: BabelNodeExpression; -} - -declare class BabelNodeSuper extends BabelNode { - type: "Super"; -} - -declare class BabelNodeTaggedTemplateExpression extends BabelNode { - type: "TaggedTemplateExpression"; - tag: BabelNodeExpression; - quasi: BabelNodeTemplateLiteral; - typeParameters?: BabelNodeTypeParameterInstantiation | BabelNodeTSTypeParameterInstantiation; -} - -declare class BabelNodeTemplateElement extends BabelNode { - type: "TemplateElement"; - value: { raw: string, cooked?: string }; - tail?: boolean; -} - -declare class BabelNodeTemplateLiteral extends BabelNode { - type: "TemplateLiteral"; - quasis: Array; - expressions: Array; -} - -declare class BabelNodeYieldExpression extends BabelNode { - type: "YieldExpression"; - argument?: BabelNodeExpression; - delegate?: boolean; -} - -declare class BabelNodeAwaitExpression extends BabelNode { - type: "AwaitExpression"; - argument: BabelNodeExpression; -} - -declare class BabelNodeImport extends BabelNode { - type: "Import"; -} - -declare class BabelNodeBigIntLiteral extends BabelNode { - type: "BigIntLiteral"; - value: string; -} - -declare class BabelNodeExportNamespaceSpecifier extends BabelNode { - type: "ExportNamespaceSpecifier"; - exported: BabelNodeIdentifier; -} - -declare class BabelNodeOptionalMemberExpression extends BabelNode { - type: "OptionalMemberExpression"; - object: BabelNodeExpression; - property: BabelNodeExpression | BabelNodeIdentifier; - computed?: boolean; - optional: boolean; -} - -declare class BabelNodeOptionalCallExpression extends BabelNode { - type: "OptionalCallExpression"; - callee: BabelNodeExpression; - arguments: Array; - optional: boolean; - typeArguments?: BabelNodeTypeParameterInstantiation; - typeParameters?: BabelNodeTSTypeParameterInstantiation; -} - -declare class BabelNodeClassProperty extends BabelNode { - type: "ClassProperty"; - key: BabelNodeIdentifier | BabelNodeStringLiteral | BabelNodeNumericLiteral | BabelNodeBigIntLiteral | BabelNodeExpression; - value?: BabelNodeExpression; - typeAnnotation?: BabelNodeTypeAnnotation | BabelNodeTSTypeAnnotation | BabelNodeNoop; - decorators?: Array; - computed?: boolean; - abstract?: boolean; - accessibility?: "public" | "private" | "protected"; - declare?: boolean; - definite?: boolean; - optional?: boolean; - override?: boolean; - readonly?: boolean; - variance?: BabelNodeVariance; -} - -declare class BabelNodeClassAccessorProperty extends BabelNode { - type: "ClassAccessorProperty"; - key: BabelNodeIdentifier | BabelNodeStringLiteral | BabelNodeNumericLiteral | BabelNodeBigIntLiteral | BabelNodeExpression | BabelNodePrivateName; - value?: BabelNodeExpression; - typeAnnotation?: BabelNodeTypeAnnotation | BabelNodeTSTypeAnnotation | BabelNodeNoop; - decorators?: Array; - computed?: boolean; - abstract?: boolean; - accessibility?: "public" | "private" | "protected"; - declare?: boolean; - definite?: boolean; - optional?: boolean; - override?: boolean; - readonly?: boolean; - variance?: BabelNodeVariance; -} - -declare class BabelNodeClassPrivateProperty extends BabelNode { - type: "ClassPrivateProperty"; - key: BabelNodePrivateName; - value?: BabelNodeExpression; - decorators?: Array; - definite?: boolean; - readonly?: boolean; - typeAnnotation?: BabelNodeTypeAnnotation | BabelNodeTSTypeAnnotation | BabelNodeNoop; - variance?: BabelNodeVariance; -} - -declare class BabelNodeClassPrivateMethod extends BabelNode { - type: "ClassPrivateMethod"; - kind?: "get" | "set" | "method"; - key: BabelNodePrivateName; - params: Array; - body: BabelNodeBlockStatement; - abstract?: boolean; - access?: "public" | "private" | "protected"; - accessibility?: "public" | "private" | "protected"; - async?: boolean; - computed?: boolean; - decorators?: Array; - generator?: boolean; - optional?: boolean; - override?: boolean; - returnType?: BabelNodeTypeAnnotation | BabelNodeTSTypeAnnotation | BabelNodeNoop; - typeParameters?: BabelNodeTypeParameterDeclaration | BabelNodeTSTypeParameterDeclaration | BabelNodeNoop; -} - -declare class BabelNodePrivateName extends BabelNode { - type: "PrivateName"; - id: BabelNodeIdentifier; -} - -declare class BabelNodeStaticBlock extends BabelNode { - type: "StaticBlock"; - body: Array; -} - -declare class BabelNodeAnyTypeAnnotation extends BabelNode { - type: "AnyTypeAnnotation"; -} - -declare class BabelNodeArrayTypeAnnotation extends BabelNode { - type: "ArrayTypeAnnotation"; - elementType: BabelNodeFlowType; -} - -declare class BabelNodeBooleanTypeAnnotation extends BabelNode { - type: "BooleanTypeAnnotation"; -} - -declare class BabelNodeBooleanLiteralTypeAnnotation extends BabelNode { - type: "BooleanLiteralTypeAnnotation"; - value: boolean; -} - -declare class BabelNodeNullLiteralTypeAnnotation extends BabelNode { - type: "NullLiteralTypeAnnotation"; -} - -declare class BabelNodeClassImplements extends BabelNode { - type: "ClassImplements"; - id: BabelNodeIdentifier; - typeParameters?: BabelNodeTypeParameterInstantiation; -} - -declare class BabelNodeDeclareClass extends BabelNode { - type: "DeclareClass"; - id: BabelNodeIdentifier; - typeParameters?: BabelNodeTypeParameterDeclaration; - body: BabelNodeObjectTypeAnnotation; - mixins?: Array; -} - -declare class BabelNodeDeclareFunction extends BabelNode { - type: "DeclareFunction"; - id: BabelNodeIdentifier; - predicate?: BabelNodeDeclaredPredicate; -} - -declare class BabelNodeDeclareInterface extends BabelNode { - type: "DeclareInterface"; - id: BabelNodeIdentifier; - typeParameters?: BabelNodeTypeParameterDeclaration; - body: BabelNodeObjectTypeAnnotation; -} - -declare class BabelNodeDeclareModule extends BabelNode { - type: "DeclareModule"; - id: BabelNodeIdentifier | BabelNodeStringLiteral; - body: BabelNodeBlockStatement; - kind?: "CommonJS" | "ES"; -} - -declare class BabelNodeDeclareModuleExports extends BabelNode { - type: "DeclareModuleExports"; - typeAnnotation: BabelNodeTypeAnnotation; -} - -declare class BabelNodeDeclareTypeAlias extends BabelNode { - type: "DeclareTypeAlias"; - id: BabelNodeIdentifier; - typeParameters?: BabelNodeTypeParameterDeclaration; - right: BabelNodeFlowType; -} - -declare class BabelNodeDeclareOpaqueType extends BabelNode { - type: "DeclareOpaqueType"; - id: BabelNodeIdentifier; - typeParameters?: BabelNodeTypeParameterDeclaration; - supertype?: BabelNodeFlowType; - impltype?: BabelNodeFlowType; -} - -declare class BabelNodeDeclareVariable extends BabelNode { - type: "DeclareVariable"; - id: BabelNodeIdentifier; -} - -declare class BabelNodeDeclareExportDeclaration extends BabelNode { - type: "DeclareExportDeclaration"; - declaration?: BabelNodeFlow; - specifiers?: Array; - source?: BabelNodeStringLiteral; -} - -declare class BabelNodeDeclareExportAllDeclaration extends BabelNode { - type: "DeclareExportAllDeclaration"; - source: BabelNodeStringLiteral; - exportKind?: "type" | "value"; -} - -declare class BabelNodeDeclaredPredicate extends BabelNode { - type: "DeclaredPredicate"; - value: BabelNodeFlow; -} - -declare class BabelNodeExistsTypeAnnotation extends BabelNode { - type: "ExistsTypeAnnotation"; -} - -declare class BabelNodeFunctionTypeAnnotation extends BabelNode { - type: "FunctionTypeAnnotation"; - typeParameters?: BabelNodeTypeParameterDeclaration; - params: Array; - rest?: BabelNodeFunctionTypeParam; - returnType: BabelNodeFlowType; -} - -declare class BabelNodeFunctionTypeParam extends BabelNode { - type: "FunctionTypeParam"; - name?: BabelNodeIdentifier; - typeAnnotation: BabelNodeFlowType; - optional?: boolean; -} - -declare class BabelNodeGenericTypeAnnotation extends BabelNode { - type: "GenericTypeAnnotation"; - id: BabelNodeIdentifier | BabelNodeQualifiedTypeIdentifier; - typeParameters?: BabelNodeTypeParameterInstantiation; -} - -declare class BabelNodeInferredPredicate extends BabelNode { - type: "InferredPredicate"; -} - -declare class BabelNodeInterfaceExtends extends BabelNode { - type: "InterfaceExtends"; - id: BabelNodeIdentifier | BabelNodeQualifiedTypeIdentifier; - typeParameters?: BabelNodeTypeParameterInstantiation; -} - -declare class BabelNodeInterfaceDeclaration extends BabelNode { - type: "InterfaceDeclaration"; - id: BabelNodeIdentifier; - typeParameters?: BabelNodeTypeParameterDeclaration; - body: BabelNodeObjectTypeAnnotation; -} - -declare class BabelNodeInterfaceTypeAnnotation extends BabelNode { - type: "InterfaceTypeAnnotation"; - body: BabelNodeObjectTypeAnnotation; -} - -declare class BabelNodeIntersectionTypeAnnotation extends BabelNode { - type: "IntersectionTypeAnnotation"; - types: Array; -} - -declare class BabelNodeMixedTypeAnnotation extends BabelNode { - type: "MixedTypeAnnotation"; -} - -declare class BabelNodeEmptyTypeAnnotation extends BabelNode { - type: "EmptyTypeAnnotation"; -} - -declare class BabelNodeNullableTypeAnnotation extends BabelNode { - type: "NullableTypeAnnotation"; - typeAnnotation: BabelNodeFlowType; -} - -declare class BabelNodeNumberLiteralTypeAnnotation extends BabelNode { - type: "NumberLiteralTypeAnnotation"; - value: number; -} - -declare class BabelNodeNumberTypeAnnotation extends BabelNode { - type: "NumberTypeAnnotation"; -} - -declare class BabelNodeObjectTypeAnnotation extends BabelNode { - type: "ObjectTypeAnnotation"; - properties: Array; - indexers?: Array; - callProperties?: Array; - internalSlots?: Array; - exact?: boolean; - inexact?: boolean; -} - -declare class BabelNodeObjectTypeInternalSlot extends BabelNode { - type: "ObjectTypeInternalSlot"; - id: BabelNodeIdentifier; - value: BabelNodeFlowType; - optional: boolean; - method: boolean; -} - -declare class BabelNodeObjectTypeCallProperty extends BabelNode { - type: "ObjectTypeCallProperty"; - value: BabelNodeFlowType; -} - -declare class BabelNodeObjectTypeIndexer extends BabelNode { - type: "ObjectTypeIndexer"; - id?: BabelNodeIdentifier; - key: BabelNodeFlowType; - value: BabelNodeFlowType; - variance?: BabelNodeVariance; -} - -declare class BabelNodeObjectTypeProperty extends BabelNode { - type: "ObjectTypeProperty"; - key: BabelNodeIdentifier | BabelNodeStringLiteral; - value: BabelNodeFlowType; - variance?: BabelNodeVariance; - kind: "init" | "get" | "set"; - method: boolean; - optional: boolean; - proto: boolean; -} - -declare class BabelNodeObjectTypeSpreadProperty extends BabelNode { - type: "ObjectTypeSpreadProperty"; - argument: BabelNodeFlowType; -} - -declare class BabelNodeOpaqueType extends BabelNode { - type: "OpaqueType"; - id: BabelNodeIdentifier; - typeParameters?: BabelNodeTypeParameterDeclaration; - supertype?: BabelNodeFlowType; - impltype: BabelNodeFlowType; -} - -declare class BabelNodeQualifiedTypeIdentifier extends BabelNode { - type: "QualifiedTypeIdentifier"; - id: BabelNodeIdentifier; - qualification: BabelNodeIdentifier | BabelNodeQualifiedTypeIdentifier; -} - -declare class BabelNodeStringLiteralTypeAnnotation extends BabelNode { - type: "StringLiteralTypeAnnotation"; - value: string; -} - -declare class BabelNodeStringTypeAnnotation extends BabelNode { - type: "StringTypeAnnotation"; -} - -declare class BabelNodeSymbolTypeAnnotation extends BabelNode { - type: "SymbolTypeAnnotation"; -} - -declare class BabelNodeThisTypeAnnotation extends BabelNode { - type: "ThisTypeAnnotation"; -} - -declare class BabelNodeTupleTypeAnnotation extends BabelNode { - type: "TupleTypeAnnotation"; - types: Array; -} - -declare class BabelNodeTypeofTypeAnnotation extends BabelNode { - type: "TypeofTypeAnnotation"; - argument: BabelNodeFlowType; -} - -declare class BabelNodeTypeAlias extends BabelNode { - type: "TypeAlias"; - id: BabelNodeIdentifier; - typeParameters?: BabelNodeTypeParameterDeclaration; - right: BabelNodeFlowType; -} - -declare class BabelNodeTypeAnnotation extends BabelNode { - type: "TypeAnnotation"; - typeAnnotation: BabelNodeFlowType; -} - -declare class BabelNodeTypeCastExpression extends BabelNode { - type: "TypeCastExpression"; - expression: BabelNodeExpression; - typeAnnotation: BabelNodeTypeAnnotation; -} - -declare class BabelNodeTypeParameter extends BabelNode { - type: "TypeParameter"; - bound?: BabelNodeTypeAnnotation; - variance?: BabelNodeVariance; - name: string; -} - -declare class BabelNodeTypeParameterDeclaration extends BabelNode { - type: "TypeParameterDeclaration"; - params: Array; -} - -declare class BabelNodeTypeParameterInstantiation extends BabelNode { - type: "TypeParameterInstantiation"; - params: Array; -} - -declare class BabelNodeUnionTypeAnnotation extends BabelNode { - type: "UnionTypeAnnotation"; - types: Array; -} - -declare class BabelNodeVariance extends BabelNode { - type: "Variance"; - kind: "minus" | "plus"; -} - -declare class BabelNodeVoidTypeAnnotation extends BabelNode { - type: "VoidTypeAnnotation"; -} - -declare class BabelNodeEnumDeclaration extends BabelNode { - type: "EnumDeclaration"; - id: BabelNodeIdentifier; - body: BabelNodeEnumBooleanBody | BabelNodeEnumNumberBody | BabelNodeEnumStringBody | BabelNodeEnumSymbolBody; -} - -declare class BabelNodeEnumBooleanBody extends BabelNode { - type: "EnumBooleanBody"; - members: Array; - explicitType: boolean; - hasUnknownMembers: boolean; -} - -declare class BabelNodeEnumNumberBody extends BabelNode { - type: "EnumNumberBody"; - members: Array; - explicitType: boolean; - hasUnknownMembers: boolean; -} - -declare class BabelNodeEnumStringBody extends BabelNode { - type: "EnumStringBody"; - members: Array; - explicitType: boolean; - hasUnknownMembers: boolean; -} - -declare class BabelNodeEnumSymbolBody extends BabelNode { - type: "EnumSymbolBody"; - members: Array; - hasUnknownMembers: boolean; -} - -declare class BabelNodeEnumBooleanMember extends BabelNode { - type: "EnumBooleanMember"; - id: BabelNodeIdentifier; - init: BabelNodeBooleanLiteral; -} - -declare class BabelNodeEnumNumberMember extends BabelNode { - type: "EnumNumberMember"; - id: BabelNodeIdentifier; - init: BabelNodeNumericLiteral; -} - -declare class BabelNodeEnumStringMember extends BabelNode { - type: "EnumStringMember"; - id: BabelNodeIdentifier; - init: BabelNodeStringLiteral; -} - -declare class BabelNodeEnumDefaultedMember extends BabelNode { - type: "EnumDefaultedMember"; - id: BabelNodeIdentifier; -} - -declare class BabelNodeIndexedAccessType extends BabelNode { - type: "IndexedAccessType"; - objectType: BabelNodeFlowType; - indexType: BabelNodeFlowType; -} - -declare class BabelNodeOptionalIndexedAccessType extends BabelNode { - type: "OptionalIndexedAccessType"; - objectType: BabelNodeFlowType; - indexType: BabelNodeFlowType; - optional: boolean; -} - -declare class BabelNodeJSXAttribute extends BabelNode { - type: "JSXAttribute"; - name: BabelNodeJSXIdentifier | BabelNodeJSXNamespacedName; - value?: BabelNodeJSXElement | BabelNodeJSXFragment | BabelNodeStringLiteral | BabelNodeJSXExpressionContainer; -} - -declare class BabelNodeJSXClosingElement extends BabelNode { - type: "JSXClosingElement"; - name: BabelNodeJSXIdentifier | BabelNodeJSXMemberExpression | BabelNodeJSXNamespacedName; -} - -declare class BabelNodeJSXElement extends BabelNode { - type: "JSXElement"; - openingElement: BabelNodeJSXOpeningElement; - closingElement?: BabelNodeJSXClosingElement; - children: Array; - selfClosing?: boolean; -} - -declare class BabelNodeJSXEmptyExpression extends BabelNode { - type: "JSXEmptyExpression"; -} - -declare class BabelNodeJSXExpressionContainer extends BabelNode { - type: "JSXExpressionContainer"; - expression: BabelNodeExpression | BabelNodeJSXEmptyExpression; -} - -declare class BabelNodeJSXSpreadChild extends BabelNode { - type: "JSXSpreadChild"; - expression: BabelNodeExpression; -} - -declare class BabelNodeJSXIdentifier extends BabelNode { - type: "JSXIdentifier"; - name: string; -} - -declare class BabelNodeJSXMemberExpression extends BabelNode { - type: "JSXMemberExpression"; - object: BabelNodeJSXMemberExpression | BabelNodeJSXIdentifier; - property: BabelNodeJSXIdentifier; -} - -declare class BabelNodeJSXNamespacedName extends BabelNode { - type: "JSXNamespacedName"; - namespace: BabelNodeJSXIdentifier; - name: BabelNodeJSXIdentifier; -} - -declare class BabelNodeJSXOpeningElement extends BabelNode { - type: "JSXOpeningElement"; - name: BabelNodeJSXIdentifier | BabelNodeJSXMemberExpression | BabelNodeJSXNamespacedName; - attributes: Array; - selfClosing?: boolean; - typeParameters?: BabelNodeTypeParameterInstantiation | BabelNodeTSTypeParameterInstantiation; -} - -declare class BabelNodeJSXSpreadAttribute extends BabelNode { - type: "JSXSpreadAttribute"; - argument: BabelNodeExpression; -} - -declare class BabelNodeJSXText extends BabelNode { - type: "JSXText"; - value: string; -} - -declare class BabelNodeJSXFragment extends BabelNode { - type: "JSXFragment"; - openingFragment: BabelNodeJSXOpeningFragment; - closingFragment: BabelNodeJSXClosingFragment; - children: Array; -} - -declare class BabelNodeJSXOpeningFragment extends BabelNode { - type: "JSXOpeningFragment"; -} - -declare class BabelNodeJSXClosingFragment extends BabelNode { - type: "JSXClosingFragment"; -} - -declare class BabelNodeNoop extends BabelNode { - type: "Noop"; -} - -declare class BabelNodePlaceholder extends BabelNode { - type: "Placeholder"; - expectedNode: "Identifier" | "StringLiteral" | "Expression" | "Statement" | "Declaration" | "BlockStatement" | "ClassBody" | "Pattern"; - name: BabelNodeIdentifier; -} - -declare class BabelNodeV8IntrinsicIdentifier extends BabelNode { - type: "V8IntrinsicIdentifier"; - name: string; -} - -declare class BabelNodeArgumentPlaceholder extends BabelNode { - type: "ArgumentPlaceholder"; -} - -declare class BabelNodeBindExpression extends BabelNode { - type: "BindExpression"; - object: BabelNodeExpression; - callee: BabelNodeExpression; -} - -declare class BabelNodeImportAttribute extends BabelNode { - type: "ImportAttribute"; - key: BabelNodeIdentifier | BabelNodeStringLiteral; - value: BabelNodeStringLiteral; -} - -declare class BabelNodeDecorator extends BabelNode { - type: "Decorator"; - expression: BabelNodeExpression; -} - -declare class BabelNodeDoExpression extends BabelNode { - type: "DoExpression"; - body: BabelNodeBlockStatement; - async?: boolean; -} - -declare class BabelNodeExportDefaultSpecifier extends BabelNode { - type: "ExportDefaultSpecifier"; - exported: BabelNodeIdentifier; -} - -declare class BabelNodeRecordExpression extends BabelNode { - type: "RecordExpression"; - properties: Array; -} - -declare class BabelNodeTupleExpression extends BabelNode { - type: "TupleExpression"; - elements?: Array; -} - -declare class BabelNodeDecimalLiteral extends BabelNode { - type: "DecimalLiteral"; - value: string; -} - -declare class BabelNodeModuleExpression extends BabelNode { - type: "ModuleExpression"; - body: BabelNodeProgram; -} - -declare class BabelNodeTopicReference extends BabelNode { - type: "TopicReference"; -} - -declare class BabelNodePipelineTopicExpression extends BabelNode { - type: "PipelineTopicExpression"; - expression: BabelNodeExpression; -} - -declare class BabelNodePipelineBareFunction extends BabelNode { - type: "PipelineBareFunction"; - callee: BabelNodeExpression; -} - -declare class BabelNodePipelinePrimaryTopicReference extends BabelNode { - type: "PipelinePrimaryTopicReference"; -} - -declare class BabelNodeTSParameterProperty extends BabelNode { - type: "TSParameterProperty"; - parameter: BabelNodeIdentifier | BabelNodeAssignmentPattern; - accessibility?: "public" | "private" | "protected"; - decorators?: Array; - override?: boolean; - readonly?: boolean; -} - -declare class BabelNodeTSDeclareFunction extends BabelNode { - type: "TSDeclareFunction"; - id?: BabelNodeIdentifier; - typeParameters?: BabelNodeTSTypeParameterDeclaration | BabelNodeNoop; - params: Array; - returnType?: BabelNodeTSTypeAnnotation | BabelNodeNoop; - async?: boolean; - declare?: boolean; - generator?: boolean; -} - -declare class BabelNodeTSDeclareMethod extends BabelNode { - type: "TSDeclareMethod"; - decorators?: Array; - key: BabelNodeIdentifier | BabelNodeStringLiteral | BabelNodeNumericLiteral | BabelNodeBigIntLiteral | BabelNodeExpression; - typeParameters?: BabelNodeTSTypeParameterDeclaration | BabelNodeNoop; - params: Array; - returnType?: BabelNodeTSTypeAnnotation | BabelNodeNoop; - abstract?: boolean; - access?: "public" | "private" | "protected"; - accessibility?: "public" | "private" | "protected"; - async?: boolean; - computed?: boolean; - generator?: boolean; - kind?: "get" | "set" | "method" | "constructor"; - optional?: boolean; - override?: boolean; -} - -declare class BabelNodeTSQualifiedName extends BabelNode { - type: "TSQualifiedName"; - left: BabelNodeTSEntityName; - right: BabelNodeIdentifier; -} - -declare class BabelNodeTSCallSignatureDeclaration extends BabelNode { - type: "TSCallSignatureDeclaration"; - typeParameters?: BabelNodeTSTypeParameterDeclaration; - parameters: Array; - typeAnnotation?: BabelNodeTSTypeAnnotation; -} - -declare class BabelNodeTSConstructSignatureDeclaration extends BabelNode { - type: "TSConstructSignatureDeclaration"; - typeParameters?: BabelNodeTSTypeParameterDeclaration; - parameters: Array; - typeAnnotation?: BabelNodeTSTypeAnnotation; -} - -declare class BabelNodeTSPropertySignature extends BabelNode { - type: "TSPropertySignature"; - key: BabelNodeExpression; - typeAnnotation?: BabelNodeTSTypeAnnotation; - computed?: boolean; - kind: "get" | "set"; - optional?: boolean; - readonly?: boolean; -} - -declare class BabelNodeTSMethodSignature extends BabelNode { - type: "TSMethodSignature"; - key: BabelNodeExpression; - typeParameters?: BabelNodeTSTypeParameterDeclaration; - parameters: Array; - typeAnnotation?: BabelNodeTSTypeAnnotation; - computed?: boolean; - kind: "method" | "get" | "set"; - optional?: boolean; -} - -declare class BabelNodeTSIndexSignature extends BabelNode { - type: "TSIndexSignature"; - parameters: Array; - typeAnnotation?: BabelNodeTSTypeAnnotation; - readonly?: boolean; -} - -declare class BabelNodeTSAnyKeyword extends BabelNode { - type: "TSAnyKeyword"; -} - -declare class BabelNodeTSBooleanKeyword extends BabelNode { - type: "TSBooleanKeyword"; -} - -declare class BabelNodeTSBigIntKeyword extends BabelNode { - type: "TSBigIntKeyword"; -} - -declare class BabelNodeTSIntrinsicKeyword extends BabelNode { - type: "TSIntrinsicKeyword"; -} - -declare class BabelNodeTSNeverKeyword extends BabelNode { - type: "TSNeverKeyword"; -} - -declare class BabelNodeTSNullKeyword extends BabelNode { - type: "TSNullKeyword"; -} - -declare class BabelNodeTSNumberKeyword extends BabelNode { - type: "TSNumberKeyword"; -} - -declare class BabelNodeTSObjectKeyword extends BabelNode { - type: "TSObjectKeyword"; -} - -declare class BabelNodeTSStringKeyword extends BabelNode { - type: "TSStringKeyword"; -} - -declare class BabelNodeTSSymbolKeyword extends BabelNode { - type: "TSSymbolKeyword"; -} - -declare class BabelNodeTSUndefinedKeyword extends BabelNode { - type: "TSUndefinedKeyword"; -} - -declare class BabelNodeTSUnknownKeyword extends BabelNode { - type: "TSUnknownKeyword"; -} - -declare class BabelNodeTSVoidKeyword extends BabelNode { - type: "TSVoidKeyword"; -} - -declare class BabelNodeTSThisType extends BabelNode { - type: "TSThisType"; -} - -declare class BabelNodeTSFunctionType extends BabelNode { - type: "TSFunctionType"; - typeParameters?: BabelNodeTSTypeParameterDeclaration; - parameters: Array; - typeAnnotation?: BabelNodeTSTypeAnnotation; -} - -declare class BabelNodeTSConstructorType extends BabelNode { - type: "TSConstructorType"; - typeParameters?: BabelNodeTSTypeParameterDeclaration; - parameters: Array; - typeAnnotation?: BabelNodeTSTypeAnnotation; - abstract?: boolean; -} - -declare class BabelNodeTSTypeReference extends BabelNode { - type: "TSTypeReference"; - typeName: BabelNodeTSEntityName; - typeParameters?: BabelNodeTSTypeParameterInstantiation; -} - -declare class BabelNodeTSTypePredicate extends BabelNode { - type: "TSTypePredicate"; - parameterName: BabelNodeIdentifier | BabelNodeTSThisType; - typeAnnotation?: BabelNodeTSTypeAnnotation; - asserts?: boolean; -} - -declare class BabelNodeTSTypeQuery extends BabelNode { - type: "TSTypeQuery"; - exprName: BabelNodeTSEntityName | BabelNodeTSImportType; - typeParameters?: BabelNodeTSTypeParameterInstantiation; -} - -declare class BabelNodeTSTypeLiteral extends BabelNode { - type: "TSTypeLiteral"; - members: Array; -} - -declare class BabelNodeTSArrayType extends BabelNode { - type: "TSArrayType"; - elementType: BabelNodeTSType; -} - -declare class BabelNodeTSTupleType extends BabelNode { - type: "TSTupleType"; - elementTypes: Array; -} - -declare class BabelNodeTSOptionalType extends BabelNode { - type: "TSOptionalType"; - typeAnnotation: BabelNodeTSType; -} - -declare class BabelNodeTSRestType extends BabelNode { - type: "TSRestType"; - typeAnnotation: BabelNodeTSType; -} - -declare class BabelNodeTSNamedTupleMember extends BabelNode { - type: "TSNamedTupleMember"; - label: BabelNodeIdentifier; - elementType: BabelNodeTSType; - optional?: boolean; -} - -declare class BabelNodeTSUnionType extends BabelNode { - type: "TSUnionType"; - types: Array; -} - -declare class BabelNodeTSIntersectionType extends BabelNode { - type: "TSIntersectionType"; - types: Array; -} - -declare class BabelNodeTSConditionalType extends BabelNode { - type: "TSConditionalType"; - checkType: BabelNodeTSType; - extendsType: BabelNodeTSType; - trueType: BabelNodeTSType; - falseType: BabelNodeTSType; -} - -declare class BabelNodeTSInferType extends BabelNode { - type: "TSInferType"; - typeParameter: BabelNodeTSTypeParameter; -} - -declare class BabelNodeTSParenthesizedType extends BabelNode { - type: "TSParenthesizedType"; - typeAnnotation: BabelNodeTSType; -} - -declare class BabelNodeTSTypeOperator extends BabelNode { - type: "TSTypeOperator"; - typeAnnotation: BabelNodeTSType; - operator: string; -} - -declare class BabelNodeTSIndexedAccessType extends BabelNode { - type: "TSIndexedAccessType"; - objectType: BabelNodeTSType; - indexType: BabelNodeTSType; -} - -declare class BabelNodeTSMappedType extends BabelNode { - type: "TSMappedType"; - typeParameter: BabelNodeTSTypeParameter; - typeAnnotation?: BabelNodeTSType; - nameType?: BabelNodeTSType; - optional?: true | false | "+" | "-"; - readonly?: true | false | "+" | "-"; -} - -declare class BabelNodeTSLiteralType extends BabelNode { - type: "TSLiteralType"; - literal: BabelNodeNumericLiteral | BabelNodeStringLiteral | BabelNodeBooleanLiteral | BabelNodeBigIntLiteral | BabelNodeTemplateLiteral | BabelNodeUnaryExpression; -} - -declare class BabelNodeTSExpressionWithTypeArguments extends BabelNode { - type: "TSExpressionWithTypeArguments"; - expression: BabelNodeTSEntityName; - typeParameters?: BabelNodeTSTypeParameterInstantiation; -} - -declare class BabelNodeTSInterfaceDeclaration extends BabelNode { - type: "TSInterfaceDeclaration"; - id: BabelNodeIdentifier; - typeParameters?: BabelNodeTSTypeParameterDeclaration; - body: BabelNodeTSInterfaceBody; - declare?: boolean; -} - -declare class BabelNodeTSInterfaceBody extends BabelNode { - type: "TSInterfaceBody"; - body: Array; -} - -declare class BabelNodeTSTypeAliasDeclaration extends BabelNode { - type: "TSTypeAliasDeclaration"; - id: BabelNodeIdentifier; - typeParameters?: BabelNodeTSTypeParameterDeclaration; - typeAnnotation: BabelNodeTSType; - declare?: boolean; -} - -declare class BabelNodeTSInstantiationExpression extends BabelNode { - type: "TSInstantiationExpression"; - expression: BabelNodeExpression; - typeParameters?: BabelNodeTSTypeParameterInstantiation; -} - -declare class BabelNodeTSAsExpression extends BabelNode { - type: "TSAsExpression"; - expression: BabelNodeExpression; - typeAnnotation: BabelNodeTSType; -} - -declare class BabelNodeTSSatisfiesExpression extends BabelNode { - type: "TSSatisfiesExpression"; - expression: BabelNodeExpression; - typeAnnotation: BabelNodeTSType; -} - -declare class BabelNodeTSTypeAssertion extends BabelNode { - type: "TSTypeAssertion"; - typeAnnotation: BabelNodeTSType; - expression: BabelNodeExpression; -} - -declare class BabelNodeTSEnumDeclaration extends BabelNode { - type: "TSEnumDeclaration"; - id: BabelNodeIdentifier; - members: Array; - declare?: boolean; - initializer?: BabelNodeExpression; -} - -declare class BabelNodeTSEnumMember extends BabelNode { - type: "TSEnumMember"; - id: BabelNodeIdentifier | BabelNodeStringLiteral; - initializer?: BabelNodeExpression; -} - -declare class BabelNodeTSModuleDeclaration extends BabelNode { - type: "TSModuleDeclaration"; - id: BabelNodeIdentifier | BabelNodeStringLiteral; - body: BabelNodeTSModuleBlock | BabelNodeTSModuleDeclaration; - declare?: boolean; - global?: boolean; -} - -declare class BabelNodeTSModuleBlock extends BabelNode { - type: "TSModuleBlock"; - body: Array; -} - -declare class BabelNodeTSImportType extends BabelNode { - type: "TSImportType"; - argument: BabelNodeStringLiteral; - qualifier?: BabelNodeTSEntityName; - typeParameters?: BabelNodeTSTypeParameterInstantiation; - options?: BabelNodeExpression; -} - -declare class BabelNodeTSImportEqualsDeclaration extends BabelNode { - type: "TSImportEqualsDeclaration"; - id: BabelNodeIdentifier; - moduleReference: BabelNodeTSEntityName | BabelNodeTSExternalModuleReference; - importKind?: "type" | "value"; - isExport: boolean; -} - -declare class BabelNodeTSExternalModuleReference extends BabelNode { - type: "TSExternalModuleReference"; - expression: BabelNodeStringLiteral; -} - -declare class BabelNodeTSNonNullExpression extends BabelNode { - type: "TSNonNullExpression"; - expression: BabelNodeExpression; -} - -declare class BabelNodeTSExportAssignment extends BabelNode { - type: "TSExportAssignment"; - expression: BabelNodeExpression; -} - -declare class BabelNodeTSNamespaceExportDeclaration extends BabelNode { - type: "TSNamespaceExportDeclaration"; - id: BabelNodeIdentifier; -} - -declare class BabelNodeTSTypeAnnotation extends BabelNode { - type: "TSTypeAnnotation"; - typeAnnotation: BabelNodeTSType; -} - -declare class BabelNodeTSTypeParameterInstantiation extends BabelNode { - type: "TSTypeParameterInstantiation"; - params: Array; -} - -declare class BabelNodeTSTypeParameterDeclaration extends BabelNode { - type: "TSTypeParameterDeclaration"; - params: Array; -} - -declare class BabelNodeTSTypeParameter extends BabelNode { - type: "TSTypeParameter"; - constraint?: BabelNodeTSType; - name: string; - out?: boolean; -} - -type BabelNodeStandardized = BabelNodeArrayExpression | BabelNodeAssignmentExpression | BabelNodeBinaryExpression | BabelNodeInterpreterDirective | BabelNodeDirective | BabelNodeDirectiveLiteral | BabelNodeBlockStatement | BabelNodeBreakStatement | BabelNodeCallExpression | BabelNodeCatchClause | BabelNodeConditionalExpression | BabelNodeContinueStatement | BabelNodeDebuggerStatement | BabelNodeDoWhileStatement | BabelNodeEmptyStatement | BabelNodeExpressionStatement | BabelNodeFile | BabelNodeForInStatement | BabelNodeForStatement | BabelNodeFunctionDeclaration | BabelNodeFunctionExpression | BabelNodeIdentifier | BabelNodeIfStatement | BabelNodeLabeledStatement | BabelNodeStringLiteral | BabelNodeNumericLiteral | BabelNodeNullLiteral | BabelNodeBooleanLiteral | BabelNodeRegExpLiteral | BabelNodeLogicalExpression | BabelNodeMemberExpression | BabelNodeNewExpression | BabelNodeProgram | BabelNodeObjectExpression | BabelNodeObjectMethod | BabelNodeObjectProperty | BabelNodeRestElement | BabelNodeReturnStatement | BabelNodeSequenceExpression | BabelNodeParenthesizedExpression | BabelNodeSwitchCase | BabelNodeSwitchStatement | BabelNodeThisExpression | BabelNodeThrowStatement | BabelNodeTryStatement | BabelNodeUnaryExpression | BabelNodeUpdateExpression | BabelNodeVariableDeclaration | BabelNodeVariableDeclarator | BabelNodeWhileStatement | BabelNodeWithStatement | BabelNodeAssignmentPattern | BabelNodeArrayPattern | BabelNodeArrowFunctionExpression | BabelNodeClassBody | BabelNodeClassExpression | BabelNodeClassDeclaration | BabelNodeExportAllDeclaration | BabelNodeExportDefaultDeclaration | BabelNodeExportNamedDeclaration | BabelNodeExportSpecifier | BabelNodeForOfStatement | BabelNodeImportDeclaration | BabelNodeImportDefaultSpecifier | BabelNodeImportNamespaceSpecifier | BabelNodeImportSpecifier | BabelNodeImportExpression | BabelNodeMetaProperty | BabelNodeClassMethod | BabelNodeObjectPattern | BabelNodeSpreadElement | BabelNodeSuper | BabelNodeTaggedTemplateExpression | BabelNodeTemplateElement | BabelNodeTemplateLiteral | BabelNodeYieldExpression | BabelNodeAwaitExpression | BabelNodeImport | BabelNodeBigIntLiteral | BabelNodeExportNamespaceSpecifier | BabelNodeOptionalMemberExpression | BabelNodeOptionalCallExpression | BabelNodeClassProperty | BabelNodeClassAccessorProperty | BabelNodeClassPrivateProperty | BabelNodeClassPrivateMethod | BabelNodePrivateName | BabelNodeStaticBlock; -type BabelNodeExpression = BabelNodeArrayExpression | BabelNodeAssignmentExpression | BabelNodeBinaryExpression | BabelNodeCallExpression | BabelNodeConditionalExpression | BabelNodeFunctionExpression | BabelNodeIdentifier | BabelNodeStringLiteral | BabelNodeNumericLiteral | BabelNodeNullLiteral | BabelNodeBooleanLiteral | BabelNodeRegExpLiteral | BabelNodeLogicalExpression | BabelNodeMemberExpression | BabelNodeNewExpression | BabelNodeObjectExpression | BabelNodeSequenceExpression | BabelNodeParenthesizedExpression | BabelNodeThisExpression | BabelNodeUnaryExpression | BabelNodeUpdateExpression | BabelNodeArrowFunctionExpression | BabelNodeClassExpression | BabelNodeImportExpression | BabelNodeMetaProperty | BabelNodeSuper | BabelNodeTaggedTemplateExpression | BabelNodeTemplateLiteral | BabelNodeYieldExpression | BabelNodeAwaitExpression | BabelNodeImport | BabelNodeBigIntLiteral | BabelNodeOptionalMemberExpression | BabelNodeOptionalCallExpression | BabelNodeTypeCastExpression | BabelNodeJSXElement | BabelNodeJSXFragment | BabelNodeBindExpression | BabelNodeDoExpression | BabelNodeRecordExpression | BabelNodeTupleExpression | BabelNodeDecimalLiteral | BabelNodeModuleExpression | BabelNodeTopicReference | BabelNodePipelineTopicExpression | BabelNodePipelineBareFunction | BabelNodePipelinePrimaryTopicReference | BabelNodeTSInstantiationExpression | BabelNodeTSAsExpression | BabelNodeTSSatisfiesExpression | BabelNodeTSTypeAssertion | BabelNodeTSNonNullExpression; -type BabelNodeBinary = BabelNodeBinaryExpression | BabelNodeLogicalExpression; -type BabelNodeScopable = BabelNodeBlockStatement | BabelNodeCatchClause | BabelNodeDoWhileStatement | BabelNodeForInStatement | BabelNodeForStatement | BabelNodeFunctionDeclaration | BabelNodeFunctionExpression | BabelNodeProgram | BabelNodeObjectMethod | BabelNodeSwitchStatement | BabelNodeWhileStatement | BabelNodeArrowFunctionExpression | BabelNodeClassExpression | BabelNodeClassDeclaration | BabelNodeForOfStatement | BabelNodeClassMethod | BabelNodeClassPrivateMethod | BabelNodeStaticBlock | BabelNodeTSModuleBlock; -type BabelNodeBlockParent = BabelNodeBlockStatement | BabelNodeCatchClause | BabelNodeDoWhileStatement | BabelNodeForInStatement | BabelNodeForStatement | BabelNodeFunctionDeclaration | BabelNodeFunctionExpression | BabelNodeProgram | BabelNodeObjectMethod | BabelNodeSwitchStatement | BabelNodeWhileStatement | BabelNodeArrowFunctionExpression | BabelNodeForOfStatement | BabelNodeClassMethod | BabelNodeClassPrivateMethod | BabelNodeStaticBlock | BabelNodeTSModuleBlock; -type BabelNodeBlock = BabelNodeBlockStatement | BabelNodeProgram | BabelNodeTSModuleBlock; -type BabelNodeStatement = BabelNodeBlockStatement | BabelNodeBreakStatement | BabelNodeContinueStatement | BabelNodeDebuggerStatement | BabelNodeDoWhileStatement | BabelNodeEmptyStatement | BabelNodeExpressionStatement | BabelNodeForInStatement | BabelNodeForStatement | BabelNodeFunctionDeclaration | BabelNodeIfStatement | BabelNodeLabeledStatement | BabelNodeReturnStatement | BabelNodeSwitchStatement | BabelNodeThrowStatement | BabelNodeTryStatement | BabelNodeVariableDeclaration | BabelNodeWhileStatement | BabelNodeWithStatement | BabelNodeClassDeclaration | BabelNodeExportAllDeclaration | BabelNodeExportDefaultDeclaration | BabelNodeExportNamedDeclaration | BabelNodeForOfStatement | BabelNodeImportDeclaration | BabelNodeDeclareClass | BabelNodeDeclareFunction | BabelNodeDeclareInterface | BabelNodeDeclareModule | BabelNodeDeclareModuleExports | BabelNodeDeclareTypeAlias | BabelNodeDeclareOpaqueType | BabelNodeDeclareVariable | BabelNodeDeclareExportDeclaration | BabelNodeDeclareExportAllDeclaration | BabelNodeInterfaceDeclaration | BabelNodeOpaqueType | BabelNodeTypeAlias | BabelNodeEnumDeclaration | BabelNodeTSDeclareFunction | BabelNodeTSInterfaceDeclaration | BabelNodeTSTypeAliasDeclaration | BabelNodeTSEnumDeclaration | BabelNodeTSModuleDeclaration | BabelNodeTSImportEqualsDeclaration | BabelNodeTSExportAssignment | BabelNodeTSNamespaceExportDeclaration; -type BabelNodeTerminatorless = BabelNodeBreakStatement | BabelNodeContinueStatement | BabelNodeReturnStatement | BabelNodeThrowStatement | BabelNodeYieldExpression | BabelNodeAwaitExpression; -type BabelNodeCompletionStatement = BabelNodeBreakStatement | BabelNodeContinueStatement | BabelNodeReturnStatement | BabelNodeThrowStatement; -type BabelNodeConditional = BabelNodeConditionalExpression | BabelNodeIfStatement; -type BabelNodeLoop = BabelNodeDoWhileStatement | BabelNodeForInStatement | BabelNodeForStatement | BabelNodeWhileStatement | BabelNodeForOfStatement; -type BabelNodeWhile = BabelNodeDoWhileStatement | BabelNodeWhileStatement; -type BabelNodeExpressionWrapper = BabelNodeExpressionStatement | BabelNodeParenthesizedExpression | BabelNodeTypeCastExpression; -type BabelNodeFor = BabelNodeForInStatement | BabelNodeForStatement | BabelNodeForOfStatement; -type BabelNodeForXStatement = BabelNodeForInStatement | BabelNodeForOfStatement; -type BabelNodeFunction = BabelNodeFunctionDeclaration | BabelNodeFunctionExpression | BabelNodeObjectMethod | BabelNodeArrowFunctionExpression | BabelNodeClassMethod | BabelNodeClassPrivateMethod; -type BabelNodeFunctionParent = BabelNodeFunctionDeclaration | BabelNodeFunctionExpression | BabelNodeObjectMethod | BabelNodeArrowFunctionExpression | BabelNodeClassMethod | BabelNodeClassPrivateMethod | BabelNodeStaticBlock | BabelNodeTSModuleBlock; -type BabelNodePureish = BabelNodeFunctionDeclaration | BabelNodeFunctionExpression | BabelNodeStringLiteral | BabelNodeNumericLiteral | BabelNodeNullLiteral | BabelNodeBooleanLiteral | BabelNodeRegExpLiteral | BabelNodeArrowFunctionExpression | BabelNodeBigIntLiteral | BabelNodeDecimalLiteral; -type BabelNodeDeclaration = BabelNodeFunctionDeclaration | BabelNodeVariableDeclaration | BabelNodeClassDeclaration | BabelNodeExportAllDeclaration | BabelNodeExportDefaultDeclaration | BabelNodeExportNamedDeclaration | BabelNodeImportDeclaration | BabelNodeDeclareClass | BabelNodeDeclareFunction | BabelNodeDeclareInterface | BabelNodeDeclareModule | BabelNodeDeclareModuleExports | BabelNodeDeclareTypeAlias | BabelNodeDeclareOpaqueType | BabelNodeDeclareVariable | BabelNodeDeclareExportDeclaration | BabelNodeDeclareExportAllDeclaration | BabelNodeInterfaceDeclaration | BabelNodeOpaqueType | BabelNodeTypeAlias | BabelNodeEnumDeclaration | BabelNodeTSDeclareFunction | BabelNodeTSInterfaceDeclaration | BabelNodeTSTypeAliasDeclaration | BabelNodeTSEnumDeclaration | BabelNodeTSModuleDeclaration; -type BabelNodePatternLike = BabelNodeIdentifier | BabelNodeRestElement | BabelNodeAssignmentPattern | BabelNodeArrayPattern | BabelNodeObjectPattern | BabelNodeTSAsExpression | BabelNodeTSSatisfiesExpression | BabelNodeTSTypeAssertion | BabelNodeTSNonNullExpression; -type BabelNodeLVal = BabelNodeIdentifier | BabelNodeMemberExpression | BabelNodeRestElement | BabelNodeAssignmentPattern | BabelNodeArrayPattern | BabelNodeObjectPattern | BabelNodeTSParameterProperty | BabelNodeTSAsExpression | BabelNodeTSSatisfiesExpression | BabelNodeTSTypeAssertion | BabelNodeTSNonNullExpression; -type BabelNodeTSEntityName = BabelNodeIdentifier | BabelNodeTSQualifiedName; -type BabelNodeLiteral = BabelNodeStringLiteral | BabelNodeNumericLiteral | BabelNodeNullLiteral | BabelNodeBooleanLiteral | BabelNodeRegExpLiteral | BabelNodeTemplateLiteral | BabelNodeBigIntLiteral | BabelNodeDecimalLiteral; -type BabelNodeImmutable = BabelNodeStringLiteral | BabelNodeNumericLiteral | BabelNodeNullLiteral | BabelNodeBooleanLiteral | BabelNodeBigIntLiteral | BabelNodeJSXAttribute | BabelNodeJSXClosingElement | BabelNodeJSXElement | BabelNodeJSXExpressionContainer | BabelNodeJSXSpreadChild | BabelNodeJSXOpeningElement | BabelNodeJSXText | BabelNodeJSXFragment | BabelNodeJSXOpeningFragment | BabelNodeJSXClosingFragment | BabelNodeDecimalLiteral; -type BabelNodeUserWhitespacable = BabelNodeObjectMethod | BabelNodeObjectProperty | BabelNodeObjectTypeInternalSlot | BabelNodeObjectTypeCallProperty | BabelNodeObjectTypeIndexer | BabelNodeObjectTypeProperty | BabelNodeObjectTypeSpreadProperty; -type BabelNodeMethod = BabelNodeObjectMethod | BabelNodeClassMethod | BabelNodeClassPrivateMethod; -type BabelNodeObjectMember = BabelNodeObjectMethod | BabelNodeObjectProperty; -type BabelNodeProperty = BabelNodeObjectProperty | BabelNodeClassProperty | BabelNodeClassAccessorProperty | BabelNodeClassPrivateProperty; -type BabelNodeUnaryLike = BabelNodeUnaryExpression | BabelNodeSpreadElement; -type BabelNodePattern = BabelNodeAssignmentPattern | BabelNodeArrayPattern | BabelNodeObjectPattern; -type BabelNodeClass = BabelNodeClassExpression | BabelNodeClassDeclaration; -type BabelNodeImportOrExportDeclaration = BabelNodeExportAllDeclaration | BabelNodeExportDefaultDeclaration | BabelNodeExportNamedDeclaration | BabelNodeImportDeclaration; -type BabelNodeExportDeclaration = BabelNodeExportAllDeclaration | BabelNodeExportDefaultDeclaration | BabelNodeExportNamedDeclaration; -type BabelNodeModuleSpecifier = BabelNodeExportSpecifier | BabelNodeImportDefaultSpecifier | BabelNodeImportNamespaceSpecifier | BabelNodeImportSpecifier | BabelNodeExportNamespaceSpecifier | BabelNodeExportDefaultSpecifier; -type BabelNodeAccessor = BabelNodeClassAccessorProperty; -type BabelNodePrivate = BabelNodeClassPrivateProperty | BabelNodeClassPrivateMethod | BabelNodePrivateName; -type BabelNodeFlow = BabelNodeAnyTypeAnnotation | BabelNodeArrayTypeAnnotation | BabelNodeBooleanTypeAnnotation | BabelNodeBooleanLiteralTypeAnnotation | BabelNodeNullLiteralTypeAnnotation | BabelNodeClassImplements | BabelNodeDeclareClass | BabelNodeDeclareFunction | BabelNodeDeclareInterface | BabelNodeDeclareModule | BabelNodeDeclareModuleExports | BabelNodeDeclareTypeAlias | BabelNodeDeclareOpaqueType | BabelNodeDeclareVariable | BabelNodeDeclareExportDeclaration | BabelNodeDeclareExportAllDeclaration | BabelNodeDeclaredPredicate | BabelNodeExistsTypeAnnotation | BabelNodeFunctionTypeAnnotation | BabelNodeFunctionTypeParam | BabelNodeGenericTypeAnnotation | BabelNodeInferredPredicate | BabelNodeInterfaceExtends | BabelNodeInterfaceDeclaration | BabelNodeInterfaceTypeAnnotation | BabelNodeIntersectionTypeAnnotation | BabelNodeMixedTypeAnnotation | BabelNodeEmptyTypeAnnotation | BabelNodeNullableTypeAnnotation | BabelNodeNumberLiteralTypeAnnotation | BabelNodeNumberTypeAnnotation | BabelNodeObjectTypeAnnotation | BabelNodeObjectTypeInternalSlot | BabelNodeObjectTypeCallProperty | BabelNodeObjectTypeIndexer | BabelNodeObjectTypeProperty | BabelNodeObjectTypeSpreadProperty | BabelNodeOpaqueType | BabelNodeQualifiedTypeIdentifier | BabelNodeStringLiteralTypeAnnotation | BabelNodeStringTypeAnnotation | BabelNodeSymbolTypeAnnotation | BabelNodeThisTypeAnnotation | BabelNodeTupleTypeAnnotation | BabelNodeTypeofTypeAnnotation | BabelNodeTypeAlias | BabelNodeTypeAnnotation | BabelNodeTypeCastExpression | BabelNodeTypeParameter | BabelNodeTypeParameterDeclaration | BabelNodeTypeParameterInstantiation | BabelNodeUnionTypeAnnotation | BabelNodeVariance | BabelNodeVoidTypeAnnotation | BabelNodeEnumDeclaration | BabelNodeEnumBooleanBody | BabelNodeEnumNumberBody | BabelNodeEnumStringBody | BabelNodeEnumSymbolBody | BabelNodeEnumBooleanMember | BabelNodeEnumNumberMember | BabelNodeEnumStringMember | BabelNodeEnumDefaultedMember | BabelNodeIndexedAccessType | BabelNodeOptionalIndexedAccessType; -type BabelNodeFlowType = BabelNodeAnyTypeAnnotation | BabelNodeArrayTypeAnnotation | BabelNodeBooleanTypeAnnotation | BabelNodeBooleanLiteralTypeAnnotation | BabelNodeNullLiteralTypeAnnotation | BabelNodeExistsTypeAnnotation | BabelNodeFunctionTypeAnnotation | BabelNodeGenericTypeAnnotation | BabelNodeInterfaceTypeAnnotation | BabelNodeIntersectionTypeAnnotation | BabelNodeMixedTypeAnnotation | BabelNodeEmptyTypeAnnotation | BabelNodeNullableTypeAnnotation | BabelNodeNumberLiteralTypeAnnotation | BabelNodeNumberTypeAnnotation | BabelNodeObjectTypeAnnotation | BabelNodeStringLiteralTypeAnnotation | BabelNodeStringTypeAnnotation | BabelNodeSymbolTypeAnnotation | BabelNodeThisTypeAnnotation | BabelNodeTupleTypeAnnotation | BabelNodeTypeofTypeAnnotation | BabelNodeUnionTypeAnnotation | BabelNodeVoidTypeAnnotation | BabelNodeIndexedAccessType | BabelNodeOptionalIndexedAccessType; -type BabelNodeFlowBaseAnnotation = BabelNodeAnyTypeAnnotation | BabelNodeBooleanTypeAnnotation | BabelNodeNullLiteralTypeAnnotation | BabelNodeMixedTypeAnnotation | BabelNodeEmptyTypeAnnotation | BabelNodeNumberTypeAnnotation | BabelNodeStringTypeAnnotation | BabelNodeSymbolTypeAnnotation | BabelNodeThisTypeAnnotation | BabelNodeVoidTypeAnnotation; -type BabelNodeFlowDeclaration = BabelNodeDeclareClass | BabelNodeDeclareFunction | BabelNodeDeclareInterface | BabelNodeDeclareModule | BabelNodeDeclareModuleExports | BabelNodeDeclareTypeAlias | BabelNodeDeclareOpaqueType | BabelNodeDeclareVariable | BabelNodeDeclareExportDeclaration | BabelNodeDeclareExportAllDeclaration | BabelNodeInterfaceDeclaration | BabelNodeOpaqueType | BabelNodeTypeAlias; -type BabelNodeFlowPredicate = BabelNodeDeclaredPredicate | BabelNodeInferredPredicate; -type BabelNodeEnumBody = BabelNodeEnumBooleanBody | BabelNodeEnumNumberBody | BabelNodeEnumStringBody | BabelNodeEnumSymbolBody; -type BabelNodeEnumMember = BabelNodeEnumBooleanMember | BabelNodeEnumNumberMember | BabelNodeEnumStringMember | BabelNodeEnumDefaultedMember; -type BabelNodeJSX = BabelNodeJSXAttribute | BabelNodeJSXClosingElement | BabelNodeJSXElement | BabelNodeJSXEmptyExpression | BabelNodeJSXExpressionContainer | BabelNodeJSXSpreadChild | BabelNodeJSXIdentifier | BabelNodeJSXMemberExpression | BabelNodeJSXNamespacedName | BabelNodeJSXOpeningElement | BabelNodeJSXSpreadAttribute | BabelNodeJSXText | BabelNodeJSXFragment | BabelNodeJSXOpeningFragment | BabelNodeJSXClosingFragment; -type BabelNodeMiscellaneous = BabelNodeNoop | BabelNodePlaceholder | BabelNodeV8IntrinsicIdentifier; -type BabelNodeTypeScript = BabelNodeTSParameterProperty | BabelNodeTSDeclareFunction | BabelNodeTSDeclareMethod | BabelNodeTSQualifiedName | BabelNodeTSCallSignatureDeclaration | BabelNodeTSConstructSignatureDeclaration | BabelNodeTSPropertySignature | BabelNodeTSMethodSignature | BabelNodeTSIndexSignature | BabelNodeTSAnyKeyword | BabelNodeTSBooleanKeyword | BabelNodeTSBigIntKeyword | BabelNodeTSIntrinsicKeyword | BabelNodeTSNeverKeyword | BabelNodeTSNullKeyword | BabelNodeTSNumberKeyword | BabelNodeTSObjectKeyword | BabelNodeTSStringKeyword | BabelNodeTSSymbolKeyword | BabelNodeTSUndefinedKeyword | BabelNodeTSUnknownKeyword | BabelNodeTSVoidKeyword | BabelNodeTSThisType | BabelNodeTSFunctionType | BabelNodeTSConstructorType | BabelNodeTSTypeReference | BabelNodeTSTypePredicate | BabelNodeTSTypeQuery | BabelNodeTSTypeLiteral | BabelNodeTSArrayType | BabelNodeTSTupleType | BabelNodeTSOptionalType | BabelNodeTSRestType | BabelNodeTSNamedTupleMember | BabelNodeTSUnionType | BabelNodeTSIntersectionType | BabelNodeTSConditionalType | BabelNodeTSInferType | BabelNodeTSParenthesizedType | BabelNodeTSTypeOperator | BabelNodeTSIndexedAccessType | BabelNodeTSMappedType | BabelNodeTSLiteralType | BabelNodeTSExpressionWithTypeArguments | BabelNodeTSInterfaceDeclaration | BabelNodeTSInterfaceBody | BabelNodeTSTypeAliasDeclaration | BabelNodeTSInstantiationExpression | BabelNodeTSAsExpression | BabelNodeTSSatisfiesExpression | BabelNodeTSTypeAssertion | BabelNodeTSEnumDeclaration | BabelNodeTSEnumMember | BabelNodeTSModuleDeclaration | BabelNodeTSModuleBlock | BabelNodeTSImportType | BabelNodeTSImportEqualsDeclaration | BabelNodeTSExternalModuleReference | BabelNodeTSNonNullExpression | BabelNodeTSExportAssignment | BabelNodeTSNamespaceExportDeclaration | BabelNodeTSTypeAnnotation | BabelNodeTSTypeParameterInstantiation | BabelNodeTSTypeParameterDeclaration | BabelNodeTSTypeParameter; -type BabelNodeTSTypeElement = BabelNodeTSCallSignatureDeclaration | BabelNodeTSConstructSignatureDeclaration | BabelNodeTSPropertySignature | BabelNodeTSMethodSignature | BabelNodeTSIndexSignature; -type BabelNodeTSType = BabelNodeTSAnyKeyword | BabelNodeTSBooleanKeyword | BabelNodeTSBigIntKeyword | BabelNodeTSIntrinsicKeyword | BabelNodeTSNeverKeyword | BabelNodeTSNullKeyword | BabelNodeTSNumberKeyword | BabelNodeTSObjectKeyword | BabelNodeTSStringKeyword | BabelNodeTSSymbolKeyword | BabelNodeTSUndefinedKeyword | BabelNodeTSUnknownKeyword | BabelNodeTSVoidKeyword | BabelNodeTSThisType | BabelNodeTSFunctionType | BabelNodeTSConstructorType | BabelNodeTSTypeReference | BabelNodeTSTypePredicate | BabelNodeTSTypeQuery | BabelNodeTSTypeLiteral | BabelNodeTSArrayType | BabelNodeTSTupleType | BabelNodeTSOptionalType | BabelNodeTSRestType | BabelNodeTSUnionType | BabelNodeTSIntersectionType | BabelNodeTSConditionalType | BabelNodeTSInferType | BabelNodeTSParenthesizedType | BabelNodeTSTypeOperator | BabelNodeTSIndexedAccessType | BabelNodeTSMappedType | BabelNodeTSLiteralType | BabelNodeTSExpressionWithTypeArguments | BabelNodeTSImportType; -type BabelNodeTSBaseType = BabelNodeTSAnyKeyword | BabelNodeTSBooleanKeyword | BabelNodeTSBigIntKeyword | BabelNodeTSIntrinsicKeyword | BabelNodeTSNeverKeyword | BabelNodeTSNullKeyword | BabelNodeTSNumberKeyword | BabelNodeTSObjectKeyword | BabelNodeTSStringKeyword | BabelNodeTSSymbolKeyword | BabelNodeTSUndefinedKeyword | BabelNodeTSUnknownKeyword | BabelNodeTSVoidKeyword | BabelNodeTSThisType | BabelNodeTSLiteralType; -type BabelNodeModuleDeclaration = BabelNodeExportAllDeclaration | BabelNodeExportDefaultDeclaration | BabelNodeExportNamedDeclaration | BabelNodeImportDeclaration; - -declare module "@babel/types" { - declare export function arrayExpression(elements?: Array): BabelNodeArrayExpression; - declare export function assignmentExpression(operator: string, left: BabelNodeLVal | BabelNodeOptionalMemberExpression, right: BabelNodeExpression): BabelNodeAssignmentExpression; - declare export function binaryExpression(operator: "+" | "-" | "/" | "%" | "*" | "**" | "&" | "|" | ">>" | ">>>" | "<<" | "^" | "==" | "===" | "!=" | "!==" | "in" | "instanceof" | ">" | "<" | ">=" | "<=" | "|>", left: BabelNodeExpression | BabelNodePrivateName, right: BabelNodeExpression): BabelNodeBinaryExpression; - declare export function interpreterDirective(value: string): BabelNodeInterpreterDirective; - declare export function directive(value: BabelNodeDirectiveLiteral): BabelNodeDirective; - declare export function directiveLiteral(value: string): BabelNodeDirectiveLiteral; - declare export function blockStatement(body: Array, directives?: Array): BabelNodeBlockStatement; - declare export function breakStatement(label?: BabelNodeIdentifier): BabelNodeBreakStatement; - declare export function callExpression(callee: BabelNodeExpression | BabelNodeSuper | BabelNodeV8IntrinsicIdentifier, _arguments: Array): BabelNodeCallExpression; - declare export function catchClause(param?: BabelNodeIdentifier | BabelNodeArrayPattern | BabelNodeObjectPattern, body: BabelNodeBlockStatement): BabelNodeCatchClause; - declare export function conditionalExpression(test: BabelNodeExpression, consequent: BabelNodeExpression, alternate: BabelNodeExpression): BabelNodeConditionalExpression; - declare export function continueStatement(label?: BabelNodeIdentifier): BabelNodeContinueStatement; - declare export function debuggerStatement(): BabelNodeDebuggerStatement; - declare export function doWhileStatement(test: BabelNodeExpression, body: BabelNodeStatement): BabelNodeDoWhileStatement; - declare export function emptyStatement(): BabelNodeEmptyStatement; - declare export function expressionStatement(expression: BabelNodeExpression): BabelNodeExpressionStatement; - declare export function file(program: BabelNodeProgram, comments?: Array, tokens?: Array): BabelNodeFile; - declare export function forInStatement(left: BabelNodeVariableDeclaration | BabelNodeLVal, right: BabelNodeExpression, body: BabelNodeStatement): BabelNodeForInStatement; - declare export function forStatement(init?: BabelNodeVariableDeclaration | BabelNodeExpression, test?: BabelNodeExpression, update?: BabelNodeExpression, body: BabelNodeStatement): BabelNodeForStatement; - declare export function functionDeclaration(id?: BabelNodeIdentifier, params: Array, body: BabelNodeBlockStatement, generator?: boolean, async?: boolean): BabelNodeFunctionDeclaration; - declare export function functionExpression(id?: BabelNodeIdentifier, params: Array, body: BabelNodeBlockStatement, generator?: boolean, async?: boolean): BabelNodeFunctionExpression; - declare export function identifier(name: string): BabelNodeIdentifier; - declare export function ifStatement(test: BabelNodeExpression, consequent: BabelNodeStatement, alternate?: BabelNodeStatement): BabelNodeIfStatement; - declare export function labeledStatement(label: BabelNodeIdentifier, body: BabelNodeStatement): BabelNodeLabeledStatement; - declare export function stringLiteral(value: string): BabelNodeStringLiteral; - declare export function numericLiteral(value: number): BabelNodeNumericLiteral; - declare export function nullLiteral(): BabelNodeNullLiteral; - declare export function booleanLiteral(value: boolean): BabelNodeBooleanLiteral; - declare export function regExpLiteral(pattern: string, flags?: string): BabelNodeRegExpLiteral; - declare export function logicalExpression(operator: "||" | "&&" | "??", left: BabelNodeExpression, right: BabelNodeExpression): BabelNodeLogicalExpression; - declare export function memberExpression(object: BabelNodeExpression | BabelNodeSuper, property: BabelNodeExpression | BabelNodeIdentifier | BabelNodePrivateName, computed?: boolean, optional?: true | false): BabelNodeMemberExpression; - declare export function newExpression(callee: BabelNodeExpression | BabelNodeSuper | BabelNodeV8IntrinsicIdentifier, _arguments: Array): BabelNodeNewExpression; - declare export function program(body: Array, directives?: Array, sourceType?: "script" | "module", interpreter?: BabelNodeInterpreterDirective): BabelNodeProgram; - declare export function objectExpression(properties: Array): BabelNodeObjectExpression; - declare export function objectMethod(kind?: "method" | "get" | "set", key: BabelNodeExpression | BabelNodeIdentifier | BabelNodeStringLiteral | BabelNodeNumericLiteral | BabelNodeBigIntLiteral, params: Array, body: BabelNodeBlockStatement, computed?: boolean, generator?: boolean, async?: boolean): BabelNodeObjectMethod; - declare export function objectProperty(key: BabelNodeExpression | BabelNodeIdentifier | BabelNodeStringLiteral | BabelNodeNumericLiteral | BabelNodeBigIntLiteral | BabelNodeDecimalLiteral | BabelNodePrivateName, value: BabelNodeExpression | BabelNodePatternLike, computed?: boolean, shorthand?: boolean, decorators?: Array): BabelNodeObjectProperty; - declare export function restElement(argument: BabelNodeLVal): BabelNodeRestElement; - declare export function returnStatement(argument?: BabelNodeExpression): BabelNodeReturnStatement; - declare export function sequenceExpression(expressions: Array): BabelNodeSequenceExpression; - declare export function parenthesizedExpression(expression: BabelNodeExpression): BabelNodeParenthesizedExpression; - declare export function switchCase(test?: BabelNodeExpression, consequent: Array): BabelNodeSwitchCase; - declare export function switchStatement(discriminant: BabelNodeExpression, cases: Array): BabelNodeSwitchStatement; - declare export function thisExpression(): BabelNodeThisExpression; - declare export function throwStatement(argument: BabelNodeExpression): BabelNodeThrowStatement; - declare export function tryStatement(block: BabelNodeBlockStatement, handler?: BabelNodeCatchClause, finalizer?: BabelNodeBlockStatement): BabelNodeTryStatement; - declare export function unaryExpression(operator: "void" | "throw" | "delete" | "!" | "+" | "-" | "~" | "typeof", argument: BabelNodeExpression, prefix?: boolean): BabelNodeUnaryExpression; - declare export function updateExpression(operator: "++" | "--", argument: BabelNodeExpression, prefix?: boolean): BabelNodeUpdateExpression; - declare export function variableDeclaration(kind: "var" | "let" | "const" | "using" | "await using", declarations: Array): BabelNodeVariableDeclaration; - declare export function variableDeclarator(id: BabelNodeLVal, init?: BabelNodeExpression): BabelNodeVariableDeclarator; - declare export function whileStatement(test: BabelNodeExpression, body: BabelNodeStatement): BabelNodeWhileStatement; - declare export function withStatement(object: BabelNodeExpression, body: BabelNodeStatement): BabelNodeWithStatement; - declare export function assignmentPattern(left: BabelNodeIdentifier | BabelNodeObjectPattern | BabelNodeArrayPattern | BabelNodeMemberExpression | BabelNodeTSAsExpression | BabelNodeTSSatisfiesExpression | BabelNodeTSTypeAssertion | BabelNodeTSNonNullExpression, right: BabelNodeExpression): BabelNodeAssignmentPattern; - declare export function arrayPattern(elements: Array): BabelNodeArrayPattern; - declare export function arrowFunctionExpression(params: Array, body: BabelNodeBlockStatement | BabelNodeExpression, async?: boolean): BabelNodeArrowFunctionExpression; - declare export function classBody(body: Array): BabelNodeClassBody; - declare export function classExpression(id?: BabelNodeIdentifier, superClass?: BabelNodeExpression, body: BabelNodeClassBody, decorators?: Array): BabelNodeClassExpression; - declare export function classDeclaration(id?: BabelNodeIdentifier, superClass?: BabelNodeExpression, body: BabelNodeClassBody, decorators?: Array): BabelNodeClassDeclaration; - declare export function exportAllDeclaration(source: BabelNodeStringLiteral): BabelNodeExportAllDeclaration; - declare export function exportDefaultDeclaration(declaration: BabelNodeTSDeclareFunction | BabelNodeFunctionDeclaration | BabelNodeClassDeclaration | BabelNodeExpression): BabelNodeExportDefaultDeclaration; - declare export function exportNamedDeclaration(declaration?: BabelNodeDeclaration, specifiers?: Array, source?: BabelNodeStringLiteral): BabelNodeExportNamedDeclaration; - declare export function exportSpecifier(local: BabelNodeIdentifier, exported: BabelNodeIdentifier | BabelNodeStringLiteral): BabelNodeExportSpecifier; - declare export function forOfStatement(left: BabelNodeVariableDeclaration | BabelNodeLVal, right: BabelNodeExpression, body: BabelNodeStatement, _await?: boolean): BabelNodeForOfStatement; - declare export function importDeclaration(specifiers: Array, source: BabelNodeStringLiteral): BabelNodeImportDeclaration; - declare export function importDefaultSpecifier(local: BabelNodeIdentifier): BabelNodeImportDefaultSpecifier; - declare export function importNamespaceSpecifier(local: BabelNodeIdentifier): BabelNodeImportNamespaceSpecifier; - declare export function importSpecifier(local: BabelNodeIdentifier, imported: BabelNodeIdentifier | BabelNodeStringLiteral): BabelNodeImportSpecifier; - declare export function importExpression(source: BabelNodeExpression, options?: BabelNodeExpression): BabelNodeImportExpression; - declare export function metaProperty(meta: BabelNodeIdentifier, property: BabelNodeIdentifier): BabelNodeMetaProperty; - declare export function classMethod(kind?: "get" | "set" | "method" | "constructor", key: BabelNodeIdentifier | BabelNodeStringLiteral | BabelNodeNumericLiteral | BabelNodeBigIntLiteral | BabelNodeExpression, params: Array, body: BabelNodeBlockStatement, computed?: boolean, _static?: boolean, generator?: boolean, async?: boolean): BabelNodeClassMethod; - declare export function objectPattern(properties: Array): BabelNodeObjectPattern; - declare export function spreadElement(argument: BabelNodeExpression): BabelNodeSpreadElement; - declare function _super(): BabelNodeSuper; - declare export { _super as super } - declare export function taggedTemplateExpression(tag: BabelNodeExpression, quasi: BabelNodeTemplateLiteral): BabelNodeTaggedTemplateExpression; - declare export function templateElement(value: { raw: string, cooked?: string }, tail?: boolean): BabelNodeTemplateElement; - declare export function templateLiteral(quasis: Array, expressions: Array): BabelNodeTemplateLiteral; - declare export function yieldExpression(argument?: BabelNodeExpression, delegate?: boolean): BabelNodeYieldExpression; - declare export function awaitExpression(argument: BabelNodeExpression): BabelNodeAwaitExpression; - declare function _import(): BabelNodeImport; - declare export { _import as import } - declare export function bigIntLiteral(value: string): BabelNodeBigIntLiteral; - declare export function exportNamespaceSpecifier(exported: BabelNodeIdentifier): BabelNodeExportNamespaceSpecifier; - declare export function optionalMemberExpression(object: BabelNodeExpression, property: BabelNodeExpression | BabelNodeIdentifier, computed?: boolean, optional: boolean): BabelNodeOptionalMemberExpression; - declare export function optionalCallExpression(callee: BabelNodeExpression, _arguments: Array, optional: boolean): BabelNodeOptionalCallExpression; - declare export function classProperty(key: BabelNodeIdentifier | BabelNodeStringLiteral | BabelNodeNumericLiteral | BabelNodeBigIntLiteral | BabelNodeExpression, value?: BabelNodeExpression, typeAnnotation?: BabelNodeTypeAnnotation | BabelNodeTSTypeAnnotation | BabelNodeNoop, decorators?: Array, computed?: boolean, _static?: boolean): BabelNodeClassProperty; - declare export function classAccessorProperty(key: BabelNodeIdentifier | BabelNodeStringLiteral | BabelNodeNumericLiteral | BabelNodeBigIntLiteral | BabelNodeExpression | BabelNodePrivateName, value?: BabelNodeExpression, typeAnnotation?: BabelNodeTypeAnnotation | BabelNodeTSTypeAnnotation | BabelNodeNoop, decorators?: Array, computed?: boolean, _static?: boolean): BabelNodeClassAccessorProperty; - declare export function classPrivateProperty(key: BabelNodePrivateName, value?: BabelNodeExpression, decorators?: Array, _static?: boolean): BabelNodeClassPrivateProperty; - declare export function classPrivateMethod(kind?: "get" | "set" | "method", key: BabelNodePrivateName, params: Array, body: BabelNodeBlockStatement, _static?: boolean): BabelNodeClassPrivateMethod; - declare export function privateName(id: BabelNodeIdentifier): BabelNodePrivateName; - declare export function staticBlock(body: Array): BabelNodeStaticBlock; - declare export function anyTypeAnnotation(): BabelNodeAnyTypeAnnotation; - declare export function arrayTypeAnnotation(elementType: BabelNodeFlowType): BabelNodeArrayTypeAnnotation; - declare export function booleanTypeAnnotation(): BabelNodeBooleanTypeAnnotation; - declare export function booleanLiteralTypeAnnotation(value: boolean): BabelNodeBooleanLiteralTypeAnnotation; - declare export function nullLiteralTypeAnnotation(): BabelNodeNullLiteralTypeAnnotation; - declare export function classImplements(id: BabelNodeIdentifier, typeParameters?: BabelNodeTypeParameterInstantiation): BabelNodeClassImplements; - declare export function declareClass(id: BabelNodeIdentifier, typeParameters?: BabelNodeTypeParameterDeclaration, _extends?: Array, body: BabelNodeObjectTypeAnnotation): BabelNodeDeclareClass; - declare export function declareFunction(id: BabelNodeIdentifier): BabelNodeDeclareFunction; - declare export function declareInterface(id: BabelNodeIdentifier, typeParameters?: BabelNodeTypeParameterDeclaration, _extends?: Array, body: BabelNodeObjectTypeAnnotation): BabelNodeDeclareInterface; - declare export function declareModule(id: BabelNodeIdentifier | BabelNodeStringLiteral, body: BabelNodeBlockStatement, kind?: "CommonJS" | "ES"): BabelNodeDeclareModule; - declare export function declareModuleExports(typeAnnotation: BabelNodeTypeAnnotation): BabelNodeDeclareModuleExports; - declare export function declareTypeAlias(id: BabelNodeIdentifier, typeParameters?: BabelNodeTypeParameterDeclaration, right: BabelNodeFlowType): BabelNodeDeclareTypeAlias; - declare export function declareOpaqueType(id: BabelNodeIdentifier, typeParameters?: BabelNodeTypeParameterDeclaration, supertype?: BabelNodeFlowType): BabelNodeDeclareOpaqueType; - declare export function declareVariable(id: BabelNodeIdentifier): BabelNodeDeclareVariable; - declare export function declareExportDeclaration(declaration?: BabelNodeFlow, specifiers?: Array, source?: BabelNodeStringLiteral): BabelNodeDeclareExportDeclaration; - declare export function declareExportAllDeclaration(source: BabelNodeStringLiteral): BabelNodeDeclareExportAllDeclaration; - declare export function declaredPredicate(value: BabelNodeFlow): BabelNodeDeclaredPredicate; - declare export function existsTypeAnnotation(): BabelNodeExistsTypeAnnotation; - declare export function functionTypeAnnotation(typeParameters?: BabelNodeTypeParameterDeclaration, params: Array, rest?: BabelNodeFunctionTypeParam, returnType: BabelNodeFlowType): BabelNodeFunctionTypeAnnotation; - declare export function functionTypeParam(name?: BabelNodeIdentifier, typeAnnotation: BabelNodeFlowType): BabelNodeFunctionTypeParam; - declare export function genericTypeAnnotation(id: BabelNodeIdentifier | BabelNodeQualifiedTypeIdentifier, typeParameters?: BabelNodeTypeParameterInstantiation): BabelNodeGenericTypeAnnotation; - declare export function inferredPredicate(): BabelNodeInferredPredicate; - declare export function interfaceExtends(id: BabelNodeIdentifier | BabelNodeQualifiedTypeIdentifier, typeParameters?: BabelNodeTypeParameterInstantiation): BabelNodeInterfaceExtends; - declare export function interfaceDeclaration(id: BabelNodeIdentifier, typeParameters?: BabelNodeTypeParameterDeclaration, _extends?: Array, body: BabelNodeObjectTypeAnnotation): BabelNodeInterfaceDeclaration; - declare export function interfaceTypeAnnotation(_extends?: Array, body: BabelNodeObjectTypeAnnotation): BabelNodeInterfaceTypeAnnotation; - declare export function intersectionTypeAnnotation(types: Array): BabelNodeIntersectionTypeAnnotation; - declare export function mixedTypeAnnotation(): BabelNodeMixedTypeAnnotation; - declare export function emptyTypeAnnotation(): BabelNodeEmptyTypeAnnotation; - declare export function nullableTypeAnnotation(typeAnnotation: BabelNodeFlowType): BabelNodeNullableTypeAnnotation; - declare export function numberLiteralTypeAnnotation(value: number): BabelNodeNumberLiteralTypeAnnotation; - declare export function numberTypeAnnotation(): BabelNodeNumberTypeAnnotation; - declare export function objectTypeAnnotation(properties: Array, indexers?: Array, callProperties?: Array, internalSlots?: Array, exact?: boolean): BabelNodeObjectTypeAnnotation; - declare export function objectTypeInternalSlot(id: BabelNodeIdentifier, value: BabelNodeFlowType, optional: boolean, _static: boolean, method: boolean): BabelNodeObjectTypeInternalSlot; - declare export function objectTypeCallProperty(value: BabelNodeFlowType): BabelNodeObjectTypeCallProperty; - declare export function objectTypeIndexer(id?: BabelNodeIdentifier, key: BabelNodeFlowType, value: BabelNodeFlowType, variance?: BabelNodeVariance): BabelNodeObjectTypeIndexer; - declare export function objectTypeProperty(key: BabelNodeIdentifier | BabelNodeStringLiteral, value: BabelNodeFlowType, variance?: BabelNodeVariance): BabelNodeObjectTypeProperty; - declare export function objectTypeSpreadProperty(argument: BabelNodeFlowType): BabelNodeObjectTypeSpreadProperty; - declare export function opaqueType(id: BabelNodeIdentifier, typeParameters?: BabelNodeTypeParameterDeclaration, supertype?: BabelNodeFlowType, impltype: BabelNodeFlowType): BabelNodeOpaqueType; - declare export function qualifiedTypeIdentifier(id: BabelNodeIdentifier, qualification: BabelNodeIdentifier | BabelNodeQualifiedTypeIdentifier): BabelNodeQualifiedTypeIdentifier; - declare export function stringLiteralTypeAnnotation(value: string): BabelNodeStringLiteralTypeAnnotation; - declare export function stringTypeAnnotation(): BabelNodeStringTypeAnnotation; - declare export function symbolTypeAnnotation(): BabelNodeSymbolTypeAnnotation; - declare export function thisTypeAnnotation(): BabelNodeThisTypeAnnotation; - declare export function tupleTypeAnnotation(types: Array): BabelNodeTupleTypeAnnotation; - declare export function typeofTypeAnnotation(argument: BabelNodeFlowType): BabelNodeTypeofTypeAnnotation; - declare export function typeAlias(id: BabelNodeIdentifier, typeParameters?: BabelNodeTypeParameterDeclaration, right: BabelNodeFlowType): BabelNodeTypeAlias; - declare export function typeAnnotation(typeAnnotation: BabelNodeFlowType): BabelNodeTypeAnnotation; - declare export function typeCastExpression(expression: BabelNodeExpression, typeAnnotation: BabelNodeTypeAnnotation): BabelNodeTypeCastExpression; - declare export function typeParameter(bound?: BabelNodeTypeAnnotation, _default?: BabelNodeFlowType, variance?: BabelNodeVariance): BabelNodeTypeParameter; - declare export function typeParameterDeclaration(params: Array): BabelNodeTypeParameterDeclaration; - declare export function typeParameterInstantiation(params: Array): BabelNodeTypeParameterInstantiation; - declare export function unionTypeAnnotation(types: Array): BabelNodeUnionTypeAnnotation; - declare export function variance(kind: "minus" | "plus"): BabelNodeVariance; - declare export function voidTypeAnnotation(): BabelNodeVoidTypeAnnotation; - declare export function enumDeclaration(id: BabelNodeIdentifier, body: BabelNodeEnumBooleanBody | BabelNodeEnumNumberBody | BabelNodeEnumStringBody | BabelNodeEnumSymbolBody): BabelNodeEnumDeclaration; - declare export function enumBooleanBody(members: Array): BabelNodeEnumBooleanBody; - declare export function enumNumberBody(members: Array): BabelNodeEnumNumberBody; - declare export function enumStringBody(members: Array): BabelNodeEnumStringBody; - declare export function enumSymbolBody(members: Array): BabelNodeEnumSymbolBody; - declare export function enumBooleanMember(id: BabelNodeIdentifier): BabelNodeEnumBooleanMember; - declare export function enumNumberMember(id: BabelNodeIdentifier, init: BabelNodeNumericLiteral): BabelNodeEnumNumberMember; - declare export function enumStringMember(id: BabelNodeIdentifier, init: BabelNodeStringLiteral): BabelNodeEnumStringMember; - declare export function enumDefaultedMember(id: BabelNodeIdentifier): BabelNodeEnumDefaultedMember; - declare export function indexedAccessType(objectType: BabelNodeFlowType, indexType: BabelNodeFlowType): BabelNodeIndexedAccessType; - declare export function optionalIndexedAccessType(objectType: BabelNodeFlowType, indexType: BabelNodeFlowType): BabelNodeOptionalIndexedAccessType; - declare export function jsxAttribute(name: BabelNodeJSXIdentifier | BabelNodeJSXNamespacedName, value?: BabelNodeJSXElement | BabelNodeJSXFragment | BabelNodeStringLiteral | BabelNodeJSXExpressionContainer): BabelNodeJSXAttribute; - declare export function jsxClosingElement(name: BabelNodeJSXIdentifier | BabelNodeJSXMemberExpression | BabelNodeJSXNamespacedName): BabelNodeJSXClosingElement; - declare export function jsxElement(openingElement: BabelNodeJSXOpeningElement, closingElement?: BabelNodeJSXClosingElement, children: Array, selfClosing?: boolean): BabelNodeJSXElement; - declare export function jsxEmptyExpression(): BabelNodeJSXEmptyExpression; - declare export function jsxExpressionContainer(expression: BabelNodeExpression | BabelNodeJSXEmptyExpression): BabelNodeJSXExpressionContainer; - declare export function jsxSpreadChild(expression: BabelNodeExpression): BabelNodeJSXSpreadChild; - declare export function jsxIdentifier(name: string): BabelNodeJSXIdentifier; - declare export function jsxMemberExpression(object: BabelNodeJSXMemberExpression | BabelNodeJSXIdentifier, property: BabelNodeJSXIdentifier): BabelNodeJSXMemberExpression; - declare export function jsxNamespacedName(namespace: BabelNodeJSXIdentifier, name: BabelNodeJSXIdentifier): BabelNodeJSXNamespacedName; - declare export function jsxOpeningElement(name: BabelNodeJSXIdentifier | BabelNodeJSXMemberExpression | BabelNodeJSXNamespacedName, attributes: Array, selfClosing?: boolean): BabelNodeJSXOpeningElement; - declare export function jsxSpreadAttribute(argument: BabelNodeExpression): BabelNodeJSXSpreadAttribute; - declare export function jsxText(value: string): BabelNodeJSXText; - declare export function jsxFragment(openingFragment: BabelNodeJSXOpeningFragment, closingFragment: BabelNodeJSXClosingFragment, children: Array): BabelNodeJSXFragment; - declare export function jsxOpeningFragment(): BabelNodeJSXOpeningFragment; - declare export function jsxClosingFragment(): BabelNodeJSXClosingFragment; - declare export function noop(): BabelNodeNoop; - declare export function placeholder(expectedNode: "Identifier" | "StringLiteral" | "Expression" | "Statement" | "Declaration" | "BlockStatement" | "ClassBody" | "Pattern", name: BabelNodeIdentifier): BabelNodePlaceholder; - declare export function v8IntrinsicIdentifier(name: string): BabelNodeV8IntrinsicIdentifier; - declare export function argumentPlaceholder(): BabelNodeArgumentPlaceholder; - declare export function bindExpression(object: BabelNodeExpression, callee: BabelNodeExpression): BabelNodeBindExpression; - declare export function importAttribute(key: BabelNodeIdentifier | BabelNodeStringLiteral, value: BabelNodeStringLiteral): BabelNodeImportAttribute; - declare export function decorator(expression: BabelNodeExpression): BabelNodeDecorator; - declare export function doExpression(body: BabelNodeBlockStatement, async?: boolean): BabelNodeDoExpression; - declare export function exportDefaultSpecifier(exported: BabelNodeIdentifier): BabelNodeExportDefaultSpecifier; - declare export function recordExpression(properties: Array): BabelNodeRecordExpression; - declare export function tupleExpression(elements?: Array): BabelNodeTupleExpression; - declare export function decimalLiteral(value: string): BabelNodeDecimalLiteral; - declare export function moduleExpression(body: BabelNodeProgram): BabelNodeModuleExpression; - declare export function topicReference(): BabelNodeTopicReference; - declare export function pipelineTopicExpression(expression: BabelNodeExpression): BabelNodePipelineTopicExpression; - declare export function pipelineBareFunction(callee: BabelNodeExpression): BabelNodePipelineBareFunction; - declare export function pipelinePrimaryTopicReference(): BabelNodePipelinePrimaryTopicReference; - declare export function tsParameterProperty(parameter: BabelNodeIdentifier | BabelNodeAssignmentPattern): BabelNodeTSParameterProperty; - declare export function tsDeclareFunction(id?: BabelNodeIdentifier, typeParameters?: BabelNodeTSTypeParameterDeclaration | BabelNodeNoop, params: Array, returnType?: BabelNodeTSTypeAnnotation | BabelNodeNoop): BabelNodeTSDeclareFunction; - declare export function tsDeclareMethod(decorators?: Array, key: BabelNodeIdentifier | BabelNodeStringLiteral | BabelNodeNumericLiteral | BabelNodeBigIntLiteral | BabelNodeExpression, typeParameters?: BabelNodeTSTypeParameterDeclaration | BabelNodeNoop, params: Array, returnType?: BabelNodeTSTypeAnnotation | BabelNodeNoop): BabelNodeTSDeclareMethod; - declare export function tsQualifiedName(left: BabelNodeTSEntityName, right: BabelNodeIdentifier): BabelNodeTSQualifiedName; - declare export function tsCallSignatureDeclaration(typeParameters?: BabelNodeTSTypeParameterDeclaration, parameters: Array, typeAnnotation?: BabelNodeTSTypeAnnotation): BabelNodeTSCallSignatureDeclaration; - declare export function tsConstructSignatureDeclaration(typeParameters?: BabelNodeTSTypeParameterDeclaration, parameters: Array, typeAnnotation?: BabelNodeTSTypeAnnotation): BabelNodeTSConstructSignatureDeclaration; - declare export function tsPropertySignature(key: BabelNodeExpression, typeAnnotation?: BabelNodeTSTypeAnnotation): BabelNodeTSPropertySignature; - declare export function tsMethodSignature(key: BabelNodeExpression, typeParameters?: BabelNodeTSTypeParameterDeclaration, parameters: Array, typeAnnotation?: BabelNodeTSTypeAnnotation): BabelNodeTSMethodSignature; - declare export function tsIndexSignature(parameters: Array, typeAnnotation?: BabelNodeTSTypeAnnotation): BabelNodeTSIndexSignature; - declare export function tsAnyKeyword(): BabelNodeTSAnyKeyword; - declare export function tsBooleanKeyword(): BabelNodeTSBooleanKeyword; - declare export function tsBigIntKeyword(): BabelNodeTSBigIntKeyword; - declare export function tsIntrinsicKeyword(): BabelNodeTSIntrinsicKeyword; - declare export function tsNeverKeyword(): BabelNodeTSNeverKeyword; - declare export function tsNullKeyword(): BabelNodeTSNullKeyword; - declare export function tsNumberKeyword(): BabelNodeTSNumberKeyword; - declare export function tsObjectKeyword(): BabelNodeTSObjectKeyword; - declare export function tsStringKeyword(): BabelNodeTSStringKeyword; - declare export function tsSymbolKeyword(): BabelNodeTSSymbolKeyword; - declare export function tsUndefinedKeyword(): BabelNodeTSUndefinedKeyword; - declare export function tsUnknownKeyword(): BabelNodeTSUnknownKeyword; - declare export function tsVoidKeyword(): BabelNodeTSVoidKeyword; - declare export function tsThisType(): BabelNodeTSThisType; - declare export function tsFunctionType(typeParameters?: BabelNodeTSTypeParameterDeclaration, parameters: Array, typeAnnotation?: BabelNodeTSTypeAnnotation): BabelNodeTSFunctionType; - declare export function tsConstructorType(typeParameters?: BabelNodeTSTypeParameterDeclaration, parameters: Array, typeAnnotation?: BabelNodeTSTypeAnnotation): BabelNodeTSConstructorType; - declare export function tsTypeReference(typeName: BabelNodeTSEntityName, typeParameters?: BabelNodeTSTypeParameterInstantiation): BabelNodeTSTypeReference; - declare export function tsTypePredicate(parameterName: BabelNodeIdentifier | BabelNodeTSThisType, typeAnnotation?: BabelNodeTSTypeAnnotation, asserts?: boolean): BabelNodeTSTypePredicate; - declare export function tsTypeQuery(exprName: BabelNodeTSEntityName | BabelNodeTSImportType, typeParameters?: BabelNodeTSTypeParameterInstantiation): BabelNodeTSTypeQuery; - declare export function tsTypeLiteral(members: Array): BabelNodeTSTypeLiteral; - declare export function tsArrayType(elementType: BabelNodeTSType): BabelNodeTSArrayType; - declare export function tsTupleType(elementTypes: Array): BabelNodeTSTupleType; - declare export function tsOptionalType(typeAnnotation: BabelNodeTSType): BabelNodeTSOptionalType; - declare export function tsRestType(typeAnnotation: BabelNodeTSType): BabelNodeTSRestType; - declare export function tsNamedTupleMember(label: BabelNodeIdentifier, elementType: BabelNodeTSType, optional?: boolean): BabelNodeTSNamedTupleMember; - declare export function tsUnionType(types: Array): BabelNodeTSUnionType; - declare export function tsIntersectionType(types: Array): BabelNodeTSIntersectionType; - declare export function tsConditionalType(checkType: BabelNodeTSType, extendsType: BabelNodeTSType, trueType: BabelNodeTSType, falseType: BabelNodeTSType): BabelNodeTSConditionalType; - declare export function tsInferType(typeParameter: BabelNodeTSTypeParameter): BabelNodeTSInferType; - declare export function tsParenthesizedType(typeAnnotation: BabelNodeTSType): BabelNodeTSParenthesizedType; - declare export function tsTypeOperator(typeAnnotation: BabelNodeTSType): BabelNodeTSTypeOperator; - declare export function tsIndexedAccessType(objectType: BabelNodeTSType, indexType: BabelNodeTSType): BabelNodeTSIndexedAccessType; - declare export function tsMappedType(typeParameter: BabelNodeTSTypeParameter, typeAnnotation?: BabelNodeTSType, nameType?: BabelNodeTSType): BabelNodeTSMappedType; - declare export function tsLiteralType(literal: BabelNodeNumericLiteral | BabelNodeStringLiteral | BabelNodeBooleanLiteral | BabelNodeBigIntLiteral | BabelNodeTemplateLiteral | BabelNodeUnaryExpression): BabelNodeTSLiteralType; - declare export function tsExpressionWithTypeArguments(expression: BabelNodeTSEntityName, typeParameters?: BabelNodeTSTypeParameterInstantiation): BabelNodeTSExpressionWithTypeArguments; - declare export function tsInterfaceDeclaration(id: BabelNodeIdentifier, typeParameters?: BabelNodeTSTypeParameterDeclaration, _extends?: Array, body: BabelNodeTSInterfaceBody): BabelNodeTSInterfaceDeclaration; - declare export function tsInterfaceBody(body: Array): BabelNodeTSInterfaceBody; - declare export function tsTypeAliasDeclaration(id: BabelNodeIdentifier, typeParameters?: BabelNodeTSTypeParameterDeclaration, typeAnnotation: BabelNodeTSType): BabelNodeTSTypeAliasDeclaration; - declare export function tsInstantiationExpression(expression: BabelNodeExpression, typeParameters?: BabelNodeTSTypeParameterInstantiation): BabelNodeTSInstantiationExpression; - declare export function tsAsExpression(expression: BabelNodeExpression, typeAnnotation: BabelNodeTSType): BabelNodeTSAsExpression; - declare export function tsSatisfiesExpression(expression: BabelNodeExpression, typeAnnotation: BabelNodeTSType): BabelNodeTSSatisfiesExpression; - declare export function tsTypeAssertion(typeAnnotation: BabelNodeTSType, expression: BabelNodeExpression): BabelNodeTSTypeAssertion; - declare export function tsEnumDeclaration(id: BabelNodeIdentifier, members: Array): BabelNodeTSEnumDeclaration; - declare export function tsEnumMember(id: BabelNodeIdentifier | BabelNodeStringLiteral, initializer?: BabelNodeExpression): BabelNodeTSEnumMember; - declare export function tsModuleDeclaration(id: BabelNodeIdentifier | BabelNodeStringLiteral, body: BabelNodeTSModuleBlock | BabelNodeTSModuleDeclaration): BabelNodeTSModuleDeclaration; - declare export function tsModuleBlock(body: Array): BabelNodeTSModuleBlock; - declare export function tsImportType(argument: BabelNodeStringLiteral, qualifier?: BabelNodeTSEntityName, typeParameters?: BabelNodeTSTypeParameterInstantiation): BabelNodeTSImportType; - declare export function tsImportEqualsDeclaration(id: BabelNodeIdentifier, moduleReference: BabelNodeTSEntityName | BabelNodeTSExternalModuleReference): BabelNodeTSImportEqualsDeclaration; - declare export function tsExternalModuleReference(expression: BabelNodeStringLiteral): BabelNodeTSExternalModuleReference; - declare export function tsNonNullExpression(expression: BabelNodeExpression): BabelNodeTSNonNullExpression; - declare export function tsExportAssignment(expression: BabelNodeExpression): BabelNodeTSExportAssignment; - declare export function tsNamespaceExportDeclaration(id: BabelNodeIdentifier): BabelNodeTSNamespaceExportDeclaration; - declare export function tsTypeAnnotation(typeAnnotation: BabelNodeTSType): BabelNodeTSTypeAnnotation; - declare export function tsTypeParameterInstantiation(params: Array): BabelNodeTSTypeParameterInstantiation; - declare export function tsTypeParameterDeclaration(params: Array): BabelNodeTSTypeParameterDeclaration; - declare export function tsTypeParameter(constraint?: BabelNodeTSType, _default?: BabelNodeTSType, name: string): BabelNodeTSTypeParameter; - declare export function isArrayExpression(node: ?Object, opts?: ?Object): boolean %checks (node instanceof BabelNodeArrayExpression) - declare export function assertArrayExpression(node: ?Object, opts?: ?Object): void - declare export function isAssignmentExpression(node: ?Object, opts?: ?Object): boolean %checks (node instanceof BabelNodeAssignmentExpression) - declare export function assertAssignmentExpression(node: ?Object, opts?: ?Object): void - declare export function isBinaryExpression(node: ?Object, opts?: ?Object): boolean %checks (node instanceof BabelNodeBinaryExpression) - declare export function assertBinaryExpression(node: ?Object, opts?: ?Object): void - declare export function isInterpreterDirective(node: ?Object, opts?: ?Object): boolean %checks (node instanceof BabelNodeInterpreterDirective) - declare export function assertInterpreterDirective(node: ?Object, opts?: ?Object): void - declare export function isDirective(node: ?Object, opts?: ?Object): boolean %checks (node instanceof BabelNodeDirective) - declare export function assertDirective(node: ?Object, opts?: ?Object): void - declare export function isDirectiveLiteral(node: ?Object, opts?: ?Object): boolean %checks (node instanceof BabelNodeDirectiveLiteral) - declare export function assertDirectiveLiteral(node: ?Object, opts?: ?Object): void - declare export function isBlockStatement(node: ?Object, opts?: ?Object): boolean %checks (node instanceof BabelNodeBlockStatement) - declare export function assertBlockStatement(node: ?Object, opts?: ?Object): void - declare export function isBreakStatement(node: ?Object, opts?: ?Object): boolean %checks (node instanceof BabelNodeBreakStatement) - declare export function assertBreakStatement(node: ?Object, opts?: ?Object): void - declare export function isCallExpression(node: ?Object, opts?: ?Object): boolean %checks (node instanceof BabelNodeCallExpression) - declare export function assertCallExpression(node: ?Object, opts?: ?Object): void - declare export function isCatchClause(node: ?Object, opts?: ?Object): boolean %checks (node instanceof BabelNodeCatchClause) - declare export function assertCatchClause(node: ?Object, opts?: ?Object): void - declare export function isConditionalExpression(node: ?Object, opts?: ?Object): boolean %checks (node instanceof BabelNodeConditionalExpression) - declare export function assertConditionalExpression(node: ?Object, opts?: ?Object): void - declare export function isContinueStatement(node: ?Object, opts?: ?Object): boolean %checks (node instanceof BabelNodeContinueStatement) - declare export function assertContinueStatement(node: ?Object, opts?: ?Object): void - declare export function isDebuggerStatement(node: ?Object, opts?: ?Object): boolean %checks (node instanceof BabelNodeDebuggerStatement) - declare export function assertDebuggerStatement(node: ?Object, opts?: ?Object): void - declare export function isDoWhileStatement(node: ?Object, opts?: ?Object): boolean %checks (node instanceof BabelNodeDoWhileStatement) - declare export function assertDoWhileStatement(node: ?Object, opts?: ?Object): void - declare export function isEmptyStatement(node: ?Object, opts?: ?Object): boolean %checks (node instanceof BabelNodeEmptyStatement) - declare export function assertEmptyStatement(node: ?Object, opts?: ?Object): void - declare export function isExpressionStatement(node: ?Object, opts?: ?Object): boolean %checks (node instanceof BabelNodeExpressionStatement) - declare export function assertExpressionStatement(node: ?Object, opts?: ?Object): void - declare export function isFile(node: ?Object, opts?: ?Object): boolean %checks (node instanceof BabelNodeFile) - declare export function assertFile(node: ?Object, opts?: ?Object): void - declare export function isForInStatement(node: ?Object, opts?: ?Object): boolean %checks (node instanceof BabelNodeForInStatement) - declare export function assertForInStatement(node: ?Object, opts?: ?Object): void - declare export function isForStatement(node: ?Object, opts?: ?Object): boolean %checks (node instanceof BabelNodeForStatement) - declare export function assertForStatement(node: ?Object, opts?: ?Object): void - declare export function isFunctionDeclaration(node: ?Object, opts?: ?Object): boolean %checks (node instanceof BabelNodeFunctionDeclaration) - declare export function assertFunctionDeclaration(node: ?Object, opts?: ?Object): void - declare export function isFunctionExpression(node: ?Object, opts?: ?Object): boolean %checks (node instanceof BabelNodeFunctionExpression) - declare export function assertFunctionExpression(node: ?Object, opts?: ?Object): void - declare export function isIdentifier(node: ?Object, opts?: ?Object): boolean %checks (node instanceof BabelNodeIdentifier) - declare export function assertIdentifier(node: ?Object, opts?: ?Object): void - declare export function isIfStatement(node: ?Object, opts?: ?Object): boolean %checks (node instanceof BabelNodeIfStatement) - declare export function assertIfStatement(node: ?Object, opts?: ?Object): void - declare export function isLabeledStatement(node: ?Object, opts?: ?Object): boolean %checks (node instanceof BabelNodeLabeledStatement) - declare export function assertLabeledStatement(node: ?Object, opts?: ?Object): void - declare export function isStringLiteral(node: ?Object, opts?: ?Object): boolean %checks (node instanceof BabelNodeStringLiteral) - declare export function assertStringLiteral(node: ?Object, opts?: ?Object): void - declare export function isNumericLiteral(node: ?Object, opts?: ?Object): boolean %checks (node instanceof BabelNodeNumericLiteral) - declare export function assertNumericLiteral(node: ?Object, opts?: ?Object): void - declare export function isNullLiteral(node: ?Object, opts?: ?Object): boolean %checks (node instanceof BabelNodeNullLiteral) - declare export function assertNullLiteral(node: ?Object, opts?: ?Object): void - declare export function isBooleanLiteral(node: ?Object, opts?: ?Object): boolean %checks (node instanceof BabelNodeBooleanLiteral) - declare export function assertBooleanLiteral(node: ?Object, opts?: ?Object): void - declare export function isRegExpLiteral(node: ?Object, opts?: ?Object): boolean %checks (node instanceof BabelNodeRegExpLiteral) - declare export function assertRegExpLiteral(node: ?Object, opts?: ?Object): void - declare export function isLogicalExpression(node: ?Object, opts?: ?Object): boolean %checks (node instanceof BabelNodeLogicalExpression) - declare export function assertLogicalExpression(node: ?Object, opts?: ?Object): void - declare export function isMemberExpression(node: ?Object, opts?: ?Object): boolean %checks (node instanceof BabelNodeMemberExpression) - declare export function assertMemberExpression(node: ?Object, opts?: ?Object): void - declare export function isNewExpression(node: ?Object, opts?: ?Object): boolean %checks (node instanceof BabelNodeNewExpression) - declare export function assertNewExpression(node: ?Object, opts?: ?Object): void - declare export function isProgram(node: ?Object, opts?: ?Object): boolean %checks (node instanceof BabelNodeProgram) - declare export function assertProgram(node: ?Object, opts?: ?Object): void - declare export function isObjectExpression(node: ?Object, opts?: ?Object): boolean %checks (node instanceof BabelNodeObjectExpression) - declare export function assertObjectExpression(node: ?Object, opts?: ?Object): void - declare export function isObjectMethod(node: ?Object, opts?: ?Object): boolean %checks (node instanceof BabelNodeObjectMethod) - declare export function assertObjectMethod(node: ?Object, opts?: ?Object): void - declare export function isObjectProperty(node: ?Object, opts?: ?Object): boolean %checks (node instanceof BabelNodeObjectProperty) - declare export function assertObjectProperty(node: ?Object, opts?: ?Object): void - declare export function isRestElement(node: ?Object, opts?: ?Object): boolean %checks (node instanceof BabelNodeRestElement) - declare export function assertRestElement(node: ?Object, opts?: ?Object): void - declare export function isReturnStatement(node: ?Object, opts?: ?Object): boolean %checks (node instanceof BabelNodeReturnStatement) - declare export function assertReturnStatement(node: ?Object, opts?: ?Object): void - declare export function isSequenceExpression(node: ?Object, opts?: ?Object): boolean %checks (node instanceof BabelNodeSequenceExpression) - declare export function assertSequenceExpression(node: ?Object, opts?: ?Object): void - declare export function isParenthesizedExpression(node: ?Object, opts?: ?Object): boolean %checks (node instanceof BabelNodeParenthesizedExpression) - declare export function assertParenthesizedExpression(node: ?Object, opts?: ?Object): void - declare export function isSwitchCase(node: ?Object, opts?: ?Object): boolean %checks (node instanceof BabelNodeSwitchCase) - declare export function assertSwitchCase(node: ?Object, opts?: ?Object): void - declare export function isSwitchStatement(node: ?Object, opts?: ?Object): boolean %checks (node instanceof BabelNodeSwitchStatement) - declare export function assertSwitchStatement(node: ?Object, opts?: ?Object): void - declare export function isThisExpression(node: ?Object, opts?: ?Object): boolean %checks (node instanceof BabelNodeThisExpression) - declare export function assertThisExpression(node: ?Object, opts?: ?Object): void - declare export function isThrowStatement(node: ?Object, opts?: ?Object): boolean %checks (node instanceof BabelNodeThrowStatement) - declare export function assertThrowStatement(node: ?Object, opts?: ?Object): void - declare export function isTryStatement(node: ?Object, opts?: ?Object): boolean %checks (node instanceof BabelNodeTryStatement) - declare export function assertTryStatement(node: ?Object, opts?: ?Object): void - declare export function isUnaryExpression(node: ?Object, opts?: ?Object): boolean %checks (node instanceof BabelNodeUnaryExpression) - declare export function assertUnaryExpression(node: ?Object, opts?: ?Object): void - declare export function isUpdateExpression(node: ?Object, opts?: ?Object): boolean %checks (node instanceof BabelNodeUpdateExpression) - declare export function assertUpdateExpression(node: ?Object, opts?: ?Object): void - declare export function isVariableDeclaration(node: ?Object, opts?: ?Object): boolean %checks (node instanceof BabelNodeVariableDeclaration) - declare export function assertVariableDeclaration(node: ?Object, opts?: ?Object): void - declare export function isVariableDeclarator(node: ?Object, opts?: ?Object): boolean %checks (node instanceof BabelNodeVariableDeclarator) - declare export function assertVariableDeclarator(node: ?Object, opts?: ?Object): void - declare export function isWhileStatement(node: ?Object, opts?: ?Object): boolean %checks (node instanceof BabelNodeWhileStatement) - declare export function assertWhileStatement(node: ?Object, opts?: ?Object): void - declare export function isWithStatement(node: ?Object, opts?: ?Object): boolean %checks (node instanceof BabelNodeWithStatement) - declare export function assertWithStatement(node: ?Object, opts?: ?Object): void - declare export function isAssignmentPattern(node: ?Object, opts?: ?Object): boolean %checks (node instanceof BabelNodeAssignmentPattern) - declare export function assertAssignmentPattern(node: ?Object, opts?: ?Object): void - declare export function isArrayPattern(node: ?Object, opts?: ?Object): boolean %checks (node instanceof BabelNodeArrayPattern) - declare export function assertArrayPattern(node: ?Object, opts?: ?Object): void - declare export function isArrowFunctionExpression(node: ?Object, opts?: ?Object): boolean %checks (node instanceof BabelNodeArrowFunctionExpression) - declare export function assertArrowFunctionExpression(node: ?Object, opts?: ?Object): void - declare export function isClassBody(node: ?Object, opts?: ?Object): boolean %checks (node instanceof BabelNodeClassBody) - declare export function assertClassBody(node: ?Object, opts?: ?Object): void - declare export function isClassExpression(node: ?Object, opts?: ?Object): boolean %checks (node instanceof BabelNodeClassExpression) - declare export function assertClassExpression(node: ?Object, opts?: ?Object): void - declare export function isClassDeclaration(node: ?Object, opts?: ?Object): boolean %checks (node instanceof BabelNodeClassDeclaration) - declare export function assertClassDeclaration(node: ?Object, opts?: ?Object): void - declare export function isExportAllDeclaration(node: ?Object, opts?: ?Object): boolean %checks (node instanceof BabelNodeExportAllDeclaration) - declare export function assertExportAllDeclaration(node: ?Object, opts?: ?Object): void - declare export function isExportDefaultDeclaration(node: ?Object, opts?: ?Object): boolean %checks (node instanceof BabelNodeExportDefaultDeclaration) - declare export function assertExportDefaultDeclaration(node: ?Object, opts?: ?Object): void - declare export function isExportNamedDeclaration(node: ?Object, opts?: ?Object): boolean %checks (node instanceof BabelNodeExportNamedDeclaration) - declare export function assertExportNamedDeclaration(node: ?Object, opts?: ?Object): void - declare export function isExportSpecifier(node: ?Object, opts?: ?Object): boolean %checks (node instanceof BabelNodeExportSpecifier) - declare export function assertExportSpecifier(node: ?Object, opts?: ?Object): void - declare export function isForOfStatement(node: ?Object, opts?: ?Object): boolean %checks (node instanceof BabelNodeForOfStatement) - declare export function assertForOfStatement(node: ?Object, opts?: ?Object): void - declare export function isImportDeclaration(node: ?Object, opts?: ?Object): boolean %checks (node instanceof BabelNodeImportDeclaration) - declare export function assertImportDeclaration(node: ?Object, opts?: ?Object): void - declare export function isImportDefaultSpecifier(node: ?Object, opts?: ?Object): boolean %checks (node instanceof BabelNodeImportDefaultSpecifier) - declare export function assertImportDefaultSpecifier(node: ?Object, opts?: ?Object): void - declare export function isImportNamespaceSpecifier(node: ?Object, opts?: ?Object): boolean %checks (node instanceof BabelNodeImportNamespaceSpecifier) - declare export function assertImportNamespaceSpecifier(node: ?Object, opts?: ?Object): void - declare export function isImportSpecifier(node: ?Object, opts?: ?Object): boolean %checks (node instanceof BabelNodeImportSpecifier) - declare export function assertImportSpecifier(node: ?Object, opts?: ?Object): void - declare export function isImportExpression(node: ?Object, opts?: ?Object): boolean %checks (node instanceof BabelNodeImportExpression) - declare export function assertImportExpression(node: ?Object, opts?: ?Object): void - declare export function isMetaProperty(node: ?Object, opts?: ?Object): boolean %checks (node instanceof BabelNodeMetaProperty) - declare export function assertMetaProperty(node: ?Object, opts?: ?Object): void - declare export function isClassMethod(node: ?Object, opts?: ?Object): boolean %checks (node instanceof BabelNodeClassMethod) - declare export function assertClassMethod(node: ?Object, opts?: ?Object): void - declare export function isObjectPattern(node: ?Object, opts?: ?Object): boolean %checks (node instanceof BabelNodeObjectPattern) - declare export function assertObjectPattern(node: ?Object, opts?: ?Object): void - declare export function isSpreadElement(node: ?Object, opts?: ?Object): boolean %checks (node instanceof BabelNodeSpreadElement) - declare export function assertSpreadElement(node: ?Object, opts?: ?Object): void - declare export function isSuper(node: ?Object, opts?: ?Object): boolean %checks (node instanceof BabelNodeSuper) - declare export function assertSuper(node: ?Object, opts?: ?Object): void - declare export function isTaggedTemplateExpression(node: ?Object, opts?: ?Object): boolean %checks (node instanceof BabelNodeTaggedTemplateExpression) - declare export function assertTaggedTemplateExpression(node: ?Object, opts?: ?Object): void - declare export function isTemplateElement(node: ?Object, opts?: ?Object): boolean %checks (node instanceof BabelNodeTemplateElement) - declare export function assertTemplateElement(node: ?Object, opts?: ?Object): void - declare export function isTemplateLiteral(node: ?Object, opts?: ?Object): boolean %checks (node instanceof BabelNodeTemplateLiteral) - declare export function assertTemplateLiteral(node: ?Object, opts?: ?Object): void - declare export function isYieldExpression(node: ?Object, opts?: ?Object): boolean %checks (node instanceof BabelNodeYieldExpression) - declare export function assertYieldExpression(node: ?Object, opts?: ?Object): void - declare export function isAwaitExpression(node: ?Object, opts?: ?Object): boolean %checks (node instanceof BabelNodeAwaitExpression) - declare export function assertAwaitExpression(node: ?Object, opts?: ?Object): void - declare export function isImport(node: ?Object, opts?: ?Object): boolean %checks (node instanceof BabelNodeImport) - declare export function assertImport(node: ?Object, opts?: ?Object): void - declare export function isBigIntLiteral(node: ?Object, opts?: ?Object): boolean %checks (node instanceof BabelNodeBigIntLiteral) - declare export function assertBigIntLiteral(node: ?Object, opts?: ?Object): void - declare export function isExportNamespaceSpecifier(node: ?Object, opts?: ?Object): boolean %checks (node instanceof BabelNodeExportNamespaceSpecifier) - declare export function assertExportNamespaceSpecifier(node: ?Object, opts?: ?Object): void - declare export function isOptionalMemberExpression(node: ?Object, opts?: ?Object): boolean %checks (node instanceof BabelNodeOptionalMemberExpression) - declare export function assertOptionalMemberExpression(node: ?Object, opts?: ?Object): void - declare export function isOptionalCallExpression(node: ?Object, opts?: ?Object): boolean %checks (node instanceof BabelNodeOptionalCallExpression) - declare export function assertOptionalCallExpression(node: ?Object, opts?: ?Object): void - declare export function isClassProperty(node: ?Object, opts?: ?Object): boolean %checks (node instanceof BabelNodeClassProperty) - declare export function assertClassProperty(node: ?Object, opts?: ?Object): void - declare export function isClassAccessorProperty(node: ?Object, opts?: ?Object): boolean %checks (node instanceof BabelNodeClassAccessorProperty) - declare export function assertClassAccessorProperty(node: ?Object, opts?: ?Object): void - declare export function isClassPrivateProperty(node: ?Object, opts?: ?Object): boolean %checks (node instanceof BabelNodeClassPrivateProperty) - declare export function assertClassPrivateProperty(node: ?Object, opts?: ?Object): void - declare export function isClassPrivateMethod(node: ?Object, opts?: ?Object): boolean %checks (node instanceof BabelNodeClassPrivateMethod) - declare export function assertClassPrivateMethod(node: ?Object, opts?: ?Object): void - declare export function isPrivateName(node: ?Object, opts?: ?Object): boolean %checks (node instanceof BabelNodePrivateName) - declare export function assertPrivateName(node: ?Object, opts?: ?Object): void - declare export function isStaticBlock(node: ?Object, opts?: ?Object): boolean %checks (node instanceof BabelNodeStaticBlock) - declare export function assertStaticBlock(node: ?Object, opts?: ?Object): void - declare export function isAnyTypeAnnotation(node: ?Object, opts?: ?Object): boolean %checks (node instanceof BabelNodeAnyTypeAnnotation) - declare export function assertAnyTypeAnnotation(node: ?Object, opts?: ?Object): void - declare export function isArrayTypeAnnotation(node: ?Object, opts?: ?Object): boolean %checks (node instanceof BabelNodeArrayTypeAnnotation) - declare export function assertArrayTypeAnnotation(node: ?Object, opts?: ?Object): void - declare export function isBooleanTypeAnnotation(node: ?Object, opts?: ?Object): boolean %checks (node instanceof BabelNodeBooleanTypeAnnotation) - declare export function assertBooleanTypeAnnotation(node: ?Object, opts?: ?Object): void - declare export function isBooleanLiteralTypeAnnotation(node: ?Object, opts?: ?Object): boolean %checks (node instanceof BabelNodeBooleanLiteralTypeAnnotation) - declare export function assertBooleanLiteralTypeAnnotation(node: ?Object, opts?: ?Object): void - declare export function isNullLiteralTypeAnnotation(node: ?Object, opts?: ?Object): boolean %checks (node instanceof BabelNodeNullLiteralTypeAnnotation) - declare export function assertNullLiteralTypeAnnotation(node: ?Object, opts?: ?Object): void - declare export function isClassImplements(node: ?Object, opts?: ?Object): boolean %checks (node instanceof BabelNodeClassImplements) - declare export function assertClassImplements(node: ?Object, opts?: ?Object): void - declare export function isDeclareClass(node: ?Object, opts?: ?Object): boolean %checks (node instanceof BabelNodeDeclareClass) - declare export function assertDeclareClass(node: ?Object, opts?: ?Object): void - declare export function isDeclareFunction(node: ?Object, opts?: ?Object): boolean %checks (node instanceof BabelNodeDeclareFunction) - declare export function assertDeclareFunction(node: ?Object, opts?: ?Object): void - declare export function isDeclareInterface(node: ?Object, opts?: ?Object): boolean %checks (node instanceof BabelNodeDeclareInterface) - declare export function assertDeclareInterface(node: ?Object, opts?: ?Object): void - declare export function isDeclareModule(node: ?Object, opts?: ?Object): boolean %checks (node instanceof BabelNodeDeclareModule) - declare export function assertDeclareModule(node: ?Object, opts?: ?Object): void - declare export function isDeclareModuleExports(node: ?Object, opts?: ?Object): boolean %checks (node instanceof BabelNodeDeclareModuleExports) - declare export function assertDeclareModuleExports(node: ?Object, opts?: ?Object): void - declare export function isDeclareTypeAlias(node: ?Object, opts?: ?Object): boolean %checks (node instanceof BabelNodeDeclareTypeAlias) - declare export function assertDeclareTypeAlias(node: ?Object, opts?: ?Object): void - declare export function isDeclareOpaqueType(node: ?Object, opts?: ?Object): boolean %checks (node instanceof BabelNodeDeclareOpaqueType) - declare export function assertDeclareOpaqueType(node: ?Object, opts?: ?Object): void - declare export function isDeclareVariable(node: ?Object, opts?: ?Object): boolean %checks (node instanceof BabelNodeDeclareVariable) - declare export function assertDeclareVariable(node: ?Object, opts?: ?Object): void - declare export function isDeclareExportDeclaration(node: ?Object, opts?: ?Object): boolean %checks (node instanceof BabelNodeDeclareExportDeclaration) - declare export function assertDeclareExportDeclaration(node: ?Object, opts?: ?Object): void - declare export function isDeclareExportAllDeclaration(node: ?Object, opts?: ?Object): boolean %checks (node instanceof BabelNodeDeclareExportAllDeclaration) - declare export function assertDeclareExportAllDeclaration(node: ?Object, opts?: ?Object): void - declare export function isDeclaredPredicate(node: ?Object, opts?: ?Object): boolean %checks (node instanceof BabelNodeDeclaredPredicate) - declare export function assertDeclaredPredicate(node: ?Object, opts?: ?Object): void - declare export function isExistsTypeAnnotation(node: ?Object, opts?: ?Object): boolean %checks (node instanceof BabelNodeExistsTypeAnnotation) - declare export function assertExistsTypeAnnotation(node: ?Object, opts?: ?Object): void - declare export function isFunctionTypeAnnotation(node: ?Object, opts?: ?Object): boolean %checks (node instanceof BabelNodeFunctionTypeAnnotation) - declare export function assertFunctionTypeAnnotation(node: ?Object, opts?: ?Object): void - declare export function isFunctionTypeParam(node: ?Object, opts?: ?Object): boolean %checks (node instanceof BabelNodeFunctionTypeParam) - declare export function assertFunctionTypeParam(node: ?Object, opts?: ?Object): void - declare export function isGenericTypeAnnotation(node: ?Object, opts?: ?Object): boolean %checks (node instanceof BabelNodeGenericTypeAnnotation) - declare export function assertGenericTypeAnnotation(node: ?Object, opts?: ?Object): void - declare export function isInferredPredicate(node: ?Object, opts?: ?Object): boolean %checks (node instanceof BabelNodeInferredPredicate) - declare export function assertInferredPredicate(node: ?Object, opts?: ?Object): void - declare export function isInterfaceExtends(node: ?Object, opts?: ?Object): boolean %checks (node instanceof BabelNodeInterfaceExtends) - declare export function assertInterfaceExtends(node: ?Object, opts?: ?Object): void - declare export function isInterfaceDeclaration(node: ?Object, opts?: ?Object): boolean %checks (node instanceof BabelNodeInterfaceDeclaration) - declare export function assertInterfaceDeclaration(node: ?Object, opts?: ?Object): void - declare export function isInterfaceTypeAnnotation(node: ?Object, opts?: ?Object): boolean %checks (node instanceof BabelNodeInterfaceTypeAnnotation) - declare export function assertInterfaceTypeAnnotation(node: ?Object, opts?: ?Object): void - declare export function isIntersectionTypeAnnotation(node: ?Object, opts?: ?Object): boolean %checks (node instanceof BabelNodeIntersectionTypeAnnotation) - declare export function assertIntersectionTypeAnnotation(node: ?Object, opts?: ?Object): void - declare export function isMixedTypeAnnotation(node: ?Object, opts?: ?Object): boolean %checks (node instanceof BabelNodeMixedTypeAnnotation) - declare export function assertMixedTypeAnnotation(node: ?Object, opts?: ?Object): void - declare export function isEmptyTypeAnnotation(node: ?Object, opts?: ?Object): boolean %checks (node instanceof BabelNodeEmptyTypeAnnotation) - declare export function assertEmptyTypeAnnotation(node: ?Object, opts?: ?Object): void - declare export function isNullableTypeAnnotation(node: ?Object, opts?: ?Object): boolean %checks (node instanceof BabelNodeNullableTypeAnnotation) - declare export function assertNullableTypeAnnotation(node: ?Object, opts?: ?Object): void - declare export function isNumberLiteralTypeAnnotation(node: ?Object, opts?: ?Object): boolean %checks (node instanceof BabelNodeNumberLiteralTypeAnnotation) - declare export function assertNumberLiteralTypeAnnotation(node: ?Object, opts?: ?Object): void - declare export function isNumberTypeAnnotation(node: ?Object, opts?: ?Object): boolean %checks (node instanceof BabelNodeNumberTypeAnnotation) - declare export function assertNumberTypeAnnotation(node: ?Object, opts?: ?Object): void - declare export function isObjectTypeAnnotation(node: ?Object, opts?: ?Object): boolean %checks (node instanceof BabelNodeObjectTypeAnnotation) - declare export function assertObjectTypeAnnotation(node: ?Object, opts?: ?Object): void - declare export function isObjectTypeInternalSlot(node: ?Object, opts?: ?Object): boolean %checks (node instanceof BabelNodeObjectTypeInternalSlot) - declare export function assertObjectTypeInternalSlot(node: ?Object, opts?: ?Object): void - declare export function isObjectTypeCallProperty(node: ?Object, opts?: ?Object): boolean %checks (node instanceof BabelNodeObjectTypeCallProperty) - declare export function assertObjectTypeCallProperty(node: ?Object, opts?: ?Object): void - declare export function isObjectTypeIndexer(node: ?Object, opts?: ?Object): boolean %checks (node instanceof BabelNodeObjectTypeIndexer) - declare export function assertObjectTypeIndexer(node: ?Object, opts?: ?Object): void - declare export function isObjectTypeProperty(node: ?Object, opts?: ?Object): boolean %checks (node instanceof BabelNodeObjectTypeProperty) - declare export function assertObjectTypeProperty(node: ?Object, opts?: ?Object): void - declare export function isObjectTypeSpreadProperty(node: ?Object, opts?: ?Object): boolean %checks (node instanceof BabelNodeObjectTypeSpreadProperty) - declare export function assertObjectTypeSpreadProperty(node: ?Object, opts?: ?Object): void - declare export function isOpaqueType(node: ?Object, opts?: ?Object): boolean %checks (node instanceof BabelNodeOpaqueType) - declare export function assertOpaqueType(node: ?Object, opts?: ?Object): void - declare export function isQualifiedTypeIdentifier(node: ?Object, opts?: ?Object): boolean %checks (node instanceof BabelNodeQualifiedTypeIdentifier) - declare export function assertQualifiedTypeIdentifier(node: ?Object, opts?: ?Object): void - declare export function isStringLiteralTypeAnnotation(node: ?Object, opts?: ?Object): boolean %checks (node instanceof BabelNodeStringLiteralTypeAnnotation) - declare export function assertStringLiteralTypeAnnotation(node: ?Object, opts?: ?Object): void - declare export function isStringTypeAnnotation(node: ?Object, opts?: ?Object): boolean %checks (node instanceof BabelNodeStringTypeAnnotation) - declare export function assertStringTypeAnnotation(node: ?Object, opts?: ?Object): void - declare export function isSymbolTypeAnnotation(node: ?Object, opts?: ?Object): boolean %checks (node instanceof BabelNodeSymbolTypeAnnotation) - declare export function assertSymbolTypeAnnotation(node: ?Object, opts?: ?Object): void - declare export function isThisTypeAnnotation(node: ?Object, opts?: ?Object): boolean %checks (node instanceof BabelNodeThisTypeAnnotation) - declare export function assertThisTypeAnnotation(node: ?Object, opts?: ?Object): void - declare export function isTupleTypeAnnotation(node: ?Object, opts?: ?Object): boolean %checks (node instanceof BabelNodeTupleTypeAnnotation) - declare export function assertTupleTypeAnnotation(node: ?Object, opts?: ?Object): void - declare export function isTypeofTypeAnnotation(node: ?Object, opts?: ?Object): boolean %checks (node instanceof BabelNodeTypeofTypeAnnotation) - declare export function assertTypeofTypeAnnotation(node: ?Object, opts?: ?Object): void - declare export function isTypeAlias(node: ?Object, opts?: ?Object): boolean %checks (node instanceof BabelNodeTypeAlias) - declare export function assertTypeAlias(node: ?Object, opts?: ?Object): void - declare export function isTypeAnnotation(node: ?Object, opts?: ?Object): boolean %checks (node instanceof BabelNodeTypeAnnotation) - declare export function assertTypeAnnotation(node: ?Object, opts?: ?Object): void - declare export function isTypeCastExpression(node: ?Object, opts?: ?Object): boolean %checks (node instanceof BabelNodeTypeCastExpression) - declare export function assertTypeCastExpression(node: ?Object, opts?: ?Object): void - declare export function isTypeParameter(node: ?Object, opts?: ?Object): boolean %checks (node instanceof BabelNodeTypeParameter) - declare export function assertTypeParameter(node: ?Object, opts?: ?Object): void - declare export function isTypeParameterDeclaration(node: ?Object, opts?: ?Object): boolean %checks (node instanceof BabelNodeTypeParameterDeclaration) - declare export function assertTypeParameterDeclaration(node: ?Object, opts?: ?Object): void - declare export function isTypeParameterInstantiation(node: ?Object, opts?: ?Object): boolean %checks (node instanceof BabelNodeTypeParameterInstantiation) - declare export function assertTypeParameterInstantiation(node: ?Object, opts?: ?Object): void - declare export function isUnionTypeAnnotation(node: ?Object, opts?: ?Object): boolean %checks (node instanceof BabelNodeUnionTypeAnnotation) - declare export function assertUnionTypeAnnotation(node: ?Object, opts?: ?Object): void - declare export function isVariance(node: ?Object, opts?: ?Object): boolean %checks (node instanceof BabelNodeVariance) - declare export function assertVariance(node: ?Object, opts?: ?Object): void - declare export function isVoidTypeAnnotation(node: ?Object, opts?: ?Object): boolean %checks (node instanceof BabelNodeVoidTypeAnnotation) - declare export function assertVoidTypeAnnotation(node: ?Object, opts?: ?Object): void - declare export function isEnumDeclaration(node: ?Object, opts?: ?Object): boolean %checks (node instanceof BabelNodeEnumDeclaration) - declare export function assertEnumDeclaration(node: ?Object, opts?: ?Object): void - declare export function isEnumBooleanBody(node: ?Object, opts?: ?Object): boolean %checks (node instanceof BabelNodeEnumBooleanBody) - declare export function assertEnumBooleanBody(node: ?Object, opts?: ?Object): void - declare export function isEnumNumberBody(node: ?Object, opts?: ?Object): boolean %checks (node instanceof BabelNodeEnumNumberBody) - declare export function assertEnumNumberBody(node: ?Object, opts?: ?Object): void - declare export function isEnumStringBody(node: ?Object, opts?: ?Object): boolean %checks (node instanceof BabelNodeEnumStringBody) - declare export function assertEnumStringBody(node: ?Object, opts?: ?Object): void - declare export function isEnumSymbolBody(node: ?Object, opts?: ?Object): boolean %checks (node instanceof BabelNodeEnumSymbolBody) - declare export function assertEnumSymbolBody(node: ?Object, opts?: ?Object): void - declare export function isEnumBooleanMember(node: ?Object, opts?: ?Object): boolean %checks (node instanceof BabelNodeEnumBooleanMember) - declare export function assertEnumBooleanMember(node: ?Object, opts?: ?Object): void - declare export function isEnumNumberMember(node: ?Object, opts?: ?Object): boolean %checks (node instanceof BabelNodeEnumNumberMember) - declare export function assertEnumNumberMember(node: ?Object, opts?: ?Object): void - declare export function isEnumStringMember(node: ?Object, opts?: ?Object): boolean %checks (node instanceof BabelNodeEnumStringMember) - declare export function assertEnumStringMember(node: ?Object, opts?: ?Object): void - declare export function isEnumDefaultedMember(node: ?Object, opts?: ?Object): boolean %checks (node instanceof BabelNodeEnumDefaultedMember) - declare export function assertEnumDefaultedMember(node: ?Object, opts?: ?Object): void - declare export function isIndexedAccessType(node: ?Object, opts?: ?Object): boolean %checks (node instanceof BabelNodeIndexedAccessType) - declare export function assertIndexedAccessType(node: ?Object, opts?: ?Object): void - declare export function isOptionalIndexedAccessType(node: ?Object, opts?: ?Object): boolean %checks (node instanceof BabelNodeOptionalIndexedAccessType) - declare export function assertOptionalIndexedAccessType(node: ?Object, opts?: ?Object): void - declare export function isJSXAttribute(node: ?Object, opts?: ?Object): boolean %checks (node instanceof BabelNodeJSXAttribute) - declare export function assertJSXAttribute(node: ?Object, opts?: ?Object): void - declare export function isJSXClosingElement(node: ?Object, opts?: ?Object): boolean %checks (node instanceof BabelNodeJSXClosingElement) - declare export function assertJSXClosingElement(node: ?Object, opts?: ?Object): void - declare export function isJSXElement(node: ?Object, opts?: ?Object): boolean %checks (node instanceof BabelNodeJSXElement) - declare export function assertJSXElement(node: ?Object, opts?: ?Object): void - declare export function isJSXEmptyExpression(node: ?Object, opts?: ?Object): boolean %checks (node instanceof BabelNodeJSXEmptyExpression) - declare export function assertJSXEmptyExpression(node: ?Object, opts?: ?Object): void - declare export function isJSXExpressionContainer(node: ?Object, opts?: ?Object): boolean %checks (node instanceof BabelNodeJSXExpressionContainer) - declare export function assertJSXExpressionContainer(node: ?Object, opts?: ?Object): void - declare export function isJSXSpreadChild(node: ?Object, opts?: ?Object): boolean %checks (node instanceof BabelNodeJSXSpreadChild) - declare export function assertJSXSpreadChild(node: ?Object, opts?: ?Object): void - declare export function isJSXIdentifier(node: ?Object, opts?: ?Object): boolean %checks (node instanceof BabelNodeJSXIdentifier) - declare export function assertJSXIdentifier(node: ?Object, opts?: ?Object): void - declare export function isJSXMemberExpression(node: ?Object, opts?: ?Object): boolean %checks (node instanceof BabelNodeJSXMemberExpression) - declare export function assertJSXMemberExpression(node: ?Object, opts?: ?Object): void - declare export function isJSXNamespacedName(node: ?Object, opts?: ?Object): boolean %checks (node instanceof BabelNodeJSXNamespacedName) - declare export function assertJSXNamespacedName(node: ?Object, opts?: ?Object): void - declare export function isJSXOpeningElement(node: ?Object, opts?: ?Object): boolean %checks (node instanceof BabelNodeJSXOpeningElement) - declare export function assertJSXOpeningElement(node: ?Object, opts?: ?Object): void - declare export function isJSXSpreadAttribute(node: ?Object, opts?: ?Object): boolean %checks (node instanceof BabelNodeJSXSpreadAttribute) - declare export function assertJSXSpreadAttribute(node: ?Object, opts?: ?Object): void - declare export function isJSXText(node: ?Object, opts?: ?Object): boolean %checks (node instanceof BabelNodeJSXText) - declare export function assertJSXText(node: ?Object, opts?: ?Object): void - declare export function isJSXFragment(node: ?Object, opts?: ?Object): boolean %checks (node instanceof BabelNodeJSXFragment) - declare export function assertJSXFragment(node: ?Object, opts?: ?Object): void - declare export function isJSXOpeningFragment(node: ?Object, opts?: ?Object): boolean %checks (node instanceof BabelNodeJSXOpeningFragment) - declare export function assertJSXOpeningFragment(node: ?Object, opts?: ?Object): void - declare export function isJSXClosingFragment(node: ?Object, opts?: ?Object): boolean %checks (node instanceof BabelNodeJSXClosingFragment) - declare export function assertJSXClosingFragment(node: ?Object, opts?: ?Object): void - declare export function isNoop(node: ?Object, opts?: ?Object): boolean %checks (node instanceof BabelNodeNoop) - declare export function assertNoop(node: ?Object, opts?: ?Object): void - declare export function isPlaceholder(node: ?Object, opts?: ?Object): boolean %checks (node instanceof BabelNodePlaceholder) - declare export function assertPlaceholder(node: ?Object, opts?: ?Object): void - declare export function isV8IntrinsicIdentifier(node: ?Object, opts?: ?Object): boolean %checks (node instanceof BabelNodeV8IntrinsicIdentifier) - declare export function assertV8IntrinsicIdentifier(node: ?Object, opts?: ?Object): void - declare export function isArgumentPlaceholder(node: ?Object, opts?: ?Object): boolean %checks (node instanceof BabelNodeArgumentPlaceholder) - declare export function assertArgumentPlaceholder(node: ?Object, opts?: ?Object): void - declare export function isBindExpression(node: ?Object, opts?: ?Object): boolean %checks (node instanceof BabelNodeBindExpression) - declare export function assertBindExpression(node: ?Object, opts?: ?Object): void - declare export function isImportAttribute(node: ?Object, opts?: ?Object): boolean %checks (node instanceof BabelNodeImportAttribute) - declare export function assertImportAttribute(node: ?Object, opts?: ?Object): void - declare export function isDecorator(node: ?Object, opts?: ?Object): boolean %checks (node instanceof BabelNodeDecorator) - declare export function assertDecorator(node: ?Object, opts?: ?Object): void - declare export function isDoExpression(node: ?Object, opts?: ?Object): boolean %checks (node instanceof BabelNodeDoExpression) - declare export function assertDoExpression(node: ?Object, opts?: ?Object): void - declare export function isExportDefaultSpecifier(node: ?Object, opts?: ?Object): boolean %checks (node instanceof BabelNodeExportDefaultSpecifier) - declare export function assertExportDefaultSpecifier(node: ?Object, opts?: ?Object): void - declare export function isRecordExpression(node: ?Object, opts?: ?Object): boolean %checks (node instanceof BabelNodeRecordExpression) - declare export function assertRecordExpression(node: ?Object, opts?: ?Object): void - declare export function isTupleExpression(node: ?Object, opts?: ?Object): boolean %checks (node instanceof BabelNodeTupleExpression) - declare export function assertTupleExpression(node: ?Object, opts?: ?Object): void - declare export function isDecimalLiteral(node: ?Object, opts?: ?Object): boolean %checks (node instanceof BabelNodeDecimalLiteral) - declare export function assertDecimalLiteral(node: ?Object, opts?: ?Object): void - declare export function isModuleExpression(node: ?Object, opts?: ?Object): boolean %checks (node instanceof BabelNodeModuleExpression) - declare export function assertModuleExpression(node: ?Object, opts?: ?Object): void - declare export function isTopicReference(node: ?Object, opts?: ?Object): boolean %checks (node instanceof BabelNodeTopicReference) - declare export function assertTopicReference(node: ?Object, opts?: ?Object): void - declare export function isPipelineTopicExpression(node: ?Object, opts?: ?Object): boolean %checks (node instanceof BabelNodePipelineTopicExpression) - declare export function assertPipelineTopicExpression(node: ?Object, opts?: ?Object): void - declare export function isPipelineBareFunction(node: ?Object, opts?: ?Object): boolean %checks (node instanceof BabelNodePipelineBareFunction) - declare export function assertPipelineBareFunction(node: ?Object, opts?: ?Object): void - declare export function isPipelinePrimaryTopicReference(node: ?Object, opts?: ?Object): boolean %checks (node instanceof BabelNodePipelinePrimaryTopicReference) - declare export function assertPipelinePrimaryTopicReference(node: ?Object, opts?: ?Object): void - declare export function isTSParameterProperty(node: ?Object, opts?: ?Object): boolean %checks (node instanceof BabelNodeTSParameterProperty) - declare export function assertTSParameterProperty(node: ?Object, opts?: ?Object): void - declare export function isTSDeclareFunction(node: ?Object, opts?: ?Object): boolean %checks (node instanceof BabelNodeTSDeclareFunction) - declare export function assertTSDeclareFunction(node: ?Object, opts?: ?Object): void - declare export function isTSDeclareMethod(node: ?Object, opts?: ?Object): boolean %checks (node instanceof BabelNodeTSDeclareMethod) - declare export function assertTSDeclareMethod(node: ?Object, opts?: ?Object): void - declare export function isTSQualifiedName(node: ?Object, opts?: ?Object): boolean %checks (node instanceof BabelNodeTSQualifiedName) - declare export function assertTSQualifiedName(node: ?Object, opts?: ?Object): void - declare export function isTSCallSignatureDeclaration(node: ?Object, opts?: ?Object): boolean %checks (node instanceof BabelNodeTSCallSignatureDeclaration) - declare export function assertTSCallSignatureDeclaration(node: ?Object, opts?: ?Object): void - declare export function isTSConstructSignatureDeclaration(node: ?Object, opts?: ?Object): boolean %checks (node instanceof BabelNodeTSConstructSignatureDeclaration) - declare export function assertTSConstructSignatureDeclaration(node: ?Object, opts?: ?Object): void - declare export function isTSPropertySignature(node: ?Object, opts?: ?Object): boolean %checks (node instanceof BabelNodeTSPropertySignature) - declare export function assertTSPropertySignature(node: ?Object, opts?: ?Object): void - declare export function isTSMethodSignature(node: ?Object, opts?: ?Object): boolean %checks (node instanceof BabelNodeTSMethodSignature) - declare export function assertTSMethodSignature(node: ?Object, opts?: ?Object): void - declare export function isTSIndexSignature(node: ?Object, opts?: ?Object): boolean %checks (node instanceof BabelNodeTSIndexSignature) - declare export function assertTSIndexSignature(node: ?Object, opts?: ?Object): void - declare export function isTSAnyKeyword(node: ?Object, opts?: ?Object): boolean %checks (node instanceof BabelNodeTSAnyKeyword) - declare export function assertTSAnyKeyword(node: ?Object, opts?: ?Object): void - declare export function isTSBooleanKeyword(node: ?Object, opts?: ?Object): boolean %checks (node instanceof BabelNodeTSBooleanKeyword) - declare export function assertTSBooleanKeyword(node: ?Object, opts?: ?Object): void - declare export function isTSBigIntKeyword(node: ?Object, opts?: ?Object): boolean %checks (node instanceof BabelNodeTSBigIntKeyword) - declare export function assertTSBigIntKeyword(node: ?Object, opts?: ?Object): void - declare export function isTSIntrinsicKeyword(node: ?Object, opts?: ?Object): boolean %checks (node instanceof BabelNodeTSIntrinsicKeyword) - declare export function assertTSIntrinsicKeyword(node: ?Object, opts?: ?Object): void - declare export function isTSNeverKeyword(node: ?Object, opts?: ?Object): boolean %checks (node instanceof BabelNodeTSNeverKeyword) - declare export function assertTSNeverKeyword(node: ?Object, opts?: ?Object): void - declare export function isTSNullKeyword(node: ?Object, opts?: ?Object): boolean %checks (node instanceof BabelNodeTSNullKeyword) - declare export function assertTSNullKeyword(node: ?Object, opts?: ?Object): void - declare export function isTSNumberKeyword(node: ?Object, opts?: ?Object): boolean %checks (node instanceof BabelNodeTSNumberKeyword) - declare export function assertTSNumberKeyword(node: ?Object, opts?: ?Object): void - declare export function isTSObjectKeyword(node: ?Object, opts?: ?Object): boolean %checks (node instanceof BabelNodeTSObjectKeyword) - declare export function assertTSObjectKeyword(node: ?Object, opts?: ?Object): void - declare export function isTSStringKeyword(node: ?Object, opts?: ?Object): boolean %checks (node instanceof BabelNodeTSStringKeyword) - declare export function assertTSStringKeyword(node: ?Object, opts?: ?Object): void - declare export function isTSSymbolKeyword(node: ?Object, opts?: ?Object): boolean %checks (node instanceof BabelNodeTSSymbolKeyword) - declare export function assertTSSymbolKeyword(node: ?Object, opts?: ?Object): void - declare export function isTSUndefinedKeyword(node: ?Object, opts?: ?Object): boolean %checks (node instanceof BabelNodeTSUndefinedKeyword) - declare export function assertTSUndefinedKeyword(node: ?Object, opts?: ?Object): void - declare export function isTSUnknownKeyword(node: ?Object, opts?: ?Object): boolean %checks (node instanceof BabelNodeTSUnknownKeyword) - declare export function assertTSUnknownKeyword(node: ?Object, opts?: ?Object): void - declare export function isTSVoidKeyword(node: ?Object, opts?: ?Object): boolean %checks (node instanceof BabelNodeTSVoidKeyword) - declare export function assertTSVoidKeyword(node: ?Object, opts?: ?Object): void - declare export function isTSThisType(node: ?Object, opts?: ?Object): boolean %checks (node instanceof BabelNodeTSThisType) - declare export function assertTSThisType(node: ?Object, opts?: ?Object): void - declare export function isTSFunctionType(node: ?Object, opts?: ?Object): boolean %checks (node instanceof BabelNodeTSFunctionType) - declare export function assertTSFunctionType(node: ?Object, opts?: ?Object): void - declare export function isTSConstructorType(node: ?Object, opts?: ?Object): boolean %checks (node instanceof BabelNodeTSConstructorType) - declare export function assertTSConstructorType(node: ?Object, opts?: ?Object): void - declare export function isTSTypeReference(node: ?Object, opts?: ?Object): boolean %checks (node instanceof BabelNodeTSTypeReference) - declare export function assertTSTypeReference(node: ?Object, opts?: ?Object): void - declare export function isTSTypePredicate(node: ?Object, opts?: ?Object): boolean %checks (node instanceof BabelNodeTSTypePredicate) - declare export function assertTSTypePredicate(node: ?Object, opts?: ?Object): void - declare export function isTSTypeQuery(node: ?Object, opts?: ?Object): boolean %checks (node instanceof BabelNodeTSTypeQuery) - declare export function assertTSTypeQuery(node: ?Object, opts?: ?Object): void - declare export function isTSTypeLiteral(node: ?Object, opts?: ?Object): boolean %checks (node instanceof BabelNodeTSTypeLiteral) - declare export function assertTSTypeLiteral(node: ?Object, opts?: ?Object): void - declare export function isTSArrayType(node: ?Object, opts?: ?Object): boolean %checks (node instanceof BabelNodeTSArrayType) - declare export function assertTSArrayType(node: ?Object, opts?: ?Object): void - declare export function isTSTupleType(node: ?Object, opts?: ?Object): boolean %checks (node instanceof BabelNodeTSTupleType) - declare export function assertTSTupleType(node: ?Object, opts?: ?Object): void - declare export function isTSOptionalType(node: ?Object, opts?: ?Object): boolean %checks (node instanceof BabelNodeTSOptionalType) - declare export function assertTSOptionalType(node: ?Object, opts?: ?Object): void - declare export function isTSRestType(node: ?Object, opts?: ?Object): boolean %checks (node instanceof BabelNodeTSRestType) - declare export function assertTSRestType(node: ?Object, opts?: ?Object): void - declare export function isTSNamedTupleMember(node: ?Object, opts?: ?Object): boolean %checks (node instanceof BabelNodeTSNamedTupleMember) - declare export function assertTSNamedTupleMember(node: ?Object, opts?: ?Object): void - declare export function isTSUnionType(node: ?Object, opts?: ?Object): boolean %checks (node instanceof BabelNodeTSUnionType) - declare export function assertTSUnionType(node: ?Object, opts?: ?Object): void - declare export function isTSIntersectionType(node: ?Object, opts?: ?Object): boolean %checks (node instanceof BabelNodeTSIntersectionType) - declare export function assertTSIntersectionType(node: ?Object, opts?: ?Object): void - declare export function isTSConditionalType(node: ?Object, opts?: ?Object): boolean %checks (node instanceof BabelNodeTSConditionalType) - declare export function assertTSConditionalType(node: ?Object, opts?: ?Object): void - declare export function isTSInferType(node: ?Object, opts?: ?Object): boolean %checks (node instanceof BabelNodeTSInferType) - declare export function assertTSInferType(node: ?Object, opts?: ?Object): void - declare export function isTSParenthesizedType(node: ?Object, opts?: ?Object): boolean %checks (node instanceof BabelNodeTSParenthesizedType) - declare export function assertTSParenthesizedType(node: ?Object, opts?: ?Object): void - declare export function isTSTypeOperator(node: ?Object, opts?: ?Object): boolean %checks (node instanceof BabelNodeTSTypeOperator) - declare export function assertTSTypeOperator(node: ?Object, opts?: ?Object): void - declare export function isTSIndexedAccessType(node: ?Object, opts?: ?Object): boolean %checks (node instanceof BabelNodeTSIndexedAccessType) - declare export function assertTSIndexedAccessType(node: ?Object, opts?: ?Object): void - declare export function isTSMappedType(node: ?Object, opts?: ?Object): boolean %checks (node instanceof BabelNodeTSMappedType) - declare export function assertTSMappedType(node: ?Object, opts?: ?Object): void - declare export function isTSLiteralType(node: ?Object, opts?: ?Object): boolean %checks (node instanceof BabelNodeTSLiteralType) - declare export function assertTSLiteralType(node: ?Object, opts?: ?Object): void - declare export function isTSExpressionWithTypeArguments(node: ?Object, opts?: ?Object): boolean %checks (node instanceof BabelNodeTSExpressionWithTypeArguments) - declare export function assertTSExpressionWithTypeArguments(node: ?Object, opts?: ?Object): void - declare export function isTSInterfaceDeclaration(node: ?Object, opts?: ?Object): boolean %checks (node instanceof BabelNodeTSInterfaceDeclaration) - declare export function assertTSInterfaceDeclaration(node: ?Object, opts?: ?Object): void - declare export function isTSInterfaceBody(node: ?Object, opts?: ?Object): boolean %checks (node instanceof BabelNodeTSInterfaceBody) - declare export function assertTSInterfaceBody(node: ?Object, opts?: ?Object): void - declare export function isTSTypeAliasDeclaration(node: ?Object, opts?: ?Object): boolean %checks (node instanceof BabelNodeTSTypeAliasDeclaration) - declare export function assertTSTypeAliasDeclaration(node: ?Object, opts?: ?Object): void - declare export function isTSInstantiationExpression(node: ?Object, opts?: ?Object): boolean %checks (node instanceof BabelNodeTSInstantiationExpression) - declare export function assertTSInstantiationExpression(node: ?Object, opts?: ?Object): void - declare export function isTSAsExpression(node: ?Object, opts?: ?Object): boolean %checks (node instanceof BabelNodeTSAsExpression) - declare export function assertTSAsExpression(node: ?Object, opts?: ?Object): void - declare export function isTSSatisfiesExpression(node: ?Object, opts?: ?Object): boolean %checks (node instanceof BabelNodeTSSatisfiesExpression) - declare export function assertTSSatisfiesExpression(node: ?Object, opts?: ?Object): void - declare export function isTSTypeAssertion(node: ?Object, opts?: ?Object): boolean %checks (node instanceof BabelNodeTSTypeAssertion) - declare export function assertTSTypeAssertion(node: ?Object, opts?: ?Object): void - declare export function isTSEnumDeclaration(node: ?Object, opts?: ?Object): boolean %checks (node instanceof BabelNodeTSEnumDeclaration) - declare export function assertTSEnumDeclaration(node: ?Object, opts?: ?Object): void - declare export function isTSEnumMember(node: ?Object, opts?: ?Object): boolean %checks (node instanceof BabelNodeTSEnumMember) - declare export function assertTSEnumMember(node: ?Object, opts?: ?Object): void - declare export function isTSModuleDeclaration(node: ?Object, opts?: ?Object): boolean %checks (node instanceof BabelNodeTSModuleDeclaration) - declare export function assertTSModuleDeclaration(node: ?Object, opts?: ?Object): void - declare export function isTSModuleBlock(node: ?Object, opts?: ?Object): boolean %checks (node instanceof BabelNodeTSModuleBlock) - declare export function assertTSModuleBlock(node: ?Object, opts?: ?Object): void - declare export function isTSImportType(node: ?Object, opts?: ?Object): boolean %checks (node instanceof BabelNodeTSImportType) - declare export function assertTSImportType(node: ?Object, opts?: ?Object): void - declare export function isTSImportEqualsDeclaration(node: ?Object, opts?: ?Object): boolean %checks (node instanceof BabelNodeTSImportEqualsDeclaration) - declare export function assertTSImportEqualsDeclaration(node: ?Object, opts?: ?Object): void - declare export function isTSExternalModuleReference(node: ?Object, opts?: ?Object): boolean %checks (node instanceof BabelNodeTSExternalModuleReference) - declare export function assertTSExternalModuleReference(node: ?Object, opts?: ?Object): void - declare export function isTSNonNullExpression(node: ?Object, opts?: ?Object): boolean %checks (node instanceof BabelNodeTSNonNullExpression) - declare export function assertTSNonNullExpression(node: ?Object, opts?: ?Object): void - declare export function isTSExportAssignment(node: ?Object, opts?: ?Object): boolean %checks (node instanceof BabelNodeTSExportAssignment) - declare export function assertTSExportAssignment(node: ?Object, opts?: ?Object): void - declare export function isTSNamespaceExportDeclaration(node: ?Object, opts?: ?Object): boolean %checks (node instanceof BabelNodeTSNamespaceExportDeclaration) - declare export function assertTSNamespaceExportDeclaration(node: ?Object, opts?: ?Object): void - declare export function isTSTypeAnnotation(node: ?Object, opts?: ?Object): boolean %checks (node instanceof BabelNodeTSTypeAnnotation) - declare export function assertTSTypeAnnotation(node: ?Object, opts?: ?Object): void - declare export function isTSTypeParameterInstantiation(node: ?Object, opts?: ?Object): boolean %checks (node instanceof BabelNodeTSTypeParameterInstantiation) - declare export function assertTSTypeParameterInstantiation(node: ?Object, opts?: ?Object): void - declare export function isTSTypeParameterDeclaration(node: ?Object, opts?: ?Object): boolean %checks (node instanceof BabelNodeTSTypeParameterDeclaration) - declare export function assertTSTypeParameterDeclaration(node: ?Object, opts?: ?Object): void - declare export function isTSTypeParameter(node: ?Object, opts?: ?Object): boolean %checks (node instanceof BabelNodeTSTypeParameter) - declare export function assertTSTypeParameter(node: ?Object, opts?: ?Object): void - declare export function isStandardized(node: ?Object, opts?: ?Object): boolean - declare export function assertStandardized(node: ?Object, opts?: ?Object): void - declare export function isExpression(node: ?Object, opts?: ?Object): boolean - declare export function assertExpression(node: ?Object, opts?: ?Object): void - declare export function isBinary(node: ?Object, opts?: ?Object): boolean - declare export function assertBinary(node: ?Object, opts?: ?Object): void - declare export function isScopable(node: ?Object, opts?: ?Object): boolean - declare export function assertScopable(node: ?Object, opts?: ?Object): void - declare export function isBlockParent(node: ?Object, opts?: ?Object): boolean - declare export function assertBlockParent(node: ?Object, opts?: ?Object): void - declare export function isBlock(node: ?Object, opts?: ?Object): boolean - declare export function assertBlock(node: ?Object, opts?: ?Object): void - declare export function isStatement(node: ?Object, opts?: ?Object): boolean - declare export function assertStatement(node: ?Object, opts?: ?Object): void - declare export function isTerminatorless(node: ?Object, opts?: ?Object): boolean - declare export function assertTerminatorless(node: ?Object, opts?: ?Object): void - declare export function isCompletionStatement(node: ?Object, opts?: ?Object): boolean - declare export function assertCompletionStatement(node: ?Object, opts?: ?Object): void - declare export function isConditional(node: ?Object, opts?: ?Object): boolean - declare export function assertConditional(node: ?Object, opts?: ?Object): void - declare export function isLoop(node: ?Object, opts?: ?Object): boolean - declare export function assertLoop(node: ?Object, opts?: ?Object): void - declare export function isWhile(node: ?Object, opts?: ?Object): boolean - declare export function assertWhile(node: ?Object, opts?: ?Object): void - declare export function isExpressionWrapper(node: ?Object, opts?: ?Object): boolean - declare export function assertExpressionWrapper(node: ?Object, opts?: ?Object): void - declare export function isFor(node: ?Object, opts?: ?Object): boolean - declare export function assertFor(node: ?Object, opts?: ?Object): void - declare export function isForXStatement(node: ?Object, opts?: ?Object): boolean - declare export function assertForXStatement(node: ?Object, opts?: ?Object): void - declare export function isFunction(node: ?Object, opts?: ?Object): boolean - declare export function assertFunction(node: ?Object, opts?: ?Object): void - declare export function isFunctionParent(node: ?Object, opts?: ?Object): boolean - declare export function assertFunctionParent(node: ?Object, opts?: ?Object): void - declare export function isPureish(node: ?Object, opts?: ?Object): boolean - declare export function assertPureish(node: ?Object, opts?: ?Object): void - declare export function isDeclaration(node: ?Object, opts?: ?Object): boolean - declare export function assertDeclaration(node: ?Object, opts?: ?Object): void - declare export function isPatternLike(node: ?Object, opts?: ?Object): boolean - declare export function assertPatternLike(node: ?Object, opts?: ?Object): void - declare export function isLVal(node: ?Object, opts?: ?Object): boolean - declare export function assertLVal(node: ?Object, opts?: ?Object): void - declare export function isTSEntityName(node: ?Object, opts?: ?Object): boolean - declare export function assertTSEntityName(node: ?Object, opts?: ?Object): void - declare export function isLiteral(node: ?Object, opts?: ?Object): boolean - declare export function assertLiteral(node: ?Object, opts?: ?Object): void - declare export function isImmutable(node: ?Object, opts?: ?Object): boolean - declare export function assertImmutable(node: ?Object, opts?: ?Object): void - declare export function isUserWhitespacable(node: ?Object, opts?: ?Object): boolean - declare export function assertUserWhitespacable(node: ?Object, opts?: ?Object): void - declare export function isMethod(node: ?Object, opts?: ?Object): boolean - declare export function assertMethod(node: ?Object, opts?: ?Object): void - declare export function isObjectMember(node: ?Object, opts?: ?Object): boolean - declare export function assertObjectMember(node: ?Object, opts?: ?Object): void - declare export function isProperty(node: ?Object, opts?: ?Object): boolean - declare export function assertProperty(node: ?Object, opts?: ?Object): void - declare export function isUnaryLike(node: ?Object, opts?: ?Object): boolean - declare export function assertUnaryLike(node: ?Object, opts?: ?Object): void - declare export function isPattern(node: ?Object, opts?: ?Object): boolean - declare export function assertPattern(node: ?Object, opts?: ?Object): void - declare export function isClass(node: ?Object, opts?: ?Object): boolean - declare export function assertClass(node: ?Object, opts?: ?Object): void - declare export function isImportOrExportDeclaration(node: ?Object, opts?: ?Object): boolean - declare export function assertImportOrExportDeclaration(node: ?Object, opts?: ?Object): void - declare export function isExportDeclaration(node: ?Object, opts?: ?Object): boolean - declare export function assertExportDeclaration(node: ?Object, opts?: ?Object): void - declare export function isModuleSpecifier(node: ?Object, opts?: ?Object): boolean - declare export function assertModuleSpecifier(node: ?Object, opts?: ?Object): void - declare export function isAccessor(node: ?Object, opts?: ?Object): boolean - declare export function assertAccessor(node: ?Object, opts?: ?Object): void - declare export function isPrivate(node: ?Object, opts?: ?Object): boolean - declare export function assertPrivate(node: ?Object, opts?: ?Object): void - declare export function isFlow(node: ?Object, opts?: ?Object): boolean - declare export function assertFlow(node: ?Object, opts?: ?Object): void - declare export function isFlowType(node: ?Object, opts?: ?Object): boolean - declare export function assertFlowType(node: ?Object, opts?: ?Object): void - declare export function isFlowBaseAnnotation(node: ?Object, opts?: ?Object): boolean - declare export function assertFlowBaseAnnotation(node: ?Object, opts?: ?Object): void - declare export function isFlowDeclaration(node: ?Object, opts?: ?Object): boolean - declare export function assertFlowDeclaration(node: ?Object, opts?: ?Object): void - declare export function isFlowPredicate(node: ?Object, opts?: ?Object): boolean - declare export function assertFlowPredicate(node: ?Object, opts?: ?Object): void - declare export function isEnumBody(node: ?Object, opts?: ?Object): boolean - declare export function assertEnumBody(node: ?Object, opts?: ?Object): void - declare export function isEnumMember(node: ?Object, opts?: ?Object): boolean - declare export function assertEnumMember(node: ?Object, opts?: ?Object): void - declare export function isJSX(node: ?Object, opts?: ?Object): boolean - declare export function assertJSX(node: ?Object, opts?: ?Object): void - declare export function isMiscellaneous(node: ?Object, opts?: ?Object): boolean - declare export function assertMiscellaneous(node: ?Object, opts?: ?Object): void - declare export function isTypeScript(node: ?Object, opts?: ?Object): boolean - declare export function assertTypeScript(node: ?Object, opts?: ?Object): void - declare export function isTSTypeElement(node: ?Object, opts?: ?Object): boolean - declare export function assertTSTypeElement(node: ?Object, opts?: ?Object): void - declare export function isTSType(node: ?Object, opts?: ?Object): boolean - declare export function assertTSType(node: ?Object, opts?: ?Object): void - declare export function isTSBaseType(node: ?Object, opts?: ?Object): boolean - declare export function assertTSBaseType(node: ?Object, opts?: ?Object): void - declare export function isModuleDeclaration(node: ?Object, opts?: ?Object): boolean - declare export function assertModuleDeclaration(node: ?Object, opts?: ?Object): void - declare export function isNumberLiteral(node: ?Object, opts?: ?Object): boolean %checks (node instanceof BabelNodeNumericLiteral) - declare export function assertNumberLiteral(node: ?Object, opts?: ?Object): void - declare export function isRegexLiteral(node: ?Object, opts?: ?Object): boolean %checks (node instanceof BabelNodeRegExpLiteral) - declare export function assertRegexLiteral(node: ?Object, opts?: ?Object): void - declare export function isRestProperty(node: ?Object, opts?: ?Object): boolean %checks (node instanceof BabelNodeRestElement) - declare export function assertRestProperty(node: ?Object, opts?: ?Object): void - declare export function isSpreadProperty(node: ?Object, opts?: ?Object): boolean %checks (node instanceof BabelNodeSpreadElement) - declare export function assertSpreadProperty(node: ?Object, opts?: ?Object): void - declare export var VISITOR_KEYS: { [type: string]: string[] } - declare export function assertNode(obj: any): void - declare export function createTypeAnnotationBasedOnTypeof(type: 'string' | 'number' | 'undefined' | 'boolean' | 'function' | 'object' | 'symbol'): BabelNodeTypeAnnotation - declare export function createUnionTypeAnnotation(types: Array): BabelNodeUnionTypeAnnotation - declare export function createFlowUnionType(types: Array): BabelNodeUnionTypeAnnotation - declare export function buildChildren(node: { children: Array }): Array - declare export function clone(n: T): T; - declare export function cloneDeep(n: T): T; - declare export function cloneDeepWithoutLoc(n: T): T; - declare export function cloneNode(n: T, deep?: boolean, withoutLoc?: boolean): T; - declare export function cloneWithoutLoc(n: T): T; - declare type CommentTypeShorthand = 'leading' | 'inner' | 'trailing' - declare export function addComment(node: T, type: CommentTypeShorthand, content: string, line?: boolean): T - declare export function addComments(node: T, type: CommentTypeShorthand, comments: Array): T - declare export function inheritInnerComments(node: BabelNode, parent: BabelNode): void - declare export function inheritLeadingComments(node: BabelNode, parent: BabelNode): void - declare export function inheritsComments(node: T, parent: BabelNode): void - declare export function inheritTrailingComments(node: BabelNode, parent: BabelNode): void - declare export function removeComments(node: T): T - declare export function ensureBlock(node: BabelNode, key: string): BabelNodeBlockStatement - declare export function toBindingIdentifierName(name?: ?string): string - declare export function toBlock(node: BabelNodeStatement | BabelNodeExpression, parent?: BabelNodeFunction | null): BabelNodeBlockStatement - declare export function toComputedKey(node: BabelNodeMethod | BabelNodeProperty, key?: BabelNodeExpression | BabelNodeIdentifier): BabelNodeExpression - declare export function toExpression(node: BabelNodeExpressionStatement | BabelNodeExpression | BabelNodeClass | BabelNodeFunction): BabelNodeExpression - declare export function toIdentifier(name?: ?string): string - declare export function toKeyAlias(node: BabelNodeMethod | BabelNodeProperty, key?: BabelNode): string - declare export function toStatement(node: BabelNodeStatement | BabelNodeClass | BabelNodeFunction | BabelNodeAssignmentExpression, ignore?: boolean): BabelNodeStatement | void - declare export function valueToNode(value: any): BabelNodeExpression - declare export function removeTypeDuplicates(types: Array): Array - declare export function appendToMemberExpression(member: BabelNodeMemberExpression, append: BabelNode, computed?: boolean): BabelNodeMemberExpression - declare export function inherits(child: T, parent: BabelNode | null | void): T - declare export function prependToMemberExpression(member: BabelNodeMemberExpression, prepend: BabelNodeExpression): BabelNodeMemberExpression - declare export function removeProperties(n: T, opts: ?{}): void; - declare export function removePropertiesDeep(n: T, opts: ?{}): T; - declare export var getBindingIdentifiers: { - (node: BabelNode, duplicates?: boolean, outerOnly?: boolean): { [key: string]: BabelNodeIdentifier | Array }, - keys: { [type: string]: string[] } - } - declare export function getOuterBindingIdentifiers(node: BabelNode, duplicates?: boolean): { [key: string]: BabelNodeIdentifier | Array } - declare type TraversalAncestors = Array<{ - node: BabelNode, - key: string, - index?: number, - }>; - declare type TraversalHandler = (BabelNode, TraversalAncestors, T) => void; - declare type TraversalHandlers = { - enter?: TraversalHandler, - exit?: TraversalHandler, - }; - declare export function traverse(n: BabelNode, TraversalHandler | TraversalHandlers, state?: T): void; - declare export function traverseFast(n: BabelNode, h: TraversalHandler, state?: T): void; - declare export function shallowEqual(actual: Object, expected: Object): boolean - declare export function buildMatchMemberExpression(match: string, allowPartial?: boolean): (?BabelNode) => boolean - declare export function is(type: string, n: BabelNode, opts: Object): boolean; - declare export function isBinding(node: BabelNode, parent: BabelNode, grandparent?: BabelNode): boolean - declare export function isBlockScoped(node: BabelNode): boolean - declare export function isImmutable(node: BabelNode): boolean - declare export function isLet(node: BabelNode): boolean - declare export function isNode(node: ?Object): boolean - declare export function isNodesEquivalent(a: any, b: any): boolean - declare export function isPlaceholderType(placeholderType: string, targetType: string): boolean - declare export function isReferenced(node: BabelNode, parent: BabelNode, grandparent?: BabelNode): boolean - declare export function isScope(node: BabelNode, parent: BabelNode): boolean - declare export function isSpecifierDefault(specifier: BabelNodeModuleSpecifier): boolean - declare export function isType(nodetype: ?string, targetType: string): boolean - declare export function isValidES3Identifier(name: string): boolean - declare export function isValidES3Identifier(name: string): boolean - declare export function isValidIdentifier(name: string): boolean - declare export function isVar(node: BabelNode): boolean - declare export function matchesPattern(node: ?BabelNode, match: string | Array, allowPartial?: boolean): boolean - declare export function validate(n: BabelNode, key: string, value: mixed): void; -} \ No newline at end of file diff --git a/tools/eslint/node_modules/@babel/types/lib/modifications/appendToMemberExpression.js b/tools/eslint/node_modules/@babel/types/lib/modifications/appendToMemberExpression.js deleted file mode 100644 index 48ff2a2aeb0753..00000000000000 --- a/tools/eslint/node_modules/@babel/types/lib/modifications/appendToMemberExpression.js +++ /dev/null @@ -1,15 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.default = appendToMemberExpression; -var _index = require("../builders/generated/index.js"); -function appendToMemberExpression(member, append, computed = false) { - member.object = (0, _index.memberExpression)(member.object, member.property, member.computed); - member.property = append; - member.computed = !!computed; - return member; -} - -//# sourceMappingURL=appendToMemberExpression.js.map diff --git a/tools/eslint/node_modules/@babel/types/lib/modifications/flow/removeTypeDuplicates.js b/tools/eslint/node_modules/@babel/types/lib/modifications/flow/removeTypeDuplicates.js deleted file mode 100644 index edbdd8bacd312f..00000000000000 --- a/tools/eslint/node_modules/@babel/types/lib/modifications/flow/removeTypeDuplicates.js +++ /dev/null @@ -1,65 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.default = removeTypeDuplicates; -var _index = require("../../validators/generated/index.js"); -function getQualifiedName(node) { - return (0, _index.isIdentifier)(node) ? node.name : `${node.id.name}.${getQualifiedName(node.qualification)}`; -} -function removeTypeDuplicates(nodesIn) { - const nodes = Array.from(nodesIn); - const generics = new Map(); - const bases = new Map(); - const typeGroups = new Set(); - const types = []; - for (let i = 0; i < nodes.length; i++) { - const node = nodes[i]; - if (!node) continue; - if (types.includes(node)) { - continue; - } - if ((0, _index.isAnyTypeAnnotation)(node)) { - return [node]; - } - if ((0, _index.isFlowBaseAnnotation)(node)) { - bases.set(node.type, node); - continue; - } - if ((0, _index.isUnionTypeAnnotation)(node)) { - if (!typeGroups.has(node.types)) { - nodes.push(...node.types); - typeGroups.add(node.types); - } - continue; - } - if ((0, _index.isGenericTypeAnnotation)(node)) { - const name = getQualifiedName(node.id); - if (generics.has(name)) { - let existing = generics.get(name); - if (existing.typeParameters) { - if (node.typeParameters) { - existing.typeParameters.params.push(...node.typeParameters.params); - existing.typeParameters.params = removeTypeDuplicates(existing.typeParameters.params); - } - } else { - existing = node.typeParameters; - } - } else { - generics.set(name, node); - } - continue; - } - types.push(node); - } - for (const [, baseType] of bases) { - types.push(baseType); - } - for (const [, genericName] of generics) { - types.push(genericName); - } - return types; -} - -//# sourceMappingURL=removeTypeDuplicates.js.map diff --git a/tools/eslint/node_modules/@babel/types/lib/modifications/inherits.js b/tools/eslint/node_modules/@babel/types/lib/modifications/inherits.js deleted file mode 100644 index cea0a9c2253999..00000000000000 --- a/tools/eslint/node_modules/@babel/types/lib/modifications/inherits.js +++ /dev/null @@ -1,28 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.default = inherits; -var _index = require("../constants/index.js"); -var _inheritsComments = require("../comments/inheritsComments.js"); -function inherits(child, parent) { - if (!child || !parent) return child; - for (const key of _index.INHERIT_KEYS.optional) { - if (child[key] == null) { - child[key] = parent[key]; - } - } - for (const key of Object.keys(parent)) { - if (key[0] === "_" && key !== "__clone") { - child[key] = parent[key]; - } - } - for (const key of _index.INHERIT_KEYS.force) { - child[key] = parent[key]; - } - (0, _inheritsComments.default)(child, parent); - return child; -} - -//# sourceMappingURL=inherits.js.map diff --git a/tools/eslint/node_modules/@babel/types/lib/modifications/prependToMemberExpression.js b/tools/eslint/node_modules/@babel/types/lib/modifications/prependToMemberExpression.js deleted file mode 100644 index d86e70add32e11..00000000000000 --- a/tools/eslint/node_modules/@babel/types/lib/modifications/prependToMemberExpression.js +++ /dev/null @@ -1,17 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.default = prependToMemberExpression; -var _index = require("../builders/generated/index.js"); -var _index2 = require("../index.js"); -function prependToMemberExpression(member, prepend) { - if ((0, _index2.isSuper)(member.object)) { - throw new Error("Cannot prepend node to super property access (`super.foo`)."); - } - member.object = (0, _index.memberExpression)(prepend, member.object); - return member; -} - -//# sourceMappingURL=prependToMemberExpression.js.map diff --git a/tools/eslint/node_modules/@babel/types/lib/modifications/removeProperties.js b/tools/eslint/node_modules/@babel/types/lib/modifications/removeProperties.js deleted file mode 100644 index d3cbf16efe7fcc..00000000000000 --- a/tools/eslint/node_modules/@babel/types/lib/modifications/removeProperties.js +++ /dev/null @@ -1,24 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.default = removeProperties; -var _index = require("../constants/index.js"); -const CLEAR_KEYS = ["tokens", "start", "end", "loc", "raw", "rawValue"]; -const CLEAR_KEYS_PLUS_COMMENTS = [..._index.COMMENT_KEYS, "comments", ...CLEAR_KEYS]; -function removeProperties(node, opts = {}) { - const map = opts.preserveComments ? CLEAR_KEYS : CLEAR_KEYS_PLUS_COMMENTS; - for (const key of map) { - if (node[key] != null) node[key] = undefined; - } - for (const key of Object.keys(node)) { - if (key[0] === "_" && node[key] != null) node[key] = undefined; - } - const symbols = Object.getOwnPropertySymbols(node); - for (const sym of symbols) { - node[sym] = null; - } -} - -//# sourceMappingURL=removeProperties.js.map diff --git a/tools/eslint/node_modules/@babel/types/lib/modifications/removePropertiesDeep.js b/tools/eslint/node_modules/@babel/types/lib/modifications/removePropertiesDeep.js deleted file mode 100644 index 58a9a0074f76eb..00000000000000 --- a/tools/eslint/node_modules/@babel/types/lib/modifications/removePropertiesDeep.js +++ /dev/null @@ -1,14 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.default = removePropertiesDeep; -var _traverseFast = require("../traverse/traverseFast.js"); -var _removeProperties = require("./removeProperties.js"); -function removePropertiesDeep(tree, opts) { - (0, _traverseFast.default)(tree, _removeProperties.default, opts); - return tree; -} - -//# sourceMappingURL=removePropertiesDeep.js.map diff --git a/tools/eslint/node_modules/@babel/types/lib/modifications/typescript/removeTypeDuplicates.js b/tools/eslint/node_modules/@babel/types/lib/modifications/typescript/removeTypeDuplicates.js deleted file mode 100644 index a30fb668c3067c..00000000000000 --- a/tools/eslint/node_modules/@babel/types/lib/modifications/typescript/removeTypeDuplicates.js +++ /dev/null @@ -1,65 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.default = removeTypeDuplicates; -var _index = require("../../validators/generated/index.js"); -function getQualifiedName(node) { - return (0, _index.isIdentifier)(node) ? node.name : `${node.right.name}.${getQualifiedName(node.left)}`; -} -function removeTypeDuplicates(nodesIn) { - const nodes = Array.from(nodesIn); - const generics = new Map(); - const bases = new Map(); - const typeGroups = new Set(); - const types = []; - for (let i = 0; i < nodes.length; i++) { - const node = nodes[i]; - if (!node) continue; - if (types.includes(node)) { - continue; - } - if ((0, _index.isTSAnyKeyword)(node)) { - return [node]; - } - if ((0, _index.isTSBaseType)(node)) { - bases.set(node.type, node); - continue; - } - if ((0, _index.isTSUnionType)(node)) { - if (!typeGroups.has(node.types)) { - nodes.push(...node.types); - typeGroups.add(node.types); - } - continue; - } - if ((0, _index.isTSTypeReference)(node) && node.typeParameters) { - const name = getQualifiedName(node.typeName); - if (generics.has(name)) { - let existing = generics.get(name); - if (existing.typeParameters) { - if (node.typeParameters) { - existing.typeParameters.params.push(...node.typeParameters.params); - existing.typeParameters.params = removeTypeDuplicates(existing.typeParameters.params); - } - } else { - existing = node.typeParameters; - } - } else { - generics.set(name, node); - } - continue; - } - types.push(node); - } - for (const [, baseType] of bases) { - types.push(baseType); - } - for (const [, genericName] of generics) { - types.push(genericName); - } - return types; -} - -//# sourceMappingURL=removeTypeDuplicates.js.map diff --git a/tools/eslint/node_modules/@babel/types/lib/retrievers/getBindingIdentifiers.js b/tools/eslint/node_modules/@babel/types/lib/retrievers/getBindingIdentifiers.js deleted file mode 100644 index 31feb1e7a18814..00000000000000 --- a/tools/eslint/node_modules/@babel/types/lib/retrievers/getBindingIdentifiers.js +++ /dev/null @@ -1,101 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.default = getBindingIdentifiers; -var _index = require("../validators/generated/index.js"); -function getBindingIdentifiers(node, duplicates, outerOnly, newBindingsOnly) { - const search = [].concat(node); - const ids = Object.create(null); - while (search.length) { - const id = search.shift(); - if (!id) continue; - if (newBindingsOnly && ((0, _index.isAssignmentExpression)(id) || (0, _index.isUnaryExpression)(id) || (0, _index.isUpdateExpression)(id))) { - continue; - } - if ((0, _index.isIdentifier)(id)) { - if (duplicates) { - const _ids = ids[id.name] = ids[id.name] || []; - _ids.push(id); - } else { - ids[id.name] = id; - } - continue; - } - if ((0, _index.isExportDeclaration)(id) && !(0, _index.isExportAllDeclaration)(id)) { - if ((0, _index.isDeclaration)(id.declaration)) { - search.push(id.declaration); - } - continue; - } - if (outerOnly) { - if ((0, _index.isFunctionDeclaration)(id)) { - search.push(id.id); - continue; - } - if ((0, _index.isFunctionExpression)(id)) { - continue; - } - } - const keys = getBindingIdentifiers.keys[id.type]; - if (keys) { - for (let i = 0; i < keys.length; i++) { - const key = keys[i]; - const nodes = id[key]; - if (nodes) { - if (Array.isArray(nodes)) { - search.push(...nodes); - } else { - search.push(nodes); - } - } - } - } - } - return ids; -} -const keys = { - DeclareClass: ["id"], - DeclareFunction: ["id"], - DeclareModule: ["id"], - DeclareVariable: ["id"], - DeclareInterface: ["id"], - DeclareTypeAlias: ["id"], - DeclareOpaqueType: ["id"], - InterfaceDeclaration: ["id"], - TypeAlias: ["id"], - OpaqueType: ["id"], - CatchClause: ["param"], - LabeledStatement: ["label"], - UnaryExpression: ["argument"], - AssignmentExpression: ["left"], - ImportSpecifier: ["local"], - ImportNamespaceSpecifier: ["local"], - ImportDefaultSpecifier: ["local"], - ImportDeclaration: ["specifiers"], - ExportSpecifier: ["exported"], - ExportNamespaceSpecifier: ["exported"], - ExportDefaultSpecifier: ["exported"], - FunctionDeclaration: ["id", "params"], - FunctionExpression: ["id", "params"], - ArrowFunctionExpression: ["params"], - ObjectMethod: ["params"], - ClassMethod: ["params"], - ClassPrivateMethod: ["params"], - ForInStatement: ["left"], - ForOfStatement: ["left"], - ClassDeclaration: ["id"], - ClassExpression: ["id"], - RestElement: ["argument"], - UpdateExpression: ["argument"], - ObjectProperty: ["value"], - AssignmentPattern: ["left"], - ArrayPattern: ["elements"], - ObjectPattern: ["properties"], - VariableDeclaration: ["declarations"], - VariableDeclarator: ["id"] -}; -getBindingIdentifiers.keys = keys; - -//# sourceMappingURL=getBindingIdentifiers.js.map diff --git a/tools/eslint/node_modules/@babel/types/lib/retrievers/getOuterBindingIdentifiers.js b/tools/eslint/node_modules/@babel/types/lib/retrievers/getOuterBindingIdentifiers.js deleted file mode 100644 index f51c47b5f89fea..00000000000000 --- a/tools/eslint/node_modules/@babel/types/lib/retrievers/getOuterBindingIdentifiers.js +++ /dev/null @@ -1,13 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.default = void 0; -var _getBindingIdentifiers = require("./getBindingIdentifiers.js"); -var _default = exports.default = getOuterBindingIdentifiers; -function getOuterBindingIdentifiers(node, duplicates) { - return (0, _getBindingIdentifiers.default)(node, duplicates, true); -} - -//# sourceMappingURL=getOuterBindingIdentifiers.js.map diff --git a/tools/eslint/node_modules/@babel/types/lib/traverse/traverse.js b/tools/eslint/node_modules/@babel/types/lib/traverse/traverse.js deleted file mode 100644 index 77b0c3736f94a6..00000000000000 --- a/tools/eslint/node_modules/@babel/types/lib/traverse/traverse.js +++ /dev/null @@ -1,50 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.default = traverse; -var _index = require("../definitions/index.js"); -function traverse(node, handlers, state) { - if (typeof handlers === "function") { - handlers = { - enter: handlers - }; - } - const { - enter, - exit - } = handlers; - traverseSimpleImpl(node, enter, exit, state, []); -} -function traverseSimpleImpl(node, enter, exit, state, ancestors) { - const keys = _index.VISITOR_KEYS[node.type]; - if (!keys) return; - if (enter) enter(node, ancestors, state); - for (const key of keys) { - const subNode = node[key]; - if (Array.isArray(subNode)) { - for (let i = 0; i < subNode.length; i++) { - const child = subNode[i]; - if (!child) continue; - ancestors.push({ - node, - key, - index: i - }); - traverseSimpleImpl(child, enter, exit, state, ancestors); - ancestors.pop(); - } - } else if (subNode) { - ancestors.push({ - node, - key - }); - traverseSimpleImpl(subNode, enter, exit, state, ancestors); - ancestors.pop(); - } - } - if (exit) exit(node, ancestors, state); -} - -//# sourceMappingURL=traverse.js.map diff --git a/tools/eslint/node_modules/@babel/types/lib/traverse/traverseFast.js b/tools/eslint/node_modules/@babel/types/lib/traverse/traverseFast.js deleted file mode 100644 index f618cff3b27ea5..00000000000000 --- a/tools/eslint/node_modules/@babel/types/lib/traverse/traverseFast.js +++ /dev/null @@ -1,26 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.default = traverseFast; -var _index = require("../definitions/index.js"); -function traverseFast(node, enter, opts) { - if (!node) return; - const keys = _index.VISITOR_KEYS[node.type]; - if (!keys) return; - opts = opts || {}; - enter(node, opts); - for (const key of keys) { - const subNode = node[key]; - if (Array.isArray(subNode)) { - for (const node of subNode) { - traverseFast(node, enter, opts); - } - } else { - traverseFast(subNode, enter, opts); - } - } -} - -//# sourceMappingURL=traverseFast.js.map diff --git a/tools/eslint/node_modules/@babel/types/lib/utils/deprecationWarning.js b/tools/eslint/node_modules/@babel/types/lib/utils/deprecationWarning.js deleted file mode 100644 index 358b558f8c9fef..00000000000000 --- a/tools/eslint/node_modules/@babel/types/lib/utils/deprecationWarning.js +++ /dev/null @@ -1,44 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.default = deprecationWarning; -const warnings = new Set(); -function deprecationWarning(oldName, newName, prefix = "") { - if (warnings.has(oldName)) return; - warnings.add(oldName); - const { - internal, - trace - } = captureShortStackTrace(1, 2); - if (internal) { - return; - } - console.warn(`${prefix}\`${oldName}\` has been deprecated, please migrate to \`${newName}\`\n${trace}`); -} -function captureShortStackTrace(skip, length) { - const { - stackTraceLimit, - prepareStackTrace - } = Error; - let stackTrace; - Error.stackTraceLimit = 1 + skip + length; - Error.prepareStackTrace = function (err, stack) { - stackTrace = stack; - }; - new Error().stack; - Error.stackTraceLimit = stackTraceLimit; - Error.prepareStackTrace = prepareStackTrace; - if (!stackTrace) return { - internal: false, - trace: "" - }; - const shortStackTrace = stackTrace.slice(1 + skip, 1 + skip + length); - return { - internal: /[\\/]@babel[\\/]/.test(shortStackTrace[1].getFileName()), - trace: shortStackTrace.map(frame => ` at ${frame}`).join("\n") - }; -} - -//# sourceMappingURL=deprecationWarning.js.map diff --git a/tools/eslint/node_modules/@babel/types/lib/utils/inherit.js b/tools/eslint/node_modules/@babel/types/lib/utils/inherit.js deleted file mode 100644 index 9023d2c4d9519a..00000000000000 --- a/tools/eslint/node_modules/@babel/types/lib/utils/inherit.js +++ /dev/null @@ -1,13 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.default = inherit; -function inherit(key, child, parent) { - if (child && parent) { - child[key] = Array.from(new Set([].concat(child[key], parent[key]).filter(Boolean))); - } -} - -//# sourceMappingURL=inherit.js.map diff --git a/tools/eslint/node_modules/@babel/types/lib/utils/react/cleanJSXElementLiteralChild.js b/tools/eslint/node_modules/@babel/types/lib/utils/react/cleanJSXElementLiteralChild.js deleted file mode 100644 index 0250a5bee271c5..00000000000000 --- a/tools/eslint/node_modules/@babel/types/lib/utils/react/cleanJSXElementLiteralChild.js +++ /dev/null @@ -1,40 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.default = cleanJSXElementLiteralChild; -var _index = require("../../builders/generated/index.js"); -var _index2 = require("../../index.js"); -function cleanJSXElementLiteralChild(child, args) { - const lines = child.value.split(/\r\n|\n|\r/); - let lastNonEmptyLine = 0; - for (let i = 0; i < lines.length; i++) { - if (/[^ \t]/.exec(lines[i])) { - lastNonEmptyLine = i; - } - } - let str = ""; - for (let i = 0; i < lines.length; i++) { - const line = lines[i]; - const isFirstLine = i === 0; - const isLastLine = i === lines.length - 1; - const isLastNonEmptyLine = i === lastNonEmptyLine; - let trimmedLine = line.replace(/\t/g, " "); - if (!isFirstLine) { - trimmedLine = trimmedLine.replace(/^[ ]+/, ""); - } - if (!isLastLine) { - trimmedLine = trimmedLine.replace(/[ ]+$/, ""); - } - if (trimmedLine) { - if (!isLastNonEmptyLine) { - trimmedLine += " "; - } - str += trimmedLine; - } - } - if (str) args.push((0, _index2.inherits)((0, _index.stringLiteral)(str), child)); -} - -//# sourceMappingURL=cleanJSXElementLiteralChild.js.map diff --git a/tools/eslint/node_modules/@babel/types/lib/utils/shallowEqual.js b/tools/eslint/node_modules/@babel/types/lib/utils/shallowEqual.js deleted file mode 100644 index 9a1d6c71754b3d..00000000000000 --- a/tools/eslint/node_modules/@babel/types/lib/utils/shallowEqual.js +++ /dev/null @@ -1,17 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.default = shallowEqual; -function shallowEqual(actual, expected) { - const keys = Object.keys(expected); - for (const key of keys) { - if (actual[key] !== expected[key]) { - return false; - } - } - return true; -} - -//# sourceMappingURL=shallowEqual.js.map diff --git a/tools/eslint/node_modules/@babel/types/lib/validators/buildMatchMemberExpression.js b/tools/eslint/node_modules/@babel/types/lib/validators/buildMatchMemberExpression.js deleted file mode 100644 index dcde1dbf8c9396..00000000000000 --- a/tools/eslint/node_modules/@babel/types/lib/validators/buildMatchMemberExpression.js +++ /dev/null @@ -1,13 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.default = buildMatchMemberExpression; -var _matchesPattern = require("./matchesPattern.js"); -function buildMatchMemberExpression(match, allowPartial) { - const parts = match.split("."); - return member => (0, _matchesPattern.default)(member, parts, allowPartial); -} - -//# sourceMappingURL=buildMatchMemberExpression.js.map diff --git a/tools/eslint/node_modules/@babel/types/lib/validators/generated/index.js b/tools/eslint/node_modules/@babel/types/lib/validators/generated/index.js deleted file mode 100644 index 6f8ae4c8d128c9..00000000000000 --- a/tools/eslint/node_modules/@babel/types/lib/validators/generated/index.js +++ /dev/null @@ -1,2752 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.isAccessor = isAccessor; -exports.isAnyTypeAnnotation = isAnyTypeAnnotation; -exports.isArgumentPlaceholder = isArgumentPlaceholder; -exports.isArrayExpression = isArrayExpression; -exports.isArrayPattern = isArrayPattern; -exports.isArrayTypeAnnotation = isArrayTypeAnnotation; -exports.isArrowFunctionExpression = isArrowFunctionExpression; -exports.isAssignmentExpression = isAssignmentExpression; -exports.isAssignmentPattern = isAssignmentPattern; -exports.isAwaitExpression = isAwaitExpression; -exports.isBigIntLiteral = isBigIntLiteral; -exports.isBinary = isBinary; -exports.isBinaryExpression = isBinaryExpression; -exports.isBindExpression = isBindExpression; -exports.isBlock = isBlock; -exports.isBlockParent = isBlockParent; -exports.isBlockStatement = isBlockStatement; -exports.isBooleanLiteral = isBooleanLiteral; -exports.isBooleanLiteralTypeAnnotation = isBooleanLiteralTypeAnnotation; -exports.isBooleanTypeAnnotation = isBooleanTypeAnnotation; -exports.isBreakStatement = isBreakStatement; -exports.isCallExpression = isCallExpression; -exports.isCatchClause = isCatchClause; -exports.isClass = isClass; -exports.isClassAccessorProperty = isClassAccessorProperty; -exports.isClassBody = isClassBody; -exports.isClassDeclaration = isClassDeclaration; -exports.isClassExpression = isClassExpression; -exports.isClassImplements = isClassImplements; -exports.isClassMethod = isClassMethod; -exports.isClassPrivateMethod = isClassPrivateMethod; -exports.isClassPrivateProperty = isClassPrivateProperty; -exports.isClassProperty = isClassProperty; -exports.isCompletionStatement = isCompletionStatement; -exports.isConditional = isConditional; -exports.isConditionalExpression = isConditionalExpression; -exports.isContinueStatement = isContinueStatement; -exports.isDebuggerStatement = isDebuggerStatement; -exports.isDecimalLiteral = isDecimalLiteral; -exports.isDeclaration = isDeclaration; -exports.isDeclareClass = isDeclareClass; -exports.isDeclareExportAllDeclaration = isDeclareExportAllDeclaration; -exports.isDeclareExportDeclaration = isDeclareExportDeclaration; -exports.isDeclareFunction = isDeclareFunction; -exports.isDeclareInterface = isDeclareInterface; -exports.isDeclareModule = isDeclareModule; -exports.isDeclareModuleExports = isDeclareModuleExports; -exports.isDeclareOpaqueType = isDeclareOpaqueType; -exports.isDeclareTypeAlias = isDeclareTypeAlias; -exports.isDeclareVariable = isDeclareVariable; -exports.isDeclaredPredicate = isDeclaredPredicate; -exports.isDecorator = isDecorator; -exports.isDirective = isDirective; -exports.isDirectiveLiteral = isDirectiveLiteral; -exports.isDoExpression = isDoExpression; -exports.isDoWhileStatement = isDoWhileStatement; -exports.isEmptyStatement = isEmptyStatement; -exports.isEmptyTypeAnnotation = isEmptyTypeAnnotation; -exports.isEnumBody = isEnumBody; -exports.isEnumBooleanBody = isEnumBooleanBody; -exports.isEnumBooleanMember = isEnumBooleanMember; -exports.isEnumDeclaration = isEnumDeclaration; -exports.isEnumDefaultedMember = isEnumDefaultedMember; -exports.isEnumMember = isEnumMember; -exports.isEnumNumberBody = isEnumNumberBody; -exports.isEnumNumberMember = isEnumNumberMember; -exports.isEnumStringBody = isEnumStringBody; -exports.isEnumStringMember = isEnumStringMember; -exports.isEnumSymbolBody = isEnumSymbolBody; -exports.isExistsTypeAnnotation = isExistsTypeAnnotation; -exports.isExportAllDeclaration = isExportAllDeclaration; -exports.isExportDeclaration = isExportDeclaration; -exports.isExportDefaultDeclaration = isExportDefaultDeclaration; -exports.isExportDefaultSpecifier = isExportDefaultSpecifier; -exports.isExportNamedDeclaration = isExportNamedDeclaration; -exports.isExportNamespaceSpecifier = isExportNamespaceSpecifier; -exports.isExportSpecifier = isExportSpecifier; -exports.isExpression = isExpression; -exports.isExpressionStatement = isExpressionStatement; -exports.isExpressionWrapper = isExpressionWrapper; -exports.isFile = isFile; -exports.isFlow = isFlow; -exports.isFlowBaseAnnotation = isFlowBaseAnnotation; -exports.isFlowDeclaration = isFlowDeclaration; -exports.isFlowPredicate = isFlowPredicate; -exports.isFlowType = isFlowType; -exports.isFor = isFor; -exports.isForInStatement = isForInStatement; -exports.isForOfStatement = isForOfStatement; -exports.isForStatement = isForStatement; -exports.isForXStatement = isForXStatement; -exports.isFunction = isFunction; -exports.isFunctionDeclaration = isFunctionDeclaration; -exports.isFunctionExpression = isFunctionExpression; -exports.isFunctionParent = isFunctionParent; -exports.isFunctionTypeAnnotation = isFunctionTypeAnnotation; -exports.isFunctionTypeParam = isFunctionTypeParam; -exports.isGenericTypeAnnotation = isGenericTypeAnnotation; -exports.isIdentifier = isIdentifier; -exports.isIfStatement = isIfStatement; -exports.isImmutable = isImmutable; -exports.isImport = isImport; -exports.isImportAttribute = isImportAttribute; -exports.isImportDeclaration = isImportDeclaration; -exports.isImportDefaultSpecifier = isImportDefaultSpecifier; -exports.isImportExpression = isImportExpression; -exports.isImportNamespaceSpecifier = isImportNamespaceSpecifier; -exports.isImportOrExportDeclaration = isImportOrExportDeclaration; -exports.isImportSpecifier = isImportSpecifier; -exports.isIndexedAccessType = isIndexedAccessType; -exports.isInferredPredicate = isInferredPredicate; -exports.isInterfaceDeclaration = isInterfaceDeclaration; -exports.isInterfaceExtends = isInterfaceExtends; -exports.isInterfaceTypeAnnotation = isInterfaceTypeAnnotation; -exports.isInterpreterDirective = isInterpreterDirective; -exports.isIntersectionTypeAnnotation = isIntersectionTypeAnnotation; -exports.isJSX = isJSX; -exports.isJSXAttribute = isJSXAttribute; -exports.isJSXClosingElement = isJSXClosingElement; -exports.isJSXClosingFragment = isJSXClosingFragment; -exports.isJSXElement = isJSXElement; -exports.isJSXEmptyExpression = isJSXEmptyExpression; -exports.isJSXExpressionContainer = isJSXExpressionContainer; -exports.isJSXFragment = isJSXFragment; -exports.isJSXIdentifier = isJSXIdentifier; -exports.isJSXMemberExpression = isJSXMemberExpression; -exports.isJSXNamespacedName = isJSXNamespacedName; -exports.isJSXOpeningElement = isJSXOpeningElement; -exports.isJSXOpeningFragment = isJSXOpeningFragment; -exports.isJSXSpreadAttribute = isJSXSpreadAttribute; -exports.isJSXSpreadChild = isJSXSpreadChild; -exports.isJSXText = isJSXText; -exports.isLVal = isLVal; -exports.isLabeledStatement = isLabeledStatement; -exports.isLiteral = isLiteral; -exports.isLogicalExpression = isLogicalExpression; -exports.isLoop = isLoop; -exports.isMemberExpression = isMemberExpression; -exports.isMetaProperty = isMetaProperty; -exports.isMethod = isMethod; -exports.isMiscellaneous = isMiscellaneous; -exports.isMixedTypeAnnotation = isMixedTypeAnnotation; -exports.isModuleDeclaration = isModuleDeclaration; -exports.isModuleExpression = isModuleExpression; -exports.isModuleSpecifier = isModuleSpecifier; -exports.isNewExpression = isNewExpression; -exports.isNoop = isNoop; -exports.isNullLiteral = isNullLiteral; -exports.isNullLiteralTypeAnnotation = isNullLiteralTypeAnnotation; -exports.isNullableTypeAnnotation = isNullableTypeAnnotation; -exports.isNumberLiteral = isNumberLiteral; -exports.isNumberLiteralTypeAnnotation = isNumberLiteralTypeAnnotation; -exports.isNumberTypeAnnotation = isNumberTypeAnnotation; -exports.isNumericLiteral = isNumericLiteral; -exports.isObjectExpression = isObjectExpression; -exports.isObjectMember = isObjectMember; -exports.isObjectMethod = isObjectMethod; -exports.isObjectPattern = isObjectPattern; -exports.isObjectProperty = isObjectProperty; -exports.isObjectTypeAnnotation = isObjectTypeAnnotation; -exports.isObjectTypeCallProperty = isObjectTypeCallProperty; -exports.isObjectTypeIndexer = isObjectTypeIndexer; -exports.isObjectTypeInternalSlot = isObjectTypeInternalSlot; -exports.isObjectTypeProperty = isObjectTypeProperty; -exports.isObjectTypeSpreadProperty = isObjectTypeSpreadProperty; -exports.isOpaqueType = isOpaqueType; -exports.isOptionalCallExpression = isOptionalCallExpression; -exports.isOptionalIndexedAccessType = isOptionalIndexedAccessType; -exports.isOptionalMemberExpression = isOptionalMemberExpression; -exports.isParenthesizedExpression = isParenthesizedExpression; -exports.isPattern = isPattern; -exports.isPatternLike = isPatternLike; -exports.isPipelineBareFunction = isPipelineBareFunction; -exports.isPipelinePrimaryTopicReference = isPipelinePrimaryTopicReference; -exports.isPipelineTopicExpression = isPipelineTopicExpression; -exports.isPlaceholder = isPlaceholder; -exports.isPrivate = isPrivate; -exports.isPrivateName = isPrivateName; -exports.isProgram = isProgram; -exports.isProperty = isProperty; -exports.isPureish = isPureish; -exports.isQualifiedTypeIdentifier = isQualifiedTypeIdentifier; -exports.isRecordExpression = isRecordExpression; -exports.isRegExpLiteral = isRegExpLiteral; -exports.isRegexLiteral = isRegexLiteral; -exports.isRestElement = isRestElement; -exports.isRestProperty = isRestProperty; -exports.isReturnStatement = isReturnStatement; -exports.isScopable = isScopable; -exports.isSequenceExpression = isSequenceExpression; -exports.isSpreadElement = isSpreadElement; -exports.isSpreadProperty = isSpreadProperty; -exports.isStandardized = isStandardized; -exports.isStatement = isStatement; -exports.isStaticBlock = isStaticBlock; -exports.isStringLiteral = isStringLiteral; -exports.isStringLiteralTypeAnnotation = isStringLiteralTypeAnnotation; -exports.isStringTypeAnnotation = isStringTypeAnnotation; -exports.isSuper = isSuper; -exports.isSwitchCase = isSwitchCase; -exports.isSwitchStatement = isSwitchStatement; -exports.isSymbolTypeAnnotation = isSymbolTypeAnnotation; -exports.isTSAnyKeyword = isTSAnyKeyword; -exports.isTSArrayType = isTSArrayType; -exports.isTSAsExpression = isTSAsExpression; -exports.isTSBaseType = isTSBaseType; -exports.isTSBigIntKeyword = isTSBigIntKeyword; -exports.isTSBooleanKeyword = isTSBooleanKeyword; -exports.isTSCallSignatureDeclaration = isTSCallSignatureDeclaration; -exports.isTSConditionalType = isTSConditionalType; -exports.isTSConstructSignatureDeclaration = isTSConstructSignatureDeclaration; -exports.isTSConstructorType = isTSConstructorType; -exports.isTSDeclareFunction = isTSDeclareFunction; -exports.isTSDeclareMethod = isTSDeclareMethod; -exports.isTSEntityName = isTSEntityName; -exports.isTSEnumDeclaration = isTSEnumDeclaration; -exports.isTSEnumMember = isTSEnumMember; -exports.isTSExportAssignment = isTSExportAssignment; -exports.isTSExpressionWithTypeArguments = isTSExpressionWithTypeArguments; -exports.isTSExternalModuleReference = isTSExternalModuleReference; -exports.isTSFunctionType = isTSFunctionType; -exports.isTSImportEqualsDeclaration = isTSImportEqualsDeclaration; -exports.isTSImportType = isTSImportType; -exports.isTSIndexSignature = isTSIndexSignature; -exports.isTSIndexedAccessType = isTSIndexedAccessType; -exports.isTSInferType = isTSInferType; -exports.isTSInstantiationExpression = isTSInstantiationExpression; -exports.isTSInterfaceBody = isTSInterfaceBody; -exports.isTSInterfaceDeclaration = isTSInterfaceDeclaration; -exports.isTSIntersectionType = isTSIntersectionType; -exports.isTSIntrinsicKeyword = isTSIntrinsicKeyword; -exports.isTSLiteralType = isTSLiteralType; -exports.isTSMappedType = isTSMappedType; -exports.isTSMethodSignature = isTSMethodSignature; -exports.isTSModuleBlock = isTSModuleBlock; -exports.isTSModuleDeclaration = isTSModuleDeclaration; -exports.isTSNamedTupleMember = isTSNamedTupleMember; -exports.isTSNamespaceExportDeclaration = isTSNamespaceExportDeclaration; -exports.isTSNeverKeyword = isTSNeverKeyword; -exports.isTSNonNullExpression = isTSNonNullExpression; -exports.isTSNullKeyword = isTSNullKeyword; -exports.isTSNumberKeyword = isTSNumberKeyword; -exports.isTSObjectKeyword = isTSObjectKeyword; -exports.isTSOptionalType = isTSOptionalType; -exports.isTSParameterProperty = isTSParameterProperty; -exports.isTSParenthesizedType = isTSParenthesizedType; -exports.isTSPropertySignature = isTSPropertySignature; -exports.isTSQualifiedName = isTSQualifiedName; -exports.isTSRestType = isTSRestType; -exports.isTSSatisfiesExpression = isTSSatisfiesExpression; -exports.isTSStringKeyword = isTSStringKeyword; -exports.isTSSymbolKeyword = isTSSymbolKeyword; -exports.isTSThisType = isTSThisType; -exports.isTSTupleType = isTSTupleType; -exports.isTSType = isTSType; -exports.isTSTypeAliasDeclaration = isTSTypeAliasDeclaration; -exports.isTSTypeAnnotation = isTSTypeAnnotation; -exports.isTSTypeAssertion = isTSTypeAssertion; -exports.isTSTypeElement = isTSTypeElement; -exports.isTSTypeLiteral = isTSTypeLiteral; -exports.isTSTypeOperator = isTSTypeOperator; -exports.isTSTypeParameter = isTSTypeParameter; -exports.isTSTypeParameterDeclaration = isTSTypeParameterDeclaration; -exports.isTSTypeParameterInstantiation = isTSTypeParameterInstantiation; -exports.isTSTypePredicate = isTSTypePredicate; -exports.isTSTypeQuery = isTSTypeQuery; -exports.isTSTypeReference = isTSTypeReference; -exports.isTSUndefinedKeyword = isTSUndefinedKeyword; -exports.isTSUnionType = isTSUnionType; -exports.isTSUnknownKeyword = isTSUnknownKeyword; -exports.isTSVoidKeyword = isTSVoidKeyword; -exports.isTaggedTemplateExpression = isTaggedTemplateExpression; -exports.isTemplateElement = isTemplateElement; -exports.isTemplateLiteral = isTemplateLiteral; -exports.isTerminatorless = isTerminatorless; -exports.isThisExpression = isThisExpression; -exports.isThisTypeAnnotation = isThisTypeAnnotation; -exports.isThrowStatement = isThrowStatement; -exports.isTopicReference = isTopicReference; -exports.isTryStatement = isTryStatement; -exports.isTupleExpression = isTupleExpression; -exports.isTupleTypeAnnotation = isTupleTypeAnnotation; -exports.isTypeAlias = isTypeAlias; -exports.isTypeAnnotation = isTypeAnnotation; -exports.isTypeCastExpression = isTypeCastExpression; -exports.isTypeParameter = isTypeParameter; -exports.isTypeParameterDeclaration = isTypeParameterDeclaration; -exports.isTypeParameterInstantiation = isTypeParameterInstantiation; -exports.isTypeScript = isTypeScript; -exports.isTypeofTypeAnnotation = isTypeofTypeAnnotation; -exports.isUnaryExpression = isUnaryExpression; -exports.isUnaryLike = isUnaryLike; -exports.isUnionTypeAnnotation = isUnionTypeAnnotation; -exports.isUpdateExpression = isUpdateExpression; -exports.isUserWhitespacable = isUserWhitespacable; -exports.isV8IntrinsicIdentifier = isV8IntrinsicIdentifier; -exports.isVariableDeclaration = isVariableDeclaration; -exports.isVariableDeclarator = isVariableDeclarator; -exports.isVariance = isVariance; -exports.isVoidTypeAnnotation = isVoidTypeAnnotation; -exports.isWhile = isWhile; -exports.isWhileStatement = isWhileStatement; -exports.isWithStatement = isWithStatement; -exports.isYieldExpression = isYieldExpression; -var _shallowEqual = require("../../utils/shallowEqual.js"); -var _deprecationWarning = require("../../utils/deprecationWarning.js"); -function isArrayExpression(node, opts) { - if (!node) return false; - if (node.type !== "ArrayExpression") return false; - return opts == null || (0, _shallowEqual.default)(node, opts); -} -function isAssignmentExpression(node, opts) { - if (!node) return false; - if (node.type !== "AssignmentExpression") return false; - return opts == null || (0, _shallowEqual.default)(node, opts); -} -function isBinaryExpression(node, opts) { - if (!node) return false; - if (node.type !== "BinaryExpression") return false; - return opts == null || (0, _shallowEqual.default)(node, opts); -} -function isInterpreterDirective(node, opts) { - if (!node) return false; - if (node.type !== "InterpreterDirective") return false; - return opts == null || (0, _shallowEqual.default)(node, opts); -} -function isDirective(node, opts) { - if (!node) return false; - if (node.type !== "Directive") return false; - return opts == null || (0, _shallowEqual.default)(node, opts); -} -function isDirectiveLiteral(node, opts) { - if (!node) return false; - if (node.type !== "DirectiveLiteral") return false; - return opts == null || (0, _shallowEqual.default)(node, opts); -} -function isBlockStatement(node, opts) { - if (!node) return false; - if (node.type !== "BlockStatement") return false; - return opts == null || (0, _shallowEqual.default)(node, opts); -} -function isBreakStatement(node, opts) { - if (!node) return false; - if (node.type !== "BreakStatement") return false; - return opts == null || (0, _shallowEqual.default)(node, opts); -} -function isCallExpression(node, opts) { - if (!node) return false; - if (node.type !== "CallExpression") return false; - return opts == null || (0, _shallowEqual.default)(node, opts); -} -function isCatchClause(node, opts) { - if (!node) return false; - if (node.type !== "CatchClause") return false; - return opts == null || (0, _shallowEqual.default)(node, opts); -} -function isConditionalExpression(node, opts) { - if (!node) return false; - if (node.type !== "ConditionalExpression") return false; - return opts == null || (0, _shallowEqual.default)(node, opts); -} -function isContinueStatement(node, opts) { - if (!node) return false; - if (node.type !== "ContinueStatement") return false; - return opts == null || (0, _shallowEqual.default)(node, opts); -} -function isDebuggerStatement(node, opts) { - if (!node) return false; - if (node.type !== "DebuggerStatement") return false; - return opts == null || (0, _shallowEqual.default)(node, opts); -} -function isDoWhileStatement(node, opts) { - if (!node) return false; - if (node.type !== "DoWhileStatement") return false; - return opts == null || (0, _shallowEqual.default)(node, opts); -} -function isEmptyStatement(node, opts) { - if (!node) return false; - if (node.type !== "EmptyStatement") return false; - return opts == null || (0, _shallowEqual.default)(node, opts); -} -function isExpressionStatement(node, opts) { - if (!node) return false; - if (node.type !== "ExpressionStatement") return false; - return opts == null || (0, _shallowEqual.default)(node, opts); -} -function isFile(node, opts) { - if (!node) return false; - if (node.type !== "File") return false; - return opts == null || (0, _shallowEqual.default)(node, opts); -} -function isForInStatement(node, opts) { - if (!node) return false; - if (node.type !== "ForInStatement") return false; - return opts == null || (0, _shallowEqual.default)(node, opts); -} -function isForStatement(node, opts) { - if (!node) return false; - if (node.type !== "ForStatement") return false; - return opts == null || (0, _shallowEqual.default)(node, opts); -} -function isFunctionDeclaration(node, opts) { - if (!node) return false; - if (node.type !== "FunctionDeclaration") return false; - return opts == null || (0, _shallowEqual.default)(node, opts); -} -function isFunctionExpression(node, opts) { - if (!node) return false; - if (node.type !== "FunctionExpression") return false; - return opts == null || (0, _shallowEqual.default)(node, opts); -} -function isIdentifier(node, opts) { - if (!node) return false; - if (node.type !== "Identifier") return false; - return opts == null || (0, _shallowEqual.default)(node, opts); -} -function isIfStatement(node, opts) { - if (!node) return false; - if (node.type !== "IfStatement") return false; - return opts == null || (0, _shallowEqual.default)(node, opts); -} -function isLabeledStatement(node, opts) { - if (!node) return false; - if (node.type !== "LabeledStatement") return false; - return opts == null || (0, _shallowEqual.default)(node, opts); -} -function isStringLiteral(node, opts) { - if (!node) return false; - if (node.type !== "StringLiteral") return false; - return opts == null || (0, _shallowEqual.default)(node, opts); -} -function isNumericLiteral(node, opts) { - if (!node) return false; - if (node.type !== "NumericLiteral") return false; - return opts == null || (0, _shallowEqual.default)(node, opts); -} -function isNullLiteral(node, opts) { - if (!node) return false; - if (node.type !== "NullLiteral") return false; - return opts == null || (0, _shallowEqual.default)(node, opts); -} -function isBooleanLiteral(node, opts) { - if (!node) return false; - if (node.type !== "BooleanLiteral") return false; - return opts == null || (0, _shallowEqual.default)(node, opts); -} -function isRegExpLiteral(node, opts) { - if (!node) return false; - if (node.type !== "RegExpLiteral") return false; - return opts == null || (0, _shallowEqual.default)(node, opts); -} -function isLogicalExpression(node, opts) { - if (!node) return false; - if (node.type !== "LogicalExpression") return false; - return opts == null || (0, _shallowEqual.default)(node, opts); -} -function isMemberExpression(node, opts) { - if (!node) return false; - if (node.type !== "MemberExpression") return false; - return opts == null || (0, _shallowEqual.default)(node, opts); -} -function isNewExpression(node, opts) { - if (!node) return false; - if (node.type !== "NewExpression") return false; - return opts == null || (0, _shallowEqual.default)(node, opts); -} -function isProgram(node, opts) { - if (!node) return false; - if (node.type !== "Program") return false; - return opts == null || (0, _shallowEqual.default)(node, opts); -} -function isObjectExpression(node, opts) { - if (!node) return false; - if (node.type !== "ObjectExpression") return false; - return opts == null || (0, _shallowEqual.default)(node, opts); -} -function isObjectMethod(node, opts) { - if (!node) return false; - if (node.type !== "ObjectMethod") return false; - return opts == null || (0, _shallowEqual.default)(node, opts); -} -function isObjectProperty(node, opts) { - if (!node) return false; - if (node.type !== "ObjectProperty") return false; - return opts == null || (0, _shallowEqual.default)(node, opts); -} -function isRestElement(node, opts) { - if (!node) return false; - if (node.type !== "RestElement") return false; - return opts == null || (0, _shallowEqual.default)(node, opts); -} -function isReturnStatement(node, opts) { - if (!node) return false; - if (node.type !== "ReturnStatement") return false; - return opts == null || (0, _shallowEqual.default)(node, opts); -} -function isSequenceExpression(node, opts) { - if (!node) return false; - if (node.type !== "SequenceExpression") return false; - return opts == null || (0, _shallowEqual.default)(node, opts); -} -function isParenthesizedExpression(node, opts) { - if (!node) return false; - if (node.type !== "ParenthesizedExpression") return false; - return opts == null || (0, _shallowEqual.default)(node, opts); -} -function isSwitchCase(node, opts) { - if (!node) return false; - if (node.type !== "SwitchCase") return false; - return opts == null || (0, _shallowEqual.default)(node, opts); -} -function isSwitchStatement(node, opts) { - if (!node) return false; - if (node.type !== "SwitchStatement") return false; - return opts == null || (0, _shallowEqual.default)(node, opts); -} -function isThisExpression(node, opts) { - if (!node) return false; - if (node.type !== "ThisExpression") return false; - return opts == null || (0, _shallowEqual.default)(node, opts); -} -function isThrowStatement(node, opts) { - if (!node) return false; - if (node.type !== "ThrowStatement") return false; - return opts == null || (0, _shallowEqual.default)(node, opts); -} -function isTryStatement(node, opts) { - if (!node) return false; - if (node.type !== "TryStatement") return false; - return opts == null || (0, _shallowEqual.default)(node, opts); -} -function isUnaryExpression(node, opts) { - if (!node) return false; - if (node.type !== "UnaryExpression") return false; - return opts == null || (0, _shallowEqual.default)(node, opts); -} -function isUpdateExpression(node, opts) { - if (!node) return false; - if (node.type !== "UpdateExpression") return false; - return opts == null || (0, _shallowEqual.default)(node, opts); -} -function isVariableDeclaration(node, opts) { - if (!node) return false; - if (node.type !== "VariableDeclaration") return false; - return opts == null || (0, _shallowEqual.default)(node, opts); -} -function isVariableDeclarator(node, opts) { - if (!node) return false; - if (node.type !== "VariableDeclarator") return false; - return opts == null || (0, _shallowEqual.default)(node, opts); -} -function isWhileStatement(node, opts) { - if (!node) return false; - if (node.type !== "WhileStatement") return false; - return opts == null || (0, _shallowEqual.default)(node, opts); -} -function isWithStatement(node, opts) { - if (!node) return false; - if (node.type !== "WithStatement") return false; - return opts == null || (0, _shallowEqual.default)(node, opts); -} -function isAssignmentPattern(node, opts) { - if (!node) return false; - if (node.type !== "AssignmentPattern") return false; - return opts == null || (0, _shallowEqual.default)(node, opts); -} -function isArrayPattern(node, opts) { - if (!node) return false; - if (node.type !== "ArrayPattern") return false; - return opts == null || (0, _shallowEqual.default)(node, opts); -} -function isArrowFunctionExpression(node, opts) { - if (!node) return false; - if (node.type !== "ArrowFunctionExpression") return false; - return opts == null || (0, _shallowEqual.default)(node, opts); -} -function isClassBody(node, opts) { - if (!node) return false; - if (node.type !== "ClassBody") return false; - return opts == null || (0, _shallowEqual.default)(node, opts); -} -function isClassExpression(node, opts) { - if (!node) return false; - if (node.type !== "ClassExpression") return false; - return opts == null || (0, _shallowEqual.default)(node, opts); -} -function isClassDeclaration(node, opts) { - if (!node) return false; - if (node.type !== "ClassDeclaration") return false; - return opts == null || (0, _shallowEqual.default)(node, opts); -} -function isExportAllDeclaration(node, opts) { - if (!node) return false; - if (node.type !== "ExportAllDeclaration") return false; - return opts == null || (0, _shallowEqual.default)(node, opts); -} -function isExportDefaultDeclaration(node, opts) { - if (!node) return false; - if (node.type !== "ExportDefaultDeclaration") return false; - return opts == null || (0, _shallowEqual.default)(node, opts); -} -function isExportNamedDeclaration(node, opts) { - if (!node) return false; - if (node.type !== "ExportNamedDeclaration") return false; - return opts == null || (0, _shallowEqual.default)(node, opts); -} -function isExportSpecifier(node, opts) { - if (!node) return false; - if (node.type !== "ExportSpecifier") return false; - return opts == null || (0, _shallowEqual.default)(node, opts); -} -function isForOfStatement(node, opts) { - if (!node) return false; - if (node.type !== "ForOfStatement") return false; - return opts == null || (0, _shallowEqual.default)(node, opts); -} -function isImportDeclaration(node, opts) { - if (!node) return false; - if (node.type !== "ImportDeclaration") return false; - return opts == null || (0, _shallowEqual.default)(node, opts); -} -function isImportDefaultSpecifier(node, opts) { - if (!node) return false; - if (node.type !== "ImportDefaultSpecifier") return false; - return opts == null || (0, _shallowEqual.default)(node, opts); -} -function isImportNamespaceSpecifier(node, opts) { - if (!node) return false; - if (node.type !== "ImportNamespaceSpecifier") return false; - return opts == null || (0, _shallowEqual.default)(node, opts); -} -function isImportSpecifier(node, opts) { - if (!node) return false; - if (node.type !== "ImportSpecifier") return false; - return opts == null || (0, _shallowEqual.default)(node, opts); -} -function isImportExpression(node, opts) { - if (!node) return false; - if (node.type !== "ImportExpression") return false; - return opts == null || (0, _shallowEqual.default)(node, opts); -} -function isMetaProperty(node, opts) { - if (!node) return false; - if (node.type !== "MetaProperty") return false; - return opts == null || (0, _shallowEqual.default)(node, opts); -} -function isClassMethod(node, opts) { - if (!node) return false; - if (node.type !== "ClassMethod") return false; - return opts == null || (0, _shallowEqual.default)(node, opts); -} -function isObjectPattern(node, opts) { - if (!node) return false; - if (node.type !== "ObjectPattern") return false; - return opts == null || (0, _shallowEqual.default)(node, opts); -} -function isSpreadElement(node, opts) { - if (!node) return false; - if (node.type !== "SpreadElement") return false; - return opts == null || (0, _shallowEqual.default)(node, opts); -} -function isSuper(node, opts) { - if (!node) return false; - if (node.type !== "Super") return false; - return opts == null || (0, _shallowEqual.default)(node, opts); -} -function isTaggedTemplateExpression(node, opts) { - if (!node) return false; - if (node.type !== "TaggedTemplateExpression") return false; - return opts == null || (0, _shallowEqual.default)(node, opts); -} -function isTemplateElement(node, opts) { - if (!node) return false; - if (node.type !== "TemplateElement") return false; - return opts == null || (0, _shallowEqual.default)(node, opts); -} -function isTemplateLiteral(node, opts) { - if (!node) return false; - if (node.type !== "TemplateLiteral") return false; - return opts == null || (0, _shallowEqual.default)(node, opts); -} -function isYieldExpression(node, opts) { - if (!node) return false; - if (node.type !== "YieldExpression") return false; - return opts == null || (0, _shallowEqual.default)(node, opts); -} -function isAwaitExpression(node, opts) { - if (!node) return false; - if (node.type !== "AwaitExpression") return false; - return opts == null || (0, _shallowEqual.default)(node, opts); -} -function isImport(node, opts) { - if (!node) return false; - if (node.type !== "Import") return false; - return opts == null || (0, _shallowEqual.default)(node, opts); -} -function isBigIntLiteral(node, opts) { - if (!node) return false; - if (node.type !== "BigIntLiteral") return false; - return opts == null || (0, _shallowEqual.default)(node, opts); -} -function isExportNamespaceSpecifier(node, opts) { - if (!node) return false; - if (node.type !== "ExportNamespaceSpecifier") return false; - return opts == null || (0, _shallowEqual.default)(node, opts); -} -function isOptionalMemberExpression(node, opts) { - if (!node) return false; - if (node.type !== "OptionalMemberExpression") return false; - return opts == null || (0, _shallowEqual.default)(node, opts); -} -function isOptionalCallExpression(node, opts) { - if (!node) return false; - if (node.type !== "OptionalCallExpression") return false; - return opts == null || (0, _shallowEqual.default)(node, opts); -} -function isClassProperty(node, opts) { - if (!node) return false; - if (node.type !== "ClassProperty") return false; - return opts == null || (0, _shallowEqual.default)(node, opts); -} -function isClassAccessorProperty(node, opts) { - if (!node) return false; - if (node.type !== "ClassAccessorProperty") return false; - return opts == null || (0, _shallowEqual.default)(node, opts); -} -function isClassPrivateProperty(node, opts) { - if (!node) return false; - if (node.type !== "ClassPrivateProperty") return false; - return opts == null || (0, _shallowEqual.default)(node, opts); -} -function isClassPrivateMethod(node, opts) { - if (!node) return false; - if (node.type !== "ClassPrivateMethod") return false; - return opts == null || (0, _shallowEqual.default)(node, opts); -} -function isPrivateName(node, opts) { - if (!node) return false; - if (node.type !== "PrivateName") return false; - return opts == null || (0, _shallowEqual.default)(node, opts); -} -function isStaticBlock(node, opts) { - if (!node) return false; - if (node.type !== "StaticBlock") return false; - return opts == null || (0, _shallowEqual.default)(node, opts); -} -function isAnyTypeAnnotation(node, opts) { - if (!node) return false; - if (node.type !== "AnyTypeAnnotation") return false; - return opts == null || (0, _shallowEqual.default)(node, opts); -} -function isArrayTypeAnnotation(node, opts) { - if (!node) return false; - if (node.type !== "ArrayTypeAnnotation") return false; - return opts == null || (0, _shallowEqual.default)(node, opts); -} -function isBooleanTypeAnnotation(node, opts) { - if (!node) return false; - if (node.type !== "BooleanTypeAnnotation") return false; - return opts == null || (0, _shallowEqual.default)(node, opts); -} -function isBooleanLiteralTypeAnnotation(node, opts) { - if (!node) return false; - if (node.type !== "BooleanLiteralTypeAnnotation") return false; - return opts == null || (0, _shallowEqual.default)(node, opts); -} -function isNullLiteralTypeAnnotation(node, opts) { - if (!node) return false; - if (node.type !== "NullLiteralTypeAnnotation") return false; - return opts == null || (0, _shallowEqual.default)(node, opts); -} -function isClassImplements(node, opts) { - if (!node) return false; - if (node.type !== "ClassImplements") return false; - return opts == null || (0, _shallowEqual.default)(node, opts); -} -function isDeclareClass(node, opts) { - if (!node) return false; - if (node.type !== "DeclareClass") return false; - return opts == null || (0, _shallowEqual.default)(node, opts); -} -function isDeclareFunction(node, opts) { - if (!node) return false; - if (node.type !== "DeclareFunction") return false; - return opts == null || (0, _shallowEqual.default)(node, opts); -} -function isDeclareInterface(node, opts) { - if (!node) return false; - if (node.type !== "DeclareInterface") return false; - return opts == null || (0, _shallowEqual.default)(node, opts); -} -function isDeclareModule(node, opts) { - if (!node) return false; - if (node.type !== "DeclareModule") return false; - return opts == null || (0, _shallowEqual.default)(node, opts); -} -function isDeclareModuleExports(node, opts) { - if (!node) return false; - if (node.type !== "DeclareModuleExports") return false; - return opts == null || (0, _shallowEqual.default)(node, opts); -} -function isDeclareTypeAlias(node, opts) { - if (!node) return false; - if (node.type !== "DeclareTypeAlias") return false; - return opts == null || (0, _shallowEqual.default)(node, opts); -} -function isDeclareOpaqueType(node, opts) { - if (!node) return false; - if (node.type !== "DeclareOpaqueType") return false; - return opts == null || (0, _shallowEqual.default)(node, opts); -} -function isDeclareVariable(node, opts) { - if (!node) return false; - if (node.type !== "DeclareVariable") return false; - return opts == null || (0, _shallowEqual.default)(node, opts); -} -function isDeclareExportDeclaration(node, opts) { - if (!node) return false; - if (node.type !== "DeclareExportDeclaration") return false; - return opts == null || (0, _shallowEqual.default)(node, opts); -} -function isDeclareExportAllDeclaration(node, opts) { - if (!node) return false; - if (node.type !== "DeclareExportAllDeclaration") return false; - return opts == null || (0, _shallowEqual.default)(node, opts); -} -function isDeclaredPredicate(node, opts) { - if (!node) return false; - if (node.type !== "DeclaredPredicate") return false; - return opts == null || (0, _shallowEqual.default)(node, opts); -} -function isExistsTypeAnnotation(node, opts) { - if (!node) return false; - if (node.type !== "ExistsTypeAnnotation") return false; - return opts == null || (0, _shallowEqual.default)(node, opts); -} -function isFunctionTypeAnnotation(node, opts) { - if (!node) return false; - if (node.type !== "FunctionTypeAnnotation") return false; - return opts == null || (0, _shallowEqual.default)(node, opts); -} -function isFunctionTypeParam(node, opts) { - if (!node) return false; - if (node.type !== "FunctionTypeParam") return false; - return opts == null || (0, _shallowEqual.default)(node, opts); -} -function isGenericTypeAnnotation(node, opts) { - if (!node) return false; - if (node.type !== "GenericTypeAnnotation") return false; - return opts == null || (0, _shallowEqual.default)(node, opts); -} -function isInferredPredicate(node, opts) { - if (!node) return false; - if (node.type !== "InferredPredicate") return false; - return opts == null || (0, _shallowEqual.default)(node, opts); -} -function isInterfaceExtends(node, opts) { - if (!node) return false; - if (node.type !== "InterfaceExtends") return false; - return opts == null || (0, _shallowEqual.default)(node, opts); -} -function isInterfaceDeclaration(node, opts) { - if (!node) return false; - if (node.type !== "InterfaceDeclaration") return false; - return opts == null || (0, _shallowEqual.default)(node, opts); -} -function isInterfaceTypeAnnotation(node, opts) { - if (!node) return false; - if (node.type !== "InterfaceTypeAnnotation") return false; - return opts == null || (0, _shallowEqual.default)(node, opts); -} -function isIntersectionTypeAnnotation(node, opts) { - if (!node) return false; - if (node.type !== "IntersectionTypeAnnotation") return false; - return opts == null || (0, _shallowEqual.default)(node, opts); -} -function isMixedTypeAnnotation(node, opts) { - if (!node) return false; - if (node.type !== "MixedTypeAnnotation") return false; - return opts == null || (0, _shallowEqual.default)(node, opts); -} -function isEmptyTypeAnnotation(node, opts) { - if (!node) return false; - if (node.type !== "EmptyTypeAnnotation") return false; - return opts == null || (0, _shallowEqual.default)(node, opts); -} -function isNullableTypeAnnotation(node, opts) { - if (!node) return false; - if (node.type !== "NullableTypeAnnotation") return false; - return opts == null || (0, _shallowEqual.default)(node, opts); -} -function isNumberLiteralTypeAnnotation(node, opts) { - if (!node) return false; - if (node.type !== "NumberLiteralTypeAnnotation") return false; - return opts == null || (0, _shallowEqual.default)(node, opts); -} -function isNumberTypeAnnotation(node, opts) { - if (!node) return false; - if (node.type !== "NumberTypeAnnotation") return false; - return opts == null || (0, _shallowEqual.default)(node, opts); -} -function isObjectTypeAnnotation(node, opts) { - if (!node) return false; - if (node.type !== "ObjectTypeAnnotation") return false; - return opts == null || (0, _shallowEqual.default)(node, opts); -} -function isObjectTypeInternalSlot(node, opts) { - if (!node) return false; - if (node.type !== "ObjectTypeInternalSlot") return false; - return opts == null || (0, _shallowEqual.default)(node, opts); -} -function isObjectTypeCallProperty(node, opts) { - if (!node) return false; - if (node.type !== "ObjectTypeCallProperty") return false; - return opts == null || (0, _shallowEqual.default)(node, opts); -} -function isObjectTypeIndexer(node, opts) { - if (!node) return false; - if (node.type !== "ObjectTypeIndexer") return false; - return opts == null || (0, _shallowEqual.default)(node, opts); -} -function isObjectTypeProperty(node, opts) { - if (!node) return false; - if (node.type !== "ObjectTypeProperty") return false; - return opts == null || (0, _shallowEqual.default)(node, opts); -} -function isObjectTypeSpreadProperty(node, opts) { - if (!node) return false; - if (node.type !== "ObjectTypeSpreadProperty") return false; - return opts == null || (0, _shallowEqual.default)(node, opts); -} -function isOpaqueType(node, opts) { - if (!node) return false; - if (node.type !== "OpaqueType") return false; - return opts == null || (0, _shallowEqual.default)(node, opts); -} -function isQualifiedTypeIdentifier(node, opts) { - if (!node) return false; - if (node.type !== "QualifiedTypeIdentifier") return false; - return opts == null || (0, _shallowEqual.default)(node, opts); -} -function isStringLiteralTypeAnnotation(node, opts) { - if (!node) return false; - if (node.type !== "StringLiteralTypeAnnotation") return false; - return opts == null || (0, _shallowEqual.default)(node, opts); -} -function isStringTypeAnnotation(node, opts) { - if (!node) return false; - if (node.type !== "StringTypeAnnotation") return false; - return opts == null || (0, _shallowEqual.default)(node, opts); -} -function isSymbolTypeAnnotation(node, opts) { - if (!node) return false; - if (node.type !== "SymbolTypeAnnotation") return false; - return opts == null || (0, _shallowEqual.default)(node, opts); -} -function isThisTypeAnnotation(node, opts) { - if (!node) return false; - if (node.type !== "ThisTypeAnnotation") return false; - return opts == null || (0, _shallowEqual.default)(node, opts); -} -function isTupleTypeAnnotation(node, opts) { - if (!node) return false; - if (node.type !== "TupleTypeAnnotation") return false; - return opts == null || (0, _shallowEqual.default)(node, opts); -} -function isTypeofTypeAnnotation(node, opts) { - if (!node) return false; - if (node.type !== "TypeofTypeAnnotation") return false; - return opts == null || (0, _shallowEqual.default)(node, opts); -} -function isTypeAlias(node, opts) { - if (!node) return false; - if (node.type !== "TypeAlias") return false; - return opts == null || (0, _shallowEqual.default)(node, opts); -} -function isTypeAnnotation(node, opts) { - if (!node) return false; - if (node.type !== "TypeAnnotation") return false; - return opts == null || (0, _shallowEqual.default)(node, opts); -} -function isTypeCastExpression(node, opts) { - if (!node) return false; - if (node.type !== "TypeCastExpression") return false; - return opts == null || (0, _shallowEqual.default)(node, opts); -} -function isTypeParameter(node, opts) { - if (!node) return false; - if (node.type !== "TypeParameter") return false; - return opts == null || (0, _shallowEqual.default)(node, opts); -} -function isTypeParameterDeclaration(node, opts) { - if (!node) return false; - if (node.type !== "TypeParameterDeclaration") return false; - return opts == null || (0, _shallowEqual.default)(node, opts); -} -function isTypeParameterInstantiation(node, opts) { - if (!node) return false; - if (node.type !== "TypeParameterInstantiation") return false; - return opts == null || (0, _shallowEqual.default)(node, opts); -} -function isUnionTypeAnnotation(node, opts) { - if (!node) return false; - if (node.type !== "UnionTypeAnnotation") return false; - return opts == null || (0, _shallowEqual.default)(node, opts); -} -function isVariance(node, opts) { - if (!node) return false; - if (node.type !== "Variance") return false; - return opts == null || (0, _shallowEqual.default)(node, opts); -} -function isVoidTypeAnnotation(node, opts) { - if (!node) return false; - if (node.type !== "VoidTypeAnnotation") return false; - return opts == null || (0, _shallowEqual.default)(node, opts); -} -function isEnumDeclaration(node, opts) { - if (!node) return false; - if (node.type !== "EnumDeclaration") return false; - return opts == null || (0, _shallowEqual.default)(node, opts); -} -function isEnumBooleanBody(node, opts) { - if (!node) return false; - if (node.type !== "EnumBooleanBody") return false; - return opts == null || (0, _shallowEqual.default)(node, opts); -} -function isEnumNumberBody(node, opts) { - if (!node) return false; - if (node.type !== "EnumNumberBody") return false; - return opts == null || (0, _shallowEqual.default)(node, opts); -} -function isEnumStringBody(node, opts) { - if (!node) return false; - if (node.type !== "EnumStringBody") return false; - return opts == null || (0, _shallowEqual.default)(node, opts); -} -function isEnumSymbolBody(node, opts) { - if (!node) return false; - if (node.type !== "EnumSymbolBody") return false; - return opts == null || (0, _shallowEqual.default)(node, opts); -} -function isEnumBooleanMember(node, opts) { - if (!node) return false; - if (node.type !== "EnumBooleanMember") return false; - return opts == null || (0, _shallowEqual.default)(node, opts); -} -function isEnumNumberMember(node, opts) { - if (!node) return false; - if (node.type !== "EnumNumberMember") return false; - return opts == null || (0, _shallowEqual.default)(node, opts); -} -function isEnumStringMember(node, opts) { - if (!node) return false; - if (node.type !== "EnumStringMember") return false; - return opts == null || (0, _shallowEqual.default)(node, opts); -} -function isEnumDefaultedMember(node, opts) { - if (!node) return false; - if (node.type !== "EnumDefaultedMember") return false; - return opts == null || (0, _shallowEqual.default)(node, opts); -} -function isIndexedAccessType(node, opts) { - if (!node) return false; - if (node.type !== "IndexedAccessType") return false; - return opts == null || (0, _shallowEqual.default)(node, opts); -} -function isOptionalIndexedAccessType(node, opts) { - if (!node) return false; - if (node.type !== "OptionalIndexedAccessType") return false; - return opts == null || (0, _shallowEqual.default)(node, opts); -} -function isJSXAttribute(node, opts) { - if (!node) return false; - if (node.type !== "JSXAttribute") return false; - return opts == null || (0, _shallowEqual.default)(node, opts); -} -function isJSXClosingElement(node, opts) { - if (!node) return false; - if (node.type !== "JSXClosingElement") return false; - return opts == null || (0, _shallowEqual.default)(node, opts); -} -function isJSXElement(node, opts) { - if (!node) return false; - if (node.type !== "JSXElement") return false; - return opts == null || (0, _shallowEqual.default)(node, opts); -} -function isJSXEmptyExpression(node, opts) { - if (!node) return false; - if (node.type !== "JSXEmptyExpression") return false; - return opts == null || (0, _shallowEqual.default)(node, opts); -} -function isJSXExpressionContainer(node, opts) { - if (!node) return false; - if (node.type !== "JSXExpressionContainer") return false; - return opts == null || (0, _shallowEqual.default)(node, opts); -} -function isJSXSpreadChild(node, opts) { - if (!node) return false; - if (node.type !== "JSXSpreadChild") return false; - return opts == null || (0, _shallowEqual.default)(node, opts); -} -function isJSXIdentifier(node, opts) { - if (!node) return false; - if (node.type !== "JSXIdentifier") return false; - return opts == null || (0, _shallowEqual.default)(node, opts); -} -function isJSXMemberExpression(node, opts) { - if (!node) return false; - if (node.type !== "JSXMemberExpression") return false; - return opts == null || (0, _shallowEqual.default)(node, opts); -} -function isJSXNamespacedName(node, opts) { - if (!node) return false; - if (node.type !== "JSXNamespacedName") return false; - return opts == null || (0, _shallowEqual.default)(node, opts); -} -function isJSXOpeningElement(node, opts) { - if (!node) return false; - if (node.type !== "JSXOpeningElement") return false; - return opts == null || (0, _shallowEqual.default)(node, opts); -} -function isJSXSpreadAttribute(node, opts) { - if (!node) return false; - if (node.type !== "JSXSpreadAttribute") return false; - return opts == null || (0, _shallowEqual.default)(node, opts); -} -function isJSXText(node, opts) { - if (!node) return false; - if (node.type !== "JSXText") return false; - return opts == null || (0, _shallowEqual.default)(node, opts); -} -function isJSXFragment(node, opts) { - if (!node) return false; - if (node.type !== "JSXFragment") return false; - return opts == null || (0, _shallowEqual.default)(node, opts); -} -function isJSXOpeningFragment(node, opts) { - if (!node) return false; - if (node.type !== "JSXOpeningFragment") return false; - return opts == null || (0, _shallowEqual.default)(node, opts); -} -function isJSXClosingFragment(node, opts) { - if (!node) return false; - if (node.type !== "JSXClosingFragment") return false; - return opts == null || (0, _shallowEqual.default)(node, opts); -} -function isNoop(node, opts) { - if (!node) return false; - if (node.type !== "Noop") return false; - return opts == null || (0, _shallowEqual.default)(node, opts); -} -function isPlaceholder(node, opts) { - if (!node) return false; - if (node.type !== "Placeholder") return false; - return opts == null || (0, _shallowEqual.default)(node, opts); -} -function isV8IntrinsicIdentifier(node, opts) { - if (!node) return false; - if (node.type !== "V8IntrinsicIdentifier") return false; - return opts == null || (0, _shallowEqual.default)(node, opts); -} -function isArgumentPlaceholder(node, opts) { - if (!node) return false; - if (node.type !== "ArgumentPlaceholder") return false; - return opts == null || (0, _shallowEqual.default)(node, opts); -} -function isBindExpression(node, opts) { - if (!node) return false; - if (node.type !== "BindExpression") return false; - return opts == null || (0, _shallowEqual.default)(node, opts); -} -function isImportAttribute(node, opts) { - if (!node) return false; - if (node.type !== "ImportAttribute") return false; - return opts == null || (0, _shallowEqual.default)(node, opts); -} -function isDecorator(node, opts) { - if (!node) return false; - if (node.type !== "Decorator") return false; - return opts == null || (0, _shallowEqual.default)(node, opts); -} -function isDoExpression(node, opts) { - if (!node) return false; - if (node.type !== "DoExpression") return false; - return opts == null || (0, _shallowEqual.default)(node, opts); -} -function isExportDefaultSpecifier(node, opts) { - if (!node) return false; - if (node.type !== "ExportDefaultSpecifier") return false; - return opts == null || (0, _shallowEqual.default)(node, opts); -} -function isRecordExpression(node, opts) { - if (!node) return false; - if (node.type !== "RecordExpression") return false; - return opts == null || (0, _shallowEqual.default)(node, opts); -} -function isTupleExpression(node, opts) { - if (!node) return false; - if (node.type !== "TupleExpression") return false; - return opts == null || (0, _shallowEqual.default)(node, opts); -} -function isDecimalLiteral(node, opts) { - if (!node) return false; - if (node.type !== "DecimalLiteral") return false; - return opts == null || (0, _shallowEqual.default)(node, opts); -} -function isModuleExpression(node, opts) { - if (!node) return false; - if (node.type !== "ModuleExpression") return false; - return opts == null || (0, _shallowEqual.default)(node, opts); -} -function isTopicReference(node, opts) { - if (!node) return false; - if (node.type !== "TopicReference") return false; - return opts == null || (0, _shallowEqual.default)(node, opts); -} -function isPipelineTopicExpression(node, opts) { - if (!node) return false; - if (node.type !== "PipelineTopicExpression") return false; - return opts == null || (0, _shallowEqual.default)(node, opts); -} -function isPipelineBareFunction(node, opts) { - if (!node) return false; - if (node.type !== "PipelineBareFunction") return false; - return opts == null || (0, _shallowEqual.default)(node, opts); -} -function isPipelinePrimaryTopicReference(node, opts) { - if (!node) return false; - if (node.type !== "PipelinePrimaryTopicReference") return false; - return opts == null || (0, _shallowEqual.default)(node, opts); -} -function isTSParameterProperty(node, opts) { - if (!node) return false; - if (node.type !== "TSParameterProperty") return false; - return opts == null || (0, _shallowEqual.default)(node, opts); -} -function isTSDeclareFunction(node, opts) { - if (!node) return false; - if (node.type !== "TSDeclareFunction") return false; - return opts == null || (0, _shallowEqual.default)(node, opts); -} -function isTSDeclareMethod(node, opts) { - if (!node) return false; - if (node.type !== "TSDeclareMethod") return false; - return opts == null || (0, _shallowEqual.default)(node, opts); -} -function isTSQualifiedName(node, opts) { - if (!node) return false; - if (node.type !== "TSQualifiedName") return false; - return opts == null || (0, _shallowEqual.default)(node, opts); -} -function isTSCallSignatureDeclaration(node, opts) { - if (!node) return false; - if (node.type !== "TSCallSignatureDeclaration") return false; - return opts == null || (0, _shallowEqual.default)(node, opts); -} -function isTSConstructSignatureDeclaration(node, opts) { - if (!node) return false; - if (node.type !== "TSConstructSignatureDeclaration") return false; - return opts == null || (0, _shallowEqual.default)(node, opts); -} -function isTSPropertySignature(node, opts) { - if (!node) return false; - if (node.type !== "TSPropertySignature") return false; - return opts == null || (0, _shallowEqual.default)(node, opts); -} -function isTSMethodSignature(node, opts) { - if (!node) return false; - if (node.type !== "TSMethodSignature") return false; - return opts == null || (0, _shallowEqual.default)(node, opts); -} -function isTSIndexSignature(node, opts) { - if (!node) return false; - if (node.type !== "TSIndexSignature") return false; - return opts == null || (0, _shallowEqual.default)(node, opts); -} -function isTSAnyKeyword(node, opts) { - if (!node) return false; - if (node.type !== "TSAnyKeyword") return false; - return opts == null || (0, _shallowEqual.default)(node, opts); -} -function isTSBooleanKeyword(node, opts) { - if (!node) return false; - if (node.type !== "TSBooleanKeyword") return false; - return opts == null || (0, _shallowEqual.default)(node, opts); -} -function isTSBigIntKeyword(node, opts) { - if (!node) return false; - if (node.type !== "TSBigIntKeyword") return false; - return opts == null || (0, _shallowEqual.default)(node, opts); -} -function isTSIntrinsicKeyword(node, opts) { - if (!node) return false; - if (node.type !== "TSIntrinsicKeyword") return false; - return opts == null || (0, _shallowEqual.default)(node, opts); -} -function isTSNeverKeyword(node, opts) { - if (!node) return false; - if (node.type !== "TSNeverKeyword") return false; - return opts == null || (0, _shallowEqual.default)(node, opts); -} -function isTSNullKeyword(node, opts) { - if (!node) return false; - if (node.type !== "TSNullKeyword") return false; - return opts == null || (0, _shallowEqual.default)(node, opts); -} -function isTSNumberKeyword(node, opts) { - if (!node) return false; - if (node.type !== "TSNumberKeyword") return false; - return opts == null || (0, _shallowEqual.default)(node, opts); -} -function isTSObjectKeyword(node, opts) { - if (!node) return false; - if (node.type !== "TSObjectKeyword") return false; - return opts == null || (0, _shallowEqual.default)(node, opts); -} -function isTSStringKeyword(node, opts) { - if (!node) return false; - if (node.type !== "TSStringKeyword") return false; - return opts == null || (0, _shallowEqual.default)(node, opts); -} -function isTSSymbolKeyword(node, opts) { - if (!node) return false; - if (node.type !== "TSSymbolKeyword") return false; - return opts == null || (0, _shallowEqual.default)(node, opts); -} -function isTSUndefinedKeyword(node, opts) { - if (!node) return false; - if (node.type !== "TSUndefinedKeyword") return false; - return opts == null || (0, _shallowEqual.default)(node, opts); -} -function isTSUnknownKeyword(node, opts) { - if (!node) return false; - if (node.type !== "TSUnknownKeyword") return false; - return opts == null || (0, _shallowEqual.default)(node, opts); -} -function isTSVoidKeyword(node, opts) { - if (!node) return false; - if (node.type !== "TSVoidKeyword") return false; - return opts == null || (0, _shallowEqual.default)(node, opts); -} -function isTSThisType(node, opts) { - if (!node) return false; - if (node.type !== "TSThisType") return false; - return opts == null || (0, _shallowEqual.default)(node, opts); -} -function isTSFunctionType(node, opts) { - if (!node) return false; - if (node.type !== "TSFunctionType") return false; - return opts == null || (0, _shallowEqual.default)(node, opts); -} -function isTSConstructorType(node, opts) { - if (!node) return false; - if (node.type !== "TSConstructorType") return false; - return opts == null || (0, _shallowEqual.default)(node, opts); -} -function isTSTypeReference(node, opts) { - if (!node) return false; - if (node.type !== "TSTypeReference") return false; - return opts == null || (0, _shallowEqual.default)(node, opts); -} -function isTSTypePredicate(node, opts) { - if (!node) return false; - if (node.type !== "TSTypePredicate") return false; - return opts == null || (0, _shallowEqual.default)(node, opts); -} -function isTSTypeQuery(node, opts) { - if (!node) return false; - if (node.type !== "TSTypeQuery") return false; - return opts == null || (0, _shallowEqual.default)(node, opts); -} -function isTSTypeLiteral(node, opts) { - if (!node) return false; - if (node.type !== "TSTypeLiteral") return false; - return opts == null || (0, _shallowEqual.default)(node, opts); -} -function isTSArrayType(node, opts) { - if (!node) return false; - if (node.type !== "TSArrayType") return false; - return opts == null || (0, _shallowEqual.default)(node, opts); -} -function isTSTupleType(node, opts) { - if (!node) return false; - if (node.type !== "TSTupleType") return false; - return opts == null || (0, _shallowEqual.default)(node, opts); -} -function isTSOptionalType(node, opts) { - if (!node) return false; - if (node.type !== "TSOptionalType") return false; - return opts == null || (0, _shallowEqual.default)(node, opts); -} -function isTSRestType(node, opts) { - if (!node) return false; - if (node.type !== "TSRestType") return false; - return opts == null || (0, _shallowEqual.default)(node, opts); -} -function isTSNamedTupleMember(node, opts) { - if (!node) return false; - if (node.type !== "TSNamedTupleMember") return false; - return opts == null || (0, _shallowEqual.default)(node, opts); -} -function isTSUnionType(node, opts) { - if (!node) return false; - if (node.type !== "TSUnionType") return false; - return opts == null || (0, _shallowEqual.default)(node, opts); -} -function isTSIntersectionType(node, opts) { - if (!node) return false; - if (node.type !== "TSIntersectionType") return false; - return opts == null || (0, _shallowEqual.default)(node, opts); -} -function isTSConditionalType(node, opts) { - if (!node) return false; - if (node.type !== "TSConditionalType") return false; - return opts == null || (0, _shallowEqual.default)(node, opts); -} -function isTSInferType(node, opts) { - if (!node) return false; - if (node.type !== "TSInferType") return false; - return opts == null || (0, _shallowEqual.default)(node, opts); -} -function isTSParenthesizedType(node, opts) { - if (!node) return false; - if (node.type !== "TSParenthesizedType") return false; - return opts == null || (0, _shallowEqual.default)(node, opts); -} -function isTSTypeOperator(node, opts) { - if (!node) return false; - if (node.type !== "TSTypeOperator") return false; - return opts == null || (0, _shallowEqual.default)(node, opts); -} -function isTSIndexedAccessType(node, opts) { - if (!node) return false; - if (node.type !== "TSIndexedAccessType") return false; - return opts == null || (0, _shallowEqual.default)(node, opts); -} -function isTSMappedType(node, opts) { - if (!node) return false; - if (node.type !== "TSMappedType") return false; - return opts == null || (0, _shallowEqual.default)(node, opts); -} -function isTSLiteralType(node, opts) { - if (!node) return false; - if (node.type !== "TSLiteralType") return false; - return opts == null || (0, _shallowEqual.default)(node, opts); -} -function isTSExpressionWithTypeArguments(node, opts) { - if (!node) return false; - if (node.type !== "TSExpressionWithTypeArguments") return false; - return opts == null || (0, _shallowEqual.default)(node, opts); -} -function isTSInterfaceDeclaration(node, opts) { - if (!node) return false; - if (node.type !== "TSInterfaceDeclaration") return false; - return opts == null || (0, _shallowEqual.default)(node, opts); -} -function isTSInterfaceBody(node, opts) { - if (!node) return false; - if (node.type !== "TSInterfaceBody") return false; - return opts == null || (0, _shallowEqual.default)(node, opts); -} -function isTSTypeAliasDeclaration(node, opts) { - if (!node) return false; - if (node.type !== "TSTypeAliasDeclaration") return false; - return opts == null || (0, _shallowEqual.default)(node, opts); -} -function isTSInstantiationExpression(node, opts) { - if (!node) return false; - if (node.type !== "TSInstantiationExpression") return false; - return opts == null || (0, _shallowEqual.default)(node, opts); -} -function isTSAsExpression(node, opts) { - if (!node) return false; - if (node.type !== "TSAsExpression") return false; - return opts == null || (0, _shallowEqual.default)(node, opts); -} -function isTSSatisfiesExpression(node, opts) { - if (!node) return false; - if (node.type !== "TSSatisfiesExpression") return false; - return opts == null || (0, _shallowEqual.default)(node, opts); -} -function isTSTypeAssertion(node, opts) { - if (!node) return false; - if (node.type !== "TSTypeAssertion") return false; - return opts == null || (0, _shallowEqual.default)(node, opts); -} -function isTSEnumDeclaration(node, opts) { - if (!node) return false; - if (node.type !== "TSEnumDeclaration") return false; - return opts == null || (0, _shallowEqual.default)(node, opts); -} -function isTSEnumMember(node, opts) { - if (!node) return false; - if (node.type !== "TSEnumMember") return false; - return opts == null || (0, _shallowEqual.default)(node, opts); -} -function isTSModuleDeclaration(node, opts) { - if (!node) return false; - if (node.type !== "TSModuleDeclaration") return false; - return opts == null || (0, _shallowEqual.default)(node, opts); -} -function isTSModuleBlock(node, opts) { - if (!node) return false; - if (node.type !== "TSModuleBlock") return false; - return opts == null || (0, _shallowEqual.default)(node, opts); -} -function isTSImportType(node, opts) { - if (!node) return false; - if (node.type !== "TSImportType") return false; - return opts == null || (0, _shallowEqual.default)(node, opts); -} -function isTSImportEqualsDeclaration(node, opts) { - if (!node) return false; - if (node.type !== "TSImportEqualsDeclaration") return false; - return opts == null || (0, _shallowEqual.default)(node, opts); -} -function isTSExternalModuleReference(node, opts) { - if (!node) return false; - if (node.type !== "TSExternalModuleReference") return false; - return opts == null || (0, _shallowEqual.default)(node, opts); -} -function isTSNonNullExpression(node, opts) { - if (!node) return false; - if (node.type !== "TSNonNullExpression") return false; - return opts == null || (0, _shallowEqual.default)(node, opts); -} -function isTSExportAssignment(node, opts) { - if (!node) return false; - if (node.type !== "TSExportAssignment") return false; - return opts == null || (0, _shallowEqual.default)(node, opts); -} -function isTSNamespaceExportDeclaration(node, opts) { - if (!node) return false; - if (node.type !== "TSNamespaceExportDeclaration") return false; - return opts == null || (0, _shallowEqual.default)(node, opts); -} -function isTSTypeAnnotation(node, opts) { - if (!node) return false; - if (node.type !== "TSTypeAnnotation") return false; - return opts == null || (0, _shallowEqual.default)(node, opts); -} -function isTSTypeParameterInstantiation(node, opts) { - if (!node) return false; - if (node.type !== "TSTypeParameterInstantiation") return false; - return opts == null || (0, _shallowEqual.default)(node, opts); -} -function isTSTypeParameterDeclaration(node, opts) { - if (!node) return false; - if (node.type !== "TSTypeParameterDeclaration") return false; - return opts == null || (0, _shallowEqual.default)(node, opts); -} -function isTSTypeParameter(node, opts) { - if (!node) return false; - if (node.type !== "TSTypeParameter") return false; - return opts == null || (0, _shallowEqual.default)(node, opts); -} -function isStandardized(node, opts) { - if (!node) return false; - switch (node.type) { - case "ArrayExpression": - case "AssignmentExpression": - case "BinaryExpression": - case "InterpreterDirective": - case "Directive": - case "DirectiveLiteral": - case "BlockStatement": - case "BreakStatement": - case "CallExpression": - case "CatchClause": - case "ConditionalExpression": - case "ContinueStatement": - case "DebuggerStatement": - case "DoWhileStatement": - case "EmptyStatement": - case "ExpressionStatement": - case "File": - case "ForInStatement": - case "ForStatement": - case "FunctionDeclaration": - case "FunctionExpression": - case "Identifier": - case "IfStatement": - case "LabeledStatement": - case "StringLiteral": - case "NumericLiteral": - case "NullLiteral": - case "BooleanLiteral": - case "RegExpLiteral": - case "LogicalExpression": - case "MemberExpression": - case "NewExpression": - case "Program": - case "ObjectExpression": - case "ObjectMethod": - case "ObjectProperty": - case "RestElement": - case "ReturnStatement": - case "SequenceExpression": - case "ParenthesizedExpression": - case "SwitchCase": - case "SwitchStatement": - case "ThisExpression": - case "ThrowStatement": - case "TryStatement": - case "UnaryExpression": - case "UpdateExpression": - case "VariableDeclaration": - case "VariableDeclarator": - case "WhileStatement": - case "WithStatement": - case "AssignmentPattern": - case "ArrayPattern": - case "ArrowFunctionExpression": - case "ClassBody": - case "ClassExpression": - case "ClassDeclaration": - case "ExportAllDeclaration": - case "ExportDefaultDeclaration": - case "ExportNamedDeclaration": - case "ExportSpecifier": - case "ForOfStatement": - case "ImportDeclaration": - case "ImportDefaultSpecifier": - case "ImportNamespaceSpecifier": - case "ImportSpecifier": - case "ImportExpression": - case "MetaProperty": - case "ClassMethod": - case "ObjectPattern": - case "SpreadElement": - case "Super": - case "TaggedTemplateExpression": - case "TemplateElement": - case "TemplateLiteral": - case "YieldExpression": - case "AwaitExpression": - case "Import": - case "BigIntLiteral": - case "ExportNamespaceSpecifier": - case "OptionalMemberExpression": - case "OptionalCallExpression": - case "ClassProperty": - case "ClassAccessorProperty": - case "ClassPrivateProperty": - case "ClassPrivateMethod": - case "PrivateName": - case "StaticBlock": - break; - case "Placeholder": - switch (node.expectedNode) { - case "Identifier": - case "StringLiteral": - case "BlockStatement": - case "ClassBody": - break; - default: - return false; - } - break; - default: - return false; - } - return opts == null || (0, _shallowEqual.default)(node, opts); -} -function isExpression(node, opts) { - if (!node) return false; - switch (node.type) { - case "ArrayExpression": - case "AssignmentExpression": - case "BinaryExpression": - case "CallExpression": - case "ConditionalExpression": - case "FunctionExpression": - case "Identifier": - case "StringLiteral": - case "NumericLiteral": - case "NullLiteral": - case "BooleanLiteral": - case "RegExpLiteral": - case "LogicalExpression": - case "MemberExpression": - case "NewExpression": - case "ObjectExpression": - case "SequenceExpression": - case "ParenthesizedExpression": - case "ThisExpression": - case "UnaryExpression": - case "UpdateExpression": - case "ArrowFunctionExpression": - case "ClassExpression": - case "ImportExpression": - case "MetaProperty": - case "Super": - case "TaggedTemplateExpression": - case "TemplateLiteral": - case "YieldExpression": - case "AwaitExpression": - case "Import": - case "BigIntLiteral": - case "OptionalMemberExpression": - case "OptionalCallExpression": - case "TypeCastExpression": - case "JSXElement": - case "JSXFragment": - case "BindExpression": - case "DoExpression": - case "RecordExpression": - case "TupleExpression": - case "DecimalLiteral": - case "ModuleExpression": - case "TopicReference": - case "PipelineTopicExpression": - case "PipelineBareFunction": - case "PipelinePrimaryTopicReference": - case "TSInstantiationExpression": - case "TSAsExpression": - case "TSSatisfiesExpression": - case "TSTypeAssertion": - case "TSNonNullExpression": - break; - case "Placeholder": - switch (node.expectedNode) { - case "Expression": - case "Identifier": - case "StringLiteral": - break; - default: - return false; - } - break; - default: - return false; - } - return opts == null || (0, _shallowEqual.default)(node, opts); -} -function isBinary(node, opts) { - if (!node) return false; - switch (node.type) { - case "BinaryExpression": - case "LogicalExpression": - break; - default: - return false; - } - return opts == null || (0, _shallowEqual.default)(node, opts); -} -function isScopable(node, opts) { - if (!node) return false; - switch (node.type) { - case "BlockStatement": - case "CatchClause": - case "DoWhileStatement": - case "ForInStatement": - case "ForStatement": - case "FunctionDeclaration": - case "FunctionExpression": - case "Program": - case "ObjectMethod": - case "SwitchStatement": - case "WhileStatement": - case "ArrowFunctionExpression": - case "ClassExpression": - case "ClassDeclaration": - case "ForOfStatement": - case "ClassMethod": - case "ClassPrivateMethod": - case "StaticBlock": - case "TSModuleBlock": - break; - case "Placeholder": - if (node.expectedNode === "BlockStatement") break; - default: - return false; - } - return opts == null || (0, _shallowEqual.default)(node, opts); -} -function isBlockParent(node, opts) { - if (!node) return false; - switch (node.type) { - case "BlockStatement": - case "CatchClause": - case "DoWhileStatement": - case "ForInStatement": - case "ForStatement": - case "FunctionDeclaration": - case "FunctionExpression": - case "Program": - case "ObjectMethod": - case "SwitchStatement": - case "WhileStatement": - case "ArrowFunctionExpression": - case "ForOfStatement": - case "ClassMethod": - case "ClassPrivateMethod": - case "StaticBlock": - case "TSModuleBlock": - break; - case "Placeholder": - if (node.expectedNode === "BlockStatement") break; - default: - return false; - } - return opts == null || (0, _shallowEqual.default)(node, opts); -} -function isBlock(node, opts) { - if (!node) return false; - switch (node.type) { - case "BlockStatement": - case "Program": - case "TSModuleBlock": - break; - case "Placeholder": - if (node.expectedNode === "BlockStatement") break; - default: - return false; - } - return opts == null || (0, _shallowEqual.default)(node, opts); -} -function isStatement(node, opts) { - if (!node) return false; - switch (node.type) { - case "BlockStatement": - case "BreakStatement": - case "ContinueStatement": - case "DebuggerStatement": - case "DoWhileStatement": - case "EmptyStatement": - case "ExpressionStatement": - case "ForInStatement": - case "ForStatement": - case "FunctionDeclaration": - case "IfStatement": - case "LabeledStatement": - case "ReturnStatement": - case "SwitchStatement": - case "ThrowStatement": - case "TryStatement": - case "VariableDeclaration": - case "WhileStatement": - case "WithStatement": - case "ClassDeclaration": - case "ExportAllDeclaration": - case "ExportDefaultDeclaration": - case "ExportNamedDeclaration": - case "ForOfStatement": - case "ImportDeclaration": - case "DeclareClass": - case "DeclareFunction": - case "DeclareInterface": - case "DeclareModule": - case "DeclareModuleExports": - case "DeclareTypeAlias": - case "DeclareOpaqueType": - case "DeclareVariable": - case "DeclareExportDeclaration": - case "DeclareExportAllDeclaration": - case "InterfaceDeclaration": - case "OpaqueType": - case "TypeAlias": - case "EnumDeclaration": - case "TSDeclareFunction": - case "TSInterfaceDeclaration": - case "TSTypeAliasDeclaration": - case "TSEnumDeclaration": - case "TSModuleDeclaration": - case "TSImportEqualsDeclaration": - case "TSExportAssignment": - case "TSNamespaceExportDeclaration": - break; - case "Placeholder": - switch (node.expectedNode) { - case "Statement": - case "Declaration": - case "BlockStatement": - break; - default: - return false; - } - break; - default: - return false; - } - return opts == null || (0, _shallowEqual.default)(node, opts); -} -function isTerminatorless(node, opts) { - if (!node) return false; - switch (node.type) { - case "BreakStatement": - case "ContinueStatement": - case "ReturnStatement": - case "ThrowStatement": - case "YieldExpression": - case "AwaitExpression": - break; - default: - return false; - } - return opts == null || (0, _shallowEqual.default)(node, opts); -} -function isCompletionStatement(node, opts) { - if (!node) return false; - switch (node.type) { - case "BreakStatement": - case "ContinueStatement": - case "ReturnStatement": - case "ThrowStatement": - break; - default: - return false; - } - return opts == null || (0, _shallowEqual.default)(node, opts); -} -function isConditional(node, opts) { - if (!node) return false; - switch (node.type) { - case "ConditionalExpression": - case "IfStatement": - break; - default: - return false; - } - return opts == null || (0, _shallowEqual.default)(node, opts); -} -function isLoop(node, opts) { - if (!node) return false; - switch (node.type) { - case "DoWhileStatement": - case "ForInStatement": - case "ForStatement": - case "WhileStatement": - case "ForOfStatement": - break; - default: - return false; - } - return opts == null || (0, _shallowEqual.default)(node, opts); -} -function isWhile(node, opts) { - if (!node) return false; - switch (node.type) { - case "DoWhileStatement": - case "WhileStatement": - break; - default: - return false; - } - return opts == null || (0, _shallowEqual.default)(node, opts); -} -function isExpressionWrapper(node, opts) { - if (!node) return false; - switch (node.type) { - case "ExpressionStatement": - case "ParenthesizedExpression": - case "TypeCastExpression": - break; - default: - return false; - } - return opts == null || (0, _shallowEqual.default)(node, opts); -} -function isFor(node, opts) { - if (!node) return false; - switch (node.type) { - case "ForInStatement": - case "ForStatement": - case "ForOfStatement": - break; - default: - return false; - } - return opts == null || (0, _shallowEqual.default)(node, opts); -} -function isForXStatement(node, opts) { - if (!node) return false; - switch (node.type) { - case "ForInStatement": - case "ForOfStatement": - break; - default: - return false; - } - return opts == null || (0, _shallowEqual.default)(node, opts); -} -function isFunction(node, opts) { - if (!node) return false; - switch (node.type) { - case "FunctionDeclaration": - case "FunctionExpression": - case "ObjectMethod": - case "ArrowFunctionExpression": - case "ClassMethod": - case "ClassPrivateMethod": - break; - default: - return false; - } - return opts == null || (0, _shallowEqual.default)(node, opts); -} -function isFunctionParent(node, opts) { - if (!node) return false; - switch (node.type) { - case "FunctionDeclaration": - case "FunctionExpression": - case "ObjectMethod": - case "ArrowFunctionExpression": - case "ClassMethod": - case "ClassPrivateMethod": - case "StaticBlock": - case "TSModuleBlock": - break; - default: - return false; - } - return opts == null || (0, _shallowEqual.default)(node, opts); -} -function isPureish(node, opts) { - if (!node) return false; - switch (node.type) { - case "FunctionDeclaration": - case "FunctionExpression": - case "StringLiteral": - case "NumericLiteral": - case "NullLiteral": - case "BooleanLiteral": - case "RegExpLiteral": - case "ArrowFunctionExpression": - case "BigIntLiteral": - case "DecimalLiteral": - break; - case "Placeholder": - if (node.expectedNode === "StringLiteral") break; - default: - return false; - } - return opts == null || (0, _shallowEqual.default)(node, opts); -} -function isDeclaration(node, opts) { - if (!node) return false; - switch (node.type) { - case "FunctionDeclaration": - case "VariableDeclaration": - case "ClassDeclaration": - case "ExportAllDeclaration": - case "ExportDefaultDeclaration": - case "ExportNamedDeclaration": - case "ImportDeclaration": - case "DeclareClass": - case "DeclareFunction": - case "DeclareInterface": - case "DeclareModule": - case "DeclareModuleExports": - case "DeclareTypeAlias": - case "DeclareOpaqueType": - case "DeclareVariable": - case "DeclareExportDeclaration": - case "DeclareExportAllDeclaration": - case "InterfaceDeclaration": - case "OpaqueType": - case "TypeAlias": - case "EnumDeclaration": - case "TSDeclareFunction": - case "TSInterfaceDeclaration": - case "TSTypeAliasDeclaration": - case "TSEnumDeclaration": - case "TSModuleDeclaration": - break; - case "Placeholder": - if (node.expectedNode === "Declaration") break; - default: - return false; - } - return opts == null || (0, _shallowEqual.default)(node, opts); -} -function isPatternLike(node, opts) { - if (!node) return false; - switch (node.type) { - case "Identifier": - case "RestElement": - case "AssignmentPattern": - case "ArrayPattern": - case "ObjectPattern": - case "TSAsExpression": - case "TSSatisfiesExpression": - case "TSTypeAssertion": - case "TSNonNullExpression": - break; - case "Placeholder": - switch (node.expectedNode) { - case "Pattern": - case "Identifier": - break; - default: - return false; - } - break; - default: - return false; - } - return opts == null || (0, _shallowEqual.default)(node, opts); -} -function isLVal(node, opts) { - if (!node) return false; - switch (node.type) { - case "Identifier": - case "MemberExpression": - case "RestElement": - case "AssignmentPattern": - case "ArrayPattern": - case "ObjectPattern": - case "TSParameterProperty": - case "TSAsExpression": - case "TSSatisfiesExpression": - case "TSTypeAssertion": - case "TSNonNullExpression": - break; - case "Placeholder": - switch (node.expectedNode) { - case "Pattern": - case "Identifier": - break; - default: - return false; - } - break; - default: - return false; - } - return opts == null || (0, _shallowEqual.default)(node, opts); -} -function isTSEntityName(node, opts) { - if (!node) return false; - switch (node.type) { - case "Identifier": - case "TSQualifiedName": - break; - case "Placeholder": - if (node.expectedNode === "Identifier") break; - default: - return false; - } - return opts == null || (0, _shallowEqual.default)(node, opts); -} -function isLiteral(node, opts) { - if (!node) return false; - switch (node.type) { - case "StringLiteral": - case "NumericLiteral": - case "NullLiteral": - case "BooleanLiteral": - case "RegExpLiteral": - case "TemplateLiteral": - case "BigIntLiteral": - case "DecimalLiteral": - break; - case "Placeholder": - if (node.expectedNode === "StringLiteral") break; - default: - return false; - } - return opts == null || (0, _shallowEqual.default)(node, opts); -} -function isImmutable(node, opts) { - if (!node) return false; - switch (node.type) { - case "StringLiteral": - case "NumericLiteral": - case "NullLiteral": - case "BooleanLiteral": - case "BigIntLiteral": - case "JSXAttribute": - case "JSXClosingElement": - case "JSXElement": - case "JSXExpressionContainer": - case "JSXSpreadChild": - case "JSXOpeningElement": - case "JSXText": - case "JSXFragment": - case "JSXOpeningFragment": - case "JSXClosingFragment": - case "DecimalLiteral": - break; - case "Placeholder": - if (node.expectedNode === "StringLiteral") break; - default: - return false; - } - return opts == null || (0, _shallowEqual.default)(node, opts); -} -function isUserWhitespacable(node, opts) { - if (!node) return false; - switch (node.type) { - case "ObjectMethod": - case "ObjectProperty": - case "ObjectTypeInternalSlot": - case "ObjectTypeCallProperty": - case "ObjectTypeIndexer": - case "ObjectTypeProperty": - case "ObjectTypeSpreadProperty": - break; - default: - return false; - } - return opts == null || (0, _shallowEqual.default)(node, opts); -} -function isMethod(node, opts) { - if (!node) return false; - switch (node.type) { - case "ObjectMethod": - case "ClassMethod": - case "ClassPrivateMethod": - break; - default: - return false; - } - return opts == null || (0, _shallowEqual.default)(node, opts); -} -function isObjectMember(node, opts) { - if (!node) return false; - switch (node.type) { - case "ObjectMethod": - case "ObjectProperty": - break; - default: - return false; - } - return opts == null || (0, _shallowEqual.default)(node, opts); -} -function isProperty(node, opts) { - if (!node) return false; - switch (node.type) { - case "ObjectProperty": - case "ClassProperty": - case "ClassAccessorProperty": - case "ClassPrivateProperty": - break; - default: - return false; - } - return opts == null || (0, _shallowEqual.default)(node, opts); -} -function isUnaryLike(node, opts) { - if (!node) return false; - switch (node.type) { - case "UnaryExpression": - case "SpreadElement": - break; - default: - return false; - } - return opts == null || (0, _shallowEqual.default)(node, opts); -} -function isPattern(node, opts) { - if (!node) return false; - switch (node.type) { - case "AssignmentPattern": - case "ArrayPattern": - case "ObjectPattern": - break; - case "Placeholder": - if (node.expectedNode === "Pattern") break; - default: - return false; - } - return opts == null || (0, _shallowEqual.default)(node, opts); -} -function isClass(node, opts) { - if (!node) return false; - switch (node.type) { - case "ClassExpression": - case "ClassDeclaration": - break; - default: - return false; - } - return opts == null || (0, _shallowEqual.default)(node, opts); -} -function isImportOrExportDeclaration(node, opts) { - if (!node) return false; - switch (node.type) { - case "ExportAllDeclaration": - case "ExportDefaultDeclaration": - case "ExportNamedDeclaration": - case "ImportDeclaration": - break; - default: - return false; - } - return opts == null || (0, _shallowEqual.default)(node, opts); -} -function isExportDeclaration(node, opts) { - if (!node) return false; - switch (node.type) { - case "ExportAllDeclaration": - case "ExportDefaultDeclaration": - case "ExportNamedDeclaration": - break; - default: - return false; - } - return opts == null || (0, _shallowEqual.default)(node, opts); -} -function isModuleSpecifier(node, opts) { - if (!node) return false; - switch (node.type) { - case "ExportSpecifier": - case "ImportDefaultSpecifier": - case "ImportNamespaceSpecifier": - case "ImportSpecifier": - case "ExportNamespaceSpecifier": - case "ExportDefaultSpecifier": - break; - default: - return false; - } - return opts == null || (0, _shallowEqual.default)(node, opts); -} -function isAccessor(node, opts) { - if (!node) return false; - switch (node.type) { - case "ClassAccessorProperty": - break; - default: - return false; - } - return opts == null || (0, _shallowEqual.default)(node, opts); -} -function isPrivate(node, opts) { - if (!node) return false; - switch (node.type) { - case "ClassPrivateProperty": - case "ClassPrivateMethod": - case "PrivateName": - break; - default: - return false; - } - return opts == null || (0, _shallowEqual.default)(node, opts); -} -function isFlow(node, opts) { - if (!node) return false; - switch (node.type) { - case "AnyTypeAnnotation": - case "ArrayTypeAnnotation": - case "BooleanTypeAnnotation": - case "BooleanLiteralTypeAnnotation": - case "NullLiteralTypeAnnotation": - case "ClassImplements": - case "DeclareClass": - case "DeclareFunction": - case "DeclareInterface": - case "DeclareModule": - case "DeclareModuleExports": - case "DeclareTypeAlias": - case "DeclareOpaqueType": - case "DeclareVariable": - case "DeclareExportDeclaration": - case "DeclareExportAllDeclaration": - case "DeclaredPredicate": - case "ExistsTypeAnnotation": - case "FunctionTypeAnnotation": - case "FunctionTypeParam": - case "GenericTypeAnnotation": - case "InferredPredicate": - case "InterfaceExtends": - case "InterfaceDeclaration": - case "InterfaceTypeAnnotation": - case "IntersectionTypeAnnotation": - case "MixedTypeAnnotation": - case "EmptyTypeAnnotation": - case "NullableTypeAnnotation": - case "NumberLiteralTypeAnnotation": - case "NumberTypeAnnotation": - case "ObjectTypeAnnotation": - case "ObjectTypeInternalSlot": - case "ObjectTypeCallProperty": - case "ObjectTypeIndexer": - case "ObjectTypeProperty": - case "ObjectTypeSpreadProperty": - case "OpaqueType": - case "QualifiedTypeIdentifier": - case "StringLiteralTypeAnnotation": - case "StringTypeAnnotation": - case "SymbolTypeAnnotation": - case "ThisTypeAnnotation": - case "TupleTypeAnnotation": - case "TypeofTypeAnnotation": - case "TypeAlias": - case "TypeAnnotation": - case "TypeCastExpression": - case "TypeParameter": - case "TypeParameterDeclaration": - case "TypeParameterInstantiation": - case "UnionTypeAnnotation": - case "Variance": - case "VoidTypeAnnotation": - case "EnumDeclaration": - case "EnumBooleanBody": - case "EnumNumberBody": - case "EnumStringBody": - case "EnumSymbolBody": - case "EnumBooleanMember": - case "EnumNumberMember": - case "EnumStringMember": - case "EnumDefaultedMember": - case "IndexedAccessType": - case "OptionalIndexedAccessType": - break; - default: - return false; - } - return opts == null || (0, _shallowEqual.default)(node, opts); -} -function isFlowType(node, opts) { - if (!node) return false; - switch (node.type) { - case "AnyTypeAnnotation": - case "ArrayTypeAnnotation": - case "BooleanTypeAnnotation": - case "BooleanLiteralTypeAnnotation": - case "NullLiteralTypeAnnotation": - case "ExistsTypeAnnotation": - case "FunctionTypeAnnotation": - case "GenericTypeAnnotation": - case "InterfaceTypeAnnotation": - case "IntersectionTypeAnnotation": - case "MixedTypeAnnotation": - case "EmptyTypeAnnotation": - case "NullableTypeAnnotation": - case "NumberLiteralTypeAnnotation": - case "NumberTypeAnnotation": - case "ObjectTypeAnnotation": - case "StringLiteralTypeAnnotation": - case "StringTypeAnnotation": - case "SymbolTypeAnnotation": - case "ThisTypeAnnotation": - case "TupleTypeAnnotation": - case "TypeofTypeAnnotation": - case "UnionTypeAnnotation": - case "VoidTypeAnnotation": - case "IndexedAccessType": - case "OptionalIndexedAccessType": - break; - default: - return false; - } - return opts == null || (0, _shallowEqual.default)(node, opts); -} -function isFlowBaseAnnotation(node, opts) { - if (!node) return false; - switch (node.type) { - case "AnyTypeAnnotation": - case "BooleanTypeAnnotation": - case "NullLiteralTypeAnnotation": - case "MixedTypeAnnotation": - case "EmptyTypeAnnotation": - case "NumberTypeAnnotation": - case "StringTypeAnnotation": - case "SymbolTypeAnnotation": - case "ThisTypeAnnotation": - case "VoidTypeAnnotation": - break; - default: - return false; - } - return opts == null || (0, _shallowEqual.default)(node, opts); -} -function isFlowDeclaration(node, opts) { - if (!node) return false; - switch (node.type) { - case "DeclareClass": - case "DeclareFunction": - case "DeclareInterface": - case "DeclareModule": - case "DeclareModuleExports": - case "DeclareTypeAlias": - case "DeclareOpaqueType": - case "DeclareVariable": - case "DeclareExportDeclaration": - case "DeclareExportAllDeclaration": - case "InterfaceDeclaration": - case "OpaqueType": - case "TypeAlias": - break; - default: - return false; - } - return opts == null || (0, _shallowEqual.default)(node, opts); -} -function isFlowPredicate(node, opts) { - if (!node) return false; - switch (node.type) { - case "DeclaredPredicate": - case "InferredPredicate": - break; - default: - return false; - } - return opts == null || (0, _shallowEqual.default)(node, opts); -} -function isEnumBody(node, opts) { - if (!node) return false; - switch (node.type) { - case "EnumBooleanBody": - case "EnumNumberBody": - case "EnumStringBody": - case "EnumSymbolBody": - break; - default: - return false; - } - return opts == null || (0, _shallowEqual.default)(node, opts); -} -function isEnumMember(node, opts) { - if (!node) return false; - switch (node.type) { - case "EnumBooleanMember": - case "EnumNumberMember": - case "EnumStringMember": - case "EnumDefaultedMember": - break; - default: - return false; - } - return opts == null || (0, _shallowEqual.default)(node, opts); -} -function isJSX(node, opts) { - if (!node) return false; - switch (node.type) { - case "JSXAttribute": - case "JSXClosingElement": - case "JSXElement": - case "JSXEmptyExpression": - case "JSXExpressionContainer": - case "JSXSpreadChild": - case "JSXIdentifier": - case "JSXMemberExpression": - case "JSXNamespacedName": - case "JSXOpeningElement": - case "JSXSpreadAttribute": - case "JSXText": - case "JSXFragment": - case "JSXOpeningFragment": - case "JSXClosingFragment": - break; - default: - return false; - } - return opts == null || (0, _shallowEqual.default)(node, opts); -} -function isMiscellaneous(node, opts) { - if (!node) return false; - switch (node.type) { - case "Noop": - case "Placeholder": - case "V8IntrinsicIdentifier": - break; - default: - return false; - } - return opts == null || (0, _shallowEqual.default)(node, opts); -} -function isTypeScript(node, opts) { - if (!node) return false; - switch (node.type) { - case "TSParameterProperty": - case "TSDeclareFunction": - case "TSDeclareMethod": - case "TSQualifiedName": - case "TSCallSignatureDeclaration": - case "TSConstructSignatureDeclaration": - case "TSPropertySignature": - case "TSMethodSignature": - case "TSIndexSignature": - case "TSAnyKeyword": - case "TSBooleanKeyword": - case "TSBigIntKeyword": - case "TSIntrinsicKeyword": - case "TSNeverKeyword": - case "TSNullKeyword": - case "TSNumberKeyword": - case "TSObjectKeyword": - case "TSStringKeyword": - case "TSSymbolKeyword": - case "TSUndefinedKeyword": - case "TSUnknownKeyword": - case "TSVoidKeyword": - case "TSThisType": - case "TSFunctionType": - case "TSConstructorType": - case "TSTypeReference": - case "TSTypePredicate": - case "TSTypeQuery": - case "TSTypeLiteral": - case "TSArrayType": - case "TSTupleType": - case "TSOptionalType": - case "TSRestType": - case "TSNamedTupleMember": - case "TSUnionType": - case "TSIntersectionType": - case "TSConditionalType": - case "TSInferType": - case "TSParenthesizedType": - case "TSTypeOperator": - case "TSIndexedAccessType": - case "TSMappedType": - case "TSLiteralType": - case "TSExpressionWithTypeArguments": - case "TSInterfaceDeclaration": - case "TSInterfaceBody": - case "TSTypeAliasDeclaration": - case "TSInstantiationExpression": - case "TSAsExpression": - case "TSSatisfiesExpression": - case "TSTypeAssertion": - case "TSEnumDeclaration": - case "TSEnumMember": - case "TSModuleDeclaration": - case "TSModuleBlock": - case "TSImportType": - case "TSImportEqualsDeclaration": - case "TSExternalModuleReference": - case "TSNonNullExpression": - case "TSExportAssignment": - case "TSNamespaceExportDeclaration": - case "TSTypeAnnotation": - case "TSTypeParameterInstantiation": - case "TSTypeParameterDeclaration": - case "TSTypeParameter": - break; - default: - return false; - } - return opts == null || (0, _shallowEqual.default)(node, opts); -} -function isTSTypeElement(node, opts) { - if (!node) return false; - switch (node.type) { - case "TSCallSignatureDeclaration": - case "TSConstructSignatureDeclaration": - case "TSPropertySignature": - case "TSMethodSignature": - case "TSIndexSignature": - break; - default: - return false; - } - return opts == null || (0, _shallowEqual.default)(node, opts); -} -function isTSType(node, opts) { - if (!node) return false; - switch (node.type) { - case "TSAnyKeyword": - case "TSBooleanKeyword": - case "TSBigIntKeyword": - case "TSIntrinsicKeyword": - case "TSNeverKeyword": - case "TSNullKeyword": - case "TSNumberKeyword": - case "TSObjectKeyword": - case "TSStringKeyword": - case "TSSymbolKeyword": - case "TSUndefinedKeyword": - case "TSUnknownKeyword": - case "TSVoidKeyword": - case "TSThisType": - case "TSFunctionType": - case "TSConstructorType": - case "TSTypeReference": - case "TSTypePredicate": - case "TSTypeQuery": - case "TSTypeLiteral": - case "TSArrayType": - case "TSTupleType": - case "TSOptionalType": - case "TSRestType": - case "TSUnionType": - case "TSIntersectionType": - case "TSConditionalType": - case "TSInferType": - case "TSParenthesizedType": - case "TSTypeOperator": - case "TSIndexedAccessType": - case "TSMappedType": - case "TSLiteralType": - case "TSExpressionWithTypeArguments": - case "TSImportType": - break; - default: - return false; - } - return opts == null || (0, _shallowEqual.default)(node, opts); -} -function isTSBaseType(node, opts) { - if (!node) return false; - switch (node.type) { - case "TSAnyKeyword": - case "TSBooleanKeyword": - case "TSBigIntKeyword": - case "TSIntrinsicKeyword": - case "TSNeverKeyword": - case "TSNullKeyword": - case "TSNumberKeyword": - case "TSObjectKeyword": - case "TSStringKeyword": - case "TSSymbolKeyword": - case "TSUndefinedKeyword": - case "TSUnknownKeyword": - case "TSVoidKeyword": - case "TSThisType": - case "TSLiteralType": - break; - default: - return false; - } - return opts == null || (0, _shallowEqual.default)(node, opts); -} -function isNumberLiteral(node, opts) { - (0, _deprecationWarning.default)("isNumberLiteral", "isNumericLiteral"); - if (!node) return false; - if (node.type !== "NumberLiteral") return false; - return opts == null || (0, _shallowEqual.default)(node, opts); -} -function isRegexLiteral(node, opts) { - (0, _deprecationWarning.default)("isRegexLiteral", "isRegExpLiteral"); - if (!node) return false; - if (node.type !== "RegexLiteral") return false; - return opts == null || (0, _shallowEqual.default)(node, opts); -} -function isRestProperty(node, opts) { - (0, _deprecationWarning.default)("isRestProperty", "isRestElement"); - if (!node) return false; - if (node.type !== "RestProperty") return false; - return opts == null || (0, _shallowEqual.default)(node, opts); -} -function isSpreadProperty(node, opts) { - (0, _deprecationWarning.default)("isSpreadProperty", "isSpreadElement"); - if (!node) return false; - if (node.type !== "SpreadProperty") return false; - return opts == null || (0, _shallowEqual.default)(node, opts); -} -function isModuleDeclaration(node, opts) { - (0, _deprecationWarning.default)("isModuleDeclaration", "isImportOrExportDeclaration"); - return isImportOrExportDeclaration(node, opts); -} - -//# sourceMappingURL=index.js.map diff --git a/tools/eslint/node_modules/@babel/types/lib/validators/is.js b/tools/eslint/node_modules/@babel/types/lib/validators/is.js deleted file mode 100644 index b4f2649af865f3..00000000000000 --- a/tools/eslint/node_modules/@babel/types/lib/validators/is.js +++ /dev/null @@ -1,27 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.default = is; -var _shallowEqual = require("../utils/shallowEqual.js"); -var _isType = require("./isType.js"); -var _isPlaceholderType = require("./isPlaceholderType.js"); -var _index = require("../definitions/index.js"); -function is(type, node, opts) { - if (!node) return false; - const matches = (0, _isType.default)(node.type, type); - if (!matches) { - if (!opts && node.type === "Placeholder" && type in _index.FLIPPED_ALIAS_KEYS) { - return (0, _isPlaceholderType.default)(node.expectedNode, type); - } - return false; - } - if (typeof opts === "undefined") { - return true; - } else { - return (0, _shallowEqual.default)(node, opts); - } -} - -//# sourceMappingURL=is.js.map diff --git a/tools/eslint/node_modules/@babel/types/lib/validators/isBinding.js b/tools/eslint/node_modules/@babel/types/lib/validators/isBinding.js deleted file mode 100644 index b3b1a4b835e236..00000000000000 --- a/tools/eslint/node_modules/@babel/types/lib/validators/isBinding.js +++ /dev/null @@ -1,27 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.default = isBinding; -var _getBindingIdentifiers = require("../retrievers/getBindingIdentifiers.js"); -function isBinding(node, parent, grandparent) { - if (grandparent && node.type === "Identifier" && parent.type === "ObjectProperty" && grandparent.type === "ObjectExpression") { - return false; - } - const keys = _getBindingIdentifiers.default.keys[parent.type]; - if (keys) { - for (let i = 0; i < keys.length; i++) { - const key = keys[i]; - const val = parent[key]; - if (Array.isArray(val)) { - if (val.includes(node)) return true; - } else { - if (val === node) return true; - } - } - } - return false; -} - -//# sourceMappingURL=isBinding.js.map diff --git a/tools/eslint/node_modules/@babel/types/lib/validators/isBlockScoped.js b/tools/eslint/node_modules/@babel/types/lib/validators/isBlockScoped.js deleted file mode 100644 index a552f65f62ba6c..00000000000000 --- a/tools/eslint/node_modules/@babel/types/lib/validators/isBlockScoped.js +++ /dev/null @@ -1,13 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.default = isBlockScoped; -var _index = require("./generated/index.js"); -var _isLet = require("./isLet.js"); -function isBlockScoped(node) { - return (0, _index.isFunctionDeclaration)(node) || (0, _index.isClassDeclaration)(node) || (0, _isLet.default)(node); -} - -//# sourceMappingURL=isBlockScoped.js.map diff --git a/tools/eslint/node_modules/@babel/types/lib/validators/isImmutable.js b/tools/eslint/node_modules/@babel/types/lib/validators/isImmutable.js deleted file mode 100644 index 324fae63afadf3..00000000000000 --- a/tools/eslint/node_modules/@babel/types/lib/validators/isImmutable.js +++ /dev/null @@ -1,21 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.default = isImmutable; -var _isType = require("./isType.js"); -var _index = require("./generated/index.js"); -function isImmutable(node) { - if ((0, _isType.default)(node.type, "Immutable")) return true; - if ((0, _index.isIdentifier)(node)) { - if (node.name === "undefined") { - return true; - } else { - return false; - } - } - return false; -} - -//# sourceMappingURL=isImmutable.js.map diff --git a/tools/eslint/node_modules/@babel/types/lib/validators/isLet.js b/tools/eslint/node_modules/@babel/types/lib/validators/isLet.js deleted file mode 100644 index 2965a8af82861c..00000000000000 --- a/tools/eslint/node_modules/@babel/types/lib/validators/isLet.js +++ /dev/null @@ -1,13 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.default = isLet; -var _index = require("./generated/index.js"); -var _index2 = require("../constants/index.js"); -function isLet(node) { - return (0, _index.isVariableDeclaration)(node) && (node.kind !== "var" || node[_index2.BLOCK_SCOPED_SYMBOL]); -} - -//# sourceMappingURL=isLet.js.map diff --git a/tools/eslint/node_modules/@babel/types/lib/validators/isNode.js b/tools/eslint/node_modules/@babel/types/lib/validators/isNode.js deleted file mode 100644 index d80ce74a5c948b..00000000000000 --- a/tools/eslint/node_modules/@babel/types/lib/validators/isNode.js +++ /dev/null @@ -1,12 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.default = isNode; -var _index = require("../definitions/index.js"); -function isNode(node) { - return !!(node && _index.VISITOR_KEYS[node.type]); -} - -//# sourceMappingURL=isNode.js.map diff --git a/tools/eslint/node_modules/@babel/types/lib/validators/isNodesEquivalent.js b/tools/eslint/node_modules/@babel/types/lib/validators/isNodesEquivalent.js deleted file mode 100644 index fc399028b439f2..00000000000000 --- a/tools/eslint/node_modules/@babel/types/lib/validators/isNodesEquivalent.js +++ /dev/null @@ -1,57 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.default = isNodesEquivalent; -var _index = require("../definitions/index.js"); -function isNodesEquivalent(a, b) { - if (typeof a !== "object" || typeof b !== "object" || a == null || b == null) { - return a === b; - } - if (a.type !== b.type) { - return false; - } - const fields = Object.keys(_index.NODE_FIELDS[a.type] || a.type); - const visitorKeys = _index.VISITOR_KEYS[a.type]; - for (const field of fields) { - const val_a = a[field]; - const val_b = b[field]; - if (typeof val_a !== typeof val_b) { - return false; - } - if (val_a == null && val_b == null) { - continue; - } else if (val_a == null || val_b == null) { - return false; - } - if (Array.isArray(val_a)) { - if (!Array.isArray(val_b)) { - return false; - } - if (val_a.length !== val_b.length) { - return false; - } - for (let i = 0; i < val_a.length; i++) { - if (!isNodesEquivalent(val_a[i], val_b[i])) { - return false; - } - } - continue; - } - if (typeof val_a === "object" && !(visitorKeys != null && visitorKeys.includes(field))) { - for (const key of Object.keys(val_a)) { - if (val_a[key] !== val_b[key]) { - return false; - } - } - continue; - } - if (!isNodesEquivalent(val_a, val_b)) { - return false; - } - } - return true; -} - -//# sourceMappingURL=isNodesEquivalent.js.map diff --git a/tools/eslint/node_modules/@babel/types/lib/validators/isPlaceholderType.js b/tools/eslint/node_modules/@babel/types/lib/validators/isPlaceholderType.js deleted file mode 100644 index ed8f24795cd994..00000000000000 --- a/tools/eslint/node_modules/@babel/types/lib/validators/isPlaceholderType.js +++ /dev/null @@ -1,19 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.default = isPlaceholderType; -var _index = require("../definitions/index.js"); -function isPlaceholderType(placeholderType, targetType) { - if (placeholderType === targetType) return true; - const aliases = _index.PLACEHOLDERS_ALIAS[placeholderType]; - if (aliases) { - for (const alias of aliases) { - if (targetType === alias) return true; - } - } - return false; -} - -//# sourceMappingURL=isPlaceholderType.js.map diff --git a/tools/eslint/node_modules/@babel/types/lib/validators/isReferenced.js b/tools/eslint/node_modules/@babel/types/lib/validators/isReferenced.js deleted file mode 100644 index f8084f1ac0126a..00000000000000 --- a/tools/eslint/node_modules/@babel/types/lib/validators/isReferenced.js +++ /dev/null @@ -1,96 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.default = isReferenced; -function isReferenced(node, parent, grandparent) { - switch (parent.type) { - case "MemberExpression": - case "OptionalMemberExpression": - if (parent.property === node) { - return !!parent.computed; - } - return parent.object === node; - case "JSXMemberExpression": - return parent.object === node; - case "VariableDeclarator": - return parent.init === node; - case "ArrowFunctionExpression": - return parent.body === node; - case "PrivateName": - return false; - case "ClassMethod": - case "ClassPrivateMethod": - case "ObjectMethod": - if (parent.key === node) { - return !!parent.computed; - } - return false; - case "ObjectProperty": - if (parent.key === node) { - return !!parent.computed; - } - return !grandparent || grandparent.type !== "ObjectPattern"; - case "ClassProperty": - case "ClassAccessorProperty": - if (parent.key === node) { - return !!parent.computed; - } - return true; - case "ClassPrivateProperty": - return parent.key !== node; - case "ClassDeclaration": - case "ClassExpression": - return parent.superClass === node; - case "AssignmentExpression": - return parent.right === node; - case "AssignmentPattern": - return parent.right === node; - case "LabeledStatement": - return false; - case "CatchClause": - return false; - case "RestElement": - return false; - case "BreakStatement": - case "ContinueStatement": - return false; - case "FunctionDeclaration": - case "FunctionExpression": - return false; - case "ExportNamespaceSpecifier": - case "ExportDefaultSpecifier": - return false; - case "ExportSpecifier": - if (grandparent != null && grandparent.source) { - return false; - } - return parent.local === node; - case "ImportDefaultSpecifier": - case "ImportNamespaceSpecifier": - case "ImportSpecifier": - return false; - case "ImportAttribute": - return false; - case "JSXAttribute": - return false; - case "ObjectPattern": - case "ArrayPattern": - return false; - case "MetaProperty": - return false; - case "ObjectTypeProperty": - return parent.key !== node; - case "TSEnumMember": - return parent.id !== node; - case "TSPropertySignature": - if (parent.key === node) { - return !!parent.computed; - } - return true; - } - return true; -} - -//# sourceMappingURL=isReferenced.js.map diff --git a/tools/eslint/node_modules/@babel/types/lib/validators/isScope.js b/tools/eslint/node_modules/@babel/types/lib/validators/isScope.js deleted file mode 100644 index 40b5dc28ee41b8..00000000000000 --- a/tools/eslint/node_modules/@babel/types/lib/validators/isScope.js +++ /dev/null @@ -1,18 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.default = isScope; -var _index = require("./generated/index.js"); -function isScope(node, parent) { - if ((0, _index.isBlockStatement)(node) && ((0, _index.isFunction)(parent) || (0, _index.isCatchClause)(parent))) { - return false; - } - if ((0, _index.isPattern)(node) && ((0, _index.isFunction)(parent) || (0, _index.isCatchClause)(parent))) { - return true; - } - return (0, _index.isScopable)(node); -} - -//# sourceMappingURL=isScope.js.map diff --git a/tools/eslint/node_modules/@babel/types/lib/validators/isSpecifierDefault.js b/tools/eslint/node_modules/@babel/types/lib/validators/isSpecifierDefault.js deleted file mode 100644 index fc492b1cfdaf1e..00000000000000 --- a/tools/eslint/node_modules/@babel/types/lib/validators/isSpecifierDefault.js +++ /dev/null @@ -1,14 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.default = isSpecifierDefault; -var _index = require("./generated/index.js"); -function isSpecifierDefault(specifier) { - return (0, _index.isImportDefaultSpecifier)(specifier) || (0, _index.isIdentifier)(specifier.imported || specifier.exported, { - name: "default" - }); -} - -//# sourceMappingURL=isSpecifierDefault.js.map diff --git a/tools/eslint/node_modules/@babel/types/lib/validators/isType.js b/tools/eslint/node_modules/@babel/types/lib/validators/isType.js deleted file mode 100644 index b3430839401afd..00000000000000 --- a/tools/eslint/node_modules/@babel/types/lib/validators/isType.js +++ /dev/null @@ -1,22 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.default = isType; -var _index = require("../definitions/index.js"); -function isType(nodeType, targetType) { - if (nodeType === targetType) return true; - if (nodeType == null) return false; - if (_index.ALIAS_KEYS[targetType]) return false; - const aliases = _index.FLIPPED_ALIAS_KEYS[targetType]; - if (aliases) { - if (aliases[0] === nodeType) return true; - for (const alias of aliases) { - if (nodeType === alias) return true; - } - } - return false; -} - -//# sourceMappingURL=isType.js.map diff --git a/tools/eslint/node_modules/@babel/types/lib/validators/isValidES3Identifier.js b/tools/eslint/node_modules/@babel/types/lib/validators/isValidES3Identifier.js deleted file mode 100644 index 08c7d0ab1236b5..00000000000000 --- a/tools/eslint/node_modules/@babel/types/lib/validators/isValidES3Identifier.js +++ /dev/null @@ -1,13 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.default = isValidES3Identifier; -var _isValidIdentifier = require("./isValidIdentifier.js"); -const RESERVED_WORDS_ES3_ONLY = new Set(["abstract", "boolean", "byte", "char", "double", "enum", "final", "float", "goto", "implements", "int", "interface", "long", "native", "package", "private", "protected", "public", "short", "static", "synchronized", "throws", "transient", "volatile"]); -function isValidES3Identifier(name) { - return (0, _isValidIdentifier.default)(name) && !RESERVED_WORDS_ES3_ONLY.has(name); -} - -//# sourceMappingURL=isValidES3Identifier.js.map diff --git a/tools/eslint/node_modules/@babel/types/lib/validators/isValidIdentifier.js b/tools/eslint/node_modules/@babel/types/lib/validators/isValidIdentifier.js deleted file mode 100644 index b8674b5d680cfd..00000000000000 --- a/tools/eslint/node_modules/@babel/types/lib/validators/isValidIdentifier.js +++ /dev/null @@ -1,18 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.default = isValidIdentifier; -var _helperValidatorIdentifier = require("@babel/helper-validator-identifier"); -function isValidIdentifier(name, reserved = true) { - if (typeof name !== "string") return false; - if (reserved) { - if ((0, _helperValidatorIdentifier.isKeyword)(name) || (0, _helperValidatorIdentifier.isStrictReservedWord)(name, true)) { - return false; - } - } - return (0, _helperValidatorIdentifier.isIdentifierName)(name); -} - -//# sourceMappingURL=isValidIdentifier.js.map diff --git a/tools/eslint/node_modules/@babel/types/lib/validators/isVar.js b/tools/eslint/node_modules/@babel/types/lib/validators/isVar.js deleted file mode 100644 index 6400af6b514eff..00000000000000 --- a/tools/eslint/node_modules/@babel/types/lib/validators/isVar.js +++ /dev/null @@ -1,15 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.default = isVar; -var _index = require("./generated/index.js"); -var _index2 = require("../constants/index.js"); -function isVar(node) { - return (0, _index.isVariableDeclaration)(node, { - kind: "var" - }) && !node[_index2.BLOCK_SCOPED_SYMBOL]; -} - -//# sourceMappingURL=isVar.js.map diff --git a/tools/eslint/node_modules/@babel/types/lib/validators/matchesPattern.js b/tools/eslint/node_modules/@babel/types/lib/validators/matchesPattern.js deleted file mode 100644 index 1c7921f4a822ac..00000000000000 --- a/tools/eslint/node_modules/@babel/types/lib/validators/matchesPattern.js +++ /dev/null @@ -1,36 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.default = matchesPattern; -var _index = require("./generated/index.js"); -function matchesPattern(member, match, allowPartial) { - if (!(0, _index.isMemberExpression)(member)) return false; - const parts = Array.isArray(match) ? match : match.split("."); - const nodes = []; - let node; - for (node = member; (0, _index.isMemberExpression)(node); node = node.object) { - nodes.push(node.property); - } - nodes.push(node); - if (nodes.length < parts.length) return false; - if (!allowPartial && nodes.length > parts.length) return false; - for (let i = 0, j = nodes.length - 1; i < parts.length; i++, j--) { - const node = nodes[j]; - let value; - if ((0, _index.isIdentifier)(node)) { - value = node.name; - } else if ((0, _index.isStringLiteral)(node)) { - value = node.value; - } else if ((0, _index.isThisExpression)(node)) { - value = "this"; - } else { - return false; - } - if (parts[i] !== value) return false; - } - return true; -} - -//# sourceMappingURL=matchesPattern.js.map diff --git a/tools/eslint/node_modules/@babel/types/lib/validators/react/isCompatTag.js b/tools/eslint/node_modules/@babel/types/lib/validators/react/isCompatTag.js deleted file mode 100644 index 868b8441a10972..00000000000000 --- a/tools/eslint/node_modules/@babel/types/lib/validators/react/isCompatTag.js +++ /dev/null @@ -1,11 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.default = isCompatTag; -function isCompatTag(tagName) { - return !!tagName && /^[a-z]/.test(tagName); -} - -//# sourceMappingURL=isCompatTag.js.map diff --git a/tools/eslint/node_modules/@babel/types/lib/validators/react/isReactComponent.js b/tools/eslint/node_modules/@babel/types/lib/validators/react/isReactComponent.js deleted file mode 100644 index 34b3467250c1e5..00000000000000 --- a/tools/eslint/node_modules/@babel/types/lib/validators/react/isReactComponent.js +++ /dev/null @@ -1,11 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.default = void 0; -var _buildMatchMemberExpression = require("../buildMatchMemberExpression.js"); -const isReactComponent = (0, _buildMatchMemberExpression.default)("React.Component"); -var _default = exports.default = isReactComponent; - -//# sourceMappingURL=isReactComponent.js.map diff --git a/tools/eslint/node_modules/@babel/types/lib/validators/validate.js b/tools/eslint/node_modules/@babel/types/lib/validators/validate.js deleted file mode 100644 index 16e28dd12c0823..00000000000000 --- a/tools/eslint/node_modules/@babel/types/lib/validators/validate.js +++ /dev/null @@ -1,30 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.default = validate; -exports.validateChild = validateChild; -exports.validateField = validateField; -var _index = require("../definitions/index.js"); -function validate(node, key, val) { - if (!node) return; - const fields = _index.NODE_FIELDS[node.type]; - if (!fields) return; - const field = fields[key]; - validateField(node, key, val, field); - validateChild(node, key, val); -} -function validateField(node, key, val, field) { - if (!(field != null && field.validate)) return; - if (field.optional && val == null) return; - field.validate(node, key, val); -} -function validateChild(node, key, val) { - if (val == null) return; - const validate = _index.NODE_PARENT_VALIDATIONS[val.type]; - if (!validate) return; - validate(node, key, val); -} - -//# sourceMappingURL=validate.js.map diff --git a/tools/eslint/node_modules/@babel/types/package.json b/tools/eslint/node_modules/@babel/types/package.json deleted file mode 100644 index fe1109e547f198..00000000000000 --- a/tools/eslint/node_modules/@babel/types/package.json +++ /dev/null @@ -1,40 +0,0 @@ -{ - "name": "@babel/types", - "version": "7.24.8", - "description": "Babel Types is a Lodash-esque utility library for AST nodes", - "author": "The Babel Team (https://babel.dev/team)", - "homepage": "https://babel.dev/docs/en/next/babel-types", - "bugs": "https://github.com/babel/babel/issues?utf8=%E2%9C%93&q=is%3Aissue+label%3A%22pkg%3A%20types%22+is%3Aopen", - "license": "MIT", - "publishConfig": { - "access": "public" - }, - "repository": { - "type": "git", - "url": "https://github.com/babel/babel.git", - "directory": "packages/babel-types" - }, - "main": "./lib/index.js", - "types": "./lib/index-legacy.d.ts", - "typesVersions": { - ">=3.7": { - "lib/index-legacy.d.ts": [ - "lib/index.d.ts" - ] - } - }, - "dependencies": { - "@babel/helper-string-parser": "^7.24.8", - "@babel/helper-validator-identifier": "^7.24.7", - "to-fast-properties": "^2.0.0" - }, - "devDependencies": { - "@babel/generator": "^7.24.8", - "@babel/parser": "^7.24.8", - "glob": "^7.2.0" - }, - "engines": { - "node": ">=6.9.0" - }, - "type": "commonjs" -} \ No newline at end of file diff --git a/tools/eslint/node_modules/@es-joy/jsdoccomment/LICENSE-MIT.txt b/tools/eslint/node_modules/@es-joy/jsdoccomment/LICENSE-MIT.txt deleted file mode 100644 index bdc5f00c160c72..00000000000000 --- a/tools/eslint/node_modules/@es-joy/jsdoccomment/LICENSE-MIT.txt +++ /dev/null @@ -1,20 +0,0 @@ -Copyright JS Foundation and other contributors, https://js.foundation -Copyright (c) 2021 Brett Zamir - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. diff --git a/tools/eslint/node_modules/@es-joy/jsdoccomment/dist/index.cjs.cjs b/tools/eslint/node_modules/@es-joy/jsdoccomment/dist/index.cjs.cjs deleted file mode 100644 index 777b59051b9e1e..00000000000000 --- a/tools/eslint/node_modules/@es-joy/jsdoccomment/dist/index.cjs.cjs +++ /dev/null @@ -1,1333 +0,0 @@ -'use strict'; - -var jsdocTypePrattParser = require('jsdoc-type-pratt-parser'); -var esquery = require('esquery'); -var commentParser = require('comment-parser'); - -/** - * Removes initial and ending brackets from `rawType` - * @param {JsdocTypeLine[]|JsdocTag} container - * @param {boolean} [isArr] - * @returns {void} - */ -const stripEncapsulatingBrackets = (container, isArr) => { - if (isArr) { - const firstItem = /** @type {JsdocTypeLine[]} */container[0]; - firstItem.rawType = firstItem.rawType.replace(/^\{/u, ''); - const lastItem = /** @type {JsdocTypeLine} */ - /** @type {JsdocTypeLine[]} */container.at(-1); - lastItem.rawType = lastItem.rawType.replace(/\}$/u, ''); - return; - } - /** @type {JsdocTag} */ - container.rawType = /** @type {JsdocTag} */container.rawType.replace(/^\{/u, '').replace(/\}$/u, ''); -}; - -/** - * @typedef {{ - * delimiter: string, - * postDelimiter: string, - * rawType: string, - * initial: string, - * type: "JsdocTypeLine" - * }} JsdocTypeLine - */ - -/** - * @typedef {{ - * delimiter: string, - * description: string, - * postDelimiter: string, - * initial: string, - * type: "JsdocDescriptionLine" - * }} JsdocDescriptionLine - */ - -/** - * @typedef {{ - * format: 'pipe' | 'plain' | 'prefix' | 'space', - * namepathOrURL: string, - * tag: string, - * text: string, - * }} JsdocInlineTagNoType - */ -/** - * @typedef {JsdocInlineTagNoType & { - * type: "JsdocInlineTag" - * }} JsdocInlineTag - */ - -/** - * @typedef {{ - * delimiter: string, - * description: string, - * descriptionLines: JsdocDescriptionLine[], - * initial: string, - * inlineTags: JsdocInlineTag[] - * name: string, - * postDelimiter: string, - * postName: string, - * postTag: string, - * postType: string, - * rawType: string, - * parsedType: import('jsdoc-type-pratt-parser').RootResult|null - * tag: string, - * type: "JsdocTag", - * typeLines: JsdocTypeLine[], - * }} JsdocTag - */ - -/** - * @typedef {number} Integer - */ - -/** - * @typedef {{ - * delimiter: string, - * delimiterLineBreak: string, - * description: string, - * descriptionEndLine?: Integer, - * descriptionLines: JsdocDescriptionLine[], - * descriptionStartLine?: Integer, - * hasPreterminalDescription: 0|1, - * hasPreterminalTagDescription?: 1, - * initial: string, - * inlineTags: JsdocInlineTag[] - * lastDescriptionLine?: Integer, - * endLine: Integer, - * lineEnd: string, - * postDelimiter: string, - * tags: JsdocTag[], - * terminal: string, - * preterminalLineBreak: string, - * type: "JsdocBlock", - * }} JsdocBlock - */ - -/** - * @param {object} cfg - * @param {string} cfg.text - * @param {string} cfg.tag - * @param {'pipe' | 'plain' | 'prefix' | 'space'} cfg.format - * @param {string} cfg.namepathOrURL - * @returns {JsdocInlineTag} - */ -const inlineTagToAST = ({ - text, - tag, - format, - namepathOrURL -}) => ({ - text, - tag, - format, - namepathOrURL, - type: 'JsdocInlineTag' -}); - -/** - * Converts comment parser AST to ESTree format. - * @param {import('.').JsdocBlockWithInline} jsdoc - * @param {import('jsdoc-type-pratt-parser').ParseMode} mode - * @param {object} opts - * @param {'compact'|'preserve'} [opts.spacing] By default, empty lines are - * compacted; set to 'preserve' to preserve empty comment lines. - * @param {boolean} [opts.throwOnTypeParsingErrors] - * @returns {JsdocBlock} - */ -const commentParserToESTree = (jsdoc, mode, { - spacing = 'compact', - throwOnTypeParsingErrors = false -} = {}) => { - /** - * Strips brackets from a tag's `rawType` values and adds `parsedType` - * @param {JsdocTag} lastTag - * @returns {void} - */ - const cleanUpLastTag = lastTag => { - // Strip out `}` that encapsulates and is not part of - // the type - stripEncapsulatingBrackets(lastTag); - if (lastTag.typeLines.length) { - stripEncapsulatingBrackets(lastTag.typeLines, true); - } - - // Remove single empty line description. - if (lastTag.descriptionLines.length === 1 && lastTag.descriptionLines[0].description === '') { - lastTag.descriptionLines.length = 0; - } - - // With even a multiline type now in full, add parsing - let parsedType = null; - try { - parsedType = jsdocTypePrattParser.parse(lastTag.rawType, mode); - } catch (err) { - // Ignore - if (lastTag.rawType && throwOnTypeParsingErrors) { - /** @type {Error} */err.message = `Tag @${lastTag.tag} with raw type ` + `\`${lastTag.rawType}\` had parsing error: ${/** @type {Error} */err.message}`; - throw err; - } - } - lastTag.parsedType = parsedType; - }; - const { - source, - inlineTags: blockInlineTags - } = jsdoc; - const { - tokens: { - delimiter: delimiterRoot, - lineEnd: lineEndRoot, - postDelimiter: postDelimiterRoot, - start: startRoot, - end: endRoot - } - } = source[0]; - const endLine = source.length - 1; - - /** @type {JsdocBlock} */ - const ast = { - delimiter: delimiterRoot, - delimiterLineBreak: '\n', - description: '', - descriptionLines: [], - inlineTags: blockInlineTags.map(t => inlineTagToAST(t)), - initial: startRoot, - tags: [], - // `terminal` will be overwritten if there are other entries - terminal: endRoot, - preterminalLineBreak: '\n', - hasPreterminalDescription: 0, - endLine, - postDelimiter: postDelimiterRoot, - lineEnd: lineEndRoot, - type: 'JsdocBlock' - }; - - /** - * @type {JsdocTag[]} - */ - const tags = []; - - /** @type {Integer|undefined} */ - let lastDescriptionLine; - - /** @type {JsdocTag|null} */ - let lastTag = null; - - // Tracks when first valid tag description line is seen. - let tagDescriptionSeen = false; - let descLineStateOpen = true; - source.forEach((info, idx) => { - const { - tokens - } = info; - const { - delimiter, - description, - postDelimiter, - start: initial, - tag, - end, - type: rawType - } = tokens; - if (!tag && description && descLineStateOpen) { - if (ast.descriptionStartLine === undefined) { - ast.descriptionStartLine = idx; - } - ast.descriptionEndLine = idx; - } - if (tag || end) { - descLineStateOpen = false; - if (lastDescriptionLine === undefined) { - lastDescriptionLine = idx; - } - - // Clean-up with last tag before end or new tag - if (lastTag) { - cleanUpLastTag(lastTag); - } - - // Stop the iteration when we reach the end - // but only when there is no tag earlier in the line - // to still process - if (end && !tag) { - ast.terminal = end; - - // Check if there are any description lines and if not then this is a - // one line comment block. - const isDelimiterLine = ast.descriptionLines.length === 0 && delimiter === '/**'; - - // Remove delimiter line break for one line comments blocks. - if (isDelimiterLine) { - ast.delimiterLineBreak = ''; - } - if (description) { - // Remove terminal line break at end when description is defined. - if (ast.terminal === '*/') { - ast.preterminalLineBreak = ''; - } - if (lastTag) { - ast.hasPreterminalTagDescription = 1; - } else { - ast.hasPreterminalDescription = 1; - } - const holder = lastTag || ast; - holder.description += (holder.description ? '\n' : '') + description; - - // Do not include `delimiter` / `postDelimiter` for opening - // delimiter line. - - holder.descriptionLines.push({ - delimiter: isDelimiterLine ? '' : delimiter, - description, - postDelimiter: isDelimiterLine ? '' : postDelimiter, - initial, - type: 'JsdocDescriptionLine' - }); - } - return; - } - const { - // eslint-disable-next-line no-unused-vars -- Discarding - end: ed, - delimiter: de, - postDelimiter: pd, - start: init, - ...tkns - } = tokens; - if (!tokens.name) { - let i = 1; - while (source[idx + i]) { - const { - tokens: { - name, - postName, - postType, - tag: tg - } - } = source[idx + i]; - if (tg) { - break; - } - if (name) { - tkns.postType = postType; - tkns.name = name; - tkns.postName = postName; - break; - } - i++; - } - } - - /** - * @type {JsdocInlineTag[]} - */ - let tagInlineTags = []; - if (tag) { - // Assuming the tags from `source` are in the same order as `jsdoc.tags` - // we can use the `tags` length as index into the parser result tags. - tagInlineTags = - /** - * @type {import('comment-parser').Spec & { - * inlineTags: JsdocInlineTagNoType[] - * }} - */ - jsdoc.tags[tags.length].inlineTags.map(t => inlineTagToAST(t)); - } - - /** @type {JsdocTag} */ - const tagObj = { - ...tkns, - initial: endLine ? init : '', - postDelimiter: lastDescriptionLine ? pd : '', - delimiter: lastDescriptionLine ? de : '', - descriptionLines: [], - inlineTags: tagInlineTags, - parsedType: null, - rawType: '', - type: 'JsdocTag', - typeLines: [] - }; - tagObj.tag = tagObj.tag.replace(/^@/u, ''); - lastTag = tagObj; - tagDescriptionSeen = false; - tags.push(tagObj); - } - if (rawType) { - // Will strip rawType brackets after this tag - /** @type {JsdocTag} */ - lastTag.typeLines.push( /** @type {JsdocTag} */lastTag.typeLines.length ? { - delimiter, - postDelimiter, - rawType, - initial, - type: 'JsdocTypeLine' - } : { - delimiter: '', - postDelimiter: '', - rawType, - initial: '', - type: 'JsdocTypeLine' - }); - /** @type {JsdocTag} */ - lastTag.rawType += /** @type {JsdocTag} */lastTag.rawType ? '\n' + rawType : rawType; - } - - // In `compact` mode skip processing if `description` is an empty string - // unless lastTag is being processed. - // - // In `preserve` mode process when `description` is not the `empty string - // or the `delimiter` is not `/**` ensuring empty lines are preserved. - if (spacing === 'compact' && description || lastTag || spacing === 'preserve' && (description || delimiter !== '/**')) { - const holder = lastTag || ast; - - // Check if there are any description lines and if not then this is a - // multi-line comment block with description on 0th line. Treat - // `delimiter` / `postDelimiter` / `initial` as being on a new line. - const isDelimiterLine = holder.descriptionLines.length === 0 && delimiter === '/**'; - - // Remove delimiter line break for one line comments blocks. - if (isDelimiterLine) { - ast.delimiterLineBreak = ''; - } - - // Track when the first description line is seen to avoid adding empty - // description lines for tag type lines. - tagDescriptionSeen || (tagDescriptionSeen = Boolean(lastTag && (rawType === '' || (rawType === null || rawType === void 0 ? void 0 : rawType.endsWith('}'))))); - if (lastTag) { - if (tagDescriptionSeen) { - // The first tag description line is a continuation after type / - // name parsing. - const isFirstDescriptionLine = holder.descriptionLines.length === 0; - - // For `compact` spacing must allow through first description line. - if (spacing === 'compact' && (description || isFirstDescriptionLine) || spacing === 'preserve') { - holder.descriptionLines.push({ - delimiter: isFirstDescriptionLine ? '' : delimiter, - description, - postDelimiter: isFirstDescriptionLine ? '' : postDelimiter, - initial: isFirstDescriptionLine ? '' : initial, - type: 'JsdocDescriptionLine' - }); - } - } - } else { - holder.descriptionLines.push({ - delimiter: isDelimiterLine ? '' : delimiter, - description, - postDelimiter: isDelimiterLine ? '' : postDelimiter, - initial: isDelimiterLine ? `` : initial, - type: 'JsdocDescriptionLine' - }); - } - if (!tag) { - if (lastTag) { - // For `compact` spacing must filter out any empty description lines - // after the initial `holder.description` has content. - if (tagDescriptionSeen && !(spacing === 'compact' && holder.description && description === '')) { - holder.description += !holder.description ? description : '\n' + description; - } - } else { - holder.description += !holder.description ? description : '\n' + description; - } - } - } - - // Clean-up where last line itself has tag content - if (end && tag) { - ast.terminal = end; - ast.hasPreterminalTagDescription = 1; - - // Remove terminal line break at end when tag is defined on last line. - if (ast.terminal === '*/') { - ast.preterminalLineBreak = ''; - } - cleanUpLastTag( /** @type {JsdocTag} */lastTag); - } - }); - ast.lastDescriptionLine = lastDescriptionLine; - ast.tags = tags; - return ast; -}; -const jsdocVisitorKeys = { - JsdocBlock: ['descriptionLines', 'tags', 'inlineTags'], - JsdocDescriptionLine: [], - JsdocTypeLine: [], - JsdocTag: ['parsedType', 'typeLines', 'descriptionLines', 'inlineTags'], - JsdocInlineTag: [] -}; - -/** - * @param {{[name: string]: any}} settings - * @returns {import('.').CommentHandler} - */ -const commentHandler = settings => { - /** - * @type {import('.').CommentHandler} - */ - return (commentSelector, jsdoc) => { - const { - mode - } = settings; - const selector = esquery.parse(commentSelector); - const ast = commentParserToESTree(jsdoc, mode); - const _ast = /** @type {unknown} */ast; - return esquery.matches( /** @type {import('estree').Node} */ - _ast, selector, undefined, { - visitorKeys: { - ...jsdocTypePrattParser.visitorKeys, - ...jsdocVisitorKeys - } - }); - }; -}; - -/** @type {Record} */ -const stringifiers = { - JsdocBlock, - /** - * @param {import('./commentParserToESTree').JsdocDescriptionLine} node - * @returns {string} - */ - JsdocDescriptionLine({ - initial, - delimiter, - postDelimiter, - description - }) { - return `${initial}${delimiter}${postDelimiter}${description}`; - }, - /** - * @param {import('./commentParserToESTree').JsdocTypeLine} node - * @returns {string} - */ - JsdocTypeLine({ - initial, - delimiter, - postDelimiter, - rawType - }) { - return `${initial}${delimiter}${postDelimiter}${rawType}`; - }, - /** - * @param {import('./commentParserToESTree').JsdocInlineTag} node - */ - JsdocInlineTag({ - format, - namepathOrURL, - tag, - text - }) { - return format === 'pipe' ? `{@${tag} ${namepathOrURL}|${text}}` : format === 'plain' ? `{@${tag} ${namepathOrURL}}` : format === 'prefix' ? `[${text}]{@${tag} ${namepathOrURL}}` - // "space" - : `{@${tag} ${namepathOrURL} ${text}}`; - }, - JsdocTag -}; - -/** - * @todo convert for use by escodegen (until may be patched to support - * custom entries?). - * @param {import('./commentParserToESTree').JsdocBlock| - * import('./commentParserToESTree').JsdocDescriptionLine| - * import('./commentParserToESTree').JsdocTypeLine| - * import('./commentParserToESTree').JsdocTag| - * import('./commentParserToESTree').JsdocInlineTag| - * import('jsdoc-type-pratt-parser').RootResult - * } node - * @param {import('.').ESTreeToStringOptions} opts - * @throws {Error} - * @returns {string} - */ -function estreeToString(node, opts = {}) { - if (Object.prototype.hasOwnProperty.call(stringifiers, node.type)) { - return stringifiers[ - /** - * @type {import('./commentParserToESTree').JsdocBlock| - * import('./commentParserToESTree').JsdocDescriptionLine| - * import('./commentParserToESTree').JsdocTypeLine| - * import('./commentParserToESTree').JsdocTag} - */ - node.type](node, opts); - } - - // We use raw type instead but it is a key as other apps may wish to traverse - if (node.type.startsWith('JsdocType')) { - return opts.preferRawType ? '' : `{${jsdocTypePrattParser.stringify( /** @type {import('jsdoc-type-pratt-parser').RootResult} */ - node)}}`; - } - throw new Error(`Unhandled node type: ${node.type}`); -} - -/** - * @param {import('./commentParserToESTree').JsdocBlock} node - * @param {import('.').ESTreeToStringOptions} opts - * @returns {string} - */ -function JsdocBlock(node, opts) { - const { - delimiter, - delimiterLineBreak, - descriptionLines, - initial, - postDelimiter, - preterminalLineBreak, - tags, - terminal - } = node; - const terminalPrepend = preterminalLineBreak !== '' ? `${preterminalLineBreak}${initial} ` : ''; - let result = `${initial}${delimiter}${postDelimiter}${delimiterLineBreak}`; - for (let i = 0; i < descriptionLines.length; i++) { - result += estreeToString(descriptionLines[i]); - if (i !== descriptionLines.length - 1 || tags.length) { - result += '\n'; - } - } - for (let i = 0; i < tags.length; i++) { - result += estreeToString(tags[i], opts); - if (i !== tags.length - 1) { - result += '\n'; - } - } - result += `${terminalPrepend}${terminal}`; - return result; -} - -/** - * @param {import('./commentParserToESTree').JsdocTag} node - * @param {import('.').ESTreeToStringOptions} opts - * @returns {string} - */ -function JsdocTag(node, opts) { - const { - delimiter, - descriptionLines, - initial, - name, - parsedType, - postDelimiter, - postName, - postTag, - postType, - tag, - typeLines - } = node; - let result = `${initial}${delimiter}${postDelimiter}@${tag}${postTag}`; - - // Could do `rawType` but may have been changed; could also do - // `typeLines` but not as likely to be changed - // parsedType - // Comment this out later in favor of `parsedType` - // We can't use raw `typeLines` as first argument has delimiter on it - if (opts.preferRawType || !parsedType) { - if (typeLines.length) { - result += '{'; - for (let i = 0; i < typeLines.length; i++) { - result += estreeToString(typeLines[i]); - if (i !== typeLines.length - 1) { - result += '\n'; - } - } - result += '}'; - } - } else if (parsedType !== null && parsedType !== void 0 && parsedType.type.startsWith('JsdocType')) { - result += `{${jsdocTypePrattParser.stringify( /** @type {import('jsdoc-type-pratt-parser').RootResult} */ - parsedType)}}`; - } - result += name ? `${postType}${name}${postName}` : postType; - for (let i = 0; i < descriptionLines.length; i++) { - const descriptionLine = descriptionLines[i]; - result += estreeToString(descriptionLine); - if (i !== descriptionLines.length - 1) { - result += '\n'; - } - } - return result; -} - -/** - * Obtained originally from {@link https://github.com/eslint/eslint/blob/master/lib/util/source-code.js#L313}. - * - * @license MIT - */ - -/** - * @typedef {import('eslint').AST.Token | import('estree').Comment | { - * type: import('eslint').AST.TokenType|"Line"|"Block"|"Shebang", - * range: [number, number], - * value: string - * }} Token - */ - -/** - * @typedef {import('eslint').Rule.Node| - * import('@typescript-eslint/types').TSESTree.Node} ESLintOrTSNode - */ - -/** - * @typedef {number} int - */ - -/** - * Checks if the given token is a comment token or not. - * - * @param {Token} token - The token to check. - * @returns {boolean} `true` if the token is a comment token. - */ -const isCommentToken = token => { - return token.type === 'Line' || token.type === 'Block' || token.type === 'Shebang'; -}; - -/** - * @param {(ESLintOrTSNode|import('estree').Comment) & { - * declaration?: any, - * decorators?: any[], - * parent?: import('eslint').Rule.Node & { - * decorators?: any[] - * } - * }} node - * @returns {import('@typescript-eslint/types').TSESTree.Decorator|undefined} - */ -const getDecorator = node => { - var _node$declaration, _node$decorators, _node$parent; - return (node === null || node === void 0 || (_node$declaration = node.declaration) === null || _node$declaration === void 0 || (_node$declaration = _node$declaration.decorators) === null || _node$declaration === void 0 ? void 0 : _node$declaration[0]) || (node === null || node === void 0 || (_node$decorators = node.decorators) === null || _node$decorators === void 0 ? void 0 : _node$decorators[0]) || (node === null || node === void 0 || (_node$parent = node.parent) === null || _node$parent === void 0 || (_node$parent = _node$parent.decorators) === null || _node$parent === void 0 ? void 0 : _node$parent[0]); -}; - -/** - * Check to see if it is a ES6 export declaration. - * - * @param {ESLintOrTSNode} astNode An AST node. - * @returns {boolean} whether the given node represents an export declaration. - * @private - */ -const looksLikeExport = function (astNode) { - return astNode.type === 'ExportDefaultDeclaration' || astNode.type === 'ExportNamedDeclaration' || astNode.type === 'ExportAllDeclaration' || astNode.type === 'ExportSpecifier'; -}; - -/** - * @param {ESLintOrTSNode} astNode - * @returns {ESLintOrTSNode} - */ -const getTSFunctionComment = function (astNode) { - const { - parent - } = astNode; - /* v8 ignore next 3 */ - if (!parent) { - return astNode; - } - const grandparent = parent.parent; - /* v8 ignore next 3 */ - if (!grandparent) { - return astNode; - } - const greatGrandparent = grandparent.parent; - const greatGreatGrandparent = greatGrandparent && greatGrandparent.parent; - - /* v8 ignore next 3 */ - if ( /** @type {ESLintOrTSNode} */parent.type !== 'TSTypeAnnotation') { - return astNode; - } - switch ( /** @type {ESLintOrTSNode} */grandparent.type) { - // @ts-expect-error -- For `ClassProperty`. - case 'PropertyDefinition': - case 'ClassProperty': - case 'TSDeclareFunction': - case 'TSMethodSignature': - case 'TSPropertySignature': - return grandparent; - case 'ArrowFunctionExpression': - /* v8 ignore next 3 */ - if (!greatGrandparent) { - return astNode; - } - if (greatGrandparent.type === 'VariableDeclarator' - - // && greatGreatGrandparent.parent.type === 'VariableDeclaration' - ) { - /* v8 ignore next 3 */ - if (!greatGreatGrandparent || !greatGreatGrandparent.parent) { - return astNode; - } - return greatGreatGrandparent.parent; - } - /* v8 ignore next */ - return astNode; - case 'FunctionExpression': - /* v8 ignore next 3 */ - if (!greatGreatGrandparent) { - return astNode; - } - if (greatGrandparent.type === 'MethodDefinition') { - return greatGrandparent; - } - - // Fallthrough - default: - /* v8 ignore next 3 */ - if (grandparent.type !== 'Identifier') { - return astNode; - } - } - - /* v8 ignore next 3 */ - if (!greatGreatGrandparent) { - return astNode; - } - switch (greatGrandparent.type) { - case 'ArrowFunctionExpression': - if (greatGreatGrandparent.type === 'VariableDeclarator' && greatGreatGrandparent.parent.type === 'VariableDeclaration') { - return greatGreatGrandparent.parent; - } - return astNode; - case 'FunctionDeclaration': - return greatGrandparent; - case 'VariableDeclarator': - if (greatGreatGrandparent.type === 'VariableDeclaration') { - return greatGreatGrandparent; - } - /* v8 ignore next 2 */ - // Fallthrough - default: - /* v8 ignore next 3 */ - return astNode; - } -}; -const invokedExpression = new Set(['CallExpression', 'OptionalCallExpression', 'NewExpression']); -const allowableCommentNode = new Set(['AssignmentPattern', 'VariableDeclaration', 'ExpressionStatement', 'MethodDefinition', 'Property', 'ObjectProperty', 'ClassProperty', 'PropertyDefinition', 'ExportDefaultDeclaration', 'ReturnStatement']); - -/** - * Reduces the provided node to the appropriate node for evaluating - * JSDoc comment status. - * - * @param {ESLintOrTSNode} node An AST node. - * @param {import('eslint').SourceCode} sourceCode The ESLint SourceCode. - * @returns {ESLintOrTSNode} The AST node that - * can be evaluated for appropriate JSDoc comments. - */ -const getReducedASTNode = function (node, sourceCode) { - let { - parent - } = node; - switch ( /** @type {ESLintOrTSNode} */node.type) { - case 'TSFunctionType': - return getTSFunctionComment(node); - case 'TSInterfaceDeclaration': - case 'TSTypeAliasDeclaration': - case 'TSEnumDeclaration': - case 'ClassDeclaration': - case 'FunctionDeclaration': - /* v8 ignore next 3 */ - if (!parent) { - return node; - } - return looksLikeExport(parent) ? parent : node; - case 'TSDeclareFunction': - case 'ClassExpression': - case 'ObjectExpression': - case 'ArrowFunctionExpression': - case 'TSEmptyBodyFunctionExpression': - case 'FunctionExpression': - /* v8 ignore next 3 */ - if (!parent) { - return node; - } - if (!invokedExpression.has(parent.type)) { - /** - * @type {ESLintOrTSNode|Token|null} - */ - let token = node; - do { - token = sourceCode.getTokenBefore( /** @type {import('eslint').Rule.Node|import('eslint').AST.Token} */ - token, { - includeComments: true - }); - } while (token && token.type === 'Punctuator' && token.value === '('); - if (token && token.type === 'Block') { - return node; - } - if (sourceCode.getCommentsBefore( /** @type {import('eslint').Rule.Node} */ - node).length) { - return node; - } - while (!sourceCode.getCommentsBefore( /** @type {import('eslint').Rule.Node} */ - parent).length && !/Function/u.test(parent.type) && !allowableCommentNode.has(parent.type)) { - ({ - parent - } = parent); - if (!parent) { - break; - } - } - if (parent && parent.type !== 'FunctionDeclaration' && parent.type !== 'Program') { - if (parent.parent && parent.parent.type === 'ExportNamedDeclaration') { - return parent.parent; - } - return parent; - } - } - return node; - default: - return node; - } -}; - -/** - * Checks for the presence of a JSDoc comment for the given node and returns it. - * - * @param {ESLintOrTSNode} astNode The AST node to get - * the comment for. - * @param {import('eslint').SourceCode} sourceCode - * @param {{maxLines: int, minLines: int, [name: string]: any}} settings - * @param {{nonJSDoc?: boolean}} [opts] - * @returns {Token|null} The Block comment token containing the JSDoc comment - * for the given node or null if not found. - */ -const findJSDocComment = (astNode, sourceCode, settings, opts = {}) => { - var _parenthesisToken, _parenthesisToken2; - const { - nonJSDoc - } = opts; - const { - minLines, - maxLines - } = settings; - - /** @type {ESLintOrTSNode|import('estree').Comment} */ - let currentNode = astNode; - let tokenBefore = null; - let parenthesisToken = null; - while (currentNode) { - const decorator = getDecorator( /** @type {import('eslint').Rule.Node} */ - currentNode); - if (decorator) { - const dec = /** @type {unknown} */decorator; - currentNode = /** @type {import('eslint').Rule.Node} */dec; - } - tokenBefore = sourceCode.getTokenBefore( /** @type {import('eslint').Rule.Node} */ - currentNode, { - includeComments: true - }); - if (tokenBefore && tokenBefore.type === 'Punctuator' && tokenBefore.value === '(') { - parenthesisToken = tokenBefore; - [tokenBefore] = sourceCode.getTokensBefore( /** @type {import('eslint').Rule.Node} */ - currentNode, { - count: 2, - includeComments: true - }); - } - if (!tokenBefore || !isCommentToken(tokenBefore)) { - return null; - } - if (!nonJSDoc && tokenBefore.type === 'Line') { - currentNode = tokenBefore; - continue; - } - break; - } - - /* v8 ignore next 3 */ - if (!tokenBefore || !currentNode.loc || !tokenBefore.loc) { - return null; - } - if ((nonJSDoc && (tokenBefore.type !== 'Block' || !/^\*\s/u.test(tokenBefore.value)) || !nonJSDoc && tokenBefore.type === 'Block' && /^\*\s/u.test(tokenBefore.value)) && currentNode.loc.start.line - ( /** @type {import('eslint').AST.Token} */(_parenthesisToken = parenthesisToken) !== null && _parenthesisToken !== void 0 ? _parenthesisToken : tokenBefore).loc.end.line >= minLines && currentNode.loc.start.line - ( /** @type {import('eslint').AST.Token} */(_parenthesisToken2 = parenthesisToken) !== null && _parenthesisToken2 !== void 0 ? _parenthesisToken2 : tokenBefore).loc.end.line <= maxLines) { - return tokenBefore; - } - return null; -}; - -/** - * Retrieves the JSDoc comment for a given node. - * - * @param {import('eslint').SourceCode} sourceCode The ESLint SourceCode - * @param {import('eslint').Rule.Node} node The AST node to get - * the comment for. - * @param {{maxLines: int, minLines: int, [name: string]: any}} settings The - * settings in context - * @returns {Token|null} The Block comment - * token containing the JSDoc comment for the given node or - * null if not found. - * @public - */ -const getJSDocComment = function (sourceCode, node, settings) { - const reducedNode = getReducedASTNode(node, sourceCode); - return findJSDocComment(reducedNode, sourceCode, settings); -}; - -/** - * Retrieves the comment preceding a given node. - * - * @param {import('eslint').SourceCode} sourceCode The ESLint SourceCode - * @param {ESLintOrTSNode} node The AST node to get - * the comment for. - * @param {{maxLines: int, minLines: int, [name: string]: any}} settings The - * settings in context - * @returns {Token|null} The Block comment - * token containing the JSDoc comment for the given node or - * null if not found. - * @public - */ -const getNonJsdocComment = function (sourceCode, node, settings) { - const reducedNode = getReducedASTNode(node, sourceCode); - return findJSDocComment(reducedNode, sourceCode, settings, { - nonJSDoc: true - }); -}; - -/** - * @param {ESLintOrTSNode|import('eslint').AST.Token| - * import('estree').Comment - * } nodeA The AST node or token to compare - * @param {ESLintOrTSNode|import('eslint').AST.Token| - * import('estree').Comment} nodeB The - * AST node or token to compare - */ -const compareLocEndToStart = (nodeA, nodeB) => { - var _nodeA$loc$end$line, _nodeA$loc, _nodeB$loc$start$line, _nodeB$loc; - /* v8 ignore next */ - return ((_nodeA$loc$end$line = (_nodeA$loc = nodeA.loc) === null || _nodeA$loc === void 0 ? void 0 : _nodeA$loc.end.line) !== null && _nodeA$loc$end$line !== void 0 ? _nodeA$loc$end$line : 0) === ((_nodeB$loc$start$line = (_nodeB$loc = nodeB.loc) === null || _nodeB$loc === void 0 ? void 0 : _nodeB$loc.start.line) !== null && _nodeB$loc$start$line !== void 0 ? _nodeB$loc$start$line : 0); -}; - -/** - * Checks for the presence of a comment following the given node and - * returns it. - * - * This method is experimental. - * - * @param {import('eslint').SourceCode} sourceCode - * @param {ESLintOrTSNode} astNode The AST node to get - * the comment for. - * @returns {Token|null} The comment token containing the comment - * for the given node or null if not found. - */ -const getFollowingComment = function (sourceCode, astNode) { - /** - * @param {ESLintOrTSNode} node The - * AST node to get the comment for. - */ - const getTokensAfterIgnoringSemis = node => { - let tokenAfter = sourceCode.getTokenAfter( /** @type {import('eslint').Rule.Node} */ - node, { - includeComments: true - }); - while (tokenAfter && tokenAfter.type === 'Punctuator' && - // tokenAfter.value === ')' // Don't apparently need to ignore - tokenAfter.value === ';') { - [tokenAfter] = sourceCode.getTokensAfter(tokenAfter, { - includeComments: true - }); - } - return tokenAfter; - }; - - /** - * @param {ESLintOrTSNode} node The - * AST node to get the comment for. - */ - const tokenAfterIgnoringSemis = node => { - const tokenAfter = getTokensAfterIgnoringSemis(node); - return tokenAfter && isCommentToken(tokenAfter) && compareLocEndToStart(node, tokenAfter) ? tokenAfter : null; - }; - let tokenAfter = tokenAfterIgnoringSemis(astNode); - if (!tokenAfter) { - switch (astNode.type) { - case 'FunctionDeclaration': - tokenAfter = tokenAfterIgnoringSemis( /** @type {ESLintOrTSNode} */ - astNode.body); - break; - case 'ExpressionStatement': - tokenAfter = tokenAfterIgnoringSemis( /** @type {ESLintOrTSNode} */ - astNode.expression); - break; - } - } - return tokenAfter; -}; - -/** - * @param {RegExpMatchArray & { - * indices: { - * groups: { - * [key: string]: [number, number] - * } - * } - * groups: {[key: string]: string} - * }} match An inline tag regexp match. - * @returns {'pipe' | 'plain' | 'prefix' | 'space'} - */ -function determineFormat(match) { - const { - separator, - text - } = match.groups; - const [, textEnd] = match.indices.groups.text; - const [tagStart] = match.indices.groups.tag; - if (!text) { - return 'plain'; - } else if (separator === '|') { - return 'pipe'; - } else if (textEnd < tagStart) { - return 'prefix'; - } - return 'space'; -} - -/** - * Extracts inline tags from a description. - * @param {string} description - * @returns {import('.').InlineTag[]} Array of inline tags from the description. - */ -function parseDescription(description) { - /** @type {import('.').InlineTag[]} */ - const result = []; - - // This could have been expressed in a single pattern, - // but having two avoids a potentially exponential time regex. - - const prefixedTextPattern = new RegExp(/(?:\[(?[^\]]+)\])\{@(?[^}\s]+)\s?(?[^}\s|]*)\}/gu, 'gud'); - // The pattern used to match for text after tag uses a negative lookbehind - // on the ']' char to avoid matching the prefixed case too. - const suffixedAfterPattern = new RegExp(/(?[^}\s]+)\s?(?[^}\s|]*)\s*(?[\s|])?\s*(?[^}]*)\}/gu, 'gud'); - const matches = [...description.matchAll(prefixedTextPattern), ...description.matchAll(suffixedAfterPattern)]; - for (const mtch of matches) { - const match = - /** - * @type {RegExpMatchArray & { - * indices: { - * groups: { - * [key: string]: [number, number] - * } - * } - * groups: {[key: string]: string} - * }} - */ - mtch; - const { - tag, - namepathOrURL, - text - } = match.groups; - const [start, end] = match.indices[0]; - const format = determineFormat(match); - result.push({ - tag, - namepathOrURL, - text, - format, - start, - end - }); - } - return result; -} - -/** - * Splits the `{@prefix}` from remaining `Spec.lines[].token.description` - * into the `inlineTags` tokens, and populates `spec.inlineTags` - * @param {import('comment-parser').Block} block - * @returns {import('.').JsdocBlockWithInline} - */ -function parseInlineTags(block) { - const inlineTags = - /** - * @type {(import('./commentParserToESTree').JsdocInlineTagNoType & { - * line?: import('./commentParserToESTree').Integer - * })[]} - */ - parseDescription(block.description); - - /** @type {import('.').JsdocBlockWithInline} */ - block.inlineTags = inlineTags; - for (const tag of block.tags) { - /** - * @type {import('.').JsdocTagWithInline} - */ - tag.inlineTags = parseDescription(tag.description); - } - return ( - /** - * @type {import('.').JsdocBlockWithInline} - */ - block - ); -} - -/* eslint-disable prefer-named-capture-group -- Temporary */ -const { - name: nameTokenizer, - tag: tagTokenizer, - type: typeTokenizer, - description: descriptionTokenizer -} = commentParser.tokenizers; - -/** - * @param {import('comment-parser').Spec} spec - * @returns {boolean} - */ -const hasSeeWithLink = spec => { - return spec.tag === 'see' && /\{@link.+?\}/u.test(spec.source[0].source); -}; -const defaultNoTypes = ['default', 'defaultvalue', 'description', 'example', 'file', 'fileoverview', 'license', 'overview', 'see', 'summary']; -const defaultNoNames = ['access', 'author', 'default', 'defaultvalue', 'description', 'example', 'exception', 'file', 'fileoverview', 'kind', 'license', 'overview', 'return', 'returns', 'since', 'summary', 'throws', 'version', 'variation']; -const optionalBrackets = /^\[(?[^=]*)=[^\]]*\]/u; -const preserveTypeTokenizer = typeTokenizer('preserve'); -const preserveDescriptionTokenizer = descriptionTokenizer('preserve'); -const plainNameTokenizer = nameTokenizer(); - -/** - * Can't import `comment-parser/es6/parser/tokenizers/index.js`, - * so we redefine here. - * @typedef {(spec: import('comment-parser').Spec) => - * import('comment-parser').Spec} CommentParserTokenizer - */ - -/** - * @param {object} [cfg] - * @param {string[]} [cfg.noTypes] - * @param {string[]} [cfg.noNames] - * @returns {CommentParserTokenizer[]} - */ -const getTokenizers = ({ - noTypes = defaultNoTypes, - noNames = defaultNoNames -} = {}) => { - // trim - return [ - // Tag - tagTokenizer(), - /** - * Type tokenizer. - * @param {import('comment-parser').Spec} spec - * @returns {import('comment-parser').Spec} - */ - spec => { - if (noTypes.includes(spec.tag)) { - return spec; - } - return preserveTypeTokenizer(spec); - }, - /** - * Name tokenizer. - * @param {import('comment-parser').Spec} spec - * @returns {import('comment-parser').Spec} - */ - spec => { - if (spec.tag === 'template') { - // const preWS = spec.postTag; - const remainder = spec.source[0].tokens.description; - let pos; - if (remainder.startsWith('[') && remainder.includes(']')) { - const endingBracketPos = remainder.indexOf(']'); - pos = remainder.slice(endingBracketPos).search(/(? -1) { - // Add offset to starting point if space found - pos += endingBracketPos; - } - } else { - pos = remainder.search(/(? -1) { - [, postName, description, lineEnd] = /** @type {RegExpMatchArray} */ - extra.match(/(\s*)([^\r]*)(\r)?/u); - } - if (optionalBrackets.test(name)) { - var _name$match; - name = - /** @type {string} */ - /** @type {RegExpMatchArray} */ - (_name$match = name.match(optionalBrackets)) === null || _name$match === void 0 || (_name$match = _name$match.groups) === null || _name$match === void 0 ? void 0 : _name$match.name; - spec.optional = true; - } else { - spec.optional = false; - } - spec.name = name; - const { - tokens - } = spec.source[0]; - tokens.name = name; - tokens.postName = postName; - tokens.description = description; - tokens.lineEnd = lineEnd || ''; - return spec; - } - if (noNames.includes(spec.tag) || hasSeeWithLink(spec)) { - return spec; - } - return plainNameTokenizer(spec); - }, - /** - * Description tokenizer. - * @param {import('comment-parser').Spec} spec - * @returns {import('comment-parser').Spec} - */ - spec => { - return preserveDescriptionTokenizer(spec); - }]; -}; - -/** - * Accepts a comment token or complete comment string and converts it into - * `comment-parser` AST. - * @param {string | {value: string}} commentOrNode - * @param {string} [indent] Whitespace - * @returns {import('.').JsdocBlockWithInline} - */ -const parseComment = (commentOrNode, indent = '') => { - let block; - switch (typeof commentOrNode) { - case 'string': - // Preserve JSDoc block start/end indentation. - [block] = commentParser.parse(`${indent}${commentOrNode}`, { - // @see https://github.com/yavorskiy/comment-parser/issues/21 - tokenizers: getTokenizers() - }); - break; - case 'object': - if (commentOrNode === null) { - throw new TypeError(`'commentOrNode' is not a string or object.`); - } - - // Preserve JSDoc block start/end indentation. - [block] = commentParser.parse(`${indent}/*${commentOrNode.value}*/`, { - // @see https://github.com/yavorskiy/comment-parser/issues/21 - tokenizers: getTokenizers() - }); - break; - default: - throw new TypeError(`'commentOrNode' is not a string or object.`); - } - return parseInlineTags(block); -}; - -Object.defineProperty(exports, "jsdocTypeVisitorKeys", { - enumerable: true, - get: function () { return jsdocTypePrattParser.visitorKeys; } -}); -exports.commentHandler = commentHandler; -exports.commentParserToESTree = commentParserToESTree; -exports.defaultNoNames = defaultNoNames; -exports.defaultNoTypes = defaultNoTypes; -exports.estreeToString = estreeToString; -exports.findJSDocComment = findJSDocComment; -exports.getDecorator = getDecorator; -exports.getFollowingComment = getFollowingComment; -exports.getJSDocComment = getJSDocComment; -exports.getNonJsdocComment = getNonJsdocComment; -exports.getReducedASTNode = getReducedASTNode; -exports.getTokenizers = getTokenizers; -exports.hasSeeWithLink = hasSeeWithLink; -exports.jsdocVisitorKeys = jsdocVisitorKeys; -exports.parseComment = parseComment; -exports.parseInlineTags = parseInlineTags; -Object.keys(jsdocTypePrattParser).forEach(function (k) { - if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, { - enumerable: true, - get: function () { return jsdocTypePrattParser[k]; } - }); -}); diff --git a/tools/eslint/node_modules/@es-joy/jsdoccomment/package.json b/tools/eslint/node_modules/@es-joy/jsdoccomment/package.json deleted file mode 100644 index 0056da21bdf4a3..00000000000000 --- a/tools/eslint/node_modules/@es-joy/jsdoccomment/package.json +++ /dev/null @@ -1,106 +0,0 @@ -{ - "name": "@es-joy/jsdoccomment", - "version": "0.46.0", - "author": "Brett Zamir ", - "contributors": [], - "description": "Maintained replacement for ESLint's deprecated SourceCode#getJSDocComment along with other jsdoc utilities", - "license": "MIT", - "keywords": [ - "ast", - "comment", - "estree", - "jsdoc", - "parser", - "eslint", - "sourcecode" - ], - "type": "module", - "types": "./dist/index.d.ts", - "exports": { - "types": "./dist/index.d.ts", - "import": "./src/index.js", - "require": "./dist/index.cjs.cjs" - }, - "browserslist": [ - "cover 100%" - ], - "typedocOptions": { - "dmtLinksService": { - "GitHub": "https://github.com/es-joy/jsdoccomment", - "NPM": "https://www.npmjs.com/package/@es-joy/jsdoccomment" - } - }, - "repository": { - "type": "git", - "url": "git+https://github.com/es-joy/jsdoccomment.git" - }, - "bugs": { - "url": "https://github.com/es-joy/jsdoccomment/issues" - }, - "homepage": "https://github.com/es-joy/jsdoccomment", - "engines": { - "node": ">=16" - }, - "dependencies": { - "comment-parser": "1.4.1", - "esquery": "^1.6.0", - "jsdoc-type-pratt-parser": "~4.0.0" - }, - "devDependencies": { - "@babel/core": "^7.24.7", - "@babel/plugin-syntax-class-properties": "^7.12.13", - "@babel/preset-env": "^7.24.7", - "@brettz9/eslint-plugin": "^1.0.4", - "@rollup/plugin-babel": "^6.0.4", - "@types/eslint": "^8.56.10", - "@types/esquery": "^1.5.4", - "@types/estraverse": "^5.1.7", - "@types/estree": "^1.0.5", - "@typescript-eslint/types": "^7.16.0", - "@typescript-eslint/visitor-keys": "^7.16.0", - "@typhonjs-build-test/esm-d-ts": "0.3.0-next.1", - "@typhonjs-typedoc/typedoc-pkg": "^0.0.5", - "@vitest/coverage-v8": "^2.0.1", - "@vitest/ui": "^2.0.1", - "eslint": "^8.56.0", - "eslint-config-ash-nazg": "35.3.0", - "eslint-config-standard": "^17.1.0", - "eslint-plugin-array-func": "^4.0.0", - "eslint-plugin-compat": "^4.2.0", - "eslint-plugin-eslint-comments": "^3.2.0", - "eslint-plugin-html": "^7.1.0", - "eslint-plugin-import": "^2.29.1", - "eslint-plugin-jsdoc": "^48.0.4", - "eslint-plugin-markdown": "^3.0.1", - "eslint-plugin-n": "^16.6.2", - "eslint-plugin-no-unsanitized": "^4.0.2", - "eslint-plugin-no-use-extend-native": "^0.5.0", - "eslint-plugin-promise": "^6.1.1", - "eslint-plugin-sonarjs": "^0.23.0", - "eslint-plugin-unicorn": "^50.0.1", - "espree": "^10.1.0", - "estraverse": "^5.3.0", - "rollup": "^4.18.1", - "typescript": "^5.5.3", - "typescript-eslint": "^7.16.0", - "vitest": "^2.0.1" - }, - "files": [ - "/dist", - "/src", - "CHANGES.md", - "LICENSE-MIT.txt" - ], - "scripts": { - "build": "rollup -c && npm run types", - "docs": "typedoc-pkg --api-link es", - "eslint": "eslint --ext=js,cjs,md,html .", - "lint": "npm run eslint --", - "open": "open ./coverage/index.html", - "test": "npm run lint && npm run build && npm run test-ui", - "test-ui": "vitest --ui --coverage", - "test-cov": "vitest --coverage", - "tsc": "tsc", - "types": "esm-d-ts gen ./src/index.js --output ./dist/index.d.ts" - } -} \ No newline at end of file diff --git a/tools/eslint/node_modules/@es-joy/jsdoccomment/src/commentHandler.js b/tools/eslint/node_modules/@es-joy/jsdoccomment/src/commentHandler.js deleted file mode 100644 index 455afdd2b4f56d..00000000000000 --- a/tools/eslint/node_modules/@es-joy/jsdoccomment/src/commentHandler.js +++ /dev/null @@ -1,39 +0,0 @@ -import esquery from 'esquery'; - -import { - visitorKeys as jsdocTypePrattParserVisitorKeys -} from 'jsdoc-type-pratt-parser'; - -import { - commentParserToESTree, jsdocVisitorKeys -} from './commentParserToESTree.js'; - -/** - * @param {{[name: string]: any}} settings - * @returns {import('.').CommentHandler} - */ -const commentHandler = (settings) => { - /** - * @type {import('.').CommentHandler} - */ - return (commentSelector, jsdoc) => { - const {mode} = settings; - - const selector = esquery.parse(commentSelector); - - const ast = commentParserToESTree(jsdoc, mode); - - const _ast = /** @type {unknown} */ (ast); - - return esquery.matches(/** @type {import('estree').Node} */ ( - _ast - ), selector, undefined, { - visitorKeys: { - ...jsdocTypePrattParserVisitorKeys, - ...jsdocVisitorKeys - } - }); - }; -}; - -export {commentHandler}; diff --git a/tools/eslint/node_modules/@es-joy/jsdoccomment/src/commentParserToESTree.js b/tools/eslint/node_modules/@es-joy/jsdoccomment/src/commentParserToESTree.js deleted file mode 100644 index ba4c8981a771c5..00000000000000 --- a/tools/eslint/node_modules/@es-joy/jsdoccomment/src/commentParserToESTree.js +++ /dev/null @@ -1,504 +0,0 @@ -import {parse as jsdocTypePrattParse} from 'jsdoc-type-pratt-parser'; - -/** - * Removes initial and ending brackets from `rawType` - * @param {JsdocTypeLine[]|JsdocTag} container - * @param {boolean} [isArr] - * @returns {void} - */ -const stripEncapsulatingBrackets = (container, isArr) => { - if (isArr) { - const firstItem = /** @type {JsdocTypeLine[]} */ (container)[0]; - firstItem.rawType = firstItem.rawType.replace( - /^\{/u, '' - ); - - const lastItem = /** @type {JsdocTypeLine} */ ( - /** @type {JsdocTypeLine[]} */ ( - container - ).at(-1) - ); - lastItem.rawType = lastItem.rawType.replace(/\}$/u, ''); - - return; - } - /** @type {JsdocTag} */ (container).rawType = - /** @type {JsdocTag} */ (container).rawType.replace( - /^\{/u, '' - ).replace(/\}$/u, ''); -}; - -/** - * @typedef {{ - * delimiter: string, - * postDelimiter: string, - * rawType: string, - * initial: string, - * type: "JsdocTypeLine" - * }} JsdocTypeLine - */ - -/** - * @typedef {{ - * delimiter: string, - * description: string, - * postDelimiter: string, - * initial: string, - * type: "JsdocDescriptionLine" - * }} JsdocDescriptionLine - */ - -/** - * @typedef {{ - * format: 'pipe' | 'plain' | 'prefix' | 'space', - * namepathOrURL: string, - * tag: string, - * text: string, - * }} JsdocInlineTagNoType - */ -/** - * @typedef {JsdocInlineTagNoType & { - * type: "JsdocInlineTag" - * }} JsdocInlineTag - */ - -/** - * @typedef {{ - * delimiter: string, - * description: string, - * descriptionLines: JsdocDescriptionLine[], - * initial: string, - * inlineTags: JsdocInlineTag[] - * name: string, - * postDelimiter: string, - * postName: string, - * postTag: string, - * postType: string, - * rawType: string, - * parsedType: import('jsdoc-type-pratt-parser').RootResult|null - * tag: string, - * type: "JsdocTag", - * typeLines: JsdocTypeLine[], - * }} JsdocTag - */ - -/** - * @typedef {number} Integer - */ - -/** - * @typedef {{ - * delimiter: string, - * delimiterLineBreak: string, - * description: string, - * descriptionEndLine?: Integer, - * descriptionLines: JsdocDescriptionLine[], - * descriptionStartLine?: Integer, - * hasPreterminalDescription: 0|1, - * hasPreterminalTagDescription?: 1, - * initial: string, - * inlineTags: JsdocInlineTag[] - * lastDescriptionLine?: Integer, - * endLine: Integer, - * lineEnd: string, - * postDelimiter: string, - * tags: JsdocTag[], - * terminal: string, - * preterminalLineBreak: string, - * type: "JsdocBlock", - * }} JsdocBlock - */ - -/** - * @param {object} cfg - * @param {string} cfg.text - * @param {string} cfg.tag - * @param {'pipe' | 'plain' | 'prefix' | 'space'} cfg.format - * @param {string} cfg.namepathOrURL - * @returns {JsdocInlineTag} - */ -const inlineTagToAST = ({text, tag, format, namepathOrURL}) => ({ - text, - tag, - format, - namepathOrURL, - type: 'JsdocInlineTag' -}); - -/** - * Converts comment parser AST to ESTree format. - * @param {import('.').JsdocBlockWithInline} jsdoc - * @param {import('jsdoc-type-pratt-parser').ParseMode} mode - * @param {object} opts - * @param {'compact'|'preserve'} [opts.spacing] By default, empty lines are - * compacted; set to 'preserve' to preserve empty comment lines. - * @param {boolean} [opts.throwOnTypeParsingErrors] - * @returns {JsdocBlock} - */ -const commentParserToESTree = (jsdoc, mode, { - spacing = 'compact', - throwOnTypeParsingErrors = false -} = {}) => { - /** - * Strips brackets from a tag's `rawType` values and adds `parsedType` - * @param {JsdocTag} lastTag - * @returns {void} - */ - const cleanUpLastTag = (lastTag) => { - // Strip out `}` that encapsulates and is not part of - // the type - stripEncapsulatingBrackets(lastTag); - - if (lastTag.typeLines.length) { - stripEncapsulatingBrackets(lastTag.typeLines, true); - } - - // Remove single empty line description. - if (lastTag.descriptionLines.length === 1 && - lastTag.descriptionLines[0].description === '') { - lastTag.descriptionLines.length = 0; - } - - // With even a multiline type now in full, add parsing - let parsedType = null; - - try { - parsedType = jsdocTypePrattParse(lastTag.rawType, mode); - } catch (err) { - // Ignore - if (lastTag.rawType && throwOnTypeParsingErrors) { - /** @type {Error} */ ( - err - ).message = `Tag @${lastTag.tag} with raw type ` + - `\`${lastTag.rawType}\` had parsing error: ${ - /** @type {Error} */ (err).message}`; - throw err; - } - } - - lastTag.parsedType = parsedType; - }; - - const {source, inlineTags: blockInlineTags} = jsdoc; - - const {tokens: { - delimiter: delimiterRoot, - lineEnd: lineEndRoot, - postDelimiter: postDelimiterRoot, - start: startRoot, - end: endRoot - }} = source[0]; - - const endLine = source.length - 1; - - /** @type {JsdocBlock} */ - const ast = { - delimiter: delimiterRoot, - delimiterLineBreak: '\n', - description: '', - - descriptionLines: [], - inlineTags: blockInlineTags.map((t) => inlineTagToAST(t)), - - initial: startRoot, - tags: [], - // `terminal` will be overwritten if there are other entries - terminal: endRoot, - preterminalLineBreak: '\n', - hasPreterminalDescription: 0, - endLine, - postDelimiter: postDelimiterRoot, - lineEnd: lineEndRoot, - - type: 'JsdocBlock' - }; - - /** - * @type {JsdocTag[]} - */ - const tags = []; - - /** @type {Integer|undefined} */ - let lastDescriptionLine; - - /** @type {JsdocTag|null} */ - let lastTag = null; - - // Tracks when first valid tag description line is seen. - let tagDescriptionSeen = false; - - let descLineStateOpen = true; - - source.forEach((info, idx) => { - const {tokens} = info; - const { - delimiter, - description, - postDelimiter, - start: initial, - tag, - end, - type: rawType - } = tokens; - - if (!tag && description && descLineStateOpen) { - if (ast.descriptionStartLine === undefined) { - ast.descriptionStartLine = idx; - } - ast.descriptionEndLine = idx; - } - - if (tag || end) { - descLineStateOpen = false; - if (lastDescriptionLine === undefined) { - lastDescriptionLine = idx; - } - - // Clean-up with last tag before end or new tag - if (lastTag) { - cleanUpLastTag(lastTag); - } - - // Stop the iteration when we reach the end - // but only when there is no tag earlier in the line - // to still process - if (end && !tag) { - ast.terminal = end; - - // Check if there are any description lines and if not then this is a - // one line comment block. - const isDelimiterLine = ast.descriptionLines.length === 0 && - delimiter === '/**'; - - // Remove delimiter line break for one line comments blocks. - if (isDelimiterLine) { - ast.delimiterLineBreak = ''; - } - - if (description) { - // Remove terminal line break at end when description is defined. - if (ast.terminal === '*/') { - ast.preterminalLineBreak = ''; - } - - if (lastTag) { - ast.hasPreterminalTagDescription = 1; - } else { - ast.hasPreterminalDescription = 1; - } - - const holder = lastTag || ast; - holder.description += (holder.description ? '\n' : '') + description; - - // Do not include `delimiter` / `postDelimiter` for opening - // delimiter line. - - holder.descriptionLines.push({ - delimiter: isDelimiterLine ? '' : delimiter, - description, - postDelimiter: isDelimiterLine ? '' : postDelimiter, - initial, - type: 'JsdocDescriptionLine' - }); - } - return; - } - - const { - // eslint-disable-next-line no-unused-vars -- Discarding - end: ed, - delimiter: de, - postDelimiter: pd, - start: init, - ...tkns - } = tokens; - - if (!tokens.name) { - let i = 1; - while (source[idx + i]) { - const {tokens: { - name, - postName, - postType, - tag: tg - }} = source[idx + i]; - if (tg) { - break; - } - if (name) { - tkns.postType = postType; - tkns.name = name; - tkns.postName = postName; - break; - } - i++; - } - } - - /** - * @type {JsdocInlineTag[]} - */ - let tagInlineTags = []; - if (tag) { - // Assuming the tags from `source` are in the same order as `jsdoc.tags` - // we can use the `tags` length as index into the parser result tags. - tagInlineTags = - /** - * @type {import('comment-parser').Spec & { - * inlineTags: JsdocInlineTagNoType[] - * }} - */ ( - jsdoc.tags[tags.length] - ).inlineTags.map( - (t) => inlineTagToAST(t) - ); - } - - /** @type {JsdocTag} */ - const tagObj = { - ...tkns, - initial: endLine ? init : '', - postDelimiter: lastDescriptionLine ? pd : '', - delimiter: lastDescriptionLine ? de : '', - descriptionLines: [], - inlineTags: tagInlineTags, - parsedType: null, - rawType: '', - type: 'JsdocTag', - typeLines: [] - }; - tagObj.tag = tagObj.tag.replace(/^@/u, ''); - - lastTag = tagObj; - tagDescriptionSeen = false; - - tags.push(tagObj); - } - - if (rawType) { - // Will strip rawType brackets after this tag - /** @type {JsdocTag} */ (lastTag).typeLines.push( - /** @type {JsdocTag} */ (lastTag).typeLines.length - ? { - delimiter, - postDelimiter, - rawType, - initial, - type: 'JsdocTypeLine' - } - : { - delimiter: '', - postDelimiter: '', - rawType, - initial: '', - type: 'JsdocTypeLine' - } - ); - /** @type {JsdocTag} */ (lastTag).rawType += /** @type {JsdocTag} */ ( - lastTag - ).rawType - ? '\n' + rawType - : rawType; - } - - // In `compact` mode skip processing if `description` is an empty string - // unless lastTag is being processed. - // - // In `preserve` mode process when `description` is not the `empty string - // or the `delimiter` is not `/**` ensuring empty lines are preserved. - if (((spacing === 'compact' && description) || lastTag) || - (spacing === 'preserve' && (description || delimiter !== '/**'))) { - const holder = lastTag || ast; - - // Check if there are any description lines and if not then this is a - // multi-line comment block with description on 0th line. Treat - // `delimiter` / `postDelimiter` / `initial` as being on a new line. - const isDelimiterLine = holder.descriptionLines.length === 0 && - delimiter === '/**'; - - // Remove delimiter line break for one line comments blocks. - if (isDelimiterLine) { - ast.delimiterLineBreak = ''; - } - - // Track when the first description line is seen to avoid adding empty - // description lines for tag type lines. - tagDescriptionSeen ||= Boolean(lastTag && - (rawType === '' || rawType?.endsWith('}'))); - - if (lastTag) { - if (tagDescriptionSeen) { - // The first tag description line is a continuation after type / - // name parsing. - const isFirstDescriptionLine = holder.descriptionLines.length === 0; - - // For `compact` spacing must allow through first description line. - if ((spacing === 'compact' && - (description || isFirstDescriptionLine)) || - spacing === 'preserve') { - holder.descriptionLines.push({ - delimiter: isFirstDescriptionLine ? '' : delimiter, - description, - postDelimiter: isFirstDescriptionLine ? '' : postDelimiter, - initial: isFirstDescriptionLine ? '' : initial, - type: 'JsdocDescriptionLine' - }); - } - } - } else { - holder.descriptionLines.push({ - delimiter: isDelimiterLine ? '' : delimiter, - description, - postDelimiter: isDelimiterLine ? '' : postDelimiter, - initial: isDelimiterLine ? `` : initial, - type: 'JsdocDescriptionLine' - }); - } - - if (!tag) { - if (lastTag) { - // For `compact` spacing must filter out any empty description lines - // after the initial `holder.description` has content. - if (tagDescriptionSeen && !(spacing === 'compact' && - holder.description && description === '')) { - holder.description += !holder.description - ? description - : '\n' + description; - } - } else { - holder.description += !holder.description - ? description - : '\n' + description; - } - } - } - - // Clean-up where last line itself has tag content - if (end && tag) { - ast.terminal = end; - ast.hasPreterminalTagDescription = 1; - - // Remove terminal line break at end when tag is defined on last line. - if (ast.terminal === '*/') { - ast.preterminalLineBreak = ''; - } - - cleanUpLastTag(/** @type {JsdocTag} */ (lastTag)); - } - }); - - ast.lastDescriptionLine = lastDescriptionLine; - ast.tags = tags; - - return ast; -}; - -const jsdocVisitorKeys = { - JsdocBlock: ['descriptionLines', 'tags', 'inlineTags'], - JsdocDescriptionLine: [], - JsdocTypeLine: [], - JsdocTag: ['parsedType', 'typeLines', 'descriptionLines', 'inlineTags'], - JsdocInlineTag: [] -}; - -export {commentParserToESTree, jsdocVisitorKeys}; diff --git a/tools/eslint/node_modules/@es-joy/jsdoccomment/src/estreeToString.js b/tools/eslint/node_modules/@es-joy/jsdoccomment/src/estreeToString.js deleted file mode 100644 index 29268803ddee93..00000000000000 --- a/tools/eslint/node_modules/@es-joy/jsdoccomment/src/estreeToString.js +++ /dev/null @@ -1,179 +0,0 @@ -import {stringify as prattStringify} from 'jsdoc-type-pratt-parser'; - -/** @type {Record} */ -const stringifiers = { - JsdocBlock, - - /** - * @param {import('./commentParserToESTree').JsdocDescriptionLine} node - * @returns {string} - */ - JsdocDescriptionLine ({ - initial, delimiter, postDelimiter, description - }) { - return `${initial}${delimiter}${postDelimiter}${description}`; - }, - - /** - * @param {import('./commentParserToESTree').JsdocTypeLine} node - * @returns {string} - */ - JsdocTypeLine ({ - initial, delimiter, postDelimiter, rawType - }) { - return `${initial}${delimiter}${postDelimiter}${rawType}`; - }, - - /** - * @param {import('./commentParserToESTree').JsdocInlineTag} node - */ - JsdocInlineTag ({format, namepathOrURL, tag, text}) { - return format === 'pipe' - ? `{@${tag} ${namepathOrURL}|${text}}` - : format === 'plain' - ? `{@${tag} ${namepathOrURL}}` - : format === 'prefix' - ? `[${text}]{@${tag} ${namepathOrURL}}` - // "space" - : `{@${tag} ${namepathOrURL} ${text}}`; - }, - - JsdocTag -}; - -/** - * @todo convert for use by escodegen (until may be patched to support - * custom entries?). - * @param {import('./commentParserToESTree').JsdocBlock| - * import('./commentParserToESTree').JsdocDescriptionLine| - * import('./commentParserToESTree').JsdocTypeLine| - * import('./commentParserToESTree').JsdocTag| - * import('./commentParserToESTree').JsdocInlineTag| - * import('jsdoc-type-pratt-parser').RootResult - * } node - * @param {import('.').ESTreeToStringOptions} opts - * @throws {Error} - * @returns {string} - */ -function estreeToString (node, opts = {}) { - if (Object.prototype.hasOwnProperty.call(stringifiers, node.type)) { - return stringifiers[ - /** - * @type {import('./commentParserToESTree').JsdocBlock| - * import('./commentParserToESTree').JsdocDescriptionLine| - * import('./commentParserToESTree').JsdocTypeLine| - * import('./commentParserToESTree').JsdocTag} - */ - (node).type - ]( - node, - opts - ); - } - - // We use raw type instead but it is a key as other apps may wish to traverse - if (node.type.startsWith('JsdocType')) { - return opts.preferRawType - ? '' - : `{${prattStringify( - /** @type {import('jsdoc-type-pratt-parser').RootResult} */ ( - node - ) - )}}`; - } - - throw new Error(`Unhandled node type: ${node.type}`); -} - -/** - * @param {import('./commentParserToESTree').JsdocBlock} node - * @param {import('.').ESTreeToStringOptions} opts - * @returns {string} - */ -function JsdocBlock (node, opts) { - const {delimiter, delimiterLineBreak, descriptionLines, - initial, postDelimiter, preterminalLineBreak, tags, terminal} = node; - - const terminalPrepend = preterminalLineBreak !== '' - ? `${preterminalLineBreak}${initial} ` - : ''; - - let result = `${initial}${delimiter}${postDelimiter}${delimiterLineBreak}`; - - for (let i = 0; i < descriptionLines.length; i++) { - result += estreeToString(descriptionLines[i]); - - if (i !== descriptionLines.length - 1 || tags.length) { - result += '\n'; - } - } - - for (let i = 0; i < tags.length; i++) { - result += estreeToString(tags[i], opts); - - if (i !== tags.length - 1) { - result += '\n'; - } - } - - result += `${terminalPrepend}${terminal}`; - - return result; -} - -/** - * @param {import('./commentParserToESTree').JsdocTag} node - * @param {import('.').ESTreeToStringOptions} opts - * @returns {string} - */ -function JsdocTag (node, opts) { - const { - delimiter, descriptionLines, initial, name, parsedType, postDelimiter, - postName, postTag, postType, tag, typeLines - } = node; - - let result = `${initial}${delimiter}${postDelimiter}@${tag}${postTag}`; - - // Could do `rawType` but may have been changed; could also do - // `typeLines` but not as likely to be changed - // parsedType - // Comment this out later in favor of `parsedType` - // We can't use raw `typeLines` as first argument has delimiter on it - if (opts.preferRawType || !parsedType) { - if (typeLines.length) { - result += '{'; - - for (let i = 0; i < typeLines.length; i++) { - result += estreeToString(typeLines[i]); - - if (i !== typeLines.length - 1) { - result += '\n'; - } - } - - result += '}'; - } - } else if (parsedType?.type.startsWith('JsdocType')) { - result += `{${prattStringify( - /** @type {import('jsdoc-type-pratt-parser').RootResult} */ ( - parsedType - ) - )}}`; - } - - result += name ? `${postType}${name}${postName}` : postType; - - for (let i = 0; i < descriptionLines.length; i++) { - const descriptionLine = descriptionLines[i]; - - result += estreeToString(descriptionLine); - - if (i !== descriptionLines.length - 1) { - result += '\n'; - } - } - - return result; -} - -export {estreeToString}; diff --git a/tools/eslint/node_modules/@es-joy/jsdoccomment/src/index.js b/tools/eslint/node_modules/@es-joy/jsdoccomment/src/index.js deleted file mode 100644 index cd68852e3edd7e..00000000000000 --- a/tools/eslint/node_modules/@es-joy/jsdoccomment/src/index.js +++ /dev/null @@ -1,50 +0,0 @@ -/** - * @typedef {import('./commentParserToESTree').JsdocInlineTagNoType & { - * start: number, - * end: number, - * }} InlineTag - */ - -/** - * @typedef {import('comment-parser').Spec & { - * line?: import('./commentParserToESTree').Integer, - * inlineTags: (import('./commentParserToESTree').JsdocInlineTagNoType & { - * line?: import('./commentParserToESTree').Integer - * })[] - * }} JsdocTagWithInline - */ - -/** - * Expands on comment-parser's `Block` interface. - * @typedef {{ - * description: string, - * source: import('comment-parser').Line[], - * problems: import('comment-parser').Problem[], - * tags: JsdocTagWithInline[], - * inlineTags: (import('./commentParserToESTree').JsdocInlineTagNoType & { - * line?: import('./commentParserToESTree').Integer - * })[] - * }} JsdocBlockWithInline - */ - -/** - * @typedef {{preferRawType?: boolean}} ESTreeToStringOptions - */ - -/** - * @callback CommentHandler - * @param {string} commentSelector - * @param {import('.').JsdocBlockWithInline} jsdoc - * @returns {boolean} - */ - -export {visitorKeys as jsdocTypeVisitorKeys} from 'jsdoc-type-pratt-parser'; - -export * from 'jsdoc-type-pratt-parser'; - -export * from './commentHandler.js'; -export * from './commentParserToESTree.js'; -export * from './estreeToString.js'; -export * from './jsdoccomment.js'; -export * from './parseComment.js'; -export * from './parseInlineTags.js'; diff --git a/tools/eslint/node_modules/@es-joy/jsdoccomment/src/jsdoccomment.js b/tools/eslint/node_modules/@es-joy/jsdoccomment/src/jsdoccomment.js deleted file mode 100644 index a810cbd2ca49b9..00000000000000 --- a/tools/eslint/node_modules/@es-joy/jsdoccomment/src/jsdoccomment.js +++ /dev/null @@ -1,487 +0,0 @@ -/** - * Obtained originally from {@link https://github.com/eslint/eslint/blob/master/lib/util/source-code.js#L313}. - * - * @license MIT - */ - -/** - * @typedef {import('eslint').AST.Token | import('estree').Comment | { - * type: import('eslint').AST.TokenType|"Line"|"Block"|"Shebang", - * range: [number, number], - * value: string - * }} Token - */ - -/** - * @typedef {import('eslint').Rule.Node| - * import('@typescript-eslint/types').TSESTree.Node} ESLintOrTSNode - */ - -/** - * @typedef {number} int - */ - -/** - * Checks if the given token is a comment token or not. - * - * @param {Token} token - The token to check. - * @returns {boolean} `true` if the token is a comment token. - */ -const isCommentToken = (token) => { - return token.type === 'Line' || token.type === 'Block' || - token.type === 'Shebang'; -}; - -/** - * @param {(ESLintOrTSNode|import('estree').Comment) & { - * declaration?: any, - * decorators?: any[], - * parent?: import('eslint').Rule.Node & { - * decorators?: any[] - * } - * }} node - * @returns {import('@typescript-eslint/types').TSESTree.Decorator|undefined} - */ -const getDecorator = (node) => { - return node?.declaration?.decorators?.[0] || node?.decorators?.[0] || - node?.parent?.decorators?.[0]; -}; - -/** - * Check to see if it is a ES6 export declaration. - * - * @param {ESLintOrTSNode} astNode An AST node. - * @returns {boolean} whether the given node represents an export declaration. - * @private - */ -const looksLikeExport = function (astNode) { - return astNode.type === 'ExportDefaultDeclaration' || - astNode.type === 'ExportNamedDeclaration' || - astNode.type === 'ExportAllDeclaration' || - astNode.type === 'ExportSpecifier'; -}; - -/** - * @param {ESLintOrTSNode} astNode - * @returns {ESLintOrTSNode} - */ -const getTSFunctionComment = function (astNode) { - const {parent} = astNode; - /* v8 ignore next 3 */ - if (!parent) { - return astNode; - } - const grandparent = parent.parent; - /* v8 ignore next 3 */ - if (!grandparent) { - return astNode; - } - const greatGrandparent = grandparent.parent; - const greatGreatGrandparent = greatGrandparent && greatGrandparent.parent; - - /* v8 ignore next 3 */ - if (/** @type {ESLintOrTSNode} */ (parent).type !== 'TSTypeAnnotation') { - return astNode; - } - - switch (/** @type {ESLintOrTSNode} */ (grandparent).type) { - // @ts-expect-error -- For `ClassProperty`. - case 'PropertyDefinition': case 'ClassProperty': - case 'TSDeclareFunction': - case 'TSMethodSignature': - case 'TSPropertySignature': - return grandparent; - case 'ArrowFunctionExpression': - /* v8 ignore next 3 */ - if (!greatGrandparent) { - return astNode; - } - - if ( - greatGrandparent.type === 'VariableDeclarator' - - // && greatGreatGrandparent.parent.type === 'VariableDeclaration' - ) { - /* v8 ignore next 3 */ - if (!greatGreatGrandparent || !greatGreatGrandparent.parent) { - return astNode; - } - return greatGreatGrandparent.parent; - } - /* v8 ignore next */ - return astNode; - case 'FunctionExpression': - /* v8 ignore next 3 */ - if (!greatGreatGrandparent) { - return astNode; - } - if (greatGrandparent.type === 'MethodDefinition') { - return greatGrandparent; - } - - // Fallthrough - default: - /* v8 ignore next 3 */ - if (grandparent.type !== 'Identifier') { - return astNode; - } - } - - /* v8 ignore next 3 */ - if (!greatGreatGrandparent) { - return astNode; - } - - switch (greatGrandparent.type) { - case 'ArrowFunctionExpression': - if ( - greatGreatGrandparent.type === 'VariableDeclarator' && - greatGreatGrandparent.parent.type === 'VariableDeclaration' - ) { - return greatGreatGrandparent.parent; - } - - return astNode; - case 'FunctionDeclaration': - return greatGrandparent; - case 'VariableDeclarator': - if (greatGreatGrandparent.type === 'VariableDeclaration') { - return greatGreatGrandparent; - } - /* v8 ignore next 2 */ - // Fallthrough - default: - /* v8 ignore next 3 */ - return astNode; - } -}; - -const invokedExpression = new Set( - ['CallExpression', 'OptionalCallExpression', 'NewExpression'] -); -const allowableCommentNode = new Set([ - 'AssignmentPattern', - 'VariableDeclaration', - 'ExpressionStatement', - 'MethodDefinition', - 'Property', - 'ObjectProperty', - 'ClassProperty', - 'PropertyDefinition', - 'ExportDefaultDeclaration', - 'ReturnStatement' -]); - -/** - * Reduces the provided node to the appropriate node for evaluating - * JSDoc comment status. - * - * @param {ESLintOrTSNode} node An AST node. - * @param {import('eslint').SourceCode} sourceCode The ESLint SourceCode. - * @returns {ESLintOrTSNode} The AST node that - * can be evaluated for appropriate JSDoc comments. - */ -const getReducedASTNode = function (node, sourceCode) { - let {parent} = node; - - switch (/** @type {ESLintOrTSNode} */ (node).type) { - case 'TSFunctionType': - return getTSFunctionComment(node); - case 'TSInterfaceDeclaration': - case 'TSTypeAliasDeclaration': - case 'TSEnumDeclaration': - case 'ClassDeclaration': - case 'FunctionDeclaration': - /* v8 ignore next 3 */ - if (!parent) { - return node; - } - return looksLikeExport(parent) ? parent : node; - - case 'TSDeclareFunction': - case 'ClassExpression': - case 'ObjectExpression': - case 'ArrowFunctionExpression': - case 'TSEmptyBodyFunctionExpression': - case 'FunctionExpression': - /* v8 ignore next 3 */ - if (!parent) { - return node; - } - if ( - !invokedExpression.has(parent.type) - ) { - /** - * @type {ESLintOrTSNode|Token|null} - */ - let token = node; - do { - token = sourceCode.getTokenBefore( - /** @type {import('eslint').Rule.Node|import('eslint').AST.Token} */ ( - token - ), - {includeComments: true} - ); - } while (token && token.type === 'Punctuator' && token.value === '('); - if (token && token.type === 'Block') { - return node; - } - - if (sourceCode.getCommentsBefore( - /** @type {import('eslint').Rule.Node} */ - (node) - ).length) { - return node; - } - - while ( - !sourceCode.getCommentsBefore( - /** @type {import('eslint').Rule.Node} */ - (parent) - ).length && - !(/Function/u).test(parent.type) && - !allowableCommentNode.has(parent.type) - ) { - ({parent} = parent); - - if (!parent) { - break; - } - } - if (parent && parent.type !== 'FunctionDeclaration' && - parent.type !== 'Program' - ) { - if (parent.parent && parent.parent.type === 'ExportNamedDeclaration') { - return parent.parent; - } - - return parent; - } - } - - return node; - - default: - return node; - } -}; - -/** - * Checks for the presence of a JSDoc comment for the given node and returns it. - * - * @param {ESLintOrTSNode} astNode The AST node to get - * the comment for. - * @param {import('eslint').SourceCode} sourceCode - * @param {{maxLines: int, minLines: int, [name: string]: any}} settings - * @param {{nonJSDoc?: boolean}} [opts] - * @returns {Token|null} The Block comment token containing the JSDoc comment - * for the given node or null if not found. - */ -const findJSDocComment = (astNode, sourceCode, settings, opts = {}) => { - const {nonJSDoc} = opts; - const {minLines, maxLines} = settings; - - /** @type {ESLintOrTSNode|import('estree').Comment} */ - let currentNode = astNode; - let tokenBefore = null; - let parenthesisToken = null; - - while (currentNode) { - const decorator = getDecorator( - /** @type {import('eslint').Rule.Node} */ - (currentNode) - ); - if (decorator) { - const dec = /** @type {unknown} */ (decorator); - currentNode = /** @type {import('eslint').Rule.Node} */ (dec); - } - tokenBefore = sourceCode.getTokenBefore( - /** @type {import('eslint').Rule.Node} */ - (currentNode), - {includeComments: true} - ); - if ( - tokenBefore && tokenBefore.type === 'Punctuator' && - tokenBefore.value === '(' - ) { - parenthesisToken = tokenBefore; - [tokenBefore] = sourceCode.getTokensBefore( - /** @type {import('eslint').Rule.Node} */ - (currentNode), - { - count: 2, - includeComments: true - } - ); - } - if (!tokenBefore || !isCommentToken(tokenBefore)) { - return null; - } - if (!nonJSDoc && tokenBefore.type === 'Line') { - currentNode = tokenBefore; - continue; - } - break; - } - - /* v8 ignore next 3 */ - if (!tokenBefore || !currentNode.loc || !tokenBefore.loc) { - return null; - } - - if ( - ( - (nonJSDoc && (tokenBefore.type !== 'Block' || - !(/^\*\s/u).test(tokenBefore.value))) || - (!nonJSDoc && tokenBefore.type === 'Block' && - (/^\*\s/u).test(tokenBefore.value)) - ) && - currentNode.loc.start.line - ( - /** @type {import('eslint').AST.Token} */ - (parenthesisToken ?? tokenBefore) - ).loc.end.line >= minLines && - currentNode.loc.start.line - ( - /** @type {import('eslint').AST.Token} */ - (parenthesisToken ?? tokenBefore) - ).loc.end.line <= maxLines - ) { - return tokenBefore; - } - - return null; -}; - -/** - * Retrieves the JSDoc comment for a given node. - * - * @param {import('eslint').SourceCode} sourceCode The ESLint SourceCode - * @param {import('eslint').Rule.Node} node The AST node to get - * the comment for. - * @param {{maxLines: int, minLines: int, [name: string]: any}} settings The - * settings in context - * @returns {Token|null} The Block comment - * token containing the JSDoc comment for the given node or - * null if not found. - * @public - */ -const getJSDocComment = function (sourceCode, node, settings) { - const reducedNode = getReducedASTNode(node, sourceCode); - - return findJSDocComment(reducedNode, sourceCode, settings); -}; - -/** - * Retrieves the comment preceding a given node. - * - * @param {import('eslint').SourceCode} sourceCode The ESLint SourceCode - * @param {ESLintOrTSNode} node The AST node to get - * the comment for. - * @param {{maxLines: int, minLines: int, [name: string]: any}} settings The - * settings in context - * @returns {Token|null} The Block comment - * token containing the JSDoc comment for the given node or - * null if not found. - * @public - */ -const getNonJsdocComment = function (sourceCode, node, settings) { - const reducedNode = getReducedASTNode(node, sourceCode); - - return findJSDocComment(reducedNode, sourceCode, settings, { - nonJSDoc: true - }); -}; - -/** - * @param {ESLintOrTSNode|import('eslint').AST.Token| - * import('estree').Comment - * } nodeA The AST node or token to compare - * @param {ESLintOrTSNode|import('eslint').AST.Token| - * import('estree').Comment} nodeB The - * AST node or token to compare - */ -const compareLocEndToStart = (nodeA, nodeB) => { - /* v8 ignore next */ - return (nodeA.loc?.end.line ?? 0) === (nodeB.loc?.start.line ?? 0); -}; - -/** - * Checks for the presence of a comment following the given node and - * returns it. - * - * This method is experimental. - * - * @param {import('eslint').SourceCode} sourceCode - * @param {ESLintOrTSNode} astNode The AST node to get - * the comment for. - * @returns {Token|null} The comment token containing the comment - * for the given node or null if not found. - */ -const getFollowingComment = function (sourceCode, astNode) { - /** - * @param {ESLintOrTSNode} node The - * AST node to get the comment for. - */ - const getTokensAfterIgnoringSemis = (node) => { - let tokenAfter = sourceCode.getTokenAfter( - /** @type {import('eslint').Rule.Node} */ - (node), - {includeComments: true} - ); - - while ( - tokenAfter && tokenAfter.type === 'Punctuator' && - // tokenAfter.value === ')' // Don't apparently need to ignore - tokenAfter.value === ';' - ) { - [tokenAfter] = sourceCode.getTokensAfter(tokenAfter, { - includeComments: true - }); - } - return tokenAfter; - }; - - /** - * @param {ESLintOrTSNode} node The - * AST node to get the comment for. - */ - const tokenAfterIgnoringSemis = (node) => { - const tokenAfter = getTokensAfterIgnoringSemis(node); - return ( - tokenAfter && - isCommentToken(tokenAfter) && - compareLocEndToStart(node, tokenAfter) - ) - ? tokenAfter - : null; - }; - - let tokenAfter = tokenAfterIgnoringSemis(astNode); - - if (!tokenAfter) { - switch (astNode.type) { - case 'FunctionDeclaration': - tokenAfter = tokenAfterIgnoringSemis( - /** @type {ESLintOrTSNode} */ - (astNode.body) - ); - break; - case 'ExpressionStatement': - tokenAfter = tokenAfterIgnoringSemis( - /** @type {ESLintOrTSNode} */ - (astNode.expression) - ); - break; - - /* v8 ignore next 3 */ - default: - break; - } - } - - return tokenAfter; -}; - -export { - getReducedASTNode, getJSDocComment, getNonJsdocComment, - getDecorator, findJSDocComment, getFollowingComment -}; diff --git a/tools/eslint/node_modules/@es-joy/jsdoccomment/src/parseComment.js b/tools/eslint/node_modules/@es-joy/jsdoccomment/src/parseComment.js deleted file mode 100644 index 385f851b3b5af2..00000000000000 --- a/tools/eslint/node_modules/@es-joy/jsdoccomment/src/parseComment.js +++ /dev/null @@ -1,190 +0,0 @@ -/* eslint-disable prefer-named-capture-group -- Temporary */ -import { - parse as commentParser, - tokenizers -} from 'comment-parser'; - -import {parseInlineTags} from './parseInlineTags.js'; - -const { - name: nameTokenizer, - tag: tagTokenizer, - type: typeTokenizer, - description: descriptionTokenizer -} = tokenizers; - -/** - * @param {import('comment-parser').Spec} spec - * @returns {boolean} - */ -export const hasSeeWithLink = (spec) => { - return spec.tag === 'see' && (/\{@link.+?\}/u).test(spec.source[0].source); -}; - -export const defaultNoTypes = [ - 'default', 'defaultvalue', 'description', 'example', - 'file', 'fileoverview', 'license', - 'overview', 'see', 'summary' -]; - -export const defaultNoNames = [ - 'access', 'author', - 'default', 'defaultvalue', - 'description', - 'example', 'exception', 'file', 'fileoverview', - 'kind', - 'license', 'overview', - 'return', 'returns', - 'since', 'summary', - 'throws', - 'version', 'variation' -]; - -const optionalBrackets = /^\[(?[^=]*)=[^\]]*\]/u; -const preserveTypeTokenizer = typeTokenizer('preserve'); -const preserveDescriptionTokenizer = descriptionTokenizer('preserve'); -const plainNameTokenizer = nameTokenizer(); - -/** - * Can't import `comment-parser/es6/parser/tokenizers/index.js`, - * so we redefine here. - * @typedef {(spec: import('comment-parser').Spec) => - * import('comment-parser').Spec} CommentParserTokenizer - */ - -/** - * @param {object} [cfg] - * @param {string[]} [cfg.noTypes] - * @param {string[]} [cfg.noNames] - * @returns {CommentParserTokenizer[]} - */ -const getTokenizers = ({ - noTypes = defaultNoTypes, - noNames = defaultNoNames -} = {}) => { - // trim - return [ - // Tag - tagTokenizer(), - - /** - * Type tokenizer. - * @param {import('comment-parser').Spec} spec - * @returns {import('comment-parser').Spec} - */ - (spec) => { - if (noTypes.includes(spec.tag)) { - return spec; - } - - return preserveTypeTokenizer(spec); - }, - - /** - * Name tokenizer. - * @param {import('comment-parser').Spec} spec - * @returns {import('comment-parser').Spec} - */ - (spec) => { - if (spec.tag === 'template') { - // const preWS = spec.postTag; - const remainder = spec.source[0].tokens.description; - - let pos; - if (remainder.startsWith('[') && remainder.includes(']')) { - const endingBracketPos = remainder.indexOf(']'); - pos = remainder.slice(endingBracketPos).search(/(? -1) { // Add offset to starting point if space found - pos += endingBracketPos; - } - } else { - pos = remainder.search(/(? -1) { - [, postName, description, lineEnd] = /** @type {RegExpMatchArray} */ ( - extra.match(/(\s*)([^\r]*)(\r)?/u) - ); - } - - if (optionalBrackets.test(name)) { - name = /** @type {string} */ ( - /** @type {RegExpMatchArray} */ ( - name.match(optionalBrackets) - )?.groups?.name - ); - spec.optional = true; - } else { - spec.optional = false; - } - - spec.name = name; - const {tokens} = spec.source[0]; - tokens.name = name; - tokens.postName = postName; - tokens.description = description; - tokens.lineEnd = lineEnd || ''; - - return spec; - } - - if (noNames.includes(spec.tag) || hasSeeWithLink(spec)) { - return spec; - } - - return plainNameTokenizer(spec); - }, - - /** - * Description tokenizer. - * @param {import('comment-parser').Spec} spec - * @returns {import('comment-parser').Spec} - */ - (spec) => { - return preserveDescriptionTokenizer(spec); - } - ]; -}; - -/** - * Accepts a comment token or complete comment string and converts it into - * `comment-parser` AST. - * @param {string | {value: string}} commentOrNode - * @param {string} [indent] Whitespace - * @returns {import('.').JsdocBlockWithInline} - */ -const parseComment = (commentOrNode, indent = '') => { - let block; - - switch (typeof commentOrNode) { - case 'string': - // Preserve JSDoc block start/end indentation. - [block] = commentParser(`${indent}${commentOrNode}`, { - // @see https://github.com/yavorskiy/comment-parser/issues/21 - tokenizers: getTokenizers() - }); - break; - - case 'object': - if (commentOrNode === null) { - throw new TypeError(`'commentOrNode' is not a string or object.`); - } - - // Preserve JSDoc block start/end indentation. - [block] = commentParser(`${indent}/*${commentOrNode.value}*/`, { - // @see https://github.com/yavorskiy/comment-parser/issues/21 - tokenizers: getTokenizers() - }); - break; - - default: - throw new TypeError(`'commentOrNode' is not a string or object.`); - } - - return parseInlineTags(block); -}; - -export {getTokenizers, parseComment}; diff --git a/tools/eslint/node_modules/@es-joy/jsdoccomment/src/parseInlineTags.js b/tools/eslint/node_modules/@es-joy/jsdoccomment/src/parseInlineTags.js deleted file mode 100644 index bd9868c96baf22..00000000000000 --- a/tools/eslint/node_modules/@es-joy/jsdoccomment/src/parseInlineTags.js +++ /dev/null @@ -1,108 +0,0 @@ -/** - * @param {RegExpMatchArray & { - * indices: { - * groups: { - * [key: string]: [number, number] - * } - * } - * groups: {[key: string]: string} - * }} match An inline tag regexp match. - * @returns {'pipe' | 'plain' | 'prefix' | 'space'} - */ -function determineFormat (match) { - const {separator, text} = match.groups; - const [, textEnd] = match.indices.groups.text; - const [tagStart] = match.indices.groups.tag; - if (!text) { - return 'plain'; - } else if (separator === '|') { - return 'pipe'; - } else if (textEnd < tagStart) { - return 'prefix'; - } - return 'space'; -} - -/** - * Extracts inline tags from a description. - * @param {string} description - * @returns {import('.').InlineTag[]} Array of inline tags from the description. - */ -function parseDescription (description) { - /** @type {import('.').InlineTag[]} */ - const result = []; - - // This could have been expressed in a single pattern, - // but having two avoids a potentially exponential time regex. - - const prefixedTextPattern = new RegExp(/(?:\[(?[^\]]+)\])\{@(?[^}\s]+)\s?(?[^}\s|]*)\}/gu, 'gud'); - // The pattern used to match for text after tag uses a negative lookbehind - // on the ']' char to avoid matching the prefixed case too. - const suffixedAfterPattern = new RegExp(/(?[^}\s]+)\s?(?[^}\s|]*)\s*(?[\s|])?\s*(?[^}]*)\}/gu, 'gud'); - - const matches = [ - ...description.matchAll(prefixedTextPattern), - ...description.matchAll(suffixedAfterPattern) - ]; - - for (const mtch of matches) { - const match = /** - * @type {RegExpMatchArray & { - * indices: { - * groups: { - * [key: string]: [number, number] - * } - * } - * groups: {[key: string]: string} - * }} - */ ( - mtch - ); - const {tag, namepathOrURL, text} = match.groups; - const [start, end] = match.indices[0]; - const format = determineFormat(match); - - result.push({ - tag, - namepathOrURL, - text, - format, - start, - end - }); - } - - return result; -} - -/** - * Splits the `{@prefix}` from remaining `Spec.lines[].token.description` - * into the `inlineTags` tokens, and populates `spec.inlineTags` - * @param {import('comment-parser').Block} block - * @returns {import('.').JsdocBlockWithInline} - */ -export function parseInlineTags (block) { - const inlineTags = - /** - * @type {(import('./commentParserToESTree').JsdocInlineTagNoType & { - * line?: import('./commentParserToESTree').Integer - * })[]} - */ ( - parseDescription(block.description) - ); - - /** @type {import('.').JsdocBlockWithInline} */ ( - block - ).inlineTags = inlineTags; - - for (const tag of block.tags) { - /** - * @type {import('.').JsdocTagWithInline} - */ (tag).inlineTags = parseDescription(tag.description); - } - return ( - /** - * @type {import('.').JsdocBlockWithInline} - */ (block) - ); -} diff --git a/tools/eslint/node_modules/@es-joy/jsdoccomment/src/toCamelCase.js b/tools/eslint/node_modules/@es-joy/jsdoccomment/src/toCamelCase.js deleted file mode 100644 index 0526f02b4c4768..00000000000000 --- a/tools/eslint/node_modules/@es-joy/jsdoccomment/src/toCamelCase.js +++ /dev/null @@ -1,13 +0,0 @@ -/** - * @param {string} str - * @returns {string} - */ -const toCamelCase = (str) => { - return str.toLowerCase().replaceAll(/^[a-z]/gu, (init) => { - return init.toUpperCase(); - }).replaceAll(/_(?[a-z])/gu, (_, n1, o, s, {wordInit}) => { - return wordInit.toUpperCase(); - }); -}; - -export {toCamelCase}; diff --git a/tools/eslint/node_modules/@eslint-community/eslint-utils/LICENSE b/tools/eslint/node_modules/@eslint-community/eslint-utils/LICENSE deleted file mode 100644 index 883ee1f612d12c..00000000000000 --- a/tools/eslint/node_modules/@eslint-community/eslint-utils/LICENSE +++ /dev/null @@ -1,21 +0,0 @@ -MIT License - -Copyright (c) 2018 Toru Nagashima - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. diff --git a/tools/eslint/node_modules/@eslint-community/eslint-utils/index.js b/tools/eslint/node_modules/@eslint-community/eslint-utils/index.js deleted file mode 100644 index 156015e0e463b5..00000000000000 --- a/tools/eslint/node_modules/@eslint-community/eslint-utils/index.js +++ /dev/null @@ -1,2068 +0,0 @@ -'use strict'; - -Object.defineProperty(exports, '__esModule', { value: true }); - -var eslintVisitorKeys = require('eslint-visitor-keys'); - -/** - * Get the innermost scope which contains a given location. - * @param {Scope} initialScope The initial scope to search. - * @param {Node} node The location to search. - * @returns {Scope} The innermost scope. - */ -function getInnermostScope(initialScope, node) { - const location = node.range[0]; - - let scope = initialScope; - let found = false; - do { - found = false; - for (const childScope of scope.childScopes) { - const range = childScope.block.range; - - if (range[0] <= location && location < range[1]) { - scope = childScope; - found = true; - break - } - } - } while (found) - - return scope -} - -/** - * Find the variable of a given name. - * @param {Scope} initialScope The scope to start finding. - * @param {string|Node} nameOrNode The variable name to find. If this is a Node object then it should be an Identifier node. - * @returns {Variable|null} The found variable or null. - */ -function findVariable(initialScope, nameOrNode) { - let name = ""; - let scope = initialScope; - - if (typeof nameOrNode === "string") { - name = nameOrNode; - } else { - name = nameOrNode.name; - scope = getInnermostScope(scope, nameOrNode); - } - - while (scope != null) { - const variable = scope.set.get(name); - if (variable != null) { - return variable - } - scope = scope.upper; - } - - return null -} - -/** - * Negate the result of `this` calling. - * @param {Token} token The token to check. - * @returns {boolean} `true` if the result of `this(token)` is `false`. - */ -function negate0(token) { - return !this(token) //eslint-disable-line no-invalid-this -} - -/** - * Creates the negate function of the given function. - * @param {function(Token):boolean} f - The function to negate. - * @returns {function(Token):boolean} Negated function. - */ -function negate(f) { - return negate0.bind(f) -} - -/** - * Checks if the given token is a PunctuatorToken with the given value - * @param {Token} token - The token to check. - * @param {string} value - The value to check. - * @returns {boolean} `true` if the token is a PunctuatorToken with the given value. - */ -function isPunctuatorTokenWithValue(token, value) { - return token.type === "Punctuator" && token.value === value -} - -/** - * Checks if the given token is an arrow token or not. - * @param {Token} token - The token to check. - * @returns {boolean} `true` if the token is an arrow token. - */ -function isArrowToken(token) { - return isPunctuatorTokenWithValue(token, "=>") -} - -/** - * Checks if the given token is a comma token or not. - * @param {Token} token - The token to check. - * @returns {boolean} `true` if the token is a comma token. - */ -function isCommaToken(token) { - return isPunctuatorTokenWithValue(token, ",") -} - -/** - * Checks if the given token is a semicolon token or not. - * @param {Token} token - The token to check. - * @returns {boolean} `true` if the token is a semicolon token. - */ -function isSemicolonToken(token) { - return isPunctuatorTokenWithValue(token, ";") -} - -/** - * Checks if the given token is a colon token or not. - * @param {Token} token - The token to check. - * @returns {boolean} `true` if the token is a colon token. - */ -function isColonToken(token) { - return isPunctuatorTokenWithValue(token, ":") -} - -/** - * Checks if the given token is an opening parenthesis token or not. - * @param {Token} token - The token to check. - * @returns {boolean} `true` if the token is an opening parenthesis token. - */ -function isOpeningParenToken(token) { - return isPunctuatorTokenWithValue(token, "(") -} - -/** - * Checks if the given token is a closing parenthesis token or not. - * @param {Token} token - The token to check. - * @returns {boolean} `true` if the token is a closing parenthesis token. - */ -function isClosingParenToken(token) { - return isPunctuatorTokenWithValue(token, ")") -} - -/** - * Checks if the given token is an opening square bracket token or not. - * @param {Token} token - The token to check. - * @returns {boolean} `true` if the token is an opening square bracket token. - */ -function isOpeningBracketToken(token) { - return isPunctuatorTokenWithValue(token, "[") -} - -/** - * Checks if the given token is a closing square bracket token or not. - * @param {Token} token - The token to check. - * @returns {boolean} `true` if the token is a closing square bracket token. - */ -function isClosingBracketToken(token) { - return isPunctuatorTokenWithValue(token, "]") -} - -/** - * Checks if the given token is an opening brace token or not. - * @param {Token} token - The token to check. - * @returns {boolean} `true` if the token is an opening brace token. - */ -function isOpeningBraceToken(token) { - return isPunctuatorTokenWithValue(token, "{") -} - -/** - * Checks if the given token is a closing brace token or not. - * @param {Token} token - The token to check. - * @returns {boolean} `true` if the token is a closing brace token. - */ -function isClosingBraceToken(token) { - return isPunctuatorTokenWithValue(token, "}") -} - -/** - * Checks if the given token is a comment token or not. - * @param {Token} token - The token to check. - * @returns {boolean} `true` if the token is a comment token. - */ -function isCommentToken(token) { - return ["Block", "Line", "Shebang"].includes(token.type) -} - -const isNotArrowToken = negate(isArrowToken); -const isNotCommaToken = negate(isCommaToken); -const isNotSemicolonToken = negate(isSemicolonToken); -const isNotColonToken = negate(isColonToken); -const isNotOpeningParenToken = negate(isOpeningParenToken); -const isNotClosingParenToken = negate(isClosingParenToken); -const isNotOpeningBracketToken = negate(isOpeningBracketToken); -const isNotClosingBracketToken = negate(isClosingBracketToken); -const isNotOpeningBraceToken = negate(isOpeningBraceToken); -const isNotClosingBraceToken = negate(isClosingBraceToken); -const isNotCommentToken = negate(isCommentToken); - -/** - * Get the `(` token of the given function node. - * @param {Node} node - The function node to get. - * @param {SourceCode} sourceCode - The source code object to get tokens. - * @returns {Token} `(` token. - */ -function getOpeningParenOfParams(node, sourceCode) { - return node.id - ? sourceCode.getTokenAfter(node.id, isOpeningParenToken) - : sourceCode.getFirstToken(node, isOpeningParenToken) -} - -/** - * Get the location of the given function node for reporting. - * @param {Node} node - The function node to get. - * @param {SourceCode} sourceCode - The source code object to get tokens. - * @returns {string} The location of the function node for reporting. - */ -function getFunctionHeadLocation(node, sourceCode) { - const parent = node.parent; - let start = null; - let end = null; - - if (node.type === "ArrowFunctionExpression") { - const arrowToken = sourceCode.getTokenBefore(node.body, isArrowToken); - - start = arrowToken.loc.start; - end = arrowToken.loc.end; - } else if ( - parent.type === "Property" || - parent.type === "MethodDefinition" || - parent.type === "PropertyDefinition" - ) { - start = parent.loc.start; - end = getOpeningParenOfParams(node, sourceCode).loc.start; - } else { - start = node.loc.start; - end = getOpeningParenOfParams(node, sourceCode).loc.start; - } - - return { - start: { ...start }, - end: { ...end }, - } -} - -/* globals globalThis, global, self, window */ - -const globalObject = - typeof globalThis !== "undefined" - ? globalThis - : typeof self !== "undefined" - ? self - : typeof window !== "undefined" - ? window - : typeof global !== "undefined" - ? global - : {}; - -const builtinNames = Object.freeze( - new Set([ - "Array", - "ArrayBuffer", - "BigInt", - "BigInt64Array", - "BigUint64Array", - "Boolean", - "DataView", - "Date", - "decodeURI", - "decodeURIComponent", - "encodeURI", - "encodeURIComponent", - "escape", - "Float32Array", - "Float64Array", - "Function", - "Infinity", - "Int16Array", - "Int32Array", - "Int8Array", - "isFinite", - "isNaN", - "isPrototypeOf", - "JSON", - "Map", - "Math", - "NaN", - "Number", - "Object", - "parseFloat", - "parseInt", - "Promise", - "Proxy", - "Reflect", - "RegExp", - "Set", - "String", - "Symbol", - "Uint16Array", - "Uint32Array", - "Uint8Array", - "Uint8ClampedArray", - "undefined", - "unescape", - "WeakMap", - "WeakSet", - ]), -); -const callAllowed = new Set( - [ - Array.isArray, - Array.of, - Array.prototype.at, - Array.prototype.concat, - Array.prototype.entries, - Array.prototype.every, - Array.prototype.filter, - Array.prototype.find, - Array.prototype.findIndex, - Array.prototype.flat, - Array.prototype.includes, - Array.prototype.indexOf, - Array.prototype.join, - Array.prototype.keys, - Array.prototype.lastIndexOf, - Array.prototype.slice, - Array.prototype.some, - Array.prototype.toString, - Array.prototype.values, - typeof BigInt === "function" ? BigInt : undefined, - Boolean, - Date, - Date.parse, - decodeURI, - decodeURIComponent, - encodeURI, - encodeURIComponent, - escape, - isFinite, - isNaN, - isPrototypeOf, - Map, - Map.prototype.entries, - Map.prototype.get, - Map.prototype.has, - Map.prototype.keys, - Map.prototype.values, - ...Object.getOwnPropertyNames(Math) - .filter((k) => k !== "random") - .map((k) => Math[k]) - .filter((f) => typeof f === "function"), - Number, - Number.isFinite, - Number.isNaN, - Number.parseFloat, - Number.parseInt, - Number.prototype.toExponential, - Number.prototype.toFixed, - Number.prototype.toPrecision, - Number.prototype.toString, - Object, - Object.entries, - Object.is, - Object.isExtensible, - Object.isFrozen, - Object.isSealed, - Object.keys, - Object.values, - parseFloat, - parseInt, - RegExp, - Set, - Set.prototype.entries, - Set.prototype.has, - Set.prototype.keys, - Set.prototype.values, - String, - String.fromCharCode, - String.fromCodePoint, - String.raw, - String.prototype.at, - String.prototype.charAt, - String.prototype.charCodeAt, - String.prototype.codePointAt, - String.prototype.concat, - String.prototype.endsWith, - String.prototype.includes, - String.prototype.indexOf, - String.prototype.lastIndexOf, - String.prototype.normalize, - String.prototype.padEnd, - String.prototype.padStart, - String.prototype.slice, - String.prototype.startsWith, - String.prototype.substr, - String.prototype.substring, - String.prototype.toLowerCase, - String.prototype.toString, - String.prototype.toUpperCase, - String.prototype.trim, - String.prototype.trimEnd, - String.prototype.trimLeft, - String.prototype.trimRight, - String.prototype.trimStart, - Symbol.for, - Symbol.keyFor, - unescape, - ].filter((f) => typeof f === "function"), -); -const callPassThrough = new Set([ - Object.freeze, - Object.preventExtensions, - Object.seal, -]); - -/** @type {ReadonlyArray]>} */ -const getterAllowed = [ - [Map, new Set(["size"])], - [ - RegExp, - new Set([ - "dotAll", - "flags", - "global", - "hasIndices", - "ignoreCase", - "multiline", - "source", - "sticky", - "unicode", - ]), - ], - [Set, new Set(["size"])], -]; - -/** - * Get the property descriptor. - * @param {object} object The object to get. - * @param {string|number|symbol} name The property name to get. - */ -function getPropertyDescriptor(object, name) { - let x = object; - while ((typeof x === "object" || typeof x === "function") && x !== null) { - const d = Object.getOwnPropertyDescriptor(x, name); - if (d) { - return d - } - x = Object.getPrototypeOf(x); - } - return null -} - -/** - * Check if a property is getter or not. - * @param {object} object The object to check. - * @param {string|number|symbol} name The property name to check. - */ -function isGetter(object, name) { - const d = getPropertyDescriptor(object, name); - return d != null && d.get != null -} - -/** - * Get the element values of a given node list. - * @param {Node[]} nodeList The node list to get values. - * @param {Scope|undefined} initialScope The initial scope to find variables. - * @returns {any[]|null} The value list if all nodes are constant. Otherwise, null. - */ -function getElementValues(nodeList, initialScope) { - const valueList = []; - - for (let i = 0; i < nodeList.length; ++i) { - const elementNode = nodeList[i]; - - if (elementNode == null) { - valueList.length = i + 1; - } else if (elementNode.type === "SpreadElement") { - const argument = getStaticValueR(elementNode.argument, initialScope); - if (argument == null) { - return null - } - valueList.push(...argument.value); - } else { - const element = getStaticValueR(elementNode, initialScope); - if (element == null) { - return null - } - valueList.push(element.value); - } - } - - return valueList -} - -/** - * Returns whether the given variable is never written to after initialization. - * @param {import("eslint").Scope.Variable} variable - * @returns {boolean} - */ -function isEffectivelyConst(variable) { - const refs = variable.references; - - const inits = refs.filter((r) => r.init).length; - const reads = refs.filter((r) => r.isReadOnly()).length; - if (inits === 1 && reads + inits === refs.length) { - // there is only one init and all other references only read - return true - } - return false -} - -const operations = Object.freeze({ - ArrayExpression(node, initialScope) { - const elements = getElementValues(node.elements, initialScope); - return elements != null ? { value: elements } : null - }, - - AssignmentExpression(node, initialScope) { - if (node.operator === "=") { - return getStaticValueR(node.right, initialScope) - } - return null - }, - - //eslint-disable-next-line complexity - BinaryExpression(node, initialScope) { - if (node.operator === "in" || node.operator === "instanceof") { - // Not supported. - return null - } - - const left = getStaticValueR(node.left, initialScope); - const right = getStaticValueR(node.right, initialScope); - if (left != null && right != null) { - switch (node.operator) { - case "==": - return { value: left.value == right.value } //eslint-disable-line eqeqeq - case "!=": - return { value: left.value != right.value } //eslint-disable-line eqeqeq - case "===": - return { value: left.value === right.value } - case "!==": - return { value: left.value !== right.value } - case "<": - return { value: left.value < right.value } - case "<=": - return { value: left.value <= right.value } - case ">": - return { value: left.value > right.value } - case ">=": - return { value: left.value >= right.value } - case "<<": - return { value: left.value << right.value } - case ">>": - return { value: left.value >> right.value } - case ">>>": - return { value: left.value >>> right.value } - case "+": - return { value: left.value + right.value } - case "-": - return { value: left.value - right.value } - case "*": - return { value: left.value * right.value } - case "/": - return { value: left.value / right.value } - case "%": - return { value: left.value % right.value } - case "**": - return { value: left.value ** right.value } - case "|": - return { value: left.value | right.value } - case "^": - return { value: left.value ^ right.value } - case "&": - return { value: left.value & right.value } - - // no default - } - } - - return null - }, - - CallExpression(node, initialScope) { - const calleeNode = node.callee; - const args = getElementValues(node.arguments, initialScope); - - if (args != null) { - if (calleeNode.type === "MemberExpression") { - if (calleeNode.property.type === "PrivateIdentifier") { - return null - } - const object = getStaticValueR(calleeNode.object, initialScope); - if (object != null) { - if ( - object.value == null && - (object.optional || node.optional) - ) { - return { value: undefined, optional: true } - } - const property = getStaticPropertyNameValue( - calleeNode, - initialScope, - ); - - if (property != null) { - const receiver = object.value; - const methodName = property.value; - if (callAllowed.has(receiver[methodName])) { - return { value: receiver[methodName](...args) } - } - if (callPassThrough.has(receiver[methodName])) { - return { value: args[0] } - } - } - } - } else { - const callee = getStaticValueR(calleeNode, initialScope); - if (callee != null) { - if (callee.value == null && node.optional) { - return { value: undefined, optional: true } - } - const func = callee.value; - if (callAllowed.has(func)) { - return { value: func(...args) } - } - if (callPassThrough.has(func)) { - return { value: args[0] } - } - } - } - } - - return null - }, - - ConditionalExpression(node, initialScope) { - const test = getStaticValueR(node.test, initialScope); - if (test != null) { - return test.value - ? getStaticValueR(node.consequent, initialScope) - : getStaticValueR(node.alternate, initialScope) - } - return null - }, - - ExpressionStatement(node, initialScope) { - return getStaticValueR(node.expression, initialScope) - }, - - Identifier(node, initialScope) { - if (initialScope != null) { - const variable = findVariable(initialScope, node); - - // Built-in globals. - if ( - variable != null && - variable.defs.length === 0 && - builtinNames.has(variable.name) && - variable.name in globalObject - ) { - return { value: globalObject[variable.name] } - } - - // Constants. - if (variable != null && variable.defs.length === 1) { - const def = variable.defs[0]; - if ( - def.parent && - def.type === "Variable" && - (def.parent.kind === "const" || - isEffectivelyConst(variable)) && - // TODO(mysticatea): don't support destructuring here. - def.node.id.type === "Identifier" - ) { - return getStaticValueR(def.node.init, initialScope) - } - } - } - return null - }, - - Literal(node) { - //istanbul ignore if : this is implementation-specific behavior. - if ((node.regex != null || node.bigint != null) && node.value == null) { - // It was a RegExp/BigInt literal, but Node.js didn't support it. - return null - } - return { value: node.value } - }, - - LogicalExpression(node, initialScope) { - const left = getStaticValueR(node.left, initialScope); - if (left != null) { - if ( - (node.operator === "||" && Boolean(left.value) === true) || - (node.operator === "&&" && Boolean(left.value) === false) || - (node.operator === "??" && left.value != null) - ) { - return left - } - - const right = getStaticValueR(node.right, initialScope); - if (right != null) { - return right - } - } - - return null - }, - - MemberExpression(node, initialScope) { - if (node.property.type === "PrivateIdentifier") { - return null - } - const object = getStaticValueR(node.object, initialScope); - if (object != null) { - if (object.value == null && (object.optional || node.optional)) { - return { value: undefined, optional: true } - } - const property = getStaticPropertyNameValue(node, initialScope); - - if (property != null) { - if (!isGetter(object.value, property.value)) { - return { value: object.value[property.value] } - } - - for (const [classFn, allowed] of getterAllowed) { - if ( - object.value instanceof classFn && - allowed.has(property.value) - ) { - return { value: object.value[property.value] } - } - } - } - } - return null - }, - - ChainExpression(node, initialScope) { - const expression = getStaticValueR(node.expression, initialScope); - if (expression != null) { - return { value: expression.value } - } - return null - }, - - NewExpression(node, initialScope) { - const callee = getStaticValueR(node.callee, initialScope); - const args = getElementValues(node.arguments, initialScope); - - if (callee != null && args != null) { - const Func = callee.value; - if (callAllowed.has(Func)) { - return { value: new Func(...args) } - } - } - - return null - }, - - ObjectExpression(node, initialScope) { - const object = {}; - - for (const propertyNode of node.properties) { - if (propertyNode.type === "Property") { - if (propertyNode.kind !== "init") { - return null - } - const key = getStaticPropertyNameValue( - propertyNode, - initialScope, - ); - const value = getStaticValueR(propertyNode.value, initialScope); - if (key == null || value == null) { - return null - } - object[key.value] = value.value; - } else if ( - propertyNode.type === "SpreadElement" || - propertyNode.type === "ExperimentalSpreadProperty" - ) { - const argument = getStaticValueR( - propertyNode.argument, - initialScope, - ); - if (argument == null) { - return null - } - Object.assign(object, argument.value); - } else { - return null - } - } - - return { value: object } - }, - - SequenceExpression(node, initialScope) { - const last = node.expressions[node.expressions.length - 1]; - return getStaticValueR(last, initialScope) - }, - - TaggedTemplateExpression(node, initialScope) { - const tag = getStaticValueR(node.tag, initialScope); - const expressions = getElementValues( - node.quasi.expressions, - initialScope, - ); - - if (tag != null && expressions != null) { - const func = tag.value; - const strings = node.quasi.quasis.map((q) => q.value.cooked); - strings.raw = node.quasi.quasis.map((q) => q.value.raw); - - if (func === String.raw) { - return { value: func(strings, ...expressions) } - } - } - - return null - }, - - TemplateLiteral(node, initialScope) { - const expressions = getElementValues(node.expressions, initialScope); - if (expressions != null) { - let value = node.quasis[0].value.cooked; - for (let i = 0; i < expressions.length; ++i) { - value += expressions[i]; - value += node.quasis[i + 1].value.cooked; - } - return { value } - } - return null - }, - - UnaryExpression(node, initialScope) { - if (node.operator === "delete") { - // Not supported. - return null - } - if (node.operator === "void") { - return { value: undefined } - } - - const arg = getStaticValueR(node.argument, initialScope); - if (arg != null) { - switch (node.operator) { - case "-": - return { value: -arg.value } - case "+": - return { value: +arg.value } //eslint-disable-line no-implicit-coercion - case "!": - return { value: !arg.value } - case "~": - return { value: ~arg.value } - case "typeof": - return { value: typeof arg.value } - - // no default - } - } - - return null - }, -}); - -/** - * Get the value of a given node if it's a static value. - * @param {Node} node The node to get. - * @param {Scope|undefined} initialScope The scope to start finding variable. - * @returns {{value:any}|{value:undefined,optional?:true}|null} The static value of the node, or `null`. - */ -function getStaticValueR(node, initialScope) { - if (node != null && Object.hasOwnProperty.call(operations, node.type)) { - return operations[node.type](node, initialScope) - } - return null -} - -/** - * Get the static value of property name from a MemberExpression node or a Property node. - * @param {Node} node The node to get. - * @param {Scope} [initialScope] The scope to start finding variable. Optional. If the node is a computed property node and this scope was given, this checks the computed property name by the `getStringIfConstant` function with the scope, and returns the value of it. - * @returns {{value:any}|{value:undefined,optional?:true}|null} The static value of the property name of the node, or `null`. - */ -function getStaticPropertyNameValue(node, initialScope) { - const nameNode = node.type === "Property" ? node.key : node.property; - - if (node.computed) { - return getStaticValueR(nameNode, initialScope) - } - - if (nameNode.type === "Identifier") { - return { value: nameNode.name } - } - - if (nameNode.type === "Literal") { - if (nameNode.bigint) { - return { value: nameNode.bigint } - } - return { value: String(nameNode.value) } - } - - return null -} - -/** - * Get the value of a given node if it's a static value. - * @param {Node} node The node to get. - * @param {Scope} [initialScope] The scope to start finding variable. Optional. If this scope was given, this tries to resolve identifier references which are in the given node as much as possible. - * @returns {{value:any}|{value:undefined,optional?:true}|null} The static value of the node, or `null`. - */ -function getStaticValue(node, initialScope = null) { - try { - return getStaticValueR(node, initialScope) - } catch (_error) { - return null - } -} - -/** - * Get the value of a given node if it's a literal or a template literal. - * @param {Node} node The node to get. - * @param {Scope} [initialScope] The scope to start finding variable. Optional. If the node is an Identifier node and this scope was given, this checks the variable of the identifier, and returns the value of it if the variable is a constant. - * @returns {string|null} The value of the node, or `null`. - */ -function getStringIfConstant(node, initialScope = null) { - // Handle the literals that the platform doesn't support natively. - if (node && node.type === "Literal" && node.value === null) { - if (node.regex) { - return `/${node.regex.pattern}/${node.regex.flags}` - } - if (node.bigint) { - return node.bigint - } - } - - const evaluated = getStaticValue(node, initialScope); - return evaluated && String(evaluated.value) -} - -/** - * Get the property name from a MemberExpression node or a Property node. - * @param {Node} node The node to get. - * @param {Scope} [initialScope] The scope to start finding variable. Optional. If the node is a computed property node and this scope was given, this checks the computed property name by the `getStringIfConstant` function with the scope, and returns the value of it. - * @returns {string|null} The property name of the node. - */ -function getPropertyName(node, initialScope) { - switch (node.type) { - case "MemberExpression": - if (node.computed) { - return getStringIfConstant(node.property, initialScope) - } - if (node.property.type === "PrivateIdentifier") { - return null - } - return node.property.name - - case "Property": - case "MethodDefinition": - case "PropertyDefinition": - if (node.computed) { - return getStringIfConstant(node.key, initialScope) - } - if (node.key.type === "Literal") { - return String(node.key.value) - } - if (node.key.type === "PrivateIdentifier") { - return null - } - return node.key.name - - // no default - } - - return null -} - -/** - * Get the name and kind of the given function node. - * @param {ASTNode} node - The function node to get. - * @param {SourceCode} [sourceCode] The source code object to get the code of computed property keys. - * @returns {string} The name and kind of the function node. - */ -// eslint-disable-next-line complexity -function getFunctionNameWithKind(node, sourceCode) { - const parent = node.parent; - const tokens = []; - const isObjectMethod = parent.type === "Property" && parent.value === node; - const isClassMethod = - parent.type === "MethodDefinition" && parent.value === node; - const isClassFieldMethod = - parent.type === "PropertyDefinition" && parent.value === node; - - // Modifiers. - if (isClassMethod || isClassFieldMethod) { - if (parent.static) { - tokens.push("static"); - } - if (parent.key.type === "PrivateIdentifier") { - tokens.push("private"); - } - } - if (node.async) { - tokens.push("async"); - } - if (node.generator) { - tokens.push("generator"); - } - - // Kinds. - if (isObjectMethod || isClassMethod) { - if (parent.kind === "constructor") { - return "constructor" - } - if (parent.kind === "get") { - tokens.push("getter"); - } else if (parent.kind === "set") { - tokens.push("setter"); - } else { - tokens.push("method"); - } - } else if (isClassFieldMethod) { - tokens.push("method"); - } else { - if (node.type === "ArrowFunctionExpression") { - tokens.push("arrow"); - } - tokens.push("function"); - } - - // Names. - if (isObjectMethod || isClassMethod || isClassFieldMethod) { - if (parent.key.type === "PrivateIdentifier") { - tokens.push(`#${parent.key.name}`); - } else { - const name = getPropertyName(parent); - if (name) { - tokens.push(`'${name}'`); - } else if (sourceCode) { - const keyText = sourceCode.getText(parent.key); - if (!keyText.includes("\n")) { - tokens.push(`[${keyText}]`); - } - } - } - } else if (node.id) { - tokens.push(`'${node.id.name}'`); - } else if ( - parent.type === "VariableDeclarator" && - parent.id && - parent.id.type === "Identifier" - ) { - tokens.push(`'${parent.id.name}'`); - } else if ( - (parent.type === "AssignmentExpression" || - parent.type === "AssignmentPattern") && - parent.left && - parent.left.type === "Identifier" - ) { - tokens.push(`'${parent.left.name}'`); - } else if ( - parent.type === "ExportDefaultDeclaration" && - parent.declaration === node - ) { - tokens.push("'default'"); - } - - return tokens.join(" ") -} - -const typeConversionBinaryOps = Object.freeze( - new Set([ - "==", - "!=", - "<", - "<=", - ">", - ">=", - "<<", - ">>", - ">>>", - "+", - "-", - "*", - "/", - "%", - "|", - "^", - "&", - "in", - ]), -); -const typeConversionUnaryOps = Object.freeze(new Set(["-", "+", "!", "~"])); - -/** - * Check whether the given value is an ASTNode or not. - * @param {any} x The value to check. - * @returns {boolean} `true` if the value is an ASTNode. - */ -function isNode(x) { - return x !== null && typeof x === "object" && typeof x.type === "string" -} - -const visitor = Object.freeze( - Object.assign(Object.create(null), { - $visit(node, options, visitorKeys) { - const { type } = node; - - if (typeof this[type] === "function") { - return this[type](node, options, visitorKeys) - } - - return this.$visitChildren(node, options, visitorKeys) - }, - - $visitChildren(node, options, visitorKeys) { - const { type } = node; - - for (const key of visitorKeys[type] || eslintVisitorKeys.getKeys(node)) { - const value = node[key]; - - if (Array.isArray(value)) { - for (const element of value) { - if ( - isNode(element) && - this.$visit(element, options, visitorKeys) - ) { - return true - } - } - } else if ( - isNode(value) && - this.$visit(value, options, visitorKeys) - ) { - return true - } - } - - return false - }, - - ArrowFunctionExpression() { - return false - }, - AssignmentExpression() { - return true - }, - AwaitExpression() { - return true - }, - BinaryExpression(node, options, visitorKeys) { - if ( - options.considerImplicitTypeConversion && - typeConversionBinaryOps.has(node.operator) && - (node.left.type !== "Literal" || node.right.type !== "Literal") - ) { - return true - } - return this.$visitChildren(node, options, visitorKeys) - }, - CallExpression() { - return true - }, - FunctionExpression() { - return false - }, - ImportExpression() { - return true - }, - MemberExpression(node, options, visitorKeys) { - if (options.considerGetters) { - return true - } - if ( - options.considerImplicitTypeConversion && - node.computed && - node.property.type !== "Literal" - ) { - return true - } - return this.$visitChildren(node, options, visitorKeys) - }, - MethodDefinition(node, options, visitorKeys) { - if ( - options.considerImplicitTypeConversion && - node.computed && - node.key.type !== "Literal" - ) { - return true - } - return this.$visitChildren(node, options, visitorKeys) - }, - NewExpression() { - return true - }, - Property(node, options, visitorKeys) { - if ( - options.considerImplicitTypeConversion && - node.computed && - node.key.type !== "Literal" - ) { - return true - } - return this.$visitChildren(node, options, visitorKeys) - }, - PropertyDefinition(node, options, visitorKeys) { - if ( - options.considerImplicitTypeConversion && - node.computed && - node.key.type !== "Literal" - ) { - return true - } - return this.$visitChildren(node, options, visitorKeys) - }, - UnaryExpression(node, options, visitorKeys) { - if (node.operator === "delete") { - return true - } - if ( - options.considerImplicitTypeConversion && - typeConversionUnaryOps.has(node.operator) && - node.argument.type !== "Literal" - ) { - return true - } - return this.$visitChildren(node, options, visitorKeys) - }, - UpdateExpression() { - return true - }, - YieldExpression() { - return true - }, - }), -); - -/** - * Check whether a given node has any side effect or not. - * @param {Node} node The node to get. - * @param {SourceCode} sourceCode The source code object. - * @param {object} [options] The option object. - * @param {boolean} [options.considerGetters=false] If `true` then it considers member accesses as the node which has side effects. - * @param {boolean} [options.considerImplicitTypeConversion=false] If `true` then it considers implicit type conversion as the node which has side effects. - * @param {object} [options.visitorKeys=KEYS] The keys to traverse nodes. Use `context.getSourceCode().visitorKeys`. - * @returns {boolean} `true` if the node has a certain side effect. - */ -function hasSideEffect( - node, - sourceCode, - { considerGetters = false, considerImplicitTypeConversion = false } = {}, -) { - return visitor.$visit( - node, - { considerGetters, considerImplicitTypeConversion }, - sourceCode.visitorKeys || eslintVisitorKeys.KEYS, - ) -} - -/** - * Get the left parenthesis of the parent node syntax if it exists. - * E.g., `if (a) {}` then the `(`. - * @param {Node} node The AST node to check. - * @param {SourceCode} sourceCode The source code object to get tokens. - * @returns {Token|null} The left parenthesis of the parent node syntax - */ -function getParentSyntaxParen(node, sourceCode) { - const parent = node.parent; - - switch (parent.type) { - case "CallExpression": - case "NewExpression": - if (parent.arguments.length === 1 && parent.arguments[0] === node) { - return sourceCode.getTokenAfter( - parent.callee, - isOpeningParenToken, - ) - } - return null - - case "DoWhileStatement": - if (parent.test === node) { - return sourceCode.getTokenAfter( - parent.body, - isOpeningParenToken, - ) - } - return null - - case "IfStatement": - case "WhileStatement": - if (parent.test === node) { - return sourceCode.getFirstToken(parent, 1) - } - return null - - case "ImportExpression": - if (parent.source === node) { - return sourceCode.getFirstToken(parent, 1) - } - return null - - case "SwitchStatement": - if (parent.discriminant === node) { - return sourceCode.getFirstToken(parent, 1) - } - return null - - case "WithStatement": - if (parent.object === node) { - return sourceCode.getFirstToken(parent, 1) - } - return null - - default: - return null - } -} - -/** - * Check whether a given node is parenthesized or not. - * @param {number} times The number of parantheses. - * @param {Node} node The AST node to check. - * @param {SourceCode} sourceCode The source code object to get tokens. - * @returns {boolean} `true` if the node is parenthesized the given times. - */ -/** - * Check whether a given node is parenthesized or not. - * @param {Node} node The AST node to check. - * @param {SourceCode} sourceCode The source code object to get tokens. - * @returns {boolean} `true` if the node is parenthesized. - */ -function isParenthesized( - timesOrNode, - nodeOrSourceCode, - optionalSourceCode, -) { - let times, node, sourceCode, maybeLeftParen, maybeRightParen; - if (typeof timesOrNode === "number") { - times = timesOrNode | 0; - node = nodeOrSourceCode; - sourceCode = optionalSourceCode; - if (!(times >= 1)) { - throw new TypeError("'times' should be a positive integer.") - } - } else { - times = 1; - node = timesOrNode; - sourceCode = nodeOrSourceCode; - } - - if ( - node == null || - // `Program` can't be parenthesized - node.parent == null || - // `CatchClause.param` can't be parenthesized, example `try {} catch (error) {}` - (node.parent.type === "CatchClause" && node.parent.param === node) - ) { - return false - } - - maybeLeftParen = maybeRightParen = node; - do { - maybeLeftParen = sourceCode.getTokenBefore(maybeLeftParen); - maybeRightParen = sourceCode.getTokenAfter(maybeRightParen); - } while ( - maybeLeftParen != null && - maybeRightParen != null && - isOpeningParenToken(maybeLeftParen) && - isClosingParenToken(maybeRightParen) && - // Avoid false positive such as `if (a) {}` - maybeLeftParen !== getParentSyntaxParen(node, sourceCode) && - --times > 0 - ) - - return times === 0 -} - -/** - * @author Toru Nagashima - * See LICENSE file in root directory for full license. - */ - -const placeholder = /\$(?:[$&`']|[1-9][0-9]?)/gu; - -/** @type {WeakMap} */ -const internal = new WeakMap(); - -/** - * Check whether a given character is escaped or not. - * @param {string} str The string to check. - * @param {number} index The location of the character to check. - * @returns {boolean} `true` if the character is escaped. - */ -function isEscaped(str, index) { - let escaped = false; - for (let i = index - 1; i >= 0 && str.charCodeAt(i) === 0x5c; --i) { - escaped = !escaped; - } - return escaped -} - -/** - * Replace a given string by a given matcher. - * @param {PatternMatcher} matcher The pattern matcher. - * @param {string} str The string to be replaced. - * @param {string} replacement The new substring to replace each matched part. - * @returns {string} The replaced string. - */ -function replaceS(matcher, str, replacement) { - const chunks = []; - let index = 0; - - /** @type {RegExpExecArray} */ - let match = null; - - /** - * @param {string} key The placeholder. - * @returns {string} The replaced string. - */ - function replacer(key) { - switch (key) { - case "$$": - return "$" - case "$&": - return match[0] - case "$`": - return str.slice(0, match.index) - case "$'": - return str.slice(match.index + match[0].length) - default: { - const i = key.slice(1); - if (i in match) { - return match[i] - } - return key - } - } - } - - for (match of matcher.execAll(str)) { - chunks.push(str.slice(index, match.index)); - chunks.push(replacement.replace(placeholder, replacer)); - index = match.index + match[0].length; - } - chunks.push(str.slice(index)); - - return chunks.join("") -} - -/** - * Replace a given string by a given matcher. - * @param {PatternMatcher} matcher The pattern matcher. - * @param {string} str The string to be replaced. - * @param {(...strs[])=>string} replace The function to replace each matched part. - * @returns {string} The replaced string. - */ -function replaceF(matcher, str, replace) { - const chunks = []; - let index = 0; - - for (const match of matcher.execAll(str)) { - chunks.push(str.slice(index, match.index)); - chunks.push(String(replace(...match, match.index, match.input))); - index = match.index + match[0].length; - } - chunks.push(str.slice(index)); - - return chunks.join("") -} - -/** - * The class to find patterns as considering escape sequences. - */ -class PatternMatcher { - /** - * Initialize this matcher. - * @param {RegExp} pattern The pattern to match. - * @param {{escaped:boolean}} options The options. - */ - constructor(pattern, { escaped = false } = {}) { - if (!(pattern instanceof RegExp)) { - throw new TypeError("'pattern' should be a RegExp instance.") - } - if (!pattern.flags.includes("g")) { - throw new Error("'pattern' should contains 'g' flag.") - } - - internal.set(this, { - pattern: new RegExp(pattern.source, pattern.flags), - escaped: Boolean(escaped), - }); - } - - /** - * Find the pattern in a given string. - * @param {string} str The string to find. - * @returns {IterableIterator} The iterator which iterate the matched information. - */ - *execAll(str) { - const { pattern, escaped } = internal.get(this); - let match = null; - let lastIndex = 0; - - pattern.lastIndex = 0; - while ((match = pattern.exec(str)) != null) { - if (escaped || !isEscaped(str, match.index)) { - lastIndex = pattern.lastIndex; - yield match; - pattern.lastIndex = lastIndex; - } - } - } - - /** - * Check whether the pattern is found in a given string. - * @param {string} str The string to check. - * @returns {boolean} `true` if the pattern was found in the string. - */ - test(str) { - const it = this.execAll(str); - const ret = it.next(); - return !ret.done - } - - /** - * Replace a given string. - * @param {string} str The string to be replaced. - * @param {(string|((...strs:string[])=>string))} replacer The string or function to replace. This is the same as the 2nd argument of `String.prototype.replace`. - * @returns {string} The replaced string. - */ - [Symbol.replace](str, replacer) { - return typeof replacer === "function" - ? replaceF(this, String(str), replacer) - : replaceS(this, String(str), String(replacer)) - } -} - -const IMPORT_TYPE = /^(?:Import|Export(?:All|Default|Named))Declaration$/u; -const has = Function.call.bind(Object.hasOwnProperty); - -const READ = Symbol("read"); -const CALL = Symbol("call"); -const CONSTRUCT = Symbol("construct"); -const ESM = Symbol("esm"); - -const requireCall = { require: { [CALL]: true } }; - -/** - * Check whether a given variable is modified or not. - * @param {Variable} variable The variable to check. - * @returns {boolean} `true` if the variable is modified. - */ -function isModifiedGlobal(variable) { - return ( - variable == null || - variable.defs.length !== 0 || - variable.references.some((r) => r.isWrite()) - ) -} - -/** - * Check if the value of a given node is passed through to the parent syntax as-is. - * For example, `a` and `b` in (`a || b` and `c ? a : b`) are passed through. - * @param {Node} node A node to check. - * @returns {boolean} `true` if the node is passed through. - */ -function isPassThrough(node) { - const parent = node.parent; - - switch (parent && parent.type) { - case "ConditionalExpression": - return parent.consequent === node || parent.alternate === node - case "LogicalExpression": - return true - case "SequenceExpression": - return parent.expressions[parent.expressions.length - 1] === node - case "ChainExpression": - return true - - default: - return false - } -} - -/** - * The reference tracker. - */ -class ReferenceTracker { - /** - * Initialize this tracker. - * @param {Scope} globalScope The global scope. - * @param {object} [options] The options. - * @param {"legacy"|"strict"} [options.mode="strict"] The mode to determine the ImportDeclaration's behavior for CJS modules. - * @param {string[]} [options.globalObjectNames=["global","globalThis","self","window"]] The variable names for Global Object. - */ - constructor( - globalScope, - { - mode = "strict", - globalObjectNames = ["global", "globalThis", "self", "window"], - } = {}, - ) { - this.variableStack = []; - this.globalScope = globalScope; - this.mode = mode; - this.globalObjectNames = globalObjectNames.slice(0); - } - - /** - * Iterate the references of global variables. - * @param {object} traceMap The trace map. - * @returns {IterableIterator<{node:Node,path:string[],type:symbol,info:any}>} The iterator to iterate references. - */ - *iterateGlobalReferences(traceMap) { - for (const key of Object.keys(traceMap)) { - const nextTraceMap = traceMap[key]; - const path = [key]; - const variable = this.globalScope.set.get(key); - - if (isModifiedGlobal(variable)) { - continue - } - - yield* this._iterateVariableReferences( - variable, - path, - nextTraceMap, - true, - ); - } - - for (const key of this.globalObjectNames) { - const path = []; - const variable = this.globalScope.set.get(key); - - if (isModifiedGlobal(variable)) { - continue - } - - yield* this._iterateVariableReferences( - variable, - path, - traceMap, - false, - ); - } - } - - /** - * Iterate the references of CommonJS modules. - * @param {object} traceMap The trace map. - * @returns {IterableIterator<{node:Node,path:string[],type:symbol,info:any}>} The iterator to iterate references. - */ - *iterateCjsReferences(traceMap) { - for (const { node } of this.iterateGlobalReferences(requireCall)) { - const key = getStringIfConstant(node.arguments[0]); - if (key == null || !has(traceMap, key)) { - continue - } - - const nextTraceMap = traceMap[key]; - const path = [key]; - - if (nextTraceMap[READ]) { - yield { - node, - path, - type: READ, - info: nextTraceMap[READ], - }; - } - yield* this._iteratePropertyReferences(node, path, nextTraceMap); - } - } - - /** - * Iterate the references of ES modules. - * @param {object} traceMap The trace map. - * @returns {IterableIterator<{node:Node,path:string[],type:symbol,info:any}>} The iterator to iterate references. - */ - *iterateEsmReferences(traceMap) { - const programNode = this.globalScope.block; - - for (const node of programNode.body) { - if (!IMPORT_TYPE.test(node.type) || node.source == null) { - continue - } - const moduleId = node.source.value; - - if (!has(traceMap, moduleId)) { - continue - } - const nextTraceMap = traceMap[moduleId]; - const path = [moduleId]; - - if (nextTraceMap[READ]) { - yield { node, path, type: READ, info: nextTraceMap[READ] }; - } - - if (node.type === "ExportAllDeclaration") { - for (const key of Object.keys(nextTraceMap)) { - const exportTraceMap = nextTraceMap[key]; - if (exportTraceMap[READ]) { - yield { - node, - path: path.concat(key), - type: READ, - info: exportTraceMap[READ], - }; - } - } - } else { - for (const specifier of node.specifiers) { - const esm = has(nextTraceMap, ESM); - const it = this._iterateImportReferences( - specifier, - path, - esm - ? nextTraceMap - : this.mode === "legacy" - ? { default: nextTraceMap, ...nextTraceMap } - : { default: nextTraceMap }, - ); - - if (esm) { - yield* it; - } else { - for (const report of it) { - report.path = report.path.filter(exceptDefault); - if ( - report.path.length >= 2 || - report.type !== READ - ) { - yield report; - } - } - } - } - } - } - } - - /** - * Iterate the references for a given variable. - * @param {Variable} variable The variable to iterate that references. - * @param {string[]} path The current path. - * @param {object} traceMap The trace map. - * @param {boolean} shouldReport = The flag to report those references. - * @returns {IterableIterator<{node:Node,path:string[],type:symbol,info:any}>} The iterator to iterate references. - */ - *_iterateVariableReferences(variable, path, traceMap, shouldReport) { - if (this.variableStack.includes(variable)) { - return - } - this.variableStack.push(variable); - try { - for (const reference of variable.references) { - if (!reference.isRead()) { - continue - } - const node = reference.identifier; - - if (shouldReport && traceMap[READ]) { - yield { node, path, type: READ, info: traceMap[READ] }; - } - yield* this._iteratePropertyReferences(node, path, traceMap); - } - } finally { - this.variableStack.pop(); - } - } - - /** - * Iterate the references for a given AST node. - * @param rootNode The AST node to iterate references. - * @param {string[]} path The current path. - * @param {object} traceMap The trace map. - * @returns {IterableIterator<{node:Node,path:string[],type:symbol,info:any}>} The iterator to iterate references. - */ - //eslint-disable-next-line complexity - *_iteratePropertyReferences(rootNode, path, traceMap) { - let node = rootNode; - while (isPassThrough(node)) { - node = node.parent; - } - - const parent = node.parent; - if (parent.type === "MemberExpression") { - if (parent.object === node) { - const key = getPropertyName(parent); - if (key == null || !has(traceMap, key)) { - return - } - - path = path.concat(key); //eslint-disable-line no-param-reassign - const nextTraceMap = traceMap[key]; - if (nextTraceMap[READ]) { - yield { - node: parent, - path, - type: READ, - info: nextTraceMap[READ], - }; - } - yield* this._iteratePropertyReferences( - parent, - path, - nextTraceMap, - ); - } - return - } - if (parent.type === "CallExpression") { - if (parent.callee === node && traceMap[CALL]) { - yield { node: parent, path, type: CALL, info: traceMap[CALL] }; - } - return - } - if (parent.type === "NewExpression") { - if (parent.callee === node && traceMap[CONSTRUCT]) { - yield { - node: parent, - path, - type: CONSTRUCT, - info: traceMap[CONSTRUCT], - }; - } - return - } - if (parent.type === "AssignmentExpression") { - if (parent.right === node) { - yield* this._iterateLhsReferences(parent.left, path, traceMap); - yield* this._iteratePropertyReferences(parent, path, traceMap); - } - return - } - if (parent.type === "AssignmentPattern") { - if (parent.right === node) { - yield* this._iterateLhsReferences(parent.left, path, traceMap); - } - return - } - if (parent.type === "VariableDeclarator") { - if (parent.init === node) { - yield* this._iterateLhsReferences(parent.id, path, traceMap); - } - } - } - - /** - * Iterate the references for a given Pattern node. - * @param {Node} patternNode The Pattern node to iterate references. - * @param {string[]} path The current path. - * @param {object} traceMap The trace map. - * @returns {IterableIterator<{node:Node,path:string[],type:symbol,info:any}>} The iterator to iterate references. - */ - *_iterateLhsReferences(patternNode, path, traceMap) { - if (patternNode.type === "Identifier") { - const variable = findVariable(this.globalScope, patternNode); - if (variable != null) { - yield* this._iterateVariableReferences( - variable, - path, - traceMap, - false, - ); - } - return - } - if (patternNode.type === "ObjectPattern") { - for (const property of patternNode.properties) { - const key = getPropertyName(property); - - if (key == null || !has(traceMap, key)) { - continue - } - - const nextPath = path.concat(key); - const nextTraceMap = traceMap[key]; - if (nextTraceMap[READ]) { - yield { - node: property, - path: nextPath, - type: READ, - info: nextTraceMap[READ], - }; - } - yield* this._iterateLhsReferences( - property.value, - nextPath, - nextTraceMap, - ); - } - return - } - if (patternNode.type === "AssignmentPattern") { - yield* this._iterateLhsReferences(patternNode.left, path, traceMap); - } - } - - /** - * Iterate the references for a given ModuleSpecifier node. - * @param {Node} specifierNode The ModuleSpecifier node to iterate references. - * @param {string[]} path The current path. - * @param {object} traceMap The trace map. - * @returns {IterableIterator<{node:Node,path:string[],type:symbol,info:any}>} The iterator to iterate references. - */ - *_iterateImportReferences(specifierNode, path, traceMap) { - const type = specifierNode.type; - - if (type === "ImportSpecifier" || type === "ImportDefaultSpecifier") { - const key = - type === "ImportDefaultSpecifier" - ? "default" - : specifierNode.imported.name; - if (!has(traceMap, key)) { - return - } - - path = path.concat(key); //eslint-disable-line no-param-reassign - const nextTraceMap = traceMap[key]; - if (nextTraceMap[READ]) { - yield { - node: specifierNode, - path, - type: READ, - info: nextTraceMap[READ], - }; - } - yield* this._iterateVariableReferences( - findVariable(this.globalScope, specifierNode.local), - path, - nextTraceMap, - false, - ); - - return - } - - if (type === "ImportNamespaceSpecifier") { - yield* this._iterateVariableReferences( - findVariable(this.globalScope, specifierNode.local), - path, - traceMap, - false, - ); - return - } - - if (type === "ExportSpecifier") { - const key = specifierNode.local.name; - if (!has(traceMap, key)) { - return - } - - path = path.concat(key); //eslint-disable-line no-param-reassign - const nextTraceMap = traceMap[key]; - if (nextTraceMap[READ]) { - yield { - node: specifierNode, - path, - type: READ, - info: nextTraceMap[READ], - }; - } - } - } -} - -ReferenceTracker.READ = READ; -ReferenceTracker.CALL = CALL; -ReferenceTracker.CONSTRUCT = CONSTRUCT; -ReferenceTracker.ESM = ESM; - -/** - * This is a predicate function for Array#filter. - * @param {string} name A name part. - * @param {number} index The index of the name. - * @returns {boolean} `false` if it's default. - */ -function exceptDefault(name, index) { - return !(index === 1 && name === "default") -} - -var index = { - CALL, - CONSTRUCT, - ESM, - findVariable, - getFunctionHeadLocation, - getFunctionNameWithKind, - getInnermostScope, - getPropertyName, - getStaticValue, - getStringIfConstant, - hasSideEffect, - isArrowToken, - isClosingBraceToken, - isClosingBracketToken, - isClosingParenToken, - isColonToken, - isCommaToken, - isCommentToken, - isNotArrowToken, - isNotClosingBraceToken, - isNotClosingBracketToken, - isNotClosingParenToken, - isNotColonToken, - isNotCommaToken, - isNotCommentToken, - isNotOpeningBraceToken, - isNotOpeningBracketToken, - isNotOpeningParenToken, - isNotSemicolonToken, - isOpeningBraceToken, - isOpeningBracketToken, - isOpeningParenToken, - isParenthesized, - isSemicolonToken, - PatternMatcher, - READ, - ReferenceTracker, -}; - -exports.CALL = CALL; -exports.CONSTRUCT = CONSTRUCT; -exports.ESM = ESM; -exports.PatternMatcher = PatternMatcher; -exports.READ = READ; -exports.ReferenceTracker = ReferenceTracker; -exports["default"] = index; -exports.findVariable = findVariable; -exports.getFunctionHeadLocation = getFunctionHeadLocation; -exports.getFunctionNameWithKind = getFunctionNameWithKind; -exports.getInnermostScope = getInnermostScope; -exports.getPropertyName = getPropertyName; -exports.getStaticValue = getStaticValue; -exports.getStringIfConstant = getStringIfConstant; -exports.hasSideEffect = hasSideEffect; -exports.isArrowToken = isArrowToken; -exports.isClosingBraceToken = isClosingBraceToken; -exports.isClosingBracketToken = isClosingBracketToken; -exports.isClosingParenToken = isClosingParenToken; -exports.isColonToken = isColonToken; -exports.isCommaToken = isCommaToken; -exports.isCommentToken = isCommentToken; -exports.isNotArrowToken = isNotArrowToken; -exports.isNotClosingBraceToken = isNotClosingBraceToken; -exports.isNotClosingBracketToken = isNotClosingBracketToken; -exports.isNotClosingParenToken = isNotClosingParenToken; -exports.isNotColonToken = isNotColonToken; -exports.isNotCommaToken = isNotCommaToken; -exports.isNotCommentToken = isNotCommentToken; -exports.isNotOpeningBraceToken = isNotOpeningBraceToken; -exports.isNotOpeningBracketToken = isNotOpeningBracketToken; -exports.isNotOpeningParenToken = isNotOpeningParenToken; -exports.isNotSemicolonToken = isNotSemicolonToken; -exports.isOpeningBraceToken = isOpeningBraceToken; -exports.isOpeningBracketToken = isOpeningBracketToken; -exports.isOpeningParenToken = isOpeningParenToken; -exports.isParenthesized = isParenthesized; -exports.isSemicolonToken = isSemicolonToken; -//# sourceMappingURL=index.js.map diff --git a/tools/eslint/node_modules/@eslint-community/eslint-utils/index.mjs b/tools/eslint/node_modules/@eslint-community/eslint-utils/index.mjs deleted file mode 100644 index 54b25816bf936f..00000000000000 --- a/tools/eslint/node_modules/@eslint-community/eslint-utils/index.mjs +++ /dev/null @@ -1,2027 +0,0 @@ -import { getKeys, KEYS } from 'eslint-visitor-keys'; - -/** - * Get the innermost scope which contains a given location. - * @param {Scope} initialScope The initial scope to search. - * @param {Node} node The location to search. - * @returns {Scope} The innermost scope. - */ -function getInnermostScope(initialScope, node) { - const location = node.range[0]; - - let scope = initialScope; - let found = false; - do { - found = false; - for (const childScope of scope.childScopes) { - const range = childScope.block.range; - - if (range[0] <= location && location < range[1]) { - scope = childScope; - found = true; - break - } - } - } while (found) - - return scope -} - -/** - * Find the variable of a given name. - * @param {Scope} initialScope The scope to start finding. - * @param {string|Node} nameOrNode The variable name to find. If this is a Node object then it should be an Identifier node. - * @returns {Variable|null} The found variable or null. - */ -function findVariable(initialScope, nameOrNode) { - let name = ""; - let scope = initialScope; - - if (typeof nameOrNode === "string") { - name = nameOrNode; - } else { - name = nameOrNode.name; - scope = getInnermostScope(scope, nameOrNode); - } - - while (scope != null) { - const variable = scope.set.get(name); - if (variable != null) { - return variable - } - scope = scope.upper; - } - - return null -} - -/** - * Negate the result of `this` calling. - * @param {Token} token The token to check. - * @returns {boolean} `true` if the result of `this(token)` is `false`. - */ -function negate0(token) { - return !this(token) //eslint-disable-line no-invalid-this -} - -/** - * Creates the negate function of the given function. - * @param {function(Token):boolean} f - The function to negate. - * @returns {function(Token):boolean} Negated function. - */ -function negate(f) { - return negate0.bind(f) -} - -/** - * Checks if the given token is a PunctuatorToken with the given value - * @param {Token} token - The token to check. - * @param {string} value - The value to check. - * @returns {boolean} `true` if the token is a PunctuatorToken with the given value. - */ -function isPunctuatorTokenWithValue(token, value) { - return token.type === "Punctuator" && token.value === value -} - -/** - * Checks if the given token is an arrow token or not. - * @param {Token} token - The token to check. - * @returns {boolean} `true` if the token is an arrow token. - */ -function isArrowToken(token) { - return isPunctuatorTokenWithValue(token, "=>") -} - -/** - * Checks if the given token is a comma token or not. - * @param {Token} token - The token to check. - * @returns {boolean} `true` if the token is a comma token. - */ -function isCommaToken(token) { - return isPunctuatorTokenWithValue(token, ",") -} - -/** - * Checks if the given token is a semicolon token or not. - * @param {Token} token - The token to check. - * @returns {boolean} `true` if the token is a semicolon token. - */ -function isSemicolonToken(token) { - return isPunctuatorTokenWithValue(token, ";") -} - -/** - * Checks if the given token is a colon token or not. - * @param {Token} token - The token to check. - * @returns {boolean} `true` if the token is a colon token. - */ -function isColonToken(token) { - return isPunctuatorTokenWithValue(token, ":") -} - -/** - * Checks if the given token is an opening parenthesis token or not. - * @param {Token} token - The token to check. - * @returns {boolean} `true` if the token is an opening parenthesis token. - */ -function isOpeningParenToken(token) { - return isPunctuatorTokenWithValue(token, "(") -} - -/** - * Checks if the given token is a closing parenthesis token or not. - * @param {Token} token - The token to check. - * @returns {boolean} `true` if the token is a closing parenthesis token. - */ -function isClosingParenToken(token) { - return isPunctuatorTokenWithValue(token, ")") -} - -/** - * Checks if the given token is an opening square bracket token or not. - * @param {Token} token - The token to check. - * @returns {boolean} `true` if the token is an opening square bracket token. - */ -function isOpeningBracketToken(token) { - return isPunctuatorTokenWithValue(token, "[") -} - -/** - * Checks if the given token is a closing square bracket token or not. - * @param {Token} token - The token to check. - * @returns {boolean} `true` if the token is a closing square bracket token. - */ -function isClosingBracketToken(token) { - return isPunctuatorTokenWithValue(token, "]") -} - -/** - * Checks if the given token is an opening brace token or not. - * @param {Token} token - The token to check. - * @returns {boolean} `true` if the token is an opening brace token. - */ -function isOpeningBraceToken(token) { - return isPunctuatorTokenWithValue(token, "{") -} - -/** - * Checks if the given token is a closing brace token or not. - * @param {Token} token - The token to check. - * @returns {boolean} `true` if the token is a closing brace token. - */ -function isClosingBraceToken(token) { - return isPunctuatorTokenWithValue(token, "}") -} - -/** - * Checks if the given token is a comment token or not. - * @param {Token} token - The token to check. - * @returns {boolean} `true` if the token is a comment token. - */ -function isCommentToken(token) { - return ["Block", "Line", "Shebang"].includes(token.type) -} - -const isNotArrowToken = negate(isArrowToken); -const isNotCommaToken = negate(isCommaToken); -const isNotSemicolonToken = negate(isSemicolonToken); -const isNotColonToken = negate(isColonToken); -const isNotOpeningParenToken = negate(isOpeningParenToken); -const isNotClosingParenToken = negate(isClosingParenToken); -const isNotOpeningBracketToken = negate(isOpeningBracketToken); -const isNotClosingBracketToken = negate(isClosingBracketToken); -const isNotOpeningBraceToken = negate(isOpeningBraceToken); -const isNotClosingBraceToken = negate(isClosingBraceToken); -const isNotCommentToken = negate(isCommentToken); - -/** - * Get the `(` token of the given function node. - * @param {Node} node - The function node to get. - * @param {SourceCode} sourceCode - The source code object to get tokens. - * @returns {Token} `(` token. - */ -function getOpeningParenOfParams(node, sourceCode) { - return node.id - ? sourceCode.getTokenAfter(node.id, isOpeningParenToken) - : sourceCode.getFirstToken(node, isOpeningParenToken) -} - -/** - * Get the location of the given function node for reporting. - * @param {Node} node - The function node to get. - * @param {SourceCode} sourceCode - The source code object to get tokens. - * @returns {string} The location of the function node for reporting. - */ -function getFunctionHeadLocation(node, sourceCode) { - const parent = node.parent; - let start = null; - let end = null; - - if (node.type === "ArrowFunctionExpression") { - const arrowToken = sourceCode.getTokenBefore(node.body, isArrowToken); - - start = arrowToken.loc.start; - end = arrowToken.loc.end; - } else if ( - parent.type === "Property" || - parent.type === "MethodDefinition" || - parent.type === "PropertyDefinition" - ) { - start = parent.loc.start; - end = getOpeningParenOfParams(node, sourceCode).loc.start; - } else { - start = node.loc.start; - end = getOpeningParenOfParams(node, sourceCode).loc.start; - } - - return { - start: { ...start }, - end: { ...end }, - } -} - -/* globals globalThis, global, self, window */ - -const globalObject = - typeof globalThis !== "undefined" - ? globalThis - : typeof self !== "undefined" - ? self - : typeof window !== "undefined" - ? window - : typeof global !== "undefined" - ? global - : {}; - -const builtinNames = Object.freeze( - new Set([ - "Array", - "ArrayBuffer", - "BigInt", - "BigInt64Array", - "BigUint64Array", - "Boolean", - "DataView", - "Date", - "decodeURI", - "decodeURIComponent", - "encodeURI", - "encodeURIComponent", - "escape", - "Float32Array", - "Float64Array", - "Function", - "Infinity", - "Int16Array", - "Int32Array", - "Int8Array", - "isFinite", - "isNaN", - "isPrototypeOf", - "JSON", - "Map", - "Math", - "NaN", - "Number", - "Object", - "parseFloat", - "parseInt", - "Promise", - "Proxy", - "Reflect", - "RegExp", - "Set", - "String", - "Symbol", - "Uint16Array", - "Uint32Array", - "Uint8Array", - "Uint8ClampedArray", - "undefined", - "unescape", - "WeakMap", - "WeakSet", - ]), -); -const callAllowed = new Set( - [ - Array.isArray, - Array.of, - Array.prototype.at, - Array.prototype.concat, - Array.prototype.entries, - Array.prototype.every, - Array.prototype.filter, - Array.prototype.find, - Array.prototype.findIndex, - Array.prototype.flat, - Array.prototype.includes, - Array.prototype.indexOf, - Array.prototype.join, - Array.prototype.keys, - Array.prototype.lastIndexOf, - Array.prototype.slice, - Array.prototype.some, - Array.prototype.toString, - Array.prototype.values, - typeof BigInt === "function" ? BigInt : undefined, - Boolean, - Date, - Date.parse, - decodeURI, - decodeURIComponent, - encodeURI, - encodeURIComponent, - escape, - isFinite, - isNaN, - isPrototypeOf, - Map, - Map.prototype.entries, - Map.prototype.get, - Map.prototype.has, - Map.prototype.keys, - Map.prototype.values, - ...Object.getOwnPropertyNames(Math) - .filter((k) => k !== "random") - .map((k) => Math[k]) - .filter((f) => typeof f === "function"), - Number, - Number.isFinite, - Number.isNaN, - Number.parseFloat, - Number.parseInt, - Number.prototype.toExponential, - Number.prototype.toFixed, - Number.prototype.toPrecision, - Number.prototype.toString, - Object, - Object.entries, - Object.is, - Object.isExtensible, - Object.isFrozen, - Object.isSealed, - Object.keys, - Object.values, - parseFloat, - parseInt, - RegExp, - Set, - Set.prototype.entries, - Set.prototype.has, - Set.prototype.keys, - Set.prototype.values, - String, - String.fromCharCode, - String.fromCodePoint, - String.raw, - String.prototype.at, - String.prototype.charAt, - String.prototype.charCodeAt, - String.prototype.codePointAt, - String.prototype.concat, - String.prototype.endsWith, - String.prototype.includes, - String.prototype.indexOf, - String.prototype.lastIndexOf, - String.prototype.normalize, - String.prototype.padEnd, - String.prototype.padStart, - String.prototype.slice, - String.prototype.startsWith, - String.prototype.substr, - String.prototype.substring, - String.prototype.toLowerCase, - String.prototype.toString, - String.prototype.toUpperCase, - String.prototype.trim, - String.prototype.trimEnd, - String.prototype.trimLeft, - String.prototype.trimRight, - String.prototype.trimStart, - Symbol.for, - Symbol.keyFor, - unescape, - ].filter((f) => typeof f === "function"), -); -const callPassThrough = new Set([ - Object.freeze, - Object.preventExtensions, - Object.seal, -]); - -/** @type {ReadonlyArray]>} */ -const getterAllowed = [ - [Map, new Set(["size"])], - [ - RegExp, - new Set([ - "dotAll", - "flags", - "global", - "hasIndices", - "ignoreCase", - "multiline", - "source", - "sticky", - "unicode", - ]), - ], - [Set, new Set(["size"])], -]; - -/** - * Get the property descriptor. - * @param {object} object The object to get. - * @param {string|number|symbol} name The property name to get. - */ -function getPropertyDescriptor(object, name) { - let x = object; - while ((typeof x === "object" || typeof x === "function") && x !== null) { - const d = Object.getOwnPropertyDescriptor(x, name); - if (d) { - return d - } - x = Object.getPrototypeOf(x); - } - return null -} - -/** - * Check if a property is getter or not. - * @param {object} object The object to check. - * @param {string|number|symbol} name The property name to check. - */ -function isGetter(object, name) { - const d = getPropertyDescriptor(object, name); - return d != null && d.get != null -} - -/** - * Get the element values of a given node list. - * @param {Node[]} nodeList The node list to get values. - * @param {Scope|undefined} initialScope The initial scope to find variables. - * @returns {any[]|null} The value list if all nodes are constant. Otherwise, null. - */ -function getElementValues(nodeList, initialScope) { - const valueList = []; - - for (let i = 0; i < nodeList.length; ++i) { - const elementNode = nodeList[i]; - - if (elementNode == null) { - valueList.length = i + 1; - } else if (elementNode.type === "SpreadElement") { - const argument = getStaticValueR(elementNode.argument, initialScope); - if (argument == null) { - return null - } - valueList.push(...argument.value); - } else { - const element = getStaticValueR(elementNode, initialScope); - if (element == null) { - return null - } - valueList.push(element.value); - } - } - - return valueList -} - -/** - * Returns whether the given variable is never written to after initialization. - * @param {import("eslint").Scope.Variable} variable - * @returns {boolean} - */ -function isEffectivelyConst(variable) { - const refs = variable.references; - - const inits = refs.filter((r) => r.init).length; - const reads = refs.filter((r) => r.isReadOnly()).length; - if (inits === 1 && reads + inits === refs.length) { - // there is only one init and all other references only read - return true - } - return false -} - -const operations = Object.freeze({ - ArrayExpression(node, initialScope) { - const elements = getElementValues(node.elements, initialScope); - return elements != null ? { value: elements } : null - }, - - AssignmentExpression(node, initialScope) { - if (node.operator === "=") { - return getStaticValueR(node.right, initialScope) - } - return null - }, - - //eslint-disable-next-line complexity - BinaryExpression(node, initialScope) { - if (node.operator === "in" || node.operator === "instanceof") { - // Not supported. - return null - } - - const left = getStaticValueR(node.left, initialScope); - const right = getStaticValueR(node.right, initialScope); - if (left != null && right != null) { - switch (node.operator) { - case "==": - return { value: left.value == right.value } //eslint-disable-line eqeqeq - case "!=": - return { value: left.value != right.value } //eslint-disable-line eqeqeq - case "===": - return { value: left.value === right.value } - case "!==": - return { value: left.value !== right.value } - case "<": - return { value: left.value < right.value } - case "<=": - return { value: left.value <= right.value } - case ">": - return { value: left.value > right.value } - case ">=": - return { value: left.value >= right.value } - case "<<": - return { value: left.value << right.value } - case ">>": - return { value: left.value >> right.value } - case ">>>": - return { value: left.value >>> right.value } - case "+": - return { value: left.value + right.value } - case "-": - return { value: left.value - right.value } - case "*": - return { value: left.value * right.value } - case "/": - return { value: left.value / right.value } - case "%": - return { value: left.value % right.value } - case "**": - return { value: left.value ** right.value } - case "|": - return { value: left.value | right.value } - case "^": - return { value: left.value ^ right.value } - case "&": - return { value: left.value & right.value } - - // no default - } - } - - return null - }, - - CallExpression(node, initialScope) { - const calleeNode = node.callee; - const args = getElementValues(node.arguments, initialScope); - - if (args != null) { - if (calleeNode.type === "MemberExpression") { - if (calleeNode.property.type === "PrivateIdentifier") { - return null - } - const object = getStaticValueR(calleeNode.object, initialScope); - if (object != null) { - if ( - object.value == null && - (object.optional || node.optional) - ) { - return { value: undefined, optional: true } - } - const property = getStaticPropertyNameValue( - calleeNode, - initialScope, - ); - - if (property != null) { - const receiver = object.value; - const methodName = property.value; - if (callAllowed.has(receiver[methodName])) { - return { value: receiver[methodName](...args) } - } - if (callPassThrough.has(receiver[methodName])) { - return { value: args[0] } - } - } - } - } else { - const callee = getStaticValueR(calleeNode, initialScope); - if (callee != null) { - if (callee.value == null && node.optional) { - return { value: undefined, optional: true } - } - const func = callee.value; - if (callAllowed.has(func)) { - return { value: func(...args) } - } - if (callPassThrough.has(func)) { - return { value: args[0] } - } - } - } - } - - return null - }, - - ConditionalExpression(node, initialScope) { - const test = getStaticValueR(node.test, initialScope); - if (test != null) { - return test.value - ? getStaticValueR(node.consequent, initialScope) - : getStaticValueR(node.alternate, initialScope) - } - return null - }, - - ExpressionStatement(node, initialScope) { - return getStaticValueR(node.expression, initialScope) - }, - - Identifier(node, initialScope) { - if (initialScope != null) { - const variable = findVariable(initialScope, node); - - // Built-in globals. - if ( - variable != null && - variable.defs.length === 0 && - builtinNames.has(variable.name) && - variable.name in globalObject - ) { - return { value: globalObject[variable.name] } - } - - // Constants. - if (variable != null && variable.defs.length === 1) { - const def = variable.defs[0]; - if ( - def.parent && - def.type === "Variable" && - (def.parent.kind === "const" || - isEffectivelyConst(variable)) && - // TODO(mysticatea): don't support destructuring here. - def.node.id.type === "Identifier" - ) { - return getStaticValueR(def.node.init, initialScope) - } - } - } - return null - }, - - Literal(node) { - //istanbul ignore if : this is implementation-specific behavior. - if ((node.regex != null || node.bigint != null) && node.value == null) { - // It was a RegExp/BigInt literal, but Node.js didn't support it. - return null - } - return { value: node.value } - }, - - LogicalExpression(node, initialScope) { - const left = getStaticValueR(node.left, initialScope); - if (left != null) { - if ( - (node.operator === "||" && Boolean(left.value) === true) || - (node.operator === "&&" && Boolean(left.value) === false) || - (node.operator === "??" && left.value != null) - ) { - return left - } - - const right = getStaticValueR(node.right, initialScope); - if (right != null) { - return right - } - } - - return null - }, - - MemberExpression(node, initialScope) { - if (node.property.type === "PrivateIdentifier") { - return null - } - const object = getStaticValueR(node.object, initialScope); - if (object != null) { - if (object.value == null && (object.optional || node.optional)) { - return { value: undefined, optional: true } - } - const property = getStaticPropertyNameValue(node, initialScope); - - if (property != null) { - if (!isGetter(object.value, property.value)) { - return { value: object.value[property.value] } - } - - for (const [classFn, allowed] of getterAllowed) { - if ( - object.value instanceof classFn && - allowed.has(property.value) - ) { - return { value: object.value[property.value] } - } - } - } - } - return null - }, - - ChainExpression(node, initialScope) { - const expression = getStaticValueR(node.expression, initialScope); - if (expression != null) { - return { value: expression.value } - } - return null - }, - - NewExpression(node, initialScope) { - const callee = getStaticValueR(node.callee, initialScope); - const args = getElementValues(node.arguments, initialScope); - - if (callee != null && args != null) { - const Func = callee.value; - if (callAllowed.has(Func)) { - return { value: new Func(...args) } - } - } - - return null - }, - - ObjectExpression(node, initialScope) { - const object = {}; - - for (const propertyNode of node.properties) { - if (propertyNode.type === "Property") { - if (propertyNode.kind !== "init") { - return null - } - const key = getStaticPropertyNameValue( - propertyNode, - initialScope, - ); - const value = getStaticValueR(propertyNode.value, initialScope); - if (key == null || value == null) { - return null - } - object[key.value] = value.value; - } else if ( - propertyNode.type === "SpreadElement" || - propertyNode.type === "ExperimentalSpreadProperty" - ) { - const argument = getStaticValueR( - propertyNode.argument, - initialScope, - ); - if (argument == null) { - return null - } - Object.assign(object, argument.value); - } else { - return null - } - } - - return { value: object } - }, - - SequenceExpression(node, initialScope) { - const last = node.expressions[node.expressions.length - 1]; - return getStaticValueR(last, initialScope) - }, - - TaggedTemplateExpression(node, initialScope) { - const tag = getStaticValueR(node.tag, initialScope); - const expressions = getElementValues( - node.quasi.expressions, - initialScope, - ); - - if (tag != null && expressions != null) { - const func = tag.value; - const strings = node.quasi.quasis.map((q) => q.value.cooked); - strings.raw = node.quasi.quasis.map((q) => q.value.raw); - - if (func === String.raw) { - return { value: func(strings, ...expressions) } - } - } - - return null - }, - - TemplateLiteral(node, initialScope) { - const expressions = getElementValues(node.expressions, initialScope); - if (expressions != null) { - let value = node.quasis[0].value.cooked; - for (let i = 0; i < expressions.length; ++i) { - value += expressions[i]; - value += node.quasis[i + 1].value.cooked; - } - return { value } - } - return null - }, - - UnaryExpression(node, initialScope) { - if (node.operator === "delete") { - // Not supported. - return null - } - if (node.operator === "void") { - return { value: undefined } - } - - const arg = getStaticValueR(node.argument, initialScope); - if (arg != null) { - switch (node.operator) { - case "-": - return { value: -arg.value } - case "+": - return { value: +arg.value } //eslint-disable-line no-implicit-coercion - case "!": - return { value: !arg.value } - case "~": - return { value: ~arg.value } - case "typeof": - return { value: typeof arg.value } - - // no default - } - } - - return null - }, -}); - -/** - * Get the value of a given node if it's a static value. - * @param {Node} node The node to get. - * @param {Scope|undefined} initialScope The scope to start finding variable. - * @returns {{value:any}|{value:undefined,optional?:true}|null} The static value of the node, or `null`. - */ -function getStaticValueR(node, initialScope) { - if (node != null && Object.hasOwnProperty.call(operations, node.type)) { - return operations[node.type](node, initialScope) - } - return null -} - -/** - * Get the static value of property name from a MemberExpression node or a Property node. - * @param {Node} node The node to get. - * @param {Scope} [initialScope] The scope to start finding variable. Optional. If the node is a computed property node and this scope was given, this checks the computed property name by the `getStringIfConstant` function with the scope, and returns the value of it. - * @returns {{value:any}|{value:undefined,optional?:true}|null} The static value of the property name of the node, or `null`. - */ -function getStaticPropertyNameValue(node, initialScope) { - const nameNode = node.type === "Property" ? node.key : node.property; - - if (node.computed) { - return getStaticValueR(nameNode, initialScope) - } - - if (nameNode.type === "Identifier") { - return { value: nameNode.name } - } - - if (nameNode.type === "Literal") { - if (nameNode.bigint) { - return { value: nameNode.bigint } - } - return { value: String(nameNode.value) } - } - - return null -} - -/** - * Get the value of a given node if it's a static value. - * @param {Node} node The node to get. - * @param {Scope} [initialScope] The scope to start finding variable. Optional. If this scope was given, this tries to resolve identifier references which are in the given node as much as possible. - * @returns {{value:any}|{value:undefined,optional?:true}|null} The static value of the node, or `null`. - */ -function getStaticValue(node, initialScope = null) { - try { - return getStaticValueR(node, initialScope) - } catch (_error) { - return null - } -} - -/** - * Get the value of a given node if it's a literal or a template literal. - * @param {Node} node The node to get. - * @param {Scope} [initialScope] The scope to start finding variable. Optional. If the node is an Identifier node and this scope was given, this checks the variable of the identifier, and returns the value of it if the variable is a constant. - * @returns {string|null} The value of the node, or `null`. - */ -function getStringIfConstant(node, initialScope = null) { - // Handle the literals that the platform doesn't support natively. - if (node && node.type === "Literal" && node.value === null) { - if (node.regex) { - return `/${node.regex.pattern}/${node.regex.flags}` - } - if (node.bigint) { - return node.bigint - } - } - - const evaluated = getStaticValue(node, initialScope); - return evaluated && String(evaluated.value) -} - -/** - * Get the property name from a MemberExpression node or a Property node. - * @param {Node} node The node to get. - * @param {Scope} [initialScope] The scope to start finding variable. Optional. If the node is a computed property node and this scope was given, this checks the computed property name by the `getStringIfConstant` function with the scope, and returns the value of it. - * @returns {string|null} The property name of the node. - */ -function getPropertyName(node, initialScope) { - switch (node.type) { - case "MemberExpression": - if (node.computed) { - return getStringIfConstant(node.property, initialScope) - } - if (node.property.type === "PrivateIdentifier") { - return null - } - return node.property.name - - case "Property": - case "MethodDefinition": - case "PropertyDefinition": - if (node.computed) { - return getStringIfConstant(node.key, initialScope) - } - if (node.key.type === "Literal") { - return String(node.key.value) - } - if (node.key.type === "PrivateIdentifier") { - return null - } - return node.key.name - - // no default - } - - return null -} - -/** - * Get the name and kind of the given function node. - * @param {ASTNode} node - The function node to get. - * @param {SourceCode} [sourceCode] The source code object to get the code of computed property keys. - * @returns {string} The name and kind of the function node. - */ -// eslint-disable-next-line complexity -function getFunctionNameWithKind(node, sourceCode) { - const parent = node.parent; - const tokens = []; - const isObjectMethod = parent.type === "Property" && parent.value === node; - const isClassMethod = - parent.type === "MethodDefinition" && parent.value === node; - const isClassFieldMethod = - parent.type === "PropertyDefinition" && parent.value === node; - - // Modifiers. - if (isClassMethod || isClassFieldMethod) { - if (parent.static) { - tokens.push("static"); - } - if (parent.key.type === "PrivateIdentifier") { - tokens.push("private"); - } - } - if (node.async) { - tokens.push("async"); - } - if (node.generator) { - tokens.push("generator"); - } - - // Kinds. - if (isObjectMethod || isClassMethod) { - if (parent.kind === "constructor") { - return "constructor" - } - if (parent.kind === "get") { - tokens.push("getter"); - } else if (parent.kind === "set") { - tokens.push("setter"); - } else { - tokens.push("method"); - } - } else if (isClassFieldMethod) { - tokens.push("method"); - } else { - if (node.type === "ArrowFunctionExpression") { - tokens.push("arrow"); - } - tokens.push("function"); - } - - // Names. - if (isObjectMethod || isClassMethod || isClassFieldMethod) { - if (parent.key.type === "PrivateIdentifier") { - tokens.push(`#${parent.key.name}`); - } else { - const name = getPropertyName(parent); - if (name) { - tokens.push(`'${name}'`); - } else if (sourceCode) { - const keyText = sourceCode.getText(parent.key); - if (!keyText.includes("\n")) { - tokens.push(`[${keyText}]`); - } - } - } - } else if (node.id) { - tokens.push(`'${node.id.name}'`); - } else if ( - parent.type === "VariableDeclarator" && - parent.id && - parent.id.type === "Identifier" - ) { - tokens.push(`'${parent.id.name}'`); - } else if ( - (parent.type === "AssignmentExpression" || - parent.type === "AssignmentPattern") && - parent.left && - parent.left.type === "Identifier" - ) { - tokens.push(`'${parent.left.name}'`); - } else if ( - parent.type === "ExportDefaultDeclaration" && - parent.declaration === node - ) { - tokens.push("'default'"); - } - - return tokens.join(" ") -} - -const typeConversionBinaryOps = Object.freeze( - new Set([ - "==", - "!=", - "<", - "<=", - ">", - ">=", - "<<", - ">>", - ">>>", - "+", - "-", - "*", - "/", - "%", - "|", - "^", - "&", - "in", - ]), -); -const typeConversionUnaryOps = Object.freeze(new Set(["-", "+", "!", "~"])); - -/** - * Check whether the given value is an ASTNode or not. - * @param {any} x The value to check. - * @returns {boolean} `true` if the value is an ASTNode. - */ -function isNode(x) { - return x !== null && typeof x === "object" && typeof x.type === "string" -} - -const visitor = Object.freeze( - Object.assign(Object.create(null), { - $visit(node, options, visitorKeys) { - const { type } = node; - - if (typeof this[type] === "function") { - return this[type](node, options, visitorKeys) - } - - return this.$visitChildren(node, options, visitorKeys) - }, - - $visitChildren(node, options, visitorKeys) { - const { type } = node; - - for (const key of visitorKeys[type] || getKeys(node)) { - const value = node[key]; - - if (Array.isArray(value)) { - for (const element of value) { - if ( - isNode(element) && - this.$visit(element, options, visitorKeys) - ) { - return true - } - } - } else if ( - isNode(value) && - this.$visit(value, options, visitorKeys) - ) { - return true - } - } - - return false - }, - - ArrowFunctionExpression() { - return false - }, - AssignmentExpression() { - return true - }, - AwaitExpression() { - return true - }, - BinaryExpression(node, options, visitorKeys) { - if ( - options.considerImplicitTypeConversion && - typeConversionBinaryOps.has(node.operator) && - (node.left.type !== "Literal" || node.right.type !== "Literal") - ) { - return true - } - return this.$visitChildren(node, options, visitorKeys) - }, - CallExpression() { - return true - }, - FunctionExpression() { - return false - }, - ImportExpression() { - return true - }, - MemberExpression(node, options, visitorKeys) { - if (options.considerGetters) { - return true - } - if ( - options.considerImplicitTypeConversion && - node.computed && - node.property.type !== "Literal" - ) { - return true - } - return this.$visitChildren(node, options, visitorKeys) - }, - MethodDefinition(node, options, visitorKeys) { - if ( - options.considerImplicitTypeConversion && - node.computed && - node.key.type !== "Literal" - ) { - return true - } - return this.$visitChildren(node, options, visitorKeys) - }, - NewExpression() { - return true - }, - Property(node, options, visitorKeys) { - if ( - options.considerImplicitTypeConversion && - node.computed && - node.key.type !== "Literal" - ) { - return true - } - return this.$visitChildren(node, options, visitorKeys) - }, - PropertyDefinition(node, options, visitorKeys) { - if ( - options.considerImplicitTypeConversion && - node.computed && - node.key.type !== "Literal" - ) { - return true - } - return this.$visitChildren(node, options, visitorKeys) - }, - UnaryExpression(node, options, visitorKeys) { - if (node.operator === "delete") { - return true - } - if ( - options.considerImplicitTypeConversion && - typeConversionUnaryOps.has(node.operator) && - node.argument.type !== "Literal" - ) { - return true - } - return this.$visitChildren(node, options, visitorKeys) - }, - UpdateExpression() { - return true - }, - YieldExpression() { - return true - }, - }), -); - -/** - * Check whether a given node has any side effect or not. - * @param {Node} node The node to get. - * @param {SourceCode} sourceCode The source code object. - * @param {object} [options] The option object. - * @param {boolean} [options.considerGetters=false] If `true` then it considers member accesses as the node which has side effects. - * @param {boolean} [options.considerImplicitTypeConversion=false] If `true` then it considers implicit type conversion as the node which has side effects. - * @param {object} [options.visitorKeys=KEYS] The keys to traverse nodes. Use `context.getSourceCode().visitorKeys`. - * @returns {boolean} `true` if the node has a certain side effect. - */ -function hasSideEffect( - node, - sourceCode, - { considerGetters = false, considerImplicitTypeConversion = false } = {}, -) { - return visitor.$visit( - node, - { considerGetters, considerImplicitTypeConversion }, - sourceCode.visitorKeys || KEYS, - ) -} - -/** - * Get the left parenthesis of the parent node syntax if it exists. - * E.g., `if (a) {}` then the `(`. - * @param {Node} node The AST node to check. - * @param {SourceCode} sourceCode The source code object to get tokens. - * @returns {Token|null} The left parenthesis of the parent node syntax - */ -function getParentSyntaxParen(node, sourceCode) { - const parent = node.parent; - - switch (parent.type) { - case "CallExpression": - case "NewExpression": - if (parent.arguments.length === 1 && parent.arguments[0] === node) { - return sourceCode.getTokenAfter( - parent.callee, - isOpeningParenToken, - ) - } - return null - - case "DoWhileStatement": - if (parent.test === node) { - return sourceCode.getTokenAfter( - parent.body, - isOpeningParenToken, - ) - } - return null - - case "IfStatement": - case "WhileStatement": - if (parent.test === node) { - return sourceCode.getFirstToken(parent, 1) - } - return null - - case "ImportExpression": - if (parent.source === node) { - return sourceCode.getFirstToken(parent, 1) - } - return null - - case "SwitchStatement": - if (parent.discriminant === node) { - return sourceCode.getFirstToken(parent, 1) - } - return null - - case "WithStatement": - if (parent.object === node) { - return sourceCode.getFirstToken(parent, 1) - } - return null - - default: - return null - } -} - -/** - * Check whether a given node is parenthesized or not. - * @param {number} times The number of parantheses. - * @param {Node} node The AST node to check. - * @param {SourceCode} sourceCode The source code object to get tokens. - * @returns {boolean} `true` if the node is parenthesized the given times. - */ -/** - * Check whether a given node is parenthesized or not. - * @param {Node} node The AST node to check. - * @param {SourceCode} sourceCode The source code object to get tokens. - * @returns {boolean} `true` if the node is parenthesized. - */ -function isParenthesized( - timesOrNode, - nodeOrSourceCode, - optionalSourceCode, -) { - let times, node, sourceCode, maybeLeftParen, maybeRightParen; - if (typeof timesOrNode === "number") { - times = timesOrNode | 0; - node = nodeOrSourceCode; - sourceCode = optionalSourceCode; - if (!(times >= 1)) { - throw new TypeError("'times' should be a positive integer.") - } - } else { - times = 1; - node = timesOrNode; - sourceCode = nodeOrSourceCode; - } - - if ( - node == null || - // `Program` can't be parenthesized - node.parent == null || - // `CatchClause.param` can't be parenthesized, example `try {} catch (error) {}` - (node.parent.type === "CatchClause" && node.parent.param === node) - ) { - return false - } - - maybeLeftParen = maybeRightParen = node; - do { - maybeLeftParen = sourceCode.getTokenBefore(maybeLeftParen); - maybeRightParen = sourceCode.getTokenAfter(maybeRightParen); - } while ( - maybeLeftParen != null && - maybeRightParen != null && - isOpeningParenToken(maybeLeftParen) && - isClosingParenToken(maybeRightParen) && - // Avoid false positive such as `if (a) {}` - maybeLeftParen !== getParentSyntaxParen(node, sourceCode) && - --times > 0 - ) - - return times === 0 -} - -/** - * @author Toru Nagashima - * See LICENSE file in root directory for full license. - */ - -const placeholder = /\$(?:[$&`']|[1-9][0-9]?)/gu; - -/** @type {WeakMap} */ -const internal = new WeakMap(); - -/** - * Check whether a given character is escaped or not. - * @param {string} str The string to check. - * @param {number} index The location of the character to check. - * @returns {boolean} `true` if the character is escaped. - */ -function isEscaped(str, index) { - let escaped = false; - for (let i = index - 1; i >= 0 && str.charCodeAt(i) === 0x5c; --i) { - escaped = !escaped; - } - return escaped -} - -/** - * Replace a given string by a given matcher. - * @param {PatternMatcher} matcher The pattern matcher. - * @param {string} str The string to be replaced. - * @param {string} replacement The new substring to replace each matched part. - * @returns {string} The replaced string. - */ -function replaceS(matcher, str, replacement) { - const chunks = []; - let index = 0; - - /** @type {RegExpExecArray} */ - let match = null; - - /** - * @param {string} key The placeholder. - * @returns {string} The replaced string. - */ - function replacer(key) { - switch (key) { - case "$$": - return "$" - case "$&": - return match[0] - case "$`": - return str.slice(0, match.index) - case "$'": - return str.slice(match.index + match[0].length) - default: { - const i = key.slice(1); - if (i in match) { - return match[i] - } - return key - } - } - } - - for (match of matcher.execAll(str)) { - chunks.push(str.slice(index, match.index)); - chunks.push(replacement.replace(placeholder, replacer)); - index = match.index + match[0].length; - } - chunks.push(str.slice(index)); - - return chunks.join("") -} - -/** - * Replace a given string by a given matcher. - * @param {PatternMatcher} matcher The pattern matcher. - * @param {string} str The string to be replaced. - * @param {(...strs[])=>string} replace The function to replace each matched part. - * @returns {string} The replaced string. - */ -function replaceF(matcher, str, replace) { - const chunks = []; - let index = 0; - - for (const match of matcher.execAll(str)) { - chunks.push(str.slice(index, match.index)); - chunks.push(String(replace(...match, match.index, match.input))); - index = match.index + match[0].length; - } - chunks.push(str.slice(index)); - - return chunks.join("") -} - -/** - * The class to find patterns as considering escape sequences. - */ -class PatternMatcher { - /** - * Initialize this matcher. - * @param {RegExp} pattern The pattern to match. - * @param {{escaped:boolean}} options The options. - */ - constructor(pattern, { escaped = false } = {}) { - if (!(pattern instanceof RegExp)) { - throw new TypeError("'pattern' should be a RegExp instance.") - } - if (!pattern.flags.includes("g")) { - throw new Error("'pattern' should contains 'g' flag.") - } - - internal.set(this, { - pattern: new RegExp(pattern.source, pattern.flags), - escaped: Boolean(escaped), - }); - } - - /** - * Find the pattern in a given string. - * @param {string} str The string to find. - * @returns {IterableIterator} The iterator which iterate the matched information. - */ - *execAll(str) { - const { pattern, escaped } = internal.get(this); - let match = null; - let lastIndex = 0; - - pattern.lastIndex = 0; - while ((match = pattern.exec(str)) != null) { - if (escaped || !isEscaped(str, match.index)) { - lastIndex = pattern.lastIndex; - yield match; - pattern.lastIndex = lastIndex; - } - } - } - - /** - * Check whether the pattern is found in a given string. - * @param {string} str The string to check. - * @returns {boolean} `true` if the pattern was found in the string. - */ - test(str) { - const it = this.execAll(str); - const ret = it.next(); - return !ret.done - } - - /** - * Replace a given string. - * @param {string} str The string to be replaced. - * @param {(string|((...strs:string[])=>string))} replacer The string or function to replace. This is the same as the 2nd argument of `String.prototype.replace`. - * @returns {string} The replaced string. - */ - [Symbol.replace](str, replacer) { - return typeof replacer === "function" - ? replaceF(this, String(str), replacer) - : replaceS(this, String(str), String(replacer)) - } -} - -const IMPORT_TYPE = /^(?:Import|Export(?:All|Default|Named))Declaration$/u; -const has = Function.call.bind(Object.hasOwnProperty); - -const READ = Symbol("read"); -const CALL = Symbol("call"); -const CONSTRUCT = Symbol("construct"); -const ESM = Symbol("esm"); - -const requireCall = { require: { [CALL]: true } }; - -/** - * Check whether a given variable is modified or not. - * @param {Variable} variable The variable to check. - * @returns {boolean} `true` if the variable is modified. - */ -function isModifiedGlobal(variable) { - return ( - variable == null || - variable.defs.length !== 0 || - variable.references.some((r) => r.isWrite()) - ) -} - -/** - * Check if the value of a given node is passed through to the parent syntax as-is. - * For example, `a` and `b` in (`a || b` and `c ? a : b`) are passed through. - * @param {Node} node A node to check. - * @returns {boolean} `true` if the node is passed through. - */ -function isPassThrough(node) { - const parent = node.parent; - - switch (parent && parent.type) { - case "ConditionalExpression": - return parent.consequent === node || parent.alternate === node - case "LogicalExpression": - return true - case "SequenceExpression": - return parent.expressions[parent.expressions.length - 1] === node - case "ChainExpression": - return true - - default: - return false - } -} - -/** - * The reference tracker. - */ -class ReferenceTracker { - /** - * Initialize this tracker. - * @param {Scope} globalScope The global scope. - * @param {object} [options] The options. - * @param {"legacy"|"strict"} [options.mode="strict"] The mode to determine the ImportDeclaration's behavior for CJS modules. - * @param {string[]} [options.globalObjectNames=["global","globalThis","self","window"]] The variable names for Global Object. - */ - constructor( - globalScope, - { - mode = "strict", - globalObjectNames = ["global", "globalThis", "self", "window"], - } = {}, - ) { - this.variableStack = []; - this.globalScope = globalScope; - this.mode = mode; - this.globalObjectNames = globalObjectNames.slice(0); - } - - /** - * Iterate the references of global variables. - * @param {object} traceMap The trace map. - * @returns {IterableIterator<{node:Node,path:string[],type:symbol,info:any}>} The iterator to iterate references. - */ - *iterateGlobalReferences(traceMap) { - for (const key of Object.keys(traceMap)) { - const nextTraceMap = traceMap[key]; - const path = [key]; - const variable = this.globalScope.set.get(key); - - if (isModifiedGlobal(variable)) { - continue - } - - yield* this._iterateVariableReferences( - variable, - path, - nextTraceMap, - true, - ); - } - - for (const key of this.globalObjectNames) { - const path = []; - const variable = this.globalScope.set.get(key); - - if (isModifiedGlobal(variable)) { - continue - } - - yield* this._iterateVariableReferences( - variable, - path, - traceMap, - false, - ); - } - } - - /** - * Iterate the references of CommonJS modules. - * @param {object} traceMap The trace map. - * @returns {IterableIterator<{node:Node,path:string[],type:symbol,info:any}>} The iterator to iterate references. - */ - *iterateCjsReferences(traceMap) { - for (const { node } of this.iterateGlobalReferences(requireCall)) { - const key = getStringIfConstant(node.arguments[0]); - if (key == null || !has(traceMap, key)) { - continue - } - - const nextTraceMap = traceMap[key]; - const path = [key]; - - if (nextTraceMap[READ]) { - yield { - node, - path, - type: READ, - info: nextTraceMap[READ], - }; - } - yield* this._iteratePropertyReferences(node, path, nextTraceMap); - } - } - - /** - * Iterate the references of ES modules. - * @param {object} traceMap The trace map. - * @returns {IterableIterator<{node:Node,path:string[],type:symbol,info:any}>} The iterator to iterate references. - */ - *iterateEsmReferences(traceMap) { - const programNode = this.globalScope.block; - - for (const node of programNode.body) { - if (!IMPORT_TYPE.test(node.type) || node.source == null) { - continue - } - const moduleId = node.source.value; - - if (!has(traceMap, moduleId)) { - continue - } - const nextTraceMap = traceMap[moduleId]; - const path = [moduleId]; - - if (nextTraceMap[READ]) { - yield { node, path, type: READ, info: nextTraceMap[READ] }; - } - - if (node.type === "ExportAllDeclaration") { - for (const key of Object.keys(nextTraceMap)) { - const exportTraceMap = nextTraceMap[key]; - if (exportTraceMap[READ]) { - yield { - node, - path: path.concat(key), - type: READ, - info: exportTraceMap[READ], - }; - } - } - } else { - for (const specifier of node.specifiers) { - const esm = has(nextTraceMap, ESM); - const it = this._iterateImportReferences( - specifier, - path, - esm - ? nextTraceMap - : this.mode === "legacy" - ? { default: nextTraceMap, ...nextTraceMap } - : { default: nextTraceMap }, - ); - - if (esm) { - yield* it; - } else { - for (const report of it) { - report.path = report.path.filter(exceptDefault); - if ( - report.path.length >= 2 || - report.type !== READ - ) { - yield report; - } - } - } - } - } - } - } - - /** - * Iterate the references for a given variable. - * @param {Variable} variable The variable to iterate that references. - * @param {string[]} path The current path. - * @param {object} traceMap The trace map. - * @param {boolean} shouldReport = The flag to report those references. - * @returns {IterableIterator<{node:Node,path:string[],type:symbol,info:any}>} The iterator to iterate references. - */ - *_iterateVariableReferences(variable, path, traceMap, shouldReport) { - if (this.variableStack.includes(variable)) { - return - } - this.variableStack.push(variable); - try { - for (const reference of variable.references) { - if (!reference.isRead()) { - continue - } - const node = reference.identifier; - - if (shouldReport && traceMap[READ]) { - yield { node, path, type: READ, info: traceMap[READ] }; - } - yield* this._iteratePropertyReferences(node, path, traceMap); - } - } finally { - this.variableStack.pop(); - } - } - - /** - * Iterate the references for a given AST node. - * @param rootNode The AST node to iterate references. - * @param {string[]} path The current path. - * @param {object} traceMap The trace map. - * @returns {IterableIterator<{node:Node,path:string[],type:symbol,info:any}>} The iterator to iterate references. - */ - //eslint-disable-next-line complexity - *_iteratePropertyReferences(rootNode, path, traceMap) { - let node = rootNode; - while (isPassThrough(node)) { - node = node.parent; - } - - const parent = node.parent; - if (parent.type === "MemberExpression") { - if (parent.object === node) { - const key = getPropertyName(parent); - if (key == null || !has(traceMap, key)) { - return - } - - path = path.concat(key); //eslint-disable-line no-param-reassign - const nextTraceMap = traceMap[key]; - if (nextTraceMap[READ]) { - yield { - node: parent, - path, - type: READ, - info: nextTraceMap[READ], - }; - } - yield* this._iteratePropertyReferences( - parent, - path, - nextTraceMap, - ); - } - return - } - if (parent.type === "CallExpression") { - if (parent.callee === node && traceMap[CALL]) { - yield { node: parent, path, type: CALL, info: traceMap[CALL] }; - } - return - } - if (parent.type === "NewExpression") { - if (parent.callee === node && traceMap[CONSTRUCT]) { - yield { - node: parent, - path, - type: CONSTRUCT, - info: traceMap[CONSTRUCT], - }; - } - return - } - if (parent.type === "AssignmentExpression") { - if (parent.right === node) { - yield* this._iterateLhsReferences(parent.left, path, traceMap); - yield* this._iteratePropertyReferences(parent, path, traceMap); - } - return - } - if (parent.type === "AssignmentPattern") { - if (parent.right === node) { - yield* this._iterateLhsReferences(parent.left, path, traceMap); - } - return - } - if (parent.type === "VariableDeclarator") { - if (parent.init === node) { - yield* this._iterateLhsReferences(parent.id, path, traceMap); - } - } - } - - /** - * Iterate the references for a given Pattern node. - * @param {Node} patternNode The Pattern node to iterate references. - * @param {string[]} path The current path. - * @param {object} traceMap The trace map. - * @returns {IterableIterator<{node:Node,path:string[],type:symbol,info:any}>} The iterator to iterate references. - */ - *_iterateLhsReferences(patternNode, path, traceMap) { - if (patternNode.type === "Identifier") { - const variable = findVariable(this.globalScope, patternNode); - if (variable != null) { - yield* this._iterateVariableReferences( - variable, - path, - traceMap, - false, - ); - } - return - } - if (patternNode.type === "ObjectPattern") { - for (const property of patternNode.properties) { - const key = getPropertyName(property); - - if (key == null || !has(traceMap, key)) { - continue - } - - const nextPath = path.concat(key); - const nextTraceMap = traceMap[key]; - if (nextTraceMap[READ]) { - yield { - node: property, - path: nextPath, - type: READ, - info: nextTraceMap[READ], - }; - } - yield* this._iterateLhsReferences( - property.value, - nextPath, - nextTraceMap, - ); - } - return - } - if (patternNode.type === "AssignmentPattern") { - yield* this._iterateLhsReferences(patternNode.left, path, traceMap); - } - } - - /** - * Iterate the references for a given ModuleSpecifier node. - * @param {Node} specifierNode The ModuleSpecifier node to iterate references. - * @param {string[]} path The current path. - * @param {object} traceMap The trace map. - * @returns {IterableIterator<{node:Node,path:string[],type:symbol,info:any}>} The iterator to iterate references. - */ - *_iterateImportReferences(specifierNode, path, traceMap) { - const type = specifierNode.type; - - if (type === "ImportSpecifier" || type === "ImportDefaultSpecifier") { - const key = - type === "ImportDefaultSpecifier" - ? "default" - : specifierNode.imported.name; - if (!has(traceMap, key)) { - return - } - - path = path.concat(key); //eslint-disable-line no-param-reassign - const nextTraceMap = traceMap[key]; - if (nextTraceMap[READ]) { - yield { - node: specifierNode, - path, - type: READ, - info: nextTraceMap[READ], - }; - } - yield* this._iterateVariableReferences( - findVariable(this.globalScope, specifierNode.local), - path, - nextTraceMap, - false, - ); - - return - } - - if (type === "ImportNamespaceSpecifier") { - yield* this._iterateVariableReferences( - findVariable(this.globalScope, specifierNode.local), - path, - traceMap, - false, - ); - return - } - - if (type === "ExportSpecifier") { - const key = specifierNode.local.name; - if (!has(traceMap, key)) { - return - } - - path = path.concat(key); //eslint-disable-line no-param-reassign - const nextTraceMap = traceMap[key]; - if (nextTraceMap[READ]) { - yield { - node: specifierNode, - path, - type: READ, - info: nextTraceMap[READ], - }; - } - } - } -} - -ReferenceTracker.READ = READ; -ReferenceTracker.CALL = CALL; -ReferenceTracker.CONSTRUCT = CONSTRUCT; -ReferenceTracker.ESM = ESM; - -/** - * This is a predicate function for Array#filter. - * @param {string} name A name part. - * @param {number} index The index of the name. - * @returns {boolean} `false` if it's default. - */ -function exceptDefault(name, index) { - return !(index === 1 && name === "default") -} - -var index = { - CALL, - CONSTRUCT, - ESM, - findVariable, - getFunctionHeadLocation, - getFunctionNameWithKind, - getInnermostScope, - getPropertyName, - getStaticValue, - getStringIfConstant, - hasSideEffect, - isArrowToken, - isClosingBraceToken, - isClosingBracketToken, - isClosingParenToken, - isColonToken, - isCommaToken, - isCommentToken, - isNotArrowToken, - isNotClosingBraceToken, - isNotClosingBracketToken, - isNotClosingParenToken, - isNotColonToken, - isNotCommaToken, - isNotCommentToken, - isNotOpeningBraceToken, - isNotOpeningBracketToken, - isNotOpeningParenToken, - isNotSemicolonToken, - isOpeningBraceToken, - isOpeningBracketToken, - isOpeningParenToken, - isParenthesized, - isSemicolonToken, - PatternMatcher, - READ, - ReferenceTracker, -}; - -export { CALL, CONSTRUCT, ESM, PatternMatcher, READ, ReferenceTracker, index as default, findVariable, getFunctionHeadLocation, getFunctionNameWithKind, getInnermostScope, getPropertyName, getStaticValue, getStringIfConstant, hasSideEffect, isArrowToken, isClosingBraceToken, isClosingBracketToken, isClosingParenToken, isColonToken, isCommaToken, isCommentToken, isNotArrowToken, isNotClosingBraceToken, isNotClosingBracketToken, isNotClosingParenToken, isNotColonToken, isNotCommaToken, isNotCommentToken, isNotOpeningBraceToken, isNotOpeningBracketToken, isNotOpeningParenToken, isNotSemicolonToken, isOpeningBraceToken, isOpeningBracketToken, isOpeningParenToken, isParenthesized, isSemicolonToken }; -//# sourceMappingURL=index.mjs.map diff --git a/tools/eslint/node_modules/@eslint-community/eslint-utils/node_modules/eslint-visitor-keys/LICENSE b/tools/eslint/node_modules/@eslint-community/eslint-utils/node_modules/eslint-visitor-keys/LICENSE deleted file mode 100644 index 17a25538d9bd63..00000000000000 --- a/tools/eslint/node_modules/@eslint-community/eslint-utils/node_modules/eslint-visitor-keys/LICENSE +++ /dev/null @@ -1,201 +0,0 @@ - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "{}" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright contributors - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. diff --git a/tools/eslint/node_modules/@eslint-community/eslint-utils/node_modules/eslint-visitor-keys/dist/eslint-visitor-keys.cjs b/tools/eslint/node_modules/@eslint-community/eslint-utils/node_modules/eslint-visitor-keys/dist/eslint-visitor-keys.cjs deleted file mode 100644 index 00f91bcc4834d6..00000000000000 --- a/tools/eslint/node_modules/@eslint-community/eslint-utils/node_modules/eslint-visitor-keys/dist/eslint-visitor-keys.cjs +++ /dev/null @@ -1,384 +0,0 @@ -'use strict'; - -Object.defineProperty(exports, '__esModule', { value: true }); - -/** - * @typedef {{ readonly [type: string]: ReadonlyArray }} VisitorKeys - */ - -/** - * @type {VisitorKeys} - */ -const KEYS = { - ArrayExpression: [ - "elements" - ], - ArrayPattern: [ - "elements" - ], - ArrowFunctionExpression: [ - "params", - "body" - ], - AssignmentExpression: [ - "left", - "right" - ], - AssignmentPattern: [ - "left", - "right" - ], - AwaitExpression: [ - "argument" - ], - BinaryExpression: [ - "left", - "right" - ], - BlockStatement: [ - "body" - ], - BreakStatement: [ - "label" - ], - CallExpression: [ - "callee", - "arguments" - ], - CatchClause: [ - "param", - "body" - ], - ChainExpression: [ - "expression" - ], - ClassBody: [ - "body" - ], - ClassDeclaration: [ - "id", - "superClass", - "body" - ], - ClassExpression: [ - "id", - "superClass", - "body" - ], - ConditionalExpression: [ - "test", - "consequent", - "alternate" - ], - ContinueStatement: [ - "label" - ], - DebuggerStatement: [], - DoWhileStatement: [ - "body", - "test" - ], - EmptyStatement: [], - ExperimentalRestProperty: [ - "argument" - ], - ExperimentalSpreadProperty: [ - "argument" - ], - ExportAllDeclaration: [ - "exported", - "source" - ], - ExportDefaultDeclaration: [ - "declaration" - ], - ExportNamedDeclaration: [ - "declaration", - "specifiers", - "source" - ], - ExportSpecifier: [ - "exported", - "local" - ], - ExpressionStatement: [ - "expression" - ], - ForInStatement: [ - "left", - "right", - "body" - ], - ForOfStatement: [ - "left", - "right", - "body" - ], - ForStatement: [ - "init", - "test", - "update", - "body" - ], - FunctionDeclaration: [ - "id", - "params", - "body" - ], - FunctionExpression: [ - "id", - "params", - "body" - ], - Identifier: [], - IfStatement: [ - "test", - "consequent", - "alternate" - ], - ImportDeclaration: [ - "specifiers", - "source" - ], - ImportDefaultSpecifier: [ - "local" - ], - ImportExpression: [ - "source" - ], - ImportNamespaceSpecifier: [ - "local" - ], - ImportSpecifier: [ - "imported", - "local" - ], - JSXAttribute: [ - "name", - "value" - ], - JSXClosingElement: [ - "name" - ], - JSXClosingFragment: [], - JSXElement: [ - "openingElement", - "children", - "closingElement" - ], - JSXEmptyExpression: [], - JSXExpressionContainer: [ - "expression" - ], - JSXFragment: [ - "openingFragment", - "children", - "closingFragment" - ], - JSXIdentifier: [], - JSXMemberExpression: [ - "object", - "property" - ], - JSXNamespacedName: [ - "namespace", - "name" - ], - JSXOpeningElement: [ - "name", - "attributes" - ], - JSXOpeningFragment: [], - JSXSpreadAttribute: [ - "argument" - ], - JSXSpreadChild: [ - "expression" - ], - JSXText: [], - LabeledStatement: [ - "label", - "body" - ], - Literal: [], - LogicalExpression: [ - "left", - "right" - ], - MemberExpression: [ - "object", - "property" - ], - MetaProperty: [ - "meta", - "property" - ], - MethodDefinition: [ - "key", - "value" - ], - NewExpression: [ - "callee", - "arguments" - ], - ObjectExpression: [ - "properties" - ], - ObjectPattern: [ - "properties" - ], - PrivateIdentifier: [], - Program: [ - "body" - ], - Property: [ - "key", - "value" - ], - PropertyDefinition: [ - "key", - "value" - ], - RestElement: [ - "argument" - ], - ReturnStatement: [ - "argument" - ], - SequenceExpression: [ - "expressions" - ], - SpreadElement: [ - "argument" - ], - StaticBlock: [ - "body" - ], - Super: [], - SwitchCase: [ - "test", - "consequent" - ], - SwitchStatement: [ - "discriminant", - "cases" - ], - TaggedTemplateExpression: [ - "tag", - "quasi" - ], - TemplateElement: [], - TemplateLiteral: [ - "quasis", - "expressions" - ], - ThisExpression: [], - ThrowStatement: [ - "argument" - ], - TryStatement: [ - "block", - "handler", - "finalizer" - ], - UnaryExpression: [ - "argument" - ], - UpdateExpression: [ - "argument" - ], - VariableDeclaration: [ - "declarations" - ], - VariableDeclarator: [ - "id", - "init" - ], - WhileStatement: [ - "test", - "body" - ], - WithStatement: [ - "object", - "body" - ], - YieldExpression: [ - "argument" - ] -}; - -// Types. -const NODE_TYPES = Object.keys(KEYS); - -// Freeze the keys. -for (const type of NODE_TYPES) { - Object.freeze(KEYS[type]); -} -Object.freeze(KEYS); - -/** - * @author Toru Nagashima - * See LICENSE file in root directory for full license. - */ - -/** - * @typedef {import('./visitor-keys.js').VisitorKeys} VisitorKeys - */ - -// List to ignore keys. -const KEY_BLACKLIST = new Set([ - "parent", - "leadingComments", - "trailingComments" -]); - -/** - * Check whether a given key should be used or not. - * @param {string} key The key to check. - * @returns {boolean} `true` if the key should be used. - */ -function filterKey(key) { - return !KEY_BLACKLIST.has(key) && key[0] !== "_"; -} - -/** - * Get visitor keys of a given node. - * @param {object} node The AST node to get keys. - * @returns {readonly string[]} Visitor keys of the node. - */ -function getKeys(node) { - return Object.keys(node).filter(filterKey); -} - -// Disable valid-jsdoc rule because it reports syntax error on the type of @returns. -// eslint-disable-next-line valid-jsdoc -/** - * Make the union set with `KEYS` and given keys. - * @param {VisitorKeys} additionalKeys The additional keys. - * @returns {VisitorKeys} The union set. - */ -function unionWith(additionalKeys) { - const retv = /** @type {{ - [type: string]: ReadonlyArray - }} */ (Object.assign({}, KEYS)); - - for (const type of Object.keys(additionalKeys)) { - if (Object.prototype.hasOwnProperty.call(retv, type)) { - const keys = new Set(additionalKeys[type]); - - for (const key of retv[type]) { - keys.add(key); - } - - retv[type] = Object.freeze(Array.from(keys)); - } else { - retv[type] = Object.freeze(Array.from(additionalKeys[type])); - } - } - - return Object.freeze(retv); -} - -exports.KEYS = KEYS; -exports.getKeys = getKeys; -exports.unionWith = unionWith; diff --git a/tools/eslint/node_modules/@eslint-community/eslint-utils/node_modules/eslint-visitor-keys/dist/eslint-visitor-keys.d.cts b/tools/eslint/node_modules/@eslint-community/eslint-utils/node_modules/eslint-visitor-keys/dist/eslint-visitor-keys.d.cts deleted file mode 100644 index c7c28ed37b805f..00000000000000 --- a/tools/eslint/node_modules/@eslint-community/eslint-utils/node_modules/eslint-visitor-keys/dist/eslint-visitor-keys.d.cts +++ /dev/null @@ -1,27 +0,0 @@ -type VisitorKeys$1 = { - readonly [type: string]: readonly string[]; -}; -/** - * @typedef {{ readonly [type: string]: ReadonlyArray }} VisitorKeys - */ -/** - * @type {VisitorKeys} - */ -declare const KEYS: VisitorKeys$1; - -/** - * Get visitor keys of a given node. - * @param {object} node The AST node to get keys. - * @returns {readonly string[]} Visitor keys of the node. - */ -declare function getKeys(node: object): readonly string[]; -/** - * Make the union set with `KEYS` and given keys. - * @param {VisitorKeys} additionalKeys The additional keys. - * @returns {VisitorKeys} The union set. - */ -declare function unionWith(additionalKeys: VisitorKeys): VisitorKeys; - -type VisitorKeys = VisitorKeys$1; - -export { KEYS, VisitorKeys, getKeys, unionWith }; diff --git a/tools/eslint/node_modules/@eslint-community/eslint-utils/node_modules/eslint-visitor-keys/lib/index.js b/tools/eslint/node_modules/@eslint-community/eslint-utils/node_modules/eslint-visitor-keys/lib/index.js deleted file mode 100644 index 3622816d632da0..00000000000000 --- a/tools/eslint/node_modules/@eslint-community/eslint-utils/node_modules/eslint-visitor-keys/lib/index.js +++ /dev/null @@ -1,65 +0,0 @@ -/** - * @author Toru Nagashima - * See LICENSE file in root directory for full license. - */ -import KEYS from "./visitor-keys.js"; - -/** - * @typedef {import('./visitor-keys.js').VisitorKeys} VisitorKeys - */ - -// List to ignore keys. -const KEY_BLACKLIST = new Set([ - "parent", - "leadingComments", - "trailingComments" -]); - -/** - * Check whether a given key should be used or not. - * @param {string} key The key to check. - * @returns {boolean} `true` if the key should be used. - */ -function filterKey(key) { - return !KEY_BLACKLIST.has(key) && key[0] !== "_"; -} - -/** - * Get visitor keys of a given node. - * @param {object} node The AST node to get keys. - * @returns {readonly string[]} Visitor keys of the node. - */ -export function getKeys(node) { - return Object.keys(node).filter(filterKey); -} - -// Disable valid-jsdoc rule because it reports syntax error on the type of @returns. -// eslint-disable-next-line valid-jsdoc -/** - * Make the union set with `KEYS` and given keys. - * @param {VisitorKeys} additionalKeys The additional keys. - * @returns {VisitorKeys} The union set. - */ -export function unionWith(additionalKeys) { - const retv = /** @type {{ - [type: string]: ReadonlyArray - }} */ (Object.assign({}, KEYS)); - - for (const type of Object.keys(additionalKeys)) { - if (Object.prototype.hasOwnProperty.call(retv, type)) { - const keys = new Set(additionalKeys[type]); - - for (const key of retv[type]) { - keys.add(key); - } - - retv[type] = Object.freeze(Array.from(keys)); - } else { - retv[type] = Object.freeze(Array.from(additionalKeys[type])); - } - } - - return Object.freeze(retv); -} - -export { KEYS }; diff --git a/tools/eslint/node_modules/@eslint-community/eslint-utils/node_modules/eslint-visitor-keys/lib/visitor-keys.js b/tools/eslint/node_modules/@eslint-community/eslint-utils/node_modules/eslint-visitor-keys/lib/visitor-keys.js deleted file mode 100644 index ccf2b1f9a3fe89..00000000000000 --- a/tools/eslint/node_modules/@eslint-community/eslint-utils/node_modules/eslint-visitor-keys/lib/visitor-keys.js +++ /dev/null @@ -1,315 +0,0 @@ -/** - * @typedef {{ readonly [type: string]: ReadonlyArray }} VisitorKeys - */ - -/** - * @type {VisitorKeys} - */ -const KEYS = { - ArrayExpression: [ - "elements" - ], - ArrayPattern: [ - "elements" - ], - ArrowFunctionExpression: [ - "params", - "body" - ], - AssignmentExpression: [ - "left", - "right" - ], - AssignmentPattern: [ - "left", - "right" - ], - AwaitExpression: [ - "argument" - ], - BinaryExpression: [ - "left", - "right" - ], - BlockStatement: [ - "body" - ], - BreakStatement: [ - "label" - ], - CallExpression: [ - "callee", - "arguments" - ], - CatchClause: [ - "param", - "body" - ], - ChainExpression: [ - "expression" - ], - ClassBody: [ - "body" - ], - ClassDeclaration: [ - "id", - "superClass", - "body" - ], - ClassExpression: [ - "id", - "superClass", - "body" - ], - ConditionalExpression: [ - "test", - "consequent", - "alternate" - ], - ContinueStatement: [ - "label" - ], - DebuggerStatement: [], - DoWhileStatement: [ - "body", - "test" - ], - EmptyStatement: [], - ExperimentalRestProperty: [ - "argument" - ], - ExperimentalSpreadProperty: [ - "argument" - ], - ExportAllDeclaration: [ - "exported", - "source" - ], - ExportDefaultDeclaration: [ - "declaration" - ], - ExportNamedDeclaration: [ - "declaration", - "specifiers", - "source" - ], - ExportSpecifier: [ - "exported", - "local" - ], - ExpressionStatement: [ - "expression" - ], - ForInStatement: [ - "left", - "right", - "body" - ], - ForOfStatement: [ - "left", - "right", - "body" - ], - ForStatement: [ - "init", - "test", - "update", - "body" - ], - FunctionDeclaration: [ - "id", - "params", - "body" - ], - FunctionExpression: [ - "id", - "params", - "body" - ], - Identifier: [], - IfStatement: [ - "test", - "consequent", - "alternate" - ], - ImportDeclaration: [ - "specifiers", - "source" - ], - ImportDefaultSpecifier: [ - "local" - ], - ImportExpression: [ - "source" - ], - ImportNamespaceSpecifier: [ - "local" - ], - ImportSpecifier: [ - "imported", - "local" - ], - JSXAttribute: [ - "name", - "value" - ], - JSXClosingElement: [ - "name" - ], - JSXClosingFragment: [], - JSXElement: [ - "openingElement", - "children", - "closingElement" - ], - JSXEmptyExpression: [], - JSXExpressionContainer: [ - "expression" - ], - JSXFragment: [ - "openingFragment", - "children", - "closingFragment" - ], - JSXIdentifier: [], - JSXMemberExpression: [ - "object", - "property" - ], - JSXNamespacedName: [ - "namespace", - "name" - ], - JSXOpeningElement: [ - "name", - "attributes" - ], - JSXOpeningFragment: [], - JSXSpreadAttribute: [ - "argument" - ], - JSXSpreadChild: [ - "expression" - ], - JSXText: [], - LabeledStatement: [ - "label", - "body" - ], - Literal: [], - LogicalExpression: [ - "left", - "right" - ], - MemberExpression: [ - "object", - "property" - ], - MetaProperty: [ - "meta", - "property" - ], - MethodDefinition: [ - "key", - "value" - ], - NewExpression: [ - "callee", - "arguments" - ], - ObjectExpression: [ - "properties" - ], - ObjectPattern: [ - "properties" - ], - PrivateIdentifier: [], - Program: [ - "body" - ], - Property: [ - "key", - "value" - ], - PropertyDefinition: [ - "key", - "value" - ], - RestElement: [ - "argument" - ], - ReturnStatement: [ - "argument" - ], - SequenceExpression: [ - "expressions" - ], - SpreadElement: [ - "argument" - ], - StaticBlock: [ - "body" - ], - Super: [], - SwitchCase: [ - "test", - "consequent" - ], - SwitchStatement: [ - "discriminant", - "cases" - ], - TaggedTemplateExpression: [ - "tag", - "quasi" - ], - TemplateElement: [], - TemplateLiteral: [ - "quasis", - "expressions" - ], - ThisExpression: [], - ThrowStatement: [ - "argument" - ], - TryStatement: [ - "block", - "handler", - "finalizer" - ], - UnaryExpression: [ - "argument" - ], - UpdateExpression: [ - "argument" - ], - VariableDeclaration: [ - "declarations" - ], - VariableDeclarator: [ - "id", - "init" - ], - WhileStatement: [ - "test", - "body" - ], - WithStatement: [ - "object", - "body" - ], - YieldExpression: [ - "argument" - ] -}; - -// Types. -const NODE_TYPES = Object.keys(KEYS); - -// Freeze the keys. -for (const type of NODE_TYPES) { - Object.freeze(KEYS[type]); -} -Object.freeze(KEYS); - -export default KEYS; diff --git a/tools/eslint/node_modules/@eslint-community/eslint-utils/node_modules/eslint-visitor-keys/package.json b/tools/eslint/node_modules/@eslint-community/eslint-utils/node_modules/eslint-visitor-keys/package.json deleted file mode 100644 index b9d51ce0e68900..00000000000000 --- a/tools/eslint/node_modules/@eslint-community/eslint-utils/node_modules/eslint-visitor-keys/package.json +++ /dev/null @@ -1,74 +0,0 @@ -{ - "name": "eslint-visitor-keys", - "version": "3.4.3", - "description": "Constants and utilities about visitor keys to traverse AST.", - "type": "module", - "main": "dist/eslint-visitor-keys.cjs", - "types": "./dist/index.d.ts", - "exports": { - ".": [ - { - "import": "./lib/index.js", - "require": "./dist/eslint-visitor-keys.cjs" - }, - "./dist/eslint-visitor-keys.cjs" - ], - "./package.json": "./package.json" - }, - "files": [ - "dist/index.d.ts", - "dist/visitor-keys.d.ts", - "dist/eslint-visitor-keys.cjs", - "dist/eslint-visitor-keys.d.cts", - "lib" - ], - "engines": { - "node": "^12.22.0 || ^14.17.0 || >=16.0.0" - }, - "devDependencies": { - "@types/estree": "^0.0.51", - "@types/estree-jsx": "^0.0.1", - "@typescript-eslint/parser": "^5.14.0", - "c8": "^7.11.0", - "chai": "^4.3.6", - "eslint": "^7.29.0", - "eslint-config-eslint": "^7.0.0", - "eslint-plugin-jsdoc": "^35.4.0", - "eslint-plugin-node": "^11.1.0", - "eslint-release": "^3.2.0", - "esquery": "^1.4.0", - "json-diff": "^0.7.3", - "mocha": "^9.2.1", - "opener": "^1.5.2", - "rollup": "^2.70.0", - "rollup-plugin-dts": "^4.2.3", - "tsd": "^0.19.1", - "typescript": "^4.6.2" - }, - "scripts": { - "build": "npm run build:cjs && npm run build:types", - "build:cjs": "rollup -c", - "build:debug": "npm run build:cjs -- -m && npm run build:types", - "build:keys": "node tools/build-keys-from-ts", - "build:types": "tsc", - "lint": "eslint .", - "prepare": "npm run build", - "release:generate:latest": "eslint-generate-release", - "release:generate:alpha": "eslint-generate-prerelease alpha", - "release:generate:beta": "eslint-generate-prerelease beta", - "release:generate:rc": "eslint-generate-prerelease rc", - "release:publish": "eslint-publish-release", - "test": "mocha tests/lib/**/*.cjs && c8 mocha tests/lib/**/*.js && npm run test:types", - "test:open-coverage": "c8 report --reporter lcov && opener coverage/lcov-report/index.html", - "test:types": "tsd" - }, - "repository": "eslint/eslint-visitor-keys", - "funding": "https://opencollective.com/eslint", - "keywords": [], - "author": "Toru Nagashima (https://github.com/mysticatea)", - "license": "Apache-2.0", - "bugs": { - "url": "https://github.com/eslint/eslint-visitor-keys/issues" - }, - "homepage": "https://github.com/eslint/eslint-visitor-keys#readme" -} diff --git a/tools/eslint/node_modules/@eslint-community/eslint-utils/package.json b/tools/eslint/node_modules/@eslint-community/eslint-utils/package.json deleted file mode 100644 index c4ee587b75f952..00000000000000 --- a/tools/eslint/node_modules/@eslint-community/eslint-utils/package.json +++ /dev/null @@ -1,73 +0,0 @@ -{ - "name": "@eslint-community/eslint-utils", - "version": "4.4.0", - "description": "Utilities for ESLint plugins.", - "keywords": [ - "eslint" - ], - "homepage": "https://github.com/eslint-community/eslint-utils#readme", - "bugs": { - "url": "https://github.com/eslint-community/eslint-utils/issues" - }, - "repository": { - "type": "git", - "url": "https://github.com/eslint-community/eslint-utils" - }, - "license": "MIT", - "author": "Toru Nagashima", - "sideEffects": false, - "exports": { - ".": { - "import": "./index.mjs", - "require": "./index.js" - }, - "./package.json": "./package.json" - }, - "main": "index", - "module": "index.mjs", - "files": [ - "index.*" - ], - "scripts": { - "prebuild": "npm run -s clean", - "build": "rollup -c", - "clean": "rimraf .nyc_output coverage index.*", - "coverage": "opener ./coverage/lcov-report/index.html", - "docs:build": "vitepress build docs", - "docs:watch": "vitepress dev docs", - "format": "npm run -s format:prettier -- --write", - "format:prettier": "prettier .", - "format:check": "npm run -s format:prettier -- --check", - "lint": "eslint .", - "test": "c8 mocha --reporter dot \"test/*.mjs\"", - "preversion": "npm test && npm run -s build", - "postversion": "git push && git push --tags", - "prewatch": "npm run -s clean", - "watch": "warun \"{src,test}/**/*.mjs\" -- npm run -s test:mocha" - }, - "dependencies": { - "eslint-visitor-keys": "^3.3.0" - }, - "devDependencies": { - "@eslint-community/eslint-plugin-mysticatea": "^15.2.0", - "c8": "^7.12.0", - "dot-prop": "^6.0.1", - "eslint": "^8.28.0", - "mocha": "^9.2.2", - "npm-run-all": "^4.1.5", - "opener": "^1.5.2", - "prettier": "2.8.4", - "rimraf": "^3.0.2", - "rollup": "^2.79.1", - "rollup-plugin-sourcemaps": "^0.6.3", - "semver": "^7.3.8", - "vitepress": "^1.0.0-alpha.40", - "warun": "^1.0.0" - }, - "peerDependencies": { - "eslint": "^6.0.0 || ^7.0.0 || >=8.0.0" - }, - "engines": { - "node": "^12.22.0 || ^14.17.0 || >=16.0.0" - } -} diff --git a/tools/eslint/node_modules/@eslint-community/regexpp/LICENSE b/tools/eslint/node_modules/@eslint-community/regexpp/LICENSE deleted file mode 100644 index 883ee1f612d12c..00000000000000 --- a/tools/eslint/node_modules/@eslint-community/regexpp/LICENSE +++ /dev/null @@ -1,21 +0,0 @@ -MIT License - -Copyright (c) 2018 Toru Nagashima - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. diff --git a/tools/eslint/node_modules/@eslint-community/regexpp/index.js b/tools/eslint/node_modules/@eslint-community/regexpp/index.js deleted file mode 100644 index aedc9a991ed084..00000000000000 --- a/tools/eslint/node_modules/@eslint-community/regexpp/index.js +++ /dev/null @@ -1,2868 +0,0 @@ -'use strict'; - -Object.defineProperty(exports, '__esModule', { value: true }); - -var ast = /*#__PURE__*/Object.freeze({ - __proto__: null -}); - -const latestEcmaVersion = 2025; - -let largeIdStartRanges = undefined; -let largeIdContinueRanges = undefined; -function isIdStart(cp) { - if (cp < 0x41) - return false; - if (cp < 0x5b) - return true; - if (cp < 0x61) - return false; - if (cp < 0x7b) - return true; - return isLargeIdStart(cp); -} -function isIdContinue(cp) { - if (cp < 0x30) - return false; - if (cp < 0x3a) - return true; - if (cp < 0x41) - return false; - if (cp < 0x5b) - return true; - if (cp === 0x5f) - return true; - if (cp < 0x61) - return false; - if (cp < 0x7b) - return true; - return isLargeIdStart(cp) || isLargeIdContinue(cp); -} -function isLargeIdStart(cp) { - return isInRange(cp, largeIdStartRanges !== null && largeIdStartRanges !== void 0 ? largeIdStartRanges : (largeIdStartRanges = initLargeIdStartRanges())); -} -function isLargeIdContinue(cp) { - return isInRange(cp, largeIdContinueRanges !== null && largeIdContinueRanges !== void 0 ? largeIdContinueRanges : (largeIdContinueRanges = initLargeIdContinueRanges())); -} -function initLargeIdStartRanges() { - return restoreRanges("4q 0 b 0 5 0 6 m 2 u 2 cp 5 b f 4 8 0 2 0 3m 4 2 1 3 3 2 0 7 0 2 2 2 0 2 j 2 2a 2 3u 9 4l 2 11 3 0 7 14 20 q 5 3 1a 16 10 1 2 2q 2 0 g 1 8 1 b 2 3 0 h 0 2 t u 2g c 0 p w a 1 5 0 6 l 5 0 a 0 4 0 o o 8 a 6 n 2 5 i 15 1n 1h 4 0 j 0 8 9 g f 5 7 3 1 3 l 2 6 2 0 4 3 4 0 h 0 e 1 2 2 f 1 b 0 9 5 5 1 3 l 2 6 2 1 2 1 2 1 w 3 2 0 k 2 h 8 2 2 2 l 2 6 2 1 2 4 4 0 j 0 g 1 o 0 c 7 3 1 3 l 2 6 2 1 2 4 4 0 v 1 2 2 g 0 i 0 2 5 4 2 2 3 4 1 2 0 2 1 4 1 4 2 4 b n 0 1h 7 2 2 2 m 2 f 4 0 r 2 3 0 3 1 v 0 5 7 2 2 2 m 2 9 2 4 4 0 w 1 2 1 g 1 i 8 2 2 2 14 3 0 h 0 6 2 9 2 p 5 6 h 4 n 2 8 2 0 3 6 1n 1b 2 1 d 6 1n 1 2 0 2 4 2 n 2 0 2 9 2 1 a 0 3 4 2 0 m 3 x 0 1s 7 2 z s 4 38 16 l 0 h 5 5 3 4 0 4 1 8 2 5 c d 0 i 11 2 0 6 0 3 16 2 98 2 3 3 6 2 0 2 3 3 14 2 3 3 w 2 3 3 6 2 0 2 3 3 e 2 1k 2 3 3 1u 12 f h 2d 3 5 4 h7 3 g 2 p 6 22 4 a 8 h e i f h f c 2 2 g 1f 10 0 5 0 1w 2g 8 14 2 0 6 1x b u 1e t 3 4 c 17 5 p 1j m a 1g 2b 0 2m 1a i 7 1j t e 1 b 17 r z 16 2 b z 3 8 8 16 3 2 16 3 2 5 2 1 4 0 6 5b 1t 7p 3 5 3 11 3 5 3 7 2 0 2 0 2 0 2 u 3 1g 2 6 2 0 4 2 2 6 4 3 3 5 5 c 6 2 2 6 39 0 e 0 h c 2u 0 5 0 3 9 2 0 3 5 7 0 2 0 2 0 2 f 3 3 6 4 5 0 i 14 22g 6c 7 3 4 1 d 11 2 0 6 0 3 1j 8 0 h m a 6 2 6 2 6 2 6 2 6 2 6 2 6 2 6 fb 2 q 8 8 4 3 4 5 2d 5 4 2 2h 2 3 6 16 2 2l i v 1d f e9 533 1t h3g 1w 19 3 7g 4 f b 1 l 1a h u 3 27 14 8 3 2u 3 1r 6 1 2 0 2 4 p f 2 2 2 3 2 m u 1f f 1d 1r 5 4 0 2 1 c r b m q s 8 1a t 0 h 4 2 9 b 4 2 14 o 2 2 7 l m 4 0 4 1d 2 0 4 1 3 4 3 0 2 0 p 2 3 a 8 2 d 5 3 5 3 5 a 6 2 6 2 16 2 d 7 36 u 8mb d m 5 1c 6it a5 3 2x 13 6 d 4 6 0 2 9 2 c 2 4 2 0 2 1 2 1 2 2z y a2 j 1r 3 1h 15 b 39 4 2 3q 11 p 7 p c 2g 4 5 3 5 3 5 3 2 10 b 2 p 2 i 2 1 2 e 3 d z 3e 1y 1g 7g s 4 1c 1c v e t 6 11 b t 3 z 5 7 2 4 17 4d j z 5 z 5 13 9 1f d a 2 e 2 6 2 1 2 a 2 e 2 6 2 1 1w 8m a l b 7 p 5 2 15 2 8 1y 5 3 0 2 17 2 1 4 0 3 m b m a u 1u i 2 1 b l b p 1z 1j 7 1 1t 0 g 3 2 2 2 s 17 s 4 s 10 7 2 r s 1h b l b i e h 33 20 1k 1e e 1e e z 9p 15 7 1 27 s b 0 9 l 17 h 1b k s m d 1g 1m 1 3 0 e 18 x o r z u 0 3 0 9 y 4 0 d 1b f 3 m 0 2 0 10 h 2 o k 1 1s 6 2 0 2 3 2 e 2 9 8 1a 13 7 3 1 3 l 2 6 2 1 2 4 4 0 j 0 d 4 4f 1g j 3 l 2 v 1b l 1 2 0 55 1a 16 3 11 1b l 0 1o 16 e 0 20 q 12 6 56 17 39 1r w 7 3 0 3 7 2 1 2 n g 0 2 0 2n 7 3 12 h 0 2 0 t 0 b 13 8 0 m 0 c 19 k 0 j 20 7c 8 2 10 i 0 1e t 35 6 2 1 2 11 m 0 q 5 2 1 2 v f 0 94 i g 0 2 c 2 x 3h 0 28 pl 2v 32 i 5f 219 2o g tr i 5 33u g6 6nu fs 8 u i 26 i t j 1b h 3 w k 6 i j5 1r 3l 22 6 0 1v c 1t 1 2 0 t 4qf 9 yd 17 8 6w8 3 2 6 2 1 2 82 g 0 u 2 3 0 f 3 9 az 1s5 2y 6 c 4 8 8 9 4mf 2c 2 1y 2 1 3 0 3 1 3 3 2 b 2 0 2 6 2 1s 2 3 3 7 2 6 2 r 2 3 2 4 2 0 4 6 2 9f 3 o 2 o 2 u 2 o 2 u 2 o 2 u 2 o 2 u 2 o 2 7 1f9 u 7 5 7a 1p 43 18 b 6 h 0 8y t j 17 dh r l1 6 2 3 2 1 2 e 2 5g 1o 1v 8 0 xh 3 2 q 2 1 2 0 3 0 2 9 2 3 2 0 2 0 7 0 5 0 2 0 2 0 2 2 2 1 2 0 3 0 2 0 2 0 2 0 2 0 2 1 2 0 3 3 2 6 2 3 2 3 2 0 2 9 2 g 6 2 2 4 2 g 3et wyn x 37d 7 65 3 4g1 f 5rk g h9 1wj f1 15v 3t6 6 38f"); -} -function initLargeIdContinueRanges() { - return restoreRanges("53 0 g9 33 o 0 70 4 7e 18 2 0 2 1 2 1 2 0 21 a 1d u 7 0 2u 6 3 5 3 1 2 3 3 9 o 0 v q 2k a g 9 y 8 a 0 p 3 2 8 2 2 2 4 18 2 1p 7 17 n 2 w 1j 2 2 h 2 6 b 1 3 9 i 2 1l 0 2 6 3 1 3 2 a 0 b 1 3 9 f 0 3 2 1l 0 2 4 5 1 3 2 4 0 l b 4 0 c 2 1l 0 2 7 2 2 2 2 l 1 3 9 b 5 2 2 1l 0 2 6 3 1 3 2 8 2 b 1 3 9 j 0 1o 4 4 2 2 3 a 0 f 9 h 4 1k 0 2 6 2 2 2 3 8 1 c 1 3 9 i 2 1l 0 2 6 2 2 2 3 8 1 c 1 3 9 4 0 d 3 1k 1 2 6 2 2 2 3 a 0 b 1 3 9 i 2 1z 0 5 5 2 0 2 7 7 9 3 1 1q 0 3 6 d 7 2 9 2g 0 3 8 c 6 2 9 1r 1 7 9 c 0 2 0 2 0 5 1 1e j 2 1 6 a 2 z a 0 2t j 2 9 d 3 5 2 2 2 3 6 4 3 e b 2 e jk 2 a 8 pt 3 t 2 u 1 v 1 1t v a 0 3 9 y 2 2 a 40 0 3b b 5 b b 9 3l a 1p 4 1m 9 2 s 3 a 7 9 n d 2 f 1e 4 1c g c 9 i 8 d 2 v c 3 9 19 d 1d j 9 9 7 9 3b 2 2 k 5 0 7 0 3 2 5j 1r el 1 1e 1 k 0 3g c 5 0 4 b 2db 2 3y 0 2p v ff 5 2y 1 2p 0 n51 9 1y 0 5 9 x 1 29 1 7l 0 4 0 5 0 o 4 5 0 2c 1 1f h b 9 7 h e a t 7 q c 19 3 1c d g 9 c 0 b 9 1c d d 0 9 1 3 9 y 2 1f 0 2 2 3 1 6 1 2 0 16 4 6 1 6l 7 2 1 3 9 fmt 0 ki f h f 4 1 p 2 5d 9 12 0 12 0 ig 0 6b 0 46 4 86 9 120 2 2 1 6 3 15 2 5 0 4m 1 fy 3 9 9 aa 1 29 2 1z a 1e 3 3f 2 1i e w a 3 1 b 3 1a a 8 0 1a 9 7 2 11 d 2 9 6 1 19 0 d 2 1d d 9 3 2 b 2b b 7 0 3 0 4e b 6 9 7 3 1k 1 2 6 3 1 3 2 a 0 b 1 3 6 4 4 5d h a 9 5 0 2a j d 9 5y 6 3 8 s 1 2b g g 9 2a c 9 9 2c e 5 9 6r e 4m 9 1z 5 2 1 3 3 2 0 2 1 d 9 3c 6 3 6 4 0 t 9 15 6 2 3 9 0 a a 1b f ba 7 2 7 h 9 1l l 2 d 3f 5 4 0 2 1 2 6 2 0 9 9 1d 4 2 1 2 4 9 9 96 3 a 1 2 0 1d 6 4 4 e 9 44n 0 7 e aob 9 2f 9 13 4 1o 6 q 9 s6 0 2 1i 8 3 2a 0 c 1 f58 1 3mq 19 3 m f3 4 4 5 9 7 3 6 v 3 45 2 13e 1d e9 1i 5 1d 9 0 f 0 n 4 2 e 11t 6 2 g 3 6 2 1 2 4 2t 0 4h 6 a 9 9x 0 1q d dv d rb 6 32 6 6 9 3o7 9 gvt3 6n"); -} -function isInRange(cp, ranges) { - let l = 0, r = (ranges.length / 2) | 0, i = 0, min = 0, max = 0; - while (l < r) { - i = ((l + r) / 2) | 0; - min = ranges[2 * i]; - max = ranges[2 * i + 1]; - if (cp < min) { - r = i; - } - else if (cp > max) { - l = i + 1; - } - else { - return true; - } - } - return false; -} -function restoreRanges(data) { - let last = 0; - return data.split(" ").map((s) => (last += parseInt(s, 36) | 0)); -} - -class DataSet { - constructor(raw2018, raw2019, raw2020, raw2021, raw2022, raw2023, raw2024, raw2025) { - this._raw2018 = raw2018; - this._raw2019 = raw2019; - this._raw2020 = raw2020; - this._raw2021 = raw2021; - this._raw2022 = raw2022; - this._raw2023 = raw2023; - this._raw2024 = raw2024; - this._raw2025 = raw2025; - } - get es2018() { - var _a; - return ((_a = this._set2018) !== null && _a !== void 0 ? _a : (this._set2018 = new Set(this._raw2018.split(" ")))); - } - get es2019() { - var _a; - return ((_a = this._set2019) !== null && _a !== void 0 ? _a : (this._set2019 = new Set(this._raw2019.split(" ")))); - } - get es2020() { - var _a; - return ((_a = this._set2020) !== null && _a !== void 0 ? _a : (this._set2020 = new Set(this._raw2020.split(" ")))); - } - get es2021() { - var _a; - return ((_a = this._set2021) !== null && _a !== void 0 ? _a : (this._set2021 = new Set(this._raw2021.split(" ")))); - } - get es2022() { - var _a; - return ((_a = this._set2022) !== null && _a !== void 0 ? _a : (this._set2022 = new Set(this._raw2022.split(" ")))); - } - get es2023() { - var _a; - return ((_a = this._set2023) !== null && _a !== void 0 ? _a : (this._set2023 = new Set(this._raw2023.split(" ")))); - } - get es2024() { - var _a; - return ((_a = this._set2024) !== null && _a !== void 0 ? _a : (this._set2024 = new Set(this._raw2024.split(" ")))); - } - get es2025() { - var _a; - return ((_a = this._set2025) !== null && _a !== void 0 ? _a : (this._set2025 = new Set(this._raw2025.split(" ")))); - } -} -const gcNameSet = new Set(["General_Category", "gc"]); -const scNameSet = new Set(["Script", "Script_Extensions", "sc", "scx"]); -const gcValueSets = new DataSet("C Cased_Letter Cc Cf Close_Punctuation Cn Co Combining_Mark Connector_Punctuation Control Cs Currency_Symbol Dash_Punctuation Decimal_Number Enclosing_Mark Final_Punctuation Format Initial_Punctuation L LC Letter Letter_Number Line_Separator Ll Lm Lo Lowercase_Letter Lt Lu M Mark Math_Symbol Mc Me Mn Modifier_Letter Modifier_Symbol N Nd Nl No Nonspacing_Mark Number Open_Punctuation Other Other_Letter Other_Number Other_Punctuation Other_Symbol P Paragraph_Separator Pc Pd Pe Pf Pi Po Private_Use Ps Punctuation S Sc Separator Sk Sm So Space_Separator Spacing_Mark Surrogate Symbol Titlecase_Letter Unassigned Uppercase_Letter Z Zl Zp Zs cntrl digit punct", "", "", "", "", "", "", ""); -const scValueSets = new DataSet("Adlam Adlm Aghb Ahom Anatolian_Hieroglyphs Arab Arabic Armenian Armi Armn Avestan Avst Bali Balinese Bamu Bamum Bass Bassa_Vah Batak Batk Beng Bengali Bhaiksuki Bhks Bopo Bopomofo Brah Brahmi Brai Braille Bugi Buginese Buhd Buhid Cakm Canadian_Aboriginal Cans Cari Carian Caucasian_Albanian Chakma Cham Cher Cherokee Common Copt Coptic Cprt Cuneiform Cypriot Cyrillic Cyrl Deseret Deva Devanagari Dsrt Dupl Duployan Egyp Egyptian_Hieroglyphs Elba Elbasan Ethi Ethiopic Geor Georgian Glag Glagolitic Gonm Goth Gothic Gran Grantha Greek Grek Gujarati Gujr Gurmukhi Guru Han Hang Hangul Hani Hano Hanunoo Hatr Hatran Hebr Hebrew Hira Hiragana Hluw Hmng Hung Imperial_Aramaic Inherited Inscriptional_Pahlavi Inscriptional_Parthian Ital Java Javanese Kaithi Kali Kana Kannada Katakana Kayah_Li Khar Kharoshthi Khmer Khmr Khoj Khojki Khudawadi Knda Kthi Lana Lao Laoo Latin Latn Lepc Lepcha Limb Limbu Lina Linb Linear_A Linear_B Lisu Lyci Lycian Lydi Lydian Mahajani Mahj Malayalam Mand Mandaic Mani Manichaean Marc Marchen Masaram_Gondi Meetei_Mayek Mend Mende_Kikakui Merc Mero Meroitic_Cursive Meroitic_Hieroglyphs Miao Mlym Modi Mong Mongolian Mro Mroo Mtei Mult Multani Myanmar Mymr Nabataean Narb Nbat New_Tai_Lue Newa Nko Nkoo Nshu Nushu Ogam Ogham Ol_Chiki Olck Old_Hungarian Old_Italic Old_North_Arabian Old_Permic Old_Persian Old_South_Arabian Old_Turkic Oriya Orkh Orya Osage Osge Osma Osmanya Pahawh_Hmong Palm Palmyrene Pau_Cin_Hau Pauc Perm Phag Phags_Pa Phli Phlp Phnx Phoenician Plrd Prti Psalter_Pahlavi Qaac Qaai Rejang Rjng Runic Runr Samaritan Samr Sarb Saur Saurashtra Sgnw Sharada Shavian Shaw Shrd Sidd Siddham SignWriting Sind Sinh Sinhala Sora Sora_Sompeng Soyo Soyombo Sund Sundanese Sylo Syloti_Nagri Syrc Syriac Tagalog Tagb Tagbanwa Tai_Le Tai_Tham Tai_Viet Takr Takri Tale Talu Tamil Taml Tang Tangut Tavt Telu Telugu Tfng Tglg Thaa Thaana Thai Tibetan Tibt Tifinagh Tirh Tirhuta Ugar Ugaritic Vai Vaii Wara Warang_Citi Xpeo Xsux Yi Yiii Zanabazar_Square Zanb Zinh Zyyy", "Dogr Dogra Gong Gunjala_Gondi Hanifi_Rohingya Maka Makasar Medefaidrin Medf Old_Sogdian Rohg Sogd Sogdian Sogo", "Elym Elymaic Hmnp Nand Nandinagari Nyiakeng_Puachue_Hmong Wancho Wcho", "Chorasmian Chrs Diak Dives_Akuru Khitan_Small_Script Kits Yezi Yezidi", "Cpmn Cypro_Minoan Old_Uyghur Ougr Tangsa Tnsa Toto Vith Vithkuqi", "Hrkt Katakana_Or_Hiragana Kawi Nag_Mundari Nagm Unknown Zzzz", "", ""); -const binPropertySets = new DataSet("AHex ASCII ASCII_Hex_Digit Alpha Alphabetic Any Assigned Bidi_C Bidi_Control Bidi_M Bidi_Mirrored CI CWCF CWCM CWKCF CWL CWT CWU Case_Ignorable Cased Changes_When_Casefolded Changes_When_Casemapped Changes_When_Lowercased Changes_When_NFKC_Casefolded Changes_When_Titlecased Changes_When_Uppercased DI Dash Default_Ignorable_Code_Point Dep Deprecated Dia Diacritic Emoji Emoji_Component Emoji_Modifier Emoji_Modifier_Base Emoji_Presentation Ext Extender Gr_Base Gr_Ext Grapheme_Base Grapheme_Extend Hex Hex_Digit IDC IDS IDSB IDST IDS_Binary_Operator IDS_Trinary_Operator ID_Continue ID_Start Ideo Ideographic Join_C Join_Control LOE Logical_Order_Exception Lower Lowercase Math NChar Noncharacter_Code_Point Pat_Syn Pat_WS Pattern_Syntax Pattern_White_Space QMark Quotation_Mark RI Radical Regional_Indicator SD STerm Sentence_Terminal Soft_Dotted Term Terminal_Punctuation UIdeo Unified_Ideograph Upper Uppercase VS Variation_Selector White_Space XIDC XIDS XID_Continue XID_Start space", "Extended_Pictographic", "", "EBase EComp EMod EPres ExtPict", "", "", "", ""); -const binPropertyOfStringsSets = new DataSet("", "", "", "", "", "", "Basic_Emoji Emoji_Keycap_Sequence RGI_Emoji RGI_Emoji_Flag_Sequence RGI_Emoji_Modifier_Sequence RGI_Emoji_Tag_Sequence RGI_Emoji_ZWJ_Sequence", ""); -function isValidUnicodeProperty(version, name, value) { - if (gcNameSet.has(name)) { - return version >= 2018 && gcValueSets.es2018.has(value); - } - if (scNameSet.has(name)) { - return ((version >= 2018 && scValueSets.es2018.has(value)) || - (version >= 2019 && scValueSets.es2019.has(value)) || - (version >= 2020 && scValueSets.es2020.has(value)) || - (version >= 2021 && scValueSets.es2021.has(value)) || - (version >= 2022 && scValueSets.es2022.has(value)) || - (version >= 2023 && scValueSets.es2023.has(value))); - } - return false; -} -function isValidLoneUnicodeProperty(version, value) { - return ((version >= 2018 && binPropertySets.es2018.has(value)) || - (version >= 2019 && binPropertySets.es2019.has(value)) || - (version >= 2021 && binPropertySets.es2021.has(value))); -} -function isValidLoneUnicodePropertyOfString(version, value) { - return version >= 2024 && binPropertyOfStringsSets.es2024.has(value); -} - -const BACKSPACE = 0x08; -const CHARACTER_TABULATION = 0x09; -const LINE_FEED = 0x0a; -const LINE_TABULATION = 0x0b; -const FORM_FEED = 0x0c; -const CARRIAGE_RETURN = 0x0d; -const EXCLAMATION_MARK = 0x21; -const NUMBER_SIGN = 0x23; -const DOLLAR_SIGN = 0x24; -const PERCENT_SIGN = 0x25; -const AMPERSAND = 0x26; -const LEFT_PARENTHESIS = 0x28; -const RIGHT_PARENTHESIS = 0x29; -const ASTERISK = 0x2a; -const PLUS_SIGN = 0x2b; -const COMMA = 0x2c; -const HYPHEN_MINUS = 0x2d; -const FULL_STOP = 0x2e; -const SOLIDUS = 0x2f; -const DIGIT_ZERO = 0x30; -const DIGIT_ONE = 0x31; -const DIGIT_SEVEN = 0x37; -const DIGIT_NINE = 0x39; -const COLON = 0x3a; -const SEMICOLON = 0x3b; -const LESS_THAN_SIGN = 0x3c; -const EQUALS_SIGN = 0x3d; -const GREATER_THAN_SIGN = 0x3e; -const QUESTION_MARK = 0x3f; -const COMMERCIAL_AT = 0x40; -const LATIN_CAPITAL_LETTER_A = 0x41; -const LATIN_CAPITAL_LETTER_B = 0x42; -const LATIN_CAPITAL_LETTER_D = 0x44; -const LATIN_CAPITAL_LETTER_F = 0x46; -const LATIN_CAPITAL_LETTER_P = 0x50; -const LATIN_CAPITAL_LETTER_S = 0x53; -const LATIN_CAPITAL_LETTER_W = 0x57; -const LATIN_CAPITAL_LETTER_Z = 0x5a; -const LOW_LINE = 0x5f; -const LATIN_SMALL_LETTER_A = 0x61; -const LATIN_SMALL_LETTER_B = 0x62; -const LATIN_SMALL_LETTER_C = 0x63; -const LATIN_SMALL_LETTER_D = 0x64; -const LATIN_SMALL_LETTER_F = 0x66; -const LATIN_SMALL_LETTER_G = 0x67; -const LATIN_SMALL_LETTER_I = 0x69; -const LATIN_SMALL_LETTER_K = 0x6b; -const LATIN_SMALL_LETTER_M = 0x6d; -const LATIN_SMALL_LETTER_N = 0x6e; -const LATIN_SMALL_LETTER_P = 0x70; -const LATIN_SMALL_LETTER_Q = 0x71; -const LATIN_SMALL_LETTER_R = 0x72; -const LATIN_SMALL_LETTER_S = 0x73; -const LATIN_SMALL_LETTER_T = 0x74; -const LATIN_SMALL_LETTER_U = 0x75; -const LATIN_SMALL_LETTER_V = 0x76; -const LATIN_SMALL_LETTER_W = 0x77; -const LATIN_SMALL_LETTER_X = 0x78; -const LATIN_SMALL_LETTER_Y = 0x79; -const LATIN_SMALL_LETTER_Z = 0x7a; -const LEFT_SQUARE_BRACKET = 0x5b; -const REVERSE_SOLIDUS = 0x5c; -const RIGHT_SQUARE_BRACKET = 0x5d; -const CIRCUMFLEX_ACCENT = 0x5e; -const GRAVE_ACCENT = 0x60; -const LEFT_CURLY_BRACKET = 0x7b; -const VERTICAL_LINE = 0x7c; -const RIGHT_CURLY_BRACKET = 0x7d; -const TILDE = 0x7e; -const ZERO_WIDTH_NON_JOINER = 0x200c; -const ZERO_WIDTH_JOINER = 0x200d; -const LINE_SEPARATOR = 0x2028; -const PARAGRAPH_SEPARATOR = 0x2029; -const MIN_CODE_POINT = 0x00; -const MAX_CODE_POINT = 0x10ffff; -function isLatinLetter(code) { - return ((code >= LATIN_CAPITAL_LETTER_A && code <= LATIN_CAPITAL_LETTER_Z) || - (code >= LATIN_SMALL_LETTER_A && code <= LATIN_SMALL_LETTER_Z)); -} -function isDecimalDigit(code) { - return code >= DIGIT_ZERO && code <= DIGIT_NINE; -} -function isOctalDigit(code) { - return code >= DIGIT_ZERO && code <= DIGIT_SEVEN; -} -function isHexDigit(code) { - return ((code >= DIGIT_ZERO && code <= DIGIT_NINE) || - (code >= LATIN_CAPITAL_LETTER_A && code <= LATIN_CAPITAL_LETTER_F) || - (code >= LATIN_SMALL_LETTER_A && code <= LATIN_SMALL_LETTER_F)); -} -function isLineTerminator(code) { - return (code === LINE_FEED || - code === CARRIAGE_RETURN || - code === LINE_SEPARATOR || - code === PARAGRAPH_SEPARATOR); -} -function isValidUnicode(code) { - return code >= MIN_CODE_POINT && code <= MAX_CODE_POINT; -} -function digitToInt(code) { - if (code >= LATIN_SMALL_LETTER_A && code <= LATIN_SMALL_LETTER_F) { - return code - LATIN_SMALL_LETTER_A + 10; - } - if (code >= LATIN_CAPITAL_LETTER_A && code <= LATIN_CAPITAL_LETTER_F) { - return code - LATIN_CAPITAL_LETTER_A + 10; - } - return code - DIGIT_ZERO; -} -function isLeadSurrogate(code) { - return code >= 0xd800 && code <= 0xdbff; -} -function isTrailSurrogate(code) { - return code >= 0xdc00 && code <= 0xdfff; -} -function combineSurrogatePair(lead, trail) { - return (lead - 0xd800) * 0x400 + (trail - 0xdc00) + 0x10000; -} - -class GroupSpecifiersAsES2018 { - constructor() { - this.groupName = new Set(); - } - clear() { - this.groupName.clear(); - } - isEmpty() { - return !this.groupName.size; - } - hasInPattern(name) { - return this.groupName.has(name); - } - hasInScope(name) { - return this.hasInPattern(name); - } - addToScope(name) { - this.groupName.add(name); - } - enterDisjunction() { - } - enterAlternative() { - } - leaveDisjunction() { - } -} -class BranchID { - constructor(parent, base) { - this.parent = parent; - this.base = base !== null && base !== void 0 ? base : this; - } - separatedFrom(other) { - var _a, _b; - if (this.base === other.base && this !== other) { - return true; - } - if (other.parent && this.separatedFrom(other.parent)) { - return true; - } - return (_b = (_a = this.parent) === null || _a === void 0 ? void 0 : _a.separatedFrom(other)) !== null && _b !== void 0 ? _b : false; - } - child() { - return new BranchID(this, null); - } - sibling() { - return new BranchID(this.parent, this.base); - } -} -class GroupSpecifiersAsES2025 { - constructor() { - this.branchID = new BranchID(null, null); - this.groupNames = new Map(); - } - clear() { - this.branchID = new BranchID(null, null); - this.groupNames.clear(); - } - isEmpty() { - return !this.groupNames.size; - } - enterDisjunction() { - this.branchID = this.branchID.child(); - } - enterAlternative(index) { - if (index === 0) { - return; - } - this.branchID = this.branchID.sibling(); - } - leaveDisjunction() { - this.branchID = this.branchID.parent; - } - hasInPattern(name) { - return this.groupNames.has(name); - } - hasInScope(name) { - const branches = this.groupNames.get(name); - if (!branches) { - return false; - } - for (const branch of branches) { - if (!branch.separatedFrom(this.branchID)) { - return true; - } - } - return false; - } - addToScope(name) { - const branches = this.groupNames.get(name); - if (branches) { - branches.push(this.branchID); - return; - } - this.groupNames.set(name, [this.branchID]); - } -} - -const legacyImpl = { - at(s, end, i) { - return i < end ? s.charCodeAt(i) : -1; - }, - width(c) { - return 1; - }, -}; -const unicodeImpl = { - at(s, end, i) { - return i < end ? s.codePointAt(i) : -1; - }, - width(c) { - return c > 0xffff ? 2 : 1; - }, -}; -class Reader { - constructor() { - this._impl = legacyImpl; - this._s = ""; - this._i = 0; - this._end = 0; - this._cp1 = -1; - this._w1 = 1; - this._cp2 = -1; - this._w2 = 1; - this._cp3 = -1; - this._w3 = 1; - this._cp4 = -1; - } - get source() { - return this._s; - } - get index() { - return this._i; - } - get currentCodePoint() { - return this._cp1; - } - get nextCodePoint() { - return this._cp2; - } - get nextCodePoint2() { - return this._cp3; - } - get nextCodePoint3() { - return this._cp4; - } - reset(source, start, end, uFlag) { - this._impl = uFlag ? unicodeImpl : legacyImpl; - this._s = source; - this._end = end; - this.rewind(start); - } - rewind(index) { - const impl = this._impl; - this._i = index; - this._cp1 = impl.at(this._s, this._end, index); - this._w1 = impl.width(this._cp1); - this._cp2 = impl.at(this._s, this._end, index + this._w1); - this._w2 = impl.width(this._cp2); - this._cp3 = impl.at(this._s, this._end, index + this._w1 + this._w2); - this._w3 = impl.width(this._cp3); - this._cp4 = impl.at(this._s, this._end, index + this._w1 + this._w2 + this._w3); - } - advance() { - if (this._cp1 !== -1) { - const impl = this._impl; - this._i += this._w1; - this._cp1 = this._cp2; - this._w1 = this._w2; - this._cp2 = this._cp3; - this._w2 = impl.width(this._cp2); - this._cp3 = this._cp4; - this._w3 = impl.width(this._cp3); - this._cp4 = impl.at(this._s, this._end, this._i + this._w1 + this._w2 + this._w3); - } - } - eat(cp) { - if (this._cp1 === cp) { - this.advance(); - return true; - } - return false; - } - eat2(cp1, cp2) { - if (this._cp1 === cp1 && this._cp2 === cp2) { - this.advance(); - this.advance(); - return true; - } - return false; - } - eat3(cp1, cp2, cp3) { - if (this._cp1 === cp1 && this._cp2 === cp2 && this._cp3 === cp3) { - this.advance(); - this.advance(); - this.advance(); - return true; - } - return false; - } -} - -class RegExpSyntaxError extends SyntaxError { - constructor(message, index) { - super(message); - this.index = index; - } -} -function newRegExpSyntaxError(srcCtx, flags, index, message) { - let source = ""; - if (srcCtx.kind === "literal") { - const literal = srcCtx.source.slice(srcCtx.start, srcCtx.end); - if (literal) { - source = `: ${literal}`; - } - } - else if (srcCtx.kind === "pattern") { - const pattern = srcCtx.source.slice(srcCtx.start, srcCtx.end); - const flagsText = `${flags.unicode ? "u" : ""}${flags.unicodeSets ? "v" : ""}`; - source = `: /${pattern}/${flagsText}`; - } - return new RegExpSyntaxError(`Invalid regular expression${source}: ${message}`, index); -} - -const SYNTAX_CHARACTER = new Set([ - CIRCUMFLEX_ACCENT, - DOLLAR_SIGN, - REVERSE_SOLIDUS, - FULL_STOP, - ASTERISK, - PLUS_SIGN, - QUESTION_MARK, - LEFT_PARENTHESIS, - RIGHT_PARENTHESIS, - LEFT_SQUARE_BRACKET, - RIGHT_SQUARE_BRACKET, - LEFT_CURLY_BRACKET, - RIGHT_CURLY_BRACKET, - VERTICAL_LINE, -]); -const CLASS_SET_RESERVED_DOUBLE_PUNCTUATOR_CHARACTER = new Set([ - AMPERSAND, - EXCLAMATION_MARK, - NUMBER_SIGN, - DOLLAR_SIGN, - PERCENT_SIGN, - ASTERISK, - PLUS_SIGN, - COMMA, - FULL_STOP, - COLON, - SEMICOLON, - LESS_THAN_SIGN, - EQUALS_SIGN, - GREATER_THAN_SIGN, - QUESTION_MARK, - COMMERCIAL_AT, - CIRCUMFLEX_ACCENT, - GRAVE_ACCENT, - TILDE, -]); -const CLASS_SET_SYNTAX_CHARACTER = new Set([ - LEFT_PARENTHESIS, - RIGHT_PARENTHESIS, - LEFT_SQUARE_BRACKET, - RIGHT_SQUARE_BRACKET, - LEFT_CURLY_BRACKET, - RIGHT_CURLY_BRACKET, - SOLIDUS, - HYPHEN_MINUS, - REVERSE_SOLIDUS, - VERTICAL_LINE, -]); -const CLASS_SET_RESERVED_PUNCTUATOR = new Set([ - AMPERSAND, - HYPHEN_MINUS, - EXCLAMATION_MARK, - NUMBER_SIGN, - PERCENT_SIGN, - COMMA, - COLON, - SEMICOLON, - LESS_THAN_SIGN, - EQUALS_SIGN, - GREATER_THAN_SIGN, - COMMERCIAL_AT, - GRAVE_ACCENT, - TILDE, -]); -function isSyntaxCharacter(cp) { - return SYNTAX_CHARACTER.has(cp); -} -function isClassSetReservedDoublePunctuatorCharacter(cp) { - return CLASS_SET_RESERVED_DOUBLE_PUNCTUATOR_CHARACTER.has(cp); -} -function isClassSetSyntaxCharacter(cp) { - return CLASS_SET_SYNTAX_CHARACTER.has(cp); -} -function isClassSetReservedPunctuator(cp) { - return CLASS_SET_RESERVED_PUNCTUATOR.has(cp); -} -function isIdentifierStartChar(cp) { - return isIdStart(cp) || cp === DOLLAR_SIGN || cp === LOW_LINE; -} -function isIdentifierPartChar(cp) { - return (isIdContinue(cp) || - cp === DOLLAR_SIGN || - cp === ZERO_WIDTH_NON_JOINER || - cp === ZERO_WIDTH_JOINER); -} -function isUnicodePropertyNameCharacter(cp) { - return isLatinLetter(cp) || cp === LOW_LINE; -} -function isUnicodePropertyValueCharacter(cp) { - return isUnicodePropertyNameCharacter(cp) || isDecimalDigit(cp); -} -class RegExpValidator { - constructor(options) { - this._reader = new Reader(); - this._unicodeMode = false; - this._unicodeSetsMode = false; - this._nFlag = false; - this._lastIntValue = 0; - this._lastRange = { - min: 0, - max: Number.POSITIVE_INFINITY, - }; - this._lastStrValue = ""; - this._lastAssertionIsQuantifiable = false; - this._numCapturingParens = 0; - this._backreferenceNames = new Set(); - this._srcCtx = null; - this._options = options !== null && options !== void 0 ? options : {}; - this._groupSpecifiers = - this.ecmaVersion >= 2025 - ? new GroupSpecifiersAsES2025() - : new GroupSpecifiersAsES2018(); - } - validateLiteral(source, start = 0, end = source.length) { - this._srcCtx = { source, start, end, kind: "literal" }; - this._unicodeSetsMode = this._unicodeMode = this._nFlag = false; - this.reset(source, start, end); - this.onLiteralEnter(start); - if (this.eat(SOLIDUS) && this.eatRegExpBody() && this.eat(SOLIDUS)) { - const flagStart = this.index; - const unicode = source.includes("u", flagStart); - const unicodeSets = source.includes("v", flagStart); - this.validateFlagsInternal(source, flagStart, end); - this.validatePatternInternal(source, start + 1, flagStart - 1, { - unicode, - unicodeSets, - }); - } - else if (start >= end) { - this.raise("Empty"); - } - else { - const c = String.fromCodePoint(this.currentCodePoint); - this.raise(`Unexpected character '${c}'`); - } - this.onLiteralLeave(start, end); - } - validateFlags(source, start = 0, end = source.length) { - this._srcCtx = { source, start, end, kind: "flags" }; - this.validateFlagsInternal(source, start, end); - } - validatePattern(source, start = 0, end = source.length, uFlagOrFlags = undefined) { - this._srcCtx = { source, start, end, kind: "pattern" }; - this.validatePatternInternal(source, start, end, uFlagOrFlags); - } - validatePatternInternal(source, start = 0, end = source.length, uFlagOrFlags = undefined) { - const mode = this._parseFlagsOptionToMode(uFlagOrFlags, end); - this._unicodeMode = mode.unicodeMode; - this._nFlag = mode.nFlag; - this._unicodeSetsMode = mode.unicodeSetsMode; - this.reset(source, start, end); - this.consumePattern(); - if (!this._nFlag && - this.ecmaVersion >= 2018 && - !this._groupSpecifiers.isEmpty()) { - this._nFlag = true; - this.rewind(start); - this.consumePattern(); - } - } - validateFlagsInternal(source, start, end) { - const existingFlags = new Set(); - let global = false; - let ignoreCase = false; - let multiline = false; - let sticky = false; - let unicode = false; - let dotAll = false; - let hasIndices = false; - let unicodeSets = false; - for (let i = start; i < end; ++i) { - const flag = source.charCodeAt(i); - if (existingFlags.has(flag)) { - this.raise(`Duplicated flag '${source[i]}'`, { index: start }); - } - existingFlags.add(flag); - if (flag === LATIN_SMALL_LETTER_G) { - global = true; - } - else if (flag === LATIN_SMALL_LETTER_I) { - ignoreCase = true; - } - else if (flag === LATIN_SMALL_LETTER_M) { - multiline = true; - } - else if (flag === LATIN_SMALL_LETTER_U && - this.ecmaVersion >= 2015) { - unicode = true; - } - else if (flag === LATIN_SMALL_LETTER_Y && - this.ecmaVersion >= 2015) { - sticky = true; - } - else if (flag === LATIN_SMALL_LETTER_S && - this.ecmaVersion >= 2018) { - dotAll = true; - } - else if (flag === LATIN_SMALL_LETTER_D && - this.ecmaVersion >= 2022) { - hasIndices = true; - } - else if (flag === LATIN_SMALL_LETTER_V && - this.ecmaVersion >= 2024) { - unicodeSets = true; - } - else { - this.raise(`Invalid flag '${source[i]}'`, { index: start }); - } - } - this.onRegExpFlags(start, end, { - global, - ignoreCase, - multiline, - unicode, - sticky, - dotAll, - hasIndices, - unicodeSets, - }); - } - _parseFlagsOptionToMode(uFlagOrFlags, sourceEnd) { - let unicode = false; - let unicodeSets = false; - if (uFlagOrFlags && this.ecmaVersion >= 2015) { - if (typeof uFlagOrFlags === "object") { - unicode = Boolean(uFlagOrFlags.unicode); - if (this.ecmaVersion >= 2024) { - unicodeSets = Boolean(uFlagOrFlags.unicodeSets); - } - } - else { - unicode = uFlagOrFlags; - } - } - if (unicode && unicodeSets) { - this.raise("Invalid regular expression flags", { - index: sourceEnd + 1, - unicode, - unicodeSets, - }); - } - const unicodeMode = unicode || unicodeSets; - const nFlag = (unicode && this.ecmaVersion >= 2018) || - unicodeSets || - Boolean(this._options.strict && this.ecmaVersion >= 2023); - const unicodeSetsMode = unicodeSets; - return { unicodeMode, nFlag, unicodeSetsMode }; - } - get strict() { - return Boolean(this._options.strict) || this._unicodeMode; - } - get ecmaVersion() { - var _a; - return (_a = this._options.ecmaVersion) !== null && _a !== void 0 ? _a : latestEcmaVersion; - } - onLiteralEnter(start) { - if (this._options.onLiteralEnter) { - this._options.onLiteralEnter(start); - } - } - onLiteralLeave(start, end) { - if (this._options.onLiteralLeave) { - this._options.onLiteralLeave(start, end); - } - } - onRegExpFlags(start, end, flags) { - if (this._options.onRegExpFlags) { - this._options.onRegExpFlags(start, end, flags); - } - if (this._options.onFlags) { - this._options.onFlags(start, end, flags.global, flags.ignoreCase, flags.multiline, flags.unicode, flags.sticky, flags.dotAll, flags.hasIndices); - } - } - onPatternEnter(start) { - if (this._options.onPatternEnter) { - this._options.onPatternEnter(start); - } - } - onPatternLeave(start, end) { - if (this._options.onPatternLeave) { - this._options.onPatternLeave(start, end); - } - } - onDisjunctionEnter(start) { - if (this._options.onDisjunctionEnter) { - this._options.onDisjunctionEnter(start); - } - } - onDisjunctionLeave(start, end) { - if (this._options.onDisjunctionLeave) { - this._options.onDisjunctionLeave(start, end); - } - } - onAlternativeEnter(start, index) { - if (this._options.onAlternativeEnter) { - this._options.onAlternativeEnter(start, index); - } - } - onAlternativeLeave(start, end, index) { - if (this._options.onAlternativeLeave) { - this._options.onAlternativeLeave(start, end, index); - } - } - onGroupEnter(start) { - if (this._options.onGroupEnter) { - this._options.onGroupEnter(start); - } - } - onGroupLeave(start, end) { - if (this._options.onGroupLeave) { - this._options.onGroupLeave(start, end); - } - } - onCapturingGroupEnter(start, name) { - if (this._options.onCapturingGroupEnter) { - this._options.onCapturingGroupEnter(start, name); - } - } - onCapturingGroupLeave(start, end, name) { - if (this._options.onCapturingGroupLeave) { - this._options.onCapturingGroupLeave(start, end, name); - } - } - onQuantifier(start, end, min, max, greedy) { - if (this._options.onQuantifier) { - this._options.onQuantifier(start, end, min, max, greedy); - } - } - onLookaroundAssertionEnter(start, kind, negate) { - if (this._options.onLookaroundAssertionEnter) { - this._options.onLookaroundAssertionEnter(start, kind, negate); - } - } - onLookaroundAssertionLeave(start, end, kind, negate) { - if (this._options.onLookaroundAssertionLeave) { - this._options.onLookaroundAssertionLeave(start, end, kind, negate); - } - } - onEdgeAssertion(start, end, kind) { - if (this._options.onEdgeAssertion) { - this._options.onEdgeAssertion(start, end, kind); - } - } - onWordBoundaryAssertion(start, end, kind, negate) { - if (this._options.onWordBoundaryAssertion) { - this._options.onWordBoundaryAssertion(start, end, kind, negate); - } - } - onAnyCharacterSet(start, end, kind) { - if (this._options.onAnyCharacterSet) { - this._options.onAnyCharacterSet(start, end, kind); - } - } - onEscapeCharacterSet(start, end, kind, negate) { - if (this._options.onEscapeCharacterSet) { - this._options.onEscapeCharacterSet(start, end, kind, negate); - } - } - onUnicodePropertyCharacterSet(start, end, kind, key, value, negate, strings) { - if (this._options.onUnicodePropertyCharacterSet) { - this._options.onUnicodePropertyCharacterSet(start, end, kind, key, value, negate, strings); - } - } - onCharacter(start, end, value) { - if (this._options.onCharacter) { - this._options.onCharacter(start, end, value); - } - } - onBackreference(start, end, ref) { - if (this._options.onBackreference) { - this._options.onBackreference(start, end, ref); - } - } - onCharacterClassEnter(start, negate, unicodeSets) { - if (this._options.onCharacterClassEnter) { - this._options.onCharacterClassEnter(start, negate, unicodeSets); - } - } - onCharacterClassLeave(start, end, negate) { - if (this._options.onCharacterClassLeave) { - this._options.onCharacterClassLeave(start, end, negate); - } - } - onCharacterClassRange(start, end, min, max) { - if (this._options.onCharacterClassRange) { - this._options.onCharacterClassRange(start, end, min, max); - } - } - onClassIntersection(start, end) { - if (this._options.onClassIntersection) { - this._options.onClassIntersection(start, end); - } - } - onClassSubtraction(start, end) { - if (this._options.onClassSubtraction) { - this._options.onClassSubtraction(start, end); - } - } - onClassStringDisjunctionEnter(start) { - if (this._options.onClassStringDisjunctionEnter) { - this._options.onClassStringDisjunctionEnter(start); - } - } - onClassStringDisjunctionLeave(start, end) { - if (this._options.onClassStringDisjunctionLeave) { - this._options.onClassStringDisjunctionLeave(start, end); - } - } - onStringAlternativeEnter(start, index) { - if (this._options.onStringAlternativeEnter) { - this._options.onStringAlternativeEnter(start, index); - } - } - onStringAlternativeLeave(start, end, index) { - if (this._options.onStringAlternativeLeave) { - this._options.onStringAlternativeLeave(start, end, index); - } - } - get index() { - return this._reader.index; - } - get currentCodePoint() { - return this._reader.currentCodePoint; - } - get nextCodePoint() { - return this._reader.nextCodePoint; - } - get nextCodePoint2() { - return this._reader.nextCodePoint2; - } - get nextCodePoint3() { - return this._reader.nextCodePoint3; - } - reset(source, start, end) { - this._reader.reset(source, start, end, this._unicodeMode); - } - rewind(index) { - this._reader.rewind(index); - } - advance() { - this._reader.advance(); - } - eat(cp) { - return this._reader.eat(cp); - } - eat2(cp1, cp2) { - return this._reader.eat2(cp1, cp2); - } - eat3(cp1, cp2, cp3) { - return this._reader.eat3(cp1, cp2, cp3); - } - raise(message, context) { - var _a, _b, _c; - throw newRegExpSyntaxError(this._srcCtx, { - unicode: (_a = context === null || context === void 0 ? void 0 : context.unicode) !== null && _a !== void 0 ? _a : (this._unicodeMode && !this._unicodeSetsMode), - unicodeSets: (_b = context === null || context === void 0 ? void 0 : context.unicodeSets) !== null && _b !== void 0 ? _b : this._unicodeSetsMode, - }, (_c = context === null || context === void 0 ? void 0 : context.index) !== null && _c !== void 0 ? _c : this.index, message); - } - eatRegExpBody() { - const start = this.index; - let inClass = false; - let escaped = false; - for (;;) { - const cp = this.currentCodePoint; - if (cp === -1 || isLineTerminator(cp)) { - const kind = inClass ? "character class" : "regular expression"; - this.raise(`Unterminated ${kind}`); - } - if (escaped) { - escaped = false; - } - else if (cp === REVERSE_SOLIDUS) { - escaped = true; - } - else if (cp === LEFT_SQUARE_BRACKET) { - inClass = true; - } - else if (cp === RIGHT_SQUARE_BRACKET) { - inClass = false; - } - else if ((cp === SOLIDUS && !inClass) || - (cp === ASTERISK && this.index === start)) { - break; - } - this.advance(); - } - return this.index !== start; - } - consumePattern() { - const start = this.index; - this._numCapturingParens = this.countCapturingParens(); - this._groupSpecifiers.clear(); - this._backreferenceNames.clear(); - this.onPatternEnter(start); - this.consumeDisjunction(); - const cp = this.currentCodePoint; - if (this.currentCodePoint !== -1) { - if (cp === RIGHT_PARENTHESIS) { - this.raise("Unmatched ')'"); - } - if (cp === REVERSE_SOLIDUS) { - this.raise("\\ at end of pattern"); - } - if (cp === RIGHT_SQUARE_BRACKET || cp === RIGHT_CURLY_BRACKET) { - this.raise("Lone quantifier brackets"); - } - const c = String.fromCodePoint(cp); - this.raise(`Unexpected character '${c}'`); - } - for (const name of this._backreferenceNames) { - if (!this._groupSpecifiers.hasInPattern(name)) { - this.raise("Invalid named capture referenced"); - } - } - this.onPatternLeave(start, this.index); - } - countCapturingParens() { - const start = this.index; - let inClass = false; - let escaped = false; - let count = 0; - let cp = 0; - while ((cp = this.currentCodePoint) !== -1) { - if (escaped) { - escaped = false; - } - else if (cp === REVERSE_SOLIDUS) { - escaped = true; - } - else if (cp === LEFT_SQUARE_BRACKET) { - inClass = true; - } - else if (cp === RIGHT_SQUARE_BRACKET) { - inClass = false; - } - else if (cp === LEFT_PARENTHESIS && - !inClass && - (this.nextCodePoint !== QUESTION_MARK || - (this.nextCodePoint2 === LESS_THAN_SIGN && - this.nextCodePoint3 !== EQUALS_SIGN && - this.nextCodePoint3 !== EXCLAMATION_MARK))) { - count += 1; - } - this.advance(); - } - this.rewind(start); - return count; - } - consumeDisjunction() { - const start = this.index; - let i = 0; - this._groupSpecifiers.enterDisjunction(); - this.onDisjunctionEnter(start); - do { - this.consumeAlternative(i++); - } while (this.eat(VERTICAL_LINE)); - if (this.consumeQuantifier(true)) { - this.raise("Nothing to repeat"); - } - if (this.eat(LEFT_CURLY_BRACKET)) { - this.raise("Lone quantifier brackets"); - } - this.onDisjunctionLeave(start, this.index); - this._groupSpecifiers.leaveDisjunction(); - } - consumeAlternative(i) { - const start = this.index; - this._groupSpecifiers.enterAlternative(i); - this.onAlternativeEnter(start, i); - while (this.currentCodePoint !== -1 && this.consumeTerm()) { - } - this.onAlternativeLeave(start, this.index, i); - } - consumeTerm() { - if (this._unicodeMode || this.strict) { - return (this.consumeAssertion() || - (this.consumeAtom() && this.consumeOptionalQuantifier())); - } - return ((this.consumeAssertion() && - (!this._lastAssertionIsQuantifiable || - this.consumeOptionalQuantifier())) || - (this.consumeExtendedAtom() && this.consumeOptionalQuantifier())); - } - consumeOptionalQuantifier() { - this.consumeQuantifier(); - return true; - } - consumeAssertion() { - const start = this.index; - this._lastAssertionIsQuantifiable = false; - if (this.eat(CIRCUMFLEX_ACCENT)) { - this.onEdgeAssertion(start, this.index, "start"); - return true; - } - if (this.eat(DOLLAR_SIGN)) { - this.onEdgeAssertion(start, this.index, "end"); - return true; - } - if (this.eat2(REVERSE_SOLIDUS, LATIN_CAPITAL_LETTER_B)) { - this.onWordBoundaryAssertion(start, this.index, "word", true); - return true; - } - if (this.eat2(REVERSE_SOLIDUS, LATIN_SMALL_LETTER_B)) { - this.onWordBoundaryAssertion(start, this.index, "word", false); - return true; - } - if (this.eat2(LEFT_PARENTHESIS, QUESTION_MARK)) { - const lookbehind = this.ecmaVersion >= 2018 && this.eat(LESS_THAN_SIGN); - let negate = false; - if (this.eat(EQUALS_SIGN) || - (negate = this.eat(EXCLAMATION_MARK))) { - const kind = lookbehind ? "lookbehind" : "lookahead"; - this.onLookaroundAssertionEnter(start, kind, negate); - this.consumeDisjunction(); - if (!this.eat(RIGHT_PARENTHESIS)) { - this.raise("Unterminated group"); - } - this._lastAssertionIsQuantifiable = !lookbehind && !this.strict; - this.onLookaroundAssertionLeave(start, this.index, kind, negate); - return true; - } - this.rewind(start); - } - return false; - } - consumeQuantifier(noConsume = false) { - const start = this.index; - let min = 0; - let max = 0; - let greedy = false; - if (this.eat(ASTERISK)) { - min = 0; - max = Number.POSITIVE_INFINITY; - } - else if (this.eat(PLUS_SIGN)) { - min = 1; - max = Number.POSITIVE_INFINITY; - } - else if (this.eat(QUESTION_MARK)) { - min = 0; - max = 1; - } - else if (this.eatBracedQuantifier(noConsume)) { - ({ min, max } = this._lastRange); - } - else { - return false; - } - greedy = !this.eat(QUESTION_MARK); - if (!noConsume) { - this.onQuantifier(start, this.index, min, max, greedy); - } - return true; - } - eatBracedQuantifier(noError) { - const start = this.index; - if (this.eat(LEFT_CURLY_BRACKET)) { - if (this.eatDecimalDigits()) { - const min = this._lastIntValue; - let max = min; - if (this.eat(COMMA)) { - max = this.eatDecimalDigits() - ? this._lastIntValue - : Number.POSITIVE_INFINITY; - } - if (this.eat(RIGHT_CURLY_BRACKET)) { - if (!noError && max < min) { - this.raise("numbers out of order in {} quantifier"); - } - this._lastRange = { min, max }; - return true; - } - } - if (!noError && (this._unicodeMode || this.strict)) { - this.raise("Incomplete quantifier"); - } - this.rewind(start); - } - return false; - } - consumeAtom() { - return (this.consumePatternCharacter() || - this.consumeDot() || - this.consumeReverseSolidusAtomEscape() || - Boolean(this.consumeCharacterClass()) || - this.consumeUncapturingGroup() || - this.consumeCapturingGroup()); - } - consumeDot() { - if (this.eat(FULL_STOP)) { - this.onAnyCharacterSet(this.index - 1, this.index, "any"); - return true; - } - return false; - } - consumeReverseSolidusAtomEscape() { - const start = this.index; - if (this.eat(REVERSE_SOLIDUS)) { - if (this.consumeAtomEscape()) { - return true; - } - this.rewind(start); - } - return false; - } - consumeUncapturingGroup() { - const start = this.index; - if (this.eat3(LEFT_PARENTHESIS, QUESTION_MARK, COLON)) { - this.onGroupEnter(start); - this.consumeDisjunction(); - if (!this.eat(RIGHT_PARENTHESIS)) { - this.raise("Unterminated group"); - } - this.onGroupLeave(start, this.index); - return true; - } - return false; - } - consumeCapturingGroup() { - const start = this.index; - if (this.eat(LEFT_PARENTHESIS)) { - let name = null; - if (this.ecmaVersion >= 2018) { - if (this.consumeGroupSpecifier()) { - name = this._lastStrValue; - } - } - else if (this.currentCodePoint === QUESTION_MARK) { - this.raise("Invalid group"); - } - this.onCapturingGroupEnter(start, name); - this.consumeDisjunction(); - if (!this.eat(RIGHT_PARENTHESIS)) { - this.raise("Unterminated group"); - } - this.onCapturingGroupLeave(start, this.index, name); - return true; - } - return false; - } - consumeExtendedAtom() { - return (this.consumeDot() || - this.consumeReverseSolidusAtomEscape() || - this.consumeReverseSolidusFollowedByC() || - Boolean(this.consumeCharacterClass()) || - this.consumeUncapturingGroup() || - this.consumeCapturingGroup() || - this.consumeInvalidBracedQuantifier() || - this.consumeExtendedPatternCharacter()); - } - consumeReverseSolidusFollowedByC() { - const start = this.index; - if (this.currentCodePoint === REVERSE_SOLIDUS && - this.nextCodePoint === LATIN_SMALL_LETTER_C) { - this._lastIntValue = this.currentCodePoint; - this.advance(); - this.onCharacter(start, this.index, REVERSE_SOLIDUS); - return true; - } - return false; - } - consumeInvalidBracedQuantifier() { - if (this.eatBracedQuantifier(true)) { - this.raise("Nothing to repeat"); - } - return false; - } - consumePatternCharacter() { - const start = this.index; - const cp = this.currentCodePoint; - if (cp !== -1 && !isSyntaxCharacter(cp)) { - this.advance(); - this.onCharacter(start, this.index, cp); - return true; - } - return false; - } - consumeExtendedPatternCharacter() { - const start = this.index; - const cp = this.currentCodePoint; - if (cp !== -1 && - cp !== CIRCUMFLEX_ACCENT && - cp !== DOLLAR_SIGN && - cp !== REVERSE_SOLIDUS && - cp !== FULL_STOP && - cp !== ASTERISK && - cp !== PLUS_SIGN && - cp !== QUESTION_MARK && - cp !== LEFT_PARENTHESIS && - cp !== RIGHT_PARENTHESIS && - cp !== LEFT_SQUARE_BRACKET && - cp !== VERTICAL_LINE) { - this.advance(); - this.onCharacter(start, this.index, cp); - return true; - } - return false; - } - consumeGroupSpecifier() { - if (this.eat(QUESTION_MARK)) { - if (this.eatGroupName()) { - if (!this._groupSpecifiers.hasInScope(this._lastStrValue)) { - this._groupSpecifiers.addToScope(this._lastStrValue); - return true; - } - this.raise("Duplicate capture group name"); - } - this.raise("Invalid group"); - } - return false; - } - consumeAtomEscape() { - if (this.consumeBackreference() || - this.consumeCharacterClassEscape() || - this.consumeCharacterEscape() || - (this._nFlag && this.consumeKGroupName())) { - return true; - } - if (this.strict || this._unicodeMode) { - this.raise("Invalid escape"); - } - return false; - } - consumeBackreference() { - const start = this.index; - if (this.eatDecimalEscape()) { - const n = this._lastIntValue; - if (n <= this._numCapturingParens) { - this.onBackreference(start - 1, this.index, n); - return true; - } - if (this.strict || this._unicodeMode) { - this.raise("Invalid escape"); - } - this.rewind(start); - } - return false; - } - consumeCharacterClassEscape() { - var _a; - const start = this.index; - if (this.eat(LATIN_SMALL_LETTER_D)) { - this._lastIntValue = -1; - this.onEscapeCharacterSet(start - 1, this.index, "digit", false); - return {}; - } - if (this.eat(LATIN_CAPITAL_LETTER_D)) { - this._lastIntValue = -1; - this.onEscapeCharacterSet(start - 1, this.index, "digit", true); - return {}; - } - if (this.eat(LATIN_SMALL_LETTER_S)) { - this._lastIntValue = -1; - this.onEscapeCharacterSet(start - 1, this.index, "space", false); - return {}; - } - if (this.eat(LATIN_CAPITAL_LETTER_S)) { - this._lastIntValue = -1; - this.onEscapeCharacterSet(start - 1, this.index, "space", true); - return {}; - } - if (this.eat(LATIN_SMALL_LETTER_W)) { - this._lastIntValue = -1; - this.onEscapeCharacterSet(start - 1, this.index, "word", false); - return {}; - } - if (this.eat(LATIN_CAPITAL_LETTER_W)) { - this._lastIntValue = -1; - this.onEscapeCharacterSet(start - 1, this.index, "word", true); - return {}; - } - let negate = false; - if (this._unicodeMode && - this.ecmaVersion >= 2018 && - (this.eat(LATIN_SMALL_LETTER_P) || - (negate = this.eat(LATIN_CAPITAL_LETTER_P)))) { - this._lastIntValue = -1; - let result = null; - if (this.eat(LEFT_CURLY_BRACKET) && - (result = this.eatUnicodePropertyValueExpression()) && - this.eat(RIGHT_CURLY_BRACKET)) { - if (negate && result.strings) { - this.raise("Invalid property name"); - } - this.onUnicodePropertyCharacterSet(start - 1, this.index, "property", result.key, result.value, negate, (_a = result.strings) !== null && _a !== void 0 ? _a : false); - return { mayContainStrings: result.strings }; - } - this.raise("Invalid property name"); - } - return null; - } - consumeCharacterEscape() { - const start = this.index; - if (this.eatControlEscape() || - this.eatCControlLetter() || - this.eatZero() || - this.eatHexEscapeSequence() || - this.eatRegExpUnicodeEscapeSequence() || - (!this.strict && - !this._unicodeMode && - this.eatLegacyOctalEscapeSequence()) || - this.eatIdentityEscape()) { - this.onCharacter(start - 1, this.index, this._lastIntValue); - return true; - } - return false; - } - consumeKGroupName() { - const start = this.index; - if (this.eat(LATIN_SMALL_LETTER_K)) { - if (this.eatGroupName()) { - const groupName = this._lastStrValue; - this._backreferenceNames.add(groupName); - this.onBackreference(start - 1, this.index, groupName); - return true; - } - this.raise("Invalid named reference"); - } - return false; - } - consumeCharacterClass() { - const start = this.index; - if (this.eat(LEFT_SQUARE_BRACKET)) { - const negate = this.eat(CIRCUMFLEX_ACCENT); - this.onCharacterClassEnter(start, negate, this._unicodeSetsMode); - const result = this.consumeClassContents(); - if (!this.eat(RIGHT_SQUARE_BRACKET)) { - if (this.currentCodePoint === -1) { - this.raise("Unterminated character class"); - } - this.raise("Invalid character in character class"); - } - if (negate && result.mayContainStrings) { - this.raise("Negated character class may contain strings"); - } - this.onCharacterClassLeave(start, this.index, negate); - return result; - } - return null; - } - consumeClassContents() { - if (this._unicodeSetsMode) { - if (this.currentCodePoint === RIGHT_SQUARE_BRACKET) { - return {}; - } - const result = this.consumeClassSetExpression(); - return result; - } - const strict = this.strict || this._unicodeMode; - for (;;) { - const rangeStart = this.index; - if (!this.consumeClassAtom()) { - break; - } - const min = this._lastIntValue; - if (!this.eat(HYPHEN_MINUS)) { - continue; - } - this.onCharacter(this.index - 1, this.index, HYPHEN_MINUS); - if (!this.consumeClassAtom()) { - break; - } - const max = this._lastIntValue; - if (min === -1 || max === -1) { - if (strict) { - this.raise("Invalid character class"); - } - continue; - } - if (min > max) { - this.raise("Range out of order in character class"); - } - this.onCharacterClassRange(rangeStart, this.index, min, max); - } - return {}; - } - consumeClassAtom() { - const start = this.index; - const cp = this.currentCodePoint; - if (cp !== -1 && - cp !== REVERSE_SOLIDUS && - cp !== RIGHT_SQUARE_BRACKET) { - this.advance(); - this._lastIntValue = cp; - this.onCharacter(start, this.index, this._lastIntValue); - return true; - } - if (this.eat(REVERSE_SOLIDUS)) { - if (this.consumeClassEscape()) { - return true; - } - if (!this.strict && - this.currentCodePoint === LATIN_SMALL_LETTER_C) { - this._lastIntValue = REVERSE_SOLIDUS; - this.onCharacter(start, this.index, this._lastIntValue); - return true; - } - if (this.strict || this._unicodeMode) { - this.raise("Invalid escape"); - } - this.rewind(start); - } - return false; - } - consumeClassEscape() { - const start = this.index; - if (this.eat(LATIN_SMALL_LETTER_B)) { - this._lastIntValue = BACKSPACE; - this.onCharacter(start - 1, this.index, this._lastIntValue); - return true; - } - if (this._unicodeMode && this.eat(HYPHEN_MINUS)) { - this._lastIntValue = HYPHEN_MINUS; - this.onCharacter(start - 1, this.index, this._lastIntValue); - return true; - } - let cp = 0; - if (!this.strict && - !this._unicodeMode && - this.currentCodePoint === LATIN_SMALL_LETTER_C && - (isDecimalDigit((cp = this.nextCodePoint)) || cp === LOW_LINE)) { - this.advance(); - this.advance(); - this._lastIntValue = cp % 0x20; - this.onCharacter(start - 1, this.index, this._lastIntValue); - return true; - } - return (Boolean(this.consumeCharacterClassEscape()) || - this.consumeCharacterEscape()); - } - consumeClassSetExpression() { - const start = this.index; - let mayContainStrings = false; - let result = null; - if (this.consumeClassSetCharacter()) { - if (this.consumeClassSetRangeFromOperator(start)) { - this.consumeClassUnionRight({}); - return {}; - } - mayContainStrings = false; - } - else if ((result = this.consumeClassSetOperand())) { - mayContainStrings = result.mayContainStrings; - } - else { - const cp = this.currentCodePoint; - if (cp === REVERSE_SOLIDUS) { - this.advance(); - this.raise("Invalid escape"); - } - if (cp === this.nextCodePoint && - isClassSetReservedDoublePunctuatorCharacter(cp)) { - this.raise("Invalid set operation in character class"); - } - this.raise("Invalid character in character class"); - } - if (this.eat2(AMPERSAND, AMPERSAND)) { - while (this.currentCodePoint !== AMPERSAND && - (result = this.consumeClassSetOperand())) { - this.onClassIntersection(start, this.index); - if (!result.mayContainStrings) { - mayContainStrings = false; - } - if (this.eat2(AMPERSAND, AMPERSAND)) { - continue; - } - return { mayContainStrings }; - } - this.raise("Invalid character in character class"); - } - if (this.eat2(HYPHEN_MINUS, HYPHEN_MINUS)) { - while (this.consumeClassSetOperand()) { - this.onClassSubtraction(start, this.index); - if (this.eat2(HYPHEN_MINUS, HYPHEN_MINUS)) { - continue; - } - return { mayContainStrings }; - } - this.raise("Invalid character in character class"); - } - return this.consumeClassUnionRight({ mayContainStrings }); - } - consumeClassUnionRight(leftResult) { - let mayContainStrings = leftResult.mayContainStrings; - for (;;) { - const start = this.index; - if (this.consumeClassSetCharacter()) { - this.consumeClassSetRangeFromOperator(start); - continue; - } - const result = this.consumeClassSetOperand(); - if (result) { - if (result.mayContainStrings) { - mayContainStrings = true; - } - continue; - } - break; - } - return { mayContainStrings }; - } - consumeClassSetRangeFromOperator(start) { - const currentStart = this.index; - const min = this._lastIntValue; - if (this.eat(HYPHEN_MINUS)) { - if (this.consumeClassSetCharacter()) { - const max = this._lastIntValue; - if (min === -1 || max === -1) { - this.raise("Invalid character class"); - } - if (min > max) { - this.raise("Range out of order in character class"); - } - this.onCharacterClassRange(start, this.index, min, max); - return true; - } - this.rewind(currentStart); - } - return false; - } - consumeClassSetOperand() { - let result = null; - if ((result = this.consumeNestedClass())) { - return result; - } - if ((result = this.consumeClassStringDisjunction())) { - return result; - } - if (this.consumeClassSetCharacter()) { - return {}; - } - return null; - } - consumeNestedClass() { - const start = this.index; - if (this.eat(LEFT_SQUARE_BRACKET)) { - const negate = this.eat(CIRCUMFLEX_ACCENT); - this.onCharacterClassEnter(start, negate, true); - const result = this.consumeClassContents(); - if (!this.eat(RIGHT_SQUARE_BRACKET)) { - this.raise("Unterminated character class"); - } - if (negate && result.mayContainStrings) { - this.raise("Negated character class may contain strings"); - } - this.onCharacterClassLeave(start, this.index, negate); - return result; - } - if (this.eat(REVERSE_SOLIDUS)) { - const result = this.consumeCharacterClassEscape(); - if (result) { - return result; - } - this.rewind(start); - } - return null; - } - consumeClassStringDisjunction() { - const start = this.index; - if (this.eat3(REVERSE_SOLIDUS, LATIN_SMALL_LETTER_Q, LEFT_CURLY_BRACKET)) { - this.onClassStringDisjunctionEnter(start); - let i = 0; - let mayContainStrings = false; - do { - if (this.consumeClassString(i++).mayContainStrings) { - mayContainStrings = true; - } - } while (this.eat(VERTICAL_LINE)); - if (this.eat(RIGHT_CURLY_BRACKET)) { - this.onClassStringDisjunctionLeave(start, this.index); - return { mayContainStrings }; - } - this.raise("Unterminated class string disjunction"); - } - return null; - } - consumeClassString(i) { - const start = this.index; - let count = 0; - this.onStringAlternativeEnter(start, i); - while (this.currentCodePoint !== -1 && - this.consumeClassSetCharacter()) { - count++; - } - this.onStringAlternativeLeave(start, this.index, i); - return { mayContainStrings: count !== 1 }; - } - consumeClassSetCharacter() { - const start = this.index; - const cp = this.currentCodePoint; - if (cp !== this.nextCodePoint || - !isClassSetReservedDoublePunctuatorCharacter(cp)) { - if (cp !== -1 && !isClassSetSyntaxCharacter(cp)) { - this._lastIntValue = cp; - this.advance(); - this.onCharacter(start, this.index, this._lastIntValue); - return true; - } - } - if (this.eat(REVERSE_SOLIDUS)) { - if (this.consumeCharacterEscape()) { - return true; - } - if (isClassSetReservedPunctuator(this.currentCodePoint)) { - this._lastIntValue = this.currentCodePoint; - this.advance(); - this.onCharacter(start, this.index, this._lastIntValue); - return true; - } - if (this.eat(LATIN_SMALL_LETTER_B)) { - this._lastIntValue = BACKSPACE; - this.onCharacter(start, this.index, this._lastIntValue); - return true; - } - this.rewind(start); - } - return false; - } - eatGroupName() { - if (this.eat(LESS_THAN_SIGN)) { - if (this.eatRegExpIdentifierName() && this.eat(GREATER_THAN_SIGN)) { - return true; - } - this.raise("Invalid capture group name"); - } - return false; - } - eatRegExpIdentifierName() { - if (this.eatRegExpIdentifierStart()) { - this._lastStrValue = String.fromCodePoint(this._lastIntValue); - while (this.eatRegExpIdentifierPart()) { - this._lastStrValue += String.fromCodePoint(this._lastIntValue); - } - return true; - } - return false; - } - eatRegExpIdentifierStart() { - const start = this.index; - const forceUFlag = !this._unicodeMode && this.ecmaVersion >= 2020; - let cp = this.currentCodePoint; - this.advance(); - if (cp === REVERSE_SOLIDUS && - this.eatRegExpUnicodeEscapeSequence(forceUFlag)) { - cp = this._lastIntValue; - } - else if (forceUFlag && - isLeadSurrogate(cp) && - isTrailSurrogate(this.currentCodePoint)) { - cp = combineSurrogatePair(cp, this.currentCodePoint); - this.advance(); - } - if (isIdentifierStartChar(cp)) { - this._lastIntValue = cp; - return true; - } - if (this.index !== start) { - this.rewind(start); - } - return false; - } - eatRegExpIdentifierPart() { - const start = this.index; - const forceUFlag = !this._unicodeMode && this.ecmaVersion >= 2020; - let cp = this.currentCodePoint; - this.advance(); - if (cp === REVERSE_SOLIDUS && - this.eatRegExpUnicodeEscapeSequence(forceUFlag)) { - cp = this._lastIntValue; - } - else if (forceUFlag && - isLeadSurrogate(cp) && - isTrailSurrogate(this.currentCodePoint)) { - cp = combineSurrogatePair(cp, this.currentCodePoint); - this.advance(); - } - if (isIdentifierPartChar(cp)) { - this._lastIntValue = cp; - return true; - } - if (this.index !== start) { - this.rewind(start); - } - return false; - } - eatCControlLetter() { - const start = this.index; - if (this.eat(LATIN_SMALL_LETTER_C)) { - if (this.eatControlLetter()) { - return true; - } - this.rewind(start); - } - return false; - } - eatZero() { - if (this.currentCodePoint === DIGIT_ZERO && - !isDecimalDigit(this.nextCodePoint)) { - this._lastIntValue = 0; - this.advance(); - return true; - } - return false; - } - eatControlEscape() { - if (this.eat(LATIN_SMALL_LETTER_F)) { - this._lastIntValue = FORM_FEED; - return true; - } - if (this.eat(LATIN_SMALL_LETTER_N)) { - this._lastIntValue = LINE_FEED; - return true; - } - if (this.eat(LATIN_SMALL_LETTER_R)) { - this._lastIntValue = CARRIAGE_RETURN; - return true; - } - if (this.eat(LATIN_SMALL_LETTER_T)) { - this._lastIntValue = CHARACTER_TABULATION; - return true; - } - if (this.eat(LATIN_SMALL_LETTER_V)) { - this._lastIntValue = LINE_TABULATION; - return true; - } - return false; - } - eatControlLetter() { - const cp = this.currentCodePoint; - if (isLatinLetter(cp)) { - this.advance(); - this._lastIntValue = cp % 0x20; - return true; - } - return false; - } - eatRegExpUnicodeEscapeSequence(forceUFlag = false) { - const start = this.index; - const uFlag = forceUFlag || this._unicodeMode; - if (this.eat(LATIN_SMALL_LETTER_U)) { - if ((uFlag && this.eatRegExpUnicodeSurrogatePairEscape()) || - this.eatFixedHexDigits(4) || - (uFlag && this.eatRegExpUnicodeCodePointEscape())) { - return true; - } - if (this.strict || uFlag) { - this.raise("Invalid unicode escape"); - } - this.rewind(start); - } - return false; - } - eatRegExpUnicodeSurrogatePairEscape() { - const start = this.index; - if (this.eatFixedHexDigits(4)) { - const lead = this._lastIntValue; - if (isLeadSurrogate(lead) && - this.eat(REVERSE_SOLIDUS) && - this.eat(LATIN_SMALL_LETTER_U) && - this.eatFixedHexDigits(4)) { - const trail = this._lastIntValue; - if (isTrailSurrogate(trail)) { - this._lastIntValue = combineSurrogatePair(lead, trail); - return true; - } - } - this.rewind(start); - } - return false; - } - eatRegExpUnicodeCodePointEscape() { - const start = this.index; - if (this.eat(LEFT_CURLY_BRACKET) && - this.eatHexDigits() && - this.eat(RIGHT_CURLY_BRACKET) && - isValidUnicode(this._lastIntValue)) { - return true; - } - this.rewind(start); - return false; - } - eatIdentityEscape() { - const cp = this.currentCodePoint; - if (this.isValidIdentityEscape(cp)) { - this._lastIntValue = cp; - this.advance(); - return true; - } - return false; - } - isValidIdentityEscape(cp) { - if (cp === -1) { - return false; - } - if (this._unicodeMode) { - return isSyntaxCharacter(cp) || cp === SOLIDUS; - } - if (this.strict) { - return !isIdContinue(cp); - } - if (this._nFlag) { - return !(cp === LATIN_SMALL_LETTER_C || cp === LATIN_SMALL_LETTER_K); - } - return cp !== LATIN_SMALL_LETTER_C; - } - eatDecimalEscape() { - this._lastIntValue = 0; - let cp = this.currentCodePoint; - if (cp >= DIGIT_ONE && cp <= DIGIT_NINE) { - do { - this._lastIntValue = 10 * this._lastIntValue + (cp - DIGIT_ZERO); - this.advance(); - } while ((cp = this.currentCodePoint) >= DIGIT_ZERO && - cp <= DIGIT_NINE); - return true; - } - return false; - } - eatUnicodePropertyValueExpression() { - const start = this.index; - if (this.eatUnicodePropertyName() && this.eat(EQUALS_SIGN)) { - const key = this._lastStrValue; - if (this.eatUnicodePropertyValue()) { - const value = this._lastStrValue; - if (isValidUnicodeProperty(this.ecmaVersion, key, value)) { - return { - key, - value: value || null, - }; - } - this.raise("Invalid property name"); - } - } - this.rewind(start); - if (this.eatLoneUnicodePropertyNameOrValue()) { - const nameOrValue = this._lastStrValue; - if (isValidUnicodeProperty(this.ecmaVersion, "General_Category", nameOrValue)) { - return { - key: "General_Category", - value: nameOrValue || null, - }; - } - if (isValidLoneUnicodeProperty(this.ecmaVersion, nameOrValue)) { - return { - key: nameOrValue, - value: null, - }; - } - if (this._unicodeSetsMode && - isValidLoneUnicodePropertyOfString(this.ecmaVersion, nameOrValue)) { - return { - key: nameOrValue, - value: null, - strings: true, - }; - } - this.raise("Invalid property name"); - } - return null; - } - eatUnicodePropertyName() { - this._lastStrValue = ""; - while (isUnicodePropertyNameCharacter(this.currentCodePoint)) { - this._lastStrValue += String.fromCodePoint(this.currentCodePoint); - this.advance(); - } - return this._lastStrValue !== ""; - } - eatUnicodePropertyValue() { - this._lastStrValue = ""; - while (isUnicodePropertyValueCharacter(this.currentCodePoint)) { - this._lastStrValue += String.fromCodePoint(this.currentCodePoint); - this.advance(); - } - return this._lastStrValue !== ""; - } - eatLoneUnicodePropertyNameOrValue() { - return this.eatUnicodePropertyValue(); - } - eatHexEscapeSequence() { - const start = this.index; - if (this.eat(LATIN_SMALL_LETTER_X)) { - if (this.eatFixedHexDigits(2)) { - return true; - } - if (this._unicodeMode || this.strict) { - this.raise("Invalid escape"); - } - this.rewind(start); - } - return false; - } - eatDecimalDigits() { - const start = this.index; - this._lastIntValue = 0; - while (isDecimalDigit(this.currentCodePoint)) { - this._lastIntValue = - 10 * this._lastIntValue + digitToInt(this.currentCodePoint); - this.advance(); - } - return this.index !== start; - } - eatHexDigits() { - const start = this.index; - this._lastIntValue = 0; - while (isHexDigit(this.currentCodePoint)) { - this._lastIntValue = - 16 * this._lastIntValue + digitToInt(this.currentCodePoint); - this.advance(); - } - return this.index !== start; - } - eatLegacyOctalEscapeSequence() { - if (this.eatOctalDigit()) { - const n1 = this._lastIntValue; - if (this.eatOctalDigit()) { - const n2 = this._lastIntValue; - if (n1 <= 3 && this.eatOctalDigit()) { - this._lastIntValue = n1 * 64 + n2 * 8 + this._lastIntValue; - } - else { - this._lastIntValue = n1 * 8 + n2; - } - } - else { - this._lastIntValue = n1; - } - return true; - } - return false; - } - eatOctalDigit() { - const cp = this.currentCodePoint; - if (isOctalDigit(cp)) { - this.advance(); - this._lastIntValue = cp - DIGIT_ZERO; - return true; - } - this._lastIntValue = 0; - return false; - } - eatFixedHexDigits(length) { - const start = this.index; - this._lastIntValue = 0; - for (let i = 0; i < length; ++i) { - const cp = this.currentCodePoint; - if (!isHexDigit(cp)) { - this.rewind(start); - return false; - } - this._lastIntValue = 16 * this._lastIntValue + digitToInt(cp); - this.advance(); - } - return true; - } -} - -const DUMMY_PATTERN = {}; -const DUMMY_FLAGS = {}; -const DUMMY_CAPTURING_GROUP = {}; -function isClassSetOperand(node) { - return (node.type === "Character" || - node.type === "CharacterSet" || - node.type === "CharacterClass" || - node.type === "ExpressionCharacterClass" || - node.type === "ClassStringDisjunction"); -} -class RegExpParserState { - constructor(options) { - var _a; - this._node = DUMMY_PATTERN; - this._expressionBufferMap = new Map(); - this._flags = DUMMY_FLAGS; - this._backreferences = []; - this._capturingGroups = []; - this.source = ""; - this.strict = Boolean(options === null || options === void 0 ? void 0 : options.strict); - this.ecmaVersion = (_a = options === null || options === void 0 ? void 0 : options.ecmaVersion) !== null && _a !== void 0 ? _a : latestEcmaVersion; - } - get pattern() { - if (this._node.type !== "Pattern") { - throw new Error("UnknownError"); - } - return this._node; - } - get flags() { - if (this._flags.type !== "Flags") { - throw new Error("UnknownError"); - } - return this._flags; - } - onRegExpFlags(start, end, { global, ignoreCase, multiline, unicode, sticky, dotAll, hasIndices, unicodeSets, }) { - this._flags = { - type: "Flags", - parent: null, - start, - end, - raw: this.source.slice(start, end), - global, - ignoreCase, - multiline, - unicode, - sticky, - dotAll, - hasIndices, - unicodeSets, - }; - } - onPatternEnter(start) { - this._node = { - type: "Pattern", - parent: null, - start, - end: start, - raw: "", - alternatives: [], - }; - this._backreferences.length = 0; - this._capturingGroups.length = 0; - } - onPatternLeave(start, end) { - this._node.end = end; - this._node.raw = this.source.slice(start, end); - for (const reference of this._backreferences) { - const ref = reference.ref; - const groups = typeof ref === "number" - ? [this._capturingGroups[ref - 1]] - : this._capturingGroups.filter((g) => g.name === ref); - if (groups.length === 1) { - const group = groups[0]; - reference.ambiguous = false; - reference.resolved = group; - } - else { - reference.ambiguous = true; - reference.resolved = groups; - } - for (const group of groups) { - group.references.push(reference); - } - } - } - onAlternativeEnter(start) { - const parent = this._node; - if (parent.type !== "Assertion" && - parent.type !== "CapturingGroup" && - parent.type !== "Group" && - parent.type !== "Pattern") { - throw new Error("UnknownError"); - } - this._node = { - type: "Alternative", - parent, - start, - end: start, - raw: "", - elements: [], - }; - parent.alternatives.push(this._node); - } - onAlternativeLeave(start, end) { - const node = this._node; - if (node.type !== "Alternative") { - throw new Error("UnknownError"); - } - node.end = end; - node.raw = this.source.slice(start, end); - this._node = node.parent; - } - onGroupEnter(start) { - const parent = this._node; - if (parent.type !== "Alternative") { - throw new Error("UnknownError"); - } - this._node = { - type: "Group", - parent, - start, - end: start, - raw: "", - alternatives: [], - }; - parent.elements.push(this._node); - } - onGroupLeave(start, end) { - const node = this._node; - if (node.type !== "Group" || node.parent.type !== "Alternative") { - throw new Error("UnknownError"); - } - node.end = end; - node.raw = this.source.slice(start, end); - this._node = node.parent; - } - onCapturingGroupEnter(start, name) { - const parent = this._node; - if (parent.type !== "Alternative") { - throw new Error("UnknownError"); - } - this._node = { - type: "CapturingGroup", - parent, - start, - end: start, - raw: "", - name, - alternatives: [], - references: [], - }; - parent.elements.push(this._node); - this._capturingGroups.push(this._node); - } - onCapturingGroupLeave(start, end) { - const node = this._node; - if (node.type !== "CapturingGroup" || - node.parent.type !== "Alternative") { - throw new Error("UnknownError"); - } - node.end = end; - node.raw = this.source.slice(start, end); - this._node = node.parent; - } - onQuantifier(start, end, min, max, greedy) { - const parent = this._node; - if (parent.type !== "Alternative") { - throw new Error("UnknownError"); - } - const element = parent.elements.pop(); - if (element == null || - element.type === "Quantifier" || - (element.type === "Assertion" && element.kind !== "lookahead")) { - throw new Error("UnknownError"); - } - const node = { - type: "Quantifier", - parent, - start: element.start, - end, - raw: this.source.slice(element.start, end), - min, - max, - greedy, - element, - }; - parent.elements.push(node); - element.parent = node; - } - onLookaroundAssertionEnter(start, kind, negate) { - const parent = this._node; - if (parent.type !== "Alternative") { - throw new Error("UnknownError"); - } - const node = (this._node = { - type: "Assertion", - parent, - start, - end: start, - raw: "", - kind, - negate, - alternatives: [], - }); - parent.elements.push(node); - } - onLookaroundAssertionLeave(start, end) { - const node = this._node; - if (node.type !== "Assertion" || node.parent.type !== "Alternative") { - throw new Error("UnknownError"); - } - node.end = end; - node.raw = this.source.slice(start, end); - this._node = node.parent; - } - onEdgeAssertion(start, end, kind) { - const parent = this._node; - if (parent.type !== "Alternative") { - throw new Error("UnknownError"); - } - parent.elements.push({ - type: "Assertion", - parent, - start, - end, - raw: this.source.slice(start, end), - kind, - }); - } - onWordBoundaryAssertion(start, end, kind, negate) { - const parent = this._node; - if (parent.type !== "Alternative") { - throw new Error("UnknownError"); - } - parent.elements.push({ - type: "Assertion", - parent, - start, - end, - raw: this.source.slice(start, end), - kind, - negate, - }); - } - onAnyCharacterSet(start, end, kind) { - const parent = this._node; - if (parent.type !== "Alternative") { - throw new Error("UnknownError"); - } - parent.elements.push({ - type: "CharacterSet", - parent, - start, - end, - raw: this.source.slice(start, end), - kind, - }); - } - onEscapeCharacterSet(start, end, kind, negate) { - const parent = this._node; - if (parent.type !== "Alternative" && parent.type !== "CharacterClass") { - throw new Error("UnknownError"); - } - parent.elements.push({ - type: "CharacterSet", - parent, - start, - end, - raw: this.source.slice(start, end), - kind, - negate, - }); - } - onUnicodePropertyCharacterSet(start, end, kind, key, value, negate, strings) { - const parent = this._node; - if (parent.type !== "Alternative" && parent.type !== "CharacterClass") { - throw new Error("UnknownError"); - } - const base = { - type: "CharacterSet", - parent: null, - start, - end, - raw: this.source.slice(start, end), - kind, - strings: null, - key, - }; - if (strings) { - if ((parent.type === "CharacterClass" && !parent.unicodeSets) || - negate || - value !== null) { - throw new Error("UnknownError"); - } - parent.elements.push(Object.assign(Object.assign({}, base), { parent, strings, value, negate })); - } - else { - parent.elements.push(Object.assign(Object.assign({}, base), { parent, strings, value, negate })); - } - } - onCharacter(start, end, value) { - const parent = this._node; - if (parent.type !== "Alternative" && - parent.type !== "CharacterClass" && - parent.type !== "StringAlternative") { - throw new Error("UnknownError"); - } - parent.elements.push({ - type: "Character", - parent, - start, - end, - raw: this.source.slice(start, end), - value, - }); - } - onBackreference(start, end, ref) { - const parent = this._node; - if (parent.type !== "Alternative") { - throw new Error("UnknownError"); - } - const node = { - type: "Backreference", - parent, - start, - end, - raw: this.source.slice(start, end), - ref, - ambiguous: false, - resolved: DUMMY_CAPTURING_GROUP, - }; - parent.elements.push(node); - this._backreferences.push(node); - } - onCharacterClassEnter(start, negate, unicodeSets) { - const parent = this._node; - const base = { - type: "CharacterClass", - parent, - start, - end: start, - raw: "", - unicodeSets, - negate, - elements: [], - }; - if (parent.type === "Alternative") { - const node = Object.assign(Object.assign({}, base), { parent }); - this._node = node; - parent.elements.push(node); - } - else if (parent.type === "CharacterClass" && - parent.unicodeSets && - unicodeSets) { - const node = Object.assign(Object.assign({}, base), { parent, - unicodeSets }); - this._node = node; - parent.elements.push(node); - } - else { - throw new Error("UnknownError"); - } - } - onCharacterClassLeave(start, end) { - const node = this._node; - if (node.type !== "CharacterClass" || - (node.parent.type !== "Alternative" && - node.parent.type !== "CharacterClass")) { - throw new Error("UnknownError"); - } - const parent = node.parent; - node.end = end; - node.raw = this.source.slice(start, end); - this._node = parent; - const expression = this._expressionBufferMap.get(node); - if (!expression) { - return; - } - if (node.elements.length > 0) { - throw new Error("UnknownError"); - } - this._expressionBufferMap.delete(node); - const newNode = { - type: "ExpressionCharacterClass", - parent, - start: node.start, - end: node.end, - raw: node.raw, - negate: node.negate, - expression, - }; - expression.parent = newNode; - if (node !== parent.elements.pop()) { - throw new Error("UnknownError"); - } - parent.elements.push(newNode); - } - onCharacterClassRange(start, end) { - const parent = this._node; - if (parent.type !== "CharacterClass") { - throw new Error("UnknownError"); - } - const elements = parent.elements; - const max = elements.pop(); - if (!max || max.type !== "Character") { - throw new Error("UnknownError"); - } - if (!parent.unicodeSets) { - const hyphen = elements.pop(); - if (!hyphen || - hyphen.type !== "Character" || - hyphen.value !== HYPHEN_MINUS) { - throw new Error("UnknownError"); - } - } - const min = elements.pop(); - if (!min || min.type !== "Character") { - throw new Error("UnknownError"); - } - const node = { - type: "CharacterClassRange", - parent, - start, - end, - raw: this.source.slice(start, end), - min, - max, - }; - min.parent = node; - max.parent = node; - elements.push(node); - } - onClassIntersection(start, end) { - var _a; - const parent = this._node; - if (parent.type !== "CharacterClass" || !parent.unicodeSets) { - throw new Error("UnknownError"); - } - const right = parent.elements.pop(); - const left = (_a = this._expressionBufferMap.get(parent)) !== null && _a !== void 0 ? _a : parent.elements.pop(); - if (!left || - !right || - left.type === "ClassSubtraction" || - (left.type !== "ClassIntersection" && !isClassSetOperand(left)) || - !isClassSetOperand(right)) { - throw new Error("UnknownError"); - } - const node = { - type: "ClassIntersection", - parent: parent, - start, - end, - raw: this.source.slice(start, end), - left, - right, - }; - left.parent = node; - right.parent = node; - this._expressionBufferMap.set(parent, node); - } - onClassSubtraction(start, end) { - var _a; - const parent = this._node; - if (parent.type !== "CharacterClass" || !parent.unicodeSets) { - throw new Error("UnknownError"); - } - const right = parent.elements.pop(); - const left = (_a = this._expressionBufferMap.get(parent)) !== null && _a !== void 0 ? _a : parent.elements.pop(); - if (!left || - !right || - left.type === "ClassIntersection" || - (left.type !== "ClassSubtraction" && !isClassSetOperand(left)) || - !isClassSetOperand(right)) { - throw new Error("UnknownError"); - } - const node = { - type: "ClassSubtraction", - parent: parent, - start, - end, - raw: this.source.slice(start, end), - left, - right, - }; - left.parent = node; - right.parent = node; - this._expressionBufferMap.set(parent, node); - } - onClassStringDisjunctionEnter(start) { - const parent = this._node; - if (parent.type !== "CharacterClass" || !parent.unicodeSets) { - throw new Error("UnknownError"); - } - this._node = { - type: "ClassStringDisjunction", - parent, - start, - end: start, - raw: "", - alternatives: [], - }; - parent.elements.push(this._node); - } - onClassStringDisjunctionLeave(start, end) { - const node = this._node; - if (node.type !== "ClassStringDisjunction" || - node.parent.type !== "CharacterClass") { - throw new Error("UnknownError"); - } - node.end = end; - node.raw = this.source.slice(start, end); - this._node = node.parent; - } - onStringAlternativeEnter(start) { - const parent = this._node; - if (parent.type !== "ClassStringDisjunction") { - throw new Error("UnknownError"); - } - this._node = { - type: "StringAlternative", - parent, - start, - end: start, - raw: "", - elements: [], - }; - parent.alternatives.push(this._node); - } - onStringAlternativeLeave(start, end) { - const node = this._node; - if (node.type !== "StringAlternative") { - throw new Error("UnknownError"); - } - node.end = end; - node.raw = this.source.slice(start, end); - this._node = node.parent; - } -} -class RegExpParser { - constructor(options) { - this._state = new RegExpParserState(options); - this._validator = new RegExpValidator(this._state); - } - parseLiteral(source, start = 0, end = source.length) { - this._state.source = source; - this._validator.validateLiteral(source, start, end); - const pattern = this._state.pattern; - const flags = this._state.flags; - const literal = { - type: "RegExpLiteral", - parent: null, - start, - end, - raw: source, - pattern, - flags, - }; - pattern.parent = literal; - flags.parent = literal; - return literal; - } - parseFlags(source, start = 0, end = source.length) { - this._state.source = source; - this._validator.validateFlags(source, start, end); - return this._state.flags; - } - parsePattern(source, start = 0, end = source.length, uFlagOrFlags = undefined) { - this._state.source = source; - this._validator.validatePattern(source, start, end, uFlagOrFlags); - return this._state.pattern; - } -} - -class RegExpVisitor { - constructor(handlers) { - this._handlers = handlers; - } - visit(node) { - switch (node.type) { - case "Alternative": - this.visitAlternative(node); - break; - case "Assertion": - this.visitAssertion(node); - break; - case "Backreference": - this.visitBackreference(node); - break; - case "CapturingGroup": - this.visitCapturingGroup(node); - break; - case "Character": - this.visitCharacter(node); - break; - case "CharacterClass": - this.visitCharacterClass(node); - break; - case "CharacterClassRange": - this.visitCharacterClassRange(node); - break; - case "CharacterSet": - this.visitCharacterSet(node); - break; - case "ClassIntersection": - this.visitClassIntersection(node); - break; - case "ClassStringDisjunction": - this.visitClassStringDisjunction(node); - break; - case "ClassSubtraction": - this.visitClassSubtraction(node); - break; - case "ExpressionCharacterClass": - this.visitExpressionCharacterClass(node); - break; - case "Flags": - this.visitFlags(node); - break; - case "Group": - this.visitGroup(node); - break; - case "Pattern": - this.visitPattern(node); - break; - case "Quantifier": - this.visitQuantifier(node); - break; - case "RegExpLiteral": - this.visitRegExpLiteral(node); - break; - case "StringAlternative": - this.visitStringAlternative(node); - break; - default: - throw new Error(`Unknown type: ${node.type}`); - } - } - visitAlternative(node) { - if (this._handlers.onAlternativeEnter) { - this._handlers.onAlternativeEnter(node); - } - node.elements.forEach(this.visit, this); - if (this._handlers.onAlternativeLeave) { - this._handlers.onAlternativeLeave(node); - } - } - visitAssertion(node) { - if (this._handlers.onAssertionEnter) { - this._handlers.onAssertionEnter(node); - } - if (node.kind === "lookahead" || node.kind === "lookbehind") { - node.alternatives.forEach(this.visit, this); - } - if (this._handlers.onAssertionLeave) { - this._handlers.onAssertionLeave(node); - } - } - visitBackreference(node) { - if (this._handlers.onBackreferenceEnter) { - this._handlers.onBackreferenceEnter(node); - } - if (this._handlers.onBackreferenceLeave) { - this._handlers.onBackreferenceLeave(node); - } - } - visitCapturingGroup(node) { - if (this._handlers.onCapturingGroupEnter) { - this._handlers.onCapturingGroupEnter(node); - } - node.alternatives.forEach(this.visit, this); - if (this._handlers.onCapturingGroupLeave) { - this._handlers.onCapturingGroupLeave(node); - } - } - visitCharacter(node) { - if (this._handlers.onCharacterEnter) { - this._handlers.onCharacterEnter(node); - } - if (this._handlers.onCharacterLeave) { - this._handlers.onCharacterLeave(node); - } - } - visitCharacterClass(node) { - if (this._handlers.onCharacterClassEnter) { - this._handlers.onCharacterClassEnter(node); - } - node.elements.forEach(this.visit, this); - if (this._handlers.onCharacterClassLeave) { - this._handlers.onCharacterClassLeave(node); - } - } - visitCharacterClassRange(node) { - if (this._handlers.onCharacterClassRangeEnter) { - this._handlers.onCharacterClassRangeEnter(node); - } - this.visitCharacter(node.min); - this.visitCharacter(node.max); - if (this._handlers.onCharacterClassRangeLeave) { - this._handlers.onCharacterClassRangeLeave(node); - } - } - visitCharacterSet(node) { - if (this._handlers.onCharacterSetEnter) { - this._handlers.onCharacterSetEnter(node); - } - if (this._handlers.onCharacterSetLeave) { - this._handlers.onCharacterSetLeave(node); - } - } - visitClassIntersection(node) { - if (this._handlers.onClassIntersectionEnter) { - this._handlers.onClassIntersectionEnter(node); - } - this.visit(node.left); - this.visit(node.right); - if (this._handlers.onClassIntersectionLeave) { - this._handlers.onClassIntersectionLeave(node); - } - } - visitClassStringDisjunction(node) { - if (this._handlers.onClassStringDisjunctionEnter) { - this._handlers.onClassStringDisjunctionEnter(node); - } - node.alternatives.forEach(this.visit, this); - if (this._handlers.onClassStringDisjunctionLeave) { - this._handlers.onClassStringDisjunctionLeave(node); - } - } - visitClassSubtraction(node) { - if (this._handlers.onClassSubtractionEnter) { - this._handlers.onClassSubtractionEnter(node); - } - this.visit(node.left); - this.visit(node.right); - if (this._handlers.onClassSubtractionLeave) { - this._handlers.onClassSubtractionLeave(node); - } - } - visitExpressionCharacterClass(node) { - if (this._handlers.onExpressionCharacterClassEnter) { - this._handlers.onExpressionCharacterClassEnter(node); - } - this.visit(node.expression); - if (this._handlers.onExpressionCharacterClassLeave) { - this._handlers.onExpressionCharacterClassLeave(node); - } - } - visitFlags(node) { - if (this._handlers.onFlagsEnter) { - this._handlers.onFlagsEnter(node); - } - if (this._handlers.onFlagsLeave) { - this._handlers.onFlagsLeave(node); - } - } - visitGroup(node) { - if (this._handlers.onGroupEnter) { - this._handlers.onGroupEnter(node); - } - node.alternatives.forEach(this.visit, this); - if (this._handlers.onGroupLeave) { - this._handlers.onGroupLeave(node); - } - } - visitPattern(node) { - if (this._handlers.onPatternEnter) { - this._handlers.onPatternEnter(node); - } - node.alternatives.forEach(this.visit, this); - if (this._handlers.onPatternLeave) { - this._handlers.onPatternLeave(node); - } - } - visitQuantifier(node) { - if (this._handlers.onQuantifierEnter) { - this._handlers.onQuantifierEnter(node); - } - this.visit(node.element); - if (this._handlers.onQuantifierLeave) { - this._handlers.onQuantifierLeave(node); - } - } - visitRegExpLiteral(node) { - if (this._handlers.onRegExpLiteralEnter) { - this._handlers.onRegExpLiteralEnter(node); - } - this.visitPattern(node.pattern); - this.visitFlags(node.flags); - if (this._handlers.onRegExpLiteralLeave) { - this._handlers.onRegExpLiteralLeave(node); - } - } - visitStringAlternative(node) { - if (this._handlers.onStringAlternativeEnter) { - this._handlers.onStringAlternativeEnter(node); - } - node.elements.forEach(this.visit, this); - if (this._handlers.onStringAlternativeLeave) { - this._handlers.onStringAlternativeLeave(node); - } - } -} - -function parseRegExpLiteral(source, options) { - return new RegExpParser(options).parseLiteral(String(source)); -} -function validateRegExpLiteral(source, options) { - new RegExpValidator(options).validateLiteral(source); -} -function visitRegExpAST(node, handlers) { - new RegExpVisitor(handlers).visit(node); -} - -exports.AST = ast; -exports.RegExpParser = RegExpParser; -exports.RegExpSyntaxError = RegExpSyntaxError; -exports.RegExpValidator = RegExpValidator; -exports.parseRegExpLiteral = parseRegExpLiteral; -exports.validateRegExpLiteral = validateRegExpLiteral; -exports.visitRegExpAST = visitRegExpAST; -//# sourceMappingURL=index.js.map diff --git a/tools/eslint/node_modules/@eslint-community/regexpp/index.mjs b/tools/eslint/node_modules/@eslint-community/regexpp/index.mjs deleted file mode 100644 index 6589e43f1d46f5..00000000000000 --- a/tools/eslint/node_modules/@eslint-community/regexpp/index.mjs +++ /dev/null @@ -1,2858 +0,0 @@ -var ast = /*#__PURE__*/Object.freeze({ - __proto__: null -}); - -const latestEcmaVersion = 2025; - -let largeIdStartRanges = undefined; -let largeIdContinueRanges = undefined; -function isIdStart(cp) { - if (cp < 0x41) - return false; - if (cp < 0x5b) - return true; - if (cp < 0x61) - return false; - if (cp < 0x7b) - return true; - return isLargeIdStart(cp); -} -function isIdContinue(cp) { - if (cp < 0x30) - return false; - if (cp < 0x3a) - return true; - if (cp < 0x41) - return false; - if (cp < 0x5b) - return true; - if (cp === 0x5f) - return true; - if (cp < 0x61) - return false; - if (cp < 0x7b) - return true; - return isLargeIdStart(cp) || isLargeIdContinue(cp); -} -function isLargeIdStart(cp) { - return isInRange(cp, largeIdStartRanges !== null && largeIdStartRanges !== void 0 ? largeIdStartRanges : (largeIdStartRanges = initLargeIdStartRanges())); -} -function isLargeIdContinue(cp) { - return isInRange(cp, largeIdContinueRanges !== null && largeIdContinueRanges !== void 0 ? largeIdContinueRanges : (largeIdContinueRanges = initLargeIdContinueRanges())); -} -function initLargeIdStartRanges() { - return restoreRanges("4q 0 b 0 5 0 6 m 2 u 2 cp 5 b f 4 8 0 2 0 3m 4 2 1 3 3 2 0 7 0 2 2 2 0 2 j 2 2a 2 3u 9 4l 2 11 3 0 7 14 20 q 5 3 1a 16 10 1 2 2q 2 0 g 1 8 1 b 2 3 0 h 0 2 t u 2g c 0 p w a 1 5 0 6 l 5 0 a 0 4 0 o o 8 a 6 n 2 5 i 15 1n 1h 4 0 j 0 8 9 g f 5 7 3 1 3 l 2 6 2 0 4 3 4 0 h 0 e 1 2 2 f 1 b 0 9 5 5 1 3 l 2 6 2 1 2 1 2 1 w 3 2 0 k 2 h 8 2 2 2 l 2 6 2 1 2 4 4 0 j 0 g 1 o 0 c 7 3 1 3 l 2 6 2 1 2 4 4 0 v 1 2 2 g 0 i 0 2 5 4 2 2 3 4 1 2 0 2 1 4 1 4 2 4 b n 0 1h 7 2 2 2 m 2 f 4 0 r 2 3 0 3 1 v 0 5 7 2 2 2 m 2 9 2 4 4 0 w 1 2 1 g 1 i 8 2 2 2 14 3 0 h 0 6 2 9 2 p 5 6 h 4 n 2 8 2 0 3 6 1n 1b 2 1 d 6 1n 1 2 0 2 4 2 n 2 0 2 9 2 1 a 0 3 4 2 0 m 3 x 0 1s 7 2 z s 4 38 16 l 0 h 5 5 3 4 0 4 1 8 2 5 c d 0 i 11 2 0 6 0 3 16 2 98 2 3 3 6 2 0 2 3 3 14 2 3 3 w 2 3 3 6 2 0 2 3 3 e 2 1k 2 3 3 1u 12 f h 2d 3 5 4 h7 3 g 2 p 6 22 4 a 8 h e i f h f c 2 2 g 1f 10 0 5 0 1w 2g 8 14 2 0 6 1x b u 1e t 3 4 c 17 5 p 1j m a 1g 2b 0 2m 1a i 7 1j t e 1 b 17 r z 16 2 b z 3 8 8 16 3 2 16 3 2 5 2 1 4 0 6 5b 1t 7p 3 5 3 11 3 5 3 7 2 0 2 0 2 0 2 u 3 1g 2 6 2 0 4 2 2 6 4 3 3 5 5 c 6 2 2 6 39 0 e 0 h c 2u 0 5 0 3 9 2 0 3 5 7 0 2 0 2 0 2 f 3 3 6 4 5 0 i 14 22g 6c 7 3 4 1 d 11 2 0 6 0 3 1j 8 0 h m a 6 2 6 2 6 2 6 2 6 2 6 2 6 2 6 fb 2 q 8 8 4 3 4 5 2d 5 4 2 2h 2 3 6 16 2 2l i v 1d f e9 533 1t h3g 1w 19 3 7g 4 f b 1 l 1a h u 3 27 14 8 3 2u 3 1r 6 1 2 0 2 4 p f 2 2 2 3 2 m u 1f f 1d 1r 5 4 0 2 1 c r b m q s 8 1a t 0 h 4 2 9 b 4 2 14 o 2 2 7 l m 4 0 4 1d 2 0 4 1 3 4 3 0 2 0 p 2 3 a 8 2 d 5 3 5 3 5 a 6 2 6 2 16 2 d 7 36 u 8mb d m 5 1c 6it a5 3 2x 13 6 d 4 6 0 2 9 2 c 2 4 2 0 2 1 2 1 2 2z y a2 j 1r 3 1h 15 b 39 4 2 3q 11 p 7 p c 2g 4 5 3 5 3 5 3 2 10 b 2 p 2 i 2 1 2 e 3 d z 3e 1y 1g 7g s 4 1c 1c v e t 6 11 b t 3 z 5 7 2 4 17 4d j z 5 z 5 13 9 1f d a 2 e 2 6 2 1 2 a 2 e 2 6 2 1 1w 8m a l b 7 p 5 2 15 2 8 1y 5 3 0 2 17 2 1 4 0 3 m b m a u 1u i 2 1 b l b p 1z 1j 7 1 1t 0 g 3 2 2 2 s 17 s 4 s 10 7 2 r s 1h b l b i e h 33 20 1k 1e e 1e e z 9p 15 7 1 27 s b 0 9 l 17 h 1b k s m d 1g 1m 1 3 0 e 18 x o r z u 0 3 0 9 y 4 0 d 1b f 3 m 0 2 0 10 h 2 o k 1 1s 6 2 0 2 3 2 e 2 9 8 1a 13 7 3 1 3 l 2 6 2 1 2 4 4 0 j 0 d 4 4f 1g j 3 l 2 v 1b l 1 2 0 55 1a 16 3 11 1b l 0 1o 16 e 0 20 q 12 6 56 17 39 1r w 7 3 0 3 7 2 1 2 n g 0 2 0 2n 7 3 12 h 0 2 0 t 0 b 13 8 0 m 0 c 19 k 0 j 20 7c 8 2 10 i 0 1e t 35 6 2 1 2 11 m 0 q 5 2 1 2 v f 0 94 i g 0 2 c 2 x 3h 0 28 pl 2v 32 i 5f 219 2o g tr i 5 33u g6 6nu fs 8 u i 26 i t j 1b h 3 w k 6 i j5 1r 3l 22 6 0 1v c 1t 1 2 0 t 4qf 9 yd 17 8 6w8 3 2 6 2 1 2 82 g 0 u 2 3 0 f 3 9 az 1s5 2y 6 c 4 8 8 9 4mf 2c 2 1y 2 1 3 0 3 1 3 3 2 b 2 0 2 6 2 1s 2 3 3 7 2 6 2 r 2 3 2 4 2 0 4 6 2 9f 3 o 2 o 2 u 2 o 2 u 2 o 2 u 2 o 2 u 2 o 2 7 1f9 u 7 5 7a 1p 43 18 b 6 h 0 8y t j 17 dh r l1 6 2 3 2 1 2 e 2 5g 1o 1v 8 0 xh 3 2 q 2 1 2 0 3 0 2 9 2 3 2 0 2 0 7 0 5 0 2 0 2 0 2 2 2 1 2 0 3 0 2 0 2 0 2 0 2 0 2 1 2 0 3 3 2 6 2 3 2 3 2 0 2 9 2 g 6 2 2 4 2 g 3et wyn x 37d 7 65 3 4g1 f 5rk g h9 1wj f1 15v 3t6 6 38f"); -} -function initLargeIdContinueRanges() { - return restoreRanges("53 0 g9 33 o 0 70 4 7e 18 2 0 2 1 2 1 2 0 21 a 1d u 7 0 2u 6 3 5 3 1 2 3 3 9 o 0 v q 2k a g 9 y 8 a 0 p 3 2 8 2 2 2 4 18 2 1p 7 17 n 2 w 1j 2 2 h 2 6 b 1 3 9 i 2 1l 0 2 6 3 1 3 2 a 0 b 1 3 9 f 0 3 2 1l 0 2 4 5 1 3 2 4 0 l b 4 0 c 2 1l 0 2 7 2 2 2 2 l 1 3 9 b 5 2 2 1l 0 2 6 3 1 3 2 8 2 b 1 3 9 j 0 1o 4 4 2 2 3 a 0 f 9 h 4 1k 0 2 6 2 2 2 3 8 1 c 1 3 9 i 2 1l 0 2 6 2 2 2 3 8 1 c 1 3 9 4 0 d 3 1k 1 2 6 2 2 2 3 a 0 b 1 3 9 i 2 1z 0 5 5 2 0 2 7 7 9 3 1 1q 0 3 6 d 7 2 9 2g 0 3 8 c 6 2 9 1r 1 7 9 c 0 2 0 2 0 5 1 1e j 2 1 6 a 2 z a 0 2t j 2 9 d 3 5 2 2 2 3 6 4 3 e b 2 e jk 2 a 8 pt 3 t 2 u 1 v 1 1t v a 0 3 9 y 2 2 a 40 0 3b b 5 b b 9 3l a 1p 4 1m 9 2 s 3 a 7 9 n d 2 f 1e 4 1c g c 9 i 8 d 2 v c 3 9 19 d 1d j 9 9 7 9 3b 2 2 k 5 0 7 0 3 2 5j 1r el 1 1e 1 k 0 3g c 5 0 4 b 2db 2 3y 0 2p v ff 5 2y 1 2p 0 n51 9 1y 0 5 9 x 1 29 1 7l 0 4 0 5 0 o 4 5 0 2c 1 1f h b 9 7 h e a t 7 q c 19 3 1c d g 9 c 0 b 9 1c d d 0 9 1 3 9 y 2 1f 0 2 2 3 1 6 1 2 0 16 4 6 1 6l 7 2 1 3 9 fmt 0 ki f h f 4 1 p 2 5d 9 12 0 12 0 ig 0 6b 0 46 4 86 9 120 2 2 1 6 3 15 2 5 0 4m 1 fy 3 9 9 aa 1 29 2 1z a 1e 3 3f 2 1i e w a 3 1 b 3 1a a 8 0 1a 9 7 2 11 d 2 9 6 1 19 0 d 2 1d d 9 3 2 b 2b b 7 0 3 0 4e b 6 9 7 3 1k 1 2 6 3 1 3 2 a 0 b 1 3 6 4 4 5d h a 9 5 0 2a j d 9 5y 6 3 8 s 1 2b g g 9 2a c 9 9 2c e 5 9 6r e 4m 9 1z 5 2 1 3 3 2 0 2 1 d 9 3c 6 3 6 4 0 t 9 15 6 2 3 9 0 a a 1b f ba 7 2 7 h 9 1l l 2 d 3f 5 4 0 2 1 2 6 2 0 9 9 1d 4 2 1 2 4 9 9 96 3 a 1 2 0 1d 6 4 4 e 9 44n 0 7 e aob 9 2f 9 13 4 1o 6 q 9 s6 0 2 1i 8 3 2a 0 c 1 f58 1 3mq 19 3 m f3 4 4 5 9 7 3 6 v 3 45 2 13e 1d e9 1i 5 1d 9 0 f 0 n 4 2 e 11t 6 2 g 3 6 2 1 2 4 2t 0 4h 6 a 9 9x 0 1q d dv d rb 6 32 6 6 9 3o7 9 gvt3 6n"); -} -function isInRange(cp, ranges) { - let l = 0, r = (ranges.length / 2) | 0, i = 0, min = 0, max = 0; - while (l < r) { - i = ((l + r) / 2) | 0; - min = ranges[2 * i]; - max = ranges[2 * i + 1]; - if (cp < min) { - r = i; - } - else if (cp > max) { - l = i + 1; - } - else { - return true; - } - } - return false; -} -function restoreRanges(data) { - let last = 0; - return data.split(" ").map((s) => (last += parseInt(s, 36) | 0)); -} - -class DataSet { - constructor(raw2018, raw2019, raw2020, raw2021, raw2022, raw2023, raw2024, raw2025) { - this._raw2018 = raw2018; - this._raw2019 = raw2019; - this._raw2020 = raw2020; - this._raw2021 = raw2021; - this._raw2022 = raw2022; - this._raw2023 = raw2023; - this._raw2024 = raw2024; - this._raw2025 = raw2025; - } - get es2018() { - var _a; - return ((_a = this._set2018) !== null && _a !== void 0 ? _a : (this._set2018 = new Set(this._raw2018.split(" ")))); - } - get es2019() { - var _a; - return ((_a = this._set2019) !== null && _a !== void 0 ? _a : (this._set2019 = new Set(this._raw2019.split(" ")))); - } - get es2020() { - var _a; - return ((_a = this._set2020) !== null && _a !== void 0 ? _a : (this._set2020 = new Set(this._raw2020.split(" ")))); - } - get es2021() { - var _a; - return ((_a = this._set2021) !== null && _a !== void 0 ? _a : (this._set2021 = new Set(this._raw2021.split(" ")))); - } - get es2022() { - var _a; - return ((_a = this._set2022) !== null && _a !== void 0 ? _a : (this._set2022 = new Set(this._raw2022.split(" ")))); - } - get es2023() { - var _a; - return ((_a = this._set2023) !== null && _a !== void 0 ? _a : (this._set2023 = new Set(this._raw2023.split(" ")))); - } - get es2024() { - var _a; - return ((_a = this._set2024) !== null && _a !== void 0 ? _a : (this._set2024 = new Set(this._raw2024.split(" ")))); - } - get es2025() { - var _a; - return ((_a = this._set2025) !== null && _a !== void 0 ? _a : (this._set2025 = new Set(this._raw2025.split(" ")))); - } -} -const gcNameSet = new Set(["General_Category", "gc"]); -const scNameSet = new Set(["Script", "Script_Extensions", "sc", "scx"]); -const gcValueSets = new DataSet("C Cased_Letter Cc Cf Close_Punctuation Cn Co Combining_Mark Connector_Punctuation Control Cs Currency_Symbol Dash_Punctuation Decimal_Number Enclosing_Mark Final_Punctuation Format Initial_Punctuation L LC Letter Letter_Number Line_Separator Ll Lm Lo Lowercase_Letter Lt Lu M Mark Math_Symbol Mc Me Mn Modifier_Letter Modifier_Symbol N Nd Nl No Nonspacing_Mark Number Open_Punctuation Other Other_Letter Other_Number Other_Punctuation Other_Symbol P Paragraph_Separator Pc Pd Pe Pf Pi Po Private_Use Ps Punctuation S Sc Separator Sk Sm So Space_Separator Spacing_Mark Surrogate Symbol Titlecase_Letter Unassigned Uppercase_Letter Z Zl Zp Zs cntrl digit punct", "", "", "", "", "", "", ""); -const scValueSets = new DataSet("Adlam Adlm Aghb Ahom Anatolian_Hieroglyphs Arab Arabic Armenian Armi Armn Avestan Avst Bali Balinese Bamu Bamum Bass Bassa_Vah Batak Batk Beng Bengali Bhaiksuki Bhks Bopo Bopomofo Brah Brahmi Brai Braille Bugi Buginese Buhd Buhid Cakm Canadian_Aboriginal Cans Cari Carian Caucasian_Albanian Chakma Cham Cher Cherokee Common Copt Coptic Cprt Cuneiform Cypriot Cyrillic Cyrl Deseret Deva Devanagari Dsrt Dupl Duployan Egyp Egyptian_Hieroglyphs Elba Elbasan Ethi Ethiopic Geor Georgian Glag Glagolitic Gonm Goth Gothic Gran Grantha Greek Grek Gujarati Gujr Gurmukhi Guru Han Hang Hangul Hani Hano Hanunoo Hatr Hatran Hebr Hebrew Hira Hiragana Hluw Hmng Hung Imperial_Aramaic Inherited Inscriptional_Pahlavi Inscriptional_Parthian Ital Java Javanese Kaithi Kali Kana Kannada Katakana Kayah_Li Khar Kharoshthi Khmer Khmr Khoj Khojki Khudawadi Knda Kthi Lana Lao Laoo Latin Latn Lepc Lepcha Limb Limbu Lina Linb Linear_A Linear_B Lisu Lyci Lycian Lydi Lydian Mahajani Mahj Malayalam Mand Mandaic Mani Manichaean Marc Marchen Masaram_Gondi Meetei_Mayek Mend Mende_Kikakui Merc Mero Meroitic_Cursive Meroitic_Hieroglyphs Miao Mlym Modi Mong Mongolian Mro Mroo Mtei Mult Multani Myanmar Mymr Nabataean Narb Nbat New_Tai_Lue Newa Nko Nkoo Nshu Nushu Ogam Ogham Ol_Chiki Olck Old_Hungarian Old_Italic Old_North_Arabian Old_Permic Old_Persian Old_South_Arabian Old_Turkic Oriya Orkh Orya Osage Osge Osma Osmanya Pahawh_Hmong Palm Palmyrene Pau_Cin_Hau Pauc Perm Phag Phags_Pa Phli Phlp Phnx Phoenician Plrd Prti Psalter_Pahlavi Qaac Qaai Rejang Rjng Runic Runr Samaritan Samr Sarb Saur Saurashtra Sgnw Sharada Shavian Shaw Shrd Sidd Siddham SignWriting Sind Sinh Sinhala Sora Sora_Sompeng Soyo Soyombo Sund Sundanese Sylo Syloti_Nagri Syrc Syriac Tagalog Tagb Tagbanwa Tai_Le Tai_Tham Tai_Viet Takr Takri Tale Talu Tamil Taml Tang Tangut Tavt Telu Telugu Tfng Tglg Thaa Thaana Thai Tibetan Tibt Tifinagh Tirh Tirhuta Ugar Ugaritic Vai Vaii Wara Warang_Citi Xpeo Xsux Yi Yiii Zanabazar_Square Zanb Zinh Zyyy", "Dogr Dogra Gong Gunjala_Gondi Hanifi_Rohingya Maka Makasar Medefaidrin Medf Old_Sogdian Rohg Sogd Sogdian Sogo", "Elym Elymaic Hmnp Nand Nandinagari Nyiakeng_Puachue_Hmong Wancho Wcho", "Chorasmian Chrs Diak Dives_Akuru Khitan_Small_Script Kits Yezi Yezidi", "Cpmn Cypro_Minoan Old_Uyghur Ougr Tangsa Tnsa Toto Vith Vithkuqi", "Hrkt Katakana_Or_Hiragana Kawi Nag_Mundari Nagm Unknown Zzzz", "", ""); -const binPropertySets = new DataSet("AHex ASCII ASCII_Hex_Digit Alpha Alphabetic Any Assigned Bidi_C Bidi_Control Bidi_M Bidi_Mirrored CI CWCF CWCM CWKCF CWL CWT CWU Case_Ignorable Cased Changes_When_Casefolded Changes_When_Casemapped Changes_When_Lowercased Changes_When_NFKC_Casefolded Changes_When_Titlecased Changes_When_Uppercased DI Dash Default_Ignorable_Code_Point Dep Deprecated Dia Diacritic Emoji Emoji_Component Emoji_Modifier Emoji_Modifier_Base Emoji_Presentation Ext Extender Gr_Base Gr_Ext Grapheme_Base Grapheme_Extend Hex Hex_Digit IDC IDS IDSB IDST IDS_Binary_Operator IDS_Trinary_Operator ID_Continue ID_Start Ideo Ideographic Join_C Join_Control LOE Logical_Order_Exception Lower Lowercase Math NChar Noncharacter_Code_Point Pat_Syn Pat_WS Pattern_Syntax Pattern_White_Space QMark Quotation_Mark RI Radical Regional_Indicator SD STerm Sentence_Terminal Soft_Dotted Term Terminal_Punctuation UIdeo Unified_Ideograph Upper Uppercase VS Variation_Selector White_Space XIDC XIDS XID_Continue XID_Start space", "Extended_Pictographic", "", "EBase EComp EMod EPres ExtPict", "", "", "", ""); -const binPropertyOfStringsSets = new DataSet("", "", "", "", "", "", "Basic_Emoji Emoji_Keycap_Sequence RGI_Emoji RGI_Emoji_Flag_Sequence RGI_Emoji_Modifier_Sequence RGI_Emoji_Tag_Sequence RGI_Emoji_ZWJ_Sequence", ""); -function isValidUnicodeProperty(version, name, value) { - if (gcNameSet.has(name)) { - return version >= 2018 && gcValueSets.es2018.has(value); - } - if (scNameSet.has(name)) { - return ((version >= 2018 && scValueSets.es2018.has(value)) || - (version >= 2019 && scValueSets.es2019.has(value)) || - (version >= 2020 && scValueSets.es2020.has(value)) || - (version >= 2021 && scValueSets.es2021.has(value)) || - (version >= 2022 && scValueSets.es2022.has(value)) || - (version >= 2023 && scValueSets.es2023.has(value))); - } - return false; -} -function isValidLoneUnicodeProperty(version, value) { - return ((version >= 2018 && binPropertySets.es2018.has(value)) || - (version >= 2019 && binPropertySets.es2019.has(value)) || - (version >= 2021 && binPropertySets.es2021.has(value))); -} -function isValidLoneUnicodePropertyOfString(version, value) { - return version >= 2024 && binPropertyOfStringsSets.es2024.has(value); -} - -const BACKSPACE = 0x08; -const CHARACTER_TABULATION = 0x09; -const LINE_FEED = 0x0a; -const LINE_TABULATION = 0x0b; -const FORM_FEED = 0x0c; -const CARRIAGE_RETURN = 0x0d; -const EXCLAMATION_MARK = 0x21; -const NUMBER_SIGN = 0x23; -const DOLLAR_SIGN = 0x24; -const PERCENT_SIGN = 0x25; -const AMPERSAND = 0x26; -const LEFT_PARENTHESIS = 0x28; -const RIGHT_PARENTHESIS = 0x29; -const ASTERISK = 0x2a; -const PLUS_SIGN = 0x2b; -const COMMA = 0x2c; -const HYPHEN_MINUS = 0x2d; -const FULL_STOP = 0x2e; -const SOLIDUS = 0x2f; -const DIGIT_ZERO = 0x30; -const DIGIT_ONE = 0x31; -const DIGIT_SEVEN = 0x37; -const DIGIT_NINE = 0x39; -const COLON = 0x3a; -const SEMICOLON = 0x3b; -const LESS_THAN_SIGN = 0x3c; -const EQUALS_SIGN = 0x3d; -const GREATER_THAN_SIGN = 0x3e; -const QUESTION_MARK = 0x3f; -const COMMERCIAL_AT = 0x40; -const LATIN_CAPITAL_LETTER_A = 0x41; -const LATIN_CAPITAL_LETTER_B = 0x42; -const LATIN_CAPITAL_LETTER_D = 0x44; -const LATIN_CAPITAL_LETTER_F = 0x46; -const LATIN_CAPITAL_LETTER_P = 0x50; -const LATIN_CAPITAL_LETTER_S = 0x53; -const LATIN_CAPITAL_LETTER_W = 0x57; -const LATIN_CAPITAL_LETTER_Z = 0x5a; -const LOW_LINE = 0x5f; -const LATIN_SMALL_LETTER_A = 0x61; -const LATIN_SMALL_LETTER_B = 0x62; -const LATIN_SMALL_LETTER_C = 0x63; -const LATIN_SMALL_LETTER_D = 0x64; -const LATIN_SMALL_LETTER_F = 0x66; -const LATIN_SMALL_LETTER_G = 0x67; -const LATIN_SMALL_LETTER_I = 0x69; -const LATIN_SMALL_LETTER_K = 0x6b; -const LATIN_SMALL_LETTER_M = 0x6d; -const LATIN_SMALL_LETTER_N = 0x6e; -const LATIN_SMALL_LETTER_P = 0x70; -const LATIN_SMALL_LETTER_Q = 0x71; -const LATIN_SMALL_LETTER_R = 0x72; -const LATIN_SMALL_LETTER_S = 0x73; -const LATIN_SMALL_LETTER_T = 0x74; -const LATIN_SMALL_LETTER_U = 0x75; -const LATIN_SMALL_LETTER_V = 0x76; -const LATIN_SMALL_LETTER_W = 0x77; -const LATIN_SMALL_LETTER_X = 0x78; -const LATIN_SMALL_LETTER_Y = 0x79; -const LATIN_SMALL_LETTER_Z = 0x7a; -const LEFT_SQUARE_BRACKET = 0x5b; -const REVERSE_SOLIDUS = 0x5c; -const RIGHT_SQUARE_BRACKET = 0x5d; -const CIRCUMFLEX_ACCENT = 0x5e; -const GRAVE_ACCENT = 0x60; -const LEFT_CURLY_BRACKET = 0x7b; -const VERTICAL_LINE = 0x7c; -const RIGHT_CURLY_BRACKET = 0x7d; -const TILDE = 0x7e; -const ZERO_WIDTH_NON_JOINER = 0x200c; -const ZERO_WIDTH_JOINER = 0x200d; -const LINE_SEPARATOR = 0x2028; -const PARAGRAPH_SEPARATOR = 0x2029; -const MIN_CODE_POINT = 0x00; -const MAX_CODE_POINT = 0x10ffff; -function isLatinLetter(code) { - return ((code >= LATIN_CAPITAL_LETTER_A && code <= LATIN_CAPITAL_LETTER_Z) || - (code >= LATIN_SMALL_LETTER_A && code <= LATIN_SMALL_LETTER_Z)); -} -function isDecimalDigit(code) { - return code >= DIGIT_ZERO && code <= DIGIT_NINE; -} -function isOctalDigit(code) { - return code >= DIGIT_ZERO && code <= DIGIT_SEVEN; -} -function isHexDigit(code) { - return ((code >= DIGIT_ZERO && code <= DIGIT_NINE) || - (code >= LATIN_CAPITAL_LETTER_A && code <= LATIN_CAPITAL_LETTER_F) || - (code >= LATIN_SMALL_LETTER_A && code <= LATIN_SMALL_LETTER_F)); -} -function isLineTerminator(code) { - return (code === LINE_FEED || - code === CARRIAGE_RETURN || - code === LINE_SEPARATOR || - code === PARAGRAPH_SEPARATOR); -} -function isValidUnicode(code) { - return code >= MIN_CODE_POINT && code <= MAX_CODE_POINT; -} -function digitToInt(code) { - if (code >= LATIN_SMALL_LETTER_A && code <= LATIN_SMALL_LETTER_F) { - return code - LATIN_SMALL_LETTER_A + 10; - } - if (code >= LATIN_CAPITAL_LETTER_A && code <= LATIN_CAPITAL_LETTER_F) { - return code - LATIN_CAPITAL_LETTER_A + 10; - } - return code - DIGIT_ZERO; -} -function isLeadSurrogate(code) { - return code >= 0xd800 && code <= 0xdbff; -} -function isTrailSurrogate(code) { - return code >= 0xdc00 && code <= 0xdfff; -} -function combineSurrogatePair(lead, trail) { - return (lead - 0xd800) * 0x400 + (trail - 0xdc00) + 0x10000; -} - -class GroupSpecifiersAsES2018 { - constructor() { - this.groupName = new Set(); - } - clear() { - this.groupName.clear(); - } - isEmpty() { - return !this.groupName.size; - } - hasInPattern(name) { - return this.groupName.has(name); - } - hasInScope(name) { - return this.hasInPattern(name); - } - addToScope(name) { - this.groupName.add(name); - } - enterDisjunction() { - } - enterAlternative() { - } - leaveDisjunction() { - } -} -class BranchID { - constructor(parent, base) { - this.parent = parent; - this.base = base !== null && base !== void 0 ? base : this; - } - separatedFrom(other) { - var _a, _b; - if (this.base === other.base && this !== other) { - return true; - } - if (other.parent && this.separatedFrom(other.parent)) { - return true; - } - return (_b = (_a = this.parent) === null || _a === void 0 ? void 0 : _a.separatedFrom(other)) !== null && _b !== void 0 ? _b : false; - } - child() { - return new BranchID(this, null); - } - sibling() { - return new BranchID(this.parent, this.base); - } -} -class GroupSpecifiersAsES2025 { - constructor() { - this.branchID = new BranchID(null, null); - this.groupNames = new Map(); - } - clear() { - this.branchID = new BranchID(null, null); - this.groupNames.clear(); - } - isEmpty() { - return !this.groupNames.size; - } - enterDisjunction() { - this.branchID = this.branchID.child(); - } - enterAlternative(index) { - if (index === 0) { - return; - } - this.branchID = this.branchID.sibling(); - } - leaveDisjunction() { - this.branchID = this.branchID.parent; - } - hasInPattern(name) { - return this.groupNames.has(name); - } - hasInScope(name) { - const branches = this.groupNames.get(name); - if (!branches) { - return false; - } - for (const branch of branches) { - if (!branch.separatedFrom(this.branchID)) { - return true; - } - } - return false; - } - addToScope(name) { - const branches = this.groupNames.get(name); - if (branches) { - branches.push(this.branchID); - return; - } - this.groupNames.set(name, [this.branchID]); - } -} - -const legacyImpl = { - at(s, end, i) { - return i < end ? s.charCodeAt(i) : -1; - }, - width(c) { - return 1; - }, -}; -const unicodeImpl = { - at(s, end, i) { - return i < end ? s.codePointAt(i) : -1; - }, - width(c) { - return c > 0xffff ? 2 : 1; - }, -}; -class Reader { - constructor() { - this._impl = legacyImpl; - this._s = ""; - this._i = 0; - this._end = 0; - this._cp1 = -1; - this._w1 = 1; - this._cp2 = -1; - this._w2 = 1; - this._cp3 = -1; - this._w3 = 1; - this._cp4 = -1; - } - get source() { - return this._s; - } - get index() { - return this._i; - } - get currentCodePoint() { - return this._cp1; - } - get nextCodePoint() { - return this._cp2; - } - get nextCodePoint2() { - return this._cp3; - } - get nextCodePoint3() { - return this._cp4; - } - reset(source, start, end, uFlag) { - this._impl = uFlag ? unicodeImpl : legacyImpl; - this._s = source; - this._end = end; - this.rewind(start); - } - rewind(index) { - const impl = this._impl; - this._i = index; - this._cp1 = impl.at(this._s, this._end, index); - this._w1 = impl.width(this._cp1); - this._cp2 = impl.at(this._s, this._end, index + this._w1); - this._w2 = impl.width(this._cp2); - this._cp3 = impl.at(this._s, this._end, index + this._w1 + this._w2); - this._w3 = impl.width(this._cp3); - this._cp4 = impl.at(this._s, this._end, index + this._w1 + this._w2 + this._w3); - } - advance() { - if (this._cp1 !== -1) { - const impl = this._impl; - this._i += this._w1; - this._cp1 = this._cp2; - this._w1 = this._w2; - this._cp2 = this._cp3; - this._w2 = impl.width(this._cp2); - this._cp3 = this._cp4; - this._w3 = impl.width(this._cp3); - this._cp4 = impl.at(this._s, this._end, this._i + this._w1 + this._w2 + this._w3); - } - } - eat(cp) { - if (this._cp1 === cp) { - this.advance(); - return true; - } - return false; - } - eat2(cp1, cp2) { - if (this._cp1 === cp1 && this._cp2 === cp2) { - this.advance(); - this.advance(); - return true; - } - return false; - } - eat3(cp1, cp2, cp3) { - if (this._cp1 === cp1 && this._cp2 === cp2 && this._cp3 === cp3) { - this.advance(); - this.advance(); - this.advance(); - return true; - } - return false; - } -} - -class RegExpSyntaxError extends SyntaxError { - constructor(message, index) { - super(message); - this.index = index; - } -} -function newRegExpSyntaxError(srcCtx, flags, index, message) { - let source = ""; - if (srcCtx.kind === "literal") { - const literal = srcCtx.source.slice(srcCtx.start, srcCtx.end); - if (literal) { - source = `: ${literal}`; - } - } - else if (srcCtx.kind === "pattern") { - const pattern = srcCtx.source.slice(srcCtx.start, srcCtx.end); - const flagsText = `${flags.unicode ? "u" : ""}${flags.unicodeSets ? "v" : ""}`; - source = `: /${pattern}/${flagsText}`; - } - return new RegExpSyntaxError(`Invalid regular expression${source}: ${message}`, index); -} - -const SYNTAX_CHARACTER = new Set([ - CIRCUMFLEX_ACCENT, - DOLLAR_SIGN, - REVERSE_SOLIDUS, - FULL_STOP, - ASTERISK, - PLUS_SIGN, - QUESTION_MARK, - LEFT_PARENTHESIS, - RIGHT_PARENTHESIS, - LEFT_SQUARE_BRACKET, - RIGHT_SQUARE_BRACKET, - LEFT_CURLY_BRACKET, - RIGHT_CURLY_BRACKET, - VERTICAL_LINE, -]); -const CLASS_SET_RESERVED_DOUBLE_PUNCTUATOR_CHARACTER = new Set([ - AMPERSAND, - EXCLAMATION_MARK, - NUMBER_SIGN, - DOLLAR_SIGN, - PERCENT_SIGN, - ASTERISK, - PLUS_SIGN, - COMMA, - FULL_STOP, - COLON, - SEMICOLON, - LESS_THAN_SIGN, - EQUALS_SIGN, - GREATER_THAN_SIGN, - QUESTION_MARK, - COMMERCIAL_AT, - CIRCUMFLEX_ACCENT, - GRAVE_ACCENT, - TILDE, -]); -const CLASS_SET_SYNTAX_CHARACTER = new Set([ - LEFT_PARENTHESIS, - RIGHT_PARENTHESIS, - LEFT_SQUARE_BRACKET, - RIGHT_SQUARE_BRACKET, - LEFT_CURLY_BRACKET, - RIGHT_CURLY_BRACKET, - SOLIDUS, - HYPHEN_MINUS, - REVERSE_SOLIDUS, - VERTICAL_LINE, -]); -const CLASS_SET_RESERVED_PUNCTUATOR = new Set([ - AMPERSAND, - HYPHEN_MINUS, - EXCLAMATION_MARK, - NUMBER_SIGN, - PERCENT_SIGN, - COMMA, - COLON, - SEMICOLON, - LESS_THAN_SIGN, - EQUALS_SIGN, - GREATER_THAN_SIGN, - COMMERCIAL_AT, - GRAVE_ACCENT, - TILDE, -]); -function isSyntaxCharacter(cp) { - return SYNTAX_CHARACTER.has(cp); -} -function isClassSetReservedDoublePunctuatorCharacter(cp) { - return CLASS_SET_RESERVED_DOUBLE_PUNCTUATOR_CHARACTER.has(cp); -} -function isClassSetSyntaxCharacter(cp) { - return CLASS_SET_SYNTAX_CHARACTER.has(cp); -} -function isClassSetReservedPunctuator(cp) { - return CLASS_SET_RESERVED_PUNCTUATOR.has(cp); -} -function isIdentifierStartChar(cp) { - return isIdStart(cp) || cp === DOLLAR_SIGN || cp === LOW_LINE; -} -function isIdentifierPartChar(cp) { - return (isIdContinue(cp) || - cp === DOLLAR_SIGN || - cp === ZERO_WIDTH_NON_JOINER || - cp === ZERO_WIDTH_JOINER); -} -function isUnicodePropertyNameCharacter(cp) { - return isLatinLetter(cp) || cp === LOW_LINE; -} -function isUnicodePropertyValueCharacter(cp) { - return isUnicodePropertyNameCharacter(cp) || isDecimalDigit(cp); -} -class RegExpValidator { - constructor(options) { - this._reader = new Reader(); - this._unicodeMode = false; - this._unicodeSetsMode = false; - this._nFlag = false; - this._lastIntValue = 0; - this._lastRange = { - min: 0, - max: Number.POSITIVE_INFINITY, - }; - this._lastStrValue = ""; - this._lastAssertionIsQuantifiable = false; - this._numCapturingParens = 0; - this._backreferenceNames = new Set(); - this._srcCtx = null; - this._options = options !== null && options !== void 0 ? options : {}; - this._groupSpecifiers = - this.ecmaVersion >= 2025 - ? new GroupSpecifiersAsES2025() - : new GroupSpecifiersAsES2018(); - } - validateLiteral(source, start = 0, end = source.length) { - this._srcCtx = { source, start, end, kind: "literal" }; - this._unicodeSetsMode = this._unicodeMode = this._nFlag = false; - this.reset(source, start, end); - this.onLiteralEnter(start); - if (this.eat(SOLIDUS) && this.eatRegExpBody() && this.eat(SOLIDUS)) { - const flagStart = this.index; - const unicode = source.includes("u", flagStart); - const unicodeSets = source.includes("v", flagStart); - this.validateFlagsInternal(source, flagStart, end); - this.validatePatternInternal(source, start + 1, flagStart - 1, { - unicode, - unicodeSets, - }); - } - else if (start >= end) { - this.raise("Empty"); - } - else { - const c = String.fromCodePoint(this.currentCodePoint); - this.raise(`Unexpected character '${c}'`); - } - this.onLiteralLeave(start, end); - } - validateFlags(source, start = 0, end = source.length) { - this._srcCtx = { source, start, end, kind: "flags" }; - this.validateFlagsInternal(source, start, end); - } - validatePattern(source, start = 0, end = source.length, uFlagOrFlags = undefined) { - this._srcCtx = { source, start, end, kind: "pattern" }; - this.validatePatternInternal(source, start, end, uFlagOrFlags); - } - validatePatternInternal(source, start = 0, end = source.length, uFlagOrFlags = undefined) { - const mode = this._parseFlagsOptionToMode(uFlagOrFlags, end); - this._unicodeMode = mode.unicodeMode; - this._nFlag = mode.nFlag; - this._unicodeSetsMode = mode.unicodeSetsMode; - this.reset(source, start, end); - this.consumePattern(); - if (!this._nFlag && - this.ecmaVersion >= 2018 && - !this._groupSpecifiers.isEmpty()) { - this._nFlag = true; - this.rewind(start); - this.consumePattern(); - } - } - validateFlagsInternal(source, start, end) { - const existingFlags = new Set(); - let global = false; - let ignoreCase = false; - let multiline = false; - let sticky = false; - let unicode = false; - let dotAll = false; - let hasIndices = false; - let unicodeSets = false; - for (let i = start; i < end; ++i) { - const flag = source.charCodeAt(i); - if (existingFlags.has(flag)) { - this.raise(`Duplicated flag '${source[i]}'`, { index: start }); - } - existingFlags.add(flag); - if (flag === LATIN_SMALL_LETTER_G) { - global = true; - } - else if (flag === LATIN_SMALL_LETTER_I) { - ignoreCase = true; - } - else if (flag === LATIN_SMALL_LETTER_M) { - multiline = true; - } - else if (flag === LATIN_SMALL_LETTER_U && - this.ecmaVersion >= 2015) { - unicode = true; - } - else if (flag === LATIN_SMALL_LETTER_Y && - this.ecmaVersion >= 2015) { - sticky = true; - } - else if (flag === LATIN_SMALL_LETTER_S && - this.ecmaVersion >= 2018) { - dotAll = true; - } - else if (flag === LATIN_SMALL_LETTER_D && - this.ecmaVersion >= 2022) { - hasIndices = true; - } - else if (flag === LATIN_SMALL_LETTER_V && - this.ecmaVersion >= 2024) { - unicodeSets = true; - } - else { - this.raise(`Invalid flag '${source[i]}'`, { index: start }); - } - } - this.onRegExpFlags(start, end, { - global, - ignoreCase, - multiline, - unicode, - sticky, - dotAll, - hasIndices, - unicodeSets, - }); - } - _parseFlagsOptionToMode(uFlagOrFlags, sourceEnd) { - let unicode = false; - let unicodeSets = false; - if (uFlagOrFlags && this.ecmaVersion >= 2015) { - if (typeof uFlagOrFlags === "object") { - unicode = Boolean(uFlagOrFlags.unicode); - if (this.ecmaVersion >= 2024) { - unicodeSets = Boolean(uFlagOrFlags.unicodeSets); - } - } - else { - unicode = uFlagOrFlags; - } - } - if (unicode && unicodeSets) { - this.raise("Invalid regular expression flags", { - index: sourceEnd + 1, - unicode, - unicodeSets, - }); - } - const unicodeMode = unicode || unicodeSets; - const nFlag = (unicode && this.ecmaVersion >= 2018) || - unicodeSets || - Boolean(this._options.strict && this.ecmaVersion >= 2023); - const unicodeSetsMode = unicodeSets; - return { unicodeMode, nFlag, unicodeSetsMode }; - } - get strict() { - return Boolean(this._options.strict) || this._unicodeMode; - } - get ecmaVersion() { - var _a; - return (_a = this._options.ecmaVersion) !== null && _a !== void 0 ? _a : latestEcmaVersion; - } - onLiteralEnter(start) { - if (this._options.onLiteralEnter) { - this._options.onLiteralEnter(start); - } - } - onLiteralLeave(start, end) { - if (this._options.onLiteralLeave) { - this._options.onLiteralLeave(start, end); - } - } - onRegExpFlags(start, end, flags) { - if (this._options.onRegExpFlags) { - this._options.onRegExpFlags(start, end, flags); - } - if (this._options.onFlags) { - this._options.onFlags(start, end, flags.global, flags.ignoreCase, flags.multiline, flags.unicode, flags.sticky, flags.dotAll, flags.hasIndices); - } - } - onPatternEnter(start) { - if (this._options.onPatternEnter) { - this._options.onPatternEnter(start); - } - } - onPatternLeave(start, end) { - if (this._options.onPatternLeave) { - this._options.onPatternLeave(start, end); - } - } - onDisjunctionEnter(start) { - if (this._options.onDisjunctionEnter) { - this._options.onDisjunctionEnter(start); - } - } - onDisjunctionLeave(start, end) { - if (this._options.onDisjunctionLeave) { - this._options.onDisjunctionLeave(start, end); - } - } - onAlternativeEnter(start, index) { - if (this._options.onAlternativeEnter) { - this._options.onAlternativeEnter(start, index); - } - } - onAlternativeLeave(start, end, index) { - if (this._options.onAlternativeLeave) { - this._options.onAlternativeLeave(start, end, index); - } - } - onGroupEnter(start) { - if (this._options.onGroupEnter) { - this._options.onGroupEnter(start); - } - } - onGroupLeave(start, end) { - if (this._options.onGroupLeave) { - this._options.onGroupLeave(start, end); - } - } - onCapturingGroupEnter(start, name) { - if (this._options.onCapturingGroupEnter) { - this._options.onCapturingGroupEnter(start, name); - } - } - onCapturingGroupLeave(start, end, name) { - if (this._options.onCapturingGroupLeave) { - this._options.onCapturingGroupLeave(start, end, name); - } - } - onQuantifier(start, end, min, max, greedy) { - if (this._options.onQuantifier) { - this._options.onQuantifier(start, end, min, max, greedy); - } - } - onLookaroundAssertionEnter(start, kind, negate) { - if (this._options.onLookaroundAssertionEnter) { - this._options.onLookaroundAssertionEnter(start, kind, negate); - } - } - onLookaroundAssertionLeave(start, end, kind, negate) { - if (this._options.onLookaroundAssertionLeave) { - this._options.onLookaroundAssertionLeave(start, end, kind, negate); - } - } - onEdgeAssertion(start, end, kind) { - if (this._options.onEdgeAssertion) { - this._options.onEdgeAssertion(start, end, kind); - } - } - onWordBoundaryAssertion(start, end, kind, negate) { - if (this._options.onWordBoundaryAssertion) { - this._options.onWordBoundaryAssertion(start, end, kind, negate); - } - } - onAnyCharacterSet(start, end, kind) { - if (this._options.onAnyCharacterSet) { - this._options.onAnyCharacterSet(start, end, kind); - } - } - onEscapeCharacterSet(start, end, kind, negate) { - if (this._options.onEscapeCharacterSet) { - this._options.onEscapeCharacterSet(start, end, kind, negate); - } - } - onUnicodePropertyCharacterSet(start, end, kind, key, value, negate, strings) { - if (this._options.onUnicodePropertyCharacterSet) { - this._options.onUnicodePropertyCharacterSet(start, end, kind, key, value, negate, strings); - } - } - onCharacter(start, end, value) { - if (this._options.onCharacter) { - this._options.onCharacter(start, end, value); - } - } - onBackreference(start, end, ref) { - if (this._options.onBackreference) { - this._options.onBackreference(start, end, ref); - } - } - onCharacterClassEnter(start, negate, unicodeSets) { - if (this._options.onCharacterClassEnter) { - this._options.onCharacterClassEnter(start, negate, unicodeSets); - } - } - onCharacterClassLeave(start, end, negate) { - if (this._options.onCharacterClassLeave) { - this._options.onCharacterClassLeave(start, end, negate); - } - } - onCharacterClassRange(start, end, min, max) { - if (this._options.onCharacterClassRange) { - this._options.onCharacterClassRange(start, end, min, max); - } - } - onClassIntersection(start, end) { - if (this._options.onClassIntersection) { - this._options.onClassIntersection(start, end); - } - } - onClassSubtraction(start, end) { - if (this._options.onClassSubtraction) { - this._options.onClassSubtraction(start, end); - } - } - onClassStringDisjunctionEnter(start) { - if (this._options.onClassStringDisjunctionEnter) { - this._options.onClassStringDisjunctionEnter(start); - } - } - onClassStringDisjunctionLeave(start, end) { - if (this._options.onClassStringDisjunctionLeave) { - this._options.onClassStringDisjunctionLeave(start, end); - } - } - onStringAlternativeEnter(start, index) { - if (this._options.onStringAlternativeEnter) { - this._options.onStringAlternativeEnter(start, index); - } - } - onStringAlternativeLeave(start, end, index) { - if (this._options.onStringAlternativeLeave) { - this._options.onStringAlternativeLeave(start, end, index); - } - } - get index() { - return this._reader.index; - } - get currentCodePoint() { - return this._reader.currentCodePoint; - } - get nextCodePoint() { - return this._reader.nextCodePoint; - } - get nextCodePoint2() { - return this._reader.nextCodePoint2; - } - get nextCodePoint3() { - return this._reader.nextCodePoint3; - } - reset(source, start, end) { - this._reader.reset(source, start, end, this._unicodeMode); - } - rewind(index) { - this._reader.rewind(index); - } - advance() { - this._reader.advance(); - } - eat(cp) { - return this._reader.eat(cp); - } - eat2(cp1, cp2) { - return this._reader.eat2(cp1, cp2); - } - eat3(cp1, cp2, cp3) { - return this._reader.eat3(cp1, cp2, cp3); - } - raise(message, context) { - var _a, _b, _c; - throw newRegExpSyntaxError(this._srcCtx, { - unicode: (_a = context === null || context === void 0 ? void 0 : context.unicode) !== null && _a !== void 0 ? _a : (this._unicodeMode && !this._unicodeSetsMode), - unicodeSets: (_b = context === null || context === void 0 ? void 0 : context.unicodeSets) !== null && _b !== void 0 ? _b : this._unicodeSetsMode, - }, (_c = context === null || context === void 0 ? void 0 : context.index) !== null && _c !== void 0 ? _c : this.index, message); - } - eatRegExpBody() { - const start = this.index; - let inClass = false; - let escaped = false; - for (;;) { - const cp = this.currentCodePoint; - if (cp === -1 || isLineTerminator(cp)) { - const kind = inClass ? "character class" : "regular expression"; - this.raise(`Unterminated ${kind}`); - } - if (escaped) { - escaped = false; - } - else if (cp === REVERSE_SOLIDUS) { - escaped = true; - } - else if (cp === LEFT_SQUARE_BRACKET) { - inClass = true; - } - else if (cp === RIGHT_SQUARE_BRACKET) { - inClass = false; - } - else if ((cp === SOLIDUS && !inClass) || - (cp === ASTERISK && this.index === start)) { - break; - } - this.advance(); - } - return this.index !== start; - } - consumePattern() { - const start = this.index; - this._numCapturingParens = this.countCapturingParens(); - this._groupSpecifiers.clear(); - this._backreferenceNames.clear(); - this.onPatternEnter(start); - this.consumeDisjunction(); - const cp = this.currentCodePoint; - if (this.currentCodePoint !== -1) { - if (cp === RIGHT_PARENTHESIS) { - this.raise("Unmatched ')'"); - } - if (cp === REVERSE_SOLIDUS) { - this.raise("\\ at end of pattern"); - } - if (cp === RIGHT_SQUARE_BRACKET || cp === RIGHT_CURLY_BRACKET) { - this.raise("Lone quantifier brackets"); - } - const c = String.fromCodePoint(cp); - this.raise(`Unexpected character '${c}'`); - } - for (const name of this._backreferenceNames) { - if (!this._groupSpecifiers.hasInPattern(name)) { - this.raise("Invalid named capture referenced"); - } - } - this.onPatternLeave(start, this.index); - } - countCapturingParens() { - const start = this.index; - let inClass = false; - let escaped = false; - let count = 0; - let cp = 0; - while ((cp = this.currentCodePoint) !== -1) { - if (escaped) { - escaped = false; - } - else if (cp === REVERSE_SOLIDUS) { - escaped = true; - } - else if (cp === LEFT_SQUARE_BRACKET) { - inClass = true; - } - else if (cp === RIGHT_SQUARE_BRACKET) { - inClass = false; - } - else if (cp === LEFT_PARENTHESIS && - !inClass && - (this.nextCodePoint !== QUESTION_MARK || - (this.nextCodePoint2 === LESS_THAN_SIGN && - this.nextCodePoint3 !== EQUALS_SIGN && - this.nextCodePoint3 !== EXCLAMATION_MARK))) { - count += 1; - } - this.advance(); - } - this.rewind(start); - return count; - } - consumeDisjunction() { - const start = this.index; - let i = 0; - this._groupSpecifiers.enterDisjunction(); - this.onDisjunctionEnter(start); - do { - this.consumeAlternative(i++); - } while (this.eat(VERTICAL_LINE)); - if (this.consumeQuantifier(true)) { - this.raise("Nothing to repeat"); - } - if (this.eat(LEFT_CURLY_BRACKET)) { - this.raise("Lone quantifier brackets"); - } - this.onDisjunctionLeave(start, this.index); - this._groupSpecifiers.leaveDisjunction(); - } - consumeAlternative(i) { - const start = this.index; - this._groupSpecifiers.enterAlternative(i); - this.onAlternativeEnter(start, i); - while (this.currentCodePoint !== -1 && this.consumeTerm()) { - } - this.onAlternativeLeave(start, this.index, i); - } - consumeTerm() { - if (this._unicodeMode || this.strict) { - return (this.consumeAssertion() || - (this.consumeAtom() && this.consumeOptionalQuantifier())); - } - return ((this.consumeAssertion() && - (!this._lastAssertionIsQuantifiable || - this.consumeOptionalQuantifier())) || - (this.consumeExtendedAtom() && this.consumeOptionalQuantifier())); - } - consumeOptionalQuantifier() { - this.consumeQuantifier(); - return true; - } - consumeAssertion() { - const start = this.index; - this._lastAssertionIsQuantifiable = false; - if (this.eat(CIRCUMFLEX_ACCENT)) { - this.onEdgeAssertion(start, this.index, "start"); - return true; - } - if (this.eat(DOLLAR_SIGN)) { - this.onEdgeAssertion(start, this.index, "end"); - return true; - } - if (this.eat2(REVERSE_SOLIDUS, LATIN_CAPITAL_LETTER_B)) { - this.onWordBoundaryAssertion(start, this.index, "word", true); - return true; - } - if (this.eat2(REVERSE_SOLIDUS, LATIN_SMALL_LETTER_B)) { - this.onWordBoundaryAssertion(start, this.index, "word", false); - return true; - } - if (this.eat2(LEFT_PARENTHESIS, QUESTION_MARK)) { - const lookbehind = this.ecmaVersion >= 2018 && this.eat(LESS_THAN_SIGN); - let negate = false; - if (this.eat(EQUALS_SIGN) || - (negate = this.eat(EXCLAMATION_MARK))) { - const kind = lookbehind ? "lookbehind" : "lookahead"; - this.onLookaroundAssertionEnter(start, kind, negate); - this.consumeDisjunction(); - if (!this.eat(RIGHT_PARENTHESIS)) { - this.raise("Unterminated group"); - } - this._lastAssertionIsQuantifiable = !lookbehind && !this.strict; - this.onLookaroundAssertionLeave(start, this.index, kind, negate); - return true; - } - this.rewind(start); - } - return false; - } - consumeQuantifier(noConsume = false) { - const start = this.index; - let min = 0; - let max = 0; - let greedy = false; - if (this.eat(ASTERISK)) { - min = 0; - max = Number.POSITIVE_INFINITY; - } - else if (this.eat(PLUS_SIGN)) { - min = 1; - max = Number.POSITIVE_INFINITY; - } - else if (this.eat(QUESTION_MARK)) { - min = 0; - max = 1; - } - else if (this.eatBracedQuantifier(noConsume)) { - ({ min, max } = this._lastRange); - } - else { - return false; - } - greedy = !this.eat(QUESTION_MARK); - if (!noConsume) { - this.onQuantifier(start, this.index, min, max, greedy); - } - return true; - } - eatBracedQuantifier(noError) { - const start = this.index; - if (this.eat(LEFT_CURLY_BRACKET)) { - if (this.eatDecimalDigits()) { - const min = this._lastIntValue; - let max = min; - if (this.eat(COMMA)) { - max = this.eatDecimalDigits() - ? this._lastIntValue - : Number.POSITIVE_INFINITY; - } - if (this.eat(RIGHT_CURLY_BRACKET)) { - if (!noError && max < min) { - this.raise("numbers out of order in {} quantifier"); - } - this._lastRange = { min, max }; - return true; - } - } - if (!noError && (this._unicodeMode || this.strict)) { - this.raise("Incomplete quantifier"); - } - this.rewind(start); - } - return false; - } - consumeAtom() { - return (this.consumePatternCharacter() || - this.consumeDot() || - this.consumeReverseSolidusAtomEscape() || - Boolean(this.consumeCharacterClass()) || - this.consumeUncapturingGroup() || - this.consumeCapturingGroup()); - } - consumeDot() { - if (this.eat(FULL_STOP)) { - this.onAnyCharacterSet(this.index - 1, this.index, "any"); - return true; - } - return false; - } - consumeReverseSolidusAtomEscape() { - const start = this.index; - if (this.eat(REVERSE_SOLIDUS)) { - if (this.consumeAtomEscape()) { - return true; - } - this.rewind(start); - } - return false; - } - consumeUncapturingGroup() { - const start = this.index; - if (this.eat3(LEFT_PARENTHESIS, QUESTION_MARK, COLON)) { - this.onGroupEnter(start); - this.consumeDisjunction(); - if (!this.eat(RIGHT_PARENTHESIS)) { - this.raise("Unterminated group"); - } - this.onGroupLeave(start, this.index); - return true; - } - return false; - } - consumeCapturingGroup() { - const start = this.index; - if (this.eat(LEFT_PARENTHESIS)) { - let name = null; - if (this.ecmaVersion >= 2018) { - if (this.consumeGroupSpecifier()) { - name = this._lastStrValue; - } - } - else if (this.currentCodePoint === QUESTION_MARK) { - this.raise("Invalid group"); - } - this.onCapturingGroupEnter(start, name); - this.consumeDisjunction(); - if (!this.eat(RIGHT_PARENTHESIS)) { - this.raise("Unterminated group"); - } - this.onCapturingGroupLeave(start, this.index, name); - return true; - } - return false; - } - consumeExtendedAtom() { - return (this.consumeDot() || - this.consumeReverseSolidusAtomEscape() || - this.consumeReverseSolidusFollowedByC() || - Boolean(this.consumeCharacterClass()) || - this.consumeUncapturingGroup() || - this.consumeCapturingGroup() || - this.consumeInvalidBracedQuantifier() || - this.consumeExtendedPatternCharacter()); - } - consumeReverseSolidusFollowedByC() { - const start = this.index; - if (this.currentCodePoint === REVERSE_SOLIDUS && - this.nextCodePoint === LATIN_SMALL_LETTER_C) { - this._lastIntValue = this.currentCodePoint; - this.advance(); - this.onCharacter(start, this.index, REVERSE_SOLIDUS); - return true; - } - return false; - } - consumeInvalidBracedQuantifier() { - if (this.eatBracedQuantifier(true)) { - this.raise("Nothing to repeat"); - } - return false; - } - consumePatternCharacter() { - const start = this.index; - const cp = this.currentCodePoint; - if (cp !== -1 && !isSyntaxCharacter(cp)) { - this.advance(); - this.onCharacter(start, this.index, cp); - return true; - } - return false; - } - consumeExtendedPatternCharacter() { - const start = this.index; - const cp = this.currentCodePoint; - if (cp !== -1 && - cp !== CIRCUMFLEX_ACCENT && - cp !== DOLLAR_SIGN && - cp !== REVERSE_SOLIDUS && - cp !== FULL_STOP && - cp !== ASTERISK && - cp !== PLUS_SIGN && - cp !== QUESTION_MARK && - cp !== LEFT_PARENTHESIS && - cp !== RIGHT_PARENTHESIS && - cp !== LEFT_SQUARE_BRACKET && - cp !== VERTICAL_LINE) { - this.advance(); - this.onCharacter(start, this.index, cp); - return true; - } - return false; - } - consumeGroupSpecifier() { - if (this.eat(QUESTION_MARK)) { - if (this.eatGroupName()) { - if (!this._groupSpecifiers.hasInScope(this._lastStrValue)) { - this._groupSpecifiers.addToScope(this._lastStrValue); - return true; - } - this.raise("Duplicate capture group name"); - } - this.raise("Invalid group"); - } - return false; - } - consumeAtomEscape() { - if (this.consumeBackreference() || - this.consumeCharacterClassEscape() || - this.consumeCharacterEscape() || - (this._nFlag && this.consumeKGroupName())) { - return true; - } - if (this.strict || this._unicodeMode) { - this.raise("Invalid escape"); - } - return false; - } - consumeBackreference() { - const start = this.index; - if (this.eatDecimalEscape()) { - const n = this._lastIntValue; - if (n <= this._numCapturingParens) { - this.onBackreference(start - 1, this.index, n); - return true; - } - if (this.strict || this._unicodeMode) { - this.raise("Invalid escape"); - } - this.rewind(start); - } - return false; - } - consumeCharacterClassEscape() { - var _a; - const start = this.index; - if (this.eat(LATIN_SMALL_LETTER_D)) { - this._lastIntValue = -1; - this.onEscapeCharacterSet(start - 1, this.index, "digit", false); - return {}; - } - if (this.eat(LATIN_CAPITAL_LETTER_D)) { - this._lastIntValue = -1; - this.onEscapeCharacterSet(start - 1, this.index, "digit", true); - return {}; - } - if (this.eat(LATIN_SMALL_LETTER_S)) { - this._lastIntValue = -1; - this.onEscapeCharacterSet(start - 1, this.index, "space", false); - return {}; - } - if (this.eat(LATIN_CAPITAL_LETTER_S)) { - this._lastIntValue = -1; - this.onEscapeCharacterSet(start - 1, this.index, "space", true); - return {}; - } - if (this.eat(LATIN_SMALL_LETTER_W)) { - this._lastIntValue = -1; - this.onEscapeCharacterSet(start - 1, this.index, "word", false); - return {}; - } - if (this.eat(LATIN_CAPITAL_LETTER_W)) { - this._lastIntValue = -1; - this.onEscapeCharacterSet(start - 1, this.index, "word", true); - return {}; - } - let negate = false; - if (this._unicodeMode && - this.ecmaVersion >= 2018 && - (this.eat(LATIN_SMALL_LETTER_P) || - (negate = this.eat(LATIN_CAPITAL_LETTER_P)))) { - this._lastIntValue = -1; - let result = null; - if (this.eat(LEFT_CURLY_BRACKET) && - (result = this.eatUnicodePropertyValueExpression()) && - this.eat(RIGHT_CURLY_BRACKET)) { - if (negate && result.strings) { - this.raise("Invalid property name"); - } - this.onUnicodePropertyCharacterSet(start - 1, this.index, "property", result.key, result.value, negate, (_a = result.strings) !== null && _a !== void 0 ? _a : false); - return { mayContainStrings: result.strings }; - } - this.raise("Invalid property name"); - } - return null; - } - consumeCharacterEscape() { - const start = this.index; - if (this.eatControlEscape() || - this.eatCControlLetter() || - this.eatZero() || - this.eatHexEscapeSequence() || - this.eatRegExpUnicodeEscapeSequence() || - (!this.strict && - !this._unicodeMode && - this.eatLegacyOctalEscapeSequence()) || - this.eatIdentityEscape()) { - this.onCharacter(start - 1, this.index, this._lastIntValue); - return true; - } - return false; - } - consumeKGroupName() { - const start = this.index; - if (this.eat(LATIN_SMALL_LETTER_K)) { - if (this.eatGroupName()) { - const groupName = this._lastStrValue; - this._backreferenceNames.add(groupName); - this.onBackreference(start - 1, this.index, groupName); - return true; - } - this.raise("Invalid named reference"); - } - return false; - } - consumeCharacterClass() { - const start = this.index; - if (this.eat(LEFT_SQUARE_BRACKET)) { - const negate = this.eat(CIRCUMFLEX_ACCENT); - this.onCharacterClassEnter(start, negate, this._unicodeSetsMode); - const result = this.consumeClassContents(); - if (!this.eat(RIGHT_SQUARE_BRACKET)) { - if (this.currentCodePoint === -1) { - this.raise("Unterminated character class"); - } - this.raise("Invalid character in character class"); - } - if (negate && result.mayContainStrings) { - this.raise("Negated character class may contain strings"); - } - this.onCharacterClassLeave(start, this.index, negate); - return result; - } - return null; - } - consumeClassContents() { - if (this._unicodeSetsMode) { - if (this.currentCodePoint === RIGHT_SQUARE_BRACKET) { - return {}; - } - const result = this.consumeClassSetExpression(); - return result; - } - const strict = this.strict || this._unicodeMode; - for (;;) { - const rangeStart = this.index; - if (!this.consumeClassAtom()) { - break; - } - const min = this._lastIntValue; - if (!this.eat(HYPHEN_MINUS)) { - continue; - } - this.onCharacter(this.index - 1, this.index, HYPHEN_MINUS); - if (!this.consumeClassAtom()) { - break; - } - const max = this._lastIntValue; - if (min === -1 || max === -1) { - if (strict) { - this.raise("Invalid character class"); - } - continue; - } - if (min > max) { - this.raise("Range out of order in character class"); - } - this.onCharacterClassRange(rangeStart, this.index, min, max); - } - return {}; - } - consumeClassAtom() { - const start = this.index; - const cp = this.currentCodePoint; - if (cp !== -1 && - cp !== REVERSE_SOLIDUS && - cp !== RIGHT_SQUARE_BRACKET) { - this.advance(); - this._lastIntValue = cp; - this.onCharacter(start, this.index, this._lastIntValue); - return true; - } - if (this.eat(REVERSE_SOLIDUS)) { - if (this.consumeClassEscape()) { - return true; - } - if (!this.strict && - this.currentCodePoint === LATIN_SMALL_LETTER_C) { - this._lastIntValue = REVERSE_SOLIDUS; - this.onCharacter(start, this.index, this._lastIntValue); - return true; - } - if (this.strict || this._unicodeMode) { - this.raise("Invalid escape"); - } - this.rewind(start); - } - return false; - } - consumeClassEscape() { - const start = this.index; - if (this.eat(LATIN_SMALL_LETTER_B)) { - this._lastIntValue = BACKSPACE; - this.onCharacter(start - 1, this.index, this._lastIntValue); - return true; - } - if (this._unicodeMode && this.eat(HYPHEN_MINUS)) { - this._lastIntValue = HYPHEN_MINUS; - this.onCharacter(start - 1, this.index, this._lastIntValue); - return true; - } - let cp = 0; - if (!this.strict && - !this._unicodeMode && - this.currentCodePoint === LATIN_SMALL_LETTER_C && - (isDecimalDigit((cp = this.nextCodePoint)) || cp === LOW_LINE)) { - this.advance(); - this.advance(); - this._lastIntValue = cp % 0x20; - this.onCharacter(start - 1, this.index, this._lastIntValue); - return true; - } - return (Boolean(this.consumeCharacterClassEscape()) || - this.consumeCharacterEscape()); - } - consumeClassSetExpression() { - const start = this.index; - let mayContainStrings = false; - let result = null; - if (this.consumeClassSetCharacter()) { - if (this.consumeClassSetRangeFromOperator(start)) { - this.consumeClassUnionRight({}); - return {}; - } - mayContainStrings = false; - } - else if ((result = this.consumeClassSetOperand())) { - mayContainStrings = result.mayContainStrings; - } - else { - const cp = this.currentCodePoint; - if (cp === REVERSE_SOLIDUS) { - this.advance(); - this.raise("Invalid escape"); - } - if (cp === this.nextCodePoint && - isClassSetReservedDoublePunctuatorCharacter(cp)) { - this.raise("Invalid set operation in character class"); - } - this.raise("Invalid character in character class"); - } - if (this.eat2(AMPERSAND, AMPERSAND)) { - while (this.currentCodePoint !== AMPERSAND && - (result = this.consumeClassSetOperand())) { - this.onClassIntersection(start, this.index); - if (!result.mayContainStrings) { - mayContainStrings = false; - } - if (this.eat2(AMPERSAND, AMPERSAND)) { - continue; - } - return { mayContainStrings }; - } - this.raise("Invalid character in character class"); - } - if (this.eat2(HYPHEN_MINUS, HYPHEN_MINUS)) { - while (this.consumeClassSetOperand()) { - this.onClassSubtraction(start, this.index); - if (this.eat2(HYPHEN_MINUS, HYPHEN_MINUS)) { - continue; - } - return { mayContainStrings }; - } - this.raise("Invalid character in character class"); - } - return this.consumeClassUnionRight({ mayContainStrings }); - } - consumeClassUnionRight(leftResult) { - let mayContainStrings = leftResult.mayContainStrings; - for (;;) { - const start = this.index; - if (this.consumeClassSetCharacter()) { - this.consumeClassSetRangeFromOperator(start); - continue; - } - const result = this.consumeClassSetOperand(); - if (result) { - if (result.mayContainStrings) { - mayContainStrings = true; - } - continue; - } - break; - } - return { mayContainStrings }; - } - consumeClassSetRangeFromOperator(start) { - const currentStart = this.index; - const min = this._lastIntValue; - if (this.eat(HYPHEN_MINUS)) { - if (this.consumeClassSetCharacter()) { - const max = this._lastIntValue; - if (min === -1 || max === -1) { - this.raise("Invalid character class"); - } - if (min > max) { - this.raise("Range out of order in character class"); - } - this.onCharacterClassRange(start, this.index, min, max); - return true; - } - this.rewind(currentStart); - } - return false; - } - consumeClassSetOperand() { - let result = null; - if ((result = this.consumeNestedClass())) { - return result; - } - if ((result = this.consumeClassStringDisjunction())) { - return result; - } - if (this.consumeClassSetCharacter()) { - return {}; - } - return null; - } - consumeNestedClass() { - const start = this.index; - if (this.eat(LEFT_SQUARE_BRACKET)) { - const negate = this.eat(CIRCUMFLEX_ACCENT); - this.onCharacterClassEnter(start, negate, true); - const result = this.consumeClassContents(); - if (!this.eat(RIGHT_SQUARE_BRACKET)) { - this.raise("Unterminated character class"); - } - if (negate && result.mayContainStrings) { - this.raise("Negated character class may contain strings"); - } - this.onCharacterClassLeave(start, this.index, negate); - return result; - } - if (this.eat(REVERSE_SOLIDUS)) { - const result = this.consumeCharacterClassEscape(); - if (result) { - return result; - } - this.rewind(start); - } - return null; - } - consumeClassStringDisjunction() { - const start = this.index; - if (this.eat3(REVERSE_SOLIDUS, LATIN_SMALL_LETTER_Q, LEFT_CURLY_BRACKET)) { - this.onClassStringDisjunctionEnter(start); - let i = 0; - let mayContainStrings = false; - do { - if (this.consumeClassString(i++).mayContainStrings) { - mayContainStrings = true; - } - } while (this.eat(VERTICAL_LINE)); - if (this.eat(RIGHT_CURLY_BRACKET)) { - this.onClassStringDisjunctionLeave(start, this.index); - return { mayContainStrings }; - } - this.raise("Unterminated class string disjunction"); - } - return null; - } - consumeClassString(i) { - const start = this.index; - let count = 0; - this.onStringAlternativeEnter(start, i); - while (this.currentCodePoint !== -1 && - this.consumeClassSetCharacter()) { - count++; - } - this.onStringAlternativeLeave(start, this.index, i); - return { mayContainStrings: count !== 1 }; - } - consumeClassSetCharacter() { - const start = this.index; - const cp = this.currentCodePoint; - if (cp !== this.nextCodePoint || - !isClassSetReservedDoublePunctuatorCharacter(cp)) { - if (cp !== -1 && !isClassSetSyntaxCharacter(cp)) { - this._lastIntValue = cp; - this.advance(); - this.onCharacter(start, this.index, this._lastIntValue); - return true; - } - } - if (this.eat(REVERSE_SOLIDUS)) { - if (this.consumeCharacterEscape()) { - return true; - } - if (isClassSetReservedPunctuator(this.currentCodePoint)) { - this._lastIntValue = this.currentCodePoint; - this.advance(); - this.onCharacter(start, this.index, this._lastIntValue); - return true; - } - if (this.eat(LATIN_SMALL_LETTER_B)) { - this._lastIntValue = BACKSPACE; - this.onCharacter(start, this.index, this._lastIntValue); - return true; - } - this.rewind(start); - } - return false; - } - eatGroupName() { - if (this.eat(LESS_THAN_SIGN)) { - if (this.eatRegExpIdentifierName() && this.eat(GREATER_THAN_SIGN)) { - return true; - } - this.raise("Invalid capture group name"); - } - return false; - } - eatRegExpIdentifierName() { - if (this.eatRegExpIdentifierStart()) { - this._lastStrValue = String.fromCodePoint(this._lastIntValue); - while (this.eatRegExpIdentifierPart()) { - this._lastStrValue += String.fromCodePoint(this._lastIntValue); - } - return true; - } - return false; - } - eatRegExpIdentifierStart() { - const start = this.index; - const forceUFlag = !this._unicodeMode && this.ecmaVersion >= 2020; - let cp = this.currentCodePoint; - this.advance(); - if (cp === REVERSE_SOLIDUS && - this.eatRegExpUnicodeEscapeSequence(forceUFlag)) { - cp = this._lastIntValue; - } - else if (forceUFlag && - isLeadSurrogate(cp) && - isTrailSurrogate(this.currentCodePoint)) { - cp = combineSurrogatePair(cp, this.currentCodePoint); - this.advance(); - } - if (isIdentifierStartChar(cp)) { - this._lastIntValue = cp; - return true; - } - if (this.index !== start) { - this.rewind(start); - } - return false; - } - eatRegExpIdentifierPart() { - const start = this.index; - const forceUFlag = !this._unicodeMode && this.ecmaVersion >= 2020; - let cp = this.currentCodePoint; - this.advance(); - if (cp === REVERSE_SOLIDUS && - this.eatRegExpUnicodeEscapeSequence(forceUFlag)) { - cp = this._lastIntValue; - } - else if (forceUFlag && - isLeadSurrogate(cp) && - isTrailSurrogate(this.currentCodePoint)) { - cp = combineSurrogatePair(cp, this.currentCodePoint); - this.advance(); - } - if (isIdentifierPartChar(cp)) { - this._lastIntValue = cp; - return true; - } - if (this.index !== start) { - this.rewind(start); - } - return false; - } - eatCControlLetter() { - const start = this.index; - if (this.eat(LATIN_SMALL_LETTER_C)) { - if (this.eatControlLetter()) { - return true; - } - this.rewind(start); - } - return false; - } - eatZero() { - if (this.currentCodePoint === DIGIT_ZERO && - !isDecimalDigit(this.nextCodePoint)) { - this._lastIntValue = 0; - this.advance(); - return true; - } - return false; - } - eatControlEscape() { - if (this.eat(LATIN_SMALL_LETTER_F)) { - this._lastIntValue = FORM_FEED; - return true; - } - if (this.eat(LATIN_SMALL_LETTER_N)) { - this._lastIntValue = LINE_FEED; - return true; - } - if (this.eat(LATIN_SMALL_LETTER_R)) { - this._lastIntValue = CARRIAGE_RETURN; - return true; - } - if (this.eat(LATIN_SMALL_LETTER_T)) { - this._lastIntValue = CHARACTER_TABULATION; - return true; - } - if (this.eat(LATIN_SMALL_LETTER_V)) { - this._lastIntValue = LINE_TABULATION; - return true; - } - return false; - } - eatControlLetter() { - const cp = this.currentCodePoint; - if (isLatinLetter(cp)) { - this.advance(); - this._lastIntValue = cp % 0x20; - return true; - } - return false; - } - eatRegExpUnicodeEscapeSequence(forceUFlag = false) { - const start = this.index; - const uFlag = forceUFlag || this._unicodeMode; - if (this.eat(LATIN_SMALL_LETTER_U)) { - if ((uFlag && this.eatRegExpUnicodeSurrogatePairEscape()) || - this.eatFixedHexDigits(4) || - (uFlag && this.eatRegExpUnicodeCodePointEscape())) { - return true; - } - if (this.strict || uFlag) { - this.raise("Invalid unicode escape"); - } - this.rewind(start); - } - return false; - } - eatRegExpUnicodeSurrogatePairEscape() { - const start = this.index; - if (this.eatFixedHexDigits(4)) { - const lead = this._lastIntValue; - if (isLeadSurrogate(lead) && - this.eat(REVERSE_SOLIDUS) && - this.eat(LATIN_SMALL_LETTER_U) && - this.eatFixedHexDigits(4)) { - const trail = this._lastIntValue; - if (isTrailSurrogate(trail)) { - this._lastIntValue = combineSurrogatePair(lead, trail); - return true; - } - } - this.rewind(start); - } - return false; - } - eatRegExpUnicodeCodePointEscape() { - const start = this.index; - if (this.eat(LEFT_CURLY_BRACKET) && - this.eatHexDigits() && - this.eat(RIGHT_CURLY_BRACKET) && - isValidUnicode(this._lastIntValue)) { - return true; - } - this.rewind(start); - return false; - } - eatIdentityEscape() { - const cp = this.currentCodePoint; - if (this.isValidIdentityEscape(cp)) { - this._lastIntValue = cp; - this.advance(); - return true; - } - return false; - } - isValidIdentityEscape(cp) { - if (cp === -1) { - return false; - } - if (this._unicodeMode) { - return isSyntaxCharacter(cp) || cp === SOLIDUS; - } - if (this.strict) { - return !isIdContinue(cp); - } - if (this._nFlag) { - return !(cp === LATIN_SMALL_LETTER_C || cp === LATIN_SMALL_LETTER_K); - } - return cp !== LATIN_SMALL_LETTER_C; - } - eatDecimalEscape() { - this._lastIntValue = 0; - let cp = this.currentCodePoint; - if (cp >= DIGIT_ONE && cp <= DIGIT_NINE) { - do { - this._lastIntValue = 10 * this._lastIntValue + (cp - DIGIT_ZERO); - this.advance(); - } while ((cp = this.currentCodePoint) >= DIGIT_ZERO && - cp <= DIGIT_NINE); - return true; - } - return false; - } - eatUnicodePropertyValueExpression() { - const start = this.index; - if (this.eatUnicodePropertyName() && this.eat(EQUALS_SIGN)) { - const key = this._lastStrValue; - if (this.eatUnicodePropertyValue()) { - const value = this._lastStrValue; - if (isValidUnicodeProperty(this.ecmaVersion, key, value)) { - return { - key, - value: value || null, - }; - } - this.raise("Invalid property name"); - } - } - this.rewind(start); - if (this.eatLoneUnicodePropertyNameOrValue()) { - const nameOrValue = this._lastStrValue; - if (isValidUnicodeProperty(this.ecmaVersion, "General_Category", nameOrValue)) { - return { - key: "General_Category", - value: nameOrValue || null, - }; - } - if (isValidLoneUnicodeProperty(this.ecmaVersion, nameOrValue)) { - return { - key: nameOrValue, - value: null, - }; - } - if (this._unicodeSetsMode && - isValidLoneUnicodePropertyOfString(this.ecmaVersion, nameOrValue)) { - return { - key: nameOrValue, - value: null, - strings: true, - }; - } - this.raise("Invalid property name"); - } - return null; - } - eatUnicodePropertyName() { - this._lastStrValue = ""; - while (isUnicodePropertyNameCharacter(this.currentCodePoint)) { - this._lastStrValue += String.fromCodePoint(this.currentCodePoint); - this.advance(); - } - return this._lastStrValue !== ""; - } - eatUnicodePropertyValue() { - this._lastStrValue = ""; - while (isUnicodePropertyValueCharacter(this.currentCodePoint)) { - this._lastStrValue += String.fromCodePoint(this.currentCodePoint); - this.advance(); - } - return this._lastStrValue !== ""; - } - eatLoneUnicodePropertyNameOrValue() { - return this.eatUnicodePropertyValue(); - } - eatHexEscapeSequence() { - const start = this.index; - if (this.eat(LATIN_SMALL_LETTER_X)) { - if (this.eatFixedHexDigits(2)) { - return true; - } - if (this._unicodeMode || this.strict) { - this.raise("Invalid escape"); - } - this.rewind(start); - } - return false; - } - eatDecimalDigits() { - const start = this.index; - this._lastIntValue = 0; - while (isDecimalDigit(this.currentCodePoint)) { - this._lastIntValue = - 10 * this._lastIntValue + digitToInt(this.currentCodePoint); - this.advance(); - } - return this.index !== start; - } - eatHexDigits() { - const start = this.index; - this._lastIntValue = 0; - while (isHexDigit(this.currentCodePoint)) { - this._lastIntValue = - 16 * this._lastIntValue + digitToInt(this.currentCodePoint); - this.advance(); - } - return this.index !== start; - } - eatLegacyOctalEscapeSequence() { - if (this.eatOctalDigit()) { - const n1 = this._lastIntValue; - if (this.eatOctalDigit()) { - const n2 = this._lastIntValue; - if (n1 <= 3 && this.eatOctalDigit()) { - this._lastIntValue = n1 * 64 + n2 * 8 + this._lastIntValue; - } - else { - this._lastIntValue = n1 * 8 + n2; - } - } - else { - this._lastIntValue = n1; - } - return true; - } - return false; - } - eatOctalDigit() { - const cp = this.currentCodePoint; - if (isOctalDigit(cp)) { - this.advance(); - this._lastIntValue = cp - DIGIT_ZERO; - return true; - } - this._lastIntValue = 0; - return false; - } - eatFixedHexDigits(length) { - const start = this.index; - this._lastIntValue = 0; - for (let i = 0; i < length; ++i) { - const cp = this.currentCodePoint; - if (!isHexDigit(cp)) { - this.rewind(start); - return false; - } - this._lastIntValue = 16 * this._lastIntValue + digitToInt(cp); - this.advance(); - } - return true; - } -} - -const DUMMY_PATTERN = {}; -const DUMMY_FLAGS = {}; -const DUMMY_CAPTURING_GROUP = {}; -function isClassSetOperand(node) { - return (node.type === "Character" || - node.type === "CharacterSet" || - node.type === "CharacterClass" || - node.type === "ExpressionCharacterClass" || - node.type === "ClassStringDisjunction"); -} -class RegExpParserState { - constructor(options) { - var _a; - this._node = DUMMY_PATTERN; - this._expressionBufferMap = new Map(); - this._flags = DUMMY_FLAGS; - this._backreferences = []; - this._capturingGroups = []; - this.source = ""; - this.strict = Boolean(options === null || options === void 0 ? void 0 : options.strict); - this.ecmaVersion = (_a = options === null || options === void 0 ? void 0 : options.ecmaVersion) !== null && _a !== void 0 ? _a : latestEcmaVersion; - } - get pattern() { - if (this._node.type !== "Pattern") { - throw new Error("UnknownError"); - } - return this._node; - } - get flags() { - if (this._flags.type !== "Flags") { - throw new Error("UnknownError"); - } - return this._flags; - } - onRegExpFlags(start, end, { global, ignoreCase, multiline, unicode, sticky, dotAll, hasIndices, unicodeSets, }) { - this._flags = { - type: "Flags", - parent: null, - start, - end, - raw: this.source.slice(start, end), - global, - ignoreCase, - multiline, - unicode, - sticky, - dotAll, - hasIndices, - unicodeSets, - }; - } - onPatternEnter(start) { - this._node = { - type: "Pattern", - parent: null, - start, - end: start, - raw: "", - alternatives: [], - }; - this._backreferences.length = 0; - this._capturingGroups.length = 0; - } - onPatternLeave(start, end) { - this._node.end = end; - this._node.raw = this.source.slice(start, end); - for (const reference of this._backreferences) { - const ref = reference.ref; - const groups = typeof ref === "number" - ? [this._capturingGroups[ref - 1]] - : this._capturingGroups.filter((g) => g.name === ref); - if (groups.length === 1) { - const group = groups[0]; - reference.ambiguous = false; - reference.resolved = group; - } - else { - reference.ambiguous = true; - reference.resolved = groups; - } - for (const group of groups) { - group.references.push(reference); - } - } - } - onAlternativeEnter(start) { - const parent = this._node; - if (parent.type !== "Assertion" && - parent.type !== "CapturingGroup" && - parent.type !== "Group" && - parent.type !== "Pattern") { - throw new Error("UnknownError"); - } - this._node = { - type: "Alternative", - parent, - start, - end: start, - raw: "", - elements: [], - }; - parent.alternatives.push(this._node); - } - onAlternativeLeave(start, end) { - const node = this._node; - if (node.type !== "Alternative") { - throw new Error("UnknownError"); - } - node.end = end; - node.raw = this.source.slice(start, end); - this._node = node.parent; - } - onGroupEnter(start) { - const parent = this._node; - if (parent.type !== "Alternative") { - throw new Error("UnknownError"); - } - this._node = { - type: "Group", - parent, - start, - end: start, - raw: "", - alternatives: [], - }; - parent.elements.push(this._node); - } - onGroupLeave(start, end) { - const node = this._node; - if (node.type !== "Group" || node.parent.type !== "Alternative") { - throw new Error("UnknownError"); - } - node.end = end; - node.raw = this.source.slice(start, end); - this._node = node.parent; - } - onCapturingGroupEnter(start, name) { - const parent = this._node; - if (parent.type !== "Alternative") { - throw new Error("UnknownError"); - } - this._node = { - type: "CapturingGroup", - parent, - start, - end: start, - raw: "", - name, - alternatives: [], - references: [], - }; - parent.elements.push(this._node); - this._capturingGroups.push(this._node); - } - onCapturingGroupLeave(start, end) { - const node = this._node; - if (node.type !== "CapturingGroup" || - node.parent.type !== "Alternative") { - throw new Error("UnknownError"); - } - node.end = end; - node.raw = this.source.slice(start, end); - this._node = node.parent; - } - onQuantifier(start, end, min, max, greedy) { - const parent = this._node; - if (parent.type !== "Alternative") { - throw new Error("UnknownError"); - } - const element = parent.elements.pop(); - if (element == null || - element.type === "Quantifier" || - (element.type === "Assertion" && element.kind !== "lookahead")) { - throw new Error("UnknownError"); - } - const node = { - type: "Quantifier", - parent, - start: element.start, - end, - raw: this.source.slice(element.start, end), - min, - max, - greedy, - element, - }; - parent.elements.push(node); - element.parent = node; - } - onLookaroundAssertionEnter(start, kind, negate) { - const parent = this._node; - if (parent.type !== "Alternative") { - throw new Error("UnknownError"); - } - const node = (this._node = { - type: "Assertion", - parent, - start, - end: start, - raw: "", - kind, - negate, - alternatives: [], - }); - parent.elements.push(node); - } - onLookaroundAssertionLeave(start, end) { - const node = this._node; - if (node.type !== "Assertion" || node.parent.type !== "Alternative") { - throw new Error("UnknownError"); - } - node.end = end; - node.raw = this.source.slice(start, end); - this._node = node.parent; - } - onEdgeAssertion(start, end, kind) { - const parent = this._node; - if (parent.type !== "Alternative") { - throw new Error("UnknownError"); - } - parent.elements.push({ - type: "Assertion", - parent, - start, - end, - raw: this.source.slice(start, end), - kind, - }); - } - onWordBoundaryAssertion(start, end, kind, negate) { - const parent = this._node; - if (parent.type !== "Alternative") { - throw new Error("UnknownError"); - } - parent.elements.push({ - type: "Assertion", - parent, - start, - end, - raw: this.source.slice(start, end), - kind, - negate, - }); - } - onAnyCharacterSet(start, end, kind) { - const parent = this._node; - if (parent.type !== "Alternative") { - throw new Error("UnknownError"); - } - parent.elements.push({ - type: "CharacterSet", - parent, - start, - end, - raw: this.source.slice(start, end), - kind, - }); - } - onEscapeCharacterSet(start, end, kind, negate) { - const parent = this._node; - if (parent.type !== "Alternative" && parent.type !== "CharacterClass") { - throw new Error("UnknownError"); - } - parent.elements.push({ - type: "CharacterSet", - parent, - start, - end, - raw: this.source.slice(start, end), - kind, - negate, - }); - } - onUnicodePropertyCharacterSet(start, end, kind, key, value, negate, strings) { - const parent = this._node; - if (parent.type !== "Alternative" && parent.type !== "CharacterClass") { - throw new Error("UnknownError"); - } - const base = { - type: "CharacterSet", - parent: null, - start, - end, - raw: this.source.slice(start, end), - kind, - strings: null, - key, - }; - if (strings) { - if ((parent.type === "CharacterClass" && !parent.unicodeSets) || - negate || - value !== null) { - throw new Error("UnknownError"); - } - parent.elements.push(Object.assign(Object.assign({}, base), { parent, strings, value, negate })); - } - else { - parent.elements.push(Object.assign(Object.assign({}, base), { parent, strings, value, negate })); - } - } - onCharacter(start, end, value) { - const parent = this._node; - if (parent.type !== "Alternative" && - parent.type !== "CharacterClass" && - parent.type !== "StringAlternative") { - throw new Error("UnknownError"); - } - parent.elements.push({ - type: "Character", - parent, - start, - end, - raw: this.source.slice(start, end), - value, - }); - } - onBackreference(start, end, ref) { - const parent = this._node; - if (parent.type !== "Alternative") { - throw new Error("UnknownError"); - } - const node = { - type: "Backreference", - parent, - start, - end, - raw: this.source.slice(start, end), - ref, - ambiguous: false, - resolved: DUMMY_CAPTURING_GROUP, - }; - parent.elements.push(node); - this._backreferences.push(node); - } - onCharacterClassEnter(start, negate, unicodeSets) { - const parent = this._node; - const base = { - type: "CharacterClass", - parent, - start, - end: start, - raw: "", - unicodeSets, - negate, - elements: [], - }; - if (parent.type === "Alternative") { - const node = Object.assign(Object.assign({}, base), { parent }); - this._node = node; - parent.elements.push(node); - } - else if (parent.type === "CharacterClass" && - parent.unicodeSets && - unicodeSets) { - const node = Object.assign(Object.assign({}, base), { parent, - unicodeSets }); - this._node = node; - parent.elements.push(node); - } - else { - throw new Error("UnknownError"); - } - } - onCharacterClassLeave(start, end) { - const node = this._node; - if (node.type !== "CharacterClass" || - (node.parent.type !== "Alternative" && - node.parent.type !== "CharacterClass")) { - throw new Error("UnknownError"); - } - const parent = node.parent; - node.end = end; - node.raw = this.source.slice(start, end); - this._node = parent; - const expression = this._expressionBufferMap.get(node); - if (!expression) { - return; - } - if (node.elements.length > 0) { - throw new Error("UnknownError"); - } - this._expressionBufferMap.delete(node); - const newNode = { - type: "ExpressionCharacterClass", - parent, - start: node.start, - end: node.end, - raw: node.raw, - negate: node.negate, - expression, - }; - expression.parent = newNode; - if (node !== parent.elements.pop()) { - throw new Error("UnknownError"); - } - parent.elements.push(newNode); - } - onCharacterClassRange(start, end) { - const parent = this._node; - if (parent.type !== "CharacterClass") { - throw new Error("UnknownError"); - } - const elements = parent.elements; - const max = elements.pop(); - if (!max || max.type !== "Character") { - throw new Error("UnknownError"); - } - if (!parent.unicodeSets) { - const hyphen = elements.pop(); - if (!hyphen || - hyphen.type !== "Character" || - hyphen.value !== HYPHEN_MINUS) { - throw new Error("UnknownError"); - } - } - const min = elements.pop(); - if (!min || min.type !== "Character") { - throw new Error("UnknownError"); - } - const node = { - type: "CharacterClassRange", - parent, - start, - end, - raw: this.source.slice(start, end), - min, - max, - }; - min.parent = node; - max.parent = node; - elements.push(node); - } - onClassIntersection(start, end) { - var _a; - const parent = this._node; - if (parent.type !== "CharacterClass" || !parent.unicodeSets) { - throw new Error("UnknownError"); - } - const right = parent.elements.pop(); - const left = (_a = this._expressionBufferMap.get(parent)) !== null && _a !== void 0 ? _a : parent.elements.pop(); - if (!left || - !right || - left.type === "ClassSubtraction" || - (left.type !== "ClassIntersection" && !isClassSetOperand(left)) || - !isClassSetOperand(right)) { - throw new Error("UnknownError"); - } - const node = { - type: "ClassIntersection", - parent: parent, - start, - end, - raw: this.source.slice(start, end), - left, - right, - }; - left.parent = node; - right.parent = node; - this._expressionBufferMap.set(parent, node); - } - onClassSubtraction(start, end) { - var _a; - const parent = this._node; - if (parent.type !== "CharacterClass" || !parent.unicodeSets) { - throw new Error("UnknownError"); - } - const right = parent.elements.pop(); - const left = (_a = this._expressionBufferMap.get(parent)) !== null && _a !== void 0 ? _a : parent.elements.pop(); - if (!left || - !right || - left.type === "ClassIntersection" || - (left.type !== "ClassSubtraction" && !isClassSetOperand(left)) || - !isClassSetOperand(right)) { - throw new Error("UnknownError"); - } - const node = { - type: "ClassSubtraction", - parent: parent, - start, - end, - raw: this.source.slice(start, end), - left, - right, - }; - left.parent = node; - right.parent = node; - this._expressionBufferMap.set(parent, node); - } - onClassStringDisjunctionEnter(start) { - const parent = this._node; - if (parent.type !== "CharacterClass" || !parent.unicodeSets) { - throw new Error("UnknownError"); - } - this._node = { - type: "ClassStringDisjunction", - parent, - start, - end: start, - raw: "", - alternatives: [], - }; - parent.elements.push(this._node); - } - onClassStringDisjunctionLeave(start, end) { - const node = this._node; - if (node.type !== "ClassStringDisjunction" || - node.parent.type !== "CharacterClass") { - throw new Error("UnknownError"); - } - node.end = end; - node.raw = this.source.slice(start, end); - this._node = node.parent; - } - onStringAlternativeEnter(start) { - const parent = this._node; - if (parent.type !== "ClassStringDisjunction") { - throw new Error("UnknownError"); - } - this._node = { - type: "StringAlternative", - parent, - start, - end: start, - raw: "", - elements: [], - }; - parent.alternatives.push(this._node); - } - onStringAlternativeLeave(start, end) { - const node = this._node; - if (node.type !== "StringAlternative") { - throw new Error("UnknownError"); - } - node.end = end; - node.raw = this.source.slice(start, end); - this._node = node.parent; - } -} -class RegExpParser { - constructor(options) { - this._state = new RegExpParserState(options); - this._validator = new RegExpValidator(this._state); - } - parseLiteral(source, start = 0, end = source.length) { - this._state.source = source; - this._validator.validateLiteral(source, start, end); - const pattern = this._state.pattern; - const flags = this._state.flags; - const literal = { - type: "RegExpLiteral", - parent: null, - start, - end, - raw: source, - pattern, - flags, - }; - pattern.parent = literal; - flags.parent = literal; - return literal; - } - parseFlags(source, start = 0, end = source.length) { - this._state.source = source; - this._validator.validateFlags(source, start, end); - return this._state.flags; - } - parsePattern(source, start = 0, end = source.length, uFlagOrFlags = undefined) { - this._state.source = source; - this._validator.validatePattern(source, start, end, uFlagOrFlags); - return this._state.pattern; - } -} - -class RegExpVisitor { - constructor(handlers) { - this._handlers = handlers; - } - visit(node) { - switch (node.type) { - case "Alternative": - this.visitAlternative(node); - break; - case "Assertion": - this.visitAssertion(node); - break; - case "Backreference": - this.visitBackreference(node); - break; - case "CapturingGroup": - this.visitCapturingGroup(node); - break; - case "Character": - this.visitCharacter(node); - break; - case "CharacterClass": - this.visitCharacterClass(node); - break; - case "CharacterClassRange": - this.visitCharacterClassRange(node); - break; - case "CharacterSet": - this.visitCharacterSet(node); - break; - case "ClassIntersection": - this.visitClassIntersection(node); - break; - case "ClassStringDisjunction": - this.visitClassStringDisjunction(node); - break; - case "ClassSubtraction": - this.visitClassSubtraction(node); - break; - case "ExpressionCharacterClass": - this.visitExpressionCharacterClass(node); - break; - case "Flags": - this.visitFlags(node); - break; - case "Group": - this.visitGroup(node); - break; - case "Pattern": - this.visitPattern(node); - break; - case "Quantifier": - this.visitQuantifier(node); - break; - case "RegExpLiteral": - this.visitRegExpLiteral(node); - break; - case "StringAlternative": - this.visitStringAlternative(node); - break; - default: - throw new Error(`Unknown type: ${node.type}`); - } - } - visitAlternative(node) { - if (this._handlers.onAlternativeEnter) { - this._handlers.onAlternativeEnter(node); - } - node.elements.forEach(this.visit, this); - if (this._handlers.onAlternativeLeave) { - this._handlers.onAlternativeLeave(node); - } - } - visitAssertion(node) { - if (this._handlers.onAssertionEnter) { - this._handlers.onAssertionEnter(node); - } - if (node.kind === "lookahead" || node.kind === "lookbehind") { - node.alternatives.forEach(this.visit, this); - } - if (this._handlers.onAssertionLeave) { - this._handlers.onAssertionLeave(node); - } - } - visitBackreference(node) { - if (this._handlers.onBackreferenceEnter) { - this._handlers.onBackreferenceEnter(node); - } - if (this._handlers.onBackreferenceLeave) { - this._handlers.onBackreferenceLeave(node); - } - } - visitCapturingGroup(node) { - if (this._handlers.onCapturingGroupEnter) { - this._handlers.onCapturingGroupEnter(node); - } - node.alternatives.forEach(this.visit, this); - if (this._handlers.onCapturingGroupLeave) { - this._handlers.onCapturingGroupLeave(node); - } - } - visitCharacter(node) { - if (this._handlers.onCharacterEnter) { - this._handlers.onCharacterEnter(node); - } - if (this._handlers.onCharacterLeave) { - this._handlers.onCharacterLeave(node); - } - } - visitCharacterClass(node) { - if (this._handlers.onCharacterClassEnter) { - this._handlers.onCharacterClassEnter(node); - } - node.elements.forEach(this.visit, this); - if (this._handlers.onCharacterClassLeave) { - this._handlers.onCharacterClassLeave(node); - } - } - visitCharacterClassRange(node) { - if (this._handlers.onCharacterClassRangeEnter) { - this._handlers.onCharacterClassRangeEnter(node); - } - this.visitCharacter(node.min); - this.visitCharacter(node.max); - if (this._handlers.onCharacterClassRangeLeave) { - this._handlers.onCharacterClassRangeLeave(node); - } - } - visitCharacterSet(node) { - if (this._handlers.onCharacterSetEnter) { - this._handlers.onCharacterSetEnter(node); - } - if (this._handlers.onCharacterSetLeave) { - this._handlers.onCharacterSetLeave(node); - } - } - visitClassIntersection(node) { - if (this._handlers.onClassIntersectionEnter) { - this._handlers.onClassIntersectionEnter(node); - } - this.visit(node.left); - this.visit(node.right); - if (this._handlers.onClassIntersectionLeave) { - this._handlers.onClassIntersectionLeave(node); - } - } - visitClassStringDisjunction(node) { - if (this._handlers.onClassStringDisjunctionEnter) { - this._handlers.onClassStringDisjunctionEnter(node); - } - node.alternatives.forEach(this.visit, this); - if (this._handlers.onClassStringDisjunctionLeave) { - this._handlers.onClassStringDisjunctionLeave(node); - } - } - visitClassSubtraction(node) { - if (this._handlers.onClassSubtractionEnter) { - this._handlers.onClassSubtractionEnter(node); - } - this.visit(node.left); - this.visit(node.right); - if (this._handlers.onClassSubtractionLeave) { - this._handlers.onClassSubtractionLeave(node); - } - } - visitExpressionCharacterClass(node) { - if (this._handlers.onExpressionCharacterClassEnter) { - this._handlers.onExpressionCharacterClassEnter(node); - } - this.visit(node.expression); - if (this._handlers.onExpressionCharacterClassLeave) { - this._handlers.onExpressionCharacterClassLeave(node); - } - } - visitFlags(node) { - if (this._handlers.onFlagsEnter) { - this._handlers.onFlagsEnter(node); - } - if (this._handlers.onFlagsLeave) { - this._handlers.onFlagsLeave(node); - } - } - visitGroup(node) { - if (this._handlers.onGroupEnter) { - this._handlers.onGroupEnter(node); - } - node.alternatives.forEach(this.visit, this); - if (this._handlers.onGroupLeave) { - this._handlers.onGroupLeave(node); - } - } - visitPattern(node) { - if (this._handlers.onPatternEnter) { - this._handlers.onPatternEnter(node); - } - node.alternatives.forEach(this.visit, this); - if (this._handlers.onPatternLeave) { - this._handlers.onPatternLeave(node); - } - } - visitQuantifier(node) { - if (this._handlers.onQuantifierEnter) { - this._handlers.onQuantifierEnter(node); - } - this.visit(node.element); - if (this._handlers.onQuantifierLeave) { - this._handlers.onQuantifierLeave(node); - } - } - visitRegExpLiteral(node) { - if (this._handlers.onRegExpLiteralEnter) { - this._handlers.onRegExpLiteralEnter(node); - } - this.visitPattern(node.pattern); - this.visitFlags(node.flags); - if (this._handlers.onRegExpLiteralLeave) { - this._handlers.onRegExpLiteralLeave(node); - } - } - visitStringAlternative(node) { - if (this._handlers.onStringAlternativeEnter) { - this._handlers.onStringAlternativeEnter(node); - } - node.elements.forEach(this.visit, this); - if (this._handlers.onStringAlternativeLeave) { - this._handlers.onStringAlternativeLeave(node); - } - } -} - -function parseRegExpLiteral(source, options) { - return new RegExpParser(options).parseLiteral(String(source)); -} -function validateRegExpLiteral(source, options) { - new RegExpValidator(options).validateLiteral(source); -} -function visitRegExpAST(node, handlers) { - new RegExpVisitor(handlers).visit(node); -} - -export { ast as AST, RegExpParser, RegExpSyntaxError, RegExpValidator, parseRegExpLiteral, validateRegExpLiteral, visitRegExpAST }; -//# sourceMappingURL=index.mjs.map diff --git a/tools/eslint/node_modules/@eslint-community/regexpp/package.json b/tools/eslint/node_modules/@eslint-community/regexpp/package.json deleted file mode 100644 index 6c64680641fa4a..00000000000000 --- a/tools/eslint/node_modules/@eslint-community/regexpp/package.json +++ /dev/null @@ -1,91 +0,0 @@ -{ - "name": "@eslint-community/regexpp", - "version": "4.11.0", - "description": "Regular expression parser for ECMAScript.", - "keywords": [ - "regexp", - "regular", - "expression", - "parser", - "validator", - "ast", - "abstract", - "syntax", - "tree", - "ecmascript", - "es2015", - "es2016", - "es2017", - "es2018", - "es2019", - "es2020", - "es2021", - "annexB" - ], - "homepage": "https://github.com/eslint-community/regexpp#readme", - "bugs": { - "url": "https://github.com/eslint-community/regexpp/issues" - }, - "repository": { - "type": "git", - "url": "https://github.com/eslint-community/regexpp" - }, - "license": "MIT", - "author": "Toru Nagashima", - "exports": { - ".": { - "types": "./index.d.ts", - "import": "./index.mjs", - "default": "./index.js" - }, - "./package.json": "./package.json" - }, - "main": "index", - "files": [ - "index.*" - ], - "scripts": { - "prebuild": "npm run -s clean", - "build": "run-s build:*", - "build:tsc": "tsc --module es2015", - "build:rollup": "rollup -c", - "build:dts": "npm run -s build:tsc -- --removeComments false && dts-bundle --name @eslint-community/regexpp --main .temp/index.d.ts --out ../index.d.ts && prettier --write index.d.ts", - "clean": "rimraf .temp index.*", - "lint": "eslint . --ext .ts", - "test": "nyc _mocha \"test/*.ts\" --reporter dot --timeout 10000", - "debug": "mocha --require ts-node/register/transpile-only \"test/*.ts\" --reporter dot --timeout 10000", - "update:test": "ts-node scripts/update-fixtures.ts", - "update:unicode": "run-s update:unicode:*", - "update:unicode:ids": "ts-node scripts/update-unicode-ids.ts", - "update:unicode:props": "ts-node scripts/update-unicode-properties.ts", - "update:test262:extract": "ts-node -T scripts/extract-test262.ts", - "preversion": "npm test && npm run -s build", - "postversion": "git push && git push --tags", - "prewatch": "npm run -s clean", - "watch": "_mocha \"test/*.ts\" --require ts-node/register --reporter dot --timeout 10000 --watch-extensions ts --watch --growl" - }, - "dependencies": {}, - "devDependencies": { - "@eslint-community/eslint-plugin-mysticatea": "^15.5.1", - "@rollup/plugin-node-resolve": "^14.1.0", - "@types/eslint": "^8.44.3", - "@types/jsdom": "^16.2.15", - "@types/mocha": "^9.1.1", - "@types/node": "^12.20.55", - "dts-bundle": "^0.7.3", - "eslint": "^8.50.0", - "js-tokens": "^8.0.2", - "jsdom": "^19.0.0", - "mocha": "^9.2.2", - "npm-run-all": "^4.1.5", - "nyc": "^14.1.1", - "rimraf": "^3.0.2", - "rollup": "^2.79.1", - "rollup-plugin-sourcemaps": "^0.6.3", - "ts-node": "^10.9.1", - "typescript": "~5.0.2" - }, - "engines": { - "node": "^12.0.0 || ^14.0.0 || >=16.0.0" - } -} diff --git a/tools/eslint/node_modules/@eslint/config-array/LICENSE b/tools/eslint/node_modules/@eslint/config-array/LICENSE deleted file mode 100644 index 261eeb9e9f8b2b..00000000000000 --- a/tools/eslint/node_modules/@eslint/config-array/LICENSE +++ /dev/null @@ -1,201 +0,0 @@ - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright [yyyy] [name of copyright owner] - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. diff --git a/tools/eslint/node_modules/@eslint/config-array/dist/cjs/index.cjs b/tools/eslint/node_modules/@eslint/config-array/dist/cjs/index.cjs deleted file mode 100644 index 0a4b034e6f60bb..00000000000000 --- a/tools/eslint/node_modules/@eslint/config-array/dist/cjs/index.cjs +++ /dev/null @@ -1,1217 +0,0 @@ -'use strict'; - -var path = require('node:path'); -var minimatch = require('minimatch'); -var createDebug = require('debug'); -var objectSchema = require('@eslint/object-schema'); - -/** - * @fileoverview ConfigSchema - * @author Nicholas C. Zakas - */ - -//------------------------------------------------------------------------------ -// Types -//------------------------------------------------------------------------------ - -/** @typedef {import("@eslint/object-schema").PropertyDefinition} PropertyDefinition */ -/** @typedef {import("@eslint/object-schema").ObjectDefinition} ObjectDefinition */ - -//------------------------------------------------------------------------------ -// Helpers -//------------------------------------------------------------------------------ - -/** - * A strategy that does nothing. - * @type {PropertyDefinition} - */ -const NOOP_STRATEGY = { - required: false, - merge() { - return undefined; - }, - validate() {}, -}; - -//------------------------------------------------------------------------------ -// Exports -//------------------------------------------------------------------------------ - -/** - * The base schema that every ConfigArray uses. - * @type {ObjectDefinition} - */ -const baseSchema = Object.freeze({ - name: { - required: false, - merge() { - return undefined; - }, - validate(value) { - if (typeof value !== "string") { - throw new TypeError("Property must be a string."); - } - }, - }, - files: NOOP_STRATEGY, - ignores: NOOP_STRATEGY, -}); - -/** - * @fileoverview ConfigSchema - * @author Nicholas C. Zakas - */ - -//------------------------------------------------------------------------------ -// Types -//------------------------------------------------------------------------------ - - -//------------------------------------------------------------------------------ -// Helpers -//------------------------------------------------------------------------------ - -/** - * Asserts that a given value is an array. - * @param {*} value The value to check. - * @returns {void} - * @throws {TypeError} When the value is not an array. - */ -function assertIsArray(value) { - if (!Array.isArray(value)) { - throw new TypeError("Expected value to be an array."); - } -} - -/** - * Asserts that a given value is an array containing only strings and functions. - * @param {*} value The value to check. - * @returns {void} - * @throws {TypeError} When the value is not an array of strings and functions. - */ -function assertIsArrayOfStringsAndFunctions(value) { - assertIsArray(value); - - if ( - value.some( - item => typeof item !== "string" && typeof item !== "function", - ) - ) { - throw new TypeError( - "Expected array to only contain strings and functions.", - ); - } -} - -/** - * Asserts that a given value is a non-empty array. - * @param {*} value The value to check. - * @returns {void} - * @throws {TypeError} When the value is not an array or an empty array. - */ -function assertIsNonEmptyArray(value) { - if (!Array.isArray(value) || value.length === 0) { - throw new TypeError("Expected value to be a non-empty array."); - } -} - -//------------------------------------------------------------------------------ -// Exports -//------------------------------------------------------------------------------ - -/** - * The schema for `files` and `ignores` that every ConfigArray uses. - * @type {ObjectDefinition} - */ -const filesAndIgnoresSchema = Object.freeze({ - files: { - required: false, - merge() { - return undefined; - }, - validate(value) { - // first check if it's an array - assertIsNonEmptyArray(value); - - // then check each member - value.forEach(item => { - if (Array.isArray(item)) { - assertIsArrayOfStringsAndFunctions(item); - } else if ( - typeof item !== "string" && - typeof item !== "function" - ) { - throw new TypeError( - "Items must be a string, a function, or an array of strings and functions.", - ); - } - }); - }, - }, - ignores: { - required: false, - merge() { - return undefined; - }, - validate: assertIsArrayOfStringsAndFunctions, - }, -}); - -/** - * @fileoverview ConfigArray - * @author Nicholas C. Zakas - */ - - -//------------------------------------------------------------------------------ -// Types -//------------------------------------------------------------------------------ - -/** @typedef {import("./types.ts").ConfigObject} ConfigObject */ -/** @typedef {import("minimatch").IMinimatchStatic} IMinimatchStatic */ -/** @typedef {import("minimatch").IMinimatch} IMinimatch */ - -/* - * This is a bit of a hack to make TypeScript happy with the Rollup-created - * CommonJS file. Rollup doesn't do object destructuring for imported files - * and instead imports the default via `require()`. This messes up type checking - * for `ObjectSchema`. To work around that, we just import the type manually - * and give it a different name to use in the JSDoc comments. - */ -/** @typedef {import("@eslint/object-schema").ObjectSchema} ObjectSchemaInstance */ - -//------------------------------------------------------------------------------ -// Helpers -//------------------------------------------------------------------------------ - -const Minimatch = minimatch.Minimatch; -const debug = createDebug("@eslint/config-array"); - -/** - * A cache for minimatch instances. - * @type {Map} - */ -const minimatchCache = new Map(); - -/** - * A cache for negated minimatch instances. - * @type {Map} - */ -const negatedMinimatchCache = new Map(); - -/** - * Options to use with minimatch. - * @type {Object} - */ -const MINIMATCH_OPTIONS = { - // matchBase: true, - dot: true, - allowWindowsEscape: true, -}; - -/** - * The types of config objects that are supported. - * @type {Set} - */ -const CONFIG_TYPES = new Set(["array", "function"]); - -/** - * Fields that are considered metadata and not part of the config object. - * @type {Set} - */ -const META_FIELDS = new Set(["name"]); - -/** - * A schema containing just files and ignores for early validation. - * @type {ObjectSchemaInstance} - */ -const FILES_AND_IGNORES_SCHEMA = new objectSchema.ObjectSchema(filesAndIgnoresSchema); - -// Precomputed constant objects returned by `ConfigArray.getConfigWithStatus`. - -const CONFIG_WITH_STATUS_EXTERNAL = Object.freeze({ status: "external" }); -const CONFIG_WITH_STATUS_IGNORED = Object.freeze({ status: "ignored" }); -const CONFIG_WITH_STATUS_UNCONFIGURED = Object.freeze({ - status: "unconfigured", -}); - -/** - * Wrapper error for config validation errors that adds a name to the front of the - * error message. - */ -class ConfigError extends Error { - /** - * Creates a new instance. - * @param {string} name The config object name causing the error. - * @param {number} index The index of the config object in the array. - * @param {Object} options The options for the error. - * @param {Error} [options.cause] The error that caused this error. - * @param {string} [options.message] The message to use for the error. - */ - constructor(name, index, { cause, message }) { - const finalMessage = message || cause.message; - - super(`Config ${name}: ${finalMessage}`, { cause }); - - // copy over custom properties that aren't represented - if (cause) { - for (const key of Object.keys(cause)) { - if (!(key in this)) { - this[key] = cause[key]; - } - } - } - - /** - * The name of the error. - * @type {string} - * @readonly - */ - this.name = "ConfigError"; - - /** - * The index of the config object in the array. - * @type {number} - * @readonly - */ - this.index = index; - } -} - -/** - * Gets the name of a config object. - * @param {ConfigObject} config The config object to get the name of. - * @returns {string} The name of the config object. - */ -function getConfigName(config) { - if (config && typeof config.name === "string" && config.name) { - return `"${config.name}"`; - } - - return "(unnamed)"; -} - -/** - * Rethrows a config error with additional information about the config object. - * @param {object} config The config object to get the name of. - * @param {number} index The index of the config object in the array. - * @param {Error} error The error to rethrow. - * @throws {ConfigError} When the error is rethrown for a config. - */ -function rethrowConfigError(config, index, error) { - const configName = getConfigName(config); - throw new ConfigError(configName, index, { cause: error }); -} - -/** - * Shorthand for checking if a value is a string. - * @param {any} value The value to check. - * @returns {boolean} True if a string, false if not. - */ -function isString(value) { - return typeof value === "string"; -} - -/** - * Creates a function that asserts that the config is valid - * during normalization. This checks that the config is not nullish - * and that files and ignores keys of a config object are valid as per base schema. - * @param {Object} config The config object to check. - * @param {number} index The index of the config object in the array. - * @returns {void} - * @throws {ConfigError} If the files and ignores keys of a config object are not valid. - */ -function assertValidBaseConfig(config, index) { - if (config === null) { - throw new ConfigError(getConfigName(config), index, { - message: "Unexpected null config.", - }); - } - - if (config === undefined) { - throw new ConfigError(getConfigName(config), index, { - message: "Unexpected undefined config.", - }); - } - - if (typeof config !== "object") { - throw new ConfigError(getConfigName(config), index, { - message: "Unexpected non-object config.", - }); - } - - const validateConfig = {}; - - if ("files" in config) { - validateConfig.files = config.files; - } - - if ("ignores" in config) { - validateConfig.ignores = config.ignores; - } - - try { - FILES_AND_IGNORES_SCHEMA.validate(validateConfig); - } catch (validationError) { - rethrowConfigError(config, index, validationError); - } -} - -/** - * Wrapper around minimatch that caches minimatch patterns for - * faster matching speed over multiple file path evaluations. - * @param {string} filepath The file path to match. - * @param {string} pattern The glob pattern to match against. - * @param {object} options The minimatch options to use. - * @returns - */ -function doMatch(filepath, pattern, options = {}) { - let cache = minimatchCache; - - if (options.flipNegate) { - cache = negatedMinimatchCache; - } - - let matcher = cache.get(pattern); - - if (!matcher) { - matcher = new Minimatch( - pattern, - Object.assign({}, MINIMATCH_OPTIONS, options), - ); - cache.set(pattern, matcher); - } - - return matcher.match(filepath); -} - -/** - * Normalizes a `ConfigArray` by flattening it and executing any functions - * that are found inside. - * @param {Array} items The items in a `ConfigArray`. - * @param {Object} context The context object to pass into any function - * found. - * @param {Array} extraConfigTypes The config types to check. - * @returns {Promise} A flattened array containing only config objects. - * @throws {TypeError} When a config function returns a function. - */ -async function normalize(items, context, extraConfigTypes) { - const allowFunctions = extraConfigTypes.includes("function"); - const allowArrays = extraConfigTypes.includes("array"); - - async function* flatTraverse(array) { - for (let item of array) { - if (typeof item === "function") { - if (!allowFunctions) { - throw new TypeError("Unexpected function."); - } - - item = item(context); - if (item.then) { - item = await item; - } - } - - if (Array.isArray(item)) { - if (!allowArrays) { - throw new TypeError("Unexpected array."); - } - yield* flatTraverse(item); - } else if (typeof item === "function") { - throw new TypeError( - "A config function can only return an object or array.", - ); - } else { - yield item; - } - } - } - - /* - * Async iterables cannot be used with the spread operator, so we need to manually - * create the array to return. - */ - const asyncIterable = await flatTraverse(items); - const configs = []; - - for await (const config of asyncIterable) { - configs.push(config); - } - - return configs; -} - -/** - * Normalizes a `ConfigArray` by flattening it and executing any functions - * that are found inside. - * @param {Array} items The items in a `ConfigArray`. - * @param {Object} context The context object to pass into any function - * found. - * @param {Array} extraConfigTypes The config types to check. - * @returns {Array} A flattened array containing only config objects. - * @throws {TypeError} When a config function returns a function. - */ -function normalizeSync(items, context, extraConfigTypes) { - const allowFunctions = extraConfigTypes.includes("function"); - const allowArrays = extraConfigTypes.includes("array"); - - function* flatTraverse(array) { - for (let item of array) { - if (typeof item === "function") { - if (!allowFunctions) { - throw new TypeError("Unexpected function."); - } - - item = item(context); - if (item.then) { - throw new TypeError( - "Async config functions are not supported.", - ); - } - } - - if (Array.isArray(item)) { - if (!allowArrays) { - throw new TypeError("Unexpected array."); - } - - yield* flatTraverse(item); - } else if (typeof item === "function") { - throw new TypeError( - "A config function can only return an object or array.", - ); - } else { - yield item; - } - } - } - - return [...flatTraverse(items)]; -} - -/** - * Determines if a given file path should be ignored based on the given - * matcher. - * @param {Array boolean)>} ignores The ignore patterns to check. - * @param {string} filePath The absolute path of the file to check. - * @param {string} relativeFilePath The relative path of the file to check. - * @returns {boolean} True if the path should be ignored and false if not. - */ -function shouldIgnorePath(ignores, filePath, relativeFilePath) { - // all files outside of the basePath are ignored - if (relativeFilePath.startsWith("..")) { - return true; - } - - return ignores.reduce((ignored, matcher) => { - if (!ignored) { - if (typeof matcher === "function") { - return matcher(filePath); - } - - // don't check negated patterns because we're not ignored yet - if (!matcher.startsWith("!")) { - return doMatch(relativeFilePath, matcher); - } - - // otherwise we're still not ignored - return false; - } - - // only need to check negated patterns because we're ignored - if (typeof matcher === "string" && matcher.startsWith("!")) { - return !doMatch(relativeFilePath, matcher, { - flipNegate: true, - }); - } - - return ignored; - }, false); -} - -/** - * Determines if a given file path is matched by a config based on - * `ignores` only. - * @param {string} filePath The absolute file path to check. - * @param {string} basePath The base path for the config. - * @param {Object} config The config object to check. - * @returns {boolean} True if the file path is matched by the config, - * false if not. - */ -function pathMatchesIgnores(filePath, basePath, config) { - /* - * For both files and ignores, functions are passed the absolute - * file path while strings are compared against the relative - * file path. - */ - const relativeFilePath = path.relative(basePath, filePath); - - return ( - Object.keys(config).filter(key => !META_FIELDS.has(key)).length > 1 && - !shouldIgnorePath(config.ignores, filePath, relativeFilePath) - ); -} - -/** - * Determines if a given file path is matched by a config. If the config - * has no `files` field, then it matches; otherwise, if a `files` field - * is present then we match the globs in `files` and exclude any globs in - * `ignores`. - * @param {string} filePath The absolute file path to check. - * @param {string} basePath The base path for the config. - * @param {Object} config The config object to check. - * @returns {boolean} True if the file path is matched by the config, - * false if not. - */ -function pathMatches(filePath, basePath, config) { - /* - * For both files and ignores, functions are passed the absolute - * file path while strings are compared against the relative - * file path. - */ - const relativeFilePath = path.relative(basePath, filePath); - - // match both strings and functions - function match(pattern) { - if (isString(pattern)) { - return doMatch(relativeFilePath, pattern); - } - - if (typeof pattern === "function") { - return pattern(filePath); - } - - throw new TypeError(`Unexpected matcher type ${pattern}.`); - } - - // check for all matches to config.files - let filePathMatchesPattern = config.files.some(pattern => { - if (Array.isArray(pattern)) { - return pattern.every(match); - } - - return match(pattern); - }); - - /* - * If the file path matches the config.files patterns, then check to see - * if there are any files to ignore. - */ - if (filePathMatchesPattern && config.ignores) { - filePathMatchesPattern = !shouldIgnorePath( - config.ignores, - filePath, - relativeFilePath, - ); - } - - return filePathMatchesPattern; -} - -/** - * Ensures that a ConfigArray has been normalized. - * @param {ConfigArray} configArray The ConfigArray to check. - * @returns {void} - * @throws {Error} When the `ConfigArray` is not normalized. - */ -function assertNormalized(configArray) { - // TODO: Throw more verbose error - if (!configArray.isNormalized()) { - throw new Error( - "ConfigArray must be normalized to perform this operation.", - ); - } -} - -/** - * Ensures that config types are valid. - * @param {Array} extraConfigTypes The config types to check. - * @returns {void} - * @throws {Error} When the config types array is invalid. - */ -function assertExtraConfigTypes(extraConfigTypes) { - if (extraConfigTypes.length > 2) { - throw new TypeError( - "configTypes must be an array with at most two items.", - ); - } - - for (const configType of extraConfigTypes) { - if (!CONFIG_TYPES.has(configType)) { - throw new TypeError( - `Unexpected config type "${configType}" found. Expected one of: "object", "array", "function".`, - ); - } - } -} - -//------------------------------------------------------------------------------ -// Public Interface -//------------------------------------------------------------------------------ - -const ConfigArraySymbol = { - isNormalized: Symbol("isNormalized"), - configCache: Symbol("configCache"), - schema: Symbol("schema"), - finalizeConfig: Symbol("finalizeConfig"), - preprocessConfig: Symbol("preprocessConfig"), -}; - -// used to store calculate data for faster lookup -const dataCache = new WeakMap(); - -/** - * Represents an array of config objects and provides method for working with - * those config objects. - */ -class ConfigArray extends Array { - /** - * Creates a new instance of ConfigArray. - * @param {Iterable|Function|Object} configs An iterable yielding config - * objects, or a config function, or a config object. - * @param {Object} options The options for the ConfigArray. - * @param {string} [options.basePath=""] The path of the config file - * @param {boolean} [options.normalized=false] Flag indicating if the - * configs have already been normalized. - * @param {Object} [options.schema] The additional schema - * definitions to use for the ConfigArray schema. - * @param {Array} [options.extraConfigTypes] List of config types supported. - */ - constructor( - configs, - { - basePath = "", - normalized = false, - schema: customSchema, - extraConfigTypes = [], - } = {}, - ) { - super(); - - /** - * Tracks if the array has been normalized. - * @property isNormalized - * @type {boolean} - * @private - */ - this[ConfigArraySymbol.isNormalized] = normalized; - - /** - * The schema used for validating and merging configs. - * @property schema - * @type {ObjectSchemaInstance} - * @private - */ - this[ConfigArraySymbol.schema] = new objectSchema.ObjectSchema( - Object.assign({}, customSchema, baseSchema), - ); - - /** - * The path of the config file that this array was loaded from. - * This is used to calculate filename matches. - * @property basePath - * @type {string} - */ - this.basePath = basePath; - - assertExtraConfigTypes(extraConfigTypes); - - /** - * The supported config types. - * @type {Array} - */ - this.extraConfigTypes = [...extraConfigTypes]; - Object.freeze(this.extraConfigTypes); - - /** - * A cache to store calculated configs for faster repeat lookup. - * @property configCache - * @type {Map} - * @private - */ - this[ConfigArraySymbol.configCache] = new Map(); - - // init cache - dataCache.set(this, { - explicitMatches: new Map(), - directoryMatches: new Map(), - files: undefined, - ignores: undefined, - }); - - // load the configs into this array - if (Array.isArray(configs)) { - this.push(...configs); - } else { - this.push(configs); - } - } - - /** - * Prevent normal array methods from creating a new `ConfigArray` instance. - * This is to ensure that methods such as `slice()` won't try to create a - * new instance of `ConfigArray` behind the scenes as doing so may throw - * an error due to the different constructor signature. - * @type {ArrayConstructor} The `Array` constructor. - */ - static get [Symbol.species]() { - return Array; - } - - /** - * Returns the `files` globs from every config object in the array. - * This can be used to determine which files will be matched by a - * config array or to use as a glob pattern when no patterns are provided - * for a command line interface. - * @returns {Array} An array of matchers. - */ - get files() { - assertNormalized(this); - - // if this data has been cached, retrieve it - const cache = dataCache.get(this); - - if (cache.files) { - return cache.files; - } - - // otherwise calculate it - - const result = []; - - for (const config of this) { - if (config.files) { - config.files.forEach(filePattern => { - result.push(filePattern); - }); - } - } - - // store result - cache.files = result; - dataCache.set(this, cache); - - return result; - } - - /** - * Returns ignore matchers that should always be ignored regardless of - * the matching `files` fields in any configs. This is necessary to mimic - * the behavior of things like .gitignore and .eslintignore, allowing a - * globbing operation to be faster. - * @returns {string[]} An array of string patterns and functions to be ignored. - */ - get ignores() { - assertNormalized(this); - - // if this data has been cached, retrieve it - const cache = dataCache.get(this); - - if (cache.ignores) { - return cache.ignores; - } - - // otherwise calculate it - - const result = []; - - for (const config of this) { - /* - * We only count ignores if there are no other keys in the object. - * In this case, it acts list a globally ignored pattern. If there - * are additional keys, then ignores act like exclusions. - */ - if ( - config.ignores && - Object.keys(config).filter(key => !META_FIELDS.has(key)) - .length === 1 - ) { - result.push(...config.ignores); - } - } - - // store result - cache.ignores = result; - dataCache.set(this, cache); - - return result; - } - - /** - * Indicates if the config array has been normalized. - * @returns {boolean} True if the config array is normalized, false if not. - */ - isNormalized() { - return this[ConfigArraySymbol.isNormalized]; - } - - /** - * Normalizes a config array by flattening embedded arrays and executing - * config functions. - * @param {Object} [context] The context object for config functions. - * @returns {Promise} The current ConfigArray instance. - */ - async normalize(context = {}) { - if (!this.isNormalized()) { - const normalizedConfigs = await normalize( - this, - context, - this.extraConfigTypes, - ); - this.length = 0; - this.push( - ...normalizedConfigs.map( - this[ConfigArraySymbol.preprocessConfig].bind(this), - ), - ); - this.forEach(assertValidBaseConfig); - this[ConfigArraySymbol.isNormalized] = true; - - // prevent further changes - Object.freeze(this); - } - - return this; - } - - /** - * Normalizes a config array by flattening embedded arrays and executing - * config functions. - * @param {Object} [context] The context object for config functions. - * @returns {ConfigArray} The current ConfigArray instance. - */ - normalizeSync(context = {}) { - if (!this.isNormalized()) { - const normalizedConfigs = normalizeSync( - this, - context, - this.extraConfigTypes, - ); - this.length = 0; - this.push( - ...normalizedConfigs.map( - this[ConfigArraySymbol.preprocessConfig].bind(this), - ), - ); - this.forEach(assertValidBaseConfig); - this[ConfigArraySymbol.isNormalized] = true; - - // prevent further changes - Object.freeze(this); - } - - return this; - } - - /* eslint-disable class-methods-use-this -- Desired as instance methods */ - - /** - * Finalizes the state of a config before being cached and returned by - * `getConfig()`. Does nothing by default but is provided to be - * overridden by subclasses as necessary. - * @param {Object} config The config to finalize. - * @returns {Object} The finalized config. - */ - [ConfigArraySymbol.finalizeConfig](config) { - return config; - } - - /** - * Preprocesses a config during the normalization process. This is the - * method to override if you want to convert an array item before it is - * validated for the first time. For example, if you want to replace a - * string with an object, this is the method to override. - * @param {Object} config The config to preprocess. - * @returns {Object} The config to use in place of the argument. - */ - [ConfigArraySymbol.preprocessConfig](config) { - return config; - } - - /* eslint-enable class-methods-use-this -- Desired as instance methods */ - - /** - * Returns the config object for a given file path and a status that can be used to determine why a file has no config. - * @param {string} filePath The complete path of a file to get a config for. - * @returns {{ config?: Object, status: "ignored"|"external"|"unconfigured"|"matched" }} - * An object with an optional property `config` and property `status`. - * `config` is the config object for the specified file as returned by {@linkcode ConfigArray.getConfig}, - * `status` a is one of the constants returned by {@linkcode ConfigArray.getConfigStatus}. - */ - getConfigWithStatus(filePath) { - assertNormalized(this); - - const cache = this[ConfigArraySymbol.configCache]; - - // first check the cache for a filename match to avoid duplicate work - if (cache.has(filePath)) { - return cache.get(filePath); - } - - // check to see if the file is outside the base path - - const relativeFilePath = path.relative(this.basePath, filePath); - - if (relativeFilePath.startsWith("..")) { - debug(`No config for file ${filePath} outside of base path`); - - // cache and return result - cache.set(filePath, CONFIG_WITH_STATUS_EXTERNAL); - return CONFIG_WITH_STATUS_EXTERNAL; - } - - // next check to see if the file should be ignored - - // check if this should be ignored due to its directory - if (this.isDirectoryIgnored(path.dirname(filePath))) { - debug(`Ignoring ${filePath} based on directory pattern`); - - // cache and return result - cache.set(filePath, CONFIG_WITH_STATUS_IGNORED); - return CONFIG_WITH_STATUS_IGNORED; - } - - if (shouldIgnorePath(this.ignores, filePath, relativeFilePath)) { - debug(`Ignoring ${filePath} based on file pattern`); - - // cache and return result - cache.set(filePath, CONFIG_WITH_STATUS_IGNORED); - return CONFIG_WITH_STATUS_IGNORED; - } - - // filePath isn't automatically ignored, so try to construct config - - const matchingConfigIndices = []; - let matchFound = false; - const universalPattern = /^\*$|\/\*{1,2}$/u; - - this.forEach((config, index) => { - if (!config.files) { - if (!config.ignores) { - debug(`Anonymous universal config found for ${filePath}`); - matchingConfigIndices.push(index); - return; - } - - if (pathMatchesIgnores(filePath, this.basePath, config)) { - debug( - `Matching config found for ${filePath} (based on ignores: ${config.ignores})`, - ); - matchingConfigIndices.push(index); - return; - } - - debug( - `Skipped config found for ${filePath} (based on ignores: ${config.ignores})`, - ); - return; - } - - /* - * If a config has a files pattern * or patterns ending in /** or /*, - * and the filePath only matches those patterns, then the config is only - * applied if there is another config where the filePath matches - * a file with a specific extensions such as *.js. - */ - - const universalFiles = config.files.filter(pattern => - universalPattern.test(pattern), - ); - - // universal patterns were found so we need to check the config twice - if (universalFiles.length) { - debug("Universal files patterns found. Checking carefully."); - - const nonUniversalFiles = config.files.filter( - pattern => !universalPattern.test(pattern), - ); - - // check that the config matches without the non-universal files first - if ( - nonUniversalFiles.length && - pathMatches(filePath, this.basePath, { - files: nonUniversalFiles, - ignores: config.ignores, - }) - ) { - debug(`Matching config found for ${filePath}`); - matchingConfigIndices.push(index); - matchFound = true; - return; - } - - // if there wasn't a match then check if it matches with universal files - if ( - universalFiles.length && - pathMatches(filePath, this.basePath, { - files: universalFiles, - ignores: config.ignores, - }) - ) { - debug(`Matching config found for ${filePath}`); - matchingConfigIndices.push(index); - return; - } - - // if we make here, then there was no match - return; - } - - // the normal case - if (pathMatches(filePath, this.basePath, config)) { - debug(`Matching config found for ${filePath}`); - matchingConfigIndices.push(index); - matchFound = true; - } - }); - - // if matching both files and ignores, there will be no config to create - if (!matchFound) { - debug(`No matching configs found for ${filePath}`); - - // cache and return result - cache.set(filePath, CONFIG_WITH_STATUS_UNCONFIGURED); - return CONFIG_WITH_STATUS_UNCONFIGURED; - } - - // check to see if there is a config cached by indices - const indicesKey = matchingConfigIndices.toString(); - let configWithStatus = cache.get(indicesKey); - - if (configWithStatus) { - // also store for filename for faster lookup next time - cache.set(filePath, configWithStatus); - - return configWithStatus; - } - - // otherwise construct the config - - // eslint-disable-next-line array-callback-return, consistent-return -- rethrowConfigError always throws an error - let finalConfig = matchingConfigIndices.reduce((result, index) => { - try { - return this[ConfigArraySymbol.schema].merge( - result, - this[index], - ); - } catch (validationError) { - rethrowConfigError(this[index], index, validationError); - } - }, {}); - - finalConfig = this[ConfigArraySymbol.finalizeConfig](finalConfig); - - configWithStatus = Object.freeze({ - config: finalConfig, - status: "matched", - }); - cache.set(filePath, configWithStatus); - cache.set(indicesKey, configWithStatus); - - return configWithStatus; - } - - /** - * Returns the config object for a given file path. - * @param {string} filePath The complete path of a file to get a config for. - * @returns {Object|undefined} The config object for this file or `undefined`. - */ - getConfig(filePath) { - return this.getConfigWithStatus(filePath).config; - } - - /** - * Determines whether a file has a config or why it doesn't. - * @param {string} filePath The complete path of the file to check. - * @returns {"ignored"|"external"|"unconfigured"|"matched"} One of the following values: - * * `"ignored"`: the file is ignored - * * `"external"`: the file is outside the base path - * * `"unconfigured"`: the file is not matched by any config - * * `"matched"`: the file has a matching config - */ - getConfigStatus(filePath) { - return this.getConfigWithStatus(filePath).status; - } - - /** - * Determines if the given filepath is ignored based on the configs. - * @param {string} filePath The complete path of a file to check. - * @returns {boolean} True if the path is ignored, false if not. - * @deprecated Use `isFileIgnored` instead. - */ - isIgnored(filePath) { - return this.isFileIgnored(filePath); - } - - /** - * Determines if the given filepath is ignored based on the configs. - * @param {string} filePath The complete path of a file to check. - * @returns {boolean} True if the path is ignored, false if not. - */ - isFileIgnored(filePath) { - return this.getConfigStatus(filePath) === "ignored"; - } - - /** - * Determines if the given directory is ignored based on the configs. - * This checks only default `ignores` that don't have `files` in the - * same config. A pattern such as `/foo` be considered to ignore the directory - * while a pattern such as `/foo/**` is not considered to ignore the - * directory because it is matching files. - * @param {string} directoryPath The complete path of a directory to check. - * @returns {boolean} True if the directory is ignored, false if not. Will - * return true for any directory that is not inside of `basePath`. - * @throws {Error} When the `ConfigArray` is not normalized. - */ - isDirectoryIgnored(directoryPath) { - assertNormalized(this); - - const relativeDirectoryPath = path - .relative(this.basePath, directoryPath) - .replace(/\\/gu, "/"); - - if (relativeDirectoryPath.startsWith("..")) { - return true; - } - - // first check the cache - const cache = dataCache.get(this).directoryMatches; - - if (cache.has(relativeDirectoryPath)) { - return cache.get(relativeDirectoryPath); - } - - const directoryParts = relativeDirectoryPath.split("/"); - let relativeDirectoryToCheck = ""; - let result; - - /* - * In order to get the correct gitignore-style ignores, where an - * ignored parent directory cannot have any descendants unignored, - * we need to check every directory starting at the parent all - * the way down to the actual requested directory. - * - * We aggressively cache all of this info to make sure we don't - * have to recalculate everything for every call. - */ - do { - relativeDirectoryToCheck += `${directoryParts.shift()}/`; - - result = shouldIgnorePath( - this.ignores, - path.join(this.basePath, relativeDirectoryToCheck), - relativeDirectoryToCheck, - ); - - cache.set(relativeDirectoryToCheck, result); - } while (!result && directoryParts.length); - - // also cache the result for the requested path - cache.set(relativeDirectoryPath, result); - - return result; - } -} - -exports.ConfigArray = ConfigArray; -exports.ConfigArraySymbol = ConfigArraySymbol; diff --git a/tools/eslint/node_modules/@eslint/config-array/dist/cjs/index.d.cts b/tools/eslint/node_modules/@eslint/config-array/dist/cjs/index.d.cts deleted file mode 100644 index 375f46b3de078d..00000000000000 --- a/tools/eslint/node_modules/@eslint/config-array/dist/cjs/index.d.cts +++ /dev/null @@ -1,137 +0,0 @@ -export type PropertyDefinition = import("@eslint/object-schema").PropertyDefinition; -export type ObjectDefinition = import("@eslint/object-schema").ObjectDefinition; -export type ConfigObject = import("./types.ts").ConfigObject; -export type IMinimatchStatic = import("minimatch").IMinimatchStatic; -export type IMinimatch = import("minimatch").IMinimatch; -export type ObjectSchemaInstance = import("@eslint/object-schema").ObjectSchema; -/** - * Represents an array of config objects and provides method for working with - * those config objects. - */ -export class ConfigArray extends Array { - /** - * Creates a new instance of ConfigArray. - * @param {Iterable|Function|Object} configs An iterable yielding config - * objects, or a config function, or a config object. - * @param {Object} options The options for the ConfigArray. - * @param {string} [options.basePath=""] The path of the config file - * @param {boolean} [options.normalized=false] Flag indicating if the - * configs have already been normalized. - * @param {Object} [options.schema] The additional schema - * definitions to use for the ConfigArray schema. - * @param {Array} [options.extraConfigTypes] List of config types supported. - */ - constructor(configs: Iterable | Function | any, { basePath, normalized, schema: customSchema, extraConfigTypes, }?: { - basePath?: string; - normalized?: boolean; - schema?: any; - extraConfigTypes?: Array; - }); - /** - * The path of the config file that this array was loaded from. - * This is used to calculate filename matches. - * @property basePath - * @type {string} - */ - basePath: string; - /** - * The supported config types. - * @type {Array} - */ - extraConfigTypes: Array; - /** - * Returns the `files` globs from every config object in the array. - * This can be used to determine which files will be matched by a - * config array or to use as a glob pattern when no patterns are provided - * for a command line interface. - * @returns {Array} An array of matchers. - */ - get files(): (string | Function)[]; - /** - * Returns ignore matchers that should always be ignored regardless of - * the matching `files` fields in any configs. This is necessary to mimic - * the behavior of things like .gitignore and .eslintignore, allowing a - * globbing operation to be faster. - * @returns {string[]} An array of string patterns and functions to be ignored. - */ - get ignores(): string[]; - /** - * Indicates if the config array has been normalized. - * @returns {boolean} True if the config array is normalized, false if not. - */ - isNormalized(): boolean; - /** - * Normalizes a config array by flattening embedded arrays and executing - * config functions. - * @param {Object} [context] The context object for config functions. - * @returns {Promise} The current ConfigArray instance. - */ - normalize(context?: any): Promise; - /** - * Normalizes a config array by flattening embedded arrays and executing - * config functions. - * @param {Object} [context] The context object for config functions. - * @returns {ConfigArray} The current ConfigArray instance. - */ - normalizeSync(context?: any): ConfigArray; - /** - * Returns the config object for a given file path and a status that can be used to determine why a file has no config. - * @param {string} filePath The complete path of a file to get a config for. - * @returns {{ config?: Object, status: "ignored"|"external"|"unconfigured"|"matched" }} - * An object with an optional property `config` and property `status`. - * `config` is the config object for the specified file as returned by {@linkcode ConfigArray.getConfig}, - * `status` a is one of the constants returned by {@linkcode ConfigArray.getConfigStatus}. - */ - getConfigWithStatus(filePath: string): { - config?: any; - status: "ignored" | "external" | "unconfigured" | "matched"; - }; - /** - * Returns the config object for a given file path. - * @param {string} filePath The complete path of a file to get a config for. - * @returns {Object|undefined} The config object for this file or `undefined`. - */ - getConfig(filePath: string): any | undefined; - /** - * Determines whether a file has a config or why it doesn't. - * @param {string} filePath The complete path of the file to check. - * @returns {"ignored"|"external"|"unconfigured"|"matched"} One of the following values: - * * `"ignored"`: the file is ignored - * * `"external"`: the file is outside the base path - * * `"unconfigured"`: the file is not matched by any config - * * `"matched"`: the file has a matching config - */ - getConfigStatus(filePath: string): "ignored" | "external" | "unconfigured" | "matched"; - /** - * Determines if the given filepath is ignored based on the configs. - * @param {string} filePath The complete path of a file to check. - * @returns {boolean} True if the path is ignored, false if not. - * @deprecated Use `isFileIgnored` instead. - */ - isIgnored(filePath: string): boolean; - /** - * Determines if the given filepath is ignored based on the configs. - * @param {string} filePath The complete path of a file to check. - * @returns {boolean} True if the path is ignored, false if not. - */ - isFileIgnored(filePath: string): boolean; - /** - * Determines if the given directory is ignored based on the configs. - * This checks only default `ignores` that don't have `files` in the - * same config. A pattern such as `/foo` be considered to ignore the directory - * while a pattern such as `/foo/**` is not considered to ignore the - * directory because it is matching files. - * @param {string} directoryPath The complete path of a directory to check. - * @returns {boolean} True if the directory is ignored, false if not. Will - * return true for any directory that is not inside of `basePath`. - * @throws {Error} When the `ConfigArray` is not normalized. - */ - isDirectoryIgnored(directoryPath: string): boolean; -} -export namespace ConfigArraySymbol { - let isNormalized: symbol; - let configCache: symbol; - let schema: symbol; - let finalizeConfig: symbol; - let preprocessConfig: symbol; -} diff --git a/tools/eslint/node_modules/@eslint/config-array/dist/esm/index.js b/tools/eslint/node_modules/@eslint/config-array/dist/esm/index.js deleted file mode 100644 index ce238f280e5c58..00000000000000 --- a/tools/eslint/node_modules/@eslint/config-array/dist/esm/index.js +++ /dev/null @@ -1,1215 +0,0 @@ -// @ts-self-types="./index.d.ts" -import path from 'node:path'; -import minimatch from 'minimatch'; -import createDebug from 'debug'; -import { ObjectSchema } from '@eslint/object-schema'; - -/** - * @fileoverview ConfigSchema - * @author Nicholas C. Zakas - */ - -//------------------------------------------------------------------------------ -// Types -//------------------------------------------------------------------------------ - -/** @typedef {import("@eslint/object-schema").PropertyDefinition} PropertyDefinition */ -/** @typedef {import("@eslint/object-schema").ObjectDefinition} ObjectDefinition */ - -//------------------------------------------------------------------------------ -// Helpers -//------------------------------------------------------------------------------ - -/** - * A strategy that does nothing. - * @type {PropertyDefinition} - */ -const NOOP_STRATEGY = { - required: false, - merge() { - return undefined; - }, - validate() {}, -}; - -//------------------------------------------------------------------------------ -// Exports -//------------------------------------------------------------------------------ - -/** - * The base schema that every ConfigArray uses. - * @type {ObjectDefinition} - */ -const baseSchema = Object.freeze({ - name: { - required: false, - merge() { - return undefined; - }, - validate(value) { - if (typeof value !== "string") { - throw new TypeError("Property must be a string."); - } - }, - }, - files: NOOP_STRATEGY, - ignores: NOOP_STRATEGY, -}); - -/** - * @fileoverview ConfigSchema - * @author Nicholas C. Zakas - */ - -//------------------------------------------------------------------------------ -// Types -//------------------------------------------------------------------------------ - - -//------------------------------------------------------------------------------ -// Helpers -//------------------------------------------------------------------------------ - -/** - * Asserts that a given value is an array. - * @param {*} value The value to check. - * @returns {void} - * @throws {TypeError} When the value is not an array. - */ -function assertIsArray(value) { - if (!Array.isArray(value)) { - throw new TypeError("Expected value to be an array."); - } -} - -/** - * Asserts that a given value is an array containing only strings and functions. - * @param {*} value The value to check. - * @returns {void} - * @throws {TypeError} When the value is not an array of strings and functions. - */ -function assertIsArrayOfStringsAndFunctions(value) { - assertIsArray(value); - - if ( - value.some( - item => typeof item !== "string" && typeof item !== "function", - ) - ) { - throw new TypeError( - "Expected array to only contain strings and functions.", - ); - } -} - -/** - * Asserts that a given value is a non-empty array. - * @param {*} value The value to check. - * @returns {void} - * @throws {TypeError} When the value is not an array or an empty array. - */ -function assertIsNonEmptyArray(value) { - if (!Array.isArray(value) || value.length === 0) { - throw new TypeError("Expected value to be a non-empty array."); - } -} - -//------------------------------------------------------------------------------ -// Exports -//------------------------------------------------------------------------------ - -/** - * The schema for `files` and `ignores` that every ConfigArray uses. - * @type {ObjectDefinition} - */ -const filesAndIgnoresSchema = Object.freeze({ - files: { - required: false, - merge() { - return undefined; - }, - validate(value) { - // first check if it's an array - assertIsNonEmptyArray(value); - - // then check each member - value.forEach(item => { - if (Array.isArray(item)) { - assertIsArrayOfStringsAndFunctions(item); - } else if ( - typeof item !== "string" && - typeof item !== "function" - ) { - throw new TypeError( - "Items must be a string, a function, or an array of strings and functions.", - ); - } - }); - }, - }, - ignores: { - required: false, - merge() { - return undefined; - }, - validate: assertIsArrayOfStringsAndFunctions, - }, -}); - -/** - * @fileoverview ConfigArray - * @author Nicholas C. Zakas - */ - - -//------------------------------------------------------------------------------ -// Types -//------------------------------------------------------------------------------ - -/** @typedef {import("./types.ts").ConfigObject} ConfigObject */ -/** @typedef {import("minimatch").IMinimatchStatic} IMinimatchStatic */ -/** @typedef {import("minimatch").IMinimatch} IMinimatch */ - -/* - * This is a bit of a hack to make TypeScript happy with the Rollup-created - * CommonJS file. Rollup doesn't do object destructuring for imported files - * and instead imports the default via `require()`. This messes up type checking - * for `ObjectSchema`. To work around that, we just import the type manually - * and give it a different name to use in the JSDoc comments. - */ -/** @typedef {import("@eslint/object-schema").ObjectSchema} ObjectSchemaInstance */ - -//------------------------------------------------------------------------------ -// Helpers -//------------------------------------------------------------------------------ - -const Minimatch = minimatch.Minimatch; -const debug = createDebug("@eslint/config-array"); - -/** - * A cache for minimatch instances. - * @type {Map} - */ -const minimatchCache = new Map(); - -/** - * A cache for negated minimatch instances. - * @type {Map} - */ -const negatedMinimatchCache = new Map(); - -/** - * Options to use with minimatch. - * @type {Object} - */ -const MINIMATCH_OPTIONS = { - // matchBase: true, - dot: true, - allowWindowsEscape: true, -}; - -/** - * The types of config objects that are supported. - * @type {Set} - */ -const CONFIG_TYPES = new Set(["array", "function"]); - -/** - * Fields that are considered metadata and not part of the config object. - * @type {Set} - */ -const META_FIELDS = new Set(["name"]); - -/** - * A schema containing just files and ignores for early validation. - * @type {ObjectSchemaInstance} - */ -const FILES_AND_IGNORES_SCHEMA = new ObjectSchema(filesAndIgnoresSchema); - -// Precomputed constant objects returned by `ConfigArray.getConfigWithStatus`. - -const CONFIG_WITH_STATUS_EXTERNAL = Object.freeze({ status: "external" }); -const CONFIG_WITH_STATUS_IGNORED = Object.freeze({ status: "ignored" }); -const CONFIG_WITH_STATUS_UNCONFIGURED = Object.freeze({ - status: "unconfigured", -}); - -/** - * Wrapper error for config validation errors that adds a name to the front of the - * error message. - */ -class ConfigError extends Error { - /** - * Creates a new instance. - * @param {string} name The config object name causing the error. - * @param {number} index The index of the config object in the array. - * @param {Object} options The options for the error. - * @param {Error} [options.cause] The error that caused this error. - * @param {string} [options.message] The message to use for the error. - */ - constructor(name, index, { cause, message }) { - const finalMessage = message || cause.message; - - super(`Config ${name}: ${finalMessage}`, { cause }); - - // copy over custom properties that aren't represented - if (cause) { - for (const key of Object.keys(cause)) { - if (!(key in this)) { - this[key] = cause[key]; - } - } - } - - /** - * The name of the error. - * @type {string} - * @readonly - */ - this.name = "ConfigError"; - - /** - * The index of the config object in the array. - * @type {number} - * @readonly - */ - this.index = index; - } -} - -/** - * Gets the name of a config object. - * @param {ConfigObject} config The config object to get the name of. - * @returns {string} The name of the config object. - */ -function getConfigName(config) { - if (config && typeof config.name === "string" && config.name) { - return `"${config.name}"`; - } - - return "(unnamed)"; -} - -/** - * Rethrows a config error with additional information about the config object. - * @param {object} config The config object to get the name of. - * @param {number} index The index of the config object in the array. - * @param {Error} error The error to rethrow. - * @throws {ConfigError} When the error is rethrown for a config. - */ -function rethrowConfigError(config, index, error) { - const configName = getConfigName(config); - throw new ConfigError(configName, index, { cause: error }); -} - -/** - * Shorthand for checking if a value is a string. - * @param {any} value The value to check. - * @returns {boolean} True if a string, false if not. - */ -function isString(value) { - return typeof value === "string"; -} - -/** - * Creates a function that asserts that the config is valid - * during normalization. This checks that the config is not nullish - * and that files and ignores keys of a config object are valid as per base schema. - * @param {Object} config The config object to check. - * @param {number} index The index of the config object in the array. - * @returns {void} - * @throws {ConfigError} If the files and ignores keys of a config object are not valid. - */ -function assertValidBaseConfig(config, index) { - if (config === null) { - throw new ConfigError(getConfigName(config), index, { - message: "Unexpected null config.", - }); - } - - if (config === undefined) { - throw new ConfigError(getConfigName(config), index, { - message: "Unexpected undefined config.", - }); - } - - if (typeof config !== "object") { - throw new ConfigError(getConfigName(config), index, { - message: "Unexpected non-object config.", - }); - } - - const validateConfig = {}; - - if ("files" in config) { - validateConfig.files = config.files; - } - - if ("ignores" in config) { - validateConfig.ignores = config.ignores; - } - - try { - FILES_AND_IGNORES_SCHEMA.validate(validateConfig); - } catch (validationError) { - rethrowConfigError(config, index, validationError); - } -} - -/** - * Wrapper around minimatch that caches minimatch patterns for - * faster matching speed over multiple file path evaluations. - * @param {string} filepath The file path to match. - * @param {string} pattern The glob pattern to match against. - * @param {object} options The minimatch options to use. - * @returns - */ -function doMatch(filepath, pattern, options = {}) { - let cache = minimatchCache; - - if (options.flipNegate) { - cache = negatedMinimatchCache; - } - - let matcher = cache.get(pattern); - - if (!matcher) { - matcher = new Minimatch( - pattern, - Object.assign({}, MINIMATCH_OPTIONS, options), - ); - cache.set(pattern, matcher); - } - - return matcher.match(filepath); -} - -/** - * Normalizes a `ConfigArray` by flattening it and executing any functions - * that are found inside. - * @param {Array} items The items in a `ConfigArray`. - * @param {Object} context The context object to pass into any function - * found. - * @param {Array} extraConfigTypes The config types to check. - * @returns {Promise} A flattened array containing only config objects. - * @throws {TypeError} When a config function returns a function. - */ -async function normalize(items, context, extraConfigTypes) { - const allowFunctions = extraConfigTypes.includes("function"); - const allowArrays = extraConfigTypes.includes("array"); - - async function* flatTraverse(array) { - for (let item of array) { - if (typeof item === "function") { - if (!allowFunctions) { - throw new TypeError("Unexpected function."); - } - - item = item(context); - if (item.then) { - item = await item; - } - } - - if (Array.isArray(item)) { - if (!allowArrays) { - throw new TypeError("Unexpected array."); - } - yield* flatTraverse(item); - } else if (typeof item === "function") { - throw new TypeError( - "A config function can only return an object or array.", - ); - } else { - yield item; - } - } - } - - /* - * Async iterables cannot be used with the spread operator, so we need to manually - * create the array to return. - */ - const asyncIterable = await flatTraverse(items); - const configs = []; - - for await (const config of asyncIterable) { - configs.push(config); - } - - return configs; -} - -/** - * Normalizes a `ConfigArray` by flattening it and executing any functions - * that are found inside. - * @param {Array} items The items in a `ConfigArray`. - * @param {Object} context The context object to pass into any function - * found. - * @param {Array} extraConfigTypes The config types to check. - * @returns {Array} A flattened array containing only config objects. - * @throws {TypeError} When a config function returns a function. - */ -function normalizeSync(items, context, extraConfigTypes) { - const allowFunctions = extraConfigTypes.includes("function"); - const allowArrays = extraConfigTypes.includes("array"); - - function* flatTraverse(array) { - for (let item of array) { - if (typeof item === "function") { - if (!allowFunctions) { - throw new TypeError("Unexpected function."); - } - - item = item(context); - if (item.then) { - throw new TypeError( - "Async config functions are not supported.", - ); - } - } - - if (Array.isArray(item)) { - if (!allowArrays) { - throw new TypeError("Unexpected array."); - } - - yield* flatTraverse(item); - } else if (typeof item === "function") { - throw new TypeError( - "A config function can only return an object or array.", - ); - } else { - yield item; - } - } - } - - return [...flatTraverse(items)]; -} - -/** - * Determines if a given file path should be ignored based on the given - * matcher. - * @param {Array boolean)>} ignores The ignore patterns to check. - * @param {string} filePath The absolute path of the file to check. - * @param {string} relativeFilePath The relative path of the file to check. - * @returns {boolean} True if the path should be ignored and false if not. - */ -function shouldIgnorePath(ignores, filePath, relativeFilePath) { - // all files outside of the basePath are ignored - if (relativeFilePath.startsWith("..")) { - return true; - } - - return ignores.reduce((ignored, matcher) => { - if (!ignored) { - if (typeof matcher === "function") { - return matcher(filePath); - } - - // don't check negated patterns because we're not ignored yet - if (!matcher.startsWith("!")) { - return doMatch(relativeFilePath, matcher); - } - - // otherwise we're still not ignored - return false; - } - - // only need to check negated patterns because we're ignored - if (typeof matcher === "string" && matcher.startsWith("!")) { - return !doMatch(relativeFilePath, matcher, { - flipNegate: true, - }); - } - - return ignored; - }, false); -} - -/** - * Determines if a given file path is matched by a config based on - * `ignores` only. - * @param {string} filePath The absolute file path to check. - * @param {string} basePath The base path for the config. - * @param {Object} config The config object to check. - * @returns {boolean} True if the file path is matched by the config, - * false if not. - */ -function pathMatchesIgnores(filePath, basePath, config) { - /* - * For both files and ignores, functions are passed the absolute - * file path while strings are compared against the relative - * file path. - */ - const relativeFilePath = path.relative(basePath, filePath); - - return ( - Object.keys(config).filter(key => !META_FIELDS.has(key)).length > 1 && - !shouldIgnorePath(config.ignores, filePath, relativeFilePath) - ); -} - -/** - * Determines if a given file path is matched by a config. If the config - * has no `files` field, then it matches; otherwise, if a `files` field - * is present then we match the globs in `files` and exclude any globs in - * `ignores`. - * @param {string} filePath The absolute file path to check. - * @param {string} basePath The base path for the config. - * @param {Object} config The config object to check. - * @returns {boolean} True if the file path is matched by the config, - * false if not. - */ -function pathMatches(filePath, basePath, config) { - /* - * For both files and ignores, functions are passed the absolute - * file path while strings are compared against the relative - * file path. - */ - const relativeFilePath = path.relative(basePath, filePath); - - // match both strings and functions - function match(pattern) { - if (isString(pattern)) { - return doMatch(relativeFilePath, pattern); - } - - if (typeof pattern === "function") { - return pattern(filePath); - } - - throw new TypeError(`Unexpected matcher type ${pattern}.`); - } - - // check for all matches to config.files - let filePathMatchesPattern = config.files.some(pattern => { - if (Array.isArray(pattern)) { - return pattern.every(match); - } - - return match(pattern); - }); - - /* - * If the file path matches the config.files patterns, then check to see - * if there are any files to ignore. - */ - if (filePathMatchesPattern && config.ignores) { - filePathMatchesPattern = !shouldIgnorePath( - config.ignores, - filePath, - relativeFilePath, - ); - } - - return filePathMatchesPattern; -} - -/** - * Ensures that a ConfigArray has been normalized. - * @param {ConfigArray} configArray The ConfigArray to check. - * @returns {void} - * @throws {Error} When the `ConfigArray` is not normalized. - */ -function assertNormalized(configArray) { - // TODO: Throw more verbose error - if (!configArray.isNormalized()) { - throw new Error( - "ConfigArray must be normalized to perform this operation.", - ); - } -} - -/** - * Ensures that config types are valid. - * @param {Array} extraConfigTypes The config types to check. - * @returns {void} - * @throws {Error} When the config types array is invalid. - */ -function assertExtraConfigTypes(extraConfigTypes) { - if (extraConfigTypes.length > 2) { - throw new TypeError( - "configTypes must be an array with at most two items.", - ); - } - - for (const configType of extraConfigTypes) { - if (!CONFIG_TYPES.has(configType)) { - throw new TypeError( - `Unexpected config type "${configType}" found. Expected one of: "object", "array", "function".`, - ); - } - } -} - -//------------------------------------------------------------------------------ -// Public Interface -//------------------------------------------------------------------------------ - -const ConfigArraySymbol = { - isNormalized: Symbol("isNormalized"), - configCache: Symbol("configCache"), - schema: Symbol("schema"), - finalizeConfig: Symbol("finalizeConfig"), - preprocessConfig: Symbol("preprocessConfig"), -}; - -// used to store calculate data for faster lookup -const dataCache = new WeakMap(); - -/** - * Represents an array of config objects and provides method for working with - * those config objects. - */ -class ConfigArray extends Array { - /** - * Creates a new instance of ConfigArray. - * @param {Iterable|Function|Object} configs An iterable yielding config - * objects, or a config function, or a config object. - * @param {Object} options The options for the ConfigArray. - * @param {string} [options.basePath=""] The path of the config file - * @param {boolean} [options.normalized=false] Flag indicating if the - * configs have already been normalized. - * @param {Object} [options.schema] The additional schema - * definitions to use for the ConfigArray schema. - * @param {Array} [options.extraConfigTypes] List of config types supported. - */ - constructor( - configs, - { - basePath = "", - normalized = false, - schema: customSchema, - extraConfigTypes = [], - } = {}, - ) { - super(); - - /** - * Tracks if the array has been normalized. - * @property isNormalized - * @type {boolean} - * @private - */ - this[ConfigArraySymbol.isNormalized] = normalized; - - /** - * The schema used for validating and merging configs. - * @property schema - * @type {ObjectSchemaInstance} - * @private - */ - this[ConfigArraySymbol.schema] = new ObjectSchema( - Object.assign({}, customSchema, baseSchema), - ); - - /** - * The path of the config file that this array was loaded from. - * This is used to calculate filename matches. - * @property basePath - * @type {string} - */ - this.basePath = basePath; - - assertExtraConfigTypes(extraConfigTypes); - - /** - * The supported config types. - * @type {Array} - */ - this.extraConfigTypes = [...extraConfigTypes]; - Object.freeze(this.extraConfigTypes); - - /** - * A cache to store calculated configs for faster repeat lookup. - * @property configCache - * @type {Map} - * @private - */ - this[ConfigArraySymbol.configCache] = new Map(); - - // init cache - dataCache.set(this, { - explicitMatches: new Map(), - directoryMatches: new Map(), - files: undefined, - ignores: undefined, - }); - - // load the configs into this array - if (Array.isArray(configs)) { - this.push(...configs); - } else { - this.push(configs); - } - } - - /** - * Prevent normal array methods from creating a new `ConfigArray` instance. - * This is to ensure that methods such as `slice()` won't try to create a - * new instance of `ConfigArray` behind the scenes as doing so may throw - * an error due to the different constructor signature. - * @type {ArrayConstructor} The `Array` constructor. - */ - static get [Symbol.species]() { - return Array; - } - - /** - * Returns the `files` globs from every config object in the array. - * This can be used to determine which files will be matched by a - * config array or to use as a glob pattern when no patterns are provided - * for a command line interface. - * @returns {Array} An array of matchers. - */ - get files() { - assertNormalized(this); - - // if this data has been cached, retrieve it - const cache = dataCache.get(this); - - if (cache.files) { - return cache.files; - } - - // otherwise calculate it - - const result = []; - - for (const config of this) { - if (config.files) { - config.files.forEach(filePattern => { - result.push(filePattern); - }); - } - } - - // store result - cache.files = result; - dataCache.set(this, cache); - - return result; - } - - /** - * Returns ignore matchers that should always be ignored regardless of - * the matching `files` fields in any configs. This is necessary to mimic - * the behavior of things like .gitignore and .eslintignore, allowing a - * globbing operation to be faster. - * @returns {string[]} An array of string patterns and functions to be ignored. - */ - get ignores() { - assertNormalized(this); - - // if this data has been cached, retrieve it - const cache = dataCache.get(this); - - if (cache.ignores) { - return cache.ignores; - } - - // otherwise calculate it - - const result = []; - - for (const config of this) { - /* - * We only count ignores if there are no other keys in the object. - * In this case, it acts list a globally ignored pattern. If there - * are additional keys, then ignores act like exclusions. - */ - if ( - config.ignores && - Object.keys(config).filter(key => !META_FIELDS.has(key)) - .length === 1 - ) { - result.push(...config.ignores); - } - } - - // store result - cache.ignores = result; - dataCache.set(this, cache); - - return result; - } - - /** - * Indicates if the config array has been normalized. - * @returns {boolean} True if the config array is normalized, false if not. - */ - isNormalized() { - return this[ConfigArraySymbol.isNormalized]; - } - - /** - * Normalizes a config array by flattening embedded arrays and executing - * config functions. - * @param {Object} [context] The context object for config functions. - * @returns {Promise} The current ConfigArray instance. - */ - async normalize(context = {}) { - if (!this.isNormalized()) { - const normalizedConfigs = await normalize( - this, - context, - this.extraConfigTypes, - ); - this.length = 0; - this.push( - ...normalizedConfigs.map( - this[ConfigArraySymbol.preprocessConfig].bind(this), - ), - ); - this.forEach(assertValidBaseConfig); - this[ConfigArraySymbol.isNormalized] = true; - - // prevent further changes - Object.freeze(this); - } - - return this; - } - - /** - * Normalizes a config array by flattening embedded arrays and executing - * config functions. - * @param {Object} [context] The context object for config functions. - * @returns {ConfigArray} The current ConfigArray instance. - */ - normalizeSync(context = {}) { - if (!this.isNormalized()) { - const normalizedConfigs = normalizeSync( - this, - context, - this.extraConfigTypes, - ); - this.length = 0; - this.push( - ...normalizedConfigs.map( - this[ConfigArraySymbol.preprocessConfig].bind(this), - ), - ); - this.forEach(assertValidBaseConfig); - this[ConfigArraySymbol.isNormalized] = true; - - // prevent further changes - Object.freeze(this); - } - - return this; - } - - /* eslint-disable class-methods-use-this -- Desired as instance methods */ - - /** - * Finalizes the state of a config before being cached and returned by - * `getConfig()`. Does nothing by default but is provided to be - * overridden by subclasses as necessary. - * @param {Object} config The config to finalize. - * @returns {Object} The finalized config. - */ - [ConfigArraySymbol.finalizeConfig](config) { - return config; - } - - /** - * Preprocesses a config during the normalization process. This is the - * method to override if you want to convert an array item before it is - * validated for the first time. For example, if you want to replace a - * string with an object, this is the method to override. - * @param {Object} config The config to preprocess. - * @returns {Object} The config to use in place of the argument. - */ - [ConfigArraySymbol.preprocessConfig](config) { - return config; - } - - /* eslint-enable class-methods-use-this -- Desired as instance methods */ - - /** - * Returns the config object for a given file path and a status that can be used to determine why a file has no config. - * @param {string} filePath The complete path of a file to get a config for. - * @returns {{ config?: Object, status: "ignored"|"external"|"unconfigured"|"matched" }} - * An object with an optional property `config` and property `status`. - * `config` is the config object for the specified file as returned by {@linkcode ConfigArray.getConfig}, - * `status` a is one of the constants returned by {@linkcode ConfigArray.getConfigStatus}. - */ - getConfigWithStatus(filePath) { - assertNormalized(this); - - const cache = this[ConfigArraySymbol.configCache]; - - // first check the cache for a filename match to avoid duplicate work - if (cache.has(filePath)) { - return cache.get(filePath); - } - - // check to see if the file is outside the base path - - const relativeFilePath = path.relative(this.basePath, filePath); - - if (relativeFilePath.startsWith("..")) { - debug(`No config for file ${filePath} outside of base path`); - - // cache and return result - cache.set(filePath, CONFIG_WITH_STATUS_EXTERNAL); - return CONFIG_WITH_STATUS_EXTERNAL; - } - - // next check to see if the file should be ignored - - // check if this should be ignored due to its directory - if (this.isDirectoryIgnored(path.dirname(filePath))) { - debug(`Ignoring ${filePath} based on directory pattern`); - - // cache and return result - cache.set(filePath, CONFIG_WITH_STATUS_IGNORED); - return CONFIG_WITH_STATUS_IGNORED; - } - - if (shouldIgnorePath(this.ignores, filePath, relativeFilePath)) { - debug(`Ignoring ${filePath} based on file pattern`); - - // cache and return result - cache.set(filePath, CONFIG_WITH_STATUS_IGNORED); - return CONFIG_WITH_STATUS_IGNORED; - } - - // filePath isn't automatically ignored, so try to construct config - - const matchingConfigIndices = []; - let matchFound = false; - const universalPattern = /^\*$|\/\*{1,2}$/u; - - this.forEach((config, index) => { - if (!config.files) { - if (!config.ignores) { - debug(`Anonymous universal config found for ${filePath}`); - matchingConfigIndices.push(index); - return; - } - - if (pathMatchesIgnores(filePath, this.basePath, config)) { - debug( - `Matching config found for ${filePath} (based on ignores: ${config.ignores})`, - ); - matchingConfigIndices.push(index); - return; - } - - debug( - `Skipped config found for ${filePath} (based on ignores: ${config.ignores})`, - ); - return; - } - - /* - * If a config has a files pattern * or patterns ending in /** or /*, - * and the filePath only matches those patterns, then the config is only - * applied if there is another config where the filePath matches - * a file with a specific extensions such as *.js. - */ - - const universalFiles = config.files.filter(pattern => - universalPattern.test(pattern), - ); - - // universal patterns were found so we need to check the config twice - if (universalFiles.length) { - debug("Universal files patterns found. Checking carefully."); - - const nonUniversalFiles = config.files.filter( - pattern => !universalPattern.test(pattern), - ); - - // check that the config matches without the non-universal files first - if ( - nonUniversalFiles.length && - pathMatches(filePath, this.basePath, { - files: nonUniversalFiles, - ignores: config.ignores, - }) - ) { - debug(`Matching config found for ${filePath}`); - matchingConfigIndices.push(index); - matchFound = true; - return; - } - - // if there wasn't a match then check if it matches with universal files - if ( - universalFiles.length && - pathMatches(filePath, this.basePath, { - files: universalFiles, - ignores: config.ignores, - }) - ) { - debug(`Matching config found for ${filePath}`); - matchingConfigIndices.push(index); - return; - } - - // if we make here, then there was no match - return; - } - - // the normal case - if (pathMatches(filePath, this.basePath, config)) { - debug(`Matching config found for ${filePath}`); - matchingConfigIndices.push(index); - matchFound = true; - } - }); - - // if matching both files and ignores, there will be no config to create - if (!matchFound) { - debug(`No matching configs found for ${filePath}`); - - // cache and return result - cache.set(filePath, CONFIG_WITH_STATUS_UNCONFIGURED); - return CONFIG_WITH_STATUS_UNCONFIGURED; - } - - // check to see if there is a config cached by indices - const indicesKey = matchingConfigIndices.toString(); - let configWithStatus = cache.get(indicesKey); - - if (configWithStatus) { - // also store for filename for faster lookup next time - cache.set(filePath, configWithStatus); - - return configWithStatus; - } - - // otherwise construct the config - - // eslint-disable-next-line array-callback-return, consistent-return -- rethrowConfigError always throws an error - let finalConfig = matchingConfigIndices.reduce((result, index) => { - try { - return this[ConfigArraySymbol.schema].merge( - result, - this[index], - ); - } catch (validationError) { - rethrowConfigError(this[index], index, validationError); - } - }, {}); - - finalConfig = this[ConfigArraySymbol.finalizeConfig](finalConfig); - - configWithStatus = Object.freeze({ - config: finalConfig, - status: "matched", - }); - cache.set(filePath, configWithStatus); - cache.set(indicesKey, configWithStatus); - - return configWithStatus; - } - - /** - * Returns the config object for a given file path. - * @param {string} filePath The complete path of a file to get a config for. - * @returns {Object|undefined} The config object for this file or `undefined`. - */ - getConfig(filePath) { - return this.getConfigWithStatus(filePath).config; - } - - /** - * Determines whether a file has a config or why it doesn't. - * @param {string} filePath The complete path of the file to check. - * @returns {"ignored"|"external"|"unconfigured"|"matched"} One of the following values: - * * `"ignored"`: the file is ignored - * * `"external"`: the file is outside the base path - * * `"unconfigured"`: the file is not matched by any config - * * `"matched"`: the file has a matching config - */ - getConfigStatus(filePath) { - return this.getConfigWithStatus(filePath).status; - } - - /** - * Determines if the given filepath is ignored based on the configs. - * @param {string} filePath The complete path of a file to check. - * @returns {boolean} True if the path is ignored, false if not. - * @deprecated Use `isFileIgnored` instead. - */ - isIgnored(filePath) { - return this.isFileIgnored(filePath); - } - - /** - * Determines if the given filepath is ignored based on the configs. - * @param {string} filePath The complete path of a file to check. - * @returns {boolean} True if the path is ignored, false if not. - */ - isFileIgnored(filePath) { - return this.getConfigStatus(filePath) === "ignored"; - } - - /** - * Determines if the given directory is ignored based on the configs. - * This checks only default `ignores` that don't have `files` in the - * same config. A pattern such as `/foo` be considered to ignore the directory - * while a pattern such as `/foo/**` is not considered to ignore the - * directory because it is matching files. - * @param {string} directoryPath The complete path of a directory to check. - * @returns {boolean} True if the directory is ignored, false if not. Will - * return true for any directory that is not inside of `basePath`. - * @throws {Error} When the `ConfigArray` is not normalized. - */ - isDirectoryIgnored(directoryPath) { - assertNormalized(this); - - const relativeDirectoryPath = path - .relative(this.basePath, directoryPath) - .replace(/\\/gu, "/"); - - if (relativeDirectoryPath.startsWith("..")) { - return true; - } - - // first check the cache - const cache = dataCache.get(this).directoryMatches; - - if (cache.has(relativeDirectoryPath)) { - return cache.get(relativeDirectoryPath); - } - - const directoryParts = relativeDirectoryPath.split("/"); - let relativeDirectoryToCheck = ""; - let result; - - /* - * In order to get the correct gitignore-style ignores, where an - * ignored parent directory cannot have any descendants unignored, - * we need to check every directory starting at the parent all - * the way down to the actual requested directory. - * - * We aggressively cache all of this info to make sure we don't - * have to recalculate everything for every call. - */ - do { - relativeDirectoryToCheck += `${directoryParts.shift()}/`; - - result = shouldIgnorePath( - this.ignores, - path.join(this.basePath, relativeDirectoryToCheck), - relativeDirectoryToCheck, - ); - - cache.set(relativeDirectoryToCheck, result); - } while (!result && directoryParts.length); - - // also cache the result for the requested path - cache.set(relativeDirectoryPath, result); - - return result; - } -} - -export { ConfigArray, ConfigArraySymbol }; diff --git a/tools/eslint/node_modules/@eslint/config-array/package.json b/tools/eslint/node_modules/@eslint/config-array/package.json deleted file mode 100644 index 5e7f838e47cc4e..00000000000000 --- a/tools/eslint/node_modules/@eslint/config-array/package.json +++ /dev/null @@ -1,64 +0,0 @@ -{ - "name": "@eslint/config-array", - "version": "0.17.0", - "description": "General purpose glob-based configuration matching.", - "author": "Nicholas C. Zakas", - "type": "module", - "main": "dist/esm/index.js", - "types": "dist/esm/index.d.ts", - "exports": { - "require": { - "types": "./dist/cjs/index.d.cts", - "default": "./dist/cjs/index.cjs" - }, - "import": { - "types": "./dist/esm/index.d.ts", - "default": "./dist/esm/index.js" - } - }, - "files": [ - "dist" - ], - "publishConfig": { - "access": "public" - }, - "repository": { - "type": "git", - "url": "git+https://github.com/eslint/rewrite.git" - }, - "bugs": { - "url": "https://github.com/eslint/rewrite/issues" - }, - "homepage": "https://github.com/eslint/rewrite#readme", - "scripts": { - "build:dedupe-types": "node ../../tools/dedupe-types.js dist/cjs/index.cjs dist/esm/index.js", - "build:cts": "node -e \"fs.copyFileSync('dist/esm/index.d.ts', 'dist/cjs/index.d.cts')\"", - "build": "rollup -c && npm run build:dedupe-types && tsc -p tsconfig.esm.json && npm run build:cts", - "test:jsr": "npx jsr@latest publish --dry-run", - "pretest": "npm run build", - "test": "mocha tests/", - "test:coverage": "c8 npm test" - }, - "keywords": [ - "configuration", - "configarray", - "config file" - ], - "license": "Apache-2.0", - "dependencies": { - "@eslint/object-schema": "^2.1.4", - "debug": "^4.3.1", - "minimatch": "^3.1.2" - }, - "devDependencies": { - "@types/minimatch": "^3.0.5", - "c8": "^9.1.0", - "mocha": "^10.4.0", - "rollup": "^4.16.2", - "rollup-plugin-copy": "^3.5.0", - "typescript": "^5.4.5" - }, - "engines": { - "node": "^18.18.0 || ^20.9.0 || >=21.1.0" - } -} diff --git a/tools/eslint/node_modules/@eslint/eslintrc/LICENSE b/tools/eslint/node_modules/@eslint/eslintrc/LICENSE deleted file mode 100644 index b607bb36e96c33..00000000000000 --- a/tools/eslint/node_modules/@eslint/eslintrc/LICENSE +++ /dev/null @@ -1,19 +0,0 @@ -Copyright OpenJS Foundation and other contributors, - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. diff --git a/tools/eslint/node_modules/@eslint/eslintrc/conf/config-schema.js b/tools/eslint/node_modules/@eslint/eslintrc/conf/config-schema.js deleted file mode 100644 index ada90e135caf41..00000000000000 --- a/tools/eslint/node_modules/@eslint/eslintrc/conf/config-schema.js +++ /dev/null @@ -1,79 +0,0 @@ -/** - * @fileoverview Defines a schema for configs. - * @author Sylvan Mably - */ - -const baseConfigProperties = { - $schema: { type: "string" }, - env: { type: "object" }, - extends: { $ref: "#/definitions/stringOrStrings" }, - globals: { type: "object" }, - overrides: { - type: "array", - items: { $ref: "#/definitions/overrideConfig" }, - additionalItems: false - }, - parser: { type: ["string", "null"] }, - parserOptions: { type: "object" }, - plugins: { type: "array" }, - processor: { type: "string" }, - rules: { type: "object" }, - settings: { type: "object" }, - noInlineConfig: { type: "boolean" }, - reportUnusedDisableDirectives: { type: "boolean" }, - - ecmaFeatures: { type: "object" } // deprecated; logs a warning when used -}; - -const configSchema = { - definitions: { - stringOrStrings: { - oneOf: [ - { type: "string" }, - { - type: "array", - items: { type: "string" }, - additionalItems: false - } - ] - }, - stringOrStringsRequired: { - oneOf: [ - { type: "string" }, - { - type: "array", - items: { type: "string" }, - additionalItems: false, - minItems: 1 - } - ] - }, - - // Config at top-level. - objectConfig: { - type: "object", - properties: { - root: { type: "boolean" }, - ignorePatterns: { $ref: "#/definitions/stringOrStrings" }, - ...baseConfigProperties - }, - additionalProperties: false - }, - - // Config in `overrides`. - overrideConfig: { - type: "object", - properties: { - excludedFiles: { $ref: "#/definitions/stringOrStrings" }, - files: { $ref: "#/definitions/stringOrStringsRequired" }, - ...baseConfigProperties - }, - required: ["files"], - additionalProperties: false - } - }, - - $ref: "#/definitions/objectConfig" -}; - -export default configSchema; diff --git a/tools/eslint/node_modules/@eslint/eslintrc/conf/environments.js b/tools/eslint/node_modules/@eslint/eslintrc/conf/environments.js deleted file mode 100644 index 50d1b1d106616f..00000000000000 --- a/tools/eslint/node_modules/@eslint/eslintrc/conf/environments.js +++ /dev/null @@ -1,215 +0,0 @@ -/** - * @fileoverview Defines environment settings and globals. - * @author Elan Shanker - */ - -//------------------------------------------------------------------------------ -// Requirements -//------------------------------------------------------------------------------ - -import globals from "globals"; - -//------------------------------------------------------------------------------ -// Helpers -//------------------------------------------------------------------------------ - -/** - * Get the object that has difference. - * @param {Record} current The newer object. - * @param {Record} prev The older object. - * @returns {Record} The difference object. - */ -function getDiff(current, prev) { - const retv = {}; - - for (const [key, value] of Object.entries(current)) { - if (!Object.hasOwnProperty.call(prev, key)) { - retv[key] = value; - } - } - - return retv; -} - -const newGlobals2015 = getDiff(globals.es2015, globals.es5); // 19 variables such as Promise, Map, ... -const newGlobals2017 = { - Atomics: false, - SharedArrayBuffer: false -}; -const newGlobals2020 = { - BigInt: false, - BigInt64Array: false, - BigUint64Array: false, - globalThis: false -}; - -const newGlobals2021 = { - AggregateError: false, - FinalizationRegistry: false, - WeakRef: false -}; - -//------------------------------------------------------------------------------ -// Public Interface -//------------------------------------------------------------------------------ - -/** @type {Map} */ -export default new Map(Object.entries({ - - // Language - builtin: { - globals: globals.es5 - }, - es6: { - globals: newGlobals2015, - parserOptions: { - ecmaVersion: 6 - } - }, - es2015: { - globals: newGlobals2015, - parserOptions: { - ecmaVersion: 6 - } - }, - es2016: { - globals: newGlobals2015, - parserOptions: { - ecmaVersion: 7 - } - }, - es2017: { - globals: { ...newGlobals2015, ...newGlobals2017 }, - parserOptions: { - ecmaVersion: 8 - } - }, - es2018: { - globals: { ...newGlobals2015, ...newGlobals2017 }, - parserOptions: { - ecmaVersion: 9 - } - }, - es2019: { - globals: { ...newGlobals2015, ...newGlobals2017 }, - parserOptions: { - ecmaVersion: 10 - } - }, - es2020: { - globals: { ...newGlobals2015, ...newGlobals2017, ...newGlobals2020 }, - parserOptions: { - ecmaVersion: 11 - } - }, - es2021: { - globals: { ...newGlobals2015, ...newGlobals2017, ...newGlobals2020, ...newGlobals2021 }, - parserOptions: { - ecmaVersion: 12 - } - }, - es2022: { - globals: { ...newGlobals2015, ...newGlobals2017, ...newGlobals2020, ...newGlobals2021 }, - parserOptions: { - ecmaVersion: 13 - } - }, - es2023: { - globals: { ...newGlobals2015, ...newGlobals2017, ...newGlobals2020, ...newGlobals2021 }, - parserOptions: { - ecmaVersion: 14 - } - }, - es2024: { - globals: { ...newGlobals2015, ...newGlobals2017, ...newGlobals2020, ...newGlobals2021 }, - parserOptions: { - ecmaVersion: 15 - } - }, - - // Platforms - browser: { - globals: globals.browser - }, - node: { - globals: globals.node, - parserOptions: { - ecmaFeatures: { - globalReturn: true - } - } - }, - "shared-node-browser": { - globals: globals["shared-node-browser"] - }, - worker: { - globals: globals.worker - }, - serviceworker: { - globals: globals.serviceworker - }, - - // Frameworks - commonjs: { - globals: globals.commonjs, - parserOptions: { - ecmaFeatures: { - globalReturn: true - } - } - }, - amd: { - globals: globals.amd - }, - mocha: { - globals: globals.mocha - }, - jasmine: { - globals: globals.jasmine - }, - jest: { - globals: globals.jest - }, - phantomjs: { - globals: globals.phantomjs - }, - jquery: { - globals: globals.jquery - }, - qunit: { - globals: globals.qunit - }, - prototypejs: { - globals: globals.prototypejs - }, - shelljs: { - globals: globals.shelljs - }, - meteor: { - globals: globals.meteor - }, - mongo: { - globals: globals.mongo - }, - protractor: { - globals: globals.protractor - }, - applescript: { - globals: globals.applescript - }, - nashorn: { - globals: globals.nashorn - }, - atomtest: { - globals: globals.atomtest - }, - embertest: { - globals: globals.embertest - }, - webextensions: { - globals: globals.webextensions - }, - greasemonkey: { - globals: globals.greasemonkey - } -})); diff --git a/tools/eslint/node_modules/@eslint/eslintrc/dist/eslintrc-universal.cjs b/tools/eslint/node_modules/@eslint/eslintrc/dist/eslintrc-universal.cjs deleted file mode 100644 index 98892f61f25753..00000000000000 --- a/tools/eslint/node_modules/@eslint/eslintrc/dist/eslintrc-universal.cjs +++ /dev/null @@ -1,1143 +0,0 @@ -'use strict'; - -Object.defineProperty(exports, '__esModule', { value: true }); - -var util = require('util'); -var path = require('path'); -var Ajv = require('ajv'); -var globals = require('globals'); - -function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; } - -var util__default = /*#__PURE__*/_interopDefaultLegacy(util); -var path__default = /*#__PURE__*/_interopDefaultLegacy(path); -var Ajv__default = /*#__PURE__*/_interopDefaultLegacy(Ajv); -var globals__default = /*#__PURE__*/_interopDefaultLegacy(globals); - -/** - * @fileoverview Config file operations. This file must be usable in the browser, - * so no Node-specific code can be here. - * @author Nicholas C. Zakas - */ - -//------------------------------------------------------------------------------ -// Private -//------------------------------------------------------------------------------ - -const RULE_SEVERITY_STRINGS = ["off", "warn", "error"], - RULE_SEVERITY = RULE_SEVERITY_STRINGS.reduce((map, value, index) => { - map[value] = index; - return map; - }, {}), - VALID_SEVERITIES = [0, 1, 2, "off", "warn", "error"]; - -//------------------------------------------------------------------------------ -// Public Interface -//------------------------------------------------------------------------------ - -/** - * Normalizes the severity value of a rule's configuration to a number - * @param {(number|string|[number, ...*]|[string, ...*])} ruleConfig A rule's configuration value, generally - * received from the user. A valid config value is either 0, 1, 2, the string "off" (treated the same as 0), - * the string "warn" (treated the same as 1), the string "error" (treated the same as 2), or an array - * whose first element is one of the above values. Strings are matched case-insensitively. - * @returns {(0|1|2)} The numeric severity value if the config value was valid, otherwise 0. - */ -function getRuleSeverity(ruleConfig) { - const severityValue = Array.isArray(ruleConfig) ? ruleConfig[0] : ruleConfig; - - if (severityValue === 0 || severityValue === 1 || severityValue === 2) { - return severityValue; - } - - if (typeof severityValue === "string") { - return RULE_SEVERITY[severityValue.toLowerCase()] || 0; - } - - return 0; -} - -/** - * Converts old-style severity settings (0, 1, 2) into new-style - * severity settings (off, warn, error) for all rules. Assumption is that severity - * values have already been validated as correct. - * @param {Object} config The config object to normalize. - * @returns {void} - */ -function normalizeToStrings(config) { - - if (config.rules) { - Object.keys(config.rules).forEach(ruleId => { - const ruleConfig = config.rules[ruleId]; - - if (typeof ruleConfig === "number") { - config.rules[ruleId] = RULE_SEVERITY_STRINGS[ruleConfig] || RULE_SEVERITY_STRINGS[0]; - } else if (Array.isArray(ruleConfig) && typeof ruleConfig[0] === "number") { - ruleConfig[0] = RULE_SEVERITY_STRINGS[ruleConfig[0]] || RULE_SEVERITY_STRINGS[0]; - } - }); - } -} - -/** - * Determines if the severity for the given rule configuration represents an error. - * @param {int|string|Array} ruleConfig The configuration for an individual rule. - * @returns {boolean} True if the rule represents an error, false if not. - */ -function isErrorSeverity(ruleConfig) { - return getRuleSeverity(ruleConfig) === 2; -} - -/** - * Checks whether a given config has valid severity or not. - * @param {number|string|Array} ruleConfig The configuration for an individual rule. - * @returns {boolean} `true` if the configuration has valid severity. - */ -function isValidSeverity(ruleConfig) { - let severity = Array.isArray(ruleConfig) ? ruleConfig[0] : ruleConfig; - - if (typeof severity === "string") { - severity = severity.toLowerCase(); - } - return VALID_SEVERITIES.indexOf(severity) !== -1; -} - -/** - * Checks whether every rule of a given config has valid severity or not. - * @param {Object} config The configuration for rules. - * @returns {boolean} `true` if the configuration has valid severity. - */ -function isEverySeverityValid(config) { - return Object.keys(config).every(ruleId => isValidSeverity(config[ruleId])); -} - -/** - * Normalizes a value for a global in a config - * @param {(boolean|string|null)} configuredValue The value given for a global in configuration or in - * a global directive comment - * @returns {("readable"|"writeable"|"off")} The value normalized as a string - * @throws Error if global value is invalid - */ -function normalizeConfigGlobal(configuredValue) { - switch (configuredValue) { - case "off": - return "off"; - - case true: - case "true": - case "writeable": - case "writable": - return "writable"; - - case null: - case false: - case "false": - case "readable": - case "readonly": - return "readonly"; - - default: - throw new Error(`'${configuredValue}' is not a valid configuration for a global (use 'readonly', 'writable', or 'off')`); - } -} - -var ConfigOps = { - __proto__: null, - getRuleSeverity: getRuleSeverity, - normalizeToStrings: normalizeToStrings, - isErrorSeverity: isErrorSeverity, - isValidSeverity: isValidSeverity, - isEverySeverityValid: isEverySeverityValid, - normalizeConfigGlobal: normalizeConfigGlobal -}; - -/** - * @fileoverview Provide the function that emits deprecation warnings. - * @author Toru Nagashima - */ - -//------------------------------------------------------------------------------ -// Private -//------------------------------------------------------------------------------ - -// Defitions for deprecation warnings. -const deprecationWarningMessages = { - ESLINT_LEGACY_ECMAFEATURES: - "The 'ecmaFeatures' config file property is deprecated and has no effect.", - ESLINT_PERSONAL_CONFIG_LOAD: - "'~/.eslintrc.*' config files have been deprecated. " + - "Please use a config file per project or the '--config' option.", - ESLINT_PERSONAL_CONFIG_SUPPRESS: - "'~/.eslintrc.*' config files have been deprecated. " + - "Please remove it or add 'root:true' to the config files in your " + - "projects in order to avoid loading '~/.eslintrc.*' accidentally." -}; - -const sourceFileErrorCache = new Set(); - -/** - * Emits a deprecation warning containing a given filepath. A new deprecation warning is emitted - * for each unique file path, but repeated invocations with the same file path have no effect. - * No warnings are emitted if the `--no-deprecation` or `--no-warnings` Node runtime flags are active. - * @param {string} source The name of the configuration source to report the warning for. - * @param {string} errorCode The warning message to show. - * @returns {void} - */ -function emitDeprecationWarning(source, errorCode) { - const cacheKey = JSON.stringify({ source, errorCode }); - - if (sourceFileErrorCache.has(cacheKey)) { - return; - } - sourceFileErrorCache.add(cacheKey); - - const rel = path__default["default"].relative(process.cwd(), source); - const message = deprecationWarningMessages[errorCode]; - - process.emitWarning( - `${message} (found in "${rel}")`, - "DeprecationWarning", - errorCode - ); -} - -/** - * @fileoverview The instance of Ajv validator. - * @author Evgeny Poberezkin - */ - -//----------------------------------------------------------------------------- -// Helpers -//----------------------------------------------------------------------------- - -/* - * Copied from ajv/lib/refs/json-schema-draft-04.json - * The MIT License (MIT) - * Copyright (c) 2015-2017 Evgeny Poberezkin - */ -const metaSchema = { - id: "http://json-schema.org/draft-04/schema#", - $schema: "http://json-schema.org/draft-04/schema#", - description: "Core schema meta-schema", - definitions: { - schemaArray: { - type: "array", - minItems: 1, - items: { $ref: "#" } - }, - positiveInteger: { - type: "integer", - minimum: 0 - }, - positiveIntegerDefault0: { - allOf: [{ $ref: "#/definitions/positiveInteger" }, { default: 0 }] - }, - simpleTypes: { - enum: ["array", "boolean", "integer", "null", "number", "object", "string"] - }, - stringArray: { - type: "array", - items: { type: "string" }, - minItems: 1, - uniqueItems: true - } - }, - type: "object", - properties: { - id: { - type: "string" - }, - $schema: { - type: "string" - }, - title: { - type: "string" - }, - description: { - type: "string" - }, - default: { }, - multipleOf: { - type: "number", - minimum: 0, - exclusiveMinimum: true - }, - maximum: { - type: "number" - }, - exclusiveMaximum: { - type: "boolean", - default: false - }, - minimum: { - type: "number" - }, - exclusiveMinimum: { - type: "boolean", - default: false - }, - maxLength: { $ref: "#/definitions/positiveInteger" }, - minLength: { $ref: "#/definitions/positiveIntegerDefault0" }, - pattern: { - type: "string", - format: "regex" - }, - additionalItems: { - anyOf: [ - { type: "boolean" }, - { $ref: "#" } - ], - default: { } - }, - items: { - anyOf: [ - { $ref: "#" }, - { $ref: "#/definitions/schemaArray" } - ], - default: { } - }, - maxItems: { $ref: "#/definitions/positiveInteger" }, - minItems: { $ref: "#/definitions/positiveIntegerDefault0" }, - uniqueItems: { - type: "boolean", - default: false - }, - maxProperties: { $ref: "#/definitions/positiveInteger" }, - minProperties: { $ref: "#/definitions/positiveIntegerDefault0" }, - required: { $ref: "#/definitions/stringArray" }, - additionalProperties: { - anyOf: [ - { type: "boolean" }, - { $ref: "#" } - ], - default: { } - }, - definitions: { - type: "object", - additionalProperties: { $ref: "#" }, - default: { } - }, - properties: { - type: "object", - additionalProperties: { $ref: "#" }, - default: { } - }, - patternProperties: { - type: "object", - additionalProperties: { $ref: "#" }, - default: { } - }, - dependencies: { - type: "object", - additionalProperties: { - anyOf: [ - { $ref: "#" }, - { $ref: "#/definitions/stringArray" } - ] - } - }, - enum: { - type: "array", - minItems: 1, - uniqueItems: true - }, - type: { - anyOf: [ - { $ref: "#/definitions/simpleTypes" }, - { - type: "array", - items: { $ref: "#/definitions/simpleTypes" }, - minItems: 1, - uniqueItems: true - } - ] - }, - format: { type: "string" }, - allOf: { $ref: "#/definitions/schemaArray" }, - anyOf: { $ref: "#/definitions/schemaArray" }, - oneOf: { $ref: "#/definitions/schemaArray" }, - not: { $ref: "#" } - }, - dependencies: { - exclusiveMaximum: ["maximum"], - exclusiveMinimum: ["minimum"] - }, - default: { } -}; - -//------------------------------------------------------------------------------ -// Public Interface -//------------------------------------------------------------------------------ - -var ajvOrig = (additionalOptions = {}) => { - const ajv = new Ajv__default["default"]({ - meta: false, - useDefaults: true, - validateSchema: false, - missingRefs: "ignore", - verbose: true, - schemaId: "auto", - ...additionalOptions - }); - - ajv.addMetaSchema(metaSchema); - // eslint-disable-next-line no-underscore-dangle - ajv._opts.defaultMeta = metaSchema.id; - - return ajv; -}; - -/** - * @fileoverview Defines a schema for configs. - * @author Sylvan Mably - */ - -const baseConfigProperties = { - $schema: { type: "string" }, - env: { type: "object" }, - extends: { $ref: "#/definitions/stringOrStrings" }, - globals: { type: "object" }, - overrides: { - type: "array", - items: { $ref: "#/definitions/overrideConfig" }, - additionalItems: false - }, - parser: { type: ["string", "null"] }, - parserOptions: { type: "object" }, - plugins: { type: "array" }, - processor: { type: "string" }, - rules: { type: "object" }, - settings: { type: "object" }, - noInlineConfig: { type: "boolean" }, - reportUnusedDisableDirectives: { type: "boolean" }, - - ecmaFeatures: { type: "object" } // deprecated; logs a warning when used -}; - -const configSchema = { - definitions: { - stringOrStrings: { - oneOf: [ - { type: "string" }, - { - type: "array", - items: { type: "string" }, - additionalItems: false - } - ] - }, - stringOrStringsRequired: { - oneOf: [ - { type: "string" }, - { - type: "array", - items: { type: "string" }, - additionalItems: false, - minItems: 1 - } - ] - }, - - // Config at top-level. - objectConfig: { - type: "object", - properties: { - root: { type: "boolean" }, - ignorePatterns: { $ref: "#/definitions/stringOrStrings" }, - ...baseConfigProperties - }, - additionalProperties: false - }, - - // Config in `overrides`. - overrideConfig: { - type: "object", - properties: { - excludedFiles: { $ref: "#/definitions/stringOrStrings" }, - files: { $ref: "#/definitions/stringOrStringsRequired" }, - ...baseConfigProperties - }, - required: ["files"], - additionalProperties: false - } - }, - - $ref: "#/definitions/objectConfig" -}; - -/** - * @fileoverview Defines environment settings and globals. - * @author Elan Shanker - */ - -//------------------------------------------------------------------------------ -// Helpers -//------------------------------------------------------------------------------ - -/** - * Get the object that has difference. - * @param {Record} current The newer object. - * @param {Record} prev The older object. - * @returns {Record} The difference object. - */ -function getDiff(current, prev) { - const retv = {}; - - for (const [key, value] of Object.entries(current)) { - if (!Object.hasOwnProperty.call(prev, key)) { - retv[key] = value; - } - } - - return retv; -} - -const newGlobals2015 = getDiff(globals__default["default"].es2015, globals__default["default"].es5); // 19 variables such as Promise, Map, ... -const newGlobals2017 = { - Atomics: false, - SharedArrayBuffer: false -}; -const newGlobals2020 = { - BigInt: false, - BigInt64Array: false, - BigUint64Array: false, - globalThis: false -}; - -const newGlobals2021 = { - AggregateError: false, - FinalizationRegistry: false, - WeakRef: false -}; - -//------------------------------------------------------------------------------ -// Public Interface -//------------------------------------------------------------------------------ - -/** @type {Map} */ -var environments = new Map(Object.entries({ - - // Language - builtin: { - globals: globals__default["default"].es5 - }, - es6: { - globals: newGlobals2015, - parserOptions: { - ecmaVersion: 6 - } - }, - es2015: { - globals: newGlobals2015, - parserOptions: { - ecmaVersion: 6 - } - }, - es2016: { - globals: newGlobals2015, - parserOptions: { - ecmaVersion: 7 - } - }, - es2017: { - globals: { ...newGlobals2015, ...newGlobals2017 }, - parserOptions: { - ecmaVersion: 8 - } - }, - es2018: { - globals: { ...newGlobals2015, ...newGlobals2017 }, - parserOptions: { - ecmaVersion: 9 - } - }, - es2019: { - globals: { ...newGlobals2015, ...newGlobals2017 }, - parserOptions: { - ecmaVersion: 10 - } - }, - es2020: { - globals: { ...newGlobals2015, ...newGlobals2017, ...newGlobals2020 }, - parserOptions: { - ecmaVersion: 11 - } - }, - es2021: { - globals: { ...newGlobals2015, ...newGlobals2017, ...newGlobals2020, ...newGlobals2021 }, - parserOptions: { - ecmaVersion: 12 - } - }, - es2022: { - globals: { ...newGlobals2015, ...newGlobals2017, ...newGlobals2020, ...newGlobals2021 }, - parserOptions: { - ecmaVersion: 13 - } - }, - es2023: { - globals: { ...newGlobals2015, ...newGlobals2017, ...newGlobals2020, ...newGlobals2021 }, - parserOptions: { - ecmaVersion: 14 - } - }, - es2024: { - globals: { ...newGlobals2015, ...newGlobals2017, ...newGlobals2020, ...newGlobals2021 }, - parserOptions: { - ecmaVersion: 15 - } - }, - - // Platforms - browser: { - globals: globals__default["default"].browser - }, - node: { - globals: globals__default["default"].node, - parserOptions: { - ecmaFeatures: { - globalReturn: true - } - } - }, - "shared-node-browser": { - globals: globals__default["default"]["shared-node-browser"] - }, - worker: { - globals: globals__default["default"].worker - }, - serviceworker: { - globals: globals__default["default"].serviceworker - }, - - // Frameworks - commonjs: { - globals: globals__default["default"].commonjs, - parserOptions: { - ecmaFeatures: { - globalReturn: true - } - } - }, - amd: { - globals: globals__default["default"].amd - }, - mocha: { - globals: globals__default["default"].mocha - }, - jasmine: { - globals: globals__default["default"].jasmine - }, - jest: { - globals: globals__default["default"].jest - }, - phantomjs: { - globals: globals__default["default"].phantomjs - }, - jquery: { - globals: globals__default["default"].jquery - }, - qunit: { - globals: globals__default["default"].qunit - }, - prototypejs: { - globals: globals__default["default"].prototypejs - }, - shelljs: { - globals: globals__default["default"].shelljs - }, - meteor: { - globals: globals__default["default"].meteor - }, - mongo: { - globals: globals__default["default"].mongo - }, - protractor: { - globals: globals__default["default"].protractor - }, - applescript: { - globals: globals__default["default"].applescript - }, - nashorn: { - globals: globals__default["default"].nashorn - }, - atomtest: { - globals: globals__default["default"].atomtest - }, - embertest: { - globals: globals__default["default"].embertest - }, - webextensions: { - globals: globals__default["default"].webextensions - }, - greasemonkey: { - globals: globals__default["default"].greasemonkey - } -})); - -/** - * @fileoverview Validates configs. - * @author Brandon Mills - */ - -const ajv = ajvOrig(); - -const ruleValidators = new WeakMap(); -const noop = Function.prototype; - -//------------------------------------------------------------------------------ -// Private -//------------------------------------------------------------------------------ -let validateSchema; -const severityMap = { - error: 2, - warn: 1, - off: 0 -}; - -const validated = new WeakSet(); - -// JSON schema that disallows passing any options -const noOptionsSchema = Object.freeze({ - type: "array", - minItems: 0, - maxItems: 0 -}); - -//----------------------------------------------------------------------------- -// Exports -//----------------------------------------------------------------------------- - -class ConfigValidator { - constructor({ builtInRules = new Map() } = {}) { - this.builtInRules = builtInRules; - } - - /** - * Gets a complete options schema for a rule. - * @param {Rule} rule A rule object - * @throws {TypeError} If `meta.schema` is specified but is not an array, object or `false`. - * @returns {Object|null} JSON Schema for the rule's options. - * `null` if rule wasn't passed or its `meta.schema` is `false`. - */ - getRuleOptionsSchema(rule) { - if (!rule) { - return null; - } - - if (!rule.meta) { - return { ...noOptionsSchema }; // default if `meta.schema` is not specified - } - - const schema = rule.meta.schema; - - if (typeof schema === "undefined") { - return { ...noOptionsSchema }; // default if `meta.schema` is not specified - } - - // `schema:false` is an allowed explicit opt-out of options validation for the rule - if (schema === false) { - return null; - } - - if (typeof schema !== "object" || schema === null) { - throw new TypeError("Rule's `meta.schema` must be an array or object"); - } - - // ESLint-specific array form needs to be converted into a valid JSON Schema definition - if (Array.isArray(schema)) { - if (schema.length) { - return { - type: "array", - items: schema, - minItems: 0, - maxItems: schema.length - }; - } - - // `schema:[]` is an explicit way to specify that the rule does not accept any options - return { ...noOptionsSchema }; - } - - // `schema:` is assumed to be a valid JSON Schema definition - return schema; - } - - /** - * Validates a rule's severity and returns the severity value. Throws an error if the severity is invalid. - * @param {options} options The given options for the rule. - * @returns {number|string} The rule's severity value - */ - validateRuleSeverity(options) { - const severity = Array.isArray(options) ? options[0] : options; - const normSeverity = typeof severity === "string" ? severityMap[severity.toLowerCase()] : severity; - - if (normSeverity === 0 || normSeverity === 1 || normSeverity === 2) { - return normSeverity; - } - - throw new Error(`\tSeverity should be one of the following: 0 = off, 1 = warn, 2 = error (you passed '${util__default["default"].inspect(severity).replace(/'/gu, "\"").replace(/\n/gu, "")}').\n`); - - } - - /** - * Validates the non-severity options passed to a rule, based on its schema. - * @param {{create: Function}} rule The rule to validate - * @param {Array} localOptions The options for the rule, excluding severity - * @returns {void} - */ - validateRuleSchema(rule, localOptions) { - if (!ruleValidators.has(rule)) { - try { - const schema = this.getRuleOptionsSchema(rule); - - if (schema) { - ruleValidators.set(rule, ajv.compile(schema)); - } - } catch (err) { - const errorWithCode = new Error(err.message, { cause: err }); - - errorWithCode.code = "ESLINT_INVALID_RULE_OPTIONS_SCHEMA"; - - throw errorWithCode; - } - } - - const validateRule = ruleValidators.get(rule); - - if (validateRule) { - validateRule(localOptions); - if (validateRule.errors) { - throw new Error(validateRule.errors.map( - error => `\tValue ${JSON.stringify(error.data)} ${error.message}.\n` - ).join("")); - } - } - } - - /** - * Validates a rule's options against its schema. - * @param {{create: Function}|null} rule The rule that the config is being validated for - * @param {string} ruleId The rule's unique name. - * @param {Array|number} options The given options for the rule. - * @param {string|null} source The name of the configuration source to report in any errors. If null or undefined, - * no source is prepended to the message. - * @returns {void} - */ - validateRuleOptions(rule, ruleId, options, source = null) { - try { - const severity = this.validateRuleSeverity(options); - - if (severity !== 0) { - this.validateRuleSchema(rule, Array.isArray(options) ? options.slice(1) : []); - } - } catch (err) { - let enhancedMessage = err.code === "ESLINT_INVALID_RULE_OPTIONS_SCHEMA" - ? `Error while processing options validation schema of rule '${ruleId}': ${err.message}` - : `Configuration for rule "${ruleId}" is invalid:\n${err.message}`; - - if (typeof source === "string") { - enhancedMessage = `${source}:\n\t${enhancedMessage}`; - } - - const enhancedError = new Error(enhancedMessage, { cause: err }); - - if (err.code) { - enhancedError.code = err.code; - } - - throw enhancedError; - } - } - - /** - * Validates an environment object - * @param {Object} environment The environment config object to validate. - * @param {string} source The name of the configuration source to report in any errors. - * @param {function(envId:string): Object} [getAdditionalEnv] A map from strings to loaded environments. - * @returns {void} - */ - validateEnvironment( - environment, - source, - getAdditionalEnv = noop - ) { - - // not having an environment is ok - if (!environment) { - return; - } - - Object.keys(environment).forEach(id => { - const env = getAdditionalEnv(id) || environments.get(id) || null; - - if (!env) { - const message = `${source}:\n\tEnvironment key "${id}" is unknown\n`; - - throw new Error(message); - } - }); - } - - /** - * Validates a rules config object - * @param {Object} rulesConfig The rules config object to validate. - * @param {string} source The name of the configuration source to report in any errors. - * @param {function(ruleId:string): Object} getAdditionalRule A map from strings to loaded rules - * @returns {void} - */ - validateRules( - rulesConfig, - source, - getAdditionalRule = noop - ) { - if (!rulesConfig) { - return; - } - - Object.keys(rulesConfig).forEach(id => { - const rule = getAdditionalRule(id) || this.builtInRules.get(id) || null; - - this.validateRuleOptions(rule, id, rulesConfig[id], source); - }); - } - - /** - * Validates a `globals` section of a config file - * @param {Object} globalsConfig The `globals` section - * @param {string|null} source The name of the configuration source to report in the event of an error. - * @returns {void} - */ - validateGlobals(globalsConfig, source = null) { - if (!globalsConfig) { - return; - } - - Object.entries(globalsConfig) - .forEach(([configuredGlobal, configuredValue]) => { - try { - normalizeConfigGlobal(configuredValue); - } catch (err) { - throw new Error(`ESLint configuration of global '${configuredGlobal}' in ${source} is invalid:\n${err.message}`); - } - }); - } - - /** - * Validate `processor` configuration. - * @param {string|undefined} processorName The processor name. - * @param {string} source The name of config file. - * @param {function(id:string): Processor} getProcessor The getter of defined processors. - * @returns {void} - */ - validateProcessor(processorName, source, getProcessor) { - if (processorName && !getProcessor(processorName)) { - throw new Error(`ESLint configuration of processor in '${source}' is invalid: '${processorName}' was not found.`); - } - } - - /** - * Formats an array of schema validation errors. - * @param {Array} errors An array of error messages to format. - * @returns {string} Formatted error message - */ - formatErrors(errors) { - return errors.map(error => { - if (error.keyword === "additionalProperties") { - const formattedPropertyPath = error.dataPath.length ? `${error.dataPath.slice(1)}.${error.params.additionalProperty}` : error.params.additionalProperty; - - return `Unexpected top-level property "${formattedPropertyPath}"`; - } - if (error.keyword === "type") { - const formattedField = error.dataPath.slice(1); - const formattedExpectedType = Array.isArray(error.schema) ? error.schema.join("/") : error.schema; - const formattedValue = JSON.stringify(error.data); - - return `Property "${formattedField}" is the wrong type (expected ${formattedExpectedType} but got \`${formattedValue}\`)`; - } - - const field = error.dataPath[0] === "." ? error.dataPath.slice(1) : error.dataPath; - - return `"${field}" ${error.message}. Value: ${JSON.stringify(error.data)}`; - }).map(message => `\t- ${message}.\n`).join(""); - } - - /** - * Validates the top level properties of the config object. - * @param {Object} config The config object to validate. - * @param {string} source The name of the configuration source to report in any errors. - * @returns {void} - */ - validateConfigSchema(config, source = null) { - validateSchema = validateSchema || ajv.compile(configSchema); - - if (!validateSchema(config)) { - throw new Error(`ESLint configuration in ${source} is invalid:\n${this.formatErrors(validateSchema.errors)}`); - } - - if (Object.hasOwnProperty.call(config, "ecmaFeatures")) { - emitDeprecationWarning(source, "ESLINT_LEGACY_ECMAFEATURES"); - } - } - - /** - * Validates an entire config object. - * @param {Object} config The config object to validate. - * @param {string} source The name of the configuration source to report in any errors. - * @param {function(ruleId:string): Object} [getAdditionalRule] A map from strings to loaded rules. - * @param {function(envId:string): Object} [getAdditionalEnv] A map from strings to loaded envs. - * @returns {void} - */ - validate(config, source, getAdditionalRule, getAdditionalEnv) { - this.validateConfigSchema(config, source); - this.validateRules(config.rules, source, getAdditionalRule); - this.validateEnvironment(config.env, source, getAdditionalEnv); - this.validateGlobals(config.globals, source); - - for (const override of config.overrides || []) { - this.validateRules(override.rules, source, getAdditionalRule); - this.validateEnvironment(override.env, source, getAdditionalEnv); - this.validateGlobals(config.globals, source); - } - } - - /** - * Validate config array object. - * @param {ConfigArray} configArray The config array to validate. - * @returns {void} - */ - validateConfigArray(configArray) { - const getPluginEnv = Map.prototype.get.bind(configArray.pluginEnvironments); - const getPluginProcessor = Map.prototype.get.bind(configArray.pluginProcessors); - const getPluginRule = Map.prototype.get.bind(configArray.pluginRules); - - // Validate. - for (const element of configArray) { - if (validated.has(element)) { - continue; - } - validated.add(element); - - this.validateEnvironment(element.env, element.name, getPluginEnv); - this.validateGlobals(element.globals, element.name); - this.validateProcessor(element.processor, element.name, getPluginProcessor); - this.validateRules(element.rules, element.name, getPluginRule); - } - } - -} - -/** - * @fileoverview Common helpers for naming of plugins, formatters and configs - */ - -const NAMESPACE_REGEX = /^@.*\//iu; - -/** - * Brings package name to correct format based on prefix - * @param {string} name The name of the package. - * @param {string} prefix Can be either "eslint-plugin", "eslint-config" or "eslint-formatter" - * @returns {string} Normalized name of the package - * @private - */ -function normalizePackageName(name, prefix) { - let normalizedName = name; - - /** - * On Windows, name can come in with Windows slashes instead of Unix slashes. - * Normalize to Unix first to avoid errors later on. - * https://github.com/eslint/eslint/issues/5644 - */ - if (normalizedName.includes("\\")) { - normalizedName = normalizedName.replace(/\\/gu, "/"); - } - - if (normalizedName.charAt(0) === "@") { - - /** - * it's a scoped package - * package name is the prefix, or just a username - */ - const scopedPackageShortcutRegex = new RegExp(`^(@[^/]+)(?:/(?:${prefix})?)?$`, "u"), - scopedPackageNameRegex = new RegExp(`^${prefix}(-|$)`, "u"); - - if (scopedPackageShortcutRegex.test(normalizedName)) { - normalizedName = normalizedName.replace(scopedPackageShortcutRegex, `$1/${prefix}`); - } else if (!scopedPackageNameRegex.test(normalizedName.split("/")[1])) { - - /** - * for scoped packages, insert the prefix after the first / unless - * the path is already @scope/eslint or @scope/eslint-xxx-yyy - */ - normalizedName = normalizedName.replace(/^@([^/]+)\/(.*)$/u, `@$1/${prefix}-$2`); - } - } else if (!normalizedName.startsWith(`${prefix}-`)) { - normalizedName = `${prefix}-${normalizedName}`; - } - - return normalizedName; -} - -/** - * Removes the prefix from a fullname. - * @param {string} fullname The term which may have the prefix. - * @param {string} prefix The prefix to remove. - * @returns {string} The term without prefix. - */ -function getShorthandName(fullname, prefix) { - if (fullname[0] === "@") { - let matchResult = new RegExp(`^(@[^/]+)/${prefix}$`, "u").exec(fullname); - - if (matchResult) { - return matchResult[1]; - } - - matchResult = new RegExp(`^(@[^/]+)/${prefix}-(.+)$`, "u").exec(fullname); - if (matchResult) { - return `${matchResult[1]}/${matchResult[2]}`; - } - } else if (fullname.startsWith(`${prefix}-`)) { - return fullname.slice(prefix.length + 1); - } - - return fullname; -} - -/** - * Gets the scope (namespace) of a term. - * @param {string} term The term which may have the namespace. - * @returns {string} The namespace of the term if it has one. - */ -function getNamespaceFromTerm(term) { - const match = term.match(NAMESPACE_REGEX); - - return match ? match[0] : ""; -} - -var naming = { - __proto__: null, - normalizePackageName: normalizePackageName, - getShorthandName: getShorthandName, - getNamespaceFromTerm: getNamespaceFromTerm -}; - -/** - * @fileoverview Package exports for @eslint/eslintrc - * @author Nicholas C. Zakas - */ - -//----------------------------------------------------------------------------- -// Exports -//----------------------------------------------------------------------------- - -const Legacy = { - environments, - - // shared - ConfigOps, - ConfigValidator, - naming -}; - -exports.Legacy = Legacy; -//# sourceMappingURL=eslintrc-universal.cjs.map diff --git a/tools/eslint/node_modules/@eslint/eslintrc/dist/eslintrc.cjs b/tools/eslint/node_modules/@eslint/eslintrc/dist/eslintrc.cjs deleted file mode 100644 index f3db9dfe5091f1..00000000000000 --- a/tools/eslint/node_modules/@eslint/eslintrc/dist/eslintrc.cjs +++ /dev/null @@ -1,4371 +0,0 @@ -'use strict'; - -Object.defineProperty(exports, '__esModule', { value: true }); - -var debugOrig = require('debug'); -var fs = require('fs'); -var importFresh = require('import-fresh'); -var Module = require('module'); -var path = require('path'); -var stripComments = require('strip-json-comments'); -var assert = require('assert'); -var ignore = require('ignore'); -var util = require('util'); -var minimatch = require('minimatch'); -var Ajv = require('ajv'); -var globals = require('globals'); -var os = require('os'); - -function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; } - -var debugOrig__default = /*#__PURE__*/_interopDefaultLegacy(debugOrig); -var fs__default = /*#__PURE__*/_interopDefaultLegacy(fs); -var importFresh__default = /*#__PURE__*/_interopDefaultLegacy(importFresh); -var Module__default = /*#__PURE__*/_interopDefaultLegacy(Module); -var path__default = /*#__PURE__*/_interopDefaultLegacy(path); -var stripComments__default = /*#__PURE__*/_interopDefaultLegacy(stripComments); -var assert__default = /*#__PURE__*/_interopDefaultLegacy(assert); -var ignore__default = /*#__PURE__*/_interopDefaultLegacy(ignore); -var util__default = /*#__PURE__*/_interopDefaultLegacy(util); -var minimatch__default = /*#__PURE__*/_interopDefaultLegacy(minimatch); -var Ajv__default = /*#__PURE__*/_interopDefaultLegacy(Ajv); -var globals__default = /*#__PURE__*/_interopDefaultLegacy(globals); -var os__default = /*#__PURE__*/_interopDefaultLegacy(os); - -/** - * @fileoverview `IgnorePattern` class. - * - * `IgnorePattern` class has the set of glob patterns and the base path. - * - * It provides two static methods. - * - * - `IgnorePattern.createDefaultIgnore(cwd)` - * Create the default predicate function. - * - `IgnorePattern.createIgnore(ignorePatterns)` - * Create the predicate function from multiple `IgnorePattern` objects. - * - * It provides two properties and a method. - * - * - `patterns` - * The glob patterns that ignore to lint. - * - `basePath` - * The base path of the glob patterns. If absolute paths existed in the - * glob patterns, those are handled as relative paths to the base path. - * - `getPatternsRelativeTo(basePath)` - * Get `patterns` as modified for a given base path. It modifies the - * absolute paths in the patterns as prepending the difference of two base - * paths. - * - * `ConfigArrayFactory` creates `IgnorePattern` objects when it processes - * `ignorePatterns` properties. - * - * @author Toru Nagashima - */ - -const debug$3 = debugOrig__default["default"]("eslintrc:ignore-pattern"); - -/** @typedef {ReturnType} Ignore */ - -//------------------------------------------------------------------------------ -// Helpers -//------------------------------------------------------------------------------ - -/** - * Get the path to the common ancestor directory of given paths. - * @param {string[]} sourcePaths The paths to calculate the common ancestor. - * @returns {string} The path to the common ancestor directory. - */ -function getCommonAncestorPath(sourcePaths) { - let result = sourcePaths[0]; - - for (let i = 1; i < sourcePaths.length; ++i) { - const a = result; - const b = sourcePaths[i]; - - // Set the shorter one (it's the common ancestor if one includes the other). - result = a.length < b.length ? a : b; - - // Set the common ancestor. - for (let j = 0, lastSepPos = 0; j < a.length && j < b.length; ++j) { - if (a[j] !== b[j]) { - result = a.slice(0, lastSepPos); - break; - } - if (a[j] === path__default["default"].sep) { - lastSepPos = j; - } - } - } - - let resolvedResult = result || path__default["default"].sep; - - // if Windows common ancestor is root of drive must have trailing slash to be absolute. - if (resolvedResult && resolvedResult.endsWith(":") && process.platform === "win32") { - resolvedResult += path__default["default"].sep; - } - return resolvedResult; -} - -/** - * Make relative path. - * @param {string} from The source path to get relative path. - * @param {string} to The destination path to get relative path. - * @returns {string} The relative path. - */ -function relative(from, to) { - const relPath = path__default["default"].relative(from, to); - - if (path__default["default"].sep === "/") { - return relPath; - } - return relPath.split(path__default["default"].sep).join("/"); -} - -/** - * Get the trailing slash if existed. - * @param {string} filePath The path to check. - * @returns {string} The trailing slash if existed. - */ -function dirSuffix(filePath) { - const isDir = ( - filePath.endsWith(path__default["default"].sep) || - (process.platform === "win32" && filePath.endsWith("/")) - ); - - return isDir ? "/" : ""; -} - -const DefaultPatterns = Object.freeze(["/**/node_modules/*"]); -const DotPatterns = Object.freeze([".*", "!.eslintrc.*", "!../"]); - -//------------------------------------------------------------------------------ -// Public -//------------------------------------------------------------------------------ - -class IgnorePattern { - - /** - * The default patterns. - * @type {string[]} - */ - static get DefaultPatterns() { - return DefaultPatterns; - } - - /** - * Create the default predicate function. - * @param {string} cwd The current working directory. - * @returns {((filePath:string, dot:boolean) => boolean) & {basePath:string; patterns:string[]}} - * The preficate function. - * The first argument is an absolute path that is checked. - * The second argument is the flag to not ignore dotfiles. - * If the predicate function returned `true`, it means the path should be ignored. - */ - static createDefaultIgnore(cwd) { - return this.createIgnore([new IgnorePattern(DefaultPatterns, cwd)]); - } - - /** - * Create the predicate function from multiple `IgnorePattern` objects. - * @param {IgnorePattern[]} ignorePatterns The list of ignore patterns. - * @returns {((filePath:string, dot?:boolean) => boolean) & {basePath:string; patterns:string[]}} - * The preficate function. - * The first argument is an absolute path that is checked. - * The second argument is the flag to not ignore dotfiles. - * If the predicate function returned `true`, it means the path should be ignored. - */ - static createIgnore(ignorePatterns) { - debug$3("Create with: %o", ignorePatterns); - - const basePath = getCommonAncestorPath(ignorePatterns.map(p => p.basePath)); - const patterns = [].concat( - ...ignorePatterns.map(p => p.getPatternsRelativeTo(basePath)) - ); - const ig = ignore__default["default"]({ allowRelativePaths: true }).add([...DotPatterns, ...patterns]); - const dotIg = ignore__default["default"]({ allowRelativePaths: true }).add(patterns); - - debug$3(" processed: %o", { basePath, patterns }); - - return Object.assign( - (filePath, dot = false) => { - assert__default["default"](path__default["default"].isAbsolute(filePath), "'filePath' should be an absolute path."); - const relPathRaw = relative(basePath, filePath); - const relPath = relPathRaw && (relPathRaw + dirSuffix(filePath)); - const adoptedIg = dot ? dotIg : ig; - const result = relPath !== "" && adoptedIg.ignores(relPath); - - debug$3("Check", { filePath, dot, relativePath: relPath, result }); - return result; - }, - { basePath, patterns } - ); - } - - /** - * Initialize a new `IgnorePattern` instance. - * @param {string[]} patterns The glob patterns that ignore to lint. - * @param {string} basePath The base path of `patterns`. - */ - constructor(patterns, basePath) { - assert__default["default"](path__default["default"].isAbsolute(basePath), "'basePath' should be an absolute path."); - - /** - * The glob patterns that ignore to lint. - * @type {string[]} - */ - this.patterns = patterns; - - /** - * The base path of `patterns`. - * @type {string} - */ - this.basePath = basePath; - - /** - * If `true` then patterns which don't start with `/` will match the paths to the outside of `basePath`. Defaults to `false`. - * - * It's set `true` for `.eslintignore`, `package.json`, and `--ignore-path` for backward compatibility. - * It's `false` as-is for `ignorePatterns` property in config files. - * @type {boolean} - */ - this.loose = false; - } - - /** - * Get `patterns` as modified for a given base path. It modifies the - * absolute paths in the patterns as prepending the difference of two base - * paths. - * @param {string} newBasePath The base path. - * @returns {string[]} Modifired patterns. - */ - getPatternsRelativeTo(newBasePath) { - assert__default["default"](path__default["default"].isAbsolute(newBasePath), "'newBasePath' should be an absolute path."); - const { basePath, loose, patterns } = this; - - if (newBasePath === basePath) { - return patterns; - } - const prefix = `/${relative(newBasePath, basePath)}`; - - return patterns.map(pattern => { - const negative = pattern.startsWith("!"); - const head = negative ? "!" : ""; - const body = negative ? pattern.slice(1) : pattern; - - if (body.startsWith("/") || body.startsWith("../")) { - return `${head}${prefix}${body}`; - } - return loose ? pattern : `${head}${prefix}/**/${body}`; - }); - } -} - -/** - * @fileoverview `ExtractedConfig` class. - * - * `ExtractedConfig` class expresses a final configuration for a specific file. - * - * It provides one method. - * - * - `toCompatibleObjectAsConfigFileContent()` - * Convert this configuration to the compatible object as the content of - * config files. It converts the loaded parser and plugins to strings. - * `CLIEngine#getConfigForFile(filePath)` method uses this method. - * - * `ConfigArray#extractConfig(filePath)` creates a `ExtractedConfig` instance. - * - * @author Toru Nagashima - */ - -// For VSCode intellisense -/** @typedef {import("../../shared/types").ConfigData} ConfigData */ -/** @typedef {import("../../shared/types").GlobalConf} GlobalConf */ -/** @typedef {import("../../shared/types").SeverityConf} SeverityConf */ -/** @typedef {import("./config-dependency").DependentParser} DependentParser */ -/** @typedef {import("./config-dependency").DependentPlugin} DependentPlugin */ - -/** - * Check if `xs` starts with `ys`. - * @template T - * @param {T[]} xs The array to check. - * @param {T[]} ys The array that may be the first part of `xs`. - * @returns {boolean} `true` if `xs` starts with `ys`. - */ -function startsWith(xs, ys) { - return xs.length >= ys.length && ys.every((y, i) => y === xs[i]); -} - -/** - * The class for extracted config data. - */ -class ExtractedConfig { - constructor() { - - /** - * The config name what `noInlineConfig` setting came from. - * @type {string} - */ - this.configNameOfNoInlineConfig = ""; - - /** - * Environments. - * @type {Record} - */ - this.env = {}; - - /** - * Global variables. - * @type {Record} - */ - this.globals = {}; - - /** - * The glob patterns that ignore to lint. - * @type {(((filePath:string, dot?:boolean) => boolean) & { basePath:string; patterns:string[] }) | undefined} - */ - this.ignores = void 0; - - /** - * The flag that disables directive comments. - * @type {boolean|undefined} - */ - this.noInlineConfig = void 0; - - /** - * Parser definition. - * @type {DependentParser|null} - */ - this.parser = null; - - /** - * Options for the parser. - * @type {Object} - */ - this.parserOptions = {}; - - /** - * Plugin definitions. - * @type {Record} - */ - this.plugins = {}; - - /** - * Processor ID. - * @type {string|null} - */ - this.processor = null; - - /** - * The flag that reports unused `eslint-disable` directive comments. - * @type {boolean|undefined} - */ - this.reportUnusedDisableDirectives = void 0; - - /** - * Rule settings. - * @type {Record} - */ - this.rules = {}; - - /** - * Shared settings. - * @type {Object} - */ - this.settings = {}; - } - - /** - * Convert this config to the compatible object as a config file content. - * @returns {ConfigData} The converted object. - */ - toCompatibleObjectAsConfigFileContent() { - const { - /* eslint-disable no-unused-vars */ - configNameOfNoInlineConfig: _ignore1, - processor: _ignore2, - /* eslint-enable no-unused-vars */ - ignores, - ...config - } = this; - - config.parser = config.parser && config.parser.filePath; - config.plugins = Object.keys(config.plugins).filter(Boolean).reverse(); - config.ignorePatterns = ignores ? ignores.patterns : []; - - // Strip the default patterns from `ignorePatterns`. - if (startsWith(config.ignorePatterns, IgnorePattern.DefaultPatterns)) { - config.ignorePatterns = - config.ignorePatterns.slice(IgnorePattern.DefaultPatterns.length); - } - - return config; - } -} - -/** - * @fileoverview `ConfigArray` class. - * - * `ConfigArray` class expresses the full of a configuration. It has the entry - * config file, base config files that were extended, loaded parsers, and loaded - * plugins. - * - * `ConfigArray` class provides three properties and two methods. - * - * - `pluginEnvironments` - * - `pluginProcessors` - * - `pluginRules` - * The `Map` objects that contain the members of all plugins that this - * config array contains. Those map objects don't have mutation methods. - * Those keys are the member ID such as `pluginId/memberName`. - * - `isRoot()` - * If `true` then this configuration has `root:true` property. - * - `extractConfig(filePath)` - * Extract the final configuration for a given file. This means merging - * every config array element which that `criteria` property matched. The - * `filePath` argument must be an absolute path. - * - * `ConfigArrayFactory` provides the loading logic of config files. - * - * @author Toru Nagashima - */ - -//------------------------------------------------------------------------------ -// Helpers -//------------------------------------------------------------------------------ - -// Define types for VSCode IntelliSense. -/** @typedef {import("../../shared/types").Environment} Environment */ -/** @typedef {import("../../shared/types").GlobalConf} GlobalConf */ -/** @typedef {import("../../shared/types").RuleConf} RuleConf */ -/** @typedef {import("../../shared/types").Rule} Rule */ -/** @typedef {import("../../shared/types").Plugin} Plugin */ -/** @typedef {import("../../shared/types").Processor} Processor */ -/** @typedef {import("./config-dependency").DependentParser} DependentParser */ -/** @typedef {import("./config-dependency").DependentPlugin} DependentPlugin */ -/** @typedef {import("./override-tester")["OverrideTester"]} OverrideTester */ - -/** - * @typedef {Object} ConfigArrayElement - * @property {string} name The name of this config element. - * @property {string} filePath The path to the source file of this config element. - * @property {InstanceType|null} criteria The tester for the `files` and `excludedFiles` of this config element. - * @property {Record|undefined} env The environment settings. - * @property {Record|undefined} globals The global variable settings. - * @property {IgnorePattern|undefined} ignorePattern The ignore patterns. - * @property {boolean|undefined} noInlineConfig The flag that disables directive comments. - * @property {DependentParser|undefined} parser The parser loader. - * @property {Object|undefined} parserOptions The parser options. - * @property {Record|undefined} plugins The plugin loaders. - * @property {string|undefined} processor The processor name to refer plugin's processor. - * @property {boolean|undefined} reportUnusedDisableDirectives The flag to report unused `eslint-disable` comments. - * @property {boolean|undefined} root The flag to express root. - * @property {Record|undefined} rules The rule settings - * @property {Object|undefined} settings The shared settings. - * @property {"config" | "ignore" | "implicit-processor"} type The element type. - */ - -/** - * @typedef {Object} ConfigArrayInternalSlots - * @property {Map} cache The cache to extract configs. - * @property {ReadonlyMap|null} envMap The map from environment ID to environment definition. - * @property {ReadonlyMap|null} processorMap The map from processor ID to environment definition. - * @property {ReadonlyMap|null} ruleMap The map from rule ID to rule definition. - */ - -/** @type {WeakMap} */ -const internalSlotsMap$2 = new class extends WeakMap { - get(key) { - let value = super.get(key); - - if (!value) { - value = { - cache: new Map(), - envMap: null, - processorMap: null, - ruleMap: null - }; - super.set(key, value); - } - - return value; - } -}(); - -/** - * Get the indices which are matched to a given file. - * @param {ConfigArrayElement[]} elements The elements. - * @param {string} filePath The path to a target file. - * @returns {number[]} The indices. - */ -function getMatchedIndices(elements, filePath) { - const indices = []; - - for (let i = elements.length - 1; i >= 0; --i) { - const element = elements[i]; - - if (!element.criteria || (filePath && element.criteria.test(filePath))) { - indices.push(i); - } - } - - return indices; -} - -/** - * Check if a value is a non-null object. - * @param {any} x The value to check. - * @returns {boolean} `true` if the value is a non-null object. - */ -function isNonNullObject(x) { - return typeof x === "object" && x !== null; -} - -/** - * Merge two objects. - * - * Assign every property values of `y` to `x` if `x` doesn't have the property. - * If `x`'s property value is an object, it does recursive. - * @param {Object} target The destination to merge - * @param {Object|undefined} source The source to merge. - * @returns {void} - */ -function mergeWithoutOverwrite(target, source) { - if (!isNonNullObject(source)) { - return; - } - - for (const key of Object.keys(source)) { - if (key === "__proto__") { - continue; - } - - if (isNonNullObject(target[key])) { - mergeWithoutOverwrite(target[key], source[key]); - } else if (target[key] === void 0) { - if (isNonNullObject(source[key])) { - target[key] = Array.isArray(source[key]) ? [] : {}; - mergeWithoutOverwrite(target[key], source[key]); - } else if (source[key] !== void 0) { - target[key] = source[key]; - } - } - } -} - -/** - * The error for plugin conflicts. - */ -class PluginConflictError extends Error { - - /** - * Initialize this error object. - * @param {string} pluginId The plugin ID. - * @param {{filePath:string, importerName:string}[]} plugins The resolved plugins. - */ - constructor(pluginId, plugins) { - super(`Plugin "${pluginId}" was conflicted between ${plugins.map(p => `"${p.importerName}"`).join(" and ")}.`); - this.messageTemplate = "plugin-conflict"; - this.messageData = { pluginId, plugins }; - } -} - -/** - * Merge plugins. - * `target`'s definition is prior to `source`'s. - * @param {Record} target The destination to merge - * @param {Record|undefined} source The source to merge. - * @returns {void} - */ -function mergePlugins(target, source) { - if (!isNonNullObject(source)) { - return; - } - - for (const key of Object.keys(source)) { - if (key === "__proto__") { - continue; - } - const targetValue = target[key]; - const sourceValue = source[key]; - - // Adopt the plugin which was found at first. - if (targetValue === void 0) { - if (sourceValue.error) { - throw sourceValue.error; - } - target[key] = sourceValue; - } else if (sourceValue.filePath !== targetValue.filePath) { - throw new PluginConflictError(key, [ - { - filePath: targetValue.filePath, - importerName: targetValue.importerName - }, - { - filePath: sourceValue.filePath, - importerName: sourceValue.importerName - } - ]); - } - } -} - -/** - * Merge rule configs. - * `target`'s definition is prior to `source`'s. - * @param {Record} target The destination to merge - * @param {Record|undefined} source The source to merge. - * @returns {void} - */ -function mergeRuleConfigs(target, source) { - if (!isNonNullObject(source)) { - return; - } - - for (const key of Object.keys(source)) { - if (key === "__proto__") { - continue; - } - const targetDef = target[key]; - const sourceDef = source[key]; - - // Adopt the rule config which was found at first. - if (targetDef === void 0) { - if (Array.isArray(sourceDef)) { - target[key] = [...sourceDef]; - } else { - target[key] = [sourceDef]; - } - - /* - * If the first found rule config is severity only and the current rule - * config has options, merge the severity and the options. - */ - } else if ( - targetDef.length === 1 && - Array.isArray(sourceDef) && - sourceDef.length >= 2 - ) { - targetDef.push(...sourceDef.slice(1)); - } - } -} - -/** - * Create the extracted config. - * @param {ConfigArray} instance The config elements. - * @param {number[]} indices The indices to use. - * @returns {ExtractedConfig} The extracted config. - */ -function createConfig(instance, indices) { - const config = new ExtractedConfig(); - const ignorePatterns = []; - - // Merge elements. - for (const index of indices) { - const element = instance[index]; - - // Adopt the parser which was found at first. - if (!config.parser && element.parser) { - if (element.parser.error) { - throw element.parser.error; - } - config.parser = element.parser; - } - - // Adopt the processor which was found at first. - if (!config.processor && element.processor) { - config.processor = element.processor; - } - - // Adopt the noInlineConfig which was found at first. - if (config.noInlineConfig === void 0 && element.noInlineConfig !== void 0) { - config.noInlineConfig = element.noInlineConfig; - config.configNameOfNoInlineConfig = element.name; - } - - // Adopt the reportUnusedDisableDirectives which was found at first. - if (config.reportUnusedDisableDirectives === void 0 && element.reportUnusedDisableDirectives !== void 0) { - config.reportUnusedDisableDirectives = element.reportUnusedDisableDirectives; - } - - // Collect ignorePatterns - if (element.ignorePattern) { - ignorePatterns.push(element.ignorePattern); - } - - // Merge others. - mergeWithoutOverwrite(config.env, element.env); - mergeWithoutOverwrite(config.globals, element.globals); - mergeWithoutOverwrite(config.parserOptions, element.parserOptions); - mergeWithoutOverwrite(config.settings, element.settings); - mergePlugins(config.plugins, element.plugins); - mergeRuleConfigs(config.rules, element.rules); - } - - // Create the predicate function for ignore patterns. - if (ignorePatterns.length > 0) { - config.ignores = IgnorePattern.createIgnore(ignorePatterns.reverse()); - } - - return config; -} - -/** - * Collect definitions. - * @template T, U - * @param {string} pluginId The plugin ID for prefix. - * @param {Record} defs The definitions to collect. - * @param {Map} map The map to output. - * @returns {void} - */ -function collect(pluginId, defs, map) { - if (defs) { - const prefix = pluginId && `${pluginId}/`; - - for (const [key, value] of Object.entries(defs)) { - map.set(`${prefix}${key}`, value); - } - } -} - -/** - * Delete the mutation methods from a given map. - * @param {Map} map The map object to delete. - * @returns {void} - */ -function deleteMutationMethods(map) { - Object.defineProperties(map, { - clear: { configurable: true, value: void 0 }, - delete: { configurable: true, value: void 0 }, - set: { configurable: true, value: void 0 } - }); -} - -/** - * Create `envMap`, `processorMap`, `ruleMap` with the plugins in the config array. - * @param {ConfigArrayElement[]} elements The config elements. - * @param {ConfigArrayInternalSlots} slots The internal slots. - * @returns {void} - */ -function initPluginMemberMaps(elements, slots) { - const processed = new Set(); - - slots.envMap = new Map(); - slots.processorMap = new Map(); - slots.ruleMap = new Map(); - - for (const element of elements) { - if (!element.plugins) { - continue; - } - - for (const [pluginId, value] of Object.entries(element.plugins)) { - const plugin = value.definition; - - if (!plugin || processed.has(pluginId)) { - continue; - } - processed.add(pluginId); - - collect(pluginId, plugin.environments, slots.envMap); - collect(pluginId, plugin.processors, slots.processorMap); - collect(pluginId, plugin.rules, slots.ruleMap); - } - } - - deleteMutationMethods(slots.envMap); - deleteMutationMethods(slots.processorMap); - deleteMutationMethods(slots.ruleMap); -} - -/** - * Create `envMap`, `processorMap`, `ruleMap` with the plugins in the config array. - * @param {ConfigArray} instance The config elements. - * @returns {ConfigArrayInternalSlots} The extracted config. - */ -function ensurePluginMemberMaps(instance) { - const slots = internalSlotsMap$2.get(instance); - - if (!slots.ruleMap) { - initPluginMemberMaps(instance, slots); - } - - return slots; -} - -//------------------------------------------------------------------------------ -// Public Interface -//------------------------------------------------------------------------------ - -/** - * The Config Array. - * - * `ConfigArray` instance contains all settings, parsers, and plugins. - * You need to call `ConfigArray#extractConfig(filePath)` method in order to - * extract, merge and get only the config data which is related to an arbitrary - * file. - * @extends {Array} - */ -class ConfigArray extends Array { - - /** - * Get the plugin environments. - * The returned map cannot be mutated. - * @type {ReadonlyMap} The plugin environments. - */ - get pluginEnvironments() { - return ensurePluginMemberMaps(this).envMap; - } - - /** - * Get the plugin processors. - * The returned map cannot be mutated. - * @type {ReadonlyMap} The plugin processors. - */ - get pluginProcessors() { - return ensurePluginMemberMaps(this).processorMap; - } - - /** - * Get the plugin rules. - * The returned map cannot be mutated. - * @returns {ReadonlyMap} The plugin rules. - */ - get pluginRules() { - return ensurePluginMemberMaps(this).ruleMap; - } - - /** - * Check if this config has `root` flag. - * @returns {boolean} `true` if this config array is root. - */ - isRoot() { - for (let i = this.length - 1; i >= 0; --i) { - const root = this[i].root; - - if (typeof root === "boolean") { - return root; - } - } - return false; - } - - /** - * Extract the config data which is related to a given file. - * @param {string} filePath The absolute path to the target file. - * @returns {ExtractedConfig} The extracted config data. - */ - extractConfig(filePath) { - const { cache } = internalSlotsMap$2.get(this); - const indices = getMatchedIndices(this, filePath); - const cacheKey = indices.join(","); - - if (!cache.has(cacheKey)) { - cache.set(cacheKey, createConfig(this, indices)); - } - - return cache.get(cacheKey); - } - - /** - * Check if a given path is an additional lint target. - * @param {string} filePath The absolute path to the target file. - * @returns {boolean} `true` if the file is an additional lint target. - */ - isAdditionalTargetPath(filePath) { - for (const { criteria, type } of this) { - if ( - type === "config" && - criteria && - !criteria.endsWithWildcard && - criteria.test(filePath) - ) { - return true; - } - } - return false; - } -} - -/** - * Get the used extracted configs. - * CLIEngine will use this method to collect used deprecated rules. - * @param {ConfigArray} instance The config array object to get. - * @returns {ExtractedConfig[]} The used extracted configs. - * @private - */ -function getUsedExtractedConfigs(instance) { - const { cache } = internalSlotsMap$2.get(instance); - - return Array.from(cache.values()); -} - -/** - * @fileoverview `ConfigDependency` class. - * - * `ConfigDependency` class expresses a loaded parser or plugin. - * - * If the parser or plugin was loaded successfully, it has `definition` property - * and `filePath` property. Otherwise, it has `error` property. - * - * When `JSON.stringify()` converted a `ConfigDependency` object to a JSON, it - * omits `definition` property. - * - * `ConfigArrayFactory` creates `ConfigDependency` objects when it loads parsers - * or plugins. - * - * @author Toru Nagashima - */ - -/** - * The class is to store parsers or plugins. - * This class hides the loaded object from `JSON.stringify()` and `console.log`. - * @template T - */ -class ConfigDependency { - - /** - * Initialize this instance. - * @param {Object} data The dependency data. - * @param {T} [data.definition] The dependency if the loading succeeded. - * @param {T} [data.original] The original, non-normalized dependency if the loading succeeded. - * @param {Error} [data.error] The error object if the loading failed. - * @param {string} [data.filePath] The actual path to the dependency if the loading succeeded. - * @param {string} data.id The ID of this dependency. - * @param {string} data.importerName The name of the config file which loads this dependency. - * @param {string} data.importerPath The path to the config file which loads this dependency. - */ - constructor({ - definition = null, - original = null, - error = null, - filePath = null, - id, - importerName, - importerPath - }) { - - /** - * The loaded dependency if the loading succeeded. - * @type {T|null} - */ - this.definition = definition; - - /** - * The original dependency as loaded directly from disk if the loading succeeded. - * @type {T|null} - */ - this.original = original; - - /** - * The error object if the loading failed. - * @type {Error|null} - */ - this.error = error; - - /** - * The loaded dependency if the loading succeeded. - * @type {string|null} - */ - this.filePath = filePath; - - /** - * The ID of this dependency. - * @type {string} - */ - this.id = id; - - /** - * The name of the config file which loads this dependency. - * @type {string} - */ - this.importerName = importerName; - - /** - * The path to the config file which loads this dependency. - * @type {string} - */ - this.importerPath = importerPath; - } - - // eslint-disable-next-line jsdoc/require-description - /** - * @returns {Object} a JSON compatible object. - */ - toJSON() { - const obj = this[util__default["default"].inspect.custom](); - - // Display `error.message` (`Error#message` is unenumerable). - if (obj.error instanceof Error) { - obj.error = { ...obj.error, message: obj.error.message }; - } - - return obj; - } - - // eslint-disable-next-line jsdoc/require-description - /** - * @returns {Object} an object to display by `console.log()`. - */ - [util__default["default"].inspect.custom]() { - const { - definition: _ignore1, // eslint-disable-line no-unused-vars - original: _ignore2, // eslint-disable-line no-unused-vars - ...obj - } = this; - - return obj; - } -} - -/** - * @fileoverview `OverrideTester` class. - * - * `OverrideTester` class handles `files` property and `excludedFiles` property - * of `overrides` config. - * - * It provides one method. - * - * - `test(filePath)` - * Test if a file path matches the pair of `files` property and - * `excludedFiles` property. The `filePath` argument must be an absolute - * path. - * - * `ConfigArrayFactory` creates `OverrideTester` objects when it processes - * `overrides` properties. - * - * @author Toru Nagashima - */ - -const { Minimatch } = minimatch__default["default"]; - -const minimatchOpts = { dot: true, matchBase: true }; - -/** - * @typedef {Object} Pattern - * @property {InstanceType[] | null} includes The positive matchers. - * @property {InstanceType[] | null} excludes The negative matchers. - */ - -/** - * Normalize a given pattern to an array. - * @param {string|string[]|undefined} patterns A glob pattern or an array of glob patterns. - * @returns {string[]|null} Normalized patterns. - * @private - */ -function normalizePatterns(patterns) { - if (Array.isArray(patterns)) { - return patterns.filter(Boolean); - } - if (typeof patterns === "string" && patterns) { - return [patterns]; - } - return []; -} - -/** - * Create the matchers of given patterns. - * @param {string[]} patterns The patterns. - * @returns {InstanceType[] | null} The matchers. - */ -function toMatcher(patterns) { - if (patterns.length === 0) { - return null; - } - return patterns.map(pattern => { - if (/^\.[/\\]/u.test(pattern)) { - return new Minimatch( - pattern.slice(2), - - // `./*.js` should not match with `subdir/foo.js` - { ...minimatchOpts, matchBase: false } - ); - } - return new Minimatch(pattern, minimatchOpts); - }); -} - -/** - * Convert a given matcher to string. - * @param {Pattern} matchers The matchers. - * @returns {string} The string expression of the matcher. - */ -function patternToJson({ includes, excludes }) { - return { - includes: includes && includes.map(m => m.pattern), - excludes: excludes && excludes.map(m => m.pattern) - }; -} - -/** - * The class to test given paths are matched by the patterns. - */ -class OverrideTester { - - /** - * Create a tester with given criteria. - * If there are no criteria, returns `null`. - * @param {string|string[]} files The glob patterns for included files. - * @param {string|string[]} excludedFiles The glob patterns for excluded files. - * @param {string} basePath The path to the base directory to test paths. - * @returns {OverrideTester|null} The created instance or `null`. - */ - static create(files, excludedFiles, basePath) { - const includePatterns = normalizePatterns(files); - const excludePatterns = normalizePatterns(excludedFiles); - let endsWithWildcard = false; - - if (includePatterns.length === 0) { - return null; - } - - // Rejects absolute paths or relative paths to parents. - for (const pattern of includePatterns) { - if (path__default["default"].isAbsolute(pattern) || pattern.includes("..")) { - throw new Error(`Invalid override pattern (expected relative path not containing '..'): ${pattern}`); - } - if (pattern.endsWith("*")) { - endsWithWildcard = true; - } - } - for (const pattern of excludePatterns) { - if (path__default["default"].isAbsolute(pattern) || pattern.includes("..")) { - throw new Error(`Invalid override pattern (expected relative path not containing '..'): ${pattern}`); - } - } - - const includes = toMatcher(includePatterns); - const excludes = toMatcher(excludePatterns); - - return new OverrideTester( - [{ includes, excludes }], - basePath, - endsWithWildcard - ); - } - - /** - * Combine two testers by logical and. - * If either of the testers was `null`, returns the other tester. - * The `basePath` property of the two must be the same value. - * @param {OverrideTester|null} a A tester. - * @param {OverrideTester|null} b Another tester. - * @returns {OverrideTester|null} Combined tester. - */ - static and(a, b) { - if (!b) { - return a && new OverrideTester( - a.patterns, - a.basePath, - a.endsWithWildcard - ); - } - if (!a) { - return new OverrideTester( - b.patterns, - b.basePath, - b.endsWithWildcard - ); - } - - assert__default["default"].strictEqual(a.basePath, b.basePath); - return new OverrideTester( - a.patterns.concat(b.patterns), - a.basePath, - a.endsWithWildcard || b.endsWithWildcard - ); - } - - /** - * Initialize this instance. - * @param {Pattern[]} patterns The matchers. - * @param {string} basePath The base path. - * @param {boolean} endsWithWildcard If `true` then a pattern ends with `*`. - */ - constructor(patterns, basePath, endsWithWildcard = false) { - - /** @type {Pattern[]} */ - this.patterns = patterns; - - /** @type {string} */ - this.basePath = basePath; - - /** @type {boolean} */ - this.endsWithWildcard = endsWithWildcard; - } - - /** - * Test if a given path is matched or not. - * @param {string} filePath The absolute path to the target file. - * @returns {boolean} `true` if the path was matched. - */ - test(filePath) { - if (typeof filePath !== "string" || !path__default["default"].isAbsolute(filePath)) { - throw new Error(`'filePath' should be an absolute path, but got ${filePath}.`); - } - const relativePath = path__default["default"].relative(this.basePath, filePath); - - return this.patterns.every(({ includes, excludes }) => ( - (!includes || includes.some(m => m.match(relativePath))) && - (!excludes || !excludes.some(m => m.match(relativePath))) - )); - } - - // eslint-disable-next-line jsdoc/require-description - /** - * @returns {Object} a JSON compatible object. - */ - toJSON() { - if (this.patterns.length === 1) { - return { - ...patternToJson(this.patterns[0]), - basePath: this.basePath - }; - } - return { - AND: this.patterns.map(patternToJson), - basePath: this.basePath - }; - } - - // eslint-disable-next-line jsdoc/require-description - /** - * @returns {Object} an object to display by `console.log()`. - */ - [util__default["default"].inspect.custom]() { - return this.toJSON(); - } -} - -/** - * @fileoverview `ConfigArray` class. - * @author Toru Nagashima - */ - -/** - * @fileoverview Config file operations. This file must be usable in the browser, - * so no Node-specific code can be here. - * @author Nicholas C. Zakas - */ - -//------------------------------------------------------------------------------ -// Private -//------------------------------------------------------------------------------ - -const RULE_SEVERITY_STRINGS = ["off", "warn", "error"], - RULE_SEVERITY = RULE_SEVERITY_STRINGS.reduce((map, value, index) => { - map[value] = index; - return map; - }, {}), - VALID_SEVERITIES = [0, 1, 2, "off", "warn", "error"]; - -//------------------------------------------------------------------------------ -// Public Interface -//------------------------------------------------------------------------------ - -/** - * Normalizes the severity value of a rule's configuration to a number - * @param {(number|string|[number, ...*]|[string, ...*])} ruleConfig A rule's configuration value, generally - * received from the user. A valid config value is either 0, 1, 2, the string "off" (treated the same as 0), - * the string "warn" (treated the same as 1), the string "error" (treated the same as 2), or an array - * whose first element is one of the above values. Strings are matched case-insensitively. - * @returns {(0|1|2)} The numeric severity value if the config value was valid, otherwise 0. - */ -function getRuleSeverity(ruleConfig) { - const severityValue = Array.isArray(ruleConfig) ? ruleConfig[0] : ruleConfig; - - if (severityValue === 0 || severityValue === 1 || severityValue === 2) { - return severityValue; - } - - if (typeof severityValue === "string") { - return RULE_SEVERITY[severityValue.toLowerCase()] || 0; - } - - return 0; -} - -/** - * Converts old-style severity settings (0, 1, 2) into new-style - * severity settings (off, warn, error) for all rules. Assumption is that severity - * values have already been validated as correct. - * @param {Object} config The config object to normalize. - * @returns {void} - */ -function normalizeToStrings(config) { - - if (config.rules) { - Object.keys(config.rules).forEach(ruleId => { - const ruleConfig = config.rules[ruleId]; - - if (typeof ruleConfig === "number") { - config.rules[ruleId] = RULE_SEVERITY_STRINGS[ruleConfig] || RULE_SEVERITY_STRINGS[0]; - } else if (Array.isArray(ruleConfig) && typeof ruleConfig[0] === "number") { - ruleConfig[0] = RULE_SEVERITY_STRINGS[ruleConfig[0]] || RULE_SEVERITY_STRINGS[0]; - } - }); - } -} - -/** - * Determines if the severity for the given rule configuration represents an error. - * @param {int|string|Array} ruleConfig The configuration for an individual rule. - * @returns {boolean} True if the rule represents an error, false if not. - */ -function isErrorSeverity(ruleConfig) { - return getRuleSeverity(ruleConfig) === 2; -} - -/** - * Checks whether a given config has valid severity or not. - * @param {number|string|Array} ruleConfig The configuration for an individual rule. - * @returns {boolean} `true` if the configuration has valid severity. - */ -function isValidSeverity(ruleConfig) { - let severity = Array.isArray(ruleConfig) ? ruleConfig[0] : ruleConfig; - - if (typeof severity === "string") { - severity = severity.toLowerCase(); - } - return VALID_SEVERITIES.indexOf(severity) !== -1; -} - -/** - * Checks whether every rule of a given config has valid severity or not. - * @param {Object} config The configuration for rules. - * @returns {boolean} `true` if the configuration has valid severity. - */ -function isEverySeverityValid(config) { - return Object.keys(config).every(ruleId => isValidSeverity(config[ruleId])); -} - -/** - * Normalizes a value for a global in a config - * @param {(boolean|string|null)} configuredValue The value given for a global in configuration or in - * a global directive comment - * @returns {("readable"|"writeable"|"off")} The value normalized as a string - * @throws Error if global value is invalid - */ -function normalizeConfigGlobal(configuredValue) { - switch (configuredValue) { - case "off": - return "off"; - - case true: - case "true": - case "writeable": - case "writable": - return "writable"; - - case null: - case false: - case "false": - case "readable": - case "readonly": - return "readonly"; - - default: - throw new Error(`'${configuredValue}' is not a valid configuration for a global (use 'readonly', 'writable', or 'off')`); - } -} - -var ConfigOps = { - __proto__: null, - getRuleSeverity: getRuleSeverity, - normalizeToStrings: normalizeToStrings, - isErrorSeverity: isErrorSeverity, - isValidSeverity: isValidSeverity, - isEverySeverityValid: isEverySeverityValid, - normalizeConfigGlobal: normalizeConfigGlobal -}; - -/** - * @fileoverview Provide the function that emits deprecation warnings. - * @author Toru Nagashima - */ - -//------------------------------------------------------------------------------ -// Private -//------------------------------------------------------------------------------ - -// Defitions for deprecation warnings. -const deprecationWarningMessages = { - ESLINT_LEGACY_ECMAFEATURES: - "The 'ecmaFeatures' config file property is deprecated and has no effect.", - ESLINT_PERSONAL_CONFIG_LOAD: - "'~/.eslintrc.*' config files have been deprecated. " + - "Please use a config file per project or the '--config' option.", - ESLINT_PERSONAL_CONFIG_SUPPRESS: - "'~/.eslintrc.*' config files have been deprecated. " + - "Please remove it or add 'root:true' to the config files in your " + - "projects in order to avoid loading '~/.eslintrc.*' accidentally." -}; - -const sourceFileErrorCache = new Set(); - -/** - * Emits a deprecation warning containing a given filepath. A new deprecation warning is emitted - * for each unique file path, but repeated invocations with the same file path have no effect. - * No warnings are emitted if the `--no-deprecation` or `--no-warnings` Node runtime flags are active. - * @param {string} source The name of the configuration source to report the warning for. - * @param {string} errorCode The warning message to show. - * @returns {void} - */ -function emitDeprecationWarning(source, errorCode) { - const cacheKey = JSON.stringify({ source, errorCode }); - - if (sourceFileErrorCache.has(cacheKey)) { - return; - } - sourceFileErrorCache.add(cacheKey); - - const rel = path__default["default"].relative(process.cwd(), source); - const message = deprecationWarningMessages[errorCode]; - - process.emitWarning( - `${message} (found in "${rel}")`, - "DeprecationWarning", - errorCode - ); -} - -/** - * @fileoverview The instance of Ajv validator. - * @author Evgeny Poberezkin - */ - -//----------------------------------------------------------------------------- -// Helpers -//----------------------------------------------------------------------------- - -/* - * Copied from ajv/lib/refs/json-schema-draft-04.json - * The MIT License (MIT) - * Copyright (c) 2015-2017 Evgeny Poberezkin - */ -const metaSchema = { - id: "http://json-schema.org/draft-04/schema#", - $schema: "http://json-schema.org/draft-04/schema#", - description: "Core schema meta-schema", - definitions: { - schemaArray: { - type: "array", - minItems: 1, - items: { $ref: "#" } - }, - positiveInteger: { - type: "integer", - minimum: 0 - }, - positiveIntegerDefault0: { - allOf: [{ $ref: "#/definitions/positiveInteger" }, { default: 0 }] - }, - simpleTypes: { - enum: ["array", "boolean", "integer", "null", "number", "object", "string"] - }, - stringArray: { - type: "array", - items: { type: "string" }, - minItems: 1, - uniqueItems: true - } - }, - type: "object", - properties: { - id: { - type: "string" - }, - $schema: { - type: "string" - }, - title: { - type: "string" - }, - description: { - type: "string" - }, - default: { }, - multipleOf: { - type: "number", - minimum: 0, - exclusiveMinimum: true - }, - maximum: { - type: "number" - }, - exclusiveMaximum: { - type: "boolean", - default: false - }, - minimum: { - type: "number" - }, - exclusiveMinimum: { - type: "boolean", - default: false - }, - maxLength: { $ref: "#/definitions/positiveInteger" }, - minLength: { $ref: "#/definitions/positiveIntegerDefault0" }, - pattern: { - type: "string", - format: "regex" - }, - additionalItems: { - anyOf: [ - { type: "boolean" }, - { $ref: "#" } - ], - default: { } - }, - items: { - anyOf: [ - { $ref: "#" }, - { $ref: "#/definitions/schemaArray" } - ], - default: { } - }, - maxItems: { $ref: "#/definitions/positiveInteger" }, - minItems: { $ref: "#/definitions/positiveIntegerDefault0" }, - uniqueItems: { - type: "boolean", - default: false - }, - maxProperties: { $ref: "#/definitions/positiveInteger" }, - minProperties: { $ref: "#/definitions/positiveIntegerDefault0" }, - required: { $ref: "#/definitions/stringArray" }, - additionalProperties: { - anyOf: [ - { type: "boolean" }, - { $ref: "#" } - ], - default: { } - }, - definitions: { - type: "object", - additionalProperties: { $ref: "#" }, - default: { } - }, - properties: { - type: "object", - additionalProperties: { $ref: "#" }, - default: { } - }, - patternProperties: { - type: "object", - additionalProperties: { $ref: "#" }, - default: { } - }, - dependencies: { - type: "object", - additionalProperties: { - anyOf: [ - { $ref: "#" }, - { $ref: "#/definitions/stringArray" } - ] - } - }, - enum: { - type: "array", - minItems: 1, - uniqueItems: true - }, - type: { - anyOf: [ - { $ref: "#/definitions/simpleTypes" }, - { - type: "array", - items: { $ref: "#/definitions/simpleTypes" }, - minItems: 1, - uniqueItems: true - } - ] - }, - format: { type: "string" }, - allOf: { $ref: "#/definitions/schemaArray" }, - anyOf: { $ref: "#/definitions/schemaArray" }, - oneOf: { $ref: "#/definitions/schemaArray" }, - not: { $ref: "#" } - }, - dependencies: { - exclusiveMaximum: ["maximum"], - exclusiveMinimum: ["minimum"] - }, - default: { } -}; - -//------------------------------------------------------------------------------ -// Public Interface -//------------------------------------------------------------------------------ - -var ajvOrig = (additionalOptions = {}) => { - const ajv = new Ajv__default["default"]({ - meta: false, - useDefaults: true, - validateSchema: false, - missingRefs: "ignore", - verbose: true, - schemaId: "auto", - ...additionalOptions - }); - - ajv.addMetaSchema(metaSchema); - // eslint-disable-next-line no-underscore-dangle - ajv._opts.defaultMeta = metaSchema.id; - - return ajv; -}; - -/** - * @fileoverview Defines a schema for configs. - * @author Sylvan Mably - */ - -const baseConfigProperties = { - $schema: { type: "string" }, - env: { type: "object" }, - extends: { $ref: "#/definitions/stringOrStrings" }, - globals: { type: "object" }, - overrides: { - type: "array", - items: { $ref: "#/definitions/overrideConfig" }, - additionalItems: false - }, - parser: { type: ["string", "null"] }, - parserOptions: { type: "object" }, - plugins: { type: "array" }, - processor: { type: "string" }, - rules: { type: "object" }, - settings: { type: "object" }, - noInlineConfig: { type: "boolean" }, - reportUnusedDisableDirectives: { type: "boolean" }, - - ecmaFeatures: { type: "object" } // deprecated; logs a warning when used -}; - -const configSchema = { - definitions: { - stringOrStrings: { - oneOf: [ - { type: "string" }, - { - type: "array", - items: { type: "string" }, - additionalItems: false - } - ] - }, - stringOrStringsRequired: { - oneOf: [ - { type: "string" }, - { - type: "array", - items: { type: "string" }, - additionalItems: false, - minItems: 1 - } - ] - }, - - // Config at top-level. - objectConfig: { - type: "object", - properties: { - root: { type: "boolean" }, - ignorePatterns: { $ref: "#/definitions/stringOrStrings" }, - ...baseConfigProperties - }, - additionalProperties: false - }, - - // Config in `overrides`. - overrideConfig: { - type: "object", - properties: { - excludedFiles: { $ref: "#/definitions/stringOrStrings" }, - files: { $ref: "#/definitions/stringOrStringsRequired" }, - ...baseConfigProperties - }, - required: ["files"], - additionalProperties: false - } - }, - - $ref: "#/definitions/objectConfig" -}; - -/** - * @fileoverview Defines environment settings and globals. - * @author Elan Shanker - */ - -//------------------------------------------------------------------------------ -// Helpers -//------------------------------------------------------------------------------ - -/** - * Get the object that has difference. - * @param {Record} current The newer object. - * @param {Record} prev The older object. - * @returns {Record} The difference object. - */ -function getDiff(current, prev) { - const retv = {}; - - for (const [key, value] of Object.entries(current)) { - if (!Object.hasOwnProperty.call(prev, key)) { - retv[key] = value; - } - } - - return retv; -} - -const newGlobals2015 = getDiff(globals__default["default"].es2015, globals__default["default"].es5); // 19 variables such as Promise, Map, ... -const newGlobals2017 = { - Atomics: false, - SharedArrayBuffer: false -}; -const newGlobals2020 = { - BigInt: false, - BigInt64Array: false, - BigUint64Array: false, - globalThis: false -}; - -const newGlobals2021 = { - AggregateError: false, - FinalizationRegistry: false, - WeakRef: false -}; - -//------------------------------------------------------------------------------ -// Public Interface -//------------------------------------------------------------------------------ - -/** @type {Map} */ -var environments = new Map(Object.entries({ - - // Language - builtin: { - globals: globals__default["default"].es5 - }, - es6: { - globals: newGlobals2015, - parserOptions: { - ecmaVersion: 6 - } - }, - es2015: { - globals: newGlobals2015, - parserOptions: { - ecmaVersion: 6 - } - }, - es2016: { - globals: newGlobals2015, - parserOptions: { - ecmaVersion: 7 - } - }, - es2017: { - globals: { ...newGlobals2015, ...newGlobals2017 }, - parserOptions: { - ecmaVersion: 8 - } - }, - es2018: { - globals: { ...newGlobals2015, ...newGlobals2017 }, - parserOptions: { - ecmaVersion: 9 - } - }, - es2019: { - globals: { ...newGlobals2015, ...newGlobals2017 }, - parserOptions: { - ecmaVersion: 10 - } - }, - es2020: { - globals: { ...newGlobals2015, ...newGlobals2017, ...newGlobals2020 }, - parserOptions: { - ecmaVersion: 11 - } - }, - es2021: { - globals: { ...newGlobals2015, ...newGlobals2017, ...newGlobals2020, ...newGlobals2021 }, - parserOptions: { - ecmaVersion: 12 - } - }, - es2022: { - globals: { ...newGlobals2015, ...newGlobals2017, ...newGlobals2020, ...newGlobals2021 }, - parserOptions: { - ecmaVersion: 13 - } - }, - es2023: { - globals: { ...newGlobals2015, ...newGlobals2017, ...newGlobals2020, ...newGlobals2021 }, - parserOptions: { - ecmaVersion: 14 - } - }, - es2024: { - globals: { ...newGlobals2015, ...newGlobals2017, ...newGlobals2020, ...newGlobals2021 }, - parserOptions: { - ecmaVersion: 15 - } - }, - - // Platforms - browser: { - globals: globals__default["default"].browser - }, - node: { - globals: globals__default["default"].node, - parserOptions: { - ecmaFeatures: { - globalReturn: true - } - } - }, - "shared-node-browser": { - globals: globals__default["default"]["shared-node-browser"] - }, - worker: { - globals: globals__default["default"].worker - }, - serviceworker: { - globals: globals__default["default"].serviceworker - }, - - // Frameworks - commonjs: { - globals: globals__default["default"].commonjs, - parserOptions: { - ecmaFeatures: { - globalReturn: true - } - } - }, - amd: { - globals: globals__default["default"].amd - }, - mocha: { - globals: globals__default["default"].mocha - }, - jasmine: { - globals: globals__default["default"].jasmine - }, - jest: { - globals: globals__default["default"].jest - }, - phantomjs: { - globals: globals__default["default"].phantomjs - }, - jquery: { - globals: globals__default["default"].jquery - }, - qunit: { - globals: globals__default["default"].qunit - }, - prototypejs: { - globals: globals__default["default"].prototypejs - }, - shelljs: { - globals: globals__default["default"].shelljs - }, - meteor: { - globals: globals__default["default"].meteor - }, - mongo: { - globals: globals__default["default"].mongo - }, - protractor: { - globals: globals__default["default"].protractor - }, - applescript: { - globals: globals__default["default"].applescript - }, - nashorn: { - globals: globals__default["default"].nashorn - }, - atomtest: { - globals: globals__default["default"].atomtest - }, - embertest: { - globals: globals__default["default"].embertest - }, - webextensions: { - globals: globals__default["default"].webextensions - }, - greasemonkey: { - globals: globals__default["default"].greasemonkey - } -})); - -/** - * @fileoverview Validates configs. - * @author Brandon Mills - */ - -const ajv = ajvOrig(); - -const ruleValidators = new WeakMap(); -const noop = Function.prototype; - -//------------------------------------------------------------------------------ -// Private -//------------------------------------------------------------------------------ -let validateSchema; -const severityMap = { - error: 2, - warn: 1, - off: 0 -}; - -const validated = new WeakSet(); - -// JSON schema that disallows passing any options -const noOptionsSchema = Object.freeze({ - type: "array", - minItems: 0, - maxItems: 0 -}); - -//----------------------------------------------------------------------------- -// Exports -//----------------------------------------------------------------------------- - -class ConfigValidator { - constructor({ builtInRules = new Map() } = {}) { - this.builtInRules = builtInRules; - } - - /** - * Gets a complete options schema for a rule. - * @param {Rule} rule A rule object - * @throws {TypeError} If `meta.schema` is specified but is not an array, object or `false`. - * @returns {Object|null} JSON Schema for the rule's options. - * `null` if rule wasn't passed or its `meta.schema` is `false`. - */ - getRuleOptionsSchema(rule) { - if (!rule) { - return null; - } - - if (!rule.meta) { - return { ...noOptionsSchema }; // default if `meta.schema` is not specified - } - - const schema = rule.meta.schema; - - if (typeof schema === "undefined") { - return { ...noOptionsSchema }; // default if `meta.schema` is not specified - } - - // `schema:false` is an allowed explicit opt-out of options validation for the rule - if (schema === false) { - return null; - } - - if (typeof schema !== "object" || schema === null) { - throw new TypeError("Rule's `meta.schema` must be an array or object"); - } - - // ESLint-specific array form needs to be converted into a valid JSON Schema definition - if (Array.isArray(schema)) { - if (schema.length) { - return { - type: "array", - items: schema, - minItems: 0, - maxItems: schema.length - }; - } - - // `schema:[]` is an explicit way to specify that the rule does not accept any options - return { ...noOptionsSchema }; - } - - // `schema:` is assumed to be a valid JSON Schema definition - return schema; - } - - /** - * Validates a rule's severity and returns the severity value. Throws an error if the severity is invalid. - * @param {options} options The given options for the rule. - * @returns {number|string} The rule's severity value - */ - validateRuleSeverity(options) { - const severity = Array.isArray(options) ? options[0] : options; - const normSeverity = typeof severity === "string" ? severityMap[severity.toLowerCase()] : severity; - - if (normSeverity === 0 || normSeverity === 1 || normSeverity === 2) { - return normSeverity; - } - - throw new Error(`\tSeverity should be one of the following: 0 = off, 1 = warn, 2 = error (you passed '${util__default["default"].inspect(severity).replace(/'/gu, "\"").replace(/\n/gu, "")}').\n`); - - } - - /** - * Validates the non-severity options passed to a rule, based on its schema. - * @param {{create: Function}} rule The rule to validate - * @param {Array} localOptions The options for the rule, excluding severity - * @returns {void} - */ - validateRuleSchema(rule, localOptions) { - if (!ruleValidators.has(rule)) { - try { - const schema = this.getRuleOptionsSchema(rule); - - if (schema) { - ruleValidators.set(rule, ajv.compile(schema)); - } - } catch (err) { - const errorWithCode = new Error(err.message, { cause: err }); - - errorWithCode.code = "ESLINT_INVALID_RULE_OPTIONS_SCHEMA"; - - throw errorWithCode; - } - } - - const validateRule = ruleValidators.get(rule); - - if (validateRule) { - validateRule(localOptions); - if (validateRule.errors) { - throw new Error(validateRule.errors.map( - error => `\tValue ${JSON.stringify(error.data)} ${error.message}.\n` - ).join("")); - } - } - } - - /** - * Validates a rule's options against its schema. - * @param {{create: Function}|null} rule The rule that the config is being validated for - * @param {string} ruleId The rule's unique name. - * @param {Array|number} options The given options for the rule. - * @param {string|null} source The name of the configuration source to report in any errors. If null or undefined, - * no source is prepended to the message. - * @returns {void} - */ - validateRuleOptions(rule, ruleId, options, source = null) { - try { - const severity = this.validateRuleSeverity(options); - - if (severity !== 0) { - this.validateRuleSchema(rule, Array.isArray(options) ? options.slice(1) : []); - } - } catch (err) { - let enhancedMessage = err.code === "ESLINT_INVALID_RULE_OPTIONS_SCHEMA" - ? `Error while processing options validation schema of rule '${ruleId}': ${err.message}` - : `Configuration for rule "${ruleId}" is invalid:\n${err.message}`; - - if (typeof source === "string") { - enhancedMessage = `${source}:\n\t${enhancedMessage}`; - } - - const enhancedError = new Error(enhancedMessage, { cause: err }); - - if (err.code) { - enhancedError.code = err.code; - } - - throw enhancedError; - } - } - - /** - * Validates an environment object - * @param {Object} environment The environment config object to validate. - * @param {string} source The name of the configuration source to report in any errors. - * @param {function(envId:string): Object} [getAdditionalEnv] A map from strings to loaded environments. - * @returns {void} - */ - validateEnvironment( - environment, - source, - getAdditionalEnv = noop - ) { - - // not having an environment is ok - if (!environment) { - return; - } - - Object.keys(environment).forEach(id => { - const env = getAdditionalEnv(id) || environments.get(id) || null; - - if (!env) { - const message = `${source}:\n\tEnvironment key "${id}" is unknown\n`; - - throw new Error(message); - } - }); - } - - /** - * Validates a rules config object - * @param {Object} rulesConfig The rules config object to validate. - * @param {string} source The name of the configuration source to report in any errors. - * @param {function(ruleId:string): Object} getAdditionalRule A map from strings to loaded rules - * @returns {void} - */ - validateRules( - rulesConfig, - source, - getAdditionalRule = noop - ) { - if (!rulesConfig) { - return; - } - - Object.keys(rulesConfig).forEach(id => { - const rule = getAdditionalRule(id) || this.builtInRules.get(id) || null; - - this.validateRuleOptions(rule, id, rulesConfig[id], source); - }); - } - - /** - * Validates a `globals` section of a config file - * @param {Object} globalsConfig The `globals` section - * @param {string|null} source The name of the configuration source to report in the event of an error. - * @returns {void} - */ - validateGlobals(globalsConfig, source = null) { - if (!globalsConfig) { - return; - } - - Object.entries(globalsConfig) - .forEach(([configuredGlobal, configuredValue]) => { - try { - normalizeConfigGlobal(configuredValue); - } catch (err) { - throw new Error(`ESLint configuration of global '${configuredGlobal}' in ${source} is invalid:\n${err.message}`); - } - }); - } - - /** - * Validate `processor` configuration. - * @param {string|undefined} processorName The processor name. - * @param {string} source The name of config file. - * @param {function(id:string): Processor} getProcessor The getter of defined processors. - * @returns {void} - */ - validateProcessor(processorName, source, getProcessor) { - if (processorName && !getProcessor(processorName)) { - throw new Error(`ESLint configuration of processor in '${source}' is invalid: '${processorName}' was not found.`); - } - } - - /** - * Formats an array of schema validation errors. - * @param {Array} errors An array of error messages to format. - * @returns {string} Formatted error message - */ - formatErrors(errors) { - return errors.map(error => { - if (error.keyword === "additionalProperties") { - const formattedPropertyPath = error.dataPath.length ? `${error.dataPath.slice(1)}.${error.params.additionalProperty}` : error.params.additionalProperty; - - return `Unexpected top-level property "${formattedPropertyPath}"`; - } - if (error.keyword === "type") { - const formattedField = error.dataPath.slice(1); - const formattedExpectedType = Array.isArray(error.schema) ? error.schema.join("/") : error.schema; - const formattedValue = JSON.stringify(error.data); - - return `Property "${formattedField}" is the wrong type (expected ${formattedExpectedType} but got \`${formattedValue}\`)`; - } - - const field = error.dataPath[0] === "." ? error.dataPath.slice(1) : error.dataPath; - - return `"${field}" ${error.message}. Value: ${JSON.stringify(error.data)}`; - }).map(message => `\t- ${message}.\n`).join(""); - } - - /** - * Validates the top level properties of the config object. - * @param {Object} config The config object to validate. - * @param {string} source The name of the configuration source to report in any errors. - * @returns {void} - */ - validateConfigSchema(config, source = null) { - validateSchema = validateSchema || ajv.compile(configSchema); - - if (!validateSchema(config)) { - throw new Error(`ESLint configuration in ${source} is invalid:\n${this.formatErrors(validateSchema.errors)}`); - } - - if (Object.hasOwnProperty.call(config, "ecmaFeatures")) { - emitDeprecationWarning(source, "ESLINT_LEGACY_ECMAFEATURES"); - } - } - - /** - * Validates an entire config object. - * @param {Object} config The config object to validate. - * @param {string} source The name of the configuration source to report in any errors. - * @param {function(ruleId:string): Object} [getAdditionalRule] A map from strings to loaded rules. - * @param {function(envId:string): Object} [getAdditionalEnv] A map from strings to loaded envs. - * @returns {void} - */ - validate(config, source, getAdditionalRule, getAdditionalEnv) { - this.validateConfigSchema(config, source); - this.validateRules(config.rules, source, getAdditionalRule); - this.validateEnvironment(config.env, source, getAdditionalEnv); - this.validateGlobals(config.globals, source); - - for (const override of config.overrides || []) { - this.validateRules(override.rules, source, getAdditionalRule); - this.validateEnvironment(override.env, source, getAdditionalEnv); - this.validateGlobals(config.globals, source); - } - } - - /** - * Validate config array object. - * @param {ConfigArray} configArray The config array to validate. - * @returns {void} - */ - validateConfigArray(configArray) { - const getPluginEnv = Map.prototype.get.bind(configArray.pluginEnvironments); - const getPluginProcessor = Map.prototype.get.bind(configArray.pluginProcessors); - const getPluginRule = Map.prototype.get.bind(configArray.pluginRules); - - // Validate. - for (const element of configArray) { - if (validated.has(element)) { - continue; - } - validated.add(element); - - this.validateEnvironment(element.env, element.name, getPluginEnv); - this.validateGlobals(element.globals, element.name); - this.validateProcessor(element.processor, element.name, getPluginProcessor); - this.validateRules(element.rules, element.name, getPluginRule); - } - } - -} - -/** - * @fileoverview Common helpers for naming of plugins, formatters and configs - */ - -const NAMESPACE_REGEX = /^@.*\//iu; - -/** - * Brings package name to correct format based on prefix - * @param {string} name The name of the package. - * @param {string} prefix Can be either "eslint-plugin", "eslint-config" or "eslint-formatter" - * @returns {string} Normalized name of the package - * @private - */ -function normalizePackageName(name, prefix) { - let normalizedName = name; - - /** - * On Windows, name can come in with Windows slashes instead of Unix slashes. - * Normalize to Unix first to avoid errors later on. - * https://github.com/eslint/eslint/issues/5644 - */ - if (normalizedName.includes("\\")) { - normalizedName = normalizedName.replace(/\\/gu, "/"); - } - - if (normalizedName.charAt(0) === "@") { - - /** - * it's a scoped package - * package name is the prefix, or just a username - */ - const scopedPackageShortcutRegex = new RegExp(`^(@[^/]+)(?:/(?:${prefix})?)?$`, "u"), - scopedPackageNameRegex = new RegExp(`^${prefix}(-|$)`, "u"); - - if (scopedPackageShortcutRegex.test(normalizedName)) { - normalizedName = normalizedName.replace(scopedPackageShortcutRegex, `$1/${prefix}`); - } else if (!scopedPackageNameRegex.test(normalizedName.split("/")[1])) { - - /** - * for scoped packages, insert the prefix after the first / unless - * the path is already @scope/eslint or @scope/eslint-xxx-yyy - */ - normalizedName = normalizedName.replace(/^@([^/]+)\/(.*)$/u, `@$1/${prefix}-$2`); - } - } else if (!normalizedName.startsWith(`${prefix}-`)) { - normalizedName = `${prefix}-${normalizedName}`; - } - - return normalizedName; -} - -/** - * Removes the prefix from a fullname. - * @param {string} fullname The term which may have the prefix. - * @param {string} prefix The prefix to remove. - * @returns {string} The term without prefix. - */ -function getShorthandName(fullname, prefix) { - if (fullname[0] === "@") { - let matchResult = new RegExp(`^(@[^/]+)/${prefix}$`, "u").exec(fullname); - - if (matchResult) { - return matchResult[1]; - } - - matchResult = new RegExp(`^(@[^/]+)/${prefix}-(.+)$`, "u").exec(fullname); - if (matchResult) { - return `${matchResult[1]}/${matchResult[2]}`; - } - } else if (fullname.startsWith(`${prefix}-`)) { - return fullname.slice(prefix.length + 1); - } - - return fullname; -} - -/** - * Gets the scope (namespace) of a term. - * @param {string} term The term which may have the namespace. - * @returns {string} The namespace of the term if it has one. - */ -function getNamespaceFromTerm(term) { - const match = term.match(NAMESPACE_REGEX); - - return match ? match[0] : ""; -} - -var naming = { - __proto__: null, - normalizePackageName: normalizePackageName, - getShorthandName: getShorthandName, - getNamespaceFromTerm: getNamespaceFromTerm -}; - -/** - * Utility for resolving a module relative to another module - * @author Teddy Katz - */ - -/* - * `Module.createRequire` is added in v12.2.0. It supports URL as well. - * We only support the case where the argument is a filepath, not a URL. - */ -const createRequire = Module__default["default"].createRequire; - -/** - * Resolves a Node module relative to another module - * @param {string} moduleName The name of a Node module, or a path to a Node module. - * @param {string} relativeToPath An absolute path indicating the module that `moduleName` should be resolved relative to. This must be - * a file rather than a directory, but the file need not actually exist. - * @returns {string} The absolute path that would result from calling `require.resolve(moduleName)` in a file located at `relativeToPath` - */ -function resolve(moduleName, relativeToPath) { - try { - return createRequire(relativeToPath).resolve(moduleName); - } catch (error) { - - // This `if` block is for older Node.js than 12.0.0. We can remove this block in the future. - if ( - typeof error === "object" && - error !== null && - error.code === "MODULE_NOT_FOUND" && - !error.requireStack && - error.message.includes(moduleName) - ) { - error.message += `\nRequire stack:\n- ${relativeToPath}`; - } - throw error; - } -} - -var ModuleResolver = { - __proto__: null, - resolve: resolve -}; - -/** - * @fileoverview The factory of `ConfigArray` objects. - * - * This class provides methods to create `ConfigArray` instance. - * - * - `create(configData, options)` - * Create a `ConfigArray` instance from a config data. This is to handle CLI - * options except `--config`. - * - `loadFile(filePath, options)` - * Create a `ConfigArray` instance from a config file. This is to handle - * `--config` option. If the file was not found, throws the following error: - * - If the filename was `*.js`, a `MODULE_NOT_FOUND` error. - * - If the filename was `package.json`, an IO error or an - * `ESLINT_CONFIG_FIELD_NOT_FOUND` error. - * - Otherwise, an IO error such as `ENOENT`. - * - `loadInDirectory(directoryPath, options)` - * Create a `ConfigArray` instance from a config file which is on a given - * directory. This tries to load `.eslintrc.*` or `package.json`. If not - * found, returns an empty `ConfigArray`. - * - `loadESLintIgnore(filePath)` - * Create a `ConfigArray` instance from a config file that is `.eslintignore` - * format. This is to handle `--ignore-path` option. - * - `loadDefaultESLintIgnore()` - * Create a `ConfigArray` instance from `.eslintignore` or `package.json` in - * the current working directory. - * - * `ConfigArrayFactory` class has the responsibility that loads configuration - * files, including loading `extends`, `parser`, and `plugins`. The created - * `ConfigArray` instance has the loaded `extends`, `parser`, and `plugins`. - * - * But this class doesn't handle cascading. `CascadingConfigArrayFactory` class - * handles cascading and hierarchy. - * - * @author Toru Nagashima - */ - -const require$1 = Module.createRequire(require('url').pathToFileURL(__filename).toString()); - -const debug$2 = debugOrig__default["default"]("eslintrc:config-array-factory"); - -//------------------------------------------------------------------------------ -// Helpers -//------------------------------------------------------------------------------ - -const configFilenames = [ - ".eslintrc.js", - ".eslintrc.cjs", - ".eslintrc.yaml", - ".eslintrc.yml", - ".eslintrc.json", - ".eslintrc", - "package.json" -]; - -// Define types for VSCode IntelliSense. -/** @typedef {import("./shared/types").ConfigData} ConfigData */ -/** @typedef {import("./shared/types").OverrideConfigData} OverrideConfigData */ -/** @typedef {import("./shared/types").Parser} Parser */ -/** @typedef {import("./shared/types").Plugin} Plugin */ -/** @typedef {import("./shared/types").Rule} Rule */ -/** @typedef {import("./config-array/config-dependency").DependentParser} DependentParser */ -/** @typedef {import("./config-array/config-dependency").DependentPlugin} DependentPlugin */ -/** @typedef {ConfigArray[0]} ConfigArrayElement */ - -/** - * @typedef {Object} ConfigArrayFactoryOptions - * @property {Map} [additionalPluginPool] The map for additional plugins. - * @property {string} [cwd] The path to the current working directory. - * @property {string} [resolvePluginsRelativeTo] A path to the directory that plugins should be resolved from. Defaults to `cwd`. - * @property {Map} builtInRules The rules that are built in to ESLint. - * @property {Object} [resolver=ModuleResolver] The module resolver object. - * @property {string} eslintAllPath The path to the definitions for eslint:all. - * @property {Function} getEslintAllConfig Returns the config data for eslint:all. - * @property {string} eslintRecommendedPath The path to the definitions for eslint:recommended. - * @property {Function} getEslintRecommendedConfig Returns the config data for eslint:recommended. - */ - -/** - * @typedef {Object} ConfigArrayFactoryInternalSlots - * @property {Map} additionalPluginPool The map for additional plugins. - * @property {string} cwd The path to the current working directory. - * @property {string | undefined} resolvePluginsRelativeTo An absolute path the the directory that plugins should be resolved from. - * @property {Map} builtInRules The rules that are built in to ESLint. - * @property {Object} [resolver=ModuleResolver] The module resolver object. - * @property {string} eslintAllPath The path to the definitions for eslint:all. - * @property {Function} getEslintAllConfig Returns the config data for eslint:all. - * @property {string} eslintRecommendedPath The path to the definitions for eslint:recommended. - * @property {Function} getEslintRecommendedConfig Returns the config data for eslint:recommended. - */ - -/** - * @typedef {Object} ConfigArrayFactoryLoadingContext - * @property {string} filePath The path to the current configuration. - * @property {string} matchBasePath The base path to resolve relative paths in `overrides[].files`, `overrides[].excludedFiles`, and `ignorePatterns`. - * @property {string} name The name of the current configuration. - * @property {string} pluginBasePath The base path to resolve plugins. - * @property {"config" | "ignore" | "implicit-processor"} type The type of the current configuration. This is `"config"` in normal. This is `"ignore"` if it came from `.eslintignore`. This is `"implicit-processor"` if it came from legacy file-extension processors. - */ - -/** - * @typedef {Object} ConfigArrayFactoryLoadingContext - * @property {string} filePath The path to the current configuration. - * @property {string} matchBasePath The base path to resolve relative paths in `overrides[].files`, `overrides[].excludedFiles`, and `ignorePatterns`. - * @property {string} name The name of the current configuration. - * @property {"config" | "ignore" | "implicit-processor"} type The type of the current configuration. This is `"config"` in normal. This is `"ignore"` if it came from `.eslintignore`. This is `"implicit-processor"` if it came from legacy file-extension processors. - */ - -/** @type {WeakMap} */ -const internalSlotsMap$1 = new WeakMap(); - -/** @type {WeakMap} */ -const normalizedPlugins = new WeakMap(); - -/** - * Check if a given string is a file path. - * @param {string} nameOrPath A module name or file path. - * @returns {boolean} `true` if the `nameOrPath` is a file path. - */ -function isFilePath(nameOrPath) { - return ( - /^\.{1,2}[/\\]/u.test(nameOrPath) || - path__default["default"].isAbsolute(nameOrPath) - ); -} - -/** - * Convenience wrapper for synchronously reading file contents. - * @param {string} filePath The filename to read. - * @returns {string} The file contents, with the BOM removed. - * @private - */ -function readFile(filePath) { - return fs__default["default"].readFileSync(filePath, "utf8").replace(/^\ufeff/u, ""); -} - -/** - * Loads a YAML configuration from a file. - * @param {string} filePath The filename to load. - * @returns {ConfigData} The configuration object from the file. - * @throws {Error} If the file cannot be read. - * @private - */ -function loadYAMLConfigFile(filePath) { - debug$2(`Loading YAML config file: ${filePath}`); - - // lazy load YAML to improve performance when not used - const yaml = require$1("js-yaml"); - - try { - - // empty YAML file can be null, so always use - return yaml.load(readFile(filePath)) || {}; - } catch (e) { - debug$2(`Error reading YAML file: ${filePath}`); - e.message = `Cannot read config file: ${filePath}\nError: ${e.message}`; - throw e; - } -} - -/** - * Loads a JSON configuration from a file. - * @param {string} filePath The filename to load. - * @returns {ConfigData} The configuration object from the file. - * @throws {Error} If the file cannot be read. - * @private - */ -function loadJSONConfigFile(filePath) { - debug$2(`Loading JSON config file: ${filePath}`); - - try { - return JSON.parse(stripComments__default["default"](readFile(filePath))); - } catch (e) { - debug$2(`Error reading JSON file: ${filePath}`); - e.message = `Cannot read config file: ${filePath}\nError: ${e.message}`; - e.messageTemplate = "failed-to-read-json"; - e.messageData = { - path: filePath, - message: e.message - }; - throw e; - } -} - -/** - * Loads a legacy (.eslintrc) configuration from a file. - * @param {string} filePath The filename to load. - * @returns {ConfigData} The configuration object from the file. - * @throws {Error} If the file cannot be read. - * @private - */ -function loadLegacyConfigFile(filePath) { - debug$2(`Loading legacy config file: ${filePath}`); - - // lazy load YAML to improve performance when not used - const yaml = require$1("js-yaml"); - - try { - return yaml.load(stripComments__default["default"](readFile(filePath))) || /* istanbul ignore next */ {}; - } catch (e) { - debug$2("Error reading YAML file: %s\n%o", filePath, e); - e.message = `Cannot read config file: ${filePath}\nError: ${e.message}`; - throw e; - } -} - -/** - * Loads a JavaScript configuration from a file. - * @param {string} filePath The filename to load. - * @returns {ConfigData} The configuration object from the file. - * @throws {Error} If the file cannot be read. - * @private - */ -function loadJSConfigFile(filePath) { - debug$2(`Loading JS config file: ${filePath}`); - try { - return importFresh__default["default"](filePath); - } catch (e) { - debug$2(`Error reading JavaScript file: ${filePath}`); - e.message = `Cannot read config file: ${filePath}\nError: ${e.message}`; - throw e; - } -} - -/** - * Loads a configuration from a package.json file. - * @param {string} filePath The filename to load. - * @returns {ConfigData} The configuration object from the file. - * @throws {Error} If the file cannot be read. - * @private - */ -function loadPackageJSONConfigFile(filePath) { - debug$2(`Loading package.json config file: ${filePath}`); - try { - const packageData = loadJSONConfigFile(filePath); - - if (!Object.hasOwnProperty.call(packageData, "eslintConfig")) { - throw Object.assign( - new Error("package.json file doesn't have 'eslintConfig' field."), - { code: "ESLINT_CONFIG_FIELD_NOT_FOUND" } - ); - } - - return packageData.eslintConfig; - } catch (e) { - debug$2(`Error reading package.json file: ${filePath}`); - e.message = `Cannot read config file: ${filePath}\nError: ${e.message}`; - throw e; - } -} - -/** - * Loads a `.eslintignore` from a file. - * @param {string} filePath The filename to load. - * @returns {string[]} The ignore patterns from the file. - * @private - */ -function loadESLintIgnoreFile(filePath) { - debug$2(`Loading .eslintignore file: ${filePath}`); - - try { - return readFile(filePath) - .split(/\r?\n/gu) - .filter(line => line.trim() !== "" && !line.startsWith("#")); - } catch (e) { - debug$2(`Error reading .eslintignore file: ${filePath}`); - e.message = `Cannot read .eslintignore file: ${filePath}\nError: ${e.message}`; - throw e; - } -} - -/** - * Creates an error to notify about a missing config to extend from. - * @param {string} configName The name of the missing config. - * @param {string} importerName The name of the config that imported the missing config - * @param {string} messageTemplate The text template to source error strings from. - * @returns {Error} The error object to throw - * @private - */ -function configInvalidError(configName, importerName, messageTemplate) { - return Object.assign( - new Error(`Failed to load config "${configName}" to extend from.`), - { - messageTemplate, - messageData: { configName, importerName } - } - ); -} - -/** - * Loads a configuration file regardless of the source. Inspects the file path - * to determine the correctly way to load the config file. - * @param {string} filePath The path to the configuration. - * @returns {ConfigData|null} The configuration information. - * @private - */ -function loadConfigFile(filePath) { - switch (path__default["default"].extname(filePath)) { - case ".js": - case ".cjs": - return loadJSConfigFile(filePath); - - case ".json": - if (path__default["default"].basename(filePath) === "package.json") { - return loadPackageJSONConfigFile(filePath); - } - return loadJSONConfigFile(filePath); - - case ".yaml": - case ".yml": - return loadYAMLConfigFile(filePath); - - default: - return loadLegacyConfigFile(filePath); - } -} - -/** - * Write debug log. - * @param {string} request The requested module name. - * @param {string} relativeTo The file path to resolve the request relative to. - * @param {string} filePath The resolved file path. - * @returns {void} - */ -function writeDebugLogForLoading(request, relativeTo, filePath) { - /* istanbul ignore next */ - if (debug$2.enabled) { - let nameAndVersion = null; - - try { - const packageJsonPath = resolve( - `${request}/package.json`, - relativeTo - ); - const { version = "unknown" } = require$1(packageJsonPath); - - nameAndVersion = `${request}@${version}`; - } catch (error) { - debug$2("package.json was not found:", error.message); - nameAndVersion = request; - } - - debug$2("Loaded: %s (%s)", nameAndVersion, filePath); - } -} - -/** - * Create a new context with default values. - * @param {ConfigArrayFactoryInternalSlots} slots The internal slots. - * @param {"config" | "ignore" | "implicit-processor" | undefined} providedType The type of the current configuration. Default is `"config"`. - * @param {string | undefined} providedName The name of the current configuration. Default is the relative path from `cwd` to `filePath`. - * @param {string | undefined} providedFilePath The path to the current configuration. Default is empty string. - * @param {string | undefined} providedMatchBasePath The type of the current configuration. Default is the directory of `filePath` or `cwd`. - * @returns {ConfigArrayFactoryLoadingContext} The created context. - */ -function createContext( - { cwd, resolvePluginsRelativeTo }, - providedType, - providedName, - providedFilePath, - providedMatchBasePath -) { - const filePath = providedFilePath - ? path__default["default"].resolve(cwd, providedFilePath) - : ""; - const matchBasePath = - (providedMatchBasePath && path__default["default"].resolve(cwd, providedMatchBasePath)) || - (filePath && path__default["default"].dirname(filePath)) || - cwd; - const name = - providedName || - (filePath && path__default["default"].relative(cwd, filePath)) || - ""; - const pluginBasePath = - resolvePluginsRelativeTo || - (filePath && path__default["default"].dirname(filePath)) || - cwd; - const type = providedType || "config"; - - return { filePath, matchBasePath, name, pluginBasePath, type }; -} - -/** - * Normalize a given plugin. - * - Ensure the object to have four properties: configs, environments, processors, and rules. - * - Ensure the object to not have other properties. - * @param {Plugin} plugin The plugin to normalize. - * @returns {Plugin} The normalized plugin. - */ -function normalizePlugin(plugin) { - - // first check the cache - let normalizedPlugin = normalizedPlugins.get(plugin); - - if (normalizedPlugin) { - return normalizedPlugin; - } - - normalizedPlugin = { - configs: plugin.configs || {}, - environments: plugin.environments || {}, - processors: plugin.processors || {}, - rules: plugin.rules || {} - }; - - // save the reference for later - normalizedPlugins.set(plugin, normalizedPlugin); - - return normalizedPlugin; -} - -//------------------------------------------------------------------------------ -// Public Interface -//------------------------------------------------------------------------------ - -/** - * The factory of `ConfigArray` objects. - */ -class ConfigArrayFactory { - - /** - * Initialize this instance. - * @param {ConfigArrayFactoryOptions} [options] The map for additional plugins. - */ - constructor({ - additionalPluginPool = new Map(), - cwd = process.cwd(), - resolvePluginsRelativeTo, - builtInRules, - resolver = ModuleResolver, - eslintAllPath, - getEslintAllConfig, - eslintRecommendedPath, - getEslintRecommendedConfig - } = {}) { - internalSlotsMap$1.set(this, { - additionalPluginPool, - cwd, - resolvePluginsRelativeTo: - resolvePluginsRelativeTo && - path__default["default"].resolve(cwd, resolvePluginsRelativeTo), - builtInRules, - resolver, - eslintAllPath, - getEslintAllConfig, - eslintRecommendedPath, - getEslintRecommendedConfig - }); - } - - /** - * Create `ConfigArray` instance from a config data. - * @param {ConfigData|null} configData The config data to create. - * @param {Object} [options] The options. - * @param {string} [options.basePath] The base path to resolve relative paths in `overrides[].files`, `overrides[].excludedFiles`, and `ignorePatterns`. - * @param {string} [options.filePath] The path to this config data. - * @param {string} [options.name] The config name. - * @returns {ConfigArray} Loaded config. - */ - create(configData, { basePath, filePath, name } = {}) { - if (!configData) { - return new ConfigArray(); - } - - const slots = internalSlotsMap$1.get(this); - const ctx = createContext(slots, "config", name, filePath, basePath); - const elements = this._normalizeConfigData(configData, ctx); - - return new ConfigArray(...elements); - } - - /** - * Load a config file. - * @param {string} filePath The path to a config file. - * @param {Object} [options] The options. - * @param {string} [options.basePath] The base path to resolve relative paths in `overrides[].files`, `overrides[].excludedFiles`, and `ignorePatterns`. - * @param {string} [options.name] The config name. - * @returns {ConfigArray} Loaded config. - */ - loadFile(filePath, { basePath, name } = {}) { - const slots = internalSlotsMap$1.get(this); - const ctx = createContext(slots, "config", name, filePath, basePath); - - return new ConfigArray(...this._loadConfigData(ctx)); - } - - /** - * Load the config file on a given directory if exists. - * @param {string} directoryPath The path to a directory. - * @param {Object} [options] The options. - * @param {string} [options.basePath] The base path to resolve relative paths in `overrides[].files`, `overrides[].excludedFiles`, and `ignorePatterns`. - * @param {string} [options.name] The config name. - * @returns {ConfigArray} Loaded config. An empty `ConfigArray` if any config doesn't exist. - */ - loadInDirectory(directoryPath, { basePath, name } = {}) { - const slots = internalSlotsMap$1.get(this); - - for (const filename of configFilenames) { - const ctx = createContext( - slots, - "config", - name, - path__default["default"].join(directoryPath, filename), - basePath - ); - - if (fs__default["default"].existsSync(ctx.filePath) && fs__default["default"].statSync(ctx.filePath).isFile()) { - let configData; - - try { - configData = loadConfigFile(ctx.filePath); - } catch (error) { - if (!error || error.code !== "ESLINT_CONFIG_FIELD_NOT_FOUND") { - throw error; - } - } - - if (configData) { - debug$2(`Config file found: ${ctx.filePath}`); - return new ConfigArray( - ...this._normalizeConfigData(configData, ctx) - ); - } - } - } - - debug$2(`Config file not found on ${directoryPath}`); - return new ConfigArray(); - } - - /** - * Check if a config file on a given directory exists or not. - * @param {string} directoryPath The path to a directory. - * @returns {string | null} The path to the found config file. If not found then null. - */ - static getPathToConfigFileInDirectory(directoryPath) { - for (const filename of configFilenames) { - const filePath = path__default["default"].join(directoryPath, filename); - - if (fs__default["default"].existsSync(filePath)) { - if (filename === "package.json") { - try { - loadPackageJSONConfigFile(filePath); - return filePath; - } catch { /* ignore */ } - } else { - return filePath; - } - } - } - return null; - } - - /** - * Load `.eslintignore` file. - * @param {string} filePath The path to a `.eslintignore` file to load. - * @returns {ConfigArray} Loaded config. An empty `ConfigArray` if any config doesn't exist. - */ - loadESLintIgnore(filePath) { - const slots = internalSlotsMap$1.get(this); - const ctx = createContext( - slots, - "ignore", - void 0, - filePath, - slots.cwd - ); - const ignorePatterns = loadESLintIgnoreFile(ctx.filePath); - - return new ConfigArray( - ...this._normalizeESLintIgnoreData(ignorePatterns, ctx) - ); - } - - /** - * Load `.eslintignore` file in the current working directory. - * @returns {ConfigArray} Loaded config. An empty `ConfigArray` if any config doesn't exist. - */ - loadDefaultESLintIgnore() { - const slots = internalSlotsMap$1.get(this); - const eslintIgnorePath = path__default["default"].resolve(slots.cwd, ".eslintignore"); - const packageJsonPath = path__default["default"].resolve(slots.cwd, "package.json"); - - if (fs__default["default"].existsSync(eslintIgnorePath)) { - return this.loadESLintIgnore(eslintIgnorePath); - } - if (fs__default["default"].existsSync(packageJsonPath)) { - const data = loadJSONConfigFile(packageJsonPath); - - if (Object.hasOwnProperty.call(data, "eslintIgnore")) { - if (!Array.isArray(data.eslintIgnore)) { - throw new Error("Package.json eslintIgnore property requires an array of paths"); - } - const ctx = createContext( - slots, - "ignore", - "eslintIgnore in package.json", - packageJsonPath, - slots.cwd - ); - - return new ConfigArray( - ...this._normalizeESLintIgnoreData(data.eslintIgnore, ctx) - ); - } - } - - return new ConfigArray(); - } - - /** - * Load a given config file. - * @param {ConfigArrayFactoryLoadingContext} ctx The loading context. - * @returns {IterableIterator} Loaded config. - * @private - */ - _loadConfigData(ctx) { - return this._normalizeConfigData(loadConfigFile(ctx.filePath), ctx); - } - - /** - * Normalize a given `.eslintignore` data to config array elements. - * @param {string[]} ignorePatterns The patterns to ignore files. - * @param {ConfigArrayFactoryLoadingContext} ctx The loading context. - * @returns {IterableIterator} The normalized config. - * @private - */ - *_normalizeESLintIgnoreData(ignorePatterns, ctx) { - const elements = this._normalizeObjectConfigData( - { ignorePatterns }, - ctx - ); - - // Set `ignorePattern.loose` flag for backward compatibility. - for (const element of elements) { - if (element.ignorePattern) { - element.ignorePattern.loose = true; - } - yield element; - } - } - - /** - * Normalize a given config to an array. - * @param {ConfigData} configData The config data to normalize. - * @param {ConfigArrayFactoryLoadingContext} ctx The loading context. - * @returns {IterableIterator} The normalized config. - * @private - */ - _normalizeConfigData(configData, ctx) { - const validator = new ConfigValidator(); - - validator.validateConfigSchema(configData, ctx.name || ctx.filePath); - return this._normalizeObjectConfigData(configData, ctx); - } - - /** - * Normalize a given config to an array. - * @param {ConfigData|OverrideConfigData} configData The config data to normalize. - * @param {ConfigArrayFactoryLoadingContext} ctx The loading context. - * @returns {IterableIterator} The normalized config. - * @private - */ - *_normalizeObjectConfigData(configData, ctx) { - const { files, excludedFiles, ...configBody } = configData; - const criteria = OverrideTester.create( - files, - excludedFiles, - ctx.matchBasePath - ); - const elements = this._normalizeObjectConfigDataBody(configBody, ctx); - - // Apply the criteria to every element. - for (const element of elements) { - - /* - * Merge the criteria. - * This is for the `overrides` entries that came from the - * configurations of `overrides[].extends`. - */ - element.criteria = OverrideTester.and(criteria, element.criteria); - - /* - * Remove `root` property to ignore `root` settings which came from - * `extends` in `overrides`. - */ - if (element.criteria) { - element.root = void 0; - } - - yield element; - } - } - - /** - * Normalize a given config to an array. - * @param {ConfigData} configData The config data to normalize. - * @param {ConfigArrayFactoryLoadingContext} ctx The loading context. - * @returns {IterableIterator} The normalized config. - * @private - */ - *_normalizeObjectConfigDataBody( - { - env, - extends: extend, - globals, - ignorePatterns, - noInlineConfig, - parser: parserName, - parserOptions, - plugins: pluginList, - processor, - reportUnusedDisableDirectives, - root, - rules, - settings, - overrides: overrideList = [] - }, - ctx - ) { - const extendList = Array.isArray(extend) ? extend : [extend]; - const ignorePattern = ignorePatterns && new IgnorePattern( - Array.isArray(ignorePatterns) ? ignorePatterns : [ignorePatterns], - ctx.matchBasePath - ); - - // Flatten `extends`. - for (const extendName of extendList.filter(Boolean)) { - yield* this._loadExtends(extendName, ctx); - } - - // Load parser & plugins. - const parser = parserName && this._loadParser(parserName, ctx); - const plugins = pluginList && this._loadPlugins(pluginList, ctx); - - // Yield pseudo config data for file extension processors. - if (plugins) { - yield* this._takeFileExtensionProcessors(plugins, ctx); - } - - // Yield the config data except `extends` and `overrides`. - yield { - - // Debug information. - type: ctx.type, - name: ctx.name, - filePath: ctx.filePath, - - // Config data. - criteria: null, - env, - globals, - ignorePattern, - noInlineConfig, - parser, - parserOptions, - plugins, - processor, - reportUnusedDisableDirectives, - root, - rules, - settings - }; - - // Flatten `overries`. - for (let i = 0; i < overrideList.length; ++i) { - yield* this._normalizeObjectConfigData( - overrideList[i], - { ...ctx, name: `${ctx.name}#overrides[${i}]` } - ); - } - } - - /** - * Load configs of an element in `extends`. - * @param {string} extendName The name of a base config. - * @param {ConfigArrayFactoryLoadingContext} ctx The loading context. - * @returns {IterableIterator} The normalized config. - * @private - */ - _loadExtends(extendName, ctx) { - debug$2("Loading {extends:%j} relative to %s", extendName, ctx.filePath); - try { - if (extendName.startsWith("eslint:")) { - return this._loadExtendedBuiltInConfig(extendName, ctx); - } - if (extendName.startsWith("plugin:")) { - return this._loadExtendedPluginConfig(extendName, ctx); - } - return this._loadExtendedShareableConfig(extendName, ctx); - } catch (error) { - error.message += `\nReferenced from: ${ctx.filePath || ctx.name}`; - throw error; - } - } - - /** - * Load configs of an element in `extends`. - * @param {string} extendName The name of a base config. - * @param {ConfigArrayFactoryLoadingContext} ctx The loading context. - * @returns {IterableIterator} The normalized config. - * @private - */ - _loadExtendedBuiltInConfig(extendName, ctx) { - const { - eslintAllPath, - getEslintAllConfig, - eslintRecommendedPath, - getEslintRecommendedConfig - } = internalSlotsMap$1.get(this); - - if (extendName === "eslint:recommended") { - const name = `${ctx.name} ยป ${extendName}`; - - if (getEslintRecommendedConfig) { - if (typeof getEslintRecommendedConfig !== "function") { - throw new Error(`getEslintRecommendedConfig must be a function instead of '${getEslintRecommendedConfig}'`); - } - return this._normalizeConfigData(getEslintRecommendedConfig(), { ...ctx, name, filePath: "" }); - } - return this._loadConfigData({ - ...ctx, - name, - filePath: eslintRecommendedPath - }); - } - if (extendName === "eslint:all") { - const name = `${ctx.name} ยป ${extendName}`; - - if (getEslintAllConfig) { - if (typeof getEslintAllConfig !== "function") { - throw new Error(`getEslintAllConfig must be a function instead of '${getEslintAllConfig}'`); - } - return this._normalizeConfigData(getEslintAllConfig(), { ...ctx, name, filePath: "" }); - } - return this._loadConfigData({ - ...ctx, - name, - filePath: eslintAllPath - }); - } - - throw configInvalidError(extendName, ctx.name, "extend-config-missing"); - } - - /** - * Load configs of an element in `extends`. - * @param {string} extendName The name of a base config. - * @param {ConfigArrayFactoryLoadingContext} ctx The loading context. - * @returns {IterableIterator} The normalized config. - * @private - */ - _loadExtendedPluginConfig(extendName, ctx) { - const slashIndex = extendName.lastIndexOf("/"); - - if (slashIndex === -1) { - throw configInvalidError(extendName, ctx.filePath, "plugin-invalid"); - } - - const pluginName = extendName.slice("plugin:".length, slashIndex); - const configName = extendName.slice(slashIndex + 1); - - if (isFilePath(pluginName)) { - throw new Error("'extends' cannot use a file path for plugins."); - } - - const plugin = this._loadPlugin(pluginName, ctx); - const configData = - plugin.definition && - plugin.definition.configs[configName]; - - if (configData) { - return this._normalizeConfigData(configData, { - ...ctx, - filePath: plugin.filePath || ctx.filePath, - name: `${ctx.name} ยป plugin:${plugin.id}/${configName}` - }); - } - - throw plugin.error || configInvalidError(extendName, ctx.filePath, "extend-config-missing"); - } - - /** - * Load configs of an element in `extends`. - * @param {string} extendName The name of a base config. - * @param {ConfigArrayFactoryLoadingContext} ctx The loading context. - * @returns {IterableIterator} The normalized config. - * @private - */ - _loadExtendedShareableConfig(extendName, ctx) { - const { cwd, resolver } = internalSlotsMap$1.get(this); - const relativeTo = ctx.filePath || path__default["default"].join(cwd, "__placeholder__.js"); - let request; - - if (isFilePath(extendName)) { - request = extendName; - } else if (extendName.startsWith(".")) { - request = `./${extendName}`; // For backward compatibility. A ton of tests depended on this behavior. - } else { - request = normalizePackageName( - extendName, - "eslint-config" - ); - } - - let filePath; - - try { - filePath = resolver.resolve(request, relativeTo); - } catch (error) { - /* istanbul ignore else */ - if (error && error.code === "MODULE_NOT_FOUND") { - throw configInvalidError(extendName, ctx.filePath, "extend-config-missing"); - } - throw error; - } - - writeDebugLogForLoading(request, relativeTo, filePath); - return this._loadConfigData({ - ...ctx, - filePath, - name: `${ctx.name} ยป ${request}` - }); - } - - /** - * Load given plugins. - * @param {string[]} names The plugin names to load. - * @param {ConfigArrayFactoryLoadingContext} ctx The loading context. - * @returns {Record} The loaded parser. - * @private - */ - _loadPlugins(names, ctx) { - return names.reduce((map, name) => { - if (isFilePath(name)) { - throw new Error("Plugins array cannot includes file paths."); - } - const plugin = this._loadPlugin(name, ctx); - - map[plugin.id] = plugin; - - return map; - }, {}); - } - - /** - * Load a given parser. - * @param {string} nameOrPath The package name or the path to a parser file. - * @param {ConfigArrayFactoryLoadingContext} ctx The loading context. - * @returns {DependentParser} The loaded parser. - */ - _loadParser(nameOrPath, ctx) { - debug$2("Loading parser %j from %s", nameOrPath, ctx.filePath); - - const { cwd, resolver } = internalSlotsMap$1.get(this); - const relativeTo = ctx.filePath || path__default["default"].join(cwd, "__placeholder__.js"); - - try { - const filePath = resolver.resolve(nameOrPath, relativeTo); - - writeDebugLogForLoading(nameOrPath, relativeTo, filePath); - - return new ConfigDependency({ - definition: require$1(filePath), - filePath, - id: nameOrPath, - importerName: ctx.name, - importerPath: ctx.filePath - }); - } catch (error) { - - // If the parser name is "espree", load the espree of ESLint. - if (nameOrPath === "espree") { - debug$2("Fallback espree."); - return new ConfigDependency({ - definition: require$1("espree"), - filePath: require$1.resolve("espree"), - id: nameOrPath, - importerName: ctx.name, - importerPath: ctx.filePath - }); - } - - debug$2("Failed to load parser '%s' declared in '%s'.", nameOrPath, ctx.name); - error.message = `Failed to load parser '${nameOrPath}' declared in '${ctx.name}': ${error.message}`; - - return new ConfigDependency({ - error, - id: nameOrPath, - importerName: ctx.name, - importerPath: ctx.filePath - }); - } - } - - /** - * Load a given plugin. - * @param {string} name The plugin name to load. - * @param {ConfigArrayFactoryLoadingContext} ctx The loading context. - * @returns {DependentPlugin} The loaded plugin. - * @private - */ - _loadPlugin(name, ctx) { - debug$2("Loading plugin %j from %s", name, ctx.filePath); - - const { additionalPluginPool, resolver } = internalSlotsMap$1.get(this); - const request = normalizePackageName(name, "eslint-plugin"); - const id = getShorthandName(request, "eslint-plugin"); - const relativeTo = path__default["default"].join(ctx.pluginBasePath, "__placeholder__.js"); - - if (name.match(/\s+/u)) { - const error = Object.assign( - new Error(`Whitespace found in plugin name '${name}'`), - { - messageTemplate: "whitespace-found", - messageData: { pluginName: request } - } - ); - - return new ConfigDependency({ - error, - id, - importerName: ctx.name, - importerPath: ctx.filePath - }); - } - - // Check for additional pool. - const plugin = - additionalPluginPool.get(request) || - additionalPluginPool.get(id); - - if (plugin) { - return new ConfigDependency({ - definition: normalizePlugin(plugin), - original: plugin, - filePath: "", // It's unknown where the plugin came from. - id, - importerName: ctx.name, - importerPath: ctx.filePath - }); - } - - let filePath; - let error; - - try { - filePath = resolver.resolve(request, relativeTo); - } catch (resolveError) { - error = resolveError; - /* istanbul ignore else */ - if (error && error.code === "MODULE_NOT_FOUND") { - error.messageTemplate = "plugin-missing"; - error.messageData = { - pluginName: request, - resolvePluginsRelativeTo: ctx.pluginBasePath, - importerName: ctx.name - }; - } - } - - if (filePath) { - try { - writeDebugLogForLoading(request, relativeTo, filePath); - - const startTime = Date.now(); - const pluginDefinition = require$1(filePath); - - debug$2(`Plugin ${filePath} loaded in: ${Date.now() - startTime}ms`); - - return new ConfigDependency({ - definition: normalizePlugin(pluginDefinition), - original: pluginDefinition, - filePath, - id, - importerName: ctx.name, - importerPath: ctx.filePath - }); - } catch (loadError) { - error = loadError; - } - } - - debug$2("Failed to load plugin '%s' declared in '%s'.", name, ctx.name); - error.message = `Failed to load plugin '${name}' declared in '${ctx.name}': ${error.message}`; - return new ConfigDependency({ - error, - id, - importerName: ctx.name, - importerPath: ctx.filePath - }); - } - - /** - * Take file expression processors as config array elements. - * @param {Record} plugins The plugin definitions. - * @param {ConfigArrayFactoryLoadingContext} ctx The loading context. - * @returns {IterableIterator} The config array elements of file expression processors. - * @private - */ - *_takeFileExtensionProcessors(plugins, ctx) { - for (const pluginId of Object.keys(plugins)) { - const processors = - plugins[pluginId] && - plugins[pluginId].definition && - plugins[pluginId].definition.processors; - - if (!processors) { - continue; - } - - for (const processorId of Object.keys(processors)) { - if (processorId.startsWith(".")) { - yield* this._normalizeObjectConfigData( - { - files: [`*${processorId}`], - processor: `${pluginId}/${processorId}` - }, - { - ...ctx, - type: "implicit-processor", - name: `${ctx.name}#processors["${pluginId}/${processorId}"]` - } - ); - } - } - } - } -} - -/** - * @fileoverview `CascadingConfigArrayFactory` class. - * - * `CascadingConfigArrayFactory` class has a responsibility: - * - * 1. Handles cascading of config files. - * - * It provides two methods: - * - * - `getConfigArrayForFile(filePath)` - * Get the corresponded configuration of a given file. This method doesn't - * throw even if the given file didn't exist. - * - `clearCache()` - * Clear the internal cache. You have to call this method when - * `additionalPluginPool` was updated if `baseConfig` or `cliConfig` depends - * on the additional plugins. (`CLIEngine#addPlugin()` method calls this.) - * - * @author Toru Nagashima - */ - -const debug$1 = debugOrig__default["default"]("eslintrc:cascading-config-array-factory"); - -//------------------------------------------------------------------------------ -// Helpers -//------------------------------------------------------------------------------ - -// Define types for VSCode IntelliSense. -/** @typedef {import("./shared/types").ConfigData} ConfigData */ -/** @typedef {import("./shared/types").Parser} Parser */ -/** @typedef {import("./shared/types").Plugin} Plugin */ -/** @typedef {import("./shared/types").Rule} Rule */ -/** @typedef {ReturnType} ConfigArray */ - -/** - * @typedef {Object} CascadingConfigArrayFactoryOptions - * @property {Map} [additionalPluginPool] The map for additional plugins. - * @property {ConfigData} [baseConfig] The config by `baseConfig` option. - * @property {ConfigData} [cliConfig] The config by CLI options (`--env`, `--global`, `--ignore-pattern`, `--parser`, `--parser-options`, `--plugin`, and `--rule`). CLI options overwrite the setting in config files. - * @property {string} [cwd] The base directory to start lookup. - * @property {string} [ignorePath] The path to the alternative file of `.eslintignore`. - * @property {string[]} [rulePaths] The value of `--rulesdir` option. - * @property {string} [specificConfigPath] The value of `--config` option. - * @property {boolean} [useEslintrc] if `false` then it doesn't load config files. - * @property {Function} loadRules The function to use to load rules. - * @property {Map} builtInRules The rules that are built in to ESLint. - * @property {Object} [resolver=ModuleResolver] The module resolver object. - * @property {string} eslintAllPath The path to the definitions for eslint:all. - * @property {Function} getEslintAllConfig Returns the config data for eslint:all. - * @property {string} eslintRecommendedPath The path to the definitions for eslint:recommended. - * @property {Function} getEslintRecommendedConfig Returns the config data for eslint:recommended. - */ - -/** - * @typedef {Object} CascadingConfigArrayFactoryInternalSlots - * @property {ConfigArray} baseConfigArray The config array of `baseConfig` option. - * @property {ConfigData} baseConfigData The config data of `baseConfig` option. This is used to reset `baseConfigArray`. - * @property {ConfigArray} cliConfigArray The config array of CLI options. - * @property {ConfigData} cliConfigData The config data of CLI options. This is used to reset `cliConfigArray`. - * @property {ConfigArrayFactory} configArrayFactory The factory for config arrays. - * @property {Map} configCache The cache from directory paths to config arrays. - * @property {string} cwd The base directory to start lookup. - * @property {WeakMap} finalizeCache The cache from config arrays to finalized config arrays. - * @property {string} [ignorePath] The path to the alternative file of `.eslintignore`. - * @property {string[]|null} rulePaths The value of `--rulesdir` option. This is used to reset `baseConfigArray`. - * @property {string|null} specificConfigPath The value of `--config` option. This is used to reset `cliConfigArray`. - * @property {boolean} useEslintrc if `false` then it doesn't load config files. - * @property {Function} loadRules The function to use to load rules. - * @property {Map} builtInRules The rules that are built in to ESLint. - * @property {Object} [resolver=ModuleResolver] The module resolver object. - * @property {string} eslintAllPath The path to the definitions for eslint:all. - * @property {Function} getEslintAllConfig Returns the config data for eslint:all. - * @property {string} eslintRecommendedPath The path to the definitions for eslint:recommended. - * @property {Function} getEslintRecommendedConfig Returns the config data for eslint:recommended. - */ - -/** @type {WeakMap} */ -const internalSlotsMap = new WeakMap(); - -/** - * Create the config array from `baseConfig` and `rulePaths`. - * @param {CascadingConfigArrayFactoryInternalSlots} slots The slots. - * @returns {ConfigArray} The config array of the base configs. - */ -function createBaseConfigArray({ - configArrayFactory, - baseConfigData, - rulePaths, - cwd, - loadRules -}) { - const baseConfigArray = configArrayFactory.create( - baseConfigData, - { name: "BaseConfig" } - ); - - /* - * Create the config array element for the default ignore patterns. - * This element has `ignorePattern` property that ignores the default - * patterns in the current working directory. - */ - baseConfigArray.unshift(configArrayFactory.create( - { ignorePatterns: IgnorePattern.DefaultPatterns }, - { name: "DefaultIgnorePattern" } - )[0]); - - /* - * Load rules `--rulesdir` option as a pseudo plugin. - * Use a pseudo plugin to define rules of `--rulesdir`, so we can validate - * the rule's options with only information in the config array. - */ - if (rulePaths && rulePaths.length > 0) { - baseConfigArray.push({ - type: "config", - name: "--rulesdir", - filePath: "", - plugins: { - "": new ConfigDependency({ - definition: { - rules: rulePaths.reduce( - (map, rulesPath) => Object.assign( - map, - loadRules(rulesPath, cwd) - ), - {} - ) - }, - filePath: "", - id: "", - importerName: "--rulesdir", - importerPath: "" - }) - } - }); - } - - return baseConfigArray; -} - -/** - * Create the config array from CLI options. - * @param {CascadingConfigArrayFactoryInternalSlots} slots The slots. - * @returns {ConfigArray} The config array of the base configs. - */ -function createCLIConfigArray({ - cliConfigData, - configArrayFactory, - cwd, - ignorePath, - specificConfigPath -}) { - const cliConfigArray = configArrayFactory.create( - cliConfigData, - { name: "CLIOptions" } - ); - - cliConfigArray.unshift( - ...(ignorePath - ? configArrayFactory.loadESLintIgnore(ignorePath) - : configArrayFactory.loadDefaultESLintIgnore()) - ); - - if (specificConfigPath) { - cliConfigArray.unshift( - ...configArrayFactory.loadFile( - specificConfigPath, - { name: "--config", basePath: cwd } - ) - ); - } - - return cliConfigArray; -} - -/** - * The error type when there are files matched by a glob, but all of them have been ignored. - */ -class ConfigurationNotFoundError extends Error { - - // eslint-disable-next-line jsdoc/require-description - /** - * @param {string} directoryPath The directory path. - */ - constructor(directoryPath) { - super(`No ESLint configuration found in ${directoryPath}.`); - this.messageTemplate = "no-config-found"; - this.messageData = { directoryPath }; - } -} - -/** - * This class provides the functionality that enumerates every file which is - * matched by given glob patterns and that configuration. - */ -class CascadingConfigArrayFactory { - - /** - * Initialize this enumerator. - * @param {CascadingConfigArrayFactoryOptions} options The options. - */ - constructor({ - additionalPluginPool = new Map(), - baseConfig: baseConfigData = null, - cliConfig: cliConfigData = null, - cwd = process.cwd(), - ignorePath, - resolvePluginsRelativeTo, - rulePaths = [], - specificConfigPath = null, - useEslintrc = true, - builtInRules = new Map(), - loadRules, - resolver, - eslintRecommendedPath, - getEslintRecommendedConfig, - eslintAllPath, - getEslintAllConfig - } = {}) { - const configArrayFactory = new ConfigArrayFactory({ - additionalPluginPool, - cwd, - resolvePluginsRelativeTo, - builtInRules, - resolver, - eslintRecommendedPath, - getEslintRecommendedConfig, - eslintAllPath, - getEslintAllConfig - }); - - internalSlotsMap.set(this, { - baseConfigArray: createBaseConfigArray({ - baseConfigData, - configArrayFactory, - cwd, - rulePaths, - loadRules - }), - baseConfigData, - cliConfigArray: createCLIConfigArray({ - cliConfigData, - configArrayFactory, - cwd, - ignorePath, - specificConfigPath - }), - cliConfigData, - configArrayFactory, - configCache: new Map(), - cwd, - finalizeCache: new WeakMap(), - ignorePath, - rulePaths, - specificConfigPath, - useEslintrc, - builtInRules, - loadRules - }); - } - - /** - * The path to the current working directory. - * This is used by tests. - * @type {string} - */ - get cwd() { - const { cwd } = internalSlotsMap.get(this); - - return cwd; - } - - /** - * Get the config array of a given file. - * If `filePath` was not given, it returns the config which contains only - * `baseConfigData` and `cliConfigData`. - * @param {string} [filePath] The file path to a file. - * @param {Object} [options] The options. - * @param {boolean} [options.ignoreNotFoundError] If `true` then it doesn't throw `ConfigurationNotFoundError`. - * @returns {ConfigArray} The config array of the file. - */ - getConfigArrayForFile(filePath, { ignoreNotFoundError = false } = {}) { - const { - baseConfigArray, - cliConfigArray, - cwd - } = internalSlotsMap.get(this); - - if (!filePath) { - return new ConfigArray(...baseConfigArray, ...cliConfigArray); - } - - const directoryPath = path__default["default"].dirname(path__default["default"].resolve(cwd, filePath)); - - debug$1(`Load config files for ${directoryPath}.`); - - return this._finalizeConfigArray( - this._loadConfigInAncestors(directoryPath), - directoryPath, - ignoreNotFoundError - ); - } - - /** - * Set the config data to override all configs. - * Require to call `clearCache()` method after this method is called. - * @param {ConfigData} configData The config data to override all configs. - * @returns {void} - */ - setOverrideConfig(configData) { - const slots = internalSlotsMap.get(this); - - slots.cliConfigData = configData; - } - - /** - * Clear config cache. - * @returns {void} - */ - clearCache() { - const slots = internalSlotsMap.get(this); - - slots.baseConfigArray = createBaseConfigArray(slots); - slots.cliConfigArray = createCLIConfigArray(slots); - slots.configCache.clear(); - } - - /** - * Load and normalize config files from the ancestor directories. - * @param {string} directoryPath The path to a leaf directory. - * @param {boolean} configsExistInSubdirs `true` if configurations exist in subdirectories. - * @returns {ConfigArray} The loaded config. - * @private - */ - _loadConfigInAncestors(directoryPath, configsExistInSubdirs = false) { - const { - baseConfigArray, - configArrayFactory, - configCache, - cwd, - useEslintrc - } = internalSlotsMap.get(this); - - if (!useEslintrc) { - return baseConfigArray; - } - - let configArray = configCache.get(directoryPath); - - // Hit cache. - if (configArray) { - debug$1(`Cache hit: ${directoryPath}.`); - return configArray; - } - debug$1(`No cache found: ${directoryPath}.`); - - const homePath = os__default["default"].homedir(); - - // Consider this is root. - if (directoryPath === homePath && cwd !== homePath) { - debug$1("Stop traversing because of considered root."); - if (configsExistInSubdirs) { - const filePath = ConfigArrayFactory.getPathToConfigFileInDirectory(directoryPath); - - if (filePath) { - emitDeprecationWarning( - filePath, - "ESLINT_PERSONAL_CONFIG_SUPPRESS" - ); - } - } - return this._cacheConfig(directoryPath, baseConfigArray); - } - - // Load the config on this directory. - try { - configArray = configArrayFactory.loadInDirectory(directoryPath); - } catch (error) { - /* istanbul ignore next */ - if (error.code === "EACCES") { - debug$1("Stop traversing because of 'EACCES' error."); - return this._cacheConfig(directoryPath, baseConfigArray); - } - throw error; - } - - if (configArray.length > 0 && configArray.isRoot()) { - debug$1("Stop traversing because of 'root:true'."); - configArray.unshift(...baseConfigArray); - return this._cacheConfig(directoryPath, configArray); - } - - // Load from the ancestors and merge it. - const parentPath = path__default["default"].dirname(directoryPath); - const parentConfigArray = parentPath && parentPath !== directoryPath - ? this._loadConfigInAncestors( - parentPath, - configsExistInSubdirs || configArray.length > 0 - ) - : baseConfigArray; - - if (configArray.length > 0) { - configArray.unshift(...parentConfigArray); - } else { - configArray = parentConfigArray; - } - - // Cache and return. - return this._cacheConfig(directoryPath, configArray); - } - - /** - * Freeze and cache a given config. - * @param {string} directoryPath The path to a directory as a cache key. - * @param {ConfigArray} configArray The config array as a cache value. - * @returns {ConfigArray} The `configArray` (frozen). - */ - _cacheConfig(directoryPath, configArray) { - const { configCache } = internalSlotsMap.get(this); - - Object.freeze(configArray); - configCache.set(directoryPath, configArray); - - return configArray; - } - - /** - * Finalize a given config array. - * Concatenate `--config` and other CLI options. - * @param {ConfigArray} configArray The parent config array. - * @param {string} directoryPath The path to the leaf directory to find config files. - * @param {boolean} ignoreNotFoundError If `true` then it doesn't throw `ConfigurationNotFoundError`. - * @returns {ConfigArray} The loaded config. - * @private - */ - _finalizeConfigArray(configArray, directoryPath, ignoreNotFoundError) { - const { - cliConfigArray, - configArrayFactory, - finalizeCache, - useEslintrc, - builtInRules - } = internalSlotsMap.get(this); - - let finalConfigArray = finalizeCache.get(configArray); - - if (!finalConfigArray) { - finalConfigArray = configArray; - - // Load the personal config if there are no regular config files. - if ( - useEslintrc && - configArray.every(c => !c.filePath) && - cliConfigArray.every(c => !c.filePath) // `--config` option can be a file. - ) { - const homePath = os__default["default"].homedir(); - - debug$1("Loading the config file of the home directory:", homePath); - - const personalConfigArray = configArrayFactory.loadInDirectory( - homePath, - { name: "PersonalConfig" } - ); - - if ( - personalConfigArray.length > 0 && - !directoryPath.startsWith(homePath) - ) { - const lastElement = - personalConfigArray[personalConfigArray.length - 1]; - - emitDeprecationWarning( - lastElement.filePath, - "ESLINT_PERSONAL_CONFIG_LOAD" - ); - } - - finalConfigArray = finalConfigArray.concat(personalConfigArray); - } - - // Apply CLI options. - if (cliConfigArray.length > 0) { - finalConfigArray = finalConfigArray.concat(cliConfigArray); - } - - // Validate rule settings and environments. - const validator = new ConfigValidator({ - builtInRules - }); - - validator.validateConfigArray(finalConfigArray); - - // Cache it. - Object.freeze(finalConfigArray); - finalizeCache.set(configArray, finalConfigArray); - - debug$1( - "Configuration was determined: %o on %s", - finalConfigArray, - directoryPath - ); - } - - // At least one element (the default ignore patterns) exists. - if (!ignoreNotFoundError && useEslintrc && finalConfigArray.length <= 1) { - throw new ConfigurationNotFoundError(directoryPath); - } - - return finalConfigArray; - } -} - -/** - * @fileoverview Compatibility class for flat config. - * @author Nicholas C. Zakas - */ - -//----------------------------------------------------------------------------- -// Helpers -//----------------------------------------------------------------------------- - -/** @typedef {import("../../shared/types").Environment} Environment */ -/** @typedef {import("../../shared/types").Processor} Processor */ - -const debug = debugOrig__default["default"]("eslintrc:flat-compat"); -const cafactory = Symbol("cafactory"); - -/** - * Translates an ESLintRC-style config object into a flag-config-style config - * object. - * @param {Object} eslintrcConfig An ESLintRC-style config object. - * @param {Object} options Options to help translate the config. - * @param {string} options.resolveConfigRelativeTo To the directory to resolve - * configs from. - * @param {string} options.resolvePluginsRelativeTo The directory to resolve - * plugins from. - * @param {ReadOnlyMap} options.pluginEnvironments A map of plugin environment - * names to objects. - * @param {ReadOnlyMap} options.pluginProcessors A map of plugin processor - * names to objects. - * @returns {Object} A flag-config-style config object. - */ -function translateESLintRC(eslintrcConfig, { - resolveConfigRelativeTo, - resolvePluginsRelativeTo, - pluginEnvironments, - pluginProcessors -}) { - - const flatConfig = {}; - const configs = []; - const languageOptions = {}; - const linterOptions = {}; - const keysToCopy = ["settings", "rules", "processor"]; - const languageOptionsKeysToCopy = ["globals", "parser", "parserOptions"]; - const linterOptionsKeysToCopy = ["noInlineConfig", "reportUnusedDisableDirectives"]; - - // copy over simple translations - for (const key of keysToCopy) { - if (key in eslintrcConfig && typeof eslintrcConfig[key] !== "undefined") { - flatConfig[key] = eslintrcConfig[key]; - } - } - - // copy over languageOptions - for (const key of languageOptionsKeysToCopy) { - if (key in eslintrcConfig && typeof eslintrcConfig[key] !== "undefined") { - - // create the languageOptions key in the flat config - flatConfig.languageOptions = languageOptions; - - if (key === "parser") { - debug(`Resolving parser '${languageOptions[key]}' relative to ${resolveConfigRelativeTo}`); - - if (eslintrcConfig[key].error) { - throw eslintrcConfig[key].error; - } - - languageOptions[key] = eslintrcConfig[key].definition; - continue; - } - - // clone any object values that are in the eslintrc config - if (eslintrcConfig[key] && typeof eslintrcConfig[key] === "object") { - languageOptions[key] = { - ...eslintrcConfig[key] - }; - } else { - languageOptions[key] = eslintrcConfig[key]; - } - } - } - - // copy over linterOptions - for (const key of linterOptionsKeysToCopy) { - if (key in eslintrcConfig && typeof eslintrcConfig[key] !== "undefined") { - flatConfig.linterOptions = linterOptions; - linterOptions[key] = eslintrcConfig[key]; - } - } - - // move ecmaVersion a level up - if (languageOptions.parserOptions) { - - if ("ecmaVersion" in languageOptions.parserOptions) { - languageOptions.ecmaVersion = languageOptions.parserOptions.ecmaVersion; - delete languageOptions.parserOptions.ecmaVersion; - } - - if ("sourceType" in languageOptions.parserOptions) { - languageOptions.sourceType = languageOptions.parserOptions.sourceType; - delete languageOptions.parserOptions.sourceType; - } - - // check to see if we even need parserOptions anymore and remove it if not - if (Object.keys(languageOptions.parserOptions).length === 0) { - delete languageOptions.parserOptions; - } - } - - // overrides - if (eslintrcConfig.criteria) { - flatConfig.files = [absoluteFilePath => eslintrcConfig.criteria.test(absoluteFilePath)]; - } - - // translate plugins - if (eslintrcConfig.plugins && typeof eslintrcConfig.plugins === "object") { - debug(`Translating plugins: ${eslintrcConfig.plugins}`); - - flatConfig.plugins = {}; - - for (const pluginName of Object.keys(eslintrcConfig.plugins)) { - - debug(`Translating plugin: ${pluginName}`); - debug(`Resolving plugin '${pluginName} relative to ${resolvePluginsRelativeTo}`); - - const { original: plugin, error } = eslintrcConfig.plugins[pluginName]; - - if (error) { - throw error; - } - - flatConfig.plugins[pluginName] = plugin; - - // create a config for any processors - if (plugin.processors) { - for (const processorName of Object.keys(plugin.processors)) { - if (processorName.startsWith(".")) { - debug(`Assigning processor: ${pluginName}/${processorName}`); - - configs.unshift({ - files: [`**/*${processorName}`], - processor: pluginProcessors.get(`${pluginName}/${processorName}`) - }); - } - - } - } - } - } - - // translate env - must come after plugins - if (eslintrcConfig.env && typeof eslintrcConfig.env === "object") { - for (const envName of Object.keys(eslintrcConfig.env)) { - - // only add environments that are true - if (eslintrcConfig.env[envName]) { - debug(`Translating environment: ${envName}`); - - if (environments.has(envName)) { - - // built-in environments should be defined first - configs.unshift(...translateESLintRC({ - criteria: eslintrcConfig.criteria, - ...environments.get(envName) - }, { - resolveConfigRelativeTo, - resolvePluginsRelativeTo - })); - } else if (pluginEnvironments.has(envName)) { - - // if the environment comes from a plugin, it should come after the plugin config - configs.push(...translateESLintRC({ - criteria: eslintrcConfig.criteria, - ...pluginEnvironments.get(envName) - }, { - resolveConfigRelativeTo, - resolvePluginsRelativeTo - })); - } - } - } - } - - // only add if there are actually keys in the config - if (Object.keys(flatConfig).length > 0) { - configs.push(flatConfig); - } - - return configs; -} - - -//----------------------------------------------------------------------------- -// Exports -//----------------------------------------------------------------------------- - -/** - * A compatibility class for working with configs. - */ -class FlatCompat { - - constructor({ - baseDirectory = process.cwd(), - resolvePluginsRelativeTo = baseDirectory, - recommendedConfig, - allConfig - } = {}) { - this.baseDirectory = baseDirectory; - this.resolvePluginsRelativeTo = resolvePluginsRelativeTo; - this[cafactory] = new ConfigArrayFactory({ - cwd: baseDirectory, - resolvePluginsRelativeTo, - getEslintAllConfig: () => { - - if (!allConfig) { - throw new TypeError("Missing parameter 'allConfig' in FlatCompat constructor."); - } - - return allConfig; - }, - getEslintRecommendedConfig: () => { - - if (!recommendedConfig) { - throw new TypeError("Missing parameter 'recommendedConfig' in FlatCompat constructor."); - } - - return recommendedConfig; - } - }); - } - - /** - * Translates an ESLintRC-style config into a flag-config-style config. - * @param {Object} eslintrcConfig The ESLintRC-style config object. - * @returns {Object} A flag-config-style config object. - */ - config(eslintrcConfig) { - const eslintrcArray = this[cafactory].create(eslintrcConfig, { - basePath: this.baseDirectory - }); - - const flatArray = []; - let hasIgnorePatterns = false; - - eslintrcArray.forEach(configData => { - if (configData.type === "config") { - hasIgnorePatterns = hasIgnorePatterns || configData.ignorePattern; - flatArray.push(...translateESLintRC(configData, { - resolveConfigRelativeTo: path__default["default"].join(this.baseDirectory, "__placeholder.js"), - resolvePluginsRelativeTo: path__default["default"].join(this.resolvePluginsRelativeTo, "__placeholder.js"), - pluginEnvironments: eslintrcArray.pluginEnvironments, - pluginProcessors: eslintrcArray.pluginProcessors - })); - } - }); - - // combine ignorePatterns to emulate ESLintRC behavior better - if (hasIgnorePatterns) { - flatArray.unshift({ - ignores: [filePath => { - - // Compute the final config for this file. - // This filters config array elements by `files`/`excludedFiles` then merges the elements. - const finalConfig = eslintrcArray.extractConfig(filePath); - - // Test the `ignorePattern` properties of the final config. - return Boolean(finalConfig.ignores) && finalConfig.ignores(filePath); - }] - }); - } - - return flatArray; - } - - /** - * Translates the `env` section of an ESLintRC-style config. - * @param {Object} envConfig The `env` section of an ESLintRC config. - * @returns {Object[]} An array of flag-config objects representing the environments. - */ - env(envConfig) { - return this.config({ - env: envConfig - }); - } - - /** - * Translates the `extends` section of an ESLintRC-style config. - * @param {...string} configsToExtend The names of the configs to load. - * @returns {Object[]} An array of flag-config objects representing the config. - */ - extends(...configsToExtend) { - return this.config({ - extends: configsToExtend - }); - } - - /** - * Translates the `plugins` section of an ESLintRC-style config. - * @param {...string} plugins The names of the plugins to load. - * @returns {Object[]} An array of flag-config objects representing the plugins. - */ - plugins(...plugins) { - return this.config({ - plugins - }); - } -} - -/** - * @fileoverview Package exports for @eslint/eslintrc - * @author Nicholas C. Zakas - */ - -//----------------------------------------------------------------------------- -// Exports -//----------------------------------------------------------------------------- - -const Legacy = { - ConfigArray, - createConfigArrayFactoryContext: createContext, - CascadingConfigArrayFactory, - ConfigArrayFactory, - ConfigDependency, - ExtractedConfig, - IgnorePattern, - OverrideTester, - getUsedExtractedConfigs, - environments, - loadConfigFile, - - // shared - ConfigOps, - ConfigValidator, - ModuleResolver, - naming -}; - -exports.FlatCompat = FlatCompat; -exports.Legacy = Legacy; -//# sourceMappingURL=eslintrc.cjs.map diff --git a/tools/eslint/node_modules/@eslint/eslintrc/lib/cascading-config-array-factory.js b/tools/eslint/node_modules/@eslint/eslintrc/lib/cascading-config-array-factory.js deleted file mode 100644 index 597352e4394e6e..00000000000000 --- a/tools/eslint/node_modules/@eslint/eslintrc/lib/cascading-config-array-factory.js +++ /dev/null @@ -1,532 +0,0 @@ -/** - * @fileoverview `CascadingConfigArrayFactory` class. - * - * `CascadingConfigArrayFactory` class has a responsibility: - * - * 1. Handles cascading of config files. - * - * It provides two methods: - * - * - `getConfigArrayForFile(filePath)` - * Get the corresponded configuration of a given file. This method doesn't - * throw even if the given file didn't exist. - * - `clearCache()` - * Clear the internal cache. You have to call this method when - * `additionalPluginPool` was updated if `baseConfig` or `cliConfig` depends - * on the additional plugins. (`CLIEngine#addPlugin()` method calls this.) - * - * @author Toru Nagashima - */ - -//------------------------------------------------------------------------------ -// Requirements -//------------------------------------------------------------------------------ - -import debugOrig from "debug"; -import os from "os"; -import path from "path"; - -import { ConfigArrayFactory } from "./config-array-factory.js"; -import { - ConfigArray, - ConfigDependency, - IgnorePattern -} from "./config-array/index.js"; -import ConfigValidator from "./shared/config-validator.js"; -import { emitDeprecationWarning } from "./shared/deprecation-warnings.js"; - -const debug = debugOrig("eslintrc:cascading-config-array-factory"); - -//------------------------------------------------------------------------------ -// Helpers -//------------------------------------------------------------------------------ - -// Define types for VSCode IntelliSense. -/** @typedef {import("./shared/types").ConfigData} ConfigData */ -/** @typedef {import("./shared/types").Parser} Parser */ -/** @typedef {import("./shared/types").Plugin} Plugin */ -/** @typedef {import("./shared/types").Rule} Rule */ -/** @typedef {ReturnType} ConfigArray */ - -/** - * @typedef {Object} CascadingConfigArrayFactoryOptions - * @property {Map} [additionalPluginPool] The map for additional plugins. - * @property {ConfigData} [baseConfig] The config by `baseConfig` option. - * @property {ConfigData} [cliConfig] The config by CLI options (`--env`, `--global`, `--ignore-pattern`, `--parser`, `--parser-options`, `--plugin`, and `--rule`). CLI options overwrite the setting in config files. - * @property {string} [cwd] The base directory to start lookup. - * @property {string} [ignorePath] The path to the alternative file of `.eslintignore`. - * @property {string[]} [rulePaths] The value of `--rulesdir` option. - * @property {string} [specificConfigPath] The value of `--config` option. - * @property {boolean} [useEslintrc] if `false` then it doesn't load config files. - * @property {Function} loadRules The function to use to load rules. - * @property {Map} builtInRules The rules that are built in to ESLint. - * @property {Object} [resolver=ModuleResolver] The module resolver object. - * @property {string} eslintAllPath The path to the definitions for eslint:all. - * @property {Function} getEslintAllConfig Returns the config data for eslint:all. - * @property {string} eslintRecommendedPath The path to the definitions for eslint:recommended. - * @property {Function} getEslintRecommendedConfig Returns the config data for eslint:recommended. - */ - -/** - * @typedef {Object} CascadingConfigArrayFactoryInternalSlots - * @property {ConfigArray} baseConfigArray The config array of `baseConfig` option. - * @property {ConfigData} baseConfigData The config data of `baseConfig` option. This is used to reset `baseConfigArray`. - * @property {ConfigArray} cliConfigArray The config array of CLI options. - * @property {ConfigData} cliConfigData The config data of CLI options. This is used to reset `cliConfigArray`. - * @property {ConfigArrayFactory} configArrayFactory The factory for config arrays. - * @property {Map} configCache The cache from directory paths to config arrays. - * @property {string} cwd The base directory to start lookup. - * @property {WeakMap} finalizeCache The cache from config arrays to finalized config arrays. - * @property {string} [ignorePath] The path to the alternative file of `.eslintignore`. - * @property {string[]|null} rulePaths The value of `--rulesdir` option. This is used to reset `baseConfigArray`. - * @property {string|null} specificConfigPath The value of `--config` option. This is used to reset `cliConfigArray`. - * @property {boolean} useEslintrc if `false` then it doesn't load config files. - * @property {Function} loadRules The function to use to load rules. - * @property {Map} builtInRules The rules that are built in to ESLint. - * @property {Object} [resolver=ModuleResolver] The module resolver object. - * @property {string} eslintAllPath The path to the definitions for eslint:all. - * @property {Function} getEslintAllConfig Returns the config data for eslint:all. - * @property {string} eslintRecommendedPath The path to the definitions for eslint:recommended. - * @property {Function} getEslintRecommendedConfig Returns the config data for eslint:recommended. - */ - -/** @type {WeakMap} */ -const internalSlotsMap = new WeakMap(); - -/** - * Create the config array from `baseConfig` and `rulePaths`. - * @param {CascadingConfigArrayFactoryInternalSlots} slots The slots. - * @returns {ConfigArray} The config array of the base configs. - */ -function createBaseConfigArray({ - configArrayFactory, - baseConfigData, - rulePaths, - cwd, - loadRules -}) { - const baseConfigArray = configArrayFactory.create( - baseConfigData, - { name: "BaseConfig" } - ); - - /* - * Create the config array element for the default ignore patterns. - * This element has `ignorePattern` property that ignores the default - * patterns in the current working directory. - */ - baseConfigArray.unshift(configArrayFactory.create( - { ignorePatterns: IgnorePattern.DefaultPatterns }, - { name: "DefaultIgnorePattern" } - )[0]); - - /* - * Load rules `--rulesdir` option as a pseudo plugin. - * Use a pseudo plugin to define rules of `--rulesdir`, so we can validate - * the rule's options with only information in the config array. - */ - if (rulePaths && rulePaths.length > 0) { - baseConfigArray.push({ - type: "config", - name: "--rulesdir", - filePath: "", - plugins: { - "": new ConfigDependency({ - definition: { - rules: rulePaths.reduce( - (map, rulesPath) => Object.assign( - map, - loadRules(rulesPath, cwd) - ), - {} - ) - }, - filePath: "", - id: "", - importerName: "--rulesdir", - importerPath: "" - }) - } - }); - } - - return baseConfigArray; -} - -/** - * Create the config array from CLI options. - * @param {CascadingConfigArrayFactoryInternalSlots} slots The slots. - * @returns {ConfigArray} The config array of the base configs. - */ -function createCLIConfigArray({ - cliConfigData, - configArrayFactory, - cwd, - ignorePath, - specificConfigPath -}) { - const cliConfigArray = configArrayFactory.create( - cliConfigData, - { name: "CLIOptions" } - ); - - cliConfigArray.unshift( - ...(ignorePath - ? configArrayFactory.loadESLintIgnore(ignorePath) - : configArrayFactory.loadDefaultESLintIgnore()) - ); - - if (specificConfigPath) { - cliConfigArray.unshift( - ...configArrayFactory.loadFile( - specificConfigPath, - { name: "--config", basePath: cwd } - ) - ); - } - - return cliConfigArray; -} - -/** - * The error type when there are files matched by a glob, but all of them have been ignored. - */ -class ConfigurationNotFoundError extends Error { - - // eslint-disable-next-line jsdoc/require-description - /** - * @param {string} directoryPath The directory path. - */ - constructor(directoryPath) { - super(`No ESLint configuration found in ${directoryPath}.`); - this.messageTemplate = "no-config-found"; - this.messageData = { directoryPath }; - } -} - -/** - * This class provides the functionality that enumerates every file which is - * matched by given glob patterns and that configuration. - */ -class CascadingConfigArrayFactory { - - /** - * Initialize this enumerator. - * @param {CascadingConfigArrayFactoryOptions} options The options. - */ - constructor({ - additionalPluginPool = new Map(), - baseConfig: baseConfigData = null, - cliConfig: cliConfigData = null, - cwd = process.cwd(), - ignorePath, - resolvePluginsRelativeTo, - rulePaths = [], - specificConfigPath = null, - useEslintrc = true, - builtInRules = new Map(), - loadRules, - resolver, - eslintRecommendedPath, - getEslintRecommendedConfig, - eslintAllPath, - getEslintAllConfig - } = {}) { - const configArrayFactory = new ConfigArrayFactory({ - additionalPluginPool, - cwd, - resolvePluginsRelativeTo, - builtInRules, - resolver, - eslintRecommendedPath, - getEslintRecommendedConfig, - eslintAllPath, - getEslintAllConfig - }); - - internalSlotsMap.set(this, { - baseConfigArray: createBaseConfigArray({ - baseConfigData, - configArrayFactory, - cwd, - rulePaths, - loadRules - }), - baseConfigData, - cliConfigArray: createCLIConfigArray({ - cliConfigData, - configArrayFactory, - cwd, - ignorePath, - specificConfigPath - }), - cliConfigData, - configArrayFactory, - configCache: new Map(), - cwd, - finalizeCache: new WeakMap(), - ignorePath, - rulePaths, - specificConfigPath, - useEslintrc, - builtInRules, - loadRules - }); - } - - /** - * The path to the current working directory. - * This is used by tests. - * @type {string} - */ - get cwd() { - const { cwd } = internalSlotsMap.get(this); - - return cwd; - } - - /** - * Get the config array of a given file. - * If `filePath` was not given, it returns the config which contains only - * `baseConfigData` and `cliConfigData`. - * @param {string} [filePath] The file path to a file. - * @param {Object} [options] The options. - * @param {boolean} [options.ignoreNotFoundError] If `true` then it doesn't throw `ConfigurationNotFoundError`. - * @returns {ConfigArray} The config array of the file. - */ - getConfigArrayForFile(filePath, { ignoreNotFoundError = false } = {}) { - const { - baseConfigArray, - cliConfigArray, - cwd - } = internalSlotsMap.get(this); - - if (!filePath) { - return new ConfigArray(...baseConfigArray, ...cliConfigArray); - } - - const directoryPath = path.dirname(path.resolve(cwd, filePath)); - - debug(`Load config files for ${directoryPath}.`); - - return this._finalizeConfigArray( - this._loadConfigInAncestors(directoryPath), - directoryPath, - ignoreNotFoundError - ); - } - - /** - * Set the config data to override all configs. - * Require to call `clearCache()` method after this method is called. - * @param {ConfigData} configData The config data to override all configs. - * @returns {void} - */ - setOverrideConfig(configData) { - const slots = internalSlotsMap.get(this); - - slots.cliConfigData = configData; - } - - /** - * Clear config cache. - * @returns {void} - */ - clearCache() { - const slots = internalSlotsMap.get(this); - - slots.baseConfigArray = createBaseConfigArray(slots); - slots.cliConfigArray = createCLIConfigArray(slots); - slots.configCache.clear(); - } - - /** - * Load and normalize config files from the ancestor directories. - * @param {string} directoryPath The path to a leaf directory. - * @param {boolean} configsExistInSubdirs `true` if configurations exist in subdirectories. - * @returns {ConfigArray} The loaded config. - * @private - */ - _loadConfigInAncestors(directoryPath, configsExistInSubdirs = false) { - const { - baseConfigArray, - configArrayFactory, - configCache, - cwd, - useEslintrc - } = internalSlotsMap.get(this); - - if (!useEslintrc) { - return baseConfigArray; - } - - let configArray = configCache.get(directoryPath); - - // Hit cache. - if (configArray) { - debug(`Cache hit: ${directoryPath}.`); - return configArray; - } - debug(`No cache found: ${directoryPath}.`); - - const homePath = os.homedir(); - - // Consider this is root. - if (directoryPath === homePath && cwd !== homePath) { - debug("Stop traversing because of considered root."); - if (configsExistInSubdirs) { - const filePath = ConfigArrayFactory.getPathToConfigFileInDirectory(directoryPath); - - if (filePath) { - emitDeprecationWarning( - filePath, - "ESLINT_PERSONAL_CONFIG_SUPPRESS" - ); - } - } - return this._cacheConfig(directoryPath, baseConfigArray); - } - - // Load the config on this directory. - try { - configArray = configArrayFactory.loadInDirectory(directoryPath); - } catch (error) { - /* istanbul ignore next */ - if (error.code === "EACCES") { - debug("Stop traversing because of 'EACCES' error."); - return this._cacheConfig(directoryPath, baseConfigArray); - } - throw error; - } - - if (configArray.length > 0 && configArray.isRoot()) { - debug("Stop traversing because of 'root:true'."); - configArray.unshift(...baseConfigArray); - return this._cacheConfig(directoryPath, configArray); - } - - // Load from the ancestors and merge it. - const parentPath = path.dirname(directoryPath); - const parentConfigArray = parentPath && parentPath !== directoryPath - ? this._loadConfigInAncestors( - parentPath, - configsExistInSubdirs || configArray.length > 0 - ) - : baseConfigArray; - - if (configArray.length > 0) { - configArray.unshift(...parentConfigArray); - } else { - configArray = parentConfigArray; - } - - // Cache and return. - return this._cacheConfig(directoryPath, configArray); - } - - /** - * Freeze and cache a given config. - * @param {string} directoryPath The path to a directory as a cache key. - * @param {ConfigArray} configArray The config array as a cache value. - * @returns {ConfigArray} The `configArray` (frozen). - */ - _cacheConfig(directoryPath, configArray) { - const { configCache } = internalSlotsMap.get(this); - - Object.freeze(configArray); - configCache.set(directoryPath, configArray); - - return configArray; - } - - /** - * Finalize a given config array. - * Concatenate `--config` and other CLI options. - * @param {ConfigArray} configArray The parent config array. - * @param {string} directoryPath The path to the leaf directory to find config files. - * @param {boolean} ignoreNotFoundError If `true` then it doesn't throw `ConfigurationNotFoundError`. - * @returns {ConfigArray} The loaded config. - * @private - */ - _finalizeConfigArray(configArray, directoryPath, ignoreNotFoundError) { - const { - cliConfigArray, - configArrayFactory, - finalizeCache, - useEslintrc, - builtInRules - } = internalSlotsMap.get(this); - - let finalConfigArray = finalizeCache.get(configArray); - - if (!finalConfigArray) { - finalConfigArray = configArray; - - // Load the personal config if there are no regular config files. - if ( - useEslintrc && - configArray.every(c => !c.filePath) && - cliConfigArray.every(c => !c.filePath) // `--config` option can be a file. - ) { - const homePath = os.homedir(); - - debug("Loading the config file of the home directory:", homePath); - - const personalConfigArray = configArrayFactory.loadInDirectory( - homePath, - { name: "PersonalConfig" } - ); - - if ( - personalConfigArray.length > 0 && - !directoryPath.startsWith(homePath) - ) { - const lastElement = - personalConfigArray[personalConfigArray.length - 1]; - - emitDeprecationWarning( - lastElement.filePath, - "ESLINT_PERSONAL_CONFIG_LOAD" - ); - } - - finalConfigArray = finalConfigArray.concat(personalConfigArray); - } - - // Apply CLI options. - if (cliConfigArray.length > 0) { - finalConfigArray = finalConfigArray.concat(cliConfigArray); - } - - // Validate rule settings and environments. - const validator = new ConfigValidator({ - builtInRules - }); - - validator.validateConfigArray(finalConfigArray); - - // Cache it. - Object.freeze(finalConfigArray); - finalizeCache.set(configArray, finalConfigArray); - - debug( - "Configuration was determined: %o on %s", - finalConfigArray, - directoryPath - ); - } - - // At least one element (the default ignore patterns) exists. - if (!ignoreNotFoundError && useEslintrc && finalConfigArray.length <= 1) { - throw new ConfigurationNotFoundError(directoryPath); - } - - return finalConfigArray; - } -} - -//------------------------------------------------------------------------------ -// Public Interface -//------------------------------------------------------------------------------ - -export { CascadingConfigArrayFactory }; diff --git a/tools/eslint/node_modules/@eslint/eslintrc/lib/config-array-factory.js b/tools/eslint/node_modules/@eslint/eslintrc/lib/config-array-factory.js deleted file mode 100644 index e4b18ebd898606..00000000000000 --- a/tools/eslint/node_modules/@eslint/eslintrc/lib/config-array-factory.js +++ /dev/null @@ -1,1155 +0,0 @@ -/** - * @fileoverview The factory of `ConfigArray` objects. - * - * This class provides methods to create `ConfigArray` instance. - * - * - `create(configData, options)` - * Create a `ConfigArray` instance from a config data. This is to handle CLI - * options except `--config`. - * - `loadFile(filePath, options)` - * Create a `ConfigArray` instance from a config file. This is to handle - * `--config` option. If the file was not found, throws the following error: - * - If the filename was `*.js`, a `MODULE_NOT_FOUND` error. - * - If the filename was `package.json`, an IO error or an - * `ESLINT_CONFIG_FIELD_NOT_FOUND` error. - * - Otherwise, an IO error such as `ENOENT`. - * - `loadInDirectory(directoryPath, options)` - * Create a `ConfigArray` instance from a config file which is on a given - * directory. This tries to load `.eslintrc.*` or `package.json`. If not - * found, returns an empty `ConfigArray`. - * - `loadESLintIgnore(filePath)` - * Create a `ConfigArray` instance from a config file that is `.eslintignore` - * format. This is to handle `--ignore-path` option. - * - `loadDefaultESLintIgnore()` - * Create a `ConfigArray` instance from `.eslintignore` or `package.json` in - * the current working directory. - * - * `ConfigArrayFactory` class has the responsibility that loads configuration - * files, including loading `extends`, `parser`, and `plugins`. The created - * `ConfigArray` instance has the loaded `extends`, `parser`, and `plugins`. - * - * But this class doesn't handle cascading. `CascadingConfigArrayFactory` class - * handles cascading and hierarchy. - * - * @author Toru Nagashima - */ - -//------------------------------------------------------------------------------ -// Requirements -//------------------------------------------------------------------------------ - -import debugOrig from "debug"; -import fs from "fs"; -import importFresh from "import-fresh"; -import { createRequire } from "module"; -import path from "path"; -import stripComments from "strip-json-comments"; - -import { - ConfigArray, - ConfigDependency, - IgnorePattern, - OverrideTester -} from "./config-array/index.js"; -import ConfigValidator from "./shared/config-validator.js"; -import * as naming from "./shared/naming.js"; -import * as ModuleResolver from "./shared/relative-module-resolver.js"; - -const require = createRequire(import.meta.url); - -const debug = debugOrig("eslintrc:config-array-factory"); - -//------------------------------------------------------------------------------ -// Helpers -//------------------------------------------------------------------------------ - -const configFilenames = [ - ".eslintrc.js", - ".eslintrc.cjs", - ".eslintrc.yaml", - ".eslintrc.yml", - ".eslintrc.json", - ".eslintrc", - "package.json" -]; - -// Define types for VSCode IntelliSense. -/** @typedef {import("./shared/types").ConfigData} ConfigData */ -/** @typedef {import("./shared/types").OverrideConfigData} OverrideConfigData */ -/** @typedef {import("./shared/types").Parser} Parser */ -/** @typedef {import("./shared/types").Plugin} Plugin */ -/** @typedef {import("./shared/types").Rule} Rule */ -/** @typedef {import("./config-array/config-dependency").DependentParser} DependentParser */ -/** @typedef {import("./config-array/config-dependency").DependentPlugin} DependentPlugin */ -/** @typedef {ConfigArray[0]} ConfigArrayElement */ - -/** - * @typedef {Object} ConfigArrayFactoryOptions - * @property {Map} [additionalPluginPool] The map for additional plugins. - * @property {string} [cwd] The path to the current working directory. - * @property {string} [resolvePluginsRelativeTo] A path to the directory that plugins should be resolved from. Defaults to `cwd`. - * @property {Map} builtInRules The rules that are built in to ESLint. - * @property {Object} [resolver=ModuleResolver] The module resolver object. - * @property {string} eslintAllPath The path to the definitions for eslint:all. - * @property {Function} getEslintAllConfig Returns the config data for eslint:all. - * @property {string} eslintRecommendedPath The path to the definitions for eslint:recommended. - * @property {Function} getEslintRecommendedConfig Returns the config data for eslint:recommended. - */ - -/** - * @typedef {Object} ConfigArrayFactoryInternalSlots - * @property {Map} additionalPluginPool The map for additional plugins. - * @property {string} cwd The path to the current working directory. - * @property {string | undefined} resolvePluginsRelativeTo An absolute path the the directory that plugins should be resolved from. - * @property {Map} builtInRules The rules that are built in to ESLint. - * @property {Object} [resolver=ModuleResolver] The module resolver object. - * @property {string} eslintAllPath The path to the definitions for eslint:all. - * @property {Function} getEslintAllConfig Returns the config data for eslint:all. - * @property {string} eslintRecommendedPath The path to the definitions for eslint:recommended. - * @property {Function} getEslintRecommendedConfig Returns the config data for eslint:recommended. - */ - -/** - * @typedef {Object} ConfigArrayFactoryLoadingContext - * @property {string} filePath The path to the current configuration. - * @property {string} matchBasePath The base path to resolve relative paths in `overrides[].files`, `overrides[].excludedFiles`, and `ignorePatterns`. - * @property {string} name The name of the current configuration. - * @property {string} pluginBasePath The base path to resolve plugins. - * @property {"config" | "ignore" | "implicit-processor"} type The type of the current configuration. This is `"config"` in normal. This is `"ignore"` if it came from `.eslintignore`. This is `"implicit-processor"` if it came from legacy file-extension processors. - */ - -/** - * @typedef {Object} ConfigArrayFactoryLoadingContext - * @property {string} filePath The path to the current configuration. - * @property {string} matchBasePath The base path to resolve relative paths in `overrides[].files`, `overrides[].excludedFiles`, and `ignorePatterns`. - * @property {string} name The name of the current configuration. - * @property {"config" | "ignore" | "implicit-processor"} type The type of the current configuration. This is `"config"` in normal. This is `"ignore"` if it came from `.eslintignore`. This is `"implicit-processor"` if it came from legacy file-extension processors. - */ - -/** @type {WeakMap} */ -const internalSlotsMap = new WeakMap(); - -/** @type {WeakMap} */ -const normalizedPlugins = new WeakMap(); - -/** - * Check if a given string is a file path. - * @param {string} nameOrPath A module name or file path. - * @returns {boolean} `true` if the `nameOrPath` is a file path. - */ -function isFilePath(nameOrPath) { - return ( - /^\.{1,2}[/\\]/u.test(nameOrPath) || - path.isAbsolute(nameOrPath) - ); -} - -/** - * Convenience wrapper for synchronously reading file contents. - * @param {string} filePath The filename to read. - * @returns {string} The file contents, with the BOM removed. - * @private - */ -function readFile(filePath) { - return fs.readFileSync(filePath, "utf8").replace(/^\ufeff/u, ""); -} - -/** - * Loads a YAML configuration from a file. - * @param {string} filePath The filename to load. - * @returns {ConfigData} The configuration object from the file. - * @throws {Error} If the file cannot be read. - * @private - */ -function loadYAMLConfigFile(filePath) { - debug(`Loading YAML config file: ${filePath}`); - - // lazy load YAML to improve performance when not used - const yaml = require("js-yaml"); - - try { - - // empty YAML file can be null, so always use - return yaml.load(readFile(filePath)) || {}; - } catch (e) { - debug(`Error reading YAML file: ${filePath}`); - e.message = `Cannot read config file: ${filePath}\nError: ${e.message}`; - throw e; - } -} - -/** - * Loads a JSON configuration from a file. - * @param {string} filePath The filename to load. - * @returns {ConfigData} The configuration object from the file. - * @throws {Error} If the file cannot be read. - * @private - */ -function loadJSONConfigFile(filePath) { - debug(`Loading JSON config file: ${filePath}`); - - try { - return JSON.parse(stripComments(readFile(filePath))); - } catch (e) { - debug(`Error reading JSON file: ${filePath}`); - e.message = `Cannot read config file: ${filePath}\nError: ${e.message}`; - e.messageTemplate = "failed-to-read-json"; - e.messageData = { - path: filePath, - message: e.message - }; - throw e; - } -} - -/** - * Loads a legacy (.eslintrc) configuration from a file. - * @param {string} filePath The filename to load. - * @returns {ConfigData} The configuration object from the file. - * @throws {Error} If the file cannot be read. - * @private - */ -function loadLegacyConfigFile(filePath) { - debug(`Loading legacy config file: ${filePath}`); - - // lazy load YAML to improve performance when not used - const yaml = require("js-yaml"); - - try { - return yaml.load(stripComments(readFile(filePath))) || /* istanbul ignore next */ {}; - } catch (e) { - debug("Error reading YAML file: %s\n%o", filePath, e); - e.message = `Cannot read config file: ${filePath}\nError: ${e.message}`; - throw e; - } -} - -/** - * Loads a JavaScript configuration from a file. - * @param {string} filePath The filename to load. - * @returns {ConfigData} The configuration object from the file. - * @throws {Error} If the file cannot be read. - * @private - */ -function loadJSConfigFile(filePath) { - debug(`Loading JS config file: ${filePath}`); - try { - return importFresh(filePath); - } catch (e) { - debug(`Error reading JavaScript file: ${filePath}`); - e.message = `Cannot read config file: ${filePath}\nError: ${e.message}`; - throw e; - } -} - -/** - * Loads a configuration from a package.json file. - * @param {string} filePath The filename to load. - * @returns {ConfigData} The configuration object from the file. - * @throws {Error} If the file cannot be read. - * @private - */ -function loadPackageJSONConfigFile(filePath) { - debug(`Loading package.json config file: ${filePath}`); - try { - const packageData = loadJSONConfigFile(filePath); - - if (!Object.hasOwnProperty.call(packageData, "eslintConfig")) { - throw Object.assign( - new Error("package.json file doesn't have 'eslintConfig' field."), - { code: "ESLINT_CONFIG_FIELD_NOT_FOUND" } - ); - } - - return packageData.eslintConfig; - } catch (e) { - debug(`Error reading package.json file: ${filePath}`); - e.message = `Cannot read config file: ${filePath}\nError: ${e.message}`; - throw e; - } -} - -/** - * Loads a `.eslintignore` from a file. - * @param {string} filePath The filename to load. - * @returns {string[]} The ignore patterns from the file. - * @private - */ -function loadESLintIgnoreFile(filePath) { - debug(`Loading .eslintignore file: ${filePath}`); - - try { - return readFile(filePath) - .split(/\r?\n/gu) - .filter(line => line.trim() !== "" && !line.startsWith("#")); - } catch (e) { - debug(`Error reading .eslintignore file: ${filePath}`); - e.message = `Cannot read .eslintignore file: ${filePath}\nError: ${e.message}`; - throw e; - } -} - -/** - * Creates an error to notify about a missing config to extend from. - * @param {string} configName The name of the missing config. - * @param {string} importerName The name of the config that imported the missing config - * @param {string} messageTemplate The text template to source error strings from. - * @returns {Error} The error object to throw - * @private - */ -function configInvalidError(configName, importerName, messageTemplate) { - return Object.assign( - new Error(`Failed to load config "${configName}" to extend from.`), - { - messageTemplate, - messageData: { configName, importerName } - } - ); -} - -/** - * Loads a configuration file regardless of the source. Inspects the file path - * to determine the correctly way to load the config file. - * @param {string} filePath The path to the configuration. - * @returns {ConfigData|null} The configuration information. - * @private - */ -function loadConfigFile(filePath) { - switch (path.extname(filePath)) { - case ".js": - case ".cjs": - return loadJSConfigFile(filePath); - - case ".json": - if (path.basename(filePath) === "package.json") { - return loadPackageJSONConfigFile(filePath); - } - return loadJSONConfigFile(filePath); - - case ".yaml": - case ".yml": - return loadYAMLConfigFile(filePath); - - default: - return loadLegacyConfigFile(filePath); - } -} - -/** - * Write debug log. - * @param {string} request The requested module name. - * @param {string} relativeTo The file path to resolve the request relative to. - * @param {string} filePath The resolved file path. - * @returns {void} - */ -function writeDebugLogForLoading(request, relativeTo, filePath) { - /* istanbul ignore next */ - if (debug.enabled) { - let nameAndVersion = null; - - try { - const packageJsonPath = ModuleResolver.resolve( - `${request}/package.json`, - relativeTo - ); - const { version = "unknown" } = require(packageJsonPath); - - nameAndVersion = `${request}@${version}`; - } catch (error) { - debug("package.json was not found:", error.message); - nameAndVersion = request; - } - - debug("Loaded: %s (%s)", nameAndVersion, filePath); - } -} - -/** - * Create a new context with default values. - * @param {ConfigArrayFactoryInternalSlots} slots The internal slots. - * @param {"config" | "ignore" | "implicit-processor" | undefined} providedType The type of the current configuration. Default is `"config"`. - * @param {string | undefined} providedName The name of the current configuration. Default is the relative path from `cwd` to `filePath`. - * @param {string | undefined} providedFilePath The path to the current configuration. Default is empty string. - * @param {string | undefined} providedMatchBasePath The type of the current configuration. Default is the directory of `filePath` or `cwd`. - * @returns {ConfigArrayFactoryLoadingContext} The created context. - */ -function createContext( - { cwd, resolvePluginsRelativeTo }, - providedType, - providedName, - providedFilePath, - providedMatchBasePath -) { - const filePath = providedFilePath - ? path.resolve(cwd, providedFilePath) - : ""; - const matchBasePath = - (providedMatchBasePath && path.resolve(cwd, providedMatchBasePath)) || - (filePath && path.dirname(filePath)) || - cwd; - const name = - providedName || - (filePath && path.relative(cwd, filePath)) || - ""; - const pluginBasePath = - resolvePluginsRelativeTo || - (filePath && path.dirname(filePath)) || - cwd; - const type = providedType || "config"; - - return { filePath, matchBasePath, name, pluginBasePath, type }; -} - -/** - * Normalize a given plugin. - * - Ensure the object to have four properties: configs, environments, processors, and rules. - * - Ensure the object to not have other properties. - * @param {Plugin} plugin The plugin to normalize. - * @returns {Plugin} The normalized plugin. - */ -function normalizePlugin(plugin) { - - // first check the cache - let normalizedPlugin = normalizedPlugins.get(plugin); - - if (normalizedPlugin) { - return normalizedPlugin; - } - - normalizedPlugin = { - configs: plugin.configs || {}, - environments: plugin.environments || {}, - processors: plugin.processors || {}, - rules: plugin.rules || {} - }; - - // save the reference for later - normalizedPlugins.set(plugin, normalizedPlugin); - - return normalizedPlugin; -} - -//------------------------------------------------------------------------------ -// Public Interface -//------------------------------------------------------------------------------ - -/** - * The factory of `ConfigArray` objects. - */ -class ConfigArrayFactory { - - /** - * Initialize this instance. - * @param {ConfigArrayFactoryOptions} [options] The map for additional plugins. - */ - constructor({ - additionalPluginPool = new Map(), - cwd = process.cwd(), - resolvePluginsRelativeTo, - builtInRules, - resolver = ModuleResolver, - eslintAllPath, - getEslintAllConfig, - eslintRecommendedPath, - getEslintRecommendedConfig - } = {}) { - internalSlotsMap.set(this, { - additionalPluginPool, - cwd, - resolvePluginsRelativeTo: - resolvePluginsRelativeTo && - path.resolve(cwd, resolvePluginsRelativeTo), - builtInRules, - resolver, - eslintAllPath, - getEslintAllConfig, - eslintRecommendedPath, - getEslintRecommendedConfig - }); - } - - /** - * Create `ConfigArray` instance from a config data. - * @param {ConfigData|null} configData The config data to create. - * @param {Object} [options] The options. - * @param {string} [options.basePath] The base path to resolve relative paths in `overrides[].files`, `overrides[].excludedFiles`, and `ignorePatterns`. - * @param {string} [options.filePath] The path to this config data. - * @param {string} [options.name] The config name. - * @returns {ConfigArray} Loaded config. - */ - create(configData, { basePath, filePath, name } = {}) { - if (!configData) { - return new ConfigArray(); - } - - const slots = internalSlotsMap.get(this); - const ctx = createContext(slots, "config", name, filePath, basePath); - const elements = this._normalizeConfigData(configData, ctx); - - return new ConfigArray(...elements); - } - - /** - * Load a config file. - * @param {string} filePath The path to a config file. - * @param {Object} [options] The options. - * @param {string} [options.basePath] The base path to resolve relative paths in `overrides[].files`, `overrides[].excludedFiles`, and `ignorePatterns`. - * @param {string} [options.name] The config name. - * @returns {ConfigArray} Loaded config. - */ - loadFile(filePath, { basePath, name } = {}) { - const slots = internalSlotsMap.get(this); - const ctx = createContext(slots, "config", name, filePath, basePath); - - return new ConfigArray(...this._loadConfigData(ctx)); - } - - /** - * Load the config file on a given directory if exists. - * @param {string} directoryPath The path to a directory. - * @param {Object} [options] The options. - * @param {string} [options.basePath] The base path to resolve relative paths in `overrides[].files`, `overrides[].excludedFiles`, and `ignorePatterns`. - * @param {string} [options.name] The config name. - * @returns {ConfigArray} Loaded config. An empty `ConfigArray` if any config doesn't exist. - */ - loadInDirectory(directoryPath, { basePath, name } = {}) { - const slots = internalSlotsMap.get(this); - - for (const filename of configFilenames) { - const ctx = createContext( - slots, - "config", - name, - path.join(directoryPath, filename), - basePath - ); - - if (fs.existsSync(ctx.filePath) && fs.statSync(ctx.filePath).isFile()) { - let configData; - - try { - configData = loadConfigFile(ctx.filePath); - } catch (error) { - if (!error || error.code !== "ESLINT_CONFIG_FIELD_NOT_FOUND") { - throw error; - } - } - - if (configData) { - debug(`Config file found: ${ctx.filePath}`); - return new ConfigArray( - ...this._normalizeConfigData(configData, ctx) - ); - } - } - } - - debug(`Config file not found on ${directoryPath}`); - return new ConfigArray(); - } - - /** - * Check if a config file on a given directory exists or not. - * @param {string} directoryPath The path to a directory. - * @returns {string | null} The path to the found config file. If not found then null. - */ - static getPathToConfigFileInDirectory(directoryPath) { - for (const filename of configFilenames) { - const filePath = path.join(directoryPath, filename); - - if (fs.existsSync(filePath)) { - if (filename === "package.json") { - try { - loadPackageJSONConfigFile(filePath); - return filePath; - } catch { /* ignore */ } - } else { - return filePath; - } - } - } - return null; - } - - /** - * Load `.eslintignore` file. - * @param {string} filePath The path to a `.eslintignore` file to load. - * @returns {ConfigArray} Loaded config. An empty `ConfigArray` if any config doesn't exist. - */ - loadESLintIgnore(filePath) { - const slots = internalSlotsMap.get(this); - const ctx = createContext( - slots, - "ignore", - void 0, - filePath, - slots.cwd - ); - const ignorePatterns = loadESLintIgnoreFile(ctx.filePath); - - return new ConfigArray( - ...this._normalizeESLintIgnoreData(ignorePatterns, ctx) - ); - } - - /** - * Load `.eslintignore` file in the current working directory. - * @returns {ConfigArray} Loaded config. An empty `ConfigArray` if any config doesn't exist. - */ - loadDefaultESLintIgnore() { - const slots = internalSlotsMap.get(this); - const eslintIgnorePath = path.resolve(slots.cwd, ".eslintignore"); - const packageJsonPath = path.resolve(slots.cwd, "package.json"); - - if (fs.existsSync(eslintIgnorePath)) { - return this.loadESLintIgnore(eslintIgnorePath); - } - if (fs.existsSync(packageJsonPath)) { - const data = loadJSONConfigFile(packageJsonPath); - - if (Object.hasOwnProperty.call(data, "eslintIgnore")) { - if (!Array.isArray(data.eslintIgnore)) { - throw new Error("Package.json eslintIgnore property requires an array of paths"); - } - const ctx = createContext( - slots, - "ignore", - "eslintIgnore in package.json", - packageJsonPath, - slots.cwd - ); - - return new ConfigArray( - ...this._normalizeESLintIgnoreData(data.eslintIgnore, ctx) - ); - } - } - - return new ConfigArray(); - } - - /** - * Load a given config file. - * @param {ConfigArrayFactoryLoadingContext} ctx The loading context. - * @returns {IterableIterator} Loaded config. - * @private - */ - _loadConfigData(ctx) { - return this._normalizeConfigData(loadConfigFile(ctx.filePath), ctx); - } - - /** - * Normalize a given `.eslintignore` data to config array elements. - * @param {string[]} ignorePatterns The patterns to ignore files. - * @param {ConfigArrayFactoryLoadingContext} ctx The loading context. - * @returns {IterableIterator} The normalized config. - * @private - */ - *_normalizeESLintIgnoreData(ignorePatterns, ctx) { - const elements = this._normalizeObjectConfigData( - { ignorePatterns }, - ctx - ); - - // Set `ignorePattern.loose` flag for backward compatibility. - for (const element of elements) { - if (element.ignorePattern) { - element.ignorePattern.loose = true; - } - yield element; - } - } - - /** - * Normalize a given config to an array. - * @param {ConfigData} configData The config data to normalize. - * @param {ConfigArrayFactoryLoadingContext} ctx The loading context. - * @returns {IterableIterator} The normalized config. - * @private - */ - _normalizeConfigData(configData, ctx) { - const validator = new ConfigValidator(); - - validator.validateConfigSchema(configData, ctx.name || ctx.filePath); - return this._normalizeObjectConfigData(configData, ctx); - } - - /** - * Normalize a given config to an array. - * @param {ConfigData|OverrideConfigData} configData The config data to normalize. - * @param {ConfigArrayFactoryLoadingContext} ctx The loading context. - * @returns {IterableIterator} The normalized config. - * @private - */ - *_normalizeObjectConfigData(configData, ctx) { - const { files, excludedFiles, ...configBody } = configData; - const criteria = OverrideTester.create( - files, - excludedFiles, - ctx.matchBasePath - ); - const elements = this._normalizeObjectConfigDataBody(configBody, ctx); - - // Apply the criteria to every element. - for (const element of elements) { - - /* - * Merge the criteria. - * This is for the `overrides` entries that came from the - * configurations of `overrides[].extends`. - */ - element.criteria = OverrideTester.and(criteria, element.criteria); - - /* - * Remove `root` property to ignore `root` settings which came from - * `extends` in `overrides`. - */ - if (element.criteria) { - element.root = void 0; - } - - yield element; - } - } - - /** - * Normalize a given config to an array. - * @param {ConfigData} configData The config data to normalize. - * @param {ConfigArrayFactoryLoadingContext} ctx The loading context. - * @returns {IterableIterator} The normalized config. - * @private - */ - *_normalizeObjectConfigDataBody( - { - env, - extends: extend, - globals, - ignorePatterns, - noInlineConfig, - parser: parserName, - parserOptions, - plugins: pluginList, - processor, - reportUnusedDisableDirectives, - root, - rules, - settings, - overrides: overrideList = [] - }, - ctx - ) { - const extendList = Array.isArray(extend) ? extend : [extend]; - const ignorePattern = ignorePatterns && new IgnorePattern( - Array.isArray(ignorePatterns) ? ignorePatterns : [ignorePatterns], - ctx.matchBasePath - ); - - // Flatten `extends`. - for (const extendName of extendList.filter(Boolean)) { - yield* this._loadExtends(extendName, ctx); - } - - // Load parser & plugins. - const parser = parserName && this._loadParser(parserName, ctx); - const plugins = pluginList && this._loadPlugins(pluginList, ctx); - - // Yield pseudo config data for file extension processors. - if (plugins) { - yield* this._takeFileExtensionProcessors(plugins, ctx); - } - - // Yield the config data except `extends` and `overrides`. - yield { - - // Debug information. - type: ctx.type, - name: ctx.name, - filePath: ctx.filePath, - - // Config data. - criteria: null, - env, - globals, - ignorePattern, - noInlineConfig, - parser, - parserOptions, - plugins, - processor, - reportUnusedDisableDirectives, - root, - rules, - settings - }; - - // Flatten `overries`. - for (let i = 0; i < overrideList.length; ++i) { - yield* this._normalizeObjectConfigData( - overrideList[i], - { ...ctx, name: `${ctx.name}#overrides[${i}]` } - ); - } - } - - /** - * Load configs of an element in `extends`. - * @param {string} extendName The name of a base config. - * @param {ConfigArrayFactoryLoadingContext} ctx The loading context. - * @returns {IterableIterator} The normalized config. - * @private - */ - _loadExtends(extendName, ctx) { - debug("Loading {extends:%j} relative to %s", extendName, ctx.filePath); - try { - if (extendName.startsWith("eslint:")) { - return this._loadExtendedBuiltInConfig(extendName, ctx); - } - if (extendName.startsWith("plugin:")) { - return this._loadExtendedPluginConfig(extendName, ctx); - } - return this._loadExtendedShareableConfig(extendName, ctx); - } catch (error) { - error.message += `\nReferenced from: ${ctx.filePath || ctx.name}`; - throw error; - } - } - - /** - * Load configs of an element in `extends`. - * @param {string} extendName The name of a base config. - * @param {ConfigArrayFactoryLoadingContext} ctx The loading context. - * @returns {IterableIterator} The normalized config. - * @private - */ - _loadExtendedBuiltInConfig(extendName, ctx) { - const { - eslintAllPath, - getEslintAllConfig, - eslintRecommendedPath, - getEslintRecommendedConfig - } = internalSlotsMap.get(this); - - if (extendName === "eslint:recommended") { - const name = `${ctx.name} ยป ${extendName}`; - - if (getEslintRecommendedConfig) { - if (typeof getEslintRecommendedConfig !== "function") { - throw new Error(`getEslintRecommendedConfig must be a function instead of '${getEslintRecommendedConfig}'`); - } - return this._normalizeConfigData(getEslintRecommendedConfig(), { ...ctx, name, filePath: "" }); - } - return this._loadConfigData({ - ...ctx, - name, - filePath: eslintRecommendedPath - }); - } - if (extendName === "eslint:all") { - const name = `${ctx.name} ยป ${extendName}`; - - if (getEslintAllConfig) { - if (typeof getEslintAllConfig !== "function") { - throw new Error(`getEslintAllConfig must be a function instead of '${getEslintAllConfig}'`); - } - return this._normalizeConfigData(getEslintAllConfig(), { ...ctx, name, filePath: "" }); - } - return this._loadConfigData({ - ...ctx, - name, - filePath: eslintAllPath - }); - } - - throw configInvalidError(extendName, ctx.name, "extend-config-missing"); - } - - /** - * Load configs of an element in `extends`. - * @param {string} extendName The name of a base config. - * @param {ConfigArrayFactoryLoadingContext} ctx The loading context. - * @returns {IterableIterator} The normalized config. - * @private - */ - _loadExtendedPluginConfig(extendName, ctx) { - const slashIndex = extendName.lastIndexOf("/"); - - if (slashIndex === -1) { - throw configInvalidError(extendName, ctx.filePath, "plugin-invalid"); - } - - const pluginName = extendName.slice("plugin:".length, slashIndex); - const configName = extendName.slice(slashIndex + 1); - - if (isFilePath(pluginName)) { - throw new Error("'extends' cannot use a file path for plugins."); - } - - const plugin = this._loadPlugin(pluginName, ctx); - const configData = - plugin.definition && - plugin.definition.configs[configName]; - - if (configData) { - return this._normalizeConfigData(configData, { - ...ctx, - filePath: plugin.filePath || ctx.filePath, - name: `${ctx.name} ยป plugin:${plugin.id}/${configName}` - }); - } - - throw plugin.error || configInvalidError(extendName, ctx.filePath, "extend-config-missing"); - } - - /** - * Load configs of an element in `extends`. - * @param {string} extendName The name of a base config. - * @param {ConfigArrayFactoryLoadingContext} ctx The loading context. - * @returns {IterableIterator} The normalized config. - * @private - */ - _loadExtendedShareableConfig(extendName, ctx) { - const { cwd, resolver } = internalSlotsMap.get(this); - const relativeTo = ctx.filePath || path.join(cwd, "__placeholder__.js"); - let request; - - if (isFilePath(extendName)) { - request = extendName; - } else if (extendName.startsWith(".")) { - request = `./${extendName}`; // For backward compatibility. A ton of tests depended on this behavior. - } else { - request = naming.normalizePackageName( - extendName, - "eslint-config" - ); - } - - let filePath; - - try { - filePath = resolver.resolve(request, relativeTo); - } catch (error) { - /* istanbul ignore else */ - if (error && error.code === "MODULE_NOT_FOUND") { - throw configInvalidError(extendName, ctx.filePath, "extend-config-missing"); - } - throw error; - } - - writeDebugLogForLoading(request, relativeTo, filePath); - return this._loadConfigData({ - ...ctx, - filePath, - name: `${ctx.name} ยป ${request}` - }); - } - - /** - * Load given plugins. - * @param {string[]} names The plugin names to load. - * @param {ConfigArrayFactoryLoadingContext} ctx The loading context. - * @returns {Record} The loaded parser. - * @private - */ - _loadPlugins(names, ctx) { - return names.reduce((map, name) => { - if (isFilePath(name)) { - throw new Error("Plugins array cannot includes file paths."); - } - const plugin = this._loadPlugin(name, ctx); - - map[plugin.id] = plugin; - - return map; - }, {}); - } - - /** - * Load a given parser. - * @param {string} nameOrPath The package name or the path to a parser file. - * @param {ConfigArrayFactoryLoadingContext} ctx The loading context. - * @returns {DependentParser} The loaded parser. - */ - _loadParser(nameOrPath, ctx) { - debug("Loading parser %j from %s", nameOrPath, ctx.filePath); - - const { cwd, resolver } = internalSlotsMap.get(this); - const relativeTo = ctx.filePath || path.join(cwd, "__placeholder__.js"); - - try { - const filePath = resolver.resolve(nameOrPath, relativeTo); - - writeDebugLogForLoading(nameOrPath, relativeTo, filePath); - - return new ConfigDependency({ - definition: require(filePath), - filePath, - id: nameOrPath, - importerName: ctx.name, - importerPath: ctx.filePath - }); - } catch (error) { - - // If the parser name is "espree", load the espree of ESLint. - if (nameOrPath === "espree") { - debug("Fallback espree."); - return new ConfigDependency({ - definition: require("espree"), - filePath: require.resolve("espree"), - id: nameOrPath, - importerName: ctx.name, - importerPath: ctx.filePath - }); - } - - debug("Failed to load parser '%s' declared in '%s'.", nameOrPath, ctx.name); - error.message = `Failed to load parser '${nameOrPath}' declared in '${ctx.name}': ${error.message}`; - - return new ConfigDependency({ - error, - id: nameOrPath, - importerName: ctx.name, - importerPath: ctx.filePath - }); - } - } - - /** - * Load a given plugin. - * @param {string} name The plugin name to load. - * @param {ConfigArrayFactoryLoadingContext} ctx The loading context. - * @returns {DependentPlugin} The loaded plugin. - * @private - */ - _loadPlugin(name, ctx) { - debug("Loading plugin %j from %s", name, ctx.filePath); - - const { additionalPluginPool, resolver } = internalSlotsMap.get(this); - const request = naming.normalizePackageName(name, "eslint-plugin"); - const id = naming.getShorthandName(request, "eslint-plugin"); - const relativeTo = path.join(ctx.pluginBasePath, "__placeholder__.js"); - - if (name.match(/\s+/u)) { - const error = Object.assign( - new Error(`Whitespace found in plugin name '${name}'`), - { - messageTemplate: "whitespace-found", - messageData: { pluginName: request } - } - ); - - return new ConfigDependency({ - error, - id, - importerName: ctx.name, - importerPath: ctx.filePath - }); - } - - // Check for additional pool. - const plugin = - additionalPluginPool.get(request) || - additionalPluginPool.get(id); - - if (plugin) { - return new ConfigDependency({ - definition: normalizePlugin(plugin), - original: plugin, - filePath: "", // It's unknown where the plugin came from. - id, - importerName: ctx.name, - importerPath: ctx.filePath - }); - } - - let filePath; - let error; - - try { - filePath = resolver.resolve(request, relativeTo); - } catch (resolveError) { - error = resolveError; - /* istanbul ignore else */ - if (error && error.code === "MODULE_NOT_FOUND") { - error.messageTemplate = "plugin-missing"; - error.messageData = { - pluginName: request, - resolvePluginsRelativeTo: ctx.pluginBasePath, - importerName: ctx.name - }; - } - } - - if (filePath) { - try { - writeDebugLogForLoading(request, relativeTo, filePath); - - const startTime = Date.now(); - const pluginDefinition = require(filePath); - - debug(`Plugin ${filePath} loaded in: ${Date.now() - startTime}ms`); - - return new ConfigDependency({ - definition: normalizePlugin(pluginDefinition), - original: pluginDefinition, - filePath, - id, - importerName: ctx.name, - importerPath: ctx.filePath - }); - } catch (loadError) { - error = loadError; - } - } - - debug("Failed to load plugin '%s' declared in '%s'.", name, ctx.name); - error.message = `Failed to load plugin '${name}' declared in '${ctx.name}': ${error.message}`; - return new ConfigDependency({ - error, - id, - importerName: ctx.name, - importerPath: ctx.filePath - }); - } - - /** - * Take file expression processors as config array elements. - * @param {Record} plugins The plugin definitions. - * @param {ConfigArrayFactoryLoadingContext} ctx The loading context. - * @returns {IterableIterator} The config array elements of file expression processors. - * @private - */ - *_takeFileExtensionProcessors(plugins, ctx) { - for (const pluginId of Object.keys(plugins)) { - const processors = - plugins[pluginId] && - plugins[pluginId].definition && - plugins[pluginId].definition.processors; - - if (!processors) { - continue; - } - - for (const processorId of Object.keys(processors)) { - if (processorId.startsWith(".")) { - yield* this._normalizeObjectConfigData( - { - files: [`*${processorId}`], - processor: `${pluginId}/${processorId}` - }, - { - ...ctx, - type: "implicit-processor", - name: `${ctx.name}#processors["${pluginId}/${processorId}"]` - } - ); - } - } - } - } -} - -export { - ConfigArrayFactory, - createContext, - loadConfigFile -}; diff --git a/tools/eslint/node_modules/@eslint/eslintrc/lib/config-array/config-array.js b/tools/eslint/node_modules/@eslint/eslintrc/lib/config-array/config-array.js deleted file mode 100644 index 5766fc468a6674..00000000000000 --- a/tools/eslint/node_modules/@eslint/eslintrc/lib/config-array/config-array.js +++ /dev/null @@ -1,510 +0,0 @@ -/** - * @fileoverview `ConfigArray` class. - * - * `ConfigArray` class expresses the full of a configuration. It has the entry - * config file, base config files that were extended, loaded parsers, and loaded - * plugins. - * - * `ConfigArray` class provides three properties and two methods. - * - * - `pluginEnvironments` - * - `pluginProcessors` - * - `pluginRules` - * The `Map` objects that contain the members of all plugins that this - * config array contains. Those map objects don't have mutation methods. - * Those keys are the member ID such as `pluginId/memberName`. - * - `isRoot()` - * If `true` then this configuration has `root:true` property. - * - `extractConfig(filePath)` - * Extract the final configuration for a given file. This means merging - * every config array element which that `criteria` property matched. The - * `filePath` argument must be an absolute path. - * - * `ConfigArrayFactory` provides the loading logic of config files. - * - * @author Toru Nagashima - */ - -//------------------------------------------------------------------------------ -// Requirements -//------------------------------------------------------------------------------ - -import { ExtractedConfig } from "./extracted-config.js"; -import { IgnorePattern } from "./ignore-pattern.js"; - -//------------------------------------------------------------------------------ -// Helpers -//------------------------------------------------------------------------------ - -// Define types for VSCode IntelliSense. -/** @typedef {import("../../shared/types").Environment} Environment */ -/** @typedef {import("../../shared/types").GlobalConf} GlobalConf */ -/** @typedef {import("../../shared/types").RuleConf} RuleConf */ -/** @typedef {import("../../shared/types").Rule} Rule */ -/** @typedef {import("../../shared/types").Plugin} Plugin */ -/** @typedef {import("../../shared/types").Processor} Processor */ -/** @typedef {import("./config-dependency").DependentParser} DependentParser */ -/** @typedef {import("./config-dependency").DependentPlugin} DependentPlugin */ -/** @typedef {import("./override-tester")["OverrideTester"]} OverrideTester */ - -/** - * @typedef {Object} ConfigArrayElement - * @property {string} name The name of this config element. - * @property {string} filePath The path to the source file of this config element. - * @property {InstanceType|null} criteria The tester for the `files` and `excludedFiles` of this config element. - * @property {Record|undefined} env The environment settings. - * @property {Record|undefined} globals The global variable settings. - * @property {IgnorePattern|undefined} ignorePattern The ignore patterns. - * @property {boolean|undefined} noInlineConfig The flag that disables directive comments. - * @property {DependentParser|undefined} parser The parser loader. - * @property {Object|undefined} parserOptions The parser options. - * @property {Record|undefined} plugins The plugin loaders. - * @property {string|undefined} processor The processor name to refer plugin's processor. - * @property {boolean|undefined} reportUnusedDisableDirectives The flag to report unused `eslint-disable` comments. - * @property {boolean|undefined} root The flag to express root. - * @property {Record|undefined} rules The rule settings - * @property {Object|undefined} settings The shared settings. - * @property {"config" | "ignore" | "implicit-processor"} type The element type. - */ - -/** - * @typedef {Object} ConfigArrayInternalSlots - * @property {Map} cache The cache to extract configs. - * @property {ReadonlyMap|null} envMap The map from environment ID to environment definition. - * @property {ReadonlyMap|null} processorMap The map from processor ID to environment definition. - * @property {ReadonlyMap|null} ruleMap The map from rule ID to rule definition. - */ - -/** @type {WeakMap} */ -const internalSlotsMap = new class extends WeakMap { - get(key) { - let value = super.get(key); - - if (!value) { - value = { - cache: new Map(), - envMap: null, - processorMap: null, - ruleMap: null - }; - super.set(key, value); - } - - return value; - } -}(); - -/** - * Get the indices which are matched to a given file. - * @param {ConfigArrayElement[]} elements The elements. - * @param {string} filePath The path to a target file. - * @returns {number[]} The indices. - */ -function getMatchedIndices(elements, filePath) { - const indices = []; - - for (let i = elements.length - 1; i >= 0; --i) { - const element = elements[i]; - - if (!element.criteria || (filePath && element.criteria.test(filePath))) { - indices.push(i); - } - } - - return indices; -} - -/** - * Check if a value is a non-null object. - * @param {any} x The value to check. - * @returns {boolean} `true` if the value is a non-null object. - */ -function isNonNullObject(x) { - return typeof x === "object" && x !== null; -} - -/** - * Merge two objects. - * - * Assign every property values of `y` to `x` if `x` doesn't have the property. - * If `x`'s property value is an object, it does recursive. - * @param {Object} target The destination to merge - * @param {Object|undefined} source The source to merge. - * @returns {void} - */ -function mergeWithoutOverwrite(target, source) { - if (!isNonNullObject(source)) { - return; - } - - for (const key of Object.keys(source)) { - if (key === "__proto__") { - continue; - } - - if (isNonNullObject(target[key])) { - mergeWithoutOverwrite(target[key], source[key]); - } else if (target[key] === void 0) { - if (isNonNullObject(source[key])) { - target[key] = Array.isArray(source[key]) ? [] : {}; - mergeWithoutOverwrite(target[key], source[key]); - } else if (source[key] !== void 0) { - target[key] = source[key]; - } - } - } -} - -/** - * The error for plugin conflicts. - */ -class PluginConflictError extends Error { - - /** - * Initialize this error object. - * @param {string} pluginId The plugin ID. - * @param {{filePath:string, importerName:string}[]} plugins The resolved plugins. - */ - constructor(pluginId, plugins) { - super(`Plugin "${pluginId}" was conflicted between ${plugins.map(p => `"${p.importerName}"`).join(" and ")}.`); - this.messageTemplate = "plugin-conflict"; - this.messageData = { pluginId, plugins }; - } -} - -/** - * Merge plugins. - * `target`'s definition is prior to `source`'s. - * @param {Record} target The destination to merge - * @param {Record|undefined} source The source to merge. - * @returns {void} - */ -function mergePlugins(target, source) { - if (!isNonNullObject(source)) { - return; - } - - for (const key of Object.keys(source)) { - if (key === "__proto__") { - continue; - } - const targetValue = target[key]; - const sourceValue = source[key]; - - // Adopt the plugin which was found at first. - if (targetValue === void 0) { - if (sourceValue.error) { - throw sourceValue.error; - } - target[key] = sourceValue; - } else if (sourceValue.filePath !== targetValue.filePath) { - throw new PluginConflictError(key, [ - { - filePath: targetValue.filePath, - importerName: targetValue.importerName - }, - { - filePath: sourceValue.filePath, - importerName: sourceValue.importerName - } - ]); - } - } -} - -/** - * Merge rule configs. - * `target`'s definition is prior to `source`'s. - * @param {Record} target The destination to merge - * @param {Record|undefined} source The source to merge. - * @returns {void} - */ -function mergeRuleConfigs(target, source) { - if (!isNonNullObject(source)) { - return; - } - - for (const key of Object.keys(source)) { - if (key === "__proto__") { - continue; - } - const targetDef = target[key]; - const sourceDef = source[key]; - - // Adopt the rule config which was found at first. - if (targetDef === void 0) { - if (Array.isArray(sourceDef)) { - target[key] = [...sourceDef]; - } else { - target[key] = [sourceDef]; - } - - /* - * If the first found rule config is severity only and the current rule - * config has options, merge the severity and the options. - */ - } else if ( - targetDef.length === 1 && - Array.isArray(sourceDef) && - sourceDef.length >= 2 - ) { - targetDef.push(...sourceDef.slice(1)); - } - } -} - -/** - * Create the extracted config. - * @param {ConfigArray} instance The config elements. - * @param {number[]} indices The indices to use. - * @returns {ExtractedConfig} The extracted config. - */ -function createConfig(instance, indices) { - const config = new ExtractedConfig(); - const ignorePatterns = []; - - // Merge elements. - for (const index of indices) { - const element = instance[index]; - - // Adopt the parser which was found at first. - if (!config.parser && element.parser) { - if (element.parser.error) { - throw element.parser.error; - } - config.parser = element.parser; - } - - // Adopt the processor which was found at first. - if (!config.processor && element.processor) { - config.processor = element.processor; - } - - // Adopt the noInlineConfig which was found at first. - if (config.noInlineConfig === void 0 && element.noInlineConfig !== void 0) { - config.noInlineConfig = element.noInlineConfig; - config.configNameOfNoInlineConfig = element.name; - } - - // Adopt the reportUnusedDisableDirectives which was found at first. - if (config.reportUnusedDisableDirectives === void 0 && element.reportUnusedDisableDirectives !== void 0) { - config.reportUnusedDisableDirectives = element.reportUnusedDisableDirectives; - } - - // Collect ignorePatterns - if (element.ignorePattern) { - ignorePatterns.push(element.ignorePattern); - } - - // Merge others. - mergeWithoutOverwrite(config.env, element.env); - mergeWithoutOverwrite(config.globals, element.globals); - mergeWithoutOverwrite(config.parserOptions, element.parserOptions); - mergeWithoutOverwrite(config.settings, element.settings); - mergePlugins(config.plugins, element.plugins); - mergeRuleConfigs(config.rules, element.rules); - } - - // Create the predicate function for ignore patterns. - if (ignorePatterns.length > 0) { - config.ignores = IgnorePattern.createIgnore(ignorePatterns.reverse()); - } - - return config; -} - -/** - * Collect definitions. - * @template T, U - * @param {string} pluginId The plugin ID for prefix. - * @param {Record} defs The definitions to collect. - * @param {Map} map The map to output. - * @returns {void} - */ -function collect(pluginId, defs, map) { - if (defs) { - const prefix = pluginId && `${pluginId}/`; - - for (const [key, value] of Object.entries(defs)) { - map.set(`${prefix}${key}`, value); - } - } -} - -/** - * Delete the mutation methods from a given map. - * @param {Map} map The map object to delete. - * @returns {void} - */ -function deleteMutationMethods(map) { - Object.defineProperties(map, { - clear: { configurable: true, value: void 0 }, - delete: { configurable: true, value: void 0 }, - set: { configurable: true, value: void 0 } - }); -} - -/** - * Create `envMap`, `processorMap`, `ruleMap` with the plugins in the config array. - * @param {ConfigArrayElement[]} elements The config elements. - * @param {ConfigArrayInternalSlots} slots The internal slots. - * @returns {void} - */ -function initPluginMemberMaps(elements, slots) { - const processed = new Set(); - - slots.envMap = new Map(); - slots.processorMap = new Map(); - slots.ruleMap = new Map(); - - for (const element of elements) { - if (!element.plugins) { - continue; - } - - for (const [pluginId, value] of Object.entries(element.plugins)) { - const plugin = value.definition; - - if (!plugin || processed.has(pluginId)) { - continue; - } - processed.add(pluginId); - - collect(pluginId, plugin.environments, slots.envMap); - collect(pluginId, plugin.processors, slots.processorMap); - collect(pluginId, plugin.rules, slots.ruleMap); - } - } - - deleteMutationMethods(slots.envMap); - deleteMutationMethods(slots.processorMap); - deleteMutationMethods(slots.ruleMap); -} - -/** - * Create `envMap`, `processorMap`, `ruleMap` with the plugins in the config array. - * @param {ConfigArray} instance The config elements. - * @returns {ConfigArrayInternalSlots} The extracted config. - */ -function ensurePluginMemberMaps(instance) { - const slots = internalSlotsMap.get(instance); - - if (!slots.ruleMap) { - initPluginMemberMaps(instance, slots); - } - - return slots; -} - -//------------------------------------------------------------------------------ -// Public Interface -//------------------------------------------------------------------------------ - -/** - * The Config Array. - * - * `ConfigArray` instance contains all settings, parsers, and plugins. - * You need to call `ConfigArray#extractConfig(filePath)` method in order to - * extract, merge and get only the config data which is related to an arbitrary - * file. - * @extends {Array} - */ -class ConfigArray extends Array { - - /** - * Get the plugin environments. - * The returned map cannot be mutated. - * @type {ReadonlyMap} The plugin environments. - */ - get pluginEnvironments() { - return ensurePluginMemberMaps(this).envMap; - } - - /** - * Get the plugin processors. - * The returned map cannot be mutated. - * @type {ReadonlyMap} The plugin processors. - */ - get pluginProcessors() { - return ensurePluginMemberMaps(this).processorMap; - } - - /** - * Get the plugin rules. - * The returned map cannot be mutated. - * @returns {ReadonlyMap} The plugin rules. - */ - get pluginRules() { - return ensurePluginMemberMaps(this).ruleMap; - } - - /** - * Check if this config has `root` flag. - * @returns {boolean} `true` if this config array is root. - */ - isRoot() { - for (let i = this.length - 1; i >= 0; --i) { - const root = this[i].root; - - if (typeof root === "boolean") { - return root; - } - } - return false; - } - - /** - * Extract the config data which is related to a given file. - * @param {string} filePath The absolute path to the target file. - * @returns {ExtractedConfig} The extracted config data. - */ - extractConfig(filePath) { - const { cache } = internalSlotsMap.get(this); - const indices = getMatchedIndices(this, filePath); - const cacheKey = indices.join(","); - - if (!cache.has(cacheKey)) { - cache.set(cacheKey, createConfig(this, indices)); - } - - return cache.get(cacheKey); - } - - /** - * Check if a given path is an additional lint target. - * @param {string} filePath The absolute path to the target file. - * @returns {boolean} `true` if the file is an additional lint target. - */ - isAdditionalTargetPath(filePath) { - for (const { criteria, type } of this) { - if ( - type === "config" && - criteria && - !criteria.endsWithWildcard && - criteria.test(filePath) - ) { - return true; - } - } - return false; - } -} - -/** - * Get the used extracted configs. - * CLIEngine will use this method to collect used deprecated rules. - * @param {ConfigArray} instance The config array object to get. - * @returns {ExtractedConfig[]} The used extracted configs. - * @private - */ -function getUsedExtractedConfigs(instance) { - const { cache } = internalSlotsMap.get(instance); - - return Array.from(cache.values()); -} - - -export { - ConfigArray, - getUsedExtractedConfigs -}; diff --git a/tools/eslint/node_modules/@eslint/eslintrc/lib/config-array/config-dependency.js b/tools/eslint/node_modules/@eslint/eslintrc/lib/config-array/config-dependency.js deleted file mode 100644 index 080e6405e9ba2c..00000000000000 --- a/tools/eslint/node_modules/@eslint/eslintrc/lib/config-array/config-dependency.js +++ /dev/null @@ -1,124 +0,0 @@ -/** - * @fileoverview `ConfigDependency` class. - * - * `ConfigDependency` class expresses a loaded parser or plugin. - * - * If the parser or plugin was loaded successfully, it has `definition` property - * and `filePath` property. Otherwise, it has `error` property. - * - * When `JSON.stringify()` converted a `ConfigDependency` object to a JSON, it - * omits `definition` property. - * - * `ConfigArrayFactory` creates `ConfigDependency` objects when it loads parsers - * or plugins. - * - * @author Toru Nagashima - */ - -import util from "util"; - -/** - * The class is to store parsers or plugins. - * This class hides the loaded object from `JSON.stringify()` and `console.log`. - * @template T - */ -class ConfigDependency { - - /** - * Initialize this instance. - * @param {Object} data The dependency data. - * @param {T} [data.definition] The dependency if the loading succeeded. - * @param {T} [data.original] The original, non-normalized dependency if the loading succeeded. - * @param {Error} [data.error] The error object if the loading failed. - * @param {string} [data.filePath] The actual path to the dependency if the loading succeeded. - * @param {string} data.id The ID of this dependency. - * @param {string} data.importerName The name of the config file which loads this dependency. - * @param {string} data.importerPath The path to the config file which loads this dependency. - */ - constructor({ - definition = null, - original = null, - error = null, - filePath = null, - id, - importerName, - importerPath - }) { - - /** - * The loaded dependency if the loading succeeded. - * @type {T|null} - */ - this.definition = definition; - - /** - * The original dependency as loaded directly from disk if the loading succeeded. - * @type {T|null} - */ - this.original = original; - - /** - * The error object if the loading failed. - * @type {Error|null} - */ - this.error = error; - - /** - * The loaded dependency if the loading succeeded. - * @type {string|null} - */ - this.filePath = filePath; - - /** - * The ID of this dependency. - * @type {string} - */ - this.id = id; - - /** - * The name of the config file which loads this dependency. - * @type {string} - */ - this.importerName = importerName; - - /** - * The path to the config file which loads this dependency. - * @type {string} - */ - this.importerPath = importerPath; - } - - // eslint-disable-next-line jsdoc/require-description - /** - * @returns {Object} a JSON compatible object. - */ - toJSON() { - const obj = this[util.inspect.custom](); - - // Display `error.message` (`Error#message` is unenumerable). - if (obj.error instanceof Error) { - obj.error = { ...obj.error, message: obj.error.message }; - } - - return obj; - } - - // eslint-disable-next-line jsdoc/require-description - /** - * @returns {Object} an object to display by `console.log()`. - */ - [util.inspect.custom]() { - const { - definition: _ignore1, // eslint-disable-line no-unused-vars - original: _ignore2, // eslint-disable-line no-unused-vars - ...obj - } = this; - - return obj; - } -} - -/** @typedef {ConfigDependency} DependentParser */ -/** @typedef {ConfigDependency} DependentPlugin */ - -export { ConfigDependency }; diff --git a/tools/eslint/node_modules/@eslint/eslintrc/lib/config-array/extracted-config.js b/tools/eslint/node_modules/@eslint/eslintrc/lib/config-array/extracted-config.js deleted file mode 100644 index e93b0b67b6500b..00000000000000 --- a/tools/eslint/node_modules/@eslint/eslintrc/lib/config-array/extracted-config.js +++ /dev/null @@ -1,145 +0,0 @@ -/** - * @fileoverview `ExtractedConfig` class. - * - * `ExtractedConfig` class expresses a final configuration for a specific file. - * - * It provides one method. - * - * - `toCompatibleObjectAsConfigFileContent()` - * Convert this configuration to the compatible object as the content of - * config files. It converts the loaded parser and plugins to strings. - * `CLIEngine#getConfigForFile(filePath)` method uses this method. - * - * `ConfigArray#extractConfig(filePath)` creates a `ExtractedConfig` instance. - * - * @author Toru Nagashima - */ - -import { IgnorePattern } from "./ignore-pattern.js"; - -// For VSCode intellisense -/** @typedef {import("../../shared/types").ConfigData} ConfigData */ -/** @typedef {import("../../shared/types").GlobalConf} GlobalConf */ -/** @typedef {import("../../shared/types").SeverityConf} SeverityConf */ -/** @typedef {import("./config-dependency").DependentParser} DependentParser */ -/** @typedef {import("./config-dependency").DependentPlugin} DependentPlugin */ - -/** - * Check if `xs` starts with `ys`. - * @template T - * @param {T[]} xs The array to check. - * @param {T[]} ys The array that may be the first part of `xs`. - * @returns {boolean} `true` if `xs` starts with `ys`. - */ -function startsWith(xs, ys) { - return xs.length >= ys.length && ys.every((y, i) => y === xs[i]); -} - -/** - * The class for extracted config data. - */ -class ExtractedConfig { - constructor() { - - /** - * The config name what `noInlineConfig` setting came from. - * @type {string} - */ - this.configNameOfNoInlineConfig = ""; - - /** - * Environments. - * @type {Record} - */ - this.env = {}; - - /** - * Global variables. - * @type {Record} - */ - this.globals = {}; - - /** - * The glob patterns that ignore to lint. - * @type {(((filePath:string, dot?:boolean) => boolean) & { basePath:string; patterns:string[] }) | undefined} - */ - this.ignores = void 0; - - /** - * The flag that disables directive comments. - * @type {boolean|undefined} - */ - this.noInlineConfig = void 0; - - /** - * Parser definition. - * @type {DependentParser|null} - */ - this.parser = null; - - /** - * Options for the parser. - * @type {Object} - */ - this.parserOptions = {}; - - /** - * Plugin definitions. - * @type {Record} - */ - this.plugins = {}; - - /** - * Processor ID. - * @type {string|null} - */ - this.processor = null; - - /** - * The flag that reports unused `eslint-disable` directive comments. - * @type {boolean|undefined} - */ - this.reportUnusedDisableDirectives = void 0; - - /** - * Rule settings. - * @type {Record} - */ - this.rules = {}; - - /** - * Shared settings. - * @type {Object} - */ - this.settings = {}; - } - - /** - * Convert this config to the compatible object as a config file content. - * @returns {ConfigData} The converted object. - */ - toCompatibleObjectAsConfigFileContent() { - const { - /* eslint-disable no-unused-vars */ - configNameOfNoInlineConfig: _ignore1, - processor: _ignore2, - /* eslint-enable no-unused-vars */ - ignores, - ...config - } = this; - - config.parser = config.parser && config.parser.filePath; - config.plugins = Object.keys(config.plugins).filter(Boolean).reverse(); - config.ignorePatterns = ignores ? ignores.patterns : []; - - // Strip the default patterns from `ignorePatterns`. - if (startsWith(config.ignorePatterns, IgnorePattern.DefaultPatterns)) { - config.ignorePatterns = - config.ignorePatterns.slice(IgnorePattern.DefaultPatterns.length); - } - - return config; - } -} - -export { ExtractedConfig }; diff --git a/tools/eslint/node_modules/@eslint/eslintrc/lib/config-array/ignore-pattern.js b/tools/eslint/node_modules/@eslint/eslintrc/lib/config-array/ignore-pattern.js deleted file mode 100644 index 3022ba9f487dbf..00000000000000 --- a/tools/eslint/node_modules/@eslint/eslintrc/lib/config-array/ignore-pattern.js +++ /dev/null @@ -1,238 +0,0 @@ -/** - * @fileoverview `IgnorePattern` class. - * - * `IgnorePattern` class has the set of glob patterns and the base path. - * - * It provides two static methods. - * - * - `IgnorePattern.createDefaultIgnore(cwd)` - * Create the default predicate function. - * - `IgnorePattern.createIgnore(ignorePatterns)` - * Create the predicate function from multiple `IgnorePattern` objects. - * - * It provides two properties and a method. - * - * - `patterns` - * The glob patterns that ignore to lint. - * - `basePath` - * The base path of the glob patterns. If absolute paths existed in the - * glob patterns, those are handled as relative paths to the base path. - * - `getPatternsRelativeTo(basePath)` - * Get `patterns` as modified for a given base path. It modifies the - * absolute paths in the patterns as prepending the difference of two base - * paths. - * - * `ConfigArrayFactory` creates `IgnorePattern` objects when it processes - * `ignorePatterns` properties. - * - * @author Toru Nagashima - */ - -//------------------------------------------------------------------------------ -// Requirements -//------------------------------------------------------------------------------ - -import assert from "assert"; -import path from "path"; -import ignore from "ignore"; -import debugOrig from "debug"; - -const debug = debugOrig("eslintrc:ignore-pattern"); - -/** @typedef {ReturnType} Ignore */ - -//------------------------------------------------------------------------------ -// Helpers -//------------------------------------------------------------------------------ - -/** - * Get the path to the common ancestor directory of given paths. - * @param {string[]} sourcePaths The paths to calculate the common ancestor. - * @returns {string} The path to the common ancestor directory. - */ -function getCommonAncestorPath(sourcePaths) { - let result = sourcePaths[0]; - - for (let i = 1; i < sourcePaths.length; ++i) { - const a = result; - const b = sourcePaths[i]; - - // Set the shorter one (it's the common ancestor if one includes the other). - result = a.length < b.length ? a : b; - - // Set the common ancestor. - for (let j = 0, lastSepPos = 0; j < a.length && j < b.length; ++j) { - if (a[j] !== b[j]) { - result = a.slice(0, lastSepPos); - break; - } - if (a[j] === path.sep) { - lastSepPos = j; - } - } - } - - let resolvedResult = result || path.sep; - - // if Windows common ancestor is root of drive must have trailing slash to be absolute. - if (resolvedResult && resolvedResult.endsWith(":") && process.platform === "win32") { - resolvedResult += path.sep; - } - return resolvedResult; -} - -/** - * Make relative path. - * @param {string} from The source path to get relative path. - * @param {string} to The destination path to get relative path. - * @returns {string} The relative path. - */ -function relative(from, to) { - const relPath = path.relative(from, to); - - if (path.sep === "/") { - return relPath; - } - return relPath.split(path.sep).join("/"); -} - -/** - * Get the trailing slash if existed. - * @param {string} filePath The path to check. - * @returns {string} The trailing slash if existed. - */ -function dirSuffix(filePath) { - const isDir = ( - filePath.endsWith(path.sep) || - (process.platform === "win32" && filePath.endsWith("/")) - ); - - return isDir ? "/" : ""; -} - -const DefaultPatterns = Object.freeze(["/**/node_modules/*"]); -const DotPatterns = Object.freeze([".*", "!.eslintrc.*", "!../"]); - -//------------------------------------------------------------------------------ -// Public -//------------------------------------------------------------------------------ - -class IgnorePattern { - - /** - * The default patterns. - * @type {string[]} - */ - static get DefaultPatterns() { - return DefaultPatterns; - } - - /** - * Create the default predicate function. - * @param {string} cwd The current working directory. - * @returns {((filePath:string, dot:boolean) => boolean) & {basePath:string; patterns:string[]}} - * The preficate function. - * The first argument is an absolute path that is checked. - * The second argument is the flag to not ignore dotfiles. - * If the predicate function returned `true`, it means the path should be ignored. - */ - static createDefaultIgnore(cwd) { - return this.createIgnore([new IgnorePattern(DefaultPatterns, cwd)]); - } - - /** - * Create the predicate function from multiple `IgnorePattern` objects. - * @param {IgnorePattern[]} ignorePatterns The list of ignore patterns. - * @returns {((filePath:string, dot?:boolean) => boolean) & {basePath:string; patterns:string[]}} - * The preficate function. - * The first argument is an absolute path that is checked. - * The second argument is the flag to not ignore dotfiles. - * If the predicate function returned `true`, it means the path should be ignored. - */ - static createIgnore(ignorePatterns) { - debug("Create with: %o", ignorePatterns); - - const basePath = getCommonAncestorPath(ignorePatterns.map(p => p.basePath)); - const patterns = [].concat( - ...ignorePatterns.map(p => p.getPatternsRelativeTo(basePath)) - ); - const ig = ignore({ allowRelativePaths: true }).add([...DotPatterns, ...patterns]); - const dotIg = ignore({ allowRelativePaths: true }).add(patterns); - - debug(" processed: %o", { basePath, patterns }); - - return Object.assign( - (filePath, dot = false) => { - assert(path.isAbsolute(filePath), "'filePath' should be an absolute path."); - const relPathRaw = relative(basePath, filePath); - const relPath = relPathRaw && (relPathRaw + dirSuffix(filePath)); - const adoptedIg = dot ? dotIg : ig; - const result = relPath !== "" && adoptedIg.ignores(relPath); - - debug("Check", { filePath, dot, relativePath: relPath, result }); - return result; - }, - { basePath, patterns } - ); - } - - /** - * Initialize a new `IgnorePattern` instance. - * @param {string[]} patterns The glob patterns that ignore to lint. - * @param {string} basePath The base path of `patterns`. - */ - constructor(patterns, basePath) { - assert(path.isAbsolute(basePath), "'basePath' should be an absolute path."); - - /** - * The glob patterns that ignore to lint. - * @type {string[]} - */ - this.patterns = patterns; - - /** - * The base path of `patterns`. - * @type {string} - */ - this.basePath = basePath; - - /** - * If `true` then patterns which don't start with `/` will match the paths to the outside of `basePath`. Defaults to `false`. - * - * It's set `true` for `.eslintignore`, `package.json`, and `--ignore-path` for backward compatibility. - * It's `false` as-is for `ignorePatterns` property in config files. - * @type {boolean} - */ - this.loose = false; - } - - /** - * Get `patterns` as modified for a given base path. It modifies the - * absolute paths in the patterns as prepending the difference of two base - * paths. - * @param {string} newBasePath The base path. - * @returns {string[]} Modifired patterns. - */ - getPatternsRelativeTo(newBasePath) { - assert(path.isAbsolute(newBasePath), "'newBasePath' should be an absolute path."); - const { basePath, loose, patterns } = this; - - if (newBasePath === basePath) { - return patterns; - } - const prefix = `/${relative(newBasePath, basePath)}`; - - return patterns.map(pattern => { - const negative = pattern.startsWith("!"); - const head = negative ? "!" : ""; - const body = negative ? pattern.slice(1) : pattern; - - if (body.startsWith("/") || body.startsWith("../")) { - return `${head}${prefix}${body}`; - } - return loose ? pattern : `${head}${prefix}/**/${body}`; - }); - } -} - -export { IgnorePattern }; diff --git a/tools/eslint/node_modules/@eslint/eslintrc/lib/config-array/index.js b/tools/eslint/node_modules/@eslint/eslintrc/lib/config-array/index.js deleted file mode 100644 index 647f02b7469b80..00000000000000 --- a/tools/eslint/node_modules/@eslint/eslintrc/lib/config-array/index.js +++ /dev/null @@ -1,19 +0,0 @@ -/** - * @fileoverview `ConfigArray` class. - * @author Toru Nagashima - */ - -import { ConfigArray, getUsedExtractedConfigs } from "./config-array.js"; -import { ConfigDependency } from "./config-dependency.js"; -import { ExtractedConfig } from "./extracted-config.js"; -import { IgnorePattern } from "./ignore-pattern.js"; -import { OverrideTester } from "./override-tester.js"; - -export { - ConfigArray, - ConfigDependency, - ExtractedConfig, - IgnorePattern, - OverrideTester, - getUsedExtractedConfigs -}; diff --git a/tools/eslint/node_modules/@eslint/eslintrc/lib/config-array/override-tester.js b/tools/eslint/node_modules/@eslint/eslintrc/lib/config-array/override-tester.js deleted file mode 100644 index 460aafcf80c384..00000000000000 --- a/tools/eslint/node_modules/@eslint/eslintrc/lib/config-array/override-tester.js +++ /dev/null @@ -1,225 +0,0 @@ -/** - * @fileoverview `OverrideTester` class. - * - * `OverrideTester` class handles `files` property and `excludedFiles` property - * of `overrides` config. - * - * It provides one method. - * - * - `test(filePath)` - * Test if a file path matches the pair of `files` property and - * `excludedFiles` property. The `filePath` argument must be an absolute - * path. - * - * `ConfigArrayFactory` creates `OverrideTester` objects when it processes - * `overrides` properties. - * - * @author Toru Nagashima - */ - -import assert from "assert"; -import path from "path"; -import util from "util"; -import minimatch from "minimatch"; - -const { Minimatch } = minimatch; - -const minimatchOpts = { dot: true, matchBase: true }; - -/** - * @typedef {Object} Pattern - * @property {InstanceType[] | null} includes The positive matchers. - * @property {InstanceType[] | null} excludes The negative matchers. - */ - -/** - * Normalize a given pattern to an array. - * @param {string|string[]|undefined} patterns A glob pattern or an array of glob patterns. - * @returns {string[]|null} Normalized patterns. - * @private - */ -function normalizePatterns(patterns) { - if (Array.isArray(patterns)) { - return patterns.filter(Boolean); - } - if (typeof patterns === "string" && patterns) { - return [patterns]; - } - return []; -} - -/** - * Create the matchers of given patterns. - * @param {string[]} patterns The patterns. - * @returns {InstanceType[] | null} The matchers. - */ -function toMatcher(patterns) { - if (patterns.length === 0) { - return null; - } - return patterns.map(pattern => { - if (/^\.[/\\]/u.test(pattern)) { - return new Minimatch( - pattern.slice(2), - - // `./*.js` should not match with `subdir/foo.js` - { ...minimatchOpts, matchBase: false } - ); - } - return new Minimatch(pattern, minimatchOpts); - }); -} - -/** - * Convert a given matcher to string. - * @param {Pattern} matchers The matchers. - * @returns {string} The string expression of the matcher. - */ -function patternToJson({ includes, excludes }) { - return { - includes: includes && includes.map(m => m.pattern), - excludes: excludes && excludes.map(m => m.pattern) - }; -} - -/** - * The class to test given paths are matched by the patterns. - */ -class OverrideTester { - - /** - * Create a tester with given criteria. - * If there are no criteria, returns `null`. - * @param {string|string[]} files The glob patterns for included files. - * @param {string|string[]} excludedFiles The glob patterns for excluded files. - * @param {string} basePath The path to the base directory to test paths. - * @returns {OverrideTester|null} The created instance or `null`. - */ - static create(files, excludedFiles, basePath) { - const includePatterns = normalizePatterns(files); - const excludePatterns = normalizePatterns(excludedFiles); - let endsWithWildcard = false; - - if (includePatterns.length === 0) { - return null; - } - - // Rejects absolute paths or relative paths to parents. - for (const pattern of includePatterns) { - if (path.isAbsolute(pattern) || pattern.includes("..")) { - throw new Error(`Invalid override pattern (expected relative path not containing '..'): ${pattern}`); - } - if (pattern.endsWith("*")) { - endsWithWildcard = true; - } - } - for (const pattern of excludePatterns) { - if (path.isAbsolute(pattern) || pattern.includes("..")) { - throw new Error(`Invalid override pattern (expected relative path not containing '..'): ${pattern}`); - } - } - - const includes = toMatcher(includePatterns); - const excludes = toMatcher(excludePatterns); - - return new OverrideTester( - [{ includes, excludes }], - basePath, - endsWithWildcard - ); - } - - /** - * Combine two testers by logical and. - * If either of the testers was `null`, returns the other tester. - * The `basePath` property of the two must be the same value. - * @param {OverrideTester|null} a A tester. - * @param {OverrideTester|null} b Another tester. - * @returns {OverrideTester|null} Combined tester. - */ - static and(a, b) { - if (!b) { - return a && new OverrideTester( - a.patterns, - a.basePath, - a.endsWithWildcard - ); - } - if (!a) { - return new OverrideTester( - b.patterns, - b.basePath, - b.endsWithWildcard - ); - } - - assert.strictEqual(a.basePath, b.basePath); - return new OverrideTester( - a.patterns.concat(b.patterns), - a.basePath, - a.endsWithWildcard || b.endsWithWildcard - ); - } - - /** - * Initialize this instance. - * @param {Pattern[]} patterns The matchers. - * @param {string} basePath The base path. - * @param {boolean} endsWithWildcard If `true` then a pattern ends with `*`. - */ - constructor(patterns, basePath, endsWithWildcard = false) { - - /** @type {Pattern[]} */ - this.patterns = patterns; - - /** @type {string} */ - this.basePath = basePath; - - /** @type {boolean} */ - this.endsWithWildcard = endsWithWildcard; - } - - /** - * Test if a given path is matched or not. - * @param {string} filePath The absolute path to the target file. - * @returns {boolean} `true` if the path was matched. - */ - test(filePath) { - if (typeof filePath !== "string" || !path.isAbsolute(filePath)) { - throw new Error(`'filePath' should be an absolute path, but got ${filePath}.`); - } - const relativePath = path.relative(this.basePath, filePath); - - return this.patterns.every(({ includes, excludes }) => ( - (!includes || includes.some(m => m.match(relativePath))) && - (!excludes || !excludes.some(m => m.match(relativePath))) - )); - } - - // eslint-disable-next-line jsdoc/require-description - /** - * @returns {Object} a JSON compatible object. - */ - toJSON() { - if (this.patterns.length === 1) { - return { - ...patternToJson(this.patterns[0]), - basePath: this.basePath - }; - } - return { - AND: this.patterns.map(patternToJson), - basePath: this.basePath - }; - } - - // eslint-disable-next-line jsdoc/require-description - /** - * @returns {Object} an object to display by `console.log()`. - */ - [util.inspect.custom]() { - return this.toJSON(); - } -} - -export { OverrideTester }; diff --git a/tools/eslint/node_modules/@eslint/eslintrc/lib/flat-compat.js b/tools/eslint/node_modules/@eslint/eslintrc/lib/flat-compat.js deleted file mode 100644 index 6c307a99246ae0..00000000000000 --- a/tools/eslint/node_modules/@eslint/eslintrc/lib/flat-compat.js +++ /dev/null @@ -1,318 +0,0 @@ -/** - * @fileoverview Compatibility class for flat config. - * @author Nicholas C. Zakas - */ - -//----------------------------------------------------------------------------- -// Requirements -//----------------------------------------------------------------------------- - -import createDebug from "debug"; -import path from "path"; - -import environments from "../conf/environments.js"; -import { ConfigArrayFactory } from "./config-array-factory.js"; - -//----------------------------------------------------------------------------- -// Helpers -//----------------------------------------------------------------------------- - -/** @typedef {import("../../shared/types").Environment} Environment */ -/** @typedef {import("../../shared/types").Processor} Processor */ - -const debug = createDebug("eslintrc:flat-compat"); -const cafactory = Symbol("cafactory"); - -/** - * Translates an ESLintRC-style config object into a flag-config-style config - * object. - * @param {Object} eslintrcConfig An ESLintRC-style config object. - * @param {Object} options Options to help translate the config. - * @param {string} options.resolveConfigRelativeTo To the directory to resolve - * configs from. - * @param {string} options.resolvePluginsRelativeTo The directory to resolve - * plugins from. - * @param {ReadOnlyMap} options.pluginEnvironments A map of plugin environment - * names to objects. - * @param {ReadOnlyMap} options.pluginProcessors A map of plugin processor - * names to objects. - * @returns {Object} A flag-config-style config object. - */ -function translateESLintRC(eslintrcConfig, { - resolveConfigRelativeTo, - resolvePluginsRelativeTo, - pluginEnvironments, - pluginProcessors -}) { - - const flatConfig = {}; - const configs = []; - const languageOptions = {}; - const linterOptions = {}; - const keysToCopy = ["settings", "rules", "processor"]; - const languageOptionsKeysToCopy = ["globals", "parser", "parserOptions"]; - const linterOptionsKeysToCopy = ["noInlineConfig", "reportUnusedDisableDirectives"]; - - // copy over simple translations - for (const key of keysToCopy) { - if (key in eslintrcConfig && typeof eslintrcConfig[key] !== "undefined") { - flatConfig[key] = eslintrcConfig[key]; - } - } - - // copy over languageOptions - for (const key of languageOptionsKeysToCopy) { - if (key in eslintrcConfig && typeof eslintrcConfig[key] !== "undefined") { - - // create the languageOptions key in the flat config - flatConfig.languageOptions = languageOptions; - - if (key === "parser") { - debug(`Resolving parser '${languageOptions[key]}' relative to ${resolveConfigRelativeTo}`); - - if (eslintrcConfig[key].error) { - throw eslintrcConfig[key].error; - } - - languageOptions[key] = eslintrcConfig[key].definition; - continue; - } - - // clone any object values that are in the eslintrc config - if (eslintrcConfig[key] && typeof eslintrcConfig[key] === "object") { - languageOptions[key] = { - ...eslintrcConfig[key] - }; - } else { - languageOptions[key] = eslintrcConfig[key]; - } - } - } - - // copy over linterOptions - for (const key of linterOptionsKeysToCopy) { - if (key in eslintrcConfig && typeof eslintrcConfig[key] !== "undefined") { - flatConfig.linterOptions = linterOptions; - linterOptions[key] = eslintrcConfig[key]; - } - } - - // move ecmaVersion a level up - if (languageOptions.parserOptions) { - - if ("ecmaVersion" in languageOptions.parserOptions) { - languageOptions.ecmaVersion = languageOptions.parserOptions.ecmaVersion; - delete languageOptions.parserOptions.ecmaVersion; - } - - if ("sourceType" in languageOptions.parserOptions) { - languageOptions.sourceType = languageOptions.parserOptions.sourceType; - delete languageOptions.parserOptions.sourceType; - } - - // check to see if we even need parserOptions anymore and remove it if not - if (Object.keys(languageOptions.parserOptions).length === 0) { - delete languageOptions.parserOptions; - } - } - - // overrides - if (eslintrcConfig.criteria) { - flatConfig.files = [absoluteFilePath => eslintrcConfig.criteria.test(absoluteFilePath)]; - } - - // translate plugins - if (eslintrcConfig.plugins && typeof eslintrcConfig.plugins === "object") { - debug(`Translating plugins: ${eslintrcConfig.plugins}`); - - flatConfig.plugins = {}; - - for (const pluginName of Object.keys(eslintrcConfig.plugins)) { - - debug(`Translating plugin: ${pluginName}`); - debug(`Resolving plugin '${pluginName} relative to ${resolvePluginsRelativeTo}`); - - const { original: plugin, error } = eslintrcConfig.plugins[pluginName]; - - if (error) { - throw error; - } - - flatConfig.plugins[pluginName] = plugin; - - // create a config for any processors - if (plugin.processors) { - for (const processorName of Object.keys(plugin.processors)) { - if (processorName.startsWith(".")) { - debug(`Assigning processor: ${pluginName}/${processorName}`); - - configs.unshift({ - files: [`**/*${processorName}`], - processor: pluginProcessors.get(`${pluginName}/${processorName}`) - }); - } - - } - } - } - } - - // translate env - must come after plugins - if (eslintrcConfig.env && typeof eslintrcConfig.env === "object") { - for (const envName of Object.keys(eslintrcConfig.env)) { - - // only add environments that are true - if (eslintrcConfig.env[envName]) { - debug(`Translating environment: ${envName}`); - - if (environments.has(envName)) { - - // built-in environments should be defined first - configs.unshift(...translateESLintRC({ - criteria: eslintrcConfig.criteria, - ...environments.get(envName) - }, { - resolveConfigRelativeTo, - resolvePluginsRelativeTo - })); - } else if (pluginEnvironments.has(envName)) { - - // if the environment comes from a plugin, it should come after the plugin config - configs.push(...translateESLintRC({ - criteria: eslintrcConfig.criteria, - ...pluginEnvironments.get(envName) - }, { - resolveConfigRelativeTo, - resolvePluginsRelativeTo - })); - } - } - } - } - - // only add if there are actually keys in the config - if (Object.keys(flatConfig).length > 0) { - configs.push(flatConfig); - } - - return configs; -} - - -//----------------------------------------------------------------------------- -// Exports -//----------------------------------------------------------------------------- - -/** - * A compatibility class for working with configs. - */ -class FlatCompat { - - constructor({ - baseDirectory = process.cwd(), - resolvePluginsRelativeTo = baseDirectory, - recommendedConfig, - allConfig - } = {}) { - this.baseDirectory = baseDirectory; - this.resolvePluginsRelativeTo = resolvePluginsRelativeTo; - this[cafactory] = new ConfigArrayFactory({ - cwd: baseDirectory, - resolvePluginsRelativeTo, - getEslintAllConfig: () => { - - if (!allConfig) { - throw new TypeError("Missing parameter 'allConfig' in FlatCompat constructor."); - } - - return allConfig; - }, - getEslintRecommendedConfig: () => { - - if (!recommendedConfig) { - throw new TypeError("Missing parameter 'recommendedConfig' in FlatCompat constructor."); - } - - return recommendedConfig; - } - }); - } - - /** - * Translates an ESLintRC-style config into a flag-config-style config. - * @param {Object} eslintrcConfig The ESLintRC-style config object. - * @returns {Object} A flag-config-style config object. - */ - config(eslintrcConfig) { - const eslintrcArray = this[cafactory].create(eslintrcConfig, { - basePath: this.baseDirectory - }); - - const flatArray = []; - let hasIgnorePatterns = false; - - eslintrcArray.forEach(configData => { - if (configData.type === "config") { - hasIgnorePatterns = hasIgnorePatterns || configData.ignorePattern; - flatArray.push(...translateESLintRC(configData, { - resolveConfigRelativeTo: path.join(this.baseDirectory, "__placeholder.js"), - resolvePluginsRelativeTo: path.join(this.resolvePluginsRelativeTo, "__placeholder.js"), - pluginEnvironments: eslintrcArray.pluginEnvironments, - pluginProcessors: eslintrcArray.pluginProcessors - })); - } - }); - - // combine ignorePatterns to emulate ESLintRC behavior better - if (hasIgnorePatterns) { - flatArray.unshift({ - ignores: [filePath => { - - // Compute the final config for this file. - // This filters config array elements by `files`/`excludedFiles` then merges the elements. - const finalConfig = eslintrcArray.extractConfig(filePath); - - // Test the `ignorePattern` properties of the final config. - return Boolean(finalConfig.ignores) && finalConfig.ignores(filePath); - }] - }); - } - - return flatArray; - } - - /** - * Translates the `env` section of an ESLintRC-style config. - * @param {Object} envConfig The `env` section of an ESLintRC config. - * @returns {Object[]} An array of flag-config objects representing the environments. - */ - env(envConfig) { - return this.config({ - env: envConfig - }); - } - - /** - * Translates the `extends` section of an ESLintRC-style config. - * @param {...string} configsToExtend The names of the configs to load. - * @returns {Object[]} An array of flag-config objects representing the config. - */ - extends(...configsToExtend) { - return this.config({ - extends: configsToExtend - }); - } - - /** - * Translates the `plugins` section of an ESLintRC-style config. - * @param {...string} plugins The names of the plugins to load. - * @returns {Object[]} An array of flag-config objects representing the plugins. - */ - plugins(...plugins) { - return this.config({ - plugins - }); - } -} - -export { FlatCompat }; diff --git a/tools/eslint/node_modules/@eslint/eslintrc/lib/index-universal.js b/tools/eslint/node_modules/@eslint/eslintrc/lib/index-universal.js deleted file mode 100644 index 6f6b30265f27d4..00000000000000 --- a/tools/eslint/node_modules/@eslint/eslintrc/lib/index-universal.js +++ /dev/null @@ -1,29 +0,0 @@ -/** - * @fileoverview Package exports for @eslint/eslintrc - * @author Nicholas C. Zakas - */ -//------------------------------------------------------------------------------ -// Requirements -//------------------------------------------------------------------------------ - -import * as ConfigOps from "./shared/config-ops.js"; -import ConfigValidator from "./shared/config-validator.js"; -import * as naming from "./shared/naming.js"; -import environments from "../conf/environments.js"; - -//----------------------------------------------------------------------------- -// Exports -//----------------------------------------------------------------------------- - -const Legacy = { - environments, - - // shared - ConfigOps, - ConfigValidator, - naming -}; - -export { - Legacy -}; diff --git a/tools/eslint/node_modules/@eslint/eslintrc/lib/index.js b/tools/eslint/node_modules/@eslint/eslintrc/lib/index.js deleted file mode 100644 index a37e57465ac062..00000000000000 --- a/tools/eslint/node_modules/@eslint/eslintrc/lib/index.js +++ /dev/null @@ -1,58 +0,0 @@ -/** - * @fileoverview Package exports for @eslint/eslintrc - * @author Nicholas C. Zakas - */ -//------------------------------------------------------------------------------ -// Requirements -//------------------------------------------------------------------------------ - -import { - ConfigArrayFactory, - createContext as createConfigArrayFactoryContext, - loadConfigFile -} from "./config-array-factory.js"; - -import { CascadingConfigArrayFactory } from "./cascading-config-array-factory.js"; -import * as ModuleResolver from "./shared/relative-module-resolver.js"; -import { ConfigArray, getUsedExtractedConfigs } from "./config-array/index.js"; -import { ConfigDependency } from "./config-array/config-dependency.js"; -import { ExtractedConfig } from "./config-array/extracted-config.js"; -import { IgnorePattern } from "./config-array/ignore-pattern.js"; -import { OverrideTester } from "./config-array/override-tester.js"; -import * as ConfigOps from "./shared/config-ops.js"; -import ConfigValidator from "./shared/config-validator.js"; -import * as naming from "./shared/naming.js"; -import { FlatCompat } from "./flat-compat.js"; -import environments from "../conf/environments.js"; - -//----------------------------------------------------------------------------- -// Exports -//----------------------------------------------------------------------------- - -const Legacy = { - ConfigArray, - createConfigArrayFactoryContext, - CascadingConfigArrayFactory, - ConfigArrayFactory, - ConfigDependency, - ExtractedConfig, - IgnorePattern, - OverrideTester, - getUsedExtractedConfigs, - environments, - loadConfigFile, - - // shared - ConfigOps, - ConfigValidator, - ModuleResolver, - naming -}; - -export { - - Legacy, - - FlatCompat - -}; diff --git a/tools/eslint/node_modules/@eslint/eslintrc/lib/shared/ajv.js b/tools/eslint/node_modules/@eslint/eslintrc/lib/shared/ajv.js deleted file mode 100644 index b79ad36c3c3501..00000000000000 --- a/tools/eslint/node_modules/@eslint/eslintrc/lib/shared/ajv.js +++ /dev/null @@ -1,191 +0,0 @@ -/** - * @fileoverview The instance of Ajv validator. - * @author Evgeny Poberezkin - */ - -//------------------------------------------------------------------------------ -// Requirements -//------------------------------------------------------------------------------ - -import Ajv from "ajv"; - -//----------------------------------------------------------------------------- -// Helpers -//----------------------------------------------------------------------------- - -/* - * Copied from ajv/lib/refs/json-schema-draft-04.json - * The MIT License (MIT) - * Copyright (c) 2015-2017 Evgeny Poberezkin - */ -const metaSchema = { - id: "http://json-schema.org/draft-04/schema#", - $schema: "http://json-schema.org/draft-04/schema#", - description: "Core schema meta-schema", - definitions: { - schemaArray: { - type: "array", - minItems: 1, - items: { $ref: "#" } - }, - positiveInteger: { - type: "integer", - minimum: 0 - }, - positiveIntegerDefault0: { - allOf: [{ $ref: "#/definitions/positiveInteger" }, { default: 0 }] - }, - simpleTypes: { - enum: ["array", "boolean", "integer", "null", "number", "object", "string"] - }, - stringArray: { - type: "array", - items: { type: "string" }, - minItems: 1, - uniqueItems: true - } - }, - type: "object", - properties: { - id: { - type: "string" - }, - $schema: { - type: "string" - }, - title: { - type: "string" - }, - description: { - type: "string" - }, - default: { }, - multipleOf: { - type: "number", - minimum: 0, - exclusiveMinimum: true - }, - maximum: { - type: "number" - }, - exclusiveMaximum: { - type: "boolean", - default: false - }, - minimum: { - type: "number" - }, - exclusiveMinimum: { - type: "boolean", - default: false - }, - maxLength: { $ref: "#/definitions/positiveInteger" }, - minLength: { $ref: "#/definitions/positiveIntegerDefault0" }, - pattern: { - type: "string", - format: "regex" - }, - additionalItems: { - anyOf: [ - { type: "boolean" }, - { $ref: "#" } - ], - default: { } - }, - items: { - anyOf: [ - { $ref: "#" }, - { $ref: "#/definitions/schemaArray" } - ], - default: { } - }, - maxItems: { $ref: "#/definitions/positiveInteger" }, - minItems: { $ref: "#/definitions/positiveIntegerDefault0" }, - uniqueItems: { - type: "boolean", - default: false - }, - maxProperties: { $ref: "#/definitions/positiveInteger" }, - minProperties: { $ref: "#/definitions/positiveIntegerDefault0" }, - required: { $ref: "#/definitions/stringArray" }, - additionalProperties: { - anyOf: [ - { type: "boolean" }, - { $ref: "#" } - ], - default: { } - }, - definitions: { - type: "object", - additionalProperties: { $ref: "#" }, - default: { } - }, - properties: { - type: "object", - additionalProperties: { $ref: "#" }, - default: { } - }, - patternProperties: { - type: "object", - additionalProperties: { $ref: "#" }, - default: { } - }, - dependencies: { - type: "object", - additionalProperties: { - anyOf: [ - { $ref: "#" }, - { $ref: "#/definitions/stringArray" } - ] - } - }, - enum: { - type: "array", - minItems: 1, - uniqueItems: true - }, - type: { - anyOf: [ - { $ref: "#/definitions/simpleTypes" }, - { - type: "array", - items: { $ref: "#/definitions/simpleTypes" }, - minItems: 1, - uniqueItems: true - } - ] - }, - format: { type: "string" }, - allOf: { $ref: "#/definitions/schemaArray" }, - anyOf: { $ref: "#/definitions/schemaArray" }, - oneOf: { $ref: "#/definitions/schemaArray" }, - not: { $ref: "#" } - }, - dependencies: { - exclusiveMaximum: ["maximum"], - exclusiveMinimum: ["minimum"] - }, - default: { } -}; - -//------------------------------------------------------------------------------ -// Public Interface -//------------------------------------------------------------------------------ - -export default (additionalOptions = {}) => { - const ajv = new Ajv({ - meta: false, - useDefaults: true, - validateSchema: false, - missingRefs: "ignore", - verbose: true, - schemaId: "auto", - ...additionalOptions - }); - - ajv.addMetaSchema(metaSchema); - // eslint-disable-next-line no-underscore-dangle - ajv._opts.defaultMeta = metaSchema.id; - - return ajv; -}; diff --git a/tools/eslint/node_modules/@eslint/eslintrc/lib/shared/config-ops.js b/tools/eslint/node_modules/@eslint/eslintrc/lib/shared/config-ops.js deleted file mode 100644 index d203be0e0ef29d..00000000000000 --- a/tools/eslint/node_modules/@eslint/eslintrc/lib/shared/config-ops.js +++ /dev/null @@ -1,135 +0,0 @@ -/** - * @fileoverview Config file operations. This file must be usable in the browser, - * so no Node-specific code can be here. - * @author Nicholas C. Zakas - */ - -//------------------------------------------------------------------------------ -// Private -//------------------------------------------------------------------------------ - -const RULE_SEVERITY_STRINGS = ["off", "warn", "error"], - RULE_SEVERITY = RULE_SEVERITY_STRINGS.reduce((map, value, index) => { - map[value] = index; - return map; - }, {}), - VALID_SEVERITIES = [0, 1, 2, "off", "warn", "error"]; - -//------------------------------------------------------------------------------ -// Public Interface -//------------------------------------------------------------------------------ - -/** - * Normalizes the severity value of a rule's configuration to a number - * @param {(number|string|[number, ...*]|[string, ...*])} ruleConfig A rule's configuration value, generally - * received from the user. A valid config value is either 0, 1, 2, the string "off" (treated the same as 0), - * the string "warn" (treated the same as 1), the string "error" (treated the same as 2), or an array - * whose first element is one of the above values. Strings are matched case-insensitively. - * @returns {(0|1|2)} The numeric severity value if the config value was valid, otherwise 0. - */ -function getRuleSeverity(ruleConfig) { - const severityValue = Array.isArray(ruleConfig) ? ruleConfig[0] : ruleConfig; - - if (severityValue === 0 || severityValue === 1 || severityValue === 2) { - return severityValue; - } - - if (typeof severityValue === "string") { - return RULE_SEVERITY[severityValue.toLowerCase()] || 0; - } - - return 0; -} - -/** - * Converts old-style severity settings (0, 1, 2) into new-style - * severity settings (off, warn, error) for all rules. Assumption is that severity - * values have already been validated as correct. - * @param {Object} config The config object to normalize. - * @returns {void} - */ -function normalizeToStrings(config) { - - if (config.rules) { - Object.keys(config.rules).forEach(ruleId => { - const ruleConfig = config.rules[ruleId]; - - if (typeof ruleConfig === "number") { - config.rules[ruleId] = RULE_SEVERITY_STRINGS[ruleConfig] || RULE_SEVERITY_STRINGS[0]; - } else if (Array.isArray(ruleConfig) && typeof ruleConfig[0] === "number") { - ruleConfig[0] = RULE_SEVERITY_STRINGS[ruleConfig[0]] || RULE_SEVERITY_STRINGS[0]; - } - }); - } -} - -/** - * Determines if the severity for the given rule configuration represents an error. - * @param {int|string|Array} ruleConfig The configuration for an individual rule. - * @returns {boolean} True if the rule represents an error, false if not. - */ -function isErrorSeverity(ruleConfig) { - return getRuleSeverity(ruleConfig) === 2; -} - -/** - * Checks whether a given config has valid severity or not. - * @param {number|string|Array} ruleConfig The configuration for an individual rule. - * @returns {boolean} `true` if the configuration has valid severity. - */ -function isValidSeverity(ruleConfig) { - let severity = Array.isArray(ruleConfig) ? ruleConfig[0] : ruleConfig; - - if (typeof severity === "string") { - severity = severity.toLowerCase(); - } - return VALID_SEVERITIES.indexOf(severity) !== -1; -} - -/** - * Checks whether every rule of a given config has valid severity or not. - * @param {Object} config The configuration for rules. - * @returns {boolean} `true` if the configuration has valid severity. - */ -function isEverySeverityValid(config) { - return Object.keys(config).every(ruleId => isValidSeverity(config[ruleId])); -} - -/** - * Normalizes a value for a global in a config - * @param {(boolean|string|null)} configuredValue The value given for a global in configuration or in - * a global directive comment - * @returns {("readable"|"writeable"|"off")} The value normalized as a string - * @throws Error if global value is invalid - */ -function normalizeConfigGlobal(configuredValue) { - switch (configuredValue) { - case "off": - return "off"; - - case true: - case "true": - case "writeable": - case "writable": - return "writable"; - - case null: - case false: - case "false": - case "readable": - case "readonly": - return "readonly"; - - default: - throw new Error(`'${configuredValue}' is not a valid configuration for a global (use 'readonly', 'writable', or 'off')`); - } -} - -export { - getRuleSeverity, - normalizeToStrings, - isErrorSeverity, - isValidSeverity, - isEverySeverityValid, - normalizeConfigGlobal -}; diff --git a/tools/eslint/node_modules/@eslint/eslintrc/lib/shared/config-validator.js b/tools/eslint/node_modules/@eslint/eslintrc/lib/shared/config-validator.js deleted file mode 100644 index 531ccbf7a9a0cf..00000000000000 --- a/tools/eslint/node_modules/@eslint/eslintrc/lib/shared/config-validator.js +++ /dev/null @@ -1,370 +0,0 @@ -/** - * @fileoverview Validates configs. - * @author Brandon Mills - */ - -/* eslint class-methods-use-this: "off" */ - -//------------------------------------------------------------------------------ -// Typedefs -//------------------------------------------------------------------------------ - -/** @typedef {import("../shared/types").Rule} Rule */ - -//------------------------------------------------------------------------------ -// Requirements -//------------------------------------------------------------------------------ - -import util from "util"; -import * as ConfigOps from "./config-ops.js"; -import { emitDeprecationWarning } from "./deprecation-warnings.js"; -import ajvOrig from "./ajv.js"; -import configSchema from "../../conf/config-schema.js"; -import BuiltInEnvironments from "../../conf/environments.js"; - -const ajv = ajvOrig(); - -const ruleValidators = new WeakMap(); -const noop = Function.prototype; - -//------------------------------------------------------------------------------ -// Private -//------------------------------------------------------------------------------ -let validateSchema; -const severityMap = { - error: 2, - warn: 1, - off: 0 -}; - -const validated = new WeakSet(); - -// JSON schema that disallows passing any options -const noOptionsSchema = Object.freeze({ - type: "array", - minItems: 0, - maxItems: 0 -}); - -//----------------------------------------------------------------------------- -// Exports -//----------------------------------------------------------------------------- - -export default class ConfigValidator { - constructor({ builtInRules = new Map() } = {}) { - this.builtInRules = builtInRules; - } - - /** - * Gets a complete options schema for a rule. - * @param {Rule} rule A rule object - * @throws {TypeError} If `meta.schema` is specified but is not an array, object or `false`. - * @returns {Object|null} JSON Schema for the rule's options. - * `null` if rule wasn't passed or its `meta.schema` is `false`. - */ - getRuleOptionsSchema(rule) { - if (!rule) { - return null; - } - - if (!rule.meta) { - return { ...noOptionsSchema }; // default if `meta.schema` is not specified - } - - const schema = rule.meta.schema; - - if (typeof schema === "undefined") { - return { ...noOptionsSchema }; // default if `meta.schema` is not specified - } - - // `schema:false` is an allowed explicit opt-out of options validation for the rule - if (schema === false) { - return null; - } - - if (typeof schema !== "object" || schema === null) { - throw new TypeError("Rule's `meta.schema` must be an array or object"); - } - - // ESLint-specific array form needs to be converted into a valid JSON Schema definition - if (Array.isArray(schema)) { - if (schema.length) { - return { - type: "array", - items: schema, - minItems: 0, - maxItems: schema.length - }; - } - - // `schema:[]` is an explicit way to specify that the rule does not accept any options - return { ...noOptionsSchema }; - } - - // `schema:` is assumed to be a valid JSON Schema definition - return schema; - } - - /** - * Validates a rule's severity and returns the severity value. Throws an error if the severity is invalid. - * @param {options} options The given options for the rule. - * @returns {number|string} The rule's severity value - */ - validateRuleSeverity(options) { - const severity = Array.isArray(options) ? options[0] : options; - const normSeverity = typeof severity === "string" ? severityMap[severity.toLowerCase()] : severity; - - if (normSeverity === 0 || normSeverity === 1 || normSeverity === 2) { - return normSeverity; - } - - throw new Error(`\tSeverity should be one of the following: 0 = off, 1 = warn, 2 = error (you passed '${util.inspect(severity).replace(/'/gu, "\"").replace(/\n/gu, "")}').\n`); - - } - - /** - * Validates the non-severity options passed to a rule, based on its schema. - * @param {{create: Function}} rule The rule to validate - * @param {Array} localOptions The options for the rule, excluding severity - * @returns {void} - */ - validateRuleSchema(rule, localOptions) { - if (!ruleValidators.has(rule)) { - try { - const schema = this.getRuleOptionsSchema(rule); - - if (schema) { - ruleValidators.set(rule, ajv.compile(schema)); - } - } catch (err) { - const errorWithCode = new Error(err.message, { cause: err }); - - errorWithCode.code = "ESLINT_INVALID_RULE_OPTIONS_SCHEMA"; - - throw errorWithCode; - } - } - - const validateRule = ruleValidators.get(rule); - - if (validateRule) { - validateRule(localOptions); - if (validateRule.errors) { - throw new Error(validateRule.errors.map( - error => `\tValue ${JSON.stringify(error.data)} ${error.message}.\n` - ).join("")); - } - } - } - - /** - * Validates a rule's options against its schema. - * @param {{create: Function}|null} rule The rule that the config is being validated for - * @param {string} ruleId The rule's unique name. - * @param {Array|number} options The given options for the rule. - * @param {string|null} source The name of the configuration source to report in any errors. If null or undefined, - * no source is prepended to the message. - * @returns {void} - */ - validateRuleOptions(rule, ruleId, options, source = null) { - try { - const severity = this.validateRuleSeverity(options); - - if (severity !== 0) { - this.validateRuleSchema(rule, Array.isArray(options) ? options.slice(1) : []); - } - } catch (err) { - let enhancedMessage = err.code === "ESLINT_INVALID_RULE_OPTIONS_SCHEMA" - ? `Error while processing options validation schema of rule '${ruleId}': ${err.message}` - : `Configuration for rule "${ruleId}" is invalid:\n${err.message}`; - - if (typeof source === "string") { - enhancedMessage = `${source}:\n\t${enhancedMessage}`; - } - - const enhancedError = new Error(enhancedMessage, { cause: err }); - - if (err.code) { - enhancedError.code = err.code; - } - - throw enhancedError; - } - } - - /** - * Validates an environment object - * @param {Object} environment The environment config object to validate. - * @param {string} source The name of the configuration source to report in any errors. - * @param {function(envId:string): Object} [getAdditionalEnv] A map from strings to loaded environments. - * @returns {void} - */ - validateEnvironment( - environment, - source, - getAdditionalEnv = noop - ) { - - // not having an environment is ok - if (!environment) { - return; - } - - Object.keys(environment).forEach(id => { - const env = getAdditionalEnv(id) || BuiltInEnvironments.get(id) || null; - - if (!env) { - const message = `${source}:\n\tEnvironment key "${id}" is unknown\n`; - - throw new Error(message); - } - }); - } - - /** - * Validates a rules config object - * @param {Object} rulesConfig The rules config object to validate. - * @param {string} source The name of the configuration source to report in any errors. - * @param {function(ruleId:string): Object} getAdditionalRule A map from strings to loaded rules - * @returns {void} - */ - validateRules( - rulesConfig, - source, - getAdditionalRule = noop - ) { - if (!rulesConfig) { - return; - } - - Object.keys(rulesConfig).forEach(id => { - const rule = getAdditionalRule(id) || this.builtInRules.get(id) || null; - - this.validateRuleOptions(rule, id, rulesConfig[id], source); - }); - } - - /** - * Validates a `globals` section of a config file - * @param {Object} globalsConfig The `globals` section - * @param {string|null} source The name of the configuration source to report in the event of an error. - * @returns {void} - */ - validateGlobals(globalsConfig, source = null) { - if (!globalsConfig) { - return; - } - - Object.entries(globalsConfig) - .forEach(([configuredGlobal, configuredValue]) => { - try { - ConfigOps.normalizeConfigGlobal(configuredValue); - } catch (err) { - throw new Error(`ESLint configuration of global '${configuredGlobal}' in ${source} is invalid:\n${err.message}`); - } - }); - } - - /** - * Validate `processor` configuration. - * @param {string|undefined} processorName The processor name. - * @param {string} source The name of config file. - * @param {function(id:string): Processor} getProcessor The getter of defined processors. - * @returns {void} - */ - validateProcessor(processorName, source, getProcessor) { - if (processorName && !getProcessor(processorName)) { - throw new Error(`ESLint configuration of processor in '${source}' is invalid: '${processorName}' was not found.`); - } - } - - /** - * Formats an array of schema validation errors. - * @param {Array} errors An array of error messages to format. - * @returns {string} Formatted error message - */ - formatErrors(errors) { - return errors.map(error => { - if (error.keyword === "additionalProperties") { - const formattedPropertyPath = error.dataPath.length ? `${error.dataPath.slice(1)}.${error.params.additionalProperty}` : error.params.additionalProperty; - - return `Unexpected top-level property "${formattedPropertyPath}"`; - } - if (error.keyword === "type") { - const formattedField = error.dataPath.slice(1); - const formattedExpectedType = Array.isArray(error.schema) ? error.schema.join("/") : error.schema; - const formattedValue = JSON.stringify(error.data); - - return `Property "${formattedField}" is the wrong type (expected ${formattedExpectedType} but got \`${formattedValue}\`)`; - } - - const field = error.dataPath[0] === "." ? error.dataPath.slice(1) : error.dataPath; - - return `"${field}" ${error.message}. Value: ${JSON.stringify(error.data)}`; - }).map(message => `\t- ${message}.\n`).join(""); - } - - /** - * Validates the top level properties of the config object. - * @param {Object} config The config object to validate. - * @param {string} source The name of the configuration source to report in any errors. - * @returns {void} - */ - validateConfigSchema(config, source = null) { - validateSchema = validateSchema || ajv.compile(configSchema); - - if (!validateSchema(config)) { - throw new Error(`ESLint configuration in ${source} is invalid:\n${this.formatErrors(validateSchema.errors)}`); - } - - if (Object.hasOwnProperty.call(config, "ecmaFeatures")) { - emitDeprecationWarning(source, "ESLINT_LEGACY_ECMAFEATURES"); - } - } - - /** - * Validates an entire config object. - * @param {Object} config The config object to validate. - * @param {string} source The name of the configuration source to report in any errors. - * @param {function(ruleId:string): Object} [getAdditionalRule] A map from strings to loaded rules. - * @param {function(envId:string): Object} [getAdditionalEnv] A map from strings to loaded envs. - * @returns {void} - */ - validate(config, source, getAdditionalRule, getAdditionalEnv) { - this.validateConfigSchema(config, source); - this.validateRules(config.rules, source, getAdditionalRule); - this.validateEnvironment(config.env, source, getAdditionalEnv); - this.validateGlobals(config.globals, source); - - for (const override of config.overrides || []) { - this.validateRules(override.rules, source, getAdditionalRule); - this.validateEnvironment(override.env, source, getAdditionalEnv); - this.validateGlobals(config.globals, source); - } - } - - /** - * Validate config array object. - * @param {ConfigArray} configArray The config array to validate. - * @returns {void} - */ - validateConfigArray(configArray) { - const getPluginEnv = Map.prototype.get.bind(configArray.pluginEnvironments); - const getPluginProcessor = Map.prototype.get.bind(configArray.pluginProcessors); - const getPluginRule = Map.prototype.get.bind(configArray.pluginRules); - - // Validate. - for (const element of configArray) { - if (validated.has(element)) { - continue; - } - validated.add(element); - - this.validateEnvironment(element.env, element.name, getPluginEnv); - this.validateGlobals(element.globals, element.name); - this.validateProcessor(element.processor, element.name, getPluginProcessor); - this.validateRules(element.rules, element.name, getPluginRule); - } - } - -} diff --git a/tools/eslint/node_modules/@eslint/eslintrc/lib/shared/deprecation-warnings.js b/tools/eslint/node_modules/@eslint/eslintrc/lib/shared/deprecation-warnings.js deleted file mode 100644 index 91907b1370fbce..00000000000000 --- a/tools/eslint/node_modules/@eslint/eslintrc/lib/shared/deprecation-warnings.js +++ /dev/null @@ -1,63 +0,0 @@ -/** - * @fileoverview Provide the function that emits deprecation warnings. - * @author Toru Nagashima - */ - -//------------------------------------------------------------------------------ -// Requirements -//------------------------------------------------------------------------------ - -import path from "path"; - -//------------------------------------------------------------------------------ -// Private -//------------------------------------------------------------------------------ - -// Defitions for deprecation warnings. -const deprecationWarningMessages = { - ESLINT_LEGACY_ECMAFEATURES: - "The 'ecmaFeatures' config file property is deprecated and has no effect.", - ESLINT_PERSONAL_CONFIG_LOAD: - "'~/.eslintrc.*' config files have been deprecated. " + - "Please use a config file per project or the '--config' option.", - ESLINT_PERSONAL_CONFIG_SUPPRESS: - "'~/.eslintrc.*' config files have been deprecated. " + - "Please remove it or add 'root:true' to the config files in your " + - "projects in order to avoid loading '~/.eslintrc.*' accidentally." -}; - -const sourceFileErrorCache = new Set(); - -/** - * Emits a deprecation warning containing a given filepath. A new deprecation warning is emitted - * for each unique file path, but repeated invocations with the same file path have no effect. - * No warnings are emitted if the `--no-deprecation` or `--no-warnings` Node runtime flags are active. - * @param {string} source The name of the configuration source to report the warning for. - * @param {string} errorCode The warning message to show. - * @returns {void} - */ -function emitDeprecationWarning(source, errorCode) { - const cacheKey = JSON.stringify({ source, errorCode }); - - if (sourceFileErrorCache.has(cacheKey)) { - return; - } - sourceFileErrorCache.add(cacheKey); - - const rel = path.relative(process.cwd(), source); - const message = deprecationWarningMessages[errorCode]; - - process.emitWarning( - `${message} (found in "${rel}")`, - "DeprecationWarning", - errorCode - ); -} - -//------------------------------------------------------------------------------ -// Public Interface -//------------------------------------------------------------------------------ - -export { - emitDeprecationWarning -}; diff --git a/tools/eslint/node_modules/@eslint/eslintrc/lib/shared/naming.js b/tools/eslint/node_modules/@eslint/eslintrc/lib/shared/naming.js deleted file mode 100644 index 93df5fc438b2de..00000000000000 --- a/tools/eslint/node_modules/@eslint/eslintrc/lib/shared/naming.js +++ /dev/null @@ -1,96 +0,0 @@ -/** - * @fileoverview Common helpers for naming of plugins, formatters and configs - */ - -const NAMESPACE_REGEX = /^@.*\//iu; - -/** - * Brings package name to correct format based on prefix - * @param {string} name The name of the package. - * @param {string} prefix Can be either "eslint-plugin", "eslint-config" or "eslint-formatter" - * @returns {string} Normalized name of the package - * @private - */ -function normalizePackageName(name, prefix) { - let normalizedName = name; - - /** - * On Windows, name can come in with Windows slashes instead of Unix slashes. - * Normalize to Unix first to avoid errors later on. - * https://github.com/eslint/eslint/issues/5644 - */ - if (normalizedName.includes("\\")) { - normalizedName = normalizedName.replace(/\\/gu, "/"); - } - - if (normalizedName.charAt(0) === "@") { - - /** - * it's a scoped package - * package name is the prefix, or just a username - */ - const scopedPackageShortcutRegex = new RegExp(`^(@[^/]+)(?:/(?:${prefix})?)?$`, "u"), - scopedPackageNameRegex = new RegExp(`^${prefix}(-|$)`, "u"); - - if (scopedPackageShortcutRegex.test(normalizedName)) { - normalizedName = normalizedName.replace(scopedPackageShortcutRegex, `$1/${prefix}`); - } else if (!scopedPackageNameRegex.test(normalizedName.split("/")[1])) { - - /** - * for scoped packages, insert the prefix after the first / unless - * the path is already @scope/eslint or @scope/eslint-xxx-yyy - */ - normalizedName = normalizedName.replace(/^@([^/]+)\/(.*)$/u, `@$1/${prefix}-$2`); - } - } else if (!normalizedName.startsWith(`${prefix}-`)) { - normalizedName = `${prefix}-${normalizedName}`; - } - - return normalizedName; -} - -/** - * Removes the prefix from a fullname. - * @param {string} fullname The term which may have the prefix. - * @param {string} prefix The prefix to remove. - * @returns {string} The term without prefix. - */ -function getShorthandName(fullname, prefix) { - if (fullname[0] === "@") { - let matchResult = new RegExp(`^(@[^/]+)/${prefix}$`, "u").exec(fullname); - - if (matchResult) { - return matchResult[1]; - } - - matchResult = new RegExp(`^(@[^/]+)/${prefix}-(.+)$`, "u").exec(fullname); - if (matchResult) { - return `${matchResult[1]}/${matchResult[2]}`; - } - } else if (fullname.startsWith(`${prefix}-`)) { - return fullname.slice(prefix.length + 1); - } - - return fullname; -} - -/** - * Gets the scope (namespace) of a term. - * @param {string} term The term which may have the namespace. - * @returns {string} The namespace of the term if it has one. - */ -function getNamespaceFromTerm(term) { - const match = term.match(NAMESPACE_REGEX); - - return match ? match[0] : ""; -} - -//------------------------------------------------------------------------------ -// Public Interface -//------------------------------------------------------------------------------ - -export { - normalizePackageName, - getShorthandName, - getNamespaceFromTerm -}; diff --git a/tools/eslint/node_modules/@eslint/eslintrc/lib/shared/relative-module-resolver.js b/tools/eslint/node_modules/@eslint/eslintrc/lib/shared/relative-module-resolver.js deleted file mode 100644 index 1df0ca8071d25d..00000000000000 --- a/tools/eslint/node_modules/@eslint/eslintrc/lib/shared/relative-module-resolver.js +++ /dev/null @@ -1,42 +0,0 @@ -/** - * Utility for resolving a module relative to another module - * @author Teddy Katz - */ - -import Module from "module"; - -/* - * `Module.createRequire` is added in v12.2.0. It supports URL as well. - * We only support the case where the argument is a filepath, not a URL. - */ -const createRequire = Module.createRequire; - -/** - * Resolves a Node module relative to another module - * @param {string} moduleName The name of a Node module, or a path to a Node module. - * @param {string} relativeToPath An absolute path indicating the module that `moduleName` should be resolved relative to. This must be - * a file rather than a directory, but the file need not actually exist. - * @returns {string} The absolute path that would result from calling `require.resolve(moduleName)` in a file located at `relativeToPath` - */ -function resolve(moduleName, relativeToPath) { - try { - return createRequire(relativeToPath).resolve(moduleName); - } catch (error) { - - // This `if` block is for older Node.js than 12.0.0. We can remove this block in the future. - if ( - typeof error === "object" && - error !== null && - error.code === "MODULE_NOT_FOUND" && - !error.requireStack && - error.message.includes(moduleName) - ) { - error.message += `\nRequire stack:\n- ${relativeToPath}`; - } - throw error; - } -} - -export { - resolve -}; diff --git a/tools/eslint/node_modules/@eslint/eslintrc/lib/shared/types.js b/tools/eslint/node_modules/@eslint/eslintrc/lib/shared/types.js deleted file mode 100644 index a32c35e39130bb..00000000000000 --- a/tools/eslint/node_modules/@eslint/eslintrc/lib/shared/types.js +++ /dev/null @@ -1,149 +0,0 @@ -/** - * @fileoverview Define common types for input completion. - * @author Toru Nagashima - */ - -/** @type {any} */ -export default {}; - -/** @typedef {boolean | "off" | "readable" | "readonly" | "writable" | "writeable"} GlobalConf */ -/** @typedef {0 | 1 | 2 | "off" | "warn" | "error"} SeverityConf */ -/** @typedef {SeverityConf | [SeverityConf, ...any[]]} RuleConf */ - -/** - * @typedef {Object} EcmaFeatures - * @property {boolean} [globalReturn] Enabling `return` statements at the top-level. - * @property {boolean} [jsx] Enabling JSX syntax. - * @property {boolean} [impliedStrict] Enabling strict mode always. - */ - -/** - * @typedef {Object} ParserOptions - * @property {EcmaFeatures} [ecmaFeatures] The optional features. - * @property {3|5|6|7|8|9|10|11|12|2015|2016|2017|2018|2019|2020|2021} [ecmaVersion] The ECMAScript version (or revision number). - * @property {"script"|"module"} [sourceType] The source code type. - */ - -/** - * @typedef {Object} ConfigData - * @property {Record} [env] The environment settings. - * @property {string | string[]} [extends] The path to other config files or the package name of shareable configs. - * @property {Record} [globals] The global variable settings. - * @property {string | string[]} [ignorePatterns] The glob patterns that ignore to lint. - * @property {boolean} [noInlineConfig] The flag that disables directive comments. - * @property {OverrideConfigData[]} [overrides] The override settings per kind of files. - * @property {string} [parser] The path to a parser or the package name of a parser. - * @property {ParserOptions} [parserOptions] The parser options. - * @property {string[]} [plugins] The plugin specifiers. - * @property {string} [processor] The processor specifier. - * @property {boolean} [reportUnusedDisableDirectives] The flag to report unused `eslint-disable` comments. - * @property {boolean} [root] The root flag. - * @property {Record} [rules] The rule settings. - * @property {Object} [settings] The shared settings. - */ - -/** - * @typedef {Object} OverrideConfigData - * @property {Record} [env] The environment settings. - * @property {string | string[]} [excludedFiles] The glob pattarns for excluded files. - * @property {string | string[]} [extends] The path to other config files or the package name of shareable configs. - * @property {string | string[]} files The glob patterns for target files. - * @property {Record} [globals] The global variable settings. - * @property {boolean} [noInlineConfig] The flag that disables directive comments. - * @property {OverrideConfigData[]} [overrides] The override settings per kind of files. - * @property {string} [parser] The path to a parser or the package name of a parser. - * @property {ParserOptions} [parserOptions] The parser options. - * @property {string[]} [plugins] The plugin specifiers. - * @property {string} [processor] The processor specifier. - * @property {boolean} [reportUnusedDisableDirectives] The flag to report unused `eslint-disable` comments. - * @property {Record} [rules] The rule settings. - * @property {Object} [settings] The shared settings. - */ - -/** - * @typedef {Object} ParseResult - * @property {Object} ast The AST. - * @property {ScopeManager} [scopeManager] The scope manager of the AST. - * @property {Record} [services] The services that the parser provides. - * @property {Record} [visitorKeys] The visitor keys of the AST. - */ - -/** - * @typedef {Object} Parser - * @property {(text:string, options:ParserOptions) => Object} parse The definition of global variables. - * @property {(text:string, options:ParserOptions) => ParseResult} [parseForESLint] The parser options that will be enabled under this environment. - */ - -/** - * @typedef {Object} Environment - * @property {Record} [globals] The definition of global variables. - * @property {ParserOptions} [parserOptions] The parser options that will be enabled under this environment. - */ - -/** - * @typedef {Object} LintMessage - * @property {number} column The 1-based column number. - * @property {number} [endColumn] The 1-based column number of the end location. - * @property {number} [endLine] The 1-based line number of the end location. - * @property {boolean} fatal If `true` then this is a fatal error. - * @property {{range:[number,number], text:string}} [fix] Information for autofix. - * @property {number} line The 1-based line number. - * @property {string} message The error message. - * @property {string|null} ruleId The ID of the rule which makes this message. - * @property {0|1|2} severity The severity of this message. - * @property {Array<{desc?: string, messageId?: string, fix: {range: [number, number], text: string}}>} [suggestions] Information for suggestions. - */ - -/** - * @typedef {Object} SuggestionResult - * @property {string} desc A short description. - * @property {string} [messageId] Id referencing a message for the description. - * @property {{ text: string, range: number[] }} fix fix result info - */ - -/** - * @typedef {Object} Processor - * @property {(text:string, filename:string) => Array} [preprocess] The function to extract code blocks. - * @property {(messagesList:LintMessage[][], filename:string) => LintMessage[]} [postprocess] The function to merge messages. - * @property {boolean} [supportsAutofix] If `true` then it means the processor supports autofix. - */ - -/** - * @typedef {Object} RuleMetaDocs - * @property {string} category The category of the rule. - * @property {string} description The description of the rule. - * @property {boolean} recommended If `true` then the rule is included in `eslint:recommended` preset. - * @property {string} url The URL of the rule documentation. - */ - -/** - * @typedef {Object} RuleMeta - * @property {boolean} [deprecated] If `true` then the rule has been deprecated. - * @property {RuleMetaDocs} docs The document information of the rule. - * @property {"code"|"whitespace"} [fixable] The autofix type. - * @property {Record} [messages] The messages the rule reports. - * @property {string[]} [replacedBy] The IDs of the alternative rules. - * @property {Array|Object} schema The option schema of the rule. - * @property {"problem"|"suggestion"|"layout"} type The rule type. - */ - -/** - * @typedef {Object} Rule - * @property {Function} create The factory of the rule. - * @property {RuleMeta} meta The meta data of the rule. - */ - -/** - * @typedef {Object} Plugin - * @property {Record} [configs] The definition of plugin configs. - * @property {Record} [environments] The definition of plugin environments. - * @property {Record} [processors] The definition of plugin processors. - * @property {Record} [rules] The definition of plugin rules. - */ - -/** - * Information of deprecated rules. - * @typedef {Object} DeprecatedRuleInfo - * @property {string} ruleId The rule ID. - * @property {string[]} replacedBy The rule IDs that replace this deprecated rule. - */ diff --git a/tools/eslint/node_modules/@eslint/eslintrc/node_modules/globals/globals.json b/tools/eslint/node_modules/@eslint/eslintrc/node_modules/globals/globals.json deleted file mode 100644 index 4e75173f051713..00000000000000 --- a/tools/eslint/node_modules/@eslint/eslintrc/node_modules/globals/globals.json +++ /dev/null @@ -1,1998 +0,0 @@ -{ - "builtin": { - "AggregateError": false, - "Array": false, - "ArrayBuffer": false, - "Atomics": false, - "BigInt": false, - "BigInt64Array": false, - "BigUint64Array": false, - "Boolean": false, - "constructor": false, - "DataView": false, - "Date": false, - "decodeURI": false, - "decodeURIComponent": false, - "encodeURI": false, - "encodeURIComponent": false, - "Error": false, - "escape": false, - "eval": false, - "EvalError": false, - "FinalizationRegistry": false, - "Float32Array": false, - "Float64Array": false, - "Function": false, - "globalThis": false, - "hasOwnProperty": false, - "Infinity": false, - "Int16Array": false, - "Int32Array": false, - "Int8Array": false, - "isFinite": false, - "isNaN": false, - "isPrototypeOf": false, - "JSON": false, - "Map": false, - "Math": false, - "NaN": false, - "Number": false, - "Object": false, - "parseFloat": false, - "parseInt": false, - "Promise": false, - "propertyIsEnumerable": false, - "Proxy": false, - "RangeError": false, - "ReferenceError": false, - "Reflect": false, - "RegExp": false, - "Set": false, - "SharedArrayBuffer": false, - "String": false, - "Symbol": false, - "SyntaxError": false, - "toLocaleString": false, - "toString": false, - "TypeError": false, - "Uint16Array": false, - "Uint32Array": false, - "Uint8Array": false, - "Uint8ClampedArray": false, - "undefined": false, - "unescape": false, - "URIError": false, - "valueOf": false, - "WeakMap": false, - "WeakRef": false, - "WeakSet": false - }, - "es5": { - "Array": false, - "Boolean": false, - "constructor": false, - "Date": false, - "decodeURI": false, - "decodeURIComponent": false, - "encodeURI": false, - "encodeURIComponent": false, - "Error": false, - "escape": false, - "eval": false, - "EvalError": false, - "Function": false, - "hasOwnProperty": false, - "Infinity": false, - "isFinite": false, - "isNaN": false, - "isPrototypeOf": false, - "JSON": false, - "Math": false, - "NaN": false, - "Number": false, - "Object": false, - "parseFloat": false, - "parseInt": false, - "propertyIsEnumerable": false, - "RangeError": false, - "ReferenceError": false, - "RegExp": false, - "String": false, - "SyntaxError": false, - "toLocaleString": false, - "toString": false, - "TypeError": false, - "undefined": false, - "unescape": false, - "URIError": false, - "valueOf": false - }, - "es2015": { - "Array": false, - "ArrayBuffer": false, - "Boolean": false, - "constructor": false, - "DataView": false, - "Date": false, - "decodeURI": false, - "decodeURIComponent": false, - "encodeURI": false, - "encodeURIComponent": false, - "Error": false, - "escape": false, - "eval": false, - "EvalError": false, - "Float32Array": false, - "Float64Array": false, - "Function": false, - "hasOwnProperty": false, - "Infinity": false, - "Int16Array": false, - "Int32Array": false, - "Int8Array": false, - "isFinite": false, - "isNaN": false, - "isPrototypeOf": false, - "JSON": false, - "Map": false, - "Math": false, - "NaN": false, - "Number": false, - "Object": false, - "parseFloat": false, - "parseInt": false, - "Promise": false, - "propertyIsEnumerable": false, - "Proxy": false, - "RangeError": false, - "ReferenceError": false, - "Reflect": false, - "RegExp": false, - "Set": false, - "String": false, - "Symbol": false, - "SyntaxError": false, - "toLocaleString": false, - "toString": false, - "TypeError": false, - "Uint16Array": false, - "Uint32Array": false, - "Uint8Array": false, - "Uint8ClampedArray": false, - "undefined": false, - "unescape": false, - "URIError": false, - "valueOf": false, - "WeakMap": false, - "WeakSet": false - }, - "es2017": { - "Array": false, - "ArrayBuffer": false, - "Atomics": false, - "Boolean": false, - "constructor": false, - "DataView": false, - "Date": false, - "decodeURI": false, - "decodeURIComponent": false, - "encodeURI": false, - "encodeURIComponent": false, - "Error": false, - "escape": false, - "eval": false, - "EvalError": false, - "Float32Array": false, - "Float64Array": false, - "Function": false, - "hasOwnProperty": false, - "Infinity": false, - "Int16Array": false, - "Int32Array": false, - "Int8Array": false, - "isFinite": false, - "isNaN": false, - "isPrototypeOf": false, - "JSON": false, - "Map": false, - "Math": false, - "NaN": false, - "Number": false, - "Object": false, - "parseFloat": false, - "parseInt": false, - "Promise": false, - "propertyIsEnumerable": false, - "Proxy": false, - "RangeError": false, - "ReferenceError": false, - "Reflect": false, - "RegExp": false, - "Set": false, - "SharedArrayBuffer": false, - "String": false, - "Symbol": false, - "SyntaxError": false, - "toLocaleString": false, - "toString": false, - "TypeError": false, - "Uint16Array": false, - "Uint32Array": false, - "Uint8Array": false, - "Uint8ClampedArray": false, - "undefined": false, - "unescape": false, - "URIError": false, - "valueOf": false, - "WeakMap": false, - "WeakSet": false - }, - "es2020": { - "Array": false, - "ArrayBuffer": false, - "Atomics": false, - "BigInt": false, - "BigInt64Array": false, - "BigUint64Array": false, - "Boolean": false, - "constructor": false, - "DataView": false, - "Date": false, - "decodeURI": false, - "decodeURIComponent": false, - "encodeURI": false, - "encodeURIComponent": false, - "Error": false, - "escape": false, - "eval": false, - "EvalError": false, - "Float32Array": false, - "Float64Array": false, - "Function": false, - "globalThis": false, - "hasOwnProperty": false, - "Infinity": false, - "Int16Array": false, - "Int32Array": false, - "Int8Array": false, - "isFinite": false, - "isNaN": false, - "isPrototypeOf": false, - "JSON": false, - "Map": false, - "Math": false, - "NaN": false, - "Number": false, - "Object": false, - "parseFloat": false, - "parseInt": false, - "Promise": false, - "propertyIsEnumerable": false, - "Proxy": false, - "RangeError": false, - "ReferenceError": false, - "Reflect": false, - "RegExp": false, - "Set": false, - "SharedArrayBuffer": false, - "String": false, - "Symbol": false, - "SyntaxError": false, - "toLocaleString": false, - "toString": false, - "TypeError": false, - "Uint16Array": false, - "Uint32Array": false, - "Uint8Array": false, - "Uint8ClampedArray": false, - "undefined": false, - "unescape": false, - "URIError": false, - "valueOf": false, - "WeakMap": false, - "WeakSet": false - }, - "es2021": { - "AggregateError": false, - "Array": false, - "ArrayBuffer": false, - "Atomics": false, - "BigInt": false, - "BigInt64Array": false, - "BigUint64Array": false, - "Boolean": false, - "constructor": false, - "DataView": false, - "Date": false, - "decodeURI": false, - "decodeURIComponent": false, - "encodeURI": false, - "encodeURIComponent": false, - "Error": false, - "escape": false, - "eval": false, - "EvalError": false, - "FinalizationRegistry": false, - "Float32Array": false, - "Float64Array": false, - "Function": false, - "globalThis": false, - "hasOwnProperty": false, - "Infinity": false, - "Int16Array": false, - "Int32Array": false, - "Int8Array": false, - "isFinite": false, - "isNaN": false, - "isPrototypeOf": false, - "JSON": false, - "Map": false, - "Math": false, - "NaN": false, - "Number": false, - "Object": false, - "parseFloat": false, - "parseInt": false, - "Promise": false, - "propertyIsEnumerable": false, - "Proxy": false, - "RangeError": false, - "ReferenceError": false, - "Reflect": false, - "RegExp": false, - "Set": false, - "SharedArrayBuffer": false, - "String": false, - "Symbol": false, - "SyntaxError": false, - "toLocaleString": false, - "toString": false, - "TypeError": false, - "Uint16Array": false, - "Uint32Array": false, - "Uint8Array": false, - "Uint8ClampedArray": false, - "undefined": false, - "unescape": false, - "URIError": false, - "valueOf": false, - "WeakMap": false, - "WeakRef": false, - "WeakSet": false - }, - "browser": { - "AbortController": false, - "AbortSignal": false, - "addEventListener": false, - "alert": false, - "AnalyserNode": false, - "Animation": false, - "AnimationEffectReadOnly": false, - "AnimationEffectTiming": false, - "AnimationEffectTimingReadOnly": false, - "AnimationEvent": false, - "AnimationPlaybackEvent": false, - "AnimationTimeline": false, - "applicationCache": false, - "ApplicationCache": false, - "ApplicationCacheErrorEvent": false, - "atob": false, - "Attr": false, - "Audio": false, - "AudioBuffer": false, - "AudioBufferSourceNode": false, - "AudioContext": false, - "AudioDestinationNode": false, - "AudioListener": false, - "AudioNode": false, - "AudioParam": false, - "AudioProcessingEvent": false, - "AudioScheduledSourceNode": false, - "AudioWorkletGlobalScope": false, - "AudioWorkletNode": false, - "AudioWorkletProcessor": false, - "BarProp": false, - "BaseAudioContext": false, - "BatteryManager": false, - "BeforeUnloadEvent": false, - "BiquadFilterNode": false, - "Blob": false, - "BlobEvent": false, - "blur": false, - "BroadcastChannel": false, - "btoa": false, - "BudgetService": false, - "ByteLengthQueuingStrategy": false, - "Cache": false, - "caches": false, - "CacheStorage": false, - "cancelAnimationFrame": false, - "cancelIdleCallback": false, - "CanvasCaptureMediaStreamTrack": false, - "CanvasGradient": false, - "CanvasPattern": false, - "CanvasRenderingContext2D": false, - "ChannelMergerNode": false, - "ChannelSplitterNode": false, - "CharacterData": false, - "clearInterval": false, - "clearTimeout": false, - "clientInformation": false, - "ClipboardEvent": false, - "ClipboardItem": false, - "close": false, - "closed": false, - "CloseEvent": false, - "Comment": false, - "CompositionEvent": false, - "CompressionStream": false, - "confirm": false, - "console": false, - "ConstantSourceNode": false, - "ConvolverNode": false, - "CountQueuingStrategy": false, - "createImageBitmap": false, - "Credential": false, - "CredentialsContainer": false, - "crypto": false, - "Crypto": false, - "CryptoKey": false, - "CSS": false, - "CSSConditionRule": false, - "CSSFontFaceRule": false, - "CSSGroupingRule": false, - "CSSImportRule": false, - "CSSKeyframeRule": false, - "CSSKeyframesRule": false, - "CSSMatrixComponent": false, - "CSSMediaRule": false, - "CSSNamespaceRule": false, - "CSSPageRule": false, - "CSSPerspective": false, - "CSSRotate": false, - "CSSRule": false, - "CSSRuleList": false, - "CSSScale": false, - "CSSSkew": false, - "CSSSkewX": false, - "CSSSkewY": false, - "CSSStyleDeclaration": false, - "CSSStyleRule": false, - "CSSStyleSheet": false, - "CSSSupportsRule": false, - "CSSTransformValue": false, - "CSSTranslate": false, - "CustomElementRegistry": false, - "customElements": false, - "CustomEvent": false, - "DataTransfer": false, - "DataTransferItem": false, - "DataTransferItemList": false, - "DecompressionStream": false, - "defaultstatus": false, - "defaultStatus": false, - "DelayNode": false, - "DeviceMotionEvent": false, - "DeviceOrientationEvent": false, - "devicePixelRatio": false, - "dispatchEvent": false, - "document": false, - "Document": false, - "DocumentFragment": false, - "DocumentType": false, - "DOMError": false, - "DOMException": false, - "DOMImplementation": false, - "DOMMatrix": false, - "DOMMatrixReadOnly": false, - "DOMParser": false, - "DOMPoint": false, - "DOMPointReadOnly": false, - "DOMQuad": false, - "DOMRect": false, - "DOMRectList": false, - "DOMRectReadOnly": false, - "DOMStringList": false, - "DOMStringMap": false, - "DOMTokenList": false, - "DragEvent": false, - "DynamicsCompressorNode": false, - "Element": false, - "ErrorEvent": false, - "event": false, - "Event": false, - "EventSource": false, - "EventTarget": false, - "external": false, - "fetch": false, - "File": false, - "FileList": false, - "FileReader": false, - "find": false, - "focus": false, - "FocusEvent": false, - "FontFace": false, - "FontFaceSetLoadEvent": false, - "FormData": false, - "FormDataEvent": false, - "frameElement": false, - "frames": false, - "GainNode": false, - "Gamepad": false, - "GamepadButton": false, - "GamepadEvent": false, - "getComputedStyle": false, - "getSelection": false, - "HashChangeEvent": false, - "Headers": false, - "history": false, - "History": false, - "HTMLAllCollection": false, - "HTMLAnchorElement": false, - "HTMLAreaElement": false, - "HTMLAudioElement": false, - "HTMLBaseElement": false, - "HTMLBodyElement": false, - "HTMLBRElement": false, - "HTMLButtonElement": false, - "HTMLCanvasElement": false, - "HTMLCollection": false, - "HTMLContentElement": false, - "HTMLDataElement": false, - "HTMLDataListElement": false, - "HTMLDetailsElement": false, - "HTMLDialogElement": false, - "HTMLDirectoryElement": false, - "HTMLDivElement": false, - "HTMLDListElement": false, - "HTMLDocument": false, - "HTMLElement": false, - "HTMLEmbedElement": false, - "HTMLFieldSetElement": false, - "HTMLFontElement": false, - "HTMLFormControlsCollection": false, - "HTMLFormElement": false, - "HTMLFrameElement": false, - "HTMLFrameSetElement": false, - "HTMLHeadElement": false, - "HTMLHeadingElement": false, - "HTMLHRElement": false, - "HTMLHtmlElement": false, - "HTMLIFrameElement": false, - "HTMLImageElement": false, - "HTMLInputElement": false, - "HTMLLabelElement": false, - "HTMLLegendElement": false, - "HTMLLIElement": false, - "HTMLLinkElement": false, - "HTMLMapElement": false, - "HTMLMarqueeElement": false, - "HTMLMediaElement": false, - "HTMLMenuElement": false, - "HTMLMetaElement": false, - "HTMLMeterElement": false, - "HTMLModElement": false, - "HTMLObjectElement": false, - "HTMLOListElement": false, - "HTMLOptGroupElement": false, - "HTMLOptionElement": false, - "HTMLOptionsCollection": false, - "HTMLOutputElement": false, - "HTMLParagraphElement": false, - "HTMLParamElement": false, - "HTMLPictureElement": false, - "HTMLPreElement": false, - "HTMLProgressElement": false, - "HTMLQuoteElement": false, - "HTMLScriptElement": false, - "HTMLSelectElement": false, - "HTMLShadowElement": false, - "HTMLSlotElement": false, - "HTMLSourceElement": false, - "HTMLSpanElement": false, - "HTMLStyleElement": false, - "HTMLTableCaptionElement": false, - "HTMLTableCellElement": false, - "HTMLTableColElement": false, - "HTMLTableElement": false, - "HTMLTableRowElement": false, - "HTMLTableSectionElement": false, - "HTMLTemplateElement": false, - "HTMLTextAreaElement": false, - "HTMLTimeElement": false, - "HTMLTitleElement": false, - "HTMLTrackElement": false, - "HTMLUListElement": false, - "HTMLUnknownElement": false, - "HTMLVideoElement": false, - "IDBCursor": false, - "IDBCursorWithValue": false, - "IDBDatabase": false, - "IDBFactory": false, - "IDBIndex": false, - "IDBKeyRange": false, - "IDBObjectStore": false, - "IDBOpenDBRequest": false, - "IDBRequest": false, - "IDBTransaction": false, - "IDBVersionChangeEvent": false, - "IdleDeadline": false, - "IIRFilterNode": false, - "Image": false, - "ImageBitmap": false, - "ImageBitmapRenderingContext": false, - "ImageCapture": false, - "ImageData": false, - "indexedDB": false, - "innerHeight": false, - "innerWidth": false, - "InputEvent": false, - "IntersectionObserver": false, - "IntersectionObserverEntry": false, - "Intl": false, - "isSecureContext": false, - "KeyboardEvent": false, - "KeyframeEffect": false, - "KeyframeEffectReadOnly": false, - "length": false, - "localStorage": false, - "location": true, - "Location": false, - "locationbar": false, - "matchMedia": false, - "MediaDeviceInfo": false, - "MediaDevices": false, - "MediaElementAudioSourceNode": false, - "MediaEncryptedEvent": false, - "MediaError": false, - "MediaKeyMessageEvent": false, - "MediaKeySession": false, - "MediaKeyStatusMap": false, - "MediaKeySystemAccess": false, - "MediaList": false, - "MediaMetadata": false, - "MediaQueryList": false, - "MediaQueryListEvent": false, - "MediaRecorder": false, - "MediaSettingsRange": false, - "MediaSource": false, - "MediaStream": false, - "MediaStreamAudioDestinationNode": false, - "MediaStreamAudioSourceNode": false, - "MediaStreamConstraints": false, - "MediaStreamEvent": false, - "MediaStreamTrack": false, - "MediaStreamTrackEvent": false, - "menubar": false, - "MessageChannel": false, - "MessageEvent": false, - "MessagePort": false, - "MIDIAccess": false, - "MIDIConnectionEvent": false, - "MIDIInput": false, - "MIDIInputMap": false, - "MIDIMessageEvent": false, - "MIDIOutput": false, - "MIDIOutputMap": false, - "MIDIPort": false, - "MimeType": false, - "MimeTypeArray": false, - "MouseEvent": false, - "moveBy": false, - "moveTo": false, - "MutationEvent": false, - "MutationObserver": false, - "MutationRecord": false, - "name": false, - "NamedNodeMap": false, - "NavigationPreloadManager": false, - "navigator": false, - "Navigator": false, - "NavigatorUAData": false, - "NetworkInformation": false, - "Node": false, - "NodeFilter": false, - "NodeIterator": false, - "NodeList": false, - "Notification": false, - "OfflineAudioCompletionEvent": false, - "OfflineAudioContext": false, - "offscreenBuffering": false, - "OffscreenCanvas": true, - "OffscreenCanvasRenderingContext2D": false, - "onabort": true, - "onafterprint": true, - "onanimationend": true, - "onanimationiteration": true, - "onanimationstart": true, - "onappinstalled": true, - "onauxclick": true, - "onbeforeinstallprompt": true, - "onbeforeprint": true, - "onbeforeunload": true, - "onblur": true, - "oncancel": true, - "oncanplay": true, - "oncanplaythrough": true, - "onchange": true, - "onclick": true, - "onclose": true, - "oncontextmenu": true, - "oncuechange": true, - "ondblclick": true, - "ondevicemotion": true, - "ondeviceorientation": true, - "ondeviceorientationabsolute": true, - "ondrag": true, - "ondragend": true, - "ondragenter": true, - "ondragleave": true, - "ondragover": true, - "ondragstart": true, - "ondrop": true, - "ondurationchange": true, - "onemptied": true, - "onended": true, - "onerror": true, - "onfocus": true, - "ongotpointercapture": true, - "onhashchange": true, - "oninput": true, - "oninvalid": true, - "onkeydown": true, - "onkeypress": true, - "onkeyup": true, - "onlanguagechange": true, - "onload": true, - "onloadeddata": true, - "onloadedmetadata": true, - "onloadstart": true, - "onlostpointercapture": true, - "onmessage": true, - "onmessageerror": true, - "onmousedown": true, - "onmouseenter": true, - "onmouseleave": true, - "onmousemove": true, - "onmouseout": true, - "onmouseover": true, - "onmouseup": true, - "onmousewheel": true, - "onoffline": true, - "ononline": true, - "onpagehide": true, - "onpageshow": true, - "onpause": true, - "onplay": true, - "onplaying": true, - "onpointercancel": true, - "onpointerdown": true, - "onpointerenter": true, - "onpointerleave": true, - "onpointermove": true, - "onpointerout": true, - "onpointerover": true, - "onpointerup": true, - "onpopstate": true, - "onprogress": true, - "onratechange": true, - "onrejectionhandled": true, - "onreset": true, - "onresize": true, - "onscroll": true, - "onsearch": true, - "onseeked": true, - "onseeking": true, - "onselect": true, - "onstalled": true, - "onstorage": true, - "onsubmit": true, - "onsuspend": true, - "ontimeupdate": true, - "ontoggle": true, - "ontransitionend": true, - "onunhandledrejection": true, - "onunload": true, - "onvolumechange": true, - "onwaiting": true, - "onwheel": true, - "open": false, - "openDatabase": false, - "opener": false, - "Option": false, - "origin": false, - "OscillatorNode": false, - "outerHeight": false, - "outerWidth": false, - "OverconstrainedError": false, - "PageTransitionEvent": false, - "pageXOffset": false, - "pageYOffset": false, - "PannerNode": false, - "parent": false, - "Path2D": false, - "PaymentAddress": false, - "PaymentRequest": false, - "PaymentRequestUpdateEvent": false, - "PaymentResponse": false, - "performance": false, - "Performance": false, - "PerformanceEntry": false, - "PerformanceLongTaskTiming": false, - "PerformanceMark": false, - "PerformanceMeasure": false, - "PerformanceNavigation": false, - "PerformanceNavigationTiming": false, - "PerformanceObserver": false, - "PerformanceObserverEntryList": false, - "PerformancePaintTiming": false, - "PerformanceResourceTiming": false, - "PerformanceTiming": false, - "PeriodicWave": false, - "Permissions": false, - "PermissionStatus": false, - "personalbar": false, - "PhotoCapabilities": false, - "Plugin": false, - "PluginArray": false, - "PointerEvent": false, - "PopStateEvent": false, - "postMessage": false, - "Presentation": false, - "PresentationAvailability": false, - "PresentationConnection": false, - "PresentationConnectionAvailableEvent": false, - "PresentationConnectionCloseEvent": false, - "PresentationConnectionList": false, - "PresentationReceiver": false, - "PresentationRequest": false, - "print": false, - "ProcessingInstruction": false, - "ProgressEvent": false, - "PromiseRejectionEvent": false, - "prompt": false, - "PushManager": false, - "PushSubscription": false, - "PushSubscriptionOptions": false, - "queueMicrotask": false, - "RadioNodeList": false, - "Range": false, - "ReadableByteStreamController": false, - "ReadableStream": false, - "ReadableStreamBYOBReader": false, - "ReadableStreamBYOBRequest": false, - "ReadableStreamDefaultController": false, - "ReadableStreamDefaultReader": false, - "registerProcessor": false, - "RemotePlayback": false, - "removeEventListener": false, - "reportError": false, - "Request": false, - "requestAnimationFrame": false, - "requestIdleCallback": false, - "resizeBy": false, - "ResizeObserver": false, - "ResizeObserverEntry": false, - "resizeTo": false, - "Response": false, - "RTCCertificate": false, - "RTCDataChannel": false, - "RTCDataChannelEvent": false, - "RTCDtlsTransport": false, - "RTCIceCandidate": false, - "RTCIceGatherer": false, - "RTCIceTransport": false, - "RTCPeerConnection": false, - "RTCPeerConnectionIceEvent": false, - "RTCRtpContributingSource": false, - "RTCRtpReceiver": false, - "RTCRtpSender": false, - "RTCSctpTransport": false, - "RTCSessionDescription": false, - "RTCStatsReport": false, - "RTCTrackEvent": false, - "screen": false, - "Screen": false, - "screenLeft": false, - "ScreenOrientation": false, - "screenTop": false, - "screenX": false, - "screenY": false, - "ScriptProcessorNode": false, - "scroll": false, - "scrollbars": false, - "scrollBy": false, - "scrollTo": false, - "scrollX": false, - "scrollY": false, - "SecurityPolicyViolationEvent": false, - "Selection": false, - "self": false, - "ServiceWorker": false, - "ServiceWorkerContainer": false, - "ServiceWorkerRegistration": false, - "sessionStorage": false, - "setInterval": false, - "setTimeout": false, - "ShadowRoot": false, - "SharedWorker": false, - "SourceBuffer": false, - "SourceBufferList": false, - "speechSynthesis": false, - "SpeechSynthesisEvent": false, - "SpeechSynthesisUtterance": false, - "StaticRange": false, - "status": false, - "statusbar": false, - "StereoPannerNode": false, - "stop": false, - "Storage": false, - "StorageEvent": false, - "StorageManager": false, - "structuredClone": false, - "styleMedia": false, - "StyleSheet": false, - "StyleSheetList": false, - "SubmitEvent": false, - "SubtleCrypto": false, - "SVGAElement": false, - "SVGAngle": false, - "SVGAnimatedAngle": false, - "SVGAnimatedBoolean": false, - "SVGAnimatedEnumeration": false, - "SVGAnimatedInteger": false, - "SVGAnimatedLength": false, - "SVGAnimatedLengthList": false, - "SVGAnimatedNumber": false, - "SVGAnimatedNumberList": false, - "SVGAnimatedPreserveAspectRatio": false, - "SVGAnimatedRect": false, - "SVGAnimatedString": false, - "SVGAnimatedTransformList": false, - "SVGAnimateElement": false, - "SVGAnimateMotionElement": false, - "SVGAnimateTransformElement": false, - "SVGAnimationElement": false, - "SVGCircleElement": false, - "SVGClipPathElement": false, - "SVGComponentTransferFunctionElement": false, - "SVGDefsElement": false, - "SVGDescElement": false, - "SVGDiscardElement": false, - "SVGElement": false, - "SVGEllipseElement": false, - "SVGFEBlendElement": false, - "SVGFEColorMatrixElement": false, - "SVGFEComponentTransferElement": false, - "SVGFECompositeElement": false, - "SVGFEConvolveMatrixElement": false, - "SVGFEDiffuseLightingElement": false, - "SVGFEDisplacementMapElement": false, - "SVGFEDistantLightElement": false, - "SVGFEDropShadowElement": false, - "SVGFEFloodElement": false, - "SVGFEFuncAElement": false, - "SVGFEFuncBElement": false, - "SVGFEFuncGElement": false, - "SVGFEFuncRElement": false, - "SVGFEGaussianBlurElement": false, - "SVGFEImageElement": false, - "SVGFEMergeElement": false, - "SVGFEMergeNodeElement": false, - "SVGFEMorphologyElement": false, - "SVGFEOffsetElement": false, - "SVGFEPointLightElement": false, - "SVGFESpecularLightingElement": false, - "SVGFESpotLightElement": false, - "SVGFETileElement": false, - "SVGFETurbulenceElement": false, - "SVGFilterElement": false, - "SVGForeignObjectElement": false, - "SVGGElement": false, - "SVGGeometryElement": false, - "SVGGradientElement": false, - "SVGGraphicsElement": false, - "SVGImageElement": false, - "SVGLength": false, - "SVGLengthList": false, - "SVGLinearGradientElement": false, - "SVGLineElement": false, - "SVGMarkerElement": false, - "SVGMaskElement": false, - "SVGMatrix": false, - "SVGMetadataElement": false, - "SVGMPathElement": false, - "SVGNumber": false, - "SVGNumberList": false, - "SVGPathElement": false, - "SVGPatternElement": false, - "SVGPoint": false, - "SVGPointList": false, - "SVGPolygonElement": false, - "SVGPolylineElement": false, - "SVGPreserveAspectRatio": false, - "SVGRadialGradientElement": false, - "SVGRect": false, - "SVGRectElement": false, - "SVGScriptElement": false, - "SVGSetElement": false, - "SVGStopElement": false, - "SVGStringList": false, - "SVGStyleElement": false, - "SVGSVGElement": false, - "SVGSwitchElement": false, - "SVGSymbolElement": false, - "SVGTextContentElement": false, - "SVGTextElement": false, - "SVGTextPathElement": false, - "SVGTextPositioningElement": false, - "SVGTitleElement": false, - "SVGTransform": false, - "SVGTransformList": false, - "SVGTSpanElement": false, - "SVGUnitTypes": false, - "SVGUseElement": false, - "SVGViewElement": false, - "TaskAttributionTiming": false, - "Text": false, - "TextDecoder": false, - "TextDecoderStream": false, - "TextEncoder": false, - "TextEncoderStream": false, - "TextEvent": false, - "TextMetrics": false, - "TextTrack": false, - "TextTrackCue": false, - "TextTrackCueList": false, - "TextTrackList": false, - "TimeRanges": false, - "ToggleEvent": false, - "toolbar": false, - "top": false, - "Touch": false, - "TouchEvent": false, - "TouchList": false, - "TrackEvent": false, - "TransformStream": false, - "TransformStreamDefaultController": false, - "TransitionEvent": false, - "TreeWalker": false, - "UIEvent": false, - "URL": false, - "URLSearchParams": false, - "ValidityState": false, - "visualViewport": false, - "VisualViewport": false, - "VTTCue": false, - "WaveShaperNode": false, - "WebAssembly": false, - "WebGL2RenderingContext": false, - "WebGLActiveInfo": false, - "WebGLBuffer": false, - "WebGLContextEvent": false, - "WebGLFramebuffer": false, - "WebGLProgram": false, - "WebGLQuery": false, - "WebGLRenderbuffer": false, - "WebGLRenderingContext": false, - "WebGLSampler": false, - "WebGLShader": false, - "WebGLShaderPrecisionFormat": false, - "WebGLSync": false, - "WebGLTexture": false, - "WebGLTransformFeedback": false, - "WebGLUniformLocation": false, - "WebGLVertexArrayObject": false, - "WebSocket": false, - "WheelEvent": false, - "window": false, - "Window": false, - "Worker": false, - "WritableStream": false, - "WritableStreamDefaultController": false, - "WritableStreamDefaultWriter": false, - "XMLDocument": false, - "XMLHttpRequest": false, - "XMLHttpRequestEventTarget": false, - "XMLHttpRequestUpload": false, - "XMLSerializer": false, - "XPathEvaluator": false, - "XPathExpression": false, - "XPathResult": false, - "XRAnchor": false, - "XRBoundedReferenceSpace": false, - "XRCPUDepthInformation": false, - "XRDepthInformation": false, - "XRFrame": false, - "XRInputSource": false, - "XRInputSourceArray": false, - "XRInputSourceEvent": false, - "XRInputSourcesChangeEvent": false, - "XRPose": false, - "XRReferenceSpace": false, - "XRReferenceSpaceEvent": false, - "XRRenderState": false, - "XRRigidTransform": false, - "XRSession": false, - "XRSessionEvent": false, - "XRSpace": false, - "XRSystem": false, - "XRView": false, - "XRViewerPose": false, - "XRViewport": false, - "XRWebGLBinding": false, - "XRWebGLDepthInformation": false, - "XRWebGLLayer": false, - "XSLTProcessor": false - }, - "worker": { - "addEventListener": false, - "applicationCache": false, - "atob": false, - "Blob": false, - "BroadcastChannel": false, - "btoa": false, - "ByteLengthQueuingStrategy": false, - "Cache": false, - "caches": false, - "clearInterval": false, - "clearTimeout": false, - "close": true, - "CompressionStream": false, - "console": false, - "CountQueuingStrategy": false, - "crypto": false, - "Crypto": false, - "CryptoKey": false, - "CustomEvent": false, - "DecompressionStream": false, - "ErrorEvent": false, - "Event": false, - "fetch": false, - "File": false, - "FileReaderSync": false, - "FormData": false, - "Headers": false, - "IDBCursor": false, - "IDBCursorWithValue": false, - "IDBDatabase": false, - "IDBFactory": false, - "IDBIndex": false, - "IDBKeyRange": false, - "IDBObjectStore": false, - "IDBOpenDBRequest": false, - "IDBRequest": false, - "IDBTransaction": false, - "IDBVersionChangeEvent": false, - "ImageData": false, - "importScripts": true, - "indexedDB": false, - "location": false, - "MessageChannel": false, - "MessageEvent": false, - "MessagePort": false, - "name": false, - "navigator": false, - "Notification": false, - "onclose": true, - "onconnect": true, - "onerror": true, - "onlanguagechange": true, - "onmessage": true, - "onoffline": true, - "ononline": true, - "onrejectionhandled": true, - "onunhandledrejection": true, - "performance": false, - "Performance": false, - "PerformanceEntry": false, - "PerformanceMark": false, - "PerformanceMeasure": false, - "PerformanceNavigation": false, - "PerformanceObserver": false, - "PerformanceObserverEntryList": false, - "PerformanceResourceTiming": false, - "PerformanceTiming": false, - "postMessage": true, - "Promise": false, - "queueMicrotask": false, - "ReadableByteStreamController": false, - "ReadableStream": false, - "ReadableStreamBYOBReader": false, - "ReadableStreamBYOBRequest": false, - "ReadableStreamDefaultController": false, - "ReadableStreamDefaultReader": false, - "removeEventListener": false, - "reportError": false, - "Request": false, - "Response": false, - "self": true, - "ServiceWorkerRegistration": false, - "setInterval": false, - "setTimeout": false, - "SubtleCrypto": false, - "TextDecoder": false, - "TextDecoderStream": false, - "TextEncoder": false, - "TextEncoderStream": false, - "TransformStream": false, - "TransformStreamDefaultController": false, - "URL": false, - "URLSearchParams": false, - "WebAssembly": false, - "WebSocket": false, - "Worker": false, - "WorkerGlobalScope": false, - "WritableStream": false, - "WritableStreamDefaultController": false, - "WritableStreamDefaultWriter": false, - "XMLHttpRequest": false - }, - "node": { - "__dirname": false, - "__filename": false, - "AbortController": false, - "AbortSignal": false, - "atob": false, - "Blob": false, - "BroadcastChannel": false, - "btoa": false, - "Buffer": false, - "ByteLengthQueuingStrategy": false, - "clearImmediate": false, - "clearInterval": false, - "clearTimeout": false, - "CompressionStream": false, - "console": false, - "CountQueuingStrategy": false, - "crypto": false, - "Crypto": false, - "CryptoKey": false, - "CustomEvent": false, - "DecompressionStream": false, - "DOMException": false, - "Event": false, - "EventTarget": false, - "exports": true, - "fetch": false, - "File": false, - "FormData": false, - "global": false, - "Headers": false, - "Intl": false, - "MessageChannel": false, - "MessageEvent": false, - "MessagePort": false, - "module": false, - "performance": false, - "PerformanceEntry": false, - "PerformanceMark": false, - "PerformanceMeasure": false, - "PerformanceObserver": false, - "PerformanceObserverEntryList": false, - "PerformanceResourceTiming": false, - "process": false, - "queueMicrotask": false, - "ReadableByteStreamController": false, - "ReadableStream": false, - "ReadableStreamBYOBReader": false, - "ReadableStreamBYOBRequest": false, - "ReadableStreamDefaultController": false, - "ReadableStreamDefaultReader": false, - "Request": false, - "require": false, - "Response": false, - "setImmediate": false, - "setInterval": false, - "setTimeout": false, - "structuredClone": false, - "SubtleCrypto": false, - "TextDecoder": false, - "TextDecoderStream": false, - "TextEncoder": false, - "TextEncoderStream": false, - "TransformStream": false, - "TransformStreamDefaultController": false, - "URL": false, - "URLSearchParams": false, - "WebAssembly": false, - "WritableStream": false, - "WritableStreamDefaultController": false, - "WritableStreamDefaultWriter": false - }, - "nodeBuiltin": { - "AbortController": false, - "AbortSignal": false, - "atob": false, - "Blob": false, - "BroadcastChannel": false, - "btoa": false, - "Buffer": false, - "ByteLengthQueuingStrategy": false, - "clearImmediate": false, - "clearInterval": false, - "clearTimeout": false, - "CompressionStream": false, - "console": false, - "CountQueuingStrategy": false, - "crypto": false, - "Crypto": false, - "CryptoKey": false, - "CustomEvent": false, - "DecompressionStream": false, - "DOMException": false, - "Event": false, - "EventTarget": false, - "fetch": false, - "File": false, - "FormData": false, - "global": false, - "Headers": false, - "Intl": false, - "MessageChannel": false, - "MessageEvent": false, - "MessagePort": false, - "performance": false, - "PerformanceEntry": false, - "PerformanceMark": false, - "PerformanceMeasure": false, - "PerformanceObserver": false, - "PerformanceObserverEntryList": false, - "PerformanceResourceTiming": false, - "process": false, - "queueMicrotask": false, - "ReadableByteStreamController": false, - "ReadableStream": false, - "ReadableStreamBYOBReader": false, - "ReadableStreamBYOBRequest": false, - "ReadableStreamDefaultController": false, - "ReadableStreamDefaultReader": false, - "Request": false, - "Response": false, - "setImmediate": false, - "setInterval": false, - "setTimeout": false, - "structuredClone": false, - "SubtleCrypto": false, - "TextDecoder": false, - "TextDecoderStream": false, - "TextEncoder": false, - "TextEncoderStream": false, - "TransformStream": false, - "TransformStreamDefaultController": false, - "URL": false, - "URLSearchParams": false, - "WebAssembly": false, - "WritableStream": false, - "WritableStreamDefaultController": false, - "WritableStreamDefaultWriter": false - }, - "commonjs": { - "exports": true, - "global": false, - "module": false, - "require": false - }, - "amd": { - "define": false, - "require": false - }, - "mocha": { - "after": false, - "afterEach": false, - "before": false, - "beforeEach": false, - "context": false, - "describe": false, - "it": false, - "mocha": false, - "run": false, - "setup": false, - "specify": false, - "suite": false, - "suiteSetup": false, - "suiteTeardown": false, - "teardown": false, - "test": false, - "xcontext": false, - "xdescribe": false, - "xit": false, - "xspecify": false - }, - "jasmine": { - "afterAll": false, - "afterEach": false, - "beforeAll": false, - "beforeEach": false, - "describe": false, - "expect": false, - "expectAsync": false, - "fail": false, - "fdescribe": false, - "fit": false, - "it": false, - "jasmine": false, - "pending": false, - "runs": false, - "spyOn": false, - "spyOnAllFunctions": false, - "spyOnProperty": false, - "waits": false, - "waitsFor": false, - "xdescribe": false, - "xit": false - }, - "jest": { - "afterAll": false, - "afterEach": false, - "beforeAll": false, - "beforeEach": false, - "describe": false, - "expect": false, - "fdescribe": false, - "fit": false, - "it": false, - "jest": false, - "pit": false, - "require": false, - "test": false, - "xdescribe": false, - "xit": false, - "xtest": false - }, - "qunit": { - "asyncTest": false, - "deepEqual": false, - "equal": false, - "expect": false, - "module": false, - "notDeepEqual": false, - "notEqual": false, - "notOk": false, - "notPropEqual": false, - "notStrictEqual": false, - "ok": false, - "propEqual": false, - "QUnit": false, - "raises": false, - "start": false, - "stop": false, - "strictEqual": false, - "test": false, - "throws": false - }, - "phantomjs": { - "console": true, - "exports": true, - "phantom": true, - "require": true, - "WebPage": true - }, - "couch": { - "emit": false, - "exports": false, - "getRow": false, - "log": false, - "module": false, - "provides": false, - "require": false, - "respond": false, - "send": false, - "start": false, - "sum": false - }, - "rhino": { - "defineClass": false, - "deserialize": false, - "gc": false, - "help": false, - "importClass": false, - "importPackage": false, - "java": false, - "load": false, - "loadClass": false, - "Packages": false, - "print": false, - "quit": false, - "readFile": false, - "readUrl": false, - "runCommand": false, - "seal": false, - "serialize": false, - "spawn": false, - "sync": false, - "toint32": false, - "version": false - }, - "nashorn": { - "__DIR__": false, - "__FILE__": false, - "__LINE__": false, - "com": false, - "edu": false, - "exit": false, - "java": false, - "Java": false, - "javafx": false, - "JavaImporter": false, - "javax": false, - "JSAdapter": false, - "load": false, - "loadWithNewGlobal": false, - "org": false, - "Packages": false, - "print": false, - "quit": false - }, - "wsh": { - "ActiveXObject": false, - "CollectGarbage": false, - "Debug": false, - "Enumerator": false, - "GetObject": false, - "RuntimeObject": false, - "ScriptEngine": false, - "ScriptEngineBuildVersion": false, - "ScriptEngineMajorVersion": false, - "ScriptEngineMinorVersion": false, - "VBArray": false, - "WScript": false, - "WSH": false - }, - "jquery": { - "$": false, - "jQuery": false - }, - "yui": { - "YAHOO": false, - "YAHOO_config": false, - "YUI": false, - "YUI_config": false - }, - "shelljs": { - "cat": false, - "cd": false, - "chmod": false, - "config": false, - "cp": false, - "dirs": false, - "echo": false, - "env": false, - "error": false, - "exec": false, - "exit": false, - "find": false, - "grep": false, - "ln": false, - "ls": false, - "mkdir": false, - "mv": false, - "popd": false, - "pushd": false, - "pwd": false, - "rm": false, - "sed": false, - "set": false, - "target": false, - "tempdir": false, - "test": false, - "touch": false, - "which": false - }, - "prototypejs": { - "$": false, - "$$": false, - "$A": false, - "$break": false, - "$continue": false, - "$F": false, - "$H": false, - "$R": false, - "$w": false, - "Abstract": false, - "Ajax": false, - "Autocompleter": false, - "Builder": false, - "Class": false, - "Control": false, - "Draggable": false, - "Draggables": false, - "Droppables": false, - "Effect": false, - "Element": false, - "Enumerable": false, - "Event": false, - "Field": false, - "Form": false, - "Hash": false, - "Insertion": false, - "ObjectRange": false, - "PeriodicalExecuter": false, - "Position": false, - "Prototype": false, - "Scriptaculous": false, - "Selector": false, - "Sortable": false, - "SortableObserver": false, - "Sound": false, - "Template": false, - "Toggle": false, - "Try": false - }, - "meteor": { - "$": false, - "Accounts": false, - "AccountsClient": false, - "AccountsCommon": false, - "AccountsServer": false, - "App": false, - "Assets": false, - "Blaze": false, - "check": false, - "Cordova": false, - "DDP": false, - "DDPRateLimiter": false, - "DDPServer": false, - "Deps": false, - "EJSON": false, - "Email": false, - "HTTP": false, - "Log": false, - "Match": false, - "Meteor": false, - "Mongo": false, - "MongoInternals": false, - "Npm": false, - "Package": false, - "Plugin": false, - "process": false, - "Random": false, - "ReactiveDict": false, - "ReactiveVar": false, - "Router": false, - "ServiceConfiguration": false, - "Session": false, - "share": false, - "Spacebars": false, - "Template": false, - "Tinytest": false, - "Tracker": false, - "UI": false, - "Utils": false, - "WebApp": false, - "WebAppInternals": false - }, - "mongo": { - "_isWindows": false, - "_rand": false, - "BulkWriteResult": false, - "cat": false, - "cd": false, - "connect": false, - "db": false, - "getHostName": false, - "getMemInfo": false, - "hostname": false, - "ISODate": false, - "listFiles": false, - "load": false, - "ls": false, - "md5sumFile": false, - "mkdir": false, - "Mongo": false, - "NumberInt": false, - "NumberLong": false, - "ObjectId": false, - "PlanCache": false, - "print": false, - "printjson": false, - "pwd": false, - "quit": false, - "removeFile": false, - "rs": false, - "sh": false, - "UUID": false, - "version": false, - "WriteResult": false - }, - "applescript": { - "$": false, - "Application": false, - "Automation": false, - "console": false, - "delay": false, - "Library": false, - "ObjC": false, - "ObjectSpecifier": false, - "Path": false, - "Progress": false, - "Ref": false - }, - "serviceworker": { - "addEventListener": false, - "applicationCache": false, - "atob": false, - "Blob": false, - "BroadcastChannel": false, - "btoa": false, - "ByteLengthQueuingStrategy": false, - "Cache": false, - "caches": false, - "CacheStorage": false, - "clearInterval": false, - "clearTimeout": false, - "Client": false, - "clients": false, - "Clients": false, - "close": true, - "CompressionStream": false, - "console": false, - "CountQueuingStrategy": false, - "crypto": false, - "Crypto": false, - "CryptoKey": false, - "CustomEvent": false, - "DecompressionStream": false, - "ErrorEvent": false, - "Event": false, - "ExtendableEvent": false, - "ExtendableMessageEvent": false, - "fetch": false, - "FetchEvent": false, - "File": false, - "FileReaderSync": false, - "FormData": false, - "Headers": false, - "IDBCursor": false, - "IDBCursorWithValue": false, - "IDBDatabase": false, - "IDBFactory": false, - "IDBIndex": false, - "IDBKeyRange": false, - "IDBObjectStore": false, - "IDBOpenDBRequest": false, - "IDBRequest": false, - "IDBTransaction": false, - "IDBVersionChangeEvent": false, - "ImageData": false, - "importScripts": false, - "indexedDB": false, - "location": false, - "MessageChannel": false, - "MessageEvent": false, - "MessagePort": false, - "name": false, - "navigator": false, - "Notification": false, - "onclose": true, - "onconnect": true, - "onerror": true, - "onfetch": true, - "oninstall": true, - "onlanguagechange": true, - "onmessage": true, - "onmessageerror": true, - "onnotificationclick": true, - "onnotificationclose": true, - "onoffline": true, - "ononline": true, - "onpush": true, - "onpushsubscriptionchange": true, - "onrejectionhandled": true, - "onsync": true, - "onunhandledrejection": true, - "performance": false, - "Performance": false, - "PerformanceEntry": false, - "PerformanceMark": false, - "PerformanceMeasure": false, - "PerformanceNavigation": false, - "PerformanceObserver": false, - "PerformanceObserverEntryList": false, - "PerformanceResourceTiming": false, - "PerformanceTiming": false, - "postMessage": true, - "Promise": false, - "queueMicrotask": false, - "ReadableByteStreamController": false, - "ReadableStream": false, - "ReadableStreamBYOBReader": false, - "ReadableStreamBYOBRequest": false, - "ReadableStreamDefaultController": false, - "ReadableStreamDefaultReader": false, - "registration": false, - "removeEventListener": false, - "Request": false, - "Response": false, - "self": false, - "ServiceWorker": false, - "ServiceWorkerContainer": false, - "ServiceWorkerGlobalScope": false, - "ServiceWorkerMessageEvent": false, - "ServiceWorkerRegistration": false, - "setInterval": false, - "setTimeout": false, - "skipWaiting": false, - "SubtleCrypto": false, - "TextDecoder": false, - "TextDecoderStream": false, - "TextEncoder": false, - "TextEncoderStream": false, - "TransformStream": false, - "TransformStreamDefaultController": false, - "URL": false, - "URLSearchParams": false, - "WebAssembly": false, - "WebSocket": false, - "WindowClient": false, - "Worker": false, - "WorkerGlobalScope": false, - "WritableStream": false, - "WritableStreamDefaultController": false, - "WritableStreamDefaultWriter": false, - "XMLHttpRequest": false - }, - "atomtest": { - "advanceClock": false, - "atom": false, - "fakeClearInterval": false, - "fakeClearTimeout": false, - "fakeSetInterval": false, - "fakeSetTimeout": false, - "resetTimeouts": false, - "waitsForPromise": false - }, - "embertest": { - "andThen": false, - "click": false, - "currentPath": false, - "currentRouteName": false, - "currentURL": false, - "fillIn": false, - "find": false, - "findAll": false, - "findWithAssert": false, - "keyEvent": false, - "pauseTest": false, - "resumeTest": false, - "triggerEvent": false, - "visit": false, - "wait": false - }, - "protractor": { - "$": false, - "$$": false, - "browser": false, - "by": false, - "By": false, - "DartObject": false, - "element": false, - "protractor": false - }, - "shared-node-browser": { - "AbortController": false, - "AbortSignal": false, - "atob": false, - "Blob": false, - "BroadcastChannel": false, - "btoa": false, - "ByteLengthQueuingStrategy": false, - "clearInterval": false, - "clearTimeout": false, - "CompressionStream": false, - "console": false, - "CountQueuingStrategy": false, - "crypto": false, - "Crypto": false, - "CryptoKey": false, - "CustomEvent": false, - "DecompressionStream": false, - "DOMException": false, - "Event": false, - "EventTarget": false, - "fetch": false, - "File": false, - "FormData": false, - "Headers": false, - "Intl": false, - "MessageChannel": false, - "MessageEvent": false, - "MessagePort": false, - "performance": false, - "PerformanceEntry": false, - "PerformanceMark": false, - "PerformanceMeasure": false, - "PerformanceObserver": false, - "PerformanceObserverEntryList": false, - "PerformanceResourceTiming": false, - "queueMicrotask": false, - "ReadableByteStreamController": false, - "ReadableStream": false, - "ReadableStreamBYOBReader": false, - "ReadableStreamBYOBRequest": false, - "ReadableStreamDefaultController": false, - "ReadableStreamDefaultReader": false, - "Request": false, - "Response": false, - "setInterval": false, - "setTimeout": false, - "structuredClone": false, - "SubtleCrypto": false, - "TextDecoder": false, - "TextDecoderStream": false, - "TextEncoder": false, - "TextEncoderStream": false, - "TransformStream": false, - "TransformStreamDefaultController": false, - "URL": false, - "URLSearchParams": false, - "WebAssembly": false, - "WritableStream": false, - "WritableStreamDefaultController": false, - "WritableStreamDefaultWriter": false - }, - "webextensions": { - "browser": false, - "chrome": false, - "opr": false - }, - "greasemonkey": { - "cloneInto": false, - "createObjectIn": false, - "exportFunction": false, - "GM": false, - "GM_addElement": false, - "GM_addStyle": false, - "GM_addValueChangeListener": false, - "GM_deleteValue": false, - "GM_download": false, - "GM_getResourceText": false, - "GM_getResourceURL": false, - "GM_getTab": false, - "GM_getTabs": false, - "GM_getValue": false, - "GM_info": false, - "GM_listValues": false, - "GM_log": false, - "GM_notification": false, - "GM_openInTab": false, - "GM_registerMenuCommand": false, - "GM_removeValueChangeListener": false, - "GM_saveTab": false, - "GM_setClipboard": false, - "GM_setValue": false, - "GM_unregisterMenuCommand": false, - "GM_xmlhttpRequest": false, - "unsafeWindow": false - }, - "devtools": { - "$": false, - "$_": false, - "$$": false, - "$0": false, - "$1": false, - "$2": false, - "$3": false, - "$4": false, - "$x": false, - "chrome": false, - "clear": false, - "copy": false, - "debug": false, - "dir": false, - "dirxml": false, - "getEventListeners": false, - "inspect": false, - "keys": false, - "monitor": false, - "monitorEvents": false, - "profile": false, - "profileEnd": false, - "queryObjects": false, - "table": false, - "undebug": false, - "unmonitor": false, - "unmonitorEvents": false, - "values": false - } -} diff --git a/tools/eslint/node_modules/@eslint/eslintrc/node_modules/globals/index.js b/tools/eslint/node_modules/@eslint/eslintrc/node_modules/globals/index.js deleted file mode 100644 index a951582e4176e8..00000000000000 --- a/tools/eslint/node_modules/@eslint/eslintrc/node_modules/globals/index.js +++ /dev/null @@ -1,2 +0,0 @@ -'use strict'; -module.exports = require('./globals.json'); diff --git a/tools/eslint/node_modules/@eslint/eslintrc/node_modules/globals/license b/tools/eslint/node_modules/@eslint/eslintrc/node_modules/globals/license deleted file mode 100644 index fa7ceba3eb4a96..00000000000000 --- a/tools/eslint/node_modules/@eslint/eslintrc/node_modules/globals/license +++ /dev/null @@ -1,9 +0,0 @@ -MIT License - -Copyright (c) Sindre Sorhus (https://sindresorhus.com) - -Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/tools/eslint/node_modules/@eslint/eslintrc/node_modules/globals/package.json b/tools/eslint/node_modules/@eslint/eslintrc/node_modules/globals/package.json deleted file mode 100644 index fca10a52d13024..00000000000000 --- a/tools/eslint/node_modules/@eslint/eslintrc/node_modules/globals/package.json +++ /dev/null @@ -1,58 +0,0 @@ -{ - "name": "globals", - "version": "14.0.0", - "description": "Global identifiers from different JavaScript environments", - "license": "MIT", - "repository": "sindresorhus/globals", - "funding": "https://github.com/sponsors/sindresorhus", - "author": { - "name": "Sindre Sorhus", - "email": "sindresorhus@gmail.com", - "url": "https://sindresorhus.com" - }, - "sideEffects": false, - "engines": { - "node": ">=18" - }, - "scripts": { - "test": "xo && ava && tsd", - "prepare": "npm run --silent update-types", - "update-builtin-globals": "node scripts/get-builtin-globals.mjs", - "update-types": "node scripts/generate-types.mjs > index.d.ts" - }, - "files": [ - "index.js", - "index.d.ts", - "globals.json" - ], - "keywords": [ - "globals", - "global", - "identifiers", - "variables", - "vars", - "jshint", - "eslint", - "environments" - ], - "devDependencies": { - "ava": "^2.4.0", - "cheerio": "^1.0.0-rc.12", - "tsd": "^0.30.4", - "type-fest": "^4.10.2", - "xo": "^0.36.1" - }, - "xo": { - "ignores": [ - "get-browser-globals.js" - ], - "rules": { - "node/no-unsupported-features/es-syntax": "off" - } - }, - "tsd": { - "compilerOptions": { - "resolveJsonModule": true - } - } -} diff --git a/tools/eslint/node_modules/@eslint/eslintrc/node_modules/globals/readme.md b/tools/eslint/node_modules/@eslint/eslintrc/node_modules/globals/readme.md deleted file mode 100644 index 29442a85510b95..00000000000000 --- a/tools/eslint/node_modules/@eslint/eslintrc/node_modules/globals/readme.md +++ /dev/null @@ -1,44 +0,0 @@ -# globals - -> Global identifiers from different JavaScript environments - -It's just a [JSON file](globals.json), so use it in any environment. - -This package is used by ESLint. - -**This package [no longer accepts](https://github.com/sindresorhus/globals/issues/82) new environments. If you need it for ESLint, just [create a plugin](http://eslint.org/docs/developer-guide/working-with-plugins#environments-in-plugins).** - -## Install - -```sh -npm install globals -``` - -## Usage - -```js -const globals = require('globals'); - -console.log(globals.browser); -/* -{ - addEventListener: false, - applicationCache: false, - ArrayBuffer: false, - atob: false, - โ€ฆ -} -*/ -``` - -Each global is given a value of `true` or `false`. A value of `true` indicates that the variable may be overwritten. A value of `false` indicates that the variable should be considered read-only. This information is used by static analysis tools to flag incorrect behavior. We assume all variables should be `false` unless we hear otherwise. - -For Node.js this package provides two sets of globals: - -- `globals.nodeBuiltin`: Globals available to all code running in Node.js. - These will usually be available as properties on the `global` object and include `process`, `Buffer`, but not CommonJS arguments like `require`. - See: https://nodejs.org/api/globals.html -- `globals.node`: A combination of the globals from `nodeBuiltin` plus all CommonJS arguments ("CommonJS module scope"). - See: https://nodejs.org/api/modules.html#modules_the_module_scope - -When analyzing code that is known to run outside of a CommonJS wrapper, for example, JavaScript modules, `nodeBuiltin` can find accidental CommonJS references. diff --git a/tools/eslint/node_modules/@eslint/eslintrc/package.json b/tools/eslint/node_modules/@eslint/eslintrc/package.json deleted file mode 100644 index fea77e2d9d39cc..00000000000000 --- a/tools/eslint/node_modules/@eslint/eslintrc/package.json +++ /dev/null @@ -1,82 +0,0 @@ -{ - "name": "@eslint/eslintrc", - "version": "3.1.0", - "description": "The legacy ESLintRC config file format for ESLint", - "type": "module", - "main": "./dist/eslintrc.cjs", - "exports": { - ".": { - "import": "./lib/index.js", - "require": "./dist/eslintrc.cjs" - }, - "./package.json": "./package.json", - "./universal": { - "import": "./lib/index-universal.js", - "require": "./dist/eslintrc-universal.cjs" - } - }, - "files": [ - "lib", - "conf", - "LICENSE", - "dist", - "universal.js" - ], - "publishConfig": { - "access": "public" - }, - "scripts": { - "build": "rollup -c", - "lint": "eslint . --report-unused-disable-directives", - "lint:fix": "npm run lint -- --fix", - "prepare": "npm run build", - "release:generate:latest": "eslint-generate-release", - "release:generate:alpha": "eslint-generate-prerelease alpha", - "release:generate:beta": "eslint-generate-prerelease beta", - "release:generate:rc": "eslint-generate-prerelease rc", - "release:publish": "eslint-publish-release", - "test": "mocha -R progress -c 'tests/lib/*.cjs' && c8 mocha -R progress -c 'tests/lib/**/*.js'" - }, - "repository": "eslint/eslintrc", - "funding": "https://opencollective.com/eslint", - "keywords": [ - "ESLint", - "ESLintRC", - "Configuration" - ], - "author": "Nicholas C. Zakas", - "license": "MIT", - "bugs": { - "url": "https://github.com/eslint/eslintrc/issues" - }, - "homepage": "https://github.com/eslint/eslintrc#readme", - "devDependencies": { - "c8": "^7.7.3", - "chai": "^4.3.4", - "eslint": "^7.31.0", - "eslint-config-eslint": "^7.0.0", - "eslint-plugin-jsdoc": "^35.4.1", - "eslint-plugin-node": "^11.1.0", - "eslint-release": "^3.2.0", - "fs-teardown": "^0.1.3", - "mocha": "^9.0.3", - "rollup": "^2.70.1", - "shelljs": "^0.8.5", - "sinon": "^11.1.2", - "temp-dir": "^2.0.0" - }, - "dependencies": { - "ajv": "^6.12.4", - "debug": "^4.3.2", - "espree": "^10.0.1", - "globals": "^14.0.0", - "ignore": "^5.2.0", - "import-fresh": "^3.2.1", - "js-yaml": "^4.1.0", - "minimatch": "^3.1.2", - "strip-json-comments": "^3.1.1" - }, - "engines": { - "node": "^18.18.0 || ^20.9.0 || >=21.1.0" - } -} diff --git a/tools/eslint/node_modules/@eslint/eslintrc/universal.js b/tools/eslint/node_modules/@eslint/eslintrc/universal.js deleted file mode 100644 index 4e1846ee6e0106..00000000000000 --- a/tools/eslint/node_modules/@eslint/eslintrc/universal.js +++ /dev/null @@ -1,9 +0,0 @@ -// Jest (and probably some other runtimes with custom implementations of -// `require`) doesn't support `exports` in `package.json`, so this file is here -// to help them load this module. Note that it is also `.js` and not `.cjs` for -// the same reason - `cjs` files requires to be loaded with an extension, but -// since Jest doesn't respect `module` outside of ESM mode it still works in -// this case (and the `require` in _this_ file does specify the extension). - -// eslint-disable-next-line no-undef -module.exports = require("./dist/eslintrc-universal.cjs"); diff --git a/tools/eslint/node_modules/@eslint/js/LICENSE b/tools/eslint/node_modules/@eslint/js/LICENSE deleted file mode 100644 index b607bb36e96c33..00000000000000 --- a/tools/eslint/node_modules/@eslint/js/LICENSE +++ /dev/null @@ -1,19 +0,0 @@ -Copyright OpenJS Foundation and other contributors, - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. diff --git a/tools/eslint/node_modules/@eslint/js/package.json b/tools/eslint/node_modules/@eslint/js/package.json deleted file mode 100644 index 898afe3bd8a615..00000000000000 --- a/tools/eslint/node_modules/@eslint/js/package.json +++ /dev/null @@ -1,31 +0,0 @@ -{ - "name": "@eslint/js", - "version": "9.7.0", - "description": "ESLint JavaScript language implementation", - "main": "./src/index.js", - "scripts": {}, - "files": [ - "LICENSE", - "README.md", - "src" - ], - "publishConfig": { - "access": "public" - }, - "repository": { - "type": "git", - "url": "https://github.com/eslint/eslint.git", - "directory": "packages/js" - }, - "homepage": "https://eslint.org", - "bugs": "https://github.com/eslint/eslint/issues/", - "keywords": [ - "javascript", - "eslint-plugin", - "eslint" - ], - "license": "MIT", - "engines": { - "node": "^18.18.0 || ^20.9.0 || >=21.1.0" - } -} diff --git a/tools/eslint/node_modules/@eslint/js/src/configs/eslint-all.js b/tools/eslint/node_modules/@eslint/js/src/configs/eslint-all.js deleted file mode 100644 index e7f4e0e3a11b73..00000000000000 --- a/tools/eslint/node_modules/@eslint/js/src/configs/eslint-all.js +++ /dev/null @@ -1,217 +0,0 @@ -/* - * WARNING: This file is autogenerated using the tools/update-eslint-all.js - * script. Do not edit manually. - */ -"use strict"; - -/* eslint quote-props: off -- autogenerated so don't lint */ - -/* - * IMPORTANT! - * - * We cannot add a "name" property to this object because it's still used in eslintrc - * which doesn't support the "name" property. If we add a "name" property, it will - * cause an error. - */ - -module.exports = Object.freeze({ - "rules": { - "accessor-pairs": "error", - "array-callback-return": "error", - "arrow-body-style": "error", - "block-scoped-var": "error", - "camelcase": "error", - "capitalized-comments": "error", - "class-methods-use-this": "error", - "complexity": "error", - "consistent-return": "error", - "consistent-this": "error", - "constructor-super": "error", - "curly": "error", - "default-case": "error", - "default-case-last": "error", - "default-param-last": "error", - "dot-notation": "error", - "eqeqeq": "error", - "for-direction": "error", - "func-name-matching": "error", - "func-names": "error", - "func-style": "error", - "getter-return": "error", - "grouped-accessor-pairs": "error", - "guard-for-in": "error", - "id-denylist": "error", - "id-length": "error", - "id-match": "error", - "init-declarations": "error", - "logical-assignment-operators": "error", - "max-classes-per-file": "error", - "max-depth": "error", - "max-lines": "error", - "max-lines-per-function": "error", - "max-nested-callbacks": "error", - "max-params": "error", - "max-statements": "error", - "new-cap": "error", - "no-alert": "error", - "no-array-constructor": "error", - "no-async-promise-executor": "error", - "no-await-in-loop": "error", - "no-bitwise": "error", - "no-caller": "error", - "no-case-declarations": "error", - "no-class-assign": "error", - "no-compare-neg-zero": "error", - "no-cond-assign": "error", - "no-console": "error", - "no-const-assign": "error", - "no-constant-binary-expression": "error", - "no-constant-condition": "error", - "no-constructor-return": "error", - "no-continue": "error", - "no-control-regex": "error", - "no-debugger": "error", - "no-delete-var": "error", - "no-div-regex": "error", - "no-dupe-args": "error", - "no-dupe-class-members": "error", - "no-dupe-else-if": "error", - "no-dupe-keys": "error", - "no-duplicate-case": "error", - "no-duplicate-imports": "error", - "no-else-return": "error", - "no-empty": "error", - "no-empty-character-class": "error", - "no-empty-function": "error", - "no-empty-pattern": "error", - "no-empty-static-block": "error", - "no-eq-null": "error", - "no-eval": "error", - "no-ex-assign": "error", - "no-extend-native": "error", - "no-extra-bind": "error", - "no-extra-boolean-cast": "error", - "no-extra-label": "error", - "no-fallthrough": "error", - "no-func-assign": "error", - "no-global-assign": "error", - "no-implicit-coercion": "error", - "no-implicit-globals": "error", - "no-implied-eval": "error", - "no-import-assign": "error", - "no-inline-comments": "error", - "no-inner-declarations": "error", - "no-invalid-regexp": "error", - "no-invalid-this": "error", - "no-irregular-whitespace": "error", - "no-iterator": "error", - "no-label-var": "error", - "no-labels": "error", - "no-lone-blocks": "error", - "no-lonely-if": "error", - "no-loop-func": "error", - "no-loss-of-precision": "error", - "no-magic-numbers": "error", - "no-misleading-character-class": "error", - "no-multi-assign": "error", - "no-multi-str": "error", - "no-negated-condition": "error", - "no-nested-ternary": "error", - "no-new": "error", - "no-new-func": "error", - "no-new-native-nonconstructor": "error", - "no-new-wrappers": "error", - "no-nonoctal-decimal-escape": "error", - "no-obj-calls": "error", - "no-object-constructor": "error", - "no-octal": "error", - "no-octal-escape": "error", - "no-param-reassign": "error", - "no-plusplus": "error", - "no-promise-executor-return": "error", - "no-proto": "error", - "no-prototype-builtins": "error", - "no-redeclare": "error", - "no-regex-spaces": "error", - "no-restricted-exports": "error", - "no-restricted-globals": "error", - "no-restricted-imports": "error", - "no-restricted-properties": "error", - "no-restricted-syntax": "error", - "no-return-assign": "error", - "no-script-url": "error", - "no-self-assign": "error", - "no-self-compare": "error", - "no-sequences": "error", - "no-setter-return": "error", - "no-shadow": "error", - "no-shadow-restricted-names": "error", - "no-sparse-arrays": "error", - "no-template-curly-in-string": "error", - "no-ternary": "error", - "no-this-before-super": "error", - "no-throw-literal": "error", - "no-undef": "error", - "no-undef-init": "error", - "no-undefined": "error", - "no-underscore-dangle": "error", - "no-unexpected-multiline": "error", - "no-unmodified-loop-condition": "error", - "no-unneeded-ternary": "error", - "no-unreachable": "error", - "no-unreachable-loop": "error", - "no-unsafe-finally": "error", - "no-unsafe-negation": "error", - "no-unsafe-optional-chaining": "error", - "no-unused-expressions": "error", - "no-unused-labels": "error", - "no-unused-private-class-members": "error", - "no-unused-vars": "error", - "no-use-before-define": "error", - "no-useless-assignment": "error", - "no-useless-backreference": "error", - "no-useless-call": "error", - "no-useless-catch": "error", - "no-useless-computed-key": "error", - "no-useless-concat": "error", - "no-useless-constructor": "error", - "no-useless-escape": "error", - "no-useless-rename": "error", - "no-useless-return": "error", - "no-var": "error", - "no-void": "error", - "no-warning-comments": "error", - "no-with": "error", - "object-shorthand": "error", - "one-var": "error", - "operator-assignment": "error", - "prefer-arrow-callback": "error", - "prefer-const": "error", - "prefer-destructuring": "error", - "prefer-exponentiation-operator": "error", - "prefer-named-capture-group": "error", - "prefer-numeric-literals": "error", - "prefer-object-has-own": "error", - "prefer-object-spread": "error", - "prefer-promise-reject-errors": "error", - "prefer-regex-literals": "error", - "prefer-rest-params": "error", - "prefer-spread": "error", - "prefer-template": "error", - "radix": "error", - "require-atomic-updates": "error", - "require-await": "error", - "require-unicode-regexp": "error", - "require-yield": "error", - "sort-imports": "error", - "sort-keys": "error", - "sort-vars": "error", - "strict": "error", - "symbol-description": "error", - "unicode-bom": "error", - "use-isnan": "error", - "valid-typeof": "error", - "vars-on-top": "error", - "yoda": "error" - } -}); diff --git a/tools/eslint/node_modules/@eslint/js/src/configs/eslint-recommended.js b/tools/eslint/node_modules/@eslint/js/src/configs/eslint-recommended.js deleted file mode 100644 index 3559267efc6f1f..00000000000000 --- a/tools/eslint/node_modules/@eslint/js/src/configs/eslint-recommended.js +++ /dev/null @@ -1,83 +0,0 @@ -/** - * @fileoverview Configuration applied when a user configuration extends from - * eslint:recommended. - * @author Nicholas C. Zakas - */ - -"use strict"; - -/* eslint sort-keys: ["error", "asc"] -- Long, so make more readable */ - -/* - * IMPORTANT! - * - * We cannot add a "name" property to this object because it's still used in eslintrc - * which doesn't support the "name" property. If we add a "name" property, it will - * cause an error. - */ - -module.exports = Object.freeze({ - rules: Object.freeze({ - "constructor-super": "error", - "for-direction": "error", - "getter-return": "error", - "no-async-promise-executor": "error", - "no-case-declarations": "error", - "no-class-assign": "error", - "no-compare-neg-zero": "error", - "no-cond-assign": "error", - "no-const-assign": "error", - "no-constant-binary-expression": "error", - "no-constant-condition": "error", - "no-control-regex": "error", - "no-debugger": "error", - "no-delete-var": "error", - "no-dupe-args": "error", - "no-dupe-class-members": "error", - "no-dupe-else-if": "error", - "no-dupe-keys": "error", - "no-duplicate-case": "error", - "no-empty": "error", - "no-empty-character-class": "error", - "no-empty-pattern": "error", - "no-empty-static-block": "error", - "no-ex-assign": "error", - "no-extra-boolean-cast": "error", - "no-fallthrough": "error", - "no-func-assign": "error", - "no-global-assign": "error", - "no-import-assign": "error", - "no-invalid-regexp": "error", - "no-irregular-whitespace": "error", - "no-loss-of-precision": "error", - "no-misleading-character-class": "error", - "no-new-native-nonconstructor": "error", - "no-nonoctal-decimal-escape": "error", - "no-obj-calls": "error", - "no-octal": "error", - "no-prototype-builtins": "error", - "no-redeclare": "error", - "no-regex-spaces": "error", - "no-self-assign": "error", - "no-setter-return": "error", - "no-shadow-restricted-names": "error", - "no-sparse-arrays": "error", - "no-this-before-super": "error", - "no-undef": "error", - "no-unexpected-multiline": "error", - "no-unreachable": "error", - "no-unsafe-finally": "error", - "no-unsafe-negation": "error", - "no-unsafe-optional-chaining": "error", - "no-unused-labels": "error", - "no-unused-private-class-members": "error", - "no-unused-vars": "error", - "no-useless-backreference": "error", - "no-useless-catch": "error", - "no-useless-escape": "error", - "no-with": "error", - "require-yield": "error", - "use-isnan": "error", - "valid-typeof": "error" - }) -}); diff --git a/tools/eslint/node_modules/@eslint/js/src/index.js b/tools/eslint/node_modules/@eslint/js/src/index.js deleted file mode 100644 index 0d4be486a9b3da..00000000000000 --- a/tools/eslint/node_modules/@eslint/js/src/index.js +++ /dev/null @@ -1,17 +0,0 @@ -/** - * @fileoverview Main package entrypoint. - * @author Nicholas C. Zakas - */ - -"use strict"; - -//------------------------------------------------------------------------------ -// Public Interface -//------------------------------------------------------------------------------ - -module.exports = { - configs: { - all: require("./configs/eslint-all"), - recommended: require("./configs/eslint-recommended") - } -}; diff --git a/tools/eslint/node_modules/@eslint/object-schema/LICENSE b/tools/eslint/node_modules/@eslint/object-schema/LICENSE deleted file mode 100644 index 261eeb9e9f8b2b..00000000000000 --- a/tools/eslint/node_modules/@eslint/object-schema/LICENSE +++ /dev/null @@ -1,201 +0,0 @@ - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright [yyyy] [name of copyright owner] - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. diff --git a/tools/eslint/node_modules/@eslint/object-schema/dist/cjs/index.cjs b/tools/eslint/node_modules/@eslint/object-schema/dist/cjs/index.cjs deleted file mode 100644 index a9687a5f48c68d..00000000000000 --- a/tools/eslint/node_modules/@eslint/object-schema/dist/cjs/index.cjs +++ /dev/null @@ -1,455 +0,0 @@ -'use strict'; - -/** - * @fileoverview Merge Strategy - */ - -//----------------------------------------------------------------------------- -// Class -//----------------------------------------------------------------------------- - -/** - * Container class for several different merge strategies. - */ -class MergeStrategy { - /** - * Merges two keys by overwriting the first with the second. - * @param {*} value1 The value from the first object key. - * @param {*} value2 The value from the second object key. - * @returns {*} The second value. - */ - static overwrite(value1, value2) { - return value2; - } - - /** - * Merges two keys by replacing the first with the second only if the - * second is defined. - * @param {*} value1 The value from the first object key. - * @param {*} value2 The value from the second object key. - * @returns {*} The second value if it is defined. - */ - static replace(value1, value2) { - if (typeof value2 !== "undefined") { - return value2; - } - - return value1; - } - - /** - * Merges two properties by assigning properties from the second to the first. - * @param {*} value1 The value from the first object key. - * @param {*} value2 The value from the second object key. - * @returns {*} A new object containing properties from both value1 and - * value2. - */ - static assign(value1, value2) { - return Object.assign({}, value1, value2); - } -} - -/** - * @fileoverview Validation Strategy - */ - -//----------------------------------------------------------------------------- -// Class -//----------------------------------------------------------------------------- - -/** - * Container class for several different validation strategies. - */ -class ValidationStrategy { - /** - * Validates that a value is an array. - * @param {*} value The value to validate. - * @returns {void} - * @throws {TypeError} If the value is invalid. - */ - static array(value) { - if (!Array.isArray(value)) { - throw new TypeError("Expected an array."); - } - } - - /** - * Validates that a value is a boolean. - * @param {*} value The value to validate. - * @returns {void} - * @throws {TypeError} If the value is invalid. - */ - static boolean(value) { - if (typeof value !== "boolean") { - throw new TypeError("Expected a Boolean."); - } - } - - /** - * Validates that a value is a number. - * @param {*} value The value to validate. - * @returns {void} - * @throws {TypeError} If the value is invalid. - */ - static number(value) { - if (typeof value !== "number") { - throw new TypeError("Expected a number."); - } - } - - /** - * Validates that a value is a object. - * @param {*} value The value to validate. - * @returns {void} - * @throws {TypeError} If the value is invalid. - */ - static object(value) { - if (!value || typeof value !== "object") { - throw new TypeError("Expected an object."); - } - } - - /** - * Validates that a value is a object or null. - * @param {*} value The value to validate. - * @returns {void} - * @throws {TypeError} If the value is invalid. - */ - static "object?"(value) { - if (typeof value !== "object") { - throw new TypeError("Expected an object or null."); - } - } - - /** - * Validates that a value is a string. - * @param {*} value The value to validate. - * @returns {void} - * @throws {TypeError} If the value is invalid. - */ - static string(value) { - if (typeof value !== "string") { - throw new TypeError("Expected a string."); - } - } - - /** - * Validates that a value is a non-empty string. - * @param {*} value The value to validate. - * @returns {void} - * @throws {TypeError} If the value is invalid. - */ - static "string!"(value) { - if (typeof value !== "string" || value.length === 0) { - throw new TypeError("Expected a non-empty string."); - } - } -} - -/** - * @fileoverview Object Schema - */ - - -//----------------------------------------------------------------------------- -// Types -//----------------------------------------------------------------------------- - -/** @typedef {import("./types.ts").ObjectDefinition} ObjectDefinition */ -/** @typedef {import("./types.ts").PropertyDefinition} PropertyDefinition */ - -//----------------------------------------------------------------------------- -// Private -//----------------------------------------------------------------------------- - -/** - * Validates a schema strategy. - * @param {string} name The name of the key this strategy is for. - * @param {PropertyDefinition} definition The strategy for the object key. - * @returns {void} - * @throws {Error} When the strategy is missing a name. - * @throws {Error} When the strategy is missing a merge() method. - * @throws {Error} When the strategy is missing a validate() method. - */ -function validateDefinition(name, definition) { - let hasSchema = false; - if (definition.schema) { - if (typeof definition.schema === "object") { - hasSchema = true; - } else { - throw new TypeError("Schema must be an object."); - } - } - - if (typeof definition.merge === "string") { - if (!(definition.merge in MergeStrategy)) { - throw new TypeError( - `Definition for key "${name}" missing valid merge strategy.`, - ); - } - } else if (!hasSchema && typeof definition.merge !== "function") { - throw new TypeError( - `Definition for key "${name}" must have a merge property.`, - ); - } - - if (typeof definition.validate === "string") { - if (!(definition.validate in ValidationStrategy)) { - throw new TypeError( - `Definition for key "${name}" missing valid validation strategy.`, - ); - } - } else if (!hasSchema && typeof definition.validate !== "function") { - throw new TypeError( - `Definition for key "${name}" must have a validate() method.`, - ); - } -} - -//----------------------------------------------------------------------------- -// Errors -//----------------------------------------------------------------------------- - -/** - * Error when an unexpected key is found. - */ -class UnexpectedKeyError extends Error { - /** - * Creates a new instance. - * @param {string} key The key that was unexpected. - */ - constructor(key) { - super(`Unexpected key "${key}" found.`); - } -} - -/** - * Error when a required key is missing. - */ -class MissingKeyError extends Error { - /** - * Creates a new instance. - * @param {string} key The key that was missing. - */ - constructor(key) { - super(`Missing required key "${key}".`); - } -} - -/** - * Error when a key requires other keys that are missing. - */ -class MissingDependentKeysError extends Error { - /** - * Creates a new instance. - * @param {string} key The key that was unexpected. - * @param {Array} requiredKeys The keys that are required. - */ - constructor(key, requiredKeys) { - super(`Key "${key}" requires keys "${requiredKeys.join('", "')}".`); - } -} - -/** - * Wrapper error for errors occuring during a merge or validate operation. - */ -class WrapperError extends Error { - /** - * Creates a new instance. - * @param {string} key The object key causing the error. - * @param {Error} source The source error. - */ - constructor(key, source) { - super(`Key "${key}": ${source.message}`, { cause: source }); - - // copy over custom properties that aren't represented - for (const sourceKey of Object.keys(source)) { - if (!(sourceKey in this)) { - this[sourceKey] = source[sourceKey]; - } - } - } -} - -//----------------------------------------------------------------------------- -// Main -//----------------------------------------------------------------------------- - -/** - * Represents an object validation/merging schema. - */ -class ObjectSchema { - /** - * Track all definitions in the schema by key. - * @type {Map} - */ - #definitions = new Map(); - - /** - * Separately track any keys that are required for faster validtion. - * @type {Map} - */ - #requiredKeys = new Map(); - - /** - * Creates a new instance. - * @param {ObjectDefinition} definitions The schema definitions. - */ - constructor(definitions) { - if (!definitions) { - throw new Error("Schema definitions missing."); - } - - // add in all strategies - for (const key of Object.keys(definitions)) { - validateDefinition(key, definitions[key]); - - // normalize merge and validate methods if subschema is present - if (typeof definitions[key].schema === "object") { - const schema = new ObjectSchema(definitions[key].schema); - definitions[key] = { - ...definitions[key], - merge(first = {}, second = {}) { - return schema.merge(first, second); - }, - validate(value) { - ValidationStrategy.object(value); - schema.validate(value); - }, - }; - } - - // normalize the merge method in case there's a string - if (typeof definitions[key].merge === "string") { - definitions[key] = { - ...definitions[key], - merge: MergeStrategy[ - /** @type {string} */ (definitions[key].merge) - ], - }; - } - - // normalize the validate method in case there's a string - if (typeof definitions[key].validate === "string") { - definitions[key] = { - ...definitions[key], - validate: - ValidationStrategy[ - /** @type {string} */ (definitions[key].validate) - ], - }; - } - - this.#definitions.set(key, definitions[key]); - - if (definitions[key].required) { - this.#requiredKeys.set(key, definitions[key]); - } - } - } - - /** - * Determines if a strategy has been registered for the given object key. - * @param {string} key The object key to find a strategy for. - * @returns {boolean} True if the key has a strategy registered, false if not. - */ - hasKey(key) { - return this.#definitions.has(key); - } - - /** - * Merges objects together to create a new object comprised of the keys - * of the all objects. Keys are merged based on the each key's merge - * strategy. - * @param {...Object} objects The objects to merge. - * @returns {Object} A new object with a mix of all objects' keys. - * @throws {Error} If any object is invalid. - */ - merge(...objects) { - // double check arguments - if (objects.length < 2) { - throw new TypeError("merge() requires at least two arguments."); - } - - if ( - objects.some( - object => object === null || typeof object !== "object", - ) - ) { - throw new TypeError("All arguments must be objects."); - } - - return objects.reduce((result, object) => { - this.validate(object); - - for (const [key, strategy] of this.#definitions) { - try { - if (key in result || key in object) { - const merge = /** @type {Function} */ (strategy.merge); - const value = merge.call( - this, - result[key], - object[key], - ); - if (value !== undefined) { - result[key] = value; - } - } - } catch (ex) { - throw new WrapperError(key, ex); - } - } - return result; - }, {}); - } - - /** - * Validates an object's keys based on the validate strategy for each key. - * @param {Object} object The object to validate. - * @returns {void} - * @throws {Error} When the object is invalid. - */ - validate(object) { - // check existing keys first - for (const key of Object.keys(object)) { - // check to see if the key is defined - if (!this.hasKey(key)) { - throw new UnexpectedKeyError(key); - } - - // validate existing keys - const definition = this.#definitions.get(key); - - // first check to see if any other keys are required - if (Array.isArray(definition.requires)) { - if ( - !definition.requires.every(otherKey => otherKey in object) - ) { - throw new MissingDependentKeysError( - key, - definition.requires, - ); - } - } - - // now apply remaining validation strategy - try { - const validate = /** @type {Function} */ (definition.validate); - validate.call(definition, object[key]); - } catch (ex) { - throw new WrapperError(key, ex); - } - } - - // ensure required keys aren't missing - for (const [key] of this.#requiredKeys) { - if (!(key in object)) { - throw new MissingKeyError(key); - } - } - } -} - -exports.MergeStrategy = MergeStrategy; -exports.ObjectSchema = ObjectSchema; -exports.ValidationStrategy = ValidationStrategy; diff --git a/tools/eslint/node_modules/@eslint/object-schema/dist/cjs/index.d.cts b/tools/eslint/node_modules/@eslint/object-schema/dist/cjs/index.d.cts deleted file mode 100644 index 0775e9a6128292..00000000000000 --- a/tools/eslint/node_modules/@eslint/object-schema/dist/cjs/index.d.cts +++ /dev/null @@ -1,123 +0,0 @@ -export type ObjectDefinition = import("./types.ts").ObjectDefinition; -export type PropertyDefinition = import("./types.ts").PropertyDefinition; -/** - * @fileoverview Merge Strategy - */ -/** - * Container class for several different merge strategies. - */ -export class MergeStrategy { - /** - * Merges two keys by overwriting the first with the second. - * @param {*} value1 The value from the first object key. - * @param {*} value2 The value from the second object key. - * @returns {*} The second value. - */ - static overwrite(value1: any, value2: any): any; - /** - * Merges two keys by replacing the first with the second only if the - * second is defined. - * @param {*} value1 The value from the first object key. - * @param {*} value2 The value from the second object key. - * @returns {*} The second value if it is defined. - */ - static replace(value1: any, value2: any): any; - /** - * Merges two properties by assigning properties from the second to the first. - * @param {*} value1 The value from the first object key. - * @param {*} value2 The value from the second object key. - * @returns {*} A new object containing properties from both value1 and - * value2. - */ - static assign(value1: any, value2: any): any; -} -/** - * Represents an object validation/merging schema. - */ -export class ObjectSchema { - /** - * Creates a new instance. - * @param {ObjectDefinition} definitions The schema definitions. - */ - constructor(definitions: ObjectDefinition); - /** - * Determines if a strategy has been registered for the given object key. - * @param {string} key The object key to find a strategy for. - * @returns {boolean} True if the key has a strategy registered, false if not. - */ - hasKey(key: string): boolean; - /** - * Merges objects together to create a new object comprised of the keys - * of the all objects. Keys are merged based on the each key's merge - * strategy. - * @param {...Object} objects The objects to merge. - * @returns {Object} A new object with a mix of all objects' keys. - * @throws {Error} If any object is invalid. - */ - merge(...objects: any[]): any; - /** - * Validates an object's keys based on the validate strategy for each key. - * @param {Object} object The object to validate. - * @returns {void} - * @throws {Error} When the object is invalid. - */ - validate(object: any): void; - #private; -} -/** - * @fileoverview Validation Strategy - */ -/** - * Container class for several different validation strategies. - */ -export class ValidationStrategy { - /** - * Validates that a value is an array. - * @param {*} value The value to validate. - * @returns {void} - * @throws {TypeError} If the value is invalid. - */ - static array(value: any): void; - /** - * Validates that a value is a boolean. - * @param {*} value The value to validate. - * @returns {void} - * @throws {TypeError} If the value is invalid. - */ - static boolean(value: any): void; - /** - * Validates that a value is a number. - * @param {*} value The value to validate. - * @returns {void} - * @throws {TypeError} If the value is invalid. - */ - static number(value: any): void; - /** - * Validates that a value is a object. - * @param {*} value The value to validate. - * @returns {void} - * @throws {TypeError} If the value is invalid. - */ - static object(value: any): void; - /** - * Validates that a value is a object or null. - * @param {*} value The value to validate. - * @returns {void} - * @throws {TypeError} If the value is invalid. - */ - static "object?"(value: any): void; - /** - * Validates that a value is a string. - * @param {*} value The value to validate. - * @returns {void} - * @throws {TypeError} If the value is invalid. - */ - static string(value: any): void; - /** - * Validates that a value is a non-empty string. - * @param {*} value The value to validate. - * @returns {void} - * @throws {TypeError} If the value is invalid. - */ - static "string!"(value: any): void; -} diff --git a/tools/eslint/node_modules/@eslint/object-schema/dist/esm/index.js b/tools/eslint/node_modules/@eslint/object-schema/dist/esm/index.js deleted file mode 100644 index 2e7bcd425b1492..00000000000000 --- a/tools/eslint/node_modules/@eslint/object-schema/dist/esm/index.js +++ /dev/null @@ -1,452 +0,0 @@ -// @ts-self-types="./index.d.ts" -/** - * @fileoverview Merge Strategy - */ - -//----------------------------------------------------------------------------- -// Class -//----------------------------------------------------------------------------- - -/** - * Container class for several different merge strategies. - */ -class MergeStrategy { - /** - * Merges two keys by overwriting the first with the second. - * @param {*} value1 The value from the first object key. - * @param {*} value2 The value from the second object key. - * @returns {*} The second value. - */ - static overwrite(value1, value2) { - return value2; - } - - /** - * Merges two keys by replacing the first with the second only if the - * second is defined. - * @param {*} value1 The value from the first object key. - * @param {*} value2 The value from the second object key. - * @returns {*} The second value if it is defined. - */ - static replace(value1, value2) { - if (typeof value2 !== "undefined") { - return value2; - } - - return value1; - } - - /** - * Merges two properties by assigning properties from the second to the first. - * @param {*} value1 The value from the first object key. - * @param {*} value2 The value from the second object key. - * @returns {*} A new object containing properties from both value1 and - * value2. - */ - static assign(value1, value2) { - return Object.assign({}, value1, value2); - } -} - -/** - * @fileoverview Validation Strategy - */ - -//----------------------------------------------------------------------------- -// Class -//----------------------------------------------------------------------------- - -/** - * Container class for several different validation strategies. - */ -class ValidationStrategy { - /** - * Validates that a value is an array. - * @param {*} value The value to validate. - * @returns {void} - * @throws {TypeError} If the value is invalid. - */ - static array(value) { - if (!Array.isArray(value)) { - throw new TypeError("Expected an array."); - } - } - - /** - * Validates that a value is a boolean. - * @param {*} value The value to validate. - * @returns {void} - * @throws {TypeError} If the value is invalid. - */ - static boolean(value) { - if (typeof value !== "boolean") { - throw new TypeError("Expected a Boolean."); - } - } - - /** - * Validates that a value is a number. - * @param {*} value The value to validate. - * @returns {void} - * @throws {TypeError} If the value is invalid. - */ - static number(value) { - if (typeof value !== "number") { - throw new TypeError("Expected a number."); - } - } - - /** - * Validates that a value is a object. - * @param {*} value The value to validate. - * @returns {void} - * @throws {TypeError} If the value is invalid. - */ - static object(value) { - if (!value || typeof value !== "object") { - throw new TypeError("Expected an object."); - } - } - - /** - * Validates that a value is a object or null. - * @param {*} value The value to validate. - * @returns {void} - * @throws {TypeError} If the value is invalid. - */ - static "object?"(value) { - if (typeof value !== "object") { - throw new TypeError("Expected an object or null."); - } - } - - /** - * Validates that a value is a string. - * @param {*} value The value to validate. - * @returns {void} - * @throws {TypeError} If the value is invalid. - */ - static string(value) { - if (typeof value !== "string") { - throw new TypeError("Expected a string."); - } - } - - /** - * Validates that a value is a non-empty string. - * @param {*} value The value to validate. - * @returns {void} - * @throws {TypeError} If the value is invalid. - */ - static "string!"(value) { - if (typeof value !== "string" || value.length === 0) { - throw new TypeError("Expected a non-empty string."); - } - } -} - -/** - * @fileoverview Object Schema - */ - - -//----------------------------------------------------------------------------- -// Types -//----------------------------------------------------------------------------- - -/** @typedef {import("./types.ts").ObjectDefinition} ObjectDefinition */ -/** @typedef {import("./types.ts").PropertyDefinition} PropertyDefinition */ - -//----------------------------------------------------------------------------- -// Private -//----------------------------------------------------------------------------- - -/** - * Validates a schema strategy. - * @param {string} name The name of the key this strategy is for. - * @param {PropertyDefinition} definition The strategy for the object key. - * @returns {void} - * @throws {Error} When the strategy is missing a name. - * @throws {Error} When the strategy is missing a merge() method. - * @throws {Error} When the strategy is missing a validate() method. - */ -function validateDefinition(name, definition) { - let hasSchema = false; - if (definition.schema) { - if (typeof definition.schema === "object") { - hasSchema = true; - } else { - throw new TypeError("Schema must be an object."); - } - } - - if (typeof definition.merge === "string") { - if (!(definition.merge in MergeStrategy)) { - throw new TypeError( - `Definition for key "${name}" missing valid merge strategy.`, - ); - } - } else if (!hasSchema && typeof definition.merge !== "function") { - throw new TypeError( - `Definition for key "${name}" must have a merge property.`, - ); - } - - if (typeof definition.validate === "string") { - if (!(definition.validate in ValidationStrategy)) { - throw new TypeError( - `Definition for key "${name}" missing valid validation strategy.`, - ); - } - } else if (!hasSchema && typeof definition.validate !== "function") { - throw new TypeError( - `Definition for key "${name}" must have a validate() method.`, - ); - } -} - -//----------------------------------------------------------------------------- -// Errors -//----------------------------------------------------------------------------- - -/** - * Error when an unexpected key is found. - */ -class UnexpectedKeyError extends Error { - /** - * Creates a new instance. - * @param {string} key The key that was unexpected. - */ - constructor(key) { - super(`Unexpected key "${key}" found.`); - } -} - -/** - * Error when a required key is missing. - */ -class MissingKeyError extends Error { - /** - * Creates a new instance. - * @param {string} key The key that was missing. - */ - constructor(key) { - super(`Missing required key "${key}".`); - } -} - -/** - * Error when a key requires other keys that are missing. - */ -class MissingDependentKeysError extends Error { - /** - * Creates a new instance. - * @param {string} key The key that was unexpected. - * @param {Array} requiredKeys The keys that are required. - */ - constructor(key, requiredKeys) { - super(`Key "${key}" requires keys "${requiredKeys.join('", "')}".`); - } -} - -/** - * Wrapper error for errors occuring during a merge or validate operation. - */ -class WrapperError extends Error { - /** - * Creates a new instance. - * @param {string} key The object key causing the error. - * @param {Error} source The source error. - */ - constructor(key, source) { - super(`Key "${key}": ${source.message}`, { cause: source }); - - // copy over custom properties that aren't represented - for (const sourceKey of Object.keys(source)) { - if (!(sourceKey in this)) { - this[sourceKey] = source[sourceKey]; - } - } - } -} - -//----------------------------------------------------------------------------- -// Main -//----------------------------------------------------------------------------- - -/** - * Represents an object validation/merging schema. - */ -class ObjectSchema { - /** - * Track all definitions in the schema by key. - * @type {Map} - */ - #definitions = new Map(); - - /** - * Separately track any keys that are required for faster validtion. - * @type {Map} - */ - #requiredKeys = new Map(); - - /** - * Creates a new instance. - * @param {ObjectDefinition} definitions The schema definitions. - */ - constructor(definitions) { - if (!definitions) { - throw new Error("Schema definitions missing."); - } - - // add in all strategies - for (const key of Object.keys(definitions)) { - validateDefinition(key, definitions[key]); - - // normalize merge and validate methods if subschema is present - if (typeof definitions[key].schema === "object") { - const schema = new ObjectSchema(definitions[key].schema); - definitions[key] = { - ...definitions[key], - merge(first = {}, second = {}) { - return schema.merge(first, second); - }, - validate(value) { - ValidationStrategy.object(value); - schema.validate(value); - }, - }; - } - - // normalize the merge method in case there's a string - if (typeof definitions[key].merge === "string") { - definitions[key] = { - ...definitions[key], - merge: MergeStrategy[ - /** @type {string} */ (definitions[key].merge) - ], - }; - } - - // normalize the validate method in case there's a string - if (typeof definitions[key].validate === "string") { - definitions[key] = { - ...definitions[key], - validate: - ValidationStrategy[ - /** @type {string} */ (definitions[key].validate) - ], - }; - } - - this.#definitions.set(key, definitions[key]); - - if (definitions[key].required) { - this.#requiredKeys.set(key, definitions[key]); - } - } - } - - /** - * Determines if a strategy has been registered for the given object key. - * @param {string} key The object key to find a strategy for. - * @returns {boolean} True if the key has a strategy registered, false if not. - */ - hasKey(key) { - return this.#definitions.has(key); - } - - /** - * Merges objects together to create a new object comprised of the keys - * of the all objects. Keys are merged based on the each key's merge - * strategy. - * @param {...Object} objects The objects to merge. - * @returns {Object} A new object with a mix of all objects' keys. - * @throws {Error} If any object is invalid. - */ - merge(...objects) { - // double check arguments - if (objects.length < 2) { - throw new TypeError("merge() requires at least two arguments."); - } - - if ( - objects.some( - object => object === null || typeof object !== "object", - ) - ) { - throw new TypeError("All arguments must be objects."); - } - - return objects.reduce((result, object) => { - this.validate(object); - - for (const [key, strategy] of this.#definitions) { - try { - if (key in result || key in object) { - const merge = /** @type {Function} */ (strategy.merge); - const value = merge.call( - this, - result[key], - object[key], - ); - if (value !== undefined) { - result[key] = value; - } - } - } catch (ex) { - throw new WrapperError(key, ex); - } - } - return result; - }, {}); - } - - /** - * Validates an object's keys based on the validate strategy for each key. - * @param {Object} object The object to validate. - * @returns {void} - * @throws {Error} When the object is invalid. - */ - validate(object) { - // check existing keys first - for (const key of Object.keys(object)) { - // check to see if the key is defined - if (!this.hasKey(key)) { - throw new UnexpectedKeyError(key); - } - - // validate existing keys - const definition = this.#definitions.get(key); - - // first check to see if any other keys are required - if (Array.isArray(definition.requires)) { - if ( - !definition.requires.every(otherKey => otherKey in object) - ) { - throw new MissingDependentKeysError( - key, - definition.requires, - ); - } - } - - // now apply remaining validation strategy - try { - const validate = /** @type {Function} */ (definition.validate); - validate.call(definition, object[key]); - } catch (ex) { - throw new WrapperError(key, ex); - } - } - - // ensure required keys aren't missing - for (const [key] of this.#requiredKeys) { - if (!(key in object)) { - throw new MissingKeyError(key); - } - } - } -} - -export { MergeStrategy, ObjectSchema, ValidationStrategy }; diff --git a/tools/eslint/node_modules/@eslint/object-schema/package.json b/tools/eslint/node_modules/@eslint/object-schema/package.json deleted file mode 100644 index 2a09a765fadd0d..00000000000000 --- a/tools/eslint/node_modules/@eslint/object-schema/package.json +++ /dev/null @@ -1,60 +0,0 @@ -{ - "name": "@eslint/object-schema", - "version": "2.1.4", - "description": "An object schema merger/validator", - "type": "module", - "main": "dist/esm/index.js", - "types": "dist/esm/index.d.ts", - "exports": { - "require": { - "types": "./dist/cjs/index.d.cts", - "default": "./dist/cjs/index.cjs" - }, - "import": { - "types": "./dist/esm/index.d.ts", - "default": "./dist/esm/index.js" - } - }, - "files": [ - "dist" - ], - "publishConfig": { - "access": "public" - }, - "directories": { - "test": "tests" - }, - "scripts": { - "build:cts": "node -e \"fs.copyFileSync('dist/esm/index.d.ts', 'dist/cjs/index.d.cts')\"", - "build": "rollup -c && tsc -p tsconfig.esm.json && npm run build:cts", - "test:jsr": "npx jsr@latest publish --dry-run", - "test": "mocha tests/", - "test:coverage": "c8 npm test" - }, - "repository": { - "type": "git", - "url": "git+https://github.com/eslint/rewrite.git" - }, - "keywords": [ - "object", - "validation", - "schema", - "merge" - ], - "author": "Nicholas C. Zakas", - "license": "Apache-2.0", - "bugs": { - "url": "https://github.com/eslint/rewrite/issues" - }, - "homepage": "https://github.com/eslint/rewrite#readme", - "devDependencies": { - "c8": "^9.1.0", - "mocha": "^10.4.0", - "rollup": "^4.16.2", - "rollup-plugin-copy": "^3.5.0", - "typescript": "^5.4.5" - }, - "engines": { - "node": "^18.18.0 || ^20.9.0 || >=21.1.0" - } -} diff --git a/tools/eslint/node_modules/@humanwhocodes/module-importer/LICENSE b/tools/eslint/node_modules/@humanwhocodes/module-importer/LICENSE deleted file mode 100644 index 261eeb9e9f8b2b..00000000000000 --- a/tools/eslint/node_modules/@humanwhocodes/module-importer/LICENSE +++ /dev/null @@ -1,201 +0,0 @@ - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright [yyyy] [name of copyright owner] - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. diff --git a/tools/eslint/node_modules/@humanwhocodes/module-importer/dist/module-importer.cjs b/tools/eslint/node_modules/@humanwhocodes/module-importer/dist/module-importer.cjs deleted file mode 100644 index 779e0cf6f5cf61..00000000000000 --- a/tools/eslint/node_modules/@humanwhocodes/module-importer/dist/module-importer.cjs +++ /dev/null @@ -1,22 +0,0 @@ -'use strict'; - -Object.defineProperty(exports, '__esModule', { value: true }); - -var module$1 = require('module'); -var url = require('url'); -var path = require('path'); - -/** - * @fileoverview Universal module importer - */ - -//----------------------------------------------------------------------------- -// Helpers -//----------------------------------------------------------------------------- - -const __filename$1 = url.fileURLToPath((typeof document === 'undefined' ? new (require('u' + 'rl').URL)('file:' + __filename).href : (document.currentScript && document.currentScript.src || new URL('module-importer.cjs', document.baseURI).href))); -const __dirname$1 = path.dirname(__filename$1); -const require$1 = module$1.createRequire(__dirname$1 + "/"); -const { ModuleImporter } = require$1("./module-importer.cjs"); - -exports.ModuleImporter = ModuleImporter; diff --git a/tools/eslint/node_modules/@humanwhocodes/module-importer/dist/module-importer.d.cts b/tools/eslint/node_modules/@humanwhocodes/module-importer/dist/module-importer.d.cts deleted file mode 100644 index a1acbb6d38689d..00000000000000 --- a/tools/eslint/node_modules/@humanwhocodes/module-importer/dist/module-importer.d.cts +++ /dev/null @@ -1,27 +0,0 @@ -export class ModuleImporter { - /** - * Creates a new instance. - * @param {string} [cwd] The current working directory to resolve from. - */ - constructor(cwd?: string); - /** - * The base directory from which paths should be resolved. - * @type {string} - */ - cwd: string; - /** - * Resolves a module based on its name or location. - * @param {string} specifier Either an npm package name or - * relative file path. - * @returns {string|undefined} The location of the import. - * @throws {Error} If specifier cannot be located. - */ - resolve(specifier: string): string | undefined; - /** - * Imports a module based on its name or location. - * @param {string} specifier Either an npm package name or - * relative file path. - * @returns {Promise} The module's object. - */ - import(specifier: string): Promise; -} diff --git a/tools/eslint/node_modules/@humanwhocodes/module-importer/dist/module-importer.js b/tools/eslint/node_modules/@humanwhocodes/module-importer/dist/module-importer.js deleted file mode 100644 index 26e052da1f2b81..00000000000000 --- a/tools/eslint/node_modules/@humanwhocodes/module-importer/dist/module-importer.js +++ /dev/null @@ -1,18 +0,0 @@ -import { createRequire } from 'module'; -import { fileURLToPath } from 'url'; -import { dirname } from 'path'; - -/** - * @fileoverview Universal module importer - */ - -//----------------------------------------------------------------------------- -// Helpers -//----------------------------------------------------------------------------- - -const __filename = fileURLToPath(import.meta.url); -const __dirname = dirname(__filename); -const require = createRequire(__dirname + "/"); -const { ModuleImporter } = require("./module-importer.cjs"); - -export { ModuleImporter }; diff --git a/tools/eslint/node_modules/@humanwhocodes/module-importer/package.json b/tools/eslint/node_modules/@humanwhocodes/module-importer/package.json deleted file mode 100644 index 8ece071e94f384..00000000000000 --- a/tools/eslint/node_modules/@humanwhocodes/module-importer/package.json +++ /dev/null @@ -1,65 +0,0 @@ -{ - "name": "@humanwhocodes/module-importer", - "version": "1.0.1", - "description": "Universal module importer for Node.js", - "main": "src/module-importer.cjs", - "module": "src/module-importer.js", - "type": "module", - "types": "dist/module-importer.d.ts", - "exports": { - "require": "./src/module-importer.cjs", - "import": "./src/module-importer.js" - }, - "files": [ - "dist", - "src" - ], - "publishConfig": { - "access": "public" - }, - "gitHooks": { - "pre-commit": "lint-staged" - }, - "lint-staged": { - "*.js": [ - "eslint --fix" - ] - }, - "funding": { - "type": "github", - "url": "https://github.com/sponsors/nzakas" - }, - "scripts": { - "build": "rollup -c && tsc", - "prepare": "npm run build", - "lint": "eslint src/ tests/", - "test:unit": "c8 mocha tests/module-importer.test.js", - "test:build": "node tests/pkg.test.cjs && node tests/pkg.test.mjs", - "test": "npm run test:unit && npm run test:build" - }, - "repository": { - "type": "git", - "url": "git+https://github.com/humanwhocodes/module-importer.git" - }, - "keywords": [ - "modules", - "esm", - "commonjs" - ], - "engines": { - "node": ">=12.22" - }, - "author": "Nicholas C. Zaks", - "license": "Apache-2.0", - "devDependencies": { - "@types/node": "^18.7.6", - "c8": "7.12.0", - "chai": "4.3.6", - "eslint": "8.22.0", - "lint-staged": "13.0.3", - "mocha": "9.2.2", - "rollup": "2.78.0", - "typescript": "4.7.4", - "yorkie": "2.0.0" - } -} diff --git a/tools/eslint/node_modules/@humanwhocodes/module-importer/src/module-importer.cjs b/tools/eslint/node_modules/@humanwhocodes/module-importer/src/module-importer.cjs deleted file mode 100644 index 3efb095e11af65..00000000000000 --- a/tools/eslint/node_modules/@humanwhocodes/module-importer/src/module-importer.cjs +++ /dev/null @@ -1,81 +0,0 @@ -/** - * @fileoverview Universal module importer - */ - -//----------------------------------------------------------------------------- -// Imports -//----------------------------------------------------------------------------- - -const { createRequire } = require("module"); -const { pathToFileURL } = require("url"); - -//----------------------------------------------------------------------------- -// Helpers -//----------------------------------------------------------------------------- - -const SLASHES = new Set(["/", "\\"]); - -/** - * Normalizes directories to have a trailing slash. - * Resolve is pretty finicky -- if the directory name doesn't have - * a trailing slash then it tries to look in the parent directory. - * i.e., if the directory is "/usr/nzakas/foo" it will start the - * search in /usr/nzakas. However, if the directory is "/user/nzakas/foo/", - * then it will start the search in /user/nzakas/foo. - * @param {string} directory The directory to check. - * @returns {string} The normalized directory. - */ -function normalizeDirectory(directory) { - if (!SLASHES.has(directory[directory.length-1])) { - return directory + "/"; - } - - return directory; -} - -//----------------------------------------------------------------------------- -// Exports -//----------------------------------------------------------------------------- - -/** - * Class for importing both CommonJS and ESM modules in Node.js. - */ -exports.ModuleImporter = class ModuleImporter { - - /** - * Creates a new instance. - * @param {string} [cwd] The current working directory to resolve from. - */ - constructor(cwd = process.cwd()) { - - /** - * The base directory from which paths should be resolved. - * @type {string} - */ - this.cwd = normalizeDirectory(cwd); - } - - /** - * Resolves a module based on its name or location. - * @param {string} specifier Either an npm package name or - * relative file path. - * @returns {string|undefined} The location of the import. - * @throws {Error} If specifier cannot be located. - */ - resolve(specifier) { - const require = createRequire(this.cwd); - return require.resolve(specifier); - } - - /** - * Imports a module based on its name or location. - * @param {string} specifier Either an npm package name or - * relative file path. - * @returns {Promise} The module's object. - */ - import(specifier) { - const location = this.resolve(specifier); - return import(pathToFileURL(location).href); - } - -} diff --git a/tools/eslint/node_modules/@humanwhocodes/module-importer/src/module-importer.js b/tools/eslint/node_modules/@humanwhocodes/module-importer/src/module-importer.js deleted file mode 100644 index f5464e18deccb1..00000000000000 --- a/tools/eslint/node_modules/@humanwhocodes/module-importer/src/module-importer.js +++ /dev/null @@ -1,22 +0,0 @@ -/** - * @fileoverview Universal module importer - */ - -//----------------------------------------------------------------------------- -// Imports -//----------------------------------------------------------------------------- - -import { createRequire } from "module"; -import { fileURLToPath } from "url"; -import { dirname } from "path"; - -//----------------------------------------------------------------------------- -// Helpers -//----------------------------------------------------------------------------- - -const __filename = fileURLToPath(import.meta.url); -const __dirname = dirname(__filename); -const require = createRequire(__dirname + "/"); -const { ModuleImporter } = require("./module-importer.cjs"); - -export { ModuleImporter }; diff --git a/tools/eslint/node_modules/@humanwhocodes/retry/LICENSE b/tools/eslint/node_modules/@humanwhocodes/retry/LICENSE deleted file mode 100644 index 261eeb9e9f8b2b..00000000000000 --- a/tools/eslint/node_modules/@humanwhocodes/retry/LICENSE +++ /dev/null @@ -1,201 +0,0 @@ - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright [yyyy] [name of copyright owner] - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. diff --git a/tools/eslint/node_modules/@humanwhocodes/retry/dist/retrier.cjs b/tools/eslint/node_modules/@humanwhocodes/retry/dist/retrier.cjs deleted file mode 100644 index b14e608e6c0a8b..00000000000000 --- a/tools/eslint/node_modules/@humanwhocodes/retry/dist/retrier.cjs +++ /dev/null @@ -1,284 +0,0 @@ -'use strict'; - -/** - * @fileoverview A utility for retrying failed async method calls. - */ - -/* global setTimeout, clearTimeout */ - -//----------------------------------------------------------------------------- -// Constants -//----------------------------------------------------------------------------- - -const MAX_TASK_TIMEOUT = 60000; -const MAX_TASK_DELAY = 100; - -//----------------------------------------------------------------------------- -// Helpers -//----------------------------------------------------------------------------- - -/* - * The following logic has been extracted from graceful-fs. - * - * The ISC License - * - * Copyright (c) 2011-2023 Isaac Z. Schlueter, Ben Noordhuis, and Contributors - * - * Permission to use, copy, modify, and/or distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR - * IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -/** - * Checks if it is time to retry a task based on the timestamp and last attempt time. - * @param {RetryTask} task The task to check. - * @param {number} maxDelay The maximum delay for the queue. - * @returns {boolean} true if it is time to retry, false otherwise. - */ -function isTimeToRetry(task, maxDelay) { - const timeSinceLastAttempt = Date.now() - task.lastAttempt; - const timeSinceStart = Math.max(task.lastAttempt - task.timestamp, 1); - const desiredDelay = Math.min(timeSinceStart * 1.2, maxDelay); - - return timeSinceLastAttempt >= desiredDelay; -} - -/** - * Checks if it is time to bail out based on the given timestamp. - * @param {RetryTask} task The task to check. - * @param {number} timeout The timeout for the queue. - * @returns {boolean} true if it is time to bail, false otherwise. - */ -function isTimeToBail(task, timeout) { - return Date.now() - task.timestamp > timeout; -} - - -/** - * A class to represent a task in the retry queue. - */ -class RetryTask { - /** - * The function to call. - * @type {Function} - */ - fn; - - /** - * The error that was thrown. - * @type {Error} - */ - error; - - /** - * The timestamp of the task. - * @type {number} - */ - timestamp = Date.now(); - - /** - * The timestamp of the last attempt. - * @type {number} - */ - lastAttempt = this.timestamp; - - /** - * The resolve function for the promise. - * @type {Function} - */ - resolve; - - /** - * The reject function for the promise. - * @type {Function} - */ - reject; - - /** - * The AbortSignal to monitor for cancellation. - * @type {AbortSignal|undefined} - */ - signal; - - /** - * Creates a new instance. - * @param {Function} fn The function to call. - * @param {Error} error The error that was thrown. - * @param {Function} resolve The resolve function for the promise. - * @param {Function} reject The reject function for the promise. - * @param {AbortSignal|undefined} signal The AbortSignal to monitor for cancellation. - */ - constructor(fn, error, resolve, reject, signal) { - this.fn = fn; - this.error = error; - this.timestamp = Date.now(); - this.lastAttempt = Date.now(); - this.resolve = resolve; - this.reject = reject; - this.signal = signal; - } - -} - -//----------------------------------------------------------------------------- -// Exports -//----------------------------------------------------------------------------- - -/** - * A class that manages a queue of retry jobs. - */ -class Retrier { - /** - * Represents the queue for processing tasks. - * @type {Array} - */ - #queue = []; - - /** - * The timeout for the queue. - * @type {number} - */ - #timeout; - - /** - * The maximum delay for the queue. - * @type {number} - */ - #maxDelay; - - /** - * The setTimeout() timer ID. - * @type {NodeJS.Timeout|undefined} - */ - #timerId; - - /** - * The function to call. - * @type {Function} - */ - #check; - - /** - * Creates a new instance. - * @param {Function} check The function to call. - * @param {object} [options] The options for the instance. - * @param {number} [options.timeout] The timeout for the queue. - * @param {number} [options.maxDelay] The maximum delay for the queue. - */ - constructor(check, { timeout = MAX_TASK_TIMEOUT, maxDelay = MAX_TASK_DELAY } = {}) { - - if (typeof check !== "function") { - throw new Error("Missing function to check errors"); - } - - this.#check = check; - this.#timeout = timeout; - this.#maxDelay = maxDelay; - } - - /** - * Adds a new retry job to the queue. - * @param {Function} fn The function to call. - * @param {object} [options] The options for the job. - * @param {AbortSignal} [options.signal] The AbortSignal to monitor for cancellation. - * @returns {Promise} A promise that resolves when the queue is - * processed. - */ - retry(fn, { signal } = {}) { - - signal?.throwIfAborted(); - - let result; - - try { - result = fn(); - } catch (/** @type {any} */ error) { - return Promise.reject(new Error(`Synchronous error: ${error.message}`, { cause: error })); - } - - // if the result is not a promise then reject an error - if (!result || typeof result.then !== "function") { - return Promise.reject(new Error("Result is not a promise.")); - } - - // call the original function and catch any ENFILE or EMFILE errors - // @ts-ignore because we know it's any - return Promise.resolve(result).catch(error => { - if (!this.#check(error)) { - throw error; - } - - return new Promise((resolve, reject) => { - this.#queue.push(new RetryTask(fn, error, resolve, reject, signal)); - - signal?.addEventListener("abort", () => { - reject(signal.reason); - }); - - this.#processQueue(); - }); - }); - } - - /** - * Processes the queue. - * @returns {void} - */ - #processQueue() { - // clear any timer because we're going to check right now - clearTimeout(this.#timerId); - this.#timerId = undefined; - - // if there's nothing in the queue, we're done - const task = this.#queue.shift(); - if (!task) { - return; - } - - // if it's time to bail, then bail - if (isTimeToBail(task, this.#timeout)) { - task.reject(task.error); - this.#processQueue(); - return; - } - - // if it's not time to retry, then wait and try again - if (!isTimeToRetry(task, this.#maxDelay)) { - this.#queue.unshift(task); - this.#timerId = setTimeout(() => this.#processQueue(), 0); - return; - } - - // otherwise, try again - task.lastAttempt = Date.now(); - - // Promise.resolve needed in case it's a thenable but not a Promise - Promise.resolve(task.fn()) - // @ts-ignore because we know it's any - .then(result => task.resolve(result)) - - // @ts-ignore because we know it's any - .catch(error => { - if (!this.#check(error)) { - task.reject(error); - return; - } - - // update the task timestamp and push to back of queue to try again - task.lastAttempt = Date.now(); - this.#queue.push(task); - - }) - .finally(() => this.#processQueue()); - } -} - -exports.Retrier = Retrier; diff --git a/tools/eslint/node_modules/@humanwhocodes/retry/dist/retrier.d.cts b/tools/eslint/node_modules/@humanwhocodes/retry/dist/retrier.d.cts deleted file mode 100644 index f152965005fc61..00000000000000 --- a/tools/eslint/node_modules/@humanwhocodes/retry/dist/retrier.d.cts +++ /dev/null @@ -1,28 +0,0 @@ -/** - * A class that manages a queue of retry jobs. - */ -export class Retrier { - /** - * Creates a new instance. - * @param {Function} check The function to call. - * @param {object} [options] The options for the instance. - * @param {number} [options.timeout] The timeout for the queue. - * @param {number} [options.maxDelay] The maximum delay for the queue. - */ - constructor(check: Function, { timeout, maxDelay }?: { - timeout?: number | undefined; - maxDelay?: number | undefined; - } | undefined); - /** - * Adds a new retry job to the queue. - * @param {Function} fn The function to call. - * @param {object} [options] The options for the job. - * @param {AbortSignal} [options.signal] The AbortSignal to monitor for cancellation. - * @returns {Promise} A promise that resolves when the queue is - * processed. - */ - retry(fn: Function, { signal }?: { - signal?: AbortSignal | undefined; - } | undefined): Promise; - #private; -} diff --git a/tools/eslint/node_modules/@humanwhocodes/retry/dist/retrier.js b/tools/eslint/node_modules/@humanwhocodes/retry/dist/retrier.js deleted file mode 100644 index b16166d85d028f..00000000000000 --- a/tools/eslint/node_modules/@humanwhocodes/retry/dist/retrier.js +++ /dev/null @@ -1,283 +0,0 @@ -/// -/** - * @fileoverview A utility for retrying failed async method calls. - */ - -/* global setTimeout, clearTimeout */ - -//----------------------------------------------------------------------------- -// Constants -//----------------------------------------------------------------------------- - -const MAX_TASK_TIMEOUT = 60000; -const MAX_TASK_DELAY = 100; - -//----------------------------------------------------------------------------- -// Helpers -//----------------------------------------------------------------------------- - -/* - * The following logic has been extracted from graceful-fs. - * - * The ISC License - * - * Copyright (c) 2011-2023 Isaac Z. Schlueter, Ben Noordhuis, and Contributors - * - * Permission to use, copy, modify, and/or distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR - * IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -/** - * Checks if it is time to retry a task based on the timestamp and last attempt time. - * @param {RetryTask} task The task to check. - * @param {number} maxDelay The maximum delay for the queue. - * @returns {boolean} true if it is time to retry, false otherwise. - */ -function isTimeToRetry(task, maxDelay) { - const timeSinceLastAttempt = Date.now() - task.lastAttempt; - const timeSinceStart = Math.max(task.lastAttempt - task.timestamp, 1); - const desiredDelay = Math.min(timeSinceStart * 1.2, maxDelay); - - return timeSinceLastAttempt >= desiredDelay; -} - -/** - * Checks if it is time to bail out based on the given timestamp. - * @param {RetryTask} task The task to check. - * @param {number} timeout The timeout for the queue. - * @returns {boolean} true if it is time to bail, false otherwise. - */ -function isTimeToBail(task, timeout) { - return Date.now() - task.timestamp > timeout; -} - - -/** - * A class to represent a task in the retry queue. - */ -class RetryTask { - /** - * The function to call. - * @type {Function} - */ - fn; - - /** - * The error that was thrown. - * @type {Error} - */ - error; - - /** - * The timestamp of the task. - * @type {number} - */ - timestamp = Date.now(); - - /** - * The timestamp of the last attempt. - * @type {number} - */ - lastAttempt = this.timestamp; - - /** - * The resolve function for the promise. - * @type {Function} - */ - resolve; - - /** - * The reject function for the promise. - * @type {Function} - */ - reject; - - /** - * The AbortSignal to monitor for cancellation. - * @type {AbortSignal|undefined} - */ - signal; - - /** - * Creates a new instance. - * @param {Function} fn The function to call. - * @param {Error} error The error that was thrown. - * @param {Function} resolve The resolve function for the promise. - * @param {Function} reject The reject function for the promise. - * @param {AbortSignal|undefined} signal The AbortSignal to monitor for cancellation. - */ - constructor(fn, error, resolve, reject, signal) { - this.fn = fn; - this.error = error; - this.timestamp = Date.now(); - this.lastAttempt = Date.now(); - this.resolve = resolve; - this.reject = reject; - this.signal = signal; - } - -} - -//----------------------------------------------------------------------------- -// Exports -//----------------------------------------------------------------------------- - -/** - * A class that manages a queue of retry jobs. - */ -class Retrier { - /** - * Represents the queue for processing tasks. - * @type {Array} - */ - #queue = []; - - /** - * The timeout for the queue. - * @type {number} - */ - #timeout; - - /** - * The maximum delay for the queue. - * @type {number} - */ - #maxDelay; - - /** - * The setTimeout() timer ID. - * @type {NodeJS.Timeout|undefined} - */ - #timerId; - - /** - * The function to call. - * @type {Function} - */ - #check; - - /** - * Creates a new instance. - * @param {Function} check The function to call. - * @param {object} [options] The options for the instance. - * @param {number} [options.timeout] The timeout for the queue. - * @param {number} [options.maxDelay] The maximum delay for the queue. - */ - constructor(check, { timeout = MAX_TASK_TIMEOUT, maxDelay = MAX_TASK_DELAY } = {}) { - - if (typeof check !== "function") { - throw new Error("Missing function to check errors"); - } - - this.#check = check; - this.#timeout = timeout; - this.#maxDelay = maxDelay; - } - - /** - * Adds a new retry job to the queue. - * @param {Function} fn The function to call. - * @param {object} [options] The options for the job. - * @param {AbortSignal} [options.signal] The AbortSignal to monitor for cancellation. - * @returns {Promise} A promise that resolves when the queue is - * processed. - */ - retry(fn, { signal } = {}) { - - signal?.throwIfAborted(); - - let result; - - try { - result = fn(); - } catch (/** @type {any} */ error) { - return Promise.reject(new Error(`Synchronous error: ${error.message}`, { cause: error })); - } - - // if the result is not a promise then reject an error - if (!result || typeof result.then !== "function") { - return Promise.reject(new Error("Result is not a promise.")); - } - - // call the original function and catch any ENFILE or EMFILE errors - // @ts-ignore because we know it's any - return Promise.resolve(result).catch(error => { - if (!this.#check(error)) { - throw error; - } - - return new Promise((resolve, reject) => { - this.#queue.push(new RetryTask(fn, error, resolve, reject, signal)); - - signal?.addEventListener("abort", () => { - reject(signal.reason); - }); - - this.#processQueue(); - }); - }); - } - - /** - * Processes the queue. - * @returns {void} - */ - #processQueue() { - // clear any timer because we're going to check right now - clearTimeout(this.#timerId); - this.#timerId = undefined; - - // if there's nothing in the queue, we're done - const task = this.#queue.shift(); - if (!task) { - return; - } - - // if it's time to bail, then bail - if (isTimeToBail(task, this.#timeout)) { - task.reject(task.error); - this.#processQueue(); - return; - } - - // if it's not time to retry, then wait and try again - if (!isTimeToRetry(task, this.#maxDelay)) { - this.#queue.unshift(task); - this.#timerId = setTimeout(() => this.#processQueue(), 0); - return; - } - - // otherwise, try again - task.lastAttempt = Date.now(); - - // Promise.resolve needed in case it's a thenable but not a Promise - Promise.resolve(task.fn()) - // @ts-ignore because we know it's any - .then(result => task.resolve(result)) - - // @ts-ignore because we know it's any - .catch(error => { - if (!this.#check(error)) { - task.reject(error); - return; - } - - // update the task timestamp and push to back of queue to try again - task.lastAttempt = Date.now(); - this.#queue.push(task); - - }) - .finally(() => this.#processQueue()); - } -} - -export { Retrier }; diff --git a/tools/eslint/node_modules/@humanwhocodes/retry/dist/retrier.min.js b/tools/eslint/node_modules/@humanwhocodes/retry/dist/retrier.min.js deleted file mode 100644 index ad730c01b1bc81..00000000000000 --- a/tools/eslint/node_modules/@humanwhocodes/retry/dist/retrier.min.js +++ /dev/null @@ -1 +0,0 @@ -class RetryTask{fn;error;timestamp=Date.now();lastAttempt=this.timestamp;resolve;reject;signal;constructor(t,e,r,s,i){this.fn=t,this.error=e,this.timestamp=Date.now(),this.lastAttempt=Date.now(),this.resolve=r,this.reject=s,this.signal=i}}class Retrier{#t=[];#e;#r;#s;#i;constructor(t,{timeout:e=6e4,maxDelay:r=100}={}){if("function"!=typeof t)throw new Error("Missing function to check errors");this.#i=t,this.#e=e,this.#r=r}retry(t,{signal:e}={}){let r;e?.throwIfAborted();try{r=t()}catch(t){return Promise.reject(new Error(`Synchronous error: ${t.message}`,{cause:t}))}return r&&"function"==typeof r.then?Promise.resolve(r).catch((r=>{if(!this.#i(r))throw r;return new Promise(((s,i)=>{this.#t.push(new RetryTask(t,r,s,i,e)),e?.addEventListener("abort",(()=>{i(e.reason)})),this.#o()}))})):Promise.reject(new Error("Result is not a promise."))}#o(){clearTimeout(this.#s),this.#s=void 0;const t=this.#t.shift();if(t){if(function(t,e){return Date.now()-t.timestamp>e}(t,this.#e))return t.reject(t.error),void this.#o();if(!function(t,e){const r=Date.now()-t.lastAttempt,s=Math.max(t.lastAttempt-t.timestamp,1);return r>=Math.min(1.2*s,e)}(t,this.#r))return this.#t.unshift(t),void(this.#s=setTimeout((()=>this.#o()),0));t.lastAttempt=Date.now(),Promise.resolve(t.fn()).then((e=>t.resolve(e))).catch((e=>{this.#i(e)?(t.lastAttempt=Date.now(),this.#t.push(t)):t.reject(e)})).finally((()=>this.#o()))}}}export{Retrier}; diff --git a/tools/eslint/node_modules/@humanwhocodes/retry/dist/retrier.mjs b/tools/eslint/node_modules/@humanwhocodes/retry/dist/retrier.mjs deleted file mode 100644 index 26eb4d318b58a1..00000000000000 --- a/tools/eslint/node_modules/@humanwhocodes/retry/dist/retrier.mjs +++ /dev/null @@ -1,282 +0,0 @@ -/** - * @fileoverview A utility for retrying failed async method calls. - */ - -/* global setTimeout, clearTimeout */ - -//----------------------------------------------------------------------------- -// Constants -//----------------------------------------------------------------------------- - -const MAX_TASK_TIMEOUT = 60000; -const MAX_TASK_DELAY = 100; - -//----------------------------------------------------------------------------- -// Helpers -//----------------------------------------------------------------------------- - -/* - * The following logic has been extracted from graceful-fs. - * - * The ISC License - * - * Copyright (c) 2011-2023 Isaac Z. Schlueter, Ben Noordhuis, and Contributors - * - * Permission to use, copy, modify, and/or distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR - * IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -/** - * Checks if it is time to retry a task based on the timestamp and last attempt time. - * @param {RetryTask} task The task to check. - * @param {number} maxDelay The maximum delay for the queue. - * @returns {boolean} true if it is time to retry, false otherwise. - */ -function isTimeToRetry(task, maxDelay) { - const timeSinceLastAttempt = Date.now() - task.lastAttempt; - const timeSinceStart = Math.max(task.lastAttempt - task.timestamp, 1); - const desiredDelay = Math.min(timeSinceStart * 1.2, maxDelay); - - return timeSinceLastAttempt >= desiredDelay; -} - -/** - * Checks if it is time to bail out based on the given timestamp. - * @param {RetryTask} task The task to check. - * @param {number} timeout The timeout for the queue. - * @returns {boolean} true if it is time to bail, false otherwise. - */ -function isTimeToBail(task, timeout) { - return Date.now() - task.timestamp > timeout; -} - - -/** - * A class to represent a task in the retry queue. - */ -class RetryTask { - /** - * The function to call. - * @type {Function} - */ - fn; - - /** - * The error that was thrown. - * @type {Error} - */ - error; - - /** - * The timestamp of the task. - * @type {number} - */ - timestamp = Date.now(); - - /** - * The timestamp of the last attempt. - * @type {number} - */ - lastAttempt = this.timestamp; - - /** - * The resolve function for the promise. - * @type {Function} - */ - resolve; - - /** - * The reject function for the promise. - * @type {Function} - */ - reject; - - /** - * The AbortSignal to monitor for cancellation. - * @type {AbortSignal|undefined} - */ - signal; - - /** - * Creates a new instance. - * @param {Function} fn The function to call. - * @param {Error} error The error that was thrown. - * @param {Function} resolve The resolve function for the promise. - * @param {Function} reject The reject function for the promise. - * @param {AbortSignal|undefined} signal The AbortSignal to monitor for cancellation. - */ - constructor(fn, error, resolve, reject, signal) { - this.fn = fn; - this.error = error; - this.timestamp = Date.now(); - this.lastAttempt = Date.now(); - this.resolve = resolve; - this.reject = reject; - this.signal = signal; - } - -} - -//----------------------------------------------------------------------------- -// Exports -//----------------------------------------------------------------------------- - -/** - * A class that manages a queue of retry jobs. - */ -class Retrier { - /** - * Represents the queue for processing tasks. - * @type {Array} - */ - #queue = []; - - /** - * The timeout for the queue. - * @type {number} - */ - #timeout; - - /** - * The maximum delay for the queue. - * @type {number} - */ - #maxDelay; - - /** - * The setTimeout() timer ID. - * @type {NodeJS.Timeout|undefined} - */ - #timerId; - - /** - * The function to call. - * @type {Function} - */ - #check; - - /** - * Creates a new instance. - * @param {Function} check The function to call. - * @param {object} [options] The options for the instance. - * @param {number} [options.timeout] The timeout for the queue. - * @param {number} [options.maxDelay] The maximum delay for the queue. - */ - constructor(check, { timeout = MAX_TASK_TIMEOUT, maxDelay = MAX_TASK_DELAY } = {}) { - - if (typeof check !== "function") { - throw new Error("Missing function to check errors"); - } - - this.#check = check; - this.#timeout = timeout; - this.#maxDelay = maxDelay; - } - - /** - * Adds a new retry job to the queue. - * @param {Function} fn The function to call. - * @param {object} [options] The options for the job. - * @param {AbortSignal} [options.signal] The AbortSignal to monitor for cancellation. - * @returns {Promise} A promise that resolves when the queue is - * processed. - */ - retry(fn, { signal } = {}) { - - signal?.throwIfAborted(); - - let result; - - try { - result = fn(); - } catch (/** @type {any} */ error) { - return Promise.reject(new Error(`Synchronous error: ${error.message}`, { cause: error })); - } - - // if the result is not a promise then reject an error - if (!result || typeof result.then !== "function") { - return Promise.reject(new Error("Result is not a promise.")); - } - - // call the original function and catch any ENFILE or EMFILE errors - // @ts-ignore because we know it's any - return Promise.resolve(result).catch(error => { - if (!this.#check(error)) { - throw error; - } - - return new Promise((resolve, reject) => { - this.#queue.push(new RetryTask(fn, error, resolve, reject, signal)); - - signal?.addEventListener("abort", () => { - reject(signal.reason); - }); - - this.#processQueue(); - }); - }); - } - - /** - * Processes the queue. - * @returns {void} - */ - #processQueue() { - // clear any timer because we're going to check right now - clearTimeout(this.#timerId); - this.#timerId = undefined; - - // if there's nothing in the queue, we're done - const task = this.#queue.shift(); - if (!task) { - return; - } - - // if it's time to bail, then bail - if (isTimeToBail(task, this.#timeout)) { - task.reject(task.error); - this.#processQueue(); - return; - } - - // if it's not time to retry, then wait and try again - if (!isTimeToRetry(task, this.#maxDelay)) { - this.#queue.unshift(task); - this.#timerId = setTimeout(() => this.#processQueue(), 0); - return; - } - - // otherwise, try again - task.lastAttempt = Date.now(); - - // Promise.resolve needed in case it's a thenable but not a Promise - Promise.resolve(task.fn()) - // @ts-ignore because we know it's any - .then(result => task.resolve(result)) - - // @ts-ignore because we know it's any - .catch(error => { - if (!this.#check(error)) { - task.reject(error); - return; - } - - // update the task timestamp and push to back of queue to try again - task.lastAttempt = Date.now(); - this.#queue.push(task); - - }) - .finally(() => this.#processQueue()); - } -} - -export { Retrier }; diff --git a/tools/eslint/node_modules/@humanwhocodes/retry/package.json b/tools/eslint/node_modules/@humanwhocodes/retry/package.json deleted file mode 100644 index f5272be0cdd959..00000000000000 --- a/tools/eslint/node_modules/@humanwhocodes/retry/package.json +++ /dev/null @@ -1,76 +0,0 @@ -{ - "name": "@humanwhocodes/retry", - "version": "0.3.0", - "description": "A utility to retry failed async methods.", - "type": "module", - "main": "dist/retrier.cjs", - "module": "dist/retrier.js", - "types": "dist/retrier.d.ts", - "exports": { - "require": { - "types": "./dist/retrier.d.cts", - "default": "./dist/retrier.cjs" - }, - "import": { - "types": "./dist/retrier.d.ts", - "default": "./dist/retrier.js" - } - }, - "files": [ - "dist" - ], - "engines": { - "node": ">=18.18" - }, - "publishConfig": { - "access": "public" - }, - "gitHooks": { - "pre-commit": "lint-staged" - }, - "lint-staged": { - "*.js": [ - "eslint --fix" - ] - }, - "funding": { - "type": "github", - "url": "https://github.com/sponsors/nzakas" - }, - "scripts": { - "build:cts-types": "node -e \"fs.copyFileSync('dist/retrier.d.ts', 'dist/retrier.d.cts')\"", - "build:prepend-type-ref": "node tools/prepend-type-ref.js dist/retrier.js", - "build": "rollup -c && tsc && npm run build:prepend-type-ref && npm run build:cts-types", - "prepare": "npm run build", - "lint": "eslint src/ tests/", - "pretest": "npm run build", - "test:unit": "mocha tests/retrier.test.js", - "test:build": "node tests/pkg.test.cjs && node tests/pkg.test.mjs", - "test": "npm run test:unit && npm run test:build" - }, - "repository": { - "type": "git", - "url": "git+https://github.com/humanwhocodes/retrier.git" - }, - "keywords": [ - "nodejs", - "retry", - "async", - "promises" - ], - "author": "Nicholas C. Zaks", - "license": "Apache-2.0", - "devDependencies": { - "@eslint/js": "^8.49.0", - "@rollup/plugin-terser": "0.4.4", - "@tsconfig/node16": "^16.1.1", - "@types/mocha": "^10.0.3", - "@types/node": "20.12.6", - "eslint": "^8.21.0", - "lint-staged": "15.2.1", - "mocha": "^10.3.0", - "rollup": "3.29.4", - "typescript": "5.4.4", - "yorkie": "2.0.0" - } -} diff --git a/tools/eslint/node_modules/@jridgewell/gen-mapping/LICENSE b/tools/eslint/node_modules/@jridgewell/gen-mapping/LICENSE deleted file mode 100644 index 352f0715f391f0..00000000000000 --- a/tools/eslint/node_modules/@jridgewell/gen-mapping/LICENSE +++ /dev/null @@ -1,19 +0,0 @@ -Copyright 2022 Justin Ridgewell - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. diff --git a/tools/eslint/node_modules/@jridgewell/gen-mapping/dist/gen-mapping.mjs b/tools/eslint/node_modules/@jridgewell/gen-mapping/dist/gen-mapping.mjs deleted file mode 100644 index 5d38e38380ed49..00000000000000 --- a/tools/eslint/node_modules/@jridgewell/gen-mapping/dist/gen-mapping.mjs +++ /dev/null @@ -1,230 +0,0 @@ -import { SetArray, put, remove } from '@jridgewell/set-array'; -import { encode } from '@jridgewell/sourcemap-codec'; -import { TraceMap, decodedMappings } from '@jridgewell/trace-mapping'; - -const COLUMN = 0; -const SOURCES_INDEX = 1; -const SOURCE_LINE = 2; -const SOURCE_COLUMN = 3; -const NAMES_INDEX = 4; - -const NO_NAME = -1; -/** - * Provides the state to generate a sourcemap. - */ -class GenMapping { - constructor({ file, sourceRoot } = {}) { - this._names = new SetArray(); - this._sources = new SetArray(); - this._sourcesContent = []; - this._mappings = []; - this.file = file; - this.sourceRoot = sourceRoot; - this._ignoreList = new SetArray(); - } -} -/** - * Typescript doesn't allow friend access to private fields, so this just casts the map into a type - * with public access modifiers. - */ -function cast(map) { - return map; -} -function addSegment(map, genLine, genColumn, source, sourceLine, sourceColumn, name, content) { - return addSegmentInternal(false, map, genLine, genColumn, source, sourceLine, sourceColumn, name, content); -} -function addMapping(map, mapping) { - return addMappingInternal(false, map, mapping); -} -/** - * Same as `addSegment`, but will only add the segment if it generates useful information in the - * resulting map. This only works correctly if segments are added **in order**, meaning you should - * not add a segment with a lower generated line/column than one that came before. - */ -const maybeAddSegment = (map, genLine, genColumn, source, sourceLine, sourceColumn, name, content) => { - return addSegmentInternal(true, map, genLine, genColumn, source, sourceLine, sourceColumn, name, content); -}; -/** - * Same as `addMapping`, but will only add the mapping if it generates useful information in the - * resulting map. This only works correctly if mappings are added **in order**, meaning you should - * not add a mapping with a lower generated line/column than one that came before. - */ -const maybeAddMapping = (map, mapping) => { - return addMappingInternal(true, map, mapping); -}; -/** - * Adds/removes the content of the source file to the source map. - */ -function setSourceContent(map, source, content) { - const { _sources: sources, _sourcesContent: sourcesContent } = cast(map); - const index = put(sources, source); - sourcesContent[index] = content; -} -function setIgnore(map, source, ignore = true) { - const { _sources: sources, _sourcesContent: sourcesContent, _ignoreList: ignoreList } = cast(map); - const index = put(sources, source); - if (index === sourcesContent.length) - sourcesContent[index] = null; - if (ignore) - put(ignoreList, index); - else - remove(ignoreList, index); -} -/** - * Returns a sourcemap object (with decoded mappings) suitable for passing to a library that expects - * a sourcemap, or to JSON.stringify. - */ -function toDecodedMap(map) { - const { _mappings: mappings, _sources: sources, _sourcesContent: sourcesContent, _names: names, _ignoreList: ignoreList, } = cast(map); - removeEmptyFinalLines(mappings); - return { - version: 3, - file: map.file || undefined, - names: names.array, - sourceRoot: map.sourceRoot || undefined, - sources: sources.array, - sourcesContent, - mappings, - ignoreList: ignoreList.array, - }; -} -/** - * Returns a sourcemap object (with encoded mappings) suitable for passing to a library that expects - * a sourcemap, or to JSON.stringify. - */ -function toEncodedMap(map) { - const decoded = toDecodedMap(map); - return Object.assign(Object.assign({}, decoded), { mappings: encode(decoded.mappings) }); -} -/** - * Constructs a new GenMapping, using the already present mappings of the input. - */ -function fromMap(input) { - const map = new TraceMap(input); - const gen = new GenMapping({ file: map.file, sourceRoot: map.sourceRoot }); - putAll(cast(gen)._names, map.names); - putAll(cast(gen)._sources, map.sources); - cast(gen)._sourcesContent = map.sourcesContent || map.sources.map(() => null); - cast(gen)._mappings = decodedMappings(map); - if (map.ignoreList) - putAll(cast(gen)._ignoreList, map.ignoreList); - return gen; -} -/** - * Returns an array of high-level mapping objects for every recorded segment, which could then be - * passed to the `source-map` library. - */ -function allMappings(map) { - const out = []; - const { _mappings: mappings, _sources: sources, _names: names } = cast(map); - for (let i = 0; i < mappings.length; i++) { - const line = mappings[i]; - for (let j = 0; j < line.length; j++) { - const seg = line[j]; - const generated = { line: i + 1, column: seg[COLUMN] }; - let source = undefined; - let original = undefined; - let name = undefined; - if (seg.length !== 1) { - source = sources.array[seg[SOURCES_INDEX]]; - original = { line: seg[SOURCE_LINE] + 1, column: seg[SOURCE_COLUMN] }; - if (seg.length === 5) - name = names.array[seg[NAMES_INDEX]]; - } - out.push({ generated, source, original, name }); - } - } - return out; -} -// This split declaration is only so that terser can elminiate the static initialization block. -function addSegmentInternal(skipable, map, genLine, genColumn, source, sourceLine, sourceColumn, name, content) { - const { _mappings: mappings, _sources: sources, _sourcesContent: sourcesContent, _names: names, } = cast(map); - const line = getLine(mappings, genLine); - const index = getColumnIndex(line, genColumn); - if (!source) { - if (skipable && skipSourceless(line, index)) - return; - return insert(line, index, [genColumn]); - } - const sourcesIndex = put(sources, source); - const namesIndex = name ? put(names, name) : NO_NAME; - if (sourcesIndex === sourcesContent.length) - sourcesContent[sourcesIndex] = content !== null && content !== void 0 ? content : null; - if (skipable && skipSource(line, index, sourcesIndex, sourceLine, sourceColumn, namesIndex)) { - return; - } - return insert(line, index, name - ? [genColumn, sourcesIndex, sourceLine, sourceColumn, namesIndex] - : [genColumn, sourcesIndex, sourceLine, sourceColumn]); -} -function getLine(mappings, index) { - for (let i = mappings.length; i <= index; i++) { - mappings[i] = []; - } - return mappings[index]; -} -function getColumnIndex(line, genColumn) { - let index = line.length; - for (let i = index - 1; i >= 0; index = i--) { - const current = line[i]; - if (genColumn >= current[COLUMN]) - break; - } - return index; -} -function insert(array, index, value) { - for (let i = array.length; i > index; i--) { - array[i] = array[i - 1]; - } - array[index] = value; -} -function removeEmptyFinalLines(mappings) { - const { length } = mappings; - let len = length; - for (let i = len - 1; i >= 0; len = i, i--) { - if (mappings[i].length > 0) - break; - } - if (len < length) - mappings.length = len; -} -function putAll(setarr, array) { - for (let i = 0; i < array.length; i++) - put(setarr, array[i]); -} -function skipSourceless(line, index) { - // The start of a line is already sourceless, so adding a sourceless segment to the beginning - // doesn't generate any useful information. - if (index === 0) - return true; - const prev = line[index - 1]; - // If the previous segment is also sourceless, then adding another sourceless segment doesn't - // genrate any new information. Else, this segment will end the source/named segment and point to - // a sourceless position, which is useful. - return prev.length === 1; -} -function skipSource(line, index, sourcesIndex, sourceLine, sourceColumn, namesIndex) { - // A source/named segment at the start of a line gives position at that genColumn - if (index === 0) - return false; - const prev = line[index - 1]; - // If the previous segment is sourceless, then we're transitioning to a source. - if (prev.length === 1) - return false; - // If the previous segment maps to the exact same source position, then this segment doesn't - // provide any new position information. - return (sourcesIndex === prev[SOURCES_INDEX] && - sourceLine === prev[SOURCE_LINE] && - sourceColumn === prev[SOURCE_COLUMN] && - namesIndex === (prev.length === 5 ? prev[NAMES_INDEX] : NO_NAME)); -} -function addMappingInternal(skipable, map, mapping) { - const { generated, source, original, name, content } = mapping; - if (!source) { - return addSegmentInternal(skipable, map, generated.line - 1, generated.column, null, null, null, null, null); - } - return addSegmentInternal(skipable, map, generated.line - 1, generated.column, source, original.line - 1, original.column, name, content); -} - -export { GenMapping, addMapping, addSegment, allMappings, fromMap, maybeAddMapping, maybeAddSegment, setIgnore, setSourceContent, toDecodedMap, toEncodedMap }; -//# sourceMappingURL=gen-mapping.mjs.map diff --git a/tools/eslint/node_modules/@jridgewell/gen-mapping/dist/gen-mapping.umd.js b/tools/eslint/node_modules/@jridgewell/gen-mapping/dist/gen-mapping.umd.js deleted file mode 100644 index 3bf18f3ad656a4..00000000000000 --- a/tools/eslint/node_modules/@jridgewell/gen-mapping/dist/gen-mapping.umd.js +++ /dev/null @@ -1,246 +0,0 @@ -(function (global, factory) { - typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@jridgewell/set-array'), require('@jridgewell/sourcemap-codec'), require('@jridgewell/trace-mapping')) : - typeof define === 'function' && define.amd ? define(['exports', '@jridgewell/set-array', '@jridgewell/sourcemap-codec', '@jridgewell/trace-mapping'], factory) : - (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.genMapping = {}, global.setArray, global.sourcemapCodec, global.traceMapping)); -})(this, (function (exports, setArray, sourcemapCodec, traceMapping) { 'use strict'; - - const COLUMN = 0; - const SOURCES_INDEX = 1; - const SOURCE_LINE = 2; - const SOURCE_COLUMN = 3; - const NAMES_INDEX = 4; - - const NO_NAME = -1; - /** - * Provides the state to generate a sourcemap. - */ - class GenMapping { - constructor({ file, sourceRoot } = {}) { - this._names = new setArray.SetArray(); - this._sources = new setArray.SetArray(); - this._sourcesContent = []; - this._mappings = []; - this.file = file; - this.sourceRoot = sourceRoot; - this._ignoreList = new setArray.SetArray(); - } - } - /** - * Typescript doesn't allow friend access to private fields, so this just casts the map into a type - * with public access modifiers. - */ - function cast(map) { - return map; - } - function addSegment(map, genLine, genColumn, source, sourceLine, sourceColumn, name, content) { - return addSegmentInternal(false, map, genLine, genColumn, source, sourceLine, sourceColumn, name, content); - } - function addMapping(map, mapping) { - return addMappingInternal(false, map, mapping); - } - /** - * Same as `addSegment`, but will only add the segment if it generates useful information in the - * resulting map. This only works correctly if segments are added **in order**, meaning you should - * not add a segment with a lower generated line/column than one that came before. - */ - const maybeAddSegment = (map, genLine, genColumn, source, sourceLine, sourceColumn, name, content) => { - return addSegmentInternal(true, map, genLine, genColumn, source, sourceLine, sourceColumn, name, content); - }; - /** - * Same as `addMapping`, but will only add the mapping if it generates useful information in the - * resulting map. This only works correctly if mappings are added **in order**, meaning you should - * not add a mapping with a lower generated line/column than one that came before. - */ - const maybeAddMapping = (map, mapping) => { - return addMappingInternal(true, map, mapping); - }; - /** - * Adds/removes the content of the source file to the source map. - */ - function setSourceContent(map, source, content) { - const { _sources: sources, _sourcesContent: sourcesContent } = cast(map); - const index = setArray.put(sources, source); - sourcesContent[index] = content; - } - function setIgnore(map, source, ignore = true) { - const { _sources: sources, _sourcesContent: sourcesContent, _ignoreList: ignoreList } = cast(map); - const index = setArray.put(sources, source); - if (index === sourcesContent.length) - sourcesContent[index] = null; - if (ignore) - setArray.put(ignoreList, index); - else - setArray.remove(ignoreList, index); - } - /** - * Returns a sourcemap object (with decoded mappings) suitable for passing to a library that expects - * a sourcemap, or to JSON.stringify. - */ - function toDecodedMap(map) { - const { _mappings: mappings, _sources: sources, _sourcesContent: sourcesContent, _names: names, _ignoreList: ignoreList, } = cast(map); - removeEmptyFinalLines(mappings); - return { - version: 3, - file: map.file || undefined, - names: names.array, - sourceRoot: map.sourceRoot || undefined, - sources: sources.array, - sourcesContent, - mappings, - ignoreList: ignoreList.array, - }; - } - /** - * Returns a sourcemap object (with encoded mappings) suitable for passing to a library that expects - * a sourcemap, or to JSON.stringify. - */ - function toEncodedMap(map) { - const decoded = toDecodedMap(map); - return Object.assign(Object.assign({}, decoded), { mappings: sourcemapCodec.encode(decoded.mappings) }); - } - /** - * Constructs a new GenMapping, using the already present mappings of the input. - */ - function fromMap(input) { - const map = new traceMapping.TraceMap(input); - const gen = new GenMapping({ file: map.file, sourceRoot: map.sourceRoot }); - putAll(cast(gen)._names, map.names); - putAll(cast(gen)._sources, map.sources); - cast(gen)._sourcesContent = map.sourcesContent || map.sources.map(() => null); - cast(gen)._mappings = traceMapping.decodedMappings(map); - if (map.ignoreList) - putAll(cast(gen)._ignoreList, map.ignoreList); - return gen; - } - /** - * Returns an array of high-level mapping objects for every recorded segment, which could then be - * passed to the `source-map` library. - */ - function allMappings(map) { - const out = []; - const { _mappings: mappings, _sources: sources, _names: names } = cast(map); - for (let i = 0; i < mappings.length; i++) { - const line = mappings[i]; - for (let j = 0; j < line.length; j++) { - const seg = line[j]; - const generated = { line: i + 1, column: seg[COLUMN] }; - let source = undefined; - let original = undefined; - let name = undefined; - if (seg.length !== 1) { - source = sources.array[seg[SOURCES_INDEX]]; - original = { line: seg[SOURCE_LINE] + 1, column: seg[SOURCE_COLUMN] }; - if (seg.length === 5) - name = names.array[seg[NAMES_INDEX]]; - } - out.push({ generated, source, original, name }); - } - } - return out; - } - // This split declaration is only so that terser can elminiate the static initialization block. - function addSegmentInternal(skipable, map, genLine, genColumn, source, sourceLine, sourceColumn, name, content) { - const { _mappings: mappings, _sources: sources, _sourcesContent: sourcesContent, _names: names, } = cast(map); - const line = getLine(mappings, genLine); - const index = getColumnIndex(line, genColumn); - if (!source) { - if (skipable && skipSourceless(line, index)) - return; - return insert(line, index, [genColumn]); - } - const sourcesIndex = setArray.put(sources, source); - const namesIndex = name ? setArray.put(names, name) : NO_NAME; - if (sourcesIndex === sourcesContent.length) - sourcesContent[sourcesIndex] = content !== null && content !== void 0 ? content : null; - if (skipable && skipSource(line, index, sourcesIndex, sourceLine, sourceColumn, namesIndex)) { - return; - } - return insert(line, index, name - ? [genColumn, sourcesIndex, sourceLine, sourceColumn, namesIndex] - : [genColumn, sourcesIndex, sourceLine, sourceColumn]); - } - function getLine(mappings, index) { - for (let i = mappings.length; i <= index; i++) { - mappings[i] = []; - } - return mappings[index]; - } - function getColumnIndex(line, genColumn) { - let index = line.length; - for (let i = index - 1; i >= 0; index = i--) { - const current = line[i]; - if (genColumn >= current[COLUMN]) - break; - } - return index; - } - function insert(array, index, value) { - for (let i = array.length; i > index; i--) { - array[i] = array[i - 1]; - } - array[index] = value; - } - function removeEmptyFinalLines(mappings) { - const { length } = mappings; - let len = length; - for (let i = len - 1; i >= 0; len = i, i--) { - if (mappings[i].length > 0) - break; - } - if (len < length) - mappings.length = len; - } - function putAll(setarr, array) { - for (let i = 0; i < array.length; i++) - setArray.put(setarr, array[i]); - } - function skipSourceless(line, index) { - // The start of a line is already sourceless, so adding a sourceless segment to the beginning - // doesn't generate any useful information. - if (index === 0) - return true; - const prev = line[index - 1]; - // If the previous segment is also sourceless, then adding another sourceless segment doesn't - // genrate any new information. Else, this segment will end the source/named segment and point to - // a sourceless position, which is useful. - return prev.length === 1; - } - function skipSource(line, index, sourcesIndex, sourceLine, sourceColumn, namesIndex) { - // A source/named segment at the start of a line gives position at that genColumn - if (index === 0) - return false; - const prev = line[index - 1]; - // If the previous segment is sourceless, then we're transitioning to a source. - if (prev.length === 1) - return false; - // If the previous segment maps to the exact same source position, then this segment doesn't - // provide any new position information. - return (sourcesIndex === prev[SOURCES_INDEX] && - sourceLine === prev[SOURCE_LINE] && - sourceColumn === prev[SOURCE_COLUMN] && - namesIndex === (prev.length === 5 ? prev[NAMES_INDEX] : NO_NAME)); - } - function addMappingInternal(skipable, map, mapping) { - const { generated, source, original, name, content } = mapping; - if (!source) { - return addSegmentInternal(skipable, map, generated.line - 1, generated.column, null, null, null, null, null); - } - return addSegmentInternal(skipable, map, generated.line - 1, generated.column, source, original.line - 1, original.column, name, content); - } - - exports.GenMapping = GenMapping; - exports.addMapping = addMapping; - exports.addSegment = addSegment; - exports.allMappings = allMappings; - exports.fromMap = fromMap; - exports.maybeAddMapping = maybeAddMapping; - exports.maybeAddSegment = maybeAddSegment; - exports.setIgnore = setIgnore; - exports.setSourceContent = setSourceContent; - exports.toDecodedMap = toDecodedMap; - exports.toEncodedMap = toEncodedMap; - - Object.defineProperty(exports, '__esModule', { value: true }); - -})); -//# sourceMappingURL=gen-mapping.umd.js.map diff --git a/tools/eslint/node_modules/@jridgewell/gen-mapping/package.json b/tools/eslint/node_modules/@jridgewell/gen-mapping/package.json deleted file mode 100644 index f2e7fe0e0543f5..00000000000000 --- a/tools/eslint/node_modules/@jridgewell/gen-mapping/package.json +++ /dev/null @@ -1,76 +0,0 @@ -{ - "name": "@jridgewell/gen-mapping", - "version": "0.3.5", - "description": "Generate source maps", - "keywords": [ - "source", - "map" - ], - "author": "Justin Ridgewell ", - "license": "MIT", - "repository": "https://github.com/jridgewell/gen-mapping", - "main": "dist/gen-mapping.umd.js", - "module": "dist/gen-mapping.mjs", - "types": "dist/types/gen-mapping.d.ts", - "exports": { - ".": [ - { - "types": "./dist/types/gen-mapping.d.ts", - "browser": "./dist/gen-mapping.umd.js", - "require": "./dist/gen-mapping.umd.js", - "import": "./dist/gen-mapping.mjs" - }, - "./dist/gen-mapping.umd.js" - ], - "./package.json": "./package.json" - }, - "files": [ - "dist" - ], - "engines": { - "node": ">=6.0.0" - }, - "scripts": { - "benchmark": "run-s build:rollup benchmark:*", - "benchmark:install": "cd benchmark && npm install", - "benchmark:only": "node benchmark/index.mjs", - "prebuild": "rm -rf dist", - "build": "run-s -n build:*", - "build:rollup": "rollup -c rollup.config.js", - "build:ts": "tsc --project tsconfig.build.json", - "lint": "run-s -n lint:*", - "lint:prettier": "npm run test:lint:prettier -- --write", - "lint:ts": "npm run test:lint:ts -- --fix", - "test": "run-s -n test:lint test:only", - "test:debug": "mocha --inspect-brk", - "test:lint": "run-s -n test:lint:*", - "test:lint:prettier": "prettier --check '{src,test}/**/*.ts'", - "test:lint:ts": "eslint '{src,test}/**/*.ts'", - "test:only": "c8 mocha", - "test:watch": "mocha --watch", - "prepublishOnly": "npm run preversion", - "preversion": "run-s test build" - }, - "devDependencies": { - "@rollup/plugin-typescript": "8.3.2", - "@types/mocha": "9.1.1", - "@types/node": "17.0.29", - "@typescript-eslint/eslint-plugin": "5.21.0", - "@typescript-eslint/parser": "5.21.0", - "benchmark": "2.1.4", - "c8": "7.11.2", - "eslint": "8.14.0", - "eslint-config-prettier": "8.5.0", - "mocha": "9.2.2", - "npm-run-all": "4.1.5", - "prettier": "2.6.2", - "rollup": "2.70.2", - "tsx": "4.7.1", - "typescript": "4.6.3" - }, - "dependencies": { - "@jridgewell/set-array": "^1.2.1", - "@jridgewell/sourcemap-codec": "^1.4.10", - "@jridgewell/trace-mapping": "^0.3.24" - } -} diff --git a/tools/eslint/node_modules/@jridgewell/resolve-uri/LICENSE b/tools/eslint/node_modules/@jridgewell/resolve-uri/LICENSE deleted file mode 100644 index 0a81b2ade1c77e..00000000000000 --- a/tools/eslint/node_modules/@jridgewell/resolve-uri/LICENSE +++ /dev/null @@ -1,19 +0,0 @@ -Copyright 2019 Justin Ridgewell - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. \ No newline at end of file diff --git a/tools/eslint/node_modules/@jridgewell/resolve-uri/dist/resolve-uri.mjs b/tools/eslint/node_modules/@jridgewell/resolve-uri/dist/resolve-uri.mjs deleted file mode 100644 index e958e881708120..00000000000000 --- a/tools/eslint/node_modules/@jridgewell/resolve-uri/dist/resolve-uri.mjs +++ /dev/null @@ -1,232 +0,0 @@ -// Matches the scheme of a URL, eg "http://" -const schemeRegex = /^[\w+.-]+:\/\//; -/** - * Matches the parts of a URL: - * 1. Scheme, including ":", guaranteed. - * 2. User/password, including "@", optional. - * 3. Host, guaranteed. - * 4. Port, including ":", optional. - * 5. Path, including "/", optional. - * 6. Query, including "?", optional. - * 7. Hash, including "#", optional. - */ -const urlRegex = /^([\w+.-]+:)\/\/([^@/#?]*@)?([^:/#?]*)(:\d+)?(\/[^#?]*)?(\?[^#]*)?(#.*)?/; -/** - * File URLs are weird. They dont' need the regular `//` in the scheme, they may or may not start - * with a leading `/`, they can have a domain (but only if they don't start with a Windows drive). - * - * 1. Host, optional. - * 2. Path, which may include "/", guaranteed. - * 3. Query, including "?", optional. - * 4. Hash, including "#", optional. - */ -const fileRegex = /^file:(?:\/\/((?![a-z]:)[^/#?]*)?)?(\/?[^#?]*)(\?[^#]*)?(#.*)?/i; -function isAbsoluteUrl(input) { - return schemeRegex.test(input); -} -function isSchemeRelativeUrl(input) { - return input.startsWith('//'); -} -function isAbsolutePath(input) { - return input.startsWith('/'); -} -function isFileUrl(input) { - return input.startsWith('file:'); -} -function isRelative(input) { - return /^[.?#]/.test(input); -} -function parseAbsoluteUrl(input) { - const match = urlRegex.exec(input); - return makeUrl(match[1], match[2] || '', match[3], match[4] || '', match[5] || '/', match[6] || '', match[7] || ''); -} -function parseFileUrl(input) { - const match = fileRegex.exec(input); - const path = match[2]; - return makeUrl('file:', '', match[1] || '', '', isAbsolutePath(path) ? path : '/' + path, match[3] || '', match[4] || ''); -} -function makeUrl(scheme, user, host, port, path, query, hash) { - return { - scheme, - user, - host, - port, - path, - query, - hash, - type: 7 /* Absolute */, - }; -} -function parseUrl(input) { - if (isSchemeRelativeUrl(input)) { - const url = parseAbsoluteUrl('http:' + input); - url.scheme = ''; - url.type = 6 /* SchemeRelative */; - return url; - } - if (isAbsolutePath(input)) { - const url = parseAbsoluteUrl('http://foo.com' + input); - url.scheme = ''; - url.host = ''; - url.type = 5 /* AbsolutePath */; - return url; - } - if (isFileUrl(input)) - return parseFileUrl(input); - if (isAbsoluteUrl(input)) - return parseAbsoluteUrl(input); - const url = parseAbsoluteUrl('http://foo.com/' + input); - url.scheme = ''; - url.host = ''; - url.type = input - ? input.startsWith('?') - ? 3 /* Query */ - : input.startsWith('#') - ? 2 /* Hash */ - : 4 /* RelativePath */ - : 1 /* Empty */; - return url; -} -function stripPathFilename(path) { - // If a path ends with a parent directory "..", then it's a relative path with excess parent - // paths. It's not a file, so we can't strip it. - if (path.endsWith('/..')) - return path; - const index = path.lastIndexOf('/'); - return path.slice(0, index + 1); -} -function mergePaths(url, base) { - normalizePath(base, base.type); - // If the path is just a "/", then it was an empty path to begin with (remember, we're a relative - // path). - if (url.path === '/') { - url.path = base.path; - } - else { - // Resolution happens relative to the base path's directory, not the file. - url.path = stripPathFilename(base.path) + url.path; - } -} -/** - * The path can have empty directories "//", unneeded parents "foo/..", or current directory - * "foo/.". We need to normalize to a standard representation. - */ -function normalizePath(url, type) { - const rel = type <= 4 /* RelativePath */; - const pieces = url.path.split('/'); - // We need to preserve the first piece always, so that we output a leading slash. The item at - // pieces[0] is an empty string. - let pointer = 1; - // Positive is the number of real directories we've output, used for popping a parent directory. - // Eg, "foo/bar/.." will have a positive 2, and we can decrement to be left with just "foo". - let positive = 0; - // We need to keep a trailing slash if we encounter an empty directory (eg, splitting "foo/" will - // generate `["foo", ""]` pieces). And, if we pop a parent directory. But once we encounter a - // real directory, we won't need to append, unless the other conditions happen again. - let addTrailingSlash = false; - for (let i = 1; i < pieces.length; i++) { - const piece = pieces[i]; - // An empty directory, could be a trailing slash, or just a double "//" in the path. - if (!piece) { - addTrailingSlash = true; - continue; - } - // If we encounter a real directory, then we don't need to append anymore. - addTrailingSlash = false; - // A current directory, which we can always drop. - if (piece === '.') - continue; - // A parent directory, we need to see if there are any real directories we can pop. Else, we - // have an excess of parents, and we'll need to keep the "..". - if (piece === '..') { - if (positive) { - addTrailingSlash = true; - positive--; - pointer--; - } - else if (rel) { - // If we're in a relativePath, then we need to keep the excess parents. Else, in an absolute - // URL, protocol relative URL, or an absolute path, we don't need to keep excess. - pieces[pointer++] = piece; - } - continue; - } - // We've encountered a real directory. Move it to the next insertion pointer, which accounts for - // any popped or dropped directories. - pieces[pointer++] = piece; - positive++; - } - let path = ''; - for (let i = 1; i < pointer; i++) { - path += '/' + pieces[i]; - } - if (!path || (addTrailingSlash && !path.endsWith('/..'))) { - path += '/'; - } - url.path = path; -} -/** - * Attempts to resolve `input` URL/path relative to `base`. - */ -function resolve(input, base) { - if (!input && !base) - return ''; - const url = parseUrl(input); - let inputType = url.type; - if (base && inputType !== 7 /* Absolute */) { - const baseUrl = parseUrl(base); - const baseType = baseUrl.type; - switch (inputType) { - case 1 /* Empty */: - url.hash = baseUrl.hash; - // fall through - case 2 /* Hash */: - url.query = baseUrl.query; - // fall through - case 3 /* Query */: - case 4 /* RelativePath */: - mergePaths(url, baseUrl); - // fall through - case 5 /* AbsolutePath */: - // The host, user, and port are joined, you can't copy one without the others. - url.user = baseUrl.user; - url.host = baseUrl.host; - url.port = baseUrl.port; - // fall through - case 6 /* SchemeRelative */: - // The input doesn't have a schema at least, so we need to copy at least that over. - url.scheme = baseUrl.scheme; - } - if (baseType > inputType) - inputType = baseType; - } - normalizePath(url, inputType); - const queryHash = url.query + url.hash; - switch (inputType) { - // This is impossible, because of the empty checks at the start of the function. - // case UrlType.Empty: - case 2 /* Hash */: - case 3 /* Query */: - return queryHash; - case 4 /* RelativePath */: { - // The first char is always a "/", and we need it to be relative. - const path = url.path.slice(1); - if (!path) - return queryHash || '.'; - if (isRelative(base || input) && !isRelative(path)) { - // If base started with a leading ".", or there is no base and input started with a ".", - // then we need to ensure that the relative path starts with a ".". We don't know if - // relative starts with a "..", though, so check before prepending. - return './' + path + queryHash; - } - return path + queryHash; - } - case 5 /* AbsolutePath */: - return url.path + queryHash; - default: - return url.scheme + '//' + url.user + url.host + url.port + url.path + queryHash; - } -} - -export { resolve as default }; -//# sourceMappingURL=resolve-uri.mjs.map diff --git a/tools/eslint/node_modules/@jridgewell/resolve-uri/dist/resolve-uri.umd.js b/tools/eslint/node_modules/@jridgewell/resolve-uri/dist/resolve-uri.umd.js deleted file mode 100644 index a783049b0136da..00000000000000 --- a/tools/eslint/node_modules/@jridgewell/resolve-uri/dist/resolve-uri.umd.js +++ /dev/null @@ -1,240 +0,0 @@ -(function (global, factory) { - typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() : - typeof define === 'function' && define.amd ? define(factory) : - (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.resolveURI = factory()); -})(this, (function () { 'use strict'; - - // Matches the scheme of a URL, eg "http://" - const schemeRegex = /^[\w+.-]+:\/\//; - /** - * Matches the parts of a URL: - * 1. Scheme, including ":", guaranteed. - * 2. User/password, including "@", optional. - * 3. Host, guaranteed. - * 4. Port, including ":", optional. - * 5. Path, including "/", optional. - * 6. Query, including "?", optional. - * 7. Hash, including "#", optional. - */ - const urlRegex = /^([\w+.-]+:)\/\/([^@/#?]*@)?([^:/#?]*)(:\d+)?(\/[^#?]*)?(\?[^#]*)?(#.*)?/; - /** - * File URLs are weird. They dont' need the regular `//` in the scheme, they may or may not start - * with a leading `/`, they can have a domain (but only if they don't start with a Windows drive). - * - * 1. Host, optional. - * 2. Path, which may include "/", guaranteed. - * 3. Query, including "?", optional. - * 4. Hash, including "#", optional. - */ - const fileRegex = /^file:(?:\/\/((?![a-z]:)[^/#?]*)?)?(\/?[^#?]*)(\?[^#]*)?(#.*)?/i; - function isAbsoluteUrl(input) { - return schemeRegex.test(input); - } - function isSchemeRelativeUrl(input) { - return input.startsWith('//'); - } - function isAbsolutePath(input) { - return input.startsWith('/'); - } - function isFileUrl(input) { - return input.startsWith('file:'); - } - function isRelative(input) { - return /^[.?#]/.test(input); - } - function parseAbsoluteUrl(input) { - const match = urlRegex.exec(input); - return makeUrl(match[1], match[2] || '', match[3], match[4] || '', match[5] || '/', match[6] || '', match[7] || ''); - } - function parseFileUrl(input) { - const match = fileRegex.exec(input); - const path = match[2]; - return makeUrl('file:', '', match[1] || '', '', isAbsolutePath(path) ? path : '/' + path, match[3] || '', match[4] || ''); - } - function makeUrl(scheme, user, host, port, path, query, hash) { - return { - scheme, - user, - host, - port, - path, - query, - hash, - type: 7 /* Absolute */, - }; - } - function parseUrl(input) { - if (isSchemeRelativeUrl(input)) { - const url = parseAbsoluteUrl('http:' + input); - url.scheme = ''; - url.type = 6 /* SchemeRelative */; - return url; - } - if (isAbsolutePath(input)) { - const url = parseAbsoluteUrl('http://foo.com' + input); - url.scheme = ''; - url.host = ''; - url.type = 5 /* AbsolutePath */; - return url; - } - if (isFileUrl(input)) - return parseFileUrl(input); - if (isAbsoluteUrl(input)) - return parseAbsoluteUrl(input); - const url = parseAbsoluteUrl('http://foo.com/' + input); - url.scheme = ''; - url.host = ''; - url.type = input - ? input.startsWith('?') - ? 3 /* Query */ - : input.startsWith('#') - ? 2 /* Hash */ - : 4 /* RelativePath */ - : 1 /* Empty */; - return url; - } - function stripPathFilename(path) { - // If a path ends with a parent directory "..", then it's a relative path with excess parent - // paths. It's not a file, so we can't strip it. - if (path.endsWith('/..')) - return path; - const index = path.lastIndexOf('/'); - return path.slice(0, index + 1); - } - function mergePaths(url, base) { - normalizePath(base, base.type); - // If the path is just a "/", then it was an empty path to begin with (remember, we're a relative - // path). - if (url.path === '/') { - url.path = base.path; - } - else { - // Resolution happens relative to the base path's directory, not the file. - url.path = stripPathFilename(base.path) + url.path; - } - } - /** - * The path can have empty directories "//", unneeded parents "foo/..", or current directory - * "foo/.". We need to normalize to a standard representation. - */ - function normalizePath(url, type) { - const rel = type <= 4 /* RelativePath */; - const pieces = url.path.split('/'); - // We need to preserve the first piece always, so that we output a leading slash. The item at - // pieces[0] is an empty string. - let pointer = 1; - // Positive is the number of real directories we've output, used for popping a parent directory. - // Eg, "foo/bar/.." will have a positive 2, and we can decrement to be left with just "foo". - let positive = 0; - // We need to keep a trailing slash if we encounter an empty directory (eg, splitting "foo/" will - // generate `["foo", ""]` pieces). And, if we pop a parent directory. But once we encounter a - // real directory, we won't need to append, unless the other conditions happen again. - let addTrailingSlash = false; - for (let i = 1; i < pieces.length; i++) { - const piece = pieces[i]; - // An empty directory, could be a trailing slash, or just a double "//" in the path. - if (!piece) { - addTrailingSlash = true; - continue; - } - // If we encounter a real directory, then we don't need to append anymore. - addTrailingSlash = false; - // A current directory, which we can always drop. - if (piece === '.') - continue; - // A parent directory, we need to see if there are any real directories we can pop. Else, we - // have an excess of parents, and we'll need to keep the "..". - if (piece === '..') { - if (positive) { - addTrailingSlash = true; - positive--; - pointer--; - } - else if (rel) { - // If we're in a relativePath, then we need to keep the excess parents. Else, in an absolute - // URL, protocol relative URL, or an absolute path, we don't need to keep excess. - pieces[pointer++] = piece; - } - continue; - } - // We've encountered a real directory. Move it to the next insertion pointer, which accounts for - // any popped or dropped directories. - pieces[pointer++] = piece; - positive++; - } - let path = ''; - for (let i = 1; i < pointer; i++) { - path += '/' + pieces[i]; - } - if (!path || (addTrailingSlash && !path.endsWith('/..'))) { - path += '/'; - } - url.path = path; - } - /** - * Attempts to resolve `input` URL/path relative to `base`. - */ - function resolve(input, base) { - if (!input && !base) - return ''; - const url = parseUrl(input); - let inputType = url.type; - if (base && inputType !== 7 /* Absolute */) { - const baseUrl = parseUrl(base); - const baseType = baseUrl.type; - switch (inputType) { - case 1 /* Empty */: - url.hash = baseUrl.hash; - // fall through - case 2 /* Hash */: - url.query = baseUrl.query; - // fall through - case 3 /* Query */: - case 4 /* RelativePath */: - mergePaths(url, baseUrl); - // fall through - case 5 /* AbsolutePath */: - // The host, user, and port are joined, you can't copy one without the others. - url.user = baseUrl.user; - url.host = baseUrl.host; - url.port = baseUrl.port; - // fall through - case 6 /* SchemeRelative */: - // The input doesn't have a schema at least, so we need to copy at least that over. - url.scheme = baseUrl.scheme; - } - if (baseType > inputType) - inputType = baseType; - } - normalizePath(url, inputType); - const queryHash = url.query + url.hash; - switch (inputType) { - // This is impossible, because of the empty checks at the start of the function. - // case UrlType.Empty: - case 2 /* Hash */: - case 3 /* Query */: - return queryHash; - case 4 /* RelativePath */: { - // The first char is always a "/", and we need it to be relative. - const path = url.path.slice(1); - if (!path) - return queryHash || '.'; - if (isRelative(base || input) && !isRelative(path)) { - // If base started with a leading ".", or there is no base and input started with a ".", - // then we need to ensure that the relative path starts with a ".". We don't know if - // relative starts with a "..", though, so check before prepending. - return './' + path + queryHash; - } - return path + queryHash; - } - case 5 /* AbsolutePath */: - return url.path + queryHash; - default: - return url.scheme + '//' + url.user + url.host + url.port + url.path + queryHash; - } - } - - return resolve; - -})); -//# sourceMappingURL=resolve-uri.umd.js.map diff --git a/tools/eslint/node_modules/@jridgewell/resolve-uri/package.json b/tools/eslint/node_modules/@jridgewell/resolve-uri/package.json deleted file mode 100644 index 02a4c5187e7ca7..00000000000000 --- a/tools/eslint/node_modules/@jridgewell/resolve-uri/package.json +++ /dev/null @@ -1,69 +0,0 @@ -{ - "name": "@jridgewell/resolve-uri", - "version": "3.1.2", - "description": "Resolve a URI relative to an optional base URI", - "keywords": [ - "resolve", - "uri", - "url", - "path" - ], - "author": "Justin Ridgewell ", - "license": "MIT", - "repository": "https://github.com/jridgewell/resolve-uri", - "main": "dist/resolve-uri.umd.js", - "module": "dist/resolve-uri.mjs", - "types": "dist/types/resolve-uri.d.ts", - "exports": { - ".": [ - { - "types": "./dist/types/resolve-uri.d.ts", - "browser": "./dist/resolve-uri.umd.js", - "require": "./dist/resolve-uri.umd.js", - "import": "./dist/resolve-uri.mjs" - }, - "./dist/resolve-uri.umd.js" - ], - "./package.json": "./package.json" - }, - "files": [ - "dist" - ], - "engines": { - "node": ">=6.0.0" - }, - "scripts": { - "prebuild": "rm -rf dist", - "build": "run-s -n build:*", - "build:rollup": "rollup -c rollup.config.js", - "build:ts": "tsc --project tsconfig.build.json", - "lint": "run-s -n lint:*", - "lint:prettier": "npm run test:lint:prettier -- --write", - "lint:ts": "npm run test:lint:ts -- --fix", - "pretest": "run-s build:rollup", - "test": "run-s -n test:lint test:only", - "test:debug": "mocha --inspect-brk", - "test:lint": "run-s -n test:lint:*", - "test:lint:prettier": "prettier --check '{src,test}/**/*.ts'", - "test:lint:ts": "eslint '{src,test}/**/*.ts'", - "test:only": "mocha", - "test:coverage": "c8 mocha", - "test:watch": "mocha --watch", - "prepublishOnly": "npm run preversion", - "preversion": "run-s test build" - }, - "devDependencies": { - "@jridgewell/resolve-uri-latest": "npm:@jridgewell/resolve-uri@*", - "@rollup/plugin-typescript": "8.3.0", - "@typescript-eslint/eslint-plugin": "5.10.0", - "@typescript-eslint/parser": "5.10.0", - "c8": "7.11.0", - "eslint": "8.7.0", - "eslint-config-prettier": "8.3.0", - "mocha": "9.2.0", - "npm-run-all": "4.1.5", - "prettier": "2.5.1", - "rollup": "2.66.0", - "typescript": "4.5.5" - } -} diff --git a/tools/eslint/node_modules/@jridgewell/set-array/LICENSE b/tools/eslint/node_modules/@jridgewell/set-array/LICENSE deleted file mode 100644 index 352f0715f391f0..00000000000000 --- a/tools/eslint/node_modules/@jridgewell/set-array/LICENSE +++ /dev/null @@ -1,19 +0,0 @@ -Copyright 2022 Justin Ridgewell - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. diff --git a/tools/eslint/node_modules/@jridgewell/set-array/dist/set-array.mjs b/tools/eslint/node_modules/@jridgewell/set-array/dist/set-array.mjs deleted file mode 100644 index 8a2d60b8947b0d..00000000000000 --- a/tools/eslint/node_modules/@jridgewell/set-array/dist/set-array.mjs +++ /dev/null @@ -1,69 +0,0 @@ -/** - * SetArray acts like a `Set` (allowing only one occurrence of a string `key`), but provides the - * index of the `key` in the backing array. - * - * This is designed to allow synchronizing a second array with the contents of the backing array, - * like how in a sourcemap `sourcesContent[i]` is the source content associated with `source[i]`, - * and there are never duplicates. - */ -class SetArray { - constructor() { - this._indexes = { __proto__: null }; - this.array = []; - } -} -/** - * Typescript doesn't allow friend access to private fields, so this just casts the set into a type - * with public access modifiers. - */ -function cast(set) { - return set; -} -/** - * Gets the index associated with `key` in the backing array, if it is already present. - */ -function get(setarr, key) { - return cast(setarr)._indexes[key]; -} -/** - * Puts `key` into the backing array, if it is not already present. Returns - * the index of the `key` in the backing array. - */ -function put(setarr, key) { - // The key may or may not be present. If it is present, it's a number. - const index = get(setarr, key); - if (index !== undefined) - return index; - const { array, _indexes: indexes } = cast(setarr); - const length = array.push(key); - return (indexes[key] = length - 1); -} -/** - * Pops the last added item out of the SetArray. - */ -function pop(setarr) { - const { array, _indexes: indexes } = cast(setarr); - if (array.length === 0) - return; - const last = array.pop(); - indexes[last] = undefined; -} -/** - * Removes the key, if it exists in the set. - */ -function remove(setarr, key) { - const index = get(setarr, key); - if (index === undefined) - return; - const { array, _indexes: indexes } = cast(setarr); - for (let i = index + 1; i < array.length; i++) { - const k = array[i]; - array[i - 1] = k; - indexes[k]--; - } - indexes[key] = undefined; - array.pop(); -} - -export { SetArray, get, pop, put, remove }; -//# sourceMappingURL=set-array.mjs.map diff --git a/tools/eslint/node_modules/@jridgewell/set-array/dist/set-array.umd.js b/tools/eslint/node_modules/@jridgewell/set-array/dist/set-array.umd.js deleted file mode 100644 index ab498cc13bbdc0..00000000000000 --- a/tools/eslint/node_modules/@jridgewell/set-array/dist/set-array.umd.js +++ /dev/null @@ -1,83 +0,0 @@ -(function (global, factory) { - typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) : - typeof define === 'function' && define.amd ? define(['exports'], factory) : - (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.setArray = {})); -})(this, (function (exports) { 'use strict'; - - /** - * SetArray acts like a `Set` (allowing only one occurrence of a string `key`), but provides the - * index of the `key` in the backing array. - * - * This is designed to allow synchronizing a second array with the contents of the backing array, - * like how in a sourcemap `sourcesContent[i]` is the source content associated with `source[i]`, - * and there are never duplicates. - */ - class SetArray { - constructor() { - this._indexes = { __proto__: null }; - this.array = []; - } - } - /** - * Typescript doesn't allow friend access to private fields, so this just casts the set into a type - * with public access modifiers. - */ - function cast(set) { - return set; - } - /** - * Gets the index associated with `key` in the backing array, if it is already present. - */ - function get(setarr, key) { - return cast(setarr)._indexes[key]; - } - /** - * Puts `key` into the backing array, if it is not already present. Returns - * the index of the `key` in the backing array. - */ - function put(setarr, key) { - // The key may or may not be present. If it is present, it's a number. - const index = get(setarr, key); - if (index !== undefined) - return index; - const { array, _indexes: indexes } = cast(setarr); - const length = array.push(key); - return (indexes[key] = length - 1); - } - /** - * Pops the last added item out of the SetArray. - */ - function pop(setarr) { - const { array, _indexes: indexes } = cast(setarr); - if (array.length === 0) - return; - const last = array.pop(); - indexes[last] = undefined; - } - /** - * Removes the key, if it exists in the set. - */ - function remove(setarr, key) { - const index = get(setarr, key); - if (index === undefined) - return; - const { array, _indexes: indexes } = cast(setarr); - for (let i = index + 1; i < array.length; i++) { - const k = array[i]; - array[i - 1] = k; - indexes[k]--; - } - indexes[key] = undefined; - array.pop(); - } - - exports.SetArray = SetArray; - exports.get = get; - exports.pop = pop; - exports.put = put; - exports.remove = remove; - - Object.defineProperty(exports, '__esModule', { value: true }); - -})); -//# sourceMappingURL=set-array.umd.js.map diff --git a/tools/eslint/node_modules/@jridgewell/set-array/package.json b/tools/eslint/node_modules/@jridgewell/set-array/package.json deleted file mode 100644 index f652ca5931ade0..00000000000000 --- a/tools/eslint/node_modules/@jridgewell/set-array/package.json +++ /dev/null @@ -1,65 +0,0 @@ -{ - "name": "@jridgewell/set-array", - "version": "1.2.1", - "description": "Like a Set, but provides the index of the `key` in the backing array", - "keywords": [], - "author": "Justin Ridgewell ", - "license": "MIT", - "repository": "https://github.com/jridgewell/set-array", - "main": "dist/set-array.umd.js", - "module": "dist/set-array.mjs", - "typings": "dist/types/set-array.d.ts", - "exports": { - ".": [ - { - "types": "./dist/types/set-array.d.ts", - "browser": "./dist/set-array.umd.js", - "require": "./dist/set-array.umd.js", - "import": "./dist/set-array.mjs" - }, - "./dist/set-array.umd.js" - ], - "./package.json": "./package.json" - }, - "files": [ - "dist" - ], - "engines": { - "node": ">=6.0.0" - }, - "scripts": { - "prebuild": "rm -rf dist", - "build": "run-s -n build:*", - "build:rollup": "rollup -c rollup.config.js", - "build:ts": "tsc --project tsconfig.build.json", - "lint": "run-s -n lint:*", - "lint:prettier": "npm run test:lint:prettier -- --write", - "lint:ts": "npm run test:lint:ts -- --fix", - "test": "run-s -n test:lint test:only", - "test:debug": "mocha --inspect-brk", - "test:lint": "run-s -n test:lint:*", - "test:lint:prettier": "prettier --check '{src,test}/**/*.ts'", - "test:lint:ts": "eslint '{src,test}/**/*.ts'", - "test:only": "mocha", - "test:coverage": "c8 mocha", - "test:watch": "mocha --watch", - "prepublishOnly": "npm run preversion", - "preversion": "run-s test build" - }, - "devDependencies": { - "@rollup/plugin-typescript": "8.3.0", - "@types/mocha": "9.1.1", - "@types/node": "17.0.29", - "@typescript-eslint/eslint-plugin": "5.10.0", - "@typescript-eslint/parser": "5.10.0", - "c8": "7.11.0", - "eslint": "8.7.0", - "eslint-config-prettier": "8.3.0", - "mocha": "9.2.0", - "npm-run-all": "4.1.5", - "prettier": "2.5.1", - "rollup": "2.66.0", - "tsx": "4.7.1", - "typescript": "4.5.5" - } -} diff --git a/tools/eslint/node_modules/@jridgewell/sourcemap-codec/LICENSE b/tools/eslint/node_modules/@jridgewell/sourcemap-codec/LICENSE deleted file mode 100644 index a331065a46b90f..00000000000000 --- a/tools/eslint/node_modules/@jridgewell/sourcemap-codec/LICENSE +++ /dev/null @@ -1,21 +0,0 @@ -The MIT License - -Copyright (c) 2015 Rich Harris - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. diff --git a/tools/eslint/node_modules/@jridgewell/sourcemap-codec/dist/sourcemap-codec.mjs b/tools/eslint/node_modules/@jridgewell/sourcemap-codec/dist/sourcemap-codec.mjs deleted file mode 100644 index 60e17b3d6368d6..00000000000000 --- a/tools/eslint/node_modules/@jridgewell/sourcemap-codec/dist/sourcemap-codec.mjs +++ /dev/null @@ -1,424 +0,0 @@ -const comma = ','.charCodeAt(0); -const semicolon = ';'.charCodeAt(0); -const chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'; -const intToChar = new Uint8Array(64); // 64 possible chars. -const charToInt = new Uint8Array(128); // z is 122 in ASCII -for (let i = 0; i < chars.length; i++) { - const c = chars.charCodeAt(i); - intToChar[i] = c; - charToInt[c] = i; -} -function decodeInteger(reader, relative) { - let value = 0; - let shift = 0; - let integer = 0; - do { - const c = reader.next(); - integer = charToInt[c]; - value |= (integer & 31) << shift; - shift += 5; - } while (integer & 32); - const shouldNegate = value & 1; - value >>>= 1; - if (shouldNegate) { - value = -0x80000000 | -value; - } - return relative + value; -} -function encodeInteger(builder, num, relative) { - let delta = num - relative; - delta = delta < 0 ? (-delta << 1) | 1 : delta << 1; - do { - let clamped = delta & 0b011111; - delta >>>= 5; - if (delta > 0) - clamped |= 0b100000; - builder.write(intToChar[clamped]); - } while (delta > 0); - return num; -} -function hasMoreVlq(reader, max) { - if (reader.pos >= max) - return false; - return reader.peek() !== comma; -} - -const bufLength = 1024 * 16; -// Provide a fallback for older environments. -const td = typeof TextDecoder !== 'undefined' - ? /* #__PURE__ */ new TextDecoder() - : typeof Buffer !== 'undefined' - ? { - decode(buf) { - const out = Buffer.from(buf.buffer, buf.byteOffset, buf.byteLength); - return out.toString(); - }, - } - : { - decode(buf) { - let out = ''; - for (let i = 0; i < buf.length; i++) { - out += String.fromCharCode(buf[i]); - } - return out; - }, - }; -class StringWriter { - constructor() { - this.pos = 0; - this.out = ''; - this.buffer = new Uint8Array(bufLength); - } - write(v) { - const { buffer } = this; - buffer[this.pos++] = v; - if (this.pos === bufLength) { - this.out += td.decode(buffer); - this.pos = 0; - } - } - flush() { - const { buffer, out, pos } = this; - return pos > 0 ? out + td.decode(buffer.subarray(0, pos)) : out; - } -} -class StringReader { - constructor(buffer) { - this.pos = 0; - this.buffer = buffer; - } - next() { - return this.buffer.charCodeAt(this.pos++); - } - peek() { - return this.buffer.charCodeAt(this.pos); - } - indexOf(char) { - const { buffer, pos } = this; - const idx = buffer.indexOf(char, pos); - return idx === -1 ? buffer.length : idx; - } -} - -const EMPTY = []; -function decodeOriginalScopes(input) { - const { length } = input; - const reader = new StringReader(input); - const scopes = []; - const stack = []; - let line = 0; - for (; reader.pos < length; reader.pos++) { - line = decodeInteger(reader, line); - const column = decodeInteger(reader, 0); - if (!hasMoreVlq(reader, length)) { - const last = stack.pop(); - last[2] = line; - last[3] = column; - continue; - } - const kind = decodeInteger(reader, 0); - const fields = decodeInteger(reader, 0); - const hasName = fields & 0b0001; - const scope = (hasName ? [line, column, 0, 0, kind, decodeInteger(reader, 0)] : [line, column, 0, 0, kind]); - let vars = EMPTY; - if (hasMoreVlq(reader, length)) { - vars = []; - do { - const varsIndex = decodeInteger(reader, 0); - vars.push(varsIndex); - } while (hasMoreVlq(reader, length)); - } - scope.vars = vars; - scopes.push(scope); - stack.push(scope); - } - return scopes; -} -function encodeOriginalScopes(scopes) { - const writer = new StringWriter(); - for (let i = 0; i < scopes.length;) { - i = _encodeOriginalScopes(scopes, i, writer, [0]); - } - return writer.flush(); -} -function _encodeOriginalScopes(scopes, index, writer, state) { - const scope = scopes[index]; - const { 0: startLine, 1: startColumn, 2: endLine, 3: endColumn, 4: kind, vars } = scope; - if (index > 0) - writer.write(comma); - state[0] = encodeInteger(writer, startLine, state[0]); - encodeInteger(writer, startColumn, 0); - encodeInteger(writer, kind, 0); - const fields = scope.length === 6 ? 0b0001 : 0; - encodeInteger(writer, fields, 0); - if (scope.length === 6) - encodeInteger(writer, scope[5], 0); - for (const v of vars) { - encodeInteger(writer, v, 0); - } - for (index++; index < scopes.length;) { - const next = scopes[index]; - const { 0: l, 1: c } = next; - if (l > endLine || (l === endLine && c >= endColumn)) { - break; - } - index = _encodeOriginalScopes(scopes, index, writer, state); - } - writer.write(comma); - state[0] = encodeInteger(writer, endLine, state[0]); - encodeInteger(writer, endColumn, 0); - return index; -} -function decodeGeneratedRanges(input) { - const { length } = input; - const reader = new StringReader(input); - const ranges = []; - const stack = []; - let genLine = 0; - let definitionSourcesIndex = 0; - let definitionScopeIndex = 0; - let callsiteSourcesIndex = 0; - let callsiteLine = 0; - let callsiteColumn = 0; - let bindingLine = 0; - let bindingColumn = 0; - do { - const semi = reader.indexOf(';'); - let genColumn = 0; - for (; reader.pos < semi; reader.pos++) { - genColumn = decodeInteger(reader, genColumn); - if (!hasMoreVlq(reader, semi)) { - const last = stack.pop(); - last[2] = genLine; - last[3] = genColumn; - continue; - } - const fields = decodeInteger(reader, 0); - const hasDefinition = fields & 0b0001; - const hasCallsite = fields & 0b0010; - const hasScope = fields & 0b0100; - let callsite = null; - let bindings = EMPTY; - let range; - if (hasDefinition) { - const defSourcesIndex = decodeInteger(reader, definitionSourcesIndex); - definitionScopeIndex = decodeInteger(reader, definitionSourcesIndex === defSourcesIndex ? definitionScopeIndex : 0); - definitionSourcesIndex = defSourcesIndex; - range = [genLine, genColumn, 0, 0, defSourcesIndex, definitionScopeIndex]; - } - else { - range = [genLine, genColumn, 0, 0]; - } - range.isScope = !!hasScope; - if (hasCallsite) { - const prevCsi = callsiteSourcesIndex; - const prevLine = callsiteLine; - callsiteSourcesIndex = decodeInteger(reader, callsiteSourcesIndex); - const sameSource = prevCsi === callsiteSourcesIndex; - callsiteLine = decodeInteger(reader, sameSource ? callsiteLine : 0); - callsiteColumn = decodeInteger(reader, sameSource && prevLine === callsiteLine ? callsiteColumn : 0); - callsite = [callsiteSourcesIndex, callsiteLine, callsiteColumn]; - } - range.callsite = callsite; - if (hasMoreVlq(reader, semi)) { - bindings = []; - do { - bindingLine = genLine; - bindingColumn = genColumn; - const expressionsCount = decodeInteger(reader, 0); - let expressionRanges; - if (expressionsCount < -1) { - expressionRanges = [[decodeInteger(reader, 0)]]; - for (let i = -1; i > expressionsCount; i--) { - const prevBl = bindingLine; - bindingLine = decodeInteger(reader, bindingLine); - bindingColumn = decodeInteger(reader, bindingLine === prevBl ? bindingColumn : 0); - const expression = decodeInteger(reader, 0); - expressionRanges.push([expression, bindingLine, bindingColumn]); - } - } - else { - expressionRanges = [[expressionsCount]]; - } - bindings.push(expressionRanges); - } while (hasMoreVlq(reader, semi)); - } - range.bindings = bindings; - ranges.push(range); - stack.push(range); - } - genLine++; - reader.pos = semi + 1; - } while (reader.pos < length); - return ranges; -} -function encodeGeneratedRanges(ranges) { - if (ranges.length === 0) - return ''; - const writer = new StringWriter(); - for (let i = 0; i < ranges.length;) { - i = _encodeGeneratedRanges(ranges, i, writer, [0, 0, 0, 0, 0, 0, 0]); - } - return writer.flush(); -} -function _encodeGeneratedRanges(ranges, index, writer, state) { - const range = ranges[index]; - const { 0: startLine, 1: startColumn, 2: endLine, 3: endColumn, isScope, callsite, bindings, } = range; - if (state[0] < startLine) { - catchupLine(writer, state[0], startLine); - state[0] = startLine; - state[1] = 0; - } - else if (index > 0) { - writer.write(comma); - } - state[1] = encodeInteger(writer, range[1], state[1]); - const fields = (range.length === 6 ? 0b0001 : 0) | (callsite ? 0b0010 : 0) | (isScope ? 0b0100 : 0); - encodeInteger(writer, fields, 0); - if (range.length === 6) { - const { 4: sourcesIndex, 5: scopesIndex } = range; - if (sourcesIndex !== state[2]) { - state[3] = 0; - } - state[2] = encodeInteger(writer, sourcesIndex, state[2]); - state[3] = encodeInteger(writer, scopesIndex, state[3]); - } - if (callsite) { - const { 0: sourcesIndex, 1: callLine, 2: callColumn } = range.callsite; - if (sourcesIndex !== state[4]) { - state[5] = 0; - state[6] = 0; - } - else if (callLine !== state[5]) { - state[6] = 0; - } - state[4] = encodeInteger(writer, sourcesIndex, state[4]); - state[5] = encodeInteger(writer, callLine, state[5]); - state[6] = encodeInteger(writer, callColumn, state[6]); - } - if (bindings) { - for (const binding of bindings) { - if (binding.length > 1) - encodeInteger(writer, -binding.length, 0); - const expression = binding[0][0]; - encodeInteger(writer, expression, 0); - let bindingStartLine = startLine; - let bindingStartColumn = startColumn; - for (let i = 1; i < binding.length; i++) { - const expRange = binding[i]; - bindingStartLine = encodeInteger(writer, expRange[1], bindingStartLine); - bindingStartColumn = encodeInteger(writer, expRange[2], bindingStartColumn); - encodeInteger(writer, expRange[0], 0); - } - } - } - for (index++; index < ranges.length;) { - const next = ranges[index]; - const { 0: l, 1: c } = next; - if (l > endLine || (l === endLine && c >= endColumn)) { - break; - } - index = _encodeGeneratedRanges(ranges, index, writer, state); - } - if (state[0] < endLine) { - catchupLine(writer, state[0], endLine); - state[0] = endLine; - state[1] = 0; - } - else { - writer.write(comma); - } - state[1] = encodeInteger(writer, endColumn, state[1]); - return index; -} -function catchupLine(writer, lastLine, line) { - do { - writer.write(semicolon); - } while (++lastLine < line); -} - -function decode(mappings) { - const { length } = mappings; - const reader = new StringReader(mappings); - const decoded = []; - let genColumn = 0; - let sourcesIndex = 0; - let sourceLine = 0; - let sourceColumn = 0; - let namesIndex = 0; - do { - const semi = reader.indexOf(';'); - const line = []; - let sorted = true; - let lastCol = 0; - genColumn = 0; - while (reader.pos < semi) { - let seg; - genColumn = decodeInteger(reader, genColumn); - if (genColumn < lastCol) - sorted = false; - lastCol = genColumn; - if (hasMoreVlq(reader, semi)) { - sourcesIndex = decodeInteger(reader, sourcesIndex); - sourceLine = decodeInteger(reader, sourceLine); - sourceColumn = decodeInteger(reader, sourceColumn); - if (hasMoreVlq(reader, semi)) { - namesIndex = decodeInteger(reader, namesIndex); - seg = [genColumn, sourcesIndex, sourceLine, sourceColumn, namesIndex]; - } - else { - seg = [genColumn, sourcesIndex, sourceLine, sourceColumn]; - } - } - else { - seg = [genColumn]; - } - line.push(seg); - reader.pos++; - } - if (!sorted) - sort(line); - decoded.push(line); - reader.pos = semi + 1; - } while (reader.pos <= length); - return decoded; -} -function sort(line) { - line.sort(sortComparator); -} -function sortComparator(a, b) { - return a[0] - b[0]; -} -function encode(decoded) { - const writer = new StringWriter(); - let sourcesIndex = 0; - let sourceLine = 0; - let sourceColumn = 0; - let namesIndex = 0; - for (let i = 0; i < decoded.length; i++) { - const line = decoded[i]; - if (i > 0) - writer.write(semicolon); - if (line.length === 0) - continue; - let genColumn = 0; - for (let j = 0; j < line.length; j++) { - const segment = line[j]; - if (j > 0) - writer.write(comma); - genColumn = encodeInteger(writer, segment[0], genColumn); - if (segment.length === 1) - continue; - sourcesIndex = encodeInteger(writer, segment[1], sourcesIndex); - sourceLine = encodeInteger(writer, segment[2], sourceLine); - sourceColumn = encodeInteger(writer, segment[3], sourceColumn); - if (segment.length === 4) - continue; - namesIndex = encodeInteger(writer, segment[4], namesIndex); - } - } - return writer.flush(); -} - -export { decode, decodeGeneratedRanges, decodeOriginalScopes, encode, encodeGeneratedRanges, encodeOriginalScopes }; -//# sourceMappingURL=sourcemap-codec.mjs.map diff --git a/tools/eslint/node_modules/@jridgewell/sourcemap-codec/dist/sourcemap-codec.umd.js b/tools/eslint/node_modules/@jridgewell/sourcemap-codec/dist/sourcemap-codec.umd.js deleted file mode 100644 index 93caf17652fe7b..00000000000000 --- a/tools/eslint/node_modules/@jridgewell/sourcemap-codec/dist/sourcemap-codec.umd.js +++ /dev/null @@ -1,439 +0,0 @@ -(function (global, factory) { - typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) : - typeof define === 'function' && define.amd ? define(['exports'], factory) : - (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.sourcemapCodec = {})); -})(this, (function (exports) { 'use strict'; - - const comma = ','.charCodeAt(0); - const semicolon = ';'.charCodeAt(0); - const chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'; - const intToChar = new Uint8Array(64); // 64 possible chars. - const charToInt = new Uint8Array(128); // z is 122 in ASCII - for (let i = 0; i < chars.length; i++) { - const c = chars.charCodeAt(i); - intToChar[i] = c; - charToInt[c] = i; - } - function decodeInteger(reader, relative) { - let value = 0; - let shift = 0; - let integer = 0; - do { - const c = reader.next(); - integer = charToInt[c]; - value |= (integer & 31) << shift; - shift += 5; - } while (integer & 32); - const shouldNegate = value & 1; - value >>>= 1; - if (shouldNegate) { - value = -0x80000000 | -value; - } - return relative + value; - } - function encodeInteger(builder, num, relative) { - let delta = num - relative; - delta = delta < 0 ? (-delta << 1) | 1 : delta << 1; - do { - let clamped = delta & 0b011111; - delta >>>= 5; - if (delta > 0) - clamped |= 0b100000; - builder.write(intToChar[clamped]); - } while (delta > 0); - return num; - } - function hasMoreVlq(reader, max) { - if (reader.pos >= max) - return false; - return reader.peek() !== comma; - } - - const bufLength = 1024 * 16; - // Provide a fallback for older environments. - const td = typeof TextDecoder !== 'undefined' - ? /* #__PURE__ */ new TextDecoder() - : typeof Buffer !== 'undefined' - ? { - decode(buf) { - const out = Buffer.from(buf.buffer, buf.byteOffset, buf.byteLength); - return out.toString(); - }, - } - : { - decode(buf) { - let out = ''; - for (let i = 0; i < buf.length; i++) { - out += String.fromCharCode(buf[i]); - } - return out; - }, - }; - class StringWriter { - constructor() { - this.pos = 0; - this.out = ''; - this.buffer = new Uint8Array(bufLength); - } - write(v) { - const { buffer } = this; - buffer[this.pos++] = v; - if (this.pos === bufLength) { - this.out += td.decode(buffer); - this.pos = 0; - } - } - flush() { - const { buffer, out, pos } = this; - return pos > 0 ? out + td.decode(buffer.subarray(0, pos)) : out; - } - } - class StringReader { - constructor(buffer) { - this.pos = 0; - this.buffer = buffer; - } - next() { - return this.buffer.charCodeAt(this.pos++); - } - peek() { - return this.buffer.charCodeAt(this.pos); - } - indexOf(char) { - const { buffer, pos } = this; - const idx = buffer.indexOf(char, pos); - return idx === -1 ? buffer.length : idx; - } - } - - const EMPTY = []; - function decodeOriginalScopes(input) { - const { length } = input; - const reader = new StringReader(input); - const scopes = []; - const stack = []; - let line = 0; - for (; reader.pos < length; reader.pos++) { - line = decodeInteger(reader, line); - const column = decodeInteger(reader, 0); - if (!hasMoreVlq(reader, length)) { - const last = stack.pop(); - last[2] = line; - last[3] = column; - continue; - } - const kind = decodeInteger(reader, 0); - const fields = decodeInteger(reader, 0); - const hasName = fields & 0b0001; - const scope = (hasName ? [line, column, 0, 0, kind, decodeInteger(reader, 0)] : [line, column, 0, 0, kind]); - let vars = EMPTY; - if (hasMoreVlq(reader, length)) { - vars = []; - do { - const varsIndex = decodeInteger(reader, 0); - vars.push(varsIndex); - } while (hasMoreVlq(reader, length)); - } - scope.vars = vars; - scopes.push(scope); - stack.push(scope); - } - return scopes; - } - function encodeOriginalScopes(scopes) { - const writer = new StringWriter(); - for (let i = 0; i < scopes.length;) { - i = _encodeOriginalScopes(scopes, i, writer, [0]); - } - return writer.flush(); - } - function _encodeOriginalScopes(scopes, index, writer, state) { - const scope = scopes[index]; - const { 0: startLine, 1: startColumn, 2: endLine, 3: endColumn, 4: kind, vars } = scope; - if (index > 0) - writer.write(comma); - state[0] = encodeInteger(writer, startLine, state[0]); - encodeInteger(writer, startColumn, 0); - encodeInteger(writer, kind, 0); - const fields = scope.length === 6 ? 0b0001 : 0; - encodeInteger(writer, fields, 0); - if (scope.length === 6) - encodeInteger(writer, scope[5], 0); - for (const v of vars) { - encodeInteger(writer, v, 0); - } - for (index++; index < scopes.length;) { - const next = scopes[index]; - const { 0: l, 1: c } = next; - if (l > endLine || (l === endLine && c >= endColumn)) { - break; - } - index = _encodeOriginalScopes(scopes, index, writer, state); - } - writer.write(comma); - state[0] = encodeInteger(writer, endLine, state[0]); - encodeInteger(writer, endColumn, 0); - return index; - } - function decodeGeneratedRanges(input) { - const { length } = input; - const reader = new StringReader(input); - const ranges = []; - const stack = []; - let genLine = 0; - let definitionSourcesIndex = 0; - let definitionScopeIndex = 0; - let callsiteSourcesIndex = 0; - let callsiteLine = 0; - let callsiteColumn = 0; - let bindingLine = 0; - let bindingColumn = 0; - do { - const semi = reader.indexOf(';'); - let genColumn = 0; - for (; reader.pos < semi; reader.pos++) { - genColumn = decodeInteger(reader, genColumn); - if (!hasMoreVlq(reader, semi)) { - const last = stack.pop(); - last[2] = genLine; - last[3] = genColumn; - continue; - } - const fields = decodeInteger(reader, 0); - const hasDefinition = fields & 0b0001; - const hasCallsite = fields & 0b0010; - const hasScope = fields & 0b0100; - let callsite = null; - let bindings = EMPTY; - let range; - if (hasDefinition) { - const defSourcesIndex = decodeInteger(reader, definitionSourcesIndex); - definitionScopeIndex = decodeInteger(reader, definitionSourcesIndex === defSourcesIndex ? definitionScopeIndex : 0); - definitionSourcesIndex = defSourcesIndex; - range = [genLine, genColumn, 0, 0, defSourcesIndex, definitionScopeIndex]; - } - else { - range = [genLine, genColumn, 0, 0]; - } - range.isScope = !!hasScope; - if (hasCallsite) { - const prevCsi = callsiteSourcesIndex; - const prevLine = callsiteLine; - callsiteSourcesIndex = decodeInteger(reader, callsiteSourcesIndex); - const sameSource = prevCsi === callsiteSourcesIndex; - callsiteLine = decodeInteger(reader, sameSource ? callsiteLine : 0); - callsiteColumn = decodeInteger(reader, sameSource && prevLine === callsiteLine ? callsiteColumn : 0); - callsite = [callsiteSourcesIndex, callsiteLine, callsiteColumn]; - } - range.callsite = callsite; - if (hasMoreVlq(reader, semi)) { - bindings = []; - do { - bindingLine = genLine; - bindingColumn = genColumn; - const expressionsCount = decodeInteger(reader, 0); - let expressionRanges; - if (expressionsCount < -1) { - expressionRanges = [[decodeInteger(reader, 0)]]; - for (let i = -1; i > expressionsCount; i--) { - const prevBl = bindingLine; - bindingLine = decodeInteger(reader, bindingLine); - bindingColumn = decodeInteger(reader, bindingLine === prevBl ? bindingColumn : 0); - const expression = decodeInteger(reader, 0); - expressionRanges.push([expression, bindingLine, bindingColumn]); - } - } - else { - expressionRanges = [[expressionsCount]]; - } - bindings.push(expressionRanges); - } while (hasMoreVlq(reader, semi)); - } - range.bindings = bindings; - ranges.push(range); - stack.push(range); - } - genLine++; - reader.pos = semi + 1; - } while (reader.pos < length); - return ranges; - } - function encodeGeneratedRanges(ranges) { - if (ranges.length === 0) - return ''; - const writer = new StringWriter(); - for (let i = 0; i < ranges.length;) { - i = _encodeGeneratedRanges(ranges, i, writer, [0, 0, 0, 0, 0, 0, 0]); - } - return writer.flush(); - } - function _encodeGeneratedRanges(ranges, index, writer, state) { - const range = ranges[index]; - const { 0: startLine, 1: startColumn, 2: endLine, 3: endColumn, isScope, callsite, bindings, } = range; - if (state[0] < startLine) { - catchupLine(writer, state[0], startLine); - state[0] = startLine; - state[1] = 0; - } - else if (index > 0) { - writer.write(comma); - } - state[1] = encodeInteger(writer, range[1], state[1]); - const fields = (range.length === 6 ? 0b0001 : 0) | (callsite ? 0b0010 : 0) | (isScope ? 0b0100 : 0); - encodeInteger(writer, fields, 0); - if (range.length === 6) { - const { 4: sourcesIndex, 5: scopesIndex } = range; - if (sourcesIndex !== state[2]) { - state[3] = 0; - } - state[2] = encodeInteger(writer, sourcesIndex, state[2]); - state[3] = encodeInteger(writer, scopesIndex, state[3]); - } - if (callsite) { - const { 0: sourcesIndex, 1: callLine, 2: callColumn } = range.callsite; - if (sourcesIndex !== state[4]) { - state[5] = 0; - state[6] = 0; - } - else if (callLine !== state[5]) { - state[6] = 0; - } - state[4] = encodeInteger(writer, sourcesIndex, state[4]); - state[5] = encodeInteger(writer, callLine, state[5]); - state[6] = encodeInteger(writer, callColumn, state[6]); - } - if (bindings) { - for (const binding of bindings) { - if (binding.length > 1) - encodeInteger(writer, -binding.length, 0); - const expression = binding[0][0]; - encodeInteger(writer, expression, 0); - let bindingStartLine = startLine; - let bindingStartColumn = startColumn; - for (let i = 1; i < binding.length; i++) { - const expRange = binding[i]; - bindingStartLine = encodeInteger(writer, expRange[1], bindingStartLine); - bindingStartColumn = encodeInteger(writer, expRange[2], bindingStartColumn); - encodeInteger(writer, expRange[0], 0); - } - } - } - for (index++; index < ranges.length;) { - const next = ranges[index]; - const { 0: l, 1: c } = next; - if (l > endLine || (l === endLine && c >= endColumn)) { - break; - } - index = _encodeGeneratedRanges(ranges, index, writer, state); - } - if (state[0] < endLine) { - catchupLine(writer, state[0], endLine); - state[0] = endLine; - state[1] = 0; - } - else { - writer.write(comma); - } - state[1] = encodeInteger(writer, endColumn, state[1]); - return index; - } - function catchupLine(writer, lastLine, line) { - do { - writer.write(semicolon); - } while (++lastLine < line); - } - - function decode(mappings) { - const { length } = mappings; - const reader = new StringReader(mappings); - const decoded = []; - let genColumn = 0; - let sourcesIndex = 0; - let sourceLine = 0; - let sourceColumn = 0; - let namesIndex = 0; - do { - const semi = reader.indexOf(';'); - const line = []; - let sorted = true; - let lastCol = 0; - genColumn = 0; - while (reader.pos < semi) { - let seg; - genColumn = decodeInteger(reader, genColumn); - if (genColumn < lastCol) - sorted = false; - lastCol = genColumn; - if (hasMoreVlq(reader, semi)) { - sourcesIndex = decodeInteger(reader, sourcesIndex); - sourceLine = decodeInteger(reader, sourceLine); - sourceColumn = decodeInteger(reader, sourceColumn); - if (hasMoreVlq(reader, semi)) { - namesIndex = decodeInteger(reader, namesIndex); - seg = [genColumn, sourcesIndex, sourceLine, sourceColumn, namesIndex]; - } - else { - seg = [genColumn, sourcesIndex, sourceLine, sourceColumn]; - } - } - else { - seg = [genColumn]; - } - line.push(seg); - reader.pos++; - } - if (!sorted) - sort(line); - decoded.push(line); - reader.pos = semi + 1; - } while (reader.pos <= length); - return decoded; - } - function sort(line) { - line.sort(sortComparator); - } - function sortComparator(a, b) { - return a[0] - b[0]; - } - function encode(decoded) { - const writer = new StringWriter(); - let sourcesIndex = 0; - let sourceLine = 0; - let sourceColumn = 0; - let namesIndex = 0; - for (let i = 0; i < decoded.length; i++) { - const line = decoded[i]; - if (i > 0) - writer.write(semicolon); - if (line.length === 0) - continue; - let genColumn = 0; - for (let j = 0; j < line.length; j++) { - const segment = line[j]; - if (j > 0) - writer.write(comma); - genColumn = encodeInteger(writer, segment[0], genColumn); - if (segment.length === 1) - continue; - sourcesIndex = encodeInteger(writer, segment[1], sourcesIndex); - sourceLine = encodeInteger(writer, segment[2], sourceLine); - sourceColumn = encodeInteger(writer, segment[3], sourceColumn); - if (segment.length === 4) - continue; - namesIndex = encodeInteger(writer, segment[4], namesIndex); - } - } - return writer.flush(); - } - - exports.decode = decode; - exports.decodeGeneratedRanges = decodeGeneratedRanges; - exports.decodeOriginalScopes = decodeOriginalScopes; - exports.encode = encode; - exports.encodeGeneratedRanges = encodeGeneratedRanges; - exports.encodeOriginalScopes = encodeOriginalScopes; - - Object.defineProperty(exports, '__esModule', { value: true }); - -})); -//# sourceMappingURL=sourcemap-codec.umd.js.map diff --git a/tools/eslint/node_modules/@jridgewell/sourcemap-codec/package.json b/tools/eslint/node_modules/@jridgewell/sourcemap-codec/package.json deleted file mode 100644 index 7168efcae7aa1a..00000000000000 --- a/tools/eslint/node_modules/@jridgewell/sourcemap-codec/package.json +++ /dev/null @@ -1,75 +0,0 @@ -{ - "name": "@jridgewell/sourcemap-codec", - "version": "1.5.0", - "description": "Encode/decode sourcemap mappings", - "keywords": [ - "sourcemap", - "vlq" - ], - "main": "dist/sourcemap-codec.umd.js", - "module": "dist/sourcemap-codec.mjs", - "types": "dist/types/sourcemap-codec.d.ts", - "files": [ - "dist" - ], - "exports": { - ".": [ - { - "types": "./dist/types/sourcemap-codec.d.ts", - "browser": "./dist/sourcemap-codec.umd.js", - "require": "./dist/sourcemap-codec.umd.js", - "import": "./dist/sourcemap-codec.mjs" - }, - "./dist/sourcemap-codec.umd.js" - ], - "./package.json": "./package.json" - }, - "scripts": { - "benchmark": "run-s build:rollup benchmark:*", - "benchmark:install": "cd benchmark && npm install", - "benchmark:only": "node --expose-gc benchmark/index.js", - "build": "run-s -n build:*", - "build:rollup": "rollup -c rollup.config.js", - "build:ts": "tsc --project tsconfig.build.json", - "lint": "run-s -n lint:*", - "lint:prettier": "npm run test:lint:prettier -- --write", - "lint:ts": "npm run test:lint:ts -- --fix", - "prebuild": "rm -rf dist", - "prepublishOnly": "npm run preversion", - "preversion": "run-s test build", - "test": "run-s -n test:lint test:only", - "test:debug": "mocha --inspect-brk", - "test:lint": "run-s -n test:lint:*", - "test:lint:prettier": "prettier --check '{src,test}/**/*.ts'", - "test:lint:ts": "eslint '{src,test}/**/*.ts'", - "test:only": "mocha", - "test:coverage": "c8 mocha", - "test:watch": "mocha --watch" - }, - "repository": { - "type": "git", - "url": "git+https://github.com/jridgewell/sourcemap-codec.git" - }, - "author": "Rich Harris", - "license": "MIT", - "devDependencies": { - "@rollup/plugin-typescript": "8.3.0", - "@types/mocha": "10.0.6", - "@types/node": "17.0.15", - "@typescript-eslint/eslint-plugin": "5.10.0", - "@typescript-eslint/parser": "5.10.0", - "benchmark": "2.1.4", - "c8": "7.11.2", - "eslint": "8.7.0", - "eslint-config-prettier": "8.3.0", - "mocha": "9.2.0", - "npm-run-all": "4.1.5", - "prettier": "2.5.1", - "rollup": "2.64.0", - "source-map": "0.6.1", - "source-map-js": "1.0.2", - "sourcemap-codec": "1.4.8", - "tsx": "4.7.1", - "typescript": "4.5.4" - } -} diff --git a/tools/eslint/node_modules/@jridgewell/trace-mapping/LICENSE b/tools/eslint/node_modules/@jridgewell/trace-mapping/LICENSE deleted file mode 100644 index 37bb488f08a129..00000000000000 --- a/tools/eslint/node_modules/@jridgewell/trace-mapping/LICENSE +++ /dev/null @@ -1,19 +0,0 @@ -Copyright 2022 Justin Ridgewell - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. diff --git a/tools/eslint/node_modules/@jridgewell/trace-mapping/dist/trace-mapping.mjs b/tools/eslint/node_modules/@jridgewell/trace-mapping/dist/trace-mapping.mjs deleted file mode 100644 index 8238e0ae79a8e2..00000000000000 --- a/tools/eslint/node_modules/@jridgewell/trace-mapping/dist/trace-mapping.mjs +++ /dev/null @@ -1,580 +0,0 @@ -import { encode, decode } from '@jridgewell/sourcemap-codec'; -import resolveUri from '@jridgewell/resolve-uri'; - -function resolve(input, base) { - // The base is always treated as a directory, if it's not empty. - // https://github.com/mozilla/source-map/blob/8cb3ee57/lib/util.js#L327 - // https://github.com/chromium/chromium/blob/da4adbb3/third_party/blink/renderer/devtools/front_end/sdk/SourceMap.js#L400-L401 - if (base && !base.endsWith('/')) - base += '/'; - return resolveUri(input, base); -} - -/** - * Removes everything after the last "/", but leaves the slash. - */ -function stripFilename(path) { - if (!path) - return ''; - const index = path.lastIndexOf('/'); - return path.slice(0, index + 1); -} - -const COLUMN = 0; -const SOURCES_INDEX = 1; -const SOURCE_LINE = 2; -const SOURCE_COLUMN = 3; -const NAMES_INDEX = 4; -const REV_GENERATED_LINE = 1; -const REV_GENERATED_COLUMN = 2; - -function maybeSort(mappings, owned) { - const unsortedIndex = nextUnsortedSegmentLine(mappings, 0); - if (unsortedIndex === mappings.length) - return mappings; - // If we own the array (meaning we parsed it from JSON), then we're free to directly mutate it. If - // not, we do not want to modify the consumer's input array. - if (!owned) - mappings = mappings.slice(); - for (let i = unsortedIndex; i < mappings.length; i = nextUnsortedSegmentLine(mappings, i + 1)) { - mappings[i] = sortSegments(mappings[i], owned); - } - return mappings; -} -function nextUnsortedSegmentLine(mappings, start) { - for (let i = start; i < mappings.length; i++) { - if (!isSorted(mappings[i])) - return i; - } - return mappings.length; -} -function isSorted(line) { - for (let j = 1; j < line.length; j++) { - if (line[j][COLUMN] < line[j - 1][COLUMN]) { - return false; - } - } - return true; -} -function sortSegments(line, owned) { - if (!owned) - line = line.slice(); - return line.sort(sortComparator); -} -function sortComparator(a, b) { - return a[COLUMN] - b[COLUMN]; -} - -let found = false; -/** - * A binary search implementation that returns the index if a match is found. - * If no match is found, then the left-index (the index associated with the item that comes just - * before the desired index) is returned. To maintain proper sort order, a splice would happen at - * the next index: - * - * ```js - * const array = [1, 3]; - * const needle = 2; - * const index = binarySearch(array, needle, (item, needle) => item - needle); - * - * assert.equal(index, 0); - * array.splice(index + 1, 0, needle); - * assert.deepEqual(array, [1, 2, 3]); - * ``` - */ -function binarySearch(haystack, needle, low, high) { - while (low <= high) { - const mid = low + ((high - low) >> 1); - const cmp = haystack[mid][COLUMN] - needle; - if (cmp === 0) { - found = true; - return mid; - } - if (cmp < 0) { - low = mid + 1; - } - else { - high = mid - 1; - } - } - found = false; - return low - 1; -} -function upperBound(haystack, needle, index) { - for (let i = index + 1; i < haystack.length; index = i++) { - if (haystack[i][COLUMN] !== needle) - break; - } - return index; -} -function lowerBound(haystack, needle, index) { - for (let i = index - 1; i >= 0; index = i--) { - if (haystack[i][COLUMN] !== needle) - break; - } - return index; -} -function memoizedState() { - return { - lastKey: -1, - lastNeedle: -1, - lastIndex: -1, - }; -} -/** - * This overly complicated beast is just to record the last tested line/column and the resulting - * index, allowing us to skip a few tests if mappings are monotonically increasing. - */ -function memoizedBinarySearch(haystack, needle, state, key) { - const { lastKey, lastNeedle, lastIndex } = state; - let low = 0; - let high = haystack.length - 1; - if (key === lastKey) { - if (needle === lastNeedle) { - found = lastIndex !== -1 && haystack[lastIndex][COLUMN] === needle; - return lastIndex; - } - if (needle >= lastNeedle) { - // lastIndex may be -1 if the previous needle was not found. - low = lastIndex === -1 ? 0 : lastIndex; - } - else { - high = lastIndex; - } - } - state.lastKey = key; - state.lastNeedle = needle; - return (state.lastIndex = binarySearch(haystack, needle, low, high)); -} - -// Rebuilds the original source files, with mappings that are ordered by source line/column instead -// of generated line/column. -function buildBySources(decoded, memos) { - const sources = memos.map(buildNullArray); - for (let i = 0; i < decoded.length; i++) { - const line = decoded[i]; - for (let j = 0; j < line.length; j++) { - const seg = line[j]; - if (seg.length === 1) - continue; - const sourceIndex = seg[SOURCES_INDEX]; - const sourceLine = seg[SOURCE_LINE]; - const sourceColumn = seg[SOURCE_COLUMN]; - const originalSource = sources[sourceIndex]; - const originalLine = (originalSource[sourceLine] || (originalSource[sourceLine] = [])); - const memo = memos[sourceIndex]; - // The binary search either found a match, or it found the left-index just before where the - // segment should go. Either way, we want to insert after that. And there may be multiple - // generated segments associated with an original location, so there may need to move several - // indexes before we find where we need to insert. - let index = upperBound(originalLine, sourceColumn, memoizedBinarySearch(originalLine, sourceColumn, memo, sourceLine)); - memo.lastIndex = ++index; - insert(originalLine, index, [sourceColumn, i, seg[COLUMN]]); - } - } - return sources; -} -function insert(array, index, value) { - for (let i = array.length; i > index; i--) { - array[i] = array[i - 1]; - } - array[index] = value; -} -// Null arrays allow us to use ordered index keys without actually allocating contiguous memory like -// a real array. We use a null-prototype object to avoid prototype pollution and deoptimizations. -// Numeric properties on objects are magically sorted in ascending order by the engine regardless of -// the insertion order. So, by setting any numeric keys, even out of order, we'll get ascending -// order when iterating with for-in. -function buildNullArray() { - return { __proto__: null }; -} - -const AnyMap = function (map, mapUrl) { - const parsed = parse(map); - if (!('sections' in parsed)) { - return new TraceMap(parsed, mapUrl); - } - const mappings = []; - const sources = []; - const sourcesContent = []; - const names = []; - const ignoreList = []; - recurse(parsed, mapUrl, mappings, sources, sourcesContent, names, ignoreList, 0, 0, Infinity, Infinity); - const joined = { - version: 3, - file: parsed.file, - names, - sources, - sourcesContent, - mappings, - ignoreList, - }; - return presortedDecodedMap(joined); -}; -function parse(map) { - return typeof map === 'string' ? JSON.parse(map) : map; -} -function recurse(input, mapUrl, mappings, sources, sourcesContent, names, ignoreList, lineOffset, columnOffset, stopLine, stopColumn) { - const { sections } = input; - for (let i = 0; i < sections.length; i++) { - const { map, offset } = sections[i]; - let sl = stopLine; - let sc = stopColumn; - if (i + 1 < sections.length) { - const nextOffset = sections[i + 1].offset; - sl = Math.min(stopLine, lineOffset + nextOffset.line); - if (sl === stopLine) { - sc = Math.min(stopColumn, columnOffset + nextOffset.column); - } - else if (sl < stopLine) { - sc = columnOffset + nextOffset.column; - } - } - addSection(map, mapUrl, mappings, sources, sourcesContent, names, ignoreList, lineOffset + offset.line, columnOffset + offset.column, sl, sc); - } -} -function addSection(input, mapUrl, mappings, sources, sourcesContent, names, ignoreList, lineOffset, columnOffset, stopLine, stopColumn) { - const parsed = parse(input); - if ('sections' in parsed) - return recurse(...arguments); - const map = new TraceMap(parsed, mapUrl); - const sourcesOffset = sources.length; - const namesOffset = names.length; - const decoded = decodedMappings(map); - const { resolvedSources, sourcesContent: contents, ignoreList: ignores } = map; - append(sources, resolvedSources); - append(names, map.names); - if (contents) - append(sourcesContent, contents); - else - for (let i = 0; i < resolvedSources.length; i++) - sourcesContent.push(null); - if (ignores) - for (let i = 0; i < ignores.length; i++) - ignoreList.push(ignores[i] + sourcesOffset); - for (let i = 0; i < decoded.length; i++) { - const lineI = lineOffset + i; - // We can only add so many lines before we step into the range that the next section's map - // controls. When we get to the last line, then we'll start checking the segments to see if - // they've crossed into the column range. But it may not have any columns that overstep, so we - // still need to check that we don't overstep lines, too. - if (lineI > stopLine) - return; - // The out line may already exist in mappings (if we're continuing the line started by a - // previous section). Or, we may have jumped ahead several lines to start this section. - const out = getLine(mappings, lineI); - // On the 0th loop, the section's column offset shifts us forward. On all other lines (since the - // map can be multiple lines), it doesn't. - const cOffset = i === 0 ? columnOffset : 0; - const line = decoded[i]; - for (let j = 0; j < line.length; j++) { - const seg = line[j]; - const column = cOffset + seg[COLUMN]; - // If this segment steps into the column range that the next section's map controls, we need - // to stop early. - if (lineI === stopLine && column >= stopColumn) - return; - if (seg.length === 1) { - out.push([column]); - continue; - } - const sourcesIndex = sourcesOffset + seg[SOURCES_INDEX]; - const sourceLine = seg[SOURCE_LINE]; - const sourceColumn = seg[SOURCE_COLUMN]; - out.push(seg.length === 4 - ? [column, sourcesIndex, sourceLine, sourceColumn] - : [column, sourcesIndex, sourceLine, sourceColumn, namesOffset + seg[NAMES_INDEX]]); - } - } -} -function append(arr, other) { - for (let i = 0; i < other.length; i++) - arr.push(other[i]); -} -function getLine(arr, index) { - for (let i = arr.length; i <= index; i++) - arr[i] = []; - return arr[index]; -} - -const LINE_GTR_ZERO = '`line` must be greater than 0 (lines start at line 1)'; -const COL_GTR_EQ_ZERO = '`column` must be greater than or equal to 0 (columns start at column 0)'; -const LEAST_UPPER_BOUND = -1; -const GREATEST_LOWER_BOUND = 1; -class TraceMap { - constructor(map, mapUrl) { - const isString = typeof map === 'string'; - if (!isString && map._decodedMemo) - return map; - const parsed = (isString ? JSON.parse(map) : map); - const { version, file, names, sourceRoot, sources, sourcesContent } = parsed; - this.version = version; - this.file = file; - this.names = names || []; - this.sourceRoot = sourceRoot; - this.sources = sources; - this.sourcesContent = sourcesContent; - this.ignoreList = parsed.ignoreList || parsed.x_google_ignoreList || undefined; - const from = resolve(sourceRoot || '', stripFilename(mapUrl)); - this.resolvedSources = sources.map((s) => resolve(s || '', from)); - const { mappings } = parsed; - if (typeof mappings === 'string') { - this._encoded = mappings; - this._decoded = undefined; - } - else { - this._encoded = undefined; - this._decoded = maybeSort(mappings, isString); - } - this._decodedMemo = memoizedState(); - this._bySources = undefined; - this._bySourceMemos = undefined; - } -} -/** - * Typescript doesn't allow friend access to private fields, so this just casts the map into a type - * with public access modifiers. - */ -function cast(map) { - return map; -} -/** - * Returns the encoded (VLQ string) form of the SourceMap's mappings field. - */ -function encodedMappings(map) { - var _a; - var _b; - return ((_a = (_b = cast(map))._encoded) !== null && _a !== void 0 ? _a : (_b._encoded = encode(cast(map)._decoded))); -} -/** - * Returns the decoded (array of lines of segments) form of the SourceMap's mappings field. - */ -function decodedMappings(map) { - var _a; - return ((_a = cast(map))._decoded || (_a._decoded = decode(cast(map)._encoded))); -} -/** - * A low-level API to find the segment associated with a generated line/column (think, from a - * stack trace). Line and column here are 0-based, unlike `originalPositionFor`. - */ -function traceSegment(map, line, column) { - const decoded = decodedMappings(map); - // It's common for parent source maps to have pointers to lines that have no - // mapping (like a "//# sourceMappingURL=") at the end of the child file. - if (line >= decoded.length) - return null; - const segments = decoded[line]; - const index = traceSegmentInternal(segments, cast(map)._decodedMemo, line, column, GREATEST_LOWER_BOUND); - return index === -1 ? null : segments[index]; -} -/** - * A higher-level API to find the source/line/column associated with a generated line/column - * (think, from a stack trace). Line is 1-based, but column is 0-based, due to legacy behavior in - * `source-map` library. - */ -function originalPositionFor(map, needle) { - let { line, column, bias } = needle; - line--; - if (line < 0) - throw new Error(LINE_GTR_ZERO); - if (column < 0) - throw new Error(COL_GTR_EQ_ZERO); - const decoded = decodedMappings(map); - // It's common for parent source maps to have pointers to lines that have no - // mapping (like a "//# sourceMappingURL=") at the end of the child file. - if (line >= decoded.length) - return OMapping(null, null, null, null); - const segments = decoded[line]; - const index = traceSegmentInternal(segments, cast(map)._decodedMemo, line, column, bias || GREATEST_LOWER_BOUND); - if (index === -1) - return OMapping(null, null, null, null); - const segment = segments[index]; - if (segment.length === 1) - return OMapping(null, null, null, null); - const { names, resolvedSources } = map; - return OMapping(resolvedSources[segment[SOURCES_INDEX]], segment[SOURCE_LINE] + 1, segment[SOURCE_COLUMN], segment.length === 5 ? names[segment[NAMES_INDEX]] : null); -} -/** - * Finds the generated line/column position of the provided source/line/column source position. - */ -function generatedPositionFor(map, needle) { - const { source, line, column, bias } = needle; - return generatedPosition(map, source, line, column, bias || GREATEST_LOWER_BOUND, false); -} -/** - * Finds all generated line/column positions of the provided source/line/column source position. - */ -function allGeneratedPositionsFor(map, needle) { - const { source, line, column, bias } = needle; - // SourceMapConsumer uses LEAST_UPPER_BOUND for some reason, so we follow suit. - return generatedPosition(map, source, line, column, bias || LEAST_UPPER_BOUND, true); -} -/** - * Iterates each mapping in generated position order. - */ -function eachMapping(map, cb) { - const decoded = decodedMappings(map); - const { names, resolvedSources } = map; - for (let i = 0; i < decoded.length; i++) { - const line = decoded[i]; - for (let j = 0; j < line.length; j++) { - const seg = line[j]; - const generatedLine = i + 1; - const generatedColumn = seg[0]; - let source = null; - let originalLine = null; - let originalColumn = null; - let name = null; - if (seg.length !== 1) { - source = resolvedSources[seg[1]]; - originalLine = seg[2] + 1; - originalColumn = seg[3]; - } - if (seg.length === 5) - name = names[seg[4]]; - cb({ - generatedLine, - generatedColumn, - source, - originalLine, - originalColumn, - name, - }); - } - } -} -function sourceIndex(map, source) { - const { sources, resolvedSources } = map; - let index = sources.indexOf(source); - if (index === -1) - index = resolvedSources.indexOf(source); - return index; -} -/** - * Retrieves the source content for a particular source, if its found. Returns null if not. - */ -function sourceContentFor(map, source) { - const { sourcesContent } = map; - if (sourcesContent == null) - return null; - const index = sourceIndex(map, source); - return index === -1 ? null : sourcesContent[index]; -} -/** - * Determines if the source is marked to ignore by the source map. - */ -function isIgnored(map, source) { - const { ignoreList } = map; - if (ignoreList == null) - return false; - const index = sourceIndex(map, source); - return index === -1 ? false : ignoreList.includes(index); -} -/** - * A helper that skips sorting of the input map's mappings array, which can be expensive for larger - * maps. - */ -function presortedDecodedMap(map, mapUrl) { - const tracer = new TraceMap(clone(map, []), mapUrl); - cast(tracer)._decoded = map.mappings; - return tracer; -} -/** - * Returns a sourcemap object (with decoded mappings) suitable for passing to a library that expects - * a sourcemap, or to JSON.stringify. - */ -function decodedMap(map) { - return clone(map, decodedMappings(map)); -} -/** - * Returns a sourcemap object (with encoded mappings) suitable for passing to a library that expects - * a sourcemap, or to JSON.stringify. - */ -function encodedMap(map) { - return clone(map, encodedMappings(map)); -} -function clone(map, mappings) { - return { - version: map.version, - file: map.file, - names: map.names, - sourceRoot: map.sourceRoot, - sources: map.sources, - sourcesContent: map.sourcesContent, - mappings, - ignoreList: map.ignoreList || map.x_google_ignoreList, - }; -} -function OMapping(source, line, column, name) { - return { source, line, column, name }; -} -function GMapping(line, column) { - return { line, column }; -} -function traceSegmentInternal(segments, memo, line, column, bias) { - let index = memoizedBinarySearch(segments, column, memo, line); - if (found) { - index = (bias === LEAST_UPPER_BOUND ? upperBound : lowerBound)(segments, column, index); - } - else if (bias === LEAST_UPPER_BOUND) - index++; - if (index === -1 || index === segments.length) - return -1; - return index; -} -function sliceGeneratedPositions(segments, memo, line, column, bias) { - let min = traceSegmentInternal(segments, memo, line, column, GREATEST_LOWER_BOUND); - // We ignored the bias when tracing the segment so that we're guarnateed to find the first (in - // insertion order) segment that matched. Even if we did respect the bias when tracing, we would - // still need to call `lowerBound()` to find the first segment, which is slower than just looking - // for the GREATEST_LOWER_BOUND to begin with. The only difference that matters for us is when the - // binary search didn't match, in which case GREATEST_LOWER_BOUND just needs to increment to - // match LEAST_UPPER_BOUND. - if (!found && bias === LEAST_UPPER_BOUND) - min++; - if (min === -1 || min === segments.length) - return []; - // We may have found the segment that started at an earlier column. If this is the case, then we - // need to slice all generated segments that match _that_ column, because all such segments span - // to our desired column. - const matchedColumn = found ? column : segments[min][COLUMN]; - // The binary search is not guaranteed to find the lower bound when a match wasn't found. - if (!found) - min = lowerBound(segments, matchedColumn, min); - const max = upperBound(segments, matchedColumn, min); - const result = []; - for (; min <= max; min++) { - const segment = segments[min]; - result.push(GMapping(segment[REV_GENERATED_LINE] + 1, segment[REV_GENERATED_COLUMN])); - } - return result; -} -function generatedPosition(map, source, line, column, bias, all) { - var _a; - line--; - if (line < 0) - throw new Error(LINE_GTR_ZERO); - if (column < 0) - throw new Error(COL_GTR_EQ_ZERO); - const { sources, resolvedSources } = map; - let sourceIndex = sources.indexOf(source); - if (sourceIndex === -1) - sourceIndex = resolvedSources.indexOf(source); - if (sourceIndex === -1) - return all ? [] : GMapping(null, null); - const generated = ((_a = cast(map))._bySources || (_a._bySources = buildBySources(decodedMappings(map), (cast(map)._bySourceMemos = sources.map(memoizedState))))); - const segments = generated[sourceIndex][line]; - if (segments == null) - return all ? [] : GMapping(null, null); - const memo = cast(map)._bySourceMemos[sourceIndex]; - if (all) - return sliceGeneratedPositions(segments, memo, line, column, bias); - const index = traceSegmentInternal(segments, memo, line, column, bias); - if (index === -1) - return GMapping(null, null); - const segment = segments[index]; - return GMapping(segment[REV_GENERATED_LINE] + 1, segment[REV_GENERATED_COLUMN]); -} - -export { AnyMap, GREATEST_LOWER_BOUND, LEAST_UPPER_BOUND, TraceMap, allGeneratedPositionsFor, decodedMap, decodedMappings, eachMapping, encodedMap, encodedMappings, generatedPositionFor, isIgnored, originalPositionFor, presortedDecodedMap, sourceContentFor, traceSegment }; -//# sourceMappingURL=trace-mapping.mjs.map diff --git a/tools/eslint/node_modules/@jridgewell/trace-mapping/dist/trace-mapping.umd.js b/tools/eslint/node_modules/@jridgewell/trace-mapping/dist/trace-mapping.umd.js deleted file mode 100644 index 3be0f36effc2b7..00000000000000 --- a/tools/eslint/node_modules/@jridgewell/trace-mapping/dist/trace-mapping.umd.js +++ /dev/null @@ -1,600 +0,0 @@ -(function (global, factory) { - typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@jridgewell/sourcemap-codec'), require('@jridgewell/resolve-uri')) : - typeof define === 'function' && define.amd ? define(['exports', '@jridgewell/sourcemap-codec', '@jridgewell/resolve-uri'], factory) : - (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.traceMapping = {}, global.sourcemapCodec, global.resolveURI)); -})(this, (function (exports, sourcemapCodec, resolveUri) { 'use strict'; - - function resolve(input, base) { - // The base is always treated as a directory, if it's not empty. - // https://github.com/mozilla/source-map/blob/8cb3ee57/lib/util.js#L327 - // https://github.com/chromium/chromium/blob/da4adbb3/third_party/blink/renderer/devtools/front_end/sdk/SourceMap.js#L400-L401 - if (base && !base.endsWith('/')) - base += '/'; - return resolveUri(input, base); - } - - /** - * Removes everything after the last "/", but leaves the slash. - */ - function stripFilename(path) { - if (!path) - return ''; - const index = path.lastIndexOf('/'); - return path.slice(0, index + 1); - } - - const COLUMN = 0; - const SOURCES_INDEX = 1; - const SOURCE_LINE = 2; - const SOURCE_COLUMN = 3; - const NAMES_INDEX = 4; - const REV_GENERATED_LINE = 1; - const REV_GENERATED_COLUMN = 2; - - function maybeSort(mappings, owned) { - const unsortedIndex = nextUnsortedSegmentLine(mappings, 0); - if (unsortedIndex === mappings.length) - return mappings; - // If we own the array (meaning we parsed it from JSON), then we're free to directly mutate it. If - // not, we do not want to modify the consumer's input array. - if (!owned) - mappings = mappings.slice(); - for (let i = unsortedIndex; i < mappings.length; i = nextUnsortedSegmentLine(mappings, i + 1)) { - mappings[i] = sortSegments(mappings[i], owned); - } - return mappings; - } - function nextUnsortedSegmentLine(mappings, start) { - for (let i = start; i < mappings.length; i++) { - if (!isSorted(mappings[i])) - return i; - } - return mappings.length; - } - function isSorted(line) { - for (let j = 1; j < line.length; j++) { - if (line[j][COLUMN] < line[j - 1][COLUMN]) { - return false; - } - } - return true; - } - function sortSegments(line, owned) { - if (!owned) - line = line.slice(); - return line.sort(sortComparator); - } - function sortComparator(a, b) { - return a[COLUMN] - b[COLUMN]; - } - - let found = false; - /** - * A binary search implementation that returns the index if a match is found. - * If no match is found, then the left-index (the index associated with the item that comes just - * before the desired index) is returned. To maintain proper sort order, a splice would happen at - * the next index: - * - * ```js - * const array = [1, 3]; - * const needle = 2; - * const index = binarySearch(array, needle, (item, needle) => item - needle); - * - * assert.equal(index, 0); - * array.splice(index + 1, 0, needle); - * assert.deepEqual(array, [1, 2, 3]); - * ``` - */ - function binarySearch(haystack, needle, low, high) { - while (low <= high) { - const mid = low + ((high - low) >> 1); - const cmp = haystack[mid][COLUMN] - needle; - if (cmp === 0) { - found = true; - return mid; - } - if (cmp < 0) { - low = mid + 1; - } - else { - high = mid - 1; - } - } - found = false; - return low - 1; - } - function upperBound(haystack, needle, index) { - for (let i = index + 1; i < haystack.length; index = i++) { - if (haystack[i][COLUMN] !== needle) - break; - } - return index; - } - function lowerBound(haystack, needle, index) { - for (let i = index - 1; i >= 0; index = i--) { - if (haystack[i][COLUMN] !== needle) - break; - } - return index; - } - function memoizedState() { - return { - lastKey: -1, - lastNeedle: -1, - lastIndex: -1, - }; - } - /** - * This overly complicated beast is just to record the last tested line/column and the resulting - * index, allowing us to skip a few tests if mappings are monotonically increasing. - */ - function memoizedBinarySearch(haystack, needle, state, key) { - const { lastKey, lastNeedle, lastIndex } = state; - let low = 0; - let high = haystack.length - 1; - if (key === lastKey) { - if (needle === lastNeedle) { - found = lastIndex !== -1 && haystack[lastIndex][COLUMN] === needle; - return lastIndex; - } - if (needle >= lastNeedle) { - // lastIndex may be -1 if the previous needle was not found. - low = lastIndex === -1 ? 0 : lastIndex; - } - else { - high = lastIndex; - } - } - state.lastKey = key; - state.lastNeedle = needle; - return (state.lastIndex = binarySearch(haystack, needle, low, high)); - } - - // Rebuilds the original source files, with mappings that are ordered by source line/column instead - // of generated line/column. - function buildBySources(decoded, memos) { - const sources = memos.map(buildNullArray); - for (let i = 0; i < decoded.length; i++) { - const line = decoded[i]; - for (let j = 0; j < line.length; j++) { - const seg = line[j]; - if (seg.length === 1) - continue; - const sourceIndex = seg[SOURCES_INDEX]; - const sourceLine = seg[SOURCE_LINE]; - const sourceColumn = seg[SOURCE_COLUMN]; - const originalSource = sources[sourceIndex]; - const originalLine = (originalSource[sourceLine] || (originalSource[sourceLine] = [])); - const memo = memos[sourceIndex]; - // The binary search either found a match, or it found the left-index just before where the - // segment should go. Either way, we want to insert after that. And there may be multiple - // generated segments associated with an original location, so there may need to move several - // indexes before we find where we need to insert. - let index = upperBound(originalLine, sourceColumn, memoizedBinarySearch(originalLine, sourceColumn, memo, sourceLine)); - memo.lastIndex = ++index; - insert(originalLine, index, [sourceColumn, i, seg[COLUMN]]); - } - } - return sources; - } - function insert(array, index, value) { - for (let i = array.length; i > index; i--) { - array[i] = array[i - 1]; - } - array[index] = value; - } - // Null arrays allow us to use ordered index keys without actually allocating contiguous memory like - // a real array. We use a null-prototype object to avoid prototype pollution and deoptimizations. - // Numeric properties on objects are magically sorted in ascending order by the engine regardless of - // the insertion order. So, by setting any numeric keys, even out of order, we'll get ascending - // order when iterating with for-in. - function buildNullArray() { - return { __proto__: null }; - } - - const AnyMap = function (map, mapUrl) { - const parsed = parse(map); - if (!('sections' in parsed)) { - return new TraceMap(parsed, mapUrl); - } - const mappings = []; - const sources = []; - const sourcesContent = []; - const names = []; - const ignoreList = []; - recurse(parsed, mapUrl, mappings, sources, sourcesContent, names, ignoreList, 0, 0, Infinity, Infinity); - const joined = { - version: 3, - file: parsed.file, - names, - sources, - sourcesContent, - mappings, - ignoreList, - }; - return presortedDecodedMap(joined); - }; - function parse(map) { - return typeof map === 'string' ? JSON.parse(map) : map; - } - function recurse(input, mapUrl, mappings, sources, sourcesContent, names, ignoreList, lineOffset, columnOffset, stopLine, stopColumn) { - const { sections } = input; - for (let i = 0; i < sections.length; i++) { - const { map, offset } = sections[i]; - let sl = stopLine; - let sc = stopColumn; - if (i + 1 < sections.length) { - const nextOffset = sections[i + 1].offset; - sl = Math.min(stopLine, lineOffset + nextOffset.line); - if (sl === stopLine) { - sc = Math.min(stopColumn, columnOffset + nextOffset.column); - } - else if (sl < stopLine) { - sc = columnOffset + nextOffset.column; - } - } - addSection(map, mapUrl, mappings, sources, sourcesContent, names, ignoreList, lineOffset + offset.line, columnOffset + offset.column, sl, sc); - } - } - function addSection(input, mapUrl, mappings, sources, sourcesContent, names, ignoreList, lineOffset, columnOffset, stopLine, stopColumn) { - const parsed = parse(input); - if ('sections' in parsed) - return recurse(...arguments); - const map = new TraceMap(parsed, mapUrl); - const sourcesOffset = sources.length; - const namesOffset = names.length; - const decoded = decodedMappings(map); - const { resolvedSources, sourcesContent: contents, ignoreList: ignores } = map; - append(sources, resolvedSources); - append(names, map.names); - if (contents) - append(sourcesContent, contents); - else - for (let i = 0; i < resolvedSources.length; i++) - sourcesContent.push(null); - if (ignores) - for (let i = 0; i < ignores.length; i++) - ignoreList.push(ignores[i] + sourcesOffset); - for (let i = 0; i < decoded.length; i++) { - const lineI = lineOffset + i; - // We can only add so many lines before we step into the range that the next section's map - // controls. When we get to the last line, then we'll start checking the segments to see if - // they've crossed into the column range. But it may not have any columns that overstep, so we - // still need to check that we don't overstep lines, too. - if (lineI > stopLine) - return; - // The out line may already exist in mappings (if we're continuing the line started by a - // previous section). Or, we may have jumped ahead several lines to start this section. - const out = getLine(mappings, lineI); - // On the 0th loop, the section's column offset shifts us forward. On all other lines (since the - // map can be multiple lines), it doesn't. - const cOffset = i === 0 ? columnOffset : 0; - const line = decoded[i]; - for (let j = 0; j < line.length; j++) { - const seg = line[j]; - const column = cOffset + seg[COLUMN]; - // If this segment steps into the column range that the next section's map controls, we need - // to stop early. - if (lineI === stopLine && column >= stopColumn) - return; - if (seg.length === 1) { - out.push([column]); - continue; - } - const sourcesIndex = sourcesOffset + seg[SOURCES_INDEX]; - const sourceLine = seg[SOURCE_LINE]; - const sourceColumn = seg[SOURCE_COLUMN]; - out.push(seg.length === 4 - ? [column, sourcesIndex, sourceLine, sourceColumn] - : [column, sourcesIndex, sourceLine, sourceColumn, namesOffset + seg[NAMES_INDEX]]); - } - } - } - function append(arr, other) { - for (let i = 0; i < other.length; i++) - arr.push(other[i]); - } - function getLine(arr, index) { - for (let i = arr.length; i <= index; i++) - arr[i] = []; - return arr[index]; - } - - const LINE_GTR_ZERO = '`line` must be greater than 0 (lines start at line 1)'; - const COL_GTR_EQ_ZERO = '`column` must be greater than or equal to 0 (columns start at column 0)'; - const LEAST_UPPER_BOUND = -1; - const GREATEST_LOWER_BOUND = 1; - class TraceMap { - constructor(map, mapUrl) { - const isString = typeof map === 'string'; - if (!isString && map._decodedMemo) - return map; - const parsed = (isString ? JSON.parse(map) : map); - const { version, file, names, sourceRoot, sources, sourcesContent } = parsed; - this.version = version; - this.file = file; - this.names = names || []; - this.sourceRoot = sourceRoot; - this.sources = sources; - this.sourcesContent = sourcesContent; - this.ignoreList = parsed.ignoreList || parsed.x_google_ignoreList || undefined; - const from = resolve(sourceRoot || '', stripFilename(mapUrl)); - this.resolvedSources = sources.map((s) => resolve(s || '', from)); - const { mappings } = parsed; - if (typeof mappings === 'string') { - this._encoded = mappings; - this._decoded = undefined; - } - else { - this._encoded = undefined; - this._decoded = maybeSort(mappings, isString); - } - this._decodedMemo = memoizedState(); - this._bySources = undefined; - this._bySourceMemos = undefined; - } - } - /** - * Typescript doesn't allow friend access to private fields, so this just casts the map into a type - * with public access modifiers. - */ - function cast(map) { - return map; - } - /** - * Returns the encoded (VLQ string) form of the SourceMap's mappings field. - */ - function encodedMappings(map) { - var _a; - var _b; - return ((_a = (_b = cast(map))._encoded) !== null && _a !== void 0 ? _a : (_b._encoded = sourcemapCodec.encode(cast(map)._decoded))); - } - /** - * Returns the decoded (array of lines of segments) form of the SourceMap's mappings field. - */ - function decodedMappings(map) { - var _a; - return ((_a = cast(map))._decoded || (_a._decoded = sourcemapCodec.decode(cast(map)._encoded))); - } - /** - * A low-level API to find the segment associated with a generated line/column (think, from a - * stack trace). Line and column here are 0-based, unlike `originalPositionFor`. - */ - function traceSegment(map, line, column) { - const decoded = decodedMappings(map); - // It's common for parent source maps to have pointers to lines that have no - // mapping (like a "//# sourceMappingURL=") at the end of the child file. - if (line >= decoded.length) - return null; - const segments = decoded[line]; - const index = traceSegmentInternal(segments, cast(map)._decodedMemo, line, column, GREATEST_LOWER_BOUND); - return index === -1 ? null : segments[index]; - } - /** - * A higher-level API to find the source/line/column associated with a generated line/column - * (think, from a stack trace). Line is 1-based, but column is 0-based, due to legacy behavior in - * `source-map` library. - */ - function originalPositionFor(map, needle) { - let { line, column, bias } = needle; - line--; - if (line < 0) - throw new Error(LINE_GTR_ZERO); - if (column < 0) - throw new Error(COL_GTR_EQ_ZERO); - const decoded = decodedMappings(map); - // It's common for parent source maps to have pointers to lines that have no - // mapping (like a "//# sourceMappingURL=") at the end of the child file. - if (line >= decoded.length) - return OMapping(null, null, null, null); - const segments = decoded[line]; - const index = traceSegmentInternal(segments, cast(map)._decodedMemo, line, column, bias || GREATEST_LOWER_BOUND); - if (index === -1) - return OMapping(null, null, null, null); - const segment = segments[index]; - if (segment.length === 1) - return OMapping(null, null, null, null); - const { names, resolvedSources } = map; - return OMapping(resolvedSources[segment[SOURCES_INDEX]], segment[SOURCE_LINE] + 1, segment[SOURCE_COLUMN], segment.length === 5 ? names[segment[NAMES_INDEX]] : null); - } - /** - * Finds the generated line/column position of the provided source/line/column source position. - */ - function generatedPositionFor(map, needle) { - const { source, line, column, bias } = needle; - return generatedPosition(map, source, line, column, bias || GREATEST_LOWER_BOUND, false); - } - /** - * Finds all generated line/column positions of the provided source/line/column source position. - */ - function allGeneratedPositionsFor(map, needle) { - const { source, line, column, bias } = needle; - // SourceMapConsumer uses LEAST_UPPER_BOUND for some reason, so we follow suit. - return generatedPosition(map, source, line, column, bias || LEAST_UPPER_BOUND, true); - } - /** - * Iterates each mapping in generated position order. - */ - function eachMapping(map, cb) { - const decoded = decodedMappings(map); - const { names, resolvedSources } = map; - for (let i = 0; i < decoded.length; i++) { - const line = decoded[i]; - for (let j = 0; j < line.length; j++) { - const seg = line[j]; - const generatedLine = i + 1; - const generatedColumn = seg[0]; - let source = null; - let originalLine = null; - let originalColumn = null; - let name = null; - if (seg.length !== 1) { - source = resolvedSources[seg[1]]; - originalLine = seg[2] + 1; - originalColumn = seg[3]; - } - if (seg.length === 5) - name = names[seg[4]]; - cb({ - generatedLine, - generatedColumn, - source, - originalLine, - originalColumn, - name, - }); - } - } - } - function sourceIndex(map, source) { - const { sources, resolvedSources } = map; - let index = sources.indexOf(source); - if (index === -1) - index = resolvedSources.indexOf(source); - return index; - } - /** - * Retrieves the source content for a particular source, if its found. Returns null if not. - */ - function sourceContentFor(map, source) { - const { sourcesContent } = map; - if (sourcesContent == null) - return null; - const index = sourceIndex(map, source); - return index === -1 ? null : sourcesContent[index]; - } - /** - * Determines if the source is marked to ignore by the source map. - */ - function isIgnored(map, source) { - const { ignoreList } = map; - if (ignoreList == null) - return false; - const index = sourceIndex(map, source); - return index === -1 ? false : ignoreList.includes(index); - } - /** - * A helper that skips sorting of the input map's mappings array, which can be expensive for larger - * maps. - */ - function presortedDecodedMap(map, mapUrl) { - const tracer = new TraceMap(clone(map, []), mapUrl); - cast(tracer)._decoded = map.mappings; - return tracer; - } - /** - * Returns a sourcemap object (with decoded mappings) suitable for passing to a library that expects - * a sourcemap, or to JSON.stringify. - */ - function decodedMap(map) { - return clone(map, decodedMappings(map)); - } - /** - * Returns a sourcemap object (with encoded mappings) suitable for passing to a library that expects - * a sourcemap, or to JSON.stringify. - */ - function encodedMap(map) { - return clone(map, encodedMappings(map)); - } - function clone(map, mappings) { - return { - version: map.version, - file: map.file, - names: map.names, - sourceRoot: map.sourceRoot, - sources: map.sources, - sourcesContent: map.sourcesContent, - mappings, - ignoreList: map.ignoreList || map.x_google_ignoreList, - }; - } - function OMapping(source, line, column, name) { - return { source, line, column, name }; - } - function GMapping(line, column) { - return { line, column }; - } - function traceSegmentInternal(segments, memo, line, column, bias) { - let index = memoizedBinarySearch(segments, column, memo, line); - if (found) { - index = (bias === LEAST_UPPER_BOUND ? upperBound : lowerBound)(segments, column, index); - } - else if (bias === LEAST_UPPER_BOUND) - index++; - if (index === -1 || index === segments.length) - return -1; - return index; - } - function sliceGeneratedPositions(segments, memo, line, column, bias) { - let min = traceSegmentInternal(segments, memo, line, column, GREATEST_LOWER_BOUND); - // We ignored the bias when tracing the segment so that we're guarnateed to find the first (in - // insertion order) segment that matched. Even if we did respect the bias when tracing, we would - // still need to call `lowerBound()` to find the first segment, which is slower than just looking - // for the GREATEST_LOWER_BOUND to begin with. The only difference that matters for us is when the - // binary search didn't match, in which case GREATEST_LOWER_BOUND just needs to increment to - // match LEAST_UPPER_BOUND. - if (!found && bias === LEAST_UPPER_BOUND) - min++; - if (min === -1 || min === segments.length) - return []; - // We may have found the segment that started at an earlier column. If this is the case, then we - // need to slice all generated segments that match _that_ column, because all such segments span - // to our desired column. - const matchedColumn = found ? column : segments[min][COLUMN]; - // The binary search is not guaranteed to find the lower bound when a match wasn't found. - if (!found) - min = lowerBound(segments, matchedColumn, min); - const max = upperBound(segments, matchedColumn, min); - const result = []; - for (; min <= max; min++) { - const segment = segments[min]; - result.push(GMapping(segment[REV_GENERATED_LINE] + 1, segment[REV_GENERATED_COLUMN])); - } - return result; - } - function generatedPosition(map, source, line, column, bias, all) { - var _a; - line--; - if (line < 0) - throw new Error(LINE_GTR_ZERO); - if (column < 0) - throw new Error(COL_GTR_EQ_ZERO); - const { sources, resolvedSources } = map; - let sourceIndex = sources.indexOf(source); - if (sourceIndex === -1) - sourceIndex = resolvedSources.indexOf(source); - if (sourceIndex === -1) - return all ? [] : GMapping(null, null); - const generated = ((_a = cast(map))._bySources || (_a._bySources = buildBySources(decodedMappings(map), (cast(map)._bySourceMemos = sources.map(memoizedState))))); - const segments = generated[sourceIndex][line]; - if (segments == null) - return all ? [] : GMapping(null, null); - const memo = cast(map)._bySourceMemos[sourceIndex]; - if (all) - return sliceGeneratedPositions(segments, memo, line, column, bias); - const index = traceSegmentInternal(segments, memo, line, column, bias); - if (index === -1) - return GMapping(null, null); - const segment = segments[index]; - return GMapping(segment[REV_GENERATED_LINE] + 1, segment[REV_GENERATED_COLUMN]); - } - - exports.AnyMap = AnyMap; - exports.GREATEST_LOWER_BOUND = GREATEST_LOWER_BOUND; - exports.LEAST_UPPER_BOUND = LEAST_UPPER_BOUND; - exports.TraceMap = TraceMap; - exports.allGeneratedPositionsFor = allGeneratedPositionsFor; - exports.decodedMap = decodedMap; - exports.decodedMappings = decodedMappings; - exports.eachMapping = eachMapping; - exports.encodedMap = encodedMap; - exports.encodedMappings = encodedMappings; - exports.generatedPositionFor = generatedPositionFor; - exports.isIgnored = isIgnored; - exports.originalPositionFor = originalPositionFor; - exports.presortedDecodedMap = presortedDecodedMap; - exports.sourceContentFor = sourceContentFor; - exports.traceSegment = traceSegment; - -})); -//# sourceMappingURL=trace-mapping.umd.js.map diff --git a/tools/eslint/node_modules/@jridgewell/trace-mapping/package.json b/tools/eslint/node_modules/@jridgewell/trace-mapping/package.json deleted file mode 100644 index 454a1bdbe09cc0..00000000000000 --- a/tools/eslint/node_modules/@jridgewell/trace-mapping/package.json +++ /dev/null @@ -1,77 +0,0 @@ -{ - "name": "@jridgewell/trace-mapping", - "version": "0.3.25", - "description": "Trace the original position through a source map", - "keywords": [ - "source", - "map" - ], - "main": "dist/trace-mapping.umd.js", - "module": "dist/trace-mapping.mjs", - "types": "dist/types/trace-mapping.d.ts", - "files": [ - "dist" - ], - "exports": { - ".": [ - { - "types": "./dist/types/trace-mapping.d.ts", - "browser": "./dist/trace-mapping.umd.js", - "require": "./dist/trace-mapping.umd.js", - "import": "./dist/trace-mapping.mjs" - }, - "./dist/trace-mapping.umd.js" - ], - "./package.json": "./package.json" - }, - "author": "Justin Ridgewell ", - "repository": { - "type": "git", - "url": "git+https://github.com/jridgewell/trace-mapping.git" - }, - "license": "MIT", - "scripts": { - "benchmark": "run-s build:rollup benchmark:*", - "benchmark:install": "cd benchmark && npm install", - "benchmark:only": "node --expose-gc benchmark/index.mjs", - "build": "run-s -n build:*", - "build:rollup": "rollup -c rollup.config.mjs", - "build:ts": "tsc --project tsconfig.build.json", - "lint": "run-s -n lint:*", - "lint:prettier": "npm run test:lint:prettier -- --write", - "lint:ts": "npm run test:lint:ts -- --fix", - "prebuild": "rm -rf dist", - "prepublishOnly": "npm run preversion", - "preversion": "run-s test build", - "test": "run-s -n test:lint test:only", - "test:debug": "mocha --inspect-brk", - "test:lint": "run-s -n test:lint:*", - "test:lint:prettier": "prettier --check '{src,test}/**/*.ts' '**/*.md'", - "test:lint:ts": "eslint '{src,test}/**/*.ts'", - "test:only": "c8 mocha", - "test:watch": "mocha --watch" - }, - "devDependencies": { - "@rollup/plugin-typescript": "11.1.6", - "@types/mocha": "10.0.6", - "@types/node": "20.11.20", - "@typescript-eslint/eslint-plugin": "6.18.1", - "@typescript-eslint/parser": "6.18.1", - "benchmark": "2.1.4", - "c8": "9.0.0", - "esbuild": "0.19.11", - "eslint": "8.56.0", - "eslint-config-prettier": "9.1.0", - "eslint-plugin-no-only-tests": "3.1.0", - "mocha": "10.3.0", - "npm-run-all": "4.1.5", - "prettier": "3.1.1", - "rollup": "4.9.4", - "tsx": "4.7.0", - "typescript": "5.3.3" - }, - "dependencies": { - "@jridgewell/resolve-uri": "^3.1.0", - "@jridgewell/sourcemap-codec": "^1.4.14" - } -} diff --git a/tools/eslint/node_modules/@nicolo-ribaudo/eslint-scope-5-internals/LICENSE b/tools/eslint/node_modules/@nicolo-ribaudo/eslint-scope-5-internals/LICENSE deleted file mode 100644 index 01ce2036bbd848..00000000000000 --- a/tools/eslint/node_modules/@nicolo-ribaudo/eslint-scope-5-internals/LICENSE +++ /dev/null @@ -1,7 +0,0 @@ -Copyright 2022 Nicolรฒ Ribaudo - -Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. \ No newline at end of file diff --git a/tools/eslint/node_modules/@nicolo-ribaudo/eslint-scope-5-internals/index.js b/tools/eslint/node_modules/@nicolo-ribaudo/eslint-scope-5-internals/index.js deleted file mode 100644 index 0ff6afc6a4c9a0..00000000000000 --- a/tools/eslint/node_modules/@nicolo-ribaudo/eslint-scope-5-internals/index.js +++ /dev/null @@ -1,8 +0,0 @@ -"use strict"; - -module.exports = { - ...require("eslint-scope"), - Definition: require("eslint-scope/lib/definition").Definition, - PatternVisitor: require("eslint-scope/lib/pattern-visitor"), - Referencer: require("eslint-scope/lib/referencer"), -}; diff --git a/tools/eslint/node_modules/@nicolo-ribaudo/eslint-scope-5-internals/package.json b/tools/eslint/node_modules/@nicolo-ribaudo/eslint-scope-5-internals/package.json deleted file mode 100644 index 8932502dfb448a..00000000000000 --- a/tools/eslint/node_modules/@nicolo-ribaudo/eslint-scope-5-internals/package.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "name": "@nicolo-ribaudo/eslint-scope-5-internals", - "version": "5.1.1-v1", - "description": "Proxy package exposing internals of eslint-scope@5 for @babel/eslint-parser", - "main": "index.js", - "dependencies": { - "eslint-scope": "5.1.1" - }, - "license": "MIT", - "type": "commonjs", - "publishConfig": { - "access": "public" - } -} diff --git a/tools/eslint/node_modules/@nodelib/fs.scandir/LICENSE b/tools/eslint/node_modules/@nodelib/fs.scandir/LICENSE deleted file mode 100644 index 65a99946017035..00000000000000 --- a/tools/eslint/node_modules/@nodelib/fs.scandir/LICENSE +++ /dev/null @@ -1,21 +0,0 @@ -The MIT License (MIT) - -Copyright (c) Denis Malinochkin - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. diff --git a/tools/eslint/node_modules/@nodelib/fs.scandir/out/adapters/fs.js b/tools/eslint/node_modules/@nodelib/fs.scandir/out/adapters/fs.js deleted file mode 100644 index f0fe022023e6df..00000000000000 --- a/tools/eslint/node_modules/@nodelib/fs.scandir/out/adapters/fs.js +++ /dev/null @@ -1,19 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.createFileSystemAdapter = exports.FILE_SYSTEM_ADAPTER = void 0; -const fs = require("fs"); -exports.FILE_SYSTEM_ADAPTER = { - lstat: fs.lstat, - stat: fs.stat, - lstatSync: fs.lstatSync, - statSync: fs.statSync, - readdir: fs.readdir, - readdirSync: fs.readdirSync -}; -function createFileSystemAdapter(fsMethods) { - if (fsMethods === undefined) { - return exports.FILE_SYSTEM_ADAPTER; - } - return Object.assign(Object.assign({}, exports.FILE_SYSTEM_ADAPTER), fsMethods); -} -exports.createFileSystemAdapter = createFileSystemAdapter; diff --git a/tools/eslint/node_modules/@nodelib/fs.scandir/out/constants.js b/tools/eslint/node_modules/@nodelib/fs.scandir/out/constants.js deleted file mode 100644 index 7e3d4411f751e1..00000000000000 --- a/tools/eslint/node_modules/@nodelib/fs.scandir/out/constants.js +++ /dev/null @@ -1,17 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.IS_SUPPORT_READDIR_WITH_FILE_TYPES = void 0; -const NODE_PROCESS_VERSION_PARTS = process.versions.node.split('.'); -if (NODE_PROCESS_VERSION_PARTS[0] === undefined || NODE_PROCESS_VERSION_PARTS[1] === undefined) { - throw new Error(`Unexpected behavior. The 'process.versions.node' variable has invalid value: ${process.versions.node}`); -} -const MAJOR_VERSION = Number.parseInt(NODE_PROCESS_VERSION_PARTS[0], 10); -const MINOR_VERSION = Number.parseInt(NODE_PROCESS_VERSION_PARTS[1], 10); -const SUPPORTED_MAJOR_VERSION = 10; -const SUPPORTED_MINOR_VERSION = 10; -const IS_MATCHED_BY_MAJOR = MAJOR_VERSION > SUPPORTED_MAJOR_VERSION; -const IS_MATCHED_BY_MAJOR_AND_MINOR = MAJOR_VERSION === SUPPORTED_MAJOR_VERSION && MINOR_VERSION >= SUPPORTED_MINOR_VERSION; -/** - * IS `true` for Node.js 10.10 and greater. - */ -exports.IS_SUPPORT_READDIR_WITH_FILE_TYPES = IS_MATCHED_BY_MAJOR || IS_MATCHED_BY_MAJOR_AND_MINOR; diff --git a/tools/eslint/node_modules/@nodelib/fs.scandir/out/index.js b/tools/eslint/node_modules/@nodelib/fs.scandir/out/index.js deleted file mode 100644 index 99c70d3d635f73..00000000000000 --- a/tools/eslint/node_modules/@nodelib/fs.scandir/out/index.js +++ /dev/null @@ -1,26 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.Settings = exports.scandirSync = exports.scandir = void 0; -const async = require("./providers/async"); -const sync = require("./providers/sync"); -const settings_1 = require("./settings"); -exports.Settings = settings_1.default; -function scandir(path, optionsOrSettingsOrCallback, callback) { - if (typeof optionsOrSettingsOrCallback === 'function') { - async.read(path, getSettings(), optionsOrSettingsOrCallback); - return; - } - async.read(path, getSettings(optionsOrSettingsOrCallback), callback); -} -exports.scandir = scandir; -function scandirSync(path, optionsOrSettings) { - const settings = getSettings(optionsOrSettings); - return sync.read(path, settings); -} -exports.scandirSync = scandirSync; -function getSettings(settingsOrOptions = {}) { - if (settingsOrOptions instanceof settings_1.default) { - return settingsOrOptions; - } - return new settings_1.default(settingsOrOptions); -} diff --git a/tools/eslint/node_modules/@nodelib/fs.scandir/out/providers/async.js b/tools/eslint/node_modules/@nodelib/fs.scandir/out/providers/async.js deleted file mode 100644 index e8e2f0a9cba94e..00000000000000 --- a/tools/eslint/node_modules/@nodelib/fs.scandir/out/providers/async.js +++ /dev/null @@ -1,104 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.readdir = exports.readdirWithFileTypes = exports.read = void 0; -const fsStat = require("@nodelib/fs.stat"); -const rpl = require("run-parallel"); -const constants_1 = require("../constants"); -const utils = require("../utils"); -const common = require("./common"); -function read(directory, settings, callback) { - if (!settings.stats && constants_1.IS_SUPPORT_READDIR_WITH_FILE_TYPES) { - readdirWithFileTypes(directory, settings, callback); - return; - } - readdir(directory, settings, callback); -} -exports.read = read; -function readdirWithFileTypes(directory, settings, callback) { - settings.fs.readdir(directory, { withFileTypes: true }, (readdirError, dirents) => { - if (readdirError !== null) { - callFailureCallback(callback, readdirError); - return; - } - const entries = dirents.map((dirent) => ({ - dirent, - name: dirent.name, - path: common.joinPathSegments(directory, dirent.name, settings.pathSegmentSeparator) - })); - if (!settings.followSymbolicLinks) { - callSuccessCallback(callback, entries); - return; - } - const tasks = entries.map((entry) => makeRplTaskEntry(entry, settings)); - rpl(tasks, (rplError, rplEntries) => { - if (rplError !== null) { - callFailureCallback(callback, rplError); - return; - } - callSuccessCallback(callback, rplEntries); - }); - }); -} -exports.readdirWithFileTypes = readdirWithFileTypes; -function makeRplTaskEntry(entry, settings) { - return (done) => { - if (!entry.dirent.isSymbolicLink()) { - done(null, entry); - return; - } - settings.fs.stat(entry.path, (statError, stats) => { - if (statError !== null) { - if (settings.throwErrorOnBrokenSymbolicLink) { - done(statError); - return; - } - done(null, entry); - return; - } - entry.dirent = utils.fs.createDirentFromStats(entry.name, stats); - done(null, entry); - }); - }; -} -function readdir(directory, settings, callback) { - settings.fs.readdir(directory, (readdirError, names) => { - if (readdirError !== null) { - callFailureCallback(callback, readdirError); - return; - } - const tasks = names.map((name) => { - const path = common.joinPathSegments(directory, name, settings.pathSegmentSeparator); - return (done) => { - fsStat.stat(path, settings.fsStatSettings, (error, stats) => { - if (error !== null) { - done(error); - return; - } - const entry = { - name, - path, - dirent: utils.fs.createDirentFromStats(name, stats) - }; - if (settings.stats) { - entry.stats = stats; - } - done(null, entry); - }); - }; - }); - rpl(tasks, (rplError, entries) => { - if (rplError !== null) { - callFailureCallback(callback, rplError); - return; - } - callSuccessCallback(callback, entries); - }); - }); -} -exports.readdir = readdir; -function callFailureCallback(callback, error) { - callback(error); -} -function callSuccessCallback(callback, result) { - callback(null, result); -} diff --git a/tools/eslint/node_modules/@nodelib/fs.scandir/out/providers/common.js b/tools/eslint/node_modules/@nodelib/fs.scandir/out/providers/common.js deleted file mode 100644 index 8724cb59afe97c..00000000000000 --- a/tools/eslint/node_modules/@nodelib/fs.scandir/out/providers/common.js +++ /dev/null @@ -1,13 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.joinPathSegments = void 0; -function joinPathSegments(a, b, separator) { - /** - * The correct handling of cases when the first segment is a root (`/`, `C:/`) or UNC path (`//?/C:/`). - */ - if (a.endsWith(separator)) { - return a + b; - } - return a + separator + b; -} -exports.joinPathSegments = joinPathSegments; diff --git a/tools/eslint/node_modules/@nodelib/fs.scandir/out/providers/sync.js b/tools/eslint/node_modules/@nodelib/fs.scandir/out/providers/sync.js deleted file mode 100644 index 146db3434f4225..00000000000000 --- a/tools/eslint/node_modules/@nodelib/fs.scandir/out/providers/sync.js +++ /dev/null @@ -1,54 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.readdir = exports.readdirWithFileTypes = exports.read = void 0; -const fsStat = require("@nodelib/fs.stat"); -const constants_1 = require("../constants"); -const utils = require("../utils"); -const common = require("./common"); -function read(directory, settings) { - if (!settings.stats && constants_1.IS_SUPPORT_READDIR_WITH_FILE_TYPES) { - return readdirWithFileTypes(directory, settings); - } - return readdir(directory, settings); -} -exports.read = read; -function readdirWithFileTypes(directory, settings) { - const dirents = settings.fs.readdirSync(directory, { withFileTypes: true }); - return dirents.map((dirent) => { - const entry = { - dirent, - name: dirent.name, - path: common.joinPathSegments(directory, dirent.name, settings.pathSegmentSeparator) - }; - if (entry.dirent.isSymbolicLink() && settings.followSymbolicLinks) { - try { - const stats = settings.fs.statSync(entry.path); - entry.dirent = utils.fs.createDirentFromStats(entry.name, stats); - } - catch (error) { - if (settings.throwErrorOnBrokenSymbolicLink) { - throw error; - } - } - } - return entry; - }); -} -exports.readdirWithFileTypes = readdirWithFileTypes; -function readdir(directory, settings) { - const names = settings.fs.readdirSync(directory); - return names.map((name) => { - const entryPath = common.joinPathSegments(directory, name, settings.pathSegmentSeparator); - const stats = fsStat.statSync(entryPath, settings.fsStatSettings); - const entry = { - name, - path: entryPath, - dirent: utils.fs.createDirentFromStats(name, stats) - }; - if (settings.stats) { - entry.stats = stats; - } - return entry; - }); -} -exports.readdir = readdir; diff --git a/tools/eslint/node_modules/@nodelib/fs.scandir/out/settings.js b/tools/eslint/node_modules/@nodelib/fs.scandir/out/settings.js deleted file mode 100644 index 15a3e8cde7704a..00000000000000 --- a/tools/eslint/node_modules/@nodelib/fs.scandir/out/settings.js +++ /dev/null @@ -1,24 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -const path = require("path"); -const fsStat = require("@nodelib/fs.stat"); -const fs = require("./adapters/fs"); -class Settings { - constructor(_options = {}) { - this._options = _options; - this.followSymbolicLinks = this._getValue(this._options.followSymbolicLinks, false); - this.fs = fs.createFileSystemAdapter(this._options.fs); - this.pathSegmentSeparator = this._getValue(this._options.pathSegmentSeparator, path.sep); - this.stats = this._getValue(this._options.stats, false); - this.throwErrorOnBrokenSymbolicLink = this._getValue(this._options.throwErrorOnBrokenSymbolicLink, true); - this.fsStatSettings = new fsStat.Settings({ - followSymbolicLink: this.followSymbolicLinks, - fs: this.fs, - throwErrorOnBrokenSymbolicLink: this.throwErrorOnBrokenSymbolicLink - }); - } - _getValue(option, value) { - return option !== null && option !== void 0 ? option : value; - } -} -exports.default = Settings; diff --git a/tools/eslint/node_modules/@nodelib/fs.scandir/out/types/index.js b/tools/eslint/node_modules/@nodelib/fs.scandir/out/types/index.js deleted file mode 100644 index c8ad2e549bdc68..00000000000000 --- a/tools/eslint/node_modules/@nodelib/fs.scandir/out/types/index.js +++ /dev/null @@ -1,2 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); diff --git a/tools/eslint/node_modules/@nodelib/fs.scandir/out/utils/fs.js b/tools/eslint/node_modules/@nodelib/fs.scandir/out/utils/fs.js deleted file mode 100644 index ace7c74d63f6da..00000000000000 --- a/tools/eslint/node_modules/@nodelib/fs.scandir/out/utils/fs.js +++ /dev/null @@ -1,19 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.createDirentFromStats = void 0; -class DirentFromStats { - constructor(name, stats) { - this.name = name; - this.isBlockDevice = stats.isBlockDevice.bind(stats); - this.isCharacterDevice = stats.isCharacterDevice.bind(stats); - this.isDirectory = stats.isDirectory.bind(stats); - this.isFIFO = stats.isFIFO.bind(stats); - this.isFile = stats.isFile.bind(stats); - this.isSocket = stats.isSocket.bind(stats); - this.isSymbolicLink = stats.isSymbolicLink.bind(stats); - } -} -function createDirentFromStats(name, stats) { - return new DirentFromStats(name, stats); -} -exports.createDirentFromStats = createDirentFromStats; diff --git a/tools/eslint/node_modules/@nodelib/fs.scandir/out/utils/index.js b/tools/eslint/node_modules/@nodelib/fs.scandir/out/utils/index.js deleted file mode 100644 index f5de129f47b803..00000000000000 --- a/tools/eslint/node_modules/@nodelib/fs.scandir/out/utils/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.fs = void 0; -const fs = require("./fs"); -exports.fs = fs; diff --git a/tools/eslint/node_modules/@nodelib/fs.scandir/package.json b/tools/eslint/node_modules/@nodelib/fs.scandir/package.json deleted file mode 100644 index d3a89241b3c189..00000000000000 --- a/tools/eslint/node_modules/@nodelib/fs.scandir/package.json +++ /dev/null @@ -1,44 +0,0 @@ -{ - "name": "@nodelib/fs.scandir", - "version": "2.1.5", - "description": "List files and directories inside the specified directory", - "license": "MIT", - "repository": "https://github.com/nodelib/nodelib/tree/master/packages/fs/fs.scandir", - "keywords": [ - "NodeLib", - "fs", - "FileSystem", - "file system", - "scandir", - "readdir", - "dirent" - ], - "engines": { - "node": ">= 8" - }, - "files": [ - "out/**", - "!out/**/*.map", - "!out/**/*.spec.*" - ], - "main": "out/index.js", - "typings": "out/index.d.ts", - "scripts": { - "clean": "rimraf {tsconfig.tsbuildinfo,out}", - "lint": "eslint \"src/**/*.ts\" --cache", - "compile": "tsc -b .", - "compile:watch": "tsc -p . --watch --sourceMap", - "test": "mocha \"out/**/*.spec.js\" -s 0", - "build": "npm run clean && npm run compile && npm run lint && npm test", - "watch": "npm run clean && npm run compile:watch" - }, - "dependencies": { - "@nodelib/fs.stat": "2.0.5", - "run-parallel": "^1.1.9" - }, - "devDependencies": { - "@nodelib/fs.macchiato": "1.0.4", - "@types/run-parallel": "^1.1.0" - }, - "gitHead": "d6a7960d5281d3dd5f8e2efba49bb552d090f562" -} diff --git a/tools/eslint/node_modules/@nodelib/fs.stat/LICENSE b/tools/eslint/node_modules/@nodelib/fs.stat/LICENSE deleted file mode 100644 index 65a99946017035..00000000000000 --- a/tools/eslint/node_modules/@nodelib/fs.stat/LICENSE +++ /dev/null @@ -1,21 +0,0 @@ -The MIT License (MIT) - -Copyright (c) Denis Malinochkin - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. diff --git a/tools/eslint/node_modules/@nodelib/fs.stat/out/adapters/fs.js b/tools/eslint/node_modules/@nodelib/fs.stat/out/adapters/fs.js deleted file mode 100644 index 8dc08c8ca1f1c7..00000000000000 --- a/tools/eslint/node_modules/@nodelib/fs.stat/out/adapters/fs.js +++ /dev/null @@ -1,17 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.createFileSystemAdapter = exports.FILE_SYSTEM_ADAPTER = void 0; -const fs = require("fs"); -exports.FILE_SYSTEM_ADAPTER = { - lstat: fs.lstat, - stat: fs.stat, - lstatSync: fs.lstatSync, - statSync: fs.statSync -}; -function createFileSystemAdapter(fsMethods) { - if (fsMethods === undefined) { - return exports.FILE_SYSTEM_ADAPTER; - } - return Object.assign(Object.assign({}, exports.FILE_SYSTEM_ADAPTER), fsMethods); -} -exports.createFileSystemAdapter = createFileSystemAdapter; diff --git a/tools/eslint/node_modules/@nodelib/fs.stat/out/index.js b/tools/eslint/node_modules/@nodelib/fs.stat/out/index.js deleted file mode 100644 index b23f7510d050fe..00000000000000 --- a/tools/eslint/node_modules/@nodelib/fs.stat/out/index.js +++ /dev/null @@ -1,26 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.statSync = exports.stat = exports.Settings = void 0; -const async = require("./providers/async"); -const sync = require("./providers/sync"); -const settings_1 = require("./settings"); -exports.Settings = settings_1.default; -function stat(path, optionsOrSettingsOrCallback, callback) { - if (typeof optionsOrSettingsOrCallback === 'function') { - async.read(path, getSettings(), optionsOrSettingsOrCallback); - return; - } - async.read(path, getSettings(optionsOrSettingsOrCallback), callback); -} -exports.stat = stat; -function statSync(path, optionsOrSettings) { - const settings = getSettings(optionsOrSettings); - return sync.read(path, settings); -} -exports.statSync = statSync; -function getSettings(settingsOrOptions = {}) { - if (settingsOrOptions instanceof settings_1.default) { - return settingsOrOptions; - } - return new settings_1.default(settingsOrOptions); -} diff --git a/tools/eslint/node_modules/@nodelib/fs.stat/out/providers/async.js b/tools/eslint/node_modules/@nodelib/fs.stat/out/providers/async.js deleted file mode 100644 index 983ff0e6cb79f6..00000000000000 --- a/tools/eslint/node_modules/@nodelib/fs.stat/out/providers/async.js +++ /dev/null @@ -1,36 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.read = void 0; -function read(path, settings, callback) { - settings.fs.lstat(path, (lstatError, lstat) => { - if (lstatError !== null) { - callFailureCallback(callback, lstatError); - return; - } - if (!lstat.isSymbolicLink() || !settings.followSymbolicLink) { - callSuccessCallback(callback, lstat); - return; - } - settings.fs.stat(path, (statError, stat) => { - if (statError !== null) { - if (settings.throwErrorOnBrokenSymbolicLink) { - callFailureCallback(callback, statError); - return; - } - callSuccessCallback(callback, lstat); - return; - } - if (settings.markSymbolicLink) { - stat.isSymbolicLink = () => true; - } - callSuccessCallback(callback, stat); - }); - }); -} -exports.read = read; -function callFailureCallback(callback, error) { - callback(error); -} -function callSuccessCallback(callback, result) { - callback(null, result); -} diff --git a/tools/eslint/node_modules/@nodelib/fs.stat/out/providers/sync.js b/tools/eslint/node_modules/@nodelib/fs.stat/out/providers/sync.js deleted file mode 100644 index 1521c3616eaee4..00000000000000 --- a/tools/eslint/node_modules/@nodelib/fs.stat/out/providers/sync.js +++ /dev/null @@ -1,23 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.read = void 0; -function read(path, settings) { - const lstat = settings.fs.lstatSync(path); - if (!lstat.isSymbolicLink() || !settings.followSymbolicLink) { - return lstat; - } - try { - const stat = settings.fs.statSync(path); - if (settings.markSymbolicLink) { - stat.isSymbolicLink = () => true; - } - return stat; - } - catch (error) { - if (!settings.throwErrorOnBrokenSymbolicLink) { - return lstat; - } - throw error; - } -} -exports.read = read; diff --git a/tools/eslint/node_modules/@nodelib/fs.stat/out/settings.js b/tools/eslint/node_modules/@nodelib/fs.stat/out/settings.js deleted file mode 100644 index 111ec09ca6491a..00000000000000 --- a/tools/eslint/node_modules/@nodelib/fs.stat/out/settings.js +++ /dev/null @@ -1,16 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -const fs = require("./adapters/fs"); -class Settings { - constructor(_options = {}) { - this._options = _options; - this.followSymbolicLink = this._getValue(this._options.followSymbolicLink, true); - this.fs = fs.createFileSystemAdapter(this._options.fs); - this.markSymbolicLink = this._getValue(this._options.markSymbolicLink, false); - this.throwErrorOnBrokenSymbolicLink = this._getValue(this._options.throwErrorOnBrokenSymbolicLink, true); - } - _getValue(option, value) { - return option !== null && option !== void 0 ? option : value; - } -} -exports.default = Settings; diff --git a/tools/eslint/node_modules/@nodelib/fs.stat/out/types/index.js b/tools/eslint/node_modules/@nodelib/fs.stat/out/types/index.js deleted file mode 100644 index c8ad2e549bdc68..00000000000000 --- a/tools/eslint/node_modules/@nodelib/fs.stat/out/types/index.js +++ /dev/null @@ -1,2 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); diff --git a/tools/eslint/node_modules/@nodelib/fs.stat/package.json b/tools/eslint/node_modules/@nodelib/fs.stat/package.json deleted file mode 100644 index f2540c2894ea91..00000000000000 --- a/tools/eslint/node_modules/@nodelib/fs.stat/package.json +++ /dev/null @@ -1,37 +0,0 @@ -{ - "name": "@nodelib/fs.stat", - "version": "2.0.5", - "description": "Get the status of a file with some features", - "license": "MIT", - "repository": "https://github.com/nodelib/nodelib/tree/master/packages/fs/fs.stat", - "keywords": [ - "NodeLib", - "fs", - "FileSystem", - "file system", - "stat" - ], - "engines": { - "node": ">= 8" - }, - "files": [ - "out/**", - "!out/**/*.map", - "!out/**/*.spec.*" - ], - "main": "out/index.js", - "typings": "out/index.d.ts", - "scripts": { - "clean": "rimraf {tsconfig.tsbuildinfo,out}", - "lint": "eslint \"src/**/*.ts\" --cache", - "compile": "tsc -b .", - "compile:watch": "tsc -p . --watch --sourceMap", - "test": "mocha \"out/**/*.spec.js\" -s 0", - "build": "npm run clean && npm run compile && npm run lint && npm test", - "watch": "npm run clean && npm run compile:watch" - }, - "devDependencies": { - "@nodelib/fs.macchiato": "1.0.4" - }, - "gitHead": "d6a7960d5281d3dd5f8e2efba49bb552d090f562" -} diff --git a/tools/eslint/node_modules/@nodelib/fs.walk/LICENSE b/tools/eslint/node_modules/@nodelib/fs.walk/LICENSE deleted file mode 100644 index 65a99946017035..00000000000000 --- a/tools/eslint/node_modules/@nodelib/fs.walk/LICENSE +++ /dev/null @@ -1,21 +0,0 @@ -The MIT License (MIT) - -Copyright (c) Denis Malinochkin - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. diff --git a/tools/eslint/node_modules/@nodelib/fs.walk/out/index.js b/tools/eslint/node_modules/@nodelib/fs.walk/out/index.js deleted file mode 100644 index 15207874afa1da..00000000000000 --- a/tools/eslint/node_modules/@nodelib/fs.walk/out/index.js +++ /dev/null @@ -1,34 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.Settings = exports.walkStream = exports.walkSync = exports.walk = void 0; -const async_1 = require("./providers/async"); -const stream_1 = require("./providers/stream"); -const sync_1 = require("./providers/sync"); -const settings_1 = require("./settings"); -exports.Settings = settings_1.default; -function walk(directory, optionsOrSettingsOrCallback, callback) { - if (typeof optionsOrSettingsOrCallback === 'function') { - new async_1.default(directory, getSettings()).read(optionsOrSettingsOrCallback); - return; - } - new async_1.default(directory, getSettings(optionsOrSettingsOrCallback)).read(callback); -} -exports.walk = walk; -function walkSync(directory, optionsOrSettings) { - const settings = getSettings(optionsOrSettings); - const provider = new sync_1.default(directory, settings); - return provider.read(); -} -exports.walkSync = walkSync; -function walkStream(directory, optionsOrSettings) { - const settings = getSettings(optionsOrSettings); - const provider = new stream_1.default(directory, settings); - return provider.read(); -} -exports.walkStream = walkStream; -function getSettings(settingsOrOptions = {}) { - if (settingsOrOptions instanceof settings_1.default) { - return settingsOrOptions; - } - return new settings_1.default(settingsOrOptions); -} diff --git a/tools/eslint/node_modules/@nodelib/fs.walk/out/providers/async.js b/tools/eslint/node_modules/@nodelib/fs.walk/out/providers/async.js deleted file mode 100644 index 51d3be51a85d46..00000000000000 --- a/tools/eslint/node_modules/@nodelib/fs.walk/out/providers/async.js +++ /dev/null @@ -1,30 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -const async_1 = require("../readers/async"); -class AsyncProvider { - constructor(_root, _settings) { - this._root = _root; - this._settings = _settings; - this._reader = new async_1.default(this._root, this._settings); - this._storage = []; - } - read(callback) { - this._reader.onError((error) => { - callFailureCallback(callback, error); - }); - this._reader.onEntry((entry) => { - this._storage.push(entry); - }); - this._reader.onEnd(() => { - callSuccessCallback(callback, this._storage); - }); - this._reader.read(); - } -} -exports.default = AsyncProvider; -function callFailureCallback(callback, error) { - callback(error); -} -function callSuccessCallback(callback, entries) { - callback(null, entries); -} diff --git a/tools/eslint/node_modules/@nodelib/fs.walk/out/providers/index.js b/tools/eslint/node_modules/@nodelib/fs.walk/out/providers/index.js deleted file mode 100644 index 4c2529ce8a385a..00000000000000 --- a/tools/eslint/node_modules/@nodelib/fs.walk/out/providers/index.js +++ /dev/null @@ -1,9 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.SyncProvider = exports.StreamProvider = exports.AsyncProvider = void 0; -const async_1 = require("./async"); -exports.AsyncProvider = async_1.default; -const stream_1 = require("./stream"); -exports.StreamProvider = stream_1.default; -const sync_1 = require("./sync"); -exports.SyncProvider = sync_1.default; diff --git a/tools/eslint/node_modules/@nodelib/fs.walk/out/providers/stream.js b/tools/eslint/node_modules/@nodelib/fs.walk/out/providers/stream.js deleted file mode 100644 index 51298b0f58f14b..00000000000000 --- a/tools/eslint/node_modules/@nodelib/fs.walk/out/providers/stream.js +++ /dev/null @@ -1,34 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -const stream_1 = require("stream"); -const async_1 = require("../readers/async"); -class StreamProvider { - constructor(_root, _settings) { - this._root = _root; - this._settings = _settings; - this._reader = new async_1.default(this._root, this._settings); - this._stream = new stream_1.Readable({ - objectMode: true, - read: () => { }, - destroy: () => { - if (!this._reader.isDestroyed) { - this._reader.destroy(); - } - } - }); - } - read() { - this._reader.onError((error) => { - this._stream.emit('error', error); - }); - this._reader.onEntry((entry) => { - this._stream.push(entry); - }); - this._reader.onEnd(() => { - this._stream.push(null); - }); - this._reader.read(); - return this._stream; - } -} -exports.default = StreamProvider; diff --git a/tools/eslint/node_modules/@nodelib/fs.walk/out/providers/sync.js b/tools/eslint/node_modules/@nodelib/fs.walk/out/providers/sync.js deleted file mode 100644 index faab6ca2ad4262..00000000000000 --- a/tools/eslint/node_modules/@nodelib/fs.walk/out/providers/sync.js +++ /dev/null @@ -1,14 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -const sync_1 = require("../readers/sync"); -class SyncProvider { - constructor(_root, _settings) { - this._root = _root; - this._settings = _settings; - this._reader = new sync_1.default(this._root, this._settings); - } - read() { - return this._reader.read(); - } -} -exports.default = SyncProvider; diff --git a/tools/eslint/node_modules/@nodelib/fs.walk/out/readers/async.js b/tools/eslint/node_modules/@nodelib/fs.walk/out/readers/async.js deleted file mode 100644 index ebe8dd5735858b..00000000000000 --- a/tools/eslint/node_modules/@nodelib/fs.walk/out/readers/async.js +++ /dev/null @@ -1,97 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -const events_1 = require("events"); -const fsScandir = require("@nodelib/fs.scandir"); -const fastq = require("fastq"); -const common = require("./common"); -const reader_1 = require("./reader"); -class AsyncReader extends reader_1.default { - constructor(_root, _settings) { - super(_root, _settings); - this._settings = _settings; - this._scandir = fsScandir.scandir; - this._emitter = new events_1.EventEmitter(); - this._queue = fastq(this._worker.bind(this), this._settings.concurrency); - this._isFatalError = false; - this._isDestroyed = false; - this._queue.drain = () => { - if (!this._isFatalError) { - this._emitter.emit('end'); - } - }; - } - read() { - this._isFatalError = false; - this._isDestroyed = false; - setImmediate(() => { - this._pushToQueue(this._root, this._settings.basePath); - }); - return this._emitter; - } - get isDestroyed() { - return this._isDestroyed; - } - destroy() { - if (this._isDestroyed) { - throw new Error('The reader is already destroyed'); - } - this._isDestroyed = true; - this._queue.killAndDrain(); - } - onEntry(callback) { - this._emitter.on('entry', callback); - } - onError(callback) { - this._emitter.once('error', callback); - } - onEnd(callback) { - this._emitter.once('end', callback); - } - _pushToQueue(directory, base) { - const queueItem = { directory, base }; - this._queue.push(queueItem, (error) => { - if (error !== null) { - this._handleError(error); - } - }); - } - _worker(item, done) { - this._scandir(item.directory, this._settings.fsScandirSettings, (error, entries) => { - if (error !== null) { - done(error, undefined); - return; - } - for (const entry of entries) { - this._handleEntry(entry, item.base); - } - done(null, undefined); - }); - } - _handleError(error) { - if (this._isDestroyed || !common.isFatalError(this._settings, error)) { - return; - } - this._isFatalError = true; - this._isDestroyed = true; - this._emitter.emit('error', error); - } - _handleEntry(entry, base) { - if (this._isDestroyed || this._isFatalError) { - return; - } - const fullpath = entry.path; - if (base !== undefined) { - entry.path = common.joinPathSegments(base, entry.name, this._settings.pathSegmentSeparator); - } - if (common.isAppliedFilter(this._settings.entryFilter, entry)) { - this._emitEntry(entry); - } - if (entry.dirent.isDirectory() && common.isAppliedFilter(this._settings.deepFilter, entry)) { - this._pushToQueue(fullpath, base === undefined ? undefined : entry.path); - } - } - _emitEntry(entry) { - this._emitter.emit('entry', entry); - } -} -exports.default = AsyncReader; diff --git a/tools/eslint/node_modules/@nodelib/fs.walk/out/readers/common.js b/tools/eslint/node_modules/@nodelib/fs.walk/out/readers/common.js deleted file mode 100644 index a93572f48a79ec..00000000000000 --- a/tools/eslint/node_modules/@nodelib/fs.walk/out/readers/common.js +++ /dev/null @@ -1,31 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.joinPathSegments = exports.replacePathSegmentSeparator = exports.isAppliedFilter = exports.isFatalError = void 0; -function isFatalError(settings, error) { - if (settings.errorFilter === null) { - return true; - } - return !settings.errorFilter(error); -} -exports.isFatalError = isFatalError; -function isAppliedFilter(filter, value) { - return filter === null || filter(value); -} -exports.isAppliedFilter = isAppliedFilter; -function replacePathSegmentSeparator(filepath, separator) { - return filepath.split(/[/\\]/).join(separator); -} -exports.replacePathSegmentSeparator = replacePathSegmentSeparator; -function joinPathSegments(a, b, separator) { - if (a === '') { - return b; - } - /** - * The correct handling of cases when the first segment is a root (`/`, `C:/`) or UNC path (`//?/C:/`). - */ - if (a.endsWith(separator)) { - return a + b; - } - return a + separator + b; -} -exports.joinPathSegments = joinPathSegments; diff --git a/tools/eslint/node_modules/@nodelib/fs.walk/out/readers/reader.js b/tools/eslint/node_modules/@nodelib/fs.walk/out/readers/reader.js deleted file mode 100644 index 782f07cbfab62f..00000000000000 --- a/tools/eslint/node_modules/@nodelib/fs.walk/out/readers/reader.js +++ /dev/null @@ -1,11 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -const common = require("./common"); -class Reader { - constructor(_root, _settings) { - this._root = _root; - this._settings = _settings; - this._root = common.replacePathSegmentSeparator(_root, _settings.pathSegmentSeparator); - } -} -exports.default = Reader; diff --git a/tools/eslint/node_modules/@nodelib/fs.walk/out/readers/sync.js b/tools/eslint/node_modules/@nodelib/fs.walk/out/readers/sync.js deleted file mode 100644 index 9a8d5a6f1e18e8..00000000000000 --- a/tools/eslint/node_modules/@nodelib/fs.walk/out/readers/sync.js +++ /dev/null @@ -1,59 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -const fsScandir = require("@nodelib/fs.scandir"); -const common = require("./common"); -const reader_1 = require("./reader"); -class SyncReader extends reader_1.default { - constructor() { - super(...arguments); - this._scandir = fsScandir.scandirSync; - this._storage = []; - this._queue = new Set(); - } - read() { - this._pushToQueue(this._root, this._settings.basePath); - this._handleQueue(); - return this._storage; - } - _pushToQueue(directory, base) { - this._queue.add({ directory, base }); - } - _handleQueue() { - for (const item of this._queue.values()) { - this._handleDirectory(item.directory, item.base); - } - } - _handleDirectory(directory, base) { - try { - const entries = this._scandir(directory, this._settings.fsScandirSettings); - for (const entry of entries) { - this._handleEntry(entry, base); - } - } - catch (error) { - this._handleError(error); - } - } - _handleError(error) { - if (!common.isFatalError(this._settings, error)) { - return; - } - throw error; - } - _handleEntry(entry, base) { - const fullpath = entry.path; - if (base !== undefined) { - entry.path = common.joinPathSegments(base, entry.name, this._settings.pathSegmentSeparator); - } - if (common.isAppliedFilter(this._settings.entryFilter, entry)) { - this._pushToStorage(entry); - } - if (entry.dirent.isDirectory() && common.isAppliedFilter(this._settings.deepFilter, entry)) { - this._pushToQueue(fullpath, base === undefined ? undefined : entry.path); - } - } - _pushToStorage(entry) { - this._storage.push(entry); - } -} -exports.default = SyncReader; diff --git a/tools/eslint/node_modules/@nodelib/fs.walk/out/settings.js b/tools/eslint/node_modules/@nodelib/fs.walk/out/settings.js deleted file mode 100644 index d7a85c81eeecf8..00000000000000 --- a/tools/eslint/node_modules/@nodelib/fs.walk/out/settings.js +++ /dev/null @@ -1,26 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -const path = require("path"); -const fsScandir = require("@nodelib/fs.scandir"); -class Settings { - constructor(_options = {}) { - this._options = _options; - this.basePath = this._getValue(this._options.basePath, undefined); - this.concurrency = this._getValue(this._options.concurrency, Number.POSITIVE_INFINITY); - this.deepFilter = this._getValue(this._options.deepFilter, null); - this.entryFilter = this._getValue(this._options.entryFilter, null); - this.errorFilter = this._getValue(this._options.errorFilter, null); - this.pathSegmentSeparator = this._getValue(this._options.pathSegmentSeparator, path.sep); - this.fsScandirSettings = new fsScandir.Settings({ - followSymbolicLinks: this._options.followSymbolicLinks, - fs: this._options.fs, - pathSegmentSeparator: this._options.pathSegmentSeparator, - stats: this._options.stats, - throwErrorOnBrokenSymbolicLink: this._options.throwErrorOnBrokenSymbolicLink - }); - } - _getValue(option, value) { - return option !== null && option !== void 0 ? option : value; - } -} -exports.default = Settings; diff --git a/tools/eslint/node_modules/@nodelib/fs.walk/out/types/index.js b/tools/eslint/node_modules/@nodelib/fs.walk/out/types/index.js deleted file mode 100644 index c8ad2e549bdc68..00000000000000 --- a/tools/eslint/node_modules/@nodelib/fs.walk/out/types/index.js +++ /dev/null @@ -1,2 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); diff --git a/tools/eslint/node_modules/@nodelib/fs.walk/package.json b/tools/eslint/node_modules/@nodelib/fs.walk/package.json deleted file mode 100644 index 86bfce48b59e41..00000000000000 --- a/tools/eslint/node_modules/@nodelib/fs.walk/package.json +++ /dev/null @@ -1,44 +0,0 @@ -{ - "name": "@nodelib/fs.walk", - "version": "1.2.8", - "description": "A library for efficiently walking a directory recursively", - "license": "MIT", - "repository": "https://github.com/nodelib/nodelib/tree/master/packages/fs/fs.walk", - "keywords": [ - "NodeLib", - "fs", - "FileSystem", - "file system", - "walk", - "scanner", - "crawler" - ], - "engines": { - "node": ">= 8" - }, - "files": [ - "out/**", - "!out/**/*.map", - "!out/**/*.spec.*", - "!out/**/tests/**" - ], - "main": "out/index.js", - "typings": "out/index.d.ts", - "scripts": { - "clean": "rimraf {tsconfig.tsbuildinfo,out}", - "lint": "eslint \"src/**/*.ts\" --cache", - "compile": "tsc -b .", - "compile:watch": "tsc -p . --watch --sourceMap", - "test": "mocha \"out/**/*.spec.js\" -s 0", - "build": "npm run clean && npm run compile && npm run lint && npm test", - "watch": "npm run clean && npm run compile:watch" - }, - "dependencies": { - "@nodelib/fs.scandir": "2.1.5", - "fastq": "^1.6.0" - }, - "devDependencies": { - "@nodelib/fs.macchiato": "1.0.4" - }, - "gitHead": "1e5bad48565da2b06b8600e744324ea240bf49d8" -} diff --git a/tools/eslint/node_modules/@pkgr/core/lib/constants.js b/tools/eslint/node_modules/@pkgr/core/lib/constants.js deleted file mode 100644 index 374f420c29c903..00000000000000 --- a/tools/eslint/node_modules/@pkgr/core/lib/constants.js +++ /dev/null @@ -1,5 +0,0 @@ -import { createRequire } from 'node:module'; -export const CWD = process.cwd(); -export const cjsRequire = typeof require === 'undefined' ? createRequire(import.meta.url) : require; -export const EXTENSIONS = ['.ts', '.tsx', ...Object.keys(cjsRequire.extensions)]; -//# sourceMappingURL=constants.js.map \ No newline at end of file diff --git a/tools/eslint/node_modules/@pkgr/core/lib/helpers.js b/tools/eslint/node_modules/@pkgr/core/lib/helpers.js deleted file mode 100644 index 08e33302dc7df1..00000000000000 --- a/tools/eslint/node_modules/@pkgr/core/lib/helpers.js +++ /dev/null @@ -1,49 +0,0 @@ -import fs from 'node:fs'; -import path from 'node:path'; -import { CWD, EXTENSIONS, cjsRequire } from './constants.js'; -export const tryPkg = (pkg) => { - try { - return cjsRequire.resolve(pkg); - } - catch (_a) { } -}; -export const isPkgAvailable = (pkg) => !!tryPkg(pkg); -export const tryFile = (filePath, includeDir = false) => { - if (typeof filePath === 'string') { - return fs.existsSync(filePath) && - (includeDir || fs.statSync(filePath).isFile()) - ? filePath - : ''; - } - for (const file of filePath !== null && filePath !== void 0 ? filePath : []) { - if (tryFile(file, includeDir)) { - return file; - } - } - return ''; -}; -export const tryExtensions = (filepath, extensions = EXTENSIONS) => { - const ext = [...extensions, ''].find(ext => tryFile(filepath + ext)); - return ext == null ? '' : filepath + ext; -}; -export const findUp = (searchEntry, searchFileOrIncludeDir, includeDir) => { - console.assert(path.isAbsolute(searchEntry)); - if (!tryFile(searchEntry, true) || - (searchEntry !== CWD && !searchEntry.startsWith(CWD + path.sep))) { - return ''; - } - searchEntry = path.resolve(fs.statSync(searchEntry).isDirectory() - ? searchEntry - : path.resolve(searchEntry, '..')); - const isSearchFile = typeof searchFileOrIncludeDir === 'string'; - const searchFile = isSearchFile ? searchFileOrIncludeDir : 'package.json'; - do { - const searched = tryFile(path.resolve(searchEntry, searchFile), isSearchFile && includeDir); - if (searched) { - return searched; - } - searchEntry = path.resolve(searchEntry, '..'); - } while (searchEntry === CWD || searchEntry.startsWith(CWD + path.sep)); - return ''; -}; -//# sourceMappingURL=helpers.js.map \ No newline at end of file diff --git a/tools/eslint/node_modules/@pkgr/core/lib/index.cjs b/tools/eslint/node_modules/@pkgr/core/lib/index.cjs deleted file mode 100644 index 8c63baf13b9816..00000000000000 --- a/tools/eslint/node_modules/@pkgr/core/lib/index.cjs +++ /dev/null @@ -1,64 +0,0 @@ -'use strict'; - -var node_module = require('node:module'); -var fs = require('node:fs'); -var path = require('node:path'); - -const import_meta = {}; -const CWD = process.cwd(); -const cjsRequire = typeof require === "undefined" ? node_module.createRequire(import_meta.url) : require; -const EXTENSIONS = [".ts", ".tsx", ...Object.keys(cjsRequire.extensions)]; - -const tryPkg = (pkg) => { - try { - return cjsRequire.resolve(pkg); - } catch (e) { - } -}; -const isPkgAvailable = (pkg) => !!tryPkg(pkg); -const tryFile = (filePath, includeDir = false) => { - if (typeof filePath === "string") { - return fs.existsSync(filePath) && (includeDir || fs.statSync(filePath).isFile()) ? filePath : ""; - } - for (const file of filePath != null ? filePath : []) { - if (tryFile(file, includeDir)) { - return file; - } - } - return ""; -}; -const tryExtensions = (filepath, extensions = EXTENSIONS) => { - const ext = [...extensions, ""].find((ext2) => tryFile(filepath + ext2)); - return ext == null ? "" : filepath + ext; -}; -const findUp = (searchEntry, searchFileOrIncludeDir, includeDir) => { - console.assert(path.isAbsolute(searchEntry)); - if (!tryFile(searchEntry, true) || searchEntry !== CWD && !searchEntry.startsWith(CWD + path.sep)) { - return ""; - } - searchEntry = path.resolve( - fs.statSync(searchEntry).isDirectory() ? searchEntry : path.resolve(searchEntry, "..") - ); - const isSearchFile = typeof searchFileOrIncludeDir === "string"; - const searchFile = isSearchFile ? searchFileOrIncludeDir : "package.json"; - do { - const searched = tryFile( - path.resolve(searchEntry, searchFile), - isSearchFile && includeDir - ); - if (searched) { - return searched; - } - searchEntry = path.resolve(searchEntry, ".."); - } while (searchEntry === CWD || searchEntry.startsWith(CWD + path.sep)); - return ""; -}; - -exports.CWD = CWD; -exports.EXTENSIONS = EXTENSIONS; -exports.cjsRequire = cjsRequire; -exports.findUp = findUp; -exports.isPkgAvailable = isPkgAvailable; -exports.tryExtensions = tryExtensions; -exports.tryFile = tryFile; -exports.tryPkg = tryPkg; diff --git a/tools/eslint/node_modules/@pkgr/core/lib/index.js b/tools/eslint/node_modules/@pkgr/core/lib/index.js deleted file mode 100644 index e54355320647f5..00000000000000 --- a/tools/eslint/node_modules/@pkgr/core/lib/index.js +++ /dev/null @@ -1,3 +0,0 @@ -export * from './constants.js'; -export * from './helpers.js'; -//# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/tools/eslint/node_modules/@pkgr/core/package.json b/tools/eslint/node_modules/@pkgr/core/package.json deleted file mode 100644 index 6760bd55984d1c..00000000000000 --- a/tools/eslint/node_modules/@pkgr/core/package.json +++ /dev/null @@ -1,29 +0,0 @@ -{ - "name": "@pkgr/core", - "version": "0.1.1", - "type": "module", - "description": "Shared core module for `@pkgr` packages or any package else", - "repository": "git+https://github.com/un-ts/pkgr.git", - "homepage": "https://github.com/un-ts/pkgr/blob/master/packages/core", - "author": "JounQin (https://www.1stG.me) ", - "funding": "https://opencollective.com/unts", - "license": "MIT", - "engines": { - "node": "^12.20.0 || ^14.18.0 || >=16.0.0" - }, - "main": "./lib/index.cjs", - "module": "./lib/index.js", - "exports": { - "types": "./lib/index.d.ts", - "import": "./lib/index.js", - "require": "./lib/index.cjs" - }, - "types": "./lib/index.d.ts", - "files": [ - "lib" - ], - "publishConfig": { - "access": "public" - }, - "sideEffects": false -} diff --git a/tools/eslint/node_modules/@stylistic/eslint-plugin-js/LICENSE b/tools/eslint/node_modules/@stylistic/eslint-plugin-js/LICENSE deleted file mode 100644 index 346776d58bb927..00000000000000 --- a/tools/eslint/node_modules/@stylistic/eslint-plugin-js/LICENSE +++ /dev/null @@ -1,22 +0,0 @@ -MIT License - -Copyright OpenJS Foundation and other contributors, -Copyright (c) 2023-PRESENT eslint-stylistic and other contributors - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. diff --git a/tools/eslint/node_modules/@stylistic/eslint-plugin-js/dist/array-bracket-newline.js b/tools/eslint/node_modules/@stylistic/eslint-plugin-js/dist/array-bracket-newline.js deleted file mode 100644 index e4cfc51ac80fbf..00000000000000 --- a/tools/eslint/node_modules/@stylistic/eslint-plugin-js/dist/array-bracket-newline.js +++ /dev/null @@ -1,148 +0,0 @@ -'use strict'; - -var utils = require('./utils.js'); - -var arrayBracketNewline = utils.createRule({ - meta: { - type: "layout", - docs: { - description: "Enforce linebreaks after opening and before closing array brackets", - url: "https://eslint.style/rules/js/array-bracket-newline" - }, - fixable: "whitespace", - schema: [ - { - oneOf: [ - { - type: "string", - enum: ["always", "never", "consistent"] - }, - { - type: "object", - properties: { - multiline: { - type: "boolean" - }, - minItems: { - type: ["integer", "null"], - minimum: 0 - } - }, - additionalProperties: false - } - ] - } - ], - messages: { - unexpectedOpeningLinebreak: "There should be no linebreak after '['.", - unexpectedClosingLinebreak: "There should be no linebreak before ']'.", - missingOpeningLinebreak: "A linebreak is required after '['.", - missingClosingLinebreak: "A linebreak is required before ']'." - } - }, - create(context) { - const sourceCode = context.sourceCode; - function normalizeOptionValue(option) { - let consistent = false; - let multiline = false; - let minItems = 0; - if (option) { - if (option === "consistent") { - consistent = true; - minItems = Number.POSITIVE_INFINITY; - } else if (option === "always" || typeof option !== "string" && option.minItems === 0) { - minItems = 0; - } else if (option === "never") { - minItems = Number.POSITIVE_INFINITY; - } else { - multiline = Boolean(option.multiline); - minItems = option.minItems || Number.POSITIVE_INFINITY; - } - } else { - consistent = false; - multiline = true; - minItems = Number.POSITIVE_INFINITY; - } - return { consistent, multiline, minItems }; - } - function normalizeOptions(options) { - const value = normalizeOptionValue(options); - return { ArrayExpression: value, ArrayPattern: value }; - } - function reportNoBeginningLinebreak(node, token) { - context.report({ - node, - loc: token.loc, - messageId: "unexpectedOpeningLinebreak", - fix(fixer) { - const nextToken = sourceCode.getTokenAfter(token, { includeComments: true }); - if (!nextToken || utils.isCommentToken(nextToken)) - return null; - return fixer.removeRange([token.range[1], nextToken.range[0]]); - } - }); - } - function reportNoEndingLinebreak(node, token) { - context.report({ - node, - loc: token.loc, - messageId: "unexpectedClosingLinebreak", - fix(fixer) { - const previousToken = sourceCode.getTokenBefore(token, { includeComments: true }); - if (!previousToken || utils.isCommentToken(previousToken)) - return null; - return fixer.removeRange([previousToken.range[1], token.range[0]]); - } - }); - } - function reportRequiredBeginningLinebreak(node, token) { - context.report({ - node, - loc: token.loc, - messageId: "missingOpeningLinebreak", - fix(fixer) { - return fixer.insertTextAfter(token, "\n"); - } - }); - } - function reportRequiredEndingLinebreak(node, token) { - context.report({ - node, - loc: token.loc, - messageId: "missingClosingLinebreak", - fix(fixer) { - return fixer.insertTextBefore(token, "\n"); - } - }); - } - function check(node) { - const elements = node.elements; - const normalizedOptions = normalizeOptions(context.options[0]); - const options = normalizedOptions[node.type]; - const openBracket = sourceCode.getFirstToken(node); - const closeBracket = sourceCode.getLastToken(node); - const firstIncComment = sourceCode.getTokenAfter(openBracket, { includeComments: true }); - const lastIncComment = sourceCode.getTokenBefore(closeBracket, { includeComments: true }); - const first = sourceCode.getTokenAfter(openBracket); - const last = sourceCode.getTokenBefore(closeBracket); - const needsLinebreaks = elements.length >= options.minItems || options.multiline && elements.length > 0 && firstIncComment.loc.start.line !== lastIncComment.loc.end.line || elements.length === 0 && firstIncComment.type === "Block" && firstIncComment.loc.start.line !== lastIncComment.loc.end.line && firstIncComment === lastIncComment || options.consistent && openBracket.loc.end.line !== first.loc.start.line; - if (needsLinebreaks) { - if (utils.isTokenOnSameLine(openBracket, first)) - reportRequiredBeginningLinebreak(node, openBracket); - if (utils.isTokenOnSameLine(last, closeBracket)) - reportRequiredEndingLinebreak(node, closeBracket); - } else { - if (!utils.isTokenOnSameLine(openBracket, first)) - reportNoBeginningLinebreak(node, openBracket); - if (!utils.isTokenOnSameLine(last, closeBracket)) - reportNoEndingLinebreak(node, closeBracket); - } - } - return { - ArrayPattern: check, - ArrayExpression: check - }; - } -}); - -exports.arrayBracketNewline = arrayBracketNewline; diff --git a/tools/eslint/node_modules/@stylistic/eslint-plugin-js/dist/array-bracket-spacing.js b/tools/eslint/node_modules/@stylistic/eslint-plugin-js/dist/array-bracket-spacing.js deleted file mode 100644 index abc1827ee3d218..00000000000000 --- a/tools/eslint/node_modules/@stylistic/eslint-plugin-js/dist/array-bracket-spacing.js +++ /dev/null @@ -1,144 +0,0 @@ -'use strict'; - -var utils = require('./utils.js'); - -var arrayBracketSpacing = utils.createRule({ - meta: { - type: "layout", - docs: { - description: "Enforce consistent spacing inside array brackets", - url: "https://eslint.style/rules/js/array-bracket-spacing" - }, - fixable: "whitespace", - schema: [ - { - type: "string", - enum: ["always", "never"] - }, - { - type: "object", - properties: { - singleValue: { - type: "boolean" - }, - objectsInArrays: { - type: "boolean" - }, - arraysInArrays: { - type: "boolean" - } - }, - additionalProperties: false - } - ], - messages: { - unexpectedSpaceAfter: "There should be no space after '{{tokenValue}}'.", - unexpectedSpaceBefore: "There should be no space before '{{tokenValue}}'.", - missingSpaceAfter: "A space is required after '{{tokenValue}}'.", - missingSpaceBefore: "A space is required before '{{tokenValue}}'." - } - }, - create(context) { - const spaced = context.options[0] === "always"; - const sourceCode = context.sourceCode; - function isOptionSet(option) { - return context.options[1] ? context.options[1][option] === !spaced : false; - } - const options = { - spaced, - singleElementException: isOptionSet("singleValue"), - objectsInArraysException: isOptionSet("objectsInArrays"), - arraysInArraysException: isOptionSet("arraysInArrays") - }; - function reportNoBeginningSpace(node, token) { - const nextToken = sourceCode.getTokenAfter(token); - context.report({ - node, - loc: { start: token.loc.end, end: nextToken.loc.start }, - messageId: "unexpectedSpaceAfter", - data: { - tokenValue: token.value - }, - fix(fixer) { - return fixer.removeRange([token.range[1], nextToken.range[0]]); - } - }); - } - function reportNoEndingSpace(node, token) { - const previousToken = sourceCode.getTokenBefore(token); - context.report({ - node, - loc: { start: previousToken.loc.end, end: token.loc.start }, - messageId: "unexpectedSpaceBefore", - data: { - tokenValue: token.value - }, - fix(fixer) { - return fixer.removeRange([previousToken.range[1], token.range[0]]); - } - }); - } - function reportRequiredBeginningSpace(node, token) { - context.report({ - node, - loc: token.loc, - messageId: "missingSpaceAfter", - data: { - tokenValue: token.value - }, - fix(fixer) { - return fixer.insertTextAfter(token, " "); - } - }); - } - function reportRequiredEndingSpace(node, token) { - context.report({ - node, - loc: token.loc, - messageId: "missingSpaceBefore", - data: { - tokenValue: token.value - }, - fix(fixer) { - return fixer.insertTextBefore(token, " "); - } - }); - } - function isObjectType(node) { - return node && (node.type === "ObjectExpression" || node.type === "ObjectPattern"); - } - function isArrayType(node) { - return node && (node.type === "ArrayExpression" || node.type === "ArrayPattern"); - } - function validateArraySpacing(node) { - if (options.spaced && node.elements.length === 0) - return; - const first = sourceCode.getFirstToken(node); - const second = sourceCode.getFirstToken(node, 1); - const last = node.type === "ArrayPattern" && node.typeAnnotation ? sourceCode.getTokenBefore(node.typeAnnotation) : sourceCode.getLastToken(node); - const penultimate = sourceCode.getTokenBefore(last); - const firstElement = node.elements[0]; - const lastElement = node.elements[node.elements.length - 1]; - const openingBracketMustBeSpaced = firstElement && options.objectsInArraysException && isObjectType(firstElement) || firstElement && options.arraysInArraysException && isArrayType(firstElement) || options.singleElementException && node.elements.length === 1 ? !options.spaced : options.spaced; - const closingBracketMustBeSpaced = lastElement && options.objectsInArraysException && isObjectType(lastElement) || lastElement && options.arraysInArraysException && isArrayType(lastElement) || options.singleElementException && node.elements.length === 1 ? !options.spaced : options.spaced; - if (utils.isTokenOnSameLine(first, second)) { - if (openingBracketMustBeSpaced && !sourceCode.isSpaceBetweenTokens(first, second)) - reportRequiredBeginningSpace(node, first); - if (!openingBracketMustBeSpaced && sourceCode.isSpaceBetweenTokens(first, second)) - reportNoBeginningSpace(node, first); - } - if (first !== penultimate && utils.isTokenOnSameLine(penultimate, last)) { - if (closingBracketMustBeSpaced && !sourceCode.isSpaceBetweenTokens(penultimate, last)) - reportRequiredEndingSpace(node, last); - if (!closingBracketMustBeSpaced && sourceCode.isSpaceBetweenTokens(penultimate, last)) - reportNoEndingSpace(node, last); - } - } - return { - ArrayPattern: validateArraySpacing, - ArrayExpression: validateArraySpacing - }; - } -}); - -exports.arrayBracketSpacing = arrayBracketSpacing; diff --git a/tools/eslint/node_modules/@stylistic/eslint-plugin-js/dist/array-element-newline.js b/tools/eslint/node_modules/@stylistic/eslint-plugin-js/dist/array-element-newline.js deleted file mode 100644 index 5108c33cc9833d..00000000000000 --- a/tools/eslint/node_modules/@stylistic/eslint-plugin-js/dist/array-element-newline.js +++ /dev/null @@ -1,181 +0,0 @@ -'use strict'; - -var utils = require('./utils.js'); - -var arrayElementNewline = utils.createRule({ - meta: { - type: "layout", - docs: { - description: "Enforce line breaks after each array element", - url: "https://eslint.style/rules/js/array-element-newline" - }, - fixable: "whitespace", - schema: { - definitions: { - basicConfig: { - oneOf: [ - { - type: "string", - enum: ["always", "never", "consistent"] - }, - { - type: "object", - properties: { - consistent: { - type: "boolean" - }, - multiline: { - type: "boolean" - }, - minItems: { - type: ["integer", "null"], - minimum: 0 - } - }, - additionalProperties: false - } - ] - } - }, - type: "array", - items: [ - { - oneOf: [ - { - $ref: "#/definitions/basicConfig" - }, - { - type: "object", - properties: { - ArrayExpression: { - $ref: "#/definitions/basicConfig" - }, - ArrayPattern: { - $ref: "#/definitions/basicConfig" - } - }, - additionalProperties: false, - minProperties: 1 - } - ] - } - ] - }, - messages: { - unexpectedLineBreak: "There should be no linebreak here.", - missingLineBreak: "There should be a linebreak after this element." - } - }, - create(context) { - const sourceCode = context.sourceCode; - function normalizeOptionValue(providedOption) { - let consistent = false; - let multiline = false; - let minItems; - const option = providedOption || "always"; - if (!option || option === "always" || typeof option === "object" && option.minItems === 0) { - minItems = 0; - } else if (option === "never") { - minItems = Number.POSITIVE_INFINITY; - } else if (option === "consistent") { - consistent = true; - minItems = Number.POSITIVE_INFINITY; - } else { - consistent = Boolean(option.consistent); - multiline = Boolean(option.multiline); - minItems = option.minItems || Number.POSITIVE_INFINITY; - } - return { consistent, multiline, minItems }; - } - function normalizeOptions(options) { - if (options && (options.ArrayExpression || options.ArrayPattern)) { - let expressionOptions, patternOptions; - if (options.ArrayExpression) - expressionOptions = normalizeOptionValue(options.ArrayExpression); - if (options.ArrayPattern) - patternOptions = normalizeOptionValue(options.ArrayPattern); - return { ArrayExpression: expressionOptions, ArrayPattern: patternOptions }; - } - const value = normalizeOptionValue(options); - return { ArrayExpression: value, ArrayPattern: value }; - } - function reportNoLineBreak(token) { - const tokenBefore = sourceCode.getTokenBefore(token, { includeComments: true }); - context.report({ - loc: { - start: tokenBefore.loc.end, - end: token.loc.start - }, - messageId: "unexpectedLineBreak", - fix(fixer) { - if (utils.isCommentToken(tokenBefore)) - return null; - if (!utils.isTokenOnSameLine(tokenBefore, token)) - return fixer.replaceTextRange([tokenBefore.range[1], token.range[0]], " "); - const twoTokensBefore = sourceCode.getTokenBefore(tokenBefore, { includeComments: true }); - if (utils.isCommentToken(twoTokensBefore)) - return null; - return fixer.replaceTextRange([twoTokensBefore.range[1], tokenBefore.range[0]], ""); - } - }); - } - function reportRequiredLineBreak(token) { - const tokenBefore = sourceCode.getTokenBefore(token, { includeComments: true }); - context.report({ - loc: { - start: tokenBefore.loc.end, - end: token.loc.start - }, - messageId: "missingLineBreak", - fix(fixer) { - return fixer.replaceTextRange([tokenBefore.range[1], token.range[0]], "\n"); - } - }); - } - function check(node) { - const elements = node.elements; - const normalizedOptions = normalizeOptions(context.options[0]); - const options = normalizedOptions[node.type]; - if (!options) - return; - let elementBreak = false; - if (options.multiline) { - elementBreak = elements.filter((element) => element !== null).some((element) => element.loc.start.line !== element.loc.end.line); - } - let linebreaksCount = 0; - for (let i = 0; i < node.elements.length; i++) { - const element = node.elements[i]; - const previousElement = elements[i - 1]; - if (i === 0 || element === null || previousElement === null) - continue; - const commaToken = sourceCode.getFirstTokenBetween(previousElement, element, utils.isCommaToken); - const lastTokenOfPreviousElement = sourceCode.getTokenBefore(commaToken); - const firstTokenOfCurrentElement = sourceCode.getTokenAfter(commaToken); - if (!utils.isTokenOnSameLine(lastTokenOfPreviousElement, firstTokenOfCurrentElement)) - linebreaksCount++; - } - const needsLinebreaks = elements.length >= options.minItems || options.multiline && elementBreak || options.consistent && linebreaksCount > 0 && linebreaksCount < node.elements.length; - elements.forEach((element, i) => { - const previousElement = elements[i - 1]; - if (i === 0 || element === null || previousElement === null) - return; - const commaToken = sourceCode.getFirstTokenBetween(previousElement, element, utils.isCommaToken); - const lastTokenOfPreviousElement = sourceCode.getTokenBefore(commaToken); - const firstTokenOfCurrentElement = sourceCode.getTokenAfter(commaToken); - if (needsLinebreaks) { - if (utils.isTokenOnSameLine(lastTokenOfPreviousElement, firstTokenOfCurrentElement)) - reportRequiredLineBreak(firstTokenOfCurrentElement); - } else { - if (!utils.isTokenOnSameLine(lastTokenOfPreviousElement, firstTokenOfCurrentElement)) - reportNoLineBreak(firstTokenOfCurrentElement); - } - }); - } - return { - ArrayPattern: check, - ArrayExpression: check - }; - } -}); - -exports.arrayElementNewline = arrayElementNewline; diff --git a/tools/eslint/node_modules/@stylistic/eslint-plugin-js/dist/arrow-parens.js b/tools/eslint/node_modules/@stylistic/eslint-plugin-js/dist/arrow-parens.js deleted file mode 100644 index c0f239487a6e86..00000000000000 --- a/tools/eslint/node_modules/@stylistic/eslint-plugin-js/dist/arrow-parens.js +++ /dev/null @@ -1,98 +0,0 @@ -'use strict'; - -var utils = require('./utils.js'); - -function hasBlockBody(node) { - return node.body.type === "BlockStatement"; -} -var arrowParens = utils.createRule({ - meta: { - type: "layout", - docs: { - description: "Require parentheses around arrow function arguments", - url: "https://eslint.style/rules/js/arrow-parens" - }, - fixable: "code", - schema: [ - { - type: "string", - enum: ["always", "as-needed"] - }, - { - type: "object", - properties: { - requireForBlockBody: { - type: "boolean", - default: false - } - }, - additionalProperties: false - } - ], - messages: { - unexpectedParens: "Unexpected parentheses around single function argument.", - expectedParens: "Expected parentheses around arrow function argument.", - unexpectedParensInline: "Unexpected parentheses around single function argument having a body with no curly braces.", - expectedParensBlock: "Expected parentheses around arrow function argument having a body with curly braces." - } - }, - create(context) { - const asNeeded = context.options[0] === "as-needed"; - const requireForBlockBody = asNeeded && context.options[1] && context.options[1].requireForBlockBody === true; - const sourceCode = context.sourceCode; - function findOpeningParenOfParams(node) { - const tokenBeforeParams = sourceCode.getTokenBefore(node.params[0]); - if (tokenBeforeParams && utils.isOpeningParenToken(tokenBeforeParams) && node.range[0] <= tokenBeforeParams.range[0]) { - return tokenBeforeParams; - } - return null; - } - function getClosingParenOfParams(node) { - return sourceCode.getTokenAfter(node.params[0], utils.isClosingParenToken); - } - function hasCommentsInParensOfParams(node, openingParen) { - return sourceCode.commentsExistBetween(openingParen, getClosingParenOfParams(node)); - } - function hasUnexpectedTokensBeforeOpeningParen(node, openingParen) { - const expectedCount = node.async ? 1 : 0; - return sourceCode.getFirstToken(node, { skip: expectedCount }) !== openingParen; - } - return { - "ArrowFunctionExpression[params.length=1]": function(node) { - const shouldHaveParens = !asNeeded || requireForBlockBody && hasBlockBody(node); - const openingParen = findOpeningParenOfParams(node); - const hasParens = openingParen !== null; - const [param] = node.params; - if (shouldHaveParens && !hasParens) { - context.report({ - node, - messageId: requireForBlockBody ? "expectedParensBlock" : "expectedParens", - loc: param.loc, - *fix(fixer) { - yield fixer.insertTextBefore(param, "("); - yield fixer.insertTextAfter(param, ")"); - } - }); - } - if (!shouldHaveParens && hasParens && param.type === "Identifier" && !param.typeAnnotation && !node.returnType && !hasCommentsInParensOfParams(node, openingParen) && !hasUnexpectedTokensBeforeOpeningParen(node, openingParen)) { - context.report({ - node, - messageId: requireForBlockBody ? "unexpectedParensInline" : "unexpectedParens", - loc: param.loc, - *fix(fixer) { - const tokenBeforeOpeningParen = sourceCode.getTokenBefore(openingParen); - const closingParen = getClosingParenOfParams(node); - if (tokenBeforeOpeningParen && tokenBeforeOpeningParen.range[1] === openingParen.range[0] && !utils.canTokensBeAdjacent(tokenBeforeOpeningParen, sourceCode.getFirstToken(param))) { - yield fixer.insertTextBefore(openingParen, " "); - } - yield fixer.removeRange([openingParen.range[0], param.range[0]]); - yield fixer.removeRange([param.range[1], closingParen.range[1]]); - } - }); - } - } - }; - } -}); - -exports.arrowParens = arrowParens; diff --git a/tools/eslint/node_modules/@stylistic/eslint-plugin-js/dist/arrow-spacing.js b/tools/eslint/node_modules/@stylistic/eslint-plugin-js/dist/arrow-spacing.js deleted file mode 100644 index 006a87af068b92..00000000000000 --- a/tools/eslint/node_modules/@stylistic/eslint-plugin-js/dist/arrow-spacing.js +++ /dev/null @@ -1,106 +0,0 @@ -'use strict'; - -var utils = require('./utils.js'); - -var arrowSpacing = utils.createRule({ - meta: { - type: "layout", - docs: { - description: "Enforce consistent spacing before and after the arrow in arrow functions", - url: "https://eslint.style/rules/js/arrow-spacing" - }, - fixable: "whitespace", - schema: [ - { - type: "object", - properties: { - before: { - type: "boolean", - default: true - }, - after: { - type: "boolean", - default: true - } - }, - additionalProperties: false - } - ], - messages: { - expectedBefore: "Missing space before =>.", - unexpectedBefore: "Unexpected space before =>.", - expectedAfter: "Missing space after =>.", - unexpectedAfter: "Unexpected space after =>." - } - }, - create(context) { - const rule = Object.assign({}, context.options[0]); - rule.before = rule.before !== false; - rule.after = rule.after !== false; - const sourceCode = context.sourceCode; - function getTokens(node) { - const arrow = sourceCode.getTokenBefore(node.body, utils.isArrowToken); - return { - before: sourceCode.getTokenBefore(arrow), - arrow, - after: sourceCode.getTokenAfter(arrow) - }; - } - function countSpaces(tokens) { - const before = tokens.arrow.range[0] - tokens.before.range[1]; - const after = tokens.after.range[0] - tokens.arrow.range[1]; - return { before, after }; - } - function spaces(node) { - const tokens = getTokens(node); - const countSpace = countSpaces(tokens); - if (rule.before) { - if (countSpace.before === 0) { - context.report({ - node: tokens.before, - messageId: "expectedBefore", - fix(fixer) { - return fixer.insertTextBefore(tokens.arrow, " "); - } - }); - } - } else { - if (countSpace.before > 0) { - context.report({ - node: tokens.before, - messageId: "unexpectedBefore", - fix(fixer) { - return fixer.removeRange([tokens.before.range[1], tokens.arrow.range[0]]); - } - }); - } - } - if (rule.after) { - if (countSpace.after === 0) { - context.report({ - node: tokens.after, - messageId: "expectedAfter", - fix(fixer) { - return fixer.insertTextAfter(tokens.arrow, " "); - } - }); - } - } else { - if (countSpace.after > 0) { - context.report({ - node: tokens.after, - messageId: "unexpectedAfter", - fix(fixer) { - return fixer.removeRange([tokens.arrow.range[1], tokens.after.range[0]]); - } - }); - } - } - } - return { - ArrowFunctionExpression: spaces - }; - } -}); - -exports.arrowSpacing = arrowSpacing; diff --git a/tools/eslint/node_modules/@stylistic/eslint-plugin-js/dist/block-spacing.js b/tools/eslint/node_modules/@stylistic/eslint-plugin-js/dist/block-spacing.js deleted file mode 100644 index 0af14ff854c666..00000000000000 --- a/tools/eslint/node_modules/@stylistic/eslint-plugin-js/dist/block-spacing.js +++ /dev/null @@ -1,103 +0,0 @@ -'use strict'; - -var utils = require('./utils.js'); - -var blockSpacing = utils.createRule({ - meta: { - type: "layout", - docs: { - description: "Disallow or enforce spaces inside of blocks after opening block and before closing block", - url: "https://eslint.style/rules/js/block-spacing" - }, - fixable: "whitespace", - schema: [ - { type: "string", enum: ["always", "never"] } - ], - messages: { - missing: "Requires a space {{location}} '{{token}}'.", - extra: "Unexpected space(s) {{location}} '{{token}}'." - } - }, - create(context) { - const always = context.options[0] !== "never"; - const messageId = always ? "missing" : "extra"; - const sourceCode = context.sourceCode; - function getOpenBrace(node) { - if (node.type === "SwitchStatement") { - if (node.cases.length > 0) - return sourceCode.getTokenBefore(node.cases[0]); - return sourceCode.getLastToken(node, 1); - } - if (node.type === "StaticBlock") - return sourceCode.getFirstToken(node, { skip: 1 }); - return sourceCode.getFirstToken(node); - } - function isValid(left, right) { - return !utils.isTokenOnSameLine(left, right) || sourceCode.isSpaceBetweenTokens(left, right) === always; - } - function checkSpacingInsideBraces(node) { - const openBrace = getOpenBrace(node); - const closeBrace = sourceCode.getLastToken(node); - const firstToken = sourceCode.getTokenAfter(openBrace, { includeComments: true }); - const lastToken = sourceCode.getTokenBefore(closeBrace, { includeComments: true }); - if (openBrace.type !== "Punctuator" || openBrace.value !== "{" || closeBrace.type !== "Punctuator" || closeBrace.value !== "}" || firstToken === closeBrace) { - return; - } - if (!always && firstToken.type === "Line") - return; - if (!isValid(openBrace, firstToken)) { - let loc = openBrace.loc; - if (messageId === "extra") { - loc = { - start: openBrace.loc.end, - end: firstToken.loc.start - }; - } - context.report({ - node, - loc, - messageId, - data: { - location: "after", - token: openBrace.value - }, - fix(fixer) { - if (always) - return fixer.insertTextBefore(firstToken, " "); - return fixer.removeRange([openBrace.range[1], firstToken.range[0]]); - } - }); - } - if (!isValid(lastToken, closeBrace)) { - let loc = closeBrace.loc; - if (messageId === "extra") { - loc = { - start: lastToken.loc.end, - end: closeBrace.loc.start - }; - } - context.report({ - node, - loc, - messageId, - data: { - location: "before", - token: closeBrace.value - }, - fix(fixer) { - if (always) - return fixer.insertTextAfter(lastToken, " "); - return fixer.removeRange([lastToken.range[1], closeBrace.range[0]]); - } - }); - } - } - return { - BlockStatement: checkSpacingInsideBraces, - StaticBlock: checkSpacingInsideBraces, - SwitchStatement: checkSpacingInsideBraces - }; - } -}); - -exports.blockSpacing = blockSpacing; diff --git a/tools/eslint/node_modules/@stylistic/eslint-plugin-js/dist/brace-style.js b/tools/eslint/node_modules/@stylistic/eslint-plugin-js/dist/brace-style.js deleted file mode 100644 index 902b38461fd733..00000000000000 --- a/tools/eslint/node_modules/@stylistic/eslint-plugin-js/dist/brace-style.js +++ /dev/null @@ -1,138 +0,0 @@ -'use strict'; - -var utils = require('./utils.js'); - -var braceStyle = utils.createRule({ - meta: { - type: "layout", - docs: { - description: "Enforce consistent brace style for blocks", - url: "https://eslint.style/rules/js/brace-style" - }, - schema: [ - { - type: "string", - enum: ["1tbs", "stroustrup", "allman"] - }, - { - type: "object", - properties: { - allowSingleLine: { - type: "boolean", - default: false - } - }, - additionalProperties: false - } - ], - fixable: "whitespace", - messages: { - nextLineOpen: "Opening curly brace does not appear on the same line as controlling statement.", - sameLineOpen: "Opening curly brace appears on the same line as controlling statement.", - blockSameLine: "Statement inside of curly braces should be on next line.", - nextLineClose: "Closing curly brace does not appear on the same line as the subsequent block.", - singleLineClose: "Closing curly brace should be on the same line as opening curly brace or on the line after the previous block.", - sameLineClose: "Closing curly brace appears on the same line as the subsequent block." - } - }, - create(context) { - const style = context.options[0] || "1tbs"; - const params = context.options[1] || {}; - const sourceCode = context.sourceCode; - function removeNewlineBetween(firstToken, secondToken) { - const textRange = [firstToken.range[1], secondToken.range[0]]; - const textBetween = sourceCode.text.slice(textRange[0], textRange[1]); - if (textBetween.trim()) - return null; - return (fixer) => fixer.replaceTextRange(textRange, " "); - } - function validateCurlyPair(openingCurly, closingCurly) { - const tokenBeforeOpeningCurly = sourceCode.getTokenBefore(openingCurly); - const tokenAfterOpeningCurly = sourceCode.getTokenAfter(openingCurly); - const tokenBeforeClosingCurly = sourceCode.getTokenBefore(closingCurly); - const singleLineException = params.allowSingleLine && utils.isTokenOnSameLine(openingCurly, closingCurly); - if (style !== "allman" && !utils.isTokenOnSameLine(tokenBeforeOpeningCurly, openingCurly)) { - context.report({ - node: openingCurly, - messageId: "nextLineOpen", - fix: removeNewlineBetween( - tokenBeforeOpeningCurly, - openingCurly - ) - }); - } - if (style === "allman" && utils.isTokenOnSameLine(tokenBeforeOpeningCurly, openingCurly) && !singleLineException) { - context.report({ - node: openingCurly, - messageId: "sameLineOpen", - fix: (fixer) => fixer.insertTextBefore(openingCurly, "\n") - }); - } - if (utils.isTokenOnSameLine(openingCurly, tokenAfterOpeningCurly) && tokenAfterOpeningCurly !== closingCurly && !singleLineException) { - context.report({ - node: openingCurly, - messageId: "blockSameLine", - fix: (fixer) => fixer.insertTextAfter(openingCurly, "\n") - }); - } - if (tokenBeforeClosingCurly !== openingCurly && !singleLineException && utils.isTokenOnSameLine(tokenBeforeClosingCurly, closingCurly)) { - context.report({ - node: closingCurly, - messageId: "singleLineClose", - fix: (fixer) => fixer.insertTextBefore(closingCurly, "\n") - }); - } - } - function validateCurlyBeforeKeyword(curlyToken) { - const keywordToken = sourceCode.getTokenAfter(curlyToken); - if (style === "1tbs" && !utils.isTokenOnSameLine(curlyToken, keywordToken)) { - context.report({ - node: curlyToken, - messageId: "nextLineClose", - fix: removeNewlineBetween(curlyToken, keywordToken) - }); - } - if (style !== "1tbs" && utils.isTokenOnSameLine(curlyToken, keywordToken)) { - context.report({ - node: curlyToken, - messageId: "sameLineClose", - fix: (fixer) => fixer.insertTextAfter(curlyToken, "\n") - }); - } - } - return { - BlockStatement(node) { - if (!utils.STATEMENT_LIST_PARENTS.has(node.parent.type)) - validateCurlyPair(sourceCode.getFirstToken(node), sourceCode.getLastToken(node)); - }, - StaticBlock(node) { - validateCurlyPair( - sourceCode.getFirstToken(node, { skip: 1 }), - // skip the `static` token - sourceCode.getLastToken(node) - ); - }, - ClassBody(node) { - validateCurlyPair(sourceCode.getFirstToken(node), sourceCode.getLastToken(node)); - }, - SwitchStatement(node) { - const closingCurly = sourceCode.getLastToken(node); - const openingCurly = sourceCode.getTokenBefore(node.cases.length ? node.cases[0] : closingCurly); - validateCurlyPair(openingCurly, closingCurly); - }, - IfStatement(node) { - if (node.consequent.type === "BlockStatement" && node.alternate) { - validateCurlyBeforeKeyword(sourceCode.getLastToken(node.consequent)); - } - }, - TryStatement(node) { - validateCurlyBeforeKeyword(sourceCode.getLastToken(node.block)); - if (node.handler && node.finalizer) { - validateCurlyBeforeKeyword(sourceCode.getLastToken(node.handler.body)); - } - } - }; - } -}); - -exports.braceStyle = braceStyle; diff --git a/tools/eslint/node_modules/@stylistic/eslint-plugin-js/dist/comma-dangle.js b/tools/eslint/node_modules/@stylistic/eslint-plugin-js/dist/comma-dangle.js deleted file mode 100644 index 3508924d955486..00000000000000 --- a/tools/eslint/node_modules/@stylistic/eslint-plugin-js/dist/comma-dangle.js +++ /dev/null @@ -1,231 +0,0 @@ -'use strict'; - -var utils = require('./utils.js'); - -const DEFAULT_OPTIONS = Object.freeze({ - arrays: "never", - objects: "never", - imports: "never", - exports: "never", - functions: "never" -}); -const closeBraces = ["}", "]", ")", ">"]; -function isTrailingCommaAllowed(lastItem) { - return lastItem.type !== "RestElement"; -} -function normalizeOptions(optionValue, ecmaVersion) { - if (typeof optionValue === "string") { - return { - arrays: optionValue, - objects: optionValue, - imports: optionValue, - exports: optionValue, - functions: !ecmaVersion || ecmaVersion === "latest" ? optionValue : ecmaVersion < 2017 ? "ignore" : optionValue - }; - } - if (typeof optionValue === "object" && optionValue !== null) { - return { - arrays: optionValue.arrays || DEFAULT_OPTIONS.arrays, - objects: optionValue.objects || DEFAULT_OPTIONS.objects, - imports: optionValue.imports || DEFAULT_OPTIONS.imports, - exports: optionValue.exports || DEFAULT_OPTIONS.exports, - functions: optionValue.functions || DEFAULT_OPTIONS.functions - }; - } - return DEFAULT_OPTIONS; -} -var commaDangle = utils.createRule({ - meta: { - type: "layout", - docs: { - description: "Require or disallow trailing commas", - url: "https://eslint.style/rules/js/comma-dangle" - }, - fixable: "code", - schema: { - definitions: { - value: { - type: "string", - enum: [ - "always-multiline", - "always", - "never", - "only-multiline" - ] - }, - valueWithIgnore: { - type: "string", - enum: [ - "always-multiline", - "always", - "ignore", - "never", - "only-multiline" - ] - } - }, - type: "array", - items: [ - { - oneOf: [ - { - $ref: "#/definitions/value" - }, - { - type: "object", - properties: { - arrays: { $ref: "#/definitions/valueWithIgnore" }, - objects: { $ref: "#/definitions/valueWithIgnore" }, - imports: { $ref: "#/definitions/valueWithIgnore" }, - exports: { $ref: "#/definitions/valueWithIgnore" }, - functions: { $ref: "#/definitions/valueWithIgnore" } - }, - additionalProperties: false - } - ] - } - ], - additionalItems: false - }, - messages: { - unexpected: "Unexpected trailing comma.", - missing: "Missing trailing comma." - } - }, - create(context) { - const ecmaVersion = context?.languageOptions?.ecmaVersion ?? context.parserOptions.ecmaVersion; - const options = normalizeOptions(context.options[0], ecmaVersion); - const sourceCode = context.sourceCode; - function getLastItem(node) { - function last(array) { - return array[array.length - 1]; - } - switch (node.type) { - case "ObjectExpression": - case "ObjectPattern": - return last(node.properties); - case "ArrayExpression": - case "ArrayPattern": - return last(node.elements); - case "ImportDeclaration": - case "ExportNamedDeclaration": - return last(node.specifiers); - case "FunctionDeclaration": - case "FunctionExpression": - case "ArrowFunctionExpression": - return last(node.params); - case "CallExpression": - case "NewExpression": - return last(node.arguments); - default: - return null; - } - } - function getTrailingToken(node, lastItem) { - switch (node.type) { - case "ObjectExpression": - case "ArrayExpression": - case "CallExpression": - case "NewExpression": - return sourceCode.getLastToken(node, 1); - default: { - const nextToken = sourceCode.getTokenAfter(lastItem); - if (utils.isCommaToken(nextToken)) - return nextToken; - return sourceCode.getLastToken(lastItem); - } - } - } - function isMultiline(node) { - const lastItem = getLastItem(node); - if (!lastItem) - return false; - const penultimateToken = getTrailingToken(node, lastItem); - if (!penultimateToken) - return false; - const lastToken = sourceCode.getTokenAfter(penultimateToken); - if (!lastToken) - return false; - return lastToken.loc.end.line !== penultimateToken.loc.end.line; - } - function forbidTrailingComma(node) { - const lastItem = getLastItem(node); - if (!lastItem || node.type === "ImportDeclaration" && lastItem.type !== "ImportSpecifier") - return; - const trailingToken = getTrailingToken(node, lastItem); - if (trailingToken && utils.isCommaToken(trailingToken)) { - context.report({ - node: lastItem, - loc: trailingToken.loc, - messageId: "unexpected", - *fix(fixer) { - yield fixer.remove(trailingToken); - yield fixer.insertTextBefore(sourceCode.getTokenBefore(trailingToken), ""); - yield fixer.insertTextAfter(sourceCode.getTokenAfter(trailingToken), ""); - } - }); - } - } - function forceTrailingComma(node) { - const lastItem = getLastItem(node); - if (!lastItem || node.type === "ImportDeclaration" && lastItem.type !== "ImportSpecifier") - return; - if (!isTrailingCommaAllowed(lastItem)) { - forbidTrailingComma(node); - return; - } - const trailingToken = getTrailingToken(node, lastItem); - if (!trailingToken || trailingToken.value === ",") - return; - const nextToken = sourceCode.getTokenAfter(trailingToken); - if (!nextToken || !closeBraces.includes(nextToken.value)) - return; - context.report({ - node: lastItem, - loc: { - start: trailingToken.loc.end, - end: utils.getNextLocation(sourceCode, trailingToken.loc.end) - }, - messageId: "missing", - *fix(fixer) { - yield fixer.insertTextAfter(trailingToken, ","); - yield fixer.insertTextBefore(trailingToken, ""); - yield fixer.insertTextAfter(sourceCode.getTokenAfter(trailingToken), ""); - } - }); - } - function forceTrailingCommaIfMultiline(node) { - if (isMultiline(node)) - forceTrailingComma(node); - else - forbidTrailingComma(node); - } - function allowTrailingCommaIfMultiline(node) { - if (!isMultiline(node)) - forbidTrailingComma(node); - } - const predicate = { - "always": forceTrailingComma, - "always-multiline": forceTrailingCommaIfMultiline, - "only-multiline": allowTrailingCommaIfMultiline, - "never": forbidTrailingComma, - ignore() { - } - }; - return { - ObjectExpression: predicate[options.objects], - ObjectPattern: predicate[options.objects], - ArrayExpression: predicate[options.arrays], - ArrayPattern: predicate[options.arrays], - ImportDeclaration: predicate[options.imports], - ExportNamedDeclaration: predicate[options.exports], - FunctionDeclaration: predicate[options.functions], - FunctionExpression: predicate[options.functions], - ArrowFunctionExpression: predicate[options.functions], - CallExpression: predicate[options.functions], - NewExpression: predicate[options.functions] - }; - } -}); - -exports.commaDangle = commaDangle; diff --git a/tools/eslint/node_modules/@stylistic/eslint-plugin-js/dist/comma-spacing.js b/tools/eslint/node_modules/@stylistic/eslint-plugin-js/dist/comma-spacing.js deleted file mode 100644 index d44c2eccdc6c92..00000000000000 --- a/tools/eslint/node_modules/@stylistic/eslint-plugin-js/dist/comma-spacing.js +++ /dev/null @@ -1,103 +0,0 @@ -'use strict'; - -var utils = require('./utils.js'); - -var commaSpacing = utils.createRule({ - meta: { - type: "layout", - docs: { - description: "Enforce consistent spacing before and after commas", - url: "https://eslint.style/rules/js/comma-spacing" - }, - fixable: "whitespace", - schema: [ - { - type: "object", - properties: { - before: { - type: "boolean", - default: false - }, - after: { - type: "boolean", - default: true - } - }, - additionalProperties: false - } - ], - messages: { - missing: "A space is required {{loc}} ','.", - unexpected: "There should be no space {{loc}} ','." - } - }, - create(context) { - const sourceCode = context.sourceCode; - const tokensAndComments = sourceCode.tokensAndComments; - const options = { - before: context.options[0] ? context.options[0].before : false, - after: context.options[0] ? context.options[0].after : true - }; - const commaTokensToIgnore = []; - function report(node, loc, otherNode) { - context.report({ - node, - fix(fixer) { - if (options[loc]) { - if (loc === "before") - return fixer.insertTextBefore(node, " "); - return fixer.insertTextAfter(node, " "); - } - let start, end; - const newText = ""; - if (loc === "before") { - start = otherNode.range[1]; - end = node.range[0]; - } else { - start = node.range[1]; - end = otherNode.range[0]; - } - return fixer.replaceTextRange([start, end], newText); - }, - messageId: options[loc] ? "missing" : "unexpected", - data: { - loc - } - }); - } - function addNullElementsToIgnoreList(node) { - let previousToken = sourceCode.getFirstToken(node); - node.elements.forEach((element) => { - let token; - if (element === null) { - token = sourceCode.getTokenAfter(previousToken); - if (utils.isCommaToken(token)) - commaTokensToIgnore.push(token); - } else { - token = sourceCode.getTokenAfter(element); - } - previousToken = token; - }); - } - return { - "Program:exit": function() { - tokensAndComments.forEach((token, i) => { - if (!utils.isCommaToken(token)) - return; - const previousToken = tokensAndComments[i - 1]; - const nextToken = tokensAndComments[i + 1]; - if (previousToken && !utils.isCommaToken(previousToken) && !commaTokensToIgnore.includes(token) && utils.isTokenOnSameLine(previousToken, token) && options.before !== sourceCode.isSpaceBetweenTokens(previousToken, token)) { - report(token, "before", previousToken); - } - if (nextToken && !utils.isCommaToken(nextToken) && !utils.isClosingParenToken(nextToken) && !utils.isClosingBracketToken(nextToken) && !utils.isClosingBraceToken(nextToken) && !(!options.after && nextToken.type === "Line") && utils.isTokenOnSameLine(token, nextToken) && options.after !== sourceCode.isSpaceBetweenTokens(token, nextToken)) { - report(token, "after", nextToken); - } - }); - }, - "ArrayExpression": addNullElementsToIgnoreList, - "ArrayPattern": addNullElementsToIgnoreList - }; - } -}); - -exports.commaSpacing = commaSpacing; diff --git a/tools/eslint/node_modules/@stylistic/eslint-plugin-js/dist/comma-style.js b/tools/eslint/node_modules/@stylistic/eslint-plugin-js/dist/comma-style.js deleted file mode 100644 index 502ba3842c9296..00000000000000 --- a/tools/eslint/node_modules/@stylistic/eslint-plugin-js/dist/comma-style.js +++ /dev/null @@ -1,195 +0,0 @@ -'use strict'; - -var utils = require('./utils.js'); - -var commaStyle = utils.createRule({ - meta: { - type: "layout", - docs: { - description: "Enforce consistent comma style", - url: "https://eslint.style/rules/js/comma-style" - }, - fixable: "code", - schema: [ - { - type: "string", - enum: ["first", "last"] - }, - { - type: "object", - properties: { - exceptions: { - type: "object", - additionalProperties: { - type: "boolean" - } - } - }, - additionalProperties: false - } - ], - messages: { - unexpectedLineBeforeAndAfterComma: "Bad line breaking before and after ','.", - expectedCommaFirst: "',' should be placed first.", - expectedCommaLast: "',' should be placed last." - } - }, - create(context) { - var _a; - const style = context.options[0] || "last"; - const sourceCode = context.sourceCode; - const exceptions = { - ArrayPattern: true, - ArrowFunctionExpression: true, - CallExpression: true, - FunctionDeclaration: true, - FunctionExpression: true, - ImportDeclaration: true, - ObjectPattern: true, - NewExpression: true - }; - if (context.options.length === 2 && Object.prototype.hasOwnProperty.call(context.options[1], "exceptions")) { - (_a = context.options)[1] ?? (_a[1] = { exceptions: {} }); - const rawExceptions = context.options[1].exceptions; - const keys = Object.keys(rawExceptions); - for (let i = 0; i < keys.length; i++) - exceptions[keys[i]] = rawExceptions[keys[i]]; - } - function getReplacedText(styleType, text) { - switch (styleType) { - case "between": - return `,${text.replace(utils.LINEBREAK_MATCHER, "")}`; - case "first": - return `${text},`; - case "last": - return `,${text}`; - default: - return ""; - } - } - function getFixerFunction(styleType, previousItemToken, commaToken, currentItemToken) { - const text = sourceCode.text.slice(previousItemToken.range[1], commaToken.range[0]) + sourceCode.text.slice(commaToken.range[1], currentItemToken.range[0]); - const range = [previousItemToken.range[1], currentItemToken.range[0]]; - return function(fixer) { - return fixer.replaceTextRange(range, getReplacedText(styleType, text)); - }; - } - function validateCommaItemSpacing(previousItemToken, commaToken, currentItemToken, reportItem) { - if (utils.isTokenOnSameLine(commaToken, currentItemToken) && utils.isTokenOnSameLine(previousItemToken, commaToken)) ; else if (!utils.isTokenOnSameLine(commaToken, currentItemToken) && !utils.isTokenOnSameLine(previousItemToken, commaToken)) { - const comment = sourceCode.getCommentsAfter(commaToken)[0]; - const styleType = comment && comment.type === "Block" && utils.isTokenOnSameLine(commaToken, comment) ? style : "between"; - context.report({ - node: reportItem, - loc: commaToken.loc, - messageId: "unexpectedLineBeforeAndAfterComma", - fix: getFixerFunction(styleType, previousItemToken, commaToken, currentItemToken) - }); - } else if (style === "first" && !utils.isTokenOnSameLine(commaToken, currentItemToken)) { - context.report({ - node: reportItem, - loc: commaToken.loc, - messageId: "expectedCommaFirst", - fix: getFixerFunction(style, previousItemToken, commaToken, currentItemToken) - }); - } else if (style === "last" && utils.isTokenOnSameLine(commaToken, currentItemToken)) { - context.report({ - node: reportItem, - loc: commaToken.loc, - messageId: "expectedCommaLast", - fix: getFixerFunction(style, previousItemToken, commaToken, currentItemToken) - }); - } - } - function validateComma(node, property) { - const items = node[property]; - const arrayLiteral = node.type === "ArrayExpression" || node.type === "ArrayPattern"; - if (items.length > 1 || arrayLiteral) { - let previousItemToken = sourceCode.getFirstToken(node); - items.forEach((item) => { - const commaToken = item ? sourceCode.getTokenBefore(item) : previousItemToken; - const currentItemToken = item ? sourceCode.getFirstToken(item) : sourceCode.getTokenAfter(commaToken); - const reportItem = item || currentItemToken; - if (utils.isCommaToken(commaToken)) - validateCommaItemSpacing(previousItemToken, commaToken, currentItemToken, reportItem); - if (item) { - const tokenAfterItem = sourceCode.getTokenAfter(item, utils.isNotClosingParenToken); - previousItemToken = tokenAfterItem ? sourceCode.getTokenBefore(tokenAfterItem) : sourceCode.ast.tokens[sourceCode.ast.tokens.length - 1]; - } else { - previousItemToken = currentItemToken; - } - }); - if (arrayLiteral) { - const lastToken = sourceCode.getLastToken(node); - const nextToLastToken = sourceCode.getTokenBefore(lastToken); - if (utils.isCommaToken(nextToLastToken)) { - validateCommaItemSpacing( - sourceCode.getTokenBefore(nextToLastToken), - nextToLastToken, - lastToken, - lastToken - ); - } - } - } - } - const nodes = {}; - if (!exceptions.VariableDeclaration) { - nodes.VariableDeclaration = function(node) { - validateComma(node, "declarations"); - }; - } - if (!exceptions.ObjectExpression) { - nodes.ObjectExpression = function(node) { - validateComma(node, "properties"); - }; - } - if (!exceptions.ObjectPattern) { - nodes.ObjectPattern = function(node) { - validateComma(node, "properties"); - }; - } - if (!exceptions.ArrayExpression) { - nodes.ArrayExpression = function(node) { - validateComma(node, "elements"); - }; - } - if (!exceptions.ArrayPattern) { - nodes.ArrayPattern = function(node) { - validateComma(node, "elements"); - }; - } - if (!exceptions.FunctionDeclaration) { - nodes.FunctionDeclaration = function(node) { - validateComma(node, "params"); - }; - } - if (!exceptions.FunctionExpression) { - nodes.FunctionExpression = function(node) { - validateComma(node, "params"); - }; - } - if (!exceptions.ArrowFunctionExpression) { - nodes.ArrowFunctionExpression = function(node) { - validateComma(node, "params"); - }; - } - if (!exceptions.CallExpression) { - nodes.CallExpression = function(node) { - validateComma(node, "arguments"); - }; - } - if (!exceptions.ImportDeclaration) { - nodes.ImportDeclaration = function(node) { - validateComma(node, "specifiers"); - }; - } - if (!exceptions.NewExpression) { - nodes.NewExpression = function(node) { - validateComma(node, "arguments"); - }; - } - return nodes; - } -}); - -exports.commaStyle = commaStyle; diff --git a/tools/eslint/node_modules/@stylistic/eslint-plugin-js/dist/computed-property-spacing.js b/tools/eslint/node_modules/@stylistic/eslint-plugin-js/dist/computed-property-spacing.js deleted file mode 100644 index 17e91d511f30b1..00000000000000 --- a/tools/eslint/node_modules/@stylistic/eslint-plugin-js/dist/computed-property-spacing.js +++ /dev/null @@ -1,133 +0,0 @@ -'use strict'; - -var utils = require('./utils.js'); - -var computedPropertySpacing = utils.createRule({ - meta: { - type: "layout", - docs: { - description: "Enforce consistent spacing inside computed property brackets", - url: "https://eslint.style/rules/js/computed-property-spacing" - }, - fixable: "whitespace", - schema: [ - { - type: "string", - enum: ["always", "never"] - }, - { - type: "object", - properties: { - enforceForClassMembers: { - type: "boolean", - default: true - } - }, - additionalProperties: false - } - ], - messages: { - unexpectedSpaceBefore: "There should be no space before '{{tokenValue}}'.", - unexpectedSpaceAfter: "There should be no space after '{{tokenValue}}'.", - missingSpaceBefore: "A space is required before '{{tokenValue}}'.", - missingSpaceAfter: "A space is required after '{{tokenValue}}'." - } - }, - create(context) { - const sourceCode = context.sourceCode; - const propertyNameMustBeSpaced = context.options[0] === "always"; - const enforceForClassMembers = !context.options[1] || context.options[1].enforceForClassMembers; - function reportNoBeginningSpace(node, token, tokenAfter) { - context.report({ - node, - loc: { start: token.loc.end, end: tokenAfter.loc.start }, - messageId: "unexpectedSpaceAfter", - data: { - tokenValue: token.value - }, - fix(fixer) { - return fixer.removeRange([token.range[1], tokenAfter.range[0]]); - } - }); - } - function reportNoEndingSpace(node, token, tokenBefore) { - context.report({ - node, - loc: { start: tokenBefore.loc.end, end: token.loc.start }, - messageId: "unexpectedSpaceBefore", - data: { - tokenValue: token.value - }, - fix(fixer) { - return fixer.removeRange([tokenBefore.range[1], token.range[0]]); - } - }); - } - function reportRequiredBeginningSpace(node, token) { - context.report({ - node, - loc: token.loc, - messageId: "missingSpaceAfter", - data: { - tokenValue: token.value - }, - fix(fixer) { - return fixer.insertTextAfter(token, " "); - } - }); - } - function reportRequiredEndingSpace(node, token) { - context.report({ - node, - loc: token.loc, - messageId: "missingSpaceBefore", - data: { - tokenValue: token.value - }, - fix(fixer) { - return fixer.insertTextBefore(token, " "); - } - }); - } - function checkSpacing(propertyName) { - return function(node) { - if (!node.computed) - return; - const property = node[propertyName]; - const before = sourceCode.getTokenBefore(property, utils.isOpeningBracketToken); - const first = sourceCode.getTokenAfter(before, { includeComments: true }); - const after = sourceCode.getTokenAfter(property, utils.isClosingBracketToken); - const last = sourceCode.getTokenBefore(after, { includeComments: true }); - if (utils.isTokenOnSameLine(before, first)) { - if (propertyNameMustBeSpaced) { - if (!sourceCode.isSpaceBetweenTokens(before, first) && utils.isTokenOnSameLine(before, first)) - reportRequiredBeginningSpace(node, before); - } else { - if (sourceCode.isSpaceBetweenTokens(before, first)) - reportNoBeginningSpace(node, before, first); - } - } - if (utils.isTokenOnSameLine(last, after)) { - if (propertyNameMustBeSpaced) { - if (!sourceCode.isSpaceBetweenTokens(last, after) && utils.isTokenOnSameLine(last, after)) - reportRequiredEndingSpace(node, after); - } else { - if (sourceCode.isSpaceBetweenTokens(last, after)) - reportNoEndingSpace(node, after, last); - } - } - }; - } - const listeners = { - Property: checkSpacing("key"), - MemberExpression: checkSpacing("property") - }; - if (enforceForClassMembers) { - listeners.MethodDefinition = checkSpacing("key"); - listeners.PropertyDefinition = checkSpacing("key"); - } - return listeners; - } -}); - -exports.computedPropertySpacing = computedPropertySpacing; diff --git a/tools/eslint/node_modules/@stylistic/eslint-plugin-js/dist/configs.js b/tools/eslint/node_modules/@stylistic/eslint-plugin-js/dist/configs.js deleted file mode 100644 index 4841b0bd40b78d..00000000000000 --- a/tools/eslint/node_modules/@stylistic/eslint-plugin-js/dist/configs.js +++ /dev/null @@ -1,255 +0,0 @@ -'use strict'; - -var arrayBracketNewline = require('./array-bracket-newline.js'); -var arrayBracketSpacing = require('./array-bracket-spacing.js'); -var arrayElementNewline = require('./array-element-newline.js'); -var arrowParens = require('./arrow-parens.js'); -var arrowSpacing = require('./arrow-spacing.js'); -var blockSpacing = require('./block-spacing.js'); -var braceStyle = require('./brace-style.js'); -var commaDangle = require('./comma-dangle.js'); -var commaSpacing = require('./comma-spacing.js'); -var commaStyle = require('./comma-style.js'); -var computedPropertySpacing = require('./computed-property-spacing.js'); -var dotLocation = require('./dot-location.js'); -var eolLast = require('./eol-last.js'); -var functionCallArgumentNewline = require('./function-call-argument-newline.js'); -var functionCallSpacing = require('./function-call-spacing.js'); -var functionParenNewline = require('./function-paren-newline.js'); -var generatorStarSpacing = require('./generator-star-spacing.js'); -var implicitArrowLinebreak = require('./implicit-arrow-linebreak.js'); -var indent = require('./indent.js'); -var jsxQuotes = require('./jsx-quotes.js'); -var keySpacing = require('./key-spacing.js'); -var keywordSpacing = require('./keyword-spacing.js'); -var lineCommentPosition = require('./line-comment-position.js'); -var linebreakStyle = require('./linebreak-style.js'); -var linesAroundComment = require('./lines-around-comment.js'); -var linesBetweenClassMembers = require('./lines-between-class-members.js'); -var maxLen = require('./max-len.js'); -var maxStatementsPerLine = require('./max-statements-per-line.js'); -var multilineCommentStyle = require('./multiline-comment-style.js'); -var multilineTernary = require('./multiline-ternary.js'); -var newParens = require('./new-parens.js'); -var newlinePerChainedCall = require('./newline-per-chained-call.js'); -var noConfusingArrow = require('./no-confusing-arrow.js'); -var noExtraParens = require('./no-extra-parens.js'); -var noExtraSemi = require('./no-extra-semi.js'); -var noFloatingDecimal = require('./no-floating-decimal.js'); -var noMixedOperators = require('./no-mixed-operators.js'); -var noMixedSpacesAndTabs = require('./no-mixed-spaces-and-tabs.js'); -var noMultiSpaces = require('./no-multi-spaces.js'); -var noMultipleEmptyLines = require('./no-multiple-empty-lines.js'); -var noTabs = require('./no-tabs.js'); -var noTrailingSpaces = require('./no-trailing-spaces.js'); -var noWhitespaceBeforeProperty = require('./no-whitespace-before-property.js'); -var nonblockStatementBodyPosition = require('./nonblock-statement-body-position.js'); -var objectCurlyNewline = require('./object-curly-newline.js'); -var objectCurlySpacing = require('./object-curly-spacing.js'); -var objectPropertyNewline = require('./object-property-newline.js'); -var oneVarDeclarationPerLine = require('./one-var-declaration-per-line.js'); -var operatorLinebreak = require('./operator-linebreak.js'); -var paddedBlocks = require('./padded-blocks.js'); -var paddingLineBetweenStatements = require('./padding-line-between-statements.js'); -var quoteProps = require('./quote-props.js'); -var quotes = require('./quotes.js'); -var restSpreadSpacing = require('./rest-spread-spacing.js'); -var semi = require('./semi.js'); -var semiSpacing = require('./semi-spacing.js'); -var semiStyle = require('./semi-style.js'); -var spaceBeforeBlocks = require('./space-before-blocks.js'); -var spaceBeforeFunctionParen = require('./space-before-function-paren.js'); -var spaceInParens = require('./space-in-parens.js'); -var spaceInfixOps = require('./space-infix-ops.js'); -var spaceUnaryOps = require('./space-unary-ops.js'); -var spacedComment = require('./spaced-comment.js'); -var switchColonSpacing = require('./switch-colon-spacing.js'); -var templateCurlySpacing = require('./template-curly-spacing.js'); -var templateTagSpacing = require('./template-tag-spacing.js'); -var wrapIife = require('./wrap-iife.js'); -var wrapRegex = require('./wrap-regex.js'); -var yieldStarSpacing = require('./yield-star-spacing.js'); - -function createAllConfigs(plugin, name, flat, filter) { - const rules = Object.fromEntries( - Object.entries(plugin.rules).filter( - ([key, rule]) => ( - // Only include fixable rules - rule.meta.fixable && !rule.meta.deprecated && key === rule.meta.docs.url.split("/").pop() && (!filter ) - ) - ).map(([key]) => [`${name}/${key}`, 2]) - ); - if (flat) { - return { - plugins: { - [name]: plugin - }, - rules - }; - } else { - return { - plugins: [name], - rules - }; - } -} - -var rules = { - "array-bracket-newline": arrayBracketNewline.arrayBracketNewline, - "array-bracket-spacing": arrayBracketSpacing.arrayBracketSpacing, - "array-element-newline": arrayElementNewline.arrayElementNewline, - "arrow-parens": arrowParens.arrowParens, - "arrow-spacing": arrowSpacing.arrowSpacing, - "block-spacing": blockSpacing.blockSpacing, - "brace-style": braceStyle.braceStyle, - "comma-dangle": commaDangle.commaDangle, - "comma-spacing": commaSpacing.commaSpacing, - "comma-style": commaStyle.commaStyle, - "computed-property-spacing": computedPropertySpacing.computedPropertySpacing, - "dot-location": dotLocation.dotLocation, - "eol-last": eolLast.eolLast, - "func-call-spacing": functionCallSpacing.functionCallSpacing, - "function-call-argument-newline": functionCallArgumentNewline.functionCallArgumentNewline, - "function-call-spacing": functionCallSpacing.functionCallSpacing, - "function-paren-newline": functionParenNewline.functionParenNewline, - "generator-star-spacing": generatorStarSpacing.generatorStarSpacing, - "implicit-arrow-linebreak": implicitArrowLinebreak.implicitArrowLinebreak, - "indent": indent.indent, - "jsx-quotes": jsxQuotes.jsxQuotes, - "key-spacing": keySpacing.keySpacing, - "keyword-spacing": keywordSpacing.keywordSpacing, - "line-comment-position": lineCommentPosition.lineCommentPosition, - "linebreak-style": linebreakStyle.linebreakStyle, - "lines-around-comment": linesAroundComment.linesAroundComment, - "lines-between-class-members": linesBetweenClassMembers.linesBetweenClassMembers, - "max-len": maxLen.maxLen, - "max-statements-per-line": maxStatementsPerLine.maxStatementsPerLine, - "multiline-comment-style": multilineCommentStyle.multilineCommentStyle, - "multiline-ternary": multilineTernary.multilineTernary, - "new-parens": newParens.newParens, - "newline-per-chained-call": newlinePerChainedCall.newlinePerChainedCall, - "no-confusing-arrow": noConfusingArrow.noConfusingArrow, - "no-extra-parens": noExtraParens.noExtraParens, - "no-extra-semi": noExtraSemi.noExtraSemi, - "no-floating-decimal": noFloatingDecimal.noFloatingDecimal, - "no-mixed-operators": noMixedOperators.noMixedOperators, - "no-mixed-spaces-and-tabs": noMixedSpacesAndTabs.noMixedSpacesAndTabs, - "no-multi-spaces": noMultiSpaces.noMultiSpaces, - "no-multiple-empty-lines": noMultipleEmptyLines.noMultipleEmptyLines, - "no-tabs": noTabs.noTabs, - "no-trailing-spaces": noTrailingSpaces.noTrailingSpaces, - "no-whitespace-before-property": noWhitespaceBeforeProperty.noWhitespaceBeforeProperty, - "nonblock-statement-body-position": nonblockStatementBodyPosition.nonblockStatementBodyPosition, - "object-curly-newline": objectCurlyNewline.objectCurlyNewline, - "object-curly-spacing": objectCurlySpacing.objectCurlySpacing, - "object-property-newline": objectPropertyNewline.objectPropertyNewline, - "one-var-declaration-per-line": oneVarDeclarationPerLine.oneVarDeclarationPerLine, - "operator-linebreak": operatorLinebreak.operatorLinebreak, - "padded-blocks": paddedBlocks.paddedBlocks, - "padding-line-between-statements": paddingLineBetweenStatements.paddingLineBetweenStatements, - "quote-props": quoteProps.quoteProps, - "quotes": quotes.quotes, - "rest-spread-spacing": restSpreadSpacing.restSpreadSpacing, - "semi": semi.semi, - "semi-spacing": semiSpacing.semiSpacing, - "semi-style": semiStyle.semiStyle, - "space-before-blocks": spaceBeforeBlocks.spaceBeforeBlocks, - "space-before-function-paren": spaceBeforeFunctionParen.spaceBeforeFunctionParen, - "space-in-parens": spaceInParens.spaceInParens, - "space-infix-ops": spaceInfixOps.spaceInfixOps, - "space-unary-ops": spaceUnaryOps.spaceUnaryOps, - "spaced-comment": spacedComment.spacedComment, - "switch-colon-spacing": switchColonSpacing.switchColonSpacing, - "template-curly-spacing": templateCurlySpacing.templateCurlySpacing, - "template-tag-spacing": templateTagSpacing.templateTagSpacing, - "wrap-iife": wrapIife.wrapIife, - "wrap-regex": wrapRegex.wrapRegex, - "yield-star-spacing": yieldStarSpacing.yieldStarSpacing -}; - -var plugin = { - rules -}; - -const config = { - rules: { - "array-bracket-newline": 0, - "array-bracket-spacing": 0, - "array-element-newline": 0, - "arrow-parens": 0, - "arrow-spacing": 0, - "block-spacing": 0, - "brace-style": 0, - "comma-dangle": 0, - "comma-spacing": 0, - "comma-style": 0, - "computed-property-spacing": 0, - "dot-location": 0, - "eol-last": 0, - "func-call-spacing": 0, - "function-call-argument-newline": 0, - "function-paren-newline": 0, - "generator-star-spacing": 0, - "implicit-arrow-linebreak": 0, - "indent": 0, - "jsx-quotes": 0, - "key-spacing": 0, - "keyword-spacing": 0, - "line-comment-position": 0, - "linebreak-style": 0, - "lines-around-comment": 0, - "lines-between-class-members": 0, - "max-len": 0, - "max-statements-per-line": 0, - "multiline-comment-style": 0, - "multiline-ternary": 0, - "new-parens": 0, - "newline-per-chained-call": 0, - "no-confusing-arrow": 0, - "no-extra-parens": 0, - "no-extra-semi": 0, - "no-floating-decimal": 0, - "no-mixed-operators": 0, - "no-mixed-spaces-and-tabs": 0, - "no-multi-spaces": 0, - "no-multiple-empty-lines": 0, - "no-tabs": 0, - "no-trailing-spaces": 0, - "no-whitespace-before-property": 0, - "nonblock-statement-body-position": 0, - "object-curly-newline": 0, - "object-curly-spacing": 0, - "object-property-newline": 0, - "one-var-declaration-per-line": 0, - "operator-linebreak": 0, - "padded-blocks": 0, - "padding-line-between-statements": 0, - "quote-props": 0, - "quotes": 0, - "rest-spread-spacing": 0, - "semi": 0, - "semi-spacing": 0, - "semi-style": 0, - "space-before-blocks": 0, - "space-before-function-paren": 0, - "space-in-parens": 0, - "space-infix-ops": 0, - "space-unary-ops": 0, - "spaced-comment": 0, - "switch-colon-spacing": 0, - "template-curly-spacing": 0, - "template-tag-spacing": 0, - "wrap-iife": 0, - "wrap-regex": 0, - "yield-star-spacing": 0 - } -}; - -const configs = { - "disable-legacy": config, - "all-flat": createAllConfigs(plugin, "@stylistic/js", true), - "all-extends": createAllConfigs(plugin, "@stylistic/js", false) -}; - -exports.configs = configs; -exports.plugin = plugin; diff --git a/tools/eslint/node_modules/@stylistic/eslint-plugin-js/dist/dot-location.js b/tools/eslint/node_modules/@stylistic/eslint-plugin-js/dist/dot-location.js deleted file mode 100644 index 52edb942109e3b..00000000000000 --- a/tools/eslint/node_modules/@stylistic/eslint-plugin-js/dist/dot-location.js +++ /dev/null @@ -1,69 +0,0 @@ -'use strict'; - -var utils = require('./utils.js'); - -var dotLocation = utils.createRule({ - meta: { - type: "layout", - docs: { - description: "Enforce consistent newlines before and after dots", - url: "https://eslint.style/rules/js/dot-location" - }, - schema: [ - { - type: "string", - enum: ["object", "property"] - } - ], - fixable: "code", - messages: { - expectedDotAfterObject: "Expected dot to be on same line as object.", - expectedDotBeforeProperty: "Expected dot to be on same line as property." - } - }, - create(context) { - const config = context.options[0]; - const onObject = config === "object" || !config; - const sourceCode = context.sourceCode; - function checkDotLocation(node) { - const property = node.property; - const dotToken = sourceCode.getTokenBefore(property); - if (onObject && dotToken) { - const tokenBeforeDot = sourceCode.getTokenBefore(dotToken); - if (tokenBeforeDot && !utils.isTokenOnSameLine(tokenBeforeDot, dotToken)) { - context.report({ - node, - loc: dotToken.loc, - messageId: "expectedDotAfterObject", - *fix(fixer) { - if (dotToken.value.startsWith(".") && utils.isDecimalIntegerNumericToken(tokenBeforeDot)) - yield fixer.insertTextAfter(tokenBeforeDot, ` ${dotToken.value}`); - else - yield fixer.insertTextAfter(tokenBeforeDot, dotToken.value); - yield fixer.remove(dotToken); - } - }); - } - } else if (!utils.isTokenOnSameLine(dotToken, property) && dotToken) { - context.report({ - node, - loc: dotToken.loc, - messageId: "expectedDotBeforeProperty", - *fix(fixer) { - yield fixer.remove(dotToken); - yield fixer.insertTextBefore(property, dotToken.value); - } - }); - } - } - function checkNode(node) { - if (node.type === "MemberExpression" && !node.computed) - checkDotLocation(node); - } - return { - MemberExpression: checkNode - }; - } -}); - -exports.dotLocation = dotLocation; diff --git a/tools/eslint/node_modules/@stylistic/eslint-plugin-js/dist/eol-last.js b/tools/eslint/node_modules/@stylistic/eslint-plugin-js/dist/eol-last.js deleted file mode 100644 index 3eec714cc12722..00000000000000 --- a/tools/eslint/node_modules/@stylistic/eslint-plugin-js/dist/eol-last.js +++ /dev/null @@ -1,80 +0,0 @@ -'use strict'; - -var utils = require('./utils.js'); - -var eolLast = utils.createRule({ - meta: { - type: "layout", - docs: { - description: "Require or disallow newline at the end of files", - url: "https://eslint.style/rules/js/eol-last" - }, - fixable: "whitespace", - schema: [ - { - type: "string", - enum: ["always", "never", "unix", "windows"] - } - ], - messages: { - missing: "Newline required at end of file but not found.", - unexpected: "Newline not allowed at end of file." - } - }, - create(context) { - return { - Program: function checkBadEOF(node) { - const sourceCode = context.sourceCode; - const src = sourceCode.getText(); - const lastLine = sourceCode.lines[sourceCode.lines.length - 1]; - const location = { - column: lastLine.length, - line: sourceCode.lines.length - }; - const LF = "\n"; - const CRLF = `\r${LF}`; - const endsWithNewline = src.endsWith(LF); - if (!src.length) - return; - let mode = context.options[0] || "always"; - let appendCRLF = false; - if (mode === "unix") { - mode = "always"; - } - if (mode === "windows") { - mode = "always"; - appendCRLF = true; - } - if (mode === "always" && !endsWithNewline) { - context.report({ - node, - loc: location, - messageId: "missing", - fix(fixer) { - return fixer.insertTextAfterRange([0, src.length], appendCRLF ? CRLF : LF); - } - }); - } else if (mode === "never" && endsWithNewline) { - const secondLastLine = sourceCode.lines[sourceCode.lines.length - 2]; - context.report({ - node, - loc: { - start: { line: sourceCode.lines.length - 1, column: secondLastLine.length }, - end: { line: sourceCode.lines.length, column: 0 } - }, - messageId: "unexpected", - fix(fixer) { - const finalEOLs = /(?:\r?\n)+$/u; - const match = finalEOLs.exec(sourceCode.text); - const start = match.index; - const end = sourceCode.text.length; - return fixer.replaceTextRange([start, end], ""); - } - }); - } - } - }; - } -}); - -exports.eolLast = eolLast; diff --git a/tools/eslint/node_modules/@stylistic/eslint-plugin-js/dist/function-call-argument-newline.js b/tools/eslint/node_modules/@stylistic/eslint-plugin-js/dist/function-call-argument-newline.js deleted file mode 100644 index 6845a00768c142..00000000000000 --- a/tools/eslint/node_modules/@stylistic/eslint-plugin-js/dist/function-call-argument-newline.js +++ /dev/null @@ -1,84 +0,0 @@ -'use strict'; - -var utils = require('./utils.js'); - -var functionCallArgumentNewline = utils.createRule({ - meta: { - type: "layout", - docs: { - description: "Enforce line breaks between arguments of a function call", - url: "https://eslint.style/rules/js/function-call-argument-newline" - }, - fixable: "whitespace", - schema: [ - { - type: "string", - enum: ["always", "never", "consistent"] - } - ], - messages: { - unexpectedLineBreak: "There should be no line break here.", - missingLineBreak: "There should be a line break after this argument." - } - }, - create(context) { - const sourceCode = context.sourceCode; - const checkers = { - unexpected: { - messageId: "unexpectedLineBreak", - check: (prevToken, currentToken) => prevToken.loc.end.line !== currentToken.loc.start.line, - createFix: (token, tokenBefore) => (fixer) => fixer.replaceTextRange([tokenBefore.range[1], token.range[0]], " ") - }, - missing: { - messageId: "missingLineBreak", - check: (prevToken, currentToken) => prevToken.loc.end.line === currentToken.loc.start.line, - createFix: (token, tokenBefore) => (fixer) => fixer.replaceTextRange([tokenBefore.range[1], token.range[0]], "\n") - } - }; - function checkArguments(node, checker) { - for (let i = 1; i < node.arguments.length; i++) { - const prevArgToken = sourceCode.getLastToken(node.arguments[i - 1]); - const currentArgToken = sourceCode.getFirstToken(node.arguments[i]); - if (checker.check(prevArgToken, currentArgToken)) { - const tokenBefore = sourceCode.getTokenBefore( - currentArgToken, - { includeComments: true } - ); - const hasLineCommentBefore = tokenBefore.type === "Line"; - context.report({ - node, - loc: { - start: tokenBefore.loc.end, - end: currentArgToken.loc.start - }, - messageId: checker.messageId, - fix: hasLineCommentBefore ? null : checker.createFix(currentArgToken, tokenBefore) - }); - } - } - } - function check(node) { - if (node.arguments.length < 2) - return; - const option = context.options[0] || "always"; - if (option === "never") { - checkArguments(node, checkers.unexpected); - } else if (option === "always") { - checkArguments(node, checkers.missing); - } else if (option === "consistent") { - const firstArgToken = sourceCode.getLastToken(node.arguments[0]); - const secondArgToken = sourceCode.getFirstToken(node.arguments[1]); - if (firstArgToken?.loc.end.line === secondArgToken?.loc.start.line) - checkArguments(node, checkers.unexpected); - else - checkArguments(node, checkers.missing); - } - } - return { - CallExpression: check, - NewExpression: check - }; - } -}); - -exports.functionCallArgumentNewline = functionCallArgumentNewline; diff --git a/tools/eslint/node_modules/@stylistic/eslint-plugin-js/dist/function-call-spacing.js b/tools/eslint/node_modules/@stylistic/eslint-plugin-js/dist/function-call-spacing.js deleted file mode 100644 index b8a90d45a67d92..00000000000000 --- a/tools/eslint/node_modules/@stylistic/eslint-plugin-js/dist/function-call-spacing.js +++ /dev/null @@ -1,144 +0,0 @@ -'use strict'; - -var utils = require('./utils.js'); - -var functionCallSpacing = utils.createRule({ - meta: { - type: "layout", - docs: { - description: "Require or disallow spacing between function identifiers and their invocations", - url: "https://eslint.style/rules/js/function-call-spacing" - }, - fixable: "whitespace", - schema: { - anyOf: [ - { - type: "array", - items: [ - { - type: "string", - enum: ["never"] - } - ], - minItems: 0, - maxItems: 1 - }, - { - type: "array", - items: [ - { - type: "string", - enum: ["always"] - }, - { - type: "object", - properties: { - allowNewlines: { - type: "boolean" - } - }, - additionalProperties: false - } - ], - minItems: 0, - maxItems: 2 - } - ] - }, - messages: { - unexpectedWhitespace: "Unexpected whitespace between function name and paren.", - unexpectedNewline: "Unexpected newline between function name and paren.", - missing: "Missing space between function name and paren." - } - }, - create(context) { - const never = context.options[0] !== "always"; - const allowNewlines = !never && context.options[1] && context.options[1].allowNewlines; - const sourceCode = context.sourceCode; - const text = sourceCode.getText(); - function checkSpacing(node, leftToken, rightToken) { - const textBetweenTokens = text.slice(leftToken.range[1], rightToken.range[0]).replace(/\/\*.*?\*\//gu, ""); - const hasWhitespace = /\s/u.test(textBetweenTokens); - const hasNewline = hasWhitespace && utils.LINEBREAK_MATCHER.test(textBetweenTokens); - if (never && hasWhitespace) { - context.report({ - node, - loc: { - start: leftToken.loc.end, - end: { - line: rightToken.loc.start.line, - column: rightToken.loc.start.column - 1 - } - }, - messageId: "unexpectedWhitespace", - fix(fixer) { - if (sourceCode.commentsExistBetween(leftToken, rightToken)) - return null; - if ("optional" in node && node.optional) - return fixer.replaceTextRange([leftToken.range[1], rightToken.range[0]], "?."); - if (hasNewline) - return null; - return fixer.removeRange([leftToken.range[1], rightToken.range[0]]); - } - }); - } else if (!never && !hasWhitespace) { - context.report({ - node, - loc: { - start: { - line: leftToken.loc.end.line, - column: leftToken.loc.end.column - 1 - }, - end: rightToken.loc.start - }, - messageId: "missing", - fix(fixer) { - if ("optional" in node && node.optional) - return null; - return fixer.insertTextBefore(rightToken, " "); - } - }); - } else if (!never && !allowNewlines && hasNewline) { - context.report({ - node, - loc: { - start: leftToken.loc.end, - end: rightToken.loc.start - }, - messageId: "unexpectedNewline", - fix(fixer) { - if (!("optional" in node) || !node.optional) - return null; - if (sourceCode.commentsExistBetween(leftToken, rightToken)) - return null; - const range = [leftToken.range[1], rightToken.range[0]]; - const qdToken = sourceCode.getTokenAfter(leftToken); - if (qdToken.range[0] === leftToken.range[1]) - return fixer.replaceTextRange(range, "?. "); - if (qdToken.range[1] === rightToken.range[0]) - return fixer.replaceTextRange(range, " ?."); - return fixer.replaceTextRange(range, " ?. "); - } - }); - } - } - return { - "CallExpression, NewExpression": function(node) { - const lastToken = sourceCode.getLastToken(node); - const lastCalleeToken = sourceCode.getLastToken(node.callee); - const parenToken = sourceCode.getFirstTokenBetween(lastCalleeToken, lastToken, utils.isOpeningParenToken); - const prevToken = parenToken && sourceCode.getTokenBefore(parenToken, utils.isNotQuestionDotToken); - if (!(parenToken && parenToken.range[1] < node.range[1])) - return; - checkSpacing(node, prevToken, parenToken); - }, - ImportExpression(node) { - const leftToken = sourceCode.getFirstToken(node); - const rightToken = sourceCode.getTokenAfter(leftToken); - checkSpacing(node, leftToken, rightToken); - } - }; - } -}); - -exports.functionCallSpacing = functionCallSpacing; diff --git a/tools/eslint/node_modules/@stylistic/eslint-plugin-js/dist/function-paren-newline.js b/tools/eslint/node_modules/@stylistic/eslint-plugin-js/dist/function-paren-newline.js deleted file mode 100644 index b04502763ff344..00000000000000 --- a/tools/eslint/node_modules/@stylistic/eslint-plugin-js/dist/function-paren-newline.js +++ /dev/null @@ -1,194 +0,0 @@ -'use strict'; - -var utils = require('./utils.js'); - -var functionParenNewline = utils.createRule({ - meta: { - type: "layout", - docs: { - description: "Enforce consistent line breaks inside function parentheses", - url: "https://eslint.style/rules/js/function-paren-newline" - }, - fixable: "whitespace", - schema: [ - { - oneOf: [ - { - type: "string", - enum: ["always", "never", "consistent", "multiline", "multiline-arguments"] - }, - { - type: "object", - properties: { - minItems: { - type: "integer", - minimum: 0 - } - }, - additionalProperties: false - } - ] - } - ], - messages: { - expectedBefore: "Expected newline before ')'.", - expectedAfter: "Expected newline after '('.", - expectedBetween: "Expected newline between arguments/params.", - unexpectedBefore: "Unexpected newline before ')'.", - unexpectedAfter: "Unexpected newline after '('." - } - }, - create(context) { - const sourceCode = context.sourceCode; - const rawOption = context.options[0] || "multiline"; - const multilineOption = rawOption === "multiline"; - const multilineArgumentsOption = rawOption === "multiline-arguments"; - const consistentOption = rawOption === "consistent"; - let minItems; - if (typeof rawOption === "object") - minItems = rawOption.minItems; - else if (rawOption === "always") - minItems = 0; - else if (rawOption === "never") - minItems = Infinity; - function shouldHaveNewlines(elements, hasLeftNewline) { - if (multilineArgumentsOption && elements.length === 1) - return hasLeftNewline; - if (multilineOption || multilineArgumentsOption) - return elements.some((element, index) => index !== elements.length - 1 && element.loc.end.line !== elements[index + 1].loc.start.line); - if (consistentOption) - return hasLeftNewline; - return minItems == null || elements.length >= minItems; - } - function validateParens(parens, elements) { - const leftParen = parens.leftParen; - const rightParen = parens.rightParen; - const tokenAfterLeftParen = sourceCode.getTokenAfter(leftParen); - const tokenBeforeRightParen = sourceCode.getTokenBefore(rightParen); - const hasLeftNewline = !utils.isTokenOnSameLine(leftParen, tokenAfterLeftParen); - const hasRightNewline = !utils.isTokenOnSameLine(tokenBeforeRightParen, rightParen); - const needsNewlines = shouldHaveNewlines(elements, hasLeftNewline); - if (hasLeftNewline && !needsNewlines) { - context.report({ - node: leftParen, - messageId: "unexpectedAfter", - fix(fixer) { - return sourceCode.getText().slice(leftParen.range[1], tokenAfterLeftParen.range[0]).trim() ? null : fixer.removeRange([leftParen.range[1], tokenAfterLeftParen.range[0]]); - } - }); - } else if (!hasLeftNewline && needsNewlines) { - context.report({ - node: leftParen, - messageId: "expectedAfter", - fix: (fixer) => fixer.insertTextAfter(leftParen, "\n") - }); - } - if (hasRightNewline && !needsNewlines) { - context.report({ - node: rightParen, - messageId: "unexpectedBefore", - fix(fixer) { - return sourceCode.getText().slice(tokenBeforeRightParen.range[1], rightParen.range[0]).trim() ? null : fixer.removeRange([tokenBeforeRightParen.range[1], rightParen.range[0]]); - } - }); - } else if (!hasRightNewline && needsNewlines) { - context.report({ - node: rightParen, - messageId: "expectedBefore", - fix: (fixer) => fixer.insertTextBefore(rightParen, "\n") - }); - } - } - function validateArguments(parens, elements) { - const leftParen = parens.leftParen; - const tokenAfterLeftParen = sourceCode.getTokenAfter(leftParen); - const hasLeftNewline = !utils.isTokenOnSameLine(leftParen, tokenAfterLeftParen); - const needsNewlines = shouldHaveNewlines(elements, hasLeftNewline); - for (let i = 0; i <= elements.length - 2; i++) { - const currentElement = elements[i]; - const nextElement = elements[i + 1]; - const hasNewLine = currentElement.loc.end.line !== nextElement.loc.start.line; - if (!hasNewLine && needsNewlines) { - context.report({ - node: currentElement, - messageId: "expectedBetween", - fix: (fixer) => fixer.insertTextBefore(nextElement, "\n") - }); - } - } - } - function getParenTokens(node) { - const isOpeningParenTokenOutsideTypeParameter = () => { - let typeParameterOpeningLevel = 0; - return (token) => { - if (token.type === "Punctuator" && token.value === "<") - typeParameterOpeningLevel += 1; - if (token.type === "Punctuator" && token.value === ">") - typeParameterOpeningLevel -= 1; - return typeParameterOpeningLevel !== 0 ? false : utils.isOpeningParenToken(token); - }; - }; - switch (node.type) { - case "NewExpression": - if (!node.arguments.length && !(utils.isOpeningParenToken(sourceCode.getLastToken(node, { skip: 1 })) && utils.isClosingParenToken(sourceCode.getLastToken(node)) && node.callee.range[1] < node.range[1])) { - return null; - } - case "CallExpression": - return { - leftParen: sourceCode.getTokenAfter(node.callee, isOpeningParenTokenOutsideTypeParameter()), - rightParen: sourceCode.getLastToken(node) - }; - case "FunctionDeclaration": - case "FunctionExpression": { - const leftParen = sourceCode.getFirstToken(node, isOpeningParenTokenOutsideTypeParameter()); - const rightParen = node.params.length ? sourceCode.getTokenAfter(node.params[node.params.length - 1], utils.isClosingParenToken) : sourceCode.getTokenAfter(leftParen); - return { leftParen, rightParen }; - } - case "ArrowFunctionExpression": { - const firstToken = sourceCode.getFirstToken(node, { skip: node.async ? 1 : 0 }); - if (!utils.isOpeningParenToken(firstToken)) { - return null; - } - const rightParen = node.params.length ? sourceCode.getTokenAfter(node.params[node.params.length - 1], utils.isClosingParenToken) : sourceCode.getTokenAfter(firstToken); - return { - leftParen: firstToken, - rightParen - }; - } - case "ImportExpression": { - const leftParen = sourceCode.getFirstToken(node, 1); - const rightParen = sourceCode.getLastToken(node); - return { leftParen, rightParen }; - } - default: - throw new TypeError(`unexpected node with type ${node.type}`); - } - } - return { - [[ - "ArrowFunctionExpression", - "CallExpression", - "FunctionDeclaration", - "FunctionExpression", - "ImportExpression", - "NewExpression" - ].join(", ")](node) { - const parens = getParenTokens(node); - let params; - if (node.type === "ImportExpression") - params = [node.source]; - else if (utils.isFunction(node)) - params = node.params; - else - params = node.arguments; - if (parens) { - validateParens(parens, params); - if (multilineArgumentsOption) - validateArguments(parens, params); - } - } - }; - } -}); - -exports.functionParenNewline = functionParenNewline; diff --git a/tools/eslint/node_modules/@stylistic/eslint-plugin-js/dist/generator-star-spacing.js b/tools/eslint/node_modules/@stylistic/eslint-plugin-js/dist/generator-star-spacing.js deleted file mode 100644 index e863c7ea3e0da7..00000000000000 --- a/tools/eslint/node_modules/@stylistic/eslint-plugin-js/dist/generator-star-spacing.js +++ /dev/null @@ -1,132 +0,0 @@ -'use strict'; - -var utils = require('./utils.js'); - -const OVERRIDE_SCHEMA = { - oneOf: [ - { - type: "string", - enum: ["before", "after", "both", "neither"] - }, - { - type: "object", - properties: { - before: { type: "boolean" }, - after: { type: "boolean" } - }, - additionalProperties: false - } - ] -}; -var generatorStarSpacing = utils.createRule({ - meta: { - type: "layout", - docs: { - description: "Enforce consistent spacing around `*` operators in generator functions", - url: "https://eslint.style/rules/js/generator-star-spacing" - }, - fixable: "whitespace", - schema: [ - { - oneOf: [ - { - type: "string", - enum: ["before", "after", "both", "neither"] - }, - { - type: "object", - properties: { - before: { type: "boolean" }, - after: { type: "boolean" }, - named: OVERRIDE_SCHEMA, - anonymous: OVERRIDE_SCHEMA, - method: OVERRIDE_SCHEMA - }, - additionalProperties: false - } - ] - } - ], - messages: { - missingBefore: "Missing space before *.", - missingAfter: "Missing space after *.", - unexpectedBefore: "Unexpected space before *.", - unexpectedAfter: "Unexpected space after *." - } - }, - create(context) { - const optionDefinitions = { - before: { before: true, after: false }, - after: { before: false, after: true }, - both: { before: true, after: true }, - neither: { before: false, after: false } - }; - function optionToDefinition(option, defaults) { - if (!option) - return defaults; - return typeof option === "string" ? optionDefinitions[option] : Object.assign({}, defaults, option); - } - const modes = function(option) { - const defaults = optionToDefinition(option, optionDefinitions.before); - return { - named: optionToDefinition(option.named, defaults), - anonymous: optionToDefinition(option.anonymous, defaults), - method: optionToDefinition(option.method, defaults) - }; - }(context.options[0] || {}); - const sourceCode = context.sourceCode; - function isStarToken(token) { - return token.value === "*" && token.type === "Punctuator"; - } - function getStarToken(node) { - return sourceCode.getFirstToken( - "method" in node.parent && node.parent.method || node.parent.type === "MethodDefinition" ? node.parent : node, - isStarToken - ); - } - function capitalize(str) { - return str[0].toUpperCase() + str.slice(1); - } - function checkSpacing(kind, side, leftToken, rightToken) { - if (!!(rightToken.range[0] - leftToken.range[1]) !== modes[kind][side]) { - const after = leftToken.value === "*"; - const spaceRequired = modes[kind][side]; - const node = after ? leftToken : rightToken; - const messageId = `${spaceRequired ? "missing" : "unexpected"}${capitalize(side)}`; - context.report({ - node, - messageId, - fix(fixer) { - if (spaceRequired) { - if (after) - return fixer.insertTextAfter(node, " "); - return fixer.insertTextBefore(node, " "); - } - return fixer.removeRange([leftToken.range[1], rightToken.range[0]]); - } - }); - } - } - function checkFunction(node) { - if (!node.generator) - return; - const starToken = getStarToken(node); - const prevToken = sourceCode.getTokenBefore(starToken); - const nextToken = sourceCode.getTokenAfter(starToken); - let kind = "named"; - if (node.parent.type === "MethodDefinition" || node.parent.type === "Property" && node.parent.method) - kind = "method"; - else if (!node.id) - kind = "anonymous"; - if (!(kind === "method" && starToken === sourceCode.getFirstToken(node.parent))) - checkSpacing(kind, "before", prevToken, starToken); - checkSpacing(kind, "after", starToken, nextToken); - } - return { - FunctionDeclaration: checkFunction, - FunctionExpression: checkFunction - }; - } -}); - -exports.generatorStarSpacing = generatorStarSpacing; diff --git a/tools/eslint/node_modules/@stylistic/eslint-plugin-js/dist/implicit-arrow-linebreak.js b/tools/eslint/node_modules/@stylistic/eslint-plugin-js/dist/implicit-arrow-linebreak.js deleted file mode 100644 index 3bed145a63414e..00000000000000 --- a/tools/eslint/node_modules/@stylistic/eslint-plugin-js/dist/implicit-arrow-linebreak.js +++ /dev/null @@ -1,56 +0,0 @@ -'use strict'; - -var utils = require('./utils.js'); - -var implicitArrowLinebreak = utils.createRule({ - meta: { - type: "layout", - docs: { - description: "Enforce the location of arrow function bodies", - url: "https://eslint.style/rules/js/implicit-arrow-linebreak" - }, - fixable: "whitespace", - schema: [ - { - type: "string", - enum: ["beside", "below"] - } - ], - messages: { - expected: "Expected a linebreak before this expression.", - unexpected: "Expected no linebreak before this expression." - } - }, - create(context) { - const sourceCode = context.sourceCode; - const option = context.options[0] || "beside"; - function validateExpression(node) { - if (node.body.type === "BlockStatement") - return; - const arrowToken = sourceCode.getTokenBefore(node.body, utils.isNotOpeningParenToken); - const firstTokenOfBody = sourceCode.getTokenAfter(arrowToken); - if (arrowToken.loc.end.line === firstTokenOfBody.loc.start.line && option === "below") { - context.report({ - node: firstTokenOfBody, - messageId: "expected", - fix: (fixer) => fixer.insertTextBefore(firstTokenOfBody, "\n") - }); - } else if (arrowToken.loc.end.line !== firstTokenOfBody.loc.start.line && option === "beside") { - context.report({ - node: firstTokenOfBody, - messageId: "unexpected", - fix(fixer) { - if (sourceCode.getFirstTokenBetween(arrowToken, firstTokenOfBody, { includeComments: true, filter: utils.isCommentToken })) - return null; - return fixer.replaceTextRange([arrowToken.range[1], firstTokenOfBody.range[0]], " "); - } - }); - } - } - return { - ArrowFunctionExpression: (node) => validateExpression(node) - }; - } -}); - -exports.implicitArrowLinebreak = implicitArrowLinebreak; diff --git a/tools/eslint/node_modules/@stylistic/eslint-plugin-js/dist/indent.js b/tools/eslint/node_modules/@stylistic/eslint-plugin-js/dist/indent.js deleted file mode 100644 index 7f3bec52653ce5..00000000000000 --- a/tools/eslint/node_modules/@stylistic/eslint-plugin-js/dist/indent.js +++ /dev/null @@ -1,1254 +0,0 @@ -'use strict'; - -var utils = require('./utils.js'); - -var __defProp = Object.defineProperty; -var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value; -var __publicField = (obj, key, value) => { - __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value); - return value; -}; -const KNOWN_NODES = /* @__PURE__ */ new Set([ - "AssignmentExpression", - "AssignmentPattern", - "ArrayExpression", - "ArrayPattern", - "ArrowFunctionExpression", - "AwaitExpression", - "BlockStatement", - "BinaryExpression", - "BreakStatement", - "CallExpression", - "CatchClause", - "ChainExpression", - "ClassBody", - "ClassDeclaration", - "ClassExpression", - "ConditionalExpression", - "ContinueStatement", - "DoWhileStatement", - "DebuggerStatement", - "EmptyStatement", - "ExpressionStatement", - "ForStatement", - "ForInStatement", - "ForOfStatement", - "FunctionDeclaration", - "FunctionExpression", - "Identifier", - "IfStatement", - "Literal", - "LabeledStatement", - "LogicalExpression", - "MemberExpression", - "MetaProperty", - "MethodDefinition", - "NewExpression", - "ObjectExpression", - "ObjectPattern", - "PrivateIdentifier", - "Program", - "Property", - "PropertyDefinition", - "RestElement", - "ReturnStatement", - "SequenceExpression", - "SpreadElement", - "StaticBlock", - "Super", - "SwitchCase", - "SwitchStatement", - "TaggedTemplateExpression", - "TemplateElement", - "TemplateLiteral", - "ThisExpression", - "ThrowStatement", - "TryStatement", - "UnaryExpression", - "UpdateExpression", - "VariableDeclaration", - "VariableDeclarator", - "WhileStatement", - "WithStatement", - "YieldExpression", - "JSXFragment", - "JSXOpeningFragment", - "JSXClosingFragment", - "JSXIdentifier", - "JSXNamespacedName", - "JSXMemberExpression", - "JSXEmptyExpression", - "JSXExpressionContainer", - "JSXElement", - "JSXClosingElement", - "JSXOpeningElement", - "JSXAttribute", - "JSXSpreadAttribute", - "JSXText", - "ExportDefaultDeclaration", - "ExportNamedDeclaration", - "ExportAllDeclaration", - "ExportSpecifier", - "ImportDeclaration", - "ImportSpecifier", - "ImportDefaultSpecifier", - "ImportNamespaceSpecifier", - "ImportExpression" -]); -class IndexMap { - /** - * Creates an empty map - * @param maxKey The maximum key - */ - constructor(maxKey) { - __publicField(this, "_values"); - this._values = Array(maxKey + 1); - } - /** - * Inserts an entry into the map. - * @param key The entry's key - * @param value The entry's value - */ - insert(key, value) { - this._values[key] = value; - } - /** - * Finds the value of the entry with the largest key less than or equal to the provided key - * @param key The provided key - * @returns The value of the found entry, or undefined if no such entry exists. - */ - findLastNotAfter(key) { - const values = this._values; - for (let index = key; index >= 0; index--) { - const value = values[index]; - if (value) - return value; - } - } - /** - * Deletes all of the keys in the interval [start, end) - * @param start The start of the range - * @param end The end of the range - */ - deleteRange(start, end) { - this._values.fill(void 0, start, end); - } -} -class TokenInfo { - /** - * @param sourceCode A SourceCode object - */ - constructor(sourceCode) { - __publicField(this, "sourceCode"); - __publicField(this, "firstTokensByLineNumber"); - this.sourceCode = sourceCode; - this.firstTokensByLineNumber = /* @__PURE__ */ new Map(); - const tokens = sourceCode.tokensAndComments; - for (let i = 0; i < tokens.length; i++) { - const token = tokens[i]; - if (!this.firstTokensByLineNumber.has(token.loc.start.line)) - this.firstTokensByLineNumber.set(token.loc.start.line, token); - if (!this.firstTokensByLineNumber.has(token.loc.end.line) && sourceCode.text.slice(token.range[1] - token.loc.end.column, token.range[1]).trim()) - this.firstTokensByLineNumber.set(token.loc.end.line, token); - } - } - /** - * Gets the first token on a given token's line - * @param token a node or token - * @returns The first token on the given line - */ - getFirstTokenOfLine(token) { - return this.firstTokensByLineNumber.get(token.loc.start.line); - } - /** - * Determines whether a token is the first token in its line - * @param token The token - * @returns `true` if the token is the first on its line - */ - isFirstTokenOfLine(token) { - return this.getFirstTokenOfLine(token) === token; - } - /** - * Get the actual indent of a token - * @param token Token to examine. This should be the first token on its line. - * @returns The indentation characters that precede the token - */ - getTokenIndent(token) { - return this.sourceCode.text.slice(token.range[0] - token.loc.start.column, token.range[0]); - } -} -class OffsetStorage { - /** - * @param tokenInfo a TokenInfo instance - * @param indentSize The desired size of each indentation level - * @param indentType The indentation character - * @param maxIndex The maximum end index of any token - */ - constructor(tokenInfo, indentSize, indentType, maxIndex) { - __publicField(this, "_tokenInfo"); - __publicField(this, "_indentSize"); - __publicField(this, "_indentType"); - __publicField(this, "_indexMap"); - __publicField(this, "_lockedFirstTokens", /* @__PURE__ */ new WeakMap()); - __publicField(this, "_desiredIndentCache", /* @__PURE__ */ new WeakMap()); - __publicField(this, "_ignoredTokens", /* @__PURE__ */ new WeakSet()); - this._tokenInfo = tokenInfo; - this._indentSize = indentSize; - this._indentType = indentType; - this._indexMap = new IndexMap(maxIndex); - this._indexMap.insert(0, { offset: 0, from: null, force: false }); - } - _getOffsetDescriptor(token) { - return this._indexMap.findLastNotAfter(token.range[0]); - } - /** - * Sets the offset column of token B to match the offset column of token A. - * - **WARNING**: This matches a *column*, even if baseToken is not the first token on its line. In - * most cases, `setDesiredOffset` should be used instead. - * @param baseToken The first token - * @param offsetToken The second token, whose offset should be matched to the first token - */ - matchOffsetOf(baseToken, offsetToken) { - this._lockedFirstTokens.set(offsetToken, baseToken); - } - /** - * Sets the desired offset of a token. - * - * This uses a line-based offset collapsing behavior to handle tokens on the same line. - * For example, consider the following two cases: - * - * ( - * [ - * bar - * ] - * ) - * - * ([ - * bar - * ]) - * - * Based on the first case, it's clear that the `bar` token needs to have an offset of 1 indent level (4 spaces) from - * the `[` token, and the `[` token has to have an offset of 1 indent level from the `(` token. Since the `(` token is - * the first on its line (with an indent of 0 spaces), the `bar` token needs to be offset by 2 indent levels (8 spaces) - * from the start of its line. - * - * However, in the second case `bar` should only be indented by 4 spaces. This is because the offset of 1 indent level - * between the `(` and the `[` tokens gets "collapsed" because the two tokens are on the same line. As a result, the - * `(` token is mapped to the `[` token with an offset of 0, and the rule correctly decides that `bar` should be indented - * by 1 indent level from the start of the line. - * - * This is useful because rule listeners can usually just call `setDesiredOffset` for all the tokens in the node, - * without needing to check which lines those tokens are on. - * - * Note that since collapsing only occurs when two tokens are on the same line, there are a few cases where non-intuitive - * behavior can occur. For example, consider the following cases: - * - * foo( - * ). - * bar( - * baz - * ) - * - * foo( - * ).bar( - * baz - * ) - * - * Based on the first example, it would seem that `bar` should be offset by 1 indent level from `foo`, and `baz` - * should be offset by 1 indent level from `bar`. However, this is not correct, because it would result in `baz` - * being indented by 2 indent levels in the second case (since `foo`, `bar`, and `baz` are all on separate lines, no - * collapsing would occur). - * - * Instead, the correct way would be to offset `baz` by 1 level from `bar`, offset `bar` by 1 level from the `)`, and - * offset the `)` by 0 levels from `foo`. This ensures that the offset between `bar` and the `)` are correctly collapsed - * in the second case. - * @param token The token - * @param fromToken The token that `token` should be offset from - * @param offset The desired indent level - */ - setDesiredOffset(token, fromToken, offset) { - if (token) - this.setDesiredOffsets(token.range, fromToken, offset); - } - /** - * Sets the desired offset of all tokens in a range - * It's common for node listeners in this file to need to apply the same offset to a large, contiguous range of tokens. - * Moreover, the offset of any given token is usually updated multiple times (roughly once for each node that contains - * it). This means that the offset of each token is updated O(AST depth) times. - * It would not be performant to store and update the offsets for each token independently, because the rule would end - * up having a time complexity of O(number of tokens * AST depth), which is quite slow for large files. - * - * Instead, the offset tree is represented as a collection of contiguous offset ranges in a file. For example, the following - * list could represent the state of the offset tree at a given point: - * - * - Tokens starting in the interval [0, 15) are aligned with the beginning of the file - * - Tokens starting in the interval [15, 30) are offset by 1 indent level from the `bar` token - * - Tokens starting in the interval [30, 43) are offset by 1 indent level from the `foo` token - * - Tokens starting in the interval [43, 820) are offset by 2 indent levels from the `bar` token - * - Tokens starting in the interval [820, โˆž) are offset by 1 indent level from the `baz` token - * - * The `setDesiredOffsets` methods inserts ranges like the ones above. The third line above would be inserted by using: - * `setDesiredOffsets([30, 43], fooToken, 1);` - * @param range A [start, end] pair. All tokens with range[0] <= token.start < range[1] will have the offset applied. - * @param fromToken The token that this is offset from - * @param offset The desired indent level - * @param force `true` if this offset should not use the normal collapsing behavior. This should almost always be false. - */ - setDesiredOffsets(range, fromToken, offset, force = false) { - const descriptorToInsert = { offset, from: fromToken, force }; - const descriptorAfterRange = this._indexMap.findLastNotAfter(range[1]); - const fromTokenIsInRange = fromToken && fromToken.range[0] >= range[0] && fromToken.range[1] <= range[1]; - const fromTokenDescriptor = fromTokenIsInRange && this._getOffsetDescriptor(fromToken); - this._indexMap.deleteRange(range[0] + 1, range[1]); - this._indexMap.insert(range[0], descriptorToInsert); - if (fromTokenIsInRange) { - this._indexMap.insert(fromToken.range[0], fromTokenDescriptor); - this._indexMap.insert(fromToken.range[1], descriptorToInsert); - } - this._indexMap.insert(range[1], descriptorAfterRange); - } - /** - * Gets the desired indent of a token - * @param token The token - * @returns The desired indent of the token - */ - getDesiredIndent(token) { - if (!this._desiredIndentCache.has(token)) { - if (this._ignoredTokens.has(token)) { - this._desiredIndentCache.set( - token, - this._tokenInfo.getTokenIndent(token) - ); - } else if (this._lockedFirstTokens.has(token)) { - const firstToken = this._lockedFirstTokens.get(token); - this._desiredIndentCache.set( - token, - // (indentation for the first element's line) - this.getDesiredIndent(this._tokenInfo.getFirstTokenOfLine(firstToken)) + this._indentType.repeat(firstToken.loc.start.column - this._tokenInfo.getFirstTokenOfLine(firstToken).loc.start.column) - ); - } else { - const offsetInfo = this._getOffsetDescriptor(token); - const offset = offsetInfo.from && offsetInfo.from.loc.start.line === token.loc.start.line && !/^\s*?\n/u.test(token.value) && !offsetInfo.force ? 0 : offsetInfo.offset * this._indentSize; - this._desiredIndentCache.set( - token, - (offsetInfo.from ? this.getDesiredIndent(offsetInfo.from) : "") + this._indentType.repeat(offset) - ); - } - } - return this._desiredIndentCache.get(token); - } - /** - * Ignores a token, preventing it from being reported. - * @param token The token - */ - ignoreToken(token) { - if (this._tokenInfo.isFirstTokenOfLine(token)) - this._ignoredTokens.add(token); - } - /** - * Gets the first token that the given token's indentation is dependent on - * @param token The token - * @returns The token that the given token depends on, or `null` if the given token is at the top level - */ - getFirstDependency(token) { - return this._getOffsetDescriptor(token).from; - } -} -const ELEMENT_LIST_SCHEMA = { - oneOf: [ - { - type: "integer", - minimum: 0 - }, - { - type: "string", - enum: ["first", "off"] - } - ] -}; -var indent = utils.createRule({ - meta: { - type: "layout", - docs: { - description: "Enforce consistent indentation", - url: "https://eslint.style/rules/js/indent" - }, - fixable: "whitespace", - schema: [ - { - oneOf: [ - { - type: "string", - enum: ["tab"] - }, - { - type: "integer", - minimum: 0 - } - ] - }, - { - type: "object", - properties: { - SwitchCase: { - type: "integer", - minimum: 0, - default: 0 - }, - VariableDeclarator: { - oneOf: [ - ELEMENT_LIST_SCHEMA, - { - type: "object", - properties: { - var: ELEMENT_LIST_SCHEMA, - let: ELEMENT_LIST_SCHEMA, - const: ELEMENT_LIST_SCHEMA - }, - additionalProperties: false - } - ] - }, - outerIIFEBody: { - oneOf: [ - { - type: "integer", - minimum: 0 - }, - { - type: "string", - enum: ["off"] - } - ] - }, - MemberExpression: { - oneOf: [ - { - type: "integer", - minimum: 0 - }, - { - type: "string", - enum: ["off"] - } - ] - }, - FunctionDeclaration: { - type: "object", - properties: { - parameters: ELEMENT_LIST_SCHEMA, - body: { - type: "integer", - minimum: 0 - } - }, - additionalProperties: false - }, - FunctionExpression: { - type: "object", - properties: { - parameters: ELEMENT_LIST_SCHEMA, - body: { - type: "integer", - minimum: 0 - } - }, - additionalProperties: false - }, - StaticBlock: { - type: "object", - properties: { - body: { - type: "integer", - minimum: 0 - } - }, - additionalProperties: false - }, - CallExpression: { - type: "object", - properties: { - arguments: ELEMENT_LIST_SCHEMA - }, - additionalProperties: false - }, - ArrayExpression: ELEMENT_LIST_SCHEMA, - ObjectExpression: ELEMENT_LIST_SCHEMA, - ImportDeclaration: ELEMENT_LIST_SCHEMA, - flatTernaryExpressions: { - type: "boolean", - default: false - }, - offsetTernaryExpressions: { - type: "boolean", - default: false - }, - ignoredNodes: { - type: "array", - items: { - type: "string", - // @ts-expect-error Not sure the original intention - not: { - pattern: ":exit$" - } - } - }, - ignoreComments: { - type: "boolean", - default: false - } - }, - additionalProperties: false - } - ], - messages: { - wrongIndentation: "Expected indentation of {{expected}} but found {{actual}}." - } - }, - create(context) { - const DEFAULT_VARIABLE_INDENT = 1; - const DEFAULT_PARAMETER_INDENT = 1; - const DEFAULT_FUNCTION_BODY_INDENT = 1; - let indentType = "space"; - let indentSize = 4; - const options = { - SwitchCase: 0, - VariableDeclarator: { - var: DEFAULT_VARIABLE_INDENT, - let: DEFAULT_VARIABLE_INDENT, - const: DEFAULT_VARIABLE_INDENT - }, - outerIIFEBody: 1, - FunctionDeclaration: { - parameters: DEFAULT_PARAMETER_INDENT, - body: DEFAULT_FUNCTION_BODY_INDENT - }, - FunctionExpression: { - parameters: DEFAULT_PARAMETER_INDENT, - body: DEFAULT_FUNCTION_BODY_INDENT - }, - StaticBlock: { - body: DEFAULT_FUNCTION_BODY_INDENT - }, - CallExpression: { - arguments: DEFAULT_PARAMETER_INDENT - }, - MemberExpression: 1, - ArrayExpression: 1, - ObjectExpression: 1, - ImportDeclaration: 1, - flatTernaryExpressions: false, - ignoredNodes: [], - ignoreComments: false, - offsetTernaryExpressions: false - }; - if (context.options.length) { - if (context.options[0] === "tab") { - indentSize = 1; - indentType = "tab"; - } else { - indentSize = context.options[0] ?? indentSize; - indentType = "space"; - } - const userOptions = context.options[1]; - if (userOptions) { - Object.assign(options, userOptions); - if (typeof userOptions.VariableDeclarator === "number" || userOptions.VariableDeclarator === "first") { - options.VariableDeclarator = { - var: userOptions.VariableDeclarator, - let: userOptions.VariableDeclarator, - const: userOptions.VariableDeclarator - }; - } - } - } - const sourceCode = context.sourceCode; - const tokenInfo = new TokenInfo(sourceCode); - const offsets = new OffsetStorage(tokenInfo, indentSize, indentType === "space" ? " " : " ", sourceCode.text.length); - const parameterParens = /* @__PURE__ */ new WeakSet(); - function createErrorMessageData(expectedAmount, actualSpaces, actualTabs) { - const expectedStatement = `${expectedAmount} ${indentType}${expectedAmount === 1 ? "" : "s"}`; - const foundSpacesWord = `space${actualSpaces === 1 ? "" : "s"}`; - const foundTabsWord = `tab${actualTabs === 1 ? "" : "s"}`; - let foundStatement; - if (actualSpaces > 0) { - foundStatement = indentType === "space" ? actualSpaces : `${actualSpaces} ${foundSpacesWord}`; - } else if (actualTabs > 0) { - foundStatement = indentType === "tab" ? actualTabs : `${actualTabs} ${foundTabsWord}`; - } else { - foundStatement = "0"; - } - return { - expected: expectedStatement, - actual: foundStatement - }; - } - function report(token, neededIndent) { - const actualIndent = Array.from(tokenInfo.getTokenIndent(token)); - const numSpaces = actualIndent.filter((char) => char === " ").length; - const numTabs = actualIndent.filter((char) => char === " ").length; - context.report({ - node: token, - messageId: "wrongIndentation", - data: createErrorMessageData(neededIndent.length, numSpaces, numTabs), - loc: { - start: { line: token.loc.start.line, column: 0 }, - end: { line: token.loc.start.line, column: token.loc.start.column } - }, - fix(fixer) { - const range = [token.range[0] - token.loc.start.column, token.range[0]]; - const newText = neededIndent; - return fixer.replaceTextRange(range, newText); - } - }); - } - function validateTokenIndent(token, desiredIndent) { - const indentation = tokenInfo.getTokenIndent(token); - return indentation === desiredIndent || indentation.includes(" ") && indentation.includes(" "); - } - function isOuterIIFE(node) { - if (!node.parent || node.parent.type !== "CallExpression" || node.parent.callee !== node) - return false; - let statement = node.parent && node.parent.parent; - while (statement.type === "UnaryExpression" && ["!", "~", "+", "-"].includes(statement.operator) || statement.type === "AssignmentExpression" || statement.type === "LogicalExpression" || statement.type === "SequenceExpression" || statement.type === "VariableDeclarator") { - statement = statement.parent; - } - return (statement.type === "ExpressionStatement" || statement.type === "VariableDeclaration") && statement.parent.type === "Program"; - } - function countTrailingLinebreaks(string) { - const trailingWhitespace = string.match(/\s*$/u)[0]; - const linebreakMatches = trailingWhitespace.match(utils.createGlobalLinebreakMatcher()); - return linebreakMatches === null ? 0 : linebreakMatches.length; - } - function addElementListIndent(elements, startToken, endToken, offset) { - function getFirstToken(element) { - let token = sourceCode.getTokenBefore(element); - while (utils.isOpeningParenToken(token) && token !== startToken) - token = sourceCode.getTokenBefore(token); - return sourceCode.getTokenAfter(token); - } - offsets.setDesiredOffsets( - [startToken.range[1], endToken.range[0]], - startToken, - typeof offset === "number" ? offset : 1 - ); - offsets.setDesiredOffset(endToken, startToken, 0); - if (offset === "first" && elements.length && !elements[0]) - return; - elements.forEach((element, index) => { - if (!element) { - return; - } - if (offset === "off") { - offsets.ignoreToken(getFirstToken(element)); - } - if (index === 0) - return; - if (offset === "first" && tokenInfo.isFirstTokenOfLine(getFirstToken(element))) { - offsets.matchOffsetOf(getFirstToken(elements[0]), getFirstToken(element)); - } else { - const previousElement = elements[index - 1]; - const firstTokenOfPreviousElement = previousElement && getFirstToken(previousElement); - const previousElementLastToken = previousElement && sourceCode.getLastToken(previousElement); - if (previousElement && previousElementLastToken.loc.end.line - countTrailingLinebreaks(previousElementLastToken.value) > startToken.loc.end.line) { - offsets.setDesiredOffsets( - [previousElement.range[1], element.range[1]], - firstTokenOfPreviousElement, - 0 - ); - } - } - }); - } - function addBlocklessNodeIndent(node) { - if (node.type !== "BlockStatement") { - const lastParentToken = sourceCode.getTokenBefore(node, utils.isNotOpeningParenToken); - let firstBodyToken = sourceCode.getFirstToken(node); - let lastBodyToken = sourceCode.getLastToken(node); - while (utils.isOpeningParenToken(sourceCode.getTokenBefore(firstBodyToken)) && utils.isClosingParenToken(sourceCode.getTokenAfter(lastBodyToken))) { - firstBodyToken = sourceCode.getTokenBefore(firstBodyToken); - lastBodyToken = sourceCode.getTokenAfter(lastBodyToken); - } - offsets.setDesiredOffsets([firstBodyToken.range[0], lastBodyToken.range[1]], lastParentToken, 1); - } - } - function addFunctionCallIndent(node) { - let openingParen; - if (node.arguments.length) - openingParen = sourceCode.getFirstTokenBetween(node.callee, node.arguments[0], utils.isOpeningParenToken); - else - openingParen = sourceCode.getLastToken(node, 1); - const closingParen = sourceCode.getLastToken(node); - parameterParens.add(openingParen); - parameterParens.add(closingParen); - if ("optional" in node && node.optional) { - const dotToken = sourceCode.getTokenAfter(node.callee, utils.isQuestionDotToken); - const calleeParenCount = sourceCode.getTokensBetween(node.callee, dotToken, { filter: utils.isClosingParenToken }).length; - const firstTokenOfCallee = calleeParenCount ? sourceCode.getTokenBefore(node.callee, { skip: calleeParenCount - 1 }) : sourceCode.getFirstToken(node.callee); - const lastTokenOfCallee = sourceCode.getTokenBefore(dotToken); - const offsetBase = lastTokenOfCallee.loc.end.line === openingParen.loc.start.line ? lastTokenOfCallee : firstTokenOfCallee; - offsets.setDesiredOffset(dotToken, offsetBase, 1); - } - const offsetAfterToken = node.callee.type === "TaggedTemplateExpression" ? sourceCode.getFirstToken(node.callee.quasi) : node.typeArguments ?? openingParen; - const offsetToken = sourceCode.getTokenBefore(offsetAfterToken); - offsets.setDesiredOffset(openingParen, offsetToken, 0); - addElementListIndent(node.arguments, openingParen, closingParen, options.CallExpression.arguments); - } - function addParensIndent(tokens) { - const parenStack = []; - const parenPairs = []; - for (let i = 0; i < tokens.length; i++) { - const nextToken = tokens[i]; - if (utils.isOpeningParenToken(nextToken)) - parenStack.push(nextToken); - else if (utils.isClosingParenToken(nextToken)) - parenPairs.push({ left: parenStack.pop(), right: nextToken }); - } - for (let i = parenPairs.length - 1; i >= 0; i--) { - const leftParen = parenPairs[i].left; - const rightParen = parenPairs[i].right; - if (!parameterParens.has(leftParen) && !parameterParens.has(rightParen)) { - const parenthesizedTokens = new Set(sourceCode.getTokensBetween(leftParen, rightParen)); - parenthesizedTokens.forEach((token) => { - if (!parenthesizedTokens.has(offsets.getFirstDependency(token))) - offsets.setDesiredOffset(token, leftParen, 1); - }); - } - offsets.setDesiredOffset(rightParen, leftParen, 0); - } - } - function ignoreNode(node) { - const unknownNodeTokens = new Set(sourceCode.getTokens(node, { includeComments: true })); - unknownNodeTokens.forEach((token) => { - if (!unknownNodeTokens.has(offsets.getFirstDependency(token))) { - const firstTokenOfLine = tokenInfo.getFirstTokenOfLine(token); - if (token === firstTokenOfLine) - offsets.ignoreToken(token); - else - offsets.setDesiredOffset(token, firstTokenOfLine, 0); - } - }); - } - function isOnFirstLineOfStatement(token, leafNode) { - let node = leafNode; - while (node.parent && !node.parent.type.endsWith("Statement") && !node.parent.type.endsWith("Declaration")) - node = node.parent; - node = node.parent; - return !node || node.loc.start.line === token.loc.start.line; - } - function hasBlankLinesBetween(firstToken, secondToken) { - const firstTokenLine = firstToken.loc.end.line; - const secondTokenLine = secondToken.loc.start.line; - if (firstTokenLine === secondTokenLine || firstTokenLine === secondTokenLine - 1) - return false; - for (let line = firstTokenLine + 1; line < secondTokenLine; ++line) { - if (!tokenInfo.firstTokensByLineNumber.has(line)) - return true; - } - return false; - } - const ignoredNodeFirstTokens = /* @__PURE__ */ new Set(); - const baseOffsetListeners = { - "ArrayExpression, ArrayPattern": function(node) { - const openingBracket = sourceCode.getFirstToken(node); - const closingBracket = sourceCode.getTokenAfter([...node.elements].reverse().find((_) => _) || openingBracket, utils.isClosingBracketToken); - addElementListIndent(node.elements, openingBracket, closingBracket, options.ArrayExpression); - }, - "ObjectExpression, ObjectPattern": function(node) { - const openingCurly = sourceCode.getFirstToken(node, utils.isOpeningBraceToken); - const closingCurly = sourceCode.getTokenAfter( - node.properties.length ? node.properties[node.properties.length - 1] : openingCurly, - utils.isClosingBraceToken - ); - addElementListIndent(node.properties, openingCurly, closingCurly, options.ObjectExpression); - }, - ArrowFunctionExpression(node) { - const maybeOpeningParen = sourceCode.getFirstToken(node, { skip: node.async ? 1 : 0 }); - if (utils.isOpeningParenToken(maybeOpeningParen)) { - const openingParen = maybeOpeningParen; - const closingParen = sourceCode.getTokenBefore(node.body, utils.isClosingParenToken); - parameterParens.add(openingParen); - parameterParens.add(closingParen); - addElementListIndent(node.params, openingParen, closingParen, options.FunctionExpression.parameters); - } - addBlocklessNodeIndent(node.body); - }, - AssignmentExpression(node) { - const operator = sourceCode.getFirstTokenBetween(node.left, node.right, (token) => token.value === node.operator); - offsets.setDesiredOffsets([operator.range[0], node.range[1]], sourceCode.getLastToken(node.left), 1); - offsets.ignoreToken(operator); - offsets.ignoreToken(sourceCode.getTokenAfter(operator)); - }, - "BinaryExpression, LogicalExpression": function(node) { - const operator = sourceCode.getFirstTokenBetween(node.left, node.right, (token) => token.value === node.operator); - const tokenAfterOperator = sourceCode.getTokenAfter(operator); - offsets.ignoreToken(operator); - offsets.ignoreToken(tokenAfterOperator); - offsets.setDesiredOffset(tokenAfterOperator, operator, 0); - }, - "BlockStatement, ClassBody": function(node) { - let blockIndentLevel; - if (node.parent && isOuterIIFE(node.parent)) - blockIndentLevel = options.outerIIFEBody; - else if (node.parent && (node.parent.type === "FunctionExpression" || node.parent.type === "ArrowFunctionExpression")) - blockIndentLevel = options.FunctionExpression.body; - else if (node.parent && node.parent.type === "FunctionDeclaration") - blockIndentLevel = options.FunctionDeclaration.body; - else - blockIndentLevel = 1; - if (!utils.STATEMENT_LIST_PARENTS.has(node.parent.type)) - offsets.setDesiredOffset(sourceCode.getFirstToken(node), sourceCode.getFirstToken(node.parent), 0); - addElementListIndent( - node.body, - sourceCode.getFirstToken(node), - sourceCode.getLastToken(node), - blockIndentLevel - ); - }, - "CallExpression": addFunctionCallIndent, - "ClassDeclaration[superClass], ClassExpression[superClass]": function(node) { - if (!node.superClass) - return; - const classToken = sourceCode.getFirstToken(node); - const extendsToken = sourceCode.getTokenBefore(node.superClass, utils.isNotOpeningParenToken); - offsets.setDesiredOffsets([extendsToken.range[0], node.body.range[0]], classToken, 1); - }, - ConditionalExpression(node) { - const firstToken = sourceCode.getFirstToken(node); - if (!options.flatTernaryExpressions || !utils.isTokenOnSameLine(node.test, node.consequent) || isOnFirstLineOfStatement(firstToken, node)) { - const questionMarkToken = sourceCode.getFirstTokenBetween(node.test, node.consequent, (token) => token.type === "Punctuator" && token.value === "?"); - const colonToken = sourceCode.getFirstTokenBetween(node.consequent, node.alternate, (token) => token.type === "Punctuator" && token.value === ":"); - const firstConsequentToken = sourceCode.getTokenAfter(questionMarkToken); - const lastConsequentToken = sourceCode.getTokenBefore(colonToken); - const firstAlternateToken = sourceCode.getTokenAfter(colonToken); - offsets.setDesiredOffset(questionMarkToken, firstToken, 1); - offsets.setDesiredOffset(colonToken, firstToken, 1); - offsets.setDesiredOffset( - firstConsequentToken, - firstToken, - firstConsequentToken.type === "Punctuator" && options.offsetTernaryExpressions ? 2 : 1 - ); - if (lastConsequentToken.loc.end.line === firstAlternateToken.loc.start.line) { - offsets.setDesiredOffset(firstAlternateToken, firstConsequentToken, 0); - } else { - offsets.setDesiredOffset(firstAlternateToken, firstToken, firstAlternateToken.type === "Punctuator" && options.offsetTernaryExpressions ? 2 : 1); - } - } - }, - "DoWhileStatement, WhileStatement, ForInStatement, ForOfStatement, WithStatement": function(node) { - addBlocklessNodeIndent(node.body); - }, - ExportNamedDeclaration(node) { - if (node.declaration === null) { - const closingCurly = sourceCode.getLastToken(node, utils.isClosingBraceToken); - addElementListIndent(node.specifiers, sourceCode.getFirstToken(node, { skip: 1 }), closingCurly, 1); - if (node.source) { - offsets.setDesiredOffsets([closingCurly.range[1], node.range[1]], sourceCode.getFirstToken(node), 1); - } - } - }, - ForStatement(node) { - const forOpeningParen = sourceCode.getFirstToken(node, 1); - if (node.init) - offsets.setDesiredOffsets(node.init.range, forOpeningParen, 1); - if (node.test) - offsets.setDesiredOffsets(node.test.range, forOpeningParen, 1); - if (node.update) - offsets.setDesiredOffsets(node.update.range, forOpeningParen, 1); - addBlocklessNodeIndent(node.body); - }, - "FunctionDeclaration, FunctionExpression": function(node) { - const closingParen = sourceCode.getTokenBefore(node.body); - const openingParen = sourceCode.getTokenBefore(node.params.length ? node.params[0] : closingParen); - parameterParens.add(openingParen); - parameterParens.add(closingParen); - addElementListIndent(node.params, openingParen, closingParen, options[node.type].parameters); - }, - IfStatement(node) { - addBlocklessNodeIndent(node.consequent); - if (node.alternate) - addBlocklessNodeIndent(node.alternate); - }, - /** - * For blockless nodes with semicolon-first style, don't indent the semicolon. - * e.g. - * if (foo) - * bar() - * ; [1, 2, 3].map(foo) - * - * Traversal into the node sets indentation of the semicolon, so we need to override it on exit. - */ - ":matches(DoWhileStatement, ForStatement, ForInStatement, ForOfStatement, IfStatement, WhileStatement, WithStatement):exit": function(node) { - let nodesToCheck; - if (node.type === "IfStatement") { - nodesToCheck = [node.consequent]; - if (node.alternate) - nodesToCheck.push(node.alternate); - } else { - nodesToCheck = [node.body]; - } - for (const nodeToCheck of nodesToCheck) { - const lastToken = sourceCode.getLastToken(nodeToCheck); - if (utils.isSemicolonToken(lastToken)) { - const tokenBeforeLast = sourceCode.getTokenBefore(lastToken); - const tokenAfterLast = sourceCode.getTokenAfter(lastToken); - if (!utils.isTokenOnSameLine(tokenBeforeLast, lastToken) && tokenAfterLast && utils.isTokenOnSameLine(lastToken, tokenAfterLast)) { - offsets.setDesiredOffset( - lastToken, - sourceCode.getFirstToken(node), - 0 - ); - } - } - } - }, - ImportDeclaration(node) { - if (node.specifiers.some((specifier) => specifier.type === "ImportSpecifier")) { - const openingCurly = sourceCode.getFirstToken(node, utils.isOpeningBraceToken); - const closingCurly = sourceCode.getLastToken(node, utils.isClosingBraceToken); - addElementListIndent(node.specifiers.filter((specifier) => specifier.type === "ImportSpecifier"), openingCurly, closingCurly, options.ImportDeclaration); - } - const fromToken = sourceCode.getLastToken(node, (token) => token.type === "Identifier" && token.value === "from"); - const sourceToken = sourceCode.getLastToken(node, (token) => token.type === "String"); - const semiToken = sourceCode.getLastToken(node, (token) => token.type === "Punctuator" && token.value === ";"); - if (fromToken) { - const end = semiToken && semiToken.range[1] === sourceToken.range[1] ? node.range[1] : sourceToken.range[1]; - offsets.setDesiredOffsets([fromToken.range[0], end], sourceCode.getFirstToken(node), 1); - } - }, - ImportExpression(node) { - const openingParen = sourceCode.getFirstToken(node, 1); - const closingParen = sourceCode.getLastToken(node); - parameterParens.add(openingParen); - parameterParens.add(closingParen); - offsets.setDesiredOffset(openingParen, sourceCode.getTokenBefore(openingParen), 0); - addElementListIndent([node.source], openingParen, closingParen, options.CallExpression.arguments); - }, - "MemberExpression, JSXMemberExpression, MetaProperty": function(node) { - const object = node.type === "MetaProperty" ? node.meta : node.object; - const firstNonObjectToken = sourceCode.getFirstTokenBetween(object, node.property, utils.isNotClosingParenToken); - const secondNonObjectToken = sourceCode.getTokenAfter(firstNonObjectToken); - const objectParenCount = sourceCode.getTokensBetween(object, node.property, { filter: utils.isClosingParenToken }).length; - const firstObjectToken = objectParenCount ? sourceCode.getTokenBefore(object, { skip: objectParenCount - 1 }) : sourceCode.getFirstToken(object); - const lastObjectToken = sourceCode.getTokenBefore(firstNonObjectToken); - const firstPropertyToken = "computed" in node && node.computed ? firstNonObjectToken : secondNonObjectToken; - if ("computed" in node && node.computed) { - offsets.setDesiredOffset(sourceCode.getLastToken(node), firstNonObjectToken, 0); - offsets.setDesiredOffsets(node.property.range, firstNonObjectToken, 1); - } - const offsetBase = lastObjectToken.loc.end.line === firstPropertyToken.loc.start.line ? lastObjectToken : firstObjectToken; - if (typeof options.MemberExpression === "number") { - offsets.setDesiredOffset(firstNonObjectToken, offsetBase, options.MemberExpression); - offsets.setDesiredOffset(secondNonObjectToken, "computed" in node && node.computed ? firstNonObjectToken : offsetBase, options.MemberExpression); - } else { - offsets.ignoreToken(firstNonObjectToken); - offsets.ignoreToken(secondNonObjectToken); - offsets.setDesiredOffset(firstNonObjectToken, offsetBase, 0); - offsets.setDesiredOffset(secondNonObjectToken, firstNonObjectToken, 0); - } - }, - NewExpression(node) { - if (node.arguments.length > 0 || utils.isClosingParenToken(sourceCode.getLastToken(node)) && utils.isOpeningParenToken(sourceCode.getLastToken(node, 1))) { - addFunctionCallIndent(node); - } - }, - Property(node) { - if (!node.shorthand && !node.method && node.kind === "init") { - const colon = sourceCode.getFirstTokenBetween(node.key, node.value, utils.isColonToken); - offsets.ignoreToken(sourceCode.getTokenAfter(colon)); - } - }, - PropertyDefinition(node) { - const firstToken = sourceCode.getFirstToken(node); - const maybeSemicolonToken = sourceCode.getLastToken(node); - let keyLastToken = null; - if (node.computed) { - const bracketTokenL = sourceCode.getTokenBefore(node.key, utils.isOpeningBracketToken); - const bracketTokenR = keyLastToken = sourceCode.getTokenAfter(node.key, utils.isClosingBracketToken); - const keyRange = [bracketTokenL.range[1], bracketTokenR.range[0]]; - if (bracketTokenL !== firstToken) - offsets.setDesiredOffset(bracketTokenL, firstToken, 0); - offsets.setDesiredOffsets(keyRange, bracketTokenL, 1); - offsets.setDesiredOffset(bracketTokenR, bracketTokenL, 0); - } else { - const idToken = keyLastToken = sourceCode.getFirstToken(node.key); - if (idToken !== firstToken) - offsets.setDesiredOffset(idToken, firstToken, 1); - } - if (node.value) { - const eqToken = sourceCode.getTokenBefore(node.value, utils.isEqToken); - const valueToken = sourceCode.getTokenAfter(eqToken); - offsets.setDesiredOffset(eqToken, keyLastToken, 1); - offsets.setDesiredOffset(valueToken, eqToken, 1); - if (utils.isSemicolonToken(maybeSemicolonToken)) - offsets.setDesiredOffset(maybeSemicolonToken, eqToken, 1); - } else if (utils.isSemicolonToken(maybeSemicolonToken)) { - offsets.setDesiredOffset(maybeSemicolonToken, keyLastToken, 1); - } - }, - StaticBlock(node) { - const openingCurly = sourceCode.getFirstToken(node, { skip: 1 }); - const closingCurly = sourceCode.getLastToken(node); - addElementListIndent(node.body, openingCurly, closingCurly, options.StaticBlock.body); - }, - SwitchStatement(node) { - const openingCurly = sourceCode.getTokenAfter(node.discriminant, utils.isOpeningBraceToken); - const closingCurly = sourceCode.getLastToken(node); - offsets.setDesiredOffsets([openingCurly.range[1], closingCurly.range[0]], openingCurly, options.SwitchCase); - if (node.cases.length) { - sourceCode.getTokensBetween( - node.cases[node.cases.length - 1], - closingCurly, - { includeComments: true, filter: utils.isCommentToken } - ).forEach((token) => offsets.ignoreToken(token)); - } - }, - SwitchCase(node) { - if (!(node.consequent.length === 1 && node.consequent[0].type === "BlockStatement")) { - const caseKeyword = sourceCode.getFirstToken(node); - const tokenAfterCurrentCase = sourceCode.getTokenAfter(node); - offsets.setDesiredOffsets([caseKeyword.range[1], tokenAfterCurrentCase.range[0]], caseKeyword, 1); - } - }, - TemplateLiteral(node) { - node.expressions.forEach((expression, index) => { - const previousQuasi = node.quasis[index]; - const nextQuasi = node.quasis[index + 1]; - const tokenToAlignFrom = previousQuasi.loc.start.line === previousQuasi.loc.end.line ? sourceCode.getFirstToken(previousQuasi) : null; - offsets.setDesiredOffsets([previousQuasi.range[1], nextQuasi.range[0]], tokenToAlignFrom, 1); - offsets.setDesiredOffset(sourceCode.getFirstToken(nextQuasi), tokenToAlignFrom, 0); - }); - }, - VariableDeclaration(node) { - let variableIndent = Object.prototype.hasOwnProperty.call(options.VariableDeclarator, node.kind) ? options.VariableDeclarator[node.kind] : DEFAULT_VARIABLE_INDENT; - const firstToken = sourceCode.getFirstToken(node); - const lastToken = sourceCode.getLastToken(node); - if (options.VariableDeclarator[node.kind] === "first") { - if (node.declarations.length > 1) { - addElementListIndent( - node.declarations, - firstToken, - lastToken, - "first" - ); - return; - } - variableIndent = DEFAULT_VARIABLE_INDENT; - } - if (node.declarations[node.declarations.length - 1].loc.start.line > node.loc.start.line) { - offsets.setDesiredOffsets(node.range, firstToken, variableIndent, true); - } else { - offsets.setDesiredOffsets(node.range, firstToken, variableIndent); - } - if (utils.isSemicolonToken(lastToken)) - offsets.ignoreToken(lastToken); - }, - VariableDeclarator(node) { - if (node.init) { - const equalOperator = sourceCode.getTokenBefore(node.init, utils.isNotOpeningParenToken); - const tokenAfterOperator = sourceCode.getTokenAfter(equalOperator); - offsets.ignoreToken(equalOperator); - offsets.ignoreToken(tokenAfterOperator); - offsets.setDesiredOffsets([tokenAfterOperator.range[0], node.range[1]], equalOperator, 1); - offsets.setDesiredOffset(equalOperator, sourceCode.getLastToken(node.id), 0); - } - }, - "JSXAttribute[value]": function(node) { - if (!node.value) - return; - const equalsToken = sourceCode.getFirstTokenBetween(node.name, node.value, (token) => token.type === "Punctuator" && token.value === "="); - offsets.setDesiredOffsets([equalsToken.range[0], node.value.range[1]], sourceCode.getFirstToken(node.name), 1); - }, - JSXElement(node) { - if (node.closingElement) { - addElementListIndent( - node.children, - sourceCode.getFirstToken(node.openingElement), - sourceCode.getFirstToken(node.closingElement), - 1 - ); - } - }, - JSXOpeningElement(node) { - const firstToken = sourceCode.getFirstToken(node); - let closingToken; - if (node.selfClosing) { - closingToken = sourceCode.getLastToken(node, { skip: 1 }); - offsets.setDesiredOffset(sourceCode.getLastToken(node), closingToken, 0); - } else { - closingToken = sourceCode.getLastToken(node); - } - offsets.setDesiredOffsets(node.name.range, sourceCode.getFirstToken(node), 0); - addElementListIndent(node.attributes, firstToken, closingToken, 1); - }, - JSXClosingElement(node) { - const firstToken = sourceCode.getFirstToken(node); - offsets.setDesiredOffsets(node.name.range, firstToken, 1); - }, - JSXFragment(node) { - const firstOpeningToken = sourceCode.getFirstToken(node.openingFragment); - const firstClosingToken = sourceCode.getFirstToken(node.closingFragment); - addElementListIndent(node.children, firstOpeningToken, firstClosingToken, 1); - }, - JSXOpeningFragment(node) { - const firstToken = sourceCode.getFirstToken(node); - const closingToken = sourceCode.getLastToken(node); - offsets.setDesiredOffsets(node.range, firstToken, 1); - offsets.matchOffsetOf(firstToken, closingToken); - }, - JSXClosingFragment(node) { - const firstToken = sourceCode.getFirstToken(node); - const slashToken = sourceCode.getLastToken(node, { skip: 1 }); - const closingToken = sourceCode.getLastToken(node); - const tokenToMatch = utils.isTokenOnSameLine(slashToken, closingToken) ? slashToken : closingToken; - offsets.setDesiredOffsets(node.range, firstToken, 1); - offsets.matchOffsetOf(firstToken, tokenToMatch); - }, - JSXExpressionContainer(node) { - const openingCurly = sourceCode.getFirstToken(node); - const closingCurly = sourceCode.getLastToken(node); - offsets.setDesiredOffsets( - [openingCurly.range[1], closingCurly.range[0]], - openingCurly, - 1 - ); - }, - JSXSpreadAttribute(node) { - const openingCurly = sourceCode.getFirstToken(node); - const closingCurly = sourceCode.getLastToken(node); - offsets.setDesiredOffsets( - [openingCurly.range[1], closingCurly.range[0]], - openingCurly, - 1 - ); - }, - "*": function(node) { - const firstToken = sourceCode.getFirstToken(node); - if (firstToken && !ignoredNodeFirstTokens.has(firstToken)) - offsets.setDesiredOffsets(node.range, firstToken, 0); - } - }; - const listenerCallQueue = []; - const offsetListeners = {}; - for (const [selector, listener] of Object.entries(baseOffsetListeners)) { - offsetListeners[selector] = (node) => listenerCallQueue.push({ listener, node }); - } - const ignoredNodes = /* @__PURE__ */ new Set(); - function addToIgnoredNodes(node) { - ignoredNodes.add(node); - ignoredNodeFirstTokens.add(sourceCode.getFirstToken(node)); - } - const ignoredNodeListeners = options.ignoredNodes.reduce( - (listeners, ignoredSelector) => Object.assign(listeners, { [ignoredSelector]: addToIgnoredNodes }), - {} - ); - function getNodeIndent(node, byLastLine = false, excludeCommas = false) { - let src = context.sourceCode.getText(node, node.loc.start.column); - const lines = src.split("\n"); - if (byLastLine) - src = lines[lines.length - 1]; - else - src = lines[0]; - const skip = excludeCommas ? "," : ""; - let regExp; - if (indentType === "space") - regExp = new RegExp(`^[ ${skip}]+`); - else - regExp = new RegExp(`^[ ${skip}]+`); - const indent = regExp.exec(src); - return indent ? indent[0].length : 0; - } - function handleJSXTextnode(node) { - if (!node.parent) - return; - if (node.parent.type !== "JSXElement" && node.parent.type !== "JSXFragment") - return; - const value = node.value; - const regExp = indentType === "space" ? /\n( *)[\t ]*\S/g : /\n(\t*)[\t ]*\S/g; - const nodeIndentsPerLine = Array.from( - String(value).matchAll(regExp), - (match) => match[1] ? match[1].length : 0 - ); - const hasFirstInLineNode = nodeIndentsPerLine.length > 0; - const parentNodeIndent = getNodeIndent(node.parent); - const indent = parentNodeIndent + indentSize; - if (hasFirstInLineNode && !nodeIndentsPerLine.every((actualIndent) => actualIndent === indent)) { - nodeIndentsPerLine.forEach((nodeIndent) => { - context.report({ - node, - messageId: "wrongIndentation", - data: createErrorMessageData(indent, nodeIndent, nodeIndent), - fix: getFixerFunction(node, indent) - }); - }); - } - } - const indentChar = indentType === "space" ? " " : " "; - function getFixerFunction(node, needed) { - const indent = Array(needed + 1).join(indentChar); - return function fix(fixer) { - const regExp = /\n[\t ]*(\S)/g; - const fixedText = node.raw.replace(regExp, (match, p1) => ` -${indent}${p1}`); - return fixer.replaceText(node, fixedText); - }; - } - return { - // Listeners - ...offsetListeners, - // Special handling for JSXText nodes - "JSXText": handleJSXTextnode, - // Ignored nodes - ...ignoredNodeListeners, - // Validate indentation of all tokens at the end - "*:exit": function(node) { - if (!KNOWN_NODES.has(node.type)) - addToIgnoredNodes(node); - }, - "Program:exit": function() { - if (options.ignoreComments) { - sourceCode.getAllComments().forEach((comment) => offsets.ignoreToken(comment)); - } - for (let i = 0; i < listenerCallQueue.length; i++) { - const nodeInfo = listenerCallQueue[i]; - if (!ignoredNodes.has(nodeInfo.node)) - nodeInfo.listener?.(nodeInfo.node); - } - ignoredNodes.forEach(ignoreNode); - addParensIndent(sourceCode.ast.tokens); - const precedingTokens = /* @__PURE__ */ new WeakMap(); - for (let i = 0; i < sourceCode.ast.comments.length; i++) { - const comment = sourceCode.ast.comments[i]; - const tokenOrCommentBefore = sourceCode.getTokenBefore(comment, { includeComments: true }); - const hasToken = precedingTokens.has(tokenOrCommentBefore) ? precedingTokens.get(tokenOrCommentBefore) : tokenOrCommentBefore; - precedingTokens.set(comment, hasToken); - } - for (let i = 1; i < sourceCode.lines.length + 1; i++) { - if (!tokenInfo.firstTokensByLineNumber.has(i)) { - continue; - } - const firstTokenOfLine = tokenInfo.firstTokensByLineNumber.get(i); - if (firstTokenOfLine.loc.start.line !== i) { - continue; - } - if (utils.isCommentToken(firstTokenOfLine)) { - const tokenBefore = precedingTokens.get(firstTokenOfLine); - const tokenAfter = tokenBefore ? sourceCode.getTokenAfter(tokenBefore) : sourceCode.ast.tokens[0]; - const mayAlignWithBefore = tokenBefore && !hasBlankLinesBetween(tokenBefore, firstTokenOfLine); - const mayAlignWithAfter = tokenAfter && !hasBlankLinesBetween(firstTokenOfLine, tokenAfter); - if (tokenAfter && utils.isSemicolonToken(tokenAfter) && !utils.isTokenOnSameLine(firstTokenOfLine, tokenAfter)) - offsets.setDesiredOffset(firstTokenOfLine, tokenAfter, 0); - if (mayAlignWithBefore && validateTokenIndent(firstTokenOfLine, offsets.getDesiredIndent(tokenBefore)) || mayAlignWithAfter && validateTokenIndent(firstTokenOfLine, offsets.getDesiredIndent(tokenAfter))) { - continue; - } - } - if (validateTokenIndent(firstTokenOfLine, offsets.getDesiredIndent(firstTokenOfLine))) - continue; - report(firstTokenOfLine, offsets.getDesiredIndent(firstTokenOfLine)); - } - } - }; - } -}); - -exports.indent = indent; diff --git a/tools/eslint/node_modules/@stylistic/eslint-plugin-js/dist/index.js b/tools/eslint/node_modules/@stylistic/eslint-plugin-js/dist/index.js deleted file mode 100644 index 9033a5a1c464d4..00000000000000 --- a/tools/eslint/node_modules/@stylistic/eslint-plugin-js/dist/index.js +++ /dev/null @@ -1,79 +0,0 @@ -'use strict'; - -var configs = require('./configs.js'); -require('./array-bracket-newline.js'); -require('./utils.js'); -require('eslint-visitor-keys'); -require('espree'); -require('./array-bracket-spacing.js'); -require('./array-element-newline.js'); -require('./arrow-parens.js'); -require('./arrow-spacing.js'); -require('./block-spacing.js'); -require('./brace-style.js'); -require('./comma-dangle.js'); -require('./comma-spacing.js'); -require('./comma-style.js'); -require('./computed-property-spacing.js'); -require('./dot-location.js'); -require('./eol-last.js'); -require('./function-call-argument-newline.js'); -require('./function-call-spacing.js'); -require('./function-paren-newline.js'); -require('./generator-star-spacing.js'); -require('./implicit-arrow-linebreak.js'); -require('./indent.js'); -require('./jsx-quotes.js'); -require('./key-spacing.js'); -require('./keyword-spacing.js'); -require('./line-comment-position.js'); -require('./linebreak-style.js'); -require('./lines-around-comment.js'); -require('./lines-between-class-members.js'); -require('./max-len.js'); -require('./max-statements-per-line.js'); -require('./multiline-comment-style.js'); -require('./multiline-ternary.js'); -require('./new-parens.js'); -require('./newline-per-chained-call.js'); -require('./no-confusing-arrow.js'); -require('./no-extra-parens.js'); -require('./no-extra-semi.js'); -require('./no-floating-decimal.js'); -require('./no-mixed-operators.js'); -require('./no-mixed-spaces-and-tabs.js'); -require('./no-multi-spaces.js'); -require('./no-multiple-empty-lines.js'); -require('./no-tabs.js'); -require('./no-trailing-spaces.js'); -require('./no-whitespace-before-property.js'); -require('./nonblock-statement-body-position.js'); -require('./object-curly-newline.js'); -require('./object-curly-spacing.js'); -require('./object-property-newline.js'); -require('./one-var-declaration-per-line.js'); -require('./operator-linebreak.js'); -require('./padded-blocks.js'); -require('./padding-line-between-statements.js'); -require('./quote-props.js'); -require('./quotes.js'); -require('./rest-spread-spacing.js'); -require('./semi.js'); -require('./semi-spacing.js'); -require('./semi-style.js'); -require('./space-before-blocks.js'); -require('./space-before-function-paren.js'); -require('./space-in-parens.js'); -require('./space-infix-ops.js'); -require('./space-unary-ops.js'); -require('./spaced-comment.js'); -require('./switch-colon-spacing.js'); -require('./template-curly-spacing.js'); -require('./template-tag-spacing.js'); -require('./wrap-iife.js'); -require('./wrap-regex.js'); -require('./yield-star-spacing.js'); - -var index = Object.assign(configs.plugin, { configs: configs.configs }); - -module.exports = index; diff --git a/tools/eslint/node_modules/@stylistic/eslint-plugin-js/dist/jsx-quotes.js b/tools/eslint/node_modules/@stylistic/eslint-plugin-js/dist/jsx-quotes.js deleted file mode 100644 index 43ae23e82d8ded..00000000000000 --- a/tools/eslint/node_modules/@stylistic/eslint-plugin-js/dist/jsx-quotes.js +++ /dev/null @@ -1,65 +0,0 @@ -'use strict'; - -var utils = require('./utils.js'); - -const QUOTE_SETTINGS = { - "prefer-double": { - quote: '"', - description: "singlequote", - convert(str) { - return str.replace(/'/gu, '"'); - } - }, - "prefer-single": { - quote: "'", - description: "doublequote", - convert(str) { - return str.replace(/"/gu, "'"); - } - } -}; -var jsxQuotes = utils.createRule({ - meta: { - type: "layout", - docs: { - description: "Enforce the consistent use of either double or single quotes in JSX attributes", - url: "https://eslint.style/rules/js/jsx-quotes" - }, - fixable: "whitespace", - schema: [ - { - type: "string", - enum: ["prefer-single", "prefer-double"] - } - ], - messages: { - unexpected: "Unexpected usage of {{description}}." - } - }, - create(context) { - const quoteOption = context.options[0] || "prefer-double"; - const setting = QUOTE_SETTINGS[quoteOption]; - function usesExpectedQuotes(node) { - return node.value.includes(setting.quote) || utils.isSurroundedBy(node.raw, setting.quote); - } - return { - JSXAttribute(node) { - const attributeValue = node.value; - if (attributeValue && utils.isStringLiteral(attributeValue) && !usesExpectedQuotes(attributeValue)) { - context.report({ - node: attributeValue, - messageId: "unexpected", - data: { - description: setting.description - }, - fix(fixer) { - return fixer.replaceText(attributeValue, setting.convert(attributeValue.raw)); - } - }); - } - } - }; - } -}); - -exports.jsxQuotes = jsxQuotes; diff --git a/tools/eslint/node_modules/@stylistic/eslint-plugin-js/dist/key-spacing.js b/tools/eslint/node_modules/@stylistic/eslint-plugin-js/dist/key-spacing.js deleted file mode 100644 index 082229c05909ec..00000000000000 --- a/tools/eslint/node_modules/@stylistic/eslint-plugin-js/dist/key-spacing.js +++ /dev/null @@ -1,450 +0,0 @@ -'use strict'; - -var utils = require('./utils.js'); - -function containsLineTerminator(str) { - return utils.LINEBREAK_MATCHER.test(str); -} -function last(arr) { - return arr[arr.length - 1]; -} -function isSingleLine(node) { - return node.loc.end.line === node.loc.start.line; -} -function isSingleLineProperties(properties) { - const [firstProp] = properties; - const lastProp = last(properties); - return firstProp.loc.start.line === lastProp.loc.end.line; -} -function initOptionProperty(toOptions, fromOptions) { - toOptions.mode = fromOptions.mode || "strict"; - if (typeof fromOptions.beforeColon !== "undefined") - toOptions.beforeColon = +fromOptions.beforeColon; - else - toOptions.beforeColon = 0; - if (typeof fromOptions.afterColon !== "undefined") - toOptions.afterColon = +fromOptions.afterColon; - else - toOptions.afterColon = 1; - if (typeof fromOptions.align !== "undefined") { - if (typeof fromOptions.align === "object") { - toOptions.align = fromOptions.align; - } else { - toOptions.align = { - on: fromOptions.align, - mode: toOptions.mode, - beforeColon: toOptions.beforeColon, - afterColon: toOptions.afterColon - }; - } - } - return toOptions; -} -function initOptions(toOptions, fromOptions) { - if (typeof fromOptions.align === "object") { - toOptions.align = initOptionProperty({}, fromOptions.align); - toOptions.align.on = fromOptions.align.on || "colon"; - toOptions.align.mode = fromOptions.align.mode || "strict"; - toOptions.multiLine = initOptionProperty({}, fromOptions.multiLine || fromOptions); - toOptions.singleLine = initOptionProperty({}, fromOptions.singleLine || fromOptions); - } else { - toOptions.multiLine = initOptionProperty({}, fromOptions.multiLine || fromOptions); - toOptions.singleLine = initOptionProperty({}, fromOptions.singleLine || fromOptions); - if (toOptions.multiLine.align) { - toOptions.align = { - on: toOptions.multiLine.align.on, - mode: toOptions.multiLine.align.mode || toOptions.multiLine.mode, - beforeColon: toOptions.multiLine.align.beforeColon, - afterColon: toOptions.multiLine.align.afterColon - }; - } - } - return toOptions; -} -var keySpacing = utils.createRule({ - meta: { - type: "layout", - docs: { - description: "Enforce consistent spacing between keys and values in object literal properties", - url: "https://eslint.style/rules/js/key-spacing" - }, - fixable: "whitespace", - schema: [{ - anyOf: [ - { - type: "object", - properties: { - align: { - anyOf: [ - { - type: "string", - enum: ["colon", "value"] - }, - { - type: "object", - properties: { - mode: { - type: "string", - enum: ["strict", "minimum"] - }, - on: { - type: "string", - enum: ["colon", "value"] - }, - beforeColon: { - type: "boolean" - }, - afterColon: { - type: "boolean" - } - }, - additionalProperties: false - } - ] - }, - mode: { - type: "string", - enum: ["strict", "minimum"] - }, - beforeColon: { - type: "boolean" - }, - afterColon: { - type: "boolean" - } - }, - additionalProperties: false - }, - { - type: "object", - properties: { - singleLine: { - type: "object", - properties: { - mode: { - type: "string", - enum: ["strict", "minimum"] - }, - beforeColon: { - type: "boolean" - }, - afterColon: { - type: "boolean" - } - }, - additionalProperties: false - }, - multiLine: { - type: "object", - properties: { - align: { - anyOf: [ - { - type: "string", - enum: ["colon", "value"] - }, - { - type: "object", - properties: { - mode: { - type: "string", - enum: ["strict", "minimum"] - }, - on: { - type: "string", - enum: ["colon", "value"] - }, - beforeColon: { - type: "boolean" - }, - afterColon: { - type: "boolean" - } - }, - additionalProperties: false - } - ] - }, - mode: { - type: "string", - enum: ["strict", "minimum"] - }, - beforeColon: { - type: "boolean" - }, - afterColon: { - type: "boolean" - } - }, - additionalProperties: false - } - }, - additionalProperties: false - }, - { - type: "object", - properties: { - singleLine: { - type: "object", - properties: { - mode: { - type: "string", - enum: ["strict", "minimum"] - }, - beforeColon: { - type: "boolean" - }, - afterColon: { - type: "boolean" - } - }, - additionalProperties: false - }, - multiLine: { - type: "object", - properties: { - mode: { - type: "string", - enum: ["strict", "minimum"] - }, - beforeColon: { - type: "boolean" - }, - afterColon: { - type: "boolean" - } - }, - additionalProperties: false - }, - align: { - type: "object", - properties: { - mode: { - type: "string", - enum: ["strict", "minimum"] - }, - on: { - type: "string", - enum: ["colon", "value"] - }, - beforeColon: { - type: "boolean" - }, - afterColon: { - type: "boolean" - } - }, - additionalProperties: false - } - }, - additionalProperties: false - } - ] - }], - messages: { - extraKey: "Extra space after {{computed}}key '{{key}}'.", - extraValue: "Extra space before value for {{computed}}key '{{key}}'.", - missingKey: "Missing space after {{computed}}key '{{key}}'.", - missingValue: "Missing space before value for {{computed}}key '{{key}}'." - } - }, - create(context) { - const options = context.options[0] || {}; - const ruleOptions = initOptions({}, options); - const multiLineOptions = ruleOptions.multiLine; - const singleLineOptions = ruleOptions.singleLine; - const alignmentOptions = ruleOptions.align || null; - const sourceCode = context.sourceCode; - function isKeyValueProperty(property) { - return !("method" in property && property.method || "shorthand" in property && property.shorthand || "kind" in property && property.kind !== "init" || property.type !== "Property"); - } - function getNextColon(node) { - return sourceCode.getTokenAfter(node, utils.isColonToken); - } - function getLastTokenBeforeColon(node) { - const colonToken = getNextColon(node); - return sourceCode.getTokenBefore(colonToken); - } - function getFirstTokenAfterColon(node) { - const colonToken = getNextColon(node); - return sourceCode.getTokenAfter(colonToken); - } - function continuesPropertyGroup(lastMember, candidate) { - const groupEndLine = lastMember.loc.start.line; - const candidateValueStartLine = (isKeyValueProperty(candidate) ? getFirstTokenAfterColon(candidate.key) : candidate).loc.start.line; - if (candidateValueStartLine - groupEndLine <= 1) - return true; - const leadingComments = sourceCode.getCommentsBefore(candidate); - if (leadingComments.length && leadingComments[0].loc.start.line - groupEndLine <= 1 && candidateValueStartLine - last(leadingComments).loc.end.line <= 1) { - for (let i = 1; i < leadingComments.length; i++) { - if (leadingComments[i].loc.start.line - leadingComments[i - 1].loc.end.line > 1) - return false; - } - return true; - } - return false; - } - function getKey(property) { - const key = property.key; - if (property.computed) - return sourceCode.getText().slice(key.range[0], key.range[1]); - return utils.getStaticPropertyName(property); - } - function report(property, side, whitespace, expected, mode) { - const diff = whitespace.length - expected; - if ((diff && mode === "strict" || diff < 0 && mode === "minimum" || diff > 0 && !expected && mode === "minimum") && !(expected && containsLineTerminator(whitespace))) { - const nextColon = getNextColon(property.key); - const tokenBeforeColon = sourceCode.getTokenBefore(nextColon, { includeComments: true }); - const tokenAfterColon = sourceCode.getTokenAfter(nextColon, { includeComments: true }); - const isKeySide = side === "key"; - const isExtra = diff > 0; - const diffAbs = Math.abs(diff); - const spaces = Array(diffAbs + 1).join(" "); - const locStart = isKeySide ? tokenBeforeColon.loc.end : nextColon.loc.start; - const locEnd = isKeySide ? nextColon.loc.start : tokenAfterColon.loc.start; - const missingLoc = isKeySide ? tokenBeforeColon.loc : tokenAfterColon.loc; - const loc = isExtra ? { start: locStart, end: locEnd } : missingLoc; - let fix; - if (isExtra) { - let range; - if (isKeySide) - range = [tokenBeforeColon.range[1], tokenBeforeColon.range[1] + diffAbs]; - else - range = [tokenAfterColon.range[0] - diffAbs, tokenAfterColon.range[0]]; - fix = function(fixer) { - return fixer.removeRange(range); - }; - } else { - if (isKeySide) { - fix = function(fixer) { - return fixer.insertTextAfter(tokenBeforeColon, spaces); - }; - } else { - fix = function(fixer) { - return fixer.insertTextBefore(tokenAfterColon, spaces); - }; - } - } - let messageId; - if (isExtra) - messageId = side === "key" ? "extraKey" : "extraValue"; - else - messageId = side === "key" ? "missingKey" : "missingValue"; - context.report({ - node: property[side], - loc, - messageId, - data: { - computed: property.computed ? "computed " : "", - key: getKey(property) - }, - fix - }); - } - } - function getKeyWidth(property) { - const startToken = sourceCode.getFirstToken(property); - const endToken = getLastTokenBeforeColon(property.key); - return utils.getGraphemeCount(sourceCode.getText().slice(startToken.range[0], endToken.range[1])); - } - function getPropertyWhitespace(property) { - const whitespace = /(\s*):(\s*)/u.exec(sourceCode.getText().slice( - property.key.range[1], - property.value.range[0] - )); - if (whitespace) { - return { - beforeColon: whitespace[1], - afterColon: whitespace[2] - }; - } - return null; - } - function createGroups(node) { - if (node.properties.length === 1) - return [node.properties]; - return node.properties.reduce((groups, property) => { - const currentGroup = last(groups); - const prev = last(currentGroup); - if (!prev || continuesPropertyGroup(prev, property)) - currentGroup.push(property); - else - groups.push([property]); - return groups; - }, [ - [] - ]); - } - function verifyGroupAlignment(properties) { - const length = properties.length; - const widths = properties.map(getKeyWidth); - const align = alignmentOptions.on; - let targetWidth = Math.max(...widths); - let beforeColon; - let afterColon; - let mode; - if (alignmentOptions && length > 1) { - beforeColon = alignmentOptions.beforeColon; - afterColon = alignmentOptions.afterColon; - mode = alignmentOptions.mode; - } else { - beforeColon = multiLineOptions.beforeColon; - afterColon = multiLineOptions.afterColon; - mode = alignmentOptions.mode; - } - targetWidth += align === "colon" ? beforeColon : afterColon; - for (let i = 0; i < length; i++) { - const property = properties[i]; - const whitespace = getPropertyWhitespace(property); - if (whitespace) { - const width = widths[i]; - if (align === "value") { - report(property, "key", whitespace.beforeColon, beforeColon, mode); - report(property, "value", whitespace.afterColon, targetWidth - width, mode); - } else { - report(property, "key", whitespace.beforeColon, targetWidth - width, mode); - report(property, "value", whitespace.afterColon, afterColon, mode); - } - } - } - } - function verifySpacing(node, lineOptions) { - const actual = getPropertyWhitespace(node); - if (actual) { - report(node, "key", actual.beforeColon, lineOptions.beforeColon, lineOptions.mode); - report(node, "value", actual.afterColon, lineOptions.afterColon, lineOptions.mode); - } - } - function verifyListSpacing(properties, lineOptions) { - const length = properties.length; - for (let i = 0; i < length; i++) - verifySpacing(properties[i], lineOptions); - } - function verifyAlignment(node) { - createGroups(node).forEach((group) => { - const properties = group.filter(isKeyValueProperty); - if (properties.length > 0 && isSingleLineProperties(properties)) - verifyListSpacing(properties, multiLineOptions); - else - verifyGroupAlignment(properties); - }); - } - if (alignmentOptions) { - return { - ObjectExpression(node) { - if (isSingleLine(node)) - verifyListSpacing(node.properties.filter(isKeyValueProperty), singleLineOptions); - else - verifyAlignment(node); - } - }; - } - return { - Property(node) { - verifySpacing(node, isSingleLine(node.parent) ? singleLineOptions : multiLineOptions); - } - }; - } -}); - -exports.keySpacing = keySpacing; diff --git a/tools/eslint/node_modules/@stylistic/eslint-plugin-js/dist/keyword-spacing.js b/tools/eslint/node_modules/@stylistic/eslint-plugin-js/dist/keyword-spacing.js deleted file mode 100644 index 500c9a15dc324c..00000000000000 --- a/tools/eslint/node_modules/@stylistic/eslint-plugin-js/dist/keyword-spacing.js +++ /dev/null @@ -1,336 +0,0 @@ -'use strict'; - -var utils = require('./utils.js'); - -const PREV_TOKEN = /^[)\]}>]$/u; -const NEXT_TOKEN = /^(?:[([{<~!]|\+\+?|--?)$/u; -const PREV_TOKEN_M = /^[)\]}>*]$/u; -const NEXT_TOKEN_M = /^[{*]$/u; -const TEMPLATE_OPEN_PAREN = /\$\{$/u; -const TEMPLATE_CLOSE_PAREN = /^\}/u; -const CHECK_TYPE = /^(?:JSXElement|RegularExpression|String|Template|PrivateIdentifier)$/u; -const KEYS = utils.keywords.concat(["as", "async", "await", "from", "get", "let", "of", "set", "yield"]); -(function() { - KEYS.sort(); - for (let i = 1; i < KEYS.length; ++i) { - if (KEYS[i] === KEYS[i - 1]) - throw new Error(`Duplication was found in the keyword list: ${KEYS[i]}`); - } -})(); -function isOpenParenOfTemplate(token) { - return token.type === "Template" && TEMPLATE_OPEN_PAREN.test(token.value); -} -function isCloseParenOfTemplate(token) { - return token.type === "Template" && TEMPLATE_CLOSE_PAREN.test(token.value); -} -var keywordSpacing = utils.createRule({ - meta: { - type: "layout", - docs: { - description: "Enforce consistent spacing before and after keywords", - url: "https://eslint.style/rules/js/keyword-spacing" - }, - fixable: "whitespace", - schema: [ - { - type: "object", - properties: { - before: { type: "boolean", default: true }, - after: { type: "boolean", default: true }, - overrides: { - type: "object", - properties: KEYS.reduce((retv, key) => { - retv[key] = { - type: "object", - properties: { - before: { type: "boolean" }, - after: { type: "boolean" } - }, - additionalProperties: false - }; - return retv; - }, {}), - additionalProperties: false - } - }, - additionalProperties: false - } - ], - messages: { - expectedBefore: 'Expected space(s) before "{{value}}".', - expectedAfter: 'Expected space(s) after "{{value}}".', - unexpectedBefore: 'Unexpected space(s) before "{{value}}".', - unexpectedAfter: 'Unexpected space(s) after "{{value}}".' - } - }, - create(context) { - const sourceCode = context.sourceCode; - const tokensToIgnore = /* @__PURE__ */ new WeakSet(); - function expectSpaceBefore(token, pattern) { - const prevToken = sourceCode.getTokenBefore(token); - if (prevToken && (CHECK_TYPE.test(prevToken.type) || pattern.test(prevToken.value)) && !isOpenParenOfTemplate(prevToken) && !tokensToIgnore.has(prevToken) && utils.isTokenOnSameLine(prevToken, token) && !sourceCode.isSpaceBetweenTokens(prevToken, token)) { - context.report({ - loc: token.loc, - messageId: "expectedBefore", - // @ts-expect-error index signature for string is missing - data: token, - fix(fixer) { - return fixer.insertTextBefore(token, " "); - } - }); - } - } - function unexpectSpaceBefore(token, pattern) { - const prevToken = sourceCode.getTokenBefore(token); - if (prevToken && (CHECK_TYPE.test(prevToken.type) || pattern.test(prevToken.value)) && !isOpenParenOfTemplate(prevToken) && !tokensToIgnore.has(prevToken) && utils.isTokenOnSameLine(prevToken, token) && sourceCode.isSpaceBetweenTokens(prevToken, token)) { - context.report({ - loc: { start: prevToken.loc.end, end: token.loc.start }, - messageId: "unexpectedBefore", - // @ts-expect-error index signature for string is missing - data: token, - fix(fixer) { - return fixer.removeRange([prevToken.range[1], token.range[0]]); - } - }); - } - } - function expectSpaceAfter(token, pattern) { - const nextToken = sourceCode.getTokenAfter(token); - if (nextToken && (CHECK_TYPE.test(nextToken.type) || pattern.test(nextToken.value)) && !isCloseParenOfTemplate(nextToken) && !tokensToIgnore.has(nextToken) && utils.isTokenOnSameLine(token, nextToken) && !sourceCode.isSpaceBetweenTokens(token, nextToken)) { - context.report({ - loc: token.loc, - messageId: "expectedAfter", - // @ts-expect-error index signature for string is missing - data: token, - fix(fixer) { - return fixer.insertTextAfter(token, " "); - } - }); - } - } - function unexpectSpaceAfter(token, pattern) { - const nextToken = sourceCode.getTokenAfter(token); - if (nextToken && (CHECK_TYPE.test(nextToken.type) || pattern.test(nextToken.value)) && !isCloseParenOfTemplate(nextToken) && !tokensToIgnore.has(nextToken) && utils.isTokenOnSameLine(token, nextToken) && sourceCode.isSpaceBetweenTokens(token, nextToken)) { - context.report({ - loc: { start: token.loc.end, end: nextToken.loc.start }, - messageId: "unexpectedAfter", - // @ts-expect-error index signature for string is missing - data: token, - fix(fixer) { - return fixer.removeRange([token.range[1], nextToken.range[0]]); - } - }); - } - } - function parseOptions(options = {}) { - const before = options.before !== false; - const after = options.after !== false; - const defaultValue = { - before: before ? expectSpaceBefore : unexpectSpaceBefore, - after: after ? expectSpaceAfter : unexpectSpaceAfter - }; - const overrides = options && options.overrides || {}; - const retv = /* @__PURE__ */ Object.create(null); - for (let i = 0; i < KEYS.length; ++i) { - const key = KEYS[i]; - const override = overrides[key]; - if (override) { - const thisBefore = "before" in override ? override.before : before; - const thisAfter = "after" in override ? override.after : after; - retv[key] = { - before: thisBefore ? expectSpaceBefore : unexpectSpaceBefore, - after: thisAfter ? expectSpaceAfter : unexpectSpaceAfter - }; - } else { - retv[key] = defaultValue; - } - } - return retv; - } - const checkMethodMap = parseOptions(context.options[0]); - function checkSpacingBefore(token, pattern) { - checkMethodMap[token.value].before(token, pattern || PREV_TOKEN); - } - function checkSpacingAfter(token, pattern) { - checkMethodMap[token.value].after(token, pattern || NEXT_TOKEN); - } - function checkSpacingAround(token) { - checkSpacingBefore(token); - checkSpacingAfter(token); - } - function checkSpacingAroundFirstToken(node) { - const firstToken = node && sourceCode.getFirstToken(node); - if (firstToken && firstToken.type === "Keyword") - checkSpacingAround(firstToken); - } - function checkSpacingBeforeFirstToken(node) { - const firstToken = node && sourceCode.getFirstToken(node); - if (firstToken && firstToken.type === "Keyword") - checkSpacingBefore(firstToken); - } - function checkSpacingAroundTokenBefore(node) { - if (node) { - const token = sourceCode.getTokenBefore(node, utils.isKeywordToken); - if (token) - checkSpacingAround(token); - } - } - function checkSpacingForFunction(node) { - const firstToken = node && sourceCode.getFirstToken(node); - if (firstToken && (firstToken.type === "Keyword" && firstToken.value === "function" || firstToken.value === "async")) { - checkSpacingBefore(firstToken); - } - } - function checkSpacingForClass(node) { - checkSpacingAroundFirstToken(node); - checkSpacingAroundTokenBefore(node.superClass); - } - function checkSpacingForIfStatement(node) { - checkSpacingAroundFirstToken(node); - checkSpacingAroundTokenBefore(node.alternate); - } - function checkSpacingForTryStatement(node) { - checkSpacingAroundFirstToken(node); - checkSpacingAroundFirstToken(node.handler); - checkSpacingAroundTokenBefore(node.finalizer); - } - function checkSpacingForDoWhileStatement(node) { - checkSpacingAroundFirstToken(node); - checkSpacingAroundTokenBefore(node.test); - } - function checkSpacingForForInStatement(node) { - checkSpacingAroundFirstToken(node); - const inToken = sourceCode.getTokenBefore(node.right, utils.isNotOpeningParenToken); - const previousToken = sourceCode.getTokenBefore(inToken); - if (previousToken.type !== "PrivateIdentifier") - checkSpacingBefore(inToken); - checkSpacingAfter(inToken); - } - function checkSpacingForForOfStatement(node) { - if (node.await) { - checkSpacingBefore(sourceCode.getFirstToken(node, 0)); - checkSpacingAfter(sourceCode.getFirstToken(node, 1)); - } else { - checkSpacingAroundFirstToken(node); - } - const ofToken = sourceCode.getTokenBefore(node.right, utils.isNotOpeningParenToken); - const previousToken = sourceCode.getTokenBefore(ofToken); - if (previousToken.type !== "PrivateIdentifier") - checkSpacingBefore(ofToken); - checkSpacingAfter(ofToken); - } - function checkSpacingForModuleDeclaration(node) { - const firstToken = sourceCode.getFirstToken(node); - checkSpacingBefore(firstToken, PREV_TOKEN_M); - checkSpacingAfter(firstToken, NEXT_TOKEN_M); - if (node.type === "ExportDefaultDeclaration") - checkSpacingAround(sourceCode.getTokenAfter(firstToken)); - if (node.type === "ExportAllDeclaration" && node.exported) { - const asToken = sourceCode.getTokenBefore(node.exported); - checkSpacingBefore(asToken, PREV_TOKEN_M); - checkSpacingAfter(asToken, NEXT_TOKEN_M); - } - if ("source" in node && node.source) { - const fromToken = sourceCode.getTokenBefore(node.source); - checkSpacingBefore(fromToken, PREV_TOKEN_M); - checkSpacingAfter(fromToken, NEXT_TOKEN_M); - } - } - function checkSpacingForImportSpecifier(node) { - if (node.imported.range[0] !== node.local.range[0]) { - const asToken = sourceCode.getTokenBefore(node.local); - checkSpacingBefore(asToken, PREV_TOKEN_M); - } - } - function checkSpacingForExportSpecifier(node) { - if (node.local.range[0] !== node.exported.range[0]) { - const asToken = sourceCode.getTokenBefore(node.exported); - checkSpacingBefore(asToken, PREV_TOKEN_M); - checkSpacingAfter(asToken, NEXT_TOKEN_M); - } - } - function checkSpacingForImportNamespaceSpecifier(node) { - const asToken = sourceCode.getFirstToken(node, 1); - checkSpacingBefore(asToken, PREV_TOKEN_M); - } - function checkSpacingForProperty(node) { - if ("static" in node && node.static) - checkSpacingAroundFirstToken(node); - if (node.kind === "get" || node.kind === "set" || ("method" in node && node.method || node.type === "MethodDefinition") && "async" in node.value && node.value.async) { - const token = sourceCode.getTokenBefore( - node.key, - (tok) => { - switch (tok.value) { - case "get": - case "set": - case "async": - return true; - default: - return false; - } - } - ); - if (!token) - throw new Error("Failed to find token get, set, or async beside method name"); - checkSpacingAround(token); - } - } - function checkSpacingForAwaitExpression(node) { - checkSpacingBefore(sourceCode.getFirstToken(node)); - } - return { - // Statements - "DebuggerStatement": checkSpacingAroundFirstToken, - "WithStatement": checkSpacingAroundFirstToken, - // Statements - Control flow - "BreakStatement": checkSpacingAroundFirstToken, - "ContinueStatement": checkSpacingAroundFirstToken, - "ReturnStatement": checkSpacingAroundFirstToken, - "ThrowStatement": checkSpacingAroundFirstToken, - "TryStatement": checkSpacingForTryStatement, - // Statements - Choice - "IfStatement": checkSpacingForIfStatement, - "SwitchStatement": checkSpacingAroundFirstToken, - "SwitchCase": checkSpacingAroundFirstToken, - // Statements - Loops - "DoWhileStatement": checkSpacingForDoWhileStatement, - "ForInStatement": checkSpacingForForInStatement, - "ForOfStatement": checkSpacingForForOfStatement, - "ForStatement": checkSpacingAroundFirstToken, - "WhileStatement": checkSpacingAroundFirstToken, - // Statements - Declarations - "ClassDeclaration": checkSpacingForClass, - "ExportNamedDeclaration": checkSpacingForModuleDeclaration, - "ExportDefaultDeclaration": checkSpacingForModuleDeclaration, - "ExportAllDeclaration": checkSpacingForModuleDeclaration, - "FunctionDeclaration": checkSpacingForFunction, - "ImportDeclaration": checkSpacingForModuleDeclaration, - "VariableDeclaration": checkSpacingAroundFirstToken, - // Expressions - "ArrowFunctionExpression": checkSpacingForFunction, - "AwaitExpression": checkSpacingForAwaitExpression, - "ClassExpression": checkSpacingForClass, - "FunctionExpression": checkSpacingForFunction, - "NewExpression": checkSpacingBeforeFirstToken, - "Super": checkSpacingBeforeFirstToken, - "ThisExpression": checkSpacingBeforeFirstToken, - "UnaryExpression": checkSpacingBeforeFirstToken, - "YieldExpression": checkSpacingBeforeFirstToken, - // Others - "ImportSpecifier": checkSpacingForImportSpecifier, - "ExportSpecifier": checkSpacingForExportSpecifier, - "ImportNamespaceSpecifier": checkSpacingForImportNamespaceSpecifier, - "MethodDefinition": checkSpacingForProperty, - "PropertyDefinition": checkSpacingForProperty, - "StaticBlock": checkSpacingAroundFirstToken, - "Property": checkSpacingForProperty, - // To avoid conflicts with `space-infix-ops`, e.g. `a > this.b` - "BinaryExpression[operator='>']": function(node) { - const operatorToken = sourceCode.getTokenBefore(node.right, utils.isNotOpeningParenToken); - tokensToIgnore.add(operatorToken); - } - }; - } -}); - -exports.keywordSpacing = keywordSpacing; diff --git a/tools/eslint/node_modules/@stylistic/eslint-plugin-js/dist/line-comment-position.js b/tools/eslint/node_modules/@stylistic/eslint-plugin-js/dist/line-comment-position.js deleted file mode 100644 index a66fd29c78987c..00000000000000 --- a/tools/eslint/node_modules/@stylistic/eslint-plugin-js/dist/line-comment-position.js +++ /dev/null @@ -1,97 +0,0 @@ -'use strict'; - -var utils = require('./utils.js'); - -var lineCommentPosition = utils.createRule({ - meta: { - type: "layout", - docs: { - description: "Enforce position of line comments", - url: "https://eslint.style/rules/js/line-comment-position" - }, - schema: [ - { - oneOf: [ - { - type: "string", - enum: ["above", "beside"] - }, - { - type: "object", - properties: { - position: { - type: "string", - enum: ["above", "beside"] - }, - ignorePattern: { - type: "string" - }, - applyDefaultPatterns: { - type: "boolean" - }, - applyDefaultIgnorePatterns: { - type: "boolean" - } - }, - additionalProperties: false - } - ] - } - ], - messages: { - above: "Expected comment to be above code.", - beside: "Expected comment to be beside code." - } - }, - create(context) { - const options = context.options[0]; - let above; - let ignorePattern; - let applyDefaultIgnorePatterns = true; - let customIgnoreRegExp; - if (!options || typeof options === "string") { - above = !options || options === "above"; - } else { - above = !options.position || options.position === "above"; - ignorePattern = options.ignorePattern; - customIgnoreRegExp = new RegExp(ignorePattern, "u"); - if (Object.hasOwn(options, "applyDefaultIgnorePatterns")) - applyDefaultIgnorePatterns = options.applyDefaultIgnorePatterns; - else - applyDefaultIgnorePatterns = options.applyDefaultPatterns !== false; - } - const defaultIgnoreRegExp = utils.COMMENTS_IGNORE_PATTERN; - const fallThroughRegExp = /^\s*falls?\s?through/u; - const sourceCode = context.sourceCode; - return { - Program() { - const comments = sourceCode.getAllComments(); - comments.filter((token) => token.type === "Line").forEach((node) => { - if (applyDefaultIgnorePatterns && (defaultIgnoreRegExp.test(node.value) || fallThroughRegExp.test(node.value))) - return; - if (ignorePattern && customIgnoreRegExp.test(node.value)) - return; - const previous = sourceCode.getTokenBefore(node, { includeComments: true }); - const isOnSameLine = previous && previous.loc.end.line === node.loc.start.line; - if (above) { - if (isOnSameLine) { - context.report({ - node, - messageId: "above" - }); - } - } else { - if (!isOnSameLine) { - context.report({ - node, - messageId: "beside" - }); - } - } - }); - } - }; - } -}); - -exports.lineCommentPosition = lineCommentPosition; diff --git a/tools/eslint/node_modules/@stylistic/eslint-plugin-js/dist/linebreak-style.js b/tools/eslint/node_modules/@stylistic/eslint-plugin-js/dist/linebreak-style.js deleted file mode 100644 index 6b0cad6ff3cda6..00000000000000 --- a/tools/eslint/node_modules/@stylistic/eslint-plugin-js/dist/linebreak-style.js +++ /dev/null @@ -1,67 +0,0 @@ -'use strict'; - -var utils = require('./utils.js'); - -var linebreakStyle = utils.createRule({ - meta: { - type: "layout", - docs: { - description: "Enforce consistent linebreak style", - url: "https://eslint.style/rules/js/linebreak-style" - }, - fixable: "whitespace", - schema: [ - { - type: "string", - enum: ["unix", "windows"] - } - ], - messages: { - expectedLF: "Expected linebreaks to be 'LF' but found 'CRLF'.", - expectedCRLF: "Expected linebreaks to be 'CRLF' but found 'LF'." - } - }, - create(context) { - const sourceCode = context.sourceCode; - function createFix(range, text) { - return function(fixer) { - return fixer.replaceTextRange(range, text); - }; - } - return { - Program: function checkForLinebreakStyle(node) { - const linebreakStyle = context.options[0] || "unix"; - const expectedLF = linebreakStyle === "unix"; - const expectedLFChars = expectedLF ? "\n" : "\r\n"; - const source = sourceCode.getText(); - const pattern = utils.createGlobalLinebreakMatcher(); - let match; - let i = 0; - while ((match = pattern.exec(source)) !== null) { - i++; - if (match[0] === expectedLFChars) - continue; - const index = match.index; - const range = [index, index + match[0].length]; - context.report({ - node, - loc: { - start: { - line: i, - column: sourceCode.lines[i - 1].length - }, - end: { - line: i + 1, - column: 0 - } - }, - messageId: expectedLF ? "expectedLF" : "expectedCRLF", - fix: createFix(range, expectedLFChars) - }); - } - } - }; - } -}); - -exports.linebreakStyle = linebreakStyle; diff --git a/tools/eslint/node_modules/@stylistic/eslint-plugin-js/dist/lines-around-comment.js b/tools/eslint/node_modules/@stylistic/eslint-plugin-js/dist/lines-around-comment.js deleted file mode 100644 index 2ceea60d286274..00000000000000 --- a/tools/eslint/node_modules/@stylistic/eslint-plugin-js/dist/lines-around-comment.js +++ /dev/null @@ -1,257 +0,0 @@ -'use strict'; - -var utils = require('./utils.js'); - -function getEmptyLineNums(lines) { - const emptyLines = lines.map((line, i) => ({ - code: line.trim(), - num: i + 1 - })).filter((line) => !line.code).map((line) => line.num); - return emptyLines; -} -function getCommentLineNums(comments) { - const lines = []; - comments.forEach((token) => { - const start = token.loc.start.line; - const end = token.loc.end.line; - lines.push(start, end); - }); - return lines; -} -var linesAroundComment = utils.createRule({ - meta: { - type: "layout", - docs: { - description: "Require empty lines around comments", - url: "https://eslint.style/rules/js/lines-around-comment" - }, - fixable: "whitespace", - schema: [ - { - type: "object", - properties: { - beforeBlockComment: { - type: "boolean", - default: true - }, - afterBlockComment: { - type: "boolean", - default: false - }, - beforeLineComment: { - type: "boolean", - default: false - }, - afterLineComment: { - type: "boolean", - default: false - }, - allowBlockStart: { - type: "boolean", - default: false - }, - allowBlockEnd: { - type: "boolean", - default: false - }, - allowClassStart: { - type: "boolean" - }, - allowClassEnd: { - type: "boolean" - }, - allowObjectStart: { - type: "boolean" - }, - allowObjectEnd: { - type: "boolean" - }, - allowArrayStart: { - type: "boolean" - }, - allowArrayEnd: { - type: "boolean" - }, - ignorePattern: { - type: "string" - }, - applyDefaultIgnorePatterns: { - type: "boolean" - }, - afterHashbangComment: { - type: "boolean", - default: false - } - }, - additionalProperties: false - } - ], - messages: { - after: "Expected line after comment.", - before: "Expected line before comment." - } - }, - create(context) { - const options = Object.assign({}, context.options[0]); - const ignorePattern = options.ignorePattern; - const defaultIgnoreRegExp = utils.COMMENTS_IGNORE_PATTERN; - const customIgnoreRegExp = ignorePattern && new RegExp(ignorePattern, "u"); - const applyDefaultIgnorePatterns = options.applyDefaultIgnorePatterns !== false; - options.beforeBlockComment = typeof options.beforeBlockComment !== "undefined" ? options.beforeBlockComment : true; - const sourceCode = context.sourceCode; - const lines = sourceCode.lines; - const numLines = lines.length + 1; - const comments = sourceCode.getAllComments(); - const commentLines = getCommentLineNums(comments); - const emptyLines = getEmptyLineNums(lines); - const commentAndEmptyLines = new Set(commentLines.concat(emptyLines)); - function codeAroundComment(token) { - let currentToken = token; - do - currentToken = sourceCode.getTokenBefore(currentToken, { includeComments: true }); - while (currentToken && utils.isCommentToken(currentToken)); - if (currentToken && utils.isTokenOnSameLine(currentToken, token)) - return true; - currentToken = token; - do - currentToken = sourceCode.getTokenAfter(currentToken, { includeComments: true }); - while (currentToken && utils.isCommentToken(currentToken)); - if (currentToken && utils.isTokenOnSameLine(token, currentToken)) - return true; - return false; - } - function isParentNodeType(parent, nodeType) { - return parent.type === nodeType; - } - function getParentNodeOfToken(token) { - const node = sourceCode.getNodeByRangeIndex(token.range[0]); - if (node && node.type === "StaticBlock") { - const openingBrace = sourceCode.getFirstToken(node, { skip: 1 }); - return openingBrace && token.range[0] >= openingBrace.range[0] ? node : null; - } - return node; - } - function isCommentAtParentStart(token, nodeType) { - const parent = getParentNodeOfToken(token); - if (parent && isParentNodeType(parent, nodeType)) { - let parentStartNodeOrToken = parent; - if (parent.type === "StaticBlock") { - parentStartNodeOrToken = sourceCode.getFirstToken(parent, { skip: 1 }); - } else if (parent.type === "SwitchStatement") { - parentStartNodeOrToken = sourceCode.getTokenAfter(parent.discriminant, { - filter: utils.isOpeningBraceToken - }); - } - return !!parentStartNodeOrToken && token.loc.start.line - parentStartNodeOrToken.loc.start.line === 1; - } - return false; - } - function isCommentAtParentEnd(token, nodeType) { - const parent = getParentNodeOfToken(token); - return !!parent && isParentNodeType(parent, nodeType) && parent.loc.end.line - token.loc.end.line === 1; - } - function isCommentAtBlockStart(token) { - return isCommentAtParentStart(token, "ClassBody") || isCommentAtParentStart(token, "BlockStatement") || isCommentAtParentStart(token, "StaticBlock") || isCommentAtParentStart(token, "SwitchCase") || isCommentAtParentStart(token, "SwitchStatement"); - } - function isCommentAtBlockEnd(token) { - return isCommentAtParentEnd(token, "ClassBody") || isCommentAtParentEnd(token, "BlockStatement") || isCommentAtParentEnd(token, "StaticBlock") || isCommentAtParentEnd(token, "SwitchCase") || isCommentAtParentEnd(token, "SwitchStatement"); - } - function isCommentAtClassStart(token) { - return isCommentAtParentStart(token, "ClassBody"); - } - function isCommentAtClassEnd(token) { - return isCommentAtParentEnd(token, "ClassBody"); - } - function isCommentAtObjectStart(token) { - return isCommentAtParentStart(token, "ObjectExpression") || isCommentAtParentStart(token, "ObjectPattern"); - } - function isCommentAtObjectEnd(token) { - return isCommentAtParentEnd(token, "ObjectExpression") || isCommentAtParentEnd(token, "ObjectPattern"); - } - function isCommentAtArrayStart(token) { - return isCommentAtParentStart(token, "ArrayExpression") || isCommentAtParentStart(token, "ArrayPattern"); - } - function isCommentAtArrayEnd(token) { - return isCommentAtParentEnd(token, "ArrayExpression") || isCommentAtParentEnd(token, "ArrayPattern"); - } - function checkForEmptyLine(token, opts) { - if (applyDefaultIgnorePatterns && defaultIgnoreRegExp.test(token.value)) - return; - if (customIgnoreRegExp && customIgnoreRegExp.test(token.value)) - return; - let after = opts.after; - let before = opts.before; - const prevLineNum = token.loc.start.line - 1; - const nextLineNum = token.loc.end.line + 1; - const commentIsNotAlone = codeAroundComment(token); - const blockStartAllowed = options.allowBlockStart && isCommentAtBlockStart(token) && !(options.allowClassStart === false && isCommentAtClassStart(token)); - const blockEndAllowed = options.allowBlockEnd && isCommentAtBlockEnd(token) && !(options.allowClassEnd === false && isCommentAtClassEnd(token)); - const classStartAllowed = options.allowClassStart && isCommentAtClassStart(token); - const classEndAllowed = options.allowClassEnd && isCommentAtClassEnd(token); - const objectStartAllowed = options.allowObjectStart && isCommentAtObjectStart(token); - const objectEndAllowed = options.allowObjectEnd && isCommentAtObjectEnd(token); - const arrayStartAllowed = options.allowArrayStart && isCommentAtArrayStart(token); - const arrayEndAllowed = options.allowArrayEnd && isCommentAtArrayEnd(token); - const exceptionStartAllowed = blockStartAllowed || classStartAllowed || objectStartAllowed || arrayStartAllowed; - const exceptionEndAllowed = blockEndAllowed || classEndAllowed || objectEndAllowed || arrayEndAllowed; - if (prevLineNum < 1) - before = false; - if (nextLineNum >= numLines) - after = false; - if (commentIsNotAlone) - return; - const previousTokenOrComment = sourceCode.getTokenBefore(token, { includeComments: true }); - const nextTokenOrComment = sourceCode.getTokenAfter(token, { includeComments: true }); - if (!exceptionStartAllowed && before && !commentAndEmptyLines.has(prevLineNum) && !(utils.isCommentToken(previousTokenOrComment) && utils.isTokenOnSameLine(previousTokenOrComment, token))) { - const lineStart = token.range[0] - token.loc.start.column; - const range = [lineStart, lineStart]; - context.report({ - node: token, - messageId: "before", - fix(fixer) { - return fixer.insertTextBeforeRange(range, "\n"); - } - }); - } - if (!exceptionEndAllowed && after && !commentAndEmptyLines.has(nextLineNum) && !(utils.isCommentToken(nextTokenOrComment) && utils.isTokenOnSameLine(token, nextTokenOrComment))) { - context.report({ - node: token, - messageId: "after", - fix(fixer) { - return fixer.insertTextAfter(token, "\n"); - } - }); - } - } - return { - Program() { - comments.forEach((token) => { - if (token.type === "Line") { - if (options.beforeLineComment || options.afterLineComment) { - checkForEmptyLine(token, { - after: options.afterLineComment, - before: options.beforeLineComment - }); - } - } else if (token.type === "Block") { - if (options.beforeBlockComment || options.afterBlockComment) { - checkForEmptyLine(token, { - after: options.afterBlockComment, - before: options.beforeBlockComment - }); - } - } else if (token.type === "Shebang") { - if (options.afterHashbangComment) { - checkForEmptyLine(token, { - after: options.afterHashbangComment, - before: false - }); - } - } - }); - } - }; - } -}); - -exports.linesAroundComment = linesAroundComment; diff --git a/tools/eslint/node_modules/@stylistic/eslint-plugin-js/dist/lines-between-class-members.js b/tools/eslint/node_modules/@stylistic/eslint-plugin-js/dist/lines-between-class-members.js deleted file mode 100644 index f7650753fa6693..00000000000000 --- a/tools/eslint/node_modules/@stylistic/eslint-plugin-js/dist/lines-between-class-members.js +++ /dev/null @@ -1,147 +0,0 @@ -'use strict'; - -var utils = require('./utils.js'); - -const ClassMemberTypes = { - "*": { test: () => true }, - "field": { test: (node) => node.type === "PropertyDefinition" }, - "method": { test: (node) => node.type === "MethodDefinition" } -}; -var linesBetweenClassMembers = utils.createRule( - { - meta: { - type: "layout", - docs: { - description: "Require or disallow an empty line between class members", - url: "https://eslint.style/rules/js/lines-between-class-members" - }, - fixable: "whitespace", - schema: [ - { - anyOf: [ - { - type: "object", - properties: { - enforce: { - type: "array", - items: { - type: "object", - properties: { - blankLine: { type: "string", enum: ["always", "never"] }, - prev: { type: "string", enum: ["method", "field", "*"] }, - next: { type: "string", enum: ["method", "field", "*"] } - }, - additionalProperties: false, - required: ["blankLine", "prev", "next"] - }, - minItems: 1 - } - }, - additionalProperties: false, - required: ["enforce"] - }, - { - type: "string", - enum: ["always", "never"] - } - ] - }, - { - type: "object", - properties: { - exceptAfterSingleLine: { - type: "boolean", - default: false - } - }, - additionalProperties: false - } - ], - messages: { - never: "Unexpected blank line between class members.", - always: "Expected blank line between class members." - } - }, - create(context) { - const options = []; - options[0] = context.options[0] || "always"; - options[1] = context.options[1] || { exceptAfterSingleLine: false }; - const configureList = typeof options[0] === "object" ? options[0].enforce : [{ blankLine: options[0], prev: "*", next: "*" }]; - const sourceCode = context.sourceCode; - function getBoundaryTokens(curNode, nextNode) { - const lastToken = sourceCode.getLastToken(curNode); - const prevToken = sourceCode.getTokenBefore(lastToken); - const nextToken = sourceCode.getFirstToken(nextNode); - const isSemicolonLessStyle = utils.isSemicolonToken(lastToken) && !utils.isTokenOnSameLine(prevToken, lastToken) && utils.isTokenOnSameLine(lastToken, nextToken); - return isSemicolonLessStyle ? { curLast: prevToken, nextFirst: lastToken } : { curLast: lastToken, nextFirst: nextToken }; - } - function findLastConsecutiveTokenAfter(prevLastToken, nextFirstToken, maxLine) { - const after = sourceCode.getTokenAfter(prevLastToken, { includeComments: true }); - if (after !== nextFirstToken && after.loc.start.line - prevLastToken.loc.end.line <= maxLine) - return findLastConsecutiveTokenAfter(after, nextFirstToken, maxLine); - return prevLastToken; - } - function findFirstConsecutiveTokenBefore(nextFirstToken, prevLastToken, maxLine) { - const before = sourceCode.getTokenBefore(nextFirstToken, { includeComments: true }); - if (before !== prevLastToken && nextFirstToken.loc.start.line - before.loc.end.line <= maxLine) - return findFirstConsecutiveTokenBefore(before, prevLastToken, maxLine); - return nextFirstToken; - } - function hasTokenOrCommentBetween(before, after) { - return sourceCode.getTokensBetween(before, after, { includeComments: true }).length !== 0; - } - function match(node, type) { - return ClassMemberTypes[type].test(node); - } - function getPaddingType(prevNode, nextNode) { - for (let i = configureList.length - 1; i >= 0; --i) { - const configure = configureList[i]; - const matched = match(prevNode, configure.prev) && match(nextNode, configure.next); - if (matched) - return configure.blankLine; - } - return null; - } - return { - ClassBody(node) { - const body = node.body; - for (let i = 0; i < body.length - 1; i++) { - const curFirst = sourceCode.getFirstToken(body[i]); - const { curLast, nextFirst } = getBoundaryTokens(body[i], body[i + 1]); - const isMulti = !utils.isTokenOnSameLine(curFirst, curLast); - const skip = !isMulti && options[1].exceptAfterSingleLine; - const beforePadding = findLastConsecutiveTokenAfter(curLast, nextFirst, 1); - const afterPadding = findFirstConsecutiveTokenBefore(nextFirst, curLast, 1); - const isPadded = afterPadding.loc.start.line - beforePadding.loc.end.line > 1; - const hasTokenInPadding = hasTokenOrCommentBetween(beforePadding, afterPadding); - const curLineLastToken = findLastConsecutiveTokenAfter(curLast, nextFirst, 0); - const paddingType = getPaddingType(body[i], body[i + 1]); - if (paddingType === "never" && isPadded) { - context.report({ - node: body[i + 1], - messageId: "never", - fix(fixer) { - if (hasTokenInPadding) - return null; - return fixer.replaceTextRange([beforePadding.range[1], afterPadding.range[0]], "\n"); - } - }); - } else if (paddingType === "always" && !skip && !isPadded) { - context.report({ - node: body[i + 1], - messageId: "always", - fix(fixer) { - if (hasTokenInPadding) - return null; - return fixer.insertTextAfter(curLineLastToken, "\n"); - } - }); - } - } - } - }; - } - } -); - -exports.linesBetweenClassMembers = linesBetweenClassMembers; diff --git a/tools/eslint/node_modules/@stylistic/eslint-plugin-js/dist/max-len.js b/tools/eslint/node_modules/@stylistic/eslint-plugin-js/dist/max-len.js deleted file mode 100644 index f19a0ae941f8a9..00000000000000 --- a/tools/eslint/node_modules/@stylistic/eslint-plugin-js/dist/max-len.js +++ /dev/null @@ -1,237 +0,0 @@ -'use strict'; - -var utils = require('./utils.js'); - -const OPTIONS_SCHEMA = { - type: "object", - properties: { - code: { - type: "integer", - minimum: 0 - }, - comments: { - type: "integer", - minimum: 0 - }, - tabWidth: { - type: "integer", - minimum: 0 - }, - ignorePattern: { - type: "string" - }, - ignoreComments: { - type: "boolean" - }, - ignoreStrings: { - type: "boolean" - }, - ignoreUrls: { - type: "boolean" - }, - ignoreTemplateLiterals: { - type: "boolean" - }, - ignoreRegExpLiterals: { - type: "boolean" - }, - ignoreTrailingComments: { - type: "boolean" - } - }, - additionalProperties: false -}; -const OPTIONS_OR_INTEGER_SCHEMA = { - anyOf: [ - OPTIONS_SCHEMA, - { - type: "integer", - minimum: 0 - } - ] -}; -var maxLen = utils.createRule({ - meta: { - type: "layout", - docs: { - description: "Enforce a maximum line length", - url: "https://eslint.style/rules/js/max-len" - }, - schema: [ - OPTIONS_OR_INTEGER_SCHEMA, - OPTIONS_OR_INTEGER_SCHEMA, - OPTIONS_SCHEMA - ], - messages: { - max: "This line has a length of {{lineLength}}. Maximum allowed is {{maxLength}}.", - maxComment: "This line has a comment length of {{lineLength}}. Maximum allowed is {{maxCommentLength}}." - } - }, - create(context) { - const URL_REGEXP = /[^:/?#]:\/\/[^?#]/u; - const sourceCode = context.sourceCode; - function computeLineLength(line, tabWidth2) { - let extraCharacterCount = 0; - line.replace(/\t/gu, (_, offset) => { - const totalOffset = offset + extraCharacterCount; - const previousTabStopOffset = tabWidth2 ? totalOffset % tabWidth2 : 0; - const spaceCount = tabWidth2 - previousTabStopOffset; - extraCharacterCount += spaceCount - 1; - return ""; - }); - return Array.from(line).length + extraCharacterCount; - } - const options = Object.assign({}, context.options[context.options.length - 1]); - if (typeof context.options[0] === "number") - options.code = context.options[0]; - if (typeof context.options[1] === "number") - options.tabWidth = context.options[1]; - const maxLength = typeof options.code === "number" ? options.code : 80; - const tabWidth = typeof options.tabWidth === "number" ? options.tabWidth : 4; - const ignoreComments = !!options.ignoreComments; - const ignoreStrings = !!options.ignoreStrings; - const ignoreTemplateLiterals = !!options.ignoreTemplateLiterals; - const ignoreRegExpLiterals = !!options.ignoreRegExpLiterals; - const ignoreTrailingComments = !!options.ignoreTrailingComments || !!options.ignoreComments; - const ignoreUrls = !!options.ignoreUrls; - const maxCommentLength = options.comments; - let ignorePattern = null; - if (options.ignorePattern) - ignorePattern = new RegExp(options.ignorePattern, "u"); - function isTrailingComment(line, lineNumber, comment) { - return comment && (comment.loc.start.line === lineNumber && lineNumber <= comment.loc.end.line) && (comment.loc.end.line > lineNumber || comment.loc.end.column === line.length); - } - function isFullLineComment(line, lineNumber, comment) { - const start = comment.loc.start; - const end = comment.loc.end; - const isFirstTokenOnLine = !line.slice(0, comment.loc.start.column).trim(); - return comment && (start.line < lineNumber || start.line === lineNumber && isFirstTokenOnLine) && (end.line > lineNumber || end.line === lineNumber && end.column === line.length); - } - function isJSXEmptyExpressionInSingleLineContainer(node) { - if (!node || !node.parent || node.type !== "JSXEmptyExpression" || node.parent.type !== "JSXExpressionContainer") - return false; - const parent = node.parent; - return parent.loc.start.line === parent.loc.end.line; - } - function stripTrailingComment(line, comment) { - return line.slice(0, comment.loc.start.column).replace(/\s+$/u, ""); - } - function ensureArrayAndPush(object, key, value) { - if (!Array.isArray(object[key])) - object[key] = []; - object[key].push(value); - } - function getAllStrings() { - return sourceCode.ast.tokens.filter((token) => token.type === "String" || token.type === "JSXText" && sourceCode.getNodeByRangeIndex(token.range[0] - 1).type === "JSXAttribute"); - } - function getAllTemplateLiterals() { - return sourceCode.ast.tokens.filter((token) => token.type === "Template"); - } - function getAllRegExpLiterals() { - return sourceCode.ast.tokens.filter((token) => token.type === "RegularExpression"); - } - function groupArrayByLineNumber(arr) { - const obj = {}; - for (let i = 0; i < arr.length; i++) { - const node = arr[i]; - for (let j = node.loc.start.line; j <= node.loc.end.line; ++j) - ensureArrayAndPush(obj, j, node); - } - return obj; - } - function getAllComments() { - const comments = []; - sourceCode.getAllComments().forEach((commentNode) => { - const containingNode = sourceCode.getNodeByRangeIndex(commentNode.range[0]); - if (isJSXEmptyExpressionInSingleLineContainer(containingNode)) { - if (comments[comments.length - 1] !== containingNode.parent) - comments.push(containingNode.parent); - } else { - comments.push(commentNode); - } - }); - return comments; - } - function checkProgramForMaxLength(node) { - const lines = sourceCode.lines; - const comments = ignoreComments || maxCommentLength || ignoreTrailingComments ? getAllComments() : []; - let commentsIndex = 0; - const strings = getAllStrings(); - const stringsByLine = groupArrayByLineNumber(strings); - const templateLiterals = getAllTemplateLiterals(); - const templateLiteralsByLine = groupArrayByLineNumber(templateLiterals); - const regExpLiterals = getAllRegExpLiterals(); - const regExpLiteralsByLine = groupArrayByLineNumber(regExpLiterals); - lines.forEach((line, i) => { - const lineNumber = i + 1; - let lineIsComment = false; - let textToMeasure; - if (commentsIndex < comments.length) { - let comment = null; - do - comment = comments[++commentsIndex]; - while (comment && comment.loc.start.line <= lineNumber); - comment = comments[--commentsIndex]; - if (isFullLineComment(line, lineNumber, comment)) { - lineIsComment = true; - textToMeasure = line; - } else if (ignoreTrailingComments && isTrailingComment(line, lineNumber, comment)) { - textToMeasure = stripTrailingComment(line, comment); - let lastIndex = commentsIndex; - while (isTrailingComment(textToMeasure, lineNumber, comments[--lastIndex])) - textToMeasure = stripTrailingComment(textToMeasure, comments[lastIndex]); - } else { - textToMeasure = line; - } - } else { - textToMeasure = line; - } - if (ignorePattern && ignorePattern.test(textToMeasure) || ignoreUrls && URL_REGEXP.test(textToMeasure) || ignoreStrings && stringsByLine[lineNumber] || ignoreTemplateLiterals && templateLiteralsByLine[lineNumber] || ignoreRegExpLiterals && regExpLiteralsByLine[lineNumber]) { - return; - } - const lineLength = computeLineLength(textToMeasure, tabWidth); - const commentLengthApplies = lineIsComment && maxCommentLength; - if (lineIsComment && ignoreComments) - return; - const loc = { - start: { - line: lineNumber, - column: 0 - }, - end: { - line: lineNumber, - column: textToMeasure.length - } - }; - if (commentLengthApplies) { - if (lineLength > maxCommentLength) { - context.report({ - node, - loc, - messageId: "maxComment", - data: { - lineLength, - maxCommentLength - } - }); - } - } else if (lineLength > maxLength) { - context.report({ - node, - loc, - messageId: "max", - data: { - lineLength, - maxLength - } - }); - } - }); - } - return { - Program: checkProgramForMaxLength - }; - } -}); - -exports.maxLen = maxLen; diff --git a/tools/eslint/node_modules/@stylistic/eslint-plugin-js/dist/max-statements-per-line.js b/tools/eslint/node_modules/@stylistic/eslint-plugin-js/dist/max-statements-per-line.js deleted file mode 100644 index 6cb398f3d7eb25..00000000000000 --- a/tools/eslint/node_modules/@stylistic/eslint-plugin-js/dist/max-statements-per-line.js +++ /dev/null @@ -1,129 +0,0 @@ -'use strict'; - -var utils = require('./utils.js'); - -var maxStatementsPerLine = utils.createRule({ - meta: { - type: "layout", - docs: { - description: "Enforce a maximum number of statements allowed per line", - url: "https://eslint.style/rules/js/max-statements-per-line" - }, - schema: [ - { - type: "object", - properties: { - max: { - type: "integer", - minimum: 1, - default: 1 - } - }, - additionalProperties: false - } - ], - messages: { - exceed: "This line has {{numberOfStatementsOnThisLine}} {{statements}}. Maximum allowed is {{maxStatementsPerLine}}." - } - }, - create(context) { - const sourceCode = context.sourceCode; - const options = context.options[0] || {}; - const maxStatementsPerLine = typeof options.max !== "undefined" ? options.max : 1; - let lastStatementLine = 0; - let numberOfStatementsOnThisLine = 0; - let firstExtraStatement = null; - const SINGLE_CHILD_ALLOWED = /^(?:(?:DoWhile|For|ForIn|ForOf|If|Labeled|While)Statement|Export(?:Default|Named)Declaration)$/u; - function reportFirstExtraStatementAndClear() { - if (firstExtraStatement) { - context.report({ - node: firstExtraStatement, - messageId: "exceed", - data: { - numberOfStatementsOnThisLine, - maxStatementsPerLine, - statements: numberOfStatementsOnThisLine === 1 ? "statement" : "statements" - } - }); - } - firstExtraStatement = null; - } - function getActualLastToken(node) { - return sourceCode.getLastToken(node, utils.isNotSemicolonToken); - } - function enterStatement(node) { - const line = node.loc.start.line; - if (node.parent && SINGLE_CHILD_ALLOWED.test(node.parent.type) && (!("alternate" in node.parent) || node.parent.alternate !== node)) { - return; - } - if (line === lastStatementLine) { - numberOfStatementsOnThisLine += 1; - } else { - reportFirstExtraStatementAndClear(); - numberOfStatementsOnThisLine = 1; - lastStatementLine = line; - } - if (numberOfStatementsOnThisLine === maxStatementsPerLine + 1) - firstExtraStatement = firstExtraStatement || node; - } - function leaveStatement(node) { - const line = getActualLastToken(node).loc.end.line; - if (line !== lastStatementLine) { - reportFirstExtraStatementAndClear(); - numberOfStatementsOnThisLine = 1; - lastStatementLine = line; - } - } - return { - "BreakStatement": enterStatement, - "ClassDeclaration": enterStatement, - "ContinueStatement": enterStatement, - "DebuggerStatement": enterStatement, - "DoWhileStatement": enterStatement, - "ExpressionStatement": enterStatement, - "ForInStatement": enterStatement, - "ForOfStatement": enterStatement, - "ForStatement": enterStatement, - "FunctionDeclaration": enterStatement, - "IfStatement": enterStatement, - "ImportDeclaration": enterStatement, - "LabeledStatement": enterStatement, - "ReturnStatement": enterStatement, - "SwitchStatement": enterStatement, - "ThrowStatement": enterStatement, - "TryStatement": enterStatement, - "VariableDeclaration": enterStatement, - "WhileStatement": enterStatement, - "WithStatement": enterStatement, - "ExportNamedDeclaration": enterStatement, - "ExportDefaultDeclaration": enterStatement, - "ExportAllDeclaration": enterStatement, - "BreakStatement:exit": leaveStatement, - "ClassDeclaration:exit": leaveStatement, - "ContinueStatement:exit": leaveStatement, - "DebuggerStatement:exit": leaveStatement, - "DoWhileStatement:exit": leaveStatement, - "ExpressionStatement:exit": leaveStatement, - "ForInStatement:exit": leaveStatement, - "ForOfStatement:exit": leaveStatement, - "ForStatement:exit": leaveStatement, - "FunctionDeclaration:exit": leaveStatement, - "IfStatement:exit": leaveStatement, - "ImportDeclaration:exit": leaveStatement, - "LabeledStatement:exit": leaveStatement, - "ReturnStatement:exit": leaveStatement, - "SwitchStatement:exit": leaveStatement, - "ThrowStatement:exit": leaveStatement, - "TryStatement:exit": leaveStatement, - "VariableDeclaration:exit": leaveStatement, - "WhileStatement:exit": leaveStatement, - "WithStatement:exit": leaveStatement, - "ExportNamedDeclaration:exit": leaveStatement, - "ExportDefaultDeclaration:exit": leaveStatement, - "ExportAllDeclaration:exit": leaveStatement, - "Program:exit": reportFirstExtraStatementAndClear - }; - } -}); - -exports.maxStatementsPerLine = maxStatementsPerLine; diff --git a/tools/eslint/node_modules/@stylistic/eslint-plugin-js/dist/multiline-comment-style.js b/tools/eslint/node_modules/@stylistic/eslint-plugin-js/dist/multiline-comment-style.js deleted file mode 100644 index ef6fb04de9063b..00000000000000 --- a/tools/eslint/node_modules/@stylistic/eslint-plugin-js/dist/multiline-comment-style.js +++ /dev/null @@ -1,291 +0,0 @@ -'use strict'; - -var utils = require('./utils.js'); - -var multilineCommentStyle = utils.createRule({ - meta: { - type: "suggestion", - docs: { - description: "Enforce a particular style for multiline comments", - url: "https://eslint.style/rules/js/multiline-comment-style" - }, - fixable: "whitespace", - schema: { - anyOf: [ - { - type: "array", - items: [ - { - enum: ["starred-block", "bare-block"], - type: "string" - } - ], - additionalItems: false - }, - { - type: "array", - items: [ - { - enum: ["separate-lines"], - type: "string" - }, - { - type: "object", - properties: { - checkJSDoc: { - type: "boolean" - } - }, - additionalProperties: false - } - ], - additionalItems: false - } - ] - }, - messages: { - expectedBlock: "Expected a block comment instead of consecutive line comments.", - expectedBareBlock: "Expected a block comment without padding stars.", - startNewline: "Expected a linebreak after '/*'.", - endNewline: "Expected a linebreak before '*/'.", - missingStar: "Expected a '*' at the start of this line.", - alignment: "Expected this line to be aligned with the start of the comment.", - expectedLines: "Expected multiple line comments instead of a block comment." - } - }, - create(context) { - const sourceCode = context.sourceCode; - const option = context.options[0] || "starred-block"; - const params = context.options[1] || {}; - const checkJSDoc = !!params.checkJSDoc; - function isStarredCommentLine(line) { - return /^\s*\*/u.test(line); - } - function isStarredBlockComment([firstComment]) { - if (firstComment.type !== "Block") - return false; - const lines = firstComment.value.split(utils.LINEBREAK_MATCHER); - return lines.length > 0 && lines.every((line, i) => (i === 0 || i === lines.length - 1 ? /^\s*$/u : /^\s*\*/u).test(line)); - } - function isJSDocComment([firstComment]) { - if (firstComment.type !== "Block") - return false; - const lines = firstComment.value.split(utils.LINEBREAK_MATCHER); - return /^\*\s*$/u.test(lines[0]) && lines.slice(1, -1).every((line) => /^\s* /u.test(line)) && /^\s*$/u.test(lines.at(-1)); - } - function processSeparateLineComments(commentGroup) { - const allLinesHaveLeadingSpace = commentGroup.map(({ value }) => value).filter((line) => line.trim().length).every((line) => line.startsWith(" ")); - return commentGroup.map(({ value }) => allLinesHaveLeadingSpace ? value.replace(/^ /u, "") : value); - } - function processStarredBlockComment(comment) { - const lines = comment.value.split(utils.LINEBREAK_MATCHER).filter((line, i, linesArr) => !(i === 0 || i === linesArr.length - 1)).map((line) => line.replace(/^\s*$/u, "")); - const allLinesHaveLeadingSpace = lines.map((line) => line.replace(/\s*\*/u, "")).filter((line) => line.trim().length).every((line) => line.startsWith(" ")); - return lines.map((line) => line.replace(allLinesHaveLeadingSpace ? /\s*\* ?/u : /\s*\*/u, "")); - } - function processBareBlockComment(comment) { - const lines = comment.value.split(utils.LINEBREAK_MATCHER).map((line) => line.replace(/^\s*$/u, "")); - const leadingWhitespace = `${sourceCode.text.slice(comment.range[0] - comment.loc.start.column, comment.range[0])} `; - let offset = ""; - for (const [i, line] of lines.entries()) { - if (!line.trim().length || i === 0) - continue; - const [, lineOffset] = line.match(/^(\s*\*?\s*)/u); - if (lineOffset.length < leadingWhitespace.length) { - const newOffset = leadingWhitespace.slice(lineOffset.length - leadingWhitespace.length); - if (newOffset.length > offset.length) - offset = newOffset; - } - } - return lines.map((line) => { - const match = line.match(/^(\s*\*?\s*)(.*)/u); - const [, lineOffset, lineContents] = match; - if (lineOffset.length > leadingWhitespace.length) - return `${lineOffset.slice(leadingWhitespace.length - (offset.length + lineOffset.length))}${lineContents}`; - if (lineOffset.length < leadingWhitespace.length) - return `${lineOffset.slice(leadingWhitespace.length)}${lineContents}`; - return lineContents; - }); - } - function getCommentLines(commentGroup) { - const [firstComment] = commentGroup; - if (firstComment.type === "Line") - return processSeparateLineComments(commentGroup); - if (isStarredBlockComment(commentGroup)) - return processStarredBlockComment(firstComment); - return processBareBlockComment(firstComment); - } - function getInitialOffset(comment) { - return sourceCode.text.slice(comment.range[0] - comment.loc.start.column, comment.range[0]); - } - function convertToStarredBlock(firstComment, commentLinesList) { - const initialOffset = getInitialOffset(firstComment); - return `/* -${commentLinesList.map((line) => `${initialOffset} * ${line}`).join("\n")} -${initialOffset} */`; - } - function convertToSeparateLines(firstComment, commentLinesList) { - return commentLinesList.map((line) => `// ${line}`).join(` -${getInitialOffset(firstComment)}`); - } - function convertToBlock(firstComment, commentLinesList) { - return `/* ${commentLinesList.join(` -${getInitialOffset(firstComment)} `)} */`; - } - const commentGroupCheckers = { - "starred-block": function(commentGroup) { - const [firstComment] = commentGroup; - const commentLines = getCommentLines(commentGroup); - if (commentLines.some((value) => value.includes("*/"))) - return; - if (commentGroup.length > 1) { - context.report({ - loc: { - start: firstComment.loc.start, - end: commentGroup.at(-1).loc.end - }, - messageId: "expectedBlock", - fix(fixer) { - const range = [firstComment.range[0], commentGroup.at(-1).range[1]]; - return commentLines.some((value) => value.startsWith("/")) ? null : fixer.replaceTextRange(range, convertToStarredBlock(firstComment, commentLines)); - } - }); - } else { - const lines = firstComment.value.split(utils.LINEBREAK_MATCHER); - const expectedLeadingWhitespace = getInitialOffset(firstComment); - const expectedLinePrefix = `${expectedLeadingWhitespace} *`; - if (!/^\*?\s*$/u.test(lines[0])) { - const start = firstComment.value.startsWith("*") ? firstComment.range[0] + 1 : firstComment.range[0]; - context.report({ - loc: { - start: firstComment.loc.start, - end: { line: firstComment.loc.start.line, column: firstComment.loc.start.column + 2 } - }, - messageId: "startNewline", - fix: (fixer) => fixer.insertTextAfterRange([start, start + 2], ` -${expectedLinePrefix}`) - }); - } - if (!/^\s*$/u.test(lines.at(-1))) { - context.report({ - loc: { - start: { line: firstComment.loc.end.line, column: firstComment.loc.end.column - 2 }, - end: firstComment.loc.end - }, - messageId: "endNewline", - fix: (fixer) => fixer.replaceTextRange([firstComment.range[1] - 2, firstComment.range[1]], ` -${expectedLinePrefix}/`) - }); - } - for (let lineNumber = firstComment.loc.start.line + 1; lineNumber <= firstComment.loc.end.line; lineNumber++) { - const lineText = sourceCode.lines[lineNumber - 1]; - const errorType = isStarredCommentLine(lineText) ? "alignment" : "missingStar"; - if (!lineText.startsWith(expectedLinePrefix)) { - context.report({ - loc: { - start: { line: lineNumber, column: 0 }, - end: { line: lineNumber, column: lineText.length } - }, - messageId: errorType, - fix(fixer) { - const lineStartIndex = sourceCode.getIndexFromLoc({ line: lineNumber, column: 0 }); - if (errorType === "alignment") { - const [, commentTextPrefix2 = ""] = lineText.match(/^(\s*\*)/u) || []; - const commentTextStartIndex2 = lineStartIndex + commentTextPrefix2.length; - return fixer.replaceTextRange([lineStartIndex, commentTextStartIndex2], expectedLinePrefix); - } - const [, commentTextPrefix = ""] = lineText.match(/^(\s*)/u) || []; - const commentTextStartIndex = lineStartIndex + commentTextPrefix.length; - let offset; - for (const [idx, line] of lines.entries()) { - if (!/\S+/u.test(line)) - continue; - const lineTextToAlignWith = sourceCode.lines[firstComment.loc.start.line - 1 + idx]; - const [, prefix = "", initialOffset = ""] = lineTextToAlignWith.match(/^(\s*(?:\/?\*)?(\s*))/u) || []; - offset = `${commentTextPrefix.slice(prefix.length)}${initialOffset}`; - if (/^\s*\//u.test(lineText) && offset.length === 0) - offset += " "; - break; - } - return fixer.replaceTextRange([lineStartIndex, commentTextStartIndex], `${expectedLinePrefix}${offset}`); - } - }); - } - } - } - }, - "separate-lines": function(commentGroup) { - const [firstComment] = commentGroup; - const isJSDoc = isJSDocComment(commentGroup); - if (firstComment.type !== "Block" || !checkJSDoc && isJSDoc) - return; - let commentLines = getCommentLines(commentGroup); - if (isJSDoc) - commentLines = commentLines.slice(1, commentLines.length - 1); - const tokenAfter = sourceCode.getTokenAfter(firstComment, { includeComments: true }); - if (tokenAfter && firstComment.loc.end.line === tokenAfter.loc.start.line) - return; - context.report({ - loc: { - start: firstComment.loc.start, - end: { line: firstComment.loc.start.line, column: firstComment.loc.start.column + 2 } - }, - messageId: "expectedLines", - fix(fixer) { - return fixer.replaceText(firstComment, convertToSeparateLines(firstComment, commentLines)); - } - }); - }, - "bare-block": function(commentGroup) { - if (isJSDocComment(commentGroup)) - return; - const [firstComment] = commentGroup; - const commentLines = getCommentLines(commentGroup); - if (firstComment.type === "Line" && commentLines.length > 1 && !commentLines.some((value) => value.includes("*/"))) { - context.report({ - loc: { - start: firstComment.loc.start, - end: commentGroup.at(-1).loc.end - }, - messageId: "expectedBlock", - fix(fixer) { - return fixer.replaceTextRange( - [firstComment.range[0], commentGroup.at(-1).range[1]], - convertToBlock(firstComment, commentLines) - ); - } - }); - } - if (isStarredBlockComment(commentGroup)) { - context.report({ - loc: { - start: firstComment.loc.start, - end: { line: firstComment.loc.start.line, column: firstComment.loc.start.column + 2 } - }, - messageId: "expectedBareBlock", - fix(fixer) { - return fixer.replaceText(firstComment, convertToBlock(firstComment, commentLines)); - } - }); - } - } - }; - return { - Program() { - return sourceCode.getAllComments().filter((comment) => comment.type !== "Shebang").filter((comment) => !utils.COMMENTS_IGNORE_PATTERN.test(comment.value)).filter((comment) => { - const tokenBefore = sourceCode.getTokenBefore(comment, { includeComments: true }); - return !tokenBefore || tokenBefore.loc.end.line < comment.loc.start.line; - }).reduce((commentGroups, comment, index, commentList) => { - const tokenBefore = sourceCode.getTokenBefore(comment, { includeComments: true }); - if (comment.type === "Line" && index && commentList[index - 1].type === "Line" && tokenBefore && tokenBefore.loc.end.line === comment.loc.start.line - 1 && tokenBefore === commentList[index - 1]) { - commentGroups.at(-1).push(comment); - } else { - commentGroups.push([comment]); - } - return commentGroups; - }, []).filter((commentGroup) => !(commentGroup.length === 1 && commentGroup[0].loc.start.line === commentGroup[0].loc.end.line)).forEach(commentGroupCheckers[option]); - } - }; - } -}); - -exports.multilineCommentStyle = multilineCommentStyle; diff --git a/tools/eslint/node_modules/@stylistic/eslint-plugin-js/dist/multiline-ternary.js b/tools/eslint/node_modules/@stylistic/eslint-plugin-js/dist/multiline-ternary.js deleted file mode 100644 index 8ee8c446db5e08..00000000000000 --- a/tools/eslint/node_modules/@stylistic/eslint-plugin-js/dist/multiline-ternary.js +++ /dev/null @@ -1,145 +0,0 @@ -'use strict'; - -var utils = require('./utils.js'); - -var multilineTernary = utils.createRule({ - meta: { - type: "layout", - docs: { - description: "Enforce newlines between operands of ternary expressions", - url: "https://eslint.style/rules/js/multiline-ternary" - }, - schema: [ - { - type: "string", - enum: ["always", "always-multiline", "never"] - }, - { - type: "object", - properties: { - ignoreJSX: { - type: "boolean", - default: false - } - } - } - ], - messages: { - expectedTestCons: "Expected newline between test and consequent of ternary expression.", - expectedConsAlt: "Expected newline between consequent and alternate of ternary expression.", - unexpectedTestCons: "Unexpected newline between test and consequent of ternary expression.", - unexpectedConsAlt: "Unexpected newline between consequent and alternate of ternary expression." - }, - fixable: "whitespace" - }, - create(context) { - const sourceCode = context.sourceCode; - const multiline = context.options[0] !== "never"; - const allowSingleLine = context.options[0] === "always-multiline"; - const IGNORE_JSX = context.options[1] && context.options[1].ignoreJSX; - return { - ConditionalExpression(node) { - const questionToken = sourceCode.getTokenAfter(node.test, utils.isNotClosingParenToken); - const colonToken = sourceCode.getTokenAfter(node.consequent, utils.isNotClosingParenToken); - const firstTokenOfTest = sourceCode.getFirstToken(node); - const lastTokenOfTest = sourceCode.getTokenBefore(questionToken); - const firstTokenOfConsequent = sourceCode.getTokenAfter(questionToken); - const lastTokenOfConsequent = sourceCode.getTokenBefore(colonToken); - const firstTokenOfAlternate = sourceCode.getTokenAfter(colonToken); - const areTestAndConsequentOnSameLine = utils.isTokenOnSameLine(lastTokenOfTest, firstTokenOfConsequent); - const areConsequentAndAlternateOnSameLine = utils.isTokenOnSameLine(lastTokenOfConsequent, firstTokenOfAlternate); - const hasComments = !!sourceCode.getCommentsInside(node).length; - if (IGNORE_JSX) { - if (node.parent.type === "JSXElement" || node.parent.type === "JSXFragment" || node.parent.type === "JSXExpressionContainer") { - return null; - } - } - if (!multiline) { - if (!areTestAndConsequentOnSameLine) { - context.report({ - node: node.test, - loc: { - start: firstTokenOfTest.loc.start, - end: lastTokenOfTest.loc.end - }, - messageId: "unexpectedTestCons", - fix(fixer) { - if (hasComments) - return null; - const fixers = []; - const areTestAndQuestionOnSameLine = utils.isTokenOnSameLine(lastTokenOfTest, questionToken); - const areQuestionAndConsOnSameLine = utils.isTokenOnSameLine(questionToken, firstTokenOfConsequent); - if (!areTestAndQuestionOnSameLine) - fixers.push(fixer.removeRange([lastTokenOfTest.range[1], questionToken.range[0]])); - if (!areQuestionAndConsOnSameLine) - fixers.push(fixer.removeRange([questionToken.range[1], firstTokenOfConsequent.range[0]])); - return fixers; - } - }); - } - if (!areConsequentAndAlternateOnSameLine) { - context.report({ - node: node.consequent, - loc: { - start: firstTokenOfConsequent.loc.start, - end: lastTokenOfConsequent.loc.end - }, - messageId: "unexpectedConsAlt", - fix(fixer) { - if (hasComments) - return null; - const fixers = []; - const areConsAndColonOnSameLine = utils.isTokenOnSameLine(lastTokenOfConsequent, colonToken); - const areColonAndAltOnSameLine = utils.isTokenOnSameLine(colonToken, firstTokenOfAlternate); - if (!areConsAndColonOnSameLine) - fixers.push(fixer.removeRange([lastTokenOfConsequent.range[1], colonToken.range[0]])); - if (!areColonAndAltOnSameLine) - fixers.push(fixer.removeRange([colonToken.range[1], firstTokenOfAlternate.range[0]])); - return fixers; - } - }); - } - } else { - if (allowSingleLine && node.loc.start.line === node.loc.end.line) - return; - if (areTestAndConsequentOnSameLine) { - context.report({ - node: node.test, - loc: { - start: firstTokenOfTest.loc.start, - end: lastTokenOfTest.loc.end - }, - messageId: "expectedTestCons", - fix: (fixer) => hasComments ? null : fixer.replaceTextRange( - [ - lastTokenOfTest.range[1], - questionToken.range[0] - ], - "\n" - ) - }); - } - if (areConsequentAndAlternateOnSameLine) { - context.report({ - node: node.consequent, - loc: { - start: firstTokenOfConsequent.loc.start, - end: lastTokenOfConsequent.loc.end - }, - messageId: "expectedConsAlt", - fix: (fixer) => hasComments ? null : fixer.replaceTextRange( - [ - lastTokenOfConsequent.range[1], - colonToken.range[0] - ], - "\n" - ) - }); - } - } - } - }; - } -}); - -exports.multilineTernary = multilineTernary; diff --git a/tools/eslint/node_modules/@stylistic/eslint-plugin-js/dist/new-parens.js b/tools/eslint/node_modules/@stylistic/eslint-plugin-js/dist/new-parens.js deleted file mode 100644 index 4d9a5e982181f8..00000000000000 --- a/tools/eslint/node_modules/@stylistic/eslint-plugin-js/dist/new-parens.js +++ /dev/null @@ -1,63 +0,0 @@ -'use strict'; - -var utils = require('./utils.js'); - -var newParens = utils.createRule({ - meta: { - type: "layout", - docs: { - description: "Enforce or disallow parentheses when invoking a constructor with no arguments", - url: "https://eslint.style/rules/js/new-parens" - }, - fixable: "code", - schema: [ - { - type: "string", - enum: ["always", "never"] - } - ], - messages: { - missing: "Missing '()' invoking a constructor.", - unnecessary: "Unnecessary '()' invoking a constructor with no arguments." - } - }, - create(context) { - const options = context.options; - const always = options[0] !== "never"; - const sourceCode = context.sourceCode; - return { - NewExpression(node) { - if (node.arguments.length !== 0) - return; - const lastToken = sourceCode.getLastToken(node); - const hasLastParen = lastToken && utils.isClosingParenToken(lastToken); - const tokenBeforeLastToken = sourceCode.getTokenBefore(lastToken); - const hasParens = hasLastParen && utils.isOpeningParenToken(tokenBeforeLastToken) && node.callee.range[1] < node.range[1]; - if (always) { - if (!hasParens) { - context.report({ - node, - messageId: "missing", - fix: (fixer) => fixer.insertTextAfter(node, "()") - }); - } - } else { - if (hasParens) { - context.report({ - node, - messageId: "unnecessary", - fix: (fixer) => [ - fixer.remove(tokenBeforeLastToken), - fixer.remove(lastToken), - fixer.insertTextBefore(node, "("), - fixer.insertTextAfter(node, ")") - ] - }); - } - } - } - }; - } -}); - -exports.newParens = newParens; diff --git a/tools/eslint/node_modules/@stylistic/eslint-plugin-js/dist/newline-per-chained-call.js b/tools/eslint/node_modules/@stylistic/eslint-plugin-js/dist/newline-per-chained-call.js deleted file mode 100644 index def135fff02122..00000000000000 --- a/tools/eslint/node_modules/@stylistic/eslint-plugin-js/dist/newline-per-chained-call.js +++ /dev/null @@ -1,85 +0,0 @@ -'use strict'; - -var utils = require('./utils.js'); - -var newlinePerChainedCall = utils.createRule({ - meta: { - type: "layout", - docs: { - description: "Require a newline after each call in a method chain", - url: "https://eslint.style/rules/js/newline-per-chained-call" - }, - fixable: "whitespace", - schema: [{ - type: "object", - properties: { - ignoreChainWithDepth: { - type: "integer", - minimum: 1, - maximum: 10, - default: 2 - } - }, - additionalProperties: false - }], - messages: { - expected: "Expected line break before `{{callee}}`." - } - }, - create(context) { - const options = context.options[0] || {}; - const ignoreChainWithDepth = options.ignoreChainWithDepth || 2; - const sourceCode = context.sourceCode; - function getPrefix(node) { - if (node.computed) { - if (node.optional) - return "?.["; - return "["; - } - if (node.optional) - return "?."; - return "."; - } - function getPropertyText(node) { - const prefix = getPrefix(node); - const lines = sourceCode.getText(node.property).split(utils.LINEBREAK_MATCHER); - const suffix = node.computed && lines.length === 1 ? "]" : ""; - return prefix + lines[0] + suffix; - } - return { - "CallExpression:exit": function(node) { - const callee = utils.skipChainExpression(node.callee); - if (callee.type !== "MemberExpression") - return; - let parent = utils.skipChainExpression(callee.object); - let depth = 1; - while (parent && "callee" in parent && parent.callee) { - depth += 1; - const parentCallee = utils.skipChainExpression(parent.callee); - if (!("object" in parentCallee)) - break; - parent = utils.skipChainExpression(parentCallee.object); - } - if (depth > ignoreChainWithDepth && utils.isTokenOnSameLine(callee.object, callee.property)) { - const firstTokenAfterObject = sourceCode.getTokenAfter(callee.object, utils.isNotClosingParenToken); - context.report({ - node: callee.property, - loc: { - start: firstTokenAfterObject.loc.start, - end: callee.loc.end - }, - messageId: "expected", - data: { - callee: getPropertyText(callee) - }, - fix(fixer) { - return fixer.insertTextBefore(firstTokenAfterObject, "\n"); - } - }); - } - } - }; - } -}); - -exports.newlinePerChainedCall = newlinePerChainedCall; diff --git a/tools/eslint/node_modules/@stylistic/eslint-plugin-js/dist/no-confusing-arrow.js b/tools/eslint/node_modules/@stylistic/eslint-plugin-js/dist/no-confusing-arrow.js deleted file mode 100644 index ebedd955453563..00000000000000 --- a/tools/eslint/node_modules/@stylistic/eslint-plugin-js/dist/no-confusing-arrow.js +++ /dev/null @@ -1,51 +0,0 @@ -'use strict'; - -var utils = require('./utils.js'); - -function isConditional(node) { - return node.type === "ConditionalExpression"; -} -var noConfusingArrow = utils.createRule({ - meta: { - type: "layout", - docs: { - description: "Disallow arrow functions where they could be confused with comparisons", - url: "https://eslint.style/rules/js/no-confusing-arrow" - }, - fixable: "code", - schema: [{ - type: "object", - properties: { - allowParens: { type: "boolean", default: true }, - onlyOneSimpleParam: { type: "boolean", default: false } - }, - additionalProperties: false - }], - messages: { - confusing: "Arrow function used ambiguously with a conditional expression." - } - }, - create(context) { - const config = context.options[0] || {}; - const allowParens = config.allowParens || config.allowParens === void 0; - const onlyOneSimpleParam = config.onlyOneSimpleParam; - const sourceCode = context.sourceCode; - function checkArrowFunc(node) { - const body = node.body; - if (isConditional(body) && !(allowParens && utils.isParenthesised(sourceCode, body)) && !(onlyOneSimpleParam && !(node.params.length === 1 && node.params[0].type === "Identifier"))) { - context.report({ - node, - messageId: "confusing", - fix(fixer) { - return allowParens ? fixer.replaceText(node.body, `(${sourceCode.getText(node.body)})`) : null; - } - }); - } - } - return { - ArrowFunctionExpression: checkArrowFunc - }; - } -}); - -exports.noConfusingArrow = noConfusingArrow; diff --git a/tools/eslint/node_modules/@stylistic/eslint-plugin-js/dist/no-extra-parens.js b/tools/eslint/node_modules/@stylistic/eslint-plugin-js/dist/no-extra-parens.js deleted file mode 100644 index e84b7dcaf76459..00000000000000 --- a/tools/eslint/node_modules/@stylistic/eslint-plugin-js/dist/no-extra-parens.js +++ /dev/null @@ -1,651 +0,0 @@ -'use strict'; - -var utils = require('./utils.js'); - -var noExtraParens = utils.createRule({ - meta: { - type: "layout", - docs: { - description: "Disallow unnecessary parentheses", - url: "https://eslint.style/rules/js/no-extra-parens" - }, - fixable: "code", - schema: { - anyOf: [ - { - type: "array", - items: [ - { - type: "string", - enum: ["functions"] - } - ], - minItems: 0, - maxItems: 1 - }, - { - type: "array", - items: [ - { - type: "string", - enum: ["all"] - }, - { - type: "object", - properties: { - conditionalAssign: { type: "boolean" }, - ternaryOperandBinaryExpressions: { type: "boolean" }, - nestedBinaryExpressions: { type: "boolean" }, - returnAssign: { type: "boolean" }, - ignoreJSX: { type: "string", enum: ["none", "all", "single-line", "multi-line"] }, - enforceForArrowConditionals: { type: "boolean" }, - enforceForSequenceExpressions: { type: "boolean" }, - enforceForNewInMemberExpressions: { type: "boolean" }, - enforceForFunctionPrototypeMethods: { type: "boolean" }, - allowParensAfterCommentPattern: { type: "string" } - }, - additionalProperties: false - } - ], - minItems: 0, - maxItems: 2 - } - ] - }, - messages: { - unexpected: "Unnecessary parentheses around expression." - } - }, - create(context) { - const sourceCode = context.sourceCode; - const tokensToIgnore = /* @__PURE__ */ new WeakSet(); - const precedence = utils.getPrecedence; - const ALL_NODES = context.options[0] !== "functions"; - const EXCEPT_COND_ASSIGN = ALL_NODES && context.options[1] && context.options[1].conditionalAssign === false; - const EXCEPT_COND_TERNARY = ALL_NODES && context.options[1] && context.options[1].ternaryOperandBinaryExpressions === false; - const NESTED_BINARY = ALL_NODES && context.options[1] && context.options[1].nestedBinaryExpressions === false; - const EXCEPT_RETURN_ASSIGN = ALL_NODES && context.options[1] && context.options[1].returnAssign === false; - const IGNORE_JSX = ALL_NODES && context.options[1] && context.options[1].ignoreJSX; - const IGNORE_ARROW_CONDITIONALS = ALL_NODES && context.options[1] && context.options[1].enforceForArrowConditionals === false; - const IGNORE_SEQUENCE_EXPRESSIONS = ALL_NODES && context.options[1] && context.options[1].enforceForSequenceExpressions === false; - const IGNORE_NEW_IN_MEMBER_EXPR = ALL_NODES && context.options[1] && context.options[1].enforceForNewInMemberExpressions === false; - const IGNORE_FUNCTION_PROTOTYPE_METHODS = ALL_NODES && context.options[1] && context.options[1].enforceForFunctionPrototypeMethods === false; - const ALLOW_PARENS_AFTER_COMMENT_PATTERN = ALL_NODES && context.options[1] && context.options[1].allowParensAfterCommentPattern; - const PRECEDENCE_OF_ASSIGNMENT_EXPR = precedence({ type: "AssignmentExpression" }); - const PRECEDENCE_OF_UPDATE_EXPR = precedence({ type: "UpdateExpression" }); - let reportsBuffer; - function isImmediateFunctionPrototypeMethodCall(node) { - const callNode = utils.skipChainExpression(node); - if (callNode.type !== "CallExpression") - return false; - const callee = utils.skipChainExpression(callNode.callee); - return callee.type === "MemberExpression" && callee.object.type === "FunctionExpression" && ["call", "apply"].includes(utils.getStaticPropertyName(callee)); - } - function ruleApplies(node) { - if (node.type === "JSXElement" || node.type === "JSXFragment") { - const isSingleLine = node.loc.start.line === node.loc.end.line; - switch (IGNORE_JSX) { - case "all": - return false; - case "multi-line": - return isSingleLine; - case "single-line": - return !isSingleLine; - } - } - if (node.type === "SequenceExpression" && IGNORE_SEQUENCE_EXPRESSIONS) - return false; - if (isImmediateFunctionPrototypeMethodCall(node) && IGNORE_FUNCTION_PROTOTYPE_METHODS) - return false; - return ALL_NODES || node.type === "FunctionExpression" || node.type === "ArrowFunctionExpression"; - } - function isParenthesised(node) { - return utils.isParenthesized(1, node, sourceCode); - } - function isParenthesisedTwice(node) { - return utils.isParenthesized(2, node, sourceCode); - } - function hasExcessParens(node) { - return ruleApplies(node) && isParenthesised(node); - } - function hasDoubleExcessParens(node) { - return ruleApplies(node) && isParenthesisedTwice(node); - } - function hasExcessParensWithPrecedence(node, precedenceLowerLimit) { - if (ruleApplies(node) && isParenthesised(node)) { - if (precedence(node) >= precedenceLowerLimit || isParenthesisedTwice(node)) { - return true; - } - } - return false; - } - function isCondAssignException(node) { - return EXCEPT_COND_ASSIGN && node.test && node.test.type === "AssignmentExpression"; - } - function isInReturnStatement(node) { - for (let currentNode = node; currentNode; currentNode = currentNode.parent) { - if (currentNode.type === "ReturnStatement" || currentNode.type === "ArrowFunctionExpression" && currentNode.body.type !== "BlockStatement") { - return true; - } - } - return false; - } - function isNewExpressionWithParens(newExpression) { - const lastToken = sourceCode.getLastToken(newExpression); - const penultimateToken = sourceCode.getTokenBefore(lastToken); - return newExpression.arguments.length > 0 || // The expression should end with its own parens, e.g., new new foo() is not a new expression with parens - utils.isOpeningParenToken(penultimateToken) && utils.isClosingParenToken(lastToken) && newExpression.callee.range[1] < newExpression.range[1]; - } - function containsAssignment(node) { - if (node.type === "AssignmentExpression") - return true; - if (node.type === "ConditionalExpression" && (node.consequent.type === "AssignmentExpression" || node.alternate.type === "AssignmentExpression")) { - return true; - } - if ("left" in node && (node.left && node.left.type === "AssignmentExpression" || node.right && node.right.type === "AssignmentExpression")) { - return true; - } - return false; - } - function isReturnAssignException(node) { - if (!EXCEPT_RETURN_ASSIGN || !isInReturnStatement(node)) - return false; - if (node.type === "ReturnStatement") - return node.argument && containsAssignment(node.argument); - if (node.type === "ArrowFunctionExpression" && node.body.type !== "BlockStatement") - return containsAssignment(node.body); - return containsAssignment(node); - } - function hasExcessParensNoLineTerminator(token, node) { - if (token.loc.end.line === node.loc.start.line) - return hasExcessParens(node); - return hasDoubleExcessParens(node); - } - function requiresLeadingSpace(node) { - const leftParenToken = sourceCode.getTokenBefore(node); - const tokenBeforeLeftParen = sourceCode.getTokenBefore(leftParenToken, { includeComments: true }); - const tokenAfterLeftParen = sourceCode.getTokenAfter(leftParenToken, { includeComments: true }); - return tokenBeforeLeftParen && tokenBeforeLeftParen.range[1] === leftParenToken.range[0] && leftParenToken.range[1] === tokenAfterLeftParen.range[0] && !utils.canTokensBeAdjacent(tokenBeforeLeftParen, tokenAfterLeftParen); - } - function requiresTrailingSpace(node) { - const nextTwoTokens = sourceCode.getTokensAfter(node, { count: 2 }); - const rightParenToken = nextTwoTokens[0]; - const tokenAfterRightParen = nextTwoTokens[1]; - const tokenBeforeRightParen = sourceCode.getLastToken(node); - return rightParenToken && tokenAfterRightParen && !sourceCode.isSpaceBetweenTokens(rightParenToken, tokenAfterRightParen) && !utils.canTokensBeAdjacent(tokenBeforeRightParen, tokenAfterRightParen); - } - function isIIFE(node) { - const maybeCallNode = utils.skipChainExpression(node); - return maybeCallNode.type === "CallExpression" && maybeCallNode.callee.type === "FunctionExpression"; - } - function canBeAssignmentTarget(node) { - return node && (node.type === "Identifier" || node.type === "MemberExpression"); - } - function isFixable(node) { - if (node.type !== "Literal" || typeof node.value !== "string") - return true; - if (isParenthesisedTwice(node)) - return true; - return !utils.isTopLevelExpressionStatement(node.parent); - } - function report(node) { - const leftParenToken = sourceCode.getTokenBefore(node); - const rightParenToken = sourceCode.getTokenAfter(node); - if (!isParenthesisedTwice(node)) { - if (tokensToIgnore.has(sourceCode.getFirstToken(node))) - return; - if (isIIFE(node) && !("callee" in node && isParenthesised(node.callee))) - return; - if (ALLOW_PARENS_AFTER_COMMENT_PATTERN) { - const commentsBeforeLeftParenToken = sourceCode.getCommentsBefore(leftParenToken); - const totalCommentsBeforeLeftParenTokenCount = commentsBeforeLeftParenToken.length; - const ignorePattern = new RegExp(ALLOW_PARENS_AFTER_COMMENT_PATTERN, "u"); - if (totalCommentsBeforeLeftParenTokenCount > 0 && ignorePattern.test(commentsBeforeLeftParenToken[totalCommentsBeforeLeftParenTokenCount - 1].value)) { - return; - } - } - } - function finishReport() { - context.report({ - node, - loc: leftParenToken.loc, - messageId: "unexpected", - fix: isFixable(node) ? (fixer) => { - const parenthesizedSource = sourceCode.text.slice(leftParenToken.range[1], rightParenToken.range[0]); - return fixer.replaceTextRange([ - leftParenToken.range[0], - rightParenToken.range[1] - ], (requiresLeadingSpace(node) ? " " : "") + parenthesizedSource + (requiresTrailingSpace(node) ? " " : "")); - } : null - }); - } - if (reportsBuffer) { - reportsBuffer.reports.push({ node, finishReport }); - return; - } - finishReport(); - } - function checkArgumentWithPrecedence(node) { - if ("argument" in node && node.argument && hasExcessParensWithPrecedence(node.argument, precedence(node))) - report(node.argument); - } - function doesMemberExpressionContainCallExpression(node) { - let currentNode = node.object; - let currentNodeType = node.object.type; - while (currentNodeType === "MemberExpression") { - if (!("object" in currentNode)) - break; - currentNode = currentNode.object; - currentNodeType = currentNode.type; - } - return currentNodeType === "CallExpression"; - } - function checkCallNew(node) { - const callee = node.callee; - if (hasExcessParensWithPrecedence(callee, precedence(node))) { - if (hasDoubleExcessParens(callee) || !(isIIFE(node) || // @ts-expect-error comment above - callee.type === "NewExpression" && !isNewExpressionWithParens(callee) && !(node.type === "NewExpression" && !isNewExpressionWithParens(node)) || node.type === "NewExpression" && callee.type === "MemberExpression" && doesMemberExpressionContainCallExpression(callee) || (!("optional" in node) || !node.optional) && callee.type === "ChainExpression")) { - report(node.callee); - } - } - node.arguments.filter((arg) => hasExcessParensWithPrecedence(arg, PRECEDENCE_OF_ASSIGNMENT_EXPR)).forEach(report); - } - function checkBinaryLogical(node) { - const prec = precedence(node); - const leftPrecedence = precedence(node.left); - const rightPrecedence = precedence(node.right); - const isExponentiation = node.operator === "**"; - const shouldSkipLeft = NESTED_BINARY && (node.left.type === "BinaryExpression" || node.left.type === "LogicalExpression"); - const shouldSkipRight = NESTED_BINARY && (node.right.type === "BinaryExpression" || node.right.type === "LogicalExpression"); - if (!shouldSkipLeft && hasExcessParens(node.left)) { - if (!(["AwaitExpression", "UnaryExpression"].includes(node.left.type) && isExponentiation) && !utils.isMixedLogicalAndCoalesceExpressions(node.left, node) && (leftPrecedence > prec || leftPrecedence === prec && !isExponentiation) || isParenthesisedTwice(node.left)) { - report(node.left); - } - } - if (!shouldSkipRight && hasExcessParens(node.right)) { - if (!utils.isMixedLogicalAndCoalesceExpressions(node.right, node) && (rightPrecedence > prec || rightPrecedence === prec && isExponentiation) || isParenthesisedTwice(node.right)) { - report(node.right); - } - } - } - function checkClass(node) { - if (!node.superClass) - return; - const hasExtraParens = precedence(node.superClass) > PRECEDENCE_OF_UPDATE_EXPR ? hasExcessParens(node.superClass) : hasDoubleExcessParens(node.superClass); - if (hasExtraParens) - report(node.superClass); - } - function checkSpreadOperator(node) { - if (hasExcessParensWithPrecedence(node.argument, PRECEDENCE_OF_ASSIGNMENT_EXPR)) - report(node.argument); - } - function checkExpressionOrExportStatement(node) { - const firstToken = isParenthesised(node) ? sourceCode.getTokenBefore(node) : sourceCode.getFirstToken(node); - const secondToken = sourceCode.getTokenAfter(firstToken, utils.isNotOpeningParenToken); - const thirdToken = secondToken ? sourceCode.getTokenAfter(secondToken) : null; - const tokenAfterClosingParens = secondToken ? sourceCode.getTokenAfter(secondToken, utils.isNotClosingParenToken) : null; - if (utils.isOpeningParenToken(firstToken) && (utils.isOpeningBraceToken(secondToken) || secondToken.type === "Keyword" && (secondToken.value === "function" || secondToken.value === "class" || secondToken.value === "let" && tokenAfterClosingParens && (utils.isOpeningBracketToken(tokenAfterClosingParens) || tokenAfterClosingParens.type === "Identifier")) || secondToken && secondToken.type === "Identifier" && secondToken.value === "async" && thirdToken && thirdToken.type === "Keyword" && thirdToken.value === "function")) { - tokensToIgnore.add(secondToken); - } - const hasExtraParens = node.parent.type === "ExportDefaultDeclaration" ? hasExcessParensWithPrecedence(node, PRECEDENCE_OF_ASSIGNMENT_EXPR) : hasExcessParens(node); - if (hasExtraParens) - report(node); - } - function pathToAncestor(node, ancestor) { - const path = [node]; - let currentNode = node; - while (currentNode !== ancestor) { - currentNode = currentNode.parent; - if (currentNode === null || currentNode === void 0) - throw new Error("Nodes are not in the ancestor-descendant relationship."); - path.push(currentNode); - } - return path; - } - function pathToDescendant(node, descendant) { - return pathToAncestor(descendant, node).reverse(); - } - function isSafelyEnclosingInExpression(node, child) { - switch (node.type) { - case "ArrayExpression": - case "ArrayPattern": - case "BlockStatement": - case "ObjectExpression": - case "ObjectPattern": - case "TemplateLiteral": - return true; - case "ArrowFunctionExpression": - case "FunctionExpression": - return node.params.includes(child); - case "CallExpression": - case "NewExpression": - return node.arguments.includes(child); - case "MemberExpression": - return node.computed && node.property === child; - case "ConditionalExpression": - return node.consequent === child; - default: - return false; - } - } - function startNewReportsBuffering() { - reportsBuffer = { - upper: reportsBuffer, - inExpressionNodes: [], - reports: [] - }; - } - function endCurrentReportsBuffering() { - const { upper, inExpressionNodes, reports } = reportsBuffer ?? {}; - if (upper) { - upper.inExpressionNodes.push(...inExpressionNodes ?? []); - upper.reports.push(...reports ?? []); - } else { - reports?.forEach(({ finishReport }) => finishReport()); - } - reportsBuffer = upper; - } - function isInCurrentReportsBuffer(node) { - return reportsBuffer?.reports.some((r) => r.node === node); - } - function removeFromCurrentReportsBuffer(node) { - if (reportsBuffer) - reportsBuffer.reports = reportsBuffer.reports.filter((r) => r.node !== node); - } - function isMemberExpInNewCallee(node) { - if (node.type === "MemberExpression") { - return node.parent.type === "NewExpression" && node.parent.callee === node ? true : "object" in node.parent && node.parent.object === node && isMemberExpInNewCallee(node.parent); - } - return false; - } - function isAnonymousFunctionAssignmentException({ left, operator, right }) { - if (left.type === "Identifier" && ["=", "&&=", "||=", "??="].includes(operator)) { - const rhsType = right.type; - if (rhsType === "ArrowFunctionExpression") - return true; - if ((rhsType === "FunctionExpression" || rhsType === "ClassExpression") && !right.id) - return true; - } - return false; - } - return { - ArrayExpression(node) { - node.elements.filter((e) => !!e && hasExcessParensWithPrecedence(e, PRECEDENCE_OF_ASSIGNMENT_EXPR)).forEach(report); - }, - ArrayPattern(node) { - node.elements.filter((e) => e && canBeAssignmentTarget(e) && hasExcessParens(e)).forEach(report); - }, - ArrowFunctionExpression(node) { - if (isReturnAssignException(node)) - return; - if (node.body.type === "ConditionalExpression" && IGNORE_ARROW_CONDITIONALS) { - return; - } - if (node.body.type !== "BlockStatement") { - const firstBodyToken = sourceCode.getFirstToken(node.body, utils.isNotOpeningParenToken); - const tokenBeforeFirst = sourceCode.getTokenBefore(firstBodyToken); - if (utils.isOpeningParenToken(tokenBeforeFirst) && utils.isOpeningBraceToken(firstBodyToken)) - tokensToIgnore.add(firstBodyToken); - if (hasExcessParensWithPrecedence(node.body, PRECEDENCE_OF_ASSIGNMENT_EXPR)) - report(node.body); - } - }, - AssignmentExpression(node) { - if (canBeAssignmentTarget(node.left) && hasExcessParens(node.left) && (!isAnonymousFunctionAssignmentException(node) || isParenthesisedTwice(node.left))) { - report(node.left); - } - if (!isReturnAssignException(node) && hasExcessParensWithPrecedence(node.right, precedence(node))) - report(node.right); - }, - BinaryExpression(node) { - if (reportsBuffer && node.operator === "in") - reportsBuffer.inExpressionNodes.push(node); - checkBinaryLogical(node); - }, - "CallExpression": checkCallNew, - ConditionalExpression(node) { - if (isReturnAssignException(node)) - return; - const availableTypes = /* @__PURE__ */ new Set(["BinaryExpression", "LogicalExpression"]); - if (!(EXCEPT_COND_TERNARY && availableTypes.has(node.test.type)) && !isCondAssignException(node) && hasExcessParensWithPrecedence(node.test, precedence({ type: "LogicalExpression", operator: "||" }))) { - report(node.test); - } - if (!(EXCEPT_COND_TERNARY && availableTypes.has(node.consequent.type)) && hasExcessParensWithPrecedence(node.consequent, PRECEDENCE_OF_ASSIGNMENT_EXPR)) { - report(node.consequent); - } - if (!(EXCEPT_COND_TERNARY && availableTypes.has(node.alternate.type)) && hasExcessParensWithPrecedence(node.alternate, PRECEDENCE_OF_ASSIGNMENT_EXPR)) { - report(node.alternate); - } - }, - DoWhileStatement(node) { - if (hasExcessParens(node.test) && !isCondAssignException(node)) - report(node.test); - }, - "ExportDefaultDeclaration": (node) => checkExpressionOrExportStatement(node.declaration), - "ExpressionStatement": (node) => checkExpressionOrExportStatement(node.expression), - ForInStatement(node) { - if (node.left.type !== "VariableDeclaration") { - const firstLeftToken = sourceCode.getFirstToken(node.left, utils.isNotOpeningParenToken); - if (firstLeftToken.value === "let" && utils.isOpeningBracketToken( - sourceCode.getTokenAfter(firstLeftToken, utils.isNotClosingParenToken) - )) { - tokensToIgnore.add(firstLeftToken); - } - } - if (hasExcessParens(node.left)) - report(node.left); - if (hasExcessParens(node.right)) - report(node.right); - }, - ForOfStatement(node) { - if (node.left.type !== "VariableDeclaration") { - const firstLeftToken = sourceCode.getFirstToken(node.left, utils.isNotOpeningParenToken); - if (firstLeftToken.value === "let") { - tokensToIgnore.add(firstLeftToken); - } - } - if (hasExcessParens(node.left)) - report(node.left); - if (hasExcessParensWithPrecedence(node.right, PRECEDENCE_OF_ASSIGNMENT_EXPR)) - report(node.right); - }, - ForStatement(node) { - if (node.test && hasExcessParens(node.test) && !isCondAssignException(node)) - report(node.test); - if (node.update && hasExcessParens(node.update)) - report(node.update); - if (node.init) { - if (node.init.type !== "VariableDeclaration") { - const firstToken = sourceCode.getFirstToken(node.init, utils.isNotOpeningParenToken); - if (firstToken.value === "let" && utils.isOpeningBracketToken( - sourceCode.getTokenAfter(firstToken, utils.isNotClosingParenToken) - )) { - tokensToIgnore.add(firstToken); - } - } - startNewReportsBuffering(); - if (hasExcessParens(node.init)) - report(node.init); - } - }, - "ForStatement > *.init:exit": function(node) { - if (reportsBuffer?.reports.length) { - reportsBuffer.inExpressionNodes.forEach((inExpressionNode) => { - const path = pathToDescendant(node, inExpressionNode); - let nodeToExclude = null; - for (let i = 0; i < path.length; i++) { - const pathNode = path[i]; - if (i < path.length - 1) { - const nextPathNode = path[i + 1]; - if (isSafelyEnclosingInExpression(pathNode, nextPathNode)) { - return; - } - } - if (isParenthesised(pathNode)) { - if (isInCurrentReportsBuffer(pathNode)) { - if (isParenthesisedTwice(pathNode)) { - return; - } - if (!nodeToExclude) - nodeToExclude = pathNode; - } else { - return; - } - } - } - if (nodeToExclude) - removeFromCurrentReportsBuffer(nodeToExclude); - }); - } - endCurrentReportsBuffering(); - }, - IfStatement(node) { - if (hasExcessParens(node.test) && !isCondAssignException(node)) - report(node.test); - }, - ImportExpression(node) { - const { source } = node; - if (source.type === "SequenceExpression") { - if (hasDoubleExcessParens(source)) - report(source); - } else if (hasExcessParens(source)) { - report(source); - } - }, - "LogicalExpression": checkBinaryLogical, - MemberExpression(node) { - const shouldAllowWrapOnce = isMemberExpInNewCallee(node) && doesMemberExpressionContainCallExpression(node); - const nodeObjHasExcessParens = shouldAllowWrapOnce ? hasDoubleExcessParens(node.object) : hasExcessParens(node.object) && !(isImmediateFunctionPrototypeMethodCall(node.parent) && "callee" in node.parent && node.parent.callee === node && IGNORE_FUNCTION_PROTOTYPE_METHODS); - if (nodeObjHasExcessParens && precedence(node.object) >= precedence(node) && (node.computed || !(utils.isDecimalInteger(node.object) || node.object.type === "Literal" && "regex" in node.object && node.object.regex))) { - report(node.object); - } - if (nodeObjHasExcessParens && node.object.type === "CallExpression") { - report(node.object); - } - if (nodeObjHasExcessParens && !IGNORE_NEW_IN_MEMBER_EXPR && node.object.type === "NewExpression" && isNewExpressionWithParens(node.object)) { - report(node.object); - } - if (nodeObjHasExcessParens && node.optional && node.object.type === "ChainExpression") { - report(node.object); - } - if (node.computed && hasExcessParens(node.property)) - report(node.property); - }, - "MethodDefinition[computed=true]": function(node) { - if (hasExcessParensWithPrecedence(node.key, PRECEDENCE_OF_ASSIGNMENT_EXPR)) - report(node.key); - }, - "NewExpression": checkCallNew, - ObjectExpression(node) { - node.properties.filter((property) => property.type === "Property" && property.value && hasExcessParensWithPrecedence(property.value, PRECEDENCE_OF_ASSIGNMENT_EXPR)).forEach((property) => report(property.value)); - }, - ObjectPattern(node) { - node.properties.filter((property) => { - const value = property.value; - return value && canBeAssignmentTarget(value) && hasExcessParens(value); - }).forEach((property) => report(property.value)); - }, - Property(node) { - if (node.computed) { - const { key } = node; - if (key && hasExcessParensWithPrecedence(key, PRECEDENCE_OF_ASSIGNMENT_EXPR)) - report(key); - } - }, - PropertyDefinition(node) { - if (node.computed && hasExcessParensWithPrecedence(node.key, PRECEDENCE_OF_ASSIGNMENT_EXPR)) - report(node.key); - if (node.value && hasExcessParensWithPrecedence(node.value, PRECEDENCE_OF_ASSIGNMENT_EXPR)) - report(node.value); - }, - RestElement(node) { - const argument = node.argument; - if (canBeAssignmentTarget(argument) && hasExcessParens(argument)) - report(argument); - }, - ReturnStatement(node) { - const returnToken = sourceCode.getFirstToken(node); - if (isReturnAssignException(node)) - return; - if (node.argument && returnToken && hasExcessParensNoLineTerminator(returnToken, node.argument) && !(node.argument.type === "Literal" && "regex" in node.argument && node.argument.regex)) { - report(node.argument); - } - }, - SequenceExpression(node) { - const precedenceOfNode = precedence(node); - node.expressions.filter((e) => hasExcessParensWithPrecedence(e, precedenceOfNode)).forEach(report); - }, - SwitchCase(node) { - if (node.test && hasExcessParens(node.test)) - report(node.test); - }, - SwitchStatement(node) { - if (hasExcessParens(node.discriminant)) - report(node.discriminant); - }, - ThrowStatement(node) { - const throwToken = sourceCode.getFirstToken(node); - if (throwToken && node.argument && hasExcessParensNoLineTerminator(throwToken, node.argument)) - report(node.argument); - }, - "UnaryExpression": checkArgumentWithPrecedence, - UpdateExpression(node) { - if (node.prefix) { - checkArgumentWithPrecedence(node); - } else { - const { argument } = node; - const operatorToken = sourceCode.getLastToken(node); - if (argument.loc.end.line === operatorToken.loc.start.line) { - checkArgumentWithPrecedence(node); - } else { - if (hasDoubleExcessParens(argument)) - report(argument); - } - } - }, - "AwaitExpression": checkArgumentWithPrecedence, - VariableDeclarator(node) { - if (node.init && hasExcessParensWithPrecedence(node.init, PRECEDENCE_OF_ASSIGNMENT_EXPR) && !(node.init.type === "Literal" && "regex" in node.init && node.init.regex)) { - report(node.init); - } - }, - WhileStatement(node) { - if (hasExcessParens(node.test) && !isCondAssignException(node)) - report(node.test); - }, - WithStatement(node) { - if (hasExcessParens(node.object)) - report(node.object); - }, - YieldExpression(node) { - if (node.argument) { - const yieldToken = sourceCode.getFirstToken(node); - if (precedence(node.argument) >= precedence(node) && yieldToken && hasExcessParensNoLineTerminator(yieldToken, node.argument) || hasDoubleExcessParens(node.argument)) { - report(node.argument); - } - } - }, - "ClassDeclaration": checkClass, - "ClassExpression": checkClass, - "SpreadElement": checkSpreadOperator, - "SpreadProperty": checkSpreadOperator, - TemplateLiteral(node) { - node.expressions.filter((e) => e && hasExcessParens(e)).forEach(report); - }, - AssignmentPattern(node) { - const { left, right } = node; - if (canBeAssignmentTarget(left) && hasExcessParens(left)) - report(left); - if (right && hasExcessParensWithPrecedence(right, PRECEDENCE_OF_ASSIGNMENT_EXPR)) - report(right); - }, - // This listener is exposed for TypeScript rule to consume - TSStringKeyword(node) { - if (hasExcessParens(node)) - report(node); - } - }; - } -}); - -exports.noExtraParens = noExtraParens; diff --git a/tools/eslint/node_modules/@stylistic/eslint-plugin-js/dist/no-extra-semi.js b/tools/eslint/node_modules/@stylistic/eslint-plugin-js/dist/no-extra-semi.js deleted file mode 100644 index 6bfe2c2dd2ca41..00000000000000 --- a/tools/eslint/node_modules/@stylistic/eslint-plugin-js/dist/no-extra-semi.js +++ /dev/null @@ -1,78 +0,0 @@ -'use strict'; - -var utils = require('./utils.js'); - -var noExtraSemi = utils.createRule({ - meta: { - type: "layout", - docs: { - description: "Disallow unnecessary semicolons", - url: "https://eslint.style/rules/js/no-extra-semi" - }, - fixable: "code", - schema: [], - messages: { - unexpected: "Unnecessary semicolon." - } - }, - create(context) { - const sourceCode = context.sourceCode; - function isFixable(nodeOrToken) { - const nextToken = sourceCode.getTokenAfter(nodeOrToken); - if (!nextToken || nextToken.type !== "String") - return true; - const stringNode = sourceCode.getNodeByRangeIndex(nextToken.range[0]); - return !utils.isTopLevelExpressionStatement(stringNode.parent); - } - function report(nodeOrToken) { - context.report({ - node: nodeOrToken, - messageId: "unexpected", - fix: isFixable(nodeOrToken) ? (fixer) => new utils.FixTracker(fixer, context.sourceCode).retainSurroundingTokens(nodeOrToken).remove(nodeOrToken) : null - }); - } - function checkForPartOfClassBody(firstToken) { - for (let token = firstToken; token.type === "Punctuator" && !utils.isClosingBraceToken(token); token = sourceCode.getTokenAfter(token)) { - if (utils.isSemicolonToken(token)) - report(token); - } - } - return { - /** - * Reports this empty statement, except if the parent node is a loop. - * @param node A EmptyStatement node to be reported. - */ - EmptyStatement(node) { - const parent = node.parent; - const allowedParentTypes = [ - "ForStatement", - "ForInStatement", - "ForOfStatement", - "WhileStatement", - "DoWhileStatement", - "IfStatement", - "LabeledStatement", - "WithStatement" - ]; - if (!allowedParentTypes.includes(parent.type)) - report(node); - }, - /** - * Checks tokens from the head of this class body to the first MethodDefinition or the end of this class body. - * @param node A ClassBody node to check. - */ - ClassBody(node) { - checkForPartOfClassBody(sourceCode.getFirstToken(node, 1)); - }, - /** - * Checks tokens from this MethodDefinition to the next MethodDefinition or the end of this class body. - * @param node A MethodDefinition node of the start point. - */ - "MethodDefinition, PropertyDefinition, StaticBlock": function(node) { - checkForPartOfClassBody(sourceCode.getTokenAfter(node)); - } - }; - } -}); - -exports.noExtraSemi = noExtraSemi; diff --git a/tools/eslint/node_modules/@stylistic/eslint-plugin-js/dist/no-floating-decimal.js b/tools/eslint/node_modules/@stylistic/eslint-plugin-js/dist/no-floating-decimal.js deleted file mode 100644 index 8fd5e9fc12331a..00000000000000 --- a/tools/eslint/node_modules/@stylistic/eslint-plugin-js/dist/no-floating-decimal.js +++ /dev/null @@ -1,48 +0,0 @@ -'use strict'; - -var utils = require('./utils.js'); - -var noFloatingDecimal = utils.createRule({ - meta: { - type: "layout", - docs: { - description: "Disallow leading or trailing decimal points in numeric literals", - url: "https://eslint.style/rules/js/no-floating-decimal" - }, - schema: [], - fixable: "code", - messages: { - leading: "A leading decimal point can be confused with a dot.", - trailing: "A trailing decimal point can be confused with a dot." - } - }, - create(context) { - const sourceCode = context.sourceCode; - return { - Literal(node) { - if (typeof node.value === "number") { - if (node.raw.startsWith(".")) { - context.report({ - node, - messageId: "leading", - fix(fixer) { - const tokenBefore = sourceCode.getTokenBefore(node); - const needsSpaceBefore = tokenBefore && tokenBefore.range[1] === node.range[0] && !utils.canTokensBeAdjacent(tokenBefore, `0${node.raw}`); - return fixer.insertTextBefore(node, needsSpaceBefore ? " 0" : "0"); - } - }); - } - if (node.raw.indexOf(".") === node.raw.length - 1) { - context.report({ - node, - messageId: "trailing", - fix: (fixer) => fixer.insertTextAfter(node, "0") - }); - } - } - } - }; - } -}); - -exports.noFloatingDecimal = noFloatingDecimal; diff --git a/tools/eslint/node_modules/@stylistic/eslint-plugin-js/dist/no-mixed-operators.js b/tools/eslint/node_modules/@stylistic/eslint-plugin-js/dist/no-mixed-operators.js deleted file mode 100644 index 1147596511979e..00000000000000 --- a/tools/eslint/node_modules/@stylistic/eslint-plugin-js/dist/no-mixed-operators.js +++ /dev/null @@ -1,131 +0,0 @@ -'use strict'; - -var utils = require('./utils.js'); - -const ARITHMETIC_OPERATORS = ["+", "-", "*", "/", "%", "**"]; -const BITWISE_OPERATORS = ["&", "|", "^", "~", "<<", ">>", ">>>"]; -const COMPARISON_OPERATORS = ["==", "!=", "===", "!==", ">", ">=", "<", "<="]; -const LOGICAL_OPERATORS = ["&&", "||"]; -const RELATIONAL_OPERATORS = ["in", "instanceof"]; -const TERNARY_OPERATOR = ["?:"]; -const COALESCE_OPERATOR = ["??"]; -const ALL_OPERATORS = [].concat( - ARITHMETIC_OPERATORS, - BITWISE_OPERATORS, - COMPARISON_OPERATORS, - LOGICAL_OPERATORS, - RELATIONAL_OPERATORS, - TERNARY_OPERATOR, - COALESCE_OPERATOR -); -const DEFAULT_GROUPS = [ - ARITHMETIC_OPERATORS, - BITWISE_OPERATORS, - COMPARISON_OPERATORS, - LOGICAL_OPERATORS, - RELATIONAL_OPERATORS -]; -const TARGET_NODE_TYPE = /^(?:Binary|Logical|Conditional)Expression$/u; -function normalizeOptions(options = {}) { - const hasGroups = options.groups && options.groups.length > 0; - const groups = hasGroups ? options.groups : DEFAULT_GROUPS; - const allowSamePrecedence = options.allowSamePrecedence !== false; - return { - groups, - allowSamePrecedence - }; -} -function includesBothInAGroup(groups, left, right) { - return groups.some((group) => group.includes(left) && group.includes(right)); -} -function getChildNode(node) { - return node.type === "ConditionalExpression" ? node.test : node.left; -} -var noMixedOperators = utils.createRule({ - meta: { - type: "layout", - docs: { - description: "Disallow mixed binary operators", - url: "https://eslint.style/rules/js/no-mixed-operators" - }, - schema: [ - { - type: "object", - properties: { - groups: { - type: "array", - items: { - type: "array", - items: { - type: "string", - enum: ALL_OPERATORS - }, - minItems: 2, - uniqueItems: true - }, - uniqueItems: true - }, - allowSamePrecedence: { - type: "boolean", - default: true - } - }, - additionalProperties: false - } - ], - messages: { - unexpectedMixedOperator: "Unexpected mix of '{{leftOperator}}' and '{{rightOperator}}'. Use parentheses to clarify the intended order of operations." - } - }, - create(context) { - const sourceCode = context.sourceCode; - const options = normalizeOptions(context.options[0]); - function shouldIgnore(node) { - const a = node; - const b = node.parent; - return !includesBothInAGroup( - options.groups ?? [], - a.operator, - b.type === "ConditionalExpression" ? "?:" : b.operator - ) || options.allowSamePrecedence && utils.getPrecedence(a) === utils.getPrecedence(b); - } - function isMixedWithParent(node) { - return node.operator !== node.parent.operator && !utils.isParenthesised(sourceCode, node); - } - function getOperatorToken(node) { - return sourceCode.getTokenAfter(getChildNode(node), utils.isNotClosingParenToken); - } - function reportBothOperators(node) { - const parent = node.parent; - const left = getChildNode(parent) === node ? node : parent; - const right = getChildNode(parent) !== node ? node : parent; - const data = { - leftOperator: left.operator || "?:", - rightOperator: right.operator || "?:" - }; - context.report({ - node: left, - loc: getOperatorToken(left).loc, - messageId: "unexpectedMixedOperator", - data - }); - context.report({ - node: right, - loc: getOperatorToken(right).loc, - messageId: "unexpectedMixedOperator", - data - }); - } - function check(node) { - if (TARGET_NODE_TYPE.test(node.parent.type) && isMixedWithParent(node) && !shouldIgnore(node)) { - reportBothOperators(node); - } - } - return { - BinaryExpression: check, - LogicalExpression: check - }; - } -}); - -exports.noMixedOperators = noMixedOperators; diff --git a/tools/eslint/node_modules/@stylistic/eslint-plugin-js/dist/no-mixed-spaces-and-tabs.js b/tools/eslint/node_modules/@stylistic/eslint-plugin-js/dist/no-mixed-spaces-and-tabs.js deleted file mode 100644 index d4b53a242736d2..00000000000000 --- a/tools/eslint/node_modules/@stylistic/eslint-plugin-js/dist/no-mixed-spaces-and-tabs.js +++ /dev/null @@ -1,84 +0,0 @@ -'use strict'; - -var utils = require('./utils.js'); - -var noMixedSpacesAndTabs = utils.createRule({ - meta: { - type: "layout", - docs: { - description: "Disallow mixed spaces and tabs for indentation", - url: "https://eslint.style/rules/js/no-mixed-spaces-and-tabs" - }, - schema: [ - { - oneOf: [ - { - type: "string", - enum: ["smart-tabs"] - }, - { - type: "boolean" - } - ] - } - ], - messages: { - mixedSpacesAndTabs: "Mixed spaces and tabs." - } - }, - create(context) { - const sourceCode = context.sourceCode; - let smartTabs; - switch (context.options[0]) { - case true: - case "smart-tabs": - smartTabs = true; - break; - default: - smartTabs = false; - } - return { - "Program:exit": function(node) { - const lines = sourceCode.lines; - const comments = sourceCode.getAllComments(); - const ignoredCommentLines = /* @__PURE__ */ new Set(); - comments.forEach((comment) => { - for (let i = comment.loc.start.line + 1; i <= comment.loc.end.line; i++) - ignoredCommentLines.add(i); - }); - let regex = /^(?=( +|\t+))\1(?:\t| )/u; - if (smartTabs) { - regex = /^(?=(\t*))\1(?=( +))\2\t/u; - } - lines.forEach((line, i) => { - const match = regex.exec(line); - if (match) { - const lineNumber = i + 1; - const loc = { - start: { - line: lineNumber, - column: match[0].length - 2 - }, - end: { - line: lineNumber, - column: match[0].length - } - }; - if (!ignoredCommentLines.has(lineNumber)) { - const containingNode = sourceCode.getNodeByRangeIndex(sourceCode.getIndexFromLoc(loc.start)); - if (!(containingNode && ["Literal", "TemplateElement"].includes(containingNode.type))) { - context.report({ - node, - loc, - messageId: "mixedSpacesAndTabs" - }); - } - } - } - }); - } - }; - } -}); - -exports.noMixedSpacesAndTabs = noMixedSpacesAndTabs; diff --git a/tools/eslint/node_modules/@stylistic/eslint-plugin-js/dist/no-multi-spaces.js b/tools/eslint/node_modules/@stylistic/eslint-plugin-js/dist/no-multi-spaces.js deleted file mode 100644 index 5b9fa14dade63b..00000000000000 --- a/tools/eslint/node_modules/@stylistic/eslint-plugin-js/dist/no-multi-spaces.js +++ /dev/null @@ -1,92 +0,0 @@ -'use strict'; - -var utils = require('./utils.js'); - -var noMultiSpaces = utils.createRule({ - meta: { - type: "layout", - docs: { - description: "Disallow multiple spaces", - url: "https://eslint.style/rules/js/no-multi-spaces" - }, - fixable: "whitespace", - schema: [ - { - type: "object", - properties: { - exceptions: { - type: "object", - patternProperties: { - "^([A-Z][a-z]*)+$": { - type: "boolean" - } - }, - additionalProperties: false - }, - ignoreEOLComments: { - type: "boolean", - default: false - }, - includeTabs: { - type: "boolean", - default: true - } - }, - additionalProperties: false - } - ], - messages: { - multipleSpaces: "Multiple spaces found before '{{displayValue}}'." - } - }, - create(context) { - const sourceCode = context.sourceCode; - const options = context.options[0] || {}; - const ignoreEOLComments = options.ignoreEOLComments; - const exceptions = Object.assign({ Property: true }, options.exceptions); - const hasExceptions = Object.keys(exceptions).some((key) => exceptions[key]); - const spacesRe = options.includeTabs === false ? / {2}/ : /[ \t]{2}/; - function formatReportedCommentValue(token) { - const valueLines = token.value.split("\n"); - const value = valueLines[0]; - const formattedValue = `${value.slice(0, 12)}...`; - return valueLines.length === 1 && value.length <= 12 ? value : formattedValue; - } - return { - Program() { - sourceCode.tokensAndComments.forEach((leftToken, leftIndex, tokensAndComments) => { - if (leftIndex === tokensAndComments.length - 1) - return; - const rightToken = tokensAndComments[leftIndex + 1]; - if (!spacesRe.test(sourceCode.text.slice(leftToken.range[1], rightToken.range[0])) || leftToken.loc.end.line < rightToken.loc.start.line) { - return; - } - if (ignoreEOLComments && utils.isCommentToken(rightToken) && (leftIndex === tokensAndComments.length - 2 || rightToken.loc.end.line < tokensAndComments[leftIndex + 2].loc.start.line)) { - return; - } - if (hasExceptions) { - const parentNode = sourceCode.getNodeByRangeIndex(rightToken.range[0] - 1); - if (parentNode && exceptions[parentNode.type]) - return; - } - let displayValue; - if (rightToken.type === "Block") - displayValue = `/*${formatReportedCommentValue(rightToken)}*/`; - else if (rightToken.type === "Line") - displayValue = `//${formatReportedCommentValue(rightToken)}`; - else - displayValue = rightToken.value; - context.report({ - node: rightToken, - loc: { start: leftToken.loc.end, end: rightToken.loc.start }, - messageId: "multipleSpaces", - data: { displayValue }, - fix: (fixer) => fixer.replaceTextRange([leftToken.range[1], rightToken.range[0]], " ") - }); - }); - } - }; - } -}); - -exports.noMultiSpaces = noMultiSpaces; diff --git a/tools/eslint/node_modules/@stylistic/eslint-plugin-js/dist/no-multiple-empty-lines.js b/tools/eslint/node_modules/@stylistic/eslint-plugin-js/dist/no-multiple-empty-lines.js deleted file mode 100644 index 943f38f3fc7c95..00000000000000 --- a/tools/eslint/node_modules/@stylistic/eslint-plugin-js/dist/no-multiple-empty-lines.js +++ /dev/null @@ -1,103 +0,0 @@ -'use strict'; - -var utils = require('./utils.js'); - -var noMultipleEmptyLines = utils.createRule({ - meta: { - type: "layout", - docs: { - description: "Disallow multiple empty lines", - url: "https://eslint.style/rules/js/no-multiple-empty-lines" - }, - fixable: "whitespace", - schema: [ - { - type: "object", - properties: { - max: { - type: "integer", - minimum: 0 - }, - maxEOF: { - type: "integer", - minimum: 0 - }, - maxBOF: { - type: "integer", - minimum: 0 - } - }, - required: ["max"], - additionalProperties: false - } - ], - messages: { - blankBeginningOfFile: "Too many blank lines at the beginning of file. Max of {{max}} allowed.", - blankEndOfFile: "Too many blank lines at the end of file. Max of {{max}} allowed.", - consecutiveBlank: "More than {{max}} blank {{pluralizedLines}} not allowed." - } - }, - create(context) { - let max = 2; - let maxEOF = max; - let maxBOF = max; - if (context.options.length && context.options[0]) { - max = context.options[0].max; - maxEOF = typeof context.options[0].maxEOF !== "undefined" ? context.options[0].maxEOF : max; - maxBOF = typeof context.options[0].maxBOF !== "undefined" ? context.options[0].maxBOF : max; - } - const sourceCode = context.sourceCode; - const allLines = sourceCode.lines[sourceCode.lines.length - 1] === "" ? sourceCode.lines.slice(0, -1) : sourceCode.lines; - const templateLiteralLines = /* @__PURE__ */ new Set(); - return { - TemplateLiteral(node) { - node.quasis.forEach((literalPart) => { - for (let ignoredLine = literalPart.loc.start.line; ignoredLine < literalPart.loc.end.line; ignoredLine++) - templateLiteralLines.add(ignoredLine); - }); - }, - "Program:exit": function(node) { - return allLines.reduce((nonEmptyLineNumbers, line, index) => { - if (line.trim() || templateLiteralLines.has(index + 1)) - nonEmptyLineNumbers.push(index + 1); - return nonEmptyLineNumbers; - }, []).concat(allLines.length + 1).reduce((lastLineNumber, lineNumber) => { - let messageId, maxAllowed; - if (lastLineNumber === 0) { - messageId = "blankBeginningOfFile"; - maxAllowed = maxBOF; - } else if (lineNumber === allLines.length + 1) { - messageId = "blankEndOfFile"; - maxAllowed = maxEOF; - } else { - messageId = "consecutiveBlank"; - maxAllowed = max; - } - if (lineNumber - lastLineNumber - 1 > maxAllowed) { - context.report({ - node, - loc: { - start: { line: lastLineNumber + maxAllowed + 1, column: 0 }, - end: { line: lineNumber, column: 0 } - }, - messageId, - data: { - max: maxAllowed, - pluralizedLines: maxAllowed === 1 ? "line" : "lines" - }, - fix(fixer) { - const rangeStart = sourceCode.getIndexFromLoc({ line: lastLineNumber + 1, column: 0 }); - const lineNumberAfterRemovedLines = lineNumber - maxAllowed; - const rangeEnd = lineNumberAfterRemovedLines <= allLines.length ? sourceCode.getIndexFromLoc({ line: lineNumberAfterRemovedLines, column: 0 }) : sourceCode.text.length; - return fixer.removeRange([rangeStart, rangeEnd]); - } - }); - } - return lineNumber; - }, 0); - } - }; - } -}); - -exports.noMultipleEmptyLines = noMultipleEmptyLines; diff --git a/tools/eslint/node_modules/@stylistic/eslint-plugin-js/dist/no-tabs.js b/tools/eslint/node_modules/@stylistic/eslint-plugin-js/dist/no-tabs.js deleted file mode 100644 index d8520738527002..00000000000000 --- a/tools/eslint/node_modules/@stylistic/eslint-plugin-js/dist/no-tabs.js +++ /dev/null @@ -1,59 +0,0 @@ -'use strict'; - -var utils = require('./utils.js'); - -const tabRegex = /\t+/gu; -const anyNonWhitespaceRegex = /\S/u; -var noTabs = utils.createRule({ - meta: { - type: "layout", - docs: { - description: "Disallow all tabs", - url: "https://eslint.style/rules/js/no-tabs" - }, - schema: [{ - type: "object", - properties: { - allowIndentationTabs: { - type: "boolean", - default: false - } - }, - additionalProperties: false - }], - messages: { - unexpectedTab: "Unexpected tab character." - } - }, - create(context) { - const sourceCode = context.sourceCode; - const allowIndentationTabs = context.options && context.options[0] && context.options[0].allowIndentationTabs; - return { - Program(node) { - sourceCode.getLines().forEach((line, index) => { - let match; - while ((match = tabRegex.exec(line)) !== null) { - if (allowIndentationTabs && !anyNonWhitespaceRegex.test(line.slice(0, match.index))) - continue; - context.report({ - node, - loc: { - start: { - line: index + 1, - column: match.index - }, - end: { - line: index + 1, - column: match.index + match[0].length - } - }, - messageId: "unexpectedTab" - }); - } - }); - } - }; - } -}); - -exports.noTabs = noTabs; diff --git a/tools/eslint/node_modules/@stylistic/eslint-plugin-js/dist/no-trailing-spaces.js b/tools/eslint/node_modules/@stylistic/eslint-plugin-js/dist/no-trailing-spaces.js deleted file mode 100644 index f5377f0048fd88..00000000000000 --- a/tools/eslint/node_modules/@stylistic/eslint-plugin-js/dist/no-trailing-spaces.js +++ /dev/null @@ -1,107 +0,0 @@ -'use strict'; - -var utils = require('./utils.js'); - -var noTrailingSpaces = utils.createRule({ - meta: { - type: "layout", - docs: { - description: "Disallow trailing whitespace at the end of lines", - url: "https://eslint.style/rules/js/no-trailing-spaces" - }, - fixable: "whitespace", - schema: [ - { - type: "object", - properties: { - skipBlankLines: { - type: "boolean", - default: false - }, - ignoreComments: { - type: "boolean", - default: false - } - }, - additionalProperties: false - } - ], - messages: { - trailingSpace: "Trailing spaces not allowed." - } - }, - create(context) { - const sourceCode = context.sourceCode; - const BLANK_CLASS = "[ \xA0\u2000-\u200B\u3000]"; - const SKIP_BLANK = `^${BLANK_CLASS}*$`; - const NONBLANK = `${BLANK_CLASS}+$`; - const options = context.options[0] || {}; - const skipBlankLines = options.skipBlankLines || false; - const ignoreComments = options.ignoreComments || false; - function report(node, location, fixRange) { - context.report({ - node, - loc: location, - messageId: "trailingSpace", - fix(fixer) { - return fixer.removeRange(fixRange); - } - }); - } - function getCommentLineNumbers(comments) { - const lines = /* @__PURE__ */ new Set(); - comments.forEach((comment) => { - const endLine = comment.type === "Block" ? comment.loc.end.line - 1 : comment.loc.end.line; - for (let i = comment.loc.start.line; i <= endLine; i++) - lines.add(i); - }); - return lines; - } - return { - Program: function checkTrailingSpaces(node) { - const re = new RegExp(NONBLANK, "u"); - const skipMatch = new RegExp(SKIP_BLANK, "u"); - const lines = sourceCode.lines; - const linebreaks = sourceCode.getText().match(utils.createGlobalLinebreakMatcher()); - const comments = sourceCode.getAllComments(); - const commentLineNumbers = getCommentLineNumbers(comments); - let totalLength = 0; - for (let i = 0, ii = lines.length; i < ii; i++) { - const lineNumber = i + 1; - const linebreakLength = linebreaks && linebreaks[i] ? linebreaks[i].length : 1; - const lineLength = lines[i].length + linebreakLength; - const matches = re.exec(lines[i]); - if (matches) { - const location = { - start: { - line: lineNumber, - column: matches.index - }, - end: { - line: lineNumber, - column: lineLength - linebreakLength - } - }; - const rangeStart = totalLength + location.start.column; - const rangeEnd = totalLength + location.end.column; - const containingNode = sourceCode.getNodeByRangeIndex(rangeStart); - if (containingNode && containingNode.type === "TemplateElement" && rangeStart > containingNode.parent.range[0] && rangeEnd < containingNode.parent.range[1]) { - totalLength += lineLength; - continue; - } - if (skipBlankLines && skipMatch.test(lines[i])) { - totalLength += lineLength; - continue; - } - const fixRange = [rangeStart, rangeEnd]; - if (!ignoreComments || !commentLineNumbers.has(lineNumber)) - report(node, location, fixRange); - } - totalLength += lineLength; - } - } - }; - } -}); - -exports.noTrailingSpaces = noTrailingSpaces; diff --git a/tools/eslint/node_modules/@stylistic/eslint-plugin-js/dist/no-whitespace-before-property.js b/tools/eslint/node_modules/@stylistic/eslint-plugin-js/dist/no-whitespace-before-property.js deleted file mode 100644 index 3cd0bb8d66ca68..00000000000000 --- a/tools/eslint/node_modules/@stylistic/eslint-plugin-js/dist/no-whitespace-before-property.js +++ /dev/null @@ -1,62 +0,0 @@ -'use strict'; - -var utils = require('./utils.js'); - -var noWhitespaceBeforeProperty = utils.createRule({ - meta: { - type: "layout", - docs: { - description: "Disallow whitespace before properties", - url: "https://eslint.style/rules/js/no-whitespace-before-property" - }, - fixable: "whitespace", - schema: [], - messages: { - unexpectedWhitespace: "Unexpected whitespace before property {{propName}}." - } - }, - create(context) { - const sourceCode = context.sourceCode; - function reportError(node, leftToken, rightToken) { - context.report({ - node, - messageId: "unexpectedWhitespace", - data: { - propName: sourceCode.getText(node.property) - }, - fix(fixer) { - let replacementText = ""; - if (!node.computed && !node.optional && utils.isDecimalInteger(node.object)) { - return null; - } - if (sourceCode.commentsExistBetween(leftToken, rightToken)) - return null; - if (node.optional) - replacementText = "?."; - else if (!node.computed) - replacementText = "."; - return fixer.replaceTextRange([leftToken.range[1], rightToken.range[0]], replacementText); - } - }); - } - return { - MemberExpression(node) { - let rightToken; - let leftToken; - if (!utils.isTokenOnSameLine(node.object, node.property)) - return; - if (node.computed) { - rightToken = sourceCode.getTokenBefore(node.property, utils.isOpeningBracketToken); - leftToken = sourceCode.getTokenBefore(rightToken, node.optional ? 1 : 0); - } else { - rightToken = sourceCode.getFirstToken(node.property); - leftToken = sourceCode.getTokenBefore(rightToken, 1); - } - if (sourceCode.isSpaceBetweenTokens(leftToken, rightToken)) - reportError(node, leftToken, rightToken); - } - }; - } -}); - -exports.noWhitespaceBeforeProperty = noWhitespaceBeforeProperty; diff --git a/tools/eslint/node_modules/@stylistic/eslint-plugin-js/dist/nonblock-statement-body-position.js b/tools/eslint/node_modules/@stylistic/eslint-plugin-js/dist/nonblock-statement-body-position.js deleted file mode 100644 index f9d3851972b428..00000000000000 --- a/tools/eslint/node_modules/@stylistic/eslint-plugin-js/dist/nonblock-statement-body-position.js +++ /dev/null @@ -1,85 +0,0 @@ -'use strict'; - -var utils = require('./utils.js'); - -const POSITION_SCHEMA = { - type: "string", - enum: ["beside", "below", "any"] -}; -var nonblockStatementBodyPosition = utils.createRule({ - meta: { - type: "layout", - docs: { - description: "Enforce the location of single-line statements", - url: "https://eslint.style/rules/js/nonblock-statement-body-position" - }, - fixable: "whitespace", - schema: [ - POSITION_SCHEMA, - { - type: "object", - properties: { - overrides: { - type: "object", - properties: { - if: POSITION_SCHEMA, - else: POSITION_SCHEMA, - while: POSITION_SCHEMA, - do: POSITION_SCHEMA, - for: POSITION_SCHEMA - }, - additionalProperties: false - } - }, - additionalProperties: false - } - ], - messages: { - expectNoLinebreak: "Expected no linebreak before this statement.", - expectLinebreak: "Expected a linebreak before this statement." - } - }, - create(context) { - const sourceCode = context.sourceCode; - function getOption(keywordName) { - return context.options[1] && context.options[1].overrides && context.options[1].overrides[keywordName] || context.options[0] || "beside"; - } - function validateStatement(node, keywordName) { - const option = getOption(keywordName); - if (node.type === "BlockStatement" || option === "any") - return; - const tokenBefore = sourceCode.getTokenBefore(node); - if (tokenBefore.loc.end.line === node.loc.start.line && option === "below") { - context.report({ - node, - messageId: "expectLinebreak", - fix: (fixer) => fixer.insertTextBefore(node, "\n") - }); - } else if (tokenBefore.loc.end.line !== node.loc.start.line && option === "beside") { - context.report({ - node, - messageId: "expectNoLinebreak", - fix(fixer) { - if (sourceCode.getText().slice(tokenBefore.range[1], node.range[0]).trim()) - return null; - return fixer.replaceTextRange([tokenBefore.range[1], node.range[0]], " "); - } - }); - } - } - return { - IfStatement(node) { - validateStatement(node.consequent, "if"); - if (node.alternate && node.alternate.type !== "IfStatement") - validateStatement(node.alternate, "else"); - }, - WhileStatement: (node) => validateStatement(node.body, "while"), - DoWhileStatement: (node) => validateStatement(node.body, "do"), - ForStatement: (node) => validateStatement(node.body, "for"), - ForInStatement: (node) => validateStatement(node.body, "for"), - ForOfStatement: (node) => validateStatement(node.body, "for") - }; - } -}); - -exports.nonblockStatementBodyPosition = nonblockStatementBodyPosition; diff --git a/tools/eslint/node_modules/@stylistic/eslint-plugin-js/dist/object-curly-newline.js b/tools/eslint/node_modules/@stylistic/eslint-plugin-js/dist/object-curly-newline.js deleted file mode 100644 index f016cce245bf98..00000000000000 --- a/tools/eslint/node_modules/@stylistic/eslint-plugin-js/dist/object-curly-newline.js +++ /dev/null @@ -1,210 +0,0 @@ -'use strict'; - -var utils = require('./utils.js'); - -const OPTION_VALUE = { - oneOf: [ - { - type: "string", - enum: ["always", "never"] - }, - { - type: "object", - properties: { - multiline: { - type: "boolean" - }, - minProperties: { - type: "integer", - minimum: 0 - }, - consistent: { - type: "boolean" - } - }, - additionalProperties: false, - minProperties: 1 - } - ] -}; -function normalizeOptionValue(value) { - let multiline = false; - let minProperties = Number.POSITIVE_INFINITY; - let consistent = false; - if (value) { - if (value === "always") { - minProperties = 0; - } else if (value === "never") { - minProperties = Number.POSITIVE_INFINITY; - } else { - multiline = Boolean(value.multiline); - minProperties = value.minProperties || Number.POSITIVE_INFINITY; - consistent = Boolean(value.consistent); - } - } else { - consistent = true; - } - return { multiline, minProperties, consistent }; -} -function isObject(value) { - return typeof value === "object" && value !== null; -} -function isNodeSpecificOption(option) { - return isObject(option) || typeof option === "string"; -} -function normalizeOptions(options) { - if (isObject(options) && Object.values(options).some(isNodeSpecificOption)) { - return { - ObjectExpression: normalizeOptionValue(options.ObjectExpression), - ObjectPattern: normalizeOptionValue(options.ObjectPattern), - ImportDeclaration: normalizeOptionValue(options.ImportDeclaration), - ExportNamedDeclaration: normalizeOptionValue(options.ExportDeclaration), - TSTypeLiteral: normalizeOptionValue(options.TSTypeLiteral), - TSInterfaceBody: normalizeOptionValue(options.TSInterfaceBody) - }; - } - const value = normalizeOptionValue(options); - return { ObjectExpression: value, ObjectPattern: value, ImportDeclaration: value, ExportNamedDeclaration: value, TSTypeLiteral: value, TSInterfaceBody: value }; -} -function areLineBreaksRequired(node, options, first, last) { - let objectProperties; - if (node.type === "ObjectExpression" || node.type === "ObjectPattern") { - objectProperties = node.properties; - } else if (node.type === "TSTypeLiteral") { - objectProperties = node.members; - } else if (node.type === "TSInterfaceBody") { - objectProperties = node.body; - } else { - objectProperties = node.specifiers.filter((s) => s.type === "ImportSpecifier" || s.type === "ExportSpecifier"); - } - return objectProperties.length >= options.minProperties || options.multiline && objectProperties.length > 0 && first.loc.start.line !== last.loc.end.line; -} -var objectCurlyNewline = utils.createRule({ - meta: { - type: "layout", - docs: { - description: "Enforce consistent line breaks after opening and before closing braces", - url: "https://eslint.style/rules/js/object-curly-newline" - }, - fixable: "whitespace", - schema: [ - { - oneOf: [ - OPTION_VALUE, - { - type: "object", - properties: { - ObjectExpression: OPTION_VALUE, - ObjectPattern: OPTION_VALUE, - ImportDeclaration: OPTION_VALUE, - ExportDeclaration: OPTION_VALUE, - TSTypeLiteral: OPTION_VALUE, - TSInterfaceBody: OPTION_VALUE - }, - additionalProperties: false, - minProperties: 1 - } - ] - } - ], - messages: { - unexpectedLinebreakBeforeClosingBrace: "Unexpected line break before this closing brace.", - unexpectedLinebreakAfterOpeningBrace: "Unexpected line break after this opening brace.", - expectedLinebreakBeforeClosingBrace: "Expected a line break before this closing brace.", - expectedLinebreakAfterOpeningBrace: "Expected a line break after this opening brace." - } - }, - create(context) { - const sourceCode = context.sourceCode; - const normalizedOptions = normalizeOptions(context.options[0]); - function check(node) { - const options = normalizedOptions[node.type]; - if (node.type === "ImportDeclaration" && !node.specifiers.some((specifier) => specifier.type === "ImportSpecifier") || node.type === "ExportNamedDeclaration" && !node.specifiers.some((specifier) => specifier.type === "ExportSpecifier")) { - return; - } - const openBrace = sourceCode.getFirstToken(node, (token) => token.value === "{"); - let closeBrace; - if (node.type === "ObjectPattern" && node.typeAnnotation) - closeBrace = sourceCode.getTokenBefore(node.typeAnnotation); - else - closeBrace = sourceCode.getLastToken(node, (token) => token.value === "}"); - let first = sourceCode.getTokenAfter(openBrace, { includeComments: true }); - let last = sourceCode.getTokenBefore(closeBrace, { includeComments: true }); - const needsLineBreaks = areLineBreaksRequired(node, options, first, last); - const hasCommentsFirstToken = utils.isCommentToken(first); - const hasCommentsLastToken = utils.isCommentToken(last); - first = sourceCode.getTokenAfter(openBrace); - last = sourceCode.getTokenBefore(closeBrace); - if (needsLineBreaks) { - if (utils.isTokenOnSameLine(openBrace, first)) { - context.report({ - messageId: "expectedLinebreakAfterOpeningBrace", - node, - loc: openBrace.loc, - fix(fixer) { - if (hasCommentsFirstToken) - return null; - return fixer.insertTextAfter(openBrace, "\n"); - } - }); - } - if (utils.isTokenOnSameLine(last, closeBrace)) { - context.report({ - messageId: "expectedLinebreakBeforeClosingBrace", - node, - loc: closeBrace.loc, - fix(fixer) { - if (hasCommentsLastToken) - return null; - return fixer.insertTextBefore(closeBrace, "\n"); - } - }); - } - } else { - const consistent = options.consistent; - const hasLineBreakBetweenOpenBraceAndFirst = !utils.isTokenOnSameLine(openBrace, first); - const hasLineBreakBetweenCloseBraceAndLast = !utils.isTokenOnSameLine(last, closeBrace); - if (!consistent && hasLineBreakBetweenOpenBraceAndFirst || consistent && hasLineBreakBetweenOpenBraceAndFirst && !hasLineBreakBetweenCloseBraceAndLast) { - context.report({ - messageId: "unexpectedLinebreakAfterOpeningBrace", - node, - loc: openBrace.loc, - fix(fixer) { - if (hasCommentsFirstToken) - return null; - return fixer.removeRange([ - openBrace.range[1], - first.range[0] - ]); - } - }); - } - if (!consistent && hasLineBreakBetweenCloseBraceAndLast || consistent && !hasLineBreakBetweenOpenBraceAndFirst && hasLineBreakBetweenCloseBraceAndLast) { - context.report({ - messageId: "unexpectedLinebreakBeforeClosingBrace", - node, - loc: closeBrace.loc, - fix(fixer) { - if (hasCommentsLastToken) - return null; - return fixer.removeRange([ - last.range[1], - closeBrace.range[0] - ]); - } - }); - } - } - } - return { - ObjectExpression: check, - ObjectPattern: check, - ImportDeclaration: check, - ExportNamedDeclaration: check, - TSTypeLiteral: check, - TSInterfaceBody: check - }; - } -}); - -exports.objectCurlyNewline = objectCurlyNewline; diff --git a/tools/eslint/node_modules/@stylistic/eslint-plugin-js/dist/object-curly-spacing.js b/tools/eslint/node_modules/@stylistic/eslint-plugin-js/dist/object-curly-spacing.js deleted file mode 100644 index f674d5df2a8ec2..00000000000000 --- a/tools/eslint/node_modules/@stylistic/eslint-plugin-js/dist/object-curly-spacing.js +++ /dev/null @@ -1,176 +0,0 @@ -'use strict'; - -var utils = require('./utils.js'); - -var objectCurlySpacing = utils.createRule( - { - meta: { - type: "layout", - docs: { - description: "Enforce consistent spacing inside braces", - url: "https://eslint.style/rules/js/object-curly-spacing" - }, - fixable: "whitespace", - schema: [ - { - type: "string", - enum: ["always", "never"] - }, - { - type: "object", - properties: { - arraysInObjects: { - type: "boolean" - }, - objectsInObjects: { - type: "boolean" - } - }, - additionalProperties: false - } - ], - messages: { - requireSpaceBefore: "A space is required before '{{token}}'.", - requireSpaceAfter: "A space is required after '{{token}}'.", - unexpectedSpaceBefore: "There should be no space before '{{token}}'.", - unexpectedSpaceAfter: "There should be no space after '{{token}}'." - } - }, - create(context) { - const spaced = context.options[0] === "always"; - const sourceCode = context.sourceCode; - function isOptionSet(option) { - return context.options[1] ? context.options[1][option] === !spaced : false; - } - const options = { - spaced, - arraysInObjectsException: isOptionSet("arraysInObjects"), - objectsInObjectsException: isOptionSet("objectsInObjects") - }; - function reportNoBeginningSpace(node, token) { - const nextToken = context.sourceCode.getTokenAfter(token, { includeComments: true }); - context.report({ - node, - loc: { start: token.loc.end, end: nextToken.loc.start }, - messageId: "unexpectedSpaceAfter", - data: { - token: token.value - }, - fix(fixer) { - return fixer.removeRange([token.range[1], nextToken.range[0]]); - } - }); - } - function reportNoEndingSpace(node, token) { - const previousToken = context.sourceCode.getTokenBefore(token, { includeComments: true }); - context.report({ - node, - loc: { start: previousToken.loc.end, end: token.loc.start }, - messageId: "unexpectedSpaceBefore", - data: { - token: token.value - }, - fix(fixer) { - return fixer.removeRange([previousToken.range[1], token.range[0]]); - } - }); - } - function reportRequiredBeginningSpace(node, token) { - context.report({ - node, - loc: token.loc, - messageId: "requireSpaceAfter", - data: { - token: token.value - }, - fix(fixer) { - return fixer.insertTextAfter(token, " "); - } - }); - } - function reportRequiredEndingSpace(node, token) { - context.report({ - node, - loc: token.loc, - messageId: "requireSpaceBefore", - data: { - token: token.value - }, - fix(fixer) { - return fixer.insertTextBefore(token, " "); - } - }); - } - function validateBraceSpacing(node, first, second, penultimate, last) { - if (utils.isTokenOnSameLine(first, second)) { - const firstSpaced = sourceCode.isSpaceBetweenTokens(first, second); - if (options.spaced && !firstSpaced) - reportRequiredBeginningSpace(node, first); - if (!options.spaced && firstSpaced && second.type !== "Line") - reportNoBeginningSpace(node, first); - } - if (utils.isTokenOnSameLine(penultimate, last)) { - const shouldCheckPenultimate = options.arraysInObjectsException && utils.isClosingBracketToken(penultimate) || options.objectsInObjectsException && utils.isClosingBraceToken(penultimate); - const penultimateType = shouldCheckPenultimate && sourceCode.getNodeByRangeIndex(penultimate.range[0]).type; - const closingCurlyBraceMustBeSpaced = options.arraysInObjectsException && penultimateType === "ArrayExpression" || options.objectsInObjectsException && (penultimateType === "ObjectExpression" || penultimateType === "ObjectPattern") ? !options.spaced : options.spaced; - const lastSpaced = sourceCode.isSpaceBetweenTokens(penultimate, last); - if (closingCurlyBraceMustBeSpaced && !lastSpaced) - reportRequiredEndingSpace(node, last); - if (!closingCurlyBraceMustBeSpaced && lastSpaced) - reportNoEndingSpace(node, last); - } - } - function getClosingBraceOfObject(node) { - const lastProperty = node.properties[node.properties.length - 1]; - return sourceCode.getTokenAfter(lastProperty, utils.isClosingBraceToken); - } - function checkForObject(node) { - if (node.properties.length === 0) - return; - const first = sourceCode.getFirstToken(node); - const last = getClosingBraceOfObject(node); - const second = sourceCode.getTokenAfter(first, { includeComments: true }); - const penultimate = sourceCode.getTokenBefore(last, { includeComments: true }); - validateBraceSpacing(node, first, second, penultimate, last); - } - function checkForImport(node) { - if (node.specifiers.length === 0) - return; - let firstSpecifier = node.specifiers[0]; - const lastSpecifier = node.specifiers[node.specifiers.length - 1]; - if (lastSpecifier.type !== "ImportSpecifier") - return; - if (firstSpecifier.type !== "ImportSpecifier") - firstSpecifier = node.specifiers[1]; - const first = sourceCode.getTokenBefore(firstSpecifier); - const last = sourceCode.getTokenAfter(lastSpecifier, utils.isNotCommaToken); - const second = sourceCode.getTokenAfter(first, { includeComments: true }); - const penultimate = sourceCode.getTokenBefore(last, { includeComments: true }); - validateBraceSpacing(node, first, second, penultimate, last); - } - function checkForExport(node) { - if (node.specifiers.length === 0) - return; - const firstSpecifier = node.specifiers[0]; - const lastSpecifier = node.specifiers[node.specifiers.length - 1]; - const first = sourceCode.getTokenBefore(firstSpecifier); - const last = sourceCode.getTokenAfter(lastSpecifier, utils.isNotCommaToken); - const second = sourceCode.getTokenAfter(first, { includeComments: true }); - const penultimate = sourceCode.getTokenBefore(last, { includeComments: true }); - validateBraceSpacing(node, first, second, penultimate, last); - } - return { - // var {x} = y; - ObjectPattern: checkForObject, - // var y = {x: 'y'} - ObjectExpression: checkForObject, - // import {y} from 'x'; - ImportDeclaration: checkForImport, - // export {name} from 'yo'; - ExportNamedDeclaration: checkForExport - }; - } - } -); - -exports.objectCurlySpacing = objectCurlySpacing; diff --git a/tools/eslint/node_modules/@stylistic/eslint-plugin-js/dist/object-property-newline.js b/tools/eslint/node_modules/@stylistic/eslint-plugin-js/dist/object-property-newline.js deleted file mode 100644 index 5fad5d1d512912..00000000000000 --- a/tools/eslint/node_modules/@stylistic/eslint-plugin-js/dist/object-property-newline.js +++ /dev/null @@ -1,73 +0,0 @@ -'use strict'; - -var utils = require('./utils.js'); - -var objectPropertyNewline = utils.createRule({ - meta: { - type: "layout", - docs: { - description: "Enforce placing object properties on separate lines", - url: "https://eslint.style/rules/js/object-property-newline" - }, - schema: [ - { - type: "object", - properties: { - allowAllPropertiesOnSameLine: { - type: "boolean", - default: false - }, - allowMultiplePropertiesPerLine: { - // Deprecated - type: "boolean", - default: false - } - }, - additionalProperties: false - } - ], - fixable: "whitespace", - messages: { - propertiesOnNewlineAll: "Object properties must go on a new line if they aren't all on the same line.", - propertiesOnNewline: "Object properties must go on a new line." - } - }, - create(context) { - const allowSameLine = context.options[0] && (context.options[0].allowAllPropertiesOnSameLine || context.options[0].allowMultiplePropertiesPerLine); - const messageId = allowSameLine ? "propertiesOnNewlineAll" : "propertiesOnNewline"; - const sourceCode = context.sourceCode; - return { - ObjectExpression(node) { - if (allowSameLine) { - if (node.properties.length > 1) { - const firstTokenOfFirstProperty = sourceCode.getFirstToken(node.properties[0]); - const lastTokenOfLastProperty = sourceCode.getLastToken(node.properties[node.properties.length - 1]); - if (firstTokenOfFirstProperty.loc.end.line === lastTokenOfLastProperty.loc.start.line) { - return; - } - } - } - for (let i = 1; i < node.properties.length; i++) { - const lastTokenOfPreviousProperty = sourceCode.getLastToken(node.properties[i - 1]); - const firstTokenOfCurrentProperty = sourceCode.getFirstToken(node.properties[i]); - if (lastTokenOfPreviousProperty.loc.end.line === firstTokenOfCurrentProperty.loc.start.line) { - context.report({ - node, - loc: firstTokenOfCurrentProperty.loc, - messageId, - fix(fixer) { - const comma = sourceCode.getTokenBefore(firstTokenOfCurrentProperty); - const rangeAfterComma = [comma.range[1], firstTokenOfCurrentProperty.range[0]]; - if (sourceCode.text.slice(rangeAfterComma[0], rangeAfterComma[1]).trim()) - return null; - return fixer.replaceTextRange(rangeAfterComma, "\n"); - } - }); - } - } - } - }; - } -}); - -exports.objectPropertyNewline = objectPropertyNewline; diff --git a/tools/eslint/node_modules/@stylistic/eslint-plugin-js/dist/one-var-declaration-per-line.js b/tools/eslint/node_modules/@stylistic/eslint-plugin-js/dist/one-var-declaration-per-line.js deleted file mode 100644 index 68fd3c55c2b0c2..00000000000000 --- a/tools/eslint/node_modules/@stylistic/eslint-plugin-js/dist/one-var-declaration-per-line.js +++ /dev/null @@ -1,53 +0,0 @@ -'use strict'; - -var utils = require('./utils.js'); - -var oneVarDeclarationPerLine = utils.createRule({ - meta: { - type: "layout", - docs: { - description: "Require or disallow newlines around variable declarations", - url: "https://eslint.style/rules/js/one-var-declaration-per-line" - }, - schema: [ - { - type: "string", - enum: ["always", "initializations"] - } - ], - fixable: "whitespace", - messages: { - expectVarOnNewline: "Expected variable declaration to be on a new line." - } - }, - create(context) { - const always = context.options[0] === "always"; - function isForTypeSpecifier(keyword) { - return keyword === "ForStatement" || keyword === "ForInStatement" || keyword === "ForOfStatement"; - } - function checkForNewLine(node) { - if (isForTypeSpecifier(node.parent.type)) - return; - const declarations = node.declarations; - let prev; - declarations.forEach((current) => { - if (prev && prev.loc.end.line === current.loc.start.line) { - if (always || prev.init || current.init) { - context.report({ - node, - messageId: "expectVarOnNewline", - loc: current.loc, - fix: (fixer) => fixer.insertTextBefore(current, "\n") - }); - } - } - prev = current; - }); - } - return { - VariableDeclaration: checkForNewLine - }; - } -}); - -exports.oneVarDeclarationPerLine = oneVarDeclarationPerLine; diff --git a/tools/eslint/node_modules/@stylistic/eslint-plugin-js/dist/operator-linebreak.js b/tools/eslint/node_modules/@stylistic/eslint-plugin-js/dist/operator-linebreak.js deleted file mode 100644 index 0368303a538a2d..00000000000000 --- a/tools/eslint/node_modules/@stylistic/eslint-plugin-js/dist/operator-linebreak.js +++ /dev/null @@ -1,156 +0,0 @@ -'use strict'; - -var utils = require('./utils.js'); - -var operatorLinebreak = utils.createRule({ - meta: { - type: "layout", - docs: { - description: "Enforce consistent linebreak style for operators", - url: "https://eslint.style/rules/js/operator-linebreak" - }, - schema: [ - { - oneOf: [ - { - type: "string", - enum: ["after", "before", "none"] - }, - { - type: "null" - } - ] - }, - { - type: "object", - properties: { - overrides: { - type: "object", - additionalProperties: { - type: "string", - enum: ["after", "before", "none", "ignore"] - } - } - }, - additionalProperties: false - } - ], - fixable: "code", - messages: { - operatorAtBeginning: "'{{operator}}' should be placed at the beginning of the line.", - operatorAtEnd: "'{{operator}}' should be placed at the end of the line.", - badLinebreak: "Bad line breaking before and after '{{operator}}'.", - noLinebreak: "There should be no line break before or after '{{operator}}'." - } - }, - create(context) { - const usedDefaultGlobal = !context.options[0]; - const globalStyle = context.options[0] || "after"; - const options = context.options[1] || {}; - const styleOverrides = options.overrides ? Object.assign({}, options.overrides) : {}; - if (usedDefaultGlobal && !styleOverrides["?"]) - styleOverrides["?"] = "before"; - if (usedDefaultGlobal && !styleOverrides[":"]) - styleOverrides[":"] = "before"; - const sourceCode = context.sourceCode; - function getFixer(operatorToken, desiredStyle) { - return (fixer) => { - const tokenBefore = sourceCode.getTokenBefore(operatorToken); - const tokenAfter = sourceCode.getTokenAfter(operatorToken); - const textBefore = sourceCode.text.slice(tokenBefore.range[1], operatorToken.range[0]); - const textAfter = sourceCode.text.slice(operatorToken.range[1], tokenAfter.range[0]); - const hasLinebreakBefore = !utils.isTokenOnSameLine(tokenBefore, operatorToken); - const hasLinebreakAfter = !utils.isTokenOnSameLine(operatorToken, tokenAfter); - let newTextBefore, newTextAfter; - if (hasLinebreakBefore !== hasLinebreakAfter && desiredStyle !== "none") { - if (sourceCode.getTokenBefore(operatorToken, { includeComments: true }) !== tokenBefore && sourceCode.getTokenAfter(operatorToken, { includeComments: true }) !== tokenAfter) { - return null; - } - newTextBefore = textAfter; - newTextAfter = textBefore; - } else { - const LINEBREAK_REGEX = utils.createGlobalLinebreakMatcher(); - newTextBefore = desiredStyle === "before" || textBefore.trim() ? textBefore : textBefore.replace(LINEBREAK_REGEX, ""); - newTextAfter = desiredStyle === "after" || textAfter.trim() ? textAfter : textAfter.replace(LINEBREAK_REGEX, ""); - if (newTextBefore === textBefore && newTextAfter === textAfter) - return null; - } - if (newTextAfter === "" && tokenAfter.type === "Punctuator" && "+-".includes(operatorToken.value) && tokenAfter.value === operatorToken.value) { - newTextAfter += " "; - } - return fixer.replaceTextRange([tokenBefore.range[1], tokenAfter.range[0]], newTextBefore + operatorToken.value + newTextAfter); - }; - } - function validateNode(node, rightSide, operator) { - const operatorToken = sourceCode.getTokenBefore(rightSide, (token) => token.value === operator); - const leftToken = sourceCode.getTokenBefore(operatorToken); - const rightToken = sourceCode.getTokenAfter(operatorToken); - const operatorStyleOverride = styleOverrides[operator]; - const style = operatorStyleOverride || globalStyle; - const fix = getFixer(operatorToken, style); - if (utils.isTokenOnSameLine(leftToken, operatorToken) && utils.isTokenOnSameLine(operatorToken, rightToken)) ; else if (operatorStyleOverride !== "ignore" && !utils.isTokenOnSameLine(leftToken, operatorToken) && !utils.isTokenOnSameLine(operatorToken, rightToken)) { - context.report({ - node, - loc: operatorToken.loc, - messageId: "badLinebreak", - data: { - operator - }, - fix - }); - } else if (style === "before" && utils.isTokenOnSameLine(leftToken, operatorToken)) { - context.report({ - node, - loc: operatorToken.loc, - messageId: "operatorAtBeginning", - data: { - operator - }, - fix - }); - } else if (style === "after" && utils.isTokenOnSameLine(operatorToken, rightToken)) { - context.report({ - node, - loc: operatorToken.loc, - messageId: "operatorAtEnd", - data: { - operator - }, - fix - }); - } else if (style === "none") { - context.report({ - node, - loc: operatorToken.loc, - messageId: "noLinebreak", - data: { - operator - }, - fix - }); - } - } - function validateBinaryExpression(node) { - validateNode(node, node.right, node.operator); - } - return { - BinaryExpression: validateBinaryExpression, - LogicalExpression: validateBinaryExpression, - AssignmentExpression: validateBinaryExpression, - VariableDeclarator(node) { - if (node.init) - validateNode(node, node.init, "="); - }, - PropertyDefinition(node) { - if (node.value) - validateNode(node, node.value, "="); - }, - ConditionalExpression(node) { - validateNode(node, node.consequent, "?"); - validateNode(node, node.alternate, ":"); - } - }; - } -}); - -exports.operatorLinebreak = operatorLinebreak; diff --git a/tools/eslint/node_modules/@stylistic/eslint-plugin-js/dist/padded-blocks.js b/tools/eslint/node_modules/@stylistic/eslint-plugin-js/dist/padded-blocks.js deleted file mode 100644 index ef4009e12c3147..00000000000000 --- a/tools/eslint/node_modules/@stylistic/eslint-plugin-js/dist/padded-blocks.js +++ /dev/null @@ -1,214 +0,0 @@ -'use strict'; - -var utils = require('./utils.js'); - -var paddedBlocks = utils.createRule({ - meta: { - type: "layout", - docs: { - description: "Require or disallow padding within blocks", - url: "https://eslint.style/rules/js/padded-blocks" - }, - fixable: "whitespace", - schema: [ - { - oneOf: [ - { - type: "string", - enum: ["always", "never"] - }, - { - type: "object", - properties: { - blocks: { - type: "string", - enum: ["always", "never"] - }, - switches: { - type: "string", - enum: ["always", "never"] - }, - classes: { - type: "string", - enum: ["always", "never"] - } - }, - additionalProperties: false, - minProperties: 1 - } - ] - }, - { - type: "object", - properties: { - allowSingleLineBlocks: { - type: "boolean" - } - }, - additionalProperties: false - } - ], - messages: { - alwaysPadBlock: "Block must be padded by blank lines.", - neverPadBlock: "Block must not be padded by blank lines." - } - }, - create(context) { - const options = {}; - const typeOptions = context.options[0] || "always"; - const exceptOptions = context.options[1] || {}; - if (typeof typeOptions === "string") { - const shouldHavePadding = typeOptions === "always"; - options.blocks = shouldHavePadding; - options.switches = shouldHavePadding; - options.classes = shouldHavePadding; - } else { - if (Object.prototype.hasOwnProperty.call(typeOptions, "blocks")) - options.blocks = typeOptions.blocks === "always"; - if (Object.prototype.hasOwnProperty.call(typeOptions, "switches")) - options.switches = typeOptions.switches === "always"; - if (Object.prototype.hasOwnProperty.call(typeOptions, "classes")) - options.classes = typeOptions.classes === "always"; - } - if (Object.prototype.hasOwnProperty.call(exceptOptions, "allowSingleLineBlocks")) - options.allowSingleLineBlocks = exceptOptions.allowSingleLineBlocks === true; - const sourceCode = context.sourceCode; - function getOpenBrace(node) { - if (node.type === "SwitchStatement") - return sourceCode.getTokenBefore(node.cases[0]); - if (node.type === "StaticBlock") - return sourceCode.getFirstToken(node, { skip: 1 }); - return sourceCode.getFirstToken(node); - } - function isComment(node) { - return node.type === "Line" || node.type === "Block"; - } - function isPaddingBetweenTokens(first, second) { - return second.loc.start.line - first.loc.end.line >= 2; - } - function getFirstBlockToken(token) { - let prev; - let first = token; - do { - prev = first; - first = sourceCode.getTokenAfter(first, { includeComments: true }); - } while (isComment(first) && first.loc.start.line === prev.loc.end.line); - return first; - } - function getLastBlockToken(token) { - let last = token; - let next; - do { - next = last; - last = sourceCode.getTokenBefore(last, { includeComments: true }); - } while (isComment(last) && last.loc.end.line === next.loc.start.line); - return last; - } - function requirePaddingFor(node) { - switch (node.type) { - case "BlockStatement": - case "StaticBlock": - return options.blocks; - case "SwitchStatement": - return options.switches; - case "ClassBody": - return options.classes; - default: - throw new Error("unreachable"); - } - } - function checkPadding(node) { - const openBrace = getOpenBrace(node); - const firstBlockToken = getFirstBlockToken(openBrace); - const tokenBeforeFirst = sourceCode.getTokenBefore(firstBlockToken, { includeComments: true }); - const closeBrace = sourceCode.getLastToken(node); - const lastBlockToken = getLastBlockToken(closeBrace); - const tokenAfterLast = sourceCode.getTokenAfter(lastBlockToken, { includeComments: true }); - const blockHasTopPadding = isPaddingBetweenTokens(tokenBeforeFirst, firstBlockToken); - const blockHasBottomPadding = isPaddingBetweenTokens(lastBlockToken, tokenAfterLast); - if (options.allowSingleLineBlocks && utils.isTokenOnSameLine(tokenBeforeFirst, tokenAfterLast)) - return; - if (requirePaddingFor(node)) { - if (!blockHasTopPadding) { - context.report({ - node, - loc: { - start: tokenBeforeFirst.loc.start, - end: firstBlockToken.loc.start - }, - fix(fixer) { - return fixer.insertTextAfter(tokenBeforeFirst, "\n"); - }, - messageId: "alwaysPadBlock" - }); - } - if (!blockHasBottomPadding) { - context.report({ - node, - loc: { - end: tokenAfterLast.loc.start, - start: lastBlockToken.loc.end - }, - fix(fixer) { - return fixer.insertTextBefore(tokenAfterLast, "\n"); - }, - messageId: "alwaysPadBlock" - }); - } - } else { - if (blockHasTopPadding) { - context.report({ - node, - loc: { - start: tokenBeforeFirst.loc.start, - end: firstBlockToken.loc.start - }, - fix(fixer) { - return fixer.replaceTextRange([tokenBeforeFirst.range[1], firstBlockToken.range[0] - firstBlockToken.loc.start.column], "\n"); - }, - messageId: "neverPadBlock" - }); - } - if (blockHasBottomPadding) { - context.report({ - node, - loc: { - end: tokenAfterLast.loc.start, - start: lastBlockToken.loc.end - }, - messageId: "neverPadBlock", - fix(fixer) { - return fixer.replaceTextRange([lastBlockToken.range[1], tokenAfterLast.range[0] - tokenAfterLast.loc.start.column], "\n"); - } - }); - } - } - } - const rule = {}; - if (Object.prototype.hasOwnProperty.call(options, "switches")) { - rule.SwitchStatement = function(node) { - if (node.cases.length === 0) - return; - checkPadding(node); - }; - } - if (Object.prototype.hasOwnProperty.call(options, "blocks")) { - rule.BlockStatement = function(node) { - if (node.body.length === 0) - return; - checkPadding(node); - }; - rule.StaticBlock = rule.BlockStatement; - } - if (Object.prototype.hasOwnProperty.call(options, "classes")) { - rule.ClassBody = function(node) { - if (node.body.length === 0) - return; - checkPadding(node); - }; - } - return rule; - } -}); - -exports.paddedBlocks = paddedBlocks; diff --git a/tools/eslint/node_modules/@stylistic/eslint-plugin-js/dist/padding-line-between-statements.js b/tools/eslint/node_modules/@stylistic/eslint-plugin-js/dist/padding-line-between-statements.js deleted file mode 100644 index 5ecf25681dccd0..00000000000000 --- a/tools/eslint/node_modules/@stylistic/eslint-plugin-js/dist/padding-line-between-statements.js +++ /dev/null @@ -1,313 +0,0 @@ -'use strict'; - -var utils = require('./utils.js'); - -const LT = `[${Array.from(utils.LINEBREAKS).join("")}]`; -const PADDING_LINE_SEQUENCE = new RegExp( - String.raw`^(\s*?${LT})\s*${LT}(\s*;?)$`, - "u" -); -const CJS_EXPORT = /^(?:module\s*\.\s*)?exports(?:\s*\.|\s*\[|$)/u; -const CJS_IMPORT = /^require\(/u; -function newKeywordTester(keyword) { - return { - test: (node, sourceCode) => sourceCode.getFirstToken(node)?.value === keyword - }; -} -function newSinglelineKeywordTester(keyword) { - return { - test: (node, sourceCode) => node.loc.start.line === node.loc.end.line && sourceCode.getFirstToken(node)?.value === keyword - }; -} -function newMultilineKeywordTester(keyword) { - return { - test: (node, sourceCode) => node.loc.start.line !== node.loc.end.line && sourceCode.getFirstToken(node)?.value === keyword - }; -} -function newNodeTypeTester(type) { - return { - test: (node) => node.type === type - }; -} -function isIIFEStatement(node) { - if (node.type === "ExpressionStatement") { - let call = utils.skipChainExpression(node.expression); - if (call.type === "UnaryExpression") - call = utils.skipChainExpression(call.argument); - return call.type === "CallExpression" && utils.isFunction(call.callee); - } - return false; -} -function isBlockLikeStatement(sourceCode, node) { - if (node.type === "DoWhileStatement" && node.body.type === "BlockStatement") - return true; - if (isIIFEStatement(node)) - return true; - const lastToken = sourceCode.getLastToken(node, utils.isNotSemicolonToken); - const belongingNode = lastToken && utils.isClosingBraceToken(lastToken) ? sourceCode.getNodeByRangeIndex(lastToken.range[0]) : null; - return Boolean(belongingNode) && (belongingNode?.type === "BlockStatement" || belongingNode?.type === "SwitchStatement"); -} -function getActualLastToken(sourceCode, node) { - const semiToken = sourceCode.getLastToken(node); - const prevToken = sourceCode.getTokenBefore(semiToken); - const nextToken = sourceCode.getTokenAfter(semiToken); - const isSemicolonLessStyle = Boolean( - prevToken && nextToken && prevToken.range[0] >= node.range[0] && utils.isSemicolonToken(semiToken) && semiToken.loc.start.line !== prevToken.loc.end.line && semiToken.loc.end.line === nextToken.loc.start.line - ); - return isSemicolonLessStyle ? prevToken : semiToken; -} -function replacerToRemovePaddingLines(_, trailingSpaces, indentSpaces) { - return trailingSpaces + indentSpaces; -} -function verifyForAny() { -} -function verifyForNever(context, _, nextNode, paddingLines) { - if (paddingLines.length === 0) - return; - context.report({ - node: nextNode, - messageId: "unexpectedBlankLine", - fix(fixer) { - if (paddingLines.length >= 2) - return null; - const prevToken = paddingLines[0][0]; - const nextToken = paddingLines[0][1]; - const start = prevToken.range[1]; - const end = nextToken.range[0]; - const text = context.sourceCode.text.slice(start, end).replace(PADDING_LINE_SEQUENCE, replacerToRemovePaddingLines); - return fixer.replaceTextRange([start, end], text); - } - }); -} -function verifyForAlways(context, prevNode, nextNode, paddingLines) { - if (paddingLines.length > 0) - return; - context.report({ - node: nextNode, - messageId: "expectedBlankLine", - fix(fixer) { - const sourceCode = context.sourceCode; - let prevToken = getActualLastToken(sourceCode, prevNode); - const nextToken = sourceCode.getFirstTokenBetween( - prevToken, - nextNode, - { - includeComments: true, - /** - * Skip the trailing comments of the previous node. - * This inserts a blank line after the last trailing comment. - * - * For example: - * - * foo(); // trailing comment. - * // comment. - * bar(); - * - * Get fixed to: - * - * foo(); // trailing comment. - * - * // comment. - * bar(); - * @param token The token to check. - * @returns `true` if the token is not a trailing comment. - * @private - */ - filter(token) { - if (utils.isTokenOnSameLine(prevToken, token)) { - prevToken = token; - return false; - } - return true; - } - } - ) || nextNode; - const insertText = utils.isTokenOnSameLine(prevToken, nextToken) ? "\n\n" : "\n"; - return fixer.insertTextAfter(prevToken, insertText); - } - }); -} -const PaddingTypes = { - any: { verify: verifyForAny }, - never: { verify: verifyForNever }, - always: { verify: verifyForAlways } -}; -const StatementTypes = { - "*": { test: () => true }, - "block-like": { - test: (node, sourceCode) => isBlockLikeStatement(sourceCode, node) - }, - "cjs-export": { - test: (node, sourceCode) => node.type === "ExpressionStatement" && node.expression.type === "AssignmentExpression" && CJS_EXPORT.test(sourceCode.getText(node.expression.left)) - }, - "cjs-import": { - test: (node, sourceCode) => node.type === "VariableDeclaration" && node.declarations.length > 0 && Boolean(node.declarations[0].init) && CJS_IMPORT.test(sourceCode.getText(node.declarations[0].init)) - }, - "directive": { - test: utils.isDirective - }, - "expression": { - test: (node) => node.type === "ExpressionStatement" && !utils.isDirective(node) - }, - "iife": { - test: isIIFEStatement - }, - "multiline-block-like": { - test: (node, sourceCode) => node.loc.start.line !== node.loc.end.line && isBlockLikeStatement(sourceCode, node) - }, - "multiline-expression": { - test: (node) => node.loc.start.line !== node.loc.end.line && node.type === "ExpressionStatement" && !utils.isDirective(node) - }, - "multiline-const": newMultilineKeywordTester("const"), - "multiline-let": newMultilineKeywordTester("let"), - "multiline-var": newMultilineKeywordTester("var"), - "singleline-const": newSinglelineKeywordTester("const"), - "singleline-let": newSinglelineKeywordTester("let"), - "singleline-var": newSinglelineKeywordTester("var"), - "block": newNodeTypeTester("BlockStatement"), - "empty": newNodeTypeTester("EmptyStatement"), - "function": newNodeTypeTester("FunctionDeclaration"), - "break": newKeywordTester("break"), - "case": newKeywordTester("case"), - "class": newKeywordTester("class"), - "const": newKeywordTester("const"), - "continue": newKeywordTester("continue"), - "debugger": newKeywordTester("debugger"), - "default": newKeywordTester("default"), - "do": newKeywordTester("do"), - "export": newKeywordTester("export"), - "for": newKeywordTester("for"), - "if": newKeywordTester("if"), - "import": newKeywordTester("import"), - "let": newKeywordTester("let"), - "return": newKeywordTester("return"), - "switch": newKeywordTester("switch"), - "throw": newKeywordTester("throw"), - "try": newKeywordTester("try"), - "var": newKeywordTester("var"), - "while": newKeywordTester("while"), - "with": newKeywordTester("with") -}; -var paddingLineBetweenStatements = utils.createRule({ - meta: { - type: "layout", - docs: { - description: "Require or disallow padding lines between statements", - url: "https://eslint.style/rules/js/padding-line-between-statements" - }, - fixable: "whitespace", - schema: { - definitions: { - paddingType: { - type: "string", - enum: Object.keys(PaddingTypes) - }, - statementType: { - anyOf: [ - { type: "string", enum: Object.keys(StatementTypes) }, - { - type: "array", - items: { type: "string", enum: Object.keys(StatementTypes) }, - minItems: 1, - uniqueItems: true - } - ] - } - }, - type: "array", - items: { - type: "object", - properties: { - blankLine: { $ref: "#/definitions/paddingType" }, - prev: { $ref: "#/definitions/statementType" }, - next: { $ref: "#/definitions/statementType" } - }, - additionalProperties: false, - required: ["blankLine", "prev", "next"] - } - }, - messages: { - unexpectedBlankLine: "Unexpected blank line before this statement.", - expectedBlankLine: "Expected blank line before this statement." - } - }, - create(context) { - const sourceCode = context.sourceCode; - const configureList = context.options || []; - let scopeInfo = null; - function enterScope() { - scopeInfo = { - upper: scopeInfo, - prevNode: null - }; - } - function exitScope() { - scopeInfo = scopeInfo?.upper; - } - function match(node, type) { - let innerStatementNode = node; - while (innerStatementNode.type === "LabeledStatement") - innerStatementNode = innerStatementNode.body; - if (Array.isArray(type)) - return type.some(match.bind(null, innerStatementNode)); - return StatementTypes[type].test(innerStatementNode, sourceCode); - } - function getPaddingType(prevNode, nextNode) { - for (let i = configureList.length - 1; i >= 0; --i) { - const configure = configureList[i]; - const matched = match(prevNode, configure.prev) && match(nextNode, configure.next); - if (matched) - return PaddingTypes[configure.blankLine]; - } - return PaddingTypes.any; - } - function getPaddingLineSequences(prevNode, nextNode) { - const pairs = []; - let prevToken = getActualLastToken(sourceCode, prevNode); - if (nextNode.loc.start.line - prevToken.loc.end.line >= 2) { - do { - const token = sourceCode.getTokenAfter( - prevToken, - { includeComments: true } - ); - if (token.loc.start.line - prevToken.loc.end.line >= 2) - pairs.push([prevToken, token]); - prevToken = token; - } while (prevToken.range[0] < nextNode.range[0]); - } - return pairs; - } - function verify(node) { - const parentType = node.parent.type; - const validParent = utils.STATEMENT_LIST_PARENTS.has(parentType) || parentType === "SwitchStatement"; - if (!validParent) - return; - const prevNode = scopeInfo?.prevNode; - if (prevNode) { - const type = getPaddingType(prevNode, node); - const paddingLines = getPaddingLineSequences(prevNode, node); - type.verify(context, prevNode, node, paddingLines); - } - scopeInfo.prevNode = node; - } - function verifyThenEnterScope(node) { - verify(node); - enterScope(); - } - return { - "Program": enterScope, - "BlockStatement": enterScope, - "SwitchStatement": enterScope, - "StaticBlock": enterScope, - "Program:exit": exitScope, - "BlockStatement:exit": exitScope, - "SwitchStatement:exit": exitScope, - "StaticBlock:exit": exitScope, - ":statement": verify, - "SwitchCase": verifyThenEnterScope, - "SwitchCase:exit": exitScope - }; - } -}); - -exports.paddingLineBetweenStatements = paddingLineBetweenStatements; diff --git a/tools/eslint/node_modules/@stylistic/eslint-plugin-js/dist/quote-props.js b/tools/eslint/node_modules/@stylistic/eslint-plugin-js/dist/quote-props.js deleted file mode 100644 index b0d260e6532c13..00000000000000 --- a/tools/eslint/node_modules/@stylistic/eslint-plugin-js/dist/quote-props.js +++ /dev/null @@ -1,213 +0,0 @@ -'use strict'; - -var espree = require('espree'); -var utils = require('./utils.js'); - -var quoteProps = utils.createRule({ - meta: { - type: "layout", - docs: { - description: "Require quotes around object literal property names", - url: "https://eslint.style/rules/js/quote-props" - }, - schema: { - anyOf: [ - { - type: "array", - items: [ - { - type: "string", - enum: ["always", "as-needed", "consistent", "consistent-as-needed"] - } - ], - minItems: 0, - maxItems: 1 - }, - { - type: "array", - items: [ - { - type: "string", - enum: ["always", "as-needed", "consistent", "consistent-as-needed"] - }, - { - type: "object", - properties: { - keywords: { - type: "boolean" - }, - unnecessary: { - type: "boolean" - }, - numbers: { - type: "boolean" - } - }, - additionalProperties: false - } - ], - minItems: 0, - maxItems: 2 - } - ] - }, - fixable: "code", - messages: { - requireQuotesDueToReservedWord: "Properties should be quoted as '{{property}}' is a reserved word.", - inconsistentlyQuotedProperty: "Inconsistently quoted property '{{key}}' found.", - unnecessarilyQuotedProperty: "Unnecessarily quoted property '{{property}}' found.", - unquotedReservedProperty: "Unquoted reserved word '{{property}}' used as key.", - unquotedNumericProperty: "Unquoted number literal '{{property}}' used as key.", - unquotedPropertyFound: "Unquoted property '{{property}}' found.", - redundantQuoting: "Properties shouldn't be quoted as all quotes are redundant." - } - }, - create(context) { - const MODE = context.options[0]; - const KEYWORDS = context.options[1] && context.options[1].keywords; - const CHECK_UNNECESSARY = !context.options[1] || context.options[1].unnecessary !== false; - const NUMBERS = context.options[1] && context.options[1].numbers; - const sourceCode = context.sourceCode; - function isKeyword(tokenStr) { - return utils.keywords.includes(tokenStr); - } - function areQuotesRedundant(rawKey, tokens, skipNumberLiterals = false) { - return tokens.length === 1 && tokens[0].start === 0 && tokens[0].end === rawKey.length && (["Identifier", "Keyword", "Null", "Boolean"].includes(tokens[0].type) || tokens[0].type === "Numeric" && !skipNumberLiterals && String(+tokens[0].value) === tokens[0].value); - } - function getUnquotedKey(key) { - return key.type === "Identifier" ? key.name : key.value; - } - function getQuotedKey(key) { - if (key.type === "Literal" && typeof key.value === "string") { - return sourceCode.getText(key); - } - return `"${key.type === "Identifier" ? key.name : key.value}"`; - } - function checkUnnecessaryQuotes(node) { - const key = node.key; - if (node.method || node.computed || node.shorthand) - return; - if (key.type === "Literal" && typeof key.value === "string") { - let tokens; - try { - tokens = espree.tokenize(key.value); - } catch { - return; - } - if (tokens.length !== 1) - return; - const isKeywordToken = isKeyword(tokens[0].value); - if (isKeywordToken && KEYWORDS) - return; - if (CHECK_UNNECESSARY && areQuotesRedundant(key.value, tokens, NUMBERS)) { - context.report({ - node, - messageId: "unnecessarilyQuotedProperty", - data: { property: key.value }, - fix: (fixer) => fixer.replaceText(key, getUnquotedKey(key)) - }); - } - } else if (KEYWORDS && key.type === "Identifier" && isKeyword(key.name)) { - context.report({ - node, - messageId: "unquotedReservedProperty", - data: { property: key.name }, - fix: (fixer) => fixer.replaceText(key, getQuotedKey(key)) - }); - } else if (NUMBERS && key.type === "Literal" && utils.isNumericLiteral(key)) { - context.report({ - node, - messageId: "unquotedNumericProperty", - data: { property: key.value }, - fix: (fixer) => fixer.replaceText(key, getQuotedKey(key)) - }); - } - } - function checkOmittedQuotes(node) { - const key = node.key; - if (!node.method && !node.computed && !node.shorthand && !(key.type === "Literal" && typeof key.value === "string")) { - context.report({ - node, - messageId: "unquotedPropertyFound", - data: { property: key.name || key.value }, - fix: (fixer) => fixer.replaceText(key, getQuotedKey(key)) - }); - } - } - function checkConsistency(node, checkQuotesRedundancy) { - const quotedProps = []; - const unquotedProps = []; - let keywordKeyName = null; - let necessaryQuotes = false; - node.properties.forEach((rawProperty) => { - const property = rawProperty; - const key = property.key; - if (!key || property.method || property.computed || property.shorthand) - return; - if (key.type === "Literal" && typeof key.value === "string") { - quotedProps.push(property); - if (checkQuotesRedundancy) { - let tokens; - try { - tokens = espree.tokenize(key.value); - } catch { - necessaryQuotes = true; - return; - } - necessaryQuotes = necessaryQuotes || !areQuotesRedundant(key.value, tokens) || KEYWORDS && isKeyword(tokens[0].value); - } - } else if (KEYWORDS && checkQuotesRedundancy && key.type === "Identifier" && isKeyword(key.name)) { - unquotedProps.push(property); - necessaryQuotes = true; - keywordKeyName = key.name; - } else { - unquotedProps.push(property); - } - }); - if (checkQuotesRedundancy && quotedProps.length && !necessaryQuotes) { - quotedProps.forEach((property) => { - const key = property.key; - context.report({ - node: property, - messageId: "redundantQuoting", - fix: (fixer) => fixer.replaceText(key, getUnquotedKey(key)) - }); - }); - } else if (unquotedProps.length && keywordKeyName) { - unquotedProps.forEach((property) => { - context.report({ - node: property, - messageId: "requireQuotesDueToReservedWord", - data: { property: keywordKeyName }, - fix: (fixer) => fixer.replaceText(property.key, getQuotedKey(property.key)) - }); - }); - } else if (quotedProps.length && unquotedProps.length) { - unquotedProps.forEach((property) => { - context.report({ - node: property, - messageId: "inconsistentlyQuotedProperty", - data: { key: property.key.name || property.key.value }, - fix: (fixer) => fixer.replaceText(property.key, getQuotedKey(property.key)) - }); - }); - } - } - return { - Property(node) { - if (MODE === "always" || !MODE) - checkOmittedQuotes(node); - if (MODE === "as-needed") - checkUnnecessaryQuotes(node); - }, - ObjectExpression(node) { - if (MODE === "consistent") - checkConsistency(node, false); - if (MODE === "consistent-as-needed") - checkConsistency(node, true); - } - }; - } -}); - -exports.quoteProps = quoteProps; diff --git a/tools/eslint/node_modules/@stylistic/eslint-plugin-js/dist/quotes.js b/tools/eslint/node_modules/@stylistic/eslint-plugin-js/dist/quotes.js deleted file mode 100644 index a8859cdf9b59bc..00000000000000 --- a/tools/eslint/node_modules/@stylistic/eslint-plugin-js/dist/quotes.js +++ /dev/null @@ -1,207 +0,0 @@ -'use strict'; - -var utils = require('./utils.js'); - -function switchQuote(str) { - const newQuote = this.quote; - const oldQuote = str[0]; - if (newQuote === oldQuote) - return str; - return newQuote + str.slice(1, -1).replace(/\\(\$\{|\r\n?|\n|.)|["'`]|\$\{|(\r\n?|\n)/gu, (match, escaped, newline) => { - if (escaped === oldQuote || oldQuote === "`" && escaped === "${") - return escaped; - if (match === newQuote || newQuote === "`" && match === "${") - return `\\${match}`; - if (newline && oldQuote === "`") - return "\\n"; - return match; - }) + newQuote; -} -const QUOTE_SETTINGS = { - double: { - quote: '"', - alternateQuote: "'", - description: "doublequote", - convert: switchQuote - }, - single: { - quote: "'", - alternateQuote: '"', - description: "singlequote", - convert: switchQuote - }, - backtick: { - quote: "`", - alternateQuote: '"', - description: "backtick", - convert: switchQuote - } -}; -const UNESCAPED_LINEBREAK_PATTERN = new RegExp(String.raw`(^|[^\\])(\\\\)*[${Array.from(utils.LINEBREAKS).join("")}]`, "u"); -const AVOID_ESCAPE = "avoid-escape"; -var quotes = utils.createRule({ - meta: { - type: "layout", - docs: { - description: "Enforce the consistent use of either backticks, double, or single quotes", - url: "https://eslint.style/rules/js/quotes" - }, - fixable: "code", - schema: [ - { - type: "string", - enum: ["single", "double", "backtick"] - }, - { - anyOf: [ - { - type: "string", - enum: ["avoid-escape"] - }, - { - type: "object", - properties: { - avoidEscape: { - type: "boolean" - }, - allowTemplateLiterals: { - type: "boolean" - }, - ignoreStringLiterals: { - type: "boolean" - } - }, - additionalProperties: false - } - ] - } - ], - messages: { - wrongQuotes: "Strings must use {{description}}." - } - }, - create(context) { - const quoteOption = context.options[0]; - const settings = QUOTE_SETTINGS[quoteOption || "double"]; - const options = context.options[1]; - const allowTemplateLiterals = options && typeof options === "object" && options.allowTemplateLiterals === true; - const ignoreStringLiterals = options && typeof options === "object" && options.ignoreStringLiterals === true; - const sourceCode = context.sourceCode; - let avoidEscape = options && typeof options === "object" && options.avoidEscape === true; - if (options === AVOID_ESCAPE) - avoidEscape = true; - function isJSXLiteral(node) { - if (!node.parent) - return false; - return node.parent.type === "JSXAttribute" || node.parent.type === "JSXElement" || node.parent.type === "JSXFragment"; - } - function isDirective(node) { - return node.type === "ExpressionStatement" && node.expression.type === "Literal" && typeof node.expression.value === "string" && !utils.isParenthesised(sourceCode, node.expression); - } - function isExpressionInOrJustAfterDirectivePrologue(node) { - if (!node.parent) - return false; - if (!utils.isTopLevelExpressionStatement(node.parent)) - return false; - const block = node.parent.parent; - if (!block || !("body" in block) || !Array.isArray(block.body)) - return false; - for (let i = 0; i < block.body.length; ++i) { - const statement = block.body[i]; - if (statement === node.parent) - return true; - if (!isDirective(statement)) - break; - } - return false; - } - function isAllowedAsNonBacktick(node) { - const parent = node.parent; - if (!parent) - return false; - switch (parent.type) { - case "ExpressionStatement": - return !utils.isParenthesised(sourceCode, node) && isExpressionInOrJustAfterDirectivePrologue(node); - case "Property": - case "PropertyDefinition": - case "MethodDefinition": - return parent.key === node && !parent.computed; - case "ImportDeclaration": - case "ExportNamedDeclaration": - return parent.source === node; - case "ExportAllDeclaration": - return parent.exported === node || parent.source === node; - case "ImportSpecifier": - return parent.imported === node; - case "ExportSpecifier": - return parent.local === node || parent.exported === node; - case "ImportAttribute": - return parent.value === node; - default: - return false; - } - } - function isUsingFeatureOfTemplateLiteral(node) { - const hasTag = node.parent.type === "TaggedTemplateExpression" && node === node.parent.quasi; - if (hasTag) - return true; - const hasStringInterpolation = node.expressions.length > 0; - if (hasStringInterpolation) - return true; - const isMultilineString = node.quasis.length >= 1 && UNESCAPED_LINEBREAK_PATTERN.test(node.quasis[0].value.raw); - if (isMultilineString) - return true; - return false; - } - return { - Literal(node) { - if (ignoreStringLiterals) - return; - const val = node.value; - const rawVal = node.raw; - if (settings && typeof val === "string") { - let isValid = quoteOption === "backtick" && isAllowedAsNonBacktick(node) || isJSXLiteral(node) || utils.isSurroundedBy(rawVal, settings.quote); - if (!isValid && avoidEscape) - isValid = utils.isSurroundedBy(rawVal, settings.alternateQuote) && rawVal.includes(settings.quote); - if (!isValid) { - context.report({ - node, - messageId: "wrongQuotes", - data: { - description: settings.description - }, - fix(fixer) { - if (quoteOption === "backtick" && utils.hasOctalOrNonOctalDecimalEscapeSequence(rawVal)) { - return null; - } - return fixer.replaceText(node, settings.convert(node.raw)); - } - }); - } - } - }, - TemplateLiteral(node) { - if (allowTemplateLiterals || quoteOption === "backtick" || isUsingFeatureOfTemplateLiteral(node)) { - return; - } - if (avoidEscape && sourceCode.getText(node).includes(settings.quote)) - return; - context.report({ - node, - messageId: "wrongQuotes", - data: { - description: settings.description - }, - fix(fixer) { - if (utils.isTopLevelExpressionStatement(node.parent) && !utils.isParenthesised(sourceCode, node)) { - return null; - } - return fixer.replaceText(node, settings.convert(sourceCode.getText(node))); - } - }); - } - }; - } -}); - -exports.quotes = quotes; diff --git a/tools/eslint/node_modules/@stylistic/eslint-plugin-js/dist/rest-spread-spacing.js b/tools/eslint/node_modules/@stylistic/eslint-plugin-js/dist/rest-spread-spacing.js deleted file mode 100644 index 901fe993bdeeaa..00000000000000 --- a/tools/eslint/node_modules/@stylistic/eslint-plugin-js/dist/rest-spread-spacing.js +++ /dev/null @@ -1,82 +0,0 @@ -'use strict'; - -var utils = require('./utils.js'); - -var restSpreadSpacing = utils.createRule({ - meta: { - type: "layout", - docs: { - description: "Enforce spacing between rest and spread operators and their expressions", - url: "https://eslint.style/rules/js/rest-spread-spacing" - }, - fixable: "whitespace", - schema: [ - { - type: "string", - enum: ["always", "never"] - } - ], - messages: { - unexpectedWhitespace: "Unexpected whitespace after {{type}} operator.", - expectedWhitespace: "Expected whitespace after {{type}} operator." - } - }, - create(context) { - const sourceCode = context.sourceCode; - const alwaysSpace = context.options[0] === "always"; - function checkWhiteSpace(node) { - const operator = sourceCode.getFirstToken(node); - const nextToken = sourceCode.getTokenAfter(operator); - const hasWhitespace = sourceCode.isSpaceBetweenTokens(operator, nextToken); - let type; - switch (node.type) { - case "SpreadElement": - type = "spread"; - if (node.parent.type === "ObjectExpression") - type += " property"; - break; - case "RestElement": - type = "rest"; - if (node.parent.type === "ObjectPattern") - type += " property"; - break; - default: - return; - } - if (alwaysSpace && !hasWhitespace) { - context.report({ - node, - loc: operator.loc, - messageId: "expectedWhitespace", - data: { - type - }, - fix(fixer) { - return fixer.replaceTextRange([operator.range[1], nextToken.range[0]], " "); - } - }); - } else if (!alwaysSpace && hasWhitespace) { - context.report({ - node, - loc: { - start: operator.loc.end, - end: nextToken.loc.start - }, - messageId: "unexpectedWhitespace", - data: { - type - }, - fix(fixer) { - return fixer.removeRange([operator.range[1], nextToken.range[0]]); - } - }); - } - } - return { - SpreadElement: checkWhiteSpace, - RestElement: checkWhiteSpace - }; - } -}); - -exports.restSpreadSpacing = restSpreadSpacing; diff --git a/tools/eslint/node_modules/@stylistic/eslint-plugin-js/dist/semi-spacing.js b/tools/eslint/node_modules/@stylistic/eslint-plugin-js/dist/semi-spacing.js deleted file mode 100644 index d767c23dbdbc02..00000000000000 --- a/tools/eslint/node_modules/@stylistic/eslint-plugin-js/dist/semi-spacing.js +++ /dev/null @@ -1,157 +0,0 @@ -'use strict'; - -var utils = require('./utils.js'); - -var semiSpacing = utils.createRule({ - meta: { - type: "layout", - docs: { - description: "Enforce consistent spacing before and after semicolons", - url: "https://eslint.style/rules/js/semi-spacing" - }, - fixable: "whitespace", - schema: [ - { - type: "object", - properties: { - before: { - type: "boolean", - default: false - }, - after: { - type: "boolean", - default: true - } - }, - additionalProperties: false - } - ], - messages: { - unexpectedWhitespaceBefore: "Unexpected whitespace before semicolon.", - unexpectedWhitespaceAfter: "Unexpected whitespace after semicolon.", - missingWhitespaceBefore: "Missing whitespace before semicolon.", - missingWhitespaceAfter: "Missing whitespace after semicolon." - } - }, - create(context) { - const config = context.options[0]; - const sourceCode = context.sourceCode; - let requireSpaceBefore = false; - let requireSpaceAfter = true; - if (typeof config === "object") { - requireSpaceBefore = config.before; - requireSpaceAfter = config.after; - } - function hasLeadingSpace(token) { - const tokenBefore = sourceCode.getTokenBefore(token); - return tokenBefore && utils.isTokenOnSameLine(tokenBefore, token) && sourceCode.isSpaceBetweenTokens(tokenBefore, token); - } - function hasTrailingSpace(token) { - const tokenAfter = sourceCode.getTokenAfter(token); - return tokenAfter && utils.isTokenOnSameLine(token, tokenAfter) && sourceCode.isSpaceBetweenTokens(token, tokenAfter); - } - function isLastTokenInCurrentLine(token) { - const tokenAfter = sourceCode.getTokenAfter(token); - return !(tokenAfter && utils.isTokenOnSameLine(token, tokenAfter)); - } - function isFirstTokenInCurrentLine(token) { - const tokenBefore = sourceCode.getTokenBefore(token); - return !(tokenBefore && utils.isTokenOnSameLine(token, tokenBefore)); - } - function isBeforeClosingParen(token) { - const nextToken = sourceCode.getTokenAfter(token); - return nextToken && utils.isClosingBraceToken(nextToken) || utils.isClosingParenToken(nextToken); - } - function checkSemicolonSpacing(token, node) { - if (utils.isSemicolonToken(token)) { - if (hasLeadingSpace(token)) { - if (!requireSpaceBefore) { - const tokenBefore = sourceCode.getTokenBefore(token); - const loc = { - start: tokenBefore.loc.end, - end: token.loc.start - }; - context.report({ - node, - loc, - messageId: "unexpectedWhitespaceBefore", - fix(fixer) { - return fixer.removeRange([tokenBefore.range[1], token.range[0]]); - } - }); - } - } else { - if (requireSpaceBefore) { - const loc = token.loc; - context.report({ - node, - loc, - messageId: "missingWhitespaceBefore", - fix(fixer) { - return fixer.insertTextBefore(token, " "); - } - }); - } - } - if (!isFirstTokenInCurrentLine(token) && !isLastTokenInCurrentLine(token) && !isBeforeClosingParen(token)) { - if (hasTrailingSpace(token)) { - if (!requireSpaceAfter) { - const tokenAfter = sourceCode.getTokenAfter(token); - const loc = { - start: token.loc.end, - end: tokenAfter.loc.start - }; - context.report({ - node, - loc, - messageId: "unexpectedWhitespaceAfter", - fix(fixer) { - return fixer.removeRange([token.range[1], tokenAfter.range[0]]); - } - }); - } - } else { - if (requireSpaceAfter) { - const loc = token.loc; - context.report({ - node, - loc, - messageId: "missingWhitespaceAfter", - fix(fixer) { - return fixer.insertTextAfter(token, " "); - } - }); - } - } - } - } - } - function checkNode(node) { - const token = sourceCode.getLastToken(node); - checkSemicolonSpacing(token, node); - } - return { - VariableDeclaration: checkNode, - ExpressionStatement: checkNode, - BreakStatement: checkNode, - ContinueStatement: checkNode, - DebuggerStatement: checkNode, - DoWhileStatement: checkNode, - ReturnStatement: checkNode, - ThrowStatement: checkNode, - ImportDeclaration: checkNode, - ExportNamedDeclaration: checkNode, - ExportAllDeclaration: checkNode, - ExportDefaultDeclaration: checkNode, - ForStatement(node) { - if (node.init) - checkSemicolonSpacing(sourceCode.getTokenAfter(node.init), node); - if (node.test) - checkSemicolonSpacing(sourceCode.getTokenAfter(node.test), node); - }, - PropertyDefinition: checkNode - }; - } -}); - -exports.semiSpacing = semiSpacing; diff --git a/tools/eslint/node_modules/@stylistic/eslint-plugin-js/dist/semi-style.js b/tools/eslint/node_modules/@stylistic/eslint-plugin-js/dist/semi-style.js deleted file mode 100644 index 1cc371ec1b46ad..00000000000000 --- a/tools/eslint/node_modules/@stylistic/eslint-plugin-js/dist/semi-style.js +++ /dev/null @@ -1,101 +0,0 @@ -'use strict'; - -var utils = require('./utils.js'); - -const SELECTOR = [ - "BreakStatement", - "ContinueStatement", - "DebuggerStatement", - "DoWhileStatement", - "ExportAllDeclaration", - "ExportDefaultDeclaration", - "ExportNamedDeclaration", - "ExpressionStatement", - "ImportDeclaration", - "ReturnStatement", - "ThrowStatement", - "VariableDeclaration", - "PropertyDefinition" -].join(","); -function getChildren(node) { - const t = node.type; - if (t === "BlockStatement" || t === "StaticBlock" || t === "Program" || t === "ClassBody") { - return node.body; - } - if (t === "SwitchCase") - return node.consequent; - return null; -} -function isLastChild(node) { - if (!node.parent) - return true; - const t = node.parent.type; - if (t === "IfStatement" && node.parent.consequent === node && node.parent.alternate) { - return true; - } - if (t === "DoWhileStatement") { - return true; - } - const nodeList = getChildren(node.parent); - return nodeList !== null && nodeList[nodeList.length - 1] === node; -} -var semiStyle = utils.createRule({ - meta: { - type: "layout", - docs: { - description: "Enforce location of semicolons", - url: "https://eslint.style/rules/js/semi-style" - }, - schema: [{ type: "string", enum: ["last", "first"] }], - fixable: "whitespace", - messages: { - expectedSemiColon: "Expected this semicolon to be at {{pos}}." - } - }, - create(context) { - const sourceCode = context.sourceCode; - const option = context.options[0] || "last"; - function check(semiToken, expected) { - const prevToken = sourceCode.getTokenBefore(semiToken); - const nextToken = sourceCode.getTokenAfter(semiToken); - const prevIsSameLine = !prevToken || utils.isTokenOnSameLine(prevToken, semiToken); - const nextIsSameLine = !nextToken || utils.isTokenOnSameLine(semiToken, nextToken); - if (expected === "last" && !prevIsSameLine || expected === "first" && !nextIsSameLine) { - context.report({ - loc: semiToken.loc, - messageId: "expectedSemiColon", - data: { - pos: expected === "last" ? "the end of the previous line" : "the beginning of the next line" - }, - fix(fixer) { - if (prevToken && nextToken && sourceCode.commentsExistBetween(prevToken, nextToken)) - return null; - const start = prevToken ? prevToken.range[1] : semiToken.range[0]; - const end = nextToken ? nextToken.range[0] : semiToken.range[1]; - const text = expected === "last" ? ";\n" : "\n;"; - return fixer.replaceTextRange([start, end], text); - } - }); - } - } - return { - [SELECTOR](node) { - if (option === "first" && isLastChild(node)) - return; - const lastToken = sourceCode.getLastToken(node); - if (utils.isSemicolonToken(lastToken)) - check(lastToken, option); - }, - ForStatement(node) { - const firstSemi = node.init && sourceCode.getTokenAfter(node.init, utils.isSemicolonToken); - const secondSemi = node.test && sourceCode.getTokenAfter(node.test, utils.isSemicolonToken); - if (firstSemi) - check(firstSemi, "last"); - if (secondSemi) - check(secondSemi, "last"); - } - }; - } -}); - -exports.semiStyle = semiStyle; diff --git a/tools/eslint/node_modules/@stylistic/eslint-plugin-js/dist/semi.js b/tools/eslint/node_modules/@stylistic/eslint-plugin-js/dist/semi.js deleted file mode 100644 index e5522cf7128a75..00000000000000 --- a/tools/eslint/node_modules/@stylistic/eslint-plugin-js/dist/semi.js +++ /dev/null @@ -1,230 +0,0 @@ -'use strict'; - -var utils = require('./utils.js'); - -var semi = utils.createRule({ - meta: { - type: "layout", - docs: { - description: "Require or disallow semicolons instead of ASI", - url: "https://eslint.style/rules/js/semi" - }, - fixable: "code", - schema: { - anyOf: [ - { - type: "array", - items: [ - { - type: "string", - enum: ["never"] - }, - { - type: "object", - properties: { - beforeStatementContinuationChars: { - type: "string", - enum: ["always", "any", "never"] - } - }, - additionalProperties: false - } - ], - minItems: 0, - maxItems: 2 - }, - { - type: "array", - items: [ - { - type: "string", - enum: ["always"] - }, - { - type: "object", - properties: { - omitLastInOneLineBlock: { type: "boolean" }, - omitLastInOneLineClassBody: { type: "boolean" } - }, - additionalProperties: false - } - ], - minItems: 0, - maxItems: 2 - } - ] - }, - messages: { - missingSemi: "Missing semicolon.", - extraSemi: "Extra semicolon." - } - }, - create(context) { - const OPT_OUT_PATTERN = /^[-[(/+`]/u; - const unsafeClassFieldNames = /* @__PURE__ */ new Set(["get", "set", "static"]); - const unsafeClassFieldFollowers = /* @__PURE__ */ new Set(["*", "in", "instanceof"]); - const options = context.options[1]; - const never = context.options[0] === "never"; - const exceptOneLine = Boolean(options && "omitLastInOneLineBlock" in options && options.omitLastInOneLineBlock); - const exceptOneLineClassBody = Boolean(options && "omitLastInOneLineClassBody" in options && options.omitLastInOneLineClassBody); - const beforeStatementContinuationChars = options && "beforeStatementContinuationChars" in options && options.beforeStatementContinuationChars || "any"; - const sourceCode = context.sourceCode; - function report(node, missing = false) { - const lastToken = sourceCode.getLastToken(node); - let messageId = "missingSemi"; - let fix, loc; - if (!missing) { - loc = { - start: lastToken.loc.end, - end: utils.getNextLocation(sourceCode, lastToken.loc.end) - }; - fix = function(fixer) { - return fixer.insertTextAfter(lastToken, ";"); - }; - } else { - messageId = "extraSemi"; - loc = lastToken.loc; - fix = function(fixer) { - return new utils.FixTracker(fixer, sourceCode).retainSurroundingTokens(lastToken).remove(lastToken); - }; - } - context.report({ - node, - loc, - messageId, - fix - }); - } - function isRedundantSemi(semiToken) { - const nextToken = sourceCode.getTokenAfter(semiToken); - return !nextToken || utils.isClosingBraceToken(nextToken) || utils.isSemicolonToken(nextToken); - } - function isEndOfArrowBlock(lastToken) { - if (!utils.isClosingBraceToken(lastToken)) - return false; - const node = sourceCode.getNodeByRangeIndex(lastToken.range[0]); - return node.type === "BlockStatement" && node.parent.type === "ArrowFunctionExpression"; - } - function maybeClassFieldAsiHazard(node) { - if (node.type !== "PropertyDefinition") - return false; - const needsNameCheck = !node.computed && node.key.type === "Identifier"; - if (needsNameCheck && "name" in node.key && unsafeClassFieldNames.has(node.key.name)) { - const isStaticStatic = node.static && node.key.name === "static"; - if (!isStaticStatic && !node.value) - return true; - } - const followingToken = sourceCode.getTokenAfter(node); - return unsafeClassFieldFollowers.has(followingToken.value); - } - function isOnSameLineWithNextToken(node) { - const prevToken = sourceCode.getLastToken(node, 1); - const nextToken = sourceCode.getTokenAfter(node); - return !!nextToken && utils.isTokenOnSameLine(prevToken, nextToken); - } - function maybeAsiHazardAfter(node) { - const t = node.type; - if (t === "DoWhileStatement" || t === "BreakStatement" || t === "ContinueStatement" || t === "DebuggerStatement" || t === "ImportDeclaration" || t === "ExportAllDeclaration") { - return false; - } - if (t === "ReturnStatement") - return Boolean(node.argument); - if (t === "ExportNamedDeclaration") - return Boolean(node.declaration); - const lastToken = sourceCode.getLastToken(node, 1); - if (isEndOfArrowBlock(lastToken)) - return false; - return true; - } - function maybeAsiHazardBefore(token) { - return Boolean(token) && OPT_OUT_PATTERN.test(token.value) && token.value !== "++" && token.value !== "--"; - } - function canRemoveSemicolon(node) { - const lastToken = sourceCode.getLastToken(node); - if (isRedundantSemi(lastToken)) - return true; - if (maybeClassFieldAsiHazard(node)) - return false; - if (isOnSameLineWithNextToken(node)) - return false; - if (node.type !== "PropertyDefinition" && beforeStatementContinuationChars === "never" && !maybeAsiHazardAfter(node)) { - return true; - } - const nextToken = sourceCode.getTokenAfter(node); - if (!maybeAsiHazardBefore(nextToken)) - return true; - return false; - } - function isLastInOneLinerBlock(node) { - const parent = node.parent; - const nextToken = sourceCode.getTokenAfter(node); - if (!nextToken || nextToken.value !== "}") - return false; - if (parent.type === "BlockStatement") - return parent.loc.start.line === parent.loc.end.line; - if (parent.type === "StaticBlock") { - const openingBrace = sourceCode.getFirstToken(parent, { skip: 1 }); - return openingBrace.loc.start.line === parent.loc.end.line; - } - return false; - } - function isLastInOneLinerClassBody(node) { - const parent = node.parent; - const nextToken = sourceCode.getTokenAfter(node); - if (!nextToken || nextToken.value !== "}") - return false; - if (parent.type === "ClassBody") - return parent.loc.start.line === parent.loc.end.line; - return false; - } - function checkForSemicolon(node) { - const lastToken = sourceCode.getLastToken(node); - const isSemi = utils.isSemicolonToken(lastToken); - if (never) { - const nextToken = sourceCode.getTokenAfter(node); - if (isSemi && canRemoveSemicolon(node)) { - report(node, true); - } else if (!isSemi && beforeStatementContinuationChars === "always" && node.type !== "PropertyDefinition" && maybeAsiHazardBefore(nextToken)) { - report(node); - } - } else { - const oneLinerBlock = exceptOneLine && isLastInOneLinerBlock(node); - const oneLinerClassBody = exceptOneLineClassBody && isLastInOneLinerClassBody(node); - const oneLinerBlockOrClassBody = oneLinerBlock || oneLinerClassBody; - if (isSemi && oneLinerBlockOrClassBody) - report(node, true); - else if (!isSemi && !oneLinerBlockOrClassBody) - report(node); - } - } - function checkForSemicolonForVariableDeclaration(node) { - const parent = node.parent; - if ((parent.type !== "ForStatement" || parent.init !== node) && (!/^For(?:In|Of)Statement/u.test(parent.type) || parent.left !== node)) { - checkForSemicolon(node); - } - } - return { - VariableDeclaration: checkForSemicolonForVariableDeclaration, - ExpressionStatement: checkForSemicolon, - ReturnStatement: checkForSemicolon, - ThrowStatement: checkForSemicolon, - DoWhileStatement: checkForSemicolon, - DebuggerStatement: checkForSemicolon, - BreakStatement: checkForSemicolon, - ContinueStatement: checkForSemicolon, - ImportDeclaration: checkForSemicolon, - ExportAllDeclaration: checkForSemicolon, - ExportNamedDeclaration(node) { - if (!node.declaration) - checkForSemicolon(node); - }, - ExportDefaultDeclaration(node) { - if (!/(?:Class|Function)Declaration/u.test(node.declaration.type)) - checkForSemicolon(node); - }, - PropertyDefinition: checkForSemicolon - }; - } -}); - -exports.semi = semi; diff --git a/tools/eslint/node_modules/@stylistic/eslint-plugin-js/dist/space-before-blocks.js b/tools/eslint/node_modules/@stylistic/eslint-plugin-js/dist/space-before-blocks.js deleted file mode 100644 index ce8a8da1fb9c53..00000000000000 --- a/tools/eslint/node_modules/@stylistic/eslint-plugin-js/dist/space-before-blocks.js +++ /dev/null @@ -1,129 +0,0 @@ -'use strict'; - -var utils = require('./utils.js'); - -function isFunctionBody(node) { - const parent = node.parent; - return node.type === "BlockStatement" && utils.isFunction(parent) && parent.body === node; -} -var spaceBeforeBlocks = utils.createRule({ - meta: { - type: "layout", - docs: { - description: "Enforce consistent spacing before blocks", - url: "https://eslint.style/rules/js/space-before-blocks" - }, - fixable: "whitespace", - schema: [ - { - oneOf: [ - { - type: "string", - enum: ["always", "never"] - }, - { - type: "object", - properties: { - keywords: { - type: "string", - enum: ["always", "never", "off"] - }, - functions: { - type: "string", - enum: ["always", "never", "off"] - }, - classes: { - type: "string", - enum: ["always", "never", "off"] - } - }, - additionalProperties: false - } - ] - } - ], - messages: { - unexpectedSpace: "Unexpected space before opening brace.", - missingSpace: "Missing space before opening brace." - } - }, - create(context) { - const config = context.options[0]; - const sourceCode = context.sourceCode; - let alwaysFunctions = true; - let alwaysKeywords = true; - let alwaysClasses = true; - let neverFunctions = false; - let neverKeywords = false; - let neverClasses = false; - if (typeof config === "object") { - alwaysFunctions = config.functions === "always"; - alwaysKeywords = config.keywords === "always"; - alwaysClasses = config.classes === "always"; - neverFunctions = config.functions === "never"; - neverKeywords = config.keywords === "never"; - neverClasses = config.classes === "never"; - } else if (config === "never") { - alwaysFunctions = false; - alwaysKeywords = false; - alwaysClasses = false; - neverFunctions = true; - neverKeywords = true; - neverClasses = true; - } - function isConflicted(precedingToken, node) { - return utils.isArrowToken(precedingToken) || utils.isKeywordToken(precedingToken) && !isFunctionBody(node) || utils.isColonToken(precedingToken) && "parent" in node && node.parent && node.parent.type === "SwitchCase" && precedingToken === utils.getSwitchCaseColonToken(node.parent, sourceCode); - } - function checkPrecedingSpace(node) { - const precedingToken = sourceCode.getTokenBefore(node); - if (precedingToken && !isConflicted(precedingToken, node) && utils.isTokenOnSameLine(precedingToken, node)) { - const hasSpace = sourceCode.isSpaceBetweenTokens(precedingToken, node); - let requireSpace; - let requireNoSpace; - if (isFunctionBody(node)) { - requireSpace = alwaysFunctions; - requireNoSpace = neverFunctions; - } else if (node.type === "ClassBody") { - requireSpace = alwaysClasses; - requireNoSpace = neverClasses; - } else { - requireSpace = alwaysKeywords; - requireNoSpace = neverKeywords; - } - if (requireSpace && !hasSpace) { - context.report({ - node, - messageId: "missingSpace", - fix(fixer) { - return fixer.insertTextBefore(node, " "); - } - }); - } else if (requireNoSpace && hasSpace) { - context.report({ - node, - messageId: "unexpectedSpace", - fix(fixer) { - return fixer.removeRange([precedingToken.range[1], node.range[0]]); - } - }); - } - } - } - function checkSpaceBeforeCaseBlock(node) { - const cases = node.cases; - let openingBrace; - if (cases.length > 0) - openingBrace = sourceCode.getTokenBefore(cases[0]); - else - openingBrace = sourceCode.getLastToken(node, 1); - checkPrecedingSpace(openingBrace); - } - return { - BlockStatement: checkPrecedingSpace, - ClassBody: checkPrecedingSpace, - SwitchStatement: checkSpaceBeforeCaseBlock - }; - } -}); - -exports.spaceBeforeBlocks = spaceBeforeBlocks; diff --git a/tools/eslint/node_modules/@stylistic/eslint-plugin-js/dist/space-before-function-paren.js b/tools/eslint/node_modules/@stylistic/eslint-plugin-js/dist/space-before-function-paren.js deleted file mode 100644 index 60b49c4b291135..00000000000000 --- a/tools/eslint/node_modules/@stylistic/eslint-plugin-js/dist/space-before-function-paren.js +++ /dev/null @@ -1,109 +0,0 @@ -'use strict'; - -var utils = require('./utils.js'); - -var spaceBeforeFunctionParen = utils.createRule({ - meta: { - type: "layout", - docs: { - description: "Enforce consistent spacing before `function` definition opening parenthesis", - url: "https://eslint.style/rules/js/space-before-function-paren" - }, - fixable: "whitespace", - schema: [ - { - oneOf: [ - { - type: "string", - enum: ["always", "never"] - }, - { - type: "object", - properties: { - anonymous: { - type: "string", - enum: ["always", "never", "ignore"] - }, - named: { - type: "string", - enum: ["always", "never", "ignore"] - }, - asyncArrow: { - type: "string", - enum: ["always", "never", "ignore"] - } - }, - additionalProperties: false - } - ] - } - ], - messages: { - unexpectedSpace: "Unexpected space before function parentheses.", - missingSpace: "Missing space before function parentheses." - } - }, - create(context) { - const sourceCode = context.sourceCode; - const baseConfig = typeof context.options[0] === "string" ? context.options[0] : "always"; - const overrideConfig = typeof context.options[0] === "object" ? context.options[0] : {}; - function isNamedFunction(node) { - if (node.id) - return true; - const parent = node.parent; - return parent.type === "MethodDefinition" || parent.type === "Property" && (parent.kind === "get" || parent.kind === "set" || parent.method); - } - function getConfigForFunction(node) { - if (node.type === "ArrowFunctionExpression") { - if (node.async && utils.isOpeningParenToken(sourceCode.getFirstToken(node, { skip: 1 }))) - return overrideConfig.asyncArrow || baseConfig; - } else if (isNamedFunction(node)) { - return overrideConfig.named || baseConfig; - } else if (!node.generator) { - return overrideConfig.anonymous || baseConfig; - } - return "ignore"; - } - function checkFunction(node) { - const functionConfig = getConfigForFunction(node); - if (functionConfig === "ignore") - return; - const rightToken = sourceCode.getFirstToken(node, utils.isOpeningParenToken); - const leftToken = sourceCode.getTokenBefore(rightToken); - const hasSpacing = sourceCode.isSpaceBetweenTokens(leftToken, rightToken); - if (hasSpacing && functionConfig === "never") { - context.report({ - node, - loc: { - start: leftToken.loc.end, - end: rightToken.loc.start - }, - messageId: "unexpectedSpace", - fix(fixer) { - const comments = sourceCode.getCommentsBefore(rightToken); - if (comments.some((comment) => comment.type === "Line")) - return null; - return fixer.replaceTextRange( - [leftToken.range[1], rightToken.range[0]], - comments.reduce((text, comment) => text + sourceCode.getText(comment), "") - ); - } - }); - } else if (!hasSpacing && functionConfig === "always") { - context.report({ - node, - loc: rightToken.loc, - messageId: "missingSpace", - fix: (fixer) => fixer.insertTextAfter(leftToken, " ") - }); - } - } - return { - ArrowFunctionExpression: checkFunction, - FunctionDeclaration: checkFunction, - FunctionExpression: checkFunction - }; - } -}); - -exports.spaceBeforeFunctionParen = spaceBeforeFunctionParen; diff --git a/tools/eslint/node_modules/@stylistic/eslint-plugin-js/dist/space-in-parens.js b/tools/eslint/node_modules/@stylistic/eslint-plugin-js/dist/space-in-parens.js deleted file mode 100644 index bdcbfdc77bc394..00000000000000 --- a/tools/eslint/node_modules/@stylistic/eslint-plugin-js/dist/space-in-parens.js +++ /dev/null @@ -1,183 +0,0 @@ -'use strict'; - -var utils = require('./utils.js'); - -var spaceInParens = utils.createRule({ - meta: { - type: "layout", - docs: { - description: "Enforce consistent spacing inside parentheses", - url: "https://eslint.style/rules/js/space-in-parens" - }, - fixable: "whitespace", - schema: [ - { - type: "string", - enum: ["always", "never"] - }, - { - type: "object", - properties: { - exceptions: { - type: "array", - items: { - type: "string", - enum: ["{}", "[]", "()", "empty"] - }, - uniqueItems: true - } - }, - additionalProperties: false - } - ], - messages: { - missingOpeningSpace: "There must be a space after this paren.", - missingClosingSpace: "There must be a space before this paren.", - rejectedOpeningSpace: "There should be no space after this paren.", - rejectedClosingSpace: "There should be no space before this paren." - } - }, - create(context) { - const ALWAYS = context.options[0] === "always"; - const exceptionsArrayOptions = context.options[1] && context.options[1].exceptions || []; - const options = { - braceException: false, - bracketException: false, - parenException: false, - empty: false - }; - let exceptions = { - openers: [], - closers: [] - }; - if (exceptionsArrayOptions.length) { - options.braceException = exceptionsArrayOptions.includes("{}"); - options.bracketException = exceptionsArrayOptions.includes("[]"); - options.parenException = exceptionsArrayOptions.includes("()"); - options.empty = exceptionsArrayOptions.includes("empty"); - } - function getExceptions() { - const openers = []; - const closers = []; - if (options.braceException) { - openers.push("{"); - closers.push("}"); - } - if (options.bracketException) { - openers.push("["); - closers.push("]"); - } - if (options.parenException) { - openers.push("("); - closers.push(")"); - } - if (options.empty) { - openers.push(")"); - closers.push("("); - } - return { - openers, - closers - }; - } - const sourceCode = context.sourceCode; - function isOpenerException(token) { - return exceptions.openers.includes(token.value); - } - function isCloserException(token) { - return exceptions.closers.includes(token.value); - } - function openerMissingSpace(openingParenToken, tokenAfterOpeningParen) { - if (sourceCode.isSpaceBetweenTokens(openingParenToken, tokenAfterOpeningParen)) - return false; - if (!options.empty && utils.isClosingParenToken(tokenAfterOpeningParen)) - return false; - if (ALWAYS) - return !isOpenerException(tokenAfterOpeningParen); - return isOpenerException(tokenAfterOpeningParen); - } - function openerRejectsSpace(openingParenToken, tokenAfterOpeningParen) { - if (!utils.isTokenOnSameLine(openingParenToken, tokenAfterOpeningParen)) - return false; - if (tokenAfterOpeningParen.type === "Line") - return false; - if (!sourceCode.isSpaceBetweenTokens(openingParenToken, tokenAfterOpeningParen)) - return false; - if (ALWAYS) - return isOpenerException(tokenAfterOpeningParen); - return !isOpenerException(tokenAfterOpeningParen); - } - function closerMissingSpace(tokenBeforeClosingParen, closingParenToken) { - if (sourceCode.isSpaceBetweenTokens(tokenBeforeClosingParen, closingParenToken)) - return false; - if (!options.empty && utils.isOpeningParenToken(tokenBeforeClosingParen)) - return false; - if (ALWAYS) - return !isCloserException(tokenBeforeClosingParen); - return isCloserException(tokenBeforeClosingParen); - } - function closerRejectsSpace(tokenBeforeClosingParen, closingParenToken) { - if (!utils.isTokenOnSameLine(tokenBeforeClosingParen, closingParenToken)) - return false; - if (!sourceCode.isSpaceBetweenTokens(tokenBeforeClosingParen, closingParenToken)) - return false; - if (ALWAYS) - return isCloserException(tokenBeforeClosingParen); - return !isCloserException(tokenBeforeClosingParen); - } - return { - Program: function checkParenSpaces(node) { - exceptions = getExceptions(); - const tokens = sourceCode.tokensAndComments; - tokens.forEach((token, i) => { - const prevToken = tokens[i - 1]; - const nextToken = tokens[i + 1]; - if (!utils.isOpeningParenToken(token) && !utils.isClosingParenToken(token)) - return; - if (token.value === "(" && openerMissingSpace(token, nextToken)) { - context.report({ - node, - loc: token.loc, - messageId: "missingOpeningSpace", - fix(fixer) { - return fixer.insertTextAfter(token, " "); - } - }); - } - if (token.value === "(" && openerRejectsSpace(token, nextToken)) { - context.report({ - node, - loc: { start: token.loc.end, end: nextToken.loc.start }, - messageId: "rejectedOpeningSpace", - fix(fixer) { - return fixer.removeRange([token.range[1], nextToken.range[0]]); - } - }); - } - if (token.value === ")" && closerMissingSpace(prevToken, token)) { - context.report({ - node, - loc: token.loc, - messageId: "missingClosingSpace", - fix(fixer) { - return fixer.insertTextBefore(token, " "); - } - }); - } - if (token.value === ")" && closerRejectsSpace(prevToken, token)) { - context.report({ - node, - loc: { start: prevToken.loc.end, end: token.loc.start }, - messageId: "rejectedClosingSpace", - fix(fixer) { - return fixer.removeRange([prevToken.range[1], token.range[0]]); - } - }); - } - }); - } - }; - } -}); - -exports.spaceInParens = spaceInParens; diff --git a/tools/eslint/node_modules/@stylistic/eslint-plugin-js/dist/space-infix-ops.js b/tools/eslint/node_modules/@stylistic/eslint-plugin-js/dist/space-infix-ops.js deleted file mode 100644 index c765f0b6b113bc..00000000000000 --- a/tools/eslint/node_modules/@stylistic/eslint-plugin-js/dist/space-infix-ops.js +++ /dev/null @@ -1,109 +0,0 @@ -'use strict'; - -var utils = require('./utils.js'); - -var spaceInfixOps = utils.createRule({ - meta: { - type: "layout", - docs: { - description: "Require spacing around infix operators", - url: "https://eslint.style/rules/js/space-infix-ops" - }, - fixable: "whitespace", - schema: [ - { - type: "object", - properties: { - int32Hint: { - type: "boolean", - default: false - } - }, - additionalProperties: false - } - ], - messages: { - missingSpace: "Operator '{{operator}}' must be spaced." - } - }, - create(context) { - const int32Hint = context.options[0] ? context.options[0].int32Hint === true : false; - const sourceCode = context.sourceCode; - function getFirstNonSpacedToken(left, right, op) { - const operator = sourceCode.getFirstTokenBetween(left, right, (token) => token.value === op); - const prev = sourceCode.getTokenBefore(operator); - const next = sourceCode.getTokenAfter(operator); - if (!sourceCode.isSpaceBetweenTokens(prev, operator) || !sourceCode.isSpaceBetweenTokens(operator, next)) - return operator; - return null; - } - function report(mainNode, culpritToken) { - context.report({ - node: mainNode, - loc: culpritToken.loc, - messageId: "missingSpace", - data: { - operator: culpritToken.value - }, - fix(fixer) { - const previousToken = sourceCode.getTokenBefore(culpritToken); - const afterToken = sourceCode.getTokenAfter(culpritToken); - let fixString = ""; - if (culpritToken.range[0] - previousToken.range[1] === 0) - fixString = " "; - fixString += culpritToken.value; - if (afterToken.range[0] - culpritToken.range[1] === 0) - fixString += " "; - return fixer.replaceText(culpritToken, fixString); - } - }); - } - function checkBinary(node) { - const leftNode = "typeAnnotation" in node.left && node.left.typeAnnotation ? node.left.typeAnnotation : node.left; - const rightNode = node.right; - const operator = "operator" in node && node.operator ? node.operator : "="; - const nonSpacedNode = getFirstNonSpacedToken(leftNode, rightNode, operator); - if (nonSpacedNode) { - if (!(int32Hint && sourceCode.getText(node).endsWith("|0"))) - report(node, nonSpacedNode); - } - } - function checkConditional(node) { - const nonSpacedConsequentNode = getFirstNonSpacedToken(node.test, node.consequent, "?"); - const nonSpacedAlternateNode = getFirstNonSpacedToken(node.consequent, node.alternate, ":"); - if (nonSpacedConsequentNode) - report(node, nonSpacedConsequentNode); - if (nonSpacedAlternateNode) - report(node, nonSpacedAlternateNode); - } - function checkVar(node) { - const leftNode = node.id.typeAnnotation ? node.id.typeAnnotation : node.id; - const rightNode = node.init; - if (rightNode) { - const nonSpacedNode = getFirstNonSpacedToken(leftNode, rightNode, "="); - if (nonSpacedNode) - report(node, nonSpacedNode); - } - } - return { - AssignmentExpression: checkBinary, - AssignmentPattern: checkBinary, - BinaryExpression: checkBinary, - LogicalExpression: checkBinary, - ConditionalExpression: checkConditional, - VariableDeclarator: checkVar, - PropertyDefinition(node) { - if (!node.value) - return; - const operatorToken = sourceCode.getTokenBefore(node.value, utils.isEqToken); - const leftToken = sourceCode.getTokenBefore(operatorToken); - const rightToken = sourceCode.getTokenAfter(operatorToken); - if (!sourceCode.isSpaceBetweenTokens(leftToken, operatorToken) || !sourceCode.isSpaceBetweenTokens(operatorToken, rightToken)) { - report(node, operatorToken); - } - } - }; - } -}); - -exports.spaceInfixOps = spaceInfixOps; diff --git a/tools/eslint/node_modules/@stylistic/eslint-plugin-js/dist/space-unary-ops.js b/tools/eslint/node_modules/@stylistic/eslint-plugin-js/dist/space-unary-ops.js deleted file mode 100644 index e41574c5755eaf..00000000000000 --- a/tools/eslint/node_modules/@stylistic/eslint-plugin-js/dist/space-unary-ops.js +++ /dev/null @@ -1,201 +0,0 @@ -'use strict'; - -var utils = require('./utils.js'); - -var spaceUnaryOps = utils.createRule({ - meta: { - type: "layout", - docs: { - description: "Enforce consistent spacing before or after unary operators", - url: "https://eslint.style/rules/js/space-unary-ops" - }, - fixable: "whitespace", - schema: [ - { - type: "object", - properties: { - words: { - type: "boolean", - default: true - }, - nonwords: { - type: "boolean", - default: false - }, - overrides: { - type: "object", - additionalProperties: { - type: "boolean" - } - } - }, - additionalProperties: false - } - ], - messages: { - unexpectedBefore: "Unexpected space before unary operator '{{operator}}'.", - unexpectedAfter: "Unexpected space after unary operator '{{operator}}'.", - unexpectedAfterWord: "Unexpected space after unary word operator '{{word}}'.", - wordOperator: "Unary word operator '{{word}}' must be followed by whitespace.", - operator: "Unary operator '{{operator}}' must be followed by whitespace.", - beforeUnaryExpressions: "Space is required before unary expressions '{{token}}'." - } - }, - create(context) { - const options = context.options[0] || { words: true, nonwords: false }; - const sourceCode = context.sourceCode; - function isFirstBangInBangBangExpression(node) { - return node && node.type === "UnaryExpression" && node.argument && node.argument.type === "UnaryExpression" && node.argument.operator === "!"; - } - function overrideExistsForOperator(operator) { - return options.overrides && Object.prototype.hasOwnProperty.call(options.overrides, operator); - } - function overrideEnforcesSpaces(operator) { - return options.overrides?.[operator]; - } - function verifyWordHasSpaces(node, firstToken, secondToken, word) { - if (secondToken.range[0] === firstToken.range[1]) { - context.report({ - node, - messageId: "wordOperator", - data: { - word - }, - fix(fixer) { - return fixer.insertTextAfter(firstToken, " "); - } - }); - } - } - function verifyWordDoesntHaveSpaces(node, firstToken, secondToken, word) { - if (utils.canTokensBeAdjacent(firstToken, secondToken)) { - if (secondToken.range[0] > firstToken.range[1]) { - context.report({ - node, - messageId: "unexpectedAfterWord", - data: { - word - }, - fix(fixer) { - return fixer.removeRange([firstToken.range[1], secondToken.range[0]]); - } - }); - } - } - } - function checkUnaryWordOperatorForSpaces(node, firstToken, secondToken, word) { - if (overrideExistsForOperator(word)) { - if (overrideEnforcesSpaces(word)) - verifyWordHasSpaces(node, firstToken, secondToken, word); - else - verifyWordDoesntHaveSpaces(node, firstToken, secondToken, word); - } else if (options.words) { - verifyWordHasSpaces(node, firstToken, secondToken, word); - } else { - verifyWordDoesntHaveSpaces(node, firstToken, secondToken, word); - } - } - function checkForSpacesAfterYield(node) { - const tokens = sourceCode.getFirstTokens(node, 3); - const word = "yield"; - if (!node.argument || node.delegate) - return; - checkUnaryWordOperatorForSpaces(node, tokens[0], tokens[1], word); - } - function checkForSpacesAfterAwait(node) { - const tokens = sourceCode.getFirstTokens(node, 3); - checkUnaryWordOperatorForSpaces(node, tokens[0], tokens[1], "await"); - } - function verifyNonWordsHaveSpaces(node, firstToken, secondToken) { - if ("prefix" in node && node.prefix) { - if (isFirstBangInBangBangExpression(node)) - return; - if (firstToken.range[1] === secondToken.range[0]) { - context.report({ - node, - messageId: "operator", - data: { - operator: firstToken.value - }, - fix(fixer) { - return fixer.insertTextAfter(firstToken, " "); - } - }); - } - } else { - if (firstToken.range[1] === secondToken.range[0]) { - context.report({ - node, - messageId: "beforeUnaryExpressions", - data: { - token: secondToken.value - }, - fix(fixer) { - return fixer.insertTextBefore(secondToken, " "); - } - }); - } - } - } - function verifyNonWordsDontHaveSpaces(node, firstToken, secondToken) { - if ("prefix" in node && node.prefix) { - if (secondToken.range[0] > firstToken.range[1]) { - context.report({ - node, - messageId: "unexpectedAfter", - data: { - operator: firstToken.value - }, - fix(fixer) { - if (utils.canTokensBeAdjacent(firstToken, secondToken)) - return fixer.removeRange([firstToken.range[1], secondToken.range[0]]); - return null; - } - }); - } - } else { - if (secondToken.range[0] > firstToken.range[1]) { - context.report({ - node, - messageId: "unexpectedBefore", - data: { - operator: secondToken.value - }, - fix(fixer) { - return fixer.removeRange([firstToken.range[1], secondToken.range[0]]); - } - }); - } - } - } - function checkForSpaces(node) { - const tokens = node.type === "UpdateExpression" && !node.prefix ? sourceCode.getLastTokens(node, 2) : sourceCode.getFirstTokens(node, 2); - const firstToken = tokens[0]; - const secondToken = tokens[1]; - if ((node.type === "NewExpression" || node.prefix) && firstToken.type === "Keyword") { - checkUnaryWordOperatorForSpaces(node, firstToken, secondToken, firstToken.value); - return; - } - const operator = "prefix" in node && node.prefix ? tokens[0].value : tokens[1].value; - if (overrideExistsForOperator(operator)) { - if (overrideEnforcesSpaces(operator)) - verifyNonWordsHaveSpaces(node, firstToken, secondToken); - else - verifyNonWordsDontHaveSpaces(node, firstToken, secondToken); - } else if (options.nonwords) { - verifyNonWordsHaveSpaces(node, firstToken, secondToken); - } else { - verifyNonWordsDontHaveSpaces(node, firstToken, secondToken); - } - } - return { - UnaryExpression: checkForSpaces, - UpdateExpression: checkForSpaces, - NewExpression: checkForSpaces, - YieldExpression: checkForSpacesAfterYield, - AwaitExpression: checkForSpacesAfterAwait - }; - } -}); - -exports.spaceUnaryOps = spaceUnaryOps; diff --git a/tools/eslint/node_modules/@stylistic/eslint-plugin-js/dist/spaced-comment.js b/tools/eslint/node_modules/@stylistic/eslint-plugin-js/dist/spaced-comment.js deleted file mode 100644 index c6c6ed0e71d3a6..00000000000000 --- a/tools/eslint/node_modules/@stylistic/eslint-plugin-js/dist/spaced-comment.js +++ /dev/null @@ -1,239 +0,0 @@ -'use strict'; - -var utils = require('./utils.js'); - -function escapeStringRegexp(string) { - if (typeof string !== 'string') { - throw new TypeError('Expected a string'); - } - - // Escape characters with special meaning either inside or outside character sets. - // Use a simple backslash escape when itโ€™s always valid, and a `\xnn` escape when the simpler form would be disallowed by Unicode patternsโ€™ stricter grammar. - return string - .replace(/[|\\{}()[\]^$+*?.]/g, '\\$&') - .replace(/-/g, '\\x2d'); -} - -function escape(s) { - return `(?:${escapeStringRegexp(s)})`; -} -function escapeAndRepeat(s) { - return `${escape(s)}+`; -} -function parseMarkersOption(markers) { - if (!markers.includes("*")) - return markers.concat("*"); - return markers; -} -function createExceptionsPattern(exceptions) { - let pattern = ""; - if (exceptions.length === 0) { - pattern += "\\s"; - } else { - pattern += "(?:\\s|"; - if (exceptions.length === 1) { - pattern += escapeAndRepeat(exceptions[0]); - } else { - pattern += "(?:"; - pattern += exceptions.map(escapeAndRepeat).join("|"); - pattern += ")"; - } - pattern += `(?:$|[${Array.from(utils.LINEBREAKS).join("")}]))`; - } - return pattern; -} -function createAlwaysStylePattern(markers, exceptions) { - let pattern = "^"; - if (markers.length === 1) { - pattern += escape(markers[0]); - } else { - pattern += "(?:"; - pattern += markers.map(escape).join("|"); - pattern += ")"; - } - pattern += "?"; - pattern += createExceptionsPattern(exceptions); - return new RegExp(pattern, "u"); -} -function createNeverStylePattern(markers) { - const pattern = `^(${markers.map(escape).join("|")})?[ ]+`; - return new RegExp(pattern, "u"); -} -var spacedComment = utils.createRule({ - meta: { - type: "layout", - docs: { - description: "Enforce consistent spacing after the `//` or `/*` in a comment", - url: "https://eslint.style/rules/js/spaced-comment" - }, - fixable: "whitespace", - schema: [ - { - type: "string", - enum: ["always", "never"] - }, - { - type: "object", - properties: { - exceptions: { - type: "array", - items: { - type: "string" - } - }, - markers: { - type: "array", - items: { - type: "string" - } - }, - line: { - type: "object", - properties: { - exceptions: { - type: "array", - items: { - type: "string" - } - }, - markers: { - type: "array", - items: { - type: "string" - } - } - }, - additionalProperties: false - }, - block: { - type: "object", - properties: { - exceptions: { - type: "array", - items: { - type: "string" - } - }, - markers: { - type: "array", - items: { - type: "string" - } - }, - balanced: { - type: "boolean", - default: false - } - }, - additionalProperties: false - } - }, - additionalProperties: false - } - ], - messages: { - unexpectedSpaceAfterMarker: "Unexpected space or tab after marker ({{refChar}}) in comment.", - expectedExceptionAfter: "Expected exception block, space or tab after '{{refChar}}' in comment.", - unexpectedSpaceBefore: "Unexpected space or tab before '*/' in comment.", - unexpectedSpaceAfter: "Unexpected space or tab after '{{refChar}}' in comment.", - expectedSpaceBefore: "Expected space or tab before '*/' in comment.", - expectedSpaceAfter: "Expected space or tab after '{{refChar}}' in comment." - } - }, - create(context) { - const sourceCode = context.sourceCode; - const requireSpace = context.options[0] !== "never"; - const config = context.options[1] || {}; - const balanced = config.block && config.block.balanced; - const styleRules = ["block", "line"].reduce((rule, type) => { - const nodeType = type; - const markers = parseMarkersOption(config[nodeType] && config[nodeType]?.markers || config.markers || []); - const exceptions = config[nodeType] && config[nodeType]?.exceptions || config.exceptions || []; - const endNeverPattern = "[ ]+$"; - rule[nodeType] = { - beginRegex: requireSpace ? createAlwaysStylePattern(markers, exceptions) : createNeverStylePattern(markers), - endRegex: balanced && requireSpace ? new RegExp(`${createExceptionsPattern(exceptions)}$`, "u") : new RegExp(endNeverPattern, "u"), - hasExceptions: exceptions.length > 0, - captureMarker: new RegExp(`^(${markers.map(escape).join("|")})`, "u"), - markers: new Set(markers) - }; - return rule; - }, {}); - function reportBegin(node, messageId, match, refChar) { - const type = node.type.toLowerCase(); - const commentIdentifier = type === "block" ? "/*" : "//"; - context.report({ - node, - fix(fixer) { - const start = node.range[0]; - let end = start + 2; - if (requireSpace) { - if (match) - end += match[0].length; - return fixer.insertTextAfterRange([start, end], " "); - } - if (match) - end += match[0].length; - return fixer.replaceTextRange([start, end], commentIdentifier + (match && match[1] ? match[1] : "")); - }, - messageId, - data: { refChar } - }); - } - function reportEnd(node, messageId, match) { - context.report({ - node, - fix(fixer) { - if (requireSpace) - return fixer.insertTextAfterRange([node.range[0], node.range[1] - 2], " "); - const end = node.range[1] - 2; - let start = end; - if (match) - start -= match[0].length; - return fixer.replaceTextRange([start, end], ""); - }, - messageId - }); - } - function checkCommentForSpace(node) { - const type = node.type.toLowerCase(); - const rule = styleRules[type]; - const commentIdentifier = type === "block" ? "/*" : "//"; - if (node.value.length === 0 || rule.markers.has(node.value)) - return; - if (type === "line" && (node.value.startsWith("/ token.type !== "Shebang").forEach(checkCommentForSpace); - } - }; - } -}); - -exports.spacedComment = spacedComment; diff --git a/tools/eslint/node_modules/@stylistic/eslint-plugin-js/dist/switch-colon-spacing.js b/tools/eslint/node_modules/@stylistic/eslint-plugin-js/dist/switch-colon-spacing.js deleted file mode 100644 index 0f47a070ecbb4c..00000000000000 --- a/tools/eslint/node_modules/@stylistic/eslint-plugin-js/dist/switch-colon-spacing.js +++ /dev/null @@ -1,81 +0,0 @@ -'use strict'; - -var utils = require('./utils.js'); - -var switchColonSpacing = utils.createRule({ - meta: { - type: "layout", - docs: { - description: "Enforce spacing around colons of switch statements", - url: "https://eslint.style/rules/js/switch-colon-spacing" - }, - schema: [ - { - type: "object", - properties: { - before: { type: "boolean", default: false }, - after: { type: "boolean", default: true } - }, - additionalProperties: false - } - ], - fixable: "whitespace", - messages: { - expectedBefore: "Expected space(s) before this colon.", - expectedAfter: "Expected space(s) after this colon.", - unexpectedBefore: "Unexpected space(s) before this colon.", - unexpectedAfter: "Unexpected space(s) after this colon." - } - }, - create(context) { - const sourceCode = context.sourceCode; - const options = context.options[0] || {}; - const beforeSpacing = options.before === true; - const afterSpacing = options.after !== false; - function isValidSpacing(left, right, expected) { - return utils.isClosingBraceToken(right) || !utils.isTokenOnSameLine(left, right) || sourceCode.isSpaceBetweenTokens(left, right) === expected; - } - function commentsExistBetween(left, right) { - return sourceCode.getFirstTokenBetween( - left, - right, - { - includeComments: true, - filter: utils.isCommentToken - } - ) !== null; - } - function fix(fixer, left, right, spacing) { - if (commentsExistBetween(left, right)) - return null; - if (spacing) - return fixer.insertTextAfter(left, " "); - return fixer.removeRange([left.range[1], right.range[0]]); - } - return { - SwitchCase(node) { - const colonToken = utils.getSwitchCaseColonToken(node, sourceCode); - const beforeToken = sourceCode.getTokenBefore(colonToken); - const afterToken = sourceCode.getTokenAfter(colonToken); - if (!isValidSpacing(beforeToken, colonToken, beforeSpacing)) { - context.report({ - node, - loc: colonToken.loc, - messageId: beforeSpacing ? "expectedBefore" : "unexpectedBefore", - fix: (fixer) => fix(fixer, beforeToken, colonToken, beforeSpacing) - }); - } - if (!isValidSpacing(colonToken, afterToken, afterSpacing)) { - context.report({ - node, - loc: colonToken.loc, - messageId: afterSpacing ? "expectedAfter" : "unexpectedAfter", - fix: (fixer) => fix(fixer, colonToken, afterToken, afterSpacing) - }); - } - } - }; - } -}); - -exports.switchColonSpacing = switchColonSpacing; diff --git a/tools/eslint/node_modules/@stylistic/eslint-plugin-js/dist/template-curly-spacing.js b/tools/eslint/node_modules/@stylistic/eslint-plugin-js/dist/template-curly-spacing.js deleted file mode 100644 index 2e142271a037e6..00000000000000 --- a/tools/eslint/node_modules/@stylistic/eslint-plugin-js/dist/template-curly-spacing.js +++ /dev/null @@ -1,101 +0,0 @@ -'use strict'; - -var utils = require('./utils.js'); - -var templateCurlySpacing = utils.createRule({ - meta: { - type: "layout", - docs: { - description: "Require or disallow spacing around embedded expressions of template strings", - url: "https://eslint.style/rules/js/template-curly-spacing" - }, - fixable: "whitespace", - schema: [ - { - type: "string", - enum: ["always", "never"] - } - ], - messages: { - expectedBefore: "Expected space(s) before '}'.", - expectedAfter: "Expected space(s) after '${'.", - unexpectedBefore: "Unexpected space(s) before '}'.", - unexpectedAfter: "Unexpected space(s) after '${'." - } - }, - create(context) { - const sourceCode = context.sourceCode; - const always = context.options[0] === "always"; - function checkSpacingBefore(token) { - if (!token.value.startsWith("}")) - return; - const prevToken = sourceCode.getTokenBefore(token, { includeComments: true }); - const hasSpace = sourceCode.isSpaceBetween(prevToken, token); - if (!utils.isTokenOnSameLine(prevToken, token)) - return; - if (always && !hasSpace) { - context.report({ - loc: { - start: token.loc.start, - end: { - line: token.loc.start.line, - column: token.loc.start.column + 1 - } - }, - messageId: "expectedBefore", - fix: (fixer) => fixer.insertTextBefore(token, " ") - }); - } - if (!always && hasSpace) { - context.report({ - loc: { - start: prevToken.loc.end, - end: token.loc.start - }, - messageId: "unexpectedBefore", - fix: (fixer) => fixer.removeRange([prevToken.range[1], token.range[0]]) - }); - } - } - function checkSpacingAfter(token) { - if (!token.value.endsWith("${")) - return; - const nextToken = sourceCode.getTokenAfter(token, { includeComments: true }); - const hasSpace = sourceCode.isSpaceBetween(token, nextToken); - if (!utils.isTokenOnSameLine(token, nextToken)) - return; - if (always && !hasSpace) { - context.report({ - loc: { - start: { - line: token.loc.end.line, - column: token.loc.end.column - 2 - }, - end: token.loc.end - }, - messageId: "expectedAfter", - fix: (fixer) => fixer.insertTextAfter(token, " ") - }); - } - if (!always && hasSpace) { - context.report({ - loc: { - start: token.loc.end, - end: nextToken.loc.start - }, - messageId: "unexpectedAfter", - fix: (fixer) => fixer.removeRange([token.range[1], nextToken.range[0]]) - }); - } - } - return { - TemplateElement(node) { - const token = sourceCode.getFirstToken(node); - checkSpacingBefore(token); - checkSpacingAfter(token); - } - }; - } -}); - -exports.templateCurlySpacing = templateCurlySpacing; diff --git a/tools/eslint/node_modules/@stylistic/eslint-plugin-js/dist/template-tag-spacing.js b/tools/eslint/node_modules/@stylistic/eslint-plugin-js/dist/template-tag-spacing.js deleted file mode 100644 index 0b650d56b63888..00000000000000 --- a/tools/eslint/node_modules/@stylistic/eslint-plugin-js/dist/template-tag-spacing.js +++ /dev/null @@ -1,69 +0,0 @@ -'use strict'; - -var utils = require('./utils.js'); - -var templateTagSpacing = utils.createRule({ - meta: { - type: "layout", - docs: { - description: "Require or disallow spacing between template tags and their literals", - url: "https://eslint.style/rules/js/template-tag-spacing" - }, - fixable: "whitespace", - schema: [ - { - type: "string", - enum: ["always", "never"] - } - ], - messages: { - unexpected: "Unexpected space between template tag and template literal.", - missing: "Missing space between template tag and template literal." - } - }, - create(context) { - const never = context.options[0] !== "always"; - const sourceCode = context.sourceCode; - function checkSpacing(node) { - const tagToken = sourceCode.getTokenBefore(node.quasi); - const literalToken = sourceCode.getFirstToken(node.quasi); - const hasWhitespace = sourceCode.isSpaceBetweenTokens(tagToken, literalToken); - if (never && hasWhitespace) { - context.report({ - node, - loc: { - start: tagToken.loc.end, - end: literalToken.loc.start - }, - messageId: "unexpected", - fix(fixer) { - const comments = sourceCode.getCommentsBefore(node.quasi); - if (comments.some((comment) => comment.type === "Line")) - return null; - return fixer.replaceTextRange( - [tagToken.range[1], literalToken.range[0]], - comments.reduce((text, comment) => text + sourceCode.getText(comment), "") - ); - } - }); - } else if (!never && !hasWhitespace) { - context.report({ - node, - loc: { - start: node.loc.start, - end: literalToken.loc.start - }, - messageId: "missing", - fix(fixer) { - return fixer.insertTextAfter(tagToken, " "); - } - }); - } - } - return { - TaggedTemplateExpression: checkSpacing - }; - } -}); - -exports.templateTagSpacing = templateTagSpacing; diff --git a/tools/eslint/node_modules/@stylistic/eslint-plugin-js/dist/utils.js b/tools/eslint/node_modules/@stylistic/eslint-plugin-js/dist/utils.js deleted file mode 100644 index c3aa922d40fdd5..00000000000000 --- a/tools/eslint/node_modules/@stylistic/eslint-plugin-js/dist/utils.js +++ /dev/null @@ -1,1113 +0,0 @@ -'use strict'; - -var eslintVisitorKeys = require('eslint-visitor-keys'); -var espree = require('espree'); - -const anyFunctionPattern = /^(?:Function(?:Declaration|Expression)|ArrowFunctionExpression)$/u; -const COMMENTS_IGNORE_PATTERN = /^\s*(?:eslint|jshint\s+|jslint\s+|istanbul\s+|globals?\s+|exported\s+|jscs)/u; -const LINEBREAKS = /* @__PURE__ */ new Set(["\r\n", "\r", "\n", "\u2028", "\u2029"]); -const LINEBREAK_MATCHER = /\r\n|[\r\n\u2028\u2029]/u; -const STATEMENT_LIST_PARENTS = /* @__PURE__ */ new Set(["Program", "BlockStatement", "StaticBlock", "SwitchCase"]); -const DECIMAL_INTEGER_PATTERN = /^(?:0|0[0-7]*[89]\d*|[1-9](?:_?\d)*)$/u; -const OCTAL_OR_NON_OCTAL_DECIMAL_ESCAPE_PATTERN = /^(?:[^\\]|\\.)*\\(?:[1-9]|0\d)/su; -function createGlobalLinebreakMatcher() { - return new RegExp(LINEBREAK_MATCHER.source, "gu"); -} -function getUpperFunction(node) { - for (let currentNode = node; currentNode; currentNode = currentNode.parent) { - if (anyFunctionPattern.test(currentNode.type)) - return currentNode; - } - return null; -} -function isFunction(node) { - return Boolean(node && anyFunctionPattern.test(node.type)); -} -function isNullLiteral(node) { - return node.type === "Literal" && node.value === null && !("regex" in node) && !("bigint" in node); -} -function getStaticStringValue(node) { - switch (node.type) { - case "Literal": - if (node.value === null) { - if (isNullLiteral(node)) - return String(node.value); - if ("regex" in node && node.regex) - return `/${node.regex.pattern}/${node.regex.flags}`; - if ("bigint" in node && node.bigint) - return node.bigint; - } else { - return String(node.value); - } - break; - case "TemplateLiteral": - if (node.expressions.length === 0 && node.quasis.length === 1) - return node.quasis[0].value.cooked; - break; - } - return null; -} -function getStaticPropertyName(node) { - let prop; - if (node) { - switch (node.type) { - case "ChainExpression": - return getStaticPropertyName(node.expression); - case "Property": - case "PropertyDefinition": - case "MethodDefinition": - prop = node.key; - break; - case "MemberExpression": - prop = node.property; - break; - } - } - if (prop) { - if (prop.type === "Identifier" && !("computed" in node && node.computed)) - return prop.name; - return getStaticStringValue(prop); - } - return null; -} -function skipChainExpression(node) { - return node && node.type === "ChainExpression" ? node.expression : node; -} -function negate$1(f) { - return (token) => !f(token); -} -function isParenthesised(sourceCode, node) { - const previousToken = sourceCode.getTokenBefore(node); - const nextToken = sourceCode.getTokenAfter(node); - return !!previousToken && !!nextToken && previousToken.value === "(" && previousToken.range[1] <= node.range[0] && nextToken.value === ")" && nextToken.range[0] >= node.range[1]; -} -function isEqToken(token) { - return token.value === "=" && token.type === "Punctuator"; -} -function isArrowToken$1(token) { - return token.value === "=>" && token.type === "Punctuator"; -} -function isCommaToken$1(token) { - return token.value === "," && token.type === "Punctuator"; -} -function isQuestionDotToken(token) { - return token.value === "?." && token.type === "Punctuator"; -} -function isSemicolonToken$1(token) { - return token.value === ";" && token.type === "Punctuator"; -} -function isColonToken$1(token) { - return token.value === ":" && token.type === "Punctuator"; -} -function isOpeningParenToken$1(token) { - return token.value === "(" && token.type === "Punctuator"; -} -function isClosingParenToken$1(token) { - return token.value === ")" && token.type === "Punctuator"; -} -function isOpeningBracketToken$1(token) { - return token.value === "[" && token.type === "Punctuator"; -} -function isClosingBracketToken$1(token) { - return token.value === "]" && token.type === "Punctuator"; -} -function isOpeningBraceToken$1(token) { - return token.value === "{" && token.type === "Punctuator"; -} -function isClosingBraceToken$1(token) { - return token.value === "}" && token.type === "Punctuator"; -} -function isCommentToken$1(token) { - if (!token) - return false; - return token.type === "Line" || token.type === "Block" || token.type === "Shebang"; -} -function isKeywordToken(token) { - return token.type === "Keyword"; -} -function isLogicalExpression(node) { - return node.type === "LogicalExpression" && (node.operator === "&&" || node.operator === "||"); -} -function isCoalesceExpression(node) { - return node.type === "LogicalExpression" && node.operator === "??"; -} -function isMixedLogicalAndCoalesceExpressions(left, right) { - return isLogicalExpression(left) && isCoalesceExpression(right) || isCoalesceExpression(left) && isLogicalExpression(right); -} -function getSwitchCaseColonToken(node, sourceCode) { - if ("test" in node && node.test) - return sourceCode.getTokenAfter(node.test, (token) => isColonToken$1(token)); - return sourceCode.getFirstToken(node, 1); -} -function isTopLevelExpressionStatement(node) { - if (node.type !== "ExpressionStatement") - return false; - const parent = node.parent; - return parent.type === "Program" || parent.type === "BlockStatement" && isFunction(parent.parent); -} -function isDirective(node) { - return node.type === "ExpressionStatement" && typeof node.directive === "string"; -} -function isTokenOnSameLine(left, right) { - return left?.loc?.end.line === right?.loc?.start.line; -} -const isNotClosingParenToken = negate$1(isClosingParenToken$1); -const isNotCommaToken = negate$1(isCommaToken$1); -const isNotQuestionDotToken = negate$1(isQuestionDotToken); -const isNotOpeningParenToken = negate$1(isOpeningParenToken$1); -const isNotSemicolonToken = negate$1(isSemicolonToken$1); -function isStringLiteral(node) { - return node.type === "Literal" && typeof node.value === "string" || node.type === "TemplateLiteral"; -} -function isSurroundedBy(val, character) { - return val[0] === character && val[val.length - 1] === character; -} -function getPrecedence(node) { - switch (node.type) { - case "SequenceExpression": - return 0; - case "AssignmentExpression": - case "ArrowFunctionExpression": - case "YieldExpression": - return 1; - case "ConditionalExpression": - return 3; - case "LogicalExpression": - switch (node.operator) { - case "||": - case "??": - return 4; - case "&&": - return 5; - } - case "BinaryExpression": - switch (node.operator) { - case "|": - return 6; - case "^": - return 7; - case "&": - return 8; - case "==": - case "!=": - case "===": - case "!==": - return 9; - case "<": - case "<=": - case ">": - case ">=": - case "in": - case "instanceof": - return 10; - case "<<": - case ">>": - case ">>>": - return 11; - case "+": - case "-": - return 12; - case "*": - case "/": - case "%": - return 13; - case "**": - return 15; - } - case "UnaryExpression": - case "AwaitExpression": - return 16; - case "UpdateExpression": - return 17; - case "CallExpression": - case "ChainExpression": - case "ImportExpression": - return 18; - case "NewExpression": - return 19; - default: - if (node.type in eslintVisitorKeys.KEYS) - return 20; - return -1; - } -} -function isDecimalInteger(node) { - return node.type === "Literal" && typeof node.value === "number" && DECIMAL_INTEGER_PATTERN.test(node.raw); -} -function isDecimalIntegerNumericToken(token) { - return token.type === "Numeric" && DECIMAL_INTEGER_PATTERN.test(token.value); -} -function getNextLocation(sourceCode, { column, line }) { - if (column < sourceCode.lines[line - 1].length) { - return { - column: column + 1, - line - }; - } - if (line < sourceCode.lines.length) { - return { - column: 0, - line: line + 1 - }; - } - return null; -} -function isNumericLiteral(node) { - return node.type === "Literal" && (typeof node.value === "number" || Boolean("bigint" in node && node.bigint)); -} -function canTokensBeAdjacent(leftValue, rightValue) { - const espreeOptions = { - comment: true, - ecmaVersion: espree.latestEcmaVersion, - range: true - }; - let leftToken; - if (typeof leftValue === "string") { - let tokens; - try { - tokens = espree.tokenize(leftValue, espreeOptions); - } catch { - return false; - } - const comments = tokens.comments; - leftToken = tokens[tokens.length - 1]; - if (comments.length) { - const lastComment = comments[comments.length - 1]; - if (!leftToken || lastComment.range[0] > leftToken.range[0]) - leftToken = lastComment; - } - } else { - leftToken = leftValue; - } - if (leftToken.type === "Shebang" || leftToken.type === "Hashbang") - return false; - let rightToken; - if (typeof rightValue === "string") { - let tokens; - try { - tokens = espree.tokenize(rightValue, espreeOptions); - } catch { - return false; - } - const comments = tokens.comments; - rightToken = tokens[0]; - if (comments.length) { - const firstComment = comments[0]; - if (!rightToken || firstComment.range[0] < rightToken.range[0]) - rightToken = firstComment; - } - } else { - rightToken = rightValue; - } - if (leftToken.type === "Punctuator" || rightToken.type === "Punctuator") { - if (leftToken.type === "Punctuator" && rightToken.type === "Punctuator") { - const PLUS_TOKENS = /* @__PURE__ */ new Set(["+", "++"]); - const MINUS_TOKENS = /* @__PURE__ */ new Set(["-", "--"]); - return !(PLUS_TOKENS.has(leftToken.value) && PLUS_TOKENS.has(rightToken.value) || MINUS_TOKENS.has(leftToken.value) && MINUS_TOKENS.has(rightToken.value)); - } - if (leftToken.type === "Punctuator" && leftToken.value === "/") - return !["Block", "Line", "RegularExpression"].includes(rightToken.type); - return true; - } - if (leftToken.type === "String" || rightToken.type === "String" || leftToken.type === "Template" || rightToken.type === "Template") - return true; - if (leftToken.type !== "Numeric" && rightToken.type === "Numeric" && rightToken.value.startsWith(".")) - return true; - if (leftToken.type === "Block" || rightToken.type === "Block" || rightToken.type === "Line") - return true; - if (rightToken.type === "PrivateIdentifier") - return true; - return false; -} -function hasOctalOrNonOctalDecimalEscapeSequence(rawString) { - return OCTAL_OR_NON_OCTAL_DECIMAL_ESCAPE_PATTERN.test(rawString); -} - -function createRule(rule) { - return rule; -} - -const ASCII_REGEX = /^[\u0000-\u007F]*$/u; -let segmenter; -function getGraphemeCount(value) { - if (ASCII_REGEX.test(value)) - return value.length; - if (!segmenter) - segmenter = new Intl.Segmenter(); - return [...segmenter.segment(value)].length; -} - -var keywords = [ - "abstract", - "boolean", - "break", - "byte", - "case", - "catch", - "char", - "class", - "const", - "continue", - "debugger", - "default", - "delete", - "do", - "double", - "else", - "enum", - "export", - "extends", - "false", - "final", - "finally", - "float", - "for", - "function", - "goto", - "if", - "implements", - "import", - "in", - "instanceof", - "int", - "interface", - "long", - "native", - "new", - "null", - "package", - "private", - "protected", - "public", - "return", - "short", - "static", - "super", - "switch", - "synchronized", - "this", - "throw", - "throws", - "transient", - "true", - "try", - "typeof", - "var", - "void", - "volatile", - "while", - "with" -]; - -/** - * Negate the result of `this` calling. - * @param {Token} token The token to check. - * @returns {boolean} `true` if the result of `this(token)` is `false`. - */ -function negate0(token) { - return !this(token) //eslint-disable-line no-invalid-this -} - -/** - * Creates the negate function of the given function. - * @param {function(Token):boolean} f - The function to negate. - * @returns {function(Token):boolean} Negated function. - */ -function negate(f) { - return negate0.bind(f) -} - -/** - * Checks if the given token is a PunctuatorToken with the given value - * @param {Token} token - The token to check. - * @param {string} value - The value to check. - * @returns {boolean} `true` if the token is a PunctuatorToken with the given value. - */ -function isPunctuatorTokenWithValue(token, value) { - return token.type === "Punctuator" && token.value === value -} - -/** - * Checks if the given token is an arrow token or not. - * @param {Token} token - The token to check. - * @returns {boolean} `true` if the token is an arrow token. - */ -function isArrowToken(token) { - return isPunctuatorTokenWithValue(token, "=>") -} - -/** - * Checks if the given token is a comma token or not. - * @param {Token} token - The token to check. - * @returns {boolean} `true` if the token is a comma token. - */ -function isCommaToken(token) { - return isPunctuatorTokenWithValue(token, ",") -} - -/** - * Checks if the given token is a semicolon token or not. - * @param {Token} token - The token to check. - * @returns {boolean} `true` if the token is a semicolon token. - */ -function isSemicolonToken(token) { - return isPunctuatorTokenWithValue(token, ";") -} - -/** - * Checks if the given token is a colon token or not. - * @param {Token} token - The token to check. - * @returns {boolean} `true` if the token is a colon token. - */ -function isColonToken(token) { - return isPunctuatorTokenWithValue(token, ":") -} - -/** - * Checks if the given token is an opening parenthesis token or not. - * @param {Token} token - The token to check. - * @returns {boolean} `true` if the token is an opening parenthesis token. - */ -function isOpeningParenToken(token) { - return isPunctuatorTokenWithValue(token, "(") -} - -/** - * Checks if the given token is a closing parenthesis token or not. - * @param {Token} token - The token to check. - * @returns {boolean} `true` if the token is a closing parenthesis token. - */ -function isClosingParenToken(token) { - return isPunctuatorTokenWithValue(token, ")") -} - -/** - * Checks if the given token is an opening square bracket token or not. - * @param {Token} token - The token to check. - * @returns {boolean} `true` if the token is an opening square bracket token. - */ -function isOpeningBracketToken(token) { - return isPunctuatorTokenWithValue(token, "[") -} - -/** - * Checks if the given token is a closing square bracket token or not. - * @param {Token} token - The token to check. - * @returns {boolean} `true` if the token is a closing square bracket token. - */ -function isClosingBracketToken(token) { - return isPunctuatorTokenWithValue(token, "]") -} - -/** - * Checks if the given token is an opening brace token or not. - * @param {Token} token - The token to check. - * @returns {boolean} `true` if the token is an opening brace token. - */ -function isOpeningBraceToken(token) { - return isPunctuatorTokenWithValue(token, "{") -} - -/** - * Checks if the given token is a closing brace token or not. - * @param {Token} token - The token to check. - * @returns {boolean} `true` if the token is a closing brace token. - */ -function isClosingBraceToken(token) { - return isPunctuatorTokenWithValue(token, "}") -} - -/** - * Checks if the given token is a comment token or not. - * @param {Token} token - The token to check. - * @returns {boolean} `true` if the token is a comment token. - */ -function isCommentToken(token) { - return ["Block", "Line", "Shebang"].includes(token.type) -} - -negate(isArrowToken); -negate(isCommaToken); -negate(isSemicolonToken); -negate(isColonToken); -negate(isOpeningParenToken); -negate(isClosingParenToken); -negate(isOpeningBracketToken); -negate(isClosingBracketToken); -negate(isOpeningBraceToken); -negate(isClosingBraceToken); -negate(isCommentToken); - -Object.freeze( - new Set([ - "Array", - "ArrayBuffer", - "BigInt", - "BigInt64Array", - "BigUint64Array", - "Boolean", - "DataView", - "Date", - "decodeURI", - "decodeURIComponent", - "encodeURI", - "encodeURIComponent", - "escape", - "Float32Array", - "Float64Array", - "Function", - "Infinity", - "Int16Array", - "Int32Array", - "Int8Array", - "isFinite", - "isNaN", - "isPrototypeOf", - "JSON", - "Map", - "Math", - "NaN", - "Number", - "Object", - "parseFloat", - "parseInt", - "Promise", - "Proxy", - "Reflect", - "RegExp", - "Set", - "String", - "Symbol", - "Uint16Array", - "Uint32Array", - "Uint8Array", - "Uint8ClampedArray", - "undefined", - "unescape", - "WeakMap", - "WeakSet", - ]), -); -new Set( - [ - Array.isArray, - Array.of, - Array.prototype.at, - Array.prototype.concat, - Array.prototype.entries, - Array.prototype.every, - Array.prototype.filter, - Array.prototype.find, - Array.prototype.findIndex, - Array.prototype.flat, - Array.prototype.includes, - Array.prototype.indexOf, - Array.prototype.join, - Array.prototype.keys, - Array.prototype.lastIndexOf, - Array.prototype.slice, - Array.prototype.some, - Array.prototype.toString, - Array.prototype.values, - typeof BigInt === "function" ? BigInt : undefined, - Boolean, - Date, - Date.parse, - decodeURI, - decodeURIComponent, - encodeURI, - encodeURIComponent, - escape, - isFinite, - isNaN, - isPrototypeOf, - Map, - Map.prototype.entries, - Map.prototype.get, - Map.prototype.has, - Map.prototype.keys, - Map.prototype.values, - ...Object.getOwnPropertyNames(Math) - .filter((k) => k !== "random") - .map((k) => Math[k]) - .filter((f) => typeof f === "function"), - Number, - Number.isFinite, - Number.isNaN, - Number.parseFloat, - Number.parseInt, - Number.prototype.toExponential, - Number.prototype.toFixed, - Number.prototype.toPrecision, - Number.prototype.toString, - Object, - Object.entries, - Object.is, - Object.isExtensible, - Object.isFrozen, - Object.isSealed, - Object.keys, - Object.values, - parseFloat, - parseInt, - RegExp, - Set, - Set.prototype.entries, - Set.prototype.has, - Set.prototype.keys, - Set.prototype.values, - String, - String.fromCharCode, - String.fromCodePoint, - String.raw, - String.prototype.at, - String.prototype.charAt, - String.prototype.charCodeAt, - String.prototype.codePointAt, - String.prototype.concat, - String.prototype.endsWith, - String.prototype.includes, - String.prototype.indexOf, - String.prototype.lastIndexOf, - String.prototype.normalize, - String.prototype.padEnd, - String.prototype.padStart, - String.prototype.slice, - String.prototype.startsWith, - String.prototype.substr, - String.prototype.substring, - String.prototype.toLowerCase, - String.prototype.toString, - String.prototype.toUpperCase, - String.prototype.trim, - String.prototype.trimEnd, - String.prototype.trimLeft, - String.prototype.trimRight, - String.prototype.trimStart, - Symbol.for, - Symbol.keyFor, - unescape, - ].filter((f) => typeof f === "function"), -); - -const typeConversionBinaryOps = Object.freeze( - new Set([ - "==", - "!=", - "<", - "<=", - ">", - ">=", - "<<", - ">>", - ">>>", - "+", - "-", - "*", - "/", - "%", - "|", - "^", - "&", - "in", - ]), -); -const typeConversionUnaryOps = Object.freeze(new Set(["-", "+", "!", "~"])); - -/** - * Check whether the given value is an ASTNode or not. - * @param {any} x The value to check. - * @returns {boolean} `true` if the value is an ASTNode. - */ -function isNode(x) { - return x !== null && typeof x === "object" && typeof x.type === "string" -} - -Object.freeze( - Object.assign(Object.create(null), { - $visit(node, options, visitorKeys) { - const { type } = node; - - if (typeof this[type] === "function") { - return this[type](node, options, visitorKeys) - } - - return this.$visitChildren(node, options, visitorKeys) - }, - - $visitChildren(node, options, visitorKeys) { - const { type } = node; - - for (const key of visitorKeys[type] || eslintVisitorKeys.getKeys(node)) { - const value = node[key]; - - if (Array.isArray(value)) { - for (const element of value) { - if ( - isNode(element) && - this.$visit(element, options, visitorKeys) - ) { - return true - } - } - } else if ( - isNode(value) && - this.$visit(value, options, visitorKeys) - ) { - return true - } - } - - return false - }, - - ArrowFunctionExpression() { - return false - }, - AssignmentExpression() { - return true - }, - AwaitExpression() { - return true - }, - BinaryExpression(node, options, visitorKeys) { - if ( - options.considerImplicitTypeConversion && - typeConversionBinaryOps.has(node.operator) && - (node.left.type !== "Literal" || node.right.type !== "Literal") - ) { - return true - } - return this.$visitChildren(node, options, visitorKeys) - }, - CallExpression() { - return true - }, - FunctionExpression() { - return false - }, - ImportExpression() { - return true - }, - MemberExpression(node, options, visitorKeys) { - if (options.considerGetters) { - return true - } - if ( - options.considerImplicitTypeConversion && - node.computed && - node.property.type !== "Literal" - ) { - return true - } - return this.$visitChildren(node, options, visitorKeys) - }, - MethodDefinition(node, options, visitorKeys) { - if ( - options.considerImplicitTypeConversion && - node.computed && - node.key.type !== "Literal" - ) { - return true - } - return this.$visitChildren(node, options, visitorKeys) - }, - NewExpression() { - return true - }, - Property(node, options, visitorKeys) { - if ( - options.considerImplicitTypeConversion && - node.computed && - node.key.type !== "Literal" - ) { - return true - } - return this.$visitChildren(node, options, visitorKeys) - }, - PropertyDefinition(node, options, visitorKeys) { - if ( - options.considerImplicitTypeConversion && - node.computed && - node.key.type !== "Literal" - ) { - return true - } - return this.$visitChildren(node, options, visitorKeys) - }, - UnaryExpression(node, options, visitorKeys) { - if (node.operator === "delete") { - return true - } - if ( - options.considerImplicitTypeConversion && - typeConversionUnaryOps.has(node.operator) && - node.argument.type !== "Literal" - ) { - return true - } - return this.$visitChildren(node, options, visitorKeys) - }, - UpdateExpression() { - return true - }, - YieldExpression() { - return true - }, - }), -); - -/** - * Get the left parenthesis of the parent node syntax if it exists. - * E.g., `if (a) {}` then the `(`. - * @param {Node} node The AST node to check. - * @param {SourceCode} sourceCode The source code object to get tokens. - * @returns {Token|null} The left parenthesis of the parent node syntax - */ -function getParentSyntaxParen(node, sourceCode) { - const parent = node.parent; - - switch (parent.type) { - case "CallExpression": - case "NewExpression": - if (parent.arguments.length === 1 && parent.arguments[0] === node) { - return sourceCode.getTokenAfter( - parent.callee, - isOpeningParenToken, - ) - } - return null - - case "DoWhileStatement": - if (parent.test === node) { - return sourceCode.getTokenAfter( - parent.body, - isOpeningParenToken, - ) - } - return null - - case "IfStatement": - case "WhileStatement": - if (parent.test === node) { - return sourceCode.getFirstToken(parent, 1) - } - return null - - case "ImportExpression": - if (parent.source === node) { - return sourceCode.getFirstToken(parent, 1) - } - return null - - case "SwitchStatement": - if (parent.discriminant === node) { - return sourceCode.getFirstToken(parent, 1) - } - return null - - case "WithStatement": - if (parent.object === node) { - return sourceCode.getFirstToken(parent, 1) - } - return null - - default: - return null - } -} - -/** - * Check whether a given node is parenthesized or not. - * @param {number} times The number of parantheses. - * @param {Node} node The AST node to check. - * @param {SourceCode} sourceCode The source code object to get tokens. - * @returns {boolean} `true` if the node is parenthesized the given times. - */ -/** - * Check whether a given node is parenthesized or not. - * @param {Node} node The AST node to check. - * @param {SourceCode} sourceCode The source code object to get tokens. - * @returns {boolean} `true` if the node is parenthesized. - */ -function isParenthesized( - timesOrNode, - nodeOrSourceCode, - optionalSourceCode, -) { - let times, node, sourceCode, maybeLeftParen, maybeRightParen; - if (typeof timesOrNode === "number") { - times = timesOrNode | 0; - node = nodeOrSourceCode; - sourceCode = optionalSourceCode; - if (!(times >= 1)) { - throw new TypeError("'times' should be a positive integer.") - } - } else { - times = 1; - node = timesOrNode; - sourceCode = nodeOrSourceCode; - } - - if ( - node == null || - // `Program` can't be parenthesized - node.parent == null || - // `CatchClause.param` can't be parenthesized, example `try {} catch (error) {}` - (node.parent.type === "CatchClause" && node.parent.param === node) - ) { - return false - } - - maybeLeftParen = maybeRightParen = node; - do { - maybeLeftParen = sourceCode.getTokenBefore(maybeLeftParen); - maybeRightParen = sourceCode.getTokenAfter(maybeRightParen); - } while ( - maybeLeftParen != null && - maybeRightParen != null && - isOpeningParenToken(maybeLeftParen) && - isClosingParenToken(maybeRightParen) && - // Avoid false positive such as `if (a) {}` - maybeLeftParen !== getParentSyntaxParen(node, sourceCode) && - --times > 0 - ) - - return times === 0 -} -Function.call.bind(Object.hasOwnProperty); - -var __defProp = Object.defineProperty; -var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value; -var __publicField = (obj, key, value) => { - __defNormalProp(obj, key + "" , value); - return value; -}; -class FixTracker { - /** - * Create a new FixTracker. - * @param fixer A ruleFixer instance. - * @param sourceCode A SourceCode object for the current code. - */ - constructor(fixer, sourceCode) { - this.fixer = fixer; - this.sourceCode = sourceCode; - __publicField(this, "retainedRange"); - this.retainedRange = null; - } - /** - * Mark the given range as "retained", meaning that other fixes may not - * may not modify this region in the same pass. - * @param range The range to retain. - * @returns The same RuleFixer, for chained calls. - */ - retainRange(range) { - this.retainedRange = range; - return this; - } - /** - * Given a node, find the function containing it (or the entire program) and - * mark it as retained, meaning that other fixes may not modify it in this - * pass. This is useful for avoiding conflicts in fixes that modify control - * flow. - * @param node The node to use as a starting point. - * @returns The same RuleFixer, for chained calls. - */ - retainEnclosingFunction(node) { - const functionNode = getUpperFunction(node); - return this.retainRange(functionNode ? functionNode.range : this.sourceCode.ast.range); - } - /** - * Given a node or token, find the token before and afterward, and mark that - * range as retained, meaning that other fixes may not modify it in this - * pass. This is useful for avoiding conflicts in fixes that make a small - * change to the code where the AST should not be changed. - * @param nodeOrToken The node or token to use as a starting - * point. The token to the left and right are use in the range. - * @returns The same RuleFixer, for chained calls. - */ - retainSurroundingTokens(nodeOrToken) { - const tokenBefore = this.sourceCode.getTokenBefore(nodeOrToken) || nodeOrToken; - const tokenAfter = this.sourceCode.getTokenAfter(nodeOrToken) || nodeOrToken; - return this.retainRange([tokenBefore.range[0], tokenAfter.range[1]]); - } - /** - * Create a fix command that replaces the given range with the given text, - * accounting for any retained ranges. - * @param range The range to remove in the fix. - * @param text The text to insert in place of the range. - * @returns The fix command. - */ - replaceTextRange(range, text) { - let actualRange; - if (this.retainedRange) { - actualRange = [ - Math.min(this.retainedRange[0], range[0]), - Math.max(this.retainedRange[1], range[1]) - ]; - } else { - actualRange = range; - } - return this.fixer.replaceTextRange( - actualRange, - this.sourceCode.text.slice(actualRange[0], range[0]) + text + this.sourceCode.text.slice(range[1], actualRange[1]) - ); - } - /** - * Create a fix command that removes the given node or token, accounting for - * any retained ranges. - * @param nodeOrToken The node or token to remove. - * @returns The fix command. - */ - remove(nodeOrToken) { - return this.replaceTextRange(nodeOrToken.range, ""); - } -} - -exports.COMMENTS_IGNORE_PATTERN = COMMENTS_IGNORE_PATTERN; -exports.FixTracker = FixTracker; -exports.LINEBREAKS = LINEBREAKS; -exports.LINEBREAK_MATCHER = LINEBREAK_MATCHER; -exports.STATEMENT_LIST_PARENTS = STATEMENT_LIST_PARENTS; -exports.canTokensBeAdjacent = canTokensBeAdjacent; -exports.createGlobalLinebreakMatcher = createGlobalLinebreakMatcher; -exports.createRule = createRule; -exports.getGraphemeCount = getGraphemeCount; -exports.getNextLocation = getNextLocation; -exports.getPrecedence = getPrecedence; -exports.getStaticPropertyName = getStaticPropertyName; -exports.getSwitchCaseColonToken = getSwitchCaseColonToken; -exports.hasOctalOrNonOctalDecimalEscapeSequence = hasOctalOrNonOctalDecimalEscapeSequence; -exports.isArrowToken = isArrowToken$1; -exports.isClosingBraceToken = isClosingBraceToken$1; -exports.isClosingBracketToken = isClosingBracketToken$1; -exports.isClosingParenToken = isClosingParenToken$1; -exports.isColonToken = isColonToken$1; -exports.isCommaToken = isCommaToken$1; -exports.isCommentToken = isCommentToken$1; -exports.isDecimalInteger = isDecimalInteger; -exports.isDecimalIntegerNumericToken = isDecimalIntegerNumericToken; -exports.isDirective = isDirective; -exports.isEqToken = isEqToken; -exports.isFunction = isFunction; -exports.isKeywordToken = isKeywordToken; -exports.isMixedLogicalAndCoalesceExpressions = isMixedLogicalAndCoalesceExpressions; -exports.isNotClosingParenToken = isNotClosingParenToken; -exports.isNotCommaToken = isNotCommaToken; -exports.isNotOpeningParenToken = isNotOpeningParenToken; -exports.isNotQuestionDotToken = isNotQuestionDotToken; -exports.isNotSemicolonToken = isNotSemicolonToken; -exports.isNumericLiteral = isNumericLiteral; -exports.isOpeningBraceToken = isOpeningBraceToken$1; -exports.isOpeningBracketToken = isOpeningBracketToken$1; -exports.isOpeningParenToken = isOpeningParenToken$1; -exports.isParenthesised = isParenthesised; -exports.isParenthesized = isParenthesized; -exports.isQuestionDotToken = isQuestionDotToken; -exports.isSemicolonToken = isSemicolonToken$1; -exports.isStringLiteral = isStringLiteral; -exports.isSurroundedBy = isSurroundedBy; -exports.isTokenOnSameLine = isTokenOnSameLine; -exports.isTopLevelExpressionStatement = isTopLevelExpressionStatement; -exports.keywords = keywords; -exports.skipChainExpression = skipChainExpression; diff --git a/tools/eslint/node_modules/@stylistic/eslint-plugin-js/dist/wrap-iife.js b/tools/eslint/node_modules/@stylistic/eslint-plugin-js/dist/wrap-iife.js deleted file mode 100644 index a1a4759e4180e7..00000000000000 --- a/tools/eslint/node_modules/@stylistic/eslint-plugin-js/dist/wrap-iife.js +++ /dev/null @@ -1,113 +0,0 @@ -'use strict'; - -var utils = require('./utils.js'); - -function isCalleeOfNewExpression(node) { - const maybeCallee = node.parent?.type === "ChainExpression" ? node.parent : node; - return maybeCallee.parent?.type === "NewExpression" && maybeCallee.parent.callee === maybeCallee; -} -var wrapIife = utils.createRule({ - meta: { - type: "layout", - docs: { - description: "Require parentheses around immediate `function` invocations", - url: "https://eslint.style/rules/js/wrap-iife" - }, - schema: [ - { - type: "string", - enum: ["outside", "inside", "any"] - }, - { - type: "object", - properties: { - functionPrototypeMethods: { - type: "boolean", - default: false - } - }, - additionalProperties: false - } - ], - fixable: "code", - messages: { - wrapInvocation: "Wrap an immediate function invocation in parentheses.", - wrapExpression: "Wrap only the function expression in parens.", - moveInvocation: "Move the invocation into the parens that contain the function." - } - }, - create(context) { - const style = context.options[0] || "outside"; - const includeFunctionPrototypeMethods = context.options[1] && context.options[1].functionPrototypeMethods; - const sourceCode = context.sourceCode; - function isWrappedInAnyParens(node) { - return utils.isParenthesised(sourceCode, node); - } - function isWrappedInGroupingParens(node) { - return utils.isParenthesized(1, node, sourceCode); - } - function getFunctionNodeFromIIFE(node) { - const callee = utils.skipChainExpression(node.callee); - if (callee.type === "FunctionExpression") - return callee; - if (includeFunctionPrototypeMethods && callee.type === "MemberExpression" && callee.object.type === "FunctionExpression" && (utils.getStaticPropertyName(callee) === "call" || utils.getStaticPropertyName(callee) === "apply")) { - return callee.object; - } - return null; - } - return { - CallExpression(node) { - const innerNode = getFunctionNodeFromIIFE(node); - if (!innerNode) - return; - const isCallExpressionWrapped = isWrappedInAnyParens(node); - const isFunctionExpressionWrapped = isWrappedInAnyParens(innerNode); - if (!isCallExpressionWrapped && !isFunctionExpressionWrapped) { - context.report({ - node, - messageId: "wrapInvocation", - fix(fixer) { - const nodeToSurround = style === "inside" ? innerNode : node; - return fixer.replaceText(nodeToSurround, `(${sourceCode.getText(nodeToSurround)})`); - } - }); - } else if (style === "inside" && !isFunctionExpressionWrapped) { - context.report({ - node, - messageId: "wrapExpression", - fix(fixer) { - if (isWrappedInGroupingParens(node) && !isCalleeOfNewExpression(node)) { - const parenAfter = sourceCode.getTokenAfter(node); - return fixer.replaceTextRange( - [ - innerNode.range[1], - parenAfter.range[1] - ], - `)${sourceCode.getText().slice(innerNode.range[1], parenAfter.range[0])}` - ); - } - return fixer.replaceText(innerNode, `(${sourceCode.getText(innerNode)})`); - } - }); - } else if (style === "outside" && !isCallExpressionWrapped) { - context.report({ - node, - messageId: "moveInvocation", - fix(fixer) { - const parenAfter = sourceCode.getTokenAfter(innerNode); - return fixer.replaceTextRange( - [ - parenAfter.range[0], - node.range[1] - ], - `${sourceCode.getText().slice(parenAfter.range[1], node.range[1])})` - ); - } - }); - } - } - }; - } -}); - -exports.wrapIife = wrapIife; diff --git a/tools/eslint/node_modules/@stylistic/eslint-plugin-js/dist/wrap-regex.js b/tools/eslint/node_modules/@stylistic/eslint-plugin-js/dist/wrap-regex.js deleted file mode 100644 index ca1405f3a22725..00000000000000 --- a/tools/eslint/node_modules/@stylistic/eslint-plugin-js/dist/wrap-regex.js +++ /dev/null @@ -1,41 +0,0 @@ -'use strict'; - -var utils = require('./utils.js'); - -var wrapRegex = utils.createRule({ - meta: { - type: "layout", - docs: { - description: "Require parenthesis around regex literals", - url: "https://eslint.style/rules/js/wrap-regex" - }, - schema: [], - fixable: "code", - messages: { - requireParens: "Wrap the regexp literal in parens to disambiguate the slash." - } - }, - create(context) { - const sourceCode = context.sourceCode; - return { - Literal(node) { - const token = sourceCode.getFirstToken(node); - const nodeType = token.type; - if (nodeType === "RegularExpression") { - const beforeToken = sourceCode.getTokenBefore(node); - const afterToken = sourceCode.getTokenAfter(node); - const { parent } = node; - if (parent.type === "MemberExpression" && parent.object === node && !(beforeToken && beforeToken.value === "(" && afterToken && afterToken.value === ")")) { - context.report({ - node, - messageId: "requireParens", - fix: (fixer) => fixer.replaceText(node, `(${sourceCode.getText(node)})`) - }); - } - } - } - }; - } -}); - -exports.wrapRegex = wrapRegex; diff --git a/tools/eslint/node_modules/@stylistic/eslint-plugin-js/dist/yield-star-spacing.js b/tools/eslint/node_modules/@stylistic/eslint-plugin-js/dist/yield-star-spacing.js deleted file mode 100644 index 445e09452687c9..00000000000000 --- a/tools/eslint/node_modules/@stylistic/eslint-plugin-js/dist/yield-star-spacing.js +++ /dev/null @@ -1,87 +0,0 @@ -'use strict'; - -var utils = require('./utils.js'); - -var yieldStarSpacing = utils.createRule({ - meta: { - type: "layout", - docs: { - description: "Require or disallow spacing around the `*` in `yield*` expressions", - url: "https://eslint.style/rules/js/yield-star-spacing" - }, - fixable: "whitespace", - schema: [ - { - oneOf: [ - { - type: "string", - enum: ["before", "after", "both", "neither"] - }, - { - type: "object", - properties: { - before: { type: "boolean" }, - after: { type: "boolean" } - }, - additionalProperties: false - } - ] - } - ], - messages: { - missingBefore: "Missing space before *.", - missingAfter: "Missing space after *.", - unexpectedBefore: "Unexpected space before *.", - unexpectedAfter: "Unexpected space after *." - } - }, - create(context) { - const sourceCode = context.sourceCode; - const mode = function(option = "after") { - if (typeof option === "string") { - return { - before: { before: true, after: false }, - after: { before: false, after: true }, - both: { before: true, after: true }, - neither: { before: false, after: false } - }[option]; - } - return option; - }(context.options[0]); - function checkSpacing(side, leftToken, rightToken) { - if (sourceCode.isSpaceBetweenTokens(leftToken, rightToken) !== mode[side]) { - const after = leftToken.value === "*"; - const spaceRequired = mode[side]; - const node = after ? leftToken : rightToken; - const messageId = spaceRequired ? side === "before" ? "missingBefore" : "missingAfter" : side === "before" ? "unexpectedBefore" : "unexpectedAfter"; - context.report({ - node, - messageId, - fix(fixer) { - if (spaceRequired) { - if (after) - return fixer.insertTextAfter(node, " "); - return fixer.insertTextBefore(node, " "); - } - return fixer.removeRange([leftToken.range[1], rightToken.range[0]]); - } - }); - } - } - function checkExpression(node) { - if (!("delegate" in node && node.delegate)) - return; - const tokens = sourceCode.getFirstTokens(node, 3); - const yieldToken = tokens[0]; - const starToken = tokens[1]; - const nextToken = tokens[2]; - checkSpacing("before", yieldToken, starToken); - checkSpacing("after", starToken, nextToken); - } - return { - YieldExpression: checkExpression - }; - } -}); - -exports.yieldStarSpacing = yieldStarSpacing; diff --git a/tools/eslint/node_modules/@stylistic/eslint-plugin-js/node_modules/eslint-visitor-keys/LICENSE b/tools/eslint/node_modules/@stylistic/eslint-plugin-js/node_modules/eslint-visitor-keys/LICENSE deleted file mode 100644 index 17a25538d9bd63..00000000000000 --- a/tools/eslint/node_modules/@stylistic/eslint-plugin-js/node_modules/eslint-visitor-keys/LICENSE +++ /dev/null @@ -1,201 +0,0 @@ - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "{}" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright contributors - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. diff --git a/tools/eslint/node_modules/@stylistic/eslint-plugin-js/node_modules/eslint-visitor-keys/dist/eslint-visitor-keys.cjs b/tools/eslint/node_modules/@stylistic/eslint-plugin-js/node_modules/eslint-visitor-keys/dist/eslint-visitor-keys.cjs deleted file mode 100644 index 00f91bcc4834d6..00000000000000 --- a/tools/eslint/node_modules/@stylistic/eslint-plugin-js/node_modules/eslint-visitor-keys/dist/eslint-visitor-keys.cjs +++ /dev/null @@ -1,384 +0,0 @@ -'use strict'; - -Object.defineProperty(exports, '__esModule', { value: true }); - -/** - * @typedef {{ readonly [type: string]: ReadonlyArray }} VisitorKeys - */ - -/** - * @type {VisitorKeys} - */ -const KEYS = { - ArrayExpression: [ - "elements" - ], - ArrayPattern: [ - "elements" - ], - ArrowFunctionExpression: [ - "params", - "body" - ], - AssignmentExpression: [ - "left", - "right" - ], - AssignmentPattern: [ - "left", - "right" - ], - AwaitExpression: [ - "argument" - ], - BinaryExpression: [ - "left", - "right" - ], - BlockStatement: [ - "body" - ], - BreakStatement: [ - "label" - ], - CallExpression: [ - "callee", - "arguments" - ], - CatchClause: [ - "param", - "body" - ], - ChainExpression: [ - "expression" - ], - ClassBody: [ - "body" - ], - ClassDeclaration: [ - "id", - "superClass", - "body" - ], - ClassExpression: [ - "id", - "superClass", - "body" - ], - ConditionalExpression: [ - "test", - "consequent", - "alternate" - ], - ContinueStatement: [ - "label" - ], - DebuggerStatement: [], - DoWhileStatement: [ - "body", - "test" - ], - EmptyStatement: [], - ExperimentalRestProperty: [ - "argument" - ], - ExperimentalSpreadProperty: [ - "argument" - ], - ExportAllDeclaration: [ - "exported", - "source" - ], - ExportDefaultDeclaration: [ - "declaration" - ], - ExportNamedDeclaration: [ - "declaration", - "specifiers", - "source" - ], - ExportSpecifier: [ - "exported", - "local" - ], - ExpressionStatement: [ - "expression" - ], - ForInStatement: [ - "left", - "right", - "body" - ], - ForOfStatement: [ - "left", - "right", - "body" - ], - ForStatement: [ - "init", - "test", - "update", - "body" - ], - FunctionDeclaration: [ - "id", - "params", - "body" - ], - FunctionExpression: [ - "id", - "params", - "body" - ], - Identifier: [], - IfStatement: [ - "test", - "consequent", - "alternate" - ], - ImportDeclaration: [ - "specifiers", - "source" - ], - ImportDefaultSpecifier: [ - "local" - ], - ImportExpression: [ - "source" - ], - ImportNamespaceSpecifier: [ - "local" - ], - ImportSpecifier: [ - "imported", - "local" - ], - JSXAttribute: [ - "name", - "value" - ], - JSXClosingElement: [ - "name" - ], - JSXClosingFragment: [], - JSXElement: [ - "openingElement", - "children", - "closingElement" - ], - JSXEmptyExpression: [], - JSXExpressionContainer: [ - "expression" - ], - JSXFragment: [ - "openingFragment", - "children", - "closingFragment" - ], - JSXIdentifier: [], - JSXMemberExpression: [ - "object", - "property" - ], - JSXNamespacedName: [ - "namespace", - "name" - ], - JSXOpeningElement: [ - "name", - "attributes" - ], - JSXOpeningFragment: [], - JSXSpreadAttribute: [ - "argument" - ], - JSXSpreadChild: [ - "expression" - ], - JSXText: [], - LabeledStatement: [ - "label", - "body" - ], - Literal: [], - LogicalExpression: [ - "left", - "right" - ], - MemberExpression: [ - "object", - "property" - ], - MetaProperty: [ - "meta", - "property" - ], - MethodDefinition: [ - "key", - "value" - ], - NewExpression: [ - "callee", - "arguments" - ], - ObjectExpression: [ - "properties" - ], - ObjectPattern: [ - "properties" - ], - PrivateIdentifier: [], - Program: [ - "body" - ], - Property: [ - "key", - "value" - ], - PropertyDefinition: [ - "key", - "value" - ], - RestElement: [ - "argument" - ], - ReturnStatement: [ - "argument" - ], - SequenceExpression: [ - "expressions" - ], - SpreadElement: [ - "argument" - ], - StaticBlock: [ - "body" - ], - Super: [], - SwitchCase: [ - "test", - "consequent" - ], - SwitchStatement: [ - "discriminant", - "cases" - ], - TaggedTemplateExpression: [ - "tag", - "quasi" - ], - TemplateElement: [], - TemplateLiteral: [ - "quasis", - "expressions" - ], - ThisExpression: [], - ThrowStatement: [ - "argument" - ], - TryStatement: [ - "block", - "handler", - "finalizer" - ], - UnaryExpression: [ - "argument" - ], - UpdateExpression: [ - "argument" - ], - VariableDeclaration: [ - "declarations" - ], - VariableDeclarator: [ - "id", - "init" - ], - WhileStatement: [ - "test", - "body" - ], - WithStatement: [ - "object", - "body" - ], - YieldExpression: [ - "argument" - ] -}; - -// Types. -const NODE_TYPES = Object.keys(KEYS); - -// Freeze the keys. -for (const type of NODE_TYPES) { - Object.freeze(KEYS[type]); -} -Object.freeze(KEYS); - -/** - * @author Toru Nagashima - * See LICENSE file in root directory for full license. - */ - -/** - * @typedef {import('./visitor-keys.js').VisitorKeys} VisitorKeys - */ - -// List to ignore keys. -const KEY_BLACKLIST = new Set([ - "parent", - "leadingComments", - "trailingComments" -]); - -/** - * Check whether a given key should be used or not. - * @param {string} key The key to check. - * @returns {boolean} `true` if the key should be used. - */ -function filterKey(key) { - return !KEY_BLACKLIST.has(key) && key[0] !== "_"; -} - -/** - * Get visitor keys of a given node. - * @param {object} node The AST node to get keys. - * @returns {readonly string[]} Visitor keys of the node. - */ -function getKeys(node) { - return Object.keys(node).filter(filterKey); -} - -// Disable valid-jsdoc rule because it reports syntax error on the type of @returns. -// eslint-disable-next-line valid-jsdoc -/** - * Make the union set with `KEYS` and given keys. - * @param {VisitorKeys} additionalKeys The additional keys. - * @returns {VisitorKeys} The union set. - */ -function unionWith(additionalKeys) { - const retv = /** @type {{ - [type: string]: ReadonlyArray - }} */ (Object.assign({}, KEYS)); - - for (const type of Object.keys(additionalKeys)) { - if (Object.prototype.hasOwnProperty.call(retv, type)) { - const keys = new Set(additionalKeys[type]); - - for (const key of retv[type]) { - keys.add(key); - } - - retv[type] = Object.freeze(Array.from(keys)); - } else { - retv[type] = Object.freeze(Array.from(additionalKeys[type])); - } - } - - return Object.freeze(retv); -} - -exports.KEYS = KEYS; -exports.getKeys = getKeys; -exports.unionWith = unionWith; diff --git a/tools/eslint/node_modules/@stylistic/eslint-plugin-js/node_modules/eslint-visitor-keys/dist/eslint-visitor-keys.d.cts b/tools/eslint/node_modules/@stylistic/eslint-plugin-js/node_modules/eslint-visitor-keys/dist/eslint-visitor-keys.d.cts deleted file mode 100644 index c7c28ed37b805f..00000000000000 --- a/tools/eslint/node_modules/@stylistic/eslint-plugin-js/node_modules/eslint-visitor-keys/dist/eslint-visitor-keys.d.cts +++ /dev/null @@ -1,27 +0,0 @@ -type VisitorKeys$1 = { - readonly [type: string]: readonly string[]; -}; -/** - * @typedef {{ readonly [type: string]: ReadonlyArray }} VisitorKeys - */ -/** - * @type {VisitorKeys} - */ -declare const KEYS: VisitorKeys$1; - -/** - * Get visitor keys of a given node. - * @param {object} node The AST node to get keys. - * @returns {readonly string[]} Visitor keys of the node. - */ -declare function getKeys(node: object): readonly string[]; -/** - * Make the union set with `KEYS` and given keys. - * @param {VisitorKeys} additionalKeys The additional keys. - * @returns {VisitorKeys} The union set. - */ -declare function unionWith(additionalKeys: VisitorKeys): VisitorKeys; - -type VisitorKeys = VisitorKeys$1; - -export { KEYS, VisitorKeys, getKeys, unionWith }; diff --git a/tools/eslint/node_modules/@stylistic/eslint-plugin-js/node_modules/eslint-visitor-keys/lib/index.js b/tools/eslint/node_modules/@stylistic/eslint-plugin-js/node_modules/eslint-visitor-keys/lib/index.js deleted file mode 100644 index 3622816d632da0..00000000000000 --- a/tools/eslint/node_modules/@stylistic/eslint-plugin-js/node_modules/eslint-visitor-keys/lib/index.js +++ /dev/null @@ -1,65 +0,0 @@ -/** - * @author Toru Nagashima - * See LICENSE file in root directory for full license. - */ -import KEYS from "./visitor-keys.js"; - -/** - * @typedef {import('./visitor-keys.js').VisitorKeys} VisitorKeys - */ - -// List to ignore keys. -const KEY_BLACKLIST = new Set([ - "parent", - "leadingComments", - "trailingComments" -]); - -/** - * Check whether a given key should be used or not. - * @param {string} key The key to check. - * @returns {boolean} `true` if the key should be used. - */ -function filterKey(key) { - return !KEY_BLACKLIST.has(key) && key[0] !== "_"; -} - -/** - * Get visitor keys of a given node. - * @param {object} node The AST node to get keys. - * @returns {readonly string[]} Visitor keys of the node. - */ -export function getKeys(node) { - return Object.keys(node).filter(filterKey); -} - -// Disable valid-jsdoc rule because it reports syntax error on the type of @returns. -// eslint-disable-next-line valid-jsdoc -/** - * Make the union set with `KEYS` and given keys. - * @param {VisitorKeys} additionalKeys The additional keys. - * @returns {VisitorKeys} The union set. - */ -export function unionWith(additionalKeys) { - const retv = /** @type {{ - [type: string]: ReadonlyArray - }} */ (Object.assign({}, KEYS)); - - for (const type of Object.keys(additionalKeys)) { - if (Object.prototype.hasOwnProperty.call(retv, type)) { - const keys = new Set(additionalKeys[type]); - - for (const key of retv[type]) { - keys.add(key); - } - - retv[type] = Object.freeze(Array.from(keys)); - } else { - retv[type] = Object.freeze(Array.from(additionalKeys[type])); - } - } - - return Object.freeze(retv); -} - -export { KEYS }; diff --git a/tools/eslint/node_modules/@stylistic/eslint-plugin-js/node_modules/eslint-visitor-keys/lib/visitor-keys.js b/tools/eslint/node_modules/@stylistic/eslint-plugin-js/node_modules/eslint-visitor-keys/lib/visitor-keys.js deleted file mode 100644 index ccf2b1f9a3fe89..00000000000000 --- a/tools/eslint/node_modules/@stylistic/eslint-plugin-js/node_modules/eslint-visitor-keys/lib/visitor-keys.js +++ /dev/null @@ -1,315 +0,0 @@ -/** - * @typedef {{ readonly [type: string]: ReadonlyArray }} VisitorKeys - */ - -/** - * @type {VisitorKeys} - */ -const KEYS = { - ArrayExpression: [ - "elements" - ], - ArrayPattern: [ - "elements" - ], - ArrowFunctionExpression: [ - "params", - "body" - ], - AssignmentExpression: [ - "left", - "right" - ], - AssignmentPattern: [ - "left", - "right" - ], - AwaitExpression: [ - "argument" - ], - BinaryExpression: [ - "left", - "right" - ], - BlockStatement: [ - "body" - ], - BreakStatement: [ - "label" - ], - CallExpression: [ - "callee", - "arguments" - ], - CatchClause: [ - "param", - "body" - ], - ChainExpression: [ - "expression" - ], - ClassBody: [ - "body" - ], - ClassDeclaration: [ - "id", - "superClass", - "body" - ], - ClassExpression: [ - "id", - "superClass", - "body" - ], - ConditionalExpression: [ - "test", - "consequent", - "alternate" - ], - ContinueStatement: [ - "label" - ], - DebuggerStatement: [], - DoWhileStatement: [ - "body", - "test" - ], - EmptyStatement: [], - ExperimentalRestProperty: [ - "argument" - ], - ExperimentalSpreadProperty: [ - "argument" - ], - ExportAllDeclaration: [ - "exported", - "source" - ], - ExportDefaultDeclaration: [ - "declaration" - ], - ExportNamedDeclaration: [ - "declaration", - "specifiers", - "source" - ], - ExportSpecifier: [ - "exported", - "local" - ], - ExpressionStatement: [ - "expression" - ], - ForInStatement: [ - "left", - "right", - "body" - ], - ForOfStatement: [ - "left", - "right", - "body" - ], - ForStatement: [ - "init", - "test", - "update", - "body" - ], - FunctionDeclaration: [ - "id", - "params", - "body" - ], - FunctionExpression: [ - "id", - "params", - "body" - ], - Identifier: [], - IfStatement: [ - "test", - "consequent", - "alternate" - ], - ImportDeclaration: [ - "specifiers", - "source" - ], - ImportDefaultSpecifier: [ - "local" - ], - ImportExpression: [ - "source" - ], - ImportNamespaceSpecifier: [ - "local" - ], - ImportSpecifier: [ - "imported", - "local" - ], - JSXAttribute: [ - "name", - "value" - ], - JSXClosingElement: [ - "name" - ], - JSXClosingFragment: [], - JSXElement: [ - "openingElement", - "children", - "closingElement" - ], - JSXEmptyExpression: [], - JSXExpressionContainer: [ - "expression" - ], - JSXFragment: [ - "openingFragment", - "children", - "closingFragment" - ], - JSXIdentifier: [], - JSXMemberExpression: [ - "object", - "property" - ], - JSXNamespacedName: [ - "namespace", - "name" - ], - JSXOpeningElement: [ - "name", - "attributes" - ], - JSXOpeningFragment: [], - JSXSpreadAttribute: [ - "argument" - ], - JSXSpreadChild: [ - "expression" - ], - JSXText: [], - LabeledStatement: [ - "label", - "body" - ], - Literal: [], - LogicalExpression: [ - "left", - "right" - ], - MemberExpression: [ - "object", - "property" - ], - MetaProperty: [ - "meta", - "property" - ], - MethodDefinition: [ - "key", - "value" - ], - NewExpression: [ - "callee", - "arguments" - ], - ObjectExpression: [ - "properties" - ], - ObjectPattern: [ - "properties" - ], - PrivateIdentifier: [], - Program: [ - "body" - ], - Property: [ - "key", - "value" - ], - PropertyDefinition: [ - "key", - "value" - ], - RestElement: [ - "argument" - ], - ReturnStatement: [ - "argument" - ], - SequenceExpression: [ - "expressions" - ], - SpreadElement: [ - "argument" - ], - StaticBlock: [ - "body" - ], - Super: [], - SwitchCase: [ - "test", - "consequent" - ], - SwitchStatement: [ - "discriminant", - "cases" - ], - TaggedTemplateExpression: [ - "tag", - "quasi" - ], - TemplateElement: [], - TemplateLiteral: [ - "quasis", - "expressions" - ], - ThisExpression: [], - ThrowStatement: [ - "argument" - ], - TryStatement: [ - "block", - "handler", - "finalizer" - ], - UnaryExpression: [ - "argument" - ], - UpdateExpression: [ - "argument" - ], - VariableDeclaration: [ - "declarations" - ], - VariableDeclarator: [ - "id", - "init" - ], - WhileStatement: [ - "test", - "body" - ], - WithStatement: [ - "object", - "body" - ], - YieldExpression: [ - "argument" - ] -}; - -// Types. -const NODE_TYPES = Object.keys(KEYS); - -// Freeze the keys. -for (const type of NODE_TYPES) { - Object.freeze(KEYS[type]); -} -Object.freeze(KEYS); - -export default KEYS; diff --git a/tools/eslint/node_modules/@stylistic/eslint-plugin-js/node_modules/eslint-visitor-keys/package.json b/tools/eslint/node_modules/@stylistic/eslint-plugin-js/node_modules/eslint-visitor-keys/package.json deleted file mode 100644 index 51a5dad8a79929..00000000000000 --- a/tools/eslint/node_modules/@stylistic/eslint-plugin-js/node_modules/eslint-visitor-keys/package.json +++ /dev/null @@ -1,74 +0,0 @@ -{ - "name": "eslint-visitor-keys", - "version": "4.0.0", - "description": "Constants and utilities about visitor keys to traverse AST.", - "type": "module", - "main": "dist/eslint-visitor-keys.cjs", - "types": "./dist/index.d.ts", - "exports": { - ".": [ - { - "import": "./lib/index.js", - "require": "./dist/eslint-visitor-keys.cjs" - }, - "./dist/eslint-visitor-keys.cjs" - ], - "./package.json": "./package.json" - }, - "files": [ - "dist/index.d.ts", - "dist/visitor-keys.d.ts", - "dist/eslint-visitor-keys.cjs", - "dist/eslint-visitor-keys.d.cts", - "lib" - ], - "engines": { - "node": "^18.18.0 || ^20.9.0 || >=21.1.0" - }, - "devDependencies": { - "@types/estree": "^0.0.51", - "@types/estree-jsx": "^0.0.1", - "@typescript-eslint/parser": "^5.14.0", - "c8": "^7.11.0", - "chai": "^4.3.6", - "eslint": "^7.29.0", - "eslint-config-eslint": "^7.0.0", - "eslint-plugin-jsdoc": "^35.4.0", - "eslint-plugin-node": "^11.1.0", - "eslint-release": "^3.2.0", - "esquery": "^1.4.0", - "json-diff": "^0.7.3", - "mocha": "^9.2.1", - "opener": "^1.5.2", - "rollup": "^2.70.0", - "rollup-plugin-dts": "^4.2.3", - "tsd": "^0.19.1", - "typescript": "^4.6.2" - }, - "scripts": { - "build": "npm run build:cjs && npm run build:types", - "build:cjs": "rollup -c", - "build:debug": "npm run build:cjs -- -m && npm run build:types", - "build:keys": "node tools/build-keys-from-ts", - "build:types": "tsc", - "lint": "eslint .", - "prepare": "npm run build", - "release:generate:latest": "eslint-generate-release", - "release:generate:alpha": "eslint-generate-prerelease alpha", - "release:generate:beta": "eslint-generate-prerelease beta", - "release:generate:rc": "eslint-generate-prerelease rc", - "release:publish": "eslint-publish-release", - "test": "mocha tests/lib/**/*.cjs && c8 mocha tests/lib/**/*.js && npm run test:types", - "test:open-coverage": "c8 report --reporter lcov && opener coverage/lcov-report/index.html", - "test:types": "tsd" - }, - "repository": "eslint/eslint-visitor-keys", - "funding": "https://opencollective.com/eslint", - "keywords": [], - "author": "Toru Nagashima (https://github.com/mysticatea)", - "license": "Apache-2.0", - "bugs": { - "url": "https://github.com/eslint/eslint-visitor-keys/issues" - }, - "homepage": "https://github.com/eslint/eslint-visitor-keys#readme" -} diff --git a/tools/eslint/node_modules/@stylistic/eslint-plugin-js/package.json b/tools/eslint/node_modules/@stylistic/eslint-plugin-js/package.json deleted file mode 100644 index 2b5c6051b4bd6f..00000000000000 --- a/tools/eslint/node_modules/@stylistic/eslint-plugin-js/package.json +++ /dev/null @@ -1,126 +0,0 @@ -{ - "name": "@stylistic/eslint-plugin-js", - "version": "2.3.0", - "author": "Anthony Fu ", - "license": "MIT", - "homepage": "https://github.com/eslint-stylistic/eslint-stylistic#readme", - "repository": { - "type": "git", - "url": "git+https://github.com/eslint-stylistic/eslint-stylistic.git", - "directory": "packages/eslint-plugin-js" - }, - "bugs": { - "url": "https://github.com/eslint-stylistic/eslint-stylistic/issues" - }, - "exports": { - ".": { - "types": "./dts/index.d.ts", - "require": "./dist/index.js", - "default": "./dist/index.js" - }, - "./define-config-support": { - "types": "./dts/define-config-support.d.ts" - }, - "./rule-options": { - "types": "./dts/rule-options.d.ts" - }, - "./rules/array-bracket-newline": "./dist/array-bracket-newline.js", - "./rules/array-bracket-spacing": "./dist/array-bracket-spacing.js", - "./rules/array-element-newline": "./dist/array-element-newline.js", - "./rules/arrow-parens": "./dist/arrow-parens.js", - "./rules/arrow-spacing": "./dist/arrow-spacing.js", - "./rules/block-spacing": "./dist/block-spacing.js", - "./rules/brace-style": "./dist/brace-style.js", - "./rules/comma-dangle": "./dist/comma-dangle.js", - "./rules/comma-spacing": "./dist/comma-spacing.js", - "./rules/comma-style": "./dist/comma-style.js", - "./rules/computed-property-spacing": "./dist/computed-property-spacing.js", - "./rules/dot-location": "./dist/dot-location.js", - "./rules/eol-last": "./dist/eol-last.js", - "./rules/func-call-spacing": "./dist/func-call-spacing.js", - "./rules/function-call-argument-newline": "./dist/function-call-argument-newline.js", - "./rules/function-call-spacing": "./dist/function-call-spacing.js", - "./rules/function-paren-newline": "./dist/function-paren-newline.js", - "./rules/generator-star-spacing": "./dist/generator-star-spacing.js", - "./rules/implicit-arrow-linebreak": "./dist/implicit-arrow-linebreak.js", - "./rules/indent": "./dist/indent.js", - "./rules/jsx-quotes": "./dist/jsx-quotes.js", - "./rules/key-spacing": "./dist/key-spacing.js", - "./rules/keyword-spacing": "./dist/keyword-spacing.js", - "./rules/line-comment-position": "./dist/line-comment-position.js", - "./rules/linebreak-style": "./dist/linebreak-style.js", - "./rules/lines-around-comment": "./dist/lines-around-comment.js", - "./rules/lines-between-class-members": "./dist/lines-between-class-members.js", - "./rules/max-len": "./dist/max-len.js", - "./rules/max-statements-per-line": "./dist/max-statements-per-line.js", - "./rules/multiline-comment-style": "./dist/multiline-comment-style.js", - "./rules/multiline-ternary": "./dist/multiline-ternary.js", - "./rules/new-parens": "./dist/new-parens.js", - "./rules/newline-per-chained-call": "./dist/newline-per-chained-call.js", - "./rules/no-confusing-arrow": "./dist/no-confusing-arrow.js", - "./rules/no-extra-parens": "./dist/no-extra-parens.js", - "./rules/no-extra-semi": "./dist/no-extra-semi.js", - "./rules/no-floating-decimal": "./dist/no-floating-decimal.js", - "./rules/no-mixed-operators": "./dist/no-mixed-operators.js", - "./rules/no-mixed-spaces-and-tabs": "./dist/no-mixed-spaces-and-tabs.js", - "./rules/no-multi-spaces": "./dist/no-multi-spaces.js", - "./rules/no-multiple-empty-lines": "./dist/no-multiple-empty-lines.js", - "./rules/no-tabs": "./dist/no-tabs.js", - "./rules/no-trailing-spaces": "./dist/no-trailing-spaces.js", - "./rules/no-whitespace-before-property": "./dist/no-whitespace-before-property.js", - "./rules/nonblock-statement-body-position": "./dist/nonblock-statement-body-position.js", - "./rules/object-curly-newline": "./dist/object-curly-newline.js", - "./rules/object-curly-spacing": "./dist/object-curly-spacing.js", - "./rules/object-property-newline": "./dist/object-property-newline.js", - "./rules/one-var-declaration-per-line": "./dist/one-var-declaration-per-line.js", - "./rules/operator-linebreak": "./dist/operator-linebreak.js", - "./rules/padded-blocks": "./dist/padded-blocks.js", - "./rules/padding-line-between-statements": "./dist/padding-line-between-statements.js", - "./rules/quote-props": "./dist/quote-props.js", - "./rules/quotes": "./dist/quotes.js", - "./rules/rest-spread-spacing": "./dist/rest-spread-spacing.js", - "./rules/semi": "./dist/semi.js", - "./rules/semi-spacing": "./dist/semi-spacing.js", - "./rules/semi-style": "./dist/semi-style.js", - "./rules/space-before-blocks": "./dist/space-before-blocks.js", - "./rules/space-before-function-paren": "./dist/space-before-function-paren.js", - "./rules/space-in-parens": "./dist/space-in-parens.js", - "./rules/space-infix-ops": "./dist/space-infix-ops.js", - "./rules/space-unary-ops": "./dist/space-unary-ops.js", - "./rules/spaced-comment": "./dist/spaced-comment.js", - "./rules/switch-colon-spacing": "./dist/switch-colon-spacing.js", - "./rules/template-curly-spacing": "./dist/template-curly-spacing.js", - "./rules/template-tag-spacing": "./dist/template-tag-spacing.js", - "./rules/wrap-iife": "./dist/wrap-iife.js", - "./rules/wrap-regex": "./dist/wrap-regex.js", - "./rules/yield-star-spacing": "./dist/yield-star-spacing.js" - }, - "main": "./dist/index.js", - "types": "./dts/index.d.ts", - "files": [ - "dist", - "dts", - "rules/**/*.d.ts" - ], - "engines": { - "node": "^18.18.0 || ^20.9.0 || >=21.1.0" - }, - "peerDependencies": { - "eslint": ">=8.40.0" - }, - "dependencies": { - "@types/eslint": "^8.56.10", - "acorn": "^8.11.3", - "eslint-visitor-keys": "^4.0.0", - "espree": "^10.0.1" - }, - "devDependencies": { - "@eslint-community/eslint-utils": "^4.4.0", - "@typescript-eslint/parser": "^7.12.0", - "escape-string-regexp": "^5.0.0" - }, - "scripts": { - "build": "rimraf dist && rollup --config=rollup.config.mts --configPlugin=rollup-plugin-esbuild", - "dev": "rollup --config=rollup.config.mts --configPlugin=rollup-plugin-esbuild --watch" - } -} \ No newline at end of file diff --git a/tools/eslint/node_modules/@types/eslint/LICENSE b/tools/eslint/node_modules/@types/eslint/LICENSE deleted file mode 100644 index 9e841e7a26e4eb..00000000000000 --- a/tools/eslint/node_modules/@types/eslint/LICENSE +++ /dev/null @@ -1,21 +0,0 @@ - MIT License - - Copyright (c) Microsoft Corporation. - - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated documentation files (the "Software"), to deal - in the Software without restriction, including without limitation the rights - to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in all - copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - SOFTWARE diff --git a/tools/eslint/node_modules/@types/eslint/package.json b/tools/eslint/node_modules/@types/eslint/package.json deleted file mode 100644 index fa6917a992ed5f..00000000000000 --- a/tools/eslint/node_modules/@types/eslint/package.json +++ /dev/null @@ -1,70 +0,0 @@ -{ - "name": "@types/eslint", - "version": "8.56.10", - "description": "TypeScript definitions for eslint", - "homepage": "https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/eslint", - "license": "MIT", - "contributors": [ - { - "name": "Pierre-Marie Dartus", - "githubUsername": "pmdartus", - "url": "https://github.com/pmdartus" - }, - { - "name": "Jed Fox", - "githubUsername": "j-f1", - "url": "https://github.com/j-f1" - }, - { - "name": "Saad Quadri", - "githubUsername": "saadq", - "url": "https://github.com/saadq" - }, - { - "name": "Jason Kwok", - "githubUsername": "JasonHK", - "url": "https://github.com/JasonHK" - }, - { - "name": "Brad Zacher", - "githubUsername": "bradzacher", - "url": "https://github.com/bradzacher" - }, - { - "name": "JounQin", - "githubUsername": "JounQin", - "url": "https://github.com/JounQin" - }, - { - "name": "Bryan Mishkin", - "githubUsername": "bmish", - "url": "https://github.com/bmish" - } - ], - "main": "", - "types": "index.d.ts", - "exports": { - ".": { - "types": "./index.d.ts" - }, - "./use-at-your-own-risk": { - "types": "./use-at-your-own-risk.d.ts" - }, - "./rules": { - "types": "./rules/index.d.ts" - }, - "./package.json": "./package.json" - }, - "repository": { - "type": "git", - "url": "https://github.com/DefinitelyTyped/DefinitelyTyped.git", - "directory": "types/eslint" - }, - "scripts": {}, - "dependencies": { - "@types/estree": "*", - "@types/json-schema": "*" - }, - "typesPublisherContentHash": "522d3c76ab9a1be04075a38852c1f9c8c64f6722d17428f2cbbddc55e0477b81", - "typeScriptVersion": "4.7" -} \ No newline at end of file diff --git a/tools/eslint/node_modules/@types/estree/LICENSE b/tools/eslint/node_modules/@types/estree/LICENSE deleted file mode 100644 index 9e841e7a26e4eb..00000000000000 --- a/tools/eslint/node_modules/@types/estree/LICENSE +++ /dev/null @@ -1,21 +0,0 @@ - MIT License - - Copyright (c) Microsoft Corporation. - - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated documentation files (the "Software"), to deal - in the Software without restriction, including without limitation the rights - to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in all - copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - SOFTWARE diff --git a/tools/eslint/node_modules/@types/estree/package.json b/tools/eslint/node_modules/@types/estree/package.json deleted file mode 100644 index 2d5a998377ab74..00000000000000 --- a/tools/eslint/node_modules/@types/estree/package.json +++ /dev/null @@ -1,26 +0,0 @@ -{ - "name": "@types/estree", - "version": "1.0.5", - "description": "TypeScript definitions for estree", - "homepage": "https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/estree", - "license": "MIT", - "contributors": [ - { - "name": "RReverser", - "githubUsername": "RReverser", - "url": "https://github.com/RReverser" - } - ], - "main": "", - "types": "index.d.ts", - "repository": { - "type": "git", - "url": "https://github.com/DefinitelyTyped/DefinitelyTyped.git", - "directory": "types/estree" - }, - "scripts": {}, - "dependencies": {}, - "typesPublisherContentHash": "6f0eeaffe488ce594e73f8df619c677d752a279b51edbc744e4aebb20db4b3a7", - "typeScriptVersion": "4.5", - "nonNpm": true -} \ No newline at end of file diff --git a/tools/eslint/node_modules/@types/json-schema/LICENSE b/tools/eslint/node_modules/@types/json-schema/LICENSE deleted file mode 100644 index 9e841e7a26e4eb..00000000000000 --- a/tools/eslint/node_modules/@types/json-schema/LICENSE +++ /dev/null @@ -1,21 +0,0 @@ - MIT License - - Copyright (c) Microsoft Corporation. - - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated documentation files (the "Software"), to deal - in the Software without restriction, including without limitation the rights - to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in all - copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - SOFTWARE diff --git a/tools/eslint/node_modules/@types/json-schema/package.json b/tools/eslint/node_modules/@types/json-schema/package.json deleted file mode 100644 index 3c41bd7f1e46f4..00000000000000 --- a/tools/eslint/node_modules/@types/json-schema/package.json +++ /dev/null @@ -1,40 +0,0 @@ -{ - "name": "@types/json-schema", - "version": "7.0.15", - "description": "TypeScript definitions for json-schema", - "homepage": "https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/json-schema", - "license": "MIT", - "contributors": [ - { - "name": "Boris Cherny", - "githubUsername": "bcherny", - "url": "https://github.com/bcherny" - }, - { - "name": "Lucian Buzzo", - "githubUsername": "lucianbuzzo", - "url": "https://github.com/lucianbuzzo" - }, - { - "name": "Roland Groza", - "githubUsername": "rolandjitsu", - "url": "https://github.com/rolandjitsu" - }, - { - "name": "Jason Kwok", - "githubUsername": "JasonHK", - "url": "https://github.com/JasonHK" - } - ], - "main": "", - "types": "index.d.ts", - "repository": { - "type": "git", - "url": "https://github.com/DefinitelyTyped/DefinitelyTyped.git", - "directory": "types/json-schema" - }, - "scripts": {}, - "dependencies": {}, - "typesPublisherContentHash": "79984fd70cd25c3f7d72b84368778c763c89728ea0073832d745d4691b705257", - "typeScriptVersion": "4.5" -} \ No newline at end of file diff --git a/tools/eslint/node_modules/@types/mdast/LICENSE b/tools/eslint/node_modules/@types/mdast/LICENSE deleted file mode 100644 index 9e841e7a26e4eb..00000000000000 --- a/tools/eslint/node_modules/@types/mdast/LICENSE +++ /dev/null @@ -1,21 +0,0 @@ - MIT License - - Copyright (c) Microsoft Corporation. - - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated documentation files (the "Software"), to deal - in the Software without restriction, including without limitation the rights - to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in all - copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - SOFTWARE diff --git a/tools/eslint/node_modules/@types/mdast/package.json b/tools/eslint/node_modules/@types/mdast/package.json deleted file mode 100644 index 89b4c99fb2c643..00000000000000 --- a/tools/eslint/node_modules/@types/mdast/package.json +++ /dev/null @@ -1,42 +0,0 @@ -{ - "name": "@types/mdast", - "version": "3.0.15", - "description": "TypeScript definitions for mdast", - "homepage": "https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/mdast", - "license": "MIT", - "contributors": [ - { - "name": "Christian Murphy", - "githubUsername": "ChristianMurphy", - "url": "https://github.com/ChristianMurphy" - }, - { - "name": "Jun Lu", - "githubUsername": "lujun2", - "url": "https://github.com/lujun2" - }, - { - "name": "Remco Haszing", - "githubUsername": "remcohaszing", - "url": "https://github.com/remcohaszing" - }, - { - "name": "Titus Wormer", - "githubUsername": "wooorm", - "url": "https://github.com/wooorm" - } - ], - "main": "", - "types": "index.d.ts", - "repository": { - "type": "git", - "url": "https://github.com/DefinitelyTyped/DefinitelyTyped.git", - "directory": "types/mdast" - }, - "scripts": {}, - "dependencies": { - "@types/unist": "^2" - }, - "typesPublisherContentHash": "856cf2bf5ad8e053a42747d48af6b089fac3bd7f568451deb8053f84dfac225d", - "typeScriptVersion": "4.5" -} \ No newline at end of file diff --git a/tools/eslint/node_modules/@types/unist/LICENSE b/tools/eslint/node_modules/@types/unist/LICENSE deleted file mode 100644 index 9e841e7a26e4eb..00000000000000 --- a/tools/eslint/node_modules/@types/unist/LICENSE +++ /dev/null @@ -1,21 +0,0 @@ - MIT License - - Copyright (c) Microsoft Corporation. - - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated documentation files (the "Software"), to deal - in the Software without restriction, including without limitation the rights - to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in all - copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - SOFTWARE diff --git a/tools/eslint/node_modules/@types/unist/package.json b/tools/eslint/node_modules/@types/unist/package.json deleted file mode 100644 index eff0fce8f6b8cd..00000000000000 --- a/tools/eslint/node_modules/@types/unist/package.json +++ /dev/null @@ -1,56 +0,0 @@ -{ - "name": "@types/unist", - "version": "2.0.10", - "description": "TypeScript definitions for unist", - "homepage": "https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/unist", - "license": "MIT", - "contributors": [ - { - "name": "bizen241", - "githubUsername": "bizen241", - "url": "https://github.com/bizen241" - }, - { - "name": "Jun Lu", - "githubUsername": "lujun2", - "url": "https://github.com/lujun2" - }, - { - "name": "Hernan Rajchert", - "githubUsername": "hrajchert", - "url": "https://github.com/hrajchert" - }, - { - "name": "Titus Wormer", - "githubUsername": "wooorm", - "url": "https://github.com/wooorm" - }, - { - "name": "Junyoung Choi", - "githubUsername": "rokt33r", - "url": "https://github.com/rokt33r" - }, - { - "name": "Ben Moon", - "githubUsername": "GuiltyDolphin", - "url": "https://github.com/GuiltyDolphin" - }, - { - "name": "JounQin", - "githubUsername": "JounQin", - "url": "https://github.com/JounQin" - } - ], - "main": "", - "types": "index.d.ts", - "repository": { - "type": "git", - "url": "https://github.com/DefinitelyTyped/DefinitelyTyped.git", - "directory": "types/unist" - }, - "scripts": {}, - "dependencies": {}, - "typesPublisherContentHash": "65c419f7bf5fb4a8b58da16b61b8cfc2629fb81d70dff861467e0292b2ed70ea", - "typeScriptVersion": "4.5", - "nonNpm": true -} \ No newline at end of file diff --git a/tools/eslint/node_modules/acorn-jsx/LICENSE b/tools/eslint/node_modules/acorn-jsx/LICENSE deleted file mode 100644 index 695d4b93082bee..00000000000000 --- a/tools/eslint/node_modules/acorn-jsx/LICENSE +++ /dev/null @@ -1,19 +0,0 @@ -Copyright (C) 2012-2017 by Ingvar Stepanyan - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. diff --git a/tools/eslint/node_modules/acorn-jsx/index.js b/tools/eslint/node_modules/acorn-jsx/index.js deleted file mode 100644 index 004e0809024006..00000000000000 --- a/tools/eslint/node_modules/acorn-jsx/index.js +++ /dev/null @@ -1,488 +0,0 @@ -'use strict'; - -const XHTMLEntities = require('./xhtml'); - -const hexNumber = /^[\da-fA-F]+$/; -const decimalNumber = /^\d+$/; - -// The map to `acorn-jsx` tokens from `acorn` namespace objects. -const acornJsxMap = new WeakMap(); - -// Get the original tokens for the given `acorn` namespace object. -function getJsxTokens(acorn) { - acorn = acorn.Parser.acorn || acorn; - let acornJsx = acornJsxMap.get(acorn); - if (!acornJsx) { - const tt = acorn.tokTypes; - const TokContext = acorn.TokContext; - const TokenType = acorn.TokenType; - const tc_oTag = new TokContext('...', true, true); - const tokContexts = { - tc_oTag: tc_oTag, - tc_cTag: tc_cTag, - tc_expr: tc_expr - }; - const tokTypes = { - jsxName: new TokenType('jsxName'), - jsxText: new TokenType('jsxText', {beforeExpr: true}), - jsxTagStart: new TokenType('jsxTagStart', {startsExpr: true}), - jsxTagEnd: new TokenType('jsxTagEnd') - }; - - tokTypes.jsxTagStart.updateContext = function() { - this.context.push(tc_expr); // treat as beginning of JSX expression - this.context.push(tc_oTag); // start opening tag context - this.exprAllowed = false; - }; - tokTypes.jsxTagEnd.updateContext = function(prevType) { - let out = this.context.pop(); - if (out === tc_oTag && prevType === tt.slash || out === tc_cTag) { - this.context.pop(); - this.exprAllowed = this.curContext() === tc_expr; - } else { - this.exprAllowed = true; - } - }; - - acornJsx = { tokContexts: tokContexts, tokTypes: tokTypes }; - acornJsxMap.set(acorn, acornJsx); - } - - return acornJsx; -} - -// Transforms JSX element name to string. - -function getQualifiedJSXName(object) { - if (!object) - return object; - - if (object.type === 'JSXIdentifier') - return object.name; - - if (object.type === 'JSXNamespacedName') - return object.namespace.name + ':' + object.name.name; - - if (object.type === 'JSXMemberExpression') - return getQualifiedJSXName(object.object) + '.' + - getQualifiedJSXName(object.property); -} - -module.exports = function(options) { - options = options || {}; - return function(Parser) { - return plugin({ - allowNamespaces: options.allowNamespaces !== false, - allowNamespacedObjects: !!options.allowNamespacedObjects - }, Parser); - }; -}; - -// This is `tokTypes` of the peer dep. -// This can be different instances from the actual `tokTypes` this plugin uses. -Object.defineProperty(module.exports, "tokTypes", { - get: function get_tokTypes() { - return getJsxTokens(require("acorn")).tokTypes; - }, - configurable: true, - enumerable: true -}); - -function plugin(options, Parser) { - const acorn = Parser.acorn || require("acorn"); - const acornJsx = getJsxTokens(acorn); - const tt = acorn.tokTypes; - const tok = acornJsx.tokTypes; - const tokContexts = acorn.tokContexts; - const tc_oTag = acornJsx.tokContexts.tc_oTag; - const tc_cTag = acornJsx.tokContexts.tc_cTag; - const tc_expr = acornJsx.tokContexts.tc_expr; - const isNewLine = acorn.isNewLine; - const isIdentifierStart = acorn.isIdentifierStart; - const isIdentifierChar = acorn.isIdentifierChar; - - return class extends Parser { - // Expose actual `tokTypes` and `tokContexts` to other plugins. - static get acornJsx() { - return acornJsx; - } - - // Reads inline JSX contents token. - jsx_readToken() { - let out = '', chunkStart = this.pos; - for (;;) { - if (this.pos >= this.input.length) - this.raise(this.start, 'Unterminated JSX contents'); - let ch = this.input.charCodeAt(this.pos); - - switch (ch) { - case 60: // '<' - case 123: // '{' - if (this.pos === this.start) { - if (ch === 60 && this.exprAllowed) { - ++this.pos; - return this.finishToken(tok.jsxTagStart); - } - return this.getTokenFromCode(ch); - } - out += this.input.slice(chunkStart, this.pos); - return this.finishToken(tok.jsxText, out); - - case 38: // '&' - out += this.input.slice(chunkStart, this.pos); - out += this.jsx_readEntity(); - chunkStart = this.pos; - break; - - case 62: // '>' - case 125: // '}' - this.raise( - this.pos, - "Unexpected token `" + this.input[this.pos] + "`. Did you mean `" + - (ch === 62 ? ">" : "}") + "` or " + "`{\"" + this.input[this.pos] + "\"}" + "`?" - ); - - default: - if (isNewLine(ch)) { - out += this.input.slice(chunkStart, this.pos); - out += this.jsx_readNewLine(true); - chunkStart = this.pos; - } else { - ++this.pos; - } - } - } - } - - jsx_readNewLine(normalizeCRLF) { - let ch = this.input.charCodeAt(this.pos); - let out; - ++this.pos; - if (ch === 13 && this.input.charCodeAt(this.pos) === 10) { - ++this.pos; - out = normalizeCRLF ? '\n' : '\r\n'; - } else { - out = String.fromCharCode(ch); - } - if (this.options.locations) { - ++this.curLine; - this.lineStart = this.pos; - } - - return out; - } - - jsx_readString(quote) { - let out = '', chunkStart = ++this.pos; - for (;;) { - if (this.pos >= this.input.length) - this.raise(this.start, 'Unterminated string constant'); - let ch = this.input.charCodeAt(this.pos); - if (ch === quote) break; - if (ch === 38) { // '&' - out += this.input.slice(chunkStart, this.pos); - out += this.jsx_readEntity(); - chunkStart = this.pos; - } else if (isNewLine(ch)) { - out += this.input.slice(chunkStart, this.pos); - out += this.jsx_readNewLine(false); - chunkStart = this.pos; - } else { - ++this.pos; - } - } - out += this.input.slice(chunkStart, this.pos++); - return this.finishToken(tt.string, out); - } - - jsx_readEntity() { - let str = '', count = 0, entity; - let ch = this.input[this.pos]; - if (ch !== '&') - this.raise(this.pos, 'Entity must start with an ampersand'); - let startPos = ++this.pos; - while (this.pos < this.input.length && count++ < 10) { - ch = this.input[this.pos++]; - if (ch === ';') { - if (str[0] === '#') { - if (str[1] === 'x') { - str = str.substr(2); - if (hexNumber.test(str)) - entity = String.fromCharCode(parseInt(str, 16)); - } else { - str = str.substr(1); - if (decimalNumber.test(str)) - entity = String.fromCharCode(parseInt(str, 10)); - } - } else { - entity = XHTMLEntities[str]; - } - break; - } - str += ch; - } - if (!entity) { - this.pos = startPos; - return '&'; - } - return entity; - } - - // Read a JSX identifier (valid tag or attribute name). - // - // Optimized version since JSX identifiers can't contain - // escape characters and so can be read as single slice. - // Also assumes that first character was already checked - // by isIdentifierStart in readToken. - - jsx_readWord() { - let ch, start = this.pos; - do { - ch = this.input.charCodeAt(++this.pos); - } while (isIdentifierChar(ch) || ch === 45); // '-' - return this.finishToken(tok.jsxName, this.input.slice(start, this.pos)); - } - - // Parse next token as JSX identifier - - jsx_parseIdentifier() { - let node = this.startNode(); - if (this.type === tok.jsxName) - node.name = this.value; - else if (this.type.keyword) - node.name = this.type.keyword; - else - this.unexpected(); - this.next(); - return this.finishNode(node, 'JSXIdentifier'); - } - - // Parse namespaced identifier. - - jsx_parseNamespacedName() { - let startPos = this.start, startLoc = this.startLoc; - let name = this.jsx_parseIdentifier(); - if (!options.allowNamespaces || !this.eat(tt.colon)) return name; - var node = this.startNodeAt(startPos, startLoc); - node.namespace = name; - node.name = this.jsx_parseIdentifier(); - return this.finishNode(node, 'JSXNamespacedName'); - } - - // Parses element name in any form - namespaced, member - // or single identifier. - - jsx_parseElementName() { - if (this.type === tok.jsxTagEnd) return ''; - let startPos = this.start, startLoc = this.startLoc; - let node = this.jsx_parseNamespacedName(); - if (this.type === tt.dot && node.type === 'JSXNamespacedName' && !options.allowNamespacedObjects) { - this.unexpected(); - } - while (this.eat(tt.dot)) { - let newNode = this.startNodeAt(startPos, startLoc); - newNode.object = node; - newNode.property = this.jsx_parseIdentifier(); - node = this.finishNode(newNode, 'JSXMemberExpression'); - } - return node; - } - - // Parses any type of JSX attribute value. - - jsx_parseAttributeValue() { - switch (this.type) { - case tt.braceL: - let node = this.jsx_parseExpressionContainer(); - if (node.expression.type === 'JSXEmptyExpression') - this.raise(node.start, 'JSX attributes must only be assigned a non-empty expression'); - return node; - - case tok.jsxTagStart: - case tt.string: - return this.parseExprAtom(); - - default: - this.raise(this.start, 'JSX value should be either an expression or a quoted JSX text'); - } - } - - // JSXEmptyExpression is unique type since it doesn't actually parse anything, - // and so it should start at the end of last read token (left brace) and finish - // at the beginning of the next one (right brace). - - jsx_parseEmptyExpression() { - let node = this.startNodeAt(this.lastTokEnd, this.lastTokEndLoc); - return this.finishNodeAt(node, 'JSXEmptyExpression', this.start, this.startLoc); - } - - // Parses JSX expression enclosed into curly brackets. - - jsx_parseExpressionContainer() { - let node = this.startNode(); - this.next(); - node.expression = this.type === tt.braceR - ? this.jsx_parseEmptyExpression() - : this.parseExpression(); - this.expect(tt.braceR); - return this.finishNode(node, 'JSXExpressionContainer'); - } - - // Parses following JSX attribute name-value pair. - - jsx_parseAttribute() { - let node = this.startNode(); - if (this.eat(tt.braceL)) { - this.expect(tt.ellipsis); - node.argument = this.parseMaybeAssign(); - this.expect(tt.braceR); - return this.finishNode(node, 'JSXSpreadAttribute'); - } - node.name = this.jsx_parseNamespacedName(); - node.value = this.eat(tt.eq) ? this.jsx_parseAttributeValue() : null; - return this.finishNode(node, 'JSXAttribute'); - } - - // Parses JSX opening tag starting after '<'. - - jsx_parseOpeningElementAt(startPos, startLoc) { - let node = this.startNodeAt(startPos, startLoc); - node.attributes = []; - let nodeName = this.jsx_parseElementName(); - if (nodeName) node.name = nodeName; - while (this.type !== tt.slash && this.type !== tok.jsxTagEnd) - node.attributes.push(this.jsx_parseAttribute()); - node.selfClosing = this.eat(tt.slash); - this.expect(tok.jsxTagEnd); - return this.finishNode(node, nodeName ? 'JSXOpeningElement' : 'JSXOpeningFragment'); - } - - // Parses JSX closing tag starting after ''); - } - } - let fragmentOrElement = openingElement.name ? 'Element' : 'Fragment'; - - node['opening' + fragmentOrElement] = openingElement; - node['closing' + fragmentOrElement] = closingElement; - node.children = children; - if (this.type === tt.relational && this.value === "<") { - this.raise(this.start, "Adjacent JSX elements must be wrapped in an enclosing tag"); - } - return this.finishNode(node, 'JSX' + fragmentOrElement); - } - - // Parse JSX text - - jsx_parseText() { - let node = this.parseLiteral(this.value); - node.type = "JSXText"; - return node; - } - - // Parses entire JSX element from current position. - - jsx_parseElement() { - let startPos = this.start, startLoc = this.startLoc; - this.next(); - return this.jsx_parseElementAt(startPos, startLoc); - } - - parseExprAtom(refShortHandDefaultPos) { - if (this.type === tok.jsxText) - return this.jsx_parseText(); - else if (this.type === tok.jsxTagStart) - return this.jsx_parseElement(); - else - return super.parseExprAtom(refShortHandDefaultPos); - } - - readToken(code) { - let context = this.curContext(); - - if (context === tc_expr) return this.jsx_readToken(); - - if (context === tc_oTag || context === tc_cTag) { - if (isIdentifierStart(code)) return this.jsx_readWord(); - - if (code == 62) { - ++this.pos; - return this.finishToken(tok.jsxTagEnd); - } - - if ((code === 34 || code === 39) && context == tc_oTag) - return this.jsx_readString(code); - } - - if (code === 60 && this.exprAllowed && this.input.charCodeAt(this.pos + 1) !== 33) { - ++this.pos; - return this.finishToken(tok.jsxTagStart); - } - return super.readToken(code); - } - - updateContext(prevType) { - if (this.type == tt.braceL) { - var curContext = this.curContext(); - if (curContext == tc_oTag) this.context.push(tokContexts.b_expr); - else if (curContext == tc_expr) this.context.push(tokContexts.b_tmpl); - else super.updateContext(prevType); - this.exprAllowed = true; - } else if (this.type === tt.slash && prevType === tok.jsxTagStart) { - this.context.length -= 2; // do not consider JSX expr -> JSX open tag -> ... anymore - this.context.push(tc_cTag); // reconsider as closing tag context - this.exprAllowed = false; - } else { - return super.updateContext(prevType); - } - } - }; -} diff --git a/tools/eslint/node_modules/acorn-jsx/package.json b/tools/eslint/node_modules/acorn-jsx/package.json deleted file mode 100644 index 6debde9caa30ba..00000000000000 --- a/tools/eslint/node_modules/acorn-jsx/package.json +++ /dev/null @@ -1,27 +0,0 @@ -{ - "name": "acorn-jsx", - "description": "Modern, fast React.js JSX parser", - "homepage": "https://github.com/acornjs/acorn-jsx", - "version": "5.3.2", - "maintainers": [ - { - "name": "Ingvar Stepanyan", - "email": "me@rreverser.com", - "web": "http://rreverser.com/" - } - ], - "repository": { - "type": "git", - "url": "https://github.com/acornjs/acorn-jsx" - }, - "license": "MIT", - "scripts": { - "test": "node test/run.js" - }, - "peerDependencies": { - "acorn": "^6.0.0 || ^7.0.0 || ^8.0.0" - }, - "devDependencies": { - "acorn": "^8.0.1" - } -} diff --git a/tools/eslint/node_modules/acorn-jsx/xhtml.js b/tools/eslint/node_modules/acorn-jsx/xhtml.js deleted file mode 100644 index c1520092f8e31e..00000000000000 --- a/tools/eslint/node_modules/acorn-jsx/xhtml.js +++ /dev/null @@ -1,255 +0,0 @@ -module.exports = { - quot: '\u0022', - amp: '&', - apos: '\u0027', - lt: '<', - gt: '>', - nbsp: '\u00A0', - iexcl: '\u00A1', - cent: '\u00A2', - pound: '\u00A3', - curren: '\u00A4', - yen: '\u00A5', - brvbar: '\u00A6', - sect: '\u00A7', - uml: '\u00A8', - copy: '\u00A9', - ordf: '\u00AA', - laquo: '\u00AB', - not: '\u00AC', - shy: '\u00AD', - reg: '\u00AE', - macr: '\u00AF', - deg: '\u00B0', - plusmn: '\u00B1', - sup2: '\u00B2', - sup3: '\u00B3', - acute: '\u00B4', - micro: '\u00B5', - para: '\u00B6', - middot: '\u00B7', - cedil: '\u00B8', - sup1: '\u00B9', - ordm: '\u00BA', - raquo: '\u00BB', - frac14: '\u00BC', - frac12: '\u00BD', - frac34: '\u00BE', - iquest: '\u00BF', - Agrave: '\u00C0', - Aacute: '\u00C1', - Acirc: '\u00C2', - Atilde: '\u00C3', - Auml: '\u00C4', - Aring: '\u00C5', - AElig: '\u00C6', - Ccedil: '\u00C7', - Egrave: '\u00C8', - Eacute: '\u00C9', - Ecirc: '\u00CA', - Euml: '\u00CB', - Igrave: '\u00CC', - Iacute: '\u00CD', - Icirc: '\u00CE', - Iuml: '\u00CF', - ETH: '\u00D0', - Ntilde: '\u00D1', - Ograve: '\u00D2', - Oacute: '\u00D3', - Ocirc: '\u00D4', - Otilde: '\u00D5', - Ouml: '\u00D6', - times: '\u00D7', - Oslash: '\u00D8', - Ugrave: '\u00D9', - Uacute: '\u00DA', - Ucirc: '\u00DB', - Uuml: '\u00DC', - Yacute: '\u00DD', - THORN: '\u00DE', - szlig: '\u00DF', - agrave: '\u00E0', - aacute: '\u00E1', - acirc: '\u00E2', - atilde: '\u00E3', - auml: '\u00E4', - aring: '\u00E5', - aelig: '\u00E6', - ccedil: '\u00E7', - egrave: '\u00E8', - eacute: '\u00E9', - ecirc: '\u00EA', - euml: '\u00EB', - igrave: '\u00EC', - iacute: '\u00ED', - icirc: '\u00EE', - iuml: '\u00EF', - eth: '\u00F0', - ntilde: '\u00F1', - ograve: '\u00F2', - oacute: '\u00F3', - ocirc: '\u00F4', - otilde: '\u00F5', - ouml: '\u00F6', - divide: '\u00F7', - oslash: '\u00F8', - ugrave: '\u00F9', - uacute: '\u00FA', - ucirc: '\u00FB', - uuml: '\u00FC', - yacute: '\u00FD', - thorn: '\u00FE', - yuml: '\u00FF', - OElig: '\u0152', - oelig: '\u0153', - Scaron: '\u0160', - scaron: '\u0161', - Yuml: '\u0178', - fnof: '\u0192', - circ: '\u02C6', - tilde: '\u02DC', - Alpha: '\u0391', - Beta: '\u0392', - Gamma: '\u0393', - Delta: '\u0394', - Epsilon: '\u0395', - Zeta: '\u0396', - Eta: '\u0397', - Theta: '\u0398', - Iota: '\u0399', - Kappa: '\u039A', - Lambda: '\u039B', - Mu: '\u039C', - Nu: '\u039D', - Xi: '\u039E', - Omicron: '\u039F', - Pi: '\u03A0', - Rho: '\u03A1', - Sigma: '\u03A3', - Tau: '\u03A4', - Upsilon: '\u03A5', - Phi: '\u03A6', - Chi: '\u03A7', - Psi: '\u03A8', - Omega: '\u03A9', - alpha: '\u03B1', - beta: '\u03B2', - gamma: '\u03B3', - delta: '\u03B4', - epsilon: '\u03B5', - zeta: '\u03B6', - eta: '\u03B7', - theta: '\u03B8', - iota: '\u03B9', - kappa: '\u03BA', - lambda: '\u03BB', - mu: '\u03BC', - nu: '\u03BD', - xi: '\u03BE', - omicron: '\u03BF', - pi: '\u03C0', - rho: '\u03C1', - sigmaf: '\u03C2', - sigma: '\u03C3', - tau: '\u03C4', - upsilon: '\u03C5', - phi: '\u03C6', - chi: '\u03C7', - psi: '\u03C8', - omega: '\u03C9', - thetasym: '\u03D1', - upsih: '\u03D2', - piv: '\u03D6', - ensp: '\u2002', - emsp: '\u2003', - thinsp: '\u2009', - zwnj: '\u200C', - zwj: '\u200D', - lrm: '\u200E', - rlm: '\u200F', - ndash: '\u2013', - mdash: '\u2014', - lsquo: '\u2018', - rsquo: '\u2019', - sbquo: '\u201A', - ldquo: '\u201C', - rdquo: '\u201D', - bdquo: '\u201E', - dagger: '\u2020', - Dagger: '\u2021', - bull: '\u2022', - hellip: '\u2026', - permil: '\u2030', - prime: '\u2032', - Prime: '\u2033', - lsaquo: '\u2039', - rsaquo: '\u203A', - oline: '\u203E', - frasl: '\u2044', - euro: '\u20AC', - image: '\u2111', - weierp: '\u2118', - real: '\u211C', - trade: '\u2122', - alefsym: '\u2135', - larr: '\u2190', - uarr: '\u2191', - rarr: '\u2192', - darr: '\u2193', - harr: '\u2194', - crarr: '\u21B5', - lArr: '\u21D0', - uArr: '\u21D1', - rArr: '\u21D2', - dArr: '\u21D3', - hArr: '\u21D4', - forall: '\u2200', - part: '\u2202', - exist: '\u2203', - empty: '\u2205', - nabla: '\u2207', - isin: '\u2208', - notin: '\u2209', - ni: '\u220B', - prod: '\u220F', - sum: '\u2211', - minus: '\u2212', - lowast: '\u2217', - radic: '\u221A', - prop: '\u221D', - infin: '\u221E', - ang: '\u2220', - and: '\u2227', - or: '\u2228', - cap: '\u2229', - cup: '\u222A', - 'int': '\u222B', - there4: '\u2234', - sim: '\u223C', - cong: '\u2245', - asymp: '\u2248', - ne: '\u2260', - equiv: '\u2261', - le: '\u2264', - ge: '\u2265', - sub: '\u2282', - sup: '\u2283', - nsub: '\u2284', - sube: '\u2286', - supe: '\u2287', - oplus: '\u2295', - otimes: '\u2297', - perp: '\u22A5', - sdot: '\u22C5', - lceil: '\u2308', - rceil: '\u2309', - lfloor: '\u230A', - rfloor: '\u230B', - lang: '\u2329', - rang: '\u232A', - loz: '\u25CA', - spades: '\u2660', - clubs: '\u2663', - hearts: '\u2665', - diams: '\u2666' -}; diff --git a/tools/eslint/node_modules/acorn/LICENSE b/tools/eslint/node_modules/acorn/LICENSE deleted file mode 100644 index 9d71cc63a35e7d..00000000000000 --- a/tools/eslint/node_modules/acorn/LICENSE +++ /dev/null @@ -1,21 +0,0 @@ -MIT License - -Copyright (C) 2012-2022 by various contributors (see AUTHORS) - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. diff --git a/tools/eslint/node_modules/acorn/bin/acorn b/tools/eslint/node_modules/acorn/bin/acorn deleted file mode 100755 index 3ef3c124b08bd4..00000000000000 --- a/tools/eslint/node_modules/acorn/bin/acorn +++ /dev/null @@ -1,4 +0,0 @@ -#!/usr/bin/env node -"use strict" - -require("../dist/bin.js") diff --git a/tools/eslint/node_modules/acorn/dist/acorn.d.mts b/tools/eslint/node_modules/acorn/dist/acorn.d.mts deleted file mode 100644 index cd204b1c50db94..00000000000000 --- a/tools/eslint/node_modules/acorn/dist/acorn.d.mts +++ /dev/null @@ -1,856 +0,0 @@ -export interface Node { - start: number - end: number - type: string - range?: [number, number] - loc?: SourceLocation | null -} - -export interface SourceLocation { - source?: string | null - start: Position - end: Position -} - -export interface Position { - /** 1-based */ - line: number - /** 0-based */ - column: number -} - -export interface Identifier extends Node { - type: "Identifier" - name: string -} - -export interface Literal extends Node { - type: "Literal" - value?: string | boolean | null | number | RegExp | bigint - raw?: string - regex?: { - pattern: string - flags: string - } - bigint?: string -} - -export interface Program extends Node { - type: "Program" - body: Array - sourceType: "script" | "module" -} - -export interface Function extends Node { - id?: Identifier | null - params: Array - body: BlockStatement | Expression - generator: boolean - expression: boolean - async: boolean -} - -export interface ExpressionStatement extends Node { - type: "ExpressionStatement" - expression: Expression | Literal - directive?: string -} - -export interface BlockStatement extends Node { - type: "BlockStatement" - body: Array -} - -export interface EmptyStatement extends Node { - type: "EmptyStatement" -} - -export interface DebuggerStatement extends Node { - type: "DebuggerStatement" -} - -export interface WithStatement extends Node { - type: "WithStatement" - object: Expression - body: Statement -} - -export interface ReturnStatement extends Node { - type: "ReturnStatement" - argument?: Expression | null -} - -export interface LabeledStatement extends Node { - type: "LabeledStatement" - label: Identifier - body: Statement -} - -export interface BreakStatement extends Node { - type: "BreakStatement" - label?: Identifier | null -} - -export interface ContinueStatement extends Node { - type: "ContinueStatement" - label?: Identifier | null -} - -export interface IfStatement extends Node { - type: "IfStatement" - test: Expression - consequent: Statement - alternate?: Statement | null -} - -export interface SwitchStatement extends Node { - type: "SwitchStatement" - discriminant: Expression - cases: Array -} - -export interface SwitchCase extends Node { - type: "SwitchCase" - test?: Expression | null - consequent: Array -} - -export interface ThrowStatement extends Node { - type: "ThrowStatement" - argument: Expression -} - -export interface TryStatement extends Node { - type: "TryStatement" - block: BlockStatement - handler?: CatchClause | null - finalizer?: BlockStatement | null -} - -export interface CatchClause extends Node { - type: "CatchClause" - param?: Pattern | null - body: BlockStatement -} - -export interface WhileStatement extends Node { - type: "WhileStatement" - test: Expression - body: Statement -} - -export interface DoWhileStatement extends Node { - type: "DoWhileStatement" - body: Statement - test: Expression -} - -export interface ForStatement extends Node { - type: "ForStatement" - init?: VariableDeclaration | Expression | null - test?: Expression | null - update?: Expression | null - body: Statement -} - -export interface ForInStatement extends Node { - type: "ForInStatement" - left: VariableDeclaration | Pattern - right: Expression - body: Statement -} - -export interface FunctionDeclaration extends Function { - type: "FunctionDeclaration" - id: Identifier - body: BlockStatement -} - -export interface VariableDeclaration extends Node { - type: "VariableDeclaration" - declarations: Array - kind: "var" | "let" | "const" -} - -export interface VariableDeclarator extends Node { - type: "VariableDeclarator" - id: Pattern - init?: Expression | null -} - -export interface ThisExpression extends Node { - type: "ThisExpression" -} - -export interface ArrayExpression extends Node { - type: "ArrayExpression" - elements: Array -} - -export interface ObjectExpression extends Node { - type: "ObjectExpression" - properties: Array -} - -export interface Property extends Node { - type: "Property" - key: Expression - value: Expression - kind: "init" | "get" | "set" - method: boolean - shorthand: boolean - computed: boolean -} - -export interface FunctionExpression extends Function { - type: "FunctionExpression" - body: BlockStatement -} - -export interface UnaryExpression extends Node { - type: "UnaryExpression" - operator: UnaryOperator - prefix: boolean - argument: Expression -} - -export type UnaryOperator = "-" | "+" | "!" | "~" | "typeof" | "void" | "delete" - -export interface UpdateExpression extends Node { - type: "UpdateExpression" - operator: UpdateOperator - argument: Expression - prefix: boolean -} - -export type UpdateOperator = "++" | "--" - -export interface BinaryExpression extends Node { - type: "BinaryExpression" - operator: BinaryOperator - left: Expression | PrivateIdentifier - right: Expression -} - -export type BinaryOperator = "==" | "!=" | "===" | "!==" | "<" | "<=" | ">" | ">=" | "<<" | ">>" | ">>>" | "+" | "-" | "*" | "/" | "%" | "|" | "^" | "&" | "in" | "instanceof" | "**" - -export interface AssignmentExpression extends Node { - type: "AssignmentExpression" - operator: AssignmentOperator - left: Pattern - right: Expression -} - -export type AssignmentOperator = "=" | "+=" | "-=" | "*=" | "/=" | "%=" | "<<=" | ">>=" | ">>>=" | "|=" | "^=" | "&=" | "**=" | "||=" | "&&=" | "??=" - -export interface LogicalExpression extends Node { - type: "LogicalExpression" - operator: LogicalOperator - left: Expression - right: Expression -} - -export type LogicalOperator = "||" | "&&" | "??" - -export interface MemberExpression extends Node { - type: "MemberExpression" - object: Expression | Super - property: Expression | PrivateIdentifier - computed: boolean - optional: boolean -} - -export interface ConditionalExpression extends Node { - type: "ConditionalExpression" - test: Expression - alternate: Expression - consequent: Expression -} - -export interface CallExpression extends Node { - type: "CallExpression" - callee: Expression | Super - arguments: Array - optional: boolean -} - -export interface NewExpression extends Node { - type: "NewExpression" - callee: Expression - arguments: Array -} - -export interface SequenceExpression extends Node { - type: "SequenceExpression" - expressions: Array -} - -export interface ForOfStatement extends Node { - type: "ForOfStatement" - left: VariableDeclaration | Pattern - right: Expression - body: Statement - await: boolean -} - -export interface Super extends Node { - type: "Super" -} - -export interface SpreadElement extends Node { - type: "SpreadElement" - argument: Expression -} - -export interface ArrowFunctionExpression extends Function { - type: "ArrowFunctionExpression" -} - -export interface YieldExpression extends Node { - type: "YieldExpression" - argument?: Expression | null - delegate: boolean -} - -export interface TemplateLiteral extends Node { - type: "TemplateLiteral" - quasis: Array - expressions: Array -} - -export interface TaggedTemplateExpression extends Node { - type: "TaggedTemplateExpression" - tag: Expression - quasi: TemplateLiteral -} - -export interface TemplateElement extends Node { - type: "TemplateElement" - tail: boolean - value: { - cooked?: string | null - raw: string - } -} - -export interface AssignmentProperty extends Node { - type: "Property" - key: Expression - value: Pattern - kind: "init" - method: false - shorthand: boolean - computed: boolean -} - -export interface ObjectPattern extends Node { - type: "ObjectPattern" - properties: Array -} - -export interface ArrayPattern extends Node { - type: "ArrayPattern" - elements: Array -} - -export interface RestElement extends Node { - type: "RestElement" - argument: Pattern -} - -export interface AssignmentPattern extends Node { - type: "AssignmentPattern" - left: Pattern - right: Expression -} - -export interface Class extends Node { - id?: Identifier | null - superClass?: Expression | null - body: ClassBody -} - -export interface ClassBody extends Node { - type: "ClassBody" - body: Array -} - -export interface MethodDefinition extends Node { - type: "MethodDefinition" - key: Expression | PrivateIdentifier - value: FunctionExpression - kind: "constructor" | "method" | "get" | "set" - computed: boolean - static: boolean -} - -export interface ClassDeclaration extends Class { - type: "ClassDeclaration" - id: Identifier -} - -export interface ClassExpression extends Class { - type: "ClassExpression" -} - -export interface MetaProperty extends Node { - type: "MetaProperty" - meta: Identifier - property: Identifier -} - -export interface ImportDeclaration extends Node { - type: "ImportDeclaration" - specifiers: Array - source: Literal -} - -export interface ImportSpecifier extends Node { - type: "ImportSpecifier" - imported: Identifier | Literal - local: Identifier -} - -export interface ImportDefaultSpecifier extends Node { - type: "ImportDefaultSpecifier" - local: Identifier -} - -export interface ImportNamespaceSpecifier extends Node { - type: "ImportNamespaceSpecifier" - local: Identifier -} - -export interface ExportNamedDeclaration extends Node { - type: "ExportNamedDeclaration" - declaration?: Declaration | null - specifiers: Array - source?: Literal | null -} - -export interface ExportSpecifier extends Node { - type: "ExportSpecifier" - exported: Identifier | Literal - local: Identifier | Literal -} - -export interface AnonymousFunctionDeclaration extends Function { - type: "FunctionDeclaration" - id: null - body: BlockStatement -} - -export interface AnonymousClassDeclaration extends Class { - type: "ClassDeclaration" - id: null -} - -export interface ExportDefaultDeclaration extends Node { - type: "ExportDefaultDeclaration" - declaration: AnonymousFunctionDeclaration | FunctionDeclaration | AnonymousClassDeclaration | ClassDeclaration | Expression -} - -export interface ExportAllDeclaration extends Node { - type: "ExportAllDeclaration" - source: Literal - exported?: Identifier | Literal | null -} - -export interface AwaitExpression extends Node { - type: "AwaitExpression" - argument: Expression -} - -export interface ChainExpression extends Node { - type: "ChainExpression" - expression: MemberExpression | CallExpression -} - -export interface ImportExpression extends Node { - type: "ImportExpression" - source: Expression -} - -export interface ParenthesizedExpression extends Node { - type: "ParenthesizedExpression" - expression: Expression -} - -export interface PropertyDefinition extends Node { - type: "PropertyDefinition" - key: Expression | PrivateIdentifier - value?: Expression | null - computed: boolean - static: boolean -} - -export interface PrivateIdentifier extends Node { - type: "PrivateIdentifier" - name: string -} - -export interface StaticBlock extends Node { - type: "StaticBlock" - body: Array -} - -export type Statement = -| ExpressionStatement -| BlockStatement -| EmptyStatement -| DebuggerStatement -| WithStatement -| ReturnStatement -| LabeledStatement -| BreakStatement -| ContinueStatement -| IfStatement -| SwitchStatement -| ThrowStatement -| TryStatement -| WhileStatement -| DoWhileStatement -| ForStatement -| ForInStatement -| ForOfStatement -| Declaration - -export type Declaration = -| FunctionDeclaration -| VariableDeclaration -| ClassDeclaration - -export type Expression = -| Identifier -| Literal -| ThisExpression -| ArrayExpression -| ObjectExpression -| FunctionExpression -| UnaryExpression -| UpdateExpression -| BinaryExpression -| AssignmentExpression -| LogicalExpression -| MemberExpression -| ConditionalExpression -| CallExpression -| NewExpression -| SequenceExpression -| ArrowFunctionExpression -| YieldExpression -| TemplateLiteral -| TaggedTemplateExpression -| ClassExpression -| MetaProperty -| AwaitExpression -| ChainExpression -| ImportExpression -| ParenthesizedExpression - -export type Pattern = -| Identifier -| MemberExpression -| ObjectPattern -| ArrayPattern -| RestElement -| AssignmentPattern - -export type ModuleDeclaration = -| ImportDeclaration -| ExportNamedDeclaration -| ExportDefaultDeclaration -| ExportAllDeclaration - -export type AnyNode = Statement | Expression | Declaration | ModuleDeclaration | Literal | Program | SwitchCase | CatchClause | Property | Super | SpreadElement | TemplateElement | AssignmentProperty | ObjectPattern | ArrayPattern | RestElement | AssignmentPattern | ClassBody | MethodDefinition | MetaProperty | ImportSpecifier | ImportDefaultSpecifier | ImportNamespaceSpecifier | ExportSpecifier | AnonymousFunctionDeclaration | AnonymousClassDeclaration | PropertyDefinition | PrivateIdentifier | StaticBlock | VariableDeclarator - -export function parse(input: string, options: Options): Program - -export function parseExpressionAt(input: string, pos: number, options: Options): Expression - -export function tokenizer(input: string, options: Options): { - getToken(): Token - [Symbol.iterator](): Iterator -} - -export type ecmaVersion = 3 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 2015 | 2016 | 2017 | 2018 | 2019 | 2020 | 2021 | 2022 | 2023 | 2024 | 2025 | "latest" - -export interface Options { - /** - * `ecmaVersion` indicates the ECMAScript version to parse. Can be a - * number, either in year (`2022`) or plain version number (`6`) form, - * or `"latest"` (the latest the library supports). This influences - * support for strict mode, the set of reserved words, and support for - * new syntax features. - */ - ecmaVersion: ecmaVersion - - /** - * `sourceType` indicates the mode the code should be parsed in. - * Can be either `"script"` or `"module"`. This influences global - * strict mode and parsing of `import` and `export` declarations. - */ - sourceType?: "script" | "module" - - /** - * a callback that will be called when a semicolon is automatically inserted. - * @param lastTokEnd the position of the comma as an offset - * @param lastTokEndLoc location if {@link locations} is enabled - */ - onInsertedSemicolon?: (lastTokEnd: number, lastTokEndLoc?: Position) => void - - /** - * similar to `onInsertedSemicolon`, but for trailing commas - * @param lastTokEnd the position of the comma as an offset - * @param lastTokEndLoc location if `locations` is enabled - */ - onTrailingComma?: (lastTokEnd: number, lastTokEndLoc?: Position) => void - - /** - * By default, reserved words are only enforced if ecmaVersion >= 5. - * Set `allowReserved` to a boolean value to explicitly turn this on - * an off. When this option has the value "never", reserved words - * and keywords can also not be used as property names. - */ - allowReserved?: boolean | "never" - - /** - * When enabled, a return at the top level is not considered an error. - */ - allowReturnOutsideFunction?: boolean - - /** - * When enabled, import/export statements are not constrained to - * appearing at the top of the program, and an import.meta expression - * in a script isn't considered an error. - */ - allowImportExportEverywhere?: boolean - - /** - * By default, `await` identifiers are allowed to appear at the top-level scope only if {@link ecmaVersion} >= 2022. - * When enabled, await identifiers are allowed to appear at the top-level scope, - * but they are still not allowed in non-async functions. - */ - allowAwaitOutsideFunction?: boolean - - /** - * When enabled, super identifiers are not constrained to - * appearing in methods and do not raise an error when they appear elsewhere. - */ - allowSuperOutsideMethod?: boolean - - /** - * When enabled, hashbang directive in the beginning of file is - * allowed and treated as a line comment. Enabled by default when - * {@link ecmaVersion} >= 2023. - */ - allowHashBang?: boolean - - /** - * By default, the parser will verify that private properties are - * only used in places where they are valid and have been declared. - * Set this to false to turn such checks off. - */ - checkPrivateFields?: boolean - - /** - * When `locations` is on, `loc` properties holding objects with - * `start` and `end` properties as {@link Position} objects will be attached to the - * nodes. - */ - locations?: boolean - - /** - * a callback that will cause Acorn to call that export function with object in the same - * format as tokens returned from `tokenizer().getToken()`. Note - * that you are not allowed to call the parser from the - * callbackโ€”that will corrupt its internal state. - */ - onToken?: ((token: Token) => void) | Token[] - - - /** - * This takes a export function or an array. - * - * When a export function is passed, Acorn will call that export function with `(block, text, start, - * end)` parameters whenever a comment is skipped. `block` is a - * boolean indicating whether this is a block (`/* *\/`) comment, - * `text` is the content of the comment, and `start` and `end` are - * character offsets that denote the start and end of the comment. - * When the {@link locations} option is on, two more parameters are - * passed, the full locations of {@link Position} export type of the start and - * end of the comments. - * - * When a array is passed, each found comment of {@link Comment} export type is pushed to the array. - * - * Note that you are not allowed to call the - * parser from the callbackโ€”that will corrupt its internal state. - */ - onComment?: (( - isBlock: boolean, text: string, start: number, end: number, startLoc?: Position, - endLoc?: Position - ) => void) | Comment[] - - /** - * Nodes have their start and end characters offsets recorded in - * `start` and `end` properties (directly on the node, rather than - * the `loc` object, which holds line/column data. To also add a - * [semi-standardized][range] `range` property holding a `[start, - * end]` array with the same numbers, set the `ranges` option to - * `true`. - */ - ranges?: boolean - - /** - * It is possible to parse multiple files into a single AST by - * passing the tree produced by parsing the first file as - * `program` option in subsequent parses. This will add the - * toplevel forms of the parsed file to the `Program` (top) node - * of an existing parse tree. - */ - program?: Node - - /** - * When {@link locations} is on, you can pass this to record the source - * file in every node's `loc` object. - */ - sourceFile?: string - - /** - * This value, if given, is stored in every node, whether {@link locations} is on or off. - */ - directSourceFile?: string - - /** - * When enabled, parenthesized expressions are represented by - * (non-standard) ParenthesizedExpression nodes - */ - preserveParens?: boolean -} - -export class Parser { - options: Options - input: string - - protected constructor(options: Options, input: string, startPos?: number) - parse(): Program - - static parse(input: string, options: Options): Program - static parseExpressionAt(input: string, pos: number, options: Options): Expression - static tokenizer(input: string, options: Options): { - getToken(): Token - [Symbol.iterator](): Iterator - } - static extend(...plugins: ((BaseParser: typeof Parser) => typeof Parser)[]): typeof Parser -} - -export const defaultOptions: Options - -export function getLineInfo(input: string, offset: number): Position - -export class TokenType { - label: string - keyword: string | undefined -} - -export const tokTypes: { - num: TokenType - regexp: TokenType - string: TokenType - name: TokenType - privateId: TokenType - eof: TokenType - - bracketL: TokenType - bracketR: TokenType - braceL: TokenType - braceR: TokenType - parenL: TokenType - parenR: TokenType - comma: TokenType - semi: TokenType - colon: TokenType - dot: TokenType - question: TokenType - questionDot: TokenType - arrow: TokenType - template: TokenType - invalidTemplate: TokenType - ellipsis: TokenType - backQuote: TokenType - dollarBraceL: TokenType - - eq: TokenType - assign: TokenType - incDec: TokenType - prefix: TokenType - logicalOR: TokenType - logicalAND: TokenType - bitwiseOR: TokenType - bitwiseXOR: TokenType - bitwiseAND: TokenType - equality: TokenType - relational: TokenType - bitShift: TokenType - plusMin: TokenType - modulo: TokenType - star: TokenType - slash: TokenType - starstar: TokenType - coalesce: TokenType - - _break: TokenType - _case: TokenType - _catch: TokenType - _continue: TokenType - _debugger: TokenType - _default: TokenType - _do: TokenType - _else: TokenType - _finally: TokenType - _for: TokenType - _function: TokenType - _if: TokenType - _return: TokenType - _switch: TokenType - _throw: TokenType - _try: TokenType - _var: TokenType - _const: TokenType - _while: TokenType - _with: TokenType - _new: TokenType - _this: TokenType - _super: TokenType - _class: TokenType - _extends: TokenType - _export: TokenType - _import: TokenType - _null: TokenType - _true: TokenType - _false: TokenType - _in: TokenType - _instanceof: TokenType - _typeof: TokenType - _void: TokenType - _delete: TokenType -} - -export interface Comment { - type: "Line" | "Block" - value: string - start: number - end: number - loc?: SourceLocation - range?: [number, number] -} - -export class Token { - type: TokenType - start: number - end: number - loc?: SourceLocation - range?: [number, number] -} - -export const version: string diff --git a/tools/eslint/node_modules/acorn/dist/acorn.js b/tools/eslint/node_modules/acorn/dist/acorn.js deleted file mode 100644 index 68bf2a714e294d..00000000000000 --- a/tools/eslint/node_modules/acorn/dist/acorn.js +++ /dev/null @@ -1,6065 +0,0 @@ -(function (global, factory) { - typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) : - typeof define === 'function' && define.amd ? define(['exports'], factory) : - (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.acorn = {})); -})(this, (function (exports) { 'use strict'; - - // This file was generated. Do not modify manually! - var astralIdentifierCodes = [509, 0, 227, 0, 150, 4, 294, 9, 1368, 2, 2, 1, 6, 3, 41, 2, 5, 0, 166, 1, 574, 3, 9, 9, 370, 1, 81, 2, 71, 10, 50, 3, 123, 2, 54, 14, 32, 10, 3, 1, 11, 3, 46, 10, 8, 0, 46, 9, 7, 2, 37, 13, 2, 9, 6, 1, 45, 0, 13, 2, 49, 13, 9, 3, 2, 11, 83, 11, 7, 0, 3, 0, 158, 11, 6, 9, 7, 3, 56, 1, 2, 6, 3, 1, 3, 2, 10, 0, 11, 1, 3, 6, 4, 4, 193, 17, 10, 9, 5, 0, 82, 19, 13, 9, 214, 6, 3, 8, 28, 1, 83, 16, 16, 9, 82, 12, 9, 9, 84, 14, 5, 9, 243, 14, 166, 9, 71, 5, 2, 1, 3, 3, 2, 0, 2, 1, 13, 9, 120, 6, 3, 6, 4, 0, 29, 9, 41, 6, 2, 3, 9, 0, 10, 10, 47, 15, 406, 7, 2, 7, 17, 9, 57, 21, 2, 13, 123, 5, 4, 0, 2, 1, 2, 6, 2, 0, 9, 9, 49, 4, 2, 1, 2, 4, 9, 9, 330, 3, 10, 1, 2, 0, 49, 6, 4, 4, 14, 9, 5351, 0, 7, 14, 13835, 9, 87, 9, 39, 4, 60, 6, 26, 9, 1014, 0, 2, 54, 8, 3, 82, 0, 12, 1, 19628, 1, 4706, 45, 3, 22, 543, 4, 4, 5, 9, 7, 3, 6, 31, 3, 149, 2, 1418, 49, 513, 54, 5, 49, 9, 0, 15, 0, 23, 4, 2, 14, 1361, 6, 2, 16, 3, 6, 2, 1, 2, 4, 101, 0, 161, 6, 10, 9, 357, 0, 62, 13, 499, 13, 983, 6, 110, 6, 6, 9, 4759, 9, 787719, 239]; - - // This file was generated. Do not modify manually! - var astralIdentifierStartCodes = [0, 11, 2, 25, 2, 18, 2, 1, 2, 14, 3, 13, 35, 122, 70, 52, 268, 28, 4, 48, 48, 31, 14, 29, 6, 37, 11, 29, 3, 35, 5, 7, 2, 4, 43, 157, 19, 35, 5, 35, 5, 39, 9, 51, 13, 10, 2, 14, 2, 6, 2, 1, 2, 10, 2, 14, 2, 6, 2, 1, 68, 310, 10, 21, 11, 7, 25, 5, 2, 41, 2, 8, 70, 5, 3, 0, 2, 43, 2, 1, 4, 0, 3, 22, 11, 22, 10, 30, 66, 18, 2, 1, 11, 21, 11, 25, 71, 55, 7, 1, 65, 0, 16, 3, 2, 2, 2, 28, 43, 28, 4, 28, 36, 7, 2, 27, 28, 53, 11, 21, 11, 18, 14, 17, 111, 72, 56, 50, 14, 50, 14, 35, 349, 41, 7, 1, 79, 28, 11, 0, 9, 21, 43, 17, 47, 20, 28, 22, 13, 52, 58, 1, 3, 0, 14, 44, 33, 24, 27, 35, 30, 0, 3, 0, 9, 34, 4, 0, 13, 47, 15, 3, 22, 0, 2, 0, 36, 17, 2, 24, 20, 1, 64, 6, 2, 0, 2, 3, 2, 14, 2, 9, 8, 46, 39, 7, 3, 1, 3, 21, 2, 6, 2, 1, 2, 4, 4, 0, 19, 0, 13, 4, 159, 52, 19, 3, 21, 2, 31, 47, 21, 1, 2, 0, 185, 46, 42, 3, 37, 47, 21, 0, 60, 42, 14, 0, 72, 26, 38, 6, 186, 43, 117, 63, 32, 7, 3, 0, 3, 7, 2, 1, 2, 23, 16, 0, 2, 0, 95, 7, 3, 38, 17, 0, 2, 0, 29, 0, 11, 39, 8, 0, 22, 0, 12, 45, 20, 0, 19, 72, 264, 8, 2, 36, 18, 0, 50, 29, 113, 6, 2, 1, 2, 37, 22, 0, 26, 5, 2, 1, 2, 31, 15, 0, 328, 18, 16, 0, 2, 12, 2, 33, 125, 0, 80, 921, 103, 110, 18, 195, 2637, 96, 16, 1071, 18, 5, 4026, 582, 8634, 568, 8, 30, 18, 78, 18, 29, 19, 47, 17, 3, 32, 20, 6, 18, 689, 63, 129, 74, 6, 0, 67, 12, 65, 1, 2, 0, 29, 6135, 9, 1237, 43, 8, 8936, 3, 2, 6, 2, 1, 2, 290, 16, 0, 30, 2, 3, 0, 15, 3, 9, 395, 2309, 106, 6, 12, 4, 8, 8, 9, 5991, 84, 2, 70, 2, 1, 3, 0, 3, 1, 3, 3, 2, 11, 2, 0, 2, 6, 2, 64, 2, 3, 3, 7, 2, 6, 2, 27, 2, 3, 2, 4, 2, 0, 4, 6, 2, 339, 3, 24, 2, 24, 2, 30, 2, 24, 2, 30, 2, 24, 2, 30, 2, 24, 2, 30, 2, 24, 2, 7, 1845, 30, 7, 5, 262, 61, 147, 44, 11, 6, 17, 0, 322, 29, 19, 43, 485, 27, 757, 6, 2, 3, 2, 1, 2, 14, 2, 196, 60, 67, 8, 0, 1205, 3, 2, 26, 2, 1, 2, 0, 3, 0, 2, 9, 2, 3, 2, 0, 2, 0, 7, 0, 5, 0, 2, 0, 2, 0, 2, 2, 2, 1, 2, 0, 3, 0, 2, 0, 2, 0, 2, 0, 2, 0, 2, 1, 2, 0, 3, 3, 2, 6, 2, 3, 2, 3, 2, 0, 2, 9, 2, 16, 6, 2, 2, 4, 2, 16, 4421, 42719, 33, 4153, 7, 221, 3, 5761, 15, 7472, 16, 621, 2467, 541, 1507, 4938, 6, 4191]; - - // This file was generated. Do not modify manually! - var nonASCIIidentifierChars = "\u200c\u200d\xb7\u0300-\u036f\u0387\u0483-\u0487\u0591-\u05bd\u05bf\u05c1\u05c2\u05c4\u05c5\u05c7\u0610-\u061a\u064b-\u0669\u0670\u06d6-\u06dc\u06df-\u06e4\u06e7\u06e8\u06ea-\u06ed\u06f0-\u06f9\u0711\u0730-\u074a\u07a6-\u07b0\u07c0-\u07c9\u07eb-\u07f3\u07fd\u0816-\u0819\u081b-\u0823\u0825-\u0827\u0829-\u082d\u0859-\u085b\u0898-\u089f\u08ca-\u08e1\u08e3-\u0903\u093a-\u093c\u093e-\u094f\u0951-\u0957\u0962\u0963\u0966-\u096f\u0981-\u0983\u09bc\u09be-\u09c4\u09c7\u09c8\u09cb-\u09cd\u09d7\u09e2\u09e3\u09e6-\u09ef\u09fe\u0a01-\u0a03\u0a3c\u0a3e-\u0a42\u0a47\u0a48\u0a4b-\u0a4d\u0a51\u0a66-\u0a71\u0a75\u0a81-\u0a83\u0abc\u0abe-\u0ac5\u0ac7-\u0ac9\u0acb-\u0acd\u0ae2\u0ae3\u0ae6-\u0aef\u0afa-\u0aff\u0b01-\u0b03\u0b3c\u0b3e-\u0b44\u0b47\u0b48\u0b4b-\u0b4d\u0b55-\u0b57\u0b62\u0b63\u0b66-\u0b6f\u0b82\u0bbe-\u0bc2\u0bc6-\u0bc8\u0bca-\u0bcd\u0bd7\u0be6-\u0bef\u0c00-\u0c04\u0c3c\u0c3e-\u0c44\u0c46-\u0c48\u0c4a-\u0c4d\u0c55\u0c56\u0c62\u0c63\u0c66-\u0c6f\u0c81-\u0c83\u0cbc\u0cbe-\u0cc4\u0cc6-\u0cc8\u0cca-\u0ccd\u0cd5\u0cd6\u0ce2\u0ce3\u0ce6-\u0cef\u0cf3\u0d00-\u0d03\u0d3b\u0d3c\u0d3e-\u0d44\u0d46-\u0d48\u0d4a-\u0d4d\u0d57\u0d62\u0d63\u0d66-\u0d6f\u0d81-\u0d83\u0dca\u0dcf-\u0dd4\u0dd6\u0dd8-\u0ddf\u0de6-\u0def\u0df2\u0df3\u0e31\u0e34-\u0e3a\u0e47-\u0e4e\u0e50-\u0e59\u0eb1\u0eb4-\u0ebc\u0ec8-\u0ece\u0ed0-\u0ed9\u0f18\u0f19\u0f20-\u0f29\u0f35\u0f37\u0f39\u0f3e\u0f3f\u0f71-\u0f84\u0f86\u0f87\u0f8d-\u0f97\u0f99-\u0fbc\u0fc6\u102b-\u103e\u1040-\u1049\u1056-\u1059\u105e-\u1060\u1062-\u1064\u1067-\u106d\u1071-\u1074\u1082-\u108d\u108f-\u109d\u135d-\u135f\u1369-\u1371\u1712-\u1715\u1732-\u1734\u1752\u1753\u1772\u1773\u17b4-\u17d3\u17dd\u17e0-\u17e9\u180b-\u180d\u180f-\u1819\u18a9\u1920-\u192b\u1930-\u193b\u1946-\u194f\u19d0-\u19da\u1a17-\u1a1b\u1a55-\u1a5e\u1a60-\u1a7c\u1a7f-\u1a89\u1a90-\u1a99\u1ab0-\u1abd\u1abf-\u1ace\u1b00-\u1b04\u1b34-\u1b44\u1b50-\u1b59\u1b6b-\u1b73\u1b80-\u1b82\u1ba1-\u1bad\u1bb0-\u1bb9\u1be6-\u1bf3\u1c24-\u1c37\u1c40-\u1c49\u1c50-\u1c59\u1cd0-\u1cd2\u1cd4-\u1ce8\u1ced\u1cf4\u1cf7-\u1cf9\u1dc0-\u1dff\u200c\u200d\u203f\u2040\u2054\u20d0-\u20dc\u20e1\u20e5-\u20f0\u2cef-\u2cf1\u2d7f\u2de0-\u2dff\u302a-\u302f\u3099\u309a\u30fb\ua620-\ua629\ua66f\ua674-\ua67d\ua69e\ua69f\ua6f0\ua6f1\ua802\ua806\ua80b\ua823-\ua827\ua82c\ua880\ua881\ua8b4-\ua8c5\ua8d0-\ua8d9\ua8e0-\ua8f1\ua8ff-\ua909\ua926-\ua92d\ua947-\ua953\ua980-\ua983\ua9b3-\ua9c0\ua9d0-\ua9d9\ua9e5\ua9f0-\ua9f9\uaa29-\uaa36\uaa43\uaa4c\uaa4d\uaa50-\uaa59\uaa7b-\uaa7d\uaab0\uaab2-\uaab4\uaab7\uaab8\uaabe\uaabf\uaac1\uaaeb-\uaaef\uaaf5\uaaf6\uabe3-\uabea\uabec\uabed\uabf0-\uabf9\ufb1e\ufe00-\ufe0f\ufe20-\ufe2f\ufe33\ufe34\ufe4d-\ufe4f\uff10-\uff19\uff3f\uff65"; - - // This file was generated. Do not modify manually! - var nonASCIIidentifierStartChars = "\xaa\xb5\xba\xc0-\xd6\xd8-\xf6\xf8-\u02c1\u02c6-\u02d1\u02e0-\u02e4\u02ec\u02ee\u0370-\u0374\u0376\u0377\u037a-\u037d\u037f\u0386\u0388-\u038a\u038c\u038e-\u03a1\u03a3-\u03f5\u03f7-\u0481\u048a-\u052f\u0531-\u0556\u0559\u0560-\u0588\u05d0-\u05ea\u05ef-\u05f2\u0620-\u064a\u066e\u066f\u0671-\u06d3\u06d5\u06e5\u06e6\u06ee\u06ef\u06fa-\u06fc\u06ff\u0710\u0712-\u072f\u074d-\u07a5\u07b1\u07ca-\u07ea\u07f4\u07f5\u07fa\u0800-\u0815\u081a\u0824\u0828\u0840-\u0858\u0860-\u086a\u0870-\u0887\u0889-\u088e\u08a0-\u08c9\u0904-\u0939\u093d\u0950\u0958-\u0961\u0971-\u0980\u0985-\u098c\u098f\u0990\u0993-\u09a8\u09aa-\u09b0\u09b2\u09b6-\u09b9\u09bd\u09ce\u09dc\u09dd\u09df-\u09e1\u09f0\u09f1\u09fc\u0a05-\u0a0a\u0a0f\u0a10\u0a13-\u0a28\u0a2a-\u0a30\u0a32\u0a33\u0a35\u0a36\u0a38\u0a39\u0a59-\u0a5c\u0a5e\u0a72-\u0a74\u0a85-\u0a8d\u0a8f-\u0a91\u0a93-\u0aa8\u0aaa-\u0ab0\u0ab2\u0ab3\u0ab5-\u0ab9\u0abd\u0ad0\u0ae0\u0ae1\u0af9\u0b05-\u0b0c\u0b0f\u0b10\u0b13-\u0b28\u0b2a-\u0b30\u0b32\u0b33\u0b35-\u0b39\u0b3d\u0b5c\u0b5d\u0b5f-\u0b61\u0b71\u0b83\u0b85-\u0b8a\u0b8e-\u0b90\u0b92-\u0b95\u0b99\u0b9a\u0b9c\u0b9e\u0b9f\u0ba3\u0ba4\u0ba8-\u0baa\u0bae-\u0bb9\u0bd0\u0c05-\u0c0c\u0c0e-\u0c10\u0c12-\u0c28\u0c2a-\u0c39\u0c3d\u0c58-\u0c5a\u0c5d\u0c60\u0c61\u0c80\u0c85-\u0c8c\u0c8e-\u0c90\u0c92-\u0ca8\u0caa-\u0cb3\u0cb5-\u0cb9\u0cbd\u0cdd\u0cde\u0ce0\u0ce1\u0cf1\u0cf2\u0d04-\u0d0c\u0d0e-\u0d10\u0d12-\u0d3a\u0d3d\u0d4e\u0d54-\u0d56\u0d5f-\u0d61\u0d7a-\u0d7f\u0d85-\u0d96\u0d9a-\u0db1\u0db3-\u0dbb\u0dbd\u0dc0-\u0dc6\u0e01-\u0e30\u0e32\u0e33\u0e40-\u0e46\u0e81\u0e82\u0e84\u0e86-\u0e8a\u0e8c-\u0ea3\u0ea5\u0ea7-\u0eb0\u0eb2\u0eb3\u0ebd\u0ec0-\u0ec4\u0ec6\u0edc-\u0edf\u0f00\u0f40-\u0f47\u0f49-\u0f6c\u0f88-\u0f8c\u1000-\u102a\u103f\u1050-\u1055\u105a-\u105d\u1061\u1065\u1066\u106e-\u1070\u1075-\u1081\u108e\u10a0-\u10c5\u10c7\u10cd\u10d0-\u10fa\u10fc-\u1248\u124a-\u124d\u1250-\u1256\u1258\u125a-\u125d\u1260-\u1288\u128a-\u128d\u1290-\u12b0\u12b2-\u12b5\u12b8-\u12be\u12c0\u12c2-\u12c5\u12c8-\u12d6\u12d8-\u1310\u1312-\u1315\u1318-\u135a\u1380-\u138f\u13a0-\u13f5\u13f8-\u13fd\u1401-\u166c\u166f-\u167f\u1681-\u169a\u16a0-\u16ea\u16ee-\u16f8\u1700-\u1711\u171f-\u1731\u1740-\u1751\u1760-\u176c\u176e-\u1770\u1780-\u17b3\u17d7\u17dc\u1820-\u1878\u1880-\u18a8\u18aa\u18b0-\u18f5\u1900-\u191e\u1950-\u196d\u1970-\u1974\u1980-\u19ab\u19b0-\u19c9\u1a00-\u1a16\u1a20-\u1a54\u1aa7\u1b05-\u1b33\u1b45-\u1b4c\u1b83-\u1ba0\u1bae\u1baf\u1bba-\u1be5\u1c00-\u1c23\u1c4d-\u1c4f\u1c5a-\u1c7d\u1c80-\u1c88\u1c90-\u1cba\u1cbd-\u1cbf\u1ce9-\u1cec\u1cee-\u1cf3\u1cf5\u1cf6\u1cfa\u1d00-\u1dbf\u1e00-\u1f15\u1f18-\u1f1d\u1f20-\u1f45\u1f48-\u1f4d\u1f50-\u1f57\u1f59\u1f5b\u1f5d\u1f5f-\u1f7d\u1f80-\u1fb4\u1fb6-\u1fbc\u1fbe\u1fc2-\u1fc4\u1fc6-\u1fcc\u1fd0-\u1fd3\u1fd6-\u1fdb\u1fe0-\u1fec\u1ff2-\u1ff4\u1ff6-\u1ffc\u2071\u207f\u2090-\u209c\u2102\u2107\u210a-\u2113\u2115\u2118-\u211d\u2124\u2126\u2128\u212a-\u2139\u213c-\u213f\u2145-\u2149\u214e\u2160-\u2188\u2c00-\u2ce4\u2ceb-\u2cee\u2cf2\u2cf3\u2d00-\u2d25\u2d27\u2d2d\u2d30-\u2d67\u2d6f\u2d80-\u2d96\u2da0-\u2da6\u2da8-\u2dae\u2db0-\u2db6\u2db8-\u2dbe\u2dc0-\u2dc6\u2dc8-\u2dce\u2dd0-\u2dd6\u2dd8-\u2dde\u3005-\u3007\u3021-\u3029\u3031-\u3035\u3038-\u303c\u3041-\u3096\u309b-\u309f\u30a1-\u30fa\u30fc-\u30ff\u3105-\u312f\u3131-\u318e\u31a0-\u31bf\u31f0-\u31ff\u3400-\u4dbf\u4e00-\ua48c\ua4d0-\ua4fd\ua500-\ua60c\ua610-\ua61f\ua62a\ua62b\ua640-\ua66e\ua67f-\ua69d\ua6a0-\ua6ef\ua717-\ua71f\ua722-\ua788\ua78b-\ua7ca\ua7d0\ua7d1\ua7d3\ua7d5-\ua7d9\ua7f2-\ua801\ua803-\ua805\ua807-\ua80a\ua80c-\ua822\ua840-\ua873\ua882-\ua8b3\ua8f2-\ua8f7\ua8fb\ua8fd\ua8fe\ua90a-\ua925\ua930-\ua946\ua960-\ua97c\ua984-\ua9b2\ua9cf\ua9e0-\ua9e4\ua9e6-\ua9ef\ua9fa-\ua9fe\uaa00-\uaa28\uaa40-\uaa42\uaa44-\uaa4b\uaa60-\uaa76\uaa7a\uaa7e-\uaaaf\uaab1\uaab5\uaab6\uaab9-\uaabd\uaac0\uaac2\uaadb-\uaadd\uaae0-\uaaea\uaaf2-\uaaf4\uab01-\uab06\uab09-\uab0e\uab11-\uab16\uab20-\uab26\uab28-\uab2e\uab30-\uab5a\uab5c-\uab69\uab70-\uabe2\uac00-\ud7a3\ud7b0-\ud7c6\ud7cb-\ud7fb\uf900-\ufa6d\ufa70-\ufad9\ufb00-\ufb06\ufb13-\ufb17\ufb1d\ufb1f-\ufb28\ufb2a-\ufb36\ufb38-\ufb3c\ufb3e\ufb40\ufb41\ufb43\ufb44\ufb46-\ufbb1\ufbd3-\ufd3d\ufd50-\ufd8f\ufd92-\ufdc7\ufdf0-\ufdfb\ufe70-\ufe74\ufe76-\ufefc\uff21-\uff3a\uff41-\uff5a\uff66-\uffbe\uffc2-\uffc7\uffca-\uffcf\uffd2-\uffd7\uffda-\uffdc"; - - // These are a run-length and offset encoded representation of the - // >0xffff code points that are a valid part of identifiers. The - // offset starts at 0x10000, and each pair of numbers represents an - // offset to the next range, and then a size of the range. - - // Reserved word lists for various dialects of the language - - var reservedWords = { - 3: "abstract boolean byte char class double enum export extends final float goto implements import int interface long native package private protected public short static super synchronized throws transient volatile", - 5: "class enum extends super const export import", - 6: "enum", - strict: "implements interface let package private protected public static yield", - strictBind: "eval arguments" - }; - - // And the keywords - - var ecma5AndLessKeywords = "break case catch continue debugger default do else finally for function if return switch throw try var while with null true false instanceof typeof void delete new in this"; - - var keywords$1 = { - 5: ecma5AndLessKeywords, - "5module": ecma5AndLessKeywords + " export import", - 6: ecma5AndLessKeywords + " const class extends export import super" - }; - - var keywordRelationalOperator = /^in(stanceof)?$/; - - // ## Character categories - - var nonASCIIidentifierStart = new RegExp("[" + nonASCIIidentifierStartChars + "]"); - var nonASCIIidentifier = new RegExp("[" + nonASCIIidentifierStartChars + nonASCIIidentifierChars + "]"); - - // This has a complexity linear to the value of the code. The - // assumption is that looking up astral identifier characters is - // rare. - function isInAstralSet(code, set) { - var pos = 0x10000; - for (var i = 0; i < set.length; i += 2) { - pos += set[i]; - if (pos > code) { return false } - pos += set[i + 1]; - if (pos >= code) { return true } - } - return false - } - - // Test whether a given character code starts an identifier. - - function isIdentifierStart(code, astral) { - if (code < 65) { return code === 36 } - if (code < 91) { return true } - if (code < 97) { return code === 95 } - if (code < 123) { return true } - if (code <= 0xffff) { return code >= 0xaa && nonASCIIidentifierStart.test(String.fromCharCode(code)) } - if (astral === false) { return false } - return isInAstralSet(code, astralIdentifierStartCodes) - } - - // Test whether a given character is part of an identifier. - - function isIdentifierChar(code, astral) { - if (code < 48) { return code === 36 } - if (code < 58) { return true } - if (code < 65) { return false } - if (code < 91) { return true } - if (code < 97) { return code === 95 } - if (code < 123) { return true } - if (code <= 0xffff) { return code >= 0xaa && nonASCIIidentifier.test(String.fromCharCode(code)) } - if (astral === false) { return false } - return isInAstralSet(code, astralIdentifierStartCodes) || isInAstralSet(code, astralIdentifierCodes) - } - - // ## Token types - - // The assignment of fine-grained, information-carrying type objects - // allows the tokenizer to store the information it has about a - // token in a way that is very cheap for the parser to look up. - - // All token type variables start with an underscore, to make them - // easy to recognize. - - // The `beforeExpr` property is used to disambiguate between regular - // expressions and divisions. It is set on all token types that can - // be followed by an expression (thus, a slash after them would be a - // regular expression). - // - // The `startsExpr` property is used to check if the token ends a - // `yield` expression. It is set on all token types that either can - // directly start an expression (like a quotation mark) or can - // continue an expression (like the body of a string). - // - // `isLoop` marks a keyword as starting a loop, which is important - // to know when parsing a label, in order to allow or disallow - // continue jumps to that label. - - var TokenType = function TokenType(label, conf) { - if ( conf === void 0 ) conf = {}; - - this.label = label; - this.keyword = conf.keyword; - this.beforeExpr = !!conf.beforeExpr; - this.startsExpr = !!conf.startsExpr; - this.isLoop = !!conf.isLoop; - this.isAssign = !!conf.isAssign; - this.prefix = !!conf.prefix; - this.postfix = !!conf.postfix; - this.binop = conf.binop || null; - this.updateContext = null; - }; - - function binop(name, prec) { - return new TokenType(name, {beforeExpr: true, binop: prec}) - } - var beforeExpr = {beforeExpr: true}, startsExpr = {startsExpr: true}; - - // Map keyword names to token types. - - var keywords = {}; - - // Succinct definitions of keyword token types - function kw(name, options) { - if ( options === void 0 ) options = {}; - - options.keyword = name; - return keywords[name] = new TokenType(name, options) - } - - var types$1 = { - num: new TokenType("num", startsExpr), - regexp: new TokenType("regexp", startsExpr), - string: new TokenType("string", startsExpr), - name: new TokenType("name", startsExpr), - privateId: new TokenType("privateId", startsExpr), - eof: new TokenType("eof"), - - // Punctuation token types. - bracketL: new TokenType("[", {beforeExpr: true, startsExpr: true}), - bracketR: new TokenType("]"), - braceL: new TokenType("{", {beforeExpr: true, startsExpr: true}), - braceR: new TokenType("}"), - parenL: new TokenType("(", {beforeExpr: true, startsExpr: true}), - parenR: new TokenType(")"), - comma: new TokenType(",", beforeExpr), - semi: new TokenType(";", beforeExpr), - colon: new TokenType(":", beforeExpr), - dot: new TokenType("."), - question: new TokenType("?", beforeExpr), - questionDot: new TokenType("?."), - arrow: new TokenType("=>", beforeExpr), - template: new TokenType("template"), - invalidTemplate: new TokenType("invalidTemplate"), - ellipsis: new TokenType("...", beforeExpr), - backQuote: new TokenType("`", startsExpr), - dollarBraceL: new TokenType("${", {beforeExpr: true, startsExpr: true}), - - // Operators. These carry several kinds of properties to help the - // parser use them properly (the presence of these properties is - // what categorizes them as operators). - // - // `binop`, when present, specifies that this operator is a binary - // operator, and will refer to its precedence. - // - // `prefix` and `postfix` mark the operator as a prefix or postfix - // unary operator. - // - // `isAssign` marks all of `=`, `+=`, `-=` etcetera, which act as - // binary operators with a very low precedence, that should result - // in AssignmentExpression nodes. - - eq: new TokenType("=", {beforeExpr: true, isAssign: true}), - assign: new TokenType("_=", {beforeExpr: true, isAssign: true}), - incDec: new TokenType("++/--", {prefix: true, postfix: true, startsExpr: true}), - prefix: new TokenType("!/~", {beforeExpr: true, prefix: true, startsExpr: true}), - logicalOR: binop("||", 1), - logicalAND: binop("&&", 2), - bitwiseOR: binop("|", 3), - bitwiseXOR: binop("^", 4), - bitwiseAND: binop("&", 5), - equality: binop("==/!=/===/!==", 6), - relational: binop("/<=/>=", 7), - bitShift: binop("<>/>>>", 8), - plusMin: new TokenType("+/-", {beforeExpr: true, binop: 9, prefix: true, startsExpr: true}), - modulo: binop("%", 10), - star: binop("*", 10), - slash: binop("/", 10), - starstar: new TokenType("**", {beforeExpr: true}), - coalesce: binop("??", 1), - - // Keyword token types. - _break: kw("break"), - _case: kw("case", beforeExpr), - _catch: kw("catch"), - _continue: kw("continue"), - _debugger: kw("debugger"), - _default: kw("default", beforeExpr), - _do: kw("do", {isLoop: true, beforeExpr: true}), - _else: kw("else", beforeExpr), - _finally: kw("finally"), - _for: kw("for", {isLoop: true}), - _function: kw("function", startsExpr), - _if: kw("if"), - _return: kw("return", beforeExpr), - _switch: kw("switch"), - _throw: kw("throw", beforeExpr), - _try: kw("try"), - _var: kw("var"), - _const: kw("const"), - _while: kw("while", {isLoop: true}), - _with: kw("with"), - _new: kw("new", {beforeExpr: true, startsExpr: true}), - _this: kw("this", startsExpr), - _super: kw("super", startsExpr), - _class: kw("class", startsExpr), - _extends: kw("extends", beforeExpr), - _export: kw("export"), - _import: kw("import", startsExpr), - _null: kw("null", startsExpr), - _true: kw("true", startsExpr), - _false: kw("false", startsExpr), - _in: kw("in", {beforeExpr: true, binop: 7}), - _instanceof: kw("instanceof", {beforeExpr: true, binop: 7}), - _typeof: kw("typeof", {beforeExpr: true, prefix: true, startsExpr: true}), - _void: kw("void", {beforeExpr: true, prefix: true, startsExpr: true}), - _delete: kw("delete", {beforeExpr: true, prefix: true, startsExpr: true}) - }; - - // Matches a whole line break (where CRLF is considered a single - // line break). Used to count lines. - - var lineBreak = /\r\n?|\n|\u2028|\u2029/; - var lineBreakG = new RegExp(lineBreak.source, "g"); - - function isNewLine(code) { - return code === 10 || code === 13 || code === 0x2028 || code === 0x2029 - } - - function nextLineBreak(code, from, end) { - if ( end === void 0 ) end = code.length; - - for (var i = from; i < end; i++) { - var next = code.charCodeAt(i); - if (isNewLine(next)) - { return i < end - 1 && next === 13 && code.charCodeAt(i + 1) === 10 ? i + 2 : i + 1 } - } - return -1 - } - - var nonASCIIwhitespace = /[\u1680\u2000-\u200a\u202f\u205f\u3000\ufeff]/; - - var skipWhiteSpace = /(?:\s|\/\/.*|\/\*[^]*?\*\/)*/g; - - var ref = Object.prototype; - var hasOwnProperty = ref.hasOwnProperty; - var toString = ref.toString; - - var hasOwn = Object.hasOwn || (function (obj, propName) { return ( - hasOwnProperty.call(obj, propName) - ); }); - - var isArray = Array.isArray || (function (obj) { return ( - toString.call(obj) === "[object Array]" - ); }); - - var regexpCache = Object.create(null); - - function wordsRegexp(words) { - return regexpCache[words] || (regexpCache[words] = new RegExp("^(?:" + words.replace(/ /g, "|") + ")$")) - } - - function codePointToString(code) { - // UTF-16 Decoding - if (code <= 0xFFFF) { return String.fromCharCode(code) } - code -= 0x10000; - return String.fromCharCode((code >> 10) + 0xD800, (code & 1023) + 0xDC00) - } - - var loneSurrogate = /(?:[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])/; - - // These are used when `options.locations` is on, for the - // `startLoc` and `endLoc` properties. - - var Position = function Position(line, col) { - this.line = line; - this.column = col; - }; - - Position.prototype.offset = function offset (n) { - return new Position(this.line, this.column + n) - }; - - var SourceLocation = function SourceLocation(p, start, end) { - this.start = start; - this.end = end; - if (p.sourceFile !== null) { this.source = p.sourceFile; } - }; - - // The `getLineInfo` function is mostly useful when the - // `locations` option is off (for performance reasons) and you - // want to find the line/column position for a given character - // offset. `input` should be the code string that the offset refers - // into. - - function getLineInfo(input, offset) { - for (var line = 1, cur = 0;;) { - var nextBreak = nextLineBreak(input, cur, offset); - if (nextBreak < 0) { return new Position(line, offset - cur) } - ++line; - cur = nextBreak; - } - } - - // A second argument must be given to configure the parser process. - // These options are recognized (only `ecmaVersion` is required): - - var defaultOptions = { - // `ecmaVersion` indicates the ECMAScript version to parse. Must be - // either 3, 5, 6 (or 2015), 7 (2016), 8 (2017), 9 (2018), 10 - // (2019), 11 (2020), 12 (2021), 13 (2022), 14 (2023), or `"latest"` - // (the latest version the library supports). This influences - // support for strict mode, the set of reserved words, and support - // for new syntax features. - ecmaVersion: null, - // `sourceType` indicates the mode the code should be parsed in. - // Can be either `"script"` or `"module"`. This influences global - // strict mode and parsing of `import` and `export` declarations. - sourceType: "script", - // `onInsertedSemicolon` can be a callback that will be called when - // a semicolon is automatically inserted. It will be passed the - // position of the inserted semicolon as an offset, and if - // `locations` is enabled, it is given the location as a `{line, - // column}` object as second argument. - onInsertedSemicolon: null, - // `onTrailingComma` is similar to `onInsertedSemicolon`, but for - // trailing commas. - onTrailingComma: null, - // By default, reserved words are only enforced if ecmaVersion >= 5. - // Set `allowReserved` to a boolean value to explicitly turn this on - // an off. When this option has the value "never", reserved words - // and keywords can also not be used as property names. - allowReserved: null, - // When enabled, a return at the top level is not considered an - // error. - allowReturnOutsideFunction: false, - // When enabled, import/export statements are not constrained to - // appearing at the top of the program, and an import.meta expression - // in a script isn't considered an error. - allowImportExportEverywhere: false, - // By default, await identifiers are allowed to appear at the top-level scope only if ecmaVersion >= 2022. - // When enabled, await identifiers are allowed to appear at the top-level scope, - // but they are still not allowed in non-async functions. - allowAwaitOutsideFunction: null, - // When enabled, super identifiers are not constrained to - // appearing in methods and do not raise an error when they appear elsewhere. - allowSuperOutsideMethod: null, - // When enabled, hashbang directive in the beginning of file is - // allowed and treated as a line comment. Enabled by default when - // `ecmaVersion` >= 2023. - allowHashBang: false, - // By default, the parser will verify that private properties are - // only used in places where they are valid and have been declared. - // Set this to false to turn such checks off. - checkPrivateFields: true, - // When `locations` is on, `loc` properties holding objects with - // `start` and `end` properties in `{line, column}` form (with - // line being 1-based and column 0-based) will be attached to the - // nodes. - locations: false, - // A function can be passed as `onToken` option, which will - // cause Acorn to call that function with object in the same - // format as tokens returned from `tokenizer().getToken()`. Note - // that you are not allowed to call the parser from the - // callbackโ€”that will corrupt its internal state. - onToken: null, - // A function can be passed as `onComment` option, which will - // cause Acorn to call that function with `(block, text, start, - // end)` parameters whenever a comment is skipped. `block` is a - // boolean indicating whether this is a block (`/* */`) comment, - // `text` is the content of the comment, and `start` and `end` are - // character offsets that denote the start and end of the comment. - // When the `locations` option is on, two more parameters are - // passed, the full `{line, column}` locations of the start and - // end of the comments. Note that you are not allowed to call the - // parser from the callbackโ€”that will corrupt its internal state. - // When this option has an array as value, objects representing the - // comments are pushed to it. - onComment: null, - // Nodes have their start and end characters offsets recorded in - // `start` and `end` properties (directly on the node, rather than - // the `loc` object, which holds line/column data. To also add a - // [semi-standardized][range] `range` property holding a `[start, - // end]` array with the same numbers, set the `ranges` option to - // `true`. - // - // [range]: https://bugzilla.mozilla.org/show_bug.cgi?id=745678 - ranges: false, - // It is possible to parse multiple files into a single AST by - // passing the tree produced by parsing the first file as - // `program` option in subsequent parses. This will add the - // toplevel forms of the parsed file to the `Program` (top) node - // of an existing parse tree. - program: null, - // When `locations` is on, you can pass this to record the source - // file in every node's `loc` object. - sourceFile: null, - // This value, if given, is stored in every node, whether - // `locations` is on or off. - directSourceFile: null, - // When enabled, parenthesized expressions are represented by - // (non-standard) ParenthesizedExpression nodes - preserveParens: false - }; - - // Interpret and default an options object - - var warnedAboutEcmaVersion = false; - - function getOptions(opts) { - var options = {}; - - for (var opt in defaultOptions) - { options[opt] = opts && hasOwn(opts, opt) ? opts[opt] : defaultOptions[opt]; } - - if (options.ecmaVersion === "latest") { - options.ecmaVersion = 1e8; - } else if (options.ecmaVersion == null) { - if (!warnedAboutEcmaVersion && typeof console === "object" && console.warn) { - warnedAboutEcmaVersion = true; - console.warn("Since Acorn 8.0.0, options.ecmaVersion is required.\nDefaulting to 2020, but this will stop working in the future."); - } - options.ecmaVersion = 11; - } else if (options.ecmaVersion >= 2015) { - options.ecmaVersion -= 2009; - } - - if (options.allowReserved == null) - { options.allowReserved = options.ecmaVersion < 5; } - - if (!opts || opts.allowHashBang == null) - { options.allowHashBang = options.ecmaVersion >= 14; } - - if (isArray(options.onToken)) { - var tokens = options.onToken; - options.onToken = function (token) { return tokens.push(token); }; - } - if (isArray(options.onComment)) - { options.onComment = pushComment(options, options.onComment); } - - return options - } - - function pushComment(options, array) { - return function(block, text, start, end, startLoc, endLoc) { - var comment = { - type: block ? "Block" : "Line", - value: text, - start: start, - end: end - }; - if (options.locations) - { comment.loc = new SourceLocation(this, startLoc, endLoc); } - if (options.ranges) - { comment.range = [start, end]; } - array.push(comment); - } - } - - // Each scope gets a bitset that may contain these flags - var - SCOPE_TOP = 1, - SCOPE_FUNCTION = 2, - SCOPE_ASYNC = 4, - SCOPE_GENERATOR = 8, - SCOPE_ARROW = 16, - SCOPE_SIMPLE_CATCH = 32, - SCOPE_SUPER = 64, - SCOPE_DIRECT_SUPER = 128, - SCOPE_CLASS_STATIC_BLOCK = 256, - SCOPE_VAR = SCOPE_TOP | SCOPE_FUNCTION | SCOPE_CLASS_STATIC_BLOCK; - - function functionFlags(async, generator) { - return SCOPE_FUNCTION | (async ? SCOPE_ASYNC : 0) | (generator ? SCOPE_GENERATOR : 0) - } - - // Used in checkLVal* and declareName to determine the type of a binding - var - BIND_NONE = 0, // Not a binding - BIND_VAR = 1, // Var-style binding - BIND_LEXICAL = 2, // Let- or const-style binding - BIND_FUNCTION = 3, // Function declaration - BIND_SIMPLE_CATCH = 4, // Simple (identifier pattern) catch binding - BIND_OUTSIDE = 5; // Special case for function names as bound inside the function - - var Parser = function Parser(options, input, startPos) { - this.options = options = getOptions(options); - this.sourceFile = options.sourceFile; - this.keywords = wordsRegexp(keywords$1[options.ecmaVersion >= 6 ? 6 : options.sourceType === "module" ? "5module" : 5]); - var reserved = ""; - if (options.allowReserved !== true) { - reserved = reservedWords[options.ecmaVersion >= 6 ? 6 : options.ecmaVersion === 5 ? 5 : 3]; - if (options.sourceType === "module") { reserved += " await"; } - } - this.reservedWords = wordsRegexp(reserved); - var reservedStrict = (reserved ? reserved + " " : "") + reservedWords.strict; - this.reservedWordsStrict = wordsRegexp(reservedStrict); - this.reservedWordsStrictBind = wordsRegexp(reservedStrict + " " + reservedWords.strictBind); - this.input = String(input); - - // Used to signal to callers of `readWord1` whether the word - // contained any escape sequences. This is needed because words with - // escape sequences must not be interpreted as keywords. - this.containsEsc = false; - - // Set up token state - - // The current position of the tokenizer in the input. - if (startPos) { - this.pos = startPos; - this.lineStart = this.input.lastIndexOf("\n", startPos - 1) + 1; - this.curLine = this.input.slice(0, this.lineStart).split(lineBreak).length; - } else { - this.pos = this.lineStart = 0; - this.curLine = 1; - } - - // Properties of the current token: - // Its type - this.type = types$1.eof; - // For tokens that include more information than their type, the value - this.value = null; - // Its start and end offset - this.start = this.end = this.pos; - // And, if locations are used, the {line, column} object - // corresponding to those offsets - this.startLoc = this.endLoc = this.curPosition(); - - // Position information for the previous token - this.lastTokEndLoc = this.lastTokStartLoc = null; - this.lastTokStart = this.lastTokEnd = this.pos; - - // The context stack is used to superficially track syntactic - // context to predict whether a regular expression is allowed in a - // given position. - this.context = this.initialContext(); - this.exprAllowed = true; - - // Figure out if it's a module code. - this.inModule = options.sourceType === "module"; - this.strict = this.inModule || this.strictDirective(this.pos); - - // Used to signify the start of a potential arrow function - this.potentialArrowAt = -1; - this.potentialArrowInForAwait = false; - - // Positions to delayed-check that yield/await does not exist in default parameters. - this.yieldPos = this.awaitPos = this.awaitIdentPos = 0; - // Labels in scope. - this.labels = []; - // Thus-far undefined exports. - this.undefinedExports = Object.create(null); - - // If enabled, skip leading hashbang line. - if (this.pos === 0 && options.allowHashBang && this.input.slice(0, 2) === "#!") - { this.skipLineComment(2); } - - // Scope tracking for duplicate variable names (see scope.js) - this.scopeStack = []; - this.enterScope(SCOPE_TOP); - - // For RegExp validation - this.regexpState = null; - - // The stack of private names. - // Each element has two properties: 'declared' and 'used'. - // When it exited from the outermost class definition, all used private names must be declared. - this.privateNameStack = []; - }; - - var prototypeAccessors = { inFunction: { configurable: true },inGenerator: { configurable: true },inAsync: { configurable: true },canAwait: { configurable: true },allowSuper: { configurable: true },allowDirectSuper: { configurable: true },treatFunctionsAsVar: { configurable: true },allowNewDotTarget: { configurable: true },inClassStaticBlock: { configurable: true } }; - - Parser.prototype.parse = function parse () { - var node = this.options.program || this.startNode(); - this.nextToken(); - return this.parseTopLevel(node) - }; - - prototypeAccessors.inFunction.get = function () { return (this.currentVarScope().flags & SCOPE_FUNCTION) > 0 }; - - prototypeAccessors.inGenerator.get = function () { return (this.currentVarScope().flags & SCOPE_GENERATOR) > 0 && !this.currentVarScope().inClassFieldInit }; - - prototypeAccessors.inAsync.get = function () { return (this.currentVarScope().flags & SCOPE_ASYNC) > 0 && !this.currentVarScope().inClassFieldInit }; - - prototypeAccessors.canAwait.get = function () { - for (var i = this.scopeStack.length - 1; i >= 0; i--) { - var scope = this.scopeStack[i]; - if (scope.inClassFieldInit || scope.flags & SCOPE_CLASS_STATIC_BLOCK) { return false } - if (scope.flags & SCOPE_FUNCTION) { return (scope.flags & SCOPE_ASYNC) > 0 } - } - return (this.inModule && this.options.ecmaVersion >= 13) || this.options.allowAwaitOutsideFunction - }; - - prototypeAccessors.allowSuper.get = function () { - var ref = this.currentThisScope(); - var flags = ref.flags; - var inClassFieldInit = ref.inClassFieldInit; - return (flags & SCOPE_SUPER) > 0 || inClassFieldInit || this.options.allowSuperOutsideMethod - }; - - prototypeAccessors.allowDirectSuper.get = function () { return (this.currentThisScope().flags & SCOPE_DIRECT_SUPER) > 0 }; - - prototypeAccessors.treatFunctionsAsVar.get = function () { return this.treatFunctionsAsVarInScope(this.currentScope()) }; - - prototypeAccessors.allowNewDotTarget.get = function () { - var ref = this.currentThisScope(); - var flags = ref.flags; - var inClassFieldInit = ref.inClassFieldInit; - return (flags & (SCOPE_FUNCTION | SCOPE_CLASS_STATIC_BLOCK)) > 0 || inClassFieldInit - }; - - prototypeAccessors.inClassStaticBlock.get = function () { - return (this.currentVarScope().flags & SCOPE_CLASS_STATIC_BLOCK) > 0 - }; - - Parser.extend = function extend () { - var plugins = [], len = arguments.length; - while ( len-- ) plugins[ len ] = arguments[ len ]; - - var cls = this; - for (var i = 0; i < plugins.length; i++) { cls = plugins[i](cls); } - return cls - }; - - Parser.parse = function parse (input, options) { - return new this(options, input).parse() - }; - - Parser.parseExpressionAt = function parseExpressionAt (input, pos, options) { - var parser = new this(options, input, pos); - parser.nextToken(); - return parser.parseExpression() - }; - - Parser.tokenizer = function tokenizer (input, options) { - return new this(options, input) - }; - - Object.defineProperties( Parser.prototype, prototypeAccessors ); - - var pp$9 = Parser.prototype; - - // ## Parser utilities - - var literal = /^(?:'((?:\\[^]|[^'\\])*?)'|"((?:\\[^]|[^"\\])*?)")/; - pp$9.strictDirective = function(start) { - if (this.options.ecmaVersion < 5) { return false } - for (;;) { - // Try to find string literal. - skipWhiteSpace.lastIndex = start; - start += skipWhiteSpace.exec(this.input)[0].length; - var match = literal.exec(this.input.slice(start)); - if (!match) { return false } - if ((match[1] || match[2]) === "use strict") { - skipWhiteSpace.lastIndex = start + match[0].length; - var spaceAfter = skipWhiteSpace.exec(this.input), end = spaceAfter.index + spaceAfter[0].length; - var next = this.input.charAt(end); - return next === ";" || next === "}" || - (lineBreak.test(spaceAfter[0]) && - !(/[(`.[+\-/*%<>=,?^&]/.test(next) || next === "!" && this.input.charAt(end + 1) === "=")) - } - start += match[0].length; - - // Skip semicolon, if any. - skipWhiteSpace.lastIndex = start; - start += skipWhiteSpace.exec(this.input)[0].length; - if (this.input[start] === ";") - { start++; } - } - }; - - // Predicate that tests whether the next token is of the given - // type, and if yes, consumes it as a side effect. - - pp$9.eat = function(type) { - if (this.type === type) { - this.next(); - return true - } else { - return false - } - }; - - // Tests whether parsed token is a contextual keyword. - - pp$9.isContextual = function(name) { - return this.type === types$1.name && this.value === name && !this.containsEsc - }; - - // Consumes contextual keyword if possible. - - pp$9.eatContextual = function(name) { - if (!this.isContextual(name)) { return false } - this.next(); - return true - }; - - // Asserts that following token is given contextual keyword. - - pp$9.expectContextual = function(name) { - if (!this.eatContextual(name)) { this.unexpected(); } - }; - - // Test whether a semicolon can be inserted at the current position. - - pp$9.canInsertSemicolon = function() { - return this.type === types$1.eof || - this.type === types$1.braceR || - lineBreak.test(this.input.slice(this.lastTokEnd, this.start)) - }; - - pp$9.insertSemicolon = function() { - if (this.canInsertSemicolon()) { - if (this.options.onInsertedSemicolon) - { this.options.onInsertedSemicolon(this.lastTokEnd, this.lastTokEndLoc); } - return true - } - }; - - // Consume a semicolon, or, failing that, see if we are allowed to - // pretend that there is a semicolon at this position. - - pp$9.semicolon = function() { - if (!this.eat(types$1.semi) && !this.insertSemicolon()) { this.unexpected(); } - }; - - pp$9.afterTrailingComma = function(tokType, notNext) { - if (this.type === tokType) { - if (this.options.onTrailingComma) - { this.options.onTrailingComma(this.lastTokStart, this.lastTokStartLoc); } - if (!notNext) - { this.next(); } - return true - } - }; - - // Expect a token of a given type. If found, consume it, otherwise, - // raise an unexpected token error. - - pp$9.expect = function(type) { - this.eat(type) || this.unexpected(); - }; - - // Raise an unexpected token error. - - pp$9.unexpected = function(pos) { - this.raise(pos != null ? pos : this.start, "Unexpected token"); - }; - - var DestructuringErrors = function DestructuringErrors() { - this.shorthandAssign = - this.trailingComma = - this.parenthesizedAssign = - this.parenthesizedBind = - this.doubleProto = - -1; - }; - - pp$9.checkPatternErrors = function(refDestructuringErrors, isAssign) { - if (!refDestructuringErrors) { return } - if (refDestructuringErrors.trailingComma > -1) - { this.raiseRecoverable(refDestructuringErrors.trailingComma, "Comma is not permitted after the rest element"); } - var parens = isAssign ? refDestructuringErrors.parenthesizedAssign : refDestructuringErrors.parenthesizedBind; - if (parens > -1) { this.raiseRecoverable(parens, isAssign ? "Assigning to rvalue" : "Parenthesized pattern"); } - }; - - pp$9.checkExpressionErrors = function(refDestructuringErrors, andThrow) { - if (!refDestructuringErrors) { return false } - var shorthandAssign = refDestructuringErrors.shorthandAssign; - var doubleProto = refDestructuringErrors.doubleProto; - if (!andThrow) { return shorthandAssign >= 0 || doubleProto >= 0 } - if (shorthandAssign >= 0) - { this.raise(shorthandAssign, "Shorthand property assignments are valid only in destructuring patterns"); } - if (doubleProto >= 0) - { this.raiseRecoverable(doubleProto, "Redefinition of __proto__ property"); } - }; - - pp$9.checkYieldAwaitInDefaultParams = function() { - if (this.yieldPos && (!this.awaitPos || this.yieldPos < this.awaitPos)) - { this.raise(this.yieldPos, "Yield expression cannot be a default value"); } - if (this.awaitPos) - { this.raise(this.awaitPos, "Await expression cannot be a default value"); } - }; - - pp$9.isSimpleAssignTarget = function(expr) { - if (expr.type === "ParenthesizedExpression") - { return this.isSimpleAssignTarget(expr.expression) } - return expr.type === "Identifier" || expr.type === "MemberExpression" - }; - - var pp$8 = Parser.prototype; - - // ### Statement parsing - - // Parse a program. Initializes the parser, reads any number of - // statements, and wraps them in a Program node. Optionally takes a - // `program` argument. If present, the statements will be appended - // to its body instead of creating a new node. - - pp$8.parseTopLevel = function(node) { - var exports = Object.create(null); - if (!node.body) { node.body = []; } - while (this.type !== types$1.eof) { - var stmt = this.parseStatement(null, true, exports); - node.body.push(stmt); - } - if (this.inModule) - { for (var i = 0, list = Object.keys(this.undefinedExports); i < list.length; i += 1) - { - var name = list[i]; - - this.raiseRecoverable(this.undefinedExports[name].start, ("Export '" + name + "' is not defined")); - } } - this.adaptDirectivePrologue(node.body); - this.next(); - node.sourceType = this.options.sourceType; - return this.finishNode(node, "Program") - }; - - var loopLabel = {kind: "loop"}, switchLabel = {kind: "switch"}; - - pp$8.isLet = function(context) { - if (this.options.ecmaVersion < 6 || !this.isContextual("let")) { return false } - skipWhiteSpace.lastIndex = this.pos; - var skip = skipWhiteSpace.exec(this.input); - var next = this.pos + skip[0].length, nextCh = this.input.charCodeAt(next); - // For ambiguous cases, determine if a LexicalDeclaration (or only a - // Statement) is allowed here. If context is not empty then only a Statement - // is allowed. However, `let [` is an explicit negative lookahead for - // ExpressionStatement, so special-case it first. - if (nextCh === 91 || nextCh === 92) { return true } // '[', '\' - if (context) { return false } - - if (nextCh === 123 || nextCh > 0xd7ff && nextCh < 0xdc00) { return true } // '{', astral - if (isIdentifierStart(nextCh, true)) { - var pos = next + 1; - while (isIdentifierChar(nextCh = this.input.charCodeAt(pos), true)) { ++pos; } - if (nextCh === 92 || nextCh > 0xd7ff && nextCh < 0xdc00) { return true } - var ident = this.input.slice(next, pos); - if (!keywordRelationalOperator.test(ident)) { return true } - } - return false - }; - - // check 'async [no LineTerminator here] function' - // - 'async /*foo*/ function' is OK. - // - 'async /*\n*/ function' is invalid. - pp$8.isAsyncFunction = function() { - if (this.options.ecmaVersion < 8 || !this.isContextual("async")) - { return false } - - skipWhiteSpace.lastIndex = this.pos; - var skip = skipWhiteSpace.exec(this.input); - var next = this.pos + skip[0].length, after; - return !lineBreak.test(this.input.slice(this.pos, next)) && - this.input.slice(next, next + 8) === "function" && - (next + 8 === this.input.length || - !(isIdentifierChar(after = this.input.charCodeAt(next + 8)) || after > 0xd7ff && after < 0xdc00)) - }; - - // Parse a single statement. - // - // If expecting a statement and finding a slash operator, parse a - // regular expression literal. This is to handle cases like - // `if (foo) /blah/.exec(foo)`, where looking at the previous token - // does not help. - - pp$8.parseStatement = function(context, topLevel, exports) { - var starttype = this.type, node = this.startNode(), kind; - - if (this.isLet(context)) { - starttype = types$1._var; - kind = "let"; - } - - // Most types of statements are recognized by the keyword they - // start with. Many are trivial to parse, some require a bit of - // complexity. - - switch (starttype) { - case types$1._break: case types$1._continue: return this.parseBreakContinueStatement(node, starttype.keyword) - case types$1._debugger: return this.parseDebuggerStatement(node) - case types$1._do: return this.parseDoStatement(node) - case types$1._for: return this.parseForStatement(node) - case types$1._function: - // Function as sole body of either an if statement or a labeled statement - // works, but not when it is part of a labeled statement that is the sole - // body of an if statement. - if ((context && (this.strict || context !== "if" && context !== "label")) && this.options.ecmaVersion >= 6) { this.unexpected(); } - return this.parseFunctionStatement(node, false, !context) - case types$1._class: - if (context) { this.unexpected(); } - return this.parseClass(node, true) - case types$1._if: return this.parseIfStatement(node) - case types$1._return: return this.parseReturnStatement(node) - case types$1._switch: return this.parseSwitchStatement(node) - case types$1._throw: return this.parseThrowStatement(node) - case types$1._try: return this.parseTryStatement(node) - case types$1._const: case types$1._var: - kind = kind || this.value; - if (context && kind !== "var") { this.unexpected(); } - return this.parseVarStatement(node, kind) - case types$1._while: return this.parseWhileStatement(node) - case types$1._with: return this.parseWithStatement(node) - case types$1.braceL: return this.parseBlock(true, node) - case types$1.semi: return this.parseEmptyStatement(node) - case types$1._export: - case types$1._import: - if (this.options.ecmaVersion > 10 && starttype === types$1._import) { - skipWhiteSpace.lastIndex = this.pos; - var skip = skipWhiteSpace.exec(this.input); - var next = this.pos + skip[0].length, nextCh = this.input.charCodeAt(next); - if (nextCh === 40 || nextCh === 46) // '(' or '.' - { return this.parseExpressionStatement(node, this.parseExpression()) } - } - - if (!this.options.allowImportExportEverywhere) { - if (!topLevel) - { this.raise(this.start, "'import' and 'export' may only appear at the top level"); } - if (!this.inModule) - { this.raise(this.start, "'import' and 'export' may appear only with 'sourceType: module'"); } - } - return starttype === types$1._import ? this.parseImport(node) : this.parseExport(node, exports) - - // If the statement does not start with a statement keyword or a - // brace, it's an ExpressionStatement or LabeledStatement. We - // simply start parsing an expression, and afterwards, if the - // next token is a colon and the expression was a simple - // Identifier node, we switch to interpreting it as a label. - default: - if (this.isAsyncFunction()) { - if (context) { this.unexpected(); } - this.next(); - return this.parseFunctionStatement(node, true, !context) - } - - var maybeName = this.value, expr = this.parseExpression(); - if (starttype === types$1.name && expr.type === "Identifier" && this.eat(types$1.colon)) - { return this.parseLabeledStatement(node, maybeName, expr, context) } - else { return this.parseExpressionStatement(node, expr) } - } - }; - - pp$8.parseBreakContinueStatement = function(node, keyword) { - var isBreak = keyword === "break"; - this.next(); - if (this.eat(types$1.semi) || this.insertSemicolon()) { node.label = null; } - else if (this.type !== types$1.name) { this.unexpected(); } - else { - node.label = this.parseIdent(); - this.semicolon(); - } - - // Verify that there is an actual destination to break or - // continue to. - var i = 0; - for (; i < this.labels.length; ++i) { - var lab = this.labels[i]; - if (node.label == null || lab.name === node.label.name) { - if (lab.kind != null && (isBreak || lab.kind === "loop")) { break } - if (node.label && isBreak) { break } - } - } - if (i === this.labels.length) { this.raise(node.start, "Unsyntactic " + keyword); } - return this.finishNode(node, isBreak ? "BreakStatement" : "ContinueStatement") - }; - - pp$8.parseDebuggerStatement = function(node) { - this.next(); - this.semicolon(); - return this.finishNode(node, "DebuggerStatement") - }; - - pp$8.parseDoStatement = function(node) { - this.next(); - this.labels.push(loopLabel); - node.body = this.parseStatement("do"); - this.labels.pop(); - this.expect(types$1._while); - node.test = this.parseParenExpression(); - if (this.options.ecmaVersion >= 6) - { this.eat(types$1.semi); } - else - { this.semicolon(); } - return this.finishNode(node, "DoWhileStatement") - }; - - // Disambiguating between a `for` and a `for`/`in` or `for`/`of` - // loop is non-trivial. Basically, we have to parse the init `var` - // statement or expression, disallowing the `in` operator (see - // the second parameter to `parseExpression`), and then check - // whether the next token is `in` or `of`. When there is no init - // part (semicolon immediately after the opening parenthesis), it - // is a regular `for` loop. - - pp$8.parseForStatement = function(node) { - this.next(); - var awaitAt = (this.options.ecmaVersion >= 9 && this.canAwait && this.eatContextual("await")) ? this.lastTokStart : -1; - this.labels.push(loopLabel); - this.enterScope(0); - this.expect(types$1.parenL); - if (this.type === types$1.semi) { - if (awaitAt > -1) { this.unexpected(awaitAt); } - return this.parseFor(node, null) - } - var isLet = this.isLet(); - if (this.type === types$1._var || this.type === types$1._const || isLet) { - var init$1 = this.startNode(), kind = isLet ? "let" : this.value; - this.next(); - this.parseVar(init$1, true, kind); - this.finishNode(init$1, "VariableDeclaration"); - if ((this.type === types$1._in || (this.options.ecmaVersion >= 6 && this.isContextual("of"))) && init$1.declarations.length === 1) { - if (this.options.ecmaVersion >= 9) { - if (this.type === types$1._in) { - if (awaitAt > -1) { this.unexpected(awaitAt); } - } else { node.await = awaitAt > -1; } - } - return this.parseForIn(node, init$1) - } - if (awaitAt > -1) { this.unexpected(awaitAt); } - return this.parseFor(node, init$1) - } - var startsWithLet = this.isContextual("let"), isForOf = false; - var containsEsc = this.containsEsc; - var refDestructuringErrors = new DestructuringErrors; - var initPos = this.start; - var init = awaitAt > -1 - ? this.parseExprSubscripts(refDestructuringErrors, "await") - : this.parseExpression(true, refDestructuringErrors); - if (this.type === types$1._in || (isForOf = this.options.ecmaVersion >= 6 && this.isContextual("of"))) { - if (awaitAt > -1) { // implies `ecmaVersion >= 9` (see declaration of awaitAt) - if (this.type === types$1._in) { this.unexpected(awaitAt); } - node.await = true; - } else if (isForOf && this.options.ecmaVersion >= 8) { - if (init.start === initPos && !containsEsc && init.type === "Identifier" && init.name === "async") { this.unexpected(); } - else if (this.options.ecmaVersion >= 9) { node.await = false; } - } - if (startsWithLet && isForOf) { this.raise(init.start, "The left-hand side of a for-of loop may not start with 'let'."); } - this.toAssignable(init, false, refDestructuringErrors); - this.checkLValPattern(init); - return this.parseForIn(node, init) - } else { - this.checkExpressionErrors(refDestructuringErrors, true); - } - if (awaitAt > -1) { this.unexpected(awaitAt); } - return this.parseFor(node, init) - }; - - pp$8.parseFunctionStatement = function(node, isAsync, declarationPosition) { - this.next(); - return this.parseFunction(node, FUNC_STATEMENT | (declarationPosition ? 0 : FUNC_HANGING_STATEMENT), false, isAsync) - }; - - pp$8.parseIfStatement = function(node) { - this.next(); - node.test = this.parseParenExpression(); - // allow function declarations in branches, but only in non-strict mode - node.consequent = this.parseStatement("if"); - node.alternate = this.eat(types$1._else) ? this.parseStatement("if") : null; - return this.finishNode(node, "IfStatement") - }; - - pp$8.parseReturnStatement = function(node) { - if (!this.inFunction && !this.options.allowReturnOutsideFunction) - { this.raise(this.start, "'return' outside of function"); } - this.next(); - - // In `return` (and `break`/`continue`), the keywords with - // optional arguments, we eagerly look for a semicolon or the - // possibility to insert one. - - if (this.eat(types$1.semi) || this.insertSemicolon()) { node.argument = null; } - else { node.argument = this.parseExpression(); this.semicolon(); } - return this.finishNode(node, "ReturnStatement") - }; - - pp$8.parseSwitchStatement = function(node) { - this.next(); - node.discriminant = this.parseParenExpression(); - node.cases = []; - this.expect(types$1.braceL); - this.labels.push(switchLabel); - this.enterScope(0); - - // Statements under must be grouped (by label) in SwitchCase - // nodes. `cur` is used to keep the node that we are currently - // adding statements to. - - var cur; - for (var sawDefault = false; this.type !== types$1.braceR;) { - if (this.type === types$1._case || this.type === types$1._default) { - var isCase = this.type === types$1._case; - if (cur) { this.finishNode(cur, "SwitchCase"); } - node.cases.push(cur = this.startNode()); - cur.consequent = []; - this.next(); - if (isCase) { - cur.test = this.parseExpression(); - } else { - if (sawDefault) { this.raiseRecoverable(this.lastTokStart, "Multiple default clauses"); } - sawDefault = true; - cur.test = null; - } - this.expect(types$1.colon); - } else { - if (!cur) { this.unexpected(); } - cur.consequent.push(this.parseStatement(null)); - } - } - this.exitScope(); - if (cur) { this.finishNode(cur, "SwitchCase"); } - this.next(); // Closing brace - this.labels.pop(); - return this.finishNode(node, "SwitchStatement") - }; - - pp$8.parseThrowStatement = function(node) { - this.next(); - if (lineBreak.test(this.input.slice(this.lastTokEnd, this.start))) - { this.raise(this.lastTokEnd, "Illegal newline after throw"); } - node.argument = this.parseExpression(); - this.semicolon(); - return this.finishNode(node, "ThrowStatement") - }; - - // Reused empty array added for node fields that are always empty. - - var empty$1 = []; - - pp$8.parseCatchClauseParam = function() { - var param = this.parseBindingAtom(); - var simple = param.type === "Identifier"; - this.enterScope(simple ? SCOPE_SIMPLE_CATCH : 0); - this.checkLValPattern(param, simple ? BIND_SIMPLE_CATCH : BIND_LEXICAL); - this.expect(types$1.parenR); - - return param - }; - - pp$8.parseTryStatement = function(node) { - this.next(); - node.block = this.parseBlock(); - node.handler = null; - if (this.type === types$1._catch) { - var clause = this.startNode(); - this.next(); - if (this.eat(types$1.parenL)) { - clause.param = this.parseCatchClauseParam(); - } else { - if (this.options.ecmaVersion < 10) { this.unexpected(); } - clause.param = null; - this.enterScope(0); - } - clause.body = this.parseBlock(false); - this.exitScope(); - node.handler = this.finishNode(clause, "CatchClause"); - } - node.finalizer = this.eat(types$1._finally) ? this.parseBlock() : null; - if (!node.handler && !node.finalizer) - { this.raise(node.start, "Missing catch or finally clause"); } - return this.finishNode(node, "TryStatement") - }; - - pp$8.parseVarStatement = function(node, kind, allowMissingInitializer) { - this.next(); - this.parseVar(node, false, kind, allowMissingInitializer); - this.semicolon(); - return this.finishNode(node, "VariableDeclaration") - }; - - pp$8.parseWhileStatement = function(node) { - this.next(); - node.test = this.parseParenExpression(); - this.labels.push(loopLabel); - node.body = this.parseStatement("while"); - this.labels.pop(); - return this.finishNode(node, "WhileStatement") - }; - - pp$8.parseWithStatement = function(node) { - if (this.strict) { this.raise(this.start, "'with' in strict mode"); } - this.next(); - node.object = this.parseParenExpression(); - node.body = this.parseStatement("with"); - return this.finishNode(node, "WithStatement") - }; - - pp$8.parseEmptyStatement = function(node) { - this.next(); - return this.finishNode(node, "EmptyStatement") - }; - - pp$8.parseLabeledStatement = function(node, maybeName, expr, context) { - for (var i$1 = 0, list = this.labels; i$1 < list.length; i$1 += 1) - { - var label = list[i$1]; - - if (label.name === maybeName) - { this.raise(expr.start, "Label '" + maybeName + "' is already declared"); - } } - var kind = this.type.isLoop ? "loop" : this.type === types$1._switch ? "switch" : null; - for (var i = this.labels.length - 1; i >= 0; i--) { - var label$1 = this.labels[i]; - if (label$1.statementStart === node.start) { - // Update information about previous labels on this node - label$1.statementStart = this.start; - label$1.kind = kind; - } else { break } - } - this.labels.push({name: maybeName, kind: kind, statementStart: this.start}); - node.body = this.parseStatement(context ? context.indexOf("label") === -1 ? context + "label" : context : "label"); - this.labels.pop(); - node.label = expr; - return this.finishNode(node, "LabeledStatement") - }; - - pp$8.parseExpressionStatement = function(node, expr) { - node.expression = expr; - this.semicolon(); - return this.finishNode(node, "ExpressionStatement") - }; - - // Parse a semicolon-enclosed block of statements, handling `"use - // strict"` declarations when `allowStrict` is true (used for - // function bodies). - - pp$8.parseBlock = function(createNewLexicalScope, node, exitStrict) { - if ( createNewLexicalScope === void 0 ) createNewLexicalScope = true; - if ( node === void 0 ) node = this.startNode(); - - node.body = []; - this.expect(types$1.braceL); - if (createNewLexicalScope) { this.enterScope(0); } - while (this.type !== types$1.braceR) { - var stmt = this.parseStatement(null); - node.body.push(stmt); - } - if (exitStrict) { this.strict = false; } - this.next(); - if (createNewLexicalScope) { this.exitScope(); } - return this.finishNode(node, "BlockStatement") - }; - - // Parse a regular `for` loop. The disambiguation code in - // `parseStatement` will already have parsed the init statement or - // expression. - - pp$8.parseFor = function(node, init) { - node.init = init; - this.expect(types$1.semi); - node.test = this.type === types$1.semi ? null : this.parseExpression(); - this.expect(types$1.semi); - node.update = this.type === types$1.parenR ? null : this.parseExpression(); - this.expect(types$1.parenR); - node.body = this.parseStatement("for"); - this.exitScope(); - this.labels.pop(); - return this.finishNode(node, "ForStatement") - }; - - // Parse a `for`/`in` and `for`/`of` loop, which are almost - // same from parser's perspective. - - pp$8.parseForIn = function(node, init) { - var isForIn = this.type === types$1._in; - this.next(); - - if ( - init.type === "VariableDeclaration" && - init.declarations[0].init != null && - ( - !isForIn || - this.options.ecmaVersion < 8 || - this.strict || - init.kind !== "var" || - init.declarations[0].id.type !== "Identifier" - ) - ) { - this.raise( - init.start, - ((isForIn ? "for-in" : "for-of") + " loop variable declaration may not have an initializer") - ); - } - node.left = init; - node.right = isForIn ? this.parseExpression() : this.parseMaybeAssign(); - this.expect(types$1.parenR); - node.body = this.parseStatement("for"); - this.exitScope(); - this.labels.pop(); - return this.finishNode(node, isForIn ? "ForInStatement" : "ForOfStatement") - }; - - // Parse a list of variable declarations. - - pp$8.parseVar = function(node, isFor, kind, allowMissingInitializer) { - node.declarations = []; - node.kind = kind; - for (;;) { - var decl = this.startNode(); - this.parseVarId(decl, kind); - if (this.eat(types$1.eq)) { - decl.init = this.parseMaybeAssign(isFor); - } else if (!allowMissingInitializer && kind === "const" && !(this.type === types$1._in || (this.options.ecmaVersion >= 6 && this.isContextual("of")))) { - this.unexpected(); - } else if (!allowMissingInitializer && decl.id.type !== "Identifier" && !(isFor && (this.type === types$1._in || this.isContextual("of")))) { - this.raise(this.lastTokEnd, "Complex binding patterns require an initialization value"); - } else { - decl.init = null; - } - node.declarations.push(this.finishNode(decl, "VariableDeclarator")); - if (!this.eat(types$1.comma)) { break } - } - return node - }; - - pp$8.parseVarId = function(decl, kind) { - decl.id = this.parseBindingAtom(); - this.checkLValPattern(decl.id, kind === "var" ? BIND_VAR : BIND_LEXICAL, false); - }; - - var FUNC_STATEMENT = 1, FUNC_HANGING_STATEMENT = 2, FUNC_NULLABLE_ID = 4; - - // Parse a function declaration or literal (depending on the - // `statement & FUNC_STATEMENT`). - - // Remove `allowExpressionBody` for 7.0.0, as it is only called with false - pp$8.parseFunction = function(node, statement, allowExpressionBody, isAsync, forInit) { - this.initFunction(node); - if (this.options.ecmaVersion >= 9 || this.options.ecmaVersion >= 6 && !isAsync) { - if (this.type === types$1.star && (statement & FUNC_HANGING_STATEMENT)) - { this.unexpected(); } - node.generator = this.eat(types$1.star); - } - if (this.options.ecmaVersion >= 8) - { node.async = !!isAsync; } - - if (statement & FUNC_STATEMENT) { - node.id = (statement & FUNC_NULLABLE_ID) && this.type !== types$1.name ? null : this.parseIdent(); - if (node.id && !(statement & FUNC_HANGING_STATEMENT)) - // If it is a regular function declaration in sloppy mode, then it is - // subject to Annex B semantics (BIND_FUNCTION). Otherwise, the binding - // mode depends on properties of the current scope (see - // treatFunctionsAsVar). - { this.checkLValSimple(node.id, (this.strict || node.generator || node.async) ? this.treatFunctionsAsVar ? BIND_VAR : BIND_LEXICAL : BIND_FUNCTION); } - } - - var oldYieldPos = this.yieldPos, oldAwaitPos = this.awaitPos, oldAwaitIdentPos = this.awaitIdentPos; - this.yieldPos = 0; - this.awaitPos = 0; - this.awaitIdentPos = 0; - this.enterScope(functionFlags(node.async, node.generator)); - - if (!(statement & FUNC_STATEMENT)) - { node.id = this.type === types$1.name ? this.parseIdent() : null; } - - this.parseFunctionParams(node); - this.parseFunctionBody(node, allowExpressionBody, false, forInit); - - this.yieldPos = oldYieldPos; - this.awaitPos = oldAwaitPos; - this.awaitIdentPos = oldAwaitIdentPos; - return this.finishNode(node, (statement & FUNC_STATEMENT) ? "FunctionDeclaration" : "FunctionExpression") - }; - - pp$8.parseFunctionParams = function(node) { - this.expect(types$1.parenL); - node.params = this.parseBindingList(types$1.parenR, false, this.options.ecmaVersion >= 8); - this.checkYieldAwaitInDefaultParams(); - }; - - // Parse a class declaration or literal (depending on the - // `isStatement` parameter). - - pp$8.parseClass = function(node, isStatement) { - this.next(); - - // ecma-262 14.6 Class Definitions - // A class definition is always strict mode code. - var oldStrict = this.strict; - this.strict = true; - - this.parseClassId(node, isStatement); - this.parseClassSuper(node); - var privateNameMap = this.enterClassBody(); - var classBody = this.startNode(); - var hadConstructor = false; - classBody.body = []; - this.expect(types$1.braceL); - while (this.type !== types$1.braceR) { - var element = this.parseClassElement(node.superClass !== null); - if (element) { - classBody.body.push(element); - if (element.type === "MethodDefinition" && element.kind === "constructor") { - if (hadConstructor) { this.raiseRecoverable(element.start, "Duplicate constructor in the same class"); } - hadConstructor = true; - } else if (element.key && element.key.type === "PrivateIdentifier" && isPrivateNameConflicted(privateNameMap, element)) { - this.raiseRecoverable(element.key.start, ("Identifier '#" + (element.key.name) + "' has already been declared")); - } - } - } - this.strict = oldStrict; - this.next(); - node.body = this.finishNode(classBody, "ClassBody"); - this.exitClassBody(); - return this.finishNode(node, isStatement ? "ClassDeclaration" : "ClassExpression") - }; - - pp$8.parseClassElement = function(constructorAllowsSuper) { - if (this.eat(types$1.semi)) { return null } - - var ecmaVersion = this.options.ecmaVersion; - var node = this.startNode(); - var keyName = ""; - var isGenerator = false; - var isAsync = false; - var kind = "method"; - var isStatic = false; - - if (this.eatContextual("static")) { - // Parse static init block - if (ecmaVersion >= 13 && this.eat(types$1.braceL)) { - this.parseClassStaticBlock(node); - return node - } - if (this.isClassElementNameStart() || this.type === types$1.star) { - isStatic = true; - } else { - keyName = "static"; - } - } - node.static = isStatic; - if (!keyName && ecmaVersion >= 8 && this.eatContextual("async")) { - if ((this.isClassElementNameStart() || this.type === types$1.star) && !this.canInsertSemicolon()) { - isAsync = true; - } else { - keyName = "async"; - } - } - if (!keyName && (ecmaVersion >= 9 || !isAsync) && this.eat(types$1.star)) { - isGenerator = true; - } - if (!keyName && !isAsync && !isGenerator) { - var lastValue = this.value; - if (this.eatContextual("get") || this.eatContextual("set")) { - if (this.isClassElementNameStart()) { - kind = lastValue; - } else { - keyName = lastValue; - } - } - } - - // Parse element name - if (keyName) { - // 'async', 'get', 'set', or 'static' were not a keyword contextually. - // The last token is any of those. Make it the element name. - node.computed = false; - node.key = this.startNodeAt(this.lastTokStart, this.lastTokStartLoc); - node.key.name = keyName; - this.finishNode(node.key, "Identifier"); - } else { - this.parseClassElementName(node); - } - - // Parse element value - if (ecmaVersion < 13 || this.type === types$1.parenL || kind !== "method" || isGenerator || isAsync) { - var isConstructor = !node.static && checkKeyName(node, "constructor"); - var allowsDirectSuper = isConstructor && constructorAllowsSuper; - // Couldn't move this check into the 'parseClassMethod' method for backward compatibility. - if (isConstructor && kind !== "method") { this.raise(node.key.start, "Constructor can't have get/set modifier"); } - node.kind = isConstructor ? "constructor" : kind; - this.parseClassMethod(node, isGenerator, isAsync, allowsDirectSuper); - } else { - this.parseClassField(node); - } - - return node - }; - - pp$8.isClassElementNameStart = function() { - return ( - this.type === types$1.name || - this.type === types$1.privateId || - this.type === types$1.num || - this.type === types$1.string || - this.type === types$1.bracketL || - this.type.keyword - ) - }; - - pp$8.parseClassElementName = function(element) { - if (this.type === types$1.privateId) { - if (this.value === "constructor") { - this.raise(this.start, "Classes can't have an element named '#constructor'"); - } - element.computed = false; - element.key = this.parsePrivateIdent(); - } else { - this.parsePropertyName(element); - } - }; - - pp$8.parseClassMethod = function(method, isGenerator, isAsync, allowsDirectSuper) { - // Check key and flags - var key = method.key; - if (method.kind === "constructor") { - if (isGenerator) { this.raise(key.start, "Constructor can't be a generator"); } - if (isAsync) { this.raise(key.start, "Constructor can't be an async method"); } - } else if (method.static && checkKeyName(method, "prototype")) { - this.raise(key.start, "Classes may not have a static property named prototype"); - } - - // Parse value - var value = method.value = this.parseMethod(isGenerator, isAsync, allowsDirectSuper); - - // Check value - if (method.kind === "get" && value.params.length !== 0) - { this.raiseRecoverable(value.start, "getter should have no params"); } - if (method.kind === "set" && value.params.length !== 1) - { this.raiseRecoverable(value.start, "setter should have exactly one param"); } - if (method.kind === "set" && value.params[0].type === "RestElement") - { this.raiseRecoverable(value.params[0].start, "Setter cannot use rest params"); } - - return this.finishNode(method, "MethodDefinition") - }; - - pp$8.parseClassField = function(field) { - if (checkKeyName(field, "constructor")) { - this.raise(field.key.start, "Classes can't have a field named 'constructor'"); - } else if (field.static && checkKeyName(field, "prototype")) { - this.raise(field.key.start, "Classes can't have a static field named 'prototype'"); - } - - if (this.eat(types$1.eq)) { - // To raise SyntaxError if 'arguments' exists in the initializer. - var scope = this.currentThisScope(); - var inClassFieldInit = scope.inClassFieldInit; - scope.inClassFieldInit = true; - field.value = this.parseMaybeAssign(); - scope.inClassFieldInit = inClassFieldInit; - } else { - field.value = null; - } - this.semicolon(); - - return this.finishNode(field, "PropertyDefinition") - }; - - pp$8.parseClassStaticBlock = function(node) { - node.body = []; - - var oldLabels = this.labels; - this.labels = []; - this.enterScope(SCOPE_CLASS_STATIC_BLOCK | SCOPE_SUPER); - while (this.type !== types$1.braceR) { - var stmt = this.parseStatement(null); - node.body.push(stmt); - } - this.next(); - this.exitScope(); - this.labels = oldLabels; - - return this.finishNode(node, "StaticBlock") - }; - - pp$8.parseClassId = function(node, isStatement) { - if (this.type === types$1.name) { - node.id = this.parseIdent(); - if (isStatement) - { this.checkLValSimple(node.id, BIND_LEXICAL, false); } - } else { - if (isStatement === true) - { this.unexpected(); } - node.id = null; - } - }; - - pp$8.parseClassSuper = function(node) { - node.superClass = this.eat(types$1._extends) ? this.parseExprSubscripts(null, false) : null; - }; - - pp$8.enterClassBody = function() { - var element = {declared: Object.create(null), used: []}; - this.privateNameStack.push(element); - return element.declared - }; - - pp$8.exitClassBody = function() { - var ref = this.privateNameStack.pop(); - var declared = ref.declared; - var used = ref.used; - if (!this.options.checkPrivateFields) { return } - var len = this.privateNameStack.length; - var parent = len === 0 ? null : this.privateNameStack[len - 1]; - for (var i = 0; i < used.length; ++i) { - var id = used[i]; - if (!hasOwn(declared, id.name)) { - if (parent) { - parent.used.push(id); - } else { - this.raiseRecoverable(id.start, ("Private field '#" + (id.name) + "' must be declared in an enclosing class")); - } - } - } - }; - - function isPrivateNameConflicted(privateNameMap, element) { - var name = element.key.name; - var curr = privateNameMap[name]; - - var next = "true"; - if (element.type === "MethodDefinition" && (element.kind === "get" || element.kind === "set")) { - next = (element.static ? "s" : "i") + element.kind; - } - - // `class { get #a(){}; static set #a(_){} }` is also conflict. - if ( - curr === "iget" && next === "iset" || - curr === "iset" && next === "iget" || - curr === "sget" && next === "sset" || - curr === "sset" && next === "sget" - ) { - privateNameMap[name] = "true"; - return false - } else if (!curr) { - privateNameMap[name] = next; - return false - } else { - return true - } - } - - function checkKeyName(node, name) { - var computed = node.computed; - var key = node.key; - return !computed && ( - key.type === "Identifier" && key.name === name || - key.type === "Literal" && key.value === name - ) - } - - // Parses module export declaration. - - pp$8.parseExportAllDeclaration = function(node, exports) { - if (this.options.ecmaVersion >= 11) { - if (this.eatContextual("as")) { - node.exported = this.parseModuleExportName(); - this.checkExport(exports, node.exported, this.lastTokStart); - } else { - node.exported = null; - } - } - this.expectContextual("from"); - if (this.type !== types$1.string) { this.unexpected(); } - node.source = this.parseExprAtom(); - this.semicolon(); - return this.finishNode(node, "ExportAllDeclaration") - }; - - pp$8.parseExport = function(node, exports) { - this.next(); - // export * from '...' - if (this.eat(types$1.star)) { - return this.parseExportAllDeclaration(node, exports) - } - if (this.eat(types$1._default)) { // export default ... - this.checkExport(exports, "default", this.lastTokStart); - node.declaration = this.parseExportDefaultDeclaration(); - return this.finishNode(node, "ExportDefaultDeclaration") - } - // export var|const|let|function|class ... - if (this.shouldParseExportStatement()) { - node.declaration = this.parseExportDeclaration(node); - if (node.declaration.type === "VariableDeclaration") - { this.checkVariableExport(exports, node.declaration.declarations); } - else - { this.checkExport(exports, node.declaration.id, node.declaration.id.start); } - node.specifiers = []; - node.source = null; - } else { // export { x, y as z } [from '...'] - node.declaration = null; - node.specifiers = this.parseExportSpecifiers(exports); - if (this.eatContextual("from")) { - if (this.type !== types$1.string) { this.unexpected(); } - node.source = this.parseExprAtom(); - } else { - for (var i = 0, list = node.specifiers; i < list.length; i += 1) { - // check for keywords used as local names - var spec = list[i]; - - this.checkUnreserved(spec.local); - // check if export is defined - this.checkLocalExport(spec.local); - - if (spec.local.type === "Literal") { - this.raise(spec.local.start, "A string literal cannot be used as an exported binding without `from`."); - } - } - - node.source = null; - } - this.semicolon(); - } - return this.finishNode(node, "ExportNamedDeclaration") - }; - - pp$8.parseExportDeclaration = function(node) { - return this.parseStatement(null) - }; - - pp$8.parseExportDefaultDeclaration = function() { - var isAsync; - if (this.type === types$1._function || (isAsync = this.isAsyncFunction())) { - var fNode = this.startNode(); - this.next(); - if (isAsync) { this.next(); } - return this.parseFunction(fNode, FUNC_STATEMENT | FUNC_NULLABLE_ID, false, isAsync) - } else if (this.type === types$1._class) { - var cNode = this.startNode(); - return this.parseClass(cNode, "nullableID") - } else { - var declaration = this.parseMaybeAssign(); - this.semicolon(); - return declaration - } - }; - - pp$8.checkExport = function(exports, name, pos) { - if (!exports) { return } - if (typeof name !== "string") - { name = name.type === "Identifier" ? name.name : name.value; } - if (hasOwn(exports, name)) - { this.raiseRecoverable(pos, "Duplicate export '" + name + "'"); } - exports[name] = true; - }; - - pp$8.checkPatternExport = function(exports, pat) { - var type = pat.type; - if (type === "Identifier") - { this.checkExport(exports, pat, pat.start); } - else if (type === "ObjectPattern") - { for (var i = 0, list = pat.properties; i < list.length; i += 1) - { - var prop = list[i]; - - this.checkPatternExport(exports, prop); - } } - else if (type === "ArrayPattern") - { for (var i$1 = 0, list$1 = pat.elements; i$1 < list$1.length; i$1 += 1) { - var elt = list$1[i$1]; - - if (elt) { this.checkPatternExport(exports, elt); } - } } - else if (type === "Property") - { this.checkPatternExport(exports, pat.value); } - else if (type === "AssignmentPattern") - { this.checkPatternExport(exports, pat.left); } - else if (type === "RestElement") - { this.checkPatternExport(exports, pat.argument); } - }; - - pp$8.checkVariableExport = function(exports, decls) { - if (!exports) { return } - for (var i = 0, list = decls; i < list.length; i += 1) - { - var decl = list[i]; - - this.checkPatternExport(exports, decl.id); - } - }; - - pp$8.shouldParseExportStatement = function() { - return this.type.keyword === "var" || - this.type.keyword === "const" || - this.type.keyword === "class" || - this.type.keyword === "function" || - this.isLet() || - this.isAsyncFunction() - }; - - // Parses a comma-separated list of module exports. - - pp$8.parseExportSpecifier = function(exports) { - var node = this.startNode(); - node.local = this.parseModuleExportName(); - - node.exported = this.eatContextual("as") ? this.parseModuleExportName() : node.local; - this.checkExport( - exports, - node.exported, - node.exported.start - ); - - return this.finishNode(node, "ExportSpecifier") - }; - - pp$8.parseExportSpecifiers = function(exports) { - var nodes = [], first = true; - // export { x, y as z } [from '...'] - this.expect(types$1.braceL); - while (!this.eat(types$1.braceR)) { - if (!first) { - this.expect(types$1.comma); - if (this.afterTrailingComma(types$1.braceR)) { break } - } else { first = false; } - - nodes.push(this.parseExportSpecifier(exports)); - } - return nodes - }; - - // Parses import declaration. - - pp$8.parseImport = function(node) { - this.next(); - - // import '...' - if (this.type === types$1.string) { - node.specifiers = empty$1; - node.source = this.parseExprAtom(); - } else { - node.specifiers = this.parseImportSpecifiers(); - this.expectContextual("from"); - node.source = this.type === types$1.string ? this.parseExprAtom() : this.unexpected(); - } - this.semicolon(); - return this.finishNode(node, "ImportDeclaration") - }; - - // Parses a comma-separated list of module imports. - - pp$8.parseImportSpecifier = function() { - var node = this.startNode(); - node.imported = this.parseModuleExportName(); - - if (this.eatContextual("as")) { - node.local = this.parseIdent(); - } else { - this.checkUnreserved(node.imported); - node.local = node.imported; - } - this.checkLValSimple(node.local, BIND_LEXICAL); - - return this.finishNode(node, "ImportSpecifier") - }; - - pp$8.parseImportDefaultSpecifier = function() { - // import defaultObj, { x, y as z } from '...' - var node = this.startNode(); - node.local = this.parseIdent(); - this.checkLValSimple(node.local, BIND_LEXICAL); - return this.finishNode(node, "ImportDefaultSpecifier") - }; - - pp$8.parseImportNamespaceSpecifier = function() { - var node = this.startNode(); - this.next(); - this.expectContextual("as"); - node.local = this.parseIdent(); - this.checkLValSimple(node.local, BIND_LEXICAL); - return this.finishNode(node, "ImportNamespaceSpecifier") - }; - - pp$8.parseImportSpecifiers = function() { - var nodes = [], first = true; - if (this.type === types$1.name) { - nodes.push(this.parseImportDefaultSpecifier()); - if (!this.eat(types$1.comma)) { return nodes } - } - if (this.type === types$1.star) { - nodes.push(this.parseImportNamespaceSpecifier()); - return nodes - } - this.expect(types$1.braceL); - while (!this.eat(types$1.braceR)) { - if (!first) { - this.expect(types$1.comma); - if (this.afterTrailingComma(types$1.braceR)) { break } - } else { first = false; } - - nodes.push(this.parseImportSpecifier()); - } - return nodes - }; - - pp$8.parseModuleExportName = function() { - if (this.options.ecmaVersion >= 13 && this.type === types$1.string) { - var stringLiteral = this.parseLiteral(this.value); - if (loneSurrogate.test(stringLiteral.value)) { - this.raise(stringLiteral.start, "An export name cannot include a lone surrogate."); - } - return stringLiteral - } - return this.parseIdent(true) - }; - - // Set `ExpressionStatement#directive` property for directive prologues. - pp$8.adaptDirectivePrologue = function(statements) { - for (var i = 0; i < statements.length && this.isDirectiveCandidate(statements[i]); ++i) { - statements[i].directive = statements[i].expression.raw.slice(1, -1); - } - }; - pp$8.isDirectiveCandidate = function(statement) { - return ( - this.options.ecmaVersion >= 5 && - statement.type === "ExpressionStatement" && - statement.expression.type === "Literal" && - typeof statement.expression.value === "string" && - // Reject parenthesized strings. - (this.input[statement.start] === "\"" || this.input[statement.start] === "'") - ) - }; - - var pp$7 = Parser.prototype; - - // Convert existing expression atom to assignable pattern - // if possible. - - pp$7.toAssignable = function(node, isBinding, refDestructuringErrors) { - if (this.options.ecmaVersion >= 6 && node) { - switch (node.type) { - case "Identifier": - if (this.inAsync && node.name === "await") - { this.raise(node.start, "Cannot use 'await' as identifier inside an async function"); } - break - - case "ObjectPattern": - case "ArrayPattern": - case "AssignmentPattern": - case "RestElement": - break - - case "ObjectExpression": - node.type = "ObjectPattern"; - if (refDestructuringErrors) { this.checkPatternErrors(refDestructuringErrors, true); } - for (var i = 0, list = node.properties; i < list.length; i += 1) { - var prop = list[i]; - - this.toAssignable(prop, isBinding); - // Early error: - // AssignmentRestProperty[Yield, Await] : - // `...` DestructuringAssignmentTarget[Yield, Await] - // - // It is a Syntax Error if |DestructuringAssignmentTarget| is an |ArrayLiteral| or an |ObjectLiteral|. - if ( - prop.type === "RestElement" && - (prop.argument.type === "ArrayPattern" || prop.argument.type === "ObjectPattern") - ) { - this.raise(prop.argument.start, "Unexpected token"); - } - } - break - - case "Property": - // AssignmentProperty has type === "Property" - if (node.kind !== "init") { this.raise(node.key.start, "Object pattern can't contain getter or setter"); } - this.toAssignable(node.value, isBinding); - break - - case "ArrayExpression": - node.type = "ArrayPattern"; - if (refDestructuringErrors) { this.checkPatternErrors(refDestructuringErrors, true); } - this.toAssignableList(node.elements, isBinding); - break - - case "SpreadElement": - node.type = "RestElement"; - this.toAssignable(node.argument, isBinding); - if (node.argument.type === "AssignmentPattern") - { this.raise(node.argument.start, "Rest elements cannot have a default value"); } - break - - case "AssignmentExpression": - if (node.operator !== "=") { this.raise(node.left.end, "Only '=' operator can be used for specifying default value."); } - node.type = "AssignmentPattern"; - delete node.operator; - this.toAssignable(node.left, isBinding); - break - - case "ParenthesizedExpression": - this.toAssignable(node.expression, isBinding, refDestructuringErrors); - break - - case "ChainExpression": - this.raiseRecoverable(node.start, "Optional chaining cannot appear in left-hand side"); - break - - case "MemberExpression": - if (!isBinding) { break } - - default: - this.raise(node.start, "Assigning to rvalue"); - } - } else if (refDestructuringErrors) { this.checkPatternErrors(refDestructuringErrors, true); } - return node - }; - - // Convert list of expression atoms to binding list. - - pp$7.toAssignableList = function(exprList, isBinding) { - var end = exprList.length; - for (var i = 0; i < end; i++) { - var elt = exprList[i]; - if (elt) { this.toAssignable(elt, isBinding); } - } - if (end) { - var last = exprList[end - 1]; - if (this.options.ecmaVersion === 6 && isBinding && last && last.type === "RestElement" && last.argument.type !== "Identifier") - { this.unexpected(last.argument.start); } - } - return exprList - }; - - // Parses spread element. - - pp$7.parseSpread = function(refDestructuringErrors) { - var node = this.startNode(); - this.next(); - node.argument = this.parseMaybeAssign(false, refDestructuringErrors); - return this.finishNode(node, "SpreadElement") - }; - - pp$7.parseRestBinding = function() { - var node = this.startNode(); - this.next(); - - // RestElement inside of a function parameter must be an identifier - if (this.options.ecmaVersion === 6 && this.type !== types$1.name) - { this.unexpected(); } - - node.argument = this.parseBindingAtom(); - - return this.finishNode(node, "RestElement") - }; - - // Parses lvalue (assignable) atom. - - pp$7.parseBindingAtom = function() { - if (this.options.ecmaVersion >= 6) { - switch (this.type) { - case types$1.bracketL: - var node = this.startNode(); - this.next(); - node.elements = this.parseBindingList(types$1.bracketR, true, true); - return this.finishNode(node, "ArrayPattern") - - case types$1.braceL: - return this.parseObj(true) - } - } - return this.parseIdent() - }; - - pp$7.parseBindingList = function(close, allowEmpty, allowTrailingComma, allowModifiers) { - var elts = [], first = true; - while (!this.eat(close)) { - if (first) { first = false; } - else { this.expect(types$1.comma); } - if (allowEmpty && this.type === types$1.comma) { - elts.push(null); - } else if (allowTrailingComma && this.afterTrailingComma(close)) { - break - } else if (this.type === types$1.ellipsis) { - var rest = this.parseRestBinding(); - this.parseBindingListItem(rest); - elts.push(rest); - if (this.type === types$1.comma) { this.raiseRecoverable(this.start, "Comma is not permitted after the rest element"); } - this.expect(close); - break - } else { - elts.push(this.parseAssignableListItem(allowModifiers)); - } - } - return elts - }; - - pp$7.parseAssignableListItem = function(allowModifiers) { - var elem = this.parseMaybeDefault(this.start, this.startLoc); - this.parseBindingListItem(elem); - return elem - }; - - pp$7.parseBindingListItem = function(param) { - return param - }; - - // Parses assignment pattern around given atom if possible. - - pp$7.parseMaybeDefault = function(startPos, startLoc, left) { - left = left || this.parseBindingAtom(); - if (this.options.ecmaVersion < 6 || !this.eat(types$1.eq)) { return left } - var node = this.startNodeAt(startPos, startLoc); - node.left = left; - node.right = this.parseMaybeAssign(); - return this.finishNode(node, "AssignmentPattern") - }; - - // The following three functions all verify that a node is an lvalue โ€” - // something that can be bound, or assigned to. In order to do so, they perform - // a variety of checks: - // - // - Check that none of the bound/assigned-to identifiers are reserved words. - // - Record name declarations for bindings in the appropriate scope. - // - Check duplicate argument names, if checkClashes is set. - // - // If a complex binding pattern is encountered (e.g., object and array - // destructuring), the entire pattern is recursively checked. - // - // There are three versions of checkLVal*() appropriate for different - // circumstances: - // - // - checkLValSimple() shall be used if the syntactic construct supports - // nothing other than identifiers and member expressions. Parenthesized - // expressions are also correctly handled. This is generally appropriate for - // constructs for which the spec says - // - // > It is a Syntax Error if AssignmentTargetType of [the production] is not - // > simple. - // - // It is also appropriate for checking if an identifier is valid and not - // defined elsewhere, like import declarations or function/class identifiers. - // - // Examples where this is used include: - // a += โ€ฆ; - // import a from 'โ€ฆ'; - // where a is the node to be checked. - // - // - checkLValPattern() shall be used if the syntactic construct supports - // anything checkLValSimple() supports, as well as object and array - // destructuring patterns. This is generally appropriate for constructs for - // which the spec says - // - // > It is a Syntax Error if [the production] is neither an ObjectLiteral nor - // > an ArrayLiteral and AssignmentTargetType of [the production] is not - // > simple. - // - // Examples where this is used include: - // (a = โ€ฆ); - // const a = โ€ฆ; - // try { โ€ฆ } catch (a) { โ€ฆ } - // where a is the node to be checked. - // - // - checkLValInnerPattern() shall be used if the syntactic construct supports - // anything checkLValPattern() supports, as well as default assignment - // patterns, rest elements, and other constructs that may appear within an - // object or array destructuring pattern. - // - // As a special case, function parameters also use checkLValInnerPattern(), - // as they also support defaults and rest constructs. - // - // These functions deliberately support both assignment and binding constructs, - // as the logic for both is exceedingly similar. If the node is the target of - // an assignment, then bindingType should be set to BIND_NONE. Otherwise, it - // should be set to the appropriate BIND_* constant, like BIND_VAR or - // BIND_LEXICAL. - // - // If the function is called with a non-BIND_NONE bindingType, then - // additionally a checkClashes object may be specified to allow checking for - // duplicate argument names. checkClashes is ignored if the provided construct - // is an assignment (i.e., bindingType is BIND_NONE). - - pp$7.checkLValSimple = function(expr, bindingType, checkClashes) { - if ( bindingType === void 0 ) bindingType = BIND_NONE; - - var isBind = bindingType !== BIND_NONE; - - switch (expr.type) { - case "Identifier": - if (this.strict && this.reservedWordsStrictBind.test(expr.name)) - { this.raiseRecoverable(expr.start, (isBind ? "Binding " : "Assigning to ") + expr.name + " in strict mode"); } - if (isBind) { - if (bindingType === BIND_LEXICAL && expr.name === "let") - { this.raiseRecoverable(expr.start, "let is disallowed as a lexically bound name"); } - if (checkClashes) { - if (hasOwn(checkClashes, expr.name)) - { this.raiseRecoverable(expr.start, "Argument name clash"); } - checkClashes[expr.name] = true; - } - if (bindingType !== BIND_OUTSIDE) { this.declareName(expr.name, bindingType, expr.start); } - } - break - - case "ChainExpression": - this.raiseRecoverable(expr.start, "Optional chaining cannot appear in left-hand side"); - break - - case "MemberExpression": - if (isBind) { this.raiseRecoverable(expr.start, "Binding member expression"); } - break - - case "ParenthesizedExpression": - if (isBind) { this.raiseRecoverable(expr.start, "Binding parenthesized expression"); } - return this.checkLValSimple(expr.expression, bindingType, checkClashes) - - default: - this.raise(expr.start, (isBind ? "Binding" : "Assigning to") + " rvalue"); - } - }; - - pp$7.checkLValPattern = function(expr, bindingType, checkClashes) { - if ( bindingType === void 0 ) bindingType = BIND_NONE; - - switch (expr.type) { - case "ObjectPattern": - for (var i = 0, list = expr.properties; i < list.length; i += 1) { - var prop = list[i]; - - this.checkLValInnerPattern(prop, bindingType, checkClashes); - } - break - - case "ArrayPattern": - for (var i$1 = 0, list$1 = expr.elements; i$1 < list$1.length; i$1 += 1) { - var elem = list$1[i$1]; - - if (elem) { this.checkLValInnerPattern(elem, bindingType, checkClashes); } - } - break - - default: - this.checkLValSimple(expr, bindingType, checkClashes); - } - }; - - pp$7.checkLValInnerPattern = function(expr, bindingType, checkClashes) { - if ( bindingType === void 0 ) bindingType = BIND_NONE; - - switch (expr.type) { - case "Property": - // AssignmentProperty has type === "Property" - this.checkLValInnerPattern(expr.value, bindingType, checkClashes); - break - - case "AssignmentPattern": - this.checkLValPattern(expr.left, bindingType, checkClashes); - break - - case "RestElement": - this.checkLValPattern(expr.argument, bindingType, checkClashes); - break - - default: - this.checkLValPattern(expr, bindingType, checkClashes); - } - }; - - // The algorithm used to determine whether a regexp can appear at a - // given point in the program is loosely based on sweet.js' approach. - // See https://github.com/mozilla/sweet.js/wiki/design - - - var TokContext = function TokContext(token, isExpr, preserveSpace, override, generator) { - this.token = token; - this.isExpr = !!isExpr; - this.preserveSpace = !!preserveSpace; - this.override = override; - this.generator = !!generator; - }; - - var types = { - b_stat: new TokContext("{", false), - b_expr: new TokContext("{", true), - b_tmpl: new TokContext("${", false), - p_stat: new TokContext("(", false), - p_expr: new TokContext("(", true), - q_tmpl: new TokContext("`", true, true, function (p) { return p.tryReadTemplateToken(); }), - f_stat: new TokContext("function", false), - f_expr: new TokContext("function", true), - f_expr_gen: new TokContext("function", true, false, null, true), - f_gen: new TokContext("function", false, false, null, true) - }; - - var pp$6 = Parser.prototype; - - pp$6.initialContext = function() { - return [types.b_stat] - }; - - pp$6.curContext = function() { - return this.context[this.context.length - 1] - }; - - pp$6.braceIsBlock = function(prevType) { - var parent = this.curContext(); - if (parent === types.f_expr || parent === types.f_stat) - { return true } - if (prevType === types$1.colon && (parent === types.b_stat || parent === types.b_expr)) - { return !parent.isExpr } - - // The check for `tt.name && exprAllowed` detects whether we are - // after a `yield` or `of` construct. See the `updateContext` for - // `tt.name`. - if (prevType === types$1._return || prevType === types$1.name && this.exprAllowed) - { return lineBreak.test(this.input.slice(this.lastTokEnd, this.start)) } - if (prevType === types$1._else || prevType === types$1.semi || prevType === types$1.eof || prevType === types$1.parenR || prevType === types$1.arrow) - { return true } - if (prevType === types$1.braceL) - { return parent === types.b_stat } - if (prevType === types$1._var || prevType === types$1._const || prevType === types$1.name) - { return false } - return !this.exprAllowed - }; - - pp$6.inGeneratorContext = function() { - for (var i = this.context.length - 1; i >= 1; i--) { - var context = this.context[i]; - if (context.token === "function") - { return context.generator } - } - return false - }; - - pp$6.updateContext = function(prevType) { - var update, type = this.type; - if (type.keyword && prevType === types$1.dot) - { this.exprAllowed = false; } - else if (update = type.updateContext) - { update.call(this, prevType); } - else - { this.exprAllowed = type.beforeExpr; } - }; - - // Used to handle edge cases when token context could not be inferred correctly during tokenization phase - - pp$6.overrideContext = function(tokenCtx) { - if (this.curContext() !== tokenCtx) { - this.context[this.context.length - 1] = tokenCtx; - } - }; - - // Token-specific context update code - - types$1.parenR.updateContext = types$1.braceR.updateContext = function() { - if (this.context.length === 1) { - this.exprAllowed = true; - return - } - var out = this.context.pop(); - if (out === types.b_stat && this.curContext().token === "function") { - out = this.context.pop(); - } - this.exprAllowed = !out.isExpr; - }; - - types$1.braceL.updateContext = function(prevType) { - this.context.push(this.braceIsBlock(prevType) ? types.b_stat : types.b_expr); - this.exprAllowed = true; - }; - - types$1.dollarBraceL.updateContext = function() { - this.context.push(types.b_tmpl); - this.exprAllowed = true; - }; - - types$1.parenL.updateContext = function(prevType) { - var statementParens = prevType === types$1._if || prevType === types$1._for || prevType === types$1._with || prevType === types$1._while; - this.context.push(statementParens ? types.p_stat : types.p_expr); - this.exprAllowed = true; - }; - - types$1.incDec.updateContext = function() { - // tokExprAllowed stays unchanged - }; - - types$1._function.updateContext = types$1._class.updateContext = function(prevType) { - if (prevType.beforeExpr && prevType !== types$1._else && - !(prevType === types$1.semi && this.curContext() !== types.p_stat) && - !(prevType === types$1._return && lineBreak.test(this.input.slice(this.lastTokEnd, this.start))) && - !((prevType === types$1.colon || prevType === types$1.braceL) && this.curContext() === types.b_stat)) - { this.context.push(types.f_expr); } - else - { this.context.push(types.f_stat); } - this.exprAllowed = false; - }; - - types$1.colon.updateContext = function() { - if (this.curContext().token === "function") { this.context.pop(); } - this.exprAllowed = true; - }; - - types$1.backQuote.updateContext = function() { - if (this.curContext() === types.q_tmpl) - { this.context.pop(); } - else - { this.context.push(types.q_tmpl); } - this.exprAllowed = false; - }; - - types$1.star.updateContext = function(prevType) { - if (prevType === types$1._function) { - var index = this.context.length - 1; - if (this.context[index] === types.f_expr) - { this.context[index] = types.f_expr_gen; } - else - { this.context[index] = types.f_gen; } - } - this.exprAllowed = true; - }; - - types$1.name.updateContext = function(prevType) { - var allowed = false; - if (this.options.ecmaVersion >= 6 && prevType !== types$1.dot) { - if (this.value === "of" && !this.exprAllowed || - this.value === "yield" && this.inGeneratorContext()) - { allowed = true; } - } - this.exprAllowed = allowed; - }; - - // A recursive descent parser operates by defining functions for all - // syntactic elements, and recursively calling those, each function - // advancing the input stream and returning an AST node. Precedence - // of constructs (for example, the fact that `!x[1]` means `!(x[1])` - // instead of `(!x)[1]` is handled by the fact that the parser - // function that parses unary prefix operators is called first, and - // in turn calls the function that parses `[]` subscripts โ€” that - // way, it'll receive the node for `x[1]` already parsed, and wraps - // *that* in the unary operator node. - // - // Acorn uses an [operator precedence parser][opp] to handle binary - // operator precedence, because it is much more compact than using - // the technique outlined above, which uses different, nesting - // functions to specify precedence, for all of the ten binary - // precedence levels that JavaScript defines. - // - // [opp]: http://en.wikipedia.org/wiki/Operator-precedence_parser - - - var pp$5 = Parser.prototype; - - // Check if property name clashes with already added. - // Object/class getters and setters are not allowed to clash โ€” - // either with each other or with an init property โ€” and in - // strict mode, init properties are also not allowed to be repeated. - - pp$5.checkPropClash = function(prop, propHash, refDestructuringErrors) { - if (this.options.ecmaVersion >= 9 && prop.type === "SpreadElement") - { return } - if (this.options.ecmaVersion >= 6 && (prop.computed || prop.method || prop.shorthand)) - { return } - var key = prop.key; - var name; - switch (key.type) { - case "Identifier": name = key.name; break - case "Literal": name = String(key.value); break - default: return - } - var kind = prop.kind; - if (this.options.ecmaVersion >= 6) { - if (name === "__proto__" && kind === "init") { - if (propHash.proto) { - if (refDestructuringErrors) { - if (refDestructuringErrors.doubleProto < 0) { - refDestructuringErrors.doubleProto = key.start; - } - } else { - this.raiseRecoverable(key.start, "Redefinition of __proto__ property"); - } - } - propHash.proto = true; - } - return - } - name = "$" + name; - var other = propHash[name]; - if (other) { - var redefinition; - if (kind === "init") { - redefinition = this.strict && other.init || other.get || other.set; - } else { - redefinition = other.init || other[kind]; - } - if (redefinition) - { this.raiseRecoverable(key.start, "Redefinition of property"); } - } else { - other = propHash[name] = { - init: false, - get: false, - set: false - }; - } - other[kind] = true; - }; - - // ### Expression parsing - - // These nest, from the most general expression type at the top to - // 'atomic', nondivisible expression types at the bottom. Most of - // the functions will simply let the function(s) below them parse, - // and, *if* the syntactic construct they handle is present, wrap - // the AST node that the inner parser gave them in another node. - - // Parse a full expression. The optional arguments are used to - // forbid the `in` operator (in for loops initalization expressions) - // and provide reference for storing '=' operator inside shorthand - // property assignment in contexts where both object expression - // and object pattern might appear (so it's possible to raise - // delayed syntax error at correct position). - - pp$5.parseExpression = function(forInit, refDestructuringErrors) { - var startPos = this.start, startLoc = this.startLoc; - var expr = this.parseMaybeAssign(forInit, refDestructuringErrors); - if (this.type === types$1.comma) { - var node = this.startNodeAt(startPos, startLoc); - node.expressions = [expr]; - while (this.eat(types$1.comma)) { node.expressions.push(this.parseMaybeAssign(forInit, refDestructuringErrors)); } - return this.finishNode(node, "SequenceExpression") - } - return expr - }; - - // Parse an assignment expression. This includes applications of - // operators like `+=`. - - pp$5.parseMaybeAssign = function(forInit, refDestructuringErrors, afterLeftParse) { - if (this.isContextual("yield")) { - if (this.inGenerator) { return this.parseYield(forInit) } - // The tokenizer will assume an expression is allowed after - // `yield`, but this isn't that kind of yield - else { this.exprAllowed = false; } - } - - var ownDestructuringErrors = false, oldParenAssign = -1, oldTrailingComma = -1, oldDoubleProto = -1; - if (refDestructuringErrors) { - oldParenAssign = refDestructuringErrors.parenthesizedAssign; - oldTrailingComma = refDestructuringErrors.trailingComma; - oldDoubleProto = refDestructuringErrors.doubleProto; - refDestructuringErrors.parenthesizedAssign = refDestructuringErrors.trailingComma = -1; - } else { - refDestructuringErrors = new DestructuringErrors; - ownDestructuringErrors = true; - } - - var startPos = this.start, startLoc = this.startLoc; - if (this.type === types$1.parenL || this.type === types$1.name) { - this.potentialArrowAt = this.start; - this.potentialArrowInForAwait = forInit === "await"; - } - var left = this.parseMaybeConditional(forInit, refDestructuringErrors); - if (afterLeftParse) { left = afterLeftParse.call(this, left, startPos, startLoc); } - if (this.type.isAssign) { - var node = this.startNodeAt(startPos, startLoc); - node.operator = this.value; - if (this.type === types$1.eq) - { left = this.toAssignable(left, false, refDestructuringErrors); } - if (!ownDestructuringErrors) { - refDestructuringErrors.parenthesizedAssign = refDestructuringErrors.trailingComma = refDestructuringErrors.doubleProto = -1; - } - if (refDestructuringErrors.shorthandAssign >= left.start) - { refDestructuringErrors.shorthandAssign = -1; } // reset because shorthand default was used correctly - if (this.type === types$1.eq) - { this.checkLValPattern(left); } - else - { this.checkLValSimple(left); } - node.left = left; - this.next(); - node.right = this.parseMaybeAssign(forInit); - if (oldDoubleProto > -1) { refDestructuringErrors.doubleProto = oldDoubleProto; } - return this.finishNode(node, "AssignmentExpression") - } else { - if (ownDestructuringErrors) { this.checkExpressionErrors(refDestructuringErrors, true); } - } - if (oldParenAssign > -1) { refDestructuringErrors.parenthesizedAssign = oldParenAssign; } - if (oldTrailingComma > -1) { refDestructuringErrors.trailingComma = oldTrailingComma; } - return left - }; - - // Parse a ternary conditional (`?:`) operator. - - pp$5.parseMaybeConditional = function(forInit, refDestructuringErrors) { - var startPos = this.start, startLoc = this.startLoc; - var expr = this.parseExprOps(forInit, refDestructuringErrors); - if (this.checkExpressionErrors(refDestructuringErrors)) { return expr } - if (this.eat(types$1.question)) { - var node = this.startNodeAt(startPos, startLoc); - node.test = expr; - node.consequent = this.parseMaybeAssign(); - this.expect(types$1.colon); - node.alternate = this.parseMaybeAssign(forInit); - return this.finishNode(node, "ConditionalExpression") - } - return expr - }; - - // Start the precedence parser. - - pp$5.parseExprOps = function(forInit, refDestructuringErrors) { - var startPos = this.start, startLoc = this.startLoc; - var expr = this.parseMaybeUnary(refDestructuringErrors, false, false, forInit); - if (this.checkExpressionErrors(refDestructuringErrors)) { return expr } - return expr.start === startPos && expr.type === "ArrowFunctionExpression" ? expr : this.parseExprOp(expr, startPos, startLoc, -1, forInit) - }; - - // Parse binary operators with the operator precedence parsing - // algorithm. `left` is the left-hand side of the operator. - // `minPrec` provides context that allows the function to stop and - // defer further parser to one of its callers when it encounters an - // operator that has a lower precedence than the set it is parsing. - - pp$5.parseExprOp = function(left, leftStartPos, leftStartLoc, minPrec, forInit) { - var prec = this.type.binop; - if (prec != null && (!forInit || this.type !== types$1._in)) { - if (prec > minPrec) { - var logical = this.type === types$1.logicalOR || this.type === types$1.logicalAND; - var coalesce = this.type === types$1.coalesce; - if (coalesce) { - // Handle the precedence of `tt.coalesce` as equal to the range of logical expressions. - // In other words, `node.right` shouldn't contain logical expressions in order to check the mixed error. - prec = types$1.logicalAND.binop; - } - var op = this.value; - this.next(); - var startPos = this.start, startLoc = this.startLoc; - var right = this.parseExprOp(this.parseMaybeUnary(null, false, false, forInit), startPos, startLoc, prec, forInit); - var node = this.buildBinary(leftStartPos, leftStartLoc, left, right, op, logical || coalesce); - if ((logical && this.type === types$1.coalesce) || (coalesce && (this.type === types$1.logicalOR || this.type === types$1.logicalAND))) { - this.raiseRecoverable(this.start, "Logical expressions and coalesce expressions cannot be mixed. Wrap either by parentheses"); - } - return this.parseExprOp(node, leftStartPos, leftStartLoc, minPrec, forInit) - } - } - return left - }; - - pp$5.buildBinary = function(startPos, startLoc, left, right, op, logical) { - if (right.type === "PrivateIdentifier") { this.raise(right.start, "Private identifier can only be left side of binary expression"); } - var node = this.startNodeAt(startPos, startLoc); - node.left = left; - node.operator = op; - node.right = right; - return this.finishNode(node, logical ? "LogicalExpression" : "BinaryExpression") - }; - - // Parse unary operators, both prefix and postfix. - - pp$5.parseMaybeUnary = function(refDestructuringErrors, sawUnary, incDec, forInit) { - var startPos = this.start, startLoc = this.startLoc, expr; - if (this.isContextual("await") && this.canAwait) { - expr = this.parseAwait(forInit); - sawUnary = true; - } else if (this.type.prefix) { - var node = this.startNode(), update = this.type === types$1.incDec; - node.operator = this.value; - node.prefix = true; - this.next(); - node.argument = this.parseMaybeUnary(null, true, update, forInit); - this.checkExpressionErrors(refDestructuringErrors, true); - if (update) { this.checkLValSimple(node.argument); } - else if (this.strict && node.operator === "delete" && isLocalVariableAccess(node.argument)) - { this.raiseRecoverable(node.start, "Deleting local variable in strict mode"); } - else if (node.operator === "delete" && isPrivateFieldAccess(node.argument)) - { this.raiseRecoverable(node.start, "Private fields can not be deleted"); } - else { sawUnary = true; } - expr = this.finishNode(node, update ? "UpdateExpression" : "UnaryExpression"); - } else if (!sawUnary && this.type === types$1.privateId) { - if ((forInit || this.privateNameStack.length === 0) && this.options.checkPrivateFields) { this.unexpected(); } - expr = this.parsePrivateIdent(); - // only could be private fields in 'in', such as #x in obj - if (this.type !== types$1._in) { this.unexpected(); } - } else { - expr = this.parseExprSubscripts(refDestructuringErrors, forInit); - if (this.checkExpressionErrors(refDestructuringErrors)) { return expr } - while (this.type.postfix && !this.canInsertSemicolon()) { - var node$1 = this.startNodeAt(startPos, startLoc); - node$1.operator = this.value; - node$1.prefix = false; - node$1.argument = expr; - this.checkLValSimple(expr); - this.next(); - expr = this.finishNode(node$1, "UpdateExpression"); - } - } - - if (!incDec && this.eat(types$1.starstar)) { - if (sawUnary) - { this.unexpected(this.lastTokStart); } - else - { return this.buildBinary(startPos, startLoc, expr, this.parseMaybeUnary(null, false, false, forInit), "**", false) } - } else { - return expr - } - }; - - function isLocalVariableAccess(node) { - return ( - node.type === "Identifier" || - node.type === "ParenthesizedExpression" && isLocalVariableAccess(node.expression) - ) - } - - function isPrivateFieldAccess(node) { - return ( - node.type === "MemberExpression" && node.property.type === "PrivateIdentifier" || - node.type === "ChainExpression" && isPrivateFieldAccess(node.expression) || - node.type === "ParenthesizedExpression" && isPrivateFieldAccess(node.expression) - ) - } - - // Parse call, dot, and `[]`-subscript expressions. - - pp$5.parseExprSubscripts = function(refDestructuringErrors, forInit) { - var startPos = this.start, startLoc = this.startLoc; - var expr = this.parseExprAtom(refDestructuringErrors, forInit); - if (expr.type === "ArrowFunctionExpression" && this.input.slice(this.lastTokStart, this.lastTokEnd) !== ")") - { return expr } - var result = this.parseSubscripts(expr, startPos, startLoc, false, forInit); - if (refDestructuringErrors && result.type === "MemberExpression") { - if (refDestructuringErrors.parenthesizedAssign >= result.start) { refDestructuringErrors.parenthesizedAssign = -1; } - if (refDestructuringErrors.parenthesizedBind >= result.start) { refDestructuringErrors.parenthesizedBind = -1; } - if (refDestructuringErrors.trailingComma >= result.start) { refDestructuringErrors.trailingComma = -1; } - } - return result - }; - - pp$5.parseSubscripts = function(base, startPos, startLoc, noCalls, forInit) { - var maybeAsyncArrow = this.options.ecmaVersion >= 8 && base.type === "Identifier" && base.name === "async" && - this.lastTokEnd === base.end && !this.canInsertSemicolon() && base.end - base.start === 5 && - this.potentialArrowAt === base.start; - var optionalChained = false; - - while (true) { - var element = this.parseSubscript(base, startPos, startLoc, noCalls, maybeAsyncArrow, optionalChained, forInit); - - if (element.optional) { optionalChained = true; } - if (element === base || element.type === "ArrowFunctionExpression") { - if (optionalChained) { - var chainNode = this.startNodeAt(startPos, startLoc); - chainNode.expression = element; - element = this.finishNode(chainNode, "ChainExpression"); - } - return element - } - - base = element; - } - }; - - pp$5.shouldParseAsyncArrow = function() { - return !this.canInsertSemicolon() && this.eat(types$1.arrow) - }; - - pp$5.parseSubscriptAsyncArrow = function(startPos, startLoc, exprList, forInit) { - return this.parseArrowExpression(this.startNodeAt(startPos, startLoc), exprList, true, forInit) - }; - - pp$5.parseSubscript = function(base, startPos, startLoc, noCalls, maybeAsyncArrow, optionalChained, forInit) { - var optionalSupported = this.options.ecmaVersion >= 11; - var optional = optionalSupported && this.eat(types$1.questionDot); - if (noCalls && optional) { this.raise(this.lastTokStart, "Optional chaining cannot appear in the callee of new expressions"); } - - var computed = this.eat(types$1.bracketL); - if (computed || (optional && this.type !== types$1.parenL && this.type !== types$1.backQuote) || this.eat(types$1.dot)) { - var node = this.startNodeAt(startPos, startLoc); - node.object = base; - if (computed) { - node.property = this.parseExpression(); - this.expect(types$1.bracketR); - } else if (this.type === types$1.privateId && base.type !== "Super") { - node.property = this.parsePrivateIdent(); - } else { - node.property = this.parseIdent(this.options.allowReserved !== "never"); - } - node.computed = !!computed; - if (optionalSupported) { - node.optional = optional; - } - base = this.finishNode(node, "MemberExpression"); - } else if (!noCalls && this.eat(types$1.parenL)) { - var refDestructuringErrors = new DestructuringErrors, oldYieldPos = this.yieldPos, oldAwaitPos = this.awaitPos, oldAwaitIdentPos = this.awaitIdentPos; - this.yieldPos = 0; - this.awaitPos = 0; - this.awaitIdentPos = 0; - var exprList = this.parseExprList(types$1.parenR, this.options.ecmaVersion >= 8, false, refDestructuringErrors); - if (maybeAsyncArrow && !optional && this.shouldParseAsyncArrow()) { - this.checkPatternErrors(refDestructuringErrors, false); - this.checkYieldAwaitInDefaultParams(); - if (this.awaitIdentPos > 0) - { this.raise(this.awaitIdentPos, "Cannot use 'await' as identifier inside an async function"); } - this.yieldPos = oldYieldPos; - this.awaitPos = oldAwaitPos; - this.awaitIdentPos = oldAwaitIdentPos; - return this.parseSubscriptAsyncArrow(startPos, startLoc, exprList, forInit) - } - this.checkExpressionErrors(refDestructuringErrors, true); - this.yieldPos = oldYieldPos || this.yieldPos; - this.awaitPos = oldAwaitPos || this.awaitPos; - this.awaitIdentPos = oldAwaitIdentPos || this.awaitIdentPos; - var node$1 = this.startNodeAt(startPos, startLoc); - node$1.callee = base; - node$1.arguments = exprList; - if (optionalSupported) { - node$1.optional = optional; - } - base = this.finishNode(node$1, "CallExpression"); - } else if (this.type === types$1.backQuote) { - if (optional || optionalChained) { - this.raise(this.start, "Optional chaining cannot appear in the tag of tagged template expressions"); - } - var node$2 = this.startNodeAt(startPos, startLoc); - node$2.tag = base; - node$2.quasi = this.parseTemplate({isTagged: true}); - base = this.finishNode(node$2, "TaggedTemplateExpression"); - } - return base - }; - - // Parse an atomic expression โ€” either a single token that is an - // expression, an expression started by a keyword like `function` or - // `new`, or an expression wrapped in punctuation like `()`, `[]`, - // or `{}`. - - pp$5.parseExprAtom = function(refDestructuringErrors, forInit, forNew) { - // If a division operator appears in an expression position, the - // tokenizer got confused, and we force it to read a regexp instead. - if (this.type === types$1.slash) { this.readRegexp(); } - - var node, canBeArrow = this.potentialArrowAt === this.start; - switch (this.type) { - case types$1._super: - if (!this.allowSuper) - { this.raise(this.start, "'super' keyword outside a method"); } - node = this.startNode(); - this.next(); - if (this.type === types$1.parenL && !this.allowDirectSuper) - { this.raise(node.start, "super() call outside constructor of a subclass"); } - // The `super` keyword can appear at below: - // SuperProperty: - // super [ Expression ] - // super . IdentifierName - // SuperCall: - // super ( Arguments ) - if (this.type !== types$1.dot && this.type !== types$1.bracketL && this.type !== types$1.parenL) - { this.unexpected(); } - return this.finishNode(node, "Super") - - case types$1._this: - node = this.startNode(); - this.next(); - return this.finishNode(node, "ThisExpression") - - case types$1.name: - var startPos = this.start, startLoc = this.startLoc, containsEsc = this.containsEsc; - var id = this.parseIdent(false); - if (this.options.ecmaVersion >= 8 && !containsEsc && id.name === "async" && !this.canInsertSemicolon() && this.eat(types$1._function)) { - this.overrideContext(types.f_expr); - return this.parseFunction(this.startNodeAt(startPos, startLoc), 0, false, true, forInit) - } - if (canBeArrow && !this.canInsertSemicolon()) { - if (this.eat(types$1.arrow)) - { return this.parseArrowExpression(this.startNodeAt(startPos, startLoc), [id], false, forInit) } - if (this.options.ecmaVersion >= 8 && id.name === "async" && this.type === types$1.name && !containsEsc && - (!this.potentialArrowInForAwait || this.value !== "of" || this.containsEsc)) { - id = this.parseIdent(false); - if (this.canInsertSemicolon() || !this.eat(types$1.arrow)) - { this.unexpected(); } - return this.parseArrowExpression(this.startNodeAt(startPos, startLoc), [id], true, forInit) - } - } - return id - - case types$1.regexp: - var value = this.value; - node = this.parseLiteral(value.value); - node.regex = {pattern: value.pattern, flags: value.flags}; - return node - - case types$1.num: case types$1.string: - return this.parseLiteral(this.value) - - case types$1._null: case types$1._true: case types$1._false: - node = this.startNode(); - node.value = this.type === types$1._null ? null : this.type === types$1._true; - node.raw = this.type.keyword; - this.next(); - return this.finishNode(node, "Literal") - - case types$1.parenL: - var start = this.start, expr = this.parseParenAndDistinguishExpression(canBeArrow, forInit); - if (refDestructuringErrors) { - if (refDestructuringErrors.parenthesizedAssign < 0 && !this.isSimpleAssignTarget(expr)) - { refDestructuringErrors.parenthesizedAssign = start; } - if (refDestructuringErrors.parenthesizedBind < 0) - { refDestructuringErrors.parenthesizedBind = start; } - } - return expr - - case types$1.bracketL: - node = this.startNode(); - this.next(); - node.elements = this.parseExprList(types$1.bracketR, true, true, refDestructuringErrors); - return this.finishNode(node, "ArrayExpression") - - case types$1.braceL: - this.overrideContext(types.b_expr); - return this.parseObj(false, refDestructuringErrors) - - case types$1._function: - node = this.startNode(); - this.next(); - return this.parseFunction(node, 0) - - case types$1._class: - return this.parseClass(this.startNode(), false) - - case types$1._new: - return this.parseNew() - - case types$1.backQuote: - return this.parseTemplate() - - case types$1._import: - if (this.options.ecmaVersion >= 11) { - return this.parseExprImport(forNew) - } else { - return this.unexpected() - } - - default: - return this.parseExprAtomDefault() - } - }; - - pp$5.parseExprAtomDefault = function() { - this.unexpected(); - }; - - pp$5.parseExprImport = function(forNew) { - var node = this.startNode(); - - // Consume `import` as an identifier for `import.meta`. - // Because `this.parseIdent(true)` doesn't check escape sequences, it needs the check of `this.containsEsc`. - if (this.containsEsc) { this.raiseRecoverable(this.start, "Escape sequence in keyword import"); } - this.next(); - - if (this.type === types$1.parenL && !forNew) { - return this.parseDynamicImport(node) - } else if (this.type === types$1.dot) { - var meta = this.startNodeAt(node.start, node.loc && node.loc.start); - meta.name = "import"; - node.meta = this.finishNode(meta, "Identifier"); - return this.parseImportMeta(node) - } else { - this.unexpected(); - } - }; - - pp$5.parseDynamicImport = function(node) { - this.next(); // skip `(` - - // Parse node.source. - node.source = this.parseMaybeAssign(); - - // Verify ending. - if (!this.eat(types$1.parenR)) { - var errorPos = this.start; - if (this.eat(types$1.comma) && this.eat(types$1.parenR)) { - this.raiseRecoverable(errorPos, "Trailing comma is not allowed in import()"); - } else { - this.unexpected(errorPos); - } - } - - return this.finishNode(node, "ImportExpression") - }; - - pp$5.parseImportMeta = function(node) { - this.next(); // skip `.` - - var containsEsc = this.containsEsc; - node.property = this.parseIdent(true); - - if (node.property.name !== "meta") - { this.raiseRecoverable(node.property.start, "The only valid meta property for import is 'import.meta'"); } - if (containsEsc) - { this.raiseRecoverable(node.start, "'import.meta' must not contain escaped characters"); } - if (this.options.sourceType !== "module" && !this.options.allowImportExportEverywhere) - { this.raiseRecoverable(node.start, "Cannot use 'import.meta' outside a module"); } - - return this.finishNode(node, "MetaProperty") - }; - - pp$5.parseLiteral = function(value) { - var node = this.startNode(); - node.value = value; - node.raw = this.input.slice(this.start, this.end); - if (node.raw.charCodeAt(node.raw.length - 1) === 110) { node.bigint = node.raw.slice(0, -1).replace(/_/g, ""); } - this.next(); - return this.finishNode(node, "Literal") - }; - - pp$5.parseParenExpression = function() { - this.expect(types$1.parenL); - var val = this.parseExpression(); - this.expect(types$1.parenR); - return val - }; - - pp$5.shouldParseArrow = function(exprList) { - return !this.canInsertSemicolon() - }; - - pp$5.parseParenAndDistinguishExpression = function(canBeArrow, forInit) { - var startPos = this.start, startLoc = this.startLoc, val, allowTrailingComma = this.options.ecmaVersion >= 8; - if (this.options.ecmaVersion >= 6) { - this.next(); - - var innerStartPos = this.start, innerStartLoc = this.startLoc; - var exprList = [], first = true, lastIsComma = false; - var refDestructuringErrors = new DestructuringErrors, oldYieldPos = this.yieldPos, oldAwaitPos = this.awaitPos, spreadStart; - this.yieldPos = 0; - this.awaitPos = 0; - // Do not save awaitIdentPos to allow checking awaits nested in parameters - while (this.type !== types$1.parenR) { - first ? first = false : this.expect(types$1.comma); - if (allowTrailingComma && this.afterTrailingComma(types$1.parenR, true)) { - lastIsComma = true; - break - } else if (this.type === types$1.ellipsis) { - spreadStart = this.start; - exprList.push(this.parseParenItem(this.parseRestBinding())); - if (this.type === types$1.comma) { - this.raiseRecoverable( - this.start, - "Comma is not permitted after the rest element" - ); - } - break - } else { - exprList.push(this.parseMaybeAssign(false, refDestructuringErrors, this.parseParenItem)); - } - } - var innerEndPos = this.lastTokEnd, innerEndLoc = this.lastTokEndLoc; - this.expect(types$1.parenR); - - if (canBeArrow && this.shouldParseArrow(exprList) && this.eat(types$1.arrow)) { - this.checkPatternErrors(refDestructuringErrors, false); - this.checkYieldAwaitInDefaultParams(); - this.yieldPos = oldYieldPos; - this.awaitPos = oldAwaitPos; - return this.parseParenArrowList(startPos, startLoc, exprList, forInit) - } - - if (!exprList.length || lastIsComma) { this.unexpected(this.lastTokStart); } - if (spreadStart) { this.unexpected(spreadStart); } - this.checkExpressionErrors(refDestructuringErrors, true); - this.yieldPos = oldYieldPos || this.yieldPos; - this.awaitPos = oldAwaitPos || this.awaitPos; - - if (exprList.length > 1) { - val = this.startNodeAt(innerStartPos, innerStartLoc); - val.expressions = exprList; - this.finishNodeAt(val, "SequenceExpression", innerEndPos, innerEndLoc); - } else { - val = exprList[0]; - } - } else { - val = this.parseParenExpression(); - } - - if (this.options.preserveParens) { - var par = this.startNodeAt(startPos, startLoc); - par.expression = val; - return this.finishNode(par, "ParenthesizedExpression") - } else { - return val - } - }; - - pp$5.parseParenItem = function(item) { - return item - }; - - pp$5.parseParenArrowList = function(startPos, startLoc, exprList, forInit) { - return this.parseArrowExpression(this.startNodeAt(startPos, startLoc), exprList, false, forInit) - }; - - // New's precedence is slightly tricky. It must allow its argument to - // be a `[]` or dot subscript expression, but not a call โ€” at least, - // not without wrapping it in parentheses. Thus, it uses the noCalls - // argument to parseSubscripts to prevent it from consuming the - // argument list. - - var empty = []; - - pp$5.parseNew = function() { - if (this.containsEsc) { this.raiseRecoverable(this.start, "Escape sequence in keyword new"); } - var node = this.startNode(); - this.next(); - if (this.options.ecmaVersion >= 6 && this.type === types$1.dot) { - var meta = this.startNodeAt(node.start, node.loc && node.loc.start); - meta.name = "new"; - node.meta = this.finishNode(meta, "Identifier"); - this.next(); - var containsEsc = this.containsEsc; - node.property = this.parseIdent(true); - if (node.property.name !== "target") - { this.raiseRecoverable(node.property.start, "The only valid meta property for new is 'new.target'"); } - if (containsEsc) - { this.raiseRecoverable(node.start, "'new.target' must not contain escaped characters"); } - if (!this.allowNewDotTarget) - { this.raiseRecoverable(node.start, "'new.target' can only be used in functions and class static block"); } - return this.finishNode(node, "MetaProperty") - } - var startPos = this.start, startLoc = this.startLoc; - node.callee = this.parseSubscripts(this.parseExprAtom(null, false, true), startPos, startLoc, true, false); - if (this.eat(types$1.parenL)) { node.arguments = this.parseExprList(types$1.parenR, this.options.ecmaVersion >= 8, false); } - else { node.arguments = empty; } - return this.finishNode(node, "NewExpression") - }; - - // Parse template expression. - - pp$5.parseTemplateElement = function(ref) { - var isTagged = ref.isTagged; - - var elem = this.startNode(); - if (this.type === types$1.invalidTemplate) { - if (!isTagged) { - this.raiseRecoverable(this.start, "Bad escape sequence in untagged template literal"); - } - elem.value = { - raw: this.value.replace(/\r\n?/g, "\n"), - cooked: null - }; - } else { - elem.value = { - raw: this.input.slice(this.start, this.end).replace(/\r\n?/g, "\n"), - cooked: this.value - }; - } - this.next(); - elem.tail = this.type === types$1.backQuote; - return this.finishNode(elem, "TemplateElement") - }; - - pp$5.parseTemplate = function(ref) { - if ( ref === void 0 ) ref = {}; - var isTagged = ref.isTagged; if ( isTagged === void 0 ) isTagged = false; - - var node = this.startNode(); - this.next(); - node.expressions = []; - var curElt = this.parseTemplateElement({isTagged: isTagged}); - node.quasis = [curElt]; - while (!curElt.tail) { - if (this.type === types$1.eof) { this.raise(this.pos, "Unterminated template literal"); } - this.expect(types$1.dollarBraceL); - node.expressions.push(this.parseExpression()); - this.expect(types$1.braceR); - node.quasis.push(curElt = this.parseTemplateElement({isTagged: isTagged})); - } - this.next(); - return this.finishNode(node, "TemplateLiteral") - }; - - pp$5.isAsyncProp = function(prop) { - return !prop.computed && prop.key.type === "Identifier" && prop.key.name === "async" && - (this.type === types$1.name || this.type === types$1.num || this.type === types$1.string || this.type === types$1.bracketL || this.type.keyword || (this.options.ecmaVersion >= 9 && this.type === types$1.star)) && - !lineBreak.test(this.input.slice(this.lastTokEnd, this.start)) - }; - - // Parse an object literal or binding pattern. - - pp$5.parseObj = function(isPattern, refDestructuringErrors) { - var node = this.startNode(), first = true, propHash = {}; - node.properties = []; - this.next(); - while (!this.eat(types$1.braceR)) { - if (!first) { - this.expect(types$1.comma); - if (this.options.ecmaVersion >= 5 && this.afterTrailingComma(types$1.braceR)) { break } - } else { first = false; } - - var prop = this.parseProperty(isPattern, refDestructuringErrors); - if (!isPattern) { this.checkPropClash(prop, propHash, refDestructuringErrors); } - node.properties.push(prop); - } - return this.finishNode(node, isPattern ? "ObjectPattern" : "ObjectExpression") - }; - - pp$5.parseProperty = function(isPattern, refDestructuringErrors) { - var prop = this.startNode(), isGenerator, isAsync, startPos, startLoc; - if (this.options.ecmaVersion >= 9 && this.eat(types$1.ellipsis)) { - if (isPattern) { - prop.argument = this.parseIdent(false); - if (this.type === types$1.comma) { - this.raiseRecoverable(this.start, "Comma is not permitted after the rest element"); - } - return this.finishNode(prop, "RestElement") - } - // Parse argument. - prop.argument = this.parseMaybeAssign(false, refDestructuringErrors); - // To disallow trailing comma via `this.toAssignable()`. - if (this.type === types$1.comma && refDestructuringErrors && refDestructuringErrors.trailingComma < 0) { - refDestructuringErrors.trailingComma = this.start; - } - // Finish - return this.finishNode(prop, "SpreadElement") - } - if (this.options.ecmaVersion >= 6) { - prop.method = false; - prop.shorthand = false; - if (isPattern || refDestructuringErrors) { - startPos = this.start; - startLoc = this.startLoc; - } - if (!isPattern) - { isGenerator = this.eat(types$1.star); } - } - var containsEsc = this.containsEsc; - this.parsePropertyName(prop); - if (!isPattern && !containsEsc && this.options.ecmaVersion >= 8 && !isGenerator && this.isAsyncProp(prop)) { - isAsync = true; - isGenerator = this.options.ecmaVersion >= 9 && this.eat(types$1.star); - this.parsePropertyName(prop); - } else { - isAsync = false; - } - this.parsePropertyValue(prop, isPattern, isGenerator, isAsync, startPos, startLoc, refDestructuringErrors, containsEsc); - return this.finishNode(prop, "Property") - }; - - pp$5.parseGetterSetter = function(prop) { - prop.kind = prop.key.name; - this.parsePropertyName(prop); - prop.value = this.parseMethod(false); - var paramCount = prop.kind === "get" ? 0 : 1; - if (prop.value.params.length !== paramCount) { - var start = prop.value.start; - if (prop.kind === "get") - { this.raiseRecoverable(start, "getter should have no params"); } - else - { this.raiseRecoverable(start, "setter should have exactly one param"); } - } else { - if (prop.kind === "set" && prop.value.params[0].type === "RestElement") - { this.raiseRecoverable(prop.value.params[0].start, "Setter cannot use rest params"); } - } - }; - - pp$5.parsePropertyValue = function(prop, isPattern, isGenerator, isAsync, startPos, startLoc, refDestructuringErrors, containsEsc) { - if ((isGenerator || isAsync) && this.type === types$1.colon) - { this.unexpected(); } - - if (this.eat(types$1.colon)) { - prop.value = isPattern ? this.parseMaybeDefault(this.start, this.startLoc) : this.parseMaybeAssign(false, refDestructuringErrors); - prop.kind = "init"; - } else if (this.options.ecmaVersion >= 6 && this.type === types$1.parenL) { - if (isPattern) { this.unexpected(); } - prop.kind = "init"; - prop.method = true; - prop.value = this.parseMethod(isGenerator, isAsync); - } else if (!isPattern && !containsEsc && - this.options.ecmaVersion >= 5 && !prop.computed && prop.key.type === "Identifier" && - (prop.key.name === "get" || prop.key.name === "set") && - (this.type !== types$1.comma && this.type !== types$1.braceR && this.type !== types$1.eq)) { - if (isGenerator || isAsync) { this.unexpected(); } - this.parseGetterSetter(prop); - } else if (this.options.ecmaVersion >= 6 && !prop.computed && prop.key.type === "Identifier") { - if (isGenerator || isAsync) { this.unexpected(); } - this.checkUnreserved(prop.key); - if (prop.key.name === "await" && !this.awaitIdentPos) - { this.awaitIdentPos = startPos; } - prop.kind = "init"; - if (isPattern) { - prop.value = this.parseMaybeDefault(startPos, startLoc, this.copyNode(prop.key)); - } else if (this.type === types$1.eq && refDestructuringErrors) { - if (refDestructuringErrors.shorthandAssign < 0) - { refDestructuringErrors.shorthandAssign = this.start; } - prop.value = this.parseMaybeDefault(startPos, startLoc, this.copyNode(prop.key)); - } else { - prop.value = this.copyNode(prop.key); - } - prop.shorthand = true; - } else { this.unexpected(); } - }; - - pp$5.parsePropertyName = function(prop) { - if (this.options.ecmaVersion >= 6) { - if (this.eat(types$1.bracketL)) { - prop.computed = true; - prop.key = this.parseMaybeAssign(); - this.expect(types$1.bracketR); - return prop.key - } else { - prop.computed = false; - } - } - return prop.key = this.type === types$1.num || this.type === types$1.string ? this.parseExprAtom() : this.parseIdent(this.options.allowReserved !== "never") - }; - - // Initialize empty function node. - - pp$5.initFunction = function(node) { - node.id = null; - if (this.options.ecmaVersion >= 6) { node.generator = node.expression = false; } - if (this.options.ecmaVersion >= 8) { node.async = false; } - }; - - // Parse object or class method. - - pp$5.parseMethod = function(isGenerator, isAsync, allowDirectSuper) { - var node = this.startNode(), oldYieldPos = this.yieldPos, oldAwaitPos = this.awaitPos, oldAwaitIdentPos = this.awaitIdentPos; - - this.initFunction(node); - if (this.options.ecmaVersion >= 6) - { node.generator = isGenerator; } - if (this.options.ecmaVersion >= 8) - { node.async = !!isAsync; } - - this.yieldPos = 0; - this.awaitPos = 0; - this.awaitIdentPos = 0; - this.enterScope(functionFlags(isAsync, node.generator) | SCOPE_SUPER | (allowDirectSuper ? SCOPE_DIRECT_SUPER : 0)); - - this.expect(types$1.parenL); - node.params = this.parseBindingList(types$1.parenR, false, this.options.ecmaVersion >= 8); - this.checkYieldAwaitInDefaultParams(); - this.parseFunctionBody(node, false, true, false); - - this.yieldPos = oldYieldPos; - this.awaitPos = oldAwaitPos; - this.awaitIdentPos = oldAwaitIdentPos; - return this.finishNode(node, "FunctionExpression") - }; - - // Parse arrow function expression with given parameters. - - pp$5.parseArrowExpression = function(node, params, isAsync, forInit) { - var oldYieldPos = this.yieldPos, oldAwaitPos = this.awaitPos, oldAwaitIdentPos = this.awaitIdentPos; - - this.enterScope(functionFlags(isAsync, false) | SCOPE_ARROW); - this.initFunction(node); - if (this.options.ecmaVersion >= 8) { node.async = !!isAsync; } - - this.yieldPos = 0; - this.awaitPos = 0; - this.awaitIdentPos = 0; - - node.params = this.toAssignableList(params, true); - this.parseFunctionBody(node, true, false, forInit); - - this.yieldPos = oldYieldPos; - this.awaitPos = oldAwaitPos; - this.awaitIdentPos = oldAwaitIdentPos; - return this.finishNode(node, "ArrowFunctionExpression") - }; - - // Parse function body and check parameters. - - pp$5.parseFunctionBody = function(node, isArrowFunction, isMethod, forInit) { - var isExpression = isArrowFunction && this.type !== types$1.braceL; - var oldStrict = this.strict, useStrict = false; - - if (isExpression) { - node.body = this.parseMaybeAssign(forInit); - node.expression = true; - this.checkParams(node, false); - } else { - var nonSimple = this.options.ecmaVersion >= 7 && !this.isSimpleParamList(node.params); - if (!oldStrict || nonSimple) { - useStrict = this.strictDirective(this.end); - // If this is a strict mode function, verify that argument names - // are not repeated, and it does not try to bind the words `eval` - // or `arguments`. - if (useStrict && nonSimple) - { this.raiseRecoverable(node.start, "Illegal 'use strict' directive in function with non-simple parameter list"); } - } - // Start a new scope with regard to labels and the `inFunction` - // flag (restore them to their old value afterwards). - var oldLabels = this.labels; - this.labels = []; - if (useStrict) { this.strict = true; } - - // Add the params to varDeclaredNames to ensure that an error is thrown - // if a let/const declaration in the function clashes with one of the params. - this.checkParams(node, !oldStrict && !useStrict && !isArrowFunction && !isMethod && this.isSimpleParamList(node.params)); - // Ensure the function name isn't a forbidden identifier in strict mode, e.g. 'eval' - if (this.strict && node.id) { this.checkLValSimple(node.id, BIND_OUTSIDE); } - node.body = this.parseBlock(false, undefined, useStrict && !oldStrict); - node.expression = false; - this.adaptDirectivePrologue(node.body.body); - this.labels = oldLabels; - } - this.exitScope(); - }; - - pp$5.isSimpleParamList = function(params) { - for (var i = 0, list = params; i < list.length; i += 1) - { - var param = list[i]; - - if (param.type !== "Identifier") { return false - } } - return true - }; - - // Checks function params for various disallowed patterns such as using "eval" - // or "arguments" and duplicate parameters. - - pp$5.checkParams = function(node, allowDuplicates) { - var nameHash = Object.create(null); - for (var i = 0, list = node.params; i < list.length; i += 1) - { - var param = list[i]; - - this.checkLValInnerPattern(param, BIND_VAR, allowDuplicates ? null : nameHash); - } - }; - - // Parses a comma-separated list of expressions, and returns them as - // an array. `close` is the token type that ends the list, and - // `allowEmpty` can be turned on to allow subsequent commas with - // nothing in between them to be parsed as `null` (which is needed - // for array literals). - - pp$5.parseExprList = function(close, allowTrailingComma, allowEmpty, refDestructuringErrors) { - var elts = [], first = true; - while (!this.eat(close)) { - if (!first) { - this.expect(types$1.comma); - if (allowTrailingComma && this.afterTrailingComma(close)) { break } - } else { first = false; } - - var elt = (void 0); - if (allowEmpty && this.type === types$1.comma) - { elt = null; } - else if (this.type === types$1.ellipsis) { - elt = this.parseSpread(refDestructuringErrors); - if (refDestructuringErrors && this.type === types$1.comma && refDestructuringErrors.trailingComma < 0) - { refDestructuringErrors.trailingComma = this.start; } - } else { - elt = this.parseMaybeAssign(false, refDestructuringErrors); - } - elts.push(elt); - } - return elts - }; - - pp$5.checkUnreserved = function(ref) { - var start = ref.start; - var end = ref.end; - var name = ref.name; - - if (this.inGenerator && name === "yield") - { this.raiseRecoverable(start, "Cannot use 'yield' as identifier inside a generator"); } - if (this.inAsync && name === "await") - { this.raiseRecoverable(start, "Cannot use 'await' as identifier inside an async function"); } - if (this.currentThisScope().inClassFieldInit && name === "arguments") - { this.raiseRecoverable(start, "Cannot use 'arguments' in class field initializer"); } - if (this.inClassStaticBlock && (name === "arguments" || name === "await")) - { this.raise(start, ("Cannot use " + name + " in class static initialization block")); } - if (this.keywords.test(name)) - { this.raise(start, ("Unexpected keyword '" + name + "'")); } - if (this.options.ecmaVersion < 6 && - this.input.slice(start, end).indexOf("\\") !== -1) { return } - var re = this.strict ? this.reservedWordsStrict : this.reservedWords; - if (re.test(name)) { - if (!this.inAsync && name === "await") - { this.raiseRecoverable(start, "Cannot use keyword 'await' outside an async function"); } - this.raiseRecoverable(start, ("The keyword '" + name + "' is reserved")); - } - }; - - // Parse the next token as an identifier. If `liberal` is true (used - // when parsing properties), it will also convert keywords into - // identifiers. - - pp$5.parseIdent = function(liberal) { - var node = this.parseIdentNode(); - this.next(!!liberal); - this.finishNode(node, "Identifier"); - if (!liberal) { - this.checkUnreserved(node); - if (node.name === "await" && !this.awaitIdentPos) - { this.awaitIdentPos = node.start; } - } - return node - }; - - pp$5.parseIdentNode = function() { - var node = this.startNode(); - if (this.type === types$1.name) { - node.name = this.value; - } else if (this.type.keyword) { - node.name = this.type.keyword; - - // To fix https://github.com/acornjs/acorn/issues/575 - // `class` and `function` keywords push new context into this.context. - // But there is no chance to pop the context if the keyword is consumed as an identifier such as a property name. - // If the previous token is a dot, this does not apply because the context-managing code already ignored the keyword - if ((node.name === "class" || node.name === "function") && - (this.lastTokEnd !== this.lastTokStart + 1 || this.input.charCodeAt(this.lastTokStart) !== 46)) { - this.context.pop(); - } - this.type = types$1.name; - } else { - this.unexpected(); - } - return node - }; - - pp$5.parsePrivateIdent = function() { - var node = this.startNode(); - if (this.type === types$1.privateId) { - node.name = this.value; - } else { - this.unexpected(); - } - this.next(); - this.finishNode(node, "PrivateIdentifier"); - - // For validating existence - if (this.options.checkPrivateFields) { - if (this.privateNameStack.length === 0) { - this.raise(node.start, ("Private field '#" + (node.name) + "' must be declared in an enclosing class")); - } else { - this.privateNameStack[this.privateNameStack.length - 1].used.push(node); - } - } - - return node - }; - - // Parses yield expression inside generator. - - pp$5.parseYield = function(forInit) { - if (!this.yieldPos) { this.yieldPos = this.start; } - - var node = this.startNode(); - this.next(); - if (this.type === types$1.semi || this.canInsertSemicolon() || (this.type !== types$1.star && !this.type.startsExpr)) { - node.delegate = false; - node.argument = null; - } else { - node.delegate = this.eat(types$1.star); - node.argument = this.parseMaybeAssign(forInit); - } - return this.finishNode(node, "YieldExpression") - }; - - pp$5.parseAwait = function(forInit) { - if (!this.awaitPos) { this.awaitPos = this.start; } - - var node = this.startNode(); - this.next(); - node.argument = this.parseMaybeUnary(null, true, false, forInit); - return this.finishNode(node, "AwaitExpression") - }; - - var pp$4 = Parser.prototype; - - // This function is used to raise exceptions on parse errors. It - // takes an offset integer (into the current `input`) to indicate - // the location of the error, attaches the position to the end - // of the error message, and then raises a `SyntaxError` with that - // message. - - pp$4.raise = function(pos, message) { - var loc = getLineInfo(this.input, pos); - message += " (" + loc.line + ":" + loc.column + ")"; - var err = new SyntaxError(message); - err.pos = pos; err.loc = loc; err.raisedAt = this.pos; - throw err - }; - - pp$4.raiseRecoverable = pp$4.raise; - - pp$4.curPosition = function() { - if (this.options.locations) { - return new Position(this.curLine, this.pos - this.lineStart) - } - }; - - var pp$3 = Parser.prototype; - - var Scope = function Scope(flags) { - this.flags = flags; - // A list of var-declared names in the current lexical scope - this.var = []; - // A list of lexically-declared names in the current lexical scope - this.lexical = []; - // A list of lexically-declared FunctionDeclaration names in the current lexical scope - this.functions = []; - // A switch to disallow the identifier reference 'arguments' - this.inClassFieldInit = false; - }; - - // The functions in this module keep track of declared variables in the current scope in order to detect duplicate variable names. - - pp$3.enterScope = function(flags) { - this.scopeStack.push(new Scope(flags)); - }; - - pp$3.exitScope = function() { - this.scopeStack.pop(); - }; - - // The spec says: - // > At the top level of a function, or script, function declarations are - // > treated like var declarations rather than like lexical declarations. - pp$3.treatFunctionsAsVarInScope = function(scope) { - return (scope.flags & SCOPE_FUNCTION) || !this.inModule && (scope.flags & SCOPE_TOP) - }; - - pp$3.declareName = function(name, bindingType, pos) { - var redeclared = false; - if (bindingType === BIND_LEXICAL) { - var scope = this.currentScope(); - redeclared = scope.lexical.indexOf(name) > -1 || scope.functions.indexOf(name) > -1 || scope.var.indexOf(name) > -1; - scope.lexical.push(name); - if (this.inModule && (scope.flags & SCOPE_TOP)) - { delete this.undefinedExports[name]; } - } else if (bindingType === BIND_SIMPLE_CATCH) { - var scope$1 = this.currentScope(); - scope$1.lexical.push(name); - } else if (bindingType === BIND_FUNCTION) { - var scope$2 = this.currentScope(); - if (this.treatFunctionsAsVar) - { redeclared = scope$2.lexical.indexOf(name) > -1; } - else - { redeclared = scope$2.lexical.indexOf(name) > -1 || scope$2.var.indexOf(name) > -1; } - scope$2.functions.push(name); - } else { - for (var i = this.scopeStack.length - 1; i >= 0; --i) { - var scope$3 = this.scopeStack[i]; - if (scope$3.lexical.indexOf(name) > -1 && !((scope$3.flags & SCOPE_SIMPLE_CATCH) && scope$3.lexical[0] === name) || - !this.treatFunctionsAsVarInScope(scope$3) && scope$3.functions.indexOf(name) > -1) { - redeclared = true; - break - } - scope$3.var.push(name); - if (this.inModule && (scope$3.flags & SCOPE_TOP)) - { delete this.undefinedExports[name]; } - if (scope$3.flags & SCOPE_VAR) { break } - } - } - if (redeclared) { this.raiseRecoverable(pos, ("Identifier '" + name + "' has already been declared")); } - }; - - pp$3.checkLocalExport = function(id) { - // scope.functions must be empty as Module code is always strict. - if (this.scopeStack[0].lexical.indexOf(id.name) === -1 && - this.scopeStack[0].var.indexOf(id.name) === -1) { - this.undefinedExports[id.name] = id; - } - }; - - pp$3.currentScope = function() { - return this.scopeStack[this.scopeStack.length - 1] - }; - - pp$3.currentVarScope = function() { - for (var i = this.scopeStack.length - 1;; i--) { - var scope = this.scopeStack[i]; - if (scope.flags & SCOPE_VAR) { return scope } - } - }; - - // Could be useful for `this`, `new.target`, `super()`, `super.property`, and `super[property]`. - pp$3.currentThisScope = function() { - for (var i = this.scopeStack.length - 1;; i--) { - var scope = this.scopeStack[i]; - if (scope.flags & SCOPE_VAR && !(scope.flags & SCOPE_ARROW)) { return scope } - } - }; - - var Node = function Node(parser, pos, loc) { - this.type = ""; - this.start = pos; - this.end = 0; - if (parser.options.locations) - { this.loc = new SourceLocation(parser, loc); } - if (parser.options.directSourceFile) - { this.sourceFile = parser.options.directSourceFile; } - if (parser.options.ranges) - { this.range = [pos, 0]; } - }; - - // Start an AST node, attaching a start offset. - - var pp$2 = Parser.prototype; - - pp$2.startNode = function() { - return new Node(this, this.start, this.startLoc) - }; - - pp$2.startNodeAt = function(pos, loc) { - return new Node(this, pos, loc) - }; - - // Finish an AST node, adding `type` and `end` properties. - - function finishNodeAt(node, type, pos, loc) { - node.type = type; - node.end = pos; - if (this.options.locations) - { node.loc.end = loc; } - if (this.options.ranges) - { node.range[1] = pos; } - return node - } - - pp$2.finishNode = function(node, type) { - return finishNodeAt.call(this, node, type, this.lastTokEnd, this.lastTokEndLoc) - }; - - // Finish node at given position - - pp$2.finishNodeAt = function(node, type, pos, loc) { - return finishNodeAt.call(this, node, type, pos, loc) - }; - - pp$2.copyNode = function(node) { - var newNode = new Node(this, node.start, this.startLoc); - for (var prop in node) { newNode[prop] = node[prop]; } - return newNode - }; - - // This file contains Unicode properties extracted from the ECMAScript specification. - // The lists are extracted like so: - // $$('#table-binary-unicode-properties > figure > table > tbody > tr > td:nth-child(1) code').map(el => el.innerText) - - // #table-binary-unicode-properties - var ecma9BinaryProperties = "ASCII ASCII_Hex_Digit AHex Alphabetic Alpha Any Assigned Bidi_Control Bidi_C Bidi_Mirrored Bidi_M Case_Ignorable CI Cased Changes_When_Casefolded CWCF Changes_When_Casemapped CWCM Changes_When_Lowercased CWL Changes_When_NFKC_Casefolded CWKCF Changes_When_Titlecased CWT Changes_When_Uppercased CWU Dash Default_Ignorable_Code_Point DI Deprecated Dep Diacritic Dia Emoji Emoji_Component Emoji_Modifier Emoji_Modifier_Base Emoji_Presentation Extender Ext Grapheme_Base Gr_Base Grapheme_Extend Gr_Ext Hex_Digit Hex IDS_Binary_Operator IDSB IDS_Trinary_Operator IDST ID_Continue IDC ID_Start IDS Ideographic Ideo Join_Control Join_C Logical_Order_Exception LOE Lowercase Lower Math Noncharacter_Code_Point NChar Pattern_Syntax Pat_Syn Pattern_White_Space Pat_WS Quotation_Mark QMark Radical Regional_Indicator RI Sentence_Terminal STerm Soft_Dotted SD Terminal_Punctuation Term Unified_Ideograph UIdeo Uppercase Upper Variation_Selector VS White_Space space XID_Continue XIDC XID_Start XIDS"; - var ecma10BinaryProperties = ecma9BinaryProperties + " Extended_Pictographic"; - var ecma11BinaryProperties = ecma10BinaryProperties; - var ecma12BinaryProperties = ecma11BinaryProperties + " EBase EComp EMod EPres ExtPict"; - var ecma13BinaryProperties = ecma12BinaryProperties; - var ecma14BinaryProperties = ecma13BinaryProperties; - - var unicodeBinaryProperties = { - 9: ecma9BinaryProperties, - 10: ecma10BinaryProperties, - 11: ecma11BinaryProperties, - 12: ecma12BinaryProperties, - 13: ecma13BinaryProperties, - 14: ecma14BinaryProperties - }; - - // #table-binary-unicode-properties-of-strings - var ecma14BinaryPropertiesOfStrings = "Basic_Emoji Emoji_Keycap_Sequence RGI_Emoji_Modifier_Sequence RGI_Emoji_Flag_Sequence RGI_Emoji_Tag_Sequence RGI_Emoji_ZWJ_Sequence RGI_Emoji"; - - var unicodeBinaryPropertiesOfStrings = { - 9: "", - 10: "", - 11: "", - 12: "", - 13: "", - 14: ecma14BinaryPropertiesOfStrings - }; - - // #table-unicode-general-category-values - var unicodeGeneralCategoryValues = "Cased_Letter LC Close_Punctuation Pe Connector_Punctuation Pc Control Cc cntrl Currency_Symbol Sc Dash_Punctuation Pd Decimal_Number Nd digit Enclosing_Mark Me Final_Punctuation Pf Format Cf Initial_Punctuation Pi Letter L Letter_Number Nl Line_Separator Zl Lowercase_Letter Ll Mark M Combining_Mark Math_Symbol Sm Modifier_Letter Lm Modifier_Symbol Sk Nonspacing_Mark Mn Number N Open_Punctuation Ps Other C Other_Letter Lo Other_Number No Other_Punctuation Po Other_Symbol So Paragraph_Separator Zp Private_Use Co Punctuation P punct Separator Z Space_Separator Zs Spacing_Mark Mc Surrogate Cs Symbol S Titlecase_Letter Lt Unassigned Cn Uppercase_Letter Lu"; - - // #table-unicode-script-values - var ecma9ScriptValues = "Adlam Adlm Ahom Anatolian_Hieroglyphs Hluw Arabic Arab Armenian Armn Avestan Avst Balinese Bali Bamum Bamu Bassa_Vah Bass Batak Batk Bengali Beng Bhaiksuki Bhks Bopomofo Bopo Brahmi Brah Braille Brai Buginese Bugi Buhid Buhd Canadian_Aboriginal Cans Carian Cari Caucasian_Albanian Aghb Chakma Cakm Cham Cham Cherokee Cher Common Zyyy Coptic Copt Qaac Cuneiform Xsux Cypriot Cprt Cyrillic Cyrl Deseret Dsrt Devanagari Deva Duployan Dupl Egyptian_Hieroglyphs Egyp Elbasan Elba Ethiopic Ethi Georgian Geor Glagolitic Glag Gothic Goth Grantha Gran Greek Grek Gujarati Gujr Gurmukhi Guru Han Hani Hangul Hang Hanunoo Hano Hatran Hatr Hebrew Hebr Hiragana Hira Imperial_Aramaic Armi Inherited Zinh Qaai Inscriptional_Pahlavi Phli Inscriptional_Parthian Prti Javanese Java Kaithi Kthi Kannada Knda Katakana Kana Kayah_Li Kali Kharoshthi Khar Khmer Khmr Khojki Khoj Khudawadi Sind Lao Laoo Latin Latn Lepcha Lepc Limbu Limb Linear_A Lina Linear_B Linb Lisu Lisu Lycian Lyci Lydian Lydi Mahajani Mahj Malayalam Mlym Mandaic Mand Manichaean Mani Marchen Marc Masaram_Gondi Gonm Meetei_Mayek Mtei Mende_Kikakui Mend Meroitic_Cursive Merc Meroitic_Hieroglyphs Mero Miao Plrd Modi Mongolian Mong Mro Mroo Multani Mult Myanmar Mymr Nabataean Nbat New_Tai_Lue Talu Newa Newa Nko Nkoo Nushu Nshu Ogham Ogam Ol_Chiki Olck Old_Hungarian Hung Old_Italic Ital Old_North_Arabian Narb Old_Permic Perm Old_Persian Xpeo Old_South_Arabian Sarb Old_Turkic Orkh Oriya Orya Osage Osge Osmanya Osma Pahawh_Hmong Hmng Palmyrene Palm Pau_Cin_Hau Pauc Phags_Pa Phag Phoenician Phnx Psalter_Pahlavi Phlp Rejang Rjng Runic Runr Samaritan Samr Saurashtra Saur Sharada Shrd Shavian Shaw Siddham Sidd SignWriting Sgnw Sinhala Sinh Sora_Sompeng Sora Soyombo Soyo Sundanese Sund Syloti_Nagri Sylo Syriac Syrc Tagalog Tglg Tagbanwa Tagb Tai_Le Tale Tai_Tham Lana Tai_Viet Tavt Takri Takr Tamil Taml Tangut Tang Telugu Telu Thaana Thaa Thai Thai Tibetan Tibt Tifinagh Tfng Tirhuta Tirh Ugaritic Ugar Vai Vaii Warang_Citi Wara Yi Yiii Zanabazar_Square Zanb"; - var ecma10ScriptValues = ecma9ScriptValues + " Dogra Dogr Gunjala_Gondi Gong Hanifi_Rohingya Rohg Makasar Maka Medefaidrin Medf Old_Sogdian Sogo Sogdian Sogd"; - var ecma11ScriptValues = ecma10ScriptValues + " Elymaic Elym Nandinagari Nand Nyiakeng_Puachue_Hmong Hmnp Wancho Wcho"; - var ecma12ScriptValues = ecma11ScriptValues + " Chorasmian Chrs Diak Dives_Akuru Khitan_Small_Script Kits Yezi Yezidi"; - var ecma13ScriptValues = ecma12ScriptValues + " Cypro_Minoan Cpmn Old_Uyghur Ougr Tangsa Tnsa Toto Vithkuqi Vith"; - var ecma14ScriptValues = ecma13ScriptValues + " Hrkt Katakana_Or_Hiragana Kawi Nag_Mundari Nagm Unknown Zzzz"; - - var unicodeScriptValues = { - 9: ecma9ScriptValues, - 10: ecma10ScriptValues, - 11: ecma11ScriptValues, - 12: ecma12ScriptValues, - 13: ecma13ScriptValues, - 14: ecma14ScriptValues - }; - - var data = {}; - function buildUnicodeData(ecmaVersion) { - var d = data[ecmaVersion] = { - binary: wordsRegexp(unicodeBinaryProperties[ecmaVersion] + " " + unicodeGeneralCategoryValues), - binaryOfStrings: wordsRegexp(unicodeBinaryPropertiesOfStrings[ecmaVersion]), - nonBinary: { - General_Category: wordsRegexp(unicodeGeneralCategoryValues), - Script: wordsRegexp(unicodeScriptValues[ecmaVersion]) - } - }; - d.nonBinary.Script_Extensions = d.nonBinary.Script; - - d.nonBinary.gc = d.nonBinary.General_Category; - d.nonBinary.sc = d.nonBinary.Script; - d.nonBinary.scx = d.nonBinary.Script_Extensions; - } - - for (var i = 0, list = [9, 10, 11, 12, 13, 14]; i < list.length; i += 1) { - var ecmaVersion = list[i]; - - buildUnicodeData(ecmaVersion); - } - - var pp$1 = Parser.prototype; - - // Track disjunction structure to determine whether a duplicate - // capture group name is allowed because it is in a separate branch. - var BranchID = function BranchID(parent, base) { - // Parent disjunction branch - this.parent = parent; - // Identifies this set of sibling branches - this.base = base || this; - }; - - BranchID.prototype.separatedFrom = function separatedFrom (alt) { - // A branch is separate from another branch if they or any of - // their parents are siblings in a given disjunction - for (var self = this; self; self = self.parent) { - for (var other = alt; other; other = other.parent) { - if (self.base === other.base && self !== other) { return true } - } - } - return false - }; - - BranchID.prototype.sibling = function sibling () { - return new BranchID(this.parent, this.base) - }; - - var RegExpValidationState = function RegExpValidationState(parser) { - this.parser = parser; - this.validFlags = "gim" + (parser.options.ecmaVersion >= 6 ? "uy" : "") + (parser.options.ecmaVersion >= 9 ? "s" : "") + (parser.options.ecmaVersion >= 13 ? "d" : "") + (parser.options.ecmaVersion >= 15 ? "v" : ""); - this.unicodeProperties = data[parser.options.ecmaVersion >= 14 ? 14 : parser.options.ecmaVersion]; - this.source = ""; - this.flags = ""; - this.start = 0; - this.switchU = false; - this.switchV = false; - this.switchN = false; - this.pos = 0; - this.lastIntValue = 0; - this.lastStringValue = ""; - this.lastAssertionIsQuantifiable = false; - this.numCapturingParens = 0; - this.maxBackReference = 0; - this.groupNames = Object.create(null); - this.backReferenceNames = []; - this.branchID = null; - }; - - RegExpValidationState.prototype.reset = function reset (start, pattern, flags) { - var unicodeSets = flags.indexOf("v") !== -1; - var unicode = flags.indexOf("u") !== -1; - this.start = start | 0; - this.source = pattern + ""; - this.flags = flags; - if (unicodeSets && this.parser.options.ecmaVersion >= 15) { - this.switchU = true; - this.switchV = true; - this.switchN = true; - } else { - this.switchU = unicode && this.parser.options.ecmaVersion >= 6; - this.switchV = false; - this.switchN = unicode && this.parser.options.ecmaVersion >= 9; - } - }; - - RegExpValidationState.prototype.raise = function raise (message) { - this.parser.raiseRecoverable(this.start, ("Invalid regular expression: /" + (this.source) + "/: " + message)); - }; - - // If u flag is given, this returns the code point at the index (it combines a surrogate pair). - // Otherwise, this returns the code unit of the index (can be a part of a surrogate pair). - RegExpValidationState.prototype.at = function at (i, forceU) { - if ( forceU === void 0 ) forceU = false; - - var s = this.source; - var l = s.length; - if (i >= l) { - return -1 - } - var c = s.charCodeAt(i); - if (!(forceU || this.switchU) || c <= 0xD7FF || c >= 0xE000 || i + 1 >= l) { - return c - } - var next = s.charCodeAt(i + 1); - return next >= 0xDC00 && next <= 0xDFFF ? (c << 10) + next - 0x35FDC00 : c - }; - - RegExpValidationState.prototype.nextIndex = function nextIndex (i, forceU) { - if ( forceU === void 0 ) forceU = false; - - var s = this.source; - var l = s.length; - if (i >= l) { - return l - } - var c = s.charCodeAt(i), next; - if (!(forceU || this.switchU) || c <= 0xD7FF || c >= 0xE000 || i + 1 >= l || - (next = s.charCodeAt(i + 1)) < 0xDC00 || next > 0xDFFF) { - return i + 1 - } - return i + 2 - }; - - RegExpValidationState.prototype.current = function current (forceU) { - if ( forceU === void 0 ) forceU = false; - - return this.at(this.pos, forceU) - }; - - RegExpValidationState.prototype.lookahead = function lookahead (forceU) { - if ( forceU === void 0 ) forceU = false; - - return this.at(this.nextIndex(this.pos, forceU), forceU) - }; - - RegExpValidationState.prototype.advance = function advance (forceU) { - if ( forceU === void 0 ) forceU = false; - - this.pos = this.nextIndex(this.pos, forceU); - }; - - RegExpValidationState.prototype.eat = function eat (ch, forceU) { - if ( forceU === void 0 ) forceU = false; - - if (this.current(forceU) === ch) { - this.advance(forceU); - return true - } - return false - }; - - RegExpValidationState.prototype.eatChars = function eatChars (chs, forceU) { - if ( forceU === void 0 ) forceU = false; - - var pos = this.pos; - for (var i = 0, list = chs; i < list.length; i += 1) { - var ch = list[i]; - - var current = this.at(pos, forceU); - if (current === -1 || current !== ch) { - return false - } - pos = this.nextIndex(pos, forceU); - } - this.pos = pos; - return true - }; - - /** - * Validate the flags part of a given RegExpLiteral. - * - * @param {RegExpValidationState} state The state to validate RegExp. - * @returns {void} - */ - pp$1.validateRegExpFlags = function(state) { - var validFlags = state.validFlags; - var flags = state.flags; - - var u = false; - var v = false; - - for (var i = 0; i < flags.length; i++) { - var flag = flags.charAt(i); - if (validFlags.indexOf(flag) === -1) { - this.raise(state.start, "Invalid regular expression flag"); - } - if (flags.indexOf(flag, i + 1) > -1) { - this.raise(state.start, "Duplicate regular expression flag"); - } - if (flag === "u") { u = true; } - if (flag === "v") { v = true; } - } - if (this.options.ecmaVersion >= 15 && u && v) { - this.raise(state.start, "Invalid regular expression flag"); - } - }; - - function hasProp(obj) { - for (var _ in obj) { return true } - return false - } - - /** - * Validate the pattern part of a given RegExpLiteral. - * - * @param {RegExpValidationState} state The state to validate RegExp. - * @returns {void} - */ - pp$1.validateRegExpPattern = function(state) { - this.regexp_pattern(state); - - // The goal symbol for the parse is |Pattern[~U, ~N]|. If the result of - // parsing contains a |GroupName|, reparse with the goal symbol - // |Pattern[~U, +N]| and use this result instead. Throw a *SyntaxError* - // exception if _P_ did not conform to the grammar, if any elements of _P_ - // were not matched by the parse, or if any Early Error conditions exist. - if (!state.switchN && this.options.ecmaVersion >= 9 && hasProp(state.groupNames)) { - state.switchN = true; - this.regexp_pattern(state); - } - }; - - // https://www.ecma-international.org/ecma-262/8.0/#prod-Pattern - pp$1.regexp_pattern = function(state) { - state.pos = 0; - state.lastIntValue = 0; - state.lastStringValue = ""; - state.lastAssertionIsQuantifiable = false; - state.numCapturingParens = 0; - state.maxBackReference = 0; - state.groupNames = Object.create(null); - state.backReferenceNames.length = 0; - state.branchID = null; - - this.regexp_disjunction(state); - - if (state.pos !== state.source.length) { - // Make the same messages as V8. - if (state.eat(0x29 /* ) */)) { - state.raise("Unmatched ')'"); - } - if (state.eat(0x5D /* ] */) || state.eat(0x7D /* } */)) { - state.raise("Lone quantifier brackets"); - } - } - if (state.maxBackReference > state.numCapturingParens) { - state.raise("Invalid escape"); - } - for (var i = 0, list = state.backReferenceNames; i < list.length; i += 1) { - var name = list[i]; - - if (!state.groupNames[name]) { - state.raise("Invalid named capture referenced"); - } - } - }; - - // https://www.ecma-international.org/ecma-262/8.0/#prod-Disjunction - pp$1.regexp_disjunction = function(state) { - var trackDisjunction = this.options.ecmaVersion >= 16; - if (trackDisjunction) { state.branchID = new BranchID(state.branchID, null); } - this.regexp_alternative(state); - while (state.eat(0x7C /* | */)) { - if (trackDisjunction) { state.branchID = state.branchID.sibling(); } - this.regexp_alternative(state); - } - if (trackDisjunction) { state.branchID = state.branchID.parent; } - - // Make the same message as V8. - if (this.regexp_eatQuantifier(state, true)) { - state.raise("Nothing to repeat"); - } - if (state.eat(0x7B /* { */)) { - state.raise("Lone quantifier brackets"); - } - }; - - // https://www.ecma-international.org/ecma-262/8.0/#prod-Alternative - pp$1.regexp_alternative = function(state) { - while (state.pos < state.source.length && this.regexp_eatTerm(state)) {} - }; - - // https://www.ecma-international.org/ecma-262/8.0/#prod-annexB-Term - pp$1.regexp_eatTerm = function(state) { - if (this.regexp_eatAssertion(state)) { - // Handle `QuantifiableAssertion Quantifier` alternative. - // `state.lastAssertionIsQuantifiable` is true if the last eaten Assertion - // is a QuantifiableAssertion. - if (state.lastAssertionIsQuantifiable && this.regexp_eatQuantifier(state)) { - // Make the same message as V8. - if (state.switchU) { - state.raise("Invalid quantifier"); - } - } - return true - } - - if (state.switchU ? this.regexp_eatAtom(state) : this.regexp_eatExtendedAtom(state)) { - this.regexp_eatQuantifier(state); - return true - } - - return false - }; - - // https://www.ecma-international.org/ecma-262/8.0/#prod-annexB-Assertion - pp$1.regexp_eatAssertion = function(state) { - var start = state.pos; - state.lastAssertionIsQuantifiable = false; - - // ^, $ - if (state.eat(0x5E /* ^ */) || state.eat(0x24 /* $ */)) { - return true - } - - // \b \B - if (state.eat(0x5C /* \ */)) { - if (state.eat(0x42 /* B */) || state.eat(0x62 /* b */)) { - return true - } - state.pos = start; - } - - // Lookahead / Lookbehind - if (state.eat(0x28 /* ( */) && state.eat(0x3F /* ? */)) { - var lookbehind = false; - if (this.options.ecmaVersion >= 9) { - lookbehind = state.eat(0x3C /* < */); - } - if (state.eat(0x3D /* = */) || state.eat(0x21 /* ! */)) { - this.regexp_disjunction(state); - if (!state.eat(0x29 /* ) */)) { - state.raise("Unterminated group"); - } - state.lastAssertionIsQuantifiable = !lookbehind; - return true - } - } - - state.pos = start; - return false - }; - - // https://www.ecma-international.org/ecma-262/8.0/#prod-Quantifier - pp$1.regexp_eatQuantifier = function(state, noError) { - if ( noError === void 0 ) noError = false; - - if (this.regexp_eatQuantifierPrefix(state, noError)) { - state.eat(0x3F /* ? */); - return true - } - return false - }; - - // https://www.ecma-international.org/ecma-262/8.0/#prod-QuantifierPrefix - pp$1.regexp_eatQuantifierPrefix = function(state, noError) { - return ( - state.eat(0x2A /* * */) || - state.eat(0x2B /* + */) || - state.eat(0x3F /* ? */) || - this.regexp_eatBracedQuantifier(state, noError) - ) - }; - pp$1.regexp_eatBracedQuantifier = function(state, noError) { - var start = state.pos; - if (state.eat(0x7B /* { */)) { - var min = 0, max = -1; - if (this.regexp_eatDecimalDigits(state)) { - min = state.lastIntValue; - if (state.eat(0x2C /* , */) && this.regexp_eatDecimalDigits(state)) { - max = state.lastIntValue; - } - if (state.eat(0x7D /* } */)) { - // SyntaxError in https://www.ecma-international.org/ecma-262/8.0/#sec-term - if (max !== -1 && max < min && !noError) { - state.raise("numbers out of order in {} quantifier"); - } - return true - } - } - if (state.switchU && !noError) { - state.raise("Incomplete quantifier"); - } - state.pos = start; - } - return false - }; - - // https://www.ecma-international.org/ecma-262/8.0/#prod-Atom - pp$1.regexp_eatAtom = function(state) { - return ( - this.regexp_eatPatternCharacters(state) || - state.eat(0x2E /* . */) || - this.regexp_eatReverseSolidusAtomEscape(state) || - this.regexp_eatCharacterClass(state) || - this.regexp_eatUncapturingGroup(state) || - this.regexp_eatCapturingGroup(state) - ) - }; - pp$1.regexp_eatReverseSolidusAtomEscape = function(state) { - var start = state.pos; - if (state.eat(0x5C /* \ */)) { - if (this.regexp_eatAtomEscape(state)) { - return true - } - state.pos = start; - } - return false - }; - pp$1.regexp_eatUncapturingGroup = function(state) { - var start = state.pos; - if (state.eat(0x28 /* ( */)) { - if (state.eat(0x3F /* ? */) && state.eat(0x3A /* : */)) { - this.regexp_disjunction(state); - if (state.eat(0x29 /* ) */)) { - return true - } - state.raise("Unterminated group"); - } - state.pos = start; - } - return false - }; - pp$1.regexp_eatCapturingGroup = function(state) { - if (state.eat(0x28 /* ( */)) { - if (this.options.ecmaVersion >= 9) { - this.regexp_groupSpecifier(state); - } else if (state.current() === 0x3F /* ? */) { - state.raise("Invalid group"); - } - this.regexp_disjunction(state); - if (state.eat(0x29 /* ) */)) { - state.numCapturingParens += 1; - return true - } - state.raise("Unterminated group"); - } - return false - }; - - // https://www.ecma-international.org/ecma-262/8.0/#prod-annexB-ExtendedAtom - pp$1.regexp_eatExtendedAtom = function(state) { - return ( - state.eat(0x2E /* . */) || - this.regexp_eatReverseSolidusAtomEscape(state) || - this.regexp_eatCharacterClass(state) || - this.regexp_eatUncapturingGroup(state) || - this.regexp_eatCapturingGroup(state) || - this.regexp_eatInvalidBracedQuantifier(state) || - this.regexp_eatExtendedPatternCharacter(state) - ) - }; - - // https://www.ecma-international.org/ecma-262/8.0/#prod-annexB-InvalidBracedQuantifier - pp$1.regexp_eatInvalidBracedQuantifier = function(state) { - if (this.regexp_eatBracedQuantifier(state, true)) { - state.raise("Nothing to repeat"); - } - return false - }; - - // https://www.ecma-international.org/ecma-262/8.0/#prod-SyntaxCharacter - pp$1.regexp_eatSyntaxCharacter = function(state) { - var ch = state.current(); - if (isSyntaxCharacter(ch)) { - state.lastIntValue = ch; - state.advance(); - return true - } - return false - }; - function isSyntaxCharacter(ch) { - return ( - ch === 0x24 /* $ */ || - ch >= 0x28 /* ( */ && ch <= 0x2B /* + */ || - ch === 0x2E /* . */ || - ch === 0x3F /* ? */ || - ch >= 0x5B /* [ */ && ch <= 0x5E /* ^ */ || - ch >= 0x7B /* { */ && ch <= 0x7D /* } */ - ) - } - - // https://www.ecma-international.org/ecma-262/8.0/#prod-PatternCharacter - // But eat eager. - pp$1.regexp_eatPatternCharacters = function(state) { - var start = state.pos; - var ch = 0; - while ((ch = state.current()) !== -1 && !isSyntaxCharacter(ch)) { - state.advance(); - } - return state.pos !== start - }; - - // https://www.ecma-international.org/ecma-262/8.0/#prod-annexB-ExtendedPatternCharacter - pp$1.regexp_eatExtendedPatternCharacter = function(state) { - var ch = state.current(); - if ( - ch !== -1 && - ch !== 0x24 /* $ */ && - !(ch >= 0x28 /* ( */ && ch <= 0x2B /* + */) && - ch !== 0x2E /* . */ && - ch !== 0x3F /* ? */ && - ch !== 0x5B /* [ */ && - ch !== 0x5E /* ^ */ && - ch !== 0x7C /* | */ - ) { - state.advance(); - return true - } - return false - }; - - // GroupSpecifier :: - // [empty] - // `?` GroupName - pp$1.regexp_groupSpecifier = function(state) { - if (state.eat(0x3F /* ? */)) { - if (!this.regexp_eatGroupName(state)) { state.raise("Invalid group"); } - var trackDisjunction = this.options.ecmaVersion >= 16; - var known = state.groupNames[state.lastStringValue]; - if (known) { - if (trackDisjunction) { - for (var i = 0, list = known; i < list.length; i += 1) { - var altID = list[i]; - - if (!altID.separatedFrom(state.branchID)) - { state.raise("Duplicate capture group name"); } - } - } else { - state.raise("Duplicate capture group name"); - } - } - if (trackDisjunction) { - (known || (state.groupNames[state.lastStringValue] = [])).push(state.branchID); - } else { - state.groupNames[state.lastStringValue] = true; - } - } - }; - - // GroupName :: - // `<` RegExpIdentifierName `>` - // Note: this updates `state.lastStringValue` property with the eaten name. - pp$1.regexp_eatGroupName = function(state) { - state.lastStringValue = ""; - if (state.eat(0x3C /* < */)) { - if (this.regexp_eatRegExpIdentifierName(state) && state.eat(0x3E /* > */)) { - return true - } - state.raise("Invalid capture group name"); - } - return false - }; - - // RegExpIdentifierName :: - // RegExpIdentifierStart - // RegExpIdentifierName RegExpIdentifierPart - // Note: this updates `state.lastStringValue` property with the eaten name. - pp$1.regexp_eatRegExpIdentifierName = function(state) { - state.lastStringValue = ""; - if (this.regexp_eatRegExpIdentifierStart(state)) { - state.lastStringValue += codePointToString(state.lastIntValue); - while (this.regexp_eatRegExpIdentifierPart(state)) { - state.lastStringValue += codePointToString(state.lastIntValue); - } - return true - } - return false - }; - - // RegExpIdentifierStart :: - // UnicodeIDStart - // `$` - // `_` - // `\` RegExpUnicodeEscapeSequence[+U] - pp$1.regexp_eatRegExpIdentifierStart = function(state) { - var start = state.pos; - var forceU = this.options.ecmaVersion >= 11; - var ch = state.current(forceU); - state.advance(forceU); - - if (ch === 0x5C /* \ */ && this.regexp_eatRegExpUnicodeEscapeSequence(state, forceU)) { - ch = state.lastIntValue; - } - if (isRegExpIdentifierStart(ch)) { - state.lastIntValue = ch; - return true - } - - state.pos = start; - return false - }; - function isRegExpIdentifierStart(ch) { - return isIdentifierStart(ch, true) || ch === 0x24 /* $ */ || ch === 0x5F /* _ */ - } - - // RegExpIdentifierPart :: - // UnicodeIDContinue - // `$` - // `_` - // `\` RegExpUnicodeEscapeSequence[+U] - // - // - pp$1.regexp_eatRegExpIdentifierPart = function(state) { - var start = state.pos; - var forceU = this.options.ecmaVersion >= 11; - var ch = state.current(forceU); - state.advance(forceU); - - if (ch === 0x5C /* \ */ && this.regexp_eatRegExpUnicodeEscapeSequence(state, forceU)) { - ch = state.lastIntValue; - } - if (isRegExpIdentifierPart(ch)) { - state.lastIntValue = ch; - return true - } - - state.pos = start; - return false - }; - function isRegExpIdentifierPart(ch) { - return isIdentifierChar(ch, true) || ch === 0x24 /* $ */ || ch === 0x5F /* _ */ || ch === 0x200C /* */ || ch === 0x200D /* */ - } - - // https://www.ecma-international.org/ecma-262/8.0/#prod-annexB-AtomEscape - pp$1.regexp_eatAtomEscape = function(state) { - if ( - this.regexp_eatBackReference(state) || - this.regexp_eatCharacterClassEscape(state) || - this.regexp_eatCharacterEscape(state) || - (state.switchN && this.regexp_eatKGroupName(state)) - ) { - return true - } - if (state.switchU) { - // Make the same message as V8. - if (state.current() === 0x63 /* c */) { - state.raise("Invalid unicode escape"); - } - state.raise("Invalid escape"); - } - return false - }; - pp$1.regexp_eatBackReference = function(state) { - var start = state.pos; - if (this.regexp_eatDecimalEscape(state)) { - var n = state.lastIntValue; - if (state.switchU) { - // For SyntaxError in https://www.ecma-international.org/ecma-262/8.0/#sec-atomescape - if (n > state.maxBackReference) { - state.maxBackReference = n; - } - return true - } - if (n <= state.numCapturingParens) { - return true - } - state.pos = start; - } - return false - }; - pp$1.regexp_eatKGroupName = function(state) { - if (state.eat(0x6B /* k */)) { - if (this.regexp_eatGroupName(state)) { - state.backReferenceNames.push(state.lastStringValue); - return true - } - state.raise("Invalid named reference"); - } - return false - }; - - // https://www.ecma-international.org/ecma-262/8.0/#prod-annexB-CharacterEscape - pp$1.regexp_eatCharacterEscape = function(state) { - return ( - this.regexp_eatControlEscape(state) || - this.regexp_eatCControlLetter(state) || - this.regexp_eatZero(state) || - this.regexp_eatHexEscapeSequence(state) || - this.regexp_eatRegExpUnicodeEscapeSequence(state, false) || - (!state.switchU && this.regexp_eatLegacyOctalEscapeSequence(state)) || - this.regexp_eatIdentityEscape(state) - ) - }; - pp$1.regexp_eatCControlLetter = function(state) { - var start = state.pos; - if (state.eat(0x63 /* c */)) { - if (this.regexp_eatControlLetter(state)) { - return true - } - state.pos = start; - } - return false - }; - pp$1.regexp_eatZero = function(state) { - if (state.current() === 0x30 /* 0 */ && !isDecimalDigit(state.lookahead())) { - state.lastIntValue = 0; - state.advance(); - return true - } - return false - }; - - // https://www.ecma-international.org/ecma-262/8.0/#prod-ControlEscape - pp$1.regexp_eatControlEscape = function(state) { - var ch = state.current(); - if (ch === 0x74 /* t */) { - state.lastIntValue = 0x09; /* \t */ - state.advance(); - return true - } - if (ch === 0x6E /* n */) { - state.lastIntValue = 0x0A; /* \n */ - state.advance(); - return true - } - if (ch === 0x76 /* v */) { - state.lastIntValue = 0x0B; /* \v */ - state.advance(); - return true - } - if (ch === 0x66 /* f */) { - state.lastIntValue = 0x0C; /* \f */ - state.advance(); - return true - } - if (ch === 0x72 /* r */) { - state.lastIntValue = 0x0D; /* \r */ - state.advance(); - return true - } - return false - }; - - // https://www.ecma-international.org/ecma-262/8.0/#prod-ControlLetter - pp$1.regexp_eatControlLetter = function(state) { - var ch = state.current(); - if (isControlLetter(ch)) { - state.lastIntValue = ch % 0x20; - state.advance(); - return true - } - return false - }; - function isControlLetter(ch) { - return ( - (ch >= 0x41 /* A */ && ch <= 0x5A /* Z */) || - (ch >= 0x61 /* a */ && ch <= 0x7A /* z */) - ) - } - - // https://www.ecma-international.org/ecma-262/8.0/#prod-RegExpUnicodeEscapeSequence - pp$1.regexp_eatRegExpUnicodeEscapeSequence = function(state, forceU) { - if ( forceU === void 0 ) forceU = false; - - var start = state.pos; - var switchU = forceU || state.switchU; - - if (state.eat(0x75 /* u */)) { - if (this.regexp_eatFixedHexDigits(state, 4)) { - var lead = state.lastIntValue; - if (switchU && lead >= 0xD800 && lead <= 0xDBFF) { - var leadSurrogateEnd = state.pos; - if (state.eat(0x5C /* \ */) && state.eat(0x75 /* u */) && this.regexp_eatFixedHexDigits(state, 4)) { - var trail = state.lastIntValue; - if (trail >= 0xDC00 && trail <= 0xDFFF) { - state.lastIntValue = (lead - 0xD800) * 0x400 + (trail - 0xDC00) + 0x10000; - return true - } - } - state.pos = leadSurrogateEnd; - state.lastIntValue = lead; - } - return true - } - if ( - switchU && - state.eat(0x7B /* { */) && - this.regexp_eatHexDigits(state) && - state.eat(0x7D /* } */) && - isValidUnicode(state.lastIntValue) - ) { - return true - } - if (switchU) { - state.raise("Invalid unicode escape"); - } - state.pos = start; - } - - return false - }; - function isValidUnicode(ch) { - return ch >= 0 && ch <= 0x10FFFF - } - - // https://www.ecma-international.org/ecma-262/8.0/#prod-annexB-IdentityEscape - pp$1.regexp_eatIdentityEscape = function(state) { - if (state.switchU) { - if (this.regexp_eatSyntaxCharacter(state)) { - return true - } - if (state.eat(0x2F /* / */)) { - state.lastIntValue = 0x2F; /* / */ - return true - } - return false - } - - var ch = state.current(); - if (ch !== 0x63 /* c */ && (!state.switchN || ch !== 0x6B /* k */)) { - state.lastIntValue = ch; - state.advance(); - return true - } - - return false - }; - - // https://www.ecma-international.org/ecma-262/8.0/#prod-DecimalEscape - pp$1.regexp_eatDecimalEscape = function(state) { - state.lastIntValue = 0; - var ch = state.current(); - if (ch >= 0x31 /* 1 */ && ch <= 0x39 /* 9 */) { - do { - state.lastIntValue = 10 * state.lastIntValue + (ch - 0x30 /* 0 */); - state.advance(); - } while ((ch = state.current()) >= 0x30 /* 0 */ && ch <= 0x39 /* 9 */) - return true - } - return false - }; - - // Return values used by character set parsing methods, needed to - // forbid negation of sets that can match strings. - var CharSetNone = 0; // Nothing parsed - var CharSetOk = 1; // Construct parsed, cannot contain strings - var CharSetString = 2; // Construct parsed, can contain strings - - // https://www.ecma-international.org/ecma-262/8.0/#prod-CharacterClassEscape - pp$1.regexp_eatCharacterClassEscape = function(state) { - var ch = state.current(); - - if (isCharacterClassEscape(ch)) { - state.lastIntValue = -1; - state.advance(); - return CharSetOk - } - - var negate = false; - if ( - state.switchU && - this.options.ecmaVersion >= 9 && - ((negate = ch === 0x50 /* P */) || ch === 0x70 /* p */) - ) { - state.lastIntValue = -1; - state.advance(); - var result; - if ( - state.eat(0x7B /* { */) && - (result = this.regexp_eatUnicodePropertyValueExpression(state)) && - state.eat(0x7D /* } */) - ) { - if (negate && result === CharSetString) { state.raise("Invalid property name"); } - return result - } - state.raise("Invalid property name"); - } - - return CharSetNone - }; - - function isCharacterClassEscape(ch) { - return ( - ch === 0x64 /* d */ || - ch === 0x44 /* D */ || - ch === 0x73 /* s */ || - ch === 0x53 /* S */ || - ch === 0x77 /* w */ || - ch === 0x57 /* W */ - ) - } - - // UnicodePropertyValueExpression :: - // UnicodePropertyName `=` UnicodePropertyValue - // LoneUnicodePropertyNameOrValue - pp$1.regexp_eatUnicodePropertyValueExpression = function(state) { - var start = state.pos; - - // UnicodePropertyName `=` UnicodePropertyValue - if (this.regexp_eatUnicodePropertyName(state) && state.eat(0x3D /* = */)) { - var name = state.lastStringValue; - if (this.regexp_eatUnicodePropertyValue(state)) { - var value = state.lastStringValue; - this.regexp_validateUnicodePropertyNameAndValue(state, name, value); - return CharSetOk - } - } - state.pos = start; - - // LoneUnicodePropertyNameOrValue - if (this.regexp_eatLoneUnicodePropertyNameOrValue(state)) { - var nameOrValue = state.lastStringValue; - return this.regexp_validateUnicodePropertyNameOrValue(state, nameOrValue) - } - return CharSetNone - }; - - pp$1.regexp_validateUnicodePropertyNameAndValue = function(state, name, value) { - if (!hasOwn(state.unicodeProperties.nonBinary, name)) - { state.raise("Invalid property name"); } - if (!state.unicodeProperties.nonBinary[name].test(value)) - { state.raise("Invalid property value"); } - }; - - pp$1.regexp_validateUnicodePropertyNameOrValue = function(state, nameOrValue) { - if (state.unicodeProperties.binary.test(nameOrValue)) { return CharSetOk } - if (state.switchV && state.unicodeProperties.binaryOfStrings.test(nameOrValue)) { return CharSetString } - state.raise("Invalid property name"); - }; - - // UnicodePropertyName :: - // UnicodePropertyNameCharacters - pp$1.regexp_eatUnicodePropertyName = function(state) { - var ch = 0; - state.lastStringValue = ""; - while (isUnicodePropertyNameCharacter(ch = state.current())) { - state.lastStringValue += codePointToString(ch); - state.advance(); - } - return state.lastStringValue !== "" - }; - - function isUnicodePropertyNameCharacter(ch) { - return isControlLetter(ch) || ch === 0x5F /* _ */ - } - - // UnicodePropertyValue :: - // UnicodePropertyValueCharacters - pp$1.regexp_eatUnicodePropertyValue = function(state) { - var ch = 0; - state.lastStringValue = ""; - while (isUnicodePropertyValueCharacter(ch = state.current())) { - state.lastStringValue += codePointToString(ch); - state.advance(); - } - return state.lastStringValue !== "" - }; - function isUnicodePropertyValueCharacter(ch) { - return isUnicodePropertyNameCharacter(ch) || isDecimalDigit(ch) - } - - // LoneUnicodePropertyNameOrValue :: - // UnicodePropertyValueCharacters - pp$1.regexp_eatLoneUnicodePropertyNameOrValue = function(state) { - return this.regexp_eatUnicodePropertyValue(state) - }; - - // https://www.ecma-international.org/ecma-262/8.0/#prod-CharacterClass - pp$1.regexp_eatCharacterClass = function(state) { - if (state.eat(0x5B /* [ */)) { - var negate = state.eat(0x5E /* ^ */); - var result = this.regexp_classContents(state); - if (!state.eat(0x5D /* ] */)) - { state.raise("Unterminated character class"); } - if (negate && result === CharSetString) - { state.raise("Negated character class may contain strings"); } - return true - } - return false - }; - - // https://tc39.es/ecma262/#prod-ClassContents - // https://www.ecma-international.org/ecma-262/8.0/#prod-ClassRanges - pp$1.regexp_classContents = function(state) { - if (state.current() === 0x5D /* ] */) { return CharSetOk } - if (state.switchV) { return this.regexp_classSetExpression(state) } - this.regexp_nonEmptyClassRanges(state); - return CharSetOk - }; - - // https://www.ecma-international.org/ecma-262/8.0/#prod-NonemptyClassRanges - // https://www.ecma-international.org/ecma-262/8.0/#prod-NonemptyClassRangesNoDash - pp$1.regexp_nonEmptyClassRanges = function(state) { - while (this.regexp_eatClassAtom(state)) { - var left = state.lastIntValue; - if (state.eat(0x2D /* - */) && this.regexp_eatClassAtom(state)) { - var right = state.lastIntValue; - if (state.switchU && (left === -1 || right === -1)) { - state.raise("Invalid character class"); - } - if (left !== -1 && right !== -1 && left > right) { - state.raise("Range out of order in character class"); - } - } - } - }; - - // https://www.ecma-international.org/ecma-262/8.0/#prod-ClassAtom - // https://www.ecma-international.org/ecma-262/8.0/#prod-ClassAtomNoDash - pp$1.regexp_eatClassAtom = function(state) { - var start = state.pos; - - if (state.eat(0x5C /* \ */)) { - if (this.regexp_eatClassEscape(state)) { - return true - } - if (state.switchU) { - // Make the same message as V8. - var ch$1 = state.current(); - if (ch$1 === 0x63 /* c */ || isOctalDigit(ch$1)) { - state.raise("Invalid class escape"); - } - state.raise("Invalid escape"); - } - state.pos = start; - } - - var ch = state.current(); - if (ch !== 0x5D /* ] */) { - state.lastIntValue = ch; - state.advance(); - return true - } - - return false - }; - - // https://www.ecma-international.org/ecma-262/8.0/#prod-annexB-ClassEscape - pp$1.regexp_eatClassEscape = function(state) { - var start = state.pos; - - if (state.eat(0x62 /* b */)) { - state.lastIntValue = 0x08; /* */ - return true - } - - if (state.switchU && state.eat(0x2D /* - */)) { - state.lastIntValue = 0x2D; /* - */ - return true - } - - if (!state.switchU && state.eat(0x63 /* c */)) { - if (this.regexp_eatClassControlLetter(state)) { - return true - } - state.pos = start; - } - - return ( - this.regexp_eatCharacterClassEscape(state) || - this.regexp_eatCharacterEscape(state) - ) - }; - - // https://tc39.es/ecma262/#prod-ClassSetExpression - // https://tc39.es/ecma262/#prod-ClassUnion - // https://tc39.es/ecma262/#prod-ClassIntersection - // https://tc39.es/ecma262/#prod-ClassSubtraction - pp$1.regexp_classSetExpression = function(state) { - var result = CharSetOk, subResult; - if (this.regexp_eatClassSetRange(state)) ; else if (subResult = this.regexp_eatClassSetOperand(state)) { - if (subResult === CharSetString) { result = CharSetString; } - // https://tc39.es/ecma262/#prod-ClassIntersection - var start = state.pos; - while (state.eatChars([0x26, 0x26] /* && */)) { - if ( - state.current() !== 0x26 /* & */ && - (subResult = this.regexp_eatClassSetOperand(state)) - ) { - if (subResult !== CharSetString) { result = CharSetOk; } - continue - } - state.raise("Invalid character in character class"); - } - if (start !== state.pos) { return result } - // https://tc39.es/ecma262/#prod-ClassSubtraction - while (state.eatChars([0x2D, 0x2D] /* -- */)) { - if (this.regexp_eatClassSetOperand(state)) { continue } - state.raise("Invalid character in character class"); - } - if (start !== state.pos) { return result } - } else { - state.raise("Invalid character in character class"); - } - // https://tc39.es/ecma262/#prod-ClassUnion - for (;;) { - if (this.regexp_eatClassSetRange(state)) { continue } - subResult = this.regexp_eatClassSetOperand(state); - if (!subResult) { return result } - if (subResult === CharSetString) { result = CharSetString; } - } - }; - - // https://tc39.es/ecma262/#prod-ClassSetRange - pp$1.regexp_eatClassSetRange = function(state) { - var start = state.pos; - if (this.regexp_eatClassSetCharacter(state)) { - var left = state.lastIntValue; - if (state.eat(0x2D /* - */) && this.regexp_eatClassSetCharacter(state)) { - var right = state.lastIntValue; - if (left !== -1 && right !== -1 && left > right) { - state.raise("Range out of order in character class"); - } - return true - } - state.pos = start; - } - return false - }; - - // https://tc39.es/ecma262/#prod-ClassSetOperand - pp$1.regexp_eatClassSetOperand = function(state) { - if (this.regexp_eatClassSetCharacter(state)) { return CharSetOk } - return this.regexp_eatClassStringDisjunction(state) || this.regexp_eatNestedClass(state) - }; - - // https://tc39.es/ecma262/#prod-NestedClass - pp$1.regexp_eatNestedClass = function(state) { - var start = state.pos; - if (state.eat(0x5B /* [ */)) { - var negate = state.eat(0x5E /* ^ */); - var result = this.regexp_classContents(state); - if (state.eat(0x5D /* ] */)) { - if (negate && result === CharSetString) { - state.raise("Negated character class may contain strings"); - } - return result - } - state.pos = start; - } - if (state.eat(0x5C /* \ */)) { - var result$1 = this.regexp_eatCharacterClassEscape(state); - if (result$1) { - return result$1 - } - state.pos = start; - } - return null - }; - - // https://tc39.es/ecma262/#prod-ClassStringDisjunction - pp$1.regexp_eatClassStringDisjunction = function(state) { - var start = state.pos; - if (state.eatChars([0x5C, 0x71] /* \q */)) { - if (state.eat(0x7B /* { */)) { - var result = this.regexp_classStringDisjunctionContents(state); - if (state.eat(0x7D /* } */)) { - return result - } - } else { - // Make the same message as V8. - state.raise("Invalid escape"); - } - state.pos = start; - } - return null - }; - - // https://tc39.es/ecma262/#prod-ClassStringDisjunctionContents - pp$1.regexp_classStringDisjunctionContents = function(state) { - var result = this.regexp_classString(state); - while (state.eat(0x7C /* | */)) { - if (this.regexp_classString(state) === CharSetString) { result = CharSetString; } - } - return result - }; - - // https://tc39.es/ecma262/#prod-ClassString - // https://tc39.es/ecma262/#prod-NonEmptyClassString - pp$1.regexp_classString = function(state) { - var count = 0; - while (this.regexp_eatClassSetCharacter(state)) { count++; } - return count === 1 ? CharSetOk : CharSetString - }; - - // https://tc39.es/ecma262/#prod-ClassSetCharacter - pp$1.regexp_eatClassSetCharacter = function(state) { - var start = state.pos; - if (state.eat(0x5C /* \ */)) { - if ( - this.regexp_eatCharacterEscape(state) || - this.regexp_eatClassSetReservedPunctuator(state) - ) { - return true - } - if (state.eat(0x62 /* b */)) { - state.lastIntValue = 0x08; /* */ - return true - } - state.pos = start; - return false - } - var ch = state.current(); - if (ch < 0 || ch === state.lookahead() && isClassSetReservedDoublePunctuatorCharacter(ch)) { return false } - if (isClassSetSyntaxCharacter(ch)) { return false } - state.advance(); - state.lastIntValue = ch; - return true - }; - - // https://tc39.es/ecma262/#prod-ClassSetReservedDoublePunctuator - function isClassSetReservedDoublePunctuatorCharacter(ch) { - return ( - ch === 0x21 /* ! */ || - ch >= 0x23 /* # */ && ch <= 0x26 /* & */ || - ch >= 0x2A /* * */ && ch <= 0x2C /* , */ || - ch === 0x2E /* . */ || - ch >= 0x3A /* : */ && ch <= 0x40 /* @ */ || - ch === 0x5E /* ^ */ || - ch === 0x60 /* ` */ || - ch === 0x7E /* ~ */ - ) - } - - // https://tc39.es/ecma262/#prod-ClassSetSyntaxCharacter - function isClassSetSyntaxCharacter(ch) { - return ( - ch === 0x28 /* ( */ || - ch === 0x29 /* ) */ || - ch === 0x2D /* - */ || - ch === 0x2F /* / */ || - ch >= 0x5B /* [ */ && ch <= 0x5D /* ] */ || - ch >= 0x7B /* { */ && ch <= 0x7D /* } */ - ) - } - - // https://tc39.es/ecma262/#prod-ClassSetReservedPunctuator - pp$1.regexp_eatClassSetReservedPunctuator = function(state) { - var ch = state.current(); - if (isClassSetReservedPunctuator(ch)) { - state.lastIntValue = ch; - state.advance(); - return true - } - return false - }; - - // https://tc39.es/ecma262/#prod-ClassSetReservedPunctuator - function isClassSetReservedPunctuator(ch) { - return ( - ch === 0x21 /* ! */ || - ch === 0x23 /* # */ || - ch === 0x25 /* % */ || - ch === 0x26 /* & */ || - ch === 0x2C /* , */ || - ch === 0x2D /* - */ || - ch >= 0x3A /* : */ && ch <= 0x3E /* > */ || - ch === 0x40 /* @ */ || - ch === 0x60 /* ` */ || - ch === 0x7E /* ~ */ - ) - } - - // https://www.ecma-international.org/ecma-262/8.0/#prod-annexB-ClassControlLetter - pp$1.regexp_eatClassControlLetter = function(state) { - var ch = state.current(); - if (isDecimalDigit(ch) || ch === 0x5F /* _ */) { - state.lastIntValue = ch % 0x20; - state.advance(); - return true - } - return false - }; - - // https://www.ecma-international.org/ecma-262/8.0/#prod-HexEscapeSequence - pp$1.regexp_eatHexEscapeSequence = function(state) { - var start = state.pos; - if (state.eat(0x78 /* x */)) { - if (this.regexp_eatFixedHexDigits(state, 2)) { - return true - } - if (state.switchU) { - state.raise("Invalid escape"); - } - state.pos = start; - } - return false - }; - - // https://www.ecma-international.org/ecma-262/8.0/#prod-DecimalDigits - pp$1.regexp_eatDecimalDigits = function(state) { - var start = state.pos; - var ch = 0; - state.lastIntValue = 0; - while (isDecimalDigit(ch = state.current())) { - state.lastIntValue = 10 * state.lastIntValue + (ch - 0x30 /* 0 */); - state.advance(); - } - return state.pos !== start - }; - function isDecimalDigit(ch) { - return ch >= 0x30 /* 0 */ && ch <= 0x39 /* 9 */ - } - - // https://www.ecma-international.org/ecma-262/8.0/#prod-HexDigits - pp$1.regexp_eatHexDigits = function(state) { - var start = state.pos; - var ch = 0; - state.lastIntValue = 0; - while (isHexDigit(ch = state.current())) { - state.lastIntValue = 16 * state.lastIntValue + hexToInt(ch); - state.advance(); - } - return state.pos !== start - }; - function isHexDigit(ch) { - return ( - (ch >= 0x30 /* 0 */ && ch <= 0x39 /* 9 */) || - (ch >= 0x41 /* A */ && ch <= 0x46 /* F */) || - (ch >= 0x61 /* a */ && ch <= 0x66 /* f */) - ) - } - function hexToInt(ch) { - if (ch >= 0x41 /* A */ && ch <= 0x46 /* F */) { - return 10 + (ch - 0x41 /* A */) - } - if (ch >= 0x61 /* a */ && ch <= 0x66 /* f */) { - return 10 + (ch - 0x61 /* a */) - } - return ch - 0x30 /* 0 */ - } - - // https://www.ecma-international.org/ecma-262/8.0/#prod-annexB-LegacyOctalEscapeSequence - // Allows only 0-377(octal) i.e. 0-255(decimal). - pp$1.regexp_eatLegacyOctalEscapeSequence = function(state) { - if (this.regexp_eatOctalDigit(state)) { - var n1 = state.lastIntValue; - if (this.regexp_eatOctalDigit(state)) { - var n2 = state.lastIntValue; - if (n1 <= 3 && this.regexp_eatOctalDigit(state)) { - state.lastIntValue = n1 * 64 + n2 * 8 + state.lastIntValue; - } else { - state.lastIntValue = n1 * 8 + n2; - } - } else { - state.lastIntValue = n1; - } - return true - } - return false - }; - - // https://www.ecma-international.org/ecma-262/8.0/#prod-OctalDigit - pp$1.regexp_eatOctalDigit = function(state) { - var ch = state.current(); - if (isOctalDigit(ch)) { - state.lastIntValue = ch - 0x30; /* 0 */ - state.advance(); - return true - } - state.lastIntValue = 0; - return false - }; - function isOctalDigit(ch) { - return ch >= 0x30 /* 0 */ && ch <= 0x37 /* 7 */ - } - - // https://www.ecma-international.org/ecma-262/8.0/#prod-Hex4Digits - // https://www.ecma-international.org/ecma-262/8.0/#prod-HexDigit - // And HexDigit HexDigit in https://www.ecma-international.org/ecma-262/8.0/#prod-HexEscapeSequence - pp$1.regexp_eatFixedHexDigits = function(state, length) { - var start = state.pos; - state.lastIntValue = 0; - for (var i = 0; i < length; ++i) { - var ch = state.current(); - if (!isHexDigit(ch)) { - state.pos = start; - return false - } - state.lastIntValue = 16 * state.lastIntValue + hexToInt(ch); - state.advance(); - } - return true - }; - - // Object type used to represent tokens. Note that normally, tokens - // simply exist as properties on the parser object. This is only - // used for the onToken callback and the external tokenizer. - - var Token = function Token(p) { - this.type = p.type; - this.value = p.value; - this.start = p.start; - this.end = p.end; - if (p.options.locations) - { this.loc = new SourceLocation(p, p.startLoc, p.endLoc); } - if (p.options.ranges) - { this.range = [p.start, p.end]; } - }; - - // ## Tokenizer - - var pp = Parser.prototype; - - // Move to the next token - - pp.next = function(ignoreEscapeSequenceInKeyword) { - if (!ignoreEscapeSequenceInKeyword && this.type.keyword && this.containsEsc) - { this.raiseRecoverable(this.start, "Escape sequence in keyword " + this.type.keyword); } - if (this.options.onToken) - { this.options.onToken(new Token(this)); } - - this.lastTokEnd = this.end; - this.lastTokStart = this.start; - this.lastTokEndLoc = this.endLoc; - this.lastTokStartLoc = this.startLoc; - this.nextToken(); - }; - - pp.getToken = function() { - this.next(); - return new Token(this) - }; - - // If we're in an ES6 environment, make parsers iterable - if (typeof Symbol !== "undefined") - { pp[Symbol.iterator] = function() { - var this$1$1 = this; - - return { - next: function () { - var token = this$1$1.getToken(); - return { - done: token.type === types$1.eof, - value: token - } - } - } - }; } - - // Toggle strict mode. Re-reads the next number or string to please - // pedantic tests (`"use strict"; 010;` should fail). - - // Read a single token, updating the parser object's token-related - // properties. - - pp.nextToken = function() { - var curContext = this.curContext(); - if (!curContext || !curContext.preserveSpace) { this.skipSpace(); } - - this.start = this.pos; - if (this.options.locations) { this.startLoc = this.curPosition(); } - if (this.pos >= this.input.length) { return this.finishToken(types$1.eof) } - - if (curContext.override) { return curContext.override(this) } - else { this.readToken(this.fullCharCodeAtPos()); } - }; - - pp.readToken = function(code) { - // Identifier or keyword. '\uXXXX' sequences are allowed in - // identifiers, so '\' also dispatches to that. - if (isIdentifierStart(code, this.options.ecmaVersion >= 6) || code === 92 /* '\' */) - { return this.readWord() } - - return this.getTokenFromCode(code) - }; - - pp.fullCharCodeAtPos = function() { - var code = this.input.charCodeAt(this.pos); - if (code <= 0xd7ff || code >= 0xdc00) { return code } - var next = this.input.charCodeAt(this.pos + 1); - return next <= 0xdbff || next >= 0xe000 ? code : (code << 10) + next - 0x35fdc00 - }; - - pp.skipBlockComment = function() { - var startLoc = this.options.onComment && this.curPosition(); - var start = this.pos, end = this.input.indexOf("*/", this.pos += 2); - if (end === -1) { this.raise(this.pos - 2, "Unterminated comment"); } - this.pos = end + 2; - if (this.options.locations) { - for (var nextBreak = (void 0), pos = start; (nextBreak = nextLineBreak(this.input, pos, this.pos)) > -1;) { - ++this.curLine; - pos = this.lineStart = nextBreak; - } - } - if (this.options.onComment) - { this.options.onComment(true, this.input.slice(start + 2, end), start, this.pos, - startLoc, this.curPosition()); } - }; - - pp.skipLineComment = function(startSkip) { - var start = this.pos; - var startLoc = this.options.onComment && this.curPosition(); - var ch = this.input.charCodeAt(this.pos += startSkip); - while (this.pos < this.input.length && !isNewLine(ch)) { - ch = this.input.charCodeAt(++this.pos); - } - if (this.options.onComment) - { this.options.onComment(false, this.input.slice(start + startSkip, this.pos), start, this.pos, - startLoc, this.curPosition()); } - }; - - // Called at the start of the parse and after every token. Skips - // whitespace and comments, and. - - pp.skipSpace = function() { - loop: while (this.pos < this.input.length) { - var ch = this.input.charCodeAt(this.pos); - switch (ch) { - case 32: case 160: // ' ' - ++this.pos; - break - case 13: - if (this.input.charCodeAt(this.pos + 1) === 10) { - ++this.pos; - } - case 10: case 8232: case 8233: - ++this.pos; - if (this.options.locations) { - ++this.curLine; - this.lineStart = this.pos; - } - break - case 47: // '/' - switch (this.input.charCodeAt(this.pos + 1)) { - case 42: // '*' - this.skipBlockComment(); - break - case 47: - this.skipLineComment(2); - break - default: - break loop - } - break - default: - if (ch > 8 && ch < 14 || ch >= 5760 && nonASCIIwhitespace.test(String.fromCharCode(ch))) { - ++this.pos; - } else { - break loop - } - } - } - }; - - // Called at the end of every token. Sets `end`, `val`, and - // maintains `context` and `exprAllowed`, and skips the space after - // the token, so that the next one's `start` will point at the - // right position. - - pp.finishToken = function(type, val) { - this.end = this.pos; - if (this.options.locations) { this.endLoc = this.curPosition(); } - var prevType = this.type; - this.type = type; - this.value = val; - - this.updateContext(prevType); - }; - - // ### Token reading - - // This is the function that is called to fetch the next token. It - // is somewhat obscure, because it works in character codes rather - // than characters, and because operator parsing has been inlined - // into it. - // - // All in the name of speed. - // - pp.readToken_dot = function() { - var next = this.input.charCodeAt(this.pos + 1); - if (next >= 48 && next <= 57) { return this.readNumber(true) } - var next2 = this.input.charCodeAt(this.pos + 2); - if (this.options.ecmaVersion >= 6 && next === 46 && next2 === 46) { // 46 = dot '.' - this.pos += 3; - return this.finishToken(types$1.ellipsis) - } else { - ++this.pos; - return this.finishToken(types$1.dot) - } - }; - - pp.readToken_slash = function() { // '/' - var next = this.input.charCodeAt(this.pos + 1); - if (this.exprAllowed) { ++this.pos; return this.readRegexp() } - if (next === 61) { return this.finishOp(types$1.assign, 2) } - return this.finishOp(types$1.slash, 1) - }; - - pp.readToken_mult_modulo_exp = function(code) { // '%*' - var next = this.input.charCodeAt(this.pos + 1); - var size = 1; - var tokentype = code === 42 ? types$1.star : types$1.modulo; - - // exponentiation operator ** and **= - if (this.options.ecmaVersion >= 7 && code === 42 && next === 42) { - ++size; - tokentype = types$1.starstar; - next = this.input.charCodeAt(this.pos + 2); - } - - if (next === 61) { return this.finishOp(types$1.assign, size + 1) } - return this.finishOp(tokentype, size) - }; - - pp.readToken_pipe_amp = function(code) { // '|&' - var next = this.input.charCodeAt(this.pos + 1); - if (next === code) { - if (this.options.ecmaVersion >= 12) { - var next2 = this.input.charCodeAt(this.pos + 2); - if (next2 === 61) { return this.finishOp(types$1.assign, 3) } - } - return this.finishOp(code === 124 ? types$1.logicalOR : types$1.logicalAND, 2) - } - if (next === 61) { return this.finishOp(types$1.assign, 2) } - return this.finishOp(code === 124 ? types$1.bitwiseOR : types$1.bitwiseAND, 1) - }; - - pp.readToken_caret = function() { // '^' - var next = this.input.charCodeAt(this.pos + 1); - if (next === 61) { return this.finishOp(types$1.assign, 2) } - return this.finishOp(types$1.bitwiseXOR, 1) - }; - - pp.readToken_plus_min = function(code) { // '+-' - var next = this.input.charCodeAt(this.pos + 1); - if (next === code) { - if (next === 45 && !this.inModule && this.input.charCodeAt(this.pos + 2) === 62 && - (this.lastTokEnd === 0 || lineBreak.test(this.input.slice(this.lastTokEnd, this.pos)))) { - // A `-->` line comment - this.skipLineComment(3); - this.skipSpace(); - return this.nextToken() - } - return this.finishOp(types$1.incDec, 2) - } - if (next === 61) { return this.finishOp(types$1.assign, 2) } - return this.finishOp(types$1.plusMin, 1) - }; - - pp.readToken_lt_gt = function(code) { // '<>' - var next = this.input.charCodeAt(this.pos + 1); - var size = 1; - if (next === code) { - size = code === 62 && this.input.charCodeAt(this.pos + 2) === 62 ? 3 : 2; - if (this.input.charCodeAt(this.pos + size) === 61) { return this.finishOp(types$1.assign, size + 1) } - return this.finishOp(types$1.bitShift, size) - } - if (next === 33 && code === 60 && !this.inModule && this.input.charCodeAt(this.pos + 2) === 45 && - this.input.charCodeAt(this.pos + 3) === 45) { - // `` line comment - this.skipLineComment(3); - this.skipSpace(); - return this.nextToken() - } - return this.finishOp(types$1.incDec, 2) - } - if (next === 61) { return this.finishOp(types$1.assign, 2) } - return this.finishOp(types$1.plusMin, 1) -}; - -pp.readToken_lt_gt = function(code) { // '<>' - var next = this.input.charCodeAt(this.pos + 1); - var size = 1; - if (next === code) { - size = code === 62 && this.input.charCodeAt(this.pos + 2) === 62 ? 3 : 2; - if (this.input.charCodeAt(this.pos + size) === 61) { return this.finishOp(types$1.assign, size + 1) } - return this.finishOp(types$1.bitShift, size) - } - if (next === 33 && code === 60 && !this.inModule && this.input.charCodeAt(this.pos + 2) === 45 && - this.input.charCodeAt(this.pos + 3) === 45) { - // ` - -[build-badge]: https://img.shields.io/travis/wooorm/character-entities-legacy.svg - -[build]: https://travis-ci.org/wooorm/character-entities-legacy - -[downloads-badge]: https://img.shields.io/npm/dm/character-entities-legacy.svg - -[downloads]: https://www.npmjs.com/package/character-entities-legacy - -[size-badge]: https://img.shields.io/bundlephobia/minzip/character-entities-legacy.svg - -[size]: https://bundlephobia.com/result?p=character-entities-legacy - -[npm]: https://docs.npmjs.com/cli/install - -[license]: license - -[author]: https://wooorm.com - -[html]: https://raw.githubusercontent.com/whatwg/html/master/json-entities-legacy.inc diff --git a/tools/eslint/node_modules/character-entities/index.json b/tools/eslint/node_modules/character-entities/index.json deleted file mode 100644 index a63babe093521d..00000000000000 --- a/tools/eslint/node_modules/character-entities/index.json +++ /dev/null @@ -1,2224 +0,0 @@ -{ - "AEli": "ร†", - "AElig": "ร†", - "AM": "&", - "AMP": "&", - "Aacut": "ร", - "Aacute": "ร", - "Abreve": "ฤ‚", - "Acir": "ร‚", - "Acirc": "ร‚", - "Acy": "ะ", - "Afr": "๐”„", - "Agrav": "ร€", - "Agrave": "ร€", - "Alpha": "ฮ‘", - "Amacr": "ฤ€", - "And": "โฉ“", - "Aogon": "ฤ„", - "Aopf": "๐”ธ", - "ApplyFunction": "โก", - "Arin": "ร…", - "Aring": "ร…", - "Ascr": "๐’œ", - "Assign": "โ‰”", - "Atild": "รƒ", - "Atilde": "รƒ", - "Aum": "ร„", - "Auml": "ร„", - "Backslash": "โˆ–", - "Barv": "โซง", - "Barwed": "โŒ†", - "Bcy": "ะ‘", - "Because": "โˆต", - "Bernoullis": "โ„ฌ", - "Beta": "ฮ’", - "Bfr": "๐”…", - "Bopf": "๐”น", - "Breve": "ห˜", - "Bscr": "โ„ฌ", - "Bumpeq": "โ‰Ž", - "CHcy": "ะง", - "COP": "ยฉ", - "COPY": "ยฉ", - "Cacute": "ฤ†", - "Cap": "โ‹’", - "CapitalDifferentialD": "โ……", - "Cayleys": "โ„ญ", - "Ccaron": "ฤŒ", - "Ccedi": "ร‡", - "Ccedil": "ร‡", - "Ccirc": "ฤˆ", - "Cconint": "โˆฐ", - "Cdot": "ฤŠ", - "Cedilla": "ยธ", - "CenterDot": "ยท", - "Cfr": "โ„ญ", - "Chi": "ฮง", - "CircleDot": "โŠ™", - "CircleMinus": "โŠ–", - "CirclePlus": "โŠ•", - "CircleTimes": "โŠ—", - "ClockwiseContourIntegral": "โˆฒ", - "CloseCurlyDoubleQuote": "โ€", - "CloseCurlyQuote": "โ€™", - "Colon": "โˆท", - "Colone": "โฉด", - "Congruent": "โ‰ก", - "Conint": "โˆฏ", - "ContourIntegral": "โˆฎ", - "Copf": "โ„‚", - "Coproduct": "โˆ", - "CounterClockwiseContourIntegral": "โˆณ", - "Cross": "โจฏ", - "Cscr": "๐’ž", - "Cup": "โ‹“", - "CupCap": "โ‰", - "DD": "โ……", - "DDotrahd": "โค‘", - "DJcy": "ะ‚", - "DScy": "ะ…", - "DZcy": "ะ", - "Dagger": "โ€ก", - "Darr": "โ†ก", - "Dashv": "โซค", - "Dcaron": "ฤŽ", - "Dcy": "ะ”", - "Del": "โˆ‡", - "Delta": "ฮ”", - "Dfr": "๐”‡", - "DiacriticalAcute": "ยด", - "DiacriticalDot": "ห™", - "DiacriticalDoubleAcute": "ห", - "DiacriticalGrave": "`", - "DiacriticalTilde": "หœ", - "Diamond": "โ‹„", - "DifferentialD": "โ…†", - "Dopf": "๐”ป", - "Dot": "ยจ", - "DotDot": "โƒœ", - "DotEqual": "โ‰", - "DoubleContourIntegral": "โˆฏ", - "DoubleDot": "ยจ", - "DoubleDownArrow": "โ‡“", - "DoubleLeftArrow": "โ‡", - "DoubleLeftRightArrow": "โ‡”", - "DoubleLeftTee": "โซค", - "DoubleLongLeftArrow": "โŸธ", - "DoubleLongLeftRightArrow": "โŸบ", - "DoubleLongRightArrow": "โŸน", - "DoubleRightArrow": "โ‡’", - "DoubleRightTee": "โŠจ", - "DoubleUpArrow": "โ‡‘", - "DoubleUpDownArrow": "โ‡•", - "DoubleVerticalBar": "โˆฅ", - "DownArrow": "โ†“", - "DownArrowBar": "โค“", - "DownArrowUpArrow": "โ‡ต", - "DownBreve": "ฬ‘", - "DownLeftRightVector": "โฅ", - "DownLeftTeeVector": "โฅž", - "DownLeftVector": "โ†ฝ", - "DownLeftVectorBar": "โฅ–", - "DownRightTeeVector": "โฅŸ", - "DownRightVector": "โ‡", - "DownRightVectorBar": "โฅ—", - "DownTee": "โŠค", - "DownTeeArrow": "โ†ง", - "Downarrow": "โ‡“", - "Dscr": "๐’Ÿ", - "Dstrok": "ฤ", - "ENG": "ลŠ", - "ET": "ร", - "ETH": "ร", - "Eacut": "ร‰", - "Eacute": "ร‰", - "Ecaron": "ฤš", - "Ecir": "รŠ", - "Ecirc": "รŠ", - "Ecy": "ะญ", - "Edot": "ฤ–", - "Efr": "๐”ˆ", - "Egrav": "รˆ", - "Egrave": "รˆ", - "Element": "โˆˆ", - "Emacr": "ฤ’", - "EmptySmallSquare": "โ—ป", - "EmptyVerySmallSquare": "โ–ซ", - "Eogon": "ฤ˜", - "Eopf": "๐”ผ", - "Epsilon": "ฮ•", - "Equal": "โฉต", - "EqualTilde": "โ‰‚", - "Equilibrium": "โ‡Œ", - "Escr": "โ„ฐ", - "Esim": "โฉณ", - "Eta": "ฮ—", - "Eum": "ร‹", - "Euml": "ร‹", - "Exists": "โˆƒ", - "ExponentialE": "โ…‡", - "Fcy": "ะค", - "Ffr": "๐”‰", - "FilledSmallSquare": "โ—ผ", - "FilledVerySmallSquare": "โ–ช", - "Fopf": "๐”ฝ", - "ForAll": "โˆ€", - "Fouriertrf": "โ„ฑ", - "Fscr": "โ„ฑ", - "GJcy": "ะƒ", - "G": ">", - "GT": ">", - "Gamma": "ฮ“", - "Gammad": "ฯœ", - "Gbreve": "ฤž", - "Gcedil": "ฤข", - "Gcirc": "ฤœ", - "Gcy": "ะ“", - "Gdot": "ฤ ", - "Gfr": "๐”Š", - "Gg": "โ‹™", - "Gopf": "๐”พ", - "GreaterEqual": "โ‰ฅ", - "GreaterEqualLess": "โ‹›", - "GreaterFullEqual": "โ‰ง", - "GreaterGreater": "โชข", - "GreaterLess": "โ‰ท", - "GreaterSlantEqual": "โฉพ", - "GreaterTilde": "โ‰ณ", - "Gscr": "๐’ข", - "Gt": "โ‰ซ", - "HARDcy": "ะช", - "Hacek": "ห‡", - "Hat": "^", - "Hcirc": "ฤค", - "Hfr": "โ„Œ", - "HilbertSpace": "โ„‹", - "Hopf": "โ„", - "HorizontalLine": "โ”€", - "Hscr": "โ„‹", - "Hstrok": "ฤฆ", - "HumpDownHump": "โ‰Ž", - "HumpEqual": "โ‰", - "IEcy": "ะ•", - "IJlig": "ฤฒ", - "IOcy": "ะ", - "Iacut": "ร", - "Iacute": "ร", - "Icir": "รŽ", - "Icirc": "รŽ", - "Icy": "ะ˜", - "Idot": "ฤฐ", - "Ifr": "โ„‘", - "Igrav": "รŒ", - "Igrave": "รŒ", - "Im": "โ„‘", - "Imacr": "ฤช", - "ImaginaryI": "โ…ˆ", - "Implies": "โ‡’", - "Int": "โˆฌ", - "Integral": "โˆซ", - "Intersection": "โ‹‚", - "InvisibleComma": "โฃ", - "InvisibleTimes": "โข", - "Iogon": "ฤฎ", - "Iopf": "๐•€", - "Iota": "ฮ™", - "Iscr": "โ„", - "Itilde": "ฤจ", - "Iukcy": "ะ†", - "Ium": "ร", - "Iuml": "ร", - "Jcirc": "ฤด", - "Jcy": "ะ™", - "Jfr": "๐”", - "Jopf": "๐•", - "Jscr": "๐’ฅ", - "Jsercy": "ะˆ", - "Jukcy": "ะ„", - "KHcy": "ะฅ", - "KJcy": "ะŒ", - "Kappa": "ฮš", - "Kcedil": "ฤถ", - "Kcy": "ะš", - "Kfr": "๐”Ž", - "Kopf": "๐•‚", - "Kscr": "๐’ฆ", - "LJcy": "ะ‰", - "L": "<", - "LT": "<", - "Lacute": "ฤน", - "Lambda": "ฮ›", - "Lang": "โŸช", - "Laplacetrf": "โ„’", - "Larr": "โ†ž", - "Lcaron": "ฤฝ", - "Lcedil": "ฤป", - "Lcy": "ะ›", - "LeftAngleBracket": "โŸจ", - "LeftArrow": "โ†", - "LeftArrowBar": "โ‡ค", - "LeftArrowRightArrow": "โ‡†", - "LeftCeiling": "โŒˆ", - "LeftDoubleBracket": "โŸฆ", - "LeftDownTeeVector": "โฅก", - "LeftDownVector": "โ‡ƒ", - "LeftDownVectorBar": "โฅ™", - "LeftFloor": "โŒŠ", - "LeftRightArrow": "โ†”", - "LeftRightVector": "โฅŽ", - "LeftTee": "โŠฃ", - "LeftTeeArrow": "โ†ค", - "LeftTeeVector": "โฅš", - "LeftTriangle": "โŠฒ", - "LeftTriangleBar": "โง", - "LeftTriangleEqual": "โŠด", - "LeftUpDownVector": "โฅ‘", - "LeftUpTeeVector": "โฅ ", - "LeftUpVector": "โ†ฟ", - "LeftUpVectorBar": "โฅ˜", - "LeftVector": "โ†ผ", - "LeftVectorBar": "โฅ’", - "Leftarrow": "โ‡", - "Leftrightarrow": "โ‡”", - "LessEqualGreater": "โ‹š", - "LessFullEqual": "โ‰ฆ", - "LessGreater": "โ‰ถ", - "LessLess": "โชก", - "LessSlantEqual": "โฉฝ", - "LessTilde": "โ‰ฒ", - "Lfr": "๐”", - "Ll": "โ‹˜", - "Lleftarrow": "โ‡š", - "Lmidot": "ฤฟ", - "LongLeftArrow": "โŸต", - "LongLeftRightArrow": "โŸท", - "LongRightArrow": "โŸถ", - "Longleftarrow": "โŸธ", - "Longleftrightarrow": "โŸบ", - "Longrightarrow": "โŸน", - "Lopf": "๐•ƒ", - "LowerLeftArrow": "โ†™", - "LowerRightArrow": "โ†˜", - "Lscr": "โ„’", - "Lsh": "โ†ฐ", - "Lstrok": "ล", - "Lt": "โ‰ช", - "Map": "โค…", - "Mcy": "ะœ", - "MediumSpace": "โŸ", - "Mellintrf": "โ„ณ", - "Mfr": "๐”", - "MinusPlus": "โˆ“", - "Mopf": "๐•„", - "Mscr": "โ„ณ", - "Mu": "ฮœ", - "NJcy": "ะŠ", - "Nacute": "ลƒ", - "Ncaron": "ล‡", - "Ncedil": "ล…", - "Ncy": "ะ", - "NegativeMediumSpace": "โ€‹", - "NegativeThickSpace": "โ€‹", - "NegativeThinSpace": "โ€‹", - "NegativeVeryThinSpace": "โ€‹", - "NestedGreaterGreater": "โ‰ซ", - "NestedLessLess": "โ‰ช", - "NewLine": "\n", - "Nfr": "๐”‘", - "NoBreak": "โ ", - "NonBreakingSpace": "ย ", - "Nopf": "โ„•", - "Not": "โซฌ", - "NotCongruent": "โ‰ข", - "NotCupCap": "โ‰ญ", - "NotDoubleVerticalBar": "โˆฆ", - "NotElement": "โˆ‰", - "NotEqual": "โ‰ ", - "NotEqualTilde": "โ‰‚ฬธ", - "NotExists": "โˆ„", - "NotGreater": "โ‰ฏ", - "NotGreaterEqual": "โ‰ฑ", - "NotGreaterFullEqual": "โ‰งฬธ", - "NotGreaterGreater": "โ‰ซฬธ", - "NotGreaterLess": "โ‰น", - "NotGreaterSlantEqual": "โฉพฬธ", - "NotGreaterTilde": "โ‰ต", - "NotHumpDownHump": "โ‰Žฬธ", - "NotHumpEqual": "โ‰ฬธ", - "NotLeftTriangle": "โ‹ช", - "NotLeftTriangleBar": "โงฬธ", - "NotLeftTriangleEqual": "โ‹ฌ", - "NotLess": "โ‰ฎ", - "NotLessEqual": "โ‰ฐ", - "NotLessGreater": "โ‰ธ", - "NotLessLess": "โ‰ชฬธ", - "NotLessSlantEqual": "โฉฝฬธ", - "NotLessTilde": "โ‰ด", - "NotNestedGreaterGreater": "โชขฬธ", - "NotNestedLessLess": "โชกฬธ", - "NotPrecedes": "โŠ€", - "NotPrecedesEqual": "โชฏฬธ", - "NotPrecedesSlantEqual": "โ‹ ", - "NotReverseElement": "โˆŒ", - "NotRightTriangle": "โ‹ซ", - "NotRightTriangleBar": "โงฬธ", - "NotRightTriangleEqual": "โ‹ญ", - "NotSquareSubset": "โŠฬธ", - "NotSquareSubsetEqual": "โ‹ข", - "NotSquareSuperset": "โŠฬธ", - "NotSquareSupersetEqual": "โ‹ฃ", - "NotSubset": "โŠ‚โƒ’", - "NotSubsetEqual": "โŠˆ", - "NotSucceeds": "โŠ", - "NotSucceedsEqual": "โชฐฬธ", - "NotSucceedsSlantEqual": "โ‹ก", - "NotSucceedsTilde": "โ‰ฟฬธ", - "NotSuperset": "โŠƒโƒ’", - "NotSupersetEqual": "โŠ‰", - "NotTilde": "โ‰", - "NotTildeEqual": "โ‰„", - "NotTildeFullEqual": "โ‰‡", - "NotTildeTilde": "โ‰‰", - "NotVerticalBar": "โˆค", - "Nscr": "๐’ฉ", - "Ntild": "ร‘", - "Ntilde": "ร‘", - "Nu": "ฮ", - "OElig": "ล’", - "Oacut": "ร“", - "Oacute": "ร“", - "Ocir": "ร”", - "Ocirc": "ร”", - "Ocy": "ะž", - "Odblac": "ล", - "Ofr": "๐”’", - "Ograv": "ร’", - "Ograve": "ร’", - "Omacr": "ลŒ", - "Omega": "ฮฉ", - "Omicron": "ฮŸ", - "Oopf": "๐•†", - "OpenCurlyDoubleQuote": "โ€œ", - "OpenCurlyQuote": "โ€˜", - "Or": "โฉ”", - "Oscr": "๐’ช", - "Oslas": "ร˜", - "Oslash": "ร˜", - "Otild": "ร•", - "Otilde": "ร•", - "Otimes": "โจท", - "Oum": "ร–", - "Ouml": "ร–", - "OverBar": "โ€พ", - "OverBrace": "โž", - "OverBracket": "โŽด", - "OverParenthesis": "โœ", - "PartialD": "โˆ‚", - "Pcy": "ะŸ", - "Pfr": "๐”“", - "Phi": "ฮฆ", - "Pi": "ฮ ", - "PlusMinus": "ยฑ", - "Poincareplane": "โ„Œ", - "Popf": "โ„™", - "Pr": "โชป", - "Precedes": "โ‰บ", - "PrecedesEqual": "โชฏ", - "PrecedesSlantEqual": "โ‰ผ", - "PrecedesTilde": "โ‰พ", - "Prime": "โ€ณ", - "Product": "โˆ", - "Proportion": "โˆท", - "Proportional": "โˆ", - "Pscr": "๐’ซ", - "Psi": "ฮจ", - "QUO": "\"", - "QUOT": "\"", - "Qfr": "๐””", - "Qopf": "โ„š", - "Qscr": "๐’ฌ", - "RBarr": "โค", - "RE": "ยฎ", - "REG": "ยฎ", - "Racute": "ล”", - "Rang": "โŸซ", - "Rarr": "โ† ", - "Rarrtl": "โค–", - "Rcaron": "ล˜", - "Rcedil": "ล–", - "Rcy": "ะ ", - "Re": "โ„œ", - "ReverseElement": "โˆ‹", - "ReverseEquilibrium": "โ‡‹", - "ReverseUpEquilibrium": "โฅฏ", - "Rfr": "โ„œ", - "Rho": "ฮก", - "RightAngleBracket": "โŸฉ", - "RightArrow": "โ†’", - "RightArrowBar": "โ‡ฅ", - "RightArrowLeftArrow": "โ‡„", - "RightCeiling": "โŒ‰", - "RightDoubleBracket": "โŸง", - "RightDownTeeVector": "โฅ", - "RightDownVector": "โ‡‚", - "RightDownVectorBar": "โฅ•", - "RightFloor": "โŒ‹", - "RightTee": "โŠข", - "RightTeeArrow": "โ†ฆ", - "RightTeeVector": "โฅ›", - "RightTriangle": "โŠณ", - "RightTriangleBar": "โง", - "RightTriangleEqual": "โŠต", - "RightUpDownVector": "โฅ", - "RightUpTeeVector": "โฅœ", - "RightUpVector": "โ†พ", - "RightUpVectorBar": "โฅ”", - "RightVector": "โ‡€", - "RightVectorBar": "โฅ“", - "Rightarrow": "โ‡’", - "Ropf": "โ„", - "RoundImplies": "โฅฐ", - "Rrightarrow": "โ‡›", - "Rscr": "โ„›", - "Rsh": "โ†ฑ", - "RuleDelayed": "โงด", - "SHCHcy": "ะฉ", - "SHcy": "ะจ", - "SOFTcy": "ะฌ", - "Sacute": "ลš", - "Sc": "โชผ", - "Scaron": "ล ", - "Scedil": "ลž", - "Scirc": "ลœ", - "Scy": "ะก", - "Sfr": "๐”–", - "ShortDownArrow": "โ†“", - "ShortLeftArrow": "โ†", - "ShortRightArrow": "โ†’", - "ShortUpArrow": "โ†‘", - "Sigma": "ฮฃ", - "SmallCircle": "โˆ˜", - "Sopf": "๐•Š", - "Sqrt": "โˆš", - "Square": "โ–ก", - "SquareIntersection": "โŠ“", - "SquareSubset": "โŠ", - "SquareSubsetEqual": "โŠ‘", - "SquareSuperset": "โŠ", - "SquareSupersetEqual": "โŠ’", - "SquareUnion": "โŠ”", - "Sscr": "๐’ฎ", - "Star": "โ‹†", - "Sub": "โ‹", - "Subset": "โ‹", - "SubsetEqual": "โŠ†", - "Succeeds": "โ‰ป", - "SucceedsEqual": "โชฐ", - "SucceedsSlantEqual": "โ‰ฝ", - "SucceedsTilde": "โ‰ฟ", - "SuchThat": "โˆ‹", - "Sum": "โˆ‘", - "Sup": "โ‹‘", - "Superset": "โŠƒ", - "SupersetEqual": "โŠ‡", - "Supset": "โ‹‘", - "THOR": "รž", - "THORN": "รž", - "TRADE": "โ„ข", - "TSHcy": "ะ‹", - "TScy": "ะฆ", - "Tab": "\t", - "Tau": "ฮค", - "Tcaron": "ลค", - "Tcedil": "ลข", - "Tcy": "ะข", - "Tfr": "๐”—", - "Therefore": "โˆด", - "Theta": "ฮ˜", - "ThickSpace": "โŸโ€Š", - "ThinSpace": "โ€‰", - "Tilde": "โˆผ", - "TildeEqual": "โ‰ƒ", - "TildeFullEqual": "โ‰…", - "TildeTilde": "โ‰ˆ", - "Topf": "๐•‹", - "TripleDot": "โƒ›", - "Tscr": "๐’ฏ", - "Tstrok": "ลฆ", - "Uacut": "รš", - "Uacute": "รš", - "Uarr": "โ†Ÿ", - "Uarrocir": "โฅ‰", - "Ubrcy": "ะŽ", - "Ubreve": "ลฌ", - "Ucir": "ร›", - "Ucirc": "ร›", - "Ucy": "ะฃ", - "Udblac": "ลฐ", - "Ufr": "๐”˜", - "Ugrav": "ร™", - "Ugrave": "ร™", - "Umacr": "ลช", - "UnderBar": "_", - "UnderBrace": "โŸ", - "UnderBracket": "โŽต", - "UnderParenthesis": "โ", - "Union": "โ‹ƒ", - "UnionPlus": "โŠŽ", - "Uogon": "ลฒ", - "Uopf": "๐•Œ", - "UpArrow": "โ†‘", - "UpArrowBar": "โค’", - "UpArrowDownArrow": "โ‡…", - "UpDownArrow": "โ†•", - "UpEquilibrium": "โฅฎ", - "UpTee": "โŠฅ", - "UpTeeArrow": "โ†ฅ", - "Uparrow": "โ‡‘", - "Updownarrow": "โ‡•", - "UpperLeftArrow": "โ†–", - "UpperRightArrow": "โ†—", - "Upsi": "ฯ’", - "Upsilon": "ฮฅ", - "Uring": "ลฎ", - "Uscr": "๐’ฐ", - "Utilde": "ลจ", - "Uum": "รœ", - "Uuml": "รœ", - "VDash": "โŠซ", - "Vbar": "โซซ", - "Vcy": "ะ’", - "Vdash": "โŠฉ", - "Vdashl": "โซฆ", - "Vee": "โ‹", - "Verbar": "โ€–", - "Vert": "โ€–", - "VerticalBar": "โˆฃ", - "VerticalLine": "|", - "VerticalSeparator": "โ˜", - "VerticalTilde": "โ‰€", - "VeryThinSpace": "โ€Š", - "Vfr": "๐”™", - "Vopf": "๐•", - "Vscr": "๐’ฑ", - "Vvdash": "โŠช", - "Wcirc": "ลด", - "Wedge": "โ‹€", - "Wfr": "๐”š", - "Wopf": "๐•Ž", - "Wscr": "๐’ฒ", - "Xfr": "๐”›", - "Xi": "ฮž", - "Xopf": "๐•", - "Xscr": "๐’ณ", - "YAcy": "ะฏ", - "YIcy": "ะ‡", - "YUcy": "ะฎ", - "Yacut": "ร", - "Yacute": "ร", - "Ycirc": "ลถ", - "Ycy": "ะซ", - "Yfr": "๐”œ", - "Yopf": "๐•", - "Yscr": "๐’ด", - "Yuml": "ลธ", - "ZHcy": "ะ–", - "Zacute": "ลน", - "Zcaron": "ลฝ", - "Zcy": "ะ—", - "Zdot": "ลป", - "ZeroWidthSpace": "โ€‹", - "Zeta": "ฮ–", - "Zfr": "โ„จ", - "Zopf": "โ„ค", - "Zscr": "๐’ต", - "aacut": "รก", - "aacute": "รก", - "abreve": "ฤƒ", - "ac": "โˆพ", - "acE": "โˆพฬณ", - "acd": "โˆฟ", - "acir": "รข", - "acirc": "รข", - "acut": "ยด", - "acute": "ยด", - "acy": "ะฐ", - "aeli": "รฆ", - "aelig": "รฆ", - "af": "โก", - "afr": "๐”ž", - "agrav": "ร ", - "agrave": "ร ", - "alefsym": "โ„ต", - "aleph": "โ„ต", - "alpha": "ฮฑ", - "amacr": "ฤ", - "amalg": "โจฟ", - "am": "&", - "amp": "&", - "and": "โˆง", - "andand": "โฉ•", - "andd": "โฉœ", - "andslope": "โฉ˜", - "andv": "โฉš", - "ang": "โˆ ", - "ange": "โฆค", - "angle": "โˆ ", - "angmsd": "โˆก", - "angmsdaa": "โฆจ", - "angmsdab": "โฆฉ", - "angmsdac": "โฆช", - "angmsdad": "โฆซ", - "angmsdae": "โฆฌ", - "angmsdaf": "โฆญ", - "angmsdag": "โฆฎ", - "angmsdah": "โฆฏ", - "angrt": "โˆŸ", - "angrtvb": "โŠพ", - "angrtvbd": "โฆ", - "angsph": "โˆข", - "angst": "ร…", - "angzarr": "โผ", - "aogon": "ฤ…", - "aopf": "๐•’", - "ap": "โ‰ˆ", - "apE": "โฉฐ", - "apacir": "โฉฏ", - "ape": "โ‰Š", - "apid": "โ‰‹", - "apos": "'", - "approx": "โ‰ˆ", - "approxeq": "โ‰Š", - "arin": "รฅ", - "aring": "รฅ", - "ascr": "๐’ถ", - "ast": "*", - "asymp": "โ‰ˆ", - "asympeq": "โ‰", - "atild": "รฃ", - "atilde": "รฃ", - "aum": "รค", - "auml": "รค", - "awconint": "โˆณ", - "awint": "โจ‘", - "bNot": "โซญ", - "backcong": "โ‰Œ", - "backepsilon": "ฯถ", - "backprime": "โ€ต", - "backsim": "โˆฝ", - "backsimeq": "โ‹", - "barvee": "โŠฝ", - "barwed": "โŒ…", - "barwedge": "โŒ…", - "bbrk": "โŽต", - "bbrktbrk": "โŽถ", - "bcong": "โ‰Œ", - "bcy": "ะฑ", - "bdquo": "โ€ž", - "becaus": "โˆต", - "because": "โˆต", - "bemptyv": "โฆฐ", - "bepsi": "ฯถ", - "bernou": "โ„ฌ", - "beta": "ฮฒ", - "beth": "โ„ถ", - "between": "โ‰ฌ", - "bfr": "๐”Ÿ", - "bigcap": "โ‹‚", - "bigcirc": "โ—ฏ", - "bigcup": "โ‹ƒ", - "bigodot": "โจ€", - "bigoplus": "โจ", - "bigotimes": "โจ‚", - "bigsqcup": "โจ†", - "bigstar": "โ˜…", - "bigtriangledown": "โ–ฝ", - "bigtriangleup": "โ–ณ", - "biguplus": "โจ„", - "bigvee": "โ‹", - "bigwedge": "โ‹€", - "bkarow": "โค", - "blacklozenge": "โงซ", - "blacksquare": "โ–ช", - "blacktriangle": "โ–ด", - "blacktriangledown": "โ–พ", - "blacktriangleleft": "โ—‚", - "blacktriangleright": "โ–ธ", - "blank": "โฃ", - "blk12": "โ–’", - "blk14": "โ–‘", - "blk34": "โ–“", - "block": "โ–ˆ", - "bne": "=โƒฅ", - "bnequiv": "โ‰กโƒฅ", - "bnot": "โŒ", - "bopf": "๐•“", - "bot": "โŠฅ", - "bottom": "โŠฅ", - "bowtie": "โ‹ˆ", - "boxDL": "โ•—", - "boxDR": "โ•”", - "boxDl": "โ•–", - "boxDr": "โ•“", - "boxH": "โ•", - "boxHD": "โ•ฆ", - "boxHU": "โ•ฉ", - "boxHd": "โ•ค", - "boxHu": "โ•ง", - "boxUL": "โ•", - "boxUR": "โ•š", - "boxUl": "โ•œ", - "boxUr": "โ•™", - "boxV": "โ•‘", - "boxVH": "โ•ฌ", - "boxVL": "โ•ฃ", - "boxVR": "โ• ", - "boxVh": "โ•ซ", - "boxVl": "โ•ข", - "boxVr": "โ•Ÿ", - "boxbox": "โง‰", - "boxdL": "โ••", - "boxdR": "โ•’", - "boxdl": "โ”", - "boxdr": "โ”Œ", - "boxh": "โ”€", - "boxhD": "โ•ฅ", - "boxhU": "โ•จ", - "boxhd": "โ”ฌ", - "boxhu": "โ”ด", - "boxminus": "โŠŸ", - "boxplus": "โŠž", - "boxtimes": "โŠ ", - "boxuL": "โ•›", - "boxuR": "โ•˜", - "boxul": "โ”˜", - "boxur": "โ””", - "boxv": "โ”‚", - "boxvH": "โ•ช", - "boxvL": "โ•ก", - "boxvR": "โ•ž", - "boxvh": "โ”ผ", - "boxvl": "โ”ค", - "boxvr": "โ”œ", - "bprime": "โ€ต", - "breve": "ห˜", - "brvba": "ยฆ", - "brvbar": "ยฆ", - "bscr": "๐’ท", - "bsemi": "โ", - "bsim": "โˆฝ", - "bsime": "โ‹", - "bsol": "\\", - "bsolb": "โง…", - "bsolhsub": "โŸˆ", - "bull": "โ€ข", - "bullet": "โ€ข", - "bump": "โ‰Ž", - "bumpE": "โชฎ", - "bumpe": "โ‰", - "bumpeq": "โ‰", - "cacute": "ฤ‡", - "cap": "โˆฉ", - "capand": "โฉ„", - "capbrcup": "โฉ‰", - "capcap": "โฉ‹", - "capcup": "โฉ‡", - "capdot": "โฉ€", - "caps": "โˆฉ๏ธ€", - "caret": "โ", - "caron": "ห‡", - "ccaps": "โฉ", - "ccaron": "ฤ", - "ccedi": "รง", - "ccedil": "รง", - "ccirc": "ฤ‰", - "ccups": "โฉŒ", - "ccupssm": "โฉ", - "cdot": "ฤ‹", - "cedi": "ยธ", - "cedil": "ยธ", - "cemptyv": "โฆฒ", - "cen": "ยข", - "cent": "ยข", - "centerdot": "ยท", - "cfr": "๐” ", - "chcy": "ั‡", - "check": "โœ“", - "checkmark": "โœ“", - "chi": "ฯ‡", - "cir": "โ—‹", - "cirE": "โงƒ", - "circ": "ห†", - "circeq": "โ‰—", - "circlearrowleft": "โ†บ", - "circlearrowright": "โ†ป", - "circledR": "ยฎ", - "circledS": "โ“ˆ", - "circledast": "โŠ›", - "circledcirc": "โŠš", - "circleddash": "โŠ", - "cire": "โ‰—", - "cirfnint": "โจ", - "cirmid": "โซฏ", - "cirscir": "โง‚", - "clubs": "โ™ฃ", - "clubsuit": "โ™ฃ", - "colon": ":", - "colone": "โ‰”", - "coloneq": "โ‰”", - "comma": ",", - "commat": "@", - "comp": "โˆ", - "compfn": "โˆ˜", - "complement": "โˆ", - "complexes": "โ„‚", - "cong": "โ‰…", - "congdot": "โฉญ", - "conint": "โˆฎ", - "copf": "๐•”", - "coprod": "โˆ", - "cop": "ยฉ", - "copy": "ยฉ", - "copysr": "โ„—", - "crarr": "โ†ต", - "cross": "โœ—", - "cscr": "๐’ธ", - "csub": "โซ", - "csube": "โซ‘", - "csup": "โซ", - "csupe": "โซ’", - "ctdot": "โ‹ฏ", - "cudarrl": "โคธ", - "cudarrr": "โคต", - "cuepr": "โ‹ž", - "cuesc": "โ‹Ÿ", - "cularr": "โ†ถ", - "cularrp": "โคฝ", - "cup": "โˆช", - "cupbrcap": "โฉˆ", - "cupcap": "โฉ†", - "cupcup": "โฉŠ", - "cupdot": "โŠ", - "cupor": "โฉ…", - "cups": "โˆช๏ธ€", - "curarr": "โ†ท", - "curarrm": "โคผ", - "curlyeqprec": "โ‹ž", - "curlyeqsucc": "โ‹Ÿ", - "curlyvee": "โ‹Ž", - "curlywedge": "โ‹", - "curre": "ยค", - "curren": "ยค", - "curvearrowleft": "โ†ถ", - "curvearrowright": "โ†ท", - "cuvee": "โ‹Ž", - "cuwed": "โ‹", - "cwconint": "โˆฒ", - "cwint": "โˆฑ", - "cylcty": "โŒญ", - "dArr": "โ‡“", - "dHar": "โฅฅ", - "dagger": "โ€ ", - "daleth": "โ„ธ", - "darr": "โ†“", - "dash": "โ€", - "dashv": "โŠฃ", - "dbkarow": "โค", - "dblac": "ห", - "dcaron": "ฤ", - "dcy": "ะด", - "dd": "โ…†", - "ddagger": "โ€ก", - "ddarr": "โ‡Š", - "ddotseq": "โฉท", - "de": "ยฐ", - "deg": "ยฐ", - "delta": "ฮด", - "demptyv": "โฆฑ", - "dfisht": "โฅฟ", - "dfr": "๐”ก", - "dharl": "โ‡ƒ", - "dharr": "โ‡‚", - "diam": "โ‹„", - "diamond": "โ‹„", - "diamondsuit": "โ™ฆ", - "diams": "โ™ฆ", - "die": "ยจ", - "digamma": "ฯ", - "disin": "โ‹ฒ", - "div": "รท", - "divid": "รท", - "divide": "รท", - "divideontimes": "โ‹‡", - "divonx": "โ‹‡", - "djcy": "ั’", - "dlcorn": "โŒž", - "dlcrop": "โŒ", - "dollar": "$", - "dopf": "๐••", - "dot": "ห™", - "doteq": "โ‰", - "doteqdot": "โ‰‘", - "dotminus": "โˆธ", - "dotplus": "โˆ”", - "dotsquare": "โŠก", - "doublebarwedge": "โŒ†", - "downarrow": "โ†“", - "downdownarrows": "โ‡Š", - "downharpoonleft": "โ‡ƒ", - "downharpoonright": "โ‡‚", - "drbkarow": "โค", - "drcorn": "โŒŸ", - "drcrop": "โŒŒ", - "dscr": "๐’น", - "dscy": "ั•", - "dsol": "โงถ", - "dstrok": "ฤ‘", - "dtdot": "โ‹ฑ", - "dtri": "โ–ฟ", - "dtrif": "โ–พ", - "duarr": "โ‡ต", - "duhar": "โฅฏ", - "dwangle": "โฆฆ", - "dzcy": "ัŸ", - "dzigrarr": "โŸฟ", - "eDDot": "โฉท", - "eDot": "โ‰‘", - "eacut": "รฉ", - "eacute": "รฉ", - "easter": "โฉฎ", - "ecaron": "ฤ›", - "ecir": "รช", - "ecirc": "รช", - "ecolon": "โ‰•", - "ecy": "ั", - "edot": "ฤ—", - "ee": "โ…‡", - "efDot": "โ‰’", - "efr": "๐”ข", - "eg": "โชš", - "egrav": "รจ", - "egrave": "รจ", - "egs": "โช–", - "egsdot": "โช˜", - "el": "โช™", - "elinters": "โง", - "ell": "โ„“", - "els": "โช•", - "elsdot": "โช—", - "emacr": "ฤ“", - "empty": "โˆ…", - "emptyset": "โˆ…", - "emptyv": "โˆ…", - "emsp13": "โ€„", - "emsp14": "โ€…", - "emsp": "โ€ƒ", - "eng": "ล‹", - "ensp": "โ€‚", - "eogon": "ฤ™", - "eopf": "๐•–", - "epar": "โ‹•", - "eparsl": "โงฃ", - "eplus": "โฉฑ", - "epsi": "ฮต", - "epsilon": "ฮต", - "epsiv": "ฯต", - "eqcirc": "โ‰–", - "eqcolon": "โ‰•", - "eqsim": "โ‰‚", - "eqslantgtr": "โช–", - "eqslantless": "โช•", - "equals": "=", - "equest": "โ‰Ÿ", - "equiv": "โ‰ก", - "equivDD": "โฉธ", - "eqvparsl": "โงฅ", - "erDot": "โ‰“", - "erarr": "โฅฑ", - "escr": "โ„ฏ", - "esdot": "โ‰", - "esim": "โ‰‚", - "eta": "ฮท", - "et": "รฐ", - "eth": "รฐ", - "eum": "รซ", - "euml": "รซ", - "euro": "โ‚ฌ", - "excl": "!", - "exist": "โˆƒ", - "expectation": "โ„ฐ", - "exponentiale": "โ…‡", - "fallingdotseq": "โ‰’", - "fcy": "ั„", - "female": "โ™€", - "ffilig": "๏ฌƒ", - "fflig": "๏ฌ€", - "ffllig": "๏ฌ„", - "ffr": "๐”ฃ", - "filig": "๏ฌ", - "fjlig": "fj", - "flat": "โ™ญ", - "fllig": "๏ฌ‚", - "fltns": "โ–ฑ", - "fnof": "ฦ’", - "fopf": "๐•—", - "forall": "โˆ€", - "fork": "โ‹”", - "forkv": "โซ™", - "fpartint": "โจ", - "frac1": "ยผ", - "frac12": "ยฝ", - "frac13": "โ…“", - "frac14": "ยผ", - "frac15": "โ…•", - "frac16": "โ…™", - "frac18": "โ…›", - "frac23": "โ…”", - "frac25": "โ…–", - "frac3": "ยพ", - "frac34": "ยพ", - "frac35": "โ…—", - "frac38": "โ…œ", - "frac45": "โ…˜", - "frac56": "โ…š", - "frac58": "โ…", - "frac78": "โ…ž", - "frasl": "โ„", - "frown": "โŒข", - "fscr": "๐’ป", - "gE": "โ‰ง", - "gEl": "โชŒ", - "gacute": "วต", - "gamma": "ฮณ", - "gammad": "ฯ", - "gap": "โช†", - "gbreve": "ฤŸ", - "gcirc": "ฤ", - "gcy": "ะณ", - "gdot": "ฤก", - "ge": "โ‰ฅ", - "gel": "โ‹›", - "geq": "โ‰ฅ", - "geqq": "โ‰ง", - "geqslant": "โฉพ", - "ges": "โฉพ", - "gescc": "โชฉ", - "gesdot": "โช€", - "gesdoto": "โช‚", - "gesdotol": "โช„", - "gesl": "โ‹›๏ธ€", - "gesles": "โช”", - "gfr": "๐”ค", - "gg": "โ‰ซ", - "ggg": "โ‹™", - "gimel": "โ„ท", - "gjcy": "ั“", - "gl": "โ‰ท", - "glE": "โช’", - "gla": "โชฅ", - "glj": "โชค", - "gnE": "โ‰ฉ", - "gnap": "โชŠ", - "gnapprox": "โชŠ", - "gne": "โชˆ", - "gneq": "โชˆ", - "gneqq": "โ‰ฉ", - "gnsim": "โ‹ง", - "gopf": "๐•˜", - "grave": "`", - "gscr": "โ„Š", - "gsim": "โ‰ณ", - "gsime": "โชŽ", - "gsiml": "โช", - "g": ">", - "gt": ">", - "gtcc": "โชง", - "gtcir": "โฉบ", - "gtdot": "โ‹—", - "gtlPar": "โฆ•", - "gtquest": "โฉผ", - "gtrapprox": "โช†", - "gtrarr": "โฅธ", - "gtrdot": "โ‹—", - "gtreqless": "โ‹›", - "gtreqqless": "โชŒ", - "gtrless": "โ‰ท", - "gtrsim": "โ‰ณ", - "gvertneqq": "โ‰ฉ๏ธ€", - "gvnE": "โ‰ฉ๏ธ€", - "hArr": "โ‡”", - "hairsp": "โ€Š", - "half": "ยฝ", - "hamilt": "โ„‹", - "hardcy": "ัŠ", - "harr": "โ†”", - "harrcir": "โฅˆ", - "harrw": "โ†ญ", - "hbar": "โ„", - "hcirc": "ฤฅ", - "hearts": "โ™ฅ", - "heartsuit": "โ™ฅ", - "hellip": "โ€ฆ", - "hercon": "โŠน", - "hfr": "๐”ฅ", - "hksearow": "โคฅ", - "hkswarow": "โคฆ", - "hoarr": "โ‡ฟ", - "homtht": "โˆป", - "hookleftarrow": "โ†ฉ", - "hookrightarrow": "โ†ช", - "hopf": "๐•™", - "horbar": "โ€•", - "hscr": "๐’ฝ", - "hslash": "โ„", - "hstrok": "ฤง", - "hybull": "โƒ", - "hyphen": "โ€", - "iacut": "รญ", - "iacute": "รญ", - "ic": "โฃ", - "icir": "รฎ", - "icirc": "รฎ", - "icy": "ะธ", - "iecy": "ะต", - "iexc": "ยก", - "iexcl": "ยก", - "iff": "โ‡”", - "ifr": "๐”ฆ", - "igrav": "รฌ", - "igrave": "รฌ", - "ii": "โ…ˆ", - "iiiint": "โจŒ", - "iiint": "โˆญ", - "iinfin": "โงœ", - "iiota": "โ„ฉ", - "ijlig": "ฤณ", - "imacr": "ฤซ", - "image": "โ„‘", - "imagline": "โ„", - "imagpart": "โ„‘", - "imath": "ฤฑ", - "imof": "โŠท", - "imped": "ฦต", - "in": "โˆˆ", - "incare": "โ„…", - "infin": "โˆž", - "infintie": "โง", - "inodot": "ฤฑ", - "int": "โˆซ", - "intcal": "โŠบ", - "integers": "โ„ค", - "intercal": "โŠบ", - "intlarhk": "โจ—", - "intprod": "โจผ", - "iocy": "ั‘", - "iogon": "ฤฏ", - "iopf": "๐•š", - "iota": "ฮน", - "iprod": "โจผ", - "iques": "ยฟ", - "iquest": "ยฟ", - "iscr": "๐’พ", - "isin": "โˆˆ", - "isinE": "โ‹น", - "isindot": "โ‹ต", - "isins": "โ‹ด", - "isinsv": "โ‹ณ", - "isinv": "โˆˆ", - "it": "โข", - "itilde": "ฤฉ", - "iukcy": "ั–", - "ium": "รฏ", - "iuml": "รฏ", - "jcirc": "ฤต", - "jcy": "ะน", - "jfr": "๐”ง", - "jmath": "ศท", - "jopf": "๐•›", - "jscr": "๐’ฟ", - "jsercy": "ั˜", - "jukcy": "ั”", - "kappa": "ฮบ", - "kappav": "ฯฐ", - "kcedil": "ฤท", - "kcy": "ะบ", - "kfr": "๐”จ", - "kgreen": "ฤธ", - "khcy": "ั…", - "kjcy": "ัœ", - "kopf": "๐•œ", - "kscr": "๐“€", - "lAarr": "โ‡š", - "lArr": "โ‡", - "lAtail": "โค›", - "lBarr": "โคŽ", - "lE": "โ‰ฆ", - "lEg": "โช‹", - "lHar": "โฅข", - "lacute": "ฤบ", - "laemptyv": "โฆด", - "lagran": "โ„’", - "lambda": "ฮป", - "lang": "โŸจ", - "langd": "โฆ‘", - "langle": "โŸจ", - "lap": "โช…", - "laqu": "ยซ", - "laquo": "ยซ", - "larr": "โ†", - "larrb": "โ‡ค", - "larrbfs": "โคŸ", - "larrfs": "โค", - "larrhk": "โ†ฉ", - "larrlp": "โ†ซ", - "larrpl": "โคน", - "larrsim": "โฅณ", - "larrtl": "โ†ข", - "lat": "โชซ", - "latail": "โค™", - "late": "โชญ", - "lates": "โชญ๏ธ€", - "lbarr": "โคŒ", - "lbbrk": "โฒ", - "lbrace": "{", - "lbrack": "[", - "lbrke": "โฆ‹", - "lbrksld": "โฆ", - "lbrkslu": "โฆ", - "lcaron": "ฤพ", - "lcedil": "ฤผ", - "lceil": "โŒˆ", - "lcub": "{", - "lcy": "ะป", - "ldca": "โคถ", - "ldquo": "โ€œ", - "ldquor": "โ€ž", - "ldrdhar": "โฅง", - "ldrushar": "โฅ‹", - "ldsh": "โ†ฒ", - "le": "โ‰ค", - "leftarrow": "โ†", - "leftarrowtail": "โ†ข", - "leftharpoondown": "โ†ฝ", - "leftharpoonup": "โ†ผ", - "leftleftarrows": "โ‡‡", - "leftrightarrow": "โ†”", - "leftrightarrows": "โ‡†", - "leftrightharpoons": "โ‡‹", - "leftrightsquigarrow": "โ†ญ", - "leftthreetimes": "โ‹‹", - "leg": "โ‹š", - "leq": "โ‰ค", - "leqq": "โ‰ฆ", - "leqslant": "โฉฝ", - "les": "โฉฝ", - "lescc": "โชจ", - "lesdot": "โฉฟ", - "lesdoto": "โช", - "lesdotor": "โชƒ", - "lesg": "โ‹š๏ธ€", - "lesges": "โช“", - "lessapprox": "โช…", - "lessdot": "โ‹–", - "lesseqgtr": "โ‹š", - "lesseqqgtr": "โช‹", - "lessgtr": "โ‰ถ", - "lesssim": "โ‰ฒ", - "lfisht": "โฅผ", - "lfloor": "โŒŠ", - "lfr": "๐”ฉ", - "lg": "โ‰ถ", - "lgE": "โช‘", - "lhard": "โ†ฝ", - "lharu": "โ†ผ", - "lharul": "โฅช", - "lhblk": "โ–„", - "ljcy": "ั™", - "ll": "โ‰ช", - "llarr": "โ‡‡", - "llcorner": "โŒž", - "llhard": "โฅซ", - "lltri": "โ—บ", - "lmidot": "ล€", - "lmoust": "โŽฐ", - "lmoustache": "โŽฐ", - "lnE": "โ‰จ", - "lnap": "โช‰", - "lnapprox": "โช‰", - "lne": "โช‡", - "lneq": "โช‡", - "lneqq": "โ‰จ", - "lnsim": "โ‹ฆ", - "loang": "โŸฌ", - "loarr": "โ‡ฝ", - "lobrk": "โŸฆ", - "longleftarrow": "โŸต", - "longleftrightarrow": "โŸท", - "longmapsto": "โŸผ", - "longrightarrow": "โŸถ", - "looparrowleft": "โ†ซ", - "looparrowright": "โ†ฌ", - "lopar": "โฆ…", - "lopf": "๐•", - "loplus": "โจญ", - "lotimes": "โจด", - "lowast": "โˆ—", - "lowbar": "_", - "loz": "โ—Š", - "lozenge": "โ—Š", - "lozf": "โงซ", - "lpar": "(", - "lparlt": "โฆ“", - "lrarr": "โ‡†", - "lrcorner": "โŒŸ", - "lrhar": "โ‡‹", - "lrhard": "โฅญ", - "lrm": "โ€Ž", - "lrtri": "โŠฟ", - "lsaquo": "โ€น", - "lscr": "๐“", - "lsh": "โ†ฐ", - "lsim": "โ‰ฒ", - "lsime": "โช", - "lsimg": "โช", - "lsqb": "[", - "lsquo": "โ€˜", - "lsquor": "โ€š", - "lstrok": "ล‚", - "l": "<", - "lt": "<", - "ltcc": "โชฆ", - "ltcir": "โฉน", - "ltdot": "โ‹–", - "lthree": "โ‹‹", - "ltimes": "โ‹‰", - "ltlarr": "โฅถ", - "ltquest": "โฉป", - "ltrPar": "โฆ–", - "ltri": "โ—ƒ", - "ltrie": "โŠด", - "ltrif": "โ—‚", - "lurdshar": "โฅŠ", - "luruhar": "โฅฆ", - "lvertneqq": "โ‰จ๏ธ€", - "lvnE": "โ‰จ๏ธ€", - "mDDot": "โˆบ", - "mac": "ยฏ", - "macr": "ยฏ", - "male": "โ™‚", - "malt": "โœ ", - "maltese": "โœ ", - "map": "โ†ฆ", - "mapsto": "โ†ฆ", - "mapstodown": "โ†ง", - "mapstoleft": "โ†ค", - "mapstoup": "โ†ฅ", - "marker": "โ–ฎ", - "mcomma": "โจฉ", - "mcy": "ะผ", - "mdash": "โ€”", - "measuredangle": "โˆก", - "mfr": "๐”ช", - "mho": "โ„ง", - "micr": "ยต", - "micro": "ยต", - "mid": "โˆฃ", - "midast": "*", - "midcir": "โซฐ", - "middo": "ยท", - "middot": "ยท", - "minus": "โˆ’", - "minusb": "โŠŸ", - "minusd": "โˆธ", - "minusdu": "โจช", - "mlcp": "โซ›", - "mldr": "โ€ฆ", - "mnplus": "โˆ“", - "models": "โŠง", - "mopf": "๐•ž", - "mp": "โˆ“", - "mscr": "๐“‚", - "mstpos": "โˆพ", - "mu": "ฮผ", - "multimap": "โŠธ", - "mumap": "โŠธ", - "nGg": "โ‹™ฬธ", - "nGt": "โ‰ซโƒ’", - "nGtv": "โ‰ซฬธ", - "nLeftarrow": "โ‡", - "nLeftrightarrow": "โ‡Ž", - "nLl": "โ‹˜ฬธ", - "nLt": "โ‰ชโƒ’", - "nLtv": "โ‰ชฬธ", - "nRightarrow": "โ‡", - "nVDash": "โŠฏ", - "nVdash": "โŠฎ", - "nabla": "โˆ‡", - "nacute": "ล„", - "nang": "โˆ โƒ’", - "nap": "โ‰‰", - "napE": "โฉฐฬธ", - "napid": "โ‰‹ฬธ", - "napos": "ล‰", - "napprox": "โ‰‰", - "natur": "โ™ฎ", - "natural": "โ™ฎ", - "naturals": "โ„•", - "nbs": "ย ", - "nbsp": "ย ", - "nbump": "โ‰Žฬธ", - "nbumpe": "โ‰ฬธ", - "ncap": "โฉƒ", - "ncaron": "ลˆ", - "ncedil": "ล†", - "ncong": "โ‰‡", - "ncongdot": "โฉญฬธ", - "ncup": "โฉ‚", - "ncy": "ะฝ", - "ndash": "โ€“", - "ne": "โ‰ ", - "neArr": "โ‡—", - "nearhk": "โคค", - "nearr": "โ†—", - "nearrow": "โ†—", - "nedot": "โ‰ฬธ", - "nequiv": "โ‰ข", - "nesear": "โคจ", - "nesim": "โ‰‚ฬธ", - "nexist": "โˆ„", - "nexists": "โˆ„", - "nfr": "๐”ซ", - "ngE": "โ‰งฬธ", - "nge": "โ‰ฑ", - "ngeq": "โ‰ฑ", - "ngeqq": "โ‰งฬธ", - "ngeqslant": "โฉพฬธ", - "nges": "โฉพฬธ", - "ngsim": "โ‰ต", - "ngt": "โ‰ฏ", - "ngtr": "โ‰ฏ", - "nhArr": "โ‡Ž", - "nharr": "โ†ฎ", - "nhpar": "โซฒ", - "ni": "โˆ‹", - "nis": "โ‹ผ", - "nisd": "โ‹บ", - "niv": "โˆ‹", - "njcy": "ัš", - "nlArr": "โ‡", - "nlE": "โ‰ฆฬธ", - "nlarr": "โ†š", - "nldr": "โ€ฅ", - "nle": "โ‰ฐ", - "nleftarrow": "โ†š", - "nleftrightarrow": "โ†ฎ", - "nleq": "โ‰ฐ", - "nleqq": "โ‰ฆฬธ", - "nleqslant": "โฉฝฬธ", - "nles": "โฉฝฬธ", - "nless": "โ‰ฎ", - "nlsim": "โ‰ด", - "nlt": "โ‰ฎ", - "nltri": "โ‹ช", - "nltrie": "โ‹ฌ", - "nmid": "โˆค", - "nopf": "๐•Ÿ", - "no": "ยฌ", - "not": "ยฌ", - "notin": "โˆ‰", - "notinE": "โ‹นฬธ", - "notindot": "โ‹ตฬธ", - "notinva": "โˆ‰", - "notinvb": "โ‹ท", - "notinvc": "โ‹ถ", - "notni": "โˆŒ", - "notniva": "โˆŒ", - "notnivb": "โ‹พ", - "notnivc": "โ‹ฝ", - "npar": "โˆฆ", - "nparallel": "โˆฆ", - "nparsl": "โซฝโƒฅ", - "npart": "โˆ‚ฬธ", - "npolint": "โจ”", - "npr": "โŠ€", - "nprcue": "โ‹ ", - "npre": "โชฏฬธ", - "nprec": "โŠ€", - "npreceq": "โชฏฬธ", - "nrArr": "โ‡", - "nrarr": "โ†›", - "nrarrc": "โคณฬธ", - "nrarrw": "โ†ฬธ", - "nrightarrow": "โ†›", - "nrtri": "โ‹ซ", - "nrtrie": "โ‹ญ", - "nsc": "โŠ", - "nsccue": "โ‹ก", - "nsce": "โชฐฬธ", - "nscr": "๐“ƒ", - "nshortmid": "โˆค", - "nshortparallel": "โˆฆ", - "nsim": "โ‰", - "nsime": "โ‰„", - "nsimeq": "โ‰„", - "nsmid": "โˆค", - "nspar": "โˆฆ", - "nsqsube": "โ‹ข", - "nsqsupe": "โ‹ฃ", - "nsub": "โŠ„", - "nsubE": "โซ…ฬธ", - "nsube": "โŠˆ", - "nsubset": "โŠ‚โƒ’", - "nsubseteq": "โŠˆ", - "nsubseteqq": "โซ…ฬธ", - "nsucc": "โŠ", - "nsucceq": "โชฐฬธ", - "nsup": "โŠ…", - "nsupE": "โซ†ฬธ", - "nsupe": "โŠ‰", - "nsupset": "โŠƒโƒ’", - "nsupseteq": "โŠ‰", - "nsupseteqq": "โซ†ฬธ", - "ntgl": "โ‰น", - "ntild": "รฑ", - "ntilde": "รฑ", - "ntlg": "โ‰ธ", - "ntriangleleft": "โ‹ช", - "ntrianglelefteq": "โ‹ฌ", - "ntriangleright": "โ‹ซ", - "ntrianglerighteq": "โ‹ญ", - "nu": "ฮฝ", - "num": "#", - "numero": "โ„–", - "numsp": "โ€‡", - "nvDash": "โŠญ", - "nvHarr": "โค„", - "nvap": "โ‰โƒ’", - "nvdash": "โŠฌ", - "nvge": "โ‰ฅโƒ’", - "nvgt": ">โƒ’", - "nvinfin": "โงž", - "nvlArr": "โค‚", - "nvle": "โ‰คโƒ’", - "nvlt": "<โƒ’", - "nvltrie": "โŠดโƒ’", - "nvrArr": "โคƒ", - "nvrtrie": "โŠตโƒ’", - "nvsim": "โˆผโƒ’", - "nwArr": "โ‡–", - "nwarhk": "โคฃ", - "nwarr": "โ†–", - "nwarrow": "โ†–", - "nwnear": "โคง", - "oS": "โ“ˆ", - "oacut": "รณ", - "oacute": "รณ", - "oast": "โŠ›", - "ocir": "รด", - "ocirc": "รด", - "ocy": "ะพ", - "odash": "โŠ", - "odblac": "ล‘", - "odiv": "โจธ", - "odot": "โŠ™", - "odsold": "โฆผ", - "oelig": "ล“", - "ofcir": "โฆฟ", - "ofr": "๐”ฌ", - "ogon": "ห›", - "ograv": "รฒ", - "ograve": "รฒ", - "ogt": "โง", - "ohbar": "โฆต", - "ohm": "ฮฉ", - "oint": "โˆฎ", - "olarr": "โ†บ", - "olcir": "โฆพ", - "olcross": "โฆป", - "oline": "โ€พ", - "olt": "โง€", - "omacr": "ล", - "omega": "ฯ‰", - "omicron": "ฮฟ", - "omid": "โฆถ", - "ominus": "โŠ–", - "oopf": "๐• ", - "opar": "โฆท", - "operp": "โฆน", - "oplus": "โŠ•", - "or": "โˆจ", - "orarr": "โ†ป", - "ord": "ยบ", - "order": "โ„ด", - "orderof": "โ„ด", - "ordf": "ยช", - "ordm": "ยบ", - "origof": "โŠถ", - "oror": "โฉ–", - "orslope": "โฉ—", - "orv": "โฉ›", - "oscr": "โ„ด", - "oslas": "รธ", - "oslash": "รธ", - "osol": "โŠ˜", - "otild": "รต", - "otilde": "รต", - "otimes": "โŠ—", - "otimesas": "โจถ", - "oum": "รถ", - "ouml": "รถ", - "ovbar": "โŒฝ", - "par": "ยถ", - "para": "ยถ", - "parallel": "โˆฅ", - "parsim": "โซณ", - "parsl": "โซฝ", - "part": "โˆ‚", - "pcy": "ะฟ", - "percnt": "%", - "period": ".", - "permil": "โ€ฐ", - "perp": "โŠฅ", - "pertenk": "โ€ฑ", - "pfr": "๐”ญ", - "phi": "ฯ†", - "phiv": "ฯ•", - "phmmat": "โ„ณ", - "phone": "โ˜Ž", - "pi": "ฯ€", - "pitchfork": "โ‹”", - "piv": "ฯ–", - "planck": "โ„", - "planckh": "โ„Ž", - "plankv": "โ„", - "plus": "+", - "plusacir": "โจฃ", - "plusb": "โŠž", - "pluscir": "โจข", - "plusdo": "โˆ”", - "plusdu": "โจฅ", - "pluse": "โฉฒ", - "plusm": "ยฑ", - "plusmn": "ยฑ", - "plussim": "โจฆ", - "plustwo": "โจง", - "pm": "ยฑ", - "pointint": "โจ•", - "popf": "๐•ก", - "poun": "ยฃ", - "pound": "ยฃ", - "pr": "โ‰บ", - "prE": "โชณ", - "prap": "โชท", - "prcue": "โ‰ผ", - "pre": "โชฏ", - "prec": "โ‰บ", - "precapprox": "โชท", - "preccurlyeq": "โ‰ผ", - "preceq": "โชฏ", - "precnapprox": "โชน", - "precneqq": "โชต", - "precnsim": "โ‹จ", - "precsim": "โ‰พ", - "prime": "โ€ฒ", - "primes": "โ„™", - "prnE": "โชต", - "prnap": "โชน", - "prnsim": "โ‹จ", - "prod": "โˆ", - "profalar": "โŒฎ", - "profline": "โŒ’", - "profsurf": "โŒ“", - "prop": "โˆ", - "propto": "โˆ", - "prsim": "โ‰พ", - "prurel": "โŠฐ", - "pscr": "๐“…", - "psi": "ฯˆ", - "puncsp": "โ€ˆ", - "qfr": "๐”ฎ", - "qint": "โจŒ", - "qopf": "๐•ข", - "qprime": "โ—", - "qscr": "๐“†", - "quaternions": "โ„", - "quatint": "โจ–", - "quest": "?", - "questeq": "โ‰Ÿ", - "quo": "\"", - "quot": "\"", - "rAarr": "โ‡›", - "rArr": "โ‡’", - "rAtail": "โคœ", - "rBarr": "โค", - "rHar": "โฅค", - "race": "โˆฝฬฑ", - "racute": "ล•", - "radic": "โˆš", - "raemptyv": "โฆณ", - "rang": "โŸฉ", - "rangd": "โฆ’", - "range": "โฆฅ", - "rangle": "โŸฉ", - "raqu": "ยป", - "raquo": "ยป", - "rarr": "โ†’", - "rarrap": "โฅต", - "rarrb": "โ‡ฅ", - "rarrbfs": "โค ", - "rarrc": "โคณ", - "rarrfs": "โคž", - "rarrhk": "โ†ช", - "rarrlp": "โ†ฌ", - "rarrpl": "โฅ…", - "rarrsim": "โฅด", - "rarrtl": "โ†ฃ", - "rarrw": "โ†", - "ratail": "โคš", - "ratio": "โˆถ", - "rationals": "โ„š", - "rbarr": "โค", - "rbbrk": "โณ", - "rbrace": "}", - "rbrack": "]", - "rbrke": "โฆŒ", - "rbrksld": "โฆŽ", - "rbrkslu": "โฆ", - "rcaron": "ล™", - "rcedil": "ล—", - "rceil": "โŒ‰", - "rcub": "}", - "rcy": "ั€", - "rdca": "โคท", - "rdldhar": "โฅฉ", - "rdquo": "โ€", - "rdquor": "โ€", - "rdsh": "โ†ณ", - "real": "โ„œ", - "realine": "โ„›", - "realpart": "โ„œ", - "reals": "โ„", - "rect": "โ–ญ", - "re": "ยฎ", - "reg": "ยฎ", - "rfisht": "โฅฝ", - "rfloor": "โŒ‹", - "rfr": "๐”ฏ", - "rhard": "โ‡", - "rharu": "โ‡€", - "rharul": "โฅฌ", - "rho": "ฯ", - "rhov": "ฯฑ", - "rightarrow": "โ†’", - "rightarrowtail": "โ†ฃ", - "rightharpoondown": "โ‡", - "rightharpoonup": "โ‡€", - "rightleftarrows": "โ‡„", - "rightleftharpoons": "โ‡Œ", - "rightrightarrows": "โ‡‰", - "rightsquigarrow": "โ†", - "rightthreetimes": "โ‹Œ", - "ring": "หš", - "risingdotseq": "โ‰“", - "rlarr": "โ‡„", - "rlhar": "โ‡Œ", - "rlm": "โ€", - "rmoust": "โŽฑ", - "rmoustache": "โŽฑ", - "rnmid": "โซฎ", - "roang": "โŸญ", - "roarr": "โ‡พ", - "robrk": "โŸง", - "ropar": "โฆ†", - "ropf": "๐•ฃ", - "roplus": "โจฎ", - "rotimes": "โจต", - "rpar": ")", - "rpargt": "โฆ”", - "rppolint": "โจ’", - "rrarr": "โ‡‰", - "rsaquo": "โ€บ", - "rscr": "๐“‡", - "rsh": "โ†ฑ", - "rsqb": "]", - "rsquo": "โ€™", - "rsquor": "โ€™", - "rthree": "โ‹Œ", - "rtimes": "โ‹Š", - "rtri": "โ–น", - "rtrie": "โŠต", - "rtrif": "โ–ธ", - "rtriltri": "โงŽ", - "ruluhar": "โฅจ", - "rx": "โ„ž", - "sacute": "ล›", - "sbquo": "โ€š", - "sc": "โ‰ป", - "scE": "โชด", - "scap": "โชธ", - "scaron": "ลก", - "sccue": "โ‰ฝ", - "sce": "โชฐ", - "scedil": "ลŸ", - "scirc": "ล", - "scnE": "โชถ", - "scnap": "โชบ", - "scnsim": "โ‹ฉ", - "scpolint": "โจ“", - "scsim": "โ‰ฟ", - "scy": "ั", - "sdot": "โ‹…", - "sdotb": "โŠก", - "sdote": "โฉฆ", - "seArr": "โ‡˜", - "searhk": "โคฅ", - "searr": "โ†˜", - "searrow": "โ†˜", - "sec": "ยง", - "sect": "ยง", - "semi": ";", - "seswar": "โคฉ", - "setminus": "โˆ–", - "setmn": "โˆ–", - "sext": "โœถ", - "sfr": "๐”ฐ", - "sfrown": "โŒข", - "sharp": "โ™ฏ", - "shchcy": "ั‰", - "shcy": "ัˆ", - "shortmid": "โˆฃ", - "shortparallel": "โˆฅ", - "sh": "ยญ", - "shy": "ยญ", - "sigma": "ฯƒ", - "sigmaf": "ฯ‚", - "sigmav": "ฯ‚", - "sim": "โˆผ", - "simdot": "โฉช", - "sime": "โ‰ƒ", - "simeq": "โ‰ƒ", - "simg": "โชž", - "simgE": "โช ", - "siml": "โช", - "simlE": "โชŸ", - "simne": "โ‰†", - "simplus": "โจค", - "simrarr": "โฅฒ", - "slarr": "โ†", - "smallsetminus": "โˆ–", - "smashp": "โจณ", - "smeparsl": "โงค", - "smid": "โˆฃ", - "smile": "โŒฃ", - "smt": "โชช", - "smte": "โชฌ", - "smtes": "โชฌ๏ธ€", - "softcy": "ัŒ", - "sol": "/", - "solb": "โง„", - "solbar": "โŒฟ", - "sopf": "๐•ค", - "spades": "โ™ ", - "spadesuit": "โ™ ", - "spar": "โˆฅ", - "sqcap": "โŠ“", - "sqcaps": "โŠ“๏ธ€", - "sqcup": "โŠ”", - "sqcups": "โŠ”๏ธ€", - "sqsub": "โŠ", - "sqsube": "โŠ‘", - "sqsubset": "โŠ", - "sqsubseteq": "โŠ‘", - "sqsup": "โŠ", - "sqsupe": "โŠ’", - "sqsupset": "โŠ", - "sqsupseteq": "โŠ’", - "squ": "โ–ก", - "square": "โ–ก", - "squarf": "โ–ช", - "squf": "โ–ช", - "srarr": "โ†’", - "sscr": "๐“ˆ", - "ssetmn": "โˆ–", - "ssmile": "โŒฃ", - "sstarf": "โ‹†", - "star": "โ˜†", - "starf": "โ˜…", - "straightepsilon": "ฯต", - "straightphi": "ฯ•", - "strns": "ยฏ", - "sub": "โŠ‚", - "subE": "โซ…", - "subdot": "โชฝ", - "sube": "โŠ†", - "subedot": "โซƒ", - "submult": "โซ", - "subnE": "โซ‹", - "subne": "โŠŠ", - "subplus": "โชฟ", - "subrarr": "โฅน", - "subset": "โŠ‚", - "subseteq": "โŠ†", - "subseteqq": "โซ…", - "subsetneq": "โŠŠ", - "subsetneqq": "โซ‹", - "subsim": "โซ‡", - "subsub": "โซ•", - "subsup": "โซ“", - "succ": "โ‰ป", - "succapprox": "โชธ", - "succcurlyeq": "โ‰ฝ", - "succeq": "โชฐ", - "succnapprox": "โชบ", - "succneqq": "โชถ", - "succnsim": "โ‹ฉ", - "succsim": "โ‰ฟ", - "sum": "โˆ‘", - "sung": "โ™ช", - "sup": "โŠƒ", - "sup1": "ยน", - "sup2": "ยฒ", - "sup3": "ยณ", - "supE": "โซ†", - "supdot": "โชพ", - "supdsub": "โซ˜", - "supe": "โŠ‡", - "supedot": "โซ„", - "suphsol": "โŸ‰", - "suphsub": "โซ—", - "suplarr": "โฅป", - "supmult": "โซ‚", - "supnE": "โซŒ", - "supne": "โŠ‹", - "supplus": "โซ€", - "supset": "โŠƒ", - "supseteq": "โŠ‡", - "supseteqq": "โซ†", - "supsetneq": "โŠ‹", - "supsetneqq": "โซŒ", - "supsim": "โซˆ", - "supsub": "โซ”", - "supsup": "โซ–", - "swArr": "โ‡™", - "swarhk": "โคฆ", - "swarr": "โ†™", - "swarrow": "โ†™", - "swnwar": "โคช", - "szli": "รŸ", - "szlig": "รŸ", - "target": "โŒ–", - "tau": "ฯ„", - "tbrk": "โŽด", - "tcaron": "ลฅ", - "tcedil": "ลฃ", - "tcy": "ั‚", - "tdot": "โƒ›", - "telrec": "โŒ•", - "tfr": "๐”ฑ", - "there4": "โˆด", - "therefore": "โˆด", - "theta": "ฮธ", - "thetasym": "ฯ‘", - "thetav": "ฯ‘", - "thickapprox": "โ‰ˆ", - "thicksim": "โˆผ", - "thinsp": "โ€‰", - "thkap": "โ‰ˆ", - "thksim": "โˆผ", - "thor": "รพ", - "thorn": "รพ", - "tilde": "หœ", - "time": "ร—", - "times": "ร—", - "timesb": "โŠ ", - "timesbar": "โจฑ", - "timesd": "โจฐ", - "tint": "โˆญ", - "toea": "โคจ", - "top": "โŠค", - "topbot": "โŒถ", - "topcir": "โซฑ", - "topf": "๐•ฅ", - "topfork": "โซš", - "tosa": "โคฉ", - "tprime": "โ€ด", - "trade": "โ„ข", - "triangle": "โ–ต", - "triangledown": "โ–ฟ", - "triangleleft": "โ—ƒ", - "trianglelefteq": "โŠด", - "triangleq": "โ‰œ", - "triangleright": "โ–น", - "trianglerighteq": "โŠต", - "tridot": "โ—ฌ", - "trie": "โ‰œ", - "triminus": "โจบ", - "triplus": "โจน", - "trisb": "โง", - "tritime": "โจป", - "trpezium": "โข", - "tscr": "๐“‰", - "tscy": "ั†", - "tshcy": "ั›", - "tstrok": "ลง", - "twixt": "โ‰ฌ", - "twoheadleftarrow": "โ†ž", - "twoheadrightarrow": "โ† ", - "uArr": "โ‡‘", - "uHar": "โฅฃ", - "uacut": "รบ", - "uacute": "รบ", - "uarr": "โ†‘", - "ubrcy": "ัž", - "ubreve": "ลญ", - "ucir": "รป", - "ucirc": "รป", - "ucy": "ัƒ", - "udarr": "โ‡…", - "udblac": "ลฑ", - "udhar": "โฅฎ", - "ufisht": "โฅพ", - "ufr": "๐”ฒ", - "ugrav": "รน", - "ugrave": "รน", - "uharl": "โ†ฟ", - "uharr": "โ†พ", - "uhblk": "โ–€", - "ulcorn": "โŒœ", - "ulcorner": "โŒœ", - "ulcrop": "โŒ", - "ultri": "โ—ธ", - "umacr": "ลซ", - "um": "ยจ", - "uml": "ยจ", - "uogon": "ลณ", - "uopf": "๐•ฆ", - "uparrow": "โ†‘", - "updownarrow": "โ†•", - "upharpoonleft": "โ†ฟ", - "upharpoonright": "โ†พ", - "uplus": "โŠŽ", - "upsi": "ฯ…", - "upsih": "ฯ’", - "upsilon": "ฯ…", - "upuparrows": "โ‡ˆ", - "urcorn": "โŒ", - "urcorner": "โŒ", - "urcrop": "โŒŽ", - "uring": "ลฏ", - "urtri": "โ—น", - "uscr": "๐“Š", - "utdot": "โ‹ฐ", - "utilde": "ลฉ", - "utri": "โ–ต", - "utrif": "โ–ด", - "uuarr": "โ‡ˆ", - "uum": "รผ", - "uuml": "รผ", - "uwangle": "โฆง", - "vArr": "โ‡•", - "vBar": "โซจ", - "vBarv": "โซฉ", - "vDash": "โŠจ", - "vangrt": "โฆœ", - "varepsilon": "ฯต", - "varkappa": "ฯฐ", - "varnothing": "โˆ…", - "varphi": "ฯ•", - "varpi": "ฯ–", - "varpropto": "โˆ", - "varr": "โ†•", - "varrho": "ฯฑ", - "varsigma": "ฯ‚", - "varsubsetneq": "โŠŠ๏ธ€", - "varsubsetneqq": "โซ‹๏ธ€", - "varsupsetneq": "โŠ‹๏ธ€", - "varsupsetneqq": "โซŒ๏ธ€", - "vartheta": "ฯ‘", - "vartriangleleft": "โŠฒ", - "vartriangleright": "โŠณ", - "vcy": "ะฒ", - "vdash": "โŠข", - "vee": "โˆจ", - "veebar": "โŠป", - "veeeq": "โ‰š", - "vellip": "โ‹ฎ", - "verbar": "|", - "vert": "|", - "vfr": "๐”ณ", - "vltri": "โŠฒ", - "vnsub": "โŠ‚โƒ’", - "vnsup": "โŠƒโƒ’", - "vopf": "๐•ง", - "vprop": "โˆ", - "vrtri": "โŠณ", - "vscr": "๐“‹", - "vsubnE": "โซ‹๏ธ€", - "vsubne": "โŠŠ๏ธ€", - "vsupnE": "โซŒ๏ธ€", - "vsupne": "โŠ‹๏ธ€", - "vzigzag": "โฆš", - "wcirc": "ลต", - "wedbar": "โฉŸ", - "wedge": "โˆง", - "wedgeq": "โ‰™", - "weierp": "โ„˜", - "wfr": "๐”ด", - "wopf": "๐•จ", - "wp": "โ„˜", - "wr": "โ‰€", - "wreath": "โ‰€", - "wscr": "๐“Œ", - "xcap": "โ‹‚", - "xcirc": "โ—ฏ", - "xcup": "โ‹ƒ", - "xdtri": "โ–ฝ", - "xfr": "๐”ต", - "xhArr": "โŸบ", - "xharr": "โŸท", - "xi": "ฮพ", - "xlArr": "โŸธ", - "xlarr": "โŸต", - "xmap": "โŸผ", - "xnis": "โ‹ป", - "xodot": "โจ€", - "xopf": "๐•ฉ", - "xoplus": "โจ", - "xotime": "โจ‚", - "xrArr": "โŸน", - "xrarr": "โŸถ", - "xscr": "๐“", - "xsqcup": "โจ†", - "xuplus": "โจ„", - "xutri": "โ–ณ", - "xvee": "โ‹", - "xwedge": "โ‹€", - "yacut": "รฝ", - "yacute": "รฝ", - "yacy": "ั", - "ycirc": "ลท", - "ycy": "ั‹", - "ye": "ยฅ", - "yen": "ยฅ", - "yfr": "๐”ถ", - "yicy": "ั—", - "yopf": "๐•ช", - "yscr": "๐“Ž", - "yucy": "ัŽ", - "yum": "รฟ", - "yuml": "รฟ", - "zacute": "ลบ", - "zcaron": "ลพ", - "zcy": "ะท", - "zdot": "ลผ", - "zeetrf": "โ„จ", - "zeta": "ฮถ", - "zfr": "๐”ท", - "zhcy": "ะถ", - "zigrarr": "โ‡", - "zopf": "๐•ซ", - "zscr": "๐“", - "zwj": "โ€", - "zwnj": "โ€Œ" -} diff --git a/tools/eslint/node_modules/character-entities/license b/tools/eslint/node_modules/character-entities/license deleted file mode 100644 index 32e7a3d93ca5a2..00000000000000 --- a/tools/eslint/node_modules/character-entities/license +++ /dev/null @@ -1,22 +0,0 @@ -(The MIT License) - -Copyright (c) 2015 Titus Wormer - -Permission is hereby granted, free of charge, to any person obtaining -a copy of this software and associated documentation files (the -'Software'), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sublicense, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY -CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, -TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/tools/eslint/node_modules/character-entities/package.json b/tools/eslint/node_modules/character-entities/package.json deleted file mode 100644 index e1151d249e23dd..00000000000000 --- a/tools/eslint/node_modules/character-entities/package.json +++ /dev/null @@ -1,71 +0,0 @@ -{ - "name": "character-entities", - "version": "1.2.4", - "description": "HTML character entity information", - "license": "MIT", - "keywords": [ - "html", - "entity", - "entities", - "character", - "reference", - "name", - "replacement" - ], - "repository": "wooorm/character-entities", - "bugs": "https://github.com/wooorm/character-entities/issues", - "funding": { - "type": "github", - "url": "https://github.com/sponsors/wooorm" - }, - "author": "Titus Wormer (https://wooorm.com)", - "contributors": [ - "Titus Wormer (https://wooorm.com)" - ], - "main": "index.json", - "files": [ - "index.json" - ], - "dependencies": {}, - "devDependencies": { - "bail": "^1.0.0", - "browserify": "^16.0.0", - "concat-stream": "^2.0.0", - "prettier": "^1.0.0", - "remark-cli": "^7.0.0", - "remark-preset-wooorm": "^6.0.0", - "tape": "^4.0.0", - "tinyify": "^2.0.0", - "xo": "^0.25.0" - }, - "scripts": { - "generate": "node build", - "format": "remark . -qfo && prettier --write \"**/*.js\" && xo --fix", - "build-bundle": "browserify index.json -s characterEntities -o character-entities.js", - "build-mangle": "browserify index.json -s characterEntities -p tinyify -o character-entities.min.js", - "build": "npm run build-bundle && npm run build-mangle", - "lint": "xo", - "test-api": "node test", - "test": "npm run generate && npm run format && npm run build && npm run test-api" - }, - "prettier": { - "tabWidth": 2, - "useTabs": false, - "singleQuote": true, - "bracketSpacing": false, - "semi": false, - "trailingComma": "none" - }, - "xo": { - "prettier": true, - "esnext": false, - "ignores": [ - "character-entities.js" - ] - }, - "remarkConfig": { - "plugins": [ - "preset-wooorm" - ] - } -} diff --git a/tools/eslint/node_modules/character-entities/readme.md b/tools/eslint/node_modules/character-entities/readme.md deleted file mode 100644 index b890e2aec3c4c7..00000000000000 --- a/tools/eslint/node_modules/character-entities/readme.md +++ /dev/null @@ -1,72 +0,0 @@ -# character-entities - -[![Build][build-badge]][build] -[![Downloads][downloads-badge]][downloads] -[![Size][size-badge]][size] - -HTML character entity information. - -## Install - -[npm][]: - -```sh -npm install character-entities -``` - -## Use - -```js -var characterEntities = require('character-entities') - -console.log(characterEntities.AElig) // => 'ร†' -console.log(characterEntities.aelig) // => 'รฆ' -console.log(characterEntities.amp) // => '&' -``` - -## API - -### characterEntities - -Mapping between (case-sensitive) character entity names to replacements. - -## Support - -See [`html.spec.whatwg.org`][html]. - -## Related - -* [`character-entities-html4`](https://github.com/wooorm/character-entities-html4) - โ€” HTML 4 character entity info -* [`character-entities-legacy`](https://github.com/wooorm/character-entities-legacy) - โ€” Legacy character entity info -* [`parse-entities`](https://github.com/wooorm/parse-entities) - โ€” Parse HTML character references -* [`stringify-entities`](https://github.com/wooorm/stringify-entities) - โ€” Stringify HTML character references - -## License - -[MIT][license] ยฉ [Titus Wormer][author] - - - -[build-badge]: https://img.shields.io/travis/wooorm/character-entities.svg - -[build]: https://travis-ci.org/wooorm/character-entities - -[downloads-badge]: https://img.shields.io/npm/dm/character-entities.svg - -[downloads]: https://www.npmjs.com/package/character-entities - -[size-badge]: https://img.shields.io/bundlephobia/minzip/character-entities.svg - -[size]: https://bundlephobia.com/result?p=character-entities - -[npm]: https://docs.npmjs.com/cli/install - -[license]: license - -[author]: https://wooorm.com - -[html]: https://html.spec.whatwg.org/multipage/syntax.html#named-character-references diff --git a/tools/eslint/node_modules/character-reference-invalid/index.json b/tools/eslint/node_modules/character-reference-invalid/index.json deleted file mode 100644 index 9337a854e40194..00000000000000 --- a/tools/eslint/node_modules/character-reference-invalid/index.json +++ /dev/null @@ -1,30 +0,0 @@ -{ - "0": "๏ฟฝ", - "128": "โ‚ฌ", - "130": "โ€š", - "131": "ฦ’", - "132": "โ€ž", - "133": "โ€ฆ", - "134": "โ€ ", - "135": "โ€ก", - "136": "ห†", - "137": "โ€ฐ", - "138": "ล ", - "139": "โ€น", - "140": "ล’", - "142": "ลฝ", - "145": "โ€˜", - "146": "โ€™", - "147": "โ€œ", - "148": "โ€", - "149": "โ€ข", - "150": "โ€“", - "151": "โ€”", - "152": "หœ", - "153": "โ„ข", - "154": "ลก", - "155": "โ€บ", - "156": "ล“", - "158": "ลพ", - "159": "ลธ" -} diff --git a/tools/eslint/node_modules/character-reference-invalid/license b/tools/eslint/node_modules/character-reference-invalid/license deleted file mode 100644 index 32e7a3d93ca5a2..00000000000000 --- a/tools/eslint/node_modules/character-reference-invalid/license +++ /dev/null @@ -1,22 +0,0 @@ -(The MIT License) - -Copyright (c) 2015 Titus Wormer - -Permission is hereby granted, free of charge, to any person obtaining -a copy of this software and associated documentation files (the -'Software'), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sublicense, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY -CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, -TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/tools/eslint/node_modules/character-reference-invalid/package.json b/tools/eslint/node_modules/character-reference-invalid/package.json deleted file mode 100644 index 069dc4b2b53901..00000000000000 --- a/tools/eslint/node_modules/character-reference-invalid/package.json +++ /dev/null @@ -1,74 +0,0 @@ -{ - "name": "character-reference-invalid", - "version": "1.1.4", - "description": "HTML invalid numeric character reference information", - "license": "MIT", - "keywords": [ - "html", - "entity", - "numeric", - "character", - "reference", - "replacement", - "invalid", - "name" - ], - "repository": "wooorm/character-reference-invalid", - "bugs": "https://github.com/wooorm/character-reference-invalid/issues", - "funding": { - "type": "github", - "url": "https://github.com/sponsors/wooorm" - }, - "author": "Titus Wormer (https://wooorm.com)", - "contributors": [ - "Titus Wormer (https://wooorm.com)" - ], - "main": "index.json", - "files": [ - "index.json" - ], - "dependencies": {}, - "devDependencies": { - "bail": "^1.0.0", - "browserify": "^16.0.0", - "concat-stream": "^2.0.0", - "hast-util-select": "^3.0.0", - "hast-util-to-string": "^1.0.0", - "rehype-parse": "^6.0.0", - "remark-cli": "^7.0.0", - "remark-preset-wooorm": "^6.0.0", - "tape": "^4.0.0", - "tinyify": "^2.0.0", - "unified": "^8.0.0", - "xo": "^0.25.0" - }, - "scripts": { - "generate": "node build", - "format": "remark . -qfo && prettier --write \"**/*.js\" && xo --fix", - "build-bundle": "browserify index.json -s characterReferenceInvalid -o character-reference-invalid.js", - "build-mangle": "browserify index.json -s characterReferenceInvalid -p tinyify -o character-reference-invalid.min.js", - "build": "npm run build-bundle && npm run build-mangle", - "test-api": "node test", - "test": "npm run generate && npm run format && npm run build && npm run test-api" - }, - "prettier": { - "tabWidth": 2, - "useTabs": false, - "singleQuote": true, - "bracketSpacing": false, - "semi": false, - "trailingComma": "none" - }, - "xo": { - "prettier": true, - "esnext": false, - "ignores": [ - "character-reference-invalid.js" - ] - }, - "remarkConfig": { - "plugins": [ - "preset-wooorm" - ] - } -} diff --git a/tools/eslint/node_modules/character-reference-invalid/readme.md b/tools/eslint/node_modules/character-reference-invalid/readme.md deleted file mode 100644 index e2e8f7a5177708..00000000000000 --- a/tools/eslint/node_modules/character-reference-invalid/readme.md +++ /dev/null @@ -1,74 +0,0 @@ -# character-reference-invalid - -[![Build][build-badge]][build] -[![Downloads][downloads-badge]][downloads] -[![Size][size-badge]][size] - -HTML invalid numeric character reference information. - -## Install - -[npm][]: - -```sh -npm install character-reference-invalid -``` - -## Use - -```js -var characterReferenceInvalid = require('character-reference-invalid') - -console.log(characterReferenceInvalid[0x80]) // => 'โ‚ฌ' -console.log(characterReferenceInvalid[0x89]) // => 'โ€ฐ' -console.log(characterReferenceInvalid[0x99]) // => 'โ„ข' -``` - -## API - -### `characterReferenceInvalid` - -Mapping between invalid numeric character reference to replacements. - -## Support - -See [`html.spec.whatwg.org`][html]. - -## Related - -* [`character-entities`](https://github.com/wooorm/character-entities) - โ€” HTML character entity info -* [`character-entities-html4`](https://github.com/wooorm/character-entities-html4) - โ€” HTML 4 character entity info -* [`character-entities-legacy`](https://github.com/wooorm/character-entities-legacy) - โ€” Legacy character entity info -* [`parse-entities`](https://github.com/wooorm/parse-entities) - โ€” Parse HTML character references -* [`stringify-entities`](https://github.com/wooorm/stringify-entities) - โ€” Serialize HTML character references - -## License - -[MIT][license] ยฉ [Titus Wormer][author] - - - -[build-badge]: https://img.shields.io/travis/wooorm/character-reference-invalid.svg - -[build]: https://travis-ci.org/wooorm/character-reference-invalid - -[downloads-badge]: https://img.shields.io/npm/dm/character-reference-invalid.svg - -[downloads]: https://www.npmjs.com/package/character-reference-invalid - -[size-badge]: https://img.shields.io/bundlephobia/minzip/character-reference-invalid.svg - -[size]: https://bundlephobia.com/result?p=character-reference-invalid - -[npm]: https://docs.npmjs.com/cli/install - -[license]: license - -[author]: https://wooorm.com - -[html]: https://html.spec.whatwg.org/multipage/syntax.html#table-charref-overrides diff --git a/tools/eslint/node_modules/color-convert/LICENSE b/tools/eslint/node_modules/color-convert/LICENSE deleted file mode 100644 index 5b4c386f9269b3..00000000000000 --- a/tools/eslint/node_modules/color-convert/LICENSE +++ /dev/null @@ -1,21 +0,0 @@ -Copyright (c) 2011-2016 Heather Arthur - -Permission is hereby granted, free of charge, to any person obtaining -a copy of this software and associated documentation files (the -"Software"), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sublicense, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - diff --git a/tools/eslint/node_modules/color-convert/conversions.js b/tools/eslint/node_modules/color-convert/conversions.js deleted file mode 100644 index 32172007ec0b17..00000000000000 --- a/tools/eslint/node_modules/color-convert/conversions.js +++ /dev/null @@ -1,868 +0,0 @@ -/* MIT license */ -var cssKeywords = require('color-name'); - -// NOTE: conversions should only return primitive values (i.e. arrays, or -// values that give correct `typeof` results). -// do not use box values types (i.e. Number(), String(), etc.) - -var reverseKeywords = {}; -for (var key in cssKeywords) { - if (cssKeywords.hasOwnProperty(key)) { - reverseKeywords[cssKeywords[key]] = key; - } -} - -var convert = module.exports = { - rgb: {channels: 3, labels: 'rgb'}, - hsl: {channels: 3, labels: 'hsl'}, - hsv: {channels: 3, labels: 'hsv'}, - hwb: {channels: 3, labels: 'hwb'}, - cmyk: {channels: 4, labels: 'cmyk'}, - xyz: {channels: 3, labels: 'xyz'}, - lab: {channels: 3, labels: 'lab'}, - lch: {channels: 3, labels: 'lch'}, - hex: {channels: 1, labels: ['hex']}, - keyword: {channels: 1, labels: ['keyword']}, - ansi16: {channels: 1, labels: ['ansi16']}, - ansi256: {channels: 1, labels: ['ansi256']}, - hcg: {channels: 3, labels: ['h', 'c', 'g']}, - apple: {channels: 3, labels: ['r16', 'g16', 'b16']}, - gray: {channels: 1, labels: ['gray']} -}; - -// hide .channels and .labels properties -for (var model in convert) { - if (convert.hasOwnProperty(model)) { - if (!('channels' in convert[model])) { - throw new Error('missing channels property: ' + model); - } - - if (!('labels' in convert[model])) { - throw new Error('missing channel labels property: ' + model); - } - - if (convert[model].labels.length !== convert[model].channels) { - throw new Error('channel and label counts mismatch: ' + model); - } - - var channels = convert[model].channels; - var labels = convert[model].labels; - delete convert[model].channels; - delete convert[model].labels; - Object.defineProperty(convert[model], 'channels', {value: channels}); - Object.defineProperty(convert[model], 'labels', {value: labels}); - } -} - -convert.rgb.hsl = function (rgb) { - var r = rgb[0] / 255; - var g = rgb[1] / 255; - var b = rgb[2] / 255; - var min = Math.min(r, g, b); - var max = Math.max(r, g, b); - var delta = max - min; - var h; - var s; - var l; - - if (max === min) { - h = 0; - } else if (r === max) { - h = (g - b) / delta; - } else if (g === max) { - h = 2 + (b - r) / delta; - } else if (b === max) { - h = 4 + (r - g) / delta; - } - - h = Math.min(h * 60, 360); - - if (h < 0) { - h += 360; - } - - l = (min + max) / 2; - - if (max === min) { - s = 0; - } else if (l <= 0.5) { - s = delta / (max + min); - } else { - s = delta / (2 - max - min); - } - - return [h, s * 100, l * 100]; -}; - -convert.rgb.hsv = function (rgb) { - var rdif; - var gdif; - var bdif; - var h; - var s; - - var r = rgb[0] / 255; - var g = rgb[1] / 255; - var b = rgb[2] / 255; - var v = Math.max(r, g, b); - var diff = v - Math.min(r, g, b); - var diffc = function (c) { - return (v - c) / 6 / diff + 1 / 2; - }; - - if (diff === 0) { - h = s = 0; - } else { - s = diff / v; - rdif = diffc(r); - gdif = diffc(g); - bdif = diffc(b); - - if (r === v) { - h = bdif - gdif; - } else if (g === v) { - h = (1 / 3) + rdif - bdif; - } else if (b === v) { - h = (2 / 3) + gdif - rdif; - } - if (h < 0) { - h += 1; - } else if (h > 1) { - h -= 1; - } - } - - return [ - h * 360, - s * 100, - v * 100 - ]; -}; - -convert.rgb.hwb = function (rgb) { - var r = rgb[0]; - var g = rgb[1]; - var b = rgb[2]; - var h = convert.rgb.hsl(rgb)[0]; - var w = 1 / 255 * Math.min(r, Math.min(g, b)); - - b = 1 - 1 / 255 * Math.max(r, Math.max(g, b)); - - return [h, w * 100, b * 100]; -}; - -convert.rgb.cmyk = function (rgb) { - var r = rgb[0] / 255; - var g = rgb[1] / 255; - var b = rgb[2] / 255; - var c; - var m; - var y; - var k; - - k = Math.min(1 - r, 1 - g, 1 - b); - c = (1 - r - k) / (1 - k) || 0; - m = (1 - g - k) / (1 - k) || 0; - y = (1 - b - k) / (1 - k) || 0; - - return [c * 100, m * 100, y * 100, k * 100]; -}; - -/** - * See https://en.m.wikipedia.org/wiki/Euclidean_distance#Squared_Euclidean_distance - * */ -function comparativeDistance(x, y) { - return ( - Math.pow(x[0] - y[0], 2) + - Math.pow(x[1] - y[1], 2) + - Math.pow(x[2] - y[2], 2) - ); -} - -convert.rgb.keyword = function (rgb) { - var reversed = reverseKeywords[rgb]; - if (reversed) { - return reversed; - } - - var currentClosestDistance = Infinity; - var currentClosestKeyword; - - for (var keyword in cssKeywords) { - if (cssKeywords.hasOwnProperty(keyword)) { - var value = cssKeywords[keyword]; - - // Compute comparative distance - var distance = comparativeDistance(rgb, value); - - // Check if its less, if so set as closest - if (distance < currentClosestDistance) { - currentClosestDistance = distance; - currentClosestKeyword = keyword; - } - } - } - - return currentClosestKeyword; -}; - -convert.keyword.rgb = function (keyword) { - return cssKeywords[keyword]; -}; - -convert.rgb.xyz = function (rgb) { - var r = rgb[0] / 255; - var g = rgb[1] / 255; - var b = rgb[2] / 255; - - // assume sRGB - r = r > 0.04045 ? Math.pow(((r + 0.055) / 1.055), 2.4) : (r / 12.92); - g = g > 0.04045 ? Math.pow(((g + 0.055) / 1.055), 2.4) : (g / 12.92); - b = b > 0.04045 ? Math.pow(((b + 0.055) / 1.055), 2.4) : (b / 12.92); - - var x = (r * 0.4124) + (g * 0.3576) + (b * 0.1805); - var y = (r * 0.2126) + (g * 0.7152) + (b * 0.0722); - var z = (r * 0.0193) + (g * 0.1192) + (b * 0.9505); - - return [x * 100, y * 100, z * 100]; -}; - -convert.rgb.lab = function (rgb) { - var xyz = convert.rgb.xyz(rgb); - var x = xyz[0]; - var y = xyz[1]; - var z = xyz[2]; - var l; - var a; - var b; - - x /= 95.047; - y /= 100; - z /= 108.883; - - x = x > 0.008856 ? Math.pow(x, 1 / 3) : (7.787 * x) + (16 / 116); - y = y > 0.008856 ? Math.pow(y, 1 / 3) : (7.787 * y) + (16 / 116); - z = z > 0.008856 ? Math.pow(z, 1 / 3) : (7.787 * z) + (16 / 116); - - l = (116 * y) - 16; - a = 500 * (x - y); - b = 200 * (y - z); - - return [l, a, b]; -}; - -convert.hsl.rgb = function (hsl) { - var h = hsl[0] / 360; - var s = hsl[1] / 100; - var l = hsl[2] / 100; - var t1; - var t2; - var t3; - var rgb; - var val; - - if (s === 0) { - val = l * 255; - return [val, val, val]; - } - - if (l < 0.5) { - t2 = l * (1 + s); - } else { - t2 = l + s - l * s; - } - - t1 = 2 * l - t2; - - rgb = [0, 0, 0]; - for (var i = 0; i < 3; i++) { - t3 = h + 1 / 3 * -(i - 1); - if (t3 < 0) { - t3++; - } - if (t3 > 1) { - t3--; - } - - if (6 * t3 < 1) { - val = t1 + (t2 - t1) * 6 * t3; - } else if (2 * t3 < 1) { - val = t2; - } else if (3 * t3 < 2) { - val = t1 + (t2 - t1) * (2 / 3 - t3) * 6; - } else { - val = t1; - } - - rgb[i] = val * 255; - } - - return rgb; -}; - -convert.hsl.hsv = function (hsl) { - var h = hsl[0]; - var s = hsl[1] / 100; - var l = hsl[2] / 100; - var smin = s; - var lmin = Math.max(l, 0.01); - var sv; - var v; - - l *= 2; - s *= (l <= 1) ? l : 2 - l; - smin *= lmin <= 1 ? lmin : 2 - lmin; - v = (l + s) / 2; - sv = l === 0 ? (2 * smin) / (lmin + smin) : (2 * s) / (l + s); - - return [h, sv * 100, v * 100]; -}; - -convert.hsv.rgb = function (hsv) { - var h = hsv[0] / 60; - var s = hsv[1] / 100; - var v = hsv[2] / 100; - var hi = Math.floor(h) % 6; - - var f = h - Math.floor(h); - var p = 255 * v * (1 - s); - var q = 255 * v * (1 - (s * f)); - var t = 255 * v * (1 - (s * (1 - f))); - v *= 255; - - switch (hi) { - case 0: - return [v, t, p]; - case 1: - return [q, v, p]; - case 2: - return [p, v, t]; - case 3: - return [p, q, v]; - case 4: - return [t, p, v]; - case 5: - return [v, p, q]; - } -}; - -convert.hsv.hsl = function (hsv) { - var h = hsv[0]; - var s = hsv[1] / 100; - var v = hsv[2] / 100; - var vmin = Math.max(v, 0.01); - var lmin; - var sl; - var l; - - l = (2 - s) * v; - lmin = (2 - s) * vmin; - sl = s * vmin; - sl /= (lmin <= 1) ? lmin : 2 - lmin; - sl = sl || 0; - l /= 2; - - return [h, sl * 100, l * 100]; -}; - -// http://dev.w3.org/csswg/css-color/#hwb-to-rgb -convert.hwb.rgb = function (hwb) { - var h = hwb[0] / 360; - var wh = hwb[1] / 100; - var bl = hwb[2] / 100; - var ratio = wh + bl; - var i; - var v; - var f; - var n; - - // wh + bl cant be > 1 - if (ratio > 1) { - wh /= ratio; - bl /= ratio; - } - - i = Math.floor(6 * h); - v = 1 - bl; - f = 6 * h - i; - - if ((i & 0x01) !== 0) { - f = 1 - f; - } - - n = wh + f * (v - wh); // linear interpolation - - var r; - var g; - var b; - switch (i) { - default: - case 6: - case 0: r = v; g = n; b = wh; break; - case 1: r = n; g = v; b = wh; break; - case 2: r = wh; g = v; b = n; break; - case 3: r = wh; g = n; b = v; break; - case 4: r = n; g = wh; b = v; break; - case 5: r = v; g = wh; b = n; break; - } - - return [r * 255, g * 255, b * 255]; -}; - -convert.cmyk.rgb = function (cmyk) { - var c = cmyk[0] / 100; - var m = cmyk[1] / 100; - var y = cmyk[2] / 100; - var k = cmyk[3] / 100; - var r; - var g; - var b; - - r = 1 - Math.min(1, c * (1 - k) + k); - g = 1 - Math.min(1, m * (1 - k) + k); - b = 1 - Math.min(1, y * (1 - k) + k); - - return [r * 255, g * 255, b * 255]; -}; - -convert.xyz.rgb = function (xyz) { - var x = xyz[0] / 100; - var y = xyz[1] / 100; - var z = xyz[2] / 100; - var r; - var g; - var b; - - r = (x * 3.2406) + (y * -1.5372) + (z * -0.4986); - g = (x * -0.9689) + (y * 1.8758) + (z * 0.0415); - b = (x * 0.0557) + (y * -0.2040) + (z * 1.0570); - - // assume sRGB - r = r > 0.0031308 - ? ((1.055 * Math.pow(r, 1.0 / 2.4)) - 0.055) - : r * 12.92; - - g = g > 0.0031308 - ? ((1.055 * Math.pow(g, 1.0 / 2.4)) - 0.055) - : g * 12.92; - - b = b > 0.0031308 - ? ((1.055 * Math.pow(b, 1.0 / 2.4)) - 0.055) - : b * 12.92; - - r = Math.min(Math.max(0, r), 1); - g = Math.min(Math.max(0, g), 1); - b = Math.min(Math.max(0, b), 1); - - return [r * 255, g * 255, b * 255]; -}; - -convert.xyz.lab = function (xyz) { - var x = xyz[0]; - var y = xyz[1]; - var z = xyz[2]; - var l; - var a; - var b; - - x /= 95.047; - y /= 100; - z /= 108.883; - - x = x > 0.008856 ? Math.pow(x, 1 / 3) : (7.787 * x) + (16 / 116); - y = y > 0.008856 ? Math.pow(y, 1 / 3) : (7.787 * y) + (16 / 116); - z = z > 0.008856 ? Math.pow(z, 1 / 3) : (7.787 * z) + (16 / 116); - - l = (116 * y) - 16; - a = 500 * (x - y); - b = 200 * (y - z); - - return [l, a, b]; -}; - -convert.lab.xyz = function (lab) { - var l = lab[0]; - var a = lab[1]; - var b = lab[2]; - var x; - var y; - var z; - - y = (l + 16) / 116; - x = a / 500 + y; - z = y - b / 200; - - var y2 = Math.pow(y, 3); - var x2 = Math.pow(x, 3); - var z2 = Math.pow(z, 3); - y = y2 > 0.008856 ? y2 : (y - 16 / 116) / 7.787; - x = x2 > 0.008856 ? x2 : (x - 16 / 116) / 7.787; - z = z2 > 0.008856 ? z2 : (z - 16 / 116) / 7.787; - - x *= 95.047; - y *= 100; - z *= 108.883; - - return [x, y, z]; -}; - -convert.lab.lch = function (lab) { - var l = lab[0]; - var a = lab[1]; - var b = lab[2]; - var hr; - var h; - var c; - - hr = Math.atan2(b, a); - h = hr * 360 / 2 / Math.PI; - - if (h < 0) { - h += 360; - } - - c = Math.sqrt(a * a + b * b); - - return [l, c, h]; -}; - -convert.lch.lab = function (lch) { - var l = lch[0]; - var c = lch[1]; - var h = lch[2]; - var a; - var b; - var hr; - - hr = h / 360 * 2 * Math.PI; - a = c * Math.cos(hr); - b = c * Math.sin(hr); - - return [l, a, b]; -}; - -convert.rgb.ansi16 = function (args) { - var r = args[0]; - var g = args[1]; - var b = args[2]; - var value = 1 in arguments ? arguments[1] : convert.rgb.hsv(args)[2]; // hsv -> ansi16 optimization - - value = Math.round(value / 50); - - if (value === 0) { - return 30; - } - - var ansi = 30 - + ((Math.round(b / 255) << 2) - | (Math.round(g / 255) << 1) - | Math.round(r / 255)); - - if (value === 2) { - ansi += 60; - } - - return ansi; -}; - -convert.hsv.ansi16 = function (args) { - // optimization here; we already know the value and don't need to get - // it converted for us. - return convert.rgb.ansi16(convert.hsv.rgb(args), args[2]); -}; - -convert.rgb.ansi256 = function (args) { - var r = args[0]; - var g = args[1]; - var b = args[2]; - - // we use the extended greyscale palette here, with the exception of - // black and white. normal palette only has 4 greyscale shades. - if (r === g && g === b) { - if (r < 8) { - return 16; - } - - if (r > 248) { - return 231; - } - - return Math.round(((r - 8) / 247) * 24) + 232; - } - - var ansi = 16 - + (36 * Math.round(r / 255 * 5)) - + (6 * Math.round(g / 255 * 5)) - + Math.round(b / 255 * 5); - - return ansi; -}; - -convert.ansi16.rgb = function (args) { - var color = args % 10; - - // handle greyscale - if (color === 0 || color === 7) { - if (args > 50) { - color += 3.5; - } - - color = color / 10.5 * 255; - - return [color, color, color]; - } - - var mult = (~~(args > 50) + 1) * 0.5; - var r = ((color & 1) * mult) * 255; - var g = (((color >> 1) & 1) * mult) * 255; - var b = (((color >> 2) & 1) * mult) * 255; - - return [r, g, b]; -}; - -convert.ansi256.rgb = function (args) { - // handle greyscale - if (args >= 232) { - var c = (args - 232) * 10 + 8; - return [c, c, c]; - } - - args -= 16; - - var rem; - var r = Math.floor(args / 36) / 5 * 255; - var g = Math.floor((rem = args % 36) / 6) / 5 * 255; - var b = (rem % 6) / 5 * 255; - - return [r, g, b]; -}; - -convert.rgb.hex = function (args) { - var integer = ((Math.round(args[0]) & 0xFF) << 16) - + ((Math.round(args[1]) & 0xFF) << 8) - + (Math.round(args[2]) & 0xFF); - - var string = integer.toString(16).toUpperCase(); - return '000000'.substring(string.length) + string; -}; - -convert.hex.rgb = function (args) { - var match = args.toString(16).match(/[a-f0-9]{6}|[a-f0-9]{3}/i); - if (!match) { - return [0, 0, 0]; - } - - var colorString = match[0]; - - if (match[0].length === 3) { - colorString = colorString.split('').map(function (char) { - return char + char; - }).join(''); - } - - var integer = parseInt(colorString, 16); - var r = (integer >> 16) & 0xFF; - var g = (integer >> 8) & 0xFF; - var b = integer & 0xFF; - - return [r, g, b]; -}; - -convert.rgb.hcg = function (rgb) { - var r = rgb[0] / 255; - var g = rgb[1] / 255; - var b = rgb[2] / 255; - var max = Math.max(Math.max(r, g), b); - var min = Math.min(Math.min(r, g), b); - var chroma = (max - min); - var grayscale; - var hue; - - if (chroma < 1) { - grayscale = min / (1 - chroma); - } else { - grayscale = 0; - } - - if (chroma <= 0) { - hue = 0; - } else - if (max === r) { - hue = ((g - b) / chroma) % 6; - } else - if (max === g) { - hue = 2 + (b - r) / chroma; - } else { - hue = 4 + (r - g) / chroma + 4; - } - - hue /= 6; - hue %= 1; - - return [hue * 360, chroma * 100, grayscale * 100]; -}; - -convert.hsl.hcg = function (hsl) { - var s = hsl[1] / 100; - var l = hsl[2] / 100; - var c = 1; - var f = 0; - - if (l < 0.5) { - c = 2.0 * s * l; - } else { - c = 2.0 * s * (1.0 - l); - } - - if (c < 1.0) { - f = (l - 0.5 * c) / (1.0 - c); - } - - return [hsl[0], c * 100, f * 100]; -}; - -convert.hsv.hcg = function (hsv) { - var s = hsv[1] / 100; - var v = hsv[2] / 100; - - var c = s * v; - var f = 0; - - if (c < 1.0) { - f = (v - c) / (1 - c); - } - - return [hsv[0], c * 100, f * 100]; -}; - -convert.hcg.rgb = function (hcg) { - var h = hcg[0] / 360; - var c = hcg[1] / 100; - var g = hcg[2] / 100; - - if (c === 0.0) { - return [g * 255, g * 255, g * 255]; - } - - var pure = [0, 0, 0]; - var hi = (h % 1) * 6; - var v = hi % 1; - var w = 1 - v; - var mg = 0; - - switch (Math.floor(hi)) { - case 0: - pure[0] = 1; pure[1] = v; pure[2] = 0; break; - case 1: - pure[0] = w; pure[1] = 1; pure[2] = 0; break; - case 2: - pure[0] = 0; pure[1] = 1; pure[2] = v; break; - case 3: - pure[0] = 0; pure[1] = w; pure[2] = 1; break; - case 4: - pure[0] = v; pure[1] = 0; pure[2] = 1; break; - default: - pure[0] = 1; pure[1] = 0; pure[2] = w; - } - - mg = (1.0 - c) * g; - - return [ - (c * pure[0] + mg) * 255, - (c * pure[1] + mg) * 255, - (c * pure[2] + mg) * 255 - ]; -}; - -convert.hcg.hsv = function (hcg) { - var c = hcg[1] / 100; - var g = hcg[2] / 100; - - var v = c + g * (1.0 - c); - var f = 0; - - if (v > 0.0) { - f = c / v; - } - - return [hcg[0], f * 100, v * 100]; -}; - -convert.hcg.hsl = function (hcg) { - var c = hcg[1] / 100; - var g = hcg[2] / 100; - - var l = g * (1.0 - c) + 0.5 * c; - var s = 0; - - if (l > 0.0 && l < 0.5) { - s = c / (2 * l); - } else - if (l >= 0.5 && l < 1.0) { - s = c / (2 * (1 - l)); - } - - return [hcg[0], s * 100, l * 100]; -}; - -convert.hcg.hwb = function (hcg) { - var c = hcg[1] / 100; - var g = hcg[2] / 100; - var v = c + g * (1.0 - c); - return [hcg[0], (v - c) * 100, (1 - v) * 100]; -}; - -convert.hwb.hcg = function (hwb) { - var w = hwb[1] / 100; - var b = hwb[2] / 100; - var v = 1 - b; - var c = v - w; - var g = 0; - - if (c < 1) { - g = (v - c) / (1 - c); - } - - return [hwb[0], c * 100, g * 100]; -}; - -convert.apple.rgb = function (apple) { - return [(apple[0] / 65535) * 255, (apple[1] / 65535) * 255, (apple[2] / 65535) * 255]; -}; - -convert.rgb.apple = function (rgb) { - return [(rgb[0] / 255) * 65535, (rgb[1] / 255) * 65535, (rgb[2] / 255) * 65535]; -}; - -convert.gray.rgb = function (args) { - return [args[0] / 100 * 255, args[0] / 100 * 255, args[0] / 100 * 255]; -}; - -convert.gray.hsl = convert.gray.hsv = function (args) { - return [0, 0, args[0]]; -}; - -convert.gray.hwb = function (gray) { - return [0, 100, gray[0]]; -}; - -convert.gray.cmyk = function (gray) { - return [0, 0, 0, gray[0]]; -}; - -convert.gray.lab = function (gray) { - return [gray[0], 0, 0]; -}; - -convert.gray.hex = function (gray) { - var val = Math.round(gray[0] / 100 * 255) & 0xFF; - var integer = (val << 16) + (val << 8) + val; - - var string = integer.toString(16).toUpperCase(); - return '000000'.substring(string.length) + string; -}; - -convert.rgb.gray = function (rgb) { - var val = (rgb[0] + rgb[1] + rgb[2]) / 3; - return [val / 255 * 100]; -}; diff --git a/tools/eslint/node_modules/color-convert/index.js b/tools/eslint/node_modules/color-convert/index.js deleted file mode 100644 index e65b5d775da353..00000000000000 --- a/tools/eslint/node_modules/color-convert/index.js +++ /dev/null @@ -1,78 +0,0 @@ -var conversions = require('./conversions'); -var route = require('./route'); - -var convert = {}; - -var models = Object.keys(conversions); - -function wrapRaw(fn) { - var wrappedFn = function (args) { - if (args === undefined || args === null) { - return args; - } - - if (arguments.length > 1) { - args = Array.prototype.slice.call(arguments); - } - - return fn(args); - }; - - // preserve .conversion property if there is one - if ('conversion' in fn) { - wrappedFn.conversion = fn.conversion; - } - - return wrappedFn; -} - -function wrapRounded(fn) { - var wrappedFn = function (args) { - if (args === undefined || args === null) { - return args; - } - - if (arguments.length > 1) { - args = Array.prototype.slice.call(arguments); - } - - var result = fn(args); - - // we're assuming the result is an array here. - // see notice in conversions.js; don't use box types - // in conversion functions. - if (typeof result === 'object') { - for (var len = result.length, i = 0; i < len; i++) { - result[i] = Math.round(result[i]); - } - } - - return result; - }; - - // preserve .conversion property if there is one - if ('conversion' in fn) { - wrappedFn.conversion = fn.conversion; - } - - return wrappedFn; -} - -models.forEach(function (fromModel) { - convert[fromModel] = {}; - - Object.defineProperty(convert[fromModel], 'channels', {value: conversions[fromModel].channels}); - Object.defineProperty(convert[fromModel], 'labels', {value: conversions[fromModel].labels}); - - var routes = route(fromModel); - var routeModels = Object.keys(routes); - - routeModels.forEach(function (toModel) { - var fn = routes[toModel]; - - convert[fromModel][toModel] = wrapRounded(fn); - convert[fromModel][toModel].raw = wrapRaw(fn); - }); -}); - -module.exports = convert; diff --git a/tools/eslint/node_modules/color-convert/package.json b/tools/eslint/node_modules/color-convert/package.json deleted file mode 100644 index dfbc471407ff4c..00000000000000 --- a/tools/eslint/node_modules/color-convert/package.json +++ /dev/null @@ -1,46 +0,0 @@ -{ - "name": "color-convert", - "description": "Plain color conversion functions", - "version": "1.9.3", - "author": "Heather Arthur ", - "license": "MIT", - "repository": "Qix-/color-convert", - "scripts": { - "pretest": "xo", - "test": "node test/basic.js" - }, - "keywords": [ - "color", - "colour", - "convert", - "converter", - "conversion", - "rgb", - "hsl", - "hsv", - "hwb", - "cmyk", - "ansi", - "ansi16" - ], - "files": [ - "index.js", - "conversions.js", - "css-keywords.js", - "route.js" - ], - "xo": { - "rules": { - "default-case": 0, - "no-inline-comments": 0, - "operator-linebreak": 0 - } - }, - "devDependencies": { - "chalk": "1.1.1", - "xo": "0.11.2" - }, - "dependencies": { - "color-name": "1.1.3" - } -} diff --git a/tools/eslint/node_modules/color-convert/route.js b/tools/eslint/node_modules/color-convert/route.js deleted file mode 100644 index 0a1fdea689e2a7..00000000000000 --- a/tools/eslint/node_modules/color-convert/route.js +++ /dev/null @@ -1,97 +0,0 @@ -var conversions = require('./conversions'); - -/* - this function routes a model to all other models. - - all functions that are routed have a property `.conversion` attached - to the returned synthetic function. This property is an array - of strings, each with the steps in between the 'from' and 'to' - color models (inclusive). - - conversions that are not possible simply are not included. -*/ - -function buildGraph() { - var graph = {}; - // https://jsperf.com/object-keys-vs-for-in-with-closure/3 - var models = Object.keys(conversions); - - for (var len = models.length, i = 0; i < len; i++) { - graph[models[i]] = { - // http://jsperf.com/1-vs-infinity - // micro-opt, but this is simple. - distance: -1, - parent: null - }; - } - - return graph; -} - -// https://en.wikipedia.org/wiki/Breadth-first_search -function deriveBFS(fromModel) { - var graph = buildGraph(); - var queue = [fromModel]; // unshift -> queue -> pop - - graph[fromModel].distance = 0; - - while (queue.length) { - var current = queue.pop(); - var adjacents = Object.keys(conversions[current]); - - for (var len = adjacents.length, i = 0; i < len; i++) { - var adjacent = adjacents[i]; - var node = graph[adjacent]; - - if (node.distance === -1) { - node.distance = graph[current].distance + 1; - node.parent = current; - queue.unshift(adjacent); - } - } - } - - return graph; -} - -function link(from, to) { - return function (args) { - return to(from(args)); - }; -} - -function wrapConversion(toModel, graph) { - var path = [graph[toModel].parent, toModel]; - var fn = conversions[graph[toModel].parent][toModel]; - - var cur = graph[toModel].parent; - while (graph[cur].parent) { - path.unshift(graph[cur].parent); - fn = link(conversions[graph[cur].parent][cur], fn); - cur = graph[cur].parent; - } - - fn.conversion = path; - return fn; -} - -module.exports = function (fromModel) { - var graph = deriveBFS(fromModel); - var conversion = {}; - - var models = Object.keys(graph); - for (var len = models.length, i = 0; i < len; i++) { - var toModel = models[i]; - var node = graph[toModel]; - - if (node.parent === null) { - // no possible conversion, or this node is the source model. - continue; - } - - conversion[toModel] = wrapConversion(toModel, graph); - } - - return conversion; -}; - diff --git a/tools/eslint/node_modules/color-name/LICENSE b/tools/eslint/node_modules/color-name/LICENSE deleted file mode 100644 index c6b10012540c24..00000000000000 --- a/tools/eslint/node_modules/color-name/LICENSE +++ /dev/null @@ -1,8 +0,0 @@ -The MIT License (MIT) -Copyright (c) 2015 Dmitry Ivanov - -Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. \ No newline at end of file diff --git a/tools/eslint/node_modules/color-name/index.js b/tools/eslint/node_modules/color-name/index.js deleted file mode 100644 index b7c198a6f3d7c5..00000000000000 --- a/tools/eslint/node_modules/color-name/index.js +++ /dev/null @@ -1,152 +0,0 @@ -'use strict' - -module.exports = { - "aliceblue": [240, 248, 255], - "antiquewhite": [250, 235, 215], - "aqua": [0, 255, 255], - "aquamarine": [127, 255, 212], - "azure": [240, 255, 255], - "beige": [245, 245, 220], - "bisque": [255, 228, 196], - "black": [0, 0, 0], - "blanchedalmond": [255, 235, 205], - "blue": [0, 0, 255], - "blueviolet": [138, 43, 226], - "brown": [165, 42, 42], - "burlywood": [222, 184, 135], - "cadetblue": [95, 158, 160], - "chartreuse": [127, 255, 0], - "chocolate": [210, 105, 30], - "coral": [255, 127, 80], - "cornflowerblue": [100, 149, 237], - "cornsilk": [255, 248, 220], - "crimson": [220, 20, 60], - "cyan": [0, 255, 255], - "darkblue": [0, 0, 139], - "darkcyan": [0, 139, 139], - "darkgoldenrod": [184, 134, 11], - "darkgray": [169, 169, 169], - "darkgreen": [0, 100, 0], - "darkgrey": [169, 169, 169], - "darkkhaki": [189, 183, 107], - "darkmagenta": [139, 0, 139], - "darkolivegreen": [85, 107, 47], - "darkorange": [255, 140, 0], - "darkorchid": [153, 50, 204], - "darkred": [139, 0, 0], - "darksalmon": [233, 150, 122], - "darkseagreen": [143, 188, 143], - "darkslateblue": [72, 61, 139], - "darkslategray": [47, 79, 79], - "darkslategrey": [47, 79, 79], - "darkturquoise": [0, 206, 209], - "darkviolet": [148, 0, 211], - "deeppink": [255, 20, 147], - "deepskyblue": [0, 191, 255], - "dimgray": [105, 105, 105], - "dimgrey": [105, 105, 105], - "dodgerblue": [30, 144, 255], - "firebrick": [178, 34, 34], - "floralwhite": [255, 250, 240], - "forestgreen": [34, 139, 34], - "fuchsia": [255, 0, 255], - "gainsboro": [220, 220, 220], - "ghostwhite": [248, 248, 255], - "gold": [255, 215, 0], - "goldenrod": [218, 165, 32], - "gray": [128, 128, 128], - "green": [0, 128, 0], - "greenyellow": [173, 255, 47], - "grey": [128, 128, 128], - "honeydew": [240, 255, 240], - "hotpink": [255, 105, 180], - "indianred": [205, 92, 92], - "indigo": [75, 0, 130], - "ivory": [255, 255, 240], - "khaki": [240, 230, 140], - "lavender": [230, 230, 250], - "lavenderblush": [255, 240, 245], - "lawngreen": [124, 252, 0], - "lemonchiffon": [255, 250, 205], - "lightblue": [173, 216, 230], - "lightcoral": [240, 128, 128], - "lightcyan": [224, 255, 255], - "lightgoldenrodyellow": [250, 250, 210], - "lightgray": [211, 211, 211], - "lightgreen": [144, 238, 144], - "lightgrey": [211, 211, 211], - "lightpink": [255, 182, 193], - "lightsalmon": [255, 160, 122], - "lightseagreen": [32, 178, 170], - "lightskyblue": [135, 206, 250], - "lightslategray": [119, 136, 153], - "lightslategrey": [119, 136, 153], - "lightsteelblue": [176, 196, 222], - "lightyellow": [255, 255, 224], - "lime": [0, 255, 0], - "limegreen": [50, 205, 50], - "linen": [250, 240, 230], - "magenta": [255, 0, 255], - "maroon": [128, 0, 0], - "mediumaquamarine": [102, 205, 170], - "mediumblue": [0, 0, 205], - "mediumorchid": [186, 85, 211], - "mediumpurple": [147, 112, 219], - "mediumseagreen": [60, 179, 113], - "mediumslateblue": [123, 104, 238], - "mediumspringgreen": [0, 250, 154], - "mediumturquoise": [72, 209, 204], - "mediumvioletred": [199, 21, 133], - "midnightblue": [25, 25, 112], - "mintcream": [245, 255, 250], - "mistyrose": [255, 228, 225], - "moccasin": [255, 228, 181], - "navajowhite": [255, 222, 173], - "navy": [0, 0, 128], - "oldlace": [253, 245, 230], - "olive": [128, 128, 0], - "olivedrab": [107, 142, 35], - "orange": [255, 165, 0], - "orangered": [255, 69, 0], - "orchid": [218, 112, 214], - "palegoldenrod": [238, 232, 170], - "palegreen": [152, 251, 152], - "paleturquoise": [175, 238, 238], - "palevioletred": [219, 112, 147], - "papayawhip": [255, 239, 213], - "peachpuff": [255, 218, 185], - "peru": [205, 133, 63], - "pink": [255, 192, 203], - "plum": [221, 160, 221], - "powderblue": [176, 224, 230], - "purple": [128, 0, 128], - "rebeccapurple": [102, 51, 153], - "red": [255, 0, 0], - "rosybrown": [188, 143, 143], - "royalblue": [65, 105, 225], - "saddlebrown": [139, 69, 19], - "salmon": [250, 128, 114], - "sandybrown": [244, 164, 96], - "seagreen": [46, 139, 87], - "seashell": [255, 245, 238], - "sienna": [160, 82, 45], - "silver": [192, 192, 192], - "skyblue": [135, 206, 235], - "slateblue": [106, 90, 205], - "slategray": [112, 128, 144], - "slategrey": [112, 128, 144], - "snow": [255, 250, 250], - "springgreen": [0, 255, 127], - "steelblue": [70, 130, 180], - "tan": [210, 180, 140], - "teal": [0, 128, 128], - "thistle": [216, 191, 216], - "tomato": [255, 99, 71], - "turquoise": [64, 224, 208], - "violet": [238, 130, 238], - "wheat": [245, 222, 179], - "white": [255, 255, 255], - "whitesmoke": [245, 245, 245], - "yellow": [255, 255, 0], - "yellowgreen": [154, 205, 50] -}; diff --git a/tools/eslint/node_modules/color-name/package.json b/tools/eslint/node_modules/color-name/package.json deleted file mode 100644 index d061123ef02f40..00000000000000 --- a/tools/eslint/node_modules/color-name/package.json +++ /dev/null @@ -1,25 +0,0 @@ -{ - "name": "color-name", - "version": "1.1.3", - "description": "A list of color names and its values", - "main": "index.js", - "scripts": { - "test": "node test.js" - }, - "repository": { - "type": "git", - "url": "git@github.com:dfcreative/color-name.git" - }, - "keywords": [ - "color-name", - "color", - "color-keyword", - "keyword" - ], - "author": "DY ", - "license": "MIT", - "bugs": { - "url": "https://github.com/dfcreative/color-name/issues" - }, - "homepage": "https://github.com/dfcreative/color-name" -} diff --git a/tools/eslint/node_modules/comment-parser/LICENSE b/tools/eslint/node_modules/comment-parser/LICENSE deleted file mode 100644 index c91d3e722ea663..00000000000000 --- a/tools/eslint/node_modules/comment-parser/LICENSE +++ /dev/null @@ -1,21 +0,0 @@ -The MIT License (MIT) - -Copyright (c) 2014 Sergii Iavorskyi - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. \ No newline at end of file diff --git a/tools/eslint/node_modules/comment-parser/browser/index.js b/tools/eslint/node_modules/comment-parser/browser/index.js deleted file mode 100644 index 1a17905c63c64c..00000000000000 --- a/tools/eslint/node_modules/comment-parser/browser/index.js +++ /dev/null @@ -1,650 +0,0 @@ -var CommentParser = (function (exports) { - 'use strict'; - - /** @deprecated */ - exports.Markers = void 0; - (function (Markers) { - Markers["start"] = "/**"; - Markers["nostart"] = "/***"; - Markers["delim"] = "*"; - Markers["end"] = "*/"; - })(exports.Markers = exports.Markers || (exports.Markers = {})); - - function isSpace(source) { - return /^\s+$/.test(source); - } - function splitCR(source) { - const matches = source.match(/\r+$/); - return matches == null - ? ['', source] - : [source.slice(-matches[0].length), source.slice(0, -matches[0].length)]; - } - function splitSpace(source) { - const matches = source.match(/^\s+/); - return matches == null - ? ['', source] - : [source.slice(0, matches[0].length), source.slice(matches[0].length)]; - } - function splitLines(source) { - return source.split(/\n/); - } - function seedBlock(block = {}) { - return Object.assign({ description: '', tags: [], source: [], problems: [] }, block); - } - function seedSpec(spec = {}) { - return Object.assign({ tag: '', name: '', type: '', optional: false, description: '', problems: [], source: [] }, spec); - } - function seedTokens(tokens = {}) { - return Object.assign({ start: '', delimiter: '', postDelimiter: '', tag: '', postTag: '', name: '', postName: '', type: '', postType: '', description: '', end: '', lineEnd: '' }, tokens); - } - /** - * Assures Block.tags[].source contains references to the Block.source items, - * using Block.source as a source of truth. This is a counterpart of rewireSpecs - * @param block parsed coments block - */ - function rewireSource(block) { - const source = block.source.reduce((acc, line) => acc.set(line.number, line), new Map()); - for (const spec of block.tags) { - spec.source = spec.source.map((line) => source.get(line.number)); - } - return block; - } - /** - * Assures Block.source contains references to the Block.tags[].source items, - * using Block.tags[].source as a source of truth. This is a counterpart of rewireSource - * @param block parsed coments block - */ - function rewireSpecs(block) { - const source = block.tags.reduce((acc, spec) => spec.source.reduce((acc, line) => acc.set(line.number, line), acc), new Map()); - block.source = block.source.map((line) => source.get(line.number) || line); - return block; - } - - const reTag = /^@\S+/; - /** - * Creates configured `Parser` - * @param {Partial} options - */ - function getParser$3({ fence = '```', } = {}) { - const fencer = getFencer(fence); - const toggleFence = (source, isFenced) => fencer(source) ? !isFenced : isFenced; - return function parseBlock(source) { - // start with description section - const sections = [[]]; - let isFenced = false; - for (const line of source) { - if (reTag.test(line.tokens.description) && !isFenced) { - sections.push([line]); - } - else { - sections[sections.length - 1].push(line); - } - isFenced = toggleFence(line.tokens.description, isFenced); - } - return sections; - }; - } - function getFencer(fence) { - if (typeof fence === 'string') - return (source) => source.split(fence).length % 2 === 0; - return fence; - } - - function getParser$2({ startLine = 0, markers = exports.Markers, } = {}) { - let block = null; - let num = startLine; - return function parseSource(source) { - let rest = source; - const tokens = seedTokens(); - [tokens.lineEnd, rest] = splitCR(rest); - [tokens.start, rest] = splitSpace(rest); - if (block === null && - rest.startsWith(markers.start) && - !rest.startsWith(markers.nostart)) { - block = []; - tokens.delimiter = rest.slice(0, markers.start.length); - rest = rest.slice(markers.start.length); - [tokens.postDelimiter, rest] = splitSpace(rest); - } - if (block === null) { - num++; - return null; - } - const isClosed = rest.trimRight().endsWith(markers.end); - if (tokens.delimiter === '' && - rest.startsWith(markers.delim) && - !rest.startsWith(markers.end)) { - tokens.delimiter = markers.delim; - rest = rest.slice(markers.delim.length); - [tokens.postDelimiter, rest] = splitSpace(rest); - } - if (isClosed) { - const trimmed = rest.trimRight(); - tokens.end = rest.slice(trimmed.length - markers.end.length); - rest = trimmed.slice(0, -markers.end.length); - } - tokens.description = rest; - block.push({ number: num, source, tokens }); - num++; - if (isClosed) { - const result = block.slice(); - block = null; - return result; - } - return null; - }; - } - - function getParser$1({ tokenizers }) { - return function parseSpec(source) { - var _a; - let spec = seedSpec({ source }); - for (const tokenize of tokenizers) { - spec = tokenize(spec); - if ((_a = spec.problems[spec.problems.length - 1]) === null || _a === void 0 ? void 0 : _a.critical) - break; - } - return spec; - }; - } - - /** - * Splits the `@prefix` from remaining `Spec.lines[].token.description` into the `tag` token, - * and populates `spec.tag` - */ - function tagTokenizer() { - return (spec) => { - const { tokens } = spec.source[0]; - const match = tokens.description.match(/\s*(@(\S+))(\s*)/); - if (match === null) { - spec.problems.push({ - code: 'spec:tag:prefix', - message: 'tag should start with "@" symbol', - line: spec.source[0].number, - critical: true, - }); - return spec; - } - tokens.tag = match[1]; - tokens.postTag = match[3]; - tokens.description = tokens.description.slice(match[0].length); - spec.tag = match[2]; - return spec; - }; - } - - /** - * Sets splits remaining `Spec.lines[].tokes.description` into `type` and `description` - * tokens and populates Spec.type` - * - * @param {Spacing} spacing tells how to deal with a whitespace - * for type values going over multiple lines - */ - function typeTokenizer(spacing = 'compact') { - const join = getJoiner$1(spacing); - return (spec) => { - let curlies = 0; - let lines = []; - for (const [i, { tokens }] of spec.source.entries()) { - let type = ''; - if (i === 0 && tokens.description[0] !== '{') - return spec; - for (const ch of tokens.description) { - if (ch === '{') - curlies++; - if (ch === '}') - curlies--; - type += ch; - if (curlies === 0) - break; - } - lines.push([tokens, type]); - if (curlies === 0) - break; - } - if (curlies !== 0) { - spec.problems.push({ - code: 'spec:type:unpaired-curlies', - message: 'unpaired curlies', - line: spec.source[0].number, - critical: true, - }); - return spec; - } - const parts = []; - const offset = lines[0][0].postDelimiter.length; - for (const [i, [tokens, type]] of lines.entries()) { - tokens.type = type; - if (i > 0) { - tokens.type = tokens.postDelimiter.slice(offset) + type; - tokens.postDelimiter = tokens.postDelimiter.slice(0, offset); - } - [tokens.postType, tokens.description] = splitSpace(tokens.description.slice(type.length)); - parts.push(tokens.type); - } - parts[0] = parts[0].slice(1); - parts[parts.length - 1] = parts[parts.length - 1].slice(0, -1); - spec.type = join(parts); - return spec; - }; - } - const trim = (x) => x.trim(); - function getJoiner$1(spacing) { - if (spacing === 'compact') - return (t) => t.map(trim).join(''); - else if (spacing === 'preserve') - return (t) => t.join('\n'); - else - return spacing; - } - - const isQuoted = (s) => s && s.startsWith('"') && s.endsWith('"'); - /** - * Splits remaining `spec.lines[].tokens.description` into `name` and `descriptions` tokens, - * and populates the `spec.name` - */ - function nameTokenizer() { - const typeEnd = (num, { tokens }, i) => tokens.type === '' ? num : i; - return (spec) => { - // look for the name in the line where {type} ends - const { tokens } = spec.source[spec.source.reduce(typeEnd, 0)]; - const source = tokens.description.trimLeft(); - const quotedGroups = source.split('"'); - // if it starts with quoted group, assume it is a literal - if (quotedGroups.length > 1 && - quotedGroups[0] === '' && - quotedGroups.length % 2 === 1) { - spec.name = quotedGroups[1]; - tokens.name = `"${quotedGroups[1]}"`; - [tokens.postName, tokens.description] = splitSpace(source.slice(tokens.name.length)); - return spec; - } - let brackets = 0; - let name = ''; - let optional = false; - let defaultValue; - // assume name is non-space string or anything wrapped into brackets - for (const ch of source) { - if (brackets === 0 && isSpace(ch)) - break; - if (ch === '[') - brackets++; - if (ch === ']') - brackets--; - name += ch; - } - if (brackets !== 0) { - spec.problems.push({ - code: 'spec:name:unpaired-brackets', - message: 'unpaired brackets', - line: spec.source[0].number, - critical: true, - }); - return spec; - } - const nameToken = name; - if (name[0] === '[' && name[name.length - 1] === ']') { - optional = true; - name = name.slice(1, -1); - const parts = name.split('='); - name = parts[0].trim(); - if (parts[1] !== undefined) - defaultValue = parts.slice(1).join('=').trim(); - if (name === '') { - spec.problems.push({ - code: 'spec:name:empty-name', - message: 'empty name', - line: spec.source[0].number, - critical: true, - }); - return spec; - } - if (defaultValue === '') { - spec.problems.push({ - code: 'spec:name:empty-default', - message: 'empty default value', - line: spec.source[0].number, - critical: true, - }); - return spec; - } - // has "=" and is not a string, except for "=>" - if (!isQuoted(defaultValue) && /=(?!>)/.test(defaultValue)) { - spec.problems.push({ - code: 'spec:name:invalid-default', - message: 'invalid default value syntax', - line: spec.source[0].number, - critical: true, - }); - return spec; - } - } - spec.optional = optional; - spec.name = name; - tokens.name = nameToken; - if (defaultValue !== undefined) - spec.default = defaultValue; - [tokens.postName, tokens.description] = splitSpace(source.slice(tokens.name.length)); - return spec; - }; - } - - /** - * Makes no changes to `spec.lines[].tokens` but joins them into `spec.description` - * following given spacing srtategy - * @param {Spacing} spacing tells how to handle the whitespace - * @param {BlockMarkers} markers tells how to handle comment block delimitation - */ - function descriptionTokenizer(spacing = 'compact', markers = exports.Markers) { - const join = getJoiner(spacing); - return (spec) => { - spec.description = join(spec.source, markers); - return spec; - }; - } - function getJoiner(spacing) { - if (spacing === 'compact') - return compactJoiner; - if (spacing === 'preserve') - return preserveJoiner; - return spacing; - } - function compactJoiner(lines, markers = exports.Markers) { - return lines - .map(({ tokens: { description } }) => description.trim()) - .filter((description) => description !== '') - .join(' '); - } - const lineNo = (num, { tokens }, i) => tokens.type === '' ? num : i; - const getDescription = ({ tokens }) => (tokens.delimiter === '' ? tokens.start : tokens.postDelimiter.slice(1)) + - tokens.description; - function preserveJoiner(lines, markers = exports.Markers) { - if (lines.length === 0) - return ''; - // skip the opening line with no description - if (lines[0].tokens.description === '' && - lines[0].tokens.delimiter === markers.start) - lines = lines.slice(1); - // skip the closing line with no description - const lastLine = lines[lines.length - 1]; - if (lastLine !== undefined && - lastLine.tokens.description === '' && - lastLine.tokens.end.endsWith(markers.end)) - lines = lines.slice(0, -1); - // description starts at the last line of type definition - lines = lines.slice(lines.reduce(lineNo, 0)); - return lines.map(getDescription).join('\n'); - } - - function getParser({ startLine = 0, fence = '```', spacing = 'compact', markers = exports.Markers, tokenizers = [ - tagTokenizer(), - typeTokenizer(spacing), - nameTokenizer(), - descriptionTokenizer(spacing), - ], } = {}) { - if (startLine < 0 || startLine % 1 > 0) - throw new Error('Invalid startLine'); - const parseSource = getParser$2({ startLine, markers }); - const parseBlock = getParser$3({ fence }); - const parseSpec = getParser$1({ tokenizers }); - const joinDescription = getJoiner(spacing); - return function (source) { - const blocks = []; - for (const line of splitLines(source)) { - const lines = parseSource(line); - if (lines === null) - continue; - const sections = parseBlock(lines); - const specs = sections.slice(1).map(parseSpec); - blocks.push({ - description: joinDescription(sections[0], markers), - tags: specs, - source: lines, - problems: specs.reduce((acc, spec) => acc.concat(spec.problems), []), - }); - } - return blocks; - }; - } - - function join(tokens) { - return (tokens.start + - tokens.delimiter + - tokens.postDelimiter + - tokens.tag + - tokens.postTag + - tokens.type + - tokens.postType + - tokens.name + - tokens.postName + - tokens.description + - tokens.end + - tokens.lineEnd); - } - function getStringifier() { - return (block) => block.source.map(({ tokens }) => join(tokens)).join('\n'); - } - - var __rest$2 = (window && window.__rest) || function (s, e) { - var t = {}; - for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) - t[p] = s[p]; - if (s != null && typeof Object.getOwnPropertySymbols === "function") - for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) { - if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) - t[p[i]] = s[p[i]]; - } - return t; - }; - const zeroWidth$1 = { - start: 0, - tag: 0, - type: 0, - name: 0, - }; - const getWidth = (markers = exports.Markers) => (w, { tokens: t }) => ({ - start: t.delimiter === markers.start ? t.start.length : w.start, - tag: Math.max(w.tag, t.tag.length), - type: Math.max(w.type, t.type.length), - name: Math.max(w.name, t.name.length), - }); - const space = (len) => ''.padStart(len, ' '); - function align$1(markers = exports.Markers) { - let intoTags = false; - let w; - function update(line) { - const tokens = Object.assign({}, line.tokens); - if (tokens.tag !== '') - intoTags = true; - const isEmpty = tokens.tag === '' && - tokens.name === '' && - tokens.type === '' && - tokens.description === ''; - // dangling '*/' - if (tokens.end === markers.end && isEmpty) { - tokens.start = space(w.start + 1); - return Object.assign(Object.assign({}, line), { tokens }); - } - switch (tokens.delimiter) { - case markers.start: - tokens.start = space(w.start); - break; - case markers.delim: - tokens.start = space(w.start + 1); - break; - default: - tokens.delimiter = ''; - tokens.start = space(w.start + 2); // compensate delimiter - } - if (!intoTags) { - tokens.postDelimiter = tokens.description === '' ? '' : ' '; - return Object.assign(Object.assign({}, line), { tokens }); - } - const nothingAfter = { - delim: false, - tag: false, - type: false, - name: false, - }; - if (tokens.description === '') { - nothingAfter.name = true; - tokens.postName = ''; - if (tokens.name === '') { - nothingAfter.type = true; - tokens.postType = ''; - if (tokens.type === '') { - nothingAfter.tag = true; - tokens.postTag = ''; - if (tokens.tag === '') { - nothingAfter.delim = true; - } - } - } - } - tokens.postDelimiter = nothingAfter.delim ? '' : ' '; - if (!nothingAfter.tag) - tokens.postTag = space(w.tag - tokens.tag.length + 1); - if (!nothingAfter.type) - tokens.postType = space(w.type - tokens.type.length + 1); - if (!nothingAfter.name) - tokens.postName = space(w.name - tokens.name.length + 1); - return Object.assign(Object.assign({}, line), { tokens }); - } - return (_a) => { - var { source } = _a, fields = __rest$2(_a, ["source"]); - w = source.reduce(getWidth(markers), Object.assign({}, zeroWidth$1)); - return rewireSource(Object.assign(Object.assign({}, fields), { source: source.map(update) })); - }; - } - - var __rest$1 = (window && window.__rest) || function (s, e) { - var t = {}; - for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) - t[p] = s[p]; - if (s != null && typeof Object.getOwnPropertySymbols === "function") - for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) { - if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) - t[p[i]] = s[p[i]]; - } - return t; - }; - const pull = (offset) => (str) => str.slice(offset); - const push = (offset) => { - const space = ''.padStart(offset, ' '); - return (str) => str + space; - }; - function indent(pos) { - let shift; - const pad = (start) => { - if (shift === undefined) { - const offset = pos - start.length; - shift = offset > 0 ? push(offset) : pull(-offset); - } - return shift(start); - }; - const update = (line) => (Object.assign(Object.assign({}, line), { tokens: Object.assign(Object.assign({}, line.tokens), { start: pad(line.tokens.start) }) })); - return (_a) => { - var { source } = _a, fields = __rest$1(_a, ["source"]); - return rewireSource(Object.assign(Object.assign({}, fields), { source: source.map(update) })); - }; - } - - var __rest = (window && window.__rest) || function (s, e) { - var t = {}; - for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) - t[p] = s[p]; - if (s != null && typeof Object.getOwnPropertySymbols === "function") - for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) { - if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) - t[p[i]] = s[p[i]]; - } - return t; - }; - function crlf(ending) { - function update(line) { - return Object.assign(Object.assign({}, line), { tokens: Object.assign(Object.assign({}, line.tokens), { lineEnd: ending === 'LF' ? '' : '\r' }) }); - } - return (_a) => { - var { source } = _a, fields = __rest(_a, ["source"]); - return rewireSource(Object.assign(Object.assign({}, fields), { source: source.map(update) })); - }; - } - - function flow(...transforms) { - return (block) => transforms.reduce((block, t) => t(block), block); - } - - const zeroWidth = { - line: 0, - start: 0, - delimiter: 0, - postDelimiter: 0, - tag: 0, - postTag: 0, - name: 0, - postName: 0, - type: 0, - postType: 0, - description: 0, - end: 0, - lineEnd: 0, - }; - const headers = { lineEnd: 'CR' }; - const fields = Object.keys(zeroWidth); - const repr = (x) => (isSpace(x) ? `{${x.length}}` : x); - const frame = (line) => '|' + line.join('|') + '|'; - const align = (width, tokens) => Object.keys(tokens).map((k) => repr(tokens[k]).padEnd(width[k])); - function inspect({ source }) { - var _a, _b; - if (source.length === 0) - return ''; - const width = Object.assign({}, zeroWidth); - for (const f of fields) - width[f] = ((_a = headers[f]) !== null && _a !== void 0 ? _a : f).length; - for (const { number, tokens } of source) { - width.line = Math.max(width.line, number.toString().length); - for (const k in tokens) - width[k] = Math.max(width[k], repr(tokens[k]).length); - } - const lines = [[], []]; - for (const f of fields) - lines[0].push(((_b = headers[f]) !== null && _b !== void 0 ? _b : f).padEnd(width[f])); - for (const f of fields) - lines[1].push('-'.padEnd(width[f], '-')); - for (const { number, tokens } of source) { - const line = number.toString().padStart(width.line); - lines.push([line, ...align(width, tokens)]); - } - return lines.map(frame).join('\n'); - } - - function parse(source, options = {}) { - return getParser(options)(source); - } - const stringify = getStringifier(); - const transforms = { - flow: flow, - align: align$1, - indent: indent, - crlf: crlf, - }; - const tokenizers = { - tag: tagTokenizer, - type: typeTokenizer, - name: nameTokenizer, - description: descriptionTokenizer, - }; - const util = { rewireSpecs, rewireSource, seedBlock, seedTokens }; - - exports.inspect = inspect; - exports.parse = parse; - exports.stringify = stringify; - exports.tokenizers = tokenizers; - exports.transforms = transforms; - exports.util = util; - - Object.defineProperty(exports, '__esModule', { value: true }); - - return exports; - -}({})); diff --git a/tools/eslint/node_modules/comment-parser/es6/index.js b/tools/eslint/node_modules/comment-parser/es6/index.js deleted file mode 100644 index 6b6c4751396e20..00000000000000 --- a/tools/eslint/node_modules/comment-parser/es6/index.js +++ /dev/null @@ -1,30 +0,0 @@ -import getParser from './parser/index.js'; -import descriptionTokenizer from './parser/tokenizers/description.js'; -import nameTokenizer from './parser/tokenizers/name.js'; -import tagTokenizer from './parser/tokenizers/tag.js'; -import typeTokenizer from './parser/tokenizers/type.js'; -import getStringifier from './stringifier/index.js'; -import alignTransform from './transforms/align.js'; -import indentTransform from './transforms/indent.js'; -import crlfTransform from './transforms/crlf.js'; -import { flow as flowTransform } from './transforms/index.js'; -import { rewireSpecs, rewireSource, seedBlock, seedTokens } from './util.js'; -export * from './primitives.js'; -export function parse(source, options = {}) { - return getParser(options)(source); -} -export const stringify = getStringifier(); -export { default as inspect } from './stringifier/inspect.js'; -export const transforms = { - flow: flowTransform, - align: alignTransform, - indent: indentTransform, - crlf: crlfTransform, -}; -export const tokenizers = { - tag: tagTokenizer, - type: typeTokenizer, - name: nameTokenizer, - description: descriptionTokenizer, -}; -export const util = { rewireSpecs, rewireSource, seedBlock, seedTokens }; diff --git a/tools/eslint/node_modules/comment-parser/es6/parser/block-parser.js b/tools/eslint/node_modules/comment-parser/es6/parser/block-parser.js deleted file mode 100644 index 9c4a62bc845d13..00000000000000 --- a/tools/eslint/node_modules/comment-parser/es6/parser/block-parser.js +++ /dev/null @@ -1,29 +0,0 @@ -const reTag = /^@\S+/; -/** - * Creates configured `Parser` - * @param {Partial} options - */ -export default function getParser({ fence = '```', } = {}) { - const fencer = getFencer(fence); - const toggleFence = (source, isFenced) => fencer(source) ? !isFenced : isFenced; - return function parseBlock(source) { - // start with description section - const sections = [[]]; - let isFenced = false; - for (const line of source) { - if (reTag.test(line.tokens.description) && !isFenced) { - sections.push([line]); - } - else { - sections[sections.length - 1].push(line); - } - isFenced = toggleFence(line.tokens.description, isFenced); - } - return sections; - }; -} -function getFencer(fence) { - if (typeof fence === 'string') - return (source) => source.split(fence).length % 2 === 0; - return fence; -} diff --git a/tools/eslint/node_modules/comment-parser/es6/parser/index.js b/tools/eslint/node_modules/comment-parser/es6/parser/index.js deleted file mode 100644 index 236d23e844017b..00000000000000 --- a/tools/eslint/node_modules/comment-parser/es6/parser/index.js +++ /dev/null @@ -1,39 +0,0 @@ -import { Markers } from '../primitives.js'; -import { splitLines } from '../util.js'; -import blockParser from './block-parser.js'; -import sourceParser from './source-parser.js'; -import specParser from './spec-parser.js'; -import tokenizeTag from './tokenizers/tag.js'; -import tokenizeType from './tokenizers/type.js'; -import tokenizeName from './tokenizers/name.js'; -import tokenizeDescription, { getJoiner as getDescriptionJoiner, } from './tokenizers/description.js'; -export default function getParser({ startLine = 0, fence = '```', spacing = 'compact', markers = Markers, tokenizers = [ - tokenizeTag(), - tokenizeType(spacing), - tokenizeName(), - tokenizeDescription(spacing), -], } = {}) { - if (startLine < 0 || startLine % 1 > 0) - throw new Error('Invalid startLine'); - const parseSource = sourceParser({ startLine, markers }); - const parseBlock = blockParser({ fence }); - const parseSpec = specParser({ tokenizers }); - const joinDescription = getDescriptionJoiner(spacing); - return function (source) { - const blocks = []; - for (const line of splitLines(source)) { - const lines = parseSource(line); - if (lines === null) - continue; - const sections = parseBlock(lines); - const specs = sections.slice(1).map(parseSpec); - blocks.push({ - description: joinDescription(sections[0], markers), - tags: specs, - source: lines, - problems: specs.reduce((acc, spec) => acc.concat(spec.problems), []), - }); - } - return blocks; - }; -} diff --git a/tools/eslint/node_modules/comment-parser/es6/parser/source-parser.js b/tools/eslint/node_modules/comment-parser/es6/parser/source-parser.js deleted file mode 100644 index de1c95d5e8cbcf..00000000000000 --- a/tools/eslint/node_modules/comment-parser/es6/parser/source-parser.js +++ /dev/null @@ -1,46 +0,0 @@ -import { Markers } from '../primitives.js'; -import { seedTokens, splitSpace, splitCR } from '../util.js'; -export default function getParser({ startLine = 0, markers = Markers, } = {}) { - let block = null; - let num = startLine; - return function parseSource(source) { - let rest = source; - const tokens = seedTokens(); - [tokens.lineEnd, rest] = splitCR(rest); - [tokens.start, rest] = splitSpace(rest); - if (block === null && - rest.startsWith(markers.start) && - !rest.startsWith(markers.nostart)) { - block = []; - tokens.delimiter = rest.slice(0, markers.start.length); - rest = rest.slice(markers.start.length); - [tokens.postDelimiter, rest] = splitSpace(rest); - } - if (block === null) { - num++; - return null; - } - const isClosed = rest.trimRight().endsWith(markers.end); - if (tokens.delimiter === '' && - rest.startsWith(markers.delim) && - !rest.startsWith(markers.end)) { - tokens.delimiter = markers.delim; - rest = rest.slice(markers.delim.length); - [tokens.postDelimiter, rest] = splitSpace(rest); - } - if (isClosed) { - const trimmed = rest.trimRight(); - tokens.end = rest.slice(trimmed.length - markers.end.length); - rest = trimmed.slice(0, -markers.end.length); - } - tokens.description = rest; - block.push({ number: num, source, tokens }); - num++; - if (isClosed) { - const result = block.slice(); - block = null; - return result; - } - return null; - }; -} diff --git a/tools/eslint/node_modules/comment-parser/es6/parser/spec-parser.js b/tools/eslint/node_modules/comment-parser/es6/parser/spec-parser.js deleted file mode 100644 index 934e009052c5fc..00000000000000 --- a/tools/eslint/node_modules/comment-parser/es6/parser/spec-parser.js +++ /dev/null @@ -1,13 +0,0 @@ -import { seedSpec } from '../util.js'; -export default function getParser({ tokenizers }) { - return function parseSpec(source) { - var _a; - let spec = seedSpec({ source }); - for (const tokenize of tokenizers) { - spec = tokenize(spec); - if ((_a = spec.problems[spec.problems.length - 1]) === null || _a === void 0 ? void 0 : _a.critical) - break; - } - return spec; - }; -} diff --git a/tools/eslint/node_modules/comment-parser/es6/parser/tokenizers/description.js b/tools/eslint/node_modules/comment-parser/es6/parser/tokenizers/description.js deleted file mode 100644 index a74bc90bfaf5be..00000000000000 --- a/tools/eslint/node_modules/comment-parser/es6/parser/tokenizers/description.js +++ /dev/null @@ -1,47 +0,0 @@ -import { Markers } from '../../primitives.js'; -/** - * Makes no changes to `spec.lines[].tokens` but joins them into `spec.description` - * following given spacing srtategy - * @param {Spacing} spacing tells how to handle the whitespace - * @param {BlockMarkers} markers tells how to handle comment block delimitation - */ -export default function descriptionTokenizer(spacing = 'compact', markers = Markers) { - const join = getJoiner(spacing); - return (spec) => { - spec.description = join(spec.source, markers); - return spec; - }; -} -export function getJoiner(spacing) { - if (spacing === 'compact') - return compactJoiner; - if (spacing === 'preserve') - return preserveJoiner; - return spacing; -} -function compactJoiner(lines, markers = Markers) { - return lines - .map(({ tokens: { description } }) => description.trim()) - .filter((description) => description !== '') - .join(' '); -} -const lineNo = (num, { tokens }, i) => tokens.type === '' ? num : i; -const getDescription = ({ tokens }) => (tokens.delimiter === '' ? tokens.start : tokens.postDelimiter.slice(1)) + - tokens.description; -function preserveJoiner(lines, markers = Markers) { - if (lines.length === 0) - return ''; - // skip the opening line with no description - if (lines[0].tokens.description === '' && - lines[0].tokens.delimiter === markers.start) - lines = lines.slice(1); - // skip the closing line with no description - const lastLine = lines[lines.length - 1]; - if (lastLine !== undefined && - lastLine.tokens.description === '' && - lastLine.tokens.end.endsWith(markers.end)) - lines = lines.slice(0, -1); - // description starts at the last line of type definition - lines = lines.slice(lines.reduce(lineNo, 0)); - return lines.map(getDescription).join('\n'); -} diff --git a/tools/eslint/node_modules/comment-parser/es6/parser/tokenizers/index.js b/tools/eslint/node_modules/comment-parser/es6/parser/tokenizers/index.js deleted file mode 100644 index cb0ff5c3b541f6..00000000000000 --- a/tools/eslint/node_modules/comment-parser/es6/parser/tokenizers/index.js +++ /dev/null @@ -1 +0,0 @@ -export {}; diff --git a/tools/eslint/node_modules/comment-parser/es6/parser/tokenizers/name.js b/tools/eslint/node_modules/comment-parser/es6/parser/tokenizers/name.js deleted file mode 100644 index ec1b44717bccb6..00000000000000 --- a/tools/eslint/node_modules/comment-parser/es6/parser/tokenizers/name.js +++ /dev/null @@ -1,91 +0,0 @@ -import { splitSpace, isSpace } from '../../util.js'; -const isQuoted = (s) => s && s.startsWith('"') && s.endsWith('"'); -/** - * Splits remaining `spec.lines[].tokens.description` into `name` and `descriptions` tokens, - * and populates the `spec.name` - */ -export default function nameTokenizer() { - const typeEnd = (num, { tokens }, i) => tokens.type === '' ? num : i; - return (spec) => { - // look for the name in the line where {type} ends - const { tokens } = spec.source[spec.source.reduce(typeEnd, 0)]; - const source = tokens.description.trimLeft(); - const quotedGroups = source.split('"'); - // if it starts with quoted group, assume it is a literal - if (quotedGroups.length > 1 && - quotedGroups[0] === '' && - quotedGroups.length % 2 === 1) { - spec.name = quotedGroups[1]; - tokens.name = `"${quotedGroups[1]}"`; - [tokens.postName, tokens.description] = splitSpace(source.slice(tokens.name.length)); - return spec; - } - let brackets = 0; - let name = ''; - let optional = false; - let defaultValue; - // assume name is non-space string or anything wrapped into brackets - for (const ch of source) { - if (brackets === 0 && isSpace(ch)) - break; - if (ch === '[') - brackets++; - if (ch === ']') - brackets--; - name += ch; - } - if (brackets !== 0) { - spec.problems.push({ - code: 'spec:name:unpaired-brackets', - message: 'unpaired brackets', - line: spec.source[0].number, - critical: true, - }); - return spec; - } - const nameToken = name; - if (name[0] === '[' && name[name.length - 1] === ']') { - optional = true; - name = name.slice(1, -1); - const parts = name.split('='); - name = parts[0].trim(); - if (parts[1] !== undefined) - defaultValue = parts.slice(1).join('=').trim(); - if (name === '') { - spec.problems.push({ - code: 'spec:name:empty-name', - message: 'empty name', - line: spec.source[0].number, - critical: true, - }); - return spec; - } - if (defaultValue === '') { - spec.problems.push({ - code: 'spec:name:empty-default', - message: 'empty default value', - line: spec.source[0].number, - critical: true, - }); - return spec; - } - // has "=" and is not a string, except for "=>" - if (!isQuoted(defaultValue) && /=(?!>)/.test(defaultValue)) { - spec.problems.push({ - code: 'spec:name:invalid-default', - message: 'invalid default value syntax', - line: spec.source[0].number, - critical: true, - }); - return spec; - } - } - spec.optional = optional; - spec.name = name; - tokens.name = nameToken; - if (defaultValue !== undefined) - spec.default = defaultValue; - [tokens.postName, tokens.description] = splitSpace(source.slice(tokens.name.length)); - return spec; - }; -} diff --git a/tools/eslint/node_modules/comment-parser/es6/parser/tokenizers/tag.js b/tools/eslint/node_modules/comment-parser/es6/parser/tokenizers/tag.js deleted file mode 100644 index adbea116d2c6c5..00000000000000 --- a/tools/eslint/node_modules/comment-parser/es6/parser/tokenizers/tag.js +++ /dev/null @@ -1,24 +0,0 @@ -/** - * Splits the `@prefix` from remaining `Spec.lines[].token.description` into the `tag` token, - * and populates `spec.tag` - */ -export default function tagTokenizer() { - return (spec) => { - const { tokens } = spec.source[0]; - const match = tokens.description.match(/\s*(@(\S+))(\s*)/); - if (match === null) { - spec.problems.push({ - code: 'spec:tag:prefix', - message: 'tag should start with "@" symbol', - line: spec.source[0].number, - critical: true, - }); - return spec; - } - tokens.tag = match[1]; - tokens.postTag = match[3]; - tokens.description = tokens.description.slice(match[0].length); - spec.tag = match[2]; - return spec; - }; -} diff --git a/tools/eslint/node_modules/comment-parser/es6/parser/tokenizers/type.js b/tools/eslint/node_modules/comment-parser/es6/parser/tokenizers/type.js deleted file mode 100644 index b084603d76314c..00000000000000 --- a/tools/eslint/node_modules/comment-parser/es6/parser/tokenizers/type.js +++ /dev/null @@ -1,65 +0,0 @@ -import { splitSpace } from '../../util.js'; -/** - * Sets splits remaining `Spec.lines[].tokes.description` into `type` and `description` - * tokens and populates Spec.type` - * - * @param {Spacing} spacing tells how to deal with a whitespace - * for type values going over multiple lines - */ -export default function typeTokenizer(spacing = 'compact') { - const join = getJoiner(spacing); - return (spec) => { - let curlies = 0; - let lines = []; - for (const [i, { tokens }] of spec.source.entries()) { - let type = ''; - if (i === 0 && tokens.description[0] !== '{') - return spec; - for (const ch of tokens.description) { - if (ch === '{') - curlies++; - if (ch === '}') - curlies--; - type += ch; - if (curlies === 0) - break; - } - lines.push([tokens, type]); - if (curlies === 0) - break; - } - if (curlies !== 0) { - spec.problems.push({ - code: 'spec:type:unpaired-curlies', - message: 'unpaired curlies', - line: spec.source[0].number, - critical: true, - }); - return spec; - } - const parts = []; - const offset = lines[0][0].postDelimiter.length; - for (const [i, [tokens, type]] of lines.entries()) { - tokens.type = type; - if (i > 0) { - tokens.type = tokens.postDelimiter.slice(offset) + type; - tokens.postDelimiter = tokens.postDelimiter.slice(0, offset); - } - [tokens.postType, tokens.description] = splitSpace(tokens.description.slice(type.length)); - parts.push(tokens.type); - } - parts[0] = parts[0].slice(1); - parts[parts.length - 1] = parts[parts.length - 1].slice(0, -1); - spec.type = join(parts); - return spec; - }; -} -const trim = (x) => x.trim(); -function getJoiner(spacing) { - if (spacing === 'compact') - return (t) => t.map(trim).join(''); - else if (spacing === 'preserve') - return (t) => t.join('\n'); - else - return spacing; -} diff --git a/tools/eslint/node_modules/comment-parser/es6/primitives.js b/tools/eslint/node_modules/comment-parser/es6/primitives.js deleted file mode 100644 index 9118d3010aecf9..00000000000000 --- a/tools/eslint/node_modules/comment-parser/es6/primitives.js +++ /dev/null @@ -1,8 +0,0 @@ -/** @deprecated */ -export var Markers; -(function (Markers) { - Markers["start"] = "/**"; - Markers["nostart"] = "/***"; - Markers["delim"] = "*"; - Markers["end"] = "*/"; -})(Markers = Markers || (Markers = {})); diff --git a/tools/eslint/node_modules/comment-parser/es6/stringifier/index.js b/tools/eslint/node_modules/comment-parser/es6/stringifier/index.js deleted file mode 100644 index 60b46ca4f59575..00000000000000 --- a/tools/eslint/node_modules/comment-parser/es6/stringifier/index.js +++ /dev/null @@ -1,17 +0,0 @@ -function join(tokens) { - return (tokens.start + - tokens.delimiter + - tokens.postDelimiter + - tokens.tag + - tokens.postTag + - tokens.type + - tokens.postType + - tokens.name + - tokens.postName + - tokens.description + - tokens.end + - tokens.lineEnd); -} -export default function getStringifier() { - return (block) => block.source.map(({ tokens }) => join(tokens)).join('\n'); -} diff --git a/tools/eslint/node_modules/comment-parser/es6/stringifier/inspect.js b/tools/eslint/node_modules/comment-parser/es6/stringifier/inspect.js deleted file mode 100644 index 4569f3ccfe1273..00000000000000 --- a/tools/eslint/node_modules/comment-parser/es6/stringifier/inspect.js +++ /dev/null @@ -1,44 +0,0 @@ -import { isSpace } from '../util.js'; -const zeroWidth = { - line: 0, - start: 0, - delimiter: 0, - postDelimiter: 0, - tag: 0, - postTag: 0, - name: 0, - postName: 0, - type: 0, - postType: 0, - description: 0, - end: 0, - lineEnd: 0, -}; -const headers = { lineEnd: 'CR' }; -const fields = Object.keys(zeroWidth); -const repr = (x) => (isSpace(x) ? `{${x.length}}` : x); -const frame = (line) => '|' + line.join('|') + '|'; -const align = (width, tokens) => Object.keys(tokens).map((k) => repr(tokens[k]).padEnd(width[k])); -export default function inspect({ source }) { - var _a, _b; - if (source.length === 0) - return ''; - const width = Object.assign({}, zeroWidth); - for (const f of fields) - width[f] = ((_a = headers[f]) !== null && _a !== void 0 ? _a : f).length; - for (const { number, tokens } of source) { - width.line = Math.max(width.line, number.toString().length); - for (const k in tokens) - width[k] = Math.max(width[k], repr(tokens[k]).length); - } - const lines = [[], []]; - for (const f of fields) - lines[0].push(((_b = headers[f]) !== null && _b !== void 0 ? _b : f).padEnd(width[f])); - for (const f of fields) - lines[1].push('-'.padEnd(width[f], '-')); - for (const { number, tokens } of source) { - const line = number.toString().padStart(width.line); - lines.push([line, ...align(width, tokens)]); - } - return lines.map(frame).join('\n'); -} diff --git a/tools/eslint/node_modules/comment-parser/es6/transforms/align.js b/tools/eslint/node_modules/comment-parser/es6/transforms/align.js deleted file mode 100644 index 0c1d6616c5e6c0..00000000000000 --- a/tools/eslint/node_modules/comment-parser/es6/transforms/align.js +++ /dev/null @@ -1,93 +0,0 @@ -var __rest = (this && this.__rest) || function (s, e) { - var t = {}; - for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) - t[p] = s[p]; - if (s != null && typeof Object.getOwnPropertySymbols === "function") - for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) { - if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) - t[p[i]] = s[p[i]]; - } - return t; -}; -import { Markers } from '../primitives.js'; -import { rewireSource } from '../util.js'; -const zeroWidth = { - start: 0, - tag: 0, - type: 0, - name: 0, -}; -const getWidth = (markers = Markers) => (w, { tokens: t }) => ({ - start: t.delimiter === markers.start ? t.start.length : w.start, - tag: Math.max(w.tag, t.tag.length), - type: Math.max(w.type, t.type.length), - name: Math.max(w.name, t.name.length), -}); -const space = (len) => ''.padStart(len, ' '); -export default function align(markers = Markers) { - let intoTags = false; - let w; - function update(line) { - const tokens = Object.assign({}, line.tokens); - if (tokens.tag !== '') - intoTags = true; - const isEmpty = tokens.tag === '' && - tokens.name === '' && - tokens.type === '' && - tokens.description === ''; - // dangling '*/' - if (tokens.end === markers.end && isEmpty) { - tokens.start = space(w.start + 1); - return Object.assign(Object.assign({}, line), { tokens }); - } - switch (tokens.delimiter) { - case markers.start: - tokens.start = space(w.start); - break; - case markers.delim: - tokens.start = space(w.start + 1); - break; - default: - tokens.delimiter = ''; - tokens.start = space(w.start + 2); // compensate delimiter - } - if (!intoTags) { - tokens.postDelimiter = tokens.description === '' ? '' : ' '; - return Object.assign(Object.assign({}, line), { tokens }); - } - const nothingAfter = { - delim: false, - tag: false, - type: false, - name: false, - }; - if (tokens.description === '') { - nothingAfter.name = true; - tokens.postName = ''; - if (tokens.name === '') { - nothingAfter.type = true; - tokens.postType = ''; - if (tokens.type === '') { - nothingAfter.tag = true; - tokens.postTag = ''; - if (tokens.tag === '') { - nothingAfter.delim = true; - } - } - } - } - tokens.postDelimiter = nothingAfter.delim ? '' : ' '; - if (!nothingAfter.tag) - tokens.postTag = space(w.tag - tokens.tag.length + 1); - if (!nothingAfter.type) - tokens.postType = space(w.type - tokens.type.length + 1); - if (!nothingAfter.name) - tokens.postName = space(w.name - tokens.name.length + 1); - return Object.assign(Object.assign({}, line), { tokens }); - } - return (_a) => { - var { source } = _a, fields = __rest(_a, ["source"]); - w = source.reduce(getWidth(markers), Object.assign({}, zeroWidth)); - return rewireSource(Object.assign(Object.assign({}, fields), { source: source.map(update) })); - }; -} diff --git a/tools/eslint/node_modules/comment-parser/es6/transforms/crlf.js b/tools/eslint/node_modules/comment-parser/es6/transforms/crlf.js deleted file mode 100644 index f876f949cb19bf..00000000000000 --- a/tools/eslint/node_modules/comment-parser/es6/transforms/crlf.js +++ /dev/null @@ -1,34 +0,0 @@ -var __rest = (this && this.__rest) || function (s, e) { - var t = {}; - for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) - t[p] = s[p]; - if (s != null && typeof Object.getOwnPropertySymbols === "function") - for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) { - if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) - t[p[i]] = s[p[i]]; - } - return t; -}; -import { rewireSource } from '../util.js'; -const order = [ - 'end', - 'description', - 'postType', - 'type', - 'postName', - 'name', - 'postTag', - 'tag', - 'postDelimiter', - 'delimiter', - 'start', -]; -export default function crlf(ending) { - function update(line) { - return Object.assign(Object.assign({}, line), { tokens: Object.assign(Object.assign({}, line.tokens), { lineEnd: ending === 'LF' ? '' : '\r' }) }); - } - return (_a) => { - var { source } = _a, fields = __rest(_a, ["source"]); - return rewireSource(Object.assign(Object.assign({}, fields), { source: source.map(update) })); - }; -} diff --git a/tools/eslint/node_modules/comment-parser/es6/transforms/indent.js b/tools/eslint/node_modules/comment-parser/es6/transforms/indent.js deleted file mode 100644 index ca24b854026b6a..00000000000000 --- a/tools/eslint/node_modules/comment-parser/es6/transforms/indent.js +++ /dev/null @@ -1,32 +0,0 @@ -var __rest = (this && this.__rest) || function (s, e) { - var t = {}; - for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) - t[p] = s[p]; - if (s != null && typeof Object.getOwnPropertySymbols === "function") - for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) { - if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) - t[p[i]] = s[p[i]]; - } - return t; -}; -import { rewireSource } from '../util.js'; -const pull = (offset) => (str) => str.slice(offset); -const push = (offset) => { - const space = ''.padStart(offset, ' '); - return (str) => str + space; -}; -export default function indent(pos) { - let shift; - const pad = (start) => { - if (shift === undefined) { - const offset = pos - start.length; - shift = offset > 0 ? push(offset) : pull(-offset); - } - return shift(start); - }; - const update = (line) => (Object.assign(Object.assign({}, line), { tokens: Object.assign(Object.assign({}, line.tokens), { start: pad(line.tokens.start) }) })); - return (_a) => { - var { source } = _a, fields = __rest(_a, ["source"]); - return rewireSource(Object.assign(Object.assign({}, fields), { source: source.map(update) })); - }; -} diff --git a/tools/eslint/node_modules/comment-parser/es6/transforms/index.js b/tools/eslint/node_modules/comment-parser/es6/transforms/index.js deleted file mode 100644 index af165719fb822b..00000000000000 --- a/tools/eslint/node_modules/comment-parser/es6/transforms/index.js +++ /dev/null @@ -1,3 +0,0 @@ -export function flow(...transforms) { - return (block) => transforms.reduce((block, t) => t(block), block); -} diff --git a/tools/eslint/node_modules/comment-parser/es6/util.js b/tools/eslint/node_modules/comment-parser/es6/util.js deleted file mode 100644 index 4476e26f2711fc..00000000000000 --- a/tools/eslint/node_modules/comment-parser/es6/util.js +++ /dev/null @@ -1,52 +0,0 @@ -export function isSpace(source) { - return /^\s+$/.test(source); -} -export function hasCR(source) { - return /\r$/.test(source); -} -export function splitCR(source) { - const matches = source.match(/\r+$/); - return matches == null - ? ['', source] - : [source.slice(-matches[0].length), source.slice(0, -matches[0].length)]; -} -export function splitSpace(source) { - const matches = source.match(/^\s+/); - return matches == null - ? ['', source] - : [source.slice(0, matches[0].length), source.slice(matches[0].length)]; -} -export function splitLines(source) { - return source.split(/\n/); -} -export function seedBlock(block = {}) { - return Object.assign({ description: '', tags: [], source: [], problems: [] }, block); -} -export function seedSpec(spec = {}) { - return Object.assign({ tag: '', name: '', type: '', optional: false, description: '', problems: [], source: [] }, spec); -} -export function seedTokens(tokens = {}) { - return Object.assign({ start: '', delimiter: '', postDelimiter: '', tag: '', postTag: '', name: '', postName: '', type: '', postType: '', description: '', end: '', lineEnd: '' }, tokens); -} -/** - * Assures Block.tags[].source contains references to the Block.source items, - * using Block.source as a source of truth. This is a counterpart of rewireSpecs - * @param block parsed coments block - */ -export function rewireSource(block) { - const source = block.source.reduce((acc, line) => acc.set(line.number, line), new Map()); - for (const spec of block.tags) { - spec.source = spec.source.map((line) => source.get(line.number)); - } - return block; -} -/** - * Assures Block.source contains references to the Block.tags[].source items, - * using Block.tags[].source as a source of truth. This is a counterpart of rewireSource - * @param block parsed coments block - */ -export function rewireSpecs(block) { - const source = block.tags.reduce((acc, spec) => spec.source.reduce((acc, line) => acc.set(line.number, line), acc), new Map()); - block.source = block.source.map((line) => source.get(line.number) || line); - return block; -} diff --git a/tools/eslint/node_modules/comment-parser/jest.config.cjs b/tools/eslint/node_modules/comment-parser/jest.config.cjs deleted file mode 100644 index 5831deee995149..00000000000000 --- a/tools/eslint/node_modules/comment-parser/jest.config.cjs +++ /dev/null @@ -1,209 +0,0 @@ -// For a detailed explanation regarding each configuration property, visit: -// https://jestjs.io/docs/en/configuration.html - -const { compilerOptions: tsconfig } = JSON.parse( - require('fs').readFileSync('./tsconfig.node.json') -); - -module.exports = { - globals: { - 'ts-jest': { - tsconfig, - }, - }, - - // All imported modules in your tests should be mocked automatically - // automock: false, - - // Stop running tests after `n` failures - // bail: 0, - - // The directory where Jest should store its cached dependency information - // cacheDirectory: "/private/var/folders/_g/g97k3tbx31x08qqy2z18kxq80000gn/T/jest_dx", - - // Automatically clear mock calls and instances between every test - // clearMocks: false, - - // Indicates whether the coverage information should be collected while executing the test - collectCoverage: true, - - // An array of glob patterns indicating a set of files for which coverage information should be collected - // collectCoverageFrom: undefined, - - // The directory where Jest should output its coverage files - // coverageDirectory: ".coverage", - - // An array of regexp pattern strings used to skip coverage collection - coveragePathIgnorePatterns: ['/node_modules/', '/lib/', '/tests/'], - - // Indicates which provider should be used to instrument code for coverage - coverageProvider: 'v8', - - // A list of reporter names that Jest uses when writing coverage reports - // coverageReporters: [ - // "json", - // "text", - // "lcov", - // "clover" - // ], - - // An object that configures minimum threshold enforcement for coverage results - // coverageThreshold: { - // global : { - // branches: 85, - // functions: 85, - // lines: 85, - // statements: 85 - // } - // }, - - // A path to a custom dependency extractor - // dependencyExtractor: undefined, - - // Make calling deprecated APIs throw helpful error messages - // errorOnDeprecated: false, - - // Force coverage collection from ignored files using an array of glob patterns - // forceCoverageMatch: [], - - // A path to a module which exports an async function that is triggered once before all test suites - // globalSetup: undefined, - - // A path to a module which exports an async function that is triggered once after all test suites - // globalTeardown: undefined, - - // A set of global variables that need to be available in all test environments - // globals: {}, - - // The maximum amount of workers used to run your tests. Can be specified as % or a number. E.g. maxWorkers: 10% will use 10% of your CPU amount + 1 as the maximum worker number. maxWorkers: 2 will use a maximum of 2 workers. - // maxWorkers: "50%", - - // An array of directory names to be searched recursively up from the requiring module's location - // moduleDirectories: [ - // "node_modules" - // ], - - // An array of file extensions your modules use - // moduleFileExtensions: [ - // "js", - // "json", - // "jsx", - // "ts", - // "tsx", - // "node" - // ], - - // A map from regular expressions to module names or to arrays of module names that allow to stub out resources with a single module - moduleNameMapper: { - [/(.+)\.js$/.source]: ['$1.js', '$1.ts'] - }, - - // An array of regexp pattern strings, matched against all module paths before considered 'visible' to the module loader - // modulePathIgnorePatterns: [], - - // Activates notifications for test results - // notify: false, - - // An enum that specifies notification mode. Requires { notify: true } - // notifyMode: "failure-change", - - // A preset that is used as a base for Jest's configuration - preset: 'ts-jest', - - // Run tests from one or more projects - // projects: undefined, - - // Use this configuration option to add custom reporters to Jest - // reporters: undefined, - - // Automatically reset mock state between every test - // resetMocks: false, - - // Reset the module registry before running each individual test - // resetModules: false, - - // A path to a custom resolver - // resolver: undefined, - - // Automatically restore mock state between every test - // restoreMocks: false, - - // The root directory that Jest should scan for tests and modules within - // rootDir: undefined, - - // A list of paths to directories that Jest should use to search for files in - roots: ['/tests/'], - - // Allows you to use a custom runner instead of Jest's default test runner - // runner: "jest-runner", - - // The paths to modules that run some code to configure or set up the testing environment before each test - // setupFiles: [], - - // A list of paths to modules that run some code to configure or set up the testing framework before each test - // setupFilesAfterEnv: [], - - // The number of seconds after which a test is considered as slow and reported as such in the results. - // slowTestThreshold: 5, - - // A list of paths to snapshot serializer modules Jest should use for snapshot testing - // snapshotSerializers: [], - - // The test environment that will be used for testing - testEnvironment: 'node', - - // Options that will be passed to the testEnvironment - // testEnvironmentOptions: {}, - - // Adds a location field to test results - // testLocationInResults: false, - - // The glob patterns Jest uses to detect test files - // testMatch: [ - // "**/__tests__/**/*.[jt]s?(x)", - // "**/?(*.)+(spec|test).[tj]s?(x)" - // ], - - // An array of regexp pattern strings that are matched against all test paths, matched tests are skipped - // testPathIgnorePatterns: [ - // "/node_modules/" - // ], - - // The regexp pattern or array of patterns that Jest uses to detect test files - // testRegex: [], - - // This option allows the use of a custom results processor - // testResultsProcessor: undefined, - - // This option allows use of a custom test runner - // testRunner: "jasmine2", - - // This option sets the URL for the jsdom environment. It is reflected in properties such as location.href - // testURL: "http://localhost", - - // Setting this value to "fake" allows the use of fake timers for functions such as "setTimeout" - // timers: "real", - - // A map from regular expressions to paths to transformers - transform: { - '^.+\\.ts$': 'ts-jest', - }, - - // An array of regexp pattern strings that are matched against all source file paths, matched files will skip transformation - // transformIgnorePatterns: [ - // "/node_modules/", - // "\\.pnp\\.[^\\/]+$" - // ], - - // An array of regexp pattern strings that are matched against all modules before the module loader will automatically return a mock for them - // unmockedModulePathPatterns: undefined, - - // Indicates whether each individual test should be reported during the run - // verbose: undefined, - - // An array of regexp patterns that are matched against all source file paths before re-running tests in watch mode - // watchPathIgnorePatterns: [], - - // Whether to use watchman for file crawling - // watchman: true, -}; diff --git a/tools/eslint/node_modules/comment-parser/lib/index.cjs b/tools/eslint/node_modules/comment-parser/lib/index.cjs deleted file mode 100644 index e69b41ccd7dfec..00000000000000 --- a/tools/eslint/node_modules/comment-parser/lib/index.cjs +++ /dev/null @@ -1,88 +0,0 @@ -"use strict"; - -var __createBinding = this && this.__createBinding || (Object.create ? function (o, m, k, k2) { - if (k2 === undefined) k2 = k; - var desc = Object.getOwnPropertyDescriptor(m, k); - - if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { - desc = { - enumerable: true, - get: function () { - return m[k]; - } - }; - } - - Object.defineProperty(o, k2, desc); -} : function (o, m, k, k2) { - if (k2 === undefined) k2 = k; - o[k2] = m[k]; -}); - -var __exportStar = this && this.__exportStar || function (m, exports) { - for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p); -}; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.util = exports.tokenizers = exports.transforms = exports.inspect = exports.stringify = exports.parse = void 0; - -const index_js_1 = require("./parser/index.cjs"); - -const description_js_1 = require("./parser/tokenizers/description.cjs"); - -const name_js_1 = require("./parser/tokenizers/name.cjs"); - -const tag_js_1 = require("./parser/tokenizers/tag.cjs"); - -const type_js_1 = require("./parser/tokenizers/type.cjs"); - -const index_js_2 = require("./stringifier/index.cjs"); - -const align_js_1 = require("./transforms/align.cjs"); - -const indent_js_1 = require("./transforms/indent.cjs"); - -const crlf_js_1 = require("./transforms/crlf.cjs"); - -const index_js_3 = require("./transforms/index.cjs"); - -const util_js_1 = require("./util.cjs"); - -__exportStar(require("./primitives.cjs"), exports); - -function parse(source, options = {}) { - return (0, index_js_1.default)(options)(source); -} - -exports.parse = parse; -exports.stringify = (0, index_js_2.default)(); - -var inspect_js_1 = require("./stringifier/inspect.cjs"); - -Object.defineProperty(exports, "inspect", { - enumerable: true, - get: function () { - return inspect_js_1.default; - } -}); -exports.transforms = { - flow: index_js_3.flow, - align: align_js_1.default, - indent: indent_js_1.default, - crlf: crlf_js_1.default -}; -exports.tokenizers = { - tag: tag_js_1.default, - type: type_js_1.default, - name: name_js_1.default, - description: description_js_1.default -}; -exports.util = { - rewireSpecs: util_js_1.rewireSpecs, - rewireSource: util_js_1.rewireSource, - seedBlock: util_js_1.seedBlock, - seedTokens: util_js_1.seedTokens -}; -//# sourceMappingURL=index.cjs.map diff --git a/tools/eslint/node_modules/comment-parser/lib/parser/block-parser.cjs b/tools/eslint/node_modules/comment-parser/lib/parser/block-parser.cjs deleted file mode 100644 index b81ecd79c4fe59..00000000000000 --- a/tools/eslint/node_modules/comment-parser/lib/parser/block-parser.cjs +++ /dev/null @@ -1,44 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -const reTag = /^@\S+/; -/** - * Creates configured `Parser` - * @param {Partial} options - */ - -function getParser({ - fence = '```' -} = {}) { - const fencer = getFencer(fence); - - const toggleFence = (source, isFenced) => fencer(source) ? !isFenced : isFenced; - - return function parseBlock(source) { - // start with description section - const sections = [[]]; - let isFenced = false; - - for (const line of source) { - if (reTag.test(line.tokens.description) && !isFenced) { - sections.push([line]); - } else { - sections[sections.length - 1].push(line); - } - - isFenced = toggleFence(line.tokens.description, isFenced); - } - - return sections; - }; -} - -exports.default = getParser; - -function getFencer(fence) { - if (typeof fence === 'string') return source => source.split(fence).length % 2 === 0; - return fence; -} -//# sourceMappingURL=block-parser.cjs.map diff --git a/tools/eslint/node_modules/comment-parser/lib/parser/index.cjs b/tools/eslint/node_modules/comment-parser/lib/parser/index.cjs deleted file mode 100644 index cb7df88bbaafef..00000000000000 --- a/tools/eslint/node_modules/comment-parser/lib/parser/index.cjs +++ /dev/null @@ -1,65 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); - -const primitives_js_1 = require("../primitives.cjs"); - -const util_js_1 = require("../util.cjs"); - -const block_parser_js_1 = require("./block-parser.cjs"); - -const source_parser_js_1 = require("./source-parser.cjs"); - -const spec_parser_js_1 = require("./spec-parser.cjs"); - -const tag_js_1 = require("./tokenizers/tag.cjs"); - -const type_js_1 = require("./tokenizers/type.cjs"); - -const name_js_1 = require("./tokenizers/name.cjs"); - -const description_js_1 = require("./tokenizers/description.cjs"); - -function getParser({ - startLine = 0, - fence = '```', - spacing = 'compact', - markers = primitives_js_1.Markers, - tokenizers = [(0, tag_js_1.default)(), (0, type_js_1.default)(spacing), (0, name_js_1.default)(), (0, description_js_1.default)(spacing)] -} = {}) { - if (startLine < 0 || startLine % 1 > 0) throw new Error('Invalid startLine'); - const parseSource = (0, source_parser_js_1.default)({ - startLine, - markers - }); - const parseBlock = (0, block_parser_js_1.default)({ - fence - }); - const parseSpec = (0, spec_parser_js_1.default)({ - tokenizers - }); - const joinDescription = (0, description_js_1.getJoiner)(spacing); - return function (source) { - const blocks = []; - - for (const line of (0, util_js_1.splitLines)(source)) { - const lines = parseSource(line); - if (lines === null) continue; - const sections = parseBlock(lines); - const specs = sections.slice(1).map(parseSpec); - blocks.push({ - description: joinDescription(sections[0], markers), - tags: specs, - source: lines, - problems: specs.reduce((acc, spec) => acc.concat(spec.problems), []) - }); - } - - return blocks; - }; -} - -exports.default = getParser; -//# sourceMappingURL=index.cjs.map diff --git a/tools/eslint/node_modules/comment-parser/lib/parser/source-parser.cjs b/tools/eslint/node_modules/comment-parser/lib/parser/source-parser.cjs deleted file mode 100644 index 0e0e3a156dd1d0..00000000000000 --- a/tools/eslint/node_modules/comment-parser/lib/parser/source-parser.cjs +++ /dev/null @@ -1,68 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); - -const primitives_js_1 = require("../primitives.cjs"); - -const util_js_1 = require("../util.cjs"); - -function getParser({ - startLine = 0, - markers = primitives_js_1.Markers -} = {}) { - let block = null; - let num = startLine; - return function parseSource(source) { - let rest = source; - const tokens = (0, util_js_1.seedTokens)(); - [tokens.lineEnd, rest] = (0, util_js_1.splitCR)(rest); - [tokens.start, rest] = (0, util_js_1.splitSpace)(rest); - - if (block === null && rest.startsWith(markers.start) && !rest.startsWith(markers.nostart)) { - block = []; - tokens.delimiter = rest.slice(0, markers.start.length); - rest = rest.slice(markers.start.length); - [tokens.postDelimiter, rest] = (0, util_js_1.splitSpace)(rest); - } - - if (block === null) { - num++; - return null; - } - - const isClosed = rest.trimRight().endsWith(markers.end); - - if (tokens.delimiter === '' && rest.startsWith(markers.delim) && !rest.startsWith(markers.end)) { - tokens.delimiter = markers.delim; - rest = rest.slice(markers.delim.length); - [tokens.postDelimiter, rest] = (0, util_js_1.splitSpace)(rest); - } - - if (isClosed) { - const trimmed = rest.trimRight(); - tokens.end = rest.slice(trimmed.length - markers.end.length); - rest = trimmed.slice(0, -markers.end.length); - } - - tokens.description = rest; - block.push({ - number: num, - source, - tokens - }); - num++; - - if (isClosed) { - const result = block.slice(); - block = null; - return result; - } - - return null; - }; -} - -exports.default = getParser; -//# sourceMappingURL=source-parser.cjs.map diff --git a/tools/eslint/node_modules/comment-parser/lib/parser/spec-parser.cjs b/tools/eslint/node_modules/comment-parser/lib/parser/spec-parser.cjs deleted file mode 100644 index 52741921e51028..00000000000000 --- a/tools/eslint/node_modules/comment-parser/lib/parser/spec-parser.cjs +++ /dev/null @@ -1,29 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); - -const util_js_1 = require("../util.cjs"); - -function getParser({ - tokenizers -}) { - return function parseSpec(source) { - var _a; - - let spec = (0, util_js_1.seedSpec)({ - source - }); - - for (const tokenize of tokenizers) { - spec = tokenize(spec); - if ((_a = spec.problems[spec.problems.length - 1]) === null || _a === void 0 ? void 0 : _a.critical) break; - } - - return spec; - }; -} - -exports.default = getParser; -//# sourceMappingURL=spec-parser.cjs.map diff --git a/tools/eslint/node_modules/comment-parser/lib/parser/tokenizers/description.cjs b/tools/eslint/node_modules/comment-parser/lib/parser/tokenizers/description.cjs deleted file mode 100644 index 936f3c93ab39c1..00000000000000 --- a/tools/eslint/node_modules/comment-parser/lib/parser/tokenizers/description.cjs +++ /dev/null @@ -1,62 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.getJoiner = void 0; - -const primitives_js_1 = require("../../primitives.cjs"); -/** - * Makes no changes to `spec.lines[].tokens` but joins them into `spec.description` - * following given spacing srtategy - * @param {Spacing} spacing tells how to handle the whitespace - * @param {BlockMarkers} markers tells how to handle comment block delimitation - */ - - -function descriptionTokenizer(spacing = 'compact', markers = primitives_js_1.Markers) { - const join = getJoiner(spacing); - return spec => { - spec.description = join(spec.source, markers); - return spec; - }; -} - -exports.default = descriptionTokenizer; - -function getJoiner(spacing) { - if (spacing === 'compact') return compactJoiner; - if (spacing === 'preserve') return preserveJoiner; - return spacing; -} - -exports.getJoiner = getJoiner; - -function compactJoiner(lines, markers = primitives_js_1.Markers) { - return lines.map(({ - tokens: { - description - } - }) => description.trim()).filter(description => description !== '').join(' '); -} - -const lineNo = (num, { - tokens -}, i) => tokens.type === '' ? num : i; - -const getDescription = ({ - tokens -}) => (tokens.delimiter === '' ? tokens.start : tokens.postDelimiter.slice(1)) + tokens.description; - -function preserveJoiner(lines, markers = primitives_js_1.Markers) { - if (lines.length === 0) return ''; // skip the opening line with no description - - if (lines[0].tokens.description === '' && lines[0].tokens.delimiter === markers.start) lines = lines.slice(1); // skip the closing line with no description - - const lastLine = lines[lines.length - 1]; - if (lastLine !== undefined && lastLine.tokens.description === '' && lastLine.tokens.end.endsWith(markers.end)) lines = lines.slice(0, -1); // description starts at the last line of type definition - - lines = lines.slice(lines.reduce(lineNo, 0)); - return lines.map(getDescription).join('\n'); -} -//# sourceMappingURL=description.cjs.map diff --git a/tools/eslint/node_modules/comment-parser/lib/parser/tokenizers/index.cjs b/tools/eslint/node_modules/comment-parser/lib/parser/tokenizers/index.cjs deleted file mode 100644 index 203880fed84ce2..00000000000000 --- a/tools/eslint/node_modules/comment-parser/lib/parser/tokenizers/index.cjs +++ /dev/null @@ -1,6 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -//# sourceMappingURL=index.cjs.map diff --git a/tools/eslint/node_modules/comment-parser/lib/parser/tokenizers/name.cjs b/tools/eslint/node_modules/comment-parser/lib/parser/tokenizers/name.cjs deleted file mode 100644 index 294d3671c251a1..00000000000000 --- a/tools/eslint/node_modules/comment-parser/lib/parser/tokenizers/name.cjs +++ /dev/null @@ -1,109 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); - -const util_js_1 = require("../../util.cjs"); - -const isQuoted = s => s && s.startsWith('"') && s.endsWith('"'); -/** - * Splits remaining `spec.lines[].tokens.description` into `name` and `descriptions` tokens, - * and populates the `spec.name` - */ - - -function nameTokenizer() { - const typeEnd = (num, { - tokens - }, i) => tokens.type === '' ? num : i; - - return spec => { - // look for the name in the line where {type} ends - const { - tokens - } = spec.source[spec.source.reduce(typeEnd, 0)]; - const source = tokens.description.trimLeft(); - const quotedGroups = source.split('"'); // if it starts with quoted group, assume it is a literal - - if (quotedGroups.length > 1 && quotedGroups[0] === '' && quotedGroups.length % 2 === 1) { - spec.name = quotedGroups[1]; - tokens.name = `"${quotedGroups[1]}"`; - [tokens.postName, tokens.description] = (0, util_js_1.splitSpace)(source.slice(tokens.name.length)); - return spec; - } - - let brackets = 0; - let name = ''; - let optional = false; - let defaultValue; // assume name is non-space string or anything wrapped into brackets - - for (const ch of source) { - if (brackets === 0 && (0, util_js_1.isSpace)(ch)) break; - if (ch === '[') brackets++; - if (ch === ']') brackets--; - name += ch; - } - - if (brackets !== 0) { - spec.problems.push({ - code: 'spec:name:unpaired-brackets', - message: 'unpaired brackets', - line: spec.source[0].number, - critical: true - }); - return spec; - } - - const nameToken = name; - - if (name[0] === '[' && name[name.length - 1] === ']') { - optional = true; - name = name.slice(1, -1); - const parts = name.split('='); - name = parts[0].trim(); - if (parts[1] !== undefined) defaultValue = parts.slice(1).join('=').trim(); - - if (name === '') { - spec.problems.push({ - code: 'spec:name:empty-name', - message: 'empty name', - line: spec.source[0].number, - critical: true - }); - return spec; - } - - if (defaultValue === '') { - spec.problems.push({ - code: 'spec:name:empty-default', - message: 'empty default value', - line: spec.source[0].number, - critical: true - }); - return spec; - } // has "=" and is not a string, except for "=>" - - - if (!isQuoted(defaultValue) && /=(?!>)/.test(defaultValue)) { - spec.problems.push({ - code: 'spec:name:invalid-default', - message: 'invalid default value syntax', - line: spec.source[0].number, - critical: true - }); - return spec; - } - } - - spec.optional = optional; - spec.name = name; - tokens.name = nameToken; - if (defaultValue !== undefined) spec.default = defaultValue; - [tokens.postName, tokens.description] = (0, util_js_1.splitSpace)(source.slice(tokens.name.length)); - return spec; - }; -} - -exports.default = nameTokenizer; -//# sourceMappingURL=name.cjs.map diff --git a/tools/eslint/node_modules/comment-parser/lib/parser/tokenizers/tag.cjs b/tools/eslint/node_modules/comment-parser/lib/parser/tokenizers/tag.cjs deleted file mode 100644 index 10b4597e436fa9..00000000000000 --- a/tools/eslint/node_modules/comment-parser/lib/parser/tokenizers/tag.cjs +++ /dev/null @@ -1,37 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -/** - * Splits the `@prefix` from remaining `Spec.lines[].token.description` into the `tag` token, - * and populates `spec.tag` - */ - -function tagTokenizer() { - return spec => { - const { - tokens - } = spec.source[0]; - const match = tokens.description.match(/\s*(@(\S+))(\s*)/); - - if (match === null) { - spec.problems.push({ - code: 'spec:tag:prefix', - message: 'tag should start with "@" symbol', - line: spec.source[0].number, - critical: true - }); - return spec; - } - - tokens.tag = match[1]; - tokens.postTag = match[3]; - tokens.description = tokens.description.slice(match[0].length); - spec.tag = match[2]; - return spec; - }; -} - -exports.default = tagTokenizer; -//# sourceMappingURL=tag.cjs.map diff --git a/tools/eslint/node_modules/comment-parser/lib/parser/tokenizers/type.cjs b/tools/eslint/node_modules/comment-parser/lib/parser/tokenizers/type.cjs deleted file mode 100644 index 9c86575bc1bb55..00000000000000 --- a/tools/eslint/node_modules/comment-parser/lib/parser/tokenizers/type.cjs +++ /dev/null @@ -1,79 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); - -const util_js_1 = require("../../util.cjs"); -/** - * Sets splits remaining `Spec.lines[].tokes.description` into `type` and `description` - * tokens and populates Spec.type` - * - * @param {Spacing} spacing tells how to deal with a whitespace - * for type values going over multiple lines - */ - - -function typeTokenizer(spacing = 'compact') { - const join = getJoiner(spacing); - return spec => { - let curlies = 0; - let lines = []; - - for (const [i, { - tokens - }] of spec.source.entries()) { - let type = ''; - if (i === 0 && tokens.description[0] !== '{') return spec; - - for (const ch of tokens.description) { - if (ch === '{') curlies++; - if (ch === '}') curlies--; - type += ch; - if (curlies === 0) break; - } - - lines.push([tokens, type]); - if (curlies === 0) break; - } - - if (curlies !== 0) { - spec.problems.push({ - code: 'spec:type:unpaired-curlies', - message: 'unpaired curlies', - line: spec.source[0].number, - critical: true - }); - return spec; - } - - const parts = []; - const offset = lines[0][0].postDelimiter.length; - - for (const [i, [tokens, type]] of lines.entries()) { - tokens.type = type; - - if (i > 0) { - tokens.type = tokens.postDelimiter.slice(offset) + type; - tokens.postDelimiter = tokens.postDelimiter.slice(0, offset); - } - - [tokens.postType, tokens.description] = (0, util_js_1.splitSpace)(tokens.description.slice(type.length)); - parts.push(tokens.type); - } - - parts[0] = parts[0].slice(1); - parts[parts.length - 1] = parts[parts.length - 1].slice(0, -1); - spec.type = join(parts); - return spec; - }; -} - -exports.default = typeTokenizer; - -const trim = x => x.trim(); - -function getJoiner(spacing) { - if (spacing === 'compact') return t => t.map(trim).join('');else if (spacing === 'preserve') return t => t.join('\n');else return spacing; -} -//# sourceMappingURL=type.cjs.map diff --git a/tools/eslint/node_modules/comment-parser/lib/primitives.cjs b/tools/eslint/node_modules/comment-parser/lib/primitives.cjs deleted file mode 100644 index a60ed1473dbd71..00000000000000 --- a/tools/eslint/node_modules/comment-parser/lib/primitives.cjs +++ /dev/null @@ -1,17 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.Markers = void 0; -/** @deprecated */ - -var Markers; - -(function (Markers) { - Markers["start"] = "/**"; - Markers["nostart"] = "/***"; - Markers["delim"] = "*"; - Markers["end"] = "*/"; -})(Markers = exports.Markers || (exports.Markers = {})); -//# sourceMappingURL=primitives.cjs.map diff --git a/tools/eslint/node_modules/comment-parser/lib/stringifier/index.cjs b/tools/eslint/node_modules/comment-parser/lib/stringifier/index.cjs deleted file mode 100644 index 26214cb1d0d0b4..00000000000000 --- a/tools/eslint/node_modules/comment-parser/lib/stringifier/index.cjs +++ /dev/null @@ -1,18 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); - -function join(tokens) { - return tokens.start + tokens.delimiter + tokens.postDelimiter + tokens.tag + tokens.postTag + tokens.type + tokens.postType + tokens.name + tokens.postName + tokens.description + tokens.end + tokens.lineEnd; -} - -function getStringifier() { - return block => block.source.map(({ - tokens - }) => join(tokens)).join('\n'); -} - -exports.default = getStringifier; -//# sourceMappingURL=index.cjs.map diff --git a/tools/eslint/node_modules/comment-parser/lib/stringifier/inspect.cjs b/tools/eslint/node_modules/comment-parser/lib/stringifier/inspect.cjs deleted file mode 100644 index 7158ae17cf5c72..00000000000000 --- a/tools/eslint/node_modules/comment-parser/lib/stringifier/inspect.cjs +++ /dev/null @@ -1,72 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); - -const util_js_1 = require("../util.cjs"); - -const zeroWidth = { - line: 0, - start: 0, - delimiter: 0, - postDelimiter: 0, - tag: 0, - postTag: 0, - name: 0, - postName: 0, - type: 0, - postType: 0, - description: 0, - end: 0, - lineEnd: 0 -}; -const headers = { - lineEnd: 'CR' -}; -const fields = Object.keys(zeroWidth); - -const repr = x => (0, util_js_1.isSpace)(x) ? `{${x.length}}` : x; - -const frame = line => '|' + line.join('|') + '|'; - -const align = (width, tokens) => Object.keys(tokens).map(k => repr(tokens[k]).padEnd(width[k])); - -function inspect({ - source -}) { - var _a, _b; - - if (source.length === 0) return ''; - const width = Object.assign({}, zeroWidth); - - for (const f of fields) width[f] = ((_a = headers[f]) !== null && _a !== void 0 ? _a : f).length; - - for (const { - number, - tokens - } of source) { - width.line = Math.max(width.line, number.toString().length); - - for (const k in tokens) width[k] = Math.max(width[k], repr(tokens[k]).length); - } - - const lines = [[], []]; - - for (const f of fields) lines[0].push(((_b = headers[f]) !== null && _b !== void 0 ? _b : f).padEnd(width[f])); - - for (const f of fields) lines[1].push('-'.padEnd(width[f], '-')); - - for (const { - number, - tokens - } of source) { - const line = number.toString().padStart(width.line); - lines.push([line, ...align(width, tokens)]); - } - - return lines.map(frame).join('\n'); -} - -exports.default = inspect; -//# sourceMappingURL=inspect.cjs.map diff --git a/tools/eslint/node_modules/comment-parser/lib/transforms/align.cjs b/tools/eslint/node_modules/comment-parser/lib/transforms/align.cjs deleted file mode 100644 index 8a5dd768f80885..00000000000000 --- a/tools/eslint/node_modules/comment-parser/lib/transforms/align.cjs +++ /dev/null @@ -1,127 +0,0 @@ -"use strict"; - -var __rest = this && this.__rest || function (s, e) { - var t = {}; - - for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p]; - - if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) { - if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]]; - } - return t; -}; - -Object.defineProperty(exports, "__esModule", { - value: true -}); - -const primitives_js_1 = require("../primitives.cjs"); - -const util_js_1 = require("../util.cjs"); - -const zeroWidth = { - start: 0, - tag: 0, - type: 0, - name: 0 -}; - -const getWidth = (markers = primitives_js_1.Markers) => (w, { - tokens: t -}) => ({ - start: t.delimiter === markers.start ? t.start.length : w.start, - tag: Math.max(w.tag, t.tag.length), - type: Math.max(w.type, t.type.length), - name: Math.max(w.name, t.name.length) -}); - -const space = len => ''.padStart(len, ' '); - -function align(markers = primitives_js_1.Markers) { - let intoTags = false; - let w; - - function update(line) { - const tokens = Object.assign({}, line.tokens); - if (tokens.tag !== '') intoTags = true; - const isEmpty = tokens.tag === '' && tokens.name === '' && tokens.type === '' && tokens.description === ''; // dangling '*/' - - if (tokens.end === markers.end && isEmpty) { - tokens.start = space(w.start + 1); - return Object.assign(Object.assign({}, line), { - tokens - }); - } - - switch (tokens.delimiter) { - case markers.start: - tokens.start = space(w.start); - break; - - case markers.delim: - tokens.start = space(w.start + 1); - break; - - default: - tokens.delimiter = ''; - tokens.start = space(w.start + 2); - // compensate delimiter - } - - if (!intoTags) { - tokens.postDelimiter = tokens.description === '' ? '' : ' '; - return Object.assign(Object.assign({}, line), { - tokens - }); - } - - const nothingAfter = { - delim: false, - tag: false, - type: false, - name: false - }; - - if (tokens.description === '') { - nothingAfter.name = true; - tokens.postName = ''; - - if (tokens.name === '') { - nothingAfter.type = true; - tokens.postType = ''; - - if (tokens.type === '') { - nothingAfter.tag = true; - tokens.postTag = ''; - - if (tokens.tag === '') { - nothingAfter.delim = true; - } - } - } - } - - tokens.postDelimiter = nothingAfter.delim ? '' : ' '; - if (!nothingAfter.tag) tokens.postTag = space(w.tag - tokens.tag.length + 1); - if (!nothingAfter.type) tokens.postType = space(w.type - tokens.type.length + 1); - if (!nothingAfter.name) tokens.postName = space(w.name - tokens.name.length + 1); - return Object.assign(Object.assign({}, line), { - tokens - }); - } - - return _a => { - var { - source - } = _a, - fields = __rest(_a, ["source"]); - - w = source.reduce(getWidth(markers), Object.assign({}, zeroWidth)); - return (0, util_js_1.rewireSource)(Object.assign(Object.assign({}, fields), { - source: source.map(update) - })); - }; -} - -exports.default = align; -//# sourceMappingURL=align.cjs.map diff --git a/tools/eslint/node_modules/comment-parser/lib/transforms/crlf.cjs b/tools/eslint/node_modules/comment-parser/lib/transforms/crlf.cjs deleted file mode 100644 index de231597add3c5..00000000000000 --- a/tools/eslint/node_modules/comment-parser/lib/transforms/crlf.cjs +++ /dev/null @@ -1,44 +0,0 @@ -"use strict"; - -var __rest = this && this.__rest || function (s, e) { - var t = {}; - - for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p]; - - if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) { - if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]]; - } - return t; -}; - -Object.defineProperty(exports, "__esModule", { - value: true -}); - -const util_js_1 = require("../util.cjs"); - -const order = ['end', 'description', 'postType', 'type', 'postName', 'name', 'postTag', 'tag', 'postDelimiter', 'delimiter', 'start']; - -function crlf(ending) { - function update(line) { - return Object.assign(Object.assign({}, line), { - tokens: Object.assign(Object.assign({}, line.tokens), { - lineEnd: ending === 'LF' ? '' : '\r' - }) - }); - } - - return _a => { - var { - source - } = _a, - fields = __rest(_a, ["source"]); - - return (0, util_js_1.rewireSource)(Object.assign(Object.assign({}, fields), { - source: source.map(update) - })); - }; -} - -exports.default = crlf; -//# sourceMappingURL=crlf.cjs.map diff --git a/tools/eslint/node_modules/comment-parser/lib/transforms/indent.cjs b/tools/eslint/node_modules/comment-parser/lib/transforms/indent.cjs deleted file mode 100644 index d646f1fc68d789..00000000000000 --- a/tools/eslint/node_modules/comment-parser/lib/transforms/indent.cjs +++ /dev/null @@ -1,58 +0,0 @@ -"use strict"; - -var __rest = this && this.__rest || function (s, e) { - var t = {}; - - for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p]; - - if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) { - if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]]; - } - return t; -}; - -Object.defineProperty(exports, "__esModule", { - value: true -}); - -const util_js_1 = require("../util.cjs"); - -const pull = offset => str => str.slice(offset); - -const push = offset => { - const space = ''.padStart(offset, ' '); - return str => str + space; -}; - -function indent(pos) { - let shift; - - const pad = start => { - if (shift === undefined) { - const offset = pos - start.length; - shift = offset > 0 ? push(offset) : pull(-offset); - } - - return shift(start); - }; - - const update = line => Object.assign(Object.assign({}, line), { - tokens: Object.assign(Object.assign({}, line.tokens), { - start: pad(line.tokens.start) - }) - }); - - return _a => { - var { - source - } = _a, - fields = __rest(_a, ["source"]); - - return (0, util_js_1.rewireSource)(Object.assign(Object.assign({}, fields), { - source: source.map(update) - })); - }; -} - -exports.default = indent; -//# sourceMappingURL=indent.cjs.map diff --git a/tools/eslint/node_modules/comment-parser/lib/transforms/index.cjs b/tools/eslint/node_modules/comment-parser/lib/transforms/index.cjs deleted file mode 100644 index 767083ae35d7be..00000000000000 --- a/tools/eslint/node_modules/comment-parser/lib/transforms/index.cjs +++ /dev/null @@ -1,13 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.flow = void 0; - -function flow(...transforms) { - return block => transforms.reduce((block, t) => t(block), block); -} - -exports.flow = flow; -//# sourceMappingURL=index.cjs.map diff --git a/tools/eslint/node_modules/comment-parser/lib/util.cjs b/tools/eslint/node_modules/comment-parser/lib/util.cjs deleted file mode 100644 index 5d94c0a5d82d21..00000000000000 --- a/tools/eslint/node_modules/comment-parser/lib/util.cjs +++ /dev/null @@ -1,113 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.rewireSpecs = exports.rewireSource = exports.seedTokens = exports.seedSpec = exports.seedBlock = exports.splitLines = exports.splitSpace = exports.splitCR = exports.hasCR = exports.isSpace = void 0; - -function isSpace(source) { - return /^\s+$/.test(source); -} - -exports.isSpace = isSpace; - -function hasCR(source) { - return /\r$/.test(source); -} - -exports.hasCR = hasCR; - -function splitCR(source) { - const matches = source.match(/\r+$/); - return matches == null ? ['', source] : [source.slice(-matches[0].length), source.slice(0, -matches[0].length)]; -} - -exports.splitCR = splitCR; - -function splitSpace(source) { - const matches = source.match(/^\s+/); - return matches == null ? ['', source] : [source.slice(0, matches[0].length), source.slice(matches[0].length)]; -} - -exports.splitSpace = splitSpace; - -function splitLines(source) { - return source.split(/\n/); -} - -exports.splitLines = splitLines; - -function seedBlock(block = {}) { - return Object.assign({ - description: '', - tags: [], - source: [], - problems: [] - }, block); -} - -exports.seedBlock = seedBlock; - -function seedSpec(spec = {}) { - return Object.assign({ - tag: '', - name: '', - type: '', - optional: false, - description: '', - problems: [], - source: [] - }, spec); -} - -exports.seedSpec = seedSpec; - -function seedTokens(tokens = {}) { - return Object.assign({ - start: '', - delimiter: '', - postDelimiter: '', - tag: '', - postTag: '', - name: '', - postName: '', - type: '', - postType: '', - description: '', - end: '', - lineEnd: '' - }, tokens); -} - -exports.seedTokens = seedTokens; -/** - * Assures Block.tags[].source contains references to the Block.source items, - * using Block.source as a source of truth. This is a counterpart of rewireSpecs - * @param block parsed coments block - */ - -function rewireSource(block) { - const source = block.source.reduce((acc, line) => acc.set(line.number, line), new Map()); - - for (const spec of block.tags) { - spec.source = spec.source.map(line => source.get(line.number)); - } - - return block; -} - -exports.rewireSource = rewireSource; -/** - * Assures Block.source contains references to the Block.tags[].source items, - * using Block.tags[].source as a source of truth. This is a counterpart of rewireSource - * @param block parsed coments block - */ - -function rewireSpecs(block) { - const source = block.tags.reduce((acc, spec) => spec.source.reduce((acc, line) => acc.set(line.number, line), acc), new Map()); - block.source = block.source.map(line => source.get(line.number) || line); - return block; -} - -exports.rewireSpecs = rewireSpecs; -//# sourceMappingURL=util.cjs.map diff --git a/tools/eslint/node_modules/comment-parser/migrate-1.0.md b/tools/eslint/node_modules/comment-parser/migrate-1.0.md deleted file mode 100644 index bd815b678299c2..00000000000000 --- a/tools/eslint/node_modules/comment-parser/migrate-1.0.md +++ /dev/null @@ -1,105 +0,0 @@ -# Migrating 0.x to 1.x - -## Parser - -0.x can be mostly translated into 1.x one way or another. The idea behind the new config structure is to handle only the most common cases, and provide the fallback for alternative implementation. - -### `dotted_names: boolean` - -> By default dotted names like `name.subname.subsubname` will be expanded into nested sections, this can be prevented by passing opts.dotted_names = false. - -**Removed** This feature is removed but still can be done on top of the `parse()` output. Please post a request or contribute a PR if you need it. - -### `trim: boolean` - -> Set this to false to avoid the default of trimming whitespace at the start and end of each line. - -In the new parser all original spacing is kept along with comment lines in `.source`. Description lines are joined together depending on `spacing` option - -**New option:** - -- `spacing: "compact"` lines concatenated with a single space and no line breaks -- `spacing: "preserve"` keeps line breaks and space around as is. Indentation space counts from `*` delimiter or from the start of the line if the delimiter is omitted -- `spacing: (lines: Line[]) => string` completely freeform joining strategy, since all original spacing can be accessed, there is no limit to how this can be implemented. See [primitives.ts](./src/primitives.ts) and [spacer.ts](./src/parser/spacer.ts) - -### `join: string | number | boolean` - -> If the following lines of a multiline comment do not start with a star, `join` will have the following effect on tag source (and description) when joining the lines together: -> -> - If a string, use that string in place of the leading whitespace (and avoid newlines). -> - If a non-zero number (e.g., 1), do no trimming and avoid newlines. -> - If undefined, false, or 0, use the default behavior of not trimming but adding a newline. -> - Otherwise (e.g., if join is true), replace any leading whitespace with a single space and avoid newlines. -> -> Note that if a multi-line comment has lines that start with a star, these will be appended with initial whitespace as is and with newlines regardless of the join setting. - -See the `spacing` option above, all the variations can be fine-tunned with `spacing: (lines: Line[]) => string` - -### `fence: string | RegExp | ((source: string) => boolean)` - -> Set to a string or regular expression to toggle state upon finding an odd number of matches within a line. Defaults to ```. -> -> If set to a function, it should return true to toggle fenced state; upon returning true the first time, this will prevent subsequent lines from being interpreted as starting a new jsdoc tag until such time as the function returns true again to indicate that the state has toggled back. - -This is mostly kept the same - -**New optoins:** - -- ```` fence: '```' ```` same as 0.x -- `fencer: (source: string) => boolean` same as 0.x, see [parser/block-parser.ts](./src/parser/block-parser.ts) - -### `parsers: Parser[]` - -> In case you need to parse tags in different way you can pass opts.parsers = [parser1, ..., parserN], where each parser is function name(str:String, data:Object):{source:String, data:Object}. -> ... - -**New options:** - -- `tokenizers: []Tokenizer` is a list of functions extracting the `tag`, `type`, `name` and `description` tokens from this string. See [parser/spec-parser.ts](./src/parser/spec-parser.ts) and [primitives.ts](./src/primitives.ts) - -Default tokenizers chain is - -```js -[ - tagTokenizer(), - typeTokenizer(), - nameTokenizer(), - descriptionTokenizer(getSpacer(spacing)), -] -``` - -where - -```ts -type Tokenizer = (spec: Spec) => Spec - -interface Spec { - tag: string; - name: string; - default?: string; - type: string; - optional: boolean; - description: string; - problems: Problem[]; - source: Line[]; -} -``` - -chain starts with blank `Spec` and each tokenizer fulfills a piece using `.source` input - -## Stringifier - -> One may also convert comment-parser JSON structures back into strings using the stringify method (stringify(o: (object|Array) [, opts: object]): string). -> ... - -Stringifier config follows the same strategy โ€“ a couple of common cases, and freeform formatter as a fallback - -**New Options:** - -- `format: "none"` re-assembles the source with original spacing and delimiters preserved -- `format: "align"` aligns tag, name, type, and descriptions into fixed-width columns -- `format: (tokens: Tokens) => string[]` do what you like, resulting lines will be concatenated into the output. Despite the simple interface, this can be turned into a complex stateful formatter, see `"align"` implementation in [transforms/align.ts](./src/transforms/align.ts) - -## Stream - -Work in progress diff --git a/tools/eslint/node_modules/comment-parser/package.json b/tools/eslint/node_modules/comment-parser/package.json deleted file mode 100644 index f20c80355dbbba..00000000000000 --- a/tools/eslint/node_modules/comment-parser/package.json +++ /dev/null @@ -1,84 +0,0 @@ -{ - "name": "comment-parser", - "version": "1.4.1", - "description": "Generic JSDoc-like comment parser", - "type": "module", - "main": "lib/index.cjs", - "exports": { - ".": { - "import": "./es6/index.js", - "require": "./lib/index.cjs" - }, - "./primitives": { - "import": "./es6/primitives.js", - "require": "./lib/primitives.cjs" - }, - "./util": { - "import": "./es6/util.js", - "require": "./lib/util.cjs" - }, - "./parser/*": { - "import": "./es6/parser/*.js", - "require": "./lib/parser/*.cjs" - }, - "./stringifier/*": { - "import": "./es6/stringifier/*.js", - "require": "./lib/stringifier/*.cjs" - }, - "./transforms/*": { - "import": "./es6/transforms/*.js", - "require": "./lib/transforms/*.cjs" - } - }, - "types": "lib/index.d.ts", - "directories": { - "test": "tests" - }, - "devDependencies": { - "@types/jest": "^26.0.23", - "convert-extension": "^0.3.0", - "jest": "^27.0.5", - "prettier": "2.3.1", - "rimraf": "^3.0.2", - "rollup": "^2.52.2", - "ts-jest": "^27.0.3", - "typescript": "^4.9.5" - }, - "engines": { - "node": ">= 12.0.0" - }, - "scripts": { - "build": "rimraf lib es6 browser; tsc -p tsconfig.json && tsc -p tsconfig.node.json && rollup -o browser/index.js -f iife --context window -n CommentParser es6/index.js && convert-extension cjs lib/", - "format": "prettier --write src tests", - "pretest": "rimraf coverage; npm run build", - "test": "prettier --check src tests && jest --verbose", - "preversion": "npm run build" - }, - "repository": { - "type": "git", - "url": "git@github.com:yavorskiy/comment-parser.git" - }, - "keywords": [ - "jsdoc", - "comments", - "parser" - ], - "author": "Sergiy Yavorsky (https://github.com/syavorsky)", - "contributors": [ - "Alex Grozav (https://github.com/alexgrozav)", - "Alexej Yaroshevich (https://github.com/zxqfox)", - "Andre Wachsmuth (https://github.com/blutorange)", - "Brett Zamir (https://github.com/brettz9)", - "Dieter Oberkofler (https://github.com/doberkofler)", - "Evgeny Reznichenko (https://github.com/zxcabs)", - "Javier \"Ciberma\" Mora (https://github.com/jhm-ciberman)", - "Jayden Seric (https://github.com/jaydenseric)", - "Jordan Harband (https://github.com/ljharb)", - "tengattack (https://github.com/tengattack)" - ], - "license": "MIT", - "bugs": { - "url": "https://github.com/syavorsky/comment-parser/issues" - }, - "homepage": "https://github.com/syavorsky/comment-parser" -} diff --git a/tools/eslint/node_modules/comment-parser/tsconfig.node.json b/tools/eslint/node_modules/comment-parser/tsconfig.node.json deleted file mode 100644 index 6b0bb474487840..00000000000000 --- a/tools/eslint/node_modules/comment-parser/tsconfig.node.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "compilerOptions": { - "target": "es2015", - "module": "commonjs", - "moduleResolution": "node16", - "declaration": true, - "outDir": "./lib", - "lib": ["es2016", "es5"] - }, - "include": ["src"], - "exclude": ["node_modules"] -} diff --git a/tools/eslint/node_modules/concat-map/LICENSE b/tools/eslint/node_modules/concat-map/LICENSE deleted file mode 100644 index ee27ba4b4412b0..00000000000000 --- a/tools/eslint/node_modules/concat-map/LICENSE +++ /dev/null @@ -1,18 +0,0 @@ -This software is released under the MIT license: - -Permission is hereby granted, free of charge, to any person obtaining a copy of -this software and associated documentation files (the "Software"), to deal in -the Software without restriction, including without limitation the rights to -use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of -the Software, and to permit persons to whom the Software is furnished to do so, -subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS -FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR -COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER -IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/tools/eslint/node_modules/concat-map/index.js b/tools/eslint/node_modules/concat-map/index.js deleted file mode 100644 index b29a7812e5055a..00000000000000 --- a/tools/eslint/node_modules/concat-map/index.js +++ /dev/null @@ -1,13 +0,0 @@ -module.exports = function (xs, fn) { - var res = []; - for (var i = 0; i < xs.length; i++) { - var x = fn(xs[i], i); - if (isArray(x)) res.push.apply(res, x); - else res.push(x); - } - return res; -}; - -var isArray = Array.isArray || function (xs) { - return Object.prototype.toString.call(xs) === '[object Array]'; -}; diff --git a/tools/eslint/node_modules/concat-map/package.json b/tools/eslint/node_modules/concat-map/package.json deleted file mode 100644 index d3640e6b027b9e..00000000000000 --- a/tools/eslint/node_modules/concat-map/package.json +++ /dev/null @@ -1,43 +0,0 @@ -{ - "name" : "concat-map", - "description" : "concatenative mapdashery", - "version" : "0.0.1", - "repository" : { - "type" : "git", - "url" : "git://github.com/substack/node-concat-map.git" - }, - "main" : "index.js", - "keywords" : [ - "concat", - "concatMap", - "map", - "functional", - "higher-order" - ], - "directories" : { - "example" : "example", - "test" : "test" - }, - "scripts" : { - "test" : "tape test/*.js" - }, - "devDependencies" : { - "tape" : "~2.4.0" - }, - "license" : "MIT", - "author" : { - "name" : "James Halliday", - "email" : "mail@substack.net", - "url" : "http://substack.net" - }, - "testling" : { - "files" : "test/*.js", - "browsers" : { - "ie" : [ 6, 7, 8, 9 ], - "ff" : [ 3.5, 10, 15.0 ], - "chrome" : [ 10, 22 ], - "safari" : [ 5.1 ], - "opera" : [ 12 ] - } - } -} diff --git a/tools/eslint/node_modules/convert-source-map/LICENSE b/tools/eslint/node_modules/convert-source-map/LICENSE deleted file mode 100644 index 41702c5043478f..00000000000000 --- a/tools/eslint/node_modules/convert-source-map/LICENSE +++ /dev/null @@ -1,23 +0,0 @@ -Copyright 2013 Thorsten Lorenz. -All rights reserved. - -Permission is hereby granted, free of charge, to any person -obtaining a copy of this software and associated documentation -files (the "Software"), to deal in the Software without -restriction, including without limitation the rights to use, -copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the -Software is furnished to do so, subject to the following -conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES -OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT -HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, -WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR -OTHER DEALINGS IN THE SOFTWARE. diff --git a/tools/eslint/node_modules/convert-source-map/index.js b/tools/eslint/node_modules/convert-source-map/index.js deleted file mode 100644 index 2e8e916e79d66c..00000000000000 --- a/tools/eslint/node_modules/convert-source-map/index.js +++ /dev/null @@ -1,233 +0,0 @@ -'use strict'; - -Object.defineProperty(exports, 'commentRegex', { - get: function getCommentRegex () { - // Groups: 1: media type, 2: MIME type, 3: charset, 4: encoding, 5: data. - return /^\s*?\/[\/\*][@#]\s+?sourceMappingURL=data:(((?:application|text)\/json)(?:;charset=([^;,]+?)?)?)?(?:;(base64))?,(.*?)$/mg; - } -}); - - -Object.defineProperty(exports, 'mapFileCommentRegex', { - get: function getMapFileCommentRegex () { - // Matches sourceMappingURL in either // or /* comment styles. - return /(?:\/\/[@#][ \t]+?sourceMappingURL=([^\s'"`]+?)[ \t]*?$)|(?:\/\*[@#][ \t]+sourceMappingURL=([^*]+?)[ \t]*?(?:\*\/){1}[ \t]*?$)/mg; - } -}); - -var decodeBase64; -if (typeof Buffer !== 'undefined') { - if (typeof Buffer.from === 'function') { - decodeBase64 = decodeBase64WithBufferFrom; - } else { - decodeBase64 = decodeBase64WithNewBuffer; - } -} else { - decodeBase64 = decodeBase64WithAtob; -} - -function decodeBase64WithBufferFrom(base64) { - return Buffer.from(base64, 'base64').toString(); -} - -function decodeBase64WithNewBuffer(base64) { - if (typeof value === 'number') { - throw new TypeError('The value to decode must not be of type number.'); - } - return new Buffer(base64, 'base64').toString(); -} - -function decodeBase64WithAtob(base64) { - return decodeURIComponent(escape(atob(base64))); -} - -function stripComment(sm) { - return sm.split(',').pop(); -} - -function readFromFileMap(sm, read) { - var r = exports.mapFileCommentRegex.exec(sm); - // for some odd reason //# .. captures in 1 and /* .. */ in 2 - var filename = r[1] || r[2]; - - try { - var sm = read(filename); - if (sm != null && typeof sm.catch === 'function') { - return sm.catch(throwError); - } else { - return sm; - } - } catch (e) { - throwError(e); - } - - function throwError(e) { - throw new Error('An error occurred while trying to read the map file at ' + filename + '\n' + e.stack); - } -} - -function Converter (sm, opts) { - opts = opts || {}; - - if (opts.hasComment) { - sm = stripComment(sm); - } - - if (opts.encoding === 'base64') { - sm = decodeBase64(sm); - } else if (opts.encoding === 'uri') { - sm = decodeURIComponent(sm); - } - - if (opts.isJSON || opts.encoding) { - sm = JSON.parse(sm); - } - - this.sourcemap = sm; -} - -Converter.prototype.toJSON = function (space) { - return JSON.stringify(this.sourcemap, null, space); -}; - -if (typeof Buffer !== 'undefined') { - if (typeof Buffer.from === 'function') { - Converter.prototype.toBase64 = encodeBase64WithBufferFrom; - } else { - Converter.prototype.toBase64 = encodeBase64WithNewBuffer; - } -} else { - Converter.prototype.toBase64 = encodeBase64WithBtoa; -} - -function encodeBase64WithBufferFrom() { - var json = this.toJSON(); - return Buffer.from(json, 'utf8').toString('base64'); -} - -function encodeBase64WithNewBuffer() { - var json = this.toJSON(); - if (typeof json === 'number') { - throw new TypeError('The json to encode must not be of type number.'); - } - return new Buffer(json, 'utf8').toString('base64'); -} - -function encodeBase64WithBtoa() { - var json = this.toJSON(); - return btoa(unescape(encodeURIComponent(json))); -} - -Converter.prototype.toURI = function () { - var json = this.toJSON(); - return encodeURIComponent(json); -}; - -Converter.prototype.toComment = function (options) { - var encoding, content, data; - if (options != null && options.encoding === 'uri') { - encoding = ''; - content = this.toURI(); - } else { - encoding = ';base64'; - content = this.toBase64(); - } - data = 'sourceMappingURL=data:application/json;charset=utf-8' + encoding + ',' + content; - return options != null && options.multiline ? '/*# ' + data + ' */' : '//# ' + data; -}; - -// returns copy instead of original -Converter.prototype.toObject = function () { - return JSON.parse(this.toJSON()); -}; - -Converter.prototype.addProperty = function (key, value) { - if (this.sourcemap.hasOwnProperty(key)) throw new Error('property "' + key + '" already exists on the sourcemap, use set property instead'); - return this.setProperty(key, value); -}; - -Converter.prototype.setProperty = function (key, value) { - this.sourcemap[key] = value; - return this; -}; - -Converter.prototype.getProperty = function (key) { - return this.sourcemap[key]; -}; - -exports.fromObject = function (obj) { - return new Converter(obj); -}; - -exports.fromJSON = function (json) { - return new Converter(json, { isJSON: true }); -}; - -exports.fromURI = function (uri) { - return new Converter(uri, { encoding: 'uri' }); -}; - -exports.fromBase64 = function (base64) { - return new Converter(base64, { encoding: 'base64' }); -}; - -exports.fromComment = function (comment) { - var m, encoding; - comment = comment - .replace(/^\/\*/g, '//') - .replace(/\*\/$/g, ''); - m = exports.commentRegex.exec(comment); - encoding = m && m[4] || 'uri'; - return new Converter(comment, { encoding: encoding, hasComment: true }); -}; - -function makeConverter(sm) { - return new Converter(sm, { isJSON: true }); -} - -exports.fromMapFileComment = function (comment, read) { - if (typeof read === 'string') { - throw new Error( - 'String directory paths are no longer supported with `fromMapFileComment`\n' + - 'Please review the Upgrading documentation at https://github.com/thlorenz/convert-source-map#upgrading' - ) - } - - var sm = readFromFileMap(comment, read); - if (sm != null && typeof sm.then === 'function') { - return sm.then(makeConverter); - } else { - return makeConverter(sm); - } -}; - -// Finds last sourcemap comment in file or returns null if none was found -exports.fromSource = function (content) { - var m = content.match(exports.commentRegex); - return m ? exports.fromComment(m.pop()) : null; -}; - -// Finds last sourcemap comment in file or returns null if none was found -exports.fromMapFileSource = function (content, read) { - if (typeof read === 'string') { - throw new Error( - 'String directory paths are no longer supported with `fromMapFileSource`\n' + - 'Please review the Upgrading documentation at https://github.com/thlorenz/convert-source-map#upgrading' - ) - } - var m = content.match(exports.mapFileCommentRegex); - return m ? exports.fromMapFileComment(m.pop(), read) : null; -}; - -exports.removeComments = function (src) { - return src.replace(exports.commentRegex, ''); -}; - -exports.removeMapFileComments = function (src) { - return src.replace(exports.mapFileCommentRegex, ''); -}; - -exports.generateMapFileComment = function (file, options) { - var data = 'sourceMappingURL=' + file; - return options && options.multiline ? '/*# ' + data + ' */' : '//# ' + data; -}; diff --git a/tools/eslint/node_modules/convert-source-map/package.json b/tools/eslint/node_modules/convert-source-map/package.json deleted file mode 100644 index c38f29f7200dc8..00000000000000 --- a/tools/eslint/node_modules/convert-source-map/package.json +++ /dev/null @@ -1,38 +0,0 @@ -{ - "name": "convert-source-map", - "version": "2.0.0", - "description": "Converts a source-map from/to different formats and allows adding/changing properties.", - "main": "index.js", - "scripts": { - "test": "tap test/*.js --color" - }, - "repository": { - "type": "git", - "url": "git://github.com/thlorenz/convert-source-map.git" - }, - "homepage": "https://github.com/thlorenz/convert-source-map", - "devDependencies": { - "inline-source-map": "~0.6.2", - "tap": "~9.0.0" - }, - "keywords": [ - "convert", - "sourcemap", - "source", - "map", - "browser", - "debug" - ], - "author": { - "name": "Thorsten Lorenz", - "email": "thlorenz@gmx.de", - "url": "http://thlorenz.com" - }, - "license": "MIT", - "engine": { - "node": ">=4" - }, - "files": [ - "index.js" - ] -} diff --git a/tools/eslint/node_modules/cross-spawn/LICENSE b/tools/eslint/node_modules/cross-spawn/LICENSE deleted file mode 100644 index 8407b9a30f51b0..00000000000000 --- a/tools/eslint/node_modules/cross-spawn/LICENSE +++ /dev/null @@ -1,21 +0,0 @@ -The MIT License (MIT) - -Copyright (c) 2018 Made With MOXY Lda - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. diff --git a/tools/eslint/node_modules/cross-spawn/index.js b/tools/eslint/node_modules/cross-spawn/index.js deleted file mode 100644 index 5509742ca9fa8f..00000000000000 --- a/tools/eslint/node_modules/cross-spawn/index.js +++ /dev/null @@ -1,39 +0,0 @@ -'use strict'; - -const cp = require('child_process'); -const parse = require('./lib/parse'); -const enoent = require('./lib/enoent'); - -function spawn(command, args, options) { - // Parse the arguments - const parsed = parse(command, args, options); - - // Spawn the child process - const spawned = cp.spawn(parsed.command, parsed.args, parsed.options); - - // Hook into child process "exit" event to emit an error if the command - // does not exists, see: https://github.com/IndigoUnited/node-cross-spawn/issues/16 - enoent.hookChildProcess(spawned, parsed); - - return spawned; -} - -function spawnSync(command, args, options) { - // Parse the arguments - const parsed = parse(command, args, options); - - // Spawn the child process - const result = cp.spawnSync(parsed.command, parsed.args, parsed.options); - - // Analyze if the command does not exist, see: https://github.com/IndigoUnited/node-cross-spawn/issues/16 - result.error = result.error || enoent.verifyENOENTSync(result.status, parsed); - - return result; -} - -module.exports = spawn; -module.exports.spawn = spawn; -module.exports.sync = spawnSync; - -module.exports._parse = parse; -module.exports._enoent = enoent; diff --git a/tools/eslint/node_modules/cross-spawn/lib/enoent.js b/tools/eslint/node_modules/cross-spawn/lib/enoent.js deleted file mode 100644 index 14df9b623d0a20..00000000000000 --- a/tools/eslint/node_modules/cross-spawn/lib/enoent.js +++ /dev/null @@ -1,59 +0,0 @@ -'use strict'; - -const isWin = process.platform === 'win32'; - -function notFoundError(original, syscall) { - return Object.assign(new Error(`${syscall} ${original.command} ENOENT`), { - code: 'ENOENT', - errno: 'ENOENT', - syscall: `${syscall} ${original.command}`, - path: original.command, - spawnargs: original.args, - }); -} - -function hookChildProcess(cp, parsed) { - if (!isWin) { - return; - } - - const originalEmit = cp.emit; - - cp.emit = function (name, arg1) { - // If emitting "exit" event and exit code is 1, we need to check if - // the command exists and emit an "error" instead - // See https://github.com/IndigoUnited/node-cross-spawn/issues/16 - if (name === 'exit') { - const err = verifyENOENT(arg1, parsed, 'spawn'); - - if (err) { - return originalEmit.call(cp, 'error', err); - } - } - - return originalEmit.apply(cp, arguments); // eslint-disable-line prefer-rest-params - }; -} - -function verifyENOENT(status, parsed) { - if (isWin && status === 1 && !parsed.file) { - return notFoundError(parsed.original, 'spawn'); - } - - return null; -} - -function verifyENOENTSync(status, parsed) { - if (isWin && status === 1 && !parsed.file) { - return notFoundError(parsed.original, 'spawnSync'); - } - - return null; -} - -module.exports = { - hookChildProcess, - verifyENOENT, - verifyENOENTSync, - notFoundError, -}; diff --git a/tools/eslint/node_modules/cross-spawn/lib/parse.js b/tools/eslint/node_modules/cross-spawn/lib/parse.js deleted file mode 100644 index 0129d74774a8a0..00000000000000 --- a/tools/eslint/node_modules/cross-spawn/lib/parse.js +++ /dev/null @@ -1,91 +0,0 @@ -'use strict'; - -const path = require('path'); -const resolveCommand = require('./util/resolveCommand'); -const escape = require('./util/escape'); -const readShebang = require('./util/readShebang'); - -const isWin = process.platform === 'win32'; -const isExecutableRegExp = /\.(?:com|exe)$/i; -const isCmdShimRegExp = /node_modules[\\/].bin[\\/][^\\/]+\.cmd$/i; - -function detectShebang(parsed) { - parsed.file = resolveCommand(parsed); - - const shebang = parsed.file && readShebang(parsed.file); - - if (shebang) { - parsed.args.unshift(parsed.file); - parsed.command = shebang; - - return resolveCommand(parsed); - } - - return parsed.file; -} - -function parseNonShell(parsed) { - if (!isWin) { - return parsed; - } - - // Detect & add support for shebangs - const commandFile = detectShebang(parsed); - - // We don't need a shell if the command filename is an executable - const needsShell = !isExecutableRegExp.test(commandFile); - - // If a shell is required, use cmd.exe and take care of escaping everything correctly - // Note that `forceShell` is an hidden option used only in tests - if (parsed.options.forceShell || needsShell) { - // Need to double escape meta chars if the command is a cmd-shim located in `node_modules/.bin/` - // The cmd-shim simply calls execute the package bin file with NodeJS, proxying any argument - // Because the escape of metachars with ^ gets interpreted when the cmd.exe is first called, - // we need to double escape them - const needsDoubleEscapeMetaChars = isCmdShimRegExp.test(commandFile); - - // Normalize posix paths into OS compatible paths (e.g.: foo/bar -> foo\bar) - // This is necessary otherwise it will always fail with ENOENT in those cases - parsed.command = path.normalize(parsed.command); - - // Escape command & arguments - parsed.command = escape.command(parsed.command); - parsed.args = parsed.args.map((arg) => escape.argument(arg, needsDoubleEscapeMetaChars)); - - const shellCommand = [parsed.command].concat(parsed.args).join(' '); - - parsed.args = ['/d', '/s', '/c', `"${shellCommand}"`]; - parsed.command = process.env.comspec || 'cmd.exe'; - parsed.options.windowsVerbatimArguments = true; // Tell node's spawn that the arguments are already escaped - } - - return parsed; -} - -function parse(command, args, options) { - // Normalize arguments, similar to nodejs - if (args && !Array.isArray(args)) { - options = args; - args = null; - } - - args = args ? args.slice(0) : []; // Clone array to avoid changing the original - options = Object.assign({}, options); // Clone object to avoid changing the original - - // Build our parsed object - const parsed = { - command, - args, - options, - file: undefined, - original: { - command, - args, - }, - }; - - // Delegate further parsing to shell or non-shell - return options.shell ? parsed : parseNonShell(parsed); -} - -module.exports = parse; diff --git a/tools/eslint/node_modules/cross-spawn/lib/util/escape.js b/tools/eslint/node_modules/cross-spawn/lib/util/escape.js deleted file mode 100644 index b0bb84c3a14092..00000000000000 --- a/tools/eslint/node_modules/cross-spawn/lib/util/escape.js +++ /dev/null @@ -1,45 +0,0 @@ -'use strict'; - -// See http://www.robvanderwoude.com/escapechars.php -const metaCharsRegExp = /([()\][%!^"`<>&|;, *?])/g; - -function escapeCommand(arg) { - // Escape meta chars - arg = arg.replace(metaCharsRegExp, '^$1'); - - return arg; -} - -function escapeArgument(arg, doubleEscapeMetaChars) { - // Convert to string - arg = `${arg}`; - - // Algorithm below is based on https://qntm.org/cmd - - // Sequence of backslashes followed by a double quote: - // double up all the backslashes and escape the double quote - arg = arg.replace(/(\\*)"/g, '$1$1\\"'); - - // Sequence of backslashes followed by the end of the string - // (which will become a double quote later): - // double up all the backslashes - arg = arg.replace(/(\\*)$/, '$1$1'); - - // All other backslashes occur literally - - // Quote the whole thing: - arg = `"${arg}"`; - - // Escape meta chars - arg = arg.replace(metaCharsRegExp, '^$1'); - - // Double escape meta chars if necessary - if (doubleEscapeMetaChars) { - arg = arg.replace(metaCharsRegExp, '^$1'); - } - - return arg; -} - -module.exports.command = escapeCommand; -module.exports.argument = escapeArgument; diff --git a/tools/eslint/node_modules/cross-spawn/lib/util/readShebang.js b/tools/eslint/node_modules/cross-spawn/lib/util/readShebang.js deleted file mode 100644 index 5e83733fef260f..00000000000000 --- a/tools/eslint/node_modules/cross-spawn/lib/util/readShebang.js +++ /dev/null @@ -1,23 +0,0 @@ -'use strict'; - -const fs = require('fs'); -const shebangCommand = require('shebang-command'); - -function readShebang(command) { - // Read the first 150 bytes from the file - const size = 150; - const buffer = Buffer.alloc(size); - - let fd; - - try { - fd = fs.openSync(command, 'r'); - fs.readSync(fd, buffer, 0, size, 0); - fs.closeSync(fd); - } catch (e) { /* Empty */ } - - // Attempt to extract shebang (null is returned if not a shebang) - return shebangCommand(buffer.toString()); -} - -module.exports = readShebang; diff --git a/tools/eslint/node_modules/cross-spawn/lib/util/resolveCommand.js b/tools/eslint/node_modules/cross-spawn/lib/util/resolveCommand.js deleted file mode 100644 index 7972455008e917..00000000000000 --- a/tools/eslint/node_modules/cross-spawn/lib/util/resolveCommand.js +++ /dev/null @@ -1,52 +0,0 @@ -'use strict'; - -const path = require('path'); -const which = require('which'); -const getPathKey = require('path-key'); - -function resolveCommandAttempt(parsed, withoutPathExt) { - const env = parsed.options.env || process.env; - const cwd = process.cwd(); - const hasCustomCwd = parsed.options.cwd != null; - // Worker threads do not have process.chdir() - const shouldSwitchCwd = hasCustomCwd && process.chdir !== undefined && !process.chdir.disabled; - - // If a custom `cwd` was specified, we need to change the process cwd - // because `which` will do stat calls but does not support a custom cwd - if (shouldSwitchCwd) { - try { - process.chdir(parsed.options.cwd); - } catch (err) { - /* Empty */ - } - } - - let resolved; - - try { - resolved = which.sync(parsed.command, { - path: env[getPathKey({ env })], - pathExt: withoutPathExt ? path.delimiter : undefined, - }); - } catch (e) { - /* Empty */ - } finally { - if (shouldSwitchCwd) { - process.chdir(cwd); - } - } - - // If we successfully resolved, ensure that an absolute path is returned - // Note that when a custom `cwd` was used, we need to resolve to an absolute path based on it - if (resolved) { - resolved = path.resolve(hasCustomCwd ? parsed.options.cwd : '', resolved); - } - - return resolved; -} - -function resolveCommand(parsed) { - return resolveCommandAttempt(parsed) || resolveCommandAttempt(parsed, true); -} - -module.exports = resolveCommand; diff --git a/tools/eslint/node_modules/cross-spawn/package.json b/tools/eslint/node_modules/cross-spawn/package.json deleted file mode 100644 index 232ff97e04b213..00000000000000 --- a/tools/eslint/node_modules/cross-spawn/package.json +++ /dev/null @@ -1,73 +0,0 @@ -{ - "name": "cross-spawn", - "version": "7.0.3", - "description": "Cross platform child_process#spawn and child_process#spawnSync", - "keywords": [ - "spawn", - "spawnSync", - "windows", - "cross-platform", - "path-ext", - "shebang", - "cmd", - "execute" - ], - "author": "Andrรฉ Cruz ", - "homepage": "https://github.com/moxystudio/node-cross-spawn", - "repository": { - "type": "git", - "url": "git@github.com:moxystudio/node-cross-spawn.git" - }, - "license": "MIT", - "main": "index.js", - "files": [ - "lib" - ], - "scripts": { - "lint": "eslint .", - "test": "jest --env node --coverage", - "prerelease": "npm t && npm run lint", - "release": "standard-version", - "postrelease": "git push --follow-tags origin HEAD && npm publish" - }, - "husky": { - "hooks": { - "commit-msg": "commitlint -E HUSKY_GIT_PARAMS", - "pre-commit": "lint-staged" - } - }, - "lint-staged": { - "*.js": [ - "eslint --fix", - "git add" - ] - }, - "commitlint": { - "extends": [ - "@commitlint/config-conventional" - ] - }, - "dependencies": { - "path-key": "^3.1.0", - "shebang-command": "^2.0.0", - "which": "^2.0.1" - }, - "devDependencies": { - "@commitlint/cli": "^8.1.0", - "@commitlint/config-conventional": "^8.1.0", - "babel-core": "^6.26.3", - "babel-jest": "^24.9.0", - "babel-preset-moxy": "^3.1.0", - "eslint": "^5.16.0", - "eslint-config-moxy": "^7.1.0", - "husky": "^3.0.5", - "jest": "^24.9.0", - "lint-staged": "^9.2.5", - "mkdirp": "^0.5.1", - "rimraf": "^3.0.0", - "standard-version": "^7.0.0" - }, - "engines": { - "node": ">= 8" - } -} diff --git a/tools/eslint/node_modules/debug/LICENSE b/tools/eslint/node_modules/debug/LICENSE deleted file mode 100644 index 1a9820e262b26b..00000000000000 --- a/tools/eslint/node_modules/debug/LICENSE +++ /dev/null @@ -1,20 +0,0 @@ -(The MIT License) - -Copyright (c) 2014-2017 TJ Holowaychuk -Copyright (c) 2018-2021 Josh Junon - -Permission is hereby granted, free of charge, to any person obtaining a copy of this software -and associated documentation files (the 'Software'), to deal in the Software without restriction, -including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, -and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, -subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all copies or substantial -portions of the Software. - -THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT -LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, -WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - diff --git a/tools/eslint/node_modules/debug/package.json b/tools/eslint/node_modules/debug/package.json deleted file mode 100644 index cb67103857af1f..00000000000000 --- a/tools/eslint/node_modules/debug/package.json +++ /dev/null @@ -1,60 +0,0 @@ -{ - "name": "debug", - "version": "4.3.5", - "repository": { - "type": "git", - "url": "git://github.com/debug-js/debug.git" - }, - "description": "Lightweight debugging utility for Node.js and the browser", - "keywords": [ - "debug", - "log", - "debugger" - ], - "files": [ - "src", - "LICENSE", - "README.md" - ], - "author": "Josh Junon (https://github.com/qix-)", - "contributors": [ - "TJ Holowaychuk ", - "Nathan Rajlich (http://n8.io)", - "Andrew Rhyne " - ], - "license": "MIT", - "scripts": { - "lint": "xo", - "test": "npm run test:node && npm run test:browser && npm run lint", - "test:node": "istanbul cover _mocha -- test.js test.node.js", - "test:browser": "karma start --single-run", - "test:coverage": "cat ./coverage/lcov.info | coveralls" - }, - "dependencies": { - "ms": "2.1.2" - }, - "devDependencies": { - "brfs": "^2.0.1", - "browserify": "^16.2.3", - "coveralls": "^3.0.2", - "istanbul": "^0.4.5", - "karma": "^3.1.4", - "karma-browserify": "^6.0.0", - "karma-chrome-launcher": "^2.2.0", - "karma-mocha": "^1.3.0", - "mocha": "^5.2.0", - "mocha-lcov-reporter": "^1.2.0", - "sinon": "^14.0.0", - "xo": "^0.23.0" - }, - "peerDependenciesMeta": { - "supports-color": { - "optional": true - } - }, - "main": "./src/index.js", - "browser": "./src/browser.js", - "engines": { - "node": ">=6.0" - } -} diff --git a/tools/eslint/node_modules/debug/src/browser.js b/tools/eslint/node_modules/debug/src/browser.js deleted file mode 100644 index cd0fc35d1ee11e..00000000000000 --- a/tools/eslint/node_modules/debug/src/browser.js +++ /dev/null @@ -1,269 +0,0 @@ -/* eslint-env browser */ - -/** - * This is the web browser implementation of `debug()`. - */ - -exports.formatArgs = formatArgs; -exports.save = save; -exports.load = load; -exports.useColors = useColors; -exports.storage = localstorage(); -exports.destroy = (() => { - let warned = false; - - return () => { - if (!warned) { - warned = true; - console.warn('Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.'); - } - }; -})(); - -/** - * Colors. - */ - -exports.colors = [ - '#0000CC', - '#0000FF', - '#0033CC', - '#0033FF', - '#0066CC', - '#0066FF', - '#0099CC', - '#0099FF', - '#00CC00', - '#00CC33', - '#00CC66', - '#00CC99', - '#00CCCC', - '#00CCFF', - '#3300CC', - '#3300FF', - '#3333CC', - '#3333FF', - '#3366CC', - '#3366FF', - '#3399CC', - '#3399FF', - '#33CC00', - '#33CC33', - '#33CC66', - '#33CC99', - '#33CCCC', - '#33CCFF', - '#6600CC', - '#6600FF', - '#6633CC', - '#6633FF', - '#66CC00', - '#66CC33', - '#9900CC', - '#9900FF', - '#9933CC', - '#9933FF', - '#99CC00', - '#99CC33', - '#CC0000', - '#CC0033', - '#CC0066', - '#CC0099', - '#CC00CC', - '#CC00FF', - '#CC3300', - '#CC3333', - '#CC3366', - '#CC3399', - '#CC33CC', - '#CC33FF', - '#CC6600', - '#CC6633', - '#CC9900', - '#CC9933', - '#CCCC00', - '#CCCC33', - '#FF0000', - '#FF0033', - '#FF0066', - '#FF0099', - '#FF00CC', - '#FF00FF', - '#FF3300', - '#FF3333', - '#FF3366', - '#FF3399', - '#FF33CC', - '#FF33FF', - '#FF6600', - '#FF6633', - '#FF9900', - '#FF9933', - '#FFCC00', - '#FFCC33' -]; - -/** - * Currently only WebKit-based Web Inspectors, Firefox >= v31, - * and the Firebug extension (any Firefox version) are known - * to support "%c" CSS customizations. - * - * TODO: add a `localStorage` variable to explicitly enable/disable colors - */ - -// eslint-disable-next-line complexity -function useColors() { - // NB: In an Electron preload script, document will be defined but not fully - // initialized. Since we know we're in Chrome, we'll just detect this case - // explicitly - if (typeof window !== 'undefined' && window.process && (window.process.type === 'renderer' || window.process.__nwjs)) { - return true; - } - - // Internet Explorer and Edge do not support colors. - if (typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/)) { - return false; - } - - // Is webkit? http://stackoverflow.com/a/16459606/376773 - // document is undefined in react-native: https://github.com/facebook/react-native/pull/1632 - return (typeof document !== 'undefined' && document.documentElement && document.documentElement.style && document.documentElement.style.WebkitAppearance) || - // Is firebug? http://stackoverflow.com/a/398120/376773 - (typeof window !== 'undefined' && window.console && (window.console.firebug || (window.console.exception && window.console.table))) || - // Is firefox >= v31? - // https://developer.mozilla.org/en-US/docs/Tools/Web_Console#Styling_messages - (typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/) && parseInt(RegExp.$1, 10) >= 31) || - // Double check webkit in userAgent just in case we are in a worker - (typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)); -} - -/** - * Colorize log arguments if enabled. - * - * @api public - */ - -function formatArgs(args) { - args[0] = (this.useColors ? '%c' : '') + - this.namespace + - (this.useColors ? ' %c' : ' ') + - args[0] + - (this.useColors ? '%c ' : ' ') + - '+' + module.exports.humanize(this.diff); - - if (!this.useColors) { - return; - } - - const c = 'color: ' + this.color; - args.splice(1, 0, c, 'color: inherit'); - - // The final "%c" is somewhat tricky, because there could be other - // arguments passed either before or after the %c, so we need to - // figure out the correct index to insert the CSS into - let index = 0; - let lastC = 0; - args[0].replace(/%[a-zA-Z%]/g, match => { - if (match === '%%') { - return; - } - index++; - if (match === '%c') { - // We only are interested in the *last* %c - // (the user may have provided their own) - lastC = index; - } - }); - - args.splice(lastC, 0, c); -} - -/** - * Invokes `console.debug()` when available. - * No-op when `console.debug` is not a "function". - * If `console.debug` is not available, falls back - * to `console.log`. - * - * @api public - */ -exports.log = console.debug || console.log || (() => {}); - -/** - * Save `namespaces`. - * - * @param {String} namespaces - * @api private - */ -function save(namespaces) { - try { - if (namespaces) { - exports.storage.setItem('debug', namespaces); - } else { - exports.storage.removeItem('debug'); - } - } catch (error) { - // Swallow - // XXX (@Qix-) should we be logging these? - } -} - -/** - * Load `namespaces`. - * - * @return {String} returns the previously persisted debug modes - * @api private - */ -function load() { - let r; - try { - r = exports.storage.getItem('debug'); - } catch (error) { - // Swallow - // XXX (@Qix-) should we be logging these? - } - - // If debug isn't set in LS, and we're in Electron, try to load $DEBUG - if (!r && typeof process !== 'undefined' && 'env' in process) { - r = process.env.DEBUG; - } - - return r; -} - -/** - * Localstorage attempts to return the localstorage. - * - * This is necessary because safari throws - * when a user disables cookies/localstorage - * and you attempt to access it. - * - * @return {LocalStorage} - * @api private - */ - -function localstorage() { - try { - // TVMLKit (Apple TV JS Runtime) does not have a window object, just localStorage in the global context - // The Browser also has localStorage in the global context. - return localStorage; - } catch (error) { - // Swallow - // XXX (@Qix-) should we be logging these? - } -} - -module.exports = require('./common')(exports); - -const {formatters} = module.exports; - -/** - * Map %j to `JSON.stringify()`, since no Web Inspectors do that by default. - */ - -formatters.j = function (v) { - try { - return JSON.stringify(v); - } catch (error) { - return '[UnexpectedJSONParseError]: ' + error.message; - } -}; diff --git a/tools/eslint/node_modules/debug/src/common.js b/tools/eslint/node_modules/debug/src/common.js deleted file mode 100644 index e3291b20faa1a6..00000000000000 --- a/tools/eslint/node_modules/debug/src/common.js +++ /dev/null @@ -1,274 +0,0 @@ - -/** - * This is the common logic for both the Node.js and web browser - * implementations of `debug()`. - */ - -function setup(env) { - createDebug.debug = createDebug; - createDebug.default = createDebug; - createDebug.coerce = coerce; - createDebug.disable = disable; - createDebug.enable = enable; - createDebug.enabled = enabled; - createDebug.humanize = require('ms'); - createDebug.destroy = destroy; - - Object.keys(env).forEach(key => { - createDebug[key] = env[key]; - }); - - /** - * The currently active debug mode names, and names to skip. - */ - - createDebug.names = []; - createDebug.skips = []; - - /** - * Map of special "%n" handling functions, for the debug "format" argument. - * - * Valid key names are a single, lower or upper-case letter, i.e. "n" and "N". - */ - createDebug.formatters = {}; - - /** - * Selects a color for a debug namespace - * @param {String} namespace The namespace string for the debug instance to be colored - * @return {Number|String} An ANSI color code for the given namespace - * @api private - */ - function selectColor(namespace) { - let hash = 0; - - for (let i = 0; i < namespace.length; i++) { - hash = ((hash << 5) - hash) + namespace.charCodeAt(i); - hash |= 0; // Convert to 32bit integer - } - - return createDebug.colors[Math.abs(hash) % createDebug.colors.length]; - } - createDebug.selectColor = selectColor; - - /** - * Create a debugger with the given `namespace`. - * - * @param {String} namespace - * @return {Function} - * @api public - */ - function createDebug(namespace) { - let prevTime; - let enableOverride = null; - let namespacesCache; - let enabledCache; - - function debug(...args) { - // Disabled? - if (!debug.enabled) { - return; - } - - const self = debug; - - // Set `diff` timestamp - const curr = Number(new Date()); - const ms = curr - (prevTime || curr); - self.diff = ms; - self.prev = prevTime; - self.curr = curr; - prevTime = curr; - - args[0] = createDebug.coerce(args[0]); - - if (typeof args[0] !== 'string') { - // Anything else let's inspect with %O - args.unshift('%O'); - } - - // Apply any `formatters` transformations - let index = 0; - args[0] = args[0].replace(/%([a-zA-Z%])/g, (match, format) => { - // If we encounter an escaped % then don't increase the array index - if (match === '%%') { - return '%'; - } - index++; - const formatter = createDebug.formatters[format]; - if (typeof formatter === 'function') { - const val = args[index]; - match = formatter.call(self, val); - - // Now we need to remove `args[index]` since it's inlined in the `format` - args.splice(index, 1); - index--; - } - return match; - }); - - // Apply env-specific formatting (colors, etc.) - createDebug.formatArgs.call(self, args); - - const logFn = self.log || createDebug.log; - logFn.apply(self, args); - } - - debug.namespace = namespace; - debug.useColors = createDebug.useColors(); - debug.color = createDebug.selectColor(namespace); - debug.extend = extend; - debug.destroy = createDebug.destroy; // XXX Temporary. Will be removed in the next major release. - - Object.defineProperty(debug, 'enabled', { - enumerable: true, - configurable: false, - get: () => { - if (enableOverride !== null) { - return enableOverride; - } - if (namespacesCache !== createDebug.namespaces) { - namespacesCache = createDebug.namespaces; - enabledCache = createDebug.enabled(namespace); - } - - return enabledCache; - }, - set: v => { - enableOverride = v; - } - }); - - // Env-specific initialization logic for debug instances - if (typeof createDebug.init === 'function') { - createDebug.init(debug); - } - - return debug; - } - - function extend(namespace, delimiter) { - const newDebug = createDebug(this.namespace + (typeof delimiter === 'undefined' ? ':' : delimiter) + namespace); - newDebug.log = this.log; - return newDebug; - } - - /** - * Enables a debug mode by namespaces. This can include modes - * separated by a colon and wildcards. - * - * @param {String} namespaces - * @api public - */ - function enable(namespaces) { - createDebug.save(namespaces); - createDebug.namespaces = namespaces; - - createDebug.names = []; - createDebug.skips = []; - - let i; - const split = (typeof namespaces === 'string' ? namespaces : '').split(/[\s,]+/); - const len = split.length; - - for (i = 0; i < len; i++) { - if (!split[i]) { - // ignore empty strings - continue; - } - - namespaces = split[i].replace(/\*/g, '.*?'); - - if (namespaces[0] === '-') { - createDebug.skips.push(new RegExp('^' + namespaces.slice(1) + '$')); - } else { - createDebug.names.push(new RegExp('^' + namespaces + '$')); - } - } - } - - /** - * Disable debug output. - * - * @return {String} namespaces - * @api public - */ - function disable() { - const namespaces = [ - ...createDebug.names.map(toNamespace), - ...createDebug.skips.map(toNamespace).map(namespace => '-' + namespace) - ].join(','); - createDebug.enable(''); - return namespaces; - } - - /** - * Returns true if the given mode name is enabled, false otherwise. - * - * @param {String} name - * @return {Boolean} - * @api public - */ - function enabled(name) { - if (name[name.length - 1] === '*') { - return true; - } - - let i; - let len; - - for (i = 0, len = createDebug.skips.length; i < len; i++) { - if (createDebug.skips[i].test(name)) { - return false; - } - } - - for (i = 0, len = createDebug.names.length; i < len; i++) { - if (createDebug.names[i].test(name)) { - return true; - } - } - - return false; - } - - /** - * Convert regexp to namespace - * - * @param {RegExp} regxep - * @return {String} namespace - * @api private - */ - function toNamespace(regexp) { - return regexp.toString() - .substring(2, regexp.toString().length - 2) - .replace(/\.\*\?$/, '*'); - } - - /** - * Coerce `val`. - * - * @param {Mixed} val - * @return {Mixed} - * @api private - */ - function coerce(val) { - if (val instanceof Error) { - return val.stack || val.message; - } - return val; - } - - /** - * XXX DO NOT USE. This is a temporary stub function. - * XXX It WILL be removed in the next major release. - */ - function destroy() { - console.warn('Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.'); - } - - createDebug.enable(createDebug.load()); - - return createDebug; -} - -module.exports = setup; diff --git a/tools/eslint/node_modules/debug/src/index.js b/tools/eslint/node_modules/debug/src/index.js deleted file mode 100644 index bf4c57f259df2e..00000000000000 --- a/tools/eslint/node_modules/debug/src/index.js +++ /dev/null @@ -1,10 +0,0 @@ -/** - * Detect Electron renderer / nwjs process, which is node, but we should - * treat as a browser. - */ - -if (typeof process === 'undefined' || process.type === 'renderer' || process.browser === true || process.__nwjs) { - module.exports = require('./browser.js'); -} else { - module.exports = require('./node.js'); -} diff --git a/tools/eslint/node_modules/debug/src/node.js b/tools/eslint/node_modules/debug/src/node.js deleted file mode 100644 index 715560a4ca8fb4..00000000000000 --- a/tools/eslint/node_modules/debug/src/node.js +++ /dev/null @@ -1,263 +0,0 @@ -/** - * Module dependencies. - */ - -const tty = require('tty'); -const util = require('util'); - -/** - * This is the Node.js implementation of `debug()`. - */ - -exports.init = init; -exports.log = log; -exports.formatArgs = formatArgs; -exports.save = save; -exports.load = load; -exports.useColors = useColors; -exports.destroy = util.deprecate( - () => {}, - 'Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.' -); - -/** - * Colors. - */ - -exports.colors = [6, 2, 3, 4, 5, 1]; - -try { - // Optional dependency (as in, doesn't need to be installed, NOT like optionalDependencies in package.json) - // eslint-disable-next-line import/no-extraneous-dependencies - const supportsColor = require('supports-color'); - - if (supportsColor && (supportsColor.stderr || supportsColor).level >= 2) { - exports.colors = [ - 20, - 21, - 26, - 27, - 32, - 33, - 38, - 39, - 40, - 41, - 42, - 43, - 44, - 45, - 56, - 57, - 62, - 63, - 68, - 69, - 74, - 75, - 76, - 77, - 78, - 79, - 80, - 81, - 92, - 93, - 98, - 99, - 112, - 113, - 128, - 129, - 134, - 135, - 148, - 149, - 160, - 161, - 162, - 163, - 164, - 165, - 166, - 167, - 168, - 169, - 170, - 171, - 172, - 173, - 178, - 179, - 184, - 185, - 196, - 197, - 198, - 199, - 200, - 201, - 202, - 203, - 204, - 205, - 206, - 207, - 208, - 209, - 214, - 215, - 220, - 221 - ]; - } -} catch (error) { - // Swallow - we only care if `supports-color` is available; it doesn't have to be. -} - -/** - * Build up the default `inspectOpts` object from the environment variables. - * - * $ DEBUG_COLORS=no DEBUG_DEPTH=10 DEBUG_SHOW_HIDDEN=enabled node script.js - */ - -exports.inspectOpts = Object.keys(process.env).filter(key => { - return /^debug_/i.test(key); -}).reduce((obj, key) => { - // Camel-case - const prop = key - .substring(6) - .toLowerCase() - .replace(/_([a-z])/g, (_, k) => { - return k.toUpperCase(); - }); - - // Coerce string value into JS value - let val = process.env[key]; - if (/^(yes|on|true|enabled)$/i.test(val)) { - val = true; - } else if (/^(no|off|false|disabled)$/i.test(val)) { - val = false; - } else if (val === 'null') { - val = null; - } else { - val = Number(val); - } - - obj[prop] = val; - return obj; -}, {}); - -/** - * Is stdout a TTY? Colored output is enabled when `true`. - */ - -function useColors() { - return 'colors' in exports.inspectOpts ? - Boolean(exports.inspectOpts.colors) : - tty.isatty(process.stderr.fd); -} - -/** - * Adds ANSI color escape codes if enabled. - * - * @api public - */ - -function formatArgs(args) { - const {namespace: name, useColors} = this; - - if (useColors) { - const c = this.color; - const colorCode = '\u001B[3' + (c < 8 ? c : '8;5;' + c); - const prefix = ` ${colorCode};1m${name} \u001B[0m`; - - args[0] = prefix + args[0].split('\n').join('\n' + prefix); - args.push(colorCode + 'm+' + module.exports.humanize(this.diff) + '\u001B[0m'); - } else { - args[0] = getDate() + name + ' ' + args[0]; - } -} - -function getDate() { - if (exports.inspectOpts.hideDate) { - return ''; - } - return new Date().toISOString() + ' '; -} - -/** - * Invokes `util.formatWithOptions()` with the specified arguments and writes to stderr. - */ - -function log(...args) { - return process.stderr.write(util.formatWithOptions(exports.inspectOpts, ...args) + '\n'); -} - -/** - * Save `namespaces`. - * - * @param {String} namespaces - * @api private - */ -function save(namespaces) { - if (namespaces) { - process.env.DEBUG = namespaces; - } else { - // If you set a process.env field to null or undefined, it gets cast to the - // string 'null' or 'undefined'. Just delete instead. - delete process.env.DEBUG; - } -} - -/** - * Load `namespaces`. - * - * @return {String} returns the previously persisted debug modes - * @api private - */ - -function load() { - return process.env.DEBUG; -} - -/** - * Init logic for `debug` instances. - * - * Create a new `inspectOpts` object in case `useColors` is set - * differently for a particular `debug` instance. - */ - -function init(debug) { - debug.inspectOpts = {}; - - const keys = Object.keys(exports.inspectOpts); - for (let i = 0; i < keys.length; i++) { - debug.inspectOpts[keys[i]] = exports.inspectOpts[keys[i]]; - } -} - -module.exports = require('./common')(exports); - -const {formatters} = module.exports; - -/** - * Map %o to `util.inspect()`, all on a single line. - */ - -formatters.o = function (v) { - this.inspectOpts.colors = this.useColors; - return util.inspect(v, this.inspectOpts) - .split('\n') - .map(str => str.trim()) - .join(' '); -}; - -/** - * Map %O to `util.inspect()`, allowing multiple lines if needed. - */ - -formatters.O = function (v) { - this.inspectOpts.colors = this.useColors; - return util.inspect(v, this.inspectOpts); -}; diff --git a/tools/eslint/node_modules/deep-is/LICENSE b/tools/eslint/node_modules/deep-is/LICENSE deleted file mode 100644 index c38f84073f61ef..00000000000000 --- a/tools/eslint/node_modules/deep-is/LICENSE +++ /dev/null @@ -1,22 +0,0 @@ -Copyright (c) 2012, 2013 Thorsten Lorenz -Copyright (c) 2012 James Halliday -Copyright (c) 2009 Thomas Robinson <280north.com> - -This software is released under the MIT license: - -Permission is hereby granted, free of charge, to any person obtaining a copy of -this software and associated documentation files (the "Software"), to deal in -the Software without restriction, including without limitation the rights to -use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of -the Software, and to permit persons to whom the Software is furnished to do so, -subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS -FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR -COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER -IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/tools/eslint/node_modules/deep-is/index.js b/tools/eslint/node_modules/deep-is/index.js deleted file mode 100644 index 506fe279531349..00000000000000 --- a/tools/eslint/node_modules/deep-is/index.js +++ /dev/null @@ -1,102 +0,0 @@ -var pSlice = Array.prototype.slice; -var Object_keys = typeof Object.keys === 'function' - ? Object.keys - : function (obj) { - var keys = []; - for (var key in obj) keys.push(key); - return keys; - } -; - -var deepEqual = module.exports = function (actual, expected) { - // enforce Object.is +0 !== -0 - if (actual === 0 && expected === 0) { - return areZerosEqual(actual, expected); - - // 7.1. All identical values are equivalent, as determined by ===. - } else if (actual === expected) { - return true; - - } else if (actual instanceof Date && expected instanceof Date) { - return actual.getTime() === expected.getTime(); - - } else if (isNumberNaN(actual)) { - return isNumberNaN(expected); - - // 7.3. Other pairs that do not both pass typeof value == 'object', - // equivalence is determined by ==. - } else if (typeof actual != 'object' && typeof expected != 'object') { - return actual == expected; - - // 7.4. For all other Object pairs, including Array objects, equivalence is - // determined by having the same number of owned properties (as verified - // with Object.prototype.hasOwnProperty.call), the same set of keys - // (although not necessarily the same order), equivalent values for every - // corresponding key, and an identical 'prototype' property. Note: this - // accounts for both named and indexed properties on Arrays. - } else { - return objEquiv(actual, expected); - } -}; - -function isUndefinedOrNull(value) { - return value === null || value === undefined; -} - -function isArguments(object) { - return Object.prototype.toString.call(object) == '[object Arguments]'; -} - -function isNumberNaN(value) { - // NaN === NaN -> false - return typeof value == 'number' && value !== value; -} - -function areZerosEqual(zeroA, zeroB) { - // (1 / +0|0) -> Infinity, but (1 / -0) -> -Infinity and (Infinity !== -Infinity) - return (1 / zeroA) === (1 / zeroB); -} - -function objEquiv(a, b) { - if (isUndefinedOrNull(a) || isUndefinedOrNull(b)) - return false; - - // an identical 'prototype' property. - if (a.prototype !== b.prototype) return false; - //~~~I've managed to break Object.keys through screwy arguments passing. - // Converting to array solves the problem. - if (isArguments(a)) { - if (!isArguments(b)) { - return false; - } - a = pSlice.call(a); - b = pSlice.call(b); - return deepEqual(a, b); - } - try { - var ka = Object_keys(a), - kb = Object_keys(b), - key, i; - } catch (e) {//happens when one is a string literal and the other isn't - return false; - } - // having the same number of owned properties (keys incorporates - // hasOwnProperty) - if (ka.length != kb.length) - return false; - //the same set of keys (although not necessarily the same order), - ka.sort(); - kb.sort(); - //~~~cheap key test - for (i = ka.length - 1; i >= 0; i--) { - if (ka[i] != kb[i]) - return false; - } - //equivalent values for every corresponding key, and - //~~~possibly expensive deep test - for (i = ka.length - 1; i >= 0; i--) { - key = ka[i]; - if (!deepEqual(a[key], b[key])) return false; - } - return true; -} diff --git a/tools/eslint/node_modules/deep-is/package.json b/tools/eslint/node_modules/deep-is/package.json deleted file mode 100644 index dae72d7873ed0b..00000000000000 --- a/tools/eslint/node_modules/deep-is/package.json +++ /dev/null @@ -1,58 +0,0 @@ -{ - "name": "deep-is", - "version": "0.1.4", - "description": "node's assert.deepEqual algorithm except for NaN being equal to NaN", - "main": "index.js", - "directories": { - "lib": ".", - "example": "example", - "test": "test" - }, - "scripts": { - "test": "tape test/*.js" - }, - "devDependencies": { - "tape": "~1.0.2" - }, - "repository": { - "type": "git", - "url": "http://github.com/thlorenz/deep-is.git" - }, - "keywords": [ - "equality", - "equal", - "compare" - ], - "author": { - "name": "Thorsten Lorenz", - "email": "thlorenz@gmx.de", - "url": "http://thlorenz.com" - }, - "license": "MIT", - "testling": { - "files": "test/*.js", - "browsers": { - "ie": [ - 6, - 7, - 8, - 9 - ], - "ff": [ - 3.5, - 10, - 15 - ], - "chrome": [ - 10, - 22 - ], - "safari": [ - 5.1 - ], - "opera": [ - 12 - ] - } - } -} diff --git a/tools/eslint/node_modules/electron-to-chromium/LICENSE b/tools/eslint/node_modules/electron-to-chromium/LICENSE deleted file mode 100644 index 6c7b614d4e9f51..00000000000000 --- a/tools/eslint/node_modules/electron-to-chromium/LICENSE +++ /dev/null @@ -1,5 +0,0 @@ -Copyright 2018 Kilian Valkhof - -Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies. - -THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. diff --git a/tools/eslint/node_modules/electron-to-chromium/chromium-versions.js b/tools/eslint/node_modules/electron-to-chromium/chromium-versions.js deleted file mode 100644 index 5be7379c8a0491..00000000000000 --- a/tools/eslint/node_modules/electron-to-chromium/chromium-versions.js +++ /dev/null @@ -1,67 +0,0 @@ -module.exports = { - "39": "0.20", - "40": "0.21", - "41": "0.21", - "42": "0.25", - "43": "0.27", - "44": "0.30", - "45": "0.31", - "47": "0.36", - "49": "0.37", - "50": "1.1", - "51": "1.2", - "52": "1.3", - "53": "1.4", - "54": "1.4", - "56": "1.6", - "58": "1.7", - "59": "1.8", - "61": "2.0", - "66": "3.0", - "69": "4.0", - "72": "5.0", - "73": "5.0", - "76": "6.0", - "78": "7.0", - "79": "8.0", - "80": "8.0", - "82": "9.0", - "83": "9.0", - "84": "10.0", - "85": "10.0", - "86": "11.0", - "87": "11.0", - "89": "12.0", - "90": "13.0", - "91": "13.0", - "92": "14.0", - "93": "14.0", - "94": "15.0", - "95": "16.0", - "96": "16.0", - "98": "17.0", - "99": "18.0", - "100": "18.0", - "102": "19.0", - "103": "20.0", - "104": "20.0", - "105": "21.0", - "106": "21.0", - "107": "22.0", - "108": "22.0", - "110": "23.0", - "111": "24.0", - "112": "24.0", - "114": "25.0", - "116": "26.0", - "118": "27.0", - "119": "28.0", - "120": "28.0", - "121": "29.0", - "122": "29.0", - "123": "30.0", - "124": "30.0", - "125": "31.0", - "126": "31.0", - "127": "32.0" -}; \ No newline at end of file diff --git a/tools/eslint/node_modules/electron-to-chromium/chromium-versions.json b/tools/eslint/node_modules/electron-to-chromium/chromium-versions.json deleted file mode 100644 index 1519dbc6a550e6..00000000000000 --- a/tools/eslint/node_modules/electron-to-chromium/chromium-versions.json +++ /dev/null @@ -1 +0,0 @@ -{"39":"0.20","40":"0.21","41":"0.21","42":"0.25","43":"0.27","44":"0.30","45":"0.31","47":"0.36","49":"0.37","50":"1.1","51":"1.2","52":"1.3","53":"1.4","54":"1.4","56":"1.6","58":"1.7","59":"1.8","61":"2.0","66":"3.0","69":"4.0","72":"5.0","73":"5.0","76":"6.0","78":"7.0","79":"8.0","80":"8.0","82":"9.0","83":"9.0","84":"10.0","85":"10.0","86":"11.0","87":"11.0","89":"12.0","90":"13.0","91":"13.0","92":"14.0","93":"14.0","94":"15.0","95":"16.0","96":"16.0","98":"17.0","99":"18.0","100":"18.0","102":"19.0","103":"20.0","104":"20.0","105":"21.0","106":"21.0","107":"22.0","108":"22.0","110":"23.0","111":"24.0","112":"24.0","114":"25.0","116":"26.0","118":"27.0","119":"28.0","120":"28.0","121":"29.0","122":"29.0","123":"30.0","124":"30.0","125":"31.0","126":"31.0","127":"32.0"} \ No newline at end of file diff --git a/tools/eslint/node_modules/electron-to-chromium/full-chromium-versions.js b/tools/eslint/node_modules/electron-to-chromium/full-chromium-versions.js deleted file mode 100644 index 83a198dc839064..00000000000000 --- a/tools/eslint/node_modules/electron-to-chromium/full-chromium-versions.js +++ /dev/null @@ -1,3327 +0,0 @@ -module.exports = { - "39.0.2171.65": [ - "0.20.0", - "0.20.1", - "0.20.2", - "0.20.3", - "0.20.4", - "0.20.5", - "0.20.6", - "0.20.7", - "0.20.8" - ], - "40.0.2214.91": [ - "0.21.0", - "0.21.1", - "0.21.2" - ], - "41.0.2272.76": [ - "0.21.3", - "0.22.1", - "0.22.2", - "0.22.3", - "0.23.0", - "0.24.0" - ], - "42.0.2311.107": [ - "0.25.0", - "0.25.1", - "0.25.2", - "0.25.3", - "0.26.0", - "0.26.1", - "0.27.0", - "0.27.1" - ], - "43.0.2357.65": [ - "0.27.2", - "0.27.3", - "0.28.0", - "0.28.1", - "0.28.2", - "0.28.3", - "0.29.1", - "0.29.2" - ], - "44.0.2403.125": [ - "0.30.4", - "0.31.0" - ], - "45.0.2454.85": [ - "0.31.2", - "0.32.2", - "0.32.3", - "0.33.0", - "0.33.1", - "0.33.2", - "0.33.3", - "0.33.4", - "0.33.6", - "0.33.7", - "0.33.8", - "0.33.9", - "0.34.0", - "0.34.1", - "0.34.2", - "0.34.3", - "0.34.4", - "0.35.1", - "0.35.2", - "0.35.3", - "0.35.4", - "0.35.5" - ], - "47.0.2526.73": [ - "0.36.0", - "0.36.2", - "0.36.3", - "0.36.4" - ], - "47.0.2526.110": [ - "0.36.5", - "0.36.6", - "0.36.7", - "0.36.8", - "0.36.9", - "0.36.10", - "0.36.11", - "0.36.12" - ], - "49.0.2623.75": [ - "0.37.0", - "0.37.1", - "0.37.3", - "0.37.4", - "0.37.5", - "0.37.6", - "0.37.7", - "0.37.8", - "1.0.0", - "1.0.1", - "1.0.2" - ], - "50.0.2661.102": [ - "1.1.0", - "1.1.1", - "1.1.2", - "1.1.3" - ], - "51.0.2704.63": [ - "1.2.0", - "1.2.1" - ], - "51.0.2704.84": [ - "1.2.2", - "1.2.3" - ], - "51.0.2704.103": [ - "1.2.4", - "1.2.5" - ], - "51.0.2704.106": [ - "1.2.6", - "1.2.7", - "1.2.8" - ], - "52.0.2743.82": [ - "1.3.0", - "1.3.1", - "1.3.2", - "1.3.3", - "1.3.4", - "1.3.5", - "1.3.6", - "1.3.7", - "1.3.9", - "1.3.10", - "1.3.13", - "1.3.14", - "1.3.15" - ], - "53.0.2785.113": [ - "1.4.0", - "1.4.1", - "1.4.2", - "1.4.3", - "1.4.4", - "1.4.5" - ], - "53.0.2785.143": [ - "1.4.6", - "1.4.7", - "1.4.8", - "1.4.10", - "1.4.11", - "1.4.13", - "1.4.14", - "1.4.15", - "1.4.16" - ], - "54.0.2840.51": [ - "1.4.12" - ], - "54.0.2840.101": [ - "1.5.0", - "1.5.1" - ], - "56.0.2924.87": [ - "1.6.0", - "1.6.1", - "1.6.2", - "1.6.3", - "1.6.4", - "1.6.5", - "1.6.6", - "1.6.7", - "1.6.8", - "1.6.9", - "1.6.10", - "1.6.11", - "1.6.12", - "1.6.13", - "1.6.14", - "1.6.15", - "1.6.16", - "1.6.17", - "1.6.18" - ], - "58.0.3029.110": [ - "1.7.0", - "1.7.1", - "1.7.2", - "1.7.3", - "1.7.4", - "1.7.5", - "1.7.6", - "1.7.7", - "1.7.8", - "1.7.9", - "1.7.10", - "1.7.11", - "1.7.12", - "1.7.13", - "1.7.14", - "1.7.15", - "1.7.16" - ], - "59.0.3071.115": [ - "1.8.0", - "1.8.1", - "1.8.2-beta.1", - "1.8.2-beta.2", - "1.8.2-beta.3", - "1.8.2-beta.4", - "1.8.2-beta.5", - "1.8.2", - "1.8.3", - "1.8.4", - "1.8.5", - "1.8.6", - "1.8.7", - "1.8.8" - ], - "61.0.3163.100": [ - "2.0.0-beta.1", - "2.0.0-beta.2", - "2.0.0-beta.3", - "2.0.0-beta.4", - "2.0.0-beta.5", - "2.0.0-beta.6", - "2.0.0-beta.7", - "2.0.0-beta.8", - "2.0.0", - "2.0.1", - "2.0.2", - "2.0.3", - "2.0.4", - "2.0.5", - "2.0.6", - "2.0.7", - "2.0.8-nightly.20180819", - "2.0.8-nightly.20180820", - "2.0.8", - "2.0.9", - "2.0.10", - "2.0.11", - "2.0.12", - "2.0.13", - "2.0.14", - "2.0.15", - "2.0.16", - "2.0.17", - "2.0.18", - "2.1.0-unsupported.20180809" - ], - "66.0.3359.181": [ - "3.0.0-beta.1", - "3.0.0-beta.2", - "3.0.0-beta.3", - "3.0.0-beta.4", - "3.0.0-beta.5", - "3.0.0-beta.6", - "3.0.0-beta.7", - "3.0.0-beta.8", - "3.0.0-beta.9", - "3.0.0-beta.10", - "3.0.0-beta.11", - "3.0.0-beta.12", - "3.0.0-beta.13", - "3.0.0-nightly.20180818", - "3.0.0-nightly.20180821", - "3.0.0-nightly.20180823", - "3.0.0-nightly.20180904", - "3.0.0", - "3.0.1", - "3.0.2", - "3.0.3", - "3.0.4", - "3.0.5", - "3.0.6", - "3.0.7", - "3.0.8", - "3.0.9", - "3.0.10", - "3.0.11", - "3.0.12", - "3.0.13", - "3.0.14", - "3.0.15", - "3.0.16", - "3.1.0-beta.1", - "3.1.0-beta.2", - "3.1.0-beta.3", - "3.1.0-beta.4", - "3.1.0-beta.5", - "3.1.0", - "3.1.1", - "3.1.2", - "3.1.3", - "3.1.4", - "3.1.5", - "3.1.6", - "3.1.7", - "3.1.8", - "3.1.9", - "3.1.10", - "3.1.11", - "3.1.12", - "3.1.13", - "4.0.0-nightly.20180817", - "4.0.0-nightly.20180819", - "4.0.0-nightly.20180821" - ], - "69.0.3497.106": [ - "4.0.0-beta.1", - "4.0.0-beta.2", - "4.0.0-beta.3", - "4.0.0-beta.4", - "4.0.0-beta.5", - "4.0.0-beta.6", - "4.0.0-beta.7", - "4.0.0-beta.8", - "4.0.0-beta.9", - "4.0.0-beta.10", - "4.0.0-beta.11", - "4.0.0-nightly.20181010", - "4.0.0", - "4.0.1", - "4.0.2", - "4.0.3", - "4.0.4", - "4.0.5", - "4.0.6" - ], - "67.0.3396.99": [ - "4.0.0-nightly.20180929" - ], - "68.0.3440.128": [ - "4.0.0-nightly.20181006" - ], - "69.0.3497.128": [ - "4.0.7", - "4.0.8", - "4.1.0", - "4.1.1", - "4.1.2", - "4.1.3", - "4.1.4", - "4.1.5", - "4.2.0", - "4.2.1", - "4.2.2", - "4.2.3", - "4.2.4", - "4.2.5", - "4.2.6", - "4.2.7", - "4.2.8", - "4.2.9", - "4.2.10", - "4.2.11", - "4.2.12" - ], - "72.0.3626.52": [ - "5.0.0-beta.1", - "5.0.0-beta.2", - "6.0.0-nightly.20190123" - ], - "73.0.3683.27": [ - "5.0.0-beta.3" - ], - "73.0.3683.54": [ - "5.0.0-beta.4" - ], - "73.0.3683.61": [ - "5.0.0-beta.5" - ], - "73.0.3683.84": [ - "5.0.0-beta.6" - ], - "73.0.3683.94": [ - "5.0.0-beta.7" - ], - "73.0.3683.104": [ - "5.0.0-beta.8" - ], - "73.0.3683.117": [ - "5.0.0-beta.9" - ], - "70.0.3538.110": [ - "5.0.0-nightly.20190107" - ], - "71.0.3578.98": [ - "5.0.0-nightly.20190121", - "5.0.0-nightly.20190122" - ], - "73.0.3683.119": [ - "5.0.0" - ], - "73.0.3683.121": [ - "5.0.1", - "5.0.2", - "5.0.3", - "5.0.4", - "5.0.5", - "5.0.6", - "5.0.7", - "5.0.8", - "5.0.9", - "5.0.10", - "5.0.11", - "5.0.12", - "5.0.13" - ], - "76.0.3774.1": [ - "6.0.0-beta.1" - ], - "76.0.3783.1": [ - "6.0.0-beta.2", - "6.0.0-beta.3", - "6.0.0-beta.4" - ], - "76.0.3805.4": [ - "6.0.0-beta.5" - ], - "76.0.3809.3": [ - "6.0.0-beta.6" - ], - "76.0.3809.22": [ - "6.0.0-beta.7" - ], - "76.0.3809.26": [ - "6.0.0-beta.8", - "6.0.0-beta.9" - ], - "76.0.3809.37": [ - "6.0.0-beta.10" - ], - "76.0.3809.42": [ - "6.0.0-beta.11" - ], - "76.0.3809.54": [ - "6.0.0-beta.12" - ], - "76.0.3809.60": [ - "6.0.0-beta.13" - ], - "76.0.3809.68": [ - "6.0.0-beta.14" - ], - "76.0.3809.74": [ - "6.0.0-beta.15" - ], - "72.0.3626.107": [ - "6.0.0-nightly.20190212" - ], - "72.0.3626.110": [ - "6.0.0-nightly.20190213" - ], - "74.0.3724.8": [ - "6.0.0-nightly.20190311" - ], - "76.0.3809.88": [ - "6.0.0" - ], - "76.0.3809.102": [ - "6.0.1" - ], - "76.0.3809.110": [ - "6.0.2" - ], - "76.0.3809.126": [ - "6.0.3" - ], - "76.0.3809.131": [ - "6.0.4" - ], - "76.0.3809.136": [ - "6.0.5" - ], - "76.0.3809.138": [ - "6.0.6" - ], - "76.0.3809.139": [ - "6.0.7" - ], - "76.0.3809.146": [ - "6.0.8", - "6.0.9", - "6.0.10", - "6.0.11", - "6.0.12", - "6.1.0", - "6.1.1", - "6.1.2", - "6.1.3", - "6.1.4", - "6.1.5", - "6.1.6", - "6.1.7", - "6.1.8", - "6.1.9", - "6.1.10", - "6.1.11", - "6.1.12" - ], - "78.0.3866.0": [ - "7.0.0-beta.1", - "7.0.0-beta.2", - "7.0.0-beta.3", - "7.0.0-nightly.20190727", - "7.0.0-nightly.20190728", - "7.0.0-nightly.20190729", - "7.0.0-nightly.20190730", - "7.0.0-nightly.20190731", - "8.0.0-nightly.20190801", - "8.0.0-nightly.20190802" - ], - "78.0.3896.6": [ - "7.0.0-beta.4" - ], - "78.0.3905.1": [ - "7.0.0-beta.5", - "7.0.0-beta.6", - "7.0.0-beta.7", - "7.0.0" - ], - "76.0.3784.0": [ - "7.0.0-nightly.20190521" - ], - "76.0.3806.0": [ - "7.0.0-nightly.20190529", - "7.0.0-nightly.20190530", - "7.0.0-nightly.20190531", - "7.0.0-nightly.20190602", - "7.0.0-nightly.20190603" - ], - "77.0.3814.0": [ - "7.0.0-nightly.20190604" - ], - "77.0.3815.0": [ - "7.0.0-nightly.20190605", - "7.0.0-nightly.20190606", - "7.0.0-nightly.20190607", - "7.0.0-nightly.20190608", - "7.0.0-nightly.20190609", - "7.0.0-nightly.20190611", - "7.0.0-nightly.20190612", - "7.0.0-nightly.20190613", - "7.0.0-nightly.20190615", - "7.0.0-nightly.20190616", - "7.0.0-nightly.20190618", - "7.0.0-nightly.20190619", - "7.0.0-nightly.20190622", - "7.0.0-nightly.20190623", - "7.0.0-nightly.20190624", - "7.0.0-nightly.20190627", - "7.0.0-nightly.20190629", - "7.0.0-nightly.20190630", - "7.0.0-nightly.20190701", - "7.0.0-nightly.20190702" - ], - "77.0.3843.0": [ - "7.0.0-nightly.20190704", - "7.0.0-nightly.20190705" - ], - "77.0.3848.0": [ - "7.0.0-nightly.20190719", - "7.0.0-nightly.20190720", - "7.0.0-nightly.20190721" - ], - "77.0.3864.0": [ - "7.0.0-nightly.20190726" - ], - "78.0.3904.92": [ - "7.0.1" - ], - "78.0.3904.94": [ - "7.1.0" - ], - "78.0.3904.99": [ - "7.1.1" - ], - "78.0.3904.113": [ - "7.1.2" - ], - "78.0.3904.126": [ - "7.1.3" - ], - "78.0.3904.130": [ - "7.1.4", - "7.1.5", - "7.1.6", - "7.1.7", - "7.1.8", - "7.1.9", - "7.1.10", - "7.1.11", - "7.1.12", - "7.1.13", - "7.1.14", - "7.2.0", - "7.2.1", - "7.2.2", - "7.2.3", - "7.2.4", - "7.3.0", - "7.3.1", - "7.3.2", - "7.3.3" - ], - "79.0.3931.0": [ - "8.0.0-beta.1", - "8.0.0-beta.2", - "8.0.0-nightly.20191019", - "8.0.0-nightly.20191020", - "8.0.0-nightly.20191021", - "8.0.0-nightly.20191023" - ], - "80.0.3955.0": [ - "8.0.0-beta.3", - "8.0.0-beta.4" - ], - "80.0.3987.14": [ - "8.0.0-beta.5" - ], - "80.0.3987.51": [ - "8.0.0-beta.6" - ], - "80.0.3987.59": [ - "8.0.0-beta.7" - ], - "80.0.3987.75": [ - "8.0.0-beta.8", - "8.0.0-beta.9" - ], - "78.0.3871.0": [ - "8.0.0-nightly.20190803", - "8.0.0-nightly.20190806", - "8.0.0-nightly.20190807", - "8.0.0-nightly.20190808", - "8.0.0-nightly.20190809", - "8.0.0-nightly.20190810", - "8.0.0-nightly.20190811", - "8.0.0-nightly.20190812", - "8.0.0-nightly.20190813", - "8.0.0-nightly.20190814", - "8.0.0-nightly.20190815" - ], - "78.0.3881.0": [ - "8.0.0-nightly.20190816", - "8.0.0-nightly.20190817", - "8.0.0-nightly.20190818", - "8.0.0-nightly.20190819", - "8.0.0-nightly.20190820" - ], - "78.0.3892.0": [ - "8.0.0-nightly.20190824", - "8.0.0-nightly.20190825", - "8.0.0-nightly.20190827", - "8.0.0-nightly.20190828", - "8.0.0-nightly.20190830", - "8.0.0-nightly.20190901", - "8.0.0-nightly.20190902", - "8.0.0-nightly.20190907", - "8.0.0-nightly.20190909", - "8.0.0-nightly.20190910", - "8.0.0-nightly.20190911", - "8.0.0-nightly.20190912", - "8.0.0-nightly.20190913", - "8.0.0-nightly.20190914", - "8.0.0-nightly.20190915", - "8.0.0-nightly.20190917" - ], - "79.0.3915.0": [ - "8.0.0-nightly.20190919", - "8.0.0-nightly.20190920" - ], - "79.0.3919.0": [ - "8.0.0-nightly.20190922", - "8.0.0-nightly.20190923", - "8.0.0-nightly.20190924", - "8.0.0-nightly.20190926", - "8.0.0-nightly.20190928", - "8.0.0-nightly.20190929", - "8.0.0-nightly.20190930", - "8.0.0-nightly.20191001", - "8.0.0-nightly.20191004", - "8.0.0-nightly.20191005", - "8.0.0-nightly.20191006", - "8.0.0-nightly.20191009", - "8.0.0-nightly.20191011", - "8.0.0-nightly.20191012", - "8.0.0-nightly.20191017" - ], - "80.0.3952.0": [ - "8.0.0-nightly.20191101", - "8.0.0-nightly.20191103", - "8.0.0-nightly.20191105" - ], - "80.0.3987.86": [ - "8.0.0", - "8.0.1", - "8.0.2" - ], - "80.0.3987.134": [ - "8.0.3" - ], - "80.0.3987.137": [ - "8.1.0" - ], - "80.0.3987.141": [ - "8.1.1" - ], - "80.0.3987.158": [ - "8.2.0" - ], - "80.0.3987.163": [ - "8.2.1", - "8.2.2", - "8.2.3", - "8.5.3", - "8.5.4", - "8.5.5" - ], - "80.0.3987.165": [ - "8.2.4", - "8.2.5", - "8.3.0", - "8.3.1", - "8.3.2", - "8.3.3", - "8.3.4", - "8.4.0", - "8.4.1", - "8.5.0", - "8.5.1", - "8.5.2" - ], - "82.0.4048.0": [ - "9.0.0-beta.1", - "9.0.0-beta.2", - "9.0.0-beta.3", - "9.0.0-beta.4", - "9.0.0-beta.5" - ], - "82.0.4058.2": [ - "9.0.0-beta.6", - "9.0.0-beta.7", - "9.0.0-beta.9" - ], - "82.0.4085.10": [ - "9.0.0-beta.10" - ], - "82.0.4085.14": [ - "9.0.0-beta.11", - "9.0.0-beta.12", - "9.0.0-beta.13" - ], - "82.0.4085.27": [ - "9.0.0-beta.14" - ], - "83.0.4102.3": [ - "9.0.0-beta.15", - "9.0.0-beta.16" - ], - "83.0.4103.14": [ - "9.0.0-beta.17" - ], - "83.0.4103.16": [ - "9.0.0-beta.18" - ], - "83.0.4103.24": [ - "9.0.0-beta.19" - ], - "83.0.4103.26": [ - "9.0.0-beta.20", - "9.0.0-beta.21" - ], - "83.0.4103.34": [ - "9.0.0-beta.22" - ], - "83.0.4103.44": [ - "9.0.0-beta.23" - ], - "83.0.4103.45": [ - "9.0.0-beta.24" - ], - "80.0.3954.0": [ - "9.0.0-nightly.20191121", - "9.0.0-nightly.20191122", - "9.0.0-nightly.20191123", - "9.0.0-nightly.20191124", - "9.0.0-nightly.20191126", - "9.0.0-nightly.20191128", - "9.0.0-nightly.20191129", - "9.0.0-nightly.20191130", - "9.0.0-nightly.20191201", - "9.0.0-nightly.20191202", - "9.0.0-nightly.20191203", - "9.0.0-nightly.20191204", - "9.0.0-nightly.20191205", - "9.0.0-nightly.20191210" - ], - "81.0.3994.0": [ - "9.0.0-nightly.20191220", - "9.0.0-nightly.20191221", - "9.0.0-nightly.20191222", - "9.0.0-nightly.20191223", - "9.0.0-nightly.20191224", - "9.0.0-nightly.20191225", - "9.0.0-nightly.20191226", - "9.0.0-nightly.20191228", - "9.0.0-nightly.20191229", - "9.0.0-nightly.20191230", - "9.0.0-nightly.20191231", - "9.0.0-nightly.20200101", - "9.0.0-nightly.20200103", - "9.0.0-nightly.20200104", - "9.0.0-nightly.20200105", - "9.0.0-nightly.20200106", - "9.0.0-nightly.20200108", - "9.0.0-nightly.20200109", - "9.0.0-nightly.20200110", - "9.0.0-nightly.20200111", - "9.0.0-nightly.20200113", - "9.0.0-nightly.20200115", - "9.0.0-nightly.20200116", - "9.0.0-nightly.20200117" - ], - "81.0.4030.0": [ - "9.0.0-nightly.20200119", - "9.0.0-nightly.20200121" - ], - "83.0.4103.64": [ - "9.0.0" - ], - "83.0.4103.94": [ - "9.0.1", - "9.0.2" - ], - "83.0.4103.100": [ - "9.0.3" - ], - "83.0.4103.104": [ - "9.0.4" - ], - "83.0.4103.119": [ - "9.0.5" - ], - "83.0.4103.122": [ - "9.1.0", - "9.1.1", - "9.1.2", - "9.2.0", - "9.2.1", - "9.3.0", - "9.3.1", - "9.3.2", - "9.3.3", - "9.3.4", - "9.3.5", - "9.4.0", - "9.4.1", - "9.4.2", - "9.4.3", - "9.4.4" - ], - "84.0.4129.0": [ - "10.0.0-beta.1", - "10.0.0-beta.2", - "10.0.0-nightly.20200501", - "10.0.0-nightly.20200504", - "10.0.0-nightly.20200505", - "10.0.0-nightly.20200506", - "10.0.0-nightly.20200507", - "10.0.0-nightly.20200508", - "10.0.0-nightly.20200511", - "10.0.0-nightly.20200512", - "10.0.0-nightly.20200513", - "10.0.0-nightly.20200514", - "10.0.0-nightly.20200515", - "10.0.0-nightly.20200518", - "10.0.0-nightly.20200519", - "10.0.0-nightly.20200520", - "10.0.0-nightly.20200521", - "11.0.0-nightly.20200525", - "11.0.0-nightly.20200526" - ], - "85.0.4161.2": [ - "10.0.0-beta.3", - "10.0.0-beta.4" - ], - "85.0.4181.1": [ - "10.0.0-beta.8", - "10.0.0-beta.9" - ], - "85.0.4183.19": [ - "10.0.0-beta.10" - ], - "85.0.4183.20": [ - "10.0.0-beta.11" - ], - "85.0.4183.26": [ - "10.0.0-beta.12" - ], - "85.0.4183.39": [ - "10.0.0-beta.13", - "10.0.0-beta.14", - "10.0.0-beta.15", - "10.0.0-beta.17", - "10.0.0-beta.19", - "10.0.0-beta.20", - "10.0.0-beta.21" - ], - "85.0.4183.70": [ - "10.0.0-beta.23" - ], - "85.0.4183.78": [ - "10.0.0-beta.24" - ], - "85.0.4183.80": [ - "10.0.0-beta.25" - ], - "82.0.4050.0": [ - "10.0.0-nightly.20200209", - "10.0.0-nightly.20200210", - "10.0.0-nightly.20200211", - "10.0.0-nightly.20200216", - "10.0.0-nightly.20200217", - "10.0.0-nightly.20200218", - "10.0.0-nightly.20200221", - "10.0.0-nightly.20200222", - "10.0.0-nightly.20200223", - "10.0.0-nightly.20200226", - "10.0.0-nightly.20200303" - ], - "82.0.4076.0": [ - "10.0.0-nightly.20200304", - "10.0.0-nightly.20200305", - "10.0.0-nightly.20200306", - "10.0.0-nightly.20200309", - "10.0.0-nightly.20200310" - ], - "82.0.4083.0": [ - "10.0.0-nightly.20200311" - ], - "83.0.4086.0": [ - "10.0.0-nightly.20200316" - ], - "83.0.4087.0": [ - "10.0.0-nightly.20200317", - "10.0.0-nightly.20200318", - "10.0.0-nightly.20200320", - "10.0.0-nightly.20200323", - "10.0.0-nightly.20200324", - "10.0.0-nightly.20200325", - "10.0.0-nightly.20200326", - "10.0.0-nightly.20200327", - "10.0.0-nightly.20200330", - "10.0.0-nightly.20200331", - "10.0.0-nightly.20200401", - "10.0.0-nightly.20200402", - "10.0.0-nightly.20200403", - "10.0.0-nightly.20200406" - ], - "83.0.4095.0": [ - "10.0.0-nightly.20200408", - "10.0.0-nightly.20200410", - "10.0.0-nightly.20200413" - ], - "84.0.4114.0": [ - "10.0.0-nightly.20200414" - ], - "84.0.4115.0": [ - "10.0.0-nightly.20200415", - "10.0.0-nightly.20200416", - "10.0.0-nightly.20200417" - ], - "84.0.4121.0": [ - "10.0.0-nightly.20200422", - "10.0.0-nightly.20200423" - ], - "84.0.4125.0": [ - "10.0.0-nightly.20200427", - "10.0.0-nightly.20200428", - "10.0.0-nightly.20200429", - "10.0.0-nightly.20200430" - ], - "85.0.4183.84": [ - "10.0.0" - ], - "85.0.4183.86": [ - "10.0.1" - ], - "85.0.4183.87": [ - "10.1.0" - ], - "85.0.4183.93": [ - "10.1.1" - ], - "85.0.4183.98": [ - "10.1.2" - ], - "85.0.4183.121": [ - "10.1.3", - "10.1.4", - "10.1.5", - "10.1.6", - "10.1.7", - "10.2.0", - "10.3.0", - "10.3.1", - "10.3.2", - "10.4.0", - "10.4.1", - "10.4.2", - "10.4.3", - "10.4.4", - "10.4.5", - "10.4.6", - "10.4.7" - ], - "86.0.4234.0": [ - "11.0.0-beta.1", - "11.0.0-beta.3", - "11.0.0-beta.4", - "11.0.0-beta.5", - "11.0.0-beta.6", - "11.0.0-beta.7", - "11.0.0-nightly.20200822", - "11.0.0-nightly.20200824", - "11.0.0-nightly.20200825", - "11.0.0-nightly.20200826", - "12.0.0-nightly.20200827", - "12.0.0-nightly.20200831", - "12.0.0-nightly.20200902", - "12.0.0-nightly.20200903", - "12.0.0-nightly.20200907", - "12.0.0-nightly.20200910", - "12.0.0-nightly.20200911", - "12.0.0-nightly.20200914" - ], - "87.0.4251.1": [ - "11.0.0-beta.8", - "11.0.0-beta.9", - "11.0.0-beta.11" - ], - "87.0.4280.11": [ - "11.0.0-beta.12", - "11.0.0-beta.13" - ], - "87.0.4280.27": [ - "11.0.0-beta.16", - "11.0.0-beta.17", - "11.0.0-beta.18", - "11.0.0-beta.19" - ], - "87.0.4280.40": [ - "11.0.0-beta.20" - ], - "87.0.4280.47": [ - "11.0.0-beta.22", - "11.0.0-beta.23" - ], - "85.0.4156.0": [ - "11.0.0-nightly.20200529" - ], - "85.0.4162.0": [ - "11.0.0-nightly.20200602", - "11.0.0-nightly.20200603", - "11.0.0-nightly.20200604", - "11.0.0-nightly.20200609", - "11.0.0-nightly.20200610", - "11.0.0-nightly.20200611", - "11.0.0-nightly.20200615", - "11.0.0-nightly.20200616", - "11.0.0-nightly.20200617", - "11.0.0-nightly.20200618", - "11.0.0-nightly.20200619" - ], - "85.0.4179.0": [ - "11.0.0-nightly.20200701", - "11.0.0-nightly.20200702", - "11.0.0-nightly.20200703", - "11.0.0-nightly.20200706", - "11.0.0-nightly.20200707", - "11.0.0-nightly.20200708", - "11.0.0-nightly.20200709" - ], - "86.0.4203.0": [ - "11.0.0-nightly.20200716", - "11.0.0-nightly.20200717", - "11.0.0-nightly.20200720", - "11.0.0-nightly.20200721" - ], - "86.0.4209.0": [ - "11.0.0-nightly.20200723", - "11.0.0-nightly.20200724", - "11.0.0-nightly.20200729", - "11.0.0-nightly.20200730", - "11.0.0-nightly.20200731", - "11.0.0-nightly.20200803", - "11.0.0-nightly.20200804", - "11.0.0-nightly.20200805", - "11.0.0-nightly.20200811", - "11.0.0-nightly.20200812" - ], - "87.0.4280.60": [ - "11.0.0", - "11.0.1" - ], - "87.0.4280.67": [ - "11.0.2", - "11.0.3", - "11.0.4" - ], - "87.0.4280.88": [ - "11.0.5", - "11.1.0", - "11.1.1" - ], - "87.0.4280.141": [ - "11.2.0", - "11.2.1", - "11.2.2", - "11.2.3", - "11.3.0", - "11.4.0", - "11.4.1", - "11.4.2", - "11.4.3", - "11.4.4", - "11.4.5", - "11.4.6", - "11.4.7", - "11.4.8", - "11.4.9", - "11.4.10", - "11.4.11", - "11.4.12", - "11.5.0" - ], - "89.0.4328.0": [ - "12.0.0-beta.1", - "12.0.0-beta.3", - "12.0.0-beta.4", - "12.0.0-beta.5", - "12.0.0-beta.6", - "12.0.0-beta.7", - "12.0.0-beta.8", - "12.0.0-beta.9", - "12.0.0-beta.10", - "12.0.0-beta.11", - "12.0.0-beta.12", - "12.0.0-beta.14", - "13.0.0-nightly.20201119", - "13.0.0-nightly.20201123", - "13.0.0-nightly.20201124", - "13.0.0-nightly.20201126", - "13.0.0-nightly.20201127", - "13.0.0-nightly.20201130", - "13.0.0-nightly.20201201", - "13.0.0-nightly.20201202", - "13.0.0-nightly.20201203", - "13.0.0-nightly.20201204", - "13.0.0-nightly.20201207", - "13.0.0-nightly.20201208", - "13.0.0-nightly.20201209", - "13.0.0-nightly.20201210", - "13.0.0-nightly.20201211", - "13.0.0-nightly.20201214" - ], - "89.0.4348.1": [ - "12.0.0-beta.16", - "12.0.0-beta.18", - "12.0.0-beta.19", - "12.0.0-beta.20" - ], - "89.0.4388.2": [ - "12.0.0-beta.21", - "12.0.0-beta.22", - "12.0.0-beta.23", - "12.0.0-beta.24", - "12.0.0-beta.25", - "12.0.0-beta.26" - ], - "89.0.4389.23": [ - "12.0.0-beta.27", - "12.0.0-beta.28", - "12.0.0-beta.29" - ], - "89.0.4389.58": [ - "12.0.0-beta.30", - "12.0.0-beta.31" - ], - "87.0.4268.0": [ - "12.0.0-nightly.20201002", - "12.0.0-nightly.20201007", - "12.0.0-nightly.20201009", - "12.0.0-nightly.20201012", - "12.0.0-nightly.20201013", - "12.0.0-nightly.20201014", - "12.0.0-nightly.20201015" - ], - "88.0.4292.0": [ - "12.0.0-nightly.20201023", - "12.0.0-nightly.20201026" - ], - "88.0.4306.0": [ - "12.0.0-nightly.20201030", - "12.0.0-nightly.20201102", - "12.0.0-nightly.20201103", - "12.0.0-nightly.20201104", - "12.0.0-nightly.20201105", - "12.0.0-nightly.20201106", - "12.0.0-nightly.20201111", - "12.0.0-nightly.20201112" - ], - "88.0.4324.0": [ - "12.0.0-nightly.20201116" - ], - "89.0.4389.69": [ - "12.0.0" - ], - "89.0.4389.82": [ - "12.0.1" - ], - "89.0.4389.90": [ - "12.0.2" - ], - "89.0.4389.114": [ - "12.0.3", - "12.0.4" - ], - "89.0.4389.128": [ - "12.0.5", - "12.0.6", - "12.0.7", - "12.0.8", - "12.0.9", - "12.0.10", - "12.0.11", - "12.0.12", - "12.0.13", - "12.0.14", - "12.0.15", - "12.0.16", - "12.0.17", - "12.0.18", - "12.1.0", - "12.1.1", - "12.1.2", - "12.2.0", - "12.2.1", - "12.2.2", - "12.2.3" - ], - "90.0.4402.0": [ - "13.0.0-beta.2", - "13.0.0-beta.3", - "13.0.0-nightly.20210210", - "13.0.0-nightly.20210211", - "13.0.0-nightly.20210212", - "13.0.0-nightly.20210216", - "13.0.0-nightly.20210217", - "13.0.0-nightly.20210218", - "13.0.0-nightly.20210219", - "13.0.0-nightly.20210222", - "13.0.0-nightly.20210225", - "13.0.0-nightly.20210226", - "13.0.0-nightly.20210301", - "13.0.0-nightly.20210302", - "13.0.0-nightly.20210303", - "14.0.0-nightly.20210304" - ], - "90.0.4415.0": [ - "13.0.0-beta.4", - "13.0.0-beta.5", - "13.0.0-beta.6", - "13.0.0-beta.7", - "13.0.0-beta.8", - "13.0.0-beta.9", - "13.0.0-beta.10", - "13.0.0-beta.11", - "13.0.0-beta.12", - "13.0.0-beta.13", - "14.0.0-nightly.20210305", - "14.0.0-nightly.20210308", - "14.0.0-nightly.20210309", - "14.0.0-nightly.20210311", - "14.0.0-nightly.20210315", - "14.0.0-nightly.20210316", - "14.0.0-nightly.20210317", - "14.0.0-nightly.20210318", - "14.0.0-nightly.20210319", - "14.0.0-nightly.20210323", - "14.0.0-nightly.20210324", - "14.0.0-nightly.20210325", - "14.0.0-nightly.20210326", - "14.0.0-nightly.20210329", - "14.0.0-nightly.20210330" - ], - "91.0.4448.0": [ - "13.0.0-beta.14", - "13.0.0-beta.16", - "13.0.0-beta.17", - "13.0.0-beta.18", - "13.0.0-beta.20", - "14.0.0-nightly.20210331", - "14.0.0-nightly.20210401", - "14.0.0-nightly.20210402", - "14.0.0-nightly.20210406", - "14.0.0-nightly.20210407", - "14.0.0-nightly.20210408", - "14.0.0-nightly.20210409", - "14.0.0-nightly.20210413" - ], - "91.0.4472.33": [ - "13.0.0-beta.21", - "13.0.0-beta.22", - "13.0.0-beta.23" - ], - "91.0.4472.38": [ - "13.0.0-beta.24", - "13.0.0-beta.25", - "13.0.0-beta.26", - "13.0.0-beta.27", - "13.0.0-beta.28" - ], - "89.0.4349.0": [ - "13.0.0-nightly.20201215", - "13.0.0-nightly.20201216", - "13.0.0-nightly.20201221", - "13.0.0-nightly.20201222" - ], - "89.0.4359.0": [ - "13.0.0-nightly.20201223", - "13.0.0-nightly.20210104", - "13.0.0-nightly.20210108", - "13.0.0-nightly.20210111" - ], - "89.0.4386.0": [ - "13.0.0-nightly.20210113", - "13.0.0-nightly.20210114", - "13.0.0-nightly.20210118", - "13.0.0-nightly.20210122", - "13.0.0-nightly.20210125" - ], - "89.0.4389.0": [ - "13.0.0-nightly.20210127", - "13.0.0-nightly.20210128", - "13.0.0-nightly.20210129", - "13.0.0-nightly.20210201", - "13.0.0-nightly.20210202", - "13.0.0-nightly.20210203", - "13.0.0-nightly.20210205", - "13.0.0-nightly.20210208", - "13.0.0-nightly.20210209" - ], - "91.0.4472.69": [ - "13.0.0", - "13.0.1" - ], - "91.0.4472.77": [ - "13.1.0", - "13.1.1", - "13.1.2" - ], - "91.0.4472.106": [ - "13.1.3", - "13.1.4" - ], - "91.0.4472.124": [ - "13.1.5", - "13.1.6", - "13.1.7" - ], - "91.0.4472.164": [ - "13.1.8", - "13.1.9", - "13.2.0", - "13.2.1", - "13.2.2", - "13.2.3", - "13.3.0", - "13.4.0", - "13.5.0", - "13.5.1", - "13.5.2", - "13.6.0", - "13.6.1", - "13.6.2", - "13.6.3", - "13.6.6", - "13.6.7", - "13.6.8", - "13.6.9" - ], - "92.0.4511.0": [ - "14.0.0-beta.1", - "14.0.0-beta.2", - "14.0.0-beta.3", - "14.0.0-nightly.20210520", - "14.0.0-nightly.20210523", - "14.0.0-nightly.20210524", - "15.0.0-nightly.20210527", - "15.0.0-nightly.20210528", - "15.0.0-nightly.20210531", - "15.0.0-nightly.20210601", - "15.0.0-nightly.20210602" - ], - "93.0.4536.0": [ - "14.0.0-beta.5", - "14.0.0-beta.6", - "14.0.0-beta.7", - "14.0.0-beta.8", - "15.0.0-nightly.20210609", - "15.0.0-nightly.20210610", - "15.0.0-nightly.20210611", - "15.0.0-nightly.20210614", - "15.0.0-nightly.20210615", - "15.0.0-nightly.20210616" - ], - "93.0.4539.0": [ - "14.0.0-beta.9", - "14.0.0-beta.10", - "15.0.0-nightly.20210617", - "15.0.0-nightly.20210618", - "15.0.0-nightly.20210621", - "15.0.0-nightly.20210622" - ], - "93.0.4557.4": [ - "14.0.0-beta.11", - "14.0.0-beta.12" - ], - "93.0.4566.0": [ - "14.0.0-beta.13", - "14.0.0-beta.14", - "14.0.0-beta.15", - "14.0.0-beta.16", - "14.0.0-beta.17", - "15.0.0-alpha.1", - "15.0.0-alpha.2", - "15.0.0-nightly.20210706", - "15.0.0-nightly.20210707", - "15.0.0-nightly.20210708", - "15.0.0-nightly.20210709", - "15.0.0-nightly.20210712", - "15.0.0-nightly.20210713", - "15.0.0-nightly.20210714", - "15.0.0-nightly.20210715", - "15.0.0-nightly.20210716", - "15.0.0-nightly.20210719", - "15.0.0-nightly.20210720", - "15.0.0-nightly.20210721", - "16.0.0-nightly.20210722", - "16.0.0-nightly.20210723", - "16.0.0-nightly.20210726" - ], - "93.0.4577.15": [ - "14.0.0-beta.18", - "14.0.0-beta.19", - "14.0.0-beta.20", - "14.0.0-beta.21" - ], - "93.0.4577.25": [ - "14.0.0-beta.22", - "14.0.0-beta.23" - ], - "93.0.4577.51": [ - "14.0.0-beta.24", - "14.0.0-beta.25" - ], - "92.0.4475.0": [ - "14.0.0-nightly.20210426", - "14.0.0-nightly.20210427" - ], - "92.0.4488.0": [ - "14.0.0-nightly.20210430", - "14.0.0-nightly.20210503" - ], - "92.0.4496.0": [ - "14.0.0-nightly.20210505" - ], - "92.0.4498.0": [ - "14.0.0-nightly.20210506" - ], - "92.0.4499.0": [ - "14.0.0-nightly.20210507", - "14.0.0-nightly.20210510", - "14.0.0-nightly.20210511", - "14.0.0-nightly.20210512", - "14.0.0-nightly.20210513" - ], - "92.0.4505.0": [ - "14.0.0-nightly.20210514", - "14.0.0-nightly.20210517", - "14.0.0-nightly.20210518", - "14.0.0-nightly.20210519" - ], - "93.0.4577.58": [ - "14.0.0" - ], - "93.0.4577.63": [ - "14.0.1" - ], - "93.0.4577.82": [ - "14.0.2", - "14.1.0", - "14.1.1", - "14.2.0", - "14.2.1", - "14.2.2", - "14.2.3", - "14.2.4", - "14.2.5", - "14.2.6", - "14.2.7", - "14.2.8", - "14.2.9" - ], - "94.0.4584.0": [ - "15.0.0-alpha.3", - "15.0.0-alpha.4", - "15.0.0-alpha.5", - "15.0.0-alpha.6", - "16.0.0-nightly.20210727", - "16.0.0-nightly.20210728", - "16.0.0-nightly.20210729", - "16.0.0-nightly.20210730", - "16.0.0-nightly.20210802", - "16.0.0-nightly.20210803", - "16.0.0-nightly.20210804", - "16.0.0-nightly.20210805", - "16.0.0-nightly.20210806", - "16.0.0-nightly.20210809", - "16.0.0-nightly.20210810", - "16.0.0-nightly.20210811" - ], - "94.0.4590.2": [ - "15.0.0-alpha.7", - "15.0.0-alpha.8", - "15.0.0-alpha.9", - "16.0.0-nightly.20210812", - "16.0.0-nightly.20210813", - "16.0.0-nightly.20210816", - "16.0.0-nightly.20210817", - "16.0.0-nightly.20210818", - "16.0.0-nightly.20210819", - "16.0.0-nightly.20210820", - "16.0.0-nightly.20210823" - ], - "94.0.4606.12": [ - "15.0.0-alpha.10" - ], - "94.0.4606.20": [ - "15.0.0-beta.1", - "15.0.0-beta.2" - ], - "94.0.4606.31": [ - "15.0.0-beta.3", - "15.0.0-beta.4", - "15.0.0-beta.5", - "15.0.0-beta.6", - "15.0.0-beta.7" - ], - "93.0.4530.0": [ - "15.0.0-nightly.20210603", - "15.0.0-nightly.20210604" - ], - "93.0.4535.0": [ - "15.0.0-nightly.20210608" - ], - "93.0.4550.0": [ - "15.0.0-nightly.20210623", - "15.0.0-nightly.20210624" - ], - "93.0.4552.0": [ - "15.0.0-nightly.20210625", - "15.0.0-nightly.20210628", - "15.0.0-nightly.20210629" - ], - "93.0.4558.0": [ - "15.0.0-nightly.20210630", - "15.0.0-nightly.20210701", - "15.0.0-nightly.20210702", - "15.0.0-nightly.20210705" - ], - "94.0.4606.51": [ - "15.0.0" - ], - "94.0.4606.61": [ - "15.1.0", - "15.1.1" - ], - "94.0.4606.71": [ - "15.1.2" - ], - "94.0.4606.81": [ - "15.2.0", - "15.3.0", - "15.3.1", - "15.3.2", - "15.3.3", - "15.3.4", - "15.3.5", - "15.3.6", - "15.3.7", - "15.4.0", - "15.4.1", - "15.4.2", - "15.5.0", - "15.5.1", - "15.5.2", - "15.5.3", - "15.5.4", - "15.5.5", - "15.5.6", - "15.5.7" - ], - "95.0.4629.0": [ - "16.0.0-alpha.1", - "16.0.0-alpha.2", - "16.0.0-alpha.3", - "16.0.0-alpha.4", - "16.0.0-alpha.5", - "16.0.0-alpha.6", - "16.0.0-alpha.7", - "16.0.0-nightly.20210902", - "16.0.0-nightly.20210903", - "16.0.0-nightly.20210906", - "16.0.0-nightly.20210907", - "16.0.0-nightly.20210908", - "16.0.0-nightly.20210909", - "16.0.0-nightly.20210910", - "16.0.0-nightly.20210913", - "16.0.0-nightly.20210914", - "16.0.0-nightly.20210915", - "16.0.0-nightly.20210916", - "16.0.0-nightly.20210917", - "16.0.0-nightly.20210920", - "16.0.0-nightly.20210921", - "16.0.0-nightly.20210922", - "17.0.0-nightly.20210923", - "17.0.0-nightly.20210924", - "17.0.0-nightly.20210927", - "17.0.0-nightly.20210928", - "17.0.0-nightly.20210929", - "17.0.0-nightly.20210930", - "17.0.0-nightly.20211001", - "17.0.0-nightly.20211004", - "17.0.0-nightly.20211005" - ], - "96.0.4647.0": [ - "16.0.0-alpha.8", - "16.0.0-alpha.9", - "16.0.0-beta.1", - "16.0.0-beta.2", - "16.0.0-beta.3", - "17.0.0-nightly.20211006", - "17.0.0-nightly.20211007", - "17.0.0-nightly.20211008", - "17.0.0-nightly.20211011", - "17.0.0-nightly.20211012", - "17.0.0-nightly.20211013", - "17.0.0-nightly.20211014", - "17.0.0-nightly.20211015", - "17.0.0-nightly.20211018", - "17.0.0-nightly.20211019", - "17.0.0-nightly.20211020", - "17.0.0-nightly.20211021" - ], - "96.0.4664.18": [ - "16.0.0-beta.4", - "16.0.0-beta.5" - ], - "96.0.4664.27": [ - "16.0.0-beta.6", - "16.0.0-beta.7" - ], - "96.0.4664.35": [ - "16.0.0-beta.8", - "16.0.0-beta.9" - ], - "95.0.4612.5": [ - "16.0.0-nightly.20210824", - "16.0.0-nightly.20210825", - "16.0.0-nightly.20210826", - "16.0.0-nightly.20210827", - "16.0.0-nightly.20210830", - "16.0.0-nightly.20210831", - "16.0.0-nightly.20210901" - ], - "96.0.4664.45": [ - "16.0.0", - "16.0.1" - ], - "96.0.4664.55": [ - "16.0.2", - "16.0.3", - "16.0.4", - "16.0.5" - ], - "96.0.4664.110": [ - "16.0.6", - "16.0.7", - "16.0.8" - ], - "96.0.4664.174": [ - "16.0.9", - "16.0.10", - "16.1.0", - "16.1.1", - "16.2.0", - "16.2.1", - "16.2.2", - "16.2.3", - "16.2.4", - "16.2.5", - "16.2.6", - "16.2.7", - "16.2.8" - ], - "96.0.4664.4": [ - "17.0.0-alpha.1", - "17.0.0-alpha.2", - "17.0.0-alpha.3", - "17.0.0-nightly.20211022", - "17.0.0-nightly.20211025", - "17.0.0-nightly.20211026", - "17.0.0-nightly.20211027", - "17.0.0-nightly.20211028", - "17.0.0-nightly.20211029", - "17.0.0-nightly.20211101", - "17.0.0-nightly.20211102", - "17.0.0-nightly.20211103", - "17.0.0-nightly.20211104", - "17.0.0-nightly.20211105", - "17.0.0-nightly.20211108", - "17.0.0-nightly.20211109", - "17.0.0-nightly.20211110", - "17.0.0-nightly.20211111", - "17.0.0-nightly.20211112", - "17.0.0-nightly.20211115", - "17.0.0-nightly.20211116", - "17.0.0-nightly.20211117", - "18.0.0-nightly.20211118", - "18.0.0-nightly.20211119", - "18.0.0-nightly.20211122", - "18.0.0-nightly.20211123" - ], - "98.0.4706.0": [ - "17.0.0-alpha.4", - "17.0.0-alpha.5", - "17.0.0-alpha.6", - "17.0.0-beta.1", - "17.0.0-beta.2", - "18.0.0-nightly.20211124", - "18.0.0-nightly.20211125", - "18.0.0-nightly.20211126", - "18.0.0-nightly.20211129", - "18.0.0-nightly.20211130", - "18.0.0-nightly.20211201", - "18.0.0-nightly.20211202", - "18.0.0-nightly.20211203", - "18.0.0-nightly.20211206", - "18.0.0-nightly.20211207", - "18.0.0-nightly.20211208", - "18.0.0-nightly.20211209", - "18.0.0-nightly.20211210", - "18.0.0-nightly.20211213", - "18.0.0-nightly.20211214", - "18.0.0-nightly.20211215", - "18.0.0-nightly.20211216", - "18.0.0-nightly.20211217", - "18.0.0-nightly.20211220", - "18.0.0-nightly.20211221", - "18.0.0-nightly.20211222", - "18.0.0-nightly.20211223", - "18.0.0-nightly.20211228", - "18.0.0-nightly.20211229", - "18.0.0-nightly.20211231", - "18.0.0-nightly.20220103", - "18.0.0-nightly.20220104", - "18.0.0-nightly.20220105", - "18.0.0-nightly.20220106", - "18.0.0-nightly.20220107", - "18.0.0-nightly.20220110" - ], - "98.0.4758.9": [ - "17.0.0-beta.3" - ], - "98.0.4758.11": [ - "17.0.0-beta.4", - "17.0.0-beta.5", - "17.0.0-beta.6", - "17.0.0-beta.7", - "17.0.0-beta.8", - "17.0.0-beta.9" - ], - "98.0.4758.74": [ - "17.0.0" - ], - "98.0.4758.82": [ - "17.0.1" - ], - "98.0.4758.102": [ - "17.1.0" - ], - "98.0.4758.109": [ - "17.1.1", - "17.1.2", - "17.2.0" - ], - "98.0.4758.141": [ - "17.3.0", - "17.3.1", - "17.4.0", - "17.4.1", - "17.4.2", - "17.4.3", - "17.4.4", - "17.4.5", - "17.4.6", - "17.4.7", - "17.4.8", - "17.4.9", - "17.4.10", - "17.4.11" - ], - "99.0.4767.0": [ - "18.0.0-alpha.1", - "18.0.0-alpha.2", - "18.0.0-alpha.3", - "18.0.0-alpha.4", - "18.0.0-alpha.5", - "18.0.0-nightly.20220111", - "18.0.0-nightly.20220112", - "18.0.0-nightly.20220113", - "18.0.0-nightly.20220114", - "18.0.0-nightly.20220117", - "18.0.0-nightly.20220118", - "18.0.0-nightly.20220119", - "18.0.0-nightly.20220121", - "18.0.0-nightly.20220124", - "18.0.0-nightly.20220125", - "18.0.0-nightly.20220127", - "18.0.0-nightly.20220128", - "18.0.0-nightly.20220131", - "18.0.0-nightly.20220201", - "19.0.0-nightly.20220202", - "19.0.0-nightly.20220203", - "19.0.0-nightly.20220204", - "19.0.0-nightly.20220207", - "19.0.0-nightly.20220208", - "19.0.0-nightly.20220209" - ], - "100.0.4894.0": [ - "18.0.0-beta.1", - "18.0.0-beta.2", - "18.0.0-beta.3", - "18.0.0-beta.4", - "18.0.0-beta.5", - "18.0.0-beta.6", - "19.0.0-nightly.20220308", - "19.0.0-nightly.20220309", - "19.0.0-nightly.20220310", - "19.0.0-nightly.20220311", - "19.0.0-nightly.20220314", - "19.0.0-nightly.20220315", - "19.0.0-nightly.20220316", - "19.0.0-nightly.20220317", - "19.0.0-nightly.20220318", - "19.0.0-nightly.20220321", - "19.0.0-nightly.20220322", - "19.0.0-nightly.20220323", - "19.0.0-nightly.20220324" - ], - "100.0.4896.56": [ - "18.0.0" - ], - "100.0.4896.60": [ - "18.0.1", - "18.0.2" - ], - "100.0.4896.75": [ - "18.0.3", - "18.0.4" - ], - "100.0.4896.127": [ - "18.1.0" - ], - "100.0.4896.143": [ - "18.2.0", - "18.2.1", - "18.2.2", - "18.2.3" - ], - "100.0.4896.160": [ - "18.2.4", - "18.3.0", - "18.3.1", - "18.3.2", - "18.3.3", - "18.3.4", - "18.3.5", - "18.3.6", - "18.3.7", - "18.3.8", - "18.3.9", - "18.3.11", - "18.3.12", - "18.3.13", - "18.3.14", - "18.3.15" - ], - "102.0.4962.3": [ - "19.0.0-alpha.1", - "19.0.0-nightly.20220328", - "19.0.0-nightly.20220329", - "20.0.0-nightly.20220330" - ], - "102.0.4971.0": [ - "19.0.0-alpha.2", - "19.0.0-alpha.3", - "20.0.0-nightly.20220411" - ], - "102.0.4989.0": [ - "19.0.0-alpha.4", - "19.0.0-alpha.5", - "20.0.0-nightly.20220414", - "20.0.0-nightly.20220415", - "20.0.0-nightly.20220418", - "20.0.0-nightly.20220419", - "20.0.0-nightly.20220420", - "20.0.0-nightly.20220421" - ], - "102.0.4999.0": [ - "19.0.0-beta.1", - "19.0.0-beta.2", - "19.0.0-beta.3", - "20.0.0-nightly.20220425", - "20.0.0-nightly.20220426", - "20.0.0-nightly.20220427", - "20.0.0-nightly.20220428", - "20.0.0-nightly.20220429", - "20.0.0-nightly.20220502", - "20.0.0-nightly.20220503", - "20.0.0-nightly.20220504", - "20.0.0-nightly.20220505", - "20.0.0-nightly.20220506", - "20.0.0-nightly.20220509", - "20.0.0-nightly.20220511", - "20.0.0-nightly.20220512", - "20.0.0-nightly.20220513", - "20.0.0-nightly.20220516", - "20.0.0-nightly.20220517" - ], - "102.0.5005.27": [ - "19.0.0-beta.4" - ], - "102.0.5005.40": [ - "19.0.0-beta.5", - "19.0.0-beta.6", - "19.0.0-beta.7" - ], - "102.0.5005.49": [ - "19.0.0-beta.8" - ], - "102.0.4961.0": [ - "19.0.0-nightly.20220325" - ], - "102.0.5005.61": [ - "19.0.0", - "19.0.1" - ], - "102.0.5005.63": [ - "19.0.2", - "19.0.3", - "19.0.4" - ], - "102.0.5005.115": [ - "19.0.5", - "19.0.6" - ], - "102.0.5005.134": [ - "19.0.7" - ], - "102.0.5005.148": [ - "19.0.8" - ], - "102.0.5005.167": [ - "19.0.9", - "19.0.10", - "19.0.11", - "19.0.12", - "19.0.13", - "19.0.14", - "19.0.15", - "19.0.16", - "19.0.17", - "19.1.0", - "19.1.1", - "19.1.2", - "19.1.3", - "19.1.4", - "19.1.5", - "19.1.6", - "19.1.7", - "19.1.8", - "19.1.9" - ], - "103.0.5044.0": [ - "20.0.0-alpha.1", - "20.0.0-nightly.20220518", - "20.0.0-nightly.20220519", - "20.0.0-nightly.20220520", - "20.0.0-nightly.20220523", - "20.0.0-nightly.20220524", - "21.0.0-nightly.20220526", - "21.0.0-nightly.20220527", - "21.0.0-nightly.20220530", - "21.0.0-nightly.20220531" - ], - "104.0.5073.0": [ - "20.0.0-alpha.2", - "20.0.0-alpha.3", - "20.0.0-alpha.4", - "20.0.0-alpha.5", - "20.0.0-alpha.6", - "20.0.0-alpha.7", - "20.0.0-beta.1", - "20.0.0-beta.2", - "20.0.0-beta.3", - "20.0.0-beta.4", - "20.0.0-beta.5", - "20.0.0-beta.6", - "20.0.0-beta.7", - "20.0.0-beta.8", - "21.0.0-nightly.20220602", - "21.0.0-nightly.20220603", - "21.0.0-nightly.20220606", - "21.0.0-nightly.20220607", - "21.0.0-nightly.20220608", - "21.0.0-nightly.20220609", - "21.0.0-nightly.20220610", - "21.0.0-nightly.20220613", - "21.0.0-nightly.20220614", - "21.0.0-nightly.20220615", - "21.0.0-nightly.20220616", - "21.0.0-nightly.20220617", - "21.0.0-nightly.20220620", - "21.0.0-nightly.20220621", - "21.0.0-nightly.20220622", - "21.0.0-nightly.20220623", - "21.0.0-nightly.20220624", - "21.0.0-nightly.20220627" - ], - "104.0.5112.39": [ - "20.0.0-beta.9" - ], - "104.0.5112.48": [ - "20.0.0-beta.10", - "20.0.0-beta.11", - "20.0.0-beta.12" - ], - "104.0.5112.57": [ - "20.0.0-beta.13" - ], - "104.0.5112.65": [ - "20.0.0" - ], - "104.0.5112.81": [ - "20.0.1", - "20.0.2", - "20.0.3" - ], - "104.0.5112.102": [ - "20.1.0", - "20.1.1" - ], - "104.0.5112.114": [ - "20.1.2", - "20.1.3", - "20.1.4" - ], - "104.0.5112.124": [ - "20.2.0", - "20.3.0", - "20.3.1", - "20.3.2", - "20.3.3", - "20.3.4", - "20.3.5", - "20.3.6", - "20.3.7", - "20.3.8", - "20.3.9", - "20.3.10", - "20.3.11", - "20.3.12" - ], - "105.0.5187.0": [ - "21.0.0-alpha.1", - "21.0.0-alpha.2", - "21.0.0-alpha.3", - "21.0.0-alpha.4", - "21.0.0-alpha.5", - "21.0.0-nightly.20220720", - "21.0.0-nightly.20220721", - "21.0.0-nightly.20220722", - "21.0.0-nightly.20220725", - "21.0.0-nightly.20220726", - "21.0.0-nightly.20220727", - "21.0.0-nightly.20220728", - "21.0.0-nightly.20220801", - "21.0.0-nightly.20220802", - "22.0.0-nightly.20220808", - "22.0.0-nightly.20220809", - "22.0.0-nightly.20220810", - "22.0.0-nightly.20220811", - "22.0.0-nightly.20220812", - "22.0.0-nightly.20220815", - "22.0.0-nightly.20220816", - "22.0.0-nightly.20220817" - ], - "106.0.5216.0": [ - "21.0.0-alpha.6", - "21.0.0-beta.1", - "21.0.0-beta.2", - "21.0.0-beta.3", - "21.0.0-beta.4", - "21.0.0-beta.5", - "22.0.0-nightly.20220822", - "22.0.0-nightly.20220823", - "22.0.0-nightly.20220824", - "22.0.0-nightly.20220825", - "22.0.0-nightly.20220829", - "22.0.0-nightly.20220830", - "22.0.0-nightly.20220831", - "22.0.0-nightly.20220901", - "22.0.0-nightly.20220902", - "22.0.0-nightly.20220905" - ], - "106.0.5249.40": [ - "21.0.0-beta.6", - "21.0.0-beta.7", - "21.0.0-beta.8" - ], - "105.0.5129.0": [ - "21.0.0-nightly.20220628", - "21.0.0-nightly.20220629", - "21.0.0-nightly.20220630", - "21.0.0-nightly.20220701", - "21.0.0-nightly.20220704", - "21.0.0-nightly.20220705", - "21.0.0-nightly.20220706", - "21.0.0-nightly.20220707", - "21.0.0-nightly.20220708", - "21.0.0-nightly.20220711", - "21.0.0-nightly.20220712", - "21.0.0-nightly.20220713" - ], - "105.0.5173.0": [ - "21.0.0-nightly.20220715", - "21.0.0-nightly.20220718", - "21.0.0-nightly.20220719" - ], - "106.0.5249.51": [ - "21.0.0" - ], - "106.0.5249.61": [ - "21.0.1" - ], - "106.0.5249.91": [ - "21.1.0" - ], - "106.0.5249.103": [ - "21.1.1" - ], - "106.0.5249.119": [ - "21.2.0" - ], - "106.0.5249.165": [ - "21.2.1" - ], - "106.0.5249.168": [ - "21.2.2", - "21.2.3" - ], - "106.0.5249.181": [ - "21.3.0", - "21.3.1" - ], - "106.0.5249.199": [ - "21.3.3", - "21.3.4", - "21.3.5", - "21.4.0", - "21.4.1", - "21.4.2", - "21.4.3", - "21.4.4" - ], - "107.0.5286.0": [ - "22.0.0-alpha.1", - "22.0.0-nightly.20220909", - "22.0.0-nightly.20220912", - "22.0.0-nightly.20220913", - "22.0.0-nightly.20220914", - "22.0.0-nightly.20220915", - "22.0.0-nightly.20220916", - "22.0.0-nightly.20220919", - "22.0.0-nightly.20220920", - "22.0.0-nightly.20220921", - "22.0.0-nightly.20220922", - "22.0.0-nightly.20220923", - "22.0.0-nightly.20220926", - "22.0.0-nightly.20220927", - "22.0.0-nightly.20220928", - "23.0.0-nightly.20220929", - "23.0.0-nightly.20220930", - "23.0.0-nightly.20221003" - ], - "108.0.5329.0": [ - "22.0.0-alpha.3", - "22.0.0-alpha.4", - "22.0.0-alpha.5", - "22.0.0-alpha.6", - "23.0.0-nightly.20221004", - "23.0.0-nightly.20221005", - "23.0.0-nightly.20221006", - "23.0.0-nightly.20221007", - "23.0.0-nightly.20221010", - "23.0.0-nightly.20221011", - "23.0.0-nightly.20221012", - "23.0.0-nightly.20221013", - "23.0.0-nightly.20221014", - "23.0.0-nightly.20221017" - ], - "108.0.5355.0": [ - "22.0.0-alpha.7", - "23.0.0-nightly.20221018", - "23.0.0-nightly.20221019", - "23.0.0-nightly.20221020", - "23.0.0-nightly.20221021", - "23.0.0-nightly.20221024", - "23.0.0-nightly.20221026" - ], - "108.0.5359.10": [ - "22.0.0-alpha.8", - "22.0.0-beta.1", - "22.0.0-beta.2", - "22.0.0-beta.3" - ], - "108.0.5359.29": [ - "22.0.0-beta.4" - ], - "108.0.5359.40": [ - "22.0.0-beta.5", - "22.0.0-beta.6" - ], - "108.0.5359.48": [ - "22.0.0-beta.7", - "22.0.0-beta.8" - ], - "107.0.5274.0": [ - "22.0.0-nightly.20220908" - ], - "108.0.5359.62": [ - "22.0.0" - ], - "108.0.5359.125": [ - "22.0.1" - ], - "108.0.5359.179": [ - "22.0.2", - "22.0.3", - "22.1.0" - ], - "108.0.5359.215": [ - "22.2.0", - "22.2.1", - "22.3.0", - "22.3.1", - "22.3.2", - "22.3.3", - "22.3.4", - "22.3.5", - "22.3.6", - "22.3.7", - "22.3.8", - "22.3.9", - "22.3.10", - "22.3.11", - "22.3.12", - "22.3.13", - "22.3.14", - "22.3.15", - "22.3.16", - "22.3.17", - "22.3.18", - "22.3.20", - "22.3.21", - "22.3.22", - "22.3.23", - "22.3.24", - "22.3.25", - "22.3.26", - "22.3.27" - ], - "110.0.5415.0": [ - "23.0.0-alpha.1", - "23.0.0-nightly.20221118", - "23.0.0-nightly.20221121", - "23.0.0-nightly.20221122", - "23.0.0-nightly.20221123", - "23.0.0-nightly.20221124", - "23.0.0-nightly.20221125", - "23.0.0-nightly.20221128", - "23.0.0-nightly.20221129", - "23.0.0-nightly.20221130", - "24.0.0-nightly.20221201", - "24.0.0-nightly.20221202", - "24.0.0-nightly.20221205" - ], - "110.0.5451.0": [ - "23.0.0-alpha.2", - "23.0.0-alpha.3", - "24.0.0-nightly.20221206", - "24.0.0-nightly.20221207", - "24.0.0-nightly.20221208", - "24.0.0-nightly.20221213", - "24.0.0-nightly.20221214", - "24.0.0-nightly.20221215", - "24.0.0-nightly.20221216" - ], - "110.0.5478.5": [ - "23.0.0-beta.1", - "23.0.0-beta.2", - "23.0.0-beta.3" - ], - "110.0.5481.30": [ - "23.0.0-beta.4" - ], - "110.0.5481.38": [ - "23.0.0-beta.5" - ], - "110.0.5481.52": [ - "23.0.0-beta.6", - "23.0.0-beta.8" - ], - "109.0.5382.0": [ - "23.0.0-nightly.20221027", - "23.0.0-nightly.20221028", - "23.0.0-nightly.20221031", - "23.0.0-nightly.20221101", - "23.0.0-nightly.20221102", - "23.0.0-nightly.20221103", - "23.0.0-nightly.20221104", - "23.0.0-nightly.20221107", - "23.0.0-nightly.20221108", - "23.0.0-nightly.20221109", - "23.0.0-nightly.20221110", - "23.0.0-nightly.20221111", - "23.0.0-nightly.20221114", - "23.0.0-nightly.20221115", - "23.0.0-nightly.20221116", - "23.0.0-nightly.20221117" - ], - "110.0.5481.77": [ - "23.0.0" - ], - "110.0.5481.100": [ - "23.1.0" - ], - "110.0.5481.104": [ - "23.1.1" - ], - "110.0.5481.177": [ - "23.1.2" - ], - "110.0.5481.179": [ - "23.1.3" - ], - "110.0.5481.192": [ - "23.1.4", - "23.2.0" - ], - "110.0.5481.208": [ - "23.2.1", - "23.2.2", - "23.2.3", - "23.2.4", - "23.3.0", - "23.3.1", - "23.3.2", - "23.3.3", - "23.3.4", - "23.3.5", - "23.3.6", - "23.3.7", - "23.3.8", - "23.3.9", - "23.3.10", - "23.3.11", - "23.3.12", - "23.3.13" - ], - "111.0.5560.0": [ - "24.0.0-alpha.1", - "24.0.0-alpha.2", - "24.0.0-alpha.3", - "24.0.0-alpha.4", - "24.0.0-alpha.5", - "24.0.0-alpha.6", - "24.0.0-alpha.7", - "24.0.0-nightly.20230203", - "24.0.0-nightly.20230206", - "24.0.0-nightly.20230207", - "24.0.0-nightly.20230208", - "24.0.0-nightly.20230209", - "25.0.0-nightly.20230210", - "25.0.0-nightly.20230214", - "25.0.0-nightly.20230215", - "25.0.0-nightly.20230216", - "25.0.0-nightly.20230217", - "25.0.0-nightly.20230220", - "25.0.0-nightly.20230221", - "25.0.0-nightly.20230222", - "25.0.0-nightly.20230223", - "25.0.0-nightly.20230224", - "25.0.0-nightly.20230227", - "25.0.0-nightly.20230228", - "25.0.0-nightly.20230301", - "25.0.0-nightly.20230302", - "25.0.0-nightly.20230303", - "25.0.0-nightly.20230306", - "25.0.0-nightly.20230307", - "25.0.0-nightly.20230308", - "25.0.0-nightly.20230309", - "25.0.0-nightly.20230310" - ], - "111.0.5563.50": [ - "24.0.0-beta.1", - "24.0.0-beta.2" - ], - "112.0.5615.20": [ - "24.0.0-beta.3", - "24.0.0-beta.4" - ], - "112.0.5615.29": [ - "24.0.0-beta.5" - ], - "112.0.5615.39": [ - "24.0.0-beta.6", - "24.0.0-beta.7" - ], - "111.0.5518.0": [ - "24.0.0-nightly.20230109", - "24.0.0-nightly.20230110", - "24.0.0-nightly.20230111", - "24.0.0-nightly.20230112", - "24.0.0-nightly.20230113", - "24.0.0-nightly.20230116", - "24.0.0-nightly.20230117", - "24.0.0-nightly.20230118", - "24.0.0-nightly.20230119", - "24.0.0-nightly.20230120", - "24.0.0-nightly.20230123", - "24.0.0-nightly.20230124", - "24.0.0-nightly.20230125", - "24.0.0-nightly.20230126", - "24.0.0-nightly.20230127", - "24.0.0-nightly.20230131", - "24.0.0-nightly.20230201", - "24.0.0-nightly.20230202" - ], - "112.0.5615.49": [ - "24.0.0" - ], - "112.0.5615.50": [ - "24.1.0", - "24.1.1" - ], - "112.0.5615.87": [ - "24.1.2" - ], - "112.0.5615.165": [ - "24.1.3", - "24.2.0", - "24.3.0" - ], - "112.0.5615.183": [ - "24.3.1" - ], - "112.0.5615.204": [ - "24.4.0", - "24.4.1", - "24.5.0", - "24.5.1", - "24.6.0", - "24.6.1", - "24.6.2", - "24.6.3", - "24.6.4", - "24.6.5", - "24.7.0", - "24.7.1", - "24.8.0", - "24.8.1", - "24.8.2", - "24.8.3", - "24.8.4", - "24.8.5", - "24.8.6", - "24.8.7", - "24.8.8" - ], - "114.0.5694.0": [ - "25.0.0-alpha.1", - "25.0.0-alpha.2", - "25.0.0-nightly.20230405", - "26.0.0-nightly.20230406", - "26.0.0-nightly.20230407", - "26.0.0-nightly.20230410", - "26.0.0-nightly.20230411" - ], - "114.0.5710.0": [ - "25.0.0-alpha.3", - "25.0.0-alpha.4", - "26.0.0-nightly.20230413", - "26.0.0-nightly.20230414", - "26.0.0-nightly.20230417" - ], - "114.0.5719.0": [ - "25.0.0-alpha.5", - "25.0.0-alpha.6", - "25.0.0-beta.1", - "25.0.0-beta.2", - "25.0.0-beta.3", - "26.0.0-nightly.20230421", - "26.0.0-nightly.20230424", - "26.0.0-nightly.20230425", - "26.0.0-nightly.20230426", - "26.0.0-nightly.20230427", - "26.0.0-nightly.20230428", - "26.0.0-nightly.20230501", - "26.0.0-nightly.20230502", - "26.0.0-nightly.20230503", - "26.0.0-nightly.20230504", - "26.0.0-nightly.20230505", - "26.0.0-nightly.20230508", - "26.0.0-nightly.20230509", - "26.0.0-nightly.20230510" - ], - "114.0.5735.16": [ - "25.0.0-beta.4", - "25.0.0-beta.5", - "25.0.0-beta.6", - "25.0.0-beta.7" - ], - "114.0.5735.35": [ - "25.0.0-beta.8" - ], - "114.0.5735.45": [ - "25.0.0-beta.9", - "25.0.0", - "25.0.1" - ], - "113.0.5636.0": [ - "25.0.0-nightly.20230314" - ], - "113.0.5651.0": [ - "25.0.0-nightly.20230315" - ], - "113.0.5653.0": [ - "25.0.0-nightly.20230317" - ], - "113.0.5660.0": [ - "25.0.0-nightly.20230320" - ], - "113.0.5664.0": [ - "25.0.0-nightly.20230321" - ], - "113.0.5666.0": [ - "25.0.0-nightly.20230322" - ], - "113.0.5668.0": [ - "25.0.0-nightly.20230323" - ], - "113.0.5670.0": [ - "25.0.0-nightly.20230324", - "25.0.0-nightly.20230327", - "25.0.0-nightly.20230328", - "25.0.0-nightly.20230329", - "25.0.0-nightly.20230330" - ], - "114.0.5684.0": [ - "25.0.0-nightly.20230331", - "25.0.0-nightly.20230403" - ], - "114.0.5692.0": [ - "25.0.0-nightly.20230404" - ], - "114.0.5735.106": [ - "25.1.0", - "25.1.1" - ], - "114.0.5735.134": [ - "25.2.0" - ], - "114.0.5735.199": [ - "25.3.0" - ], - "114.0.5735.243": [ - "25.3.1" - ], - "114.0.5735.248": [ - "25.3.2", - "25.4.0" - ], - "114.0.5735.289": [ - "25.5.0", - "25.6.0", - "25.7.0", - "25.8.0", - "25.8.1", - "25.8.2", - "25.8.3", - "25.8.4", - "25.9.0", - "25.9.1", - "25.9.2", - "25.9.3", - "25.9.4", - "25.9.5", - "25.9.6", - "25.9.7", - "25.9.8" - ], - "116.0.5791.0": [ - "26.0.0-alpha.1", - "26.0.0-alpha.2", - "26.0.0-alpha.3", - "26.0.0-alpha.4", - "26.0.0-alpha.5", - "26.0.0-nightly.20230526", - "26.0.0-nightly.20230529", - "26.0.0-nightly.20230530", - "26.0.0-nightly.20230531", - "27.0.0-nightly.20230601", - "27.0.0-nightly.20230602", - "27.0.0-nightly.20230605", - "27.0.0-nightly.20230606", - "27.0.0-nightly.20230607", - "27.0.0-nightly.20230609" - ], - "116.0.5815.0": [ - "26.0.0-alpha.6", - "27.0.0-nightly.20230612", - "27.0.0-nightly.20230613" - ], - "116.0.5831.0": [ - "26.0.0-alpha.7", - "27.0.0-nightly.20230615" - ], - "116.0.5845.0": [ - "26.0.0-alpha.8", - "26.0.0-beta.1", - "27.0.0-nightly.20230622", - "27.0.0-nightly.20230623", - "27.0.0-nightly.20230626", - "27.0.0-nightly.20230627", - "27.0.0-nightly.20230628", - "27.0.0-nightly.20230629", - "27.0.0-nightly.20230630" - ], - "116.0.5845.14": [ - "26.0.0-beta.2", - "26.0.0-beta.3", - "26.0.0-beta.4", - "26.0.0-beta.5", - "26.0.0-beta.6", - "26.0.0-beta.7" - ], - "116.0.5845.42": [ - "26.0.0-beta.8", - "26.0.0-beta.9" - ], - "116.0.5845.49": [ - "26.0.0-beta.10", - "26.0.0-beta.11" - ], - "116.0.5845.62": [ - "26.0.0-beta.12" - ], - "114.0.5708.0": [ - "26.0.0-nightly.20230412" - ], - "114.0.5715.0": [ - "26.0.0-nightly.20230418" - ], - "115.0.5760.0": [ - "26.0.0-nightly.20230511", - "26.0.0-nightly.20230512", - "26.0.0-nightly.20230515", - "26.0.0-nightly.20230516", - "26.0.0-nightly.20230517", - "26.0.0-nightly.20230518", - "26.0.0-nightly.20230519", - "26.0.0-nightly.20230522", - "26.0.0-nightly.20230523" - ], - "115.0.5786.0": [ - "26.0.0-nightly.20230524" - ], - "115.0.5790.0": [ - "26.0.0-nightly.20230525" - ], - "116.0.5845.82": [ - "26.0.0" - ], - "116.0.5845.97": [ - "26.1.0" - ], - "116.0.5845.179": [ - "26.2.0" - ], - "116.0.5845.188": [ - "26.2.1" - ], - "116.0.5845.190": [ - "26.2.2", - "26.2.3", - "26.2.4" - ], - "116.0.5845.228": [ - "26.3.0", - "26.4.0", - "26.4.1", - "26.4.2", - "26.4.3", - "26.5.0", - "26.6.0", - "26.6.1", - "26.6.2", - "26.6.3", - "26.6.4", - "26.6.5", - "26.6.6", - "26.6.7", - "26.6.8", - "26.6.9", - "26.6.10" - ], - "118.0.5949.0": [ - "27.0.0-alpha.1", - "27.0.0-alpha.2", - "27.0.0-alpha.3", - "27.0.0-alpha.4", - "27.0.0-alpha.5", - "27.0.0-alpha.6", - "27.0.0-nightly.20230816", - "28.0.0-nightly.20230817", - "28.0.0-nightly.20230818", - "28.0.0-nightly.20230821", - "28.0.0-nightly.20230822", - "28.0.0-nightly.20230823", - "28.0.0-nightly.20230824", - "28.0.0-nightly.20230825", - "28.0.0-nightly.20230828", - "28.0.0-nightly.20230829", - "28.0.0-nightly.20230830", - "28.0.0-nightly.20230831" - ], - "118.0.5993.5": [ - "27.0.0-beta.1", - "27.0.0-beta.2", - "27.0.0-beta.3" - ], - "118.0.5993.11": [ - "27.0.0-beta.4" - ], - "118.0.5993.18": [ - "27.0.0-beta.5", - "27.0.0-beta.6", - "27.0.0-beta.7", - "27.0.0-beta.8", - "27.0.0-beta.9" - ], - "116.0.5829.0": [ - "27.0.0-nightly.20230614" - ], - "116.0.5833.0": [ - "27.0.0-nightly.20230616", - "27.0.0-nightly.20230619", - "27.0.0-nightly.20230620", - "27.0.0-nightly.20230621" - ], - "117.0.5852.0": [ - "27.0.0-nightly.20230703", - "27.0.0-nightly.20230704", - "27.0.0-nightly.20230705", - "27.0.0-nightly.20230706", - "27.0.0-nightly.20230707", - "27.0.0-nightly.20230710", - "27.0.0-nightly.20230711", - "27.0.0-nightly.20230712", - "27.0.0-nightly.20230713", - "27.0.0-nightly.20230714" - ], - "117.0.5884.1": [ - "27.0.0-nightly.20230717", - "27.0.0-nightly.20230718" - ], - "117.0.5892.0": [ - "27.0.0-nightly.20230719" - ], - "117.0.5897.0": [ - "27.0.0-nightly.20230720", - "27.0.0-nightly.20230721", - "27.0.0-nightly.20230724", - "27.0.0-nightly.20230725", - "27.0.0-nightly.20230726", - "27.0.0-nightly.20230727", - "27.0.0-nightly.20230728", - "27.0.0-nightly.20230731" - ], - "117.0.5911.0": [ - "27.0.0-nightly.20230801", - "27.0.0-nightly.20230802", - "27.0.0-nightly.20230803" - ], - "117.0.5921.0": [ - "27.0.0-nightly.20230804", - "27.0.0-nightly.20230807", - "27.0.0-nightly.20230808", - "27.0.0-nightly.20230814", - "27.0.0-nightly.20230815" - ], - "118.0.5993.54": [ - "27.0.0" - ], - "118.0.5993.89": [ - "27.0.1", - "27.0.2" - ], - "118.0.5993.120": [ - "27.0.3" - ], - "118.0.5993.129": [ - "27.0.4" - ], - "118.0.5993.144": [ - "27.1.0", - "27.1.2" - ], - "118.0.5993.159": [ - "27.1.3", - "27.2.0", - "27.2.1", - "27.2.2", - "27.2.3", - "27.2.4", - "27.3.0", - "27.3.1", - "27.3.2", - "27.3.3", - "27.3.4", - "27.3.5", - "27.3.6", - "27.3.7", - "27.3.8", - "27.3.9", - "27.3.10", - "27.3.11" - ], - "119.0.6045.0": [ - "28.0.0-alpha.1", - "28.0.0-alpha.2", - "28.0.0-nightly.20231006", - "28.0.0-nightly.20231009", - "28.0.0-nightly.20231010", - "28.0.0-nightly.20231011", - "29.0.0-nightly.20231012", - "29.0.0-nightly.20231013", - "29.0.0-nightly.20231016", - "29.0.0-nightly.20231017", - "29.0.0-nightly.20231018", - "29.0.0-nightly.20231019", - "29.0.0-nightly.20231020", - "29.0.0-nightly.20231023", - "29.0.0-nightly.20231024" - ], - "119.0.6045.21": [ - "28.0.0-alpha.3", - "28.0.0-alpha.4" - ], - "119.0.6045.33": [ - "28.0.0-alpha.5", - "28.0.0-alpha.6", - "28.0.0-alpha.7", - "28.0.0-beta.1" - ], - "120.0.6099.0": [ - "28.0.0-beta.2" - ], - "120.0.6099.5": [ - "28.0.0-beta.3", - "28.0.0-beta.4" - ], - "120.0.6099.18": [ - "28.0.0-beta.5", - "28.0.0-beta.6", - "28.0.0-beta.7", - "28.0.0-beta.8", - "28.0.0-beta.9", - "28.0.0-beta.10" - ], - "120.0.6099.35": [ - "28.0.0-beta.11" - ], - "118.0.5991.0": [ - "28.0.0-nightly.20230906" - ], - "118.0.5993.0": [ - "28.0.0-nightly.20230907", - "28.0.0-nightly.20230908", - "28.0.0-nightly.20230911", - "28.0.0-nightly.20230912", - "28.0.0-nightly.20230913", - "28.0.0-nightly.20230914", - "28.0.0-nightly.20230915" - ], - "119.0.6006.0": [ - "28.0.0-nightly.20230919" - ], - "119.0.6017.0": [ - "28.0.0-nightly.20230920" - ], - "119.0.6019.2": [ - "28.0.0-nightly.20230921", - "28.0.0-nightly.20230925", - "28.0.0-nightly.20230926", - "28.0.0-nightly.20230927", - "28.0.0-nightly.20230928" - ], - "119.0.6029.0": [ - "28.0.0-nightly.20230929", - "28.0.0-nightly.20231002" - ], - "119.0.6043.0": [ - "28.0.0-nightly.20231003", - "28.0.0-nightly.20231004", - "28.0.0-nightly.20231005" - ], - "120.0.6099.56": [ - "28.0.0" - ], - "120.0.6099.109": [ - "28.1.0", - "28.1.1" - ], - "120.0.6099.199": [ - "28.1.2", - "28.1.3" - ], - "120.0.6099.216": [ - "28.1.4" - ], - "120.0.6099.227": [ - "28.2.0" - ], - "120.0.6099.268": [ - "28.2.1" - ], - "120.0.6099.276": [ - "28.2.2" - ], - "120.0.6099.283": [ - "28.2.3" - ], - "120.0.6099.291": [ - "28.2.4", - "28.2.5", - "28.2.6", - "28.2.7", - "28.2.8", - "28.2.9", - "28.2.10", - "28.3.0", - "28.3.1", - "28.3.2", - "28.3.3" - ], - "121.0.6147.0": [ - "29.0.0-alpha.1", - "29.0.0-alpha.2", - "29.0.0-alpha.3", - "29.0.0-nightly.20231129", - "29.0.0-nightly.20231130", - "29.0.0-nightly.20231201", - "29.0.0-nightly.20231204", - "29.0.0-nightly.20231205", - "29.0.0-nightly.20231206", - "30.0.0-nightly.20231207", - "30.0.0-nightly.20231208", - "30.0.0-nightly.20231211" - ], - "121.0.6159.0": [ - "29.0.0-alpha.4", - "29.0.0-alpha.5", - "29.0.0-alpha.6", - "29.0.0-alpha.7", - "30.0.0-nightly.20231212", - "30.0.0-nightly.20231213", - "30.0.0-nightly.20231214", - "30.0.0-nightly.20231215", - "30.0.0-nightly.20231218", - "30.0.0-nightly.20240102" - ], - "122.0.6194.0": [ - "29.0.0-alpha.8", - "30.0.0-nightly.20240103", - "30.0.0-nightly.20240104", - "30.0.0-nightly.20240105", - "30.0.0-nightly.20240108", - "30.0.0-nightly.20240109", - "30.0.0-nightly.20240110" - ], - "122.0.6236.2": [ - "29.0.0-alpha.9", - "29.0.0-alpha.10", - "29.0.0-alpha.11", - "29.0.0-beta.1", - "29.0.0-beta.2", - "30.0.0-nightly.20240111", - "30.0.0-nightly.20240112", - "30.0.0-nightly.20240115", - "30.0.0-nightly.20240116", - "30.0.0-nightly.20240117", - "30.0.0-nightly.20240118", - "30.0.0-nightly.20240119", - "30.0.0-nightly.20240122", - "30.0.0-nightly.20240123", - "30.0.0-nightly.20240124", - "30.0.0-nightly.20240125" - ], - "122.0.6261.6": [ - "29.0.0-beta.3", - "29.0.0-beta.4" - ], - "122.0.6261.18": [ - "29.0.0-beta.5", - "29.0.0-beta.6", - "29.0.0-beta.7", - "29.0.0-beta.8", - "29.0.0-beta.9", - "29.0.0-beta.10", - "29.0.0-beta.11" - ], - "122.0.6261.29": [ - "29.0.0-beta.12" - ], - "120.0.6078.0": [ - "29.0.0-nightly.20231025", - "29.0.0-nightly.20231026", - "29.0.0-nightly.20231027", - "29.0.0-nightly.20231030", - "29.0.0-nightly.20231031", - "29.0.0-nightly.20231101" - ], - "121.0.6100.0": [ - "29.0.0-nightly.20231102", - "29.0.0-nightly.20231103" - ], - "121.0.6104.0": [ - "29.0.0-nightly.20231106" - ], - "121.0.6110.0": [ - "29.0.0-nightly.20231107", - "29.0.0-nightly.20231108", - "29.0.0-nightly.20231109", - "29.0.0-nightly.20231110", - "29.0.0-nightly.20231113", - "29.0.0-nightly.20231114" - ], - "121.0.6116.0": [ - "29.0.0-nightly.20231115", - "29.0.0-nightly.20231116", - "29.0.0-nightly.20231117", - "29.0.0-nightly.20231120", - "29.0.0-nightly.20231121", - "29.0.0-nightly.20231122", - "29.0.0-nightly.20231123", - "29.0.0-nightly.20231124", - "29.0.0-nightly.20231127", - "29.0.0-nightly.20231128" - ], - "122.0.6261.39": [ - "29.0.0" - ], - "122.0.6261.57": [ - "29.0.1" - ], - "122.0.6261.70": [ - "29.1.0" - ], - "122.0.6261.111": [ - "29.1.1" - ], - "122.0.6261.112": [ - "29.1.2", - "29.1.3" - ], - "122.0.6261.129": [ - "29.1.4" - ], - "122.0.6261.130": [ - "29.1.5" - ], - "122.0.6261.139": [ - "29.1.6" - ], - "122.0.6261.156": [ - "29.2.0", - "29.3.0", - "29.3.1", - "29.3.2", - "29.3.3", - "29.4.0", - "29.4.1", - "29.4.2" - ], - "123.0.6296.0": [ - "30.0.0-alpha.1", - "30.0.0-nightly.20240215", - "30.0.0-nightly.20240216", - "30.0.0-nightly.20240219", - "30.0.0-nightly.20240220", - "30.0.0-nightly.20240221" - ], - "123.0.6312.5": [ - "30.0.0-alpha.2", - "31.0.0-nightly.20240222", - "31.0.0-nightly.20240223", - "31.0.0-nightly.20240226", - "31.0.0-nightly.20240227", - "31.0.0-nightly.20240228" - ], - "124.0.6323.0": [ - "30.0.0-alpha.3", - "30.0.0-alpha.4", - "31.0.0-nightly.20240229", - "31.0.0-nightly.20240301", - "31.0.0-nightly.20240304", - "31.0.0-nightly.20240305" - ], - "124.0.6331.0": [ - "30.0.0-alpha.5", - "30.0.0-alpha.6", - "31.0.0-nightly.20240306", - "31.0.0-nightly.20240307", - "31.0.0-nightly.20240308", - "31.0.0-nightly.20240311" - ], - "124.0.6353.0": [ - "30.0.0-alpha.7", - "31.0.0-nightly.20240313", - "31.0.0-nightly.20240314", - "31.0.0-nightly.20240315" - ], - "124.0.6359.0": [ - "30.0.0-beta.1", - "30.0.0-beta.2", - "31.0.0-nightly.20240318", - "31.0.0-nightly.20240319", - "31.0.0-nightly.20240320", - "31.0.0-nightly.20240321", - "31.0.0-nightly.20240325", - "31.0.0-nightly.20240327", - "31.0.0-nightly.20240328", - "31.0.0-nightly.20240329", - "31.0.0-nightly.20240401", - "31.0.0-nightly.20240402", - "31.0.0-nightly.20240404", - "31.0.0-nightly.20240405", - "31.0.0-nightly.20240408", - "31.0.0-nightly.20240409", - "31.0.0-nightly.20240410", - "31.0.0-nightly.20240411", - "31.0.0-nightly.20240412" - ], - "124.0.6367.9": [ - "30.0.0-beta.3", - "30.0.0-beta.4", - "30.0.0-beta.5" - ], - "124.0.6367.18": [ - "30.0.0-beta.6" - ], - "124.0.6367.29": [ - "30.0.0-beta.7", - "30.0.0-beta.8" - ], - "123.0.6264.0": [ - "30.0.0-nightly.20240126", - "30.0.0-nightly.20240129", - "30.0.0-nightly.20240130", - "30.0.0-nightly.20240131" - ], - "123.0.6272.0": [ - "30.0.0-nightly.20240201", - "30.0.0-nightly.20240202", - "30.0.0-nightly.20240205", - "30.0.0-nightly.20240206", - "30.0.0-nightly.20240207", - "30.0.0-nightly.20240208", - "30.0.0-nightly.20240209", - "30.0.0-nightly.20240212", - "30.0.0-nightly.20240213", - "30.0.0-nightly.20240214" - ], - "124.0.6367.49": [ - "30.0.0" - ], - "124.0.6367.60": [ - "30.0.1" - ], - "124.0.6367.91": [ - "30.0.2" - ], - "124.0.6367.119": [ - "30.0.3" - ], - "124.0.6367.201": [ - "30.0.4" - ], - "124.0.6367.207": [ - "30.0.5", - "30.0.6" - ], - "124.0.6367.221": [ - "30.0.7" - ], - "124.0.6367.230": [ - "30.0.8" - ], - "124.0.6367.233": [ - "30.0.9" - ], - "124.0.6367.243": [ - "30.1.0", - "30.1.1" - ], - "125.0.6412.0": [ - "31.0.0-alpha.1", - "31.0.0-alpha.2", - "31.0.0-alpha.3", - "31.0.0-alpha.4", - "31.0.0-alpha.5", - "32.0.0-nightly.20240418", - "32.0.0-nightly.20240419", - "32.0.0-nightly.20240422", - "32.0.0-nightly.20240423", - "32.0.0-nightly.20240424", - "32.0.0-nightly.20240425", - "32.0.0-nightly.20240426", - "32.0.0-nightly.20240429", - "32.0.0-nightly.20240430", - "32.0.0-nightly.20240501", - "32.0.0-nightly.20240503", - "32.0.0-nightly.20240506", - "32.0.0-nightly.20240507", - "32.0.0-nightly.20240508", - "32.0.0-nightly.20240509", - "32.0.0-nightly.20240510" - ], - "126.0.6445.0": [ - "31.0.0-beta.1", - "31.0.0-beta.2", - "31.0.0-beta.3", - "31.0.0-beta.4", - "31.0.0-beta.5", - "31.0.0-beta.6", - "31.0.0-beta.7", - "31.0.0-beta.8", - "31.0.0-beta.9", - "32.0.0-nightly.20240513", - "32.0.0-nightly.20240514", - "32.0.0-nightly.20240515", - "32.0.0-nightly.20240516", - "32.0.0-nightly.20240517", - "32.0.0-nightly.20240520", - "32.0.0-nightly.20240521", - "32.0.0-nightly.20240522", - "32.0.0-nightly.20240523", - "32.0.0-nightly.20240524", - "32.0.0-nightly.20240529", - "32.0.0-nightly.20240530", - "32.0.0-nightly.20240531", - "32.0.0-nightly.20240603", - "32.0.0-nightly.20240604", - "32.0.0-nightly.20240605", - "32.0.0-nightly.20240606", - "32.0.0-nightly.20240607" - ], - "126.0.6478.36": [ - "31.0.0-beta.10", - "31.0.0", - "31.0.1" - ], - "124.0.6351.0": [ - "31.0.0-nightly.20240312" - ], - "127.0.6521.0": [ - "32.0.0-alpha.1", - "32.0.0-alpha.2", - "32.0.0-nightly.20240610", - "32.0.0-nightly.20240611", - "33.0.0-nightly.20240612", - "33.0.0-nightly.20240614", - "33.0.0-nightly.20240617", - "33.0.0-nightly.20240618" - ] -}; \ No newline at end of file diff --git a/tools/eslint/node_modules/electron-to-chromium/full-chromium-versions.json b/tools/eslint/node_modules/electron-to-chromium/full-chromium-versions.json deleted file mode 100644 index 05c7524c1e4d0e..00000000000000 --- a/tools/eslint/node_modules/electron-to-chromium/full-chromium-versions.json +++ /dev/null @@ -1 +0,0 @@ -{"39.0.2171.65":["0.20.0","0.20.1","0.20.2","0.20.3","0.20.4","0.20.5","0.20.6","0.20.7","0.20.8"],"40.0.2214.91":["0.21.0","0.21.1","0.21.2"],"41.0.2272.76":["0.21.3","0.22.1","0.22.2","0.22.3","0.23.0","0.24.0"],"42.0.2311.107":["0.25.0","0.25.1","0.25.2","0.25.3","0.26.0","0.26.1","0.27.0","0.27.1"],"43.0.2357.65":["0.27.2","0.27.3","0.28.0","0.28.1","0.28.2","0.28.3","0.29.1","0.29.2"],"44.0.2403.125":["0.30.4","0.31.0"],"45.0.2454.85":["0.31.2","0.32.2","0.32.3","0.33.0","0.33.1","0.33.2","0.33.3","0.33.4","0.33.6","0.33.7","0.33.8","0.33.9","0.34.0","0.34.1","0.34.2","0.34.3","0.34.4","0.35.1","0.35.2","0.35.3","0.35.4","0.35.5"],"47.0.2526.73":["0.36.0","0.36.2","0.36.3","0.36.4"],"47.0.2526.110":["0.36.5","0.36.6","0.36.7","0.36.8","0.36.9","0.36.10","0.36.11","0.36.12"],"49.0.2623.75":["0.37.0","0.37.1","0.37.3","0.37.4","0.37.5","0.37.6","0.37.7","0.37.8","1.0.0","1.0.1","1.0.2"],"50.0.2661.102":["1.1.0","1.1.1","1.1.2","1.1.3"],"51.0.2704.63":["1.2.0","1.2.1"],"51.0.2704.84":["1.2.2","1.2.3"],"51.0.2704.103":["1.2.4","1.2.5"],"51.0.2704.106":["1.2.6","1.2.7","1.2.8"],"52.0.2743.82":["1.3.0","1.3.1","1.3.2","1.3.3","1.3.4","1.3.5","1.3.6","1.3.7","1.3.9","1.3.10","1.3.13","1.3.14","1.3.15"],"53.0.2785.113":["1.4.0","1.4.1","1.4.2","1.4.3","1.4.4","1.4.5"],"53.0.2785.143":["1.4.6","1.4.7","1.4.8","1.4.10","1.4.11","1.4.13","1.4.14","1.4.15","1.4.16"],"54.0.2840.51":["1.4.12"],"54.0.2840.101":["1.5.0","1.5.1"],"56.0.2924.87":["1.6.0","1.6.1","1.6.2","1.6.3","1.6.4","1.6.5","1.6.6","1.6.7","1.6.8","1.6.9","1.6.10","1.6.11","1.6.12","1.6.13","1.6.14","1.6.15","1.6.16","1.6.17","1.6.18"],"58.0.3029.110":["1.7.0","1.7.1","1.7.2","1.7.3","1.7.4","1.7.5","1.7.6","1.7.7","1.7.8","1.7.9","1.7.10","1.7.11","1.7.12","1.7.13","1.7.14","1.7.15","1.7.16"],"59.0.3071.115":["1.8.0","1.8.1","1.8.2-beta.1","1.8.2-beta.2","1.8.2-beta.3","1.8.2-beta.4","1.8.2-beta.5","1.8.2","1.8.3","1.8.4","1.8.5","1.8.6","1.8.7","1.8.8"],"61.0.3163.100":["2.0.0-beta.1","2.0.0-beta.2","2.0.0-beta.3","2.0.0-beta.4","2.0.0-beta.5","2.0.0-beta.6","2.0.0-beta.7","2.0.0-beta.8","2.0.0","2.0.1","2.0.2","2.0.3","2.0.4","2.0.5","2.0.6","2.0.7","2.0.8-nightly.20180819","2.0.8-nightly.20180820","2.0.8","2.0.9","2.0.10","2.0.11","2.0.12","2.0.13","2.0.14","2.0.15","2.0.16","2.0.17","2.0.18","2.1.0-unsupported.20180809"],"66.0.3359.181":["3.0.0-beta.1","3.0.0-beta.2","3.0.0-beta.3","3.0.0-beta.4","3.0.0-beta.5","3.0.0-beta.6","3.0.0-beta.7","3.0.0-beta.8","3.0.0-beta.9","3.0.0-beta.10","3.0.0-beta.11","3.0.0-beta.12","3.0.0-beta.13","3.0.0-nightly.20180818","3.0.0-nightly.20180821","3.0.0-nightly.20180823","3.0.0-nightly.20180904","3.0.0","3.0.1","3.0.2","3.0.3","3.0.4","3.0.5","3.0.6","3.0.7","3.0.8","3.0.9","3.0.10","3.0.11","3.0.12","3.0.13","3.0.14","3.0.15","3.0.16","3.1.0-beta.1","3.1.0-beta.2","3.1.0-beta.3","3.1.0-beta.4","3.1.0-beta.5","3.1.0","3.1.1","3.1.2","3.1.3","3.1.4","3.1.5","3.1.6","3.1.7","3.1.8","3.1.9","3.1.10","3.1.11","3.1.12","3.1.13","4.0.0-nightly.20180817","4.0.0-nightly.20180819","4.0.0-nightly.20180821"],"69.0.3497.106":["4.0.0-beta.1","4.0.0-beta.2","4.0.0-beta.3","4.0.0-beta.4","4.0.0-beta.5","4.0.0-beta.6","4.0.0-beta.7","4.0.0-beta.8","4.0.0-beta.9","4.0.0-beta.10","4.0.0-beta.11","4.0.0-nightly.20181010","4.0.0","4.0.1","4.0.2","4.0.3","4.0.4","4.0.5","4.0.6"],"67.0.3396.99":["4.0.0-nightly.20180929"],"68.0.3440.128":["4.0.0-nightly.20181006"],"69.0.3497.128":["4.0.7","4.0.8","4.1.0","4.1.1","4.1.2","4.1.3","4.1.4","4.1.5","4.2.0","4.2.1","4.2.2","4.2.3","4.2.4","4.2.5","4.2.6","4.2.7","4.2.8","4.2.9","4.2.10","4.2.11","4.2.12"],"72.0.3626.52":["5.0.0-beta.1","5.0.0-beta.2","6.0.0-nightly.20190123"],"73.0.3683.27":["5.0.0-beta.3"],"73.0.3683.54":["5.0.0-beta.4"],"73.0.3683.61":["5.0.0-beta.5"],"73.0.3683.84":["5.0.0-beta.6"],"73.0.3683.94":["5.0.0-beta.7"],"73.0.3683.104":["5.0.0-beta.8"],"73.0.3683.117":["5.0.0-beta.9"],"70.0.3538.110":["5.0.0-nightly.20190107"],"71.0.3578.98":["5.0.0-nightly.20190121","5.0.0-nightly.20190122"],"73.0.3683.119":["5.0.0"],"73.0.3683.121":["5.0.1","5.0.2","5.0.3","5.0.4","5.0.5","5.0.6","5.0.7","5.0.8","5.0.9","5.0.10","5.0.11","5.0.12","5.0.13"],"76.0.3774.1":["6.0.0-beta.1"],"76.0.3783.1":["6.0.0-beta.2","6.0.0-beta.3","6.0.0-beta.4"],"76.0.3805.4":["6.0.0-beta.5"],"76.0.3809.3":["6.0.0-beta.6"],"76.0.3809.22":["6.0.0-beta.7"],"76.0.3809.26":["6.0.0-beta.8","6.0.0-beta.9"],"76.0.3809.37":["6.0.0-beta.10"],"76.0.3809.42":["6.0.0-beta.11"],"76.0.3809.54":["6.0.0-beta.12"],"76.0.3809.60":["6.0.0-beta.13"],"76.0.3809.68":["6.0.0-beta.14"],"76.0.3809.74":["6.0.0-beta.15"],"72.0.3626.107":["6.0.0-nightly.20190212"],"72.0.3626.110":["6.0.0-nightly.20190213"],"74.0.3724.8":["6.0.0-nightly.20190311"],"76.0.3809.88":["6.0.0"],"76.0.3809.102":["6.0.1"],"76.0.3809.110":["6.0.2"],"76.0.3809.126":["6.0.3"],"76.0.3809.131":["6.0.4"],"76.0.3809.136":["6.0.5"],"76.0.3809.138":["6.0.6"],"76.0.3809.139":["6.0.7"],"76.0.3809.146":["6.0.8","6.0.9","6.0.10","6.0.11","6.0.12","6.1.0","6.1.1","6.1.2","6.1.3","6.1.4","6.1.5","6.1.6","6.1.7","6.1.8","6.1.9","6.1.10","6.1.11","6.1.12"],"78.0.3866.0":["7.0.0-beta.1","7.0.0-beta.2","7.0.0-beta.3","7.0.0-nightly.20190727","7.0.0-nightly.20190728","7.0.0-nightly.20190729","7.0.0-nightly.20190730","7.0.0-nightly.20190731","8.0.0-nightly.20190801","8.0.0-nightly.20190802"],"78.0.3896.6":["7.0.0-beta.4"],"78.0.3905.1":["7.0.0-beta.5","7.0.0-beta.6","7.0.0-beta.7","7.0.0"],"76.0.3784.0":["7.0.0-nightly.20190521"],"76.0.3806.0":["7.0.0-nightly.20190529","7.0.0-nightly.20190530","7.0.0-nightly.20190531","7.0.0-nightly.20190602","7.0.0-nightly.20190603"],"77.0.3814.0":["7.0.0-nightly.20190604"],"77.0.3815.0":["7.0.0-nightly.20190605","7.0.0-nightly.20190606","7.0.0-nightly.20190607","7.0.0-nightly.20190608","7.0.0-nightly.20190609","7.0.0-nightly.20190611","7.0.0-nightly.20190612","7.0.0-nightly.20190613","7.0.0-nightly.20190615","7.0.0-nightly.20190616","7.0.0-nightly.20190618","7.0.0-nightly.20190619","7.0.0-nightly.20190622","7.0.0-nightly.20190623","7.0.0-nightly.20190624","7.0.0-nightly.20190627","7.0.0-nightly.20190629","7.0.0-nightly.20190630","7.0.0-nightly.20190701","7.0.0-nightly.20190702"],"77.0.3843.0":["7.0.0-nightly.20190704","7.0.0-nightly.20190705"],"77.0.3848.0":["7.0.0-nightly.20190719","7.0.0-nightly.20190720","7.0.0-nightly.20190721"],"77.0.3864.0":["7.0.0-nightly.20190726"],"78.0.3904.92":["7.0.1"],"78.0.3904.94":["7.1.0"],"78.0.3904.99":["7.1.1"],"78.0.3904.113":["7.1.2"],"78.0.3904.126":["7.1.3"],"78.0.3904.130":["7.1.4","7.1.5","7.1.6","7.1.7","7.1.8","7.1.9","7.1.10","7.1.11","7.1.12","7.1.13","7.1.14","7.2.0","7.2.1","7.2.2","7.2.3","7.2.4","7.3.0","7.3.1","7.3.2","7.3.3"],"79.0.3931.0":["8.0.0-beta.1","8.0.0-beta.2","8.0.0-nightly.20191019","8.0.0-nightly.20191020","8.0.0-nightly.20191021","8.0.0-nightly.20191023"],"80.0.3955.0":["8.0.0-beta.3","8.0.0-beta.4"],"80.0.3987.14":["8.0.0-beta.5"],"80.0.3987.51":["8.0.0-beta.6"],"80.0.3987.59":["8.0.0-beta.7"],"80.0.3987.75":["8.0.0-beta.8","8.0.0-beta.9"],"78.0.3871.0":["8.0.0-nightly.20190803","8.0.0-nightly.20190806","8.0.0-nightly.20190807","8.0.0-nightly.20190808","8.0.0-nightly.20190809","8.0.0-nightly.20190810","8.0.0-nightly.20190811","8.0.0-nightly.20190812","8.0.0-nightly.20190813","8.0.0-nightly.20190814","8.0.0-nightly.20190815"],"78.0.3881.0":["8.0.0-nightly.20190816","8.0.0-nightly.20190817","8.0.0-nightly.20190818","8.0.0-nightly.20190819","8.0.0-nightly.20190820"],"78.0.3892.0":["8.0.0-nightly.20190824","8.0.0-nightly.20190825","8.0.0-nightly.20190827","8.0.0-nightly.20190828","8.0.0-nightly.20190830","8.0.0-nightly.20190901","8.0.0-nightly.20190902","8.0.0-nightly.20190907","8.0.0-nightly.20190909","8.0.0-nightly.20190910","8.0.0-nightly.20190911","8.0.0-nightly.20190912","8.0.0-nightly.20190913","8.0.0-nightly.20190914","8.0.0-nightly.20190915","8.0.0-nightly.20190917"],"79.0.3915.0":["8.0.0-nightly.20190919","8.0.0-nightly.20190920"],"79.0.3919.0":["8.0.0-nightly.20190922","8.0.0-nightly.20190923","8.0.0-nightly.20190924","8.0.0-nightly.20190926","8.0.0-nightly.20190928","8.0.0-nightly.20190929","8.0.0-nightly.20190930","8.0.0-nightly.20191001","8.0.0-nightly.20191004","8.0.0-nightly.20191005","8.0.0-nightly.20191006","8.0.0-nightly.20191009","8.0.0-nightly.20191011","8.0.0-nightly.20191012","8.0.0-nightly.20191017"],"80.0.3952.0":["8.0.0-nightly.20191101","8.0.0-nightly.20191103","8.0.0-nightly.20191105"],"80.0.3987.86":["8.0.0","8.0.1","8.0.2"],"80.0.3987.134":["8.0.3"],"80.0.3987.137":["8.1.0"],"80.0.3987.141":["8.1.1"],"80.0.3987.158":["8.2.0"],"80.0.3987.163":["8.2.1","8.2.2","8.2.3","8.5.3","8.5.4","8.5.5"],"80.0.3987.165":["8.2.4","8.2.5","8.3.0","8.3.1","8.3.2","8.3.3","8.3.4","8.4.0","8.4.1","8.5.0","8.5.1","8.5.2"],"82.0.4048.0":["9.0.0-beta.1","9.0.0-beta.2","9.0.0-beta.3","9.0.0-beta.4","9.0.0-beta.5"],"82.0.4058.2":["9.0.0-beta.6","9.0.0-beta.7","9.0.0-beta.9"],"82.0.4085.10":["9.0.0-beta.10"],"82.0.4085.14":["9.0.0-beta.11","9.0.0-beta.12","9.0.0-beta.13"],"82.0.4085.27":["9.0.0-beta.14"],"83.0.4102.3":["9.0.0-beta.15","9.0.0-beta.16"],"83.0.4103.14":["9.0.0-beta.17"],"83.0.4103.16":["9.0.0-beta.18"],"83.0.4103.24":["9.0.0-beta.19"],"83.0.4103.26":["9.0.0-beta.20","9.0.0-beta.21"],"83.0.4103.34":["9.0.0-beta.22"],"83.0.4103.44":["9.0.0-beta.23"],"83.0.4103.45":["9.0.0-beta.24"],"80.0.3954.0":["9.0.0-nightly.20191121","9.0.0-nightly.20191122","9.0.0-nightly.20191123","9.0.0-nightly.20191124","9.0.0-nightly.20191126","9.0.0-nightly.20191128","9.0.0-nightly.20191129","9.0.0-nightly.20191130","9.0.0-nightly.20191201","9.0.0-nightly.20191202","9.0.0-nightly.20191203","9.0.0-nightly.20191204","9.0.0-nightly.20191205","9.0.0-nightly.20191210"],"81.0.3994.0":["9.0.0-nightly.20191220","9.0.0-nightly.20191221","9.0.0-nightly.20191222","9.0.0-nightly.20191223","9.0.0-nightly.20191224","9.0.0-nightly.20191225","9.0.0-nightly.20191226","9.0.0-nightly.20191228","9.0.0-nightly.20191229","9.0.0-nightly.20191230","9.0.0-nightly.20191231","9.0.0-nightly.20200101","9.0.0-nightly.20200103","9.0.0-nightly.20200104","9.0.0-nightly.20200105","9.0.0-nightly.20200106","9.0.0-nightly.20200108","9.0.0-nightly.20200109","9.0.0-nightly.20200110","9.0.0-nightly.20200111","9.0.0-nightly.20200113","9.0.0-nightly.20200115","9.0.0-nightly.20200116","9.0.0-nightly.20200117"],"81.0.4030.0":["9.0.0-nightly.20200119","9.0.0-nightly.20200121"],"83.0.4103.64":["9.0.0"],"83.0.4103.94":["9.0.1","9.0.2"],"83.0.4103.100":["9.0.3"],"83.0.4103.104":["9.0.4"],"83.0.4103.119":["9.0.5"],"83.0.4103.122":["9.1.0","9.1.1","9.1.2","9.2.0","9.2.1","9.3.0","9.3.1","9.3.2","9.3.3","9.3.4","9.3.5","9.4.0","9.4.1","9.4.2","9.4.3","9.4.4"],"84.0.4129.0":["10.0.0-beta.1","10.0.0-beta.2","10.0.0-nightly.20200501","10.0.0-nightly.20200504","10.0.0-nightly.20200505","10.0.0-nightly.20200506","10.0.0-nightly.20200507","10.0.0-nightly.20200508","10.0.0-nightly.20200511","10.0.0-nightly.20200512","10.0.0-nightly.20200513","10.0.0-nightly.20200514","10.0.0-nightly.20200515","10.0.0-nightly.20200518","10.0.0-nightly.20200519","10.0.0-nightly.20200520","10.0.0-nightly.20200521","11.0.0-nightly.20200525","11.0.0-nightly.20200526"],"85.0.4161.2":["10.0.0-beta.3","10.0.0-beta.4"],"85.0.4181.1":["10.0.0-beta.8","10.0.0-beta.9"],"85.0.4183.19":["10.0.0-beta.10"],"85.0.4183.20":["10.0.0-beta.11"],"85.0.4183.26":["10.0.0-beta.12"],"85.0.4183.39":["10.0.0-beta.13","10.0.0-beta.14","10.0.0-beta.15","10.0.0-beta.17","10.0.0-beta.19","10.0.0-beta.20","10.0.0-beta.21"],"85.0.4183.70":["10.0.0-beta.23"],"85.0.4183.78":["10.0.0-beta.24"],"85.0.4183.80":["10.0.0-beta.25"],"82.0.4050.0":["10.0.0-nightly.20200209","10.0.0-nightly.20200210","10.0.0-nightly.20200211","10.0.0-nightly.20200216","10.0.0-nightly.20200217","10.0.0-nightly.20200218","10.0.0-nightly.20200221","10.0.0-nightly.20200222","10.0.0-nightly.20200223","10.0.0-nightly.20200226","10.0.0-nightly.20200303"],"82.0.4076.0":["10.0.0-nightly.20200304","10.0.0-nightly.20200305","10.0.0-nightly.20200306","10.0.0-nightly.20200309","10.0.0-nightly.20200310"],"82.0.4083.0":["10.0.0-nightly.20200311"],"83.0.4086.0":["10.0.0-nightly.20200316"],"83.0.4087.0":["10.0.0-nightly.20200317","10.0.0-nightly.20200318","10.0.0-nightly.20200320","10.0.0-nightly.20200323","10.0.0-nightly.20200324","10.0.0-nightly.20200325","10.0.0-nightly.20200326","10.0.0-nightly.20200327","10.0.0-nightly.20200330","10.0.0-nightly.20200331","10.0.0-nightly.20200401","10.0.0-nightly.20200402","10.0.0-nightly.20200403","10.0.0-nightly.20200406"],"83.0.4095.0":["10.0.0-nightly.20200408","10.0.0-nightly.20200410","10.0.0-nightly.20200413"],"84.0.4114.0":["10.0.0-nightly.20200414"],"84.0.4115.0":["10.0.0-nightly.20200415","10.0.0-nightly.20200416","10.0.0-nightly.20200417"],"84.0.4121.0":["10.0.0-nightly.20200422","10.0.0-nightly.20200423"],"84.0.4125.0":["10.0.0-nightly.20200427","10.0.0-nightly.20200428","10.0.0-nightly.20200429","10.0.0-nightly.20200430"],"85.0.4183.84":["10.0.0"],"85.0.4183.86":["10.0.1"],"85.0.4183.87":["10.1.0"],"85.0.4183.93":["10.1.1"],"85.0.4183.98":["10.1.2"],"85.0.4183.121":["10.1.3","10.1.4","10.1.5","10.1.6","10.1.7","10.2.0","10.3.0","10.3.1","10.3.2","10.4.0","10.4.1","10.4.2","10.4.3","10.4.4","10.4.5","10.4.6","10.4.7"],"86.0.4234.0":["11.0.0-beta.1","11.0.0-beta.3","11.0.0-beta.4","11.0.0-beta.5","11.0.0-beta.6","11.0.0-beta.7","11.0.0-nightly.20200822","11.0.0-nightly.20200824","11.0.0-nightly.20200825","11.0.0-nightly.20200826","12.0.0-nightly.20200827","12.0.0-nightly.20200831","12.0.0-nightly.20200902","12.0.0-nightly.20200903","12.0.0-nightly.20200907","12.0.0-nightly.20200910","12.0.0-nightly.20200911","12.0.0-nightly.20200914"],"87.0.4251.1":["11.0.0-beta.8","11.0.0-beta.9","11.0.0-beta.11"],"87.0.4280.11":["11.0.0-beta.12","11.0.0-beta.13"],"87.0.4280.27":["11.0.0-beta.16","11.0.0-beta.17","11.0.0-beta.18","11.0.0-beta.19"],"87.0.4280.40":["11.0.0-beta.20"],"87.0.4280.47":["11.0.0-beta.22","11.0.0-beta.23"],"85.0.4156.0":["11.0.0-nightly.20200529"],"85.0.4162.0":["11.0.0-nightly.20200602","11.0.0-nightly.20200603","11.0.0-nightly.20200604","11.0.0-nightly.20200609","11.0.0-nightly.20200610","11.0.0-nightly.20200611","11.0.0-nightly.20200615","11.0.0-nightly.20200616","11.0.0-nightly.20200617","11.0.0-nightly.20200618","11.0.0-nightly.20200619"],"85.0.4179.0":["11.0.0-nightly.20200701","11.0.0-nightly.20200702","11.0.0-nightly.20200703","11.0.0-nightly.20200706","11.0.0-nightly.20200707","11.0.0-nightly.20200708","11.0.0-nightly.20200709"],"86.0.4203.0":["11.0.0-nightly.20200716","11.0.0-nightly.20200717","11.0.0-nightly.20200720","11.0.0-nightly.20200721"],"86.0.4209.0":["11.0.0-nightly.20200723","11.0.0-nightly.20200724","11.0.0-nightly.20200729","11.0.0-nightly.20200730","11.0.0-nightly.20200731","11.0.0-nightly.20200803","11.0.0-nightly.20200804","11.0.0-nightly.20200805","11.0.0-nightly.20200811","11.0.0-nightly.20200812"],"87.0.4280.60":["11.0.0","11.0.1"],"87.0.4280.67":["11.0.2","11.0.3","11.0.4"],"87.0.4280.88":["11.0.5","11.1.0","11.1.1"],"87.0.4280.141":["11.2.0","11.2.1","11.2.2","11.2.3","11.3.0","11.4.0","11.4.1","11.4.2","11.4.3","11.4.4","11.4.5","11.4.6","11.4.7","11.4.8","11.4.9","11.4.10","11.4.11","11.4.12","11.5.0"],"89.0.4328.0":["12.0.0-beta.1","12.0.0-beta.3","12.0.0-beta.4","12.0.0-beta.5","12.0.0-beta.6","12.0.0-beta.7","12.0.0-beta.8","12.0.0-beta.9","12.0.0-beta.10","12.0.0-beta.11","12.0.0-beta.12","12.0.0-beta.14","13.0.0-nightly.20201119","13.0.0-nightly.20201123","13.0.0-nightly.20201124","13.0.0-nightly.20201126","13.0.0-nightly.20201127","13.0.0-nightly.20201130","13.0.0-nightly.20201201","13.0.0-nightly.20201202","13.0.0-nightly.20201203","13.0.0-nightly.20201204","13.0.0-nightly.20201207","13.0.0-nightly.20201208","13.0.0-nightly.20201209","13.0.0-nightly.20201210","13.0.0-nightly.20201211","13.0.0-nightly.20201214"],"89.0.4348.1":["12.0.0-beta.16","12.0.0-beta.18","12.0.0-beta.19","12.0.0-beta.20"],"89.0.4388.2":["12.0.0-beta.21","12.0.0-beta.22","12.0.0-beta.23","12.0.0-beta.24","12.0.0-beta.25","12.0.0-beta.26"],"89.0.4389.23":["12.0.0-beta.27","12.0.0-beta.28","12.0.0-beta.29"],"89.0.4389.58":["12.0.0-beta.30","12.0.0-beta.31"],"87.0.4268.0":["12.0.0-nightly.20201002","12.0.0-nightly.20201007","12.0.0-nightly.20201009","12.0.0-nightly.20201012","12.0.0-nightly.20201013","12.0.0-nightly.20201014","12.0.0-nightly.20201015"],"88.0.4292.0":["12.0.0-nightly.20201023","12.0.0-nightly.20201026"],"88.0.4306.0":["12.0.0-nightly.20201030","12.0.0-nightly.20201102","12.0.0-nightly.20201103","12.0.0-nightly.20201104","12.0.0-nightly.20201105","12.0.0-nightly.20201106","12.0.0-nightly.20201111","12.0.0-nightly.20201112"],"88.0.4324.0":["12.0.0-nightly.20201116"],"89.0.4389.69":["12.0.0"],"89.0.4389.82":["12.0.1"],"89.0.4389.90":["12.0.2"],"89.0.4389.114":["12.0.3","12.0.4"],"89.0.4389.128":["12.0.5","12.0.6","12.0.7","12.0.8","12.0.9","12.0.10","12.0.11","12.0.12","12.0.13","12.0.14","12.0.15","12.0.16","12.0.17","12.0.18","12.1.0","12.1.1","12.1.2","12.2.0","12.2.1","12.2.2","12.2.3"],"90.0.4402.0":["13.0.0-beta.2","13.0.0-beta.3","13.0.0-nightly.20210210","13.0.0-nightly.20210211","13.0.0-nightly.20210212","13.0.0-nightly.20210216","13.0.0-nightly.20210217","13.0.0-nightly.20210218","13.0.0-nightly.20210219","13.0.0-nightly.20210222","13.0.0-nightly.20210225","13.0.0-nightly.20210226","13.0.0-nightly.20210301","13.0.0-nightly.20210302","13.0.0-nightly.20210303","14.0.0-nightly.20210304"],"90.0.4415.0":["13.0.0-beta.4","13.0.0-beta.5","13.0.0-beta.6","13.0.0-beta.7","13.0.0-beta.8","13.0.0-beta.9","13.0.0-beta.10","13.0.0-beta.11","13.0.0-beta.12","13.0.0-beta.13","14.0.0-nightly.20210305","14.0.0-nightly.20210308","14.0.0-nightly.20210309","14.0.0-nightly.20210311","14.0.0-nightly.20210315","14.0.0-nightly.20210316","14.0.0-nightly.20210317","14.0.0-nightly.20210318","14.0.0-nightly.20210319","14.0.0-nightly.20210323","14.0.0-nightly.20210324","14.0.0-nightly.20210325","14.0.0-nightly.20210326","14.0.0-nightly.20210329","14.0.0-nightly.20210330"],"91.0.4448.0":["13.0.0-beta.14","13.0.0-beta.16","13.0.0-beta.17","13.0.0-beta.18","13.0.0-beta.20","14.0.0-nightly.20210331","14.0.0-nightly.20210401","14.0.0-nightly.20210402","14.0.0-nightly.20210406","14.0.0-nightly.20210407","14.0.0-nightly.20210408","14.0.0-nightly.20210409","14.0.0-nightly.20210413"],"91.0.4472.33":["13.0.0-beta.21","13.0.0-beta.22","13.0.0-beta.23"],"91.0.4472.38":["13.0.0-beta.24","13.0.0-beta.25","13.0.0-beta.26","13.0.0-beta.27","13.0.0-beta.28"],"89.0.4349.0":["13.0.0-nightly.20201215","13.0.0-nightly.20201216","13.0.0-nightly.20201221","13.0.0-nightly.20201222"],"89.0.4359.0":["13.0.0-nightly.20201223","13.0.0-nightly.20210104","13.0.0-nightly.20210108","13.0.0-nightly.20210111"],"89.0.4386.0":["13.0.0-nightly.20210113","13.0.0-nightly.20210114","13.0.0-nightly.20210118","13.0.0-nightly.20210122","13.0.0-nightly.20210125"],"89.0.4389.0":["13.0.0-nightly.20210127","13.0.0-nightly.20210128","13.0.0-nightly.20210129","13.0.0-nightly.20210201","13.0.0-nightly.20210202","13.0.0-nightly.20210203","13.0.0-nightly.20210205","13.0.0-nightly.20210208","13.0.0-nightly.20210209"],"91.0.4472.69":["13.0.0","13.0.1"],"91.0.4472.77":["13.1.0","13.1.1","13.1.2"],"91.0.4472.106":["13.1.3","13.1.4"],"91.0.4472.124":["13.1.5","13.1.6","13.1.7"],"91.0.4472.164":["13.1.8","13.1.9","13.2.0","13.2.1","13.2.2","13.2.3","13.3.0","13.4.0","13.5.0","13.5.1","13.5.2","13.6.0","13.6.1","13.6.2","13.6.3","13.6.6","13.6.7","13.6.8","13.6.9"],"92.0.4511.0":["14.0.0-beta.1","14.0.0-beta.2","14.0.0-beta.3","14.0.0-nightly.20210520","14.0.0-nightly.20210523","14.0.0-nightly.20210524","15.0.0-nightly.20210527","15.0.0-nightly.20210528","15.0.0-nightly.20210531","15.0.0-nightly.20210601","15.0.0-nightly.20210602"],"93.0.4536.0":["14.0.0-beta.5","14.0.0-beta.6","14.0.0-beta.7","14.0.0-beta.8","15.0.0-nightly.20210609","15.0.0-nightly.20210610","15.0.0-nightly.20210611","15.0.0-nightly.20210614","15.0.0-nightly.20210615","15.0.0-nightly.20210616"],"93.0.4539.0":["14.0.0-beta.9","14.0.0-beta.10","15.0.0-nightly.20210617","15.0.0-nightly.20210618","15.0.0-nightly.20210621","15.0.0-nightly.20210622"],"93.0.4557.4":["14.0.0-beta.11","14.0.0-beta.12"],"93.0.4566.0":["14.0.0-beta.13","14.0.0-beta.14","14.0.0-beta.15","14.0.0-beta.16","14.0.0-beta.17","15.0.0-alpha.1","15.0.0-alpha.2","15.0.0-nightly.20210706","15.0.0-nightly.20210707","15.0.0-nightly.20210708","15.0.0-nightly.20210709","15.0.0-nightly.20210712","15.0.0-nightly.20210713","15.0.0-nightly.20210714","15.0.0-nightly.20210715","15.0.0-nightly.20210716","15.0.0-nightly.20210719","15.0.0-nightly.20210720","15.0.0-nightly.20210721","16.0.0-nightly.20210722","16.0.0-nightly.20210723","16.0.0-nightly.20210726"],"93.0.4577.15":["14.0.0-beta.18","14.0.0-beta.19","14.0.0-beta.20","14.0.0-beta.21"],"93.0.4577.25":["14.0.0-beta.22","14.0.0-beta.23"],"93.0.4577.51":["14.0.0-beta.24","14.0.0-beta.25"],"92.0.4475.0":["14.0.0-nightly.20210426","14.0.0-nightly.20210427"],"92.0.4488.0":["14.0.0-nightly.20210430","14.0.0-nightly.20210503"],"92.0.4496.0":["14.0.0-nightly.20210505"],"92.0.4498.0":["14.0.0-nightly.20210506"],"92.0.4499.0":["14.0.0-nightly.20210507","14.0.0-nightly.20210510","14.0.0-nightly.20210511","14.0.0-nightly.20210512","14.0.0-nightly.20210513"],"92.0.4505.0":["14.0.0-nightly.20210514","14.0.0-nightly.20210517","14.0.0-nightly.20210518","14.0.0-nightly.20210519"],"93.0.4577.58":["14.0.0"],"93.0.4577.63":["14.0.1"],"93.0.4577.82":["14.0.2","14.1.0","14.1.1","14.2.0","14.2.1","14.2.2","14.2.3","14.2.4","14.2.5","14.2.6","14.2.7","14.2.8","14.2.9"],"94.0.4584.0":["15.0.0-alpha.3","15.0.0-alpha.4","15.0.0-alpha.5","15.0.0-alpha.6","16.0.0-nightly.20210727","16.0.0-nightly.20210728","16.0.0-nightly.20210729","16.0.0-nightly.20210730","16.0.0-nightly.20210802","16.0.0-nightly.20210803","16.0.0-nightly.20210804","16.0.0-nightly.20210805","16.0.0-nightly.20210806","16.0.0-nightly.20210809","16.0.0-nightly.20210810","16.0.0-nightly.20210811"],"94.0.4590.2":["15.0.0-alpha.7","15.0.0-alpha.8","15.0.0-alpha.9","16.0.0-nightly.20210812","16.0.0-nightly.20210813","16.0.0-nightly.20210816","16.0.0-nightly.20210817","16.0.0-nightly.20210818","16.0.0-nightly.20210819","16.0.0-nightly.20210820","16.0.0-nightly.20210823"],"94.0.4606.12":["15.0.0-alpha.10"],"94.0.4606.20":["15.0.0-beta.1","15.0.0-beta.2"],"94.0.4606.31":["15.0.0-beta.3","15.0.0-beta.4","15.0.0-beta.5","15.0.0-beta.6","15.0.0-beta.7"],"93.0.4530.0":["15.0.0-nightly.20210603","15.0.0-nightly.20210604"],"93.0.4535.0":["15.0.0-nightly.20210608"],"93.0.4550.0":["15.0.0-nightly.20210623","15.0.0-nightly.20210624"],"93.0.4552.0":["15.0.0-nightly.20210625","15.0.0-nightly.20210628","15.0.0-nightly.20210629"],"93.0.4558.0":["15.0.0-nightly.20210630","15.0.0-nightly.20210701","15.0.0-nightly.20210702","15.0.0-nightly.20210705"],"94.0.4606.51":["15.0.0"],"94.0.4606.61":["15.1.0","15.1.1"],"94.0.4606.71":["15.1.2"],"94.0.4606.81":["15.2.0","15.3.0","15.3.1","15.3.2","15.3.3","15.3.4","15.3.5","15.3.6","15.3.7","15.4.0","15.4.1","15.4.2","15.5.0","15.5.1","15.5.2","15.5.3","15.5.4","15.5.5","15.5.6","15.5.7"],"95.0.4629.0":["16.0.0-alpha.1","16.0.0-alpha.2","16.0.0-alpha.3","16.0.0-alpha.4","16.0.0-alpha.5","16.0.0-alpha.6","16.0.0-alpha.7","16.0.0-nightly.20210902","16.0.0-nightly.20210903","16.0.0-nightly.20210906","16.0.0-nightly.20210907","16.0.0-nightly.20210908","16.0.0-nightly.20210909","16.0.0-nightly.20210910","16.0.0-nightly.20210913","16.0.0-nightly.20210914","16.0.0-nightly.20210915","16.0.0-nightly.20210916","16.0.0-nightly.20210917","16.0.0-nightly.20210920","16.0.0-nightly.20210921","16.0.0-nightly.20210922","17.0.0-nightly.20210923","17.0.0-nightly.20210924","17.0.0-nightly.20210927","17.0.0-nightly.20210928","17.0.0-nightly.20210929","17.0.0-nightly.20210930","17.0.0-nightly.20211001","17.0.0-nightly.20211004","17.0.0-nightly.20211005"],"96.0.4647.0":["16.0.0-alpha.8","16.0.0-alpha.9","16.0.0-beta.1","16.0.0-beta.2","16.0.0-beta.3","17.0.0-nightly.20211006","17.0.0-nightly.20211007","17.0.0-nightly.20211008","17.0.0-nightly.20211011","17.0.0-nightly.20211012","17.0.0-nightly.20211013","17.0.0-nightly.20211014","17.0.0-nightly.20211015","17.0.0-nightly.20211018","17.0.0-nightly.20211019","17.0.0-nightly.20211020","17.0.0-nightly.20211021"],"96.0.4664.18":["16.0.0-beta.4","16.0.0-beta.5"],"96.0.4664.27":["16.0.0-beta.6","16.0.0-beta.7"],"96.0.4664.35":["16.0.0-beta.8","16.0.0-beta.9"],"95.0.4612.5":["16.0.0-nightly.20210824","16.0.0-nightly.20210825","16.0.0-nightly.20210826","16.0.0-nightly.20210827","16.0.0-nightly.20210830","16.0.0-nightly.20210831","16.0.0-nightly.20210901"],"96.0.4664.45":["16.0.0","16.0.1"],"96.0.4664.55":["16.0.2","16.0.3","16.0.4","16.0.5"],"96.0.4664.110":["16.0.6","16.0.7","16.0.8"],"96.0.4664.174":["16.0.9","16.0.10","16.1.0","16.1.1","16.2.0","16.2.1","16.2.2","16.2.3","16.2.4","16.2.5","16.2.6","16.2.7","16.2.8"],"96.0.4664.4":["17.0.0-alpha.1","17.0.0-alpha.2","17.0.0-alpha.3","17.0.0-nightly.20211022","17.0.0-nightly.20211025","17.0.0-nightly.20211026","17.0.0-nightly.20211027","17.0.0-nightly.20211028","17.0.0-nightly.20211029","17.0.0-nightly.20211101","17.0.0-nightly.20211102","17.0.0-nightly.20211103","17.0.0-nightly.20211104","17.0.0-nightly.20211105","17.0.0-nightly.20211108","17.0.0-nightly.20211109","17.0.0-nightly.20211110","17.0.0-nightly.20211111","17.0.0-nightly.20211112","17.0.0-nightly.20211115","17.0.0-nightly.20211116","17.0.0-nightly.20211117","18.0.0-nightly.20211118","18.0.0-nightly.20211119","18.0.0-nightly.20211122","18.0.0-nightly.20211123"],"98.0.4706.0":["17.0.0-alpha.4","17.0.0-alpha.5","17.0.0-alpha.6","17.0.0-beta.1","17.0.0-beta.2","18.0.0-nightly.20211124","18.0.0-nightly.20211125","18.0.0-nightly.20211126","18.0.0-nightly.20211129","18.0.0-nightly.20211130","18.0.0-nightly.20211201","18.0.0-nightly.20211202","18.0.0-nightly.20211203","18.0.0-nightly.20211206","18.0.0-nightly.20211207","18.0.0-nightly.20211208","18.0.0-nightly.20211209","18.0.0-nightly.20211210","18.0.0-nightly.20211213","18.0.0-nightly.20211214","18.0.0-nightly.20211215","18.0.0-nightly.20211216","18.0.0-nightly.20211217","18.0.0-nightly.20211220","18.0.0-nightly.20211221","18.0.0-nightly.20211222","18.0.0-nightly.20211223","18.0.0-nightly.20211228","18.0.0-nightly.20211229","18.0.0-nightly.20211231","18.0.0-nightly.20220103","18.0.0-nightly.20220104","18.0.0-nightly.20220105","18.0.0-nightly.20220106","18.0.0-nightly.20220107","18.0.0-nightly.20220110"],"98.0.4758.9":["17.0.0-beta.3"],"98.0.4758.11":["17.0.0-beta.4","17.0.0-beta.5","17.0.0-beta.6","17.0.0-beta.7","17.0.0-beta.8","17.0.0-beta.9"],"98.0.4758.74":["17.0.0"],"98.0.4758.82":["17.0.1"],"98.0.4758.102":["17.1.0"],"98.0.4758.109":["17.1.1","17.1.2","17.2.0"],"98.0.4758.141":["17.3.0","17.3.1","17.4.0","17.4.1","17.4.2","17.4.3","17.4.4","17.4.5","17.4.6","17.4.7","17.4.8","17.4.9","17.4.10","17.4.11"],"99.0.4767.0":["18.0.0-alpha.1","18.0.0-alpha.2","18.0.0-alpha.3","18.0.0-alpha.4","18.0.0-alpha.5","18.0.0-nightly.20220111","18.0.0-nightly.20220112","18.0.0-nightly.20220113","18.0.0-nightly.20220114","18.0.0-nightly.20220117","18.0.0-nightly.20220118","18.0.0-nightly.20220119","18.0.0-nightly.20220121","18.0.0-nightly.20220124","18.0.0-nightly.20220125","18.0.0-nightly.20220127","18.0.0-nightly.20220128","18.0.0-nightly.20220131","18.0.0-nightly.20220201","19.0.0-nightly.20220202","19.0.0-nightly.20220203","19.0.0-nightly.20220204","19.0.0-nightly.20220207","19.0.0-nightly.20220208","19.0.0-nightly.20220209"],"100.0.4894.0":["18.0.0-beta.1","18.0.0-beta.2","18.0.0-beta.3","18.0.0-beta.4","18.0.0-beta.5","18.0.0-beta.6","19.0.0-nightly.20220308","19.0.0-nightly.20220309","19.0.0-nightly.20220310","19.0.0-nightly.20220311","19.0.0-nightly.20220314","19.0.0-nightly.20220315","19.0.0-nightly.20220316","19.0.0-nightly.20220317","19.0.0-nightly.20220318","19.0.0-nightly.20220321","19.0.0-nightly.20220322","19.0.0-nightly.20220323","19.0.0-nightly.20220324"],"100.0.4896.56":["18.0.0"],"100.0.4896.60":["18.0.1","18.0.2"],"100.0.4896.75":["18.0.3","18.0.4"],"100.0.4896.127":["18.1.0"],"100.0.4896.143":["18.2.0","18.2.1","18.2.2","18.2.3"],"100.0.4896.160":["18.2.4","18.3.0","18.3.1","18.3.2","18.3.3","18.3.4","18.3.5","18.3.6","18.3.7","18.3.8","18.3.9","18.3.11","18.3.12","18.3.13","18.3.14","18.3.15"],"102.0.4962.3":["19.0.0-alpha.1","19.0.0-nightly.20220328","19.0.0-nightly.20220329","20.0.0-nightly.20220330"],"102.0.4971.0":["19.0.0-alpha.2","19.0.0-alpha.3","20.0.0-nightly.20220411"],"102.0.4989.0":["19.0.0-alpha.4","19.0.0-alpha.5","20.0.0-nightly.20220414","20.0.0-nightly.20220415","20.0.0-nightly.20220418","20.0.0-nightly.20220419","20.0.0-nightly.20220420","20.0.0-nightly.20220421"],"102.0.4999.0":["19.0.0-beta.1","19.0.0-beta.2","19.0.0-beta.3","20.0.0-nightly.20220425","20.0.0-nightly.20220426","20.0.0-nightly.20220427","20.0.0-nightly.20220428","20.0.0-nightly.20220429","20.0.0-nightly.20220502","20.0.0-nightly.20220503","20.0.0-nightly.20220504","20.0.0-nightly.20220505","20.0.0-nightly.20220506","20.0.0-nightly.20220509","20.0.0-nightly.20220511","20.0.0-nightly.20220512","20.0.0-nightly.20220513","20.0.0-nightly.20220516","20.0.0-nightly.20220517"],"102.0.5005.27":["19.0.0-beta.4"],"102.0.5005.40":["19.0.0-beta.5","19.0.0-beta.6","19.0.0-beta.7"],"102.0.5005.49":["19.0.0-beta.8"],"102.0.4961.0":["19.0.0-nightly.20220325"],"102.0.5005.61":["19.0.0","19.0.1"],"102.0.5005.63":["19.0.2","19.0.3","19.0.4"],"102.0.5005.115":["19.0.5","19.0.6"],"102.0.5005.134":["19.0.7"],"102.0.5005.148":["19.0.8"],"102.0.5005.167":["19.0.9","19.0.10","19.0.11","19.0.12","19.0.13","19.0.14","19.0.15","19.0.16","19.0.17","19.1.0","19.1.1","19.1.2","19.1.3","19.1.4","19.1.5","19.1.6","19.1.7","19.1.8","19.1.9"],"103.0.5044.0":["20.0.0-alpha.1","20.0.0-nightly.20220518","20.0.0-nightly.20220519","20.0.0-nightly.20220520","20.0.0-nightly.20220523","20.0.0-nightly.20220524","21.0.0-nightly.20220526","21.0.0-nightly.20220527","21.0.0-nightly.20220530","21.0.0-nightly.20220531"],"104.0.5073.0":["20.0.0-alpha.2","20.0.0-alpha.3","20.0.0-alpha.4","20.0.0-alpha.5","20.0.0-alpha.6","20.0.0-alpha.7","20.0.0-beta.1","20.0.0-beta.2","20.0.0-beta.3","20.0.0-beta.4","20.0.0-beta.5","20.0.0-beta.6","20.0.0-beta.7","20.0.0-beta.8","21.0.0-nightly.20220602","21.0.0-nightly.20220603","21.0.0-nightly.20220606","21.0.0-nightly.20220607","21.0.0-nightly.20220608","21.0.0-nightly.20220609","21.0.0-nightly.20220610","21.0.0-nightly.20220613","21.0.0-nightly.20220614","21.0.0-nightly.20220615","21.0.0-nightly.20220616","21.0.0-nightly.20220617","21.0.0-nightly.20220620","21.0.0-nightly.20220621","21.0.0-nightly.20220622","21.0.0-nightly.20220623","21.0.0-nightly.20220624","21.0.0-nightly.20220627"],"104.0.5112.39":["20.0.0-beta.9"],"104.0.5112.48":["20.0.0-beta.10","20.0.0-beta.11","20.0.0-beta.12"],"104.0.5112.57":["20.0.0-beta.13"],"104.0.5112.65":["20.0.0"],"104.0.5112.81":["20.0.1","20.0.2","20.0.3"],"104.0.5112.102":["20.1.0","20.1.1"],"104.0.5112.114":["20.1.2","20.1.3","20.1.4"],"104.0.5112.124":["20.2.0","20.3.0","20.3.1","20.3.2","20.3.3","20.3.4","20.3.5","20.3.6","20.3.7","20.3.8","20.3.9","20.3.10","20.3.11","20.3.12"],"105.0.5187.0":["21.0.0-alpha.1","21.0.0-alpha.2","21.0.0-alpha.3","21.0.0-alpha.4","21.0.0-alpha.5","21.0.0-nightly.20220720","21.0.0-nightly.20220721","21.0.0-nightly.20220722","21.0.0-nightly.20220725","21.0.0-nightly.20220726","21.0.0-nightly.20220727","21.0.0-nightly.20220728","21.0.0-nightly.20220801","21.0.0-nightly.20220802","22.0.0-nightly.20220808","22.0.0-nightly.20220809","22.0.0-nightly.20220810","22.0.0-nightly.20220811","22.0.0-nightly.20220812","22.0.0-nightly.20220815","22.0.0-nightly.20220816","22.0.0-nightly.20220817"],"106.0.5216.0":["21.0.0-alpha.6","21.0.0-beta.1","21.0.0-beta.2","21.0.0-beta.3","21.0.0-beta.4","21.0.0-beta.5","22.0.0-nightly.20220822","22.0.0-nightly.20220823","22.0.0-nightly.20220824","22.0.0-nightly.20220825","22.0.0-nightly.20220829","22.0.0-nightly.20220830","22.0.0-nightly.20220831","22.0.0-nightly.20220901","22.0.0-nightly.20220902","22.0.0-nightly.20220905"],"106.0.5249.40":["21.0.0-beta.6","21.0.0-beta.7","21.0.0-beta.8"],"105.0.5129.0":["21.0.0-nightly.20220628","21.0.0-nightly.20220629","21.0.0-nightly.20220630","21.0.0-nightly.20220701","21.0.0-nightly.20220704","21.0.0-nightly.20220705","21.0.0-nightly.20220706","21.0.0-nightly.20220707","21.0.0-nightly.20220708","21.0.0-nightly.20220711","21.0.0-nightly.20220712","21.0.0-nightly.20220713"],"105.0.5173.0":["21.0.0-nightly.20220715","21.0.0-nightly.20220718","21.0.0-nightly.20220719"],"106.0.5249.51":["21.0.0"],"106.0.5249.61":["21.0.1"],"106.0.5249.91":["21.1.0"],"106.0.5249.103":["21.1.1"],"106.0.5249.119":["21.2.0"],"106.0.5249.165":["21.2.1"],"106.0.5249.168":["21.2.2","21.2.3"],"106.0.5249.181":["21.3.0","21.3.1"],"106.0.5249.199":["21.3.3","21.3.4","21.3.5","21.4.0","21.4.1","21.4.2","21.4.3","21.4.4"],"107.0.5286.0":["22.0.0-alpha.1","22.0.0-nightly.20220909","22.0.0-nightly.20220912","22.0.0-nightly.20220913","22.0.0-nightly.20220914","22.0.0-nightly.20220915","22.0.0-nightly.20220916","22.0.0-nightly.20220919","22.0.0-nightly.20220920","22.0.0-nightly.20220921","22.0.0-nightly.20220922","22.0.0-nightly.20220923","22.0.0-nightly.20220926","22.0.0-nightly.20220927","22.0.0-nightly.20220928","23.0.0-nightly.20220929","23.0.0-nightly.20220930","23.0.0-nightly.20221003"],"108.0.5329.0":["22.0.0-alpha.3","22.0.0-alpha.4","22.0.0-alpha.5","22.0.0-alpha.6","23.0.0-nightly.20221004","23.0.0-nightly.20221005","23.0.0-nightly.20221006","23.0.0-nightly.20221007","23.0.0-nightly.20221010","23.0.0-nightly.20221011","23.0.0-nightly.20221012","23.0.0-nightly.20221013","23.0.0-nightly.20221014","23.0.0-nightly.20221017"],"108.0.5355.0":["22.0.0-alpha.7","23.0.0-nightly.20221018","23.0.0-nightly.20221019","23.0.0-nightly.20221020","23.0.0-nightly.20221021","23.0.0-nightly.20221024","23.0.0-nightly.20221026"],"108.0.5359.10":["22.0.0-alpha.8","22.0.0-beta.1","22.0.0-beta.2","22.0.0-beta.3"],"108.0.5359.29":["22.0.0-beta.4"],"108.0.5359.40":["22.0.0-beta.5","22.0.0-beta.6"],"108.0.5359.48":["22.0.0-beta.7","22.0.0-beta.8"],"107.0.5274.0":["22.0.0-nightly.20220908"],"108.0.5359.62":["22.0.0"],"108.0.5359.125":["22.0.1"],"108.0.5359.179":["22.0.2","22.0.3","22.1.0"],"108.0.5359.215":["22.2.0","22.2.1","22.3.0","22.3.1","22.3.2","22.3.3","22.3.4","22.3.5","22.3.6","22.3.7","22.3.8","22.3.9","22.3.10","22.3.11","22.3.12","22.3.13","22.3.14","22.3.15","22.3.16","22.3.17","22.3.18","22.3.20","22.3.21","22.3.22","22.3.23","22.3.24","22.3.25","22.3.26","22.3.27"],"110.0.5415.0":["23.0.0-alpha.1","23.0.0-nightly.20221118","23.0.0-nightly.20221121","23.0.0-nightly.20221122","23.0.0-nightly.20221123","23.0.0-nightly.20221124","23.0.0-nightly.20221125","23.0.0-nightly.20221128","23.0.0-nightly.20221129","23.0.0-nightly.20221130","24.0.0-nightly.20221201","24.0.0-nightly.20221202","24.0.0-nightly.20221205"],"110.0.5451.0":["23.0.0-alpha.2","23.0.0-alpha.3","24.0.0-nightly.20221206","24.0.0-nightly.20221207","24.0.0-nightly.20221208","24.0.0-nightly.20221213","24.0.0-nightly.20221214","24.0.0-nightly.20221215","24.0.0-nightly.20221216"],"110.0.5478.5":["23.0.0-beta.1","23.0.0-beta.2","23.0.0-beta.3"],"110.0.5481.30":["23.0.0-beta.4"],"110.0.5481.38":["23.0.0-beta.5"],"110.0.5481.52":["23.0.0-beta.6","23.0.0-beta.8"],"109.0.5382.0":["23.0.0-nightly.20221027","23.0.0-nightly.20221028","23.0.0-nightly.20221031","23.0.0-nightly.20221101","23.0.0-nightly.20221102","23.0.0-nightly.20221103","23.0.0-nightly.20221104","23.0.0-nightly.20221107","23.0.0-nightly.20221108","23.0.0-nightly.20221109","23.0.0-nightly.20221110","23.0.0-nightly.20221111","23.0.0-nightly.20221114","23.0.0-nightly.20221115","23.0.0-nightly.20221116","23.0.0-nightly.20221117"],"110.0.5481.77":["23.0.0"],"110.0.5481.100":["23.1.0"],"110.0.5481.104":["23.1.1"],"110.0.5481.177":["23.1.2"],"110.0.5481.179":["23.1.3"],"110.0.5481.192":["23.1.4","23.2.0"],"110.0.5481.208":["23.2.1","23.2.2","23.2.3","23.2.4","23.3.0","23.3.1","23.3.2","23.3.3","23.3.4","23.3.5","23.3.6","23.3.7","23.3.8","23.3.9","23.3.10","23.3.11","23.3.12","23.3.13"],"111.0.5560.0":["24.0.0-alpha.1","24.0.0-alpha.2","24.0.0-alpha.3","24.0.0-alpha.4","24.0.0-alpha.5","24.0.0-alpha.6","24.0.0-alpha.7","24.0.0-nightly.20230203","24.0.0-nightly.20230206","24.0.0-nightly.20230207","24.0.0-nightly.20230208","24.0.0-nightly.20230209","25.0.0-nightly.20230210","25.0.0-nightly.20230214","25.0.0-nightly.20230215","25.0.0-nightly.20230216","25.0.0-nightly.20230217","25.0.0-nightly.20230220","25.0.0-nightly.20230221","25.0.0-nightly.20230222","25.0.0-nightly.20230223","25.0.0-nightly.20230224","25.0.0-nightly.20230227","25.0.0-nightly.20230228","25.0.0-nightly.20230301","25.0.0-nightly.20230302","25.0.0-nightly.20230303","25.0.0-nightly.20230306","25.0.0-nightly.20230307","25.0.0-nightly.20230308","25.0.0-nightly.20230309","25.0.0-nightly.20230310"],"111.0.5563.50":["24.0.0-beta.1","24.0.0-beta.2"],"112.0.5615.20":["24.0.0-beta.3","24.0.0-beta.4"],"112.0.5615.29":["24.0.0-beta.5"],"112.0.5615.39":["24.0.0-beta.6","24.0.0-beta.7"],"111.0.5518.0":["24.0.0-nightly.20230109","24.0.0-nightly.20230110","24.0.0-nightly.20230111","24.0.0-nightly.20230112","24.0.0-nightly.20230113","24.0.0-nightly.20230116","24.0.0-nightly.20230117","24.0.0-nightly.20230118","24.0.0-nightly.20230119","24.0.0-nightly.20230120","24.0.0-nightly.20230123","24.0.0-nightly.20230124","24.0.0-nightly.20230125","24.0.0-nightly.20230126","24.0.0-nightly.20230127","24.0.0-nightly.20230131","24.0.0-nightly.20230201","24.0.0-nightly.20230202"],"112.0.5615.49":["24.0.0"],"112.0.5615.50":["24.1.0","24.1.1"],"112.0.5615.87":["24.1.2"],"112.0.5615.165":["24.1.3","24.2.0","24.3.0"],"112.0.5615.183":["24.3.1"],"112.0.5615.204":["24.4.0","24.4.1","24.5.0","24.5.1","24.6.0","24.6.1","24.6.2","24.6.3","24.6.4","24.6.5","24.7.0","24.7.1","24.8.0","24.8.1","24.8.2","24.8.3","24.8.4","24.8.5","24.8.6","24.8.7","24.8.8"],"114.0.5694.0":["25.0.0-alpha.1","25.0.0-alpha.2","25.0.0-nightly.20230405","26.0.0-nightly.20230406","26.0.0-nightly.20230407","26.0.0-nightly.20230410","26.0.0-nightly.20230411"],"114.0.5710.0":["25.0.0-alpha.3","25.0.0-alpha.4","26.0.0-nightly.20230413","26.0.0-nightly.20230414","26.0.0-nightly.20230417"],"114.0.5719.0":["25.0.0-alpha.5","25.0.0-alpha.6","25.0.0-beta.1","25.0.0-beta.2","25.0.0-beta.3","26.0.0-nightly.20230421","26.0.0-nightly.20230424","26.0.0-nightly.20230425","26.0.0-nightly.20230426","26.0.0-nightly.20230427","26.0.0-nightly.20230428","26.0.0-nightly.20230501","26.0.0-nightly.20230502","26.0.0-nightly.20230503","26.0.0-nightly.20230504","26.0.0-nightly.20230505","26.0.0-nightly.20230508","26.0.0-nightly.20230509","26.0.0-nightly.20230510"],"114.0.5735.16":["25.0.0-beta.4","25.0.0-beta.5","25.0.0-beta.6","25.0.0-beta.7"],"114.0.5735.35":["25.0.0-beta.8"],"114.0.5735.45":["25.0.0-beta.9","25.0.0","25.0.1"],"113.0.5636.0":["25.0.0-nightly.20230314"],"113.0.5651.0":["25.0.0-nightly.20230315"],"113.0.5653.0":["25.0.0-nightly.20230317"],"113.0.5660.0":["25.0.0-nightly.20230320"],"113.0.5664.0":["25.0.0-nightly.20230321"],"113.0.5666.0":["25.0.0-nightly.20230322"],"113.0.5668.0":["25.0.0-nightly.20230323"],"113.0.5670.0":["25.0.0-nightly.20230324","25.0.0-nightly.20230327","25.0.0-nightly.20230328","25.0.0-nightly.20230329","25.0.0-nightly.20230330"],"114.0.5684.0":["25.0.0-nightly.20230331","25.0.0-nightly.20230403"],"114.0.5692.0":["25.0.0-nightly.20230404"],"114.0.5735.106":["25.1.0","25.1.1"],"114.0.5735.134":["25.2.0"],"114.0.5735.199":["25.3.0"],"114.0.5735.243":["25.3.1"],"114.0.5735.248":["25.3.2","25.4.0"],"114.0.5735.289":["25.5.0","25.6.0","25.7.0","25.8.0","25.8.1","25.8.2","25.8.3","25.8.4","25.9.0","25.9.1","25.9.2","25.9.3","25.9.4","25.9.5","25.9.6","25.9.7","25.9.8"],"116.0.5791.0":["26.0.0-alpha.1","26.0.0-alpha.2","26.0.0-alpha.3","26.0.0-alpha.4","26.0.0-alpha.5","26.0.0-nightly.20230526","26.0.0-nightly.20230529","26.0.0-nightly.20230530","26.0.0-nightly.20230531","27.0.0-nightly.20230601","27.0.0-nightly.20230602","27.0.0-nightly.20230605","27.0.0-nightly.20230606","27.0.0-nightly.20230607","27.0.0-nightly.20230609"],"116.0.5815.0":["26.0.0-alpha.6","27.0.0-nightly.20230612","27.0.0-nightly.20230613"],"116.0.5831.0":["26.0.0-alpha.7","27.0.0-nightly.20230615"],"116.0.5845.0":["26.0.0-alpha.8","26.0.0-beta.1","27.0.0-nightly.20230622","27.0.0-nightly.20230623","27.0.0-nightly.20230626","27.0.0-nightly.20230627","27.0.0-nightly.20230628","27.0.0-nightly.20230629","27.0.0-nightly.20230630"],"116.0.5845.14":["26.0.0-beta.2","26.0.0-beta.3","26.0.0-beta.4","26.0.0-beta.5","26.0.0-beta.6","26.0.0-beta.7"],"116.0.5845.42":["26.0.0-beta.8","26.0.0-beta.9"],"116.0.5845.49":["26.0.0-beta.10","26.0.0-beta.11"],"116.0.5845.62":["26.0.0-beta.12"],"114.0.5708.0":["26.0.0-nightly.20230412"],"114.0.5715.0":["26.0.0-nightly.20230418"],"115.0.5760.0":["26.0.0-nightly.20230511","26.0.0-nightly.20230512","26.0.0-nightly.20230515","26.0.0-nightly.20230516","26.0.0-nightly.20230517","26.0.0-nightly.20230518","26.0.0-nightly.20230519","26.0.0-nightly.20230522","26.0.0-nightly.20230523"],"115.0.5786.0":["26.0.0-nightly.20230524"],"115.0.5790.0":["26.0.0-nightly.20230525"],"116.0.5845.82":["26.0.0"],"116.0.5845.97":["26.1.0"],"116.0.5845.179":["26.2.0"],"116.0.5845.188":["26.2.1"],"116.0.5845.190":["26.2.2","26.2.3","26.2.4"],"116.0.5845.228":["26.3.0","26.4.0","26.4.1","26.4.2","26.4.3","26.5.0","26.6.0","26.6.1","26.6.2","26.6.3","26.6.4","26.6.5","26.6.6","26.6.7","26.6.8","26.6.9","26.6.10"],"118.0.5949.0":["27.0.0-alpha.1","27.0.0-alpha.2","27.0.0-alpha.3","27.0.0-alpha.4","27.0.0-alpha.5","27.0.0-alpha.6","27.0.0-nightly.20230816","28.0.0-nightly.20230817","28.0.0-nightly.20230818","28.0.0-nightly.20230821","28.0.0-nightly.20230822","28.0.0-nightly.20230823","28.0.0-nightly.20230824","28.0.0-nightly.20230825","28.0.0-nightly.20230828","28.0.0-nightly.20230829","28.0.0-nightly.20230830","28.0.0-nightly.20230831"],"118.0.5993.5":["27.0.0-beta.1","27.0.0-beta.2","27.0.0-beta.3"],"118.0.5993.11":["27.0.0-beta.4"],"118.0.5993.18":["27.0.0-beta.5","27.0.0-beta.6","27.0.0-beta.7","27.0.0-beta.8","27.0.0-beta.9"],"116.0.5829.0":["27.0.0-nightly.20230614"],"116.0.5833.0":["27.0.0-nightly.20230616","27.0.0-nightly.20230619","27.0.0-nightly.20230620","27.0.0-nightly.20230621"],"117.0.5852.0":["27.0.0-nightly.20230703","27.0.0-nightly.20230704","27.0.0-nightly.20230705","27.0.0-nightly.20230706","27.0.0-nightly.20230707","27.0.0-nightly.20230710","27.0.0-nightly.20230711","27.0.0-nightly.20230712","27.0.0-nightly.20230713","27.0.0-nightly.20230714"],"117.0.5884.1":["27.0.0-nightly.20230717","27.0.0-nightly.20230718"],"117.0.5892.0":["27.0.0-nightly.20230719"],"117.0.5897.0":["27.0.0-nightly.20230720","27.0.0-nightly.20230721","27.0.0-nightly.20230724","27.0.0-nightly.20230725","27.0.0-nightly.20230726","27.0.0-nightly.20230727","27.0.0-nightly.20230728","27.0.0-nightly.20230731"],"117.0.5911.0":["27.0.0-nightly.20230801","27.0.0-nightly.20230802","27.0.0-nightly.20230803"],"117.0.5921.0":["27.0.0-nightly.20230804","27.0.0-nightly.20230807","27.0.0-nightly.20230808","27.0.0-nightly.20230814","27.0.0-nightly.20230815"],"118.0.5993.54":["27.0.0"],"118.0.5993.89":["27.0.1","27.0.2"],"118.0.5993.120":["27.0.3"],"118.0.5993.129":["27.0.4"],"118.0.5993.144":["27.1.0","27.1.2"],"118.0.5993.159":["27.1.3","27.2.0","27.2.1","27.2.2","27.2.3","27.2.4","27.3.0","27.3.1","27.3.2","27.3.3","27.3.4","27.3.5","27.3.6","27.3.7","27.3.8","27.3.9","27.3.10","27.3.11"],"119.0.6045.0":["28.0.0-alpha.1","28.0.0-alpha.2","28.0.0-nightly.20231006","28.0.0-nightly.20231009","28.0.0-nightly.20231010","28.0.0-nightly.20231011","29.0.0-nightly.20231012","29.0.0-nightly.20231013","29.0.0-nightly.20231016","29.0.0-nightly.20231017","29.0.0-nightly.20231018","29.0.0-nightly.20231019","29.0.0-nightly.20231020","29.0.0-nightly.20231023","29.0.0-nightly.20231024"],"119.0.6045.21":["28.0.0-alpha.3","28.0.0-alpha.4"],"119.0.6045.33":["28.0.0-alpha.5","28.0.0-alpha.6","28.0.0-alpha.7","28.0.0-beta.1"],"120.0.6099.0":["28.0.0-beta.2"],"120.0.6099.5":["28.0.0-beta.3","28.0.0-beta.4"],"120.0.6099.18":["28.0.0-beta.5","28.0.0-beta.6","28.0.0-beta.7","28.0.0-beta.8","28.0.0-beta.9","28.0.0-beta.10"],"120.0.6099.35":["28.0.0-beta.11"],"118.0.5991.0":["28.0.0-nightly.20230906"],"118.0.5993.0":["28.0.0-nightly.20230907","28.0.0-nightly.20230908","28.0.0-nightly.20230911","28.0.0-nightly.20230912","28.0.0-nightly.20230913","28.0.0-nightly.20230914","28.0.0-nightly.20230915"],"119.0.6006.0":["28.0.0-nightly.20230919"],"119.0.6017.0":["28.0.0-nightly.20230920"],"119.0.6019.2":["28.0.0-nightly.20230921","28.0.0-nightly.20230925","28.0.0-nightly.20230926","28.0.0-nightly.20230927","28.0.0-nightly.20230928"],"119.0.6029.0":["28.0.0-nightly.20230929","28.0.0-nightly.20231002"],"119.0.6043.0":["28.0.0-nightly.20231003","28.0.0-nightly.20231004","28.0.0-nightly.20231005"],"120.0.6099.56":["28.0.0"],"120.0.6099.109":["28.1.0","28.1.1"],"120.0.6099.199":["28.1.2","28.1.3"],"120.0.6099.216":["28.1.4"],"120.0.6099.227":["28.2.0"],"120.0.6099.268":["28.2.1"],"120.0.6099.276":["28.2.2"],"120.0.6099.283":["28.2.3"],"120.0.6099.291":["28.2.4","28.2.5","28.2.6","28.2.7","28.2.8","28.2.9","28.2.10","28.3.0","28.3.1","28.3.2","28.3.3"],"121.0.6147.0":["29.0.0-alpha.1","29.0.0-alpha.2","29.0.0-alpha.3","29.0.0-nightly.20231129","29.0.0-nightly.20231130","29.0.0-nightly.20231201","29.0.0-nightly.20231204","29.0.0-nightly.20231205","29.0.0-nightly.20231206","30.0.0-nightly.20231207","30.0.0-nightly.20231208","30.0.0-nightly.20231211"],"121.0.6159.0":["29.0.0-alpha.4","29.0.0-alpha.5","29.0.0-alpha.6","29.0.0-alpha.7","30.0.0-nightly.20231212","30.0.0-nightly.20231213","30.0.0-nightly.20231214","30.0.0-nightly.20231215","30.0.0-nightly.20231218","30.0.0-nightly.20240102"],"122.0.6194.0":["29.0.0-alpha.8","30.0.0-nightly.20240103","30.0.0-nightly.20240104","30.0.0-nightly.20240105","30.0.0-nightly.20240108","30.0.0-nightly.20240109","30.0.0-nightly.20240110"],"122.0.6236.2":["29.0.0-alpha.9","29.0.0-alpha.10","29.0.0-alpha.11","29.0.0-beta.1","29.0.0-beta.2","30.0.0-nightly.20240111","30.0.0-nightly.20240112","30.0.0-nightly.20240115","30.0.0-nightly.20240116","30.0.0-nightly.20240117","30.0.0-nightly.20240118","30.0.0-nightly.20240119","30.0.0-nightly.20240122","30.0.0-nightly.20240123","30.0.0-nightly.20240124","30.0.0-nightly.20240125"],"122.0.6261.6":["29.0.0-beta.3","29.0.0-beta.4"],"122.0.6261.18":["29.0.0-beta.5","29.0.0-beta.6","29.0.0-beta.7","29.0.0-beta.8","29.0.0-beta.9","29.0.0-beta.10","29.0.0-beta.11"],"122.0.6261.29":["29.0.0-beta.12"],"120.0.6078.0":["29.0.0-nightly.20231025","29.0.0-nightly.20231026","29.0.0-nightly.20231027","29.0.0-nightly.20231030","29.0.0-nightly.20231031","29.0.0-nightly.20231101"],"121.0.6100.0":["29.0.0-nightly.20231102","29.0.0-nightly.20231103"],"121.0.6104.0":["29.0.0-nightly.20231106"],"121.0.6110.0":["29.0.0-nightly.20231107","29.0.0-nightly.20231108","29.0.0-nightly.20231109","29.0.0-nightly.20231110","29.0.0-nightly.20231113","29.0.0-nightly.20231114"],"121.0.6116.0":["29.0.0-nightly.20231115","29.0.0-nightly.20231116","29.0.0-nightly.20231117","29.0.0-nightly.20231120","29.0.0-nightly.20231121","29.0.0-nightly.20231122","29.0.0-nightly.20231123","29.0.0-nightly.20231124","29.0.0-nightly.20231127","29.0.0-nightly.20231128"],"122.0.6261.39":["29.0.0"],"122.0.6261.57":["29.0.1"],"122.0.6261.70":["29.1.0"],"122.0.6261.111":["29.1.1"],"122.0.6261.112":["29.1.2","29.1.3"],"122.0.6261.129":["29.1.4"],"122.0.6261.130":["29.1.5"],"122.0.6261.139":["29.1.6"],"122.0.6261.156":["29.2.0","29.3.0","29.3.1","29.3.2","29.3.3","29.4.0","29.4.1","29.4.2"],"123.0.6296.0":["30.0.0-alpha.1","30.0.0-nightly.20240215","30.0.0-nightly.20240216","30.0.0-nightly.20240219","30.0.0-nightly.20240220","30.0.0-nightly.20240221"],"123.0.6312.5":["30.0.0-alpha.2","31.0.0-nightly.20240222","31.0.0-nightly.20240223","31.0.0-nightly.20240226","31.0.0-nightly.20240227","31.0.0-nightly.20240228"],"124.0.6323.0":["30.0.0-alpha.3","30.0.0-alpha.4","31.0.0-nightly.20240229","31.0.0-nightly.20240301","31.0.0-nightly.20240304","31.0.0-nightly.20240305"],"124.0.6331.0":["30.0.0-alpha.5","30.0.0-alpha.6","31.0.0-nightly.20240306","31.0.0-nightly.20240307","31.0.0-nightly.20240308","31.0.0-nightly.20240311"],"124.0.6353.0":["30.0.0-alpha.7","31.0.0-nightly.20240313","31.0.0-nightly.20240314","31.0.0-nightly.20240315"],"124.0.6359.0":["30.0.0-beta.1","30.0.0-beta.2","31.0.0-nightly.20240318","31.0.0-nightly.20240319","31.0.0-nightly.20240320","31.0.0-nightly.20240321","31.0.0-nightly.20240325","31.0.0-nightly.20240327","31.0.0-nightly.20240328","31.0.0-nightly.20240329","31.0.0-nightly.20240401","31.0.0-nightly.20240402","31.0.0-nightly.20240404","31.0.0-nightly.20240405","31.0.0-nightly.20240408","31.0.0-nightly.20240409","31.0.0-nightly.20240410","31.0.0-nightly.20240411","31.0.0-nightly.20240412"],"124.0.6367.9":["30.0.0-beta.3","30.0.0-beta.4","30.0.0-beta.5"],"124.0.6367.18":["30.0.0-beta.6"],"124.0.6367.29":["30.0.0-beta.7","30.0.0-beta.8"],"123.0.6264.0":["30.0.0-nightly.20240126","30.0.0-nightly.20240129","30.0.0-nightly.20240130","30.0.0-nightly.20240131"],"123.0.6272.0":["30.0.0-nightly.20240201","30.0.0-nightly.20240202","30.0.0-nightly.20240205","30.0.0-nightly.20240206","30.0.0-nightly.20240207","30.0.0-nightly.20240208","30.0.0-nightly.20240209","30.0.0-nightly.20240212","30.0.0-nightly.20240213","30.0.0-nightly.20240214"],"124.0.6367.49":["30.0.0"],"124.0.6367.60":["30.0.1"],"124.0.6367.91":["30.0.2"],"124.0.6367.119":["30.0.3"],"124.0.6367.201":["30.0.4"],"124.0.6367.207":["30.0.5","30.0.6"],"124.0.6367.221":["30.0.7"],"124.0.6367.230":["30.0.8"],"124.0.6367.233":["30.0.9"],"124.0.6367.243":["30.1.0","30.1.1"],"125.0.6412.0":["31.0.0-alpha.1","31.0.0-alpha.2","31.0.0-alpha.3","31.0.0-alpha.4","31.0.0-alpha.5","32.0.0-nightly.20240418","32.0.0-nightly.20240419","32.0.0-nightly.20240422","32.0.0-nightly.20240423","32.0.0-nightly.20240424","32.0.0-nightly.20240425","32.0.0-nightly.20240426","32.0.0-nightly.20240429","32.0.0-nightly.20240430","32.0.0-nightly.20240501","32.0.0-nightly.20240503","32.0.0-nightly.20240506","32.0.0-nightly.20240507","32.0.0-nightly.20240508","32.0.0-nightly.20240509","32.0.0-nightly.20240510"],"126.0.6445.0":["31.0.0-beta.1","31.0.0-beta.2","31.0.0-beta.3","31.0.0-beta.4","31.0.0-beta.5","31.0.0-beta.6","31.0.0-beta.7","31.0.0-beta.8","31.0.0-beta.9","32.0.0-nightly.20240513","32.0.0-nightly.20240514","32.0.0-nightly.20240515","32.0.0-nightly.20240516","32.0.0-nightly.20240517","32.0.0-nightly.20240520","32.0.0-nightly.20240521","32.0.0-nightly.20240522","32.0.0-nightly.20240523","32.0.0-nightly.20240524","32.0.0-nightly.20240529","32.0.0-nightly.20240530","32.0.0-nightly.20240531","32.0.0-nightly.20240603","32.0.0-nightly.20240604","32.0.0-nightly.20240605","32.0.0-nightly.20240606","32.0.0-nightly.20240607"],"126.0.6478.36":["31.0.0-beta.10","31.0.0","31.0.1"],"124.0.6351.0":["31.0.0-nightly.20240312"],"127.0.6521.0":["32.0.0-alpha.1","32.0.0-alpha.2","32.0.0-nightly.20240610","32.0.0-nightly.20240611","33.0.0-nightly.20240612","33.0.0-nightly.20240614","33.0.0-nightly.20240617","33.0.0-nightly.20240618"]} \ No newline at end of file diff --git a/tools/eslint/node_modules/electron-to-chromium/full-versions.js b/tools/eslint/node_modules/electron-to-chromium/full-versions.js deleted file mode 100644 index a47d74942b056e..00000000000000 --- a/tools/eslint/node_modules/electron-to-chromium/full-versions.js +++ /dev/null @@ -1,2419 +0,0 @@ -module.exports = { - "0.20.0": "39.0.2171.65", - "0.20.1": "39.0.2171.65", - "0.20.2": "39.0.2171.65", - "0.20.3": "39.0.2171.65", - "0.20.4": "39.0.2171.65", - "0.20.5": "39.0.2171.65", - "0.20.6": "39.0.2171.65", - "0.20.7": "39.0.2171.65", - "0.20.8": "39.0.2171.65", - "0.21.0": "40.0.2214.91", - "0.21.1": "40.0.2214.91", - "0.21.2": "40.0.2214.91", - "0.21.3": "41.0.2272.76", - "0.22.1": "41.0.2272.76", - "0.22.2": "41.0.2272.76", - "0.22.3": "41.0.2272.76", - "0.23.0": "41.0.2272.76", - "0.24.0": "41.0.2272.76", - "0.25.0": "42.0.2311.107", - "0.25.1": "42.0.2311.107", - "0.25.2": "42.0.2311.107", - "0.25.3": "42.0.2311.107", - "0.26.0": "42.0.2311.107", - "0.26.1": "42.0.2311.107", - "0.27.0": "42.0.2311.107", - "0.27.1": "42.0.2311.107", - "0.27.2": "43.0.2357.65", - "0.27.3": "43.0.2357.65", - "0.28.0": "43.0.2357.65", - "0.28.1": "43.0.2357.65", - "0.28.2": "43.0.2357.65", - "0.28.3": "43.0.2357.65", - "0.29.1": "43.0.2357.65", - "0.29.2": "43.0.2357.65", - "0.30.4": "44.0.2403.125", - "0.31.0": "44.0.2403.125", - "0.31.2": "45.0.2454.85", - "0.32.2": "45.0.2454.85", - "0.32.3": "45.0.2454.85", - "0.33.0": "45.0.2454.85", - "0.33.1": "45.0.2454.85", - "0.33.2": "45.0.2454.85", - "0.33.3": "45.0.2454.85", - "0.33.4": "45.0.2454.85", - "0.33.6": "45.0.2454.85", - "0.33.7": "45.0.2454.85", - "0.33.8": "45.0.2454.85", - "0.33.9": "45.0.2454.85", - "0.34.0": "45.0.2454.85", - "0.34.1": "45.0.2454.85", - "0.34.2": "45.0.2454.85", - "0.34.3": "45.0.2454.85", - "0.34.4": "45.0.2454.85", - "0.35.1": "45.0.2454.85", - "0.35.2": "45.0.2454.85", - "0.35.3": "45.0.2454.85", - "0.35.4": "45.0.2454.85", - "0.35.5": "45.0.2454.85", - "0.36.0": "47.0.2526.73", - "0.36.2": "47.0.2526.73", - "0.36.3": "47.0.2526.73", - "0.36.4": "47.0.2526.73", - "0.36.5": "47.0.2526.110", - "0.36.6": "47.0.2526.110", - "0.36.7": "47.0.2526.110", - "0.36.8": "47.0.2526.110", - "0.36.9": "47.0.2526.110", - "0.36.10": "47.0.2526.110", - "0.36.11": "47.0.2526.110", - "0.36.12": "47.0.2526.110", - "0.37.0": "49.0.2623.75", - "0.37.1": "49.0.2623.75", - "0.37.3": "49.0.2623.75", - "0.37.4": "49.0.2623.75", - "0.37.5": "49.0.2623.75", - "0.37.6": "49.0.2623.75", - "0.37.7": "49.0.2623.75", - "0.37.8": "49.0.2623.75", - "1.0.0": "49.0.2623.75", - "1.0.1": "49.0.2623.75", - "1.0.2": "49.0.2623.75", - "1.1.0": "50.0.2661.102", - "1.1.1": "50.0.2661.102", - "1.1.2": "50.0.2661.102", - "1.1.3": "50.0.2661.102", - "1.2.0": "51.0.2704.63", - "1.2.1": "51.0.2704.63", - "1.2.2": "51.0.2704.84", - "1.2.3": "51.0.2704.84", - "1.2.4": "51.0.2704.103", - "1.2.5": "51.0.2704.103", - "1.2.6": "51.0.2704.106", - "1.2.7": "51.0.2704.106", - "1.2.8": "51.0.2704.106", - "1.3.0": "52.0.2743.82", - "1.3.1": "52.0.2743.82", - "1.3.2": "52.0.2743.82", - "1.3.3": "52.0.2743.82", - "1.3.4": "52.0.2743.82", - "1.3.5": "52.0.2743.82", - "1.3.6": "52.0.2743.82", - "1.3.7": "52.0.2743.82", - "1.3.9": "52.0.2743.82", - "1.3.10": "52.0.2743.82", - "1.3.13": "52.0.2743.82", - "1.3.14": "52.0.2743.82", - "1.3.15": "52.0.2743.82", - "1.4.0": "53.0.2785.113", - "1.4.1": "53.0.2785.113", - "1.4.2": "53.0.2785.113", - "1.4.3": "53.0.2785.113", - "1.4.4": "53.0.2785.113", - "1.4.5": "53.0.2785.113", - "1.4.6": "53.0.2785.143", - "1.4.7": "53.0.2785.143", - "1.4.8": "53.0.2785.143", - "1.4.10": "53.0.2785.143", - "1.4.11": "53.0.2785.143", - "1.4.12": "54.0.2840.51", - "1.4.13": "53.0.2785.143", - "1.4.14": "53.0.2785.143", - "1.4.15": "53.0.2785.143", - "1.4.16": "53.0.2785.143", - "1.5.0": "54.0.2840.101", - "1.5.1": "54.0.2840.101", - "1.6.0": "56.0.2924.87", - "1.6.1": "56.0.2924.87", - "1.6.2": "56.0.2924.87", - "1.6.3": "56.0.2924.87", - "1.6.4": "56.0.2924.87", - "1.6.5": "56.0.2924.87", - "1.6.6": "56.0.2924.87", - "1.6.7": "56.0.2924.87", - "1.6.8": "56.0.2924.87", - "1.6.9": "56.0.2924.87", - "1.6.10": "56.0.2924.87", - "1.6.11": "56.0.2924.87", - "1.6.12": "56.0.2924.87", - "1.6.13": "56.0.2924.87", - "1.6.14": "56.0.2924.87", - "1.6.15": "56.0.2924.87", - "1.6.16": "56.0.2924.87", - "1.6.17": "56.0.2924.87", - "1.6.18": "56.0.2924.87", - "1.7.0": "58.0.3029.110", - "1.7.1": "58.0.3029.110", - "1.7.2": "58.0.3029.110", - "1.7.3": "58.0.3029.110", - "1.7.4": "58.0.3029.110", - "1.7.5": "58.0.3029.110", - "1.7.6": "58.0.3029.110", - "1.7.7": "58.0.3029.110", - "1.7.8": "58.0.3029.110", - "1.7.9": "58.0.3029.110", - "1.7.10": "58.0.3029.110", - "1.7.11": "58.0.3029.110", - "1.7.12": "58.0.3029.110", - "1.7.13": "58.0.3029.110", - "1.7.14": "58.0.3029.110", - "1.7.15": "58.0.3029.110", - "1.7.16": "58.0.3029.110", - "1.8.0": "59.0.3071.115", - "1.8.1": "59.0.3071.115", - "1.8.2-beta.1": "59.0.3071.115", - "1.8.2-beta.2": "59.0.3071.115", - "1.8.2-beta.3": "59.0.3071.115", - "1.8.2-beta.4": "59.0.3071.115", - "1.8.2-beta.5": "59.0.3071.115", - "1.8.2": "59.0.3071.115", - "1.8.3": "59.0.3071.115", - "1.8.4": "59.0.3071.115", - "1.8.5": "59.0.3071.115", - "1.8.6": "59.0.3071.115", - "1.8.7": "59.0.3071.115", - "1.8.8": "59.0.3071.115", - "2.0.0-beta.1": "61.0.3163.100", - "2.0.0-beta.2": "61.0.3163.100", - "2.0.0-beta.3": "61.0.3163.100", - "2.0.0-beta.4": "61.0.3163.100", - "2.0.0-beta.5": "61.0.3163.100", - "2.0.0-beta.6": "61.0.3163.100", - "2.0.0-beta.7": "61.0.3163.100", - "2.0.0-beta.8": "61.0.3163.100", - "2.0.0": "61.0.3163.100", - "2.0.1": "61.0.3163.100", - "2.0.2": "61.0.3163.100", - "2.0.3": "61.0.3163.100", - "2.0.4": "61.0.3163.100", - "2.0.5": "61.0.3163.100", - "2.0.6": "61.0.3163.100", - "2.0.7": "61.0.3163.100", - "2.0.8-nightly.20180819": "61.0.3163.100", - "2.0.8-nightly.20180820": "61.0.3163.100", - "2.0.8": "61.0.3163.100", - "2.0.9": "61.0.3163.100", - "2.0.10": "61.0.3163.100", - "2.0.11": "61.0.3163.100", - "2.0.12": "61.0.3163.100", - "2.0.13": "61.0.3163.100", - "2.0.14": "61.0.3163.100", - "2.0.15": "61.0.3163.100", - "2.0.16": "61.0.3163.100", - "2.0.17": "61.0.3163.100", - "2.0.18": "61.0.3163.100", - "2.1.0-unsupported.20180809": "61.0.3163.100", - "3.0.0-beta.1": "66.0.3359.181", - "3.0.0-beta.2": "66.0.3359.181", - "3.0.0-beta.3": "66.0.3359.181", - "3.0.0-beta.4": "66.0.3359.181", - "3.0.0-beta.5": "66.0.3359.181", - "3.0.0-beta.6": "66.0.3359.181", - "3.0.0-beta.7": "66.0.3359.181", - "3.0.0-beta.8": "66.0.3359.181", - "3.0.0-beta.9": "66.0.3359.181", - "3.0.0-beta.10": "66.0.3359.181", - "3.0.0-beta.11": "66.0.3359.181", - "3.0.0-beta.12": "66.0.3359.181", - "3.0.0-beta.13": "66.0.3359.181", - "3.0.0-nightly.20180818": "66.0.3359.181", - "3.0.0-nightly.20180821": "66.0.3359.181", - "3.0.0-nightly.20180823": "66.0.3359.181", - "3.0.0-nightly.20180904": "66.0.3359.181", - "3.0.0": "66.0.3359.181", - "3.0.1": "66.0.3359.181", - "3.0.2": "66.0.3359.181", - "3.0.3": "66.0.3359.181", - "3.0.4": "66.0.3359.181", - "3.0.5": "66.0.3359.181", - "3.0.6": "66.0.3359.181", - "3.0.7": "66.0.3359.181", - "3.0.8": "66.0.3359.181", - "3.0.9": "66.0.3359.181", - "3.0.10": "66.0.3359.181", - "3.0.11": "66.0.3359.181", - "3.0.12": "66.0.3359.181", - "3.0.13": "66.0.3359.181", - "3.0.14": "66.0.3359.181", - "3.0.15": "66.0.3359.181", - "3.0.16": "66.0.3359.181", - "3.1.0-beta.1": "66.0.3359.181", - "3.1.0-beta.2": "66.0.3359.181", - "3.1.0-beta.3": "66.0.3359.181", - "3.1.0-beta.4": "66.0.3359.181", - "3.1.0-beta.5": "66.0.3359.181", - "3.1.0": "66.0.3359.181", - "3.1.1": "66.0.3359.181", - "3.1.2": "66.0.3359.181", - "3.1.3": "66.0.3359.181", - "3.1.4": "66.0.3359.181", - "3.1.5": "66.0.3359.181", - "3.1.6": "66.0.3359.181", - "3.1.7": "66.0.3359.181", - "3.1.8": "66.0.3359.181", - "3.1.9": "66.0.3359.181", - "3.1.10": "66.0.3359.181", - "3.1.11": "66.0.3359.181", - "3.1.12": "66.0.3359.181", - "3.1.13": "66.0.3359.181", - "4.0.0-beta.1": "69.0.3497.106", - "4.0.0-beta.2": "69.0.3497.106", - "4.0.0-beta.3": "69.0.3497.106", - "4.0.0-beta.4": "69.0.3497.106", - "4.0.0-beta.5": "69.0.3497.106", - "4.0.0-beta.6": "69.0.3497.106", - "4.0.0-beta.7": "69.0.3497.106", - "4.0.0-beta.8": "69.0.3497.106", - "4.0.0-beta.9": "69.0.3497.106", - "4.0.0-beta.10": "69.0.3497.106", - "4.0.0-beta.11": "69.0.3497.106", - "4.0.0-nightly.20180817": "66.0.3359.181", - "4.0.0-nightly.20180819": "66.0.3359.181", - "4.0.0-nightly.20180821": "66.0.3359.181", - "4.0.0-nightly.20180929": "67.0.3396.99", - "4.0.0-nightly.20181006": "68.0.3440.128", - "4.0.0-nightly.20181010": "69.0.3497.106", - "4.0.0": "69.0.3497.106", - "4.0.1": "69.0.3497.106", - "4.0.2": "69.0.3497.106", - "4.0.3": "69.0.3497.106", - "4.0.4": "69.0.3497.106", - "4.0.5": "69.0.3497.106", - "4.0.6": "69.0.3497.106", - "4.0.7": "69.0.3497.128", - "4.0.8": "69.0.3497.128", - "4.1.0": "69.0.3497.128", - "4.1.1": "69.0.3497.128", - "4.1.2": "69.0.3497.128", - "4.1.3": "69.0.3497.128", - "4.1.4": "69.0.3497.128", - "4.1.5": "69.0.3497.128", - "4.2.0": "69.0.3497.128", - "4.2.1": "69.0.3497.128", - "4.2.2": "69.0.3497.128", - "4.2.3": "69.0.3497.128", - "4.2.4": "69.0.3497.128", - "4.2.5": "69.0.3497.128", - "4.2.6": "69.0.3497.128", - "4.2.7": "69.0.3497.128", - "4.2.8": "69.0.3497.128", - "4.2.9": "69.0.3497.128", - "4.2.10": "69.0.3497.128", - "4.2.11": "69.0.3497.128", - "4.2.12": "69.0.3497.128", - "5.0.0-beta.1": "72.0.3626.52", - "5.0.0-beta.2": "72.0.3626.52", - "5.0.0-beta.3": "73.0.3683.27", - "5.0.0-beta.4": "73.0.3683.54", - "5.0.0-beta.5": "73.0.3683.61", - "5.0.0-beta.6": "73.0.3683.84", - "5.0.0-beta.7": "73.0.3683.94", - "5.0.0-beta.8": "73.0.3683.104", - "5.0.0-beta.9": "73.0.3683.117", - "5.0.0-nightly.20190107": "70.0.3538.110", - "5.0.0-nightly.20190121": "71.0.3578.98", - "5.0.0-nightly.20190122": "71.0.3578.98", - "5.0.0": "73.0.3683.119", - "5.0.1": "73.0.3683.121", - "5.0.2": "73.0.3683.121", - "5.0.3": "73.0.3683.121", - "5.0.4": "73.0.3683.121", - "5.0.5": "73.0.3683.121", - "5.0.6": "73.0.3683.121", - "5.0.7": "73.0.3683.121", - "5.0.8": "73.0.3683.121", - "5.0.9": "73.0.3683.121", - "5.0.10": "73.0.3683.121", - "5.0.11": "73.0.3683.121", - "5.0.12": "73.0.3683.121", - "5.0.13": "73.0.3683.121", - "6.0.0-beta.1": "76.0.3774.1", - "6.0.0-beta.2": "76.0.3783.1", - "6.0.0-beta.3": "76.0.3783.1", - "6.0.0-beta.4": "76.0.3783.1", - "6.0.0-beta.5": "76.0.3805.4", - "6.0.0-beta.6": "76.0.3809.3", - "6.0.0-beta.7": "76.0.3809.22", - "6.0.0-beta.8": "76.0.3809.26", - "6.0.0-beta.9": "76.0.3809.26", - "6.0.0-beta.10": "76.0.3809.37", - "6.0.0-beta.11": "76.0.3809.42", - "6.0.0-beta.12": "76.0.3809.54", - "6.0.0-beta.13": "76.0.3809.60", - "6.0.0-beta.14": "76.0.3809.68", - "6.0.0-beta.15": "76.0.3809.74", - "6.0.0-nightly.20190123": "72.0.3626.52", - "6.0.0-nightly.20190212": "72.0.3626.107", - "6.0.0-nightly.20190213": "72.0.3626.110", - "6.0.0-nightly.20190311": "74.0.3724.8", - "6.0.0": "76.0.3809.88", - "6.0.1": "76.0.3809.102", - "6.0.2": "76.0.3809.110", - "6.0.3": "76.0.3809.126", - "6.0.4": "76.0.3809.131", - "6.0.5": "76.0.3809.136", - "6.0.6": "76.0.3809.138", - "6.0.7": "76.0.3809.139", - "6.0.8": "76.0.3809.146", - "6.0.9": "76.0.3809.146", - "6.0.10": "76.0.3809.146", - "6.0.11": "76.0.3809.146", - "6.0.12": "76.0.3809.146", - "6.1.0": "76.0.3809.146", - "6.1.1": "76.0.3809.146", - "6.1.2": "76.0.3809.146", - "6.1.3": "76.0.3809.146", - "6.1.4": "76.0.3809.146", - "6.1.5": "76.0.3809.146", - "6.1.6": "76.0.3809.146", - "6.1.7": "76.0.3809.146", - "6.1.8": "76.0.3809.146", - "6.1.9": "76.0.3809.146", - "6.1.10": "76.0.3809.146", - "6.1.11": "76.0.3809.146", - "6.1.12": "76.0.3809.146", - "7.0.0-beta.1": "78.0.3866.0", - "7.0.0-beta.2": "78.0.3866.0", - "7.0.0-beta.3": "78.0.3866.0", - "7.0.0-beta.4": "78.0.3896.6", - "7.0.0-beta.5": "78.0.3905.1", - "7.0.0-beta.6": "78.0.3905.1", - "7.0.0-beta.7": "78.0.3905.1", - "7.0.0-nightly.20190521": "76.0.3784.0", - "7.0.0-nightly.20190529": "76.0.3806.0", - "7.0.0-nightly.20190530": "76.0.3806.0", - "7.0.0-nightly.20190531": "76.0.3806.0", - "7.0.0-nightly.20190602": "76.0.3806.0", - "7.0.0-nightly.20190603": "76.0.3806.0", - "7.0.0-nightly.20190604": "77.0.3814.0", - "7.0.0-nightly.20190605": "77.0.3815.0", - "7.0.0-nightly.20190606": "77.0.3815.0", - "7.0.0-nightly.20190607": "77.0.3815.0", - "7.0.0-nightly.20190608": "77.0.3815.0", - "7.0.0-nightly.20190609": "77.0.3815.0", - "7.0.0-nightly.20190611": "77.0.3815.0", - "7.0.0-nightly.20190612": "77.0.3815.0", - "7.0.0-nightly.20190613": "77.0.3815.0", - "7.0.0-nightly.20190615": "77.0.3815.0", - "7.0.0-nightly.20190616": "77.0.3815.0", - "7.0.0-nightly.20190618": "77.0.3815.0", - "7.0.0-nightly.20190619": "77.0.3815.0", - "7.0.0-nightly.20190622": "77.0.3815.0", - "7.0.0-nightly.20190623": "77.0.3815.0", - "7.0.0-nightly.20190624": "77.0.3815.0", - "7.0.0-nightly.20190627": "77.0.3815.0", - "7.0.0-nightly.20190629": "77.0.3815.0", - "7.0.0-nightly.20190630": "77.0.3815.0", - "7.0.0-nightly.20190701": "77.0.3815.0", - "7.0.0-nightly.20190702": "77.0.3815.0", - "7.0.0-nightly.20190704": "77.0.3843.0", - "7.0.0-nightly.20190705": "77.0.3843.0", - "7.0.0-nightly.20190719": "77.0.3848.0", - "7.0.0-nightly.20190720": "77.0.3848.0", - "7.0.0-nightly.20190721": "77.0.3848.0", - "7.0.0-nightly.20190726": "77.0.3864.0", - "7.0.0-nightly.20190727": "78.0.3866.0", - "7.0.0-nightly.20190728": "78.0.3866.0", - "7.0.0-nightly.20190729": "78.0.3866.0", - "7.0.0-nightly.20190730": "78.0.3866.0", - "7.0.0-nightly.20190731": "78.0.3866.0", - "7.0.0": "78.0.3905.1", - "7.0.1": "78.0.3904.92", - "7.1.0": "78.0.3904.94", - "7.1.1": "78.0.3904.99", - "7.1.2": "78.0.3904.113", - "7.1.3": "78.0.3904.126", - "7.1.4": "78.0.3904.130", - "7.1.5": "78.0.3904.130", - "7.1.6": "78.0.3904.130", - "7.1.7": "78.0.3904.130", - "7.1.8": "78.0.3904.130", - "7.1.9": "78.0.3904.130", - "7.1.10": "78.0.3904.130", - "7.1.11": "78.0.3904.130", - "7.1.12": "78.0.3904.130", - "7.1.13": "78.0.3904.130", - "7.1.14": "78.0.3904.130", - "7.2.0": "78.0.3904.130", - "7.2.1": "78.0.3904.130", - "7.2.2": "78.0.3904.130", - "7.2.3": "78.0.3904.130", - "7.2.4": "78.0.3904.130", - "7.3.0": "78.0.3904.130", - "7.3.1": "78.0.3904.130", - "7.3.2": "78.0.3904.130", - "7.3.3": "78.0.3904.130", - "8.0.0-beta.1": "79.0.3931.0", - "8.0.0-beta.2": "79.0.3931.0", - "8.0.0-beta.3": "80.0.3955.0", - "8.0.0-beta.4": "80.0.3955.0", - "8.0.0-beta.5": "80.0.3987.14", - "8.0.0-beta.6": "80.0.3987.51", - "8.0.0-beta.7": "80.0.3987.59", - "8.0.0-beta.8": "80.0.3987.75", - "8.0.0-beta.9": "80.0.3987.75", - "8.0.0-nightly.20190801": "78.0.3866.0", - "8.0.0-nightly.20190802": "78.0.3866.0", - "8.0.0-nightly.20190803": "78.0.3871.0", - "8.0.0-nightly.20190806": "78.0.3871.0", - "8.0.0-nightly.20190807": "78.0.3871.0", - "8.0.0-nightly.20190808": "78.0.3871.0", - "8.0.0-nightly.20190809": "78.0.3871.0", - "8.0.0-nightly.20190810": "78.0.3871.0", - "8.0.0-nightly.20190811": "78.0.3871.0", - "8.0.0-nightly.20190812": "78.0.3871.0", - "8.0.0-nightly.20190813": "78.0.3871.0", - "8.0.0-nightly.20190814": "78.0.3871.0", - "8.0.0-nightly.20190815": "78.0.3871.0", - "8.0.0-nightly.20190816": "78.0.3881.0", - "8.0.0-nightly.20190817": "78.0.3881.0", - "8.0.0-nightly.20190818": "78.0.3881.0", - "8.0.0-nightly.20190819": "78.0.3881.0", - "8.0.0-nightly.20190820": "78.0.3881.0", - "8.0.0-nightly.20190824": "78.0.3892.0", - "8.0.0-nightly.20190825": "78.0.3892.0", - "8.0.0-nightly.20190827": "78.0.3892.0", - "8.0.0-nightly.20190828": "78.0.3892.0", - "8.0.0-nightly.20190830": "78.0.3892.0", - "8.0.0-nightly.20190901": "78.0.3892.0", - "8.0.0-nightly.20190902": "78.0.3892.0", - "8.0.0-nightly.20190907": "78.0.3892.0", - "8.0.0-nightly.20190909": "78.0.3892.0", - "8.0.0-nightly.20190910": "78.0.3892.0", - "8.0.0-nightly.20190911": "78.0.3892.0", - "8.0.0-nightly.20190912": "78.0.3892.0", - "8.0.0-nightly.20190913": "78.0.3892.0", - "8.0.0-nightly.20190914": "78.0.3892.0", - "8.0.0-nightly.20190915": "78.0.3892.0", - "8.0.0-nightly.20190917": "78.0.3892.0", - "8.0.0-nightly.20190919": "79.0.3915.0", - "8.0.0-nightly.20190920": "79.0.3915.0", - "8.0.0-nightly.20190922": "79.0.3919.0", - "8.0.0-nightly.20190923": "79.0.3919.0", - "8.0.0-nightly.20190924": "79.0.3919.0", - "8.0.0-nightly.20190926": "79.0.3919.0", - "8.0.0-nightly.20190928": "79.0.3919.0", - "8.0.0-nightly.20190929": "79.0.3919.0", - "8.0.0-nightly.20190930": "79.0.3919.0", - "8.0.0-nightly.20191001": "79.0.3919.0", - "8.0.0-nightly.20191004": "79.0.3919.0", - "8.0.0-nightly.20191005": "79.0.3919.0", - "8.0.0-nightly.20191006": "79.0.3919.0", - "8.0.0-nightly.20191009": "79.0.3919.0", - "8.0.0-nightly.20191011": "79.0.3919.0", - "8.0.0-nightly.20191012": "79.0.3919.0", - "8.0.0-nightly.20191017": "79.0.3919.0", - "8.0.0-nightly.20191019": "79.0.3931.0", - "8.0.0-nightly.20191020": "79.0.3931.0", - "8.0.0-nightly.20191021": "79.0.3931.0", - "8.0.0-nightly.20191023": "79.0.3931.0", - "8.0.0-nightly.20191101": "80.0.3952.0", - "8.0.0-nightly.20191103": "80.0.3952.0", - "8.0.0-nightly.20191105": "80.0.3952.0", - "8.0.0": "80.0.3987.86", - "8.0.1": "80.0.3987.86", - "8.0.2": "80.0.3987.86", - "8.0.3": "80.0.3987.134", - "8.1.0": "80.0.3987.137", - "8.1.1": "80.0.3987.141", - "8.2.0": "80.0.3987.158", - "8.2.1": "80.0.3987.163", - "8.2.2": "80.0.3987.163", - "8.2.3": "80.0.3987.163", - "8.2.4": "80.0.3987.165", - "8.2.5": "80.0.3987.165", - "8.3.0": "80.0.3987.165", - "8.3.1": "80.0.3987.165", - "8.3.2": "80.0.3987.165", - "8.3.3": "80.0.3987.165", - "8.3.4": "80.0.3987.165", - "8.4.0": "80.0.3987.165", - "8.4.1": "80.0.3987.165", - "8.5.0": "80.0.3987.165", - "8.5.1": "80.0.3987.165", - "8.5.2": "80.0.3987.165", - "8.5.3": "80.0.3987.163", - "8.5.4": "80.0.3987.163", - "8.5.5": "80.0.3987.163", - "9.0.0-beta.1": "82.0.4048.0", - "9.0.0-beta.2": "82.0.4048.0", - "9.0.0-beta.3": "82.0.4048.0", - "9.0.0-beta.4": "82.0.4048.0", - "9.0.0-beta.5": "82.0.4048.0", - "9.0.0-beta.6": "82.0.4058.2", - "9.0.0-beta.7": "82.0.4058.2", - "9.0.0-beta.9": "82.0.4058.2", - "9.0.0-beta.10": "82.0.4085.10", - "9.0.0-beta.11": "82.0.4085.14", - "9.0.0-beta.12": "82.0.4085.14", - "9.0.0-beta.13": "82.0.4085.14", - "9.0.0-beta.14": "82.0.4085.27", - "9.0.0-beta.15": "83.0.4102.3", - "9.0.0-beta.16": "83.0.4102.3", - "9.0.0-beta.17": "83.0.4103.14", - "9.0.0-beta.18": "83.0.4103.16", - "9.0.0-beta.19": "83.0.4103.24", - "9.0.0-beta.20": "83.0.4103.26", - "9.0.0-beta.21": "83.0.4103.26", - "9.0.0-beta.22": "83.0.4103.34", - "9.0.0-beta.23": "83.0.4103.44", - "9.0.0-beta.24": "83.0.4103.45", - "9.0.0-nightly.20191121": "80.0.3954.0", - "9.0.0-nightly.20191122": "80.0.3954.0", - "9.0.0-nightly.20191123": "80.0.3954.0", - "9.0.0-nightly.20191124": "80.0.3954.0", - "9.0.0-nightly.20191126": "80.0.3954.0", - "9.0.0-nightly.20191128": "80.0.3954.0", - "9.0.0-nightly.20191129": "80.0.3954.0", - "9.0.0-nightly.20191130": "80.0.3954.0", - "9.0.0-nightly.20191201": "80.0.3954.0", - "9.0.0-nightly.20191202": "80.0.3954.0", - "9.0.0-nightly.20191203": "80.0.3954.0", - "9.0.0-nightly.20191204": "80.0.3954.0", - "9.0.0-nightly.20191205": "80.0.3954.0", - "9.0.0-nightly.20191210": "80.0.3954.0", - "9.0.0-nightly.20191220": "81.0.3994.0", - "9.0.0-nightly.20191221": "81.0.3994.0", - "9.0.0-nightly.20191222": "81.0.3994.0", - "9.0.0-nightly.20191223": "81.0.3994.0", - "9.0.0-nightly.20191224": "81.0.3994.0", - "9.0.0-nightly.20191225": "81.0.3994.0", - "9.0.0-nightly.20191226": "81.0.3994.0", - "9.0.0-nightly.20191228": "81.0.3994.0", - "9.0.0-nightly.20191229": "81.0.3994.0", - "9.0.0-nightly.20191230": "81.0.3994.0", - "9.0.0-nightly.20191231": "81.0.3994.0", - "9.0.0-nightly.20200101": "81.0.3994.0", - "9.0.0-nightly.20200103": "81.0.3994.0", - "9.0.0-nightly.20200104": "81.0.3994.0", - "9.0.0-nightly.20200105": "81.0.3994.0", - "9.0.0-nightly.20200106": "81.0.3994.0", - "9.0.0-nightly.20200108": "81.0.3994.0", - "9.0.0-nightly.20200109": "81.0.3994.0", - "9.0.0-nightly.20200110": "81.0.3994.0", - "9.0.0-nightly.20200111": "81.0.3994.0", - "9.0.0-nightly.20200113": "81.0.3994.0", - "9.0.0-nightly.20200115": "81.0.3994.0", - "9.0.0-nightly.20200116": "81.0.3994.0", - "9.0.0-nightly.20200117": "81.0.3994.0", - "9.0.0-nightly.20200119": "81.0.4030.0", - "9.0.0-nightly.20200121": "81.0.4030.0", - "9.0.0": "83.0.4103.64", - "9.0.1": "83.0.4103.94", - "9.0.2": "83.0.4103.94", - "9.0.3": "83.0.4103.100", - "9.0.4": "83.0.4103.104", - "9.0.5": "83.0.4103.119", - "9.1.0": "83.0.4103.122", - "9.1.1": "83.0.4103.122", - "9.1.2": "83.0.4103.122", - "9.2.0": "83.0.4103.122", - "9.2.1": "83.0.4103.122", - "9.3.0": "83.0.4103.122", - "9.3.1": "83.0.4103.122", - "9.3.2": "83.0.4103.122", - "9.3.3": "83.0.4103.122", - "9.3.4": "83.0.4103.122", - "9.3.5": "83.0.4103.122", - "9.4.0": "83.0.4103.122", - "9.4.1": "83.0.4103.122", - "9.4.2": "83.0.4103.122", - "9.4.3": "83.0.4103.122", - "9.4.4": "83.0.4103.122", - "10.0.0-beta.1": "84.0.4129.0", - "10.0.0-beta.2": "84.0.4129.0", - "10.0.0-beta.3": "85.0.4161.2", - "10.0.0-beta.4": "85.0.4161.2", - "10.0.0-beta.8": "85.0.4181.1", - "10.0.0-beta.9": "85.0.4181.1", - "10.0.0-beta.10": "85.0.4183.19", - "10.0.0-beta.11": "85.0.4183.20", - "10.0.0-beta.12": "85.0.4183.26", - "10.0.0-beta.13": "85.0.4183.39", - "10.0.0-beta.14": "85.0.4183.39", - "10.0.0-beta.15": "85.0.4183.39", - "10.0.0-beta.17": "85.0.4183.39", - "10.0.0-beta.19": "85.0.4183.39", - "10.0.0-beta.20": "85.0.4183.39", - "10.0.0-beta.21": "85.0.4183.39", - "10.0.0-beta.23": "85.0.4183.70", - "10.0.0-beta.24": "85.0.4183.78", - "10.0.0-beta.25": "85.0.4183.80", - "10.0.0-nightly.20200209": "82.0.4050.0", - "10.0.0-nightly.20200210": "82.0.4050.0", - "10.0.0-nightly.20200211": "82.0.4050.0", - "10.0.0-nightly.20200216": "82.0.4050.0", - "10.0.0-nightly.20200217": "82.0.4050.0", - "10.0.0-nightly.20200218": "82.0.4050.0", - "10.0.0-nightly.20200221": "82.0.4050.0", - "10.0.0-nightly.20200222": "82.0.4050.0", - "10.0.0-nightly.20200223": "82.0.4050.0", - "10.0.0-nightly.20200226": "82.0.4050.0", - "10.0.0-nightly.20200303": "82.0.4050.0", - "10.0.0-nightly.20200304": "82.0.4076.0", - "10.0.0-nightly.20200305": "82.0.4076.0", - "10.0.0-nightly.20200306": "82.0.4076.0", - "10.0.0-nightly.20200309": "82.0.4076.0", - "10.0.0-nightly.20200310": "82.0.4076.0", - "10.0.0-nightly.20200311": "82.0.4083.0", - "10.0.0-nightly.20200316": "83.0.4086.0", - "10.0.0-nightly.20200317": "83.0.4087.0", - "10.0.0-nightly.20200318": "83.0.4087.0", - "10.0.0-nightly.20200320": "83.0.4087.0", - "10.0.0-nightly.20200323": "83.0.4087.0", - "10.0.0-nightly.20200324": "83.0.4087.0", - "10.0.0-nightly.20200325": "83.0.4087.0", - "10.0.0-nightly.20200326": "83.0.4087.0", - "10.0.0-nightly.20200327": "83.0.4087.0", - "10.0.0-nightly.20200330": "83.0.4087.0", - "10.0.0-nightly.20200331": "83.0.4087.0", - "10.0.0-nightly.20200401": "83.0.4087.0", - "10.0.0-nightly.20200402": "83.0.4087.0", - "10.0.0-nightly.20200403": "83.0.4087.0", - "10.0.0-nightly.20200406": "83.0.4087.0", - "10.0.0-nightly.20200408": "83.0.4095.0", - "10.0.0-nightly.20200410": "83.0.4095.0", - "10.0.0-nightly.20200413": "83.0.4095.0", - "10.0.0-nightly.20200414": "84.0.4114.0", - "10.0.0-nightly.20200415": "84.0.4115.0", - "10.0.0-nightly.20200416": "84.0.4115.0", - "10.0.0-nightly.20200417": "84.0.4115.0", - "10.0.0-nightly.20200422": "84.0.4121.0", - "10.0.0-nightly.20200423": "84.0.4121.0", - "10.0.0-nightly.20200427": "84.0.4125.0", - "10.0.0-nightly.20200428": "84.0.4125.0", - "10.0.0-nightly.20200429": "84.0.4125.0", - "10.0.0-nightly.20200430": "84.0.4125.0", - "10.0.0-nightly.20200501": "84.0.4129.0", - "10.0.0-nightly.20200504": "84.0.4129.0", - "10.0.0-nightly.20200505": "84.0.4129.0", - "10.0.0-nightly.20200506": "84.0.4129.0", - "10.0.0-nightly.20200507": "84.0.4129.0", - "10.0.0-nightly.20200508": "84.0.4129.0", - "10.0.0-nightly.20200511": "84.0.4129.0", - "10.0.0-nightly.20200512": "84.0.4129.0", - "10.0.0-nightly.20200513": "84.0.4129.0", - "10.0.0-nightly.20200514": "84.0.4129.0", - "10.0.0-nightly.20200515": "84.0.4129.0", - "10.0.0-nightly.20200518": "84.0.4129.0", - "10.0.0-nightly.20200519": "84.0.4129.0", - "10.0.0-nightly.20200520": "84.0.4129.0", - "10.0.0-nightly.20200521": "84.0.4129.0", - "10.0.0": "85.0.4183.84", - "10.0.1": "85.0.4183.86", - "10.1.0": "85.0.4183.87", - "10.1.1": "85.0.4183.93", - "10.1.2": "85.0.4183.98", - "10.1.3": "85.0.4183.121", - "10.1.4": "85.0.4183.121", - "10.1.5": "85.0.4183.121", - "10.1.6": "85.0.4183.121", - "10.1.7": "85.0.4183.121", - "10.2.0": "85.0.4183.121", - "10.3.0": "85.0.4183.121", - "10.3.1": "85.0.4183.121", - "10.3.2": "85.0.4183.121", - "10.4.0": "85.0.4183.121", - "10.4.1": "85.0.4183.121", - "10.4.2": "85.0.4183.121", - "10.4.3": "85.0.4183.121", - "10.4.4": "85.0.4183.121", - "10.4.5": "85.0.4183.121", - "10.4.6": "85.0.4183.121", - "10.4.7": "85.0.4183.121", - "11.0.0-beta.1": "86.0.4234.0", - "11.0.0-beta.3": "86.0.4234.0", - "11.0.0-beta.4": "86.0.4234.0", - "11.0.0-beta.5": "86.0.4234.0", - "11.0.0-beta.6": "86.0.4234.0", - "11.0.0-beta.7": "86.0.4234.0", - "11.0.0-beta.8": "87.0.4251.1", - "11.0.0-beta.9": "87.0.4251.1", - "11.0.0-beta.11": "87.0.4251.1", - "11.0.0-beta.12": "87.0.4280.11", - "11.0.0-beta.13": "87.0.4280.11", - "11.0.0-beta.16": "87.0.4280.27", - "11.0.0-beta.17": "87.0.4280.27", - "11.0.0-beta.18": "87.0.4280.27", - "11.0.0-beta.19": "87.0.4280.27", - "11.0.0-beta.20": "87.0.4280.40", - "11.0.0-beta.22": "87.0.4280.47", - "11.0.0-beta.23": "87.0.4280.47", - "11.0.0-nightly.20200525": "84.0.4129.0", - "11.0.0-nightly.20200526": "84.0.4129.0", - "11.0.0-nightly.20200529": "85.0.4156.0", - "11.0.0-nightly.20200602": "85.0.4162.0", - "11.0.0-nightly.20200603": "85.0.4162.0", - "11.0.0-nightly.20200604": "85.0.4162.0", - "11.0.0-nightly.20200609": "85.0.4162.0", - "11.0.0-nightly.20200610": "85.0.4162.0", - "11.0.0-nightly.20200611": "85.0.4162.0", - "11.0.0-nightly.20200615": "85.0.4162.0", - "11.0.0-nightly.20200616": "85.0.4162.0", - "11.0.0-nightly.20200617": "85.0.4162.0", - "11.0.0-nightly.20200618": "85.0.4162.0", - "11.0.0-nightly.20200619": "85.0.4162.0", - "11.0.0-nightly.20200701": "85.0.4179.0", - "11.0.0-nightly.20200702": "85.0.4179.0", - "11.0.0-nightly.20200703": "85.0.4179.0", - "11.0.0-nightly.20200706": "85.0.4179.0", - "11.0.0-nightly.20200707": "85.0.4179.0", - "11.0.0-nightly.20200708": "85.0.4179.0", - "11.0.0-nightly.20200709": "85.0.4179.0", - "11.0.0-nightly.20200716": "86.0.4203.0", - "11.0.0-nightly.20200717": "86.0.4203.0", - "11.0.0-nightly.20200720": "86.0.4203.0", - "11.0.0-nightly.20200721": "86.0.4203.0", - "11.0.0-nightly.20200723": "86.0.4209.0", - "11.0.0-nightly.20200724": "86.0.4209.0", - "11.0.0-nightly.20200729": "86.0.4209.0", - "11.0.0-nightly.20200730": "86.0.4209.0", - "11.0.0-nightly.20200731": "86.0.4209.0", - "11.0.0-nightly.20200803": "86.0.4209.0", - "11.0.0-nightly.20200804": "86.0.4209.0", - "11.0.0-nightly.20200805": "86.0.4209.0", - "11.0.0-nightly.20200811": "86.0.4209.0", - "11.0.0-nightly.20200812": "86.0.4209.0", - "11.0.0-nightly.20200822": "86.0.4234.0", - "11.0.0-nightly.20200824": "86.0.4234.0", - "11.0.0-nightly.20200825": "86.0.4234.0", - "11.0.0-nightly.20200826": "86.0.4234.0", - "11.0.0": "87.0.4280.60", - "11.0.1": "87.0.4280.60", - "11.0.2": "87.0.4280.67", - "11.0.3": "87.0.4280.67", - "11.0.4": "87.0.4280.67", - "11.0.5": "87.0.4280.88", - "11.1.0": "87.0.4280.88", - "11.1.1": "87.0.4280.88", - "11.2.0": "87.0.4280.141", - "11.2.1": "87.0.4280.141", - "11.2.2": "87.0.4280.141", - "11.2.3": "87.0.4280.141", - "11.3.0": "87.0.4280.141", - "11.4.0": "87.0.4280.141", - "11.4.1": "87.0.4280.141", - "11.4.2": "87.0.4280.141", - "11.4.3": "87.0.4280.141", - "11.4.4": "87.0.4280.141", - "11.4.5": "87.0.4280.141", - "11.4.6": "87.0.4280.141", - "11.4.7": "87.0.4280.141", - "11.4.8": "87.0.4280.141", - "11.4.9": "87.0.4280.141", - "11.4.10": "87.0.4280.141", - "11.4.11": "87.0.4280.141", - "11.4.12": "87.0.4280.141", - "11.5.0": "87.0.4280.141", - "12.0.0-beta.1": "89.0.4328.0", - "12.0.0-beta.3": "89.0.4328.0", - "12.0.0-beta.4": "89.0.4328.0", - "12.0.0-beta.5": "89.0.4328.0", - "12.0.0-beta.6": "89.0.4328.0", - "12.0.0-beta.7": "89.0.4328.0", - "12.0.0-beta.8": "89.0.4328.0", - "12.0.0-beta.9": "89.0.4328.0", - "12.0.0-beta.10": "89.0.4328.0", - "12.0.0-beta.11": "89.0.4328.0", - "12.0.0-beta.12": "89.0.4328.0", - "12.0.0-beta.14": "89.0.4328.0", - "12.0.0-beta.16": "89.0.4348.1", - "12.0.0-beta.18": "89.0.4348.1", - "12.0.0-beta.19": "89.0.4348.1", - "12.0.0-beta.20": "89.0.4348.1", - "12.0.0-beta.21": "89.0.4388.2", - "12.0.0-beta.22": "89.0.4388.2", - "12.0.0-beta.23": "89.0.4388.2", - "12.0.0-beta.24": "89.0.4388.2", - "12.0.0-beta.25": "89.0.4388.2", - "12.0.0-beta.26": "89.0.4388.2", - "12.0.0-beta.27": "89.0.4389.23", - "12.0.0-beta.28": "89.0.4389.23", - "12.0.0-beta.29": "89.0.4389.23", - "12.0.0-beta.30": "89.0.4389.58", - "12.0.0-beta.31": "89.0.4389.58", - "12.0.0-nightly.20200827": "86.0.4234.0", - "12.0.0-nightly.20200831": "86.0.4234.0", - "12.0.0-nightly.20200902": "86.0.4234.0", - "12.0.0-nightly.20200903": "86.0.4234.0", - "12.0.0-nightly.20200907": "86.0.4234.0", - "12.0.0-nightly.20200910": "86.0.4234.0", - "12.0.0-nightly.20200911": "86.0.4234.0", - "12.0.0-nightly.20200914": "86.0.4234.0", - "12.0.0-nightly.20201002": "87.0.4268.0", - "12.0.0-nightly.20201007": "87.0.4268.0", - "12.0.0-nightly.20201009": "87.0.4268.0", - "12.0.0-nightly.20201012": "87.0.4268.0", - "12.0.0-nightly.20201013": "87.0.4268.0", - "12.0.0-nightly.20201014": "87.0.4268.0", - "12.0.0-nightly.20201015": "87.0.4268.0", - "12.0.0-nightly.20201023": "88.0.4292.0", - "12.0.0-nightly.20201026": "88.0.4292.0", - "12.0.0-nightly.20201030": "88.0.4306.0", - "12.0.0-nightly.20201102": "88.0.4306.0", - "12.0.0-nightly.20201103": "88.0.4306.0", - "12.0.0-nightly.20201104": "88.0.4306.0", - "12.0.0-nightly.20201105": "88.0.4306.0", - "12.0.0-nightly.20201106": "88.0.4306.0", - "12.0.0-nightly.20201111": "88.0.4306.0", - "12.0.0-nightly.20201112": "88.0.4306.0", - "12.0.0-nightly.20201116": "88.0.4324.0", - "12.0.0": "89.0.4389.69", - "12.0.1": "89.0.4389.82", - "12.0.2": "89.0.4389.90", - "12.0.3": "89.0.4389.114", - "12.0.4": "89.0.4389.114", - "12.0.5": "89.0.4389.128", - "12.0.6": "89.0.4389.128", - "12.0.7": "89.0.4389.128", - "12.0.8": "89.0.4389.128", - "12.0.9": "89.0.4389.128", - "12.0.10": "89.0.4389.128", - "12.0.11": "89.0.4389.128", - "12.0.12": "89.0.4389.128", - "12.0.13": "89.0.4389.128", - "12.0.14": "89.0.4389.128", - "12.0.15": "89.0.4389.128", - "12.0.16": "89.0.4389.128", - "12.0.17": "89.0.4389.128", - "12.0.18": "89.0.4389.128", - "12.1.0": "89.0.4389.128", - "12.1.1": "89.0.4389.128", - "12.1.2": "89.0.4389.128", - "12.2.0": "89.0.4389.128", - "12.2.1": "89.0.4389.128", - "12.2.2": "89.0.4389.128", - "12.2.3": "89.0.4389.128", - "13.0.0-beta.2": "90.0.4402.0", - "13.0.0-beta.3": "90.0.4402.0", - "13.0.0-beta.4": "90.0.4415.0", - "13.0.0-beta.5": "90.0.4415.0", - "13.0.0-beta.6": "90.0.4415.0", - "13.0.0-beta.7": "90.0.4415.0", - "13.0.0-beta.8": "90.0.4415.0", - "13.0.0-beta.9": "90.0.4415.0", - "13.0.0-beta.10": "90.0.4415.0", - "13.0.0-beta.11": "90.0.4415.0", - "13.0.0-beta.12": "90.0.4415.0", - "13.0.0-beta.13": "90.0.4415.0", - "13.0.0-beta.14": "91.0.4448.0", - "13.0.0-beta.16": "91.0.4448.0", - "13.0.0-beta.17": "91.0.4448.0", - "13.0.0-beta.18": "91.0.4448.0", - "13.0.0-beta.20": "91.0.4448.0", - "13.0.0-beta.21": "91.0.4472.33", - "13.0.0-beta.22": "91.0.4472.33", - "13.0.0-beta.23": "91.0.4472.33", - "13.0.0-beta.24": "91.0.4472.38", - "13.0.0-beta.25": "91.0.4472.38", - "13.0.0-beta.26": "91.0.4472.38", - "13.0.0-beta.27": "91.0.4472.38", - "13.0.0-beta.28": "91.0.4472.38", - "13.0.0-nightly.20201119": "89.0.4328.0", - "13.0.0-nightly.20201123": "89.0.4328.0", - "13.0.0-nightly.20201124": "89.0.4328.0", - "13.0.0-nightly.20201126": "89.0.4328.0", - "13.0.0-nightly.20201127": "89.0.4328.0", - "13.0.0-nightly.20201130": "89.0.4328.0", - "13.0.0-nightly.20201201": "89.0.4328.0", - "13.0.0-nightly.20201202": "89.0.4328.0", - "13.0.0-nightly.20201203": "89.0.4328.0", - "13.0.0-nightly.20201204": "89.0.4328.0", - "13.0.0-nightly.20201207": "89.0.4328.0", - "13.0.0-nightly.20201208": "89.0.4328.0", - "13.0.0-nightly.20201209": "89.0.4328.0", - "13.0.0-nightly.20201210": "89.0.4328.0", - "13.0.0-nightly.20201211": "89.0.4328.0", - "13.0.0-nightly.20201214": "89.0.4328.0", - "13.0.0-nightly.20201215": "89.0.4349.0", - "13.0.0-nightly.20201216": "89.0.4349.0", - "13.0.0-nightly.20201221": "89.0.4349.0", - "13.0.0-nightly.20201222": "89.0.4349.0", - "13.0.0-nightly.20201223": "89.0.4359.0", - "13.0.0-nightly.20210104": "89.0.4359.0", - "13.0.0-nightly.20210108": "89.0.4359.0", - "13.0.0-nightly.20210111": "89.0.4359.0", - "13.0.0-nightly.20210113": "89.0.4386.0", - "13.0.0-nightly.20210114": "89.0.4386.0", - "13.0.0-nightly.20210118": "89.0.4386.0", - "13.0.0-nightly.20210122": "89.0.4386.0", - "13.0.0-nightly.20210125": "89.0.4386.0", - "13.0.0-nightly.20210127": "89.0.4389.0", - "13.0.0-nightly.20210128": "89.0.4389.0", - "13.0.0-nightly.20210129": "89.0.4389.0", - "13.0.0-nightly.20210201": "89.0.4389.0", - "13.0.0-nightly.20210202": "89.0.4389.0", - "13.0.0-nightly.20210203": "89.0.4389.0", - "13.0.0-nightly.20210205": "89.0.4389.0", - "13.0.0-nightly.20210208": "89.0.4389.0", - "13.0.0-nightly.20210209": "89.0.4389.0", - "13.0.0-nightly.20210210": "90.0.4402.0", - "13.0.0-nightly.20210211": "90.0.4402.0", - "13.0.0-nightly.20210212": "90.0.4402.0", - "13.0.0-nightly.20210216": "90.0.4402.0", - "13.0.0-nightly.20210217": "90.0.4402.0", - "13.0.0-nightly.20210218": "90.0.4402.0", - "13.0.0-nightly.20210219": "90.0.4402.0", - "13.0.0-nightly.20210222": "90.0.4402.0", - "13.0.0-nightly.20210225": "90.0.4402.0", - "13.0.0-nightly.20210226": "90.0.4402.0", - "13.0.0-nightly.20210301": "90.0.4402.0", - "13.0.0-nightly.20210302": "90.0.4402.0", - "13.0.0-nightly.20210303": "90.0.4402.0", - "13.0.0": "91.0.4472.69", - "13.0.1": "91.0.4472.69", - "13.1.0": "91.0.4472.77", - "13.1.1": "91.0.4472.77", - "13.1.2": "91.0.4472.77", - "13.1.3": "91.0.4472.106", - "13.1.4": "91.0.4472.106", - "13.1.5": "91.0.4472.124", - "13.1.6": "91.0.4472.124", - "13.1.7": "91.0.4472.124", - "13.1.8": "91.0.4472.164", - "13.1.9": "91.0.4472.164", - "13.2.0": "91.0.4472.164", - "13.2.1": "91.0.4472.164", - "13.2.2": "91.0.4472.164", - "13.2.3": "91.0.4472.164", - "13.3.0": "91.0.4472.164", - "13.4.0": "91.0.4472.164", - "13.5.0": "91.0.4472.164", - "13.5.1": "91.0.4472.164", - "13.5.2": "91.0.4472.164", - "13.6.0": "91.0.4472.164", - "13.6.1": "91.0.4472.164", - "13.6.2": "91.0.4472.164", - "13.6.3": "91.0.4472.164", - "13.6.6": "91.0.4472.164", - "13.6.7": "91.0.4472.164", - "13.6.8": "91.0.4472.164", - "13.6.9": "91.0.4472.164", - "14.0.0-beta.1": "92.0.4511.0", - "14.0.0-beta.2": "92.0.4511.0", - "14.0.0-beta.3": "92.0.4511.0", - "14.0.0-beta.5": "93.0.4536.0", - "14.0.0-beta.6": "93.0.4536.0", - "14.0.0-beta.7": "93.0.4536.0", - "14.0.0-beta.8": "93.0.4536.0", - "14.0.0-beta.9": "93.0.4539.0", - "14.0.0-beta.10": "93.0.4539.0", - "14.0.0-beta.11": "93.0.4557.4", - "14.0.0-beta.12": "93.0.4557.4", - "14.0.0-beta.13": "93.0.4566.0", - "14.0.0-beta.14": "93.0.4566.0", - "14.0.0-beta.15": "93.0.4566.0", - "14.0.0-beta.16": "93.0.4566.0", - "14.0.0-beta.17": "93.0.4566.0", - "14.0.0-beta.18": "93.0.4577.15", - "14.0.0-beta.19": "93.0.4577.15", - "14.0.0-beta.20": "93.0.4577.15", - "14.0.0-beta.21": "93.0.4577.15", - "14.0.0-beta.22": "93.0.4577.25", - "14.0.0-beta.23": "93.0.4577.25", - "14.0.0-beta.24": "93.0.4577.51", - "14.0.0-beta.25": "93.0.4577.51", - "14.0.0-nightly.20210304": "90.0.4402.0", - "14.0.0-nightly.20210305": "90.0.4415.0", - "14.0.0-nightly.20210308": "90.0.4415.0", - "14.0.0-nightly.20210309": "90.0.4415.0", - "14.0.0-nightly.20210311": "90.0.4415.0", - "14.0.0-nightly.20210315": "90.0.4415.0", - "14.0.0-nightly.20210316": "90.0.4415.0", - "14.0.0-nightly.20210317": "90.0.4415.0", - "14.0.0-nightly.20210318": "90.0.4415.0", - "14.0.0-nightly.20210319": "90.0.4415.0", - "14.0.0-nightly.20210323": "90.0.4415.0", - "14.0.0-nightly.20210324": "90.0.4415.0", - "14.0.0-nightly.20210325": "90.0.4415.0", - "14.0.0-nightly.20210326": "90.0.4415.0", - "14.0.0-nightly.20210329": "90.0.4415.0", - "14.0.0-nightly.20210330": "90.0.4415.0", - "14.0.0-nightly.20210331": "91.0.4448.0", - "14.0.0-nightly.20210401": "91.0.4448.0", - "14.0.0-nightly.20210402": "91.0.4448.0", - "14.0.0-nightly.20210406": "91.0.4448.0", - "14.0.0-nightly.20210407": "91.0.4448.0", - "14.0.0-nightly.20210408": "91.0.4448.0", - "14.0.0-nightly.20210409": "91.0.4448.0", - "14.0.0-nightly.20210413": "91.0.4448.0", - "14.0.0-nightly.20210426": "92.0.4475.0", - "14.0.0-nightly.20210427": "92.0.4475.0", - "14.0.0-nightly.20210430": "92.0.4488.0", - "14.0.0-nightly.20210503": "92.0.4488.0", - "14.0.0-nightly.20210505": "92.0.4496.0", - "14.0.0-nightly.20210506": "92.0.4498.0", - "14.0.0-nightly.20210507": "92.0.4499.0", - "14.0.0-nightly.20210510": "92.0.4499.0", - "14.0.0-nightly.20210511": "92.0.4499.0", - "14.0.0-nightly.20210512": "92.0.4499.0", - "14.0.0-nightly.20210513": "92.0.4499.0", - "14.0.0-nightly.20210514": "92.0.4505.0", - "14.0.0-nightly.20210517": "92.0.4505.0", - "14.0.0-nightly.20210518": "92.0.4505.0", - "14.0.0-nightly.20210519": "92.0.4505.0", - "14.0.0-nightly.20210520": "92.0.4511.0", - "14.0.0-nightly.20210523": "92.0.4511.0", - "14.0.0-nightly.20210524": "92.0.4511.0", - "14.0.0": "93.0.4577.58", - "14.0.1": "93.0.4577.63", - "14.0.2": "93.0.4577.82", - "14.1.0": "93.0.4577.82", - "14.1.1": "93.0.4577.82", - "14.2.0": "93.0.4577.82", - "14.2.1": "93.0.4577.82", - "14.2.2": "93.0.4577.82", - "14.2.3": "93.0.4577.82", - "14.2.4": "93.0.4577.82", - "14.2.5": "93.0.4577.82", - "14.2.6": "93.0.4577.82", - "14.2.7": "93.0.4577.82", - "14.2.8": "93.0.4577.82", - "14.2.9": "93.0.4577.82", - "15.0.0-alpha.1": "93.0.4566.0", - "15.0.0-alpha.2": "93.0.4566.0", - "15.0.0-alpha.3": "94.0.4584.0", - "15.0.0-alpha.4": "94.0.4584.0", - "15.0.0-alpha.5": "94.0.4584.0", - "15.0.0-alpha.6": "94.0.4584.0", - "15.0.0-alpha.7": "94.0.4590.2", - "15.0.0-alpha.8": "94.0.4590.2", - "15.0.0-alpha.9": "94.0.4590.2", - "15.0.0-alpha.10": "94.0.4606.12", - "15.0.0-beta.1": "94.0.4606.20", - "15.0.0-beta.2": "94.0.4606.20", - "15.0.0-beta.3": "94.0.4606.31", - "15.0.0-beta.4": "94.0.4606.31", - "15.0.0-beta.5": "94.0.4606.31", - "15.0.0-beta.6": "94.0.4606.31", - "15.0.0-beta.7": "94.0.4606.31", - "15.0.0-nightly.20210527": "92.0.4511.0", - "15.0.0-nightly.20210528": "92.0.4511.0", - "15.0.0-nightly.20210531": "92.0.4511.0", - "15.0.0-nightly.20210601": "92.0.4511.0", - "15.0.0-nightly.20210602": "92.0.4511.0", - "15.0.0-nightly.20210603": "93.0.4530.0", - "15.0.0-nightly.20210604": "93.0.4530.0", - "15.0.0-nightly.20210608": "93.0.4535.0", - "15.0.0-nightly.20210609": "93.0.4536.0", - "15.0.0-nightly.20210610": "93.0.4536.0", - "15.0.0-nightly.20210611": "93.0.4536.0", - "15.0.0-nightly.20210614": "93.0.4536.0", - "15.0.0-nightly.20210615": "93.0.4536.0", - "15.0.0-nightly.20210616": "93.0.4536.0", - "15.0.0-nightly.20210617": "93.0.4539.0", - "15.0.0-nightly.20210618": "93.0.4539.0", - "15.0.0-nightly.20210621": "93.0.4539.0", - "15.0.0-nightly.20210622": "93.0.4539.0", - "15.0.0-nightly.20210623": "93.0.4550.0", - "15.0.0-nightly.20210624": "93.0.4550.0", - "15.0.0-nightly.20210625": "93.0.4552.0", - "15.0.0-nightly.20210628": "93.0.4552.0", - "15.0.0-nightly.20210629": "93.0.4552.0", - "15.0.0-nightly.20210630": "93.0.4558.0", - "15.0.0-nightly.20210701": "93.0.4558.0", - "15.0.0-nightly.20210702": "93.0.4558.0", - "15.0.0-nightly.20210705": "93.0.4558.0", - "15.0.0-nightly.20210706": "93.0.4566.0", - "15.0.0-nightly.20210707": "93.0.4566.0", - "15.0.0-nightly.20210708": "93.0.4566.0", - "15.0.0-nightly.20210709": "93.0.4566.0", - "15.0.0-nightly.20210712": "93.0.4566.0", - "15.0.0-nightly.20210713": "93.0.4566.0", - "15.0.0-nightly.20210714": "93.0.4566.0", - "15.0.0-nightly.20210715": "93.0.4566.0", - "15.0.0-nightly.20210716": "93.0.4566.0", - "15.0.0-nightly.20210719": "93.0.4566.0", - "15.0.0-nightly.20210720": "93.0.4566.0", - "15.0.0-nightly.20210721": "93.0.4566.0", - "15.0.0": "94.0.4606.51", - "15.1.0": "94.0.4606.61", - "15.1.1": "94.0.4606.61", - "15.1.2": "94.0.4606.71", - "15.2.0": "94.0.4606.81", - "15.3.0": "94.0.4606.81", - "15.3.1": "94.0.4606.81", - "15.3.2": "94.0.4606.81", - "15.3.3": "94.0.4606.81", - "15.3.4": "94.0.4606.81", - "15.3.5": "94.0.4606.81", - "15.3.6": "94.0.4606.81", - "15.3.7": "94.0.4606.81", - "15.4.0": "94.0.4606.81", - "15.4.1": "94.0.4606.81", - "15.4.2": "94.0.4606.81", - "15.5.0": "94.0.4606.81", - "15.5.1": "94.0.4606.81", - "15.5.2": "94.0.4606.81", - "15.5.3": "94.0.4606.81", - "15.5.4": "94.0.4606.81", - "15.5.5": "94.0.4606.81", - "15.5.6": "94.0.4606.81", - "15.5.7": "94.0.4606.81", - "16.0.0-alpha.1": "95.0.4629.0", - "16.0.0-alpha.2": "95.0.4629.0", - "16.0.0-alpha.3": "95.0.4629.0", - "16.0.0-alpha.4": "95.0.4629.0", - "16.0.0-alpha.5": "95.0.4629.0", - "16.0.0-alpha.6": "95.0.4629.0", - "16.0.0-alpha.7": "95.0.4629.0", - "16.0.0-alpha.8": "96.0.4647.0", - "16.0.0-alpha.9": "96.0.4647.0", - "16.0.0-beta.1": "96.0.4647.0", - "16.0.0-beta.2": "96.0.4647.0", - "16.0.0-beta.3": "96.0.4647.0", - "16.0.0-beta.4": "96.0.4664.18", - "16.0.0-beta.5": "96.0.4664.18", - "16.0.0-beta.6": "96.0.4664.27", - "16.0.0-beta.7": "96.0.4664.27", - "16.0.0-beta.8": "96.0.4664.35", - "16.0.0-beta.9": "96.0.4664.35", - "16.0.0-nightly.20210722": "93.0.4566.0", - "16.0.0-nightly.20210723": "93.0.4566.0", - "16.0.0-nightly.20210726": "93.0.4566.0", - "16.0.0-nightly.20210727": "94.0.4584.0", - "16.0.0-nightly.20210728": "94.0.4584.0", - "16.0.0-nightly.20210729": "94.0.4584.0", - "16.0.0-nightly.20210730": "94.0.4584.0", - "16.0.0-nightly.20210802": "94.0.4584.0", - "16.0.0-nightly.20210803": "94.0.4584.0", - "16.0.0-nightly.20210804": "94.0.4584.0", - "16.0.0-nightly.20210805": "94.0.4584.0", - "16.0.0-nightly.20210806": "94.0.4584.0", - "16.0.0-nightly.20210809": "94.0.4584.0", - "16.0.0-nightly.20210810": "94.0.4584.0", - "16.0.0-nightly.20210811": "94.0.4584.0", - "16.0.0-nightly.20210812": "94.0.4590.2", - "16.0.0-nightly.20210813": "94.0.4590.2", - "16.0.0-nightly.20210816": "94.0.4590.2", - "16.0.0-nightly.20210817": "94.0.4590.2", - "16.0.0-nightly.20210818": "94.0.4590.2", - "16.0.0-nightly.20210819": "94.0.4590.2", - "16.0.0-nightly.20210820": "94.0.4590.2", - "16.0.0-nightly.20210823": "94.0.4590.2", - "16.0.0-nightly.20210824": "95.0.4612.5", - "16.0.0-nightly.20210825": "95.0.4612.5", - "16.0.0-nightly.20210826": "95.0.4612.5", - "16.0.0-nightly.20210827": "95.0.4612.5", - "16.0.0-nightly.20210830": "95.0.4612.5", - "16.0.0-nightly.20210831": "95.0.4612.5", - "16.0.0-nightly.20210901": "95.0.4612.5", - "16.0.0-nightly.20210902": "95.0.4629.0", - "16.0.0-nightly.20210903": "95.0.4629.0", - "16.0.0-nightly.20210906": "95.0.4629.0", - "16.0.0-nightly.20210907": "95.0.4629.0", - "16.0.0-nightly.20210908": "95.0.4629.0", - "16.0.0-nightly.20210909": "95.0.4629.0", - "16.0.0-nightly.20210910": "95.0.4629.0", - "16.0.0-nightly.20210913": "95.0.4629.0", - "16.0.0-nightly.20210914": "95.0.4629.0", - "16.0.0-nightly.20210915": "95.0.4629.0", - "16.0.0-nightly.20210916": "95.0.4629.0", - "16.0.0-nightly.20210917": "95.0.4629.0", - "16.0.0-nightly.20210920": "95.0.4629.0", - "16.0.0-nightly.20210921": "95.0.4629.0", - "16.0.0-nightly.20210922": "95.0.4629.0", - "16.0.0": "96.0.4664.45", - "16.0.1": "96.0.4664.45", - "16.0.2": "96.0.4664.55", - "16.0.3": "96.0.4664.55", - "16.0.4": "96.0.4664.55", - "16.0.5": "96.0.4664.55", - "16.0.6": "96.0.4664.110", - "16.0.7": "96.0.4664.110", - "16.0.8": "96.0.4664.110", - "16.0.9": "96.0.4664.174", - "16.0.10": "96.0.4664.174", - "16.1.0": "96.0.4664.174", - "16.1.1": "96.0.4664.174", - "16.2.0": "96.0.4664.174", - "16.2.1": "96.0.4664.174", - "16.2.2": "96.0.4664.174", - "16.2.3": "96.0.4664.174", - "16.2.4": "96.0.4664.174", - "16.2.5": "96.0.4664.174", - "16.2.6": "96.0.4664.174", - "16.2.7": "96.0.4664.174", - "16.2.8": "96.0.4664.174", - "17.0.0-alpha.1": "96.0.4664.4", - "17.0.0-alpha.2": "96.0.4664.4", - "17.0.0-alpha.3": "96.0.4664.4", - "17.0.0-alpha.4": "98.0.4706.0", - "17.0.0-alpha.5": "98.0.4706.0", - "17.0.0-alpha.6": "98.0.4706.0", - "17.0.0-beta.1": "98.0.4706.0", - "17.0.0-beta.2": "98.0.4706.0", - "17.0.0-beta.3": "98.0.4758.9", - "17.0.0-beta.4": "98.0.4758.11", - "17.0.0-beta.5": "98.0.4758.11", - "17.0.0-beta.6": "98.0.4758.11", - "17.0.0-beta.7": "98.0.4758.11", - "17.0.0-beta.8": "98.0.4758.11", - "17.0.0-beta.9": "98.0.4758.11", - "17.0.0-nightly.20210923": "95.0.4629.0", - "17.0.0-nightly.20210924": "95.0.4629.0", - "17.0.0-nightly.20210927": "95.0.4629.0", - "17.0.0-nightly.20210928": "95.0.4629.0", - "17.0.0-nightly.20210929": "95.0.4629.0", - "17.0.0-nightly.20210930": "95.0.4629.0", - "17.0.0-nightly.20211001": "95.0.4629.0", - "17.0.0-nightly.20211004": "95.0.4629.0", - "17.0.0-nightly.20211005": "95.0.4629.0", - "17.0.0-nightly.20211006": "96.0.4647.0", - "17.0.0-nightly.20211007": "96.0.4647.0", - "17.0.0-nightly.20211008": "96.0.4647.0", - "17.0.0-nightly.20211011": "96.0.4647.0", - "17.0.0-nightly.20211012": "96.0.4647.0", - "17.0.0-nightly.20211013": "96.0.4647.0", - "17.0.0-nightly.20211014": "96.0.4647.0", - "17.0.0-nightly.20211015": "96.0.4647.0", - "17.0.0-nightly.20211018": "96.0.4647.0", - "17.0.0-nightly.20211019": "96.0.4647.0", - "17.0.0-nightly.20211020": "96.0.4647.0", - "17.0.0-nightly.20211021": "96.0.4647.0", - "17.0.0-nightly.20211022": "96.0.4664.4", - "17.0.0-nightly.20211025": "96.0.4664.4", - "17.0.0-nightly.20211026": "96.0.4664.4", - "17.0.0-nightly.20211027": "96.0.4664.4", - "17.0.0-nightly.20211028": "96.0.4664.4", - "17.0.0-nightly.20211029": "96.0.4664.4", - "17.0.0-nightly.20211101": "96.0.4664.4", - "17.0.0-nightly.20211102": "96.0.4664.4", - "17.0.0-nightly.20211103": "96.0.4664.4", - "17.0.0-nightly.20211104": "96.0.4664.4", - "17.0.0-nightly.20211105": "96.0.4664.4", - "17.0.0-nightly.20211108": "96.0.4664.4", - "17.0.0-nightly.20211109": "96.0.4664.4", - "17.0.0-nightly.20211110": "96.0.4664.4", - "17.0.0-nightly.20211111": "96.0.4664.4", - "17.0.0-nightly.20211112": "96.0.4664.4", - "17.0.0-nightly.20211115": "96.0.4664.4", - "17.0.0-nightly.20211116": "96.0.4664.4", - "17.0.0-nightly.20211117": "96.0.4664.4", - "17.0.0": "98.0.4758.74", - "17.0.1": "98.0.4758.82", - "17.1.0": "98.0.4758.102", - "17.1.1": "98.0.4758.109", - "17.1.2": "98.0.4758.109", - "17.2.0": "98.0.4758.109", - "17.3.0": "98.0.4758.141", - "17.3.1": "98.0.4758.141", - "17.4.0": "98.0.4758.141", - "17.4.1": "98.0.4758.141", - "17.4.2": "98.0.4758.141", - "17.4.3": "98.0.4758.141", - "17.4.4": "98.0.4758.141", - "17.4.5": "98.0.4758.141", - "17.4.6": "98.0.4758.141", - "17.4.7": "98.0.4758.141", - "17.4.8": "98.0.4758.141", - "17.4.9": "98.0.4758.141", - "17.4.10": "98.0.4758.141", - "17.4.11": "98.0.4758.141", - "18.0.0-alpha.1": "99.0.4767.0", - "18.0.0-alpha.2": "99.0.4767.0", - "18.0.0-alpha.3": "99.0.4767.0", - "18.0.0-alpha.4": "99.0.4767.0", - "18.0.0-alpha.5": "99.0.4767.0", - "18.0.0-beta.1": "100.0.4894.0", - "18.0.0-beta.2": "100.0.4894.0", - "18.0.0-beta.3": "100.0.4894.0", - "18.0.0-beta.4": "100.0.4894.0", - "18.0.0-beta.5": "100.0.4894.0", - "18.0.0-beta.6": "100.0.4894.0", - "18.0.0-nightly.20211118": "96.0.4664.4", - "18.0.0-nightly.20211119": "96.0.4664.4", - "18.0.0-nightly.20211122": "96.0.4664.4", - "18.0.0-nightly.20211123": "96.0.4664.4", - "18.0.0-nightly.20211124": "98.0.4706.0", - "18.0.0-nightly.20211125": "98.0.4706.0", - "18.0.0-nightly.20211126": "98.0.4706.0", - "18.0.0-nightly.20211129": "98.0.4706.0", - "18.0.0-nightly.20211130": "98.0.4706.0", - "18.0.0-nightly.20211201": "98.0.4706.0", - "18.0.0-nightly.20211202": "98.0.4706.0", - "18.0.0-nightly.20211203": "98.0.4706.0", - "18.0.0-nightly.20211206": "98.0.4706.0", - "18.0.0-nightly.20211207": "98.0.4706.0", - "18.0.0-nightly.20211208": "98.0.4706.0", - "18.0.0-nightly.20211209": "98.0.4706.0", - "18.0.0-nightly.20211210": "98.0.4706.0", - "18.0.0-nightly.20211213": "98.0.4706.0", - "18.0.0-nightly.20211214": "98.0.4706.0", - "18.0.0-nightly.20211215": "98.0.4706.0", - "18.0.0-nightly.20211216": "98.0.4706.0", - "18.0.0-nightly.20211217": "98.0.4706.0", - "18.0.0-nightly.20211220": "98.0.4706.0", - "18.0.0-nightly.20211221": "98.0.4706.0", - "18.0.0-nightly.20211222": "98.0.4706.0", - "18.0.0-nightly.20211223": "98.0.4706.0", - "18.0.0-nightly.20211228": "98.0.4706.0", - "18.0.0-nightly.20211229": "98.0.4706.0", - "18.0.0-nightly.20211231": "98.0.4706.0", - "18.0.0-nightly.20220103": "98.0.4706.0", - "18.0.0-nightly.20220104": "98.0.4706.0", - "18.0.0-nightly.20220105": "98.0.4706.0", - "18.0.0-nightly.20220106": "98.0.4706.0", - "18.0.0-nightly.20220107": "98.0.4706.0", - "18.0.0-nightly.20220110": "98.0.4706.0", - "18.0.0-nightly.20220111": "99.0.4767.0", - "18.0.0-nightly.20220112": "99.0.4767.0", - "18.0.0-nightly.20220113": "99.0.4767.0", - "18.0.0-nightly.20220114": "99.0.4767.0", - "18.0.0-nightly.20220117": "99.0.4767.0", - "18.0.0-nightly.20220118": "99.0.4767.0", - "18.0.0-nightly.20220119": "99.0.4767.0", - "18.0.0-nightly.20220121": "99.0.4767.0", - "18.0.0-nightly.20220124": "99.0.4767.0", - "18.0.0-nightly.20220125": "99.0.4767.0", - "18.0.0-nightly.20220127": "99.0.4767.0", - "18.0.0-nightly.20220128": "99.0.4767.0", - "18.0.0-nightly.20220131": "99.0.4767.0", - "18.0.0-nightly.20220201": "99.0.4767.0", - "18.0.0": "100.0.4896.56", - "18.0.1": "100.0.4896.60", - "18.0.2": "100.0.4896.60", - "18.0.3": "100.0.4896.75", - "18.0.4": "100.0.4896.75", - "18.1.0": "100.0.4896.127", - "18.2.0": "100.0.4896.143", - "18.2.1": "100.0.4896.143", - "18.2.2": "100.0.4896.143", - "18.2.3": "100.0.4896.143", - "18.2.4": "100.0.4896.160", - "18.3.0": "100.0.4896.160", - "18.3.1": "100.0.4896.160", - "18.3.2": "100.0.4896.160", - "18.3.3": "100.0.4896.160", - "18.3.4": "100.0.4896.160", - "18.3.5": "100.0.4896.160", - "18.3.6": "100.0.4896.160", - "18.3.7": "100.0.4896.160", - "18.3.8": "100.0.4896.160", - "18.3.9": "100.0.4896.160", - "18.3.11": "100.0.4896.160", - "18.3.12": "100.0.4896.160", - "18.3.13": "100.0.4896.160", - "18.3.14": "100.0.4896.160", - "18.3.15": "100.0.4896.160", - "19.0.0-alpha.1": "102.0.4962.3", - "19.0.0-alpha.2": "102.0.4971.0", - "19.0.0-alpha.3": "102.0.4971.0", - "19.0.0-alpha.4": "102.0.4989.0", - "19.0.0-alpha.5": "102.0.4989.0", - "19.0.0-beta.1": "102.0.4999.0", - "19.0.0-beta.2": "102.0.4999.0", - "19.0.0-beta.3": "102.0.4999.0", - "19.0.0-beta.4": "102.0.5005.27", - "19.0.0-beta.5": "102.0.5005.40", - "19.0.0-beta.6": "102.0.5005.40", - "19.0.0-beta.7": "102.0.5005.40", - "19.0.0-beta.8": "102.0.5005.49", - "19.0.0-nightly.20220202": "99.0.4767.0", - "19.0.0-nightly.20220203": "99.0.4767.0", - "19.0.0-nightly.20220204": "99.0.4767.0", - "19.0.0-nightly.20220207": "99.0.4767.0", - "19.0.0-nightly.20220208": "99.0.4767.0", - "19.0.0-nightly.20220209": "99.0.4767.0", - "19.0.0-nightly.20220308": "100.0.4894.0", - "19.0.0-nightly.20220309": "100.0.4894.0", - "19.0.0-nightly.20220310": "100.0.4894.0", - "19.0.0-nightly.20220311": "100.0.4894.0", - "19.0.0-nightly.20220314": "100.0.4894.0", - "19.0.0-nightly.20220315": "100.0.4894.0", - "19.0.0-nightly.20220316": "100.0.4894.0", - "19.0.0-nightly.20220317": "100.0.4894.0", - "19.0.0-nightly.20220318": "100.0.4894.0", - "19.0.0-nightly.20220321": "100.0.4894.0", - "19.0.0-nightly.20220322": "100.0.4894.0", - "19.0.0-nightly.20220323": "100.0.4894.0", - "19.0.0-nightly.20220324": "100.0.4894.0", - "19.0.0-nightly.20220325": "102.0.4961.0", - "19.0.0-nightly.20220328": "102.0.4962.3", - "19.0.0-nightly.20220329": "102.0.4962.3", - "19.0.0": "102.0.5005.61", - "19.0.1": "102.0.5005.61", - "19.0.2": "102.0.5005.63", - "19.0.3": "102.0.5005.63", - "19.0.4": "102.0.5005.63", - "19.0.5": "102.0.5005.115", - "19.0.6": "102.0.5005.115", - "19.0.7": "102.0.5005.134", - "19.0.8": "102.0.5005.148", - "19.0.9": "102.0.5005.167", - "19.0.10": "102.0.5005.167", - "19.0.11": "102.0.5005.167", - "19.0.12": "102.0.5005.167", - "19.0.13": "102.0.5005.167", - "19.0.14": "102.0.5005.167", - "19.0.15": "102.0.5005.167", - "19.0.16": "102.0.5005.167", - "19.0.17": "102.0.5005.167", - "19.1.0": "102.0.5005.167", - "19.1.1": "102.0.5005.167", - "19.1.2": "102.0.5005.167", - "19.1.3": "102.0.5005.167", - "19.1.4": "102.0.5005.167", - "19.1.5": "102.0.5005.167", - "19.1.6": "102.0.5005.167", - "19.1.7": "102.0.5005.167", - "19.1.8": "102.0.5005.167", - "19.1.9": "102.0.5005.167", - "20.0.0-alpha.1": "103.0.5044.0", - "20.0.0-alpha.2": "104.0.5073.0", - "20.0.0-alpha.3": "104.0.5073.0", - "20.0.0-alpha.4": "104.0.5073.0", - "20.0.0-alpha.5": "104.0.5073.0", - "20.0.0-alpha.6": "104.0.5073.0", - "20.0.0-alpha.7": "104.0.5073.0", - "20.0.0-beta.1": "104.0.5073.0", - "20.0.0-beta.2": "104.0.5073.0", - "20.0.0-beta.3": "104.0.5073.0", - "20.0.0-beta.4": "104.0.5073.0", - "20.0.0-beta.5": "104.0.5073.0", - "20.0.0-beta.6": "104.0.5073.0", - "20.0.0-beta.7": "104.0.5073.0", - "20.0.0-beta.8": "104.0.5073.0", - "20.0.0-beta.9": "104.0.5112.39", - "20.0.0-beta.10": "104.0.5112.48", - "20.0.0-beta.11": "104.0.5112.48", - "20.0.0-beta.12": "104.0.5112.48", - "20.0.0-beta.13": "104.0.5112.57", - "20.0.0-nightly.20220330": "102.0.4962.3", - "20.0.0-nightly.20220411": "102.0.4971.0", - "20.0.0-nightly.20220414": "102.0.4989.0", - "20.0.0-nightly.20220415": "102.0.4989.0", - "20.0.0-nightly.20220418": "102.0.4989.0", - "20.0.0-nightly.20220419": "102.0.4989.0", - "20.0.0-nightly.20220420": "102.0.4989.0", - "20.0.0-nightly.20220421": "102.0.4989.0", - "20.0.0-nightly.20220425": "102.0.4999.0", - "20.0.0-nightly.20220426": "102.0.4999.0", - "20.0.0-nightly.20220427": "102.0.4999.0", - "20.0.0-nightly.20220428": "102.0.4999.0", - "20.0.0-nightly.20220429": "102.0.4999.0", - "20.0.0-nightly.20220502": "102.0.4999.0", - "20.0.0-nightly.20220503": "102.0.4999.0", - "20.0.0-nightly.20220504": "102.0.4999.0", - "20.0.0-nightly.20220505": "102.0.4999.0", - "20.0.0-nightly.20220506": "102.0.4999.0", - "20.0.0-nightly.20220509": "102.0.4999.0", - "20.0.0-nightly.20220511": "102.0.4999.0", - "20.0.0-nightly.20220512": "102.0.4999.0", - "20.0.0-nightly.20220513": "102.0.4999.0", - "20.0.0-nightly.20220516": "102.0.4999.0", - "20.0.0-nightly.20220517": "102.0.4999.0", - "20.0.0-nightly.20220518": "103.0.5044.0", - "20.0.0-nightly.20220519": "103.0.5044.0", - "20.0.0-nightly.20220520": "103.0.5044.0", - "20.0.0-nightly.20220523": "103.0.5044.0", - "20.0.0-nightly.20220524": "103.0.5044.0", - "20.0.0": "104.0.5112.65", - "20.0.1": "104.0.5112.81", - "20.0.2": "104.0.5112.81", - "20.0.3": "104.0.5112.81", - "20.1.0": "104.0.5112.102", - "20.1.1": "104.0.5112.102", - "20.1.2": "104.0.5112.114", - "20.1.3": "104.0.5112.114", - "20.1.4": "104.0.5112.114", - "20.2.0": "104.0.5112.124", - "20.3.0": "104.0.5112.124", - "20.3.1": "104.0.5112.124", - "20.3.2": "104.0.5112.124", - "20.3.3": "104.0.5112.124", - "20.3.4": "104.0.5112.124", - "20.3.5": "104.0.5112.124", - "20.3.6": "104.0.5112.124", - "20.3.7": "104.0.5112.124", - "20.3.8": "104.0.5112.124", - "20.3.9": "104.0.5112.124", - "20.3.10": "104.0.5112.124", - "20.3.11": "104.0.5112.124", - "20.3.12": "104.0.5112.124", - "21.0.0-alpha.1": "105.0.5187.0", - "21.0.0-alpha.2": "105.0.5187.0", - "21.0.0-alpha.3": "105.0.5187.0", - "21.0.0-alpha.4": "105.0.5187.0", - "21.0.0-alpha.5": "105.0.5187.0", - "21.0.0-alpha.6": "106.0.5216.0", - "21.0.0-beta.1": "106.0.5216.0", - "21.0.0-beta.2": "106.0.5216.0", - "21.0.0-beta.3": "106.0.5216.0", - "21.0.0-beta.4": "106.0.5216.0", - "21.0.0-beta.5": "106.0.5216.0", - "21.0.0-beta.6": "106.0.5249.40", - "21.0.0-beta.7": "106.0.5249.40", - "21.0.0-beta.8": "106.0.5249.40", - "21.0.0-nightly.20220526": "103.0.5044.0", - "21.0.0-nightly.20220527": "103.0.5044.0", - "21.0.0-nightly.20220530": "103.0.5044.0", - "21.0.0-nightly.20220531": "103.0.5044.0", - "21.0.0-nightly.20220602": "104.0.5073.0", - "21.0.0-nightly.20220603": "104.0.5073.0", - "21.0.0-nightly.20220606": "104.0.5073.0", - "21.0.0-nightly.20220607": "104.0.5073.0", - "21.0.0-nightly.20220608": "104.0.5073.0", - "21.0.0-nightly.20220609": "104.0.5073.0", - "21.0.0-nightly.20220610": "104.0.5073.0", - "21.0.0-nightly.20220613": "104.0.5073.0", - "21.0.0-nightly.20220614": "104.0.5073.0", - "21.0.0-nightly.20220615": "104.0.5073.0", - "21.0.0-nightly.20220616": "104.0.5073.0", - "21.0.0-nightly.20220617": "104.0.5073.0", - "21.0.0-nightly.20220620": "104.0.5073.0", - "21.0.0-nightly.20220621": "104.0.5073.0", - "21.0.0-nightly.20220622": "104.0.5073.0", - "21.0.0-nightly.20220623": "104.0.5073.0", - "21.0.0-nightly.20220624": "104.0.5073.0", - "21.0.0-nightly.20220627": "104.0.5073.0", - "21.0.0-nightly.20220628": "105.0.5129.0", - "21.0.0-nightly.20220629": "105.0.5129.0", - "21.0.0-nightly.20220630": "105.0.5129.0", - "21.0.0-nightly.20220701": "105.0.5129.0", - "21.0.0-nightly.20220704": "105.0.5129.0", - "21.0.0-nightly.20220705": "105.0.5129.0", - "21.0.0-nightly.20220706": "105.0.5129.0", - "21.0.0-nightly.20220707": "105.0.5129.0", - "21.0.0-nightly.20220708": "105.0.5129.0", - "21.0.0-nightly.20220711": "105.0.5129.0", - "21.0.0-nightly.20220712": "105.0.5129.0", - "21.0.0-nightly.20220713": "105.0.5129.0", - "21.0.0-nightly.20220715": "105.0.5173.0", - "21.0.0-nightly.20220718": "105.0.5173.0", - "21.0.0-nightly.20220719": "105.0.5173.0", - "21.0.0-nightly.20220720": "105.0.5187.0", - "21.0.0-nightly.20220721": "105.0.5187.0", - "21.0.0-nightly.20220722": "105.0.5187.0", - "21.0.0-nightly.20220725": "105.0.5187.0", - "21.0.0-nightly.20220726": "105.0.5187.0", - "21.0.0-nightly.20220727": "105.0.5187.0", - "21.0.0-nightly.20220728": "105.0.5187.0", - "21.0.0-nightly.20220801": "105.0.5187.0", - "21.0.0-nightly.20220802": "105.0.5187.0", - "21.0.0": "106.0.5249.51", - "21.0.1": "106.0.5249.61", - "21.1.0": "106.0.5249.91", - "21.1.1": "106.0.5249.103", - "21.2.0": "106.0.5249.119", - "21.2.1": "106.0.5249.165", - "21.2.2": "106.0.5249.168", - "21.2.3": "106.0.5249.168", - "21.3.0": "106.0.5249.181", - "21.3.1": "106.0.5249.181", - "21.3.3": "106.0.5249.199", - "21.3.4": "106.0.5249.199", - "21.3.5": "106.0.5249.199", - "21.4.0": "106.0.5249.199", - "21.4.1": "106.0.5249.199", - "21.4.2": "106.0.5249.199", - "21.4.3": "106.0.5249.199", - "21.4.4": "106.0.5249.199", - "22.0.0-alpha.1": "107.0.5286.0", - "22.0.0-alpha.3": "108.0.5329.0", - "22.0.0-alpha.4": "108.0.5329.0", - "22.0.0-alpha.5": "108.0.5329.0", - "22.0.0-alpha.6": "108.0.5329.0", - "22.0.0-alpha.7": "108.0.5355.0", - "22.0.0-alpha.8": "108.0.5359.10", - "22.0.0-beta.1": "108.0.5359.10", - "22.0.0-beta.2": "108.0.5359.10", - "22.0.0-beta.3": "108.0.5359.10", - "22.0.0-beta.4": "108.0.5359.29", - "22.0.0-beta.5": "108.0.5359.40", - "22.0.0-beta.6": "108.0.5359.40", - "22.0.0-beta.7": "108.0.5359.48", - "22.0.0-beta.8": "108.0.5359.48", - "22.0.0-nightly.20220808": "105.0.5187.0", - "22.0.0-nightly.20220809": "105.0.5187.0", - "22.0.0-nightly.20220810": "105.0.5187.0", - "22.0.0-nightly.20220811": "105.0.5187.0", - "22.0.0-nightly.20220812": "105.0.5187.0", - "22.0.0-nightly.20220815": "105.0.5187.0", - "22.0.0-nightly.20220816": "105.0.5187.0", - "22.0.0-nightly.20220817": "105.0.5187.0", - "22.0.0-nightly.20220822": "106.0.5216.0", - "22.0.0-nightly.20220823": "106.0.5216.0", - "22.0.0-nightly.20220824": "106.0.5216.0", - "22.0.0-nightly.20220825": "106.0.5216.0", - "22.0.0-nightly.20220829": "106.0.5216.0", - "22.0.0-nightly.20220830": "106.0.5216.0", - "22.0.0-nightly.20220831": "106.0.5216.0", - "22.0.0-nightly.20220901": "106.0.5216.0", - "22.0.0-nightly.20220902": "106.0.5216.0", - "22.0.0-nightly.20220905": "106.0.5216.0", - "22.0.0-nightly.20220908": "107.0.5274.0", - "22.0.0-nightly.20220909": "107.0.5286.0", - "22.0.0-nightly.20220912": "107.0.5286.0", - "22.0.0-nightly.20220913": "107.0.5286.0", - "22.0.0-nightly.20220914": "107.0.5286.0", - "22.0.0-nightly.20220915": "107.0.5286.0", - "22.0.0-nightly.20220916": "107.0.5286.0", - "22.0.0-nightly.20220919": "107.0.5286.0", - "22.0.0-nightly.20220920": "107.0.5286.0", - "22.0.0-nightly.20220921": "107.0.5286.0", - "22.0.0-nightly.20220922": "107.0.5286.0", - "22.0.0-nightly.20220923": "107.0.5286.0", - "22.0.0-nightly.20220926": "107.0.5286.0", - "22.0.0-nightly.20220927": "107.0.5286.0", - "22.0.0-nightly.20220928": "107.0.5286.0", - "22.0.0": "108.0.5359.62", - "22.0.1": "108.0.5359.125", - "22.0.2": "108.0.5359.179", - "22.0.3": "108.0.5359.179", - "22.1.0": "108.0.5359.179", - "22.2.0": "108.0.5359.215", - "22.2.1": "108.0.5359.215", - "22.3.0": "108.0.5359.215", - "22.3.1": "108.0.5359.215", - "22.3.2": "108.0.5359.215", - "22.3.3": "108.0.5359.215", - "22.3.4": "108.0.5359.215", - "22.3.5": "108.0.5359.215", - "22.3.6": "108.0.5359.215", - "22.3.7": "108.0.5359.215", - "22.3.8": "108.0.5359.215", - "22.3.9": "108.0.5359.215", - "22.3.10": "108.0.5359.215", - "22.3.11": "108.0.5359.215", - "22.3.12": "108.0.5359.215", - "22.3.13": "108.0.5359.215", - "22.3.14": "108.0.5359.215", - "22.3.15": "108.0.5359.215", - "22.3.16": "108.0.5359.215", - "22.3.17": "108.0.5359.215", - "22.3.18": "108.0.5359.215", - "22.3.20": "108.0.5359.215", - "22.3.21": "108.0.5359.215", - "22.3.22": "108.0.5359.215", - "22.3.23": "108.0.5359.215", - "22.3.24": "108.0.5359.215", - "22.3.25": "108.0.5359.215", - "22.3.26": "108.0.5359.215", - "22.3.27": "108.0.5359.215", - "23.0.0-alpha.1": "110.0.5415.0", - "23.0.0-alpha.2": "110.0.5451.0", - "23.0.0-alpha.3": "110.0.5451.0", - "23.0.0-beta.1": "110.0.5478.5", - "23.0.0-beta.2": "110.0.5478.5", - "23.0.0-beta.3": "110.0.5478.5", - "23.0.0-beta.4": "110.0.5481.30", - "23.0.0-beta.5": "110.0.5481.38", - "23.0.0-beta.6": "110.0.5481.52", - "23.0.0-beta.8": "110.0.5481.52", - "23.0.0-nightly.20220929": "107.0.5286.0", - "23.0.0-nightly.20220930": "107.0.5286.0", - "23.0.0-nightly.20221003": "107.0.5286.0", - "23.0.0-nightly.20221004": "108.0.5329.0", - "23.0.0-nightly.20221005": "108.0.5329.0", - "23.0.0-nightly.20221006": "108.0.5329.0", - "23.0.0-nightly.20221007": "108.0.5329.0", - "23.0.0-nightly.20221010": "108.0.5329.0", - "23.0.0-nightly.20221011": "108.0.5329.0", - "23.0.0-nightly.20221012": "108.0.5329.0", - "23.0.0-nightly.20221013": "108.0.5329.0", - "23.0.0-nightly.20221014": "108.0.5329.0", - "23.0.0-nightly.20221017": "108.0.5329.0", - "23.0.0-nightly.20221018": "108.0.5355.0", - "23.0.0-nightly.20221019": "108.0.5355.0", - "23.0.0-nightly.20221020": "108.0.5355.0", - "23.0.0-nightly.20221021": "108.0.5355.0", - "23.0.0-nightly.20221024": "108.0.5355.0", - "23.0.0-nightly.20221026": "108.0.5355.0", - "23.0.0-nightly.20221027": "109.0.5382.0", - "23.0.0-nightly.20221028": "109.0.5382.0", - "23.0.0-nightly.20221031": "109.0.5382.0", - "23.0.0-nightly.20221101": "109.0.5382.0", - "23.0.0-nightly.20221102": "109.0.5382.0", - "23.0.0-nightly.20221103": "109.0.5382.0", - "23.0.0-nightly.20221104": "109.0.5382.0", - "23.0.0-nightly.20221107": "109.0.5382.0", - "23.0.0-nightly.20221108": "109.0.5382.0", - "23.0.0-nightly.20221109": "109.0.5382.0", - "23.0.0-nightly.20221110": "109.0.5382.0", - "23.0.0-nightly.20221111": "109.0.5382.0", - "23.0.0-nightly.20221114": "109.0.5382.0", - "23.0.0-nightly.20221115": "109.0.5382.0", - "23.0.0-nightly.20221116": "109.0.5382.0", - "23.0.0-nightly.20221117": "109.0.5382.0", - "23.0.0-nightly.20221118": "110.0.5415.0", - "23.0.0-nightly.20221121": "110.0.5415.0", - "23.0.0-nightly.20221122": "110.0.5415.0", - "23.0.0-nightly.20221123": "110.0.5415.0", - "23.0.0-nightly.20221124": "110.0.5415.0", - "23.0.0-nightly.20221125": "110.0.5415.0", - "23.0.0-nightly.20221128": "110.0.5415.0", - "23.0.0-nightly.20221129": "110.0.5415.0", - "23.0.0-nightly.20221130": "110.0.5415.0", - "23.0.0": "110.0.5481.77", - "23.1.0": "110.0.5481.100", - "23.1.1": "110.0.5481.104", - "23.1.2": "110.0.5481.177", - "23.1.3": "110.0.5481.179", - "23.1.4": "110.0.5481.192", - "23.2.0": "110.0.5481.192", - "23.2.1": "110.0.5481.208", - "23.2.2": "110.0.5481.208", - "23.2.3": "110.0.5481.208", - "23.2.4": "110.0.5481.208", - "23.3.0": "110.0.5481.208", - "23.3.1": "110.0.5481.208", - "23.3.2": "110.0.5481.208", - "23.3.3": "110.0.5481.208", - "23.3.4": "110.0.5481.208", - "23.3.5": "110.0.5481.208", - "23.3.6": "110.0.5481.208", - "23.3.7": "110.0.5481.208", - "23.3.8": "110.0.5481.208", - "23.3.9": "110.0.5481.208", - "23.3.10": "110.0.5481.208", - "23.3.11": "110.0.5481.208", - "23.3.12": "110.0.5481.208", - "23.3.13": "110.0.5481.208", - "24.0.0-alpha.1": "111.0.5560.0", - "24.0.0-alpha.2": "111.0.5560.0", - "24.0.0-alpha.3": "111.0.5560.0", - "24.0.0-alpha.4": "111.0.5560.0", - "24.0.0-alpha.5": "111.0.5560.0", - "24.0.0-alpha.6": "111.0.5560.0", - "24.0.0-alpha.7": "111.0.5560.0", - "24.0.0-beta.1": "111.0.5563.50", - "24.0.0-beta.2": "111.0.5563.50", - "24.0.0-beta.3": "112.0.5615.20", - "24.0.0-beta.4": "112.0.5615.20", - "24.0.0-beta.5": "112.0.5615.29", - "24.0.0-beta.6": "112.0.5615.39", - "24.0.0-beta.7": "112.0.5615.39", - "24.0.0-nightly.20221201": "110.0.5415.0", - "24.0.0-nightly.20221202": "110.0.5415.0", - "24.0.0-nightly.20221205": "110.0.5415.0", - "24.0.0-nightly.20221206": "110.0.5451.0", - "24.0.0-nightly.20221207": "110.0.5451.0", - "24.0.0-nightly.20221208": "110.0.5451.0", - "24.0.0-nightly.20221213": "110.0.5451.0", - "24.0.0-nightly.20221214": "110.0.5451.0", - "24.0.0-nightly.20221215": "110.0.5451.0", - "24.0.0-nightly.20221216": "110.0.5451.0", - "24.0.0-nightly.20230109": "111.0.5518.0", - "24.0.0-nightly.20230110": "111.0.5518.0", - "24.0.0-nightly.20230111": "111.0.5518.0", - "24.0.0-nightly.20230112": "111.0.5518.0", - "24.0.0-nightly.20230113": "111.0.5518.0", - "24.0.0-nightly.20230116": "111.0.5518.0", - "24.0.0-nightly.20230117": "111.0.5518.0", - "24.0.0-nightly.20230118": "111.0.5518.0", - "24.0.0-nightly.20230119": "111.0.5518.0", - "24.0.0-nightly.20230120": "111.0.5518.0", - "24.0.0-nightly.20230123": "111.0.5518.0", - "24.0.0-nightly.20230124": "111.0.5518.0", - "24.0.0-nightly.20230125": "111.0.5518.0", - "24.0.0-nightly.20230126": "111.0.5518.0", - "24.0.0-nightly.20230127": "111.0.5518.0", - "24.0.0-nightly.20230131": "111.0.5518.0", - "24.0.0-nightly.20230201": "111.0.5518.0", - "24.0.0-nightly.20230202": "111.0.5518.0", - "24.0.0-nightly.20230203": "111.0.5560.0", - "24.0.0-nightly.20230206": "111.0.5560.0", - "24.0.0-nightly.20230207": "111.0.5560.0", - "24.0.0-nightly.20230208": "111.0.5560.0", - "24.0.0-nightly.20230209": "111.0.5560.0", - "24.0.0": "112.0.5615.49", - "24.1.0": "112.0.5615.50", - "24.1.1": "112.0.5615.50", - "24.1.2": "112.0.5615.87", - "24.1.3": "112.0.5615.165", - "24.2.0": "112.0.5615.165", - "24.3.0": "112.0.5615.165", - "24.3.1": "112.0.5615.183", - "24.4.0": "112.0.5615.204", - "24.4.1": "112.0.5615.204", - "24.5.0": "112.0.5615.204", - "24.5.1": "112.0.5615.204", - "24.6.0": "112.0.5615.204", - "24.6.1": "112.0.5615.204", - "24.6.2": "112.0.5615.204", - "24.6.3": "112.0.5615.204", - "24.6.4": "112.0.5615.204", - "24.6.5": "112.0.5615.204", - "24.7.0": "112.0.5615.204", - "24.7.1": "112.0.5615.204", - "24.8.0": "112.0.5615.204", - "24.8.1": "112.0.5615.204", - "24.8.2": "112.0.5615.204", - "24.8.3": "112.0.5615.204", - "24.8.4": "112.0.5615.204", - "24.8.5": "112.0.5615.204", - "24.8.6": "112.0.5615.204", - "24.8.7": "112.0.5615.204", - "24.8.8": "112.0.5615.204", - "25.0.0-alpha.1": "114.0.5694.0", - "25.0.0-alpha.2": "114.0.5694.0", - "25.0.0-alpha.3": "114.0.5710.0", - "25.0.0-alpha.4": "114.0.5710.0", - "25.0.0-alpha.5": "114.0.5719.0", - "25.0.0-alpha.6": "114.0.5719.0", - "25.0.0-beta.1": "114.0.5719.0", - "25.0.0-beta.2": "114.0.5719.0", - "25.0.0-beta.3": "114.0.5719.0", - "25.0.0-beta.4": "114.0.5735.16", - "25.0.0-beta.5": "114.0.5735.16", - "25.0.0-beta.6": "114.0.5735.16", - "25.0.0-beta.7": "114.0.5735.16", - "25.0.0-beta.8": "114.0.5735.35", - "25.0.0-beta.9": "114.0.5735.45", - "25.0.0-nightly.20230210": "111.0.5560.0", - "25.0.0-nightly.20230214": "111.0.5560.0", - "25.0.0-nightly.20230215": "111.0.5560.0", - "25.0.0-nightly.20230216": "111.0.5560.0", - "25.0.0-nightly.20230217": "111.0.5560.0", - "25.0.0-nightly.20230220": "111.0.5560.0", - "25.0.0-nightly.20230221": "111.0.5560.0", - "25.0.0-nightly.20230222": "111.0.5560.0", - "25.0.0-nightly.20230223": "111.0.5560.0", - "25.0.0-nightly.20230224": "111.0.5560.0", - "25.0.0-nightly.20230227": "111.0.5560.0", - "25.0.0-nightly.20230228": "111.0.5560.0", - "25.0.0-nightly.20230301": "111.0.5560.0", - "25.0.0-nightly.20230302": "111.0.5560.0", - "25.0.0-nightly.20230303": "111.0.5560.0", - "25.0.0-nightly.20230306": "111.0.5560.0", - "25.0.0-nightly.20230307": "111.0.5560.0", - "25.0.0-nightly.20230308": "111.0.5560.0", - "25.0.0-nightly.20230309": "111.0.5560.0", - "25.0.0-nightly.20230310": "111.0.5560.0", - "25.0.0-nightly.20230314": "113.0.5636.0", - "25.0.0-nightly.20230315": "113.0.5651.0", - "25.0.0-nightly.20230317": "113.0.5653.0", - "25.0.0-nightly.20230320": "113.0.5660.0", - "25.0.0-nightly.20230321": "113.0.5664.0", - "25.0.0-nightly.20230322": "113.0.5666.0", - "25.0.0-nightly.20230323": "113.0.5668.0", - "25.0.0-nightly.20230324": "113.0.5670.0", - "25.0.0-nightly.20230327": "113.0.5670.0", - "25.0.0-nightly.20230328": "113.0.5670.0", - "25.0.0-nightly.20230329": "113.0.5670.0", - "25.0.0-nightly.20230330": "113.0.5670.0", - "25.0.0-nightly.20230331": "114.0.5684.0", - "25.0.0-nightly.20230403": "114.0.5684.0", - "25.0.0-nightly.20230404": "114.0.5692.0", - "25.0.0-nightly.20230405": "114.0.5694.0", - "25.0.0": "114.0.5735.45", - "25.0.1": "114.0.5735.45", - "25.1.0": "114.0.5735.106", - "25.1.1": "114.0.5735.106", - "25.2.0": "114.0.5735.134", - "25.3.0": "114.0.5735.199", - "25.3.1": "114.0.5735.243", - "25.3.2": "114.0.5735.248", - "25.4.0": "114.0.5735.248", - "25.5.0": "114.0.5735.289", - "25.6.0": "114.0.5735.289", - "25.7.0": "114.0.5735.289", - "25.8.0": "114.0.5735.289", - "25.8.1": "114.0.5735.289", - "25.8.2": "114.0.5735.289", - "25.8.3": "114.0.5735.289", - "25.8.4": "114.0.5735.289", - "25.9.0": "114.0.5735.289", - "25.9.1": "114.0.5735.289", - "25.9.2": "114.0.5735.289", - "25.9.3": "114.0.5735.289", - "25.9.4": "114.0.5735.289", - "25.9.5": "114.0.5735.289", - "25.9.6": "114.0.5735.289", - "25.9.7": "114.0.5735.289", - "25.9.8": "114.0.5735.289", - "26.0.0-alpha.1": "116.0.5791.0", - "26.0.0-alpha.2": "116.0.5791.0", - "26.0.0-alpha.3": "116.0.5791.0", - "26.0.0-alpha.4": "116.0.5791.0", - "26.0.0-alpha.5": "116.0.5791.0", - "26.0.0-alpha.6": "116.0.5815.0", - "26.0.0-alpha.7": "116.0.5831.0", - "26.0.0-alpha.8": "116.0.5845.0", - "26.0.0-beta.1": "116.0.5845.0", - "26.0.0-beta.2": "116.0.5845.14", - "26.0.0-beta.3": "116.0.5845.14", - "26.0.0-beta.4": "116.0.5845.14", - "26.0.0-beta.5": "116.0.5845.14", - "26.0.0-beta.6": "116.0.5845.14", - "26.0.0-beta.7": "116.0.5845.14", - "26.0.0-beta.8": "116.0.5845.42", - "26.0.0-beta.9": "116.0.5845.42", - "26.0.0-beta.10": "116.0.5845.49", - "26.0.0-beta.11": "116.0.5845.49", - "26.0.0-beta.12": "116.0.5845.62", - "26.0.0-nightly.20230406": "114.0.5694.0", - "26.0.0-nightly.20230407": "114.0.5694.0", - "26.0.0-nightly.20230410": "114.0.5694.0", - "26.0.0-nightly.20230411": "114.0.5694.0", - "26.0.0-nightly.20230412": "114.0.5708.0", - "26.0.0-nightly.20230413": "114.0.5710.0", - "26.0.0-nightly.20230414": "114.0.5710.0", - "26.0.0-nightly.20230417": "114.0.5710.0", - "26.0.0-nightly.20230418": "114.0.5715.0", - "26.0.0-nightly.20230421": "114.0.5719.0", - "26.0.0-nightly.20230424": "114.0.5719.0", - "26.0.0-nightly.20230425": "114.0.5719.0", - "26.0.0-nightly.20230426": "114.0.5719.0", - "26.0.0-nightly.20230427": "114.0.5719.0", - "26.0.0-nightly.20230428": "114.0.5719.0", - "26.0.0-nightly.20230501": "114.0.5719.0", - "26.0.0-nightly.20230502": "114.0.5719.0", - "26.0.0-nightly.20230503": "114.0.5719.0", - "26.0.0-nightly.20230504": "114.0.5719.0", - "26.0.0-nightly.20230505": "114.0.5719.0", - "26.0.0-nightly.20230508": "114.0.5719.0", - "26.0.0-nightly.20230509": "114.0.5719.0", - "26.0.0-nightly.20230510": "114.0.5719.0", - "26.0.0-nightly.20230511": "115.0.5760.0", - "26.0.0-nightly.20230512": "115.0.5760.0", - "26.0.0-nightly.20230515": "115.0.5760.0", - "26.0.0-nightly.20230516": "115.0.5760.0", - "26.0.0-nightly.20230517": "115.0.5760.0", - "26.0.0-nightly.20230518": "115.0.5760.0", - "26.0.0-nightly.20230519": "115.0.5760.0", - "26.0.0-nightly.20230522": "115.0.5760.0", - "26.0.0-nightly.20230523": "115.0.5760.0", - "26.0.0-nightly.20230524": "115.0.5786.0", - "26.0.0-nightly.20230525": "115.0.5790.0", - "26.0.0-nightly.20230526": "116.0.5791.0", - "26.0.0-nightly.20230529": "116.0.5791.0", - "26.0.0-nightly.20230530": "116.0.5791.0", - "26.0.0-nightly.20230531": "116.0.5791.0", - "26.0.0": "116.0.5845.82", - "26.1.0": "116.0.5845.97", - "26.2.0": "116.0.5845.179", - "26.2.1": "116.0.5845.188", - "26.2.2": "116.0.5845.190", - "26.2.3": "116.0.5845.190", - "26.2.4": "116.0.5845.190", - "26.3.0": "116.0.5845.228", - "26.4.0": "116.0.5845.228", - "26.4.1": "116.0.5845.228", - "26.4.2": "116.0.5845.228", - "26.4.3": "116.0.5845.228", - "26.5.0": "116.0.5845.228", - "26.6.0": "116.0.5845.228", - "26.6.1": "116.0.5845.228", - "26.6.2": "116.0.5845.228", - "26.6.3": "116.0.5845.228", - "26.6.4": "116.0.5845.228", - "26.6.5": "116.0.5845.228", - "26.6.6": "116.0.5845.228", - "26.6.7": "116.0.5845.228", - "26.6.8": "116.0.5845.228", - "26.6.9": "116.0.5845.228", - "26.6.10": "116.0.5845.228", - "27.0.0-alpha.1": "118.0.5949.0", - "27.0.0-alpha.2": "118.0.5949.0", - "27.0.0-alpha.3": "118.0.5949.0", - "27.0.0-alpha.4": "118.0.5949.0", - "27.0.0-alpha.5": "118.0.5949.0", - "27.0.0-alpha.6": "118.0.5949.0", - "27.0.0-beta.1": "118.0.5993.5", - "27.0.0-beta.2": "118.0.5993.5", - "27.0.0-beta.3": "118.0.5993.5", - "27.0.0-beta.4": "118.0.5993.11", - "27.0.0-beta.5": "118.0.5993.18", - "27.0.0-beta.6": "118.0.5993.18", - "27.0.0-beta.7": "118.0.5993.18", - "27.0.0-beta.8": "118.0.5993.18", - "27.0.0-beta.9": "118.0.5993.18", - "27.0.0-nightly.20230601": "116.0.5791.0", - "27.0.0-nightly.20230602": "116.0.5791.0", - "27.0.0-nightly.20230605": "116.0.5791.0", - "27.0.0-nightly.20230606": "116.0.5791.0", - "27.0.0-nightly.20230607": "116.0.5791.0", - "27.0.0-nightly.20230609": "116.0.5791.0", - "27.0.0-nightly.20230612": "116.0.5815.0", - "27.0.0-nightly.20230613": "116.0.5815.0", - "27.0.0-nightly.20230614": "116.0.5829.0", - "27.0.0-nightly.20230615": "116.0.5831.0", - "27.0.0-nightly.20230616": "116.0.5833.0", - "27.0.0-nightly.20230619": "116.0.5833.0", - "27.0.0-nightly.20230620": "116.0.5833.0", - "27.0.0-nightly.20230621": "116.0.5833.0", - "27.0.0-nightly.20230622": "116.0.5845.0", - "27.0.0-nightly.20230623": "116.0.5845.0", - "27.0.0-nightly.20230626": "116.0.5845.0", - "27.0.0-nightly.20230627": "116.0.5845.0", - "27.0.0-nightly.20230628": "116.0.5845.0", - "27.0.0-nightly.20230629": "116.0.5845.0", - "27.0.0-nightly.20230630": "116.0.5845.0", - "27.0.0-nightly.20230703": "117.0.5852.0", - "27.0.0-nightly.20230704": "117.0.5852.0", - "27.0.0-nightly.20230705": "117.0.5852.0", - "27.0.0-nightly.20230706": "117.0.5852.0", - "27.0.0-nightly.20230707": "117.0.5852.0", - "27.0.0-nightly.20230710": "117.0.5852.0", - "27.0.0-nightly.20230711": "117.0.5852.0", - "27.0.0-nightly.20230712": "117.0.5852.0", - "27.0.0-nightly.20230713": "117.0.5852.0", - "27.0.0-nightly.20230714": "117.0.5852.0", - "27.0.0-nightly.20230717": "117.0.5884.1", - "27.0.0-nightly.20230718": "117.0.5884.1", - "27.0.0-nightly.20230719": "117.0.5892.0", - "27.0.0-nightly.20230720": "117.0.5897.0", - "27.0.0-nightly.20230721": "117.0.5897.0", - "27.0.0-nightly.20230724": "117.0.5897.0", - "27.0.0-nightly.20230725": "117.0.5897.0", - "27.0.0-nightly.20230726": "117.0.5897.0", - "27.0.0-nightly.20230727": "117.0.5897.0", - "27.0.0-nightly.20230728": "117.0.5897.0", - "27.0.0-nightly.20230731": "117.0.5897.0", - "27.0.0-nightly.20230801": "117.0.5911.0", - "27.0.0-nightly.20230802": "117.0.5911.0", - "27.0.0-nightly.20230803": "117.0.5911.0", - "27.0.0-nightly.20230804": "117.0.5921.0", - "27.0.0-nightly.20230807": "117.0.5921.0", - "27.0.0-nightly.20230808": "117.0.5921.0", - "27.0.0-nightly.20230814": "117.0.5921.0", - "27.0.0-nightly.20230815": "117.0.5921.0", - "27.0.0-nightly.20230816": "118.0.5949.0", - "27.0.0": "118.0.5993.54", - "27.0.1": "118.0.5993.89", - "27.0.2": "118.0.5993.89", - "27.0.3": "118.0.5993.120", - "27.0.4": "118.0.5993.129", - "27.1.0": "118.0.5993.144", - "27.1.2": "118.0.5993.144", - "27.1.3": "118.0.5993.159", - "27.2.0": "118.0.5993.159", - "27.2.1": "118.0.5993.159", - "27.2.2": "118.0.5993.159", - "27.2.3": "118.0.5993.159", - "27.2.4": "118.0.5993.159", - "27.3.0": "118.0.5993.159", - "27.3.1": "118.0.5993.159", - "27.3.2": "118.0.5993.159", - "27.3.3": "118.0.5993.159", - "27.3.4": "118.0.5993.159", - "27.3.5": "118.0.5993.159", - "27.3.6": "118.0.5993.159", - "27.3.7": "118.0.5993.159", - "27.3.8": "118.0.5993.159", - "27.3.9": "118.0.5993.159", - "27.3.10": "118.0.5993.159", - "27.3.11": "118.0.5993.159", - "28.0.0-alpha.1": "119.0.6045.0", - "28.0.0-alpha.2": "119.0.6045.0", - "28.0.0-alpha.3": "119.0.6045.21", - "28.0.0-alpha.4": "119.0.6045.21", - "28.0.0-alpha.5": "119.0.6045.33", - "28.0.0-alpha.6": "119.0.6045.33", - "28.0.0-alpha.7": "119.0.6045.33", - "28.0.0-beta.1": "119.0.6045.33", - "28.0.0-beta.2": "120.0.6099.0", - "28.0.0-beta.3": "120.0.6099.5", - "28.0.0-beta.4": "120.0.6099.5", - "28.0.0-beta.5": "120.0.6099.18", - "28.0.0-beta.6": "120.0.6099.18", - "28.0.0-beta.7": "120.0.6099.18", - "28.0.0-beta.8": "120.0.6099.18", - "28.0.0-beta.9": "120.0.6099.18", - "28.0.0-beta.10": "120.0.6099.18", - "28.0.0-beta.11": "120.0.6099.35", - "28.0.0-nightly.20230817": "118.0.5949.0", - "28.0.0-nightly.20230818": "118.0.5949.0", - "28.0.0-nightly.20230821": "118.0.5949.0", - "28.0.0-nightly.20230822": "118.0.5949.0", - "28.0.0-nightly.20230823": "118.0.5949.0", - "28.0.0-nightly.20230824": "118.0.5949.0", - "28.0.0-nightly.20230825": "118.0.5949.0", - "28.0.0-nightly.20230828": "118.0.5949.0", - "28.0.0-nightly.20230829": "118.0.5949.0", - "28.0.0-nightly.20230830": "118.0.5949.0", - "28.0.0-nightly.20230831": "118.0.5949.0", - "28.0.0-nightly.20230906": "118.0.5991.0", - "28.0.0-nightly.20230907": "118.0.5993.0", - "28.0.0-nightly.20230908": "118.0.5993.0", - "28.0.0-nightly.20230911": "118.0.5993.0", - "28.0.0-nightly.20230912": "118.0.5993.0", - "28.0.0-nightly.20230913": "118.0.5993.0", - "28.0.0-nightly.20230914": "118.0.5993.0", - "28.0.0-nightly.20230915": "118.0.5993.0", - "28.0.0-nightly.20230919": "119.0.6006.0", - "28.0.0-nightly.20230920": "119.0.6017.0", - "28.0.0-nightly.20230921": "119.0.6019.2", - "28.0.0-nightly.20230925": "119.0.6019.2", - "28.0.0-nightly.20230926": "119.0.6019.2", - "28.0.0-nightly.20230927": "119.0.6019.2", - "28.0.0-nightly.20230928": "119.0.6019.2", - "28.0.0-nightly.20230929": "119.0.6029.0", - "28.0.0-nightly.20231002": "119.0.6029.0", - "28.0.0-nightly.20231003": "119.0.6043.0", - "28.0.0-nightly.20231004": "119.0.6043.0", - "28.0.0-nightly.20231005": "119.0.6043.0", - "28.0.0-nightly.20231006": "119.0.6045.0", - "28.0.0-nightly.20231009": "119.0.6045.0", - "28.0.0-nightly.20231010": "119.0.6045.0", - "28.0.0-nightly.20231011": "119.0.6045.0", - "28.0.0": "120.0.6099.56", - "28.1.0": "120.0.6099.109", - "28.1.1": "120.0.6099.109", - "28.1.2": "120.0.6099.199", - "28.1.3": "120.0.6099.199", - "28.1.4": "120.0.6099.216", - "28.2.0": "120.0.6099.227", - "28.2.1": "120.0.6099.268", - "28.2.2": "120.0.6099.276", - "28.2.3": "120.0.6099.283", - "28.2.4": "120.0.6099.291", - "28.2.5": "120.0.6099.291", - "28.2.6": "120.0.6099.291", - "28.2.7": "120.0.6099.291", - "28.2.8": "120.0.6099.291", - "28.2.9": "120.0.6099.291", - "28.2.10": "120.0.6099.291", - "28.3.0": "120.0.6099.291", - "28.3.1": "120.0.6099.291", - "28.3.2": "120.0.6099.291", - "28.3.3": "120.0.6099.291", - "29.0.0-alpha.1": "121.0.6147.0", - "29.0.0-alpha.2": "121.0.6147.0", - "29.0.0-alpha.3": "121.0.6147.0", - "29.0.0-alpha.4": "121.0.6159.0", - "29.0.0-alpha.5": "121.0.6159.0", - "29.0.0-alpha.6": "121.0.6159.0", - "29.0.0-alpha.7": "121.0.6159.0", - "29.0.0-alpha.8": "122.0.6194.0", - "29.0.0-alpha.9": "122.0.6236.2", - "29.0.0-alpha.10": "122.0.6236.2", - "29.0.0-alpha.11": "122.0.6236.2", - "29.0.0-beta.1": "122.0.6236.2", - "29.0.0-beta.2": "122.0.6236.2", - "29.0.0-beta.3": "122.0.6261.6", - "29.0.0-beta.4": "122.0.6261.6", - "29.0.0-beta.5": "122.0.6261.18", - "29.0.0-beta.6": "122.0.6261.18", - "29.0.0-beta.7": "122.0.6261.18", - "29.0.0-beta.8": "122.0.6261.18", - "29.0.0-beta.9": "122.0.6261.18", - "29.0.0-beta.10": "122.0.6261.18", - "29.0.0-beta.11": "122.0.6261.18", - "29.0.0-beta.12": "122.0.6261.29", - "29.0.0-nightly.20231012": "119.0.6045.0", - "29.0.0-nightly.20231013": "119.0.6045.0", - "29.0.0-nightly.20231016": "119.0.6045.0", - "29.0.0-nightly.20231017": "119.0.6045.0", - "29.0.0-nightly.20231018": "119.0.6045.0", - "29.0.0-nightly.20231019": "119.0.6045.0", - "29.0.0-nightly.20231020": "119.0.6045.0", - "29.0.0-nightly.20231023": "119.0.6045.0", - "29.0.0-nightly.20231024": "119.0.6045.0", - "29.0.0-nightly.20231025": "120.0.6078.0", - "29.0.0-nightly.20231026": "120.0.6078.0", - "29.0.0-nightly.20231027": "120.0.6078.0", - "29.0.0-nightly.20231030": "120.0.6078.0", - "29.0.0-nightly.20231031": "120.0.6078.0", - "29.0.0-nightly.20231101": "120.0.6078.0", - "29.0.0-nightly.20231102": "121.0.6100.0", - "29.0.0-nightly.20231103": "121.0.6100.0", - "29.0.0-nightly.20231106": "121.0.6104.0", - "29.0.0-nightly.20231107": "121.0.6110.0", - "29.0.0-nightly.20231108": "121.0.6110.0", - "29.0.0-nightly.20231109": "121.0.6110.0", - "29.0.0-nightly.20231110": "121.0.6110.0", - "29.0.0-nightly.20231113": "121.0.6110.0", - "29.0.0-nightly.20231114": "121.0.6110.0", - "29.0.0-nightly.20231115": "121.0.6116.0", - "29.0.0-nightly.20231116": "121.0.6116.0", - "29.0.0-nightly.20231117": "121.0.6116.0", - "29.0.0-nightly.20231120": "121.0.6116.0", - "29.0.0-nightly.20231121": "121.0.6116.0", - "29.0.0-nightly.20231122": "121.0.6116.0", - "29.0.0-nightly.20231123": "121.0.6116.0", - "29.0.0-nightly.20231124": "121.0.6116.0", - "29.0.0-nightly.20231127": "121.0.6116.0", - "29.0.0-nightly.20231128": "121.0.6116.0", - "29.0.0-nightly.20231129": "121.0.6147.0", - "29.0.0-nightly.20231130": "121.0.6147.0", - "29.0.0-nightly.20231201": "121.0.6147.0", - "29.0.0-nightly.20231204": "121.0.6147.0", - "29.0.0-nightly.20231205": "121.0.6147.0", - "29.0.0-nightly.20231206": "121.0.6147.0", - "29.0.0": "122.0.6261.39", - "29.0.1": "122.0.6261.57", - "29.1.0": "122.0.6261.70", - "29.1.1": "122.0.6261.111", - "29.1.2": "122.0.6261.112", - "29.1.3": "122.0.6261.112", - "29.1.4": "122.0.6261.129", - "29.1.5": "122.0.6261.130", - "29.1.6": "122.0.6261.139", - "29.2.0": "122.0.6261.156", - "29.3.0": "122.0.6261.156", - "29.3.1": "122.0.6261.156", - "29.3.2": "122.0.6261.156", - "29.3.3": "122.0.6261.156", - "29.4.0": "122.0.6261.156", - "29.4.1": "122.0.6261.156", - "29.4.2": "122.0.6261.156", - "30.0.0-alpha.1": "123.0.6296.0", - "30.0.0-alpha.2": "123.0.6312.5", - "30.0.0-alpha.3": "124.0.6323.0", - "30.0.0-alpha.4": "124.0.6323.0", - "30.0.0-alpha.5": "124.0.6331.0", - "30.0.0-alpha.6": "124.0.6331.0", - "30.0.0-alpha.7": "124.0.6353.0", - "30.0.0-beta.1": "124.0.6359.0", - "30.0.0-beta.2": "124.0.6359.0", - "30.0.0-beta.3": "124.0.6367.9", - "30.0.0-beta.4": "124.0.6367.9", - "30.0.0-beta.5": "124.0.6367.9", - "30.0.0-beta.6": "124.0.6367.18", - "30.0.0-beta.7": "124.0.6367.29", - "30.0.0-beta.8": "124.0.6367.29", - "30.0.0-nightly.20231207": "121.0.6147.0", - "30.0.0-nightly.20231208": "121.0.6147.0", - "30.0.0-nightly.20231211": "121.0.6147.0", - "30.0.0-nightly.20231212": "121.0.6159.0", - "30.0.0-nightly.20231213": "121.0.6159.0", - "30.0.0-nightly.20231214": "121.0.6159.0", - "30.0.0-nightly.20231215": "121.0.6159.0", - "30.0.0-nightly.20231218": "121.0.6159.0", - "30.0.0-nightly.20240102": "121.0.6159.0", - "30.0.0-nightly.20240103": "122.0.6194.0", - "30.0.0-nightly.20240104": "122.0.6194.0", - "30.0.0-nightly.20240105": "122.0.6194.0", - "30.0.0-nightly.20240108": "122.0.6194.0", - "30.0.0-nightly.20240109": "122.0.6194.0", - "30.0.0-nightly.20240110": "122.0.6194.0", - "30.0.0-nightly.20240111": "122.0.6236.2", - "30.0.0-nightly.20240112": "122.0.6236.2", - "30.0.0-nightly.20240115": "122.0.6236.2", - "30.0.0-nightly.20240116": "122.0.6236.2", - "30.0.0-nightly.20240117": "122.0.6236.2", - "30.0.0-nightly.20240118": "122.0.6236.2", - "30.0.0-nightly.20240119": "122.0.6236.2", - "30.0.0-nightly.20240122": "122.0.6236.2", - "30.0.0-nightly.20240123": "122.0.6236.2", - "30.0.0-nightly.20240124": "122.0.6236.2", - "30.0.0-nightly.20240125": "122.0.6236.2", - "30.0.0-nightly.20240126": "123.0.6264.0", - "30.0.0-nightly.20240129": "123.0.6264.0", - "30.0.0-nightly.20240130": "123.0.6264.0", - "30.0.0-nightly.20240131": "123.0.6264.0", - "30.0.0-nightly.20240201": "123.0.6272.0", - "30.0.0-nightly.20240202": "123.0.6272.0", - "30.0.0-nightly.20240205": "123.0.6272.0", - "30.0.0-nightly.20240206": "123.0.6272.0", - "30.0.0-nightly.20240207": "123.0.6272.0", - "30.0.0-nightly.20240208": "123.0.6272.0", - "30.0.0-nightly.20240209": "123.0.6272.0", - "30.0.0-nightly.20240212": "123.0.6272.0", - "30.0.0-nightly.20240213": "123.0.6272.0", - "30.0.0-nightly.20240214": "123.0.6272.0", - "30.0.0-nightly.20240215": "123.0.6296.0", - "30.0.0-nightly.20240216": "123.0.6296.0", - "30.0.0-nightly.20240219": "123.0.6296.0", - "30.0.0-nightly.20240220": "123.0.6296.0", - "30.0.0-nightly.20240221": "123.0.6296.0", - "30.0.0": "124.0.6367.49", - "30.0.1": "124.0.6367.60", - "30.0.2": "124.0.6367.91", - "30.0.3": "124.0.6367.119", - "30.0.4": "124.0.6367.201", - "30.0.5": "124.0.6367.207", - "30.0.6": "124.0.6367.207", - "30.0.7": "124.0.6367.221", - "30.0.8": "124.0.6367.230", - "30.0.9": "124.0.6367.233", - "30.1.0": "124.0.6367.243", - "30.1.1": "124.0.6367.243", - "31.0.0-alpha.1": "125.0.6412.0", - "31.0.0-alpha.2": "125.0.6412.0", - "31.0.0-alpha.3": "125.0.6412.0", - "31.0.0-alpha.4": "125.0.6412.0", - "31.0.0-alpha.5": "125.0.6412.0", - "31.0.0-beta.1": "126.0.6445.0", - "31.0.0-beta.2": "126.0.6445.0", - "31.0.0-beta.3": "126.0.6445.0", - "31.0.0-beta.4": "126.0.6445.0", - "31.0.0-beta.5": "126.0.6445.0", - "31.0.0-beta.6": "126.0.6445.0", - "31.0.0-beta.7": "126.0.6445.0", - "31.0.0-beta.8": "126.0.6445.0", - "31.0.0-beta.9": "126.0.6445.0", - "31.0.0-beta.10": "126.0.6478.36", - "31.0.0-nightly.20240222": "123.0.6312.5", - "31.0.0-nightly.20240223": "123.0.6312.5", - "31.0.0-nightly.20240226": "123.0.6312.5", - "31.0.0-nightly.20240227": "123.0.6312.5", - "31.0.0-nightly.20240228": "123.0.6312.5", - "31.0.0-nightly.20240229": "124.0.6323.0", - "31.0.0-nightly.20240301": "124.0.6323.0", - "31.0.0-nightly.20240304": "124.0.6323.0", - "31.0.0-nightly.20240305": "124.0.6323.0", - "31.0.0-nightly.20240306": "124.0.6331.0", - "31.0.0-nightly.20240307": "124.0.6331.0", - "31.0.0-nightly.20240308": "124.0.6331.0", - "31.0.0-nightly.20240311": "124.0.6331.0", - "31.0.0-nightly.20240312": "124.0.6351.0", - "31.0.0-nightly.20240313": "124.0.6353.0", - "31.0.0-nightly.20240314": "124.0.6353.0", - "31.0.0-nightly.20240315": "124.0.6353.0", - "31.0.0-nightly.20240318": "124.0.6359.0", - "31.0.0-nightly.20240319": "124.0.6359.0", - "31.0.0-nightly.20240320": "124.0.6359.0", - "31.0.0-nightly.20240321": "124.0.6359.0", - "31.0.0-nightly.20240325": "124.0.6359.0", - "31.0.0-nightly.20240327": "124.0.6359.0", - "31.0.0-nightly.20240328": "124.0.6359.0", - "31.0.0-nightly.20240329": "124.0.6359.0", - "31.0.0-nightly.20240401": "124.0.6359.0", - "31.0.0-nightly.20240402": "124.0.6359.0", - "31.0.0-nightly.20240404": "124.0.6359.0", - "31.0.0-nightly.20240405": "124.0.6359.0", - "31.0.0-nightly.20240408": "124.0.6359.0", - "31.0.0-nightly.20240409": "124.0.6359.0", - "31.0.0-nightly.20240410": "124.0.6359.0", - "31.0.0-nightly.20240411": "124.0.6359.0", - "31.0.0-nightly.20240412": "124.0.6359.0", - "31.0.0": "126.0.6478.36", - "31.0.1": "126.0.6478.36", - "32.0.0-alpha.1": "127.0.6521.0", - "32.0.0-alpha.2": "127.0.6521.0", - "32.0.0-nightly.20240418": "125.0.6412.0", - "32.0.0-nightly.20240419": "125.0.6412.0", - "32.0.0-nightly.20240422": "125.0.6412.0", - "32.0.0-nightly.20240423": "125.0.6412.0", - "32.0.0-nightly.20240424": "125.0.6412.0", - "32.0.0-nightly.20240425": "125.0.6412.0", - "32.0.0-nightly.20240426": "125.0.6412.0", - "32.0.0-nightly.20240429": "125.0.6412.0", - "32.0.0-nightly.20240430": "125.0.6412.0", - "32.0.0-nightly.20240501": "125.0.6412.0", - "32.0.0-nightly.20240503": "125.0.6412.0", - "32.0.0-nightly.20240506": "125.0.6412.0", - "32.0.0-nightly.20240507": "125.0.6412.0", - "32.0.0-nightly.20240508": "125.0.6412.0", - "32.0.0-nightly.20240509": "125.0.6412.0", - "32.0.0-nightly.20240510": "125.0.6412.0", - "32.0.0-nightly.20240513": "126.0.6445.0", - "32.0.0-nightly.20240514": "126.0.6445.0", - "32.0.0-nightly.20240515": "126.0.6445.0", - "32.0.0-nightly.20240516": "126.0.6445.0", - "32.0.0-nightly.20240517": "126.0.6445.0", - "32.0.0-nightly.20240520": "126.0.6445.0", - "32.0.0-nightly.20240521": "126.0.6445.0", - "32.0.0-nightly.20240522": "126.0.6445.0", - "32.0.0-nightly.20240523": "126.0.6445.0", - "32.0.0-nightly.20240524": "126.0.6445.0", - "32.0.0-nightly.20240529": "126.0.6445.0", - "32.0.0-nightly.20240530": "126.0.6445.0", - "32.0.0-nightly.20240531": "126.0.6445.0", - "32.0.0-nightly.20240603": "126.0.6445.0", - "32.0.0-nightly.20240604": "126.0.6445.0", - "32.0.0-nightly.20240605": "126.0.6445.0", - "32.0.0-nightly.20240606": "126.0.6445.0", - "32.0.0-nightly.20240607": "126.0.6445.0", - "32.0.0-nightly.20240610": "127.0.6521.0", - "32.0.0-nightly.20240611": "127.0.6521.0", - "33.0.0-nightly.20240612": "127.0.6521.0", - "33.0.0-nightly.20240614": "127.0.6521.0", - "33.0.0-nightly.20240617": "127.0.6521.0", - "33.0.0-nightly.20240618": "127.0.6521.0" -}; \ No newline at end of file diff --git a/tools/eslint/node_modules/electron-to-chromium/full-versions.json b/tools/eslint/node_modules/electron-to-chromium/full-versions.json deleted file mode 100644 index c7e4ccff1c2bf2..00000000000000 --- a/tools/eslint/node_modules/electron-to-chromium/full-versions.json +++ /dev/null @@ -1 +0,0 @@ -{"0.20.0":"39.0.2171.65","0.20.1":"39.0.2171.65","0.20.2":"39.0.2171.65","0.20.3":"39.0.2171.65","0.20.4":"39.0.2171.65","0.20.5":"39.0.2171.65","0.20.6":"39.0.2171.65","0.20.7":"39.0.2171.65","0.20.8":"39.0.2171.65","0.21.0":"40.0.2214.91","0.21.1":"40.0.2214.91","0.21.2":"40.0.2214.91","0.21.3":"41.0.2272.76","0.22.1":"41.0.2272.76","0.22.2":"41.0.2272.76","0.22.3":"41.0.2272.76","0.23.0":"41.0.2272.76","0.24.0":"41.0.2272.76","0.25.0":"42.0.2311.107","0.25.1":"42.0.2311.107","0.25.2":"42.0.2311.107","0.25.3":"42.0.2311.107","0.26.0":"42.0.2311.107","0.26.1":"42.0.2311.107","0.27.0":"42.0.2311.107","0.27.1":"42.0.2311.107","0.27.2":"43.0.2357.65","0.27.3":"43.0.2357.65","0.28.0":"43.0.2357.65","0.28.1":"43.0.2357.65","0.28.2":"43.0.2357.65","0.28.3":"43.0.2357.65","0.29.1":"43.0.2357.65","0.29.2":"43.0.2357.65","0.30.4":"44.0.2403.125","0.31.0":"44.0.2403.125","0.31.2":"45.0.2454.85","0.32.2":"45.0.2454.85","0.32.3":"45.0.2454.85","0.33.0":"45.0.2454.85","0.33.1":"45.0.2454.85","0.33.2":"45.0.2454.85","0.33.3":"45.0.2454.85","0.33.4":"45.0.2454.85","0.33.6":"45.0.2454.85","0.33.7":"45.0.2454.85","0.33.8":"45.0.2454.85","0.33.9":"45.0.2454.85","0.34.0":"45.0.2454.85","0.34.1":"45.0.2454.85","0.34.2":"45.0.2454.85","0.34.3":"45.0.2454.85","0.34.4":"45.0.2454.85","0.35.1":"45.0.2454.85","0.35.2":"45.0.2454.85","0.35.3":"45.0.2454.85","0.35.4":"45.0.2454.85","0.35.5":"45.0.2454.85","0.36.0":"47.0.2526.73","0.36.2":"47.0.2526.73","0.36.3":"47.0.2526.73","0.36.4":"47.0.2526.73","0.36.5":"47.0.2526.110","0.36.6":"47.0.2526.110","0.36.7":"47.0.2526.110","0.36.8":"47.0.2526.110","0.36.9":"47.0.2526.110","0.36.10":"47.0.2526.110","0.36.11":"47.0.2526.110","0.36.12":"47.0.2526.110","0.37.0":"49.0.2623.75","0.37.1":"49.0.2623.75","0.37.3":"49.0.2623.75","0.37.4":"49.0.2623.75","0.37.5":"49.0.2623.75","0.37.6":"49.0.2623.75","0.37.7":"49.0.2623.75","0.37.8":"49.0.2623.75","1.0.0":"49.0.2623.75","1.0.1":"49.0.2623.75","1.0.2":"49.0.2623.75","1.1.0":"50.0.2661.102","1.1.1":"50.0.2661.102","1.1.2":"50.0.2661.102","1.1.3":"50.0.2661.102","1.2.0":"51.0.2704.63","1.2.1":"51.0.2704.63","1.2.2":"51.0.2704.84","1.2.3":"51.0.2704.84","1.2.4":"51.0.2704.103","1.2.5":"51.0.2704.103","1.2.6":"51.0.2704.106","1.2.7":"51.0.2704.106","1.2.8":"51.0.2704.106","1.3.0":"52.0.2743.82","1.3.1":"52.0.2743.82","1.3.2":"52.0.2743.82","1.3.3":"52.0.2743.82","1.3.4":"52.0.2743.82","1.3.5":"52.0.2743.82","1.3.6":"52.0.2743.82","1.3.7":"52.0.2743.82","1.3.9":"52.0.2743.82","1.3.10":"52.0.2743.82","1.3.13":"52.0.2743.82","1.3.14":"52.0.2743.82","1.3.15":"52.0.2743.82","1.4.0":"53.0.2785.113","1.4.1":"53.0.2785.113","1.4.2":"53.0.2785.113","1.4.3":"53.0.2785.113","1.4.4":"53.0.2785.113","1.4.5":"53.0.2785.113","1.4.6":"53.0.2785.143","1.4.7":"53.0.2785.143","1.4.8":"53.0.2785.143","1.4.10":"53.0.2785.143","1.4.11":"53.0.2785.143","1.4.12":"54.0.2840.51","1.4.13":"53.0.2785.143","1.4.14":"53.0.2785.143","1.4.15":"53.0.2785.143","1.4.16":"53.0.2785.143","1.5.0":"54.0.2840.101","1.5.1":"54.0.2840.101","1.6.0":"56.0.2924.87","1.6.1":"56.0.2924.87","1.6.2":"56.0.2924.87","1.6.3":"56.0.2924.87","1.6.4":"56.0.2924.87","1.6.5":"56.0.2924.87","1.6.6":"56.0.2924.87","1.6.7":"56.0.2924.87","1.6.8":"56.0.2924.87","1.6.9":"56.0.2924.87","1.6.10":"56.0.2924.87","1.6.11":"56.0.2924.87","1.6.12":"56.0.2924.87","1.6.13":"56.0.2924.87","1.6.14":"56.0.2924.87","1.6.15":"56.0.2924.87","1.6.16":"56.0.2924.87","1.6.17":"56.0.2924.87","1.6.18":"56.0.2924.87","1.7.0":"58.0.3029.110","1.7.1":"58.0.3029.110","1.7.2":"58.0.3029.110","1.7.3":"58.0.3029.110","1.7.4":"58.0.3029.110","1.7.5":"58.0.3029.110","1.7.6":"58.0.3029.110","1.7.7":"58.0.3029.110","1.7.8":"58.0.3029.110","1.7.9":"58.0.3029.110","1.7.10":"58.0.3029.110","1.7.11":"58.0.3029.110","1.7.12":"58.0.3029.110","1.7.13":"58.0.3029.110","1.7.14":"58.0.3029.110","1.7.15":"58.0.3029.110","1.7.16":"58.0.3029.110","1.8.0":"59.0.3071.115","1.8.1":"59.0.3071.115","1.8.2-beta.1":"59.0.3071.115","1.8.2-beta.2":"59.0.3071.115","1.8.2-beta.3":"59.0.3071.115","1.8.2-beta.4":"59.0.3071.115","1.8.2-beta.5":"59.0.3071.115","1.8.2":"59.0.3071.115","1.8.3":"59.0.3071.115","1.8.4":"59.0.3071.115","1.8.5":"59.0.3071.115","1.8.6":"59.0.3071.115","1.8.7":"59.0.3071.115","1.8.8":"59.0.3071.115","2.0.0-beta.1":"61.0.3163.100","2.0.0-beta.2":"61.0.3163.100","2.0.0-beta.3":"61.0.3163.100","2.0.0-beta.4":"61.0.3163.100","2.0.0-beta.5":"61.0.3163.100","2.0.0-beta.6":"61.0.3163.100","2.0.0-beta.7":"61.0.3163.100","2.0.0-beta.8":"61.0.3163.100","2.0.0":"61.0.3163.100","2.0.1":"61.0.3163.100","2.0.2":"61.0.3163.100","2.0.3":"61.0.3163.100","2.0.4":"61.0.3163.100","2.0.5":"61.0.3163.100","2.0.6":"61.0.3163.100","2.0.7":"61.0.3163.100","2.0.8-nightly.20180819":"61.0.3163.100","2.0.8-nightly.20180820":"61.0.3163.100","2.0.8":"61.0.3163.100","2.0.9":"61.0.3163.100","2.0.10":"61.0.3163.100","2.0.11":"61.0.3163.100","2.0.12":"61.0.3163.100","2.0.13":"61.0.3163.100","2.0.14":"61.0.3163.100","2.0.15":"61.0.3163.100","2.0.16":"61.0.3163.100","2.0.17":"61.0.3163.100","2.0.18":"61.0.3163.100","2.1.0-unsupported.20180809":"61.0.3163.100","3.0.0-beta.1":"66.0.3359.181","3.0.0-beta.2":"66.0.3359.181","3.0.0-beta.3":"66.0.3359.181","3.0.0-beta.4":"66.0.3359.181","3.0.0-beta.5":"66.0.3359.181","3.0.0-beta.6":"66.0.3359.181","3.0.0-beta.7":"66.0.3359.181","3.0.0-beta.8":"66.0.3359.181","3.0.0-beta.9":"66.0.3359.181","3.0.0-beta.10":"66.0.3359.181","3.0.0-beta.11":"66.0.3359.181","3.0.0-beta.12":"66.0.3359.181","3.0.0-beta.13":"66.0.3359.181","3.0.0-nightly.20180818":"66.0.3359.181","3.0.0-nightly.20180821":"66.0.3359.181","3.0.0-nightly.20180823":"66.0.3359.181","3.0.0-nightly.20180904":"66.0.3359.181","3.0.0":"66.0.3359.181","3.0.1":"66.0.3359.181","3.0.2":"66.0.3359.181","3.0.3":"66.0.3359.181","3.0.4":"66.0.3359.181","3.0.5":"66.0.3359.181","3.0.6":"66.0.3359.181","3.0.7":"66.0.3359.181","3.0.8":"66.0.3359.181","3.0.9":"66.0.3359.181","3.0.10":"66.0.3359.181","3.0.11":"66.0.3359.181","3.0.12":"66.0.3359.181","3.0.13":"66.0.3359.181","3.0.14":"66.0.3359.181","3.0.15":"66.0.3359.181","3.0.16":"66.0.3359.181","3.1.0-beta.1":"66.0.3359.181","3.1.0-beta.2":"66.0.3359.181","3.1.0-beta.3":"66.0.3359.181","3.1.0-beta.4":"66.0.3359.181","3.1.0-beta.5":"66.0.3359.181","3.1.0":"66.0.3359.181","3.1.1":"66.0.3359.181","3.1.2":"66.0.3359.181","3.1.3":"66.0.3359.181","3.1.4":"66.0.3359.181","3.1.5":"66.0.3359.181","3.1.6":"66.0.3359.181","3.1.7":"66.0.3359.181","3.1.8":"66.0.3359.181","3.1.9":"66.0.3359.181","3.1.10":"66.0.3359.181","3.1.11":"66.0.3359.181","3.1.12":"66.0.3359.181","3.1.13":"66.0.3359.181","4.0.0-beta.1":"69.0.3497.106","4.0.0-beta.2":"69.0.3497.106","4.0.0-beta.3":"69.0.3497.106","4.0.0-beta.4":"69.0.3497.106","4.0.0-beta.5":"69.0.3497.106","4.0.0-beta.6":"69.0.3497.106","4.0.0-beta.7":"69.0.3497.106","4.0.0-beta.8":"69.0.3497.106","4.0.0-beta.9":"69.0.3497.106","4.0.0-beta.10":"69.0.3497.106","4.0.0-beta.11":"69.0.3497.106","4.0.0-nightly.20180817":"66.0.3359.181","4.0.0-nightly.20180819":"66.0.3359.181","4.0.0-nightly.20180821":"66.0.3359.181","4.0.0-nightly.20180929":"67.0.3396.99","4.0.0-nightly.20181006":"68.0.3440.128","4.0.0-nightly.20181010":"69.0.3497.106","4.0.0":"69.0.3497.106","4.0.1":"69.0.3497.106","4.0.2":"69.0.3497.106","4.0.3":"69.0.3497.106","4.0.4":"69.0.3497.106","4.0.5":"69.0.3497.106","4.0.6":"69.0.3497.106","4.0.7":"69.0.3497.128","4.0.8":"69.0.3497.128","4.1.0":"69.0.3497.128","4.1.1":"69.0.3497.128","4.1.2":"69.0.3497.128","4.1.3":"69.0.3497.128","4.1.4":"69.0.3497.128","4.1.5":"69.0.3497.128","4.2.0":"69.0.3497.128","4.2.1":"69.0.3497.128","4.2.2":"69.0.3497.128","4.2.3":"69.0.3497.128","4.2.4":"69.0.3497.128","4.2.5":"69.0.3497.128","4.2.6":"69.0.3497.128","4.2.7":"69.0.3497.128","4.2.8":"69.0.3497.128","4.2.9":"69.0.3497.128","4.2.10":"69.0.3497.128","4.2.11":"69.0.3497.128","4.2.12":"69.0.3497.128","5.0.0-beta.1":"72.0.3626.52","5.0.0-beta.2":"72.0.3626.52","5.0.0-beta.3":"73.0.3683.27","5.0.0-beta.4":"73.0.3683.54","5.0.0-beta.5":"73.0.3683.61","5.0.0-beta.6":"73.0.3683.84","5.0.0-beta.7":"73.0.3683.94","5.0.0-beta.8":"73.0.3683.104","5.0.0-beta.9":"73.0.3683.117","5.0.0-nightly.20190107":"70.0.3538.110","5.0.0-nightly.20190121":"71.0.3578.98","5.0.0-nightly.20190122":"71.0.3578.98","5.0.0":"73.0.3683.119","5.0.1":"73.0.3683.121","5.0.2":"73.0.3683.121","5.0.3":"73.0.3683.121","5.0.4":"73.0.3683.121","5.0.5":"73.0.3683.121","5.0.6":"73.0.3683.121","5.0.7":"73.0.3683.121","5.0.8":"73.0.3683.121","5.0.9":"73.0.3683.121","5.0.10":"73.0.3683.121","5.0.11":"73.0.3683.121","5.0.12":"73.0.3683.121","5.0.13":"73.0.3683.121","6.0.0-beta.1":"76.0.3774.1","6.0.0-beta.2":"76.0.3783.1","6.0.0-beta.3":"76.0.3783.1","6.0.0-beta.4":"76.0.3783.1","6.0.0-beta.5":"76.0.3805.4","6.0.0-beta.6":"76.0.3809.3","6.0.0-beta.7":"76.0.3809.22","6.0.0-beta.8":"76.0.3809.26","6.0.0-beta.9":"76.0.3809.26","6.0.0-beta.10":"76.0.3809.37","6.0.0-beta.11":"76.0.3809.42","6.0.0-beta.12":"76.0.3809.54","6.0.0-beta.13":"76.0.3809.60","6.0.0-beta.14":"76.0.3809.68","6.0.0-beta.15":"76.0.3809.74","6.0.0-nightly.20190123":"72.0.3626.52","6.0.0-nightly.20190212":"72.0.3626.107","6.0.0-nightly.20190213":"72.0.3626.110","6.0.0-nightly.20190311":"74.0.3724.8","6.0.0":"76.0.3809.88","6.0.1":"76.0.3809.102","6.0.2":"76.0.3809.110","6.0.3":"76.0.3809.126","6.0.4":"76.0.3809.131","6.0.5":"76.0.3809.136","6.0.6":"76.0.3809.138","6.0.7":"76.0.3809.139","6.0.8":"76.0.3809.146","6.0.9":"76.0.3809.146","6.0.10":"76.0.3809.146","6.0.11":"76.0.3809.146","6.0.12":"76.0.3809.146","6.1.0":"76.0.3809.146","6.1.1":"76.0.3809.146","6.1.2":"76.0.3809.146","6.1.3":"76.0.3809.146","6.1.4":"76.0.3809.146","6.1.5":"76.0.3809.146","6.1.6":"76.0.3809.146","6.1.7":"76.0.3809.146","6.1.8":"76.0.3809.146","6.1.9":"76.0.3809.146","6.1.10":"76.0.3809.146","6.1.11":"76.0.3809.146","6.1.12":"76.0.3809.146","7.0.0-beta.1":"78.0.3866.0","7.0.0-beta.2":"78.0.3866.0","7.0.0-beta.3":"78.0.3866.0","7.0.0-beta.4":"78.0.3896.6","7.0.0-beta.5":"78.0.3905.1","7.0.0-beta.6":"78.0.3905.1","7.0.0-beta.7":"78.0.3905.1","7.0.0-nightly.20190521":"76.0.3784.0","7.0.0-nightly.20190529":"76.0.3806.0","7.0.0-nightly.20190530":"76.0.3806.0","7.0.0-nightly.20190531":"76.0.3806.0","7.0.0-nightly.20190602":"76.0.3806.0","7.0.0-nightly.20190603":"76.0.3806.0","7.0.0-nightly.20190604":"77.0.3814.0","7.0.0-nightly.20190605":"77.0.3815.0","7.0.0-nightly.20190606":"77.0.3815.0","7.0.0-nightly.20190607":"77.0.3815.0","7.0.0-nightly.20190608":"77.0.3815.0","7.0.0-nightly.20190609":"77.0.3815.0","7.0.0-nightly.20190611":"77.0.3815.0","7.0.0-nightly.20190612":"77.0.3815.0","7.0.0-nightly.20190613":"77.0.3815.0","7.0.0-nightly.20190615":"77.0.3815.0","7.0.0-nightly.20190616":"77.0.3815.0","7.0.0-nightly.20190618":"77.0.3815.0","7.0.0-nightly.20190619":"77.0.3815.0","7.0.0-nightly.20190622":"77.0.3815.0","7.0.0-nightly.20190623":"77.0.3815.0","7.0.0-nightly.20190624":"77.0.3815.0","7.0.0-nightly.20190627":"77.0.3815.0","7.0.0-nightly.20190629":"77.0.3815.0","7.0.0-nightly.20190630":"77.0.3815.0","7.0.0-nightly.20190701":"77.0.3815.0","7.0.0-nightly.20190702":"77.0.3815.0","7.0.0-nightly.20190704":"77.0.3843.0","7.0.0-nightly.20190705":"77.0.3843.0","7.0.0-nightly.20190719":"77.0.3848.0","7.0.0-nightly.20190720":"77.0.3848.0","7.0.0-nightly.20190721":"77.0.3848.0","7.0.0-nightly.20190726":"77.0.3864.0","7.0.0-nightly.20190727":"78.0.3866.0","7.0.0-nightly.20190728":"78.0.3866.0","7.0.0-nightly.20190729":"78.0.3866.0","7.0.0-nightly.20190730":"78.0.3866.0","7.0.0-nightly.20190731":"78.0.3866.0","7.0.0":"78.0.3905.1","7.0.1":"78.0.3904.92","7.1.0":"78.0.3904.94","7.1.1":"78.0.3904.99","7.1.2":"78.0.3904.113","7.1.3":"78.0.3904.126","7.1.4":"78.0.3904.130","7.1.5":"78.0.3904.130","7.1.6":"78.0.3904.130","7.1.7":"78.0.3904.130","7.1.8":"78.0.3904.130","7.1.9":"78.0.3904.130","7.1.10":"78.0.3904.130","7.1.11":"78.0.3904.130","7.1.12":"78.0.3904.130","7.1.13":"78.0.3904.130","7.1.14":"78.0.3904.130","7.2.0":"78.0.3904.130","7.2.1":"78.0.3904.130","7.2.2":"78.0.3904.130","7.2.3":"78.0.3904.130","7.2.4":"78.0.3904.130","7.3.0":"78.0.3904.130","7.3.1":"78.0.3904.130","7.3.2":"78.0.3904.130","7.3.3":"78.0.3904.130","8.0.0-beta.1":"79.0.3931.0","8.0.0-beta.2":"79.0.3931.0","8.0.0-beta.3":"80.0.3955.0","8.0.0-beta.4":"80.0.3955.0","8.0.0-beta.5":"80.0.3987.14","8.0.0-beta.6":"80.0.3987.51","8.0.0-beta.7":"80.0.3987.59","8.0.0-beta.8":"80.0.3987.75","8.0.0-beta.9":"80.0.3987.75","8.0.0-nightly.20190801":"78.0.3866.0","8.0.0-nightly.20190802":"78.0.3866.0","8.0.0-nightly.20190803":"78.0.3871.0","8.0.0-nightly.20190806":"78.0.3871.0","8.0.0-nightly.20190807":"78.0.3871.0","8.0.0-nightly.20190808":"78.0.3871.0","8.0.0-nightly.20190809":"78.0.3871.0","8.0.0-nightly.20190810":"78.0.3871.0","8.0.0-nightly.20190811":"78.0.3871.0","8.0.0-nightly.20190812":"78.0.3871.0","8.0.0-nightly.20190813":"78.0.3871.0","8.0.0-nightly.20190814":"78.0.3871.0","8.0.0-nightly.20190815":"78.0.3871.0","8.0.0-nightly.20190816":"78.0.3881.0","8.0.0-nightly.20190817":"78.0.3881.0","8.0.0-nightly.20190818":"78.0.3881.0","8.0.0-nightly.20190819":"78.0.3881.0","8.0.0-nightly.20190820":"78.0.3881.0","8.0.0-nightly.20190824":"78.0.3892.0","8.0.0-nightly.20190825":"78.0.3892.0","8.0.0-nightly.20190827":"78.0.3892.0","8.0.0-nightly.20190828":"78.0.3892.0","8.0.0-nightly.20190830":"78.0.3892.0","8.0.0-nightly.20190901":"78.0.3892.0","8.0.0-nightly.20190902":"78.0.3892.0","8.0.0-nightly.20190907":"78.0.3892.0","8.0.0-nightly.20190909":"78.0.3892.0","8.0.0-nightly.20190910":"78.0.3892.0","8.0.0-nightly.20190911":"78.0.3892.0","8.0.0-nightly.20190912":"78.0.3892.0","8.0.0-nightly.20190913":"78.0.3892.0","8.0.0-nightly.20190914":"78.0.3892.0","8.0.0-nightly.20190915":"78.0.3892.0","8.0.0-nightly.20190917":"78.0.3892.0","8.0.0-nightly.20190919":"79.0.3915.0","8.0.0-nightly.20190920":"79.0.3915.0","8.0.0-nightly.20190922":"79.0.3919.0","8.0.0-nightly.20190923":"79.0.3919.0","8.0.0-nightly.20190924":"79.0.3919.0","8.0.0-nightly.20190926":"79.0.3919.0","8.0.0-nightly.20190928":"79.0.3919.0","8.0.0-nightly.20190929":"79.0.3919.0","8.0.0-nightly.20190930":"79.0.3919.0","8.0.0-nightly.20191001":"79.0.3919.0","8.0.0-nightly.20191004":"79.0.3919.0","8.0.0-nightly.20191005":"79.0.3919.0","8.0.0-nightly.20191006":"79.0.3919.0","8.0.0-nightly.20191009":"79.0.3919.0","8.0.0-nightly.20191011":"79.0.3919.0","8.0.0-nightly.20191012":"79.0.3919.0","8.0.0-nightly.20191017":"79.0.3919.0","8.0.0-nightly.20191019":"79.0.3931.0","8.0.0-nightly.20191020":"79.0.3931.0","8.0.0-nightly.20191021":"79.0.3931.0","8.0.0-nightly.20191023":"79.0.3931.0","8.0.0-nightly.20191101":"80.0.3952.0","8.0.0-nightly.20191103":"80.0.3952.0","8.0.0-nightly.20191105":"80.0.3952.0","8.0.0":"80.0.3987.86","8.0.1":"80.0.3987.86","8.0.2":"80.0.3987.86","8.0.3":"80.0.3987.134","8.1.0":"80.0.3987.137","8.1.1":"80.0.3987.141","8.2.0":"80.0.3987.158","8.2.1":"80.0.3987.163","8.2.2":"80.0.3987.163","8.2.3":"80.0.3987.163","8.2.4":"80.0.3987.165","8.2.5":"80.0.3987.165","8.3.0":"80.0.3987.165","8.3.1":"80.0.3987.165","8.3.2":"80.0.3987.165","8.3.3":"80.0.3987.165","8.3.4":"80.0.3987.165","8.4.0":"80.0.3987.165","8.4.1":"80.0.3987.165","8.5.0":"80.0.3987.165","8.5.1":"80.0.3987.165","8.5.2":"80.0.3987.165","8.5.3":"80.0.3987.163","8.5.4":"80.0.3987.163","8.5.5":"80.0.3987.163","9.0.0-beta.1":"82.0.4048.0","9.0.0-beta.2":"82.0.4048.0","9.0.0-beta.3":"82.0.4048.0","9.0.0-beta.4":"82.0.4048.0","9.0.0-beta.5":"82.0.4048.0","9.0.0-beta.6":"82.0.4058.2","9.0.0-beta.7":"82.0.4058.2","9.0.0-beta.9":"82.0.4058.2","9.0.0-beta.10":"82.0.4085.10","9.0.0-beta.11":"82.0.4085.14","9.0.0-beta.12":"82.0.4085.14","9.0.0-beta.13":"82.0.4085.14","9.0.0-beta.14":"82.0.4085.27","9.0.0-beta.15":"83.0.4102.3","9.0.0-beta.16":"83.0.4102.3","9.0.0-beta.17":"83.0.4103.14","9.0.0-beta.18":"83.0.4103.16","9.0.0-beta.19":"83.0.4103.24","9.0.0-beta.20":"83.0.4103.26","9.0.0-beta.21":"83.0.4103.26","9.0.0-beta.22":"83.0.4103.34","9.0.0-beta.23":"83.0.4103.44","9.0.0-beta.24":"83.0.4103.45","9.0.0-nightly.20191121":"80.0.3954.0","9.0.0-nightly.20191122":"80.0.3954.0","9.0.0-nightly.20191123":"80.0.3954.0","9.0.0-nightly.20191124":"80.0.3954.0","9.0.0-nightly.20191126":"80.0.3954.0","9.0.0-nightly.20191128":"80.0.3954.0","9.0.0-nightly.20191129":"80.0.3954.0","9.0.0-nightly.20191130":"80.0.3954.0","9.0.0-nightly.20191201":"80.0.3954.0","9.0.0-nightly.20191202":"80.0.3954.0","9.0.0-nightly.20191203":"80.0.3954.0","9.0.0-nightly.20191204":"80.0.3954.0","9.0.0-nightly.20191205":"80.0.3954.0","9.0.0-nightly.20191210":"80.0.3954.0","9.0.0-nightly.20191220":"81.0.3994.0","9.0.0-nightly.20191221":"81.0.3994.0","9.0.0-nightly.20191222":"81.0.3994.0","9.0.0-nightly.20191223":"81.0.3994.0","9.0.0-nightly.20191224":"81.0.3994.0","9.0.0-nightly.20191225":"81.0.3994.0","9.0.0-nightly.20191226":"81.0.3994.0","9.0.0-nightly.20191228":"81.0.3994.0","9.0.0-nightly.20191229":"81.0.3994.0","9.0.0-nightly.20191230":"81.0.3994.0","9.0.0-nightly.20191231":"81.0.3994.0","9.0.0-nightly.20200101":"81.0.3994.0","9.0.0-nightly.20200103":"81.0.3994.0","9.0.0-nightly.20200104":"81.0.3994.0","9.0.0-nightly.20200105":"81.0.3994.0","9.0.0-nightly.20200106":"81.0.3994.0","9.0.0-nightly.20200108":"81.0.3994.0","9.0.0-nightly.20200109":"81.0.3994.0","9.0.0-nightly.20200110":"81.0.3994.0","9.0.0-nightly.20200111":"81.0.3994.0","9.0.0-nightly.20200113":"81.0.3994.0","9.0.0-nightly.20200115":"81.0.3994.0","9.0.0-nightly.20200116":"81.0.3994.0","9.0.0-nightly.20200117":"81.0.3994.0","9.0.0-nightly.20200119":"81.0.4030.0","9.0.0-nightly.20200121":"81.0.4030.0","9.0.0":"83.0.4103.64","9.0.1":"83.0.4103.94","9.0.2":"83.0.4103.94","9.0.3":"83.0.4103.100","9.0.4":"83.0.4103.104","9.0.5":"83.0.4103.119","9.1.0":"83.0.4103.122","9.1.1":"83.0.4103.122","9.1.2":"83.0.4103.122","9.2.0":"83.0.4103.122","9.2.1":"83.0.4103.122","9.3.0":"83.0.4103.122","9.3.1":"83.0.4103.122","9.3.2":"83.0.4103.122","9.3.3":"83.0.4103.122","9.3.4":"83.0.4103.122","9.3.5":"83.0.4103.122","9.4.0":"83.0.4103.122","9.4.1":"83.0.4103.122","9.4.2":"83.0.4103.122","9.4.3":"83.0.4103.122","9.4.4":"83.0.4103.122","10.0.0-beta.1":"84.0.4129.0","10.0.0-beta.2":"84.0.4129.0","10.0.0-beta.3":"85.0.4161.2","10.0.0-beta.4":"85.0.4161.2","10.0.0-beta.8":"85.0.4181.1","10.0.0-beta.9":"85.0.4181.1","10.0.0-beta.10":"85.0.4183.19","10.0.0-beta.11":"85.0.4183.20","10.0.0-beta.12":"85.0.4183.26","10.0.0-beta.13":"85.0.4183.39","10.0.0-beta.14":"85.0.4183.39","10.0.0-beta.15":"85.0.4183.39","10.0.0-beta.17":"85.0.4183.39","10.0.0-beta.19":"85.0.4183.39","10.0.0-beta.20":"85.0.4183.39","10.0.0-beta.21":"85.0.4183.39","10.0.0-beta.23":"85.0.4183.70","10.0.0-beta.24":"85.0.4183.78","10.0.0-beta.25":"85.0.4183.80","10.0.0-nightly.20200209":"82.0.4050.0","10.0.0-nightly.20200210":"82.0.4050.0","10.0.0-nightly.20200211":"82.0.4050.0","10.0.0-nightly.20200216":"82.0.4050.0","10.0.0-nightly.20200217":"82.0.4050.0","10.0.0-nightly.20200218":"82.0.4050.0","10.0.0-nightly.20200221":"82.0.4050.0","10.0.0-nightly.20200222":"82.0.4050.0","10.0.0-nightly.20200223":"82.0.4050.0","10.0.0-nightly.20200226":"82.0.4050.0","10.0.0-nightly.20200303":"82.0.4050.0","10.0.0-nightly.20200304":"82.0.4076.0","10.0.0-nightly.20200305":"82.0.4076.0","10.0.0-nightly.20200306":"82.0.4076.0","10.0.0-nightly.20200309":"82.0.4076.0","10.0.0-nightly.20200310":"82.0.4076.0","10.0.0-nightly.20200311":"82.0.4083.0","10.0.0-nightly.20200316":"83.0.4086.0","10.0.0-nightly.20200317":"83.0.4087.0","10.0.0-nightly.20200318":"83.0.4087.0","10.0.0-nightly.20200320":"83.0.4087.0","10.0.0-nightly.20200323":"83.0.4087.0","10.0.0-nightly.20200324":"83.0.4087.0","10.0.0-nightly.20200325":"83.0.4087.0","10.0.0-nightly.20200326":"83.0.4087.0","10.0.0-nightly.20200327":"83.0.4087.0","10.0.0-nightly.20200330":"83.0.4087.0","10.0.0-nightly.20200331":"83.0.4087.0","10.0.0-nightly.20200401":"83.0.4087.0","10.0.0-nightly.20200402":"83.0.4087.0","10.0.0-nightly.20200403":"83.0.4087.0","10.0.0-nightly.20200406":"83.0.4087.0","10.0.0-nightly.20200408":"83.0.4095.0","10.0.0-nightly.20200410":"83.0.4095.0","10.0.0-nightly.20200413":"83.0.4095.0","10.0.0-nightly.20200414":"84.0.4114.0","10.0.0-nightly.20200415":"84.0.4115.0","10.0.0-nightly.20200416":"84.0.4115.0","10.0.0-nightly.20200417":"84.0.4115.0","10.0.0-nightly.20200422":"84.0.4121.0","10.0.0-nightly.20200423":"84.0.4121.0","10.0.0-nightly.20200427":"84.0.4125.0","10.0.0-nightly.20200428":"84.0.4125.0","10.0.0-nightly.20200429":"84.0.4125.0","10.0.0-nightly.20200430":"84.0.4125.0","10.0.0-nightly.20200501":"84.0.4129.0","10.0.0-nightly.20200504":"84.0.4129.0","10.0.0-nightly.20200505":"84.0.4129.0","10.0.0-nightly.20200506":"84.0.4129.0","10.0.0-nightly.20200507":"84.0.4129.0","10.0.0-nightly.20200508":"84.0.4129.0","10.0.0-nightly.20200511":"84.0.4129.0","10.0.0-nightly.20200512":"84.0.4129.0","10.0.0-nightly.20200513":"84.0.4129.0","10.0.0-nightly.20200514":"84.0.4129.0","10.0.0-nightly.20200515":"84.0.4129.0","10.0.0-nightly.20200518":"84.0.4129.0","10.0.0-nightly.20200519":"84.0.4129.0","10.0.0-nightly.20200520":"84.0.4129.0","10.0.0-nightly.20200521":"84.0.4129.0","10.0.0":"85.0.4183.84","10.0.1":"85.0.4183.86","10.1.0":"85.0.4183.87","10.1.1":"85.0.4183.93","10.1.2":"85.0.4183.98","10.1.3":"85.0.4183.121","10.1.4":"85.0.4183.121","10.1.5":"85.0.4183.121","10.1.6":"85.0.4183.121","10.1.7":"85.0.4183.121","10.2.0":"85.0.4183.121","10.3.0":"85.0.4183.121","10.3.1":"85.0.4183.121","10.3.2":"85.0.4183.121","10.4.0":"85.0.4183.121","10.4.1":"85.0.4183.121","10.4.2":"85.0.4183.121","10.4.3":"85.0.4183.121","10.4.4":"85.0.4183.121","10.4.5":"85.0.4183.121","10.4.6":"85.0.4183.121","10.4.7":"85.0.4183.121","11.0.0-beta.1":"86.0.4234.0","11.0.0-beta.3":"86.0.4234.0","11.0.0-beta.4":"86.0.4234.0","11.0.0-beta.5":"86.0.4234.0","11.0.0-beta.6":"86.0.4234.0","11.0.0-beta.7":"86.0.4234.0","11.0.0-beta.8":"87.0.4251.1","11.0.0-beta.9":"87.0.4251.1","11.0.0-beta.11":"87.0.4251.1","11.0.0-beta.12":"87.0.4280.11","11.0.0-beta.13":"87.0.4280.11","11.0.0-beta.16":"87.0.4280.27","11.0.0-beta.17":"87.0.4280.27","11.0.0-beta.18":"87.0.4280.27","11.0.0-beta.19":"87.0.4280.27","11.0.0-beta.20":"87.0.4280.40","11.0.0-beta.22":"87.0.4280.47","11.0.0-beta.23":"87.0.4280.47","11.0.0-nightly.20200525":"84.0.4129.0","11.0.0-nightly.20200526":"84.0.4129.0","11.0.0-nightly.20200529":"85.0.4156.0","11.0.0-nightly.20200602":"85.0.4162.0","11.0.0-nightly.20200603":"85.0.4162.0","11.0.0-nightly.20200604":"85.0.4162.0","11.0.0-nightly.20200609":"85.0.4162.0","11.0.0-nightly.20200610":"85.0.4162.0","11.0.0-nightly.20200611":"85.0.4162.0","11.0.0-nightly.20200615":"85.0.4162.0","11.0.0-nightly.20200616":"85.0.4162.0","11.0.0-nightly.20200617":"85.0.4162.0","11.0.0-nightly.20200618":"85.0.4162.0","11.0.0-nightly.20200619":"85.0.4162.0","11.0.0-nightly.20200701":"85.0.4179.0","11.0.0-nightly.20200702":"85.0.4179.0","11.0.0-nightly.20200703":"85.0.4179.0","11.0.0-nightly.20200706":"85.0.4179.0","11.0.0-nightly.20200707":"85.0.4179.0","11.0.0-nightly.20200708":"85.0.4179.0","11.0.0-nightly.20200709":"85.0.4179.0","11.0.0-nightly.20200716":"86.0.4203.0","11.0.0-nightly.20200717":"86.0.4203.0","11.0.0-nightly.20200720":"86.0.4203.0","11.0.0-nightly.20200721":"86.0.4203.0","11.0.0-nightly.20200723":"86.0.4209.0","11.0.0-nightly.20200724":"86.0.4209.0","11.0.0-nightly.20200729":"86.0.4209.0","11.0.0-nightly.20200730":"86.0.4209.0","11.0.0-nightly.20200731":"86.0.4209.0","11.0.0-nightly.20200803":"86.0.4209.0","11.0.0-nightly.20200804":"86.0.4209.0","11.0.0-nightly.20200805":"86.0.4209.0","11.0.0-nightly.20200811":"86.0.4209.0","11.0.0-nightly.20200812":"86.0.4209.0","11.0.0-nightly.20200822":"86.0.4234.0","11.0.0-nightly.20200824":"86.0.4234.0","11.0.0-nightly.20200825":"86.0.4234.0","11.0.0-nightly.20200826":"86.0.4234.0","11.0.0":"87.0.4280.60","11.0.1":"87.0.4280.60","11.0.2":"87.0.4280.67","11.0.3":"87.0.4280.67","11.0.4":"87.0.4280.67","11.0.5":"87.0.4280.88","11.1.0":"87.0.4280.88","11.1.1":"87.0.4280.88","11.2.0":"87.0.4280.141","11.2.1":"87.0.4280.141","11.2.2":"87.0.4280.141","11.2.3":"87.0.4280.141","11.3.0":"87.0.4280.141","11.4.0":"87.0.4280.141","11.4.1":"87.0.4280.141","11.4.2":"87.0.4280.141","11.4.3":"87.0.4280.141","11.4.4":"87.0.4280.141","11.4.5":"87.0.4280.141","11.4.6":"87.0.4280.141","11.4.7":"87.0.4280.141","11.4.8":"87.0.4280.141","11.4.9":"87.0.4280.141","11.4.10":"87.0.4280.141","11.4.11":"87.0.4280.141","11.4.12":"87.0.4280.141","11.5.0":"87.0.4280.141","12.0.0-beta.1":"89.0.4328.0","12.0.0-beta.3":"89.0.4328.0","12.0.0-beta.4":"89.0.4328.0","12.0.0-beta.5":"89.0.4328.0","12.0.0-beta.6":"89.0.4328.0","12.0.0-beta.7":"89.0.4328.0","12.0.0-beta.8":"89.0.4328.0","12.0.0-beta.9":"89.0.4328.0","12.0.0-beta.10":"89.0.4328.0","12.0.0-beta.11":"89.0.4328.0","12.0.0-beta.12":"89.0.4328.0","12.0.0-beta.14":"89.0.4328.0","12.0.0-beta.16":"89.0.4348.1","12.0.0-beta.18":"89.0.4348.1","12.0.0-beta.19":"89.0.4348.1","12.0.0-beta.20":"89.0.4348.1","12.0.0-beta.21":"89.0.4388.2","12.0.0-beta.22":"89.0.4388.2","12.0.0-beta.23":"89.0.4388.2","12.0.0-beta.24":"89.0.4388.2","12.0.0-beta.25":"89.0.4388.2","12.0.0-beta.26":"89.0.4388.2","12.0.0-beta.27":"89.0.4389.23","12.0.0-beta.28":"89.0.4389.23","12.0.0-beta.29":"89.0.4389.23","12.0.0-beta.30":"89.0.4389.58","12.0.0-beta.31":"89.0.4389.58","12.0.0-nightly.20200827":"86.0.4234.0","12.0.0-nightly.20200831":"86.0.4234.0","12.0.0-nightly.20200902":"86.0.4234.0","12.0.0-nightly.20200903":"86.0.4234.0","12.0.0-nightly.20200907":"86.0.4234.0","12.0.0-nightly.20200910":"86.0.4234.0","12.0.0-nightly.20200911":"86.0.4234.0","12.0.0-nightly.20200914":"86.0.4234.0","12.0.0-nightly.20201002":"87.0.4268.0","12.0.0-nightly.20201007":"87.0.4268.0","12.0.0-nightly.20201009":"87.0.4268.0","12.0.0-nightly.20201012":"87.0.4268.0","12.0.0-nightly.20201013":"87.0.4268.0","12.0.0-nightly.20201014":"87.0.4268.0","12.0.0-nightly.20201015":"87.0.4268.0","12.0.0-nightly.20201023":"88.0.4292.0","12.0.0-nightly.20201026":"88.0.4292.0","12.0.0-nightly.20201030":"88.0.4306.0","12.0.0-nightly.20201102":"88.0.4306.0","12.0.0-nightly.20201103":"88.0.4306.0","12.0.0-nightly.20201104":"88.0.4306.0","12.0.0-nightly.20201105":"88.0.4306.0","12.0.0-nightly.20201106":"88.0.4306.0","12.0.0-nightly.20201111":"88.0.4306.0","12.0.0-nightly.20201112":"88.0.4306.0","12.0.0-nightly.20201116":"88.0.4324.0","12.0.0":"89.0.4389.69","12.0.1":"89.0.4389.82","12.0.2":"89.0.4389.90","12.0.3":"89.0.4389.114","12.0.4":"89.0.4389.114","12.0.5":"89.0.4389.128","12.0.6":"89.0.4389.128","12.0.7":"89.0.4389.128","12.0.8":"89.0.4389.128","12.0.9":"89.0.4389.128","12.0.10":"89.0.4389.128","12.0.11":"89.0.4389.128","12.0.12":"89.0.4389.128","12.0.13":"89.0.4389.128","12.0.14":"89.0.4389.128","12.0.15":"89.0.4389.128","12.0.16":"89.0.4389.128","12.0.17":"89.0.4389.128","12.0.18":"89.0.4389.128","12.1.0":"89.0.4389.128","12.1.1":"89.0.4389.128","12.1.2":"89.0.4389.128","12.2.0":"89.0.4389.128","12.2.1":"89.0.4389.128","12.2.2":"89.0.4389.128","12.2.3":"89.0.4389.128","13.0.0-beta.2":"90.0.4402.0","13.0.0-beta.3":"90.0.4402.0","13.0.0-beta.4":"90.0.4415.0","13.0.0-beta.5":"90.0.4415.0","13.0.0-beta.6":"90.0.4415.0","13.0.0-beta.7":"90.0.4415.0","13.0.0-beta.8":"90.0.4415.0","13.0.0-beta.9":"90.0.4415.0","13.0.0-beta.10":"90.0.4415.0","13.0.0-beta.11":"90.0.4415.0","13.0.0-beta.12":"90.0.4415.0","13.0.0-beta.13":"90.0.4415.0","13.0.0-beta.14":"91.0.4448.0","13.0.0-beta.16":"91.0.4448.0","13.0.0-beta.17":"91.0.4448.0","13.0.0-beta.18":"91.0.4448.0","13.0.0-beta.20":"91.0.4448.0","13.0.0-beta.21":"91.0.4472.33","13.0.0-beta.22":"91.0.4472.33","13.0.0-beta.23":"91.0.4472.33","13.0.0-beta.24":"91.0.4472.38","13.0.0-beta.25":"91.0.4472.38","13.0.0-beta.26":"91.0.4472.38","13.0.0-beta.27":"91.0.4472.38","13.0.0-beta.28":"91.0.4472.38","13.0.0-nightly.20201119":"89.0.4328.0","13.0.0-nightly.20201123":"89.0.4328.0","13.0.0-nightly.20201124":"89.0.4328.0","13.0.0-nightly.20201126":"89.0.4328.0","13.0.0-nightly.20201127":"89.0.4328.0","13.0.0-nightly.20201130":"89.0.4328.0","13.0.0-nightly.20201201":"89.0.4328.0","13.0.0-nightly.20201202":"89.0.4328.0","13.0.0-nightly.20201203":"89.0.4328.0","13.0.0-nightly.20201204":"89.0.4328.0","13.0.0-nightly.20201207":"89.0.4328.0","13.0.0-nightly.20201208":"89.0.4328.0","13.0.0-nightly.20201209":"89.0.4328.0","13.0.0-nightly.20201210":"89.0.4328.0","13.0.0-nightly.20201211":"89.0.4328.0","13.0.0-nightly.20201214":"89.0.4328.0","13.0.0-nightly.20201215":"89.0.4349.0","13.0.0-nightly.20201216":"89.0.4349.0","13.0.0-nightly.20201221":"89.0.4349.0","13.0.0-nightly.20201222":"89.0.4349.0","13.0.0-nightly.20201223":"89.0.4359.0","13.0.0-nightly.20210104":"89.0.4359.0","13.0.0-nightly.20210108":"89.0.4359.0","13.0.0-nightly.20210111":"89.0.4359.0","13.0.0-nightly.20210113":"89.0.4386.0","13.0.0-nightly.20210114":"89.0.4386.0","13.0.0-nightly.20210118":"89.0.4386.0","13.0.0-nightly.20210122":"89.0.4386.0","13.0.0-nightly.20210125":"89.0.4386.0","13.0.0-nightly.20210127":"89.0.4389.0","13.0.0-nightly.20210128":"89.0.4389.0","13.0.0-nightly.20210129":"89.0.4389.0","13.0.0-nightly.20210201":"89.0.4389.0","13.0.0-nightly.20210202":"89.0.4389.0","13.0.0-nightly.20210203":"89.0.4389.0","13.0.0-nightly.20210205":"89.0.4389.0","13.0.0-nightly.20210208":"89.0.4389.0","13.0.0-nightly.20210209":"89.0.4389.0","13.0.0-nightly.20210210":"90.0.4402.0","13.0.0-nightly.20210211":"90.0.4402.0","13.0.0-nightly.20210212":"90.0.4402.0","13.0.0-nightly.20210216":"90.0.4402.0","13.0.0-nightly.20210217":"90.0.4402.0","13.0.0-nightly.20210218":"90.0.4402.0","13.0.0-nightly.20210219":"90.0.4402.0","13.0.0-nightly.20210222":"90.0.4402.0","13.0.0-nightly.20210225":"90.0.4402.0","13.0.0-nightly.20210226":"90.0.4402.0","13.0.0-nightly.20210301":"90.0.4402.0","13.0.0-nightly.20210302":"90.0.4402.0","13.0.0-nightly.20210303":"90.0.4402.0","13.0.0":"91.0.4472.69","13.0.1":"91.0.4472.69","13.1.0":"91.0.4472.77","13.1.1":"91.0.4472.77","13.1.2":"91.0.4472.77","13.1.3":"91.0.4472.106","13.1.4":"91.0.4472.106","13.1.5":"91.0.4472.124","13.1.6":"91.0.4472.124","13.1.7":"91.0.4472.124","13.1.8":"91.0.4472.164","13.1.9":"91.0.4472.164","13.2.0":"91.0.4472.164","13.2.1":"91.0.4472.164","13.2.2":"91.0.4472.164","13.2.3":"91.0.4472.164","13.3.0":"91.0.4472.164","13.4.0":"91.0.4472.164","13.5.0":"91.0.4472.164","13.5.1":"91.0.4472.164","13.5.2":"91.0.4472.164","13.6.0":"91.0.4472.164","13.6.1":"91.0.4472.164","13.6.2":"91.0.4472.164","13.6.3":"91.0.4472.164","13.6.6":"91.0.4472.164","13.6.7":"91.0.4472.164","13.6.8":"91.0.4472.164","13.6.9":"91.0.4472.164","14.0.0-beta.1":"92.0.4511.0","14.0.0-beta.2":"92.0.4511.0","14.0.0-beta.3":"92.0.4511.0","14.0.0-beta.5":"93.0.4536.0","14.0.0-beta.6":"93.0.4536.0","14.0.0-beta.7":"93.0.4536.0","14.0.0-beta.8":"93.0.4536.0","14.0.0-beta.9":"93.0.4539.0","14.0.0-beta.10":"93.0.4539.0","14.0.0-beta.11":"93.0.4557.4","14.0.0-beta.12":"93.0.4557.4","14.0.0-beta.13":"93.0.4566.0","14.0.0-beta.14":"93.0.4566.0","14.0.0-beta.15":"93.0.4566.0","14.0.0-beta.16":"93.0.4566.0","14.0.0-beta.17":"93.0.4566.0","14.0.0-beta.18":"93.0.4577.15","14.0.0-beta.19":"93.0.4577.15","14.0.0-beta.20":"93.0.4577.15","14.0.0-beta.21":"93.0.4577.15","14.0.0-beta.22":"93.0.4577.25","14.0.0-beta.23":"93.0.4577.25","14.0.0-beta.24":"93.0.4577.51","14.0.0-beta.25":"93.0.4577.51","14.0.0-nightly.20210304":"90.0.4402.0","14.0.0-nightly.20210305":"90.0.4415.0","14.0.0-nightly.20210308":"90.0.4415.0","14.0.0-nightly.20210309":"90.0.4415.0","14.0.0-nightly.20210311":"90.0.4415.0","14.0.0-nightly.20210315":"90.0.4415.0","14.0.0-nightly.20210316":"90.0.4415.0","14.0.0-nightly.20210317":"90.0.4415.0","14.0.0-nightly.20210318":"90.0.4415.0","14.0.0-nightly.20210319":"90.0.4415.0","14.0.0-nightly.20210323":"90.0.4415.0","14.0.0-nightly.20210324":"90.0.4415.0","14.0.0-nightly.20210325":"90.0.4415.0","14.0.0-nightly.20210326":"90.0.4415.0","14.0.0-nightly.20210329":"90.0.4415.0","14.0.0-nightly.20210330":"90.0.4415.0","14.0.0-nightly.20210331":"91.0.4448.0","14.0.0-nightly.20210401":"91.0.4448.0","14.0.0-nightly.20210402":"91.0.4448.0","14.0.0-nightly.20210406":"91.0.4448.0","14.0.0-nightly.20210407":"91.0.4448.0","14.0.0-nightly.20210408":"91.0.4448.0","14.0.0-nightly.20210409":"91.0.4448.0","14.0.0-nightly.20210413":"91.0.4448.0","14.0.0-nightly.20210426":"92.0.4475.0","14.0.0-nightly.20210427":"92.0.4475.0","14.0.0-nightly.20210430":"92.0.4488.0","14.0.0-nightly.20210503":"92.0.4488.0","14.0.0-nightly.20210505":"92.0.4496.0","14.0.0-nightly.20210506":"92.0.4498.0","14.0.0-nightly.20210507":"92.0.4499.0","14.0.0-nightly.20210510":"92.0.4499.0","14.0.0-nightly.20210511":"92.0.4499.0","14.0.0-nightly.20210512":"92.0.4499.0","14.0.0-nightly.20210513":"92.0.4499.0","14.0.0-nightly.20210514":"92.0.4505.0","14.0.0-nightly.20210517":"92.0.4505.0","14.0.0-nightly.20210518":"92.0.4505.0","14.0.0-nightly.20210519":"92.0.4505.0","14.0.0-nightly.20210520":"92.0.4511.0","14.0.0-nightly.20210523":"92.0.4511.0","14.0.0-nightly.20210524":"92.0.4511.0","14.0.0":"93.0.4577.58","14.0.1":"93.0.4577.63","14.0.2":"93.0.4577.82","14.1.0":"93.0.4577.82","14.1.1":"93.0.4577.82","14.2.0":"93.0.4577.82","14.2.1":"93.0.4577.82","14.2.2":"93.0.4577.82","14.2.3":"93.0.4577.82","14.2.4":"93.0.4577.82","14.2.5":"93.0.4577.82","14.2.6":"93.0.4577.82","14.2.7":"93.0.4577.82","14.2.8":"93.0.4577.82","14.2.9":"93.0.4577.82","15.0.0-alpha.1":"93.0.4566.0","15.0.0-alpha.2":"93.0.4566.0","15.0.0-alpha.3":"94.0.4584.0","15.0.0-alpha.4":"94.0.4584.0","15.0.0-alpha.5":"94.0.4584.0","15.0.0-alpha.6":"94.0.4584.0","15.0.0-alpha.7":"94.0.4590.2","15.0.0-alpha.8":"94.0.4590.2","15.0.0-alpha.9":"94.0.4590.2","15.0.0-alpha.10":"94.0.4606.12","15.0.0-beta.1":"94.0.4606.20","15.0.0-beta.2":"94.0.4606.20","15.0.0-beta.3":"94.0.4606.31","15.0.0-beta.4":"94.0.4606.31","15.0.0-beta.5":"94.0.4606.31","15.0.0-beta.6":"94.0.4606.31","15.0.0-beta.7":"94.0.4606.31","15.0.0-nightly.20210527":"92.0.4511.0","15.0.0-nightly.20210528":"92.0.4511.0","15.0.0-nightly.20210531":"92.0.4511.0","15.0.0-nightly.20210601":"92.0.4511.0","15.0.0-nightly.20210602":"92.0.4511.0","15.0.0-nightly.20210603":"93.0.4530.0","15.0.0-nightly.20210604":"93.0.4530.0","15.0.0-nightly.20210608":"93.0.4535.0","15.0.0-nightly.20210609":"93.0.4536.0","15.0.0-nightly.20210610":"93.0.4536.0","15.0.0-nightly.20210611":"93.0.4536.0","15.0.0-nightly.20210614":"93.0.4536.0","15.0.0-nightly.20210615":"93.0.4536.0","15.0.0-nightly.20210616":"93.0.4536.0","15.0.0-nightly.20210617":"93.0.4539.0","15.0.0-nightly.20210618":"93.0.4539.0","15.0.0-nightly.20210621":"93.0.4539.0","15.0.0-nightly.20210622":"93.0.4539.0","15.0.0-nightly.20210623":"93.0.4550.0","15.0.0-nightly.20210624":"93.0.4550.0","15.0.0-nightly.20210625":"93.0.4552.0","15.0.0-nightly.20210628":"93.0.4552.0","15.0.0-nightly.20210629":"93.0.4552.0","15.0.0-nightly.20210630":"93.0.4558.0","15.0.0-nightly.20210701":"93.0.4558.0","15.0.0-nightly.20210702":"93.0.4558.0","15.0.0-nightly.20210705":"93.0.4558.0","15.0.0-nightly.20210706":"93.0.4566.0","15.0.0-nightly.20210707":"93.0.4566.0","15.0.0-nightly.20210708":"93.0.4566.0","15.0.0-nightly.20210709":"93.0.4566.0","15.0.0-nightly.20210712":"93.0.4566.0","15.0.0-nightly.20210713":"93.0.4566.0","15.0.0-nightly.20210714":"93.0.4566.0","15.0.0-nightly.20210715":"93.0.4566.0","15.0.0-nightly.20210716":"93.0.4566.0","15.0.0-nightly.20210719":"93.0.4566.0","15.0.0-nightly.20210720":"93.0.4566.0","15.0.0-nightly.20210721":"93.0.4566.0","15.0.0":"94.0.4606.51","15.1.0":"94.0.4606.61","15.1.1":"94.0.4606.61","15.1.2":"94.0.4606.71","15.2.0":"94.0.4606.81","15.3.0":"94.0.4606.81","15.3.1":"94.0.4606.81","15.3.2":"94.0.4606.81","15.3.3":"94.0.4606.81","15.3.4":"94.0.4606.81","15.3.5":"94.0.4606.81","15.3.6":"94.0.4606.81","15.3.7":"94.0.4606.81","15.4.0":"94.0.4606.81","15.4.1":"94.0.4606.81","15.4.2":"94.0.4606.81","15.5.0":"94.0.4606.81","15.5.1":"94.0.4606.81","15.5.2":"94.0.4606.81","15.5.3":"94.0.4606.81","15.5.4":"94.0.4606.81","15.5.5":"94.0.4606.81","15.5.6":"94.0.4606.81","15.5.7":"94.0.4606.81","16.0.0-alpha.1":"95.0.4629.0","16.0.0-alpha.2":"95.0.4629.0","16.0.0-alpha.3":"95.0.4629.0","16.0.0-alpha.4":"95.0.4629.0","16.0.0-alpha.5":"95.0.4629.0","16.0.0-alpha.6":"95.0.4629.0","16.0.0-alpha.7":"95.0.4629.0","16.0.0-alpha.8":"96.0.4647.0","16.0.0-alpha.9":"96.0.4647.0","16.0.0-beta.1":"96.0.4647.0","16.0.0-beta.2":"96.0.4647.0","16.0.0-beta.3":"96.0.4647.0","16.0.0-beta.4":"96.0.4664.18","16.0.0-beta.5":"96.0.4664.18","16.0.0-beta.6":"96.0.4664.27","16.0.0-beta.7":"96.0.4664.27","16.0.0-beta.8":"96.0.4664.35","16.0.0-beta.9":"96.0.4664.35","16.0.0-nightly.20210722":"93.0.4566.0","16.0.0-nightly.20210723":"93.0.4566.0","16.0.0-nightly.20210726":"93.0.4566.0","16.0.0-nightly.20210727":"94.0.4584.0","16.0.0-nightly.20210728":"94.0.4584.0","16.0.0-nightly.20210729":"94.0.4584.0","16.0.0-nightly.20210730":"94.0.4584.0","16.0.0-nightly.20210802":"94.0.4584.0","16.0.0-nightly.20210803":"94.0.4584.0","16.0.0-nightly.20210804":"94.0.4584.0","16.0.0-nightly.20210805":"94.0.4584.0","16.0.0-nightly.20210806":"94.0.4584.0","16.0.0-nightly.20210809":"94.0.4584.0","16.0.0-nightly.20210810":"94.0.4584.0","16.0.0-nightly.20210811":"94.0.4584.0","16.0.0-nightly.20210812":"94.0.4590.2","16.0.0-nightly.20210813":"94.0.4590.2","16.0.0-nightly.20210816":"94.0.4590.2","16.0.0-nightly.20210817":"94.0.4590.2","16.0.0-nightly.20210818":"94.0.4590.2","16.0.0-nightly.20210819":"94.0.4590.2","16.0.0-nightly.20210820":"94.0.4590.2","16.0.0-nightly.20210823":"94.0.4590.2","16.0.0-nightly.20210824":"95.0.4612.5","16.0.0-nightly.20210825":"95.0.4612.5","16.0.0-nightly.20210826":"95.0.4612.5","16.0.0-nightly.20210827":"95.0.4612.5","16.0.0-nightly.20210830":"95.0.4612.5","16.0.0-nightly.20210831":"95.0.4612.5","16.0.0-nightly.20210901":"95.0.4612.5","16.0.0-nightly.20210902":"95.0.4629.0","16.0.0-nightly.20210903":"95.0.4629.0","16.0.0-nightly.20210906":"95.0.4629.0","16.0.0-nightly.20210907":"95.0.4629.0","16.0.0-nightly.20210908":"95.0.4629.0","16.0.0-nightly.20210909":"95.0.4629.0","16.0.0-nightly.20210910":"95.0.4629.0","16.0.0-nightly.20210913":"95.0.4629.0","16.0.0-nightly.20210914":"95.0.4629.0","16.0.0-nightly.20210915":"95.0.4629.0","16.0.0-nightly.20210916":"95.0.4629.0","16.0.0-nightly.20210917":"95.0.4629.0","16.0.0-nightly.20210920":"95.0.4629.0","16.0.0-nightly.20210921":"95.0.4629.0","16.0.0-nightly.20210922":"95.0.4629.0","16.0.0":"96.0.4664.45","16.0.1":"96.0.4664.45","16.0.2":"96.0.4664.55","16.0.3":"96.0.4664.55","16.0.4":"96.0.4664.55","16.0.5":"96.0.4664.55","16.0.6":"96.0.4664.110","16.0.7":"96.0.4664.110","16.0.8":"96.0.4664.110","16.0.9":"96.0.4664.174","16.0.10":"96.0.4664.174","16.1.0":"96.0.4664.174","16.1.1":"96.0.4664.174","16.2.0":"96.0.4664.174","16.2.1":"96.0.4664.174","16.2.2":"96.0.4664.174","16.2.3":"96.0.4664.174","16.2.4":"96.0.4664.174","16.2.5":"96.0.4664.174","16.2.6":"96.0.4664.174","16.2.7":"96.0.4664.174","16.2.8":"96.0.4664.174","17.0.0-alpha.1":"96.0.4664.4","17.0.0-alpha.2":"96.0.4664.4","17.0.0-alpha.3":"96.0.4664.4","17.0.0-alpha.4":"98.0.4706.0","17.0.0-alpha.5":"98.0.4706.0","17.0.0-alpha.6":"98.0.4706.0","17.0.0-beta.1":"98.0.4706.0","17.0.0-beta.2":"98.0.4706.0","17.0.0-beta.3":"98.0.4758.9","17.0.0-beta.4":"98.0.4758.11","17.0.0-beta.5":"98.0.4758.11","17.0.0-beta.6":"98.0.4758.11","17.0.0-beta.7":"98.0.4758.11","17.0.0-beta.8":"98.0.4758.11","17.0.0-beta.9":"98.0.4758.11","17.0.0-nightly.20210923":"95.0.4629.0","17.0.0-nightly.20210924":"95.0.4629.0","17.0.0-nightly.20210927":"95.0.4629.0","17.0.0-nightly.20210928":"95.0.4629.0","17.0.0-nightly.20210929":"95.0.4629.0","17.0.0-nightly.20210930":"95.0.4629.0","17.0.0-nightly.20211001":"95.0.4629.0","17.0.0-nightly.20211004":"95.0.4629.0","17.0.0-nightly.20211005":"95.0.4629.0","17.0.0-nightly.20211006":"96.0.4647.0","17.0.0-nightly.20211007":"96.0.4647.0","17.0.0-nightly.20211008":"96.0.4647.0","17.0.0-nightly.20211011":"96.0.4647.0","17.0.0-nightly.20211012":"96.0.4647.0","17.0.0-nightly.20211013":"96.0.4647.0","17.0.0-nightly.20211014":"96.0.4647.0","17.0.0-nightly.20211015":"96.0.4647.0","17.0.0-nightly.20211018":"96.0.4647.0","17.0.0-nightly.20211019":"96.0.4647.0","17.0.0-nightly.20211020":"96.0.4647.0","17.0.0-nightly.20211021":"96.0.4647.0","17.0.0-nightly.20211022":"96.0.4664.4","17.0.0-nightly.20211025":"96.0.4664.4","17.0.0-nightly.20211026":"96.0.4664.4","17.0.0-nightly.20211027":"96.0.4664.4","17.0.0-nightly.20211028":"96.0.4664.4","17.0.0-nightly.20211029":"96.0.4664.4","17.0.0-nightly.20211101":"96.0.4664.4","17.0.0-nightly.20211102":"96.0.4664.4","17.0.0-nightly.20211103":"96.0.4664.4","17.0.0-nightly.20211104":"96.0.4664.4","17.0.0-nightly.20211105":"96.0.4664.4","17.0.0-nightly.20211108":"96.0.4664.4","17.0.0-nightly.20211109":"96.0.4664.4","17.0.0-nightly.20211110":"96.0.4664.4","17.0.0-nightly.20211111":"96.0.4664.4","17.0.0-nightly.20211112":"96.0.4664.4","17.0.0-nightly.20211115":"96.0.4664.4","17.0.0-nightly.20211116":"96.0.4664.4","17.0.0-nightly.20211117":"96.0.4664.4","17.0.0":"98.0.4758.74","17.0.1":"98.0.4758.82","17.1.0":"98.0.4758.102","17.1.1":"98.0.4758.109","17.1.2":"98.0.4758.109","17.2.0":"98.0.4758.109","17.3.0":"98.0.4758.141","17.3.1":"98.0.4758.141","17.4.0":"98.0.4758.141","17.4.1":"98.0.4758.141","17.4.2":"98.0.4758.141","17.4.3":"98.0.4758.141","17.4.4":"98.0.4758.141","17.4.5":"98.0.4758.141","17.4.6":"98.0.4758.141","17.4.7":"98.0.4758.141","17.4.8":"98.0.4758.141","17.4.9":"98.0.4758.141","17.4.10":"98.0.4758.141","17.4.11":"98.0.4758.141","18.0.0-alpha.1":"99.0.4767.0","18.0.0-alpha.2":"99.0.4767.0","18.0.0-alpha.3":"99.0.4767.0","18.0.0-alpha.4":"99.0.4767.0","18.0.0-alpha.5":"99.0.4767.0","18.0.0-beta.1":"100.0.4894.0","18.0.0-beta.2":"100.0.4894.0","18.0.0-beta.3":"100.0.4894.0","18.0.0-beta.4":"100.0.4894.0","18.0.0-beta.5":"100.0.4894.0","18.0.0-beta.6":"100.0.4894.0","18.0.0-nightly.20211118":"96.0.4664.4","18.0.0-nightly.20211119":"96.0.4664.4","18.0.0-nightly.20211122":"96.0.4664.4","18.0.0-nightly.20211123":"96.0.4664.4","18.0.0-nightly.20211124":"98.0.4706.0","18.0.0-nightly.20211125":"98.0.4706.0","18.0.0-nightly.20211126":"98.0.4706.0","18.0.0-nightly.20211129":"98.0.4706.0","18.0.0-nightly.20211130":"98.0.4706.0","18.0.0-nightly.20211201":"98.0.4706.0","18.0.0-nightly.20211202":"98.0.4706.0","18.0.0-nightly.20211203":"98.0.4706.0","18.0.0-nightly.20211206":"98.0.4706.0","18.0.0-nightly.20211207":"98.0.4706.0","18.0.0-nightly.20211208":"98.0.4706.0","18.0.0-nightly.20211209":"98.0.4706.0","18.0.0-nightly.20211210":"98.0.4706.0","18.0.0-nightly.20211213":"98.0.4706.0","18.0.0-nightly.20211214":"98.0.4706.0","18.0.0-nightly.20211215":"98.0.4706.0","18.0.0-nightly.20211216":"98.0.4706.0","18.0.0-nightly.20211217":"98.0.4706.0","18.0.0-nightly.20211220":"98.0.4706.0","18.0.0-nightly.20211221":"98.0.4706.0","18.0.0-nightly.20211222":"98.0.4706.0","18.0.0-nightly.20211223":"98.0.4706.0","18.0.0-nightly.20211228":"98.0.4706.0","18.0.0-nightly.20211229":"98.0.4706.0","18.0.0-nightly.20211231":"98.0.4706.0","18.0.0-nightly.20220103":"98.0.4706.0","18.0.0-nightly.20220104":"98.0.4706.0","18.0.0-nightly.20220105":"98.0.4706.0","18.0.0-nightly.20220106":"98.0.4706.0","18.0.0-nightly.20220107":"98.0.4706.0","18.0.0-nightly.20220110":"98.0.4706.0","18.0.0-nightly.20220111":"99.0.4767.0","18.0.0-nightly.20220112":"99.0.4767.0","18.0.0-nightly.20220113":"99.0.4767.0","18.0.0-nightly.20220114":"99.0.4767.0","18.0.0-nightly.20220117":"99.0.4767.0","18.0.0-nightly.20220118":"99.0.4767.0","18.0.0-nightly.20220119":"99.0.4767.0","18.0.0-nightly.20220121":"99.0.4767.0","18.0.0-nightly.20220124":"99.0.4767.0","18.0.0-nightly.20220125":"99.0.4767.0","18.0.0-nightly.20220127":"99.0.4767.0","18.0.0-nightly.20220128":"99.0.4767.0","18.0.0-nightly.20220131":"99.0.4767.0","18.0.0-nightly.20220201":"99.0.4767.0","18.0.0":"100.0.4896.56","18.0.1":"100.0.4896.60","18.0.2":"100.0.4896.60","18.0.3":"100.0.4896.75","18.0.4":"100.0.4896.75","18.1.0":"100.0.4896.127","18.2.0":"100.0.4896.143","18.2.1":"100.0.4896.143","18.2.2":"100.0.4896.143","18.2.3":"100.0.4896.143","18.2.4":"100.0.4896.160","18.3.0":"100.0.4896.160","18.3.1":"100.0.4896.160","18.3.2":"100.0.4896.160","18.3.3":"100.0.4896.160","18.3.4":"100.0.4896.160","18.3.5":"100.0.4896.160","18.3.6":"100.0.4896.160","18.3.7":"100.0.4896.160","18.3.8":"100.0.4896.160","18.3.9":"100.0.4896.160","18.3.11":"100.0.4896.160","18.3.12":"100.0.4896.160","18.3.13":"100.0.4896.160","18.3.14":"100.0.4896.160","18.3.15":"100.0.4896.160","19.0.0-alpha.1":"102.0.4962.3","19.0.0-alpha.2":"102.0.4971.0","19.0.0-alpha.3":"102.0.4971.0","19.0.0-alpha.4":"102.0.4989.0","19.0.0-alpha.5":"102.0.4989.0","19.0.0-beta.1":"102.0.4999.0","19.0.0-beta.2":"102.0.4999.0","19.0.0-beta.3":"102.0.4999.0","19.0.0-beta.4":"102.0.5005.27","19.0.0-beta.5":"102.0.5005.40","19.0.0-beta.6":"102.0.5005.40","19.0.0-beta.7":"102.0.5005.40","19.0.0-beta.8":"102.0.5005.49","19.0.0-nightly.20220202":"99.0.4767.0","19.0.0-nightly.20220203":"99.0.4767.0","19.0.0-nightly.20220204":"99.0.4767.0","19.0.0-nightly.20220207":"99.0.4767.0","19.0.0-nightly.20220208":"99.0.4767.0","19.0.0-nightly.20220209":"99.0.4767.0","19.0.0-nightly.20220308":"100.0.4894.0","19.0.0-nightly.20220309":"100.0.4894.0","19.0.0-nightly.20220310":"100.0.4894.0","19.0.0-nightly.20220311":"100.0.4894.0","19.0.0-nightly.20220314":"100.0.4894.0","19.0.0-nightly.20220315":"100.0.4894.0","19.0.0-nightly.20220316":"100.0.4894.0","19.0.0-nightly.20220317":"100.0.4894.0","19.0.0-nightly.20220318":"100.0.4894.0","19.0.0-nightly.20220321":"100.0.4894.0","19.0.0-nightly.20220322":"100.0.4894.0","19.0.0-nightly.20220323":"100.0.4894.0","19.0.0-nightly.20220324":"100.0.4894.0","19.0.0-nightly.20220325":"102.0.4961.0","19.0.0-nightly.20220328":"102.0.4962.3","19.0.0-nightly.20220329":"102.0.4962.3","19.0.0":"102.0.5005.61","19.0.1":"102.0.5005.61","19.0.2":"102.0.5005.63","19.0.3":"102.0.5005.63","19.0.4":"102.0.5005.63","19.0.5":"102.0.5005.115","19.0.6":"102.0.5005.115","19.0.7":"102.0.5005.134","19.0.8":"102.0.5005.148","19.0.9":"102.0.5005.167","19.0.10":"102.0.5005.167","19.0.11":"102.0.5005.167","19.0.12":"102.0.5005.167","19.0.13":"102.0.5005.167","19.0.14":"102.0.5005.167","19.0.15":"102.0.5005.167","19.0.16":"102.0.5005.167","19.0.17":"102.0.5005.167","19.1.0":"102.0.5005.167","19.1.1":"102.0.5005.167","19.1.2":"102.0.5005.167","19.1.3":"102.0.5005.167","19.1.4":"102.0.5005.167","19.1.5":"102.0.5005.167","19.1.6":"102.0.5005.167","19.1.7":"102.0.5005.167","19.1.8":"102.0.5005.167","19.1.9":"102.0.5005.167","20.0.0-alpha.1":"103.0.5044.0","20.0.0-alpha.2":"104.0.5073.0","20.0.0-alpha.3":"104.0.5073.0","20.0.0-alpha.4":"104.0.5073.0","20.0.0-alpha.5":"104.0.5073.0","20.0.0-alpha.6":"104.0.5073.0","20.0.0-alpha.7":"104.0.5073.0","20.0.0-beta.1":"104.0.5073.0","20.0.0-beta.2":"104.0.5073.0","20.0.0-beta.3":"104.0.5073.0","20.0.0-beta.4":"104.0.5073.0","20.0.0-beta.5":"104.0.5073.0","20.0.0-beta.6":"104.0.5073.0","20.0.0-beta.7":"104.0.5073.0","20.0.0-beta.8":"104.0.5073.0","20.0.0-beta.9":"104.0.5112.39","20.0.0-beta.10":"104.0.5112.48","20.0.0-beta.11":"104.0.5112.48","20.0.0-beta.12":"104.0.5112.48","20.0.0-beta.13":"104.0.5112.57","20.0.0-nightly.20220330":"102.0.4962.3","20.0.0-nightly.20220411":"102.0.4971.0","20.0.0-nightly.20220414":"102.0.4989.0","20.0.0-nightly.20220415":"102.0.4989.0","20.0.0-nightly.20220418":"102.0.4989.0","20.0.0-nightly.20220419":"102.0.4989.0","20.0.0-nightly.20220420":"102.0.4989.0","20.0.0-nightly.20220421":"102.0.4989.0","20.0.0-nightly.20220425":"102.0.4999.0","20.0.0-nightly.20220426":"102.0.4999.0","20.0.0-nightly.20220427":"102.0.4999.0","20.0.0-nightly.20220428":"102.0.4999.0","20.0.0-nightly.20220429":"102.0.4999.0","20.0.0-nightly.20220502":"102.0.4999.0","20.0.0-nightly.20220503":"102.0.4999.0","20.0.0-nightly.20220504":"102.0.4999.0","20.0.0-nightly.20220505":"102.0.4999.0","20.0.0-nightly.20220506":"102.0.4999.0","20.0.0-nightly.20220509":"102.0.4999.0","20.0.0-nightly.20220511":"102.0.4999.0","20.0.0-nightly.20220512":"102.0.4999.0","20.0.0-nightly.20220513":"102.0.4999.0","20.0.0-nightly.20220516":"102.0.4999.0","20.0.0-nightly.20220517":"102.0.4999.0","20.0.0-nightly.20220518":"103.0.5044.0","20.0.0-nightly.20220519":"103.0.5044.0","20.0.0-nightly.20220520":"103.0.5044.0","20.0.0-nightly.20220523":"103.0.5044.0","20.0.0-nightly.20220524":"103.0.5044.0","20.0.0":"104.0.5112.65","20.0.1":"104.0.5112.81","20.0.2":"104.0.5112.81","20.0.3":"104.0.5112.81","20.1.0":"104.0.5112.102","20.1.1":"104.0.5112.102","20.1.2":"104.0.5112.114","20.1.3":"104.0.5112.114","20.1.4":"104.0.5112.114","20.2.0":"104.0.5112.124","20.3.0":"104.0.5112.124","20.3.1":"104.0.5112.124","20.3.2":"104.0.5112.124","20.3.3":"104.0.5112.124","20.3.4":"104.0.5112.124","20.3.5":"104.0.5112.124","20.3.6":"104.0.5112.124","20.3.7":"104.0.5112.124","20.3.8":"104.0.5112.124","20.3.9":"104.0.5112.124","20.3.10":"104.0.5112.124","20.3.11":"104.0.5112.124","20.3.12":"104.0.5112.124","21.0.0-alpha.1":"105.0.5187.0","21.0.0-alpha.2":"105.0.5187.0","21.0.0-alpha.3":"105.0.5187.0","21.0.0-alpha.4":"105.0.5187.0","21.0.0-alpha.5":"105.0.5187.0","21.0.0-alpha.6":"106.0.5216.0","21.0.0-beta.1":"106.0.5216.0","21.0.0-beta.2":"106.0.5216.0","21.0.0-beta.3":"106.0.5216.0","21.0.0-beta.4":"106.0.5216.0","21.0.0-beta.5":"106.0.5216.0","21.0.0-beta.6":"106.0.5249.40","21.0.0-beta.7":"106.0.5249.40","21.0.0-beta.8":"106.0.5249.40","21.0.0-nightly.20220526":"103.0.5044.0","21.0.0-nightly.20220527":"103.0.5044.0","21.0.0-nightly.20220530":"103.0.5044.0","21.0.0-nightly.20220531":"103.0.5044.0","21.0.0-nightly.20220602":"104.0.5073.0","21.0.0-nightly.20220603":"104.0.5073.0","21.0.0-nightly.20220606":"104.0.5073.0","21.0.0-nightly.20220607":"104.0.5073.0","21.0.0-nightly.20220608":"104.0.5073.0","21.0.0-nightly.20220609":"104.0.5073.0","21.0.0-nightly.20220610":"104.0.5073.0","21.0.0-nightly.20220613":"104.0.5073.0","21.0.0-nightly.20220614":"104.0.5073.0","21.0.0-nightly.20220615":"104.0.5073.0","21.0.0-nightly.20220616":"104.0.5073.0","21.0.0-nightly.20220617":"104.0.5073.0","21.0.0-nightly.20220620":"104.0.5073.0","21.0.0-nightly.20220621":"104.0.5073.0","21.0.0-nightly.20220622":"104.0.5073.0","21.0.0-nightly.20220623":"104.0.5073.0","21.0.0-nightly.20220624":"104.0.5073.0","21.0.0-nightly.20220627":"104.0.5073.0","21.0.0-nightly.20220628":"105.0.5129.0","21.0.0-nightly.20220629":"105.0.5129.0","21.0.0-nightly.20220630":"105.0.5129.0","21.0.0-nightly.20220701":"105.0.5129.0","21.0.0-nightly.20220704":"105.0.5129.0","21.0.0-nightly.20220705":"105.0.5129.0","21.0.0-nightly.20220706":"105.0.5129.0","21.0.0-nightly.20220707":"105.0.5129.0","21.0.0-nightly.20220708":"105.0.5129.0","21.0.0-nightly.20220711":"105.0.5129.0","21.0.0-nightly.20220712":"105.0.5129.0","21.0.0-nightly.20220713":"105.0.5129.0","21.0.0-nightly.20220715":"105.0.5173.0","21.0.0-nightly.20220718":"105.0.5173.0","21.0.0-nightly.20220719":"105.0.5173.0","21.0.0-nightly.20220720":"105.0.5187.0","21.0.0-nightly.20220721":"105.0.5187.0","21.0.0-nightly.20220722":"105.0.5187.0","21.0.0-nightly.20220725":"105.0.5187.0","21.0.0-nightly.20220726":"105.0.5187.0","21.0.0-nightly.20220727":"105.0.5187.0","21.0.0-nightly.20220728":"105.0.5187.0","21.0.0-nightly.20220801":"105.0.5187.0","21.0.0-nightly.20220802":"105.0.5187.0","21.0.0":"106.0.5249.51","21.0.1":"106.0.5249.61","21.1.0":"106.0.5249.91","21.1.1":"106.0.5249.103","21.2.0":"106.0.5249.119","21.2.1":"106.0.5249.165","21.2.2":"106.0.5249.168","21.2.3":"106.0.5249.168","21.3.0":"106.0.5249.181","21.3.1":"106.0.5249.181","21.3.3":"106.0.5249.199","21.3.4":"106.0.5249.199","21.3.5":"106.0.5249.199","21.4.0":"106.0.5249.199","21.4.1":"106.0.5249.199","21.4.2":"106.0.5249.199","21.4.3":"106.0.5249.199","21.4.4":"106.0.5249.199","22.0.0-alpha.1":"107.0.5286.0","22.0.0-alpha.3":"108.0.5329.0","22.0.0-alpha.4":"108.0.5329.0","22.0.0-alpha.5":"108.0.5329.0","22.0.0-alpha.6":"108.0.5329.0","22.0.0-alpha.7":"108.0.5355.0","22.0.0-alpha.8":"108.0.5359.10","22.0.0-beta.1":"108.0.5359.10","22.0.0-beta.2":"108.0.5359.10","22.0.0-beta.3":"108.0.5359.10","22.0.0-beta.4":"108.0.5359.29","22.0.0-beta.5":"108.0.5359.40","22.0.0-beta.6":"108.0.5359.40","22.0.0-beta.7":"108.0.5359.48","22.0.0-beta.8":"108.0.5359.48","22.0.0-nightly.20220808":"105.0.5187.0","22.0.0-nightly.20220809":"105.0.5187.0","22.0.0-nightly.20220810":"105.0.5187.0","22.0.0-nightly.20220811":"105.0.5187.0","22.0.0-nightly.20220812":"105.0.5187.0","22.0.0-nightly.20220815":"105.0.5187.0","22.0.0-nightly.20220816":"105.0.5187.0","22.0.0-nightly.20220817":"105.0.5187.0","22.0.0-nightly.20220822":"106.0.5216.0","22.0.0-nightly.20220823":"106.0.5216.0","22.0.0-nightly.20220824":"106.0.5216.0","22.0.0-nightly.20220825":"106.0.5216.0","22.0.0-nightly.20220829":"106.0.5216.0","22.0.0-nightly.20220830":"106.0.5216.0","22.0.0-nightly.20220831":"106.0.5216.0","22.0.0-nightly.20220901":"106.0.5216.0","22.0.0-nightly.20220902":"106.0.5216.0","22.0.0-nightly.20220905":"106.0.5216.0","22.0.0-nightly.20220908":"107.0.5274.0","22.0.0-nightly.20220909":"107.0.5286.0","22.0.0-nightly.20220912":"107.0.5286.0","22.0.0-nightly.20220913":"107.0.5286.0","22.0.0-nightly.20220914":"107.0.5286.0","22.0.0-nightly.20220915":"107.0.5286.0","22.0.0-nightly.20220916":"107.0.5286.0","22.0.0-nightly.20220919":"107.0.5286.0","22.0.0-nightly.20220920":"107.0.5286.0","22.0.0-nightly.20220921":"107.0.5286.0","22.0.0-nightly.20220922":"107.0.5286.0","22.0.0-nightly.20220923":"107.0.5286.0","22.0.0-nightly.20220926":"107.0.5286.0","22.0.0-nightly.20220927":"107.0.5286.0","22.0.0-nightly.20220928":"107.0.5286.0","22.0.0":"108.0.5359.62","22.0.1":"108.0.5359.125","22.0.2":"108.0.5359.179","22.0.3":"108.0.5359.179","22.1.0":"108.0.5359.179","22.2.0":"108.0.5359.215","22.2.1":"108.0.5359.215","22.3.0":"108.0.5359.215","22.3.1":"108.0.5359.215","22.3.2":"108.0.5359.215","22.3.3":"108.0.5359.215","22.3.4":"108.0.5359.215","22.3.5":"108.0.5359.215","22.3.6":"108.0.5359.215","22.3.7":"108.0.5359.215","22.3.8":"108.0.5359.215","22.3.9":"108.0.5359.215","22.3.10":"108.0.5359.215","22.3.11":"108.0.5359.215","22.3.12":"108.0.5359.215","22.3.13":"108.0.5359.215","22.3.14":"108.0.5359.215","22.3.15":"108.0.5359.215","22.3.16":"108.0.5359.215","22.3.17":"108.0.5359.215","22.3.18":"108.0.5359.215","22.3.20":"108.0.5359.215","22.3.21":"108.0.5359.215","22.3.22":"108.0.5359.215","22.3.23":"108.0.5359.215","22.3.24":"108.0.5359.215","22.3.25":"108.0.5359.215","22.3.26":"108.0.5359.215","22.3.27":"108.0.5359.215","23.0.0-alpha.1":"110.0.5415.0","23.0.0-alpha.2":"110.0.5451.0","23.0.0-alpha.3":"110.0.5451.0","23.0.0-beta.1":"110.0.5478.5","23.0.0-beta.2":"110.0.5478.5","23.0.0-beta.3":"110.0.5478.5","23.0.0-beta.4":"110.0.5481.30","23.0.0-beta.5":"110.0.5481.38","23.0.0-beta.6":"110.0.5481.52","23.0.0-beta.8":"110.0.5481.52","23.0.0-nightly.20220929":"107.0.5286.0","23.0.0-nightly.20220930":"107.0.5286.0","23.0.0-nightly.20221003":"107.0.5286.0","23.0.0-nightly.20221004":"108.0.5329.0","23.0.0-nightly.20221005":"108.0.5329.0","23.0.0-nightly.20221006":"108.0.5329.0","23.0.0-nightly.20221007":"108.0.5329.0","23.0.0-nightly.20221010":"108.0.5329.0","23.0.0-nightly.20221011":"108.0.5329.0","23.0.0-nightly.20221012":"108.0.5329.0","23.0.0-nightly.20221013":"108.0.5329.0","23.0.0-nightly.20221014":"108.0.5329.0","23.0.0-nightly.20221017":"108.0.5329.0","23.0.0-nightly.20221018":"108.0.5355.0","23.0.0-nightly.20221019":"108.0.5355.0","23.0.0-nightly.20221020":"108.0.5355.0","23.0.0-nightly.20221021":"108.0.5355.0","23.0.0-nightly.20221024":"108.0.5355.0","23.0.0-nightly.20221026":"108.0.5355.0","23.0.0-nightly.20221027":"109.0.5382.0","23.0.0-nightly.20221028":"109.0.5382.0","23.0.0-nightly.20221031":"109.0.5382.0","23.0.0-nightly.20221101":"109.0.5382.0","23.0.0-nightly.20221102":"109.0.5382.0","23.0.0-nightly.20221103":"109.0.5382.0","23.0.0-nightly.20221104":"109.0.5382.0","23.0.0-nightly.20221107":"109.0.5382.0","23.0.0-nightly.20221108":"109.0.5382.0","23.0.0-nightly.20221109":"109.0.5382.0","23.0.0-nightly.20221110":"109.0.5382.0","23.0.0-nightly.20221111":"109.0.5382.0","23.0.0-nightly.20221114":"109.0.5382.0","23.0.0-nightly.20221115":"109.0.5382.0","23.0.0-nightly.20221116":"109.0.5382.0","23.0.0-nightly.20221117":"109.0.5382.0","23.0.0-nightly.20221118":"110.0.5415.0","23.0.0-nightly.20221121":"110.0.5415.0","23.0.0-nightly.20221122":"110.0.5415.0","23.0.0-nightly.20221123":"110.0.5415.0","23.0.0-nightly.20221124":"110.0.5415.0","23.0.0-nightly.20221125":"110.0.5415.0","23.0.0-nightly.20221128":"110.0.5415.0","23.0.0-nightly.20221129":"110.0.5415.0","23.0.0-nightly.20221130":"110.0.5415.0","23.0.0":"110.0.5481.77","23.1.0":"110.0.5481.100","23.1.1":"110.0.5481.104","23.1.2":"110.0.5481.177","23.1.3":"110.0.5481.179","23.1.4":"110.0.5481.192","23.2.0":"110.0.5481.192","23.2.1":"110.0.5481.208","23.2.2":"110.0.5481.208","23.2.3":"110.0.5481.208","23.2.4":"110.0.5481.208","23.3.0":"110.0.5481.208","23.3.1":"110.0.5481.208","23.3.2":"110.0.5481.208","23.3.3":"110.0.5481.208","23.3.4":"110.0.5481.208","23.3.5":"110.0.5481.208","23.3.6":"110.0.5481.208","23.3.7":"110.0.5481.208","23.3.8":"110.0.5481.208","23.3.9":"110.0.5481.208","23.3.10":"110.0.5481.208","23.3.11":"110.0.5481.208","23.3.12":"110.0.5481.208","23.3.13":"110.0.5481.208","24.0.0-alpha.1":"111.0.5560.0","24.0.0-alpha.2":"111.0.5560.0","24.0.0-alpha.3":"111.0.5560.0","24.0.0-alpha.4":"111.0.5560.0","24.0.0-alpha.5":"111.0.5560.0","24.0.0-alpha.6":"111.0.5560.0","24.0.0-alpha.7":"111.0.5560.0","24.0.0-beta.1":"111.0.5563.50","24.0.0-beta.2":"111.0.5563.50","24.0.0-beta.3":"112.0.5615.20","24.0.0-beta.4":"112.0.5615.20","24.0.0-beta.5":"112.0.5615.29","24.0.0-beta.6":"112.0.5615.39","24.0.0-beta.7":"112.0.5615.39","24.0.0-nightly.20221201":"110.0.5415.0","24.0.0-nightly.20221202":"110.0.5415.0","24.0.0-nightly.20221205":"110.0.5415.0","24.0.0-nightly.20221206":"110.0.5451.0","24.0.0-nightly.20221207":"110.0.5451.0","24.0.0-nightly.20221208":"110.0.5451.0","24.0.0-nightly.20221213":"110.0.5451.0","24.0.0-nightly.20221214":"110.0.5451.0","24.0.0-nightly.20221215":"110.0.5451.0","24.0.0-nightly.20221216":"110.0.5451.0","24.0.0-nightly.20230109":"111.0.5518.0","24.0.0-nightly.20230110":"111.0.5518.0","24.0.0-nightly.20230111":"111.0.5518.0","24.0.0-nightly.20230112":"111.0.5518.0","24.0.0-nightly.20230113":"111.0.5518.0","24.0.0-nightly.20230116":"111.0.5518.0","24.0.0-nightly.20230117":"111.0.5518.0","24.0.0-nightly.20230118":"111.0.5518.0","24.0.0-nightly.20230119":"111.0.5518.0","24.0.0-nightly.20230120":"111.0.5518.0","24.0.0-nightly.20230123":"111.0.5518.0","24.0.0-nightly.20230124":"111.0.5518.0","24.0.0-nightly.20230125":"111.0.5518.0","24.0.0-nightly.20230126":"111.0.5518.0","24.0.0-nightly.20230127":"111.0.5518.0","24.0.0-nightly.20230131":"111.0.5518.0","24.0.0-nightly.20230201":"111.0.5518.0","24.0.0-nightly.20230202":"111.0.5518.0","24.0.0-nightly.20230203":"111.0.5560.0","24.0.0-nightly.20230206":"111.0.5560.0","24.0.0-nightly.20230207":"111.0.5560.0","24.0.0-nightly.20230208":"111.0.5560.0","24.0.0-nightly.20230209":"111.0.5560.0","24.0.0":"112.0.5615.49","24.1.0":"112.0.5615.50","24.1.1":"112.0.5615.50","24.1.2":"112.0.5615.87","24.1.3":"112.0.5615.165","24.2.0":"112.0.5615.165","24.3.0":"112.0.5615.165","24.3.1":"112.0.5615.183","24.4.0":"112.0.5615.204","24.4.1":"112.0.5615.204","24.5.0":"112.0.5615.204","24.5.1":"112.0.5615.204","24.6.0":"112.0.5615.204","24.6.1":"112.0.5615.204","24.6.2":"112.0.5615.204","24.6.3":"112.0.5615.204","24.6.4":"112.0.5615.204","24.6.5":"112.0.5615.204","24.7.0":"112.0.5615.204","24.7.1":"112.0.5615.204","24.8.0":"112.0.5615.204","24.8.1":"112.0.5615.204","24.8.2":"112.0.5615.204","24.8.3":"112.0.5615.204","24.8.4":"112.0.5615.204","24.8.5":"112.0.5615.204","24.8.6":"112.0.5615.204","24.8.7":"112.0.5615.204","24.8.8":"112.0.5615.204","25.0.0-alpha.1":"114.0.5694.0","25.0.0-alpha.2":"114.0.5694.0","25.0.0-alpha.3":"114.0.5710.0","25.0.0-alpha.4":"114.0.5710.0","25.0.0-alpha.5":"114.0.5719.0","25.0.0-alpha.6":"114.0.5719.0","25.0.0-beta.1":"114.0.5719.0","25.0.0-beta.2":"114.0.5719.0","25.0.0-beta.3":"114.0.5719.0","25.0.0-beta.4":"114.0.5735.16","25.0.0-beta.5":"114.0.5735.16","25.0.0-beta.6":"114.0.5735.16","25.0.0-beta.7":"114.0.5735.16","25.0.0-beta.8":"114.0.5735.35","25.0.0-beta.9":"114.0.5735.45","25.0.0-nightly.20230210":"111.0.5560.0","25.0.0-nightly.20230214":"111.0.5560.0","25.0.0-nightly.20230215":"111.0.5560.0","25.0.0-nightly.20230216":"111.0.5560.0","25.0.0-nightly.20230217":"111.0.5560.0","25.0.0-nightly.20230220":"111.0.5560.0","25.0.0-nightly.20230221":"111.0.5560.0","25.0.0-nightly.20230222":"111.0.5560.0","25.0.0-nightly.20230223":"111.0.5560.0","25.0.0-nightly.20230224":"111.0.5560.0","25.0.0-nightly.20230227":"111.0.5560.0","25.0.0-nightly.20230228":"111.0.5560.0","25.0.0-nightly.20230301":"111.0.5560.0","25.0.0-nightly.20230302":"111.0.5560.0","25.0.0-nightly.20230303":"111.0.5560.0","25.0.0-nightly.20230306":"111.0.5560.0","25.0.0-nightly.20230307":"111.0.5560.0","25.0.0-nightly.20230308":"111.0.5560.0","25.0.0-nightly.20230309":"111.0.5560.0","25.0.0-nightly.20230310":"111.0.5560.0","25.0.0-nightly.20230314":"113.0.5636.0","25.0.0-nightly.20230315":"113.0.5651.0","25.0.0-nightly.20230317":"113.0.5653.0","25.0.0-nightly.20230320":"113.0.5660.0","25.0.0-nightly.20230321":"113.0.5664.0","25.0.0-nightly.20230322":"113.0.5666.0","25.0.0-nightly.20230323":"113.0.5668.0","25.0.0-nightly.20230324":"113.0.5670.0","25.0.0-nightly.20230327":"113.0.5670.0","25.0.0-nightly.20230328":"113.0.5670.0","25.0.0-nightly.20230329":"113.0.5670.0","25.0.0-nightly.20230330":"113.0.5670.0","25.0.0-nightly.20230331":"114.0.5684.0","25.0.0-nightly.20230403":"114.0.5684.0","25.0.0-nightly.20230404":"114.0.5692.0","25.0.0-nightly.20230405":"114.0.5694.0","25.0.0":"114.0.5735.45","25.0.1":"114.0.5735.45","25.1.0":"114.0.5735.106","25.1.1":"114.0.5735.106","25.2.0":"114.0.5735.134","25.3.0":"114.0.5735.199","25.3.1":"114.0.5735.243","25.3.2":"114.0.5735.248","25.4.0":"114.0.5735.248","25.5.0":"114.0.5735.289","25.6.0":"114.0.5735.289","25.7.0":"114.0.5735.289","25.8.0":"114.0.5735.289","25.8.1":"114.0.5735.289","25.8.2":"114.0.5735.289","25.8.3":"114.0.5735.289","25.8.4":"114.0.5735.289","25.9.0":"114.0.5735.289","25.9.1":"114.0.5735.289","25.9.2":"114.0.5735.289","25.9.3":"114.0.5735.289","25.9.4":"114.0.5735.289","25.9.5":"114.0.5735.289","25.9.6":"114.0.5735.289","25.9.7":"114.0.5735.289","25.9.8":"114.0.5735.289","26.0.0-alpha.1":"116.0.5791.0","26.0.0-alpha.2":"116.0.5791.0","26.0.0-alpha.3":"116.0.5791.0","26.0.0-alpha.4":"116.0.5791.0","26.0.0-alpha.5":"116.0.5791.0","26.0.0-alpha.6":"116.0.5815.0","26.0.0-alpha.7":"116.0.5831.0","26.0.0-alpha.8":"116.0.5845.0","26.0.0-beta.1":"116.0.5845.0","26.0.0-beta.2":"116.0.5845.14","26.0.0-beta.3":"116.0.5845.14","26.0.0-beta.4":"116.0.5845.14","26.0.0-beta.5":"116.0.5845.14","26.0.0-beta.6":"116.0.5845.14","26.0.0-beta.7":"116.0.5845.14","26.0.0-beta.8":"116.0.5845.42","26.0.0-beta.9":"116.0.5845.42","26.0.0-beta.10":"116.0.5845.49","26.0.0-beta.11":"116.0.5845.49","26.0.0-beta.12":"116.0.5845.62","26.0.0-nightly.20230406":"114.0.5694.0","26.0.0-nightly.20230407":"114.0.5694.0","26.0.0-nightly.20230410":"114.0.5694.0","26.0.0-nightly.20230411":"114.0.5694.0","26.0.0-nightly.20230412":"114.0.5708.0","26.0.0-nightly.20230413":"114.0.5710.0","26.0.0-nightly.20230414":"114.0.5710.0","26.0.0-nightly.20230417":"114.0.5710.0","26.0.0-nightly.20230418":"114.0.5715.0","26.0.0-nightly.20230421":"114.0.5719.0","26.0.0-nightly.20230424":"114.0.5719.0","26.0.0-nightly.20230425":"114.0.5719.0","26.0.0-nightly.20230426":"114.0.5719.0","26.0.0-nightly.20230427":"114.0.5719.0","26.0.0-nightly.20230428":"114.0.5719.0","26.0.0-nightly.20230501":"114.0.5719.0","26.0.0-nightly.20230502":"114.0.5719.0","26.0.0-nightly.20230503":"114.0.5719.0","26.0.0-nightly.20230504":"114.0.5719.0","26.0.0-nightly.20230505":"114.0.5719.0","26.0.0-nightly.20230508":"114.0.5719.0","26.0.0-nightly.20230509":"114.0.5719.0","26.0.0-nightly.20230510":"114.0.5719.0","26.0.0-nightly.20230511":"115.0.5760.0","26.0.0-nightly.20230512":"115.0.5760.0","26.0.0-nightly.20230515":"115.0.5760.0","26.0.0-nightly.20230516":"115.0.5760.0","26.0.0-nightly.20230517":"115.0.5760.0","26.0.0-nightly.20230518":"115.0.5760.0","26.0.0-nightly.20230519":"115.0.5760.0","26.0.0-nightly.20230522":"115.0.5760.0","26.0.0-nightly.20230523":"115.0.5760.0","26.0.0-nightly.20230524":"115.0.5786.0","26.0.0-nightly.20230525":"115.0.5790.0","26.0.0-nightly.20230526":"116.0.5791.0","26.0.0-nightly.20230529":"116.0.5791.0","26.0.0-nightly.20230530":"116.0.5791.0","26.0.0-nightly.20230531":"116.0.5791.0","26.0.0":"116.0.5845.82","26.1.0":"116.0.5845.97","26.2.0":"116.0.5845.179","26.2.1":"116.0.5845.188","26.2.2":"116.0.5845.190","26.2.3":"116.0.5845.190","26.2.4":"116.0.5845.190","26.3.0":"116.0.5845.228","26.4.0":"116.0.5845.228","26.4.1":"116.0.5845.228","26.4.2":"116.0.5845.228","26.4.3":"116.0.5845.228","26.5.0":"116.0.5845.228","26.6.0":"116.0.5845.228","26.6.1":"116.0.5845.228","26.6.2":"116.0.5845.228","26.6.3":"116.0.5845.228","26.6.4":"116.0.5845.228","26.6.5":"116.0.5845.228","26.6.6":"116.0.5845.228","26.6.7":"116.0.5845.228","26.6.8":"116.0.5845.228","26.6.9":"116.0.5845.228","26.6.10":"116.0.5845.228","27.0.0-alpha.1":"118.0.5949.0","27.0.0-alpha.2":"118.0.5949.0","27.0.0-alpha.3":"118.0.5949.0","27.0.0-alpha.4":"118.0.5949.0","27.0.0-alpha.5":"118.0.5949.0","27.0.0-alpha.6":"118.0.5949.0","27.0.0-beta.1":"118.0.5993.5","27.0.0-beta.2":"118.0.5993.5","27.0.0-beta.3":"118.0.5993.5","27.0.0-beta.4":"118.0.5993.11","27.0.0-beta.5":"118.0.5993.18","27.0.0-beta.6":"118.0.5993.18","27.0.0-beta.7":"118.0.5993.18","27.0.0-beta.8":"118.0.5993.18","27.0.0-beta.9":"118.0.5993.18","27.0.0-nightly.20230601":"116.0.5791.0","27.0.0-nightly.20230602":"116.0.5791.0","27.0.0-nightly.20230605":"116.0.5791.0","27.0.0-nightly.20230606":"116.0.5791.0","27.0.0-nightly.20230607":"116.0.5791.0","27.0.0-nightly.20230609":"116.0.5791.0","27.0.0-nightly.20230612":"116.0.5815.0","27.0.0-nightly.20230613":"116.0.5815.0","27.0.0-nightly.20230614":"116.0.5829.0","27.0.0-nightly.20230615":"116.0.5831.0","27.0.0-nightly.20230616":"116.0.5833.0","27.0.0-nightly.20230619":"116.0.5833.0","27.0.0-nightly.20230620":"116.0.5833.0","27.0.0-nightly.20230621":"116.0.5833.0","27.0.0-nightly.20230622":"116.0.5845.0","27.0.0-nightly.20230623":"116.0.5845.0","27.0.0-nightly.20230626":"116.0.5845.0","27.0.0-nightly.20230627":"116.0.5845.0","27.0.0-nightly.20230628":"116.0.5845.0","27.0.0-nightly.20230629":"116.0.5845.0","27.0.0-nightly.20230630":"116.0.5845.0","27.0.0-nightly.20230703":"117.0.5852.0","27.0.0-nightly.20230704":"117.0.5852.0","27.0.0-nightly.20230705":"117.0.5852.0","27.0.0-nightly.20230706":"117.0.5852.0","27.0.0-nightly.20230707":"117.0.5852.0","27.0.0-nightly.20230710":"117.0.5852.0","27.0.0-nightly.20230711":"117.0.5852.0","27.0.0-nightly.20230712":"117.0.5852.0","27.0.0-nightly.20230713":"117.0.5852.0","27.0.0-nightly.20230714":"117.0.5852.0","27.0.0-nightly.20230717":"117.0.5884.1","27.0.0-nightly.20230718":"117.0.5884.1","27.0.0-nightly.20230719":"117.0.5892.0","27.0.0-nightly.20230720":"117.0.5897.0","27.0.0-nightly.20230721":"117.0.5897.0","27.0.0-nightly.20230724":"117.0.5897.0","27.0.0-nightly.20230725":"117.0.5897.0","27.0.0-nightly.20230726":"117.0.5897.0","27.0.0-nightly.20230727":"117.0.5897.0","27.0.0-nightly.20230728":"117.0.5897.0","27.0.0-nightly.20230731":"117.0.5897.0","27.0.0-nightly.20230801":"117.0.5911.0","27.0.0-nightly.20230802":"117.0.5911.0","27.0.0-nightly.20230803":"117.0.5911.0","27.0.0-nightly.20230804":"117.0.5921.0","27.0.0-nightly.20230807":"117.0.5921.0","27.0.0-nightly.20230808":"117.0.5921.0","27.0.0-nightly.20230814":"117.0.5921.0","27.0.0-nightly.20230815":"117.0.5921.0","27.0.0-nightly.20230816":"118.0.5949.0","27.0.0":"118.0.5993.54","27.0.1":"118.0.5993.89","27.0.2":"118.0.5993.89","27.0.3":"118.0.5993.120","27.0.4":"118.0.5993.129","27.1.0":"118.0.5993.144","27.1.2":"118.0.5993.144","27.1.3":"118.0.5993.159","27.2.0":"118.0.5993.159","27.2.1":"118.0.5993.159","27.2.2":"118.0.5993.159","27.2.3":"118.0.5993.159","27.2.4":"118.0.5993.159","27.3.0":"118.0.5993.159","27.3.1":"118.0.5993.159","27.3.2":"118.0.5993.159","27.3.3":"118.0.5993.159","27.3.4":"118.0.5993.159","27.3.5":"118.0.5993.159","27.3.6":"118.0.5993.159","27.3.7":"118.0.5993.159","27.3.8":"118.0.5993.159","27.3.9":"118.0.5993.159","27.3.10":"118.0.5993.159","27.3.11":"118.0.5993.159","28.0.0-alpha.1":"119.0.6045.0","28.0.0-alpha.2":"119.0.6045.0","28.0.0-alpha.3":"119.0.6045.21","28.0.0-alpha.4":"119.0.6045.21","28.0.0-alpha.5":"119.0.6045.33","28.0.0-alpha.6":"119.0.6045.33","28.0.0-alpha.7":"119.0.6045.33","28.0.0-beta.1":"119.0.6045.33","28.0.0-beta.2":"120.0.6099.0","28.0.0-beta.3":"120.0.6099.5","28.0.0-beta.4":"120.0.6099.5","28.0.0-beta.5":"120.0.6099.18","28.0.0-beta.6":"120.0.6099.18","28.0.0-beta.7":"120.0.6099.18","28.0.0-beta.8":"120.0.6099.18","28.0.0-beta.9":"120.0.6099.18","28.0.0-beta.10":"120.0.6099.18","28.0.0-beta.11":"120.0.6099.35","28.0.0-nightly.20230817":"118.0.5949.0","28.0.0-nightly.20230818":"118.0.5949.0","28.0.0-nightly.20230821":"118.0.5949.0","28.0.0-nightly.20230822":"118.0.5949.0","28.0.0-nightly.20230823":"118.0.5949.0","28.0.0-nightly.20230824":"118.0.5949.0","28.0.0-nightly.20230825":"118.0.5949.0","28.0.0-nightly.20230828":"118.0.5949.0","28.0.0-nightly.20230829":"118.0.5949.0","28.0.0-nightly.20230830":"118.0.5949.0","28.0.0-nightly.20230831":"118.0.5949.0","28.0.0-nightly.20230906":"118.0.5991.0","28.0.0-nightly.20230907":"118.0.5993.0","28.0.0-nightly.20230908":"118.0.5993.0","28.0.0-nightly.20230911":"118.0.5993.0","28.0.0-nightly.20230912":"118.0.5993.0","28.0.0-nightly.20230913":"118.0.5993.0","28.0.0-nightly.20230914":"118.0.5993.0","28.0.0-nightly.20230915":"118.0.5993.0","28.0.0-nightly.20230919":"119.0.6006.0","28.0.0-nightly.20230920":"119.0.6017.0","28.0.0-nightly.20230921":"119.0.6019.2","28.0.0-nightly.20230925":"119.0.6019.2","28.0.0-nightly.20230926":"119.0.6019.2","28.0.0-nightly.20230927":"119.0.6019.2","28.0.0-nightly.20230928":"119.0.6019.2","28.0.0-nightly.20230929":"119.0.6029.0","28.0.0-nightly.20231002":"119.0.6029.0","28.0.0-nightly.20231003":"119.0.6043.0","28.0.0-nightly.20231004":"119.0.6043.0","28.0.0-nightly.20231005":"119.0.6043.0","28.0.0-nightly.20231006":"119.0.6045.0","28.0.0-nightly.20231009":"119.0.6045.0","28.0.0-nightly.20231010":"119.0.6045.0","28.0.0-nightly.20231011":"119.0.6045.0","28.0.0":"120.0.6099.56","28.1.0":"120.0.6099.109","28.1.1":"120.0.6099.109","28.1.2":"120.0.6099.199","28.1.3":"120.0.6099.199","28.1.4":"120.0.6099.216","28.2.0":"120.0.6099.227","28.2.1":"120.0.6099.268","28.2.2":"120.0.6099.276","28.2.3":"120.0.6099.283","28.2.4":"120.0.6099.291","28.2.5":"120.0.6099.291","28.2.6":"120.0.6099.291","28.2.7":"120.0.6099.291","28.2.8":"120.0.6099.291","28.2.9":"120.0.6099.291","28.2.10":"120.0.6099.291","28.3.0":"120.0.6099.291","28.3.1":"120.0.6099.291","28.3.2":"120.0.6099.291","28.3.3":"120.0.6099.291","29.0.0-alpha.1":"121.0.6147.0","29.0.0-alpha.2":"121.0.6147.0","29.0.0-alpha.3":"121.0.6147.0","29.0.0-alpha.4":"121.0.6159.0","29.0.0-alpha.5":"121.0.6159.0","29.0.0-alpha.6":"121.0.6159.0","29.0.0-alpha.7":"121.0.6159.0","29.0.0-alpha.8":"122.0.6194.0","29.0.0-alpha.9":"122.0.6236.2","29.0.0-alpha.10":"122.0.6236.2","29.0.0-alpha.11":"122.0.6236.2","29.0.0-beta.1":"122.0.6236.2","29.0.0-beta.2":"122.0.6236.2","29.0.0-beta.3":"122.0.6261.6","29.0.0-beta.4":"122.0.6261.6","29.0.0-beta.5":"122.0.6261.18","29.0.0-beta.6":"122.0.6261.18","29.0.0-beta.7":"122.0.6261.18","29.0.0-beta.8":"122.0.6261.18","29.0.0-beta.9":"122.0.6261.18","29.0.0-beta.10":"122.0.6261.18","29.0.0-beta.11":"122.0.6261.18","29.0.0-beta.12":"122.0.6261.29","29.0.0-nightly.20231012":"119.0.6045.0","29.0.0-nightly.20231013":"119.0.6045.0","29.0.0-nightly.20231016":"119.0.6045.0","29.0.0-nightly.20231017":"119.0.6045.0","29.0.0-nightly.20231018":"119.0.6045.0","29.0.0-nightly.20231019":"119.0.6045.0","29.0.0-nightly.20231020":"119.0.6045.0","29.0.0-nightly.20231023":"119.0.6045.0","29.0.0-nightly.20231024":"119.0.6045.0","29.0.0-nightly.20231025":"120.0.6078.0","29.0.0-nightly.20231026":"120.0.6078.0","29.0.0-nightly.20231027":"120.0.6078.0","29.0.0-nightly.20231030":"120.0.6078.0","29.0.0-nightly.20231031":"120.0.6078.0","29.0.0-nightly.20231101":"120.0.6078.0","29.0.0-nightly.20231102":"121.0.6100.0","29.0.0-nightly.20231103":"121.0.6100.0","29.0.0-nightly.20231106":"121.0.6104.0","29.0.0-nightly.20231107":"121.0.6110.0","29.0.0-nightly.20231108":"121.0.6110.0","29.0.0-nightly.20231109":"121.0.6110.0","29.0.0-nightly.20231110":"121.0.6110.0","29.0.0-nightly.20231113":"121.0.6110.0","29.0.0-nightly.20231114":"121.0.6110.0","29.0.0-nightly.20231115":"121.0.6116.0","29.0.0-nightly.20231116":"121.0.6116.0","29.0.0-nightly.20231117":"121.0.6116.0","29.0.0-nightly.20231120":"121.0.6116.0","29.0.0-nightly.20231121":"121.0.6116.0","29.0.0-nightly.20231122":"121.0.6116.0","29.0.0-nightly.20231123":"121.0.6116.0","29.0.0-nightly.20231124":"121.0.6116.0","29.0.0-nightly.20231127":"121.0.6116.0","29.0.0-nightly.20231128":"121.0.6116.0","29.0.0-nightly.20231129":"121.0.6147.0","29.0.0-nightly.20231130":"121.0.6147.0","29.0.0-nightly.20231201":"121.0.6147.0","29.0.0-nightly.20231204":"121.0.6147.0","29.0.0-nightly.20231205":"121.0.6147.0","29.0.0-nightly.20231206":"121.0.6147.0","29.0.0":"122.0.6261.39","29.0.1":"122.0.6261.57","29.1.0":"122.0.6261.70","29.1.1":"122.0.6261.111","29.1.2":"122.0.6261.112","29.1.3":"122.0.6261.112","29.1.4":"122.0.6261.129","29.1.5":"122.0.6261.130","29.1.6":"122.0.6261.139","29.2.0":"122.0.6261.156","29.3.0":"122.0.6261.156","29.3.1":"122.0.6261.156","29.3.2":"122.0.6261.156","29.3.3":"122.0.6261.156","29.4.0":"122.0.6261.156","29.4.1":"122.0.6261.156","29.4.2":"122.0.6261.156","30.0.0-alpha.1":"123.0.6296.0","30.0.0-alpha.2":"123.0.6312.5","30.0.0-alpha.3":"124.0.6323.0","30.0.0-alpha.4":"124.0.6323.0","30.0.0-alpha.5":"124.0.6331.0","30.0.0-alpha.6":"124.0.6331.0","30.0.0-alpha.7":"124.0.6353.0","30.0.0-beta.1":"124.0.6359.0","30.0.0-beta.2":"124.0.6359.0","30.0.0-beta.3":"124.0.6367.9","30.0.0-beta.4":"124.0.6367.9","30.0.0-beta.5":"124.0.6367.9","30.0.0-beta.6":"124.0.6367.18","30.0.0-beta.7":"124.0.6367.29","30.0.0-beta.8":"124.0.6367.29","30.0.0-nightly.20231207":"121.0.6147.0","30.0.0-nightly.20231208":"121.0.6147.0","30.0.0-nightly.20231211":"121.0.6147.0","30.0.0-nightly.20231212":"121.0.6159.0","30.0.0-nightly.20231213":"121.0.6159.0","30.0.0-nightly.20231214":"121.0.6159.0","30.0.0-nightly.20231215":"121.0.6159.0","30.0.0-nightly.20231218":"121.0.6159.0","30.0.0-nightly.20240102":"121.0.6159.0","30.0.0-nightly.20240103":"122.0.6194.0","30.0.0-nightly.20240104":"122.0.6194.0","30.0.0-nightly.20240105":"122.0.6194.0","30.0.0-nightly.20240108":"122.0.6194.0","30.0.0-nightly.20240109":"122.0.6194.0","30.0.0-nightly.20240110":"122.0.6194.0","30.0.0-nightly.20240111":"122.0.6236.2","30.0.0-nightly.20240112":"122.0.6236.2","30.0.0-nightly.20240115":"122.0.6236.2","30.0.0-nightly.20240116":"122.0.6236.2","30.0.0-nightly.20240117":"122.0.6236.2","30.0.0-nightly.20240118":"122.0.6236.2","30.0.0-nightly.20240119":"122.0.6236.2","30.0.0-nightly.20240122":"122.0.6236.2","30.0.0-nightly.20240123":"122.0.6236.2","30.0.0-nightly.20240124":"122.0.6236.2","30.0.0-nightly.20240125":"122.0.6236.2","30.0.0-nightly.20240126":"123.0.6264.0","30.0.0-nightly.20240129":"123.0.6264.0","30.0.0-nightly.20240130":"123.0.6264.0","30.0.0-nightly.20240131":"123.0.6264.0","30.0.0-nightly.20240201":"123.0.6272.0","30.0.0-nightly.20240202":"123.0.6272.0","30.0.0-nightly.20240205":"123.0.6272.0","30.0.0-nightly.20240206":"123.0.6272.0","30.0.0-nightly.20240207":"123.0.6272.0","30.0.0-nightly.20240208":"123.0.6272.0","30.0.0-nightly.20240209":"123.0.6272.0","30.0.0-nightly.20240212":"123.0.6272.0","30.0.0-nightly.20240213":"123.0.6272.0","30.0.0-nightly.20240214":"123.0.6272.0","30.0.0-nightly.20240215":"123.0.6296.0","30.0.0-nightly.20240216":"123.0.6296.0","30.0.0-nightly.20240219":"123.0.6296.0","30.0.0-nightly.20240220":"123.0.6296.0","30.0.0-nightly.20240221":"123.0.6296.0","30.0.0":"124.0.6367.49","30.0.1":"124.0.6367.60","30.0.2":"124.0.6367.91","30.0.3":"124.0.6367.119","30.0.4":"124.0.6367.201","30.0.5":"124.0.6367.207","30.0.6":"124.0.6367.207","30.0.7":"124.0.6367.221","30.0.8":"124.0.6367.230","30.0.9":"124.0.6367.233","30.1.0":"124.0.6367.243","30.1.1":"124.0.6367.243","31.0.0-alpha.1":"125.0.6412.0","31.0.0-alpha.2":"125.0.6412.0","31.0.0-alpha.3":"125.0.6412.0","31.0.0-alpha.4":"125.0.6412.0","31.0.0-alpha.5":"125.0.6412.0","31.0.0-beta.1":"126.0.6445.0","31.0.0-beta.2":"126.0.6445.0","31.0.0-beta.3":"126.0.6445.0","31.0.0-beta.4":"126.0.6445.0","31.0.0-beta.5":"126.0.6445.0","31.0.0-beta.6":"126.0.6445.0","31.0.0-beta.7":"126.0.6445.0","31.0.0-beta.8":"126.0.6445.0","31.0.0-beta.9":"126.0.6445.0","31.0.0-beta.10":"126.0.6478.36","31.0.0-nightly.20240222":"123.0.6312.5","31.0.0-nightly.20240223":"123.0.6312.5","31.0.0-nightly.20240226":"123.0.6312.5","31.0.0-nightly.20240227":"123.0.6312.5","31.0.0-nightly.20240228":"123.0.6312.5","31.0.0-nightly.20240229":"124.0.6323.0","31.0.0-nightly.20240301":"124.0.6323.0","31.0.0-nightly.20240304":"124.0.6323.0","31.0.0-nightly.20240305":"124.0.6323.0","31.0.0-nightly.20240306":"124.0.6331.0","31.0.0-nightly.20240307":"124.0.6331.0","31.0.0-nightly.20240308":"124.0.6331.0","31.0.0-nightly.20240311":"124.0.6331.0","31.0.0-nightly.20240312":"124.0.6351.0","31.0.0-nightly.20240313":"124.0.6353.0","31.0.0-nightly.20240314":"124.0.6353.0","31.0.0-nightly.20240315":"124.0.6353.0","31.0.0-nightly.20240318":"124.0.6359.0","31.0.0-nightly.20240319":"124.0.6359.0","31.0.0-nightly.20240320":"124.0.6359.0","31.0.0-nightly.20240321":"124.0.6359.0","31.0.0-nightly.20240325":"124.0.6359.0","31.0.0-nightly.20240327":"124.0.6359.0","31.0.0-nightly.20240328":"124.0.6359.0","31.0.0-nightly.20240329":"124.0.6359.0","31.0.0-nightly.20240401":"124.0.6359.0","31.0.0-nightly.20240402":"124.0.6359.0","31.0.0-nightly.20240404":"124.0.6359.0","31.0.0-nightly.20240405":"124.0.6359.0","31.0.0-nightly.20240408":"124.0.6359.0","31.0.0-nightly.20240409":"124.0.6359.0","31.0.0-nightly.20240410":"124.0.6359.0","31.0.0-nightly.20240411":"124.0.6359.0","31.0.0-nightly.20240412":"124.0.6359.0","31.0.0":"126.0.6478.36","31.0.1":"126.0.6478.36","32.0.0-alpha.1":"127.0.6521.0","32.0.0-alpha.2":"127.0.6521.0","32.0.0-nightly.20240418":"125.0.6412.0","32.0.0-nightly.20240419":"125.0.6412.0","32.0.0-nightly.20240422":"125.0.6412.0","32.0.0-nightly.20240423":"125.0.6412.0","32.0.0-nightly.20240424":"125.0.6412.0","32.0.0-nightly.20240425":"125.0.6412.0","32.0.0-nightly.20240426":"125.0.6412.0","32.0.0-nightly.20240429":"125.0.6412.0","32.0.0-nightly.20240430":"125.0.6412.0","32.0.0-nightly.20240501":"125.0.6412.0","32.0.0-nightly.20240503":"125.0.6412.0","32.0.0-nightly.20240506":"125.0.6412.0","32.0.0-nightly.20240507":"125.0.6412.0","32.0.0-nightly.20240508":"125.0.6412.0","32.0.0-nightly.20240509":"125.0.6412.0","32.0.0-nightly.20240510":"125.0.6412.0","32.0.0-nightly.20240513":"126.0.6445.0","32.0.0-nightly.20240514":"126.0.6445.0","32.0.0-nightly.20240515":"126.0.6445.0","32.0.0-nightly.20240516":"126.0.6445.0","32.0.0-nightly.20240517":"126.0.6445.0","32.0.0-nightly.20240520":"126.0.6445.0","32.0.0-nightly.20240521":"126.0.6445.0","32.0.0-nightly.20240522":"126.0.6445.0","32.0.0-nightly.20240523":"126.0.6445.0","32.0.0-nightly.20240524":"126.0.6445.0","32.0.0-nightly.20240529":"126.0.6445.0","32.0.0-nightly.20240530":"126.0.6445.0","32.0.0-nightly.20240531":"126.0.6445.0","32.0.0-nightly.20240603":"126.0.6445.0","32.0.0-nightly.20240604":"126.0.6445.0","32.0.0-nightly.20240605":"126.0.6445.0","32.0.0-nightly.20240606":"126.0.6445.0","32.0.0-nightly.20240607":"126.0.6445.0","32.0.0-nightly.20240610":"127.0.6521.0","32.0.0-nightly.20240611":"127.0.6521.0","33.0.0-nightly.20240612":"127.0.6521.0","33.0.0-nightly.20240614":"127.0.6521.0","33.0.0-nightly.20240617":"127.0.6521.0","33.0.0-nightly.20240618":"127.0.6521.0"} \ No newline at end of file diff --git a/tools/eslint/node_modules/electron-to-chromium/index.js b/tools/eslint/node_modules/electron-to-chromium/index.js deleted file mode 100644 index 1818281fab5043..00000000000000 --- a/tools/eslint/node_modules/electron-to-chromium/index.js +++ /dev/null @@ -1,36 +0,0 @@ -var versions = require('./versions'); -var fullVersions = require('./full-versions'); -var chromiumVersions = require('./chromium-versions'); -var fullChromiumVersions = require('./full-chromium-versions'); - -var electronToChromium = function (query) { - var number = getQueryString(query); - return number.split('.').length > 2 ? fullVersions[number] : versions[number] || undefined; -}; - -var chromiumToElectron = function (query) { - var number = getQueryString(query); - return number.split('.').length > 2 ? fullChromiumVersions[number] : chromiumVersions[number] || undefined; -}; - -var electronToBrowserList = function (query) { - var number = getQueryString(query); - return versions[number] ? "Chrome >= " + versions[number] : undefined; -}; - -var getQueryString = function (query) { - var number = query; - if (query === 1) { number = "1.0" } - if (typeof query === 'number') { number += ''; } - return number; -}; - -module.exports = { - versions: versions, - fullVersions: fullVersions, - chromiumVersions: chromiumVersions, - fullChromiumVersions: fullChromiumVersions, - electronToChromium: electronToChromium, - electronToBrowserList: electronToBrowserList, - chromiumToElectron: chromiumToElectron -}; diff --git a/tools/eslint/node_modules/electron-to-chromium/package.json b/tools/eslint/node_modules/electron-to-chromium/package.json deleted file mode 100644 index 879c03d5b74f31..00000000000000 --- a/tools/eslint/node_modules/electron-to-chromium/package.json +++ /dev/null @@ -1,44 +0,0 @@ -{ - "name": "electron-to-chromium", - "version": "1.4.806", - "description": "Provides a list of electron-to-chromium version mappings", - "main": "index.js", - "files": [ - "versions.js", - "full-versions.js", - "chromium-versions.js", - "full-chromium-versions.js", - "versions.json", - "full-versions.json", - "chromium-versions.json", - "full-chromium-versions.json", - "LICENSE" - ], - "scripts": { - "build": "node build.mjs", - "update": "node automated-update.js", - "test": "nyc ava --verbose", - "report": "nyc report --reporter=text-lcov > coverage.lcov && codecov" - }, - "repository": { - "type": "git", - "url": "https://github.com/kilian/electron-to-chromium/" - }, - "keywords": [ - "electron", - "chrome", - "chromium", - "browserslist", - "browserlist" - ], - "author": "Kilian Valkhof", - "license": "ISC", - "devDependencies": { - "ava": "^5.1.1", - "codecov": "^3.8.2", - "compare-versions": "^6.0.0-rc.1", - "node-fetch": "^3.3.0", - "nyc": "^15.1.0", - "shelljs": "^0.8.5" - } -} diff --git a/tools/eslint/node_modules/electron-to-chromium/versions.js b/tools/eslint/node_modules/electron-to-chromium/versions.js deleted file mode 100644 index ae0a41e17172d1..00000000000000 --- a/tools/eslint/node_modules/electron-to-chromium/versions.js +++ /dev/null @@ -1,158 +0,0 @@ -module.exports = { - "0.20": "39", - "0.21": "41", - "0.22": "41", - "0.23": "41", - "0.24": "41", - "0.25": "42", - "0.26": "42", - "0.27": "43", - "0.28": "43", - "0.29": "43", - "0.30": "44", - "0.31": "45", - "0.32": "45", - "0.33": "45", - "0.34": "45", - "0.35": "45", - "0.36": "47", - "0.37": "49", - "1.0": "49", - "1.1": "50", - "1.2": "51", - "1.3": "52", - "1.4": "53", - "1.5": "54", - "1.6": "56", - "1.7": "58", - "1.8": "59", - "2.0": "61", - "2.1": "61", - "3.0": "66", - "3.1": "66", - "4.0": "69", - "4.1": "69", - "4.2": "69", - "5.0": "73", - "6.0": "76", - "6.1": "76", - "7.0": "78", - "7.1": "78", - "7.2": "78", - "7.3": "78", - "8.0": "80", - "8.1": "80", - "8.2": "80", - "8.3": "80", - "8.4": "80", - "8.5": "80", - "9.0": "83", - "9.1": "83", - "9.2": "83", - "9.3": "83", - "9.4": "83", - "10.0": "85", - "10.1": "85", - "10.2": "85", - "10.3": "85", - "10.4": "85", - "11.0": "87", - "11.1": "87", - "11.2": "87", - "11.3": "87", - "11.4": "87", - "11.5": "87", - "12.0": "89", - "12.1": "89", - "12.2": "89", - "13.0": "91", - "13.1": "91", - "13.2": "91", - "13.3": "91", - "13.4": "91", - "13.5": "91", - "13.6": "91", - "14.0": "93", - "14.1": "93", - "14.2": "93", - "15.0": "94", - "15.1": "94", - "15.2": "94", - "15.3": "94", - "15.4": "94", - "15.5": "94", - "16.0": "96", - "16.1": "96", - "16.2": "96", - "17.0": "98", - "17.1": "98", - "17.2": "98", - "17.3": "98", - "17.4": "98", - "18.0": "100", - "18.1": "100", - "18.2": "100", - "18.3": "100", - "19.0": "102", - "19.1": "102", - "20.0": "104", - "20.1": "104", - "20.2": "104", - "20.3": "104", - "21.0": "106", - "21.1": "106", - "21.2": "106", - "21.3": "106", - "21.4": "106", - "22.0": "108", - "22.1": "108", - "22.2": "108", - "22.3": "108", - "23.0": "110", - "23.1": "110", - "23.2": "110", - "23.3": "110", - "24.0": "112", - "24.1": "112", - "24.2": "112", - "24.3": "112", - "24.4": "112", - "24.5": "112", - "24.6": "112", - "24.7": "112", - "24.8": "112", - "25.0": "114", - "25.1": "114", - "25.2": "114", - "25.3": "114", - "25.4": "114", - "25.5": "114", - "25.6": "114", - "25.7": "114", - "25.8": "114", - "25.9": "114", - "26.0": "116", - "26.1": "116", - "26.2": "116", - "26.3": "116", - "26.4": "116", - "26.5": "116", - "26.6": "116", - "27.0": "118", - "27.1": "118", - "27.2": "118", - "27.3": "118", - "28.0": "120", - "28.1": "120", - "28.2": "120", - "28.3": "120", - "29.0": "122", - "29.1": "122", - "29.2": "122", - "29.3": "122", - "29.4": "122", - "30.0": "124", - "30.1": "124", - "31.0": "126", - "32.0": "127" -}; \ No newline at end of file diff --git a/tools/eslint/node_modules/electron-to-chromium/versions.json b/tools/eslint/node_modules/electron-to-chromium/versions.json deleted file mode 100644 index 21bd7395740201..00000000000000 --- a/tools/eslint/node_modules/electron-to-chromium/versions.json +++ /dev/null @@ -1 +0,0 @@ -{"0.20":"39","0.21":"41","0.22":"41","0.23":"41","0.24":"41","0.25":"42","0.26":"42","0.27":"43","0.28":"43","0.29":"43","0.30":"44","0.31":"45","0.32":"45","0.33":"45","0.34":"45","0.35":"45","0.36":"47","0.37":"49","1.0":"49","1.1":"50","1.2":"51","1.3":"52","1.4":"53","1.5":"54","1.6":"56","1.7":"58","1.8":"59","2.0":"61","2.1":"61","3.0":"66","3.1":"66","4.0":"69","4.1":"69","4.2":"69","5.0":"73","6.0":"76","6.1":"76","7.0":"78","7.1":"78","7.2":"78","7.3":"78","8.0":"80","8.1":"80","8.2":"80","8.3":"80","8.4":"80","8.5":"80","9.0":"83","9.1":"83","9.2":"83","9.3":"83","9.4":"83","10.0":"85","10.1":"85","10.2":"85","10.3":"85","10.4":"85","11.0":"87","11.1":"87","11.2":"87","11.3":"87","11.4":"87","11.5":"87","12.0":"89","12.1":"89","12.2":"89","13.0":"91","13.1":"91","13.2":"91","13.3":"91","13.4":"91","13.5":"91","13.6":"91","14.0":"93","14.1":"93","14.2":"93","15.0":"94","15.1":"94","15.2":"94","15.3":"94","15.4":"94","15.5":"94","16.0":"96","16.1":"96","16.2":"96","17.0":"98","17.1":"98","17.2":"98","17.3":"98","17.4":"98","18.0":"100","18.1":"100","18.2":"100","18.3":"100","19.0":"102","19.1":"102","20.0":"104","20.1":"104","20.2":"104","20.3":"104","21.0":"106","21.1":"106","21.2":"106","21.3":"106","21.4":"106","22.0":"108","22.1":"108","22.2":"108","22.3":"108","23.0":"110","23.1":"110","23.2":"110","23.3":"110","24.0":"112","24.1":"112","24.2":"112","24.3":"112","24.4":"112","24.5":"112","24.6":"112","24.7":"112","24.8":"112","25.0":"114","25.1":"114","25.2":"114","25.3":"114","25.4":"114","25.5":"114","25.6":"114","25.7":"114","25.8":"114","25.9":"114","26.0":"116","26.1":"116","26.2":"116","26.3":"116","26.4":"116","26.5":"116","26.6":"116","27.0":"118","27.1":"118","27.2":"118","27.3":"118","28.0":"120","28.1":"120","28.2":"120","28.3":"120","29.0":"122","29.1":"122","29.2":"122","29.3":"122","29.4":"122","30.0":"124","30.1":"124","31.0":"126","32.0":"127"} \ No newline at end of file diff --git a/tools/eslint/node_modules/es-module-lexer/LICENSE b/tools/eslint/node_modules/es-module-lexer/LICENSE deleted file mode 100644 index c795a2775f8af8..00000000000000 --- a/tools/eslint/node_modules/es-module-lexer/LICENSE +++ /dev/null @@ -1,10 +0,0 @@ -MIT License ------------ - -Copyright (C) 2018-2022 Guy Bedford - -Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/tools/eslint/node_modules/es-module-lexer/dist/lexer.asm.js b/tools/eslint/node_modules/es-module-lexer/dist/lexer.asm.js deleted file mode 100644 index d771a33c62538d..00000000000000 --- a/tools/eslint/node_modules/es-module-lexer/dist/lexer.asm.js +++ /dev/null @@ -1,2 +0,0 @@ -/* es-module-lexer 1.5.4 */ -let e,a,r,i=2<<19;const s=1===new Uint8Array(new Uint16Array([1]).buffer)[0]?function(e,a){const r=e.length;let i=0;for(;i>>8}},f="xportmportlassforetaourceromsyncunctionssertvoyiedelecontininstantybreareturdebuggeawaithrwhileifcatcfinallels";let t,c,n;export function parse(k,l="@"){t=k,c=l;const u=2*t.length+(2<<18);if(u>i||!e){for(;u>i;)i*=2;a=new ArrayBuffer(i),s(f,new Uint16Array(a,16,110)),e=function(e,a,r){"use asm";var i=new e.Int8Array(r),s=new e.Int16Array(r),f=new e.Int32Array(r),t=new e.Uint8Array(r),c=new e.Uint16Array(r),n=1040;function b(){var e=0,a=0,r=0,t=0,c=0,b=0,u=0;u=n;n=n+10240|0;i[804]=1;i[803]=0;s[399]=0;s[400]=0;f[69]=f[2];i[805]=0;f[68]=0;i[802]=0;f[70]=u+2048;f[71]=u;i[806]=0;e=(f[3]|0)+-2|0;f[72]=e;a=e+(f[66]<<1)|0;f[73]=a;e:while(1){r=e+2|0;f[72]=r;if(e>>>0>=a>>>0){t=18;break}a:do{switch(s[r>>1]|0){case 9:case 10:case 11:case 12:case 13:case 32:break;case 101:{if((((s[400]|0)==0?H(r)|0:0)?(m(e+4|0,16,10)|0)==0:0)?(k(),(i[804]|0)==0):0){t=9;break e}else t=17;break}case 105:{if(H(r)|0?(m(e+4|0,26,10)|0)==0:0){l();t=17}else t=17;break}case 59:{t=17;break}case 47:switch(s[e+4>>1]|0){case 47:{P();break a}case 42:{y(1);break a}default:{t=16;break e}}default:{t=16;break e}}}while(0);if((t|0)==17){t=0;f[69]=f[72]}e=f[72]|0;a=f[73]|0}if((t|0)==9){e=f[72]|0;f[69]=e;t=19}else if((t|0)==16){i[804]=0;f[72]=e;t=19}else if((t|0)==18)if(!(i[802]|0)){e=r;t=19}else e=0;do{if((t|0)==19){e:while(1){a=e+2|0;f[72]=a;if(e>>>0>=(f[73]|0)>>>0){t=92;break}a:do{switch(s[a>>1]|0){case 9:case 10:case 11:case 12:case 13:case 32:break;case 101:{if(((s[400]|0)==0?H(a)|0:0)?(m(e+4|0,16,10)|0)==0:0){k();t=91}else t=91;break}case 105:{if(H(a)|0?(m(e+4|0,26,10)|0)==0:0){l();t=91}else t=91;break}case 99:{if((H(a)|0?(m(e+4|0,36,8)|0)==0:0)?V(s[e+12>>1]|0)|0:0){i[806]=1;t=91}else t=91;break}case 40:{r=f[70]|0;e=s[400]|0;t=e&65535;f[r+(t<<3)>>2]=1;a=f[69]|0;s[400]=e+1<<16>>16;f[r+(t<<3)+4>>2]=a;t=91;break}case 41:{a=s[400]|0;if(!(a<<16>>16)){t=36;break e}r=a+-1<<16>>16;s[400]=r;t=s[399]|0;a=t&65535;if(t<<16>>16!=0?(f[(f[70]|0)+((r&65535)<<3)>>2]|0)==5:0){a=f[(f[71]|0)+(a+-1<<2)>>2]|0;r=a+4|0;if(!(f[r>>2]|0))f[r>>2]=(f[69]|0)+2;f[a+12>>2]=e+4;s[399]=t+-1<<16>>16;t=91}else t=91;break}case 123:{t=f[69]|0;r=f[63]|0;e=t;do{if((s[t>>1]|0)==41&(r|0)!=0?(f[r+4>>2]|0)==(t|0):0){a=f[64]|0;f[63]=a;if(!a){f[59]=0;break}else{f[a+32>>2]=0;break}}}while(0);r=f[70]|0;a=s[400]|0;t=a&65535;f[r+(t<<3)>>2]=(i[806]|0)==0?2:6;s[400]=a+1<<16>>16;f[r+(t<<3)+4>>2]=e;i[806]=0;t=91;break}case 125:{e=s[400]|0;if(!(e<<16>>16)){t=49;break e}r=f[70]|0;t=e+-1<<16>>16;s[400]=t;if((f[r+((t&65535)<<3)>>2]|0)==4){h();t=91}else t=91;break}case 39:{v(39);t=91;break}case 34:{v(34);t=91;break}case 47:switch(s[e+4>>1]|0){case 47:{P();break a}case 42:{y(1);break a}default:{e=f[69]|0;a=s[e>>1]|0;r:do{if(!(U(a)|0))if(a<<16>>16==41){r=s[400]|0;if(!(D(f[(f[70]|0)+((r&65535)<<3)+4>>2]|0)|0))t=65}else t=64;else switch(a<<16>>16){case 46:if(((s[e+-2>>1]|0)+-48&65535)<10){t=64;break r}else break r;case 43:if((s[e+-2>>1]|0)==43){t=64;break r}else break r;case 45:if((s[e+-2>>1]|0)==45){t=64;break r}else break r;default:break r}}while(0);if((t|0)==64){r=s[400]|0;t=65}r:do{if((t|0)==65){t=0;if(r<<16>>16!=0?(c=f[70]|0,b=(r&65535)+-1|0,a<<16>>16==102?(f[c+(b<<3)>>2]|0)==1:0):0){if((s[e+-2>>1]|0)==111?$(f[c+(b<<3)+4>>2]|0,44,3)|0:0)break}else t=69;if((t|0)==69?(0,a<<16>>16==125):0){t=f[70]|0;r=r&65535;if(p(f[t+(r<<3)+4>>2]|0)|0)break;if((f[t+(r<<3)>>2]|0)==6)break}if(!(o(e)|0)){switch(a<<16>>16){case 0:break r;case 47:{if(i[805]|0)break r;break}default:{}}t=f[65]|0;if((t|0?e>>>0>=(f[t>>2]|0)>>>0:0)?e>>>0<=(f[t+4>>2]|0)>>>0:0){g();i[805]=0;t=91;break a}r=f[3]|0;do{if(e>>>0<=r>>>0)break;e=e+-2|0;f[69]=e;a=s[e>>1]|0}while(!(E(a)|0));if(F(a)|0){do{if(e>>>0<=r>>>0)break;e=e+-2|0;f[69]=e}while(F(s[e>>1]|0)|0);if(j(e)|0){g();i[805]=0;t=91;break a}}i[805]=1;t=91;break a}}}while(0);g();i[805]=0;t=91;break a}}case 96:{r=f[70]|0;a=s[400]|0;t=a&65535;f[r+(t<<3)+4>>2]=f[69];s[400]=a+1<<16>>16;f[r+(t<<3)>>2]=3;h();t=91;break}default:t=91}}while(0);if((t|0)==91){t=0;f[69]=f[72]}e=f[72]|0}if((t|0)==36){T();e=0;break}else if((t|0)==49){T();e=0;break}else if((t|0)==92){e=(i[802]|0)==0?(s[399]|s[400])<<16>>16==0:0;break}}}while(0);n=u;return e|0}function k(){var e=0,a=0,r=0,t=0,c=0,n=0,b=0,k=0,l=0,o=0,h=0,d=0,C=0,g=0;k=f[72]|0;l=f[65]|0;g=k+12|0;f[72]=g;r=w(1)|0;e=f[72]|0;if(!((e|0)==(g|0)?!(I(r)|0):0))C=3;e:do{if((C|0)==3){a:do{switch(r<<16>>16){case 123:{f[72]=e+2;e=w(1)|0;a=f[72]|0;while(1){if(W(e)|0){v(e);e=(f[72]|0)+2|0;f[72]=e}else{q(e)|0;e=f[72]|0}w(1)|0;e=A(a,e)|0;if(e<<16>>16==44){f[72]=(f[72]|0)+2;e=w(1)|0}if(e<<16>>16==125){C=15;break}g=a;a=f[72]|0;if((a|0)==(g|0)){C=12;break}if(a>>>0>(f[73]|0)>>>0){C=14;break}}if((C|0)==12){T();break e}else if((C|0)==14){T();break e}else if((C|0)==15){i[803]=1;f[72]=(f[72]|0)+2;break a}break}case 42:{f[72]=e+2;w(1)|0;g=f[72]|0;A(g,g)|0;break}default:{i[804]=0;switch(r<<16>>16){case 100:{k=e+14|0;f[72]=k;switch((w(1)|0)<<16>>16){case 97:{a=f[72]|0;if((m(a+2|0,72,8)|0)==0?(c=a+10|0,F(s[c>>1]|0)|0):0){f[72]=c;w(0)|0;C=22}break}case 102:{C=22;break}case 99:{a=f[72]|0;if(((m(a+2|0,36,8)|0)==0?(t=a+10|0,g=s[t>>1]|0,V(g)|0|g<<16>>16==123):0)?(f[72]=t,n=w(1)|0,n<<16>>16!=123):0){d=n;C=31}break}default:{}}r:do{if((C|0)==22?(b=f[72]|0,(m(b+2|0,80,14)|0)==0):0){r=b+16|0;a=s[r>>1]|0;if(!(V(a)|0))switch(a<<16>>16){case 40:case 42:break;default:break r}f[72]=r;a=w(1)|0;if(a<<16>>16==42){f[72]=(f[72]|0)+2;a=w(1)|0}if(a<<16>>16!=40){d=a;C=31}}}while(0);if((C|0)==31?(o=f[72]|0,q(d)|0,h=f[72]|0,h>>>0>o>>>0):0){O(e,k,o,h);f[72]=(f[72]|0)+-2;break e}O(e,k,0,0);f[72]=e+12;break e}case 97:{f[72]=e+10;w(0)|0;e=f[72]|0;C=35;break}case 102:{C=35;break}case 99:{if((m(e+2|0,36,8)|0)==0?(a=e+10|0,E(s[a>>1]|0)|0):0){f[72]=a;g=w(1)|0;C=f[72]|0;q(g)|0;g=f[72]|0;O(C,g,C,g);f[72]=(f[72]|0)+-2;break e}e=e+4|0;f[72]=e;break}case 108:case 118:break;default:break e}if((C|0)==35){f[72]=e+16;e=w(1)|0;if(e<<16>>16==42){f[72]=(f[72]|0)+2;e=w(1)|0}C=f[72]|0;q(e)|0;g=f[72]|0;O(C,g,C,g);f[72]=(f[72]|0)+-2;break e}f[72]=e+6;i[804]=0;r=w(1)|0;e=f[72]|0;r=(q(r)|0|32)<<16>>16==123;t=f[72]|0;if(r){f[72]=t+2;g=w(1)|0;e=f[72]|0;q(g)|0}r:while(1){a=f[72]|0;if((a|0)==(e|0))break;O(e,a,e,a);a=w(1)|0;if(r)switch(a<<16>>16){case 93:case 125:break e;default:{}}e=f[72]|0;if(a<<16>>16!=44){C=51;break}f[72]=e+2;a=w(1)|0;e=f[72]|0;switch(a<<16>>16){case 91:case 123:{C=51;break r}default:{}}q(a)|0}if((C|0)==51)f[72]=e+-2;if(!r)break e;f[72]=t+-2;break e}}}while(0);g=(w(1)|0)<<16>>16==102;e=f[72]|0;if(g?(m(e+2|0,66,6)|0)==0:0){f[72]=e+8;u(k,w(1)|0,0);e=(l|0)==0?240:l+16|0;while(1){e=f[e>>2]|0;if(!e)break e;f[e+12>>2]=0;f[e+8>>2]=0;e=e+16|0}}f[72]=e+-2}}while(0);return}function l(){var e=0,a=0,r=0,t=0,c=0,n=0,b=0;c=f[72]|0;r=c+12|0;f[72]=r;t=w(1)|0;a=f[72]|0;e:do{if(t<<16>>16!=46)if(t<<16>>16==115&a>>>0>r>>>0)if((m(a+2|0,56,10)|0)==0?(e=a+12|0,V(s[e>>1]|0)|0):0)n=14;else{a=6;r=0;n=46}else{e=t;r=0;n=15}else{f[72]=a+2;switch((w(1)|0)<<16>>16){case 109:{e=f[72]|0;if(m(e+2|0,50,6)|0)break e;a=f[69]|0;if(!(G(a)|0)?(s[a>>1]|0)==46:0)break e;d(c,c,e+8|0,2);break e}case 115:{e=f[72]|0;if(m(e+2|0,56,10)|0)break e;a=f[69]|0;if(!(G(a)|0)?(s[a>>1]|0)==46:0)break e;e=e+12|0;n=14;break e}default:break e}}}while(0);if((n|0)==14){f[72]=e;e=w(1)|0;r=1;n=15}e:do{if((n|0)==15)switch(e<<16>>16){case 40:{a=f[70]|0;b=s[400]|0;t=b&65535;f[a+(t<<3)>>2]=5;e=f[72]|0;s[400]=b+1<<16>>16;f[a+(t<<3)+4>>2]=e;if((s[f[69]>>1]|0)==46)break e;f[72]=e+2;a=w(1)|0;d(c,f[72]|0,0,e);if(r){e=f[63]|0;f[e+28>>2]=5}else e=f[63]|0;c=f[71]|0;b=s[399]|0;s[399]=b+1<<16>>16;f[c+((b&65535)<<2)>>2]=e;switch(a<<16>>16){case 39:{v(39);break}case 34:{v(34);break}default:{f[72]=(f[72]|0)+-2;break e}}e=(f[72]|0)+2|0;f[72]=e;switch((w(1)|0)<<16>>16){case 44:{f[72]=(f[72]|0)+2;w(1)|0;c=f[63]|0;f[c+4>>2]=e;b=f[72]|0;f[c+16>>2]=b;i[c+24>>0]=1;f[72]=b+-2;break e}case 41:{s[400]=(s[400]|0)+-1<<16>>16;b=f[63]|0;f[b+4>>2]=e;f[b+12>>2]=(f[72]|0)+2;i[b+24>>0]=1;s[399]=(s[399]|0)+-1<<16>>16;break e}default:{f[72]=(f[72]|0)+-2;break e}}}case 123:{if(r){a=12;r=1;n=46;break e}e=f[72]|0;if(s[400]|0){f[72]=e+-2;break e}while(1){if(e>>>0>=(f[73]|0)>>>0)break;e=w(1)|0;if(!(W(e)|0)){if(e<<16>>16==125){n=36;break}}else v(e);e=(f[72]|0)+2|0;f[72]=e}if((n|0)==36)f[72]=(f[72]|0)+2;b=(w(1)|0)<<16>>16==102;e=f[72]|0;if(b?m(e+2|0,66,6)|0:0){T();break e}f[72]=e+8;e=w(1)|0;if(W(e)|0){u(c,e,0);break e}else{T();break e}}default:{if(r){a=12;r=1;n=46;break e}switch(e<<16>>16){case 42:case 39:case 34:{r=0;n=48;break e}default:{a=6;r=0;n=46;break e}}}}}while(0);if((n|0)==46){e=f[72]|0;if((e|0)==(c+(a<<1)|0))f[72]=e+-2;else n=48}do{if((n|0)==48){if(s[400]|0){f[72]=(f[72]|0)+-2;break}e=f[73]|0;a=f[72]|0;while(1){if(a>>>0>=e>>>0){n=55;break}t=s[a>>1]|0;if(W(t)|0){n=53;break}b=a+2|0;f[72]=b;a=b}if((n|0)==53){u(c,t,r);break}else if((n|0)==55){T();break}}}while(0);return}function u(e,a,r){e=e|0;a=a|0;r=r|0;var i=0,t=0;i=(f[72]|0)+2|0;switch(a<<16>>16){case 39:{v(39);t=5;break}case 34:{v(34);t=5;break}default:T()}do{if((t|0)==5){d(e,i,f[72]|0,1);if(r)f[(f[63]|0)+28>>2]=4;f[72]=(f[72]|0)+2;a=w(0)|0;r=a<<16>>16==97;if(r){i=f[72]|0;if(m(i+2|0,94,10)|0)t=13}else{i=f[72]|0;if(!(((a<<16>>16==119?(s[i+2>>1]|0)==105:0)?(s[i+4>>1]|0)==116:0)?(s[i+6>>1]|0)==104:0))t=13}if((t|0)==13){f[72]=i+-2;break}f[72]=i+((r?6:4)<<1);if((w(1)|0)<<16>>16!=123){f[72]=i;break}r=f[72]|0;a=r;e:while(1){f[72]=a+2;a=w(1)|0;switch(a<<16>>16){case 39:{v(39);f[72]=(f[72]|0)+2;a=w(1)|0;break}case 34:{v(34);f[72]=(f[72]|0)+2;a=w(1)|0;break}default:a=q(a)|0}if(a<<16>>16!=58){t=22;break}f[72]=(f[72]|0)+2;switch((w(1)|0)<<16>>16){case 39:{v(39);break}case 34:{v(34);break}default:{t=26;break e}}f[72]=(f[72]|0)+2;switch((w(1)|0)<<16>>16){case 125:{t=31;break e}case 44:break;default:{t=30;break e}}f[72]=(f[72]|0)+2;if((w(1)|0)<<16>>16==125){t=31;break}a=f[72]|0}if((t|0)==22){f[72]=i;break}else if((t|0)==26){f[72]=i;break}else if((t|0)==30){f[72]=i;break}else if((t|0)==31){t=f[63]|0;f[t+16>>2]=r;f[t+12>>2]=(f[72]|0)+2;break}}}while(0);return}function o(e){e=e|0;e:do{switch(s[e>>1]|0){case 100:switch(s[e+-2>>1]|0){case 105:{e=$(e+-4|0,104,2)|0;break e}case 108:{e=$(e+-4|0,108,3)|0;break e}default:{e=0;break e}}case 101:switch(s[e+-2>>1]|0){case 115:switch(s[e+-4>>1]|0){case 108:{e=B(e+-6|0,101)|0;break e}case 97:{e=B(e+-6|0,99)|0;break e}default:{e=0;break e}}case 116:{e=$(e+-4|0,114,4)|0;break e}case 117:{e=$(e+-4|0,122,6)|0;break e}default:{e=0;break e}}case 102:{if((s[e+-2>>1]|0)==111?(s[e+-4>>1]|0)==101:0)switch(s[e+-6>>1]|0){case 99:{e=$(e+-8|0,134,6)|0;break e}case 112:{e=$(e+-8|0,146,2)|0;break e}default:{e=0;break e}}else e=0;break}case 107:{e=$(e+-2|0,150,4)|0;break}case 110:{e=e+-2|0;if(B(e,105)|0)e=1;else e=$(e,158,5)|0;break}case 111:{e=B(e+-2|0,100)|0;break}case 114:{e=$(e+-2|0,168,7)|0;break}case 116:{e=$(e+-2|0,182,4)|0;break}case 119:switch(s[e+-2>>1]|0){case 101:{e=B(e+-4|0,110)|0;break e}case 111:{e=$(e+-4|0,190,3)|0;break e}default:{e=0;break e}}default:e=0}}while(0);return e|0}function h(){var e=0,a=0,r=0,i=0;a=f[73]|0;r=f[72]|0;e:while(1){e=r+2|0;if(r>>>0>=a>>>0){a=10;break}switch(s[e>>1]|0){case 96:{a=7;break e}case 36:{if((s[r+4>>1]|0)==123){a=6;break e}break}case 92:{e=r+4|0;break}default:{}}r=e}if((a|0)==6){e=r+4|0;f[72]=e;a=f[70]|0;i=s[400]|0;r=i&65535;f[a+(r<<3)>>2]=4;s[400]=i+1<<16>>16;f[a+(r<<3)+4>>2]=e}else if((a|0)==7){f[72]=e;r=f[70]|0;i=(s[400]|0)+-1<<16>>16;s[400]=i;if((f[r+((i&65535)<<3)>>2]|0)!=3)T()}else if((a|0)==10){f[72]=e;T()}return}function w(e){e=e|0;var a=0,r=0,i=0;r=f[72]|0;e:do{a=s[r>>1]|0;a:do{if(a<<16>>16!=47)if(e)if(V(a)|0)break;else break e;else if(F(a)|0)break;else break e;else switch(s[r+2>>1]|0){case 47:{P();break a}case 42:{y(e);break a}default:{a=47;break e}}}while(0);i=f[72]|0;r=i+2|0;f[72]=r}while(i>>>0<(f[73]|0)>>>0);return a|0}function d(e,a,r,s){e=e|0;a=a|0;r=r|0;s=s|0;var t=0,c=0;c=f[67]|0;f[67]=c+36;t=f[63]|0;f[((t|0)==0?236:t+32|0)>>2]=c;f[64]=t;f[63]=c;f[c+8>>2]=e;if(2==(s|0)){e=3;t=r}else{t=1==(s|0);e=t?1:2;t=t?r+2|0:0}f[c+12>>2]=t;f[c+28>>2]=e;f[c>>2]=a;f[c+4>>2]=r;f[c+16>>2]=0;f[c+20>>2]=s;a=1==(s|0);i[c+24>>0]=a&1;f[c+32>>2]=0;if(a|2==(s|0))i[803]=1;return}function v(e){e=e|0;var a=0,r=0,i=0,t=0;t=f[73]|0;a=f[72]|0;while(1){i=a+2|0;if(a>>>0>=t>>>0){a=9;break}r=s[i>>1]|0;if(r<<16>>16==e<<16>>16){a=10;break}if(r<<16>>16==92){r=a+4|0;if((s[r>>1]|0)==13){a=a+6|0;a=(s[a>>1]|0)==10?a:r}else a=r}else if(Z(r)|0){a=9;break}else a=i}if((a|0)==9){f[72]=i;T()}else if((a|0)==10)f[72]=i;return}function A(e,a){e=e|0;a=a|0;var r=0,i=0,t=0,c=0;r=f[72]|0;i=s[r>>1]|0;c=(e|0)==(a|0);t=c?0:e;c=c?0:a;if(i<<16>>16==97){f[72]=r+4;r=w(1)|0;e=f[72]|0;if(W(r)|0){v(r);a=(f[72]|0)+2|0;f[72]=a}else{q(r)|0;a=f[72]|0}i=w(1)|0;r=f[72]|0}if((r|0)!=(e|0))O(e,a,t,c);return i|0}function C(){var e=0,a=0,r=0;r=f[73]|0;a=f[72]|0;e:while(1){e=a+2|0;if(a>>>0>=r>>>0){a=6;break}switch(s[e>>1]|0){case 13:case 10:{a=6;break e}case 93:{a=7;break e}case 92:{e=a+4|0;break}default:{}}a=e}if((a|0)==6){f[72]=e;T();e=0}else if((a|0)==7){f[72]=e;e=93}return e|0}function g(){var e=0,a=0,r=0;e:while(1){e=f[72]|0;a=e+2|0;f[72]=a;if(e>>>0>=(f[73]|0)>>>0){r=7;break}switch(s[a>>1]|0){case 13:case 10:{r=7;break e}case 47:break e;case 91:{C()|0;break}case 92:{f[72]=e+4;break}default:{}}}if((r|0)==7)T();return}function p(e){e=e|0;switch(s[e>>1]|0){case 62:{e=(s[e+-2>>1]|0)==61;break}case 41:case 59:{e=1;break}case 104:{e=$(e+-2|0,210,4)|0;break}case 121:{e=$(e+-2|0,218,6)|0;break}case 101:{e=$(e+-2|0,230,3)|0;break}default:e=0}return e|0}function y(e){e=e|0;var a=0,r=0,i=0,t=0,c=0;t=(f[72]|0)+2|0;f[72]=t;r=f[73]|0;while(1){a=t+2|0;if(t>>>0>=r>>>0)break;i=s[a>>1]|0;if(!e?Z(i)|0:0)break;if(i<<16>>16==42?(s[t+4>>1]|0)==47:0){c=8;break}t=a}if((c|0)==8){f[72]=a;a=t+4|0}f[72]=a;return}function m(e,a,r){e=e|0;a=a|0;r=r|0;var s=0,f=0;e:do{if(!r)e=0;else{while(1){s=i[e>>0]|0;f=i[a>>0]|0;if(s<<24>>24!=f<<24>>24)break;r=r+-1|0;if(!r){e=0;break e}else{e=e+1|0;a=a+1|0}}e=(s&255)-(f&255)|0}}while(0);return e|0}function I(e){e=e|0;e:do{switch(e<<16>>16){case 38:case 37:case 33:{e=1;break}default:if((e&-8)<<16>>16==40|(e+-58&65535)<6)e=1;else{switch(e<<16>>16){case 91:case 93:case 94:{e=1;break e}default:{}}e=(e+-123&65535)<4}}}while(0);return e|0}function U(e){e=e|0;e:do{switch(e<<16>>16){case 38:case 37:case 33:break;default:if(!((e+-58&65535)<6|(e+-40&65535)<7&e<<16>>16!=41)){switch(e<<16>>16){case 91:case 94:break e;default:{}}return e<<16>>16!=125&(e+-123&65535)<4|0}}}while(0);return 1}function x(e){e=e|0;var a=0;a=s[e>>1]|0;e:do{if((a+-9&65535)>=5){switch(a<<16>>16){case 160:case 32:{a=1;break e}default:{}}if(I(a)|0)return a<<16>>16!=46|(G(e)|0)|0;else a=0}else a=1}while(0);return a|0}function S(e){e=e|0;var a=0,r=0,i=0,t=0;r=n;n=n+16|0;i=r;f[i>>2]=0;f[66]=e;a=f[3]|0;t=a+(e<<1)|0;e=t+2|0;s[t>>1]=0;f[i>>2]=e;f[67]=e;f[59]=0;f[63]=0;f[61]=0;f[60]=0;f[65]=0;f[62]=0;n=r;return a|0}function O(e,a,r,s){e=e|0;a=a|0;r=r|0;s=s|0;var t=0,c=0;t=f[67]|0;f[67]=t+20;c=f[65]|0;f[((c|0)==0?240:c+16|0)>>2]=t;f[65]=t;f[t>>2]=e;f[t+4>>2]=a;f[t+8>>2]=r;f[t+12>>2]=s;f[t+16>>2]=0;i[803]=1;return}function $(e,a,r){e=e|0;a=a|0;r=r|0;var i=0,s=0;i=e+(0-r<<1)|0;s=i+2|0;e=f[3]|0;if(s>>>0>=e>>>0?(m(s,a,r<<1)|0)==0:0)if((s|0)==(e|0))e=1;else e=x(i)|0;else e=0;return e|0}function j(e){e=e|0;switch(s[e>>1]|0){case 107:{e=$(e+-2|0,150,4)|0;break}case 101:{if((s[e+-2>>1]|0)==117)e=$(e+-4|0,122,6)|0;else e=0;break}default:e=0}return e|0}function B(e,a){e=e|0;a=a|0;var r=0;r=f[3]|0;if(r>>>0<=e>>>0?(s[e>>1]|0)==a<<16>>16:0)if((r|0)==(e|0))r=1;else r=E(s[e+-2>>1]|0)|0;else r=0;return r|0}function E(e){e=e|0;e:do{if((e+-9&65535)<5)e=1;else{switch(e<<16>>16){case 32:case 160:{e=1;break e}default:{}}e=e<<16>>16!=46&(I(e)|0)}}while(0);return e|0}function P(){var e=0,a=0,r=0;e=f[73]|0;r=f[72]|0;e:while(1){a=r+2|0;if(r>>>0>=e>>>0)break;switch(s[a>>1]|0){case 13:case 10:break e;default:r=a}}f[72]=a;return}function q(e){e=e|0;while(1){if(V(e)|0)break;if(I(e)|0)break;e=(f[72]|0)+2|0;f[72]=e;e=s[e>>1]|0;if(!(e<<16>>16)){e=0;break}}return e|0}function z(){var e=0;e=f[(f[61]|0)+20>>2]|0;switch(e|0){case 1:{e=-1;break}case 2:{e=-2;break}default:e=e-(f[3]|0)>>1}return e|0}function D(e){e=e|0;if(!($(e,196,5)|0)?!($(e,44,3)|0):0)e=$(e,206,2)|0;else e=1;return e|0}function F(e){e=e|0;switch(e<<16>>16){case 160:case 32:case 12:case 11:case 9:{e=1;break}default:e=0}return e|0}function G(e){e=e|0;if((s[e>>1]|0)==46?(s[e+-2>>1]|0)==46:0)e=(s[e+-4>>1]|0)==46;else e=0;return e|0}function H(e){e=e|0;if((f[3]|0)==(e|0))e=1;else e=x(e+-2|0)|0;return e|0}function J(){var e=0;e=f[(f[62]|0)+12>>2]|0;if(!e)e=-1;else e=e-(f[3]|0)>>1;return e|0}function K(){var e=0;e=f[(f[61]|0)+12>>2]|0;if(!e)e=-1;else e=e-(f[3]|0)>>1;return e|0}function L(){var e=0;e=f[(f[62]|0)+8>>2]|0;if(!e)e=-1;else e=e-(f[3]|0)>>1;return e|0}function M(){var e=0;e=f[(f[61]|0)+16>>2]|0;if(!e)e=-1;else e=e-(f[3]|0)>>1;return e|0}function N(){var e=0;e=f[(f[61]|0)+4>>2]|0;if(!e)e=-1;else e=e-(f[3]|0)>>1;return e|0}function Q(){var e=0;e=f[61]|0;e=f[((e|0)==0?236:e+32|0)>>2]|0;f[61]=e;return(e|0)!=0|0}function R(){var e=0;e=f[62]|0;e=f[((e|0)==0?240:e+16|0)>>2]|0;f[62]=e;return(e|0)!=0|0}function T(){i[802]=1;f[68]=(f[72]|0)-(f[3]|0)>>1;f[72]=(f[73]|0)+2;return}function V(e){e=e|0;return(e|128)<<16>>16==160|(e+-9&65535)<5|0}function W(e){e=e|0;return e<<16>>16==39|e<<16>>16==34|0}function X(){return(f[(f[61]|0)+8>>2]|0)-(f[3]|0)>>1|0}function Y(){return(f[(f[62]|0)+4>>2]|0)-(f[3]|0)>>1|0}function Z(e){e=e|0;return e<<16>>16==13|e<<16>>16==10|0}function _(){return(f[f[61]>>2]|0)-(f[3]|0)>>1|0}function ee(){return(f[f[62]>>2]|0)-(f[3]|0)>>1|0}function ae(){return t[(f[61]|0)+24>>0]|0|0}function re(e){e=e|0;f[3]=e;return}function ie(){return f[(f[61]|0)+28>>2]|0}function se(){return(i[803]|0)!=0|0}function fe(){return(i[804]|0)!=0|0}function te(){return f[68]|0}function ce(e){e=e|0;n=e+992+15&-16;return 992}return{su:ce,ai:M,e:te,ee:Y,ele:J,els:L,es:ee,f:fe,id:z,ie:N,ip:ae,is:_,it:ie,ms:se,p:b,re:R,ri:Q,sa:S,se:K,ses:re,ss:X}}("undefined"!=typeof self?self:global,{},a),r=e.su(i-(2<<17))}const h=t.length+1;e.ses(r),e.sa(h-1),s(t,new Uint16Array(a,r,h)),e.p()||(n=e.e(),o());const w=[],d=[];for(;e.ri();){const a=e.is(),r=e.ie(),i=e.ai(),s=e.id(),f=e.ss(),c=e.se(),n=e.it();let k;e.ip()&&(k=b(-1===s?a:a+1,t.charCodeAt(-1===s?a-1:a))),w.push({t:n,n:k,s:a,e:r,ss:f,se:c,d:s,a:i})}for(;e.re();){const a=e.es(),r=e.ee(),i=e.els(),s=e.ele(),f=t.charCodeAt(a),c=i>=0?t.charCodeAt(i):-1;d.push({s:a,e:r,ls:i,le:s,n:34===f||39===f?b(a+1,f):t.slice(a,r),ln:i<0?void 0:34===c||39===c?b(i+1,c):t.slice(i,s)})}return[w,d,!!e.f(),!!e.ms()]}function b(e,a){n=e;let r="",i=n;for(;;){n>=t.length&&o();const e=t.charCodeAt(n);if(e===a)break;92===e?(r+=t.slice(i,n),r+=k(),i=n):(8232===e||8233===e||u(e)&&o(),++n)}return r+=t.slice(i,n++),r}function k(){let e=t.charCodeAt(++n);switch(++n,e){case 110:return"\n";case 114:return"\r";case 120:return String.fromCharCode(l(2));case 117:return function(){const e=t.charCodeAt(n);let a;123===e?(++n,a=l(t.indexOf("}",n)-n),++n,a>1114111&&o()):a=l(4);return a<=65535?String.fromCharCode(a):(a-=65536,String.fromCharCode(55296+(a>>10),56320+(1023&a)))}();case 116:return"\t";case 98:return"\b";case 118:return"\v";case 102:return"\f";case 13:10===t.charCodeAt(n)&&++n;case 10:return"";case 56:case 57:o();default:if(e>=48&&e<=55){let a=t.substr(n-1,3).match(/^[0-7]+/)[0],r=parseInt(a,8);return r>255&&(a=a.slice(0,-1),r=parseInt(a,8)),n+=a.length-1,e=t.charCodeAt(n),"0"===a&&56!==e&&57!==e||o(),String.fromCharCode(r)}return u(e)?"":String.fromCharCode(e)}}function l(e){const a=n;let r=0,i=0;for(let a=0;a=97)e=s-97+10;else if(s>=65)e=s-65+10;else{if(!(s>=48&&s<=57))break;e=s-48}if(e>=16)break;i=s,r=16*r+e}else 95!==i&&0!==a||o(),i=s}return 95!==i&&n-a===e||o(),r}function u(e){return 13===e||10===e}function o(){throw Object.assign(Error(`Parse error ${c}:${t.slice(0,n).split("\n").length}:${n-t.lastIndexOf("\n",n-1)}`),{idx:n})} diff --git a/tools/eslint/node_modules/es-module-lexer/dist/lexer.cjs b/tools/eslint/node_modules/es-module-lexer/dist/lexer.cjs deleted file mode 100644 index 178d743dc0ee86..00000000000000 --- a/tools/eslint/node_modules/es-module-lexer/dist/lexer.cjs +++ /dev/null @@ -1 +0,0 @@ -"use strict";var ImportType;exports.init=exports.ImportType=void 0,exports.parse=parse,exports.ImportType=ImportType,function(A){A[A.Static=1]="Static",A[A.Dynamic=2]="Dynamic",A[A.ImportMeta=3]="ImportMeta",A[A.StaticSourcePhase=4]="StaticSourcePhase",A[A.DynamicSourcePhase=5]="DynamicSourcePhase"}(ImportType||(exports.ImportType=ImportType={}));const A=1===new Uint8Array(new Uint16Array([1]).buffer)[0];function parse(E,g="@"){if(!C)return init.then((()=>parse(E)));const I=E.length+1,w=(C.__heap_base.value||C.__heap_base)+4*I-C.memory.buffer.byteLength;w>0&&C.memory.grow(Math.ceil(w/65536));const K=C.sa(I-1);if((A?B:Q)(E,new Uint16Array(C.memory.buffer,K,I)),!C.parse())throw Object.assign(new Error(`Parse error ${g}:${E.slice(0,C.e()).split("\n").length}:${C.e()-E.lastIndexOf("\n",C.e()-1)}`),{idx:C.e()});const o=[],D=[];for(;C.ri();){const A=C.is(),Q=C.ie(),B=C.it(),g=C.ai(),I=C.id(),w=C.ss(),K=C.se();let D;C.ip()&&(D=k(E.slice(-1===I?A-1:A,-1===I?Q+1:Q))),o.push({n:D,t:B,s:A,e:Q,ss:w,se:K,d:I,a:g})}for(;C.re();){const A=C.es(),Q=C.ee(),B=C.els(),g=C.ele(),I=E.slice(A,Q),w=I[0],K=B<0?void 0:E.slice(B,g),o=K?K[0]:"";D.push({s:A,e:Q,ls:B,le:g,n:'"'===w||"'"===w?k(I):I,ln:'"'===o||"'"===o?k(K):K})}function k(A){try{return(0,eval)(A)}catch(A){}}return[o,D,!!C.f(),!!C.ms()]}function Q(A,Q){const B=A.length;let C=0;for(;C>>8}}function B(A,Q){const B=A.length;let C=0;for(;CA.charCodeAt(0))))).then(WebAssembly.instantiate).then((({exports:A})=>{C=A}));var E;exports.init=init; \ No newline at end of file diff --git a/tools/eslint/node_modules/es-module-lexer/dist/lexer.js b/tools/eslint/node_modules/es-module-lexer/dist/lexer.js deleted file mode 100644 index 030e14e2bf4f39..00000000000000 --- a/tools/eslint/node_modules/es-module-lexer/dist/lexer.js +++ /dev/null @@ -1,2 +0,0 @@ -/* es-module-lexer 1.5.4 */ -export var ImportType;!function(A){A[A.Static=1]="Static",A[A.Dynamic=2]="Dynamic",A[A.ImportMeta=3]="ImportMeta",A[A.StaticSourcePhase=4]="StaticSourcePhase",A[A.DynamicSourcePhase=5]="DynamicSourcePhase"}(ImportType||(ImportType={}));const A=1===new Uint8Array(new Uint16Array([1]).buffer)[0];export function parse(E,g="@"){if(!C)return init.then((()=>parse(E)));const I=E.length+1,w=(C.__heap_base.value||C.__heap_base)+4*I-C.memory.buffer.byteLength;w>0&&C.memory.grow(Math.ceil(w/65536));const K=C.sa(I-1);if((A?B:Q)(E,new Uint16Array(C.memory.buffer,K,I)),!C.parse())throw Object.assign(new Error(`Parse error ${g}:${E.slice(0,C.e()).split("\n").length}:${C.e()-E.lastIndexOf("\n",C.e()-1)}`),{idx:C.e()});const D=[],o=[];for(;C.ri();){const A=C.is(),Q=C.ie(),B=C.it(),g=C.ai(),I=C.id(),w=C.ss(),K=C.se();let o;C.ip()&&(o=k(E.slice(-1===I?A-1:A,-1===I?Q+1:Q))),D.push({n:o,t:B,s:A,e:Q,ss:w,se:K,d:I,a:g})}for(;C.re();){const A=C.es(),Q=C.ee(),B=C.els(),g=C.ele(),I=E.slice(A,Q),w=I[0],K=B<0?void 0:E.slice(B,g),D=K?K[0]:"";o.push({s:A,e:Q,ls:B,le:g,n:'"'===w||"'"===w?k(I):I,ln:'"'===D||"'"===D?k(K):K})}function k(A){try{return(0,eval)(A)}catch(A){}}return[D,o,!!C.f(),!!C.ms()]}function Q(A,Q){const B=A.length;let C=0;for(;C>>8}}function B(A,Q){const B=A.length;let C=0;for(;CA.charCodeAt(0))))).then(WebAssembly.instantiate).then((({exports:A})=>{C=A}));var E; \ No newline at end of file diff --git a/tools/eslint/node_modules/es-module-lexer/lexer.js b/tools/eslint/node_modules/es-module-lexer/lexer.js deleted file mode 100644 index 587fafe06e18c9..00000000000000 --- a/tools/eslint/node_modules/es-module-lexer/lexer.js +++ /dev/null @@ -1,925 +0,0 @@ -let source, pos, end, - openTokenDepth, - lastTokenPos, - openTokenPosStack, - openClassPosStack, - curDynamicImport, - templateStackDepth, - facade, - lastSlashWasDivision, - nextBraceIsClass, - templateDepth, - templateStack, - imports, - exports, - name; - -function addImport (ss, s, e, d) { - const impt = { ss, se: d === -2 ? e : d === -1 ? e + 1 : 0, s, e, d, a: -1, n: undefined }; - imports.push(impt); - return impt; -} - -function addExport (s, e, ls, le) { - exports.push({ - s, - e, - ls, - le, - n: s[0] === '"' ? readString(s, '"') : s[0] === "'" ? readString(s, "'") : source.slice(s, e), - ln: ls[0] === '"' ? readString(ls, '"') : ls[0] === "'" ? readString(ls, "'") : source.slice(ls, le) - }); -} - -function readName (impt) { - let { d, s } = impt; - if (d !== -1) - s++; - impt.n = readString(s, source.charCodeAt(s - 1)); -} - -// Note: parsing is based on the _assumption_ that the source is already valid -export function parse (_source, _name) { - openTokenDepth = 0; - curDynamicImport = null; - templateDepth = -1; - lastTokenPos = -1; - lastSlashWasDivision = false; - templateStack = Array(1024); - templateStackDepth = 0; - openTokenPosStack = Array(1024); - openClassPosStack = Array(1024); - nextBraceIsClass = false; - facade = true; - name = _name || '@'; - - imports = []; - exports = []; - - source = _source; - pos = -1; - end = source.length - 1; - let ch = 0; - - // start with a pure "module-only" parser - m: while (pos++ < end) { - ch = source.charCodeAt(pos); - - if (ch === 32 || ch < 14 && ch > 8) - continue; - - switch (ch) { - case 101/*e*/: - if (openTokenDepth === 0 && keywordStart(pos) && source.startsWith('xport', pos + 1)) { - tryParseExportStatement(); - // export might have been a non-pure declaration - if (!facade) { - lastTokenPos = pos; - break m; - } - } - break; - case 105/*i*/: - if (keywordStart(pos) && source.startsWith('mport', pos + 1)) - tryParseImportStatement(); - break; - case 59/*;*/: - break; - case 47/*/*/: { - const next_ch = source.charCodeAt(pos + 1); - if (next_ch === 47/*/*/) { - lineComment(); - // dont update lastToken - continue; - } - else if (next_ch === 42/***/) { - blockComment(true); - // dont update lastToken - continue; - } - // fallthrough - } - default: - // as soon as we hit a non-module token, we go to main parser - facade = false; - pos--; - break m; - } - lastTokenPos = pos; - } - - while (pos++ < end) { - ch = source.charCodeAt(pos); - - if (ch === 32 || ch < 14 && ch > 8) - continue; - - switch (ch) { - case 101/*e*/: - if (openTokenDepth === 0 && keywordStart(pos) && source.startsWith('xport', pos + 1)) - tryParseExportStatement(); - break; - case 105/*i*/: - if (keywordStart(pos) && source.startsWith('mport', pos + 1)) - tryParseImportStatement(); - break; - case 99/*c*/: - if (keywordStart(pos) && source.startsWith('lass', pos + 1) && isBrOrWs(source.charCodeAt(pos + 5))) - nextBraceIsClass = true; - break; - case 40/*(*/: - openTokenPosStack[openTokenDepth++] = lastTokenPos; - break; - case 41/*)*/: - if (openTokenDepth === 0) - syntaxError(); - openTokenDepth--; - if (curDynamicImport && curDynamicImport.d === openTokenPosStack[openTokenDepth]) { - if (curDynamicImport.e === 0) - curDynamicImport.e = pos; - curDynamicImport.se = pos; - curDynamicImport = null; - } - break; - case 123/*{*/: - // dynamic import followed by { is not a dynamic import (so remove) - // this is a sneaky way to get around { import () {} } v { import () } - // block / object ambiguity without a parser (assuming source is valid) - if (source.charCodeAt(lastTokenPos) === 41/*)*/ && imports.length && imports[imports.length - 1].e === lastTokenPos) { - imports.pop(); - } - openClassPosStack[openTokenDepth] = nextBraceIsClass; - nextBraceIsClass = false; - openTokenPosStack[openTokenDepth++] = lastTokenPos; - break; - case 125/*}*/: - if (openTokenDepth === 0) - syntaxError(); - if (openTokenDepth-- === templateDepth) { - templateDepth = templateStack[--templateStackDepth]; - templateString(); - } - else { - if (templateDepth !== -1 && openTokenDepth < templateDepth) - syntaxError(); - } - break; - case 39/*'*/: - case 34/*"*/: - stringLiteral(ch); - break; - case 47/*/*/: { - const next_ch = source.charCodeAt(pos + 1); - if (next_ch === 47/*/*/) { - lineComment(); - // dont update lastToken - continue; - } - else if (next_ch === 42/***/) { - blockComment(true); - // dont update lastToken - continue; - } - else { - // Division / regex ambiguity handling based on checking backtrack analysis of: - // - what token came previously (lastToken) - // - if a closing brace or paren, what token came before the corresponding - // opening brace or paren (lastOpenTokenIndex) - const lastToken = source.charCodeAt(lastTokenPos); - const lastExport = exports[exports.length - 1]; - if (isExpressionPunctuator(lastToken) && - !(lastToken === 46/*.*/ && (source.charCodeAt(lastTokenPos - 1) >= 48/*0*/ && source.charCodeAt(lastTokenPos - 1) <= 57/*9*/)) && - !(lastToken === 43/*+*/ && source.charCodeAt(lastTokenPos - 1) === 43/*+*/) && !(lastToken === 45/*-*/ && source.charCodeAt(lastTokenPos - 1) === 45/*-*/) || - lastToken === 41/*)*/ && isParenKeyword(openTokenPosStack[openTokenDepth]) || - lastToken === 125/*}*/ && (isExpressionTerminator(openTokenPosStack[openTokenDepth]) || openClassPosStack[openTokenDepth]) || - lastToken === 47/*/*/ && lastSlashWasDivision || - isExpressionKeyword(lastTokenPos) || - !lastToken) { - regularExpression(); - lastSlashWasDivision = false; - } - else if (lastExport && lastTokenPos >= lastExport.s && lastTokenPos <= lastExport.e) { - // export default /some-regexp/ - regularExpression(); - lastSlashWasDivision = false; - } - else { - lastSlashWasDivision = true; - } - } - break; - } - case 96/*`*/: - templateString(); - break; - } - lastTokenPos = pos; - } - - if (templateDepth !== -1 || openTokenDepth) - syntaxError(); - - return [imports, exports, facade]; -} - -function tryParseImportStatement () { - const startPos = pos; - - pos += 6; - - let ch = commentWhitespace(true); - - switch (ch) { - // dynamic import - case 40/*(*/: - openTokenPosStack[openTokenDepth++] = startPos; - if (source.charCodeAt(lastTokenPos) === 46/*.*/) - return; - // dynamic import indicated by positive d - const impt = addImport(startPos, pos + 1, 0, startPos); - curDynamicImport = impt; - // try parse a string, to record a safe dynamic import string - pos++; - ch = commentWhitespace(true); - if (ch === 39/*'*/ || ch === 34/*"*/) { - stringLiteral(ch); - } - else { - pos--; - return; - } - pos++; - ch = commentWhitespace(true); - if (ch === 44/*,*/) { - impt.e = pos; - pos++; - ch = commentWhitespace(true); - impt.a = pos; - readName(impt); - pos--; - } - else if (ch === 41/*)*/) { - openTokenDepth--; - impt.e = pos; - impt.se = pos; - readName(impt); - } - else { - pos--; - } - return; - // import.meta - case 46/*.*/: - pos++; - ch = commentWhitespace(true); - // import.meta indicated by d === -2 - if (ch === 109/*m*/ && source.startsWith('eta', pos + 1) && source.charCodeAt(lastTokenPos) !== 46/*.*/) - addImport(startPos, startPos, pos + 4, -2); - return; - - default: - // no space after "import" -> not an import keyword - if (pos === startPos + 6) - break; - case 34/*"*/: - case 39/*'*/: - case 123/*{*/: - case 42/***/: - // import statement only permitted at base-level - if (openTokenDepth !== 0) { - pos--; - return; - } - while (pos < end) { - ch = source.charCodeAt(pos); - if (ch === 39/*'*/ || ch === 34/*"*/) { - readImportString(startPos, ch); - return; - } - pos++; - } - syntaxError(); - } -} - -function tryParseExportStatement () { - const sStartPos = pos; - const prevExport = exports.length; - - pos += 6; - - const curPos = pos; - - let ch = commentWhitespace(true); - - if (pos === curPos && !isPunctuator(ch)) - return; - - switch (ch) { - // export default ... - case 100/*d*/: - addExport(pos, pos + 7, -1, -1); - return; - - // export async? function*? name () { - case 97/*a*/: - pos += 5; - commentWhitespace(true); - // fallthrough - case 102/*f*/: - pos += 8; - ch = commentWhitespace(true); - if (ch === 42/***/) { - pos++; - ch = commentWhitespace(true); - } - const startPos = pos; - ch = readToWsOrPunctuator(ch); - addExport(startPos, pos, startPos, pos); - pos--; - return; - - // export class name ... - case 99/*c*/: - if (source.startsWith('lass', pos + 1) && isBrOrWsOrPunctuatorNotDot(source.charCodeAt(pos + 5))) { - pos += 5; - ch = commentWhitespace(true); - const startPos = pos; - ch = readToWsOrPunctuator(ch); - addExport(startPos, pos, startPos, pos); - pos--; - return; - } - pos += 2; - // fallthrough - - // export var/let/const name = ...(, name = ...)+ - case 118/*v*/: - case 109/*l*/: - // destructured initializations not currently supported (skipped for { or [) - // also, lexing names after variable equals is skipped (export var p = function () { ... }, q = 5 skips "q") - pos += 2; - facade = false; - do { - pos++; - ch = commentWhitespace(true); - const startPos = pos; - ch = readToWsOrPunctuator(ch); - // dont yet handle [ { destructurings - if (ch === 123/*{*/ || ch === 91/*[*/) { - pos--; - return; - } - if (pos === startPos) - return; - addExport(startPos, pos, startPos, pos); - ch = commentWhitespace(true); - if (ch === 61/*=*/) { - pos--; - return; - } - } while (ch === 44/*,*/); - pos--; - return; - - - // export {...} - case 123/*{*/: - pos++; - ch = commentWhitespace(true); - while (true) { - const startPos = pos; - readToWsOrPunctuator(ch); - const endPos = pos; - commentWhitespace(true); - ch = readExportAs(startPos, endPos); - // , - if (ch === 44/*,*/) { - pos++; - ch = commentWhitespace(true); - } - if (ch === 125/*}*/) - break; - if (pos === startPos) - return syntaxError(); - if (pos > end) - return syntaxError(); - } - pos++; - ch = commentWhitespace(true); - break; - - // export * - // export * as X - case 42/***/: - pos++; - commentWhitespace(true); - ch = readExportAs(pos, pos); - ch = commentWhitespace(true); - break; - } - - // from ... - if (ch === 102/*f*/ && source.startsWith('rom', pos + 1)) { - pos += 4; - readImportString(sStartPos, commentWhitespace(true)); - - // There were no local names. - for (let i = prevExport; i < exports.length; ++i) { - exports[i].ls = exports[i].le = -1; - exports[i].ln = undefined; - } - } - else { - pos--; - } -} - -/* - * Ported from Acorn - * - * MIT License - - * Copyright (C) 2012-2020 by various contributors (see AUTHORS) - - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -let acornPos; -function readString (start, quote) { - acornPos = start; - let out = '', chunkStart = acornPos; - for (;;) { - if (acornPos >= source.length) syntaxError(); - const ch = source.charCodeAt(acornPos); - if (ch === quote) break; - if (ch === 92) { // '\' - out += source.slice(chunkStart, acornPos); - out += readEscapedChar(); - chunkStart = acornPos; - } - else if (ch === 0x2028 || ch === 0x2029) { - ++acornPos; - } - else { - if (isBr(ch)) syntaxError(); - ++acornPos; - } - } - out += source.slice(chunkStart, acornPos++); - return out; -} - -// Used to read escaped characters - -function readEscapedChar () { - let ch = source.charCodeAt(++acornPos); - ++acornPos; - switch (ch) { - case 110: return '\n'; // 'n' -> '\n' - case 114: return '\r'; // 'r' -> '\r' - case 120: return String.fromCharCode(readHexChar(2)); // 'x' - case 117: return readCodePointToString(); // 'u' - case 116: return '\t'; // 't' -> '\t' - case 98: return '\b'; // 'b' -> '\b' - case 118: return '\u000b'; // 'v' -> '\u000b' - case 102: return '\f'; // 'f' -> '\f' - case 13: if (source.charCodeAt(acornPos) === 10) ++acornPos; // '\r\n' - case 10: // ' \n' - return ''; - case 56: - case 57: - syntaxError(); - default: - if (ch >= 48 && ch <= 55) { - let octalStr = source.substr(acornPos - 1, 3).match(/^[0-7]+/)[0]; - let octal = parseInt(octalStr, 8); - if (octal > 255) { - octalStr = octalStr.slice(0, -1); - octal = parseInt(octalStr, 8); - } - acornPos += octalStr.length - 1; - ch = source.charCodeAt(acornPos); - if (octalStr !== '0' || ch === 56 || ch === 57) - syntaxError(); - return String.fromCharCode(octal); - } - if (isBr(ch)) { - // Unicode new line characters after \ get removed from output in both - // template literals and strings - return ''; - } - return String.fromCharCode(ch); - } -} - -// Used to read character escape sequences ('\x', '\u', '\U'). - -function readHexChar (len) { - const start = acornPos; - let total = 0, lastCode = 0; - for (let i = 0; i < len; ++i, ++acornPos) { - let code = source.charCodeAt(acornPos), val; - - if (code === 95) { - if (lastCode === 95 || i === 0) syntaxError(); - lastCode = code; - continue; - } - - if (code >= 97) val = code - 97 + 10; // a - else if (code >= 65) val = code - 65 + 10; // A - else if (code >= 48 && code <= 57) val = code - 48; // 0-9 - else break; - if (val >= 16) break; - lastCode = code; - total = total * 16 + val; - } - - if (lastCode === 95 || acornPos - start !== len) syntaxError(); - - return total; -} - -// Read a string value, interpreting backslash-escapes. - -function readCodePointToString () { - const ch = source.charCodeAt(acornPos); - let code; - if (ch === 123) { // '{' - ++acornPos; - code = readHexChar(source.indexOf('}', acornPos) - acornPos); - ++acornPos; - if (code > 0x10FFFF) syntaxError(); - } else { - code = readHexChar(4); - } - // UTF-16 Decoding - if (code <= 0xFFFF) return String.fromCharCode(code); - code -= 0x10000; - return String.fromCharCode((code >> 10) + 0xD800, (code & 1023) + 0xDC00); -} - -/* - * - */ - -function readExportAs (startPos, endPos) { - let ch = source.charCodeAt(pos); - let ls = startPos, le = endPos; - if (ch === 97 /*a*/) { - pos += 2; - ch = commentWhitespace(true); - startPos = pos; - readToWsOrPunctuator(ch); - endPos = pos; - ch = commentWhitespace(true); - } - if (pos !== startPos) - addExport(startPos, endPos, ls, le); - return ch; -} - -function readImportString (ss, ch) { - const startPos = pos + 1; - if (ch === 39/*'*/ || ch === 34/*"*/) { - stringLiteral(ch); - } - else { - syntaxError(); - return; - } - const impt = addImport(ss, startPos, pos, -1); - readName(impt); - pos++; - ch = commentWhitespace(false); - if (ch !== 97/*a*/ || !source.startsWith('ssert', pos + 1)) { - pos--; - return; - } - const assertIndex = pos; - - pos += 6; - ch = commentWhitespace(true); - if (ch !== 123/*{*/) { - pos = assertIndex; - return; - } - const assertStart = pos; - do { - pos++; - ch = commentWhitespace(true); - if (ch === 39/*'*/ || ch === 34/*"*/) { - stringLiteral(ch); - pos++; - ch = commentWhitespace(true); - } - else { - ch = readToWsOrPunctuator(ch); - } - if (ch !== 58/*:*/) { - pos = assertIndex; - return; - } - pos++; - ch = commentWhitespace(true); - if (ch === 39/*'*/ || ch === 34/*"*/) { - stringLiteral(ch); - } - else { - pos = assertIndex; - return; - } - pos++; - ch = commentWhitespace(true); - if (ch === 44/*,*/) { - pos++; - ch = commentWhitespace(true); - if (ch === 125/*}*/) - break; - continue; - } - if (ch === 125/*}*/) - break; - pos = assertIndex; - return; - } while (true); - impt.a = assertStart; - impt.se = pos + 1; -} - -function commentWhitespace (br) { - let ch; - do { - ch = source.charCodeAt(pos); - if (ch === 47/*/*/) { - const next_ch = source.charCodeAt(pos + 1); - if (next_ch === 47/*/*/) - lineComment(); - else if (next_ch === 42/***/) - blockComment(br); - else - return ch; - } - else if (br ? !isBrOrWs(ch): !isWsNotBr(ch)) { - return ch; - } - } while (pos++ < end); - return ch; -} - -function templateString () { - while (pos++ < end) { - const ch = source.charCodeAt(pos); - if (ch === 36/*$*/ && source.charCodeAt(pos + 1) === 123/*{*/) { - pos++; - templateStack[templateStackDepth++] = templateDepth; - templateDepth = ++openTokenDepth; - return; - } - if (ch === 96/*`*/) - return; - if (ch === 92/*\*/) - pos++; - } - syntaxError(); -} - -function blockComment (br) { - pos++; - while (pos++ < end) { - const ch = source.charCodeAt(pos); - if (!br && isBr(ch)) - return; - if (ch === 42/***/ && source.charCodeAt(pos + 1) === 47/*/*/) { - pos++; - return; - } - } -} - -function lineComment () { - while (pos++ < end) { - const ch = source.charCodeAt(pos); - if (ch === 10/*\n*/ || ch === 13/*\r*/) - return; - } -} - -function stringLiteral (quote) { - while (pos++ < end) { - let ch = source.charCodeAt(pos); - if (ch === quote) - return; - if (ch === 92/*\*/) { - ch = source.charCodeAt(++pos); - if (ch === 13/*\r*/ && source.charCodeAt(pos + 1) === 10/*\n*/) - pos++; - } - else if (isBr(ch)) - break; - } - syntaxError(); -} - -function regexCharacterClass () { - while (pos++ < end) { - let ch = source.charCodeAt(pos); - if (ch === 93/*]*/) - return ch; - if (ch === 92/*\*/) - pos++; - else if (ch === 10/*\n*/ || ch === 13/*\r*/) - break; - } - syntaxError(); -} - -function regularExpression () { - while (pos++ < end) { - let ch = source.charCodeAt(pos); - if (ch === 47/*/*/) - return; - if (ch === 91/*[*/) - ch = regexCharacterClass(); - else if (ch === 92/*\*/) - pos++; - else if (ch === 10/*\n*/ || ch === 13/*\r*/) - break; - } - syntaxError(); -} - -function readToWsOrPunctuator (ch) { - do { - if (isBrOrWs(ch) || isPunctuator(ch)) - return ch; - } while (ch = source.charCodeAt(++pos)); - return ch; -} - -// Note: non-asii BR and whitespace checks omitted for perf / footprint -// if there is a significant user need this can be reconsidered -function isBr (c) { - return c === 13/*\r*/ || c === 10/*\n*/; -} - -function isWsNotBr (c) { - return c === 9 || c === 11 || c === 12 || c === 32 || c === 160; -} - -function isBrOrWs (c) { - return c > 8 && c < 14 || c === 32 || c === 160; -} - -function isBrOrWsOrPunctuatorNotDot (c) { - return c > 8 && c < 14 || c === 32 || c === 160 || isPunctuator(c) && c !== 46/*.*/; -} - -function keywordStart (pos) { - return pos === 0 || isBrOrWsOrPunctuatorNotDot(source.charCodeAt(pos - 1)); -} - -function readPrecedingKeyword (pos, match) { - if (pos < match.length - 1) - return false; - return source.startsWith(match, pos - match.length + 1) && (pos === 0 || isBrOrWsOrPunctuatorNotDot(source.charCodeAt(pos - match.length))); -} - -function readPrecedingKeyword1 (pos, ch) { - return source.charCodeAt(pos) === ch && (pos === 0 || isBrOrWsOrPunctuatorNotDot(source.charCodeAt(pos - 1))); -} - -// Detects one of case, debugger, delete, do, else, in, instanceof, new, -// return, throw, typeof, void, yield, await -function isExpressionKeyword (pos) { - switch (source.charCodeAt(pos)) { - case 100/*d*/: - switch (source.charCodeAt(pos - 1)) { - case 105/*i*/: - // void - return readPrecedingKeyword(pos - 2, 'vo'); - case 108/*l*/: - // yield - return readPrecedingKeyword(pos - 2, 'yie'); - default: - return false; - } - case 101/*e*/: - switch (source.charCodeAt(pos - 1)) { - case 115/*s*/: - switch (source.charCodeAt(pos - 2)) { - case 108/*l*/: - // else - return readPrecedingKeyword1(pos - 3, 101/*e*/); - case 97/*a*/: - // case - return readPrecedingKeyword1(pos - 3, 99/*c*/); - default: - return false; - } - case 116/*t*/: - // delete - return readPrecedingKeyword(pos - 2, 'dele'); - default: - return false; - } - case 102/*f*/: - if (source.charCodeAt(pos - 1) !== 111/*o*/ || source.charCodeAt(pos - 2) !== 101/*e*/) - return false; - switch (source.charCodeAt(pos - 3)) { - case 99/*c*/: - // instanceof - return readPrecedingKeyword(pos - 4, 'instan'); - case 112/*p*/: - // typeof - return readPrecedingKeyword(pos - 4, 'ty'); - default: - return false; - } - case 110/*n*/: - // in, return - return readPrecedingKeyword1(pos - 1, 105/*i*/) || readPrecedingKeyword(pos - 1, 'retur'); - case 111/*o*/: - // do - return readPrecedingKeyword1(pos - 1, 100/*d*/); - case 114/*r*/: - // debugger - return readPrecedingKeyword(pos - 1, 'debugge'); - case 116/*t*/: - // await - return readPrecedingKeyword(pos - 1, 'awai'); - case 119/*w*/: - switch (source.charCodeAt(pos - 1)) { - case 101/*e*/: - // new - return readPrecedingKeyword1(pos - 2, 110/*n*/); - case 111/*o*/: - // throw - return readPrecedingKeyword(pos - 2, 'thr'); - default: - return false; - } - } - return false; -} - -function isParenKeyword (curPos) { - return source.charCodeAt(curPos) === 101/*e*/ && source.startsWith('whil', curPos - 4) || - source.charCodeAt(curPos) === 114/*r*/ && source.startsWith('fo', curPos - 2) || - source.charCodeAt(curPos - 1) === 105/*i*/ && source.charCodeAt(curPos) === 102/*f*/; -} - -function isPunctuator (ch) { - // 23 possible punctuator endings: !%&()*+,-./:;<=>?[]^{}|~ - return ch === 33/*!*/ || ch === 37/*%*/ || ch === 38/*&*/ || - ch > 39 && ch < 48 || ch > 57 && ch < 64 || - ch === 91/*[*/ || ch === 93/*]*/ || ch === 94/*^*/ || - ch > 122 && ch < 127; -} - -function isExpressionPunctuator (ch) { - // 20 possible expression endings: !%&(*+,-.:;<=>?[^{|~ - return ch === 33/*!*/ || ch === 37/*%*/ || ch === 38/*&*/ || - ch > 39 && ch < 47 && ch !== 41 || ch > 57 && ch < 64 || - ch === 91/*[*/ || ch === 94/*^*/ || ch > 122 && ch < 127 && ch !== 125/*}*/; -} - -function isExpressionTerminator (curPos) { - // detects: - // => ; ) finally catch else - // as all of these followed by a { will indicate a statement brace - switch (source.charCodeAt(curPos)) { - case 62/*>*/: - return source.charCodeAt(curPos - 1) === 61/*=*/; - case 59/*;*/: - case 41/*)*/: - return true; - case 104/*h*/: - return source.startsWith('catc', curPos - 4); - case 121/*y*/: - return source.startsWith('finall', curPos - 6); - case 101/*e*/: - return source.startsWith('els', curPos - 3); - } - return false; -} - -function syntaxError () { - throw Object.assign(new Error(`Parse error ${name}:${source.slice(0, pos).split('\n').length}:${pos - source.lastIndexOf('\n', pos - 1)}`), { idx: pos }); -} \ No newline at end of file diff --git a/tools/eslint/node_modules/es-module-lexer/package.json b/tools/eslint/node_modules/es-module-lexer/package.json deleted file mode 100644 index e5ac6e350d81d1..00000000000000 --- a/tools/eslint/node_modules/es-module-lexer/package.json +++ /dev/null @@ -1,54 +0,0 @@ -{ - "name": "es-module-lexer", - "version": "1.5.4", - "description": "Lexes ES modules returning their import/export metadata", - "main": "dist/lexer.cjs", - "module": "dist/lexer.js", - "types": "types/lexer.d.ts", - "exports": { - ".": { - "types": "./types/lexer.d.ts", - "module": "./dist/lexer.js", - "import": "./dist/lexer.js", - "require": "./dist/lexer.cjs" - }, - "./js": "./dist/lexer.asm.js" - }, - "scripts": { - "build": "npm install -g chomp ; chomp build", - "test": "npm install -g chomp ; chomp test" - }, - "author": "Guy Bedford", - "license": "MIT", - "devDependencies": { - "@babel/cli": "^7.5.5", - "@babel/core": "^7.5.5", - "@babel/plugin-transform-modules-commonjs": "^7.5.0", - "@swc/cli": "^0.1.57", - "@swc/core": "^1.2.224", - "@types/node": "^18.7.1", - "kleur": "^2.0.2", - "mocha": "^5.2.0", - "terser": "^5.19.4", - "typescript": "^4.7.4" - }, - "files": [ - "dist", - "types", - "lexer.js" - ], - "type": "module", - "repository": { - "type": "git", - "url": "git+https://github.com/guybedford/es-module-lexer.git" - }, - "bugs": { - "url": "https://github.com/guybedford/es-module-lexer/issues" - }, - "homepage": "https://github.com/guybedford/es-module-lexer#readme", - "directories": { - "lib": "lib", - "test": "test" - }, - "keywords": [] -} diff --git a/tools/eslint/node_modules/escalade/dist/index.js b/tools/eslint/node_modules/escalade/dist/index.js deleted file mode 100644 index ad236c49205039..00000000000000 --- a/tools/eslint/node_modules/escalade/dist/index.js +++ /dev/null @@ -1,22 +0,0 @@ -const { dirname, resolve } = require('path'); -const { readdir, stat } = require('fs'); -const { promisify } = require('util'); - -const toStats = promisify(stat); -const toRead = promisify(readdir); - -module.exports = async function (start, callback) { - let dir = resolve('.', start); - let tmp, stats = await toStats(dir); - - if (!stats.isDirectory()) { - dir = dirname(dir); - } - - while (true) { - tmp = await callback(dir, await toRead(dir)); - if (tmp) return resolve(dir, tmp); - dir = dirname(tmp = dir); - if (tmp === dir) break; - } -} diff --git a/tools/eslint/node_modules/escalade/dist/index.mjs b/tools/eslint/node_modules/escalade/dist/index.mjs deleted file mode 100644 index bf95be03425c90..00000000000000 --- a/tools/eslint/node_modules/escalade/dist/index.mjs +++ /dev/null @@ -1,22 +0,0 @@ -import { dirname, resolve } from 'path'; -import { readdir, stat } from 'fs'; -import { promisify } from 'util'; - -const toStats = promisify(stat); -const toRead = promisify(readdir); - -export default async function (start, callback) { - let dir = resolve('.', start); - let tmp, stats = await toStats(dir); - - if (!stats.isDirectory()) { - dir = dirname(dir); - } - - while (true) { - tmp = await callback(dir, await toRead(dir)); - if (tmp) return resolve(dir, tmp); - dir = dirname(tmp = dir); - if (tmp === dir) break; - } -} diff --git a/tools/eslint/node_modules/escalade/license b/tools/eslint/node_modules/escalade/license deleted file mode 100644 index fa6089faba3cf3..00000000000000 --- a/tools/eslint/node_modules/escalade/license +++ /dev/null @@ -1,9 +0,0 @@ -MIT License - -Copyright (c) Luke Edwards (lukeed.com) - -Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/tools/eslint/node_modules/escalade/package.json b/tools/eslint/node_modules/escalade/package.json deleted file mode 100644 index e0f52710bcbd36..00000000000000 --- a/tools/eslint/node_modules/escalade/package.json +++ /dev/null @@ -1,63 +0,0 @@ -{ - "name": "escalade", - "version": "3.1.2", - "repository": "lukeed/escalade", - "description": "A tiny (183B to 210B) and fast utility to ascend parent directories", - "module": "dist/index.mjs", - "main": "dist/index.js", - "types": "index.d.ts", - "license": "MIT", - "author": { - "name": "Luke Edwards", - "email": "luke.edwards05@gmail.com", - "url": "https://lukeed.com" - }, - "exports": { - ".": [ - { - "types": "./index.d.ts", - "import": "./dist/index.mjs", - "require": "./dist/index.js" - }, - "./dist/index.js" - ], - "./sync": [ - { - "types": "./sync/index.d.ts", - "import": "./sync/index.mjs", - "require": "./sync/index.js" - }, - "./sync/index.js" - ] - }, - "files": [ - "*.d.ts", - "dist", - "sync" - ], - "modes": { - "sync": "src/sync.js", - "default": "src/async.js" - }, - "engines": { - "node": ">=6" - }, - "scripts": { - "build": "bundt", - "pretest": "npm run build", - "test": "uvu -r esm test -i fixtures" - }, - "keywords": [ - "find", - "parent", - "parents", - "directory", - "search", - "walk" - ], - "devDependencies": { - "bundt": "1.1.1", - "esm": "3.2.25", - "uvu": "0.3.3" - } -} diff --git a/tools/eslint/node_modules/escalade/readme.md b/tools/eslint/node_modules/escalade/readme.md deleted file mode 100644 index e07ee0d387a9e5..00000000000000 --- a/tools/eslint/node_modules/escalade/readme.md +++ /dev/null @@ -1,211 +0,0 @@ -# escalade [![CI](https://github.com/lukeed/escalade/workflows/CI/badge.svg)](https://github.com/lukeed/escalade/actions) [![licenses](https://licenses.dev/b/npm/escalade)](https://licenses.dev/npm/escalade) [![codecov](https://badgen.now.sh/codecov/c/github/lukeed/escalade)](https://codecov.io/gh/lukeed/escalade) - -> A tiny (183B to 210B) and [fast](#benchmarks) utility to ascend parent directories - -With [escalade](https://en.wikipedia.org/wiki/Escalade), you can scale parent directories until you've found what you're looking for.
Given an input file or directory, `escalade` will continue executing your callback function until either: - -1) the callback returns a truthy value -2) `escalade` has reached the system root directory (eg, `/`) - -> **Important:**
Please note that `escalade` only deals with direct ancestry โ€“ it will not dive into parents' sibling directories. - ---- - -**Notice:** As of v3.1.0, `escalade` now includes [Deno support](http://deno.land/x/escalade)! Please see [Deno Usage](#deno) below. - ---- - -## Install - -``` -$ npm install --save escalade -``` - - -## Modes - -There are two "versions" of `escalade` available: - -#### "async" -> **Node.js:** >= 8.x
-> **Size (gzip):** 210 bytes
-> **Availability:** [CommonJS](https://unpkg.com/escalade/dist/index.js), [ES Module](https://unpkg.com/escalade/dist/index.mjs) - -This is the primary/default mode. It makes use of `async`/`await` and [`util.promisify`](https://nodejs.org/api/util.html#util_util_promisify_original). - -#### "sync" -> **Node.js:** >= 6.x
-> **Size (gzip):** 183 bytes
-> **Availability:** [CommonJS](https://unpkg.com/escalade/sync/index.js), [ES Module](https://unpkg.com/escalade/sync/index.mjs) - -This is the opt-in mode, ideal for scenarios where `async` usage cannot be supported. - - -## Usage - -***Example Structure*** - -``` -/Users/lukeed - โ””โ”€โ”€ oss - โ”œโ”€โ”€ license - โ””โ”€โ”€ escalade - โ”œโ”€โ”€ package.json - โ””โ”€โ”€ test - โ””โ”€โ”€ fixtures - โ”œโ”€โ”€ index.js - โ””โ”€โ”€ foobar - โ””โ”€โ”€ demo.js -``` - -***Example Usage*** - -```js -//~> demo.js -import { join } from 'path'; -import escalade from 'escalade'; - -const input = join(__dirname, 'demo.js'); -// or: const input = __dirname; - -const pkg = await escalade(input, (dir, names) => { - console.log('~> dir:', dir); - console.log('~> names:', names); - console.log('---'); - - if (names.includes('package.json')) { - // will be resolved into absolute - return 'package.json'; - } -}); - -//~> dir: /Users/lukeed/oss/escalade/test/fixtures/foobar -//~> names: ['demo.js'] -//--- -//~> dir: /Users/lukeed/oss/escalade/test/fixtures -//~> names: ['index.js', 'foobar'] -//--- -//~> dir: /Users/lukeed/oss/escalade/test -//~> names: ['fixtures'] -//--- -//~> dir: /Users/lukeed/oss/escalade -//~> names: ['package.json', 'test'] -//--- - -console.log(pkg); -//=> /Users/lukeed/oss/escalade/package.json - -// Now search for "missing123.txt" -// (Assume it doesn't exist anywhere!) -const missing = await escalade(input, (dir, names) => { - console.log('~> dir:', dir); - return names.includes('missing123.txt') && 'missing123.txt'; -}); - -//~> dir: /Users/lukeed/oss/escalade/test/fixtures/foobar -//~> dir: /Users/lukeed/oss/escalade/test/fixtures -//~> dir: /Users/lukeed/oss/escalade/test -//~> dir: /Users/lukeed/oss/escalade -//~> dir: /Users/lukeed/oss -//~> dir: /Users/lukeed -//~> dir: /Users -//~> dir: / - -console.log(missing); -//=> undefined -``` - -> **Note:** To run the above example with "sync" mode, import from `escalade/sync` and remove the `await` keyword. - - -## API - -### escalade(input, callback) -Returns: `string|void` or `Promise` - -When your `callback` locates a file, `escalade` will resolve/return with an absolute path.
-If your `callback` was never satisfied, then `escalade` will resolve/return with nothing (undefined). - -> **Important:**
The `sync` and `async` versions share the same API.
The **only** difference is that `sync` is not Promise-based. - -#### input -Type: `string` - -The path from which to start ascending. - -This may be a file or a directory path.
However, when `input` is a file, `escalade` will begin with its parent directory. - -> **Important:** Unless given an absolute path, `input` will be resolved from `process.cwd()` location. - -#### callback -Type: `Function` - -The callback to execute for each ancestry level. It always is given two arguments: - -1) `dir` - an absolute path of the current parent directory -2) `names` - a list (`string[]`) of contents _relative to_ the `dir` parent - -> **Note:** The `names` list can contain names of files _and_ directories. - -When your callback returns a _falsey_ value, then `escalade` will continue with `dir`'s parent directory, re-invoking your callback with new argument values. - -When your callback returns a string, then `escalade` stops iteration immediately.
-If the string is an absolute path, then it's left as is. Otherwise, the string is resolved into an absolute path _from_ the `dir` that housed the satisfying condition. - -> **Important:** Your `callback` can be a `Promise/AsyncFunction` when using the "async" version of `escalade`. - -## Benchmarks - -> Running on Node.js v10.13.0 - -``` -# Load Time - find-up 3.891ms - escalade 0.485ms - escalade/sync 0.309ms - -# Levels: 6 (target = "foo.txt"): - find-up x 24,856 ops/sec ยฑ6.46% (55 runs sampled) - escalade x 73,084 ops/sec ยฑ4.23% (73 runs sampled) - find-up.sync x 3,663 ops/sec ยฑ1.12% (83 runs sampled) - escalade/sync x 9,360 ops/sec ยฑ0.62% (88 runs sampled) - -# Levels: 12 (target = "package.json"): - find-up x 29,300 ops/sec ยฑ10.68% (70 runs sampled) - escalade x 73,685 ops/sec ยฑ 5.66% (66 runs sampled) - find-up.sync x 1,707 ops/sec ยฑ 0.58% (91 runs sampled) - escalade/sync x 4,667 ops/sec ยฑ 0.68% (94 runs sampled) - -# Levels: 18 (target = "missing123.txt"): - find-up x 21,818 ops/sec ยฑ17.37% (14 runs sampled) - escalade x 67,101 ops/sec ยฑ21.60% (20 runs sampled) - find-up.sync x 1,037 ops/sec ยฑ 2.86% (88 runs sampled) - escalade/sync x 1,248 ops/sec ยฑ 0.50% (93 runs sampled) -``` - -## Deno - -As of v3.1.0, `escalade` is available on the Deno registry. - -Please note that the [API](#api) is identical and that there are still [two modes](#modes) from which to choose: - -```ts -// Choose "async" mode -import escalade from 'https://deno.land/escalade/async.ts'; - -// Choose "sync" mode -import escalade from 'https://deno.land/escalade/sync.ts'; -``` - -> **Important:** The `allow-read` permission is required! - - -## Related - -- [premove](https://github.com/lukeed/premove) - A tiny (247B) utility to remove items recursively -- [totalist](https://github.com/lukeed/totalist) - A tiny (195B to 224B) utility to recursively list all (total) files in a directory -- [mk-dirs](https://github.com/lukeed/mk-dirs) - A tiny (420B) utility to make a directory and its parents, recursively - -## License - -MIT ยฉ [Luke Edwards](https://lukeed.com) diff --git a/tools/eslint/node_modules/escalade/sync/index.js b/tools/eslint/node_modules/escalade/sync/index.js deleted file mode 100644 index 902cc46cd9a80b..00000000000000 --- a/tools/eslint/node_modules/escalade/sync/index.js +++ /dev/null @@ -1,18 +0,0 @@ -const { dirname, resolve } = require('path'); -const { readdirSync, statSync } = require('fs'); - -module.exports = function (start, callback) { - let dir = resolve('.', start); - let tmp, stats = statSync(dir); - - if (!stats.isDirectory()) { - dir = dirname(dir); - } - - while (true) { - tmp = callback(dir, readdirSync(dir)); - if (tmp) return resolve(dir, tmp); - dir = dirname(tmp = dir); - if (tmp === dir) break; - } -} diff --git a/tools/eslint/node_modules/escalade/sync/index.mjs b/tools/eslint/node_modules/escalade/sync/index.mjs deleted file mode 100644 index 3cdc5bd1fee047..00000000000000 --- a/tools/eslint/node_modules/escalade/sync/index.mjs +++ /dev/null @@ -1,18 +0,0 @@ -import { dirname, resolve } from 'path'; -import { readdirSync, statSync } from 'fs'; - -export default function (start, callback) { - let dir = resolve('.', start); - let tmp, stats = statSync(dir); - - if (!stats.isDirectory()) { - dir = dirname(dir); - } - - while (true) { - tmp = callback(dir, readdirSync(dir)); - if (tmp) return resolve(dir, tmp); - dir = dirname(tmp = dir); - if (tmp === dir) break; - } -} diff --git a/tools/eslint/node_modules/escape-string-regexp/index.js b/tools/eslint/node_modules/escape-string-regexp/index.js deleted file mode 100644 index 7834bf9b24c481..00000000000000 --- a/tools/eslint/node_modules/escape-string-regexp/index.js +++ /dev/null @@ -1,11 +0,0 @@ -'use strict'; - -var matchOperatorsRe = /[|\\{}()[\]^$+*?.]/g; - -module.exports = function (str) { - if (typeof str !== 'string') { - throw new TypeError('Expected a string'); - } - - return str.replace(matchOperatorsRe, '\\$&'); -}; diff --git a/tools/eslint/node_modules/escape-string-regexp/license b/tools/eslint/node_modules/escape-string-regexp/license deleted file mode 100644 index 654d0bfe943437..00000000000000 --- a/tools/eslint/node_modules/escape-string-regexp/license +++ /dev/null @@ -1,21 +0,0 @@ -The MIT License (MIT) - -Copyright (c) Sindre Sorhus (sindresorhus.com) - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. diff --git a/tools/eslint/node_modules/escape-string-regexp/package.json b/tools/eslint/node_modules/escape-string-regexp/package.json deleted file mode 100644 index f307df34a232c0..00000000000000 --- a/tools/eslint/node_modules/escape-string-regexp/package.json +++ /dev/null @@ -1,41 +0,0 @@ -{ - "name": "escape-string-regexp", - "version": "1.0.5", - "description": "Escape RegExp special characters", - "license": "MIT", - "repository": "sindresorhus/escape-string-regexp", - "author": { - "name": "Sindre Sorhus", - "email": "sindresorhus@gmail.com", - "url": "sindresorhus.com" - }, - "maintainers": [ - "Sindre Sorhus (sindresorhus.com)", - "Joshua Boy Nicolai Appelman (jbna.nl)" - ], - "engines": { - "node": ">=0.8.0" - }, - "scripts": { - "test": "xo && ava" - }, - "files": [ - "index.js" - ], - "keywords": [ - "escape", - "regex", - "regexp", - "re", - "regular", - "expression", - "string", - "str", - "special", - "characters" - ], - "devDependencies": { - "ava": "*", - "xo": "*" - } -} diff --git a/tools/eslint/node_modules/escape-string-regexp/readme.md b/tools/eslint/node_modules/escape-string-regexp/readme.md deleted file mode 100644 index 87ac82d5ef8bc9..00000000000000 --- a/tools/eslint/node_modules/escape-string-regexp/readme.md +++ /dev/null @@ -1,27 +0,0 @@ -# escape-string-regexp [![Build Status](https://travis-ci.org/sindresorhus/escape-string-regexp.svg?branch=master)](https://travis-ci.org/sindresorhus/escape-string-regexp) - -> Escape RegExp special characters - - -## Install - -``` -$ npm install --save escape-string-regexp -``` - - -## Usage - -```js -const escapeStringRegexp = require('escape-string-regexp'); - -const escapedString = escapeStringRegexp('how much $ for a unicorn?'); -//=> 'how much \$ for a unicorn\?' - -new RegExp(escapedString); -``` - - -## License - -MIT ยฉ [Sindre Sorhus](http://sindresorhus.com) diff --git a/tools/eslint/node_modules/eslint-formatter-tap/index.js b/tools/eslint/node_modules/eslint-formatter-tap/index.js deleted file mode 100644 index 7ef4f7fca0656c..00000000000000 --- a/tools/eslint/node_modules/eslint-formatter-tap/index.js +++ /dev/null @@ -1,160 +0,0 @@ -/******/ (() => { // webpackBootstrap -/******/ "use strict"; -/******/ var __webpack_modules__ = ({ - -/***/ 20: -/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { - -/** - * @fileoverview TAP reporter - * @author Jonathan Kingston - */ - - -const yaml = __nccwpck_require__(917); - -//------------------------------------------------------------------------------ -// Helper Functions -//------------------------------------------------------------------------------ - -/** - * Returns a canonical error level string based upon the error message passed in. - * @param {Object} message Individual error message provided by eslint - * @returns {string} Error level string - */ -function getMessageType(message) { - if (message.fatal || message.severity === 2) { - return "error"; - } - return "warning"; -} - -/** - * Takes in a JavaScript object and outputs a TAP diagnostics string - * @param {Object} diagnostic JavaScript object to be embedded as YAML into output. - * @returns {string} diagnostics string with YAML embedded - TAP version 13 compliant - */ -function outputDiagnostics(diagnostic) { - const prefix = " "; - let output = `${prefix}---\n`; - - output += prefix + yaml.dump(diagnostic).split("\n").join(`\n${prefix}`); - output += "...\n"; - return output; -} - -//------------------------------------------------------------------------------ -// Public Interface -//------------------------------------------------------------------------------ - -module.exports = function(results) { - let output = `TAP version 13\n1..${results.length}\n`; - - results.forEach((result, id) => { - const messages = result.messages; - let testResult = "ok"; - let diagnostics = {}; - - if (messages.length > 0) { - messages.forEach(message => { - const severity = getMessageType(message); - const diagnostic = { - message: message.message, - severity, - data: { - line: message.line || 0, - column: message.column || 0, - ruleId: message.ruleId || "" - } - }; - - // This ensures a warning message is not flagged as error - if (severity === "error") { - testResult = "not ok"; - } - - /* - * If we have multiple messages place them under a messages key - * The first error will be logged as message key - * This is to adhere to TAP 13 loosely defined specification of having a message key - */ - if ("message" in diagnostics) { - if (typeof diagnostics.messages === "undefined") { - diagnostics.messages = []; - } - diagnostics.messages.push(diagnostic); - } else { - diagnostics = diagnostic; - } - }); - } - - output += `${testResult} ${id + 1} - ${result.filePath}\n`; - - // If we have an error include diagnostics - if (messages.length > 0) { - output += outputDiagnostics(diagnostics); - } - - }); - - return output; -}; - - -/***/ }), - -/***/ 917: -/***/ ((module) => { - -module.exports = require("js-yaml"); - -/***/ }) - -/******/ }); -/************************************************************************/ -/******/ // The module cache -/******/ var __webpack_module_cache__ = {}; -/******/ -/******/ // The require function -/******/ function __nccwpck_require__(moduleId) { -/******/ // Check if module is in cache -/******/ var cachedModule = __webpack_module_cache__[moduleId]; -/******/ if (cachedModule !== undefined) { -/******/ return cachedModule.exports; -/******/ } -/******/ // Create a new module (and put it into the cache) -/******/ var module = __webpack_module_cache__[moduleId] = { -/******/ // no module.id needed -/******/ // no module.loaded needed -/******/ exports: {} -/******/ }; -/******/ -/******/ // Execute the module function -/******/ var threw = true; -/******/ try { -/******/ __webpack_modules__[moduleId](module, module.exports, __nccwpck_require__); -/******/ threw = false; -/******/ } finally { -/******/ if(threw) delete __webpack_module_cache__[moduleId]; -/******/ } -/******/ -/******/ // Return the exports of the module -/******/ return module.exports; -/******/ } -/******/ -/************************************************************************/ -/******/ /* webpack/runtime/compat */ -/******/ -/******/ if (typeof __nccwpck_require__ !== 'undefined') __nccwpck_require__.ab = __dirname + "/"; -/******/ -/************************************************************************/ -/******/ -/******/ // startup -/******/ // Load entry module and return exports -/******/ // This entry module is referenced by other modules so it can't be inlined -/******/ var __webpack_exports__ = __nccwpck_require__(20); -/******/ module.exports = __webpack_exports__; -/******/ -/******/ })() -; \ No newline at end of file diff --git a/tools/eslint/node_modules/eslint-formatter-tap/license b/tools/eslint/node_modules/eslint-formatter-tap/license deleted file mode 100644 index 605e0134cce34b..00000000000000 --- a/tools/eslint/node_modules/eslint-formatter-tap/license +++ /dev/null @@ -1,21 +0,0 @@ -eslint -MIT -Copyright OpenJS Foundation and other contributors, - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. diff --git a/tools/eslint/node_modules/eslint-formatter-tap/package.json b/tools/eslint/node_modules/eslint-formatter-tap/package.json deleted file mode 100644 index dd93e792fed943..00000000000000 --- a/tools/eslint/node_modules/eslint-formatter-tap/package.json +++ /dev/null @@ -1,24 +0,0 @@ -{ - "name": "eslint-formatter-tap", - "version": "8.40.0", - "description": "ESLintโ€™s official `tap` formatter, unofficially published as a standalone module", - "keywords": [ - "lint", - "javascript", - "ecmascript" - ], - "homepage": "https://github.com/fregante/eslint-formatters/tree/main/packages/eslint-formatter-tap", - "repository": "fregante/eslint-formatters", - "license": "MIT", - "author": "Nicholas C. Zakas ", - "dependencies": { - "js-yaml": "^4.1.0" - }, - "engines": { - "node": "^12.22.0 || ^14.17.0 || >=16.0.0" - }, - "files": [ - "index.js", - "index.d.ts" - ] -} diff --git a/tools/eslint/node_modules/eslint-formatter-tap/readme.md b/tools/eslint/node_modules/eslint-formatter-tap/readme.md deleted file mode 100644 index dee0c12361bc8c..00000000000000 --- a/tools/eslint/node_modules/eslint-formatter-tap/readme.md +++ /dev/null @@ -1,16 +0,0 @@ -# eslint-formatter-tap - -> ESLintโ€™s official `tap` formatter, unofficially published as a standalone module - -This package has been extracted from [ESLintโ€™s repository](https://github.com/eslint/eslint/tree/master/lib/cli-engine/formatters) by [@fregante](https://github.com/fregante) so you can use it independently of ESLint. - -**Important:** If you're using ESLint, you do not need this package, the formatter is built into ESLint. - -## Links - -- [Formatter output example](https://eslint.org/docs/user-guide/formatters/#tap) -- [The original formatterโ€™s source](https://github.com/eslint/eslint/tree/master/lib/cli-engine/formatters/tap.js) -- [npm package contents](https://www.unpkg.com/browse/eslint-formatter-tap/) -- [Repository of the publisher tool](https://github.com/fregante/eslint-formatters) - -**Note for ESLintโ€™s maintainers:** Open an issue or ping me on Twitter [@fregante](https://twitter.com/fregante) if you'd like to publish these packages yourself as part of a monorepo. I'll gladly pass the npm names to you. Much ๐Ÿ’š diff --git a/tools/eslint/node_modules/eslint-plugin-jsdoc/LICENSE b/tools/eslint/node_modules/eslint-plugin-jsdoc/LICENSE deleted file mode 100644 index 6c41d45cd765c2..00000000000000 --- a/tools/eslint/node_modules/eslint-plugin-jsdoc/LICENSE +++ /dev/null @@ -1,24 +0,0 @@ -Copyright (c) 2018, Gajus Kuizinas (http://gajus.com/) -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: - * Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - * Neither the name of the Gajus Kuizinas (http://gajus.com/) nor the - names of its contributors may be used to endorse or promote products - derived from this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL ANUARY BE LIABLE FOR ANY -DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/tools/eslint/node_modules/eslint-plugin-jsdoc/dist/WarnSettings.cjs b/tools/eslint/node_modules/eslint-plugin-jsdoc/dist/WarnSettings.cjs deleted file mode 100644 index 8a8dd5b398e5e9..00000000000000 --- a/tools/eslint/node_modules/eslint-plugin-jsdoc/dist/WarnSettings.cjs +++ /dev/null @@ -1,38 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.default = void 0; -const WarnSettings = function () { - /** @type {WeakMap>} */ - const warnedSettings = new WeakMap(); - return { - /** - * Warn only once for each context and setting - * @param {import('eslint').Rule.RuleContext} context - * @param {string} setting - * @returns {boolean} - */ - hasBeenWarned(context, setting) { - return warnedSettings.has(context) && /** @type {Set} */warnedSettings.get(context).has(setting); - }, - /** - * @param {import('eslint').Rule.RuleContext} context - * @param {string} setting - * @returns {void} - */ - markSettingAsWarned(context, setting) { - // c8 ignore else - if (!warnedSettings.has(context)) { - warnedSettings.set(context, new Set()); - } - - /** @type {Set} */ - warnedSettings.get(context).add(setting); - } - }; -}; -var _default = exports.default = WarnSettings; -module.exports = exports.default; -//# sourceMappingURL=WarnSettings.cjs.map \ No newline at end of file diff --git a/tools/eslint/node_modules/eslint-plugin-jsdoc/dist/alignTransform.cjs b/tools/eslint/node_modules/eslint-plugin-jsdoc/dist/alignTransform.cjs deleted file mode 100644 index b5b7a937bfb5aa..00000000000000 --- a/tools/eslint/node_modules/eslint-plugin-jsdoc/dist/alignTransform.cjs +++ /dev/null @@ -1,323 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.default = void 0; -var _commentParser = require("comment-parser"); -/** - * Transform based on https://github.com/syavorsky/comment-parser/blob/master/src/transforms/align.ts - * - * It contains some customizations to align based on the tags, and some custom options. - */ - -/** - * @typedef {{ - * hasNoTypes: boolean, - * maxNamedTagLength: import('./iterateJsdoc.js').Integer, - * maxUnnamedTagLength: import('./iterateJsdoc.js').Integer - * }} TypelessInfo - */ - -const { - rewireSource -} = _commentParser.util; - -/** - * @typedef {{ - * name: import('./iterateJsdoc.js').Integer, - * start: import('./iterateJsdoc.js').Integer, - * tag: import('./iterateJsdoc.js').Integer, - * type: import('./iterateJsdoc.js').Integer - * }} Width - */ - -/** @type {Width} */ -const zeroWidth = { - name: 0, - start: 0, - tag: 0, - type: 0 -}; - -/** - * @param {string[]} tags - * @param {import('./iterateJsdoc.js').Integer} index - * @param {import('comment-parser').Line[]} source - * @returns {boolean} - */ -const shouldAlign = (tags, index, source) => { - const tag = source[index].tokens.tag.replace('@', ''); - const includesTag = tags.includes(tag); - if (includesTag) { - return true; - } - if (tag !== '') { - return false; - } - for (let iterator = index; iterator >= 0; iterator--) { - const previousTag = source[iterator].tokens.tag.replace('@', ''); - if (previousTag !== '') { - if (tags.includes(previousTag)) { - return true; - } - return false; - } - } - return true; -}; - -/** - * @param {string[]} tags - * @returns {( - * width: Width, - * line: { - * tokens: import('comment-parser').Tokens - * }, - * index: import('./iterateJsdoc.js').Integer, - * source: import('comment-parser').Line[] - * ) => Width} - */ -const getWidth = tags => { - return (width, { - tokens - }, index, source) => { - if (!shouldAlign(tags, index, source)) { - return width; - } - return { - name: Math.max(width.name, tokens.name.length), - start: tokens.delimiter === '/**' ? tokens.start.length : width.start, - tag: Math.max(width.tag, tokens.tag.length), - type: Math.max(width.type, tokens.type.length) - }; - }; -}; - -/** - * @param {{ - * description: string; - * tags: import('comment-parser').Spec[]; - * problems: import('comment-parser').Problem[]; - * }} fields - * @returns {TypelessInfo} - */ -const getTypelessInfo = fields => { - const hasNoTypes = fields.tags.every(({ - type - }) => { - return !type; - }); - const maxNamedTagLength = Math.max(...fields.tags.map(({ - tag, - name - }) => { - return name.length === 0 ? -1 : tag.length; - }).filter(length => { - return length !== -1; - })) + 1; - const maxUnnamedTagLength = Math.max(...fields.tags.map(({ - tag, - name - }) => { - return name.length === 0 ? tag.length : -1; - }).filter(length => { - return length !== -1; - })) + 1; - return { - hasNoTypes, - maxNamedTagLength, - maxUnnamedTagLength - }; -}; - -/** - * @param {import('./iterateJsdoc.js').Integer} len - * @returns {string} - */ -const space = len => { - return ''.padStart(len, ' '); -}; - -/** - * @param {{ - * customSpacings: import('../src/rules/checkLineAlignment.js').CustomSpacings, - * tags: string[], - * indent: string, - * preserveMainDescriptionPostDelimiter: boolean, - * wrapIndent: string, - * disableWrapIndent: boolean, - * }} cfg - * @returns {( - * block: import('comment-parser').Block - * ) => import('comment-parser').Block} - */ -const alignTransform = ({ - customSpacings, - tags, - indent, - preserveMainDescriptionPostDelimiter, - wrapIndent, - disableWrapIndent -}) => { - let intoTags = false; - /** @type {Width} */ - let width; - - /** - * @param {import('comment-parser').Tokens} tokens - * @param {TypelessInfo} typelessInfo - * @returns {import('comment-parser').Tokens} - */ - const alignTokens = (tokens, typelessInfo) => { - const nothingAfter = { - delim: false, - name: false, - tag: false, - type: false - }; - if (tokens.description === '') { - nothingAfter.name = true; - tokens.postName = ''; - if (tokens.name === '') { - nothingAfter.type = true; - tokens.postType = ''; - if (tokens.type === '') { - nothingAfter.tag = true; - tokens.postTag = ''; - - /* c8 ignore next: Never happens because the !intoTags return. But it's here for consistency with the original align transform */ - if (tokens.tag === '') { - nothingAfter.delim = true; - } - } - } - } - let untypedNameAdjustment = 0; - let untypedTypeAdjustment = 0; - if (typelessInfo.hasNoTypes) { - nothingAfter.tag = true; - tokens.postTag = ''; - if (tokens.name === '') { - untypedNameAdjustment = typelessInfo.maxNamedTagLength - tokens.tag.length; - } else { - untypedNameAdjustment = typelessInfo.maxNamedTagLength > typelessInfo.maxUnnamedTagLength ? 0 : Math.max(0, typelessInfo.maxUnnamedTagLength - (tokens.tag.length + tokens.name.length + 1)); - untypedTypeAdjustment = typelessInfo.maxNamedTagLength - tokens.tag.length; - } - } - - // Todo: Avoid fixing alignment of blocks with multiline wrapping of type - if (tokens.tag === '' && tokens.type) { - return tokens; - } - const spacings = { - postDelimiter: (customSpacings === null || customSpacings === void 0 ? void 0 : customSpacings.postDelimiter) || 1, - postName: (customSpacings === null || customSpacings === void 0 ? void 0 : customSpacings.postName) || 1, - postTag: (customSpacings === null || customSpacings === void 0 ? void 0 : customSpacings.postTag) || 1, - postType: (customSpacings === null || customSpacings === void 0 ? void 0 : customSpacings.postType) || 1 - }; - tokens.postDelimiter = nothingAfter.delim ? '' : space(spacings.postDelimiter); - if (!nothingAfter.tag) { - tokens.postTag = space(width.tag - tokens.tag.length + spacings.postTag); - } - if (!nothingAfter.type) { - tokens.postType = space(width.type - tokens.type.length + spacings.postType + untypedTypeAdjustment); - } - if (!nothingAfter.name) { - // If post name is empty for all lines (name width 0), don't add post name spacing. - tokens.postName = width.name === 0 ? '' : space(width.name - tokens.name.length + spacings.postName + untypedNameAdjustment); - } - return tokens; - }; - - /** - * @param {import('comment-parser').Line} line - * @param {import('./iterateJsdoc.js').Integer} index - * @param {import('comment-parser').Line[]} source - * @param {TypelessInfo} typelessInfo - * @param {string|false} indentTag - * @returns {import('comment-parser').Line} - */ - const update = (line, index, source, typelessInfo, indentTag) => { - /** @type {import('comment-parser').Tokens} */ - const tokens = { - ...line.tokens - }; - if (tokens.tag !== '') { - intoTags = true; - } - const isEmpty = tokens.tag === '' && tokens.name === '' && tokens.type === '' && tokens.description === ''; - - // dangling '*/' - if (tokens.end === '*/' && isEmpty) { - tokens.start = indent + ' '; - return { - ...line, - tokens - }; - } - switch (tokens.delimiter) { - case '/**': - tokens.start = indent; - break; - case '*': - tokens.start = indent + ' '; - break; - default: - tokens.delimiter = ''; - - // compensate delimiter - tokens.start = indent + ' '; - } - if (!intoTags) { - if (tokens.description === '') { - tokens.postDelimiter = ''; - } else if (!preserveMainDescriptionPostDelimiter) { - tokens.postDelimiter = ' '; - } - return { - ...line, - tokens - }; - } - const postHyphenSpacing = (customSpacings === null || customSpacings === void 0 ? void 0 : customSpacings.postHyphen) ?? 1; - const hyphenSpacing = /^\s*-\s+/u; - tokens.description = tokens.description.replace(hyphenSpacing, '-' + ''.padStart(postHyphenSpacing, ' ')); - - // Not align. - if (shouldAlign(tags, index, source)) { - alignTokens(tokens, typelessInfo); - if (!disableWrapIndent && indentTag) { - tokens.postDelimiter += wrapIndent; - } - } - return { - ...line, - tokens - }; - }; - return ({ - source, - ...fields - }) => { - width = source.reduce(getWidth(tags), { - ...zeroWidth - }); - const typelessInfo = getTypelessInfo(fields); - let tagIndentMode = false; - return rewireSource({ - ...fields, - source: source.map((line, index) => { - const indentTag = !disableWrapIndent && tagIndentMode && !line.tokens.tag && line.tokens.description; - const ret = update(line, index, source, typelessInfo, indentTag); - if (!disableWrapIndent && line.tokens.tag) { - tagIndentMode = true; - } - return ret; - }) - }); - }; -}; -var _default = exports.default = alignTransform; -module.exports = exports.default; -//# sourceMappingURL=alignTransform.cjs.map \ No newline at end of file diff --git a/tools/eslint/node_modules/eslint-plugin-jsdoc/dist/defaultTagOrder.cjs b/tools/eslint/node_modules/eslint-plugin-jsdoc/dist/defaultTagOrder.cjs deleted file mode 100644 index f458909d3a602d..00000000000000 --- a/tools/eslint/node_modules/eslint-plugin-jsdoc/dist/defaultTagOrder.cjs +++ /dev/null @@ -1,46 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.default = void 0; -const defaultTagOrder = [{ - tags: [ - // Brief descriptions - 'summary', 'typeSummary', - // Module/file-level - 'module', 'exports', 'file', 'fileoverview', 'overview', 'import', - // Identifying (name, type) - 'typedef', 'interface', 'record', 'template', 'name', 'kind', 'type', 'alias', 'external', 'host', 'callback', 'func', 'function', 'method', 'class', 'constructor', - // Relationships - 'modifies', 'mixes', 'mixin', 'mixinClass', 'mixinFunction', 'namespace', 'borrows', 'constructs', 'lends', 'implements', 'requires', - // Long descriptions - 'desc', 'description', 'classdesc', 'tutorial', 'copyright', 'license', - // Simple annotations - - // TypeScript - 'internal', 'overload', 'const', 'constant', 'final', 'global', 'readonly', 'abstract', 'virtual', 'var', 'member', 'memberof', 'memberof!', 'inner', 'instance', 'inheritdoc', 'inheritDoc', 'override', 'hideconstructor', - // Core function/object info - 'param', 'arg', 'argument', 'prop', 'property', 'return', 'returns', - // Important behavior details - 'async', 'generator', 'default', 'defaultvalue', 'enum', 'augments', 'extends', 'throws', 'exception', 'yield', 'yields', 'event', 'fires', 'emits', 'listens', 'this', - // TypeScript - 'satisfies', - // Access - 'static', 'private', 'protected', 'public', 'access', 'package', '-other', - // Supplementary descriptions - 'see', 'example', - // METADATA - - // Other Closure (undocumented) metadata - 'closurePrimitive', 'customElement', 'expose', 'hidden', 'idGenerator', 'meaning', 'ngInject', 'owner', 'wizaction', - // Other Closure (documented) metadata - 'define', 'dict', 'export', 'externs', 'implicitCast', 'noalias', 'nocollapse', 'nocompile', 'noinline', 'nosideeffects', 'polymer', 'polymerBehavior', 'preserve', 'struct', 'suppress', 'unrestricted', - // @homer0/prettier-plugin-jsdoc metadata - 'category', - // Non-Closure metadata - 'ignore', 'author', 'version', 'variation', 'since', 'deprecated', 'todo'] -}]; -var _default = exports.default = defaultTagOrder; -module.exports = exports.default; -//# sourceMappingURL=defaultTagOrder.cjs.map \ No newline at end of file diff --git a/tools/eslint/node_modules/eslint-plugin-jsdoc/dist/exportParser.cjs b/tools/eslint/node_modules/eslint-plugin-jsdoc/dist/exportParser.cjs deleted file mode 100644 index c27ebcd82c9db1..00000000000000 --- a/tools/eslint/node_modules/eslint-plugin-jsdoc/dist/exportParser.cjs +++ /dev/null @@ -1,730 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.default = void 0; -var _jsdoccomment = require("@es-joy/jsdoccomment"); -var _debug = _interopRequireDefault(require("debug")); -function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; } -const debug = (0, _debug.default)('requireExportJsdoc'); - -/** - * @typedef {{ - * value: string - * }} ValueObject - */ - -/** - * @typedef {{ - * type?: string, - * value?: ValueObject|import('eslint').Rule.Node, - * props: { - * [key: string]: CreatedNode|null, - * }, - * special?: true, - * globalVars?: CreatedNode, - * exported?: boolean, - * ANONYMOUS_DEFAULT?: import('eslint').Rule.Node - * }} CreatedNode - */ - -/** - * @returns {CreatedNode} - */ -const createNode = function () { - return { - props: {} - }; -}; - -/** - * @param {CreatedNode|null} symbol - * @returns {string|null} - */ -const getSymbolValue = function (symbol) { - /* c8 ignore next 3 */ - if (!symbol) { - return null; - } - - /* c8 ignore else */ - if (symbol.type === 'literal') { - return /** @type {ValueObject} */symbol.value.value; - } - /* c8 ignore next */ - return null; -}; - -/** - * - * @param {import('estree').Identifier} node - * @param {CreatedNode} globals - * @param {CreatedNode} scope - * @param {SymbolOptions} opts - * @returns {CreatedNode|null} - */ -const getIdentifier = function (node, globals, scope, opts) { - if (opts.simpleIdentifier) { - // Type is Identier for noncomputed properties - const identifierLiteral = createNode(); - identifierLiteral.type = 'literal'; - identifierLiteral.value = { - value: node.name - }; - return identifierLiteral; - } - - /* c8 ignore next */ - const block = scope || globals; - - // As scopes are not currently supported, they are not traversed upwards recursively - if (block.props[node.name]) { - return block.props[node.name]; - } - - // Seems this will only be entered once scopes added and entered - /* c8 ignore next 3 */ - if (globals.props[node.name]) { - return globals.props[node.name]; - } - return null; -}; - -/** - * @callback CreateSymbol - * @param {import('eslint').Rule.Node|null} node - * @param {CreatedNode} globals - * @param {import('eslint').Rule.Node|null} value - * @param {CreatedNode} [scope] - * @param {boolean|SymbolOptions} [isGlobal] - * @returns {CreatedNode|null} - */ - -/** @type {CreateSymbol} */ -let createSymbol; // eslint-disable-line prefer-const - -/* eslint-disable complexity -- Temporary */ - -/** - * @typedef {{ - * simpleIdentifier?: boolean - * }} SymbolOptions - */ - -/** - * - * @param {import('eslint').Rule.Node} node - * @param {CreatedNode} globals - * @param {CreatedNode} scope - * @param {SymbolOptions} [opt] - * @returns {CreatedNode|null} - */ -const getSymbol = function (node, globals, scope, opt) { - /* eslint-enable complexity -- Temporary */ - const opts = opt || {}; - /* c8 ignore next */ - switch (node.type) { - case 'Identifier': - { - return getIdentifier(node, globals, scope, opts); - } - case 'MemberExpression': - { - const obj = getSymbol( /** @type {import('eslint').Rule.Node} */ - node.object, globals, scope, opts); - const propertySymbol = getSymbol( /** @type {import('eslint').Rule.Node} */ - node.property, globals, scope, { - simpleIdentifier: !node.computed - }); - const propertyValue = getSymbolValue(propertySymbol); - - /* c8 ignore else */ - if (obj && propertyValue && obj.props[propertyValue]) { - const block = obj.props[propertyValue]; - return block; - } - /* c8 ignore next 10 */ - /* - if (opts.createMissingProps && propertyValue) { - obj.props[propertyValue] = createNode(); - return obj.props[propertyValue]; - } - */ - debug(`MemberExpression: Missing property ${/** @type {import('estree').PrivateIdentifier} */node.property.name}`); - /* c8 ignore next 2 */ - return null; - } - case 'ClassExpression': - { - return getSymbol( /** @type {import('eslint').Rule.Node} */ - node.body, globals, scope, opts); - } - - /* c8 ignore next 7 -- No longer needed? */ - // @ts-expect-error TS OK - case 'TSTypeAliasDeclaration': - // @ts-expect-error TS OK - // Fallthrough - case 'TSEnumDeclaration': - // @ts-expect-error TS OK - case 'TSInterfaceDeclaration': - case 'ClassDeclaration': - case 'FunctionExpression': - case 'FunctionDeclaration': - case 'ArrowFunctionExpression': - { - const val = createNode(); - val.props.prototype = createNode(); - val.props.prototype.type = 'object'; - val.type = 'object'; - val.value = node; - return val; - } - case 'AssignmentExpression': - { - return createSymbol( /** @type {import('eslint').Rule.Node} */ - node.left, globals, /** @type {import('eslint').Rule.Node} */ - node.right, scope, opts); - } - case 'ClassBody': - { - const val = createNode(); - for (const method of node.body) { - val.props[/** @type {import('estree').Identifier} */( /** @type {import('estree').MethodDefinition} */method.key).name] = createNode(); - /** @type {{[key: string]: CreatedNode}} */ - val.props[/** @type {import('estree').Identifier} */( /** @type {import('estree').MethodDefinition} */method.key).name].type = 'object'; - /** @type {{[key: string]: CreatedNode}} */ - val.props[/** @type {import('estree').Identifier} */( /** @type {import('estree').MethodDefinition} */method.key).name].value = /** @type {import('eslint').Rule.Node} */ - /** @type {import('estree').MethodDefinition} */method.value; - } - val.type = 'object'; - val.value = node.parent; - return val; - } - case 'ObjectExpression': - { - const val = createNode(); - val.type = 'object'; - for (const prop of node.properties) { - if ([ - // typescript-eslint, espree, acorn, etc. - 'SpreadElement', - // @babel/eslint-parser - 'ExperimentalSpreadProperty'].includes(prop.type)) { - continue; - } - const propVal = getSymbol( /** @type {import('eslint').Rule.Node} */ - /** @type {import('estree').Property} */ - prop.value, globals, scope, opts); - /* c8 ignore next 8 */ - if (propVal) { - val.props[/** @type {import('estree').PrivateIdentifier} */ - ( /** @type {import('estree').Property} */prop.key).name] = propVal; - } - } - return val; - } - case 'Literal': - { - const val = createNode(); - val.type = 'literal'; - val.value = node; - return val; - } - } - /* c8 ignore next */ - return null; -}; - -/** - * - * @param {CreatedNode} block - * @param {string} name - * @param {CreatedNode|null} value - * @param {CreatedNode} globals - * @param {boolean|SymbolOptions|undefined} isGlobal - * @returns {void} - */ -const createBlockSymbol = function (block, name, value, globals, isGlobal) { - block.props[name] = value; - if (isGlobal && globals.props.window && globals.props.window.special) { - globals.props.window.props[name] = value; - } -}; -createSymbol = function (node, globals, value, scope, isGlobal) { - const block = scope || globals; - /* c8 ignore next 3 */ - if (!node) { - return null; - } - let symbol; - switch (node.type) { - case 'FunctionDeclaration': - /* c8 ignore next */ - // @ts-expect-error TS OK - // Fall through - case 'TSEnumDeclaration': - case 'TSInterfaceDeclaration': - /* c8 ignore next */ - // @ts-expect-error TS OK - // Fall through - case 'TSTypeAliasDeclaration': - case 'ClassDeclaration': - { - const nde = /** @type {import('estree').ClassDeclaration} */node; - /* c8 ignore else */ - if (nde.id && nde.id.type === 'Identifier') { - return createSymbol( /** @type {import('eslint').Rule.Node} */nde.id, globals, node, globals); - } - /* c8 ignore next 2 */ - break; - } - case 'Identifier': - { - const nde = /** @type {import('estree').Identifier} */node; - if (value) { - const valueSymbol = getSymbol(value, globals, block); - /* c8 ignore else */ - if (valueSymbol) { - createBlockSymbol(block, nde.name, valueSymbol, globals, isGlobal); - return block.props[nde.name]; - } - /* c8 ignore next */ - debug('Identifier: Missing value symbol for %s', nde.name); - } else { - createBlockSymbol(block, nde.name, createNode(), globals, isGlobal); - return block.props[nde.name]; - } - /* c8 ignore next 2 */ - break; - } - case 'MemberExpression': - { - const nde = /** @type {import('estree').MemberExpression} */node; - symbol = getSymbol( /** @type {import('eslint').Rule.Node} */nde.object, globals, block); - const propertySymbol = getSymbol( /** @type {import('eslint').Rule.Node} */nde.property, globals, block, { - simpleIdentifier: !nde.computed - }); - const propertyValue = getSymbolValue(propertySymbol); - if (symbol && propertyValue) { - createBlockSymbol(symbol, propertyValue, getSymbol( /** @type {import('eslint').Rule.Node} */ - value, globals, block), globals, isGlobal); - return symbol.props[propertyValue]; - } - debug('MemberExpression: Missing symbol: %s', /** @type {import('estree').Identifier} */nde.property.name); - break; - } - } - return null; -}; - -/** - * Creates variables from variable definitions - * @param {import('eslint').Rule.Node} node - * @param {CreatedNode} globals - * @param {import('./rules/requireJsdoc.js').RequireJsdocOpts} opts - * @returns {void} - */ -const initVariables = function (node, globals, opts) { - switch (node.type) { - case 'Program': - { - for (const childNode of node.body) { - initVariables( /** @type {import('eslint').Rule.Node} */ - childNode, globals, opts); - } - break; - } - case 'ExpressionStatement': - { - initVariables( /** @type {import('eslint').Rule.Node} */ - node.expression, globals, opts); - break; - } - case 'VariableDeclaration': - { - for (const declaration of node.declarations) { - // let and const - const symbol = createSymbol( /** @type {import('eslint').Rule.Node} */ - declaration.id, globals, null, globals); - if (opts.initWindow && node.kind === 'var' && globals.props.window) { - // If var, also add to window - globals.props.window.props[/** @type {import('estree').Identifier} */ - declaration.id.name] = symbol; - } - } - break; - } - case 'ExportNamedDeclaration': - { - if (node.declaration) { - initVariables( /** @type {import('eslint').Rule.Node} */ - node.declaration, globals, opts); - } - break; - } - } -}; - -/* eslint-disable complexity -- Temporary */ - -/** - * Populates variable maps using AST - * @param {import('eslint').Rule.Node} node - * @param {CreatedNode} globals - * @param {import('./rules/requireJsdoc.js').RequireJsdocOpts} opt - * @param {true} [isExport] - * @returns {boolean} - */ -const mapVariables = function (node, globals, opt, isExport) { - /* eslint-enable complexity -- Temporary */ - /* c8 ignore next */ - const opts = opt || {}; - /* c8 ignore next */ - switch (node.type) { - case 'Program': - { - if (opts.ancestorsOnly) { - return false; - } - for (const childNode of node.body) { - mapVariables( /** @type {import('eslint').Rule.Node} */ - childNode, globals, opts); - } - break; - } - case 'ExpressionStatement': - { - mapVariables( /** @type {import('eslint').Rule.Node} */ - node.expression, globals, opts); - break; - } - case 'AssignmentExpression': - { - createSymbol( /** @type {import('eslint').Rule.Node} */ - node.left, globals, /** @type {import('eslint').Rule.Node} */ - node.right); - break; - } - case 'VariableDeclaration': - { - for (const declaration of node.declarations) { - const isGlobal = Boolean(opts.initWindow && node.kind === 'var' && globals.props.window); - const symbol = createSymbol( /** @type {import('eslint').Rule.Node} */ - declaration.id, globals, /** @type {import('eslint').Rule.Node} */ - declaration.init, globals, isGlobal); - if (symbol && isExport) { - symbol.exported = true; - } - } - break; - } - case 'FunctionDeclaration': - { - /* c8 ignore next 10 */ - if ( /** @type {import('estree').Identifier} */node.id.type === 'Identifier') { - createSymbol( /** @type {import('eslint').Rule.Node} */ - node.id, globals, node, globals, true); - } - break; - } - case 'ExportDefaultDeclaration': - { - const symbol = createSymbol( /** @type {import('eslint').Rule.Node} */ - node.declaration, globals, /** @type {import('eslint').Rule.Node} */ - node.declaration); - if (symbol) { - symbol.exported = true; - /* c8 ignore next 6 */ - } else { - // if (!node.id) { - globals.ANONYMOUS_DEFAULT = /** @type {import('eslint').Rule.Node} */ - node.declaration; - } - break; - } - case 'ExportNamedDeclaration': - { - if (node.declaration) { - if (node.declaration.type === 'VariableDeclaration') { - mapVariables( /** @type {import('eslint').Rule.Node} */ - node.declaration, globals, opts, true); - } else { - const symbol = createSymbol( /** @type {import('eslint').Rule.Node} */ - node.declaration, globals, /** @type {import('eslint').Rule.Node} */ - node.declaration); - /* c8 ignore next 3 */ - if (symbol) { - symbol.exported = true; - } - } - } - for (const specifier of node.specifiers) { - mapVariables( /** @type {import('eslint').Rule.Node} */ - specifier, globals, opts); - } - break; - } - case 'ExportSpecifier': - { - const symbol = getSymbol( /** @type {import('eslint').Rule.Node} */ - node.local, globals, globals); - /* c8 ignore next 3 */ - if (symbol) { - symbol.exported = true; - } - break; - } - case 'ClassDeclaration': - { - createSymbol( /** @type {import('eslint').Rule.Node|null} */node.id, globals, /** @type {import('eslint').Rule.Node} */node.body, globals); - break; - } - default: - { - /* c8 ignore next */ - return false; - } - } - return true; -}; - -/** - * - * @param {import('eslint').Rule.Node} node - * @param {CreatedNode|ValueObject|string|undefined| - * import('eslint').Rule.Node} block - * @param {(CreatedNode|ValueObject|string| - * import('eslint').Rule.Node)[]} [cache] - * @returns {boolean} - */ -const findNode = function (node, block, cache) { - let blockCache = cache || []; - if (!block || blockCache.includes(block)) { - return false; - } - blockCache = blockCache.slice(); - blockCache.push(block); - if (typeof block === 'object' && 'type' in block && (block.type === 'object' || block.type === 'MethodDefinition') && block.value === node) { - return true; - } - if (typeof block !== 'object') { - return false; - } - const props = 'props' in block && block.props || 'body' in block && block.body; - for (const propval of Object.values(props || {})) { - if (Array.isArray(propval)) { - /* c8 ignore next 5 */ - if (propval.some(val => { - return findNode(node, val, blockCache); - })) { - return true; - } - } else if (findNode(node, propval, blockCache)) { - return true; - } - } - return false; -}; -const exportTypes = new Set(['ExportNamedDeclaration', 'ExportDefaultDeclaration']); -const ignorableNestedTypes = new Set(['FunctionDeclaration', 'ArrowFunctionExpression', 'FunctionExpression']); - -/** - * @param {import('eslint').Rule.Node} nde - * @returns {import('eslint').Rule.Node|false} - */ -const getExportAncestor = function (nde) { - let node = nde; - let idx = 0; - const ignorableIfDeep = ignorableNestedTypes.has(nde === null || nde === void 0 ? void 0 : nde.type); - while (node) { - // Ignore functions nested more deeply than say `export default function () {}` - if (idx >= 2 && ignorableIfDeep) { - break; - } - if (exportTypes.has(node.type)) { - return node; - } - node = node.parent; - idx++; - } - return false; -}; -const canBeExportedByAncestorType = new Set(['TSPropertySignature', 'TSMethodSignature', 'ClassProperty', 'PropertyDefinition', 'Method']); -const canExportChildrenType = new Set(['TSInterfaceBody', 'TSInterfaceDeclaration', 'TSTypeLiteral', 'TSTypeAliasDeclaration', 'TSTypeParameterInstantiation', 'TSTypeReference', 'ClassDeclaration', 'ClassBody', 'ClassDefinition', 'ClassExpression', 'Program']); - -/** - * @param {import('eslint').Rule.Node} nde - * @returns {false|import('eslint').Rule.Node} - */ -const isExportByAncestor = function (nde) { - if (!canBeExportedByAncestorType.has(nde.type)) { - return false; - } - let node = nde.parent; - while (node) { - if (exportTypes.has(node.type)) { - return node; - } - if (!canExportChildrenType.has(node.type)) { - return false; - } - node = node.parent; - } - return false; -}; - -/** - * - * @param {CreatedNode} block - * @param {import('eslint').Rule.Node} node - * @param {CreatedNode[]} [cache] Currently unused - * @returns {boolean} - */ -const findExportedNode = function (block, node, cache) { - /* c8 ignore next 3 */ - if (block === null) { - return false; - } - const blockCache = cache || []; - const { - props - } = block; - for (const propval of Object.values(props)) { - const pval = /** @type {CreatedNode} */propval; - blockCache.push(pval); - if (pval.exported && (node === pval.value || findNode(node, pval.value))) { - return true; - } - - // No need to check `propval` for exported nodes as ESM - // exports are only global - } - return false; -}; - -/** - * - * @param {import('eslint').Rule.Node} node - * @param {CreatedNode} globals - * @param {import('./rules/requireJsdoc.js').RequireJsdocOpts} opt - * @returns {boolean} - */ -const isNodeExported = function (node, globals, opt) { - var _globals$props$module; - const moduleExports = (_globals$props$module = globals.props.module) === null || _globals$props$module === void 0 || (_globals$props$module = _globals$props$module.props) === null || _globals$props$module === void 0 ? void 0 : _globals$props$module.exports; - if (opt.initModuleExports && moduleExports && findNode(node, moduleExports)) { - return true; - } - if (opt.initWindow && globals.props.window && findNode(node, globals.props.window)) { - return true; - } - if (opt.esm && findExportedNode(globals, node)) { - return true; - } - return false; -}; - -/** - * - * @param {import('eslint').Rule.Node} node - * @param {CreatedNode} globalVars - * @param {import('./rules/requireJsdoc.js').RequireJsdocOpts} opts - * @returns {boolean} - */ -const parseRecursive = function (node, globalVars, opts) { - // Iterate from top using recursion - stop at first processed node from top - if (node.parent && parseRecursive(node.parent, globalVars, opts)) { - return true; - } - return mapVariables(node, globalVars, opts); -}; - -/** - * - * @param {import('eslint').Rule.Node} ast - * @param {import('eslint').Rule.Node} node - * @param {import('./rules/requireJsdoc.js').RequireJsdocOpts} opt - * @returns {CreatedNode} - */ -const parse = function (ast, node, opt) { - /* c8 ignore next 6 */ - const opts = opt || { - ancestorsOnly: false, - esm: true, - initModuleExports: true, - initWindow: true - }; - const globalVars = createNode(); - if (opts.initModuleExports) { - globalVars.props.module = createNode(); - globalVars.props.module.props.exports = createNode(); - globalVars.props.exports = globalVars.props.module.props.exports; - } - if (opts.initWindow) { - globalVars.props.window = createNode(); - globalVars.props.window.special = true; - } - if (opts.ancestorsOnly) { - parseRecursive(node, globalVars, opts); - } else { - initVariables(ast, globalVars, opts); - mapVariables(ast, globalVars, opts); - } - return { - globalVars, - props: {} - }; -}; -const accessibilityNodes = new Set(['PropertyDefinition', 'MethodDefinition']); - -/** - * - * @param {import('eslint').Rule.Node} node - * @returns {boolean} - */ -const isPrivate = node => { - return accessibilityNodes.has(node.type) && 'accessibility' in node && node.accessibility !== 'public' && node.accessibility !== undefined || 'key' in node && node.key.type === 'PrivateIdentifier'; -}; - -/** - * - * @param {import('eslint').Rule.Node} node - * @param {import('eslint').SourceCode} sourceCode - * @param {import('./rules/requireJsdoc.js').RequireJsdocOpts} opt - * @param {import('./iterateJsdoc.js').Settings} settings - * @returns {boolean} - */ -const isUncommentedExport = function (node, sourceCode, opt, settings) { - // console.log({node}); - // Optimize with ancestor check for esm - if (opt.esm) { - if (isPrivate(node) || node.parent && isPrivate(node.parent)) { - return false; - } - const exportNode = getExportAncestor(node); - - // Is export node comment - if (exportNode && !(0, _jsdoccomment.findJSDocComment)(exportNode, sourceCode, settings)) { - return true; - } - - /** - * Some typescript types are not in variable map, but inherit exported (interface property and method) - */ - if (isExportByAncestor(node) && !(0, _jsdoccomment.findJSDocComment)(node, sourceCode, settings)) { - return true; - } - } - const ast = /** @type {unknown} */sourceCode.ast; - const parseResult = parse( /** @type {import('eslint').Rule.Node} */ - ast, node, opt); - return isNodeExported(node, /** @type {CreatedNode} */parseResult.globalVars, opt); -}; -var _default = exports.default = { - isUncommentedExport, - parse -}; -module.exports = exports.default; -//# sourceMappingURL=exportParser.cjs.map \ No newline at end of file diff --git a/tools/eslint/node_modules/eslint-plugin-jsdoc/dist/generateRule.cjs b/tools/eslint/node_modules/eslint-plugin-jsdoc/dist/generateRule.cjs deleted file mode 100644 index a8e471cf391d31..00000000000000 --- a/tools/eslint/node_modules/eslint-plugin-jsdoc/dist/generateRule.cjs +++ /dev/null @@ -1,247 +0,0 @@ -"use strict"; - -var _url = require("url"); -var _fs = require("fs"); -var _promises = _interopRequireDefault(require("fs/promises")); -var _path = require("path"); -var _camelcase = _interopRequireDefault(require("camelcase")); -var _openEditor = _interopRequireDefault(require("open-editor")); -function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; } -function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); } -function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; } /* eslint-disable no-console -- CLI */ /** - * @example - * - * ```shell - * npm run create-rule my-new-rule -- --recommended - * ``` - */ -const _dirname = (0, _path.dirname)((0, _url.fileURLToPath)(require('url').pathToFileURL(__filename).toString())); - -// Todo: Would ideally have prompts, e.g., to ask for whether -// type was problem/layout, etc. - -const [,, ruleName, ...options] = process.argv; -const recommended = options.includes('--recommended'); -(async () => { - if (!ruleName) { - console.error('Please supply a rule name'); - return; - } - if (/[A-Z]/u.test(ruleName)) { - console.error('Please ensure the rule has no capital letters'); - return; - } - const ruleNamesPath = './test/rules/ruleNames.json'; - // @ts-expect-error Older types? - const ruleNames = JSON.parse(await _promises.default.readFile(ruleNamesPath)); - if (!ruleNames.includes(ruleName)) { - ruleNames.push(ruleName); - ruleNames.sort(); - } - await _promises.default.writeFile(ruleNamesPath, JSON.stringify(ruleNames, null, 2) + '\n'); - console.log('ruleNames', ruleNames); - const ruleTemplate = `import iterateJsdoc from '../iterateJsdoc.js'; - -export default iterateJsdoc(({ - context, - utils, -}) => { - // Rule here -}, { - iterateAllJsdocs: true, - meta: { - docs: { - description: '', - url: 'https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/${ruleName}.md#repos-sticky-header', - }, - schema: [ - { - additionalProperties: false, - properties: { - // Option properties here (or remove the object) - }, - type: 'object', - }, - ], - type: 'suggestion', - }, -}); -`; - const camelCasedRuleName = (0, _camelcase.default)(ruleName); - const rulePath = `./src/rules/${camelCasedRuleName}.js`; - if (!(0, _fs.existsSync)(rulePath)) { - await _promises.default.writeFile(rulePath, ruleTemplate); - } - const ruleTestTemplate = `export default { - invalid: [ - { - code: \` - \`, - errors: [ - { - line: 2, - message: '', - }, - ], - }, - ], - valid: [ - { - code: \` - \`, - }, - ], -}; -`; - const ruleTestPath = `./test/rules/assertions/${camelCasedRuleName}.js`; - if (!(0, _fs.existsSync)(ruleTestPath)) { - await _promises.default.writeFile(ruleTestPath, ruleTestTemplate); - } - const ruleReadmeTemplate = `# \`${ruleName}\` - -||| -|---|---| -|Context|everywhere| -|Tags|\`\`| -|Recommended|${recommended ? 'true' : 'false'}| -|Settings|| -|Options|| - -## Failing examples - - - -## Passing examples - - -`; - const ruleReadmePath = `./.README/rules/${ruleName}.md`; - if (!(0, _fs.existsSync)(ruleReadmePath)) { - await _promises.default.writeFile(ruleReadmePath, ruleReadmeTemplate); - } - - /** - * @param {object} cfg - * @param {string} cfg.path - * @param {RegExp} cfg.oldRegex - * @param {string} cfg.checkName - * @param {string} cfg.newLine - * @param {boolean} [cfg.oldIsCamel] - * @returns {Promise} - */ - const replaceInOrder = async ({ - path, - oldRegex, - checkName, - newLine, - oldIsCamel - }) => { - /** - * @typedef {number} Integer - */ - /** - * @typedef {{ - * matchedLine: string, - * offset: Integer, - * oldRule: string, - * }} OffsetInfo - */ - /** - * @type {OffsetInfo[]} - */ - const offsets = []; - let readme = await _promises.default.readFile(path, 'utf8'); - readme.replace(oldRegex, - /** - * @param {string} matchedLine - * @param {string} n1 - * @param {Integer} offset - * @param {string} str - * @param {object} groups - * @param {string} groups.oldRule - * @returns {string} - */ - (matchedLine, n1, offset, str, { - oldRule - }) => { - offsets.push({ - matchedLine, - offset, - oldRule - }); - return matchedLine; - }); - offsets.sort(({ - oldRule - }, { - oldRule: oldRuleB - }) => { - return oldRule < oldRuleB ? -1 : oldRule > oldRuleB ? 1 : 0; - }); - let alreadyIncluded = false; - const itemIndex = offsets.findIndex(({ - oldRule - }) => { - alreadyIncluded ||= oldIsCamel ? camelCasedRuleName === oldRule : ruleName === oldRule; - return oldIsCamel ? camelCasedRuleName < oldRule : ruleName < oldRule; - }); - let item = itemIndex !== undefined && offsets[itemIndex]; - if (item && itemIndex === 0 && - // This property would not always be sufficient but in this case it is. - oldIsCamel) { - item.offset = 0; - } - if (!item) { - item = /** @type {OffsetInfo} */offsets.pop(); - item.offset += item.matchedLine.length; - } - if (alreadyIncluded) { - console.log(`Rule name is already present in ${checkName}.`); - } else { - readme = readme.slice(0, item.offset) + (item.offset ? '\n' : '') + newLine + (item.offset ? '' : '\n') + readme.slice(item.offset); - await _promises.default.writeFile(path, readme); - } - }; - - // await replaceInOrder({ - // checkName: 'README', - // newLine: `{"gitdown": "include", "file": "./rules/${ruleName}.md"}`, - // oldRegex: /\n\{"gitdown": "include", "file": ".\/rules\/(?[^.]*).md"\}/gu, - // path: './.README/README.md', - // }); - - await replaceInOrder({ - checkName: 'index import', - newLine: `import ${camelCasedRuleName} from './rules/${camelCasedRuleName}.js';`, - oldIsCamel: true, - oldRegex: /\nimport (?[^ ]*) from '.\/rules\/\1\.js';/gu, - path: './src/index.js' - }); - await replaceInOrder({ - checkName: 'index recommended', - newLine: `${' '.repeat(6)}'jsdoc/${ruleName}': ${recommended ? 'warnOrError' : '\'off\''},`, - oldRegex: /\n\s{6}'jsdoc\/(?[^']*)': .*?,/gu, - path: './src/index.js' - }); - await replaceInOrder({ - checkName: 'index rules', - newLine: `${' '.repeat(4)}'${ruleName}': ${camelCasedRuleName},`, - oldRegex: /\n\s{4}'(?[^']*)': [^,]*,/gu, - path: './src/index.js' - }); - await Promise.resolve().then(() => _interopRequireWildcard(require('./generateDocs.js'))); - - /* - console.log('Paths to open for further editing\n'); - console.log(`open ${ruleReadmePath}`); - console.log(`open ${rulePath}`); - console.log(`open ${ruleTestPath}\n`); - */ - - // Set chdir as somehow still in operation from other test - process.chdir((0, _path.resolve)(_dirname, '../../')); - await (0, _openEditor.default)([ - // Could even add editor line column numbers like `${rulePath}:1:1` - ruleReadmePath, ruleTestPath, rulePath]); -})(); -//# sourceMappingURL=generateRule.cjs.map \ No newline at end of file diff --git a/tools/eslint/node_modules/eslint-plugin-jsdoc/dist/getDefaultTagStructureForMode.cjs b/tools/eslint/node_modules/eslint-plugin-jsdoc/dist/getDefaultTagStructureForMode.cjs deleted file mode 100644 index 175d9278399c68..00000000000000 --- a/tools/eslint/node_modules/eslint-plugin-jsdoc/dist/getDefaultTagStructureForMode.cjs +++ /dev/null @@ -1,293 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.default = void 0; -/** - * @typedef {Map>} TagStructure - */ -/** - * @param {import('./jsdocUtils.js').ParserMode} mode - * @returns {TagStructure} - */ -const getDefaultTagStructureForMode = mode => { - const isJsdoc = mode === 'jsdoc'; - const isClosure = mode === 'closure'; - const isTypescript = mode === 'typescript'; - const isPermissive = mode === 'permissive'; - const isJsdocOrPermissive = isJsdoc || isPermissive; - const isJsdocOrTypescript = isJsdoc || isTypescript; - const isTypescriptOrClosure = isTypescript || isClosure; - const isClosureOrPermissive = isClosure || isPermissive; - const isJsdocTypescriptOrPermissive = isJsdocOrTypescript || isPermissive; - - // Properties: - // `namepathRole` - 'namepath-referencing'|'namepath-defining'|'namepath-or-url-referencing'|'text'|false - // `typeAllowed` - boolean - // `nameRequired` - boolean - // `typeRequired` - boolean - // `typeOrNameRequired` - boolean - - // All of `typeAllowed` have a signature with "type" except for - // `augments`/`extends` ("namepath") - // `param`/`arg`/`argument` (no signature) - // `property`/`prop` (no signature) - // `modifies` (undocumented) - - // None of the `namepathRole: 'namepath-defining'` show as having curly - // brackets for their name/namepath - - // Among `namepath-defining` and `namepath-referencing`, these do not seem - // to allow curly brackets in their doc signature or examples (`modifies` - // references namepaths within its type brackets and `param` is - // name-defining but not namepath-defining, so not part of these groups) - - // Todo: Should support special processing for "name" as distinct from - // "namepath" (e.g., param can't define a namepath) - - // Todo: Should support a `tutorialID` type (for `@tutorial` block and - // inline) - - /** - * @type {TagStructure} - */ - return new Map([['alias', new Map( /** @type {[string, string|boolean][]} */[ - // Signature seems to require a "namepath" (and no counter-examples) - ['namepathRole', 'namepath-defining'], - // "namepath" - ['typeOrNameRequired', true]])], ['arg', new Map( /** @type {[string, string|boolean][]} */[['namepathRole', 'namepath-defining'], - // See `param` - ['nameRequired', true], - // Has no formal signature in the docs but shows curly brackets - // in the examples - ['typeAllowed', true]])], ['argument', new Map( /** @type {[string, string|boolean][]} */[['namepathRole', 'namepath-defining'], - // See `param` - ['nameRequired', true], - // Has no formal signature in the docs but shows curly brackets - // in the examples - ['typeAllowed', true]])], ['augments', new Map( /** @type {[string, string|boolean][]} */[ - // Signature seems to require a "namepath" (and no counter-examples) - ['namepathRole', 'namepath-referencing'], - // Does not show curly brackets in either the signature or examples - ['typeAllowed', true], - // "namepath" - ['typeOrNameRequired', true]])], ['borrows', new Map( /** @type {[string, string|boolean][]} */[ - // `borrows` has a different format, however, so needs special parsing; - // seems to require both, and as "namepath"'s - ['namepathRole', 'namepath-referencing'], - // "namepath" - ['typeOrNameRequired', true]])], ['callback', new Map( /** @type {[string, string|boolean][]} */[ - // Seems to require a "namepath" in the signature (with no - // counter-examples); TypeScript does not enforce but seems - // problematic as not attached so presumably not useable without it - ['namepathRole', 'namepath-defining'], - // "namepath" - ['nameRequired', true]])], ['class', new Map( /** @type {[string, string|boolean][]} */[ - // Allows for "name"'s in signature, but indicated as optional - ['namepathRole', 'namepath-defining'], - // Not in use, but should be this value if using to power `empty-tags` - ['nameAllowed', true], ['typeAllowed', true]])], ['const', new Map( /** @type {[string, string|boolean][]} */[ - // Allows for "name"'s in signature, but indicated as optional - ['namepathRole', 'namepath-defining'], ['typeAllowed', true]])], ['constant', new Map( /** @type {[string, string|boolean][]} */[ - // Allows for "name"'s in signature, but indicated as optional - ['namepathRole', 'namepath-defining'], ['typeAllowed', true]])], ['constructor', new Map( /** @type {[string, string|boolean][]} */[ - // Allows for "name"'s in signature, but indicated as optional - ['namepathRole', 'namepath-defining'], ['typeAllowed', true]])], ['constructs', new Map( /** @type {[string, string|boolean][]} */[ - // Allows for "name"'s in signature, but indicated as optional - ['namepathRole', 'namepath-defining'], ['nameRequired', false], ['typeAllowed', false]])], ['define', new Map( /** @type {[string, string|boolean][]} */[['typeRequired', isClosure]])], ['emits', new Map( /** @type {[string, string|boolean][]} */[ - // Signature seems to require a "name" (of an event) and no counter-examples - ['namepathRole', 'namepath-referencing'], ['nameRequired', true], ['typeAllowed', false]])], ['enum', new Map( /** @type {[string, string|boolean][]} */[ - // Has example showing curly brackets but not in doc signature - ['typeAllowed', true]])], ['event', new Map( /** @type {[string, string|boolean][]} */[ - // The doc signature of `event` seems to require a "name" - ['nameRequired', true], - // Appears to require a "name" in its signature, albeit somewhat - // different from other "name"'s (including as described - // at https://jsdoc.app/about-namepaths.html ) - ['namepathRole', 'namepath-defining']])], ['exception', new Map( /** @type {[string, string|boolean][]} */[ - // Shows curly brackets in the signature and in the examples - ['typeAllowed', true]])], - // Closure - ['export', new Map( /** @type {[string, string|boolean][]} */[['typeAllowed', isClosureOrPermissive]])], ['exports', new Map( /** @type {[string, string|boolean][]} */[['namepathRole', 'namepath-defining'], ['nameRequired', isJsdoc], ['typeAllowed', isClosureOrPermissive]])], ['extends', new Map( /** @type {[string, string|boolean][]} */[ - // Signature seems to require a "namepath" (and no counter-examples) - ['namepathRole', 'namepath-referencing'], - // Does not show curly brackets in either the signature or examples - ['typeAllowed', isTypescriptOrClosure || isPermissive], ['nameRequired', isJsdoc], - // "namepath" - ['typeOrNameRequired', isTypescriptOrClosure || isPermissive]])], ['external', new Map( /** @type {[string, string|boolean][]} */[ - // Appears to require a "name" in its signature, albeit somewhat - // different from other "name"'s (including as described - // at https://jsdoc.app/about-namepaths.html ) - ['namepathRole', 'namepath-defining'], - // "name" (and a special syntax for the `external` name) - ['nameRequired', true], ['typeAllowed', false]])], ['fires', new Map( /** @type {[string, string|boolean][]} */[ - // Signature seems to require a "name" (of an event) and no - // counter-examples - ['namepathRole', 'namepath-referencing'], ['nameRequired', true], ['typeAllowed', false]])], ['function', new Map( /** @type {[string, string|boolean][]} */[ - // Allows for "name"'s in signature, but indicated as optional - ['namepathRole', 'namepath-defining'], ['nameRequired', false], ['typeAllowed', false]])], ['func', new Map( /** @type {[string, string|boolean][]} */[ - // Allows for "name"'s in signature, but indicated as optional - ['namepathRole', 'namepath-defining']])], ['host', new Map( /** @type {[string, string|boolean][]} */[ - // Appears to require a "name" in its signature, albeit somewhat - // different from other "name"'s (including as described - // at https://jsdoc.app/about-namepaths.html ) - ['namepathRole', 'namepath-defining'], - // See `external` - ['nameRequired', true], ['typeAllowed', false]])], ['interface', new Map( /** @type {[string, string|boolean][]} */[ - // Allows for "name" in signature, but indicates as optional - ['namepathRole', isJsdocTypescriptOrPermissive ? 'namepath-defining' : false], - // Not in use, but should be this value if using to power `empty-tags` - ['nameAllowed', isClosure], ['typeAllowed', false]])], ['internal', new Map( /** @type {[string, string|boolean][]} */[ - // https://www.typescriptlang.org/tsconfig/#stripInternal - ['namepathRole', false], - // Not in use, but should be this value if using to power `empty-tags` - ['nameAllowed', false]])], ['implements', new Map( /** @type {[string, string|boolean][]} */[ - // Shows curly brackets in the doc signature and examples - // "typeExpression" - ['typeRequired', true]])], ['lends', new Map( /** @type {[string, string|boolean][]} */[ - // Signature seems to require a "namepath" (and no counter-examples) - ['namepathRole', 'namepath-referencing'], - // "namepath" - ['typeOrNameRequired', true]])], ['link', new Map( /** @type {[string, string|boolean][]} */[ - // Signature seems to require a namepath OR URL and might be checked as such. - ['namepathRole', 'namepath-or-url-referencing']])], ['linkcode', new Map( /** @type {[string, string|boolean][]} */[ - // Synonym for "link" - // Signature seems to require a namepath OR URL and might be checked as such. - ['namepathRole', 'namepath-or-url-referencing']])], ['linkplain', new Map( /** @type {[string, string|boolean][]} */[ - // Synonym for "link" - // Signature seems to require a namepath OR URL and might be checked as such. - ['namepathRole', 'namepath-or-url-referencing']])], ['listens', new Map( /** @type {[string, string|boolean][]} */[ - // Signature seems to require a "name" (of an event) and no - // counter-examples - ['namepathRole', 'namepath-referencing'], ['nameRequired', true], ['typeAllowed', false]])], ['member', new Map( /** @type {[string, string|boolean][]} */[ - // Allows for "name"'s in signature, but indicated as optional - ['namepathRole', 'namepath-defining'], - // Has example showing curly brackets but not in doc signature - ['typeAllowed', true]])], ['memberof', new Map( /** @type {[string, string|boolean][]} */[ - // Signature seems to require a "namepath" (and no counter-examples), - // though it allows an incomplete namepath ending with connecting symbol - ['namepathRole', 'namepath-referencing'], - // "namepath" - ['typeOrNameRequired', true]])], ['memberof!', new Map( /** @type {[string, string|boolean][]} */[ - // Signature seems to require a "namepath" (and no counter-examples), - // though it allows an incomplete namepath ending with connecting symbol - ['namepathRole', 'namepath-referencing'], - // "namepath" - ['typeOrNameRequired', true]])], ['method', new Map( /** @type {[string, string|boolean][]} */[ - // Allows for "name"'s in signature, but indicated as optional - ['namepathRole', 'namepath-defining']])], ['mixes', new Map( /** @type {[string, string|boolean][]} */[ - // Signature seems to require a "OtherObjectPath" with no - // counter-examples - ['namepathRole', 'namepath-referencing'], - // "OtherObjectPath" - ['typeOrNameRequired', true]])], ['mixin', new Map( /** @type {[string, string|boolean][]} */[ - // Allows for "name"'s in signature, but indicated as optional - ['namepathRole', 'namepath-defining'], ['nameRequired', false], ['typeAllowed', false]])], ['modifies', new Map( /** @type {[string, string|boolean][]} */[ - // Has no documentation, but test example has curly brackets, and - // "name" would be suggested rather than "namepath" based on example; - // not sure if name is required - ['typeAllowed', true]])], ['module', new Map( /** @type {[string, string|boolean][]} */[ - // Optional "name" and no curly brackets - // this block impacts `no-undefined-types` and `valid-types` (search for - // "isNamepathDefiningTag|tagMightHaveNamepath|tagMightHaveEitherTypeOrNamePosition") - ['namepathRole', isJsdoc ? 'namepath-defining' : 'text'], - // Shows the signature with curly brackets but not in the example - ['typeAllowed', true]])], ['name', new Map( /** @type {[string, string|boolean][]} */[ - // Seems to require a "namepath" in the signature (with no - // counter-examples) - ['namepathRole', 'namepath-defining'], - // "namepath" - ['nameRequired', true], - // "namepath" - ['typeOrNameRequired', true]])], ['namespace', new Map( /** @type {[string, string|boolean][]} */[ - // Allows for "name"'s in signature, but indicated as optional - ['namepathRole', 'namepath-defining'], - // Shows the signature with curly brackets but not in the example - ['typeAllowed', true]])], ['package', new Map( /** @type {[string, string|boolean][]} */[ - // Shows the signature with curly brackets but not in the example - // "typeExpression" - ['typeAllowed', isClosureOrPermissive]])], ['param', new Map( /** @type {[string, string|boolean][]} */[['namepathRole', 'namepath-defining'], - // Though no signature provided requiring, per - // https://jsdoc.app/tags-param.html: - // "The @param tag requires you to specify the name of the parameter you - // are documenting." - ['nameRequired', true], - // Has no formal signature in the docs but shows curly brackets - // in the examples - ['typeAllowed', true]])], ['private', new Map( /** @type {[string, string|boolean][]} */[ - // Shows the signature with curly brackets but not in the example - // "typeExpression" - ['typeAllowed', isClosureOrPermissive]])], ['prop', new Map( /** @type {[string, string|boolean][]} */[['namepathRole', 'namepath-defining'], - // See `property` - ['nameRequired', true], - // Has no formal signature in the docs but shows curly brackets - // in the examples - ['typeAllowed', true]])], ['property', new Map( /** @type {[string, string|boolean][]} */[['namepathRole', 'namepath-defining'], - // No docs indicate required, but since parallel to `param`, we treat as - // such: - ['nameRequired', true], - // Has no formal signature in the docs but shows curly brackets - // in the examples - ['typeAllowed', true]])], ['protected', new Map( /** @type {[string, string|boolean][]} */[ - // Shows the signature with curly brackets but not in the example - // "typeExpression" - ['typeAllowed', isClosureOrPermissive]])], ['public', new Map( /** @type {[string, string|boolean][]} */[ - // Does not show a signature nor show curly brackets in the example - ['typeAllowed', isClosureOrPermissive]])], ['requires', new Map( /** @type {[string, string|boolean][]} */[ - // - ['namepathRole', 'namepath-referencing'], ['nameRequired', true], ['typeAllowed', false]])], ['returns', new Map( /** @type {[string, string|boolean][]} */[ - // Shows curly brackets in the signature and in the examples - ['typeAllowed', true]])], ['return', new Map( /** @type {[string, string|boolean][]} */[ - // Shows curly brackets in the signature and in the examples - ['typeAllowed', true]])], ['satisfies', new Map( /** @type {[string, string|boolean][]} */[ - // Shows curly brackets in the doc signature and examples - ['typeRequired', true]])], ['see', new Map( /** @type {[string, string|boolean][]} */[ - // Signature allows for "namepath" or text, so user must configure to - // 'namepath-referencing' to enforce checks - ['namepathRole', 'text']])], ['static', new Map( /** @type {[string, string|boolean][]} */[ - // Does not show a signature nor show curly brackets in the example - ['typeAllowed', isClosureOrPermissive]])], ['suppress', new Map( /** @type {[string, string|boolean][]} */[['namepathRole', !isClosure], ['typeRequired', isClosure]])], ['template', new Map( /** @type {[string, string|boolean][]} */[['namepathRole', isJsdoc ? 'text' : 'namepath-referencing'], ['nameRequired', !isJsdoc], - // Though defines `namepathRole: 'namepath-defining'` in a sense, it is - // not parseable in the same way for template (e.g., allowing commas), - // so not adding - ['typeAllowed', isTypescriptOrClosure || isPermissive]])], ['this', new Map( /** @type {[string, string|boolean][]} */[ - // Signature seems to require a "namepath" (and no counter-examples) - // Not used with namepath in Closure/TypeScript, however - ['namepathRole', isJsdoc ? 'namepath-referencing' : false], ['typeRequired', isTypescriptOrClosure], - // namepath - ['typeOrNameRequired', isJsdoc]])], ['throws', new Map( /** @type {[string, string|boolean][]} */[ - // Shows curly brackets in the signature and in the examples - ['typeAllowed', true]])], ['tutorial', new Map( /** @type {[string, string|boolean][]} */[ - // (a tutorial ID) - ['nameRequired', true], ['typeAllowed', false]])], ['type', new Map( /** @type {[string, string|boolean][]} */[ - // Shows curly brackets in the doc signature and examples - // "typeName" - ['typeRequired', true]])], ['typedef', new Map( /** @type {[string, string|boolean][]} */[ - // Seems to require a "namepath" in the signature (with no - // counter-examples) - ['namepathRole', 'namepath-defining'], - // TypeScript may allow it to be dropped if followed by @property or @member; - // also shown as missing in Closure - // "namepath" - ['nameRequired', isJsdocOrPermissive], - // Is not `typeRequired` for TypeScript because it gives an error: - // JSDoc '@typedef' tag should either have a type annotation or be followed by '@property' or '@member' tags. - - // Has example showing curly brackets but not in doc signature - ['typeAllowed', true], - // TypeScript may allow it to be dropped if followed by @property or @member - // "namepath" - ['typeOrNameRequired', !isTypescript]])], ['var', new Map( /** @type {[string, string|boolean][]} */[ - // Allows for "name"'s in signature, but indicated as optional - ['namepathRole', 'namepath-defining'], - // Has example showing curly brackets but not in doc signature - ['typeAllowed', true]])], ['yields', new Map( /** @type {[string, string|boolean][]} */[ - // Shows curly brackets in the signature and in the examples - ['typeAllowed', true]])], ['yield', new Map( /** @type {[string, string|boolean][]} */[ - // Shows curly brackets in the signature and in the examples - ['typeAllowed', true]])]]); -}; -var _default = exports.default = getDefaultTagStructureForMode; -module.exports = exports.default; -//# sourceMappingURL=getDefaultTagStructureForMode.cjs.map \ No newline at end of file diff --git a/tools/eslint/node_modules/eslint-plugin-jsdoc/dist/import-worker.cjs b/tools/eslint/node_modules/eslint-plugin-jsdoc/dist/import-worker.cjs deleted file mode 100644 index 995a9baea23d23..00000000000000 --- a/tools/eslint/node_modules/eslint-plugin-jsdoc/dist/import-worker.cjs +++ /dev/null @@ -1,17 +0,0 @@ -"use strict"; - -var _synckit = require("synckit"); -function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); } -function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; } -(0, _synckit.runAsWorker)(async imprt => { - const { - parseImports - } = await Promise.resolve().then(() => _interopRequireWildcard(require('parse-imports'))); - try { - // ESLint doesn't support async rules - return [...(await parseImports(imprt))]; - } catch (err) { - return false; - } -}); -//# sourceMappingURL=import-worker.cjs.map \ No newline at end of file diff --git a/tools/eslint/node_modules/eslint-plugin-jsdoc/dist/import-worker.mjs b/tools/eslint/node_modules/eslint-plugin-jsdoc/dist/import-worker.mjs deleted file mode 100644 index cc54de761a9411..00000000000000 --- a/tools/eslint/node_modules/eslint-plugin-jsdoc/dist/import-worker.mjs +++ /dev/null @@ -1,11 +0,0 @@ -import { runAsWorker } from 'synckit' - -runAsWorker(async (imprt) => { - const { parseImports } = await import('parse-imports'); - try { - // ESLint doesn't support async rules - return [...await parseImports(imprt)]; - } catch (err) { - return false; - } -}) diff --git a/tools/eslint/node_modules/eslint-plugin-jsdoc/dist/index.cjs b/tools/eslint/node_modules/eslint-plugin-jsdoc/dist/index.cjs deleted file mode 100644 index 5f76dec7793803..00000000000000 --- a/tools/eslint/node_modules/eslint-plugin-jsdoc/dist/index.cjs +++ /dev/null @@ -1,274 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.default = void 0; -var _checkAccess = _interopRequireDefault(require("./rules/checkAccess.cjs")); -var _checkAlignment = _interopRequireDefault(require("./rules/checkAlignment.cjs")); -var _checkExamples = _interopRequireDefault(require("./rules/checkExamples.cjs")); -var _checkIndentation = _interopRequireDefault(require("./rules/checkIndentation.cjs")); -var _checkLineAlignment = _interopRequireDefault(require("./rules/checkLineAlignment.cjs")); -var _checkParamNames = _interopRequireDefault(require("./rules/checkParamNames.cjs")); -var _checkPropertyNames = _interopRequireDefault(require("./rules/checkPropertyNames.cjs")); -var _checkSyntax = _interopRequireDefault(require("./rules/checkSyntax.cjs")); -var _checkTagNames = _interopRequireDefault(require("./rules/checkTagNames.cjs")); -var _checkTypes = _interopRequireDefault(require("./rules/checkTypes.cjs")); -var _checkValues = _interopRequireDefault(require("./rules/checkValues.cjs")); -var _convertToJsdocComments = _interopRequireDefault(require("./rules/convertToJsdocComments.cjs")); -var _emptyTags = _interopRequireDefault(require("./rules/emptyTags.cjs")); -var _implementsOnClasses = _interopRequireDefault(require("./rules/implementsOnClasses.cjs")); -var _importsAsDependencies = _interopRequireDefault(require("./rules/importsAsDependencies.cjs")); -var _informativeDocs = _interopRequireDefault(require("./rules/informativeDocs.cjs")); -var _matchDescription = _interopRequireDefault(require("./rules/matchDescription.cjs")); -var _matchName = _interopRequireDefault(require("./rules/matchName.cjs")); -var _multilineBlocks = _interopRequireDefault(require("./rules/multilineBlocks.cjs")); -var _noBadBlocks = _interopRequireDefault(require("./rules/noBadBlocks.cjs")); -var _noBlankBlockDescriptions = _interopRequireDefault(require("./rules/noBlankBlockDescriptions.cjs")); -var _noBlankBlocks = _interopRequireDefault(require("./rules/noBlankBlocks.cjs")); -var _noDefaults = _interopRequireDefault(require("./rules/noDefaults.cjs")); -var _noMissingSyntax = _interopRequireDefault(require("./rules/noMissingSyntax.cjs")); -var _noMultiAsterisks = _interopRequireDefault(require("./rules/noMultiAsterisks.cjs")); -var _noRestrictedSyntax = _interopRequireDefault(require("./rules/noRestrictedSyntax.cjs")); -var _noTypes = _interopRequireDefault(require("./rules/noTypes.cjs")); -var _noUndefinedTypes = _interopRequireDefault(require("./rules/noUndefinedTypes.cjs")); -var _requireAsteriskPrefix = _interopRequireDefault(require("./rules/requireAsteriskPrefix.cjs")); -var _requireDescription = _interopRequireDefault(require("./rules/requireDescription.cjs")); -var _requireDescriptionCompleteSentence = _interopRequireDefault(require("./rules/requireDescriptionCompleteSentence.cjs")); -var _requireExample = _interopRequireDefault(require("./rules/requireExample.cjs")); -var _requireFileOverview = _interopRequireDefault(require("./rules/requireFileOverview.cjs")); -var _requireHyphenBeforeParamDescription = _interopRequireDefault(require("./rules/requireHyphenBeforeParamDescription.cjs")); -var _requireJsdoc = _interopRequireDefault(require("./rules/requireJsdoc.cjs")); -var _requireParam = _interopRequireDefault(require("./rules/requireParam.cjs")); -var _requireParamDescription = _interopRequireDefault(require("./rules/requireParamDescription.cjs")); -var _requireParamName = _interopRequireDefault(require("./rules/requireParamName.cjs")); -var _requireParamType = _interopRequireDefault(require("./rules/requireParamType.cjs")); -var _requireProperty = _interopRequireDefault(require("./rules/requireProperty.cjs")); -var _requirePropertyDescription = _interopRequireDefault(require("./rules/requirePropertyDescription.cjs")); -var _requirePropertyName = _interopRequireDefault(require("./rules/requirePropertyName.cjs")); -var _requirePropertyType = _interopRequireDefault(require("./rules/requirePropertyType.cjs")); -var _requireReturns = _interopRequireDefault(require("./rules/requireReturns.cjs")); -var _requireReturnsCheck = _interopRequireDefault(require("./rules/requireReturnsCheck.cjs")); -var _requireReturnsDescription = _interopRequireDefault(require("./rules/requireReturnsDescription.cjs")); -var _requireReturnsType = _interopRequireDefault(require("./rules/requireReturnsType.cjs")); -var _requireTemplate = _interopRequireDefault(require("./rules/requireTemplate.cjs")); -var _requireThrows = _interopRequireDefault(require("./rules/requireThrows.cjs")); -var _requireYields = _interopRequireDefault(require("./rules/requireYields.cjs")); -var _requireYieldsCheck = _interopRequireDefault(require("./rules/requireYieldsCheck.cjs")); -var _sortTags = _interopRequireDefault(require("./rules/sortTags.cjs")); -var _tagLines = _interopRequireDefault(require("./rules/tagLines.cjs")); -var _textEscaping = _interopRequireDefault(require("./rules/textEscaping.cjs")); -var _validTypes = _interopRequireDefault(require("./rules/validTypes.cjs")); -function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; } -/** - * @type {import('eslint').ESLint.Plugin & { - * configs: Record< - * "recommended"|"recommended-error"|"recommended-typescript"| - * "recommended-typescript-error"|"recommended-typescript-flavor"| - * "recommended-typescript-flavor-error"|"flat/recommended"| - * "flat/recommended-error"|"flat/recommended-typescript"| - * "flat/recommended-typescript-error"| - * "flat/recommended-typescript-flavor"| - * "flat/recommended-typescript-flavor-error", - * import('eslint').Linter.FlatConfig - * > - * }} - */ -const index = { - // @ts-expect-error Ok - configs: {}, - rules: { - 'check-access': _checkAccess.default, - 'check-alignment': _checkAlignment.default, - 'check-examples': _checkExamples.default, - 'check-indentation': _checkIndentation.default, - 'check-line-alignment': _checkLineAlignment.default, - 'check-param-names': _checkParamNames.default, - 'check-property-names': _checkPropertyNames.default, - 'check-syntax': _checkSyntax.default, - 'check-tag-names': _checkTagNames.default, - 'check-types': _checkTypes.default, - 'check-values': _checkValues.default, - 'convert-to-jsdoc-comments': _convertToJsdocComments.default, - 'empty-tags': _emptyTags.default, - 'implements-on-classes': _implementsOnClasses.default, - 'imports-as-dependencies': _importsAsDependencies.default, - 'informative-docs': _informativeDocs.default, - 'match-description': _matchDescription.default, - 'match-name': _matchName.default, - 'multiline-blocks': _multilineBlocks.default, - 'no-bad-blocks': _noBadBlocks.default, - 'no-blank-block-descriptions': _noBlankBlockDescriptions.default, - 'no-blank-blocks': _noBlankBlocks.default, - 'no-defaults': _noDefaults.default, - 'no-missing-syntax': _noMissingSyntax.default, - 'no-multi-asterisks': _noMultiAsterisks.default, - 'no-restricted-syntax': _noRestrictedSyntax.default, - 'no-types': _noTypes.default, - 'no-undefined-types': _noUndefinedTypes.default, - 'require-asterisk-prefix': _requireAsteriskPrefix.default, - 'require-description': _requireDescription.default, - 'require-description-complete-sentence': _requireDescriptionCompleteSentence.default, - 'require-example': _requireExample.default, - 'require-file-overview': _requireFileOverview.default, - 'require-hyphen-before-param-description': _requireHyphenBeforeParamDescription.default, - 'require-jsdoc': _requireJsdoc.default, - 'require-param': _requireParam.default, - 'require-param-description': _requireParamDescription.default, - 'require-param-name': _requireParamName.default, - 'require-param-type': _requireParamType.default, - 'require-property': _requireProperty.default, - 'require-property-description': _requirePropertyDescription.default, - 'require-property-name': _requirePropertyName.default, - 'require-property-type': _requirePropertyType.default, - 'require-returns': _requireReturns.default, - 'require-returns-check': _requireReturnsCheck.default, - 'require-returns-description': _requireReturnsDescription.default, - 'require-returns-type': _requireReturnsType.default, - 'require-template': _requireTemplate.default, - 'require-throws': _requireThrows.default, - 'require-yields': _requireYields.default, - 'require-yields-check': _requireYieldsCheck.default, - 'sort-tags': _sortTags.default, - 'tag-lines': _tagLines.default, - 'text-escaping': _textEscaping.default, - 'valid-types': _validTypes.default - } -}; - -/** - * @param {"warn"|"error"} warnOrError - * @param {string} [flatName] - * @returns {import('eslint').Linter.FlatConfig} - */ -const createRecommendedRuleset = (warnOrError, flatName) => { - return { - ...(flatName ? { - name: 'jsdoc/' + flatName - } : {}), - // @ts-expect-error Ok - plugins: flatName ? { - jsdoc: index - } : ['jsdoc'], - rules: { - 'jsdoc/check-access': warnOrError, - 'jsdoc/check-alignment': warnOrError, - 'jsdoc/check-examples': 'off', - 'jsdoc/check-indentation': 'off', - 'jsdoc/check-line-alignment': 'off', - 'jsdoc/check-param-names': warnOrError, - 'jsdoc/check-property-names': warnOrError, - 'jsdoc/check-syntax': 'off', - 'jsdoc/check-tag-names': warnOrError, - 'jsdoc/check-types': warnOrError, - 'jsdoc/check-values': warnOrError, - 'jsdoc/convert-to-jsdoc-comments': 'off', - 'jsdoc/empty-tags': warnOrError, - 'jsdoc/implements-on-classes': warnOrError, - 'jsdoc/imports-as-dependencies': 'off', - 'jsdoc/informative-docs': 'off', - 'jsdoc/match-description': 'off', - 'jsdoc/match-name': 'off', - 'jsdoc/multiline-blocks': warnOrError, - 'jsdoc/no-bad-blocks': 'off', - 'jsdoc/no-blank-block-descriptions': 'off', - 'jsdoc/no-blank-blocks': 'off', - 'jsdoc/no-defaults': warnOrError, - 'jsdoc/no-missing-syntax': 'off', - 'jsdoc/no-multi-asterisks': warnOrError, - 'jsdoc/no-restricted-syntax': 'off', - 'jsdoc/no-types': 'off', - 'jsdoc/no-undefined-types': warnOrError, - 'jsdoc/require-asterisk-prefix': 'off', - 'jsdoc/require-description': 'off', - 'jsdoc/require-description-complete-sentence': 'off', - 'jsdoc/require-example': 'off', - 'jsdoc/require-file-overview': 'off', - 'jsdoc/require-hyphen-before-param-description': 'off', - 'jsdoc/require-jsdoc': warnOrError, - 'jsdoc/require-param': warnOrError, - 'jsdoc/require-param-description': warnOrError, - 'jsdoc/require-param-name': warnOrError, - 'jsdoc/require-param-type': warnOrError, - 'jsdoc/require-property': warnOrError, - 'jsdoc/require-property-description': warnOrError, - 'jsdoc/require-property-name': warnOrError, - 'jsdoc/require-property-type': warnOrError, - 'jsdoc/require-returns': warnOrError, - 'jsdoc/require-returns-check': warnOrError, - 'jsdoc/require-returns-description': warnOrError, - 'jsdoc/require-returns-type': warnOrError, - 'jsdoc/require-template': 'off', - 'jsdoc/require-throws': 'off', - 'jsdoc/require-yields': warnOrError, - 'jsdoc/require-yields-check': warnOrError, - 'jsdoc/sort-tags': 'off', - 'jsdoc/tag-lines': warnOrError, - 'jsdoc/text-escaping': 'off', - 'jsdoc/valid-types': warnOrError - } - }; -}; - -/** - * @param {"warn"|"error"} warnOrError - * @param {string} [flatName] - * @returns {import('eslint').Linter.FlatConfig} - */ -const createRecommendedTypeScriptRuleset = (warnOrError, flatName) => { - const ruleset = createRecommendedRuleset(warnOrError, flatName); - return { - ...ruleset, - rules: { - ...ruleset.rules, - /* eslint-disable indent -- Extra indent to avoid use by auto-rule-editing */ - 'jsdoc/check-tag-names': [warnOrError, { - typed: true - }], - 'jsdoc/no-types': warnOrError, - 'jsdoc/no-undefined-types': 'off', - 'jsdoc/require-param-type': 'off', - 'jsdoc/require-property-type': 'off', - 'jsdoc/require-returns-type': 'off' - /* eslint-enable indent */ - } - }; -}; - -/** - * @param {"warn"|"error"} warnOrError - * @param {string} [flatName] - * @returns {import('eslint').Linter.FlatConfig} - */ -const createRecommendedTypeScriptFlavorRuleset = (warnOrError, flatName) => { - const ruleset = createRecommendedRuleset(warnOrError, flatName); - return { - ...ruleset, - rules: { - ...ruleset.rules, - /* eslint-disable indent -- Extra indent to avoid use by auto-rule-editing */ - 'jsdoc/no-undefined-types': 'off' - /* eslint-enable indent */ - } - }; -}; - -/* c8 ignore next 3 -- TS */ -if (!index.configs) { - throw new Error('TypeScript guard'); -} -index.configs.recommended = createRecommendedRuleset('warn'); -index.configs['recommended-error'] = createRecommendedRuleset('error'); -index.configs['recommended-typescript'] = createRecommendedTypeScriptRuleset('warn'); -index.configs['recommended-typescript-error'] = createRecommendedTypeScriptRuleset('error'); -index.configs['recommended-typescript-flavor'] = createRecommendedTypeScriptFlavorRuleset('warn'); -index.configs['recommended-typescript-flavor-error'] = createRecommendedTypeScriptFlavorRuleset('error'); -index.configs['flat/recommended'] = createRecommendedRuleset('warn', 'flat/recommended'); -index.configs['flat/recommended-error'] = createRecommendedRuleset('error', 'flat/recommended-error'); -index.configs['flat/recommended-typescript'] = createRecommendedTypeScriptRuleset('warn', 'flat/recommended-typescript'); -index.configs['flat/recommended-typescript-error'] = createRecommendedTypeScriptRuleset('error', 'flat/recommended-typescript-error'); -index.configs['flat/recommended-typescript-flavor'] = createRecommendedTypeScriptFlavorRuleset('warn', 'flat/recommended-typescript-flavor'); -index.configs['flat/recommended-typescript-flavor-error'] = createRecommendedTypeScriptFlavorRuleset('error', 'flat/recommended-typescript-flavor-error'); -var _default = exports.default = index; -module.exports = exports.default; -//# sourceMappingURL=index.cjs.map \ No newline at end of file diff --git a/tools/eslint/node_modules/eslint-plugin-jsdoc/dist/iterateJsdoc.cjs b/tools/eslint/node_modules/eslint-plugin-jsdoc/dist/iterateJsdoc.cjs deleted file mode 100644 index cffffd90af9ef6..00000000000000 --- a/tools/eslint/node_modules/eslint-plugin-jsdoc/dist/iterateJsdoc.cjs +++ /dev/null @@ -1,2120 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.default = iterateJsdoc; -exports.getSettings = void 0; -Object.defineProperty(exports, "parseComment", { - enumerable: true, - get: function () { - return _jsdoccomment.parseComment; - } -}); -var _jsdocUtils = _interopRequireDefault(require("./jsdocUtils.cjs")); -var _jsdoccomment = require("@es-joy/jsdoccomment"); -var _commentParser = require("comment-parser"); -var _esquery = _interopRequireDefault(require("esquery")); -function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; } -/** - * @typedef {number} Integer - */ - -/** - * @typedef {import('@es-joy/jsdoccomment').JsdocBlockWithInline} JsdocBlockWithInline - */ - -/** - * @typedef {{ - * disallowName?: string, - * allowName?: string, - * context?: string, - * comment?: string, - * tags?: string[], - * replacement?: string, - * minimum?: Integer, - * message?: string, - * forceRequireReturn?: boolean - * }} ContextObject - */ -/** - * @typedef {string|ContextObject} Context - */ - -/** - * @callback CheckJsdoc - * @param {{ - * lastIndex?: Integer, - * isFunctionContext?: boolean, - * selector?: string, - * comment?: string - * }} info - * @param {null|((jsdoc: import('@es-joy/jsdoccomment').JsdocBlockWithInline) => boolean|undefined)} handler - * @param {import('eslint').Rule.Node} node - * @returns {void} - */ - -/** - * @callback ForEachPreferredTag - * @param {string} tagName - * @param {( - * matchingJsdocTag: import('@es-joy/jsdoccomment').JsdocTagWithInline, - * targetTagName: string - * ) => void} arrayHandler - * @param {boolean} [skipReportingBlockedTag] - * @returns {void} - */ - -/** - * @callback ReportSettings - * @param {string} message - * @returns {void} - */ - -/** - * @callback ParseClosureTemplateTag - * @param {import('comment-parser').Spec} tag - * @returns {string[]} - */ - -/** - * @callback GetPreferredTagNameObject - * @param {{ - * tagName: string - * }} cfg - * @returns {string|false|{ - * message: string; - * replacement?: string|undefined - * }|{ - * blocked: true, - * tagName: string - * }} - */ - -/** - * @typedef {{ - * forEachPreferredTag: ForEachPreferredTag, - * reportSettings: ReportSettings, - * parseClosureTemplateTag: ParseClosureTemplateTag, - * getPreferredTagNameObject: GetPreferredTagNameObject, - * pathDoesNotBeginWith: import('./jsdocUtils.js').PathDoesNotBeginWith - * }} BasicUtils - */ - -/** - * @callback IsIteratingFunction - * @returns {boolean} - */ - -/** - * @callback IsVirtualFunction - * @returns {boolean} - */ - -/** - * @callback Stringify - * @param {import('comment-parser').Block} tagBlock - * @param {boolean} [specRewire] - * @returns {string} - */ - -/** - * @callback ReportJSDoc - * @param {string} msg - * @param {null|import('comment-parser').Spec|{line: Integer, column?: Integer}} [tag] - * @param {(() => void)|null} [handler] - * @param {boolean} [specRewire] - * @param {undefined|{ - * [key: string]: string - * }} [data] - */ - -/** - * @callback GetRegexFromString - * @param {string} str - * @param {string} [requiredFlags] - * @returns {RegExp} - */ - -/** - * @callback GetTagDescription - * @param {import('comment-parser').Spec} tg - * @param {boolean} [returnArray] - * @returns {string[]|string} - */ - -/** - * @callback SetTagDescription - * @param {import('comment-parser').Spec} tg - * @param {RegExp} matcher - * @param {(description: string) => string} setter - * @returns {Integer} - */ - -/** - * @callback GetDescription - * @returns {{ - * description: string, - * descriptions: string[], - * lastDescriptionLine: Integer - * }} - */ - -/** - * @callback SetBlockDescription - * @param {( - * info: { - * delimiter: string, - * postDelimiter: string, - * start: string - * }, - * seedTokens: ( - * tokens?: Partial - * ) => import('comment-parser').Tokens, - * descLines: string[] - * ) => import('comment-parser').Line[]} setter - * @returns {void} - */ - -/** - * @callback SetDescriptionLines - * @param {RegExp} matcher - * @param {(description: string) => string} setter - * @returns {Integer} - */ - -/** - * @callback ChangeTag - * @param {import('comment-parser').Spec} tag - * @param {...Partial} tokens - * @returns {void} - */ - -/** - * @callback SetTag - * @param {import('comment-parser').Spec & { - * line: Integer - * }} tag - * @param {Partial} [tokens] - * @returns {void} - */ - -/** - * @callback RemoveTag - * @param {Integer} tagIndex - * @param {{ - * removeEmptyBlock?: boolean, - * tagSourceOffset?: Integer - * }} [cfg] - * @returns {void} - */ - -/** - * @callback AddTag - * @param {string} targetTagName - * @param {Integer} [number] - * @param {import('comment-parser').Tokens|{}} [tokens] - * @returns {void} - */ - -/** - * @callback GetFirstLine - * @returns {Integer|undefined} - */ - -/** - * @typedef {( - * tokens?: Partial | undefined - * ) => import('comment-parser').Tokens} SeedTokens - */ - -/** - * Sets tokens to empty string. - * @callback EmptyTokens - * @param {import('comment-parser').Tokens} tokens - * @returns {void} - */ - -/** - * @callback AddLine - * @param {Integer} sourceIndex - * @param {Partial} tokens - * @returns {void} - */ - -/** - * @callback AddLines - * @param {Integer} tagIndex - * @param {Integer} tagSourceOffset - * @param {Integer} numLines - * @returns {void} - */ - -/** - * @callback MakeMultiline - * @returns {void} - */ - -/** - * @callback GetFunctionParameterNames - * @param {boolean} [useDefaultObjectProperties] - * @returns {import('./jsdocUtils.js').ParamNameInfo[]} - */ - -/** - * @callback HasParams - * @returns {Integer} - */ - -/** - * @callback IsGenerator - * @returns {boolean} - */ - -/** - * @callback IsConstructor - * @returns {boolean} - */ - -/** - * @callback GetJsdocTagsDeep - * @param {string} tagName - * @returns {false|{ - * idx: Integer, - * name: string, - * type: string - * }[]} - */ - -/** - * @callback GetPreferredTagName - * @param {{ - * tagName: string, - * skipReportingBlockedTag?: boolean, - * allowObjectReturn?: boolean, - * defaultMessage?: string - * }} cfg - * @returns {string|undefined|false|{ - * message: string; - * replacement?: string|undefined; - * }|{ - * blocked: true, - * tagName: string - * }} - */ - -/** - * @callback IsValidTag - * @param {string} name - * @param {string[]} definedTags - * @returns {boolean} - */ - -/** - * @callback HasATag - * @param {string[]} names - * @returns {boolean} - */ - -/** - * @callback HasTag - * @param {string} name - * @returns {boolean} - */ - -/** - * @callback ComparePaths - * @param {string} name - * @returns {(otherPathName: string) => boolean} - */ - -/** - * @callback DropPathSegmentQuotes - * @param {string} name - * @returns {string} - */ - -/** - * @callback AvoidDocs - * @returns {boolean} - */ - -/** - * @callback TagMightHaveNamePositionTypePosition - * @param {string} tagName - * @param {import('./getDefaultTagStructureForMode.js'). - * TagStructure[]} [otherModeMaps] - * @returns {boolean|{otherMode: true}} - */ - -/** - * @callback TagMustHave - * @param {string} tagName - * @param {import('./getDefaultTagStructureForMode.js'). - * TagStructure[]} otherModeMaps - * @returns {boolean|{ - * otherMode: false - * }} - */ - -/** - * @callback TagMissingRequiredTypeOrNamepath - * @param {import('comment-parser').Spec} tag - * @param {import('./getDefaultTagStructureForMode.js'). - * TagStructure[]} otherModeMaps - * @returns {boolean|{ - * otherMode: false - * }} - */ - -/** - * @callback IsNamepathX - * @param {string} tagName - * @returns {boolean} - */ - -/** - * @callback GetTagStructureForMode - * @param {import('./jsdocUtils.js').ParserMode} mde - * @returns {import('./getDefaultTagStructureForMode.js').TagStructure} - */ - -/** - * @callback MayBeUndefinedTypeTag - * @param {import('comment-parser').Spec} tag - * @returns {boolean} - */ - -/** - * @callback HasValueOrExecutorHasNonEmptyResolveValue - * @param {boolean} anyPromiseAsReturn - * @param {boolean} [allBranches] - * @returns {boolean} - */ - -/** - * @callback HasYieldValue - * @returns {boolean} - */ - -/** - * @callback HasYieldReturnValue - * @returns {boolean} - */ - -/** - * @callback HasThrowValue - * @returns {boolean} - */ - -/** - * @callback IsAsync - * @returns {boolean|undefined} - */ - -/** - * @callback GetTags - * @param {string} tagName - * @returns {import('comment-parser').Spec[]} - */ - -/** - * @callback GetPresentTags - * @param {string[]} tagList - * @returns {import('@es-joy/jsdoccomment').JsdocTagWithInline[]} - */ - -/** - * @callback FilterTags - * @param {(tag: import('@es-joy/jsdoccomment').JsdocTagWithInline) => boolean} filter - * @returns {import('@es-joy/jsdoccomment').JsdocTagWithInline[]} - */ - -/** - * @callback FilterAllTags - * @param {(tag: (import('comment-parser').Spec| - * import('@es-joy/jsdoccomment').JsdocInlineTagNoType)) => boolean} filter - * @returns {(import('comment-parser').Spec| - * import('@es-joy/jsdoccomment').JsdocInlineTagNoType)[]} - */ - -/** - * @callback GetTagsByType - * @param {import('comment-parser').Spec[]} tags - * @returns {{ - * tagsWithNames: import('comment-parser').Spec[], - * tagsWithoutNames: import('comment-parser').Spec[] - * }} - */ - -/** - * @callback HasOptionTag - * @param {string} tagName - * @returns {boolean} - */ - -/** - * @callback GetClassNode - * @returns {Node|null} - */ - -/** - * @callback GetClassJsdoc - * @returns {null|JsdocBlockWithInline} - */ - -/** - * @callback ClassHasTag - * @param {string} tagName - * @returns {boolean} - */ - -/** - * @callback FindContext - * @param {Context[]} contexts - * @param {string|undefined} comment - * @returns {{ - * foundContext: Context|undefined, - * contextStr: string - * }} - */ - -/** - * @typedef {BasicUtils & { - * isIteratingFunction: IsIteratingFunction, - * isVirtualFunction: IsVirtualFunction, - * stringify: Stringify, - * reportJSDoc: ReportJSDoc, - * getRegexFromString: GetRegexFromString, - * getTagDescription: GetTagDescription, - * setTagDescription: SetTagDescription, - * getDescription: GetDescription, - * setBlockDescription: SetBlockDescription, - * setDescriptionLines: SetDescriptionLines, - * changeTag: ChangeTag, - * setTag: SetTag, - * removeTag: RemoveTag, - * addTag: AddTag, - * getFirstLine: GetFirstLine, - * seedTokens: SeedTokens, - * emptyTokens: EmptyTokens, - * addLine: AddLine, - * addLines: AddLines, - * makeMultiline: MakeMultiline, - * flattenRoots: import('./jsdocUtils.js').FlattenRoots, - * getFunctionParameterNames: GetFunctionParameterNames, - * hasParams: HasParams, - * isGenerator: IsGenerator, - * isConstructor: IsConstructor, - * getJsdocTagsDeep: GetJsdocTagsDeep, - * getPreferredTagName: GetPreferredTagName, - * isValidTag: IsValidTag, - * hasATag: HasATag, - * hasTag: HasTag, - * comparePaths: ComparePaths, - * dropPathSegmentQuotes: DropPathSegmentQuotes, - * avoidDocs: AvoidDocs, - * tagMightHaveNamePosition: TagMightHaveNamePositionTypePosition, - * tagMightHaveTypePosition: TagMightHaveNamePositionTypePosition, - * tagMustHaveNamePosition: TagMustHave, - * tagMustHaveTypePosition: TagMustHave, - * tagMissingRequiredTypeOrNamepath: TagMissingRequiredTypeOrNamepath, - * isNamepathDefiningTag: IsNamepathX, - * isNamepathReferencingTag: IsNamepathX, - * isNamepathOrUrlReferencingTag: IsNamepathX, - * tagMightHaveNamepath: IsNamepathX, - * getTagStructureForMode: GetTagStructureForMode, - * mayBeUndefinedTypeTag: MayBeUndefinedTypeTag, - * hasValueOrExecutorHasNonEmptyResolveValue: HasValueOrExecutorHasNonEmptyResolveValue, - * hasYieldValue: HasYieldValue, - * hasYieldReturnValue: HasYieldReturnValue, - * hasThrowValue: HasThrowValue, - * isAsync: IsAsync, - * getTags: GetTags, - * getPresentTags: GetPresentTags, - * filterTags: FilterTags, - * filterAllTags: FilterAllTags, - * getTagsByType: GetTagsByType, - * hasOptionTag: HasOptionTag, - * getClassNode: GetClassNode, - * getClassJsdoc: GetClassJsdoc, - * classHasTag: ClassHasTag, - * findContext: FindContext - * }} Utils - */ - -const { - rewireSpecs, - seedTokens -} = _commentParser.util; - -// todo: Change these `any` types once importing types properly. - -/** - * Should use ESLint rule's typing. - * @typedef {import('eslint').Rule.RuleMetaData} EslintRuleMeta - */ - -/** - * A plain object for tracking state as needed by rules across iterations. - * @typedef {{ - * globalTags: {}, - * hasDuplicates: { - * [key: string]: boolean - * }, - * selectorMap: { - * [selector: string]: { - * [comment: string]: Integer - * } - * }, - * hasTag: { - * [key: string]: boolean - * }, - * hasNonComment: number, - * hasNonCommentBeforeTag: { - * [key: string]: boolean|number - * } - * }} StateObject - */ - -/** - * The Node AST as supplied by the parser. - * @typedef {import('eslint').Rule.Node} Node - */ - -/* -const { - align as commentAlign, - flow: commentFlow, - indent: commentIndent, -} = transforms; -*/ - -const globalState = new Map(); -/** - * @param {import('eslint').Rule.RuleContext} context - * @param {{ - * tagNamePreference?: import('./jsdocUtils.js').TagNamePreference, - * mode?: import('./jsdocUtils.js').ParserMode - * }} cfg - * @returns {BasicUtils} - */ -const getBasicUtils = (context, { - tagNamePreference, - mode -}) => { - /** @type {BasicUtils} */ - const utils = {}; - - /** @type {ReportSettings} */ - utils.reportSettings = message => { - context.report({ - loc: { - end: { - column: 1, - line: 1 - }, - start: { - column: 1, - line: 1 - } - }, - message - }); - }; - - /** @type {ParseClosureTemplateTag} */ - utils.parseClosureTemplateTag = tag => { - return _jsdocUtils.default.parseClosureTemplateTag(tag); - }; - utils.pathDoesNotBeginWith = _jsdocUtils.default.pathDoesNotBeginWith; - - /** @type {GetPreferredTagNameObject} */ - utils.getPreferredTagNameObject = ({ - tagName - }) => { - const ret = _jsdocUtils.default.getPreferredTagName(context, /** @type {import('./jsdocUtils.js').ParserMode} */mode, tagName, tagNamePreference); - const isObject = ret && typeof ret === 'object'; - if (ret === false || isObject && !ret.replacement) { - return { - blocked: true, - tagName - }; - } - return ret; - }; - return utils; -}; - -/** - * @callback Report - * @param {string} message - * @param {import('eslint').Rule.ReportFixer|null} [fix] - * @param {null| - * {line?: Integer, column?: Integer}| - * import('comment-parser').Spec & {line?: Integer} - * } [jsdocLoc] - * @param {undefined|{ - * [key: string]: string - * }} [data] - * @returns {void} - */ - -/** - * @param {Node|null} node - * @param {JsdocBlockWithInline} jsdoc - * @param {import('eslint').AST.Token} jsdocNode - * @param {Settings} settings - * @param {Report} report - * @param {import('eslint').Rule.RuleContext} context - * @param {import('eslint').SourceCode} sc - * @param {boolean|undefined} iteratingAll - * @param {RuleConfig} ruleConfig - * @param {string} indent - * @returns {Utils} - */ -const getUtils = (node, jsdoc, jsdocNode, settings, report, context, sc, iteratingAll, ruleConfig, indent) => { - const ancestors = /** @type {import('eslint').Rule.Node[]} */node ? sc.getAncestors ? sc.getAncestors(node) - /* c8 ignore next 4 */ : context.getAncestors() : []; - - /* c8 ignore next -- Fallback to deprecated method */ - const { - sourceCode = context.getSourceCode() - } = context; - const utils = /** @type {Utils} */getBasicUtils(context, settings); - const { - tagNamePreference, - overrideReplacesDocs, - ignoreReplacesDocs, - implementsReplacesDocs, - augmentsExtendsReplacesDocs, - maxLines, - minLines, - mode - } = settings; - - /** @type {IsIteratingFunction} */ - utils.isIteratingFunction = () => { - return !iteratingAll || ['MethodDefinition', 'ArrowFunctionExpression', 'FunctionDeclaration', 'FunctionExpression'].includes(String(node && node.type)); - }; - - /** @type {IsVirtualFunction} */ - utils.isVirtualFunction = () => { - return Boolean(iteratingAll) && utils.hasATag(['callback', 'function', 'func', 'method']); - }; - - /** @type {Stringify} */ - utils.stringify = (tagBlock, specRewire) => { - let block; - if (specRewire) { - block = rewireSpecs(tagBlock); - } - return (0, _commentParser.stringify)( /** @type {import('comment-parser').Block} */ - specRewire ? block : tagBlock); - }; - - /** @type {ReportJSDoc} */ - utils.reportJSDoc = (msg, tag, handler, specRewire, data) => { - report(msg, handler ? /** @type {import('eslint').Rule.ReportFixer} */fixer => { - handler(); - const replacement = utils.stringify(jsdoc, specRewire); - if (!replacement) { - const text = sourceCode.getText(); - const lastLineBreakPos = text.slice(0, jsdocNode.range[0]).search(/\n[ \t]*$/u); - if (lastLineBreakPos > -1) { - return fixer.removeRange([lastLineBreakPos, jsdocNode.range[1]]); - } - return fixer.removeRange(/\s/u.test(text.charAt(jsdocNode.range[1])) ? [jsdocNode.range[0], jsdocNode.range[1] + 1] : jsdocNode.range); - } - return fixer.replaceText(jsdocNode, replacement); - } : null, tag, data); - }; - - /** @type {GetRegexFromString} */ - utils.getRegexFromString = (str, requiredFlags) => { - return _jsdocUtils.default.getRegexFromString(str, requiredFlags); - }; - - /** @type {GetTagDescription} */ - utils.getTagDescription = (tg, returnArray) => { - /** - * @type {string[]} - */ - const descriptions = []; - tg.source.some(({ - tokens: { - end, - lineEnd, - postDelimiter, - tag, - postTag, - name, - type, - description - } - }) => { - const desc = (tag && postTag || !tag && !name && !type && postDelimiter || '' - - // Remove space - ).slice(1) + (description || '') + (lineEnd || ''); - if (end) { - if (desc) { - descriptions.push(desc); - } - return true; - } - descriptions.push(desc); - return false; - }); - return returnArray ? descriptions : descriptions.join('\n'); - }; - - /** @type {SetTagDescription} */ - utils.setTagDescription = (tg, matcher, setter) => { - let finalIdx = 0; - tg.source.some(({ - tokens: { - description - } - }, idx) => { - if (description && matcher.test(description)) { - tg.source[idx].tokens.description = setter(description); - finalIdx = idx; - return true; - } - return false; - }); - return finalIdx; - }; - - /** @type {GetDescription} */ - utils.getDescription = () => { - /** @type {string[]} */ - const descriptions = []; - let lastDescriptionLine = 0; - let tagsBegun = false; - jsdoc.source.some(({ - tokens: { - description, - tag, - end - } - }, idx) => { - if (tag) { - tagsBegun = true; - } - if (idx && (tag || end)) { - lastDescriptionLine = idx - 1; - if (!tagsBegun && description) { - descriptions.push(description); - } - return true; - } - if (!tagsBegun && (idx || description)) { - descriptions.push(description || (descriptions.length ? '' : '\n')); - } - return false; - }); - return { - description: descriptions.join('\n'), - descriptions, - lastDescriptionLine - }; - }; - - /** @type {SetBlockDescription} */ - utils.setBlockDescription = setter => { - /** @type {string[]} */ - const descLines = []; - /** - * @type {undefined|Integer} - */ - let startIdx; - /** - * @type {undefined|Integer} - */ - let endIdx; - - /** - * @type {undefined|{ - * delimiter: string, - * postDelimiter: string, - * start: string - * }} - */ - let info; - jsdoc.source.some(({ - tokens: { - description, - start, - delimiter, - postDelimiter, - tag, - end - } - }, idx) => { - if (delimiter === '/**') { - return false; - } - if (startIdx === undefined) { - startIdx = idx; - info = { - delimiter, - postDelimiter, - start - }; - } - if (tag || end) { - endIdx = idx; - return true; - } - descLines.push(description); - return false; - }); - - /* c8 ignore else -- Won't be called if missing */ - if (descLines.length) { - jsdoc.source.splice( /** @type {Integer} */startIdx, /** @type {Integer} */endIdx - ( /** @type {Integer} */startIdx), ...setter( - /** - * @type {{ - * delimiter: string, - * postDelimiter: string, - * start: string - * }} - */ - info, seedTokens, descLines)); - } - }; - - /** @type {SetDescriptionLines} */ - utils.setDescriptionLines = (matcher, setter) => { - let finalIdx = 0; - jsdoc.source.some(({ - tokens: { - description, - tag, - end - } - }, idx) => { - /* c8 ignore next 3 -- Already checked */ - if (idx && (tag || end)) { - return true; - } - if (description && matcher.test(description)) { - jsdoc.source[idx].tokens.description = setter(description); - finalIdx = idx; - return true; - } - return false; - }); - return finalIdx; - }; - - /** @type {ChangeTag} */ - utils.changeTag = (tag, ...tokens) => { - for (const [idx, src] of tag.source.entries()) { - src.tokens = { - ...src.tokens, - ...tokens[idx] - }; - } - }; - - /** @type {SetTag} */ - utils.setTag = (tag, tokens) => { - tag.source = [{ - number: tag.line, - // Or tag.source[0].number? - source: '', - tokens: seedTokens({ - delimiter: '*', - postDelimiter: ' ', - start: indent + ' ', - tag: '@' + tag.tag, - ...tokens - }) - }]; - }; - - /** @type {RemoveTag} */ - utils.removeTag = (tagIndex, { - removeEmptyBlock = false, - tagSourceOffset = 0 - } = {}) => { - const { - source: tagSource - } = jsdoc.tags[tagIndex]; - /** @type {Integer|undefined} */ - let lastIndex; - const firstNumber = jsdoc.source[0].number; - tagSource.some(({ - number - }, tagIdx) => { - const sourceIndex = jsdoc.source.findIndex(({ - number: srcNumber - }) => { - return number === srcNumber; - }); - // c8 ignore else - if (sourceIndex > -1) { - let spliceCount = 1; - tagSource.slice(tagIdx + 1).some(({ - tokens: { - tag, - end: ending - } - }) => { - if (!tag && !ending) { - spliceCount++; - return false; - } - return true; - }); - const spliceIdx = sourceIndex + tagSourceOffset; - const { - delimiter, - end - } = jsdoc.source[spliceIdx].tokens; - if (spliceIdx === 0 && jsdoc.tags.length >= 2 || !removeEmptyBlock && (end || delimiter === '/**')) { - const { - tokens - } = jsdoc.source[spliceIdx]; - for (const item of ['postDelimiter', 'tag', 'postTag', 'type', 'postType', 'name', 'postName', 'description']) { - tokens[( - /** - * @type {"postDelimiter"|"tag"|"type"|"postType"| - * "postTag"|"name"|"postName"|"description"} - */ - item)] = ''; - } - } else { - jsdoc.source.splice(spliceIdx, spliceCount - tagSourceOffset + (spliceIdx ? 0 : jsdoc.source.length)); - tagSource.splice(tagIdx + tagSourceOffset, spliceCount - tagSourceOffset + (spliceIdx ? 0 : jsdoc.source.length)); - } - lastIndex = sourceIndex; - return true; - } - /* c8 ignore next */ - return false; - }); - for (const [idx, src] of jsdoc.source.slice(lastIndex).entries()) { - src.number = firstNumber + ( /** @type {Integer} */lastIndex) + idx; - } - - // Todo: Once rewiring of tags may be fixed in comment-parser to reflect - // missing tags, this step should be added here (so that, e.g., - // if accessing `jsdoc.tags`, such as to add a new tag, the - // correct information will be available) - }; - - /** @type {AddTag} */ - utils.addTag = (targetTagName, number = ((_jsdoc$tags => (_jsdoc$tags = jsdoc.tags[jsdoc.tags.length - 1]) === null || _jsdoc$tags === void 0 || (_jsdoc$tags = _jsdoc$tags.source[0]) === null || _jsdoc$tags === void 0 ? void 0 : _jsdoc$tags.number)() ?? jsdoc.source.findIndex(({ - tokens: { - tag - } - }) => { - return tag; - }) - 1) + 1, tokens = {}) => { - jsdoc.source.splice(number, 0, { - number, - source: '', - tokens: seedTokens({ - delimiter: '*', - postDelimiter: ' ', - start: indent + ' ', - tag: `@${targetTagName}`, - ...tokens - }) - }); - for (const src of jsdoc.source.slice(number + 1)) { - src.number++; - } - }; - - /** @type {GetFirstLine} */ - utils.getFirstLine = () => { - let firstLine; - for (const { - number, - tokens: { - tag - } - } of jsdoc.source) { - if (tag) { - firstLine = number; - break; - } - } - return firstLine; - }; - - /** @type {SeedTokens} */ - utils.seedTokens = seedTokens; - - /** @type {EmptyTokens} */ - utils.emptyTokens = tokens => { - for (const prop of ['start', 'postDelimiter', 'tag', 'type', 'postType', 'postTag', 'name', 'postName', 'description', 'end', 'lineEnd']) { - tokens[( - /** - * @type {"start"|"postDelimiter"|"tag"|"type"|"postType"| - * "postTag"|"name"|"postName"|"description"|"end"|"lineEnd"} - */ - prop)] = ''; - } - }; - - /** @type {AddLine} */ - utils.addLine = (sourceIndex, tokens) => { - var _jsdoc$source; - const number = (((_jsdoc$source = jsdoc.source[sourceIndex - 1]) === null || _jsdoc$source === void 0 ? void 0 : _jsdoc$source.number) || 0) + 1; - jsdoc.source.splice(sourceIndex, 0, { - number, - source: '', - tokens: seedTokens(tokens) - }); - for (const src of jsdoc.source.slice(number + 1)) { - src.number++; - } - // If necessary, we can rewire the tags (misnamed method) - // rewireSource(jsdoc); - }; - - /** @type {AddLines} */ - utils.addLines = (tagIndex, tagSourceOffset, numLines) => { - const { - source: tagSource - } = jsdoc.tags[tagIndex]; - /** @type {Integer|undefined} */ - let lastIndex; - const firstNumber = jsdoc.source[0].number; - tagSource.some(({ - number - }) => { - const makeLine = () => { - return { - number, - source: '', - tokens: seedTokens({ - delimiter: '*', - start: indent + ' ' - }) - }; - }; - const makeLines = () => { - return Array.from({ - length: numLines - }, makeLine); - }; - const sourceIndex = jsdoc.source.findIndex(({ - number: srcNumber, - tokens: { - end - } - }) => { - return number === srcNumber && !end; - }); - // c8 ignore else - if (sourceIndex > -1) { - const lines = makeLines(); - jsdoc.source.splice(sourceIndex + tagSourceOffset, 0, ...lines); - - // tagSource.splice(tagIdx + 1, 0, ...makeLines()); - lastIndex = sourceIndex; - return true; - } - /* c8 ignore next */ - return false; - }); - for (const [idx, src] of jsdoc.source.slice(lastIndex).entries()) { - src.number = firstNumber + ( /** @type {Integer} */lastIndex) + idx; - } - }; - - /** @type {MakeMultiline} */ - utils.makeMultiline = () => { - const { - source: [{ - tokens - }] - } = jsdoc; - const { - postDelimiter, - description, - lineEnd, - tag, - name, - type - } = tokens; - let { - tokens: { - postName, - postTag, - postType - } - } = jsdoc.source[0]; - - // Strip trailing leftovers from single line ending - if (!description) { - if (postName) { - postName = ''; - } else if (postType) { - postType = ''; - } else /* c8 ignore else -- `comment-parser` prevents empty blocks currently per https://github.com/syavorsky/comment-parser/issues/128 */if (postTag) { - postTag = ''; - } - } - utils.emptyTokens(tokens); - utils.addLine(1, { - delimiter: '*', - // If a description were present, it may have whitespace attached - // due to being at the end of the single line - description: description.trimEnd(), - name, - postDelimiter, - postName, - postTag, - postType, - start: indent + ' ', - tag, - type - }); - utils.addLine(2, { - end: '*/', - lineEnd, - start: indent + ' ' - }); - }; - - /** - * @type {import('./jsdocUtils.js').FlattenRoots} - */ - utils.flattenRoots = _jsdocUtils.default.flattenRoots; - - /** @type {GetFunctionParameterNames} */ - utils.getFunctionParameterNames = useDefaultObjectProperties => { - return _jsdocUtils.default.getFunctionParameterNames(node, useDefaultObjectProperties); - }; - - /** @type {HasParams} */ - utils.hasParams = () => { - return _jsdocUtils.default.hasParams( /** @type {Node} */node); - }; - - /** @type {IsGenerator} */ - utils.isGenerator = () => { - var _node$declaration; - return node !== null && Boolean( - /** - * @type {import('estree').FunctionDeclaration| - * import('estree').FunctionExpression} - */ - node.generator || node.type === 'MethodDefinition' && node.value.generator || ['ExportNamedDeclaration', 'ExportDefaultDeclaration'].includes(node.type) && ( /** @type {import('estree').FunctionDeclaration} */(_node$declaration = - /** - * @type {import('estree').ExportNamedDeclaration| - * import('estree').ExportDefaultDeclaration} - */ - node.declaration) === null || _node$declaration === void 0 ? void 0 : _node$declaration.generator)); - }; - - /** @type {IsConstructor} */ - utils.isConstructor = () => { - return _jsdocUtils.default.isConstructor( /** @type {Node} */node); - }; - - /** @type {GetJsdocTagsDeep} */ - utils.getJsdocTagsDeep = tagName => { - const name = /** @type {string|false} */utils.getPreferredTagName({ - tagName - }); - if (!name) { - return false; - } - return _jsdocUtils.default.getJsdocTagsDeep(jsdoc, name); - }; - - /** @type {GetPreferredTagName} */ - utils.getPreferredTagName = ({ - tagName, - skipReportingBlockedTag = false, - allowObjectReturn = false, - defaultMessage = `Unexpected tag \`@${tagName}\`` - }) => { - const ret = _jsdocUtils.default.getPreferredTagName(context, mode, tagName, tagNamePreference); - const isObject = ret && typeof ret === 'object'; - if (utils.hasTag(tagName) && (ret === false || isObject && !ret.replacement)) { - if (skipReportingBlockedTag) { - return { - blocked: true, - tagName - }; - } - const message = isObject && ret.message || defaultMessage; - report(message, null, utils.getTags(tagName)[0]); - return false; - } - return isObject && !allowObjectReturn ? ret.replacement : ret; - }; - - /** @type {IsValidTag} */ - utils.isValidTag = (name, definedTags) => { - return _jsdocUtils.default.isValidTag(context, mode, name, definedTags); - }; - - /** @type {HasATag} */ - utils.hasATag = names => { - return _jsdocUtils.default.hasATag(jsdoc, names); - }; - - /** @type {HasTag} */ - utils.hasTag = name => { - return _jsdocUtils.default.hasTag(jsdoc, name); - }; - - /** @type {ComparePaths} */ - utils.comparePaths = name => { - return _jsdocUtils.default.comparePaths(name); - }; - - /** @type {DropPathSegmentQuotes} */ - utils.dropPathSegmentQuotes = name => { - return _jsdocUtils.default.dropPathSegmentQuotes(name); - }; - - /** @type {AvoidDocs} */ - utils.avoidDocs = () => { - var _context$options$; - if (ignoreReplacesDocs !== false && (utils.hasTag('ignore') || utils.classHasTag('ignore')) || overrideReplacesDocs !== false && (utils.hasTag('override') || utils.classHasTag('override')) || implementsReplacesDocs !== false && (utils.hasTag('implements') || utils.classHasTag('implements')) || augmentsExtendsReplacesDocs && (utils.hasATag(['augments', 'extends']) || utils.classHasTag('augments') || utils.classHasTag('extends'))) { - return true; - } - if (_jsdocUtils.default.exemptSpeciaMethods(jsdoc, node, context, /** @type {import('json-schema').JSONSchema4|import('json-schema').JSONSchema4[]} */ - ruleConfig.meta.schema)) { - return true; - } - const exemptedBy = ((_context$options$ = context.options[0]) === null || _context$options$ === void 0 ? void 0 : _context$options$.exemptedBy) ?? ['inheritDoc', ...(mode === 'closure' ? [] : ['inheritdoc'])]; - if (exemptedBy.length && utils.getPresentTags(exemptedBy).length) { - return true; - } - return false; - }; - for (const method of ['tagMightHaveNamePosition', 'tagMightHaveTypePosition']) { - /** @type {TagMightHaveNamePositionTypePosition} */ - utils[( /** @type {"tagMightHaveNamePosition"|"tagMightHaveTypePosition"} */ - method)] = (tagName, otherModeMaps) => { - const result = _jsdocUtils.default[( /** @type {"tagMightHaveNamePosition"|"tagMightHaveTypePosition"} */ - method)](tagName); - if (result) { - return true; - } - if (!otherModeMaps) { - return false; - } - const otherResult = otherModeMaps.some(otherModeMap => { - return _jsdocUtils.default[( /** @type {"tagMightHaveNamePosition"|"tagMightHaveTypePosition"} */ - method)](tagName, otherModeMap); - }); - return otherResult ? { - otherMode: true - } : false; - }; - } - - /** @type {TagMissingRequiredTypeOrNamepath} */ - utils.tagMissingRequiredTypeOrNamepath = (tagName, otherModeMaps) => { - const result = _jsdocUtils.default.tagMissingRequiredTypeOrNamepath(tagName); - if (!result) { - return false; - } - const otherResult = otherModeMaps.every(otherModeMap => { - return _jsdocUtils.default.tagMissingRequiredTypeOrNamepath(tagName, otherModeMap); - }); - return otherResult ? true : { - otherMode: false - }; - }; - for (const method of ['tagMustHaveNamePosition', 'tagMustHaveTypePosition']) { - /** @type {TagMustHave} */ - utils[( /** @type {"tagMustHaveNamePosition"|"tagMustHaveTypePosition"} */ - method)] = (tagName, otherModeMaps) => { - const result = _jsdocUtils.default[( /** @type {"tagMustHaveNamePosition"|"tagMustHaveTypePosition"} */ - method)](tagName); - if (!result) { - return false; - } - - // if (!otherModeMaps) { return true; } - - const otherResult = otherModeMaps.every(otherModeMap => { - return _jsdocUtils.default[( /** @type {"tagMustHaveNamePosition"|"tagMustHaveTypePosition"} */ - method)](tagName, otherModeMap); - }); - return otherResult ? true : { - otherMode: false - }; - }; - } - for (const method of ['isNamepathDefiningTag', 'isNamepathReferencingTag', 'isNamepathOrUrlReferencingTag', 'tagMightHaveNamepath']) { - /** @type {IsNamepathX} */ - utils[( /** @type {"isNamepathDefiningTag"|"isNamepathReferencingTag"|"isNamepathOrUrlReferencingTag"|"tagMightHaveNamepath"} */ - method)] = tagName => { - return _jsdocUtils.default[( /** @type {"isNamepathDefiningTag"|"isNamepathReferencingTag"|"isNamepathOrUrlReferencingTag"|"tagMightHaveNamepath"} */ - method)](tagName); - }; - } - - /** @type {GetTagStructureForMode} */ - utils.getTagStructureForMode = mde => { - return _jsdocUtils.default.getTagStructureForMode(mde, settings.structuredTags); - }; - - /** @type {MayBeUndefinedTypeTag} */ - utils.mayBeUndefinedTypeTag = tag => { - return _jsdocUtils.default.mayBeUndefinedTypeTag(tag, settings.mode); - }; - - /** @type {HasValueOrExecutorHasNonEmptyResolveValue} */ - utils.hasValueOrExecutorHasNonEmptyResolveValue = (anyPromiseAsReturn, allBranches) => { - return _jsdocUtils.default.hasValueOrExecutorHasNonEmptyResolveValue( /** @type {Node} */node, anyPromiseAsReturn, allBranches); - }; - - /** @type {HasYieldValue} */ - utils.hasYieldValue = () => { - if (['ExportNamedDeclaration', 'ExportDefaultDeclaration'].includes( /** @type {Node} */node.type)) { - return _jsdocUtils.default.hasYieldValue( /** @type {import('estree').Declaration|import('estree').Expression} */ - /** @type {import('estree').ExportNamedDeclaration|import('estree').ExportDefaultDeclaration} */ - node.declaration); - } - return _jsdocUtils.default.hasYieldValue( /** @type {Node} */node); - }; - - /** @type {HasYieldReturnValue} */ - utils.hasYieldReturnValue = () => { - return _jsdocUtils.default.hasYieldValue( /** @type {Node} */node, true); - }; - - /** @type {HasThrowValue} */ - utils.hasThrowValue = () => { - return _jsdocUtils.default.hasThrowValue(node); - }; - - /** @type {IsAsync} */ - utils.isAsync = () => { - return Boolean(node && 'async' in node && node.async); - }; - - /** @type {GetTags} */ - utils.getTags = tagName => { - return utils.filterTags(item => { - return item.tag === tagName; - }); - }; - - /** @type {GetPresentTags} */ - utils.getPresentTags = tagList => { - return utils.filterTags(tag => { - return tagList.includes(tag.tag); - }); - }; - - /** @type {FilterTags} */ - utils.filterTags = filter => { - return jsdoc.tags.filter(tag => { - return filter(tag); - }); - }; - - /** @type {FilterAllTags} */ - utils.filterAllTags = filter => { - const tags = _jsdocUtils.default.getAllTags(jsdoc); - return tags.filter(tag => { - return filter(tag); - }); - }; - - /** @type {GetTagsByType} */ - utils.getTagsByType = tags => { - return _jsdocUtils.default.getTagsByType(context, mode, tags); - }; - - /** @type {HasOptionTag} */ - utils.hasOptionTag = tagName => { - const { - tags - } = context.options[0] ?? {}; - return Boolean(tags && tags.includes(tagName)); - }; - - /** @type {GetClassNode} */ - utils.getClassNode = () => { - return [...ancestors, node].reverse().find(parent => { - return parent && ['ClassDeclaration', 'ClassExpression'].includes(parent.type); - }) ?? null; - }; - - /** @type {GetClassJsdoc} */ - utils.getClassJsdoc = () => { - const classNode = utils.getClassNode(); - if (!classNode) { - return null; - } - const classJsdocNode = (0, _jsdoccomment.getJSDocComment)(sourceCode, classNode, { - maxLines, - minLines - }); - if (classJsdocNode) { - return (0, _jsdoccomment.parseComment)(classJsdocNode, ''); - } - return null; - }; - - /** @type {ClassHasTag} */ - utils.classHasTag = tagName => { - const classJsdoc = utils.getClassJsdoc(); - return classJsdoc !== null && _jsdocUtils.default.hasTag(classJsdoc, tagName); - }; - - /** @type {ForEachPreferredTag} */ - utils.forEachPreferredTag = (tagName, arrayHandler, skipReportingBlockedTag = false) => { - const targetTagName = /** @type {string|false} */ - utils.getPreferredTagName({ - skipReportingBlockedTag, - tagName - }); - if (!targetTagName || skipReportingBlockedTag && targetTagName && typeof targetTagName === 'object') { - return; - } - const matchingJsdocTags = jsdoc.tags.filter(({ - tag - }) => { - return tag === targetTagName; - }); - for (const matchingJsdocTag of matchingJsdocTags) { - arrayHandler( - /** - * @type {import('@es-joy/jsdoccomment').JsdocTagWithInline} - */ - matchingJsdocTag, targetTagName); - } - }; - - /** @type {FindContext} */ - utils.findContext = (contexts, comment) => { - const foundContext = contexts.find(cntxt => { - return typeof cntxt === 'string' ? _esquery.default.matches( /** @type {Node} */node, _esquery.default.parse(cntxt), undefined, { - visitorKeys: sourceCode.visitorKeys - }) : (!cntxt.context || cntxt.context === 'any' || _esquery.default.matches( /** @type {Node} */node, _esquery.default.parse(cntxt.context), undefined, { - visitorKeys: sourceCode.visitorKeys - })) && comment === cntxt.comment; - }); - const contextStr = typeof foundContext === 'object' ? foundContext.context ?? 'any' : String(foundContext); - return { - contextStr, - foundContext - }; - }; - return utils; -}; - -/** - * @typedef {{ - * [key: string]: false|string|{ - * message: string, - * replacement?: false|string - * skipRootChecking?: boolean - * } - * }} PreferredTypes - */ -/** - * @typedef {{ - * [key: string]: { - * name?: "text"|"namepath-defining"|"namepath-referencing"|false, - * type?: boolean|string[], - * required?: ("name"|"type"|"typeOrNameRequired")[] - * } - * }} StructuredTags - */ -/** - * Settings from ESLint types. - * @typedef {{ - * maxLines: Integer, - * minLines: Integer, - * tagNamePreference: import('./jsdocUtils.js').TagNamePreference, - * mode: import('./jsdocUtils.js').ParserMode, - * preferredTypes: PreferredTypes, - * structuredTags: StructuredTags, - * [name: string]: any, - * contexts?: Context[] - * }} Settings - */ - -/** - * @param {import('eslint').Rule.RuleContext} context - * @returns {Settings|false} - */ -const getSettings = context => { - var _context$settings$jsd, _context$settings$jsd2, _context$settings$jsd3, _context$settings$jsd4, _context$settings$jsd5, _context$settings$jsd6, _context$settings$jsd7, _context$settings$jsd8, _context$settings$jsd9, _context$settings$jsd10, _context$settings$jsd11, _context$settings$jsd12, _context$settings$jsd13, _context$settings$jsd14; - /* dslint-disable canonical/sort-keys */ - const settings = { - // All rules - ignorePrivate: Boolean((_context$settings$jsd = context.settings.jsdoc) === null || _context$settings$jsd === void 0 ? void 0 : _context$settings$jsd.ignorePrivate), - ignoreInternal: Boolean((_context$settings$jsd2 = context.settings.jsdoc) === null || _context$settings$jsd2 === void 0 ? void 0 : _context$settings$jsd2.ignoreInternal), - maxLines: Number(((_context$settings$jsd3 = context.settings.jsdoc) === null || _context$settings$jsd3 === void 0 ? void 0 : _context$settings$jsd3.maxLines) ?? 1), - minLines: Number(((_context$settings$jsd4 = context.settings.jsdoc) === null || _context$settings$jsd4 === void 0 ? void 0 : _context$settings$jsd4.minLines) ?? 0), - // `check-tag-names` and many returns/param rules - tagNamePreference: ((_context$settings$jsd5 = context.settings.jsdoc) === null || _context$settings$jsd5 === void 0 ? void 0 : _context$settings$jsd5.tagNamePreference) ?? {}, - // `check-types` and `no-undefined-types` - preferredTypes: ((_context$settings$jsd6 = context.settings.jsdoc) === null || _context$settings$jsd6 === void 0 ? void 0 : _context$settings$jsd6.preferredTypes) ?? {}, - // `check-types`, `no-undefined-types`, `valid-types` - structuredTags: ((_context$settings$jsd7 = context.settings.jsdoc) === null || _context$settings$jsd7 === void 0 ? void 0 : _context$settings$jsd7.structuredTags) ?? {}, - // `require-param`, `require-description`, `require-example`, - // `require-returns`, `require-throw`, `require-yields` - overrideReplacesDocs: (_context$settings$jsd8 = context.settings.jsdoc) === null || _context$settings$jsd8 === void 0 ? void 0 : _context$settings$jsd8.overrideReplacesDocs, - ignoreReplacesDocs: (_context$settings$jsd9 = context.settings.jsdoc) === null || _context$settings$jsd9 === void 0 ? void 0 : _context$settings$jsd9.ignoreReplacesDocs, - implementsReplacesDocs: (_context$settings$jsd10 = context.settings.jsdoc) === null || _context$settings$jsd10 === void 0 ? void 0 : _context$settings$jsd10.implementsReplacesDocs, - augmentsExtendsReplacesDocs: (_context$settings$jsd11 = context.settings.jsdoc) === null || _context$settings$jsd11 === void 0 ? void 0 : _context$settings$jsd11.augmentsExtendsReplacesDocs, - // `require-param-type`, `require-param-description` - exemptDestructuredRootsFromChecks: (_context$settings$jsd12 = context.settings.jsdoc) === null || _context$settings$jsd12 === void 0 ? void 0 : _context$settings$jsd12.exemptDestructuredRootsFromChecks, - // Many rules, e.g., `check-tag-names` - mode: ((_context$settings$jsd13 = context.settings.jsdoc) === null || _context$settings$jsd13 === void 0 ? void 0 : _context$settings$jsd13.mode) ?? 'typescript', - // Many rules - contexts: (_context$settings$jsd14 = context.settings.jsdoc) === null || _context$settings$jsd14 === void 0 ? void 0 : _context$settings$jsd14.contexts - }; - /* dslint-enable canonical/sort-keys */ - - _jsdocUtils.default.setTagStructure(settings.mode); - try { - _jsdocUtils.default.overrideTagStructure(settings.structuredTags); - } catch (error) { - context.report({ - loc: { - end: { - column: 1, - line: 1 - }, - start: { - column: 1, - line: 1 - } - }, - message: /** @type {Error} */error.message - }); - return false; - } - return settings; -}; - -/** - * Create the report function - * @callback MakeReport - * @param {import('eslint').Rule.RuleContext} context - * @param {import('estree').Node} commentNode - * @returns {Report} - */ - -/** @type {MakeReport} */ -exports.getSettings = getSettings; -const makeReport = (context, commentNode) => { - /** @type {Report} */ - const report = (message, fix = null, jsdocLoc = null, data = undefined) => { - let loc; - if (jsdocLoc) { - if (!('line' in jsdocLoc)) { - jsdocLoc.line = /** @type {import('comment-parser').Spec & {line?: Integer}} */jsdocLoc.source[0].number; - } - const lineNumber = /** @type {import('eslint').AST.SourceLocation} */commentNode.loc.start.line + ( /** @type {Integer} */jsdocLoc.line); - loc = { - end: { - column: 0, - line: lineNumber - }, - start: { - column: 0, - line: lineNumber - } - }; - - // Todo: Remove ignore once `check-examples` can be restored for ESLint 8+ - if ('column' in jsdocLoc && typeof jsdocLoc.column === 'number') { - const colNumber = /** @type {import('eslint').AST.SourceLocation} */commentNode.loc.start.column + jsdocLoc.column; - loc.end.column = colNumber; - loc.start.column = colNumber; - } - } - context.report({ - data, - fix, - loc, - message, - node: commentNode - }); - }; - return report; -}; - -/** - * @typedef {( - * arg: { - * context: import('eslint').Rule.RuleContext, - * sourceCode: import('eslint').SourceCode, - * indent?: string, - * info?: { - * comment?: string|undefined, - * lastIndex?: Integer|undefined - * }, - * state?: StateObject, - * globalState?: Map>, - * jsdoc?: JsdocBlockWithInline, - * jsdocNode?: import('eslint').Rule.Node & { - * range: [number, number] - * }, - * node?: Node, - * allComments?: import('estree').Node[] - * report?: Report, - * makeReport?: MakeReport, - * settings: Settings, - * utils: BasicUtils, - * } - * ) => any } JsdocVisitorBasic - */ -/** - * @typedef {( - * arg: { - * context: import('eslint').Rule.RuleContext, - * sourceCode: import('eslint').SourceCode, - * indent: string, - * info: { - * comment?: string|undefined, - * lastIndex?: Integer|undefined - * }, - * state: StateObject, - * globalState: Map>, - * jsdoc: JsdocBlockWithInline, - * jsdocNode: import('eslint').Rule.Node & { - * range: [number, number] - * }, - * node: Node|null, - * allComments?: import('estree').Node[] - * report: Report, - * makeReport?: MakeReport, - * settings: Settings, - * utils: Utils, - * } - * ) => any } JsdocVisitor - */ - -/** - * @param {{ - * comment?: string, - * lastIndex?: Integer, - * selector?: string, - * isFunctionContext?: boolean, - * }} info - * @param {string} indent - * @param {JsdocBlockWithInline} jsdoc - * @param {RuleConfig} ruleConfig - * @param {import('eslint').Rule.RuleContext} context - * @param {import('@es-joy/jsdoccomment').Token} jsdocNode - * @param {Node|null} node - * @param {Settings} settings - * @param {import('eslint').SourceCode} sourceCode - * @param {JsdocVisitor} iterator - * @param {StateObject} state - * @param {boolean} [iteratingAll] - * @returns {void} - */ -const iterate = (info, indent, jsdoc, ruleConfig, context, jsdocNode, node, settings, sourceCode, iterator, state, iteratingAll) => { - const jsdocNde = /** @type {unknown} */jsdocNode; - const report = makeReport(context, /** @type {import('estree').Node} */ - jsdocNde); - const utils = getUtils(node, jsdoc, /** @type {import('eslint').AST.Token} */ - jsdocNode, settings, report, context, sourceCode, iteratingAll, ruleConfig, indent); - if (!ruleConfig.checkInternal && settings.ignoreInternal && utils.hasTag('internal')) { - return; - } - if (!ruleConfig.checkPrivate && settings.ignorePrivate && (utils.hasTag('private') || jsdoc.tags.filter(({ - tag - }) => { - return tag === 'access'; - }).some(({ - description - }) => { - return description === 'private'; - }))) { - return; - } - iterator({ - context, - globalState, - indent, - info, - jsdoc, - jsdocNode: ( - /** - * @type {import('eslint').Rule.Node & { - * range: [number, number];}} - */ - jsdocNde), - node, - report, - settings, - sourceCode, - state, - utils - }); -}; - -/** - * @param {string[]} lines - * @param {import('estree').Comment} jsdocNode - * @returns {[indent: string, jsdoc: JsdocBlockWithInline]} - */ -const getIndentAndJSDoc = function (lines, jsdocNode) { - const sourceLine = lines[/** @type {import('estree').SourceLocation} */ - jsdocNode.loc.start.line - 1]; - const indnt = sourceLine.charAt(0).repeat( /** @type {import('estree').SourceLocation} */ - jsdocNode.loc.start.column); - const jsdc = (0, _jsdoccomment.parseComment)(jsdocNode, ''); - return [indnt, jsdc]; -}; - -/** - * - * @typedef {{node: Node & { - * range: [number, number] - * }, state: StateObject}} NonCommentArgs - */ - -/** - * @typedef {object} RuleConfig - * @property {EslintRuleMeta} meta ESLint rule meta - * @property {import('./jsdocUtils.js').DefaultContexts} [contextDefaults] Any default contexts - * @property {true} [contextSelected] Whether to force a `contexts` check - * @property {true} [iterateAllJsdocs] Whether to iterate all JSDoc blocks by default - * regardless of context - * @property {true} [checkPrivate] Whether to check `@private` blocks (normally exempted) - * @property {true} [checkInternal] Whether to check `@internal` blocks (normally exempted) - * @property {true} [checkFile] Whether to iterates over all JSDoc blocks regardless of attachment - * @property {true} [nonGlobalSettings] Whether to avoid relying on settings for global contexts - * @property {true} [noTracking] Whether to disable the tracking of visited comment nodes (as - * non-tracked may conduct further actions) - * @property {true} [matchContext] Whether the rule expects contexts to be based on a match option - * @property {(args: { - * context: import('eslint').Rule.RuleContext, - * state: StateObject, - * settings: Settings, - * utils: BasicUtils - * }) => void} [exit] Handler to be executed upon exiting iteration of program AST - * @property {(nca: NonCommentArgs) => void} [nonComment] Handler to be executed if rule wishes - * to be supplied nodes without comments - */ - -/** - * Create an eslint rule that iterates over all JSDocs, regardless of whether - * they are attached to a function-like node. - * @param {JsdocVisitor} iterator - * @param {RuleConfig} ruleConfig The rule's configuration - * @param {ContextObject[]|null} [contexts] The `contexts` containing relevant `comment` info. - * @param {boolean} [additiveCommentContexts] If true, will have a separate - * iteration for each matching comment context. Otherwise, will iterate - * once if there is a single matching comment context. - * @returns {import('eslint').Rule.RuleModule} - */ -const iterateAllJsdocs = (iterator, ruleConfig, contexts, additiveCommentContexts) => { - const trackedJsdocs = new Set(); - - /** @type {import('@es-joy/jsdoccomment').CommentHandler} */ - let handler; - - /** @type {Settings|false} */ - let settings; - - /** - * @param {import('eslint').Rule.RuleContext} context - * @param {Node|null} node - * @param {import('estree').Comment[]} jsdocNodes - * @param {StateObject} state - * @param {boolean} [lastCall] - * @returns {void} - */ - const callIterator = (context, node, jsdocNodes, state, lastCall) => { - /* c8 ignore next -- Fallback to deprecated method */ - const { - sourceCode = context.getSourceCode() - } = context; - const { - lines - } = sourceCode; - const utils = getBasicUtils(context, /** @type {Settings} */settings); - for (const jsdocNode of jsdocNodes) { - const jsdocNde = /** @type {unknown} */jsdocNode; - if (!/^\/\*\*\s/u.test(sourceCode.getText( /** @type {import('estree').Node} */ - jsdocNde))) { - continue; - } - const [indent, jsdoc] = getIndentAndJSDoc(lines, jsdocNode); - if (additiveCommentContexts) { - for (const [idx, { - comment - }] of /** @type {ContextObject[]} */contexts.entries()) { - if (comment && handler(comment, jsdoc) === false) { - continue; - } - iterate({ - comment, - lastIndex: idx, - selector: node === null || node === void 0 ? void 0 : node.type - }, indent, jsdoc, ruleConfig, context, jsdocNode, /** @type {Node} */ - node, /** @type {Settings} */ - settings, sourceCode, iterator, state, true); - } - continue; - } - let lastComment; - let lastIndex; - // eslint-disable-next-line no-loop-func - if (contexts && contexts.every(({ - comment - }, idx) => { - lastComment = comment; - lastIndex = idx; - return comment && handler(comment, jsdoc) === false; - })) { - continue; - } - iterate(lastComment ? { - comment: lastComment, - lastIndex, - selector: node === null || node === void 0 ? void 0 : node.type - } : { - lastIndex, - selector: node === null || node === void 0 ? void 0 : node.type - }, indent, jsdoc, ruleConfig, context, jsdocNode, node, /** @type {Settings} */ - settings, sourceCode, iterator, state, true); - } - const settngs = /** @type {Settings} */settings; - if (lastCall && ruleConfig.exit) { - ruleConfig.exit({ - context, - settings: settngs, - state, - utils - }); - } - }; - return { - // @ts-expect-error ESLint accepts - create(context) { - /* c8 ignore next -- Fallback to deprecated method */ - const { - sourceCode = context.getSourceCode() - } = context; - settings = getSettings(context); - if (!settings) { - return {}; - } - if (contexts) { - handler = (0, _jsdoccomment.commentHandler)(settings); - } - const state = {}; - return { - /** - * @param {import('eslint').Rule.Node & { - * range: [Integer, Integer]; - * }} node - * @returns {void} - */ - '*:not(Program)'(node) { - const commentNode = (0, _jsdoccomment.getJSDocComment)(sourceCode, node, /** @type {Settings} */settings); - if (!ruleConfig.noTracking && trackedJsdocs.has(commentNode)) { - return; - } - if (!commentNode) { - if (ruleConfig.nonComment) { - const ste = /** @type {StateObject} */state; - ruleConfig.nonComment({ - node, - state: ste - }); - } - return; - } - trackedJsdocs.add(commentNode); - callIterator(context, node, [( /** @type {import('estree').Comment} */ - commentNode)], /** @type {StateObject} */state); - }, - 'Program:exit'() { - const allComments = sourceCode.getAllComments(); - const untrackedJSdoc = allComments.filter(node => { - return !trackedJsdocs.has(node); - }); - callIterator(context, null, untrackedJSdoc, /** @type {StateObject} */ - state, true); - } - }; - }, - meta: ruleConfig.meta - }; -}; - -/** - * Create an eslint rule that iterates over all JSDocs, regardless of whether - * they are attached to a function-like node. - * @param {JsdocVisitorBasic} iterator - * @param {RuleConfig} ruleConfig - * @returns {import('eslint').Rule.RuleModule} - */ -const checkFile = (iterator, ruleConfig) => { - return { - create(context) { - /* c8 ignore next -- Fallback to deprecated method */ - const { - sourceCode = context.getSourceCode() - } = context; - const settings = getSettings(context); - if (!settings) { - return {}; - } - return { - 'Program:exit'() { - const allComms = /** @type {unknown} */sourceCode.getAllComments(); - const utils = getBasicUtils(context, settings); - iterator({ - allComments: ( /** @type {import('estree').Node[]} */allComms), - context, - makeReport, - settings, - sourceCode, - utils - }); - } - }; - }, - meta: ruleConfig.meta - }; -}; -/** - * @param {JsdocVisitor} iterator - * @param {RuleConfig} ruleConfig - * @returns {import('eslint').Rule.RuleModule} - */ -function iterateJsdoc(iterator, ruleConfig) { - var _ruleConfig$meta; - const metaType = ruleConfig === null || ruleConfig === void 0 || (_ruleConfig$meta = ruleConfig.meta) === null || _ruleConfig$meta === void 0 ? void 0 : _ruleConfig$meta.type; - if (!metaType || !['problem', 'suggestion', 'layout'].includes(metaType)) { - throw new TypeError('Rule must include `meta.type` option (with value "problem", "suggestion", or "layout")'); - } - if (typeof iterator !== 'function') { - throw new TypeError('The iterator argument must be a function.'); - } - if (ruleConfig.checkFile) { - return checkFile( /** @type {JsdocVisitorBasic} */iterator, ruleConfig); - } - if (ruleConfig.iterateAllJsdocs) { - return iterateAllJsdocs(iterator, ruleConfig); - } - - /** @type {import('eslint').Rule.RuleModule} */ - return { - /** - * The entrypoint for the JSDoc rule. - * @param {import('eslint').Rule.RuleContext} context - * a reference to the context which hold all important information - * like settings and the sourcecode to check. - * @returns {import('eslint').Rule.RuleListener} - * a listener with parser callback function. - */ - create(context) { - const settings = getSettings(context); - if (!settings) { - return {}; - } - - /** - * @type {Context[]|undefined} - */ - let contexts; - if (ruleConfig.contextDefaults || ruleConfig.contextSelected || ruleConfig.matchContext) { - var _context$options$2, _contexts, _contexts2; - contexts = ruleConfig.matchContext && (_context$options$2 = context.options[0]) !== null && _context$options$2 !== void 0 && _context$options$2.match ? context.options[0].match : _jsdocUtils.default.enforcedContexts(context, ruleConfig.contextDefaults, ruleConfig.nonGlobalSettings ? {} : settings); - if (contexts) { - contexts = contexts.map(obj => { - if (typeof obj === 'object' && !obj.context) { - return { - ...obj, - context: 'any' - }; - } - return obj; - }); - } - const hasPlainAny = (_contexts = contexts) === null || _contexts === void 0 ? void 0 : _contexts.includes('any'); - const hasObjectAny = !hasPlainAny && ((_contexts2 = contexts) === null || _contexts2 === void 0 ? void 0 : _contexts2.find(ctxt => { - if (typeof ctxt === 'string') { - return false; - } - return (ctxt === null || ctxt === void 0 ? void 0 : ctxt.context) === 'any'; - })); - if (hasPlainAny || hasObjectAny) { - return iterateAllJsdocs(iterator, ruleConfig, hasObjectAny ? ( /** @type {ContextObject[]} */contexts) : null, ruleConfig.matchContext).create(context); - } - } - - /* c8 ignore next -- Fallback to deprecated method */ - const { - sourceCode = context.getSourceCode() - } = context; - const { - lines - } = sourceCode; - - /** @type {Partial} */ - const state = {}; - - /** @type {CheckJsdoc} */ - const checkJsdoc = (info, handler, node) => { - const jsdocNode = (0, _jsdoccomment.getJSDocComment)(sourceCode, node, settings); - if (!jsdocNode) { - return; - } - const [indent, jsdoc] = getIndentAndJSDoc(lines, /** @type {import('estree').Comment} */ - jsdocNode); - if ( - // Note, `handler` should already be bound in its first argument - // with these only to be called after the value of - // `comment` - handler && handler(jsdoc) === false) { - return; - } - iterate(info, indent, jsdoc, ruleConfig, context, jsdocNode, node, settings, sourceCode, iterator, /** @type {StateObject} */ - state); - }; - - /** @type {import('eslint').Rule.RuleListener} */ - let contextObject = {}; - if (contexts && (ruleConfig.contextDefaults || ruleConfig.contextSelected || ruleConfig.matchContext)) { - contextObject = _jsdocUtils.default.getContextObject(contexts, checkJsdoc, (0, _jsdoccomment.commentHandler)(settings)); - } else { - for (const prop of ['ArrowFunctionExpression', 'FunctionDeclaration', 'FunctionExpression', 'TSDeclareFunction']) { - contextObject[prop] = checkJsdoc.bind(null, { - selector: prop - }, null); - } - } - if (typeof ruleConfig.exit === 'function') { - contextObject['Program:exit'] = () => { - const ste = /** @type {StateObject} */state; - - // @ts-expect-error `utils` not needed at this point - /** @type {Required} */ - ruleConfig.exit({ - context, - settings, - state: ste - }); - }; - } - return contextObject; - }, - meta: ruleConfig.meta - }; -} -//# sourceMappingURL=iterateJsdoc.cjs.map \ No newline at end of file diff --git a/tools/eslint/node_modules/eslint-plugin-jsdoc/dist/jsdocUtils.cjs b/tools/eslint/node_modules/eslint-plugin-jsdoc/dist/jsdocUtils.cjs deleted file mode 100644 index d0c7be3744b593..00000000000000 --- a/tools/eslint/node_modules/eslint-plugin-jsdoc/dist/jsdocUtils.cjs +++ /dev/null @@ -1,1359 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.default = void 0; -var _getDefaultTagStructureForMode = _interopRequireDefault(require("./getDefaultTagStructureForMode.cjs")); -var _tagNames = require("./tagNames.cjs"); -var _hasReturnValue = require("./utils/hasReturnValue.cjs"); -var _WarnSettings = _interopRequireDefault(require("./WarnSettings.cjs")); -var _jsdoccomment = require("@es-joy/jsdoccomment"); -function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; } -/** - * @typedef {number} Integer - */ -/** - * @typedef {import('./utils/hasReturnValue.js').ESTreeOrTypeScriptNode} ESTreeOrTypeScriptNode - */ - -/** - * @typedef {"jsdoc"|"typescript"|"closure"|"permissive"} ParserMode - */ - -/** - * @type {import('./getDefaultTagStructureForMode.js').TagStructure} - */ -let tagStructure; - -/** - * @param {ParserMode} mode - * @returns {void} - */ -const setTagStructure = mode => { - tagStructure = (0, _getDefaultTagStructureForMode.default)(mode); -}; - -/** - * @typedef {undefined|string|{ - * name: Integer, - * restElement: boolean - * }|{ - * isRestProperty: boolean|undefined, - * name: string, - * restElement: boolean - * }|{ - * name: string, - * restElement: boolean - * }} ParamCommon - */ -/** - * @typedef {ParamCommon|[string|undefined, (FlattendRootInfo & { - * annotationParamName?: string, - * })]|NestedParamInfo} ParamNameInfo - */ - -/** - * @typedef {{ - * hasPropertyRest: boolean, - * hasRestElement: boolean, - * names: string[], - * rests: boolean[], - * }} FlattendRootInfo - */ -/** - * @typedef {[string, (string[]|ParamInfo[])]} NestedParamInfo - */ -/** - * @typedef {ParamCommon| - * [string|undefined, (FlattendRootInfo & { - * annotationParamName?: string - * })]| - * NestedParamInfo} ParamInfo - */ - -/** - * Given a nested array of property names, reduce them to a single array, - * appending the name of the root element along the way if present. - * @callback FlattenRoots - * @param {ParamInfo[]} params - * @param {string} [root] - * @returns {FlattendRootInfo} - */ - -/** @type {FlattenRoots} */ -const flattenRoots = (params, root = '') => { - let hasRestElement = false; - let hasPropertyRest = false; - - /** - * @type {boolean[]} - */ - const rests = []; - const names = params.reduce( - /** - * @param {string[]} acc - * @param {ParamInfo} cur - * @returns {string[]} - */ - (acc, cur) => { - if (Array.isArray(cur)) { - let nms; - if (Array.isArray(cur[1])) { - nms = cur[1]; - } else { - if (cur[1].hasRestElement) { - hasRestElement = true; - } - if (cur[1].hasPropertyRest) { - hasPropertyRest = true; - } - nms = cur[1].names; - } - const flattened = flattenRoots(nms, root ? `${root}.${cur[0]}` : cur[0]); - if (flattened.hasRestElement) { - hasRestElement = true; - } - if (flattened.hasPropertyRest) { - hasPropertyRest = true; - } - const inner = /** @type {string[]} */[root ? `${root}.${cur[0]}` : cur[0], ...flattened.names].filter(Boolean); - rests.push(false, ...flattened.rests); - return acc.concat(inner); - } - if (typeof cur === 'object') { - if ('isRestProperty' in cur && cur.isRestProperty) { - hasPropertyRest = true; - rests.push(true); - } else { - rests.push(false); - } - if ('restElement' in cur && cur.restElement) { - hasRestElement = true; - } - acc.push(root ? `${root}.${String(cur.name)}` : String(cur.name)); - } else if (typeof cur !== 'undefined') { - rests.push(false); - acc.push(root ? `${root}.${cur}` : cur); - } - return acc; - }, []); - return { - hasPropertyRest, - hasRestElement, - names, - rests - }; -}; - -/** - * @param {import('@typescript-eslint/types').TSESTree.TSIndexSignature| - * import('@typescript-eslint/types').TSESTree.TSConstructSignatureDeclaration| - * import('@typescript-eslint/types').TSESTree.TSCallSignatureDeclaration| - * import('@typescript-eslint/types').TSESTree.TSPropertySignature} propSignature - * @returns {undefined|string|[string, string[]]} - */ -const getPropertiesFromPropertySignature = propSignature => { - if (propSignature.type === 'TSIndexSignature' || propSignature.type === 'TSConstructSignatureDeclaration' || propSignature.type === 'TSCallSignatureDeclaration') { - return undefined; - } - if (propSignature.typeAnnotation && propSignature.typeAnnotation.typeAnnotation.type === 'TSTypeLiteral') { - return [/** @type {import('@typescript-eslint/types').TSESTree.Identifier} */propSignature.key.name, propSignature.typeAnnotation.typeAnnotation.members.map(member => { - return /** @type {string} */( - getPropertiesFromPropertySignature( /** @type {import('@typescript-eslint/types').TSESTree.TSPropertySignature} */ - member) - ); - })]; - } - return /** @type {import('@typescript-eslint/types').TSESTree.Identifier} */propSignature.key.name; -}; - -/** - * @param {ESTreeOrTypeScriptNode|null} functionNode - * @param {boolean} [checkDefaultObjects] - * @throws {Error} - * @returns {ParamNameInfo[]} - */ -const getFunctionParameterNames = (functionNode, checkDefaultObjects) => { - var _functionNode$value; - /* eslint-disable complexity -- Temporary */ - /** - * @param {import('estree').Identifier|import('estree').AssignmentPattern| - * import('estree').ObjectPattern|import('estree').Property| - * import('estree').RestElement|import('estree').ArrayPattern| - * import('@typescript-eslint/types').TSESTree.TSParameterProperty| - * import('@typescript-eslint/types').TSESTree.Property| - * import('@typescript-eslint/types').TSESTree.RestElement| - * import('@typescript-eslint/types').TSESTree.Identifier| - * import('@typescript-eslint/types').TSESTree.ObjectPattern| - * import('@typescript-eslint/types').TSESTree.BindingName| - * import('@typescript-eslint/types').TSESTree.Parameter - * } param - * @param {boolean} [isProperty] - * @returns {ParamNameInfo|[string, ParamNameInfo[]]} - */ - const getParamName = (param, isProperty) => { - var _param$left2; - /* eslint-enable complexity -- Temporary */ - const hasLeftTypeAnnotation = 'left' in param && 'typeAnnotation' in param.left; - if ('typeAnnotation' in param || hasLeftTypeAnnotation) { - var _typeAnnotation$typeA; - const typeAnnotation = hasLeftTypeAnnotation ? /** @type {import('@typescript-eslint/types').TSESTree.Identifier} */param.left.typeAnnotation : /** @type {import('@typescript-eslint/types').TSESTree.Identifier|import('@typescript-eslint/types').TSESTree.ObjectPattern} */ - param.typeAnnotation; - if ((typeAnnotation === null || typeAnnotation === void 0 || (_typeAnnotation$typeA = typeAnnotation.typeAnnotation) === null || _typeAnnotation$typeA === void 0 ? void 0 : _typeAnnotation$typeA.type) === 'TSTypeLiteral') { - const propertyNames = typeAnnotation.typeAnnotation.members.map(member => { - return getPropertiesFromPropertySignature( /** @type {import('@typescript-eslint/types').TSESTree.TSPropertySignature} */ - member); - }); - const flattened = { - ...flattenRoots(propertyNames), - annotationParamName: 'name' in param ? param.name : undefined - }; - const hasLeftName = 'left' in param && 'name' in param.left; - if ('name' in param || hasLeftName) { - return [hasLeftName ? /** @type {import('@typescript-eslint/types').TSESTree.Identifier} */param.left.name : /** @type {import('@typescript-eslint/types').TSESTree.Identifier} */param.name, flattened]; - } - return [undefined, flattened]; - } - } - if ('name' in param) { - return param.name; - } - if ('left' in param && 'name' in param.left) { - return param.left.name; - } - if (param.type === 'ObjectPattern' || 'left' in param && param.left.type === 'ObjectPattern') { - var _param$left; - const properties = /** @type {import('@typescript-eslint/types').TSESTree.ObjectPattern} */param.properties || ( /** @type {import('estree').ObjectPattern} */(_param$left = /** @type {import('@typescript-eslint/types').TSESTree.AssignmentPattern} */param.left) === null || _param$left === void 0 ? void 0 : _param$left.properties); - const roots = properties.map(prop => { - return getParamName(prop, true); - }); - return [undefined, flattenRoots(roots)]; - } - if (param.type === 'Property') { - switch (param.value.type) { - case 'ArrayPattern': - { - return [/** @type {import('estree').Identifier} */ - param.key.name, /** @type {import('estree').ArrayPattern} */param.value.elements.map((prop, idx) => { - return { - name: idx, - restElement: (prop === null || prop === void 0 ? void 0 : prop.type) === 'RestElement' - }; - })]; - } - case 'ObjectPattern': - { - return [/** @type {import('estree').Identifier} */param.key.name, /** @type {import('estree').ObjectPattern} */param.value.properties.map(prop => { - return /** @type {string|[string, string[]]} */getParamName(prop, isProperty); - })]; - } - case 'AssignmentPattern': - { - switch (param.value.left.type) { - case 'Identifier': - // Default parameter - if (checkDefaultObjects && param.value.right.type === 'ObjectExpression') { - return [/** @type {import('estree').Identifier} */param.key.name, /** @type {import('estree').AssignmentPattern} */param.value.right.properties.map(prop => { - return /** @type {string} */getParamName( /** @type {import('estree').Property} */ - prop, isProperty); - })]; - } - break; - case 'ObjectPattern': - return [/** @type {import('estree').Identifier} */ - param.key.name, /** @type {import('estree').ObjectPattern} */param.value.left.properties.map(prop => { - return getParamName(prop, isProperty); - })]; - case 'ArrayPattern': - return [/** @type {import('estree').Identifier} */ - param.key.name, /** @type {import('estree').ArrayPattern} */param.value.left.elements.map((prop, idx) => { - return { - name: idx, - restElement: (prop === null || prop === void 0 ? void 0 : prop.type) === 'RestElement' - }; - })]; - } - } - } - switch (param.key.type) { - case 'Identifier': - return param.key.name; - - // The key of an object could also be a string or number - case 'Literal': - /* c8 ignore next 2 -- `raw` may not be present in all parsers */ - return /** @type {string} */param.key.raw || param.key.value; - - // case 'MemberExpression': - default: - // Todo: We should really create a structure (and a corresponding - // option analogous to `checkRestProperty`) which allows for - // (and optionally requires) dynamic properties to have a single - // line of documentation - return undefined; - } - } - if (param.type === 'ArrayPattern' || /** @type {import('estree').AssignmentPattern} */((_param$left2 = param.left) === null || _param$left2 === void 0 ? void 0 : _param$left2.type) === 'ArrayPattern') { - var _param$left3; - const elements = /** @type {import('estree').ArrayPattern} */param.elements || ( /** @type {import('estree').ArrayPattern} */(_param$left3 = /** @type {import('estree').AssignmentPattern} */param.left) === null || _param$left3 === void 0 ? void 0 : _param$left3.elements); - const roots = elements.map((prop, idx) => { - return { - name: `"${idx}"`, - restElement: (prop === null || prop === void 0 ? void 0 : prop.type) === 'RestElement' - }; - }); - return [undefined, flattenRoots(roots)]; - } - if (['RestElement', 'ExperimentalRestProperty'].includes(param.type)) { - var _param$argument; - return { - isRestProperty: isProperty, - name: /** @type {import('@typescript-eslint/types').TSESTree.Identifier} */( /** @type {import('@typescript-eslint/types').TSESTree.RestElement} */param - // @ts-expect-error Ok - .argument).name ?? (param === null || param === void 0 || (_param$argument = param.argument) === null || _param$argument === void 0 || (_param$argument = _param$argument.elements) === null || _param$argument === void 0 ? void 0 : _param$argument.map(({ - name - }) => { - return name; - })), - restElement: true - }; - } - if (param.type === 'TSParameterProperty') { - return getParamName( /** @type {import('@typescript-eslint/types').TSESTree.Identifier} */ - /** @type {import('@typescript-eslint/types').TSESTree.TSParameterProperty} */param.parameter, true); - } - throw new Error(`Unsupported function signature format: \`${param.type}\`.`); - }; - if (!functionNode) { - return []; - } - return ( /** @type {import('@typescript-eslint/types').TSESTree.FunctionDeclaration} */functionNode.params || ( /** @type {import('@typescript-eslint/types').TSESTree.MethodDefinition} */(_functionNode$value = functionNode.value) === null || _functionNode$value === void 0 ? void 0 : _functionNode$value.params) || []).map(param => { - return getParamName(param); - }); -}; - -/** - * @param {ESTreeOrTypeScriptNode} functionNode - * @returns {Integer} - */ -const hasParams = functionNode => { - // Should also check `functionNode.value.params` if supporting `MethodDefinition` - return /** @type {import('@typescript-eslint/types').TSESTree.FunctionDeclaration} */functionNode.params.length; -}; - -/** - * Gets all names of the target type, including those that refer to a path, e.g. - * `foo` or `foo.bar`. - * @param {import('comment-parser').Block} jsdoc - * @param {string} targetTagName - * @returns {{ - * idx: Integer, - * name: string, - * type: string - * }[]} - */ -const getJsdocTagsDeep = (jsdoc, targetTagName) => { - const ret = []; - for (const [idx, { - name, - tag, - type - }] of jsdoc.tags.entries()) { - if (tag !== targetTagName) { - continue; - } - ret.push({ - idx, - name, - type - }); - } - return ret; -}; -const modeWarnSettings = (0, _WarnSettings.default)(); - -/** - * @param {ParserMode|undefined} mode - * @param {import('eslint').Rule.RuleContext} context - * @returns {import('./tagNames.js').AliasedTags} - */ -const getTagNamesForMode = (mode, context) => { - switch (mode) { - case 'jsdoc': - return _tagNames.jsdocTags; - case 'typescript': - return _tagNames.typeScriptTags; - case 'closure': - case 'permissive': - return _tagNames.closureTags; - default: - if (!modeWarnSettings.hasBeenWarned(context, 'mode')) { - context.report({ - loc: { - end: { - column: 1, - line: 1 - }, - start: { - column: 1, - line: 1 - } - }, - message: `Unrecognized value \`${mode}\` for \`settings.jsdoc.mode\`.` - }); - modeWarnSettings.markSettingAsWarned(context, 'mode'); - } - - // We'll avoid breaking too many other rules - return _tagNames.jsdocTags; - } -}; - -/** - * @param {import('eslint').Rule.RuleContext} context - * @param {ParserMode|undefined} mode - * @param {string} name - * @param {TagNamePreference} tagPreference - * @returns {string|false|{ - * message: string; - * replacement?: string|undefined; - * }} - */ -const getPreferredTagName = (context, mode, name, tagPreference = {}) => { - var _Object$entries$find; - const prefValues = Object.values(tagPreference); - if (prefValues.includes(name) || prefValues.some(prefVal => { - return prefVal && typeof prefVal === 'object' && prefVal.replacement === name; - })) { - return name; - } - - // Allow keys to have a 'tag ' prefix to avoid upstream bug in ESLint - // that disallows keys that conflict with Object.prototype, - // e.g. 'tag constructor' for 'constructor': - // https://github.com/eslint/eslint/issues/13289 - // https://github.com/gajus/eslint-plugin-jsdoc/issues/537 - const tagPreferenceFixed = Object.fromEntries(Object.entries(tagPreference).map(([key, value]) => { - return [key.replace(/^tag /u, ''), value]; - })); - if (Object.prototype.hasOwnProperty.call(tagPreferenceFixed, name)) { - return tagPreferenceFixed[name]; - } - const tagNames = getTagNamesForMode(mode, context); - const preferredTagName = (_Object$entries$find = Object.entries(tagNames).find(([, aliases]) => { - return aliases.includes(name); - })) === null || _Object$entries$find === void 0 ? void 0 : _Object$entries$find[0]; - if (preferredTagName) { - return preferredTagName; - } - return name; -}; - -/** - * @param {import('eslint').Rule.RuleContext} context - * @param {ParserMode|undefined} mode - * @param {string} name - * @param {string[]} definedTags - * @returns {boolean} - */ -const isValidTag = (context, mode, name, definedTags) => { - const tagNames = getTagNamesForMode(mode, context); - const validTagNames = Object.keys(tagNames).concat(Object.values(tagNames).flat()); - const additionalTags = definedTags; - const allTags = validTagNames.concat(additionalTags); - return allTags.includes(name); -}; - -/** - * @param {import('./iterateJsdoc.js').JsdocBlockWithInline} jsdoc - * @param {string} targetTagName - * @returns {boolean} - */ -const hasTag = (jsdoc, targetTagName) => { - const targetTagLower = targetTagName.toLowerCase(); - return jsdoc.tags.some(doc => { - return doc.tag.toLowerCase() === targetTagLower; - }); -}; - -/** - * Get all tags, inline tags and inline tags in tags - * @param {import('./iterateJsdoc.js').JsdocBlockWithInline} jsdoc - * @returns {(import('comment-parser').Spec| - * import('@es-joy/jsdoccomment').JsdocInlineTagNoType)[]} - */ -const getAllTags = jsdoc => { - return [...jsdoc.tags, ...jsdoc.inlineTags.map(inlineTag => { - // Tags don't have source or line numbers, so add before returning - let line = -1; - for (const { - tokens: { - description - } - } of jsdoc.source) { - line++; - if (description && description.includes(`{@${inlineTag.tag}`)) { - break; - } - } - inlineTag.line = line; - return inlineTag; - }), ...jsdoc.tags.flatMap(tag => { - let tagBegins = -1; - for (const { - tokens: { - tag: tg - } - } of jsdoc.source) { - tagBegins++; - if (tg) { - break; - } - } - for (const inlineTag of tag.inlineTags) { - /** @type {import('./iterateJsdoc.js').Integer} */ - let line = 0; - for (const { - number, - tokens: { - description - } - } of tag.source) { - if (description && description.includes(`{@${inlineTag.tag}`)) { - line = number; - break; - } - } - inlineTag.line = tagBegins + line - 1; - } - return ( - /** - * @type {import('comment-parser').Spec & { - * inlineTags: import('@es-joy/jsdoccomment').JsdocInlineTagNoType[] - * }} - */ - tag.inlineTags - ); - })]; -}; - -/** - * @param {import('./iterateJsdoc.js').JsdocBlockWithInline} jsdoc - * @param {string[]} targetTagNames - * @returns {boolean} - */ -const hasATag = (jsdoc, targetTagNames) => { - return targetTagNames.some(targetTagName => { - return hasTag(jsdoc, targetTagName); - }); -}; - -/** - * Checks if the JSDoc comment has an undefined type. - * @param {import('comment-parser').Spec|null|undefined} tag - * the tag which should be checked. - * @param {ParserMode} mode - * @returns {boolean} - * true in case a defined type is undeclared; otherwise false. - */ -const mayBeUndefinedTypeTag = (tag, mode) => { - // The function should not continue in the event the type is not defined... - if (typeof tag === 'undefined' || tag === null) { - return true; - } - - // .. same applies if it declares an `{undefined}` or `{void}` type - const tagType = tag.type.trim(); - - // Exit early if matching - if (tagType === 'undefined' || tagType === 'void' || tagType === '*' || tagType === 'any') { - return true; - } - let parsedTypes; - try { - parsedTypes = (0, _jsdoccomment.tryParse)(tagType, mode === 'permissive' ? undefined : [mode]); - } catch { - // Ignore - } - if ( - // We do not traverse deeply as it could be, e.g., `Promise` - parsedTypes && parsedTypes.type === 'JsdocTypeUnion' && parsedTypes.elements.find(elem => { - return elem.type === 'JsdocTypeUndefined' || elem.type === 'JsdocTypeName' && elem.value === 'void'; - })) { - return true; - } - - // In any other case, a type is present - return false; -}; - -/** - * @param {import('./getDefaultTagStructureForMode.js').TagStructure} map - * @param {string} tag - * @returns {Map} - */ -const ensureMap = (map, tag) => { - if (!map.has(tag)) { - map.set(tag, new Map()); - } - return /** @type {Map} */map.get(tag); -}; - -/** - * @param {import('./iterateJsdoc.js').StructuredTags} structuredTags - * @param {import('./getDefaultTagStructureForMode.js').TagStructure} tagMap - * @returns {void} - */ -const overrideTagStructure = (structuredTags, tagMap = tagStructure) => { - for (const [tag, { - name, - type, - required = [] - }] of Object.entries(structuredTags)) { - const tagStruct = ensureMap(tagMap, tag); - tagStruct.set('namepathRole', name); - tagStruct.set('typeAllowed', type); - const requiredName = required.includes('name'); - if (requiredName && name === false) { - throw new Error('Cannot add "name" to `require` with the tag\'s `name` set to `false`'); - } - tagStruct.set('nameRequired', requiredName); - const requiredType = required.includes('type'); - if (requiredType && type === false) { - throw new Error('Cannot add "type" to `require` with the tag\'s `type` set to `false`'); - } - tagStruct.set('typeRequired', requiredType); - const typeOrNameRequired = required.includes('typeOrNameRequired'); - if (typeOrNameRequired && name === false) { - throw new Error('Cannot add "typeOrNameRequired" to `require` with the tag\'s `name` set to `false`'); - } - if (typeOrNameRequired && type === false) { - throw new Error('Cannot add "typeOrNameRequired" to `require` with the tag\'s `type` set to `false`'); - } - tagStruct.set('typeOrNameRequired', typeOrNameRequired); - } -}; - -/** - * @param {ParserMode} mode - * @param {import('./iterateJsdoc.js').StructuredTags} structuredTags - * @returns {import('./getDefaultTagStructureForMode.js').TagStructure} - */ -const getTagStructureForMode = (mode, structuredTags) => { - const tagStruct = (0, _getDefaultTagStructureForMode.default)(mode); - try { - overrideTagStructure(structuredTags, tagStruct); - /* c8 ignore next 3 */ - } catch { - // - } - return tagStruct; -}; - -/** - * @param {string} tag - * @param {import('./getDefaultTagStructureForMode.js').TagStructure} tagMap - * @returns {boolean} - */ -const isNamepathDefiningTag = (tag, tagMap = tagStructure) => { - const tagStruct = ensureMap(tagMap, tag); - return tagStruct.get('namepathRole') === 'namepath-defining'; -}; - -/** - * @param {string} tag - * @param {import('./getDefaultTagStructureForMode.js').TagStructure} tagMap - * @returns {boolean} - */ -const isNamepathReferencingTag = (tag, tagMap = tagStructure) => { - const tagStruct = ensureMap(tagMap, tag); - return tagStruct.get('namepathRole') === 'namepath-referencing'; -}; - -/** - * @param {string} tag - * @param {import('./getDefaultTagStructureForMode.js').TagStructure} tagMap - * @returns {boolean} - */ -const isNamepathOrUrlReferencingTag = (tag, tagMap = tagStructure) => { - const tagStruct = ensureMap(tagMap, tag); - return tagStruct.get('namepathRole') === 'namepath-or-url-referencing'; -}; - -/** - * @param {string} tag - * @param {import('./getDefaultTagStructureForMode.js').TagStructure} tagMap - * @returns {boolean|undefined} - */ -const tagMustHaveTypePosition = (tag, tagMap = tagStructure) => { - const tagStruct = ensureMap(tagMap, tag); - return /** @type {boolean|undefined} */tagStruct.get('typeRequired'); -}; - -/** - * @param {string} tag - * @param {import('./getDefaultTagStructureForMode.js').TagStructure} tagMap - * @returns {boolean|string} - */ -const tagMightHaveTypePosition = (tag, tagMap = tagStructure) => { - if (tagMustHaveTypePosition(tag, tagMap)) { - return true; - } - const tagStruct = ensureMap(tagMap, tag); - const ret = /** @type {boolean|undefined} */tagStruct.get('typeAllowed'); - return ret === undefined ? true : ret; -}; -const namepathTypes = new Set(['namepath-defining', 'namepath-referencing']); - -/** - * @param {string} tag - * @param {import('./getDefaultTagStructureForMode.js').TagStructure} tagMap - * @returns {boolean} - */ -const tagMightHaveNamePosition = (tag, tagMap = tagStructure) => { - const tagStruct = ensureMap(tagMap, tag); - const ret = tagStruct.get('namepathRole'); - return ret === undefined ? true : Boolean(ret); -}; - -/** - * @param {string} tag - * @param {import('./getDefaultTagStructureForMode.js').TagStructure} tagMap - * @returns {boolean} - */ -const tagMightHaveNamepath = (tag, tagMap = tagStructure) => { - const tagStruct = ensureMap(tagMap, tag); - const nampathRole = tagStruct.get('namepathRole'); - return nampathRole !== false && namepathTypes.has( /** @type {string} */nampathRole); -}; - -/** - * @param {string} tag - * @param {import('./getDefaultTagStructureForMode.js').TagStructure} tagMap - * @returns {boolean|undefined} - */ -const tagMustHaveNamePosition = (tag, tagMap = tagStructure) => { - const tagStruct = ensureMap(tagMap, tag); - return /** @type {boolean|undefined} */tagStruct.get('nameRequired'); -}; - -/** - * @param {string} tag - * @param {import('./getDefaultTagStructureForMode.js').TagStructure} tagMap - * @returns {boolean} - */ -const tagMightHaveEitherTypeOrNamePosition = (tag, tagMap) => { - return Boolean(tagMightHaveTypePosition(tag, tagMap)) || tagMightHaveNamepath(tag, tagMap); -}; - -/** - * @param {string} tag - * @param {import('./getDefaultTagStructureForMode.js').TagStructure} tagMap - * @returns {boolean|undefined} - */ -const tagMustHaveEitherTypeOrNamePosition = (tag, tagMap) => { - const tagStruct = ensureMap(tagMap, tag); - return /** @type {boolean} */tagStruct.get('typeOrNameRequired'); -}; - -/** - * @param {import('comment-parser').Spec} tag - * @param {import('./getDefaultTagStructureForMode.js').TagStructure} tagMap - * @returns {boolean|undefined} - */ -const tagMissingRequiredTypeOrNamepath = (tag, tagMap = tagStructure) => { - const mustHaveTypePosition = tagMustHaveTypePosition(tag.tag, tagMap); - const mightHaveTypePosition = tagMightHaveTypePosition(tag.tag, tagMap); - const hasTypePosition = mightHaveTypePosition && Boolean(tag.type); - const hasNameOrNamepathPosition = (tagMustHaveNamePosition(tag.tag, tagMap) || tagMightHaveNamepath(tag.tag, tagMap)) && Boolean(tag.name); - const mustHaveEither = tagMustHaveEitherTypeOrNamePosition(tag.tag, tagMap); - const hasEither = tagMightHaveEitherTypeOrNamePosition(tag.tag, tagMap) && (hasTypePosition || hasNameOrNamepathPosition); - return mustHaveEither && !hasEither && !mustHaveTypePosition; -}; - -/* eslint-disable complexity -- Temporary */ -/** - * @param {ESTreeOrTypeScriptNode|null|undefined} node - * @param {boolean} [checkYieldReturnValue] - * @returns {boolean} - */ -const hasNonFunctionYield = (node, checkYieldReturnValue) => { - /* eslint-enable complexity -- Temporary */ - if (!node) { - return false; - } - switch (node.type) { - case 'BlockStatement': - { - return node.body.some(bodyNode => { - return !['ArrowFunctionExpression', 'FunctionDeclaration', 'FunctionExpression'].includes(bodyNode.type) && hasNonFunctionYield(bodyNode, checkYieldReturnValue); - }); - } - - /* c8 ignore next 2 -- In Babel? */ - // @ts-expect-error In Babel? - case 'OptionalCallExpression': - case 'CallExpression': - return node.arguments.some(element => { - return hasNonFunctionYield(element, checkYieldReturnValue); - }); - case 'ChainExpression': - case 'ExpressionStatement': - { - return hasNonFunctionYield(node.expression, checkYieldReturnValue); - } - case 'LabeledStatement': - case 'WhileStatement': - case 'DoWhileStatement': - case 'ForStatement': - case 'ForInStatement': - case 'ForOfStatement': - case 'WithStatement': - { - return hasNonFunctionYield(node.body, checkYieldReturnValue); - } - case 'ConditionalExpression': - case 'IfStatement': - { - return hasNonFunctionYield(node.test, checkYieldReturnValue) || hasNonFunctionYield(node.consequent, checkYieldReturnValue) || hasNonFunctionYield(node.alternate, checkYieldReturnValue); - } - case 'TryStatement': - { - return hasNonFunctionYield(node.block, checkYieldReturnValue) || hasNonFunctionYield(node.handler && node.handler.body, checkYieldReturnValue) || hasNonFunctionYield( /** @type {import('@typescript-eslint/types').TSESTree.BlockStatement} */ - node.finalizer, checkYieldReturnValue); - } - case 'SwitchStatement': - { - return node.cases.some(someCase => { - return someCase.consequent.some(nde => { - return hasNonFunctionYield(nde, checkYieldReturnValue); - }); - }); - } - case 'ArrayPattern': - case 'ArrayExpression': - return node.elements.some(element => { - return hasNonFunctionYield(element, checkYieldReturnValue); - }); - case 'AssignmentPattern': - return hasNonFunctionYield(node.right, checkYieldReturnValue); - case 'VariableDeclaration': - { - return node.declarations.some(nde => { - return hasNonFunctionYield(nde, checkYieldReturnValue); - }); - } - case 'VariableDeclarator': - { - return hasNonFunctionYield(node.id, checkYieldReturnValue) || hasNonFunctionYield(node.init, checkYieldReturnValue); - } - case 'AssignmentExpression': - case 'BinaryExpression': - case 'LogicalExpression': - { - return hasNonFunctionYield(node.left, checkYieldReturnValue) || hasNonFunctionYield(node.right, checkYieldReturnValue); - } - - // Comma - case 'SequenceExpression': - case 'TemplateLiteral': - return node.expressions.some(subExpression => { - return hasNonFunctionYield(subExpression, checkYieldReturnValue); - }); - case 'ObjectPattern': - case 'ObjectExpression': - return node.properties.some(property => { - return hasNonFunctionYield(property, checkYieldReturnValue); - }); - - /* c8 ignore next -- In Babel? */ - case 'PropertyDefinition': - /* eslint-disable no-fallthrough */ - /* c8 ignore next 2 -- In Babel? */ - // @ts-expect-error In Babel? - case 'ObjectProperty': - /* c8 ignore next 2 -- In Babel? */ - // @ts-expect-error In Babel? - case 'ClassProperty': - case 'Property': - /* eslint-enable no-fallthrough */ - return node.computed && hasNonFunctionYield(node.key, checkYieldReturnValue) || hasNonFunctionYield(node.value, checkYieldReturnValue); - /* c8 ignore next 2 -- In Babel? */ - // @ts-expect-error In Babel? - case 'ObjectMethod': - /* c8 ignore next 6 -- In Babel? */ - // @ts-expect-error In Babel? - return node.computed && hasNonFunctionYield(node.key, checkYieldReturnValue) || - // @ts-expect-error In Babel? - node.arguments.some(nde => { - return hasNonFunctionYield(nde, checkYieldReturnValue); - }); - case 'SpreadElement': - case 'UnaryExpression': - return hasNonFunctionYield(node.argument, checkYieldReturnValue); - case 'TaggedTemplateExpression': - return hasNonFunctionYield(node.quasi, checkYieldReturnValue); - - // ?. - /* c8 ignore next 2 -- In Babel? */ - // @ts-expect-error In Babel? - case 'OptionalMemberExpression': - case 'MemberExpression': - return hasNonFunctionYield(node.object, checkYieldReturnValue) || hasNonFunctionYield(node.property, checkYieldReturnValue); - - /* c8 ignore next 2 -- In Babel? */ - // @ts-expect-error In Babel? - case 'Import': - case 'ImportExpression': - return hasNonFunctionYield(node.source, checkYieldReturnValue); - case 'ReturnStatement': - { - if (node.argument === null) { - return false; - } - return hasNonFunctionYield(node.argument, checkYieldReturnValue); - } - case 'YieldExpression': - { - if (checkYieldReturnValue) { - if ( /** @type {import('eslint').Rule.Node} */node.parent.type === 'VariableDeclarator') { - return true; - } - return false; - } - - // void return does not count. - if (node.argument === null) { - return false; - } - return true; - } - default: - { - return false; - } - } -}; - -/** - * Checks if a node has a return statement. Void return does not count. - * @param {ESTreeOrTypeScriptNode} node - * @param {boolean} [checkYieldReturnValue] - * @returns {boolean} - */ -const hasYieldValue = (node, checkYieldReturnValue) => { - return /** @type {import('@typescript-eslint/types').TSESTree.FunctionDeclaration} */node.generator && ( /** @type {import('@typescript-eslint/types').TSESTree.FunctionDeclaration} */node.expression || hasNonFunctionYield( /** @type {import('@typescript-eslint/types').TSESTree.FunctionDeclaration} */ - node.body, checkYieldReturnValue)); -}; - -/** - * Checks if a node has a throws statement. - * @param {ESTreeOrTypeScriptNode|null|undefined} node - * @param {boolean} [innerFunction] - * @returns {boolean} - */ -// eslint-disable-next-line complexity -const hasThrowValue = (node, innerFunction) => { - if (!node) { - return false; - } - - // There are cases where a function may execute its inner function which - // throws, but we're treating functions atomically rather than trying to - // follow them - switch (node.type) { - case 'FunctionExpression': - case 'FunctionDeclaration': - case 'ArrowFunctionExpression': - { - return !innerFunction && !node.async && hasThrowValue(node.body, true); - } - case 'BlockStatement': - { - return node.body.some(bodyNode => { - return bodyNode.type !== 'FunctionDeclaration' && hasThrowValue(bodyNode); - }); - } - case 'LabeledStatement': - case 'WhileStatement': - case 'DoWhileStatement': - case 'ForStatement': - case 'ForInStatement': - case 'ForOfStatement': - case 'WithStatement': - { - return hasThrowValue(node.body); - } - case 'IfStatement': - { - return hasThrowValue(node.consequent) || hasThrowValue(node.alternate); - } - - // We only consider it to throw an error if the catch or finally blocks throw an error. - case 'TryStatement': - { - return hasThrowValue(node.handler && node.handler.body) || hasThrowValue(node.finalizer); - } - case 'SwitchStatement': - { - return node.cases.some(someCase => { - return someCase.consequent.some(nde => { - return hasThrowValue(nde); - }); - }); - } - case 'ThrowStatement': - { - return true; - } - default: - { - return false; - } - } -}; - -/** - * @param {string} tag - */ -/* -const isInlineTag = (tag) => { - return /^(@link|@linkcode|@linkplain|@tutorial) /u.test(tag); -}; -*/ - -/** - * Parses GCC Generic/Template types - * @see {@link https://github.com/google/closure-compiler/wiki/Generic-Types} - * @see {@link https://www.typescriptlang.org/docs/handbook/jsdoc-supported-types.html#template} - * @param {import('comment-parser').Spec} tag - * @returns {string[]} - */ -const parseClosureTemplateTag = tag => { - return tag.name.split(',').map(type => { - return type.trim().replace(/^\[(?.*?)=.*\]$/u, '$'); - }); -}; - -/** - * @typedef {true|string[]} DefaultContexts - */ - -/** - * Checks user option for `contexts` array, defaulting to - * contexts designated by the rule. Returns an array of - * ESTree AST types, indicating allowable contexts. - * @param {import('eslint').Rule.RuleContext} context - * @param {DefaultContexts|undefined} defaultContexts - * @param {{ - * contexts?: import('./iterateJsdoc.js').Context[] - * }} settings - * @returns {(string|import('./iterateJsdoc.js').ContextObject)[]} - */ -const enforcedContexts = (context, defaultContexts, settings) => { - var _context$options$; - const contexts = ((_context$options$ = context.options[0]) === null || _context$options$ === void 0 ? void 0 : _context$options$.contexts) || settings.contexts || (defaultContexts === true ? ['ArrowFunctionExpression', 'FunctionDeclaration', 'FunctionExpression', 'TSDeclareFunction'] : defaultContexts); - return contexts; -}; - -/** - * @param {import('./iterateJsdoc.js').Context[]} contexts - * @param {import('./iterateJsdoc.js').CheckJsdoc} checkJsdoc - * @param {import('@es-joy/jsdoccomment').CommentHandler} [handler] - * @returns {import('eslint').Rule.RuleListener} - */ -const getContextObject = (contexts, checkJsdoc, handler) => { - /** @type {import('eslint').Rule.RuleListener} */ - const properties = {}; - for (const [idx, prop] of contexts.entries()) { - /** @type {string} */ - let property; - - /** @type {(node: import('eslint').Rule.Node) => void} */ - let value; - if (typeof prop === 'object') { - const selInfo = { - lastIndex: idx, - selector: prop.context - }; - if (prop.comment) { - property = /** @type {string} */prop.context; - value = checkJsdoc.bind(null, { - ...selInfo, - comment: prop.comment - }, - /** - * @type {(jsdoc: import('@es-joy/jsdoccomment').JsdocBlockWithInline) => boolean} - */ - /** @type {import('@es-joy/jsdoccomment').CommentHandler} */ - handler.bind(null, prop.comment)); - } else { - property = /** @type {string} */prop.context; - value = checkJsdoc.bind(null, selInfo, null); - } - } else { - const selInfo = { - lastIndex: idx, - selector: prop - }; - property = prop; - value = checkJsdoc.bind(null, selInfo, null); - } - const old = - /** - * @type {((node: import('eslint').Rule.Node) => void)} - */ - properties[property]; - properties[property] = old ? - /** - * @type {((node: import('eslint').Rule.Node) => void)} - */ - function (node) { - old(node); - value(node); - } : value; - } - return properties; -}; -const tagsWithNamesAndDescriptions = new Set(['param', 'arg', 'argument', 'property', 'prop', 'template', -// These two are parsed by our custom parser as though having a `name` -'returns', 'return']); - -/** - * @typedef {{ - * [key: string]: false|string| - * {message: string, replacement?: string} - * }} TagNamePreference - */ - -/** - * @param {import('eslint').Rule.RuleContext} context - * @param {ParserMode|undefined} mode - * @param {import('comment-parser').Spec[]} tags - * @returns {{ - * tagsWithNames: import('comment-parser').Spec[], - * tagsWithoutNames: import('comment-parser').Spec[] - * }} - */ -const getTagsByType = (context, mode, tags) => { - /** - * @type {import('comment-parser').Spec[]} - */ - const tagsWithoutNames = []; - const tagsWithNames = tags.filter(tag => { - const { - tag: tagName - } = tag; - const tagWithName = tagsWithNamesAndDescriptions.has(tagName); - if (!tagWithName) { - tagsWithoutNames.push(tag); - } - return tagWithName; - }); - return { - tagsWithNames, - tagsWithoutNames - }; -}; - -/** - * @param {import('eslint').SourceCode|{ - * text: string - * }} sourceCode - * @returns {string} - */ -const getIndent = sourceCode => { - var _sourceCode$text$matc; - return (((_sourceCode$text$matc = sourceCode.text.match(/^\n*([ \t]+)/u)) === null || _sourceCode$text$matc === void 0 ? void 0 : _sourceCode$text$matc[1]) ?? '') + ' '; -}; - -/** - * @param {import('eslint').Rule.Node|null} node - * @returns {boolean} - */ -const isConstructor = node => { - var _node$parent; - return (node === null || node === void 0 ? void 0 : node.type) === 'MethodDefinition' && node.kind === 'constructor' || /** @type {import('@typescript-eslint/types').TSESTree.MethodDefinition} */(node === null || node === void 0 || (_node$parent = node.parent) === null || _node$parent === void 0 ? void 0 : _node$parent.kind) === 'constructor'; -}; - -/** - * @param {import('eslint').Rule.Node|null} node - * @returns {boolean} - */ -const isGetter = node => { - var _node$parent2; - return node !== null && - /** - * @type {import('@typescript-eslint/types').TSESTree.MethodDefinition| - * import('@typescript-eslint/types').TSESTree.Property} - */ - ((_node$parent2 = node.parent) === null || _node$parent2 === void 0 ? void 0 : _node$parent2.kind) === 'get'; -}; - -/** - * @param {import('eslint').Rule.Node|null} node - * @returns {boolean} - */ -const isSetter = node => { - var _node$parent3; - return node !== null && - /** - * @type {import('@typescript-eslint/types').TSESTree.MethodDefinition| - * import('@typescript-eslint/types').TSESTree.Property} - */ - ((_node$parent3 = node.parent) === null || _node$parent3 === void 0 ? void 0 : _node$parent3.kind) === 'set'; -}; - -/** - * @param {import('eslint').Rule.Node} node - * @returns {boolean} - */ -const hasAccessorPair = node => { - const { - type, - kind: sourceKind, - key - } = - /** - * @type {import('@typescript-eslint/types').TSESTree.MethodDefinition| - * import('@typescript-eslint/types').TSESTree.Property} - */ - node; - const sourceName = /** @type {import('@typescript-eslint/types').TSESTree.Identifier} */key.name; - const oppositeKind = sourceKind === 'get' ? 'set' : 'get'; - const sibling = type === 'MethodDefinition' ? /** @type {import('@typescript-eslint/types').TSESTree.ClassBody} */node.parent.body : /** @type {import('@typescript-eslint/types').TSESTree.ObjectExpression} */node.parent.properties; - return sibling.some(child => { - const { - kind, - key: ky - } = - /** - * @type {import('@typescript-eslint/types').TSESTree.MethodDefinition| - * import('@typescript-eslint/types').TSESTree.Property} - */ - child; - const name = /** @type {import('@typescript-eslint/types').TSESTree.Identifier} */ky.name; - return kind === oppositeKind && name === sourceName; - }); -}; - -/** - * @param {import('./iterateJsdoc.js').JsdocBlockWithInline} jsdoc - * @param {import('eslint').Rule.Node|null} node - * @param {import('eslint').Rule.RuleContext} context - * @param {import('json-schema').JSONSchema4} schema - * @returns {boolean} - */ -const exemptSpeciaMethods = (jsdoc, node, context, schema) => { - /** - * @param {"checkGetters"|"checkSetters"|"checkConstructors"} prop - * @returns {boolean|"no-setter"|"no-getter"} - */ - const hasSchemaOption = prop => { - var _context$options$2; - const schemaProperties = schema[0].properties; - return ((_context$options$2 = context.options[0]) === null || _context$options$2 === void 0 ? void 0 : _context$options$2[prop]) ?? (schemaProperties[prop] && schemaProperties[prop].default); - }; - const checkGetters = hasSchemaOption('checkGetters'); - const checkSetters = hasSchemaOption('checkSetters'); - return !hasSchemaOption('checkConstructors') && (isConstructor(node) || hasATag(jsdoc, ['class', 'constructor'])) || isGetter(node) && (!checkGetters || checkGetters === 'no-setter' && hasAccessorPair( /** @type {import('./iterateJsdoc.js').Node} */node.parent)) || isSetter(node) && (!checkSetters || checkSetters === 'no-getter' && hasAccessorPair( /** @type {import('./iterateJsdoc.js').Node} */node.parent)); -}; - -/** - * Since path segments may be unquoted (if matching a reserved word, - * identifier or numeric literal) or single or double quoted, in either - * the `@param` or in source, we need to strip the quotes to give a fair - * comparison. - * @param {string} str - * @returns {string} - */ -const dropPathSegmentQuotes = str => { - return str.replaceAll(/\.(['"])(.*)\1/gu, '.$2'); -}; - -/** - * @param {string} name - * @returns {(otherPathName: string) => boolean} - */ -const comparePaths = name => { - return otherPathName => { - return otherPathName === name || dropPathSegmentQuotes(otherPathName) === dropPathSegmentQuotes(name); - }; -}; - -/** - * @callback PathDoesNotBeginWith - * @param {string} name - * @param {string} otherPathName - * @returns {boolean} - */ - -/** @type {PathDoesNotBeginWith} */ -const pathDoesNotBeginWith = (name, otherPathName) => { - return !name.startsWith(otherPathName) && !dropPathSegmentQuotes(name).startsWith(dropPathSegmentQuotes(otherPathName)); -}; - -/** - * @param {string} regexString - * @param {string} [requiredFlags] - * @returns {RegExp} - */ -const getRegexFromString = (regexString, requiredFlags) => { - const match = regexString.match(/^\/(.*)\/([gimyus]*)$/us); - let flags = 'u'; - let regex = regexString; - if (match) { - [, regex, flags] = match; - if (!flags) { - flags = 'u'; - } - } - const uniqueFlags = [...new Set(flags + (requiredFlags || ''))]; - flags = uniqueFlags.join(''); - return new RegExp(regex, flags); -}; -var _default = exports.default = { - comparePaths, - dropPathSegmentQuotes, - enforcedContexts, - exemptSpeciaMethods, - flattenRoots, - getAllTags, - getContextObject, - getFunctionParameterNames, - getIndent, - getJsdocTagsDeep, - getPreferredTagName, - getRegexFromString, - getTagsByType, - getTagStructureForMode, - hasATag, - hasParams, - hasReturnValue: _hasReturnValue.hasReturnValue, - hasTag, - hasThrowValue, - hasValueOrExecutorHasNonEmptyResolveValue: _hasReturnValue.hasValueOrExecutorHasNonEmptyResolveValue, - hasYieldValue, - isConstructor, - isGetter, - isNamepathDefiningTag, - isNamepathOrUrlReferencingTag, - isNamepathReferencingTag, - isSetter, - isValidTag, - mayBeUndefinedTypeTag, - overrideTagStructure, - parseClosureTemplateTag, - pathDoesNotBeginWith, - setTagStructure, - tagMightHaveEitherTypeOrNamePosition, - tagMightHaveNamepath, - tagMightHaveNamePosition, - tagMightHaveTypePosition, - tagMissingRequiredTypeOrNamepath, - tagMustHaveNamePosition, - tagMustHaveTypePosition -}; -module.exports = exports.default; -//# sourceMappingURL=jsdocUtils.cjs.map \ No newline at end of file diff --git a/tools/eslint/node_modules/eslint-plugin-jsdoc/dist/rules/checkAccess.cjs b/tools/eslint/node_modules/eslint-plugin-jsdoc/dist/rules/checkAccess.cjs deleted file mode 100644 index 93b4918191ae6d..00000000000000 --- a/tools/eslint/node_modules/eslint-plugin-jsdoc/dist/rules/checkAccess.cjs +++ /dev/null @@ -1,40 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.default = void 0; -var _iterateJsdoc = _interopRequireDefault(require("../iterateJsdoc.cjs")); -function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; } -const accessLevels = ['package', 'private', 'protected', 'public']; -var _default = exports.default = (0, _iterateJsdoc.default)(({ - report, - utils -}) => { - utils.forEachPreferredTag('access', (jsdocParameter, targetTagName) => { - const desc = jsdocParameter.name + ' ' + jsdocParameter.description; - if (!accessLevels.includes(desc.trim())) { - report(`Missing valid JSDoc @${targetTagName} level.`, null, jsdocParameter); - } - }); - const accessLength = utils.getTags('access').length; - const individualTagLength = utils.getPresentTags(accessLevels).length; - if (accessLength && individualTagLength) { - report('The @access tag may not be used with specific access-control tags (@package, @private, @protected, or @public).'); - } - if (accessLength > 1 || individualTagLength > 1) { - report('At most one access-control tag may be present on a jsdoc block.'); - } -}, { - checkPrivate: true, - iterateAllJsdocs: true, - meta: { - docs: { - description: 'Checks that `@access` tags have a valid value.', - url: 'https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/check-access.md#repos-sticky-header' - }, - type: 'suggestion' - } -}); -module.exports = exports.default; -//# sourceMappingURL=checkAccess.cjs.map \ No newline at end of file diff --git a/tools/eslint/node_modules/eslint-plugin-jsdoc/dist/rules/checkAlignment.cjs b/tools/eslint/node_modules/eslint-plugin-jsdoc/dist/rules/checkAlignment.cjs deleted file mode 100644 index bf4dc50ae0339f..00000000000000 --- a/tools/eslint/node_modules/eslint-plugin-jsdoc/dist/rules/checkAlignment.cjs +++ /dev/null @@ -1,60 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.default = void 0; -var _iterateJsdoc = _interopRequireDefault(require("../iterateJsdoc.cjs")); -function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; } -/** - * @param {string} string - * @returns {string} - */ -const trimStart = string => { - return string.replace(/^\s+/u, ''); -}; -var _default = exports.default = (0, _iterateJsdoc.default)(({ - sourceCode, - jsdocNode, - report, - indent -}) => { - // `indent` is whitespace from line 1 (`/**`), so slice and account for "/". - const indentLevel = indent.length + 1; - const sourceLines = sourceCode.getText(jsdocNode).split('\n').slice(1).map(line => { - return line.split('*')[0]; - }).filter(line => { - return !trimStart(line).length; - }); - - /** @type {import('eslint').Rule.ReportFixer} */ - const fix = fixer => { - const replacement = sourceCode.getText(jsdocNode).split('\n').map((line, index) => { - // Ignore the first line and all lines not starting with `*` - const ignored = !index || trimStart(line.split('*')[0]).length; - return ignored ? line : `${indent} ${trimStart(line)}`; - }).join('\n'); - return fixer.replaceText(jsdocNode, replacement); - }; - sourceLines.some((line, lineNum) => { - if (line.length !== indentLevel) { - report('Expected JSDoc block to be aligned.', fix, { - line: lineNum + 1 - }); - return true; - } - return false; - }); -}, { - iterateAllJsdocs: true, - meta: { - docs: { - description: 'Reports invalid alignment of JSDoc block asterisks.', - url: 'https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/check-alignment.md#repos-sticky-header' - }, - fixable: 'code', - type: 'layout' - } -}); -module.exports = exports.default; -//# sourceMappingURL=checkAlignment.cjs.map \ No newline at end of file diff --git a/tools/eslint/node_modules/eslint-plugin-jsdoc/dist/rules/checkExamples.cjs b/tools/eslint/node_modules/eslint-plugin-jsdoc/dist/rules/checkExamples.cjs deleted file mode 100644 index d2bb764646f969..00000000000000 --- a/tools/eslint/node_modules/eslint-plugin-jsdoc/dist/rules/checkExamples.cjs +++ /dev/null @@ -1,512 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.default = void 0; -var _iterateJsdoc = _interopRequireDefault(require("../iterateJsdoc.cjs")); -var _eslint = _interopRequireWildcard(require("eslint")); -var _semver = _interopRequireDefault(require("semver")); -function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); } -function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; } -function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; } -// Todo: When replace `CLIEngine` with `ESLint` when feature set complete per https://github.com/eslint/eslint/issues/14745 -// https://github.com/eslint/eslint/blob/master/docs/user-guide/migrating-to-7.0.0.md#-the-cliengine-class-has-been-deprecated - -const { - // @ts-expect-error Older ESLint - CLIEngine -} = _eslint.default; -const zeroBasedLineIndexAdjust = -1; -const likelyNestedJSDocIndentSpace = 1; -const preTagSpaceLength = 1; - -// If a space is present, we should ignore it -const firstLinePrefixLength = preTagSpaceLength; -const hasCaptionRegex = /^\s*([\s\S]*?)<\/caption>/u; - -/** - * @param {string} str - * @returns {string} - */ -const escapeStringRegexp = str => { - return str.replaceAll(/[.*+?^${}()|[\]\\]/gu, '\\$&'); -}; - -/** - * @param {string} str - * @param {string} ch - * @returns {import('../iterateJsdoc.js').Integer} - */ -const countChars = (str, ch) => { - return (str.match(new RegExp(escapeStringRegexp(ch), 'gu')) || []).length; -}; - -/** @type {import('eslint').Linter.RulesRecord} */ -const defaultMdRules = { - // "always" newline rule at end unlikely in sample code - 'eol-last': 0, - // Wouldn't generally expect example paths to resolve relative to JS file - 'import/no-unresolved': 0, - // Snippets likely too short to always include import/export info - 'import/unambiguous': 0, - 'jsdoc/require-file-overview': 0, - // The end of a multiline comment would end the comment the example is in. - 'jsdoc/require-jsdoc': 0, - // Unlikely to have inadvertent debugging within examples - 'no-console': 0, - // Often wish to start `@example` code after newline; also may use - // empty lines for spacing - 'no-multiple-empty-lines': 0, - // Many variables in examples will be `undefined` - 'no-undef': 0, - // Common to define variables for clarity without always using them - 'no-unused-vars': 0, - // See import/no-unresolved - 'node/no-missing-import': 0, - 'node/no-missing-require': 0, - // Can generally look nicer to pad a little even if code imposes more stringency - 'padded-blocks': 0 -}; - -/** @type {import('eslint').Linter.RulesRecord} */ -const defaultExpressionRules = { - ...defaultMdRules, - 'chai-friendly/no-unused-expressions': 'off', - 'no-empty-function': 'off', - 'no-new': 'off', - 'no-unused-expressions': 'off', - quotes: ['error', 'double'], - semi: ['error', 'never'], - strict: 'off' -}; - -/** - * @param {string} text - * @returns {[ - * import('../iterateJsdoc.js').Integer, - * import('../iterateJsdoc.js').Integer - * ]} - */ -const getLinesCols = text => { - const matchLines = countChars(text, '\n'); - const colDelta = matchLines ? text.slice(text.lastIndexOf('\n') + 1).length : text.length; - return [matchLines, colDelta]; -}; -var _default = exports.default = (0, _iterateJsdoc.default)(({ - report, - utils, - context, - globalState -}) => { - if (_semver.default.gte(_eslint.ESLint.version, '8.0.0')) { - report('This rule cannot yet be supported for ESLint 8; you ' + 'should either downgrade to ESLint 7 or disable this rule. The ' + 'possibility for ESLint 8 support is being tracked at https://github.com/eslint/eslint/issues/14745', null, { - column: 1, - line: 1 - }); - return; - } - if (!globalState.has('checkExamples-matchingFileName')) { - globalState.set('checkExamples-matchingFileName', new Map()); - } - const matchingFileNameMap = /** @type {Map} */ - globalState.get('checkExamples-matchingFileName'); - const options = context.options[0] || {}; - let { - exampleCodeRegex = null, - rejectExampleCodeRegex = null - } = options; - const { - checkDefaults = false, - checkParams = false, - checkProperties = false, - noDefaultExampleRules = false, - checkEslintrc = true, - matchingFileName = null, - matchingFileNameDefaults = null, - matchingFileNameParams = null, - matchingFileNameProperties = null, - paddedIndent = 0, - baseConfig = {}, - configFile, - allowInlineConfig = true, - reportUnusedDisableDirectives = true, - captionRequired = false - } = options; - - // Make this configurable? - /** - * @type {never[]} - */ - const rulePaths = []; - const mdRules = noDefaultExampleRules ? undefined : defaultMdRules; - const expressionRules = noDefaultExampleRules ? undefined : defaultExpressionRules; - if (exampleCodeRegex) { - exampleCodeRegex = utils.getRegexFromString(exampleCodeRegex); - } - if (rejectExampleCodeRegex) { - rejectExampleCodeRegex = utils.getRegexFromString(rejectExampleCodeRegex); - } - - /** - * @param {{ - * filename: string, - * defaultFileName: string|undefined, - * source: string, - * targetTagName: string, - * rules?: import('eslint').Linter.RulesRecord|undefined, - * lines?: import('../iterateJsdoc.js').Integer, - * cols?: import('../iterateJsdoc.js').Integer, - * skipInit?: boolean, - * sources?: { - * nonJSPrefacingCols: import('../iterateJsdoc.js').Integer, - * nonJSPrefacingLines: import('../iterateJsdoc.js').Integer, - * string: string, - * }[], - * tag?: import('comment-parser').Spec & { - * line?: import('../iterateJsdoc.js').Integer, - * }|{ - * line: import('../iterateJsdoc.js').Integer, - * } - * }} cfg - */ - const checkSource = ({ - filename, - defaultFileName, - rules = expressionRules, - lines = 0, - cols = 0, - skipInit, - source, - targetTagName, - sources = [], - tag = { - line: 0 - } - }) => { - if (!skipInit) { - sources.push({ - nonJSPrefacingCols: cols, - nonJSPrefacingLines: lines, - string: source - }); - } - - // Todo: Make fixable - - /** - * @param {{ - * nonJSPrefacingCols: import('../iterateJsdoc.js').Integer, - * nonJSPrefacingLines: import('../iterateJsdoc.js').Integer, - * string: string - * }} cfg - */ - const checkRules = function ({ - nonJSPrefacingCols, - nonJSPrefacingLines, - string - }) { - const cliConfig = { - allowInlineConfig, - baseConfig, - configFile, - reportUnusedDisableDirectives, - rulePaths, - rules, - useEslintrc: checkEslintrc - }; - const cliConfigStr = JSON.stringify(cliConfig); - const src = paddedIndent ? string.replaceAll(new RegExp(`(^|\n) {${paddedIndent}}(?!$)`, 'gu'), '\n') : string; - - // Programmatic ESLint API: https://eslint.org/docs/developer-guide/nodejs-api - const fileNameMapKey = filename ? 'a' + cliConfigStr + filename : 'b' + cliConfigStr + defaultFileName; - const file = filename || defaultFileName; - let cliFile; - if (matchingFileNameMap.has(fileNameMapKey)) { - cliFile = matchingFileNameMap.get(fileNameMapKey); - } else { - const cli = new CLIEngine(cliConfig); - let config; - if (filename || checkEslintrc) { - config = cli.getConfigForFile(file); - } - - // We need a new instance to ensure that the rules that may only - // be available to `file` (if it has its own `.eslintrc`), - // will be defined. - cliFile = new CLIEngine({ - allowInlineConfig, - baseConfig: { - ...baseConfig, - ...config - }, - configFile, - reportUnusedDisableDirectives, - rulePaths, - rules, - useEslintrc: false - }); - matchingFileNameMap.set(fileNameMapKey, cliFile); - } - const { - results: [{ - messages - }] - } = cliFile.executeOnText(src); - if (!('line' in tag)) { - tag.line = tag.source[0].number; - } - - // NOTE: `tag.line` can be 0 if of form `/** @tag ... */` - const codeStartLine = - /** - * @type {import('comment-parser').Spec & { - * line: import('../iterateJsdoc.js').Integer, - * }} - */ - tag.line + nonJSPrefacingLines; - const codeStartCol = likelyNestedJSDocIndentSpace; - for (const { - message, - line, - column, - severity, - ruleId - } of messages) { - const startLine = codeStartLine + line + zeroBasedLineIndexAdjust; - const startCol = codeStartCol + ( - // This might not work for line 0, but line 0 is unlikely for examples - line <= 1 ? nonJSPrefacingCols + firstLinePrefixLength : preTagSpaceLength) + column; - report('@' + targetTagName + ' ' + (severity === 2 ? 'error' : 'warning') + (ruleId ? ' (' + ruleId + ')' : '') + ': ' + message, null, { - column: startCol, - line: startLine - }); - } - }; - for (const targetSource of sources) { - checkRules(targetSource); - } - }; - - /** - * - * @param {string} filename - * @param {string} [ext] Since `eslint-plugin-markdown` v2, and - * ESLint 7, this is the default which other JS-fenced rules will used. - * Formerly "md" was the default. - * @returns {{defaultFileName: string|undefined, filename: string}} - */ - const getFilenameInfo = (filename, ext = 'md/*.js') => { - let defaultFileName; - if (!filename) { - const jsFileName = context.getFilename(); - if (typeof jsFileName === 'string' && jsFileName.includes('.')) { - defaultFileName = jsFileName.replace(/\.[^.]*$/u, `.${ext}`); - } else { - defaultFileName = `dummy.${ext}`; - } - } - return { - defaultFileName, - filename - }; - }; - if (checkDefaults) { - const filenameInfo = getFilenameInfo(matchingFileNameDefaults, 'jsdoc-defaults'); - utils.forEachPreferredTag('default', (tag, targetTagName) => { - if (!tag.description.trim()) { - return; - } - checkSource({ - source: `(${utils.getTagDescription(tag)})`, - targetTagName, - ...filenameInfo - }); - }); - } - if (checkParams) { - const filenameInfo = getFilenameInfo(matchingFileNameParams, 'jsdoc-params'); - utils.forEachPreferredTag('param', (tag, targetTagName) => { - if (!tag.default || !tag.default.trim()) { - return; - } - checkSource({ - source: `(${tag.default})`, - targetTagName, - ...filenameInfo - }); - }); - } - if (checkProperties) { - const filenameInfo = getFilenameInfo(matchingFileNameProperties, 'jsdoc-properties'); - utils.forEachPreferredTag('property', (tag, targetTagName) => { - if (!tag.default || !tag.default.trim()) { - return; - } - checkSource({ - source: `(${tag.default})`, - targetTagName, - ...filenameInfo - }); - }); - } - const tagName = /** @type {string} */utils.getPreferredTagName({ - tagName: 'example' - }); - if (!utils.hasTag(tagName)) { - return; - } - const matchingFilenameInfo = getFilenameInfo(matchingFileName); - utils.forEachPreferredTag('example', (tag, targetTagName) => { - let source = /** @type {string} */utils.getTagDescription(tag); - const match = source.match(hasCaptionRegex); - if (captionRequired && (!match || !match[1].trim())) { - report('Caption is expected for examples.', null, tag); - } - source = source.replace(hasCaptionRegex, ''); - const [lines, cols] = match ? getLinesCols(match[0]) : [0, 0]; - if (exampleCodeRegex && !exampleCodeRegex.test(source) || rejectExampleCodeRegex && rejectExampleCodeRegex.test(source)) { - return; - } - const sources = []; - let skipInit = false; - if (exampleCodeRegex) { - let nonJSPrefacingCols = 0; - let nonJSPrefacingLines = 0; - let startingIndex = 0; - let lastStringCount = 0; - let exampleCode; - exampleCodeRegex.lastIndex = 0; - while ((exampleCode = exampleCodeRegex.exec(source)) !== null) { - const { - index, - '0': n0, - '1': n1 - } = exampleCode; - - // Count anything preceding user regex match (can affect line numbering) - const preMatch = source.slice(startingIndex, index); - const [preMatchLines, colDelta] = getLinesCols(preMatch); - let nonJSPreface; - let nonJSPrefaceLineCount; - if (n1) { - const idx = n0.indexOf(n1); - nonJSPreface = n0.slice(0, idx); - nonJSPrefaceLineCount = countChars(nonJSPreface, '\n'); - } else { - nonJSPreface = ''; - nonJSPrefaceLineCount = 0; - } - nonJSPrefacingLines += lastStringCount + preMatchLines + nonJSPrefaceLineCount; - - // Ignore `preMatch` delta if newlines here - if (nonJSPrefaceLineCount) { - const charsInLastLine = nonJSPreface.slice(nonJSPreface.lastIndexOf('\n') + 1).length; - nonJSPrefacingCols += charsInLastLine; - } else { - nonJSPrefacingCols += colDelta + nonJSPreface.length; - } - const string = n1 || n0; - sources.push({ - nonJSPrefacingCols, - nonJSPrefacingLines, - string - }); - startingIndex = exampleCodeRegex.lastIndex; - lastStringCount = countChars(string, '\n'); - if (!exampleCodeRegex.global) { - break; - } - } - skipInit = true; - } - checkSource({ - cols, - lines, - rules: mdRules, - skipInit, - source, - sources, - tag, - targetTagName, - ...matchingFilenameInfo - }); - }); -}, { - iterateAllJsdocs: true, - meta: { - docs: { - description: 'Ensures that (JavaScript) examples within JSDoc adhere to ESLint rules.', - url: 'https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/check-examples.md#repos-sticky-header' - }, - schema: [{ - additionalProperties: false, - properties: { - allowInlineConfig: { - default: true, - type: 'boolean' - }, - baseConfig: { - type: 'object' - }, - captionRequired: { - default: false, - type: 'boolean' - }, - checkDefaults: { - default: false, - type: 'boolean' - }, - checkEslintrc: { - default: true, - type: 'boolean' - }, - checkParams: { - default: false, - type: 'boolean' - }, - checkProperties: { - default: false, - type: 'boolean' - }, - configFile: { - type: 'string' - }, - exampleCodeRegex: { - type: 'string' - }, - matchingFileName: { - type: 'string' - }, - matchingFileNameDefaults: { - type: 'string' - }, - matchingFileNameParams: { - type: 'string' - }, - matchingFileNameProperties: { - type: 'string' - }, - noDefaultExampleRules: { - default: false, - type: 'boolean' - }, - paddedIndent: { - default: 0, - type: 'integer' - }, - rejectExampleCodeRegex: { - type: 'string' - }, - reportUnusedDisableDirectives: { - default: true, - type: 'boolean' - } - }, - type: 'object' - }], - type: 'suggestion' - } -}); -module.exports = exports.default; -//# sourceMappingURL=checkExamples.cjs.map \ No newline at end of file diff --git a/tools/eslint/node_modules/eslint-plugin-jsdoc/dist/rules/checkIndentation.cjs b/tools/eslint/node_modules/eslint-plugin-jsdoc/dist/rules/checkIndentation.cjs deleted file mode 100644 index 23b096587de35e..00000000000000 --- a/tools/eslint/node_modules/eslint-plugin-jsdoc/dist/rules/checkIndentation.cjs +++ /dev/null @@ -1,74 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.default = void 0; -var _iterateJsdoc = _interopRequireDefault(require("../iterateJsdoc.cjs")); -function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; } -/** - * @param {string} str - * @param {string[]} excludeTags - * @returns {string} - */ -const maskExcludedContent = (str, excludeTags) => { - const regContent = new RegExp(`([ \\t]+\\*)[ \\t]@(?:${excludeTags.join('|')})(?=[ \\n])([\\w|\\W]*?\\n)(?=[ \\t]*\\*(?:[ \\t]*@\\w+\\s|\\/))`, 'gu'); - return str.replace(regContent, (_match, margin, code) => { - return (margin + '\n').repeat(code.match(/\n/gu).length); - }); -}; - -/** - * @param {string} str - * @returns {string} - */ -const maskCodeBlocks = str => { - const regContent = /([ \t]+\*)[ \t]```[^\n]*?([\w|\W]*?\n)(?=[ \t]*\*(?:[ \t]*(?:```|@\w+\s)|\/))/gu; - return str.replaceAll(regContent, (_match, margin, code) => { - return (margin + '\n').repeat(code.match(/\n/gu).length); - }); -}; -var _default = exports.default = (0, _iterateJsdoc.default)(({ - sourceCode, - jsdocNode, - report, - context -}) => { - const options = context.options[0] || {}; - const /** @type {{excludeTags: string[]}} */{ - excludeTags = ['example'] - } = options; - const reg = /^(?:\/?\**|[ \t]*)\*[ \t]{2}/gmu; - const textWithoutCodeBlocks = maskCodeBlocks(sourceCode.getText(jsdocNode)); - const text = excludeTags.length ? maskExcludedContent(textWithoutCodeBlocks, excludeTags) : textWithoutCodeBlocks; - if (reg.test(text)) { - const lineBreaks = text.slice(0, reg.lastIndex).match(/\n/gu) || []; - report('There must be no indentation.', null, { - line: lineBreaks.length - }); - } -}, { - iterateAllJsdocs: true, - meta: { - docs: { - description: 'Reports invalid padding inside JSDoc blocks.', - url: 'https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/check-indentation.md#repos-sticky-header' - }, - schema: [{ - additionalProperties: false, - properties: { - excludeTags: { - items: { - pattern: '^\\S+$', - type: 'string' - }, - type: 'array' - } - }, - type: 'object' - }], - type: 'layout' - } -}); -module.exports = exports.default; -//# sourceMappingURL=checkIndentation.cjs.map \ No newline at end of file diff --git a/tools/eslint/node_modules/eslint-plugin-jsdoc/dist/rules/checkLineAlignment.cjs b/tools/eslint/node_modules/eslint-plugin-jsdoc/dist/rules/checkLineAlignment.cjs deleted file mode 100644 index 7730ae6d8b4dce..00000000000000 --- a/tools/eslint/node_modules/eslint-plugin-jsdoc/dist/rules/checkLineAlignment.cjs +++ /dev/null @@ -1,321 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.default = void 0; -var _alignTransform = _interopRequireDefault(require("../alignTransform.cjs")); -var _iterateJsdoc = _interopRequireDefault(require("../iterateJsdoc.cjs")); -var _commentParser = require("comment-parser"); -function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; } -const { - flow: commentFlow -} = _commentParser.transforms; - -/** - * @typedef {{ - * postDelimiter: import('../iterateJsdoc.js').Integer, - * postHyphen: import('../iterateJsdoc.js').Integer, - * postName: import('../iterateJsdoc.js').Integer, - * postTag: import('../iterateJsdoc.js').Integer, - * postType: import('../iterateJsdoc.js').Integer, - * }} CustomSpacings - */ - -/** - * @param {import('../iterateJsdoc.js').Utils} utils - * @param {import('comment-parser').Spec & { - * line: import('../iterateJsdoc.js').Integer - * }} tag - * @param {CustomSpacings} customSpacings - */ -const checkNotAlignedPerTag = (utils, tag, customSpacings) => { - /* - start + - delimiter + - postDelimiter + - tag + - postTag + - type + - postType + - name + - postName + - description + - end + - lineEnd - */ - - /** - * @typedef {"tag"|"type"|"name"|"description"} ContentProp - */ - - /** @type {("postDelimiter"|"postTag"|"postType"|"postName")[]} */ - let spacerProps; - /** @type {ContentProp[]} */ - let contentProps; - const mightHaveNamepath = utils.tagMightHaveNamepath(tag.tag); - if (mightHaveNamepath) { - spacerProps = ['postDelimiter', 'postTag', 'postType', 'postName']; - contentProps = ['tag', 'type', 'name', 'description']; - } else { - spacerProps = ['postDelimiter', 'postTag', 'postType']; - contentProps = ['tag', 'type', 'description']; - } - const { - tokens - } = tag.source[0]; - - /** - * @param {import('../iterateJsdoc.js').Integer} idx - * @param {(notRet: boolean, contentProp: ContentProp) => void} [callbck] - */ - const followedBySpace = (idx, callbck) => { - const nextIndex = idx + 1; - return spacerProps.slice(nextIndex).some((spacerProp, innerIdx) => { - const contentProp = contentProps[nextIndex + innerIdx]; - const spacePropVal = tokens[spacerProp]; - const ret = spacePropVal; - if (callbck) { - callbck(!ret, contentProp); - } - return ret && (callbck || !contentProp); - }); - }; - const postHyphenSpacing = (customSpacings === null || customSpacings === void 0 ? void 0 : customSpacings.postHyphen) ?? 1; - const exactHyphenSpacing = new RegExp(`^\\s*-\\s{${postHyphenSpacing},${postHyphenSpacing}}(?!\\s)`, 'u'); - const hasNoHyphen = !/^\s*-(?!$)(?=\s)/u.test(tokens.description); - const hasExactHyphenSpacing = exactHyphenSpacing.test(tokens.description); - - // If checking alignment on multiple lines, need to check other `source` - // items - // Go through `post*` spacing properties and exit to indicate problem if - // extra spacing detected - const ok = !spacerProps.some((spacerProp, idx) => { - const contentProp = contentProps[idx]; - const contentPropVal = tokens[contentProp]; - const spacerPropVal = tokens[spacerProp]; - const spacing = (customSpacings === null || customSpacings === void 0 ? void 0 : customSpacings[spacerProp]) || 1; - - // There will be extra alignment if... - - // 1. The spaces don't match the space it should have (1 or custom spacing) OR - return spacerPropVal.length !== spacing && spacerPropVal.length !== 0 || - // 2. There is a (single) space, no immediate content, and yet another - // space is found subsequently (not separated by intervening content) - spacerPropVal && !contentPropVal && followedBySpace(idx); - }) && (hasNoHyphen || hasExactHyphenSpacing); - if (ok) { - return; - } - const fix = () => { - for (const [idx, spacerProp] of spacerProps.entries()) { - const contentProp = contentProps[idx]; - const contentPropVal = tokens[contentProp]; - if (contentPropVal) { - const spacing = (customSpacings === null || customSpacings === void 0 ? void 0 : customSpacings[spacerProp]) || 1; - tokens[spacerProp] = ''.padStart(spacing, ' '); - followedBySpace(idx, (hasSpace, contentPrp) => { - if (hasSpace) { - tokens[contentPrp] = ''; - } - }); - } else { - tokens[spacerProp] = ''; - } - } - if (!hasExactHyphenSpacing) { - const hyphenSpacing = /^\s*-\s+/u; - tokens.description = tokens.description.replace(hyphenSpacing, '-' + ''.padStart(postHyphenSpacing, ' ')); - } - utils.setTag(tag, tokens); - }; - utils.reportJSDoc('Expected JSDoc block lines to not be aligned.', tag, fix, true); -}; - -/** - * @param {object} cfg - * @param {CustomSpacings} cfg.customSpacings - * @param {string} cfg.indent - * @param {import('comment-parser').Block} cfg.jsdoc - * @param {import('eslint').Rule.Node & { - * range: [number, number] - * }} cfg.jsdocNode - * @param {boolean} cfg.preserveMainDescriptionPostDelimiter - * @param {import('../iterateJsdoc.js').Report} cfg.report - * @param {string[]} cfg.tags - * @param {import('../iterateJsdoc.js').Utils} cfg.utils - * @param {string} cfg.wrapIndent - * @param {boolean} cfg.disableWrapIndent - * @returns {void} - */ -const checkAlignment = ({ - customSpacings, - indent, - jsdoc, - jsdocNode, - preserveMainDescriptionPostDelimiter, - report, - tags, - utils, - wrapIndent, - disableWrapIndent -}) => { - const transform = commentFlow((0, _alignTransform.default)({ - customSpacings, - indent, - preserveMainDescriptionPostDelimiter, - tags, - wrapIndent, - disableWrapIndent - })); - const transformedJsdoc = transform(jsdoc); - const comment = '/*' + - /** - * @type {import('eslint').Rule.Node & { - * range: [number, number], value: string - * }} - */ - jsdocNode.value + '*/'; - const formatted = utils.stringify(transformedJsdoc).trimStart(); - if (comment !== formatted) { - report('Expected JSDoc block lines to be aligned.', /** @type {import('eslint').Rule.ReportFixer} */fixer => { - return fixer.replaceText(jsdocNode, formatted); - }); - } -}; -var _default = exports.default = (0, _iterateJsdoc.default)(({ - indent, - jsdoc, - jsdocNode, - report, - context, - utils -}) => { - const { - tags: applicableTags = ['param', 'arg', 'argument', 'property', 'prop', 'returns', 'return'], - preserveMainDescriptionPostDelimiter, - customSpacings, - wrapIndent = '', - disableWrapIndent = false - } = context.options[1] || {}; - if (context.options[0] === 'always') { - // Skip if it contains only a single line. - if (!( - /** - * @type {import('eslint').Rule.Node & { - * range: [number, number], value: string - * }} - */ - jsdocNode.value.includes('\n'))) { - return; - } - checkAlignment({ - customSpacings, - indent, - jsdoc, - jsdocNode, - preserveMainDescriptionPostDelimiter, - report, - tags: applicableTags, - utils, - wrapIndent, - disableWrapIndent - }); - return; - } - const foundTags = utils.getPresentTags(applicableTags); - if (context.options[0] !== 'any') { - for (const tag of foundTags) { - checkNotAlignedPerTag(utils, - /** - * @type {import('comment-parser').Spec & { - * line: import('../iterateJsdoc.js').Integer - * }} - */ - tag, customSpacings); - } - } - for (const tag of foundTags) { - if (tag.source.length > 1) { - let idx = 0; - for (const { - tokens - // Avoid the tag line - } of tag.source.slice(1)) { - idx++; - if (!tokens.description || - // Avoid first lines after multiline type - tokens.type || tokens.name) { - continue; - } - - // Don't include a single separating space/tab - if (!disableWrapIndent && tokens.postDelimiter.slice(1) !== wrapIndent) { - utils.reportJSDoc('Expected wrap indent', { - line: tag.source[0].number + idx - }, () => { - tokens.postDelimiter = tokens.postDelimiter.charAt(0) + wrapIndent; - }); - return; - } - } - } - } -}, { - iterateAllJsdocs: true, - meta: { - docs: { - description: 'Reports invalid alignment of JSDoc block lines.', - url: 'https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/check-line-alignment.md#repos-sticky-header' - }, - fixable: 'whitespace', - schema: [{ - enum: ['always', 'never', 'any'], - type: 'string' - }, { - additionalProperties: false, - properties: { - customSpacings: { - additionalProperties: false, - properties: { - postDelimiter: { - type: 'integer' - }, - postHyphen: { - type: 'integer' - }, - postName: { - type: 'integer' - }, - postTag: { - type: 'integer' - }, - postType: { - type: 'integer' - } - } - }, - preserveMainDescriptionPostDelimiter: { - default: false, - type: 'boolean' - }, - tags: { - items: { - type: 'string' - }, - type: 'array' - }, - wrapIndent: { - type: 'string' - }, - disableWrapIndent: { - type: 'boolean' - } - }, - type: 'object' - }], - type: 'layout' - } -}); -module.exports = exports.default; -//# sourceMappingURL=checkLineAlignment.cjs.map \ No newline at end of file diff --git a/tools/eslint/node_modules/eslint-plugin-jsdoc/dist/rules/checkParamNames.cjs b/tools/eslint/node_modules/eslint-plugin-jsdoc/dist/rules/checkParamNames.cjs deleted file mode 100644 index 05f95d365bbfbe..00000000000000 --- a/tools/eslint/node_modules/eslint-plugin-jsdoc/dist/rules/checkParamNames.cjs +++ /dev/null @@ -1,329 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.default = void 0; -var _iterateJsdoc = _interopRequireDefault(require("../iterateJsdoc.cjs")); -function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; } -/** - * @param {string} targetTagName - * @param {boolean} allowExtraTrailingParamDocs - * @param {boolean} checkDestructured - * @param {boolean} checkRestProperty - * @param {RegExp} checkTypesRegex - * @param {boolean} disableExtraPropertyReporting - * @param {boolean} disableMissingParamChecks - * @param {boolean} enableFixer - * @param {import('../jsdocUtils.js').ParamNameInfo[]} functionParameterNames - * @param {import('comment-parser').Block} jsdoc - * @param {import('../iterateJsdoc.js').Utils} utils - * @param {import('../iterateJsdoc.js').Report} report - * @returns {boolean} - */ -const validateParameterNames = (targetTagName, allowExtraTrailingParamDocs, checkDestructured, checkRestProperty, checkTypesRegex, disableExtraPropertyReporting, disableMissingParamChecks, enableFixer, functionParameterNames, jsdoc, utils, report) => { - const paramTags = Object.entries(jsdoc.tags).filter(([, tag]) => { - return tag.tag === targetTagName; - }); - const paramTagsNonNested = paramTags.filter(([, tag]) => { - return !tag.name.includes('.'); - }); - let dotted = 0; - let thisOffset = 0; - - // eslint-disable-next-line complexity - return paramTags.some(([, tag], index) => { - /** @type {import('../iterateJsdoc.js').Integer} */ - let tagsIndex; - const dupeTagInfo = paramTags.find(([tgsIndex, tg], idx) => { - tagsIndex = Number(tgsIndex); - return tg.name === tag.name && idx !== index; - }); - if (dupeTagInfo) { - utils.reportJSDoc(`Duplicate @${targetTagName} "${tag.name}"`, dupeTagInfo[1], enableFixer ? () => { - utils.removeTag(tagsIndex); - } : null); - return true; - } - if (tag.name.includes('.')) { - dotted++; - return false; - } - let functionParameterName = functionParameterNames[index - dotted + thisOffset]; - if (functionParameterName === 'this' && tag.name.trim() !== 'this') { - ++thisOffset; - functionParameterName = functionParameterNames[index - dotted + thisOffset]; - } - if (!functionParameterName) { - if (allowExtraTrailingParamDocs) { - return false; - } - report(`@${targetTagName} "${tag.name}" does not match an existing function parameter.`, null, tag); - return true; - } - if (typeof functionParameterName === 'object' && 'name' in functionParameterName && Array.isArray(functionParameterName.name)) { - const actualName = tag.name.trim(); - const expectedName = functionParameterName.name[index]; - if (actualName === expectedName) { - thisOffset--; - return false; - } - report(`Expected @${targetTagName} name to be "${expectedName}". Got "${actualName}".`, null, tag); - return true; - } - if (Array.isArray(functionParameterName)) { - if (!checkDestructured) { - return false; - } - if (tag.type && tag.type.search(checkTypesRegex) === -1) { - return false; - } - const [parameterName, { - names: properties, - hasPropertyRest, - rests, - annotationParamName - }] = - /** - * @type {[string | undefined, import('../jsdocUtils.js').FlattendRootInfo & { - * annotationParamName?: string | undefined; - }]} */ - functionParameterName; - if (annotationParamName !== undefined) { - const name = tag.name.trim(); - if (name !== annotationParamName) { - report(`@${targetTagName} "${name}" does not match parameter name "${annotationParamName}"`, null, tag); - } - } - const tagName = parameterName === undefined ? tag.name.trim() : parameterName; - const expectedNames = properties.map(name => { - return `${tagName}.${name}`; - }); - const actualNames = paramTags.map(([, paramTag]) => { - return paramTag.name.trim(); - }); - const actualTypes = paramTags.map(([, paramTag]) => { - return paramTag.type; - }); - const missingProperties = []; - - /** @type {string[]} */ - const notCheckingNames = []; - for (const [idx, name] of expectedNames.entries()) { - if (notCheckingNames.some(notCheckingName => { - return name.startsWith(notCheckingName); - })) { - continue; - } - const actualNameIdx = actualNames.findIndex(actualName => { - return utils.comparePaths(name)(actualName); - }); - if (actualNameIdx === -1) { - if (!checkRestProperty && rests[idx]) { - continue; - } - const missingIndex = actualNames.findIndex(actualName => { - return utils.pathDoesNotBeginWith(name, actualName); - }); - const line = tag.source[0].number - 1 + (missingIndex > -1 ? missingIndex : actualNames.length); - missingProperties.push({ - name, - tagPlacement: { - line: line === 0 ? 1 : line - } - }); - } else if (actualTypes[actualNameIdx].search(checkTypesRegex) === -1 && actualTypes[actualNameIdx] !== '') { - notCheckingNames.push(name); - } - } - const hasMissing = missingProperties.length; - if (hasMissing) { - for (const { - tagPlacement, - name: missingProperty - } of missingProperties) { - report(`Missing @${targetTagName} "${missingProperty}"`, null, tagPlacement); - } - } - if (!hasPropertyRest || checkRestProperty) { - /** @type {[string, import('comment-parser').Spec][]} */ - const extraProperties = []; - for (const [idx, name] of actualNames.entries()) { - const match = name.startsWith(tag.name.trim() + '.'); - if (match && !expectedNames.some(utils.comparePaths(name)) && !utils.comparePaths(name)(tag.name) && (!disableExtraPropertyReporting || properties.some(prop => { - return prop.split('.').length >= name.split('.').length - 1; - }))) { - extraProperties.push([name, paramTags[idx][1]]); - } - } - if (extraProperties.length) { - for (const [extraProperty, tg] of extraProperties) { - report(`@${targetTagName} "${extraProperty}" does not exist on ${tag.name}`, null, tg); - } - return true; - } - } - return hasMissing; - } - let funcParamName; - if (typeof functionParameterName === 'object') { - const { - name - } = functionParameterName; - funcParamName = name; - } else { - funcParamName = functionParameterName; - } - if (funcParamName !== tag.name.trim()) { - // Todo: Improve for array or object child items - const actualNames = paramTagsNonNested.map(([, { - name - }]) => { - return name.trim(); - }); - const expectedNames = functionParameterNames.map((item, idx) => { - var _item$; - if ( - /** - * @type {[string|undefined, (import('../jsdocUtils.js').FlattendRootInfo & { - * annotationParamName?: string, - })]} */ - item !== null && item !== void 0 && (_item$ = item[1]) !== null && _item$ !== void 0 && _item$.names) { - return actualNames[idx]; - } - return item; - }).filter(item => { - return item !== 'this'; - }); - - // When disableMissingParamChecks is true tag names can be omitted. - // Report when the tag names do not match the expected names or they are used out of order. - if (disableMissingParamChecks) { - const usedExpectedNames = expectedNames.map(a => a === null || a === void 0 ? void 0 : a.toString()).filter(expectedName => expectedName && actualNames.includes(expectedName)); - const usedInOrder = actualNames.every((actualName, idx) => actualName === usedExpectedNames[idx]); - if (usedInOrder) { - return false; - } - } - report(`Expected @${targetTagName} names to be "${expectedNames.map(expectedName => { - return typeof expectedName === 'object' && 'name' in expectedName && expectedName.restElement ? '...' + expectedName.name : expectedName; - }).join(', ')}". Got "${actualNames.join(', ')}".`, null, tag); - return true; - } - return false; - }); -}; - -/** - * @param {string} targetTagName - * @param {boolean} _allowExtraTrailingParamDocs - * @param {{ - * name: string, - * idx: import('../iterateJsdoc.js').Integer - * }[]} jsdocParameterNames - * @param {import('comment-parser').Block} jsdoc - * @param {Function} report - * @returns {boolean} - */ -const validateParameterNamesDeep = (targetTagName, _allowExtraTrailingParamDocs, jsdocParameterNames, jsdoc, report) => { - /** @type {string} */ - let lastRealParameter; - return jsdocParameterNames.some(({ - name: jsdocParameterName, - idx - }) => { - const isPropertyPath = jsdocParameterName.includes('.'); - if (isPropertyPath) { - if (!lastRealParameter) { - report(`@${targetTagName} path declaration ("${jsdocParameterName}") appears before any real parameter.`, null, jsdoc.tags[idx]); - return true; - } - let pathRootNodeName = jsdocParameterName.slice(0, jsdocParameterName.indexOf('.')); - if (pathRootNodeName.endsWith('[]')) { - pathRootNodeName = pathRootNodeName.slice(0, -2); - } - if (pathRootNodeName !== lastRealParameter) { - report(`@${targetTagName} path declaration ("${jsdocParameterName}") root node name ("${pathRootNodeName}") ` + `does not match previous real parameter name ("${lastRealParameter}").`, null, jsdoc.tags[idx]); - return true; - } - } else { - lastRealParameter = jsdocParameterName; - } - return false; - }); -}; -var _default = exports.default = (0, _iterateJsdoc.default)(({ - context, - jsdoc, - report, - utils -}) => { - const { - allowExtraTrailingParamDocs, - checkDestructured = true, - checkRestProperty = false, - checkTypesPattern = '/^(?:[oO]bject|[aA]rray|PlainObject|Generic(?:Object|Array))$/', - enableFixer = false, - useDefaultObjectProperties = false, - disableExtraPropertyReporting = false, - disableMissingParamChecks = false - } = context.options[0] || {}; - const checkTypesRegex = utils.getRegexFromString(checkTypesPattern); - const jsdocParameterNamesDeep = utils.getJsdocTagsDeep('param'); - if (!jsdocParameterNamesDeep || !jsdocParameterNamesDeep.length) { - return; - } - const functionParameterNames = utils.getFunctionParameterNames(useDefaultObjectProperties); - const targetTagName = /** @type {string} */utils.getPreferredTagName({ - tagName: 'param' - }); - const isError = validateParameterNames(targetTagName, allowExtraTrailingParamDocs, checkDestructured, checkRestProperty, checkTypesRegex, disableExtraPropertyReporting, disableMissingParamChecks, enableFixer, functionParameterNames, jsdoc, utils, report); - if (isError || !checkDestructured) { - return; - } - validateParameterNamesDeep(targetTagName, allowExtraTrailingParamDocs, jsdocParameterNamesDeep, jsdoc, report); -}, { - contextDefaults: ['ArrowFunctionExpression', 'FunctionDeclaration', 'FunctionExpression', 'TSDeclareFunction', - // Add this to above defaults - 'TSMethodSignature'], - meta: { - docs: { - description: 'Ensures that parameter names in JSDoc match those in the function declaration.', - url: 'https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/check-param-names.md#repos-sticky-header' - }, - fixable: 'code', - schema: [{ - additionalProperties: false, - properties: { - allowExtraTrailingParamDocs: { - type: 'boolean' - }, - checkDestructured: { - type: 'boolean' - }, - checkRestProperty: { - type: 'boolean' - }, - checkTypesPattern: { - type: 'string' - }, - disableExtraPropertyReporting: { - type: 'boolean' - }, - disableMissingParamChecks: { - type: 'boolean' - }, - enableFixer: { - type: 'boolean' - }, - useDefaultObjectProperties: { - type: 'boolean' - } - }, - type: 'object' - }], - type: 'suggestion' - } -}); -module.exports = exports.default; -//# sourceMappingURL=checkParamNames.cjs.map \ No newline at end of file diff --git a/tools/eslint/node_modules/eslint-plugin-jsdoc/dist/rules/checkPropertyNames.cjs b/tools/eslint/node_modules/eslint-plugin-jsdoc/dist/rules/checkPropertyNames.cjs deleted file mode 100644 index 6ec7065cf0e0d6..00000000000000 --- a/tools/eslint/node_modules/eslint-plugin-jsdoc/dist/rules/checkPropertyNames.cjs +++ /dev/null @@ -1,116 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.default = void 0; -var _iterateJsdoc = _interopRequireDefault(require("../iterateJsdoc.cjs")); -function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; } -/** - * @param {string} targetTagName - * @param {boolean} enableFixer - * @param {import('comment-parser').Block} jsdoc - * @param {import('../iterateJsdoc.js').Utils} utils - * @returns {boolean} - */ -const validatePropertyNames = (targetTagName, enableFixer, jsdoc, utils) => { - const propertyTags = Object.entries(jsdoc.tags).filter(([, tag]) => { - return tag.tag === targetTagName; - }); - return propertyTags.some(([, tag], index) => { - /** @type {import('../iterateJsdoc.js').Integer} */ - let tagsIndex; - const dupeTagInfo = propertyTags.find(([tgsIndex, tg], idx) => { - tagsIndex = Number(tgsIndex); - return tg.name === tag.name && idx !== index; - }); - if (dupeTagInfo) { - utils.reportJSDoc(`Duplicate @${targetTagName} "${tag.name}"`, dupeTagInfo[1], enableFixer ? () => { - utils.removeTag(tagsIndex); - } : null); - return true; - } - return false; - }); -}; - -/** - * @param {string} targetTagName - * @param {{ - * idx: number; - * name: string; - * type: string; - * }[]} jsdocPropertyNames - * @param {import('comment-parser').Block} jsdoc - * @param {Function} report - */ -const validatePropertyNamesDeep = (targetTagName, jsdocPropertyNames, jsdoc, report) => { - /** @type {string} */ - let lastRealProperty; - return jsdocPropertyNames.some(({ - name: jsdocPropertyName, - idx - }) => { - const isPropertyPath = jsdocPropertyName.includes('.'); - if (isPropertyPath) { - if (!lastRealProperty) { - report(`@${targetTagName} path declaration ("${jsdocPropertyName}") appears before any real property.`, null, jsdoc.tags[idx]); - return true; - } - let pathRootNodeName = jsdocPropertyName.slice(0, jsdocPropertyName.indexOf('.')); - if (pathRootNodeName.endsWith('[]')) { - pathRootNodeName = pathRootNodeName.slice(0, -2); - } - if (pathRootNodeName !== lastRealProperty) { - report(`@${targetTagName} path declaration ("${jsdocPropertyName}") root node name ("${pathRootNodeName}") ` + `does not match previous real property name ("${lastRealProperty}").`, null, jsdoc.tags[idx]); - return true; - } - } else { - lastRealProperty = jsdocPropertyName; - } - return false; - }); -}; -var _default = exports.default = (0, _iterateJsdoc.default)(({ - context, - jsdoc, - report, - utils -}) => { - const { - enableFixer = false - } = context.options[0] || {}; - const jsdocPropertyNamesDeep = utils.getJsdocTagsDeep('property'); - if (!jsdocPropertyNamesDeep || !jsdocPropertyNamesDeep.length) { - return; - } - const targetTagName = /** @type {string} */utils.getPreferredTagName({ - tagName: 'property' - }); - const isError = validatePropertyNames(targetTagName, enableFixer, jsdoc, utils); - if (isError) { - return; - } - validatePropertyNamesDeep(targetTagName, jsdocPropertyNamesDeep, jsdoc, report); -}, { - iterateAllJsdocs: true, - meta: { - docs: { - description: 'Ensures that property names in JSDoc are not duplicated on the same block and that nested properties have defined roots.', - url: 'https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/check-property-names.md#repos-sticky-header' - }, - fixable: 'code', - schema: [{ - additionalProperties: false, - properties: { - enableFixer: { - type: 'boolean' - } - }, - type: 'object' - }], - type: 'suggestion' - } -}); -module.exports = exports.default; -//# sourceMappingURL=checkPropertyNames.cjs.map \ No newline at end of file diff --git a/tools/eslint/node_modules/eslint-plugin-jsdoc/dist/rules/checkSyntax.cjs b/tools/eslint/node_modules/eslint-plugin-jsdoc/dist/rules/checkSyntax.cjs deleted file mode 100644 index e88ff5ffc35df7..00000000000000 --- a/tools/eslint/node_modules/eslint-plugin-jsdoc/dist/rules/checkSyntax.cjs +++ /dev/null @@ -1,38 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.default = void 0; -var _iterateJsdoc = _interopRequireDefault(require("../iterateJsdoc.cjs")); -function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; } -var _default = exports.default = (0, _iterateJsdoc.default)(({ - jsdoc, - report, - settings -}) => { - const { - mode - } = settings; - - // Don't check for "permissive" and "closure" - if (mode === 'jsdoc' || mode === 'typescript') { - for (const tag of jsdoc.tags) { - if (tag.type.slice(-1) === '=') { - report('Syntax should not be Google Closure Compiler style.', null, tag); - break; - } - } - } -}, { - iterateAllJsdocs: true, - meta: { - docs: { - description: 'Reports against syntax not valid for the mode (e.g., Google Closure Compiler in non-Closure mode).', - url: 'https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/check-syntax.md#repos-sticky-header' - }, - type: 'suggestion' - } -}); -module.exports = exports.default; -//# sourceMappingURL=checkSyntax.cjs.map \ No newline at end of file diff --git a/tools/eslint/node_modules/eslint-plugin-jsdoc/dist/rules/checkTagNames.cjs b/tools/eslint/node_modules/eslint-plugin-jsdoc/dist/rules/checkTagNames.cjs deleted file mode 100644 index 6d3cfdc3f7c37a..00000000000000 --- a/tools/eslint/node_modules/eslint-plugin-jsdoc/dist/rules/checkTagNames.cjs +++ /dev/null @@ -1,215 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.default = void 0; -var _iterateJsdoc = _interopRequireDefault(require("../iterateJsdoc.cjs")); -var _escapeStringRegexp = _interopRequireDefault(require("escape-string-regexp")); -function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; } -// https://babeljs.io/docs/en/babel-plugin-transform-react-jsx/ -const jsxTagNames = new Set(['jsx', 'jsxFrag', 'jsxImportSource', 'jsxRuntime']); -const typedTagsAlwaysUnnecessary = new Set(['augments', 'callback', 'class', 'enum', 'implements', 'private', 'property', 'protected', 'public', 'readonly', 'this', 'type', 'typedef']); -const typedTagsNeedingName = new Set(['template']); -const typedTagsUnnecessaryOutsideDeclare = new Set(['abstract', 'access', 'class', 'constant', 'constructs', 'default', 'enum', 'export', 'exports', 'function', 'global', 'inherits', 'instance', 'interface', 'member', 'memberof', 'memberOf', 'method', 'mixes', 'mixin', 'module', 'name', 'namespace', 'override', 'property', 'requires', 'static', 'this']); -var _default = exports.default = (0, _iterateJsdoc.default)(({ - sourceCode, - jsdoc, - report, - utils, - context, - node, - settings, - jsdocNode -}) => { - const - /** - * @type {{ - * definedTags: string[], - * enableFixer: boolean, - * jsxTags: boolean, - * typed: boolean - }} */ - { - definedTags = [], - enableFixer = true, - jsxTags, - typed - } = context.options[0] || {}; - - /** @type {(string|undefined)[]} */ - let definedPreferredTags = []; - const { - tagNamePreference, - structuredTags - } = settings; - const definedStructuredTags = Object.keys(structuredTags); - const definedNonPreferredTags = Object.keys(tagNamePreference); - if (definedNonPreferredTags.length) { - definedPreferredTags = Object.values(tagNamePreference).map(preferredTag => { - if (typeof preferredTag === 'string') { - // May become an empty string but will be filtered out below - return preferredTag; - } - if (!preferredTag) { - return undefined; - } - if (typeof preferredTag !== 'object') { - utils.reportSettings('Invalid `settings.jsdoc.tagNamePreference`. Values must be falsy, a string, or an object.'); - } - return preferredTag.replacement; - }).filter(Boolean); - } - - /** - * @param {import('eslint').Rule.Node} subNode - * @returns {boolean} - */ - const isInAmbientContext = subNode => { - return subNode.type === 'Program' ? context.getFilename().endsWith('.d.ts') : Boolean( /** @type {import('@typescript-eslint/types').TSESTree.VariableDeclaration} */subNode.declare) || isInAmbientContext(subNode.parent); - }; - - /** - * @param {import('comment-parser').Spec} jsdocTag - * @returns {boolean} - */ - const tagIsRedundantWhenTyped = jsdocTag => { - var _node$parent; - if (!typedTagsUnnecessaryOutsideDeclare.has(jsdocTag.tag)) { - return false; - } - if (jsdocTag.tag === 'default') { - return false; - } - if (node === null) { - return false; - } - if (context.getFilename().endsWith('.d.ts') && ['Program', null, undefined].includes(node === null || node === void 0 || (_node$parent = node.parent) === null || _node$parent === void 0 ? void 0 : _node$parent.type)) { - return false; - } - if (isInAmbientContext( /** @type {import('eslint').Rule.Node} */node)) { - return false; - } - return true; - }; - - /** - * @param {string} message - * @param {import('comment-parser').Spec} jsdocTag - * @param {import('../iterateJsdoc.js').Integer} tagIndex - * @param {Partial} [additionalTagChanges] - * @returns {void} - */ - const reportWithTagRemovalFixer = (message, jsdocTag, tagIndex, additionalTagChanges) => { - utils.reportJSDoc(message, jsdocTag, enableFixer ? () => { - if (jsdocTag.description.trim()) { - utils.changeTag(jsdocTag, { - postType: '', - type: '', - ...additionalTagChanges - }); - } else { - utils.removeTag(tagIndex, { - removeEmptyBlock: true - }); - } - } : null, true); - }; - - /** - * @param {import('comment-parser').Spec} jsdocTag - * @param {import('../iterateJsdoc.js').Integer} tagIndex - * @returns {boolean} - */ - const checkTagForTypedValidity = (jsdocTag, tagIndex) => { - if (typedTagsAlwaysUnnecessary.has(jsdocTag.tag)) { - reportWithTagRemovalFixer(`'@${jsdocTag.tag}' is redundant when using a type system.`, jsdocTag, tagIndex, { - postTag: '', - tag: '' - }); - return true; - } - if (tagIsRedundantWhenTyped(jsdocTag)) { - reportWithTagRemovalFixer(`'@${jsdocTag.tag}' is redundant outside of ambient (\`declare\`/\`.d.ts\`) contexts when using a type system.`, jsdocTag, tagIndex); - return true; - } - if (typedTagsNeedingName.has(jsdocTag.tag) && !jsdocTag.name) { - reportWithTagRemovalFixer(`'@${jsdocTag.tag}' without a name is redundant when using a type system.`, jsdocTag, tagIndex); - return true; - } - return false; - }; - for (let tagIndex = 0; tagIndex < jsdoc.tags.length; tagIndex += 1) { - const jsdocTag = jsdoc.tags[tagIndex]; - const tagName = jsdocTag.tag; - if (jsxTags && jsxTagNames.has(tagName)) { - continue; - } - if (typed && checkTagForTypedValidity(jsdocTag, tagIndex)) { - continue; - } - const validTags = [...definedTags, ...( /** @type {string[]} */definedPreferredTags), ...definedNonPreferredTags, ...definedStructuredTags, ...(typed ? typedTagsNeedingName : [])]; - if (utils.isValidTag(tagName, validTags)) { - let preferredTagName = utils.getPreferredTagName({ - allowObjectReturn: true, - defaultMessage: `Blacklisted tag found (\`@${tagName}\`)`, - tagName - }); - if (!preferredTagName) { - continue; - } - let message; - if (typeof preferredTagName === 'object') { - ({ - message, - replacement: preferredTagName - } = /** @type {{message: string; replacement?: string | undefined;}} */ - preferredTagName); - } - if (!message) { - message = `Invalid JSDoc tag (preference). Replace "${tagName}" JSDoc tag with "${preferredTagName}".`; - } - if (preferredTagName !== tagName) { - report(message, fixer => { - const replacement = sourceCode.getText(jsdocNode).replace(new RegExp(`@${(0, _escapeStringRegexp.default)(tagName)}\\b`, 'u'), `@${preferredTagName}`); - return fixer.replaceText(jsdocNode, replacement); - }, jsdocTag); - } - } else { - report(`Invalid JSDoc tag name "${tagName}".`, null, jsdocTag); - } - } -}, { - iterateAllJsdocs: true, - meta: { - docs: { - description: 'Reports invalid block tag names.', - url: 'https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/check-tag-names.md#repos-sticky-header' - }, - fixable: 'code', - schema: [{ - additionalProperties: false, - properties: { - definedTags: { - items: { - type: 'string' - }, - type: 'array' - }, - enableFixer: { - type: 'boolean' - }, - jsxTags: { - type: 'boolean' - }, - typed: { - type: 'boolean' - } - }, - type: 'object' - }], - type: 'suggestion' - } -}); -module.exports = exports.default; -//# sourceMappingURL=checkTagNames.cjs.map \ No newline at end of file diff --git a/tools/eslint/node_modules/eslint-plugin-jsdoc/dist/rules/checkTypes.cjs b/tools/eslint/node_modules/eslint-plugin-jsdoc/dist/rules/checkTypes.cjs deleted file mode 100644 index f77b374063d955..00000000000000 --- a/tools/eslint/node_modules/eslint-plugin-jsdoc/dist/rules/checkTypes.cjs +++ /dev/null @@ -1,396 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.default = void 0; -var _iterateJsdoc = _interopRequireDefault(require("../iterateJsdoc.cjs")); -var _jsdoccomment = require("@es-joy/jsdoccomment"); -function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; } -const strictNativeTypes = ['undefined', 'null', 'boolean', 'number', 'bigint', 'string', 'symbol', 'object', 'Array', 'Function', 'Date', 'RegExp']; - -/** - * Adjusts the parent type node `meta` for generic matches (or type node - * `type` for `JsdocTypeAny`) and sets the type node `value`. - * @param {string} type The actual type - * @param {string} preferred The preferred type - * @param {boolean} isGenericMatch - * @param {string} typeNodeName - * @param {import('jsdoc-type-pratt-parser').NonRootResult} node - * @param {import('jsdoc-type-pratt-parser').NonRootResult|undefined} parentNode - * @returns {void} - */ -const adjustNames = (type, preferred, isGenericMatch, typeNodeName, node, parentNode) => { - let ret = preferred; - if (isGenericMatch) { - const parentMeta = /** @type {import('jsdoc-type-pratt-parser').GenericResult} */parentNode.meta; - if (preferred === '[]') { - parentMeta.brackets = 'square'; - parentMeta.dot = false; - ret = 'Array'; - } else { - const dotBracketEnd = preferred.match(/\.(?:<>)?$/u); - if (dotBracketEnd) { - parentMeta.brackets = 'angle'; - parentMeta.dot = true; - ret = preferred.slice(0, -dotBracketEnd[0].length); - } else { - const bracketEnd = preferred.endsWith('<>'); - if (bracketEnd) { - parentMeta.brackets = 'angle'; - parentMeta.dot = false; - ret = preferred.slice(0, -2); - } else if ((parentMeta === null || parentMeta === void 0 ? void 0 : parentMeta.brackets) === 'square' && (typeNodeName === '[]' || typeNodeName === 'Array')) { - parentMeta.brackets = 'angle'; - parentMeta.dot = false; - } - } - } - } else if (type === 'JsdocTypeAny') { - node.type = 'JsdocTypeName'; - } - - /** @type {import('jsdoc-type-pratt-parser').NameResult} */ - node.value = ret.replace(/(?:\.|<>|\.<>|\[\])$/u, ''); - - // For bare pseudo-types like `<>` - if (!ret) { - /** @type {import('jsdoc-type-pratt-parser').NameResult} */node.value = typeNodeName; - } -}; - -/** - * @param {boolean} [upperCase] - * @returns {string} - */ -const getMessage = upperCase => { - return 'Use object shorthand or index signatures instead of ' + '`' + (upperCase ? 'O' : 'o') + 'bject`, e.g., `{[key: string]: string}`'; -}; -var _default = exports.default = (0, _iterateJsdoc.default)(({ - jsdocNode, - sourceCode, - report, - utils, - settings, - context -}) => { - const jsdocTagsWithPossibleType = utils.filterTags(tag => { - return Boolean(utils.tagMightHaveTypePosition(tag.tag)); - }); - const - /** - * @type {{ - * preferredTypes: import('../iterateJsdoc.js').PreferredTypes, - * structuredTags: import('../iterateJsdoc.js').StructuredTags, - * mode: import('../jsdocUtils.js').ParserMode - * }} - */ - { - preferredTypes: preferredTypesOriginal, - structuredTags, - mode - } = settings; - const injectObjectPreferredTypes = !('Object' in preferredTypesOriginal || 'object' in preferredTypesOriginal || 'object.<>' in preferredTypesOriginal || 'Object.<>' in preferredTypesOriginal || 'object<>' in preferredTypesOriginal); - - /** - * @type {{ - * message: string, - * replacement: false - * }} - */ - const info = { - message: getMessage(), - replacement: false - }; - - /** - * @type {{ - * message: string, - * replacement: false - * }} - */ - const infoUC = { - message: getMessage(true), - replacement: false - }; - - /** @type {import('../iterateJsdoc.js').PreferredTypes} */ - const typeToInject = mode === 'typescript' ? { - Object: 'object', - 'object.<>': info, - 'Object.<>': infoUC, - 'object<>': info, - 'Object<>': infoUC - } : { - Object: 'object', - 'object.<>': 'Object<>', - 'Object.<>': 'Object<>', - 'object<>': 'Object<>' - }; - - /** @type {import('../iterateJsdoc.js').PreferredTypes} */ - const preferredTypes = { - ...(injectObjectPreferredTypes ? typeToInject : {}), - ...preferredTypesOriginal - }; - const - /** - * @type {{ - * noDefaults: boolean, - * unifyParentAndChildTypeChecks: boolean, - * exemptTagContexts: ({ - * tag: string, - * types: true|string[] - * })[] - * }} - */ - { - noDefaults, - unifyParentAndChildTypeChecks, - exemptTagContexts = [] - } = context.options[0] || {}; - - /** - * Gets information about the preferred type: whether there is a matching - * preferred type, what the type is, and whether it is a match to a generic. - * @param {string} _type Not currently in use - * @param {string} typeNodeName - * @param {import('jsdoc-type-pratt-parser').NonRootResult|undefined} parentNode - * @param {string|undefined} property - * @returns {[hasMatchingPreferredType: boolean, typeName: string, isGenericMatch: boolean]} - */ - const getPreferredTypeInfo = (_type, typeNodeName, parentNode, property) => { - let hasMatchingPreferredType = false; - let isGenericMatch = false; - let typeName = typeNodeName; - const isNameOfGeneric = parentNode !== undefined && parentNode.type === 'JsdocTypeGeneric' && property === 'left'; - if (unifyParentAndChildTypeChecks || isNameOfGeneric) { - var _parentNode$meta, _parentNode$meta2; - const brackets = /** @type {import('jsdoc-type-pratt-parser').GenericResult} */parentNode === null || parentNode === void 0 || (_parentNode$meta = parentNode.meta) === null || _parentNode$meta === void 0 ? void 0 : _parentNode$meta.brackets; - const dot = /** @type {import('jsdoc-type-pratt-parser').GenericResult} */parentNode === null || parentNode === void 0 || (_parentNode$meta2 = parentNode.meta) === null || _parentNode$meta2 === void 0 ? void 0 : _parentNode$meta2.dot; - if (brackets === 'angle') { - const checkPostFixes = dot ? ['.', '.<>'] : ['<>']; - isGenericMatch = checkPostFixes.some(checkPostFix => { - if ((preferredTypes === null || preferredTypes === void 0 ? void 0 : preferredTypes[typeNodeName + checkPostFix]) !== undefined) { - typeName += checkPostFix; - return true; - } - return false; - }); - } - if (!isGenericMatch && property && /** @type {import('jsdoc-type-pratt-parser').NonRootResult} */parentNode.type === 'JsdocTypeGeneric') { - const checkPostFixes = dot ? ['.', '.<>'] : [brackets === 'angle' ? '<>' : '[]']; - isGenericMatch = checkPostFixes.some(checkPostFix => { - if ((preferredTypes === null || preferredTypes === void 0 ? void 0 : preferredTypes[checkPostFix]) !== undefined) { - typeName = checkPostFix; - return true; - } - return false; - }); - } - } - const directNameMatch = (preferredTypes === null || preferredTypes === void 0 ? void 0 : preferredTypes[typeNodeName]) !== undefined && !Object.values(preferredTypes).includes(typeNodeName); - const unifiedSyntaxParentMatch = property && directNameMatch && unifyParentAndChildTypeChecks; - isGenericMatch = isGenericMatch || Boolean(unifiedSyntaxParentMatch); - hasMatchingPreferredType = isGenericMatch || directNameMatch && !property; - return [hasMatchingPreferredType, typeName, isGenericMatch]; - }; - - /** - * Iterates strict types to see if any should be added to `invalidTypes` (and - * the the relevant strict type returned as the new preferred type). - * @param {string} typeNodeName - * @param {string|undefined} preferred - * @param {import('jsdoc-type-pratt-parser').NonRootResult|undefined} parentNode - * @param {(string|false|undefined)[][]} invalidTypes - * @returns {string|undefined} The `preferred` type string, optionally changed - */ - const checkNativeTypes = (typeNodeName, preferred, parentNode, invalidTypes) => { - let changedPreferred = preferred; - for (const strictNativeType of strictNativeTypes) { - var _parentNode$elements, _parentNode$left, _parentNode$left2; - if (strictNativeType === 'object' && ( - // This is not set to remap with exact type match (e.g., - // `object: 'Object'`), so can ignore (including if circular) - !(preferredTypes !== null && preferredTypes !== void 0 && preferredTypes[typeNodeName]) || - // Although present on `preferredTypes` for remapping, this is a - // parent object without a parent match (and not - // `unifyParentAndChildTypeChecks`) and we don't want - // `object<>` given TypeScript issue https://github.com/microsoft/TypeScript/issues/20555 - /** - * @type {import('jsdoc-type-pratt-parser').GenericResult} - */ - parentNode !== null && parentNode !== void 0 && (_parentNode$elements = parentNode.elements) !== null && _parentNode$elements !== void 0 && _parentNode$elements.length && ( - /** - * @type {import('jsdoc-type-pratt-parser').GenericResult} - */ - (parentNode === null || parentNode === void 0 || (_parentNode$left = parentNode.left) === null || _parentNode$left === void 0 ? void 0 : _parentNode$left.type) === 'JsdocTypeName' && - /** - * @type {import('jsdoc-type-pratt-parser').GenericResult} - */ - (parentNode === null || parentNode === void 0 || (_parentNode$left2 = parentNode.left) === null || _parentNode$left2 === void 0 ? void 0 : _parentNode$left2.value) === 'Object'))) { - continue; - } - if (strictNativeType !== typeNodeName && strictNativeType.toLowerCase() === typeNodeName.toLowerCase() && ( - // Don't report if user has own map for a strict native type - !preferredTypes || (preferredTypes === null || preferredTypes === void 0 ? void 0 : preferredTypes[strictNativeType]) === undefined)) { - changedPreferred = strictNativeType; - invalidTypes.push([typeNodeName, changedPreferred]); - break; - } - } - return changedPreferred; - }; - - /** - * Collect invalid type info. - * @param {string} type - * @param {string} value - * @param {string} tagName - * @param {string} nameInTag - * @param {number} idx - * @param {string|undefined} property - * @param {import('jsdoc-type-pratt-parser').NonRootResult} node - * @param {import('jsdoc-type-pratt-parser').NonRootResult|undefined} parentNode - * @param {(string|false|undefined)[][]} invalidTypes - * @returns {void} - */ - const getInvalidTypes = (type, value, tagName, nameInTag, idx, property, node, parentNode, invalidTypes) => { - let typeNodeName = type === 'JsdocTypeAny' ? '*' : value; - const [hasMatchingPreferredType, typeName, isGenericMatch] = getPreferredTypeInfo(type, typeNodeName, parentNode, property); - let preferred; - let types; - if (hasMatchingPreferredType) { - const preferredSetting = preferredTypes[typeName]; - typeNodeName = typeName === '[]' ? typeName : typeNodeName; - if (!preferredSetting) { - invalidTypes.push([typeNodeName]); - } else if (typeof preferredSetting === 'string') { - preferred = preferredSetting; - invalidTypes.push([typeNodeName, preferred]); - } else if (preferredSetting && typeof preferredSetting === 'object') { - const nextItem = preferredSetting.skipRootChecking && jsdocTagsWithPossibleType[idx + 1]; - if (!nextItem || !nextItem.name.startsWith(`${nameInTag}.`)) { - preferred = preferredSetting.replacement; - invalidTypes.push([typeNodeName, preferred, preferredSetting.message]); - } - } else { - utils.reportSettings('Invalid `settings.jsdoc.preferredTypes`. Values must be falsy, a string, or an object.'); - return; - } - } else if (Object.entries(structuredTags).some(([tag, { - type: typs - }]) => { - types = typs; - return tag === tagName && Array.isArray(types) && !types.includes(typeNodeName); - })) { - invalidTypes.push([typeNodeName, types]); - } else if (!noDefaults && type === 'JsdocTypeName') { - preferred = checkNativeTypes(typeNodeName, preferred, parentNode, invalidTypes); - } - - // For fixer - if (preferred) { - adjustNames(type, preferred, isGenericMatch, typeNodeName, node, parentNode); - } - }; - for (const [idx, jsdocTag] of jsdocTagsWithPossibleType.entries()) { - /** @type {(string|false|undefined)[][]} */ - const invalidTypes = []; - let typeAst; - try { - typeAst = mode === 'permissive' ? (0, _jsdoccomment.tryParse)(jsdocTag.type) : (0, _jsdoccomment.parse)(jsdocTag.type, mode); - } catch { - continue; - } - const { - tag: tagName, - name: nameInTag - } = jsdocTag; - (0, _jsdoccomment.traverse)(typeAst, (node, parentNode, property) => { - const { - type, - value - } = - /** - * @type {import('jsdoc-type-pratt-parser').NameResult} - */ - node; - if (!['JsdocTypeName', 'JsdocTypeAny'].includes(type)) { - return; - } - getInvalidTypes(type, value, tagName, nameInTag, idx, property, node, parentNode, invalidTypes); - }); - if (invalidTypes.length) { - const fixedType = (0, _jsdoccomment.stringify)(typeAst); - - /** - * @type {import('eslint').Rule.ReportFixer} - */ - const fix = fixer => { - return fixer.replaceText(jsdocNode, sourceCode.getText(jsdocNode).replace(`{${jsdocTag.type}}`, `{${fixedType}}`)); - }; - for (const [badType, preferredType = '', msg] of invalidTypes) { - const tagValue = jsdocTag.name ? ` "${jsdocTag.name}"` : ''; - if (exemptTagContexts.some(({ - tag, - types - }) => { - return tag === tagName && (types === true || types.includes(jsdocTag.type)); - })) { - continue; - } - report(msg || `Invalid JSDoc @${tagName}${tagValue} type "${badType}"` + (preferredType ? '; ' : '.') + (preferredType ? `prefer: ${JSON.stringify(preferredType)}.` : ''), preferredType ? fix : null, jsdocTag, msg ? { - tagName, - tagValue - } : undefined); - } - } - } -}, { - iterateAllJsdocs: true, - meta: { - docs: { - description: 'Reports invalid types.', - url: 'https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/check-types.md#repos-sticky-header' - }, - fixable: 'code', - schema: [{ - additionalProperties: false, - properties: { - exemptTagContexts: { - items: { - additionalProperties: false, - properties: { - tag: { - type: 'string' - }, - types: { - oneOf: [{ - type: 'boolean' - }, { - items: { - type: 'string' - }, - type: 'array' - }] - } - }, - type: 'object' - }, - type: 'array' - }, - noDefaults: { - type: 'boolean' - }, - unifyParentAndChildTypeChecks: { - type: 'boolean' - } - }, - type: 'object' - }], - type: 'suggestion' - } -}); -module.exports = exports.default; -//# sourceMappingURL=checkTypes.cjs.map \ No newline at end of file diff --git a/tools/eslint/node_modules/eslint-plugin-jsdoc/dist/rules/checkValues.cjs b/tools/eslint/node_modules/eslint-plugin-jsdoc/dist/rules/checkValues.cjs deleted file mode 100644 index 0efccce86013de..00000000000000 --- a/tools/eslint/node_modules/eslint-plugin-jsdoc/dist/rules/checkValues.cjs +++ /dev/null @@ -1,154 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.default = void 0; -var _nodePath = require("node:path"); -var _nodeUrl = require("node:url"); -var _synckit = require("synckit"); -var _semver = _interopRequireDefault(require("semver")); -var _spdxExpressionParse = _interopRequireDefault(require("spdx-expression-parse")); -var _iterateJsdoc = _interopRequireDefault(require("../iterateJsdoc.cjs")); -function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; } -const _dirname = (0, _nodePath.dirname)((0, _nodeUrl.fileURLToPath)(require('url').pathToFileURL(__filename).toString())); -const pathName = (0, _nodePath.join)(_dirname, '../import-worker.mjs'); -const allowedKinds = new Set(['class', 'constant', 'event', 'external', 'file', 'function', 'member', 'mixin', 'module', 'namespace', 'typedef']); -var _default = exports.default = (0, _iterateJsdoc.default)(({ - utils, - report, - context, - settings -}) => { - const options = context.options[0] || {}; - const { - allowedLicenses = null, - allowedAuthors = null, - numericOnlyVariation = false, - licensePattern = '/([^\n\r]*)/gu' - } = options; - utils.forEachPreferredTag('version', (jsdocParameter, targetTagName) => { - const version = /** @type {string} */utils.getTagDescription(jsdocParameter).trim(); - if (!version) { - report(`Missing JSDoc @${targetTagName} value.`, null, jsdocParameter); - } else if (!_semver.default.valid(version)) { - report(`Invalid JSDoc @${targetTagName}: "${utils.getTagDescription(jsdocParameter)}".`, null, jsdocParameter); - } - }); - utils.forEachPreferredTag('kind', (jsdocParameter, targetTagName) => { - const kind = /** @type {string} */utils.getTagDescription(jsdocParameter).trim(); - if (!kind) { - report(`Missing JSDoc @${targetTagName} value.`, null, jsdocParameter); - } else if (!allowedKinds.has(kind)) { - report(`Invalid JSDoc @${targetTagName}: "${utils.getTagDescription(jsdocParameter)}"; ` + `must be one of: ${[...allowedKinds].join(', ')}.`, null, jsdocParameter); - } - }); - if (numericOnlyVariation) { - utils.forEachPreferredTag('variation', (jsdocParameter, targetTagName) => { - const variation = /** @type {string} */utils.getTagDescription(jsdocParameter).trim(); - if (!variation) { - report(`Missing JSDoc @${targetTagName} value.`, null, jsdocParameter); - } else if (!Number.isInteger(Number(variation)) || Number(variation) <= 0) { - report(`Invalid JSDoc @${targetTagName}: "${utils.getTagDescription(jsdocParameter)}".`, null, jsdocParameter); - } - }); - } - utils.forEachPreferredTag('since', (jsdocParameter, targetTagName) => { - const version = /** @type {string} */utils.getTagDescription(jsdocParameter).trim(); - if (!version) { - report(`Missing JSDoc @${targetTagName} value.`, null, jsdocParameter); - } else if (!_semver.default.valid(version)) { - report(`Invalid JSDoc @${targetTagName}: "${utils.getTagDescription(jsdocParameter)}".`, null, jsdocParameter); - } - }); - utils.forEachPreferredTag('license', (jsdocParameter, targetTagName) => { - const licenseRegex = utils.getRegexFromString(licensePattern, 'g'); - const matches = /** @type {string} */utils.getTagDescription(jsdocParameter).matchAll(licenseRegex); - let positiveMatch = false; - for (const match of matches) { - const license = match[1] || match[0]; - if (license) { - positiveMatch = true; - } - if (!license.trim()) { - // Avoid reporting again as empty match - if (positiveMatch) { - return; - } - report(`Missing JSDoc @${targetTagName} value.`, null, jsdocParameter); - } else if (allowedLicenses) { - if (allowedLicenses !== true && !allowedLicenses.includes(license)) { - report(`Invalid JSDoc @${targetTagName}: "${license}"; expected one of ${allowedLicenses.join(', ')}.`, null, jsdocParameter); - } - } else { - try { - (0, _spdxExpressionParse.default)(license); - } catch { - report(`Invalid JSDoc @${targetTagName}: "${license}"; expected SPDX expression: https://spdx.org/licenses/.`, null, jsdocParameter); - } - } - } - }); - if (settings.mode === 'typescript') { - utils.forEachPreferredTag('import', tag => { - const { - type, - name, - description - } = tag; - const typePart = type ? `{${type}} ` : ''; - const imprt = 'import ' + (description ? `${typePart}${name} ${description}` : `${typePart}${name}`); - const getImports = (0, _synckit.createSyncFn)(pathName); - if (!getImports(imprt)) { - report(`Bad @import tag`, null, tag); - } - }); - } - utils.forEachPreferredTag('author', (jsdocParameter, targetTagName) => { - const author = /** @type {string} */utils.getTagDescription(jsdocParameter).trim(); - if (!author) { - report(`Missing JSDoc @${targetTagName} value.`, null, jsdocParameter); - } else if (allowedAuthors && !allowedAuthors.includes(author)) { - report(`Invalid JSDoc @${targetTagName}: "${utils.getTagDescription(jsdocParameter)}"; expected one of ${allowedAuthors.join(', ')}.`, null, jsdocParameter); - } - }); -}, { - iterateAllJsdocs: true, - meta: { - docs: { - description: 'This rule checks the values for a handful of tags: `@version`, `@since`, `@license` and `@author`.', - url: 'https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/check-values.md#repos-sticky-header' - }, - schema: [{ - additionalProperties: false, - properties: { - allowedAuthors: { - items: { - type: 'string' - }, - type: 'array' - }, - allowedLicenses: { - anyOf: [{ - items: { - type: 'string' - }, - type: 'array' - }, { - type: 'boolean' - }] - }, - licensePattern: { - type: 'string' - }, - numericOnlyVariation: { - type: 'boolean' - } - }, - type: 'object' - }], - type: 'suggestion' - } -}); -module.exports = exports.default; -//# sourceMappingURL=checkValues.cjs.map \ No newline at end of file diff --git a/tools/eslint/node_modules/eslint-plugin-jsdoc/dist/rules/convertToJsdocComments.cjs b/tools/eslint/node_modules/eslint-plugin-jsdoc/dist/rules/convertToJsdocComments.cjs deleted file mode 100644 index 93f01279b1541d..00000000000000 --- a/tools/eslint/node_modules/eslint-plugin-jsdoc/dist/rules/convertToJsdocComments.cjs +++ /dev/null @@ -1,313 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.default = void 0; -var _iterateJsdoc = _interopRequireWildcard(require("../iterateJsdoc.cjs")); -var _jsdocUtils = _interopRequireDefault(require("../jsdocUtils.cjs")); -var _jsdoccomment = require("@es-joy/jsdoccomment"); -function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; } -function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); } -function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; } -/** @type {import('eslint').Rule.RuleModule} */ -var _default = exports.default = { - create(context) { - /** - * @typedef {import('eslint').AST.Token | import('estree').Comment | { - * type: import('eslint').AST.TokenType|"Line"|"Block"|"Shebang", - * range: [number, number], - * value: string - * }} Token - */ - - /** - * @callback AddComment - * @param {boolean|undefined} inlineCommentBlock - * @param {Token} comment - * @param {string} indent - * @param {number} lines - * @param {import('eslint').Rule.RuleFixer} fixer - */ - - /* c8 ignore next -- Fallback to deprecated method */ - const { - sourceCode = context.getSourceCode() - } = context; - const settings = (0, _iterateJsdoc.getSettings)(context); - if (!settings) { - return {}; - } - const { - contexts = settings.contexts || [], - contextsAfter = ( /** @type {string[]} */[]), - contextsBeforeAndAfter = ['VariableDeclarator', 'TSPropertySignature', 'PropertyDefinition'], - enableFixer = true, - enforceJsdocLineStyle = 'multi', - lineOrBlockStyle = 'both', - allowedPrefixes = ['@ts-', 'istanbul ', 'c8 ', 'v8 ', 'eslint', 'prettier-'] - } = context.options[0] ?? {}; - let reportingNonJsdoc = false; - - /** - * @param {string} messageId - * @param {import('estree').Comment|Token} comment - * @param {import('eslint').Rule.Node} node - * @param {import('eslint').Rule.ReportFixer} fixer - */ - const report = (messageId, comment, node, fixer) => { - var _comment$loc, _comment$loc2; - const loc = { - end: { - column: 0, - /* c8 ignore next 2 -- Guard */ - // @ts-expect-error Ok - line: ((_comment$loc = comment.loc) === null || _comment$loc === void 0 || (_comment$loc = _comment$loc.start) === null || _comment$loc === void 0 ? void 0 : _comment$loc.line) ?? 1 - }, - start: { - column: 0, - /* c8 ignore next 2 -- Guard */ - // @ts-expect-error Ok - line: ((_comment$loc2 = comment.loc) === null || _comment$loc2 === void 0 || (_comment$loc2 = _comment$loc2.start) === null || _comment$loc2 === void 0 ? void 0 : _comment$loc2.line) ?? 1 - } - }; - context.report({ - fix: enableFixer ? fixer : null, - loc, - messageId, - node - }); - }; - - /** - * @param {import('eslint').Rule.Node} node - * @param {import('eslint').AST.Token | import('estree').Comment | { - * type: import('eslint').AST.TokenType|"Line"|"Block"|"Shebang", - * range: [number, number], - * value: string - * }} comment - * @param {AddComment} addComment - * @param {import('../iterateJsdoc.js').Context[]} ctxts - */ - const getFixer = (node, comment, addComment, ctxts) => { - return /** @type {import('eslint').Rule.ReportFixer} */fixer => { - // Default to one line break if the `minLines`/`maxLines` settings allow - const lines = settings.minLines === 0 && settings.maxLines >= 1 ? 1 : settings.minLines; - let baseNode = - /** - * @type {import('@typescript-eslint/types').TSESTree.Node|import('eslint').Rule.Node} - */ - (0, _jsdoccomment.getReducedASTNode)(node, sourceCode); - const decorator = (0, _jsdoccomment.getDecorator)( /** @type {import('eslint').Rule.Node} */ - baseNode); - if (decorator) { - baseNode = /** @type {import('@typescript-eslint/types').TSESTree.Decorator} */ - decorator; - } - const indent = _jsdocUtils.default.getIndent({ - text: sourceCode.getText( /** @type {import('eslint').Rule.Node} */baseNode, /** @type {import('eslint').AST.SourceLocation} */ - ( /** @type {import('eslint').Rule.Node} */baseNode.loc).start.column) - }); - const { - inlineCommentBlock - } = - /** - * @type {{ - * context: string, - * inlineCommentBlock: boolean, - * minLineCount: import('../iterateJsdoc.js').Integer - * }[]} - */ - ctxts.find(contxt => { - if (typeof contxt === 'string') { - return false; - } - const { - context: ctxt - } = contxt; - return ctxt === node.type; - }) || {}; - return addComment(inlineCommentBlock, comment, indent, lines, fixer); - }; - }; - - /** - * @param {import('eslint').AST.Token | import('estree').Comment | { - * type: import('eslint').AST.TokenType|"Line"|"Block"|"Shebang", - * range: [number, number], - * value: string - * }} comment - * @param {import('eslint').Rule.Node} node - * @param {AddComment} addComment - * @param {import('../iterateJsdoc.js').Context[]} ctxts - */ - const reportings = (comment, node, addComment, ctxts) => { - const fixer = getFixer(node, comment, addComment, ctxts); - if (comment.type === 'Block') { - if (lineOrBlockStyle === 'line') { - return; - } - report('blockCommentsJsdocStyle', comment, node, fixer); - return; - } - if (comment.type === 'Line') { - if (lineOrBlockStyle === 'block') { - return; - } - report('lineCommentsJsdocStyle', comment, node, fixer); - } - }; - - /** - * @type {import('../iterateJsdoc.js').CheckJsdoc} - */ - const checkNonJsdoc = (_info, _handler, node) => { - const comment = (0, _jsdoccomment.getNonJsdocComment)(sourceCode, node, settings); - if (!comment || /** @type {string[]} */ - allowedPrefixes.some(prefix => { - return comment.value.trimStart().startsWith(prefix); - })) { - return; - } - reportingNonJsdoc = true; - - /** @type {AddComment} */ - const addComment = (inlineCommentBlock, comment, indent, lines, fixer) => { - const insertion = (inlineCommentBlock || enforceJsdocLineStyle === 'single' ? `/** ${comment.value.trim()} ` : `/**\n${indent}*${comment.value.trimEnd()}\n${indent}`) + `*/${'\n'.repeat((lines || 1) - 1)}`; - return fixer.replaceText( /** @type {import('eslint').AST.Token} */ - comment, insertion); - }; - reportings(comment, node, addComment, contexts); - }; - - /** - * @param {import('eslint').Rule.Node} node - * @param {import('../iterateJsdoc.js').Context[]} ctxts - */ - const checkNonJsdocAfter = (node, ctxts) => { - const comment = (0, _jsdoccomment.getFollowingComment)(sourceCode, node); - if (!comment || comment.value.startsWith('*') || /** @type {string[]} */ - allowedPrefixes.some(prefix => { - return comment.value.trimStart().startsWith(prefix); - })) { - return; - } - - /** @type {AddComment} */ - const addComment = (inlineCommentBlock, comment, indent, lines, fixer) => { - const insertion = (inlineCommentBlock || enforceJsdocLineStyle === 'single' ? `/** ${comment.value.trim()} ` : `/**\n${indent}*${comment.value.trimEnd()}\n${indent}`) + `*/${'\n'.repeat((lines || 1) - 1)}${lines ? `\n${indent.slice(1)}` : ' '}`; - return [fixer.remove( /** @type {import('eslint').AST.Token} */ - comment), fixer.insertTextBefore(node.type === 'VariableDeclarator' ? node.parent : node, insertion)]; - }; - reportings(comment, node, addComment, ctxts); - }; - - // Todo: add contexts to check after (and handle if want both before and after) - return { - ..._jsdocUtils.default.getContextObject(_jsdocUtils.default.enforcedContexts(context, true, settings), checkNonJsdoc), - ..._jsdocUtils.default.getContextObject(contextsAfter, (_info, _handler, node) => { - checkNonJsdocAfter(node, contextsAfter); - }), - ..._jsdocUtils.default.getContextObject(contextsBeforeAndAfter, (_info, _handler, node) => { - checkNonJsdoc({}, null, node); - if (!reportingNonJsdoc) { - checkNonJsdocAfter(node, contextsBeforeAndAfter); - } - }) - }; - }, - meta: { - fixable: 'code', - messages: { - blockCommentsJsdocStyle: 'Block comments should be JSDoc-style.', - lineCommentsJsdocStyle: 'Line comments should be JSDoc-style.' - }, - docs: { - description: 'Converts non-JSDoc comments preceding or following nodes into JSDoc ones', - url: 'https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/convert-to-jsdoc-comments.md#repos-sticky-header' - }, - schema: [{ - additionalProperties: false, - properties: { - allowedPrefixes: { - type: 'array', - items: { - type: 'string' - } - }, - contexts: { - items: { - anyOf: [{ - type: 'string' - }, { - additionalProperties: false, - properties: { - context: { - type: 'string' - }, - inlineCommentBlock: { - type: 'boolean' - } - }, - type: 'object' - }] - }, - type: 'array' - }, - contextsAfter: { - items: { - anyOf: [{ - type: 'string' - }, { - additionalProperties: false, - properties: { - context: { - type: 'string' - }, - inlineCommentBlock: { - type: 'boolean' - } - }, - type: 'object' - }] - }, - type: 'array' - }, - contextsBeforeAndAfter: { - items: { - anyOf: [{ - type: 'string' - }, { - additionalProperties: false, - properties: { - context: { - type: 'string' - }, - inlineCommentBlock: { - type: 'boolean' - } - }, - type: 'object' - }] - }, - type: 'array' - }, - enableFixer: { - type: 'boolean' - }, - enforceJsdocLineStyle: { - type: 'string', - enum: ['multi', 'single'] - }, - lineOrBlockStyle: { - type: 'string', - enum: ['block', 'line', 'both'] - } - }, - type: 'object' - }], - type: 'suggestion' - } -}; -module.exports = exports.default; -//# sourceMappingURL=convertToJsdocComments.cjs.map \ No newline at end of file diff --git a/tools/eslint/node_modules/eslint-plugin-jsdoc/dist/rules/emptyTags.cjs b/tools/eslint/node_modules/eslint-plugin-jsdoc/dist/rules/emptyTags.cjs deleted file mode 100644 index 4d7430103a2ee9..00000000000000 --- a/tools/eslint/node_modules/eslint-plugin-jsdoc/dist/rules/emptyTags.cjs +++ /dev/null @@ -1,75 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.default = void 0; -var _iterateJsdoc = _interopRequireDefault(require("../iterateJsdoc.cjs")); -function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; } -const defaultEmptyTags = new Set(['abstract', 'async', 'generator', 'global', 'hideconstructor', 'ignore', 'inner', 'instance', 'override', 'readonly', -// jsdoc doesn't use this form in its docs, but allow for compatibility with -// TypeScript which allows and Closure which requires -'inheritDoc', -// jsdoc doesn't use but allow for TypeScript -'internal', 'overload']); -const emptyIfNotClosure = new Set(['package', 'private', 'protected', 'public', 'static', -// Closure doesn't allow with this casing -'inheritdoc']); -const emptyIfClosure = new Set(['interface']); -var _default = exports.default = (0, _iterateJsdoc.default)(({ - settings, - jsdoc, - utils -}) => { - const emptyTags = utils.filterTags(({ - tag: tagName - }) => { - return defaultEmptyTags.has(tagName) || utils.hasOptionTag(tagName) && jsdoc.tags.some(({ - tag - }) => { - return tag === tagName; - }) || settings.mode === 'closure' && emptyIfClosure.has(tagName) || settings.mode !== 'closure' && emptyIfNotClosure.has(tagName); - }); - for (const tag of emptyTags) { - const content = tag.name || tag.description || tag.type; - if (content.trim()) { - const fix = () => { - // By time of call in fixer, `tag` will have `line` added - utils.setTag( - /** - * @type {import('comment-parser').Spec & { - * line: import('../iterateJsdoc.js').Integer - * }} - */ - tag); - }; - utils.reportJSDoc(`@${tag.tag} should be empty.`, tag, fix, true); - } - } -}, { - checkInternal: true, - checkPrivate: true, - iterateAllJsdocs: true, - meta: { - docs: { - description: 'Expects specific tags to be empty of any content.', - url: 'https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/empty-tags.md#repos-sticky-header' - }, - fixable: 'code', - schema: [{ - additionalProperties: false, - properties: { - tags: { - items: { - type: 'string' - }, - type: 'array' - } - }, - type: 'object' - }], - type: 'suggestion' - } -}); -module.exports = exports.default; -//# sourceMappingURL=emptyTags.cjs.map \ No newline at end of file diff --git a/tools/eslint/node_modules/eslint-plugin-jsdoc/dist/rules/implementsOnClasses.cjs b/tools/eslint/node_modules/eslint-plugin-jsdoc/dist/rules/implementsOnClasses.cjs deleted file mode 100644 index 08a360972fe6f8..00000000000000 --- a/tools/eslint/node_modules/eslint-plugin-jsdoc/dist/rules/implementsOnClasses.cjs +++ /dev/null @@ -1,60 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.default = void 0; -var _iterateJsdoc = _interopRequireDefault(require("../iterateJsdoc.cjs")); -function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; } -var _default = exports.default = (0, _iterateJsdoc.default)(({ - report, - utils -}) => { - const iteratingFunction = utils.isIteratingFunction(); - if (iteratingFunction) { - if (utils.hasATag(['class', 'constructor']) || utils.isConstructor()) { - return; - } - } else if (!utils.isVirtualFunction()) { - return; - } - utils.forEachPreferredTag('implements', tag => { - report('@implements used on a non-constructor function', null, tag); - }); -}, { - contextDefaults: true, - meta: { - docs: { - description: 'Reports an issue with any non-constructor function using `@implements`.', - url: 'https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/implements-on-classes.md#repos-sticky-header' - }, - schema: [{ - additionalProperties: false, - properties: { - contexts: { - items: { - anyOf: [{ - type: 'string' - }, { - additionalProperties: false, - properties: { - comment: { - type: 'string' - }, - context: { - type: 'string' - } - }, - type: 'object' - }] - }, - type: 'array' - } - }, - type: 'object' - }], - type: 'suggestion' - } -}); -module.exports = exports.default; -//# sourceMappingURL=implementsOnClasses.cjs.map \ No newline at end of file diff --git a/tools/eslint/node_modules/eslint-plugin-jsdoc/dist/rules/importsAsDependencies.cjs b/tools/eslint/node_modules/eslint-plugin-jsdoc/dist/rules/importsAsDependencies.cjs deleted file mode 100644 index 914650ec28034e..00000000000000 --- a/tools/eslint/node_modules/eslint-plugin-jsdoc/dist/rules/importsAsDependencies.cjs +++ /dev/null @@ -1,106 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.default = void 0; -var _iterateJsdoc = _interopRequireDefault(require("../iterateJsdoc.cjs")); -var _jsdoccomment = require("@es-joy/jsdoccomment"); -var _fs = require("fs"); -var _nodeModule = require("node:module"); -var _path = require("path"); -function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; } -/** - * @type {Set|null} - */ -let deps; -const setDeps = function () { - try { - const pkg = JSON.parse( - // @ts-expect-error It's ok - (0, _fs.readFileSync)((0, _path.join)(process.cwd(), './package.json'))); - deps = new Set([...(pkg.dependencies ? /* c8 ignore next 2 */ - Object.keys(pkg.dependencies) : []), ...(pkg.devDependencies ? /* c8 ignore next 2 */ - Object.keys(pkg.devDependencies) : [])]); - /* c8 ignore next -- our package.json exists */ - } catch (error) { - /* c8 ignore next -- our package.json exists */ - deps = null; - /* c8 ignore next 4 -- our package.json exists */ - /* eslint-disable no-console -- Inform user */ - console.log(error); - /* eslint-enable no-console -- Inform user */ - } -}; -const moduleCheck = new Map(); -var _default = exports.default = (0, _iterateJsdoc.default)(({ - jsdoc, - settings, - utils -}) => { - if (deps === undefined) { - setDeps(); - } - - /* c8 ignore next 3 -- our package.json exists */ - if (deps === null) { - return; - } - const { - mode - } = settings; - for (const tag of jsdoc.tags) { - let typeAst; - try { - typeAst = mode === 'permissive' ? (0, _jsdoccomment.tryParse)(tag.type) : (0, _jsdoccomment.parse)(tag.type, mode); - } catch { - continue; - } - - // eslint-disable-next-line no-loop-func -- Safe - (0, _jsdoccomment.traverse)(typeAst, nde => { - /* c8 ignore next 3 -- TS guard */ - if (deps === null) { - return; - } - if (nde.type === 'JsdocTypeImport') { - let mod = nde.element.value.replace(/^(@[^/]+\/[^/]+|[^/]+).*$/u, '$1'); - if (/^[./]/u.test(mod)) { - return; - } - if ((0, _nodeModule.isBuiltin)(mod)) { - // mod = '@types/node'; - // moduleCheck.set(mod, !deps.has(mod)); - return; - } else if (!moduleCheck.has(mod)) { - let pkg; - try { - pkg = JSON.parse( - // @ts-expect-error It's ok - (0, _fs.readFileSync)((0, _path.join)(process.cwd(), 'node_modules', mod, './package.json'))); - } catch { - // Ignore - } - if (!pkg || !pkg.types && !pkg.typings) { - mod = `@types/${mod}`; - } - moduleCheck.set(mod, !deps.has(mod)); - } - if (moduleCheck.get(mod)) { - utils.reportJSDoc('import points to package which is not found in dependencies', tag); - } - } - }); - } -}, { - iterateAllJsdocs: true, - meta: { - docs: { - description: 'Reports if JSDoc `import()` statements point to a package which is not listed in `dependencies` or `devDependencies`', - url: 'https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/imports-as-dependencies.md#repos-sticky-header' - }, - type: 'suggestion' - } -}); -module.exports = exports.default; -//# sourceMappingURL=importsAsDependencies.cjs.map \ No newline at end of file diff --git a/tools/eslint/node_modules/eslint-plugin-jsdoc/dist/rules/informativeDocs.cjs b/tools/eslint/node_modules/eslint-plugin-jsdoc/dist/rules/informativeDocs.cjs deleted file mode 100644 index bfe3940262735c..00000000000000 --- a/tools/eslint/node_modules/eslint-plugin-jsdoc/dist/rules/informativeDocs.cjs +++ /dev/null @@ -1,148 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.default = void 0; -var _iterateJsdoc = _interopRequireDefault(require("../iterateJsdoc.cjs")); -var _areDocsInformative = require("are-docs-informative"); -function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; } -const defaultAliases = { - a: ['an', 'our'] -}; -const defaultUselessWords = ['a', 'an', 'i', 'in', 'of', 's', 'the']; - -/* eslint-disable complexity -- Temporary */ - -/** - * @param {import('eslint').Rule.Node|import('@typescript-eslint/types').TSESTree.Node|null|undefined} node - * @returns {string[]} - */ -const getNamesFromNode = node => { - switch (node === null || node === void 0 ? void 0 : node.type) { - case 'AccessorProperty': - case 'MethodDefinition': - case 'PropertyDefinition': - case 'TSAbstractAccessorProperty': - case 'TSAbstractMethodDefinition': - case 'TSAbstractPropertyDefinition': - return [...getNamesFromNode( /** @type {import('@typescript-eslint/types').TSESTree.Node} */node.parent.parent), ...getNamesFromNode( /** @type {import('@typescript-eslint/types').TSESTree.Node} */ - node.key)]; - case 'ExportDefaultDeclaration': - case 'ExportNamedDeclaration': - return getNamesFromNode( /** @type {import('@typescript-eslint/types').TSESTree.ExportNamedDeclaration} */ - node.declaration); - case 'ClassDeclaration': - case 'ClassExpression': - case 'FunctionDeclaration': - case 'FunctionExpression': - case 'TSModuleDeclaration': - case 'TSMethodSignature': - case 'TSDeclareFunction': - case 'TSEnumDeclaration': - case 'TSEnumMember': - case 'TSInterfaceDeclaration': - case 'TSTypeAliasDeclaration': - return getNamesFromNode( /** @type {import('@typescript-eslint/types').TSESTree.ClassDeclaration} */ - node.id); - case 'Identifier': - return [node.name]; - case 'Property': - return getNamesFromNode( /** @type {import('@typescript-eslint/types').TSESTree.Node} */ - node.key); - case 'VariableDeclaration': - return getNamesFromNode( /** @type {import('@typescript-eslint/types').TSESTree.Node} */ - node.declarations[0]); - case 'VariableDeclarator': - return [...getNamesFromNode( /** @type {import('@typescript-eslint/types').TSESTree.Node} */ - node.id), ...getNamesFromNode( /** @type {import('@typescript-eslint/types').TSESTree.Node} */ - node.init)].filter(Boolean); - default: - return []; - } -}; -/* eslint-enable complexity -- Temporary */ -var _default = exports.default = (0, _iterateJsdoc.default)(({ - context, - jsdoc, - node, - report, - utils -}) => { - const /** @type {{aliases: {[key: string]: string[]}, excludedTags: string[], uselessWords: string[]}} */{ - aliases = defaultAliases, - excludedTags = [], - uselessWords = defaultUselessWords - } = context.options[0] || {}; - const nodeNames = getNamesFromNode(node); - - /** - * @param {string} text - * @param {string} extraName - * @returns {boolean} - */ - const descriptionIsRedundant = (text, extraName = '') => { - const textTrimmed = text.trim(); - return Boolean(textTrimmed) && !(0, _areDocsInformative.areDocsInformative)(textTrimmed, [extraName, nodeNames].filter(Boolean).join(' '), { - aliases, - uselessWords - }); - }; - const { - description, - lastDescriptionLine - } = utils.getDescription(); - let descriptionReported = false; - for (const tag of jsdoc.tags) { - if (excludedTags.includes(tag.tag)) { - continue; - } - if (descriptionIsRedundant(tag.description, tag.name)) { - utils.reportJSDoc('This tag description only repeats the name it describes.', tag); - } - descriptionReported ||= tag.description === description && /** @type {import('comment-parser').Spec & {line: import('../iterateJsdoc.js').Integer}} */ - tag.line === lastDescriptionLine; - } - if (!descriptionReported && descriptionIsRedundant(description)) { - report('This description only repeats the name it describes.'); - } -}, { - iterateAllJsdocs: true, - meta: { - docs: { - description: 'This rule reports doc comments that only restate their attached name.', - url: 'https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/informative-docs.md#repos-sticky-header' - }, - schema: [{ - additionalProperties: false, - properties: { - aliases: { - patternProperties: { - '.*': { - items: { - type: 'string' - }, - type: 'array' - } - } - }, - excludedTags: { - items: { - type: 'string' - }, - type: 'array' - }, - uselessWords: { - items: { - type: 'string' - }, - type: 'array' - } - }, - type: 'object' - }], - type: 'suggestion' - } -}); -module.exports = exports.default; -//# sourceMappingURL=informativeDocs.cjs.map \ No newline at end of file diff --git a/tools/eslint/node_modules/eslint-plugin-jsdoc/dist/rules/matchDescription.cjs b/tools/eslint/node_modules/eslint-plugin-jsdoc/dist/rules/matchDescription.cjs deleted file mode 100644 index 921677b04df276..00000000000000 --- a/tools/eslint/node_modules/eslint-plugin-jsdoc/dist/rules/matchDescription.cjs +++ /dev/null @@ -1,229 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.default = void 0; -var _iterateJsdoc = _interopRequireDefault(require("../iterateJsdoc.cjs")); -function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; } -// If supporting Node >= 10, we could loosen the default to this for the -// initial letter: \\p{Upper} -const matchDescriptionDefault = '^\n?([A-Z`\\d_][\\s\\S]*[.?!`]\\s*)?$'; - -/** - * @param {string} value - * @param {string} userDefault - * @returns {string} - */ -const stringOrDefault = (value, userDefault) => { - return typeof value === 'string' ? value : userDefault || matchDescriptionDefault; -}; -var _default = exports.default = (0, _iterateJsdoc.default)(({ - jsdoc, - report, - context, - utils -}) => { - const { - mainDescription, - matchDescription, - message, - nonemptyTags = true, - tags = {} - } = context.options[0] || {}; - - /** - * @param {string} desc - * @param {import('comment-parser').Spec} [tag] - * @returns {void} - */ - const validateDescription = (desc, tag) => { - let mainDescriptionMatch = mainDescription; - let errorMessage = message; - if (typeof mainDescription === 'object') { - mainDescriptionMatch = mainDescription.match; - errorMessage = mainDescription.message; - } - if (mainDescriptionMatch === false && (!tag || !Object.prototype.hasOwnProperty.call(tags, tag.tag))) { - return; - } - let tagValue = mainDescriptionMatch; - if (tag) { - const tagName = tag.tag; - if (typeof tags[tagName] === 'object') { - tagValue = tags[tagName].match; - errorMessage = tags[tagName].message; - } else { - tagValue = tags[tagName]; - } - } - const regex = utils.getRegexFromString(stringOrDefault(tagValue, matchDescription)); - if (!regex.test(desc)) { - report(errorMessage || 'JSDoc description does not satisfy the regex pattern.', null, tag || { - // Add one as description would typically be into block - line: jsdoc.source[0].number + 1 - }); - } - }; - const { - description - } = utils.getDescription(); - if (description) { - validateDescription(description); - } - - /** - * @param {string} tagName - * @returns {boolean} - */ - const hasNoTag = tagName => { - return !tags[tagName]; - }; - for (const tag of ['description', 'summary', 'file', 'classdesc']) { - utils.forEachPreferredTag(tag, (matchingJsdocTag, targetTagName) => { - const desc = (matchingJsdocTag.name + ' ' + utils.getTagDescription(matchingJsdocTag)).trim(); - if (hasNoTag(targetTagName)) { - validateDescription(desc, matchingJsdocTag); - } - }, true); - } - if (nonemptyTags) { - for (const tag of ['copyright', 'example', 'see', 'todo']) { - utils.forEachPreferredTag(tag, (matchingJsdocTag, targetTagName) => { - const desc = (matchingJsdocTag.name + ' ' + utils.getTagDescription(matchingJsdocTag)).trim(); - if (hasNoTag(targetTagName) && !/.+/u.test(desc)) { - report('JSDoc description must not be empty.', null, matchingJsdocTag); - } - }); - } - } - if (!Object.keys(tags).length) { - return; - } - - /** - * @param {string} tagName - * @returns {boolean} - */ - const hasOptionTag = tagName => { - return Boolean(tags[tagName]); - }; - const whitelistedTags = utils.filterTags(({ - tag: tagName - }) => { - return hasOptionTag(tagName); - }); - const { - tagsWithNames, - tagsWithoutNames - } = utils.getTagsByType(whitelistedTags); - tagsWithNames.some(tag => { - const desc = /** @type {string} */utils.getTagDescription(tag).replace(/^[- ]*/u, '').trim(); - return validateDescription(desc, tag); - }); - tagsWithoutNames.some(tag => { - const desc = (tag.name + ' ' + utils.getTagDescription(tag)).trim(); - return validateDescription(desc, tag); - }); -}, { - contextDefaults: true, - meta: { - docs: { - description: 'Enforces a regular expression pattern on descriptions.', - url: 'https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/match-description.md#repos-sticky-header' - }, - schema: [{ - additionalProperties: false, - properties: { - contexts: { - items: { - anyOf: [{ - type: 'string' - }, { - additionalProperties: false, - properties: { - comment: { - type: 'string' - }, - context: { - type: 'string' - } - }, - type: 'object' - }] - }, - type: 'array' - }, - mainDescription: { - oneOf: [{ - format: 'regex', - type: 'string' - }, { - type: 'boolean' - }, { - additionalProperties: false, - properties: { - match: { - oneOf: [{ - format: 'regex', - type: 'string' - }, { - type: 'boolean' - }] - }, - message: { - type: 'string' - } - }, - type: 'object' - }] - }, - matchDescription: { - format: 'regex', - type: 'string' - }, - message: { - type: 'string' - }, - nonemptyTags: { - type: 'boolean' - }, - tags: { - patternProperties: { - '.*': { - oneOf: [{ - format: 'regex', - type: 'string' - }, { - enum: [true], - type: 'boolean' - }, { - additionalProperties: false, - properties: { - match: { - oneOf: [{ - format: 'regex', - type: 'string' - }, { - enum: [true], - type: 'boolean' - }] - }, - message: { - type: 'string' - } - }, - type: 'object' - }] - } - }, - type: 'object' - } - }, - type: 'object' - }], - type: 'suggestion' - } -}); -module.exports = exports.default; -//# sourceMappingURL=matchDescription.cjs.map \ No newline at end of file diff --git a/tools/eslint/node_modules/eslint-plugin-jsdoc/dist/rules/matchName.cjs b/tools/eslint/node_modules/eslint-plugin-jsdoc/dist/rules/matchName.cjs deleted file mode 100644 index d279b6fa39a5f0..00000000000000 --- a/tools/eslint/node_modules/eslint-plugin-jsdoc/dist/rules/matchName.cjs +++ /dev/null @@ -1,128 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.default = void 0; -var _iterateJsdoc = _interopRequireDefault(require("../iterateJsdoc.cjs")); -function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; } -// eslint-disable-next-line complexity -var _default = exports.default = (0, _iterateJsdoc.default)(({ - context, - jsdoc, - report, - info: { - lastIndex - }, - utils -}) => { - const { - match - } = context.options[0] || {}; - if (!match) { - report('Rule `no-restricted-syntax` is missing a `match` option.'); - return; - } - const { - allowName, - disallowName, - replacement, - tags = ['*'] - } = match[( /** @type {import('../iterateJsdoc.js').Integer} */lastIndex)]; - const allowNameRegex = allowName && utils.getRegexFromString(allowName); - const disallowNameRegex = disallowName && utils.getRegexFromString(disallowName); - let applicableTags = jsdoc.tags; - if (!tags.includes('*')) { - applicableTags = utils.getPresentTags(tags); - } - let reported = false; - for (const tag of applicableTags) { - const allowed = !allowNameRegex || allowNameRegex.test(tag.name); - const disallowed = disallowNameRegex && disallowNameRegex.test(tag.name); - const hasRegex = allowNameRegex || disallowNameRegex; - if (hasRegex && allowed && !disallowed) { - continue; - } - if (!hasRegex && reported) { - continue; - } - const fixer = () => { - for (const src of tag.source) { - if (src.tokens.name) { - src.tokens.name = src.tokens.name.replace(disallowNameRegex, replacement); - break; - } - } - }; - let { - message - } = match[( /** @type {import('../iterateJsdoc.js').Integer} */lastIndex)]; - if (!message) { - if (hasRegex) { - message = disallowed ? `Only allowing names not matching \`${disallowNameRegex}\` but found "${tag.name}".` : `Only allowing names matching \`${allowNameRegex}\` but found "${tag.name}".`; - } else { - message = `Prohibited context for "${tag.name}".`; - } - } - utils.reportJSDoc(message, hasRegex ? tag : null, - // We could match up - disallowNameRegex && replacement !== undefined ? fixer : null, false, { - // Could also supply `context`, `comment`, `tags` - allowName, - disallowName, - name: tag.name - }); - if (!hasRegex) { - reported = true; - } - } -}, { - matchContext: true, - meta: { - docs: { - description: 'Reports the name portion of a JSDoc tag if matching or not matching a given regular expression.', - url: 'https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/match-name.md#repos-sticky-header' - }, - fixable: 'code', - schema: [{ - additionalProperties: false, - properties: { - match: { - additionalProperties: false, - items: { - properties: { - allowName: { - type: 'string' - }, - comment: { - type: 'string' - }, - context: { - type: 'string' - }, - disallowName: { - type: 'string' - }, - message: { - type: 'string' - }, - tags: { - items: { - type: 'string' - }, - type: 'array' - } - }, - type: 'object' - }, - type: 'array' - } - }, - required: ['match'], - type: 'object' - }], - type: 'suggestion' - } -}); -module.exports = exports.default; -//# sourceMappingURL=matchName.cjs.map \ No newline at end of file diff --git a/tools/eslint/node_modules/eslint-plugin-jsdoc/dist/rules/multilineBlocks.cjs b/tools/eslint/node_modules/eslint-plugin-jsdoc/dist/rules/multilineBlocks.cjs deleted file mode 100644 index a1ac0c236dbf48..00000000000000 --- a/tools/eslint/node_modules/eslint-plugin-jsdoc/dist/rules/multilineBlocks.cjs +++ /dev/null @@ -1,237 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.default = void 0; -var _iterateJsdoc = _interopRequireDefault(require("../iterateJsdoc.cjs")); -function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; } -var _default = exports.default = (0, _iterateJsdoc.default)(({ - context, - jsdoc, - utils -}) => { - const { - allowMultipleTags = true, - noFinalLineText = true, - noZeroLineText = true, - noSingleLineBlocks = false, - singleLineTags = ['lends', 'type'], - noMultilineBlocks = false, - minimumLengthForMultiline = Number.POSITIVE_INFINITY, - multilineTags = ['*'] - } = context.options[0] || {}; - const { - source: [{ - tokens - }] - } = jsdoc; - const { - description, - tag - } = tokens; - const sourceLength = jsdoc.source.length; - - /** - * @param {string} tagName - * @returns {boolean} - */ - const isInvalidSingleLine = tagName => { - return noSingleLineBlocks && (!tagName || !singleLineTags.includes(tagName) && !singleLineTags.includes('*')); - }; - if (sourceLength === 1) { - if (!isInvalidSingleLine(tag.slice(1))) { - return; - } - const fixer = () => { - utils.makeMultiline(); - }; - utils.reportJSDoc('Single line blocks are not permitted by your configuration.', null, fixer, true); - return; - } - const lineChecks = () => { - if (noZeroLineText && (tag || description)) { - const fixer = () => { - const line = { - ...tokens - }; - utils.emptyTokens(tokens); - const { - tokens: { - delimiter, - start - } - } = jsdoc.source[1]; - utils.addLine(1, { - ...line, - delimiter, - start - }); - }; - utils.reportJSDoc('Should have no text on the "0th" line (after the `/**`).', null, fixer); - return; - } - const finalLine = jsdoc.source[jsdoc.source.length - 1]; - const finalLineTokens = finalLine.tokens; - if (noFinalLineText && finalLineTokens.description.trim()) { - const fixer = () => { - const line = { - ...finalLineTokens - }; - line.description = line.description.trimEnd(); - const { - delimiter - } = line; - for (const prop of ['delimiter', 'postDelimiter', 'tag', 'type', 'lineEnd', 'postType', 'postTag', 'name', 'postName', 'description']) { - finalLineTokens[( - /** - * @type {"delimiter"|"postDelimiter"|"tag"|"type"| - * "lineEnd"|"postType"|"postTag"|"name"| - * "postName"|"description"} - */ - prop)] = ''; - } - utils.addLine(jsdoc.source.length - 1, { - ...line, - delimiter, - end: '' - }); - }; - utils.reportJSDoc('Should have no text on the final line (before the `*/`).', null, fixer); - } - }; - if (noMultilineBlocks) { - if (jsdoc.tags.length && (multilineTags.includes('*') || utils.hasATag(multilineTags))) { - lineChecks(); - return; - } - if (jsdoc.description.length >= minimumLengthForMultiline) { - lineChecks(); - return; - } - if (noSingleLineBlocks && (!jsdoc.tags.length || !utils.filterTags(({ - tag: tg - }) => { - return !isInvalidSingleLine(tg); - }).length)) { - utils.reportJSDoc('Multiline jsdoc blocks are prohibited by ' + 'your configuration but fixing would result in a single ' + 'line block which you have prohibited with `noSingleLineBlocks`.'); - return; - } - if (jsdoc.tags.length > 1) { - if (!allowMultipleTags) { - utils.reportJSDoc('Multiline jsdoc blocks are prohibited by ' + 'your configuration but the block has multiple tags.'); - return; - } - } else if (jsdoc.tags.length === 1 && jsdoc.description.trim()) { - if (!allowMultipleTags) { - utils.reportJSDoc('Multiline jsdoc blocks are prohibited by ' + 'your configuration but the block has a description with a tag.'); - return; - } - } else { - const fixer = () => { - jsdoc.source = [{ - number: 1, - source: '', - tokens: jsdoc.source.reduce((obj, { - tokens: { - description: desc, - tag: tg, - type: typ, - name: nme, - lineEnd, - postType, - postName, - postTag - } - }) => { - if (typ) { - obj.type = typ; - } - if (tg && typ && nme) { - obj.postType = postType; - } - if (nme) { - obj.name += nme; - } - if (nme && desc) { - obj.postName = postName; - } - obj.description += desc; - const nameOrDescription = obj.description || obj.name; - if (nameOrDescription && nameOrDescription.slice(-1) !== ' ') { - obj.description += ' '; - } - obj.lineEnd = lineEnd; - - // Already filtered for multiple tags - obj.tag += tg; - if (tg) { - obj.postTag = postTag || ' '; - } - return obj; - }, utils.seedTokens({ - delimiter: '/**', - end: '*/', - postDelimiter: ' ' - })) - }]; - }; - utils.reportJSDoc('Multiline jsdoc blocks are prohibited by ' + 'your configuration.', null, fixer); - return; - } - } - lineChecks(); -}, { - iterateAllJsdocs: true, - meta: { - docs: { - description: 'Controls how and whether jsdoc blocks can be expressed as single or multiple line blocks.', - url: 'https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/multiline-blocks.md#repos-sticky-header' - }, - fixable: 'code', - schema: [{ - additionalProperties: false, - properties: { - allowMultipleTags: { - type: 'boolean' - }, - minimumLengthForMultiline: { - type: 'integer' - }, - multilineTags: { - anyOf: [{ - enum: ['*'], - type: 'string' - }, { - items: { - type: 'string' - }, - type: 'array' - }] - }, - noFinalLineText: { - type: 'boolean' - }, - noMultilineBlocks: { - type: 'boolean' - }, - noSingleLineBlocks: { - type: 'boolean' - }, - noZeroLineText: { - type: 'boolean' - }, - singleLineTags: { - items: { - type: 'string' - }, - type: 'array' - } - }, - type: 'object' - }], - type: 'suggestion' - } -}); -module.exports = exports.default; -//# sourceMappingURL=multilineBlocks.cjs.map \ No newline at end of file diff --git a/tools/eslint/node_modules/eslint-plugin-jsdoc/dist/rules/noBadBlocks.cjs b/tools/eslint/node_modules/eslint-plugin-jsdoc/dist/rules/noBadBlocks.cjs deleted file mode 100644 index 03a75c31c7105d..00000000000000 --- a/tools/eslint/node_modules/eslint-plugin-jsdoc/dist/rules/noBadBlocks.cjs +++ /dev/null @@ -1,87 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.default = void 0; -var _iterateJsdoc = _interopRequireDefault(require("../iterateJsdoc.cjs")); -var _commentParser = require("comment-parser"); -function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; } -// Neither a single nor 3+ asterisks are valid jsdoc per -// https://jsdoc.app/about-getting-started.html#adding-documentation-comments-to-your-code -const commentRegexp = /^\/\*(?!\*)/u; -const extraAsteriskCommentRegexp = /^\/\*{3,}/u; -var _default = exports.default = (0, _iterateJsdoc.default)(({ - context, - sourceCode, - allComments, - makeReport -}) => { - const [{ - ignore = ['ts-check', 'ts-expect-error', 'ts-ignore', 'ts-nocheck'], - preventAllMultiAsteriskBlocks = false - } = {}] = context.options; - let extraAsterisks = false; - const nonJsdocNodes = /** @type {import('estree').Node[]} */allComments.filter(comment => { - const commentText = sourceCode.getText(comment); - let sliceIndex = 2; - if (!commentRegexp.test(commentText)) { - var _extraAsteriskComment; - const multiline = (_extraAsteriskComment = extraAsteriskCommentRegexp.exec(commentText)) === null || _extraAsteriskComment === void 0 ? void 0 : _extraAsteriskComment[0]; - if (!multiline) { - return false; - } - sliceIndex = multiline.length; - extraAsterisks = true; - if (preventAllMultiAsteriskBlocks) { - return true; - } - } - const tags = ((0, _commentParser.parse)(`${commentText.slice(0, 2)}*${commentText.slice(sliceIndex)}`)[0] || {}).tags ?? []; - return tags.length && !tags.some(({ - tag - }) => { - return ignore.includes(tag); - }); - }); - if (!nonJsdocNodes.length) { - return; - } - for (const node of nonJsdocNodes) { - const report = /** @type {import('../iterateJsdoc.js').MakeReport} */makeReport(context, node); - - // eslint-disable-next-line no-loop-func - const fix = /** @type {import('eslint').Rule.ReportFixer} */fixer => { - const text = sourceCode.getText(node); - return fixer.replaceText(node, extraAsterisks ? text.replace(extraAsteriskCommentRegexp, '/**') : text.replace('/*', '/**')); - }; - report('Expected JSDoc-like comment to begin with two asterisks.', fix); - } -}, { - checkFile: true, - meta: { - docs: { - description: 'This rule checks for multi-line-style comments which fail to meet the criteria of a jsdoc block.', - url: 'https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/no-bad-blocks.md#repos-sticky-header' - }, - fixable: 'code', - schema: [{ - additionalProperties: false, - properties: { - ignore: { - items: { - type: 'string' - }, - type: 'array' - }, - preventAllMultiAsteriskBlocks: { - type: 'boolean' - } - }, - type: 'object' - }], - type: 'layout' - } -}); -module.exports = exports.default; -//# sourceMappingURL=noBadBlocks.cjs.map \ No newline at end of file diff --git a/tools/eslint/node_modules/eslint-plugin-jsdoc/dist/rules/noBlankBlockDescriptions.cjs b/tools/eslint/node_modules/eslint-plugin-jsdoc/dist/rules/noBlankBlockDescriptions.cjs deleted file mode 100644 index ee37cf6bc76ba7..00000000000000 --- a/tools/eslint/node_modules/eslint-plugin-jsdoc/dist/rules/noBlankBlockDescriptions.cjs +++ /dev/null @@ -1,63 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.default = void 0; -var _iterateJsdoc = _interopRequireDefault(require("../iterateJsdoc.cjs")); -function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; } -const anyWhitespaceLines = /^\s*$/u; -const atLeastTwoLinesWhitespace = /^[ \t]*\n[ \t]*\n\s*$/u; -var _default = exports.default = (0, _iterateJsdoc.default)(({ - jsdoc, - utils -}) => { - const { - description, - descriptions, - lastDescriptionLine - } = utils.getDescription(); - const regex = jsdoc.tags.length ? anyWhitespaceLines : atLeastTwoLinesWhitespace; - if (descriptions.length && regex.test(description)) { - if (jsdoc.tags.length) { - utils.reportJSDoc('There should be no blank lines in block descriptions followed by tags.', { - line: lastDescriptionLine - }, () => { - utils.setBlockDescription(() => { - // Remove all lines - return []; - }); - }); - } else { - utils.reportJSDoc('There should be no extra blank lines in block descriptions not followed by tags.', { - line: lastDescriptionLine - }, () => { - utils.setBlockDescription((info, seedTokens) => { - return [ - // Keep the starting line - { - number: 0, - source: '', - tokens: seedTokens({ - ...info, - description: '' - }) - }]; - }); - }); - } - } -}, { - iterateAllJsdocs: true, - meta: { - docs: { - description: 'Detects and removes extra lines of a blank block description', - url: 'https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/no-blank-block-descriptions.md#repos-sticky-header' - }, - fixable: 'whitespace', - schema: [], - type: 'layout' - } -}); -module.exports = exports.default; -//# sourceMappingURL=noBlankBlockDescriptions.cjs.map \ No newline at end of file diff --git a/tools/eslint/node_modules/eslint-plugin-jsdoc/dist/rules/noBlankBlocks.cjs b/tools/eslint/node_modules/eslint-plugin-jsdoc/dist/rules/noBlankBlocks.cjs deleted file mode 100644 index 7046d4282f34b3..00000000000000 --- a/tools/eslint/node_modules/eslint-plugin-jsdoc/dist/rules/noBlankBlocks.cjs +++ /dev/null @@ -1,52 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.default = void 0; -var _iterateJsdoc = _interopRequireDefault(require("../iterateJsdoc.cjs")); -function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; } -var _default = exports.default = (0, _iterateJsdoc.default)(({ - context, - jsdoc, - utils -}) => { - if (jsdoc.tags.length) { - return; - } - const { - description, - lastDescriptionLine - } = utils.getDescription(); - if (description.trim()) { - return; - } - const { - enableFixer - } = context.options[0] || {}; - utils.reportJSDoc('No empty blocks', { - line: lastDescriptionLine - }, enableFixer ? () => { - jsdoc.source.splice(0, jsdoc.source.length); - } : null); -}, { - iterateAllJsdocs: true, - meta: { - docs: { - description: 'Removes empty blocks with nothing but possibly line breaks', - url: 'https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/no-blank-blocks.md#repos-sticky-header' - }, - fixable: 'code', - schema: [{ - additionalProperties: false, - properties: { - enableFixer: { - type: 'boolean' - } - } - }], - type: 'suggestion' - } -}); -module.exports = exports.default; -//# sourceMappingURL=noBlankBlocks.cjs.map \ No newline at end of file diff --git a/tools/eslint/node_modules/eslint-plugin-jsdoc/dist/rules/noDefaults.cjs b/tools/eslint/node_modules/eslint-plugin-jsdoc/dist/rules/noDefaults.cjs deleted file mode 100644 index 7ba6c0946b1941..00000000000000 --- a/tools/eslint/node_modules/eslint-plugin-jsdoc/dist/rules/noDefaults.cjs +++ /dev/null @@ -1,83 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.default = void 0; -var _iterateJsdoc = _interopRequireDefault(require("../iterateJsdoc.cjs")); -function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; } -var _default = exports.default = (0, _iterateJsdoc.default)(({ - context, - utils -}) => { - const { - noOptionalParamNames - } = context.options[0] || {}; - const paramTags = utils.getPresentTags(['param', 'arg', 'argument']); - for (const tag of paramTags) { - if (noOptionalParamNames && tag.optional) { - utils.reportJSDoc(`Optional param names are not permitted on @${tag.tag}.`, tag, () => { - utils.changeTag(tag, { - name: tag.name.replace(/([^=]*)(=.+)?/u, '$1') - }); - }); - } else if (tag.default) { - utils.reportJSDoc(`Defaults are not permitted on @${tag.tag}.`, tag, () => { - utils.changeTag(tag, { - name: tag.name.replace(/([^=]*)(=.+)?/u, '[$1]') - }); - }); - } - } - const defaultTags = utils.getPresentTags(['default', 'defaultvalue']); - for (const tag of defaultTags) { - if (tag.description.trim()) { - utils.reportJSDoc(`Default values are not permitted on @${tag.tag}.`, tag, () => { - utils.changeTag(tag, { - description: '', - postTag: '' - }); - }); - } - } -}, { - contextDefaults: true, - meta: { - docs: { - description: 'This rule reports defaults being used on the relevant portion of `@param` or `@default`.', - url: 'https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/no-defaults.md#repos-sticky-header' - }, - fixable: 'code', - schema: [{ - additionalProperties: false, - properties: { - contexts: { - items: { - anyOf: [{ - type: 'string' - }, { - additionalProperties: false, - properties: { - comment: { - type: 'string' - }, - context: { - type: 'string' - } - }, - type: 'object' - }] - }, - type: 'array' - }, - noOptionalParamNames: { - type: 'boolean' - } - }, - type: 'object' - }], - type: 'suggestion' - } -}); -module.exports = exports.default; -//# sourceMappingURL=noDefaults.cjs.map \ No newline at end of file diff --git a/tools/eslint/node_modules/eslint-plugin-jsdoc/dist/rules/noMissingSyntax.cjs b/tools/eslint/node_modules/eslint-plugin-jsdoc/dist/rules/noMissingSyntax.cjs deleted file mode 100644 index 3e10b9ae4d97d6..00000000000000 --- a/tools/eslint/node_modules/eslint-plugin-jsdoc/dist/rules/noMissingSyntax.cjs +++ /dev/null @@ -1,176 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.default = void 0; -var _iterateJsdoc = _interopRequireDefault(require("../iterateJsdoc.cjs")); -function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; } -/** - * @typedef {{ - * comment: string, - * context: string, - * message: string, - * minimum: import('../iterateJsdoc.js').Integer - * }} ContextObject - */ - -/** - * @typedef {string|ContextObject} Context - */ - -/** - * @param {import('../iterateJsdoc.js').StateObject} state - * @returns {void} - */ -const setDefaults = state => { - if (!state.selectorMap) { - state.selectorMap = {}; - } -}; - -/** - * @param {import('../iterateJsdoc.js').StateObject} state - * @param {string} selector - * @param {string} comment - * @returns {void} - */ -const incrementSelector = (state, selector, comment) => { - if (!state.selectorMap[selector]) { - state.selectorMap[selector] = {}; - } - if (!state.selectorMap[selector][comment]) { - state.selectorMap[selector][comment] = 0; - } - state.selectorMap[selector][comment]++; -}; -var _default = exports.default = (0, _iterateJsdoc.default)(({ - context, - info: { - comment - }, - state, - utils -}) => { - if (!context.options[0]) { - // Handle error later - return; - } - - /** - * @type {Context[]} - */ - const contexts = context.options[0].contexts; - const { - contextStr - } = utils.findContext(contexts, comment); - setDefaults(state); - incrementSelector(state, contextStr, String(comment)); -}, { - contextSelected: true, - exit({ - context, - settings, - state - }) { - if (!context.options.length && !settings.contexts) { - context.report({ - loc: { - end: { - column: 1, - line: 1 - }, - start: { - column: 1, - line: 1 - } - }, - message: 'Rule `no-missing-syntax` is missing a `contexts` option.' - }); - return; - } - setDefaults(state); - - /** - * @type {Context[]} - */ - const contexts = (context.options[0] ?? {}).contexts ?? (settings === null || settings === void 0 ? void 0 : settings.contexts); - - // Report when MISSING - contexts.some(cntxt => { - const contextStr = typeof cntxt === 'object' ? cntxt.context ?? 'any' : cntxt; - const comment = typeof cntxt === 'string' ? '' : cntxt === null || cntxt === void 0 ? void 0 : cntxt.comment; - const contextKey = contextStr === 'any' ? 'undefined' : contextStr; - if ((!state.selectorMap[contextKey] || !state.selectorMap[contextKey][comment] || state.selectorMap[contextKey][comment] < ( - // @ts-expect-error comment would need an object, not string - (cntxt === null || cntxt === void 0 ? void 0 : cntxt.minimum) ?? 1)) && (contextStr !== 'any' || Object.values(state.selectorMap).every(cmmnt => { - return !cmmnt[comment] || cmmnt[comment] < ( - // @ts-expect-error comment would need an object, not string - (cntxt === null || cntxt === void 0 ? void 0 : cntxt.minimum) ?? 1); - }))) { - const message = typeof cntxt === 'string' ? 'Syntax is required: {{context}}' : (cntxt === null || cntxt === void 0 ? void 0 : cntxt.message) ?? 'Syntax is required: {{context}}' + (comment ? ' with {{comment}}' : ''); - context.report({ - data: { - comment, - context: contextStr - }, - loc: { - end: { - column: 1, - line: 1 - }, - start: { - column: 1, - line: 1 - } - }, - message - }); - return true; - } - return false; - }); - }, - matchContext: true, - meta: { - docs: { - description: 'Reports when certain comment structures are always expected.', - url: 'https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/no-missing-syntax.md#repos-sticky-header' - }, - fixable: 'code', - schema: [{ - additionalProperties: false, - properties: { - contexts: { - items: { - anyOf: [{ - type: 'string' - }, { - additionalProperties: false, - properties: { - comment: { - type: 'string' - }, - context: { - type: 'string' - }, - message: { - type: 'string' - }, - minimum: { - type: 'integer' - } - }, - type: 'object' - }] - }, - type: 'array' - } - }, - type: 'object' - }], - type: 'suggestion' - } -}); -module.exports = exports.default; -//# sourceMappingURL=noMissingSyntax.cjs.map \ No newline at end of file diff --git a/tools/eslint/node_modules/eslint-plugin-jsdoc/dist/rules/noMultiAsterisks.cjs b/tools/eslint/node_modules/eslint-plugin-jsdoc/dist/rules/noMultiAsterisks.cjs deleted file mode 100644 index fcd5ca53df81e0..00000000000000 --- a/tools/eslint/node_modules/eslint-plugin-jsdoc/dist/rules/noMultiAsterisks.cjs +++ /dev/null @@ -1,99 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.default = void 0; -var _iterateJsdoc = _interopRequireDefault(require("../iterateJsdoc.cjs")); -function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; } -const middleAsterisksBlockWS = /^([\t ]|\*(?!\*))+/u; -const middleAsterisksNoBlockWS = /^\*+/u; -const endAsterisksSingleLineBlockWS = /\*((?:\*|(?: |\t))*)\*$/u; -const endAsterisksMultipleLineBlockWS = /((?:\*|(?: |\t))*)\*$/u; -const endAsterisksSingleLineNoBlockWS = /\*(\**)\*$/u; -const endAsterisksMultipleLineNoBlockWS = /(\**)\*$/u; -var _default = exports.default = (0, _iterateJsdoc.default)(({ - context, - jsdoc, - utils -}) => { - const { - allowWhitespace = false, - preventAtEnd = true, - preventAtMiddleLines = true - } = context.options[0] || {}; - const middleAsterisks = allowWhitespace ? middleAsterisksNoBlockWS : middleAsterisksBlockWS; - - // eslint-disable-next-line complexity -- Todo - jsdoc.source.some(({ - tokens, - number - }) => { - const { - delimiter, - tag, - name, - type, - description, - end, - postDelimiter - } = tokens; - if (preventAtMiddleLines && !end && !tag && !type && !name && (!allowWhitespace && middleAsterisks.test(description) || allowWhitespace && middleAsterisks.test(postDelimiter + description))) { - // console.log('description', JSON.stringify(description)); - const fix = () => { - tokens.description = description.replace(middleAsterisks, ''); - }; - utils.reportJSDoc('Should be no multiple asterisks on middle lines.', { - line: number - }, fix, true); - return true; - } - if (!preventAtEnd || !end) { - return false; - } - const isSingleLineBlock = delimiter === '/**'; - const delim = isSingleLineBlock ? '*' : delimiter; - const endAsterisks = allowWhitespace ? isSingleLineBlock ? endAsterisksSingleLineNoBlockWS : endAsterisksMultipleLineNoBlockWS : isSingleLineBlock ? endAsterisksSingleLineBlockWS : endAsterisksMultipleLineBlockWS; - const endingAsterisksAndSpaces = (allowWhitespace ? postDelimiter + description + delim : description + delim).match(endAsterisks); - if (!endingAsterisksAndSpaces || !isSingleLineBlock && endingAsterisksAndSpaces[1] && !endingAsterisksAndSpaces[1].trim()) { - return false; - } - const endFix = () => { - if (!isSingleLineBlock) { - tokens.delimiter = ''; - } - tokens.description = (description + delim).replace(endAsterisks, ''); - }; - utils.reportJSDoc('Should be no multiple asterisks on end lines.', { - line: number - }, endFix, true); - return true; - }); -}, { - iterateAllJsdocs: true, - meta: { - docs: { - description: '', - url: 'https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/no-multi-asterisks.md#repos-sticky-header' - }, - fixable: 'code', - schema: [{ - additionalProperties: false, - properties: { - allowWhitespace: { - type: 'boolean' - }, - preventAtEnd: { - type: 'boolean' - }, - preventAtMiddleLines: { - type: 'boolean' - } - }, - type: 'object' - }], - type: 'suggestion' - } -}); -module.exports = exports.default; -//# sourceMappingURL=noMultiAsterisks.cjs.map \ No newline at end of file diff --git a/tools/eslint/node_modules/eslint-plugin-jsdoc/dist/rules/noRestrictedSyntax.cjs b/tools/eslint/node_modules/eslint-plugin-jsdoc/dist/rules/noRestrictedSyntax.cjs deleted file mode 100644 index e1ecde36f02363..00000000000000 --- a/tools/eslint/node_modules/eslint-plugin-jsdoc/dist/rules/noRestrictedSyntax.cjs +++ /dev/null @@ -1,83 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.default = void 0; -var _iterateJsdoc = _interopRequireDefault(require("../iterateJsdoc.cjs")); -function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; } -var _default = exports.default = (0, _iterateJsdoc.default)(({ - context, - info: { - comment - }, - report, - utils -}) => { - if (!context.options.length) { - report('Rule `no-restricted-syntax` is missing a `contexts` option.'); - return; - } - const { - contexts - } = context.options[0]; - const { - foundContext, - contextStr - } = utils.findContext(contexts, comment); - - // We are not on the *particular* matching context/comment, so don't assume - // we need reporting - if (!foundContext) { - return; - } - const message = /** @type {import('../iterateJsdoc.js').ContextObject} */(foundContext === null || foundContext === void 0 ? void 0 : foundContext.message) ?? 'Syntax is restricted: {{context}}' + (comment ? ' with {{comment}}' : ''); - report(message, null, null, comment ? { - comment, - context: contextStr - } : { - context: contextStr - }); -}, { - contextSelected: true, - meta: { - docs: { - description: 'Reports when certain comment structures are present.', - url: 'https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/no-restricted-syntax.md#repos-sticky-header' - }, - fixable: 'code', - schema: [{ - additionalProperties: false, - properties: { - contexts: { - items: { - anyOf: [{ - type: 'string' - }, { - additionalProperties: false, - properties: { - comment: { - type: 'string' - }, - context: { - type: 'string' - }, - message: { - type: 'string' - } - }, - type: 'object' - }] - }, - type: 'array' - } - }, - required: ['contexts'], - type: 'object' - }], - type: 'suggestion' - }, - nonGlobalSettings: true -}); -module.exports = exports.default; -//# sourceMappingURL=noRestrictedSyntax.cjs.map \ No newline at end of file diff --git a/tools/eslint/node_modules/eslint-plugin-jsdoc/dist/rules/noTypes.cjs b/tools/eslint/node_modules/eslint-plugin-jsdoc/dist/rules/noTypes.cjs deleted file mode 100644 index 8e1998156e3cc0..00000000000000 --- a/tools/eslint/node_modules/eslint-plugin-jsdoc/dist/rules/noTypes.cjs +++ /dev/null @@ -1,73 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.default = void 0; -var _iterateJsdoc = _interopRequireDefault(require("../iterateJsdoc.cjs")); -function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; } -/** - * @param {import('comment-parser').Line} line - */ -const removeType = ({ - tokens -}) => { - tokens.postTag = ''; - tokens.type = ''; -}; -var _default = exports.default = (0, _iterateJsdoc.default)(({ - utils -}) => { - if (!utils.isIteratingFunction() && !utils.isVirtualFunction()) { - return; - } - const tags = utils.getPresentTags(['param', 'arg', 'argument', 'returns', 'return']); - for (const tag of tags) { - if (tag.type) { - utils.reportJSDoc(`Types are not permitted on @${tag.tag}.`, tag, () => { - for (const source of tag.source) { - removeType(source); - } - }); - } - } -}, { - contextDefaults: ['ArrowFunctionExpression', 'FunctionDeclaration', 'FunctionExpression', 'TSDeclareFunction', - // Add this to above defaults - 'TSMethodSignature'], - meta: { - docs: { - description: 'This rule reports types being used on `@param` or `@returns`.', - url: 'https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/no-types.md#repos-sticky-header' - }, - fixable: 'code', - schema: [{ - additionalProperties: false, - properties: { - contexts: { - items: { - anyOf: [{ - type: 'string' - }, { - additionalProperties: false, - properties: { - comment: { - type: 'string' - }, - context: { - type: 'string' - } - }, - type: 'object' - }] - }, - type: 'array' - } - }, - type: 'object' - }], - type: 'suggestion' - } -}); -module.exports = exports.default; -//# sourceMappingURL=noTypes.cjs.map \ No newline at end of file diff --git a/tools/eslint/node_modules/eslint-plugin-jsdoc/dist/rules/noUndefinedTypes.cjs b/tools/eslint/node_modules/eslint-plugin-jsdoc/dist/rules/noUndefinedTypes.cjs deleted file mode 100644 index 281a448853611f..00000000000000 --- a/tools/eslint/node_modules/eslint-plugin-jsdoc/dist/rules/noUndefinedTypes.cjs +++ /dev/null @@ -1,300 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.default = void 0; -var _path = require("path"); -var _url = require("url"); -var _synckit = require("synckit"); -var _jsdoccomment = require("@es-joy/jsdoccomment"); -var _iterateJsdoc = _interopRequireWildcard(require("../iterateJsdoc.cjs")); -function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); } -function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; } -const _dirname = (0, _path.dirname)((0, _url.fileURLToPath)(require('url').pathToFileURL(__filename).toString())); -const pathName = (0, _path.join)(_dirname, '../import-worker.mjs'); -const extraTypes = ['null', 'undefined', 'void', 'string', 'boolean', 'object', 'function', 'symbol', 'number', 'bigint', 'NaN', 'Infinity', 'any', '*', 'never', 'unknown', 'const', 'this', 'true', 'false', 'Array', 'Object', 'RegExp', 'Date', 'Function']; -const typescriptGlobals = [ -// https://www.typescriptlang.org/docs/handbook/utility-types.html -'Awaited', 'Partial', 'Required', 'Readonly', 'Record', 'Pick', 'Omit', 'Exclude', 'Extract', 'NonNullable', 'Parameters', 'ConstructorParameters', 'ReturnType', 'InstanceType', 'ThisParameterType', 'OmitThisParameter', 'ThisType', 'Uppercase', 'Lowercase', 'Capitalize', 'Uncapitalize']; - -/** - * @param {string|false|undefined} [str] - * @returns {undefined|string|false} - */ -const stripPseudoTypes = str => { - return str && str.replace(/(?:\.|<>|\.<>|\[\])$/u, ''); -}; -var _default = exports.default = (0, _iterateJsdoc.default)(({ - context, - node, - report, - settings, - sourceCode, - utils -}) => { - var _globalScope$childSco; - const { - scopeManager - } = sourceCode; - - // When is this ever `null`? - const globalScope = /** @type {import('eslint').Scope.Scope} */ - scopeManager.globalScope; - const - /** - * @type {{ - * definedTypes: string[], - * disableReporting: boolean, - * markVariablesAsUsed: boolean - * }} - */ - { - definedTypes = [], - disableReporting = false, - markVariablesAsUsed = true - } = context.options[0] || {}; - - /** @type {(string|undefined)[]} */ - let definedPreferredTypes = []; - const { - preferredTypes, - structuredTags, - mode - } = settings; - if (Object.keys(preferredTypes).length) { - definedPreferredTypes = /** @type {string[]} */Object.values(preferredTypes).map(preferredType => { - if (typeof preferredType === 'string') { - // May become an empty string but will be filtered out below - return stripPseudoTypes(preferredType); - } - if (!preferredType) { - return undefined; - } - if (typeof preferredType !== 'object') { - utils.reportSettings('Invalid `settings.jsdoc.preferredTypes`. Values must be falsy, a string, or an object.'); - } - return stripPseudoTypes(preferredType.replacement); - }).filter(Boolean); - } - const comments = sourceCode.getAllComments().filter(comment => { - return /^\*\s/u.test(comment.value); - }).map(commentNode => { - return (0, _iterateJsdoc.parseComment)(commentNode, ''); - }); - const typedefDeclarations = comments.flatMap(doc => { - return doc.tags.filter(({ - tag - }) => { - return utils.isNamepathDefiningTag(tag); - }); - }).map(tag => { - return tag.name; - }); - const importTags = settings.mode === 'typescript' ? ( /** @type {string[]} */comments.flatMap(doc => { - return doc.tags.filter(({ - tag - }) => { - return tag === 'import'; - }); - }).flatMap(tag => { - const { - type, - name, - description - } = tag; - const typePart = type ? `{${type}} ` : ''; - const imprt = 'import ' + (description ? `${typePart}${name} ${description}` : `${typePart}${name}`); - const getImports = (0, _synckit.createSyncFn)(pathName); - const imports = /** @type {import('parse-imports').Import[]} */getImports(imprt); - if (!imports) { - return null; - } - return imports.flatMap(({ - importClause - }) => { - /* c8 ignore next */ - const { - default: dflt, - named, - namespace - } = importClause || {}; - const types = []; - if (dflt) { - types.push(dflt); - } - if (namespace) { - types.push(namespace); - } - if (named) { - for (const { - binding - } of named) { - types.push(binding); - } - } - return types; - }); - }).filter(Boolean)) : []; - const ancestorNodes = []; - let currentNode = node; - // No need for Program node? - while ((_currentNode = currentNode) !== null && _currentNode !== void 0 && _currentNode.parent) { - var _currentNode; - ancestorNodes.push(currentNode); - currentNode = currentNode.parent; - } - - /** - * @param {import('eslint').Rule.Node} ancestorNode - * @returns {import('comment-parser').Spec[]} - */ - const getTemplateTags = function (ancestorNode) { - const commentNode = (0, _jsdoccomment.getJSDocComment)(sourceCode, ancestorNode, settings); - if (!commentNode) { - return []; - } - const jsdoc = (0, _iterateJsdoc.parseComment)(commentNode, ''); - return jsdoc.tags.filter(tag => { - return tag.tag === 'template'; - }); - }; - - // `currentScope` may be `null` or `Program`, so in such a case, - // we look to present tags instead - const templateTags = ancestorNodes.length ? ancestorNodes.flatMap(ancestorNode => { - return getTemplateTags(ancestorNode); - }) : utils.getPresentTags(['template']); - const closureGenericTypes = templateTags.flatMap(tag => { - return utils.parseClosureTemplateTag(tag); - }); - - // In modules, including Node, there is a global scope at top with the - // Program scope inside - const cjsOrESMScope = ((_globalScope$childSco = globalScope.childScopes[0]) === null || _globalScope$childSco === void 0 || (_globalScope$childSco = _globalScope$childSco.block) === null || _globalScope$childSco === void 0 ? void 0 : _globalScope$childSco.type) === 'Program'; - const allDefinedTypes = new Set(globalScope.variables.map(({ - name - }) => { - return name; - }) - - // If the file is a module, concat the variables from the module scope. - .concat(cjsOrESMScope ? globalScope.childScopes.flatMap(({ - variables - }) => { - return variables; - }).map(({ - name - }) => { - return name; - /* c8 ignore next */ - }) : []).concat(extraTypes).concat(typedefDeclarations).concat(importTags).concat(definedTypes).concat( /** @type {string[]} */definedPreferredTypes).concat(settings.mode === 'jsdoc' ? [] : [...(settings.mode === 'typescript' ? typescriptGlobals : []), ...closureGenericTypes])); - - /** - * @typedef {{ - * parsedType: import('jsdoc-type-pratt-parser').RootResult; - * tag: import('comment-parser').Spec|import('@es-joy/jsdoccomment').JsdocInlineTagNoType & { - * line?: import('../iterateJsdoc.js').Integer - * } - * }} TypeAndTagInfo - */ - - /** - * @param {string} propertyName - * @returns {(tag: (import('@es-joy/jsdoccomment').JsdocInlineTagNoType & { - * name?: string, - * type?: string, - * line?: import('../iterateJsdoc.js').Integer - * })|import('comment-parser').Spec & { - * namepathOrURL?: string - * } - * ) => undefined|TypeAndTagInfo} - */ - const tagToParsedType = propertyName => { - return tag => { - try { - const potentialType = tag[( /** @type {"type"|"name"|"namepathOrURL"} */propertyName)]; - return { - parsedType: mode === 'permissive' ? (0, _jsdoccomment.tryParse)( /** @type {string} */potentialType) : (0, _jsdoccomment.parse)( /** @type {string} */potentialType, mode), - tag - }; - } catch { - return undefined; - } - }; - }; - const typeTags = utils.filterTags(({ - tag - }) => { - return tag !== 'import' && utils.tagMightHaveTypePosition(tag) && (tag !== 'suppress' || settings.mode !== 'closure'); - }).map(tagToParsedType('type')); - const namepathReferencingTags = utils.filterTags(({ - tag - }) => { - return utils.isNamepathReferencingTag(tag); - }).map(tagToParsedType('name')); - const namepathOrUrlReferencingTags = utils.filterAllTags(({ - tag - }) => { - return utils.isNamepathOrUrlReferencingTag(tag); - }).map(tagToParsedType('namepathOrURL')); - const tagsWithTypes = /** @type {TypeAndTagInfo[]} */[...typeTags, ...namepathReferencingTags, ...namepathOrUrlReferencingTags - // Remove types which failed to parse - ].filter(Boolean); - for (const { - tag, - parsedType - } of tagsWithTypes) { - (0, _jsdoccomment.traverse)(parsedType, nde => { - const { - type, - value - } = /** @type {import('jsdoc-type-pratt-parser').NameResult} */nde; - if (type === 'JsdocTypeName') { - var _structuredTags$tag$t; - const structuredTypes = (_structuredTags$tag$t = structuredTags[tag.tag]) === null || _structuredTags$tag$t === void 0 ? void 0 : _structuredTags$tag$t.type; - if (!allDefinedTypes.has(value) && (!Array.isArray(structuredTypes) || !structuredTypes.includes(value))) { - if (!disableReporting) { - report(`The type '${value}' is undefined.`, null, tag); - } - } else if (markVariablesAsUsed && !extraTypes.includes(value)) { - if (sourceCode.markVariableAsUsed) { - sourceCode.markVariableAsUsed(value); - /* c8 ignore next 3 */ - } else { - context.markVariableAsUsed(value); - } - } - } - }); - } -}, { - iterateAllJsdocs: true, - meta: { - docs: { - description: 'Checks that types in jsdoc comments are defined.', - url: 'https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/no-undefined-types.md#repos-sticky-header' - }, - schema: [{ - additionalProperties: false, - properties: { - definedTypes: { - items: { - type: 'string' - }, - type: 'array' - }, - disableReporting: { - type: 'boolean' - }, - markVariablesAsUsed: { - type: 'boolean' - } - }, - type: 'object' - }], - type: 'suggestion' - } -}); -module.exports = exports.default; -//# sourceMappingURL=noUndefinedTypes.cjs.map \ No newline at end of file diff --git a/tools/eslint/node_modules/eslint-plugin-jsdoc/dist/rules/requireAsteriskPrefix.cjs b/tools/eslint/node_modules/eslint-plugin-jsdoc/dist/rules/requireAsteriskPrefix.cjs deleted file mode 100644 index 6a6d1a4a159485..00000000000000 --- a/tools/eslint/node_modules/eslint-plugin-jsdoc/dist/rules/requireAsteriskPrefix.cjs +++ /dev/null @@ -1,166 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.default = void 0; -var _iterateJsdoc = _interopRequireDefault(require("../iterateJsdoc.cjs")); -function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; } -var _default = exports.default = (0, _iterateJsdoc.default)(({ - context, - jsdoc, - utils, - indent -}) => { - const [defaultRequireValue = 'always', { - tags: tagMap = {} - } = {}] = context.options; - const { - source - } = jsdoc; - const always = defaultRequireValue === 'always'; - const never = defaultRequireValue === 'never'; - - /** @type {string} */ - let currentTag; - source.some(({ - number, - tokens - }) => { - var _tagMap$any2; - const { - delimiter, - tag, - end, - description - } = tokens; - - /** - * @returns {void} - */ - const neverFix = () => { - tokens.delimiter = ''; - tokens.postDelimiter = ''; - }; - - /** - * @param {string} checkValue - * @returns {boolean} - */ - const checkNever = checkValue => { - var _tagMap$always, _tagMap$never; - if (delimiter && delimiter !== '/**' && (never && !((_tagMap$always = tagMap.always) !== null && _tagMap$always !== void 0 && _tagMap$always.includes(checkValue)) || (_tagMap$never = tagMap.never) !== null && _tagMap$never !== void 0 && _tagMap$never.includes(checkValue))) { - utils.reportJSDoc('Expected JSDoc line to have no prefix.', { - column: 0, - line: number - }, neverFix); - return true; - } - return false; - }; - - /** - * @returns {void} - */ - const alwaysFix = () => { - if (!tokens.start) { - tokens.start = indent + ' '; - } - tokens.delimiter = '*'; - tokens.postDelimiter = tag || description ? ' ' : ''; - }; - - /** - * @param {string} checkValue - * @returns {boolean} - */ - const checkAlways = checkValue => { - var _tagMap$never2, _tagMap$always2; - if (!delimiter && (always && !((_tagMap$never2 = tagMap.never) !== null && _tagMap$never2 !== void 0 && _tagMap$never2.includes(checkValue)) || (_tagMap$always2 = tagMap.always) !== null && _tagMap$always2 !== void 0 && _tagMap$always2.includes(checkValue))) { - utils.reportJSDoc('Expected JSDoc line to have the prefix.', { - column: 0, - line: number - }, alwaysFix); - return true; - } - return false; - }; - if (tag) { - // Remove at sign - currentTag = tag.slice(1); - } - if ( - // If this is the end but has a tag, the delimiter will also be - // populated and will be safely ignored later - end && !tag) { - return false; - } - if (!currentTag) { - var _tagMap$any; - if ((_tagMap$any = tagMap.any) !== null && _tagMap$any !== void 0 && _tagMap$any.includes('*description')) { - return false; - } - if (checkNever('*description')) { - return true; - } - if (checkAlways('*description')) { - return true; - } - return false; - } - if ((_tagMap$any2 = tagMap.any) !== null && _tagMap$any2 !== void 0 && _tagMap$any2.includes(currentTag)) { - return false; - } - if (checkNever(currentTag)) { - return true; - } - if (checkAlways(currentTag)) { - return true; - } - return false; - }); -}, { - iterateAllJsdocs: true, - meta: { - docs: { - description: 'Requires that each JSDoc line starts with an `*`.', - url: 'https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/require-asterisk-prefix.md#repos-sticky-header' - }, - fixable: 'code', - schema: [{ - enum: ['always', 'never', 'any'], - type: 'string' - }, { - additionalProperties: false, - properties: { - tags: { - properties: { - always: { - items: { - type: 'string' - }, - type: 'array' - }, - any: { - items: { - type: 'string' - }, - type: 'array' - }, - never: { - items: { - type: 'string' - }, - type: 'array' - } - }, - type: 'object' - } - }, - type: 'object' - }], - type: 'layout' - } -}); -module.exports = exports.default; -//# sourceMappingURL=requireAsteriskPrefix.cjs.map \ No newline at end of file diff --git a/tools/eslint/node_modules/eslint-plugin-jsdoc/dist/rules/requireDescription.cjs b/tools/eslint/node_modules/eslint-plugin-jsdoc/dist/rules/requireDescription.cjs deleted file mode 100644 index f70f42b3b2adcc..00000000000000 --- a/tools/eslint/node_modules/eslint-plugin-jsdoc/dist/rules/requireDescription.cjs +++ /dev/null @@ -1,135 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.default = void 0; -var _iterateJsdoc = _interopRequireDefault(require("../iterateJsdoc.cjs")); -function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; } -/** - * @param {string} description - * @returns {import('../iterateJsdoc.js').Integer} - */ -const checkDescription = description => { - return description.trim().split('\n').filter(Boolean).length; -}; -var _default = exports.default = (0, _iterateJsdoc.default)(({ - jsdoc, - report, - utils, - context -}) => { - if (utils.avoidDocs()) { - return; - } - const { - descriptionStyle = 'body' - } = context.options[0] || {}; - let targetTagName = utils.getPreferredTagName({ - // We skip reporting except when `@description` is essential to the rule, - // so user can block the tag and still meaningfully use this rule - // even if the tag is present (and `check-tag-names` is the one to - // normally report the fact that it is blocked but present) - skipReportingBlockedTag: descriptionStyle !== 'tag', - tagName: 'description' - }); - if (!targetTagName) { - return; - } - const isBlocked = typeof targetTagName === 'object' && 'blocked' in targetTagName && targetTagName.blocked; - if (isBlocked) { - targetTagName = /** @type {{blocked: true; tagName: string;}} */targetTagName.tagName; - } - if (descriptionStyle !== 'tag') { - const { - description - } = utils.getDescription(); - if (checkDescription(description || '')) { - return; - } - if (descriptionStyle === 'body') { - const descTags = utils.getPresentTags(['desc', 'description']); - if (descTags.length) { - const [{ - tag: tagName - }] = descTags; - report(`Remove the @${tagName} tag to leave a plain block description or add additional description text above the @${tagName} line.`); - } else { - report('Missing JSDoc block description.'); - } - return; - } - } - const functionExamples = isBlocked ? [] : jsdoc.tags.filter(({ - tag - }) => { - return tag === targetTagName; - }); - if (!functionExamples.length) { - report(descriptionStyle === 'any' ? `Missing JSDoc block description or @${targetTagName} declaration.` : `Missing JSDoc @${targetTagName} declaration.`); - return; - } - for (const example of functionExamples) { - if (!checkDescription(`${example.name} ${utils.getTagDescription(example)}`)) { - report(`Missing JSDoc @${targetTagName} description.`, null, example); - } - } -}, { - contextDefaults: true, - meta: { - docs: { - description: 'Requires that all functions have a description.', - url: 'https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/require-description.md#repos-sticky-header' - }, - schema: [{ - additionalProperties: false, - properties: { - checkConstructors: { - default: true, - type: 'boolean' - }, - checkGetters: { - default: true, - type: 'boolean' - }, - checkSetters: { - default: true, - type: 'boolean' - }, - contexts: { - items: { - anyOf: [{ - type: 'string' - }, { - additionalProperties: false, - properties: { - comment: { - type: 'string' - }, - context: { - type: 'string' - } - }, - type: 'object' - }] - }, - type: 'array' - }, - descriptionStyle: { - enum: ['body', 'tag', 'any'], - type: 'string' - }, - exemptedBy: { - items: { - type: 'string' - }, - type: 'array' - } - }, - type: 'object' - }], - type: 'suggestion' - } -}); -module.exports = exports.default; -//# sourceMappingURL=requireDescription.cjs.map \ No newline at end of file diff --git a/tools/eslint/node_modules/eslint-plugin-jsdoc/dist/rules/requireDescriptionCompleteSentence.cjs b/tools/eslint/node_modules/eslint-plugin-jsdoc/dist/rules/requireDescriptionCompleteSentence.cjs deleted file mode 100644 index bacd35435ee2f9..00000000000000 --- a/tools/eslint/node_modules/eslint-plugin-jsdoc/dist/rules/requireDescriptionCompleteSentence.cjs +++ /dev/null @@ -1,282 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.default = void 0; -var _iterateJsdoc = _interopRequireDefault(require("../iterateJsdoc.cjs")); -var _escapeStringRegexp = _interopRequireDefault(require("escape-string-regexp")); -function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; } -const otherDescriptiveTags = new Set([ -// 'copyright' and 'see' might be good addition, but as the former may be -// sensitive text, and the latter may have just a link, they are not -// included by default -'summary', 'file', 'fileoverview', 'overview', 'classdesc', 'todo', 'deprecated', 'throws', 'exception', 'yields', 'yield']); - -/** - * @param {string} text - * @returns {string[]} - */ -const extractParagraphs = text => { - return text.split(/(? { - const txt = text - // Remove all {} tags. - .replaceAll(/(? { - return sentEnd[0]; - }); - return txt.split(/[.?!](?:\s+|$)/u) - - // Re-add the dot. - .map((sentence, idx) => { - return !puncts[idx] && /^\s*$/u.test(sentence) ? sentence : `${sentence}${puncts[idx] || ''}`; - }); -}; - -/** - * @param {string} text - * @returns {boolean} - */ -const isNewLinePrecededByAPeriod = text => { - /** @type {boolean} */ - let lastLineEndsSentence; - const lines = text.split('\n'); - return !lines.some(line => { - if (lastLineEndsSentence === false && /^[A-Z][a-z]/u.test(line)) { - return true; - } - lastLineEndsSentence = /[.:?!|]$/u.test(line); - return false; - }); -}; - -/** - * @param {string} str - * @returns {boolean} - */ -const isCapitalized = str => { - return str[0] === str[0].toUpperCase(); -}; - -/** - * @param {string} str - * @returns {boolean} - */ -const isTable = str => { - return str.charAt(0) === '|'; -}; - -/** - * @param {string} str - * @returns {string} - */ -const capitalize = str => { - return str.charAt(0).toUpperCase() + str.slice(1); -}; - -/** - * @param {string} description - * @param {import('../iterateJsdoc.js').Report} reportOrig - * @param {import('eslint').Rule.Node} jsdocNode - * @param {string|RegExp} abbreviationsRegex - * @param {import('eslint').SourceCode} sourceCode - * @param {import('comment-parser').Spec|{ - * line: import('../iterateJsdoc.js').Integer - * }} tag - * @param {boolean} newlineBeforeCapsAssumesBadSentenceEnd - * @returns {boolean} - */ -const validateDescription = (description, reportOrig, jsdocNode, abbreviationsRegex, sourceCode, tag, newlineBeforeCapsAssumesBadSentenceEnd) => { - if (!description || /^\n+$/u.test(description)) { - return false; - } - const descriptionNoHeadings = description.replaceAll(/^\s*#[^\n]*(\n|$)/gm, ''); - const paragraphs = extractParagraphs(descriptionNoHeadings).filter(Boolean); - return paragraphs.some((paragraph, parIdx) => { - const sentences = extractSentences(paragraph, abbreviationsRegex); - const fix = /** @type {import('eslint').Rule.ReportFixer} */fixer => { - let text = sourceCode.getText(jsdocNode); - if (!/[.:?!]$/u.test(paragraph)) { - const line = paragraph.split('\n').filter(Boolean).pop(); - text = text.replace(new RegExp(`${(0, _escapeStringRegexp.default)( /** @type {string} */ - line)}$`, 'mu'), `${line}.`); - } - for (const sentence of sentences.filter(sentence_ => { - return !/^\s*$/u.test(sentence_) && !isCapitalized(sentence_) && !isTable(sentence_); - })) { - const beginning = sentence.split('\n')[0]; - if ('tag' in tag && tag.tag) { - const reg = new RegExp(`(@${(0, _escapeStringRegexp.default)(tag.tag)}.*)${(0, _escapeStringRegexp.default)(beginning)}`, 'u'); - text = text.replace(reg, (_$0, $1) => { - return $1 + capitalize(beginning); - }); - } else { - text = text.replace(new RegExp('((?:[.?!]|\\*|\\})\\s*)' + (0, _escapeStringRegexp.default)(beginning), 'u'), '$1' + capitalize(beginning)); - } - } - return fixer.replaceText(jsdocNode, text); - }; - - /** - * @param {string} msg - * @param {import('eslint').Rule.ReportFixer | null | undefined} fixer - * @param {{ - * line?: number | undefined; - * column?: number | undefined; - * } | (import('comment-parser').Spec & { - * line?: number | undefined; - * column?: number | undefined; - * })} tagObj - * @returns {void} - */ - const report = (msg, fixer, tagObj) => { - if ('line' in tagObj) { - /** - * @type {{ - * line: number; - * }} - */ - tagObj.line += parIdx * 2; - } else { - /** @type {import('comment-parser').Spec} */tagObj.source[0].number += parIdx * 2; - } - - // Avoid errors if old column doesn't exist here - tagObj.column = 0; - reportOrig(msg, fixer, tagObj); - }; - if (sentences.some(sentence => { - return /^[.?!]$/u.test(sentence); - })) { - report('Sentences must be more than punctuation.', null, tag); - } - if (sentences.some(sentence => { - return !/^\s*$/u.test(sentence) && !isCapitalized(sentence) && !isTable(sentence); - })) { - report('Sentences should start with an uppercase character.', fix, tag); - } - const paragraphNoAbbreviations = paragraph.replace(abbreviationsRegex, ''); - if (!/(?:[.?!|]|```)\s*$/u.test(paragraphNoAbbreviations)) { - report('Sentences must end with a period.', fix, tag); - return true; - } - if (newlineBeforeCapsAssumesBadSentenceEnd && !isNewLinePrecededByAPeriod(paragraphNoAbbreviations)) { - report('A line of text is started with an uppercase character, but the preceding line does not end the sentence.', null, tag); - return true; - } - return false; - }); -}; -var _default = exports.default = (0, _iterateJsdoc.default)(({ - sourceCode, - context, - jsdoc, - report, - jsdocNode, - utils -}) => { - const /** @type {{abbreviations: string[], newlineBeforeCapsAssumesBadSentenceEnd: boolean}} */{ - abbreviations = [], - newlineBeforeCapsAssumesBadSentenceEnd = false - } = context.options[0] || {}; - const abbreviationsRegex = abbreviations.length ? new RegExp('\\b' + abbreviations.map(abbreviation => { - return (0, _escapeStringRegexp.default)(abbreviation.replaceAll(/\.$/ug, '') + '.'); - }).join('|') + '(?:$|\\s)', 'gu') : ''; - let { - description - } = utils.getDescription(); - const indices = [...description.matchAll(/```[\s\S]*```/gu)].map(match => { - const { - index - } = match; - const [{ - length - }] = match; - return { - index, - length - }; - }).reverse(); - for (const { - index, - length - } of indices) { - description = description.slice(0, index) + description.slice( /** @type {import('../iterateJsdoc.js').Integer} */index + length); - } - if (validateDescription(description, report, jsdocNode, abbreviationsRegex, sourceCode, { - line: jsdoc.source[0].number + 1 - }, newlineBeforeCapsAssumesBadSentenceEnd)) { - return; - } - utils.forEachPreferredTag('description', matchingJsdocTag => { - const desc = `${matchingJsdocTag.name} ${utils.getTagDescription(matchingJsdocTag)}`.trim(); - validateDescription(desc, report, jsdocNode, abbreviationsRegex, sourceCode, matchingJsdocTag, newlineBeforeCapsAssumesBadSentenceEnd); - }, true); - const { - tagsWithNames - } = utils.getTagsByType(jsdoc.tags); - const tagsWithoutNames = utils.filterTags(({ - tag: tagName - }) => { - return otherDescriptiveTags.has(tagName) || utils.hasOptionTag(tagName) && !tagsWithNames.some(({ - tag - }) => { - // If user accidentally adds tags with names (or like `returns` - // get parsed as having names), do not add to this list - return tag === tagName; - }); - }); - tagsWithNames.some(tag => { - const desc = /** @type {string} */utils.getTagDescription(tag).replace(/^- /u, '').trimEnd(); - return validateDescription(desc, report, jsdocNode, abbreviationsRegex, sourceCode, tag, newlineBeforeCapsAssumesBadSentenceEnd); - }); - tagsWithoutNames.some(tag => { - const desc = `${tag.name} ${utils.getTagDescription(tag)}`.trim(); - return validateDescription(desc, report, jsdocNode, abbreviationsRegex, sourceCode, tag, newlineBeforeCapsAssumesBadSentenceEnd); - }); -}, { - iterateAllJsdocs: true, - meta: { - docs: { - description: 'Requires that block description, explicit `@description`, and `@param`/`@returns` tag descriptions are written in complete sentences.', - url: 'https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/require-description-complete-sentence.md#repos-sticky-header' - }, - fixable: 'code', - schema: [{ - additionalProperties: false, - properties: { - abbreviations: { - items: { - type: 'string' - }, - type: 'array' - }, - newlineBeforeCapsAssumesBadSentenceEnd: { - type: 'boolean' - }, - tags: { - items: { - type: 'string' - }, - type: 'array' - } - }, - type: 'object' - }], - type: 'suggestion' - } -}); -module.exports = exports.default; -//# sourceMappingURL=requireDescriptionCompleteSentence.cjs.map \ No newline at end of file diff --git a/tools/eslint/node_modules/eslint-plugin-jsdoc/dist/rules/requireExample.cjs b/tools/eslint/node_modules/eslint-plugin-jsdoc/dist/rules/requireExample.cjs deleted file mode 100644 index 8f99a659cf051f..00000000000000 --- a/tools/eslint/node_modules/eslint-plugin-jsdoc/dist/rules/requireExample.cjs +++ /dev/null @@ -1,108 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.default = void 0; -var _iterateJsdoc = _interopRequireDefault(require("../iterateJsdoc.cjs")); -function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; } -var _default = exports.default = (0, _iterateJsdoc.default)(({ - context, - jsdoc, - report, - utils -}) => { - if (utils.avoidDocs()) { - return; - } - const { - enableFixer = true, - exemptNoArguments = false - } = context.options[0] || {}; - const targetTagName = 'example'; - const functionExamples = jsdoc.tags.filter(({ - tag - }) => { - return tag === targetTagName; - }); - if (!functionExamples.length) { - if (exemptNoArguments && utils.isIteratingFunction() && !utils.hasParams()) { - return; - } - utils.reportJSDoc(`Missing JSDoc @${targetTagName} declaration.`, null, () => { - if (enableFixer) { - utils.addTag(targetTagName); - } - }); - return; - } - for (const example of functionExamples) { - const exampleContent = `${example.name} ${utils.getTagDescription(example)}`.trim().split('\n').filter(Boolean); - if (!exampleContent.length) { - report(`Missing JSDoc @${targetTagName} description.`, null, example); - } - } -}, { - contextDefaults: true, - meta: { - docs: { - description: 'Requires that all functions have examples.', - url: 'https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/require-example.md#repos-sticky-header' - }, - fixable: 'code', - schema: [{ - additionalProperties: false, - properties: { - checkConstructors: { - default: true, - type: 'boolean' - }, - checkGetters: { - default: false, - type: 'boolean' - }, - checkSetters: { - default: false, - type: 'boolean' - }, - contexts: { - items: { - anyOf: [{ - type: 'string' - }, { - additionalProperties: false, - properties: { - comment: { - type: 'string' - }, - context: { - type: 'string' - } - }, - type: 'object' - }] - }, - type: 'array' - }, - enableFixer: { - default: true, - type: 'boolean' - }, - exemptedBy: { - items: { - type: 'string' - }, - type: 'array' - }, - exemptNoArguments: { - default: false, - type: 'boolean' - } - }, - type: 'object' - }], - type: 'suggestion' - } -}); -module.exports = exports.default; -//# sourceMappingURL=requireExample.cjs.map \ No newline at end of file diff --git a/tools/eslint/node_modules/eslint-plugin-jsdoc/dist/rules/requireFileOverview.cjs b/tools/eslint/node_modules/eslint-plugin-jsdoc/dist/rules/requireFileOverview.cjs deleted file mode 100644 index 647e7cb0f5e7ff..00000000000000 --- a/tools/eslint/node_modules/eslint-plugin-jsdoc/dist/rules/requireFileOverview.cjs +++ /dev/null @@ -1,135 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.default = void 0; -var _iterateJsdoc = _interopRequireDefault(require("../iterateJsdoc.cjs")); -function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; } -const defaultTags = { - file: { - initialCommentsOnly: true, - mustExist: true, - preventDuplicates: true - } -}; - -/** - * @param {import('../iterateJsdoc.js').StateObject} state - * @returns {void} - */ -const setDefaults = state => { - // First iteration - if (!state.globalTags) { - state.globalTags = {}; - state.hasDuplicates = {}; - state.hasTag = {}; - state.hasNonCommentBeforeTag = {}; - } -}; -var _default = exports.default = (0, _iterateJsdoc.default)(({ - jsdocNode, - state, - utils, - context -}) => { - const { - tags = defaultTags - } = context.options[0] || {}; - setDefaults(state); - for (const tagName of Object.keys(tags)) { - const targetTagName = /** @type {string} */utils.getPreferredTagName({ - tagName - }); - const hasTag = Boolean(targetTagName && utils.hasTag(targetTagName)); - state.hasTag[tagName] = hasTag || state.hasTag[tagName]; - const hasDuplicate = state.hasDuplicates[tagName]; - if (hasDuplicate === false) { - // Was marked before, so if a tag now, is a dupe - state.hasDuplicates[tagName] = hasTag; - } else if (!hasDuplicate && hasTag) { - // No dupes set before, but has first tag, so change state - // from `undefined` to `false` so can detect next time - state.hasDuplicates[tagName] = false; - state.hasNonCommentBeforeTag[tagName] = state.hasNonComment && state.hasNonComment < jsdocNode.range[0]; - } - } -}, { - exit({ - context, - state, - utils - }) { - setDefaults(state); - const { - tags = defaultTags - } = context.options[0] || {}; - for (const [tagName, { - mustExist = false, - preventDuplicates = false, - initialCommentsOnly = false - }] of Object.entries(tags)) { - const obj = utils.getPreferredTagNameObject({ - tagName - }); - if (obj && typeof obj === 'object' && 'blocked' in obj) { - utils.reportSettings(`\`settings.jsdoc.tagNamePreference\` cannot block @${obj.tagName} ` + 'for the `require-file-overview` rule'); - } else { - const targetTagName = obj && typeof obj === 'object' && obj.replacement || obj; - if (mustExist && !state.hasTag[tagName]) { - utils.reportSettings(`Missing @${targetTagName}`); - } - if (preventDuplicates && state.hasDuplicates[tagName]) { - utils.reportSettings(`Duplicate @${targetTagName}`); - } - if (initialCommentsOnly && state.hasNonCommentBeforeTag[tagName]) { - utils.reportSettings(`@${targetTagName} should be at the beginning of the file`); - } - } - } - }, - iterateAllJsdocs: true, - meta: { - docs: { - description: 'Checks that all files have one `@file`, `@fileoverview`, or `@overview` tag at the beginning of the file.', - url: 'https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/require-file-overview.md#repos-sticky-header' - }, - schema: [{ - additionalProperties: false, - properties: { - tags: { - patternProperties: { - '.*': { - additionalProperties: false, - properties: { - initialCommentsOnly: { - type: 'boolean' - }, - mustExist: { - type: 'boolean' - }, - preventDuplicates: { - type: 'boolean' - } - }, - type: 'object' - } - }, - type: 'object' - } - }, - type: 'object' - }], - type: 'suggestion' - }, - nonComment({ - state, - node - }) { - if (!state.hasNonComment) { - state.hasNonComment = node.range[0]; - } - } -}); -module.exports = exports.default; -//# sourceMappingURL=requireFileOverview.cjs.map \ No newline at end of file diff --git a/tools/eslint/node_modules/eslint-plugin-jsdoc/dist/rules/requireHyphenBeforeParamDescription.cjs b/tools/eslint/node_modules/eslint-plugin-jsdoc/dist/rules/requireHyphenBeforeParamDescription.cjs deleted file mode 100644 index 07a8c2b5a7ebea..00000000000000 --- a/tools/eslint/node_modules/eslint-plugin-jsdoc/dist/rules/requireHyphenBeforeParamDescription.cjs +++ /dev/null @@ -1,141 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.default = void 0; -var _iterateJsdoc = _interopRequireDefault(require("../iterateJsdoc.cjs")); -function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; } -var _default = exports.default = (0, _iterateJsdoc.default)(({ - sourceCode, - utils, - report, - context, - jsdoc, - jsdocNode -}) => { - const [mainCircumstance, { - tags = null - } = {}] = context.options; - const tgs = - /** - * @type {null|"any"|{[key: string]: "always"|"never"}} - */ - tags; - - /** - * @param {import('@es-joy/jsdoccomment').JsdocTagWithInline} jsdocTag - * @param {string} targetTagName - * @param {"always"|"never"} [circumstance] - * @returns {void} - */ - const checkHyphens = (jsdocTag, targetTagName, circumstance = mainCircumstance) => { - const always = !circumstance || circumstance === 'always'; - const desc = /** @type {string} */utils.getTagDescription(jsdocTag); - if (!desc.trim()) { - return; - } - const startsWithHyphen = /^\s*-/u.test(desc); - if (always) { - if (!startsWithHyphen) { - report(`There must be a hyphen before @${targetTagName} description.`, fixer => { - const lineIndex = /** @type {import('../iterateJsdoc.js').Integer} */ - jsdocTag.line; - const sourceLines = sourceCode.getText(jsdocNode).split('\n'); - - // Get start index of description, accounting for multi-line descriptions - const description = desc.split('\n')[0]; - const descriptionIndex = sourceLines[lineIndex].lastIndexOf(description); - const replacementLine = sourceLines[lineIndex].slice(0, descriptionIndex) + '- ' + description; - sourceLines.splice(lineIndex, 1, replacementLine); - const replacement = sourceLines.join('\n'); - return fixer.replaceText(jsdocNode, replacement); - }, jsdocTag); - } - } else if (startsWithHyphen) { - let lines = 0; - for (const { - tokens - } of jsdocTag.source) { - if (tokens.description) { - break; - } - lines++; - } - utils.reportJSDoc(`There must be no hyphen before @${targetTagName} description.`, { - line: jsdocTag.source[0].number + lines - }, () => { - for (const { - tokens - } of jsdocTag.source) { - if (tokens.description) { - tokens.description = tokens.description.replace(/^\s*-\s*/u, ''); - break; - } - } - }, true); - } - }; - utils.forEachPreferredTag('param', checkHyphens); - if (tgs) { - const tagEntries = Object.entries(tgs); - for (const [tagName, circumstance] of tagEntries) { - if (tagName === '*') { - const preferredParamTag = utils.getPreferredTagName({ - tagName: 'param' - }); - for (const { - tag - } of jsdoc.tags) { - if (tag === preferredParamTag || tagEntries.some(([tagNme]) => { - return tagNme !== '*' && tagNme === tag; - })) { - continue; - } - utils.forEachPreferredTag(tag, (jsdocTag, targetTagName) => { - checkHyphens(jsdocTag, targetTagName, /** @type {"always"|"never"} */circumstance); - }); - } - continue; - } - utils.forEachPreferredTag(tagName, (jsdocTag, targetTagName) => { - checkHyphens(jsdocTag, targetTagName, /** @type {"always"|"never"} */circumstance); - }); - } - } -}, { - iterateAllJsdocs: true, - meta: { - docs: { - description: 'Requires a hyphen before the `@param` description.', - url: 'https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/require-hyphen-before-param-description.md#repos-sticky-header' - }, - fixable: 'code', - schema: [{ - enum: ['always', 'never'], - type: 'string' - }, { - additionalProperties: false, - properties: { - tags: { - anyOf: [{ - patternProperties: { - '.*': { - enum: ['always', 'never'], - type: 'string' - } - }, - type: 'object' - }, { - enum: ['any'], - type: 'string' - }] - } - }, - type: 'object' - }], - type: 'layout' - } -}); -module.exports = exports.default; -//# sourceMappingURL=requireHyphenBeforeParamDescription.cjs.map \ No newline at end of file diff --git a/tools/eslint/node_modules/eslint-plugin-jsdoc/dist/rules/requireJsdoc.cjs b/tools/eslint/node_modules/eslint-plugin-jsdoc/dist/rules/requireJsdoc.cjs deleted file mode 100644 index 57271ad25e9cf1..00000000000000 --- a/tools/eslint/node_modules/eslint-plugin-jsdoc/dist/rules/requireJsdoc.cjs +++ /dev/null @@ -1,507 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.default = void 0; -var _exportParser = _interopRequireDefault(require("../exportParser.cjs")); -var _iterateJsdoc = require("../iterateJsdoc.cjs"); -var _jsdocUtils = _interopRequireDefault(require("../jsdocUtils.cjs")); -var _jsdoccomment = require("@es-joy/jsdoccomment"); -function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; } -/** - * @typedef {{ - * ancestorsOnly: boolean, - * esm: boolean, - * initModuleExports: boolean, - * initWindow: boolean - * }} RequireJsdocOpts - */ - -/** - * @typedef {import('eslint').Rule.Node| - * import('@typescript-eslint/types').TSESTree.Node} ESLintOrTSNode - */ - -/** @type {import('json-schema').JSONSchema4} */ -const OPTIONS_SCHEMA = { - additionalProperties: false, - properties: { - checkConstructors: { - default: true, - type: 'boolean' - }, - checkGetters: { - anyOf: [{ - type: 'boolean' - }, { - enum: ['no-setter'], - type: 'string' - }], - default: true - }, - checkSetters: { - anyOf: [{ - type: 'boolean' - }, { - enum: ['no-getter'], - type: 'string' - }], - default: true - }, - contexts: { - items: { - anyOf: [{ - type: 'string' - }, { - additionalProperties: false, - properties: { - context: { - type: 'string' - }, - inlineCommentBlock: { - type: 'boolean' - }, - minLineCount: { - type: 'integer' - } - }, - type: 'object' - }] - }, - type: 'array' - }, - enableFixer: { - default: true, - type: 'boolean' - }, - exemptEmptyConstructors: { - default: false, - type: 'boolean' - }, - exemptEmptyFunctions: { - default: false, - type: 'boolean' - }, - fixerMessage: { - default: '', - type: 'string' - }, - minLineCount: { - type: 'integer' - }, - publicOnly: { - oneOf: [{ - default: false, - type: 'boolean' - }, { - additionalProperties: false, - default: {}, - properties: { - ancestorsOnly: { - type: 'boolean' - }, - cjs: { - type: 'boolean' - }, - esm: { - type: 'boolean' - }, - window: { - type: 'boolean' - } - }, - type: 'object' - }] - }, - require: { - additionalProperties: false, - default: {}, - properties: { - ArrowFunctionExpression: { - default: false, - type: 'boolean' - }, - ClassDeclaration: { - default: false, - type: 'boolean' - }, - ClassExpression: { - default: false, - type: 'boolean' - }, - FunctionDeclaration: { - default: true, - type: 'boolean' - }, - FunctionExpression: { - default: false, - type: 'boolean' - }, - MethodDefinition: { - default: false, - type: 'boolean' - } - }, - type: 'object' - } - }, - type: 'object' -}; - -/** - * @param {import('eslint').Rule.RuleContext} context - * @param {import('json-schema').JSONSchema4Object} baseObject - * @param {string} option - * @param {string} key - * @returns {boolean|undefined} - */ -const getOption = (context, baseObject, option, key) => { - if (context.options[0] && option in context.options[0] && ( - // Todo: boolean shouldn't be returning property, but - // tests currently require - typeof context.options[0][option] === 'boolean' || key in context.options[0][option])) { - return context.options[0][option][key]; - } - return /** @type {{[key: string]: {default?: boolean|undefined}}} */baseObject.properties[key].default; -}; - -/** - * @param {import('eslint').Rule.RuleContext} context - * @param {import('../iterateJsdoc.js').Settings} settings - * @returns {{ - * contexts: (string|{ - * context: string, - * inlineCommentBlock: boolean, - * minLineCount: import('../iterateJsdoc.js').Integer - * })[], - * enableFixer: boolean, - * exemptEmptyConstructors: boolean, - * exemptEmptyFunctions: boolean, - * fixerMessage: string, - * minLineCount: undefined|import('../iterateJsdoc.js').Integer, - * publicOnly: boolean|{[key: string]: boolean|undefined} - * require: {[key: string]: boolean|undefined} - * }} - */ -const getOptions = (context, settings) => { - const { - publicOnly, - contexts = settings.contexts || [], - exemptEmptyConstructors = true, - exemptEmptyFunctions = false, - enableFixer = true, - fixerMessage = '', - minLineCount = undefined - } = context.options[0] || {}; - return { - contexts, - enableFixer, - exemptEmptyConstructors, - exemptEmptyFunctions, - fixerMessage, - minLineCount, - publicOnly: (baseObj => { - if (!publicOnly) { - return false; - } - - /** @type {{[key: string]: boolean|undefined}} */ - const properties = {}; - for (const prop of Object.keys( /** @type {import('json-schema').JSONSchema4Object} */ - /** @type {import('json-schema').JSONSchema4Object} */baseObj.properties)) { - const opt = getOption(context, /** @type {import('json-schema').JSONSchema4Object} */baseObj, 'publicOnly', prop); - properties[prop] = opt; - } - return properties; - })( /** @type {import('json-schema').JSONSchema4Object} */ - ( /** @type {import('json-schema').JSONSchema4Object} */ - ( /** @type {import('json-schema').JSONSchema4Object} */ - OPTIONS_SCHEMA.properties.publicOnly).oneOf)[1]), - require: (baseObj => { - /** @type {{[key: string]: boolean|undefined}} */ - const properties = {}; - for (const prop of Object.keys( /** @type {import('json-schema').JSONSchema4Object} */ - /** @type {import('json-schema').JSONSchema4Object} */baseObj.properties)) { - const opt = getOption(context, /** @type {import('json-schema').JSONSchema4Object} */ - baseObj, 'require', prop); - properties[prop] = opt; - } - return properties; - })( /** @type {import('json-schema').JSONSchema4Object} */ - OPTIONS_SCHEMA.properties.require) - }; -}; - -/** @type {import('eslint').Rule.RuleModule} */ -var _default = exports.default = { - create(context) { - /* c8 ignore next -- Fallback to deprecated method */ - const { - sourceCode = context.getSourceCode() - } = context; - const settings = (0, _iterateJsdoc.getSettings)(context); - if (!settings) { - return {}; - } - const opts = getOptions(context, settings); - const { - require: requireOption, - contexts, - exemptEmptyFunctions, - exemptEmptyConstructors, - enableFixer, - fixerMessage, - minLineCount - } = opts; - const publicOnly = - /** - * @type {{ - * [key: string]: boolean | undefined; - * }} - */ - opts.publicOnly; - - /** - * @type {import('../iterateJsdoc.js').CheckJsdoc} - */ - const checkJsDoc = (info, _handler, node) => { - if ( - // Optimize - minLineCount !== undefined || contexts.some(ctxt => { - if (typeof ctxt === 'string') { - return false; - } - const { - minLineCount: count - } = ctxt; - return count !== undefined; - })) { - /** - * @param {undefined|import('../iterateJsdoc.js').Integer} count - */ - const underMinLine = count => { - var _sourceCode$getText$m; - return count !== undefined && count > (((_sourceCode$getText$m = sourceCode.getText(node).match(/\n/gu)) === null || _sourceCode$getText$m === void 0 ? void 0 : _sourceCode$getText$m.length) ?? 0) + 1; - }; - if (underMinLine(minLineCount)) { - return; - } - const { - minLineCount: contextMinLineCount - } = - /** - * @type {{ - * context: string; - * inlineCommentBlock: boolean; - * minLineCount: number; - * }} - */ - contexts.find(ctxt => { - if (typeof ctxt === 'string') { - return false; - } - const { - context: ctx - } = ctxt; - return ctx === (info.selector || node.type); - }) || {}; - if (underMinLine(contextMinLineCount)) { - return; - } - } - const jsDocNode = (0, _jsdoccomment.getJSDocComment)(sourceCode, node, settings); - if (jsDocNode) { - return; - } - - // For those who have options configured against ANY constructors (or - // setters or getters) being reported - if (_jsdocUtils.default.exemptSpeciaMethods({ - description: '', - inlineTags: [], - problems: [], - source: [], - tags: [] - }, node, context, [OPTIONS_SCHEMA])) { - return; - } - if ( - // Avoid reporting param-less, return-less functions (when - // `exemptEmptyFunctions` option is set) - exemptEmptyFunctions && info.isFunctionContext || - // Avoid reporting param-less, return-less constructor methods (when - // `exemptEmptyConstructors` option is set) - exemptEmptyConstructors && _jsdocUtils.default.isConstructor(node)) { - const functionParameterNames = _jsdocUtils.default.getFunctionParameterNames(node); - if (!functionParameterNames.length && !_jsdocUtils.default.hasReturnValue(node)) { - return; - } - } - const fix = /** @type {import('eslint').Rule.ReportFixer} */fixer => { - // Default to one line break if the `minLines`/`maxLines` settings allow - const lines = settings.minLines === 0 && settings.maxLines >= 1 ? 1 : settings.minLines; - /** @type {ESLintOrTSNode|import('@typescript-eslint/types').TSESTree.Decorator} */ - let baseNode = (0, _jsdoccomment.getReducedASTNode)(node, sourceCode); - const decorator = (0, _jsdoccomment.getDecorator)( /** @type {import('eslint').Rule.Node} */ - baseNode); - if (decorator) { - baseNode = decorator; - } - const indent = _jsdocUtils.default.getIndent({ - text: sourceCode.getText( /** @type {import('eslint').Rule.Node} */baseNode, /** @type {import('eslint').AST.SourceLocation} */ - ( /** @type {import('eslint').Rule.Node} */baseNode.loc).start.column) - }); - const { - inlineCommentBlock - } = - /** - * @type {{ - * context: string, - * inlineCommentBlock: boolean, - * minLineCount: import('../iterateJsdoc.js').Integer - * }} - */ - contexts.find(contxt => { - if (typeof contxt === 'string') { - return false; - } - const { - context: ctxt - } = contxt; - return ctxt === node.type; - }) || {}; - const insertion = (inlineCommentBlock ? `/** ${fixerMessage}` : `/**\n${indent}*${fixerMessage}\n${indent}`) + `*/${'\n'.repeat(lines)}${indent.slice(0, -1)}`; - return fixer.insertTextBefore( /** @type {import('eslint').Rule.Node} */ - baseNode, insertion); - }; - const report = () => { - const { - start - } = /** @type {import('eslint').AST.SourceLocation} */node.loc; - const loc = { - end: { - column: 0, - line: start.line + 1 - }, - start - }; - context.report({ - fix: enableFixer ? fix : null, - loc, - messageId: 'missingJsDoc', - node - }); - }; - if (publicOnly) { - /** @type {RequireJsdocOpts} */ - const opt = { - ancestorsOnly: Boolean((publicOnly === null || publicOnly === void 0 ? void 0 : publicOnly.ancestorsOnly) ?? false), - esm: Boolean((publicOnly === null || publicOnly === void 0 ? void 0 : publicOnly.esm) ?? true), - initModuleExports: Boolean((publicOnly === null || publicOnly === void 0 ? void 0 : publicOnly.cjs) ?? true), - initWindow: Boolean((publicOnly === null || publicOnly === void 0 ? void 0 : publicOnly.window) ?? false) - }; - const exported = _exportParser.default.isUncommentedExport(node, sourceCode, opt, settings); - if (exported) { - report(); - } - } else { - report(); - } - }; - - /** - * @param {string} prop - * @returns {boolean} - */ - const hasOption = prop => { - return requireOption[prop] || contexts.some(ctxt => { - return typeof ctxt === 'object' ? ctxt.context === prop : ctxt === prop; - }); - }; - return { - ..._jsdocUtils.default.getContextObject(_jsdocUtils.default.enforcedContexts(context, [], settings), checkJsDoc), - ArrowFunctionExpression(node) { - if (!hasOption('ArrowFunctionExpression')) { - return; - } - if (['VariableDeclarator', 'AssignmentExpression', 'ExportDefaultDeclaration'].includes(node.parent.type) || ['Property', 'ObjectProperty', 'ClassProperty', 'PropertyDefinition'].includes(node.parent.type) && node === - /** - * @type {import('@typescript-eslint/types').TSESTree.Property| - * import('@typescript-eslint/types').TSESTree.PropertyDefinition - * } - */ - node.parent.value) { - checkJsDoc({ - isFunctionContext: true - }, null, node); - } - }, - ClassDeclaration(node) { - if (!hasOption('ClassDeclaration')) { - return; - } - checkJsDoc({ - isFunctionContext: false - }, null, node); - }, - ClassExpression(node) { - if (!hasOption('ClassExpression')) { - return; - } - checkJsDoc({ - isFunctionContext: false - }, null, node); - }, - FunctionDeclaration(node) { - if (!hasOption('FunctionDeclaration')) { - return; - } - checkJsDoc({ - isFunctionContext: true - }, null, node); - }, - FunctionExpression(node) { - if (!hasOption('FunctionExpression')) { - return; - } - if (['VariableDeclarator', 'AssignmentExpression', 'ExportDefaultDeclaration'].includes(node.parent.type) || ['Property', 'ObjectProperty', 'ClassProperty', 'PropertyDefinition'].includes(node.parent.type) && node === - /** - * @type {import('@typescript-eslint/types').TSESTree.Property| - * import('@typescript-eslint/types').TSESTree.PropertyDefinition - * } - */ - node.parent.value) { - checkJsDoc({ - isFunctionContext: true - }, null, node); - } - }, - MethodDefinition(node) { - if (!hasOption('MethodDefinition')) { - return; - } - checkJsDoc({ - isFunctionContext: true, - selector: 'MethodDefinition' - }, null, /** @type {import('eslint').Rule.Node} */node.value); - } - }; - }, - meta: { - docs: { - category: 'Stylistic Issues', - description: 'Require JSDoc comments', - recommended: true, - url: 'https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/require-jsdoc.md#repos-sticky-header' - }, - fixable: 'code', - messages: { - missingJsDoc: 'Missing JSDoc comment.' - }, - schema: [OPTIONS_SCHEMA], - type: 'suggestion' - } -}; -module.exports = exports.default; -//# sourceMappingURL=requireJsdoc.cjs.map \ No newline at end of file diff --git a/tools/eslint/node_modules/eslint-plugin-jsdoc/dist/rules/requireParam.cjs b/tools/eslint/node_modules/eslint-plugin-jsdoc/dist/rules/requireParam.cjs deleted file mode 100644 index b46cb5cc4c31c4..00000000000000 --- a/tools/eslint/node_modules/eslint-plugin-jsdoc/dist/rules/requireParam.cjs +++ /dev/null @@ -1,527 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.default = void 0; -var _iterateJsdoc = _interopRequireDefault(require("../iterateJsdoc.cjs")); -function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; } -/** - * @typedef {[string, boolean, () => RootNamerReturn]} RootNamerReturn - */ - -/** - * @param {string[]} desiredRoots - * @param {number} currentIndex - * @returns {RootNamerReturn} - */ -const rootNamer = (desiredRoots, currentIndex) => { - /** @type {string} */ - let name; - let idx = currentIndex; - const incremented = desiredRoots.length <= 1; - if (incremented) { - const base = desiredRoots[0]; - const suffix = idx++; - name = `${base}${suffix}`; - } else { - name = /** @type {string} */desiredRoots.shift(); - } - return [name, incremented, () => { - return rootNamer(desiredRoots, idx); - }]; -}; - -/* eslint-disable complexity -- Temporary */ -var _default = exports.default = (0, _iterateJsdoc.default)(({ - jsdoc, - utils, - context -}) => { - /* eslint-enable complexity -- Temporary */ - if (utils.avoidDocs()) { - return; - } - - // Param type is specified by type in @type - if (utils.hasTag('type')) { - return; - } - const { - autoIncrementBase = 0, - checkRestProperty = false, - checkDestructured = true, - checkDestructuredRoots = true, - checkTypesPattern = '/^(?:[oO]bject|[aA]rray|PlainObject|Generic(?:Object|Array))$/', - enableFixer = true, - enableRootFixer = true, - enableRestElementFixer = true, - unnamedRootBase = ['root'], - useDefaultObjectProperties = false - } = context.options[0] || {}; - const preferredTagName = /** @type {string} */utils.getPreferredTagName({ - tagName: 'param' - }); - if (!preferredTagName) { - return; - } - const functionParameterNames = utils.getFunctionParameterNames(useDefaultObjectProperties); - if (!functionParameterNames.length) { - return; - } - const jsdocParameterNames = - /** - * @type {{ - * idx: import('../iterateJsdoc.js').Integer; - * name: string; - * type: string; - * }[]} - */ - utils.getJsdocTagsDeep(preferredTagName); - const shallowJsdocParameterNames = jsdocParameterNames.filter(tag => { - return !tag.name.includes('.'); - }).map((tag, idx) => { - return { - ...tag, - idx - }; - }); - const checkTypesRegex = utils.getRegexFromString(checkTypesPattern); - - /** - * @type {{ - * functionParameterIdx: import('../iterateJsdoc.js').Integer, - * functionParameterName: string, - * inc: boolean|undefined, - * remove?: true, - * type?: string|undefined - * }[]} - */ - const missingTags = []; - const flattenedRoots = utils.flattenRoots(functionParameterNames).names; - - /** - * @type {{ - * [key: string]: import('../iterateJsdoc.js').Integer - * }} - */ - const paramIndex = {}; - - /** - * @param {string} cur - * @returns {boolean} - */ - const hasParamIndex = cur => { - return utils.dropPathSegmentQuotes(String(cur)) in paramIndex; - }; - - /** - * - * @param {string|number|undefined} cur - * @returns {import('../iterateJsdoc.js').Integer} - */ - const getParamIndex = cur => { - return paramIndex[utils.dropPathSegmentQuotes(String(cur))]; - }; - - /** - * - * @param {string} cur - * @param {import('../iterateJsdoc.js').Integer} idx - * @returns {void} - */ - const setParamIndex = (cur, idx) => { - paramIndex[utils.dropPathSegmentQuotes(String(cur))] = idx; - }; - for (const [idx, cur] of flattenedRoots.entries()) { - setParamIndex(cur, idx); - } - - /** - * - * @param {(import('@es-joy/jsdoccomment').JsdocTagWithInline & { - * newAdd?: boolean - * })[]} jsdocTags - * @param {import('../iterateJsdoc.js').Integer} indexAtFunctionParams - * @returns {import('../iterateJsdoc.js').Integer} - */ - const findExpectedIndex = (jsdocTags, indexAtFunctionParams) => { - const remainingRoots = functionParameterNames.slice(indexAtFunctionParams || 0); - const foundIndex = jsdocTags.findIndex(({ - name, - newAdd - }) => { - return !newAdd && remainingRoots.some(remainingRoot => { - if (Array.isArray(remainingRoot)) { - return ( - /** - * @type {import('../jsdocUtils.js').FlattendRootInfo & { - * annotationParamName?: string|undefined; - * }} - */ - remainingRoot[1].names.includes(name) - ); - } - if (typeof remainingRoot === 'object') { - return name === remainingRoot.name; - } - return name === remainingRoot; - }); - }); - const tags = foundIndex > -1 ? jsdocTags.slice(0, foundIndex) : jsdocTags.filter(({ - tag - }) => { - return tag === preferredTagName; - }); - let tagLineCount = 0; - for (const { - source - } of tags) { - for (const { - tokens: { - end - } - } of source) { - if (!end) { - tagLineCount++; - } - } - } - return tagLineCount; - }; - let [nextRootName, incremented, namer] = rootNamer([...unnamedRootBase], autoIncrementBase); - const thisOffset = functionParameterNames[0] === 'this' ? 1 : 0; - for (const [functionParameterIdx, functionParameterName] of functionParameterNames.entries()) { - let inc; - if (Array.isArray(functionParameterName)) { - const matchedJsdoc = shallowJsdocParameterNames[functionParameterIdx - thisOffset]; - - /** @type {string} */ - let rootName; - if (functionParameterName[0]) { - rootName = functionParameterName[0]; - } else if (matchedJsdoc && matchedJsdoc.name) { - rootName = matchedJsdoc.name; - if (matchedJsdoc.type && matchedJsdoc.type.search(checkTypesRegex) === -1) { - continue; - } - } else { - rootName = nextRootName; - inc = incremented; - } - [nextRootName, incremented, namer] = namer(); - const { - hasRestElement, - hasPropertyRest, - rests, - names - } = - /** - * @type {import('../jsdocUtils.js').FlattendRootInfo & { - * annotationParamName?: string | undefined; - * }} - */ - functionParameterName[1]; - const notCheckingNames = []; - if (!enableRestElementFixer && hasRestElement) { - continue; - } - if (!checkDestructuredRoots) { - continue; - } - for (const [idx, paramName] of names.entries()) { - // Add root if the root name is not in the docs (and is not already - // in the tags to be fixed) - if (!jsdocParameterNames.find(({ - name - }) => { - return name === rootName; - }) && !missingTags.find(({ - functionParameterName: fpn - }) => { - return fpn === rootName; - })) { - const emptyParamIdx = jsdocParameterNames.findIndex(({ - name - }) => { - return !name; - }); - if (emptyParamIdx > -1) { - missingTags.push({ - functionParameterIdx: emptyParamIdx, - functionParameterName: rootName, - inc, - remove: true - }); - } else { - missingTags.push({ - functionParameterIdx: hasParamIndex(rootName) ? getParamIndex(rootName) : getParamIndex(paramName), - functionParameterName: rootName, - inc - }); - } - } - if (!checkDestructured) { - continue; - } - if (!checkRestProperty && rests[idx]) { - continue; - } - const fullParamName = `${rootName}.${paramName}`; - const notCheckingName = jsdocParameterNames.find(({ - name, - type: paramType - }) => { - return utils.comparePaths(name)(fullParamName) && paramType.search(checkTypesRegex) === -1 && paramType !== ''; - }); - if (notCheckingName !== undefined) { - notCheckingNames.push(notCheckingName.name); - } - if (notCheckingNames.find(name => { - return fullParamName.startsWith(name); - })) { - continue; - } - if (jsdocParameterNames && !jsdocParameterNames.find(({ - name - }) => { - return utils.comparePaths(name)(fullParamName); - })) { - missingTags.push({ - functionParameterIdx: getParamIndex(functionParameterName[0] ? fullParamName : paramName), - functionParameterName: fullParamName, - inc, - type: hasRestElement && !hasPropertyRest ? '{...any}' : undefined - }); - } - } - continue; - } - - /** @type {string} */ - let funcParamName; - let type; - if (typeof functionParameterName === 'object') { - if (!enableRestElementFixer && functionParameterName.restElement) { - continue; - } - funcParamName = /** @type {string} */functionParameterName.name; - type = '{...any}'; - } else { - funcParamName = /** @type {string} */functionParameterName; - } - if (jsdocParameterNames && !jsdocParameterNames.find(({ - name - }) => { - return name === funcParamName; - }) && funcParamName !== 'this') { - missingTags.push({ - functionParameterIdx: getParamIndex(funcParamName), - functionParameterName: funcParamName, - inc, - type - }); - } - } - - /** - * - * @param {{ - * functionParameterIdx: import('../iterateJsdoc.js').Integer, - * functionParameterName: string, - * remove?: true, - * inc?: boolean, - * type?: string - * }} cfg - */ - const fix = ({ - functionParameterIdx, - functionParameterName, - remove, - inc, - type - }) => { - if (inc && !enableRootFixer) { - return; - } - - /** - * - * @param {import('../iterateJsdoc.js').Integer} tagIndex - * @param {import('../iterateJsdoc.js').Integer} sourceIndex - * @param {import('../iterateJsdoc.js').Integer} spliceCount - * @returns {void} - */ - const createTokens = (tagIndex, sourceIndex, spliceCount) => { - // console.log(sourceIndex, tagIndex, jsdoc.tags, jsdoc.source); - const tokens = { - number: sourceIndex + 1, - source: '', - tokens: { - delimiter: '*', - description: '', - end: '', - lineEnd: '', - name: functionParameterName, - newAdd: true, - postDelimiter: ' ', - postName: '', - postTag: ' ', - postType: type ? ' ' : '', - start: jsdoc.source[sourceIndex].tokens.start, - tag: `@${preferredTagName}`, - type: type ?? '' - } - }; - - /** - * @type {(import('@es-joy/jsdoccomment').JsdocTagWithInline & { - * newAdd?: true - * })[]} - */ - jsdoc.tags.splice(tagIndex, spliceCount, { - description: '', - inlineTags: [], - name: functionParameterName, - newAdd: true, - optional: false, - problems: [], - source: [tokens], - tag: preferredTagName, - type: type ?? '' - }); - const firstNumber = jsdoc.source[0].number; - jsdoc.source.splice(sourceIndex, spliceCount, tokens); - for (const [idx, src] of jsdoc.source.slice(sourceIndex).entries()) { - src.number = firstNumber + sourceIndex + idx; - } - }; - const offset = jsdoc.source.findIndex(({ - tokens: { - tag, - end - } - }) => { - return tag || end; - }); - if (remove) { - createTokens(functionParameterIdx, offset + functionParameterIdx, 1); - } else { - const expectedIdx = findExpectedIndex(jsdoc.tags, functionParameterIdx); - createTokens(expectedIdx, offset + expectedIdx, 0); - } - }; - - /** - * @returns {void} - */ - const fixer = () => { - for (const missingTag of missingTags) { - fix(missingTag); - } - }; - if (missingTags.length && jsdoc.source.length === 1) { - utils.makeMultiline(); - } - for (const { - functionParameterName - } of missingTags) { - utils.reportJSDoc(`Missing JSDoc @${preferredTagName} "${functionParameterName}" declaration.`, null, enableFixer ? fixer : null); - } -}, { - contextDefaults: true, - meta: { - docs: { - description: 'Requires that all function parameters are documented.', - url: 'https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/require-param.md#repos-sticky-header' - }, - fixable: 'code', - schema: [{ - additionalProperties: false, - properties: { - autoIncrementBase: { - default: 0, - type: 'integer' - }, - checkConstructors: { - default: true, - type: 'boolean' - }, - checkDestructured: { - default: true, - type: 'boolean' - }, - checkDestructuredRoots: { - default: true, - type: 'boolean' - }, - checkGetters: { - default: false, - type: 'boolean' - }, - checkRestProperty: { - default: false, - type: 'boolean' - }, - checkSetters: { - default: false, - type: 'boolean' - }, - checkTypesPattern: { - type: 'string' - }, - contexts: { - items: { - anyOf: [{ - type: 'string' - }, { - additionalProperties: false, - properties: { - comment: { - type: 'string' - }, - context: { - type: 'string' - } - }, - type: 'object' - }] - }, - type: 'array' - }, - enableFixer: { - type: 'boolean' - }, - enableRestElementFixer: { - type: 'boolean' - }, - enableRootFixer: { - type: 'boolean' - }, - exemptedBy: { - items: { - type: 'string' - }, - type: 'array' - }, - unnamedRootBase: { - items: { - type: 'string' - }, - type: 'array' - }, - useDefaultObjectProperties: { - type: 'boolean' - } - }, - type: 'object' - }], - type: 'suggestion' - }, - // We cannot cache comment nodes as the contexts may recur with the - // same comment node but a different JS node, and we may need the different - // JS node to ensure we iterate its context - noTracking: true -}); -module.exports = exports.default; -//# sourceMappingURL=requireParam.cjs.map \ No newline at end of file diff --git a/tools/eslint/node_modules/eslint-plugin-jsdoc/dist/rules/requireParamDescription.cjs b/tools/eslint/node_modules/eslint-plugin-jsdoc/dist/rules/requireParamDescription.cjs deleted file mode 100644 index 28f0e95d28426b..00000000000000 --- a/tools/eslint/node_modules/eslint-plugin-jsdoc/dist/rules/requireParamDescription.cjs +++ /dev/null @@ -1,84 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.default = void 0; -var _iterateJsdoc = _interopRequireDefault(require("../iterateJsdoc.cjs")); -function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; } -var _default = exports.default = (0, _iterateJsdoc.default)(({ - context, - report, - settings, - utils -}) => { - const { - defaultDestructuredRootDescription = 'The root object', - setDefaultDestructuredRootDescription = false - } = context.options[0] || {}; - const functionParameterNames = utils.getFunctionParameterNames(); - let rootCount = -1; - utils.forEachPreferredTag('param', (jsdocParameter, targetTagName) => { - rootCount += jsdocParameter.name.includes('.') ? 0 : 1; - if (!jsdocParameter.description.trim()) { - if (Array.isArray(functionParameterNames[rootCount])) { - if (settings.exemptDestructuredRootsFromChecks) { - return; - } - if (setDefaultDestructuredRootDescription) { - utils.reportJSDoc(`Missing root description for @${targetTagName}.`, jsdocParameter, () => { - utils.changeTag(jsdocParameter, { - description: defaultDestructuredRootDescription, - postName: ' ' - }); - }); - return; - } - } - report(`Missing JSDoc @${targetTagName} "${jsdocParameter.name}" description.`, null, jsdocParameter); - } - }); -}, { - contextDefaults: true, - meta: { - docs: { - description: 'Requires that each `@param` tag has a `description` value.', - url: 'https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/require-param-description.md#repos-sticky-header' - }, - fixable: 'code', - schema: [{ - additionalProperties: false, - properties: { - contexts: { - items: { - anyOf: [{ - type: 'string' - }, { - additionalProperties: false, - properties: { - comment: { - type: 'string' - }, - context: { - type: 'string' - } - }, - type: 'object' - }] - }, - type: 'array' - }, - defaultDestructuredRootDescription: { - type: 'string' - }, - setDefaultDestructuredRootDescription: { - type: 'boolean' - } - }, - type: 'object' - }], - type: 'suggestion' - } -}); -module.exports = exports.default; -//# sourceMappingURL=requireParamDescription.cjs.map \ No newline at end of file diff --git a/tools/eslint/node_modules/eslint-plugin-jsdoc/dist/rules/requireParamName.cjs b/tools/eslint/node_modules/eslint-plugin-jsdoc/dist/rules/requireParamName.cjs deleted file mode 100644 index 526219dbae6435..00000000000000 --- a/tools/eslint/node_modules/eslint-plugin-jsdoc/dist/rules/requireParamName.cjs +++ /dev/null @@ -1,54 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.default = void 0; -var _iterateJsdoc = _interopRequireDefault(require("../iterateJsdoc.cjs")); -function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; } -var _default = exports.default = (0, _iterateJsdoc.default)(({ - report, - utils -}) => { - utils.forEachPreferredTag('param', (jsdocParameter, targetTagName) => { - if (jsdocParameter.tag && jsdocParameter.name === '') { - report(`There must be an identifier after @${targetTagName} ${jsdocParameter.type === '' ? 'type' : 'tag'}.`, null, jsdocParameter); - } - }); -}, { - contextDefaults: true, - meta: { - docs: { - description: 'Requires that all function parameters have names.', - url: 'https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/require-param-name.md#repos-sticky-header' - }, - schema: [{ - additionalProperties: false, - properties: { - contexts: { - items: { - anyOf: [{ - type: 'string' - }, { - additionalProperties: false, - properties: { - comment: { - type: 'string' - }, - context: { - type: 'string' - } - }, - type: 'object' - }] - }, - type: 'array' - } - }, - type: 'object' - }], - type: 'suggestion' - } -}); -module.exports = exports.default; -//# sourceMappingURL=requireParamName.cjs.map \ No newline at end of file diff --git a/tools/eslint/node_modules/eslint-plugin-jsdoc/dist/rules/requireParamType.cjs b/tools/eslint/node_modules/eslint-plugin-jsdoc/dist/rules/requireParamType.cjs deleted file mode 100644 index 167864752e2acb..00000000000000 --- a/tools/eslint/node_modules/eslint-plugin-jsdoc/dist/rules/requireParamType.cjs +++ /dev/null @@ -1,84 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.default = void 0; -var _iterateJsdoc = _interopRequireDefault(require("../iterateJsdoc.cjs")); -function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; } -var _default = exports.default = (0, _iterateJsdoc.default)(({ - context, - report, - settings, - utils -}) => { - const { - defaultDestructuredRootType = 'object', - setDefaultDestructuredRootType = false - } = context.options[0] || {}; - const functionParameterNames = utils.getFunctionParameterNames(); - let rootCount = -1; - utils.forEachPreferredTag('param', (jsdocParameter, targetTagName) => { - rootCount += jsdocParameter.name.includes('.') ? 0 : 1; - if (!jsdocParameter.type) { - if (Array.isArray(functionParameterNames[rootCount])) { - if (settings.exemptDestructuredRootsFromChecks) { - return; - } - if (setDefaultDestructuredRootType) { - utils.reportJSDoc(`Missing root type for @${targetTagName}.`, jsdocParameter, () => { - utils.changeTag(jsdocParameter, { - postType: ' ', - type: `{${defaultDestructuredRootType}}` - }); - }); - return; - } - } - report(`Missing JSDoc @${targetTagName} "${jsdocParameter.name}" type.`, null, jsdocParameter); - } - }); -}, { - contextDefaults: true, - meta: { - docs: { - description: 'Requires that each `@param` tag has a `type` value.', - url: 'https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/require-param-type.md#repos-sticky-header' - }, - fixable: 'code', - schema: [{ - additionalProperties: false, - properties: { - contexts: { - items: { - anyOf: [{ - type: 'string' - }, { - additionalProperties: false, - properties: { - comment: { - type: 'string' - }, - context: { - type: 'string' - } - }, - type: 'object' - }] - }, - type: 'array' - }, - defaultDestructuredRootType: { - type: 'string' - }, - setDefaultDestructuredRootType: { - type: 'boolean' - } - }, - type: 'object' - }], - type: 'suggestion' - } -}); -module.exports = exports.default; -//# sourceMappingURL=requireParamType.cjs.map \ No newline at end of file diff --git a/tools/eslint/node_modules/eslint-plugin-jsdoc/dist/rules/requireProperty.cjs b/tools/eslint/node_modules/eslint-plugin-jsdoc/dist/rules/requireProperty.cjs deleted file mode 100644 index d71ee42a385b55..00000000000000 --- a/tools/eslint/node_modules/eslint-plugin-jsdoc/dist/rules/requireProperty.cjs +++ /dev/null @@ -1,46 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.default = void 0; -var _iterateJsdoc = _interopRequireDefault(require("../iterateJsdoc.cjs")); -function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; } -var _default = exports.default = (0, _iterateJsdoc.default)(({ - utils -}) => { - const propertyAssociatedTags = utils.filterTags(({ - tag - }) => { - return ['typedef', 'namespace'].includes(tag); - }); - if (!propertyAssociatedTags.length) { - return; - } - const targetTagName = /** @type {string} */utils.getPreferredTagName({ - tagName: 'property' - }); - if (utils.hasATag([targetTagName])) { - return; - } - for (const propertyAssociatedTag of propertyAssociatedTags) { - if (!['object', 'Object', 'PlainObject'].includes(propertyAssociatedTag.type)) { - continue; - } - utils.reportJSDoc(`Missing JSDoc @${targetTagName}.`, null, () => { - utils.addTag(targetTagName); - }); - } -}, { - iterateAllJsdocs: true, - meta: { - docs: { - description: 'Requires that all `@typedef` and `@namespace` tags have `@property` when their type is a plain `object`, `Object`, or `PlainObject`.', - url: 'https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/require-property.md#repos-sticky-header' - }, - fixable: 'code', - type: 'suggestion' - } -}); -module.exports = exports.default; -//# sourceMappingURL=requireProperty.cjs.map \ No newline at end of file diff --git a/tools/eslint/node_modules/eslint-plugin-jsdoc/dist/rules/requirePropertyDescription.cjs b/tools/eslint/node_modules/eslint-plugin-jsdoc/dist/rules/requirePropertyDescription.cjs deleted file mode 100644 index 6f11d7191e0f09..00000000000000 --- a/tools/eslint/node_modules/eslint-plugin-jsdoc/dist/rules/requirePropertyDescription.cjs +++ /dev/null @@ -1,29 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.default = void 0; -var _iterateJsdoc = _interopRequireDefault(require("../iterateJsdoc.cjs")); -function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; } -var _default = exports.default = (0, _iterateJsdoc.default)(({ - report, - utils -}) => { - utils.forEachPreferredTag('property', (jsdoc, targetTagName) => { - if (!jsdoc.description.trim()) { - report(`Missing JSDoc @${targetTagName} "${jsdoc.name}" description.`, null, jsdoc); - } - }); -}, { - iterateAllJsdocs: true, - meta: { - docs: { - description: 'Requires that each `@property` tag has a `description` value.', - url: 'https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/require-property-description.md#repos-sticky-header' - }, - type: 'suggestion' - } -}); -module.exports = exports.default; -//# sourceMappingURL=requirePropertyDescription.cjs.map \ No newline at end of file diff --git a/tools/eslint/node_modules/eslint-plugin-jsdoc/dist/rules/requirePropertyName.cjs b/tools/eslint/node_modules/eslint-plugin-jsdoc/dist/rules/requirePropertyName.cjs deleted file mode 100644 index 3a6a9c5699b1ce..00000000000000 --- a/tools/eslint/node_modules/eslint-plugin-jsdoc/dist/rules/requirePropertyName.cjs +++ /dev/null @@ -1,29 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.default = void 0; -var _iterateJsdoc = _interopRequireDefault(require("../iterateJsdoc.cjs")); -function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; } -var _default = exports.default = (0, _iterateJsdoc.default)(({ - report, - utils -}) => { - utils.forEachPreferredTag('property', (jsdoc, targetTagName) => { - if (jsdoc.tag && jsdoc.name === '') { - report(`There must be an identifier after @${targetTagName} ${jsdoc.type === '' ? 'type' : 'tag'}.`, null, jsdoc); - } - }); -}, { - iterateAllJsdocs: true, - meta: { - docs: { - description: 'Requires that all function `@property` tags have names.', - url: 'https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/require-property-name.md#repos-sticky-header' - }, - type: 'suggestion' - } -}); -module.exports = exports.default; -//# sourceMappingURL=requirePropertyName.cjs.map \ No newline at end of file diff --git a/tools/eslint/node_modules/eslint-plugin-jsdoc/dist/rules/requirePropertyType.cjs b/tools/eslint/node_modules/eslint-plugin-jsdoc/dist/rules/requirePropertyType.cjs deleted file mode 100644 index 0257e3bf62c199..00000000000000 --- a/tools/eslint/node_modules/eslint-plugin-jsdoc/dist/rules/requirePropertyType.cjs +++ /dev/null @@ -1,29 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.default = void 0; -var _iterateJsdoc = _interopRequireDefault(require("../iterateJsdoc.cjs")); -function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; } -var _default = exports.default = (0, _iterateJsdoc.default)(({ - report, - utils -}) => { - utils.forEachPreferredTag('property', (jsdoc, targetTagName) => { - if (!jsdoc.type) { - report(`Missing JSDoc @${targetTagName} "${jsdoc.name}" type.`, null, jsdoc); - } - }); -}, { - iterateAllJsdocs: true, - meta: { - docs: { - description: 'Requires that each `@property` tag has a `type` value.', - url: 'https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/require-property-type.md#repos-sticky-header' - }, - type: 'suggestion' - } -}); -module.exports = exports.default; -//# sourceMappingURL=requirePropertyType.cjs.map \ No newline at end of file diff --git a/tools/eslint/node_modules/eslint-plugin-jsdoc/dist/rules/requireReturns.cjs b/tools/eslint/node_modules/eslint-plugin-jsdoc/dist/rules/requireReturns.cjs deleted file mode 100644 index 25f52cc6b5a08b..00000000000000 --- a/tools/eslint/node_modules/eslint-plugin-jsdoc/dist/rules/requireReturns.cjs +++ /dev/null @@ -1,209 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.default = void 0; -var _exportParser = _interopRequireDefault(require("../exportParser.cjs")); -var _iterateJsdoc = _interopRequireDefault(require("../iterateJsdoc.cjs")); -function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; } -/** - * We can skip checking for a return value, in case the documentation is inherited - * or the method is either a constructor or an abstract method. - * - * In either of these cases the return value is optional or not defined. - * @param {import('../iterateJsdoc.js').Utils} utils - * a reference to the utils which are used to probe if a tag is present or not. - * @returns {boolean} - * true in case deep checking can be skipped; otherwise false. - */ -const canSkip = utils => { - return utils.hasATag([ - // inheritdoc implies that all documentation is inherited - // see https://jsdoc.app/tags-inheritdoc.html - // - // Abstract methods are by definition incomplete, - // so it is not an error if it declares a return value but does not implement it. - 'abstract', 'virtual', - // Constructors do not have a return value by definition (https://jsdoc.app/tags-class.html) - // So we can bail out here, too. - 'class', 'constructor', - // Return type is specified by type in @type - 'type', - // This seems to imply a class as well - 'interface']) || utils.avoidDocs(); -}; -var _default = exports.default = (0, _iterateJsdoc.default)(({ - info: { - comment - }, - node, - report, - settings, - utils, - context -}) => { - const { - contexts, - enableFixer = false, - forceRequireReturn = false, - forceReturnsWithAsync = false, - publicOnly = false - } = context.options[0] || {}; - - // A preflight check. We do not need to run a deep check - // in case the @returns comment is optional or undefined. - if (canSkip(utils)) { - return; - } - - /** @type {boolean|undefined} */ - let forceRequireReturnContext; - if (contexts) { - const { - foundContext - } = utils.findContext(contexts, comment); - if (typeof foundContext === 'object') { - forceRequireReturnContext = foundContext.forceRequireReturn; - } - } - const tagName = /** @type {string} */utils.getPreferredTagName({ - tagName: 'returns' - }); - if (!tagName) { - return; - } - const tags = utils.getTags(tagName); - if (tags.length > 1) { - report(`Found more than one @${tagName} declaration.`); - } - const iteratingFunction = utils.isIteratingFunction(); - - // In case the code returns something, we expect a return value in JSDoc. - const [tag] = tags; - const missingReturnTag = typeof tag === 'undefined' || tag === null; - const shouldReport = () => { - if (!missingReturnTag) { - return false; - } - if (publicOnly) { - /** @type {import('./requireJsdoc.js').RequireJsdocOpts} */ - const opt = { - ancestorsOnly: Boolean((publicOnly === null || publicOnly === void 0 ? void 0 : publicOnly.ancestorsOnly) ?? false), - esm: Boolean((publicOnly === null || publicOnly === void 0 ? void 0 : publicOnly.esm) ?? true), - initModuleExports: Boolean((publicOnly === null || publicOnly === void 0 ? void 0 : publicOnly.cjs) ?? true), - initWindow: Boolean((publicOnly === null || publicOnly === void 0 ? void 0 : publicOnly.window) ?? false) - }; - /* c8 ignore next -- Fallback to deprecated method */ - const { - sourceCode = context.getSourceCode() - } = context; - const exported = _exportParser.default.isUncommentedExport( /** @type {import('eslint').Rule.Node} */node, sourceCode, opt, settings); - if (!exported) { - return false; - } - } - if ((forceRequireReturn || forceRequireReturnContext) && (iteratingFunction || utils.isVirtualFunction())) { - return true; - } - const isAsync = !iteratingFunction && utils.hasTag('async') || iteratingFunction && utils.isAsync(); - if (forceReturnsWithAsync && isAsync) { - return true; - } - return iteratingFunction && utils.hasValueOrExecutorHasNonEmptyResolveValue(forceReturnsWithAsync); - }; - if (shouldReport()) { - utils.reportJSDoc(`Missing JSDoc @${tagName} declaration.`, null, enableFixer ? () => { - utils.addTag(tagName); - } : null); - } -}, { - contextDefaults: true, - meta: { - docs: { - description: 'Requires that returns are documented.', - url: 'https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/require-returns.md#repos-sticky-header' - }, - fixable: 'code', - schema: [{ - additionalProperties: false, - properties: { - checkConstructors: { - default: false, - type: 'boolean' - }, - checkGetters: { - default: true, - type: 'boolean' - }, - contexts: { - items: { - anyOf: [{ - type: 'string' - }, { - additionalProperties: false, - properties: { - comment: { - type: 'string' - }, - context: { - type: 'string' - }, - forceRequireReturn: { - type: 'boolean' - } - }, - type: 'object' - }] - }, - type: 'array' - }, - enableFixer: { - type: 'boolean' - }, - exemptedBy: { - items: { - type: 'string' - }, - type: 'array' - }, - forceRequireReturn: { - default: false, - type: 'boolean' - }, - forceReturnsWithAsync: { - default: false, - type: 'boolean' - }, - publicOnly: { - oneOf: [{ - default: false, - type: 'boolean' - }, { - additionalProperties: false, - default: {}, - properties: { - ancestorsOnly: { - type: 'boolean' - }, - cjs: { - type: 'boolean' - }, - esm: { - type: 'boolean' - }, - window: { - type: 'boolean' - } - }, - type: 'object' - }] - } - }, - type: 'object' - }], - type: 'suggestion' - } -}); -module.exports = exports.default; -//# sourceMappingURL=requireReturns.cjs.map \ No newline at end of file diff --git a/tools/eslint/node_modules/eslint-plugin-jsdoc/dist/rules/requireReturnsCheck.cjs b/tools/eslint/node_modules/eslint-plugin-jsdoc/dist/rules/requireReturnsCheck.cjs deleted file mode 100755 index 80f83cef3e99e4..00000000000000 --- a/tools/eslint/node_modules/eslint-plugin-jsdoc/dist/rules/requireReturnsCheck.cjs +++ /dev/null @@ -1,109 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.default = void 0; -var _iterateJsdoc = _interopRequireDefault(require("../iterateJsdoc.cjs")); -function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; } -/** - * @param {import('../iterateJsdoc.js').Utils} utils - * @param {import('../iterateJsdoc.js').Settings} settings - * @returns {boolean} - */ -const canSkip = (utils, settings) => { - const voidingTags = [ - // An abstract function is by definition incomplete - // so it is perfectly fine if a return is documented but - // not present within the function. - // A subclass may inherit the doc and implement the - // missing return. - 'abstract', 'virtual', - // A constructor function returns `this` by default, so may be `@returns` - // tag indicating this but no explicit return - 'class', 'constructor', 'interface']; - if (settings.mode === 'closure') { - // Structural Interface in GCC terms, equivalent to @interface tag as far as this rule is concerned - voidingTags.push('record'); - } - return utils.hasATag(voidingTags) || utils.isConstructor() || utils.classHasTag('interface') || settings.mode === 'closure' && utils.classHasTag('record'); -}; - -// eslint-disable-next-line complexity -- Temporary -var _default = exports.default = (0, _iterateJsdoc.default)(({ - context, - node, - report, - settings, - utils -}) => { - const { - exemptAsync = true, - exemptGenerators = settings.mode === 'typescript', - reportMissingReturnForUndefinedTypes = false - } = context.options[0] || {}; - if (canSkip(utils, settings)) { - return; - } - if (exemptAsync && utils.isAsync()) { - return; - } - const tagName = /** @type {string} */utils.getPreferredTagName({ - tagName: 'returns' - }); - if (!tagName) { - return; - } - const tags = utils.getTags(tagName); - if (tags.length === 0) { - return; - } - if (tags.length > 1) { - report(`Found more than one @${tagName} declaration.`); - return; - } - const [tag] = tags; - const type = tag.type.trim(); - - // https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-7.html#assertion-functions - if (/asserts\s/u.test(type)) { - return; - } - const returnNever = type === 'never'; - if (returnNever && utils.hasValueOrExecutorHasNonEmptyResolveValue(false)) { - report(`JSDoc @${tagName} declaration set with "never" but return expression is present in function.`); - return; - } - - // In case a return value is declared in JSDoc, we also expect one in the code. - if (!returnNever && (reportMissingReturnForUndefinedTypes || !utils.mayBeUndefinedTypeTag(tag)) && (tag.type === '' && !utils.hasValueOrExecutorHasNonEmptyResolveValue(exemptAsync) || tag.type !== '' && !utils.hasValueOrExecutorHasNonEmptyResolveValue(exemptAsync, true)) && Boolean(!exemptGenerators || !node || !('generator' in ( /** @type {import('../iterateJsdoc.js').Node} */node)) || !( /** @type {import('@typescript-eslint/types').TSESTree.FunctionDeclaration} */node).generator)) { - report(`JSDoc @${tagName} declaration present but return expression not available in function.`); - } -}, { - meta: { - docs: { - description: 'Requires a return statement in function body if a `@returns` tag is specified in jsdoc comment.', - url: 'https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/require-returns-check.md#repos-sticky-header' - }, - schema: [{ - additionalProperties: false, - properties: { - exemptAsync: { - default: true, - type: 'boolean' - }, - exemptGenerators: { - type: 'boolean' - }, - reportMissingReturnForUndefinedTypes: { - default: false, - type: 'boolean' - } - }, - type: 'object' - }], - type: 'suggestion' - } -}); -module.exports = exports.default; -//# sourceMappingURL=requireReturnsCheck.cjs.map \ No newline at end of file diff --git a/tools/eslint/node_modules/eslint-plugin-jsdoc/dist/rules/requireReturnsDescription.cjs b/tools/eslint/node_modules/eslint-plugin-jsdoc/dist/rules/requireReturnsDescription.cjs deleted file mode 100644 index aa38191e13eb9f..00000000000000 --- a/tools/eslint/node_modules/eslint-plugin-jsdoc/dist/rules/requireReturnsDescription.cjs +++ /dev/null @@ -1,58 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.default = void 0; -var _iterateJsdoc = _interopRequireDefault(require("../iterateJsdoc.cjs")); -function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; } -var _default = exports.default = (0, _iterateJsdoc.default)(({ - report, - utils -}) => { - utils.forEachPreferredTag('returns', (jsdocTag, targetTagName) => { - const type = jsdocTag.type && jsdocTag.type.trim(); - if (['void', 'undefined', 'Promise', 'Promise'].includes(type)) { - return; - } - if (!jsdocTag.description.trim()) { - report(`Missing JSDoc @${targetTagName} description.`, null, jsdocTag); - } - }); -}, { - contextDefaults: true, - meta: { - docs: { - description: 'Requires that the `@returns` tag has a `description` value.', - url: 'https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/require-returns-description.md#repos-sticky-header' - }, - schema: [{ - additionalProperties: false, - properties: { - contexts: { - items: { - anyOf: [{ - type: 'string' - }, { - additionalProperties: false, - properties: { - comment: { - type: 'string' - }, - context: { - type: 'string' - } - }, - type: 'object' - }] - }, - type: 'array' - } - }, - type: 'object' - }], - type: 'suggestion' - } -}); -module.exports = exports.default; -//# sourceMappingURL=requireReturnsDescription.cjs.map \ No newline at end of file diff --git a/tools/eslint/node_modules/eslint-plugin-jsdoc/dist/rules/requireReturnsType.cjs b/tools/eslint/node_modules/eslint-plugin-jsdoc/dist/rules/requireReturnsType.cjs deleted file mode 100644 index 06c3b47d619d7a..00000000000000 --- a/tools/eslint/node_modules/eslint-plugin-jsdoc/dist/rules/requireReturnsType.cjs +++ /dev/null @@ -1,54 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.default = void 0; -var _iterateJsdoc = _interopRequireDefault(require("../iterateJsdoc.cjs")); -function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; } -var _default = exports.default = (0, _iterateJsdoc.default)(({ - report, - utils -}) => { - utils.forEachPreferredTag('returns', (jsdocTag, targetTagName) => { - if (!jsdocTag.type) { - report(`Missing JSDoc @${targetTagName} type.`, null, jsdocTag); - } - }); -}, { - contextDefaults: true, - meta: { - docs: { - description: 'Requires that `@returns` tag has `type` value.', - url: 'https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/require-returns-type.md#repos-sticky-header' - }, - schema: [{ - additionalProperties: false, - properties: { - contexts: { - items: { - anyOf: [{ - type: 'string' - }, { - additionalProperties: false, - properties: { - comment: { - type: 'string' - }, - context: { - type: 'string' - } - }, - type: 'object' - }] - }, - type: 'array' - } - }, - type: 'object' - }], - type: 'suggestion' - } -}); -module.exports = exports.default; -//# sourceMappingURL=requireReturnsType.cjs.map \ No newline at end of file diff --git a/tools/eslint/node_modules/eslint-plugin-jsdoc/dist/rules/requireTemplate.cjs b/tools/eslint/node_modules/eslint-plugin-jsdoc/dist/rules/requireTemplate.cjs deleted file mode 100644 index b81f45f18d4df0..00000000000000 --- a/tools/eslint/node_modules/eslint-plugin-jsdoc/dist/rules/requireTemplate.cjs +++ /dev/null @@ -1,124 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.default = void 0; -var _jsdoccomment = require("@es-joy/jsdoccomment"); -var _iterateJsdoc = _interopRequireDefault(require("../iterateJsdoc.cjs")); -function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; } -var _default = exports.default = (0, _iterateJsdoc.default)(({ - context, - utils, - node, - settings, - report -}) => { - const { - requireSeparateTemplates = false - } = context.options[0] || {}; - const { - mode - } = settings; - const usedNames = new Set(); - const templateTags = utils.getTags('template'); - const templateNames = templateTags.flatMap(({ - name - }) => { - return name.split(/,\s*/); - }); - for (const tag of templateTags) { - const { - name - } = tag; - const names = name.split(/,\s*/); - if (requireSeparateTemplates && names.length > 1) { - report(`Missing separate @template for ${names[1]}`, null, tag); - } - } - - /** - * @param {import('@typescript-eslint/types').TSESTree.TSTypeAliasDeclaration} aliasDeclaration - */ - const checkParameters = aliasDeclaration => { - /* c8 ignore next -- Guard */ - const { - params - } = aliasDeclaration.typeParameters ?? { - params: [] - }; - for (const { - name: { - name - } - } of params) { - usedNames.add(name); - } - for (const usedName of usedNames) { - if (!templateNames.includes(usedName)) { - report(`Missing @template ${usedName}`); - } - } - }; - const handleTypeAliases = () => { - var _nde$declaration; - const nde = /** @type {import('@typescript-eslint/types').TSESTree.Node} */ - node; - if (!nde) { - return; - } - switch (nde.type) { - case 'ExportNamedDeclaration': - if (((_nde$declaration = nde.declaration) === null || _nde$declaration === void 0 ? void 0 : _nde$declaration.type) === 'TSTypeAliasDeclaration') { - checkParameters(nde.declaration); - } - break; - case 'TSTypeAliasDeclaration': - checkParameters(nde); - break; - } - }; - const typedefTags = utils.getTags('typedef'); - if (!typedefTags.length || typedefTags.length >= 2) { - handleTypeAliases(); - return; - } - const potentialType = typedefTags[0].type; - const parsedType = mode === 'permissive' ? (0, _jsdoccomment.tryParse)( /** @type {string} */potentialType) : (0, _jsdoccomment.parse)( /** @type {string} */potentialType, mode); - (0, _jsdoccomment.traverse)(parsedType, nde => { - const { - type, - value - } = /** @type {import('jsdoc-type-pratt-parser').NameResult} */nde; - if (type === 'JsdocTypeName' && /^[A-Z]$/.test(value)) { - usedNames.add(value); - } - }); - - // Could check against whitelist/blacklist - for (const usedName of usedNames) { - if (!templateNames.includes(usedName)) { - report(`Missing @template ${usedName}`, null, typedefTags[0]); - } - } -}, { - iterateAllJsdocs: true, - meta: { - docs: { - description: 'Requires template tags for each generic type parameter', - url: 'https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/require-template.md#repos-sticky-header' - }, - schema: [{ - additionalProperties: false, - properties: { - requireSeparateTemplates: { - type: 'boolean' - } - }, - type: 'object' - }], - type: 'suggestion' - } -}); -module.exports = exports.default; -//# sourceMappingURL=requireTemplate.cjs.map \ No newline at end of file diff --git a/tools/eslint/node_modules/eslint-plugin-jsdoc/dist/rules/requireThrows.cjs b/tools/eslint/node_modules/eslint-plugin-jsdoc/dist/rules/requireThrows.cjs deleted file mode 100644 index 274ac219ccd83a..00000000000000 --- a/tools/eslint/node_modules/eslint-plugin-jsdoc/dist/rules/requireThrows.cjs +++ /dev/null @@ -1,101 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.default = void 0; -var _iterateJsdoc = _interopRequireDefault(require("../iterateJsdoc.cjs")); -function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; } -/** - * We can skip checking for a throws value, in case the documentation is inherited - * or the method is either a constructor or an abstract method. - * @param {import('../iterateJsdoc.js').Utils} utils a reference to the utils which are used to probe if a tag is present or not. - * @returns {boolean} true in case deep checking can be skipped; otherwise false. - */ -const canSkip = utils => { - return utils.hasATag([ - // inheritdoc implies that all documentation is inherited - // see https://jsdoc.app/tags-inheritdoc.html - // - // Abstract methods are by definition incomplete, - // so it is not necessary to document that they throw an error. - 'abstract', 'virtual', - // The designated type can itself document `@throws` - 'type']) || utils.avoidDocs(); -}; -var _default = exports.default = (0, _iterateJsdoc.default)(({ - report, - utils -}) => { - // A preflight check. We do not need to run a deep check for abstract - // functions. - if (canSkip(utils)) { - return; - } - const tagName = /** @type {string} */utils.getPreferredTagName({ - tagName: 'throws' - }); - if (!tagName) { - return; - } - const tags = utils.getTags(tagName); - const iteratingFunction = utils.isIteratingFunction(); - - // In case the code returns something, we expect a return value in JSDoc. - const [tag] = tags; - const missingThrowsTag = typeof tag === 'undefined' || tag === null; - const shouldReport = () => { - if (!missingThrowsTag) { - if (tag.type.trim() === 'never' && iteratingFunction && utils.hasThrowValue()) { - report(`JSDoc @${tagName} declaration set to "never" but throw value found.`); - } - return false; - } - return iteratingFunction && utils.hasThrowValue(); - }; - if (shouldReport()) { - report(`Missing JSDoc @${tagName} declaration.`); - } -}, { - contextDefaults: true, - meta: { - docs: { - description: 'Requires that throw statements are documented.', - url: 'https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/require-throws.md#repos-sticky-header' - }, - schema: [{ - additionalProperties: false, - properties: { - contexts: { - items: { - anyOf: [{ - type: 'string' - }, { - additionalProperties: false, - properties: { - comment: { - type: 'string' - }, - context: { - type: 'string' - } - }, - type: 'object' - }] - }, - type: 'array' - }, - exemptedBy: { - items: { - type: 'string' - }, - type: 'array' - } - }, - type: 'object' - }], - type: 'suggestion' - } -}); -module.exports = exports.default; -//# sourceMappingURL=requireThrows.cjs.map \ No newline at end of file diff --git a/tools/eslint/node_modules/eslint-plugin-jsdoc/dist/rules/requireYields.cjs b/tools/eslint/node_modules/eslint-plugin-jsdoc/dist/rules/requireYields.cjs deleted file mode 100644 index 5df6b3d8a9041d..00000000000000 --- a/tools/eslint/node_modules/eslint-plugin-jsdoc/dist/rules/requireYields.cjs +++ /dev/null @@ -1,175 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.default = void 0; -var _iterateJsdoc = _interopRequireDefault(require("../iterateJsdoc.cjs")); -function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; } -/** - * We can skip checking for a yield value, in case the documentation is inherited - * or the method has a constructor or abstract tag. - * - * In either of these cases the yield value is optional or not defined. - * @param {import('../iterateJsdoc.js').Utils} utils a reference to the utils which are used to probe if a tag is present or not. - * @returns {boolean} true in case deep checking can be skipped; otherwise false. - */ -const canSkip = utils => { - return utils.hasATag([ - // inheritdoc implies that all documentation is inherited - // see https://jsdoc.app/tags-inheritdoc.html - // - // Abstract methods are by definition incomplete, - // so it is not an error if it declares a yield value but does not implement it. - 'abstract', 'virtual', - // Constructors do not have a yield value - // so we can bail out here, too. - 'class', 'constructor', - // Yield (and any `next`) type is specified accompanying the targeted - // @type - 'type', - // This seems to imply a class as well - 'interface']) || utils.avoidDocs(); -}; - -/** - * @param {import('../iterateJsdoc.js').Utils} utils - * @param {import('../iterateJsdoc.js').Report} report - * @param {string} tagName - * @returns {[preferredTagName?: string, missingTag?: boolean]} - */ -const checkTagName = (utils, report, tagName) => { - const preferredTagName = /** @type {string} */utils.getPreferredTagName({ - tagName - }); - if (!preferredTagName) { - return []; - } - const tags = utils.getTags(preferredTagName); - if (tags.length > 1) { - report(`Found more than one @${preferredTagName} declaration.`); - } - - // In case the code yields something, we expect a yields value in JSDoc. - const [tag] = tags; - const missingTag = typeof tag === 'undefined' || tag === null; - return [preferredTagName, missingTag]; -}; -var _default = exports.default = (0, _iterateJsdoc.default)(({ - report, - utils, - context -}) => { - const { - next = false, - nextWithGeneratorTag = false, - forceRequireNext = false, - forceRequireYields = false, - withGeneratorTag = true - } = context.options[0] || {}; - - // A preflight check. We do not need to run a deep check - // in case the @yield comment is optional or undefined. - if (canSkip(utils)) { - return; - } - const iteratingFunction = utils.isIteratingFunction(); - const [preferredYieldTagName, missingYieldTag] = checkTagName(utils, report, 'yields'); - if (preferredYieldTagName) { - const shouldReportYields = () => { - if (!missingYieldTag) { - return false; - } - if (withGeneratorTag && utils.hasTag('generator') || forceRequireYields && iteratingFunction && utils.isGenerator()) { - return true; - } - return iteratingFunction && utils.isGenerator() && utils.hasYieldValue(); - }; - if (shouldReportYields()) { - report(`Missing JSDoc @${preferredYieldTagName} declaration.`); - } - } - if (next || nextWithGeneratorTag || forceRequireNext) { - const [preferredNextTagName, missingNextTag] = checkTagName(utils, report, 'next'); - if (!preferredNextTagName) { - return; - } - const shouldReportNext = () => { - if (!missingNextTag) { - return false; - } - if (nextWithGeneratorTag && utils.hasTag('generator')) { - return true; - } - if (!next && !forceRequireNext || !iteratingFunction || !utils.isGenerator()) { - return false; - } - return forceRequireNext || utils.hasYieldReturnValue(); - }; - if (shouldReportNext()) { - report(`Missing JSDoc @${preferredNextTagName} declaration.`); - } - } -}, { - contextDefaults: true, - meta: { - docs: { - description: 'Requires yields are documented.', - url: 'https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/require-yields.md#repos-sticky-header' - }, - schema: [{ - additionalProperties: false, - properties: { - contexts: { - items: { - anyOf: [{ - type: 'string' - }, { - additionalProperties: false, - properties: { - comment: { - type: 'string' - }, - context: { - type: 'string' - } - }, - type: 'object' - }] - }, - type: 'array' - }, - exemptedBy: { - items: { - type: 'string' - }, - type: 'array' - }, - forceRequireNext: { - default: false, - type: 'boolean' - }, - forceRequireYields: { - default: false, - type: 'boolean' - }, - next: { - default: false, - type: 'boolean' - }, - nextWithGeneratorTag: { - default: false, - type: 'boolean' - }, - withGeneratorTag: { - default: true, - type: 'boolean' - } - }, - type: 'object' - }], - type: 'suggestion' - } -}); -module.exports = exports.default; -//# sourceMappingURL=requireYields.cjs.map \ No newline at end of file diff --git a/tools/eslint/node_modules/eslint-plugin-jsdoc/dist/rules/requireYieldsCheck.cjs b/tools/eslint/node_modules/eslint-plugin-jsdoc/dist/rules/requireYieldsCheck.cjs deleted file mode 100644 index 1d7da7c3ca1a73..00000000000000 --- a/tools/eslint/node_modules/eslint-plugin-jsdoc/dist/rules/requireYieldsCheck.cjs +++ /dev/null @@ -1,161 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.default = void 0; -var _iterateJsdoc = _interopRequireDefault(require("../iterateJsdoc.cjs")); -function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; } -/** - * @param {import('../iterateJsdoc.js').Utils} utils - * @param {import('../iterateJsdoc.js').Settings} settings - * @returns {boolean} - */ -const canSkip = (utils, settings) => { - const voidingTags = [ - // An abstract function is by definition incomplete - // so it is perfectly fine if a yield is documented but - // not present within the function. - // A subclass may inherit the doc and implement the - // missing yield. - 'abstract', 'virtual', - // Constructor functions do not have a yield value - // so we can bail here, too. - 'class', 'constructor', - // This seems to imply a class as well - 'interface']; - if (settings.mode === 'closure') { - // Structural Interface in GCC terms, equivalent to @interface tag as far as this rule is concerned - voidingTags.push('record'); - } - return utils.hasATag(voidingTags) || utils.isConstructor() || utils.classHasTag('interface') || settings.mode === 'closure' && utils.classHasTag('record'); -}; - -/** - * @param {import('../iterateJsdoc.js').Utils} utils - * @param {import('../iterateJsdoc.js').Report} report - * @param {string} tagName - * @returns {[]|[preferredTagName: string, tag: import('comment-parser').Spec]} - */ -const checkTagName = (utils, report, tagName) => { - const preferredTagName = /** @type {string} */utils.getPreferredTagName({ - tagName - }); - if (!preferredTagName) { - return []; - } - const tags = utils.getTags(preferredTagName); - if (tags.length === 0) { - return []; - } - if (tags.length > 1) { - report(`Found more than one @${preferredTagName} declaration.`); - return []; - } - return [preferredTagName, tags[0]]; -}; -var _default = exports.default = (0, _iterateJsdoc.default)(({ - context, - report, - settings, - utils -}) => { - if (canSkip(utils, settings)) { - return; - } - const { - next = false, - checkGeneratorsOnly = false - } = context.options[0] || {}; - const [preferredYieldTagName, yieldTag] = checkTagName(utils, report, 'yields'); - if (preferredYieldTagName) { - const shouldReportYields = () => { - if ( /** @type {import('comment-parser').Spec} */yieldTag.type.trim() === 'never') { - if (utils.hasYieldValue()) { - report(`JSDoc @${preferredYieldTagName} declaration set with "never" but yield expression is present in function.`); - } - return false; - } - if (checkGeneratorsOnly && !utils.isGenerator()) { - return true; - } - return !utils.mayBeUndefinedTypeTag( /** @type {import('comment-parser').Spec} */ - yieldTag) && !utils.hasYieldValue(); - }; - - // In case a yield value is declared in JSDoc, we also expect one in the code. - if (shouldReportYields()) { - report(`JSDoc @${preferredYieldTagName} declaration present but yield expression not available in function.`); - } - } - if (next) { - const [preferredNextTagName, nextTag] = checkTagName(utils, report, 'next'); - if (preferredNextTagName) { - const shouldReportNext = () => { - if ( /** @type {import('comment-parser').Spec} */nextTag.type.trim() === 'never') { - if (utils.hasYieldReturnValue()) { - report(`JSDoc @${preferredNextTagName} declaration set with "never" but yield expression with return value is present in function.`); - } - return false; - } - if (checkGeneratorsOnly && !utils.isGenerator()) { - return true; - } - return !utils.mayBeUndefinedTypeTag( /** @type {import('comment-parser').Spec} */ - nextTag) && !utils.hasYieldReturnValue(); - }; - if (shouldReportNext()) { - report(`JSDoc @${preferredNextTagName} declaration present but yield expression with return value not available in function.`); - } - } - } -}, { - meta: { - docs: { - description: 'Requires a yield statement in function body if a `@yields` tag is specified in jsdoc comment.', - url: 'https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/require-yields-check.md#repos-sticky-header' - }, - schema: [{ - additionalProperties: false, - properties: { - checkGeneratorsOnly: { - default: false, - type: 'boolean' - }, - contexts: { - items: { - anyOf: [{ - type: 'string' - }, { - additionalProperties: false, - properties: { - comment: { - type: 'string' - }, - context: { - type: 'string' - } - }, - type: 'object' - }] - }, - type: 'array' - }, - exemptedBy: { - items: { - type: 'string' - }, - type: 'array' - }, - next: { - default: false, - type: 'boolean' - } - }, - type: 'object' - }], - type: 'suggestion' - } -}); -module.exports = exports.default; -//# sourceMappingURL=requireYieldsCheck.cjs.map \ No newline at end of file diff --git a/tools/eslint/node_modules/eslint-plugin-jsdoc/dist/rules/sortTags.cjs b/tools/eslint/node_modules/eslint-plugin-jsdoc/dist/rules/sortTags.cjs deleted file mode 100644 index a7bec4f1fe081d..00000000000000 --- a/tools/eslint/node_modules/eslint-plugin-jsdoc/dist/rules/sortTags.cjs +++ /dev/null @@ -1,450 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.default = void 0; -var _defaultTagOrder = _interopRequireDefault(require("../defaultTagOrder.cjs")); -var _iterateJsdoc = _interopRequireDefault(require("../iterateJsdoc.cjs")); -function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; } -// eslint-disable-next-line complexity -- Temporary -var _default = exports.default = (0, _iterateJsdoc.default)(({ - context, - jsdoc, - utils -}) => { - const - /** - * @type {{ - * linesBetween: import('../iterateJsdoc.js').Integer, - * tagSequence: { - * tags: string[] - * }[], - * alphabetizeExtras: boolean, - * reportTagGroupSpacing: boolean, - * reportIntraTagGroupSpacing: boolean, - * }} - */ - { - linesBetween = 1, - tagSequence = _defaultTagOrder.default, - alphabetizeExtras = false, - reportTagGroupSpacing = true, - reportIntraTagGroupSpacing = true - } = context.options[0] || {}; - const tagList = tagSequence.flatMap(obj => { - /* typeof obj === 'string' ? obj : */ - return obj.tags; - }); - const otherPos = tagList.indexOf('-other'); - const endPos = otherPos > -1 ? otherPos : tagList.length; - let ongoingCount = 0; - for (const [idx, tag] of - /** - * @type {( - * import('@es-joy/jsdoccomment').JsdocTagWithInline & { - * originalIndex: import('../iterateJsdoc.js').Integer, - * originalLine: import('../iterateJsdoc.js').Integer, - * } - * )[]} - */ - jsdoc.tags.entries()) { - tag.originalIndex = idx; - ongoingCount += tag.source.length; - tag.originalLine = ongoingCount; - } - - /** @type {import('../iterateJsdoc.js').Integer|undefined} */ - let firstChangedTagLine; - /** @type {import('../iterateJsdoc.js').Integer|undefined} */ - let firstChangedTagIndex; - - /** - * @type {(import('comment-parser').Spec & { - * originalIndex: import('../iterateJsdoc.js').Integer, - * originalLine: import('../iterateJsdoc.js').Integer, - * })[]} - */ - const sortedTags = JSON.parse(JSON.stringify(jsdoc.tags)); - sortedTags.sort(({ - tag: tagNew - }, { - originalIndex, - originalLine, - tag: tagOld - }) => { - // Optimize: Just keep relative positions if the same tag name - if (tagNew === tagOld) { - return 0; - } - const checkOrSetFirstChanged = () => { - if (!firstChangedTagLine || originalLine < firstChangedTagLine) { - firstChangedTagLine = originalLine; - firstChangedTagIndex = originalIndex; - } - }; - const newPos = tagList.indexOf(tagNew); - const oldPos = tagList.indexOf(tagOld); - const preferredNewPos = newPos === -1 ? endPos : newPos; - const preferredOldPos = oldPos === -1 ? endPos : oldPos; - if (preferredNewPos < preferredOldPos) { - checkOrSetFirstChanged(); - return -1; - } - if (preferredNewPos > preferredOldPos) { - return 1; - } - - // preferredNewPos === preferredOldPos - if (!alphabetizeExtras || - // Optimize: If tagNew (or tagOld which is the same) was found in the - // priority array, it can maintain its relative positionโ€”without need - // of alphabetizing (secondary sorting) - newPos >= 0) { - return 0; - } - if (tagNew < tagOld) { - checkOrSetFirstChanged(); - return -1; - } - - // tagNew > tagOld - return 1; - }); - if (firstChangedTagLine === undefined) { - // Should be ordered by now - - /** - * @type {import('comment-parser').Spec[]} - */ - const lastTagsOfGroup = []; - - /** - * @type {[ - * import('comment-parser').Spec, - * import('../iterateJsdoc.js').Integer - * ][]} - */ - const badLastTagsOfGroup = []; - - /** - * @param {import('comment-parser').Spec} tag - */ - const countTagEmptyLines = tag => { - return tag.source.reduce((acc, { - tokens: { - description, - name, - type, - end, - tag: tg - } - }) => { - const empty = !tg && !type && !name && !description; - // Reset the count so long as there is content - return empty ? acc + Number(empty && !end) : 0; - }, 0); - }; - let idx = 0; - for (const { - tags - } of tagSequence) { - let innerIdx; - /** @type {import('comment-parser').Spec} */ - let currentTag; - /** @type {import('comment-parser').Spec|undefined} */ - let lastTag; - do { - currentTag = jsdoc.tags[idx]; - if (!currentTag) { - idx++; - break; - } - innerIdx = tags.indexOf(currentTag.tag); - if (innerIdx === -1 && ( - // eslint-disable-next-line no-loop-func -- Safe - !tags.includes('-other') || tagSequence.some(({ - tags: tgs - }) => { - return tgs.includes(currentTag.tag); - }))) { - idx++; - break; - } - lastTag = currentTag; - idx++; - } while (true); - idx--; - if (lastTag) { - lastTagsOfGroup.push(lastTag); - const ct = countTagEmptyLines(lastTag); - if (ct !== linesBetween && - // Use another rule for adding to end (should be of interest outside this rule) - jsdoc.tags[idx]) { - badLastTagsOfGroup.push([lastTag, ct]); - } - } - } - if (reportTagGroupSpacing && badLastTagsOfGroup.length) { - /** - * @param {import('comment-parser').Spec} tg - * @returns {() => void} - */ - const fixer = tg => { - return () => { - // Due to https://github.com/syavorsky/comment-parser/issues/110 , - // we have to modify `jsdoc.source` rather than just modify tags - // directly - for (const [currIdx, { - tokens - }] of jsdoc.source.entries()) { - if (tokens.tag !== '@' + tg.tag) { - continue; - } - - // Cannot be `tokens.end`, as dropped off last tag, so safe to - // go on - let newIdx = currIdx; - const emptyLine = () => { - return { - number: 0, - source: '', - tokens: utils.seedTokens({ - delimiter: '*', - start: jsdoc.source[newIdx - 1].tokens.start - }) - }; - }; - let existingEmptyLines = 0; - while (true) { - var _jsdoc$source$newIdx; - const nextTokens = (_jsdoc$source$newIdx = jsdoc.source[++newIdx]) === null || _jsdoc$source$newIdx === void 0 ? void 0 : _jsdoc$source$newIdx.tokens; - - /* c8 ignore next 3 -- Guard */ - if (!nextTokens) { - return; - } - - // Should be no `nextTokens.end` to worry about since ignored - // if not followed by tag - - if (nextTokens.tag) { - // Haven't made it to last tag instance yet, so keep looking - if (nextTokens.tag === tokens.tag) { - existingEmptyLines = 0; - continue; - } - const lineDiff = linesBetween - existingEmptyLines; - if (lineDiff > 0) { - const lines = Array.from({ - length: lineDiff - }, () => { - return emptyLine(); - }); - jsdoc.source.splice(newIdx, 0, ...lines); - } else { - // lineDiff < 0 - jsdoc.source.splice(newIdx + lineDiff, -lineDiff); - } - break; - } - const empty = !nextTokens.type && !nextTokens.name && !nextTokens.description; - if (empty) { - existingEmptyLines++; - } else { - // Has content again, so reset empty line count - existingEmptyLines = 0; - } - } - break; - } - for (const [srcIdx, src] of jsdoc.source.entries()) { - src.number = srcIdx; - } - }; - }; - for (const [tg] of badLastTagsOfGroup) { - utils.reportJSDoc('Tag groups do not have the expected whitespace', tg, fixer(tg)); - } - return; - } - if (!reportIntraTagGroupSpacing) { - return; - } - for (const [tagIdx, tag] of jsdoc.tags.entries()) { - if (!jsdoc.tags[tagIdx + 1] || lastTagsOfGroup.includes(tag)) { - continue; - } - const ct = countTagEmptyLines(tag); - if (ct) { - // eslint-disable-next-line complexity -- Temporary - const fixer = () => { - let foundFirstTag = false; - - /** @type {string|undefined} */ - let currentTag; - for (const [currIdx, { - tokens: { - description, - name, - type, - end, - tag: tg - } - }] of jsdoc.source.entries()) { - if (tg) { - foundFirstTag = true; - currentTag = tg; - } - if (!foundFirstTag) { - continue; - } - if (currentTag && !tg && !type && !name && !description && !end) { - let nextIdx = currIdx; - let ignore = true; - // Even if a tag of the same name as the last tags in a group, - // could still be an earlier tag in that group - - // eslint-disable-next-line no-loop-func -- Safe - if (lastTagsOfGroup.some(lastTagOfGroup => { - return currentTag === '@' + lastTagOfGroup.tag; - })) { - while (true) { - var _jsdoc$source$nextIdx; - const nextTokens = (_jsdoc$source$nextIdx = jsdoc.source[++nextIdx]) === null || _jsdoc$source$nextIdx === void 0 ? void 0 : _jsdoc$source$nextIdx.tokens; - if (!nextTokens) { - break; - } - if (!nextTokens.tag) { - continue; - } - - // Followed by the same tag name, so not actually last in group, - // and of interest - if (nextTokens.tag === currentTag) { - ignore = false; - } - } - } else { - while (true) { - var _jsdoc$source$nextIdx2; - const nextTokens = (_jsdoc$source$nextIdx2 = jsdoc.source[++nextIdx]) === null || _jsdoc$source$nextIdx2 === void 0 ? void 0 : _jsdoc$source$nextIdx2.tokens; - if (!nextTokens || nextTokens.end) { - break; - } - - // Not the very last tag, so don't ignore - if (nextTokens.tag) { - ignore = false; - break; - } - } - } - if (!ignore) { - jsdoc.source.splice(currIdx, 1); - for (const [srcIdx, src] of jsdoc.source.entries()) { - src.number = srcIdx; - } - } - } - } - }; - utils.reportJSDoc('Intra-group tags have unexpected whitespace', tag, fixer); - } - } - return; - } - const firstLine = utils.getFirstLine(); - const fix = () => { - const itemsToMoveRange = [...Array.from({ - length: jsdoc.tags.length - ( /** @type {import('../iterateJsdoc.js').Integer} */ - firstChangedTagIndex) - }).keys()]; - const unchangedPriorTagDescriptions = jsdoc.tags.slice(0, firstChangedTagIndex).reduce((ct, { - source - }) => { - return ct + source.length - 1; - }, 0); - - // This offset includes not only the offset from where the first tag - // must begin, and the additional offset of where the first changed - // tag begins, but it must also account for prior descriptions - const initialOffset = /** @type {import('../iterateJsdoc.js').Integer} */firstLine + ( /** @type {import('../iterateJsdoc.js').Integer} */firstChangedTagIndex) + - // May be the first tag, so don't try finding a prior one if so - unchangedPriorTagDescriptions; - - // Use `firstChangedTagLine` for line number to begin reporting/splicing - for (const idx of itemsToMoveRange) { - utils.removeTag(idx + ( /** @type {import('../iterateJsdoc.js').Integer} */ - firstChangedTagIndex)); - } - const changedTags = sortedTags.slice(firstChangedTagIndex); - let extraTagCount = 0; - for (const idx of itemsToMoveRange) { - const changedTag = changedTags[idx]; - utils.addTag(changedTag.tag, extraTagCount + initialOffset + idx, { - ...changedTag.source[0].tokens, - // `comment-parser` puts the `end` within the `tags` section, so - // avoid adding another to jsdoc.source - end: '' - }); - for (const { - tokens - } of changedTag.source.slice(1)) { - if (!tokens.end) { - utils.addLine(extraTagCount + initialOffset + idx + 1, { - ...tokens, - end: '' - }); - extraTagCount++; - } - } - } - }; - utils.reportJSDoc(`Tags are not in the prescribed order: ${tagList.join(', ') || '(alphabetical)'}`, jsdoc.tags[( /** @type {import('../iterateJsdoc.js').Integer} */ - firstChangedTagIndex)], fix, true); -}, { - iterateAllJsdocs: true, - meta: { - docs: { - description: 'Sorts tags by a specified sequence according to tag name.', - url: 'https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/sort-tags.md#repos-sticky-header' - }, - fixable: 'code', - schema: [{ - additionalProperties: false, - properties: { - alphabetizeExtras: { - type: 'boolean' - }, - linesBetween: { - type: 'integer' - }, - reportIntraTagGroupSpacing: { - type: 'boolean' - }, - reportTagGroupSpacing: { - type: 'boolean' - }, - tagSequence: { - items: { - properties: { - tags: { - items: { - type: 'string' - }, - type: 'array' - } - }, - type: 'object' - }, - type: 'array' - } - }, - type: 'object' - }], - type: 'suggestion' - } -}); -module.exports = exports.default; -//# sourceMappingURL=sortTags.cjs.map \ No newline at end of file diff --git a/tools/eslint/node_modules/eslint-plugin-jsdoc/dist/rules/tagLines.cjs b/tools/eslint/node_modules/eslint-plugin-jsdoc/dist/rules/tagLines.cjs deleted file mode 100644 index 9d67f409144ab6..00000000000000 --- a/tools/eslint/node_modules/eslint-plugin-jsdoc/dist/rules/tagLines.cjs +++ /dev/null @@ -1,274 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.default = void 0; -var _iterateJsdoc = _interopRequireDefault(require("../iterateJsdoc.cjs")); -function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; } -var _default = exports.default = (0, _iterateJsdoc.default)(({ - context, - jsdoc, - utils -}) => { - const [alwaysNever = 'never', { - count = 1, - endLines = 0, - startLines = 0, - applyToEndTag = true, - tags = {} - } = {}] = context.options; - - // eslint-disable-next-line complexity -- Temporary - jsdoc.tags.some((tg, tagIdx) => { - let lastTag; - - /** - * @type {null|import('../iterateJsdoc.js').Integer} - */ - let lastEmpty = null; - - /** - * @type {null|import('../iterateJsdoc.js').Integer} - */ - let reportIndex = null; - let emptyLinesCount = 0; - for (const [idx, { - tokens: { - tag, - name, - type, - description, - end - } - }] of tg.source.entries()) { - var _tags$lastTag$slice, _tags$lastTag$slice2; - // May be text after a line break within a tag description - if (description) { - reportIndex = null; - } - if (lastTag && ['any', 'always'].includes((_tags$lastTag$slice = tags[lastTag.slice(1)]) === null || _tags$lastTag$slice === void 0 ? void 0 : _tags$lastTag$slice.lines)) { - continue; - } - const empty = !tag && !name && !type && !description; - if (empty && !end && (alwaysNever === 'never' || lastTag && ((_tags$lastTag$slice2 = tags[lastTag.slice(1)]) === null || _tags$lastTag$slice2 === void 0 ? void 0 : _tags$lastTag$slice2.lines) === 'never')) { - reportIndex = idx; - continue; - } - if (!end) { - if (empty) { - emptyLinesCount++; - } else { - emptyLinesCount = 0; - } - lastEmpty = empty ? idx : null; - } - lastTag = tag; - } - if (typeof endLines === 'number' && lastEmpty !== null && tagIdx === jsdoc.tags.length - 1) { - const lineDiff = endLines - emptyLinesCount; - if (lineDiff < 0) { - const fixer = () => { - utils.removeTag(tagIdx, { - tagSourceOffset: /** @type {import('../iterateJsdoc.js').Integer} */lastEmpty + lineDiff + 1 - }); - }; - utils.reportJSDoc(`Expected ${endLines} trailing lines`, { - line: tg.source[lastEmpty].number + lineDiff + 1 - }, fixer); - } else if (lineDiff > 0) { - const fixer = () => { - utils.addLines(tagIdx, /** @type {import('../iterateJsdoc.js').Integer} */lastEmpty, endLines - emptyLinesCount); - }; - utils.reportJSDoc(`Expected ${endLines} trailing lines`, { - line: tg.source[lastEmpty].number - }, fixer); - } - return true; - } - if (reportIndex !== null) { - const fixer = () => { - utils.removeTag(tagIdx, { - tagSourceOffset: ( /** @type {import('../iterateJsdoc.js').Integer} */ - reportIndex) - }); - }; - utils.reportJSDoc('Expected no lines between tags', { - line: tg.source[0].number + 1 - }, fixer); - return true; - } - return false; - }); - (applyToEndTag ? jsdoc.tags : jsdoc.tags.slice(0, -1)).some((tg, tagIdx) => { - /** - * @type {{ - * idx: import('../iterateJsdoc.js').Integer, - * number: import('../iterateJsdoc.js').Integer - * }[]} - */ - const lines = []; - let currentTag; - let tagSourceIdx = 0; - for (const [idx, { - number, - tokens: { - tag, - name, - type, - description, - end - } - }] of tg.source.entries()) { - if (description) { - lines.splice(0, lines.length); - tagSourceIdx = idx; - } - if (tag) { - currentTag = tag; - } - if (!tag && !name && !type && !description && !end) { - lines.push({ - idx, - number - }); - } - } - const currentTg = currentTag && tags[currentTag.slice(1)]; - const tagCount = currentTg === null || currentTg === void 0 ? void 0 : currentTg.count; - const defaultAlways = alwaysNever === 'always' && (currentTg === null || currentTg === void 0 ? void 0 : currentTg.lines) !== 'never' && (currentTg === null || currentTg === void 0 ? void 0 : currentTg.lines) !== 'any' && lines.length < count; - let overrideAlways; - let fixCount = count; - if (!defaultAlways) { - fixCount = typeof tagCount === 'number' ? tagCount : count; - overrideAlways = (currentTg === null || currentTg === void 0 ? void 0 : currentTg.lines) === 'always' && lines.length < fixCount; - } - if (defaultAlways || overrideAlways) { - var _lines2; - const fixer = () => { - var _lines; - utils.addLines(tagIdx, ((_lines = lines[lines.length - 1]) === null || _lines === void 0 ? void 0 : _lines.idx) || tagSourceIdx + 1, fixCount - lines.length); - }; - const line = ((_lines2 = lines[lines.length - 1]) === null || _lines2 === void 0 ? void 0 : _lines2.number) || tg.source[tagSourceIdx].number; - utils.reportJSDoc(`Expected ${fixCount} line${fixCount === 1 ? '' : 's'} between tags but found ${lines.length}`, { - line - }, fixer); - return true; - } - return false; - }); - if (typeof startLines === 'number') { - var _description$match; - if (!jsdoc.tags.length) { - return; - } - const { - description, - lastDescriptionLine - } = utils.getDescription(); - if (!/\S/u.test(description)) { - return; - } - const trailingLines = (_description$match = description.match(/\n+$/u)) === null || _description$match === void 0 || (_description$match = _description$match[0]) === null || _description$match === void 0 ? void 0 : _description$match.length; - const trailingDiff = (trailingLines ?? 0) - startLines; - if (trailingDiff > 0) { - utils.reportJSDoc(`Expected only ${startLines} line after block description`, { - line: lastDescriptionLine - trailingDiff - }, () => { - utils.setBlockDescription((info, seedTokens, descLines) => { - return descLines.slice(0, -trailingDiff).map(desc => { - return { - number: 0, - source: '', - tokens: seedTokens({ - ...info, - description: desc, - postDelimiter: desc.trim() ? info.postDelimiter : '' - }) - }; - }); - }); - }); - } else if (trailingDiff < 0) { - utils.reportJSDoc(`Expected ${startLines} lines after block description`, { - line: lastDescriptionLine - }, () => { - utils.setBlockDescription((info, seedTokens, descLines) => { - return [...descLines, ...Array.from({ - length: -trailingDiff - }, () => { - return ''; - })].map(desc => { - return { - number: 0, - source: '', - tokens: seedTokens({ - ...info, - description: desc, - postDelimiter: desc.trim() ? info.postDelimiter : '' - }) - }; - }); - }); - }); - } - } -}, { - iterateAllJsdocs: true, - meta: { - docs: { - description: 'Enforces lines (or no lines) between tags.', - url: 'https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/tag-lines.md#repos-sticky-header' - }, - fixable: 'code', - schema: [{ - enum: ['always', 'any', 'never'], - type: 'string' - }, { - additionalProperties: false, - properties: { - applyToEndTag: { - type: 'boolean' - }, - count: { - type: 'integer' - }, - endLines: { - anyOf: [{ - type: 'integer' - }, { - type: 'null' - }] - }, - startLines: { - anyOf: [{ - type: 'integer' - }, { - type: 'null' - }] - }, - tags: { - patternProperties: { - '.*': { - additionalProperties: false, - properties: { - count: { - type: 'integer' - }, - lines: { - enum: ['always', 'never', 'any'], - type: 'string' - } - } - } - }, - type: 'object' - } - }, - type: 'object' - }], - type: 'suggestion' - } -}); -module.exports = exports.default; -//# sourceMappingURL=tagLines.cjs.map \ No newline at end of file diff --git a/tools/eslint/node_modules/eslint-plugin-jsdoc/dist/rules/textEscaping.cjs b/tools/eslint/node_modules/eslint-plugin-jsdoc/dist/rules/textEscaping.cjs deleted file mode 100644 index 8e64f0fd0f9a94..00000000000000 --- a/tools/eslint/node_modules/eslint-plugin-jsdoc/dist/rules/textEscaping.cjs +++ /dev/null @@ -1,131 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.default = void 0; -var _iterateJsdoc = _interopRequireDefault(require("../iterateJsdoc.cjs")); -function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; } -// We could disallow raw gt, quot, and apos, but allow for parity; but we do -// not allow hex or decimal character references -const htmlRegex = /(<|&(?!(?:amp|lt|gt|quot|apos);))(?=\S)/u; -const markdownRegex = /(? { - return desc.replaceAll(new RegExp(htmlRegex, 'gu'), _ => { - if (_ === '<') { - return '<'; - } - return '&'; - }); -}; - -/** - * @param {string} desc - * @returns {string} - */ -const markdownReplacer = desc => { - return desc.replaceAll(new RegExp(markdownRegex, 'gu'), (_, backticks, encapsed) => { - const bookend = '`'.repeat(backticks.length); - return `\\${bookend}${encapsed}${bookend}`; - }); -}; -var _default = exports.default = (0, _iterateJsdoc.default)(({ - context, - jsdoc, - utils -}) => { - const { - escapeHTML, - escapeMarkdown - } = context.options[0] || {}; - if (!escapeHTML && !escapeMarkdown) { - context.report({ - loc: { - end: { - column: 1, - line: 1 - }, - start: { - column: 1, - line: 1 - } - }, - message: 'You must include either `escapeHTML` or `escapeMarkdown`' - }); - return; - } - const { - descriptions - } = utils.getDescription(); - if (escapeHTML) { - if (descriptions.some(desc => { - return htmlRegex.test(desc); - })) { - const line = utils.setDescriptionLines(htmlRegex, htmlReplacer); - utils.reportJSDoc('You have unescaped HTML characters < or &', { - line - }, () => {}, true); - return; - } - for (const tag of jsdoc.tags) { - if ( /** @type {string[]} */utils.getTagDescription(tag, true).some(desc => { - return htmlRegex.test(desc); - })) { - const line = utils.setTagDescription(tag, htmlRegex, htmlReplacer) + tag.source[0].number; - utils.reportJSDoc('You have unescaped HTML characters < or & in a tag', { - line - }, () => {}, true); - } - } - return; - } - if (descriptions.some(desc => { - return markdownRegex.test(desc); - })) { - const line = utils.setDescriptionLines(markdownRegex, markdownReplacer); - utils.reportJSDoc('You have unescaped Markdown backtick sequences', { - line - }, () => {}, true); - return; - } - for (const tag of jsdoc.tags) { - if ( /** @type {string[]} */utils.getTagDescription(tag, true).some(desc => { - return markdownRegex.test(desc); - })) { - const line = utils.setTagDescription(tag, markdownRegex, markdownReplacer) + tag.source[0].number; - utils.reportJSDoc('You have unescaped Markdown backtick sequences in a tag', { - line - }, () => {}, true); - } - } -}, { - iterateAllJsdocs: true, - meta: { - docs: { - description: '', - url: 'https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/text-escaping.md#repos-sticky-header' - }, - fixable: 'code', - schema: [{ - additionalProperties: false, - properties: { - // Option properties here (or remove the object) - escapeHTML: { - type: 'boolean' - }, - escapeMarkdown: { - type: 'boolean' - } - }, - type: 'object' - }], - type: 'suggestion' - } -}); -module.exports = exports.default; -//# sourceMappingURL=textEscaping.cjs.map \ No newline at end of file diff --git a/tools/eslint/node_modules/eslint-plugin-jsdoc/dist/rules/validTypes.cjs b/tools/eslint/node_modules/eslint-plugin-jsdoc/dist/rules/validTypes.cjs deleted file mode 100644 index 04b6f5d6cca6d0..00000000000000 --- a/tools/eslint/node_modules/eslint-plugin-jsdoc/dist/rules/validTypes.cjs +++ /dev/null @@ -1,264 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.default = void 0; -var _iterateJsdoc = _interopRequireDefault(require("../iterateJsdoc.cjs")); -var _jsdoccomment = require("@es-joy/jsdoccomment"); -function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; } -const inlineTags = new Set(['link', 'linkcode', 'linkplain', 'tutorial']); -const jsdocTypePrattKeywords = new Set(['typeof', 'readonly', 'import', 'is']); -const asExpression = /as\s+/u; -const suppressTypes = new Set([ -// https://github.com/google/closure-compiler/wiki/@suppress-annotations -// https://github.com/google/closure-compiler/blob/master/src/com/google/javascript/jscomp/parsing/ParserConfig.properties#L154 -'accessControls', 'checkDebuggerStatement', 'checkPrototypalTypes', 'checkRegExp', 'checkTypes', 'checkVars', 'closureDepMethodUsageChecks', 'const', 'constantProperty', 'deprecated', 'duplicate', 'es5Strict', 'externsValidation', 'extraProvide', 'extraRequire', 'globalThis', 'invalidCasts', 'lateProvide', 'legacyGoogScopeRequire', 'lintChecks', 'messageConventions', 'misplacedTypeAnnotation', 'missingOverride', 'missingPolyfill', 'missingProperties', 'missingProvide', 'missingRequire', 'missingSourcesWarnings', 'moduleLoad', 'nonStandardJsDocs', 'partialAlias', 'polymer', 'reportUnknownTypes', 'strictMissingProperties', 'strictModuleDepCheck', 'strictPrimitiveOperators', 'suspiciousCode', -// Not documented in enum -'switch', 'transitionalSuspiciousCodeWarnings', 'undefinedNames', 'undefinedVars', 'underscore', 'unknownDefines', 'untranspilableFeatures', 'unusedLocalVariables', 'unusedPrivateMembers', 'useOfGoogProvide', 'uselessCode', 'visibility', 'with']); - -/** - * @param {string} path - * @returns {boolean} - */ -const tryParsePathIgnoreError = path => { - try { - (0, _jsdoccomment.tryParse)(path); - return true; - } catch { - // Keep the original error for including the whole type - } - return false; -}; - -// eslint-disable-next-line complexity -var _default = exports.default = (0, _iterateJsdoc.default)(({ - jsdoc, - report, - utils, - context, - settings -}) => { - const { - allowEmptyNamepaths = false - } = context.options[0] || {}; - const { - mode - } = settings; - for (const tag of jsdoc.tags) { - /** - * @param {string} namepath - * @param {string} [tagName] - * @returns {boolean} - */ - const validNamepathParsing = function (namepath, tagName) { - if (tryParsePathIgnoreError(namepath) || jsdocTypePrattKeywords.has(namepath)) { - return true; - } - let handled = false; - if (tagName) { - switch (tagName) { - case 'requires': - case 'module': - { - if (!namepath.startsWith('module:')) { - handled = tryParsePathIgnoreError(`module:${namepath}`); - } - break; - } - case 'memberof': - case 'memberof!': - { - const endChar = namepath.slice(-1); - if (['#', '.', '~'].includes(endChar)) { - handled = tryParsePathIgnoreError(namepath.slice(0, -1)); - } - break; - } - case 'borrows': - { - const startChar = namepath.charAt(0); - if (['#', '.', '~'].includes(startChar)) { - handled = tryParsePathIgnoreError(namepath.slice(1)); - } - } - } - } - if (!handled) { - report(`Syntax error in namepath: ${namepath}`, null, tag); - return false; - } - return true; - }; - - /** - * @param {string} type - * @returns {boolean} - */ - const validTypeParsing = function (type) { - let parsedTypes; - try { - if (mode === 'permissive') { - parsedTypes = (0, _jsdoccomment.tryParse)(type); - } else { - parsedTypes = (0, _jsdoccomment.parse)(type, mode); - } - } catch { - report(`Syntax error in type: ${type}`, null, tag); - return false; - } - if (mode === 'closure' || mode === 'typescript') { - (0, _jsdoccomment.traverse)(parsedTypes, node => { - var _node$right, _node$right2; - const { - type: typ - } = node; - if ((typ === 'JsdocTypeObjectField' || typ === 'JsdocTypeKeyValue') && ((_node$right = node.right) === null || _node$right === void 0 ? void 0 : _node$right.type) === 'JsdocTypeNullable' && ((_node$right2 = node.right) === null || _node$right2 === void 0 || (_node$right2 = _node$right2.meta) === null || _node$right2 === void 0 ? void 0 : _node$right2.position) === 'suffix') { - report(`Syntax error in type: ${node.right.type}`, null, tag); - } - }); - } - return true; - }; - if (tag.problems.length) { - const msg = tag.problems.reduce((str, { - message - }) => { - return str + '; ' + message; - }, '').slice(2); - report(`Invalid name: ${msg}`, null, tag); - continue; - } - if (tag.tag === 'import') { - // A named import will look like a type, but not be valid; we also don't - // need to check the name/namepath - continue; - } - if (tag.tag === 'borrows') { - const thisNamepath = /** @type {string} */utils.getTagDescription(tag).replace(asExpression, '').trim(); - if (!asExpression.test( /** @type {string} */ - utils.getTagDescription(tag)) || !thisNamepath) { - report(`@borrows must have an "as" expression. Found "${utils.getTagDescription(tag)}"`, null, tag); - continue; - } - if (validNamepathParsing(thisNamepath, 'borrows')) { - const thatNamepath = tag.name; - validNamepathParsing(thatNamepath); - } - continue; - } - if (tag.tag === 'suppress' && mode === 'closure') { - let parsedTypes; - try { - parsedTypes = (0, _jsdoccomment.tryParse)(tag.type); - } catch { - // Ignore - } - if (parsedTypes) { - (0, _jsdoccomment.traverse)(parsedTypes, node => { - let type; - if ('value' in node && typeof node.value === 'string') { - type = node.value; - } - if (type !== undefined && !suppressTypes.has(type)) { - report(`Syntax error in suppress type: ${type}`, null, tag); - } - }); - } - } - const otherModeMaps = /** @type {import('../jsdocUtils.js').ParserMode[]} */['jsdoc', 'typescript', 'closure', 'permissive'].filter(mde => { - return mde !== mode; - }).map(mde => { - return utils.getTagStructureForMode(mde); - }); - const tagMightHaveNamePosition = utils.tagMightHaveNamePosition(tag.tag, otherModeMaps); - if (tagMightHaveNamePosition !== true && tag.name) { - const modeInfo = tagMightHaveNamePosition === false ? '' : ` in "${mode}" mode`; - report(`@${tag.tag} should not have a name${modeInfo}.`, null, tag); - continue; - } - const mightHaveTypePosition = utils.tagMightHaveTypePosition(tag.tag, otherModeMaps); - if (mightHaveTypePosition !== true && tag.type) { - const modeInfo = mightHaveTypePosition === false ? '' : ` in "${mode}" mode`; - report(`@${tag.tag} should not have a bracketed type${modeInfo}.`, null, tag); - continue; - } - - // REQUIRED NAME - const tagMustHaveNamePosition = utils.tagMustHaveNamePosition(tag.tag, otherModeMaps); - - // Don't handle `@param` here though it does require name as handled by - // `require-param-name` (`@property` would similarly seem to require one, - // but is handled by `require-property-name`) - if (tagMustHaveNamePosition !== false && !tag.name && !allowEmptyNamepaths && !['param', 'arg', 'argument', 'property', 'prop'].includes(tag.tag) && (tag.tag !== 'see' || !utils.getTagDescription(tag).includes('{@link'))) { - const modeInfo = tagMustHaveNamePosition === true ? '' : ` in "${mode}" mode`; - report(`Tag @${tag.tag} must have a name/namepath${modeInfo}.`, null, tag); - continue; - } - - // REQUIRED TYPE - const mustHaveTypePosition = utils.tagMustHaveTypePosition(tag.tag, otherModeMaps); - if (mustHaveTypePosition !== false && !tag.type) { - const modeInfo = mustHaveTypePosition === true ? '' : ` in "${mode}" mode`; - report(`Tag @${tag.tag} must have a type${modeInfo}.`, null, tag); - continue; - } - - // REQUIRED TYPE OR NAME/NAMEPATH - const tagMissingRequiredTypeOrNamepath = utils.tagMissingRequiredTypeOrNamepath(tag, otherModeMaps); - if (tagMissingRequiredTypeOrNamepath !== false && !allowEmptyNamepaths) { - const modeInfo = tagMissingRequiredTypeOrNamepath === true ? '' : ` in "${mode}" mode`; - report(`Tag @${tag.tag} must have either a type or namepath${modeInfo}.`, null, tag); - continue; - } - - // VALID TYPE - const hasTypePosition = mightHaveTypePosition === true && Boolean(tag.type); - if (hasTypePosition) { - validTypeParsing(tag.type); - } - - // VALID NAME/NAMEPATH - const hasNameOrNamepathPosition = (tagMustHaveNamePosition !== false || utils.tagMightHaveNamepath(tag.tag)) && Boolean(tag.name); - if (hasNameOrNamepathPosition) { - if (mode !== 'jsdoc' && tag.tag === 'template') { - for (const namepath of utils.parseClosureTemplateTag(tag)) { - validNamepathParsing(namepath); - } - } else { - validNamepathParsing(tag.name, tag.tag); - } - } - for (const inlineTag of tag.inlineTags) { - if (inlineTags.has(inlineTag.tag) && !inlineTag.text && !inlineTag.namepathOrURL) { - report(`Inline tag "${inlineTag.tag}" missing content`, null, tag); - } - } - } - for (const inlineTag of jsdoc.inlineTags) { - if (inlineTags.has(inlineTag.tag) && !inlineTag.text && !inlineTag.namepathOrURL) { - report(`Inline tag "${inlineTag.tag}" missing content`); - } - } -}, { - iterateAllJsdocs: true, - meta: { - docs: { - description: 'Requires all types to be valid JSDoc or Closure compiler types without syntax errors.', - url: 'https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/valid-types.md#repos-sticky-header' - }, - schema: [{ - additionalProperties: false, - properties: { - allowEmptyNamepaths: { - default: false, - type: 'boolean' - } - }, - type: 'object' - }], - type: 'suggestion' - } -}); -module.exports = exports.default; -//# sourceMappingURL=validTypes.cjs.map \ No newline at end of file diff --git a/tools/eslint/node_modules/eslint-plugin-jsdoc/dist/tagNames.cjs b/tools/eslint/node_modules/eslint-plugin-jsdoc/dist/tagNames.cjs deleted file mode 100644 index da9750680312be..00000000000000 --- a/tools/eslint/node_modules/eslint-plugin-jsdoc/dist/tagNames.cjs +++ /dev/null @@ -1,183 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.typeScriptTags = exports.jsdocTags = exports.closureTags = void 0; -/** - * @typedef {{ - * [key: string]: string[] - * }} AliasedTags - */ - -/** - * @type {AliasedTags} - */ -const jsdocTagsUndocumented = { - // Undocumented but present; see - // https://github.com/jsdoc/jsdoc/issues/1283#issuecomment-516816802 - // https://github.com/jsdoc/jsdoc/blob/master/packages/jsdoc/lib/jsdoc/tag/dictionary/definitions.js#L594 - modifies: [] -}; - -/** - * @type {AliasedTags} - */ -const jsdocTags = exports.jsdocTags = { - ...jsdocTagsUndocumented, - abstract: ['virtual'], - access: [], - alias: [], - async: [], - augments: ['extends'], - author: [], - borrows: [], - callback: [], - class: ['constructor'], - classdesc: [], - constant: ['const'], - constructs: [], - copyright: [], - default: ['defaultvalue'], - deprecated: [], - description: ['desc'], - enum: [], - event: [], - example: [], - exports: [], - external: ['host'], - file: ['fileoverview', 'overview'], - fires: ['emits'], - function: ['func', 'method'], - generator: [], - global: [], - hideconstructor: [], - ignore: [], - implements: [], - inheritdoc: [], - // Allowing casing distinct from jsdoc `definitions.js` (required in Closure) - inheritDoc: [], - inner: [], - instance: [], - interface: [], - kind: [], - lends: [], - license: [], - listens: [], - member: ['var'], - memberof: [], - 'memberof!': [], - mixes: [], - mixin: [], - module: [], - name: [], - namespace: [], - override: [], - package: [], - param: ['arg', 'argument'], - private: [], - property: ['prop'], - protected: [], - public: [], - readonly: [], - requires: [], - returns: ['return'], - see: [], - since: [], - static: [], - summary: [], - this: [], - throws: ['exception'], - todo: [], - tutorial: [], - type: [], - typedef: [], - variation: [], - version: [], - yields: ['yield'] -}; - -/** - * @type {AliasedTags} - */ -const typeScriptTags = exports.typeScriptTags = { - ...jsdocTags, - // https://github.com/microsoft/TypeScript/issues/22160 - // https://devblogs.microsoft.com/typescript/announcing-typescript-5-5/#the-jsdoc-import-tag - import: [], - // https://www.typescriptlang.org/tsconfig/#stripInternal - internal: [], - // https://devblogs.microsoft.com/typescript/announcing-typescript-5-0/#overload-support-in-jsdoc - overload: [], - // https://devblogs.microsoft.com/typescript/announcing-typescript-5-0/#satisfies-support-in-jsdoc - satisfies: [], - // `@template` is also in TypeScript per: - // https://www.typescriptlang.org/docs/handbook/type-checking-javascript-files.html#supported-jsdoc - template: [] -}; - -/** - * @type {AliasedTags} - */ -const undocumentedClosureTags = { - // These are in Closure source but not in jsdoc source nor in the Closure - // docs: https://github.com/google/closure-compiler/blob/master/src/com/google/javascript/jscomp/parsing/Annotation.java - closurePrimitive: [], - customElement: [], - expose: [], - hidden: [], - idGenerator: [], - meaning: [], - mixinClass: [], - mixinFunction: [], - ngInject: [], - owner: [], - typeSummary: [], - wizaction: [] -}; -const { - /* eslint-disable no-unused-vars */ - inheritdoc, - internal, - overload, - satisfies, - // Will be inverted to prefer `return` - returns, - /* eslint-enable no-unused-vars */ - ...typeScriptTagsInClosure -} = typeScriptTags; - -/** - * @type {AliasedTags} - */ -const closureTags = exports.closureTags = { - ...typeScriptTagsInClosure, - ...undocumentedClosureTags, - // From https://github.com/google/closure-compiler/wiki/Annotating-JavaScript-for-the-Closure-Compiler - // These are all recognized in https://github.com/jsdoc/jsdoc/blob/master/packages/jsdoc/lib/jsdoc/tag/dictionary/definitions.js - // except for the experimental `noinline` and the casing differences noted below - - // Defined as a synonym of `const` in jsdoc `definitions.js` - define: [], - dict: [], - export: [], - externs: [], - final: [], - // With casing distinct from jsdoc `definitions.js` - implicitCast: [], - noalias: [], - nocollapse: [], - nocompile: [], - noinline: [], - nosideeffects: [], - polymer: [], - polymerBehavior: [], - preserve: [], - // Defined as a synonym of `interface` in jsdoc `definitions.js` - record: [], - return: ['returns'], - struct: [], - suppress: [], - unrestricted: [] -}; -//# sourceMappingURL=tagNames.cjs.map \ No newline at end of file diff --git a/tools/eslint/node_modules/eslint-plugin-jsdoc/dist/utils/hasReturnValue.cjs b/tools/eslint/node_modules/eslint-plugin-jsdoc/dist/utils/hasReturnValue.cjs deleted file mode 100644 index 0ce5a49d5e9612..00000000000000 --- a/tools/eslint/node_modules/eslint-plugin-jsdoc/dist/utils/hasReturnValue.cjs +++ /dev/null @@ -1,492 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.hasValueOrExecutorHasNonEmptyResolveValue = exports.hasReturnValue = void 0; -/** - * @typedef {import('estree').Node| - * import('@typescript-eslint/types').TSESTree.Node} ESTreeOrTypeScriptNode - */ - -/** - * Checks if a node is a promise but has no resolve value or an empty value. - * An `undefined` resolve does not count. - * @param {ESTreeOrTypeScriptNode|undefined|null} node - * @returns {boolean|undefined|null} - */ -const isNewPromiseExpression = node => { - return node && node.type === 'NewExpression' && node.callee.type === 'Identifier' && node.callee.name === 'Promise'; -}; - -/** - * @param {ESTreeOrTypeScriptNode|null|undefined} node - * @returns {boolean} - */ -const isVoidPromise = node => { - var _node$typeArguments, _node$typeParameters; - return /** @type {import('@typescript-eslint/types').TSESTree.TSTypeReference} */(node === null || node === void 0 || (_node$typeArguments = node.typeArguments) === null || _node$typeArguments === void 0 || (_node$typeArguments = _node$typeArguments.params) === null || _node$typeArguments === void 0 || (_node$typeArguments = _node$typeArguments[0]) === null || _node$typeArguments === void 0 ? void 0 : _node$typeArguments.type) === 'TSVoidKeyword' - /* c8 ignore next */ || /** @type {import('@typescript-eslint/types').TSESTree.TSTypeReference} */(node === null || node === void 0 || (_node$typeParameters = node.typeParameters) === null || _node$typeParameters === void 0 || (_node$typeParameters = _node$typeParameters.params) === null || _node$typeParameters === void 0 || (_node$typeParameters = _node$typeParameters[0]) === null || _node$typeParameters === void 0 ? void 0 : _node$typeParameters.type) === 'TSVoidKeyword'; -}; -const undefinedKeywords = new Set(['TSVoidKeyword', 'TSUndefinedKeyword', 'TSNeverKeyword']); - -/** - * Checks if a node has a return statement. Void return does not count. - * @param {ESTreeOrTypeScriptNode|undefined|null} node - * @param {boolean} [throwOnNullReturn] - * @param {PromiseFilter} [promFilter] - * @returns {boolean|undefined} - */ -// eslint-disable-next-line complexity -const hasReturnValue = (node, throwOnNullReturn, promFilter) => { - if (!node) { - return false; - } - switch (node.type) { - case 'TSDeclareFunction': - case 'TSFunctionType': - case 'TSMethodSignature': - { - var _node$returnType; - const type = node === null || node === void 0 || (_node$returnType = node.returnType) === null || _node$returnType === void 0 || (_node$returnType = _node$returnType.typeAnnotation) === null || _node$returnType === void 0 ? void 0 : _node$returnType.type; - return type && !undefinedKeywords.has(type); - } - case 'MethodDefinition': - return hasReturnValue(node.value, throwOnNullReturn, promFilter); - case 'FunctionExpression': - case 'FunctionDeclaration': - case 'ArrowFunctionExpression': - { - return 'expression' in node && node.expression && (!isNewPromiseExpression(node.body) || !isVoidPromise(node.body)) || hasReturnValue(node.body, throwOnNullReturn, promFilter); - } - case 'BlockStatement': - { - return node.body.some(bodyNode => { - return bodyNode.type !== 'FunctionDeclaration' && hasReturnValue(bodyNode, throwOnNullReturn, promFilter); - }); - } - case 'LabeledStatement': - case 'WhileStatement': - case 'DoWhileStatement': - case 'ForStatement': - case 'ForInStatement': - case 'ForOfStatement': - case 'WithStatement': - { - return hasReturnValue(node.body, throwOnNullReturn, promFilter); - } - case 'IfStatement': - { - return hasReturnValue(node.consequent, throwOnNullReturn, promFilter) || hasReturnValue(node.alternate, throwOnNullReturn, promFilter); - } - case 'TryStatement': - { - return hasReturnValue(node.block, throwOnNullReturn, promFilter) || hasReturnValue(node.handler && node.handler.body, throwOnNullReturn, promFilter) || hasReturnValue(node.finalizer, throwOnNullReturn, promFilter); - } - case 'SwitchStatement': - { - return node.cases.some(someCase => { - return someCase.consequent.some(nde => { - return hasReturnValue(nde, throwOnNullReturn, promFilter); - }); - }); - } - case 'ReturnStatement': - { - // void return does not count. - if (node.argument === null) { - if (throwOnNullReturn) { - throw new Error('Null return'); - } - return false; - } - if (promFilter && isNewPromiseExpression(node.argument)) { - // Let caller decide how to filter, but this is, at the least, - // a return of sorts and truthy - return promFilter(node.argument); - } - return true; - } - default: - { - return false; - } - } -}; - -/** - * Checks if a node has a return statement. Void return does not count. - * @param {ESTreeOrTypeScriptNode|null|undefined} node - * @param {PromiseFilter} promFilter - * @returns {undefined|boolean|ESTreeOrTypeScriptNode} - */ -// eslint-disable-next-line complexity -exports.hasReturnValue = hasReturnValue; -const allBrancheshaveReturnValues = (node, promFilter) => { - if (!node) { - return false; - } - switch (node.type) { - case 'TSDeclareFunction': - case 'TSFunctionType': - case 'TSMethodSignature': - { - var _node$returnType2; - const type = node === null || node === void 0 || (_node$returnType2 = node.returnType) === null || _node$returnType2 === void 0 || (_node$returnType2 = _node$returnType2.typeAnnotation) === null || _node$returnType2 === void 0 ? void 0 : _node$returnType2.type; - return type && !undefinedKeywords.has(type); - } - - // case 'MethodDefinition': - // return allBrancheshaveReturnValues(node.value, promFilter); - case 'FunctionExpression': - case 'FunctionDeclaration': - case 'ArrowFunctionExpression': - { - return 'expression' in node && node.expression && (!isNewPromiseExpression(node.body) || !isVoidPromise(node.body)) || allBrancheshaveReturnValues(node.body, promFilter) || /** @type {import('@typescript-eslint/types').TSESTree.BlockStatement} */ - node.body.body.some(nde => { - return nde.type === 'ReturnStatement'; - }); - } - case 'BlockStatement': - { - const lastBodyNode = node.body.slice(-1)[0]; - return allBrancheshaveReturnValues(lastBodyNode, promFilter); - } - case 'WhileStatement': - case 'DoWhileStatement': - if ( - /** - * @type {import('@typescript-eslint/types').TSESTree.Literal} - */ - node.test.value === true) { - // If this is an infinite loop, we assume only one branch - // is needed to provide a return - return hasReturnValue(node.body, false, promFilter); - } - - // Fallthrough - case 'LabeledStatement': - case 'ForStatement': - case 'ForInStatement': - case 'ForOfStatement': - case 'WithStatement': - { - return allBrancheshaveReturnValues(node.body, promFilter); - } - case 'IfStatement': - { - return allBrancheshaveReturnValues(node.consequent, promFilter) && allBrancheshaveReturnValues(node.alternate, promFilter); - } - case 'TryStatement': - { - // If `finally` returns, all return - return node.finalizer && allBrancheshaveReturnValues(node.finalizer, promFilter) || - // Return in `try`/`catch` may still occur despite `finally` - allBrancheshaveReturnValues(node.block, promFilter) && (!node.handler || allBrancheshaveReturnValues(node.handler && node.handler.body, promFilter)) && (!node.finalizer || (() => { - try { - hasReturnValue(node.finalizer, true, promFilter); - } catch (error) { - if ( /** @type {Error} */error.message === 'Null return') { - return false; - } - /* c8 ignore next 2 */ - throw error; - } - - // As long as not an explicit empty return, then return true - return true; - })()); - } - case 'SwitchStatement': - { - return /** @type {import('@typescript-eslint/types').TSESTree.SwitchStatement} */node.cases.every(someCase => { - return !someCase.consequent.some(consNode => { - return consNode.type === 'BreakStatement' || consNode.type === 'ReturnStatement' && consNode.argument === null; - }); - }); - } - case 'ThrowStatement': - { - return true; - } - case 'ReturnStatement': - { - // void return does not count. - if (node.argument === null) { - return false; - } - if (promFilter && isNewPromiseExpression(node.argument)) { - // Let caller decide how to filter, but this is, at the least, - // a return of sorts and truthy - return promFilter(node.argument); - } - return true; - } - default: - { - return false; - } - } -}; - -/** - * @callback PromiseFilter - * @param {ESTreeOrTypeScriptNode|undefined} node - * @returns {boolean} - */ - -/** - * Avoids further checking child nodes if a nested function shadows the - * resolver, but otherwise, if name is used (by call or passed in as an - * argument to another function), will be considered as non-empty. - * - * This could check for redeclaration of the resolver, but as such is - * unlikely, we avoid the performance cost of checking everywhere for - * (re)declarations or assignments. - * @param {import('@typescript-eslint/types').TSESTree.Node|null|undefined} node - * @param {string} resolverName - * @returns {boolean} - */ -// eslint-disable-next-line complexity -const hasNonEmptyResolverCall = (node, resolverName) => { - if (!node) { - return false; - } - - // Arrow function without block - switch (node.type) { - /* c8 ignore next 2 -- In Babel? */ - // @ts-expect-error Babel? - case 'OptionalCallExpression': - case 'CallExpression': - return /** @type {import('@typescript-eslint/types').TSESTree.Identifier} */node.callee.name === resolverName && ( - // Implicit or explicit undefined - node.arguments.length > 1 || node.arguments[0] !== undefined) || node.arguments.some(nde => { - // Being passed in to another function (which might invoke it) - return nde.type === 'Identifier' && nde.name === resolverName || - // Handle nested items - hasNonEmptyResolverCall(nde, resolverName); - }); - case 'ChainExpression': - case 'Decorator': - case 'ExpressionStatement': - return hasNonEmptyResolverCall(node.expression, resolverName); - case 'ClassBody': - case 'BlockStatement': - return node.body.some(bodyNode => { - return hasNonEmptyResolverCall(bodyNode, resolverName); - }); - case 'FunctionExpression': - case 'FunctionDeclaration': - case 'ArrowFunctionExpression': - { - var _node$params$; - // Shadowing - if ( /** @type {import('@typescript-eslint/types').TSESTree.Identifier} */((_node$params$ = node.params[0]) === null || _node$params$ === void 0 ? void 0 : _node$params$.name) === resolverName) { - return false; - } - return hasNonEmptyResolverCall(node.body, resolverName); - } - case 'LabeledStatement': - case 'WhileStatement': - case 'DoWhileStatement': - case 'ForStatement': - case 'ForInStatement': - case 'ForOfStatement': - case 'WithStatement': - { - return hasNonEmptyResolverCall(node.body, resolverName); - } - case 'ConditionalExpression': - case 'IfStatement': - { - return hasNonEmptyResolverCall(node.test, resolverName) || hasNonEmptyResolverCall(node.consequent, resolverName) || hasNonEmptyResolverCall(node.alternate, resolverName); - } - case 'TryStatement': - { - return hasNonEmptyResolverCall(node.block, resolverName) || hasNonEmptyResolverCall(node.handler && node.handler.body, resolverName) || hasNonEmptyResolverCall(node.finalizer, resolverName); - } - case 'SwitchStatement': - { - return node.cases.some(someCase => { - return someCase.consequent.some(nde => { - return hasNonEmptyResolverCall(nde, resolverName); - }); - }); - } - case 'ArrayPattern': - case 'ArrayExpression': - return node.elements.some(element => { - return hasNonEmptyResolverCall(element, resolverName); - }); - case 'AssignmentPattern': - return hasNonEmptyResolverCall(node.right, resolverName); - case 'AssignmentExpression': - case 'BinaryExpression': - case 'LogicalExpression': - { - return hasNonEmptyResolverCall(node.left, resolverName) || hasNonEmptyResolverCall(node.right, resolverName); - } - - // Comma - case 'SequenceExpression': - case 'TemplateLiteral': - return node.expressions.some(subExpression => { - return hasNonEmptyResolverCall(subExpression, resolverName); - }); - case 'ObjectPattern': - case 'ObjectExpression': - return node.properties.some(property => { - return hasNonEmptyResolverCall(property, resolverName); - }); - /* c8 ignore next 2 -- In Babel? */ - // @ts-expect-error Babel? - case 'ClassMethod': - case 'MethodDefinition': - return node.decorators && node.decorators.some(decorator => { - return hasNonEmptyResolverCall(decorator, resolverName); - }) || node.computed && hasNonEmptyResolverCall(node.key, resolverName) || hasNonEmptyResolverCall(node.value, resolverName); - - /* c8 ignore next 2 -- In Babel? */ - // @ts-expect-error Babel? - case 'ObjectProperty': - /* eslint-disable no-fallthrough */ - /* c8 ignore next -- In Babel? */ - case 'PropertyDefinition': - /* c8 ignore next 2 -- In Babel? */ - // @ts-expect-error Babel? - case 'ClassProperty': - case 'Property': - /* eslint-enable no-fallthrough */ - return node.computed && hasNonEmptyResolverCall(node.key, resolverName) || hasNonEmptyResolverCall(node.value, resolverName); - /* c8 ignore next 2 -- In Babel? */ - // @ts-expect-error Babel? - case 'ObjectMethod': - /* c8 ignore next 6 -- In Babel? */ - // @ts-expect-error - return node.computed && hasNonEmptyResolverCall(node.key, resolverName) || - // @ts-expect-error - node.arguments.some(nde => { - return hasNonEmptyResolverCall(nde, resolverName); - }); - case 'ClassExpression': - case 'ClassDeclaration': - return hasNonEmptyResolverCall(node.body, resolverName); - case 'AwaitExpression': - case 'SpreadElement': - case 'UnaryExpression': - case 'YieldExpression': - return hasNonEmptyResolverCall(node.argument, resolverName); - case 'VariableDeclaration': - { - return node.declarations.some(nde => { - return hasNonEmptyResolverCall(nde, resolverName); - }); - } - case 'VariableDeclarator': - { - return hasNonEmptyResolverCall(node.id, resolverName) || hasNonEmptyResolverCall(node.init, resolverName); - } - case 'TaggedTemplateExpression': - return hasNonEmptyResolverCall(node.quasi, resolverName); - - // ?. - /* c8 ignore next 2 -- In Babel? */ - // @ts-expect-error Babel? - case 'OptionalMemberExpression': - case 'MemberExpression': - return hasNonEmptyResolverCall(node.object, resolverName) || hasNonEmptyResolverCall(node.property, resolverName); - - /* c8 ignore next 2 -- In Babel? */ - // @ts-expect-error Babel? - case 'Import': - case 'ImportExpression': - return hasNonEmptyResolverCall(node.source, resolverName); - case 'ReturnStatement': - { - if (node.argument === null) { - return false; - } - return hasNonEmptyResolverCall(node.argument, resolverName); - } - - /* - // Shouldn't need to parse literals/literal components, etc. - case 'Identifier': - case 'TemplateElement': - case 'Super': - // Exports not relevant in this context - */ - default: - return false; - } -}; - -/** - * Checks if a Promise executor has no resolve value or an empty value. - * An `undefined` resolve does not count. - * @param {ESTreeOrTypeScriptNode} node - * @param {boolean} anyPromiseAsReturn - * @param {boolean} [allBranches] - * @returns {boolean} - */ -const hasValueOrExecutorHasNonEmptyResolveValue = (node, anyPromiseAsReturn, allBranches) => { - const hasReturnMethod = allBranches ? - /** - * @param {ESTreeOrTypeScriptNode} nde - * @param {PromiseFilter} promiseFilter - * @returns {boolean} - */ - (nde, promiseFilter) => { - let hasReturn; - try { - hasReturn = hasReturnValue(nde, true, promiseFilter); - } catch (error) { - // c8 ignore else - if ( /** @type {Error} */error.message === 'Null return') { - return false; - } - /* c8 ignore next 2 */ - throw error; - } - - // `hasReturn` check needed since `throw` treated as valid return by - // `allBrancheshaveReturnValues` - return Boolean(hasReturn && allBrancheshaveReturnValues(nde, promiseFilter)); - } : - /** - * @param {ESTreeOrTypeScriptNode} nde - * @param {PromiseFilter} promiseFilter - * @returns {boolean} - */ - (nde, promiseFilter) => { - return Boolean(hasReturnValue(nde, false, promiseFilter)); - }; - return hasReturnMethod(node, prom => { - if (anyPromiseAsReturn) { - return true; - } - if (isVoidPromise(prom)) { - return false; - } - const { - params, - body - } = - /** - * @type {import('@typescript-eslint/types').TSESTree.FunctionExpression| - * import('@typescript-eslint/types').TSESTree.ArrowFunctionExpression} - */ - ( /** @type {import('@typescript-eslint/types').TSESTree.NewExpression} */prom.arguments[0]) || {}; - if (!(params !== null && params !== void 0 && params.length)) { - return false; - } - const { - name: resolverName - } = /** @type {import('@typescript-eslint/types').TSESTree.Identifier} */ - params[0]; - return hasNonEmptyResolverCall(body, resolverName); - }); -}; -exports.hasValueOrExecutorHasNonEmptyResolveValue = hasValueOrExecutorHasNonEmptyResolveValue; -//# sourceMappingURL=hasReturnValue.cjs.map \ No newline at end of file diff --git a/tools/eslint/node_modules/eslint-plugin-jsdoc/eslint.config.js b/tools/eslint/node_modules/eslint-plugin-jsdoc/eslint.config.js deleted file mode 100644 index 0022392eabb1ad..00000000000000 --- a/tools/eslint/node_modules/eslint-plugin-jsdoc/eslint.config.js +++ /dev/null @@ -1,81 +0,0 @@ -import globals from 'globals'; -import jsdoc from './src/index.js'; -// import canonical from 'eslint-config-canonical'; -// import canonicalJsdoc from 'eslint-config-canonical/jsdoc.js'; - -const common = { - linterOptions: { - reportUnusedDisableDirectives: 'off' - }, - plugins: { - jsdoc - } -}; - -export default [ - // canonical, - // canonicalJsdoc, - { - // Must be by itself - ignores: ['dist/**/*.js', '.ignore/**/*.js'], - }, - { - ...common, - languageOptions: { - ecmaVersion: 'latest', - sourceType: 'module', - globals: globals.node - }, - settings: { - jsdoc: { - mode: 'typescript' - } - }, - rules: { - 'array-element-newline': 0, - 'filenames/match-regex': 0, - 'import/extensions': 0, - 'import/no-useless-path-segments': 0, - 'prefer-named-capture-group': 0, - 'unicorn/no-array-reduce': 0, - 'unicorn/no-unsafe-regex': 0, - 'unicorn/prefer-array-some': 0, - 'unicorn/prevent-abbreviations': 0, - 'unicorn/import-index': 0, - 'linebreak-style': 0, - 'no-inline-comments': 0, - 'no-extra-parens': 0 - } - }, - { - ...common, - files: ['.ncurc.cjs'], - languageOptions: { - parserOptions: { - ecmaFeatures: { - impliedStrict: false - }, - }, - sourceType: 'script' - }, - rules: { - 'import/no-commonjs': 0, - strict: [ - 'error', - 'global' - ] - } - }, - { - ...common, - files: ['test/**/*.js'], - languageOptions: { - ecmaVersion: 'latest', - sourceType: 'module' - }, - rules: { - 'no-restricted-syntax': 0, - 'unicorn/prevent-abbreviations': 0 - } - }, -]; diff --git a/tools/eslint/node_modules/eslint-plugin-jsdoc/node_modules/escape-string-regexp/index.js b/tools/eslint/node_modules/eslint-plugin-jsdoc/node_modules/escape-string-regexp/index.js deleted file mode 100644 index 387c5615a776b4..00000000000000 --- a/tools/eslint/node_modules/eslint-plugin-jsdoc/node_modules/escape-string-regexp/index.js +++ /dev/null @@ -1,13 +0,0 @@ -'use strict'; - -module.exports = string => { - if (typeof string !== 'string') { - throw new TypeError('Expected a string'); - } - - // Escape characters with special meaning either inside or outside character sets. - // Use a simple backslash escape when itโ€™s always valid, and a \unnnn escape when the simpler form would be disallowed by Unicode patternsโ€™ stricter grammar. - return string - .replace(/[|\\{}()[\]^$+*?.]/g, '\\$&') - .replace(/-/g, '\\x2d'); -}; diff --git a/tools/eslint/node_modules/eslint-plugin-jsdoc/node_modules/escape-string-regexp/license b/tools/eslint/node_modules/eslint-plugin-jsdoc/node_modules/escape-string-regexp/license deleted file mode 100644 index fa7ceba3eb4a96..00000000000000 --- a/tools/eslint/node_modules/eslint-plugin-jsdoc/node_modules/escape-string-regexp/license +++ /dev/null @@ -1,9 +0,0 @@ -MIT License - -Copyright (c) Sindre Sorhus (https://sindresorhus.com) - -Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/tools/eslint/node_modules/eslint-plugin-jsdoc/node_modules/escape-string-regexp/package.json b/tools/eslint/node_modules/eslint-plugin-jsdoc/node_modules/escape-string-regexp/package.json deleted file mode 100644 index c6eb4a91bc914b..00000000000000 --- a/tools/eslint/node_modules/eslint-plugin-jsdoc/node_modules/escape-string-regexp/package.json +++ /dev/null @@ -1,38 +0,0 @@ -{ - "name": "escape-string-regexp", - "version": "4.0.0", - "description": "Escape RegExp special characters", - "license": "MIT", - "repository": "sindresorhus/escape-string-regexp", - "funding": "https://github.com/sponsors/sindresorhus", - "author": { - "name": "Sindre Sorhus", - "email": "sindresorhus@gmail.com", - "url": "https://sindresorhus.com" - }, - "engines": { - "node": ">=10" - }, - "scripts": { - "test": "xo && ava && tsd" - }, - "files": [ - "index.js", - "index.d.ts" - ], - "keywords": [ - "escape", - "regex", - "regexp", - "regular", - "expression", - "string", - "special", - "characters" - ], - "devDependencies": { - "ava": "^1.4.1", - "tsd": "^0.11.0", - "xo": "^0.28.3" - } -} diff --git a/tools/eslint/node_modules/eslint-plugin-jsdoc/node_modules/escape-string-regexp/readme.md b/tools/eslint/node_modules/eslint-plugin-jsdoc/node_modules/escape-string-regexp/readme.md deleted file mode 100644 index 2945dfcb23ea11..00000000000000 --- a/tools/eslint/node_modules/eslint-plugin-jsdoc/node_modules/escape-string-regexp/readme.md +++ /dev/null @@ -1,34 +0,0 @@ -# escape-string-regexp [![Build Status](https://travis-ci.org/sindresorhus/escape-string-regexp.svg?branch=master)](https://travis-ci.org/sindresorhus/escape-string-regexp) - -> Escape RegExp special characters - -## Install - -``` -$ npm install escape-string-regexp -``` - -## Usage - -```js -const escapeStringRegexp = require('escape-string-regexp'); - -const escapedString = escapeStringRegexp('How much $ for a ๐Ÿฆ„?'); -//=> 'How much \\$ for a ๐Ÿฆ„\\?' - -new RegExp(escapedString); -``` - -You can also use this to escape a string that is inserted into the middle of a regex, for example, into a character class. - ---- - -
- - Get professional support for this package with a Tidelift subscription - -
- - Tidelift helps make open source sustainable for maintainers while giving companies
assurances about security, maintenance, and licensing for their dependencies. -
-
diff --git a/tools/eslint/node_modules/eslint-plugin-jsdoc/node_modules/semver/LICENSE b/tools/eslint/node_modules/eslint-plugin-jsdoc/node_modules/semver/LICENSE deleted file mode 100644 index 19129e315fe593..00000000000000 --- a/tools/eslint/node_modules/eslint-plugin-jsdoc/node_modules/semver/LICENSE +++ /dev/null @@ -1,15 +0,0 @@ -The ISC License - -Copyright (c) Isaac Z. Schlueter and Contributors - -Permission to use, copy, modify, and/or distribute this software for any -purpose with or without fee is hereby granted, provided that the above -copyright notice and this permission notice appear in all copies. - -THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR -IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. diff --git a/tools/eslint/node_modules/eslint-plugin-jsdoc/node_modules/semver/bin/semver.js b/tools/eslint/node_modules/eslint-plugin-jsdoc/node_modules/semver/bin/semver.js deleted file mode 100755 index f62b566f74bc63..00000000000000 --- a/tools/eslint/node_modules/eslint-plugin-jsdoc/node_modules/semver/bin/semver.js +++ /dev/null @@ -1,188 +0,0 @@ -#!/usr/bin/env node -// Standalone semver comparison program. -// Exits successfully and prints matching version(s) if -// any supplied version is valid and passes all tests. - -const argv = process.argv.slice(2) - -let versions = [] - -const range = [] - -let inc = null - -const version = require('../package.json').version - -let loose = false - -let includePrerelease = false - -let coerce = false - -let rtl = false - -let identifier - -let identifierBase - -const semver = require('../') -const parseOptions = require('../internal/parse-options') - -let reverse = false - -let options = {} - -const main = () => { - if (!argv.length) { - return help() - } - while (argv.length) { - let a = argv.shift() - const indexOfEqualSign = a.indexOf('=') - if (indexOfEqualSign !== -1) { - const value = a.slice(indexOfEqualSign + 1) - a = a.slice(0, indexOfEqualSign) - argv.unshift(value) - } - switch (a) { - case '-rv': case '-rev': case '--rev': case '--reverse': - reverse = true - break - case '-l': case '--loose': - loose = true - break - case '-p': case '--include-prerelease': - includePrerelease = true - break - case '-v': case '--version': - versions.push(argv.shift()) - break - case '-i': case '--inc': case '--increment': - switch (argv[0]) { - case 'major': case 'minor': case 'patch': case 'prerelease': - case 'premajor': case 'preminor': case 'prepatch': - inc = argv.shift() - break - default: - inc = 'patch' - break - } - break - case '--preid': - identifier = argv.shift() - break - case '-r': case '--range': - range.push(argv.shift()) - break - case '-n': - identifierBase = argv.shift() - if (identifierBase === 'false') { - identifierBase = false - } - break - case '-c': case '--coerce': - coerce = true - break - case '--rtl': - rtl = true - break - case '--ltr': - rtl = false - break - case '-h': case '--help': case '-?': - return help() - default: - versions.push(a) - break - } - } - - options = parseOptions({ loose, includePrerelease, rtl }) - - versions = versions.map((v) => { - return coerce ? (semver.coerce(v, options) || { version: v }).version : v - }).filter((v) => { - return semver.valid(v) - }) - if (!versions.length) { - return fail() - } - if (inc && (versions.length !== 1 || range.length)) { - return failInc() - } - - for (let i = 0, l = range.length; i < l; i++) { - versions = versions.filter((v) => { - return semver.satisfies(v, range[i], options) - }) - if (!versions.length) { - return fail() - } - } - versions - .sort((a, b) => semver[reverse ? 'rcompare' : 'compare'](a, b, options)) - .map(v => semver.clean(v, options)) - .map(v => inc ? semver.inc(v, inc, options, identifier, identifierBase) : v) - .forEach(v => console.log(v)) -} - -const failInc = () => { - console.error('--inc can only be used on a single version with no range') - fail() -} - -const fail = () => process.exit(1) - -const help = () => console.log( -`SemVer ${version} - -A JavaScript implementation of the https://semver.org/ specification -Copyright Isaac Z. Schlueter - -Usage: semver [options] [ [...]] -Prints valid versions sorted by SemVer precedence - -Options: --r --range - Print versions that match the specified range. - --i --increment [] - Increment a version by the specified level. Level can - be one of: major, minor, patch, premajor, preminor, - prepatch, or prerelease. Default level is 'patch'. - Only one version may be specified. - ---preid - Identifier to be used to prefix premajor, preminor, - prepatch or prerelease version increments. - --l --loose - Interpret versions and ranges loosely - --p --include-prerelease - Always include prerelease versions in range matching - --c --coerce - Coerce a string into SemVer if possible - (does not imply --loose) - ---rtl - Coerce version strings right to left - ---ltr - Coerce version strings left to right (default) - --n - Base number to be used for the prerelease identifier. - Can be either 0 or 1, or false to omit the number altogether. - Defaults to 0. - -Program exits successfully if any valid version satisfies -all supplied ranges, and prints all satisfying versions. - -If no satisfying versions are found, then exits failure. - -Versions are printed in ascending order, so supplying -multiple versions to the utility will just sort them.`) - -main() diff --git a/tools/eslint/node_modules/eslint-plugin-jsdoc/node_modules/semver/classes/comparator.js b/tools/eslint/node_modules/eslint-plugin-jsdoc/node_modules/semver/classes/comparator.js deleted file mode 100644 index 3d39c0eef78023..00000000000000 --- a/tools/eslint/node_modules/eslint-plugin-jsdoc/node_modules/semver/classes/comparator.js +++ /dev/null @@ -1,141 +0,0 @@ -const ANY = Symbol('SemVer ANY') -// hoisted class for cyclic dependency -class Comparator { - static get ANY () { - return ANY - } - - constructor (comp, options) { - options = parseOptions(options) - - if (comp instanceof Comparator) { - if (comp.loose === !!options.loose) { - return comp - } else { - comp = comp.value - } - } - - comp = comp.trim().split(/\s+/).join(' ') - debug('comparator', comp, options) - this.options = options - this.loose = !!options.loose - this.parse(comp) - - if (this.semver === ANY) { - this.value = '' - } else { - this.value = this.operator + this.semver.version - } - - debug('comp', this) - } - - parse (comp) { - const r = this.options.loose ? re[t.COMPARATORLOOSE] : re[t.COMPARATOR] - const m = comp.match(r) - - if (!m) { - throw new TypeError(`Invalid comparator: ${comp}`) - } - - this.operator = m[1] !== undefined ? m[1] : '' - if (this.operator === '=') { - this.operator = '' - } - - // if it literally is just '>' or '' then allow anything. - if (!m[2]) { - this.semver = ANY - } else { - this.semver = new SemVer(m[2], this.options.loose) - } - } - - toString () { - return this.value - } - - test (version) { - debug('Comparator.test', version, this.options.loose) - - if (this.semver === ANY || version === ANY) { - return true - } - - if (typeof version === 'string') { - try { - version = new SemVer(version, this.options) - } catch (er) { - return false - } - } - - return cmp(version, this.operator, this.semver, this.options) - } - - intersects (comp, options) { - if (!(comp instanceof Comparator)) { - throw new TypeError('a Comparator is required') - } - - if (this.operator === '') { - if (this.value === '') { - return true - } - return new Range(comp.value, options).test(this.value) - } else if (comp.operator === '') { - if (comp.value === '') { - return true - } - return new Range(this.value, options).test(comp.semver) - } - - options = parseOptions(options) - - // Special cases where nothing can possibly be lower - if (options.includePrerelease && - (this.value === '<0.0.0-0' || comp.value === '<0.0.0-0')) { - return false - } - if (!options.includePrerelease && - (this.value.startsWith('<0.0.0') || comp.value.startsWith('<0.0.0'))) { - return false - } - - // Same direction increasing (> or >=) - if (this.operator.startsWith('>') && comp.operator.startsWith('>')) { - return true - } - // Same direction decreasing (< or <=) - if (this.operator.startsWith('<') && comp.operator.startsWith('<')) { - return true - } - // same SemVer and both sides are inclusive (<= or >=) - if ( - (this.semver.version === comp.semver.version) && - this.operator.includes('=') && comp.operator.includes('=')) { - return true - } - // opposite directions less than - if (cmp(this.semver, '<', comp.semver, options) && - this.operator.startsWith('>') && comp.operator.startsWith('<')) { - return true - } - // opposite directions greater than - if (cmp(this.semver, '>', comp.semver, options) && - this.operator.startsWith('<') && comp.operator.startsWith('>')) { - return true - } - return false - } -} - -module.exports = Comparator - -const parseOptions = require('../internal/parse-options') -const { safeRe: re, t } = require('../internal/re') -const cmp = require('../functions/cmp') -const debug = require('../internal/debug') -const SemVer = require('./semver') -const Range = require('./range') diff --git a/tools/eslint/node_modules/eslint-plugin-jsdoc/node_modules/semver/classes/index.js b/tools/eslint/node_modules/eslint-plugin-jsdoc/node_modules/semver/classes/index.js deleted file mode 100644 index 5e3f5c9b19cef1..00000000000000 --- a/tools/eslint/node_modules/eslint-plugin-jsdoc/node_modules/semver/classes/index.js +++ /dev/null @@ -1,5 +0,0 @@ -module.exports = { - SemVer: require('./semver.js'), - Range: require('./range.js'), - Comparator: require('./comparator.js'), -} diff --git a/tools/eslint/node_modules/eslint-plugin-jsdoc/node_modules/semver/classes/range.js b/tools/eslint/node_modules/eslint-plugin-jsdoc/node_modules/semver/classes/range.js deleted file mode 100644 index 117b45a2b8e055..00000000000000 --- a/tools/eslint/node_modules/eslint-plugin-jsdoc/node_modules/semver/classes/range.js +++ /dev/null @@ -1,540 +0,0 @@ -// hoisted class for cyclic dependency -class Range { - constructor (range, options) { - options = parseOptions(options) - - if (range instanceof Range) { - if ( - range.loose === !!options.loose && - range.includePrerelease === !!options.includePrerelease - ) { - return range - } else { - return new Range(range.raw, options) - } - } - - if (range instanceof Comparator) { - // just put it in the set and return - this.raw = range.value - this.set = [[range]] - this.format() - return this - } - - this.options = options - this.loose = !!options.loose - this.includePrerelease = !!options.includePrerelease - - // First reduce all whitespace as much as possible so we do not have to rely - // on potentially slow regexes like \s*. This is then stored and used for - // future error messages as well. - this.raw = range - .trim() - .split(/\s+/) - .join(' ') - - // First, split on || - this.set = this.raw - .split('||') - // map the range to a 2d array of comparators - .map(r => this.parseRange(r.trim())) - // throw out any comparator lists that are empty - // this generally means that it was not a valid range, which is allowed - // in loose mode, but will still throw if the WHOLE range is invalid. - .filter(c => c.length) - - if (!this.set.length) { - throw new TypeError(`Invalid SemVer Range: ${this.raw}`) - } - - // if we have any that are not the null set, throw out null sets. - if (this.set.length > 1) { - // keep the first one, in case they're all null sets - const first = this.set[0] - this.set = this.set.filter(c => !isNullSet(c[0])) - if (this.set.length === 0) { - this.set = [first] - } else if (this.set.length > 1) { - // if we have any that are *, then the range is just * - for (const c of this.set) { - if (c.length === 1 && isAny(c[0])) { - this.set = [c] - break - } - } - } - } - - this.format() - } - - format () { - this.range = this.set - .map((comps) => comps.join(' ').trim()) - .join('||') - .trim() - return this.range - } - - toString () { - return this.range - } - - parseRange (range) { - // memoize range parsing for performance. - // this is a very hot path, and fully deterministic. - const memoOpts = - (this.options.includePrerelease && FLAG_INCLUDE_PRERELEASE) | - (this.options.loose && FLAG_LOOSE) - const memoKey = memoOpts + ':' + range - const cached = cache.get(memoKey) - if (cached) { - return cached - } - - const loose = this.options.loose - // `1.2.3 - 1.2.4` => `>=1.2.3 <=1.2.4` - const hr = loose ? re[t.HYPHENRANGELOOSE] : re[t.HYPHENRANGE] - range = range.replace(hr, hyphenReplace(this.options.includePrerelease)) - debug('hyphen replace', range) - - // `> 1.2.3 < 1.2.5` => `>1.2.3 <1.2.5` - range = range.replace(re[t.COMPARATORTRIM], comparatorTrimReplace) - debug('comparator trim', range) - - // `~ 1.2.3` => `~1.2.3` - range = range.replace(re[t.TILDETRIM], tildeTrimReplace) - debug('tilde trim', range) - - // `^ 1.2.3` => `^1.2.3` - range = range.replace(re[t.CARETTRIM], caretTrimReplace) - debug('caret trim', range) - - // At this point, the range is completely trimmed and - // ready to be split into comparators. - - let rangeList = range - .split(' ') - .map(comp => parseComparator(comp, this.options)) - .join(' ') - .split(/\s+/) - // >=0.0.0 is equivalent to * - .map(comp => replaceGTE0(comp, this.options)) - - if (loose) { - // in loose mode, throw out any that are not valid comparators - rangeList = rangeList.filter(comp => { - debug('loose invalid filter', comp, this.options) - return !!comp.match(re[t.COMPARATORLOOSE]) - }) - } - debug('range list', rangeList) - - // if any comparators are the null set, then replace with JUST null set - // if more than one comparator, remove any * comparators - // also, don't include the same comparator more than once - const rangeMap = new Map() - const comparators = rangeList.map(comp => new Comparator(comp, this.options)) - for (const comp of comparators) { - if (isNullSet(comp)) { - return [comp] - } - rangeMap.set(comp.value, comp) - } - if (rangeMap.size > 1 && rangeMap.has('')) { - rangeMap.delete('') - } - - const result = [...rangeMap.values()] - cache.set(memoKey, result) - return result - } - - intersects (range, options) { - if (!(range instanceof Range)) { - throw new TypeError('a Range is required') - } - - return this.set.some((thisComparators) => { - return ( - isSatisfiable(thisComparators, options) && - range.set.some((rangeComparators) => { - return ( - isSatisfiable(rangeComparators, options) && - thisComparators.every((thisComparator) => { - return rangeComparators.every((rangeComparator) => { - return thisComparator.intersects(rangeComparator, options) - }) - }) - ) - }) - ) - }) - } - - // if ANY of the sets match ALL of its comparators, then pass - test (version) { - if (!version) { - return false - } - - if (typeof version === 'string') { - try { - version = new SemVer(version, this.options) - } catch (er) { - return false - } - } - - for (let i = 0; i < this.set.length; i++) { - if (testSet(this.set[i], version, this.options)) { - return true - } - } - return false - } -} - -module.exports = Range - -const LRU = require('../internal/lrucache') -const cache = new LRU() - -const parseOptions = require('../internal/parse-options') -const Comparator = require('./comparator') -const debug = require('../internal/debug') -const SemVer = require('./semver') -const { - safeRe: re, - t, - comparatorTrimReplace, - tildeTrimReplace, - caretTrimReplace, -} = require('../internal/re') -const { FLAG_INCLUDE_PRERELEASE, FLAG_LOOSE } = require('../internal/constants') - -const isNullSet = c => c.value === '<0.0.0-0' -const isAny = c => c.value === '' - -// take a set of comparators and determine whether there -// exists a version which can satisfy it -const isSatisfiable = (comparators, options) => { - let result = true - const remainingComparators = comparators.slice() - let testComparator = remainingComparators.pop() - - while (result && remainingComparators.length) { - result = remainingComparators.every((otherComparator) => { - return testComparator.intersects(otherComparator, options) - }) - - testComparator = remainingComparators.pop() - } - - return result -} - -// comprised of xranges, tildes, stars, and gtlt's at this point. -// already replaced the hyphen ranges -// turn into a set of JUST comparators. -const parseComparator = (comp, options) => { - debug('comp', comp, options) - comp = replaceCarets(comp, options) - debug('caret', comp) - comp = replaceTildes(comp, options) - debug('tildes', comp) - comp = replaceXRanges(comp, options) - debug('xrange', comp) - comp = replaceStars(comp, options) - debug('stars', comp) - return comp -} - -const isX = id => !id || id.toLowerCase() === 'x' || id === '*' - -// ~, ~> --> * (any, kinda silly) -// ~2, ~2.x, ~2.x.x, ~>2, ~>2.x ~>2.x.x --> >=2.0.0 <3.0.0-0 -// ~2.0, ~2.0.x, ~>2.0, ~>2.0.x --> >=2.0.0 <2.1.0-0 -// ~1.2, ~1.2.x, ~>1.2, ~>1.2.x --> >=1.2.0 <1.3.0-0 -// ~1.2.3, ~>1.2.3 --> >=1.2.3 <1.3.0-0 -// ~1.2.0, ~>1.2.0 --> >=1.2.0 <1.3.0-0 -// ~0.0.1 --> >=0.0.1 <0.1.0-0 -const replaceTildes = (comp, options) => { - return comp - .trim() - .split(/\s+/) - .map((c) => replaceTilde(c, options)) - .join(' ') -} - -const replaceTilde = (comp, options) => { - const r = options.loose ? re[t.TILDELOOSE] : re[t.TILDE] - return comp.replace(r, (_, M, m, p, pr) => { - debug('tilde', comp, _, M, m, p, pr) - let ret - - if (isX(M)) { - ret = '' - } else if (isX(m)) { - ret = `>=${M}.0.0 <${+M + 1}.0.0-0` - } else if (isX(p)) { - // ~1.2 == >=1.2.0 <1.3.0-0 - ret = `>=${M}.${m}.0 <${M}.${+m + 1}.0-0` - } else if (pr) { - debug('replaceTilde pr', pr) - ret = `>=${M}.${m}.${p}-${pr - } <${M}.${+m + 1}.0-0` - } else { - // ~1.2.3 == >=1.2.3 <1.3.0-0 - ret = `>=${M}.${m}.${p - } <${M}.${+m + 1}.0-0` - } - - debug('tilde return', ret) - return ret - }) -} - -// ^ --> * (any, kinda silly) -// ^2, ^2.x, ^2.x.x --> >=2.0.0 <3.0.0-0 -// ^2.0, ^2.0.x --> >=2.0.0 <3.0.0-0 -// ^1.2, ^1.2.x --> >=1.2.0 <2.0.0-0 -// ^1.2.3 --> >=1.2.3 <2.0.0-0 -// ^1.2.0 --> >=1.2.0 <2.0.0-0 -// ^0.0.1 --> >=0.0.1 <0.0.2-0 -// ^0.1.0 --> >=0.1.0 <0.2.0-0 -const replaceCarets = (comp, options) => { - return comp - .trim() - .split(/\s+/) - .map((c) => replaceCaret(c, options)) - .join(' ') -} - -const replaceCaret = (comp, options) => { - debug('caret', comp, options) - const r = options.loose ? re[t.CARETLOOSE] : re[t.CARET] - const z = options.includePrerelease ? '-0' : '' - return comp.replace(r, (_, M, m, p, pr) => { - debug('caret', comp, _, M, m, p, pr) - let ret - - if (isX(M)) { - ret = '' - } else if (isX(m)) { - ret = `>=${M}.0.0${z} <${+M + 1}.0.0-0` - } else if (isX(p)) { - if (M === '0') { - ret = `>=${M}.${m}.0${z} <${M}.${+m + 1}.0-0` - } else { - ret = `>=${M}.${m}.0${z} <${+M + 1}.0.0-0` - } - } else if (pr) { - debug('replaceCaret pr', pr) - if (M === '0') { - if (m === '0') { - ret = `>=${M}.${m}.${p}-${pr - } <${M}.${m}.${+p + 1}-0` - } else { - ret = `>=${M}.${m}.${p}-${pr - } <${M}.${+m + 1}.0-0` - } - } else { - ret = `>=${M}.${m}.${p}-${pr - } <${+M + 1}.0.0-0` - } - } else { - debug('no pr') - if (M === '0') { - if (m === '0') { - ret = `>=${M}.${m}.${p - }${z} <${M}.${m}.${+p + 1}-0` - } else { - ret = `>=${M}.${m}.${p - }${z} <${M}.${+m + 1}.0-0` - } - } else { - ret = `>=${M}.${m}.${p - } <${+M + 1}.0.0-0` - } - } - - debug('caret return', ret) - return ret - }) -} - -const replaceXRanges = (comp, options) => { - debug('replaceXRanges', comp, options) - return comp - .split(/\s+/) - .map((c) => replaceXRange(c, options)) - .join(' ') -} - -const replaceXRange = (comp, options) => { - comp = comp.trim() - const r = options.loose ? re[t.XRANGELOOSE] : re[t.XRANGE] - return comp.replace(r, (ret, gtlt, M, m, p, pr) => { - debug('xRange', comp, ret, gtlt, M, m, p, pr) - const xM = isX(M) - const xm = xM || isX(m) - const xp = xm || isX(p) - const anyX = xp - - if (gtlt === '=' && anyX) { - gtlt = '' - } - - // if we're including prereleases in the match, then we need - // to fix this to -0, the lowest possible prerelease value - pr = options.includePrerelease ? '-0' : '' - - if (xM) { - if (gtlt === '>' || gtlt === '<') { - // nothing is allowed - ret = '<0.0.0-0' - } else { - // nothing is forbidden - ret = '*' - } - } else if (gtlt && anyX) { - // we know patch is an x, because we have any x at all. - // replace X with 0 - if (xm) { - m = 0 - } - p = 0 - - if (gtlt === '>') { - // >1 => >=2.0.0 - // >1.2 => >=1.3.0 - gtlt = '>=' - if (xm) { - M = +M + 1 - m = 0 - p = 0 - } else { - m = +m + 1 - p = 0 - } - } else if (gtlt === '<=') { - // <=0.7.x is actually <0.8.0, since any 0.7.x should - // pass. Similarly, <=7.x is actually <8.0.0, etc. - gtlt = '<' - if (xm) { - M = +M + 1 - } else { - m = +m + 1 - } - } - - if (gtlt === '<') { - pr = '-0' - } - - ret = `${gtlt + M}.${m}.${p}${pr}` - } else if (xm) { - ret = `>=${M}.0.0${pr} <${+M + 1}.0.0-0` - } else if (xp) { - ret = `>=${M}.${m}.0${pr - } <${M}.${+m + 1}.0-0` - } - - debug('xRange return', ret) - - return ret - }) -} - -// Because * is AND-ed with everything else in the comparator, -// and '' means "any version", just remove the *s entirely. -const replaceStars = (comp, options) => { - debug('replaceStars', comp, options) - // Looseness is ignored here. star is always as loose as it gets! - return comp - .trim() - .replace(re[t.STAR], '') -} - -const replaceGTE0 = (comp, options) => { - debug('replaceGTE0', comp, options) - return comp - .trim() - .replace(re[options.includePrerelease ? t.GTE0PRE : t.GTE0], '') -} - -// This function is passed to string.replace(re[t.HYPHENRANGE]) -// M, m, patch, prerelease, build -// 1.2 - 3.4.5 => >=1.2.0 <=3.4.5 -// 1.2.3 - 3.4 => >=1.2.0 <3.5.0-0 Any 3.4.x will do -// 1.2 - 3.4 => >=1.2.0 <3.5.0-0 -// TODO build? -const hyphenReplace = incPr => ($0, - from, fM, fm, fp, fpr, fb, - to, tM, tm, tp, tpr) => { - if (isX(fM)) { - from = '' - } else if (isX(fm)) { - from = `>=${fM}.0.0${incPr ? '-0' : ''}` - } else if (isX(fp)) { - from = `>=${fM}.${fm}.0${incPr ? '-0' : ''}` - } else if (fpr) { - from = `>=${from}` - } else { - from = `>=${from}${incPr ? '-0' : ''}` - } - - if (isX(tM)) { - to = '' - } else if (isX(tm)) { - to = `<${+tM + 1}.0.0-0` - } else if (isX(tp)) { - to = `<${tM}.${+tm + 1}.0-0` - } else if (tpr) { - to = `<=${tM}.${tm}.${tp}-${tpr}` - } else if (incPr) { - to = `<${tM}.${tm}.${+tp + 1}-0` - } else { - to = `<=${to}` - } - - return `${from} ${to}`.trim() -} - -const testSet = (set, version, options) => { - for (let i = 0; i < set.length; i++) { - if (!set[i].test(version)) { - return false - } - } - - if (version.prerelease.length && !options.includePrerelease) { - // Find the set of versions that are allowed to have prereleases - // For example, ^1.2.3-pr.1 desugars to >=1.2.3-pr.1 <2.0.0 - // That should allow `1.2.3-pr.2` to pass. - // However, `1.2.4-alpha.notready` should NOT be allowed, - // even though it's within the range set by the comparators. - for (let i = 0; i < set.length; i++) { - debug(set[i].semver) - if (set[i].semver === Comparator.ANY) { - continue - } - - if (set[i].semver.prerelease.length > 0) { - const allowed = set[i].semver - if (allowed.major === version.major && - allowed.minor === version.minor && - allowed.patch === version.patch) { - return true - } - } - } - - // Version has a -pre, but it's not one of the ones we like. - return false - } - - return true -} diff --git a/tools/eslint/node_modules/eslint-plugin-jsdoc/node_modules/semver/classes/semver.js b/tools/eslint/node_modules/eslint-plugin-jsdoc/node_modules/semver/classes/semver.js deleted file mode 100644 index 13e66ce4415694..00000000000000 --- a/tools/eslint/node_modules/eslint-plugin-jsdoc/node_modules/semver/classes/semver.js +++ /dev/null @@ -1,302 +0,0 @@ -const debug = require('../internal/debug') -const { MAX_LENGTH, MAX_SAFE_INTEGER } = require('../internal/constants') -const { safeRe: re, t } = require('../internal/re') - -const parseOptions = require('../internal/parse-options') -const { compareIdentifiers } = require('../internal/identifiers') -class SemVer { - constructor (version, options) { - options = parseOptions(options) - - if (version instanceof SemVer) { - if (version.loose === !!options.loose && - version.includePrerelease === !!options.includePrerelease) { - return version - } else { - version = version.version - } - } else if (typeof version !== 'string') { - throw new TypeError(`Invalid version. Must be a string. Got type "${typeof version}".`) - } - - if (version.length > MAX_LENGTH) { - throw new TypeError( - `version is longer than ${MAX_LENGTH} characters` - ) - } - - debug('SemVer', version, options) - this.options = options - this.loose = !!options.loose - // this isn't actually relevant for versions, but keep it so that we - // don't run into trouble passing this.options around. - this.includePrerelease = !!options.includePrerelease - - const m = version.trim().match(options.loose ? re[t.LOOSE] : re[t.FULL]) - - if (!m) { - throw new TypeError(`Invalid Version: ${version}`) - } - - this.raw = version - - // these are actually numbers - this.major = +m[1] - this.minor = +m[2] - this.patch = +m[3] - - if (this.major > MAX_SAFE_INTEGER || this.major < 0) { - throw new TypeError('Invalid major version') - } - - if (this.minor > MAX_SAFE_INTEGER || this.minor < 0) { - throw new TypeError('Invalid minor version') - } - - if (this.patch > MAX_SAFE_INTEGER || this.patch < 0) { - throw new TypeError('Invalid patch version') - } - - // numberify any prerelease numeric ids - if (!m[4]) { - this.prerelease = [] - } else { - this.prerelease = m[4].split('.').map((id) => { - if (/^[0-9]+$/.test(id)) { - const num = +id - if (num >= 0 && num < MAX_SAFE_INTEGER) { - return num - } - } - return id - }) - } - - this.build = m[5] ? m[5].split('.') : [] - this.format() - } - - format () { - this.version = `${this.major}.${this.minor}.${this.patch}` - if (this.prerelease.length) { - this.version += `-${this.prerelease.join('.')}` - } - return this.version - } - - toString () { - return this.version - } - - compare (other) { - debug('SemVer.compare', this.version, this.options, other) - if (!(other instanceof SemVer)) { - if (typeof other === 'string' && other === this.version) { - return 0 - } - other = new SemVer(other, this.options) - } - - if (other.version === this.version) { - return 0 - } - - return this.compareMain(other) || this.comparePre(other) - } - - compareMain (other) { - if (!(other instanceof SemVer)) { - other = new SemVer(other, this.options) - } - - return ( - compareIdentifiers(this.major, other.major) || - compareIdentifiers(this.minor, other.minor) || - compareIdentifiers(this.patch, other.patch) - ) - } - - comparePre (other) { - if (!(other instanceof SemVer)) { - other = new SemVer(other, this.options) - } - - // NOT having a prerelease is > having one - if (this.prerelease.length && !other.prerelease.length) { - return -1 - } else if (!this.prerelease.length && other.prerelease.length) { - return 1 - } else if (!this.prerelease.length && !other.prerelease.length) { - return 0 - } - - let i = 0 - do { - const a = this.prerelease[i] - const b = other.prerelease[i] - debug('prerelease compare', i, a, b) - if (a === undefined && b === undefined) { - return 0 - } else if (b === undefined) { - return 1 - } else if (a === undefined) { - return -1 - } else if (a === b) { - continue - } else { - return compareIdentifiers(a, b) - } - } while (++i) - } - - compareBuild (other) { - if (!(other instanceof SemVer)) { - other = new SemVer(other, this.options) - } - - let i = 0 - do { - const a = this.build[i] - const b = other.build[i] - debug('build compare', i, a, b) - if (a === undefined && b === undefined) { - return 0 - } else if (b === undefined) { - return 1 - } else if (a === undefined) { - return -1 - } else if (a === b) { - continue - } else { - return compareIdentifiers(a, b) - } - } while (++i) - } - - // preminor will bump the version up to the next minor release, and immediately - // down to pre-release. premajor and prepatch work the same way. - inc (release, identifier, identifierBase) { - switch (release) { - case 'premajor': - this.prerelease.length = 0 - this.patch = 0 - this.minor = 0 - this.major++ - this.inc('pre', identifier, identifierBase) - break - case 'preminor': - this.prerelease.length = 0 - this.patch = 0 - this.minor++ - this.inc('pre', identifier, identifierBase) - break - case 'prepatch': - // If this is already a prerelease, it will bump to the next version - // drop any prereleases that might already exist, since they are not - // relevant at this point. - this.prerelease.length = 0 - this.inc('patch', identifier, identifierBase) - this.inc('pre', identifier, identifierBase) - break - // If the input is a non-prerelease version, this acts the same as - // prepatch. - case 'prerelease': - if (this.prerelease.length === 0) { - this.inc('patch', identifier, identifierBase) - } - this.inc('pre', identifier, identifierBase) - break - - case 'major': - // If this is a pre-major version, bump up to the same major version. - // Otherwise increment major. - // 1.0.0-5 bumps to 1.0.0 - // 1.1.0 bumps to 2.0.0 - if ( - this.minor !== 0 || - this.patch !== 0 || - this.prerelease.length === 0 - ) { - this.major++ - } - this.minor = 0 - this.patch = 0 - this.prerelease = [] - break - case 'minor': - // If this is a pre-minor version, bump up to the same minor version. - // Otherwise increment minor. - // 1.2.0-5 bumps to 1.2.0 - // 1.2.1 bumps to 1.3.0 - if (this.patch !== 0 || this.prerelease.length === 0) { - this.minor++ - } - this.patch = 0 - this.prerelease = [] - break - case 'patch': - // If this is not a pre-release version, it will increment the patch. - // If it is a pre-release it will bump up to the same patch version. - // 1.2.0-5 patches to 1.2.0 - // 1.2.0 patches to 1.2.1 - if (this.prerelease.length === 0) { - this.patch++ - } - this.prerelease = [] - break - // This probably shouldn't be used publicly. - // 1.0.0 'pre' would become 1.0.0-0 which is the wrong direction. - case 'pre': { - const base = Number(identifierBase) ? 1 : 0 - - if (!identifier && identifierBase === false) { - throw new Error('invalid increment argument: identifier is empty') - } - - if (this.prerelease.length === 0) { - this.prerelease = [base] - } else { - let i = this.prerelease.length - while (--i >= 0) { - if (typeof this.prerelease[i] === 'number') { - this.prerelease[i]++ - i = -2 - } - } - if (i === -1) { - // didn't increment anything - if (identifier === this.prerelease.join('.') && identifierBase === false) { - throw new Error('invalid increment argument: identifier already exists') - } - this.prerelease.push(base) - } - } - if (identifier) { - // 1.2.0-beta.1 bumps to 1.2.0-beta.2, - // 1.2.0-beta.fooblz or 1.2.0-beta bumps to 1.2.0-beta.0 - let prerelease = [identifier, base] - if (identifierBase === false) { - prerelease = [identifier] - } - if (compareIdentifiers(this.prerelease[0], identifier) === 0) { - if (isNaN(this.prerelease[1])) { - this.prerelease = prerelease - } - } else { - this.prerelease = prerelease - } - } - break - } - default: - throw new Error(`invalid increment argument: ${release}`) - } - this.raw = this.format() - if (this.build.length) { - this.raw += `+${this.build.join('.')}` - } - return this - } -} - -module.exports = SemVer diff --git a/tools/eslint/node_modules/eslint-plugin-jsdoc/node_modules/semver/functions/clean.js b/tools/eslint/node_modules/eslint-plugin-jsdoc/node_modules/semver/functions/clean.js deleted file mode 100644 index 811fe6b82cb73e..00000000000000 --- a/tools/eslint/node_modules/eslint-plugin-jsdoc/node_modules/semver/functions/clean.js +++ /dev/null @@ -1,6 +0,0 @@ -const parse = require('./parse') -const clean = (version, options) => { - const s = parse(version.trim().replace(/^[=v]+/, ''), options) - return s ? s.version : null -} -module.exports = clean diff --git a/tools/eslint/node_modules/eslint-plugin-jsdoc/node_modules/semver/functions/cmp.js b/tools/eslint/node_modules/eslint-plugin-jsdoc/node_modules/semver/functions/cmp.js deleted file mode 100644 index 40119094747dd0..00000000000000 --- a/tools/eslint/node_modules/eslint-plugin-jsdoc/node_modules/semver/functions/cmp.js +++ /dev/null @@ -1,52 +0,0 @@ -const eq = require('./eq') -const neq = require('./neq') -const gt = require('./gt') -const gte = require('./gte') -const lt = require('./lt') -const lte = require('./lte') - -const cmp = (a, op, b, loose) => { - switch (op) { - case '===': - if (typeof a === 'object') { - a = a.version - } - if (typeof b === 'object') { - b = b.version - } - return a === b - - case '!==': - if (typeof a === 'object') { - a = a.version - } - if (typeof b === 'object') { - b = b.version - } - return a !== b - - case '': - case '=': - case '==': - return eq(a, b, loose) - - case '!=': - return neq(a, b, loose) - - case '>': - return gt(a, b, loose) - - case '>=': - return gte(a, b, loose) - - case '<': - return lt(a, b, loose) - - case '<=': - return lte(a, b, loose) - - default: - throw new TypeError(`Invalid operator: ${op}`) - } -} -module.exports = cmp diff --git a/tools/eslint/node_modules/eslint-plugin-jsdoc/node_modules/semver/functions/coerce.js b/tools/eslint/node_modules/eslint-plugin-jsdoc/node_modules/semver/functions/coerce.js deleted file mode 100644 index b378dcea4e5a74..00000000000000 --- a/tools/eslint/node_modules/eslint-plugin-jsdoc/node_modules/semver/functions/coerce.js +++ /dev/null @@ -1,60 +0,0 @@ -const SemVer = require('../classes/semver') -const parse = require('./parse') -const { safeRe: re, t } = require('../internal/re') - -const coerce = (version, options) => { - if (version instanceof SemVer) { - return version - } - - if (typeof version === 'number') { - version = String(version) - } - - if (typeof version !== 'string') { - return null - } - - options = options || {} - - let match = null - if (!options.rtl) { - match = version.match(options.includePrerelease ? re[t.COERCEFULL] : re[t.COERCE]) - } else { - // Find the right-most coercible string that does not share - // a terminus with a more left-ward coercible string. - // Eg, '1.2.3.4' wants to coerce '2.3.4', not '3.4' or '4' - // With includePrerelease option set, '1.2.3.4-rc' wants to coerce '2.3.4-rc', not '2.3.4' - // - // Walk through the string checking with a /g regexp - // Manually set the index so as to pick up overlapping matches. - // Stop when we get a match that ends at the string end, since no - // coercible string can be more right-ward without the same terminus. - const coerceRtlRegex = options.includePrerelease ? re[t.COERCERTLFULL] : re[t.COERCERTL] - let next - while ((next = coerceRtlRegex.exec(version)) && - (!match || match.index + match[0].length !== version.length) - ) { - if (!match || - next.index + next[0].length !== match.index + match[0].length) { - match = next - } - coerceRtlRegex.lastIndex = next.index + next[1].length + next[2].length - } - // leave it in a clean state - coerceRtlRegex.lastIndex = -1 - } - - if (match === null) { - return null - } - - const major = match[2] - const minor = match[3] || '0' - const patch = match[4] || '0' - const prerelease = options.includePrerelease && match[5] ? `-${match[5]}` : '' - const build = options.includePrerelease && match[6] ? `+${match[6]}` : '' - - return parse(`${major}.${minor}.${patch}${prerelease}${build}`, options) -} -module.exports = coerce diff --git a/tools/eslint/node_modules/eslint-plugin-jsdoc/node_modules/semver/functions/compare-build.js b/tools/eslint/node_modules/eslint-plugin-jsdoc/node_modules/semver/functions/compare-build.js deleted file mode 100644 index 9eb881bef0fddc..00000000000000 --- a/tools/eslint/node_modules/eslint-plugin-jsdoc/node_modules/semver/functions/compare-build.js +++ /dev/null @@ -1,7 +0,0 @@ -const SemVer = require('../classes/semver') -const compareBuild = (a, b, loose) => { - const versionA = new SemVer(a, loose) - const versionB = new SemVer(b, loose) - return versionA.compare(versionB) || versionA.compareBuild(versionB) -} -module.exports = compareBuild diff --git a/tools/eslint/node_modules/eslint-plugin-jsdoc/node_modules/semver/functions/compare-loose.js b/tools/eslint/node_modules/eslint-plugin-jsdoc/node_modules/semver/functions/compare-loose.js deleted file mode 100644 index 4881fbe00250c5..00000000000000 --- a/tools/eslint/node_modules/eslint-plugin-jsdoc/node_modules/semver/functions/compare-loose.js +++ /dev/null @@ -1,3 +0,0 @@ -const compare = require('./compare') -const compareLoose = (a, b) => compare(a, b, true) -module.exports = compareLoose diff --git a/tools/eslint/node_modules/eslint-plugin-jsdoc/node_modules/semver/functions/compare.js b/tools/eslint/node_modules/eslint-plugin-jsdoc/node_modules/semver/functions/compare.js deleted file mode 100644 index 748b7afa514a9f..00000000000000 --- a/tools/eslint/node_modules/eslint-plugin-jsdoc/node_modules/semver/functions/compare.js +++ /dev/null @@ -1,5 +0,0 @@ -const SemVer = require('../classes/semver') -const compare = (a, b, loose) => - new SemVer(a, loose).compare(new SemVer(b, loose)) - -module.exports = compare diff --git a/tools/eslint/node_modules/eslint-plugin-jsdoc/node_modules/semver/functions/diff.js b/tools/eslint/node_modules/eslint-plugin-jsdoc/node_modules/semver/functions/diff.js deleted file mode 100644 index fc224e302c0e42..00000000000000 --- a/tools/eslint/node_modules/eslint-plugin-jsdoc/node_modules/semver/functions/diff.js +++ /dev/null @@ -1,65 +0,0 @@ -const parse = require('./parse.js') - -const diff = (version1, version2) => { - const v1 = parse(version1, null, true) - const v2 = parse(version2, null, true) - const comparison = v1.compare(v2) - - if (comparison === 0) { - return null - } - - const v1Higher = comparison > 0 - const highVersion = v1Higher ? v1 : v2 - const lowVersion = v1Higher ? v2 : v1 - const highHasPre = !!highVersion.prerelease.length - const lowHasPre = !!lowVersion.prerelease.length - - if (lowHasPre && !highHasPre) { - // Going from prerelease -> no prerelease requires some special casing - - // If the low version has only a major, then it will always be a major - // Some examples: - // 1.0.0-1 -> 1.0.0 - // 1.0.0-1 -> 1.1.1 - // 1.0.0-1 -> 2.0.0 - if (!lowVersion.patch && !lowVersion.minor) { - return 'major' - } - - // Otherwise it can be determined by checking the high version - - if (highVersion.patch) { - // anything higher than a patch bump would result in the wrong version - return 'patch' - } - - if (highVersion.minor) { - // anything higher than a minor bump would result in the wrong version - return 'minor' - } - - // bumping major/minor/patch all have same result - return 'major' - } - - // add the `pre` prefix if we are going to a prerelease version - const prefix = highHasPre ? 'pre' : '' - - if (v1.major !== v2.major) { - return prefix + 'major' - } - - if (v1.minor !== v2.minor) { - return prefix + 'minor' - } - - if (v1.patch !== v2.patch) { - return prefix + 'patch' - } - - // high and low are preleases - return 'prerelease' -} - -module.exports = diff diff --git a/tools/eslint/node_modules/eslint-plugin-jsdoc/node_modules/semver/functions/eq.js b/tools/eslint/node_modules/eslint-plugin-jsdoc/node_modules/semver/functions/eq.js deleted file mode 100644 index 271fed976f34a6..00000000000000 --- a/tools/eslint/node_modules/eslint-plugin-jsdoc/node_modules/semver/functions/eq.js +++ /dev/null @@ -1,3 +0,0 @@ -const compare = require('./compare') -const eq = (a, b, loose) => compare(a, b, loose) === 0 -module.exports = eq diff --git a/tools/eslint/node_modules/eslint-plugin-jsdoc/node_modules/semver/functions/gt.js b/tools/eslint/node_modules/eslint-plugin-jsdoc/node_modules/semver/functions/gt.js deleted file mode 100644 index d9b2156d8b56c3..00000000000000 --- a/tools/eslint/node_modules/eslint-plugin-jsdoc/node_modules/semver/functions/gt.js +++ /dev/null @@ -1,3 +0,0 @@ -const compare = require('./compare') -const gt = (a, b, loose) => compare(a, b, loose) > 0 -module.exports = gt diff --git a/tools/eslint/node_modules/eslint-plugin-jsdoc/node_modules/semver/functions/gte.js b/tools/eslint/node_modules/eslint-plugin-jsdoc/node_modules/semver/functions/gte.js deleted file mode 100644 index 5aeaa634707a0c..00000000000000 --- a/tools/eslint/node_modules/eslint-plugin-jsdoc/node_modules/semver/functions/gte.js +++ /dev/null @@ -1,3 +0,0 @@ -const compare = require('./compare') -const gte = (a, b, loose) => compare(a, b, loose) >= 0 -module.exports = gte diff --git a/tools/eslint/node_modules/eslint-plugin-jsdoc/node_modules/semver/functions/inc.js b/tools/eslint/node_modules/eslint-plugin-jsdoc/node_modules/semver/functions/inc.js deleted file mode 100644 index 7670b1bea1a497..00000000000000 --- a/tools/eslint/node_modules/eslint-plugin-jsdoc/node_modules/semver/functions/inc.js +++ /dev/null @@ -1,19 +0,0 @@ -const SemVer = require('../classes/semver') - -const inc = (version, release, options, identifier, identifierBase) => { - if (typeof (options) === 'string') { - identifierBase = identifier - identifier = options - options = undefined - } - - try { - return new SemVer( - version instanceof SemVer ? version.version : version, - options - ).inc(release, identifier, identifierBase).version - } catch (er) { - return null - } -} -module.exports = inc diff --git a/tools/eslint/node_modules/eslint-plugin-jsdoc/node_modules/semver/functions/lt.js b/tools/eslint/node_modules/eslint-plugin-jsdoc/node_modules/semver/functions/lt.js deleted file mode 100644 index b440ab7d4212d3..00000000000000 --- a/tools/eslint/node_modules/eslint-plugin-jsdoc/node_modules/semver/functions/lt.js +++ /dev/null @@ -1,3 +0,0 @@ -const compare = require('./compare') -const lt = (a, b, loose) => compare(a, b, loose) < 0 -module.exports = lt diff --git a/tools/eslint/node_modules/eslint-plugin-jsdoc/node_modules/semver/functions/lte.js b/tools/eslint/node_modules/eslint-plugin-jsdoc/node_modules/semver/functions/lte.js deleted file mode 100644 index 6dcc956505584e..00000000000000 --- a/tools/eslint/node_modules/eslint-plugin-jsdoc/node_modules/semver/functions/lte.js +++ /dev/null @@ -1,3 +0,0 @@ -const compare = require('./compare') -const lte = (a, b, loose) => compare(a, b, loose) <= 0 -module.exports = lte diff --git a/tools/eslint/node_modules/eslint-plugin-jsdoc/node_modules/semver/functions/major.js b/tools/eslint/node_modules/eslint-plugin-jsdoc/node_modules/semver/functions/major.js deleted file mode 100644 index 4283165e9d2719..00000000000000 --- a/tools/eslint/node_modules/eslint-plugin-jsdoc/node_modules/semver/functions/major.js +++ /dev/null @@ -1,3 +0,0 @@ -const SemVer = require('../classes/semver') -const major = (a, loose) => new SemVer(a, loose).major -module.exports = major diff --git a/tools/eslint/node_modules/eslint-plugin-jsdoc/node_modules/semver/functions/minor.js b/tools/eslint/node_modules/eslint-plugin-jsdoc/node_modules/semver/functions/minor.js deleted file mode 100644 index 57b3455f827bac..00000000000000 --- a/tools/eslint/node_modules/eslint-plugin-jsdoc/node_modules/semver/functions/minor.js +++ /dev/null @@ -1,3 +0,0 @@ -const SemVer = require('../classes/semver') -const minor = (a, loose) => new SemVer(a, loose).minor -module.exports = minor diff --git a/tools/eslint/node_modules/eslint-plugin-jsdoc/node_modules/semver/functions/neq.js b/tools/eslint/node_modules/eslint-plugin-jsdoc/node_modules/semver/functions/neq.js deleted file mode 100644 index f944c01576973f..00000000000000 --- a/tools/eslint/node_modules/eslint-plugin-jsdoc/node_modules/semver/functions/neq.js +++ /dev/null @@ -1,3 +0,0 @@ -const compare = require('./compare') -const neq = (a, b, loose) => compare(a, b, loose) !== 0 -module.exports = neq diff --git a/tools/eslint/node_modules/eslint-plugin-jsdoc/node_modules/semver/functions/parse.js b/tools/eslint/node_modules/eslint-plugin-jsdoc/node_modules/semver/functions/parse.js deleted file mode 100644 index 459b3b17375c82..00000000000000 --- a/tools/eslint/node_modules/eslint-plugin-jsdoc/node_modules/semver/functions/parse.js +++ /dev/null @@ -1,16 +0,0 @@ -const SemVer = require('../classes/semver') -const parse = (version, options, throwErrors = false) => { - if (version instanceof SemVer) { - return version - } - try { - return new SemVer(version, options) - } catch (er) { - if (!throwErrors) { - return null - } - throw er - } -} - -module.exports = parse diff --git a/tools/eslint/node_modules/eslint-plugin-jsdoc/node_modules/semver/functions/patch.js b/tools/eslint/node_modules/eslint-plugin-jsdoc/node_modules/semver/functions/patch.js deleted file mode 100644 index 63afca2524fca9..00000000000000 --- a/tools/eslint/node_modules/eslint-plugin-jsdoc/node_modules/semver/functions/patch.js +++ /dev/null @@ -1,3 +0,0 @@ -const SemVer = require('../classes/semver') -const patch = (a, loose) => new SemVer(a, loose).patch -module.exports = patch diff --git a/tools/eslint/node_modules/eslint-plugin-jsdoc/node_modules/semver/functions/prerelease.js b/tools/eslint/node_modules/eslint-plugin-jsdoc/node_modules/semver/functions/prerelease.js deleted file mode 100644 index 06aa13248ae651..00000000000000 --- a/tools/eslint/node_modules/eslint-plugin-jsdoc/node_modules/semver/functions/prerelease.js +++ /dev/null @@ -1,6 +0,0 @@ -const parse = require('./parse') -const prerelease = (version, options) => { - const parsed = parse(version, options) - return (parsed && parsed.prerelease.length) ? parsed.prerelease : null -} -module.exports = prerelease diff --git a/tools/eslint/node_modules/eslint-plugin-jsdoc/node_modules/semver/functions/rcompare.js b/tools/eslint/node_modules/eslint-plugin-jsdoc/node_modules/semver/functions/rcompare.js deleted file mode 100644 index 0ac509e79dc8cf..00000000000000 --- a/tools/eslint/node_modules/eslint-plugin-jsdoc/node_modules/semver/functions/rcompare.js +++ /dev/null @@ -1,3 +0,0 @@ -const compare = require('./compare') -const rcompare = (a, b, loose) => compare(b, a, loose) -module.exports = rcompare diff --git a/tools/eslint/node_modules/eslint-plugin-jsdoc/node_modules/semver/functions/rsort.js b/tools/eslint/node_modules/eslint-plugin-jsdoc/node_modules/semver/functions/rsort.js deleted file mode 100644 index 82404c5cfe0266..00000000000000 --- a/tools/eslint/node_modules/eslint-plugin-jsdoc/node_modules/semver/functions/rsort.js +++ /dev/null @@ -1,3 +0,0 @@ -const compareBuild = require('./compare-build') -const rsort = (list, loose) => list.sort((a, b) => compareBuild(b, a, loose)) -module.exports = rsort diff --git a/tools/eslint/node_modules/eslint-plugin-jsdoc/node_modules/semver/functions/satisfies.js b/tools/eslint/node_modules/eslint-plugin-jsdoc/node_modules/semver/functions/satisfies.js deleted file mode 100644 index 50af1c199b6cae..00000000000000 --- a/tools/eslint/node_modules/eslint-plugin-jsdoc/node_modules/semver/functions/satisfies.js +++ /dev/null @@ -1,10 +0,0 @@ -const Range = require('../classes/range') -const satisfies = (version, range, options) => { - try { - range = new Range(range, options) - } catch (er) { - return false - } - return range.test(version) -} -module.exports = satisfies diff --git a/tools/eslint/node_modules/eslint-plugin-jsdoc/node_modules/semver/functions/sort.js b/tools/eslint/node_modules/eslint-plugin-jsdoc/node_modules/semver/functions/sort.js deleted file mode 100644 index 4d10917aba8e5a..00000000000000 --- a/tools/eslint/node_modules/eslint-plugin-jsdoc/node_modules/semver/functions/sort.js +++ /dev/null @@ -1,3 +0,0 @@ -const compareBuild = require('./compare-build') -const sort = (list, loose) => list.sort((a, b) => compareBuild(a, b, loose)) -module.exports = sort diff --git a/tools/eslint/node_modules/eslint-plugin-jsdoc/node_modules/semver/functions/valid.js b/tools/eslint/node_modules/eslint-plugin-jsdoc/node_modules/semver/functions/valid.js deleted file mode 100644 index f27bae10731c0c..00000000000000 --- a/tools/eslint/node_modules/eslint-plugin-jsdoc/node_modules/semver/functions/valid.js +++ /dev/null @@ -1,6 +0,0 @@ -const parse = require('./parse') -const valid = (version, options) => { - const v = parse(version, options) - return v ? v.version : null -} -module.exports = valid diff --git a/tools/eslint/node_modules/eslint-plugin-jsdoc/node_modules/semver/index.js b/tools/eslint/node_modules/eslint-plugin-jsdoc/node_modules/semver/index.js deleted file mode 100644 index 86d42ac16a840b..00000000000000 --- a/tools/eslint/node_modules/eslint-plugin-jsdoc/node_modules/semver/index.js +++ /dev/null @@ -1,89 +0,0 @@ -// just pre-load all the stuff that index.js lazily exports -const internalRe = require('./internal/re') -const constants = require('./internal/constants') -const SemVer = require('./classes/semver') -const identifiers = require('./internal/identifiers') -const parse = require('./functions/parse') -const valid = require('./functions/valid') -const clean = require('./functions/clean') -const inc = require('./functions/inc') -const diff = require('./functions/diff') -const major = require('./functions/major') -const minor = require('./functions/minor') -const patch = require('./functions/patch') -const prerelease = require('./functions/prerelease') -const compare = require('./functions/compare') -const rcompare = require('./functions/rcompare') -const compareLoose = require('./functions/compare-loose') -const compareBuild = require('./functions/compare-build') -const sort = require('./functions/sort') -const rsort = require('./functions/rsort') -const gt = require('./functions/gt') -const lt = require('./functions/lt') -const eq = require('./functions/eq') -const neq = require('./functions/neq') -const gte = require('./functions/gte') -const lte = require('./functions/lte') -const cmp = require('./functions/cmp') -const coerce = require('./functions/coerce') -const Comparator = require('./classes/comparator') -const Range = require('./classes/range') -const satisfies = require('./functions/satisfies') -const toComparators = require('./ranges/to-comparators') -const maxSatisfying = require('./ranges/max-satisfying') -const minSatisfying = require('./ranges/min-satisfying') -const minVersion = require('./ranges/min-version') -const validRange = require('./ranges/valid') -const outside = require('./ranges/outside') -const gtr = require('./ranges/gtr') -const ltr = require('./ranges/ltr') -const intersects = require('./ranges/intersects') -const simplifyRange = require('./ranges/simplify') -const subset = require('./ranges/subset') -module.exports = { - parse, - valid, - clean, - inc, - diff, - major, - minor, - patch, - prerelease, - compare, - rcompare, - compareLoose, - compareBuild, - sort, - rsort, - gt, - lt, - eq, - neq, - gte, - lte, - cmp, - coerce, - Comparator, - Range, - satisfies, - toComparators, - maxSatisfying, - minSatisfying, - minVersion, - validRange, - outside, - gtr, - ltr, - intersects, - simplifyRange, - subset, - SemVer, - re: internalRe.re, - src: internalRe.src, - tokens: internalRe.t, - SEMVER_SPEC_VERSION: constants.SEMVER_SPEC_VERSION, - RELEASE_TYPES: constants.RELEASE_TYPES, - compareIdentifiers: identifiers.compareIdentifiers, - rcompareIdentifiers: identifiers.rcompareIdentifiers, -} diff --git a/tools/eslint/node_modules/eslint-plugin-jsdoc/node_modules/semver/internal/constants.js b/tools/eslint/node_modules/eslint-plugin-jsdoc/node_modules/semver/internal/constants.js deleted file mode 100644 index 94be1c570277a5..00000000000000 --- a/tools/eslint/node_modules/eslint-plugin-jsdoc/node_modules/semver/internal/constants.js +++ /dev/null @@ -1,35 +0,0 @@ -// Note: this is the semver.org version of the spec that it implements -// Not necessarily the package version of this code. -const SEMVER_SPEC_VERSION = '2.0.0' - -const MAX_LENGTH = 256 -const MAX_SAFE_INTEGER = Number.MAX_SAFE_INTEGER || -/* istanbul ignore next */ 9007199254740991 - -// Max safe segment length for coercion. -const MAX_SAFE_COMPONENT_LENGTH = 16 - -// Max safe length for a build identifier. The max length minus 6 characters for -// the shortest version with a build 0.0.0+BUILD. -const MAX_SAFE_BUILD_LENGTH = MAX_LENGTH - 6 - -const RELEASE_TYPES = [ - 'major', - 'premajor', - 'minor', - 'preminor', - 'patch', - 'prepatch', - 'prerelease', -] - -module.exports = { - MAX_LENGTH, - MAX_SAFE_COMPONENT_LENGTH, - MAX_SAFE_BUILD_LENGTH, - MAX_SAFE_INTEGER, - RELEASE_TYPES, - SEMVER_SPEC_VERSION, - FLAG_INCLUDE_PRERELEASE: 0b001, - FLAG_LOOSE: 0b010, -} diff --git a/tools/eslint/node_modules/eslint-plugin-jsdoc/node_modules/semver/internal/debug.js b/tools/eslint/node_modules/eslint-plugin-jsdoc/node_modules/semver/internal/debug.js deleted file mode 100644 index 1c00e1369aa2a0..00000000000000 --- a/tools/eslint/node_modules/eslint-plugin-jsdoc/node_modules/semver/internal/debug.js +++ /dev/null @@ -1,9 +0,0 @@ -const debug = ( - typeof process === 'object' && - process.env && - process.env.NODE_DEBUG && - /\bsemver\b/i.test(process.env.NODE_DEBUG) -) ? (...args) => console.error('SEMVER', ...args) - : () => {} - -module.exports = debug diff --git a/tools/eslint/node_modules/eslint-plugin-jsdoc/node_modules/semver/internal/identifiers.js b/tools/eslint/node_modules/eslint-plugin-jsdoc/node_modules/semver/internal/identifiers.js deleted file mode 100644 index e612d0a3d83619..00000000000000 --- a/tools/eslint/node_modules/eslint-plugin-jsdoc/node_modules/semver/internal/identifiers.js +++ /dev/null @@ -1,23 +0,0 @@ -const numeric = /^[0-9]+$/ -const compareIdentifiers = (a, b) => { - const anum = numeric.test(a) - const bnum = numeric.test(b) - - if (anum && bnum) { - a = +a - b = +b - } - - return a === b ? 0 - : (anum && !bnum) ? -1 - : (bnum && !anum) ? 1 - : a < b ? -1 - : 1 -} - -const rcompareIdentifiers = (a, b) => compareIdentifiers(b, a) - -module.exports = { - compareIdentifiers, - rcompareIdentifiers, -} diff --git a/tools/eslint/node_modules/eslint-plugin-jsdoc/node_modules/semver/internal/lrucache.js b/tools/eslint/node_modules/eslint-plugin-jsdoc/node_modules/semver/internal/lrucache.js deleted file mode 100644 index 6d89ec948d0f1f..00000000000000 --- a/tools/eslint/node_modules/eslint-plugin-jsdoc/node_modules/semver/internal/lrucache.js +++ /dev/null @@ -1,40 +0,0 @@ -class LRUCache { - constructor () { - this.max = 1000 - this.map = new Map() - } - - get (key) { - const value = this.map.get(key) - if (value === undefined) { - return undefined - } else { - // Remove the key from the map and add it to the end - this.map.delete(key) - this.map.set(key, value) - return value - } - } - - delete (key) { - return this.map.delete(key) - } - - set (key, value) { - const deleted = this.delete(key) - - if (!deleted && value !== undefined) { - // If cache is full, delete the least recently used item - if (this.map.size >= this.max) { - const firstKey = this.map.keys().next().value - this.delete(firstKey) - } - - this.map.set(key, value) - } - - return this - } -} - -module.exports = LRUCache diff --git a/tools/eslint/node_modules/eslint-plugin-jsdoc/node_modules/semver/internal/parse-options.js b/tools/eslint/node_modules/eslint-plugin-jsdoc/node_modules/semver/internal/parse-options.js deleted file mode 100644 index 10d64ce06d3c59..00000000000000 --- a/tools/eslint/node_modules/eslint-plugin-jsdoc/node_modules/semver/internal/parse-options.js +++ /dev/null @@ -1,15 +0,0 @@ -// parse out just the options we care about -const looseOption = Object.freeze({ loose: true }) -const emptyOpts = Object.freeze({ }) -const parseOptions = options => { - if (!options) { - return emptyOpts - } - - if (typeof options !== 'object') { - return looseOption - } - - return options -} -module.exports = parseOptions diff --git a/tools/eslint/node_modules/eslint-plugin-jsdoc/node_modules/semver/internal/re.js b/tools/eslint/node_modules/eslint-plugin-jsdoc/node_modules/semver/internal/re.js deleted file mode 100644 index fd8920e7baa717..00000000000000 --- a/tools/eslint/node_modules/eslint-plugin-jsdoc/node_modules/semver/internal/re.js +++ /dev/null @@ -1,217 +0,0 @@ -const { - MAX_SAFE_COMPONENT_LENGTH, - MAX_SAFE_BUILD_LENGTH, - MAX_LENGTH, -} = require('./constants') -const debug = require('./debug') -exports = module.exports = {} - -// The actual regexps go on exports.re -const re = exports.re = [] -const safeRe = exports.safeRe = [] -const src = exports.src = [] -const t = exports.t = {} -let R = 0 - -const LETTERDASHNUMBER = '[a-zA-Z0-9-]' - -// Replace some greedy regex tokens to prevent regex dos issues. These regex are -// used internally via the safeRe object since all inputs in this library get -// normalized first to trim and collapse all extra whitespace. The original -// regexes are exported for userland consumption and lower level usage. A -// future breaking change could export the safer regex only with a note that -// all input should have extra whitespace removed. -const safeRegexReplacements = [ - ['\\s', 1], - ['\\d', MAX_LENGTH], - [LETTERDASHNUMBER, MAX_SAFE_BUILD_LENGTH], -] - -const makeSafeRegex = (value) => { - for (const [token, max] of safeRegexReplacements) { - value = value - .split(`${token}*`).join(`${token}{0,${max}}`) - .split(`${token}+`).join(`${token}{1,${max}}`) - } - return value -} - -const createToken = (name, value, isGlobal) => { - const safe = makeSafeRegex(value) - const index = R++ - debug(name, index, value) - t[name] = index - src[index] = value - re[index] = new RegExp(value, isGlobal ? 'g' : undefined) - safeRe[index] = new RegExp(safe, isGlobal ? 'g' : undefined) -} - -// The following Regular Expressions can be used for tokenizing, -// validating, and parsing SemVer version strings. - -// ## Numeric Identifier -// A single `0`, or a non-zero digit followed by zero or more digits. - -createToken('NUMERICIDENTIFIER', '0|[1-9]\\d*') -createToken('NUMERICIDENTIFIERLOOSE', '\\d+') - -// ## Non-numeric Identifier -// Zero or more digits, followed by a letter or hyphen, and then zero or -// more letters, digits, or hyphens. - -createToken('NONNUMERICIDENTIFIER', `\\d*[a-zA-Z-]${LETTERDASHNUMBER}*`) - -// ## Main Version -// Three dot-separated numeric identifiers. - -createToken('MAINVERSION', `(${src[t.NUMERICIDENTIFIER]})\\.` + - `(${src[t.NUMERICIDENTIFIER]})\\.` + - `(${src[t.NUMERICIDENTIFIER]})`) - -createToken('MAINVERSIONLOOSE', `(${src[t.NUMERICIDENTIFIERLOOSE]})\\.` + - `(${src[t.NUMERICIDENTIFIERLOOSE]})\\.` + - `(${src[t.NUMERICIDENTIFIERLOOSE]})`) - -// ## Pre-release Version Identifier -// A numeric identifier, or a non-numeric identifier. - -createToken('PRERELEASEIDENTIFIER', `(?:${src[t.NUMERICIDENTIFIER] -}|${src[t.NONNUMERICIDENTIFIER]})`) - -createToken('PRERELEASEIDENTIFIERLOOSE', `(?:${src[t.NUMERICIDENTIFIERLOOSE] -}|${src[t.NONNUMERICIDENTIFIER]})`) - -// ## Pre-release Version -// Hyphen, followed by one or more dot-separated pre-release version -// identifiers. - -createToken('PRERELEASE', `(?:-(${src[t.PRERELEASEIDENTIFIER] -}(?:\\.${src[t.PRERELEASEIDENTIFIER]})*))`) - -createToken('PRERELEASELOOSE', `(?:-?(${src[t.PRERELEASEIDENTIFIERLOOSE] -}(?:\\.${src[t.PRERELEASEIDENTIFIERLOOSE]})*))`) - -// ## Build Metadata Identifier -// Any combination of digits, letters, or hyphens. - -createToken('BUILDIDENTIFIER', `${LETTERDASHNUMBER}+`) - -// ## Build Metadata -// Plus sign, followed by one or more period-separated build metadata -// identifiers. - -createToken('BUILD', `(?:\\+(${src[t.BUILDIDENTIFIER] -}(?:\\.${src[t.BUILDIDENTIFIER]})*))`) - -// ## Full Version String -// A main version, followed optionally by a pre-release version and -// build metadata. - -// Note that the only major, minor, patch, and pre-release sections of -// the version string are capturing groups. The build metadata is not a -// capturing group, because it should not ever be used in version -// comparison. - -createToken('FULLPLAIN', `v?${src[t.MAINVERSION] -}${src[t.PRERELEASE]}?${ - src[t.BUILD]}?`) - -createToken('FULL', `^${src[t.FULLPLAIN]}$`) - -// like full, but allows v1.2.3 and =1.2.3, which people do sometimes. -// also, 1.0.0alpha1 (prerelease without the hyphen) which is pretty -// common in the npm registry. -createToken('LOOSEPLAIN', `[v=\\s]*${src[t.MAINVERSIONLOOSE] -}${src[t.PRERELEASELOOSE]}?${ - src[t.BUILD]}?`) - -createToken('LOOSE', `^${src[t.LOOSEPLAIN]}$`) - -createToken('GTLT', '((?:<|>)?=?)') - -// Something like "2.*" or "1.2.x". -// Note that "x.x" is a valid xRange identifer, meaning "any version" -// Only the first item is strictly required. -createToken('XRANGEIDENTIFIERLOOSE', `${src[t.NUMERICIDENTIFIERLOOSE]}|x|X|\\*`) -createToken('XRANGEIDENTIFIER', `${src[t.NUMERICIDENTIFIER]}|x|X|\\*`) - -createToken('XRANGEPLAIN', `[v=\\s]*(${src[t.XRANGEIDENTIFIER]})` + - `(?:\\.(${src[t.XRANGEIDENTIFIER]})` + - `(?:\\.(${src[t.XRANGEIDENTIFIER]})` + - `(?:${src[t.PRERELEASE]})?${ - src[t.BUILD]}?` + - `)?)?`) - -createToken('XRANGEPLAINLOOSE', `[v=\\s]*(${src[t.XRANGEIDENTIFIERLOOSE]})` + - `(?:\\.(${src[t.XRANGEIDENTIFIERLOOSE]})` + - `(?:\\.(${src[t.XRANGEIDENTIFIERLOOSE]})` + - `(?:${src[t.PRERELEASELOOSE]})?${ - src[t.BUILD]}?` + - `)?)?`) - -createToken('XRANGE', `^${src[t.GTLT]}\\s*${src[t.XRANGEPLAIN]}$`) -createToken('XRANGELOOSE', `^${src[t.GTLT]}\\s*${src[t.XRANGEPLAINLOOSE]}$`) - -// Coercion. -// Extract anything that could conceivably be a part of a valid semver -createToken('COERCEPLAIN', `${'(^|[^\\d])' + - '(\\d{1,'}${MAX_SAFE_COMPONENT_LENGTH}})` + - `(?:\\.(\\d{1,${MAX_SAFE_COMPONENT_LENGTH}}))?` + - `(?:\\.(\\d{1,${MAX_SAFE_COMPONENT_LENGTH}}))?`) -createToken('COERCE', `${src[t.COERCEPLAIN]}(?:$|[^\\d])`) -createToken('COERCEFULL', src[t.COERCEPLAIN] + - `(?:${src[t.PRERELEASE]})?` + - `(?:${src[t.BUILD]})?` + - `(?:$|[^\\d])`) -createToken('COERCERTL', src[t.COERCE], true) -createToken('COERCERTLFULL', src[t.COERCEFULL], true) - -// Tilde ranges. -// Meaning is "reasonably at or greater than" -createToken('LONETILDE', '(?:~>?)') - -createToken('TILDETRIM', `(\\s*)${src[t.LONETILDE]}\\s+`, true) -exports.tildeTrimReplace = '$1~' - -createToken('TILDE', `^${src[t.LONETILDE]}${src[t.XRANGEPLAIN]}$`) -createToken('TILDELOOSE', `^${src[t.LONETILDE]}${src[t.XRANGEPLAINLOOSE]}$`) - -// Caret ranges. -// Meaning is "at least and backwards compatible with" -createToken('LONECARET', '(?:\\^)') - -createToken('CARETTRIM', `(\\s*)${src[t.LONECARET]}\\s+`, true) -exports.caretTrimReplace = '$1^' - -createToken('CARET', `^${src[t.LONECARET]}${src[t.XRANGEPLAIN]}$`) -createToken('CARETLOOSE', `^${src[t.LONECARET]}${src[t.XRANGEPLAINLOOSE]}$`) - -// A simple gt/lt/eq thing, or just "" to indicate "any version" -createToken('COMPARATORLOOSE', `^${src[t.GTLT]}\\s*(${src[t.LOOSEPLAIN]})$|^$`) -createToken('COMPARATOR', `^${src[t.GTLT]}\\s*(${src[t.FULLPLAIN]})$|^$`) - -// An expression to strip any whitespace between the gtlt and the thing -// it modifies, so that `> 1.2.3` ==> `>1.2.3` -createToken('COMPARATORTRIM', `(\\s*)${src[t.GTLT] -}\\s*(${src[t.LOOSEPLAIN]}|${src[t.XRANGEPLAIN]})`, true) -exports.comparatorTrimReplace = '$1$2$3' - -// Something like `1.2.3 - 1.2.4` -// Note that these all use the loose form, because they'll be -// checked against either the strict or loose comparator form -// later. -createToken('HYPHENRANGE', `^\\s*(${src[t.XRANGEPLAIN]})` + - `\\s+-\\s+` + - `(${src[t.XRANGEPLAIN]})` + - `\\s*$`) - -createToken('HYPHENRANGELOOSE', `^\\s*(${src[t.XRANGEPLAINLOOSE]})` + - `\\s+-\\s+` + - `(${src[t.XRANGEPLAINLOOSE]})` + - `\\s*$`) - -// Star ranges basically just allow anything at all. -createToken('STAR', '(<|>)?=?\\s*\\*') -// >=0.0.0 is like a star -createToken('GTE0', '^\\s*>=\\s*0\\.0\\.0\\s*$') -createToken('GTE0PRE', '^\\s*>=\\s*0\\.0\\.0-0\\s*$') diff --git a/tools/eslint/node_modules/eslint-plugin-jsdoc/node_modules/semver/package.json b/tools/eslint/node_modules/eslint-plugin-jsdoc/node_modules/semver/package.json deleted file mode 100644 index cb8def45184df1..00000000000000 --- a/tools/eslint/node_modules/eslint-plugin-jsdoc/node_modules/semver/package.json +++ /dev/null @@ -1,77 +0,0 @@ -{ - "name": "semver", - "version": "7.6.2", - "description": "The semantic version parser used by npm.", - "main": "index.js", - "scripts": { - "test": "tap", - "snap": "tap", - "lint": "eslint \"**/*.{js,cjs,ts,mjs,jsx,tsx}\"", - "postlint": "template-oss-check", - "lintfix": "npm run lint -- --fix", - "posttest": "npm run lint", - "template-oss-apply": "template-oss-apply --force" - }, - "devDependencies": { - "@npmcli/eslint-config": "^4.0.0", - "@npmcli/template-oss": "4.22.0", - "benchmark": "^2.1.4", - "tap": "^16.0.0" - }, - "license": "ISC", - "repository": { - "type": "git", - "url": "git+https://github.com/npm/node-semver.git" - }, - "bin": { - "semver": "bin/semver.js" - }, - "files": [ - "bin/", - "lib/", - "classes/", - "functions/", - "internal/", - "ranges/", - "index.js", - "preload.js", - "range.bnf" - ], - "tap": { - "timeout": 30, - "coverage-map": "map.js", - "nyc-arg": [ - "--exclude", - "tap-snapshots/**" - ] - }, - "engines": { - "node": ">=10" - }, - "author": "GitHub Inc.", - "templateOSS": { - "//@npmcli/template-oss": "This file is partially managed by @npmcli/template-oss. Edits may be overwritten.", - "version": "4.22.0", - "engines": ">=10", - "distPaths": [ - "classes/", - "functions/", - "internal/", - "ranges/", - "index.js", - "preload.js", - "range.bnf" - ], - "allowPaths": [ - "/classes/", - "/functions/", - "/internal/", - "/ranges/", - "/index.js", - "/preload.js", - "/range.bnf", - "/benchmarks" - ], - "publish": "true" - } -} diff --git a/tools/eslint/node_modules/eslint-plugin-jsdoc/node_modules/semver/preload.js b/tools/eslint/node_modules/eslint-plugin-jsdoc/node_modules/semver/preload.js deleted file mode 100644 index 947cd4f7917fff..00000000000000 --- a/tools/eslint/node_modules/eslint-plugin-jsdoc/node_modules/semver/preload.js +++ /dev/null @@ -1,2 +0,0 @@ -// XXX remove in v8 or beyond -module.exports = require('./index.js') diff --git a/tools/eslint/node_modules/eslint-plugin-jsdoc/node_modules/semver/range.bnf b/tools/eslint/node_modules/eslint-plugin-jsdoc/node_modules/semver/range.bnf deleted file mode 100644 index d4c6ae0d76c9ac..00000000000000 --- a/tools/eslint/node_modules/eslint-plugin-jsdoc/node_modules/semver/range.bnf +++ /dev/null @@ -1,16 +0,0 @@ -range-set ::= range ( logical-or range ) * -logical-or ::= ( ' ' ) * '||' ( ' ' ) * -range ::= hyphen | simple ( ' ' simple ) * | '' -hyphen ::= partial ' - ' partial -simple ::= primitive | partial | tilde | caret -primitive ::= ( '<' | '>' | '>=' | '<=' | '=' ) partial -partial ::= xr ( '.' xr ( '.' xr qualifier ? )? )? -xr ::= 'x' | 'X' | '*' | nr -nr ::= '0' | [1-9] ( [0-9] ) * -tilde ::= '~' partial -caret ::= '^' partial -qualifier ::= ( '-' pre )? ( '+' build )? -pre ::= parts -build ::= parts -parts ::= part ( '.' part ) * -part ::= nr | [-0-9A-Za-z]+ diff --git a/tools/eslint/node_modules/eslint-plugin-jsdoc/node_modules/semver/ranges/gtr.js b/tools/eslint/node_modules/eslint-plugin-jsdoc/node_modules/semver/ranges/gtr.js deleted file mode 100644 index db7e35599dd566..00000000000000 --- a/tools/eslint/node_modules/eslint-plugin-jsdoc/node_modules/semver/ranges/gtr.js +++ /dev/null @@ -1,4 +0,0 @@ -// Determine if version is greater than all the versions possible in the range. -const outside = require('./outside') -const gtr = (version, range, options) => outside(version, range, '>', options) -module.exports = gtr diff --git a/tools/eslint/node_modules/eslint-plugin-jsdoc/node_modules/semver/ranges/intersects.js b/tools/eslint/node_modules/eslint-plugin-jsdoc/node_modules/semver/ranges/intersects.js deleted file mode 100644 index e0e9b7ce000e47..00000000000000 --- a/tools/eslint/node_modules/eslint-plugin-jsdoc/node_modules/semver/ranges/intersects.js +++ /dev/null @@ -1,7 +0,0 @@ -const Range = require('../classes/range') -const intersects = (r1, r2, options) => { - r1 = new Range(r1, options) - r2 = new Range(r2, options) - return r1.intersects(r2, options) -} -module.exports = intersects diff --git a/tools/eslint/node_modules/eslint-plugin-jsdoc/node_modules/semver/ranges/ltr.js b/tools/eslint/node_modules/eslint-plugin-jsdoc/node_modules/semver/ranges/ltr.js deleted file mode 100644 index 528a885ebdfcdb..00000000000000 --- a/tools/eslint/node_modules/eslint-plugin-jsdoc/node_modules/semver/ranges/ltr.js +++ /dev/null @@ -1,4 +0,0 @@ -const outside = require('./outside') -// Determine if version is less than all the versions possible in the range -const ltr = (version, range, options) => outside(version, range, '<', options) -module.exports = ltr diff --git a/tools/eslint/node_modules/eslint-plugin-jsdoc/node_modules/semver/ranges/max-satisfying.js b/tools/eslint/node_modules/eslint-plugin-jsdoc/node_modules/semver/ranges/max-satisfying.js deleted file mode 100644 index 6e3d993c67860c..00000000000000 --- a/tools/eslint/node_modules/eslint-plugin-jsdoc/node_modules/semver/ranges/max-satisfying.js +++ /dev/null @@ -1,25 +0,0 @@ -const SemVer = require('../classes/semver') -const Range = require('../classes/range') - -const maxSatisfying = (versions, range, options) => { - let max = null - let maxSV = null - let rangeObj = null - try { - rangeObj = new Range(range, options) - } catch (er) { - return null - } - versions.forEach((v) => { - if (rangeObj.test(v)) { - // satisfies(v, range, options) - if (!max || maxSV.compare(v) === -1) { - // compare(max, v, true) - max = v - maxSV = new SemVer(max, options) - } - } - }) - return max -} -module.exports = maxSatisfying diff --git a/tools/eslint/node_modules/eslint-plugin-jsdoc/node_modules/semver/ranges/min-satisfying.js b/tools/eslint/node_modules/eslint-plugin-jsdoc/node_modules/semver/ranges/min-satisfying.js deleted file mode 100644 index 9b60974e2253a0..00000000000000 --- a/tools/eslint/node_modules/eslint-plugin-jsdoc/node_modules/semver/ranges/min-satisfying.js +++ /dev/null @@ -1,24 +0,0 @@ -const SemVer = require('../classes/semver') -const Range = require('../classes/range') -const minSatisfying = (versions, range, options) => { - let min = null - let minSV = null - let rangeObj = null - try { - rangeObj = new Range(range, options) - } catch (er) { - return null - } - versions.forEach((v) => { - if (rangeObj.test(v)) { - // satisfies(v, range, options) - if (!min || minSV.compare(v) === 1) { - // compare(min, v, true) - min = v - minSV = new SemVer(min, options) - } - } - }) - return min -} -module.exports = minSatisfying diff --git a/tools/eslint/node_modules/eslint-plugin-jsdoc/node_modules/semver/ranges/min-version.js b/tools/eslint/node_modules/eslint-plugin-jsdoc/node_modules/semver/ranges/min-version.js deleted file mode 100644 index 350e1f78368ea2..00000000000000 --- a/tools/eslint/node_modules/eslint-plugin-jsdoc/node_modules/semver/ranges/min-version.js +++ /dev/null @@ -1,61 +0,0 @@ -const SemVer = require('../classes/semver') -const Range = require('../classes/range') -const gt = require('../functions/gt') - -const minVersion = (range, loose) => { - range = new Range(range, loose) - - let minver = new SemVer('0.0.0') - if (range.test(minver)) { - return minver - } - - minver = new SemVer('0.0.0-0') - if (range.test(minver)) { - return minver - } - - minver = null - for (let i = 0; i < range.set.length; ++i) { - const comparators = range.set[i] - - let setMin = null - comparators.forEach((comparator) => { - // Clone to avoid manipulating the comparator's semver object. - const compver = new SemVer(comparator.semver.version) - switch (comparator.operator) { - case '>': - if (compver.prerelease.length === 0) { - compver.patch++ - } else { - compver.prerelease.push(0) - } - compver.raw = compver.format() - /* fallthrough */ - case '': - case '>=': - if (!setMin || gt(compver, setMin)) { - setMin = compver - } - break - case '<': - case '<=': - /* Ignore maximum versions */ - break - /* istanbul ignore next */ - default: - throw new Error(`Unexpected operation: ${comparator.operator}`) - } - }) - if (setMin && (!minver || gt(minver, setMin))) { - minver = setMin - } - } - - if (minver && range.test(minver)) { - return minver - } - - return null -} -module.exports = minVersion diff --git a/tools/eslint/node_modules/eslint-plugin-jsdoc/node_modules/semver/ranges/outside.js b/tools/eslint/node_modules/eslint-plugin-jsdoc/node_modules/semver/ranges/outside.js deleted file mode 100644 index ae99b10a5b9e6a..00000000000000 --- a/tools/eslint/node_modules/eslint-plugin-jsdoc/node_modules/semver/ranges/outside.js +++ /dev/null @@ -1,80 +0,0 @@ -const SemVer = require('../classes/semver') -const Comparator = require('../classes/comparator') -const { ANY } = Comparator -const Range = require('../classes/range') -const satisfies = require('../functions/satisfies') -const gt = require('../functions/gt') -const lt = require('../functions/lt') -const lte = require('../functions/lte') -const gte = require('../functions/gte') - -const outside = (version, range, hilo, options) => { - version = new SemVer(version, options) - range = new Range(range, options) - - let gtfn, ltefn, ltfn, comp, ecomp - switch (hilo) { - case '>': - gtfn = gt - ltefn = lte - ltfn = lt - comp = '>' - ecomp = '>=' - break - case '<': - gtfn = lt - ltefn = gte - ltfn = gt - comp = '<' - ecomp = '<=' - break - default: - throw new TypeError('Must provide a hilo val of "<" or ">"') - } - - // If it satisfies the range it is not outside - if (satisfies(version, range, options)) { - return false - } - - // From now on, variable terms are as if we're in "gtr" mode. - // but note that everything is flipped for the "ltr" function. - - for (let i = 0; i < range.set.length; ++i) { - const comparators = range.set[i] - - let high = null - let low = null - - comparators.forEach((comparator) => { - if (comparator.semver === ANY) { - comparator = new Comparator('>=0.0.0') - } - high = high || comparator - low = low || comparator - if (gtfn(comparator.semver, high.semver, options)) { - high = comparator - } else if (ltfn(comparator.semver, low.semver, options)) { - low = comparator - } - }) - - // If the edge version comparator has a operator then our version - // isn't outside it - if (high.operator === comp || high.operator === ecomp) { - return false - } - - // If the lowest version comparator has an operator and our version - // is less than it then it isn't higher than the range - if ((!low.operator || low.operator === comp) && - ltefn(version, low.semver)) { - return false - } else if (low.operator === ecomp && ltfn(version, low.semver)) { - return false - } - } - return true -} - -module.exports = outside diff --git a/tools/eslint/node_modules/eslint-plugin-jsdoc/node_modules/semver/ranges/simplify.js b/tools/eslint/node_modules/eslint-plugin-jsdoc/node_modules/semver/ranges/simplify.js deleted file mode 100644 index 618d5b62735518..00000000000000 --- a/tools/eslint/node_modules/eslint-plugin-jsdoc/node_modules/semver/ranges/simplify.js +++ /dev/null @@ -1,47 +0,0 @@ -// given a set of versions and a range, create a "simplified" range -// that includes the same versions that the original range does -// If the original range is shorter than the simplified one, return that. -const satisfies = require('../functions/satisfies.js') -const compare = require('../functions/compare.js') -module.exports = (versions, range, options) => { - const set = [] - let first = null - let prev = null - const v = versions.sort((a, b) => compare(a, b, options)) - for (const version of v) { - const included = satisfies(version, range, options) - if (included) { - prev = version - if (!first) { - first = version - } - } else { - if (prev) { - set.push([first, prev]) - } - prev = null - first = null - } - } - if (first) { - set.push([first, null]) - } - - const ranges = [] - for (const [min, max] of set) { - if (min === max) { - ranges.push(min) - } else if (!max && min === v[0]) { - ranges.push('*') - } else if (!max) { - ranges.push(`>=${min}`) - } else if (min === v[0]) { - ranges.push(`<=${max}`) - } else { - ranges.push(`${min} - ${max}`) - } - } - const simplified = ranges.join(' || ') - const original = typeof range.raw === 'string' ? range.raw : String(range) - return simplified.length < original.length ? simplified : range -} diff --git a/tools/eslint/node_modules/eslint-plugin-jsdoc/node_modules/semver/ranges/subset.js b/tools/eslint/node_modules/eslint-plugin-jsdoc/node_modules/semver/ranges/subset.js deleted file mode 100644 index 1e5c26837c047d..00000000000000 --- a/tools/eslint/node_modules/eslint-plugin-jsdoc/node_modules/semver/ranges/subset.js +++ /dev/null @@ -1,247 +0,0 @@ -const Range = require('../classes/range.js') -const Comparator = require('../classes/comparator.js') -const { ANY } = Comparator -const satisfies = require('../functions/satisfies.js') -const compare = require('../functions/compare.js') - -// Complex range `r1 || r2 || ...` is a subset of `R1 || R2 || ...` iff: -// - Every simple range `r1, r2, ...` is a null set, OR -// - Every simple range `r1, r2, ...` which is not a null set is a subset of -// some `R1, R2, ...` -// -// Simple range `c1 c2 ...` is a subset of simple range `C1 C2 ...` iff: -// - If c is only the ANY comparator -// - If C is only the ANY comparator, return true -// - Else if in prerelease mode, return false -// - else replace c with `[>=0.0.0]` -// - If C is only the ANY comparator -// - if in prerelease mode, return true -// - else replace C with `[>=0.0.0]` -// - Let EQ be the set of = comparators in c -// - If EQ is more than one, return true (null set) -// - Let GT be the highest > or >= comparator in c -// - Let LT be the lowest < or <= comparator in c -// - If GT and LT, and GT.semver > LT.semver, return true (null set) -// - If any C is a = range, and GT or LT are set, return false -// - If EQ -// - If GT, and EQ does not satisfy GT, return true (null set) -// - If LT, and EQ does not satisfy LT, return true (null set) -// - If EQ satisfies every C, return true -// - Else return false -// - If GT -// - If GT.semver is lower than any > or >= comp in C, return false -// - If GT is >=, and GT.semver does not satisfy every C, return false -// - If GT.semver has a prerelease, and not in prerelease mode -// - If no C has a prerelease and the GT.semver tuple, return false -// - If LT -// - If LT.semver is greater than any < or <= comp in C, return false -// - If LT is <=, and LT.semver does not satisfy every C, return false -// - If GT.semver has a prerelease, and not in prerelease mode -// - If no C has a prerelease and the LT.semver tuple, return false -// - Else return true - -const subset = (sub, dom, options = {}) => { - if (sub === dom) { - return true - } - - sub = new Range(sub, options) - dom = new Range(dom, options) - let sawNonNull = false - - OUTER: for (const simpleSub of sub.set) { - for (const simpleDom of dom.set) { - const isSub = simpleSubset(simpleSub, simpleDom, options) - sawNonNull = sawNonNull || isSub !== null - if (isSub) { - continue OUTER - } - } - // the null set is a subset of everything, but null simple ranges in - // a complex range should be ignored. so if we saw a non-null range, - // then we know this isn't a subset, but if EVERY simple range was null, - // then it is a subset. - if (sawNonNull) { - return false - } - } - return true -} - -const minimumVersionWithPreRelease = [new Comparator('>=0.0.0-0')] -const minimumVersion = [new Comparator('>=0.0.0')] - -const simpleSubset = (sub, dom, options) => { - if (sub === dom) { - return true - } - - if (sub.length === 1 && sub[0].semver === ANY) { - if (dom.length === 1 && dom[0].semver === ANY) { - return true - } else if (options.includePrerelease) { - sub = minimumVersionWithPreRelease - } else { - sub = minimumVersion - } - } - - if (dom.length === 1 && dom[0].semver === ANY) { - if (options.includePrerelease) { - return true - } else { - dom = minimumVersion - } - } - - const eqSet = new Set() - let gt, lt - for (const c of sub) { - if (c.operator === '>' || c.operator === '>=') { - gt = higherGT(gt, c, options) - } else if (c.operator === '<' || c.operator === '<=') { - lt = lowerLT(lt, c, options) - } else { - eqSet.add(c.semver) - } - } - - if (eqSet.size > 1) { - return null - } - - let gtltComp - if (gt && lt) { - gtltComp = compare(gt.semver, lt.semver, options) - if (gtltComp > 0) { - return null - } else if (gtltComp === 0 && (gt.operator !== '>=' || lt.operator !== '<=')) { - return null - } - } - - // will iterate one or zero times - for (const eq of eqSet) { - if (gt && !satisfies(eq, String(gt), options)) { - return null - } - - if (lt && !satisfies(eq, String(lt), options)) { - return null - } - - for (const c of dom) { - if (!satisfies(eq, String(c), options)) { - return false - } - } - - return true - } - - let higher, lower - let hasDomLT, hasDomGT - // if the subset has a prerelease, we need a comparator in the superset - // with the same tuple and a prerelease, or it's not a subset - let needDomLTPre = lt && - !options.includePrerelease && - lt.semver.prerelease.length ? lt.semver : false - let needDomGTPre = gt && - !options.includePrerelease && - gt.semver.prerelease.length ? gt.semver : false - // exception: <1.2.3-0 is the same as <1.2.3 - if (needDomLTPre && needDomLTPre.prerelease.length === 1 && - lt.operator === '<' && needDomLTPre.prerelease[0] === 0) { - needDomLTPre = false - } - - for (const c of dom) { - hasDomGT = hasDomGT || c.operator === '>' || c.operator === '>=' - hasDomLT = hasDomLT || c.operator === '<' || c.operator === '<=' - if (gt) { - if (needDomGTPre) { - if (c.semver.prerelease && c.semver.prerelease.length && - c.semver.major === needDomGTPre.major && - c.semver.minor === needDomGTPre.minor && - c.semver.patch === needDomGTPre.patch) { - needDomGTPre = false - } - } - if (c.operator === '>' || c.operator === '>=') { - higher = higherGT(gt, c, options) - if (higher === c && higher !== gt) { - return false - } - } else if (gt.operator === '>=' && !satisfies(gt.semver, String(c), options)) { - return false - } - } - if (lt) { - if (needDomLTPre) { - if (c.semver.prerelease && c.semver.prerelease.length && - c.semver.major === needDomLTPre.major && - c.semver.minor === needDomLTPre.minor && - c.semver.patch === needDomLTPre.patch) { - needDomLTPre = false - } - } - if (c.operator === '<' || c.operator === '<=') { - lower = lowerLT(lt, c, options) - if (lower === c && lower !== lt) { - return false - } - } else if (lt.operator === '<=' && !satisfies(lt.semver, String(c), options)) { - return false - } - } - if (!c.operator && (lt || gt) && gtltComp !== 0) { - return false - } - } - - // if there was a < or >, and nothing in the dom, then must be false - // UNLESS it was limited by another range in the other direction. - // Eg, >1.0.0 <1.0.1 is still a subset of <2.0.0 - if (gt && hasDomLT && !lt && gtltComp !== 0) { - return false - } - - if (lt && hasDomGT && !gt && gtltComp !== 0) { - return false - } - - // we needed a prerelease range in a specific tuple, but didn't get one - // then this isn't a subset. eg >=1.2.3-pre is not a subset of >=1.0.0, - // because it includes prereleases in the 1.2.3 tuple - if (needDomGTPre || needDomLTPre) { - return false - } - - return true -} - -// >=1.2.3 is lower than >1.2.3 -const higherGT = (a, b, options) => { - if (!a) { - return b - } - const comp = compare(a.semver, b.semver, options) - return comp > 0 ? a - : comp < 0 ? b - : b.operator === '>' && a.operator === '>=' ? b - : a -} - -// <=1.2.3 is higher than <1.2.3 -const lowerLT = (a, b, options) => { - if (!a) { - return b - } - const comp = compare(a.semver, b.semver, options) - return comp < 0 ? a - : comp > 0 ? b - : b.operator === '<' && a.operator === '<=' ? b - : a -} - -module.exports = subset diff --git a/tools/eslint/node_modules/eslint-plugin-jsdoc/node_modules/semver/ranges/to-comparators.js b/tools/eslint/node_modules/eslint-plugin-jsdoc/node_modules/semver/ranges/to-comparators.js deleted file mode 100644 index 6c8bc7e6f15a40..00000000000000 --- a/tools/eslint/node_modules/eslint-plugin-jsdoc/node_modules/semver/ranges/to-comparators.js +++ /dev/null @@ -1,8 +0,0 @@ -const Range = require('../classes/range') - -// Mostly just for testing and legacy API reasons -const toComparators = (range, options) => - new Range(range, options).set - .map(comp => comp.map(c => c.value).join(' ').trim().split(' ')) - -module.exports = toComparators diff --git a/tools/eslint/node_modules/eslint-plugin-jsdoc/node_modules/semver/ranges/valid.js b/tools/eslint/node_modules/eslint-plugin-jsdoc/node_modules/semver/ranges/valid.js deleted file mode 100644 index 365f35689d358b..00000000000000 --- a/tools/eslint/node_modules/eslint-plugin-jsdoc/node_modules/semver/ranges/valid.js +++ /dev/null @@ -1,11 +0,0 @@ -const Range = require('../classes/range') -const validRange = (range, options) => { - try { - // Return '*' instead of '' so that truthiness works. - // This will throw if it's invalid anyway - return new Range(range, options).range || '*' - } catch (er) { - return null - } -} -module.exports = validRange diff --git a/tools/eslint/node_modules/eslint-plugin-jsdoc/package.json b/tools/eslint/node_modules/eslint-plugin-jsdoc/package.json deleted file mode 100644 index 4ee9c3c83147fd..00000000000000 --- a/tools/eslint/node_modules/eslint-plugin-jsdoc/package.json +++ /dev/null @@ -1,148 +0,0 @@ -{ - "author": { - "email": "gajus@gajus.com", - "name": "Gajus Kuizinas", - "url": "http://gajus.com" - }, - "dependencies": { - "@es-joy/jsdoccomment": "~0.46.0", - "are-docs-informative": "^0.0.2", - "comment-parser": "1.4.1", - "debug": "^4.3.5", - "escape-string-regexp": "^4.0.0", - "esquery": "^1.6.0", - "parse-imports": "^2.1.1", - "semver": "^7.6.2", - "spdx-expression-parse": "^4.0.0", - "synckit": "^0.9.0" - }, - "description": "JSDoc linting rules for ESLint.", - "devDependencies": { - "@babel/cli": "^7.24.7", - "@babel/core": "^7.24.7", - "@babel/eslint-parser": "^7.24.7", - "@babel/node": "^7.24.7", - "@babel/plugin-syntax-class-properties": "^7.12.13", - "@babel/plugin-transform-flow-strip-types": "^7.24.7", - "@babel/preset-env": "^7.24.7", - "@es-joy/escodegen": "^3.5.1", - "@es-joy/jsdoc-eslint-parser": "^0.21.1", - "@hkdobrev/run-if-changed": "^0.3.1", - "@semantic-release/commit-analyzer": "^13.0.0", - "@semantic-release/github": "^10.1.0", - "@semantic-release/npm": "^12.0.1", - "@types/chai": "^4.3.16", - "@types/debug": "^4.1.12", - "@types/eslint": "^8.56.10", - "@types/esquery": "^1.5.4", - "@types/estree": "^1.0.5", - "@types/json-schema": "^7.0.15", - "@types/lodash.defaultsdeep": "^4.6.9", - "@types/mocha": "^10.0.7", - "@types/node": "^20.14.10", - "@types/semver": "^7.5.8", - "@types/spdx-expression-parse": "^3.0.5", - "@typescript-eslint/types": "^7.16.0", - "babel-plugin-add-module-exports": "^1.0.4", - "babel-plugin-istanbul": "^7.0.0", - "babel-plugin-transform-import-meta": "^2.2.1", - "c8": "^10.1.2", - "camelcase": "^8.0.0", - "chai": "^5.1.1", - "cross-env": "^7.0.3", - "decamelize": "^6.0.0", - "eslint": "9.6.0", - "eslint-config-canonical": "~43.0.13", - "espree": "^10.1.0", - "gitdown": "^4.0.0", - "glob": "^10.4.2", - "globals": "^15.8.0", - "husky": "^9.0.11", - "jsdoc-type-pratt-parser": "^4.0.0", - "json-schema": "^0.4.0", - "lint-staged": "^15.2.7", - "lodash.defaultsdeep": "^4.6.1", - "mocha": "^10.6.0", - "open-editor": "^4.1.1", - "replace": "^1.2.2", - "rimraf": "^5.0.7", - "semantic-release": "^24.0.0", - "typescript": "5.5.x", - "typescript-eslint": "^8.0.0-alpha.34" - }, - "engines": { - "node": ">=18" - }, - "keywords": [ - "eslint", - "plugin", - "jsdoc" - ], - "license": "BSD-3-Clause", - "lint-staged": { - ".eslintignore": [ - "npm run lint-fix", - "git add ." - ], - "*.js": "npm run lint-arg -- --fix" - }, - "type": "module", - "main": "./dist/index.cjs", - "types": "./dist/index.d.ts", - "exports": { - "types": "./dist/index.d.ts", - "import": "./src/index.js", - "require": "./dist/index.cjs" - }, - "name": "eslint-plugin-jsdoc", - "mocha": { - "reporter": "dot", - "recursive": true, - "timeout": 12000 - }, - "c8": { - "branches": 100, - "check-coverage": true, - "exclude": [ - "src/rules/checkExamples.js" - ], - "functions": 100, - "include": [ - "src/" - ], - "instrument": false, - "lines": 100, - "reporter": "text-summary", - "sourceMap": false, - "statements": 100 - }, - "peerDependencies": { - "eslint": "^7.0.0 || ^8.0.0 || ^9.0.0" - }, - "repository": { - "type": "git", - "url": "https://github.com/gajus/eslint-plugin-jsdoc" - }, - "run-if-changed": { - "package-lock.json": "npm run install-offline" - }, - "scripts": { - "tsc": "tsc", - "tsc-build": "tsc -p tsconfig-prod.json", - "build": "rimraf ./dist && cross-env NODE_ENV=production babel ./src --out-file-extension .cjs --out-dir ./dist --copy-files --source-maps --ignore ./src/bin/*.js --no-copy-ignored && replace 'require\\(\"\\.(.*?)\\.[^.]*?\"\\)' 'require(\".$1.cjs\")' 'dist' -r --include=\"*.cjs\" && cp src/import-worker.mjs dist/import-worker.mjs && pnpm tsc-build", - "check-docs": "babel-node ./src/bin/generateDocs.js --check", - "create-docs": "npm run create-options && babel-node ./src/bin/generateDocs.js", - "create-rule": "babel-node ./src/bin/generateRule.js", - "create-options": "node ./src/bin/generateOptions.mjs", - "install-offline": "pnpm install --prefer-offline --no-audit", - "lint": "npm run lint-arg -- .", - "lint-arg": "eslint", - "lint-fix": "npm run lint-arg -- --fix .", - "prepare": "husky", - "test-no-cov": "cross-env BABEL_ENV=test mocha", - "test": "c8 npm run test-no-cov", - "test-cov": "cross-env TIMING=1 c8 --reporter text npm run test-no-cov", - "test-index": "npm run test-no-cov -- test/rules/index.js" - }, - "version": "48.7.0" -} diff --git a/tools/eslint/node_modules/eslint-plugin-jsdoc/src/WarnSettings.js b/tools/eslint/node_modules/eslint-plugin-jsdoc/src/WarnSettings.js deleted file mode 100644 index aee7c92bf7614b..00000000000000 --- a/tools/eslint/node_modules/eslint-plugin-jsdoc/src/WarnSettings.js +++ /dev/null @@ -1,34 +0,0 @@ -const WarnSettings = function () { - /** @type {WeakMap>} */ - const warnedSettings = new WeakMap(); - - return { - /** - * Warn only once for each context and setting - * @param {import('eslint').Rule.RuleContext} context - * @param {string} setting - * @returns {boolean} - */ - hasBeenWarned (context, setting) { - return warnedSettings.has(context) && /** @type {Set} */ ( - warnedSettings.get(context) - ).has(setting); - }, - - /** - * @param {import('eslint').Rule.RuleContext} context - * @param {string} setting - * @returns {void} - */ - markSettingAsWarned (context, setting) { - // c8 ignore else - if (!warnedSettings.has(context)) { - warnedSettings.set(context, new Set()); - } - - /** @type {Set} */ (warnedSettings.get(context)).add(setting); - }, - }; -}; - -export default WarnSettings; diff --git a/tools/eslint/node_modules/eslint-plugin-jsdoc/src/alignTransform.js b/tools/eslint/node_modules/eslint-plugin-jsdoc/src/alignTransform.js deleted file mode 100644 index 46871e7d57d5fe..00000000000000 --- a/tools/eslint/node_modules/eslint-plugin-jsdoc/src/alignTransform.js +++ /dev/null @@ -1,358 +0,0 @@ -/** - * Transform based on https://github.com/syavorsky/comment-parser/blob/master/src/transforms/align.ts - * - * It contains some customizations to align based on the tags, and some custom options. - */ - -import { - // `comment-parser/primitives` export - util, -} from 'comment-parser'; - -/** - * @typedef {{ - * hasNoTypes: boolean, - * maxNamedTagLength: import('./iterateJsdoc.js').Integer, - * maxUnnamedTagLength: import('./iterateJsdoc.js').Integer - * }} TypelessInfo - */ - -const { - rewireSource, -} = util; - -/** - * @typedef {{ - * name: import('./iterateJsdoc.js').Integer, - * start: import('./iterateJsdoc.js').Integer, - * tag: import('./iterateJsdoc.js').Integer, - * type: import('./iterateJsdoc.js').Integer - * }} Width - */ - -/** @type {Width} */ -const zeroWidth = { - name: 0, - start: 0, - tag: 0, - type: 0, -}; - -/** - * @param {string[]} tags - * @param {import('./iterateJsdoc.js').Integer} index - * @param {import('comment-parser').Line[]} source - * @returns {boolean} - */ -const shouldAlign = (tags, index, source) => { - const tag = source[index].tokens.tag.replace('@', ''); - const includesTag = tags.includes(tag); - - if (includesTag) { - return true; - } - - if (tag !== '') { - return false; - } - - for (let iterator = index; iterator >= 0; iterator--) { - const previousTag = source[iterator].tokens.tag.replace('@', ''); - - if (previousTag !== '') { - if (tags.includes(previousTag)) { - return true; - } - - return false; - } - } - - return true; -}; - -/** - * @param {string[]} tags - * @returns {( - * width: Width, - * line: { - * tokens: import('comment-parser').Tokens - * }, - * index: import('./iterateJsdoc.js').Integer, - * source: import('comment-parser').Line[] - * ) => Width} - */ -const getWidth = (tags) => { - return (width, { - tokens, - }, index, source) => { - if (!shouldAlign(tags, index, source)) { - return width; - } - - return { - name: Math.max(width.name, tokens.name.length), - start: tokens.delimiter === '/**' ? tokens.start.length : width.start, - tag: Math.max(width.tag, tokens.tag.length), - type: Math.max(width.type, tokens.type.length), - }; - }; -}; - -/** - * @param {{ - * description: string; - * tags: import('comment-parser').Spec[]; - * problems: import('comment-parser').Problem[]; - * }} fields - * @returns {TypelessInfo} - */ -const getTypelessInfo = (fields) => { - const hasNoTypes = fields.tags.every(({ - type, - }) => { - return !type; - }); - const maxNamedTagLength = Math.max(...fields.tags.map(({ - tag, - name, - }) => { - return name.length === 0 ? -1 : tag.length; - }).filter((length) => { - return length !== -1; - })) + 1; - const maxUnnamedTagLength = Math.max(...fields.tags.map(({ - tag, - name, - }) => { - return name.length === 0 ? tag.length : -1; - }).filter((length) => { - return length !== -1; - })) + 1; - return { - hasNoTypes, - maxNamedTagLength, - maxUnnamedTagLength, - }; -}; - -/** - * @param {import('./iterateJsdoc.js').Integer} len - * @returns {string} - */ -const space = (len) => { - return ''.padStart(len, ' '); -}; - -/** - * @param {{ - * customSpacings: import('../src/rules/checkLineAlignment.js').CustomSpacings, - * tags: string[], - * indent: string, - * preserveMainDescriptionPostDelimiter: boolean, - * wrapIndent: string, - * disableWrapIndent: boolean, - * }} cfg - * @returns {( - * block: import('comment-parser').Block - * ) => import('comment-parser').Block} - */ -const alignTransform = ({ - customSpacings, - tags, - indent, - preserveMainDescriptionPostDelimiter, - wrapIndent, - disableWrapIndent, -}) => { - let intoTags = false; - /** @type {Width} */ - let width; - - /** - * @param {import('comment-parser').Tokens} tokens - * @param {TypelessInfo} typelessInfo - * @returns {import('comment-parser').Tokens} - */ - const alignTokens = (tokens, typelessInfo) => { - const nothingAfter = { - delim: false, - name: false, - tag: false, - type: false, - }; - - if (tokens.description === '') { - nothingAfter.name = true; - tokens.postName = ''; - - if (tokens.name === '') { - nothingAfter.type = true; - tokens.postType = ''; - - if (tokens.type === '') { - nothingAfter.tag = true; - tokens.postTag = ''; - - /* c8 ignore next: Never happens because the !intoTags return. But it's here for consistency with the original align transform */ - if (tokens.tag === '') { - nothingAfter.delim = true; - } - } - } - } - - let untypedNameAdjustment = 0; - let untypedTypeAdjustment = 0; - if (typelessInfo.hasNoTypes) { - nothingAfter.tag = true; - tokens.postTag = ''; - if (tokens.name === '') { - untypedNameAdjustment = typelessInfo.maxNamedTagLength - tokens.tag.length; - } else { - untypedNameAdjustment = typelessInfo.maxNamedTagLength > typelessInfo.maxUnnamedTagLength ? 0 : - Math.max(0, typelessInfo.maxUnnamedTagLength - (tokens.tag.length + tokens.name.length + 1)); - untypedTypeAdjustment = typelessInfo.maxNamedTagLength - tokens.tag.length; - } - } - - // Todo: Avoid fixing alignment of blocks with multiline wrapping of type - if (tokens.tag === '' && tokens.type) { - return tokens; - } - - const spacings = { - postDelimiter: customSpacings?.postDelimiter || 1, - postName: customSpacings?.postName || 1, - postTag: customSpacings?.postTag || 1, - postType: customSpacings?.postType || 1, - }; - - tokens.postDelimiter = nothingAfter.delim ? '' : space(spacings.postDelimiter); - - if (!nothingAfter.tag) { - tokens.postTag = space(width.tag - tokens.tag.length + spacings.postTag); - } - - if (!nothingAfter.type) { - tokens.postType = space(width.type - tokens.type.length + spacings.postType + untypedTypeAdjustment); - } - - if (!nothingAfter.name) { - // If post name is empty for all lines (name width 0), don't add post name spacing. - tokens.postName = width.name === 0 ? '' : space(width.name - tokens.name.length + spacings.postName + untypedNameAdjustment); - } - - return tokens; - }; - - /** - * @param {import('comment-parser').Line} line - * @param {import('./iterateJsdoc.js').Integer} index - * @param {import('comment-parser').Line[]} source - * @param {TypelessInfo} typelessInfo - * @param {string|false} indentTag - * @returns {import('comment-parser').Line} - */ - const update = (line, index, source, typelessInfo, indentTag) => { - /** @type {import('comment-parser').Tokens} */ - const tokens = { - ...line.tokens, - }; - - if (tokens.tag !== '') { - intoTags = true; - } - - const isEmpty = - tokens.tag === '' && - tokens.name === '' && - tokens.type === '' && - tokens.description === ''; - - // dangling '*/' - if (tokens.end === '*/' && isEmpty) { - tokens.start = indent + ' '; - - return { - ...line, - tokens, - }; - } - - switch (tokens.delimiter) { - case '/**': - tokens.start = indent; - break; - case '*': - tokens.start = indent + ' '; - break; - default: - tokens.delimiter = ''; - - // compensate delimiter - tokens.start = indent + ' '; - } - - if (!intoTags) { - if (tokens.description === '') { - tokens.postDelimiter = ''; - } else if (!preserveMainDescriptionPostDelimiter) { - tokens.postDelimiter = ' '; - } - - return { - ...line, - tokens, - }; - } - - const postHyphenSpacing = customSpacings?.postHyphen ?? 1; - const hyphenSpacing = /^\s*-\s+/u; - tokens.description = tokens.description.replace( - hyphenSpacing, '-' + ''.padStart(postHyphenSpacing, ' '), - ); - - // Not align. - if (shouldAlign(tags, index, source)) { - alignTokens(tokens, typelessInfo); - if (!disableWrapIndent && indentTag) { - tokens.postDelimiter += wrapIndent; - } - } - - return { - ...line, - tokens, - }; - }; - - return ({ - source, - ...fields - }) => { - width = source.reduce(getWidth(tags), { - ...zeroWidth, - }); - - const typelessInfo = getTypelessInfo(fields); - - let tagIndentMode = false; - - return rewireSource({ - ...fields, - source: source.map((line, index) => { - const indentTag = !disableWrapIndent && tagIndentMode && !line.tokens.tag && line.tokens.description; - const ret = update(line, index, source, typelessInfo, indentTag); - - if (!disableWrapIndent && line.tokens.tag) { - tagIndentMode = true; - } - - return ret; - }), - }); - }; -}; - -export default alignTransform; diff --git a/tools/eslint/node_modules/eslint-plugin-jsdoc/src/defaultTagOrder.js b/tools/eslint/node_modules/eslint-plugin-jsdoc/src/defaultTagOrder.js deleted file mode 100644 index 6bcf0e8ebcee30..00000000000000 --- a/tools/eslint/node_modules/eslint-plugin-jsdoc/src/defaultTagOrder.js +++ /dev/null @@ -1,169 +0,0 @@ -const defaultTagOrder = [ - { - tags: [ - // Brief descriptions - 'summary', - 'typeSummary', - - // Module/file-level - 'module', - 'exports', - 'file', - 'fileoverview', - 'overview', - 'import', - - // Identifying (name, type) - 'typedef', - 'interface', - 'record', - 'template', - 'name', - 'kind', - 'type', - 'alias', - 'external', - 'host', - 'callback', - 'func', - 'function', - 'method', - 'class', - 'constructor', - - // Relationships - 'modifies', - 'mixes', - 'mixin', - 'mixinClass', - 'mixinFunction', - 'namespace', - 'borrows', - 'constructs', - 'lends', - 'implements', - 'requires', - - // Long descriptions - 'desc', - 'description', - 'classdesc', - 'tutorial', - 'copyright', - 'license', - - // Simple annotations - - // TypeScript - 'internal', - 'overload', - - 'const', - 'constant', - 'final', - 'global', - 'readonly', - 'abstract', - 'virtual', - 'var', - 'member', - 'memberof', - 'memberof!', - 'inner', - 'instance', - 'inheritdoc', - 'inheritDoc', - 'override', - 'hideconstructor', - - // Core function/object info - 'param', - 'arg', - 'argument', - 'prop', - 'property', - 'return', - 'returns', - - // Important behavior details - 'async', - 'generator', - 'default', - 'defaultvalue', - 'enum', - 'augments', - 'extends', - 'throws', - 'exception', - 'yield', - 'yields', - 'event', - 'fires', - 'emits', - 'listens', - 'this', - - // TypeScript - 'satisfies', - - // Access - 'static', - 'private', - 'protected', - 'public', - 'access', - 'package', - - '-other', - - // Supplementary descriptions - 'see', - 'example', - - // METADATA - - // Other Closure (undocumented) metadata - 'closurePrimitive', - 'customElement', - 'expose', - 'hidden', - 'idGenerator', - 'meaning', - 'ngInject', - 'owner', - 'wizaction', - - // Other Closure (documented) metadata - 'define', - 'dict', - 'export', - 'externs', - 'implicitCast', - 'noalias', - 'nocollapse', - 'nocompile', - 'noinline', - 'nosideeffects', - 'polymer', - 'polymerBehavior', - 'preserve', - 'struct', - 'suppress', - 'unrestricted', - - // @homer0/prettier-plugin-jsdoc metadata - 'category', - - // Non-Closure metadata - 'ignore', - 'author', - 'version', - 'variation', - 'since', - 'deprecated', - 'todo', - ], - }, -]; - -export default defaultTagOrder; diff --git a/tools/eslint/node_modules/eslint-plugin-jsdoc/src/exportParser.js b/tools/eslint/node_modules/eslint-plugin-jsdoc/src/exportParser.js deleted file mode 100644 index 4bb2e13bd04cf3..00000000000000 --- a/tools/eslint/node_modules/eslint-plugin-jsdoc/src/exportParser.js +++ /dev/null @@ -1,964 +0,0 @@ -import { - findJSDocComment, -} from '@es-joy/jsdoccomment'; -import debugModule from 'debug'; - -const debug = debugModule('requireExportJsdoc'); - -/** - * @typedef {{ - * value: string - * }} ValueObject - */ - -/** - * @typedef {{ - * type?: string, - * value?: ValueObject|import('eslint').Rule.Node, - * props: { - * [key: string]: CreatedNode|null, - * }, - * special?: true, - * globalVars?: CreatedNode, - * exported?: boolean, - * ANONYMOUS_DEFAULT?: import('eslint').Rule.Node - * }} CreatedNode - */ - -/** - * @returns {CreatedNode} - */ -const createNode = function () { - return { - props: {}, - }; -}; - -/** - * @param {CreatedNode|null} symbol - * @returns {string|null} - */ -const getSymbolValue = function (symbol) { - /* c8 ignore next 3 */ - if (!symbol) { - return null; - } - - /* c8 ignore else */ - if (symbol.type === 'literal') { - return /** @type {ValueObject} */ (symbol.value).value; - } - /* c8 ignore next */ - return null; -}; - -/** - * - * @param {import('estree').Identifier} node - * @param {CreatedNode} globals - * @param {CreatedNode} scope - * @param {SymbolOptions} opts - * @returns {CreatedNode|null} - */ -const getIdentifier = function (node, globals, scope, opts) { - if (opts.simpleIdentifier) { - // Type is Identier for noncomputed properties - const identifierLiteral = createNode(); - identifierLiteral.type = 'literal'; - identifierLiteral.value = { - value: node.name, - }; - - return identifierLiteral; - } - - /* c8 ignore next */ - const block = scope || globals; - - // As scopes are not currently supported, they are not traversed upwards recursively - if (block.props[node.name]) { - return block.props[node.name]; - } - - // Seems this will only be entered once scopes added and entered - /* c8 ignore next 3 */ - if (globals.props[node.name]) { - return globals.props[node.name]; - } - - return null; -}; - -/** - * @callback CreateSymbol - * @param {import('eslint').Rule.Node|null} node - * @param {CreatedNode} globals - * @param {import('eslint').Rule.Node|null} value - * @param {CreatedNode} [scope] - * @param {boolean|SymbolOptions} [isGlobal] - * @returns {CreatedNode|null} - */ - -/** @type {CreateSymbol} */ -let createSymbol; // eslint-disable-line prefer-const - -/* eslint-disable complexity -- Temporary */ - -/** - * @typedef {{ - * simpleIdentifier?: boolean - * }} SymbolOptions - */ - -/** - * - * @param {import('eslint').Rule.Node} node - * @param {CreatedNode} globals - * @param {CreatedNode} scope - * @param {SymbolOptions} [opt] - * @returns {CreatedNode|null} - */ -const getSymbol = function (node, globals, scope, opt) { - /* eslint-enable complexity -- Temporary */ - const opts = opt || {}; - /* c8 ignore next */ - switch (node.type) { - case 'Identifier': { - return getIdentifier(node, globals, scope, opts); - } - - case 'MemberExpression': { - const obj = getSymbol( - /** @type {import('eslint').Rule.Node} */ - (node.object), - globals, - scope, - opts, - ); - const propertySymbol = getSymbol( - /** @type {import('eslint').Rule.Node} */ - (node.property), - globals, - scope, - { - simpleIdentifier: !node.computed, - }, - ); - const propertyValue = getSymbolValue(propertySymbol); - - /* c8 ignore else */ - if (obj && propertyValue && obj.props[propertyValue]) { - const block = obj.props[propertyValue]; - - return block; - } - /* c8 ignore next 10 */ - /* - if (opts.createMissingProps && propertyValue) { - obj.props[propertyValue] = createNode(); - - return obj.props[propertyValue]; - } - */ - debug(`MemberExpression: Missing property ${ - /** @type {import('estree').PrivateIdentifier} */ (node.property).name - }`); - /* c8 ignore next 2 */ - return null; - } - - case 'ClassExpression': { - return getSymbol( - /** @type {import('eslint').Rule.Node} */ - (node.body), - globals, - scope, - opts, - ); - } - - /* c8 ignore next 7 -- No longer needed? */ - // @ts-expect-error TS OK - case 'TSTypeAliasDeclaration': - // @ts-expect-error TS OK - // Fallthrough - case 'TSEnumDeclaration': - // @ts-expect-error TS OK - case 'TSInterfaceDeclaration': - case 'ClassDeclaration': - case 'FunctionExpression': case 'FunctionDeclaration': - case 'ArrowFunctionExpression': { - const val = createNode(); - val.props.prototype = createNode(); - val.props.prototype.type = 'object'; - val.type = 'object'; - val.value = node; - - return val; - } - - case 'AssignmentExpression': { - return createSymbol( - /** @type {import('eslint').Rule.Node} */ - (node.left), - globals, - /** @type {import('eslint').Rule.Node} */ - (node.right), - scope, - opts, - ); - } - - case 'ClassBody': { - const val = createNode(); - for (const method of node.body) { - val.props[ - /** @type {import('estree').Identifier} */ ( - /** @type {import('estree').MethodDefinition} */ ( - method - ).key - ).name - ] = createNode(); - /** @type {{[key: string]: CreatedNode}} */ (val.props)[ - /** @type {import('estree').Identifier} */ ( - /** @type {import('estree').MethodDefinition} */ ( - method - ).key - ).name - ].type = 'object'; - /** @type {{[key: string]: CreatedNode}} */ (val.props)[ - /** @type {import('estree').Identifier} */ ( - /** @type {import('estree').MethodDefinition} */ ( - method - ).key - ).name - ].value = /** @type {import('eslint').Rule.Node} */ ( - /** @type {import('estree').MethodDefinition} */ (method).value - ); - } - - val.type = 'object'; - val.value = node.parent; - - return val; - } - - case 'ObjectExpression': { - const val = createNode(); - val.type = 'object'; - for (const prop of node.properties) { - if ([ - // typescript-eslint, espree, acorn, etc. - 'SpreadElement', - - // @babel/eslint-parser - 'ExperimentalSpreadProperty', - ].includes(prop.type)) { - continue; - } - - const propVal = getSymbol( - /** @type {import('eslint').Rule.Node} */ ( - /** @type {import('estree').Property} */ - (prop).value - ), - globals, - scope, - opts, - ); - /* c8 ignore next 8 */ - if (propVal) { - val.props[ - /** @type {import('estree').PrivateIdentifier} */ - ( - /** @type {import('estree').Property} */ (prop).key - ).name - ] = propVal; - } - } - - return val; - } - - case 'Literal': { - const val = createNode(); - val.type = 'literal'; - val.value = node; - - return val; - } - } - /* c8 ignore next */ - return null; -}; - -/** - * - * @param {CreatedNode} block - * @param {string} name - * @param {CreatedNode|null} value - * @param {CreatedNode} globals - * @param {boolean|SymbolOptions|undefined} isGlobal - * @returns {void} - */ -const createBlockSymbol = function (block, name, value, globals, isGlobal) { - block.props[name] = value; - if (isGlobal && globals.props.window && globals.props.window.special) { - globals.props.window.props[name] = value; - } -}; - -createSymbol = function (node, globals, value, scope, isGlobal) { - const block = scope || globals; - /* c8 ignore next 3 */ - if (!node) { - return null; - } - - let symbol; - switch (node.type) { - case 'FunctionDeclaration': - /* c8 ignore next */ - // @ts-expect-error TS OK - // Fall through - case 'TSEnumDeclaration': case 'TSInterfaceDeclaration': - /* c8 ignore next */ - // @ts-expect-error TS OK - // Fall through - case 'TSTypeAliasDeclaration': case 'ClassDeclaration': { - const nde = /** @type {import('estree').ClassDeclaration} */ (node); - /* c8 ignore else */ - if (nde.id && nde.id.type === 'Identifier') { - return createSymbol( - /** @type {import('eslint').Rule.Node} */ (nde.id), - globals, - node, - globals, - ); - } - /* c8 ignore next 2 */ - break; - } - - case 'Identifier': { - const nde = /** @type {import('estree').Identifier} */ (node); - if (value) { - const valueSymbol = getSymbol(value, globals, block); - /* c8 ignore else */ - if (valueSymbol) { - createBlockSymbol(block, nde.name, valueSymbol, globals, isGlobal); - - return block.props[nde.name]; - } - /* c8 ignore next */ - debug('Identifier: Missing value symbol for %s', nde.name); - } else { - createBlockSymbol(block, nde.name, createNode(), globals, isGlobal); - - return block.props[nde.name]; - } - /* c8 ignore next 2 */ - break; - } - - case 'MemberExpression': { - const nde = /** @type {import('estree').MemberExpression} */ (node); - symbol = getSymbol( - /** @type {import('eslint').Rule.Node} */ (nde.object), globals, block, - ); - - const propertySymbol = getSymbol( - /** @type {import('eslint').Rule.Node} */ (nde.property), - globals, - block, - { - simpleIdentifier: !nde.computed, - }, - ); - const propertyValue = getSymbolValue(propertySymbol); - if (symbol && propertyValue) { - createBlockSymbol(symbol, propertyValue, getSymbol( - /** @type {import('eslint').Rule.Node} */ - (value), globals, block, - ), globals, isGlobal); - return symbol.props[propertyValue]; - } - - debug( - 'MemberExpression: Missing symbol: %s', - /** @type {import('estree').Identifier} */ ( - nde.property - ).name, - ); - break; - } - } - - return null; -}; - -/** - * Creates variables from variable definitions - * @param {import('eslint').Rule.Node} node - * @param {CreatedNode} globals - * @param {import('./rules/requireJsdoc.js').RequireJsdocOpts} opts - * @returns {void} - */ -const initVariables = function (node, globals, opts) { - switch (node.type) { - case 'Program': { - for (const childNode of node.body) { - initVariables( - /** @type {import('eslint').Rule.Node} */ - (childNode), - globals, - opts, - ); - } - - break; - } - - case 'ExpressionStatement': { - initVariables( - /** @type {import('eslint').Rule.Node} */ - (node.expression), - globals, - opts, - ); - break; - } - - case 'VariableDeclaration': { - for (const declaration of node.declarations) { - // let and const - const symbol = createSymbol( - /** @type {import('eslint').Rule.Node} */ - (declaration.id), - globals, - null, - globals, - ); - if (opts.initWindow && node.kind === 'var' && globals.props.window) { - // If var, also add to window - globals.props.window.props[ - /** @type {import('estree').Identifier} */ - (declaration.id).name - ] = symbol; - } - } - - break; - } - - case 'ExportNamedDeclaration': { - if (node.declaration) { - initVariables( - /** @type {import('eslint').Rule.Node} */ - (node.declaration), - globals, - opts, - ); - } - - break; - } - } -}; - -/* eslint-disable complexity -- Temporary */ - -/** - * Populates variable maps using AST - * @param {import('eslint').Rule.Node} node - * @param {CreatedNode} globals - * @param {import('./rules/requireJsdoc.js').RequireJsdocOpts} opt - * @param {true} [isExport] - * @returns {boolean} - */ -const mapVariables = function (node, globals, opt, isExport) { - /* eslint-enable complexity -- Temporary */ - /* c8 ignore next */ - const opts = opt || {}; - /* c8 ignore next */ - switch (node.type) { - case 'Program': { - if (opts.ancestorsOnly) { - return false; - } - - for (const childNode of node.body) { - mapVariables( - /** @type {import('eslint').Rule.Node} */ - (childNode), - globals, - opts, - ); - } - - break; - } - - case 'ExpressionStatement': { - mapVariables( - /** @type {import('eslint').Rule.Node} */ - (node.expression), - globals, - opts, - ); - break; - } - - case 'AssignmentExpression': { - createSymbol( - /** @type {import('eslint').Rule.Node} */ - (node.left), - globals, - /** @type {import('eslint').Rule.Node} */ - (node.right), - ); - break; - } - - case 'VariableDeclaration': { - for (const declaration of node.declarations) { - const isGlobal = Boolean(opts.initWindow && node.kind === 'var' && globals.props.window); - const symbol = createSymbol( - /** @type {import('eslint').Rule.Node} */ - (declaration.id), - globals, - /** @type {import('eslint').Rule.Node} */ - (declaration.init), - globals, - isGlobal, - ); - if (symbol && isExport) { - symbol.exported = true; - } - } - - break; - } - - case 'FunctionDeclaration': { - /* c8 ignore next 10 */ - if (/** @type {import('estree').Identifier} */ (node.id).type === 'Identifier') { - createSymbol( - /** @type {import('eslint').Rule.Node} */ - (node.id), - globals, - node, - globals, - true, - ); - } - - break; - } - - case 'ExportDefaultDeclaration': { - const symbol = createSymbol( - /** @type {import('eslint').Rule.Node} */ - (node.declaration), - globals, - /** @type {import('eslint').Rule.Node} */ - (node.declaration), - ); - if (symbol) { - symbol.exported = true; - /* c8 ignore next 6 */ - } else { - // if (!node.id) { - globals.ANONYMOUS_DEFAULT = /** @type {import('eslint').Rule.Node} */ ( - node.declaration - ); - } - - break; - } - - case 'ExportNamedDeclaration': { - if (node.declaration) { - if (node.declaration.type === 'VariableDeclaration') { - mapVariables( - /** @type {import('eslint').Rule.Node} */ - (node.declaration), - globals, - opts, - true, - ); - } else { - const symbol = createSymbol( - /** @type {import('eslint').Rule.Node} */ - (node.declaration), - globals, - /** @type {import('eslint').Rule.Node} */ - (node.declaration), - ); - /* c8 ignore next 3 */ - if (symbol) { - symbol.exported = true; - } - } - } - - for (const specifier of node.specifiers) { - mapVariables( - /** @type {import('eslint').Rule.Node} */ - (specifier), - globals, - opts, - ); - } - - break; - } - - case 'ExportSpecifier': { - const symbol = getSymbol( - /** @type {import('eslint').Rule.Node} */ - (node.local), - globals, - globals, - ); - /* c8 ignore next 3 */ - if (symbol) { - symbol.exported = true; - } - - break; - } - - case 'ClassDeclaration': { - createSymbol( - /** @type {import('eslint').Rule.Node|null} */ (node.id), - globals, - /** @type {import('eslint').Rule.Node} */ (node.body), - globals, - ); - break; - } - - default: { - /* c8 ignore next */ - return false; - } - } - - return true; -}; - -/** - * - * @param {import('eslint').Rule.Node} node - * @param {CreatedNode|ValueObject|string|undefined| - * import('eslint').Rule.Node} block - * @param {(CreatedNode|ValueObject|string| - * import('eslint').Rule.Node)[]} [cache] - * @returns {boolean} - */ -const findNode = function (node, block, cache) { - let blockCache = cache || []; - if (!block || blockCache.includes(block)) { - return false; - } - - blockCache = blockCache.slice(); - blockCache.push(block); - - if ( - typeof block === 'object' && - 'type' in block && - (block.type === 'object' || block.type === 'MethodDefinition') && - block.value === node - ) { - return true; - } - - if (typeof block !== 'object') { - return false; - } - - const props = ('props' in block && block.props) || ('body' in block && block.body); - for (const propval of Object.values(props || {})) { - if (Array.isArray(propval)) { - /* c8 ignore next 5 */ - if (propval.some((val) => { - return findNode(node, val, blockCache); - })) { - return true; - } - } else if (findNode(node, propval, blockCache)) { - return true; - } - } - - return false; -}; - -const exportTypes = new Set([ - 'ExportNamedDeclaration', 'ExportDefaultDeclaration', -]); -const ignorableNestedTypes = new Set([ - 'FunctionDeclaration', 'ArrowFunctionExpression', 'FunctionExpression', -]); - -/** - * @param {import('eslint').Rule.Node} nde - * @returns {import('eslint').Rule.Node|false} - */ -const getExportAncestor = function (nde) { - let node = nde; - let idx = 0; - const ignorableIfDeep = ignorableNestedTypes.has(nde?.type); - while (node) { - // Ignore functions nested more deeply than say `export default function () {}` - if (idx >= 2 && ignorableIfDeep) { - break; - } - - if (exportTypes.has(node.type)) { - return node; - } - - node = node.parent; - idx++; - } - - return false; -}; - -const canBeExportedByAncestorType = new Set([ - 'TSPropertySignature', - 'TSMethodSignature', - 'ClassProperty', - 'PropertyDefinition', - 'Method', -]); - -const canExportChildrenType = new Set([ - 'TSInterfaceBody', - 'TSInterfaceDeclaration', - 'TSTypeLiteral', - 'TSTypeAliasDeclaration', - 'TSTypeParameterInstantiation', - 'TSTypeReference', - 'ClassDeclaration', - 'ClassBody', - 'ClassDefinition', - 'ClassExpression', - 'Program', -]); - -/** - * @param {import('eslint').Rule.Node} nde - * @returns {false|import('eslint').Rule.Node} - */ -const isExportByAncestor = function (nde) { - if (!canBeExportedByAncestorType.has(nde.type)) { - return false; - } - - let node = nde.parent; - while (node) { - if (exportTypes.has(node.type)) { - return node; - } - - if (!canExportChildrenType.has(node.type)) { - return false; - } - - node = node.parent; - } - - return false; -}; - -/** - * - * @param {CreatedNode} block - * @param {import('eslint').Rule.Node} node - * @param {CreatedNode[]} [cache] Currently unused - * @returns {boolean} - */ -const findExportedNode = function (block, node, cache) { - /* c8 ignore next 3 */ - if (block === null) { - return false; - } - - const blockCache = cache || []; - const { - props, - } = block; - for (const propval of Object.values(props)) { - const pval = /** @type {CreatedNode} */ (propval); - blockCache.push(pval); - if (pval.exported && (node === pval.value || findNode(node, pval.value))) { - return true; - } - - // No need to check `propval` for exported nodes as ESM - // exports are only global - } - - return false; -}; - -/** - * - * @param {import('eslint').Rule.Node} node - * @param {CreatedNode} globals - * @param {import('./rules/requireJsdoc.js').RequireJsdocOpts} opt - * @returns {boolean} - */ -const isNodeExported = function (node, globals, opt) { - const moduleExports = globals.props.module?.props?.exports; - if ( - opt.initModuleExports && moduleExports && findNode(node, moduleExports) - ) { - return true; - } - - if (opt.initWindow && globals.props.window && findNode(node, globals.props.window)) { - return true; - } - - if (opt.esm && findExportedNode(globals, node)) { - return true; - } - - return false; -}; - -/** - * - * @param {import('eslint').Rule.Node} node - * @param {CreatedNode} globalVars - * @param {import('./rules/requireJsdoc.js').RequireJsdocOpts} opts - * @returns {boolean} - */ -const parseRecursive = function (node, globalVars, opts) { - // Iterate from top using recursion - stop at first processed node from top - if (node.parent && parseRecursive(node.parent, globalVars, opts)) { - return true; - } - - return mapVariables(node, globalVars, opts); -}; - -/** - * - * @param {import('eslint').Rule.Node} ast - * @param {import('eslint').Rule.Node} node - * @param {import('./rules/requireJsdoc.js').RequireJsdocOpts} opt - * @returns {CreatedNode} - */ -const parse = function (ast, node, opt) { - /* c8 ignore next 6 */ - const opts = opt || { - ancestorsOnly: false, - esm: true, - initModuleExports: true, - initWindow: true, - }; - - const globalVars = createNode(); - if (opts.initModuleExports) { - globalVars.props.module = createNode(); - globalVars.props.module.props.exports = createNode(); - globalVars.props.exports = globalVars.props.module.props.exports; - } - - if (opts.initWindow) { - globalVars.props.window = createNode(); - globalVars.props.window.special = true; - } - - if (opts.ancestorsOnly) { - parseRecursive(node, globalVars, opts); - } else { - initVariables(ast, globalVars, opts); - mapVariables(ast, globalVars, opts); - } - - return { - globalVars, - props: {}, - }; -}; - -const accessibilityNodes = new Set([ - 'PropertyDefinition', - 'MethodDefinition', -]); - -/** - * - * @param {import('eslint').Rule.Node} node - * @returns {boolean} - */ -const isPrivate = (node) => { - return accessibilityNodes.has(node.type) && - ( - 'accessibility' in node && - node.accessibility !== 'public' && node.accessibility !== undefined - ) || - 'key' in node && - node.key.type === 'PrivateIdentifier'; -}; - -/** - * - * @param {import('eslint').Rule.Node} node - * @param {import('eslint').SourceCode} sourceCode - * @param {import('./rules/requireJsdoc.js').RequireJsdocOpts} opt - * @param {import('./iterateJsdoc.js').Settings} settings - * @returns {boolean} - */ -const isUncommentedExport = function (node, sourceCode, opt, settings) { - // console.log({node}); - // Optimize with ancestor check for esm - if (opt.esm) { - if (isPrivate(node) || - node.parent && isPrivate(node.parent)) { - return false; - } - - const exportNode = getExportAncestor(node); - - // Is export node comment - if (exportNode && !findJSDocComment(exportNode, sourceCode, settings)) { - return true; - } - - /** - * Some typescript types are not in variable map, but inherit exported (interface property and method) - */ - if ( - isExportByAncestor(node) && - !findJSDocComment(node, sourceCode, settings) - ) { - return true; - } - } - - const ast = /** @type {unknown} */ (sourceCode.ast); - - const parseResult = parse( - /** @type {import('eslint').Rule.Node} */ - (ast), - node, - opt, - ); - - return isNodeExported( - node, /** @type {CreatedNode} */ (parseResult.globalVars), opt, - ); -}; - -export default { - isUncommentedExport, - parse, -}; diff --git a/tools/eslint/node_modules/eslint-plugin-jsdoc/src/getDefaultTagStructureForMode.js b/tools/eslint/node_modules/eslint-plugin-jsdoc/src/getDefaultTagStructureForMode.js deleted file mode 100644 index 44cd80ce979b45..00000000000000 --- a/tools/eslint/node_modules/eslint-plugin-jsdoc/src/getDefaultTagStructureForMode.js +++ /dev/null @@ -1,969 +0,0 @@ -/** - * @typedef {Map>} TagStructure - */ -/** - * @param {import('./jsdocUtils.js').ParserMode} mode - * @returns {TagStructure} - */ -const getDefaultTagStructureForMode = (mode) => { - const isJsdoc = mode === 'jsdoc'; - const isClosure = mode === 'closure'; - const isTypescript = mode === 'typescript'; - const isPermissive = mode === 'permissive'; - - const isJsdocOrPermissive = isJsdoc || isPermissive; - const isJsdocOrTypescript = isJsdoc || isTypescript; - const isTypescriptOrClosure = isTypescript || isClosure; - const isClosureOrPermissive = isClosure || isPermissive; - const isJsdocTypescriptOrPermissive = isJsdocOrTypescript || isPermissive; - - // Properties: - // `namepathRole` - 'namepath-referencing'|'namepath-defining'|'namepath-or-url-referencing'|'text'|false - // `typeAllowed` - boolean - // `nameRequired` - boolean - // `typeRequired` - boolean - // `typeOrNameRequired` - boolean - - // All of `typeAllowed` have a signature with "type" except for - // `augments`/`extends` ("namepath") - // `param`/`arg`/`argument` (no signature) - // `property`/`prop` (no signature) - // `modifies` (undocumented) - - // None of the `namepathRole: 'namepath-defining'` show as having curly - // brackets for their name/namepath - - // Among `namepath-defining` and `namepath-referencing`, these do not seem - // to allow curly brackets in their doc signature or examples (`modifies` - // references namepaths within its type brackets and `param` is - // name-defining but not namepath-defining, so not part of these groups) - - // Todo: Should support special processing for "name" as distinct from - // "namepath" (e.g., param can't define a namepath) - - // Todo: Should support a `tutorialID` type (for `@tutorial` block and - // inline) - - /** - * @type {TagStructure} - */ - return new Map([ - [ - 'alias', new Map(/** @type {[string, string|boolean][]} */ ([ - // Signature seems to require a "namepath" (and no counter-examples) - [ - 'namepathRole', 'namepath-defining', - ], - - // "namepath" - [ - 'typeOrNameRequired', true, - ], - ])), - ], - - [ - 'arg', new Map(/** @type {[string, string|boolean][]} */ ([ - [ - 'namepathRole', 'namepath-defining', - ], - - // See `param` - [ - 'nameRequired', true, - ], - - // Has no formal signature in the docs but shows curly brackets - // in the examples - [ - 'typeAllowed', true, - ], - ])), - ], - - [ - 'argument', new Map(/** @type {[string, string|boolean][]} */ ([ - [ - 'namepathRole', 'namepath-defining', - ], - - // See `param` - [ - 'nameRequired', true, - ], - - // Has no formal signature in the docs but shows curly brackets - // in the examples - [ - 'typeAllowed', true, - ], - ])), - ], - - [ - 'augments', new Map(/** @type {[string, string|boolean][]} */ ([ - // Signature seems to require a "namepath" (and no counter-examples) - [ - 'namepathRole', 'namepath-referencing', - ], - - // Does not show curly brackets in either the signature or examples - [ - 'typeAllowed', true, - ], - - // "namepath" - [ - 'typeOrNameRequired', true, - ], - ])), - ], - - [ - 'borrows', new Map(/** @type {[string, string|boolean][]} */ ([ - // `borrows` has a different format, however, so needs special parsing; - // seems to require both, and as "namepath"'s - [ - 'namepathRole', 'namepath-referencing', - ], - - // "namepath" - [ - 'typeOrNameRequired', true, - ], - ])), - ], - - [ - 'callback', new Map(/** @type {[string, string|boolean][]} */ ([ - // Seems to require a "namepath" in the signature (with no - // counter-examples); TypeScript does not enforce but seems - // problematic as not attached so presumably not useable without it - [ - 'namepathRole', 'namepath-defining', - ], - - // "namepath" - [ - 'nameRequired', true, - ], - ])), - ], - - [ - 'class', new Map(/** @type {[string, string|boolean][]} */ ([ - // Allows for "name"'s in signature, but indicated as optional - [ - 'namepathRole', 'namepath-defining', - ], - - // Not in use, but should be this value if using to power `empty-tags` - [ - 'nameAllowed', true, - ], - - [ - 'typeAllowed', true, - ], - ])), - ], - - [ - 'const', new Map(/** @type {[string, string|boolean][]} */ ([ - // Allows for "name"'s in signature, but indicated as optional - [ - 'namepathRole', 'namepath-defining', - ], - - [ - 'typeAllowed', true, - ], - ])), - ], - [ - 'constant', new Map(/** @type {[string, string|boolean][]} */ ([ - // Allows for "name"'s in signature, but indicated as optional - [ - 'namepathRole', 'namepath-defining', - ], - - [ - 'typeAllowed', true, - ], - ])), - ], - [ - 'constructor', new Map(/** @type {[string, string|boolean][]} */ ([ - // Allows for "name"'s in signature, but indicated as optional - [ - 'namepathRole', 'namepath-defining', - ], - - [ - 'typeAllowed', true, - ], - ])), - ], - - [ - 'constructs', new Map(/** @type {[string, string|boolean][]} */ ([ - // Allows for "name"'s in signature, but indicated as optional - [ - 'namepathRole', 'namepath-defining', - ], - - [ - 'nameRequired', false, - ], - - [ - 'typeAllowed', false, - ], - ])), - ], - - [ - 'define', new Map(/** @type {[string, string|boolean][]} */ ([ - [ - 'typeRequired', isClosure, - ], - ])), - ], - - [ - 'emits', new Map(/** @type {[string, string|boolean][]} */ ([ - // Signature seems to require a "name" (of an event) and no counter-examples - [ - 'namepathRole', 'namepath-referencing', - ], - - [ - 'nameRequired', true, - ], - - [ - 'typeAllowed', false, - ], - ])), - ], - - [ - 'enum', new Map(/** @type {[string, string|boolean][]} */ ([ - // Has example showing curly brackets but not in doc signature - [ - 'typeAllowed', true, - ], - ])), - ], - - [ - 'event', new Map(/** @type {[string, string|boolean][]} */ ([ - // The doc signature of `event` seems to require a "name" - [ - 'nameRequired', true, - ], - - // Appears to require a "name" in its signature, albeit somewhat - // different from other "name"'s (including as described - // at https://jsdoc.app/about-namepaths.html ) - [ - 'namepathRole', 'namepath-defining', - ], - ])), - ], - - [ - 'exception', new Map(/** @type {[string, string|boolean][]} */ ([ - // Shows curly brackets in the signature and in the examples - [ - 'typeAllowed', true, - ], - ])), - ], - - // Closure - [ - 'export', new Map(/** @type {[string, string|boolean][]} */ ([ - [ - 'typeAllowed', isClosureOrPermissive, - ], - ])), - ], - - [ - 'exports', new Map(/** @type {[string, string|boolean][]} */ ([ - [ - 'namepathRole', 'namepath-defining', - ], - - [ - 'nameRequired', isJsdoc, - ], - - [ - 'typeAllowed', isClosureOrPermissive, - ], - ])), - ], - - [ - 'extends', new Map(/** @type {[string, string|boolean][]} */ ([ - // Signature seems to require a "namepath" (and no counter-examples) - [ - 'namepathRole', 'namepath-referencing', - ], - - // Does not show curly brackets in either the signature or examples - [ - 'typeAllowed', isTypescriptOrClosure || isPermissive, - ], - - [ - 'nameRequired', isJsdoc, - ], - - // "namepath" - [ - 'typeOrNameRequired', isTypescriptOrClosure || isPermissive, - ], - ])), - ], - - [ - 'external', new Map(/** @type {[string, string|boolean][]} */ ([ - // Appears to require a "name" in its signature, albeit somewhat - // different from other "name"'s (including as described - // at https://jsdoc.app/about-namepaths.html ) - [ - 'namepathRole', 'namepath-defining', - ], - - // "name" (and a special syntax for the `external` name) - [ - 'nameRequired', true, - ], - - [ - 'typeAllowed', false, - ], - ])), - ], - - [ - 'fires', new Map(/** @type {[string, string|boolean][]} */ ([ - // Signature seems to require a "name" (of an event) and no - // counter-examples - [ - 'namepathRole', 'namepath-referencing', - ], - - [ - 'nameRequired', true, - ], - - [ - 'typeAllowed', false, - ], - ])), - ], - - [ - 'function', new Map(/** @type {[string, string|boolean][]} */ ([ - // Allows for "name"'s in signature, but indicated as optional - [ - 'namepathRole', 'namepath-defining', - ], - - [ - 'nameRequired', false, - ], - - [ - 'typeAllowed', false, - ], - ])), - ], - [ - 'func', new Map(/** @type {[string, string|boolean][]} */ ([ - // Allows for "name"'s in signature, but indicated as optional - [ - 'namepathRole', 'namepath-defining', - ], - ])), - ], - - [ - 'host', new Map(/** @type {[string, string|boolean][]} */ ([ - // Appears to require a "name" in its signature, albeit somewhat - // different from other "name"'s (including as described - // at https://jsdoc.app/about-namepaths.html ) - [ - 'namepathRole', 'namepath-defining', - ], - - // See `external` - [ - 'nameRequired', true, - ], - - [ - 'typeAllowed', false, - ], - ])), - ], - - [ - 'interface', new Map(/** @type {[string, string|boolean][]} */ ([ - // Allows for "name" in signature, but indicates as optional - [ - 'namepathRole', - isJsdocTypescriptOrPermissive ? 'namepath-defining' : false, - ], - - // Not in use, but should be this value if using to power `empty-tags` - [ - 'nameAllowed', isClosure, - ], - - [ - 'typeAllowed', false, - ], - ])), - ], - - [ - 'internal', new Map(/** @type {[string, string|boolean][]} */ ([ - // https://www.typescriptlang.org/tsconfig/#stripInternal - [ - 'namepathRole', false, - ], - // Not in use, but should be this value if using to power `empty-tags` - [ - 'nameAllowed', false, - ], - ])), - ], - - [ - 'implements', new Map(/** @type {[string, string|boolean][]} */ ([ - // Shows curly brackets in the doc signature and examples - // "typeExpression" - [ - 'typeRequired', true, - ], - ])), - ], - - [ - 'lends', new Map(/** @type {[string, string|boolean][]} */ ([ - // Signature seems to require a "namepath" (and no counter-examples) - [ - 'namepathRole', 'namepath-referencing', - ], - - // "namepath" - [ - 'typeOrNameRequired', true, - ], - ])), - ], - - [ - 'link', new Map(/** @type {[string, string|boolean][]} */ ([ - // Signature seems to require a namepath OR URL and might be checked as such. - [ - 'namepathRole', 'namepath-or-url-referencing', - ], - - ])), - ], - - [ - 'linkcode', new Map(/** @type {[string, string|boolean][]} */ ([ - // Synonym for "link" - // Signature seems to require a namepath OR URL and might be checked as such. - [ - 'namepathRole', 'namepath-or-url-referencing', - ], - ])), - ], - - [ - 'linkplain', new Map(/** @type {[string, string|boolean][]} */ ([ - // Synonym for "link" - // Signature seems to require a namepath OR URL and might be checked as such. - [ - 'namepathRole', 'namepath-or-url-referencing', - ], - ])), - ], - - [ - 'listens', new Map(/** @type {[string, string|boolean][]} */ ([ - // Signature seems to require a "name" (of an event) and no - // counter-examples - [ - 'namepathRole', 'namepath-referencing', - ], - - [ - 'nameRequired', true, - ], - - [ - 'typeAllowed', false, - ], - ])), - ], - - [ - 'member', new Map(/** @type {[string, string|boolean][]} */ ([ - // Allows for "name"'s in signature, but indicated as optional - [ - 'namepathRole', 'namepath-defining', - ], - - // Has example showing curly brackets but not in doc signature - [ - 'typeAllowed', true, - ], - ])), - ], - - [ - 'memberof', new Map(/** @type {[string, string|boolean][]} */ ([ - // Signature seems to require a "namepath" (and no counter-examples), - // though it allows an incomplete namepath ending with connecting symbol - [ - 'namepathRole', 'namepath-referencing', - ], - - // "namepath" - [ - 'typeOrNameRequired', true, - ], - ])), - ], - [ - 'memberof!', new Map(/** @type {[string, string|boolean][]} */ ([ - // Signature seems to require a "namepath" (and no counter-examples), - // though it allows an incomplete namepath ending with connecting symbol - [ - 'namepathRole', 'namepath-referencing', - ], - - // "namepath" - [ - 'typeOrNameRequired', true, - ], - ])), - ], - - [ - 'method', new Map(/** @type {[string, string|boolean][]} */ ([ - // Allows for "name"'s in signature, but indicated as optional - [ - 'namepathRole', 'namepath-defining', - ], - ])), - ], - [ - 'mixes', new Map(/** @type {[string, string|boolean][]} */ ([ - // Signature seems to require a "OtherObjectPath" with no - // counter-examples - [ - 'namepathRole', 'namepath-referencing', - ], - - // "OtherObjectPath" - [ - 'typeOrNameRequired', true, - ], - ])), - ], - - [ - 'mixin', new Map(/** @type {[string, string|boolean][]} */ ([ - // Allows for "name"'s in signature, but indicated as optional - [ - 'namepathRole', 'namepath-defining', - ], - - [ - 'nameRequired', false, - ], - - [ - 'typeAllowed', false, - ], - ])), - ], - - [ - 'modifies', new Map(/** @type {[string, string|boolean][]} */ ([ - // Has no documentation, but test example has curly brackets, and - // "name" would be suggested rather than "namepath" based on example; - // not sure if name is required - [ - 'typeAllowed', true, - ], - ])), - ], - - [ - 'module', new Map(/** @type {[string, string|boolean][]} */ ([ - // Optional "name" and no curly brackets - // this block impacts `no-undefined-types` and `valid-types` (search for - // "isNamepathDefiningTag|tagMightHaveNamepath|tagMightHaveEitherTypeOrNamePosition") - [ - 'namepathRole', isJsdoc ? 'namepath-defining' : 'text', - ], - - // Shows the signature with curly brackets but not in the example - [ - 'typeAllowed', true, - ], - ])), - ], - - [ - 'name', new Map(/** @type {[string, string|boolean][]} */ ([ - // Seems to require a "namepath" in the signature (with no - // counter-examples) - [ - 'namepathRole', 'namepath-defining', - ], - - // "namepath" - [ - 'nameRequired', true, - ], - - // "namepath" - [ - 'typeOrNameRequired', true, - ], - ])), - ], - - [ - 'namespace', new Map(/** @type {[string, string|boolean][]} */ ([ - // Allows for "name"'s in signature, but indicated as optional - [ - 'namepathRole', 'namepath-defining', - ], - - // Shows the signature with curly brackets but not in the example - [ - 'typeAllowed', true, - ], - ])), - ], - [ - 'package', new Map(/** @type {[string, string|boolean][]} */ ([ - // Shows the signature with curly brackets but not in the example - // "typeExpression" - [ - 'typeAllowed', isClosureOrPermissive, - ], - ])), - ], - - [ - 'param', new Map(/** @type {[string, string|boolean][]} */ ([ - [ - 'namepathRole', 'namepath-defining', - ], - - // Though no signature provided requiring, per - // https://jsdoc.app/tags-param.html: - // "The @param tag requires you to specify the name of the parameter you - // are documenting." - [ - 'nameRequired', true, - ], - - // Has no formal signature in the docs but shows curly brackets - // in the examples - [ - 'typeAllowed', true, - ], - ])), - ], - - [ - 'private', new Map(/** @type {[string, string|boolean][]} */ ([ - // Shows the signature with curly brackets but not in the example - // "typeExpression" - [ - 'typeAllowed', isClosureOrPermissive, - ], - ])), - ], - - [ - 'prop', new Map(/** @type {[string, string|boolean][]} */ ([ - [ - 'namepathRole', 'namepath-defining', - ], - - // See `property` - [ - 'nameRequired', true, - ], - - // Has no formal signature in the docs but shows curly brackets - // in the examples - [ - 'typeAllowed', true, - ], - ])), - ], - - [ - 'property', new Map(/** @type {[string, string|boolean][]} */ ([ - [ - 'namepathRole', 'namepath-defining', - ], - - // No docs indicate required, but since parallel to `param`, we treat as - // such: - [ - 'nameRequired', true, - ], - - // Has no formal signature in the docs but shows curly brackets - // in the examples - [ - 'typeAllowed', true, - ], - ])), - ], - - [ - 'protected', new Map(/** @type {[string, string|boolean][]} */ ([ - // Shows the signature with curly brackets but not in the example - // "typeExpression" - [ - 'typeAllowed', isClosureOrPermissive, - ], - ])), - ], - - [ - 'public', new Map(/** @type {[string, string|boolean][]} */ ([ - // Does not show a signature nor show curly brackets in the example - [ - 'typeAllowed', isClosureOrPermissive, - ], - ])), - ], - - [ - 'requires', new Map(/** @type {[string, string|boolean][]} */ ([ - // - [ - 'namepathRole', 'namepath-referencing', - ], - - [ - 'nameRequired', true, - ], - - [ - 'typeAllowed', false, - ], - ])), - ], - - [ - 'returns', new Map(/** @type {[string, string|boolean][]} */ ([ - // Shows curly brackets in the signature and in the examples - [ - 'typeAllowed', true, - ], - ])), - ], - [ - 'return', new Map(/** @type {[string, string|boolean][]} */ ([ - // Shows curly brackets in the signature and in the examples - [ - 'typeAllowed', true, - ], - ])), - ], - - [ - 'satisfies', new Map(/** @type {[string, string|boolean][]} */ ([ - // Shows curly brackets in the doc signature and examples - [ - 'typeRequired', true, - ], - ])), - ], - - [ - 'see', new Map(/** @type {[string, string|boolean][]} */ ([ - // Signature allows for "namepath" or text, so user must configure to - // 'namepath-referencing' to enforce checks - [ - 'namepathRole', 'text', - ], - ])), - ], - - [ - 'static', new Map(/** @type {[string, string|boolean][]} */ ([ - // Does not show a signature nor show curly brackets in the example - [ - 'typeAllowed', isClosureOrPermissive, - ], - ])), - ], - - [ - 'suppress', new Map(/** @type {[string, string|boolean][]} */ ([ - [ - 'namepathRole', !isClosure, - ], - [ - 'typeRequired', isClosure, - ], - ])), - ], - - [ - 'template', new Map(/** @type {[string, string|boolean][]} */ ([ - [ - 'namepathRole', isJsdoc ? 'text' : 'namepath-referencing', - ], - - [ - 'nameRequired', !isJsdoc, - ], - - // Though defines `namepathRole: 'namepath-defining'` in a sense, it is - // not parseable in the same way for template (e.g., allowing commas), - // so not adding - [ - 'typeAllowed', isTypescriptOrClosure || isPermissive, - ], - ])), - ], - - [ - 'this', new Map(/** @type {[string, string|boolean][]} */ ([ - // Signature seems to require a "namepath" (and no counter-examples) - // Not used with namepath in Closure/TypeScript, however - [ - 'namepathRole', isJsdoc ? 'namepath-referencing' : false, - ], - - [ - 'typeRequired', isTypescriptOrClosure, - ], - - // namepath - [ - 'typeOrNameRequired', isJsdoc, - ], - ])), - ], - - [ - 'throws', new Map(/** @type {[string, string|boolean][]} */ ([ - // Shows curly brackets in the signature and in the examples - [ - 'typeAllowed', true, - ], - ])), - ], - - [ - 'tutorial', new Map(/** @type {[string, string|boolean][]} */ ([ - // (a tutorial ID) - [ - 'nameRequired', true, - ], - - [ - 'typeAllowed', false, - ], - ])), - ], - - [ - 'type', new Map(/** @type {[string, string|boolean][]} */ ([ - // Shows curly brackets in the doc signature and examples - // "typeName" - [ - 'typeRequired', true, - ], - ])), - ], - - [ - 'typedef', new Map(/** @type {[string, string|boolean][]} */ ([ - // Seems to require a "namepath" in the signature (with no - // counter-examples) - [ - 'namepathRole', 'namepath-defining', - ], - - // TypeScript may allow it to be dropped if followed by @property or @member; - // also shown as missing in Closure - // "namepath" - [ - 'nameRequired', isJsdocOrPermissive, - ], - - // Is not `typeRequired` for TypeScript because it gives an error: - // JSDoc '@typedef' tag should either have a type annotation or be followed by '@property' or '@member' tags. - - // Has example showing curly brackets but not in doc signature - [ - 'typeAllowed', true, - ], - - // TypeScript may allow it to be dropped if followed by @property or @member - // "namepath" - [ - 'typeOrNameRequired', !isTypescript, - ], - ])), - ], - - [ - 'var', new Map(/** @type {[string, string|boolean][]} */ ([ - // Allows for "name"'s in signature, but indicated as optional - [ - 'namepathRole', 'namepath-defining', - ], - - // Has example showing curly brackets but not in doc signature - [ - 'typeAllowed', true, - ], - ])), - ], - - [ - 'yields', new Map(/** @type {[string, string|boolean][]} */ ([ - // Shows curly brackets in the signature and in the examples - [ - 'typeAllowed', true, - ], - ])), - ], - [ - 'yield', new Map(/** @type {[string, string|boolean][]} */ ([ - // Shows curly brackets in the signature and in the examples - [ - 'typeAllowed', true, - ], - ])), - ], - ]); -}; - -export default getDefaultTagStructureForMode; diff --git a/tools/eslint/node_modules/eslint-plugin-jsdoc/src/import-worker.mjs b/tools/eslint/node_modules/eslint-plugin-jsdoc/src/import-worker.mjs deleted file mode 100644 index cc54de761a9411..00000000000000 --- a/tools/eslint/node_modules/eslint-plugin-jsdoc/src/import-worker.mjs +++ /dev/null @@ -1,11 +0,0 @@ -import { runAsWorker } from 'synckit' - -runAsWorker(async (imprt) => { - const { parseImports } = await import('parse-imports'); - try { - // ESLint doesn't support async rules - return [...await parseImports(imprt)]; - } catch (err) { - return false; - } -}) diff --git a/tools/eslint/node_modules/eslint-plugin-jsdoc/src/index.js b/tools/eslint/node_modules/eslint-plugin-jsdoc/src/index.js deleted file mode 100644 index a6a6bae644556a..00000000000000 --- a/tools/eslint/node_modules/eslint-plugin-jsdoc/src/index.js +++ /dev/null @@ -1,274 +0,0 @@ -import checkAccess from './rules/checkAccess.js'; -import checkAlignment from './rules/checkAlignment.js'; -import checkExamples from './rules/checkExamples.js'; -import checkIndentation from './rules/checkIndentation.js'; -import checkLineAlignment from './rules/checkLineAlignment.js'; -import checkParamNames from './rules/checkParamNames.js'; -import checkPropertyNames from './rules/checkPropertyNames.js'; -import checkSyntax from './rules/checkSyntax.js'; -import checkTagNames from './rules/checkTagNames.js'; -import checkTypes from './rules/checkTypes.js'; -import checkValues from './rules/checkValues.js'; -import convertToJsdocComments from './rules/convertToJsdocComments.js'; -import emptyTags from './rules/emptyTags.js'; -import implementsOnClasses from './rules/implementsOnClasses.js'; -import importsAsDependencies from './rules/importsAsDependencies.js'; -import informativeDocs from './rules/informativeDocs.js'; -import matchDescription from './rules/matchDescription.js'; -import matchName from './rules/matchName.js'; -import multilineBlocks from './rules/multilineBlocks.js'; -import noBadBlocks from './rules/noBadBlocks.js'; -import noBlankBlockDescriptions from './rules/noBlankBlockDescriptions.js'; -import noBlankBlocks from './rules/noBlankBlocks.js'; -import noDefaults from './rules/noDefaults.js'; -import noMissingSyntax from './rules/noMissingSyntax.js'; -import noMultiAsterisks from './rules/noMultiAsterisks.js'; -import noRestrictedSyntax from './rules/noRestrictedSyntax.js'; -import noTypes from './rules/noTypes.js'; -import noUndefinedTypes from './rules/noUndefinedTypes.js'; -import requireAsteriskPrefix from './rules/requireAsteriskPrefix.js'; -import requireDescription from './rules/requireDescription.js'; -import requireDescriptionCompleteSentence from './rules/requireDescriptionCompleteSentence.js'; -import requireExample from './rules/requireExample.js'; -import requireFileOverview from './rules/requireFileOverview.js'; -import requireHyphenBeforeParamDescription from './rules/requireHyphenBeforeParamDescription.js'; -import requireJsdoc from './rules/requireJsdoc.js'; -import requireParam from './rules/requireParam.js'; -import requireParamDescription from './rules/requireParamDescription.js'; -import requireParamName from './rules/requireParamName.js'; -import requireParamType from './rules/requireParamType.js'; -import requireProperty from './rules/requireProperty.js'; -import requirePropertyDescription from './rules/requirePropertyDescription.js'; -import requirePropertyName from './rules/requirePropertyName.js'; -import requirePropertyType from './rules/requirePropertyType.js'; -import requireReturns from './rules/requireReturns.js'; -import requireReturnsCheck from './rules/requireReturnsCheck.js'; -import requireReturnsDescription from './rules/requireReturnsDescription.js'; -import requireReturnsType from './rules/requireReturnsType.js'; -import requireTemplate from './rules/requireTemplate.js'; -import requireThrows from './rules/requireThrows.js'; -import requireYields from './rules/requireYields.js'; -import requireYieldsCheck from './rules/requireYieldsCheck.js'; -import sortTags from './rules/sortTags.js'; -import tagLines from './rules/tagLines.js'; -import textEscaping from './rules/textEscaping.js'; -import validTypes from './rules/validTypes.js'; - -/** - * @type {import('eslint').ESLint.Plugin & { - * configs: Record< - * "recommended"|"recommended-error"|"recommended-typescript"| - * "recommended-typescript-error"|"recommended-typescript-flavor"| - * "recommended-typescript-flavor-error"|"flat/recommended"| - * "flat/recommended-error"|"flat/recommended-typescript"| - * "flat/recommended-typescript-error"| - * "flat/recommended-typescript-flavor"| - * "flat/recommended-typescript-flavor-error", - * import('eslint').Linter.FlatConfig - * > - * }} - */ -const index = { - // @ts-expect-error Ok - configs: {}, - rules: { - 'check-access': checkAccess, - 'check-alignment': checkAlignment, - 'check-examples': checkExamples, - 'check-indentation': checkIndentation, - 'check-line-alignment': checkLineAlignment, - 'check-param-names': checkParamNames, - 'check-property-names': checkPropertyNames, - 'check-syntax': checkSyntax, - 'check-tag-names': checkTagNames, - 'check-types': checkTypes, - 'check-values': checkValues, - 'convert-to-jsdoc-comments': convertToJsdocComments, - 'empty-tags': emptyTags, - 'implements-on-classes': implementsOnClasses, - 'imports-as-dependencies': importsAsDependencies, - 'informative-docs': informativeDocs, - 'match-description': matchDescription, - 'match-name': matchName, - 'multiline-blocks': multilineBlocks, - 'no-bad-blocks': noBadBlocks, - 'no-blank-block-descriptions': noBlankBlockDescriptions, - 'no-blank-blocks': noBlankBlocks, - 'no-defaults': noDefaults, - 'no-missing-syntax': noMissingSyntax, - 'no-multi-asterisks': noMultiAsterisks, - 'no-restricted-syntax': noRestrictedSyntax, - 'no-types': noTypes, - 'no-undefined-types': noUndefinedTypes, - 'require-asterisk-prefix': requireAsteriskPrefix, - 'require-description': requireDescription, - 'require-description-complete-sentence': requireDescriptionCompleteSentence, - 'require-example': requireExample, - 'require-file-overview': requireFileOverview, - 'require-hyphen-before-param-description': requireHyphenBeforeParamDescription, - 'require-jsdoc': requireJsdoc, - 'require-param': requireParam, - 'require-param-description': requireParamDescription, - 'require-param-name': requireParamName, - 'require-param-type': requireParamType, - 'require-property': requireProperty, - 'require-property-description': requirePropertyDescription, - 'require-property-name': requirePropertyName, - 'require-property-type': requirePropertyType, - 'require-returns': requireReturns, - 'require-returns-check': requireReturnsCheck, - 'require-returns-description': requireReturnsDescription, - 'require-returns-type': requireReturnsType, - 'require-template': requireTemplate, - 'require-throws': requireThrows, - 'require-yields': requireYields, - 'require-yields-check': requireYieldsCheck, - 'sort-tags': sortTags, - 'tag-lines': tagLines, - 'text-escaping': textEscaping, - 'valid-types': validTypes, - }, -}; - -/** - * @param {"warn"|"error"} warnOrError - * @param {string} [flatName] - * @returns {import('eslint').Linter.FlatConfig} - */ -const createRecommendedRuleset = (warnOrError, flatName) => { - return { - ...(flatName ? {name: 'jsdoc/' + flatName} : {}), - // @ts-expect-error Ok - plugins: - flatName ? { - jsdoc: index, - } : [ - 'jsdoc', - ], - rules: { - 'jsdoc/check-access': warnOrError, - 'jsdoc/check-alignment': warnOrError, - 'jsdoc/check-examples': 'off', - 'jsdoc/check-indentation': 'off', - 'jsdoc/check-line-alignment': 'off', - 'jsdoc/check-param-names': warnOrError, - 'jsdoc/check-property-names': warnOrError, - 'jsdoc/check-syntax': 'off', - 'jsdoc/check-tag-names': warnOrError, - 'jsdoc/check-types': warnOrError, - 'jsdoc/check-values': warnOrError, - 'jsdoc/convert-to-jsdoc-comments': 'off', - 'jsdoc/empty-tags': warnOrError, - 'jsdoc/implements-on-classes': warnOrError, - 'jsdoc/imports-as-dependencies': 'off', - 'jsdoc/informative-docs': 'off', - 'jsdoc/match-description': 'off', - 'jsdoc/match-name': 'off', - 'jsdoc/multiline-blocks': warnOrError, - 'jsdoc/no-bad-blocks': 'off', - 'jsdoc/no-blank-block-descriptions': 'off', - 'jsdoc/no-blank-blocks': 'off', - 'jsdoc/no-defaults': warnOrError, - 'jsdoc/no-missing-syntax': 'off', - 'jsdoc/no-multi-asterisks': warnOrError, - 'jsdoc/no-restricted-syntax': 'off', - 'jsdoc/no-types': 'off', - 'jsdoc/no-undefined-types': warnOrError, - 'jsdoc/require-asterisk-prefix': 'off', - 'jsdoc/require-description': 'off', - 'jsdoc/require-description-complete-sentence': 'off', - 'jsdoc/require-example': 'off', - 'jsdoc/require-file-overview': 'off', - 'jsdoc/require-hyphen-before-param-description': 'off', - 'jsdoc/require-jsdoc': warnOrError, - 'jsdoc/require-param': warnOrError, - 'jsdoc/require-param-description': warnOrError, - 'jsdoc/require-param-name': warnOrError, - 'jsdoc/require-param-type': warnOrError, - 'jsdoc/require-property': warnOrError, - 'jsdoc/require-property-description': warnOrError, - 'jsdoc/require-property-name': warnOrError, - 'jsdoc/require-property-type': warnOrError, - 'jsdoc/require-returns': warnOrError, - 'jsdoc/require-returns-check': warnOrError, - 'jsdoc/require-returns-description': warnOrError, - 'jsdoc/require-returns-type': warnOrError, - 'jsdoc/require-template': 'off', - 'jsdoc/require-throws': 'off', - 'jsdoc/require-yields': warnOrError, - 'jsdoc/require-yields-check': warnOrError, - 'jsdoc/sort-tags': 'off', - 'jsdoc/tag-lines': warnOrError, - 'jsdoc/text-escaping': 'off', - 'jsdoc/valid-types': warnOrError, - }, - }; -}; - -/** - * @param {"warn"|"error"} warnOrError - * @param {string} [flatName] - * @returns {import('eslint').Linter.FlatConfig} - */ -const createRecommendedTypeScriptRuleset = (warnOrError, flatName) => { - const ruleset = createRecommendedRuleset(warnOrError, flatName); - - return { - ...ruleset, - rules: { - ...ruleset.rules, - /* eslint-disable indent -- Extra indent to avoid use by auto-rule-editing */ - 'jsdoc/check-tag-names': [ - warnOrError, { - typed: true, - }, - ], - 'jsdoc/no-types': warnOrError, - 'jsdoc/no-undefined-types': 'off', - 'jsdoc/require-param-type': 'off', - 'jsdoc/require-property-type': 'off', - 'jsdoc/require-returns-type': 'off', - /* eslint-enable indent */ - }, - }; -}; - -/** - * @param {"warn"|"error"} warnOrError - * @param {string} [flatName] - * @returns {import('eslint').Linter.FlatConfig} - */ -const createRecommendedTypeScriptFlavorRuleset = (warnOrError, flatName) => { - const ruleset = createRecommendedRuleset(warnOrError, flatName); - - return { - ...ruleset, - rules: { - ...ruleset.rules, - /* eslint-disable indent -- Extra indent to avoid use by auto-rule-editing */ - 'jsdoc/no-undefined-types': 'off', - /* eslint-enable indent */ - }, - }; -}; - -/* c8 ignore next 3 -- TS */ -if (!index.configs) { - throw new Error('TypeScript guard'); -} - -index.configs.recommended = createRecommendedRuleset('warn'); -index.configs['recommended-error'] = createRecommendedRuleset('error'); -index.configs['recommended-typescript'] = createRecommendedTypeScriptRuleset('warn'); -index.configs['recommended-typescript-error'] = createRecommendedTypeScriptRuleset('error'); -index.configs['recommended-typescript-flavor'] = createRecommendedTypeScriptFlavorRuleset('warn'); -index.configs['recommended-typescript-flavor-error'] = createRecommendedTypeScriptFlavorRuleset('error'); - -index.configs['flat/recommended'] = createRecommendedRuleset('warn', 'flat/recommended'); -index.configs['flat/recommended-error'] = createRecommendedRuleset('error', 'flat/recommended-error'); -index.configs['flat/recommended-typescript'] = createRecommendedTypeScriptRuleset('warn', 'flat/recommended-typescript'); -index.configs['flat/recommended-typescript-error'] = createRecommendedTypeScriptRuleset('error', 'flat/recommended-typescript-error'); -index.configs['flat/recommended-typescript-flavor'] = createRecommendedTypeScriptFlavorRuleset('warn', 'flat/recommended-typescript-flavor'); -index.configs['flat/recommended-typescript-flavor-error'] = createRecommendedTypeScriptFlavorRuleset('error', 'flat/recommended-typescript-flavor-error'); - -export default index; diff --git a/tools/eslint/node_modules/eslint-plugin-jsdoc/src/iterateJsdoc.js b/tools/eslint/node_modules/eslint-plugin-jsdoc/src/iterateJsdoc.js deleted file mode 100644 index 9eeddf9b0b41e7..00000000000000 --- a/tools/eslint/node_modules/eslint-plugin-jsdoc/src/iterateJsdoc.js +++ /dev/null @@ -1,2555 +0,0 @@ -import jsdocUtils from './jsdocUtils.js'; -import { - commentHandler, - getJSDocComment, - parseComment, -} from '@es-joy/jsdoccomment'; -import { - stringify as commentStringify, - util, -} from 'comment-parser'; -import esquery from 'esquery'; - -/** - * @typedef {number} Integer - */ - -/** - * @typedef {import('@es-joy/jsdoccomment').JsdocBlockWithInline} JsdocBlockWithInline - */ - -/** - * @typedef {{ - * disallowName?: string, - * allowName?: string, - * context?: string, - * comment?: string, - * tags?: string[], - * replacement?: string, - * minimum?: Integer, - * message?: string, - * forceRequireReturn?: boolean - * }} ContextObject - */ -/** - * @typedef {string|ContextObject} Context - */ - -/** - * @callback CheckJsdoc - * @param {{ - * lastIndex?: Integer, - * isFunctionContext?: boolean, - * selector?: string, - * comment?: string - * }} info - * @param {null|((jsdoc: import('@es-joy/jsdoccomment').JsdocBlockWithInline) => boolean|undefined)} handler - * @param {import('eslint').Rule.Node} node - * @returns {void} - */ - -/** - * @callback ForEachPreferredTag - * @param {string} tagName - * @param {( - * matchingJsdocTag: import('@es-joy/jsdoccomment').JsdocTagWithInline, - * targetTagName: string - * ) => void} arrayHandler - * @param {boolean} [skipReportingBlockedTag] - * @returns {void} - */ - -/** - * @callback ReportSettings - * @param {string} message - * @returns {void} - */ - -/** - * @callback ParseClosureTemplateTag - * @param {import('comment-parser').Spec} tag - * @returns {string[]} - */ - -/** - * @callback GetPreferredTagNameObject - * @param {{ - * tagName: string - * }} cfg - * @returns {string|false|{ - * message: string; - * replacement?: string|undefined - * }|{ - * blocked: true, - * tagName: string - * }} - */ - -/** - * @typedef {{ - * forEachPreferredTag: ForEachPreferredTag, - * reportSettings: ReportSettings, - * parseClosureTemplateTag: ParseClosureTemplateTag, - * getPreferredTagNameObject: GetPreferredTagNameObject, - * pathDoesNotBeginWith: import('./jsdocUtils.js').PathDoesNotBeginWith - * }} BasicUtils - */ - -/** - * @callback IsIteratingFunction - * @returns {boolean} - */ - -/** - * @callback IsVirtualFunction - * @returns {boolean} - */ - -/** - * @callback Stringify - * @param {import('comment-parser').Block} tagBlock - * @param {boolean} [specRewire] - * @returns {string} - */ - -/** - * @callback ReportJSDoc - * @param {string} msg - * @param {null|import('comment-parser').Spec|{line: Integer, column?: Integer}} [tag] - * @param {(() => void)|null} [handler] - * @param {boolean} [specRewire] - * @param {undefined|{ - * [key: string]: string - * }} [data] - */ - -/** - * @callback GetRegexFromString - * @param {string} str - * @param {string} [requiredFlags] - * @returns {RegExp} - */ - -/** - * @callback GetTagDescription - * @param {import('comment-parser').Spec} tg - * @param {boolean} [returnArray] - * @returns {string[]|string} - */ - -/** - * @callback SetTagDescription - * @param {import('comment-parser').Spec} tg - * @param {RegExp} matcher - * @param {(description: string) => string} setter - * @returns {Integer} - */ - -/** - * @callback GetDescription - * @returns {{ - * description: string, - * descriptions: string[], - * lastDescriptionLine: Integer - * }} - */ - -/** - * @callback SetBlockDescription - * @param {( - * info: { - * delimiter: string, - * postDelimiter: string, - * start: string - * }, - * seedTokens: ( - * tokens?: Partial - * ) => import('comment-parser').Tokens, - * descLines: string[] - * ) => import('comment-parser').Line[]} setter - * @returns {void} - */ - -/** - * @callback SetDescriptionLines - * @param {RegExp} matcher - * @param {(description: string) => string} setter - * @returns {Integer} - */ - -/** - * @callback ChangeTag - * @param {import('comment-parser').Spec} tag - * @param {...Partial} tokens - * @returns {void} - */ - -/** - * @callback SetTag - * @param {import('comment-parser').Spec & { - * line: Integer - * }} tag - * @param {Partial} [tokens] - * @returns {void} - */ - -/** - * @callback RemoveTag - * @param {Integer} tagIndex - * @param {{ - * removeEmptyBlock?: boolean, - * tagSourceOffset?: Integer - * }} [cfg] - * @returns {void} - */ - -/** - * @callback AddTag - * @param {string} targetTagName - * @param {Integer} [number] - * @param {import('comment-parser').Tokens|{}} [tokens] - * @returns {void} - */ - -/** - * @callback GetFirstLine - * @returns {Integer|undefined} - */ - -/** - * @typedef {( - * tokens?: Partial | undefined - * ) => import('comment-parser').Tokens} SeedTokens - */ - -/** - * Sets tokens to empty string. - * @callback EmptyTokens - * @param {import('comment-parser').Tokens} tokens - * @returns {void} - */ - -/** - * @callback AddLine - * @param {Integer} sourceIndex - * @param {Partial} tokens - * @returns {void} - */ - -/** - * @callback AddLines - * @param {Integer} tagIndex - * @param {Integer} tagSourceOffset - * @param {Integer} numLines - * @returns {void} - */ - -/** - * @callback MakeMultiline - * @returns {void} - */ - -/** - * @callback GetFunctionParameterNames - * @param {boolean} [useDefaultObjectProperties] - * @returns {import('./jsdocUtils.js').ParamNameInfo[]} - */ - -/** - * @callback HasParams - * @returns {Integer} - */ - -/** - * @callback IsGenerator - * @returns {boolean} - */ - -/** - * @callback IsConstructor - * @returns {boolean} - */ - -/** - * @callback GetJsdocTagsDeep - * @param {string} tagName - * @returns {false|{ - * idx: Integer, - * name: string, - * type: string - * }[]} - */ - -/** - * @callback GetPreferredTagName - * @param {{ - * tagName: string, - * skipReportingBlockedTag?: boolean, - * allowObjectReturn?: boolean, - * defaultMessage?: string - * }} cfg - * @returns {string|undefined|false|{ - * message: string; - * replacement?: string|undefined; - * }|{ - * blocked: true, - * tagName: string - * }} - */ - -/** - * @callback IsValidTag - * @param {string} name - * @param {string[]} definedTags - * @returns {boolean} - */ - -/** - * @callback HasATag - * @param {string[]} names - * @returns {boolean} - */ - -/** - * @callback HasTag - * @param {string} name - * @returns {boolean} - */ - -/** - * @callback ComparePaths - * @param {string} name - * @returns {(otherPathName: string) => boolean} - */ - -/** - * @callback DropPathSegmentQuotes - * @param {string} name - * @returns {string} - */ - -/** - * @callback AvoidDocs - * @returns {boolean} - */ - -/** - * @callback TagMightHaveNamePositionTypePosition - * @param {string} tagName - * @param {import('./getDefaultTagStructureForMode.js'). - * TagStructure[]} [otherModeMaps] - * @returns {boolean|{otherMode: true}} - */ - -/** - * @callback TagMustHave - * @param {string} tagName - * @param {import('./getDefaultTagStructureForMode.js'). - * TagStructure[]} otherModeMaps - * @returns {boolean|{ - * otherMode: false - * }} - */ - -/** - * @callback TagMissingRequiredTypeOrNamepath - * @param {import('comment-parser').Spec} tag - * @param {import('./getDefaultTagStructureForMode.js'). - * TagStructure[]} otherModeMaps - * @returns {boolean|{ - * otherMode: false - * }} - */ - -/** - * @callback IsNamepathX - * @param {string} tagName - * @returns {boolean} - */ - -/** - * @callback GetTagStructureForMode - * @param {import('./jsdocUtils.js').ParserMode} mde - * @returns {import('./getDefaultTagStructureForMode.js').TagStructure} - */ - -/** - * @callback MayBeUndefinedTypeTag - * @param {import('comment-parser').Spec} tag - * @returns {boolean} - */ - -/** - * @callback HasValueOrExecutorHasNonEmptyResolveValue - * @param {boolean} anyPromiseAsReturn - * @param {boolean} [allBranches] - * @returns {boolean} - */ - -/** - * @callback HasYieldValue - * @returns {boolean} - */ - -/** - * @callback HasYieldReturnValue - * @returns {boolean} - */ - -/** - * @callback HasThrowValue - * @returns {boolean} - */ - -/** - * @callback IsAsync - * @returns {boolean|undefined} - */ - -/** - * @callback GetTags - * @param {string} tagName - * @returns {import('comment-parser').Spec[]} - */ - -/** - * @callback GetPresentTags - * @param {string[]} tagList - * @returns {import('@es-joy/jsdoccomment').JsdocTagWithInline[]} - */ - -/** - * @callback FilterTags - * @param {(tag: import('@es-joy/jsdoccomment').JsdocTagWithInline) => boolean} filter - * @returns {import('@es-joy/jsdoccomment').JsdocTagWithInline[]} - */ - -/** - * @callback FilterAllTags - * @param {(tag: (import('comment-parser').Spec| - * import('@es-joy/jsdoccomment').JsdocInlineTagNoType)) => boolean} filter - * @returns {(import('comment-parser').Spec| - * import('@es-joy/jsdoccomment').JsdocInlineTagNoType)[]} - */ - -/** - * @callback GetTagsByType - * @param {import('comment-parser').Spec[]} tags - * @returns {{ - * tagsWithNames: import('comment-parser').Spec[], - * tagsWithoutNames: import('comment-parser').Spec[] - * }} - */ - -/** - * @callback HasOptionTag - * @param {string} tagName - * @returns {boolean} - */ - -/** - * @callback GetClassNode - * @returns {Node|null} - */ - -/** - * @callback GetClassJsdoc - * @returns {null|JsdocBlockWithInline} - */ - -/** - * @callback ClassHasTag - * @param {string} tagName - * @returns {boolean} - */ - -/** - * @callback FindContext - * @param {Context[]} contexts - * @param {string|undefined} comment - * @returns {{ - * foundContext: Context|undefined, - * contextStr: string - * }} - */ - -/** - * @typedef {BasicUtils & { - * isIteratingFunction: IsIteratingFunction, - * isVirtualFunction: IsVirtualFunction, - * stringify: Stringify, - * reportJSDoc: ReportJSDoc, - * getRegexFromString: GetRegexFromString, - * getTagDescription: GetTagDescription, - * setTagDescription: SetTagDescription, - * getDescription: GetDescription, - * setBlockDescription: SetBlockDescription, - * setDescriptionLines: SetDescriptionLines, - * changeTag: ChangeTag, - * setTag: SetTag, - * removeTag: RemoveTag, - * addTag: AddTag, - * getFirstLine: GetFirstLine, - * seedTokens: SeedTokens, - * emptyTokens: EmptyTokens, - * addLine: AddLine, - * addLines: AddLines, - * makeMultiline: MakeMultiline, - * flattenRoots: import('./jsdocUtils.js').FlattenRoots, - * getFunctionParameterNames: GetFunctionParameterNames, - * hasParams: HasParams, - * isGenerator: IsGenerator, - * isConstructor: IsConstructor, - * getJsdocTagsDeep: GetJsdocTagsDeep, - * getPreferredTagName: GetPreferredTagName, - * isValidTag: IsValidTag, - * hasATag: HasATag, - * hasTag: HasTag, - * comparePaths: ComparePaths, - * dropPathSegmentQuotes: DropPathSegmentQuotes, - * avoidDocs: AvoidDocs, - * tagMightHaveNamePosition: TagMightHaveNamePositionTypePosition, - * tagMightHaveTypePosition: TagMightHaveNamePositionTypePosition, - * tagMustHaveNamePosition: TagMustHave, - * tagMustHaveTypePosition: TagMustHave, - * tagMissingRequiredTypeOrNamepath: TagMissingRequiredTypeOrNamepath, - * isNamepathDefiningTag: IsNamepathX, - * isNamepathReferencingTag: IsNamepathX, - * isNamepathOrUrlReferencingTag: IsNamepathX, - * tagMightHaveNamepath: IsNamepathX, - * getTagStructureForMode: GetTagStructureForMode, - * mayBeUndefinedTypeTag: MayBeUndefinedTypeTag, - * hasValueOrExecutorHasNonEmptyResolveValue: HasValueOrExecutorHasNonEmptyResolveValue, - * hasYieldValue: HasYieldValue, - * hasYieldReturnValue: HasYieldReturnValue, - * hasThrowValue: HasThrowValue, - * isAsync: IsAsync, - * getTags: GetTags, - * getPresentTags: GetPresentTags, - * filterTags: FilterTags, - * filterAllTags: FilterAllTags, - * getTagsByType: GetTagsByType, - * hasOptionTag: HasOptionTag, - * getClassNode: GetClassNode, - * getClassJsdoc: GetClassJsdoc, - * classHasTag: ClassHasTag, - * findContext: FindContext - * }} Utils - */ - -const { - rewireSpecs, - seedTokens, -} = util; - -// todo: Change these `any` types once importing types properly. - -/** - * Should use ESLint rule's typing. - * @typedef {import('eslint').Rule.RuleMetaData} EslintRuleMeta - */ - -/** - * A plain object for tracking state as needed by rules across iterations. - * @typedef {{ - * globalTags: {}, - * hasDuplicates: { - * [key: string]: boolean - * }, - * selectorMap: { - * [selector: string]: { - * [comment: string]: Integer - * } - * }, - * hasTag: { - * [key: string]: boolean - * }, - * hasNonComment: number, - * hasNonCommentBeforeTag: { - * [key: string]: boolean|number - * } - * }} StateObject - */ - -/** - * The Node AST as supplied by the parser. - * @typedef {import('eslint').Rule.Node} Node - */ - -/* -const { - align as commentAlign, - flow: commentFlow, - indent: commentIndent, -} = transforms; -*/ - -const globalState = new Map(); -/** - * @param {import('eslint').Rule.RuleContext} context - * @param {{ - * tagNamePreference?: import('./jsdocUtils.js').TagNamePreference, - * mode?: import('./jsdocUtils.js').ParserMode - * }} cfg - * @returns {BasicUtils} - */ -const getBasicUtils = (context, { - tagNamePreference, - mode, -}) => { - /** @type {BasicUtils} */ - const utils = {}; - - /** @type {ReportSettings} */ - utils.reportSettings = (message) => { - context.report({ - loc: { - end: { - column: 1, - line: 1, - }, - start: { - column: 1, - line: 1, - }, - }, - message, - }); - }; - - /** @type {ParseClosureTemplateTag} */ - utils.parseClosureTemplateTag = (tag) => { - return jsdocUtils.parseClosureTemplateTag(tag); - }; - - utils.pathDoesNotBeginWith = jsdocUtils.pathDoesNotBeginWith; - - /** @type {GetPreferredTagNameObject} */ - utils.getPreferredTagNameObject = ({ - tagName, - }) => { - const ret = jsdocUtils.getPreferredTagName( - context, - /** @type {import('./jsdocUtils.js').ParserMode} */ (mode), - tagName, - tagNamePreference, - ); - const isObject = ret && typeof ret === 'object'; - if (ret === false || (isObject && !ret.replacement)) { - return { - blocked: true, - tagName, - }; - } - - return ret; - }; - - return utils; -}; - -/** - * @callback Report - * @param {string} message - * @param {import('eslint').Rule.ReportFixer|null} [fix] - * @param {null| - * {line?: Integer, column?: Integer}| - * import('comment-parser').Spec & {line?: Integer} - * } [jsdocLoc] - * @param {undefined|{ - * [key: string]: string - * }} [data] - * @returns {void} - */ - -/** - * @param {Node|null} node - * @param {JsdocBlockWithInline} jsdoc - * @param {import('eslint').AST.Token} jsdocNode - * @param {Settings} settings - * @param {Report} report - * @param {import('eslint').Rule.RuleContext} context - * @param {import('eslint').SourceCode} sc - * @param {boolean|undefined} iteratingAll - * @param {RuleConfig} ruleConfig - * @param {string} indent - * @returns {Utils} - */ -const getUtils = ( - node, - jsdoc, - jsdocNode, - settings, - report, - context, - sc, - iteratingAll, - ruleConfig, - indent, -) => { - const ancestors = /** @type {import('eslint').Rule.Node[]} */ (node ? - (sc.getAncestors ? - ( - sc.getAncestors(node) - /* c8 ignore next 4 */ - ) : - ( - context.getAncestors() - )) : - []); - - /* c8 ignore next -- Fallback to deprecated method */ - const { - sourceCode = context.getSourceCode(), - } = context; - - const utils = /** @type {Utils} */ (getBasicUtils(context, settings)); - - const { - tagNamePreference, - overrideReplacesDocs, - ignoreReplacesDocs, - implementsReplacesDocs, - augmentsExtendsReplacesDocs, - maxLines, - minLines, - mode, - } = settings; - - /** @type {IsIteratingFunction} */ - utils.isIteratingFunction = () => { - return !iteratingAll || [ - 'MethodDefinition', - 'ArrowFunctionExpression', - 'FunctionDeclaration', - 'FunctionExpression', - ].includes(String(node && node.type)); - }; - - /** @type {IsVirtualFunction} */ - utils.isVirtualFunction = () => { - return Boolean(iteratingAll) && utils.hasATag([ - 'callback', 'function', 'func', 'method', - ]); - }; - - /** @type {Stringify} */ - utils.stringify = (tagBlock, specRewire) => { - let block; - if (specRewire) { - block = rewireSpecs(tagBlock); - } - - return commentStringify(/** @type {import('comment-parser').Block} */ ( - specRewire ? block : tagBlock)); - }; - - /** @type {ReportJSDoc} */ - utils.reportJSDoc = (msg, tag, handler, specRewire, data) => { - report(msg, handler ? /** @type {import('eslint').Rule.ReportFixer} */ ( - fixer, - ) => { - handler(); - const replacement = utils.stringify(jsdoc, specRewire); - - if (!replacement) { - const text = sourceCode.getText(); - const lastLineBreakPos = text.slice( - 0, jsdocNode.range[0], - ).search(/\n[ \t]*$/u); - if (lastLineBreakPos > -1) { - return fixer.removeRange([ - lastLineBreakPos, jsdocNode.range[1], - ]); - } - - return fixer.removeRange( - (/\s/u).test(text.charAt(jsdocNode.range[1])) ? - [ - jsdocNode.range[0], jsdocNode.range[1] + 1, - ] : - jsdocNode.range, - ); - } - - return fixer.replaceText(jsdocNode, replacement); - } : null, tag, data); - }; - - /** @type {GetRegexFromString} */ - utils.getRegexFromString = (str, requiredFlags) => { - return jsdocUtils.getRegexFromString(str, requiredFlags); - }; - - /** @type {GetTagDescription} */ - utils.getTagDescription = (tg, returnArray) => { - /** - * @type {string[]} - */ - const descriptions = []; - tg.source.some(({ - tokens: { - end, - lineEnd, - postDelimiter, - tag, - postTag, - name, - type, - description, - }, - }) => { - const desc = ( - tag && postTag || - !tag && !name && !type && postDelimiter || '' - - // Remove space - ).slice(1) + - (description || '') + (lineEnd || ''); - - if (end) { - if (desc) { - descriptions.push(desc); - } - - return true; - } - - descriptions.push(desc); - - return false; - }); - - return returnArray ? descriptions : descriptions.join('\n'); - }; - - /** @type {SetTagDescription} */ - utils.setTagDescription = (tg, matcher, setter) => { - let finalIdx = 0; - tg.source.some(({ - tokens: { - description, - }, - }, idx) => { - if (description && matcher.test(description)) { - tg.source[idx].tokens.description = setter(description); - finalIdx = idx; - return true; - } - - return false; - }); - - return finalIdx; - }; - - /** @type {GetDescription} */ - utils.getDescription = () => { - /** @type {string[]} */ - const descriptions = []; - let lastDescriptionLine = 0; - let tagsBegun = false; - jsdoc.source.some(({ - tokens: { - description, - tag, - end, - }, - }, idx) => { - if (tag) { - tagsBegun = true; - } - - if (idx && (tag || end)) { - lastDescriptionLine = idx - 1; - if (!tagsBegun && description) { - descriptions.push(description); - } - - return true; - } - - if (!tagsBegun && (idx || description)) { - descriptions.push(description || (descriptions.length ? '' : '\n')); - } - - return false; - }); - - return { - description: descriptions.join('\n'), - descriptions, - lastDescriptionLine, - }; - }; - - /** @type {SetBlockDescription} */ - utils.setBlockDescription = (setter) => { - /** @type {string[]} */ - const descLines = []; - /** - * @type {undefined|Integer} - */ - let startIdx; - /** - * @type {undefined|Integer} - */ - let endIdx; - - /** - * @type {undefined|{ - * delimiter: string, - * postDelimiter: string, - * start: string - * }} - */ - let info; - - jsdoc.source.some(({ - tokens: { - description, - start, - delimiter, - postDelimiter, - tag, - end, - }, - }, idx) => { - if (delimiter === '/**') { - return false; - } - - if (startIdx === undefined) { - startIdx = idx; - info = { - delimiter, - postDelimiter, - start, - }; - } - - if (tag || end) { - endIdx = idx; - return true; - } - - descLines.push(description); - return false; - }); - - /* c8 ignore else -- Won't be called if missing */ - if (descLines.length) { - jsdoc.source.splice( - /** @type {Integer} */ (startIdx), - /** @type {Integer} */ (endIdx) - /** @type {Integer} */ (startIdx), - ...setter( - /** - * @type {{ - * delimiter: string, - * postDelimiter: string, - * start: string - * }} - */ - (info), - seedTokens, - descLines, - ), - ); - } - }; - - /** @type {SetDescriptionLines} */ - utils.setDescriptionLines = (matcher, setter) => { - let finalIdx = 0; - jsdoc.source.some(({ - tokens: { - description, - tag, - end, - }, - }, idx) => { - /* c8 ignore next 3 -- Already checked */ - if (idx && (tag || end)) { - return true; - } - - if (description && matcher.test(description)) { - jsdoc.source[idx].tokens.description = setter(description); - finalIdx = idx; - return true; - } - - return false; - }); - - return finalIdx; - }; - - /** @type {ChangeTag} */ - utils.changeTag = (tag, ...tokens) => { - for (const [ - idx, - src, - ] of tag.source.entries()) { - src.tokens = { - ...src.tokens, - ...tokens[idx], - }; - } - }; - - /** @type {SetTag} */ - utils.setTag = (tag, tokens) => { - tag.source = [ - { - number: tag.line, - // Or tag.source[0].number? - source: '', - tokens: seedTokens({ - delimiter: '*', - postDelimiter: ' ', - start: indent + ' ', - tag: '@' + tag.tag, - ...tokens, - }), - }, - ]; - }; - - /** @type {RemoveTag} */ - utils.removeTag = (tagIndex, { - removeEmptyBlock = false, - tagSourceOffset = 0, - } = {}) => { - const { - source: tagSource, - } = jsdoc.tags[tagIndex]; - /** @type {Integer|undefined} */ - let lastIndex; - const firstNumber = jsdoc.source[0].number; - tagSource.some(({ - number, - }, tagIdx) => { - const sourceIndex = jsdoc.source.findIndex(({ - number: srcNumber, - }) => { - return number === srcNumber; - }); - // c8 ignore else - if (sourceIndex > -1) { - let spliceCount = 1; - tagSource.slice(tagIdx + 1).some(({ - tokens: { - tag, - end: ending, - }, - }) => { - if (!tag && !ending) { - spliceCount++; - - return false; - } - - return true; - }); - - const spliceIdx = sourceIndex + tagSourceOffset; - - const { - delimiter, - end, - } = jsdoc.source[spliceIdx].tokens; - - if ( - spliceIdx === 0 && jsdoc.tags.length >= 2 || - !removeEmptyBlock && (end || delimiter === '/**') - ) { - const { - tokens, - } = jsdoc.source[spliceIdx]; - for (const item of [ - 'postDelimiter', - 'tag', - 'postTag', - 'type', - 'postType', - 'name', - 'postName', - 'description', - ]) { - tokens[ - /** - * @type {"postDelimiter"|"tag"|"type"|"postType"| - * "postTag"|"name"|"postName"|"description"} - */ ( - item - ) - ] = ''; - } - } else { - jsdoc.source.splice(spliceIdx, spliceCount - tagSourceOffset + (spliceIdx ? 0 : jsdoc.source.length)); - tagSource.splice(tagIdx + tagSourceOffset, spliceCount - tagSourceOffset + (spliceIdx ? 0 : jsdoc.source.length)); - } - - lastIndex = sourceIndex; - - return true; - } - /* c8 ignore next */ - return false; - }); - for (const [ - idx, - src, - ] of jsdoc.source.slice(lastIndex).entries()) { - src.number = firstNumber + /** @type {Integer} */ (lastIndex) + idx; - } - - // Todo: Once rewiring of tags may be fixed in comment-parser to reflect - // missing tags, this step should be added here (so that, e.g., - // if accessing `jsdoc.tags`, such as to add a new tag, the - // correct information will be available) - }; - - /** @type {AddTag} */ - utils.addTag = ( - targetTagName, - number = (jsdoc.tags[jsdoc.tags.length - 1]?.source[0]?.number ?? jsdoc.source.findIndex(({ - tokens: { - tag, - }, - }) => { - return tag; - }) - 1) + 1, - tokens = {}, - ) => { - jsdoc.source.splice(number, 0, { - number, - source: '', - tokens: seedTokens({ - delimiter: '*', - postDelimiter: ' ', - start: indent + ' ', - tag: `@${targetTagName}`, - ...tokens, - }), - }); - for (const src of jsdoc.source.slice(number + 1)) { - src.number++; - } - }; - - /** @type {GetFirstLine} */ - utils.getFirstLine = () => { - let firstLine; - for (const { - number, - tokens: { - tag, - }, - } of jsdoc.source) { - if (tag) { - firstLine = number; - break; - } - } - - return firstLine; - }; - - /** @type {SeedTokens} */ - utils.seedTokens = seedTokens; - - /** @type {EmptyTokens} */ - utils.emptyTokens = (tokens) => { - for (const prop of [ - 'start', - 'postDelimiter', - 'tag', - 'type', - 'postType', - 'postTag', - 'name', - 'postName', - 'description', - 'end', - 'lineEnd', - ]) { - tokens[ - /** - * @type {"start"|"postDelimiter"|"tag"|"type"|"postType"| - * "postTag"|"name"|"postName"|"description"|"end"|"lineEnd"} - */ ( - prop - ) - ] = ''; - } - }; - - /** @type {AddLine} */ - utils.addLine = (sourceIndex, tokens) => { - const number = (jsdoc.source[sourceIndex - 1]?.number || 0) + 1; - jsdoc.source.splice(sourceIndex, 0, { - number, - source: '', - tokens: seedTokens(tokens), - }); - - for (const src of jsdoc.source.slice(number + 1)) { - src.number++; - } - // If necessary, we can rewire the tags (misnamed method) - // rewireSource(jsdoc); - }; - - /** @type {AddLines} */ - utils.addLines = (tagIndex, tagSourceOffset, numLines) => { - const { - source: tagSource, - } = jsdoc.tags[tagIndex]; - /** @type {Integer|undefined} */ - let lastIndex; - const firstNumber = jsdoc.source[0].number; - tagSource.some(({ - number, - }) => { - const makeLine = () => { - return { - number, - source: '', - tokens: seedTokens({ - delimiter: '*', - start: indent + ' ', - }), - }; - }; - - const makeLines = () => { - return Array.from({ - length: numLines, - }, makeLine); - }; - - const sourceIndex = jsdoc.source.findIndex(({ - number: srcNumber, - tokens: { - end, - }, - }) => { - return number === srcNumber && !end; - }); - // c8 ignore else - if (sourceIndex > -1) { - const lines = makeLines(); - jsdoc.source.splice(sourceIndex + tagSourceOffset, 0, ...lines); - - // tagSource.splice(tagIdx + 1, 0, ...makeLines()); - lastIndex = sourceIndex; - - return true; - } - /* c8 ignore next */ - return false; - }); - - for (const [ - idx, - src, - ] of jsdoc.source.slice(lastIndex).entries()) { - src.number = firstNumber + /** @type {Integer} */ (lastIndex) + idx; - } - }; - - /** @type {MakeMultiline} */ - utils.makeMultiline = () => { - const { - source: [ - { - tokens, - }, - ], - } = jsdoc; - const { - postDelimiter, - description, - lineEnd, - tag, - name, - type, - } = tokens; - - let { - tokens: { - postName, - postTag, - postType, - }, - } = jsdoc.source[0]; - - // Strip trailing leftovers from single line ending - if (!description) { - if (postName) { - postName = ''; - } else if (postType) { - postType = ''; - } else /* c8 ignore else -- `comment-parser` prevents empty blocks currently per https://github.com/syavorsky/comment-parser/issues/128 */ if (postTag) { - postTag = ''; - } - } - - utils.emptyTokens(tokens); - - utils.addLine(1, { - delimiter: '*', - - // If a description were present, it may have whitespace attached - // due to being at the end of the single line - description: description.trimEnd(), - name, - postDelimiter, - postName, - postTag, - postType, - start: indent + ' ', - tag, - type, - }); - utils.addLine(2, { - end: '*/', - lineEnd, - start: indent + ' ', - }); - }; - - /** - * @type {import('./jsdocUtils.js').FlattenRoots} - */ - utils.flattenRoots = jsdocUtils.flattenRoots; - - /** @type {GetFunctionParameterNames} */ - utils.getFunctionParameterNames = (useDefaultObjectProperties) => { - return jsdocUtils.getFunctionParameterNames(node, useDefaultObjectProperties); - }; - - /** @type {HasParams} */ - utils.hasParams = () => { - return jsdocUtils.hasParams(/** @type {Node} */ (node)); - }; - - /** @type {IsGenerator} */ - utils.isGenerator = () => { - return node !== null && Boolean( - /** - * @type {import('estree').FunctionDeclaration| - * import('estree').FunctionExpression} - */ (node).generator || - node.type === 'MethodDefinition' && node.value.generator || - [ - 'ExportNamedDeclaration', 'ExportDefaultDeclaration', - ].includes(node.type) && - /** @type {import('estree').FunctionDeclaration} */ - ( - /** - * @type {import('estree').ExportNamedDeclaration| - * import('estree').ExportDefaultDeclaration} - */ (node).declaration - )?.generator, - ); - }; - - /** @type {IsConstructor} */ - utils.isConstructor = () => { - return jsdocUtils.isConstructor(/** @type {Node} */ (node)); - }; - - /** @type {GetJsdocTagsDeep} */ - utils.getJsdocTagsDeep = (tagName) => { - const name = /** @type {string|false} */ (utils.getPreferredTagName({ - tagName, - })); - if (!name) { - return false; - } - - return jsdocUtils.getJsdocTagsDeep(jsdoc, name); - }; - - /** @type {GetPreferredTagName} */ - utils.getPreferredTagName = ({ - tagName, - skipReportingBlockedTag = false, - allowObjectReturn = false, - defaultMessage = `Unexpected tag \`@${tagName}\``, - }) => { - const ret = jsdocUtils.getPreferredTagName(context, mode, tagName, tagNamePreference); - const isObject = ret && typeof ret === 'object'; - if (utils.hasTag(tagName) && (ret === false || isObject && !ret.replacement)) { - if (skipReportingBlockedTag) { - return { - blocked: true, - tagName, - }; - } - - const message = isObject && ret.message || defaultMessage; - report(message, null, utils.getTags(tagName)[0]); - - return false; - } - - return isObject && !allowObjectReturn ? ret.replacement : ret; - }; - - /** @type {IsValidTag} */ - utils.isValidTag = (name, definedTags) => { - return jsdocUtils.isValidTag(context, mode, name, definedTags); - }; - - /** @type {HasATag} */ - utils.hasATag = (names) => { - return jsdocUtils.hasATag(jsdoc, names); - }; - - /** @type {HasTag} */ - utils.hasTag = (name) => { - return jsdocUtils.hasTag(jsdoc, name); - }; - - /** @type {ComparePaths} */ - utils.comparePaths = (name) => { - return jsdocUtils.comparePaths(name); - }; - - /** @type {DropPathSegmentQuotes} */ - utils.dropPathSegmentQuotes = (name) => { - return jsdocUtils.dropPathSegmentQuotes(name); - }; - - /** @type {AvoidDocs} */ - utils.avoidDocs = () => { - if ( - ignoreReplacesDocs !== false && - (utils.hasTag('ignore') || utils.classHasTag('ignore')) || - overrideReplacesDocs !== false && - (utils.hasTag('override') || utils.classHasTag('override')) || - implementsReplacesDocs !== false && - (utils.hasTag('implements') || utils.classHasTag('implements')) || - - augmentsExtendsReplacesDocs && - (utils.hasATag([ - 'augments', 'extends', - ]) || - utils.classHasTag('augments') || - utils.classHasTag('extends'))) { - return true; - } - - if (jsdocUtils.exemptSpeciaMethods( - jsdoc, - node, - context, - /** @type {import('json-schema').JSONSchema4|import('json-schema').JSONSchema4[]} */ ( - ruleConfig.meta.schema - ), - )) { - return true; - } - - const exemptedBy = context.options[0]?.exemptedBy ?? [ - 'inheritDoc', - ...mode === 'closure' ? [] : [ - 'inheritdoc', - ], - ]; - if (exemptedBy.length && utils.getPresentTags(exemptedBy).length) { - return true; - } - - return false; - }; - - for (const method of [ - 'tagMightHaveNamePosition', - 'tagMightHaveTypePosition', - ]) { - /** @type {TagMightHaveNamePositionTypePosition} */ - utils[ - /** @type {"tagMightHaveNamePosition"|"tagMightHaveTypePosition"} */ ( - method - ) - ] = (tagName, otherModeMaps) => { - const result = jsdocUtils[ - /** @type {"tagMightHaveNamePosition"|"tagMightHaveTypePosition"} */ - (method) - ](tagName); - if (result) { - return true; - } - - if (!otherModeMaps) { - return false; - } - - const otherResult = otherModeMaps.some((otherModeMap) => { - return jsdocUtils[ - /** @type {"tagMightHaveNamePosition"|"tagMightHaveTypePosition"} */ - (method) - ](tagName, otherModeMap); - }); - - return otherResult ? { - otherMode: true, - } : false; - }; - } - - /** @type {TagMissingRequiredTypeOrNamepath} */ - utils.tagMissingRequiredTypeOrNamepath = (tagName, otherModeMaps) => { - const result = jsdocUtils.tagMissingRequiredTypeOrNamepath(tagName); - if (!result) { - return false; - } - - const otherResult = otherModeMaps.every((otherModeMap) => { - return jsdocUtils.tagMissingRequiredTypeOrNamepath(tagName, otherModeMap); - }); - - return otherResult ? true : { - otherMode: false, - }; - }; - - for (const method of [ - 'tagMustHaveNamePosition', - 'tagMustHaveTypePosition', - ]) { - /** @type {TagMustHave} */ - utils[ - /** @type {"tagMustHaveNamePosition"|"tagMustHaveTypePosition"} */ - (method) - ] = (tagName, otherModeMaps) => { - const result = jsdocUtils[ - /** @type {"tagMustHaveNamePosition"|"tagMustHaveTypePosition"} */ - (method) - ](tagName); - if (!result) { - return false; - } - - // if (!otherModeMaps) { return true; } - - const otherResult = otherModeMaps.every((otherModeMap) => { - return jsdocUtils[ - /** @type {"tagMustHaveNamePosition"|"tagMustHaveTypePosition"} */ - (method) - ](tagName, otherModeMap); - }); - - return otherResult ? true : { - otherMode: false, - }; - }; - } - - for (const method of [ - 'isNamepathDefiningTag', - 'isNamepathReferencingTag', - 'isNamepathOrUrlReferencingTag', - 'tagMightHaveNamepath', - ]) { - /** @type {IsNamepathX} */ - utils[ - /** @type {"isNamepathDefiningTag"|"isNamepathReferencingTag"|"isNamepathOrUrlReferencingTag"|"tagMightHaveNamepath"} */ ( - method - )] = (tagName) => { - return jsdocUtils[ - /** @type {"isNamepathDefiningTag"|"isNamepathReferencingTag"|"isNamepathOrUrlReferencingTag"|"tagMightHaveNamepath"} */ - (method) - ](tagName); - }; - } - - /** @type {GetTagStructureForMode} */ - utils.getTagStructureForMode = (mde) => { - return jsdocUtils.getTagStructureForMode(mde, settings.structuredTags); - }; - - /** @type {MayBeUndefinedTypeTag} */ - utils.mayBeUndefinedTypeTag = (tag) => { - return jsdocUtils.mayBeUndefinedTypeTag(tag, settings.mode); - }; - - /** @type {HasValueOrExecutorHasNonEmptyResolveValue} */ - utils.hasValueOrExecutorHasNonEmptyResolveValue = (anyPromiseAsReturn, allBranches) => { - return jsdocUtils.hasValueOrExecutorHasNonEmptyResolveValue( - /** @type {Node} */ (node), anyPromiseAsReturn, allBranches, - ); - }; - - /** @type {HasYieldValue} */ - utils.hasYieldValue = () => { - if ([ - 'ExportNamedDeclaration', 'ExportDefaultDeclaration', - ].includes(/** @type {Node} */ (node).type)) { - return jsdocUtils.hasYieldValue( - /** @type {import('estree').Declaration|import('estree').Expression} */ ( - /** @type {import('estree').ExportNamedDeclaration|import('estree').ExportDefaultDeclaration} */ - (node).declaration - ), - ); - } - - return jsdocUtils.hasYieldValue(/** @type {Node} */ (node)); - }; - - /** @type {HasYieldReturnValue} */ - utils.hasYieldReturnValue = () => { - return jsdocUtils.hasYieldValue(/** @type {Node} */ (node), true); - }; - - /** @type {HasThrowValue} */ - utils.hasThrowValue = () => { - return jsdocUtils.hasThrowValue(node); - }; - - /** @type {IsAsync} */ - utils.isAsync = () => { - return Boolean(node && 'async' in node && node.async); - }; - - /** @type {GetTags} */ - utils.getTags = (tagName) => { - return utils.filterTags((item) => { - return item.tag === tagName; - }); - }; - - /** @type {GetPresentTags} */ - utils.getPresentTags = (tagList) => { - return utils.filterTags((tag) => { - return tagList.includes(tag.tag); - }); - }; - - /** @type {FilterTags} */ - utils.filterTags = (filter) => { - return jsdoc.tags.filter((tag) => { - return filter(tag); - }); - }; - - /** @type {FilterAllTags} */ - utils.filterAllTags = (filter) => { - const tags = jsdocUtils.getAllTags(jsdoc); - return tags.filter((tag) => { - return filter(tag); - }); - }; - - /** @type {GetTagsByType} */ - utils.getTagsByType = (tags) => { - return jsdocUtils.getTagsByType(context, mode, tags); - }; - - /** @type {HasOptionTag} */ - utils.hasOptionTag = (tagName) => { - const { - tags, - } = context.options[0] ?? {}; - - return Boolean(tags && tags.includes(tagName)); - }; - - /** @type {GetClassNode} */ - utils.getClassNode = () => { - return [ - ...ancestors, node, - ].reverse().find((parent) => { - return parent && [ - 'ClassDeclaration', 'ClassExpression', - ].includes(parent.type); - }) ?? null; - }; - - /** @type {GetClassJsdoc} */ - utils.getClassJsdoc = () => { - const classNode = utils.getClassNode(); - - if (!classNode) { - return null; - } - - const classJsdocNode = getJSDocComment(sourceCode, classNode, { - maxLines, - minLines, - }); - - if (classJsdocNode) { - return parseComment(classJsdocNode, ''); - } - - return null; - }; - - /** @type {ClassHasTag} */ - utils.classHasTag = (tagName) => { - const classJsdoc = utils.getClassJsdoc(); - - return classJsdoc !== null && jsdocUtils.hasTag(classJsdoc, tagName); - }; - - /** @type {ForEachPreferredTag} */ - utils.forEachPreferredTag = (tagName, arrayHandler, skipReportingBlockedTag = false) => { - const targetTagName = /** @type {string|false} */ ( - utils.getPreferredTagName({ - skipReportingBlockedTag, - tagName, - }) - ); - if (!targetTagName || - skipReportingBlockedTag && targetTagName && typeof targetTagName === 'object' - ) { - return; - } - - const matchingJsdocTags = jsdoc.tags.filter(({ - tag, - }) => { - return tag === targetTagName; - }); - - for (const matchingJsdocTag of matchingJsdocTags) { - arrayHandler( - /** - * @type {import('@es-joy/jsdoccomment').JsdocTagWithInline} - */ ( - matchingJsdocTag - ), targetTagName, - ); - } - }; - - /** @type {FindContext} */ - utils.findContext = (contexts, comment) => { - const foundContext = contexts.find((cntxt) => { - return typeof cntxt === 'string' ? - esquery.matches( - /** @type {Node} */ (node), - esquery.parse(cntxt), - undefined, - { - visitorKeys: sourceCode.visitorKeys, - }, - ) : - (!cntxt.context || cntxt.context === 'any' || - esquery.matches( - /** @type {Node} */ (node), - esquery.parse(cntxt.context), - undefined, - { - visitorKeys: sourceCode.visitorKeys, - }, - )) && comment === cntxt.comment; - }); - - const contextStr = typeof foundContext === 'object' ? - foundContext.context ?? 'any' : - String(foundContext); - - return { - contextStr, - foundContext, - }; - }; - - return utils; -}; - -/** - * @typedef {{ - * [key: string]: false|string|{ - * message: string, - * replacement?: false|string - * skipRootChecking?: boolean - * } - * }} PreferredTypes - */ -/** - * @typedef {{ - * [key: string]: { - * name?: "text"|"namepath-defining"|"namepath-referencing"|false, - * type?: boolean|string[], - * required?: ("name"|"type"|"typeOrNameRequired")[] - * } - * }} StructuredTags - */ -/** - * Settings from ESLint types. - * @typedef {{ - * maxLines: Integer, - * minLines: Integer, - * tagNamePreference: import('./jsdocUtils.js').TagNamePreference, - * mode: import('./jsdocUtils.js').ParserMode, - * preferredTypes: PreferredTypes, - * structuredTags: StructuredTags, - * [name: string]: any, - * contexts?: Context[] - * }} Settings - */ - -/** - * @param {import('eslint').Rule.RuleContext} context - * @returns {Settings|false} - */ -const getSettings = (context) => { - /* dslint-disable canonical/sort-keys */ - const settings = { - // All rules - ignorePrivate: Boolean(context.settings.jsdoc?.ignorePrivate), - ignoreInternal: Boolean(context.settings.jsdoc?.ignoreInternal), - maxLines: Number(context.settings.jsdoc?.maxLines ?? 1), - minLines: Number(context.settings.jsdoc?.minLines ?? 0), - - // `check-tag-names` and many returns/param rules - tagNamePreference: context.settings.jsdoc?.tagNamePreference ?? {}, - - // `check-types` and `no-undefined-types` - preferredTypes: context.settings.jsdoc?.preferredTypes ?? {}, - - // `check-types`, `no-undefined-types`, `valid-types` - structuredTags: context.settings.jsdoc?.structuredTags ?? {}, - - // `require-param`, `require-description`, `require-example`, - // `require-returns`, `require-throw`, `require-yields` - overrideReplacesDocs: context.settings.jsdoc?.overrideReplacesDocs, - ignoreReplacesDocs: context.settings.jsdoc?.ignoreReplacesDocs, - implementsReplacesDocs: context.settings.jsdoc?.implementsReplacesDocs, - augmentsExtendsReplacesDocs: context.settings.jsdoc?.augmentsExtendsReplacesDocs, - - // `require-param-type`, `require-param-description` - exemptDestructuredRootsFromChecks: context.settings.jsdoc?.exemptDestructuredRootsFromChecks, - - // Many rules, e.g., `check-tag-names` - mode: context.settings.jsdoc?.mode ?? 'typescript', - - // Many rules - contexts: context.settings.jsdoc?.contexts, - }; - /* dslint-enable canonical/sort-keys */ - - jsdocUtils.setTagStructure(settings.mode); - try { - jsdocUtils.overrideTagStructure(settings.structuredTags); - } catch (error) { - context.report({ - loc: { - end: { - column: 1, - line: 1, - }, - start: { - column: 1, - line: 1, - }, - }, - message: /** @type {Error} */ (error).message, - }); - - return false; - } - - return settings; -}; - -/** - * Create the report function - * @callback MakeReport - * @param {import('eslint').Rule.RuleContext} context - * @param {import('estree').Node} commentNode - * @returns {Report} - */ - -/** @type {MakeReport} */ -const makeReport = (context, commentNode) => { - /** @type {Report} */ - const report = (message, fix = null, jsdocLoc = null, data = undefined) => { - let loc; - - if (jsdocLoc) { - if (!('line' in jsdocLoc)) { - jsdocLoc.line = /** @type {import('comment-parser').Spec & {line?: Integer}} */ ( - jsdocLoc - ).source[0].number; - } - - const lineNumber = /** @type {import('eslint').AST.SourceLocation} */ ( - commentNode.loc - ).start.line + - /** @type {Integer} */ (jsdocLoc.line); - - loc = { - end: { - column: 0, - line: lineNumber, - }, - start: { - column: 0, - line: lineNumber, - }, - }; - - // Todo: Remove ignore once `check-examples` can be restored for ESLint 8+ - if ('column' in jsdocLoc && typeof jsdocLoc.column === 'number') { - const colNumber = /** @type {import('eslint').AST.SourceLocation} */ ( - commentNode.loc - ).start.column + jsdocLoc.column; - - loc.end.column = colNumber; - loc.start.column = colNumber; - } - } - - context.report({ - data, - fix, - loc, - message, - node: commentNode, - }); - }; - - return report; -}; - -/** - * @typedef {( - * arg: { - * context: import('eslint').Rule.RuleContext, - * sourceCode: import('eslint').SourceCode, - * indent?: string, - * info?: { - * comment?: string|undefined, - * lastIndex?: Integer|undefined - * }, - * state?: StateObject, - * globalState?: Map>, - * jsdoc?: JsdocBlockWithInline, - * jsdocNode?: import('eslint').Rule.Node & { - * range: [number, number] - * }, - * node?: Node, - * allComments?: import('estree').Node[] - * report?: Report, - * makeReport?: MakeReport, - * settings: Settings, - * utils: BasicUtils, - * } - * ) => any } JsdocVisitorBasic - */ -/** - * @typedef {( - * arg: { - * context: import('eslint').Rule.RuleContext, - * sourceCode: import('eslint').SourceCode, - * indent: string, - * info: { - * comment?: string|undefined, - * lastIndex?: Integer|undefined - * }, - * state: StateObject, - * globalState: Map>, - * jsdoc: JsdocBlockWithInline, - * jsdocNode: import('eslint').Rule.Node & { - * range: [number, number] - * }, - * node: Node|null, - * allComments?: import('estree').Node[] - * report: Report, - * makeReport?: MakeReport, - * settings: Settings, - * utils: Utils, - * } - * ) => any } JsdocVisitor - */ - -/** - * @param {{ - * comment?: string, - * lastIndex?: Integer, - * selector?: string, - * isFunctionContext?: boolean, - * }} info - * @param {string} indent - * @param {JsdocBlockWithInline} jsdoc - * @param {RuleConfig} ruleConfig - * @param {import('eslint').Rule.RuleContext} context - * @param {import('@es-joy/jsdoccomment').Token} jsdocNode - * @param {Node|null} node - * @param {Settings} settings - * @param {import('eslint').SourceCode} sourceCode - * @param {JsdocVisitor} iterator - * @param {StateObject} state - * @param {boolean} [iteratingAll] - * @returns {void} - */ -const iterate = ( - info, - indent, jsdoc, - ruleConfig, context, jsdocNode, node, settings, - sourceCode, iterator, state, iteratingAll, -) => { - const jsdocNde = /** @type {unknown} */ (jsdocNode); - const report = makeReport( - context, - /** @type {import('estree').Node} */ - (jsdocNde), - ); - - const utils = getUtils( - node, - jsdoc, - /** @type {import('eslint').AST.Token} */ - (jsdocNode), - settings, - report, - context, - sourceCode, - iteratingAll, - ruleConfig, - indent, - ); - - if ( - !ruleConfig.checkInternal && settings.ignoreInternal && - utils.hasTag('internal') - ) { - return; - } - - if ( - !ruleConfig.checkPrivate && settings.ignorePrivate && - ( - utils.hasTag('private') || - jsdoc.tags - .filter(({ - tag, - }) => { - return tag === 'access'; - }) - .some(({ - description, - }) => { - return description === 'private'; - }) - ) - ) { - return; - } - - iterator({ - context, - globalState, - indent, - info, - jsdoc, - jsdocNode: /** - * @type {import('eslint').Rule.Node & { - * range: [number, number];}} - */ (jsdocNde), - node, - report, - settings, - sourceCode, - state, - utils, - }); -}; - -/** - * @param {string[]} lines - * @param {import('estree').Comment} jsdocNode - * @returns {[indent: string, jsdoc: JsdocBlockWithInline]} - */ -const getIndentAndJSDoc = function (lines, jsdocNode) { - const sourceLine = lines[ - /** @type {import('estree').SourceLocation} */ - (jsdocNode.loc).start.line - 1 - ]; - const indnt = sourceLine.charAt(0).repeat( - /** @type {import('estree').SourceLocation} */ - (jsdocNode.loc).start.column, - ); - - const jsdc = parseComment(jsdocNode, ''); - - return [ - indnt, jsdc, - ]; -}; - -/** - * - * @typedef {{node: Node & { - * range: [number, number] - * }, state: StateObject}} NonCommentArgs - */ - -/** - * @typedef {object} RuleConfig - * @property {EslintRuleMeta} meta ESLint rule meta - * @property {import('./jsdocUtils.js').DefaultContexts} [contextDefaults] Any default contexts - * @property {true} [contextSelected] Whether to force a `contexts` check - * @property {true} [iterateAllJsdocs] Whether to iterate all JSDoc blocks by default - * regardless of context - * @property {true} [checkPrivate] Whether to check `@private` blocks (normally exempted) - * @property {true} [checkInternal] Whether to check `@internal` blocks (normally exempted) - * @property {true} [checkFile] Whether to iterates over all JSDoc blocks regardless of attachment - * @property {true} [nonGlobalSettings] Whether to avoid relying on settings for global contexts - * @property {true} [noTracking] Whether to disable the tracking of visited comment nodes (as - * non-tracked may conduct further actions) - * @property {true} [matchContext] Whether the rule expects contexts to be based on a match option - * @property {(args: { - * context: import('eslint').Rule.RuleContext, - * state: StateObject, - * settings: Settings, - * utils: BasicUtils - * }) => void} [exit] Handler to be executed upon exiting iteration of program AST - * @property {(nca: NonCommentArgs) => void} [nonComment] Handler to be executed if rule wishes - * to be supplied nodes without comments - */ - -/** - * Create an eslint rule that iterates over all JSDocs, regardless of whether - * they are attached to a function-like node. - * @param {JsdocVisitor} iterator - * @param {RuleConfig} ruleConfig The rule's configuration - * @param {ContextObject[]|null} [contexts] The `contexts` containing relevant `comment` info. - * @param {boolean} [additiveCommentContexts] If true, will have a separate - * iteration for each matching comment context. Otherwise, will iterate - * once if there is a single matching comment context. - * @returns {import('eslint').Rule.RuleModule} - */ -const iterateAllJsdocs = (iterator, ruleConfig, contexts, additiveCommentContexts) => { - const trackedJsdocs = new Set(); - - /** @type {import('@es-joy/jsdoccomment').CommentHandler} */ - let handler; - - /** @type {Settings|false} */ - let settings; - - /** - * @param {import('eslint').Rule.RuleContext} context - * @param {Node|null} node - * @param {import('estree').Comment[]} jsdocNodes - * @param {StateObject} state - * @param {boolean} [lastCall] - * @returns {void} - */ - const callIterator = (context, node, jsdocNodes, state, lastCall) => { - /* c8 ignore next -- Fallback to deprecated method */ - const { - sourceCode = context.getSourceCode(), - } = context; - const { - lines, - } = sourceCode; - - const utils = getBasicUtils(context, /** @type {Settings} */ (settings)); - for (const jsdocNode of jsdocNodes) { - const jsdocNde = /** @type {unknown} */ (jsdocNode); - if (!(/^\/\*\*\s/u).test(sourceCode.getText( - /** @type {import('estree').Node} */ - (jsdocNde), - ))) { - continue; - } - - const [ - indent, - jsdoc, - ] = getIndentAndJSDoc( - lines, jsdocNode, - ); - - if (additiveCommentContexts) { - for (const [ - idx, - { - comment, - }, - ] of /** @type {ContextObject[]} */ (contexts).entries()) { - if (comment && handler(comment, jsdoc) === false) { - continue; - } - - iterate( - { - comment, - lastIndex: idx, - selector: node?.type, - }, - indent, - jsdoc, - ruleConfig, - context, - jsdocNode, - /** @type {Node} */ - (node), - /** @type {Settings} */ - (settings), - sourceCode, - iterator, - state, - true, - ); - } - - continue; - } - - let lastComment; - let lastIndex; - // eslint-disable-next-line no-loop-func - if (contexts && contexts.every(({ - comment, - }, idx) => { - lastComment = comment; - lastIndex = idx; - - return comment && handler(comment, jsdoc) === false; - })) { - continue; - } - - iterate( - lastComment ? { - comment: lastComment, - lastIndex, - selector: node?.type, - } : { - lastIndex, - selector: node?.type, - }, - indent, - jsdoc, - ruleConfig, - context, - jsdocNode, - node, - /** @type {Settings} */ - (settings), - sourceCode, - iterator, - state, - true, - ); - } - - const settngs = /** @type {Settings} */ (settings); - - if (lastCall && ruleConfig.exit) { - ruleConfig.exit({ - context, - settings: settngs, - state, - utils, - }); - } - }; - - return { - // @ts-expect-error ESLint accepts - create (context) { - /* c8 ignore next -- Fallback to deprecated method */ - const { - sourceCode = context.getSourceCode(), - } = context; - settings = getSettings(context); - if (!settings) { - return {}; - } - - if (contexts) { - handler = commentHandler(settings); - } - - const state = {}; - - return { - /** - * @param {import('eslint').Rule.Node & { - * range: [Integer, Integer]; - * }} node - * @returns {void} - */ - '*:not(Program)' (node) { - const commentNode = getJSDocComment( - sourceCode, node, /** @type {Settings} */ (settings), - ); - if (!ruleConfig.noTracking && trackedJsdocs.has(commentNode)) { - return; - } - - if (!commentNode) { - if (ruleConfig.nonComment) { - const ste = /** @type {StateObject} */ (state); - ruleConfig.nonComment({ - node, - state: ste, - }); - } - - return; - } - - trackedJsdocs.add(commentNode); - callIterator(context, node, [ - /** @type {import('estree').Comment} */ - (commentNode), - ], /** @type {StateObject} */ (state)); - }, - 'Program:exit' () { - const allComments = sourceCode.getAllComments(); - const untrackedJSdoc = allComments.filter((node) => { - return !trackedJsdocs.has(node); - }); - - callIterator( - context, - null, - untrackedJSdoc, - /** @type {StateObject} */ - (state), - true, - ); - }, - }; - }, - meta: ruleConfig.meta, - }; -}; - -/** - * Create an eslint rule that iterates over all JSDocs, regardless of whether - * they are attached to a function-like node. - * @param {JsdocVisitorBasic} iterator - * @param {RuleConfig} ruleConfig - * @returns {import('eslint').Rule.RuleModule} - */ -const checkFile = (iterator, ruleConfig) => { - return { - create (context) { - /* c8 ignore next -- Fallback to deprecated method */ - const { - sourceCode = context.getSourceCode(), - } = context; - const settings = getSettings(context); - if (!settings) { - return {}; - } - - return { - 'Program:exit' () { - const allComms = /** @type {unknown} */ (sourceCode.getAllComments()); - const utils = getBasicUtils(context, settings); - - iterator({ - allComments: /** @type {import('estree').Node[]} */ (allComms), - context, - makeReport, - settings, - sourceCode, - utils, - }); - }, - }; - }, - meta: ruleConfig.meta, - }; -}; - -export { - getSettings, - // dslint-disable-next-line unicorn/prefer-export-from -- Avoid experimental parser - parseComment, -}; - -/** - * @param {JsdocVisitor} iterator - * @param {RuleConfig} ruleConfig - * @returns {import('eslint').Rule.RuleModule} - */ -export default function iterateJsdoc (iterator, ruleConfig) { - const metaType = ruleConfig?.meta?.type; - if (!metaType || ![ - 'problem', 'suggestion', 'layout', - ].includes(metaType)) { - throw new TypeError('Rule must include `meta.type` option (with value "problem", "suggestion", or "layout")'); - } - - if (typeof iterator !== 'function') { - throw new TypeError('The iterator argument must be a function.'); - } - - if (ruleConfig.checkFile) { - return checkFile( - /** @type {JsdocVisitorBasic} */ (iterator), - ruleConfig, - ); - } - - if (ruleConfig.iterateAllJsdocs) { - return iterateAllJsdocs(iterator, ruleConfig); - } - - /** @type {import('eslint').Rule.RuleModule} */ - return { - /** - * The entrypoint for the JSDoc rule. - * @param {import('eslint').Rule.RuleContext} context - * a reference to the context which hold all important information - * like settings and the sourcecode to check. - * @returns {import('eslint').Rule.RuleListener} - * a listener with parser callback function. - */ - create (context) { - const settings = getSettings(context); - if (!settings) { - return {}; - } - - /** - * @type {Context[]|undefined} - */ - let contexts; - if (ruleConfig.contextDefaults || ruleConfig.contextSelected || ruleConfig.matchContext) { - contexts = ruleConfig.matchContext && context.options[0]?.match ? - context.options[0].match : - jsdocUtils.enforcedContexts(context, ruleConfig.contextDefaults, ruleConfig.nonGlobalSettings ? {} : settings); - - if (contexts) { - contexts = contexts.map((obj) => { - if (typeof obj === 'object' && !obj.context) { - return { - ...obj, - context: 'any', - }; - } - - return obj; - }); - } - - const hasPlainAny = contexts?.includes('any'); - const hasObjectAny = !hasPlainAny && contexts?.find((ctxt) => { - if (typeof ctxt === 'string') { - return false; - } - - return ctxt?.context === 'any'; - }); - if (hasPlainAny || hasObjectAny) { - return iterateAllJsdocs( - iterator, - ruleConfig, - hasObjectAny ? /** @type {ContextObject[]} */ (contexts) : null, - ruleConfig.matchContext, - ).create(context); - } - } - - /* c8 ignore next -- Fallback to deprecated method */ - const { - sourceCode = context.getSourceCode(), - } = context; - const { - lines, - } = sourceCode; - - /** @type {Partial} */ - const state = {}; - - /** @type {CheckJsdoc} */ - const checkJsdoc = (info, handler, node) => { - const jsdocNode = getJSDocComment(sourceCode, node, settings); - if (!jsdocNode) { - return; - } - - const [ - indent, - jsdoc, - ] = getIndentAndJSDoc( - lines, - /** @type {import('estree').Comment} */ - (jsdocNode), - ); - - if ( - // Note, `handler` should already be bound in its first argument - // with these only to be called after the value of - // `comment` - handler && handler(jsdoc) === false - ) { - return; - } - - iterate( - info, - indent, - jsdoc, - ruleConfig, - context, - jsdocNode, - node, - settings, - sourceCode, - iterator, - /** @type {StateObject} */ - (state), - ); - }; - - /** @type {import('eslint').Rule.RuleListener} */ - let contextObject = {}; - - if (contexts && ( - ruleConfig.contextDefaults || ruleConfig.contextSelected || ruleConfig.matchContext - )) { - contextObject = jsdocUtils.getContextObject( - contexts, - checkJsdoc, - commentHandler(settings), - ); - } else { - for (const prop of [ - 'ArrowFunctionExpression', - 'FunctionDeclaration', - 'FunctionExpression', - 'TSDeclareFunction', - ]) { - contextObject[prop] = checkJsdoc.bind(null, { - selector: prop, - }, null); - } - } - - if (typeof ruleConfig.exit === 'function') { - contextObject['Program:exit'] = () => { - const ste = /** @type {StateObject} */ (state); - - // @ts-expect-error `utils` not needed at this point - /** @type {Required} */ (ruleConfig).exit({ - context, - settings, - state: ste, - }); - }; - } - - return contextObject; - }, - meta: ruleConfig.meta, - }; -} diff --git a/tools/eslint/node_modules/eslint-plugin-jsdoc/src/jsdocUtils.js b/tools/eslint/node_modules/eslint-plugin-jsdoc/src/jsdocUtils.js deleted file mode 100644 index 96ef6ac925f98e..00000000000000 --- a/tools/eslint/node_modules/eslint-plugin-jsdoc/src/jsdocUtils.js +++ /dev/null @@ -1,1696 +0,0 @@ -import getDefaultTagStructureForMode from './getDefaultTagStructureForMode.js'; -import { - closureTags, - jsdocTags, - typeScriptTags, -} from './tagNames.js'; -import { - hasReturnValue, - hasValueOrExecutorHasNonEmptyResolveValue, -} from './utils/hasReturnValue.js'; -import WarnSettings from './WarnSettings.js'; -import { - tryParse, -} from '@es-joy/jsdoccomment'; - -/** - * @typedef {number} Integer - */ -/** - * @typedef {import('./utils/hasReturnValue.js').ESTreeOrTypeScriptNode} ESTreeOrTypeScriptNode - */ - -/** - * @typedef {"jsdoc"|"typescript"|"closure"|"permissive"} ParserMode - */ - -/** - * @type {import('./getDefaultTagStructureForMode.js').TagStructure} - */ -let tagStructure; - -/** - * @param {ParserMode} mode - * @returns {void} - */ -const setTagStructure = (mode) => { - tagStructure = getDefaultTagStructureForMode(mode); -}; - -/** - * @typedef {undefined|string|{ - * name: Integer, - * restElement: boolean - * }|{ - * isRestProperty: boolean|undefined, - * name: string, - * restElement: boolean - * }|{ - * name: string, - * restElement: boolean - * }} ParamCommon - */ -/** - * @typedef {ParamCommon|[string|undefined, (FlattendRootInfo & { - * annotationParamName?: string, - * })]|NestedParamInfo} ParamNameInfo - */ - -/** - * @typedef {{ - * hasPropertyRest: boolean, - * hasRestElement: boolean, - * names: string[], - * rests: boolean[], - * }} FlattendRootInfo - */ -/** - * @typedef {[string, (string[]|ParamInfo[])]} NestedParamInfo - */ -/** - * @typedef {ParamCommon| - * [string|undefined, (FlattendRootInfo & { - * annotationParamName?: string - * })]| - * NestedParamInfo} ParamInfo - */ - -/** - * Given a nested array of property names, reduce them to a single array, - * appending the name of the root element along the way if present. - * @callback FlattenRoots - * @param {ParamInfo[]} params - * @param {string} [root] - * @returns {FlattendRootInfo} - */ - -/** @type {FlattenRoots} */ -const flattenRoots = (params, root = '') => { - let hasRestElement = false; - let hasPropertyRest = false; - - /** - * @type {boolean[]} - */ - const rests = []; - - const names = params.reduce( - /** - * @param {string[]} acc - * @param {ParamInfo} cur - * @returns {string[]} - */ - (acc, cur) => { - if (Array.isArray(cur)) { - let nms; - if (Array.isArray(cur[1])) { - nms = cur[1]; - } else { - if (cur[1].hasRestElement) { - hasRestElement = true; - } - - if (cur[1].hasPropertyRest) { - hasPropertyRest = true; - } - - nms = cur[1].names; - } - - const flattened = flattenRoots(nms, root ? `${root}.${cur[0]}` : cur[0]); - if (flattened.hasRestElement) { - hasRestElement = true; - } - - if (flattened.hasPropertyRest) { - hasPropertyRest = true; - } - - const inner = /** @type {string[]} */ ([ - root ? `${root}.${cur[0]}` : cur[0], - ...flattened.names, - ].filter(Boolean)); - rests.push(false, ...flattened.rests); - - return acc.concat(inner); - } - - if (typeof cur === 'object') { - if ('isRestProperty' in cur && cur.isRestProperty) { - hasPropertyRest = true; - rests.push(true); - } else { - rests.push(false); - } - - if ('restElement' in cur && cur.restElement) { - hasRestElement = true; - } - - acc.push(root ? `${root}.${String(cur.name)}` : String(cur.name)); - } else if (typeof cur !== 'undefined') { - rests.push(false); - acc.push(root ? `${root}.${cur}` : cur); - } - - return acc; - }, [], - ); - - return { - hasPropertyRest, - hasRestElement, - names, - rests, - }; -}; - -/** - * @param {import('@typescript-eslint/types').TSESTree.TSIndexSignature| - * import('@typescript-eslint/types').TSESTree.TSConstructSignatureDeclaration| - * import('@typescript-eslint/types').TSESTree.TSCallSignatureDeclaration| - * import('@typescript-eslint/types').TSESTree.TSPropertySignature} propSignature - * @returns {undefined|string|[string, string[]]} - */ -const getPropertiesFromPropertySignature = (propSignature) => { - if ( - propSignature.type === 'TSIndexSignature' || - propSignature.type === 'TSConstructSignatureDeclaration' || - propSignature.type === 'TSCallSignatureDeclaration' - ) { - return undefined; - } - - if (propSignature.typeAnnotation && propSignature.typeAnnotation.typeAnnotation.type === 'TSTypeLiteral') { - return [ - /** @type {import('@typescript-eslint/types').TSESTree.Identifier} */ ( - propSignature.key - ).name, - propSignature.typeAnnotation.typeAnnotation.members.map((member) => { - return /** @type {string} */ ( - getPropertiesFromPropertySignature( - /** @type {import('@typescript-eslint/types').TSESTree.TSPropertySignature} */ ( - member - ), - ) - ); - }), - ]; - } - - return /** @type {import('@typescript-eslint/types').TSESTree.Identifier} */ ( - propSignature.key - ).name; -}; - -/** - * @param {ESTreeOrTypeScriptNode|null} functionNode - * @param {boolean} [checkDefaultObjects] - * @throws {Error} - * @returns {ParamNameInfo[]} - */ -const getFunctionParameterNames = ( - functionNode, checkDefaultObjects, -) => { - /* eslint-disable complexity -- Temporary */ - /** - * @param {import('estree').Identifier|import('estree').AssignmentPattern| - * import('estree').ObjectPattern|import('estree').Property| - * import('estree').RestElement|import('estree').ArrayPattern| - * import('@typescript-eslint/types').TSESTree.TSParameterProperty| - * import('@typescript-eslint/types').TSESTree.Property| - * import('@typescript-eslint/types').TSESTree.RestElement| - * import('@typescript-eslint/types').TSESTree.Identifier| - * import('@typescript-eslint/types').TSESTree.ObjectPattern| - * import('@typescript-eslint/types').TSESTree.BindingName| - * import('@typescript-eslint/types').TSESTree.Parameter - * } param - * @param {boolean} [isProperty] - * @returns {ParamNameInfo|[string, ParamNameInfo[]]} - */ - const getParamName = (param, isProperty) => { - /* eslint-enable complexity -- Temporary */ - const hasLeftTypeAnnotation = 'left' in param && 'typeAnnotation' in param.left; - - if ('typeAnnotation' in param || hasLeftTypeAnnotation) { - const typeAnnotation = hasLeftTypeAnnotation ? - /** @type {import('@typescript-eslint/types').TSESTree.Identifier} */ ( - param.left - ).typeAnnotation : - /** @type {import('@typescript-eslint/types').TSESTree.Identifier|import('@typescript-eslint/types').TSESTree.ObjectPattern} */ - (param).typeAnnotation; - - if (typeAnnotation?.typeAnnotation?.type === 'TSTypeLiteral') { - const propertyNames = typeAnnotation.typeAnnotation.members.map((member) => { - return getPropertiesFromPropertySignature( - /** @type {import('@typescript-eslint/types').TSESTree.TSPropertySignature} */ - (member), - ); - }); - - const flattened = { - ...flattenRoots(propertyNames), - annotationParamName: 'name' in param ? param.name : undefined, - }; - const hasLeftName = 'left' in param && 'name' in param.left; - - if ('name' in param || hasLeftName) { - return [ - hasLeftName ? - /** @type {import('@typescript-eslint/types').TSESTree.Identifier} */ ( - param.left - ).name : - /** @type {import('@typescript-eslint/types').TSESTree.Identifier} */ ( - param - ).name, - flattened, - ]; - } - - return [ - undefined, flattened, - ]; - } - } - - if ('name' in param) { - return param.name; - } - - if ('left' in param && 'name' in param.left) { - return param.left.name; - } - - if ( - param.type === 'ObjectPattern' || - ('left' in param && - ( - param - ).left.type === 'ObjectPattern') - ) { - const properties = /** @type {import('@typescript-eslint/types').TSESTree.ObjectPattern} */ ( - param - ).properties || - /** @type {import('estree').ObjectPattern} */ - ( - /** @type {import('@typescript-eslint/types').TSESTree.AssignmentPattern} */ ( - param - ).left - )?.properties; - const roots = properties.map((prop) => { - return getParamName(prop, true); - }); - - return [ - undefined, flattenRoots(roots), - ]; - } - - if (param.type === 'Property') { - switch (param.value.type) { - case 'ArrayPattern': { - return [ - /** @type {import('estree').Identifier} */ - (param.key).name, - /** @type {import('estree').ArrayPattern} */ ( - param.value - ).elements.map((prop, idx) => { - return { - name: idx, - restElement: prop?.type === 'RestElement', - }; - }), - ]; - } - - case 'ObjectPattern': { - return [ - /** @type {import('estree').Identifier} */ (param.key).name, - /** @type {import('estree').ObjectPattern} */ ( - param.value - ).properties.map((prop) => { - return /** @type {string|[string, string[]]} */ (getParamName(prop, isProperty)); - }), - ]; - } - - case 'AssignmentPattern': { - switch (param.value.left.type) { - case 'Identifier': - // Default parameter - if (checkDefaultObjects && param.value.right.type === 'ObjectExpression') { - return [ - /** @type {import('estree').Identifier} */ ( - param.key - ).name, - /** @type {import('estree').AssignmentPattern} */ ( - param.value - ).right.properties.map((prop) => { - return /** @type {string} */ (getParamName( - /** @type {import('estree').Property} */ - (prop), - isProperty, - )); - }), - ]; - } - - break; - case 'ObjectPattern': - return [ - /** @type {import('estree').Identifier} */ - (param.key).name, - /** @type {import('estree').ObjectPattern} */ ( - param.value.left - ).properties.map((prop) => { - return getParamName(prop, isProperty); - }), - ]; - case 'ArrayPattern': - return [ - /** @type {import('estree').Identifier} */ - (param.key).name, - /** @type {import('estree').ArrayPattern} */ ( - param.value.left - ).elements.map((prop, idx) => { - return { - name: idx, - restElement: prop?.type === 'RestElement', - }; - }), - ]; - } - } - } - - switch (param.key.type) { - case 'Identifier': - return param.key.name; - - // The key of an object could also be a string or number - case 'Literal': - /* c8 ignore next 2 -- `raw` may not be present in all parsers */ - return /** @type {string} */ (param.key.raw || - param.key.value); - - // case 'MemberExpression': - default: - // Todo: We should really create a structure (and a corresponding - // option analogous to `checkRestProperty`) which allows for - // (and optionally requires) dynamic properties to have a single - // line of documentation - return undefined; - } - } - - if ( - param.type === 'ArrayPattern' || - /** @type {import('estree').AssignmentPattern} */ ( - param - ).left?.type === 'ArrayPattern' - ) { - const elements = /** @type {import('estree').ArrayPattern} */ ( - param - ).elements || /** @type {import('estree').ArrayPattern} */ ( - /** @type {import('estree').AssignmentPattern} */ ( - param - ).left - )?.elements; - const roots = elements.map((prop, idx) => { - return { - name: `"${idx}"`, - restElement: prop?.type === 'RestElement', - }; - }); - - return [ - undefined, flattenRoots(roots), - ]; - } - - if ([ - 'RestElement', 'ExperimentalRestProperty', - ].includes(param.type)) { - return { - isRestProperty: isProperty, - name: /** @type {import('@typescript-eslint/types').TSESTree.Identifier} */ ( - /** @type {import('@typescript-eslint/types').TSESTree.RestElement} */ ( - param - // @ts-expect-error Ok - ).argument).name ?? param?.argument?.elements?.map(({name}) => { - return name; - }), - restElement: true, - }; - } - - if (param.type === 'TSParameterProperty') { - return getParamName( - /** @type {import('@typescript-eslint/types').TSESTree.Identifier} */ ( - /** @type {import('@typescript-eslint/types').TSESTree.TSParameterProperty} */ ( - param - ).parameter - ), - true, - ); - } - - throw new Error(`Unsupported function signature format: \`${param.type}\`.`); - }; - - if (!functionNode) { - return []; - } - - return (/** @type {import('@typescript-eslint/types').TSESTree.FunctionDeclaration} */ ( - functionNode - ).params || /** @type {import('@typescript-eslint/types').TSESTree.MethodDefinition} */ ( - functionNode - ).value?.params || []).map((param) => { - return getParamName(param); - }); -}; - -/** - * @param {ESTreeOrTypeScriptNode} functionNode - * @returns {Integer} - */ -const hasParams = (functionNode) => { - // Should also check `functionNode.value.params` if supporting `MethodDefinition` - return /** @type {import('@typescript-eslint/types').TSESTree.FunctionDeclaration} */ ( - functionNode - ).params.length; -}; - -/** - * Gets all names of the target type, including those that refer to a path, e.g. - * `foo` or `foo.bar`. - * @param {import('comment-parser').Block} jsdoc - * @param {string} targetTagName - * @returns {{ - * idx: Integer, - * name: string, - * type: string - * }[]} - */ -const getJsdocTagsDeep = (jsdoc, targetTagName) => { - const ret = []; - for (const [ - idx, - { - name, - tag, - type, - }, - ] of jsdoc.tags.entries()) { - if (tag !== targetTagName) { - continue; - } - - ret.push({ - idx, - name, - type, - }); - } - - return ret; -}; - -const modeWarnSettings = WarnSettings(); - -/** - * @param {ParserMode|undefined} mode - * @param {import('eslint').Rule.RuleContext} context - * @returns {import('./tagNames.js').AliasedTags} - */ -const getTagNamesForMode = (mode, context) => { - switch (mode) { - case 'jsdoc': - return jsdocTags; - case 'typescript': - return typeScriptTags; - case 'closure': case 'permissive': - return closureTags; - default: - if (!modeWarnSettings.hasBeenWarned(context, 'mode')) { - context.report({ - loc: { - end: { - column: 1, - line: 1, - }, - start: { - column: 1, - line: 1, - }, - }, - message: `Unrecognized value \`${mode}\` for \`settings.jsdoc.mode\`.`, - }); - modeWarnSettings.markSettingAsWarned(context, 'mode'); - } - - // We'll avoid breaking too many other rules - return jsdocTags; - } -}; - -/** - * @param {import('eslint').Rule.RuleContext} context - * @param {ParserMode|undefined} mode - * @param {string} name - * @param {TagNamePreference} tagPreference - * @returns {string|false|{ - * message: string; - * replacement?: string|undefined; - * }} - */ -const getPreferredTagName = ( - context, - mode, - name, - tagPreference = {}, -) => { - const prefValues = Object.values(tagPreference); - if (prefValues.includes(name) || prefValues.some((prefVal) => { - return prefVal && typeof prefVal === 'object' && prefVal.replacement === name; - })) { - return name; - } - - // Allow keys to have a 'tag ' prefix to avoid upstream bug in ESLint - // that disallows keys that conflict with Object.prototype, - // e.g. 'tag constructor' for 'constructor': - // https://github.com/eslint/eslint/issues/13289 - // https://github.com/gajus/eslint-plugin-jsdoc/issues/537 - const tagPreferenceFixed = Object.fromEntries( - Object - .entries(tagPreference) - .map(([ - key, - value, - ]) => { - return [ - key.replace(/^tag /u, ''), value, - ]; - }), - ); - - if (Object.prototype.hasOwnProperty.call(tagPreferenceFixed, name)) { - return tagPreferenceFixed[name]; - } - - const tagNames = getTagNamesForMode(mode, context); - - const preferredTagName = Object.entries(tagNames).find(([ - , aliases, - ]) => { - return aliases.includes(name); - })?.[0]; - if (preferredTagName) { - return preferredTagName; - } - - return name; -}; - -/** - * @param {import('eslint').Rule.RuleContext} context - * @param {ParserMode|undefined} mode - * @param {string} name - * @param {string[]} definedTags - * @returns {boolean} - */ -const isValidTag = ( - context, - mode, - name, - definedTags, -) => { - const tagNames = getTagNamesForMode(mode, context); - - const validTagNames = Object.keys(tagNames).concat(Object.values(tagNames).flat()); - const additionalTags = definedTags; - const allTags = validTagNames.concat(additionalTags); - - return allTags.includes(name); -}; - -/** - * @param {import('./iterateJsdoc.js').JsdocBlockWithInline} jsdoc - * @param {string} targetTagName - * @returns {boolean} - */ -const hasTag = (jsdoc, targetTagName) => { - const targetTagLower = targetTagName.toLowerCase(); - - return jsdoc.tags.some((doc) => { - return doc.tag.toLowerCase() === targetTagLower; - }); -}; - -/** - * Get all tags, inline tags and inline tags in tags - * @param {import('./iterateJsdoc.js').JsdocBlockWithInline} jsdoc - * @returns {(import('comment-parser').Spec| - * import('@es-joy/jsdoccomment').JsdocInlineTagNoType)[]} - */ -const getAllTags = (jsdoc) => { - return [ - ...jsdoc.tags, - ...jsdoc.inlineTags.map((inlineTag) => { - // Tags don't have source or line numbers, so add before returning - let line = -1; - for (const { - tokens: { - description, - }, - } of jsdoc.source) { - line++; - if (description && description.includes(`{@${inlineTag.tag}`)) { - break; - } - } - - inlineTag.line = line; - - return inlineTag; - }), - ...jsdoc.tags.flatMap((tag) => { - let tagBegins = -1; - for (const { - tokens: { - tag: tg, - }, - } of jsdoc.source) { - tagBegins++; - if (tg) { - break; - } - } - - for (const inlineTag of tag.inlineTags) { - /** @type {import('./iterateJsdoc.js').Integer} */ - let line = 0; - for (const { - number, - tokens: { - description, - }, - } of tag.source) { - if (description && description.includes(`{@${inlineTag.tag}`)) { - line = number; - break; - } - } - - inlineTag.line = tagBegins + line - 1; - } - - return ( - /** - * @type {import('comment-parser').Spec & { - * inlineTags: import('@es-joy/jsdoccomment').JsdocInlineTagNoType[] - * }} - */ ( - tag - ).inlineTags - ); - }), - ]; -}; - -/** - * @param {import('./iterateJsdoc.js').JsdocBlockWithInline} jsdoc - * @param {string[]} targetTagNames - * @returns {boolean} - */ -const hasATag = (jsdoc, targetTagNames) => { - return targetTagNames.some((targetTagName) => { - return hasTag(jsdoc, targetTagName); - }); -}; - -/** - * Checks if the JSDoc comment has an undefined type. - * @param {import('comment-parser').Spec|null|undefined} tag - * the tag which should be checked. - * @param {ParserMode} mode - * @returns {boolean} - * true in case a defined type is undeclared; otherwise false. - */ -const mayBeUndefinedTypeTag = (tag, mode) => { - // The function should not continue in the event the type is not defined... - if (typeof tag === 'undefined' || tag === null) { - return true; - } - - // .. same applies if it declares an `{undefined}` or `{void}` type - const tagType = tag.type.trim(); - - // Exit early if matching - if ( - tagType === 'undefined' || tagType === 'void' || - tagType === '*' || tagType === 'any' - ) { - return true; - } - - let parsedTypes; - try { - parsedTypes = tryParse( - tagType, - mode === 'permissive' ? undefined : [ - mode, - ], - ); - } catch { - // Ignore - } - - if ( - // We do not traverse deeply as it could be, e.g., `Promise` - parsedTypes && - parsedTypes.type === 'JsdocTypeUnion' && - parsedTypes.elements.find((elem) => { - return elem.type === 'JsdocTypeUndefined' || - elem.type === 'JsdocTypeName' && elem.value === 'void'; - })) { - return true; - } - - // In any other case, a type is present - return false; -}; - -/** - * @param {import('./getDefaultTagStructureForMode.js').TagStructure} map - * @param {string} tag - * @returns {Map} - */ -const ensureMap = (map, tag) => { - if (!map.has(tag)) { - map.set(tag, new Map()); - } - - return /** @type {Map} */ (map.get(tag)); -}; - -/** - * @param {import('./iterateJsdoc.js').StructuredTags} structuredTags - * @param {import('./getDefaultTagStructureForMode.js').TagStructure} tagMap - * @returns {void} - */ -const overrideTagStructure = (structuredTags, tagMap = tagStructure) => { - for (const [ - tag, - { - name, - type, - required = [], - }, - ] of Object.entries(structuredTags)) { - const tagStruct = ensureMap(tagMap, tag); - - tagStruct.set('namepathRole', name); - tagStruct.set('typeAllowed', type); - - const requiredName = required.includes('name'); - if (requiredName && name === false) { - throw new Error('Cannot add "name" to `require` with the tag\'s `name` set to `false`'); - } - - tagStruct.set('nameRequired', requiredName); - - const requiredType = required.includes('type'); - if (requiredType && type === false) { - throw new Error('Cannot add "type" to `require` with the tag\'s `type` set to `false`'); - } - - tagStruct.set('typeRequired', requiredType); - - const typeOrNameRequired = required.includes('typeOrNameRequired'); - if (typeOrNameRequired && name === false) { - throw new Error('Cannot add "typeOrNameRequired" to `require` with the tag\'s `name` set to `false`'); - } - - if (typeOrNameRequired && type === false) { - throw new Error('Cannot add "typeOrNameRequired" to `require` with the tag\'s `type` set to `false`'); - } - - tagStruct.set('typeOrNameRequired', typeOrNameRequired); - } -}; - -/** - * @param {ParserMode} mode - * @param {import('./iterateJsdoc.js').StructuredTags} structuredTags - * @returns {import('./getDefaultTagStructureForMode.js').TagStructure} - */ -const getTagStructureForMode = (mode, structuredTags) => { - const tagStruct = getDefaultTagStructureForMode(mode); - - try { - overrideTagStructure(structuredTags, tagStruct); - /* c8 ignore next 3 */ - } catch { - // - } - - return tagStruct; -}; - -/** - * @param {string} tag - * @param {import('./getDefaultTagStructureForMode.js').TagStructure} tagMap - * @returns {boolean} - */ -const isNamepathDefiningTag = (tag, tagMap = tagStructure) => { - const tagStruct = ensureMap(tagMap, tag); - - return tagStruct.get('namepathRole') === 'namepath-defining'; -}; - -/** - * @param {string} tag - * @param {import('./getDefaultTagStructureForMode.js').TagStructure} tagMap - * @returns {boolean} - */ -const isNamepathReferencingTag = (tag, tagMap = tagStructure) => { - const tagStruct = ensureMap(tagMap, tag); - return tagStruct.get('namepathRole') === 'namepath-referencing'; -}; - -/** - * @param {string} tag - * @param {import('./getDefaultTagStructureForMode.js').TagStructure} tagMap - * @returns {boolean} - */ -const isNamepathOrUrlReferencingTag = (tag, tagMap = tagStructure) => { - const tagStruct = ensureMap(tagMap, tag); - return tagStruct.get('namepathRole') === 'namepath-or-url-referencing'; -}; - -/** - * @param {string} tag - * @param {import('./getDefaultTagStructureForMode.js').TagStructure} tagMap - * @returns {boolean|undefined} - */ -const tagMustHaveTypePosition = (tag, tagMap = tagStructure) => { - const tagStruct = ensureMap(tagMap, tag); - - return /** @type {boolean|undefined} */ (tagStruct.get('typeRequired')); -}; - -/** - * @param {string} tag - * @param {import('./getDefaultTagStructureForMode.js').TagStructure} tagMap - * @returns {boolean|string} - */ -const tagMightHaveTypePosition = (tag, tagMap = tagStructure) => { - if (tagMustHaveTypePosition(tag, tagMap)) { - return true; - } - - const tagStruct = ensureMap(tagMap, tag); - - const ret = /** @type {boolean|undefined} */ (tagStruct.get('typeAllowed')); - - return ret === undefined ? true : ret; -}; - -const namepathTypes = new Set([ - 'namepath-defining', 'namepath-referencing', -]); - -/** - * @param {string} tag - * @param {import('./getDefaultTagStructureForMode.js').TagStructure} tagMap - * @returns {boolean} - */ -const tagMightHaveNamePosition = (tag, tagMap = tagStructure) => { - const tagStruct = ensureMap(tagMap, tag); - - const ret = tagStruct.get('namepathRole'); - - return ret === undefined ? true : Boolean(ret); -}; - -/** - * @param {string} tag - * @param {import('./getDefaultTagStructureForMode.js').TagStructure} tagMap - * @returns {boolean} - */ -const tagMightHaveNamepath = (tag, tagMap = tagStructure) => { - const tagStruct = ensureMap(tagMap, tag); - - const nampathRole = tagStruct.get('namepathRole'); - - return nampathRole !== false && - namepathTypes.has(/** @type {string} */ (nampathRole)); -}; - -/** - * @param {string} tag - * @param {import('./getDefaultTagStructureForMode.js').TagStructure} tagMap - * @returns {boolean|undefined} - */ -const tagMustHaveNamePosition = (tag, tagMap = tagStructure) => { - const tagStruct = ensureMap(tagMap, tag); - - return /** @type {boolean|undefined} */ (tagStruct.get('nameRequired')); -}; - -/** - * @param {string} tag - * @param {import('./getDefaultTagStructureForMode.js').TagStructure} tagMap - * @returns {boolean} - */ -const tagMightHaveEitherTypeOrNamePosition = (tag, tagMap) => { - return Boolean(tagMightHaveTypePosition(tag, tagMap)) || tagMightHaveNamepath(tag, tagMap); -}; - -/** - * @param {string} tag - * @param {import('./getDefaultTagStructureForMode.js').TagStructure} tagMap - * @returns {boolean|undefined} - */ -const tagMustHaveEitherTypeOrNamePosition = (tag, tagMap) => { - const tagStruct = ensureMap(tagMap, tag); - - return /** @type {boolean} */ (tagStruct.get('typeOrNameRequired')); -}; - -/** - * @param {import('comment-parser').Spec} tag - * @param {import('./getDefaultTagStructureForMode.js').TagStructure} tagMap - * @returns {boolean|undefined} - */ -const tagMissingRequiredTypeOrNamepath = (tag, tagMap = tagStructure) => { - const mustHaveTypePosition = tagMustHaveTypePosition(tag.tag, tagMap); - const mightHaveTypePosition = tagMightHaveTypePosition(tag.tag, tagMap); - const hasTypePosition = mightHaveTypePosition && Boolean(tag.type); - const hasNameOrNamepathPosition = ( - tagMustHaveNamePosition(tag.tag, tagMap) || - tagMightHaveNamepath(tag.tag, tagMap) - ) && Boolean(tag.name); - const mustHaveEither = tagMustHaveEitherTypeOrNamePosition(tag.tag, tagMap); - const hasEither = tagMightHaveEitherTypeOrNamePosition(tag.tag, tagMap) && - (hasTypePosition || hasNameOrNamepathPosition); - - return mustHaveEither && !hasEither && !mustHaveTypePosition; -}; - -/* eslint-disable complexity -- Temporary */ -/** - * @param {ESTreeOrTypeScriptNode|null|undefined} node - * @param {boolean} [checkYieldReturnValue] - * @returns {boolean} - */ -const hasNonFunctionYield = (node, checkYieldReturnValue) => { - /* eslint-enable complexity -- Temporary */ - if (!node) { - return false; - } - - switch (node.type) { - case 'BlockStatement': { - return node.body.some((bodyNode) => { - return ![ - 'ArrowFunctionExpression', - 'FunctionDeclaration', - 'FunctionExpression', - ].includes(bodyNode.type) && hasNonFunctionYield( - bodyNode, checkYieldReturnValue, - ); - }); - } - - /* c8 ignore next 2 -- In Babel? */ - // @ts-expect-error In Babel? - case 'OptionalCallExpression': - case 'CallExpression': - return node.arguments.some((element) => { - return hasNonFunctionYield(element, checkYieldReturnValue); - }); - case 'ChainExpression': - case 'ExpressionStatement': { - return hasNonFunctionYield(node.expression, checkYieldReturnValue); - } - - case 'LabeledStatement': - case 'WhileStatement': - case 'DoWhileStatement': - case 'ForStatement': - case 'ForInStatement': - case 'ForOfStatement': - case 'WithStatement': { - return hasNonFunctionYield(node.body, checkYieldReturnValue); - } - - case 'ConditionalExpression': - case 'IfStatement': { - return hasNonFunctionYield(node.test, checkYieldReturnValue) || - hasNonFunctionYield(node.consequent, checkYieldReturnValue) || - hasNonFunctionYield(node.alternate, checkYieldReturnValue); - } - - case 'TryStatement': { - return hasNonFunctionYield(node.block, checkYieldReturnValue) || - hasNonFunctionYield( - node.handler && node.handler.body, checkYieldReturnValue, - ) || - hasNonFunctionYield( - /** @type {import('@typescript-eslint/types').TSESTree.BlockStatement} */ - (node.finalizer), - checkYieldReturnValue, - ); - } - - case 'SwitchStatement': { - return node.cases.some( - (someCase) => { - return someCase.consequent.some((nde) => { - return hasNonFunctionYield(nde, checkYieldReturnValue); - }); - }, - ); - } - - case 'ArrayPattern': - case 'ArrayExpression': - return node.elements.some((element) => { - return hasNonFunctionYield(element, checkYieldReturnValue); - }); - case 'AssignmentPattern': - return hasNonFunctionYield(node.right, checkYieldReturnValue); - - case 'VariableDeclaration': { - return node.declarations.some((nde) => { - return hasNonFunctionYield(nde, checkYieldReturnValue); - }); - } - - case 'VariableDeclarator': { - return hasNonFunctionYield(node.id, checkYieldReturnValue) || - hasNonFunctionYield(node.init, checkYieldReturnValue); - } - - case 'AssignmentExpression': - case 'BinaryExpression': - case 'LogicalExpression': { - return hasNonFunctionYield(node.left, checkYieldReturnValue) || - hasNonFunctionYield(node.right, checkYieldReturnValue); - } - - // Comma - case 'SequenceExpression': - case 'TemplateLiteral': - return node.expressions.some((subExpression) => { - return hasNonFunctionYield(subExpression, checkYieldReturnValue); - }); - - case 'ObjectPattern': - case 'ObjectExpression': - return node.properties.some((property) => { - return hasNonFunctionYield(property, checkYieldReturnValue); - }); - - /* c8 ignore next -- In Babel? */ - case 'PropertyDefinition': - /* eslint-disable no-fallthrough */ - /* c8 ignore next 2 -- In Babel? */ - // @ts-expect-error In Babel? - case 'ObjectProperty': - /* c8 ignore next 2 -- In Babel? */ - // @ts-expect-error In Babel? - case 'ClassProperty': - case 'Property': - /* eslint-enable no-fallthrough */ - return node.computed && hasNonFunctionYield(node.key, checkYieldReturnValue) || - hasNonFunctionYield(node.value, checkYieldReturnValue); - /* c8 ignore next 2 -- In Babel? */ - // @ts-expect-error In Babel? - case 'ObjectMethod': - /* c8 ignore next 6 -- In Babel? */ - // @ts-expect-error In Babel? - return node.computed && hasNonFunctionYield(node.key, checkYieldReturnValue) || - // @ts-expect-error In Babel? - node.arguments.some((nde) => { - return hasNonFunctionYield(nde, checkYieldReturnValue); - }); - - case 'SpreadElement': - case 'UnaryExpression': - return hasNonFunctionYield(node.argument, checkYieldReturnValue); - - case 'TaggedTemplateExpression': - return hasNonFunctionYield(node.quasi, checkYieldReturnValue); - - // ?. - /* c8 ignore next 2 -- In Babel? */ - // @ts-expect-error In Babel? - case 'OptionalMemberExpression': - case 'MemberExpression': - return hasNonFunctionYield(node.object, checkYieldReturnValue) || - hasNonFunctionYield(node.property, checkYieldReturnValue); - - /* c8 ignore next 2 -- In Babel? */ - // @ts-expect-error In Babel? - case 'Import': - case 'ImportExpression': - return hasNonFunctionYield(node.source, checkYieldReturnValue); - - case 'ReturnStatement': { - if (node.argument === null) { - return false; - } - - return hasNonFunctionYield(node.argument, checkYieldReturnValue); - } - - case 'YieldExpression': { - if (checkYieldReturnValue) { - if ( - /** @type {import('eslint').Rule.Node} */ ( - node - ).parent.type === 'VariableDeclarator' - ) { - return true; - } - - return false; - } - - // void return does not count. - if (node.argument === null) { - return false; - } - - return true; - } - - default: { - return false; - } - } -}; - -/** - * Checks if a node has a return statement. Void return does not count. - * @param {ESTreeOrTypeScriptNode} node - * @param {boolean} [checkYieldReturnValue] - * @returns {boolean} - */ -const hasYieldValue = (node, checkYieldReturnValue) => { - return /** @type {import('@typescript-eslint/types').TSESTree.FunctionDeclaration} */ ( - node - ).generator && ( - /** @type {import('@typescript-eslint/types').TSESTree.FunctionDeclaration} */ ( - node - ).expression || hasNonFunctionYield( - /** @type {import('@typescript-eslint/types').TSESTree.FunctionDeclaration} */ - (node).body, - checkYieldReturnValue, - ) - ); -}; - -/** - * Checks if a node has a throws statement. - * @param {ESTreeOrTypeScriptNode|null|undefined} node - * @param {boolean} [innerFunction] - * @returns {boolean} - */ -// eslint-disable-next-line complexity -const hasThrowValue = (node, innerFunction) => { - if (!node) { - return false; - } - - // There are cases where a function may execute its inner function which - // throws, but we're treating functions atomically rather than trying to - // follow them - switch (node.type) { - case 'FunctionExpression': - case 'FunctionDeclaration': - case 'ArrowFunctionExpression': { - return !innerFunction && !node.async && hasThrowValue(node.body, true); - } - - case 'BlockStatement': { - return node.body.some((bodyNode) => { - return bodyNode.type !== 'FunctionDeclaration' && hasThrowValue(bodyNode); - }); - } - - case 'LabeledStatement': - case 'WhileStatement': - case 'DoWhileStatement': - case 'ForStatement': - case 'ForInStatement': - case 'ForOfStatement': - case 'WithStatement': { - return hasThrowValue(node.body); - } - - case 'IfStatement': { - return hasThrowValue(node.consequent) || hasThrowValue(node.alternate); - } - - // We only consider it to throw an error if the catch or finally blocks throw an error. - case 'TryStatement': { - return hasThrowValue(node.handler && node.handler.body) || - hasThrowValue(node.finalizer); - } - - case 'SwitchStatement': { - return node.cases.some( - (someCase) => { - return someCase.consequent.some((nde) => { - return hasThrowValue(nde); - }); - }, - ); - } - - case 'ThrowStatement': { - return true; - } - - default: { - return false; - } - } -}; - -/** - * @param {string} tag - */ -/* -const isInlineTag = (tag) => { - return /^(@link|@linkcode|@linkplain|@tutorial) /u.test(tag); -}; -*/ - -/** - * Parses GCC Generic/Template types - * @see {@link https://github.com/google/closure-compiler/wiki/Generic-Types} - * @see {@link https://www.typescriptlang.org/docs/handbook/jsdoc-supported-types.html#template} - * @param {import('comment-parser').Spec} tag - * @returns {string[]} - */ -const parseClosureTemplateTag = (tag) => { - return tag.name - .split(',') - .map((type) => { - return type.trim().replace(/^\[(?.*?)=.*\]$/u, '$'); - }); -}; - -/** - * @typedef {true|string[]} DefaultContexts - */ - -/** - * Checks user option for `contexts` array, defaulting to - * contexts designated by the rule. Returns an array of - * ESTree AST types, indicating allowable contexts. - * @param {import('eslint').Rule.RuleContext} context - * @param {DefaultContexts|undefined} defaultContexts - * @param {{ - * contexts?: import('./iterateJsdoc.js').Context[] - * }} settings - * @returns {(string|import('./iterateJsdoc.js').ContextObject)[]} - */ -const enforcedContexts = (context, defaultContexts, settings) => { - const contexts = context.options[0]?.contexts || settings.contexts || (defaultContexts === true ? [ - 'ArrowFunctionExpression', - 'FunctionDeclaration', - 'FunctionExpression', - 'TSDeclareFunction', - ] : defaultContexts); - - return contexts; -}; - -/** - * @param {import('./iterateJsdoc.js').Context[]} contexts - * @param {import('./iterateJsdoc.js').CheckJsdoc} checkJsdoc - * @param {import('@es-joy/jsdoccomment').CommentHandler} [handler] - * @returns {import('eslint').Rule.RuleListener} - */ -const getContextObject = (contexts, checkJsdoc, handler) => { - /** @type {import('eslint').Rule.RuleListener} */ - const properties = {}; - - for (const [ - idx, - prop, - ] of contexts.entries()) { - /** @type {string} */ - let property; - - /** @type {(node: import('eslint').Rule.Node) => void} */ - let value; - - if (typeof prop === 'object') { - const selInfo = { - lastIndex: idx, - selector: prop.context, - }; - if (prop.comment) { - property = /** @type {string} */ (prop.context); - value = checkJsdoc.bind( - null, - { - ...selInfo, - comment: prop.comment, - }, - /** - * @type {(jsdoc: import('@es-joy/jsdoccomment').JsdocBlockWithInline) => boolean} - */ - (/** @type {import('@es-joy/jsdoccomment').CommentHandler} */ ( - handler - ).bind(null, prop.comment)), - ); - } else { - property = /** @type {string} */ (prop.context); - value = checkJsdoc.bind(null, selInfo, null); - } - } else { - const selInfo = { - lastIndex: idx, - selector: prop, - }; - property = prop; - value = checkJsdoc.bind(null, selInfo, null); - } - - const old = /** - * @type {((node: import('eslint').Rule.Node) => void)} - */ (properties[property]); - properties[property] = old ? - /** - * @type {((node: import('eslint').Rule.Node) => void)} - */ - function (node) { - old(node); - value(node); - } : - value; - } - - return properties; -}; - -const tagsWithNamesAndDescriptions = new Set([ - 'param', 'arg', 'argument', 'property', 'prop', - 'template', - - // These two are parsed by our custom parser as though having a `name` - 'returns', 'return', -]); - -/** - * @typedef {{ - * [key: string]: false|string| - * {message: string, replacement?: string} - * }} TagNamePreference - */ - -/** - * @param {import('eslint').Rule.RuleContext} context - * @param {ParserMode|undefined} mode - * @param {import('comment-parser').Spec[]} tags - * @returns {{ - * tagsWithNames: import('comment-parser').Spec[], - * tagsWithoutNames: import('comment-parser').Spec[] - * }} - */ -const getTagsByType = (context, mode, tags) => { - /** - * @type {import('comment-parser').Spec[]} - */ - const tagsWithoutNames = []; - const tagsWithNames = tags.filter((tag) => { - const { - tag: tagName, - } = tag; - const tagWithName = tagsWithNamesAndDescriptions.has(tagName); - if (!tagWithName) { - tagsWithoutNames.push(tag); - } - - return tagWithName; - }); - - return { - tagsWithNames, - tagsWithoutNames, - }; -}; - -/** - * @param {import('eslint').SourceCode|{ - * text: string - * }} sourceCode - * @returns {string} - */ -const getIndent = (sourceCode) => { - return (sourceCode.text.match(/^\n*([ \t]+)/u)?.[1] ?? '') + ' '; -}; - -/** - * @param {import('eslint').Rule.Node|null} node - * @returns {boolean} - */ -const isConstructor = (node) => { - return node?.type === 'MethodDefinition' && node.kind === 'constructor' || - /** @type {import('@typescript-eslint/types').TSESTree.MethodDefinition} */ ( - node?.parent - )?.kind === 'constructor'; -}; - -/** - * @param {import('eslint').Rule.Node|null} node - * @returns {boolean} - */ -const isGetter = (node) => { - return node !== null && - /** - * @type {import('@typescript-eslint/types').TSESTree.MethodDefinition| - * import('@typescript-eslint/types').TSESTree.Property} - */ ( - node.parent - )?.kind === 'get'; -}; - -/** - * @param {import('eslint').Rule.Node|null} node - * @returns {boolean} - */ -const isSetter = (node) => { - return node !== null && - /** - * @type {import('@typescript-eslint/types').TSESTree.MethodDefinition| - * import('@typescript-eslint/types').TSESTree.Property} - */( - node.parent - )?.kind === 'set'; -}; - -/** - * @param {import('eslint').Rule.Node} node - * @returns {boolean} - */ -const hasAccessorPair = (node) => { - const { - type, - kind: sourceKind, - key, - } = - /** - * @type {import('@typescript-eslint/types').TSESTree.MethodDefinition| - * import('@typescript-eslint/types').TSESTree.Property} - */ (node); - - const sourceName = - /** @type {import('@typescript-eslint/types').TSESTree.Identifier} */ ( - key - ).name; - - const oppositeKind = sourceKind === 'get' ? 'set' : 'get'; - - const sibling = type === 'MethodDefinition' ? - /** @type {import('@typescript-eslint/types').TSESTree.ClassBody} */ ( - node.parent - ).body : - /** @type {import('@typescript-eslint/types').TSESTree.ObjectExpression} */ ( - node.parent - ).properties; - - return ( - sibling.some((child) => { - const { - kind, - key: ky, - } = /** - * @type {import('@typescript-eslint/types').TSESTree.MethodDefinition| - * import('@typescript-eslint/types').TSESTree.Property} - */ (child); - - const name = - /** @type {import('@typescript-eslint/types').TSESTree.Identifier} */ ( - ky - ).name; - - return kind === oppositeKind && name === sourceName; - }) - ); -}; - -/** - * @param {import('./iterateJsdoc.js').JsdocBlockWithInline} jsdoc - * @param {import('eslint').Rule.Node|null} node - * @param {import('eslint').Rule.RuleContext} context - * @param {import('json-schema').JSONSchema4} schema - * @returns {boolean} - */ -const exemptSpeciaMethods = (jsdoc, node, context, schema) => { - /** - * @param {"checkGetters"|"checkSetters"|"checkConstructors"} prop - * @returns {boolean|"no-setter"|"no-getter"} - */ - const hasSchemaOption = (prop) => { - const schemaProperties = schema[0].properties; - - return context.options[0]?.[prop] ?? - (schemaProperties[prop] && schemaProperties[prop].default); - }; - - const checkGetters = hasSchemaOption('checkGetters'); - const checkSetters = hasSchemaOption('checkSetters'); - - return !hasSchemaOption('checkConstructors') && - ( - isConstructor(node) || - hasATag(jsdoc, [ - 'class', - 'constructor', - ])) || - isGetter(node) && ( - !checkGetters || - checkGetters === 'no-setter' && hasAccessorPair(/** @type {import('./iterateJsdoc.js').Node} */ (node).parent) - ) || - isSetter(node) && ( - !checkSetters || - checkSetters === 'no-getter' && hasAccessorPair(/** @type {import('./iterateJsdoc.js').Node} */ (node).parent) - ); -}; - -/** - * Since path segments may be unquoted (if matching a reserved word, - * identifier or numeric literal) or single or double quoted, in either - * the `@param` or in source, we need to strip the quotes to give a fair - * comparison. - * @param {string} str - * @returns {string} - */ -const dropPathSegmentQuotes = (str) => { - return str.replaceAll(/\.(['"])(.*)\1/gu, '.$2'); -}; - -/** - * @param {string} name - * @returns {(otherPathName: string) => boolean} - */ -const comparePaths = (name) => { - return (otherPathName) => { - return otherPathName === name || - dropPathSegmentQuotes(otherPathName) === dropPathSegmentQuotes(name); - }; -}; - -/** - * @callback PathDoesNotBeginWith - * @param {string} name - * @param {string} otherPathName - * @returns {boolean} - */ - -/** @type {PathDoesNotBeginWith} */ -const pathDoesNotBeginWith = (name, otherPathName) => { - return !name.startsWith(otherPathName) && - !dropPathSegmentQuotes(name).startsWith(dropPathSegmentQuotes(otherPathName)); -}; - -/** - * @param {string} regexString - * @param {string} [requiredFlags] - * @returns {RegExp} - */ -const getRegexFromString = (regexString, requiredFlags) => { - const match = regexString.match(/^\/(.*)\/([gimyus]*)$/us); - let flags = 'u'; - let regex = regexString; - if (match) { - [ - , regex, - flags, - ] = match; - if (!flags) { - flags = 'u'; - } - } - - const uniqueFlags = [ - ...new Set(flags + (requiredFlags || '')), - ]; - flags = uniqueFlags.join(''); - - return new RegExp(regex, flags); -}; - -export default { - comparePaths, - dropPathSegmentQuotes, - enforcedContexts, - exemptSpeciaMethods, - flattenRoots, - getAllTags, - getContextObject, - getFunctionParameterNames, - getIndent, - getJsdocTagsDeep, - getPreferredTagName, - getRegexFromString, - getTagsByType, - getTagStructureForMode, - hasATag, - hasParams, - hasReturnValue, - hasTag, - hasThrowValue, - hasValueOrExecutorHasNonEmptyResolveValue, - hasYieldValue, - isConstructor, - isGetter, - isNamepathDefiningTag, - isNamepathOrUrlReferencingTag, - isNamepathReferencingTag, - isSetter, - isValidTag, - mayBeUndefinedTypeTag, - overrideTagStructure, - parseClosureTemplateTag, - pathDoesNotBeginWith, - setTagStructure, - tagMightHaveEitherTypeOrNamePosition, - tagMightHaveNamepath, - tagMightHaveNamePosition, - tagMightHaveTypePosition, - tagMissingRequiredTypeOrNamepath, - tagMustHaveNamePosition, - tagMustHaveTypePosition, -}; diff --git a/tools/eslint/node_modules/eslint-plugin-jsdoc/src/rules/checkAccess.js b/tools/eslint/node_modules/eslint-plugin-jsdoc/src/rules/checkAccess.js deleted file mode 100644 index 178b24771f8dad..00000000000000 --- a/tools/eslint/node_modules/eslint-plugin-jsdoc/src/rules/checkAccess.js +++ /dev/null @@ -1,45 +0,0 @@ -import iterateJsdoc from '../iterateJsdoc.js'; - -const accessLevels = [ - 'package', 'private', 'protected', 'public', -]; - -export default iterateJsdoc(({ - report, - utils, -}) => { - utils.forEachPreferredTag('access', (jsdocParameter, targetTagName) => { - const desc = jsdocParameter.name + ' ' + jsdocParameter.description; - - if (!accessLevels.includes(desc.trim())) { - report( - `Missing valid JSDoc @${targetTagName} level.`, - null, - jsdocParameter, - ); - } - }); - const accessLength = utils.getTags('access').length; - const individualTagLength = utils.getPresentTags(accessLevels).length; - if (accessLength && individualTagLength) { - report( - 'The @access tag may not be used with specific access-control tags (@package, @private, @protected, or @public).', - ); - } - - if (accessLength > 1 || individualTagLength > 1) { - report( - 'At most one access-control tag may be present on a jsdoc block.', - ); - } -}, { - checkPrivate: true, - iterateAllJsdocs: true, - meta: { - docs: { - description: 'Checks that `@access` tags have a valid value.', - url: 'https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/check-access.md#repos-sticky-header', - }, - type: 'suggestion', - }, -}); diff --git a/tools/eslint/node_modules/eslint-plugin-jsdoc/src/rules/checkAlignment.js b/tools/eslint/node_modules/eslint-plugin-jsdoc/src/rules/checkAlignment.js deleted file mode 100644 index 68d002c311cc67..00000000000000 --- a/tools/eslint/node_modules/eslint-plugin-jsdoc/src/rules/checkAlignment.js +++ /dev/null @@ -1,63 +0,0 @@ -import iterateJsdoc from '../iterateJsdoc.js'; - -/** - * @param {string} string - * @returns {string} - */ -const trimStart = (string) => { - return string.replace(/^\s+/u, ''); -}; - -export default iterateJsdoc(({ - sourceCode, - jsdocNode, - report, - indent, -}) => { - // `indent` is whitespace from line 1 (`/**`), so slice and account for "/". - const indentLevel = indent.length + 1; - const sourceLines = sourceCode.getText(jsdocNode).split('\n') - .slice(1) - .map((line) => { - return line.split('*')[0]; - }) - .filter((line) => { - return !trimStart(line).length; - }); - - /** @type {import('eslint').Rule.ReportFixer} */ - const fix = (fixer) => { - const replacement = sourceCode.getText(jsdocNode).split('\n') - .map((line, index) => { - // Ignore the first line and all lines not starting with `*` - const ignored = !index || trimStart(line.split('*')[0]).length; - - return ignored ? line : `${indent} ${trimStart(line)}`; - }) - .join('\n'); - - return fixer.replaceText(jsdocNode, replacement); - }; - - sourceLines.some((line, lineNum) => { - if (line.length !== indentLevel) { - report('Expected JSDoc block to be aligned.', fix, { - line: lineNum + 1, - }); - - return true; - } - - return false; - }); -}, { - iterateAllJsdocs: true, - meta: { - docs: { - description: 'Reports invalid alignment of JSDoc block asterisks.', - url: 'https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/check-alignment.md#repos-sticky-header', - }, - fixable: 'code', - type: 'layout', - }, -}); diff --git a/tools/eslint/node_modules/eslint-plugin-jsdoc/src/rules/checkExamples.js b/tools/eslint/node_modules/eslint-plugin-jsdoc/src/rules/checkExamples.js deleted file mode 100644 index 5d0f79875d6693..00000000000000 --- a/tools/eslint/node_modules/eslint-plugin-jsdoc/src/rules/checkExamples.js +++ /dev/null @@ -1,594 +0,0 @@ -// Todo: When replace `CLIEngine` with `ESLint` when feature set complete per https://github.com/eslint/eslint/issues/14745 -// https://github.com/eslint/eslint/blob/master/docs/user-guide/migrating-to-7.0.0.md#-the-cliengine-class-has-been-deprecated -import iterateJsdoc from '../iterateJsdoc.js'; -import eslint, { - ESLint, -} from 'eslint'; -import semver from 'semver'; - -const { - // @ts-expect-error Older ESLint - CLIEngine, -} = eslint; - -const zeroBasedLineIndexAdjust = -1; -const likelyNestedJSDocIndentSpace = 1; -const preTagSpaceLength = 1; - -// If a space is present, we should ignore it -const firstLinePrefixLength = preTagSpaceLength; - -const hasCaptionRegex = /^\s*([\s\S]*?)<\/caption>/u; - -/** - * @param {string} str - * @returns {string} - */ -const escapeStringRegexp = (str) => { - return str.replaceAll(/[.*+?^${}()|[\]\\]/gu, '\\$&'); -}; - -/** - * @param {string} str - * @param {string} ch - * @returns {import('../iterateJsdoc.js').Integer} - */ -const countChars = (str, ch) => { - return (str.match(new RegExp(escapeStringRegexp(ch), 'gu')) || []).length; -}; - -/** @type {import('eslint').Linter.RulesRecord} */ -const defaultMdRules = { - // "always" newline rule at end unlikely in sample code - 'eol-last': 0, - - // Wouldn't generally expect example paths to resolve relative to JS file - 'import/no-unresolved': 0, - - // Snippets likely too short to always include import/export info - 'import/unambiguous': 0, - - 'jsdoc/require-file-overview': 0, - - // The end of a multiline comment would end the comment the example is in. - 'jsdoc/require-jsdoc': 0, - - // Unlikely to have inadvertent debugging within examples - 'no-console': 0, - - // Often wish to start `@example` code after newline; also may use - // empty lines for spacing - 'no-multiple-empty-lines': 0, - - // Many variables in examples will be `undefined` - 'no-undef': 0, - - // Common to define variables for clarity without always using them - 'no-unused-vars': 0, - - // See import/no-unresolved - 'node/no-missing-import': 0, - 'node/no-missing-require': 0, - - // Can generally look nicer to pad a little even if code imposes more stringency - 'padded-blocks': 0, -}; - -/** @type {import('eslint').Linter.RulesRecord} */ -const defaultExpressionRules = { - ...defaultMdRules, - 'chai-friendly/no-unused-expressions': 'off', - 'no-empty-function': 'off', - 'no-new': 'off', - 'no-unused-expressions': 'off', - quotes: [ - 'error', 'double', - ], - semi: [ - 'error', 'never', - ], - strict: 'off', -}; - -/** - * @param {string} text - * @returns {[ - * import('../iterateJsdoc.js').Integer, - * import('../iterateJsdoc.js').Integer - * ]} - */ -const getLinesCols = (text) => { - const matchLines = countChars(text, '\n'); - - const colDelta = matchLines ? - text.slice(text.lastIndexOf('\n') + 1).length : - text.length; - - return [ - matchLines, colDelta, - ]; -}; - -export default iterateJsdoc(({ - report, - utils, - context, - globalState, -}) => { - if (semver.gte(ESLint.version, '8.0.0')) { - report( - 'This rule cannot yet be supported for ESLint 8; you ' + - 'should either downgrade to ESLint 7 or disable this rule. The ' + - 'possibility for ESLint 8 support is being tracked at https://github.com/eslint/eslint/issues/14745', - null, - { - column: 1, - line: 1, - }, - ); - - return; - } - - if (!globalState.has('checkExamples-matchingFileName')) { - globalState.set('checkExamples-matchingFileName', new Map()); - } - - const matchingFileNameMap = /** @type {Map} */ ( - globalState.get('checkExamples-matchingFileName') - ); - - const options = context.options[0] || {}; - let { - exampleCodeRegex = null, - rejectExampleCodeRegex = null, - } = options; - const { - checkDefaults = false, - checkParams = false, - checkProperties = false, - noDefaultExampleRules = false, - checkEslintrc = true, - matchingFileName = null, - matchingFileNameDefaults = null, - matchingFileNameParams = null, - matchingFileNameProperties = null, - paddedIndent = 0, - baseConfig = {}, - configFile, - allowInlineConfig = true, - reportUnusedDisableDirectives = true, - captionRequired = false, - } = options; - - // Make this configurable? - /** - * @type {never[]} - */ - const rulePaths = []; - - const mdRules = noDefaultExampleRules ? undefined : defaultMdRules; - - const expressionRules = noDefaultExampleRules ? undefined : defaultExpressionRules; - - if (exampleCodeRegex) { - exampleCodeRegex = utils.getRegexFromString(exampleCodeRegex); - } - - if (rejectExampleCodeRegex) { - rejectExampleCodeRegex = utils.getRegexFromString(rejectExampleCodeRegex); - } - - /** - * @param {{ - * filename: string, - * defaultFileName: string|undefined, - * source: string, - * targetTagName: string, - * rules?: import('eslint').Linter.RulesRecord|undefined, - * lines?: import('../iterateJsdoc.js').Integer, - * cols?: import('../iterateJsdoc.js').Integer, - * skipInit?: boolean, - * sources?: { - * nonJSPrefacingCols: import('../iterateJsdoc.js').Integer, - * nonJSPrefacingLines: import('../iterateJsdoc.js').Integer, - * string: string, - * }[], - * tag?: import('comment-parser').Spec & { - * line?: import('../iterateJsdoc.js').Integer, - * }|{ - * line: import('../iterateJsdoc.js').Integer, - * } - * }} cfg - */ - const checkSource = ({ - filename, - defaultFileName, - rules = expressionRules, - lines = 0, - cols = 0, - skipInit, - source, - targetTagName, - sources = [], - tag = { - line: 0, - }, - }) => { - if (!skipInit) { - sources.push({ - nonJSPrefacingCols: cols, - nonJSPrefacingLines: lines, - string: source, - }); - } - - // Todo: Make fixable - - /** - * @param {{ - * nonJSPrefacingCols: import('../iterateJsdoc.js').Integer, - * nonJSPrefacingLines: import('../iterateJsdoc.js').Integer, - * string: string - * }} cfg - */ - const checkRules = function ({ - nonJSPrefacingCols, - nonJSPrefacingLines, - string, - }) { - const cliConfig = { - allowInlineConfig, - baseConfig, - configFile, - reportUnusedDisableDirectives, - rulePaths, - rules, - useEslintrc: checkEslintrc, - }; - const cliConfigStr = JSON.stringify(cliConfig); - - const src = paddedIndent ? - string.replaceAll(new RegExp(`(^|\n) {${paddedIndent}}(?!$)`, 'gu'), '\n') : - string; - - // Programmatic ESLint API: https://eslint.org/docs/developer-guide/nodejs-api - const fileNameMapKey = filename ? - 'a' + cliConfigStr + filename : - 'b' + cliConfigStr + defaultFileName; - const file = filename || defaultFileName; - let cliFile; - if (matchingFileNameMap.has(fileNameMapKey)) { - cliFile = matchingFileNameMap.get(fileNameMapKey); - } else { - const cli = new CLIEngine(cliConfig); - let config; - if (filename || checkEslintrc) { - config = cli.getConfigForFile(file); - } - - // We need a new instance to ensure that the rules that may only - // be available to `file` (if it has its own `.eslintrc`), - // will be defined. - cliFile = new CLIEngine({ - allowInlineConfig, - baseConfig: { - ...baseConfig, - ...config, - }, - configFile, - reportUnusedDisableDirectives, - rulePaths, - rules, - useEslintrc: false, - }); - matchingFileNameMap.set(fileNameMapKey, cliFile); - } - - const { - results: [ - { - messages, - }, - ], - } = cliFile.executeOnText(src); - - if (!('line' in tag)) { - tag.line = tag.source[0].number; - } - - // NOTE: `tag.line` can be 0 if of form `/** @tag ... */` - const codeStartLine = /** - * @type {import('comment-parser').Spec & { - * line: import('../iterateJsdoc.js').Integer, - * }} - */ (tag).line + nonJSPrefacingLines; - const codeStartCol = likelyNestedJSDocIndentSpace; - - for (const { - message, - line, - column, - severity, - ruleId, - } of messages) { - const startLine = codeStartLine + line + zeroBasedLineIndexAdjust; - const startCol = codeStartCol + ( - - // This might not work for line 0, but line 0 is unlikely for examples - line <= 1 ? nonJSPrefacingCols + firstLinePrefixLength : preTagSpaceLength - ) + column; - - report( - '@' + targetTagName + ' ' + (severity === 2 ? 'error' : 'warning') + - (ruleId ? ' (' + ruleId + ')' : '') + ': ' + - message, - null, - { - column: startCol, - line: startLine, - }, - ); - } - }; - - for (const targetSource of sources) { - checkRules(targetSource); - } - }; - - /** - * - * @param {string} filename - * @param {string} [ext] Since `eslint-plugin-markdown` v2, and - * ESLint 7, this is the default which other JS-fenced rules will used. - * Formerly "md" was the default. - * @returns {{defaultFileName: string|undefined, filename: string}} - */ - const getFilenameInfo = (filename, ext = 'md/*.js') => { - let defaultFileName; - if (!filename) { - const jsFileName = context.getFilename(); - if (typeof jsFileName === 'string' && jsFileName.includes('.')) { - defaultFileName = jsFileName.replace(/\.[^.]*$/u, `.${ext}`); - } else { - defaultFileName = `dummy.${ext}`; - } - } - - return { - defaultFileName, - filename, - }; - }; - - if (checkDefaults) { - const filenameInfo = getFilenameInfo(matchingFileNameDefaults, 'jsdoc-defaults'); - utils.forEachPreferredTag('default', (tag, targetTagName) => { - if (!tag.description.trim()) { - return; - } - - checkSource({ - source: `(${utils.getTagDescription(tag)})`, - targetTagName, - ...filenameInfo, - }); - }); - } - - if (checkParams) { - const filenameInfo = getFilenameInfo(matchingFileNameParams, 'jsdoc-params'); - utils.forEachPreferredTag('param', (tag, targetTagName) => { - if (!tag.default || !tag.default.trim()) { - return; - } - - checkSource({ - source: `(${tag.default})`, - targetTagName, - ...filenameInfo, - }); - }); - } - - if (checkProperties) { - const filenameInfo = getFilenameInfo(matchingFileNameProperties, 'jsdoc-properties'); - utils.forEachPreferredTag('property', (tag, targetTagName) => { - if (!tag.default || !tag.default.trim()) { - return; - } - - checkSource({ - source: `(${tag.default})`, - targetTagName, - ...filenameInfo, - }); - }); - } - - const tagName = /** @type {string} */ (utils.getPreferredTagName({ - tagName: 'example', - })); - if (!utils.hasTag(tagName)) { - return; - } - - const matchingFilenameInfo = getFilenameInfo(matchingFileName); - - utils.forEachPreferredTag('example', (tag, targetTagName) => { - let source = /** @type {string} */ (utils.getTagDescription(tag)); - const match = source.match(hasCaptionRegex); - - if (captionRequired && (!match || !match[1].trim())) { - report('Caption is expected for examples.', null, tag); - } - - source = source.replace(hasCaptionRegex, ''); - const [ - lines, - cols, - ] = match ? getLinesCols(match[0]) : [ - 0, 0, - ]; - - if (exampleCodeRegex && !exampleCodeRegex.test(source) || - rejectExampleCodeRegex && rejectExampleCodeRegex.test(source) - ) { - return; - } - - const sources = []; - let skipInit = false; - if (exampleCodeRegex) { - let nonJSPrefacingCols = 0; - let nonJSPrefacingLines = 0; - - let startingIndex = 0; - let lastStringCount = 0; - - let exampleCode; - exampleCodeRegex.lastIndex = 0; - while ((exampleCode = exampleCodeRegex.exec(source)) !== null) { - const { - index, - '0': n0, - '1': n1, - } = exampleCode; - - // Count anything preceding user regex match (can affect line numbering) - const preMatch = source.slice(startingIndex, index); - - const [ - preMatchLines, - colDelta, - ] = getLinesCols(preMatch); - - let nonJSPreface; - let nonJSPrefaceLineCount; - if (n1) { - const idx = n0.indexOf(n1); - nonJSPreface = n0.slice(0, idx); - nonJSPrefaceLineCount = countChars(nonJSPreface, '\n'); - } else { - nonJSPreface = ''; - nonJSPrefaceLineCount = 0; - } - - nonJSPrefacingLines += lastStringCount + preMatchLines + nonJSPrefaceLineCount; - - // Ignore `preMatch` delta if newlines here - if (nonJSPrefaceLineCount) { - const charsInLastLine = nonJSPreface.slice(nonJSPreface.lastIndexOf('\n') + 1).length; - - nonJSPrefacingCols += charsInLastLine; - } else { - nonJSPrefacingCols += colDelta + nonJSPreface.length; - } - - const string = n1 || n0; - sources.push({ - nonJSPrefacingCols, - nonJSPrefacingLines, - string, - }); - startingIndex = exampleCodeRegex.lastIndex; - lastStringCount = countChars(string, '\n'); - if (!exampleCodeRegex.global) { - break; - } - } - - skipInit = true; - } - - checkSource({ - cols, - lines, - rules: mdRules, - skipInit, - source, - sources, - tag, - targetTagName, - ...matchingFilenameInfo, - }); - }); -}, { - iterateAllJsdocs: true, - meta: { - docs: { - description: 'Ensures that (JavaScript) examples within JSDoc adhere to ESLint rules.', - url: 'https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/check-examples.md#repos-sticky-header', - }, - schema: [ - { - additionalProperties: false, - properties: { - allowInlineConfig: { - default: true, - type: 'boolean', - }, - baseConfig: { - type: 'object', - }, - captionRequired: { - default: false, - type: 'boolean', - }, - checkDefaults: { - default: false, - type: 'boolean', - }, - checkEslintrc: { - default: true, - type: 'boolean', - }, - checkParams: { - default: false, - type: 'boolean', - }, - checkProperties: { - default: false, - type: 'boolean', - }, - configFile: { - type: 'string', - }, - exampleCodeRegex: { - type: 'string', - }, - matchingFileName: { - type: 'string', - }, - matchingFileNameDefaults: { - type: 'string', - }, - matchingFileNameParams: { - type: 'string', - }, - matchingFileNameProperties: { - type: 'string', - }, - noDefaultExampleRules: { - default: false, - type: 'boolean', - }, - paddedIndent: { - default: 0, - type: 'integer', - }, - rejectExampleCodeRegex: { - type: 'string', - }, - reportUnusedDisableDirectives: { - default: true, - type: 'boolean', - }, - }, - type: 'object', - }, - ], - type: 'suggestion', - }, -}); diff --git a/tools/eslint/node_modules/eslint-plugin-jsdoc/src/rules/checkIndentation.js b/tools/eslint/node_modules/eslint-plugin-jsdoc/src/rules/checkIndentation.js deleted file mode 100644 index 9157dc76515f2e..00000000000000 --- a/tools/eslint/node_modules/eslint-plugin-jsdoc/src/rules/checkIndentation.js +++ /dev/null @@ -1,75 +0,0 @@ -import iterateJsdoc from '../iterateJsdoc.js'; - -/** - * @param {string} str - * @param {string[]} excludeTags - * @returns {string} - */ -const maskExcludedContent = (str, excludeTags) => { - const regContent = new RegExp(`([ \\t]+\\*)[ \\t]@(?:${excludeTags.join('|')})(?=[ \\n])([\\w|\\W]*?\\n)(?=[ \\t]*\\*(?:[ \\t]*@\\w+\\s|\\/))`, 'gu'); - - return str.replace(regContent, (_match, margin, code) => { - return (margin + '\n').repeat(code.match(/\n/gu).length); - }); -}; - -/** - * @param {string} str - * @returns {string} - */ -const maskCodeBlocks = (str) => { - const regContent = /([ \t]+\*)[ \t]```[^\n]*?([\w|\W]*?\n)(?=[ \t]*\*(?:[ \t]*(?:```|@\w+\s)|\/))/gu; - - return str.replaceAll(regContent, (_match, margin, code) => { - return (margin + '\n').repeat(code.match(/\n/gu).length); - }); -}; - -export default iterateJsdoc(({ - sourceCode, - jsdocNode, - report, - context, -}) => { - const options = context.options[0] || {}; - const /** @type {{excludeTags: string[]}} */ { - excludeTags = [ - 'example', - ], - } = options; - - const reg = /^(?:\/?\**|[ \t]*)\*[ \t]{2}/gmu; - const textWithoutCodeBlocks = maskCodeBlocks(sourceCode.getText(jsdocNode)); - const text = excludeTags.length ? maskExcludedContent(textWithoutCodeBlocks, excludeTags) : textWithoutCodeBlocks; - - if (reg.test(text)) { - const lineBreaks = text.slice(0, reg.lastIndex).match(/\n/gu) || []; - report('There must be no indentation.', null, { - line: lineBreaks.length, - }); - } -}, { - iterateAllJsdocs: true, - meta: { - docs: { - description: 'Reports invalid padding inside JSDoc blocks.', - url: 'https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/check-indentation.md#repos-sticky-header', - }, - schema: [ - { - additionalProperties: false, - properties: { - excludeTags: { - items: { - pattern: '^\\S+$', - type: 'string', - }, - type: 'array', - }, - }, - type: 'object', - }, - ], - type: 'layout', - }, -}); diff --git a/tools/eslint/node_modules/eslint-plugin-jsdoc/src/rules/checkLineAlignment.js b/tools/eslint/node_modules/eslint-plugin-jsdoc/src/rules/checkLineAlignment.js deleted file mode 100644 index 1e9f80203f33e7..00000000000000 --- a/tools/eslint/node_modules/eslint-plugin-jsdoc/src/rules/checkLineAlignment.js +++ /dev/null @@ -1,372 +0,0 @@ -import alignTransform from '../alignTransform.js'; -import iterateJsdoc from '../iterateJsdoc.js'; -import { - transforms, -} from 'comment-parser'; - -const { - flow: commentFlow, -} = transforms; - -/** - * @typedef {{ - * postDelimiter: import('../iterateJsdoc.js').Integer, - * postHyphen: import('../iterateJsdoc.js').Integer, - * postName: import('../iterateJsdoc.js').Integer, - * postTag: import('../iterateJsdoc.js').Integer, - * postType: import('../iterateJsdoc.js').Integer, - * }} CustomSpacings - */ - -/** - * @param {import('../iterateJsdoc.js').Utils} utils - * @param {import('comment-parser').Spec & { - * line: import('../iterateJsdoc.js').Integer - * }} tag - * @param {CustomSpacings} customSpacings - */ -const checkNotAlignedPerTag = (utils, tag, customSpacings) => { - /* - start + - delimiter + - postDelimiter + - tag + - postTag + - type + - postType + - name + - postName + - description + - end + - lineEnd - */ - - /** - * @typedef {"tag"|"type"|"name"|"description"} ContentProp - */ - - /** @type {("postDelimiter"|"postTag"|"postType"|"postName")[]} */ - let spacerProps; - /** @type {ContentProp[]} */ - let contentProps; - const mightHaveNamepath = utils.tagMightHaveNamepath(tag.tag); - if (mightHaveNamepath) { - spacerProps = [ - 'postDelimiter', 'postTag', 'postType', 'postName', - ]; - contentProps = [ - 'tag', 'type', 'name', 'description', - ]; - } else { - spacerProps = [ - 'postDelimiter', 'postTag', 'postType', - ]; - contentProps = [ - 'tag', 'type', 'description', - ]; - } - - const { - tokens, - } = tag.source[0]; - - /** - * @param {import('../iterateJsdoc.js').Integer} idx - * @param {(notRet: boolean, contentProp: ContentProp) => void} [callbck] - */ - const followedBySpace = (idx, callbck) => { - const nextIndex = idx + 1; - - return spacerProps.slice(nextIndex).some((spacerProp, innerIdx) => { - const contentProp = contentProps[nextIndex + innerIdx]; - - const spacePropVal = tokens[spacerProp]; - - const ret = spacePropVal; - - if (callbck) { - callbck(!ret, contentProp); - } - - return ret && (callbck || !contentProp); - }); - }; - - const postHyphenSpacing = customSpacings?.postHyphen ?? 1; - const exactHyphenSpacing = new RegExp(`^\\s*-\\s{${postHyphenSpacing},${postHyphenSpacing}}(?!\\s)`, 'u'); - const hasNoHyphen = !(/^\s*-(?!$)(?=\s)/u).test(tokens.description); - const hasExactHyphenSpacing = exactHyphenSpacing.test( - tokens.description, - ); - - // If checking alignment on multiple lines, need to check other `source` - // items - // Go through `post*` spacing properties and exit to indicate problem if - // extra spacing detected - const ok = !spacerProps.some((spacerProp, idx) => { - const contentProp = contentProps[idx]; - const contentPropVal = tokens[contentProp]; - const spacerPropVal = tokens[spacerProp]; - const spacing = customSpacings?.[spacerProp] || 1; - - // There will be extra alignment if... - - // 1. The spaces don't match the space it should have (1 or custom spacing) OR - return spacerPropVal.length !== spacing && spacerPropVal.length !== 0 || - - // 2. There is a (single) space, no immediate content, and yet another - // space is found subsequently (not separated by intervening content) - spacerPropVal && !contentPropVal && followedBySpace(idx); - }) && (hasNoHyphen || hasExactHyphenSpacing); - if (ok) { - return; - } - - const fix = () => { - for (const [ - idx, - spacerProp, - ] of spacerProps.entries()) { - const contentProp = contentProps[idx]; - const contentPropVal = tokens[contentProp]; - - if (contentPropVal) { - const spacing = customSpacings?.[spacerProp] || 1; - tokens[spacerProp] = ''.padStart(spacing, ' '); - followedBySpace(idx, (hasSpace, contentPrp) => { - if (hasSpace) { - tokens[contentPrp] = ''; - } - }); - } else { - tokens[spacerProp] = ''; - } - } - - if (!hasExactHyphenSpacing) { - const hyphenSpacing = /^\s*-\s+/u; - tokens.description = tokens.description.replace( - hyphenSpacing, '-' + ''.padStart(postHyphenSpacing, ' '), - ); - } - - utils.setTag(tag, tokens); - }; - - utils.reportJSDoc('Expected JSDoc block lines to not be aligned.', tag, fix, true); -}; - -/** - * @param {object} cfg - * @param {CustomSpacings} cfg.customSpacings - * @param {string} cfg.indent - * @param {import('comment-parser').Block} cfg.jsdoc - * @param {import('eslint').Rule.Node & { - * range: [number, number] - * }} cfg.jsdocNode - * @param {boolean} cfg.preserveMainDescriptionPostDelimiter - * @param {import('../iterateJsdoc.js').Report} cfg.report - * @param {string[]} cfg.tags - * @param {import('../iterateJsdoc.js').Utils} cfg.utils - * @param {string} cfg.wrapIndent - * @param {boolean} cfg.disableWrapIndent - * @returns {void} - */ -const checkAlignment = ({ - customSpacings, - indent, - jsdoc, - jsdocNode, - preserveMainDescriptionPostDelimiter, - report, - tags, - utils, - wrapIndent, - disableWrapIndent, -}) => { - const transform = commentFlow( - alignTransform({ - customSpacings, - indent, - preserveMainDescriptionPostDelimiter, - tags, - wrapIndent, - disableWrapIndent, - }), - ); - const transformedJsdoc = transform(jsdoc); - - const comment = '/*' + - /** - * @type {import('eslint').Rule.Node & { - * range: [number, number], value: string - * }} - */ (jsdocNode).value + '*/'; - - const formatted = utils.stringify(transformedJsdoc) - .trimStart(); - - if (comment !== formatted) { - report( - 'Expected JSDoc block lines to be aligned.', - /** @type {import('eslint').Rule.ReportFixer} */ (fixer) => { - return fixer.replaceText(jsdocNode, formatted); - }, - ); - } -}; - -export default iterateJsdoc(({ - indent, - jsdoc, - jsdocNode, - report, - context, - utils, -}) => { - const { - tags: applicableTags = [ - 'param', 'arg', 'argument', 'property', 'prop', 'returns', 'return', - ], - preserveMainDescriptionPostDelimiter, - customSpacings, - wrapIndent = '', - disableWrapIndent = false, - } = context.options[1] || {}; - - if (context.options[0] === 'always') { - // Skip if it contains only a single line. - if (!( - /** - * @type {import('eslint').Rule.Node & { - * range: [number, number], value: string - * }} - */ - (jsdocNode).value.includes('\n') - )) { - return; - } - - checkAlignment({ - customSpacings, - indent, - jsdoc, - jsdocNode, - preserveMainDescriptionPostDelimiter, - report, - tags: applicableTags, - utils, - wrapIndent, - disableWrapIndent, - }); - - return; - } - - const foundTags = utils.getPresentTags(applicableTags); - if (context.options[0] !== 'any') { - for (const tag of foundTags) { - checkNotAlignedPerTag( - utils, - /** - * @type {import('comment-parser').Spec & { - * line: import('../iterateJsdoc.js').Integer - * }} - */ - (tag), - customSpacings, - ); - } - } - - for (const tag of foundTags) { - if (tag.source.length > 1) { - let idx = 0; - for (const { - tokens, - // Avoid the tag line - } of tag.source.slice(1)) { - idx++; - - if ( - !tokens.description || - // Avoid first lines after multiline type - tokens.type || - tokens.name - ) { - continue; - } - - // Don't include a single separating space/tab - if (!disableWrapIndent && tokens.postDelimiter.slice(1) !== wrapIndent) { - utils.reportJSDoc('Expected wrap indent', { - line: tag.source[0].number + idx, - }, () => { - tokens.postDelimiter = tokens.postDelimiter.charAt(0) + wrapIndent; - }); - return; - } - } - } - } -}, { - iterateAllJsdocs: true, - meta: { - docs: { - description: 'Reports invalid alignment of JSDoc block lines.', - url: 'https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/check-line-alignment.md#repos-sticky-header', - }, - fixable: 'whitespace', - schema: [ - { - enum: [ - 'always', 'never', 'any', - ], - type: 'string', - }, - { - additionalProperties: false, - properties: { - customSpacings: { - additionalProperties: false, - properties: { - postDelimiter: { - type: 'integer', - }, - postHyphen: { - type: 'integer', - }, - postName: { - type: 'integer', - }, - postTag: { - type: 'integer', - }, - postType: { - type: 'integer', - }, - }, - }, - preserveMainDescriptionPostDelimiter: { - default: false, - type: 'boolean', - }, - tags: { - items: { - type: 'string', - }, - type: 'array', - }, - wrapIndent: { - type: 'string', - }, - disableWrapIndent: { - type: 'boolean', - }, - }, - type: 'object', - }, - ], - type: 'layout', - }, -}); diff --git a/tools/eslint/node_modules/eslint-plugin-jsdoc/src/rules/checkParamNames.js b/tools/eslint/node_modules/eslint-plugin-jsdoc/src/rules/checkParamNames.js deleted file mode 100644 index 54ac72b9c4bc25..00000000000000 --- a/tools/eslint/node_modules/eslint-plugin-jsdoc/src/rules/checkParamNames.js +++ /dev/null @@ -1,454 +0,0 @@ -import iterateJsdoc from '../iterateJsdoc.js'; - -/** - * @param {string} targetTagName - * @param {boolean} allowExtraTrailingParamDocs - * @param {boolean} checkDestructured - * @param {boolean} checkRestProperty - * @param {RegExp} checkTypesRegex - * @param {boolean} disableExtraPropertyReporting - * @param {boolean} disableMissingParamChecks - * @param {boolean} enableFixer - * @param {import('../jsdocUtils.js').ParamNameInfo[]} functionParameterNames - * @param {import('comment-parser').Block} jsdoc - * @param {import('../iterateJsdoc.js').Utils} utils - * @param {import('../iterateJsdoc.js').Report} report - * @returns {boolean} - */ -const validateParameterNames = ( - targetTagName, - allowExtraTrailingParamDocs, - checkDestructured, - checkRestProperty, - checkTypesRegex, - disableExtraPropertyReporting, - disableMissingParamChecks, - enableFixer, - functionParameterNames, jsdoc, utils, report, -) => { - const paramTags = Object.entries(jsdoc.tags).filter(([ - , tag, - ]) => { - return tag.tag === targetTagName; - }); - const paramTagsNonNested = paramTags.filter(([ - , tag, - ]) => { - return !tag.name.includes('.'); - }); - - let dotted = 0; - let thisOffset = 0; - - // eslint-disable-next-line complexity - return paramTags.some(([ - , tag, - ], index) => { - /** @type {import('../iterateJsdoc.js').Integer} */ - let tagsIndex; - const dupeTagInfo = paramTags.find(([ - tgsIndex, - tg, - ], idx) => { - tagsIndex = Number(tgsIndex); - - return tg.name === tag.name && idx !== index; - }); - if (dupeTagInfo) { - utils.reportJSDoc(`Duplicate @${targetTagName} "${tag.name}"`, dupeTagInfo[1], enableFixer ? () => { - utils.removeTag(tagsIndex); - } : null); - - return true; - } - - if (tag.name.includes('.')) { - dotted++; - - return false; - } - - let functionParameterName = functionParameterNames[index - dotted + thisOffset]; - if (functionParameterName === 'this' && tag.name.trim() !== 'this') { - ++thisOffset; - functionParameterName = functionParameterNames[index - dotted + thisOffset]; - } - - if (!functionParameterName) { - if (allowExtraTrailingParamDocs) { - return false; - } - - report( - `@${targetTagName} "${tag.name}" does not match an existing function parameter.`, - null, - tag, - ); - - return true; - } - if ( - typeof functionParameterName === 'object' && - 'name' in functionParameterName && - Array.isArray(functionParameterName.name) - ) { - const actualName = tag.name.trim(); - const expectedName = functionParameterName.name[index]; - if (actualName === expectedName) { - thisOffset--; - return false; - } - report( - `Expected @${targetTagName} name to be "${expectedName}". Got "${actualName}".`, - null, - tag, - ); - return true; - } - - if (Array.isArray(functionParameterName)) { - if (!checkDestructured) { - return false; - } - - if (tag.type && tag.type.search(checkTypesRegex) === -1) { - return false; - } - - const [ - parameterName, - { - names: properties, - hasPropertyRest, - rests, - annotationParamName, - }, - ] = - /** - * @type {[string | undefined, import('../jsdocUtils.js').FlattendRootInfo & { - * annotationParamName?: string | undefined; - }]} */ (functionParameterName); - if (annotationParamName !== undefined) { - const name = tag.name.trim(); - if (name !== annotationParamName) { - report(`@${targetTagName} "${name}" does not match parameter name "${annotationParamName}"`, null, tag); - } - } - - const tagName = parameterName === undefined ? tag.name.trim() : parameterName; - const expectedNames = properties.map((name) => { - return `${tagName}.${name}`; - }); - const actualNames = paramTags.map(([ - , paramTag, - ]) => { - return paramTag.name.trim(); - }); - const actualTypes = paramTags.map(([ - , paramTag, - ]) => { - return paramTag.type; - }); - - const missingProperties = []; - - /** @type {string[]} */ - const notCheckingNames = []; - - for (const [ - idx, - name, - ] of expectedNames.entries()) { - if (notCheckingNames.some((notCheckingName) => { - return name.startsWith(notCheckingName); - })) { - continue; - } - - const actualNameIdx = actualNames.findIndex((actualName) => { - return utils.comparePaths(name)(actualName); - }); - if (actualNameIdx === -1) { - if (!checkRestProperty && rests[idx]) { - continue; - } - - const missingIndex = actualNames.findIndex((actualName) => { - return utils.pathDoesNotBeginWith(name, actualName); - }); - const line = tag.source[0].number - 1 + (missingIndex > -1 ? missingIndex : actualNames.length); - missingProperties.push({ - name, - tagPlacement: { - line: line === 0 ? 1 : line, - }, - }); - } else if (actualTypes[actualNameIdx].search(checkTypesRegex) === -1 && actualTypes[actualNameIdx] !== '') { - notCheckingNames.push(name); - } - } - - const hasMissing = missingProperties.length; - if (hasMissing) { - for (const { - tagPlacement, - name: missingProperty, - } of missingProperties) { - report(`Missing @${targetTagName} "${missingProperty}"`, null, tagPlacement); - } - } - - if (!hasPropertyRest || checkRestProperty) { - /** @type {[string, import('comment-parser').Spec][]} */ - const extraProperties = []; - for (const [ - idx, - name, - ] of actualNames.entries()) { - const match = name.startsWith(tag.name.trim() + '.'); - if ( - match && !expectedNames.some( - utils.comparePaths(name), - ) && !utils.comparePaths(name)(tag.name) && - (!disableExtraPropertyReporting || properties.some((prop) => { - return prop.split('.').length >= name.split('.').length - 1; - })) - ) { - extraProperties.push([ - name, paramTags[idx][1], - ]); - } - } - - if (extraProperties.length) { - for (const [ - extraProperty, - tg, - ] of extraProperties) { - report(`@${targetTagName} "${extraProperty}" does not exist on ${tag.name}`, null, tg); - } - - return true; - } - } - - return hasMissing; - } - - let funcParamName; - if (typeof functionParameterName === 'object') { - const { - name, - } = functionParameterName; - funcParamName = name; - } else { - funcParamName = functionParameterName; - } - - if (funcParamName !== tag.name.trim()) { - // Todo: Improve for array or object child items - const actualNames = paramTagsNonNested.map(([ - , { - name, - }, - ]) => { - return name.trim(); - }); - - const expectedNames = functionParameterNames.map((item, idx) => { - if (/** - * @type {[string|undefined, (import('../jsdocUtils.js').FlattendRootInfo & { - * annotationParamName?: string, - })]} */ (item)?.[1]?.names) { - return actualNames[idx]; - } - - return item; - }).filter((item) => { - return item !== 'this'; - }); - - // When disableMissingParamChecks is true tag names can be omitted. - // Report when the tag names do not match the expected names or they are used out of order. - if (disableMissingParamChecks) { - const usedExpectedNames = expectedNames.map(a => a?.toString()).filter(expectedName => expectedName && actualNames.includes(expectedName)); - const usedInOrder = actualNames.every((actualName, idx) => actualName === usedExpectedNames[idx]); - if (usedInOrder) { - return false; - } - } - - report( - `Expected @${targetTagName} names to be "${ - expectedNames.map((expectedName) => { - return typeof expectedName === 'object' && - 'name' in expectedName && - expectedName.restElement - ? '...' + expectedName.name - : expectedName; - }).join(', ') - }". Got "${actualNames.join(', ')}".`, - null, - tag, - ); - - return true; - } - - return false; - }); -}; - -/** - * @param {string} targetTagName - * @param {boolean} _allowExtraTrailingParamDocs - * @param {{ - * name: string, - * idx: import('../iterateJsdoc.js').Integer - * }[]} jsdocParameterNames - * @param {import('comment-parser').Block} jsdoc - * @param {Function} report - * @returns {boolean} - */ -const validateParameterNamesDeep = ( - targetTagName, _allowExtraTrailingParamDocs, - jsdocParameterNames, jsdoc, report, -) => { - /** @type {string} */ - let lastRealParameter; - - return jsdocParameterNames.some(({ - name: jsdocParameterName, - idx, - }) => { - const isPropertyPath = jsdocParameterName.includes('.'); - - if (isPropertyPath) { - if (!lastRealParameter) { - report(`@${targetTagName} path declaration ("${jsdocParameterName}") appears before any real parameter.`, null, jsdoc.tags[idx]); - - return true; - } - - let pathRootNodeName = jsdocParameterName.slice(0, jsdocParameterName.indexOf('.')); - - if (pathRootNodeName.endsWith('[]')) { - pathRootNodeName = pathRootNodeName.slice(0, -2); - } - - if (pathRootNodeName !== lastRealParameter) { - report( - `@${targetTagName} path declaration ("${jsdocParameterName}") root node name ("${pathRootNodeName}") ` + - `does not match previous real parameter name ("${lastRealParameter}").`, - null, - jsdoc.tags[idx], - ); - - return true; - } - } else { - lastRealParameter = jsdocParameterName; - } - - return false; - }); -}; - -export default iterateJsdoc(({ - context, - jsdoc, - report, - utils, -}) => { - const { - allowExtraTrailingParamDocs, - checkDestructured = true, - checkRestProperty = false, - checkTypesPattern = '/^(?:[oO]bject|[aA]rray|PlainObject|Generic(?:Object|Array))$/', - enableFixer = false, - useDefaultObjectProperties = false, - disableExtraPropertyReporting = false, - disableMissingParamChecks = false, - } = context.options[0] || {}; - - const checkTypesRegex = utils.getRegexFromString(checkTypesPattern); - - const jsdocParameterNamesDeep = utils.getJsdocTagsDeep('param'); - if (!jsdocParameterNamesDeep || !jsdocParameterNamesDeep.length) { - return; - } - - const functionParameterNames = utils.getFunctionParameterNames(useDefaultObjectProperties); - - const targetTagName = /** @type {string} */ (utils.getPreferredTagName({ - tagName: 'param', - })); - const isError = validateParameterNames( - targetTagName, - allowExtraTrailingParamDocs, - checkDestructured, - checkRestProperty, - checkTypesRegex, - disableExtraPropertyReporting, - disableMissingParamChecks, - enableFixer, - functionParameterNames, - jsdoc, - utils, - report, - ); - - if (isError || !checkDestructured) { - return; - } - - validateParameterNamesDeep( - targetTagName, allowExtraTrailingParamDocs, jsdocParameterNamesDeep, jsdoc, report, - ); -}, { - contextDefaults: [ - 'ArrowFunctionExpression', 'FunctionDeclaration', 'FunctionExpression', 'TSDeclareFunction', - // Add this to above defaults - 'TSMethodSignature' - ], - meta: { - docs: { - description: 'Ensures that parameter names in JSDoc match those in the function declaration.', - url: 'https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/check-param-names.md#repos-sticky-header', - }, - fixable: 'code', - schema: [ - { - additionalProperties: false, - properties: { - allowExtraTrailingParamDocs: { - type: 'boolean', - }, - checkDestructured: { - type: 'boolean', - }, - checkRestProperty: { - type: 'boolean', - }, - checkTypesPattern: { - type: 'string', - }, - disableExtraPropertyReporting: { - type: 'boolean', - }, - disableMissingParamChecks: { - type: 'boolean', - }, - enableFixer: { - type: 'boolean', - }, - useDefaultObjectProperties: { - type: 'boolean', - }, - }, - type: 'object', - }, - ], - type: 'suggestion', - }, -}); diff --git a/tools/eslint/node_modules/eslint-plugin-jsdoc/src/rules/checkPropertyNames.js b/tools/eslint/node_modules/eslint-plugin-jsdoc/src/rules/checkPropertyNames.js deleted file mode 100644 index 8bada8877b08be..00000000000000 --- a/tools/eslint/node_modules/eslint-plugin-jsdoc/src/rules/checkPropertyNames.js +++ /dev/null @@ -1,152 +0,0 @@ -import iterateJsdoc from '../iterateJsdoc.js'; - -/** - * @param {string} targetTagName - * @param {boolean} enableFixer - * @param {import('comment-parser').Block} jsdoc - * @param {import('../iterateJsdoc.js').Utils} utils - * @returns {boolean} - */ -const validatePropertyNames = ( - targetTagName, - enableFixer, - jsdoc, utils, -) => { - const propertyTags = Object.entries(jsdoc.tags).filter(([ - , tag, - ]) => { - return tag.tag === targetTagName; - }); - - return propertyTags.some(([ - , tag, - ], index) => { - /** @type {import('../iterateJsdoc.js').Integer} */ - let tagsIndex; - const dupeTagInfo = propertyTags.find(([ - tgsIndex, - tg, - ], idx) => { - tagsIndex = Number(tgsIndex); - - return tg.name === tag.name && idx !== index; - }); - if (dupeTagInfo) { - utils.reportJSDoc(`Duplicate @${targetTagName} "${tag.name}"`, dupeTagInfo[1], enableFixer ? () => { - utils.removeTag(tagsIndex); - } : null); - - return true; - } - - return false; - }); -}; - -/** - * @param {string} targetTagName - * @param {{ - * idx: number; - * name: string; - * type: string; - * }[]} jsdocPropertyNames - * @param {import('comment-parser').Block} jsdoc - * @param {Function} report - */ -const validatePropertyNamesDeep = ( - targetTagName, - jsdocPropertyNames, jsdoc, report, -) => { - /** @type {string} */ - let lastRealProperty; - - return jsdocPropertyNames.some(({ - name: jsdocPropertyName, - idx, - }) => { - const isPropertyPath = jsdocPropertyName.includes('.'); - - if (isPropertyPath) { - if (!lastRealProperty) { - report(`@${targetTagName} path declaration ("${jsdocPropertyName}") appears before any real property.`, null, jsdoc.tags[idx]); - - return true; - } - - let pathRootNodeName = jsdocPropertyName.slice(0, jsdocPropertyName.indexOf('.')); - - if (pathRootNodeName.endsWith('[]')) { - pathRootNodeName = pathRootNodeName.slice(0, -2); - } - - if (pathRootNodeName !== lastRealProperty) { - report( - `@${targetTagName} path declaration ("${jsdocPropertyName}") root node name ("${pathRootNodeName}") ` + - `does not match previous real property name ("${lastRealProperty}").`, - null, - jsdoc.tags[idx], - ); - - return true; - } - } else { - lastRealProperty = jsdocPropertyName; - } - - return false; - }); -}; - -export default iterateJsdoc(({ - context, - jsdoc, - report, - utils, -}) => { - const { - enableFixer = false, - } = context.options[0] || {}; - const jsdocPropertyNamesDeep = utils.getJsdocTagsDeep('property'); - if (!jsdocPropertyNamesDeep || !jsdocPropertyNamesDeep.length) { - return; - } - - const targetTagName = /** @type {string} */ (utils.getPreferredTagName({ - tagName: 'property', - })); - const isError = validatePropertyNames( - targetTagName, - enableFixer, - jsdoc, - utils, - ); - - if (isError) { - return; - } - - validatePropertyNamesDeep( - targetTagName, jsdocPropertyNamesDeep, jsdoc, report, - ); -}, { - iterateAllJsdocs: true, - meta: { - docs: { - description: 'Ensures that property names in JSDoc are not duplicated on the same block and that nested properties have defined roots.', - url: 'https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/check-property-names.md#repos-sticky-header', - }, - fixable: 'code', - schema: [ - { - additionalProperties: false, - properties: { - enableFixer: { - type: 'boolean', - }, - }, - type: 'object', - }, - ], - type: 'suggestion', - }, -}); diff --git a/tools/eslint/node_modules/eslint-plugin-jsdoc/src/rules/checkSyntax.js b/tools/eslint/node_modules/eslint-plugin-jsdoc/src/rules/checkSyntax.js deleted file mode 100644 index 74f81bdd45ef65..00000000000000 --- a/tools/eslint/node_modules/eslint-plugin-jsdoc/src/rules/checkSyntax.js +++ /dev/null @@ -1,30 +0,0 @@ -import iterateJsdoc from '../iterateJsdoc.js'; - -export default iterateJsdoc(({ - jsdoc, - report, - settings, -}) => { - const { - mode, - } = settings; - - // Don't check for "permissive" and "closure" - if (mode === 'jsdoc' || mode === 'typescript') { - for (const tag of jsdoc.tags) { - if (tag.type.slice(-1) === '=') { - report('Syntax should not be Google Closure Compiler style.', null, tag); - break; - } - } - } -}, { - iterateAllJsdocs: true, - meta: { - docs: { - description: 'Reports against syntax not valid for the mode (e.g., Google Closure Compiler in non-Closure mode).', - url: 'https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/check-syntax.md#repos-sticky-header', - }, - type: 'suggestion', - }, -}); diff --git a/tools/eslint/node_modules/eslint-plugin-jsdoc/src/rules/checkTagNames.js b/tools/eslint/node_modules/eslint-plugin-jsdoc/src/rules/checkTagNames.js deleted file mode 100644 index 09fe505f6e5cbb..00000000000000 --- a/tools/eslint/node_modules/eslint-plugin-jsdoc/src/rules/checkTagNames.js +++ /dev/null @@ -1,314 +0,0 @@ -import iterateJsdoc from '../iterateJsdoc.js'; -import escapeStringRegexp from 'escape-string-regexp'; - -// https://babeljs.io/docs/en/babel-plugin-transform-react-jsx/ -const jsxTagNames = new Set([ - 'jsx', - 'jsxFrag', - 'jsxImportSource', - 'jsxRuntime', -]); - -const typedTagsAlwaysUnnecessary = new Set([ - 'augments', - 'callback', - 'class', - 'enum', - 'implements', - 'private', - 'property', - 'protected', - 'public', - 'readonly', - 'this', - 'type', - 'typedef', -]); - -const typedTagsNeedingName = new Set([ - 'template', -]); - -const typedTagsUnnecessaryOutsideDeclare = new Set([ - 'abstract', - 'access', - 'class', - 'constant', - 'constructs', - 'default', - 'enum', - 'export', - 'exports', - 'function', - 'global', - 'inherits', - 'instance', - 'interface', - 'member', - 'memberof', - 'memberOf', - 'method', - 'mixes', - 'mixin', - 'module', - 'name', - 'namespace', - 'override', - 'property', - 'requires', - 'static', - 'this', -]); - -export default iterateJsdoc(({ - sourceCode, - jsdoc, - report, - utils, - context, - node, - settings, - jsdocNode, -}) => { - const - /** - * @type {{ - * definedTags: string[], - * enableFixer: boolean, - * jsxTags: boolean, - * typed: boolean - }} */ { - definedTags = [], - enableFixer = true, - jsxTags, - typed, - } = context.options[0] || {}; - - /** @type {(string|undefined)[]} */ - let definedPreferredTags = []; - const { - tagNamePreference, - structuredTags, - } = settings; - const definedStructuredTags = Object.keys(structuredTags); - const definedNonPreferredTags = Object.keys(tagNamePreference); - if (definedNonPreferredTags.length) { - definedPreferredTags = Object.values(tagNamePreference).map((preferredTag) => { - if (typeof preferredTag === 'string') { - // May become an empty string but will be filtered out below - return preferredTag; - } - - if (!preferredTag) { - return undefined; - } - - if (typeof preferredTag !== 'object') { - utils.reportSettings( - 'Invalid `settings.jsdoc.tagNamePreference`. Values must be falsy, a string, or an object.', - ); - } - - return preferredTag.replacement; - }) - .filter(Boolean); - } - - /** - * @param {import('eslint').Rule.Node} subNode - * @returns {boolean} - */ - const isInAmbientContext = (subNode) => { - return subNode.type === 'Program' ? - context.getFilename().endsWith('.d.ts') : - Boolean( - /** @type {import('@typescript-eslint/types').TSESTree.VariableDeclaration} */ ( - subNode - ).declare, - ) || isInAmbientContext(subNode.parent); - }; - - /** - * @param {import('comment-parser').Spec} jsdocTag - * @returns {boolean} - */ - const tagIsRedundantWhenTyped = (jsdocTag) => { - if (!typedTagsUnnecessaryOutsideDeclare.has(jsdocTag.tag)) { - return false; - } - - if (jsdocTag.tag === 'default') { - return false; - } - - if (node === null) { - return false; - } - - if (context.getFilename().endsWith('.d.ts') && [ - 'Program', null, undefined, - ].includes(node?.parent?.type)) { - return false; - } - - if (isInAmbientContext(/** @type {import('eslint').Rule.Node} */ (node))) { - return false; - } - - return true; - }; - - /** - * @param {string} message - * @param {import('comment-parser').Spec} jsdocTag - * @param {import('../iterateJsdoc.js').Integer} tagIndex - * @param {Partial} [additionalTagChanges] - * @returns {void} - */ - const reportWithTagRemovalFixer = (message, jsdocTag, tagIndex, additionalTagChanges) => { - utils.reportJSDoc(message, jsdocTag, enableFixer ? () => { - if (jsdocTag.description.trim()) { - utils.changeTag(jsdocTag, { - postType: '', - type: '', - ...additionalTagChanges, - }); - } else { - utils.removeTag(tagIndex, { - removeEmptyBlock: true, - }); - } - } : null, true); - }; - - /** - * @param {import('comment-parser').Spec} jsdocTag - * @param {import('../iterateJsdoc.js').Integer} tagIndex - * @returns {boolean} - */ - const checkTagForTypedValidity = (jsdocTag, tagIndex) => { - if (typedTagsAlwaysUnnecessary.has(jsdocTag.tag)) { - reportWithTagRemovalFixer( - `'@${jsdocTag.tag}' is redundant when using a type system.`, - jsdocTag, - tagIndex, - { - postTag: '', - tag: '', - }, - ); - return true; - } - - if (tagIsRedundantWhenTyped(jsdocTag)) { - reportWithTagRemovalFixer( - `'@${jsdocTag.tag}' is redundant outside of ambient (\`declare\`/\`.d.ts\`) contexts when using a type system.`, - jsdocTag, - tagIndex, - ); - return true; - } - - if (typedTagsNeedingName.has(jsdocTag.tag) && !jsdocTag.name) { - reportWithTagRemovalFixer( - `'@${jsdocTag.tag}' without a name is redundant when using a type system.`, - jsdocTag, - tagIndex, - ); - return true; - } - - return false; - }; - - for (let tagIndex = 0; tagIndex < jsdoc.tags.length; tagIndex += 1) { - const jsdocTag = jsdoc.tags[tagIndex]; - const tagName = jsdocTag.tag; - if (jsxTags && jsxTagNames.has(tagName)) { - continue; - } - - if (typed && checkTagForTypedValidity(jsdocTag, tagIndex)) { - continue; - } - - const validTags = [ - ...definedTags, - ...(/** @type {string[]} */ (definedPreferredTags)), - ...definedNonPreferredTags, - ...definedStructuredTags, - ...typed ? typedTagsNeedingName : [], - ]; - - if (utils.isValidTag(tagName, validTags)) { - let preferredTagName = utils.getPreferredTagName({ - allowObjectReturn: true, - defaultMessage: `Blacklisted tag found (\`@${tagName}\`)`, - tagName, - }); - if (!preferredTagName) { - continue; - } - - let message; - if (typeof preferredTagName === 'object') { - ({ - message, - replacement: preferredTagName, - } = /** @type {{message: string; replacement?: string | undefined;}} */ ( - preferredTagName - )); - } - - if (!message) { - message = `Invalid JSDoc tag (preference). Replace "${tagName}" JSDoc tag with "${preferredTagName}".`; - } - - if (preferredTagName !== tagName) { - report(message, (fixer) => { - const replacement = sourceCode.getText(jsdocNode).replace( - new RegExp(`@${escapeStringRegexp(tagName)}\\b`, 'u'), - `@${preferredTagName}`, - ); - - return fixer.replaceText(jsdocNode, replacement); - }, jsdocTag); - } - } else { - report(`Invalid JSDoc tag name "${tagName}".`, null, jsdocTag); - } - } -}, { - iterateAllJsdocs: true, - meta: { - docs: { - description: 'Reports invalid block tag names.', - url: 'https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/check-tag-names.md#repos-sticky-header', - }, - fixable: 'code', - schema: [ - { - additionalProperties: false, - properties: { - definedTags: { - items: { - type: 'string', - }, - type: 'array', - }, - enableFixer: { - type: 'boolean', - }, - jsxTags: { - type: 'boolean', - }, - typed: { - type: 'boolean', - }, - }, - type: 'object', - }, - ], - type: 'suggestion', - }, -}); diff --git a/tools/eslint/node_modules/eslint-plugin-jsdoc/src/rules/checkTypes.js b/tools/eslint/node_modules/eslint-plugin-jsdoc/src/rules/checkTypes.js deleted file mode 100644 index c295db88727956..00000000000000 --- a/tools/eslint/node_modules/eslint-plugin-jsdoc/src/rules/checkTypes.js +++ /dev/null @@ -1,535 +0,0 @@ -import iterateJsdoc from '../iterateJsdoc.js'; -import { - parse, - stringify, - traverse, - tryParse, -} from '@es-joy/jsdoccomment'; - -const strictNativeTypes = [ - 'undefined', - 'null', - 'boolean', - 'number', - 'bigint', - 'string', - 'symbol', - 'object', - 'Array', - 'Function', - 'Date', - 'RegExp', -]; - -/** - * Adjusts the parent type node `meta` for generic matches (or type node - * `type` for `JsdocTypeAny`) and sets the type node `value`. - * @param {string} type The actual type - * @param {string} preferred The preferred type - * @param {boolean} isGenericMatch - * @param {string} typeNodeName - * @param {import('jsdoc-type-pratt-parser').NonRootResult} node - * @param {import('jsdoc-type-pratt-parser').NonRootResult|undefined} parentNode - * @returns {void} - */ -const adjustNames = (type, preferred, isGenericMatch, typeNodeName, node, parentNode) => { - let ret = preferred; - if (isGenericMatch) { - const parentMeta = /** @type {import('jsdoc-type-pratt-parser').GenericResult} */ ( - parentNode - ).meta; - if (preferred === '[]') { - parentMeta.brackets = 'square'; - parentMeta.dot = false; - ret = 'Array'; - } else { - const dotBracketEnd = preferred.match(/\.(?:<>)?$/u); - if (dotBracketEnd) { - parentMeta.brackets = 'angle'; - parentMeta.dot = true; - ret = preferred.slice(0, -dotBracketEnd[0].length); - } else { - const bracketEnd = preferred.endsWith('<>'); - if (bracketEnd) { - parentMeta.brackets = 'angle'; - parentMeta.dot = false; - ret = preferred.slice(0, -2); - } else if ( - parentMeta?.brackets === 'square' && - (typeNodeName === '[]' || typeNodeName === 'Array') - ) { - parentMeta.brackets = 'angle'; - parentMeta.dot = false; - } - } - } - } else if (type === 'JsdocTypeAny') { - node.type = 'JsdocTypeName'; - } - - /** @type {import('jsdoc-type-pratt-parser').NameResult} */ ( - node - ).value = ret.replace(/(?:\.|<>|\.<>|\[\])$/u, ''); - - // For bare pseudo-types like `<>` - if (!ret) { - /** @type {import('jsdoc-type-pratt-parser').NameResult} */ ( - node - ).value = typeNodeName; - } -}; - -/** - * @param {boolean} [upperCase] - * @returns {string} - */ -const getMessage = (upperCase) => { - return 'Use object shorthand or index signatures instead of ' + - '`' + (upperCase ? 'O' : 'o') + 'bject`, e.g., `{[key: string]: string}`'; -}; - -export default iterateJsdoc(({ - jsdocNode, - sourceCode, - report, - utils, - settings, - context, -}) => { - const jsdocTagsWithPossibleType = utils.filterTags((tag) => { - return Boolean(utils.tagMightHaveTypePosition(tag.tag)); - }); - - const - /** - * @type {{ - * preferredTypes: import('../iterateJsdoc.js').PreferredTypes, - * structuredTags: import('../iterateJsdoc.js').StructuredTags, - * mode: import('../jsdocUtils.js').ParserMode - * }} - */ - { - preferredTypes: preferredTypesOriginal, - structuredTags, - mode, - } = settings; - - const injectObjectPreferredTypes = !('Object' in preferredTypesOriginal || - 'object' in preferredTypesOriginal || - 'object.<>' in preferredTypesOriginal || - 'Object.<>' in preferredTypesOriginal || - 'object<>' in preferredTypesOriginal); - - /** - * @type {{ - * message: string, - * replacement: false - * }} - */ - const info = { - message: getMessage(), - replacement: false, - }; - - /** - * @type {{ - * message: string, - * replacement: false - * }} - */ - const infoUC = { - message: getMessage(true), - replacement: false, - }; - - /** @type {import('../iterateJsdoc.js').PreferredTypes} */ - const typeToInject = mode === 'typescript' ? - { - Object: 'object', - 'object.<>': info, - 'Object.<>': infoUC, - 'object<>': info, - 'Object<>': infoUC, - } : - { - Object: 'object', - 'object.<>': 'Object<>', - 'Object.<>': 'Object<>', - 'object<>': 'Object<>', - }; - - /** @type {import('../iterateJsdoc.js').PreferredTypes} */ - const preferredTypes = { - ...injectObjectPreferredTypes ? - typeToInject : - {}, - ...preferredTypesOriginal, - }; - - const - /** - * @type {{ - * noDefaults: boolean, - * unifyParentAndChildTypeChecks: boolean, - * exemptTagContexts: ({ - * tag: string, - * types: true|string[] - * })[] - * }} - */ { - noDefaults, - unifyParentAndChildTypeChecks, - exemptTagContexts = [], - } = context.options[0] || {}; - - /** - * Gets information about the preferred type: whether there is a matching - * preferred type, what the type is, and whether it is a match to a generic. - * @param {string} _type Not currently in use - * @param {string} typeNodeName - * @param {import('jsdoc-type-pratt-parser').NonRootResult|undefined} parentNode - * @param {string|undefined} property - * @returns {[hasMatchingPreferredType: boolean, typeName: string, isGenericMatch: boolean]} - */ - const getPreferredTypeInfo = (_type, typeNodeName, parentNode, property) => { - let hasMatchingPreferredType = false; - let isGenericMatch = false; - let typeName = typeNodeName; - - const isNameOfGeneric = parentNode !== undefined && parentNode.type === 'JsdocTypeGeneric' && property === 'left'; - if (unifyParentAndChildTypeChecks || isNameOfGeneric) { - const brackets = /** @type {import('jsdoc-type-pratt-parser').GenericResult} */ ( - parentNode - )?.meta?.brackets; - const dot = /** @type {import('jsdoc-type-pratt-parser').GenericResult} */ ( - parentNode - )?.meta?.dot; - - if (brackets === 'angle') { - const checkPostFixes = dot ? [ - '.', '.<>', - ] : [ - '<>', - ]; - isGenericMatch = checkPostFixes.some((checkPostFix) => { - if (preferredTypes?.[typeNodeName + checkPostFix] !== undefined) { - typeName += checkPostFix; - - return true; - } - - return false; - }); - } - - if ( - !isGenericMatch && property && - /** @type {import('jsdoc-type-pratt-parser').NonRootResult} */ ( - parentNode - ).type === 'JsdocTypeGeneric' - ) { - const checkPostFixes = dot ? [ - '.', '.<>', - ] : [ - brackets === 'angle' ? '<>' : '[]', - ]; - - isGenericMatch = checkPostFixes.some((checkPostFix) => { - if (preferredTypes?.[checkPostFix] !== undefined) { - typeName = checkPostFix; - - return true; - } - - return false; - }); - } - } - - const directNameMatch = preferredTypes?.[typeNodeName] !== undefined && - !Object.values(preferredTypes).includes(typeNodeName); - const unifiedSyntaxParentMatch = property && directNameMatch && unifyParentAndChildTypeChecks; - isGenericMatch = isGenericMatch || Boolean(unifiedSyntaxParentMatch); - - hasMatchingPreferredType = isGenericMatch || - directNameMatch && !property; - - return [ - hasMatchingPreferredType, typeName, isGenericMatch, - ]; - }; - - /** - * Iterates strict types to see if any should be added to `invalidTypes` (and - * the the relevant strict type returned as the new preferred type). - * @param {string} typeNodeName - * @param {string|undefined} preferred - * @param {import('jsdoc-type-pratt-parser').NonRootResult|undefined} parentNode - * @param {(string|false|undefined)[][]} invalidTypes - * @returns {string|undefined} The `preferred` type string, optionally changed - */ - const checkNativeTypes = (typeNodeName, preferred, parentNode, invalidTypes) => { - let changedPreferred = preferred; - for (const strictNativeType of strictNativeTypes) { - if ( - strictNativeType === 'object' && - ( - // This is not set to remap with exact type match (e.g., - // `object: 'Object'`), so can ignore (including if circular) - !preferredTypes?.[typeNodeName] || - // Although present on `preferredTypes` for remapping, this is a - // parent object without a parent match (and not - // `unifyParentAndChildTypeChecks`) and we don't want - // `object<>` given TypeScript issue https://github.com/microsoft/TypeScript/issues/20555 - /** - * @type {import('jsdoc-type-pratt-parser').GenericResult} - */ - ( - parentNode - )?.elements?.length && ( - /** - * @type {import('jsdoc-type-pratt-parser').GenericResult} - */ - ( - parentNode - )?.left?.type === 'JsdocTypeName' && - /** - * @type {import('jsdoc-type-pratt-parser').GenericResult} - */ - (parentNode)?.left?.value === 'Object' - ) - ) - ) { - continue; - } - - if (strictNativeType !== typeNodeName && - strictNativeType.toLowerCase() === typeNodeName.toLowerCase() && - - // Don't report if user has own map for a strict native type - (!preferredTypes || preferredTypes?.[strictNativeType] === undefined) - ) { - changedPreferred = strictNativeType; - invalidTypes.push([ - typeNodeName, changedPreferred, - ]); - break; - } - } - - return changedPreferred; - }; - - /** - * Collect invalid type info. - * @param {string} type - * @param {string} value - * @param {string} tagName - * @param {string} nameInTag - * @param {number} idx - * @param {string|undefined} property - * @param {import('jsdoc-type-pratt-parser').NonRootResult} node - * @param {import('jsdoc-type-pratt-parser').NonRootResult|undefined} parentNode - * @param {(string|false|undefined)[][]} invalidTypes - * @returns {void} - */ - const getInvalidTypes = (type, value, tagName, nameInTag, idx, property, node, parentNode, invalidTypes) => { - let typeNodeName = type === 'JsdocTypeAny' ? '*' : value; - - const [ - hasMatchingPreferredType, - typeName, - isGenericMatch, - ] = getPreferredTypeInfo(type, typeNodeName, parentNode, property); - - let preferred; - let types; - if (hasMatchingPreferredType) { - const preferredSetting = preferredTypes[typeName]; - typeNodeName = typeName === '[]' ? typeName : typeNodeName; - - if (!preferredSetting) { - invalidTypes.push([ - typeNodeName, - ]); - } else if (typeof preferredSetting === 'string') { - preferred = preferredSetting; - invalidTypes.push([ - typeNodeName, preferred, - ]); - } else if (preferredSetting && typeof preferredSetting === 'object') { - const nextItem = preferredSetting.skipRootChecking && jsdocTagsWithPossibleType[idx + 1]; - - if (!nextItem || !nextItem.name.startsWith(`${nameInTag}.`)) { - preferred = preferredSetting.replacement; - invalidTypes.push([ - typeNodeName, - preferred, - preferredSetting.message, - ]); - } - } else { - utils.reportSettings( - 'Invalid `settings.jsdoc.preferredTypes`. Values must be falsy, a string, or an object.', - ); - - return; - } - } else if (Object.entries(structuredTags).some(([ - tag, - { - type: typs, - }, - ]) => { - types = typs; - - return tag === tagName && - Array.isArray(types) && - !types.includes(typeNodeName); - })) { - invalidTypes.push([ - typeNodeName, types, - ]); - } else if (!noDefaults && type === 'JsdocTypeName') { - preferred = checkNativeTypes(typeNodeName, preferred, parentNode, invalidTypes); - } - - // For fixer - if (preferred) { - adjustNames(type, preferred, isGenericMatch, typeNodeName, node, parentNode); - } - }; - - for (const [ - idx, - jsdocTag, - ] of jsdocTagsWithPossibleType.entries()) { - /** @type {(string|false|undefined)[][]} */ - const invalidTypes = []; - let typeAst; - - try { - typeAst = mode === 'permissive' ? tryParse(jsdocTag.type) : parse(jsdocTag.type, mode); - } catch { - continue; - } - - const { - tag: tagName, - name: nameInTag, - } = jsdocTag; - - traverse(typeAst, (node, parentNode, property) => { - const { - type, - value, - } = - /** - * @type {import('jsdoc-type-pratt-parser').NameResult} - */ (node); - if (![ - 'JsdocTypeName', 'JsdocTypeAny', - ].includes(type)) { - return; - } - - getInvalidTypes(type, value, tagName, nameInTag, idx, property, node, parentNode, invalidTypes); - }); - - if (invalidTypes.length) { - const fixedType = stringify(typeAst); - - /** - * @type {import('eslint').Rule.ReportFixer} - */ - const fix = (fixer) => { - return fixer.replaceText( - jsdocNode, - sourceCode.getText(jsdocNode).replace( - `{${jsdocTag.type}}`, - `{${fixedType}}`, - ), - ); - }; - - for (const [ - badType, - preferredType = '', - msg, - ] of invalidTypes) { - const tagValue = jsdocTag.name ? ` "${jsdocTag.name}"` : ''; - if (exemptTagContexts.some(({ - tag, - types, - }) => { - return tag === tagName && - (types === true || types.includes(jsdocTag.type)); - })) { - continue; - } - - report( - msg || - `Invalid JSDoc @${tagName}${tagValue} type "${badType}"` + - (preferredType ? '; ' : '.') + - (preferredType ? `prefer: ${JSON.stringify(preferredType)}.` : ''), - preferredType ? fix : null, - jsdocTag, - msg ? { - tagName, - tagValue, - } : undefined, - ); - } - } - } -}, { - iterateAllJsdocs: true, - meta: { - docs: { - description: 'Reports invalid types.', - url: 'https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/check-types.md#repos-sticky-header', - }, - fixable: 'code', - schema: [ - { - additionalProperties: false, - properties: { - exemptTagContexts: { - items: { - additionalProperties: false, - properties: { - tag: { - type: 'string', - }, - types: { - oneOf: [ - { - type: 'boolean', - }, - { - items: { - type: 'string', - }, - type: 'array', - }, - ], - }, - }, - type: 'object', - }, - type: 'array', - }, - noDefaults: { - type: 'boolean', - }, - unifyParentAndChildTypeChecks: { - type: 'boolean', - }, - }, - type: 'object', - }, - ], - type: 'suggestion', - }, -}); diff --git a/tools/eslint/node_modules/eslint-plugin-jsdoc/src/rules/checkValues.js b/tools/eslint/node_modules/eslint-plugin-jsdoc/src/rules/checkValues.js deleted file mode 100644 index dcb50f6a3c27ed..00000000000000 --- a/tools/eslint/node_modules/eslint-plugin-jsdoc/src/rules/checkValues.js +++ /dev/null @@ -1,249 +0,0 @@ -import { dirname, join } from 'node:path'; -import { fileURLToPath } from 'node:url'; - -import { createSyncFn } from 'synckit'; -import semver from 'semver'; -import spdxExpressionParse from 'spdx-expression-parse'; -import iterateJsdoc from '../iterateJsdoc.js'; - -const __dirname = dirname(fileURLToPath(import.meta.url)); -const pathName = join(__dirname, '../import-worker.mjs'); - -const allowedKinds = new Set([ - 'class', - 'constant', - 'event', - 'external', - 'file', - 'function', - 'member', - 'mixin', - 'module', - 'namespace', - 'typedef', -]); - -export default iterateJsdoc(({ - utils, - report, - context, - settings, -}) => { - const options = context.options[0] || {}; - const { - allowedLicenses = null, - allowedAuthors = null, - numericOnlyVariation = false, - licensePattern = '/([^\n\r]*)/gu', - } = options; - - utils.forEachPreferredTag('version', (jsdocParameter, targetTagName) => { - const version = /** @type {string} */ ( - utils.getTagDescription(jsdocParameter) - ).trim(); - if (!version) { - report( - `Missing JSDoc @${targetTagName} value.`, - null, - jsdocParameter, - ); - } else if (!semver.valid(version)) { - report( - `Invalid JSDoc @${targetTagName}: "${utils.getTagDescription(jsdocParameter)}".`, - null, - jsdocParameter, - ); - } - }); - - utils.forEachPreferredTag('kind', (jsdocParameter, targetTagName) => { - const kind = /** @type {string} */ ( - utils.getTagDescription(jsdocParameter) - ).trim(); - if (!kind) { - report( - `Missing JSDoc @${targetTagName} value.`, - null, - jsdocParameter, - ); - } else if (!allowedKinds.has(kind)) { - report( - `Invalid JSDoc @${targetTagName}: "${utils.getTagDescription(jsdocParameter)}"; ` + - `must be one of: ${[ - ...allowedKinds, - ].join(', ')}.`, - null, - jsdocParameter, - ); - } - }); - - if (numericOnlyVariation) { - utils.forEachPreferredTag('variation', (jsdocParameter, targetTagName) => { - const variation = /** @type {string} */ ( - utils.getTagDescription(jsdocParameter) - ).trim(); - if (!variation) { - report( - `Missing JSDoc @${targetTagName} value.`, - null, - jsdocParameter, - ); - } else if ( - !Number.isInteger(Number(variation)) || - Number(variation) <= 0 - ) { - report( - `Invalid JSDoc @${targetTagName}: "${utils.getTagDescription(jsdocParameter)}".`, - null, - jsdocParameter, - ); - } - }); - } - - utils.forEachPreferredTag('since', (jsdocParameter, targetTagName) => { - const version = /** @type {string} */ ( - utils.getTagDescription(jsdocParameter) - ).trim(); - if (!version) { - report( - `Missing JSDoc @${targetTagName} value.`, - null, - jsdocParameter, - ); - } else if (!semver.valid(version)) { - report( - `Invalid JSDoc @${targetTagName}: "${utils.getTagDescription(jsdocParameter)}".`, - null, - jsdocParameter, - ); - } - }); - utils.forEachPreferredTag('license', (jsdocParameter, targetTagName) => { - const licenseRegex = utils.getRegexFromString(licensePattern, 'g'); - const matches = /** @type {string} */ ( - utils.getTagDescription(jsdocParameter) - ).matchAll(licenseRegex); - let positiveMatch = false; - for (const match of matches) { - const license = match[1] || match[0]; - if (license) { - positiveMatch = true; - } - - if (!license.trim()) { - // Avoid reporting again as empty match - if (positiveMatch) { - return; - } - - report( - `Missing JSDoc @${targetTagName} value.`, - null, - jsdocParameter, - ); - } else if (allowedLicenses) { - if (allowedLicenses !== true && !allowedLicenses.includes(license)) { - report( - `Invalid JSDoc @${targetTagName}: "${license}"; expected one of ${allowedLicenses.join(', ')}.`, - null, - jsdocParameter, - ); - } - } else { - try { - spdxExpressionParse(license); - } catch { - report( - `Invalid JSDoc @${targetTagName}: "${license}"; expected SPDX expression: https://spdx.org/licenses/.`, - null, - jsdocParameter, - ); - } - } - } - }); - - if (settings.mode === 'typescript') { - utils.forEachPreferredTag('import', (tag) => { - const { - type, name, description - } = tag; - const typePart = type ? `{${type}} `: ''; - const imprt = 'import ' + (description - ? `${typePart}${name} ${description}` - : `${typePart}${name}`); - - const getImports = createSyncFn(pathName); - if (!getImports(imprt)) { - report( - `Bad @import tag`, - null, - tag, - ); - } - }); - } - - utils.forEachPreferredTag('author', (jsdocParameter, targetTagName) => { - const author = /** @type {string} */ ( - utils.getTagDescription(jsdocParameter) - ).trim(); - if (!author) { - report( - `Missing JSDoc @${targetTagName} value.`, - null, - jsdocParameter, - ); - } else if (allowedAuthors && !allowedAuthors.includes(author)) { - report( - `Invalid JSDoc @${targetTagName}: "${utils.getTagDescription(jsdocParameter)}"; expected one of ${allowedAuthors.join(', ')}.`, - null, - jsdocParameter, - ); - } - }); -}, { - iterateAllJsdocs: true, - meta: { - docs: { - description: 'This rule checks the values for a handful of tags: `@version`, `@since`, `@license` and `@author`.', - url: 'https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/check-values.md#repos-sticky-header', - }, - schema: [ - { - additionalProperties: false, - properties: { - allowedAuthors: { - items: { - type: 'string', - }, - type: 'array', - }, - allowedLicenses: { - anyOf: [ - { - items: { - type: 'string', - }, - type: 'array', - }, - { - type: 'boolean', - }, - ], - }, - licensePattern: { - type: 'string', - }, - numericOnlyVariation: { - type: 'boolean', - }, - }, - type: 'object', - }, - ], - type: 'suggestion', - }, -}); diff --git a/tools/eslint/node_modules/eslint-plugin-jsdoc/src/rules/convertToJsdocComments.js b/tools/eslint/node_modules/eslint-plugin-jsdoc/src/rules/convertToJsdocComments.js deleted file mode 100644 index 81f15b4da021a9..00000000000000 --- a/tools/eslint/node_modules/eslint-plugin-jsdoc/src/rules/convertToJsdocComments.js +++ /dev/null @@ -1,384 +0,0 @@ -import iterateJsdoc from '../iterateJsdoc.js'; -import { - getSettings, -} from '../iterateJsdoc.js'; -import jsdocUtils from '../jsdocUtils.js'; -import { - getNonJsdocComment, - getDecorator, - getReducedASTNode, - getFollowingComment, -} from '@es-joy/jsdoccomment'; - -/** @type {import('eslint').Rule.RuleModule} */ -export default { - create (context) { - /** - * @typedef {import('eslint').AST.Token | import('estree').Comment | { - * type: import('eslint').AST.TokenType|"Line"|"Block"|"Shebang", - * range: [number, number], - * value: string - * }} Token - */ - - /** - * @callback AddComment - * @param {boolean|undefined} inlineCommentBlock - * @param {Token} comment - * @param {string} indent - * @param {number} lines - * @param {import('eslint').Rule.RuleFixer} fixer - */ - - /* c8 ignore next -- Fallback to deprecated method */ - const { - sourceCode = context.getSourceCode(), - } = context; - const settings = getSettings(context); - if (!settings) { - return {}; - } - - const { - contexts = settings.contexts || [], - contextsAfter = /** @type {string[]} */ ([]), - contextsBeforeAndAfter = [ - 'VariableDeclarator', 'TSPropertySignature', 'PropertyDefinition' - ], - enableFixer = true, - enforceJsdocLineStyle = 'multi', - lineOrBlockStyle = 'both', - allowedPrefixes = ['@ts-', 'istanbul ', 'c8 ', 'v8 ', 'eslint', 'prettier-'] - } = context.options[0] ?? {}; - - let reportingNonJsdoc = false; - - /** - * @param {string} messageId - * @param {import('estree').Comment|Token} comment - * @param {import('eslint').Rule.Node} node - * @param {import('eslint').Rule.ReportFixer} fixer - */ - const report = (messageId, comment, node, fixer) => { - const loc = { - end: { - column: 0, - /* c8 ignore next 2 -- Guard */ - // @ts-expect-error Ok - line: (comment.loc?.start?.line ?? 1), - }, - start: { - column: 0, - /* c8 ignore next 2 -- Guard */ - // @ts-expect-error Ok - line: (comment.loc?.start?.line ?? 1) - }, - }; - - context.report({ - fix: enableFixer ? fixer : null, - loc, - messageId, - node, - }); - }; - - /** - * @param {import('eslint').Rule.Node} node - * @param {import('eslint').AST.Token | import('estree').Comment | { - * type: import('eslint').AST.TokenType|"Line"|"Block"|"Shebang", - * range: [number, number], - * value: string - * }} comment - * @param {AddComment} addComment - * @param {import('../iterateJsdoc.js').Context[]} ctxts - */ - const getFixer = (node, comment, addComment, ctxts) => { - return /** @type {import('eslint').Rule.ReportFixer} */ (fixer) => { - // Default to one line break if the `minLines`/`maxLines` settings allow - const lines = settings.minLines === 0 && settings.maxLines >= 1 ? 1 : settings.minLines; - let baseNode = - /** - * @type {import('@typescript-eslint/types').TSESTree.Node|import('eslint').Rule.Node} - */ ( - getReducedASTNode(node, sourceCode) - ); - - const decorator = getDecorator( - /** @type {import('eslint').Rule.Node} */ - (baseNode) - ); - if (decorator) { - baseNode = /** @type {import('@typescript-eslint/types').TSESTree.Decorator} */ ( - decorator - ); - } - - const indent = jsdocUtils.getIndent({ - text: sourceCode.getText( - /** @type {import('eslint').Rule.Node} */ (baseNode), - /** @type {import('eslint').AST.SourceLocation} */ - ( - /** @type {import('eslint').Rule.Node} */ (baseNode).loc - ).start.column, - ), - }); - - const { - inlineCommentBlock, - } = - /** - * @type {{ - * context: string, - * inlineCommentBlock: boolean, - * minLineCount: import('../iterateJsdoc.js').Integer - * }[]} - */ (ctxts).find((contxt) => { - if (typeof contxt === 'string') { - return false; - } - - const { - context: ctxt, - } = contxt; - return ctxt === node.type; - }) || {}; - - return addComment(inlineCommentBlock, comment, indent, lines, fixer); - }; - }; - - /** - * @param {import('eslint').AST.Token | import('estree').Comment | { - * type: import('eslint').AST.TokenType|"Line"|"Block"|"Shebang", - * range: [number, number], - * value: string - * }} comment - * @param {import('eslint').Rule.Node} node - * @param {AddComment} addComment - * @param {import('../iterateJsdoc.js').Context[]} ctxts - */ - const reportings = (comment, node, addComment, ctxts) => { - const fixer = getFixer(node, comment, addComment, ctxts); - - if (comment.type === 'Block') { - if (lineOrBlockStyle === 'line') { - return; - } - report('blockCommentsJsdocStyle', comment, node, fixer); - return; - } - - if (comment.type === 'Line') { - if (lineOrBlockStyle === 'block') { - return; - } - report('lineCommentsJsdocStyle', comment, node, fixer); - } - }; - - /** - * @type {import('../iterateJsdoc.js').CheckJsdoc} - */ - const checkNonJsdoc = (_info, _handler, node) => { - const comment = getNonJsdocComment(sourceCode, node, settings); - - if ( - !comment || - /** @type {string[]} */ - (allowedPrefixes).some((prefix) => { - return comment.value.trimStart().startsWith(prefix); - }) - ) { - return; - } - - reportingNonJsdoc = true; - - /** @type {AddComment} */ - const addComment = (inlineCommentBlock, comment, indent, lines, fixer) => { - const insertion = ( - inlineCommentBlock || enforceJsdocLineStyle === 'single' - ? `/** ${comment.value.trim()} ` - : `/**\n${indent}*${comment.value.trimEnd()}\n${indent}` - ) + - `*/${'\n'.repeat((lines || 1) - 1)}`; - - return fixer.replaceText( - /** @type {import('eslint').AST.Token} */ - (comment), - insertion, - ); - }; - - reportings(comment, node, addComment, contexts); - }; - - /** - * @param {import('eslint').Rule.Node} node - * @param {import('../iterateJsdoc.js').Context[]} ctxts - */ - const checkNonJsdocAfter = (node, ctxts) => { - const comment = getFollowingComment(sourceCode, node); - - if ( - !comment || - comment.value.startsWith('*') || - /** @type {string[]} */ - (allowedPrefixes).some((prefix) => { - return comment.value.trimStart().startsWith(prefix); - }) - ) { - return; - } - - /** @type {AddComment} */ - const addComment = (inlineCommentBlock, comment, indent, lines, fixer) => { - const insertion = ( - inlineCommentBlock || enforceJsdocLineStyle === 'single' - ? `/** ${comment.value.trim()} ` - : `/**\n${indent}*${comment.value.trimEnd()}\n${indent}` - ) + - `*/${'\n'.repeat((lines || 1) - 1)}${lines ? `\n${indent.slice(1)}` : ' '}`; - - return [fixer.remove( - /** @type {import('eslint').AST.Token} */ - (comment) - ), fixer.insertTextBefore( - node.type === 'VariableDeclarator' ? node.parent : node, - insertion, - )]; - }; - - reportings(comment, node, addComment, ctxts); - }; - - // Todo: add contexts to check after (and handle if want both before and after) - return { - ...jsdocUtils.getContextObject( - jsdocUtils.enforcedContexts(context, true, settings), - checkNonJsdoc, - ), - ...jsdocUtils.getContextObject( - contextsAfter, - (_info, _handler, node) => { - checkNonJsdocAfter(node, contextsAfter); - }, - ), - ...jsdocUtils.getContextObject( - contextsBeforeAndAfter, - (_info, _handler, node) => { - checkNonJsdoc({}, null, node); - if (!reportingNonJsdoc) { - checkNonJsdocAfter(node, contextsBeforeAndAfter); - } - } - ) - }; - }, - meta: { - fixable: 'code', - - messages: { - blockCommentsJsdocStyle: 'Block comments should be JSDoc-style.', - lineCommentsJsdocStyle: 'Line comments should be JSDoc-style.', - }, - - docs: { - description: 'Converts non-JSDoc comments preceding or following nodes into JSDoc ones', - url: 'https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/convert-to-jsdoc-comments.md#repos-sticky-header', - }, - schema: [ - { - additionalProperties: false, - properties: { - allowedPrefixes: { - type: 'array', - items: { - type: 'string' - } - }, - contexts: { - items: { - anyOf: [ - { - type: 'string', - }, - { - additionalProperties: false, - properties: { - context: { - type: 'string', - }, - inlineCommentBlock: { - type: 'boolean', - }, - }, - type: 'object', - }, - ], - }, - type: 'array', - }, - contextsAfter: { - items: { - anyOf: [ - { - type: 'string', - }, - { - additionalProperties: false, - properties: { - context: { - type: 'string', - }, - inlineCommentBlock: { - type: 'boolean', - }, - }, - type: 'object', - }, - ], - }, - type: 'array', - }, - contextsBeforeAndAfter: { - items: { - anyOf: [ - { - type: 'string', - }, - { - additionalProperties: false, - properties: { - context: { - type: 'string', - }, - inlineCommentBlock: { - type: 'boolean', - }, - }, - type: 'object', - }, - ], - }, - type: 'array', - }, - enableFixer: { - type: 'boolean' - }, - enforceJsdocLineStyle: { - type: 'string', - enum: ['multi', 'single'] - }, - lineOrBlockStyle: { - type: 'string', - enum: ['block', 'line', 'both'] - }, - }, - type: 'object', - }, - ], - type: 'suggestion', - }, -}; diff --git a/tools/eslint/node_modules/eslint-plugin-jsdoc/src/rules/emptyTags.js b/tools/eslint/node_modules/eslint-plugin-jsdoc/src/rules/emptyTags.js deleted file mode 100644 index 38b4aa9bf42e1e..00000000000000 --- a/tools/eslint/node_modules/eslint-plugin-jsdoc/src/rules/emptyTags.js +++ /dev/null @@ -1,88 +0,0 @@ -import iterateJsdoc from '../iterateJsdoc.js'; - -const defaultEmptyTags = new Set([ - 'abstract', 'async', 'generator', 'global', 'hideconstructor', - 'ignore', 'inner', 'instance', 'override', 'readonly', - - // jsdoc doesn't use this form in its docs, but allow for compatibility with - // TypeScript which allows and Closure which requires - 'inheritDoc', - - // jsdoc doesn't use but allow for TypeScript - 'internal', - 'overload', -]); - -const emptyIfNotClosure = new Set([ - 'package', 'private', 'protected', 'public', 'static', - - // Closure doesn't allow with this casing - 'inheritdoc', -]); - -const emptyIfClosure = new Set([ - 'interface', -]); - -export default iterateJsdoc(({ - settings, - jsdoc, - utils, -}) => { - const emptyTags = utils.filterTags(({ - tag: tagName, - }) => { - return defaultEmptyTags.has(tagName) || - utils.hasOptionTag(tagName) && jsdoc.tags.some(({ - tag, - }) => { - return tag === tagName; - }) || - settings.mode === 'closure' && emptyIfClosure.has(tagName) || - settings.mode !== 'closure' && emptyIfNotClosure.has(tagName); - }); - - for (const tag of emptyTags) { - const content = tag.name || tag.description || tag.type; - if (content.trim()) { - const fix = () => { - // By time of call in fixer, `tag` will have `line` added - utils.setTag( - /** - * @type {import('comment-parser').Spec & { - * line: import('../iterateJsdoc.js').Integer - * }} - */ (tag), - ); - }; - - utils.reportJSDoc(`@${tag.tag} should be empty.`, tag, fix, true); - } - } -}, { - checkInternal: true, - checkPrivate: true, - iterateAllJsdocs: true, - meta: { - docs: { - description: 'Expects specific tags to be empty of any content.', - url: 'https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/empty-tags.md#repos-sticky-header', - }, - fixable: 'code', - schema: [ - { - additionalProperties: false, - properties: { - tags: { - items: { - type: 'string', - }, - type: 'array', - }, - }, - type: 'object', - }, - ], - type: 'suggestion', - }, -}); diff --git a/tools/eslint/node_modules/eslint-plugin-jsdoc/src/rules/implementsOnClasses.js b/tools/eslint/node_modules/eslint-plugin-jsdoc/src/rules/implementsOnClasses.js deleted file mode 100644 index 4a3709a285364b..00000000000000 --- a/tools/eslint/node_modules/eslint-plugin-jsdoc/src/rules/implementsOnClasses.js +++ /dev/null @@ -1,64 +0,0 @@ -import iterateJsdoc from '../iterateJsdoc.js'; - -export default iterateJsdoc(({ - report, - utils, -}) => { - const iteratingFunction = utils.isIteratingFunction(); - - if (iteratingFunction) { - if (utils.hasATag([ - 'class', - 'constructor', - ]) || - utils.isConstructor() - ) { - return; - } - } else if (!utils.isVirtualFunction()) { - return; - } - - utils.forEachPreferredTag('implements', (tag) => { - report('@implements used on a non-constructor function', null, tag); - }); -}, { - contextDefaults: true, - meta: { - docs: { - description: 'Reports an issue with any non-constructor function using `@implements`.', - url: 'https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/implements-on-classes.md#repos-sticky-header', - }, - schema: [ - { - additionalProperties: false, - properties: { - contexts: { - items: { - anyOf: [ - { - type: 'string', - }, - { - additionalProperties: false, - properties: { - comment: { - type: 'string', - }, - context: { - type: 'string', - }, - }, - type: 'object', - }, - ], - }, - type: 'array', - }, - }, - type: 'object', - }, - ], - type: 'suggestion', - }, -}); diff --git a/tools/eslint/node_modules/eslint-plugin-jsdoc/src/rules/importsAsDependencies.js b/tools/eslint/node_modules/eslint-plugin-jsdoc/src/rules/importsAsDependencies.js deleted file mode 100644 index d21a4a37845660..00000000000000 --- a/tools/eslint/node_modules/eslint-plugin-jsdoc/src/rules/importsAsDependencies.js +++ /dev/null @@ -1,131 +0,0 @@ -import iterateJsdoc from '../iterateJsdoc.js'; -import { - parse, - traverse, - tryParse, -} from '@es-joy/jsdoccomment'; -import { - readFileSync, -} from 'fs'; -import {isBuiltin as isBuiltinModule} from 'node:module'; -import { - join, -} from 'path'; - -/** - * @type {Set|null} - */ -let deps; - -const setDeps = function () { - try { - const pkg = JSON.parse( - // @ts-expect-error It's ok - readFileSync(join(process.cwd(), './package.json')), - ); - deps = new Set([ - ...(pkg.dependencies ? - /* c8 ignore next 2 */ - Object.keys(pkg.dependencies) : - []), - ...(pkg.devDependencies ? - /* c8 ignore next 2 */ - Object.keys(pkg.devDependencies) : - []), - ]); - /* c8 ignore next -- our package.json exists */ - } catch (error) { - /* c8 ignore next -- our package.json exists */ - deps = null; - /* c8 ignore next 4 -- our package.json exists */ - /* eslint-disable no-console -- Inform user */ - console.log(error); - /* eslint-enable no-console -- Inform user */ - } -}; - -const moduleCheck = new Map(); - -export default iterateJsdoc(({ - jsdoc, - settings, - utils, -}) => { - if (deps === undefined) { - setDeps(); - } - - /* c8 ignore next 3 -- our package.json exists */ - if (deps === null) { - return; - } - - const { - mode, - } = settings; - - for (const tag of jsdoc.tags) { - let typeAst; - try { - typeAst = mode === 'permissive' ? tryParse(tag.type) : parse(tag.type, mode); - } catch { - continue; - } - - // eslint-disable-next-line no-loop-func -- Safe - traverse(typeAst, (nde) => { - /* c8 ignore next 3 -- TS guard */ - if (deps === null) { - return; - } - - if (nde.type === 'JsdocTypeImport') { - let mod = nde.element.value.replace( - /^(@[^/]+\/[^/]+|[^/]+).*$/u, '$1', - ); - - if ((/^[./]/u).test(mod)) { - return; - } - - if (isBuiltinModule(mod)) { - // mod = '@types/node'; - // moduleCheck.set(mod, !deps.has(mod)); - return; - } else if (!moduleCheck.has(mod)) { - let pkg; - try { - pkg = JSON.parse( - // @ts-expect-error It's ok - readFileSync(join(process.cwd(), 'node_modules', mod, './package.json')), - ); - } catch { - // Ignore - } - - if (!pkg || (!pkg.types && !pkg.typings)) { - mod = `@types/${mod}`; - } - - moduleCheck.set(mod, !deps.has(mod)); - } - - if (moduleCheck.get(mod)) { - utils.reportJSDoc( - 'import points to package which is not found in dependencies', - tag, - ); - } - } - }); - } -}, { - iterateAllJsdocs: true, - meta: { - docs: { - description: 'Reports if JSDoc `import()` statements point to a package which is not listed in `dependencies` or `devDependencies`', - url: 'https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/imports-as-dependencies.md#repos-sticky-header', - }, - type: 'suggestion', - }, -}); diff --git a/tools/eslint/node_modules/eslint-plugin-jsdoc/src/rules/informativeDocs.js b/tools/eslint/node_modules/eslint-plugin-jsdoc/src/rules/informativeDocs.js deleted file mode 100644 index 7ccbff88a6cae2..00000000000000 --- a/tools/eslint/node_modules/eslint-plugin-jsdoc/src/rules/informativeDocs.js +++ /dev/null @@ -1,189 +0,0 @@ -import iterateJsdoc from '../iterateJsdoc.js'; -import { - areDocsInformative, -} from 'are-docs-informative'; - -const defaultAliases = { - a: [ - 'an', 'our', - ], -}; - -const defaultUselessWords = [ - 'a', 'an', 'i', 'in', 'of', 's', 'the', -]; - -/* eslint-disable complexity -- Temporary */ - -/** - * @param {import('eslint').Rule.Node|import('@typescript-eslint/types').TSESTree.Node|null|undefined} node - * @returns {string[]} - */ -const getNamesFromNode = (node) => { - switch (node?.type) { - case 'AccessorProperty': - case 'MethodDefinition': - case 'PropertyDefinition': - case 'TSAbstractAccessorProperty': - case 'TSAbstractMethodDefinition': - case 'TSAbstractPropertyDefinition': - return [ - ...getNamesFromNode( - /** @type {import('@typescript-eslint/types').TSESTree.Node} */ ( - node.parent - ).parent, - ), - ...getNamesFromNode( - /** @type {import('@typescript-eslint/types').TSESTree.Node} */ - (node.key), - ), - ]; - - case 'ExportDefaultDeclaration': - case 'ExportNamedDeclaration': - return getNamesFromNode( - /** @type {import('@typescript-eslint/types').TSESTree.ExportNamedDeclaration} */ - (node).declaration - ); - case 'ClassDeclaration': - case 'ClassExpression': - case 'FunctionDeclaration': - case 'FunctionExpression': - case 'TSModuleDeclaration': - case 'TSMethodSignature': - case 'TSDeclareFunction': - case 'TSEnumDeclaration': - case 'TSEnumMember': - case 'TSInterfaceDeclaration': - case 'TSTypeAliasDeclaration': - return getNamesFromNode( - /** @type {import('@typescript-eslint/types').TSESTree.ClassDeclaration} */ - (node).id, - ); - case 'Identifier': - return [ - node.name, - ]; - case 'Property': - return getNamesFromNode( - /** @type {import('@typescript-eslint/types').TSESTree.Node} */ - (node.key), - ); - case 'VariableDeclaration': - return getNamesFromNode( - /** @type {import('@typescript-eslint/types').TSESTree.Node} */ - (node.declarations[0]), - ); - case 'VariableDeclarator': - return [ - ...getNamesFromNode( - /** @type {import('@typescript-eslint/types').TSESTree.Node} */ - (node.id), - ), - ...getNamesFromNode( - /** @type {import('@typescript-eslint/types').TSESTree.Node} */ - (node.init), - ), - ].filter(Boolean); - default: - return []; - } -}; -/* eslint-enable complexity -- Temporary */ - -export default iterateJsdoc(({ - context, - jsdoc, - node, - report, - utils, -}) => { - const /** @type {{aliases: {[key: string]: string[]}, excludedTags: string[], uselessWords: string[]}} */ { - aliases = defaultAliases, - excludedTags = [], - uselessWords = defaultUselessWords, - } = context.options[0] || {}; - const nodeNames = getNamesFromNode(node); - - /** - * @param {string} text - * @param {string} extraName - * @returns {boolean} - */ - const descriptionIsRedundant = (text, extraName = '') => { - const textTrimmed = text.trim(); - return Boolean(textTrimmed) && !areDocsInformative(textTrimmed, [ - extraName, nodeNames, - ].filter(Boolean).join(' '), { - aliases, - uselessWords, - }); - }; - - const { - description, - lastDescriptionLine, - } = utils.getDescription(); - let descriptionReported = false; - - for (const tag of jsdoc.tags) { - if (excludedTags.includes(tag.tag)) { - continue; - } - - if (descriptionIsRedundant(tag.description, tag.name)) { - utils.reportJSDoc( - 'This tag description only repeats the name it describes.', - tag, - ); - } - - descriptionReported ||= tag.description === description && - /** @type {import('comment-parser').Spec & {line: import('../iterateJsdoc.js').Integer}} */ - (tag).line === lastDescriptionLine; - } - - if (!descriptionReported && descriptionIsRedundant(description)) { - report('This description only repeats the name it describes.'); - } -}, { - iterateAllJsdocs: true, - meta: { - docs: { - description: - 'This rule reports doc comments that only restate their attached name.', - url: 'https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/informative-docs.md#repos-sticky-header', - }, - schema: [ - { - additionalProperties: false, - properties: { - aliases: { - patternProperties: { - '.*': { - items: { - type: 'string', - }, - type: 'array', - }, - }, - }, - excludedTags: { - items: { - type: 'string', - }, - type: 'array', - }, - uselessWords: { - items: { - type: 'string', - }, - type: 'array', - }, - }, - type: 'object', - }, - ], - type: 'suggestion', - }, -}); diff --git a/tools/eslint/node_modules/eslint-plugin-jsdoc/src/rules/matchDescription.js b/tools/eslint/node_modules/eslint-plugin-jsdoc/src/rules/matchDescription.js deleted file mode 100644 index 2b95adbca22e4b..00000000000000 --- a/tools/eslint/node_modules/eslint-plugin-jsdoc/src/rules/matchDescription.js +++ /dev/null @@ -1,286 +0,0 @@ -import iterateJsdoc from '../iterateJsdoc.js'; - -// If supporting Node >= 10, we could loosen the default to this for the -// initial letter: \\p{Upper} -const matchDescriptionDefault = '^\n?([A-Z`\\d_][\\s\\S]*[.?!`]\\s*)?$'; - -/** - * @param {string} value - * @param {string} userDefault - * @returns {string} - */ -const stringOrDefault = (value, userDefault) => { - return typeof value === 'string' ? - value : - userDefault || matchDescriptionDefault; -}; - -export default iterateJsdoc(({ - jsdoc, - report, - context, - utils, -}) => { - const { - mainDescription, - matchDescription, - message, - nonemptyTags = true, - tags = {}, - } = context.options[0] || {}; - - /** - * @param {string} desc - * @param {import('comment-parser').Spec} [tag] - * @returns {void} - */ - const validateDescription = (desc, tag) => { - let mainDescriptionMatch = mainDescription; - let errorMessage = message; - if (typeof mainDescription === 'object') { - mainDescriptionMatch = mainDescription.match; - errorMessage = mainDescription.message; - } - - if (mainDescriptionMatch === false && ( - !tag || !Object.prototype.hasOwnProperty.call(tags, tag.tag)) - ) { - return; - } - - let tagValue = mainDescriptionMatch; - if (tag) { - const tagName = tag.tag; - if (typeof tags[tagName] === 'object') { - tagValue = tags[tagName].match; - errorMessage = tags[tagName].message; - } else { - tagValue = tags[tagName]; - } - } - - const regex = utils.getRegexFromString( - stringOrDefault(tagValue, matchDescription), - ); - - if (!regex.test(desc)) { - report( - errorMessage || 'JSDoc description does not satisfy the regex pattern.', - null, - tag || { - // Add one as description would typically be into block - line: jsdoc.source[0].number + 1, - }, - ); - } - }; - - const { - description, - } = utils.getDescription(); - if (description) { - validateDescription(description); - } - - /** - * @param {string} tagName - * @returns {boolean} - */ - const hasNoTag = (tagName) => { - return !tags[tagName]; - }; - - for (const tag of [ - 'description', - 'summary', - 'file', - 'classdesc', - ]) { - utils.forEachPreferredTag(tag, (matchingJsdocTag, targetTagName) => { - const desc = (matchingJsdocTag.name + ' ' + utils.getTagDescription(matchingJsdocTag)).trim(); - if (hasNoTag(targetTagName)) { - validateDescription(desc, matchingJsdocTag); - } - }, true); - } - - if (nonemptyTags) { - for (const tag of [ - 'copyright', - 'example', - 'see', - 'todo', - ]) { - utils.forEachPreferredTag(tag, (matchingJsdocTag, targetTagName) => { - const desc = (matchingJsdocTag.name + ' ' + utils.getTagDescription(matchingJsdocTag)).trim(); - - if (hasNoTag(targetTagName) && !(/.+/u).test(desc)) { - report( - 'JSDoc description must not be empty.', - null, - matchingJsdocTag, - ); - } - }); - } - } - - if (!Object.keys(tags).length) { - return; - } - - /** - * @param {string} tagName - * @returns {boolean} - */ - const hasOptionTag = (tagName) => { - return Boolean(tags[tagName]); - }; - - const whitelistedTags = utils.filterTags(({ - tag: tagName, - }) => { - return hasOptionTag(tagName); - }); - const { - tagsWithNames, - tagsWithoutNames, - } = utils.getTagsByType(whitelistedTags); - - tagsWithNames.some((tag) => { - const desc = /** @type {string} */ ( - utils.getTagDescription(tag) - ).replace(/^[- ]*/u, '') - .trim(); - - return validateDescription(desc, tag); - }); - - tagsWithoutNames.some((tag) => { - const desc = (tag.name + ' ' + utils.getTagDescription(tag)).trim(); - - return validateDescription(desc, tag); - }); -}, { - contextDefaults: true, - meta: { - docs: { - description: 'Enforces a regular expression pattern on descriptions.', - url: 'https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/match-description.md#repos-sticky-header', - }, - schema: [ - { - additionalProperties: false, - properties: { - contexts: { - items: { - anyOf: [ - { - type: 'string', - }, - { - additionalProperties: false, - properties: { - comment: { - type: 'string', - }, - context: { - type: 'string', - }, - }, - type: 'object', - }, - ], - }, - type: 'array', - }, - mainDescription: { - oneOf: [ - { - format: 'regex', - type: 'string', - }, - { - type: 'boolean', - }, - { - additionalProperties: false, - properties: { - match: { - oneOf: [ - { - format: 'regex', - type: 'string', - }, - { - type: 'boolean', - }, - ], - }, - message: { - type: 'string', - }, - }, - type: 'object', - }, - ], - }, - matchDescription: { - format: 'regex', - type: 'string', - }, - message: { - type: 'string', - }, - nonemptyTags: { - type: 'boolean', - }, - tags: { - patternProperties: { - '.*': { - oneOf: [ - { - format: 'regex', - type: 'string', - }, - { - enum: [ - true, - ], - type: 'boolean', - }, - { - additionalProperties: false, - properties: { - match: { - oneOf: [ - { - format: 'regex', - type: 'string', - }, - { - enum: [ - true, - ], - type: 'boolean', - }, - ], - }, - message: { - type: 'string', - }, - }, - type: 'object', - }, - ], - }, - }, - type: 'object', - }, - }, - type: 'object', - }, - ], - type: 'suggestion', - }, -}); diff --git a/tools/eslint/node_modules/eslint-plugin-jsdoc/src/rules/matchName.js b/tools/eslint/node_modules/eslint-plugin-jsdoc/src/rules/matchName.js deleted file mode 100644 index 66d7896114f8b5..00000000000000 --- a/tools/eslint/node_modules/eslint-plugin-jsdoc/src/rules/matchName.js +++ /dev/null @@ -1,147 +0,0 @@ -import iterateJsdoc from '../iterateJsdoc.js'; - -// eslint-disable-next-line complexity -export default iterateJsdoc(({ - context, - jsdoc, - report, - info: { - lastIndex, - }, - utils, -}) => { - const { - match, - } = context.options[0] || {}; - if (!match) { - report('Rule `no-restricted-syntax` is missing a `match` option.'); - - return; - } - - const { - allowName, - disallowName, - replacement, - tags = [ - '*', - ], - } = match[/** @type {import('../iterateJsdoc.js').Integer} */ (lastIndex)]; - - const allowNameRegex = allowName && utils.getRegexFromString(allowName); - const disallowNameRegex = disallowName && utils.getRegexFromString(disallowName); - - let applicableTags = jsdoc.tags; - if (!tags.includes('*')) { - applicableTags = utils.getPresentTags(tags); - } - - let reported = false; - for (const tag of applicableTags) { - const allowed = !allowNameRegex || allowNameRegex.test(tag.name); - const disallowed = disallowNameRegex && disallowNameRegex.test(tag.name); - const hasRegex = allowNameRegex || disallowNameRegex; - if (hasRegex && allowed && !disallowed) { - continue; - } - - if (!hasRegex && reported) { - continue; - } - - const fixer = () => { - for (const src of tag.source) { - if (src.tokens.name) { - src.tokens.name = src.tokens.name.replace( - disallowNameRegex, replacement, - ); - break; - } - } - }; - - let { - message, - } = match[/** @type {import('../iterateJsdoc.js').Integer} */ (lastIndex)]; - if (!message) { - if (hasRegex) { - message = disallowed ? - `Only allowing names not matching \`${disallowNameRegex}\` but found "${tag.name}".` : - `Only allowing names matching \`${allowNameRegex}\` but found "${tag.name}".`; - } else { - message = `Prohibited context for "${tag.name}".`; - } - } - - utils.reportJSDoc( - message, - hasRegex ? tag : null, - - // We could match up - disallowNameRegex && replacement !== undefined ? - fixer : - null, - false, - { - // Could also supply `context`, `comment`, `tags` - allowName, - disallowName, - name: tag.name, - }, - ); - if (!hasRegex) { - reported = true; - } - } -}, { - matchContext: true, - meta: { - docs: { - description: 'Reports the name portion of a JSDoc tag if matching or not matching a given regular expression.', - url: 'https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/match-name.md#repos-sticky-header', - }, - fixable: 'code', - schema: [ - { - additionalProperties: false, - properties: { - match: { - additionalProperties: false, - items: { - properties: { - allowName: { - type: 'string', - }, - comment: { - type: 'string', - }, - context: { - type: 'string', - }, - disallowName: { - type: 'string', - }, - message: { - type: 'string', - }, - tags: { - items: { - type: 'string', - }, - type: 'array', - }, - }, - type: 'object', - }, - type: 'array', - }, - }, - required: [ - 'match', - ], - type: 'object', - }, - ], - type: 'suggestion', - }, -}); diff --git a/tools/eslint/node_modules/eslint-plugin-jsdoc/src/rules/multilineBlocks.js b/tools/eslint/node_modules/eslint-plugin-jsdoc/src/rules/multilineBlocks.js deleted file mode 100644 index 2bd0ff6c855cd5..00000000000000 --- a/tools/eslint/node_modules/eslint-plugin-jsdoc/src/rules/multilineBlocks.js +++ /dev/null @@ -1,333 +0,0 @@ -import iterateJsdoc from '../iterateJsdoc.js'; - -export default iterateJsdoc(({ - context, - jsdoc, - utils, -}) => { - const { - allowMultipleTags = true, - noFinalLineText = true, - noZeroLineText = true, - noSingleLineBlocks = false, - singleLineTags = [ - 'lends', 'type', - ], - noMultilineBlocks = false, - minimumLengthForMultiline = Number.POSITIVE_INFINITY, - multilineTags = [ - '*', - ], - } = context.options[0] || {}; - - const { - source: [ - { - tokens, - }, - ], - } = jsdoc; - const { - description, - tag, - } = tokens; - const sourceLength = jsdoc.source.length; - - /** - * @param {string} tagName - * @returns {boolean} - */ - const isInvalidSingleLine = (tagName) => { - return noSingleLineBlocks && - (!tagName || - !singleLineTags.includes(tagName) && !singleLineTags.includes('*')); - }; - - if (sourceLength === 1) { - if (!isInvalidSingleLine(tag.slice(1))) { - return; - } - - const fixer = () => { - utils.makeMultiline(); - }; - - utils.reportJSDoc( - 'Single line blocks are not permitted by your configuration.', - null, - fixer, - true, - ); - - return; - } - - const lineChecks = () => { - if ( - noZeroLineText && - (tag || description) - ) { - const fixer = () => { - const line = { - ...tokens, - }; - utils.emptyTokens(tokens); - const { - tokens: { - delimiter, - start, - }, - } = jsdoc.source[1]; - utils.addLine(1, { - ...line, - delimiter, - start, - }); - }; - - utils.reportJSDoc( - 'Should have no text on the "0th" line (after the `/**`).', - null, - fixer, - ); - - return; - } - - const finalLine = jsdoc.source[jsdoc.source.length - 1]; - const finalLineTokens = finalLine.tokens; - if ( - noFinalLineText && - finalLineTokens.description.trim() - ) { - const fixer = () => { - const line = { - ...finalLineTokens, - }; - line.description = line.description.trimEnd(); - - const { - delimiter, - } = line; - - for (const prop of [ - 'delimiter', - 'postDelimiter', - 'tag', - 'type', - 'lineEnd', - 'postType', - 'postTag', - 'name', - 'postName', - 'description', - ]) { - finalLineTokens[ - /** - * @type {"delimiter"|"postDelimiter"|"tag"|"type"| - * "lineEnd"|"postType"|"postTag"|"name"| - * "postName"|"description"} - */ ( - prop - ) - ] = ''; - } - - utils.addLine(jsdoc.source.length - 1, { - ...line, - delimiter, - end: '', - }); - }; - - utils.reportJSDoc( - 'Should have no text on the final line (before the `*/`).', - null, - fixer, - ); - } - }; - - if (noMultilineBlocks) { - if ( - jsdoc.tags.length && - (multilineTags.includes('*') || utils.hasATag(multilineTags)) - ) { - lineChecks(); - - return; - } - - if (jsdoc.description.length >= minimumLengthForMultiline) { - lineChecks(); - - return; - } - - if ( - noSingleLineBlocks && - (!jsdoc.tags.length || - !utils.filterTags(({ - tag: tg, - }) => { - return !isInvalidSingleLine(tg); - }).length) - ) { - utils.reportJSDoc( - 'Multiline jsdoc blocks are prohibited by ' + - 'your configuration but fixing would result in a single ' + - 'line block which you have prohibited with `noSingleLineBlocks`.', - ); - - return; - } - - if (jsdoc.tags.length > 1) { - if (!allowMultipleTags) { - utils.reportJSDoc( - 'Multiline jsdoc blocks are prohibited by ' + - 'your configuration but the block has multiple tags.', - ); - - return; - } - } else if (jsdoc.tags.length === 1 && jsdoc.description.trim()) { - if (!allowMultipleTags) { - utils.reportJSDoc( - 'Multiline jsdoc blocks are prohibited by ' + - 'your configuration but the block has a description with a tag.', - ); - - return; - } - } else { - const fixer = () => { - jsdoc.source = [ - { - number: 1, - source: '', - tokens: jsdoc.source.reduce((obj, { - tokens: { - description: desc, - tag: tg, - type: typ, - name: nme, - lineEnd, - postType, - postName, - postTag, - }, - }) => { - if (typ) { - obj.type = typ; - } - - if (tg && typ && nme) { - obj.postType = postType; - } - - if (nme) { - obj.name += nme; - } - - if (nme && desc) { - obj.postName = postName; - } - - obj.description += desc; - - const nameOrDescription = obj.description || obj.name; - if ( - nameOrDescription && nameOrDescription.slice(-1) !== ' ' - ) { - obj.description += ' '; - } - - obj.lineEnd = lineEnd; - - // Already filtered for multiple tags - obj.tag += tg; - if (tg) { - obj.postTag = postTag || ' '; - } - - return obj; - }, utils.seedTokens({ - delimiter: '/**', - end: '*/', - postDelimiter: ' ', - })), - }, - ]; - }; - - utils.reportJSDoc( - 'Multiline jsdoc blocks are prohibited by ' + - 'your configuration.', - null, - fixer, - ); - - return; - } - } - - lineChecks(); -}, { - iterateAllJsdocs: true, - meta: { - docs: { - description: 'Controls how and whether jsdoc blocks can be expressed as single or multiple line blocks.', - url: 'https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/multiline-blocks.md#repos-sticky-header', - }, - fixable: 'code', - schema: [ - { - additionalProperties: false, - properties: { - allowMultipleTags: { - type: 'boolean', - }, - minimumLengthForMultiline: { - type: 'integer', - }, - multilineTags: { - anyOf: [ - { - enum: [ - '*', - ], - type: 'string', - }, { - items: { - type: 'string', - }, - type: 'array', - }, - ], - }, - noFinalLineText: { - type: 'boolean', - }, - noMultilineBlocks: { - type: 'boolean', - }, - noSingleLineBlocks: { - type: 'boolean', - }, - noZeroLineText: { - type: 'boolean', - }, - singleLineTags: { - items: { - type: 'string', - }, - type: 'array', - }, - }, - type: 'object', - }, - ], - type: 'suggestion', - }, -}); diff --git a/tools/eslint/node_modules/eslint-plugin-jsdoc/src/rules/noBadBlocks.js b/tools/eslint/node_modules/eslint-plugin-jsdoc/src/rules/noBadBlocks.js deleted file mode 100644 index f64de2218e9e58..00000000000000 --- a/tools/eslint/node_modules/eslint-plugin-jsdoc/src/rules/noBadBlocks.js +++ /dev/null @@ -1,109 +0,0 @@ -import iterateJsdoc from '../iterateJsdoc.js'; -import { - parse as commentParser, -} from 'comment-parser'; - -// Neither a single nor 3+ asterisks are valid jsdoc per -// https://jsdoc.app/about-getting-started.html#adding-documentation-comments-to-your-code -const commentRegexp = /^\/\*(?!\*)/u; -const extraAsteriskCommentRegexp = /^\/\*{3,}/u; - -export default iterateJsdoc(({ - context, - sourceCode, - allComments, - makeReport, -}) => { - const [ - { - ignore = [ - 'ts-check', - 'ts-expect-error', - 'ts-ignore', - 'ts-nocheck', - ], - preventAllMultiAsteriskBlocks = false, - } = {}, - ] = context.options; - - let extraAsterisks = false; - const nonJsdocNodes = /** @type {import('estree').Node[]} */ ( - allComments - ).filter((comment) => { - const commentText = sourceCode.getText(comment); - let sliceIndex = 2; - if (!commentRegexp.test(commentText)) { - const multiline = extraAsteriskCommentRegexp.exec(commentText)?.[0]; - if (!multiline) { - return false; - } - - sliceIndex = multiline.length; - extraAsterisks = true; - if (preventAllMultiAsteriskBlocks) { - return true; - } - } - - const tags = (commentParser( - `${commentText.slice(0, 2)}*${commentText.slice(sliceIndex)}`, - )[0] || {}).tags ?? []; - - return tags.length && !tags.some(({ - tag, - }) => { - return ignore.includes(tag); - }); - }); - - if (!nonJsdocNodes.length) { - return; - } - - for (const node of nonJsdocNodes) { - const report = /** @type {import('../iterateJsdoc.js').MakeReport} */ ( - makeReport - )(context, node); - - // eslint-disable-next-line no-loop-func - const fix = /** @type {import('eslint').Rule.ReportFixer} */ (fixer) => { - const text = sourceCode.getText(node); - - return fixer.replaceText( - node, - extraAsterisks ? - text.replace(extraAsteriskCommentRegexp, '/**') : - text.replace('/*', '/**'), - ); - }; - - report('Expected JSDoc-like comment to begin with two asterisks.', fix); - } -}, { - checkFile: true, - meta: { - docs: { - description: 'This rule checks for multi-line-style comments which fail to meet the criteria of a jsdoc block.', - url: 'https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/no-bad-blocks.md#repos-sticky-header', - }, - fixable: 'code', - schema: [ - { - additionalProperties: false, - properties: { - ignore: { - items: { - type: 'string', - }, - type: 'array', - }, - preventAllMultiAsteriskBlocks: { - type: 'boolean', - }, - }, - type: 'object', - }, - ], - type: 'layout', - }, -}); diff --git a/tools/eslint/node_modules/eslint-plugin-jsdoc/src/rules/noBlankBlockDescriptions.js b/tools/eslint/node_modules/eslint-plugin-jsdoc/src/rules/noBlankBlockDescriptions.js deleted file mode 100644 index d28bf2b3f50d09..00000000000000 --- a/tools/eslint/node_modules/eslint-plugin-jsdoc/src/rules/noBlankBlockDescriptions.js +++ /dev/null @@ -1,69 +0,0 @@ -import iterateJsdoc from '../iterateJsdoc.js'; - -const anyWhitespaceLines = /^\s*$/u; -const atLeastTwoLinesWhitespace = /^[ \t]*\n[ \t]*\n\s*$/u; - -export default iterateJsdoc(({ - jsdoc, - utils, -}) => { - const { - description, - descriptions, - lastDescriptionLine, - } = utils.getDescription(); - - const regex = jsdoc.tags.length ? - anyWhitespaceLines : - atLeastTwoLinesWhitespace; - - if (descriptions.length && regex.test(description)) { - if (jsdoc.tags.length) { - utils.reportJSDoc( - 'There should be no blank lines in block descriptions followed by tags.', - { - line: lastDescriptionLine, - }, - () => { - utils.setBlockDescription(() => { - // Remove all lines - return []; - }); - }, - ); - } else { - utils.reportJSDoc( - 'There should be no extra blank lines in block descriptions not followed by tags.', - { - line: lastDescriptionLine, - }, - () => { - utils.setBlockDescription((info, seedTokens) => { - return [ - // Keep the starting line - { - number: 0, - source: '', - tokens: seedTokens({ - ...info, - description: '', - }), - }, - ]; - }); - }, - ); - } - } -}, { - iterateAllJsdocs: true, - meta: { - docs: { - description: 'Detects and removes extra lines of a blank block description', - url: 'https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/no-blank-block-descriptions.md#repos-sticky-header', - }, - fixable: 'whitespace', - schema: [], - type: 'layout', - }, -}); diff --git a/tools/eslint/node_modules/eslint-plugin-jsdoc/src/rules/noBlankBlocks.js b/tools/eslint/node_modules/eslint-plugin-jsdoc/src/rules/noBlankBlocks.js deleted file mode 100644 index 7bc34af9662959..00000000000000 --- a/tools/eslint/node_modules/eslint-plugin-jsdoc/src/rules/noBlankBlocks.js +++ /dev/null @@ -1,53 +0,0 @@ -import iterateJsdoc from '../iterateJsdoc.js'; - -export default iterateJsdoc(({ - context, - jsdoc, - utils, -}) => { - if (jsdoc.tags.length) { - return; - } - - const { - description, - lastDescriptionLine, - } = utils.getDescription(); - if (description.trim()) { - return; - } - - const { - enableFixer, - } = context.options[0] || {}; - - utils.reportJSDoc( - 'No empty blocks', - { - line: lastDescriptionLine, - }, - enableFixer ? () => { - jsdoc.source.splice(0, jsdoc.source.length); - } : null, - ); -}, { - iterateAllJsdocs: true, - meta: { - docs: { - description: 'Removes empty blocks with nothing but possibly line breaks', - url: 'https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/no-blank-blocks.md#repos-sticky-header', - }, - fixable: 'code', - schema: [ - { - additionalProperties: false, - properties: { - enableFixer: { - type: 'boolean', - }, - }, - }, - ], - type: 'suggestion', - }, -}); diff --git a/tools/eslint/node_modules/eslint-plugin-jsdoc/src/rules/noDefaults.js b/tools/eslint/node_modules/eslint-plugin-jsdoc/src/rules/noDefaults.js deleted file mode 100644 index 3ce05312ad6793..00000000000000 --- a/tools/eslint/node_modules/eslint-plugin-jsdoc/src/rules/noDefaults.js +++ /dev/null @@ -1,85 +0,0 @@ -import iterateJsdoc from '../iterateJsdoc.js'; - -export default iterateJsdoc(({ - context, - utils, -}) => { - const { - noOptionalParamNames, - } = context.options[0] || {}; - const paramTags = utils.getPresentTags([ - 'param', 'arg', 'argument', - ]); - for (const tag of paramTags) { - if (noOptionalParamNames && tag.optional) { - utils.reportJSDoc(`Optional param names are not permitted on @${tag.tag}.`, tag, () => { - utils.changeTag(tag, { - name: tag.name.replace(/([^=]*)(=.+)?/u, '$1'), - }); - }); - } else if (tag.default) { - utils.reportJSDoc(`Defaults are not permitted on @${tag.tag}.`, tag, () => { - utils.changeTag(tag, { - name: tag.name.replace(/([^=]*)(=.+)?/u, '[$1]'), - }); - }); - } - } - - const defaultTags = utils.getPresentTags([ - 'default', 'defaultvalue', - ]); - for (const tag of defaultTags) { - if (tag.description.trim()) { - utils.reportJSDoc(`Default values are not permitted on @${tag.tag}.`, tag, () => { - utils.changeTag(tag, { - description: '', - postTag: '', - }); - }); - } - } -}, { - contextDefaults: true, - meta: { - docs: { - description: 'This rule reports defaults being used on the relevant portion of `@param` or `@default`.', - url: 'https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/no-defaults.md#repos-sticky-header', - }, - fixable: 'code', - schema: [ - { - additionalProperties: false, - properties: { - contexts: { - items: { - anyOf: [ - { - type: 'string', - }, - { - additionalProperties: false, - properties: { - comment: { - type: 'string', - }, - context: { - type: 'string', - }, - }, - type: 'object', - }, - ], - }, - type: 'array', - }, - noOptionalParamNames: { - type: 'boolean', - }, - }, - type: 'object', - }, - ], - type: 'suggestion', - }, -}); diff --git a/tools/eslint/node_modules/eslint-plugin-jsdoc/src/rules/noMissingSyntax.js b/tools/eslint/node_modules/eslint-plugin-jsdoc/src/rules/noMissingSyntax.js deleted file mode 100644 index 417d683731c937..00000000000000 --- a/tools/eslint/node_modules/eslint-plugin-jsdoc/src/rules/noMissingSyntax.js +++ /dev/null @@ -1,195 +0,0 @@ -import iterateJsdoc from '../iterateJsdoc.js'; - -/** - * @typedef {{ - * comment: string, - * context: string, - * message: string, - * minimum: import('../iterateJsdoc.js').Integer - * }} ContextObject - */ - -/** - * @typedef {string|ContextObject} Context - */ - -/** - * @param {import('../iterateJsdoc.js').StateObject} state - * @returns {void} - */ -const setDefaults = (state) => { - if (!state.selectorMap) { - state.selectorMap = {}; - } -}; - -/** - * @param {import('../iterateJsdoc.js').StateObject} state - * @param {string} selector - * @param {string} comment - * @returns {void} - */ -const incrementSelector = (state, selector, comment) => { - if (!state.selectorMap[selector]) { - state.selectorMap[selector] = {}; - } - - if (!state.selectorMap[selector][comment]) { - state.selectorMap[selector][comment] = 0; - } - - state.selectorMap[selector][comment]++; -}; - -export default iterateJsdoc(({ - context, - info: { - comment, - }, - state, - utils, -}) => { - if (!context.options[0]) { - // Handle error later - return; - } - - /** - * @type {Context[]} - */ - const contexts = context.options[0].contexts; - - const { - contextStr, - } = utils.findContext(contexts, comment); - - setDefaults(state); - - incrementSelector(state, contextStr, String(comment)); -}, { - contextSelected: true, - exit ({ - context, - settings, - state, - }) { - if (!context.options.length && !settings.contexts) { - context.report({ - loc: { - end: { - column: 1, - line: 1, - }, - start: { - column: 1, - line: 1, - }, - }, - message: 'Rule `no-missing-syntax` is missing a `contexts` option.', - }); - - return; - } - - setDefaults(state); - - /** - * @type {Context[]} - */ - const contexts = (context.options[0] ?? {}).contexts ?? settings?.contexts; - - // Report when MISSING - contexts.some((cntxt) => { - const contextStr = typeof cntxt === 'object' ? cntxt.context ?? 'any' : cntxt; - const comment = typeof cntxt === 'string' ? '' : cntxt?.comment; - - const contextKey = contextStr === 'any' ? 'undefined' : contextStr; - - if ( - (!state.selectorMap[contextKey] || - !state.selectorMap[contextKey][comment] || - state.selectorMap[contextKey][comment] < ( - // @ts-expect-error comment would need an object, not string - cntxt?.minimum ?? 1 - )) && - (contextStr !== 'any' || Object.values(state.selectorMap).every((cmmnt) => { - return !cmmnt[comment] || cmmnt[comment] < ( - // @ts-expect-error comment would need an object, not string - cntxt?.minimum ?? 1 - ); - })) - ) { - const message = typeof cntxt === 'string' ? - 'Syntax is required: {{context}}' : - cntxt?.message ?? ('Syntax is required: {{context}}' + - (comment ? ' with {{comment}}' : '')); - context.report({ - data: { - comment, - context: contextStr, - }, - loc: { - end: { - column: 1, - line: 1, - }, - start: { - column: 1, - line: 1, - }, - }, - message, - }); - - return true; - } - - return false; - }); - }, - matchContext: true, - meta: { - docs: { - description: 'Reports when certain comment structures are always expected.', - url: 'https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/no-missing-syntax.md#repos-sticky-header', - }, - fixable: 'code', - schema: [ - { - additionalProperties: false, - properties: { - contexts: { - items: { - anyOf: [ - { - type: 'string', - }, - { - additionalProperties: false, - properties: { - comment: { - type: 'string', - }, - context: { - type: 'string', - }, - message: { - type: 'string', - }, - minimum: { - type: 'integer', - }, - }, - type: 'object', - }, - ], - }, - type: 'array', - }, - }, - type: 'object', - }, - ], - type: 'suggestion', - }, -}); diff --git a/tools/eslint/node_modules/eslint-plugin-jsdoc/src/rules/noMultiAsterisks.js b/tools/eslint/node_modules/eslint-plugin-jsdoc/src/rules/noMultiAsterisks.js deleted file mode 100644 index a8d7836237e265..00000000000000 --- a/tools/eslint/node_modules/eslint-plugin-jsdoc/src/rules/noMultiAsterisks.js +++ /dev/null @@ -1,134 +0,0 @@ -import iterateJsdoc from '../iterateJsdoc.js'; - -const middleAsterisksBlockWS = /^([\t ]|\*(?!\*))+/u; -const middleAsterisksNoBlockWS = /^\*+/u; - -const endAsterisksSingleLineBlockWS = /\*((?:\*|(?: |\t))*)\*$/u; -const endAsterisksMultipleLineBlockWS = /((?:\*|(?: |\t))*)\*$/u; - -const endAsterisksSingleLineNoBlockWS = /\*(\**)\*$/u; -const endAsterisksMultipleLineNoBlockWS = /(\**)\*$/u; - -export default iterateJsdoc(({ - context, - jsdoc, - utils, -}) => { - const { - allowWhitespace = false, - preventAtEnd = true, - preventAtMiddleLines = true, - } = context.options[0] || {}; - - const middleAsterisks = allowWhitespace ? middleAsterisksNoBlockWS : middleAsterisksBlockWS; - - // eslint-disable-next-line complexity -- Todo - jsdoc.source.some(({ - tokens, - number, - }) => { - const { - delimiter, - tag, - name, - type, - description, - end, - postDelimiter, - } = tokens; - - if ( - preventAtMiddleLines && - !end && !tag && !type && !name && - ( - !allowWhitespace && middleAsterisks.test(description) || - allowWhitespace && middleAsterisks.test(postDelimiter + description) - ) - ) { - // console.log('description', JSON.stringify(description)); - const fix = () => { - tokens.description = description.replace(middleAsterisks, ''); - }; - - utils.reportJSDoc( - 'Should be no multiple asterisks on middle lines.', - { - line: number, - }, - fix, - true, - ); - - return true; - } - - if (!preventAtEnd || !end) { - return false; - } - - const isSingleLineBlock = delimiter === '/**'; - const delim = isSingleLineBlock ? '*' : delimiter; - const endAsterisks = allowWhitespace ? - (isSingleLineBlock ? endAsterisksSingleLineNoBlockWS : endAsterisksMultipleLineNoBlockWS) : - (isSingleLineBlock ? endAsterisksSingleLineBlockWS : endAsterisksMultipleLineBlockWS); - - const endingAsterisksAndSpaces = ( - allowWhitespace ? postDelimiter + description + delim : description + delim - ).match( - endAsterisks, - ); - - if ( - !endingAsterisksAndSpaces || - !isSingleLineBlock && endingAsterisksAndSpaces[1] && !endingAsterisksAndSpaces[1].trim() - ) { - return false; - } - - const endFix = () => { - if (!isSingleLineBlock) { - tokens.delimiter = ''; - } - - tokens.description = (description + delim).replace(endAsterisks, ''); - }; - - utils.reportJSDoc( - 'Should be no multiple asterisks on end lines.', - { - line: number, - }, - endFix, - true, - ); - - return true; - }); -}, { - iterateAllJsdocs: true, - meta: { - docs: { - description: '', - url: 'https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/no-multi-asterisks.md#repos-sticky-header', - }, - fixable: 'code', - schema: [ - { - additionalProperties: false, - properties: { - allowWhitespace: { - type: 'boolean', - }, - preventAtEnd: { - type: 'boolean', - }, - preventAtMiddleLines: { - type: 'boolean', - }, - }, - type: 'object', - }, - ], - type: 'suggestion', - }, -}); diff --git a/tools/eslint/node_modules/eslint-plugin-jsdoc/src/rules/noRestrictedSyntax.js b/tools/eslint/node_modules/eslint-plugin-jsdoc/src/rules/noRestrictedSyntax.js deleted file mode 100644 index dd770f3a4866f8..00000000000000 --- a/tools/eslint/node_modules/eslint-plugin-jsdoc/src/rules/noRestrictedSyntax.js +++ /dev/null @@ -1,91 +0,0 @@ -import iterateJsdoc from '../iterateJsdoc.js'; - -export default iterateJsdoc(({ - context, - info: { - comment, - }, - report, - utils, -}) => { - if (!context.options.length) { - report('Rule `no-restricted-syntax` is missing a `contexts` option.'); - - return; - } - - const { - contexts, - } = context.options[0]; - - const { - foundContext, - contextStr, - } = utils.findContext(contexts, comment); - - // We are not on the *particular* matching context/comment, so don't assume - // we need reporting - if (!foundContext) { - return; - } - - const message = /** @type {import('../iterateJsdoc.js').ContextObject} */ ( - foundContext - )?.message ?? - 'Syntax is restricted: {{context}}' + - (comment ? ' with {{comment}}' : ''); - - report(message, null, null, comment ? { - comment, - context: contextStr, - } : { - context: contextStr, - }); -}, { - contextSelected: true, - meta: { - docs: { - description: 'Reports when certain comment structures are present.', - url: 'https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/no-restricted-syntax.md#repos-sticky-header', - }, - fixable: 'code', - schema: [ - { - additionalProperties: false, - properties: { - contexts: { - items: { - anyOf: [ - { - type: 'string', - }, - { - additionalProperties: false, - properties: { - comment: { - type: 'string', - }, - context: { - type: 'string', - }, - message: { - type: 'string', - }, - }, - type: 'object', - }, - ], - }, - type: 'array', - }, - }, - required: [ - 'contexts', - ], - type: 'object', - }, - ], - type: 'suggestion', - }, - nonGlobalSettings: true, -}); diff --git a/tools/eslint/node_modules/eslint-plugin-jsdoc/src/rules/noTypes.js b/tools/eslint/node_modules/eslint-plugin-jsdoc/src/rules/noTypes.js deleted file mode 100644 index 5f7e5b8352f7c5..00000000000000 --- a/tools/eslint/node_modules/eslint-plugin-jsdoc/src/rules/noTypes.js +++ /dev/null @@ -1,77 +0,0 @@ -import iterateJsdoc from '../iterateJsdoc.js'; - -/** - * @param {import('comment-parser').Line} line - */ -const removeType = ({ - tokens, -}) => { - tokens.postTag = ''; - tokens.type = ''; -}; - -export default iterateJsdoc(({ - utils, -}) => { - if (!utils.isIteratingFunction() && !utils.isVirtualFunction()) { - return; - } - - const tags = utils.getPresentTags([ - 'param', 'arg', 'argument', 'returns', 'return', - ]); - - for (const tag of tags) { - if (tag.type) { - utils.reportJSDoc(`Types are not permitted on @${tag.tag}.`, tag, () => { - for (const source of tag.source) { - removeType(source); - } - }); - } - } -}, { - contextDefaults: [ - 'ArrowFunctionExpression', 'FunctionDeclaration', 'FunctionExpression', 'TSDeclareFunction', - // Add this to above defaults - 'TSMethodSignature' - ], - meta: { - docs: { - description: 'This rule reports types being used on `@param` or `@returns`.', - url: 'https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/no-types.md#repos-sticky-header', - }, - fixable: 'code', - schema: [ - { - additionalProperties: false, - properties: { - contexts: { - items: { - anyOf: [ - { - type: 'string', - }, - { - additionalProperties: false, - properties: { - comment: { - type: 'string', - }, - context: { - type: 'string', - }, - }, - type: 'object', - }, - ], - }, - type: 'array', - }, - }, - type: 'object', - }, - ], - type: 'suggestion', - }, -}); diff --git a/tools/eslint/node_modules/eslint-plugin-jsdoc/src/rules/noUndefinedTypes.js b/tools/eslint/node_modules/eslint-plugin-jsdoc/src/rules/noUndefinedTypes.js deleted file mode 100644 index 3642f127853862..00000000000000 --- a/tools/eslint/node_modules/eslint-plugin-jsdoc/src/rules/noUndefinedTypes.js +++ /dev/null @@ -1,380 +0,0 @@ -import { dirname, join } from 'path'; -import { fileURLToPath } from 'url'; - -import { createSyncFn } from 'synckit'; -import { - getJSDocComment, - parse as parseType, - traverse, - tryParse as tryParseType, -} from '@es-joy/jsdoccomment'; -import iterateJsdoc, { - parseComment, -} from '../iterateJsdoc.js'; - -const __dirname = dirname(fileURLToPath(import.meta.url)); -const pathName = join(__dirname, '../import-worker.mjs'); - -const extraTypes = [ - 'null', 'undefined', 'void', 'string', 'boolean', 'object', - 'function', 'symbol', - 'number', 'bigint', 'NaN', 'Infinity', - 'any', '*', 'never', 'unknown', 'const', - 'this', 'true', 'false', - 'Array', 'Object', 'RegExp', 'Date', 'Function', -]; - -const typescriptGlobals = [ - // https://www.typescriptlang.org/docs/handbook/utility-types.html - 'Awaited', - 'Partial', - 'Required', - 'Readonly', - 'Record', - 'Pick', - 'Omit', - 'Exclude', - 'Extract', - 'NonNullable', - 'Parameters', - 'ConstructorParameters', - 'ReturnType', - 'InstanceType', - 'ThisParameterType', - 'OmitThisParameter', - 'ThisType', - 'Uppercase', - 'Lowercase', - 'Capitalize', - 'Uncapitalize', -]; - -/** - * @param {string|false|undefined} [str] - * @returns {undefined|string|false} - */ -const stripPseudoTypes = (str) => { - return str && str.replace(/(?:\.|<>|\.<>|\[\])$/u, ''); -}; - -export default iterateJsdoc(({ - context, - node, - report, - settings, - sourceCode, - utils, -}) => { - const { - scopeManager, - } = sourceCode; - - // When is this ever `null`? - const globalScope = /** @type {import('eslint').Scope.Scope} */ ( - scopeManager.globalScope - ); - - const - /** - * @type {{ - * definedTypes: string[], - * disableReporting: boolean, - * markVariablesAsUsed: boolean - * }} - */ { - definedTypes = [], - disableReporting = false, - markVariablesAsUsed = true, - } = context.options[0] || {}; - - /** @type {(string|undefined)[]} */ - let definedPreferredTypes = []; - const { - preferredTypes, - structuredTags, - mode, - } = settings; - if (Object.keys(preferredTypes).length) { - definedPreferredTypes = /** @type {string[]} */ (Object.values(preferredTypes).map((preferredType) => { - if (typeof preferredType === 'string') { - // May become an empty string but will be filtered out below - return stripPseudoTypes(preferredType); - } - - if (!preferredType) { - return undefined; - } - - if (typeof preferredType !== 'object') { - utils.reportSettings( - 'Invalid `settings.jsdoc.preferredTypes`. Values must be falsy, a string, or an object.', - ); - } - - return stripPseudoTypes(preferredType.replacement); - }) - .filter(Boolean)); - } - - const comments = sourceCode.getAllComments() - .filter((comment) => { - return (/^\*\s/u).test(comment.value); - }) - .map((commentNode) => { - return parseComment(commentNode, ''); - }); - - const typedefDeclarations = comments - .flatMap((doc) => { - return doc.tags.filter(({ - tag, - }) => { - return utils.isNamepathDefiningTag(tag); - }); - }) - .map((tag) => { - return tag.name; - }); - - - const importTags = settings.mode === 'typescript' ? /** @type {string[]} */ (comments.flatMap((doc) => { - return doc.tags.filter(({ - tag, - }) => { - return tag === 'import'; - }); - }).flatMap((tag) => { - const { - type, name, description - } = tag; - const typePart = type ? `{${type}} `: ''; - const imprt = 'import ' + (description - ? `${typePart}${name} ${description}` - : `${typePart}${name}`); - - const getImports = createSyncFn(pathName); - const imports = /** @type {import('parse-imports').Import[]} */ (getImports(imprt)); - if (!imports) { - return null; - } - - return imports.flatMap(({importClause}) => { - /* c8 ignore next */ - const {default: dflt, named, namespace} = importClause || {}; - const types = []; - if (dflt) { - types.push(dflt); - } - if (namespace) { - types.push(namespace); - } - if (named) { - for (const {binding} of named) { - types.push(binding); - } - } - - return types; - }); - }).filter(Boolean)) : []; - - const ancestorNodes = []; - - let currentNode = node; - // No need for Program node? - while (currentNode?.parent) { - ancestorNodes.push(currentNode); - currentNode = currentNode.parent; - } - - /** - * @param {import('eslint').Rule.Node} ancestorNode - * @returns {import('comment-parser').Spec[]} - */ - const getTemplateTags = function (ancestorNode) { - const commentNode = getJSDocComment(sourceCode, ancestorNode, settings); - if (!commentNode) { - return []; - } - - const jsdoc = parseComment(commentNode, ''); - - return jsdoc.tags.filter((tag) => { - return tag.tag === 'template'; - }); - }; - - // `currentScope` may be `null` or `Program`, so in such a case, - // we look to present tags instead - const templateTags = ancestorNodes.length ? - ancestorNodes.flatMap((ancestorNode) => { - return getTemplateTags(ancestorNode); - }) : - utils.getPresentTags([ - 'template', - ]); - - const closureGenericTypes = templateTags.flatMap((tag) => { - return utils.parseClosureTemplateTag(tag); - }); - - // In modules, including Node, there is a global scope at top with the - // Program scope inside - const cjsOrESMScope = globalScope.childScopes[0]?.block?.type === 'Program'; - - const allDefinedTypes = new Set(globalScope.variables.map(({ - name, - }) => { - return name; - }) - - // If the file is a module, concat the variables from the module scope. - .concat( - cjsOrESMScope ? - globalScope.childScopes.flatMap(({ - variables, - }) => { - return variables; - }).map(({ - name, - }) => { - return name; - /* c8 ignore next */ - }) : [], - ) - .concat(extraTypes) - .concat(typedefDeclarations) - .concat(importTags) - .concat(definedTypes) - .concat(/** @type {string[]} */ (definedPreferredTypes)) - .concat( - settings.mode === 'jsdoc' ? - [] : - [ - ...settings.mode === 'typescript' ? typescriptGlobals : [], - ...closureGenericTypes, - ], - )); - - /** - * @typedef {{ - * parsedType: import('jsdoc-type-pratt-parser').RootResult; - * tag: import('comment-parser').Spec|import('@es-joy/jsdoccomment').JsdocInlineTagNoType & { - * line?: import('../iterateJsdoc.js').Integer - * } - * }} TypeAndTagInfo - */ - - /** - * @param {string} propertyName - * @returns {(tag: (import('@es-joy/jsdoccomment').JsdocInlineTagNoType & { - * name?: string, - * type?: string, - * line?: import('../iterateJsdoc.js').Integer - * })|import('comment-parser').Spec & { - * namepathOrURL?: string - * } - * ) => undefined|TypeAndTagInfo} - */ - const tagToParsedType = (propertyName) => { - return (tag) => { - try { - const potentialType = tag[ - /** @type {"type"|"name"|"namepathOrURL"} */ (propertyName) - ]; - return { - parsedType: mode === 'permissive' ? - tryParseType(/** @type {string} */ (potentialType)) : - parseType(/** @type {string} */ (potentialType), mode), - tag, - }; - } catch { - return undefined; - } - }; - }; - - const typeTags = utils.filterTags(({ - tag, - }) => { - return tag !== 'import' && utils.tagMightHaveTypePosition(tag) && (tag !== 'suppress' || settings.mode !== 'closure'); - }).map(tagToParsedType('type')); - - const namepathReferencingTags = utils.filterTags(({ - tag, - }) => { - return utils.isNamepathReferencingTag(tag); - }).map(tagToParsedType('name')); - - const namepathOrUrlReferencingTags = utils.filterAllTags(({ - tag, - }) => { - return utils.isNamepathOrUrlReferencingTag(tag); - }).map(tagToParsedType('namepathOrURL')); - - const tagsWithTypes = /** @type {TypeAndTagInfo[]} */ ([ - ...typeTags, - ...namepathReferencingTags, - ...namepathOrUrlReferencingTags, - // Remove types which failed to parse - ].filter(Boolean)); - - for (const { - tag, - parsedType, - } of tagsWithTypes) { - traverse(parsedType, (nde) => { - const { - type, - value, - } = /** @type {import('jsdoc-type-pratt-parser').NameResult} */ (nde); - - if (type === 'JsdocTypeName') { - const structuredTypes = structuredTags[tag.tag]?.type; - if (!allDefinedTypes.has(value) && - (!Array.isArray(structuredTypes) || !structuredTypes.includes(value)) - ) { - if (!disableReporting) { - report(`The type '${value}' is undefined.`, null, tag); - } - } else if (markVariablesAsUsed && !extraTypes.includes(value)) { - if (sourceCode.markVariableAsUsed) { - sourceCode.markVariableAsUsed(value); - /* c8 ignore next 3 */ - } else { - context.markVariableAsUsed(value); - } - } - } - }); - } -}, { - iterateAllJsdocs: true, - meta: { - docs: { - description: 'Checks that types in jsdoc comments are defined.', - url: 'https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/no-undefined-types.md#repos-sticky-header', - }, - schema: [ - { - additionalProperties: false, - properties: { - definedTypes: { - items: { - type: 'string', - }, - type: 'array', - }, - disableReporting: { - type: 'boolean', - }, - markVariablesAsUsed: { - type: 'boolean', - }, - }, - type: 'object', - }, - ], - type: 'suggestion', - }, -}); diff --git a/tools/eslint/node_modules/eslint-plugin-jsdoc/src/rules/requireAsteriskPrefix.js b/tools/eslint/node_modules/eslint-plugin-jsdoc/src/rules/requireAsteriskPrefix.js deleted file mode 100644 index 27ad0f6602ba0d..00000000000000 --- a/tools/eslint/node_modules/eslint-plugin-jsdoc/src/rules/requireAsteriskPrefix.js +++ /dev/null @@ -1,189 +0,0 @@ -import iterateJsdoc from '../iterateJsdoc.js'; - -export default iterateJsdoc(({ - context, - jsdoc, - utils, - indent, -}) => { - const [ - defaultRequireValue = 'always', - { - tags: tagMap = {}, - } = {}, - ] = context.options; - - const { - source, - } = jsdoc; - - const always = defaultRequireValue === 'always'; - const never = defaultRequireValue === 'never'; - - /** @type {string} */ - let currentTag; - source.some(({ - number, - tokens, - }) => { - const { - delimiter, - tag, - end, - description, - } = tokens; - - /** - * @returns {void} - */ - const neverFix = () => { - tokens.delimiter = ''; - tokens.postDelimiter = ''; - }; - - /** - * @param {string} checkValue - * @returns {boolean} - */ - const checkNever = (checkValue) => { - if (delimiter && delimiter !== '/**' && ( - never && !tagMap.always?.includes(checkValue) || - tagMap.never?.includes(checkValue) - )) { - utils.reportJSDoc('Expected JSDoc line to have no prefix.', { - column: 0, - line: number, - }, neverFix); - - return true; - } - - return false; - }; - - /** - * @returns {void} - */ - const alwaysFix = () => { - if (!tokens.start) { - tokens.start = indent + ' '; - } - - tokens.delimiter = '*'; - tokens.postDelimiter = tag || description ? ' ' : ''; - }; - - /** - * @param {string} checkValue - * @returns {boolean} - */ - const checkAlways = (checkValue) => { - if ( - !delimiter && ( - always && !tagMap.never?.includes(checkValue) || - tagMap.always?.includes(checkValue) - ) - ) { - utils.reportJSDoc('Expected JSDoc line to have the prefix.', { - column: 0, - line: number, - }, alwaysFix); - - return true; - } - - return false; - }; - - if (tag) { - // Remove at sign - currentTag = tag.slice(1); - } - - if ( - // If this is the end but has a tag, the delimiter will also be - // populated and will be safely ignored later - end && !tag - ) { - return false; - } - - if (!currentTag) { - if (tagMap.any?.includes('*description')) { - return false; - } - - if (checkNever('*description')) { - return true; - } - - if (checkAlways('*description')) { - return true; - } - - return false; - } - - if (tagMap.any?.includes(currentTag)) { - return false; - } - - if (checkNever(currentTag)) { - return true; - } - - if (checkAlways(currentTag)) { - return true; - } - - return false; - }); -}, { - iterateAllJsdocs: true, - meta: { - docs: { - description: - 'Requires that each JSDoc line starts with an `*`.', - url: 'https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/require-asterisk-prefix.md#repos-sticky-header', - }, - fixable: 'code', - schema: [ - { - enum: [ - 'always', 'never', 'any', - ], - type: 'string', - }, - { - additionalProperties: false, - properties: { - tags: { - properties: { - always: { - items: { - type: 'string', - }, - type: 'array', - }, - any: { - items: { - type: 'string', - }, - type: 'array', - }, - never: { - items: { - type: 'string', - }, - type: 'array', - }, - }, - type: 'object', - }, - }, - type: 'object', - }, - ], - type: 'layout', - }, -}); diff --git a/tools/eslint/node_modules/eslint-plugin-jsdoc/src/rules/requireDescription.js b/tools/eslint/node_modules/eslint-plugin-jsdoc/src/rules/requireDescription.js deleted file mode 100644 index 6af9df631f5d33..00000000000000 --- a/tools/eslint/node_modules/eslint-plugin-jsdoc/src/rules/requireDescription.js +++ /dev/null @@ -1,161 +0,0 @@ -import iterateJsdoc from '../iterateJsdoc.js'; - -/** - * @param {string} description - * @returns {import('../iterateJsdoc.js').Integer} - */ -const checkDescription = (description) => { - return description - .trim() - .split('\n') - .filter(Boolean) - .length; -}; - -export default iterateJsdoc(({ - jsdoc, - report, - utils, - context, -}) => { - if (utils.avoidDocs()) { - return; - } - - const { - descriptionStyle = 'body', - } = context.options[0] || {}; - - let targetTagName = utils.getPreferredTagName({ - // We skip reporting except when `@description` is essential to the rule, - // so user can block the tag and still meaningfully use this rule - // even if the tag is present (and `check-tag-names` is the one to - // normally report the fact that it is blocked but present) - skipReportingBlockedTag: descriptionStyle !== 'tag', - tagName: 'description', - }); - if (!targetTagName) { - return; - } - - const isBlocked = typeof targetTagName === 'object' && 'blocked' in targetTagName && targetTagName.blocked; - if (isBlocked) { - targetTagName = /** @type {{blocked: true; tagName: string;}} */ ( - targetTagName - ).tagName; - } - - if (descriptionStyle !== 'tag') { - const { - description, - } = utils.getDescription(); - if (checkDescription(description || '')) { - return; - } - - if (descriptionStyle === 'body') { - const descTags = utils.getPresentTags([ - 'desc', 'description', - ]); - if (descTags.length) { - const [ - { - tag: tagName, - }, - ] = descTags; - report(`Remove the @${tagName} tag to leave a plain block description or add additional description text above the @${tagName} line.`); - } else { - report('Missing JSDoc block description.'); - } - - return; - } - } - - const functionExamples = isBlocked ? - [] : - jsdoc.tags.filter(({ - tag, - }) => { - return tag === targetTagName; - }); - - if (!functionExamples.length) { - report( - descriptionStyle === 'any' ? - `Missing JSDoc block description or @${targetTagName} declaration.` : - `Missing JSDoc @${targetTagName} declaration.`, - ); - - return; - } - - for (const example of functionExamples) { - if (!checkDescription(`${example.name} ${utils.getTagDescription(example)}`)) { - report(`Missing JSDoc @${targetTagName} description.`, null, example); - } - } -}, { - contextDefaults: true, - meta: { - docs: { - description: 'Requires that all functions have a description.', - url: 'https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/require-description.md#repos-sticky-header', - }, - schema: [ - { - additionalProperties: false, - properties: { - checkConstructors: { - default: true, - type: 'boolean', - }, - checkGetters: { - default: true, - type: 'boolean', - }, - checkSetters: { - default: true, - type: 'boolean', - }, - contexts: { - items: { - anyOf: [ - { - type: 'string', - }, - { - additionalProperties: false, - properties: { - comment: { - type: 'string', - }, - context: { - type: 'string', - }, - }, - type: 'object', - }, - ], - }, - type: 'array', - }, - descriptionStyle: { - enum: [ - 'body', 'tag', 'any', - ], - type: 'string', - }, - exemptedBy: { - items: { - type: 'string', - }, - type: 'array', - }, - }, - type: 'object', - }, - ], - type: 'suggestion', - }, -}); diff --git a/tools/eslint/node_modules/eslint-plugin-jsdoc/src/rules/requireDescriptionCompleteSentence.js b/tools/eslint/node_modules/eslint-plugin-jsdoc/src/rules/requireDescriptionCompleteSentence.js deleted file mode 100644 index a40720f3f2431e..00000000000000 --- a/tools/eslint/node_modules/eslint-plugin-jsdoc/src/rules/requireDescriptionCompleteSentence.js +++ /dev/null @@ -1,335 +0,0 @@ -import iterateJsdoc from '../iterateJsdoc.js'; -import escapeStringRegexp from 'escape-string-regexp'; - -const otherDescriptiveTags = new Set([ - // 'copyright' and 'see' might be good addition, but as the former may be - // sensitive text, and the latter may have just a link, they are not - // included by default - 'summary', 'file', 'fileoverview', 'overview', 'classdesc', 'todo', - 'deprecated', 'throws', 'exception', 'yields', 'yield', -]); - -/** - * @param {string} text - * @returns {string[]} - */ -const extractParagraphs = (text) => { - return text.split(/(? { - const txt = text - // Remove all {} tags. - .replaceAll(/(? { - return sentEnd[0]; - }); - - return txt - .split(/[.?!](?:\s+|$)/u) - - // Re-add the dot. - .map((sentence, idx) => { - return !puncts[idx] && /^\s*$/u.test(sentence) ? sentence : `${sentence}${puncts[idx] || ''}`; - }); -}; - -/** - * @param {string} text - * @returns {boolean} - */ -const isNewLinePrecededByAPeriod = (text) => { - /** @type {boolean} */ - let lastLineEndsSentence; - - const lines = text.split('\n'); - - return !lines.some((line) => { - if (lastLineEndsSentence === false && /^[A-Z][a-z]/u.test(line)) { - return true; - } - - lastLineEndsSentence = /[.:?!|]$/u.test(line); - - return false; - }); -}; - -/** - * @param {string} str - * @returns {boolean} - */ -const isCapitalized = (str) => { - return str[0] === str[0].toUpperCase(); -}; - -/** - * @param {string} str - * @returns {boolean} - */ -const isTable = (str) => { - return str.charAt(0) === '|'; -}; - -/** - * @param {string} str - * @returns {string} - */ -const capitalize = (str) => { - return str.charAt(0).toUpperCase() + str.slice(1); -}; - -/** - * @param {string} description - * @param {import('../iterateJsdoc.js').Report} reportOrig - * @param {import('eslint').Rule.Node} jsdocNode - * @param {string|RegExp} abbreviationsRegex - * @param {import('eslint').SourceCode} sourceCode - * @param {import('comment-parser').Spec|{ - * line: import('../iterateJsdoc.js').Integer - * }} tag - * @param {boolean} newlineBeforeCapsAssumesBadSentenceEnd - * @returns {boolean} - */ -const validateDescription = ( - description, reportOrig, jsdocNode, abbreviationsRegex, - sourceCode, tag, newlineBeforeCapsAssumesBadSentenceEnd, -) => { - if (!description || (/^\n+$/u).test(description)) { - return false; - } - - const descriptionNoHeadings = description.replaceAll(/^\s*#[^\n]*(\n|$)/gm, ''); - - const paragraphs = extractParagraphs(descriptionNoHeadings).filter(Boolean); - - return paragraphs.some((paragraph, parIdx) => { - const sentences = extractSentences(paragraph, abbreviationsRegex); - - const fix = /** @type {import('eslint').Rule.ReportFixer} */ (fixer) => { - let text = sourceCode.getText(jsdocNode); - - if (!/[.:?!]$/u.test(paragraph)) { - const line = paragraph.split('\n').filter(Boolean).pop(); - text = text.replace(new RegExp(`${escapeStringRegexp( - /** @type {string} */ - (line), - )}$`, 'mu'), `${line}.`); - } - - for (const sentence of sentences.filter((sentence_) => { - return !(/^\s*$/u).test(sentence_) && !isCapitalized(sentence_) && - !isTable(sentence_); - })) { - const beginning = sentence.split('\n')[0]; - - if ('tag' in tag && tag.tag) { - const reg = new RegExp(`(@${escapeStringRegexp(tag.tag)}.*)${escapeStringRegexp(beginning)}`, 'u'); - - text = text.replace(reg, (_$0, $1) => { - return $1 + capitalize(beginning); - }); - } else { - text = text.replace(new RegExp('((?:[.?!]|\\*|\\})\\s*)' + escapeStringRegexp(beginning), 'u'), '$1' + capitalize(beginning)); - } - } - - return fixer.replaceText(jsdocNode, text); - }; - - /** - * @param {string} msg - * @param {import('eslint').Rule.ReportFixer | null | undefined} fixer - * @param {{ - * line?: number | undefined; - * column?: number | undefined; - * } | (import('comment-parser').Spec & { - * line?: number | undefined; - * column?: number | undefined; - * })} tagObj - * @returns {void} - */ - const report = (msg, fixer, tagObj) => { - if ('line' in tagObj) { - /** - * @type {{ - * line: number; - * }} - */ (tagObj).line += parIdx * 2; - } else { - /** @type {import('comment-parser').Spec} */ ( - tagObj - ).source[0].number += parIdx * 2; - } - - // Avoid errors if old column doesn't exist here - tagObj.column = 0; - reportOrig(msg, fixer, tagObj); - }; - - if (sentences.some((sentence) => { - return (/^[.?!]$/u).test(sentence); - })) { - report('Sentences must be more than punctuation.', null, tag); - } - - if (sentences.some((sentence) => { - return !(/^\s*$/u).test(sentence) && !isCapitalized(sentence) && !isTable(sentence); - })) { - report('Sentences should start with an uppercase character.', fix, tag); - } - - const paragraphNoAbbreviations = paragraph.replace(abbreviationsRegex, ''); - - if (!/(?:[.?!|]|```)\s*$/u.test(paragraphNoAbbreviations)) { - report('Sentences must end with a period.', fix, tag); - return true; - } - - if (newlineBeforeCapsAssumesBadSentenceEnd && !isNewLinePrecededByAPeriod(paragraphNoAbbreviations)) { - report('A line of text is started with an uppercase character, but the preceding line does not end the sentence.', null, tag); - - return true; - } - - return false; - }); -}; - -export default iterateJsdoc(({ - sourceCode, - context, - jsdoc, - report, - jsdocNode, - utils, -}) => { - const /** @type {{abbreviations: string[], newlineBeforeCapsAssumesBadSentenceEnd: boolean}} */ { - abbreviations = [], - newlineBeforeCapsAssumesBadSentenceEnd = false, - } = context.options[0] || {}; - - const abbreviationsRegex = abbreviations.length ? - new RegExp('\\b' + abbreviations.map((abbreviation) => { - return escapeStringRegexp(abbreviation.replaceAll(/\.$/ug, '') + '.'); - }).join('|') + '(?:$|\\s)', 'gu') : - ''; - - let { - description, - } = utils.getDescription(); - - const indices = [ - ...description.matchAll(/```[\s\S]*```/gu), - ].map((match) => { - const { - index, - } = match; - const [ - { - length, - }, - ] = match; - return { - index, - length, - }; - }).reverse(); - - for (const { - index, - length, - } of indices) { - description = description.slice(0, index) + - description.slice(/** @type {import('../iterateJsdoc.js').Integer} */ ( - index - ) + length); - } - - if (validateDescription(description, report, jsdocNode, abbreviationsRegex, sourceCode, { - line: jsdoc.source[0].number + 1, - }, newlineBeforeCapsAssumesBadSentenceEnd)) { - return; - } - - utils.forEachPreferredTag('description', (matchingJsdocTag) => { - const desc = `${matchingJsdocTag.name} ${utils.getTagDescription(matchingJsdocTag)}`.trim(); - validateDescription(desc, report, jsdocNode, abbreviationsRegex, sourceCode, matchingJsdocTag, newlineBeforeCapsAssumesBadSentenceEnd); - }, true); - - const { - tagsWithNames, - } = utils.getTagsByType(jsdoc.tags); - const tagsWithoutNames = utils.filterTags(({ - tag: tagName, - }) => { - return otherDescriptiveTags.has(tagName) || - utils.hasOptionTag(tagName) && !tagsWithNames.some(({ - tag, - }) => { - // If user accidentally adds tags with names (or like `returns` - // get parsed as having names), do not add to this list - return tag === tagName; - }); - }); - - tagsWithNames.some((tag) => { - const desc = /** @type {string} */ ( - utils.getTagDescription(tag) - ).replace(/^- /u, '').trimEnd(); - - return validateDescription(desc, report, jsdocNode, abbreviationsRegex, sourceCode, tag, newlineBeforeCapsAssumesBadSentenceEnd); - }); - - tagsWithoutNames.some((tag) => { - const desc = `${tag.name} ${utils.getTagDescription(tag)}`.trim(); - - return validateDescription(desc, report, jsdocNode, abbreviationsRegex, sourceCode, tag, newlineBeforeCapsAssumesBadSentenceEnd); - }); -}, { - iterateAllJsdocs: true, - meta: { - docs: { - description: 'Requires that block description, explicit `@description`, and `@param`/`@returns` tag descriptions are written in complete sentences.', - url: 'https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/require-description-complete-sentence.md#repos-sticky-header', - }, - fixable: 'code', - schema: [ - { - additionalProperties: false, - properties: { - abbreviations: { - items: { - type: 'string', - }, - type: 'array', - }, - newlineBeforeCapsAssumesBadSentenceEnd: { - type: 'boolean', - }, - tags: { - items: { - type: 'string', - }, - type: 'array', - }, - }, - type: 'object', - }, - ], - type: 'suggestion', - }, -}); diff --git a/tools/eslint/node_modules/eslint-plugin-jsdoc/src/rules/requireExample.js b/tools/eslint/node_modules/eslint-plugin-jsdoc/src/rules/requireExample.js deleted file mode 100644 index 6b35f95cace418..00000000000000 --- a/tools/eslint/node_modules/eslint-plugin-jsdoc/src/rules/requireExample.js +++ /dev/null @@ -1,118 +0,0 @@ -import iterateJsdoc from '../iterateJsdoc.js'; - -export default iterateJsdoc(({ - context, - jsdoc, - report, - utils, -}) => { - if (utils.avoidDocs()) { - return; - } - - const { - enableFixer = true, - exemptNoArguments = false, - } = context.options[0] || {}; - - const targetTagName = 'example'; - - const functionExamples = jsdoc.tags.filter(({ - tag, - }) => { - return tag === targetTagName; - }); - - if (!functionExamples.length) { - if (exemptNoArguments && utils.isIteratingFunction() && - !utils.hasParams() - ) { - return; - } - - utils.reportJSDoc(`Missing JSDoc @${targetTagName} declaration.`, null, () => { - if (enableFixer) { - utils.addTag(targetTagName); - } - }); - - return; - } - - for (const example of functionExamples) { - const exampleContent = `${example.name} ${utils.getTagDescription(example)}` - .trim() - .split('\n') - .filter(Boolean); - - if (!exampleContent.length) { - report(`Missing JSDoc @${targetTagName} description.`, null, example); - } - } -}, { - contextDefaults: true, - meta: { - docs: { - description: 'Requires that all functions have examples.', - url: 'https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/require-example.md#repos-sticky-header', - }, - fixable: 'code', - schema: [ - { - additionalProperties: false, - properties: { - checkConstructors: { - default: true, - type: 'boolean', - }, - checkGetters: { - default: false, - type: 'boolean', - }, - checkSetters: { - default: false, - type: 'boolean', - }, - contexts: { - items: { - anyOf: [ - { - type: 'string', - }, - { - additionalProperties: false, - properties: { - comment: { - type: 'string', - }, - context: { - type: 'string', - }, - }, - type: 'object', - }, - ], - }, - type: 'array', - }, - enableFixer: { - default: true, - type: 'boolean', - }, - exemptedBy: { - items: { - type: 'string', - }, - type: 'array', - }, - exemptNoArguments: { - default: false, - type: 'boolean', - }, - }, - type: 'object', - }, - ], - type: 'suggestion', - }, -}); diff --git a/tools/eslint/node_modules/eslint-plugin-jsdoc/src/rules/requireFileOverview.js b/tools/eslint/node_modules/eslint-plugin-jsdoc/src/rules/requireFileOverview.js deleted file mode 100644 index dce8d0637fa798..00000000000000 --- a/tools/eslint/node_modules/eslint-plugin-jsdoc/src/rules/requireFileOverview.js +++ /dev/null @@ -1,154 +0,0 @@ -import iterateJsdoc from '../iterateJsdoc.js'; - -const defaultTags = { - file: { - initialCommentsOnly: true, - mustExist: true, - preventDuplicates: true, - }, -}; - -/** - * @param {import('../iterateJsdoc.js').StateObject} state - * @returns {void} - */ -const setDefaults = (state) => { - // First iteration - if (!state.globalTags) { - state.globalTags = {}; - state.hasDuplicates = {}; - state.hasTag = {}; - state.hasNonCommentBeforeTag = {}; - } -}; - -export default iterateJsdoc(({ - jsdocNode, - state, - utils, - context, -}) => { - const { - tags = defaultTags, - } = context.options[0] || {}; - - setDefaults(state); - - for (const tagName of Object.keys(tags)) { - const targetTagName = /** @type {string} */ (utils.getPreferredTagName({ - tagName, - })); - - const hasTag = Boolean(targetTagName && utils.hasTag(targetTagName)); - - state.hasTag[tagName] = hasTag || state.hasTag[tagName]; - - const hasDuplicate = state.hasDuplicates[tagName]; - - if (hasDuplicate === false) { - // Was marked before, so if a tag now, is a dupe - state.hasDuplicates[tagName] = hasTag; - } else if (!hasDuplicate && hasTag) { - // No dupes set before, but has first tag, so change state - // from `undefined` to `false` so can detect next time - state.hasDuplicates[tagName] = false; - state.hasNonCommentBeforeTag[tagName] = state.hasNonComment && - state.hasNonComment < jsdocNode.range[0]; - } - } -}, { - exit ({ - context, - state, - utils, - }) { - setDefaults(state); - const { - tags = defaultTags, - } = context.options[0] || {}; - - for (const [ - tagName, - { - mustExist = false, - preventDuplicates = false, - initialCommentsOnly = false, - }, - ] of Object.entries(tags)) { - const obj = utils.getPreferredTagNameObject({ - tagName, - }); - if (obj && typeof obj === 'object' && 'blocked' in obj) { - utils.reportSettings( - `\`settings.jsdoc.tagNamePreference\` cannot block @${obj.tagName} ` + - 'for the `require-file-overview` rule', - ); - } else { - const targetTagName = ( - obj && typeof obj === 'object' && obj.replacement - ) || obj; - if (mustExist && !state.hasTag[tagName]) { - utils.reportSettings(`Missing @${targetTagName}`); - } - - if (preventDuplicates && state.hasDuplicates[tagName]) { - utils.reportSettings( - `Duplicate @${targetTagName}`, - ); - } - - if (initialCommentsOnly && - state.hasNonCommentBeforeTag[tagName] - ) { - utils.reportSettings( - `@${targetTagName} should be at the beginning of the file`, - ); - } - } - } - }, - iterateAllJsdocs: true, - meta: { - docs: { - description: 'Checks that all files have one `@file`, `@fileoverview`, or `@overview` tag at the beginning of the file.', - url: 'https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/require-file-overview.md#repos-sticky-header', - }, - schema: [ - { - additionalProperties: false, - properties: { - tags: { - patternProperties: { - '.*': { - additionalProperties: false, - properties: { - initialCommentsOnly: { - type: 'boolean', - }, - mustExist: { - type: 'boolean', - }, - preventDuplicates: { - type: 'boolean', - }, - }, - type: 'object', - }, - }, - type: 'object', - }, - }, - type: 'object', - }, - ], - type: 'suggestion', - }, - nonComment ({ - state, - node, - }) { - if (!state.hasNonComment) { - state.hasNonComment = node.range[0]; - } - }, -}); diff --git a/tools/eslint/node_modules/eslint-plugin-jsdoc/src/rules/requireHyphenBeforeParamDescription.js b/tools/eslint/node_modules/eslint-plugin-jsdoc/src/rules/requireHyphenBeforeParamDescription.js deleted file mode 100644 index 791e842fa05d10..00000000000000 --- a/tools/eslint/node_modules/eslint-plugin-jsdoc/src/rules/requireHyphenBeforeParamDescription.js +++ /dev/null @@ -1,178 +0,0 @@ -import iterateJsdoc from '../iterateJsdoc.js'; - -export default iterateJsdoc(({ - sourceCode, - utils, - report, - context, - jsdoc, - jsdocNode, -}) => { - const [ - mainCircumstance, - { - tags = null, - } = {}, - ] = context.options; - - const tgs = /** - * @type {null|"any"|{[key: string]: "always"|"never"}} - */ (tags); - - /** - * @param {import('@es-joy/jsdoccomment').JsdocTagWithInline} jsdocTag - * @param {string} targetTagName - * @param {"always"|"never"} [circumstance] - * @returns {void} - */ - const checkHyphens = (jsdocTag, targetTagName, circumstance = mainCircumstance) => { - const always = !circumstance || circumstance === 'always'; - const desc = /** @type {string} */ (utils.getTagDescription(jsdocTag)); - if (!desc.trim()) { - return; - } - - const startsWithHyphen = (/^\s*-/u).test(desc); - if (always) { - if (!startsWithHyphen) { - report(`There must be a hyphen before @${targetTagName} description.`, (fixer) => { - const lineIndex = /** @type {import('../iterateJsdoc.js').Integer} */ ( - jsdocTag.line - ); - const sourceLines = sourceCode.getText(jsdocNode).split('\n'); - - // Get start index of description, accounting for multi-line descriptions - const description = desc.split('\n')[0]; - const descriptionIndex = sourceLines[lineIndex].lastIndexOf(description); - - const replacementLine = sourceLines[lineIndex] - .slice(0, descriptionIndex) + '- ' + description; - sourceLines.splice(lineIndex, 1, replacementLine); - const replacement = sourceLines.join('\n'); - - return fixer.replaceText(jsdocNode, replacement); - }, jsdocTag); - } - } else if (startsWithHyphen) { - let lines = 0; - for (const { - tokens, - } of jsdocTag.source) { - if (tokens.description) { - break; - } - - lines++; - } - - utils.reportJSDoc( - `There must be no hyphen before @${targetTagName} description.`, - { - line: jsdocTag.source[0].number + lines, - }, - () => { - for (const { - tokens, - } of jsdocTag.source) { - if (tokens.description) { - tokens.description = tokens.description.replace( - /^\s*-\s*/u, '', - ); - break; - } - } - }, - true, - ); - } - }; - - utils.forEachPreferredTag('param', checkHyphens); - if (tgs) { - const tagEntries = Object.entries(tgs); - for (const [ - tagName, - circumstance, - ] of tagEntries) { - if (tagName === '*') { - const preferredParamTag = utils.getPreferredTagName({ - tagName: 'param', - }); - for (const { - tag, - } of jsdoc.tags) { - if (tag === preferredParamTag || tagEntries.some(([ - tagNme, - ]) => { - return tagNme !== '*' && tagNme === tag; - })) { - continue; - } - - utils.forEachPreferredTag(tag, (jsdocTag, targetTagName) => { - checkHyphens( - jsdocTag, - targetTagName, - /** @type {"always"|"never"} */ (circumstance), - ); - }); - } - - continue; - } - - utils.forEachPreferredTag(tagName, (jsdocTag, targetTagName) => { - checkHyphens( - jsdocTag, - targetTagName, - /** @type {"always"|"never"} */ (circumstance), - ); - }); - } - } -}, { - iterateAllJsdocs: true, - meta: { - docs: { - description: 'Requires a hyphen before the `@param` description.', - url: 'https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/require-hyphen-before-param-description.md#repos-sticky-header', - }, - fixable: 'code', - schema: [ - { - enum: [ - 'always', 'never', - ], - type: 'string', - }, - { - additionalProperties: false, - properties: { - tags: { - anyOf: [ - { - patternProperties: { - '.*': { - enum: [ - 'always', 'never', - ], - type: 'string', - }, - }, - type: 'object', - }, - { - enum: [ - 'any', - ], - type: 'string', - }, - ], - }, - }, - type: 'object', - }, - ], - type: 'layout', - }, -}); diff --git a/tools/eslint/node_modules/eslint-plugin-jsdoc/src/rules/requireJsdoc.js b/tools/eslint/node_modules/eslint-plugin-jsdoc/src/rules/requireJsdoc.js deleted file mode 100644 index 521f191a06d012..00000000000000 --- a/tools/eslint/node_modules/eslint-plugin-jsdoc/src/rules/requireJsdoc.js +++ /dev/null @@ -1,637 +0,0 @@ -import exportParser from '../exportParser.js'; -import { - getSettings, -} from '../iterateJsdoc.js'; -import jsdocUtils from '../jsdocUtils.js'; -import { - getDecorator, - getJSDocComment, - getReducedASTNode, -} from '@es-joy/jsdoccomment'; - -/** - * @typedef {{ - * ancestorsOnly: boolean, - * esm: boolean, - * initModuleExports: boolean, - * initWindow: boolean - * }} RequireJsdocOpts - */ - -/** - * @typedef {import('eslint').Rule.Node| - * import('@typescript-eslint/types').TSESTree.Node} ESLintOrTSNode - */ - -/** @type {import('json-schema').JSONSchema4} */ -const OPTIONS_SCHEMA = { - additionalProperties: false, - properties: { - checkConstructors: { - default: true, - type: 'boolean', - }, - checkGetters: { - anyOf: [ - { - type: 'boolean', - }, - { - enum: [ - 'no-setter', - ], - type: 'string', - }, - ], - default: true, - }, - checkSetters: { - anyOf: [ - { - type: 'boolean', - }, - { - enum: [ - 'no-getter', - ], - type: 'string', - }, - ], - default: true, - }, - contexts: { - items: { - anyOf: [ - { - type: 'string', - }, - { - additionalProperties: false, - properties: { - context: { - type: 'string', - }, - inlineCommentBlock: { - type: 'boolean', - }, - minLineCount: { - type: 'integer', - }, - }, - type: 'object', - }, - ], - }, - type: 'array', - }, - enableFixer: { - default: true, - type: 'boolean', - }, - exemptEmptyConstructors: { - default: false, - type: 'boolean', - }, - exemptEmptyFunctions: { - default: false, - type: 'boolean', - }, - fixerMessage: { - default: '', - type: 'string', - }, - minLineCount: { - type: 'integer', - }, - publicOnly: { - oneOf: [ - { - default: false, - type: 'boolean', - }, - { - additionalProperties: false, - default: {}, - properties: { - ancestorsOnly: { - type: 'boolean', - }, - cjs: { - type: 'boolean', - }, - esm: { - type: 'boolean', - }, - window: { - type: 'boolean', - }, - }, - type: 'object', - }, - ], - }, - require: { - additionalProperties: false, - default: {}, - properties: { - ArrowFunctionExpression: { - default: false, - type: 'boolean', - }, - ClassDeclaration: { - default: false, - type: 'boolean', - }, - ClassExpression: { - default: false, - type: 'boolean', - }, - FunctionDeclaration: { - default: true, - type: 'boolean', - }, - FunctionExpression: { - default: false, - type: 'boolean', - }, - MethodDefinition: { - default: false, - type: 'boolean', - }, - }, - type: 'object', - }, - }, - type: 'object', -}; - -/** - * @param {import('eslint').Rule.RuleContext} context - * @param {import('json-schema').JSONSchema4Object} baseObject - * @param {string} option - * @param {string} key - * @returns {boolean|undefined} - */ -const getOption = (context, baseObject, option, key) => { - if (context.options[0] && option in context.options[0] && - // Todo: boolean shouldn't be returning property, but - // tests currently require - (typeof context.options[0][option] === 'boolean' || - key in context.options[0][option]) - ) { - return context.options[0][option][key]; - } - - return /** @type {{[key: string]: {default?: boolean|undefined}}} */ ( - baseObject.properties - )[key].default; -}; - -/** - * @param {import('eslint').Rule.RuleContext} context - * @param {import('../iterateJsdoc.js').Settings} settings - * @returns {{ - * contexts: (string|{ - * context: string, - * inlineCommentBlock: boolean, - * minLineCount: import('../iterateJsdoc.js').Integer - * })[], - * enableFixer: boolean, - * exemptEmptyConstructors: boolean, - * exemptEmptyFunctions: boolean, - * fixerMessage: string, - * minLineCount: undefined|import('../iterateJsdoc.js').Integer, - * publicOnly: boolean|{[key: string]: boolean|undefined} - * require: {[key: string]: boolean|undefined} - * }} - */ -const getOptions = (context, settings) => { - const { - publicOnly, - contexts = settings.contexts || [], - exemptEmptyConstructors = true, - exemptEmptyFunctions = false, - enableFixer = true, - fixerMessage = '', - minLineCount = undefined, - } = context.options[0] || {}; - - return { - contexts, - enableFixer, - exemptEmptyConstructors, - exemptEmptyFunctions, - fixerMessage, - minLineCount, - publicOnly: ((baseObj) => { - if (!publicOnly) { - return false; - } - - /** @type {{[key: string]: boolean|undefined}} */ - const properties = {}; - for (const prop of Object.keys( - /** @type {import('json-schema').JSONSchema4Object} */ ( - /** @type {import('json-schema').JSONSchema4Object} */ ( - baseObj - ).properties), - )) { - const opt = getOption( - context, - /** @type {import('json-schema').JSONSchema4Object} */ (baseObj), - 'publicOnly', - prop, - ); - - properties[prop] = opt; - } - - return properties; - })( - /** @type {import('json-schema').JSONSchema4Object} */ - ( - /** @type {import('json-schema').JSONSchema4Object} */ - ( - /** @type {import('json-schema').JSONSchema4Object} */ - ( - OPTIONS_SCHEMA.properties - ).publicOnly - ).oneOf - )[1], - ), - require: ((baseObj) => { - /** @type {{[key: string]: boolean|undefined}} */ - const properties = {}; - for (const prop of Object.keys( - /** @type {import('json-schema').JSONSchema4Object} */ ( - /** @type {import('json-schema').JSONSchema4Object} */ ( - baseObj - ).properties), - )) { - const opt = getOption( - context, - /** @type {import('json-schema').JSONSchema4Object} */ - (baseObj), - 'require', - prop, - ); - properties[prop] = opt; - } - - return properties; - })( - /** @type {import('json-schema').JSONSchema4Object} */ - (OPTIONS_SCHEMA.properties).require, - ), - }; -}; - -/** @type {import('eslint').Rule.RuleModule} */ -export default { - create (context) { - /* c8 ignore next -- Fallback to deprecated method */ - const { - sourceCode = context.getSourceCode(), - } = context; - const settings = getSettings(context); - if (!settings) { - return {}; - } - - const opts = getOptions(context, settings); - - const { - require: requireOption, - contexts, - exemptEmptyFunctions, - exemptEmptyConstructors, - enableFixer, - fixerMessage, - minLineCount, - } = opts; - - const publicOnly = - - /** - * @type {{ - * [key: string]: boolean | undefined; - * }} - */ ( - opts.publicOnly - ); - - /** - * @type {import('../iterateJsdoc.js').CheckJsdoc} - */ - const checkJsDoc = (info, _handler, node) => { - if ( - // Optimize - minLineCount !== undefined || contexts.some((ctxt) => { - if (typeof ctxt === 'string') { - return false; - } - - const { - minLineCount: count, - } = ctxt; - return count !== undefined; - }) - ) { - /** - * @param {undefined|import('../iterateJsdoc.js').Integer} count - */ - const underMinLine = (count) => { - return count !== undefined && count > - (sourceCode.getText(node).match(/\n/gu)?.length ?? 0) + 1; - }; - - if (underMinLine(minLineCount)) { - return; - } - - const { - minLineCount: contextMinLineCount, - } = - /** - * @type {{ - * context: string; - * inlineCommentBlock: boolean; - * minLineCount: number; - * }} - */ (contexts.find((ctxt) => { - if (typeof ctxt === 'string') { - return false; - } - - const { - context: ctx, - } = ctxt; - return ctx === (info.selector || node.type); - })) || {}; - if (underMinLine(contextMinLineCount)) { - return; - } - } - - const jsDocNode = getJSDocComment(sourceCode, node, settings); - - if (jsDocNode) { - return; - } - - // For those who have options configured against ANY constructors (or - // setters or getters) being reported - if (jsdocUtils.exemptSpeciaMethods( - { - description: '', - inlineTags: [], - problems: [], - source: [], - tags: [], - }, - node, - context, - [ - OPTIONS_SCHEMA, - ], - )) { - return; - } - - if ( - // Avoid reporting param-less, return-less functions (when - // `exemptEmptyFunctions` option is set) - exemptEmptyFunctions && info.isFunctionContext || - - // Avoid reporting param-less, return-less constructor methods (when - // `exemptEmptyConstructors` option is set) - exemptEmptyConstructors && jsdocUtils.isConstructor(node) - ) { - const functionParameterNames = jsdocUtils.getFunctionParameterNames(node); - if (!functionParameterNames.length && !jsdocUtils.hasReturnValue(node)) { - return; - } - } - - const fix = /** @type {import('eslint').Rule.ReportFixer} */ (fixer) => { - // Default to one line break if the `minLines`/`maxLines` settings allow - const lines = settings.minLines === 0 && settings.maxLines >= 1 ? 1 : settings.minLines; - /** @type {ESLintOrTSNode|import('@typescript-eslint/types').TSESTree.Decorator} */ - let baseNode = getReducedASTNode(node, sourceCode); - - const decorator = getDecorator( - /** @type {import('eslint').Rule.Node} */ - (baseNode) - ); - if (decorator) { - baseNode = decorator; - } - - const indent = jsdocUtils.getIndent({ - text: sourceCode.getText( - /** @type {import('eslint').Rule.Node} */ (baseNode), - /** @type {import('eslint').AST.SourceLocation} */ - ( - /** @type {import('eslint').Rule.Node} */ (baseNode).loc - ).start.column, - ), - }); - - const { - inlineCommentBlock, - } = - /** - * @type {{ - * context: string, - * inlineCommentBlock: boolean, - * minLineCount: import('../iterateJsdoc.js').Integer - * }} - */ (contexts.find((contxt) => { - if (typeof contxt === 'string') { - return false; - } - - const { - context: ctxt, - } = contxt; - return ctxt === node.type; - })) || {}; - const insertion = (inlineCommentBlock ? - `/** ${fixerMessage}` : - `/**\n${indent}*${fixerMessage}\n${indent}`) + - `*/${'\n'.repeat(lines)}${indent.slice(0, -1)}`; - - return fixer.insertTextBefore( - /** @type {import('eslint').Rule.Node} */ - (baseNode), - insertion, - ); - }; - - const report = () => { - const { - start, - } = /** @type {import('eslint').AST.SourceLocation} */ (node.loc); - const loc = { - end: { - column: 0, - line: start.line + 1, - }, - start, - }; - context.report({ - fix: enableFixer ? fix : null, - loc, - messageId: 'missingJsDoc', - node, - }); - }; - - if (publicOnly) { - /** @type {RequireJsdocOpts} */ - const opt = { - ancestorsOnly: Boolean(publicOnly?.ancestorsOnly ?? false), - esm: Boolean(publicOnly?.esm ?? true), - initModuleExports: Boolean(publicOnly?.cjs ?? true), - initWindow: Boolean(publicOnly?.window ?? false), - }; - const exported = exportParser.isUncommentedExport(node, sourceCode, opt, settings); - - if (exported) { - report(); - } - } else { - report(); - } - }; - - /** - * @param {string} prop - * @returns {boolean} - */ - const hasOption = (prop) => { - return requireOption[prop] || contexts.some((ctxt) => { - return typeof ctxt === 'object' ? ctxt.context === prop : ctxt === prop; - }); - }; - - return { - ...jsdocUtils.getContextObject( - jsdocUtils.enforcedContexts(context, [], settings), - checkJsDoc, - ), - ArrowFunctionExpression (node) { - if (!hasOption('ArrowFunctionExpression')) { - return; - } - - if ( - [ - 'VariableDeclarator', 'AssignmentExpression', 'ExportDefaultDeclaration', - ].includes(node.parent.type) || - [ - 'Property', 'ObjectProperty', 'ClassProperty', 'PropertyDefinition', - ].includes(node.parent.type) && - node === - /** - * @type {import('@typescript-eslint/types').TSESTree.Property| - * import('@typescript-eslint/types').TSESTree.PropertyDefinition - * } - */ - (node.parent).value - ) { - checkJsDoc({ - isFunctionContext: true, - }, null, node); - } - }, - - ClassDeclaration (node) { - if (!hasOption('ClassDeclaration')) { - return; - } - - checkJsDoc({ - isFunctionContext: false, - }, null, node); - }, - - ClassExpression (node) { - if (!hasOption('ClassExpression')) { - return; - } - - checkJsDoc({ - isFunctionContext: false, - }, null, node); - }, - - FunctionDeclaration (node) { - if (!hasOption('FunctionDeclaration')) { - return; - } - - checkJsDoc({ - isFunctionContext: true, - }, null, node); - }, - - FunctionExpression (node) { - if (!hasOption('FunctionExpression')) { - return; - } - - if ( - [ - 'VariableDeclarator', 'AssignmentExpression', 'ExportDefaultDeclaration', - ].includes(node.parent.type) || - [ - 'Property', 'ObjectProperty', 'ClassProperty', 'PropertyDefinition', - ].includes(node.parent.type) && - node === - /** - * @type {import('@typescript-eslint/types').TSESTree.Property| - * import('@typescript-eslint/types').TSESTree.PropertyDefinition - * } - */ - (node.parent).value - ) { - checkJsDoc({ - isFunctionContext: true, - }, null, node); - } - }, - - MethodDefinition (node) { - if (!hasOption('MethodDefinition')) { - return; - } - - checkJsDoc({ - isFunctionContext: true, - selector: 'MethodDefinition', - }, null, /** @type {import('eslint').Rule.Node} */ (node.value)); - }, - }; - }, - meta: { - docs: { - category: 'Stylistic Issues', - description: 'Require JSDoc comments', - recommended: true, - url: 'https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/require-jsdoc.md#repos-sticky-header', - }, - - fixable: 'code', - - messages: { - missingJsDoc: 'Missing JSDoc comment.', - }, - - schema: [ - OPTIONS_SCHEMA, - ], - - type: 'suggestion', - }, -}; diff --git a/tools/eslint/node_modules/eslint-plugin-jsdoc/src/rules/requireParam.js b/tools/eslint/node_modules/eslint-plugin-jsdoc/src/rules/requireParam.js deleted file mode 100644 index 33f50db7769e24..00000000000000 --- a/tools/eslint/node_modules/eslint-plugin-jsdoc/src/rules/requireParam.js +++ /dev/null @@ -1,594 +0,0 @@ -import iterateJsdoc from '../iterateJsdoc.js'; - -/** - * @typedef {[string, boolean, () => RootNamerReturn]} RootNamerReturn - */ - -/** - * @param {string[]} desiredRoots - * @param {number} currentIndex - * @returns {RootNamerReturn} - */ -const rootNamer = (desiredRoots, currentIndex) => { - /** @type {string} */ - let name; - let idx = currentIndex; - const incremented = desiredRoots.length <= 1; - if (incremented) { - const base = desiredRoots[0]; - const suffix = idx++; - name = `${base}${suffix}`; - } else { - name = /** @type {string} */ (desiredRoots.shift()); - } - - return [ - name, - incremented, - () => { - return rootNamer(desiredRoots, idx); - }, - ]; -}; - -/* eslint-disable complexity -- Temporary */ -export default iterateJsdoc(({ - jsdoc, - utils, - context, -}) => { - /* eslint-enable complexity -- Temporary */ - if (utils.avoidDocs()) { - return; - } - - // Param type is specified by type in @type - if (utils.hasTag('type')) { - return; - } - - const { - autoIncrementBase = 0, - checkRestProperty = false, - checkDestructured = true, - checkDestructuredRoots = true, - checkTypesPattern = '/^(?:[oO]bject|[aA]rray|PlainObject|Generic(?:Object|Array))$/', - enableFixer = true, - enableRootFixer = true, - enableRestElementFixer = true, - unnamedRootBase = [ - 'root', - ], - useDefaultObjectProperties = false, - } = context.options[0] || {}; - - const preferredTagName = /** @type {string} */ (utils.getPreferredTagName({ - tagName: 'param', - })); - if (!preferredTagName) { - return; - } - - const functionParameterNames = utils.getFunctionParameterNames(useDefaultObjectProperties); - if (!functionParameterNames.length) { - return; - } - - const jsdocParameterNames = - /** - * @type {{ - * idx: import('../iterateJsdoc.js').Integer; - * name: string; - * type: string; - * }[]} - */ (utils.getJsdocTagsDeep(preferredTagName)); - - const shallowJsdocParameterNames = jsdocParameterNames.filter((tag) => { - return !tag.name.includes('.'); - }).map((tag, idx) => { - return { - ...tag, - idx, - }; - }); - - const checkTypesRegex = utils.getRegexFromString(checkTypesPattern); - - /** - * @type {{ - * functionParameterIdx: import('../iterateJsdoc.js').Integer, - * functionParameterName: string, - * inc: boolean|undefined, - * remove?: true, - * type?: string|undefined - * }[]} - */ - const missingTags = []; - const flattenedRoots = utils.flattenRoots(functionParameterNames).names; - - /** - * @type {{ - * [key: string]: import('../iterateJsdoc.js').Integer - * }} - */ - const paramIndex = {}; - - /** - * @param {string} cur - * @returns {boolean} - */ - const hasParamIndex = (cur) => { - return utils.dropPathSegmentQuotes(String(cur)) in paramIndex; - }; - - /** - * - * @param {string|number|undefined} cur - * @returns {import('../iterateJsdoc.js').Integer} - */ - const getParamIndex = (cur) => { - return paramIndex[utils.dropPathSegmentQuotes(String(cur))]; - }; - - /** - * - * @param {string} cur - * @param {import('../iterateJsdoc.js').Integer} idx - * @returns {void} - */ - const setParamIndex = (cur, idx) => { - paramIndex[utils.dropPathSegmentQuotes(String(cur))] = idx; - }; - - for (const [ - idx, - cur, - ] of flattenedRoots.entries()) { - setParamIndex(cur, idx); - } - - /** - * - * @param {(import('@es-joy/jsdoccomment').JsdocTagWithInline & { - * newAdd?: boolean - * })[]} jsdocTags - * @param {import('../iterateJsdoc.js').Integer} indexAtFunctionParams - * @returns {import('../iterateJsdoc.js').Integer} - */ - const findExpectedIndex = (jsdocTags, indexAtFunctionParams) => { - const remainingRoots = functionParameterNames.slice(indexAtFunctionParams || 0); - const foundIndex = jsdocTags.findIndex(({ - name, - newAdd, - }) => { - return !newAdd && remainingRoots.some((remainingRoot) => { - if (Array.isArray(remainingRoot)) { - return ( - /** - * @type {import('../jsdocUtils.js').FlattendRootInfo & { - * annotationParamName?: string|undefined; - * }} - */ (remainingRoot[1]).names.includes(name) - ); - } - - if (typeof remainingRoot === 'object') { - return name === remainingRoot.name; - } - - return name === remainingRoot; - }); - }); - - const tags = foundIndex > -1 ? - jsdocTags.slice(0, foundIndex) : - jsdocTags.filter(({ - tag, - }) => { - return tag === preferredTagName; - }); - - let tagLineCount = 0; - for (const { - source, - } of tags) { - for (const { - tokens: { - end, - }, - } of source) { - if (!end) { - tagLineCount++; - } - } - } - - return tagLineCount; - }; - - let [ - nextRootName, - incremented, - namer, - ] = rootNamer([ - ...unnamedRootBase, - ], autoIncrementBase); - - const thisOffset = functionParameterNames[0] === 'this' ? 1 : 0; - - for (const [ - functionParameterIdx, - functionParameterName, - ] of functionParameterNames.entries()) { - - let inc; - if (Array.isArray(functionParameterName)) { - const matchedJsdoc = shallowJsdocParameterNames[functionParameterIdx - thisOffset]; - - /** @type {string} */ - let rootName; - if (functionParameterName[0]) { - rootName = functionParameterName[0]; - } else if (matchedJsdoc && matchedJsdoc.name) { - rootName = matchedJsdoc.name; - if (matchedJsdoc.type && matchedJsdoc.type.search(checkTypesRegex) === -1) { - continue; - } - } else { - rootName = nextRootName; - inc = incremented; - } - [ - nextRootName, - incremented, - namer, - ] = namer(); - - const { - hasRestElement, - hasPropertyRest, - rests, - names, - } = /** - * @type {import('../jsdocUtils.js').FlattendRootInfo & { - * annotationParamName?: string | undefined; - * }} - */ (functionParameterName[1]); - const notCheckingNames = []; - if (!enableRestElementFixer && hasRestElement) { - continue; - } - - if (!checkDestructuredRoots) { - continue; - } - - for (const [ - idx, - paramName, - ] of names.entries()) { - // Add root if the root name is not in the docs (and is not already - // in the tags to be fixed) - if (!jsdocParameterNames.find(({ - name, - }) => { - return name === rootName; - }) && !missingTags.find(({ - functionParameterName: fpn, - }) => { - return fpn === rootName; - })) { - const emptyParamIdx = jsdocParameterNames.findIndex(({ - name, - }) => { - return !name; - }); - - if (emptyParamIdx > -1) { - missingTags.push({ - functionParameterIdx: emptyParamIdx, - functionParameterName: rootName, - inc, - remove: true, - }); - } else { - missingTags.push({ - functionParameterIdx: hasParamIndex(rootName) ? - getParamIndex(rootName) : - getParamIndex(paramName), - functionParameterName: rootName, - inc, - }); - } - } - - if (!checkDestructured) { - continue; - } - - if (!checkRestProperty && rests[idx]) { - continue; - } - - const fullParamName = `${rootName}.${paramName}`; - - const notCheckingName = jsdocParameterNames.find(({ - name, - type: paramType, - }) => { - return utils.comparePaths(name)(fullParamName) && paramType.search(checkTypesRegex) === -1 && paramType !== ''; - }); - - if (notCheckingName !== undefined) { - notCheckingNames.push(notCheckingName.name); - } - - if (notCheckingNames.find((name) => { - return fullParamName.startsWith(name); - })) { - continue; - } - - if (jsdocParameterNames && !jsdocParameterNames.find(({ - name, - }) => { - return utils.comparePaths(name)(fullParamName); - })) { - missingTags.push({ - functionParameterIdx: getParamIndex( - functionParameterName[0] ? fullParamName : paramName, - ), - functionParameterName: fullParamName, - inc, - type: hasRestElement && !hasPropertyRest ? '{...any}' : undefined, - }); - } - } - - continue; - } - - /** @type {string} */ - let funcParamName; - let type; - if (typeof functionParameterName === 'object') { - if (!enableRestElementFixer && functionParameterName.restElement) { - continue; - } - - funcParamName = /** @type {string} */ (functionParameterName.name); - type = '{...any}'; - } else { - funcParamName = /** @type {string} */ (functionParameterName); - } - - if (jsdocParameterNames && !jsdocParameterNames.find(({ - name, - }) => { - return name === funcParamName; - }) && funcParamName !== 'this') { - missingTags.push({ - functionParameterIdx: getParamIndex(funcParamName), - functionParameterName: funcParamName, - inc, - type, - }); - } - } - - /** - * - * @param {{ - * functionParameterIdx: import('../iterateJsdoc.js').Integer, - * functionParameterName: string, - * remove?: true, - * inc?: boolean, - * type?: string - * }} cfg - */ - const fix = ({ - functionParameterIdx, - functionParameterName, - remove, - inc, - type, - }) => { - if (inc && !enableRootFixer) { - return; - } - - /** - * - * @param {import('../iterateJsdoc.js').Integer} tagIndex - * @param {import('../iterateJsdoc.js').Integer} sourceIndex - * @param {import('../iterateJsdoc.js').Integer} spliceCount - * @returns {void} - */ - const createTokens = (tagIndex, sourceIndex, spliceCount) => { - // console.log(sourceIndex, tagIndex, jsdoc.tags, jsdoc.source); - const tokens = { - number: sourceIndex + 1, - source: '', - tokens: { - delimiter: '*', - description: '', - end: '', - lineEnd: '', - name: functionParameterName, - newAdd: true, - postDelimiter: ' ', - postName: '', - postTag: ' ', - postType: type ? ' ' : '', - start: jsdoc.source[sourceIndex].tokens.start, - tag: `@${preferredTagName}`, - type: type ?? '', - }, - }; - - /** - * @type {(import('@es-joy/jsdoccomment').JsdocTagWithInline & { - * newAdd?: true - * })[]} - */ (jsdoc.tags).splice(tagIndex, spliceCount, { - description: '', - inlineTags: [], - name: functionParameterName, - newAdd: true, - optional: false, - problems: [], - source: [ - tokens, - ], - tag: preferredTagName, - type: type ?? '', - }); - const firstNumber = jsdoc.source[0].number; - jsdoc.source.splice(sourceIndex, spliceCount, tokens); - for (const [ - idx, - src, - ] of jsdoc.source.slice(sourceIndex).entries()) { - src.number = firstNumber + sourceIndex + idx; - } - }; - - const offset = jsdoc.source.findIndex(({ - tokens: { - tag, - end, - }, - }) => { - return tag || end; - }); - if (remove) { - createTokens(functionParameterIdx, offset + functionParameterIdx, 1); - } else { - const expectedIdx = findExpectedIndex(jsdoc.tags, functionParameterIdx); - createTokens(expectedIdx, offset + expectedIdx, 0); - } - }; - - /** - * @returns {void} - */ - const fixer = () => { - for (const missingTag of missingTags) { - fix(missingTag); - } - }; - - if (missingTags.length && jsdoc.source.length === 1) { - utils.makeMultiline(); - } - - for (const { - functionParameterName, - } of missingTags) { - utils.reportJSDoc( - `Missing JSDoc @${preferredTagName} "${functionParameterName}" declaration.`, - null, - enableFixer ? fixer : null, - ); - } -}, { - contextDefaults: true, - meta: { - docs: { - description: 'Requires that all function parameters are documented.', - url: 'https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/require-param.md#repos-sticky-header', - }, - fixable: 'code', - schema: [ - { - additionalProperties: false, - properties: { - autoIncrementBase: { - default: 0, - type: 'integer', - }, - checkConstructors: { - default: true, - type: 'boolean', - }, - checkDestructured: { - default: true, - type: 'boolean', - }, - checkDestructuredRoots: { - default: true, - type: 'boolean', - }, - checkGetters: { - default: false, - type: 'boolean', - }, - checkRestProperty: { - default: false, - type: 'boolean', - }, - checkSetters: { - default: false, - type: 'boolean', - }, - checkTypesPattern: { - type: 'string', - }, - contexts: { - items: { - anyOf: [ - { - type: 'string', - }, - { - additionalProperties: false, - properties: { - comment: { - type: 'string', - }, - context: { - type: 'string', - }, - }, - type: 'object', - }, - ], - }, - type: 'array', - }, - enableFixer: { - type: 'boolean', - }, - enableRestElementFixer: { - type: 'boolean', - }, - enableRootFixer: { - type: 'boolean', - }, - exemptedBy: { - items: { - type: 'string', - }, - type: 'array', - }, - unnamedRootBase: { - items: { - type: 'string', - }, - type: 'array', - }, - useDefaultObjectProperties: { - type: 'boolean', - }, - }, - type: 'object', - }, - ], - type: 'suggestion', - }, - - // We cannot cache comment nodes as the contexts may recur with the - // same comment node but a different JS node, and we may need the different - // JS node to ensure we iterate its context - noTracking: true, -}); diff --git a/tools/eslint/node_modules/eslint-plugin-jsdoc/src/rules/requireParamDescription.js b/tools/eslint/node_modules/eslint-plugin-jsdoc/src/rules/requireParamDescription.js deleted file mode 100644 index 1d32bdb26138a3..00000000000000 --- a/tools/eslint/node_modules/eslint-plugin-jsdoc/src/rules/requireParamDescription.js +++ /dev/null @@ -1,89 +0,0 @@ -import iterateJsdoc from '../iterateJsdoc.js'; - -export default iterateJsdoc(({ - context, - report, - settings, - utils, -}) => { - const { - defaultDestructuredRootDescription = 'The root object', - setDefaultDestructuredRootDescription = false, - } = context.options[0] || {}; - - const functionParameterNames = utils.getFunctionParameterNames(); - - let rootCount = -1; - utils.forEachPreferredTag('param', (jsdocParameter, targetTagName) => { - rootCount += jsdocParameter.name.includes('.') ? 0 : 1; - if (!jsdocParameter.description.trim()) { - if (Array.isArray(functionParameterNames[rootCount])) { - if (settings.exemptDestructuredRootsFromChecks) { - return; - } - - if (setDefaultDestructuredRootDescription) { - utils.reportJSDoc(`Missing root description for @${targetTagName}.`, jsdocParameter, () => { - utils.changeTag(jsdocParameter, { - description: defaultDestructuredRootDescription, - postName: ' ', - }); - }); - return; - } - } - - report( - `Missing JSDoc @${targetTagName} "${jsdocParameter.name}" description.`, - null, - jsdocParameter, - ); - } - }); -}, { - contextDefaults: true, - meta: { - docs: { - description: 'Requires that each `@param` tag has a `description` value.', - url: 'https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/require-param-description.md#repos-sticky-header', - }, - fixable: 'code', - schema: [ - { - additionalProperties: false, - properties: { - contexts: { - items: { - anyOf: [ - { - type: 'string', - }, - { - additionalProperties: false, - properties: { - comment: { - type: 'string', - }, - context: { - type: 'string', - }, - }, - type: 'object', - }, - ], - }, - type: 'array', - }, - defaultDestructuredRootDescription: { - type: 'string', - }, - setDefaultDestructuredRootDescription: { - type: 'boolean', - }, - }, - type: 'object', - }, - ], - type: 'suggestion', - }, -}); diff --git a/tools/eslint/node_modules/eslint-plugin-jsdoc/src/rules/requireParamName.js b/tools/eslint/node_modules/eslint-plugin-jsdoc/src/rules/requireParamName.js deleted file mode 100644 index d23dc3522b24b5..00000000000000 --- a/tools/eslint/node_modules/eslint-plugin-jsdoc/src/rules/requireParamName.js +++ /dev/null @@ -1,55 +0,0 @@ -import iterateJsdoc from '../iterateJsdoc.js'; - -export default iterateJsdoc(({ - report, - utils, -}) => { - utils.forEachPreferredTag('param', (jsdocParameter, targetTagName) => { - if (jsdocParameter.tag && jsdocParameter.name === '') { - report( - `There must be an identifier after @${targetTagName} ${jsdocParameter.type === '' ? 'type' : 'tag'}.`, - null, - jsdocParameter, - ); - } - }); -}, { - contextDefaults: true, - meta: { - docs: { - description: 'Requires that all function parameters have names.', - url: 'https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/require-param-name.md#repos-sticky-header', - }, - schema: [ - { - additionalProperties: false, - properties: { - contexts: { - items: { - anyOf: [ - { - type: 'string', - }, - { - additionalProperties: false, - properties: { - comment: { - type: 'string', - }, - context: { - type: 'string', - }, - }, - type: 'object', - }, - ], - }, - type: 'array', - }, - }, - type: 'object', - }, - ], - type: 'suggestion', - }, -}); diff --git a/tools/eslint/node_modules/eslint-plugin-jsdoc/src/rules/requireParamType.js b/tools/eslint/node_modules/eslint-plugin-jsdoc/src/rules/requireParamType.js deleted file mode 100644 index b405ce27414062..00000000000000 --- a/tools/eslint/node_modules/eslint-plugin-jsdoc/src/rules/requireParamType.js +++ /dev/null @@ -1,89 +0,0 @@ -import iterateJsdoc from '../iterateJsdoc.js'; - -export default iterateJsdoc(({ - context, - report, - settings, - utils, -}) => { - const { - defaultDestructuredRootType = 'object', - setDefaultDestructuredRootType = false, - } = context.options[0] || {}; - - const functionParameterNames = utils.getFunctionParameterNames(); - - let rootCount = -1; - utils.forEachPreferredTag('param', (jsdocParameter, targetTagName) => { - rootCount += jsdocParameter.name.includes('.') ? 0 : 1; - if (!jsdocParameter.type) { - if (Array.isArray(functionParameterNames[rootCount])) { - if (settings.exemptDestructuredRootsFromChecks) { - return; - } - - if (setDefaultDestructuredRootType) { - utils.reportJSDoc(`Missing root type for @${targetTagName}.`, jsdocParameter, () => { - utils.changeTag(jsdocParameter, { - postType: ' ', - type: `{${defaultDestructuredRootType}}`, - }); - }); - return; - } - } - - report( - `Missing JSDoc @${targetTagName} "${jsdocParameter.name}" type.`, - null, - jsdocParameter, - ); - } - }); -}, { - contextDefaults: true, - meta: { - docs: { - description: 'Requires that each `@param` tag has a `type` value.', - url: 'https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/require-param-type.md#repos-sticky-header', - }, - fixable: 'code', - schema: [ - { - additionalProperties: false, - properties: { - contexts: { - items: { - anyOf: [ - { - type: 'string', - }, - { - additionalProperties: false, - properties: { - comment: { - type: 'string', - }, - context: { - type: 'string', - }, - }, - type: 'object', - }, - ], - }, - type: 'array', - }, - defaultDestructuredRootType: { - type: 'string', - }, - setDefaultDestructuredRootType: { - type: 'boolean', - }, - }, - type: 'object', - }, - ], - type: 'suggestion', - }, -}); diff --git a/tools/eslint/node_modules/eslint-plugin-jsdoc/src/rules/requireProperty.js b/tools/eslint/node_modules/eslint-plugin-jsdoc/src/rules/requireProperty.js deleted file mode 100644 index 67beca13d97282..00000000000000 --- a/tools/eslint/node_modules/eslint-plugin-jsdoc/src/rules/requireProperty.js +++ /dev/null @@ -1,48 +0,0 @@ -import iterateJsdoc from '../iterateJsdoc.js'; - -export default iterateJsdoc(({ - utils, -}) => { - const propertyAssociatedTags = utils.filterTags(({ - tag, - }) => { - return [ - 'typedef', 'namespace', - ].includes(tag); - }); - if (!propertyAssociatedTags.length) { - return; - } - - const targetTagName = /** @type {string} */ (utils.getPreferredTagName({ - tagName: 'property', - })); - - if (utils.hasATag([ - targetTagName, - ])) { - return; - } - - for (const propertyAssociatedTag of propertyAssociatedTags) { - if (![ - 'object', 'Object', 'PlainObject', - ].includes(propertyAssociatedTag.type)) { - continue; - } - - utils.reportJSDoc(`Missing JSDoc @${targetTagName}.`, null, () => { - utils.addTag(targetTagName); - }); - } -}, { - iterateAllJsdocs: true, - meta: { - docs: { - description: 'Requires that all `@typedef` and `@namespace` tags have `@property` when their type is a plain `object`, `Object`, or `PlainObject`.', - url: 'https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/require-property.md#repos-sticky-header', - }, - fixable: 'code', - type: 'suggestion', - }, -}); diff --git a/tools/eslint/node_modules/eslint-plugin-jsdoc/src/rules/requirePropertyDescription.js b/tools/eslint/node_modules/eslint-plugin-jsdoc/src/rules/requirePropertyDescription.js deleted file mode 100644 index 773be42e2e612f..00000000000000 --- a/tools/eslint/node_modules/eslint-plugin-jsdoc/src/rules/requirePropertyDescription.js +++ /dev/null @@ -1,25 +0,0 @@ -import iterateJsdoc from '../iterateJsdoc.js'; - -export default iterateJsdoc(({ - report, - utils, -}) => { - utils.forEachPreferredTag('property', (jsdoc, targetTagName) => { - if (!jsdoc.description.trim()) { - report( - `Missing JSDoc @${targetTagName} "${jsdoc.name}" description.`, - null, - jsdoc, - ); - } - }); -}, { - iterateAllJsdocs: true, - meta: { - docs: { - description: 'Requires that each `@property` tag has a `description` value.', - url: 'https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/require-property-description.md#repos-sticky-header', - }, - type: 'suggestion', - }, -}); diff --git a/tools/eslint/node_modules/eslint-plugin-jsdoc/src/rules/requirePropertyName.js b/tools/eslint/node_modules/eslint-plugin-jsdoc/src/rules/requirePropertyName.js deleted file mode 100644 index d1956dd8efe1ef..00000000000000 --- a/tools/eslint/node_modules/eslint-plugin-jsdoc/src/rules/requirePropertyName.js +++ /dev/null @@ -1,25 +0,0 @@ -import iterateJsdoc from '../iterateJsdoc.js'; - -export default iterateJsdoc(({ - report, - utils, -}) => { - utils.forEachPreferredTag('property', (jsdoc, targetTagName) => { - if (jsdoc.tag && jsdoc.name === '') { - report( - `There must be an identifier after @${targetTagName} ${jsdoc.type === '' ? 'type' : 'tag'}.`, - null, - jsdoc, - ); - } - }); -}, { - iterateAllJsdocs: true, - meta: { - docs: { - description: 'Requires that all function `@property` tags have names.', - url: 'https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/require-property-name.md#repos-sticky-header', - }, - type: 'suggestion', - }, -}); diff --git a/tools/eslint/node_modules/eslint-plugin-jsdoc/src/rules/requirePropertyType.js b/tools/eslint/node_modules/eslint-plugin-jsdoc/src/rules/requirePropertyType.js deleted file mode 100644 index 5c9f09ef4bba37..00000000000000 --- a/tools/eslint/node_modules/eslint-plugin-jsdoc/src/rules/requirePropertyType.js +++ /dev/null @@ -1,25 +0,0 @@ -import iterateJsdoc from '../iterateJsdoc.js'; - -export default iterateJsdoc(({ - report, - utils, -}) => { - utils.forEachPreferredTag('property', (jsdoc, targetTagName) => { - if (!jsdoc.type) { - report( - `Missing JSDoc @${targetTagName} "${jsdoc.name}" type.`, - null, - jsdoc, - ); - } - }); -}, { - iterateAllJsdocs: true, - meta: { - docs: { - description: 'Requires that each `@property` tag has a `type` value.', - url: 'https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/require-property-type.md#repos-sticky-header', - }, - type: 'suggestion', - }, -}); diff --git a/tools/eslint/node_modules/eslint-plugin-jsdoc/src/rules/requireReturns.js b/tools/eslint/node_modules/eslint-plugin-jsdoc/src/rules/requireReturns.js deleted file mode 100644 index 99fa077c7d1c82..00000000000000 --- a/tools/eslint/node_modules/eslint-plugin-jsdoc/src/rules/requireReturns.js +++ /dev/null @@ -1,238 +0,0 @@ -import exportParser from '../exportParser.js'; -import iterateJsdoc from '../iterateJsdoc.js'; - -/** - * We can skip checking for a return value, in case the documentation is inherited - * or the method is either a constructor or an abstract method. - * - * In either of these cases the return value is optional or not defined. - * @param {import('../iterateJsdoc.js').Utils} utils - * a reference to the utils which are used to probe if a tag is present or not. - * @returns {boolean} - * true in case deep checking can be skipped; otherwise false. - */ -const canSkip = (utils) => { - return utils.hasATag([ - // inheritdoc implies that all documentation is inherited - // see https://jsdoc.app/tags-inheritdoc.html - // - // Abstract methods are by definition incomplete, - // so it is not an error if it declares a return value but does not implement it. - 'abstract', - 'virtual', - - // Constructors do not have a return value by definition (https://jsdoc.app/tags-class.html) - // So we can bail out here, too. - 'class', - 'constructor', - - // Return type is specified by type in @type - 'type', - - // This seems to imply a class as well - 'interface', - ]) || - utils.avoidDocs(); -}; - -export default iterateJsdoc(({ - info: { - comment, - }, - node, - report, - settings, - utils, - context, -}) => { - const { - contexts, - enableFixer = false, - forceRequireReturn = false, - forceReturnsWithAsync = false, - publicOnly = false, - } = context.options[0] || {}; - - // A preflight check. We do not need to run a deep check - // in case the @returns comment is optional or undefined. - if (canSkip(utils)) { - return; - } - - /** @type {boolean|undefined} */ - let forceRequireReturnContext; - if (contexts) { - const { - foundContext, - } = utils.findContext(contexts, comment); - if (typeof foundContext === 'object') { - forceRequireReturnContext = foundContext.forceRequireReturn; - } - } - - const tagName = /** @type {string} */ (utils.getPreferredTagName({ - tagName: 'returns', - })); - if (!tagName) { - return; - } - - const tags = utils.getTags(tagName); - - if (tags.length > 1) { - report(`Found more than one @${tagName} declaration.`); - } - - const iteratingFunction = utils.isIteratingFunction(); - - // In case the code returns something, we expect a return value in JSDoc. - const [ - tag, - ] = tags; - const missingReturnTag = typeof tag === 'undefined' || tag === null; - - const shouldReport = () => { - if (!missingReturnTag) { - return false; - } - - if (publicOnly) { - /** @type {import('./requireJsdoc.js').RequireJsdocOpts} */ - const opt = { - ancestorsOnly: Boolean(publicOnly?.ancestorsOnly ?? false), - esm: Boolean(publicOnly?.esm ?? true), - initModuleExports: Boolean(publicOnly?.cjs ?? true), - initWindow: Boolean(publicOnly?.window ?? false), - }; - /* c8 ignore next -- Fallback to deprecated method */ - const { - sourceCode = context.getSourceCode(), - } = context; - const exported = exportParser.isUncommentedExport( - /** @type {import('eslint').Rule.Node} */ (node), sourceCode, opt, settings, - ); - - if (!exported) { - return false; - } - } - - if ((forceRequireReturn || forceRequireReturnContext) && ( - iteratingFunction || utils.isVirtualFunction() - )) { - return true; - } - - const isAsync = !iteratingFunction && utils.hasTag('async') || - iteratingFunction && utils.isAsync(); - - if (forceReturnsWithAsync && isAsync) { - return true; - } - - return iteratingFunction && utils.hasValueOrExecutorHasNonEmptyResolveValue( - forceReturnsWithAsync, - ); - }; - - if (shouldReport()) { - utils.reportJSDoc(`Missing JSDoc @${tagName} declaration.`, null, enableFixer ? () => { - utils.addTag(tagName); - } : null); - } -}, { - contextDefaults: true, - meta: { - docs: { - description: 'Requires that returns are documented.', - url: 'https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/require-returns.md#repos-sticky-header', - }, - fixable: 'code', - schema: [ - { - additionalProperties: false, - properties: { - checkConstructors: { - default: false, - type: 'boolean', - }, - checkGetters: { - default: true, - type: 'boolean', - }, - contexts: { - items: { - anyOf: [ - { - type: 'string', - }, - { - additionalProperties: false, - properties: { - comment: { - type: 'string', - }, - context: { - type: 'string', - }, - forceRequireReturn: { - type: 'boolean', - }, - }, - type: 'object', - }, - ], - }, - type: 'array', - }, - enableFixer: { - type: 'boolean', - }, - exemptedBy: { - items: { - type: 'string', - }, - type: 'array', - }, - forceRequireReturn: { - default: false, - type: 'boolean', - }, - forceReturnsWithAsync: { - default: false, - type: 'boolean', - }, - publicOnly: { - oneOf: [ - { - default: false, - type: 'boolean', - }, - { - additionalProperties: false, - default: {}, - properties: { - ancestorsOnly: { - type: 'boolean', - }, - cjs: { - type: 'boolean', - }, - esm: { - type: 'boolean', - }, - window: { - type: 'boolean', - }, - }, - type: 'object', - }, - ], - }, - }, - type: 'object', - }, - ], - type: 'suggestion', - }, -}); diff --git a/tools/eslint/node_modules/eslint-plugin-jsdoc/src/rules/requireReturnsCheck.js b/tools/eslint/node_modules/eslint-plugin-jsdoc/src/rules/requireReturnsCheck.js deleted file mode 100755 index a8963ceeba5486..00000000000000 --- a/tools/eslint/node_modules/eslint-plugin-jsdoc/src/rules/requireReturnsCheck.js +++ /dev/null @@ -1,145 +0,0 @@ -import iterateJsdoc from '../iterateJsdoc.js'; - -/** - * @param {import('../iterateJsdoc.js').Utils} utils - * @param {import('../iterateJsdoc.js').Settings} settings - * @returns {boolean} - */ -const canSkip = (utils, settings) => { - const voidingTags = [ - // An abstract function is by definition incomplete - // so it is perfectly fine if a return is documented but - // not present within the function. - // A subclass may inherit the doc and implement the - // missing return. - 'abstract', - 'virtual', - - // A constructor function returns `this` by default, so may be `@returns` - // tag indicating this but no explicit return - 'class', - 'constructor', - 'interface', - ]; - - if (settings.mode === 'closure') { - // Structural Interface in GCC terms, equivalent to @interface tag as far as this rule is concerned - voidingTags.push('record'); - } - - return utils.hasATag(voidingTags) || - utils.isConstructor() || - utils.classHasTag('interface') || - settings.mode === 'closure' && utils.classHasTag('record'); -}; - -// eslint-disable-next-line complexity -- Temporary -export default iterateJsdoc(({ - context, - node, - report, - settings, - utils, -}) => { - const { - exemptAsync = true, - exemptGenerators = settings.mode === 'typescript', - reportMissingReturnForUndefinedTypes = false, - } = context.options[0] || {}; - - if (canSkip(utils, settings)) { - return; - } - - if (exemptAsync && utils.isAsync()) { - return; - } - - const tagName = /** @type {string} */ (utils.getPreferredTagName({ - tagName: 'returns', - })); - if (!tagName) { - return; - } - - const tags = utils.getTags(tagName); - - if (tags.length === 0) { - return; - } - - if (tags.length > 1) { - report(`Found more than one @${tagName} declaration.`); - - return; - } - - const [ - tag, - ] = tags; - - const type = tag.type.trim(); - - // https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-7.html#assertion-functions - if (/asserts\s/u.test(type)) { - return; - } - - const returnNever = type === 'never'; - - if (returnNever && utils.hasValueOrExecutorHasNonEmptyResolveValue(false)) { - report(`JSDoc @${tagName} declaration set with "never" but return expression is present in function.`); - - return; - } - - // In case a return value is declared in JSDoc, we also expect one in the code. - if ( - !returnNever && - ( - reportMissingReturnForUndefinedTypes || - !utils.mayBeUndefinedTypeTag(tag) - ) && - (tag.type === '' && !utils.hasValueOrExecutorHasNonEmptyResolveValue( - exemptAsync, - ) || - tag.type !== '' && !utils.hasValueOrExecutorHasNonEmptyResolveValue( - exemptAsync, - true, - )) && - Boolean( - !exemptGenerators || !node || - !('generator' in /** @type {import('../iterateJsdoc.js').Node} */ (node)) || - !(/** @type {import('@typescript-eslint/types').TSESTree.FunctionDeclaration} */ (node)).generator - ) - ) { - report(`JSDoc @${tagName} declaration present but return expression not available in function.`); - } -}, { - meta: { - docs: { - description: 'Requires a return statement in function body if a `@returns` tag is specified in jsdoc comment.', - url: 'https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/require-returns-check.md#repos-sticky-header', - }, - schema: [ - { - additionalProperties: false, - properties: { - exemptAsync: { - default: true, - type: 'boolean', - }, - exemptGenerators: { - type: 'boolean', - }, - reportMissingReturnForUndefinedTypes: { - default: false, - type: 'boolean', - }, - }, - type: 'object', - }, - ], - type: 'suggestion', - }, -}); diff --git a/tools/eslint/node_modules/eslint-plugin-jsdoc/src/rules/requireReturnsDescription.js b/tools/eslint/node_modules/eslint-plugin-jsdoc/src/rules/requireReturnsDescription.js deleted file mode 100644 index 5cd9915c60159e..00000000000000 --- a/tools/eslint/node_modules/eslint-plugin-jsdoc/src/rules/requireReturnsDescription.js +++ /dev/null @@ -1,59 +0,0 @@ -import iterateJsdoc from '../iterateJsdoc.js'; - -export default iterateJsdoc(({ - report, - utils, -}) => { - utils.forEachPreferredTag('returns', (jsdocTag, targetTagName) => { - const type = jsdocTag.type && jsdocTag.type.trim(); - - if ([ - 'void', 'undefined', 'Promise', 'Promise', - ].includes(type)) { - return; - } - - if (!jsdocTag.description.trim()) { - report(`Missing JSDoc @${targetTagName} description.`, null, jsdocTag); - } - }); -}, { - contextDefaults: true, - meta: { - docs: { - description: 'Requires that the `@returns` tag has a `description` value.', - url: 'https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/require-returns-description.md#repos-sticky-header', - }, - schema: [ - { - additionalProperties: false, - properties: { - contexts: { - items: { - anyOf: [ - { - type: 'string', - }, - { - additionalProperties: false, - properties: { - comment: { - type: 'string', - }, - context: { - type: 'string', - }, - }, - type: 'object', - }, - ], - }, - type: 'array', - }, - }, - type: 'object', - }, - ], - type: 'suggestion', - }, -}); diff --git a/tools/eslint/node_modules/eslint-plugin-jsdoc/src/rules/requireReturnsType.js b/tools/eslint/node_modules/eslint-plugin-jsdoc/src/rules/requireReturnsType.js deleted file mode 100644 index 47e8cb96008697..00000000000000 --- a/tools/eslint/node_modules/eslint-plugin-jsdoc/src/rules/requireReturnsType.js +++ /dev/null @@ -1,51 +0,0 @@ -import iterateJsdoc from '../iterateJsdoc.js'; - -export default iterateJsdoc(({ - report, - utils, -}) => { - utils.forEachPreferredTag('returns', (jsdocTag, targetTagName) => { - if (!jsdocTag.type) { - report(`Missing JSDoc @${targetTagName} type.`, null, jsdocTag); - } - }); -}, { - contextDefaults: true, - meta: { - docs: { - description: 'Requires that `@returns` tag has `type` value.', - url: 'https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/require-returns-type.md#repos-sticky-header', - }, - schema: [ - { - additionalProperties: false, - properties: { - contexts: { - items: { - anyOf: [ - { - type: 'string', - }, - { - additionalProperties: false, - properties: { - comment: { - type: 'string', - }, - context: { - type: 'string', - }, - }, - type: 'object', - }, - ], - }, - type: 'array', - }, - }, - type: 'object', - }, - ], - type: 'suggestion', - }, -}); diff --git a/tools/eslint/node_modules/eslint-plugin-jsdoc/src/rules/requireTemplate.js b/tools/eslint/node_modules/eslint-plugin-jsdoc/src/rules/requireTemplate.js deleted file mode 100644 index 015902eb0e8993..00000000000000 --- a/tools/eslint/node_modules/eslint-plugin-jsdoc/src/rules/requireTemplate.js +++ /dev/null @@ -1,119 +0,0 @@ -import { - parse as parseType, - traverse, - tryParse as tryParseType, -} from '@es-joy/jsdoccomment'; -import iterateJsdoc from '../iterateJsdoc.js'; - -export default iterateJsdoc(({ - context, - utils, - node, - settings, - report, -}) => { - const { - requireSeparateTemplates = false, - } = context.options[0] || {}; - - const { - mode - } = settings; - - const usedNames = new Set(); - const templateTags = utils.getTags('template'); - const templateNames = templateTags.flatMap(({name}) => { - return name.split(/,\s*/); - }); - - for (const tag of templateTags) { - const {name} = tag; - const names = name.split(/,\s*/); - if (requireSeparateTemplates && names.length > 1) { - report(`Missing separate @template for ${names[1]}`, null, tag); - } - } - - /** - * @param {import('@typescript-eslint/types').TSESTree.TSTypeAliasDeclaration} aliasDeclaration - */ - const checkParameters = (aliasDeclaration) => { - /* c8 ignore next -- Guard */ - const {params} = aliasDeclaration.typeParameters ?? {params: []}; - for (const {name: {name}} of params) { - usedNames.add(name); - } - for (const usedName of usedNames) { - if (!templateNames.includes(usedName)) { - report(`Missing @template ${usedName}`); - } - } - }; - - const handleTypeAliases = () => { - const nde = /** @type {import('@typescript-eslint/types').TSESTree.Node} */ ( - node - ); - if (!nde) { - return; - } - switch (nde.type) { - case 'ExportNamedDeclaration': - if (nde.declaration?.type === 'TSTypeAliasDeclaration') { - checkParameters(nde.declaration); - } - break; - case 'TSTypeAliasDeclaration': - checkParameters(nde); - break; - } - }; - - const typedefTags = utils.getTags('typedef'); - if (!typedefTags.length || typedefTags.length >= 2) { - handleTypeAliases(); - return; - } - - const potentialType = typedefTags[0].type; - const parsedType = mode === 'permissive' ? - tryParseType(/** @type {string} */ (potentialType)) : - parseType(/** @type {string} */ (potentialType), mode) - - traverse(parsedType, (nde) => { - const { - type, - value, - } = /** @type {import('jsdoc-type-pratt-parser').NameResult} */ (nde); - if (type === 'JsdocTypeName' && (/^[A-Z]$/).test(value)) { - usedNames.add(value); - } - }); - - // Could check against whitelist/blacklist - for (const usedName of usedNames) { - if (!templateNames.includes(usedName)) { - report(`Missing @template ${usedName}`, null, typedefTags[0]); - } - } -}, { - iterateAllJsdocs: true, - meta: { - docs: { - description: 'Requires template tags for each generic type parameter', - url: 'https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/require-template.md#repos-sticky-header', - }, - schema: [ - { - additionalProperties: false, - properties: { - requireSeparateTemplates: { - type: 'boolean' - } - }, - type: 'object', - }, - ], - type: 'suggestion', - }, -}); diff --git a/tools/eslint/node_modules/eslint-plugin-jsdoc/src/rules/requireThrows.js b/tools/eslint/node_modules/eslint-plugin-jsdoc/src/rules/requireThrows.js deleted file mode 100644 index ac694afd156479..00000000000000 --- a/tools/eslint/node_modules/eslint-plugin-jsdoc/src/rules/requireThrows.js +++ /dev/null @@ -1,111 +0,0 @@ -import iterateJsdoc from '../iterateJsdoc.js'; - -/** - * We can skip checking for a throws value, in case the documentation is inherited - * or the method is either a constructor or an abstract method. - * @param {import('../iterateJsdoc.js').Utils} utils a reference to the utils which are used to probe if a tag is present or not. - * @returns {boolean} true in case deep checking can be skipped; otherwise false. - */ -const canSkip = (utils) => { - return utils.hasATag([ - // inheritdoc implies that all documentation is inherited - // see https://jsdoc.app/tags-inheritdoc.html - // - // Abstract methods are by definition incomplete, - // so it is not necessary to document that they throw an error. - 'abstract', - 'virtual', - - // The designated type can itself document `@throws` - 'type', - ]) || - utils.avoidDocs(); -}; - -export default iterateJsdoc(({ - report, - utils, -}) => { - // A preflight check. We do not need to run a deep check for abstract - // functions. - if (canSkip(utils)) { - return; - } - - const tagName = /** @type {string} */ (utils.getPreferredTagName({ - tagName: 'throws', - })); - if (!tagName) { - return; - } - - const tags = utils.getTags(tagName); - const iteratingFunction = utils.isIteratingFunction(); - - // In case the code returns something, we expect a return value in JSDoc. - const [ - tag, - ] = tags; - const missingThrowsTag = typeof tag === 'undefined' || tag === null; - - const shouldReport = () => { - if (!missingThrowsTag) { - if (tag.type.trim() === 'never' && iteratingFunction && utils.hasThrowValue()) { - report(`JSDoc @${tagName} declaration set to "never" but throw value found.`); - } - - return false; - } - - return iteratingFunction && utils.hasThrowValue(); - }; - - if (shouldReport()) { - report(`Missing JSDoc @${tagName} declaration.`); - } -}, { - contextDefaults: true, - meta: { - docs: { - description: 'Requires that throw statements are documented.', - url: 'https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/require-throws.md#repos-sticky-header', - }, - schema: [ - { - additionalProperties: false, - properties: { - contexts: { - items: { - anyOf: [ - { - type: 'string', - }, - { - additionalProperties: false, - properties: { - comment: { - type: 'string', - }, - context: { - type: 'string', - }, - }, - type: 'object', - }, - ], - }, - type: 'array', - }, - exemptedBy: { - items: { - type: 'string', - }, - type: 'array', - }, - }, - type: 'object', - }, - ], - type: 'suggestion', - }, -}); diff --git a/tools/eslint/node_modules/eslint-plugin-jsdoc/src/rules/requireYields.js b/tools/eslint/node_modules/eslint-plugin-jsdoc/src/rules/requireYields.js deleted file mode 100644 index 83c7da7ee1c207..00000000000000 --- a/tools/eslint/node_modules/eslint-plugin-jsdoc/src/rules/requireYields.js +++ /dev/null @@ -1,216 +0,0 @@ -import iterateJsdoc from '../iterateJsdoc.js'; - -/** - * We can skip checking for a yield value, in case the documentation is inherited - * or the method has a constructor or abstract tag. - * - * In either of these cases the yield value is optional or not defined. - * @param {import('../iterateJsdoc.js').Utils} utils a reference to the utils which are used to probe if a tag is present or not. - * @returns {boolean} true in case deep checking can be skipped; otherwise false. - */ -const canSkip = (utils) => { - return utils.hasATag([ - // inheritdoc implies that all documentation is inherited - // see https://jsdoc.app/tags-inheritdoc.html - // - // Abstract methods are by definition incomplete, - // so it is not an error if it declares a yield value but does not implement it. - 'abstract', - 'virtual', - - // Constructors do not have a yield value - // so we can bail out here, too. - 'class', - 'constructor', - - // Yield (and any `next`) type is specified accompanying the targeted - // @type - 'type', - - // This seems to imply a class as well - 'interface', - ]) || - utils.avoidDocs(); -}; - -/** - * @param {import('../iterateJsdoc.js').Utils} utils - * @param {import('../iterateJsdoc.js').Report} report - * @param {string} tagName - * @returns {[preferredTagName?: string, missingTag?: boolean]} - */ -const checkTagName = (utils, report, tagName) => { - const preferredTagName = /** @type {string} */ (utils.getPreferredTagName({ - tagName, - })); - if (!preferredTagName) { - return []; - } - - const tags = utils.getTags(preferredTagName); - - if (tags.length > 1) { - report(`Found more than one @${preferredTagName} declaration.`); - } - - // In case the code yields something, we expect a yields value in JSDoc. - const [ - tag, - ] = tags; - const missingTag = typeof tag === 'undefined' || tag === null; - - return [ - preferredTagName, missingTag, - ]; -}; - -export default iterateJsdoc(({ - report, - utils, - context, -}) => { - const { - next = false, - nextWithGeneratorTag = false, - forceRequireNext = false, - forceRequireYields = false, - withGeneratorTag = true, - } = context.options[0] || {}; - - // A preflight check. We do not need to run a deep check - // in case the @yield comment is optional or undefined. - if (canSkip(utils)) { - return; - } - - const iteratingFunction = utils.isIteratingFunction(); - - const [ - preferredYieldTagName, - missingYieldTag, - ] = checkTagName( - utils, report, 'yields', - ); - if (preferredYieldTagName) { - const shouldReportYields = () => { - if (!missingYieldTag) { - return false; - } - - if ( - withGeneratorTag && utils.hasTag('generator') || - forceRequireYields && iteratingFunction && utils.isGenerator() - ) { - return true; - } - - return iteratingFunction && utils.isGenerator() && utils.hasYieldValue(); - }; - - if (shouldReportYields()) { - report(`Missing JSDoc @${preferredYieldTagName} declaration.`); - } - } - - if (next || nextWithGeneratorTag || forceRequireNext) { - const [ - preferredNextTagName, - missingNextTag, - ] = checkTagName( - utils, report, 'next', - ); - if (!preferredNextTagName) { - return; - } - - const shouldReportNext = () => { - if (!missingNextTag) { - return false; - } - - if ( - nextWithGeneratorTag && utils.hasTag('generator')) { - return true; - } - - if ( - !next && !forceRequireNext || - !iteratingFunction || - !utils.isGenerator() - ) { - return false; - } - - return forceRequireNext || utils.hasYieldReturnValue(); - }; - - if (shouldReportNext()) { - report(`Missing JSDoc @${preferredNextTagName} declaration.`); - } - } -}, { - contextDefaults: true, - meta: { - docs: { - description: 'Requires yields are documented.', - url: 'https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/require-yields.md#repos-sticky-header', - }, - schema: [ - { - additionalProperties: false, - properties: { - contexts: { - items: { - anyOf: [ - { - type: 'string', - }, - { - additionalProperties: false, - properties: { - comment: { - type: 'string', - }, - context: { - type: 'string', - }, - }, - type: 'object', - }, - ], - }, - type: 'array', - }, - exemptedBy: { - items: { - type: 'string', - }, - type: 'array', - }, - forceRequireNext: { - default: false, - type: 'boolean', - }, - forceRequireYields: { - default: false, - type: 'boolean', - }, - next: { - default: false, - type: 'boolean', - }, - nextWithGeneratorTag: { - default: false, - type: 'boolean', - }, - withGeneratorTag: { - default: true, - type: 'boolean', - }, - }, - type: 'object', - }, - ], - type: 'suggestion', - }, -}); diff --git a/tools/eslint/node_modules/eslint-plugin-jsdoc/src/rules/requireYieldsCheck.js b/tools/eslint/node_modules/eslint-plugin-jsdoc/src/rules/requireYieldsCheck.js deleted file mode 100644 index c356e7ea68963f..00000000000000 --- a/tools/eslint/node_modules/eslint-plugin-jsdoc/src/rules/requireYieldsCheck.js +++ /dev/null @@ -1,208 +0,0 @@ -import iterateJsdoc from '../iterateJsdoc.js'; - -/** - * @param {import('../iterateJsdoc.js').Utils} utils - * @param {import('../iterateJsdoc.js').Settings} settings - * @returns {boolean} - */ -const canSkip = (utils, settings) => { - const voidingTags = [ - // An abstract function is by definition incomplete - // so it is perfectly fine if a yield is documented but - // not present within the function. - // A subclass may inherit the doc and implement the - // missing yield. - 'abstract', - 'virtual', - - // Constructor functions do not have a yield value - // so we can bail here, too. - 'class', - 'constructor', - - // This seems to imply a class as well - 'interface', - ]; - - if (settings.mode === 'closure') { - // Structural Interface in GCC terms, equivalent to @interface tag as far as this rule is concerned - voidingTags.push('record'); - } - - return utils.hasATag(voidingTags) || - utils.isConstructor() || - utils.classHasTag('interface') || - settings.mode === 'closure' && utils.classHasTag('record'); -}; - -/** - * @param {import('../iterateJsdoc.js').Utils} utils - * @param {import('../iterateJsdoc.js').Report} report - * @param {string} tagName - * @returns {[]|[preferredTagName: string, tag: import('comment-parser').Spec]} - */ -const checkTagName = (utils, report, tagName) => { - const preferredTagName = /** @type {string} */ (utils.getPreferredTagName({ - tagName, - })); - if (!preferredTagName) { - return []; - } - - const tags = utils.getTags(preferredTagName); - - if (tags.length === 0) { - return []; - } - - if (tags.length > 1) { - report(`Found more than one @${preferredTagName} declaration.`); - - return []; - } - - return [ - preferredTagName, tags[0], - ]; -}; - -export default iterateJsdoc(({ - context, - report, - settings, - utils, -}) => { - if (canSkip(utils, settings)) { - return; - } - - const { - next = false, - checkGeneratorsOnly = false, - } = context.options[0] || {}; - - const [ - preferredYieldTagName, - yieldTag, - ] = checkTagName( - utils, report, 'yields', - ); - if (preferredYieldTagName) { - const shouldReportYields = () => { - if ( - /** @type {import('comment-parser').Spec} */ ( - yieldTag - ).type.trim() === 'never' - ) { - if (utils.hasYieldValue()) { - report(`JSDoc @${preferredYieldTagName} declaration set with "never" but yield expression is present in function.`); - } - - return false; - } - - if (checkGeneratorsOnly && !utils.isGenerator()) { - return true; - } - - return !utils.mayBeUndefinedTypeTag( - /** @type {import('comment-parser').Spec} */ - (yieldTag), - ) && !utils.hasYieldValue(); - }; - - // In case a yield value is declared in JSDoc, we also expect one in the code. - if (shouldReportYields()) { - report(`JSDoc @${preferredYieldTagName} declaration present but yield expression not available in function.`); - } - } - - if (next) { - const [ - preferredNextTagName, - nextTag, - ] = checkTagName( - utils, report, 'next', - ); - if (preferredNextTagName) { - const shouldReportNext = () => { - if ( - /** @type {import('comment-parser').Spec} */ ( - nextTag - ).type.trim() === 'never' - ) { - if (utils.hasYieldReturnValue()) { - report(`JSDoc @${preferredNextTagName} declaration set with "never" but yield expression with return value is present in function.`); - } - - return false; - } - - if (checkGeneratorsOnly && !utils.isGenerator()) { - return true; - } - - return !utils.mayBeUndefinedTypeTag( - /** @type {import('comment-parser').Spec} */ - (nextTag), - ) && !utils.hasYieldReturnValue(); - }; - - if (shouldReportNext()) { - report(`JSDoc @${preferredNextTagName} declaration present but yield expression with return value not available in function.`); - } - } - } -}, { - meta: { - docs: { - description: 'Requires a yield statement in function body if a `@yields` tag is specified in jsdoc comment.', - url: 'https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/require-yields-check.md#repos-sticky-header', - }, - schema: [ - { - additionalProperties: false, - properties: { - checkGeneratorsOnly: { - default: false, - type: 'boolean', - }, - contexts: { - items: { - anyOf: [ - { - type: 'string', - }, - { - additionalProperties: false, - properties: { - comment: { - type: 'string', - }, - context: { - type: 'string', - }, - }, - type: 'object', - }, - ], - }, - type: 'array', - }, - exemptedBy: { - items: { - type: 'string', - }, - type: 'array', - }, - next: { - default: false, - type: 'boolean', - }, - }, - type: 'object', - }, - ], - type: 'suggestion', - }, -}); diff --git a/tools/eslint/node_modules/eslint-plugin-jsdoc/src/rules/sortTags.js b/tools/eslint/node_modules/eslint-plugin-jsdoc/src/rules/sortTags.js deleted file mode 100644 index 3ce942b136110d..00000000000000 --- a/tools/eslint/node_modules/eslint-plugin-jsdoc/src/rules/sortTags.js +++ /dev/null @@ -1,557 +0,0 @@ -import defaultTagOrder from '../defaultTagOrder.js'; -import iterateJsdoc from '../iterateJsdoc.js'; - -// eslint-disable-next-line complexity -- Temporary -export default iterateJsdoc(({ - context, - jsdoc, - utils, -}) => { - const - /** - * @type {{ - * linesBetween: import('../iterateJsdoc.js').Integer, - * tagSequence: { - * tags: string[] - * }[], - * alphabetizeExtras: boolean, - * reportTagGroupSpacing: boolean, - * reportIntraTagGroupSpacing: boolean, - * }} - */ { - linesBetween = 1, - tagSequence = defaultTagOrder, - alphabetizeExtras = false, - reportTagGroupSpacing = true, - reportIntraTagGroupSpacing = true, - } = context.options[0] || {}; - - const tagList = tagSequence.flatMap((obj) => { - /* typeof obj === 'string' ? obj : */ - return obj.tags; - }); - - const otherPos = tagList.indexOf('-other'); - const endPos = otherPos > -1 ? otherPos : tagList.length; - - let ongoingCount = 0; - for (const [ - idx, - tag, - ] of - /** - * @type {( - * import('@es-joy/jsdoccomment').JsdocTagWithInline & { - * originalIndex: import('../iterateJsdoc.js').Integer, - * originalLine: import('../iterateJsdoc.js').Integer, - * } - * )[]} - */ (jsdoc.tags).entries()) { - tag.originalIndex = idx; - ongoingCount += tag.source.length; - tag.originalLine = ongoingCount; - } - - /** @type {import('../iterateJsdoc.js').Integer|undefined} */ - let firstChangedTagLine; - /** @type {import('../iterateJsdoc.js').Integer|undefined} */ - let firstChangedTagIndex; - - /** - * @type {(import('comment-parser').Spec & { - * originalIndex: import('../iterateJsdoc.js').Integer, - * originalLine: import('../iterateJsdoc.js').Integer, - * })[]} - */ - const sortedTags = JSON.parse(JSON.stringify(jsdoc.tags)); - sortedTags.sort(({ - tag: tagNew, - }, { - originalIndex, - originalLine, - tag: tagOld, - }) => { - // Optimize: Just keep relative positions if the same tag name - if (tagNew === tagOld) { - return 0; - } - - const checkOrSetFirstChanged = () => { - if (!firstChangedTagLine || originalLine < firstChangedTagLine) { - firstChangedTagLine = originalLine; - firstChangedTagIndex = originalIndex; - } - }; - - const newPos = tagList.indexOf(tagNew); - const oldPos = tagList.indexOf(tagOld); - - const preferredNewPos = newPos === -1 ? endPos : newPos; - const preferredOldPos = oldPos === -1 ? endPos : oldPos; - - if (preferredNewPos < preferredOldPos) { - checkOrSetFirstChanged(); - return -1; - } - - if (preferredNewPos > preferredOldPos) { - return 1; - } - - // preferredNewPos === preferredOldPos - if ( - !alphabetizeExtras || - - // Optimize: If tagNew (or tagOld which is the same) was found in the - // priority array, it can maintain its relative positionโ€”without need - // of alphabetizing (secondary sorting) - newPos >= 0 - ) { - return 0; - } - - if (tagNew < tagOld) { - checkOrSetFirstChanged(); - return -1; - } - - // tagNew > tagOld - return 1; - }); - - if (firstChangedTagLine === undefined) { - // Should be ordered by now - - /** - * @type {import('comment-parser').Spec[]} - */ - const lastTagsOfGroup = []; - - /** - * @type {[ - * import('comment-parser').Spec, - * import('../iterateJsdoc.js').Integer - * ][]} - */ - const badLastTagsOfGroup = []; - - /** - * @param {import('comment-parser').Spec} tag - */ - const countTagEmptyLines = (tag) => { - return tag.source.reduce((acc, { - tokens: { - description, - name, - type, - end, - tag: tg, - }, - }) => { - const empty = !tg && !type && !name && !description; - // Reset the count so long as there is content - return empty ? acc + Number(empty && !end) : 0; - }, 0); - }; - - let idx = 0; - for (const { - tags, - } of tagSequence) { - let innerIdx; - /** @type {import('comment-parser').Spec} */ - let currentTag; - /** @type {import('comment-parser').Spec|undefined} */ - let lastTag; - do { - currentTag = jsdoc.tags[idx]; - if (!currentTag) { - idx++; - break; - } - - innerIdx = tags.indexOf(currentTag.tag); - - if ( - innerIdx === -1 && - // eslint-disable-next-line no-loop-func -- Safe - (!tags.includes('-other') || tagSequence.some(({ - tags: tgs, - }) => { - return tgs.includes(currentTag.tag); - })) - ) { - idx++; - break; - } - - lastTag = currentTag; - - idx++; - } while (true); - - idx--; - - if (lastTag) { - lastTagsOfGroup.push(lastTag); - const ct = countTagEmptyLines(lastTag); - if ( - ct !== linesBetween && - // Use another rule for adding to end (should be of interest outside this rule) - jsdoc.tags[idx] - ) { - badLastTagsOfGroup.push([ - lastTag, ct, - ]); - } - } - } - - if (reportTagGroupSpacing && badLastTagsOfGroup.length) { - /** - * @param {import('comment-parser').Spec} tg - * @returns {() => void} - */ - const fixer = (tg) => { - return () => { - // Due to https://github.com/syavorsky/comment-parser/issues/110 , - // we have to modify `jsdoc.source` rather than just modify tags - // directly - for (const [ - currIdx, - { - tokens, - }, - ] of jsdoc.source.entries()) { - if (tokens.tag !== '@' + tg.tag) { - continue; - } - - // Cannot be `tokens.end`, as dropped off last tag, so safe to - // go on - let newIdx = currIdx; - - const emptyLine = () => { - return { - number: 0, - source: '', - tokens: utils.seedTokens({ - delimiter: '*', - start: jsdoc.source[newIdx - 1].tokens.start, - }), - }; - }; - - let existingEmptyLines = 0; - while (true) { - const nextTokens = jsdoc.source[++newIdx]?.tokens; - - /* c8 ignore next 3 -- Guard */ - if (!nextTokens) { - return; - } - - // Should be no `nextTokens.end` to worry about since ignored - // if not followed by tag - - if (nextTokens.tag) { - // Haven't made it to last tag instance yet, so keep looking - if (nextTokens.tag === tokens.tag) { - existingEmptyLines = 0; - continue; - } - - const lineDiff = linesBetween - existingEmptyLines; - if (lineDiff > 0) { - const lines = Array.from({ - length: lineDiff, - }, () => { - return emptyLine(); - }); - jsdoc.source.splice(newIdx, 0, ...lines); - } else { - // lineDiff < 0 - jsdoc.source.splice( - newIdx + lineDiff, - -lineDiff, - ); - } - - break; - } - - const empty = !nextTokens.type && !nextTokens.name && - !nextTokens.description; - - if (empty) { - existingEmptyLines++; - } else { - // Has content again, so reset empty line count - existingEmptyLines = 0; - } - } - - break; - } - - for (const [ - srcIdx, - src, - ] of jsdoc.source.entries()) { - src.number = srcIdx; - } - }; - }; - - for (const [ - tg, - ] of badLastTagsOfGroup) { - utils.reportJSDoc( - 'Tag groups do not have the expected whitespace', - tg, - fixer(tg), - ); - } - - return; - } - - if (!reportIntraTagGroupSpacing) { - return; - } - - for (const [ - tagIdx, - tag, - ] of jsdoc.tags.entries()) { - if (!jsdoc.tags[tagIdx + 1] || lastTagsOfGroup.includes(tag)) { - continue; - } - - const ct = countTagEmptyLines(tag); - if (ct) { - // eslint-disable-next-line complexity -- Temporary - const fixer = () => { - let foundFirstTag = false; - - /** @type {string|undefined} */ - let currentTag; - - for (const [ - currIdx, - { - tokens: { - description, - name, - type, - end, - tag: tg, - }, - }, - ] of jsdoc.source.entries()) { - if (tg) { - foundFirstTag = true; - currentTag = tg; - } - - if (!foundFirstTag) { - continue; - } - - if (currentTag && !tg && !type && !name && !description && !end) { - let nextIdx = currIdx; - - let ignore = true; - // Even if a tag of the same name as the last tags in a group, - // could still be an earlier tag in that group - - // eslint-disable-next-line no-loop-func -- Safe - if (lastTagsOfGroup.some((lastTagOfGroup) => { - return currentTag === '@' + lastTagOfGroup.tag; - })) { - while (true) { - const nextTokens = jsdoc.source[++nextIdx]?.tokens; - if (!nextTokens) { - break; - } - - if (!nextTokens.tag) { - continue; - } - - // Followed by the same tag name, so not actually last in group, - // and of interest - if (nextTokens.tag === currentTag) { - ignore = false; - } - } - } else { - while (true) { - const nextTokens = jsdoc.source[++nextIdx]?.tokens; - if (!nextTokens || nextTokens.end) { - break; - } - - // Not the very last tag, so don't ignore - if (nextTokens.tag) { - ignore = false; - break; - } - } - } - - if (!ignore) { - jsdoc.source.splice(currIdx, 1); - for (const [ - srcIdx, - src, - ] of jsdoc.source.entries()) { - src.number = srcIdx; - } - } - } - } - }; - - utils.reportJSDoc( - 'Intra-group tags have unexpected whitespace', - tag, - fixer, - ); - } - } - - return; - } - - const firstLine = utils.getFirstLine(); - - const fix = () => { - const itemsToMoveRange = [ - ...Array.from({ - length: jsdoc.tags.length - - /** @type {import('../iterateJsdoc.js').Integer} */ ( - firstChangedTagIndex - ), - }).keys(), - ]; - - const unchangedPriorTagDescriptions = jsdoc.tags.slice( - 0, - firstChangedTagIndex, - ).reduce((ct, { - source, - }) => { - return ct + source.length - 1; - }, 0); - - // This offset includes not only the offset from where the first tag - // must begin, and the additional offset of where the first changed - // tag begins, but it must also account for prior descriptions - const initialOffset = /** @type {import('../iterateJsdoc.js').Integer} */ ( - firstLine - ) + /** @type {import('../iterateJsdoc.js').Integer} */ (firstChangedTagIndex) + - - // May be the first tag, so don't try finding a prior one if so - unchangedPriorTagDescriptions; - - // Use `firstChangedTagLine` for line number to begin reporting/splicing - for (const idx of itemsToMoveRange) { - utils.removeTag( - idx + - /** @type {import('../iterateJsdoc.js').Integer} */ ( - firstChangedTagIndex - ), - ); - } - - const changedTags = sortedTags.slice(firstChangedTagIndex); - let extraTagCount = 0; - - for (const idx of itemsToMoveRange) { - const changedTag = changedTags[idx]; - - utils.addTag( - changedTag.tag, - extraTagCount + initialOffset + idx, - { - ...changedTag.source[0].tokens, - - // `comment-parser` puts the `end` within the `tags` section, so - // avoid adding another to jsdoc.source - end: '', - }, - ); - - for (const { - tokens, - } of changedTag.source.slice(1)) { - if (!tokens.end) { - utils.addLine( - extraTagCount + initialOffset + idx + 1, - { - ...tokens, - end: '', - }, - ); - extraTagCount++; - } - } - } - }; - - utils.reportJSDoc( - `Tags are not in the prescribed order: ${ - tagList.join(', ') || '(alphabetical)' - }`, - jsdoc.tags[/** @type {import('../iterateJsdoc.js').Integer} */ ( - firstChangedTagIndex - )], - fix, - true, - ); -}, { - iterateAllJsdocs: true, - meta: { - docs: { - description: 'Sorts tags by a specified sequence according to tag name.', - url: 'https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/sort-tags.md#repos-sticky-header', - }, - fixable: 'code', - schema: [ - { - additionalProperties: false, - properties: { - alphabetizeExtras: { - type: 'boolean', - }, - linesBetween: { - type: 'integer', - }, - reportIntraTagGroupSpacing: { - type: 'boolean', - }, - reportTagGroupSpacing: { - type: 'boolean', - }, - tagSequence: { - items: { - properties: { - tags: { - items: { - type: 'string', - }, - type: 'array', - }, - }, - type: 'object', - }, - type: 'array', - }, - }, - type: 'object', - }, - ], - type: 'suggestion', - }, -}); diff --git a/tools/eslint/node_modules/eslint-plugin-jsdoc/src/rules/tagLines.js b/tools/eslint/node_modules/eslint-plugin-jsdoc/src/rules/tagLines.js deleted file mode 100644 index 0e34ed31c4cb6a..00000000000000 --- a/tools/eslint/node_modules/eslint-plugin-jsdoc/src/rules/tagLines.js +++ /dev/null @@ -1,359 +0,0 @@ -import iterateJsdoc from '../iterateJsdoc.js'; - -export default iterateJsdoc(({ - context, - jsdoc, - utils, -}) => { - const [ - alwaysNever = 'never', - { - count = 1, - endLines = 0, - startLines = 0, - applyToEndTag = true, - tags = {}, - } = {}, - ] = context.options; - - // eslint-disable-next-line complexity -- Temporary - jsdoc.tags.some((tg, tagIdx) => { - let lastTag; - - /** - * @type {null|import('../iterateJsdoc.js').Integer} - */ - let lastEmpty = null; - - /** - * @type {null|import('../iterateJsdoc.js').Integer} - */ - let reportIndex = null; - let emptyLinesCount = 0; - for (const [ - idx, - { - tokens: { - tag, - name, - type, - description, - end, - }, - }, - ] of tg.source.entries()) { - // May be text after a line break within a tag description - if (description) { - reportIndex = null; - } - - if (lastTag && [ - 'any', 'always', - ].includes(tags[lastTag.slice(1)]?.lines)) { - continue; - } - - const empty = !tag && !name && !type && !description; - if ( - empty && !end && - (alwaysNever === 'never' || - lastTag && tags[lastTag.slice(1)]?.lines === 'never' - ) - ) { - reportIndex = idx; - - continue; - } - - if (!end) { - if (empty) { - emptyLinesCount++; - } else { - emptyLinesCount = 0; - } - - lastEmpty = empty ? idx : null; - } - - lastTag = tag; - } - - if ( - typeof endLines === 'number' && - lastEmpty !== null && tagIdx === jsdoc.tags.length - 1 - ) { - const lineDiff = endLines - emptyLinesCount; - - if (lineDiff < 0) { - const fixer = () => { - utils.removeTag(tagIdx, { - tagSourceOffset: /** @type {import('../iterateJsdoc.js').Integer} */ ( - lastEmpty - ) + lineDiff + 1, - }); - }; - - utils.reportJSDoc( - `Expected ${endLines} trailing lines`, - { - line: tg.source[lastEmpty].number + lineDiff + 1, - }, - fixer, - ); - } else if (lineDiff > 0) { - const fixer = () => { - utils.addLines( - tagIdx, - /** @type {import('../iterateJsdoc.js').Integer} */ (lastEmpty), - endLines - emptyLinesCount, - ); - }; - - utils.reportJSDoc( - `Expected ${endLines} trailing lines`, - { - line: tg.source[lastEmpty].number, - }, - fixer, - ); - } - - return true; - } - - if (reportIndex !== null) { - const fixer = () => { - utils.removeTag(tagIdx, { - tagSourceOffset: /** @type {import('../iterateJsdoc.js').Integer} */ ( - reportIndex - ), - }); - }; - - utils.reportJSDoc( - 'Expected no lines between tags', - { - line: tg.source[0].number + 1, - }, - fixer, - ); - - return true; - } - - return false; - }); - - (applyToEndTag ? jsdoc.tags : jsdoc.tags.slice(0, -1)).some((tg, tagIdx) => { - /** - * @type {{ - * idx: import('../iterateJsdoc.js').Integer, - * number: import('../iterateJsdoc.js').Integer - * }[]} - */ - const lines = []; - - let currentTag; - let tagSourceIdx = 0; - for (const [ - idx, - { - number, - tokens: { - tag, - name, - type, - description, - end, - }, - }, - ] of tg.source.entries()) { - if (description) { - lines.splice(0, lines.length); - tagSourceIdx = idx; - } - - if (tag) { - currentTag = tag; - } - - if (!tag && !name && !type && !description && !end) { - lines.push({ - idx, - number, - }); - } - } - - const currentTg = currentTag && tags[currentTag.slice(1)]; - const tagCount = currentTg?.count; - - const defaultAlways = alwaysNever === 'always' && currentTg?.lines !== 'never' && - currentTg?.lines !== 'any' && lines.length < count; - - let overrideAlways; - let fixCount = count; - if (!defaultAlways) { - fixCount = typeof tagCount === 'number' ? tagCount : count; - overrideAlways = currentTg?.lines === 'always' && - lines.length < fixCount; - } - - if (defaultAlways || overrideAlways) { - const fixer = () => { - utils.addLines(tagIdx, lines[lines.length - 1]?.idx || tagSourceIdx + 1, fixCount - lines.length); - }; - - const line = lines[lines.length - 1]?.number || tg.source[tagSourceIdx].number; - utils.reportJSDoc( - `Expected ${fixCount} line${fixCount === 1 ? '' : 's'} between tags but found ${lines.length}`, - { - line, - }, - fixer, - ); - - return true; - } - - return false; - }); - - if (typeof startLines === 'number') { - if (!jsdoc.tags.length) { - return; - } - - const { - description, - lastDescriptionLine, - } = utils.getDescription(); - if (!(/\S/u).test(description)) { - return; - } - - const trailingLines = description.match(/\n+$/u)?.[0]?.length; - const trailingDiff = (trailingLines ?? 0) - startLines; - if (trailingDiff > 0) { - utils.reportJSDoc( - `Expected only ${startLines} line after block description`, - { - line: lastDescriptionLine - trailingDiff, - }, - () => { - utils.setBlockDescription((info, seedTokens, descLines) => { - return descLines.slice(0, -trailingDiff).map((desc) => { - return { - number: 0, - source: '', - tokens: seedTokens({ - ...info, - description: desc, - postDelimiter: desc.trim() ? info.postDelimiter : '', - }), - }; - }); - }); - }, - ); - } else if (trailingDiff < 0) { - utils.reportJSDoc( - `Expected ${startLines} lines after block description`, - { - line: lastDescriptionLine, - }, - () => { - utils.setBlockDescription((info, seedTokens, descLines) => { - return [ - ...descLines, - ...Array.from({ - length: -trailingDiff, - }, () => { - return ''; - }), - ].map((desc) => { - return { - number: 0, - source: '', - tokens: seedTokens({ - ...info, - description: desc, - postDelimiter: desc.trim() ? info.postDelimiter : '', - }), - }; - }); - }); - }, - ); - } - } -}, { - iterateAllJsdocs: true, - meta: { - docs: { - description: 'Enforces lines (or no lines) between tags.', - url: 'https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/tag-lines.md#repos-sticky-header', - }, - fixable: 'code', - schema: [ - { - enum: [ - 'always', 'any', 'never', - ], - type: 'string', - }, - { - additionalProperties: false, - properties: { - applyToEndTag: { - type: 'boolean', - }, - count: { - type: 'integer', - }, - endLines: { - anyOf: [ - { - type: 'integer', - }, - { - type: 'null', - }, - ], - }, - startLines: { - anyOf: [ - { - type: 'integer', - }, - { - type: 'null', - }, - ], - }, - tags: { - patternProperties: { - '.*': { - additionalProperties: false, - properties: { - count: { - type: 'integer', - }, - lines: { - enum: [ - 'always', 'never', 'any', - ], - type: 'string', - }, - }, - }, - }, - type: 'object', - }, - }, - type: 'object', - }, - ], - type: 'suggestion', - }, -}); diff --git a/tools/eslint/node_modules/eslint-plugin-jsdoc/src/rules/textEscaping.js b/tools/eslint/node_modules/eslint-plugin-jsdoc/src/rules/textEscaping.js deleted file mode 100644 index 2486ad81af65c3..00000000000000 --- a/tools/eslint/node_modules/eslint-plugin-jsdoc/src/rules/textEscaping.js +++ /dev/null @@ -1,146 +0,0 @@ -import iterateJsdoc from '../iterateJsdoc.js'; - -// We could disallow raw gt, quot, and apos, but allow for parity; but we do -// not allow hex or decimal character references -const htmlRegex = /(<|&(?!(?:amp|lt|gt|quot|apos);))(?=\S)/u; -const markdownRegex = /(? { - return desc.replaceAll(new RegExp(htmlRegex, 'gu'), (_) => { - if (_ === '<') { - return '<'; - } - - return '&'; - }); -}; - -/** - * @param {string} desc - * @returns {string} - */ -const markdownReplacer = (desc) => { - return desc.replaceAll(new RegExp(markdownRegex, 'gu'), (_, backticks, encapsed) => { - const bookend = '`'.repeat(backticks.length); - return `\\${bookend}${encapsed}${bookend}`; - }); -}; - -export default iterateJsdoc(({ - context, - jsdoc, - utils, -}) => { - const { - escapeHTML, - escapeMarkdown, - } = context.options[0] || {}; - - if (!escapeHTML && !escapeMarkdown) { - context.report({ - loc: { - end: { - column: 1, - line: 1, - }, - start: { - column: 1, - line: 1, - }, - }, - message: 'You must include either `escapeHTML` or `escapeMarkdown`', - }); - return; - } - - const { - descriptions, - } = utils.getDescription(); - - if (escapeHTML) { - if (descriptions.some((desc) => { - return htmlRegex.test(desc); - })) { - const line = utils.setDescriptionLines(htmlRegex, htmlReplacer); - utils.reportJSDoc('You have unescaped HTML characters < or &', { - line, - }, () => {}, true); - return; - } - - for (const tag of jsdoc.tags) { - if (/** @type {string[]} */ ( - utils.getTagDescription(tag, true) - ).some((desc) => { - return htmlRegex.test(desc); - })) { - const line = utils.setTagDescription(tag, htmlRegex, htmlReplacer) + - tag.source[0].number; - utils.reportJSDoc('You have unescaped HTML characters < or & in a tag', { - line, - }, () => {}, true); - } - } - - return; - } - - if (descriptions.some((desc) => { - return markdownRegex.test(desc); - })) { - const line = utils.setDescriptionLines(markdownRegex, markdownReplacer); - utils.reportJSDoc('You have unescaped Markdown backtick sequences', { - line, - }, () => {}, true); - return; - } - - for (const tag of jsdoc.tags) { - if (/** @type {string[]} */ ( - utils.getTagDescription(tag, true) - ).some((desc) => { - return markdownRegex.test(desc); - })) { - const line = utils.setTagDescription( - tag, markdownRegex, markdownReplacer, - ) + tag.source[0].number; - utils.reportJSDoc( - 'You have unescaped Markdown backtick sequences in a tag', - { - line, - }, - () => {}, - true, - ); - } - } -}, { - iterateAllJsdocs: true, - meta: { - docs: { - description: '', - url: 'https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/text-escaping.md#repos-sticky-header', - }, - fixable: 'code', - schema: [ - { - additionalProperties: false, - properties: { - // Option properties here (or remove the object) - escapeHTML: { - type: 'boolean', - }, - escapeMarkdown: { - type: 'boolean', - }, - }, - type: 'object', - }, - ], - type: 'suggestion', - }, -}); diff --git a/tools/eslint/node_modules/eslint-plugin-jsdoc/src/rules/validTypes.js b/tools/eslint/node_modules/eslint-plugin-jsdoc/src/rules/validTypes.js deleted file mode 100644 index 8c1839bf3b8bb2..00000000000000 --- a/tools/eslint/node_modules/eslint-plugin-jsdoc/src/rules/validTypes.js +++ /dev/null @@ -1,384 +0,0 @@ -import iterateJsdoc from '../iterateJsdoc.js'; -import { - parse, - traverse, - tryParse, -} from '@es-joy/jsdoccomment'; - -const inlineTags = new Set([ - 'link', 'linkcode', 'linkplain', - 'tutorial', -]); - -const jsdocTypePrattKeywords = new Set([ - 'typeof', - 'readonly', - 'import', - 'is', -]); - -const asExpression = /as\s+/u; - -const suppressTypes = new Set([ - // https://github.com/google/closure-compiler/wiki/@suppress-annotations - // https://github.com/google/closure-compiler/blob/master/src/com/google/javascript/jscomp/parsing/ParserConfig.properties#L154 - 'accessControls', - 'checkDebuggerStatement', - 'checkPrototypalTypes', - 'checkRegExp', - 'checkTypes', - 'checkVars', - 'closureDepMethodUsageChecks', - 'const', - 'constantProperty', - 'deprecated', - 'duplicate', - 'es5Strict', - 'externsValidation', - 'extraProvide', - 'extraRequire', - 'globalThis', - 'invalidCasts', - 'lateProvide', - 'legacyGoogScopeRequire', - 'lintChecks', - 'messageConventions', - 'misplacedTypeAnnotation', - 'missingOverride', - 'missingPolyfill', - 'missingProperties', - 'missingProvide', - 'missingRequire', - 'missingSourcesWarnings', - 'moduleLoad', - 'nonStandardJsDocs', - 'partialAlias', - 'polymer', - 'reportUnknownTypes', - 'strictMissingProperties', - 'strictModuleDepCheck', - 'strictPrimitiveOperators', - 'suspiciousCode', - - // Not documented in enum - 'switch', - 'transitionalSuspiciousCodeWarnings', - 'undefinedNames', - 'undefinedVars', - 'underscore', - 'unknownDefines', - 'untranspilableFeatures', - 'unusedLocalVariables', - 'unusedPrivateMembers', - 'useOfGoogProvide', - 'uselessCode', - 'visibility', - 'with', -]); - -/** - * @param {string} path - * @returns {boolean} - */ -const tryParsePathIgnoreError = (path) => { - try { - tryParse(path); - - return true; - } catch { - // Keep the original error for including the whole type - } - - return false; -}; - -// eslint-disable-next-line complexity -export default iterateJsdoc(({ - jsdoc, - report, - utils, - context, - settings, -}) => { - const { - allowEmptyNamepaths = false, - } = context.options[0] || {}; - const { - mode, - } = settings; - - for (const tag of jsdoc.tags) { - /** - * @param {string} namepath - * @param {string} [tagName] - * @returns {boolean} - */ - const validNamepathParsing = function (namepath, tagName) { - if ( - tryParsePathIgnoreError(namepath) || - jsdocTypePrattKeywords.has(namepath) - ) { - return true; - } - - let handled = false; - - if (tagName) { - switch (tagName) { - case 'requires': - case 'module': { - if (!namepath.startsWith('module:')) { - handled = tryParsePathIgnoreError(`module:${namepath}`); - } - - break; - } - - case 'memberof': case 'memberof!': { - const endChar = namepath.slice(-1); - if ([ - '#', '.', '~', - ].includes(endChar)) { - handled = tryParsePathIgnoreError(namepath.slice(0, -1)); - } - - break; - } - - case 'borrows': { - const startChar = namepath.charAt(0); - if ([ - '#', '.', '~', - ].includes(startChar)) { - handled = tryParsePathIgnoreError(namepath.slice(1)); - } - } - } - } - - if (!handled) { - report(`Syntax error in namepath: ${namepath}`, null, tag); - - return false; - } - - return true; - }; - - /** - * @param {string} type - * @returns {boolean} - */ - const validTypeParsing = function (type) { - let parsedTypes; - try { - if (mode === 'permissive') { - parsedTypes = tryParse(type); - } else { - parsedTypes = parse(type, mode); - } - } catch { - report(`Syntax error in type: ${type}`, null, tag); - - return false; - } - - if (mode === 'closure' || mode === 'typescript') { - traverse(parsedTypes, (node) => { - const { - type: typ, - } = node; - - if ( - (typ === 'JsdocTypeObjectField' || typ === 'JsdocTypeKeyValue') && - node.right?.type === 'JsdocTypeNullable' && - node.right?.meta?.position === 'suffix' - ) { - report(`Syntax error in type: ${node.right.type}`, null, tag); - } - }); - } - - return true; - }; - - if (tag.problems.length) { - const msg = tag.problems.reduce((str, { - message, - }) => { - return str + '; ' + message; - }, '').slice(2); - report(`Invalid name: ${msg}`, null, tag); - continue; - } - - if (tag.tag === 'import') { - // A named import will look like a type, but not be valid; we also don't - // need to check the name/namepath - continue; - } - - if (tag.tag === 'borrows') { - const thisNamepath = /** @type {string} */ ( - utils.getTagDescription(tag) - ).replace(asExpression, '') - .trim(); - - if (!asExpression.test(/** @type {string} */ ( - utils.getTagDescription(tag) - )) || !thisNamepath) { - report(`@borrows must have an "as" expression. Found "${utils.getTagDescription(tag)}"`, null, tag); - - continue; - } - - if (validNamepathParsing(thisNamepath, 'borrows')) { - const thatNamepath = tag.name; - - validNamepathParsing(thatNamepath); - } - - continue; - } - - if (tag.tag === 'suppress' && mode === 'closure') { - let parsedTypes; - - try { - parsedTypes = tryParse(tag.type); - } catch { - // Ignore - } - - if (parsedTypes) { - traverse(parsedTypes, (node) => { - let type; - if ('value' in node && typeof node.value === 'string') { - type = node.value; - } - - if (type !== undefined && !suppressTypes.has(type)) { - report(`Syntax error in suppress type: ${type}`, null, tag); - } - }); - } - } - - const otherModeMaps = /** @type {import('../jsdocUtils.js').ParserMode[]} */ ([ - 'jsdoc', 'typescript', 'closure', 'permissive', - ]).filter( - (mde) => { - return mde !== mode; - }, - ).map((mde) => { - return utils.getTagStructureForMode(mde); - }); - - const tagMightHaveNamePosition = utils.tagMightHaveNamePosition(tag.tag, otherModeMaps); - if (tagMightHaveNamePosition !== true && tag.name) { - const modeInfo = tagMightHaveNamePosition === false ? '' : ` in "${mode}" mode`; - report(`@${tag.tag} should not have a name${modeInfo}.`, null, tag); - - continue; - } - - const mightHaveTypePosition = utils.tagMightHaveTypePosition(tag.tag, otherModeMaps); - if (mightHaveTypePosition !== true && tag.type) { - const modeInfo = mightHaveTypePosition === false ? '' : ` in "${mode}" mode`; - report(`@${tag.tag} should not have a bracketed type${modeInfo}.`, null, tag); - - continue; - } - - // REQUIRED NAME - const tagMustHaveNamePosition = utils.tagMustHaveNamePosition(tag.tag, otherModeMaps); - - // Don't handle `@param` here though it does require name as handled by - // `require-param-name` (`@property` would similarly seem to require one, - // but is handled by `require-property-name`) - if (tagMustHaveNamePosition !== false && !tag.name && !allowEmptyNamepaths && ![ - 'param', 'arg', 'argument', - 'property', 'prop', - ].includes(tag.tag) && - (tag.tag !== 'see' || !utils.getTagDescription(tag).includes('{@link')) - ) { - const modeInfo = tagMustHaveNamePosition === true ? '' : ` in "${mode}" mode`; - report(`Tag @${tag.tag} must have a name/namepath${modeInfo}.`, null, tag); - - continue; - } - - // REQUIRED TYPE - const mustHaveTypePosition = utils.tagMustHaveTypePosition(tag.tag, otherModeMaps); - if (mustHaveTypePosition !== false && !tag.type) { - const modeInfo = mustHaveTypePosition === true ? '' : ` in "${mode}" mode`; - report(`Tag @${tag.tag} must have a type${modeInfo}.`, null, tag); - - continue; - } - - // REQUIRED TYPE OR NAME/NAMEPATH - const tagMissingRequiredTypeOrNamepath = utils.tagMissingRequiredTypeOrNamepath(tag, otherModeMaps); - if (tagMissingRequiredTypeOrNamepath !== false && !allowEmptyNamepaths) { - const modeInfo = tagMissingRequiredTypeOrNamepath === true ? '' : ` in "${mode}" mode`; - report(`Tag @${tag.tag} must have either a type or namepath${modeInfo}.`, null, tag); - - continue; - } - - // VALID TYPE - const hasTypePosition = mightHaveTypePosition === true && Boolean(tag.type); - if (hasTypePosition) { - validTypeParsing(tag.type); - } - - // VALID NAME/NAMEPATH - const hasNameOrNamepathPosition = ( - tagMustHaveNamePosition !== false || - utils.tagMightHaveNamepath(tag.tag) - ) && Boolean(tag.name); - - if (hasNameOrNamepathPosition) { - if (mode !== 'jsdoc' && tag.tag === 'template') { - for (const namepath of utils.parseClosureTemplateTag(tag)) { - validNamepathParsing(namepath); - } - } else { - validNamepathParsing(tag.name, tag.tag); - } - } - - for (const inlineTag of tag.inlineTags) { - if (inlineTags.has(inlineTag.tag) && !inlineTag.text && !inlineTag.namepathOrURL) { - report(`Inline tag "${inlineTag.tag}" missing content`, null, tag); - } - } - } - - for (const inlineTag of jsdoc.inlineTags) { - if (inlineTags.has(inlineTag.tag) && !inlineTag.text && !inlineTag.namepathOrURL) { - report(`Inline tag "${inlineTag.tag}" missing content`); - } - } -}, { - iterateAllJsdocs: true, - meta: { - docs: { - description: 'Requires all types to be valid JSDoc or Closure compiler types without syntax errors.', - url: 'https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/valid-types.md#repos-sticky-header', - }, - schema: [ - { - additionalProperties: false, - properties: { - allowEmptyNamepaths: { - default: false, - type: 'boolean', - }, - }, - type: 'object', - }, - ], - type: 'suggestion', - }, -}); diff --git a/tools/eslint/node_modules/eslint-plugin-jsdoc/src/tagNames.js b/tools/eslint/node_modules/eslint-plugin-jsdoc/src/tagNames.js deleted file mode 100644 index 6e80840b1e6e9a..00000000000000 --- a/tools/eslint/node_modules/eslint-plugin-jsdoc/src/tagNames.js +++ /dev/null @@ -1,238 +0,0 @@ -/** - * @typedef {{ - * [key: string]: string[] - * }} AliasedTags - */ - -/** - * @type {AliasedTags} - */ -const jsdocTagsUndocumented = { - // Undocumented but present; see - // https://github.com/jsdoc/jsdoc/issues/1283#issuecomment-516816802 - // https://github.com/jsdoc/jsdoc/blob/master/packages/jsdoc/lib/jsdoc/tag/dictionary/definitions.js#L594 - modifies: [], -}; - -/** - * @type {AliasedTags} - */ -const jsdocTags = { - ...jsdocTagsUndocumented, - abstract: [ - 'virtual', - ], - access: [], - alias: [], - async: [], - augments: [ - 'extends', - ], - author: [], - borrows: [], - callback: [], - class: [ - 'constructor', - ], - classdesc: [], - constant: [ - 'const', - ], - constructs: [], - copyright: [], - default: [ - 'defaultvalue', - ], - deprecated: [], - description: [ - 'desc', - ], - enum: [], - event: [], - example: [], - exports: [], - external: [ - 'host', - ], - file: [ - 'fileoverview', - 'overview', - ], - fires: [ - 'emits', - ], - function: [ - 'func', - 'method', - ], - generator: [], - global: [], - hideconstructor: [], - ignore: [], - implements: [], - inheritdoc: [], - - // Allowing casing distinct from jsdoc `definitions.js` (required in Closure) - inheritDoc: [], - - inner: [], - instance: [], - interface: [], - kind: [], - lends: [], - license: [], - listens: [], - member: [ - 'var', - ], - memberof: [], - 'memberof!': [], - mixes: [], - mixin: [], - - module: [], - name: [], - namespace: [], - override: [], - package: [], - param: [ - 'arg', - 'argument', - ], - private: [], - property: [ - 'prop', - ], - protected: [], - public: [], - readonly: [], - requires: [], - returns: [ - 'return', - ], - see: [], - since: [], - static: [], - summary: [], - - this: [], - throws: [ - 'exception', - ], - todo: [], - tutorial: [], - type: [], - typedef: [], - variation: [], - version: [], - yields: [ - 'yield', - ], -}; - -/** - * @type {AliasedTags} - */ -const typeScriptTags = { - ...jsdocTags, - - // https://github.com/microsoft/TypeScript/issues/22160 - // https://devblogs.microsoft.com/typescript/announcing-typescript-5-5/#the-jsdoc-import-tag - import: [], - - // https://www.typescriptlang.org/tsconfig/#stripInternal - internal: [], - - // https://devblogs.microsoft.com/typescript/announcing-typescript-5-0/#overload-support-in-jsdoc - overload: [], - - // https://devblogs.microsoft.com/typescript/announcing-typescript-5-0/#satisfies-support-in-jsdoc - satisfies: [], - - // `@template` is also in TypeScript per: - // https://www.typescriptlang.org/docs/handbook/type-checking-javascript-files.html#supported-jsdoc - template: [], -}; - -/** - * @type {AliasedTags} - */ -const undocumentedClosureTags = { - // These are in Closure source but not in jsdoc source nor in the Closure - // docs: https://github.com/google/closure-compiler/blob/master/src/com/google/javascript/jscomp/parsing/Annotation.java - closurePrimitive: [], - customElement: [], - expose: [], - hidden: [], - idGenerator: [], - meaning: [], - mixinClass: [], - mixinFunction: [], - ngInject: [], - owner: [], - typeSummary: [], - wizaction: [], -}; - -const { - /* eslint-disable no-unused-vars */ - inheritdoc, - internal, - overload, - satisfies, - - // Will be inverted to prefer `return` - returns, - /* eslint-enable no-unused-vars */ - ...typeScriptTagsInClosure -} = typeScriptTags; - -/** - * @type {AliasedTags} - */ -const closureTags = { - ...typeScriptTagsInClosure, - ...undocumentedClosureTags, - - // From https://github.com/google/closure-compiler/wiki/Annotating-JavaScript-for-the-Closure-Compiler - // These are all recognized in https://github.com/jsdoc/jsdoc/blob/master/packages/jsdoc/lib/jsdoc/tag/dictionary/definitions.js - // except for the experimental `noinline` and the casing differences noted below - - // Defined as a synonym of `const` in jsdoc `definitions.js` - define: [], - - dict: [], - export: [], - externs: [], - final: [], - - // With casing distinct from jsdoc `definitions.js` - implicitCast: [], - - noalias: [], - nocollapse: [], - nocompile: [], - noinline: [], - nosideeffects: [], - polymer: [], - polymerBehavior: [], - preserve: [], - - // Defined as a synonym of `interface` in jsdoc `definitions.js` - record: [], - - return: [ - 'returns', - ], - - struct: [], - suppress: [], - - unrestricted: [], -}; - -export { - closureTags, - jsdocTags, - typeScriptTags, -}; diff --git a/tools/eslint/node_modules/eslint-plugin-jsdoc/src/utils/hasReturnValue.js b/tools/eslint/node_modules/eslint-plugin-jsdoc/src/utils/hasReturnValue.js deleted file mode 100644 index 9f370c36f94e0d..00000000000000 --- a/tools/eslint/node_modules/eslint-plugin-jsdoc/src/utils/hasReturnValue.js +++ /dev/null @@ -1,549 +0,0 @@ -/** - * @typedef {import('estree').Node| - * import('@typescript-eslint/types').TSESTree.Node} ESTreeOrTypeScriptNode - */ - -/** - * Checks if a node is a promise but has no resolve value or an empty value. - * An `undefined` resolve does not count. - * @param {ESTreeOrTypeScriptNode|undefined|null} node - * @returns {boolean|undefined|null} - */ -const isNewPromiseExpression = (node) => { - return node && node.type === 'NewExpression' && node.callee.type === 'Identifier' && - node.callee.name === 'Promise'; -}; - -/** - * @param {ESTreeOrTypeScriptNode|null|undefined} node - * @returns {boolean} - */ -const isVoidPromise = (node) => { - return /** @type {import('@typescript-eslint/types').TSESTree.TSTypeReference} */ (node)?.typeArguments?.params?.[0]?.type === 'TSVoidKeyword' - /* c8 ignore next */ - || /** @type {import('@typescript-eslint/types').TSESTree.TSTypeReference} */ (node)?.typeParameters?.params?.[0]?.type === 'TSVoidKeyword'; -}; - -const undefinedKeywords = new Set([ - 'TSVoidKeyword', 'TSUndefinedKeyword', 'TSNeverKeyword', -]); - -/** - * Checks if a node has a return statement. Void return does not count. - * @param {ESTreeOrTypeScriptNode|undefined|null} node - * @param {boolean} [throwOnNullReturn] - * @param {PromiseFilter} [promFilter] - * @returns {boolean|undefined} - */ -// eslint-disable-next-line complexity -const hasReturnValue = (node, throwOnNullReturn, promFilter) => { - if (!node) { - return false; - } - - switch (node.type) { - case 'TSDeclareFunction': - case 'TSFunctionType': - case 'TSMethodSignature': { - const type = node?.returnType?.typeAnnotation?.type; - return type && !undefinedKeywords.has(type); - } - - case 'MethodDefinition': - return hasReturnValue(node.value, throwOnNullReturn, promFilter); - case 'FunctionExpression': - case 'FunctionDeclaration': - case 'ArrowFunctionExpression': { - return 'expression' in node && node.expression && (!isNewPromiseExpression( - node.body, - ) || !isVoidPromise(node.body)) || - hasReturnValue(node.body, throwOnNullReturn, promFilter); - } - - case 'BlockStatement': { - return node.body.some((bodyNode) => { - return bodyNode.type !== 'FunctionDeclaration' && hasReturnValue(bodyNode, throwOnNullReturn, promFilter); - }); - } - - case 'LabeledStatement': - case 'WhileStatement': - case 'DoWhileStatement': - case 'ForStatement': - case 'ForInStatement': - case 'ForOfStatement': - case 'WithStatement': { - return hasReturnValue(node.body, throwOnNullReturn, promFilter); - } - - case 'IfStatement': { - return hasReturnValue(node.consequent, throwOnNullReturn, promFilter) || - hasReturnValue(node.alternate, throwOnNullReturn, promFilter); - } - - case 'TryStatement': { - return hasReturnValue(node.block, throwOnNullReturn, promFilter) || - hasReturnValue(node.handler && node.handler.body, throwOnNullReturn, promFilter) || - hasReturnValue(node.finalizer, throwOnNullReturn, promFilter); - } - - case 'SwitchStatement': { - return node.cases.some( - (someCase) => { - return someCase.consequent.some((nde) => { - return hasReturnValue(nde, throwOnNullReturn, promFilter); - }); - }, - ); - } - - case 'ReturnStatement': { - // void return does not count. - if (node.argument === null) { - if (throwOnNullReturn) { - throw new Error('Null return'); - } - - return false; - } - - if (promFilter && isNewPromiseExpression(node.argument)) { - // Let caller decide how to filter, but this is, at the least, - // a return of sorts and truthy - return promFilter(node.argument); - } - - return true; - } - - default: { - return false; - } - } -}; - -/** - * Checks if a node has a return statement. Void return does not count. - * @param {ESTreeOrTypeScriptNode|null|undefined} node - * @param {PromiseFilter} promFilter - * @returns {undefined|boolean|ESTreeOrTypeScriptNode} - */ -// eslint-disable-next-line complexity -const allBrancheshaveReturnValues = (node, promFilter) => { - if (!node) { - return false; - } - - switch (node.type) { - case 'TSDeclareFunction': - case 'TSFunctionType': - case 'TSMethodSignature': { - const type = node?.returnType?.typeAnnotation?.type; - return type && !undefinedKeywords.has(type); - } - - // case 'MethodDefinition': - // return allBrancheshaveReturnValues(node.value, promFilter); - case 'FunctionExpression': - case 'FunctionDeclaration': - case 'ArrowFunctionExpression': { - return 'expression' in node && node.expression && (!isNewPromiseExpression(node.body) || !isVoidPromise(node.body)) || - allBrancheshaveReturnValues(node.body, promFilter) || - /** @type {import('@typescript-eslint/types').TSESTree.BlockStatement} */ - (node.body).body.some((nde) => { - return nde.type === 'ReturnStatement'; - }); - } - - case 'BlockStatement': { - const lastBodyNode = node.body.slice(-1)[0]; - return allBrancheshaveReturnValues(lastBodyNode, promFilter); - } - - case 'WhileStatement': - case 'DoWhileStatement': - if ( - /** - * @type {import('@typescript-eslint/types').TSESTree.Literal} - */ - (node.test).value === true - ) { - // If this is an infinite loop, we assume only one branch - // is needed to provide a return - return hasReturnValue(node.body, false, promFilter); - } - - // Fallthrough - case 'LabeledStatement': - case 'ForStatement': - case 'ForInStatement': - case 'ForOfStatement': - case 'WithStatement': { - return allBrancheshaveReturnValues(node.body, promFilter); - } - - case 'IfStatement': { - return allBrancheshaveReturnValues(node.consequent, promFilter) && - allBrancheshaveReturnValues(node.alternate, promFilter); - } - - case 'TryStatement': { - // If `finally` returns, all return - return node.finalizer && allBrancheshaveReturnValues(node.finalizer, promFilter) || - // Return in `try`/`catch` may still occur despite `finally` - allBrancheshaveReturnValues(node.block, promFilter) && - (!node.handler || - allBrancheshaveReturnValues(node.handler && node.handler.body, promFilter)) && - (!node.finalizer || (() => { - try { - hasReturnValue(node.finalizer, true, promFilter); - } catch (error) { - if (/** @type {Error} */ (error).message === 'Null return') { - return false; - } - /* c8 ignore next 2 */ - throw error; - } - - // As long as not an explicit empty return, then return true - return true; - })()); - } - - case 'SwitchStatement': { - return /** @type {import('@typescript-eslint/types').TSESTree.SwitchStatement} */ (node).cases.every( - (someCase) => { - return !someCase.consequent.some((consNode) => { - return consNode.type === 'BreakStatement' || - consNode.type === 'ReturnStatement' && consNode.argument === null; - }); - }, - ); - } - - case 'ThrowStatement': { - return true; - } - - case 'ReturnStatement': { - // void return does not count. - if (node.argument === null) { - return false; - } - - if (promFilter && isNewPromiseExpression(node.argument)) { - // Let caller decide how to filter, but this is, at the least, - // a return of sorts and truthy - return promFilter(node.argument); - } - - return true; - } - - default: { - return false; - } - } -}; - -/** - * @callback PromiseFilter - * @param {ESTreeOrTypeScriptNode|undefined} node - * @returns {boolean} - */ - -/** - * Avoids further checking child nodes if a nested function shadows the - * resolver, but otherwise, if name is used (by call or passed in as an - * argument to another function), will be considered as non-empty. - * - * This could check for redeclaration of the resolver, but as such is - * unlikely, we avoid the performance cost of checking everywhere for - * (re)declarations or assignments. - * @param {import('@typescript-eslint/types').TSESTree.Node|null|undefined} node - * @param {string} resolverName - * @returns {boolean} - */ -// eslint-disable-next-line complexity -const hasNonEmptyResolverCall = (node, resolverName) => { - if (!node) { - return false; - } - - // Arrow function without block - switch (node.type) { - /* c8 ignore next 2 -- In Babel? */ - // @ts-expect-error Babel? - case 'OptionalCallExpression': - case 'CallExpression': - return /** @type {import('@typescript-eslint/types').TSESTree.Identifier} */ ( - node.callee - ).name === resolverName && ( - - // Implicit or explicit undefined - node.arguments.length > 1 || node.arguments[0] !== undefined - ) || - node.arguments.some((nde) => { - // Being passed in to another function (which might invoke it) - return nde.type === 'Identifier' && nde.name === resolverName || - - // Handle nested items - hasNonEmptyResolverCall(nde, resolverName); - }); - case 'ChainExpression': - case 'Decorator': - case 'ExpressionStatement': - return hasNonEmptyResolverCall(node.expression, resolverName); - case 'ClassBody': - case 'BlockStatement': - return node.body.some((bodyNode) => { - return hasNonEmptyResolverCall(bodyNode, resolverName); - }); - case 'FunctionExpression': - case 'FunctionDeclaration': - case 'ArrowFunctionExpression': { - // Shadowing - if (/** @type {import('@typescript-eslint/types').TSESTree.Identifier} */ ( - node.params[0] - )?.name === resolverName) { - return false; - } - - return hasNonEmptyResolverCall(node.body, resolverName); - } - - case 'LabeledStatement': - case 'WhileStatement': - case 'DoWhileStatement': - case 'ForStatement': - case 'ForInStatement': - case 'ForOfStatement': - case 'WithStatement': { - return hasNonEmptyResolverCall(node.body, resolverName); - } - - case 'ConditionalExpression': - case 'IfStatement': { - return hasNonEmptyResolverCall(node.test, resolverName) || - hasNonEmptyResolverCall(node.consequent, resolverName) || - hasNonEmptyResolverCall(node.alternate, resolverName); - } - - case 'TryStatement': { - return hasNonEmptyResolverCall(node.block, resolverName) || - hasNonEmptyResolverCall(node.handler && node.handler.body, resolverName) || - hasNonEmptyResolverCall(node.finalizer, resolverName); - } - - case 'SwitchStatement': { - return node.cases.some( - (someCase) => { - return someCase.consequent.some((nde) => { - return hasNonEmptyResolverCall(nde, resolverName); - }); - }, - ); - } - - case 'ArrayPattern': - case 'ArrayExpression': - return node.elements.some((element) => { - return hasNonEmptyResolverCall(element, resolverName); - }); - - case 'AssignmentPattern': - return hasNonEmptyResolverCall(node.right, resolverName); - - case 'AssignmentExpression': - case 'BinaryExpression': - case 'LogicalExpression': { - return hasNonEmptyResolverCall(node.left, resolverName) || - hasNonEmptyResolverCall(node.right, resolverName); - } - - // Comma - case 'SequenceExpression': - case 'TemplateLiteral': - return node.expressions.some((subExpression) => { - return hasNonEmptyResolverCall(subExpression, resolverName); - }); - - case 'ObjectPattern': - case 'ObjectExpression': - return node.properties.some((property) => { - return hasNonEmptyResolverCall(property, resolverName); - }); - /* c8 ignore next 2 -- In Babel? */ - // @ts-expect-error Babel? - case 'ClassMethod': - case 'MethodDefinition': - return node.decorators && node.decorators.some((decorator) => { - return hasNonEmptyResolverCall(decorator, resolverName); - }) || - node.computed && hasNonEmptyResolverCall(node.key, resolverName) || - hasNonEmptyResolverCall(node.value, resolverName); - - /* c8 ignore next 2 -- In Babel? */ - // @ts-expect-error Babel? - case 'ObjectProperty': - /* eslint-disable no-fallthrough */ - /* c8 ignore next -- In Babel? */ - case 'PropertyDefinition': - /* c8 ignore next 2 -- In Babel? */ - // @ts-expect-error Babel? - case 'ClassProperty': - case 'Property': - /* eslint-enable no-fallthrough */ - return node.computed && hasNonEmptyResolverCall(node.key, resolverName) || - hasNonEmptyResolverCall(node.value, resolverName); - /* c8 ignore next 2 -- In Babel? */ - // @ts-expect-error Babel? - case 'ObjectMethod': - /* c8 ignore next 6 -- In Babel? */ - // @ts-expect-error - return node.computed && hasNonEmptyResolverCall(node.key, resolverName) || - // @ts-expect-error - node.arguments.some((nde) => { - return hasNonEmptyResolverCall(nde, resolverName); - }); - - case 'ClassExpression': - case 'ClassDeclaration': - return hasNonEmptyResolverCall(node.body, resolverName); - - case 'AwaitExpression': - case 'SpreadElement': - case 'UnaryExpression': - case 'YieldExpression': - return hasNonEmptyResolverCall(node.argument, resolverName); - - case 'VariableDeclaration': { - return node.declarations.some((nde) => { - return hasNonEmptyResolverCall(nde, resolverName); - }); - } - - case 'VariableDeclarator': { - return hasNonEmptyResolverCall(node.id, resolverName) || - hasNonEmptyResolverCall(node.init, resolverName); - } - - case 'TaggedTemplateExpression': - return hasNonEmptyResolverCall(node.quasi, resolverName); - - // ?. - /* c8 ignore next 2 -- In Babel? */ - // @ts-expect-error Babel? - case 'OptionalMemberExpression': - case 'MemberExpression': - return hasNonEmptyResolverCall(node.object, resolverName) || - hasNonEmptyResolverCall(node.property, resolverName); - - /* c8 ignore next 2 -- In Babel? */ - // @ts-expect-error Babel? - case 'Import': - case 'ImportExpression': - return hasNonEmptyResolverCall(node.source, resolverName); - - case 'ReturnStatement': { - if (node.argument === null) { - return false; - } - - return hasNonEmptyResolverCall(node.argument, resolverName); - } - - /* - // Shouldn't need to parse literals/literal components, etc. - - case 'Identifier': - case 'TemplateElement': - case 'Super': - // Exports not relevant in this context - */ - default: - return false; - } -}; - -/** - * Checks if a Promise executor has no resolve value or an empty value. - * An `undefined` resolve does not count. - * @param {ESTreeOrTypeScriptNode} node - * @param {boolean} anyPromiseAsReturn - * @param {boolean} [allBranches] - * @returns {boolean} - */ -const hasValueOrExecutorHasNonEmptyResolveValue = (node, anyPromiseAsReturn, allBranches) => { - const hasReturnMethod = allBranches ? - /** - * @param {ESTreeOrTypeScriptNode} nde - * @param {PromiseFilter} promiseFilter - * @returns {boolean} - */ - (nde, promiseFilter) => { - let hasReturn; - try { - hasReturn = hasReturnValue(nde, true, promiseFilter); - } catch (error) { - // c8 ignore else - if (/** @type {Error} */ (error).message === 'Null return') { - return false; - } - /* c8 ignore next 2 */ - throw error; - } - - // `hasReturn` check needed since `throw` treated as valid return by - // `allBrancheshaveReturnValues` - return Boolean(hasReturn && allBrancheshaveReturnValues(nde, promiseFilter)); - } : - /** - * @param {ESTreeOrTypeScriptNode} nde - * @param {PromiseFilter} promiseFilter - * @returns {boolean} - */ - (nde, promiseFilter) => { - return Boolean(hasReturnValue(nde, false, promiseFilter)); - }; - - return hasReturnMethod(node, (prom) => { - if (anyPromiseAsReturn) { - return true; - } - - if (isVoidPromise(prom)) { - return false; - } - - const { - params, - body, - } = - /** - * @type {import('@typescript-eslint/types').TSESTree.FunctionExpression| - * import('@typescript-eslint/types').TSESTree.ArrowFunctionExpression} - */ ( - /** @type {import('@typescript-eslint/types').TSESTree.NewExpression} */ ( - prom - ).arguments[0] - ) || {}; - - if (!params?.length) { - return false; - } - - const { - name: resolverName, - } = /** @type {import('@typescript-eslint/types').TSESTree.Identifier} */ ( - params[0] - ); - - return hasNonEmptyResolverCall(body, resolverName); - }); -}; - -export { - hasReturnValue, - hasValueOrExecutorHasNonEmptyResolveValue, -}; diff --git a/tools/eslint/node_modules/eslint-plugin-markdown/LICENSE b/tools/eslint/node_modules/eslint-plugin-markdown/LICENSE deleted file mode 100644 index cf5a5995af4cd5..00000000000000 --- a/tools/eslint/node_modules/eslint-plugin-markdown/LICENSE +++ /dev/null @@ -1,21 +0,0 @@ -The MIT License (MIT) - -Copyright JS Foundation and other contributors, https://js.foundation - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. diff --git a/tools/eslint/node_modules/eslint-plugin-markdown/index.js b/tools/eslint/node_modules/eslint-plugin-markdown/index.js deleted file mode 100644 index 1638f11ee3c12b..00000000000000 --- a/tools/eslint/node_modules/eslint-plugin-markdown/index.js +++ /dev/null @@ -1,8 +0,0 @@ -/** - * @fileoverview Exports the processor. - * @author Brandon Mills - */ - -"use strict"; - -module.exports = require("./lib"); diff --git a/tools/eslint/node_modules/eslint-plugin-markdown/lib/index.js b/tools/eslint/node_modules/eslint-plugin-markdown/lib/index.js deleted file mode 100644 index 992db15e7b150f..00000000000000 --- a/tools/eslint/node_modules/eslint-plugin-markdown/lib/index.js +++ /dev/null @@ -1,104 +0,0 @@ -/** - * @fileoverview Enables the processor for Markdown file extensions. - * @author Brandon Mills - */ - -"use strict"; - -const processor = require("./processor"); -const pkg = require("../package.json"); - -const rulesConfig = { - - // The Markdown parser automatically trims trailing - // newlines from code blocks. - "eol-last": "off", - - // In code snippets and examples, these rules are often - // counterproductive to clarity and brevity. - "no-undef": "off", - "no-unused-expressions": "off", - "no-unused-vars": "off", - "padded-blocks": "off", - - // Adding a "use strict" directive at the top of every - // code block is tedious and distracting. The config - // opts into strict mode parsing without the directive. - strict: "off", - - // The processor will not receive a Unicode Byte Order - // Mark from the Markdown parser. - "unicode-bom": "off" -}; - -const plugin = { - meta: { - name: pkg.name, - version: pkg.version - }, - processors: { - markdown: processor - }, - configs: { - "recommended-legacy": { - plugins: ["markdown"], - overrides: [ - { - files: ["*.md"], - processor: "markdown/markdown" - }, - { - files: ["**/*.md/**"], - parserOptions: { - ecmaFeatures: { - - // Adding a "use strict" directive at the top of - // every code block is tedious and distracting, so - // opt into strict mode parsing without the - // directive. - impliedStrict: true - } - }, - rules: { - ...rulesConfig - } - } - ] - } - } -}; - -plugin.configs.recommended = [ - { - name: "markdown/recommended/plugin", - plugins: { - markdown: plugin - } - }, - { - name: "markdown/recommended/processor", - files: ["**/*.md"], - processor: "markdown/markdown" - }, - { - name: "markdown/recommended/code-blocks", - files: ["**/*.md/**"], - languageOptions: { - parserOptions: { - ecmaFeatures: { - - // Adding a "use strict" directive at the top of - // every code block is tedious and distracting, so - // opt into strict mode parsing without the - // directive. - impliedStrict: true - } - } - }, - rules: { - ...rulesConfig - } - } -]; - -module.exports = plugin; diff --git a/tools/eslint/node_modules/eslint-plugin-markdown/lib/processor.js b/tools/eslint/node_modules/eslint-plugin-markdown/lib/processor.js deleted file mode 100644 index b4ff61d6c8bb60..00000000000000 --- a/tools/eslint/node_modules/eslint-plugin-markdown/lib/processor.js +++ /dev/null @@ -1,421 +0,0 @@ -/** - * @fileoverview Processes Markdown files for consumption by ESLint. - * @author Brandon Mills - */ - -/** - * @typedef {import('eslint/lib/shared/types').LintMessage} Message - * @typedef {Object} ASTNode - * @property {string} type The type of node. - * @property {string} [lang] The language that the node is in - * @typedef {Object} RangeMap - * @property {number} indent Number of code block indent characters trimmed from - * the beginning of the line during extraction. - * @property {number} js Offset from the start of the code block's range in the - * extracted JS. - * @property {number} md Offset from the start of the code block's range in the - * original Markdown. - * @typedef {Object} BlockBase - * @property {string} baseIndentText Leading whitespace text for the block. - * @property {string[]} comments Comments inside of the JavaScript code. - * @property {RangeMap[]} rangeMap A list of offset-based adjustments, where - * lookups are done based on the `js` key, which represents the range in the - * linted JS, and the `md` key is the offset delta that, when added to the JS - * range, returns the corresponding location in the original Markdown source. - * @typedef {ASTNode & BlockBase} Block - */ - -"use strict"; - -const parse = require("mdast-util-from-markdown"); -const pkg = require("../package.json"); - -const UNSATISFIABLE_RULES = new Set([ - "eol-last", // The Markdown parser strips trailing newlines in code fences - "unicode-bom" // Code blocks will begin in the middle of Markdown files -]); -const SUPPORTS_AUTOFIX = true; - -/** - * @type {Map} - */ -const blocksCache = new Map(); - -/** - * Performs a depth-first traversal of the Markdown AST. - * @param {ASTNode} node A Markdown AST node. - * @param {{[key: string]: (node: ASTNode) => void}} callbacks A map of node types to callbacks. - * @returns {void} - */ -function traverse(node, callbacks) { - if (callbacks[node.type]) { - callbacks[node.type](node); - } else { - callbacks["*"](); - } - - if (typeof node.children !== "undefined") { - for (let i = 0; i < node.children.length; i++) { - traverse(node.children[i], callbacks); - } - } -} - -/** - * Extracts `eslint-*` or `global` comments from HTML comments if present. - * @param {string} html The text content of an HTML AST node. - * @returns {string} The comment's text without the opening and closing tags or - * an empty string if the text is not an ESLint HTML comment. - */ -function getComment(html) { - const commentStart = ""; - const regex = /^(eslint\b|global\s)/u; - - if ( - html.slice(0, commentStart.length) !== commentStart || - html.slice(-commentEnd.length) !== commentEnd - ) { - return ""; - } - - const comment = html.slice(commentStart.length, -commentEnd.length); - - if (!regex.test(comment.trim())) { - return ""; - } - - return comment; -} - -// Before a code block, blockquote characters (`>`) are also considered -// "whitespace". -const leadingWhitespaceRegex = /^[>\s]*/u; - -/** - * Gets the offset for the first column of the node's first line in the - * original source text. - * @param {ASTNode} node A Markdown code block AST node. - * @returns {number} The offset for the first column of the node's first line. - */ -function getBeginningOfLineOffset(node) { - return node.position.start.offset - node.position.start.column + 1; -} - -/** - * Gets the leading text, typically whitespace with possible blockquote chars, - * used to indent a code block. - * @param {string} text The text of the file. - * @param {ASTNode} node A Markdown code block AST node. - * @returns {string} The text from the start of the first line to the opening - * fence of the code block. - */ -function getIndentText(text, node) { - return leadingWhitespaceRegex.exec( - text.slice(getBeginningOfLineOffset(node)) - )[0]; -} - -/** - * When applying fixes, the postprocess step needs to know how to map fix ranges - * from their location in the linted JS to the original offset in the Markdown. - * Configuration comments and indentation trimming both complicate this process. - * - * Configuration comments appear in the linted JS but not in the Markdown code - * block. Fixes to configuration comments would cause undefined behavior and - * should be ignored during postprocessing. Fixes to actual code after - * configuration comments need to be mapped back to the code block after - * removing any offset due to configuration comments. - * - * Fenced code blocks can be indented by up to three spaces at the opening - * fence. Inside of a list, for example, this indent can be in addition to the - * indent already required for list item children. Leading whitespace inside - * indented code blocks is trimmed up to the level of the opening fence and does - * not appear in the linted code. Further, lines can have less leading - * whitespace than the opening fence, so not all lines are guaranteed to have - * the same column offset as the opening fence. - * - * The source code of a non-configuration-comment line in the linted JS is a - * suffix of the corresponding line in the Markdown code block. There are no - * differences within the line, so the mapping need only provide the offset - * delta at the beginning of each line. - * @param {string} text The text of the file. - * @param {ASTNode} node A Markdown code block AST node. - * @param {string[]} comments List of configuration comment strings that will be - * inserted at the beginning of the code block. - * @returns {RangeMap[]} A list of offset-based adjustments, where lookups are - * done based on the `js` key, which represents the range in the linted JS, - * and the `md` key is the offset delta that, when added to the JS range, - * returns the corresponding location in the original Markdown source. - */ -function getBlockRangeMap(text, node, comments) { - - /* - * The parser sets the fenced code block's start offset to wherever content - * should normally begin (typically the first column of the line, but more - * inside a list item, for example). The code block's opening fence may be - * further indented by up to three characters. If the code block has - * additional indenting, the opening fence's first backtick may be up to - * three whitespace characters after the start offset. - */ - const startOffset = getBeginningOfLineOffset(node); - - /* - * Extract the Markdown source to determine the leading whitespace for each - * line. - */ - const code = text.slice(startOffset, node.position.end.offset); - const lines = code.split("\n"); - - /* - * The parser trims leading whitespace from each line of code within the - * fenced code block up to the opening fence's first backtick. The first - * backtick's column is the AST node's starting column plus any additional - * indentation. - */ - const baseIndent = getIndentText(text, node).length; - - /* - * Track the length of any inserted configuration comments at the beginning - * of the linted JS and start the JS offset lookup keys at this index. - */ - const commentLength = comments.reduce((len, comment) => len + comment.length + 1, 0); - - /* - * In case there are configuration comments, initialize the map so that the - * first lookup index is always 0. If there are no configuration comments, - * the lookup index will also be 0, and the lookup should always go to the - * last range that matches, skipping this initialization entry. - */ - const rangeMap = [{ - indent: baseIndent, - js: 0, - md: 0 - }]; - - // Start the JS offset after any configuration comments. - let jsOffset = commentLength; - - /* - * Start the Markdown offset at the beginning of the block's first line of - * actual code. The first line of the block is always the opening fence, so - * the code begins on the second line. - */ - let mdOffset = startOffset + lines[0].length + 1; - - /* - * For each line, determine how much leading whitespace was trimmed due to - * indentation. Increase the JS lookup offset by the length of the line - * post-trimming and the Markdown offset by the total line length. - */ - for (let i = 0; i + 1 < lines.length; i++) { - const line = lines[i + 1]; - const leadingWhitespaceLength = leadingWhitespaceRegex.exec(line)[0].length; - - // The parser trims leading whitespace up to the level of the opening - // fence, so keep any additional indentation beyond that. - const trimLength = Math.min(baseIndent, leadingWhitespaceLength); - - rangeMap.push({ - indent: trimLength, - js: jsOffset, - - // Advance `trimLength` character from the beginning of the Markdown - // line to the beginning of the equivalent JS line, then compute the - // delta. - md: mdOffset + trimLength - jsOffset - }); - - // Accumulate the current line in the offsets, and don't forget the - // newline. - mdOffset += line.length + 1; - jsOffset += line.length - trimLength + 1; - } - - return rangeMap; -} - -const languageToFileExtension = { - javascript: "js", - ecmascript: "js", - typescript: "ts", - markdown: "md" -}; - -/** - * Extracts lintable code blocks from Markdown text. - * @param {string} text The text of the file. - * @param {string} filename The filename of the file - * @returns {Array<{ filename: string, text: string }>} Source code blocks to lint. - */ -function preprocess(text, filename) { - const ast = parse(text); - const blocks = []; - - blocksCache.set(filename, blocks); - - /** - * During the depth-first traversal, keep track of any sequences of HTML - * comment nodes containing `eslint-*` or `global` comments. If a code - * block immediately follows such a sequence, insert the comments at the - * top of the code block. Any non-ESLint comment or other node type breaks - * and empties the sequence. - * @type {string[]} - */ - let htmlComments = []; - - traverse(ast, { - "*"() { - htmlComments = []; - }, - code(node) { - if (node.lang) { - const comments = []; - - for (const comment of htmlComments) { - if (comment.trim() === "eslint-skip") { - htmlComments = []; - return; - } - - comments.push(`/*${comment}*/`); - } - - htmlComments = []; - - blocks.push({ - ...node, - baseIndentText: getIndentText(text, node), - comments, - rangeMap: getBlockRangeMap(text, node, comments) - }); - } - }, - html(node) { - const comment = getComment(node.value); - - if (comment) { - htmlComments.push(comment); - } else { - htmlComments = []; - } - } - }); - - return blocks.map((block, index) => { - const [language] = block.lang.trim().split(" "); - const fileExtension = Object.hasOwn(languageToFileExtension, language) ? languageToFileExtension[language] : language; - - return { - filename: `${index}.${fileExtension}`, - text: [ - ...block.comments, - block.value, - "" - ].join("\n") - }; - }); -} - -/** - * Creates a map function that adjusts messages in a code block. - * @param {Block} block A code block. - * @returns {(message: Message) => Message} A function that adjusts messages in a code block. - */ -function adjustBlock(block) { - const leadingCommentLines = block.comments.reduce((count, comment) => count + comment.split("\n").length, 0); - - const blockStart = block.position.start.line; - - /** - * Adjusts ESLint messages to point to the correct location in the Markdown. - * @param {Message} message A message from ESLint. - * @returns {Message} The same message, but adjusted to the correct location. - */ - return function adjustMessage(message) { - if (!Number.isInteger(message.line)) { - return { - ...message, - line: blockStart, - column: block.position.start.column - }; - } - - const lineInCode = message.line - leadingCommentLines; - - if (lineInCode < 1 || lineInCode >= block.rangeMap.length) { - return null; - } - - const out = { - line: lineInCode + blockStart, - column: message.column + block.rangeMap[lineInCode].indent - }; - - if (Number.isInteger(message.endLine)) { - out.endLine = message.endLine - leadingCommentLines + blockStart; - } - - const adjustedFix = {}; - - if (message.fix) { - adjustedFix.fix = { - range: message.fix.range.map(range => { - - // Advance through the block's range map to find the last - // matching range by finding the first range too far and - // then going back one. - let i = 1; - - while (i < block.rangeMap.length && block.rangeMap[i].js <= range) { - i++; - } - - // Apply the mapping delta for this range. - return range + block.rangeMap[i - 1].md; - }), - text: message.fix.text.replace(/\n/gu, `\n${block.baseIndentText}`) - }; - } - - return { ...message, ...out, ...adjustedFix }; - }; -} - -/** - * Excludes unsatisfiable rules from the list of messages. - * @param {Message} message A message from the linter. - * @returns {boolean} True if the message should be included in output. - */ -function excludeUnsatisfiableRules(message) { - return message && !UNSATISFIABLE_RULES.has(message.ruleId); -} - -/** - * Transforms generated messages for output. - * @param {Array} messages An array containing one array of messages - * for each code block returned from `preprocess`. - * @param {string} filename The filename of the file - * @returns {Message[]} A flattened array of messages with mapped locations. - */ -function postprocess(messages, filename) { - const blocks = blocksCache.get(filename); - - blocksCache.delete(filename); - - return messages.flatMap((group, i) => { - const adjust = adjustBlock(blocks[i]); - - return group.map(adjust).filter(excludeUnsatisfiableRules); - }); -} - -module.exports = { - meta: { - name: `${pkg.name}/markdown`, - version: pkg.version - }, - preprocess, - postprocess, - supportsAutofix: SUPPORTS_AUTOFIX -}; diff --git a/tools/eslint/node_modules/eslint-plugin-markdown/package.json b/tools/eslint/node_modules/eslint-plugin-markdown/package.json deleted file mode 100644 index c1ace70ea9713e..00000000000000 --- a/tools/eslint/node_modules/eslint-plugin-markdown/package.json +++ /dev/null @@ -1,57 +0,0 @@ -{ - "name": "eslint-plugin-markdown", - "version": "5.1.0", - "description": "An ESLint plugin to lint JavaScript in Markdown code fences.", - "license": "MIT", - "author": { - "name": "Brandon Mills", - "url": "https://github.com/btmills" - }, - "repository": "eslint/eslint-plugin-markdown", - "bugs": { - "url": "https://github.com/eslint/eslint-plugin-markdown/issues" - }, - "homepage": "https://github.com/eslint/eslint-plugin-markdown#readme", - "keywords": [ - "eslint", - "eslintplugin", - "markdown", - "lint", - "linter" - ], - "scripts": { - "lint": "eslint .", - "prepare": "node ./npm-prepare.js", - "release:generate:latest": "eslint-generate-release", - "release:generate:alpha": "eslint-generate-prerelease alpha", - "release:generate:beta": "eslint-generate-prerelease beta", - "release:generate:rc": "eslint-generate-prerelease rc", - "release:publish": "eslint-publish-release", - "test": "nyc _mocha -- -c tests/{examples,lib}/**/*.js --timeout 30000" - }, - "main": "index.js", - "files": [ - "index.js", - "lib/index.js", - "lib/processor.js" - ], - "devDependencies": { - "@eslint/js": "^9.4.0", - "chai": "^4.2.0", - "eslint": "^9.4.0", - "eslint-config-eslint": "^11.0.0", - "eslint-release": "^3.1.2", - "globals": "^15.1.0", - "mocha": "^6.2.2", - "nyc": "^14.1.1" - }, - "dependencies": { - "mdast-util-from-markdown": "^0.8.5" - }, - "peerDependencies": { - "eslint": ">=8" - }, - "engines": { - "node": "^18.18.0 || ^20.9.0 || >=21.1.0" - } -} diff --git a/tools/eslint/node_modules/eslint-scope/LICENSE b/tools/eslint/node_modules/eslint-scope/LICENSE deleted file mode 100644 index d36a526f7ed5d1..00000000000000 --- a/tools/eslint/node_modules/eslint-scope/LICENSE +++ /dev/null @@ -1,22 +0,0 @@ -Copyright JS Foundation and other contributors, https://js.foundation -Copyright (C) 2012-2013 Yusuke Suzuki (twitter: @Constellation) and other contributors. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -ARE DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY -DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/tools/eslint/node_modules/eslint-scope/lib/definition.js b/tools/eslint/node_modules/eslint-scope/lib/definition.js deleted file mode 100644 index 172bfe23b5fdcf..00000000000000 --- a/tools/eslint/node_modules/eslint-scope/lib/definition.js +++ /dev/null @@ -1,86 +0,0 @@ -/* - Copyright (C) 2015 Yusuke Suzuki - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - ARE DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY - DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ -"use strict"; - -const Variable = require("./variable"); - -/** - * @class Definition - */ -class Definition { - constructor(type, name, node, parent, index, kind) { - - /** - * @member {String} Definition#type - type of the occurrence (e.g. "Parameter", "Variable", ...). - */ - this.type = type; - - /** - * @member {espree.Identifier} Definition#name - the identifier AST node of the occurrence. - */ - this.name = name; - - /** - * @member {espree.Node} Definition#node - the enclosing node of the identifier. - */ - this.node = node; - - /** - * @member {espree.Node?} Definition#parent - the enclosing statement node of the identifier. - */ - this.parent = parent; - - /** - * @member {Number?} Definition#index - the index in the declaration statement. - */ - this.index = index; - - /** - * @member {String?} Definition#kind - the kind of the declaration statement. - */ - this.kind = kind; - } -} - -/** - * @class ParameterDefinition - */ -class ParameterDefinition extends Definition { - constructor(name, node, index, rest) { - super(Variable.Parameter, name, node, null, index, null); - - /** - * Whether the parameter definition is a part of a rest parameter. - * @member {boolean} ParameterDefinition#rest - */ - this.rest = rest; - } -} - -module.exports = { - ParameterDefinition, - Definition -}; - -/* vim: set sw=4 ts=4 et tw=80 : */ diff --git a/tools/eslint/node_modules/eslint-scope/lib/index.js b/tools/eslint/node_modules/eslint-scope/lib/index.js deleted file mode 100644 index 0f16fa40f8323f..00000000000000 --- a/tools/eslint/node_modules/eslint-scope/lib/index.js +++ /dev/null @@ -1,165 +0,0 @@ -/* - Copyright (C) 2012-2014 Yusuke Suzuki - Copyright (C) 2013 Alex Seville - Copyright (C) 2014 Thiago de Arruda - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - ARE DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY - DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -/** - * Escope (escope) is an ECMAScript - * scope analyzer extracted from the esmangle project. - *

- * escope finds lexical scopes in a source program, i.e. areas of that - * program where different occurrences of the same identifier refer to the same - * variable. With each scope the contained variables are collected, and each - * identifier reference in code is linked to its corresponding variable (if - * possible). - *

- * escope works on a syntax tree of the parsed source code which has - * to adhere to the - * Mozilla Parser API. E.g. espree is a parser - * that produces such syntax trees. - *

- * The main interface is the {@link analyze} function. - * @module escope - */ -"use strict"; - -/* eslint no-underscore-dangle: ["error", { "allow": ["__currentScope"] }] */ - -const assert = require("assert"); - -const ScopeManager = require("./scope-manager"); -const Referencer = require("./referencer"); -const Reference = require("./reference"); -const Variable = require("./variable"); -const Scope = require("./scope").Scope; -const version = require("../package.json").version; - -/** - * Set the default options - * @returns {Object} options - */ -function defaultOptions() { - return { - optimistic: false, - directive: false, - nodejsScope: false, - impliedStrict: false, - sourceType: "script", // one of ['script', 'module'] - ecmaVersion: 5, - childVisitorKeys: null, - fallback: "iteration" - }; -} - -/** - * Preform deep update on option object - * @param {Object} target - Options - * @param {Object} override - Updates - * @returns {Object} Updated options - */ -function updateDeeply(target, override) { - - /** - * Is hash object - * @param {Object} value - Test value - * @returns {boolean} Result - */ - function isHashObject(value) { - return typeof value === "object" && value instanceof Object && !(value instanceof Array) && !(value instanceof RegExp); - } - - for (const key in override) { - if (Object.prototype.hasOwnProperty.call(override, key)) { - const val = override[key]; - - if (isHashObject(val)) { - if (isHashObject(target[key])) { - updateDeeply(target[key], val); - } else { - target[key] = updateDeeply({}, val); - } - } else { - target[key] = val; - } - } - } - return target; -} - -/** - * Main interface function. Takes an Espree syntax tree and returns the - * analyzed scopes. - * @function analyze - * @param {espree.Tree} tree - Abstract Syntax Tree - * @param {Object} providedOptions - Options that tailor the scope analysis - * @param {boolean} [providedOptions.optimistic=false] - the optimistic flag - * @param {boolean} [providedOptions.directive=false]- the directive flag - * @param {boolean} [providedOptions.ignoreEval=false]- whether to check 'eval()' calls - * @param {boolean} [providedOptions.nodejsScope=false]- whether the whole - * script is executed under node.js environment. When enabled, escope adds - * a function scope immediately following the global scope. - * @param {boolean} [providedOptions.impliedStrict=false]- implied strict mode - * (if ecmaVersion >= 5). - * @param {string} [providedOptions.sourceType='script']- the source type of the script. one of 'script' and 'module' - * @param {number} [providedOptions.ecmaVersion=5]- which ECMAScript version is considered - * @param {Object} [providedOptions.childVisitorKeys=null] - Additional known visitor keys. See [esrecurse](https://github.com/estools/esrecurse)'s the `childVisitorKeys` option. - * @param {string} [providedOptions.fallback='iteration'] - A kind of the fallback in order to encounter with unknown node. See [esrecurse](https://github.com/estools/esrecurse)'s the `fallback` option. - * @returns {ScopeManager} ScopeManager - */ -function analyze(tree, providedOptions) { - const options = updateDeeply(defaultOptions(), providedOptions); - const scopeManager = new ScopeManager(options); - const referencer = new Referencer(options, scopeManager); - - referencer.visit(tree); - - assert(scopeManager.__currentScope === null, "currentScope should be null."); - - return scopeManager; -} - -module.exports = { - - /** @name module:escope.version */ - version, - - /** @name module:escope.Reference */ - Reference, - - /** @name module:escope.Variable */ - Variable, - - /** @name module:escope.Scope */ - Scope, - - /** @name module:escope.ScopeManager */ - ScopeManager, - analyze -}; - - -/* vim: set sw=4 ts=4 et tw=80 : */ diff --git a/tools/eslint/node_modules/eslint-scope/lib/pattern-visitor.js b/tools/eslint/node_modules/eslint-scope/lib/pattern-visitor.js deleted file mode 100644 index afa629173b73ae..00000000000000 --- a/tools/eslint/node_modules/eslint-scope/lib/pattern-visitor.js +++ /dev/null @@ -1,152 +0,0 @@ -/* - Copyright (C) 2015 Yusuke Suzuki - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - ARE DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY - DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ -"use strict"; - -/* eslint-disable no-undefined */ - -const Syntax = require("estraverse").Syntax; -const esrecurse = require("esrecurse"); - -/** - * Get last array element - * @param {array} xs - array - * @returns {any} Last elment - */ -function getLast(xs) { - return xs[xs.length - 1] || null; -} - -class PatternVisitor extends esrecurse.Visitor { - static isPattern(node) { - const nodeType = node.type; - - return ( - nodeType === Syntax.Identifier || - nodeType === Syntax.ObjectPattern || - nodeType === Syntax.ArrayPattern || - nodeType === Syntax.SpreadElement || - nodeType === Syntax.RestElement || - nodeType === Syntax.AssignmentPattern - ); - } - - constructor(options, rootPattern, callback) { - super(null, options); - this.rootPattern = rootPattern; - this.callback = callback; - this.assignments = []; - this.rightHandNodes = []; - this.restElements = []; - } - - Identifier(pattern) { - const lastRestElement = getLast(this.restElements); - - this.callback(pattern, { - topLevel: pattern === this.rootPattern, - rest: lastRestElement !== null && lastRestElement !== undefined && lastRestElement.argument === pattern, - assignments: this.assignments - }); - } - - Property(property) { - - // Computed property's key is a right hand node. - if (property.computed) { - this.rightHandNodes.push(property.key); - } - - // If it's shorthand, its key is same as its value. - // If it's shorthand and has its default value, its key is same as its value.left (the value is AssignmentPattern). - // If it's not shorthand, the name of new variable is its value's. - this.visit(property.value); - } - - ArrayPattern(pattern) { - for (let i = 0, iz = pattern.elements.length; i < iz; ++i) { - const element = pattern.elements[i]; - - this.visit(element); - } - } - - AssignmentPattern(pattern) { - this.assignments.push(pattern); - this.visit(pattern.left); - this.rightHandNodes.push(pattern.right); - this.assignments.pop(); - } - - RestElement(pattern) { - this.restElements.push(pattern); - this.visit(pattern.argument); - this.restElements.pop(); - } - - MemberExpression(node) { - - // Computed property's key is a right hand node. - if (node.computed) { - this.rightHandNodes.push(node.property); - } - - // the object is only read, write to its property. - this.rightHandNodes.push(node.object); - } - - // - // ForInStatement.left and AssignmentExpression.left are LeftHandSideExpression. - // By spec, LeftHandSideExpression is Pattern or MemberExpression. - // (see also: https://github.com/estree/estree/pull/20#issuecomment-74584758) - // But espree 2.0 parses to ArrayExpression, ObjectExpression, etc... - // - - SpreadElement(node) { - this.visit(node.argument); - } - - ArrayExpression(node) { - node.elements.forEach(this.visit, this); - } - - AssignmentExpression(node) { - this.assignments.push(node); - this.visit(node.left); - this.rightHandNodes.push(node.right); - this.assignments.pop(); - } - - CallExpression(node) { - - // arguments are right hand nodes. - node.arguments.forEach(a => { - this.rightHandNodes.push(a); - }); - this.visit(node.callee); - } -} - -module.exports = PatternVisitor; - -/* vim: set sw=4 ts=4 et tw=80 : */ diff --git a/tools/eslint/node_modules/eslint-scope/lib/reference.js b/tools/eslint/node_modules/eslint-scope/lib/reference.js deleted file mode 100644 index 9529827fe786c6..00000000000000 --- a/tools/eslint/node_modules/eslint-scope/lib/reference.js +++ /dev/null @@ -1,167 +0,0 @@ -/* - Copyright (C) 2015 Yusuke Suzuki - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - ARE DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY - DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ -"use strict"; - -const READ = 0x1; -const WRITE = 0x2; -const RW = READ | WRITE; - -/** - * A Reference represents a single occurrence of an identifier in code. - * @class Reference - */ -class Reference { - constructor(ident, scope, flag, writeExpr, maybeImplicitGlobal, partial, init) { - - /** - * Identifier syntax node. - * @member {espreeIdentifier} Reference#identifier - */ - this.identifier = ident; - - /** - * Reference to the enclosing Scope. - * @member {Scope} Reference#from - */ - this.from = scope; - - /** - * Whether the reference comes from a dynamic scope (such as 'eval', - * 'with', etc.), and may be trapped by dynamic scopes. - * @member {boolean} Reference#tainted - */ - this.tainted = false; - - /** - * The variable this reference is resolved with. - * @member {Variable} Reference#resolved - */ - this.resolved = null; - - /** - * The read-write mode of the reference. (Value is one of {@link - * Reference.READ}, {@link Reference.RW}, {@link Reference.WRITE}). - * @member {number} Reference#flag - * @private - */ - this.flag = flag; - if (this.isWrite()) { - - /** - * If reference is writeable, this is the tree being written to it. - * @member {espreeNode} Reference#writeExpr - */ - this.writeExpr = writeExpr; - - /** - * Whether the Reference might refer to a partial value of writeExpr. - * @member {boolean} Reference#partial - */ - this.partial = partial; - - /** - * Whether the Reference is to write of initialization. - * @member {boolean} Reference#init - */ - this.init = init; - } - this.__maybeImplicitGlobal = maybeImplicitGlobal; - } - - /** - * Whether the reference is static. - * @method Reference#isStatic - * @returns {boolean} static - */ - isStatic() { - return !this.tainted && this.resolved && this.resolved.scope.isStatic(); - } - - /** - * Whether the reference is writeable. - * @method Reference#isWrite - * @returns {boolean} write - */ - isWrite() { - return !!(this.flag & Reference.WRITE); - } - - /** - * Whether the reference is readable. - * @method Reference#isRead - * @returns {boolean} read - */ - isRead() { - return !!(this.flag & Reference.READ); - } - - /** - * Whether the reference is read-only. - * @method Reference#isReadOnly - * @returns {boolean} read only - */ - isReadOnly() { - return this.flag === Reference.READ; - } - - /** - * Whether the reference is write-only. - * @method Reference#isWriteOnly - * @returns {boolean} write only - */ - isWriteOnly() { - return this.flag === Reference.WRITE; - } - - /** - * Whether the reference is read-write. - * @method Reference#isReadWrite - * @returns {boolean} read write - */ - isReadWrite() { - return this.flag === Reference.RW; - } -} - -/** - * @constant Reference.READ - * @private - */ -Reference.READ = READ; - -/** - * @constant Reference.WRITE - * @private - */ -Reference.WRITE = WRITE; - -/** - * @constant Reference.RW - * @private - */ -Reference.RW = RW; - -module.exports = Reference; - -/* vim: set sw=4 ts=4 et tw=80 : */ diff --git a/tools/eslint/node_modules/eslint-scope/lib/referencer.js b/tools/eslint/node_modules/eslint-scope/lib/referencer.js deleted file mode 100644 index 63d1935b3a957f..00000000000000 --- a/tools/eslint/node_modules/eslint-scope/lib/referencer.js +++ /dev/null @@ -1,629 +0,0 @@ -/* - Copyright (C) 2015 Yusuke Suzuki - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - ARE DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY - DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ -"use strict"; - -/* eslint-disable no-underscore-dangle */ -/* eslint-disable no-undefined */ - -const Syntax = require("estraverse").Syntax; -const esrecurse = require("esrecurse"); -const Reference = require("./reference"); -const Variable = require("./variable"); -const PatternVisitor = require("./pattern-visitor"); -const definition = require("./definition"); -const assert = require("assert"); - -const ParameterDefinition = definition.ParameterDefinition; -const Definition = definition.Definition; - -/** - * Traverse identifier in pattern - * @param {Object} options - options - * @param {pattern} rootPattern - root pattern - * @param {Refencer} referencer - referencer - * @param {callback} callback - callback - * @returns {void} - */ -function traverseIdentifierInPattern(options, rootPattern, referencer, callback) { - - // Call the callback at left hand identifier nodes, and Collect right hand nodes. - const visitor = new PatternVisitor(options, rootPattern, callback); - - visitor.visit(rootPattern); - - // Process the right hand nodes recursively. - if (referencer !== null && referencer !== undefined) { - visitor.rightHandNodes.forEach(referencer.visit, referencer); - } -} - -// Importing ImportDeclaration. -// http://people.mozilla.org/~jorendorff/es6-draft.html#sec-moduledeclarationinstantiation -// https://github.com/estree/estree/blob/master/es6.md#importdeclaration -// FIXME: Now, we don't create module environment, because the context is -// implementation dependent. - -class Importer extends esrecurse.Visitor { - constructor(declaration, referencer) { - super(null, referencer.options); - this.declaration = declaration; - this.referencer = referencer; - } - - visitImport(id, specifier) { - this.referencer.visitPattern(id, pattern => { - this.referencer.currentScope().__define(pattern, - new Definition( - Variable.ImportBinding, - pattern, - specifier, - this.declaration, - null, - null - )); - }); - } - - ImportNamespaceSpecifier(node) { - const local = (node.local || node.id); - - if (local) { - this.visitImport(local, node); - } - } - - ImportDefaultSpecifier(node) { - const local = (node.local || node.id); - - this.visitImport(local, node); - } - - ImportSpecifier(node) { - const local = (node.local || node.id); - - if (node.name) { - this.visitImport(node.name, node); - } else { - this.visitImport(local, node); - } - } -} - -// Referencing variables and creating bindings. -class Referencer extends esrecurse.Visitor { - constructor(options, scopeManager) { - super(null, options); - this.options = options; - this.scopeManager = scopeManager; - this.parent = null; - this.isInnerMethodDefinition = false; - } - - currentScope() { - return this.scopeManager.__currentScope; - } - - close(node) { - while (this.currentScope() && node === this.currentScope().block) { - this.scopeManager.__currentScope = this.currentScope().__close(this.scopeManager); - } - } - - pushInnerMethodDefinition(isInnerMethodDefinition) { - const previous = this.isInnerMethodDefinition; - - this.isInnerMethodDefinition = isInnerMethodDefinition; - return previous; - } - - popInnerMethodDefinition(isInnerMethodDefinition) { - this.isInnerMethodDefinition = isInnerMethodDefinition; - } - - referencingDefaultValue(pattern, assignments, maybeImplicitGlobal, init) { - const scope = this.currentScope(); - - assignments.forEach(assignment => { - scope.__referencing( - pattern, - Reference.WRITE, - assignment.right, - maybeImplicitGlobal, - pattern !== assignment.left, - init - ); - }); - } - - visitPattern(node, options, callback) { - let visitPatternOptions = options; - let visitPatternCallback = callback; - - if (typeof options === "function") { - visitPatternCallback = options; - visitPatternOptions = { processRightHandNodes: false }; - } - - traverseIdentifierInPattern( - this.options, - node, - visitPatternOptions.processRightHandNodes ? this : null, - visitPatternCallback - ); - } - - visitFunction(node) { - let i, iz; - - // FunctionDeclaration name is defined in upper scope - // NOTE: Not referring variableScope. It is intended. - // Since - // in ES5, FunctionDeclaration should be in FunctionBody. - // in ES6, FunctionDeclaration should be block scoped. - - if (node.type === Syntax.FunctionDeclaration) { - - // id is defined in upper scope - this.currentScope().__define(node.id, - new Definition( - Variable.FunctionName, - node.id, - node, - null, - null, - null - )); - } - - // FunctionExpression with name creates its special scope; - // FunctionExpressionNameScope. - if (node.type === Syntax.FunctionExpression && node.id) { - this.scopeManager.__nestFunctionExpressionNameScope(node); - } - - // Consider this function is in the MethodDefinition. - this.scopeManager.__nestFunctionScope(node, this.isInnerMethodDefinition); - - const that = this; - - /** - * Visit pattern callback - * @param {pattern} pattern - pattern - * @param {Object} info - info - * @returns {void} - */ - function visitPatternCallback(pattern, info) { - that.currentScope().__define(pattern, - new ParameterDefinition( - pattern, - node, - i, - info.rest - )); - - that.referencingDefaultValue(pattern, info.assignments, null, true); - } - - // Process parameter declarations. - for (i = 0, iz = node.params.length; i < iz; ++i) { - this.visitPattern(node.params[i], { processRightHandNodes: true }, visitPatternCallback); - } - - // if there's a rest argument, add that - if (node.rest) { - this.visitPattern({ - type: "RestElement", - argument: node.rest - }, pattern => { - this.currentScope().__define(pattern, - new ParameterDefinition( - pattern, - node, - node.params.length, - true - )); - }); - } - - // In TypeScript there are a number of function-like constructs which have no body, - // so check it exists before traversing - if (node.body) { - - // Skip BlockStatement to prevent creating BlockStatement scope. - if (node.body.type === Syntax.BlockStatement) { - this.visitChildren(node.body); - } else { - this.visit(node.body); - } - } - - this.close(node); - } - - visitClass(node) { - if (node.type === Syntax.ClassDeclaration) { - this.currentScope().__define(node.id, - new Definition( - Variable.ClassName, - node.id, - node, - null, - null, - null - )); - } - - this.visit(node.superClass); - - this.scopeManager.__nestClassScope(node); - - if (node.id) { - this.currentScope().__define(node.id, - new Definition( - Variable.ClassName, - node.id, - node - )); - } - this.visit(node.body); - - this.close(node); - } - - visitProperty(node) { - let previous; - - if (node.computed) { - this.visit(node.key); - } - - const isMethodDefinition = node.type === Syntax.MethodDefinition; - - if (isMethodDefinition) { - previous = this.pushInnerMethodDefinition(true); - } - this.visit(node.value); - if (isMethodDefinition) { - this.popInnerMethodDefinition(previous); - } - } - - visitForIn(node) { - if (node.left.type === Syntax.VariableDeclaration && node.left.kind !== "var") { - this.scopeManager.__nestForScope(node); - } - - if (node.left.type === Syntax.VariableDeclaration) { - this.visit(node.left); - this.visitPattern(node.left.declarations[0].id, pattern => { - this.currentScope().__referencing(pattern, Reference.WRITE, node.right, null, true, true); - }); - } else { - this.visitPattern(node.left, { processRightHandNodes: true }, (pattern, info) => { - let maybeImplicitGlobal = null; - - if (!this.currentScope().isStrict) { - maybeImplicitGlobal = { - pattern, - node - }; - } - this.referencingDefaultValue(pattern, info.assignments, maybeImplicitGlobal, false); - this.currentScope().__referencing(pattern, Reference.WRITE, node.right, maybeImplicitGlobal, true, false); - }); - } - this.visit(node.right); - this.visit(node.body); - - this.close(node); - } - - visitVariableDeclaration(variableTargetScope, type, node, index) { - - const decl = node.declarations[index]; - const init = decl.init; - - this.visitPattern(decl.id, { processRightHandNodes: true }, (pattern, info) => { - variableTargetScope.__define( - pattern, - new Definition( - type, - pattern, - decl, - node, - index, - node.kind - ) - ); - - this.referencingDefaultValue(pattern, info.assignments, null, true); - if (init) { - this.currentScope().__referencing(pattern, Reference.WRITE, init, null, !info.topLevel, true); - } - }); - } - - AssignmentExpression(node) { - if (PatternVisitor.isPattern(node.left)) { - if (node.operator === "=") { - this.visitPattern(node.left, { processRightHandNodes: true }, (pattern, info) => { - let maybeImplicitGlobal = null; - - if (!this.currentScope().isStrict) { - maybeImplicitGlobal = { - pattern, - node - }; - } - this.referencingDefaultValue(pattern, info.assignments, maybeImplicitGlobal, false); - this.currentScope().__referencing(pattern, Reference.WRITE, node.right, maybeImplicitGlobal, !info.topLevel, false); - }); - } else { - this.currentScope().__referencing(node.left, Reference.RW, node.right); - } - } else { - this.visit(node.left); - } - this.visit(node.right); - } - - CatchClause(node) { - this.scopeManager.__nestCatchScope(node); - - this.visitPattern(node.param, { processRightHandNodes: true }, (pattern, info) => { - this.currentScope().__define(pattern, - new Definition( - Variable.CatchClause, - node.param, - node, - null, - null, - null - )); - this.referencingDefaultValue(pattern, info.assignments, null, true); - }); - this.visit(node.body); - - this.close(node); - } - - Program(node) { - this.scopeManager.__nestGlobalScope(node); - - if (this.scopeManager.__isNodejsScope()) { - - // Force strictness of GlobalScope to false when using node.js scope. - this.currentScope().isStrict = false; - this.scopeManager.__nestFunctionScope(node, false); - } - - if (this.scopeManager.__isES6() && this.scopeManager.isModule()) { - this.scopeManager.__nestModuleScope(node); - } - - if (this.scopeManager.isStrictModeSupported() && this.scopeManager.isImpliedStrict()) { - this.currentScope().isStrict = true; - } - - this.visitChildren(node); - this.close(node); - } - - Identifier(node) { - this.currentScope().__referencing(node); - } - - UpdateExpression(node) { - if (PatternVisitor.isPattern(node.argument)) { - this.currentScope().__referencing(node.argument, Reference.RW, null); - } else { - this.visitChildren(node); - } - } - - MemberExpression(node) { - this.visit(node.object); - if (node.computed) { - this.visit(node.property); - } - } - - Property(node) { - this.visitProperty(node); - } - - MethodDefinition(node) { - this.visitProperty(node); - } - - BreakStatement() {} // eslint-disable-line class-methods-use-this - - ContinueStatement() {} // eslint-disable-line class-methods-use-this - - LabeledStatement(node) { - this.visit(node.body); - } - - ForStatement(node) { - - // Create ForStatement declaration. - // NOTE: In ES6, ForStatement dynamically generates - // per iteration environment. However, escope is - // a static analyzer, we only generate one scope for ForStatement. - if (node.init && node.init.type === Syntax.VariableDeclaration && node.init.kind !== "var") { - this.scopeManager.__nestForScope(node); - } - - this.visitChildren(node); - - this.close(node); - } - - ClassExpression(node) { - this.visitClass(node); - } - - ClassDeclaration(node) { - this.visitClass(node); - } - - CallExpression(node) { - - // Check this is direct call to eval - if (!this.scopeManager.__ignoreEval() && node.callee.type === Syntax.Identifier && node.callee.name === "eval") { - - // NOTE: This should be `variableScope`. Since direct eval call always creates Lexical environment and - // let / const should be enclosed into it. Only VariableDeclaration affects on the caller's environment. - this.currentScope().variableScope.__detectEval(); - } - this.visitChildren(node); - } - - BlockStatement(node) { - if (this.scopeManager.__isES6()) { - this.scopeManager.__nestBlockScope(node); - } - - this.visitChildren(node); - - this.close(node); - } - - ThisExpression() { - this.currentScope().variableScope.__detectThis(); - } - - WithStatement(node) { - this.visit(node.object); - - // Then nest scope for WithStatement. - this.scopeManager.__nestWithScope(node); - - this.visit(node.body); - - this.close(node); - } - - VariableDeclaration(node) { - const variableTargetScope = (node.kind === "var") ? this.currentScope().variableScope : this.currentScope(); - - for (let i = 0, iz = node.declarations.length; i < iz; ++i) { - const decl = node.declarations[i]; - - this.visitVariableDeclaration(variableTargetScope, Variable.Variable, node, i); - if (decl.init) { - this.visit(decl.init); - } - } - } - - // sec 13.11.8 - SwitchStatement(node) { - this.visit(node.discriminant); - - if (this.scopeManager.__isES6()) { - this.scopeManager.__nestSwitchScope(node); - } - - for (let i = 0, iz = node.cases.length; i < iz; ++i) { - this.visit(node.cases[i]); - } - - this.close(node); - } - - FunctionDeclaration(node) { - this.visitFunction(node); - } - - FunctionExpression(node) { - this.visitFunction(node); - } - - ForOfStatement(node) { - this.visitForIn(node); - } - - ForInStatement(node) { - this.visitForIn(node); - } - - ArrowFunctionExpression(node) { - this.visitFunction(node); - } - - ImportDeclaration(node) { - assert(this.scopeManager.__isES6() && this.scopeManager.isModule(), "ImportDeclaration should appear when the mode is ES6 and in the module context."); - - const importer = new Importer(node, this); - - importer.visit(node); - } - - visitExportDeclaration(node) { - if (node.source) { - return; - } - if (node.declaration) { - this.visit(node.declaration); - return; - } - - this.visitChildren(node); - } - - // TODO: ExportDeclaration doesn't exist. for bc? - ExportDeclaration(node) { - this.visitExportDeclaration(node); - } - - ExportAllDeclaration(node) { - this.visitExportDeclaration(node); - } - - ExportDefaultDeclaration(node) { - this.visitExportDeclaration(node); - } - - ExportNamedDeclaration(node) { - this.visitExportDeclaration(node); - } - - ExportSpecifier(node) { - - // TODO: `node.id` doesn't exist. for bc? - const local = (node.id || node.local); - - this.visit(local); - } - - MetaProperty() { // eslint-disable-line class-methods-use-this - - // do nothing. - } -} - -module.exports = Referencer; - -/* vim: set sw=4 ts=4 et tw=80 : */ diff --git a/tools/eslint/node_modules/eslint-scope/lib/scope-manager.js b/tools/eslint/node_modules/eslint-scope/lib/scope-manager.js deleted file mode 100644 index c1927994b1166e..00000000000000 --- a/tools/eslint/node_modules/eslint-scope/lib/scope-manager.js +++ /dev/null @@ -1,247 +0,0 @@ -/* - Copyright (C) 2015 Yusuke Suzuki - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - ARE DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY - DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ -"use strict"; - -/* eslint-disable no-underscore-dangle */ - -const Scope = require("./scope"); -const assert = require("assert"); - -const GlobalScope = Scope.GlobalScope; -const CatchScope = Scope.CatchScope; -const WithScope = Scope.WithScope; -const ModuleScope = Scope.ModuleScope; -const ClassScope = Scope.ClassScope; -const SwitchScope = Scope.SwitchScope; -const FunctionScope = Scope.FunctionScope; -const ForScope = Scope.ForScope; -const FunctionExpressionNameScope = Scope.FunctionExpressionNameScope; -const BlockScope = Scope.BlockScope; - -/** - * @class ScopeManager - */ -class ScopeManager { - constructor(options) { - this.scopes = []; - this.globalScope = null; - this.__nodeToScope = new WeakMap(); - this.__currentScope = null; - this.__options = options; - this.__declaredVariables = new WeakMap(); - } - - __useDirective() { - return this.__options.directive; - } - - __isOptimistic() { - return this.__options.optimistic; - } - - __ignoreEval() { - return this.__options.ignoreEval; - } - - __isNodejsScope() { - return this.__options.nodejsScope; - } - - isModule() { - return this.__options.sourceType === "module"; - } - - isImpliedStrict() { - return this.__options.impliedStrict; - } - - isStrictModeSupported() { - return this.__options.ecmaVersion >= 5; - } - - // Returns appropriate scope for this node. - __get(node) { - return this.__nodeToScope.get(node); - } - - /** - * Get variables that are declared by the node. - * - * "are declared by the node" means the node is same as `Variable.defs[].node` or `Variable.defs[].parent`. - * If the node declares nothing, this method returns an empty array. - * CAUTION: This API is experimental. See https://github.com/estools/escope/pull/69 for more details. - * - * @param {Espree.Node} node - a node to get. - * @returns {Variable[]} variables that declared by the node. - */ - getDeclaredVariables(node) { - return this.__declaredVariables.get(node) || []; - } - - /** - * acquire scope from node. - * @method ScopeManager#acquire - * @param {Espree.Node} node - node for the acquired scope. - * @param {boolean=} inner - look up the most inner scope, default value is false. - * @returns {Scope?} Scope from node - */ - acquire(node, inner) { - - /** - * predicate - * @param {Scope} testScope - scope to test - * @returns {boolean} predicate - */ - function predicate(testScope) { - if (testScope.type === "function" && testScope.functionExpressionScope) { - return false; - } - return true; - } - - const scopes = this.__get(node); - - if (!scopes || scopes.length === 0) { - return null; - } - - // Heuristic selection from all scopes. - // If you would like to get all scopes, please use ScopeManager#acquireAll. - if (scopes.length === 1) { - return scopes[0]; - } - - if (inner) { - for (let i = scopes.length - 1; i >= 0; --i) { - const scope = scopes[i]; - - if (predicate(scope)) { - return scope; - } - } - } else { - for (let i = 0, iz = scopes.length; i < iz; ++i) { - const scope = scopes[i]; - - if (predicate(scope)) { - return scope; - } - } - } - - return null; - } - - /** - * acquire all scopes from node. - * @method ScopeManager#acquireAll - * @param {Espree.Node} node - node for the acquired scope. - * @returns {Scopes?} Scope array - */ - acquireAll(node) { - return this.__get(node); - } - - /** - * release the node. - * @method ScopeManager#release - * @param {Espree.Node} node - releasing node. - * @param {boolean=} inner - look up the most inner scope, default value is false. - * @returns {Scope?} upper scope for the node. - */ - release(node, inner) { - const scopes = this.__get(node); - - if (scopes && scopes.length) { - const scope = scopes[0].upper; - - if (!scope) { - return null; - } - return this.acquire(scope.block, inner); - } - return null; - } - - attach() { } // eslint-disable-line class-methods-use-this - - detach() { } // eslint-disable-line class-methods-use-this - - __nestScope(scope) { - if (scope instanceof GlobalScope) { - assert(this.__currentScope === null); - this.globalScope = scope; - } - this.__currentScope = scope; - return scope; - } - - __nestGlobalScope(node) { - return this.__nestScope(new GlobalScope(this, node)); - } - - __nestBlockScope(node) { - return this.__nestScope(new BlockScope(this, this.__currentScope, node)); - } - - __nestFunctionScope(node, isMethodDefinition) { - return this.__nestScope(new FunctionScope(this, this.__currentScope, node, isMethodDefinition)); - } - - __nestForScope(node) { - return this.__nestScope(new ForScope(this, this.__currentScope, node)); - } - - __nestCatchScope(node) { - return this.__nestScope(new CatchScope(this, this.__currentScope, node)); - } - - __nestWithScope(node) { - return this.__nestScope(new WithScope(this, this.__currentScope, node)); - } - - __nestClassScope(node) { - return this.__nestScope(new ClassScope(this, this.__currentScope, node)); - } - - __nestSwitchScope(node) { - return this.__nestScope(new SwitchScope(this, this.__currentScope, node)); - } - - __nestModuleScope(node) { - return this.__nestScope(new ModuleScope(this, this.__currentScope, node)); - } - - __nestFunctionExpressionNameScope(node) { - return this.__nestScope(new FunctionExpressionNameScope(this, this.__currentScope, node)); - } - - __isES6() { - return this.__options.ecmaVersion >= 6; - } -} - -module.exports = ScopeManager; - -/* vim: set sw=4 ts=4 et tw=80 : */ diff --git a/tools/eslint/node_modules/eslint-scope/lib/scope.js b/tools/eslint/node_modules/eslint-scope/lib/scope.js deleted file mode 100644 index bdb5f637f684e5..00000000000000 --- a/tools/eslint/node_modules/eslint-scope/lib/scope.js +++ /dev/null @@ -1,748 +0,0 @@ -/* - Copyright (C) 2015 Yusuke Suzuki - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - ARE DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY - DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ -"use strict"; - -/* eslint-disable no-underscore-dangle */ -/* eslint-disable no-undefined */ - -const Syntax = require("estraverse").Syntax; - -const Reference = require("./reference"); -const Variable = require("./variable"); -const Definition = require("./definition").Definition; -const assert = require("assert"); - -/** - * Test if scope is struct - * @param {Scope} scope - scope - * @param {Block} block - block - * @param {boolean} isMethodDefinition - is method definition - * @param {boolean} useDirective - use directive - * @returns {boolean} is strict scope - */ -function isStrictScope(scope, block, isMethodDefinition, useDirective) { - let body; - - // When upper scope is exists and strict, inner scope is also strict. - if (scope.upper && scope.upper.isStrict) { - return true; - } - - if (isMethodDefinition) { - return true; - } - - if (scope.type === "class" || scope.type === "module") { - return true; - } - - if (scope.type === "block" || scope.type === "switch") { - return false; - } - - if (scope.type === "function") { - if (block.type === Syntax.ArrowFunctionExpression && block.body.type !== Syntax.BlockStatement) { - return false; - } - - if (block.type === Syntax.Program) { - body = block; - } else { - body = block.body; - } - - if (!body) { - return false; - } - } else if (scope.type === "global") { - body = block; - } else { - return false; - } - - // Search 'use strict' directive. - if (useDirective) { - for (let i = 0, iz = body.body.length; i < iz; ++i) { - const stmt = body.body[i]; - - if (stmt.type !== Syntax.DirectiveStatement) { - break; - } - if (stmt.raw === "\"use strict\"" || stmt.raw === "'use strict'") { - return true; - } - } - } else { - for (let i = 0, iz = body.body.length; i < iz; ++i) { - const stmt = body.body[i]; - - if (stmt.type !== Syntax.ExpressionStatement) { - break; - } - const expr = stmt.expression; - - if (expr.type !== Syntax.Literal || typeof expr.value !== "string") { - break; - } - if (expr.raw !== null && expr.raw !== undefined) { - if (expr.raw === "\"use strict\"" || expr.raw === "'use strict'") { - return true; - } - } else { - if (expr.value === "use strict") { - return true; - } - } - } - } - return false; -} - -/** - * Register scope - * @param {ScopeManager} scopeManager - scope manager - * @param {Scope} scope - scope - * @returns {void} - */ -function registerScope(scopeManager, scope) { - scopeManager.scopes.push(scope); - - const scopes = scopeManager.__nodeToScope.get(scope.block); - - if (scopes) { - scopes.push(scope); - } else { - scopeManager.__nodeToScope.set(scope.block, [scope]); - } -} - -/** - * Should be statically - * @param {Object} def - def - * @returns {boolean} should be statically - */ -function shouldBeStatically(def) { - return ( - (def.type === Variable.ClassName) || - (def.type === Variable.Variable && def.parent.kind !== "var") - ); -} - -/** - * @class Scope - */ -class Scope { - constructor(scopeManager, type, upperScope, block, isMethodDefinition) { - - /** - * One of 'module', 'block', 'switch', 'function', 'catch', 'with', 'function', 'class', 'global'. - * @member {String} Scope#type - */ - this.type = type; - - /** - * The scoped {@link Variable}s of this scope, as { Variable.name - * : Variable }. - * @member {Map} Scope#set - */ - this.set = new Map(); - - /** - * The tainted variables of this scope, as { Variable.name : - * boolean }. - * @member {Map} Scope#taints */ - this.taints = new Map(); - - /** - * Generally, through the lexical scoping of JS you can always know - * which variable an identifier in the source code refers to. There are - * a few exceptions to this rule. With 'global' and 'with' scopes you - * can only decide at runtime which variable a reference refers to. - * Moreover, if 'eval()' is used in a scope, it might introduce new - * bindings in this or its parent scopes. - * All those scopes are considered 'dynamic'. - * @member {boolean} Scope#dynamic - */ - this.dynamic = this.type === "global" || this.type === "with"; - - /** - * A reference to the scope-defining syntax node. - * @member {espree.Node} Scope#block - */ - this.block = block; - - /** - * The {@link Reference|references} that are not resolved with this scope. - * @member {Reference[]} Scope#through - */ - this.through = []; - - /** - * The scoped {@link Variable}s of this scope. In the case of a - * 'function' scope this includes the automatic argument arguments as - * its first element, as well as all further formal arguments. - * @member {Variable[]} Scope#variables - */ - this.variables = []; - - /** - * Any variable {@link Reference|reference} found in this scope. This - * includes occurrences of local variables as well as variables from - * parent scopes (including the global scope). For local variables - * this also includes defining occurrences (like in a 'var' statement). - * In a 'function' scope this does not include the occurrences of the - * formal parameter in the parameter list. - * @member {Reference[]} Scope#references - */ - this.references = []; - - /** - * For 'global' and 'function' scopes, this is a self-reference. For - * other scope types this is the variableScope value of the - * parent scope. - * @member {Scope} Scope#variableScope - */ - this.variableScope = - (this.type === "global" || this.type === "function" || this.type === "module") ? this : upperScope.variableScope; - - /** - * Whether this scope is created by a FunctionExpression. - * @member {boolean} Scope#functionExpressionScope - */ - this.functionExpressionScope = false; - - /** - * Whether this is a scope that contains an 'eval()' invocation. - * @member {boolean} Scope#directCallToEvalScope - */ - this.directCallToEvalScope = false; - - /** - * @member {boolean} Scope#thisFound - */ - this.thisFound = false; - - this.__left = []; - - /** - * Reference to the parent {@link Scope|scope}. - * @member {Scope} Scope#upper - */ - this.upper = upperScope; - - /** - * Whether 'use strict' is in effect in this scope. - * @member {boolean} Scope#isStrict - */ - this.isStrict = isStrictScope(this, block, isMethodDefinition, scopeManager.__useDirective()); - - /** - * List of nested {@link Scope}s. - * @member {Scope[]} Scope#childScopes - */ - this.childScopes = []; - if (this.upper) { - this.upper.childScopes.push(this); - } - - this.__declaredVariables = scopeManager.__declaredVariables; - - registerScope(scopeManager, this); - } - - __shouldStaticallyClose(scopeManager) { - return (!this.dynamic || scopeManager.__isOptimistic()); - } - - __shouldStaticallyCloseForGlobal(ref) { - - // On global scope, let/const/class declarations should be resolved statically. - const name = ref.identifier.name; - - if (!this.set.has(name)) { - return false; - } - - const variable = this.set.get(name); - const defs = variable.defs; - - return defs.length > 0 && defs.every(shouldBeStatically); - } - - __staticCloseRef(ref) { - if (!this.__resolve(ref)) { - this.__delegateToUpperScope(ref); - } - } - - __dynamicCloseRef(ref) { - - // notify all names are through to global - let current = this; - - do { - current.through.push(ref); - current = current.upper; - } while (current); - } - - __globalCloseRef(ref) { - - // let/const/class declarations should be resolved statically. - // others should be resolved dynamically. - if (this.__shouldStaticallyCloseForGlobal(ref)) { - this.__staticCloseRef(ref); - } else { - this.__dynamicCloseRef(ref); - } - } - - __close(scopeManager) { - let closeRef; - - if (this.__shouldStaticallyClose(scopeManager)) { - closeRef = this.__staticCloseRef; - } else if (this.type !== "global") { - closeRef = this.__dynamicCloseRef; - } else { - closeRef = this.__globalCloseRef; - } - - // Try Resolving all references in this scope. - for (let i = 0, iz = this.__left.length; i < iz; ++i) { - const ref = this.__left[i]; - - closeRef.call(this, ref); - } - this.__left = null; - - return this.upper; - } - - // To override by function scopes. - // References in default parameters isn't resolved to variables which are in their function body. - __isValidResolution(ref, variable) { // eslint-disable-line class-methods-use-this, no-unused-vars - return true; - } - - __resolve(ref) { - const name = ref.identifier.name; - - if (!this.set.has(name)) { - return false; - } - const variable = this.set.get(name); - - if (!this.__isValidResolution(ref, variable)) { - return false; - } - variable.references.push(ref); - variable.stack = variable.stack && ref.from.variableScope === this.variableScope; - if (ref.tainted) { - variable.tainted = true; - this.taints.set(variable.name, true); - } - ref.resolved = variable; - - return true; - } - - __delegateToUpperScope(ref) { - if (this.upper) { - this.upper.__left.push(ref); - } - this.through.push(ref); - } - - __addDeclaredVariablesOfNode(variable, node) { - if (node === null || node === undefined) { - return; - } - - let variables = this.__declaredVariables.get(node); - - if (variables === null || variables === undefined) { - variables = []; - this.__declaredVariables.set(node, variables); - } - if (variables.indexOf(variable) === -1) { - variables.push(variable); - } - } - - __defineGeneric(name, set, variables, node, def) { - let variable; - - variable = set.get(name); - if (!variable) { - variable = new Variable(name, this); - set.set(name, variable); - variables.push(variable); - } - - if (def) { - variable.defs.push(def); - this.__addDeclaredVariablesOfNode(variable, def.node); - this.__addDeclaredVariablesOfNode(variable, def.parent); - } - if (node) { - variable.identifiers.push(node); - } - } - - __define(node, def) { - if (node && node.type === Syntax.Identifier) { - this.__defineGeneric( - node.name, - this.set, - this.variables, - node, - def - ); - } - } - - __referencing(node, assign, writeExpr, maybeImplicitGlobal, partial, init) { - - // because Array element may be null - if (!node || node.type !== Syntax.Identifier) { - return; - } - - // Specially handle like `this`. - if (node.name === "super") { - return; - } - - const ref = new Reference(node, this, assign || Reference.READ, writeExpr, maybeImplicitGlobal, !!partial, !!init); - - this.references.push(ref); - this.__left.push(ref); - } - - __detectEval() { - let current = this; - - this.directCallToEvalScope = true; - do { - current.dynamic = true; - current = current.upper; - } while (current); - } - - __detectThis() { - this.thisFound = true; - } - - __isClosed() { - return this.__left === null; - } - - /** - * returns resolved {Reference} - * @method Scope#resolve - * @param {Espree.Identifier} ident - identifier to be resolved. - * @returns {Reference} reference - */ - resolve(ident) { - let ref, i, iz; - - assert(this.__isClosed(), "Scope should be closed."); - assert(ident.type === Syntax.Identifier, "Target should be identifier."); - for (i = 0, iz = this.references.length; i < iz; ++i) { - ref = this.references[i]; - if (ref.identifier === ident) { - return ref; - } - } - return null; - } - - /** - * returns this scope is static - * @method Scope#isStatic - * @returns {boolean} static - */ - isStatic() { - return !this.dynamic; - } - - /** - * returns this scope has materialized arguments - * @method Scope#isArgumentsMaterialized - * @returns {boolean} arguemnts materialized - */ - isArgumentsMaterialized() { // eslint-disable-line class-methods-use-this - return true; - } - - /** - * returns this scope has materialized `this` reference - * @method Scope#isThisMaterialized - * @returns {boolean} this materialized - */ - isThisMaterialized() { // eslint-disable-line class-methods-use-this - return true; - } - - isUsedName(name) { - if (this.set.has(name)) { - return true; - } - for (let i = 0, iz = this.through.length; i < iz; ++i) { - if (this.through[i].identifier.name === name) { - return true; - } - } - return false; - } -} - -class GlobalScope extends Scope { - constructor(scopeManager, block) { - super(scopeManager, "global", null, block, false); - this.implicit = { - set: new Map(), - variables: [], - - /** - * List of {@link Reference}s that are left to be resolved (i.e. which - * need to be linked to the variable they refer to). - * @member {Reference[]} Scope#implicit#left - */ - left: [] - }; - } - - __close(scopeManager) { - const implicit = []; - - for (let i = 0, iz = this.__left.length; i < iz; ++i) { - const ref = this.__left[i]; - - if (ref.__maybeImplicitGlobal && !this.set.has(ref.identifier.name)) { - implicit.push(ref.__maybeImplicitGlobal); - } - } - - // create an implicit global variable from assignment expression - for (let i = 0, iz = implicit.length; i < iz; ++i) { - const info = implicit[i]; - - this.__defineImplicit(info.pattern, - new Definition( - Variable.ImplicitGlobalVariable, - info.pattern, - info.node, - null, - null, - null - )); - - } - - this.implicit.left = this.__left; - - return super.__close(scopeManager); - } - - __defineImplicit(node, def) { - if (node && node.type === Syntax.Identifier) { - this.__defineGeneric( - node.name, - this.implicit.set, - this.implicit.variables, - node, - def - ); - } - } -} - -class ModuleScope extends Scope { - constructor(scopeManager, upperScope, block) { - super(scopeManager, "module", upperScope, block, false); - } -} - -class FunctionExpressionNameScope extends Scope { - constructor(scopeManager, upperScope, block) { - super(scopeManager, "function-expression-name", upperScope, block, false); - this.__define(block.id, - new Definition( - Variable.FunctionName, - block.id, - block, - null, - null, - null - )); - this.functionExpressionScope = true; - } -} - -class CatchScope extends Scope { - constructor(scopeManager, upperScope, block) { - super(scopeManager, "catch", upperScope, block, false); - } -} - -class WithScope extends Scope { - constructor(scopeManager, upperScope, block) { - super(scopeManager, "with", upperScope, block, false); - } - - __close(scopeManager) { - if (this.__shouldStaticallyClose(scopeManager)) { - return super.__close(scopeManager); - } - - for (let i = 0, iz = this.__left.length; i < iz; ++i) { - const ref = this.__left[i]; - - ref.tainted = true; - this.__delegateToUpperScope(ref); - } - this.__left = null; - - return this.upper; - } -} - -class BlockScope extends Scope { - constructor(scopeManager, upperScope, block) { - super(scopeManager, "block", upperScope, block, false); - } -} - -class SwitchScope extends Scope { - constructor(scopeManager, upperScope, block) { - super(scopeManager, "switch", upperScope, block, false); - } -} - -class FunctionScope extends Scope { - constructor(scopeManager, upperScope, block, isMethodDefinition) { - super(scopeManager, "function", upperScope, block, isMethodDefinition); - - // section 9.2.13, FunctionDeclarationInstantiation. - // NOTE Arrow functions never have an arguments objects. - if (this.block.type !== Syntax.ArrowFunctionExpression) { - this.__defineArguments(); - } - } - - isArgumentsMaterialized() { - - // TODO(Constellation) - // We can more aggressive on this condition like this. - // - // function t() { - // // arguments of t is always hidden. - // function arguments() { - // } - // } - if (this.block.type === Syntax.ArrowFunctionExpression) { - return false; - } - - if (!this.isStatic()) { - return true; - } - - const variable = this.set.get("arguments"); - - assert(variable, "Always have arguments variable."); - return variable.tainted || variable.references.length !== 0; - } - - isThisMaterialized() { - if (!this.isStatic()) { - return true; - } - return this.thisFound; - } - - __defineArguments() { - this.__defineGeneric( - "arguments", - this.set, - this.variables, - null, - null - ); - this.taints.set("arguments", true); - } - - // References in default parameters isn't resolved to variables which are in their function body. - // const x = 1 - // function f(a = x) { // This `x` is resolved to the `x` in the outer scope. - // const x = 2 - // console.log(a) - // } - __isValidResolution(ref, variable) { - - // If `options.nodejsScope` is true, `this.block` becomes a Program node. - if (this.block.type === "Program") { - return true; - } - - const bodyStart = this.block.body.range[0]; - - // It's invalid resolution in the following case: - return !( - variable.scope === this && - ref.identifier.range[0] < bodyStart && // the reference is in the parameter part. - variable.defs.every(d => d.name.range[0] >= bodyStart) // the variable is in the body. - ); - } -} - -class ForScope extends Scope { - constructor(scopeManager, upperScope, block) { - super(scopeManager, "for", upperScope, block, false); - } -} - -class ClassScope extends Scope { - constructor(scopeManager, upperScope, block) { - super(scopeManager, "class", upperScope, block, false); - } -} - -module.exports = { - Scope, - GlobalScope, - ModuleScope, - FunctionExpressionNameScope, - CatchScope, - WithScope, - BlockScope, - SwitchScope, - FunctionScope, - ForScope, - ClassScope -}; - -/* vim: set sw=4 ts=4 et tw=80 : */ diff --git a/tools/eslint/node_modules/eslint-scope/lib/variable.js b/tools/eslint/node_modules/eslint-scope/lib/variable.js deleted file mode 100644 index 702c4780a248a3..00000000000000 --- a/tools/eslint/node_modules/eslint-scope/lib/variable.js +++ /dev/null @@ -1,88 +0,0 @@ -/* - Copyright (C) 2015 Yusuke Suzuki - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - ARE DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY - DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ -"use strict"; - -/** - * A Variable represents a locally scoped identifier. These include arguments to - * functions. - * @class Variable - */ -class Variable { - constructor(name, scope) { - - /** - * The variable name, as given in the source code. - * @member {String} Variable#name - */ - this.name = name; - - /** - * List of defining occurrences of this variable (like in 'var ...' - * statements or as parameter), as AST nodes. - * @member {espree.Identifier[]} Variable#identifiers - */ - this.identifiers = []; - - /** - * List of {@link Reference|references} of this variable (excluding parameter entries) - * in its defining scope and all nested scopes. For defining - * occurrences only see {@link Variable#defs}. - * @member {Reference[]} Variable#references - */ - this.references = []; - - /** - * List of defining occurrences of this variable (like in 'var ...' - * statements or as parameter), as custom objects. - * @member {Definition[]} Variable#defs - */ - this.defs = []; - - this.tainted = false; - - /** - * Whether this is a stack variable. - * @member {boolean} Variable#stack - */ - this.stack = true; - - /** - * Reference to the enclosing Scope. - * @member {Scope} Variable#scope - */ - this.scope = scope; - } -} - -Variable.CatchClause = "CatchClause"; -Variable.Parameter = "Parameter"; -Variable.FunctionName = "FunctionName"; -Variable.ClassName = "ClassName"; -Variable.Variable = "Variable"; -Variable.ImportBinding = "ImportBinding"; -Variable.ImplicitGlobalVariable = "ImplicitGlobalVariable"; - -module.exports = Variable; - -/* vim: set sw=4 ts=4 et tw=80 : */ diff --git a/tools/eslint/node_modules/eslint-scope/package.json b/tools/eslint/node_modules/eslint-scope/package.json deleted file mode 100644 index b700b92afbea29..00000000000000 --- a/tools/eslint/node_modules/eslint-scope/package.json +++ /dev/null @@ -1,48 +0,0 @@ -{ - "name": "eslint-scope", - "description": "ECMAScript scope analyzer for ESLint", - "homepage": "http://github.com/eslint/eslint-scope", - "main": "lib/index.js", - "version": "5.1.1", - "engines": { - "node": ">=8.0.0" - }, - "repository": "eslint/eslint-scope", - "bugs": { - "url": "https://github.com/eslint/eslint-scope/issues" - }, - "license": "BSD-2-Clause", - "scripts": { - "test": "node Makefile.js test", - "lint": "node Makefile.js lint", - "generate-release": "eslint-generate-release", - "generate-alpharelease": "eslint-generate-prerelease alpha", - "generate-betarelease": "eslint-generate-prerelease beta", - "generate-rcrelease": "eslint-generate-prerelease rc", - "publish-release": "eslint-publish-release" - }, - "files": [ - "LICENSE", - "README.md", - "lib" - ], - "dependencies": { - "esrecurse": "^4.3.0", - "estraverse": "^4.1.1" - }, - "devDependencies": { - "@typescript-eslint/parser": "^1.11.0", - "chai": "^4.2.0", - "eslint": "^6.0.1", - "eslint-config-eslint": "^5.0.1", - "eslint-plugin-node": "^9.1.0", - "eslint-release": "^1.0.0", - "eslint-visitor-keys": "^1.2.0", - "espree": "^7.1.0", - "istanbul": "^0.4.5", - "mocha": "^6.1.4", - "npm-license": "^0.3.3", - "shelljs": "^0.8.3", - "typescript": "^3.5.2" - } -} diff --git a/tools/eslint/node_modules/eslint-visitor-keys/LICENSE b/tools/eslint/node_modules/eslint-visitor-keys/LICENSE deleted file mode 100644 index 17a25538d9bd63..00000000000000 --- a/tools/eslint/node_modules/eslint-visitor-keys/LICENSE +++ /dev/null @@ -1,201 +0,0 @@ - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "{}" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright contributors - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. diff --git a/tools/eslint/node_modules/eslint-visitor-keys/lib/index.js b/tools/eslint/node_modules/eslint-visitor-keys/lib/index.js deleted file mode 100644 index cd8a3260834dcd..00000000000000 --- a/tools/eslint/node_modules/eslint-visitor-keys/lib/index.js +++ /dev/null @@ -1,81 +0,0 @@ -/** - * @author Toru Nagashima - * See LICENSE file in root directory for full license. - */ -"use strict"; - -const KEYS = require("./visitor-keys.json"); - -// Types. -const NODE_TYPES = Object.freeze(Object.keys(KEYS)); - -// Freeze the keys. -for (const type of NODE_TYPES) { - Object.freeze(KEYS[type]); -} -Object.freeze(KEYS); - -// List to ignore keys. -const KEY_BLACKLIST = new Set([ - "parent", - "leadingComments", - "trailingComments" -]); - -/** - * Check whether a given key should be used or not. - * @param {string} key The key to check. - * @returns {boolean} `true` if the key should be used. - */ -function filterKey(key) { - return !KEY_BLACKLIST.has(key) && key[0] !== "_"; -} - -//------------------------------------------------------------------------------ -// Public interfaces -//------------------------------------------------------------------------------ - -module.exports = Object.freeze({ - - /** - * Visitor keys. - * @type {{ [type: string]: string[] | undefined }} - */ - KEYS, - - /** - * Get visitor keys of a given node. - * @param {Object} node The AST node to get keys. - * @returns {string[]} Visitor keys of the node. - */ - getKeys(node) { - return Object.keys(node).filter(filterKey); - }, - - // Disable valid-jsdoc rule because it reports syntax error on the type of @returns. - // eslint-disable-next-line valid-jsdoc - /** - * Make the union set with `KEYS` and given keys. - * @param {Object} additionalKeys The additional keys. - * @returns {{ [type: string]: string[] | undefined }} The union set. - */ - unionWith(additionalKeys) { - const retv = Object.assign({}, KEYS); - - for (const type of Object.keys(additionalKeys)) { - if (retv.hasOwnProperty(type)) { - const keys = new Set(additionalKeys[type]); - - for (const key of retv[type]) { - keys.add(key); - } - - retv[type] = Object.freeze(Array.from(keys)); - } else { - retv[type] = Object.freeze(Array.from(additionalKeys[type])); - } - } - - return Object.freeze(retv); - } -}); diff --git a/tools/eslint/node_modules/eslint-visitor-keys/lib/visitor-keys.json b/tools/eslint/node_modules/eslint-visitor-keys/lib/visitor-keys.json deleted file mode 100644 index e648ee125acd58..00000000000000 --- a/tools/eslint/node_modules/eslint-visitor-keys/lib/visitor-keys.json +++ /dev/null @@ -1,289 +0,0 @@ -{ - "AssignmentExpression": [ - "left", - "right" - ], - "AssignmentPattern": [ - "left", - "right" - ], - "ArrayExpression": [ - "elements" - ], - "ArrayPattern": [ - "elements" - ], - "ArrowFunctionExpression": [ - "params", - "body" - ], - "AwaitExpression": [ - "argument" - ], - "BlockStatement": [ - "body" - ], - "BinaryExpression": [ - "left", - "right" - ], - "BreakStatement": [ - "label" - ], - "CallExpression": [ - "callee", - "arguments" - ], - "CatchClause": [ - "param", - "body" - ], - "ChainExpression": [ - "expression" - ], - "ClassBody": [ - "body" - ], - "ClassDeclaration": [ - "id", - "superClass", - "body" - ], - "ClassExpression": [ - "id", - "superClass", - "body" - ], - "ConditionalExpression": [ - "test", - "consequent", - "alternate" - ], - "ContinueStatement": [ - "label" - ], - "DebuggerStatement": [], - "DoWhileStatement": [ - "body", - "test" - ], - "EmptyStatement": [], - "ExportAllDeclaration": [ - "exported", - "source" - ], - "ExportDefaultDeclaration": [ - "declaration" - ], - "ExportNamedDeclaration": [ - "declaration", - "specifiers", - "source" - ], - "ExportSpecifier": [ - "exported", - "local" - ], - "ExpressionStatement": [ - "expression" - ], - "ExperimentalRestProperty": [ - "argument" - ], - "ExperimentalSpreadProperty": [ - "argument" - ], - "ForStatement": [ - "init", - "test", - "update", - "body" - ], - "ForInStatement": [ - "left", - "right", - "body" - ], - "ForOfStatement": [ - "left", - "right", - "body" - ], - "FunctionDeclaration": [ - "id", - "params", - "body" - ], - "FunctionExpression": [ - "id", - "params", - "body" - ], - "Identifier": [], - "IfStatement": [ - "test", - "consequent", - "alternate" - ], - "ImportDeclaration": [ - "specifiers", - "source" - ], - "ImportDefaultSpecifier": [ - "local" - ], - "ImportExpression": [ - "source" - ], - "ImportNamespaceSpecifier": [ - "local" - ], - "ImportSpecifier": [ - "imported", - "local" - ], - "JSXAttribute": [ - "name", - "value" - ], - "JSXClosingElement": [ - "name" - ], - "JSXElement": [ - "openingElement", - "children", - "closingElement" - ], - "JSXEmptyExpression": [], - "JSXExpressionContainer": [ - "expression" - ], - "JSXIdentifier": [], - "JSXMemberExpression": [ - "object", - "property" - ], - "JSXNamespacedName": [ - "namespace", - "name" - ], - "JSXOpeningElement": [ - "name", - "attributes" - ], - "JSXSpreadAttribute": [ - "argument" - ], - "JSXText": [], - "JSXFragment": [ - "openingFragment", - "children", - "closingFragment" - ], - "Literal": [], - "LabeledStatement": [ - "label", - "body" - ], - "LogicalExpression": [ - "left", - "right" - ], - "MemberExpression": [ - "object", - "property" - ], - "MetaProperty": [ - "meta", - "property" - ], - "MethodDefinition": [ - "key", - "value" - ], - "NewExpression": [ - "callee", - "arguments" - ], - "ObjectExpression": [ - "properties" - ], - "ObjectPattern": [ - "properties" - ], - "PrivateIdentifier": [], - "Program": [ - "body" - ], - "Property": [ - "key", - "value" - ], - "PropertyDefinition": [ - "key", - "value" - ], - "RestElement": [ - "argument" - ], - "ReturnStatement": [ - "argument" - ], - "SequenceExpression": [ - "expressions" - ], - "SpreadElement": [ - "argument" - ], - "Super": [], - "SwitchStatement": [ - "discriminant", - "cases" - ], - "SwitchCase": [ - "test", - "consequent" - ], - "TaggedTemplateExpression": [ - "tag", - "quasi" - ], - "TemplateElement": [], - "TemplateLiteral": [ - "quasis", - "expressions" - ], - "ThisExpression": [], - "ThrowStatement": [ - "argument" - ], - "TryStatement": [ - "block", - "handler", - "finalizer" - ], - "UnaryExpression": [ - "argument" - ], - "UpdateExpression": [ - "argument" - ], - "VariableDeclaration": [ - "declarations" - ], - "VariableDeclarator": [ - "id", - "init" - ], - "WhileStatement": [ - "test", - "body" - ], - "WithStatement": [ - "object", - "body" - ], - "YieldExpression": [ - "argument" - ] -} diff --git a/tools/eslint/node_modules/eslint-visitor-keys/package.json b/tools/eslint/node_modules/eslint-visitor-keys/package.json deleted file mode 100644 index 775706ba4b4ed6..00000000000000 --- a/tools/eslint/node_modules/eslint-visitor-keys/package.json +++ /dev/null @@ -1,39 +0,0 @@ -{ - "name": "eslint-visitor-keys", - "version": "2.1.0", - "description": "Constants and utilities about visitor keys to traverse AST.", - "main": "lib/index.js", - "files": [ - "lib" - ], - "engines": { - "node": ">=10" - }, - "dependencies": {}, - "devDependencies": { - "eslint": "^4.7.2", - "eslint-config-eslint": "^4.0.0", - "eslint-release": "^1.0.0", - "mocha": "^3.5.3", - "nyc": "^11.2.1", - "opener": "^1.4.3" - }, - "scripts": { - "lint": "eslint lib tests/lib", - "test": "nyc mocha tests/lib", - "coverage": "nyc report --reporter lcov && opener coverage/lcov-report/index.html", - "generate-release": "eslint-generate-release", - "generate-alpharelease": "eslint-generate-prerelease alpha", - "generate-betarelease": "eslint-generate-prerelease beta", - "generate-rcrelease": "eslint-generate-prerelease rc", - "publish-release": "eslint-publish-release" - }, - "repository": "eslint/eslint-visitor-keys", - "keywords": [], - "author": "Toru Nagashima (https://github.com/mysticatea)", - "license": "Apache-2.0", - "bugs": { - "url": "https://github.com/eslint/eslint-visitor-keys/issues" - }, - "homepage": "https://github.com/eslint/eslint-visitor-keys#readme" -} diff --git a/tools/eslint/node_modules/eslint/LICENSE b/tools/eslint/node_modules/eslint/LICENSE deleted file mode 100644 index b607bb36e96c33..00000000000000 --- a/tools/eslint/node_modules/eslint/LICENSE +++ /dev/null @@ -1,19 +0,0 @@ -Copyright OpenJS Foundation and other contributors, - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. diff --git a/tools/eslint/node_modules/eslint/bin/eslint.js b/tools/eslint/node_modules/eslint/bin/eslint.js deleted file mode 100755 index fa3960e23b758c..00000000000000 --- a/tools/eslint/node_modules/eslint/bin/eslint.js +++ /dev/null @@ -1,174 +0,0 @@ -#!/usr/bin/env node - -/** - * @fileoverview Main CLI that is run via the eslint command. - * @author Nicholas C. Zakas - */ - -/* eslint no-console:off -- CLI */ - -"use strict"; - -// must do this initialization *before* other requires in order to work -if (process.argv.includes("--debug")) { - require("debug").enable("eslint:*,-eslint:code-path,eslintrc:*"); -} - -//------------------------------------------------------------------------------ -// Helpers -//------------------------------------------------------------------------------ - -/** - * Read data from stdin til the end. - * - * Note: See - * - https://github.com/nodejs/node/blob/master/doc/api/process.md#processstdin - * - https://github.com/nodejs/node/blob/master/doc/api/process.md#a-note-on-process-io - * - https://lists.gnu.org/archive/html/bug-gnu-emacs/2016-01/msg00419.html - * - https://github.com/nodejs/node/issues/7439 (historical) - * - * On Windows using `fs.readFileSync(STDIN_FILE_DESCRIPTOR, "utf8")` seems - * to read 4096 bytes before blocking and never drains to read further data. - * - * The investigation on the Emacs thread indicates: - * - * > Emacs on MS-Windows uses pipes to communicate with subprocesses; a - * > pipe on Windows has a 4K buffer. So as soon as Emacs writes more than - * > 4096 bytes to the pipe, the pipe becomes full, and Emacs then waits for - * > the subprocess to read its end of the pipe, at which time Emacs will - * > write the rest of the stuff. - * @returns {Promise} The read text. - */ -function readStdin() { - return new Promise((resolve, reject) => { - let content = ""; - let chunk = ""; - - process.stdin - .setEncoding("utf8") - .on("readable", () => { - while ((chunk = process.stdin.read()) !== null) { - content += chunk; - } - }) - .on("end", () => resolve(content)) - .on("error", reject); - }); -} - -/** - * Get the error message of a given value. - * @param {any} error The value to get. - * @returns {string} The error message. - */ -function getErrorMessage(error) { - - // Lazy loading because this is used only if an error happened. - const util = require("node:util"); - - // Foolproof -- third-party module might throw non-object. - if (typeof error !== "object" || error === null) { - return String(error); - } - - // Use templates if `error.messageTemplate` is present. - if (typeof error.messageTemplate === "string") { - try { - const template = require(`../messages/${error.messageTemplate}.js`); - - return template(error.messageData || {}); - } catch { - - // Ignore template error then fallback to use `error.stack`. - } - } - - // Use the stacktrace if it's an error object. - if (typeof error.stack === "string") { - return error.stack; - } - - // Otherwise, dump the object. - return util.format("%o", error); -} - -/** - * Tracks error messages that are shown to the user so we only ever show the - * same message once. - * @type {Set} - */ -const displayedErrors = new Set(); - -/** - * Tracks whether an unexpected error was caught - * @type {boolean} - */ -let hadFatalError = false; - -/** - * Catch and report unexpected error. - * @param {any} error The thrown error object. - * @returns {void} - */ -function onFatalError(error) { - process.exitCode = 2; - hadFatalError = true; - - const { version } = require("../package.json"); - const message = ` -Oops! Something went wrong! :( - -ESLint: ${version} - -${getErrorMessage(error)}`; - - if (!displayedErrors.has(message)) { - console.error(message); - displayedErrors.add(message); - } -} - -//------------------------------------------------------------------------------ -// Execution -//------------------------------------------------------------------------------ - -(async function main() { - process.on("uncaughtException", onFatalError); - process.on("unhandledRejection", onFatalError); - - // Call the config initializer if `--init` is present. - if (process.argv.includes("--init")) { - - // `eslint --init` has been moved to `@eslint/create-config` - console.warn("You can also run this command directly using 'npm init @eslint/config@latest'."); - - const spawn = require("cross-spawn"); - - spawn.sync("npm", ["init", "@eslint/config@latest"], { encoding: "utf8", stdio: "inherit" }); - return; - } - - // Otherwise, call the CLI. - const cli = require("../lib/cli"); - const exitCode = await cli.execute( - process.argv, - process.argv.includes("--stdin") ? await readStdin() : null, - true - ); - - /* - * If an uncaught exception or unhandled rejection was detected in the meantime, - * keep the fatal exit code 2 that is already assigned to `process.exitCode`. - * Without this condition, exit code 2 (unsuccessful execution) could be overwritten with - * 1 (successful execution, lint problems found) or even 0 (successful execution, no lint problems found). - * This ensures that unexpected errors that seemingly don't affect the success - * of the execution will still cause a non-zero exit code, as it's a common - * practice and the default behavior of Node.js to exit with non-zero - * in case of an uncaught exception or unhandled rejection. - * - * Otherwise, assign the exit code returned from CLI. - */ - if (!hadFatalError) { - process.exitCode = exitCode; - } -}()).catch(onFatalError); diff --git a/tools/eslint/node_modules/eslint/conf/default-cli-options.js b/tools/eslint/node_modules/eslint/conf/default-cli-options.js deleted file mode 100644 index dad03d89e93da3..00000000000000 --- a/tools/eslint/node_modules/eslint/conf/default-cli-options.js +++ /dev/null @@ -1,32 +0,0 @@ -/** - * @fileoverview Default CLIEngineOptions. - * @author Ian VanSchooten - */ - -"use strict"; - -module.exports = { - configFile: null, - baseConfig: false, - rulePaths: [], - useEslintrc: true, - envs: [], - globals: [], - extensions: null, - ignore: true, - ignorePath: void 0, - cache: false, - - /* - * in order to honor the cacheFile option if specified - * this option should not have a default value otherwise - * it will always be used - */ - cacheLocation: "", - cacheFile: ".eslintcache", - cacheStrategy: "metadata", - fix: false, - allowInlineConfig: true, - reportUnusedDisableDirectives: void 0, - globInputPaths: true -}; diff --git a/tools/eslint/node_modules/eslint/conf/ecma-version.js b/tools/eslint/node_modules/eslint/conf/ecma-version.js deleted file mode 100644 index 4e38c1d2cc3750..00000000000000 --- a/tools/eslint/node_modules/eslint/conf/ecma-version.js +++ /dev/null @@ -1,16 +0,0 @@ -/** - * @fileoverview Configuration related to ECMAScript versions - * @author Milos Djermanovic - */ - -"use strict"; - -/** - * The latest ECMAScript version supported by ESLint. - * @type {number} year-based ECMAScript version - */ -const LATEST_ECMA_VERSION = 2025; - -module.exports = { - LATEST_ECMA_VERSION -}; diff --git a/tools/eslint/node_modules/eslint/conf/globals.js b/tools/eslint/node_modules/eslint/conf/globals.js deleted file mode 100644 index 81df6bb200181e..00000000000000 --- a/tools/eslint/node_modules/eslint/conf/globals.js +++ /dev/null @@ -1,160 +0,0 @@ -/** - * @fileoverview Globals for ecmaVersion/sourceType - * @author Nicholas C. Zakas - */ - -"use strict"; - -//----------------------------------------------------------------------------- -// Globals -//----------------------------------------------------------------------------- - -const commonjs = { - exports: true, - global: false, - module: false, - require: false -}; - -const es3 = { - Array: false, - Boolean: false, - constructor: false, - Date: false, - decodeURI: false, - decodeURIComponent: false, - encodeURI: false, - encodeURIComponent: false, - Error: false, - escape: false, - eval: false, - EvalError: false, - Function: false, - hasOwnProperty: false, - Infinity: false, - isFinite: false, - isNaN: false, - isPrototypeOf: false, - Math: false, - NaN: false, - Number: false, - Object: false, - parseFloat: false, - parseInt: false, - propertyIsEnumerable: false, - RangeError: false, - ReferenceError: false, - RegExp: false, - String: false, - SyntaxError: false, - toLocaleString: false, - toString: false, - TypeError: false, - undefined: false, - unescape: false, - URIError: false, - valueOf: false -}; - -const es5 = { - ...es3, - JSON: false -}; - -const es2015 = { - ...es5, - ArrayBuffer: false, - DataView: false, - Float32Array: false, - Float64Array: false, - Int16Array: false, - Int32Array: false, - Int8Array: false, - Intl: false, - Map: false, - Promise: false, - Proxy: false, - Reflect: false, - Set: false, - Symbol: false, - Uint16Array: false, - Uint32Array: false, - Uint8Array: false, - Uint8ClampedArray: false, - WeakMap: false, - WeakSet: false -}; - -// no new globals in ES2016 -const es2016 = { - ...es2015 -}; - -const es2017 = { - ...es2016, - Atomics: false, - SharedArrayBuffer: false -}; - -// no new globals in ES2018 -const es2018 = { - ...es2017 -}; - -// no new globals in ES2019 -const es2019 = { - ...es2018 -}; - -const es2020 = { - ...es2019, - BigInt: false, - BigInt64Array: false, - BigUint64Array: false, - globalThis: false -}; - -const es2021 = { - ...es2020, - AggregateError: false, - FinalizationRegistry: false, - WeakRef: false -}; - -const es2022 = { - ...es2021 -}; - -const es2023 = { - ...es2022 -}; - -const es2024 = { - ...es2023 -}; - -const es2025 = { - ...es2024 -}; - - -//----------------------------------------------------------------------------- -// Exports -//----------------------------------------------------------------------------- - -module.exports = { - commonjs, - es3, - es5, - es2015, - es2016, - es2017, - es2018, - es2019, - es2020, - es2021, - es2022, - es2023, - es2024, - es2025 -}; diff --git a/tools/eslint/node_modules/eslint/conf/replacements.json b/tools/eslint/node_modules/eslint/conf/replacements.json deleted file mode 100644 index c047811e602d41..00000000000000 --- a/tools/eslint/node_modules/eslint/conf/replacements.json +++ /dev/null @@ -1,22 +0,0 @@ -{ - "rules": { - "generator-star": ["generator-star-spacing"], - "global-strict": ["strict"], - "no-arrow-condition": ["no-confusing-arrow", "no-constant-condition"], - "no-comma-dangle": ["comma-dangle"], - "no-empty-class": ["no-empty-character-class"], - "no-empty-label": ["no-labels"], - "no-extra-strict": ["strict"], - "no-reserved-keys": ["quote-props"], - "no-space-before-semi": ["semi-spacing"], - "no-wrap-func": ["no-extra-parens"], - "space-after-function-name": ["space-before-function-paren"], - "space-after-keywords": ["keyword-spacing"], - "space-before-function-parentheses": ["space-before-function-paren"], - "space-before-keywords": ["keyword-spacing"], - "space-in-brackets": ["object-curly-spacing", "array-bracket-spacing", "computed-property-spacing"], - "space-return-throw-case": ["keyword-spacing"], - "space-unary-word-ops": ["space-unary-ops"], - "spaced-line-comment": ["spaced-comment"] - } -} diff --git a/tools/eslint/node_modules/eslint/conf/rule-type-list.json b/tools/eslint/node_modules/eslint/conf/rule-type-list.json deleted file mode 100644 index f48454bb6300db..00000000000000 --- a/tools/eslint/node_modules/eslint/conf/rule-type-list.json +++ /dev/null @@ -1,30 +0,0 @@ -{ - "types": { - "problem": [], - "suggestion": [], - "layout": [] - }, - "deprecated": [], - "removed": [ - { "removed": "generator-star", "replacedBy": ["generator-star-spacing"] }, - { "removed": "global-strict", "replacedBy": ["strict"] }, - { "removed": "no-arrow-condition", "replacedBy": ["no-confusing-arrow", "no-constant-condition"] }, - { "removed": "no-comma-dangle", "replacedBy": ["comma-dangle"] }, - { "removed": "no-empty-class", "replacedBy": ["no-empty-character-class"] }, - { "removed": "no-empty-label", "replacedBy": ["no-labels"] }, - { "removed": "no-extra-strict", "replacedBy": ["strict"] }, - { "removed": "no-reserved-keys", "replacedBy": ["quote-props"] }, - { "removed": "no-space-before-semi", "replacedBy": ["semi-spacing"] }, - { "removed": "no-wrap-func", "replacedBy": ["no-extra-parens"] }, - { "removed": "space-after-function-name", "replacedBy": ["space-before-function-paren"] }, - { "removed": "space-after-keywords", "replacedBy": ["keyword-spacing"] }, - { "removed": "space-before-function-parentheses", "replacedBy": ["space-before-function-paren"] }, - { "removed": "space-before-keywords", "replacedBy": ["keyword-spacing"] }, - { "removed": "space-in-brackets", "replacedBy": ["object-curly-spacing", "array-bracket-spacing"] }, - { "removed": "space-return-throw-case", "replacedBy": ["keyword-spacing"] }, - { "removed": "space-unary-word-ops", "replacedBy": ["space-unary-ops"] }, - { "removed": "spaced-line-comment", "replacedBy": ["spaced-comment"] }, - { "removed": "valid-jsdoc", "replacedBy": [] }, - { "removed": "require-jsdoc", "replacedBy": [] } - ] -} diff --git a/tools/eslint/node_modules/eslint/lib/api.js b/tools/eslint/node_modules/eslint/lib/api.js deleted file mode 100644 index a134ecdaae88b6..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/api.js +++ /dev/null @@ -1,50 +0,0 @@ -/** - * @fileoverview Expose out ESLint and CLI to require. - * @author Ian Christian Myers - */ - -"use strict"; - -//----------------------------------------------------------------------------- -// Requirements -//----------------------------------------------------------------------------- - -const { ESLint, shouldUseFlatConfig } = require("./eslint/eslint"); -const { LegacyESLint } = require("./eslint/legacy-eslint"); -const { Linter } = require("./linter"); -const { RuleTester } = require("./rule-tester"); -const { SourceCode } = require("./languages/js/source-code"); - -//----------------------------------------------------------------------------- -// Functions -//----------------------------------------------------------------------------- - -/** - * Loads the correct ESLint constructor given the options. - * @param {Object} [options] The options object - * @param {boolean} [options.useFlatConfig] Whether or not to use a flat config - * @returns {Promise} The ESLint constructor - */ -async function loadESLint({ useFlatConfig } = {}) { - - /* - * Note: The v8.x version of this function also accepted a `cwd` option, but - * it is not used in this implementation so we silently ignore it. - */ - - const shouldESLintUseFlatConfig = useFlatConfig ?? (await shouldUseFlatConfig()); - - return shouldESLintUseFlatConfig ? ESLint : LegacyESLint; -} - -//----------------------------------------------------------------------------- -// Exports -//----------------------------------------------------------------------------- - -module.exports = { - Linter, - loadESLint, - ESLint, - RuleTester, - SourceCode -}; diff --git a/tools/eslint/node_modules/eslint/lib/cli-engine/cli-engine.js b/tools/eslint/node_modules/eslint/lib/cli-engine/cli-engine.js deleted file mode 100644 index 43fcc73d029a83..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/cli-engine/cli-engine.js +++ /dev/null @@ -1,1089 +0,0 @@ -/** - * @fileoverview Main CLI object. - * @author Nicholas C. Zakas - */ - -"use strict"; - -/* - * The CLI object should *not* call process.exit() directly. It should only return - * exit codes. This allows other programs to use the CLI object and still control - * when the program exits. - */ - -//------------------------------------------------------------------------------ -// Requirements -//------------------------------------------------------------------------------ - -const fs = require("node:fs"); -const path = require("node:path"); -const defaultOptions = require("../../conf/default-cli-options"); -const pkg = require("../../package.json"); - - -const { - Legacy: { - ConfigOps, - naming, - CascadingConfigArrayFactory, - IgnorePattern, - getUsedExtractedConfigs, - ModuleResolver - } -} = require("@eslint/eslintrc"); - -const { FileEnumerator } = require("./file-enumerator"); - -const { Linter } = require("../linter"); -const builtInRules = require("../rules"); -const loadRules = require("./load-rules"); -const hash = require("./hash"); -const LintResultCache = require("./lint-result-cache"); - -const debug = require("debug")("eslint:cli-engine"); -const removedFormatters = new Set([ - "checkstyle", - "codeframe", - "compact", - "jslint-xml", - "junit", - "table", - "tap", - "unix", - "visualstudio" -]); -const validFixTypes = new Set(["directive", "problem", "suggestion", "layout"]); - -//------------------------------------------------------------------------------ -// Typedefs -//------------------------------------------------------------------------------ - -// For VSCode IntelliSense -/** @typedef {import("../shared/types").ConfigData} ConfigData */ -/** @typedef {import("../shared/types").DeprecatedRuleInfo} DeprecatedRuleInfo */ -/** @typedef {import("../shared/types").LintMessage} LintMessage */ -/** @typedef {import("../shared/types").SuppressedLintMessage} SuppressedLintMessage */ -/** @typedef {import("../shared/types").ParserOptions} ParserOptions */ -/** @typedef {import("../shared/types").Plugin} Plugin */ -/** @typedef {import("../shared/types").RuleConf} RuleConf */ -/** @typedef {import("../shared/types").Rule} Rule */ -/** @typedef {import("../shared/types").FormatterFunction} FormatterFunction */ -/** @typedef {ReturnType} ConfigArray */ -/** @typedef {ReturnType} ExtractedConfig */ - -/** - * The options to configure a CLI engine with. - * @typedef {Object} CLIEngineOptions - * @property {boolean} [allowInlineConfig] Enable or disable inline configuration comments. - * @property {ConfigData} [baseConfig] Base config object, extended by all configs used with this CLIEngine instance - * @property {boolean} [cache] Enable result caching. - * @property {string} [cacheLocation] The cache file to use instead of .eslintcache. - * @property {string} [configFile] The configuration file to use. - * @property {string} [cwd] The value to use for the current working directory. - * @property {string[]} [envs] An array of environments to load. - * @property {string[]|null} [extensions] An array of file extensions to check. - * @property {boolean|Function} [fix] Execute in autofix mode. If a function, should return a boolean. - * @property {string[]} [fixTypes] Array of rule types to apply fixes for. - * @property {string[]} [globals] An array of global variables to declare. - * @property {boolean} [ignore] False disables use of .eslintignore. - * @property {string} [ignorePath] The ignore file to use instead of .eslintignore. - * @property {string|string[]} [ignorePattern] One or more glob patterns to ignore. - * @property {boolean} [useEslintrc] False disables looking for .eslintrc - * @property {string} [parser] The name of the parser to use. - * @property {ParserOptions} [parserOptions] An object of parserOption settings to use. - * @property {string[]} [plugins] An array of plugins to load. - * @property {Record} [rules] An object of rules to use. - * @property {string[]} [rulePaths] An array of directories to load custom rules from. - * @property {boolean|string} [reportUnusedDisableDirectives] `true`, `"error"` or '"warn"' adds reports for unused eslint-disable directives - * @property {boolean} [globInputPaths] Set to false to skip glob resolution of input file paths to lint (default: true). If false, each input file paths is assumed to be a non-glob path to an existing file. - * @property {string} [resolvePluginsRelativeTo] The folder where plugins should be resolved from, defaulting to the CWD - */ - -/** - * A linting result. - * @typedef {Object} LintResult - * @property {string} filePath The path to the file that was linted. - * @property {LintMessage[]} messages All of the messages for the result. - * @property {SuppressedLintMessage[]} suppressedMessages All of the suppressed messages for the result. - * @property {number} errorCount Number of errors for the result. - * @property {number} fatalErrorCount Number of fatal errors for the result. - * @property {number} warningCount Number of warnings for the result. - * @property {number} fixableErrorCount Number of fixable errors for the result. - * @property {number} fixableWarningCount Number of fixable warnings for the result. - * @property {string} [source] The source code of the file that was linted. - * @property {string} [output] The source code of the file that was linted, with as many fixes applied as possible. - */ - -/** - * Linting results. - * @typedef {Object} LintReport - * @property {LintResult[]} results All of the result. - * @property {number} errorCount Number of errors for the result. - * @property {number} fatalErrorCount Number of fatal errors for the result. - * @property {number} warningCount Number of warnings for the result. - * @property {number} fixableErrorCount Number of fixable errors for the result. - * @property {number} fixableWarningCount Number of fixable warnings for the result. - * @property {DeprecatedRuleInfo[]} usedDeprecatedRules The list of used deprecated rules. - */ - -/** - * Private data for CLIEngine. - * @typedef {Object} CLIEngineInternalSlots - * @property {Map} additionalPluginPool The map for additional plugins. - * @property {string} cacheFilePath The path to the cache of lint results. - * @property {CascadingConfigArrayFactory} configArrayFactory The factory of configs. - * @property {(filePath: string) => boolean} defaultIgnores The default predicate function to check if a file ignored or not. - * @property {FileEnumerator} fileEnumerator The file enumerator. - * @property {ConfigArray[]} lastConfigArrays The list of config arrays that the last `executeOnFiles` or `executeOnText` used. - * @property {LintResultCache|null} lintResultCache The cache of lint results. - * @property {Linter} linter The linter instance which has loaded rules. - * @property {CLIEngineOptions} options The normalized options of this instance. - */ - -//------------------------------------------------------------------------------ -// Helpers -//------------------------------------------------------------------------------ - -/** @type {WeakMap} */ -const internalSlotsMap = new WeakMap(); - -/** - * Determines if each fix type in an array is supported by ESLint and throws - * an error if not. - * @param {string[]} fixTypes An array of fix types to check. - * @returns {void} - * @throws {Error} If an invalid fix type is found. - */ -function validateFixTypes(fixTypes) { - for (const fixType of fixTypes) { - if (!validFixTypes.has(fixType)) { - throw new Error(`Invalid fix type "${fixType}" found.`); - } - } -} - -/** - * It will calculate the error and warning count for collection of messages per file - * @param {LintMessage[]} messages Collection of messages - * @returns {Object} Contains the stats - * @private - */ -function calculateStatsPerFile(messages) { - const stat = { - errorCount: 0, - fatalErrorCount: 0, - warningCount: 0, - fixableErrorCount: 0, - fixableWarningCount: 0 - }; - - for (let i = 0; i < messages.length; i++) { - const message = messages[i]; - - if (message.fatal || message.severity === 2) { - stat.errorCount++; - if (message.fatal) { - stat.fatalErrorCount++; - } - if (message.fix) { - stat.fixableErrorCount++; - } - } else { - stat.warningCount++; - if (message.fix) { - stat.fixableWarningCount++; - } - } - } - return stat; -} - -/** - * It will calculate the error and warning count for collection of results from all files - * @param {LintResult[]} results Collection of messages from all the files - * @returns {Object} Contains the stats - * @private - */ -function calculateStatsPerRun(results) { - const stat = { - errorCount: 0, - fatalErrorCount: 0, - warningCount: 0, - fixableErrorCount: 0, - fixableWarningCount: 0 - }; - - for (let i = 0; i < results.length; i++) { - const result = results[i]; - - stat.errorCount += result.errorCount; - stat.fatalErrorCount += result.fatalErrorCount; - stat.warningCount += result.warningCount; - stat.fixableErrorCount += result.fixableErrorCount; - stat.fixableWarningCount += result.fixableWarningCount; - } - - return stat; -} - -/** - * Processes an source code using ESLint. - * @param {Object} config The config object. - * @param {string} config.text The source code to verify. - * @param {string} config.cwd The path to the current working directory. - * @param {string|undefined} config.filePath The path to the file of `text`. If this is undefined, it uses ``. - * @param {ConfigArray} config.config The config. - * @param {boolean} config.fix If `true` then it does fix. - * @param {boolean} config.allowInlineConfig If `true` then it uses directive comments. - * @param {boolean|string} config.reportUnusedDisableDirectives If `true`, `"error"` or '"warn"', then it reports unused `eslint-disable` comments. - * @param {FileEnumerator} config.fileEnumerator The file enumerator to check if a path is a target or not. - * @param {Linter} config.linter The linter instance to verify. - * @returns {LintResult} The result of linting. - * @private - */ -function verifyText({ - text, - cwd, - filePath: providedFilePath, - config, - fix, - allowInlineConfig, - reportUnusedDisableDirectives, - fileEnumerator, - linter -}) { - const filePath = providedFilePath || ""; - - debug(`Lint ${filePath}`); - - /* - * Verify. - * `config.extractConfig(filePath)` requires an absolute path, but `linter` - * doesn't know CWD, so it gives `linter` an absolute path always. - */ - const filePathToVerify = filePath === "" ? path.join(cwd, filePath) : filePath; - const { fixed, messages, output } = linter.verifyAndFix( - text, - config, - { - allowInlineConfig, - filename: filePathToVerify, - fix, - reportUnusedDisableDirectives, - - /** - * Check if the linter should adopt a given code block or not. - * @param {string} blockFilename The virtual filename of a code block. - * @returns {boolean} `true` if the linter should adopt the code block. - */ - filterCodeBlock(blockFilename) { - return fileEnumerator.isTargetPath(blockFilename); - } - } - ); - - // Tweak and return. - const result = { - filePath, - messages, - suppressedMessages: linter.getSuppressedMessages(), - ...calculateStatsPerFile(messages) - }; - - if (fixed) { - result.output = output; - } - if ( - result.errorCount + result.warningCount > 0 && - typeof result.output === "undefined" - ) { - result.source = text; - } - - return result; -} - -/** - * Returns result with warning by ignore settings - * @param {string} filePath File path of checked code - * @param {string} baseDir Absolute path of base directory - * @returns {LintResult} Result with single warning - * @private - */ -function createIgnoreResult(filePath, baseDir) { - let message; - const isHidden = filePath.split(path.sep) - .find(segment => /^\./u.test(segment)); - const isInNodeModules = baseDir && path.relative(baseDir, filePath).startsWith("node_modules"); - - if (isHidden) { - message = "File ignored by default. Use a negated ignore pattern (like \"--ignore-pattern '!'\") to override."; - } else if (isInNodeModules) { - message = "File ignored by default. Use \"--ignore-pattern '!node_modules/*'\" to override."; - } else { - message = "File ignored because of a matching ignore pattern. Use \"--no-ignore\" to override."; - } - - return { - filePath: path.resolve(filePath), - messages: [ - { - ruleId: null, - fatal: false, - severity: 1, - message, - nodeType: null - } - ], - suppressedMessages: [], - errorCount: 0, - fatalErrorCount: 0, - warningCount: 1, - fixableErrorCount: 0, - fixableWarningCount: 0 - }; -} - -/** - * Get a rule. - * @param {string} ruleId The rule ID to get. - * @param {ConfigArray[]} configArrays The config arrays that have plugin rules. - * @returns {Rule|null} The rule or null. - */ -function getRule(ruleId, configArrays) { - for (const configArray of configArrays) { - const rule = configArray.pluginRules.get(ruleId); - - if (rule) { - return rule; - } - } - return builtInRules.get(ruleId) || null; -} - -/** - * Checks whether a message's rule type should be fixed. - * @param {LintMessage} message The message to check. - * @param {ConfigArray[]} lastConfigArrays The list of config arrays that the last `executeOnFiles` or `executeOnText` used. - * @param {string[]} fixTypes An array of fix types to check. - * @returns {boolean} Whether the message should be fixed. - */ -function shouldMessageBeFixed(message, lastConfigArrays, fixTypes) { - if (!message.ruleId) { - return fixTypes.has("directive"); - } - - const rule = message.ruleId && getRule(message.ruleId, lastConfigArrays); - - return Boolean(rule && rule.meta && fixTypes.has(rule.meta.type)); -} - -/** - * Collect used deprecated rules. - * @param {ConfigArray[]} usedConfigArrays The config arrays which were used. - * @returns {IterableIterator} Used deprecated rules. - */ -function *iterateRuleDeprecationWarnings(usedConfigArrays) { - const processedRuleIds = new Set(); - - // Flatten used configs. - /** @type {ExtractedConfig[]} */ - const configs = usedConfigArrays.flatMap(getUsedExtractedConfigs); - - // Traverse rule configs. - for (const config of configs) { - for (const [ruleId, ruleConfig] of Object.entries(config.rules)) { - - // Skip if it was processed. - if (processedRuleIds.has(ruleId)) { - continue; - } - processedRuleIds.add(ruleId); - - // Skip if it's not used. - if (!ConfigOps.getRuleSeverity(ruleConfig)) { - continue; - } - const rule = getRule(ruleId, usedConfigArrays); - - // Skip if it's not deprecated. - if (!(rule && rule.meta && rule.meta.deprecated)) { - continue; - } - - // This rule was used and deprecated. - yield { - ruleId, - replacedBy: rule.meta.replacedBy || [] - }; - } - } -} - -/** - * Checks if the given message is an error message. - * @param {LintMessage} message The message to check. - * @returns {boolean} Whether or not the message is an error message. - * @private - */ -function isErrorMessage(message) { - return message.severity === 2; -} - - -/** - * return the cacheFile to be used by eslint, based on whether the provided parameter is - * a directory or looks like a directory (ends in `path.sep`), in which case the file - * name will be the `cacheFile/.cache_hashOfCWD` - * - * if cacheFile points to a file or looks like a file then it will just use that file - * @param {string} cacheFile The name of file to be used to store the cache - * @param {string} cwd Current working directory - * @returns {string} the resolved path to the cache file - */ -function getCacheFile(cacheFile, cwd) { - - /* - * make sure the path separators are normalized for the environment/os - * keeping the trailing path separator if present - */ - const normalizedCacheFile = path.normalize(cacheFile); - - const resolvedCacheFile = path.resolve(cwd, normalizedCacheFile); - const looksLikeADirectory = normalizedCacheFile.slice(-1) === path.sep; - - /** - * return the name for the cache file in case the provided parameter is a directory - * @returns {string} the resolved path to the cacheFile - */ - function getCacheFileForDirectory() { - return path.join(resolvedCacheFile, `.cache_${hash(cwd)}`); - } - - let fileStats; - - try { - fileStats = fs.lstatSync(resolvedCacheFile); - } catch { - fileStats = null; - } - - - /* - * in case the file exists we need to verify if the provided path - * is a directory or a file. If it is a directory we want to create a file - * inside that directory - */ - if (fileStats) { - - /* - * is a directory or is a file, but the original file the user provided - * looks like a directory but `path.resolve` removed the `last path.sep` - * so we need to still treat this like a directory - */ - if (fileStats.isDirectory() || looksLikeADirectory) { - return getCacheFileForDirectory(); - } - - // is file so just use that file - return resolvedCacheFile; - } - - /* - * here we known the file or directory doesn't exist, - * so we will try to infer if its a directory if it looks like a directory - * for the current operating system. - */ - - // if the last character passed is a path separator we assume is a directory - if (looksLikeADirectory) { - return getCacheFileForDirectory(); - } - - return resolvedCacheFile; -} - -/** - * Convert a string array to a boolean map. - * @param {string[]|null} keys The keys to assign true. - * @param {boolean} defaultValue The default value for each property. - * @param {string} displayName The property name which is used in error message. - * @throws {Error} Requires array. - * @returns {Record} The boolean map. - */ -function toBooleanMap(keys, defaultValue, displayName) { - if (keys && !Array.isArray(keys)) { - throw new Error(`${displayName} must be an array.`); - } - if (keys && keys.length > 0) { - return keys.reduce((map, def) => { - const [key, value] = def.split(":"); - - if (key !== "__proto__") { - map[key] = value === void 0 - ? defaultValue - : value === "true"; - } - - return map; - }, {}); - } - return void 0; -} - -/** - * Create a config data from CLI options. - * @param {CLIEngineOptions} options The options - * @returns {ConfigData|null} The created config data. - */ -function createConfigDataFromOptions(options) { - const { - ignorePattern, - parser, - parserOptions, - plugins, - rules - } = options; - const env = toBooleanMap(options.envs, true, "envs"); - const globals = toBooleanMap(options.globals, false, "globals"); - - if ( - env === void 0 && - globals === void 0 && - (ignorePattern === void 0 || ignorePattern.length === 0) && - parser === void 0 && - parserOptions === void 0 && - plugins === void 0 && - rules === void 0 - ) { - return null; - } - return { - env, - globals, - ignorePatterns: ignorePattern, - parser, - parserOptions, - plugins, - rules - }; -} - -/** - * Checks whether a directory exists at the given location - * @param {string} resolvedPath A path from the CWD - * @throws {Error} As thrown by `fs.statSync` or `fs.isDirectory`. - * @returns {boolean} `true` if a directory exists - */ -function directoryExists(resolvedPath) { - try { - return fs.statSync(resolvedPath).isDirectory(); - } catch (error) { - if (error && (error.code === "ENOENT" || error.code === "ENOTDIR")) { - return false; - } - throw error; - } -} - -//------------------------------------------------------------------------------ -// Public Interface -//------------------------------------------------------------------------------ - -/** - * Core CLI. - */ -class CLIEngine { - - /** - * Creates a new instance of the core CLI engine. - * @param {CLIEngineOptions} providedOptions The options for this instance. - * @param {Object} [additionalData] Additional settings that are not CLIEngineOptions. - * @param {Record|null} [additionalData.preloadedPlugins] Preloaded plugins. - */ - constructor(providedOptions, { preloadedPlugins } = {}) { - const options = Object.assign( - Object.create(null), - defaultOptions, - { cwd: process.cwd() }, - providedOptions - ); - - if (options.fix === void 0) { - options.fix = false; - } - - const additionalPluginPool = new Map(); - - if (preloadedPlugins) { - for (const [id, plugin] of Object.entries(preloadedPlugins)) { - additionalPluginPool.set(id, plugin); - } - } - - const cacheFilePath = getCacheFile( - options.cacheLocation || options.cacheFile, - options.cwd - ); - const configArrayFactory = new CascadingConfigArrayFactory({ - additionalPluginPool, - baseConfig: options.baseConfig || null, - cliConfig: createConfigDataFromOptions(options), - cwd: options.cwd, - ignorePath: options.ignorePath, - resolvePluginsRelativeTo: options.resolvePluginsRelativeTo, - rulePaths: options.rulePaths, - specificConfigPath: options.configFile, - useEslintrc: options.useEslintrc, - builtInRules, - loadRules, - getEslintRecommendedConfig: () => require("@eslint/js").configs.recommended, - getEslintAllConfig: () => require("@eslint/js").configs.all - }); - const fileEnumerator = new FileEnumerator({ - configArrayFactory, - cwd: options.cwd, - extensions: options.extensions, - globInputPaths: options.globInputPaths, - errorOnUnmatchedPattern: options.errorOnUnmatchedPattern, - ignore: options.ignore - }); - const lintResultCache = - options.cache ? new LintResultCache(cacheFilePath, options.cacheStrategy) : null; - const linter = new Linter({ cwd: options.cwd, configType: "eslintrc" }); - - /** @type {ConfigArray[]} */ - const lastConfigArrays = [configArrayFactory.getConfigArrayForFile()]; - - // Store private data. - internalSlotsMap.set(this, { - additionalPluginPool, - cacheFilePath, - configArrayFactory, - defaultIgnores: IgnorePattern.createDefaultIgnore(options.cwd), - fileEnumerator, - lastConfigArrays, - lintResultCache, - linter, - options - }); - - // setup special filter for fixes - if (options.fix && options.fixTypes && options.fixTypes.length > 0) { - debug(`Using fix types ${options.fixTypes}`); - - // throw an error if any invalid fix types are found - validateFixTypes(options.fixTypes); - - // convert to Set for faster lookup - const fixTypes = new Set(options.fixTypes); - - // save original value of options.fix in case it's a function - const originalFix = (typeof options.fix === "function") - ? options.fix : () => true; - - options.fix = message => shouldMessageBeFixed(message, lastConfigArrays, fixTypes) && originalFix(message); - } - } - - getRules() { - const { lastConfigArrays } = internalSlotsMap.get(this); - - return new Map(function *() { - yield* builtInRules; - - for (const configArray of lastConfigArrays) { - yield* configArray.pluginRules; - } - }()); - } - - /** - * Returns results that only contains errors. - * @param {LintResult[]} results The results to filter. - * @returns {LintResult[]} The filtered results. - */ - static getErrorResults(results) { - const filtered = []; - - results.forEach(result => { - const filteredMessages = result.messages.filter(isErrorMessage); - const filteredSuppressedMessages = result.suppressedMessages.filter(isErrorMessage); - - if (filteredMessages.length > 0) { - filtered.push({ - ...result, - messages: filteredMessages, - suppressedMessages: filteredSuppressedMessages, - errorCount: filteredMessages.length, - warningCount: 0, - fixableErrorCount: result.fixableErrorCount, - fixableWarningCount: 0 - }); - } - }); - - return filtered; - } - - /** - * Outputs fixes from the given results to files. - * @param {LintReport} report The report object created by CLIEngine. - * @returns {void} - */ - static outputFixes(report) { - report.results.filter(result => Object.hasOwn(result, "output")).forEach(result => { - fs.writeFileSync(result.filePath, result.output); - }); - } - - /** - * Resolves the patterns passed into executeOnFiles() into glob-based patterns - * for easier handling. - * @param {string[]} patterns The file patterns passed on the command line. - * @returns {string[]} The equivalent glob patterns. - */ - resolveFileGlobPatterns(patterns) { - const { options } = internalSlotsMap.get(this); - - if (options.globInputPaths === false) { - return patterns.filter(Boolean); - } - - const extensions = (options.extensions || [".js"]).map(ext => ext.replace(/^\./u, "")); - const dirSuffix = `/**/*.{${extensions.join(",")}}`; - - return patterns.filter(Boolean).map(pathname => { - const resolvedPath = path.resolve(options.cwd, pathname); - const newPath = directoryExists(resolvedPath) - ? pathname.replace(/[/\\]$/u, "") + dirSuffix - : pathname; - - return path.normalize(newPath).replace(/\\/gu, "/"); - }); - } - - /** - * Executes the current configuration on an array of file and directory names. - * @param {string[]} patterns An array of file and directory names. - * @throws {Error} As may be thrown by `fs.unlinkSync`. - * @returns {LintReport} The results for all files that were linted. - */ - executeOnFiles(patterns) { - const { - cacheFilePath, - fileEnumerator, - lastConfigArrays, - lintResultCache, - linter, - options: { - allowInlineConfig, - cache, - cwd, - fix, - reportUnusedDisableDirectives - } - } = internalSlotsMap.get(this); - const results = []; - const startTime = Date.now(); - - // Clear the last used config arrays. - lastConfigArrays.length = 0; - - // Delete cache file; should this do here? - if (!cache) { - try { - fs.unlinkSync(cacheFilePath); - } catch (error) { - const errorCode = error && error.code; - - // Ignore errors when no such file exists or file system is read only (and cache file does not exist) - if (errorCode !== "ENOENT" && !(errorCode === "EROFS" && !fs.existsSync(cacheFilePath))) { - throw error; - } - } - } - - // Iterate source code files. - for (const { config, filePath, ignored } of fileEnumerator.iterateFiles(patterns)) { - if (ignored) { - results.push(createIgnoreResult(filePath, cwd)); - continue; - } - - /* - * Store used configs for: - * - this method uses to collect used deprecated rules. - * - `getRules()` method uses to collect all loaded rules. - * - `--fix-type` option uses to get the loaded rule's meta data. - */ - if (!lastConfigArrays.includes(config)) { - lastConfigArrays.push(config); - } - - // Skip if there is cached result. - if (lintResultCache) { - const cachedResult = - lintResultCache.getCachedLintResults(filePath, config); - - if (cachedResult) { - const hadMessages = - cachedResult.messages && - cachedResult.messages.length > 0; - - if (hadMessages && fix) { - debug(`Reprocessing cached file to allow autofix: ${filePath}`); - } else { - debug(`Skipping file since it hasn't changed: ${filePath}`); - results.push(cachedResult); - continue; - } - } - } - - // Do lint. - const result = verifyText({ - text: fs.readFileSync(filePath, "utf8"), - filePath, - config, - cwd, - fix, - allowInlineConfig, - reportUnusedDisableDirectives, - fileEnumerator, - linter - }); - - results.push(result); - - /* - * Store the lint result in the LintResultCache. - * NOTE: The LintResultCache will remove the file source and any - * other properties that are difficult to serialize, and will - * hydrate those properties back in on future lint runs. - */ - if (lintResultCache) { - lintResultCache.setCachedLintResults(filePath, config, result); - } - } - - // Persist the cache to disk. - if (lintResultCache) { - lintResultCache.reconcile(); - } - - debug(`Linting complete in: ${Date.now() - startTime}ms`); - let usedDeprecatedRules; - - return { - results, - ...calculateStatsPerRun(results), - - // Initialize it lazily because CLI and `ESLint` API don't use it. - get usedDeprecatedRules() { - if (!usedDeprecatedRules) { - usedDeprecatedRules = Array.from( - iterateRuleDeprecationWarnings(lastConfigArrays) - ); - } - return usedDeprecatedRules; - } - }; - } - - /** - * Executes the current configuration on text. - * @param {string} text A string of JavaScript code to lint. - * @param {string} [filename] An optional string representing the texts filename. - * @param {boolean} [warnIgnored] Always warn when a file is ignored - * @returns {LintReport} The results for the linting. - */ - executeOnText(text, filename, warnIgnored) { - const { - configArrayFactory, - fileEnumerator, - lastConfigArrays, - linter, - options: { - allowInlineConfig, - cwd, - fix, - reportUnusedDisableDirectives - } - } = internalSlotsMap.get(this); - const results = []; - const startTime = Date.now(); - const resolvedFilename = filename && path.resolve(cwd, filename); - - - // Clear the last used config arrays. - lastConfigArrays.length = 0; - if (resolvedFilename && this.isPathIgnored(resolvedFilename)) { - if (warnIgnored) { - results.push(createIgnoreResult(resolvedFilename, cwd)); - } - } else { - const config = configArrayFactory.getConfigArrayForFile( - resolvedFilename || "__placeholder__.js" - ); - - /* - * Store used configs for: - * - this method uses to collect used deprecated rules. - * - `getRules()` method uses to collect all loaded rules. - * - `--fix-type` option uses to get the loaded rule's meta data. - */ - lastConfigArrays.push(config); - - // Do lint. - results.push(verifyText({ - text, - filePath: resolvedFilename, - config, - cwd, - fix, - allowInlineConfig, - reportUnusedDisableDirectives, - fileEnumerator, - linter - })); - } - - debug(`Linting complete in: ${Date.now() - startTime}ms`); - let usedDeprecatedRules; - - return { - results, - ...calculateStatsPerRun(results), - - // Initialize it lazily because CLI and `ESLint` API don't use it. - get usedDeprecatedRules() { - if (!usedDeprecatedRules) { - usedDeprecatedRules = Array.from( - iterateRuleDeprecationWarnings(lastConfigArrays) - ); - } - return usedDeprecatedRules; - } - }; - } - - /** - * Returns a configuration object for the given file based on the CLI options. - * This is the same logic used by the ESLint CLI executable to determine - * configuration for each file it processes. - * @param {string} filePath The path of the file to retrieve a config object for. - * @throws {Error} If filepath a directory path. - * @returns {ConfigData} A configuration object for the file. - */ - getConfigForFile(filePath) { - const { configArrayFactory, options } = internalSlotsMap.get(this); - const absolutePath = path.resolve(options.cwd, filePath); - - if (directoryExists(absolutePath)) { - throw Object.assign( - new Error("'filePath' should not be a directory path."), - { messageTemplate: "print-config-with-directory-path" } - ); - } - - return configArrayFactory - .getConfigArrayForFile(absolutePath) - .extractConfig(absolutePath) - .toCompatibleObjectAsConfigFileContent(); - } - - /** - * Checks if a given path is ignored by ESLint. - * @param {string} filePath The path of the file to check. - * @returns {boolean} Whether or not the given path is ignored. - */ - isPathIgnored(filePath) { - const { - configArrayFactory, - defaultIgnores, - options: { cwd, ignore } - } = internalSlotsMap.get(this); - const absolutePath = path.resolve(cwd, filePath); - - if (ignore) { - const config = configArrayFactory - .getConfigArrayForFile(absolutePath) - .extractConfig(absolutePath); - const ignores = config.ignores || defaultIgnores; - - return ignores(absolutePath); - } - - return defaultIgnores(absolutePath); - } - - /** - * Returns the formatter representing the given format or null if the `format` is not a string. - * @param {string} [format] The name of the format to load or the path to a - * custom formatter. - * @throws {any} As may be thrown by requiring of formatter - * @returns {(FormatterFunction|null)} The formatter function or null if the `format` is not a string. - */ - getFormatter(format) { - - // default is stylish - const resolvedFormatName = format || "stylish"; - - // only strings are valid formatters - if (typeof resolvedFormatName === "string") { - - // replace \ with / for Windows compatibility - const normalizedFormatName = resolvedFormatName.replace(/\\/gu, "/"); - - const slots = internalSlotsMap.get(this); - const cwd = slots ? slots.options.cwd : process.cwd(); - const namespace = naming.getNamespaceFromTerm(normalizedFormatName); - - let formatterPath; - - // if there's a slash, then it's a file (TODO: this check seems dubious for scoped npm packages) - if (!namespace && normalizedFormatName.includes("/")) { - formatterPath = path.resolve(cwd, normalizedFormatName); - } else { - try { - const npmFormat = naming.normalizePackageName(normalizedFormatName, "eslint-formatter"); - - formatterPath = ModuleResolver.resolve(npmFormat, path.join(cwd, "__placeholder__.js")); - } catch { - formatterPath = path.resolve(__dirname, "formatters", normalizedFormatName); - } - } - - try { - return require(formatterPath); - } catch (ex) { - if (removedFormatters.has(format)) { - ex.message = `The ${format} formatter is no longer part of core ESLint. Install it manually with \`npm install -D eslint-formatter-${format}\``; - } else { - ex.message = `There was a problem loading formatter: ${formatterPath}\nError: ${ex.message}`; - } - throw ex; - } - - } else { - return null; - } - } -} - -CLIEngine.version = pkg.version; -CLIEngine.getFormatter = CLIEngine.prototype.getFormatter; - -module.exports = { - CLIEngine, - - /** - * Get the internal slots of a given CLIEngine instance for tests. - * @param {CLIEngine} instance The CLIEngine instance to get. - * @returns {CLIEngineInternalSlots} The internal slots. - */ - getCLIEngineInternalSlots(instance) { - return internalSlotsMap.get(instance); - } -}; diff --git a/tools/eslint/node_modules/eslint/lib/cli-engine/file-enumerator.js b/tools/eslint/node_modules/eslint/lib/cli-engine/file-enumerator.js deleted file mode 100644 index da5d1039da7f25..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/cli-engine/file-enumerator.js +++ /dev/null @@ -1,547 +0,0 @@ -/** - * @fileoverview `FileEnumerator` class. - * - * `FileEnumerator` class has two responsibilities: - * - * 1. Find target files by processing glob patterns. - * 2. Tie each target file and appropriate configuration. - * - * It provides a method: - * - * - `iterateFiles(patterns)` - * Iterate files which are matched by given patterns together with the - * corresponded configuration. This is for `CLIEngine#executeOnFiles()`. - * While iterating files, it loads the configuration file of each directory - * before iterate files on the directory, so we can use the configuration - * files to determine target files. - * - * @example - * const enumerator = new FileEnumerator(); - * const linter = new Linter(); - * - * for (const { config, filePath } of enumerator.iterateFiles(["*.js"])) { - * const code = fs.readFileSync(filePath, "utf8"); - * const messages = linter.verify(code, config, filePath); - * - * console.log(messages); - * } - * - * @author Toru Nagashima - */ -"use strict"; - -//------------------------------------------------------------------------------ -// Requirements -//------------------------------------------------------------------------------ - -const fs = require("node:fs"); -const path = require("node:path"); -const getGlobParent = require("glob-parent"); -const isGlob = require("is-glob"); -const escapeRegExp = require("escape-string-regexp"); -const { Minimatch } = require("minimatch"); - -const { - Legacy: { - IgnorePattern, - CascadingConfigArrayFactory - } -} = require("@eslint/eslintrc"); -const debug = require("debug")("eslint:file-enumerator"); - -//------------------------------------------------------------------------------ -// Helpers -//------------------------------------------------------------------------------ - -const minimatchOpts = { dot: true, matchBase: true }; -const dotfilesPattern = /(?:(?:^\.)|(?:[/\\]\.))[^/\\.].*/u; -const NONE = 0; -const IGNORED_SILENTLY = 1; -const IGNORED = 2; - -// For VSCode intellisense -/** @typedef {ReturnType} ConfigArray */ - -/** - * @typedef {Object} FileEnumeratorOptions - * @property {CascadingConfigArrayFactory} [configArrayFactory] The factory for config arrays. - * @property {string} [cwd] The base directory to start lookup. - * @property {string[]} [extensions] The extensions to match files for directory patterns. - * @property {boolean} [globInputPaths] Set to false to skip glob resolution of input file paths to lint (default: true). If false, each input file paths is assumed to be a non-glob path to an existing file. - * @property {boolean} [ignore] The flag to check ignored files. - * @property {string[]} [rulePaths] The value of `--rulesdir` option. - */ - -/** - * @typedef {Object} FileAndConfig - * @property {string} filePath The path to a target file. - * @property {ConfigArray} config The config entries of that file. - * @property {boolean} ignored If `true` then this file should be ignored and warned because it was directly specified. - */ - -/** - * @typedef {Object} FileEntry - * @property {string} filePath The path to a target file. - * @property {ConfigArray} config The config entries of that file. - * @property {NONE|IGNORED_SILENTLY|IGNORED} flag The flag. - * - `NONE` means the file is a target file. - * - `IGNORED_SILENTLY` means the file should be ignored silently. - * - `IGNORED` means the file should be ignored and warned because it was directly specified. - */ - -/** - * @typedef {Object} FileEnumeratorInternalSlots - * @property {CascadingConfigArrayFactory} configArrayFactory The factory for config arrays. - * @property {string} cwd The base directory to start lookup. - * @property {RegExp|null} extensionRegExp The RegExp to test if a string ends with specific file extensions. - * @property {boolean} globInputPaths Set to false to skip glob resolution of input file paths to lint (default: true). If false, each input file paths is assumed to be a non-glob path to an existing file. - * @property {boolean} ignoreFlag The flag to check ignored files. - * @property {(filePath:string, dot:boolean) => boolean} defaultIgnores The default predicate function to ignore files. - */ - -/** @type {WeakMap} */ -const internalSlotsMap = new WeakMap(); - -/** - * Check if a string is a glob pattern or not. - * @param {string} pattern A glob pattern. - * @returns {boolean} `true` if the string is a glob pattern. - */ -function isGlobPattern(pattern) { - return isGlob(path.sep === "\\" ? pattern.replace(/\\/gu, "/") : pattern); -} - -/** - * Get stats of a given path. - * @param {string} filePath The path to target file. - * @throws {Error} As may be thrown by `fs.statSync`. - * @returns {fs.Stats|null} The stats. - * @private - */ -function statSafeSync(filePath) { - try { - return fs.statSync(filePath); - } catch (error) { - - /* c8 ignore next */ - if (error.code !== "ENOENT") { - throw error; - } - return null; - } -} - -/** - * Get filenames in a given path to a directory. - * @param {string} directoryPath The path to target directory. - * @throws {Error} As may be thrown by `fs.readdirSync`. - * @returns {import("fs").Dirent[]} The filenames. - * @private - */ -function readdirSafeSync(directoryPath) { - try { - return fs.readdirSync(directoryPath, { withFileTypes: true }); - } catch (error) { - - /* c8 ignore next */ - if (error.code !== "ENOENT") { - throw error; - } - return []; - } -} - -/** - * Create a `RegExp` object to detect extensions. - * @param {string[] | null} extensions The extensions to create. - * @returns {RegExp | null} The created `RegExp` object or null. - */ -function createExtensionRegExp(extensions) { - if (extensions) { - const normalizedExts = extensions.map(ext => escapeRegExp( - ext.startsWith(".") - ? ext.slice(1) - : ext - )); - - return new RegExp( - `.\\.(?:${normalizedExts.join("|")})$`, - "u" - ); - } - return null; -} - -/** - * The error type when no files match a glob. - */ -class NoFilesFoundError extends Error { - - /** - * @param {string} pattern The glob pattern which was not found. - * @param {boolean} globDisabled If `true` then the pattern was a glob pattern, but glob was disabled. - */ - constructor(pattern, globDisabled) { - super(`No files matching '${pattern}' were found${globDisabled ? " (glob was disabled)" : ""}.`); - this.messageTemplate = "file-not-found"; - this.messageData = { pattern, globDisabled }; - } -} - -/** - * The error type when there are files matched by a glob, but all of them have been ignored. - */ -class AllFilesIgnoredError extends Error { - - /** - * @param {string} pattern The glob pattern which was not found. - */ - constructor(pattern) { - super(`All files matched by '${pattern}' are ignored.`); - this.messageTemplate = "all-files-ignored"; - this.messageData = { pattern }; - } -} - -/** - * This class provides the functionality that enumerates every file which is - * matched by given glob patterns and that configuration. - */ -class FileEnumerator { - - /** - * Initialize this enumerator. - * @param {FileEnumeratorOptions} options The options. - */ - constructor({ - cwd = process.cwd(), - configArrayFactory = new CascadingConfigArrayFactory({ - cwd, - getEslintRecommendedConfig: () => require("@eslint/js").configs.recommended, - getEslintAllConfig: () => require("@eslint/js").configs.all - }), - extensions = null, - globInputPaths = true, - errorOnUnmatchedPattern = true, - ignore = true - } = {}) { - internalSlotsMap.set(this, { - configArrayFactory, - cwd, - defaultIgnores: IgnorePattern.createDefaultIgnore(cwd), - extensionRegExp: createExtensionRegExp(extensions), - globInputPaths, - errorOnUnmatchedPattern, - ignoreFlag: ignore - }); - } - - /** - * Check if a given file is target or not. - * @param {string} filePath The path to a candidate file. - * @param {ConfigArray} [providedConfig] Optional. The configuration for the file. - * @returns {boolean} `true` if the file is a target. - */ - isTargetPath(filePath, providedConfig) { - const { - configArrayFactory, - extensionRegExp - } = internalSlotsMap.get(this); - - // If `--ext` option is present, use it. - if (extensionRegExp) { - return extensionRegExp.test(filePath); - } - - // `.js` file is target by default. - if (filePath.endsWith(".js")) { - return true; - } - - // use `overrides[].files` to check additional targets. - const config = - providedConfig || - configArrayFactory.getConfigArrayForFile( - filePath, - { ignoreNotFoundError: true } - ); - - return config.isAdditionalTargetPath(filePath); - } - - /** - * Iterate files which are matched by given glob patterns. - * @param {string|string[]} patternOrPatterns The glob patterns to iterate files. - * @throws {NoFilesFoundError|AllFilesIgnoredError} On an unmatched pattern. - * @returns {IterableIterator} The found files. - */ - *iterateFiles(patternOrPatterns) { - const { globInputPaths, errorOnUnmatchedPattern } = internalSlotsMap.get(this); - const patterns = Array.isArray(patternOrPatterns) - ? patternOrPatterns - : [patternOrPatterns]; - - debug("Start to iterate files: %o", patterns); - - // The set of paths to remove duplicate. - const set = new Set(); - - for (const pattern of patterns) { - let foundRegardlessOfIgnored = false; - let found = false; - - // Skip empty string. - if (!pattern) { - continue; - } - - // Iterate files of this pattern. - for (const { config, filePath, flag } of this._iterateFiles(pattern)) { - foundRegardlessOfIgnored = true; - if (flag === IGNORED_SILENTLY) { - continue; - } - found = true; - - // Remove duplicate paths while yielding paths. - if (!set.has(filePath)) { - set.add(filePath); - yield { - config, - filePath, - ignored: flag === IGNORED - }; - } - } - - // Raise an error if any files were not found. - if (errorOnUnmatchedPattern) { - if (!foundRegardlessOfIgnored) { - throw new NoFilesFoundError( - pattern, - !globInputPaths && isGlob(pattern) - ); - } - if (!found) { - throw new AllFilesIgnoredError(pattern); - } - } - } - - debug(`Complete iterating files: ${JSON.stringify(patterns)}`); - } - - /** - * Iterate files which are matched by a given glob pattern. - * @param {string} pattern The glob pattern to iterate files. - * @returns {IterableIterator} The found files. - */ - _iterateFiles(pattern) { - const { cwd, globInputPaths } = internalSlotsMap.get(this); - const absolutePath = path.resolve(cwd, pattern); - const isDot = dotfilesPattern.test(pattern); - const stat = statSafeSync(absolutePath); - - if (stat && stat.isDirectory()) { - return this._iterateFilesWithDirectory(absolutePath, isDot); - } - if (stat && stat.isFile()) { - return this._iterateFilesWithFile(absolutePath); - } - if (globInputPaths && isGlobPattern(pattern)) { - return this._iterateFilesWithGlob(pattern, isDot); - } - - return []; - } - - /** - * Iterate a file which is matched by a given path. - * @param {string} filePath The path to the target file. - * @returns {IterableIterator} The found files. - * @private - */ - _iterateFilesWithFile(filePath) { - debug(`File: ${filePath}`); - - const { configArrayFactory } = internalSlotsMap.get(this); - const config = configArrayFactory.getConfigArrayForFile(filePath); - const ignored = this._isIgnoredFile(filePath, { config, direct: true }); - const flag = ignored ? IGNORED : NONE; - - return [{ config, filePath, flag }]; - } - - /** - * Iterate files in a given path. - * @param {string} directoryPath The path to the target directory. - * @param {boolean} dotfiles If `true` then it doesn't skip dot files by default. - * @returns {IterableIterator} The found files. - * @private - */ - _iterateFilesWithDirectory(directoryPath, dotfiles) { - debug(`Directory: ${directoryPath}`); - - return this._iterateFilesRecursive( - directoryPath, - { dotfiles, recursive: true, selector: null } - ); - } - - /** - * Iterate files which are matched by a given glob pattern. - * @param {string} pattern The glob pattern to iterate files. - * @param {boolean} dotfiles If `true` then it doesn't skip dot files by default. - * @returns {IterableIterator} The found files. - * @private - */ - _iterateFilesWithGlob(pattern, dotfiles) { - debug(`Glob: ${pattern}`); - - const { cwd } = internalSlotsMap.get(this); - const directoryPath = path.resolve(cwd, getGlobParent(pattern)); - const absolutePath = path.resolve(cwd, pattern); - const globPart = absolutePath.slice(directoryPath.length + 1); - - /* - * recursive if there are `**` or path separators in the glob part. - * Otherwise, patterns such as `src/*.js`, it doesn't need recursive. - */ - const recursive = /\*\*|\/|\\/u.test(globPart); - const selector = new Minimatch(absolutePath, minimatchOpts); - - debug(`recursive? ${recursive}`); - - return this._iterateFilesRecursive( - directoryPath, - { dotfiles, recursive, selector } - ); - } - - /** - * Iterate files in a given path. - * @param {string} directoryPath The path to the target directory. - * @param {Object} options The options to iterate files. - * @param {boolean} [options.dotfiles] If `true` then it doesn't skip dot files by default. - * @param {boolean} [options.recursive] If `true` then it dives into sub directories. - * @param {InstanceType} [options.selector] The matcher to choose files. - * @returns {IterableIterator} The found files. - * @private - */ - *_iterateFilesRecursive(directoryPath, options) { - debug(`Enter the directory: ${directoryPath}`); - const { configArrayFactory } = internalSlotsMap.get(this); - - /** @type {ConfigArray|null} */ - let config = null; - - // Enumerate the files of this directory. - for (const entry of readdirSafeSync(directoryPath)) { - const filePath = path.join(directoryPath, entry.name); - const fileInfo = entry.isSymbolicLink() ? statSafeSync(filePath) : entry; - - if (!fileInfo) { - continue; - } - - // Check if the file is matched. - if (fileInfo.isFile()) { - if (!config) { - config = configArrayFactory.getConfigArrayForFile( - filePath, - - /* - * We must ignore `ConfigurationNotFoundError` at this - * point because we don't know if target files exist in - * this directory. - */ - { ignoreNotFoundError: true } - ); - } - const matched = options.selector - - // Started with a glob pattern; choose by the pattern. - ? options.selector.match(filePath) - - // Started with a directory path; choose by file extensions. - : this.isTargetPath(filePath, config); - - if (matched) { - const ignored = this._isIgnoredFile(filePath, { ...options, config }); - const flag = ignored ? IGNORED_SILENTLY : NONE; - - debug(`Yield: ${entry.name}${ignored ? " but ignored" : ""}`); - yield { - config: configArrayFactory.getConfigArrayForFile(filePath), - filePath, - flag - }; - } else { - debug(`Didn't match: ${entry.name}`); - } - - // Dive into the sub directory. - } else if (options.recursive && fileInfo.isDirectory()) { - if (!config) { - config = configArrayFactory.getConfigArrayForFile( - filePath, - { ignoreNotFoundError: true } - ); - } - const ignored = this._isIgnoredFile( - filePath + path.sep, - { ...options, config } - ); - - if (!ignored) { - yield* this._iterateFilesRecursive(filePath, options); - } - } - } - - debug(`Leave the directory: ${directoryPath}`); - } - - /** - * Check if a given file should be ignored. - * @param {string} filePath The path to a file to check. - * @param {Object} options Options - * @param {ConfigArray} [options.config] The config for this file. - * @param {boolean} [options.dotfiles] If `true` then this is not ignore dot files by default. - * @param {boolean} [options.direct] If `true` then this is a direct specified file. - * @returns {boolean} `true` if the file should be ignored. - * @private - */ - _isIgnoredFile(filePath, { - config: providedConfig, - dotfiles = false, - direct = false - }) { - const { - configArrayFactory, - defaultIgnores, - ignoreFlag - } = internalSlotsMap.get(this); - - if (ignoreFlag) { - const config = - providedConfig || - configArrayFactory.getConfigArrayForFile( - filePath, - { ignoreNotFoundError: true } - ); - const ignores = - config.extractConfig(filePath).ignores || defaultIgnores; - - return ignores(filePath, dotfiles); - } - - return !direct && defaultIgnores(filePath, dotfiles); - } -} - -//------------------------------------------------------------------------------ -// Public Interface -//------------------------------------------------------------------------------ - -module.exports = { FileEnumerator }; diff --git a/tools/eslint/node_modules/eslint/lib/cli-engine/formatters/formatters-meta.json b/tools/eslint/node_modules/eslint/lib/cli-engine/formatters/formatters-meta.json deleted file mode 100644 index 4cc61ae3c62d30..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/cli-engine/formatters/formatters-meta.json +++ /dev/null @@ -1,18 +0,0 @@ -[ - { - "name": "html", - "description": "Outputs results to HTML. The `html` formatter is useful for visual presentation in the browser." - }, - { - "name": "json-with-metadata", - "description": "Outputs JSON-serialized results. The `json-with-metadata` provides the same linting results as the [`json`](#json) formatter with additional metadata about the rules applied. The linting results are included in the `results` property and the rules metadata is included in the `metadata` property.\n\nAlternatively, you can use the [ESLint Node.js API](../../integrate/nodejs-api) to programmatically use ESLint." - }, - { - "name": "json", - "description": "Outputs JSON-serialized results. The `json` formatter is useful when you want to programmatically work with the CLI's linting results.\n\nAlternatively, you can use the [ESLint Node.js API](../../integrate/nodejs-api) to programmatically use ESLint." - }, - { - "name": "stylish", - "description": "Human-readable output format. This is the default formatter." - } -] diff --git a/tools/eslint/node_modules/eslint/lib/cli-engine/formatters/html.js b/tools/eslint/node_modules/eslint/lib/cli-engine/formatters/html.js deleted file mode 100644 index 1aa66fcefacc3b..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/cli-engine/formatters/html.js +++ /dev/null @@ -1,351 +0,0 @@ -/** - * @fileoverview HTML reporter - * @author Julian Laval - */ -"use strict"; - -//------------------------------------------------------------------------------ -// Helpers -//------------------------------------------------------------------------------ - -const encodeHTML = (function() { - const encodeHTMLRules = { - "&": "&", - "<": "<", - ">": ">", - '"': """, - "'": "'" - }; - const matchHTML = /[&<>"']/ug; - - return function(code) { - return code - ? code.toString().replace(matchHTML, m => encodeHTMLRules[m] || m) - : ""; - }; -}()); - -/** - * Get the final HTML document. - * @param {Object} it data for the document. - * @returns {string} HTML document. - */ -function pageTemplate(it) { - const { reportColor, reportSummary, date, results } = it; - - return ` - - - - - ESLint Report - - - - - -

-

ESLint Report

-
- ${reportSummary} - Generated on ${date} -
-
- - - ${results} - -
- - - -`.trimStart(); -} - -/** - * Given a word and a count, append an s if count is not one. - * @param {string} word A word in its singular form. - * @param {int} count A number controlling whether word should be pluralized. - * @returns {string} The original word with an s on the end if count is not one. - */ -function pluralize(word, count) { - return (count === 1 ? word : `${word}s`); -} - -/** - * Renders text along the template of x problems (x errors, x warnings) - * @param {string} totalErrors Total errors - * @param {string} totalWarnings Total warnings - * @returns {string} The formatted string, pluralized where necessary - */ -function renderSummary(totalErrors, totalWarnings) { - const totalProblems = totalErrors + totalWarnings; - let renderedText = `${totalProblems} ${pluralize("problem", totalProblems)}`; - - if (totalProblems !== 0) { - renderedText += ` (${totalErrors} ${pluralize("error", totalErrors)}, ${totalWarnings} ${pluralize("warning", totalWarnings)})`; - } - return renderedText; -} - -/** - * Get the color based on whether there are errors/warnings... - * @param {string} totalErrors Total errors - * @param {string} totalWarnings Total warnings - * @returns {int} The color code (0 = green, 1 = yellow, 2 = red) - */ -function renderColor(totalErrors, totalWarnings) { - if (totalErrors !== 0) { - return 2; - } - if (totalWarnings !== 0) { - return 1; - } - return 0; -} - -/** - * Get HTML (table row) describing a single message. - * @param {Object} it data for the message. - * @returns {string} HTML (table row) describing the message. - */ -function messageTemplate(it) { - const { - parentIndex, - lineNumber, - columnNumber, - severityNumber, - severityName, - message, - ruleUrl, - ruleId - } = it; - - return ` - - ${lineNumber}:${columnNumber} - ${severityName} - ${encodeHTML(message)} - - ${ruleId ? ruleId : ""} - - -`.trimStart(); -} - -/** - * Get HTML (table rows) describing the messages. - * @param {Array} messages Messages. - * @param {int} parentIndex Index of the parent HTML row. - * @param {Object} rulesMeta Dictionary containing metadata for each rule executed by the analysis. - * @returns {string} HTML (table rows) describing the messages. - */ -function renderMessages(messages, parentIndex, rulesMeta) { - - /** - * Get HTML (table row) describing a message. - * @param {Object} message Message. - * @returns {string} HTML (table row) describing a message. - */ - return messages.map(message => { - const lineNumber = message.line || 0; - const columnNumber = message.column || 0; - let ruleUrl; - - if (rulesMeta) { - const meta = rulesMeta[message.ruleId]; - - if (meta && meta.docs && meta.docs.url) { - ruleUrl = meta.docs.url; - } - } - - return messageTemplate({ - parentIndex, - lineNumber, - columnNumber, - severityNumber: message.severity, - severityName: message.severity === 1 ? "Warning" : "Error", - message: message.message, - ruleId: message.ruleId, - ruleUrl - }); - }).join("\n"); -} - -/** - * Get HTML (table row) describing the result for a single file. - * @param {Object} it data for the file. - * @returns {string} HTML (table row) describing the result for the file. - */ -function resultTemplate(it) { - const { color, index, filePath, summary } = it; - - return ` - - - [+] ${encodeHTML(filePath)} - ${encodeHTML(summary)} - - -`.trimStart(); -} - -/** - * Render the results. - * @param {Array} results Test results. - * @param {Object} rulesMeta Dictionary containing metadata for each rule executed by the analysis. - * @returns {string} HTML string describing the results. - */ -function renderResults(results, rulesMeta) { - return results.map((result, index) => resultTemplate({ - index, - color: renderColor(result.errorCount, result.warningCount), - filePath: result.filePath, - summary: renderSummary(result.errorCount, result.warningCount) - }) + renderMessages(result.messages, index, rulesMeta)).join("\n"); -} - -//------------------------------------------------------------------------------ -// Public Interface -//------------------------------------------------------------------------------ - -module.exports = function(results, data) { - let totalErrors, - totalWarnings; - - const metaData = data ? data.rulesMeta : {}; - - totalErrors = 0; - totalWarnings = 0; - - // Iterate over results to get totals - results.forEach(result => { - totalErrors += result.errorCount; - totalWarnings += result.warningCount; - }); - - return pageTemplate({ - date: new Date(), - reportColor: renderColor(totalErrors, totalWarnings), - reportSummary: renderSummary(totalErrors, totalWarnings), - results: renderResults(results, metaData) - }); -}; diff --git a/tools/eslint/node_modules/eslint/lib/cli-engine/formatters/json-with-metadata.js b/tools/eslint/node_modules/eslint/lib/cli-engine/formatters/json-with-metadata.js deleted file mode 100644 index 6899471547a4e3..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/cli-engine/formatters/json-with-metadata.js +++ /dev/null @@ -1,16 +0,0 @@ -/** - * @fileoverview JSON reporter, including rules metadata - * @author Chris Meyer - */ -"use strict"; - -//------------------------------------------------------------------------------ -// Public Interface -//------------------------------------------------------------------------------ - -module.exports = function(results, data) { - return JSON.stringify({ - results, - metadata: data - }); -}; diff --git a/tools/eslint/node_modules/eslint/lib/cli-engine/formatters/json.js b/tools/eslint/node_modules/eslint/lib/cli-engine/formatters/json.js deleted file mode 100644 index 82138af1874855..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/cli-engine/formatters/json.js +++ /dev/null @@ -1,13 +0,0 @@ -/** - * @fileoverview JSON reporter - * @author Burak Yigit Kaya aka BYK - */ -"use strict"; - -//------------------------------------------------------------------------------ -// Public Interface -//------------------------------------------------------------------------------ - -module.exports = function(results) { - return JSON.stringify(results); -}; diff --git a/tools/eslint/node_modules/eslint/lib/cli-engine/formatters/stylish.js b/tools/eslint/node_modules/eslint/lib/cli-engine/formatters/stylish.js deleted file mode 100644 index a808448b65233f..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/cli-engine/formatters/stylish.js +++ /dev/null @@ -1,101 +0,0 @@ -/** - * @fileoverview Stylish reporter - * @author Sindre Sorhus - */ -"use strict"; - -const chalk = require("chalk"), - stripAnsi = require("strip-ansi"), - table = require("text-table"); - -//------------------------------------------------------------------------------ -// Helpers -//------------------------------------------------------------------------------ - -/** - * Given a word and a count, append an s if count is not one. - * @param {string} word A word in its singular form. - * @param {int} count A number controlling whether word should be pluralized. - * @returns {string} The original word with an s on the end if count is not one. - */ -function pluralize(word, count) { - return (count === 1 ? word : `${word}s`); -} - -//------------------------------------------------------------------------------ -// Public Interface -//------------------------------------------------------------------------------ - -module.exports = function(results) { - - let output = "\n", - errorCount = 0, - warningCount = 0, - fixableErrorCount = 0, - fixableWarningCount = 0, - summaryColor = "yellow"; - - results.forEach(result => { - const messages = result.messages; - - if (messages.length === 0) { - return; - } - - errorCount += result.errorCount; - warningCount += result.warningCount; - fixableErrorCount += result.fixableErrorCount; - fixableWarningCount += result.fixableWarningCount; - - output += `${chalk.underline(result.filePath)}\n`; - - output += `${table( - messages.map(message => { - let messageType; - - if (message.fatal || message.severity === 2) { - messageType = chalk.red("error"); - summaryColor = "red"; - } else { - messageType = chalk.yellow("warning"); - } - - return [ - "", - message.line || 0, - message.column || 0, - messageType, - message.message.replace(/([^ ])\.$/u, "$1"), - chalk.dim(message.ruleId || "") - ]; - }), - { - align: ["", "r", "l"], - stringLength(str) { - return stripAnsi(str).length; - } - } - ).split("\n").map(el => el.replace(/(\d+)\s+(\d+)/u, (m, p1, p2) => chalk.dim(`${p1}:${p2}`))).join("\n")}\n\n`; - }); - - const total = errorCount + warningCount; - - if (total > 0) { - output += chalk[summaryColor].bold([ - "\u2716 ", total, pluralize(" problem", total), - " (", errorCount, pluralize(" error", errorCount), ", ", - warningCount, pluralize(" warning", warningCount), ")\n" - ].join("")); - - if (fixableErrorCount > 0 || fixableWarningCount > 0) { - output += chalk[summaryColor].bold([ - " ", fixableErrorCount, pluralize(" error", fixableErrorCount), " and ", - fixableWarningCount, pluralize(" warning", fixableWarningCount), - " potentially fixable with the `--fix` option.\n" - ].join("")); - } - } - - // Resets output color, for prevent change on top level - return total > 0 ? chalk.reset(output) : ""; -}; diff --git a/tools/eslint/node_modules/eslint/lib/cli-engine/hash.js b/tools/eslint/node_modules/eslint/lib/cli-engine/hash.js deleted file mode 100644 index 8e467734a02357..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/cli-engine/hash.js +++ /dev/null @@ -1,35 +0,0 @@ -/** - * @fileoverview Defining the hashing function in one place. - * @author Michael Ficarra - */ - -"use strict"; - -//------------------------------------------------------------------------------ -// Requirements -//------------------------------------------------------------------------------ - -const murmur = require("imurmurhash"); - -//------------------------------------------------------------------------------ -// Helpers -//------------------------------------------------------------------------------ - -//------------------------------------------------------------------------------ -// Private -//------------------------------------------------------------------------------ - -/** - * hash the given string - * @param {string} str the string to hash - * @returns {string} the hash - */ -function hash(str) { - return murmur(str).result().toString(36); -} - -//------------------------------------------------------------------------------ -// Public Interface -//------------------------------------------------------------------------------ - -module.exports = hash; diff --git a/tools/eslint/node_modules/eslint/lib/cli-engine/index.js b/tools/eslint/node_modules/eslint/lib/cli-engine/index.js deleted file mode 100644 index 52e45a6d7910a0..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/cli-engine/index.js +++ /dev/null @@ -1,7 +0,0 @@ -"use strict"; - -const { CLIEngine } = require("./cli-engine"); - -module.exports = { - CLIEngine -}; diff --git a/tools/eslint/node_modules/eslint/lib/cli-engine/lint-result-cache.js b/tools/eslint/node_modules/eslint/lib/cli-engine/lint-result-cache.js deleted file mode 100644 index 75e770f4b28a49..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/cli-engine/lint-result-cache.js +++ /dev/null @@ -1,203 +0,0 @@ -/** - * @fileoverview Utility for caching lint results. - * @author Kevin Partington - */ -"use strict"; - -//----------------------------------------------------------------------------- -// Requirements -//----------------------------------------------------------------------------- - -const assert = require("node:assert"); -const fs = require("node:fs"); -const fileEntryCache = require("file-entry-cache"); -const stringify = require("json-stable-stringify-without-jsonify"); -const pkg = require("../../package.json"); -const hash = require("./hash"); - -const debug = require("debug")("eslint:lint-result-cache"); - -//----------------------------------------------------------------------------- -// Helpers -//----------------------------------------------------------------------------- - -const configHashCache = new WeakMap(); -const nodeVersion = process && process.version; - -const validCacheStrategies = ["metadata", "content"]; -const invalidCacheStrategyErrorMessage = `Cache strategy must be one of: ${validCacheStrategies - .map(strategy => `"${strategy}"`) - .join(", ")}`; - -/** - * Tests whether a provided cacheStrategy is valid - * @param {string} cacheStrategy The cache strategy to use - * @returns {boolean} true if `cacheStrategy` is one of `validCacheStrategies`; false otherwise - */ -function isValidCacheStrategy(cacheStrategy) { - return ( - validCacheStrategies.includes(cacheStrategy) - ); -} - -/** - * Calculates the hash of the config - * @param {ConfigArray} config The config. - * @returns {string} The hash of the config - */ -function hashOfConfigFor(config) { - if (!configHashCache.has(config)) { - configHashCache.set(config, hash(`${pkg.version}_${nodeVersion}_${stringify(config)}`)); - } - - return configHashCache.get(config); -} - -//----------------------------------------------------------------------------- -// Public Interface -//----------------------------------------------------------------------------- - -/** - * Lint result cache. This wraps around the file-entry-cache module, - * transparently removing properties that are difficult or expensive to - * serialize and adding them back in on retrieval. - */ -class LintResultCache { - - /** - * Creates a new LintResultCache instance. - * @param {string} cacheFileLocation The cache file location. - * @param {"metadata" | "content"} cacheStrategy The cache strategy to use. - */ - constructor(cacheFileLocation, cacheStrategy) { - assert(cacheFileLocation, "Cache file location is required"); - assert(cacheStrategy, "Cache strategy is required"); - assert( - isValidCacheStrategy(cacheStrategy), - invalidCacheStrategyErrorMessage - ); - - debug(`Caching results to ${cacheFileLocation}`); - - const useChecksum = cacheStrategy === "content"; - - debug( - `Using "${cacheStrategy}" strategy to detect changes` - ); - - this.fileEntryCache = fileEntryCache.create( - cacheFileLocation, - void 0, - useChecksum - ); - this.cacheFileLocation = cacheFileLocation; - } - - /** - * Retrieve cached lint results for a given file path, if present in the - * cache. If the file is present and has not been changed, rebuild any - * missing result information. - * @param {string} filePath The file for which to retrieve lint results. - * @param {ConfigArray} config The config of the file. - * @returns {Object|null} The rebuilt lint results, or null if the file is - * changed or not in the filesystem. - */ - getCachedLintResults(filePath, config) { - - /* - * Cached lint results are valid if and only if: - * 1. The file is present in the filesystem - * 2. The file has not changed since the time it was previously linted - * 3. The ESLint configuration has not changed since the time the file - * was previously linted - * If any of these are not true, we will not reuse the lint results. - */ - const fileDescriptor = this.fileEntryCache.getFileDescriptor(filePath); - const hashOfConfig = hashOfConfigFor(config); - const changed = - fileDescriptor.changed || - fileDescriptor.meta.hashOfConfig !== hashOfConfig; - - if (fileDescriptor.notFound) { - debug(`File not found on the file system: ${filePath}`); - return null; - } - - if (changed) { - debug(`Cache entry not found or no longer valid: ${filePath}`); - return null; - } - - const cachedResults = fileDescriptor.meta.results; - - // Just in case, not sure if this can ever happen. - if (!cachedResults) { - return cachedResults; - } - - /* - * Shallow clone the object to ensure that any properties added or modified afterwards - * will not be accidentally stored in the cache file when `reconcile()` is called. - * https://github.com/eslint/eslint/issues/13507 - * All intentional changes to the cache file must be done through `setCachedLintResults()`. - */ - const results = { ...cachedResults }; - - // If source is present but null, need to reread the file from the filesystem. - if (results.source === null) { - debug(`Rereading cached result source from filesystem: ${filePath}`); - results.source = fs.readFileSync(filePath, "utf-8"); - } - - return results; - } - - /** - * Set the cached lint results for a given file path, after removing any - * information that will be both unnecessary and difficult to serialize. - * Avoids caching results with an "output" property (meaning fixes were - * applied), to prevent potentially incorrect results if fixes are not - * written to disk. - * @param {string} filePath The file for which to set lint results. - * @param {ConfigArray} config The config of the file. - * @param {Object} result The lint result to be set for the file. - * @returns {void} - */ - setCachedLintResults(filePath, config, result) { - if (result && Object.hasOwn(result, "output")) { - return; - } - - const fileDescriptor = this.fileEntryCache.getFileDescriptor(filePath); - - if (fileDescriptor && !fileDescriptor.notFound) { - debug(`Updating cached result: ${filePath}`); - - // Serialize the result, except that we want to remove the file source if present. - const resultToSerialize = Object.assign({}, result); - - /* - * Set result.source to null. - * In `getCachedLintResults`, if source is explicitly null, we will - * read the file from the filesystem to set the value again. - */ - if (Object.hasOwn(resultToSerialize, "source")) { - resultToSerialize.source = null; - } - - fileDescriptor.meta.results = resultToSerialize; - fileDescriptor.meta.hashOfConfig = hashOfConfigFor(config); - } - } - - /** - * Persists the in-memory cache to disk. - * @returns {void} - */ - reconcile() { - debug(`Persisting cached results: ${this.cacheFileLocation}`); - this.fileEntryCache.reconcile(); - } -} - -module.exports = LintResultCache; diff --git a/tools/eslint/node_modules/eslint/lib/cli-engine/load-rules.js b/tools/eslint/node_modules/eslint/lib/cli-engine/load-rules.js deleted file mode 100644 index a58f954e8684d8..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/cli-engine/load-rules.js +++ /dev/null @@ -1,46 +0,0 @@ -/** - * @fileoverview Module for loading rules from files and directories. - * @author Michael Ficarra - */ - -"use strict"; - -//------------------------------------------------------------------------------ -// Requirements -//------------------------------------------------------------------------------ - -const fs = require("node:fs"), - path = require("node:path"); - -const rulesDirCache = {}; - -//------------------------------------------------------------------------------ -// Public Interface -//------------------------------------------------------------------------------ - -/** - * Load all rule modules from specified directory. - * @param {string} relativeRulesDir Path to rules directory, may be relative. - * @param {string} cwd Current working directory - * @returns {Object} Loaded rule modules. - */ -module.exports = function(relativeRulesDir, cwd) { - const rulesDir = path.resolve(cwd, relativeRulesDir); - - // cache will help performance as IO operation are expensive - if (rulesDirCache[rulesDir]) { - return rulesDirCache[rulesDir]; - } - - const rules = Object.create(null); - - fs.readdirSync(rulesDir).forEach(file => { - if (path.extname(file) !== ".js") { - return; - } - rules[file.slice(0, -3)] = require(path.join(rulesDir, file)); - }); - rulesDirCache[rulesDir] = rules; - - return rules; -}; diff --git a/tools/eslint/node_modules/eslint/lib/cli.js b/tools/eslint/node_modules/eslint/lib/cli.js deleted file mode 100644 index 6ee9e537982c97..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/cli.js +++ /dev/null @@ -1,571 +0,0 @@ -/** - * @fileoverview Main CLI object. - * @author Nicholas C. Zakas - */ - -"use strict"; - -/* - * NOTE: The CLI object should *not* call process.exit() directly. It should only return - * exit codes. This allows other programs to use the CLI object and still control - * when the program exits. - */ - -//------------------------------------------------------------------------------ -// Requirements -//------------------------------------------------------------------------------ - -const fs = require("node:fs"), - path = require("node:path"), - { promisify } = require("node:util"), - { LegacyESLint } = require("./eslint"), - { ESLint, shouldUseFlatConfig, locateConfigFileToUse } = require("./eslint/eslint"), - createCLIOptions = require("./options"), - log = require("./shared/logging"), - RuntimeInfo = require("./shared/runtime-info"), - { normalizeSeverityToString } = require("./shared/severity"); -const { Legacy: { naming } } = require("@eslint/eslintrc"); -const { ModuleImporter } = require("@humanwhocodes/module-importer"); -const { inactiveFlags, activeFlags } = require("./shared/flags"); -const debug = require("debug")("eslint:cli"); - -//------------------------------------------------------------------------------ -// Types -//------------------------------------------------------------------------------ - -/** @typedef {import("./eslint/eslint").ESLintOptions} ESLintOptions */ -/** @typedef {import("./eslint/eslint").LintMessage} LintMessage */ -/** @typedef {import("./eslint/eslint").LintResult} LintResult */ -/** @typedef {import("./options").ParsedCLIOptions} ParsedCLIOptions */ -/** @typedef {import("./shared/types").Plugin} Plugin */ -/** @typedef {import("./shared/types").ResultsMeta} ResultsMeta */ - -//------------------------------------------------------------------------------ -// Helpers -//------------------------------------------------------------------------------ - -const mkdir = promisify(fs.mkdir); -const stat = promisify(fs.stat); -const writeFile = promisify(fs.writeFile); - -/** - * Loads plugins with the specified names. - * @param {{ "import": (name: string) => Promise }} importer An object with an `import` method called once for each plugin. - * @param {string[]} pluginNames The names of the plugins to be loaded, with or without the "eslint-plugin-" prefix. - * @returns {Promise>} A mapping of plugin short names to implementations. - */ -async function loadPlugins(importer, pluginNames) { - const plugins = {}; - - await Promise.all(pluginNames.map(async pluginName => { - - const longName = naming.normalizePackageName(pluginName, "eslint-plugin"); - const module = await importer.import(longName); - - if (!("default" in module)) { - throw new Error(`"${longName}" cannot be used with the \`--plugin\` option because its default module does not provide a \`default\` export`); - } - - const shortName = naming.getShorthandName(pluginName, "eslint-plugin"); - - plugins[shortName] = module.default; - })); - - return plugins; -} - -/** - * Predicate function for whether or not to apply fixes in quiet mode. - * If a message is a warning, do not apply a fix. - * @param {LintMessage} message The lint result. - * @returns {boolean} True if the lint message is an error (and thus should be - * autofixed), false otherwise. - */ -function quietFixPredicate(message) { - return message.severity === 2; -} - -/** - * Predicate function for whether or not to run a rule in quiet mode. - * If a rule is set to warning, do not run it. - * @param {{ ruleId: string; severity: number; }} rule The rule id and severity. - * @returns {boolean} True if the lint rule should run, false otherwise. - */ -function quietRuleFilter(rule) { - return rule.severity === 2; -} - -/** - * Translates the CLI options into the options expected by the ESLint constructor. - * @param {ParsedCLIOptions} cliOptions The CLI options to translate. - * @param {"flat"|"eslintrc"} [configType="eslintrc"] The format of the - * config to generate. - * @returns {Promise} The options object for the ESLint constructor. - * @private - */ -async function translateOptions({ - cache, - cacheFile, - cacheLocation, - cacheStrategy, - config, - configLookup, - env, - errorOnUnmatchedPattern, - eslintrc, - ext, - fix, - fixDryRun, - fixType, - flag, - global, - ignore, - ignorePath, - ignorePattern, - inlineConfig, - parser, - parserOptions, - plugin, - quiet, - reportUnusedDisableDirectives, - reportUnusedDisableDirectivesSeverity, - resolvePluginsRelativeTo, - rule, - rulesdir, - stats, - warnIgnored, - passOnNoPatterns, - maxWarnings -}, configType) { - - let overrideConfig, overrideConfigFile; - const importer = new ModuleImporter(); - - if (configType === "flat") { - overrideConfigFile = (typeof config === "string") ? config : !configLookup; - if (overrideConfigFile === false) { - overrideConfigFile = void 0; - } - - let globals = {}; - - if (global) { - globals = global.reduce((obj, name) => { - if (name.endsWith(":true")) { - obj[name.slice(0, -5)] = "writable"; - } else { - obj[name] = "readonly"; - } - return obj; - }, globals); - } - - overrideConfig = [{ - languageOptions: { - globals, - parserOptions: parserOptions || {} - }, - rules: rule ? rule : {} - }]; - - if (reportUnusedDisableDirectives || reportUnusedDisableDirectivesSeverity !== void 0) { - overrideConfig[0].linterOptions = { - reportUnusedDisableDirectives: reportUnusedDisableDirectives - ? "error" - : normalizeSeverityToString(reportUnusedDisableDirectivesSeverity) - }; - } - - if (parser) { - overrideConfig[0].languageOptions.parser = await importer.import(parser); - } - - if (plugin) { - overrideConfig[0].plugins = await loadPlugins(importer, plugin); - } - - } else { - overrideConfigFile = config; - - overrideConfig = { - env: env && env.reduce((obj, name) => { - obj[name] = true; - return obj; - }, {}), - globals: global && global.reduce((obj, name) => { - if (name.endsWith(":true")) { - obj[name.slice(0, -5)] = "writable"; - } else { - obj[name] = "readonly"; - } - return obj; - }, {}), - ignorePatterns: ignorePattern, - parser, - parserOptions, - plugins: plugin, - rules: rule - }; - } - - const options = { - allowInlineConfig: inlineConfig, - cache, - cacheLocation: cacheLocation || cacheFile, - cacheStrategy, - errorOnUnmatchedPattern, - fix: (fix || fixDryRun) && (quiet ? quietFixPredicate : true), - fixTypes: fixType, - ignore, - overrideConfig, - overrideConfigFile, - passOnNoPatterns - }; - - if (configType === "flat") { - options.ignorePatterns = ignorePattern; - options.stats = stats; - options.warnIgnored = warnIgnored; - options.flags = flag; - - /* - * For performance reasons rules not marked as 'error' are filtered out in quiet mode. As maxWarnings - * requires rules set to 'warn' to be run, we only filter out 'warn' rules if maxWarnings is not specified. - */ - options.ruleFilter = quiet && maxWarnings === -1 ? quietRuleFilter : () => true; - } else { - options.resolvePluginsRelativeTo = resolvePluginsRelativeTo; - options.rulePaths = rulesdir; - options.useEslintrc = eslintrc; - options.extensions = ext; - options.ignorePath = ignorePath; - if (reportUnusedDisableDirectives || reportUnusedDisableDirectivesSeverity !== void 0) { - options.reportUnusedDisableDirectives = reportUnusedDisableDirectives - ? "error" - : normalizeSeverityToString(reportUnusedDisableDirectivesSeverity); - } - } - - return options; -} - -/** - * Count error messages. - * @param {LintResult[]} results The lint results. - * @returns {{errorCount:number;fatalErrorCount:number,warningCount:number}} The number of error messages. - */ -function countErrors(results) { - let errorCount = 0; - let fatalErrorCount = 0; - let warningCount = 0; - - for (const result of results) { - errorCount += result.errorCount; - fatalErrorCount += result.fatalErrorCount; - warningCount += result.warningCount; - } - - return { errorCount, fatalErrorCount, warningCount }; -} - -/** - * Check if a given file path is a directory or not. - * @param {string} filePath The path to a file to check. - * @returns {Promise} `true` if the given path is a directory. - */ -async function isDirectory(filePath) { - try { - return (await stat(filePath)).isDirectory(); - } catch (error) { - if (error.code === "ENOENT" || error.code === "ENOTDIR") { - return false; - } - throw error; - } -} - -/** - * Outputs the results of the linting. - * @param {ESLint} engine The ESLint instance to use. - * @param {LintResult[]} results The results to print. - * @param {string} format The name of the formatter to use or the path to the formatter. - * @param {string} outputFile The path for the output file. - * @param {ResultsMeta} resultsMeta Warning count and max threshold. - * @returns {Promise} True if the printing succeeds, false if not. - * @private - */ -async function printResults(engine, results, format, outputFile, resultsMeta) { - let formatter; - - try { - formatter = await engine.loadFormatter(format); - } catch (e) { - log.error(e.message); - return false; - } - - const output = await formatter.format(results, resultsMeta); - - if (outputFile) { - const filePath = path.resolve(process.cwd(), outputFile); - - if (await isDirectory(filePath)) { - log.error("Cannot write to output file path, it is a directory: %s", outputFile); - return false; - } - - try { - await mkdir(path.dirname(filePath), { recursive: true }); - await writeFile(filePath, output); - } catch (ex) { - log.error("There was a problem writing the output file:\n%s", ex); - return false; - } - } else if (output) { - log.info(output); - } - - return true; -} - -//------------------------------------------------------------------------------ -// Public Interface -//------------------------------------------------------------------------------ - -/** - * Encapsulates all CLI behavior for eslint. Makes it easier to test as well as - * for other Node.js programs to effectively run the CLI. - */ -const cli = { - - /** - * Calculates the command string for the --inspect-config operation. - * @param {string} configFile The path to the config file to inspect. - * @returns {Promise} The command string to execute. - */ - async calculateInspectConfigFlags(configFile) { - - // find the config file - const { - configFilePath, - basePath, - error - } = await locateConfigFileToUse({ cwd: process.cwd(), configFile }); - - if (error) { - throw error; - } - - return ["--config", configFilePath, "--basePath", basePath]; - }, - - /** - * Executes the CLI based on an array of arguments that is passed in. - * @param {string|Array|Object} args The arguments to process. - * @param {string} [text] The text to lint (used for TTY). - * @param {boolean} [allowFlatConfig=true] Whether or not to allow flat config. - * @returns {Promise} The exit code for the operation. - */ - async execute(args, text, allowFlatConfig = true) { - if (Array.isArray(args)) { - debug("CLI args: %o", args.slice(2)); - } - - /* - * Before doing anything, we need to see if we are using a - * flat config file. If so, then we need to change the way command - * line args are parsed. This is temporary, and when we fully - * switch to flat config we can remove this logic. - */ - - const usingFlatConfig = allowFlatConfig && await shouldUseFlatConfig(); - - debug("Using flat config?", usingFlatConfig); - - if (allowFlatConfig && !usingFlatConfig) { - process.emitWarning("You are using an eslintrc configuration file, which is deprecated and support will be removed in v10.0.0. Please migrate to an eslint.config.js file. See https://eslint.org/docs/latest/use/configure/migration-guide for details.", "ESLintRCWarning"); - } - - const CLIOptions = createCLIOptions(usingFlatConfig); - - /** @type {ParsedCLIOptions} */ - let options; - - try { - options = CLIOptions.parse(args); - } catch (error) { - debug("Error parsing CLI options:", error.message); - - let errorMessage = error.message; - - if (usingFlatConfig) { - errorMessage += "\nYou're using eslint.config.js, some command line flags are no longer available. Please see https://eslint.org/docs/latest/use/command-line-interface for details."; - } - - log.error(errorMessage); - return 2; - } - - const files = options._; - const useStdin = typeof text === "string"; - - if (options.help) { - log.info(CLIOptions.generateHelp()); - return 0; - } - if (options.version) { - log.info(RuntimeInfo.version()); - return 0; - } - if (options.envInfo) { - try { - log.info(RuntimeInfo.environment()); - return 0; - } catch (err) { - debug("Error retrieving environment info"); - log.error(err.message); - return 2; - } - } - - if (options.printConfig) { - if (files.length) { - log.error("The --print-config option must be used with exactly one file name."); - return 2; - } - if (useStdin) { - log.error("The --print-config option is not available for piped-in code."); - return 2; - } - - const engine = usingFlatConfig - ? new ESLint(await translateOptions(options, "flat")) - : new LegacyESLint(await translateOptions(options)); - const fileConfig = - await engine.calculateConfigForFile(options.printConfig); - - log.info(JSON.stringify(fileConfig, null, " ")); - return 0; - } - - if (options.inspectConfig) { - - log.info("You can also run this command directly using 'npx @eslint/config-inspector@latest' in the same directory as your configuration file."); - - try { - const flatOptions = await translateOptions(options, "flat"); - const spawn = require("cross-spawn"); - const flags = await cli.calculateInspectConfigFlags(flatOptions.overrideConfigFile); - - spawn.sync("npx", ["@eslint/config-inspector@latest", ...flags], { encoding: "utf8", stdio: "inherit" }); - } catch (error) { - log.error(error); - return 2; - } - - return 0; - } - - debug(`Running on ${useStdin ? "text" : "files"}`); - - if (options.fix && options.fixDryRun) { - log.error("The --fix option and the --fix-dry-run option cannot be used together."); - return 2; - } - if (useStdin && options.fix) { - log.error("The --fix option is not available for piped-in code; use --fix-dry-run instead."); - return 2; - } - if (options.fixType && !options.fix && !options.fixDryRun) { - log.error("The --fix-type option requires either --fix or --fix-dry-run."); - return 2; - } - - if (options.reportUnusedDisableDirectives && options.reportUnusedDisableDirectivesSeverity !== void 0) { - log.error("The --report-unused-disable-directives option and the --report-unused-disable-directives-severity option cannot be used together."); - return 2; - } - - const ActiveESLint = usingFlatConfig ? ESLint : LegacyESLint; - const eslintOptions = await translateOptions(options, usingFlatConfig ? "flat" : "eslintrc"); - - if (eslintOptions.flags) { - debug("Checking for inactive flags"); - - for (const flag of eslintOptions.flags) { - if (inactiveFlags.has(flag)) { - log.warn(`InactiveFlag: The '${flag}' flag is no longer active: ${inactiveFlags.get(flag)}`); - continue; - } - - if (activeFlags.has(flag)) { - continue; - } - - log.error(`InvalidFlag: The '${flag}' flag is invalid.`); - return 2; - } - } - - const engine = new ActiveESLint(eslintOptions); - let results; - - if (useStdin) { - results = await engine.lintText(text, { - filePath: options.stdinFilename, - - // flatConfig respects CLI flag and constructor warnIgnored, eslintrc forces true for backwards compatibility - warnIgnored: usingFlatConfig ? void 0 : true - }); - } else { - results = await engine.lintFiles(files); - } - - if (options.fix) { - debug("Fix mode enabled - applying fixes"); - await ActiveESLint.outputFixes(results); - } - - let resultsToPrint = results; - - if (options.quiet) { - debug("Quiet mode enabled - filtering out warnings"); - resultsToPrint = ActiveESLint.getErrorResults(resultsToPrint); - } - - const resultCounts = countErrors(results); - const tooManyWarnings = options.maxWarnings >= 0 && resultCounts.warningCount > options.maxWarnings; - const resultsMeta = tooManyWarnings - ? { - maxWarningsExceeded: { - maxWarnings: options.maxWarnings, - foundWarnings: resultCounts.warningCount - } - } - : {}; - - if (await printResults(engine, resultsToPrint, options.format, options.outputFile, resultsMeta)) { - - // Errors and warnings from the original unfiltered results should determine the exit code - const shouldExitForFatalErrors = - options.exitOnFatalError && resultCounts.fatalErrorCount > 0; - - if (!resultCounts.errorCount && tooManyWarnings) { - log.error( - "ESLint found too many warnings (maximum: %s).", - options.maxWarnings - ); - } - - if (shouldExitForFatalErrors) { - return 2; - } - - return (resultCounts.errorCount || tooManyWarnings) ? 1 : 0; - } - - return 2; - } -}; - -module.exports = cli; diff --git a/tools/eslint/node_modules/eslint/lib/config/default-config.js b/tools/eslint/node_modules/eslint/lib/config/default-config.js deleted file mode 100644 index fa60fc64304552..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/config/default-config.js +++ /dev/null @@ -1,75 +0,0 @@ -/** - * @fileoverview Default configuration - * @author Nicholas C. Zakas - */ - -"use strict"; - -//----------------------------------------------------------------------------- -// Requirements -//----------------------------------------------------------------------------- - -const Rules = require("../rules"); - -//----------------------------------------------------------------------------- -// Helpers -//----------------------------------------------------------------------------- - -exports.defaultConfig = [ - { - plugins: { - "@": { - - languages: { - js: require("../languages/js") - }, - - /* - * Because we try to delay loading rules until absolutely - * necessary, a proxy allows us to hook into the lazy-loading - * aspect of the rules map while still keeping all of the - * relevant configuration inside of the config array. - */ - rules: new Proxy({}, { - get(target, property) { - return Rules.get(property); - }, - - has(target, property) { - return Rules.has(property); - } - }) - } - }, - language: "@/js", - languageOptions: { - sourceType: "module", - ecmaVersion: "latest", - parser: require("espree"), - parserOptions: {} - }, - linterOptions: { - reportUnusedDisableDirectives: 1 - } - }, - - // default ignores are listed here - { - ignores: [ - "**/node_modules/", - ".git/" - ] - }, - - // intentionally empty config to ensure these files are globbed by default - { - files: ["**/*.js", "**/*.mjs"] - }, - { - files: ["**/*.cjs"], - languageOptions: { - sourceType: "commonjs", - ecmaVersion: "latest" - } - } -]; diff --git a/tools/eslint/node_modules/eslint/lib/config/flat-config-array.js b/tools/eslint/node_modules/eslint/lib/config/flat-config-array.js deleted file mode 100644 index 0c3b3cf9a7a0ff..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/config/flat-config-array.js +++ /dev/null @@ -1,423 +0,0 @@ -/** - * @fileoverview Flat Config Array - * @author Nicholas C. Zakas - */ - -"use strict"; - -//----------------------------------------------------------------------------- -// Requirements -//----------------------------------------------------------------------------- - -const { ConfigArray, ConfigArraySymbol } = require("@eslint/config-array"); -const { flatConfigSchema, hasMethod } = require("./flat-config-schema"); -const { RuleValidator } = require("./rule-validator"); -const { defaultConfig } = require("./default-config"); - -//----------------------------------------------------------------------------- -// Helpers -//----------------------------------------------------------------------------- - -/** - * Fields that are considered metadata and not part of the config object. - */ -const META_FIELDS = new Set(["name"]); - -const ruleValidator = new RuleValidator(); - -/** - * Splits a plugin identifier in the form a/b/c into two parts: a/b and c. - * @param {string} identifier The identifier to parse. - * @returns {{objectName: string, pluginName: string}} The parts of the plugin - * name. - */ -function splitPluginIdentifier(identifier) { - const parts = identifier.split("/"); - - return { - objectName: parts.pop(), - pluginName: parts.join("/") - }; -} - -/** - * Returns the name of an object in the config by reading its `meta` key. - * @param {Object} object The object to check. - * @returns {string?} The name of the object if found or `null` if there - * is no name. - */ -function getObjectId(object) { - - // first check old-style name - let name = object.name; - - if (!name) { - - if (!object.meta) { - return null; - } - - name = object.meta.name; - - if (!name) { - return null; - } - } - - // now check for old-style version - let version = object.version; - - if (!version) { - version = object.meta && object.meta.version; - } - - // if there's a version then append that - if (version) { - return `${name}@${version}`; - } - - return name; -} - -/** - * Wraps a config error with details about where the error occurred. - * @param {Error} error The original error. - * @param {number} originalLength The original length of the config array. - * @param {number} baseLength The length of the base config. - * @returns {TypeError} The new error with details. - */ -function wrapConfigErrorWithDetails(error, originalLength, baseLength) { - - let location = "user-defined"; - let configIndex = error.index; - - /* - * A config array is set up in this order: - * 1. Base config - * 2. Original configs - * 3. User-defined configs - * 4. CLI-defined configs - * - * So we need to adjust the index to account for the base config. - * - * - If the index is less than the base length, it's in the base config - * (as specified by `baseConfig` argument to `FlatConfigArray` constructor). - * - If the index is greater than the base length but less than the original - * length + base length, it's in the original config. The original config - * is passed to the `FlatConfigArray` constructor as the first argument. - * - Otherwise, it's in the user-defined config, which is loaded from the - * config file and merged with any command-line options. - */ - if (error.index < baseLength) { - location = "base"; - } else if (error.index < originalLength + baseLength) { - location = "original"; - configIndex = error.index - baseLength; - } else { - configIndex = error.index - originalLength - baseLength; - } - - return new TypeError( - `${error.message.slice(0, -1)} at ${location} index ${configIndex}.`, - { cause: error } - ); -} - -/** - * Converts a languageOptions object to a JSON representation. - * @param {Record} languageOptions The options to create a JSON - * representation of. - * @param {string} objectKey The key of the object being converted. - * @returns {Record} The JSON representation of the languageOptions. - * @throws {TypeError} If a function is found in the languageOptions. - */ -function languageOptionsToJSON(languageOptions, objectKey = "languageOptions") { - - const result = {}; - - for (const [key, value] of Object.entries(languageOptions)) { - if (value) { - if (typeof value === "object") { - const name = getObjectId(value); - - if (name && hasMethod(value)) { - result[key] = name; - } else { - result[key] = languageOptionsToJSON(value, key); - } - continue; - } - - if (typeof value === "function") { - throw new TypeError(`Cannot serialize key "${key}" in ${objectKey}: Function values are not supported.`); - } - - } - - result[key] = value; - } - - return result; -} - -const originalBaseConfig = Symbol("originalBaseConfig"); -const originalLength = Symbol("originalLength"); -const baseLength = Symbol("baseLength"); - -//----------------------------------------------------------------------------- -// Exports -//----------------------------------------------------------------------------- - -/** - * Represents an array containing configuration information for ESLint. - */ -class FlatConfigArray extends ConfigArray { - - /** - * Creates a new instance. - * @param {*[]} configs An array of configuration information. - * @param {{basePath: string, shouldIgnore: boolean, baseConfig: FlatConfig}} options The options - * to use for the config array instance. - */ - constructor(configs, { - basePath, - shouldIgnore = true, - baseConfig = defaultConfig - } = {}) { - super(configs, { - basePath, - schema: flatConfigSchema - }); - - /** - * The original length of the array before any modifications. - * @type {number} - */ - this[originalLength] = this.length; - - if (baseConfig[Symbol.iterator]) { - this.unshift(...baseConfig); - } else { - this.unshift(baseConfig); - } - - /** - * The length of the array after applying the base config. - * @type {number} - */ - this[baseLength] = this.length - this[originalLength]; - - /** - * The base config used to build the config array. - * @type {Array} - */ - this[originalBaseConfig] = baseConfig; - Object.defineProperty(this, originalBaseConfig, { writable: false }); - - /** - * Determines if `ignores` fields should be honored. - * If true, then all `ignores` fields are honored. - * if false, then only `ignores` fields in the baseConfig are honored. - * @type {boolean} - */ - this.shouldIgnore = shouldIgnore; - Object.defineProperty(this, "shouldIgnore", { writable: false }); - } - - /** - * Normalizes the array by calling the superclass method and catching/rethrowing - * any ConfigError exceptions with additional details. - * @param {any} [context] The context to use to normalize the array. - * @returns {Promise} A promise that resolves when the array is normalized. - */ - normalize(context) { - return super.normalize(context) - .catch(error => { - if (error.name === "ConfigError") { - throw wrapConfigErrorWithDetails(error, this[originalLength], this[baseLength]); - } - - throw error; - - }); - } - - /** - * Normalizes the array by calling the superclass method and catching/rethrowing - * any ConfigError exceptions with additional details. - * @param {any} [context] The context to use to normalize the array. - * @returns {FlatConfigArray} The current instance. - * @throws {TypeError} If the config is invalid. - */ - normalizeSync(context) { - - try { - - return super.normalizeSync(context); - - } catch (error) { - - if (error.name === "ConfigError") { - throw wrapConfigErrorWithDetails(error, this[originalLength], this[baseLength]); - } - - throw error; - - } - - } - - /* eslint-disable class-methods-use-this -- Desired as instance method */ - /** - * Replaces a config with another config to allow us to put strings - * in the config array that will be replaced by objects before - * normalization. - * @param {Object} config The config to preprocess. - * @returns {Object} The preprocessed config. - */ - [ConfigArraySymbol.preprocessConfig](config) { - - /* - * If a config object has `ignores` and no other non-meta fields, then it's an object - * for global ignores. If `shouldIgnore` is false, that object shouldn't apply, - * so we'll remove its `ignores`. - */ - if ( - !this.shouldIgnore && - !this[originalBaseConfig].includes(config) && - config.ignores && - Object.keys(config).filter(key => !META_FIELDS.has(key)).length === 1 - ) { - /* eslint-disable-next-line no-unused-vars -- need to strip off other keys */ - const { ignores, ...otherKeys } = config; - - return otherKeys; - } - - return config; - } - - /** - * Finalizes the config by replacing plugin references with their objects - * and validating rule option schemas. - * @param {Object} config The config to finalize. - * @returns {Object} The finalized config. - * @throws {TypeError} If the config is invalid. - */ - [ConfigArraySymbol.finalizeConfig](config) { - - const { plugins, language, languageOptions, processor } = config; - let parserName, processorName, languageName; - let invalidParser = false, - invalidProcessor = false, - invalidLanguage = false; - - // Check parser value - if (languageOptions && languageOptions.parser) { - const { parser } = languageOptions; - - if (typeof parser === "object") { - parserName = getObjectId(parser); - - if (!parserName) { - invalidParser = true; - } - - } else { - invalidParser = true; - } - } - - // Check language value - if (language) { - if (typeof language === "string") { - const { pluginName, objectName: localLanguageName } = splitPluginIdentifier(language); - - languageName = language; - - if (!plugins || !plugins[pluginName] || !plugins[pluginName].languages || !plugins[pluginName].languages[localLanguageName]) { - throw new TypeError(`Key "language": Could not find "${localLanguageName}" in plugin "${pluginName}".`); - } - - config.language = plugins[pluginName].languages[localLanguageName]; - } else { - invalidLanguage = true; - } - - try { - config.language.validateLanguageOptions(config.languageOptions); - } catch (error) { - throw new TypeError(`Key "languageOptions": ${error.message}`, { cause: error }); - } - } - - // Check processor value - if (processor) { - if (typeof processor === "string") { - const { pluginName, objectName: localProcessorName } = splitPluginIdentifier(processor); - - processorName = processor; - - if (!plugins || !plugins[pluginName] || !plugins[pluginName].processors || !plugins[pluginName].processors[localProcessorName]) { - throw new TypeError(`Key "processor": Could not find "${localProcessorName}" in plugin "${pluginName}".`); - } - - config.processor = plugins[pluginName].processors[localProcessorName]; - } else if (typeof processor === "object") { - processorName = getObjectId(processor); - - if (!processorName) { - invalidProcessor = true; - } - - } else { - invalidProcessor = true; - } - } - - ruleValidator.validate(config); - - // apply special logic for serialization into JSON - /* eslint-disable object-shorthand -- shorthand would change "this" value */ - Object.defineProperty(config, "toJSON", { - value: function() { - - if (invalidParser) { - throw new Error("Could not serialize parser object (missing 'meta' object)."); - } - - if (invalidProcessor) { - throw new Error("Could not serialize processor object (missing 'meta' object)."); - } - - if (invalidLanguage) { - throw new Error("Caching is not supported when language is an object."); - } - - return { - ...this, - plugins: Object.entries(plugins).map(([namespace, plugin]) => { - - const pluginId = getObjectId(plugin); - - if (!pluginId) { - return namespace; - } - - return `${namespace}:${pluginId}`; - }), - language: languageName, - languageOptions: languageOptionsToJSON(languageOptions), - processor: processorName - }; - } - }); - /* eslint-enable object-shorthand -- ok to enable now */ - - return config; - } - /* eslint-enable class-methods-use-this -- Desired as instance method */ - -} - -exports.FlatConfigArray = FlatConfigArray; diff --git a/tools/eslint/node_modules/eslint/lib/config/flat-config-helpers.js b/tools/eslint/node_modules/eslint/lib/config/flat-config-helpers.js deleted file mode 100644 index 0280255932c1ce..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/config/flat-config-helpers.js +++ /dev/null @@ -1,132 +0,0 @@ -/** - * @fileoverview Shared functions to work with configs. - * @author Nicholas C. Zakas - */ - -"use strict"; - -//------------------------------------------------------------------------------ -// Typedefs -//------------------------------------------------------------------------------ - -/** @typedef {import("../shared/types").Rule} Rule */ - -//------------------------------------------------------------------------------ -// Private Members -//------------------------------------------------------------------------------ - -// JSON schema that disallows passing any options -const noOptionsSchema = Object.freeze({ - type: "array", - minItems: 0, - maxItems: 0 -}); - -//----------------------------------------------------------------------------- -// Functions -//----------------------------------------------------------------------------- - -/** - * Parses a ruleId into its plugin and rule parts. - * @param {string} ruleId The rule ID to parse. - * @returns {{pluginName:string,ruleName:string}} The plugin and rule - * parts of the ruleId; - */ -function parseRuleId(ruleId) { - let pluginName, ruleName; - - // distinguish between core rules and plugin rules - if (ruleId.includes("/")) { - - // mimic scoped npm packages - if (ruleId.startsWith("@")) { - pluginName = ruleId.slice(0, ruleId.lastIndexOf("/")); - } else { - pluginName = ruleId.slice(0, ruleId.indexOf("/")); - } - - ruleName = ruleId.slice(pluginName.length + 1); - } else { - pluginName = "@"; - ruleName = ruleId; - } - - return { - pluginName, - ruleName - }; -} - -/** - * Retrieves a rule instance from a given config based on the ruleId. - * @param {string} ruleId The rule ID to look for. - * @param {FlatConfig} config The config to search. - * @returns {import("../shared/types").Rule|undefined} The rule if found - * or undefined if not. - */ -function getRuleFromConfig(ruleId, config) { - - const { pluginName, ruleName } = parseRuleId(ruleId); - - const plugin = config.plugins && config.plugins[pluginName]; - const rule = plugin && plugin.rules && plugin.rules[ruleName]; - - return rule; -} - -/** - * Gets a complete options schema for a rule. - * @param {Rule} rule A rule object - * @throws {TypeError} If `meta.schema` is specified but is not an array, object or `false`. - * @returns {Object|null} JSON Schema for the rule's options. `null` if `meta.schema` is `false`. - */ -function getRuleOptionsSchema(rule) { - - if (!rule.meta) { - return { ...noOptionsSchema }; // default if `meta.schema` is not specified - } - - const schema = rule.meta.schema; - - if (typeof schema === "undefined") { - return { ...noOptionsSchema }; // default if `meta.schema` is not specified - } - - // `schema:false` is an allowed explicit opt-out of options validation for the rule - if (schema === false) { - return null; - } - - if (typeof schema !== "object" || schema === null) { - throw new TypeError("Rule's `meta.schema` must be an array or object"); - } - - // ESLint-specific array form needs to be converted into a valid JSON Schema definition - if (Array.isArray(schema)) { - if (schema.length) { - return { - type: "array", - items: schema, - minItems: 0, - maxItems: schema.length - }; - } - - // `schema:[]` is an explicit way to specify that the rule does not accept any options - return { ...noOptionsSchema }; - } - - // `schema:` is assumed to be a valid JSON Schema definition - return schema; -} - - -//----------------------------------------------------------------------------- -// Exports -//----------------------------------------------------------------------------- - -module.exports = { - parseRuleId, - getRuleFromConfig, - getRuleOptionsSchema -}; diff --git a/tools/eslint/node_modules/eslint/lib/config/flat-config-schema.js b/tools/eslint/node_modules/eslint/lib/config/flat-config-schema.js deleted file mode 100644 index bffbae79406b4e..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/config/flat-config-schema.js +++ /dev/null @@ -1,576 +0,0 @@ -/** - * @fileoverview Flat config schema - * @author Nicholas C. Zakas - */ - -"use strict"; - -//----------------------------------------------------------------------------- -// Requirements -//----------------------------------------------------------------------------- - -const { normalizeSeverityToNumber } = require("../shared/severity"); - -//----------------------------------------------------------------------------- -// Type Definitions -//----------------------------------------------------------------------------- - -/** - * @typedef ObjectPropertySchema - * @property {Function|string} merge The function or name of the function to call - * to merge multiple objects with this property. - * @property {Function|string} validate The function or name of the function to call - * to validate the value of this property. - */ - -//----------------------------------------------------------------------------- -// Helpers -//----------------------------------------------------------------------------- - -const ruleSeverities = new Map([ - [0, 0], ["off", 0], - [1, 1], ["warn", 1], - [2, 2], ["error", 2] -]); - -/** - * Check if a value is a non-null object. - * @param {any} value The value to check. - * @returns {boolean} `true` if the value is a non-null object. - */ -function isNonNullObject(value) { - return typeof value === "object" && value !== null; -} - -/** - * Check if a value is a non-null non-array object. - * @param {any} value The value to check. - * @returns {boolean} `true` if the value is a non-null non-array object. - */ -function isNonArrayObject(value) { - return isNonNullObject(value) && !Array.isArray(value); -} - -/** - * Check if a value is undefined. - * @param {any} value The value to check. - * @returns {boolean} `true` if the value is undefined. - */ -function isUndefined(value) { - return typeof value === "undefined"; -} - -/** - * Deeply merges two non-array objects. - * @param {Object} first The base object. - * @param {Object} second The overrides object. - * @param {Map>} [mergeMap] Maps the combination of first and second arguments to a merged result. - * @returns {Object} An object with properties from both first and second. - */ -function deepMerge(first, second, mergeMap = new Map()) { - - let secondMergeMap = mergeMap.get(first); - - if (secondMergeMap) { - const result = secondMergeMap.get(second); - - if (result) { - - // If this combination of first and second arguments has been already visited, return the previously created result. - return result; - } - } else { - secondMergeMap = new Map(); - mergeMap.set(first, secondMergeMap); - } - - /* - * First create a result object where properties from the second object - * overwrite properties from the first. This sets up a baseline to use - * later rather than needing to inspect and change every property - * individually. - */ - const result = { - ...first, - ...second - }; - - delete result.__proto__; // eslint-disable-line no-proto -- don't merge own property "__proto__" - - // Store the pending result for this combination of first and second arguments. - secondMergeMap.set(second, result); - - for (const key of Object.keys(second)) { - - // avoid hairy edge case - if (key === "__proto__" || !Object.prototype.propertyIsEnumerable.call(first, key)) { - continue; - } - - const firstValue = first[key]; - const secondValue = second[key]; - - if (isNonArrayObject(firstValue) && isNonArrayObject(secondValue)) { - result[key] = deepMerge(firstValue, secondValue, mergeMap); - } else if (isUndefined(secondValue)) { - result[key] = firstValue; - } - } - - return result; - -} - -/** - * Normalizes the rule options config for a given rule by ensuring that - * it is an array and that the first item is 0, 1, or 2. - * @param {Array|string|number} ruleOptions The rule options config. - * @returns {Array} An array of rule options. - */ -function normalizeRuleOptions(ruleOptions) { - - const finalOptions = Array.isArray(ruleOptions) - ? ruleOptions.slice(0) - : [ruleOptions]; - - finalOptions[0] = ruleSeverities.get(finalOptions[0]); - return structuredClone(finalOptions); -} - -/** - * Determines if an object has any methods. - * @param {Object} object The object to check. - * @returns {boolean} `true` if the object has any methods. - */ -function hasMethod(object) { - - for (const key of Object.keys(object)) { - - if (typeof object[key] === "function") { - return true; - } - } - - return false; -} - -//----------------------------------------------------------------------------- -// Assertions -//----------------------------------------------------------------------------- - -/** - * The error type when a rule's options are configured with an invalid type. - */ -class InvalidRuleOptionsError extends Error { - - /** - * @param {string} ruleId Rule name being configured. - * @param {any} value The invalid value. - */ - constructor(ruleId, value) { - super(`Key "${ruleId}": Expected severity of "off", 0, "warn", 1, "error", or 2.`); - this.messageTemplate = "invalid-rule-options"; - this.messageData = { ruleId, value }; - } -} - -/** - * Validates that a value is a valid rule options entry. - * @param {string} ruleId Rule name being configured. - * @param {any} value The value to check. - * @returns {void} - * @throws {InvalidRuleOptionsError} If the value isn't a valid rule options. - */ -function assertIsRuleOptions(ruleId, value) { - if (typeof value !== "string" && typeof value !== "number" && !Array.isArray(value)) { - throw new InvalidRuleOptionsError(ruleId, value); - } -} - -/** - * The error type when a rule's severity is invalid. - */ -class InvalidRuleSeverityError extends Error { - - /** - * @param {string} ruleId Rule name being configured. - * @param {any} value The invalid value. - */ - constructor(ruleId, value) { - super(`Key "${ruleId}": Expected severity of "off", 0, "warn", 1, "error", or 2.`); - this.messageTemplate = "invalid-rule-severity"; - this.messageData = { ruleId, value }; - } -} - -/** - * Validates that a value is valid rule severity. - * @param {string} ruleId Rule name being configured. - * @param {any} value The value to check. - * @returns {void} - * @throws {InvalidRuleSeverityError} If the value isn't a valid rule severity. - */ -function assertIsRuleSeverity(ruleId, value) { - const severity = ruleSeverities.get(value); - - if (typeof severity === "undefined") { - throw new InvalidRuleSeverityError(ruleId, value); - } -} - -/** - * Validates that a given string is the form pluginName/objectName. - * @param {string} value The string to check. - * @returns {void} - * @throws {TypeError} If the string isn't in the correct format. - */ -function assertIsPluginMemberName(value) { - if (!/[@a-z0-9-_$]+(?:\/(?:[a-z0-9-_$]+))+$/iu.test(value)) { - throw new TypeError(`Expected string in the form "pluginName/objectName" but found "${value}".`); - } -} - -/** - * Validates that a value is an object. - * @param {any} value The value to check. - * @returns {void} - * @throws {TypeError} If the value isn't an object. - */ -function assertIsObject(value) { - if (!isNonNullObject(value)) { - throw new TypeError("Expected an object."); - } -} - -/** - * The error type when there's an eslintrc-style options in a flat config. - */ -class IncompatibleKeyError extends Error { - - /** - * @param {string} key The invalid key. - */ - constructor(key) { - super("This appears to be in eslintrc format rather than flat config format."); - this.messageTemplate = "eslintrc-incompat"; - this.messageData = { key }; - } -} - -/** - * The error type when there's an eslintrc-style plugins array found. - */ -class IncompatiblePluginsError extends Error { - - /** - * Creates a new instance. - * @param {Array} plugins The plugins array. - */ - constructor(plugins) { - super("This appears to be in eslintrc format (array of strings) rather than flat config format (object)."); - this.messageTemplate = "eslintrc-plugins"; - this.messageData = { plugins }; - } -} - - -//----------------------------------------------------------------------------- -// Low-Level Schemas -//----------------------------------------------------------------------------- - -/** @type {ObjectPropertySchema} */ -const booleanSchema = { - merge: "replace", - validate: "boolean" -}; - -const ALLOWED_SEVERITIES = new Set(["error", "warn", "off", 2, 1, 0]); - -/** @type {ObjectPropertySchema} */ -const disableDirectiveSeveritySchema = { - merge(first, second) { - const value = second === void 0 ? first : second; - - if (typeof value === "boolean") { - return value ? "warn" : "off"; - } - - return normalizeSeverityToNumber(value); - }, - validate(value) { - if (!(ALLOWED_SEVERITIES.has(value) || typeof value === "boolean")) { - throw new TypeError("Expected one of: \"error\", \"warn\", \"off\", 0, 1, 2, or a boolean."); - } - } -}; - -/** @type {ObjectPropertySchema} */ -const deepObjectAssignSchema = { - merge(first = {}, second = {}) { - return deepMerge(first, second); - }, - validate: "object" -}; - - -//----------------------------------------------------------------------------- -// High-Level Schemas -//----------------------------------------------------------------------------- - -/** @type {ObjectPropertySchema} */ -const languageOptionsSchema = { - merge(first = {}, second = {}) { - - const result = deepMerge(first, second); - - for (const [key, value] of Object.entries(result)) { - - /* - * Special case: Because the `parser` property is an object, it should - * not be deep merged. Instead, it should be replaced if it exists in - * the second object. To make this more generic, we just check for - * objects with methods and replace them if they exist in the second - * object. - */ - if (isNonArrayObject(value)) { - if (hasMethod(value)) { - result[key] = second[key] ?? first[key]; - continue; - } - - // for other objects, make sure we aren't reusing the same object - result[key] = { ...result[key] }; - continue; - } - - } - - return result; - }, - validate: "object" -}; - -/** @type {ObjectPropertySchema} */ -const languageSchema = { - merge: "replace", - validate: assertIsPluginMemberName -}; - -/** @type {ObjectPropertySchema} */ -const pluginsSchema = { - merge(first = {}, second = {}) { - const keys = new Set([...Object.keys(first), ...Object.keys(second)]); - const result = {}; - - // manually validate that plugins are not redefined - for (const key of keys) { - - // avoid hairy edge case - if (key === "__proto__") { - continue; - } - - if (key in first && key in second && first[key] !== second[key]) { - throw new TypeError(`Cannot redefine plugin "${key}".`); - } - - result[key] = second[key] || first[key]; - } - - return result; - }, - validate(value) { - - // first check the value to be sure it's an object - if (value === null || typeof value !== "object") { - throw new TypeError("Expected an object."); - } - - // make sure it's not an array, which would mean eslintrc-style is used - if (Array.isArray(value)) { - throw new IncompatiblePluginsError(value); - } - - // second check the keys to make sure they are objects - for (const key of Object.keys(value)) { - - // avoid hairy edge case - if (key === "__proto__") { - continue; - } - - if (value[key] === null || typeof value[key] !== "object") { - throw new TypeError(`Key "${key}": Expected an object.`); - } - } - } -}; - -/** @type {ObjectPropertySchema} */ -const processorSchema = { - merge: "replace", - validate(value) { - if (typeof value === "string") { - assertIsPluginMemberName(value); - } else if (value && typeof value === "object") { - if (typeof value.preprocess !== "function" || typeof value.postprocess !== "function") { - throw new TypeError("Object must have a preprocess() and a postprocess() method."); - } - } else { - throw new TypeError("Expected an object or a string."); - } - } -}; - -/** @type {ObjectPropertySchema} */ -const rulesSchema = { - merge(first = {}, second = {}) { - - const result = { - ...first, - ...second - }; - - - for (const ruleId of Object.keys(result)) { - - try { - - // avoid hairy edge case - if (ruleId === "__proto__") { - - /* eslint-disable-next-line no-proto -- Though deprecated, may still be present */ - delete result.__proto__; - continue; - } - - result[ruleId] = normalizeRuleOptions(result[ruleId]); - - /* - * If either rule config is missing, then the correct - * config is already present and we just need to normalize - * the severity. - */ - if (!(ruleId in first) || !(ruleId in second)) { - continue; - } - - const firstRuleOptions = normalizeRuleOptions(first[ruleId]); - const secondRuleOptions = normalizeRuleOptions(second[ruleId]); - - /* - * If the second rule config only has a severity (length of 1), - * then use that severity and keep the rest of the options from - * the first rule config. - */ - if (secondRuleOptions.length === 1) { - result[ruleId] = [secondRuleOptions[0], ...firstRuleOptions.slice(1)]; - continue; - } - - /* - * In any other situation, then the second rule config takes - * precedence. That means the value at `result[ruleId]` is - * already correct and no further work is necessary. - */ - } catch (ex) { - throw new Error(`Key "${ruleId}": ${ex.message}`, { cause: ex }); - } - - } - - return result; - - - }, - - validate(value) { - assertIsObject(value); - - /* - * We are not checking the rule schema here because there is no - * guarantee that the rule definition is present at this point. Instead - * we wait and check the rule schema during the finalization step - * of calculating a config. - */ - for (const ruleId of Object.keys(value)) { - - // avoid hairy edge case - if (ruleId === "__proto__") { - continue; - } - - const ruleOptions = value[ruleId]; - - assertIsRuleOptions(ruleId, ruleOptions); - - if (Array.isArray(ruleOptions)) { - assertIsRuleSeverity(ruleId, ruleOptions[0]); - } else { - assertIsRuleSeverity(ruleId, ruleOptions); - } - } - } -}; - -/** - * Creates a schema that always throws an error. Useful for warning - * about eslintrc-style keys. - * @param {string} key The eslintrc key to create a schema for. - * @returns {ObjectPropertySchema} The schema. - */ -function createEslintrcErrorSchema(key) { - return { - merge: "replace", - validate() { - throw new IncompatibleKeyError(key); - } - }; -} - -const eslintrcKeys = [ - "env", - "extends", - "globals", - "ignorePatterns", - "noInlineConfig", - "overrides", - "parser", - "parserOptions", - "reportUnusedDisableDirectives", - "root" -]; - -//----------------------------------------------------------------------------- -// Full schema -//----------------------------------------------------------------------------- - -const flatConfigSchema = { - - // eslintrc-style keys that should always error - ...Object.fromEntries(eslintrcKeys.map(key => [key, createEslintrcErrorSchema(key)])), - - // flat config keys - settings: deepObjectAssignSchema, - linterOptions: { - schema: { - noInlineConfig: booleanSchema, - reportUnusedDisableDirectives: disableDirectiveSeveritySchema - } - }, - language: languageSchema, - languageOptions: languageOptionsSchema, - processor: processorSchema, - plugins: pluginsSchema, - rules: rulesSchema -}; - -//----------------------------------------------------------------------------- -// Exports -//----------------------------------------------------------------------------- - -module.exports = { - flatConfigSchema, - hasMethod, - assertIsRuleSeverity -}; diff --git a/tools/eslint/node_modules/eslint/lib/config/rule-validator.js b/tools/eslint/node_modules/eslint/lib/config/rule-validator.js deleted file mode 100644 index 3b4ea6122cbcaa..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/config/rule-validator.js +++ /dev/null @@ -1,194 +0,0 @@ -/** - * @fileoverview Rule Validator - * @author Nicholas C. Zakas - */ - -"use strict"; - -//----------------------------------------------------------------------------- -// Requirements -//----------------------------------------------------------------------------- - -const ajvImport = require("../shared/ajv"); -const ajv = ajvImport(); -const { - parseRuleId, - getRuleFromConfig, - getRuleOptionsSchema -} = require("./flat-config-helpers"); -const ruleReplacements = require("../../conf/replacements.json"); - -//----------------------------------------------------------------------------- -// Helpers -//----------------------------------------------------------------------------- - -/** - * Throws a helpful error when a rule cannot be found. - * @param {Object} ruleId The rule identifier. - * @param {string} ruleId.pluginName The ID of the rule to find. - * @param {string} ruleId.ruleName The ID of the rule to find. - * @param {Object} config The config to search in. - * @throws {TypeError} For missing plugin or rule. - * @returns {void} - */ -function throwRuleNotFoundError({ pluginName, ruleName }, config) { - - const ruleId = pluginName === "@" ? ruleName : `${pluginName}/${ruleName}`; - - const errorMessageHeader = `Key "rules": Key "${ruleId}"`; - let errorMessage = `${errorMessageHeader}: Could not find plugin "${pluginName}".`; - - // if the plugin exists then we need to check if the rule exists - if (config.plugins && config.plugins[pluginName]) { - const replacementRuleName = ruleReplacements.rules[ruleName]; - - if (pluginName === "@" && replacementRuleName) { - - errorMessage = `${errorMessageHeader}: Rule "${ruleName}" was removed and replaced by "${replacementRuleName}".`; - - } else { - - errorMessage = `${errorMessageHeader}: Could not find "${ruleName}" in plugin "${pluginName}".`; - - // otherwise, let's see if we can find the rule name elsewhere - for (const [otherPluginName, otherPlugin] of Object.entries(config.plugins)) { - if (otherPlugin.rules && otherPlugin.rules[ruleName]) { - errorMessage += ` Did you mean "${otherPluginName}/${ruleName}"?`; - break; - } - } - - } - - // falls through to throw error - } - - throw new TypeError(errorMessage); -} - -/** - * The error type when a rule has an invalid `meta.schema`. - */ -class InvalidRuleOptionsSchemaError extends Error { - - /** - * Creates a new instance. - * @param {string} ruleId Id of the rule that has an invalid `meta.schema`. - * @param {Error} processingError Error caught while processing the `meta.schema`. - */ - constructor(ruleId, processingError) { - super( - `Error while processing options validation schema of rule '${ruleId}': ${processingError.message}`, - { cause: processingError } - ); - this.code = "ESLINT_INVALID_RULE_OPTIONS_SCHEMA"; - } -} - -//----------------------------------------------------------------------------- -// Exports -//----------------------------------------------------------------------------- - -/** - * Implements validation functionality for the rules portion of a config. - */ -class RuleValidator { - - /** - * Creates a new instance. - */ - constructor() { - - /** - * A collection of compiled validators for rules that have already - * been validated. - * @type {WeakMap} - */ - this.validators = new WeakMap(); - } - - /** - * Validates all of the rule configurations in a config against each - * rule's schema. - * @param {Object} config The full config to validate. This object must - * contain both the rules section and the plugins section. - * @returns {void} - * @throws {Error} If a rule's configuration does not match its schema. - */ - validate(config) { - - if (!config.rules) { - return; - } - - for (const [ruleId, ruleOptions] of Object.entries(config.rules)) { - - // check for edge case - if (ruleId === "__proto__") { - continue; - } - - /* - * If a rule is disabled, we don't do any validation. This allows - * users to safely set any value to 0 or "off" without worrying - * that it will cause a validation error. - * - * Note: ruleOptions is always an array at this point because - * this validation occurs after FlatConfigArray has merged and - * normalized values. - */ - if (ruleOptions[0] === 0) { - continue; - } - - const rule = getRuleFromConfig(ruleId, config); - - if (!rule) { - throwRuleNotFoundError(parseRuleId(ruleId), config); - } - - // Precompile and cache validator the first time - if (!this.validators.has(rule)) { - try { - const schema = getRuleOptionsSchema(rule); - - if (schema) { - this.validators.set(rule, ajv.compile(schema)); - } - } catch (err) { - throw new InvalidRuleOptionsSchemaError(ruleId, err); - } - } - - const validateRule = this.validators.get(rule); - - if (validateRule) { - - validateRule(ruleOptions.slice(1)); - - if (validateRule.errors) { - throw new Error(`Key "rules": Key "${ruleId}":\n${ - validateRule.errors.map( - error => { - if ( - error.keyword === "additionalProperties" && - error.schema === false && - typeof error.parentSchema?.properties === "object" && - typeof error.params?.additionalProperty === "string" - ) { - const expectedProperties = Object.keys(error.parentSchema.properties).map(property => `"${property}"`); - - return `\tValue ${JSON.stringify(error.data)} ${error.message}.\n\t\tUnexpected property "${error.params.additionalProperty}". Expected properties: ${expectedProperties.join(", ")}.\n`; - } - - return `\tValue ${JSON.stringify(error.data)} ${error.message}.\n`; - } - ).join("") - }`); - } - } - } - } -} - -exports.RuleValidator = RuleValidator; diff --git a/tools/eslint/node_modules/eslint/lib/eslint/eslint-helpers.js b/tools/eslint/node_modules/eslint/lib/eslint/eslint-helpers.js deleted file mode 100644 index 38c16155cfdab9..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/eslint/eslint-helpers.js +++ /dev/null @@ -1,975 +0,0 @@ -/** - * @fileoverview Helper functions for ESLint class - * @author Nicholas C. Zakas - */ - -"use strict"; - -//----------------------------------------------------------------------------- -// Requirements -//----------------------------------------------------------------------------- - -const path = require("node:path"); -const fs = require("node:fs"); -const fsp = fs.promises; -const isGlob = require("is-glob"); -const hash = require("../cli-engine/hash"); -const minimatch = require("minimatch"); -const fswalk = require("@nodelib/fs.walk"); -const globParent = require("glob-parent"); -const isPathInside = require("is-path-inside"); - -//----------------------------------------------------------------------------- -// Fixup references -//----------------------------------------------------------------------------- - -const Minimatch = minimatch.Minimatch; -const MINIMATCH_OPTIONS = { dot: true }; - -//----------------------------------------------------------------------------- -// Types -//----------------------------------------------------------------------------- - -/** - * @typedef {Object} GlobSearch - * @property {Array} patterns The normalized patterns to use for a search. - * @property {Array} rawPatterns The patterns as entered by the user - * before doing any normalization. - */ - -//----------------------------------------------------------------------------- -// Errors -//----------------------------------------------------------------------------- - -/** - * The error type when no files match a glob. - */ -class NoFilesFoundError extends Error { - - /** - * @param {string} pattern The glob pattern which was not found. - * @param {boolean} globEnabled If `false` then the pattern was a glob pattern, but glob was disabled. - */ - constructor(pattern, globEnabled) { - super(`No files matching '${pattern}' were found${!globEnabled ? " (glob was disabled)" : ""}.`); - this.messageTemplate = "file-not-found"; - this.messageData = { pattern, globDisabled: !globEnabled }; - } -} - -/** - * 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} options.unmatchedPatterns The glob patterns - * which were not found. - * @param {Array} options.patterns The glob patterns that were - * searched. - * @param {Array} 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.unmatchedPatterns = 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. - */ -class AllFilesIgnoredError extends Error { - - /** - * @param {string} pattern The glob pattern which was not found. - */ - constructor(pattern) { - super(`All files matched by '${pattern}' are ignored.`); - this.messageTemplate = "all-matched-files-ignored"; - this.messageData = { pattern }; - } -} - - -//----------------------------------------------------------------------------- -// General Helpers -//----------------------------------------------------------------------------- - -/** - * Check if a given value is a non-empty string or not. - * @param {any} value The value to check. - * @returns {boolean} `true` if `value` is a non-empty string. - */ -function isNonEmptyString(value) { - return typeof value === "string" && value.trim() !== ""; -} - -/** - * Check if a given value is an array of non-empty strings or not. - * @param {any} value The value to check. - * @returns {boolean} `true` if `value` is an array of non-empty strings. - */ -function isArrayOfNonEmptyString(value) { - return Array.isArray(value) && value.length && value.every(isNonEmptyString); -} - -/** - * Check if a given value is an empty array or an array of non-empty strings. - * @param {any} value The value to check. - * @returns {boolean} `true` if `value` is an empty array or an array of non-empty - * strings. - */ -function isEmptyArrayOrArrayOfNonEmptyString(value) { - return Array.isArray(value) && value.every(isNonEmptyString); -} - -//----------------------------------------------------------------------------- -// File-related Helpers -//----------------------------------------------------------------------------- - -/** - * Normalizes slashes in a file pattern to posix-style. - * @param {string} pattern The pattern to replace slashes in. - * @returns {string} The pattern with slashes normalized. - */ -function normalizeToPosix(pattern) { - return pattern.replace(/\\/gu, "/"); -} - -/** - * Check if a string is a glob pattern or not. - * @param {string} pattern A glob pattern. - * @returns {boolean} `true` if the string is a glob pattern. - */ -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} 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, MINIMATCH_OPTIONS); - - 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} options.patterns An array of glob patterns - * to match. - * @param {Array} 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>} An array of matching file paths - * or an empty array if there are no matches. - * @throws {UnmatchedSearchPatternsError} 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(patternToUse, MINIMATCH_OPTIONS); - }); - - /* - * 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 new Promise((resolve, reject) => { - - let promiseRejected = false; - - /** - * Wraps a boolean-returning filter function. The wrapped function will reject the promise if an error occurs. - * @param {Function} filter A filter function to wrap. - * @returns {Function} A function similar to the wrapped filter that rejects the promise if an error occurs. - */ - function wrapFilter(filter) { - return (...args) => { - - // No need to run the filter if an error has been thrown. - if (!promiseRejected) { - try { - return filter(...args); - } catch (error) { - promiseRejected = true; - reject(error); - } - } - return false; - }; - } - - fswalk.walk( - basePath, - { - deepFilter: wrapFilter(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: wrapFilter(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 has a config. If the file has no - * config, that means there wasn't a match for the - * pattern so it should not be removed. - * - * Performance note: `getConfig()` aggressively caches - * results so there is no performance penalty for calling - * it multiple times with the same argument. - */ - if (pathMatches && configs.getConfig(entry.path)) { - unmatchedPatterns.delete(matcher.pattern); - } - - return pathMatches || previousValue; - }, false) - : matchers.some(matcher => matcher.match(relativePath)); - - return matchesPattern && configs.getConfig(entry.path) !== void 0; - }) - }, - (error, entries) => { - - // If the promise is already rejected, calling `resolve` or `reject` will do nothing. - if (error) { - reject(error); - } else { - resolve(entries); - } - } - ); - })).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; -} - -/** - * Throws an error for unmatched patterns. The error will only contain information about the first one. - * Checks to see if there are any ignored results for a given search. - * @param {Object} options The options for this function. - * @param {string} options.basePath The directory to search. - * @param {Array} options.patterns An array of glob patterns - * that were used in the original search. - * @param {Array} options.rawPatterns An array of glob patterns - * as the user inputted them. Used for errors. - * @param {Array} options.unmatchedPatterns A non-empty array of glob patterns - * that were unmatched in the original search. - * @returns {void} Always throws an error. - * @throws {NoFilesFoundError} If the first unmatched pattern - * doesn't match any files even when there are no ignores. - * @throws {AllFilesIgnoredError} If the first unmatched pattern - * matches some files when there are no ignores. - */ -async function throwErrorForUnmatchedPatterns({ - basePath, - patterns, - rawPatterns, - unmatchedPatterns -}) { - - const pattern = unmatchedPatterns[0]; - const rawPattern = rawPatterns[patterns.indexOf(pattern)]; - - const patternHasMatch = await globMatch({ - basePath, - pattern - }); - - if (patternHasMatch) { - throw new AllFilesIgnoredError(rawPattern); - } - - // if we get here there are truly no matches - throw new NoFilesFoundError(rawPattern, true); -} - -/** - * Performs multiple glob searches in parallel. - * @param {Object} options The options for this function. - * @param {Map} 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>} 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 throwErrorForUnmatchedPatterns({ - ...currentSearch, - unmatchedPatterns: error.unmatchedPatterns - }); - - } - - } - - return filePaths; - -} - -/** - * Finds all files matching the options specified. - * @param {Object} args The arguments objects. - * @param {Array} args.patterns An array of glob patterns. - * @param {boolean} args.globInputPaths true to interpret glob patterns, - * false to not interpret glob patterns. - * @param {string} args.cwd The current working directory to find from. - * @param {FlatConfigArray} args.configs The configs for the current run. - * @param {boolean} args.errorOnUnmatchedPattern Determines if an unmatched pattern - * should throw an error. - * @returns {Promise>} The fully resolved file paths. - * @throws {AllFilesIgnoredError} If there are no results due to an ignore pattern. - * @throws {NoFilesFoundError} If no files matched the given patterns. - */ -async function findFiles({ - patterns, - globInputPaths, - cwd, - configs, - errorOnUnmatchedPattern -}) { - - const results = []; - const missingPatterns = []; - let globbyPatterns = []; - let rawPatterns = []; - const searches = new Map([[cwd, { patterns: globbyPatterns, rawPatterns: [] }]]); - - // check to see if we have explicit files and directories - const filePaths = patterns.map(filePath => path.resolve(cwd, filePath)); - const stats = await Promise.all( - filePaths.map( - filePath => fsp.stat(filePath).catch(() => { }) - ) - ); - - stats.forEach((stat, index) => { - - const filePath = filePaths[index]; - const pattern = normalizeToPosix(patterns[index]); - - if (stat) { - - // files are added directly to the list - if (stat.isFile()) { - results.push(filePath); - } - - // directories need extensions attached - if (stat.isDirectory()) { - - // group everything in cwd together and split out others - if (isPathInside(filePath, cwd)) { - ({ patterns: globbyPatterns, rawPatterns } = searches.get(cwd)); - } else { - if (!searches.has(filePath)) { - searches.set(filePath, { patterns: [], rawPatterns: [] }); - } - ({ patterns: globbyPatterns, rawPatterns } = searches.get(filePath)); - } - - globbyPatterns.push(`${normalizeToPosix(filePath)}/**`); - rawPatterns.push(pattern); - } - - return; - } - - // save patterns for later use based on whether globs are enabled - if (globInputPaths && isGlobPattern(pattern)) { - - const basePath = path.resolve(cwd, globParent(pattern)); - - // group in cwd if possible and split out others - if (isPathInside(basePath, cwd)) { - ({ patterns: globbyPatterns, rawPatterns } = searches.get(cwd)); - } else { - if (!searches.has(basePath)) { - searches.set(basePath, { patterns: [], rawPatterns: [] }); - } - ({ patterns: globbyPatterns, rawPatterns } = searches.get(basePath)); - } - - globbyPatterns.push(filePath); - rawPatterns.push(pattern); - } else { - missingPatterns.push(pattern); - } - }); - - // 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 [ - ...new Set([ - ...results, - ...globbyResults.map(filePath => path.resolve(filePath)) - ]) - ]; -} - -//----------------------------------------------------------------------------- -// Results-related Helpers -//----------------------------------------------------------------------------- - -/** - * Checks if the given message is an error message. - * @param {LintMessage} message The message to check. - * @returns {boolean} Whether or not the message is an error message. - * @private - */ -function isErrorMessage(message) { - return message.severity === 2; -} - -/** - * Returns result with warning by ignore settings - * @param {string} filePath File path of checked code - * @param {string} baseDir Absolute path of base directory - * @param {"ignored"|"external"|"unconfigured"} configStatus A status that determines why the file is ignored - * @returns {LintResult} Result with single warning - * @private - */ -function createIgnoreResult(filePath, baseDir, configStatus) { - let message; - - switch (configStatus) { - case "external": - message = "File ignored because outside of base path."; - break; - case "unconfigured": - message = "File ignored because no matching configuration was supplied."; - break; - default: - { - const isInNodeModules = baseDir && path.dirname(path.relative(baseDir, filePath)).split(path.sep).includes("node_modules"); - - if (isInNodeModules) { - message = "File ignored by default because it is located under the node_modules directory. Use ignore pattern \"!**/node_modules/\" to disable file ignore settings or use \"--no-warn-ignored\" to suppress this warning."; - } else { - message = "File ignored because of a matching ignore pattern. Use \"--no-ignore\" to disable file ignore settings or use \"--no-warn-ignored\" to suppress this warning."; - } - } - break; - } - - return { - filePath: path.resolve(filePath), - messages: [ - { - ruleId: null, - fatal: false, - severity: 1, - message, - nodeType: null - } - ], - suppressedMessages: [], - errorCount: 0, - warningCount: 1, - fatalErrorCount: 0, - fixableErrorCount: 0, - fixableWarningCount: 0 - }; -} - -//----------------------------------------------------------------------------- -// Options-related Helpers -//----------------------------------------------------------------------------- - - -/** - * Check if a given value is a valid fix type or not. - * @param {any} x The value to check. - * @returns {boolean} `true` if `x` is valid fix type. - */ -function isFixType(x) { - return x === "directive" || x === "problem" || x === "suggestion" || x === "layout"; -} - -/** - * Check if a given value is an array of fix types or not. - * @param {any} x The value to check. - * @returns {boolean} `true` if `x` is an array of fix types. - */ -function isFixTypeArray(x) { - return Array.isArray(x) && x.every(isFixType); -} - -/** - * The error for invalid options. - */ -class ESLintInvalidOptionsError extends Error { - constructor(messages) { - super(`Invalid Options:\n- ${messages.join("\n- ")}`); - this.code = "ESLINT_INVALID_OPTIONS"; - Error.captureStackTrace(this, ESLintInvalidOptionsError); - } -} - -/** - * Validates and normalizes options for the wrapped CLIEngine instance. - * @param {ESLintOptions} options The options to process. - * @throws {ESLintInvalidOptionsError} If of any of a variety of type errors. - * @returns {ESLintOptions} The normalized options. - */ -function processOptions({ - allowInlineConfig = true, // โ† we cannot use `overrideConfig.noInlineConfig` instead because `allowInlineConfig` has side-effect that suppress warnings that show inline configs are ignored. - baseConfig = null, - cache = false, - cacheLocation = ".eslintcache", - cacheStrategy = "metadata", - cwd = process.cwd(), - errorOnUnmatchedPattern = true, - fix = false, - fixTypes = null, // โ† should be null by default because if it's an array then it suppresses rules that don't have the `meta.type` property. - flags = [], - globInputPaths = true, - ignore = true, - ignorePatterns = null, - overrideConfig = null, - overrideConfigFile = null, - plugins = {}, - stats = false, - warnIgnored = true, - passOnNoPatterns = false, - ruleFilter = () => true, - ...unknownOptions -}) { - const errors = []; - const unknownOptionKeys = Object.keys(unknownOptions); - - if (unknownOptionKeys.length >= 1) { - errors.push(`Unknown options: ${unknownOptionKeys.join(", ")}`); - if (unknownOptionKeys.includes("cacheFile")) { - errors.push("'cacheFile' has been removed. Please use the 'cacheLocation' option instead."); - } - if (unknownOptionKeys.includes("configFile")) { - errors.push("'configFile' has been removed. Please use the 'overrideConfigFile' option instead."); - } - if (unknownOptionKeys.includes("envs")) { - errors.push("'envs' has been removed."); - } - if (unknownOptionKeys.includes("extensions")) { - errors.push("'extensions' has been removed."); - } - if (unknownOptionKeys.includes("resolvePluginsRelativeTo")) { - errors.push("'resolvePluginsRelativeTo' has been removed."); - } - if (unknownOptionKeys.includes("globals")) { - errors.push("'globals' has been removed. Please use the 'overrideConfig.languageOptions.globals' option instead."); - } - if (unknownOptionKeys.includes("ignorePath")) { - errors.push("'ignorePath' has been removed."); - } - if (unknownOptionKeys.includes("ignorePattern")) { - errors.push("'ignorePattern' has been removed. Please use the 'overrideConfig.ignorePatterns' option instead."); - } - if (unknownOptionKeys.includes("parser")) { - errors.push("'parser' has been removed. Please use the 'overrideConfig.languageOptions.parser' option instead."); - } - if (unknownOptionKeys.includes("parserOptions")) { - errors.push("'parserOptions' has been removed. Please use the 'overrideConfig.languageOptions.parserOptions' option instead."); - } - if (unknownOptionKeys.includes("rules")) { - errors.push("'rules' has been removed. Please use the 'overrideConfig.rules' option instead."); - } - if (unknownOptionKeys.includes("rulePaths")) { - errors.push("'rulePaths' has been removed. Please define your rules using plugins."); - } - if (unknownOptionKeys.includes("reportUnusedDisableDirectives")) { - errors.push("'reportUnusedDisableDirectives' has been removed. Please use the 'overrideConfig.linterOptions.reportUnusedDisableDirectives' option instead."); - } - } - if (typeof allowInlineConfig !== "boolean") { - errors.push("'allowInlineConfig' must be a boolean."); - } - if (typeof baseConfig !== "object") { - errors.push("'baseConfig' must be an object or null."); - } - if (typeof cache !== "boolean") { - errors.push("'cache' must be a boolean."); - } - if (!isNonEmptyString(cacheLocation)) { - errors.push("'cacheLocation' must be a non-empty string."); - } - if ( - cacheStrategy !== "metadata" && - cacheStrategy !== "content" - ) { - errors.push("'cacheStrategy' must be any of \"metadata\", \"content\"."); - } - if (!isNonEmptyString(cwd) || !path.isAbsolute(cwd)) { - errors.push("'cwd' must be an absolute path."); - } - if (typeof errorOnUnmatchedPattern !== "boolean") { - errors.push("'errorOnUnmatchedPattern' must be a boolean."); - } - if (typeof fix !== "boolean" && typeof fix !== "function") { - errors.push("'fix' must be a boolean or a function."); - } - if (fixTypes !== null && !isFixTypeArray(fixTypes)) { - errors.push("'fixTypes' must be an array of any of \"directive\", \"problem\", \"suggestion\", and \"layout\"."); - } - if (!isEmptyArrayOrArrayOfNonEmptyString(flags)) { - errors.push("'flags' must be an array of non-empty strings."); - } - if (typeof globInputPaths !== "boolean") { - errors.push("'globInputPaths' must be a boolean."); - } - if (typeof ignore !== "boolean") { - errors.push("'ignore' must be a boolean."); - } - if (!isEmptyArrayOrArrayOfNonEmptyString(ignorePatterns) && ignorePatterns !== null) { - errors.push("'ignorePatterns' must be an array of non-empty strings or null."); - } - if (typeof overrideConfig !== "object") { - errors.push("'overrideConfig' must be an object or null."); - } - if (!isNonEmptyString(overrideConfigFile) && overrideConfigFile !== null && overrideConfigFile !== true) { - errors.push("'overrideConfigFile' must be a non-empty string, null, or true."); - } - if (typeof passOnNoPatterns !== "boolean") { - errors.push("'passOnNoPatterns' must be a boolean."); - } - if (typeof plugins !== "object") { - errors.push("'plugins' must be an object or null."); - } else if (plugins !== null && Object.keys(plugins).includes("")) { - errors.push("'plugins' must not include an empty string."); - } - if (Array.isArray(plugins)) { - errors.push("'plugins' doesn't add plugins to configuration to load. Please use the 'overrideConfig.plugins' option instead."); - } - if (typeof stats !== "boolean") { - errors.push("'stats' must be a boolean."); - } - if (typeof warnIgnored !== "boolean") { - errors.push("'warnIgnored' must be a boolean."); - } - if (typeof ruleFilter !== "function") { - errors.push("'ruleFilter' must be a function."); - } - if (errors.length > 0) { - throw new ESLintInvalidOptionsError(errors); - } - - return { - allowInlineConfig, - baseConfig, - cache, - cacheLocation, - cacheStrategy, - - // when overrideConfigFile is true that means don't do config file lookup - configFile: overrideConfigFile === true ? false : overrideConfigFile, - overrideConfig, - cwd: path.normalize(cwd), - errorOnUnmatchedPattern, - fix, - fixTypes, - flags: [...flags], - globInputPaths, - ignore, - ignorePatterns, - stats, - passOnNoPatterns, - warnIgnored, - ruleFilter - }; -} - - -//----------------------------------------------------------------------------- -// Cache-related helpers -//----------------------------------------------------------------------------- - -/** - * return the cacheFile to be used by eslint, based on whether the provided parameter is - * a directory or looks like a directory (ends in `path.sep`), in which case the file - * name will be the `cacheFile/.cache_hashOfCWD` - * - * if cacheFile points to a file or looks like a file then in will just use that file - * @param {string} cacheFile The name of file to be used to store the cache - * @param {string} cwd Current working directory - * @returns {string} the resolved path to the cache file - */ -function getCacheFile(cacheFile, cwd) { - - /* - * make sure the path separators are normalized for the environment/os - * keeping the trailing path separator if present - */ - const normalizedCacheFile = path.normalize(cacheFile); - - const resolvedCacheFile = path.resolve(cwd, normalizedCacheFile); - const looksLikeADirectory = normalizedCacheFile.slice(-1) === path.sep; - - /** - * return the name for the cache file in case the provided parameter is a directory - * @returns {string} the resolved path to the cacheFile - */ - function getCacheFileForDirectory() { - return path.join(resolvedCacheFile, `.cache_${hash(cwd)}`); - } - - let fileStats; - - try { - fileStats = fs.lstatSync(resolvedCacheFile); - } catch { - fileStats = null; - } - - - /* - * in case the file exists we need to verify if the provided path - * is a directory or a file. If it is a directory we want to create a file - * inside that directory - */ - if (fileStats) { - - /* - * is a directory or is a file, but the original file the user provided - * looks like a directory but `path.resolve` removed the `last path.sep` - * so we need to still treat this like a directory - */ - if (fileStats.isDirectory() || looksLikeADirectory) { - return getCacheFileForDirectory(); - } - - // is file so just use that file - return resolvedCacheFile; - } - - /* - * here we known the file or directory doesn't exist, - * so we will try to infer if its a directory if it looks like a directory - * for the current operating system. - */ - - // if the last character passed is a path separator we assume is a directory - if (looksLikeADirectory) { - return getCacheFileForDirectory(); - } - - return resolvedCacheFile; -} - - -//----------------------------------------------------------------------------- -// Exports -//----------------------------------------------------------------------------- - -module.exports = { - findFiles, - - isNonEmptyString, - isArrayOfNonEmptyString, - - createIgnoreResult, - isErrorMessage, - - processOptions, - - getCacheFile -}; diff --git a/tools/eslint/node_modules/eslint/lib/eslint/eslint.js b/tools/eslint/node_modules/eslint/lib/eslint/eslint.js deleted file mode 100644 index f20b2119a418f7..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/eslint/eslint.js +++ /dev/null @@ -1,1231 +0,0 @@ -/** - * @fileoverview Main class using flat config - * @author Nicholas C. Zakas - */ - -"use strict"; - -//------------------------------------------------------------------------------ -// Requirements -//------------------------------------------------------------------------------ - -const fs = require("node:fs/promises"); -const { existsSync } = require("node:fs"); -const path = require("node:path"); -const findUp = require("find-up"); -const { version } = require("../../package.json"); -const { Linter } = require("../linter"); -const { getRuleFromConfig } = require("../config/flat-config-helpers"); -const { - Legacy: { - ConfigOps: { - getRuleSeverity - }, - ModuleResolver, - naming - } -} = require("@eslint/eslintrc"); - -const { - findFiles, - getCacheFile, - - isNonEmptyString, - isArrayOfNonEmptyString, - - createIgnoreResult, - isErrorMessage, - - processOptions -} = require("./eslint-helpers"); -const { pathToFileURL } = require("node:url"); -const { FlatConfigArray } = require("../config/flat-config-array"); -const LintResultCache = require("../cli-engine/lint-result-cache"); -const { Retrier } = require("@humanwhocodes/retry"); - -/* - * This is necessary to allow overwriting writeFile for testing purposes. - * We can just use fs/promises once we drop Node.js 12 support. - */ - -//------------------------------------------------------------------------------ -// Typedefs -//------------------------------------------------------------------------------ - -// For VSCode IntelliSense -/** @typedef {import("../shared/types").ConfigData} ConfigData */ -/** @typedef {import("../shared/types").DeprecatedRuleInfo} DeprecatedRuleInfo */ -/** @typedef {import("../shared/types").LintMessage} LintMessage */ -/** @typedef {import("../shared/types").LintResult} LintResult */ -/** @typedef {import("../shared/types").ParserOptions} ParserOptions */ -/** @typedef {import("../shared/types").Plugin} Plugin */ -/** @typedef {import("../shared/types").ResultsMeta} ResultsMeta */ -/** @typedef {import("../shared/types").RuleConf} RuleConf */ -/** @typedef {import("../shared/types").Rule} Rule */ -/** @typedef {ReturnType} ExtractedConfig */ - -/** - * The options with which to configure the ESLint instance. - * @typedef {Object} ESLintOptions - * @property {boolean} [allowInlineConfig] Enable or disable inline configuration comments. - * @property {ConfigData|Array} [baseConfig] Base config, extended by all configs used with this instance - * @property {boolean} [cache] Enable result caching. - * @property {string} [cacheLocation] The cache file to use instead of .eslintcache. - * @property {"metadata" | "content"} [cacheStrategy] The strategy used to detect changed files. - * @property {string} [cwd] The value to use for the current working directory. - * @property {boolean} [errorOnUnmatchedPattern] If `false` then `ESLint#lintFiles()` doesn't throw even if no target files found. Defaults to `true`. - * @property {boolean|Function} [fix] Execute in autofix mode. If a function, should return a boolean. - * @property {string[]} [fixTypes] Array of rule types to apply fixes for. - * @property {string[]} [flags] Array of feature flags to enable. - * @property {boolean} [globInputPaths] Set to false to skip glob resolution of input file paths to lint (default: true). If false, each input file paths is assumed to be a non-glob path to an existing file. - * @property {boolean} [ignore] False disables all ignore patterns except for the default ones. - * @property {string[]} [ignorePatterns] Ignore file patterns to use in addition to config ignores. These patterns are relative to `cwd`. - * @property {ConfigData|Array} [overrideConfig] Override config, overrides all configs used with this instance - * @property {boolean|string} [overrideConfigFile] Searches for default config file when falsy; - * doesn't do any config file lookup when `true`; considered to be a config filename - * when a string. - * @property {Record} [plugins] An array of plugin implementations. - * @property {boolean} [stats] True enables added statistics on lint results. - * @property {boolean} warnIgnored Show warnings when the file list includes ignored files - * @property {boolean} [passOnNoPatterns=false] When set to true, missing patterns cause - * the linting operation to short circuit and not report any failures. - */ - -//------------------------------------------------------------------------------ -// Helpers -//------------------------------------------------------------------------------ - -const FLAT_CONFIG_FILENAMES = [ - "eslint.config.js", - "eslint.config.mjs", - "eslint.config.cjs" -]; -const debug = require("debug")("eslint:eslint"); -const privateMembers = new WeakMap(); -const importedConfigFileModificationTime = new Map(); -const removedFormatters = new Set([ - "checkstyle", - "codeframe", - "compact", - "jslint-xml", - "junit", - "table", - "tap", - "unix", - "visualstudio" -]); - -/** - * It will calculate the error and warning count for collection of messages per file - * @param {LintMessage[]} messages Collection of messages - * @returns {Object} Contains the stats - * @private - */ -function calculateStatsPerFile(messages) { - const stat = { - errorCount: 0, - fatalErrorCount: 0, - warningCount: 0, - fixableErrorCount: 0, - fixableWarningCount: 0 - }; - - for (let i = 0; i < messages.length; i++) { - const message = messages[i]; - - if (message.fatal || message.severity === 2) { - stat.errorCount++; - if (message.fatal) { - stat.fatalErrorCount++; - } - if (message.fix) { - stat.fixableErrorCount++; - } - } else { - stat.warningCount++; - if (message.fix) { - stat.fixableWarningCount++; - } - } - } - return stat; -} - -/** - * Create rulesMeta object. - * @param {Map} rules a map of rules from which to generate the object. - * @returns {Object} metadata for all enabled rules. - */ -function createRulesMeta(rules) { - return Array.from(rules).reduce((retVal, [id, rule]) => { - retVal[id] = rule.meta; - return retVal; - }, {}); -} - -/** - * 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} */ -const usedDeprecatedRulesCache = new WeakMap(); - -/** - * Create used deprecated rule list. - * @param {CLIEngine} eslint The CLIEngine instance. - * @param {string} maybeFilePath The absolute path to a lint target file or `""`. - * @returns {DeprecatedRuleInfo[]} The used deprecated rule list. - */ -function getOrFindUsedDeprecatedRules(eslint, maybeFilePath) { - const { - configs, - options: { cwd } - } = privateMembers.get(eslint); - const filePath = path.isAbsolute(maybeFilePath) - ? maybeFilePath - : getPlaceholderPath(cwd); - const config = configs.getConfig(filePath); - - // Most files use the same config, so cache it. - if (config && !usedDeprecatedRulesCache.has(config)) { - const retv = []; - - if (config.rules) { - for (const [ruleId, ruleConf] of Object.entries(config.rules)) { - if (getRuleSeverity(ruleConf) === 0) { - continue; - } - const rule = getRuleFromConfig(ruleId, config); - const meta = rule && rule.meta; - - if (meta && meta.deprecated) { - retv.push({ ruleId, replacedBy: meta.replacedBy || [] }); - } - } - } - - - usedDeprecatedRulesCache.set(config, Object.freeze(retv)); - } - - return config ? usedDeprecatedRulesCache.get(config) : Object.freeze([]); -} - -/** - * Processes the linting results generated by a CLIEngine linting report to - * match the ESLint class's API. - * @param {CLIEngine} eslint The CLIEngine instance. - * @param {CLIEngineLintReport} report The CLIEngine linting report to process. - * @returns {LintResult[]} The processed linting results. - */ -function processLintReport(eslint, { results }) { - const descriptor = { - configurable: true, - enumerable: true, - get() { - return getOrFindUsedDeprecatedRules(eslint, this.filePath); - } - }; - - for (const result of results) { - Object.defineProperty(result, "usedDeprecatedRules", descriptor); - } - - return results; -} - -/** - * An Array.prototype.sort() compatible compare function to order results by their file path. - * @param {LintResult} a The first lint result. - * @param {LintResult} b The second lint result. - * @returns {number} An integer representing the order in which the two results should occur. - */ -function compareResultsByFilePath(a, b) { - if (a.filePath < b.filePath) { - return -1; - } - - if (a.filePath > b.filePath) { - return 1; - } - - return 0; -} - -/** - * Searches from the current working directory up until finding the - * given flat config filename. - * @param {string} cwd The current working directory to search from. - * @returns {Promise} The filename if found or `undefined` if not. - */ -function findFlatConfigFile(cwd) { - return findUp( - FLAT_CONFIG_FILENAMES, - { cwd } - ); -} - -/** - * Load the config array from the given filename. - * @param {string} filePath The filename to load from. - * @returns {Promise} The config loaded from the config file. - */ -async function loadFlatConfigFile(filePath) { - debug(`Loading config from ${filePath}`); - - const fileURL = pathToFileURL(filePath); - - debug(`Config file URL is ${fileURL}`); - - const mtime = (await fs.stat(filePath)).mtime.getTime(); - - /* - * Append a query with the config file's modification time (`mtime`) in order - * to import the current version of the config file. Without the query, `import()` would - * cache the config file module by the pathname only, and then always return - * the same version (the one that was actual when the module was imported for the first time). - * - * This ensures that the config file module is loaded and executed again - * if it has been changed since the last time it was imported. - * If it hasn't been changed, `import()` will just return the cached version. - * - * Note that we should not overuse queries (e.g., by appending the current time - * to always reload the config file module) as that could cause memory leaks - * because entries are never removed from the import cache. - */ - fileURL.searchParams.append("mtime", mtime); - - /* - * With queries, we can bypass the import cache. However, when import-ing a CJS module, - * Node.js uses the require infrastructure under the hood. That includes the require cache, - * which caches the config file module by its file path (queries have no effect). - * Therefore, we also need to clear the require cache before importing the config file module. - * In order to get the same behavior with ESM and CJS config files, in particular - to reload - * the config file only if it has been changed, we track file modification times and clear - * the require cache only if the file has been changed. - */ - if (importedConfigFileModificationTime.get(filePath) !== mtime) { - delete require.cache[filePath]; - } - - const config = (await import(fileURL)).default; - - importedConfigFileModificationTime.set(filePath, mtime); - - return config; -} - -/** - * Determines which config file to use. This is determined by seeing if an - * override config file was passed, and if so, using it; otherwise, as long - * as override config file is not explicitly set to `false`, it will search - * upwards from the cwd for a file named `eslint.config.js`. - * @param {import("./eslint").ESLintOptions} options The ESLint instance options. - * @returns {{configFilePath:string|undefined,basePath:string,error:Error|null}} Location information for - * the config file. - */ -async function locateConfigFileToUse({ configFile, cwd }) { - - // determine where to load config file from - let configFilePath; - let basePath = cwd; - let error = null; - - if (typeof configFile === "string") { - debug(`Override config file path is ${configFile}`); - configFilePath = path.resolve(cwd, configFile); - } else if (configFile !== false) { - debug("Searching for eslint.config.js"); - configFilePath = await findFlatConfigFile(cwd); - - if (configFilePath) { - basePath = path.resolve(path.dirname(configFilePath)); - } else { - error = new Error("Could not find config file."); - error.messageTemplate = "config-file-missing"; - } - - } - - return { - configFilePath, - basePath, - error - }; - -} - -/** - * Calculates the config array for this run based on inputs. - * @param {ESLint} eslint The instance to create the config array for. - * @param {import("./eslint").ESLintOptions} options The ESLint instance options. - * @returns {FlatConfigArray} The config array for `eslint``. - */ -async function calculateConfigArray(eslint, { - cwd, - baseConfig, - overrideConfig, - configFile, - ignore: shouldIgnore, - ignorePatterns -}) { - - // check for cached instance - const slots = privateMembers.get(eslint); - - if (slots.configs) { - return slots.configs; - } - - const { configFilePath, basePath, error } = await locateConfigFileToUse({ configFile, cwd }); - - // config file is required to calculate config - if (error) { - throw error; - } - - const configs = new FlatConfigArray(baseConfig || [], { basePath, shouldIgnore }); - - // load config file - if (configFilePath) { - const fileConfig = await loadFlatConfigFile(configFilePath); - - if (Array.isArray(fileConfig)) { - configs.push(...fileConfig); - } else { - configs.push(fileConfig); - } - } - - // add in any configured defaults - configs.push(...slots.defaultConfigs); - - // append command line ignore patterns - if (ignorePatterns && ignorePatterns.length > 0) { - - let relativeIgnorePatterns; - - /* - * If the config file basePath is different than the cwd, then - * the ignore patterns won't work correctly. Here, we adjust the - * ignore pattern to include the correct relative path. Patterns - * passed as `ignorePatterns` are relative to the cwd, whereas - * the config file basePath can be an ancestor of the cwd. - */ - if (basePath === cwd) { - relativeIgnorePatterns = ignorePatterns; - } else { - - // In minimatch patterns, only `/` can be used as path separator - const relativeIgnorePath = path.relative(basePath, cwd).replaceAll(path.sep, "/"); - - relativeIgnorePatterns = ignorePatterns.map(pattern => { - const negated = pattern.startsWith("!"); - const basePattern = negated ? pattern.slice(1) : pattern; - - return (negated ? "!" : "") + - path.posix.join(relativeIgnorePath, basePattern); - }); - } - - /* - * Ignore patterns are added to the end of the config array - * so they can override default ignores. - */ - configs.push({ - ignores: relativeIgnorePatterns - }); - } - - if (overrideConfig) { - if (Array.isArray(overrideConfig)) { - configs.push(...overrideConfig); - } else { - configs.push(overrideConfig); - } - } - - await configs.normalize(); - - // cache the config array for this instance - slots.configs = configs; - - return configs; -} - -/** - * Processes an source code using ESLint. - * @param {Object} config The config object. - * @param {string} config.text The source code to verify. - * @param {string} config.cwd The path to the current working directory. - * @param {string|undefined} config.filePath The path to the file of `text`. If this is undefined, it uses ``. - * @param {FlatConfigArray} config.configs The config. - * @param {boolean} config.fix If `true` then it does fix. - * @param {boolean} config.allowInlineConfig If `true` then it uses directive comments. - * @param {Function} config.ruleFilter A predicate function to filter which rules should be run. - * @param {boolean} config.stats If `true`, then if reports extra statistics with the lint results. - * @param {Linter} config.linter The linter instance to verify. - * @returns {LintResult} The result of linting. - * @private - */ -function verifyText({ - text, - cwd, - filePath: providedFilePath, - configs, - fix, - allowInlineConfig, - ruleFilter, - stats, - linter -}) { - const filePath = providedFilePath || ""; - - debug(`Lint ${filePath}`); - - /* - * Verify. - * `config.extractConfig(filePath)` requires an absolute path, but `linter` - * doesn't know CWD, so it gives `linter` an absolute path always. - */ - const filePathToVerify = filePath === "" ? getPlaceholderPath(cwd) : filePath; - const { fixed, messages, output } = linter.verifyAndFix( - text, - configs, - { - allowInlineConfig, - filename: filePathToVerify, - fix, - ruleFilter, - stats, - - /** - * Check if the linter should adopt a given code block or not. - * @param {string} blockFilename The virtual filename of a code block. - * @returns {boolean} `true` if the linter should adopt the code block. - */ - filterCodeBlock(blockFilename) { - return configs.getConfig(blockFilename) !== void 0; - } - } - ); - - // Tweak and return. - const result = { - filePath: filePath === "" ? filePath : path.resolve(filePath), - messages, - suppressedMessages: linter.getSuppressedMessages(), - ...calculateStatsPerFile(messages) - }; - - if (fixed) { - result.output = output; - } - - if ( - result.errorCount + result.warningCount > 0 && - typeof result.output === "undefined" - ) { - result.source = text; - } - - if (stats) { - result.stats = { - times: linter.getTimes(), - fixPasses: linter.getFixPassCount() - }; - } - - return result; -} - -/** - * Checks whether a message's rule type should be fixed. - * @param {LintMessage} message The message to check. - * @param {FlatConfig} config The config for the file that generated the message. - * @param {string[]} fixTypes An array of fix types to check. - * @returns {boolean} Whether the message should be fixed. - */ -function shouldMessageBeFixed(message, config, fixTypes) { - if (!message.ruleId) { - return fixTypes.has("directive"); - } - - const rule = message.ruleId && getRuleFromConfig(message.ruleId, config); - - return Boolean(rule && rule.meta && fixTypes.has(rule.meta.type)); -} - -/** - * 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 -//----------------------------------------------------------------------------- - -/** - * Primary Node.js API for ESLint. - */ -class ESLint { - - /** - * The type of configuration used by this class. - * @type {string} - */ - static configType = "flat"; - - /** - * Creates a new instance of the main ESLint API. - * @param {ESLintOptions} options The options for this instance. - */ - constructor(options = {}) { - - const defaultConfigs = []; - const processedOptions = processOptions(options); - const linter = new Linter({ - cwd: processedOptions.cwd, - configType: "flat", - flags: processedOptions.flags - }); - - const cacheFilePath = getCacheFile( - processedOptions.cacheLocation, - processedOptions.cwd - ); - - const lintResultCache = processedOptions.cache - ? new LintResultCache(cacheFilePath, processedOptions.cacheStrategy) - : null; - - privateMembers.set(this, { - options: processedOptions, - linter, - cacheFilePath, - lintResultCache, - defaultConfigs, - configs: null - }); - - /** - * If additional plugins are passed in, add that to the default - * configs for this instance. - */ - if (options.plugins) { - - const plugins = {}; - - for (const [pluginName, plugin] of Object.entries(options.plugins)) { - plugins[naming.getShorthandName(pluginName, "eslint-plugin")] = plugin; - } - - defaultConfigs.push({ - plugins - }); - } - - // Check for the .eslintignore file, and warn if it's present. - if (existsSync(path.resolve(processedOptions.cwd, ".eslintignore"))) { - process.emitWarning( - "The \".eslintignore\" file is no longer supported. Switch to using the \"ignores\" property in \"eslint.config.js\": https://eslint.org/docs/latest/use/configure/migration-guide#ignoring-files", - "ESLintIgnoreWarning" - ); - } - } - - /** - * The version text. - * @type {string} - */ - static get version() { - return version; - } - - /** - * Outputs fixes from the given results to files. - * @param {LintResult[]} results The lint results. - * @returns {Promise} Returns a promise that is used to track side effects. - */ - static async outputFixes(results) { - if (!Array.isArray(results)) { - throw new Error("'results' must be an array"); - } - - await Promise.all( - results - .filter(result => { - if (typeof result !== "object" || result === null) { - throw new Error("'results' must include only objects"); - } - return ( - typeof result.output === "string" && - path.isAbsolute(result.filePath) - ); - }) - .map(r => fs.writeFile(r.filePath, r.output)) - ); - } - - /** - * Returns results that only contains errors. - * @param {LintResult[]} results The results to filter. - * @returns {LintResult[]} The filtered results. - */ - static getErrorResults(results) { - const filtered = []; - - results.forEach(result => { - const filteredMessages = result.messages.filter(isErrorMessage); - const filteredSuppressedMessages = result.suppressedMessages.filter(isErrorMessage); - - if (filteredMessages.length > 0) { - filtered.push({ - ...result, - messages: filteredMessages, - suppressedMessages: filteredSuppressedMessages, - errorCount: filteredMessages.length, - warningCount: 0, - fixableErrorCount: result.fixableErrorCount, - fixableWarningCount: 0 - }); - } - }); - - return filtered; - } - - /** - * Returns meta objects for each rule represented in the lint results. - * @param {LintResult[]} results The results to fetch rules meta for. - * @returns {Object} A mapping of ruleIds to rule meta objects. - * @throws {TypeError} When the results object wasn't created from this ESLint instance. - * @throws {TypeError} When a plugin or rule is missing. - */ - getRulesMetaForResults(results) { - - // short-circuit simple case - if (results.length === 0) { - return {}; - } - - const resultRules = new Map(); - const { - configs, - options: { cwd } - } = privateMembers.get(this); - - /* - * We can only accurately return rules meta information for linting results if the - * results were created by this instance. Otherwise, the necessary rules data is - * not available. So if the config array doesn't already exist, just throw an error - * to let the user know we can't do anything here. - */ - if (!configs) { - throw createExtraneousResultsError(); - } - - for (const result of results) { - - /* - * Normalize filename for . - */ - const filePath = result.filePath === "" - ? getPlaceholderPath(cwd) : result.filePath; - const allMessages = result.messages.concat(result.suppressedMessages); - - for (const { ruleId } of allMessages) { - if (!ruleId) { - 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); - - // ignore unknown rules - if (rule) { - resultRules.set(ruleId, rule); - } - } - } - - return createRulesMeta(resultRules); - } - - /** - * Indicates if the given feature flag is enabled for this instance. - * @param {string} flag The feature flag to check. - * @returns {boolean} `true` if the feature flag is enabled, `false` if not. - */ - hasFlag(flag) { - - // note: Linter does validation of the flags - return privateMembers.get(this).linter.hasFlag(flag); - } - - /** - * Executes the current configuration on an array of file and directory names. - * @param {string|string[]} patterns An array of file and directory names. - * @returns {Promise} The results of linting the file patterns given. - */ - async lintFiles(patterns) { - - let normalizedPatterns = patterns; - const { - cacheFilePath, - lintResultCache, - linter, - options: eslintOptions - } = privateMembers.get(this); - - /* - * Special cases: - * 1. `patterns` is an empty string - * 2. `patterns` is an empty array - * - * In both cases, we use the cwd as the directory to lint. - */ - if (patterns === "" || Array.isArray(patterns) && patterns.length === 0) { - - /* - * Special case: If `passOnNoPatterns` is true, then we just exit - * without doing any work. - */ - if (eslintOptions.passOnNoPatterns) { - return []; - } - - normalizedPatterns = ["."]; - } else { - - if (!isNonEmptyString(patterns) && !isArrayOfNonEmptyString(patterns)) { - throw new Error("'patterns' must be a non-empty string or an array of non-empty strings"); - } - - if (typeof patterns === "string") { - normalizedPatterns = [patterns]; - } - } - - debug(`Using file patterns: ${normalizedPatterns}`); - - const configs = await calculateConfigArray(this, eslintOptions); - const { - allowInlineConfig, - cache, - cwd, - fix, - fixTypes, - ruleFilter, - stats, - globInputPaths, - errorOnUnmatchedPattern, - warnIgnored - } = eslintOptions; - const startTime = Date.now(); - const fixTypesSet = fixTypes ? new Set(fixTypes) : null; - - // Delete cache file; should this be done here? - if (!cache && cacheFilePath) { - debug(`Deleting cache file at ${cacheFilePath}`); - - try { - await fs.unlink(cacheFilePath); - } catch (error) { - const errorCode = error && error.code; - - // Ignore errors when no such file exists or file system is read only (and cache file does not exist) - if (errorCode !== "ENOENT" && !(errorCode === "EROFS" && !existsSync(cacheFilePath))) { - throw error; - } - } - } - - const filePaths = await findFiles({ - patterns: normalizedPatterns, - cwd, - globInputPaths, - configs, - errorOnUnmatchedPattern - }); - const controller = new AbortController(); - const retryCodes = new Set(["ENFILE", "EMFILE"]); - const retrier = new Retrier(error => retryCodes.has(error.code)); - - debug(`${filePaths.length} files found in: ${Date.now() - startTime}ms`); - - /* - * Because we need to process multiple files, including reading from disk, - * it is most efficient to start by reading each file via promises so that - * they can be done in parallel. Then, we can lint the returned text. This - * ensures we are waiting the minimum amount of time in between lints. - */ - const results = await Promise.all( - - filePaths.map(filePath => { - - const config = configs.getConfig(filePath); - - /* - * If a filename was entered that cannot be matched - * to a config, then notify the user. - */ - if (!config) { - if (warnIgnored) { - const configStatus = configs.getConfigStatus(filePath); - - return createIgnoreResult(filePath, cwd, configStatus); - } - - return void 0; - } - - // Skip if there is cached result. - if (lintResultCache) { - const cachedResult = - lintResultCache.getCachedLintResults(filePath, config); - - if (cachedResult) { - const hadMessages = - cachedResult.messages && - cachedResult.messages.length > 0; - - if (hadMessages && fix) { - debug(`Reprocessing cached file to allow autofix: ${filePath}`); - } else { - debug(`Skipping file since it hasn't changed: ${filePath}`); - return cachedResult; - } - } - } - - - // set up fixer for fixTypes if necessary - let fixer = fix; - - if (fix && fixTypesSet) { - - // save original value of options.fix in case it's a function - const originalFix = (typeof fix === "function") - ? fix : () => true; - - fixer = message => shouldMessageBeFixed(message, config, fixTypesSet) && originalFix(message); - } - - return retrier.retry(() => fs.readFile(filePath, { encoding: "utf8", signal: controller.signal }) - .then(text => { - - // fail immediately if an error occurred in another file - controller.signal.throwIfAborted(); - - // do the linting - const result = verifyText({ - text, - filePath, - configs, - cwd, - fix: fixer, - allowInlineConfig, - ruleFilter, - stats, - linter - }); - - /* - * Store the lint result in the LintResultCache. - * NOTE: The LintResultCache will remove the file source and any - * other properties that are difficult to serialize, and will - * hydrate those properties back in on future lint runs. - */ - if (lintResultCache) { - lintResultCache.setCachedLintResults(filePath, config, result); - } - - return result; - })) - .catch(error => { - controller.abort(error); - throw error; - }); - }) - ); - - // Persist the cache to disk. - if (lintResultCache) { - lintResultCache.reconcile(); - } - - const finalResults = results.filter(result => !!result); - - return processLintReport(this, { - results: finalResults - }); - } - - /** - * Executes the current configuration on text. - * @param {string} code A string of JavaScript code to lint. - * @param {Object} [options] The options. - * @param {string} [options.filePath] The path to the file of the source code. - * @param {boolean} [options.warnIgnored] When set to true, warn if given filePath is an ignored path. - * @returns {Promise} The results of linting the string of code given. - */ - async lintText(code, options = {}) { - - // Parameter validation - - if (typeof code !== "string") { - throw new Error("'code' must be a string"); - } - - if (typeof options !== "object") { - throw new Error("'options' must be an object, null, or undefined"); - } - - // Options validation - - const { - filePath, - warnIgnored, - ...unknownOptions - } = options || {}; - - const unknownOptionKeys = Object.keys(unknownOptions); - - if (unknownOptionKeys.length > 0) { - throw new Error(`'options' must not include the unknown option(s): ${unknownOptionKeys.join(", ")}`); - } - - if (filePath !== void 0 && !isNonEmptyString(filePath)) { - throw new Error("'options.filePath' must be a non-empty string or undefined"); - } - - if (typeof warnIgnored !== "boolean" && typeof warnIgnored !== "undefined") { - throw new Error("'options.warnIgnored' must be a boolean or undefined"); - } - - // Now we can get down to linting - - const { - linter, - options: eslintOptions - } = privateMembers.get(this); - const configs = await calculateConfigArray(this, eslintOptions); - const { - allowInlineConfig, - cwd, - fix, - warnIgnored: constructorWarnIgnored, - ruleFilter, - stats - } = eslintOptions; - const results = []; - const startTime = Date.now(); - const resolvedFilename = path.resolve(cwd, filePath || "__placeholder__.js"); - - // Clear the last used config arrays. - if (resolvedFilename && await this.isPathIgnored(resolvedFilename)) { - const shouldWarnIgnored = typeof warnIgnored === "boolean" ? warnIgnored : constructorWarnIgnored; - - if (shouldWarnIgnored) { - const configStatus = configs.getConfigStatus(resolvedFilename); - - results.push(createIgnoreResult(resolvedFilename, cwd, configStatus)); - } - } else { - - // Do lint. - results.push(verifyText({ - text: code, - filePath: resolvedFilename.endsWith("__placeholder__.js") ? "" : resolvedFilename, - configs, - cwd, - fix, - allowInlineConfig, - ruleFilter, - stats, - linter - })); - } - - debug(`Linting complete in: ${Date.now() - startTime}ms`); - - return processLintReport(this, { - results - }); - - } - - /** - * Returns the formatter representing the given formatter name. - * @param {string} [name] The name of the formatter to load. - * The following values are allowed: - * - `undefined` ... Load `stylish` builtin formatter. - * - A builtin formatter name ... Load the builtin formatter. - * - A third-party formatter name: - * - `foo` โ†’ `eslint-formatter-foo` - * - `@foo` โ†’ `@foo/eslint-formatter` - * - `@foo/bar` โ†’ `@foo/eslint-formatter-bar` - * - A file path ... Load the file. - * @returns {Promise} A promise resolving to the formatter object. - * This promise will be rejected if the given formatter was not found or not - * a function. - */ - async loadFormatter(name = "stylish") { - if (typeof name !== "string") { - throw new Error("'name' must be a string"); - } - - // replace \ with / for Windows compatibility - const normalizedFormatName = name.replace(/\\/gu, "/"); - const namespace = naming.getNamespaceFromTerm(normalizedFormatName); - - // grab our options - const { cwd } = privateMembers.get(this).options; - - - let formatterPath; - - // if there's a slash, then it's a file (TODO: this check seems dubious for scoped npm packages) - if (!namespace && normalizedFormatName.includes("/")) { - formatterPath = path.resolve(cwd, normalizedFormatName); - } else { - try { - 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, getPlaceholderPath(cwd)); - } catch { - formatterPath = path.resolve(__dirname, "../", "cli-engine", "formatters", `${normalizedFormatName}.js`); - } - } - - let formatter; - - try { - formatter = (await import(pathToFileURL(formatterPath))).default; - } catch (ex) { - - // check for formatters that have been removed - if (removedFormatters.has(name)) { - ex.message = `The ${name} formatter is no longer part of core ESLint. Install it manually with \`npm install -D eslint-formatter-${name}\``; - } else { - ex.message = `There was a problem loading formatter: ${formatterPath}\nError: ${ex.message}`; - } - - throw ex; - } - - - if (typeof formatter !== "function") { - throw new TypeError(`Formatter must be a function, but got a ${typeof formatter}.`); - } - - const eslint = this; - - return { - - /** - * The main formatter method. - * @param {LintResults[]} results The lint results to format. - * @param {ResultsMeta} resultsMeta Warning count and max threshold. - * @returns {string} The formatted lint results. - */ - format(results, resultsMeta) { - let rulesMeta = null; - - results.sort(compareResultsByFilePath); - - return formatter(results, { - ...resultsMeta, - cwd, - get rulesMeta() { - if (!rulesMeta) { - rulesMeta = eslint.getRulesMetaForResults(results); - } - - return rulesMeta; - } - }); - } - }; - } - - /** - * Returns a configuration object for the given file based on the CLI options. - * This is the same logic used by the ESLint CLI executable to determine - * configuration for each file it processes. - * @param {string} filePath The path of the file to retrieve a config object for. - * @returns {Promise} A configuration object for the file - * or `undefined` if there is no configuration data for the object. - */ - async calculateConfigForFile(filePath) { - if (!isNonEmptyString(filePath)) { - throw new Error("'filePath' must be a non-empty string"); - } - const options = privateMembers.get(this).options; - const absolutePath = path.resolve(options.cwd, filePath); - const configs = await calculateConfigArray(this, options); - - return configs.getConfig(absolutePath); - } - - /** - * Finds the config file being used by this instance based on the options - * passed to the constructor. - * @returns {string|undefined} The path to the config file being used or - * `undefined` if no config file is being used. - */ - async findConfigFile() { - const options = privateMembers.get(this).options; - const { configFilePath } = await locateConfigFileToUse(options); - - return configFilePath; - } - - /** - * Checks if a given path is ignored by ESLint. - * @param {string} filePath The path of the file to check. - * @returns {Promise} Whether or not the given path is ignored. - */ - async isPathIgnored(filePath) { - const config = await this.calculateConfigForFile(filePath); - - return config === void 0; - } -} - -/** - * Returns whether flat config should be used. - * @returns {Promise} Whether flat config should be used. - */ -async function shouldUseFlatConfig() { - return (process.env.ESLINT_USE_FLAT_CONFIG !== "false"); -} - -//------------------------------------------------------------------------------ -// Public Interface -//------------------------------------------------------------------------------ - -module.exports = { - ESLint, - shouldUseFlatConfig, - locateConfigFileToUse -}; diff --git a/tools/eslint/node_modules/eslint/lib/eslint/index.js b/tools/eslint/node_modules/eslint/lib/eslint/index.js deleted file mode 100644 index b7c52a4ea701b5..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/eslint/index.js +++ /dev/null @@ -1,9 +0,0 @@ -"use strict"; - -const { ESLint } = require("./eslint"); -const { LegacyESLint } = require("./legacy-eslint"); - -module.exports = { - ESLint, - LegacyESLint -}; diff --git a/tools/eslint/node_modules/eslint/lib/eslint/legacy-eslint.js b/tools/eslint/node_modules/eslint/lib/eslint/legacy-eslint.js deleted file mode 100644 index f282e58746411a..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/eslint/legacy-eslint.js +++ /dev/null @@ -1,742 +0,0 @@ -/** - * @fileoverview Main API Class - * @author Kai Cataldo - * @author Toru Nagashima - */ - -"use strict"; - -//------------------------------------------------------------------------------ -// Requirements -//------------------------------------------------------------------------------ - -const path = require("node:path"); -const fs = require("node:fs"); -const { promisify } = require("node:util"); -const { CLIEngine, getCLIEngineInternalSlots } = require("../cli-engine/cli-engine"); -const BuiltinRules = require("../rules"); -const { - Legacy: { - ConfigOps: { - getRuleSeverity - } - } -} = require("@eslint/eslintrc"); -const { version } = require("../../package.json"); - -//------------------------------------------------------------------------------ -// Typedefs -//------------------------------------------------------------------------------ - -/** @typedef {import("../cli-engine/cli-engine").LintReport} CLIEngineLintReport */ -/** @typedef {import("../shared/types").DeprecatedRuleInfo} DeprecatedRuleInfo */ -/** @typedef {import("../shared/types").ConfigData} ConfigData */ -/** @typedef {import("../shared/types").LintMessage} LintMessage */ -/** @typedef {import("../shared/types").SuppressedLintMessage} SuppressedLintMessage */ -/** @typedef {import("../shared/types").Plugin} Plugin */ -/** @typedef {import("../shared/types").Rule} Rule */ -/** @typedef {import("../shared/types").LintResult} LintResult */ -/** @typedef {import("../shared/types").ResultsMeta} ResultsMeta */ - -/** - * The main formatter object. - * @typedef LoadedFormatter - * @property {(results: LintResult[], resultsMeta: ResultsMeta) => string | Promise} format format function. - */ - -/** - * The options with which to configure the LegacyESLint instance. - * @typedef {Object} LegacyESLintOptions - * @property {boolean} [allowInlineConfig] Enable or disable inline configuration comments. - * @property {ConfigData} [baseConfig] Base config object, extended by all configs used with this instance - * @property {boolean} [cache] Enable result caching. - * @property {string} [cacheLocation] The cache file to use instead of .eslintcache. - * @property {"metadata" | "content"} [cacheStrategy] The strategy used to detect changed files. - * @property {string} [cwd] The value to use for the current working directory. - * @property {boolean} [errorOnUnmatchedPattern] If `false` then `ESLint#lintFiles()` doesn't throw even if no target files found. Defaults to `true`. - * @property {string[]} [extensions] An array of file extensions to check. - * @property {boolean|Function} [fix] Execute in autofix mode. If a function, should return a boolean. - * @property {string[]} [fixTypes] Array of rule types to apply fixes for. - * @property {boolean} [globInputPaths] Set to false to skip glob resolution of input file paths to lint (default: true). If false, each input file paths is assumed to be a non-glob path to an existing file. - * @property {boolean} [ignore] False disables use of .eslintignore. - * @property {string} [ignorePath] The ignore file to use instead of .eslintignore. - * @property {ConfigData} [overrideConfig] Override config object, overrides all configs used with this instance - * @property {string} [overrideConfigFile] The configuration file to use. - * @property {Record|null} [plugins] Preloaded plugins. This is a map-like object, keys are plugin IDs and each value is implementation. - * @property {"error" | "warn" | "off"} [reportUnusedDisableDirectives] the severity to report unused eslint-disable directives. - * @property {string} [resolvePluginsRelativeTo] The folder where plugins should be resolved from, defaulting to the CWD. - * @property {string[]} [rulePaths] An array of directories to load custom rules from. - * @property {boolean} [useEslintrc] False disables looking for .eslintrc.* files. - * @property {boolean} [passOnNoPatterns=false] When set to true, missing patterns cause - * the linting operation to short circuit and not report any failures. - */ - -/** - * A rules metadata object. - * @typedef {Object} RulesMeta - * @property {string} id The plugin ID. - * @property {Object} definition The plugin definition. - */ - -/** - * Private members for the `ESLint` instance. - * @typedef {Object} ESLintPrivateMembers - * @property {CLIEngine} cliEngine The wrapped CLIEngine instance. - * @property {LegacyESLintOptions} options The options used to instantiate the ESLint instance. - */ - -//------------------------------------------------------------------------------ -// Helpers -//------------------------------------------------------------------------------ - -const writeFile = promisify(fs.writeFile); - -/** - * The map with which to store private class members. - * @type {WeakMap} - */ -const privateMembersMap = new WeakMap(); - -/** - * Check if a given value is a non-empty string or not. - * @param {any} value The value to check. - * @returns {boolean} `true` if `value` is a non-empty string. - */ -function isNonEmptyString(value) { - return typeof value === "string" && value.trim() !== ""; -} - -/** - * Check if a given value is an array of non-empty strings or not. - * @param {any} value The value to check. - * @returns {boolean} `true` if `value` is an array of non-empty strings. - */ -function isArrayOfNonEmptyString(value) { - return Array.isArray(value) && value.length && value.every(isNonEmptyString); -} - -/** - * Check if a given value is an empty array or an array of non-empty strings. - * @param {any} value The value to check. - * @returns {boolean} `true` if `value` is an empty array or an array of non-empty - * strings. - */ -function isEmptyArrayOrArrayOfNonEmptyString(value) { - return Array.isArray(value) && value.every(isNonEmptyString); -} - -/** - * Check if a given value is a valid fix type or not. - * @param {any} value The value to check. - * @returns {boolean} `true` if `value` is valid fix type. - */ -function isFixType(value) { - return value === "directive" || value === "problem" || value === "suggestion" || value === "layout"; -} - -/** - * Check if a given value is an array of fix types or not. - * @param {any} value The value to check. - * @returns {boolean} `true` if `value` is an array of fix types. - */ -function isFixTypeArray(value) { - return Array.isArray(value) && value.every(isFixType); -} - -/** - * The error for invalid options. - */ -class ESLintInvalidOptionsError extends Error { - constructor(messages) { - super(`Invalid Options:\n- ${messages.join("\n- ")}`); - this.code = "ESLINT_INVALID_OPTIONS"; - Error.captureStackTrace(this, ESLintInvalidOptionsError); - } -} - -/** - * Validates and normalizes options for the wrapped CLIEngine instance. - * @param {LegacyESLintOptions} options The options to process. - * @throws {ESLintInvalidOptionsError} If of any of a variety of type errors. - * @returns {LegacyESLintOptions} The normalized options. - */ -function processOptions({ - allowInlineConfig = true, // โ† we cannot use `overrideConfig.noInlineConfig` instead because `allowInlineConfig` has side-effect that suppress warnings that show inline configs are ignored. - baseConfig = null, - cache = false, - cacheLocation = ".eslintcache", - cacheStrategy = "metadata", - cwd = process.cwd(), - errorOnUnmatchedPattern = true, - extensions = null, // โ† should be null by default because if it's an array then it suppresses RFC20 feature. - fix = false, - fixTypes = null, // โ† should be null by default because if it's an array then it suppresses rules that don't have the `meta.type` property. - flags, /* eslint-disable-line no-unused-vars -- leaving for compatibility with ESLint#hasFlag */ - globInputPaths = true, - ignore = true, - ignorePath = null, // โ† should be null by default because if it's a string then it may throw ENOENT. - overrideConfig = null, - overrideConfigFile = null, - plugins = {}, - reportUnusedDisableDirectives = null, // โ† should be null by default because if it's a string then it overrides the 'reportUnusedDisableDirectives' setting in config files. And we cannot use `overrideConfig.reportUnusedDisableDirectives` instead because we cannot configure the `error` severity with that. - resolvePluginsRelativeTo = null, // โ† should be null by default because if it's a string then it suppresses RFC47 feature. - rulePaths = [], - useEslintrc = true, - passOnNoPatterns = false, - ...unknownOptions -}) { - const errors = []; - const unknownOptionKeys = Object.keys(unknownOptions); - - if (unknownOptionKeys.length >= 1) { - errors.push(`Unknown options: ${unknownOptionKeys.join(", ")}`); - if (unknownOptionKeys.includes("cacheFile")) { - errors.push("'cacheFile' has been removed. Please use the 'cacheLocation' option instead."); - } - if (unknownOptionKeys.includes("configFile")) { - errors.push("'configFile' has been removed. Please use the 'overrideConfigFile' option instead."); - } - if (unknownOptionKeys.includes("envs")) { - errors.push("'envs' has been removed. Please use the 'overrideConfig.env' option instead."); - } - if (unknownOptionKeys.includes("globals")) { - errors.push("'globals' has been removed. Please use the 'overrideConfig.globals' option instead."); - } - if (unknownOptionKeys.includes("ignorePattern")) { - errors.push("'ignorePattern' has been removed. Please use the 'overrideConfig.ignorePatterns' option instead."); - } - if (unknownOptionKeys.includes("parser")) { - errors.push("'parser' has been removed. Please use the 'overrideConfig.parser' option instead."); - } - if (unknownOptionKeys.includes("parserOptions")) { - errors.push("'parserOptions' has been removed. Please use the 'overrideConfig.parserOptions' option instead."); - } - if (unknownOptionKeys.includes("rules")) { - errors.push("'rules' has been removed. Please use the 'overrideConfig.rules' option instead."); - } - } - if (typeof allowInlineConfig !== "boolean") { - errors.push("'allowInlineConfig' must be a boolean."); - } - if (typeof baseConfig !== "object") { - errors.push("'baseConfig' must be an object or null."); - } - if (typeof cache !== "boolean") { - errors.push("'cache' must be a boolean."); - } - if (!isNonEmptyString(cacheLocation)) { - errors.push("'cacheLocation' must be a non-empty string."); - } - if ( - cacheStrategy !== "metadata" && - cacheStrategy !== "content" - ) { - errors.push("'cacheStrategy' must be any of \"metadata\", \"content\"."); - } - if (!isNonEmptyString(cwd) || !path.isAbsolute(cwd)) { - errors.push("'cwd' must be an absolute path."); - } - if (typeof errorOnUnmatchedPattern !== "boolean") { - errors.push("'errorOnUnmatchedPattern' must be a boolean."); - } - if (!isEmptyArrayOrArrayOfNonEmptyString(extensions) && extensions !== null) { - errors.push("'extensions' must be an array of non-empty strings or null."); - } - if (typeof fix !== "boolean" && typeof fix !== "function") { - errors.push("'fix' must be a boolean or a function."); - } - if (fixTypes !== null && !isFixTypeArray(fixTypes)) { - errors.push("'fixTypes' must be an array of any of \"directive\", \"problem\", \"suggestion\", and \"layout\"."); - } - if (typeof globInputPaths !== "boolean") { - errors.push("'globInputPaths' must be a boolean."); - } - if (typeof ignore !== "boolean") { - errors.push("'ignore' must be a boolean."); - } - if (!isNonEmptyString(ignorePath) && ignorePath !== null) { - errors.push("'ignorePath' must be a non-empty string or null."); - } - if (typeof overrideConfig !== "object") { - errors.push("'overrideConfig' must be an object or null."); - } - if (!isNonEmptyString(overrideConfigFile) && overrideConfigFile !== null) { - errors.push("'overrideConfigFile' must be a non-empty string or null."); - } - if (typeof plugins !== "object") { - errors.push("'plugins' must be an object or null."); - } else if (plugins !== null && Object.keys(plugins).includes("")) { - errors.push("'plugins' must not include an empty string."); - } - if (Array.isArray(plugins)) { - errors.push("'plugins' doesn't add plugins to configuration to load. Please use the 'overrideConfig.plugins' option instead."); - } - if ( - reportUnusedDisableDirectives !== "error" && - reportUnusedDisableDirectives !== "warn" && - reportUnusedDisableDirectives !== "off" && - reportUnusedDisableDirectives !== null - ) { - errors.push("'reportUnusedDisableDirectives' must be any of \"error\", \"warn\", \"off\", and null."); - } - if ( - !isNonEmptyString(resolvePluginsRelativeTo) && - resolvePluginsRelativeTo !== null - ) { - errors.push("'resolvePluginsRelativeTo' must be a non-empty string or null."); - } - if (!isEmptyArrayOrArrayOfNonEmptyString(rulePaths)) { - errors.push("'rulePaths' must be an array of non-empty strings."); - } - if (typeof useEslintrc !== "boolean") { - errors.push("'useEslintrc' must be a boolean."); - } - if (typeof passOnNoPatterns !== "boolean") { - errors.push("'passOnNoPatterns' must be a boolean."); - } - - if (errors.length > 0) { - throw new ESLintInvalidOptionsError(errors); - } - - return { - allowInlineConfig, - baseConfig, - cache, - cacheLocation, - cacheStrategy, - configFile: overrideConfigFile, - cwd: path.normalize(cwd), - errorOnUnmatchedPattern, - extensions, - fix, - fixTypes, - flags: [], // LegacyESLint does not support flags, so just ignore them. - globInputPaths, - ignore, - ignorePath, - reportUnusedDisableDirectives, - resolvePluginsRelativeTo, - rulePaths, - useEslintrc, - passOnNoPatterns - }; -} - -/** - * Check if a value has one or more properties and that value is not undefined. - * @param {any} obj The value to check. - * @returns {boolean} `true` if `obj` has one or more properties that that value is not undefined. - */ -function hasDefinedProperty(obj) { - if (typeof obj === "object" && obj !== null) { - for (const key in obj) { - if (typeof obj[key] !== "undefined") { - return true; - } - } - } - return false; -} - -/** - * Create rulesMeta object. - * @param {Map} rules a map of rules from which to generate the object. - * @returns {Object} metadata for all enabled rules. - */ -function createRulesMeta(rules) { - return Array.from(rules).reduce((retVal, [id, rule]) => { - retVal[id] = rule.meta; - return retVal; - }, {}); -} - -/** @type {WeakMap} */ -const usedDeprecatedRulesCache = new WeakMap(); - -/** - * Create used deprecated rule list. - * @param {CLIEngine} cliEngine The CLIEngine instance. - * @param {string} maybeFilePath The absolute path to a lint target file or `""`. - * @returns {DeprecatedRuleInfo[]} The used deprecated rule list. - */ -function getOrFindUsedDeprecatedRules(cliEngine, maybeFilePath) { - const { - configArrayFactory, - options: { cwd } - } = getCLIEngineInternalSlots(cliEngine); - const filePath = path.isAbsolute(maybeFilePath) - ? maybeFilePath - : path.join(cwd, "__placeholder__.js"); - const configArray = configArrayFactory.getConfigArrayForFile(filePath); - const config = configArray.extractConfig(filePath); - - // Most files use the same config, so cache it. - if (!usedDeprecatedRulesCache.has(config)) { - const pluginRules = configArray.pluginRules; - const retv = []; - - for (const [ruleId, ruleConf] of Object.entries(config.rules)) { - if (getRuleSeverity(ruleConf) === 0) { - continue; - } - const rule = pluginRules.get(ruleId) || BuiltinRules.get(ruleId); - const meta = rule && rule.meta; - - if (meta && meta.deprecated) { - retv.push({ ruleId, replacedBy: meta.replacedBy || [] }); - } - } - - usedDeprecatedRulesCache.set(config, Object.freeze(retv)); - } - - return usedDeprecatedRulesCache.get(config); -} - -/** - * Processes the linting results generated by a CLIEngine linting report to - * match the ESLint class's API. - * @param {CLIEngine} cliEngine The CLIEngine instance. - * @param {CLIEngineLintReport} report The CLIEngine linting report to process. - * @returns {LintResult[]} The processed linting results. - */ -function processCLIEngineLintReport(cliEngine, { results }) { - const descriptor = { - configurable: true, - enumerable: true, - get() { - return getOrFindUsedDeprecatedRules(cliEngine, this.filePath); - } - }; - - for (const result of results) { - Object.defineProperty(result, "usedDeprecatedRules", descriptor); - } - - return results; -} - -/** - * An Array.prototype.sort() compatible compare function to order results by their file path. - * @param {LintResult} a The first lint result. - * @param {LintResult} b The second lint result. - * @returns {number} An integer representing the order in which the two results should occur. - */ -function compareResultsByFilePath(a, b) { - if (a.filePath < b.filePath) { - return -1; - } - - if (a.filePath > b.filePath) { - return 1; - } - - return 0; -} - -/** - * Main API. - */ -class LegacyESLint { - - /** - * The type of configuration used by this class. - * @type {string} - */ - static configType = "eslintrc"; - - /** - * Creates a new instance of the main ESLint API. - * @param {LegacyESLintOptions} options The options for this instance. - */ - constructor(options = {}) { - const processedOptions = processOptions(options); - const cliEngine = new CLIEngine(processedOptions, { preloadedPlugins: options.plugins }); - const { - configArrayFactory, - lastConfigArrays - } = getCLIEngineInternalSlots(cliEngine); - let updated = false; - - /* - * Address `overrideConfig` to set override config. - * Operate the `configArrayFactory` internal slot directly because this - * functionality doesn't exist as the public API of CLIEngine. - */ - if (hasDefinedProperty(options.overrideConfig)) { - configArrayFactory.setOverrideConfig(options.overrideConfig); - updated = true; - } - - // Update caches. - if (updated) { - configArrayFactory.clearCache(); - lastConfigArrays[0] = configArrayFactory.getConfigArrayForFile(); - } - - // Initialize private properties. - privateMembersMap.set(this, { - cliEngine, - options: processedOptions - }); - } - - /** - * The version text. - * @type {string} - */ - static get version() { - return version; - } - - /** - * Outputs fixes from the given results to files. - * @param {LintResult[]} results The lint results. - * @returns {Promise} Returns a promise that is used to track side effects. - */ - static async outputFixes(results) { - if (!Array.isArray(results)) { - throw new Error("'results' must be an array"); - } - - await Promise.all( - results - .filter(result => { - if (typeof result !== "object" || result === null) { - throw new Error("'results' must include only objects"); - } - return ( - typeof result.output === "string" && - path.isAbsolute(result.filePath) - ); - }) - .map(r => writeFile(r.filePath, r.output)) - ); - } - - /** - * Returns results that only contains errors. - * @param {LintResult[]} results The results to filter. - * @returns {LintResult[]} The filtered results. - */ - static getErrorResults(results) { - return CLIEngine.getErrorResults(results); - } - - /** - * Returns meta objects for each rule represented in the lint results. - * @param {LintResult[]} results The results to fetch rules meta for. - * @returns {Object} A mapping of ruleIds to rule meta objects. - */ - getRulesMetaForResults(results) { - - const resultRuleIds = new Set(); - - // first gather all ruleIds from all results - - for (const result of results) { - for (const { ruleId } of result.messages) { - resultRuleIds.add(ruleId); - } - for (const { ruleId } of result.suppressedMessages) { - resultRuleIds.add(ruleId); - } - } - - // create a map of all rules in the results - - const { cliEngine } = privateMembersMap.get(this); - const rules = cliEngine.getRules(); - const resultRules = new Map(); - - for (const [ruleId, rule] of rules) { - if (resultRuleIds.has(ruleId)) { - resultRules.set(ruleId, rule); - } - } - - return createRulesMeta(resultRules); - - } - - /* eslint-disable no-unused-vars, class-methods-use-this -- leaving for compatibility with ESLint#hasFlag */ - /** - * Indicates if the given feature flag is enabled for this instance. For this - * class, this always returns `false` because it does not support feature flags. - * @param {string} flag The feature flag to check. - * @returns {boolean} Always false. - */ - hasFlag(flag) { - return false; - } - /* eslint-enable no-unused-vars, class-methods-use-this -- reenable rules for the rest of the file */ - - /** - * Executes the current configuration on an array of file and directory names. - * @param {string[]} patterns An array of file and directory names. - * @returns {Promise} The results of linting the file patterns given. - */ - async lintFiles(patterns) { - const { cliEngine, options } = privateMembersMap.get(this); - - if (options.passOnNoPatterns && (patterns === "" || (Array.isArray(patterns) && patterns.length === 0))) { - return []; - } - - if (!isNonEmptyString(patterns) && !isArrayOfNonEmptyString(patterns)) { - throw new Error("'patterns' must be a non-empty string or an array of non-empty strings"); - } - - return processCLIEngineLintReport( - cliEngine, - cliEngine.executeOnFiles(patterns) - ); - } - - /** - * Executes the current configuration on text. - * @param {string} code A string of JavaScript code to lint. - * @param {Object} [options] The options. - * @param {string} [options.filePath] The path to the file of the source code. - * @param {boolean} [options.warnIgnored] When set to true, warn if given filePath is an ignored path. - * @returns {Promise} The results of linting the string of code given. - */ - async lintText(code, options = {}) { - if (typeof code !== "string") { - throw new Error("'code' must be a string"); - } - if (typeof options !== "object") { - throw new Error("'options' must be an object, null, or undefined"); - } - const { - filePath, - warnIgnored = false, - ...unknownOptions - } = options || {}; - - const unknownOptionKeys = Object.keys(unknownOptions); - - if (unknownOptionKeys.length > 0) { - throw new Error(`'options' must not include the unknown option(s): ${unknownOptionKeys.join(", ")}`); - } - - if (filePath !== void 0 && !isNonEmptyString(filePath)) { - throw new Error("'options.filePath' must be a non-empty string or undefined"); - } - if (typeof warnIgnored !== "boolean") { - throw new Error("'options.warnIgnored' must be a boolean or undefined"); - } - - const { cliEngine } = privateMembersMap.get(this); - - return processCLIEngineLintReport( - cliEngine, - cliEngine.executeOnText(code, filePath, warnIgnored) - ); - } - - /** - * Returns the formatter representing the given formatter name. - * @param {string} [name] The name of the formatter to load. - * The following values are allowed: - * - `undefined` ... Load `stylish` builtin formatter. - * - A builtin formatter name ... Load the builtin formatter. - * - A third-party formatter name: - * - `foo` โ†’ `eslint-formatter-foo` - * - `@foo` โ†’ `@foo/eslint-formatter` - * - `@foo/bar` โ†’ `@foo/eslint-formatter-bar` - * - A file path ... Load the file. - * @returns {Promise} A promise resolving to the formatter object. - * This promise will be rejected if the given formatter was not found or not - * a function. - */ - async loadFormatter(name = "stylish") { - if (typeof name !== "string") { - throw new Error("'name' must be a string"); - } - - const { cliEngine, options } = privateMembersMap.get(this); - const formatter = cliEngine.getFormatter(name); - - if (typeof formatter !== "function") { - throw new Error(`Formatter must be a function, but got a ${typeof formatter}.`); - } - - return { - - /** - * The main formatter method. - * @param {LintResult[]} results The lint results to format. - * @param {ResultsMeta} resultsMeta Warning count and max threshold. - * @returns {string | Promise} The formatted lint results. - */ - format(results, resultsMeta) { - let rulesMeta = null; - - results.sort(compareResultsByFilePath); - - return formatter(results, { - ...resultsMeta, - get cwd() { - return options.cwd; - }, - get rulesMeta() { - if (!rulesMeta) { - rulesMeta = createRulesMeta(cliEngine.getRules()); - } - - return rulesMeta; - } - }); - } - }; - } - - /** - * Returns a configuration object for the given file based on the CLI options. - * This is the same logic used by the ESLint CLI executable to determine - * configuration for each file it processes. - * @param {string} filePath The path of the file to retrieve a config object for. - * @returns {Promise} A configuration object for the file. - */ - async calculateConfigForFile(filePath) { - if (!isNonEmptyString(filePath)) { - throw new Error("'filePath' must be a non-empty string"); - } - const { cliEngine } = privateMembersMap.get(this); - - return cliEngine.getConfigForFile(filePath); - } - - /** - * Checks if a given path is ignored by ESLint. - * @param {string} filePath The path of the file to check. - * @returns {Promise} Whether or not the given path is ignored. - */ - async isPathIgnored(filePath) { - if (!isNonEmptyString(filePath)) { - throw new Error("'filePath' must be a non-empty string"); - } - const { cliEngine } = privateMembersMap.get(this); - - return cliEngine.isPathIgnored(filePath); - } -} - -//------------------------------------------------------------------------------ -// Public Interface -//------------------------------------------------------------------------------ - -module.exports = { - LegacyESLint, - - /** - * Get the private class members of a given ESLint instance for tests. - * @param {ESLint} instance The ESLint instance to get. - * @returns {ESLintPrivateMembers} The instance's private class members. - */ - getESLintPrivateMembers(instance) { - return privateMembersMap.get(instance); - } -}; diff --git a/tools/eslint/node_modules/eslint/lib/languages/js/index.js b/tools/eslint/node_modules/eslint/lib/languages/js/index.js deleted file mode 100644 index f8c3ae6c36bc10..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/languages/js/index.js +++ /dev/null @@ -1,252 +0,0 @@ -/** - * @fileoverview JavaScript Language Object - * @author Nicholas C. Zakas - */ - -"use strict"; - -//----------------------------------------------------------------------------- -// Requirements -//----------------------------------------------------------------------------- - -const { SourceCode } = require("./source-code"); -const createDebug = require("debug"); -const astUtils = require("../../shared/ast-utils"); -const eslintScope = require("eslint-scope"); -const evk = require("eslint-visitor-keys"); -const { validateLanguageOptions } = require("./validate-language-options"); - -//----------------------------------------------------------------------------- -// Type Definitions -//----------------------------------------------------------------------------- - -/** @typedef {import("@eslint/core").File} File */ -/** @typedef {import("@eslint/core").Language} Language */ -/** @typedef {import("@eslint/core").OkParseResult} OkParseResult */ - -//----------------------------------------------------------------------------- -// Helpers -//----------------------------------------------------------------------------- - -const debug = createDebug("eslint:languages:js"); -const DEFAULT_ECMA_VERSION = 5; - -/** - * Analyze scope of the given AST. - * @param {ASTNode} ast The `Program` node to analyze. - * @param {LanguageOptions} languageOptions The parser options. - * @param {Record} visitorKeys The visitor keys. - * @returns {ScopeManager} The analysis result. - */ -function analyzeScope(ast, languageOptions, visitorKeys) { - const parserOptions = languageOptions.parserOptions; - const ecmaFeatures = parserOptions.ecmaFeatures || {}; - const ecmaVersion = languageOptions.ecmaVersion || DEFAULT_ECMA_VERSION; - - return eslintScope.analyze(ast, { - ignoreEval: true, - nodejsScope: ecmaFeatures.globalReturn, - impliedStrict: ecmaFeatures.impliedStrict, - ecmaVersion: typeof ecmaVersion === "number" ? ecmaVersion : 6, - sourceType: languageOptions.sourceType || "script", - childVisitorKeys: visitorKeys || evk.KEYS, - fallback: evk.getKeys - }); -} - -//----------------------------------------------------------------------------- -// Exports -//----------------------------------------------------------------------------- - -/** - * @type {Language} - */ -module.exports = { - - fileType: "text", - lineStart: 1, - columnStart: 0, - nodeTypeKey: "type", - visitorKeys: evk.KEYS, - - validateLanguageOptions, - - /** - * Determines if a given node matches a given selector class. - * @param {string} className The class name to check. - * @param {ASTNode} node The node to check. - * @param {Array} ancestry The ancestry of the node. - * @returns {boolean} True if there's a match, false if not. - * @throws {Error} When an unknown class name is passed. - */ - matchesSelectorClass(className, node, ancestry) { - - /* - * Copyright (c) 2013, Joel Feenstra - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the ESQuery nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL JOEL FEENSTRA BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - - switch (className.toLowerCase()) { - - case "statement": - if (node.type.slice(-9) === "Statement") { - return true; - } - - // fallthrough: interface Declaration <: Statement { } - - case "declaration": - return node.type.slice(-11) === "Declaration"; - - case "pattern": - if (node.type.slice(-7) === "Pattern") { - return true; - } - - // fallthrough: interface Expression <: Node, Pattern { } - - case "expression": - return node.type.slice(-10) === "Expression" || - node.type.slice(-7) === "Literal" || - ( - node.type === "Identifier" && - (ancestry.length === 0 || ancestry[0].type !== "MetaProperty") - ) || - node.type === "MetaProperty"; - - case "function": - return node.type === "FunctionDeclaration" || - node.type === "FunctionExpression" || - node.type === "ArrowFunctionExpression"; - - default: - throw new Error(`Unknown class name: ${className}`); - } - }, - - /** - * Parses the given file into an AST. - * @param {File} file The virtual file to parse. - * @param {Object} options Additional options passed from ESLint. - * @param {LanguageOptions} options.languageOptions The language options. - * @returns {Object} The result of parsing. - */ - parse(file, { languageOptions }) { - - // Note: BOM already removed - const { body: text, path: filePath } = file; - const textToParse = text.replace(astUtils.shebangPattern, (match, captured) => `//${captured}`); - const { ecmaVersion, sourceType, parser } = languageOptions; - const parserOptions = Object.assign( - { ecmaVersion, sourceType }, - languageOptions.parserOptions, - { - loc: true, - range: true, - raw: true, - tokens: true, - comment: true, - eslintVisitorKeys: true, - eslintScopeManager: true, - filePath - } - ); - - /* - * Check for parsing errors first. If there's a parsing error, nothing - * else can happen. However, a parsing error does not throw an error - * from this method - it's just considered a fatal error message, a - * problem that ESLint identified just like any other. - */ - try { - debug("Parsing:", filePath); - const parseResult = (typeof parser.parseForESLint === "function") - ? parser.parseForESLint(textToParse, parserOptions) - : { ast: parser.parse(textToParse, parserOptions) }; - - debug("Parsing successful:", filePath); - - const { - ast, - services: parserServices = {}, - visitorKeys = evk.KEYS, - scopeManager - } = parseResult; - - return { - ok: true, - ast, - parserServices, - visitorKeys, - scopeManager - }; - } catch (ex) { - - // If the message includes a leading line number, strip it: - const message = ex.message.replace(/^line \d+:/iu, "").trim(); - - debug("%s\n%s", message, ex.stack); - - return { - ok: false, - errors: [{ - message, - line: ex.lineNumber, - column: ex.column - }] - }; - } - - }, - - /** - * Creates a new `SourceCode` object from the given information. - * @param {File} file The virtual file to create a `SourceCode` object from. - * @param {OkParseResult} parseResult The result returned from `parse()`. - * @param {Object} options Additional options passed from ESLint. - * @param {LanguageOptions} options.languageOptions The language options. - * @returns {SourceCode} The new `SourceCode` object. - */ - createSourceCode(file, parseResult, { languageOptions }) { - - const { body: text, path: filePath, bom: hasBOM } = file; - const { ast, parserServices, visitorKeys } = parseResult; - - debug("Scope analysis:", filePath); - const scopeManager = parseResult.scopeManager || analyzeScope(ast, languageOptions, visitorKeys); - - debug("Scope analysis successful:", filePath); - - return new SourceCode({ - text, - ast, - hasBOM, - parserServices, - scopeManager, - visitorKeys - }); - } - -}; diff --git a/tools/eslint/node_modules/eslint/lib/languages/js/source-code/index.js b/tools/eslint/node_modules/eslint/lib/languages/js/source-code/index.js deleted file mode 100644 index 1ecfbe470aa7cd..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/languages/js/source-code/index.js +++ /dev/null @@ -1,7 +0,0 @@ -"use strict"; - -const SourceCode = require("./source-code"); - -module.exports = { - SourceCode -}; diff --git a/tools/eslint/node_modules/eslint/lib/languages/js/source-code/source-code.js b/tools/eslint/node_modules/eslint/lib/languages/js/source-code/source-code.js deleted file mode 100644 index 7baf2ea26c864f..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/languages/js/source-code/source-code.js +++ /dev/null @@ -1,1299 +0,0 @@ -/** - * @fileoverview Abstraction of JavaScript source code. - * @author Nicholas C. Zakas - */ -"use strict"; - -//------------------------------------------------------------------------------ -// Requirements -//------------------------------------------------------------------------------ - -const - { isCommentToken } = require("@eslint-community/eslint-utils"), - TokenStore = require("./token-store"), - astUtils = require("../../../shared/ast-utils"), - Traverser = require("../../../shared/traverser"), - globals = require("../../../../conf/globals"), - { - directivesPattern - } = require("../../../shared/directives"), - - CodePathAnalyzer = require("../../../linter/code-path-analysis/code-path-analyzer"), - createEmitter = require("../../../linter/safe-emitter"), - ConfigCommentParser = require("../../../linter/config-comment-parser"), - - eslintScope = require("eslint-scope"); - -//------------------------------------------------------------------------------ -// Type Definitions -//------------------------------------------------------------------------------ - -/** @typedef {import("eslint-scope").Variable} Variable */ -/** @typedef {import("eslint-scope").Scope} Scope */ -/** @typedef {import("@eslint/core").SourceCode} ISourceCode */ -/** @typedef {import("@eslint/core").Directive} IDirective */ -/** @typedef {import("@eslint/core").TraversalStep} ITraversalStep */ - -//------------------------------------------------------------------------------ -// Private -//------------------------------------------------------------------------------ - -const commentParser = new ConfigCommentParser(); - -const CODE_PATH_EVENTS = [ - "onCodePathStart", - "onCodePathEnd", - "onCodePathSegmentStart", - "onCodePathSegmentEnd", - "onCodePathSegmentLoop", - "onUnreachableCodePathSegmentStart", - "onUnreachableCodePathSegmentEnd" -]; - -/** - * Validates that the given AST has the required information. - * @param {ASTNode} ast The Program node of the AST to check. - * @throws {Error} If the AST doesn't contain the correct information. - * @returns {void} - * @private - */ -function validate(ast) { - if (!ast.tokens) { - throw new Error("AST is missing the tokens array."); - } - - if (!ast.comments) { - throw new Error("AST is missing the comments array."); - } - - if (!ast.loc) { - throw new Error("AST is missing location information."); - } - - if (!ast.range) { - throw new Error("AST is missing range information"); - } -} - -/** - * Retrieves globals for the given ecmaVersion. - * @param {number} ecmaVersion The version to retrieve globals for. - * @returns {Object} The globals for the given ecmaVersion. - */ -function getGlobalsForEcmaVersion(ecmaVersion) { - - switch (ecmaVersion) { - case 3: - return globals.es3; - - case 5: - return globals.es5; - - default: - if (ecmaVersion < 2015) { - return globals[`es${ecmaVersion + 2009}`]; - } - - return globals[`es${ecmaVersion}`]; - } -} - -/** - * Check to see if its a ES6 export declaration. - * @param {ASTNode} astNode An AST node. - * @returns {boolean} whether the given node represents an export declaration. - * @private - */ -function looksLikeExport(astNode) { - return astNode.type === "ExportDefaultDeclaration" || astNode.type === "ExportNamedDeclaration" || - astNode.type === "ExportAllDeclaration" || astNode.type === "ExportSpecifier"; -} - -/** - * Merges two sorted lists into a larger sorted list in O(n) time. - * @param {Token[]} tokens The list of tokens. - * @param {Token[]} comments The list of comments. - * @returns {Token[]} A sorted list of tokens and comments. - * @private - */ -function sortedMerge(tokens, comments) { - const result = []; - let tokenIndex = 0; - let commentIndex = 0; - - while (tokenIndex < tokens.length || commentIndex < comments.length) { - if (commentIndex >= comments.length || tokenIndex < tokens.length && tokens[tokenIndex].range[0] < comments[commentIndex].range[0]) { - result.push(tokens[tokenIndex++]); - } else { - result.push(comments[commentIndex++]); - } - } - - return result; -} - -/** - * Normalizes a value for a global in a config - * @param {(boolean|string|null)} configuredValue The value given for a global in configuration or in - * a global directive comment - * @returns {("readable"|"writeable"|"off")} The value normalized as a string - * @throws Error if global value is invalid - */ -function normalizeConfigGlobal(configuredValue) { - switch (configuredValue) { - case "off": - return "off"; - - case true: - case "true": - case "writeable": - case "writable": - return "writable"; - - case null: - case false: - case "false": - case "readable": - case "readonly": - return "readonly"; - - default: - throw new Error(`'${configuredValue}' is not a valid configuration for a global (use 'readonly', 'writable', or 'off')`); - } -} - -/** - * Determines if two nodes or tokens overlap. - * @param {ASTNode|Token} first The first node or token to check. - * @param {ASTNode|Token} second The second node or token to check. - * @returns {boolean} True if the two nodes or tokens overlap. - * @private - */ -function nodesOrTokensOverlap(first, second) { - return (first.range[0] <= second.range[0] && first.range[1] >= second.range[0]) || - (second.range[0] <= first.range[0] && second.range[1] >= first.range[0]); -} - -/** - * Determines if two nodes or tokens have at least one whitespace character - * between them. Order does not matter. Returns false if the given nodes or - * tokens overlap. - * @param {SourceCode} sourceCode The source code object. - * @param {ASTNode|Token} first The first node or token to check between. - * @param {ASTNode|Token} second The second node or token to check between. - * @param {boolean} checkInsideOfJSXText If `true` is present, check inside of JSXText tokens for backward compatibility. - * @returns {boolean} True if there is a whitespace character between - * any of the tokens found between the two given nodes or tokens. - * @public - */ -function isSpaceBetween(sourceCode, first, second, checkInsideOfJSXText) { - if (nodesOrTokensOverlap(first, second)) { - return false; - } - - const [startingNodeOrToken, endingNodeOrToken] = first.range[1] <= second.range[0] - ? [first, second] - : [second, first]; - const firstToken = sourceCode.getLastToken(startingNodeOrToken) || startingNodeOrToken; - const finalToken = sourceCode.getFirstToken(endingNodeOrToken) || endingNodeOrToken; - let currentToken = firstToken; - - while (currentToken !== finalToken) { - const nextToken = sourceCode.getTokenAfter(currentToken, { includeComments: true }); - - if ( - currentToken.range[1] !== nextToken.range[0] || - - /* - * For backward compatibility, check spaces in JSXText. - * https://github.com/eslint/eslint/issues/12614 - */ - ( - checkInsideOfJSXText && - nextToken !== finalToken && - nextToken.type === "JSXText" && - /\s/u.test(nextToken.value) - ) - ) { - return true; - } - - currentToken = nextToken; - } - - return false; -} - -//----------------------------------------------------------------------------- -// Directive Comments -//----------------------------------------------------------------------------- - -/** - * Ensures that variables representing built-in properties of the Global Object, - * and any globals declared by special block comments, are present in the global - * scope. - * @param {Scope} globalScope The global scope. - * @param {Object|undefined} configGlobals The globals declared in configuration - * @param {Object|undefined} inlineGlobals The globals declared in the source code - * @returns {void} - */ -function addDeclaredGlobals(globalScope, configGlobals = {}, inlineGlobals = {}) { - - // Define configured global variables. - for (const id of new Set([...Object.keys(configGlobals), ...Object.keys(inlineGlobals)])) { - - /* - * `normalizeConfigGlobal` will throw an error if a configured global value is invalid. However, these errors would - * typically be caught when validating a config anyway (validity for inline global comments is checked separately). - */ - const configValue = configGlobals[id] === void 0 ? void 0 : normalizeConfigGlobal(configGlobals[id]); - const commentValue = inlineGlobals[id] && inlineGlobals[id].value; - const value = commentValue || configValue; - const sourceComments = inlineGlobals[id] && inlineGlobals[id].comments; - - if (value === "off") { - continue; - } - - let variable = globalScope.set.get(id); - - if (!variable) { - variable = new eslintScope.Variable(id, globalScope); - - globalScope.variables.push(variable); - globalScope.set.set(id, variable); - } - - variable.eslintImplicitGlobalSetting = configValue; - variable.eslintExplicitGlobal = sourceComments !== void 0; - variable.eslintExplicitGlobalComments = sourceComments; - variable.writeable = (value === "writable"); - } - - /* - * "through" contains all references which definitions cannot be found. - * Since we augment the global scope using configuration, we need to update - * references and remove the ones that were added by configuration. - */ - globalScope.through = globalScope.through.filter(reference => { - const name = reference.identifier.name; - const variable = globalScope.set.get(name); - - if (variable) { - - /* - * Links the variable and the reference. - * And this reference is removed from `Scope#through`. - */ - reference.resolved = variable; - variable.references.push(reference); - - return false; - } - - return true; - }); -} - -/** - * Sets the given variable names as exported so they won't be triggered by - * the `no-unused-vars` rule. - * @param {eslint.Scope} globalScope The global scope to define exports in. - * @param {Record} variables An object whose keys are the variable - * names to export. - * @returns {void} - */ -function markExportedVariables(globalScope, variables) { - - Object.keys(variables).forEach(name => { - const variable = globalScope.set.get(name); - - if (variable) { - variable.eslintUsed = true; - variable.eslintExported = true; - } - }); - -} - -const STEP_KIND = { - visit: 1, - call: 2 -}; - -/** - * A class to represent a step in the traversal process. - */ -class TraversalStep { - - /** - * The type of the step. - * @type {string} - */ - type; - - /** - * The kind of the step. Represents the same data as the `type` property - * but it's a number for performance. - * @type {number} - */ - kind; - - /** - * The target of the step. - * @type {ASTNode|string} - */ - target; - - /** - * The phase of the step. - * @type {number|undefined} - */ - phase; - - /** - * The arguments of the step. - * @type {Array} - */ - args; - - /** - * Creates a new instance. - * @param {Object} options The options for the step. - * @param {string} options.type The type of the step. - * @param {ASTNode|string} options.target The target of the step. - * @param {number|undefined} [options.phase] The phase of the step. - * @param {Array} options.args The arguments of the step. - * @returns {void} - */ - constructor({ type, target, phase, args }) { - this.type = type; - this.kind = STEP_KIND[type]; - this.target = target; - this.phase = phase; - this.args = args; - } -} - -/** - * A class to represent a directive comment. - * @implements {IDirective} - */ -class Directive { - - /** - * The type of directive. - * @type {"disable"|"enable"|"disable-next-line"|"disable-line"} - * @readonly - */ - type; - - /** - * The node representing the directive. - * @type {ASTNode|Comment} - * @readonly - */ - node; - - /** - * Everything after the "eslint-disable" portion of the directive, - * but before the "--" that indicates the justification. - * @type {string} - * @readonly - */ - value; - - /** - * The justification for the directive. - * @type {string} - * @readonly - */ - justification; - - /** - * Creates a new instance. - * @param {Object} options The options for the directive. - * @param {"disable"|"enable"|"disable-next-line"|"disable-line"} options.type The type of directive. - * @param {ASTNode|Comment} options.node The node representing the directive. - * @param {string} options.value The value of the directive. - * @param {string} options.justification The justification for the directive. - */ - constructor({ type, node, value, justification }) { - this.type = type; - this.node = node; - this.value = value; - this.justification = justification; - } -} - -//------------------------------------------------------------------------------ -// Public Interface -//------------------------------------------------------------------------------ - -const caches = Symbol("caches"); - -/** - * Represents parsed source code. - * @implements {ISourceCode} - */ -class SourceCode extends TokenStore { - - /** - * The cache of steps that were taken while traversing the source code. - * @type {Array} - */ - #steps; - - /** - * Creates a new instance. - * @param {string|Object} textOrConfig The source code text or config object. - * @param {string} textOrConfig.text The source code text. - * @param {ASTNode} textOrConfig.ast The Program node of the AST representing the code. This AST should be created from the text that BOM was stripped. - * @param {boolean} textOrConfig.hasBOM Indicates if the text has a Unicode BOM. - * @param {Object|null} textOrConfig.parserServices The parser services. - * @param {ScopeManager|null} textOrConfig.scopeManager The scope of this source code. - * @param {Object|null} textOrConfig.visitorKeys The visitor keys to traverse AST. - * @param {ASTNode} [astIfNoConfig] The Program node of the AST representing the code. This AST should be created from the text that BOM was stripped. - */ - constructor(textOrConfig, astIfNoConfig) { - let text, hasBOM, ast, parserServices, scopeManager, visitorKeys; - - // Process overloading of arguments - if (typeof textOrConfig === "string") { - text = textOrConfig; - ast = astIfNoConfig; - hasBOM = false; - } else if (typeof textOrConfig === "object" && textOrConfig !== null) { - text = textOrConfig.text; - ast = textOrConfig.ast; - hasBOM = textOrConfig.hasBOM; - parserServices = textOrConfig.parserServices; - scopeManager = textOrConfig.scopeManager; - visitorKeys = textOrConfig.visitorKeys; - } - - validate(ast); - super(ast.tokens, ast.comments); - - /** - * General purpose caching for the class. - */ - this[caches] = new Map([ - ["scopes", new WeakMap()], - ["vars", new Map()], - ["configNodes", void 0] - ]); - - /** - * Indicates if the AST is ESTree compatible. - * @type {boolean} - */ - this.isESTree = ast.type === "Program"; - - /* - * Backwards compatibility for BOM handling. - * - * The `hasBOM` property has been available on the `SourceCode` object - * for a long time and is used to indicate if the source contains a BOM. - * The linter strips the BOM and just passes the `hasBOM` property to the - * `SourceCode` constructor to make it easier for languages to not deal with - * the BOM. - * - * However, the text passed in to the `SourceCode` constructor might still - * have a BOM if the constructor is called outside of the linter, so we still - * need to check for the BOM in the text. - */ - const textHasBOM = text.charCodeAt(0) === 0xFEFF; - - /** - * The flag to indicate that the source code has Unicode BOM. - * @type {boolean} - */ - this.hasBOM = textHasBOM || !!hasBOM; - - /** - * The original text source code. - * BOM was stripped from this text. - * @type {string} - */ - this.text = (textHasBOM ? text.slice(1) : text); - - /** - * The parsed AST for the source code. - * @type {ASTNode} - */ - this.ast = ast; - - /** - * The parser services of this source code. - * @type {Object} - */ - this.parserServices = parserServices || {}; - - /** - * The scope of this source code. - * @type {ScopeManager|null} - */ - this.scopeManager = scopeManager || null; - - /** - * The visitor keys to traverse AST. - * @type {Object} - */ - this.visitorKeys = visitorKeys || Traverser.DEFAULT_VISITOR_KEYS; - - // Check the source text for the presence of a shebang since it is parsed as a standard line comment. - const shebangMatched = this.text.match(astUtils.shebangPattern); - const hasShebang = shebangMatched && ast.comments.length && ast.comments[0].value === shebangMatched[1]; - - if (hasShebang) { - ast.comments[0].type = "Shebang"; - } - - this.tokensAndComments = sortedMerge(ast.tokens, ast.comments); - - /** - * The source code split into lines according to ECMA-262 specification. - * This is done to avoid each rule needing to do so separately. - * @type {string[]} - */ - this.lines = []; - this.lineStartIndices = [0]; - - const lineEndingPattern = astUtils.createGlobalLinebreakMatcher(); - let match; - - /* - * Previously, this was implemented using a regex that - * matched a sequence of non-linebreak characters followed by a - * linebreak, then adding the lengths of the matches. However, - * this caused a catastrophic backtracking issue when the end - * of a file contained a large number of non-newline characters. - * To avoid this, the current implementation just matches newlines - * and uses match.index to get the correct line start indices. - */ - while ((match = lineEndingPattern.exec(this.text))) { - this.lines.push(this.text.slice(this.lineStartIndices.at(-1), match.index)); - this.lineStartIndices.push(match.index + match[0].length); - } - this.lines.push(this.text.slice(this.lineStartIndices.at(-1))); - - // don't allow further modification of this object - Object.freeze(this); - Object.freeze(this.lines); - } - - /** - * Split the source code into multiple lines based on the line delimiters. - * @param {string} text Source code as a string. - * @returns {string[]} Array of source code lines. - * @public - */ - static splitLines(text) { - return text.split(astUtils.createGlobalLinebreakMatcher()); - } - - /** - * Gets the source code for the given node. - * @param {ASTNode} [node] The AST node to get the text for. - * @param {int} [beforeCount] The number of characters before the node to retrieve. - * @param {int} [afterCount] The number of characters after the node to retrieve. - * @returns {string} The text representing the AST node. - * @public - */ - getText(node, beforeCount, afterCount) { - if (node) { - return this.text.slice(Math.max(node.range[0] - (beforeCount || 0), 0), - node.range[1] + (afterCount || 0)); - } - return this.text; - } - - /** - * Gets the entire source text split into an array of lines. - * @returns {Array} The source text as an array of lines. - * @public - */ - getLines() { - return this.lines; - } - - /** - * Retrieves an array containing all comments in the source code. - * @returns {ASTNode[]} An array of comment nodes. - * @public - */ - getAllComments() { - return this.ast.comments; - } - - /** - * Retrieves the JSDoc comment for a given node. - * @param {ASTNode} node The AST node to get the comment for. - * @returns {Token|null} The Block comment token containing the JSDoc comment - * for the given node or null if not found. - * @public - * @deprecated - */ - getJSDocComment(node) { - - /** - * Checks for the presence of a JSDoc comment for the given node and returns it. - * @param {ASTNode} astNode The AST node to get the comment for. - * @returns {Token|null} The Block comment token containing the JSDoc comment - * for the given node or null if not found. - * @private - */ - const findJSDocComment = astNode => { - const tokenBefore = this.getTokenBefore(astNode, { includeComments: true }); - - if ( - tokenBefore && - isCommentToken(tokenBefore) && - tokenBefore.type === "Block" && - tokenBefore.value.charAt(0) === "*" && - astNode.loc.start.line - tokenBefore.loc.end.line <= 1 - ) { - return tokenBefore; - } - - return null; - }; - let parent = node.parent; - - switch (node.type) { - case "ClassDeclaration": - case "FunctionDeclaration": - return findJSDocComment(looksLikeExport(parent) ? parent : node); - - case "ClassExpression": - return findJSDocComment(parent.parent); - - case "ArrowFunctionExpression": - case "FunctionExpression": - if (parent.type !== "CallExpression" && parent.type !== "NewExpression") { - while ( - !this.getCommentsBefore(parent).length && - !/Function/u.test(parent.type) && - parent.type !== "MethodDefinition" && - parent.type !== "Property" - ) { - parent = parent.parent; - - if (!parent) { - break; - } - } - - if (parent && parent.type !== "FunctionDeclaration" && parent.type !== "Program") { - return findJSDocComment(parent); - } - } - - return findJSDocComment(node); - - // falls through - default: - return null; - } - } - - /** - * Gets the deepest node containing a range index. - * @param {int} index Range index of the desired node. - * @returns {ASTNode} The node if found or null if not found. - * @public - */ - getNodeByRangeIndex(index) { - let result = null; - - Traverser.traverse(this.ast, { - visitorKeys: this.visitorKeys, - enter(node) { - if (node.range[0] <= index && index < node.range[1]) { - result = node; - } else { - this.skip(); - } - }, - leave(node) { - if (node === result) { - this.break(); - } - } - }); - - return result; - } - - /** - * Determines if two nodes or tokens have at least one whitespace character - * between them. Order does not matter. Returns false if the given nodes or - * tokens overlap. - * @param {ASTNode|Token} first The first node or token to check between. - * @param {ASTNode|Token} second The second node or token to check between. - * @returns {boolean} True if there is a whitespace character between - * any of the tokens found between the two given nodes or tokens. - * @public - */ - isSpaceBetween(first, second) { - return isSpaceBetween(this, first, second, false); - } - - /** - * Determines if two nodes or tokens have at least one whitespace character - * between them. Order does not matter. Returns false if the given nodes or - * tokens overlap. - * For backward compatibility, this method returns true if there are - * `JSXText` tokens that contain whitespaces between the two. - * @param {ASTNode|Token} first The first node or token to check between. - * @param {ASTNode|Token} second The second node or token to check between. - * @returns {boolean} True if there is a whitespace character between - * any of the tokens found between the two given nodes or tokens. - * @deprecated in favor of isSpaceBetween(). - * @public - */ - isSpaceBetweenTokens(first, second) { - return isSpaceBetween(this, first, second, true); - } - - /** - * Converts a source text index into a (line, column) pair. - * @param {number} index The index of a character in a file - * @throws {TypeError} If non-numeric index or index out of range. - * @returns {Object} A {line, column} location object with a 0-indexed column - * @public - */ - getLocFromIndex(index) { - if (typeof index !== "number") { - throw new TypeError("Expected `index` to be a number."); - } - - if (index < 0 || index > this.text.length) { - throw new RangeError(`Index out of range (requested index ${index}, but source text has length ${this.text.length}).`); - } - - /* - * For an argument of this.text.length, return the location one "spot" past the last character - * of the file. If the last character is a linebreak, the location will be column 0 of the next - * line; otherwise, the location will be in the next column on the same line. - * - * See getIndexFromLoc for the motivation for this special case. - */ - if (index === this.text.length) { - return { line: this.lines.length, column: this.lines.at(-1).length }; - } - - /* - * To figure out which line index is on, determine the last place at which index could - * be inserted into lineStartIndices to keep the list sorted. - */ - const lineNumber = index >= this.lineStartIndices.at(-1) - ? this.lineStartIndices.length - : this.lineStartIndices.findIndex(el => index < el); - - return { line: lineNumber, column: index - this.lineStartIndices[lineNumber - 1] }; - } - - /** - * Converts a (line, column) pair into a range index. - * @param {Object} loc A line/column location - * @param {number} loc.line The line number of the location (1-indexed) - * @param {number} loc.column The column number of the location (0-indexed) - * @throws {TypeError|RangeError} If `loc` is not an object with a numeric - * `line` and `column`, if the `line` is less than or equal to zero or - * the line or column is out of the expected range. - * @returns {number} The range index of the location in the file. - * @public - */ - getIndexFromLoc(loc) { - if (typeof loc !== "object" || typeof loc.line !== "number" || typeof loc.column !== "number") { - throw new TypeError("Expected `loc` to be an object with numeric `line` and `column` properties."); - } - - if (loc.line <= 0) { - throw new RangeError(`Line number out of range (line ${loc.line} requested). Line numbers should be 1-based.`); - } - - if (loc.line > this.lineStartIndices.length) { - throw new RangeError(`Line number out of range (line ${loc.line} requested, but only ${this.lineStartIndices.length} lines present).`); - } - - const lineStartIndex = this.lineStartIndices[loc.line - 1]; - const lineEndIndex = loc.line === this.lineStartIndices.length ? this.text.length : this.lineStartIndices[loc.line]; - const positionIndex = lineStartIndex + loc.column; - - /* - * By design, getIndexFromLoc({ line: lineNum, column: 0 }) should return the start index of - * the given line, provided that the line number is valid element of this.lines. Since the - * last element of this.lines is an empty string for files with trailing newlines, add a - * special case where getting the index for the first location after the end of the file - * will return the length of the file, rather than throwing an error. This allows rules to - * use getIndexFromLoc consistently without worrying about edge cases at the end of a file. - */ - if ( - loc.line === this.lineStartIndices.length && positionIndex > lineEndIndex || - loc.line < this.lineStartIndices.length && positionIndex >= lineEndIndex - ) { - throw new RangeError(`Column number out of range (column ${loc.column} requested, but the length of line ${loc.line} is ${lineEndIndex - lineStartIndex}).`); - } - - return positionIndex; - } - - /** - * Gets the scope for the given node - * @param {ASTNode} currentNode The node to get the scope of - * @returns {Scope} The scope information for this node - * @throws {TypeError} If the `currentNode` argument is missing. - */ - getScope(currentNode) { - - if (!currentNode) { - throw new TypeError("Missing required argument: node."); - } - - // check cache first - const cache = this[caches].get("scopes"); - const cachedScope = cache.get(currentNode); - - if (cachedScope) { - return cachedScope; - } - - // On Program node, get the outermost scope to avoid return Node.js special function scope or ES modules scope. - const inner = currentNode.type !== "Program"; - - for (let node = currentNode; node; node = node.parent) { - const scope = this.scopeManager.acquire(node, inner); - - if (scope) { - if (scope.type === "function-expression-name") { - cache.set(currentNode, scope.childScopes[0]); - return scope.childScopes[0]; - } - - cache.set(currentNode, scope); - return scope; - } - } - - cache.set(currentNode, this.scopeManager.scopes[0]); - return this.scopeManager.scopes[0]; - } - - /** - * Get the variables that `node` defines. - * This is a convenience method that passes through - * to the same method on the `scopeManager`. - * @param {ASTNode} node The node for which the variables are obtained. - * @returns {Array} An array of variable nodes representing - * the variables that `node` defines. - */ - getDeclaredVariables(node) { - return this.scopeManager.getDeclaredVariables(node); - } - - /* eslint-disable class-methods-use-this -- node is owned by SourceCode */ - /** - * Gets all the ancestors of a given node - * @param {ASTNode} node The node - * @returns {Array} All the ancestor nodes in the AST, not including the provided node, starting - * from the root node at index 0 and going inwards to the parent node. - * @throws {TypeError} When `node` is missing. - */ - getAncestors(node) { - - if (!node) { - throw new TypeError("Missing required argument: node."); - } - - const ancestorsStartingAtParent = []; - - for (let ancestor = node.parent; ancestor; ancestor = ancestor.parent) { - ancestorsStartingAtParent.push(ancestor); - } - - return ancestorsStartingAtParent.reverse(); - } - /* eslint-enable class-methods-use-this -- node is owned by SourceCode */ - - /** - * Marks a variable as used in the current scope - * @param {string} name The name of the variable to mark as used. - * @param {ASTNode} [refNode] The closest node to the variable reference. - * @returns {boolean} True if the variable was found and marked as used, false if not. - */ - markVariableAsUsed(name, refNode = this.ast) { - - const currentScope = this.getScope(refNode); - let initialScope = currentScope; - - /* - * When we are in an ESM or CommonJS module, we need to start searching - * from the top-level scope, not the global scope. For ESM the top-level - * scope is the module scope; for CommonJS the top-level scope is the - * outer function scope. - * - * Without this check, we might miss a variable declared with `var` at - * the top-level because it won't exist in the global scope. - */ - if ( - currentScope.type === "global" && - currentScope.childScopes.length > 0 && - - // top-level scopes refer to a `Program` node - currentScope.childScopes[0].block === this.ast - ) { - initialScope = currentScope.childScopes[0]; - } - - for (let scope = initialScope; scope; scope = scope.upper) { - const variable = scope.variables.find(scopeVar => scopeVar.name === name); - - if (variable) { - variable.eslintUsed = true; - return true; - } - } - - return false; - } - - - /** - * Returns an array of all inline configuration nodes found in the - * source code. - * @returns {Array} An array of all inline configuration nodes. - */ - getInlineConfigNodes() { - - // check the cache first - let configNodes = this[caches].get("configNodes"); - - if (configNodes) { - return configNodes; - } - - // calculate fresh config nodes - configNodes = this.ast.comments.filter(comment => { - - // shebang comments are never directives - if (comment.type === "Shebang") { - return false; - } - - const { directivePart } = commentParser.extractDirectiveComment(comment.value); - - const directiveMatch = directivesPattern.exec(directivePart); - - if (!directiveMatch) { - return false; - } - - // only certain comment types are supported as line comments - return comment.type !== "Line" || !!/^eslint-disable-(next-)?line$/u.test(directiveMatch[1]); - }); - - this[caches].set("configNodes", configNodes); - - return configNodes; - } - - /** - * Returns an all directive nodes that enable or disable rules along with any problems - * encountered while parsing the directives. - * @returns {{problems:Array,directives:Array}} Information - * that ESLint needs to further process the directives. - */ - getDisableDirectives() { - - // check the cache first - const cachedDirectives = this[caches].get("disableDirectives"); - - if (cachedDirectives) { - return cachedDirectives; - } - - const problems = []; - const directives = []; - - this.getInlineConfigNodes().forEach(comment => { - const { directivePart, justificationPart } = commentParser.extractDirectiveComment(comment.value); - - // Step 1: Extract the directive text - const match = directivesPattern.exec(directivePart); - - if (!match) { - return; - } - - const directiveText = match[1]; - - // Step 2: Extract the directive value - const lineCommentSupported = /^eslint-disable-(next-)?line$/u.test(directiveText); - - if (comment.type === "Line" && !lineCommentSupported) { - return; - } - - // Step 3: Validate the directive does not span multiple lines - if (directiveText === "eslint-disable-line" && comment.loc.start.line !== comment.loc.end.line) { - const message = `${directiveText} comment should not span multiple lines.`; - - problems.push({ - ruleId: null, - message, - loc: comment.loc - }); - return; - } - - // Step 4: Extract the directive value and create the Directive object - const directiveValue = directivePart.slice(match.index + directiveText.length); - - switch (directiveText) { - case "eslint-disable": - case "eslint-enable": - case "eslint-disable-next-line": - case "eslint-disable-line": { - const directiveType = directiveText.slice("eslint-".length); - - directives.push(new Directive({ - type: directiveType, - node: comment, - value: directiveValue, - justification: justificationPart - })); - } - - // no default - } - }); - - const result = { problems, directives }; - - this[caches].set("disableDirectives", result); - - return result; - } - - /** - * Applies language options sent in from the core. - * @param {Object} languageOptions The language options for this run. - * @returns {void} - */ - applyLanguageOptions(languageOptions) { - - /* - * Add configured globals and language globals - * - * Using Object.assign instead of object spread for performance reasons - * https://github.com/eslint/eslint/issues/16302 - */ - const configGlobals = Object.assign( - Object.create(null), // https://github.com/eslint/eslint/issues/18363 - getGlobalsForEcmaVersion(languageOptions.ecmaVersion), - languageOptions.sourceType === "commonjs" ? globals.commonjs : void 0, - languageOptions.globals - ); - const varsCache = this[caches].get("vars"); - - varsCache.set("configGlobals", configGlobals); - } - - /** - * Applies configuration found inside of the source code. This method is only - * called when ESLint is running with inline configuration allowed. - * @returns {{problems:Array,configs:{config:FlatConfigArray,loc:Location}}} Information - * that ESLint needs to further process the inline configuration. - */ - applyInlineConfig() { - - const problems = []; - const configs = []; - const exportedVariables = {}; - const inlineGlobals = Object.create(null); - - this.getInlineConfigNodes().forEach(comment => { - - const { directiveText, directiveValue } = commentParser.parseDirective(comment); - - switch (directiveText) { - case "exported": - Object.assign(exportedVariables, commentParser.parseListConfig(directiveValue, comment)); - break; - - case "globals": - case "global": - for (const [id, { value }] of Object.entries(commentParser.parseStringConfig(directiveValue, comment))) { - let normalizedValue; - - try { - normalizedValue = normalizeConfigGlobal(value); - } catch (err) { - problems.push({ - ruleId: null, - loc: comment.loc, - message: err.message - }); - continue; - } - - if (inlineGlobals[id]) { - inlineGlobals[id].comments.push(comment); - inlineGlobals[id].value = normalizedValue; - } else { - inlineGlobals[id] = { - comments: [comment], - value: normalizedValue - }; - } - } - break; - - case "eslint": { - const parseResult = commentParser.parseJsonConfig(directiveValue); - - if (parseResult.success) { - configs.push({ - config: { - rules: parseResult.config - }, - loc: comment.loc - }); - } else { - problems.push({ - ruleId: null, - loc: comment.loc, - message: parseResult.error.message - }); - } - - break; - } - - // no default - } - }); - - // save all the new variables for later - const varsCache = this[caches].get("vars"); - - varsCache.set("inlineGlobals", inlineGlobals); - varsCache.set("exportedVariables", exportedVariables); - - return { - configs, - problems - }; - } - - /** - * Called by ESLint core to indicate that it has finished providing - * information. We now add in all the missing variables and ensure that - * state-changing methods cannot be called by rules. - * @returns {void} - */ - finalize() { - - const varsCache = this[caches].get("vars"); - const configGlobals = varsCache.get("configGlobals"); - const inlineGlobals = varsCache.get("inlineGlobals"); - const exportedVariables = varsCache.get("exportedVariables"); - const globalScope = this.scopeManager.scopes[0]; - - addDeclaredGlobals(globalScope, configGlobals, inlineGlobals); - - if (exportedVariables) { - markExportedVariables(globalScope, exportedVariables); - } - - } - - /** - * Traverse the source code and return the steps that were taken. - * @returns {Array} The steps that were taken while traversing the source code. - */ - traverse() { - - // Because the AST doesn't mutate, we can cache the steps - if (this.#steps) { - return this.#steps; - } - - const steps = this.#steps = []; - - /* - * This logic works for any AST, not just ESTree. Because ESLint has allowed - * custom parsers to return any AST, we need to ensure that the traversal - * logic works for any AST. - */ - const emitter = createEmitter(); - let analyzer = { - enterNode(node) { - steps.push(new TraversalStep({ - type: "visit", - target: node, - phase: 1, - args: [node, node.parent] - })); - }, - leaveNode(node) { - steps.push(new TraversalStep({ - type: "visit", - target: node, - phase: 2, - args: [node, node.parent] - })); - }, - emitter - }; - - /* - * We do code path analysis for ESTree only. Code path analysis is not - * necessary for other ASTs, and it's also not possible to do for other - * ASTs because the necessary information is not available. - * - * Generally speaking, we can tell that the AST is an ESTree if it has a - * Program node at the top level. This is not a perfect heuristic, but it - * is good enough for now. - */ - if (this.isESTree) { - analyzer = new CodePathAnalyzer(analyzer); - - CODE_PATH_EVENTS.forEach(eventName => { - emitter.on(eventName, (...args) => { - steps.push(new TraversalStep({ - type: "call", - target: eventName, - args - })); - }); - }); - } - - /* - * The actual AST traversal is done by the `Traverser` class. This class - * is responsible for walking the AST and calling the appropriate methods - * on the `analyzer` object, which is appropriate for the given AST. - */ - Traverser.traverse(this.ast, { - enter(node, parent) { - - // save the parent node on a property for backwards compatibility - node.parent = parent; - - analyzer.enterNode(node); - }, - leave(node) { - analyzer.leaveNode(node); - }, - visitorKeys: this.visitorKeys - }); - - return steps; - } -} - -module.exports = SourceCode; diff --git a/tools/eslint/node_modules/eslint/lib/languages/js/source-code/token-store/backward-token-comment-cursor.js b/tools/eslint/node_modules/eslint/lib/languages/js/source-code/token-store/backward-token-comment-cursor.js deleted file mode 100644 index 7255a62260b29a..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/languages/js/source-code/token-store/backward-token-comment-cursor.js +++ /dev/null @@ -1,57 +0,0 @@ -/** - * @fileoverview Define the cursor which iterates tokens and comments in reverse. - * @author Toru Nagashima - */ -"use strict"; - -//------------------------------------------------------------------------------ -// Requirements -//------------------------------------------------------------------------------ - -const Cursor = require("./cursor"); -const utils = require("./utils"); - -//------------------------------------------------------------------------------ -// Exports -//------------------------------------------------------------------------------ - -/** - * The cursor which iterates tokens and comments in reverse. - */ -module.exports = class BackwardTokenCommentCursor extends Cursor { - - /** - * Initializes this cursor. - * @param {Token[]} tokens The array of tokens. - * @param {Comment[]} comments The array of comments. - * @param {Object} indexMap The map from locations to indices in `tokens`. - * @param {number} startLoc The start location of the iteration range. - * @param {number} endLoc The end location of the iteration range. - */ - constructor(tokens, comments, indexMap, startLoc, endLoc) { - super(); - this.tokens = tokens; - this.comments = comments; - this.tokenIndex = utils.getLastIndex(tokens, indexMap, endLoc); - this.commentIndex = utils.search(comments, endLoc) - 1; - this.border = startLoc; - } - - /** @inheritdoc */ - moveNext() { - const token = (this.tokenIndex >= 0) ? this.tokens[this.tokenIndex] : null; - const comment = (this.commentIndex >= 0) ? this.comments[this.commentIndex] : null; - - if (token && (!comment || token.range[1] > comment.range[1])) { - this.current = token; - this.tokenIndex -= 1; - } else if (comment) { - this.current = comment; - this.commentIndex -= 1; - } else { - this.current = null; - } - - return Boolean(this.current) && (this.border === -1 || this.current.range[0] >= this.border); - } -}; diff --git a/tools/eslint/node_modules/eslint/lib/languages/js/source-code/token-store/backward-token-cursor.js b/tools/eslint/node_modules/eslint/lib/languages/js/source-code/token-store/backward-token-cursor.js deleted file mode 100644 index d3469c99b1459e..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/languages/js/source-code/token-store/backward-token-cursor.js +++ /dev/null @@ -1,58 +0,0 @@ -/** - * @fileoverview Define the cursor which iterates tokens only in reverse. - * @author Toru Nagashima - */ -"use strict"; - -//------------------------------------------------------------------------------ -// Requirements -//------------------------------------------------------------------------------ - -const Cursor = require("./cursor"); -const { getLastIndex, getFirstIndex } = require("./utils"); - -//------------------------------------------------------------------------------ -// Exports -//------------------------------------------------------------------------------ - -/** - * The cursor which iterates tokens only in reverse. - */ -module.exports = class BackwardTokenCursor extends Cursor { - - /** - * Initializes this cursor. - * @param {Token[]} tokens The array of tokens. - * @param {Comment[]} comments The array of comments. - * @param {Object} indexMap The map from locations to indices in `tokens`. - * @param {number} startLoc The start location of the iteration range. - * @param {number} endLoc The end location of the iteration range. - */ - constructor(tokens, comments, indexMap, startLoc, endLoc) { - super(); - this.tokens = tokens; - this.index = getLastIndex(tokens, indexMap, endLoc); - this.indexEnd = getFirstIndex(tokens, indexMap, startLoc); - } - - /** @inheritdoc */ - moveNext() { - if (this.index >= this.indexEnd) { - this.current = this.tokens[this.index]; - this.index -= 1; - return true; - } - return false; - } - - /* - * - * Shorthand for performance. - * - */ - - /** @inheritdoc */ - getOneToken() { - return (this.index >= this.indexEnd) ? this.tokens[this.index] : null; - } -}; diff --git a/tools/eslint/node_modules/eslint/lib/languages/js/source-code/token-store/cursor.js b/tools/eslint/node_modules/eslint/lib/languages/js/source-code/token-store/cursor.js deleted file mode 100644 index 0b726006e8e30b..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/languages/js/source-code/token-store/cursor.js +++ /dev/null @@ -1,76 +0,0 @@ -/** - * @fileoverview Define the abstract class about cursors which iterate tokens. - * @author Toru Nagashima - */ -"use strict"; - -//------------------------------------------------------------------------------ -// Exports -//------------------------------------------------------------------------------ - -/** - * The abstract class about cursors which iterate tokens. - * - * This class has 2 abstract methods. - * - * - `current: Token | Comment | null` ... The current token. - * - `moveNext(): boolean` ... Moves this cursor to the next token. If the next token didn't exist, it returns `false`. - * - * This is similar to ES2015 Iterators. - * However, Iterators were slow (at 2017-01), so I created this class as similar to C# IEnumerable. - * - * There are the following known sub classes. - * - * - ForwardTokenCursor .......... The cursor which iterates tokens only. - * - BackwardTokenCursor ......... The cursor which iterates tokens only in reverse. - * - ForwardTokenCommentCursor ... The cursor which iterates tokens and comments. - * - BackwardTokenCommentCursor .. The cursor which iterates tokens and comments in reverse. - * - DecorativeCursor - * - FilterCursor ............ The cursor which ignores the specified tokens. - * - SkipCursor .............. The cursor which ignores the first few tokens. - * - LimitCursor ............. The cursor which limits the count of tokens. - * - */ -module.exports = class Cursor { - - /** - * Initializes this cursor. - */ - constructor() { - this.current = null; - } - - /** - * Gets the first token. - * This consumes this cursor. - * @returns {Token|Comment} The first token or null. - */ - getOneToken() { - return this.moveNext() ? this.current : null; - } - - /** - * Gets the first tokens. - * This consumes this cursor. - * @returns {(Token|Comment)[]} All tokens. - */ - getAllTokens() { - const tokens = []; - - while (this.moveNext()) { - tokens.push(this.current); - } - - return tokens; - } - - /** - * Moves this cursor to the next token. - * @returns {boolean} `true` if the next token exists. - * @abstract - */ - /* c8 ignore next */ - moveNext() { // eslint-disable-line class-methods-use-this -- Unused - throw new Error("Not implemented."); - } -}; diff --git a/tools/eslint/node_modules/eslint/lib/languages/js/source-code/token-store/cursors.js b/tools/eslint/node_modules/eslint/lib/languages/js/source-code/token-store/cursors.js deleted file mode 100644 index f2676f13da624c..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/languages/js/source-code/token-store/cursors.js +++ /dev/null @@ -1,92 +0,0 @@ -/** - * @fileoverview Define 2 token factories; forward and backward. - * @author Toru Nagashima - */ -"use strict"; - -//------------------------------------------------------------------------------ -// Requirements -//------------------------------------------------------------------------------ - -const BackwardTokenCommentCursor = require("./backward-token-comment-cursor"); -const BackwardTokenCursor = require("./backward-token-cursor"); -const FilterCursor = require("./filter-cursor"); -const ForwardTokenCommentCursor = require("./forward-token-comment-cursor"); -const ForwardTokenCursor = require("./forward-token-cursor"); -const LimitCursor = require("./limit-cursor"); -const SkipCursor = require("./skip-cursor"); - -//------------------------------------------------------------------------------ -// Helpers -//------------------------------------------------------------------------------ - -/** - * The cursor factory. - * @private - */ -class CursorFactory { - - /** - * Initializes this cursor. - * @param {Function} TokenCursor The class of the cursor which iterates tokens only. - * @param {Function} TokenCommentCursor The class of the cursor which iterates the mix of tokens and comments. - */ - constructor(TokenCursor, TokenCommentCursor) { - this.TokenCursor = TokenCursor; - this.TokenCommentCursor = TokenCommentCursor; - } - - /** - * Creates a base cursor instance that can be decorated by createCursor. - * @param {Token[]} tokens The array of tokens. - * @param {Comment[]} comments The array of comments. - * @param {Object} indexMap The map from locations to indices in `tokens`. - * @param {number} startLoc The start location of the iteration range. - * @param {number} endLoc The end location of the iteration range. - * @param {boolean} includeComments The flag to iterate comments as well. - * @returns {Cursor} The created base cursor. - */ - createBaseCursor(tokens, comments, indexMap, startLoc, endLoc, includeComments) { - const Cursor = includeComments ? this.TokenCommentCursor : this.TokenCursor; - - return new Cursor(tokens, comments, indexMap, startLoc, endLoc); - } - - /** - * Creates a cursor that iterates tokens with normalized options. - * @param {Token[]} tokens The array of tokens. - * @param {Comment[]} comments The array of comments. - * @param {Object} indexMap The map from locations to indices in `tokens`. - * @param {number} startLoc The start location of the iteration range. - * @param {number} endLoc The end location of the iteration range. - * @param {boolean} includeComments The flag to iterate comments as well. - * @param {Function|null} filter The predicate function to choose tokens. - * @param {number} skip The count of tokens the cursor skips. - * @param {number} count The maximum count of tokens the cursor iterates. Zero is no iteration for backward compatibility. - * @returns {Cursor} The created cursor. - */ - createCursor(tokens, comments, indexMap, startLoc, endLoc, includeComments, filter, skip, count) { - let cursor = this.createBaseCursor(tokens, comments, indexMap, startLoc, endLoc, includeComments); - - if (filter) { - cursor = new FilterCursor(cursor, filter); - } - if (skip >= 1) { - cursor = new SkipCursor(cursor, skip); - } - if (count >= 0) { - cursor = new LimitCursor(cursor, count); - } - - return cursor; - } -} - -//------------------------------------------------------------------------------ -// Exports -//------------------------------------------------------------------------------ - -module.exports = { - forward: new CursorFactory(ForwardTokenCursor, ForwardTokenCommentCursor), - backward: new CursorFactory(BackwardTokenCursor, BackwardTokenCommentCursor) -}; diff --git a/tools/eslint/node_modules/eslint/lib/languages/js/source-code/token-store/decorative-cursor.js b/tools/eslint/node_modules/eslint/lib/languages/js/source-code/token-store/decorative-cursor.js deleted file mode 100644 index 3ee7b0b39755e1..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/languages/js/source-code/token-store/decorative-cursor.js +++ /dev/null @@ -1,39 +0,0 @@ -/** - * @fileoverview Define the abstract class about cursors which manipulate another cursor. - * @author Toru Nagashima - */ -"use strict"; - -//------------------------------------------------------------------------------ -// Requirements -//------------------------------------------------------------------------------ - -const Cursor = require("./cursor"); - -//------------------------------------------------------------------------------ -// Exports -//------------------------------------------------------------------------------ - -/** - * The abstract class about cursors which manipulate another cursor. - */ -module.exports = class DecorativeCursor extends Cursor { - - /** - * Initializes this cursor. - * @param {Cursor} cursor The cursor to be decorated. - */ - constructor(cursor) { - super(); - this.cursor = cursor; - } - - /** @inheritdoc */ - moveNext() { - const retv = this.cursor.moveNext(); - - this.current = this.cursor.current; - - return retv; - } -}; diff --git a/tools/eslint/node_modules/eslint/lib/languages/js/source-code/token-store/filter-cursor.js b/tools/eslint/node_modules/eslint/lib/languages/js/source-code/token-store/filter-cursor.js deleted file mode 100644 index 08c4f22031af86..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/languages/js/source-code/token-store/filter-cursor.js +++ /dev/null @@ -1,43 +0,0 @@ -/** - * @fileoverview Define the cursor which ignores specified tokens. - * @author Toru Nagashima - */ -"use strict"; - -//------------------------------------------------------------------------------ -// Requirements -//------------------------------------------------------------------------------ - -const DecorativeCursor = require("./decorative-cursor"); - -//------------------------------------------------------------------------------ -// Exports -//------------------------------------------------------------------------------ - -/** - * The decorative cursor which ignores specified tokens. - */ -module.exports = class FilterCursor extends DecorativeCursor { - - /** - * Initializes this cursor. - * @param {Cursor} cursor The cursor to be decorated. - * @param {Function} predicate The predicate function to decide tokens this cursor iterates. - */ - constructor(cursor, predicate) { - super(cursor); - this.predicate = predicate; - } - - /** @inheritdoc */ - moveNext() { - const predicate = this.predicate; - - while (super.moveNext()) { - if (predicate(this.current)) { - return true; - } - } - return false; - } -}; diff --git a/tools/eslint/node_modules/eslint/lib/languages/js/source-code/token-store/forward-token-comment-cursor.js b/tools/eslint/node_modules/eslint/lib/languages/js/source-code/token-store/forward-token-comment-cursor.js deleted file mode 100644 index 8aa46c27b7435c..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/languages/js/source-code/token-store/forward-token-comment-cursor.js +++ /dev/null @@ -1,57 +0,0 @@ -/** - * @fileoverview Define the cursor which iterates tokens and comments. - * @author Toru Nagashima - */ -"use strict"; - -//------------------------------------------------------------------------------ -// Requirements -//------------------------------------------------------------------------------ - -const Cursor = require("./cursor"); -const { getFirstIndex, search } = require("./utils"); - -//------------------------------------------------------------------------------ -// Exports -//------------------------------------------------------------------------------ - -/** - * The cursor which iterates tokens and comments. - */ -module.exports = class ForwardTokenCommentCursor extends Cursor { - - /** - * Initializes this cursor. - * @param {Token[]} tokens The array of tokens. - * @param {Comment[]} comments The array of comments. - * @param {Object} indexMap The map from locations to indices in `tokens`. - * @param {number} startLoc The start location of the iteration range. - * @param {number} endLoc The end location of the iteration range. - */ - constructor(tokens, comments, indexMap, startLoc, endLoc) { - super(); - this.tokens = tokens; - this.comments = comments; - this.tokenIndex = getFirstIndex(tokens, indexMap, startLoc); - this.commentIndex = search(comments, startLoc); - this.border = endLoc; - } - - /** @inheritdoc */ - moveNext() { - const token = (this.tokenIndex < this.tokens.length) ? this.tokens[this.tokenIndex] : null; - const comment = (this.commentIndex < this.comments.length) ? this.comments[this.commentIndex] : null; - - if (token && (!comment || token.range[0] < comment.range[0])) { - this.current = token; - this.tokenIndex += 1; - } else if (comment) { - this.current = comment; - this.commentIndex += 1; - } else { - this.current = null; - } - - return Boolean(this.current) && (this.border === -1 || this.current.range[1] <= this.border); - } -}; diff --git a/tools/eslint/node_modules/eslint/lib/languages/js/source-code/token-store/forward-token-cursor.js b/tools/eslint/node_modules/eslint/lib/languages/js/source-code/token-store/forward-token-cursor.js deleted file mode 100644 index 9305cbef68380e..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/languages/js/source-code/token-store/forward-token-cursor.js +++ /dev/null @@ -1,63 +0,0 @@ -/** - * @fileoverview Define the cursor which iterates tokens only. - * @author Toru Nagashima - */ -"use strict"; - -//------------------------------------------------------------------------------ -// Requirements -//------------------------------------------------------------------------------ - -const Cursor = require("./cursor"); -const { getFirstIndex, getLastIndex } = require("./utils"); - -//------------------------------------------------------------------------------ -// Exports -//------------------------------------------------------------------------------ - -/** - * The cursor which iterates tokens only. - */ -module.exports = class ForwardTokenCursor extends Cursor { - - /** - * Initializes this cursor. - * @param {Token[]} tokens The array of tokens. - * @param {Comment[]} comments The array of comments. - * @param {Object} indexMap The map from locations to indices in `tokens`. - * @param {number} startLoc The start location of the iteration range. - * @param {number} endLoc The end location of the iteration range. - */ - constructor(tokens, comments, indexMap, startLoc, endLoc) { - super(); - this.tokens = tokens; - this.index = getFirstIndex(tokens, indexMap, startLoc); - this.indexEnd = getLastIndex(tokens, indexMap, endLoc); - } - - /** @inheritdoc */ - moveNext() { - if (this.index <= this.indexEnd) { - this.current = this.tokens[this.index]; - this.index += 1; - return true; - } - return false; - } - - /* - * - * Shorthand for performance. - * - */ - - /** @inheritdoc */ - getOneToken() { - return (this.index <= this.indexEnd) ? this.tokens[this.index] : null; - } - - /** @inheritdoc */ - getAllTokens() { - return this.tokens.slice(this.index, this.indexEnd + 1); - } -}; diff --git a/tools/eslint/node_modules/eslint/lib/languages/js/source-code/token-store/index.js b/tools/eslint/node_modules/eslint/lib/languages/js/source-code/token-store/index.js deleted file mode 100644 index 8f8d6de769f9c2..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/languages/js/source-code/token-store/index.js +++ /dev/null @@ -1,627 +0,0 @@ -/** - * @fileoverview Object to handle access and retrieval of tokens. - * @author Brandon Mills - */ -"use strict"; - -//------------------------------------------------------------------------------ -// Requirements -//------------------------------------------------------------------------------ - -const assert = require("node:assert"); -const { isCommentToken } = require("@eslint-community/eslint-utils"); -const cursors = require("./cursors"); -const ForwardTokenCursor = require("./forward-token-cursor"); -const PaddedTokenCursor = require("./padded-token-cursor"); -const utils = require("./utils"); - -//------------------------------------------------------------------------------ -// Helpers -//------------------------------------------------------------------------------ - -const TOKENS = Symbol("tokens"); -const COMMENTS = Symbol("comments"); -const INDEX_MAP = Symbol("indexMap"); - -/** - * Creates the map from locations to indices in `tokens`. - * - * The first/last location of tokens is mapped to the index of the token. - * The first/last location of comments is mapped to the index of the next token of each comment. - * @param {Token[]} tokens The array of tokens. - * @param {Comment[]} comments The array of comments. - * @returns {Object} The map from locations to indices in `tokens`. - * @private - */ -function createIndexMap(tokens, comments) { - const map = Object.create(null); - let tokenIndex = 0; - let commentIndex = 0; - let nextStart; - let range; - - while (tokenIndex < tokens.length || commentIndex < comments.length) { - nextStart = (commentIndex < comments.length) ? comments[commentIndex].range[0] : Number.MAX_SAFE_INTEGER; - while (tokenIndex < tokens.length && (range = tokens[tokenIndex].range)[0] < nextStart) { - map[range[0]] = tokenIndex; - map[range[1] - 1] = tokenIndex; - tokenIndex += 1; - } - - nextStart = (tokenIndex < tokens.length) ? tokens[tokenIndex].range[0] : Number.MAX_SAFE_INTEGER; - while (commentIndex < comments.length && (range = comments[commentIndex].range)[0] < nextStart) { - map[range[0]] = tokenIndex; - map[range[1] - 1] = tokenIndex; - commentIndex += 1; - } - } - - return map; -} - -/** - * Creates the cursor iterates tokens with options. - * @param {CursorFactory} factory The cursor factory to initialize cursor. - * @param {Token[]} tokens The array of tokens. - * @param {Comment[]} comments The array of comments. - * @param {Object} indexMap The map from locations to indices in `tokens`. - * @param {number} startLoc The start location of the iteration range. - * @param {number} endLoc The end location of the iteration range. - * @param {number|Function|Object} [opts=0] The option object. If this is a number then it's `opts.skip`. If this is a function then it's `opts.filter`. - * @param {boolean} [opts.includeComments=false] The flag to iterate comments as well. - * @param {Function|null} [opts.filter=null] The predicate function to choose tokens. - * @param {number} [opts.skip=0] The count of tokens the cursor skips. - * @returns {Cursor} The created cursor. - * @private - */ -function createCursorWithSkip(factory, tokens, comments, indexMap, startLoc, endLoc, opts) { - let includeComments = false; - let skip = 0; - let filter = null; - - if (typeof opts === "number") { - skip = opts | 0; - } else if (typeof opts === "function") { - filter = opts; - } else if (opts) { - includeComments = !!opts.includeComments; - skip = opts.skip | 0; - filter = opts.filter || null; - } - assert(skip >= 0, "options.skip should be zero or a positive integer."); - assert(!filter || typeof filter === "function", "options.filter should be a function."); - - return factory.createCursor(tokens, comments, indexMap, startLoc, endLoc, includeComments, filter, skip, -1); -} - -/** - * Creates the cursor iterates tokens with options. - * @param {CursorFactory} factory The cursor factory to initialize cursor. - * @param {Token[]} tokens The array of tokens. - * @param {Comment[]} comments The array of comments. - * @param {Object} indexMap The map from locations to indices in `tokens`. - * @param {number} startLoc The start location of the iteration range. - * @param {number} endLoc The end location of the iteration range. - * @param {number|Function|Object} [opts=0] The option object. If this is a number then it's `opts.count`. If this is a function then it's `opts.filter`. - * @param {boolean} [opts.includeComments] The flag to iterate comments as well. - * @param {Function|null} [opts.filter=null] The predicate function to choose tokens. - * @param {number} [opts.count=0] The maximum count of tokens the cursor iterates. Zero is no iteration for backward compatibility. - * @returns {Cursor} The created cursor. - * @private - */ -function createCursorWithCount(factory, tokens, comments, indexMap, startLoc, endLoc, opts) { - let includeComments = false; - let count = 0; - let countExists = false; - let filter = null; - - if (typeof opts === "number") { - count = opts | 0; - countExists = true; - } else if (typeof opts === "function") { - filter = opts; - } else if (opts) { - includeComments = !!opts.includeComments; - count = opts.count | 0; - countExists = typeof opts.count === "number"; - filter = opts.filter || null; - } - assert(count >= 0, "options.count should be zero or a positive integer."); - assert(!filter || typeof filter === "function", "options.filter should be a function."); - - return factory.createCursor(tokens, comments, indexMap, startLoc, endLoc, includeComments, filter, 0, countExists ? count : -1); -} - -/** - * Creates the cursor iterates tokens with options. - * This is overload function of the below. - * @param {Token[]} tokens The array of tokens. - * @param {Comment[]} comments The array of comments. - * @param {Object} indexMap The map from locations to indices in `tokens`. - * @param {number} startLoc The start location of the iteration range. - * @param {number} endLoc The end location of the iteration range. - * @param {Function|Object} opts The option object. If this is a function then it's `opts.filter`. - * @param {boolean} [opts.includeComments] The flag to iterate comments as well. - * @param {Function|null} [opts.filter=null] The predicate function to choose tokens. - * @param {number} [opts.count=0] The maximum count of tokens the cursor iterates. Zero is no iteration for backward compatibility. - * @returns {Cursor} The created cursor. - * @private - */ -/** - * Creates the cursor iterates tokens with options. - * @param {Token[]} tokens The array of tokens. - * @param {Comment[]} comments The array of comments. - * @param {Object} indexMap The map from locations to indices in `tokens`. - * @param {number} startLoc The start location of the iteration range. - * @param {number} endLoc The end location of the iteration range. - * @param {number} [beforeCount=0] The number of tokens before the node to retrieve. - * @param {boolean} [afterCount=0] The number of tokens after the node to retrieve. - * @returns {Cursor} The created cursor. - * @private - */ -function createCursorWithPadding(tokens, comments, indexMap, startLoc, endLoc, beforeCount, afterCount) { - if (typeof beforeCount === "undefined" && typeof afterCount === "undefined") { - return new ForwardTokenCursor(tokens, comments, indexMap, startLoc, endLoc); - } - if (typeof beforeCount === "number" || typeof beforeCount === "undefined") { - return new PaddedTokenCursor(tokens, comments, indexMap, startLoc, endLoc, beforeCount | 0, afterCount | 0); - } - return createCursorWithCount(cursors.forward, tokens, comments, indexMap, startLoc, endLoc, beforeCount); -} - -/** - * Gets comment tokens that are adjacent to the current cursor position. - * @param {Cursor} cursor A cursor instance. - * @returns {Array} An array of comment tokens adjacent to the current cursor position. - * @private - */ -function getAdjacentCommentTokensFromCursor(cursor) { - const tokens = []; - let currentToken = cursor.getOneToken(); - - while (currentToken && isCommentToken(currentToken)) { - tokens.push(currentToken); - currentToken = cursor.getOneToken(); - } - - return tokens; -} - -//------------------------------------------------------------------------------ -// Exports -//------------------------------------------------------------------------------ - -/** - * The token store. - * - * This class provides methods to get tokens by locations as fast as possible. - * The methods are a part of public API, so we should be careful if it changes this class. - * - * People can get tokens in O(1) by the hash map which is mapping from the location of tokens/comments to tokens. - * Also people can get a mix of tokens and comments in O(log k), the k is the number of comments. - * Assuming that comments to be much fewer than tokens, this does not make hash map from token's locations to comments to reduce memory cost. - * This uses binary-searching instead for comments. - */ -module.exports = class TokenStore { - - /** - * Initializes this token store. - * @param {Token[]} tokens The array of tokens. - * @param {Comment[]} comments The array of comments. - */ - constructor(tokens, comments) { - this[TOKENS] = tokens; - this[COMMENTS] = comments; - this[INDEX_MAP] = createIndexMap(tokens, comments); - } - - //-------------------------------------------------------------------------- - // Gets single token. - //-------------------------------------------------------------------------- - - /** - * Gets the token starting at the specified index. - * @param {number} offset Index of the start of the token's range. - * @param {Object} [options=0] The option object. - * @param {boolean} [options.includeComments=false] The flag to iterate comments as well. - * @returns {Token|null} The token starting at index, or null if no such token. - */ - getTokenByRangeStart(offset, options) { - const includeComments = options && options.includeComments; - const token = cursors.forward.createBaseCursor( - this[TOKENS], - this[COMMENTS], - this[INDEX_MAP], - offset, - -1, - includeComments - ).getOneToken(); - - if (token && token.range[0] === offset) { - return token; - } - return null; - } - - /** - * Gets the first token of the given node. - * @param {ASTNode} node The AST node. - * @param {number|Function|Object} [options=0] The option object. If this is a number then it's `options.skip`. If this is a function then it's `options.filter`. - * @param {boolean} [options.includeComments=false] The flag to iterate comments as well. - * @param {Function|null} [options.filter=null] The predicate function to choose tokens. - * @param {number} [options.skip=0] The count of tokens the cursor skips. - * @returns {Token|null} An object representing the token. - */ - getFirstToken(node, options) { - return createCursorWithSkip( - cursors.forward, - this[TOKENS], - this[COMMENTS], - this[INDEX_MAP], - node.range[0], - node.range[1], - options - ).getOneToken(); - } - - /** - * Gets the last token of the given node. - * @param {ASTNode} node The AST node. - * @param {number|Function|Object} [options=0] The option object. Same options as getFirstToken() - * @returns {Token|null} An object representing the token. - */ - getLastToken(node, options) { - return createCursorWithSkip( - cursors.backward, - this[TOKENS], - this[COMMENTS], - this[INDEX_MAP], - node.range[0], - node.range[1], - options - ).getOneToken(); - } - - /** - * Gets the token that precedes a given node or token. - * @param {ASTNode|Token|Comment} node The AST node or token. - * @param {number|Function|Object} [options=0] The option object. Same options as getFirstToken() - * @returns {Token|null} An object representing the token. - */ - getTokenBefore(node, options) { - return createCursorWithSkip( - cursors.backward, - this[TOKENS], - this[COMMENTS], - this[INDEX_MAP], - -1, - node.range[0], - options - ).getOneToken(); - } - - /** - * Gets the token that follows a given node or token. - * @param {ASTNode|Token|Comment} node The AST node or token. - * @param {number|Function|Object} [options=0] The option object. Same options as getFirstToken() - * @returns {Token|null} An object representing the token. - */ - getTokenAfter(node, options) { - return createCursorWithSkip( - cursors.forward, - this[TOKENS], - this[COMMENTS], - this[INDEX_MAP], - node.range[1], - -1, - options - ).getOneToken(); - } - - /** - * Gets the first token between two non-overlapping nodes. - * @param {ASTNode|Token|Comment} left Node before the desired token range. - * @param {ASTNode|Token|Comment} right Node after the desired token range. - * @param {number|Function|Object} [options=0] The option object. Same options as getFirstToken() - * @returns {Token|null} An object representing the token. - */ - getFirstTokenBetween(left, right, options) { - return createCursorWithSkip( - cursors.forward, - this[TOKENS], - this[COMMENTS], - this[INDEX_MAP], - left.range[1], - right.range[0], - options - ).getOneToken(); - } - - /** - * Gets the last token between two non-overlapping nodes. - * @param {ASTNode|Token|Comment} left Node before the desired token range. - * @param {ASTNode|Token|Comment} right Node after the desired token range. - * @param {number|Function|Object} [options=0] The option object. Same options as getFirstToken() - * @returns {Token|null} An object representing the token. - */ - getLastTokenBetween(left, right, options) { - return createCursorWithSkip( - cursors.backward, - this[TOKENS], - this[COMMENTS], - this[INDEX_MAP], - left.range[1], - right.range[0], - options - ).getOneToken(); - } - - /** - * Gets the token that precedes a given node or token in the token stream. - * This is defined for backward compatibility. Use `includeComments` option instead. - * TODO: We have a plan to remove this in a future major version. - * @param {ASTNode|Token|Comment} node The AST node or token. - * @param {number} [skip=0] A number of tokens to skip. - * @returns {Token|null} An object representing the token. - * @deprecated - */ - getTokenOrCommentBefore(node, skip) { - return this.getTokenBefore(node, { includeComments: true, skip }); - } - - /** - * Gets the token that follows a given node or token in the token stream. - * This is defined for backward compatibility. Use `includeComments` option instead. - * TODO: We have a plan to remove this in a future major version. - * @param {ASTNode|Token|Comment} node The AST node or token. - * @param {number} [skip=0] A number of tokens to skip. - * @returns {Token|null} An object representing the token. - * @deprecated - */ - getTokenOrCommentAfter(node, skip) { - return this.getTokenAfter(node, { includeComments: true, skip }); - } - - //-------------------------------------------------------------------------- - // Gets multiple tokens. - //-------------------------------------------------------------------------- - - /** - * Gets the first `count` tokens of the given node. - * @param {ASTNode} node The AST node. - * @param {number|Function|Object} [options=0] The option object. If this is a number then it's `options.count`. If this is a function then it's `options.filter`. - * @param {boolean} [options.includeComments=false] The flag to iterate comments as well. - * @param {Function|null} [options.filter=null] The predicate function to choose tokens. - * @param {number} [options.count=0] The maximum count of tokens the cursor iterates. - * @returns {Token[]} Tokens. - */ - getFirstTokens(node, options) { - return createCursorWithCount( - cursors.forward, - this[TOKENS], - this[COMMENTS], - this[INDEX_MAP], - node.range[0], - node.range[1], - options - ).getAllTokens(); - } - - /** - * Gets the last `count` tokens of the given node. - * @param {ASTNode} node The AST node. - * @param {number|Function|Object} [options=0] The option object. Same options as getFirstTokens() - * @returns {Token[]} Tokens. - */ - getLastTokens(node, options) { - return createCursorWithCount( - cursors.backward, - this[TOKENS], - this[COMMENTS], - this[INDEX_MAP], - node.range[0], - node.range[1], - options - ).getAllTokens().reverse(); - } - - /** - * Gets the `count` tokens that precedes a given node or token. - * @param {ASTNode|Token|Comment} node The AST node or token. - * @param {number|Function|Object} [options=0] The option object. Same options as getFirstTokens() - * @returns {Token[]} Tokens. - */ - getTokensBefore(node, options) { - return createCursorWithCount( - cursors.backward, - this[TOKENS], - this[COMMENTS], - this[INDEX_MAP], - -1, - node.range[0], - options - ).getAllTokens().reverse(); - } - - /** - * Gets the `count` tokens that follows a given node or token. - * @param {ASTNode|Token|Comment} node The AST node or token. - * @param {number|Function|Object} [options=0] The option object. Same options as getFirstTokens() - * @returns {Token[]} Tokens. - */ - getTokensAfter(node, options) { - return createCursorWithCount( - cursors.forward, - this[TOKENS], - this[COMMENTS], - this[INDEX_MAP], - node.range[1], - -1, - options - ).getAllTokens(); - } - - /** - * Gets the first `count` tokens between two non-overlapping nodes. - * @param {ASTNode|Token|Comment} left Node before the desired token range. - * @param {ASTNode|Token|Comment} right Node after the desired token range. - * @param {number|Function|Object} [options=0] The option object. Same options as getFirstTokens() - * @returns {Token[]} Tokens between left and right. - */ - getFirstTokensBetween(left, right, options) { - return createCursorWithCount( - cursors.forward, - this[TOKENS], - this[COMMENTS], - this[INDEX_MAP], - left.range[1], - right.range[0], - options - ).getAllTokens(); - } - - /** - * Gets the last `count` tokens between two non-overlapping nodes. - * @param {ASTNode|Token|Comment} left Node before the desired token range. - * @param {ASTNode|Token|Comment} right Node after the desired token range. - * @param {number|Function|Object} [options=0] The option object. Same options as getFirstTokens() - * @returns {Token[]} Tokens between left and right. - */ - getLastTokensBetween(left, right, options) { - return createCursorWithCount( - cursors.backward, - this[TOKENS], - this[COMMENTS], - this[INDEX_MAP], - left.range[1], - right.range[0], - options - ).getAllTokens().reverse(); - } - - /** - * Gets all tokens that are related to the given node. - * @param {ASTNode} node The AST node. - * @param {Function|Object} options The option object. If this is a function then it's `options.filter`. - * @param {boolean} [options.includeComments=false] The flag to iterate comments as well. - * @param {Function|null} [options.filter=null] The predicate function to choose tokens. - * @param {number} [options.count=0] The maximum count of tokens the cursor iterates. - * @returns {Token[]} Array of objects representing tokens. - */ - /** - * Gets all tokens that are related to the given node. - * @param {ASTNode} node The AST node. - * @param {int} [beforeCount=0] The number of tokens before the node to retrieve. - * @param {int} [afterCount=0] The number of tokens after the node to retrieve. - * @returns {Token[]} Array of objects representing tokens. - */ - getTokens(node, beforeCount, afterCount) { - return createCursorWithPadding( - this[TOKENS], - this[COMMENTS], - this[INDEX_MAP], - node.range[0], - node.range[1], - beforeCount, - afterCount - ).getAllTokens(); - } - - /** - * Gets all of the tokens between two non-overlapping nodes. - * @param {ASTNode|Token|Comment} left Node before the desired token range. - * @param {ASTNode|Token|Comment} right Node after the desired token range. - * @param {Function|Object} options The option object. If this is a function then it's `options.filter`. - * @param {boolean} [options.includeComments=false] The flag to iterate comments as well. - * @param {Function|null} [options.filter=null] The predicate function to choose tokens. - * @param {number} [options.count=0] The maximum count of tokens the cursor iterates. - * @returns {Token[]} Tokens between left and right. - */ - /** - * Gets all of the tokens between two non-overlapping nodes. - * @param {ASTNode|Token|Comment} left Node before the desired token range. - * @param {ASTNode|Token|Comment} right Node after the desired token range. - * @param {int} [padding=0] Number of extra tokens on either side of center. - * @returns {Token[]} Tokens between left and right. - */ - getTokensBetween(left, right, padding) { - return createCursorWithPadding( - this[TOKENS], - this[COMMENTS], - this[INDEX_MAP], - left.range[1], - right.range[0], - padding, - padding - ).getAllTokens(); - } - - //-------------------------------------------------------------------------- - // Others. - //-------------------------------------------------------------------------- - - /** - * Checks whether any comments exist or not between the given 2 nodes. - * @param {ASTNode} left The node to check. - * @param {ASTNode} right The node to check. - * @returns {boolean} `true` if one or more comments exist. - */ - commentsExistBetween(left, right) { - const index = utils.search(this[COMMENTS], left.range[1]); - - return ( - index < this[COMMENTS].length && - this[COMMENTS][index].range[1] <= right.range[0] - ); - } - - /** - * Gets all comment tokens directly before the given node or token. - * @param {ASTNode|token} nodeOrToken The AST node or token to check for adjacent comment tokens. - * @returns {Array} An array of comments in occurrence order. - */ - getCommentsBefore(nodeOrToken) { - const cursor = createCursorWithCount( - cursors.backward, - this[TOKENS], - this[COMMENTS], - this[INDEX_MAP], - -1, - nodeOrToken.range[0], - { includeComments: true } - ); - - return getAdjacentCommentTokensFromCursor(cursor).reverse(); - } - - /** - * Gets all comment tokens directly after the given node or token. - * @param {ASTNode|token} nodeOrToken The AST node or token to check for adjacent comment tokens. - * @returns {Array} An array of comments in occurrence order. - */ - getCommentsAfter(nodeOrToken) { - const cursor = createCursorWithCount( - cursors.forward, - this[TOKENS], - this[COMMENTS], - this[INDEX_MAP], - nodeOrToken.range[1], - -1, - { includeComments: true } - ); - - return getAdjacentCommentTokensFromCursor(cursor); - } - - /** - * Gets all comment tokens inside the given node. - * @param {ASTNode} node The AST node to get the comments for. - * @returns {Array} An array of comments in occurrence order. - */ - getCommentsInside(node) { - return this.getTokens(node, { - includeComments: true, - filter: isCommentToken - }); - } -}; diff --git a/tools/eslint/node_modules/eslint/lib/languages/js/source-code/token-store/limit-cursor.js b/tools/eslint/node_modules/eslint/lib/languages/js/source-code/token-store/limit-cursor.js deleted file mode 100644 index 0fd92a77657ab3..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/languages/js/source-code/token-store/limit-cursor.js +++ /dev/null @@ -1,40 +0,0 @@ -/** - * @fileoverview Define the cursor which limits the number of tokens. - * @author Toru Nagashima - */ -"use strict"; - -//------------------------------------------------------------------------------ -// Requirements -//------------------------------------------------------------------------------ - -const DecorativeCursor = require("./decorative-cursor"); - -//------------------------------------------------------------------------------ -// Exports -//------------------------------------------------------------------------------ - -/** - * The decorative cursor which limits the number of tokens. - */ -module.exports = class LimitCursor extends DecorativeCursor { - - /** - * Initializes this cursor. - * @param {Cursor} cursor The cursor to be decorated. - * @param {number} count The count of tokens this cursor iterates. - */ - constructor(cursor, count) { - super(cursor); - this.count = count; - } - - /** @inheritdoc */ - moveNext() { - if (this.count > 0) { - this.count -= 1; - return super.moveNext(); - } - return false; - } -}; diff --git a/tools/eslint/node_modules/eslint/lib/languages/js/source-code/token-store/padded-token-cursor.js b/tools/eslint/node_modules/eslint/lib/languages/js/source-code/token-store/padded-token-cursor.js deleted file mode 100644 index 89349fa1c69526..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/languages/js/source-code/token-store/padded-token-cursor.js +++ /dev/null @@ -1,38 +0,0 @@ -/** - * @fileoverview Define the cursor which iterates tokens only, with inflated range. - * @author Toru Nagashima - */ -"use strict"; - -//------------------------------------------------------------------------------ -// Requirements -//------------------------------------------------------------------------------ - -const ForwardTokenCursor = require("./forward-token-cursor"); - -//------------------------------------------------------------------------------ -// Exports -//------------------------------------------------------------------------------ - -/** - * The cursor which iterates tokens only, with inflated range. - * This is for the backward compatibility of padding options. - */ -module.exports = class PaddedTokenCursor extends ForwardTokenCursor { - - /** - * Initializes this cursor. - * @param {Token[]} tokens The array of tokens. - * @param {Comment[]} comments The array of comments. - * @param {Object} indexMap The map from locations to indices in `tokens`. - * @param {number} startLoc The start location of the iteration range. - * @param {number} endLoc The end location of the iteration range. - * @param {number} beforeCount The number of tokens this cursor iterates before start. - * @param {number} afterCount The number of tokens this cursor iterates after end. - */ - constructor(tokens, comments, indexMap, startLoc, endLoc, beforeCount, afterCount) { - super(tokens, comments, indexMap, startLoc, endLoc); - this.index = Math.max(0, this.index - beforeCount); - this.indexEnd = Math.min(tokens.length - 1, this.indexEnd + afterCount); - } -}; diff --git a/tools/eslint/node_modules/eslint/lib/languages/js/source-code/token-store/skip-cursor.js b/tools/eslint/node_modules/eslint/lib/languages/js/source-code/token-store/skip-cursor.js deleted file mode 100644 index f068f531c1e3df..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/languages/js/source-code/token-store/skip-cursor.js +++ /dev/null @@ -1,42 +0,0 @@ -/** - * @fileoverview Define the cursor which ignores the first few tokens. - * @author Toru Nagashima - */ -"use strict"; - -//------------------------------------------------------------------------------ -// Requirements -//------------------------------------------------------------------------------ - -const DecorativeCursor = require("./decorative-cursor"); - -//------------------------------------------------------------------------------ -// Exports -//------------------------------------------------------------------------------ - -/** - * The decorative cursor which ignores the first few tokens. - */ -module.exports = class SkipCursor extends DecorativeCursor { - - /** - * Initializes this cursor. - * @param {Cursor} cursor The cursor to be decorated. - * @param {number} count The count of tokens this cursor skips. - */ - constructor(cursor, count) { - super(cursor); - this.count = count; - } - - /** @inheritdoc */ - moveNext() { - while (this.count > 0) { - this.count -= 1; - if (!super.moveNext()) { - return false; - } - } - return super.moveNext(); - } -}; diff --git a/tools/eslint/node_modules/eslint/lib/languages/js/source-code/token-store/utils.js b/tools/eslint/node_modules/eslint/lib/languages/js/source-code/token-store/utils.js deleted file mode 100644 index 3e01470321a43b..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/languages/js/source-code/token-store/utils.js +++ /dev/null @@ -1,107 +0,0 @@ -/** - * @fileoverview Define utility functions for token store. - * @author Toru Nagashima - */ -"use strict"; - -//------------------------------------------------------------------------------ -// Exports -//------------------------------------------------------------------------------ - -/** - * Finds the index of the first token which is after the given location. - * If it was not found, this returns `tokens.length`. - * @param {(Token|Comment)[]} tokens It searches the token in this list. - * @param {number} location The location to search. - * @returns {number} The found index or `tokens.length`. - */ -exports.search = function search(tokens, location) { - for (let minIndex = 0, maxIndex = tokens.length - 1; minIndex <= maxIndex;) { - - /* - * Calculate the index in the middle between minIndex and maxIndex. - * `| 0` is used to round a fractional value down to the nearest integer: this is similar to - * using `Math.trunc()` or `Math.floor()`, but performance tests have shown this method to - * be faster. - */ - const index = (minIndex + maxIndex) / 2 | 0; - const token = tokens[index]; - const tokenStartLocation = token.range[0]; - - if (location <= tokenStartLocation) { - if (index === minIndex) { - return index; - } - maxIndex = index; - } else { - minIndex = index + 1; - } - } - return tokens.length; -}; - -/** - * Gets the index of the `startLoc` in `tokens`. - * `startLoc` can be the value of `node.range[1]`, so this checks about `startLoc - 1` as well. - * @param {(Token|Comment)[]} tokens The tokens to find an index. - * @param {Object} indexMap The map from locations to indices. - * @param {number} startLoc The location to get an index. - * @returns {number} The index. - */ -exports.getFirstIndex = function getFirstIndex(tokens, indexMap, startLoc) { - if (startLoc in indexMap) { - return indexMap[startLoc]; - } - if ((startLoc - 1) in indexMap) { - const index = indexMap[startLoc - 1]; - const token = tokens[index]; - - // If the mapped index is out of bounds, the returned cursor index will point after the end of the tokens array. - if (!token) { - return tokens.length; - } - - /* - * For the map of "comment's location -> token's index", it points the next token of a comment. - * In that case, +1 is unnecessary. - */ - if (token.range[0] >= startLoc) { - return index; - } - return index + 1; - } - return 0; -}; - -/** - * Gets the index of the `endLoc` in `tokens`. - * The information of end locations are recorded at `endLoc - 1` in `indexMap`, so this checks about `endLoc - 1` as well. - * @param {(Token|Comment)[]} tokens The tokens to find an index. - * @param {Object} indexMap The map from locations to indices. - * @param {number} endLoc The location to get an index. - * @returns {number} The index. - */ -exports.getLastIndex = function getLastIndex(tokens, indexMap, endLoc) { - if (endLoc in indexMap) { - return indexMap[endLoc] - 1; - } - if ((endLoc - 1) in indexMap) { - const index = indexMap[endLoc - 1]; - const token = tokens[index]; - - // If the mapped index is out of bounds, the returned cursor index will point before the end of the tokens array. - if (!token) { - return tokens.length - 1; - } - - /* - * For the map of "comment's location -> token's index", it points the next token of a comment. - * In that case, -1 is necessary. - */ - if (token.range[1] > endLoc) { - return index - 1; - } - return index; - } - return tokens.length - 1; -}; diff --git a/tools/eslint/node_modules/eslint/lib/languages/js/validate-language-options.js b/tools/eslint/node_modules/eslint/lib/languages/js/validate-language-options.js deleted file mode 100644 index ba1e5e39b83d70..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/languages/js/validate-language-options.js +++ /dev/null @@ -1,181 +0,0 @@ -/** - * @fileoverview The schema to validate language options - * @author Nicholas C. Zakas - */ - -"use strict"; - -//----------------------------------------------------------------------------- -// Data -//----------------------------------------------------------------------------- - -const globalVariablesValues = new Set([ - true, "true", "writable", "writeable", - false, "false", "readonly", "readable", null, - "off" -]); - -//------------------------------------------------------------------------------ -// Helpers -//------------------------------------------------------------------------------ - -/** - * Check if a value is a non-null object. - * @param {any} value The value to check. - * @returns {boolean} `true` if the value is a non-null object. - */ -function isNonNullObject(value) { - return typeof value === "object" && value !== null; -} - -/** - * Check if a value is a non-null non-array object. - * @param {any} value The value to check. - * @returns {boolean} `true` if the value is a non-null non-array object. - */ -function isNonArrayObject(value) { - return isNonNullObject(value) && !Array.isArray(value); -} - -/** - * Check if a value is undefined. - * @param {any} value The value to check. - * @returns {boolean} `true` if the value is undefined. - */ -function isUndefined(value) { - return typeof value === "undefined"; -} - -//----------------------------------------------------------------------------- -// Schemas -//----------------------------------------------------------------------------- - -/** - * Validates the ecmaVersion property. - * @param {string|number} ecmaVersion The value to check. - * @returns {void} - * @throws {TypeError} If the value is invalid. - */ -function validateEcmaVersion(ecmaVersion) { - - if (isUndefined(ecmaVersion)) { - throw new TypeError("Key \"ecmaVersion\": Expected an \"ecmaVersion\" property."); - } - - if (typeof ecmaVersion !== "number" && ecmaVersion !== "latest") { - throw new TypeError("Key \"ecmaVersion\": Expected a number or \"latest\"."); - } - -} - -/** - * Validates the sourceType property. - * @param {string} sourceType The value to check. - * @returns {void} - * @throws {TypeError} If the value is invalid. - */ -function validateSourceType(sourceType) { - - if (typeof sourceType !== "string" || !/^(?:script|module|commonjs)$/u.test(sourceType)) { - throw new TypeError("Key \"sourceType\": Expected \"script\", \"module\", or \"commonjs\"."); - } - -} - -/** - * Validates the globals property. - * @param {Object} globals The value to check. - * @returns {void} - * @throws {TypeError} If the value is invalid. - */ -function validateGlobals(globals) { - - if (!isNonArrayObject(globals)) { - throw new TypeError("Key \"globals\": Expected an object."); - } - - for (const key of Object.keys(globals)) { - - // avoid hairy edge case - if (key === "__proto__") { - continue; - } - - if (key !== key.trim()) { - throw new TypeError(`Key "globals": Global "${key}" has leading or trailing whitespace.`); - } - - if (!globalVariablesValues.has(globals[key])) { - throw new TypeError(`Key "globals": Key "${key}": Expected "readonly", "writable", or "off".`); - } - } -} - -/** - * Validates the parser property. - * @param {Object} parser The value to check. - * @returns {void} - * @throws {TypeError} If the value is invalid. - */ -function validateParser(parser) { - - if (!parser || typeof parser !== "object" || - (typeof parser.parse !== "function" && typeof parser.parseForESLint !== "function") - ) { - throw new TypeError("Key \"parser\": Expected object with parse() or parseForESLint() method."); - } - -} - -/** - * Validates the language options. - * @param {Object} languageOptions The language options to validate. - * @returns {void} - * @throws {TypeError} If the language options are invalid. - */ -function validateLanguageOptions(languageOptions) { - - if (!isNonArrayObject(languageOptions)) { - throw new TypeError("Expected an object."); - } - - const { - ecmaVersion, - sourceType, - globals, - parser, - parserOptions, - ...otherOptions - } = languageOptions; - - if ("ecmaVersion" in languageOptions) { - validateEcmaVersion(ecmaVersion); - } - - if ("sourceType" in languageOptions) { - validateSourceType(sourceType); - } - - if ("globals" in languageOptions) { - validateGlobals(globals); - } - - if ("parser" in languageOptions) { - validateParser(parser); - } - - if ("parserOptions" in languageOptions) { - if (!isNonArrayObject(parserOptions)) { - throw new TypeError("Key \"parserOptions\": Expected an object."); - } - } - - const otherOptionKeys = Object.keys(otherOptions); - - if (otherOptionKeys.length > 0) { - throw new TypeError(`Unexpected key "${otherOptionKeys[0]}" found.`); - } - -} - -module.exports = { validateLanguageOptions }; diff --git a/tools/eslint/node_modules/eslint/lib/linter/apply-disable-directives.js b/tools/eslint/node_modules/eslint/lib/linter/apply-disable-directives.js deleted file mode 100644 index 723bcf55015c2d..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/linter/apply-disable-directives.js +++ /dev/null @@ -1,501 +0,0 @@ -/** - * @fileoverview A module that filters reported problems based on `eslint-disable` and `eslint-enable` comments - * @author Teddy Katz - */ - -"use strict"; - -//------------------------------------------------------------------------------ -// Typedefs -//------------------------------------------------------------------------------ - -/** @typedef {import("../shared/types").LintMessage} LintMessage */ -/** @typedef {import("@eslint/core").Language} Language */ -/** @typedef {import("@eslint/core").Position} Position */ -/** @typedef {import("@eslint/core").RulesConfig} RulesConfig */ - -//------------------------------------------------------------------------------ -// Module Definition -//------------------------------------------------------------------------------ - -const escapeRegExp = require("escape-string-regexp"); -const { - Legacy: { - ConfigOps - } -} = require("@eslint/eslintrc/universal"); - -/** - * Compares the locations of two objects in a source file - * @param {Position} itemA The first object - * @param {Position} itemB The second object - * @returns {number} A value less than 1 if itemA appears before itemB in the source file, greater than 1 if - * itemA appears after itemB in the source file, or 0 if itemA and itemB have the same location. - */ -function compareLocations(itemA, itemB) { - return itemA.line - itemB.line || itemA.column - itemB.column; -} - -/** - * Groups a set of directives into sub-arrays by their parent comment. - * @param {Iterable} directives Unused directives to be removed. - * @returns {Directive[][]} Directives grouped by their parent comment. - */ -function groupByParentDirective(directives) { - const groups = new Map(); - - for (const directive of directives) { - const { unprocessedDirective: { parentDirective } } = directive; - - if (groups.has(parentDirective)) { - groups.get(parentDirective).push(directive); - } else { - groups.set(parentDirective, [directive]); - } - } - - return [...groups.values()]; -} - -/** - * Creates removal details for a set of directives within the same comment. - * @param {Directive[]} directives Unused directives to be removed. - * @param {Token} node The backing Comment token. - * @returns {{ description, fix, unprocessedDirective }[]} Details for later creation of output Problems. - */ -function createIndividualDirectivesRemoval(directives, node) { - - /* - * `node.value` starts right after `//` or `/*`. - * All calculated offsets will be relative to this index. - */ - const commentValueStart = node.range[0] + "//".length; - - // Find where the list of rules starts. `\S+` matches with the directive name (e.g. `eslint-disable-line`) - const listStartOffset = /^\s*\S+\s+/u.exec(node.value)[0].length; - - /* - * Get the list text without any surrounding whitespace. In order to preserve the original - * formatting, we don't want to change that whitespace. - * - * // eslint-disable-line rule-one , rule-two , rule-three -- comment - * ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - */ - const listText = node.value - .slice(listStartOffset) // remove directive name and all whitespace before the list - .split(/\s-{2,}\s/u)[0] // remove `-- comment`, if it exists - .trimEnd(); // remove all whitespace after the list - - /* - * We can assume that `listText` contains multiple elements. - * Otherwise, this function wouldn't be called - if there is - * only one rule in the list, then the whole comment must be removed. - */ - - return directives.map(directive => { - const { ruleId } = directive; - - const regex = new RegExp(String.raw`(?:^|\s*,\s*)(?['"]?)${escapeRegExp(ruleId)}\k(?:\s*,\s*|$)`, "u"); - const match = regex.exec(listText); - const matchedText = match[0]; - const matchStartOffset = listStartOffset + match.index; - const matchEndOffset = matchStartOffset + matchedText.length; - - const firstIndexOfComma = matchedText.indexOf(","); - const lastIndexOfComma = matchedText.lastIndexOf(","); - - let removalStartOffset, removalEndOffset; - - if (firstIndexOfComma !== lastIndexOfComma) { - - /* - * Since there are two commas, this must one of the elements in the middle of the list. - * Matched range starts where the previous rule name ends, and ends where the next rule name starts. - * - * // eslint-disable-line rule-one , rule-two , rule-three -- comment - * ^^^^^^^^^^^^^^ - * - * We want to remove only the content between the two commas, and also one of the commas. - * - * // eslint-disable-line rule-one , rule-two , rule-three -- comment - * ^^^^^^^^^^^ - */ - removalStartOffset = matchStartOffset + firstIndexOfComma; - removalEndOffset = matchStartOffset + lastIndexOfComma; - - } else { - - /* - * This is either the first element or the last element. - * - * If this is the first element, matched range starts where the first rule name starts - * and ends where the second rule name starts. This is exactly the range we want - * to remove so that the second rule name will start where the first one was starting - * and thus preserve the original formatting. - * - * // eslint-disable-line rule-one , rule-two , rule-three -- comment - * ^^^^^^^^^^^ - * - * Similarly, if this is the last element, we've already matched the range we want to - * remove. The previous rule name will end where the last one was ending, relative - * to the content on the right side. - * - * // eslint-disable-line rule-one , rule-two , rule-three -- comment - * ^^^^^^^^^^^^^ - */ - removalStartOffset = matchStartOffset; - removalEndOffset = matchEndOffset; - } - - return { - description: `'${ruleId}'`, - fix: { - range: [ - commentValueStart + removalStartOffset, - commentValueStart + removalEndOffset - ], - text: "" - }, - unprocessedDirective: directive.unprocessedDirective - }; - }); -} - -/** - * Creates a description of deleting an entire unused disable directive. - * @param {Directive[]} directives Unused directives to be removed. - * @param {Token} node The backing Comment token. - * @returns {{ description, fix, unprocessedDirective }} Details for later creation of an output problem. - */ -function createDirectiveRemoval(directives, node) { - const { range } = node; - const ruleIds = directives.filter(directive => directive.ruleId).map(directive => `'${directive.ruleId}'`); - - return { - description: ruleIds.length <= 2 - ? ruleIds.join(" or ") - : `${ruleIds.slice(0, ruleIds.length - 1).join(", ")}, or ${ruleIds.at(-1)}`, - fix: { - range, - text: " " - }, - unprocessedDirective: directives[0].unprocessedDirective - }; -} - -/** - * Parses details from directives to create output Problems. - * @param {Iterable} allDirectives Unused directives to be removed. - * @returns {{ description, fix, unprocessedDirective }[]} Details for later creation of output Problems. - */ -function processUnusedDirectives(allDirectives) { - const directiveGroups = groupByParentDirective(allDirectives); - - return directiveGroups.flatMap( - directives => { - const { parentDirective } = directives[0].unprocessedDirective; - const remainingRuleIds = new Set(parentDirective.ruleIds); - - for (const directive of directives) { - remainingRuleIds.delete(directive.ruleId); - } - - return remainingRuleIds.size - ? createIndividualDirectivesRemoval(directives, parentDirective.node) - : [createDirectiveRemoval(directives, parentDirective.node)]; - } - ); -} - -/** - * Collect eslint-enable comments that are removing suppressions by eslint-disable comments. - * @param {Directive[]} directives The directives to check. - * @returns {Set} The used eslint-enable comments - */ -function collectUsedEnableDirectives(directives) { - - /** - * A Map of `eslint-enable` keyed by ruleIds that may be marked as used. - * If `eslint-enable` does not have a ruleId, the key will be `null`. - * @type {Map} - */ - const enabledRules = new Map(); - - /** - * A Set of `eslint-enable` marked as used. - * It is also the return value of `collectUsedEnableDirectives` function. - * @type {Set} - */ - const usedEnableDirectives = new Set(); - - /* - * Checks the directives backwards to see if the encountered `eslint-enable` is used by the previous `eslint-disable`, - * and if so, stores the `eslint-enable` in `usedEnableDirectives`. - */ - for (let index = directives.length - 1; index >= 0; index--) { - const directive = directives[index]; - - if (directive.type === "disable") { - if (enabledRules.size === 0) { - continue; - } - if (directive.ruleId === null) { - - // If encounter `eslint-disable` without ruleId, - // mark all `eslint-enable` currently held in enabledRules as used. - // e.g. - // /* eslint-disable */ <- current directive - // /* eslint-enable rule-id1 */ <- used - // /* eslint-enable rule-id2 */ <- used - // /* eslint-enable */ <- used - for (const enableDirective of enabledRules.values()) { - usedEnableDirectives.add(enableDirective); - } - enabledRules.clear(); - } else { - const enableDirective = enabledRules.get(directive.ruleId); - - if (enableDirective) { - - // If encounter `eslint-disable` with ruleId, and there is an `eslint-enable` with the same ruleId in enabledRules, - // mark `eslint-enable` with ruleId as used. - // e.g. - // /* eslint-disable rule-id */ <- current directive - // /* eslint-enable rule-id */ <- used - usedEnableDirectives.add(enableDirective); - } else { - const enabledDirectiveWithoutRuleId = enabledRules.get(null); - - if (enabledDirectiveWithoutRuleId) { - - // If encounter `eslint-disable` with ruleId, and there is no `eslint-enable` with the same ruleId in enabledRules, - // mark `eslint-enable` without ruleId as used. - // e.g. - // /* eslint-disable rule-id */ <- current directive - // /* eslint-enable */ <- used - usedEnableDirectives.add(enabledDirectiveWithoutRuleId); - } - } - } - } else if (directive.type === "enable") { - if (directive.ruleId === null) { - - // If encounter `eslint-enable` without ruleId, the `eslint-enable` that follows it are unused. - // So clear enabledRules. - // e.g. - // /* eslint-enable */ <- current directive - // /* eslint-enable rule-id *// <- unused - // /* eslint-enable */ <- unused - enabledRules.clear(); - enabledRules.set(null, directive); - } else { - enabledRules.set(directive.ruleId, directive); - } - } - } - return usedEnableDirectives; -} - -/** - * This is the same as the exported function, except that it - * doesn't handle disable-line and disable-next-line directives, and it always reports unused - * disable directives. - * @param {Object} options options for applying directives. This is the same as the options - * for the exported function, except that `reportUnusedDisableDirectives` is not supported - * (this function always reports unused disable directives). - * @returns {{problems: LintMessage[], unusedDirectives: LintMessage[]}} An object with a list - * of problems (including suppressed ones) and unused eslint-disable directives - */ -function applyDirectives(options) { - const problems = []; - const usedDisableDirectives = new Set(); - - for (const problem of options.problems) { - let disableDirectivesForProblem = []; - let nextDirectiveIndex = 0; - - while ( - nextDirectiveIndex < options.directives.length && - compareLocations(options.directives[nextDirectiveIndex], problem) <= 0 - ) { - const directive = options.directives[nextDirectiveIndex++]; - - if (directive.ruleId === null || directive.ruleId === problem.ruleId) { - switch (directive.type) { - case "disable": - disableDirectivesForProblem.push(directive); - break; - - case "enable": - disableDirectivesForProblem = []; - break; - - // no default - } - } - } - - if (disableDirectivesForProblem.length > 0) { - const suppressions = disableDirectivesForProblem.map(directive => ({ - kind: "directive", - justification: directive.unprocessedDirective.justification - })); - - if (problem.suppressions) { - problem.suppressions = problem.suppressions.concat(suppressions); - } else { - problem.suppressions = suppressions; - usedDisableDirectives.add(disableDirectivesForProblem.at(-1)); - } - } - - problems.push(problem); - } - - const unusedDisableDirectivesToReport = options.directives - .filter(directive => directive.type === "disable" && !usedDisableDirectives.has(directive) && !options.rulesToIgnore.has(directive.ruleId)); - - - const unusedEnableDirectivesToReport = new Set( - options.directives.filter(directive => directive.unprocessedDirective.type === "enable" && !options.rulesToIgnore.has(directive.ruleId)) - ); - - /* - * If directives has the eslint-enable directive, - * check whether the eslint-enable comment is used. - */ - if (unusedEnableDirectivesToReport.size > 0) { - for (const directive of collectUsedEnableDirectives(options.directives)) { - unusedEnableDirectivesToReport.delete(directive); - } - } - - const processed = processUnusedDirectives(unusedDisableDirectivesToReport) - .concat(processUnusedDirectives(unusedEnableDirectivesToReport)); - const columnOffset = options.language.columnStart === 1 ? 0 : 1; - const lineOffset = options.language.lineStart === 1 ? 0 : 1; - - const unusedDirectives = processed - .map(({ description, fix, unprocessedDirective }) => { - const { parentDirective, type, line, column } = unprocessedDirective; - - let message; - - if (type === "enable") { - message = description - ? `Unused eslint-enable directive (no matching eslint-disable directives were found for ${description}).` - : "Unused eslint-enable directive (no matching eslint-disable directives were found)."; - } else { - message = description - ? `Unused eslint-disable directive (no problems were reported from ${description}).` - : "Unused eslint-disable directive (no problems were reported)."; - } - return { - ruleId: null, - message, - line: type === "disable-next-line" ? parentDirective.node.loc.start.line + lineOffset : line, - column: type === "disable-next-line" ? parentDirective.node.loc.start.column + columnOffset : column, - severity: options.reportUnusedDisableDirectives === "warn" ? 1 : 2, - nodeType: null, - ...options.disableFixes ? {} : { fix } - }; - }); - - return { problems, unusedDirectives }; -} - -/** - * Given a list of directive comments (i.e. metadata about eslint-disable and eslint-enable comments) and a list - * of reported problems, adds the suppression information to the problems. - * @param {Object} options Information about directives and problems - * @param {Language} options.language The language being linted. - * @param {{ - * type: ("disable"|"enable"|"disable-line"|"disable-next-line"), - * ruleId: (string|null), - * line: number, - * column: number, - * justification: string - * }} options.directives Directive comments found in the file, with one-based columns. - * Two directive comments can only have the same location if they also have the same type (e.g. a single eslint-disable - * comment for two different rules is represented as two directives). - * @param {{ruleId: (string|null), line: number, column: number}[]} options.problems - * A list of problems reported by rules, sorted by increasing location in the file, with one-based columns. - * @param {"off" | "warn" | "error"} options.reportUnusedDisableDirectives If `"warn"` or `"error"`, adds additional problems for unused directives - * @param {RulesConfig} options.configuredRules The rules configuration. - * @param {Function} options.ruleFilter A predicate function to filter which rules should be executed. - * @param {boolean} options.disableFixes If true, it doesn't make `fix` properties. - * @returns {{ruleId: (string|null), line: number, column: number, suppressions?: {kind: string, justification: string}}[]} - * An object with a list of reported problems, the suppressed of which contain the suppression information. - */ -module.exports = ({ language, directives, disableFixes, problems, configuredRules, ruleFilter, reportUnusedDisableDirectives = "off" }) => { - const blockDirectives = directives - .filter(directive => directive.type === "disable" || directive.type === "enable") - .map(directive => Object.assign({}, directive, { unprocessedDirective: directive })) - .sort(compareLocations); - - const lineDirectives = directives.flatMap(directive => { - switch (directive.type) { - case "disable": - case "enable": - return []; - - case "disable-line": - return [ - { type: "disable", line: directive.line, column: 1, ruleId: directive.ruleId, unprocessedDirective: directive }, - { type: "enable", line: directive.line + 1, column: 0, ruleId: directive.ruleId, unprocessedDirective: directive } - ]; - - case "disable-next-line": - return [ - { type: "disable", line: directive.line + 1, column: 1, ruleId: directive.ruleId, unprocessedDirective: directive }, - { type: "enable", line: directive.line + 2, column: 0, ruleId: directive.ruleId, unprocessedDirective: directive } - ]; - - default: - throw new TypeError(`Unrecognized directive type '${directive.type}'`); - } - }).sort(compareLocations); - - // This determines a list of rules that are not being run by the given ruleFilter, if present. - const rulesToIgnore = configuredRules && ruleFilter - ? new Set(Object.keys(configuredRules).filter(ruleId => { - const severity = ConfigOps.getRuleSeverity(configuredRules[ruleId]); - - // Ignore for disabled rules. - if (severity === 0) { - return false; - } - - return !ruleFilter({ severity, ruleId }); - })) - : new Set(); - - // If no ruleId is supplied that means this directive is applied to all rules, so we can't determine if it's unused if any rules are filtered out. - if (rulesToIgnore.size > 0) { - rulesToIgnore.add(null); - } - - const blockDirectivesResult = applyDirectives({ - language, - problems, - directives: blockDirectives, - disableFixes, - reportUnusedDisableDirectives, - rulesToIgnore - }); - const lineDirectivesResult = applyDirectives({ - language, - problems: blockDirectivesResult.problems, - directives: lineDirectives, - disableFixes, - reportUnusedDisableDirectives, - rulesToIgnore - }); - - return reportUnusedDisableDirectives !== "off" - ? lineDirectivesResult.problems - .concat(blockDirectivesResult.unusedDirectives) - .concat(lineDirectivesResult.unusedDirectives) - .sort(compareLocations) - : lineDirectivesResult.problems; -}; diff --git a/tools/eslint/node_modules/eslint/lib/linter/code-path-analysis/code-path-analyzer.js b/tools/eslint/node_modules/eslint/lib/linter/code-path-analysis/code-path-analyzer.js deleted file mode 100644 index 16e9d18aa64df1..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/linter/code-path-analysis/code-path-analyzer.js +++ /dev/null @@ -1,851 +0,0 @@ -/** - * @fileoverview A class of the code path analyzer. - * @author Toru Nagashima - */ - -"use strict"; - -//------------------------------------------------------------------------------ -// Requirements -//------------------------------------------------------------------------------ - -const assert = require("node:assert"), - { breakableTypePattern } = require("../../shared/ast-utils"), - CodePath = require("./code-path"), - CodePathSegment = require("./code-path-segment"), - IdGenerator = require("./id-generator"), - debug = require("./debug-helpers"); - -//------------------------------------------------------------------------------ -// Helpers -//------------------------------------------------------------------------------ - -/** - * Checks whether or not a given node is a `case` node (not `default` node). - * @param {ASTNode} node A `SwitchCase` node to check. - * @returns {boolean} `true` if the node is a `case` node (not `default` node). - */ -function isCaseNode(node) { - return Boolean(node.test); -} - -/** - * Checks if a given node appears as the value of a PropertyDefinition node. - * @param {ASTNode} node THe node to check. - * @returns {boolean} `true` if the node is a PropertyDefinition value, - * false if not. - */ -function isPropertyDefinitionValue(node) { - const parent = node.parent; - - return parent && parent.type === "PropertyDefinition" && parent.value === node; -} - -/** - * Checks whether the given logical operator is taken into account for the code - * path analysis. - * @param {string} operator The operator found in the LogicalExpression node - * @returns {boolean} `true` if the operator is "&&" or "||" or "??" - */ -function isHandledLogicalOperator(operator) { - return operator === "&&" || operator === "||" || operator === "??"; -} - -/** - * Checks whether the given assignment operator is a logical assignment operator. - * Logical assignments are taken into account for the code path analysis - * because of their short-circuiting semantics. - * @param {string} operator The operator found in the AssignmentExpression node - * @returns {boolean} `true` if the operator is "&&=" or "||=" or "??=" - */ -function isLogicalAssignmentOperator(operator) { - return operator === "&&=" || operator === "||=" || operator === "??="; -} - -/** - * Gets the label if the parent node of a given node is a LabeledStatement. - * @param {ASTNode} node A node to get. - * @returns {string|null} The label or `null`. - */ -function getLabel(node) { - if (node.parent.type === "LabeledStatement") { - return node.parent.label.name; - } - return null; -} - -/** - * Checks whether or not a given logical expression node goes different path - * between the `true` case and the `false` case. - * @param {ASTNode} node A node to check. - * @returns {boolean} `true` if the node is a test of a choice statement. - */ -function isForkingByTrueOrFalse(node) { - const parent = node.parent; - - switch (parent.type) { - case "ConditionalExpression": - case "IfStatement": - case "WhileStatement": - case "DoWhileStatement": - case "ForStatement": - return parent.test === node; - - case "LogicalExpression": - return isHandledLogicalOperator(parent.operator); - - case "AssignmentExpression": - return isLogicalAssignmentOperator(parent.operator); - - default: - return false; - } -} - -/** - * Gets the boolean value of a given literal node. - * - * This is used to detect infinity loops (e.g. `while (true) {}`). - * Statements preceded by an infinity loop are unreachable if the loop didn't - * have any `break` statement. - * @param {ASTNode} node A node to get. - * @returns {boolean|undefined} a boolean value if the node is a Literal node, - * otherwise `undefined`. - */ -function getBooleanValueIfSimpleConstant(node) { - if (node.type === "Literal") { - return Boolean(node.value); - } - return void 0; -} - -/** - * Checks that a given identifier node is a reference or not. - * - * This is used to detect the first throwable node in a `try` block. - * @param {ASTNode} node An Identifier node to check. - * @returns {boolean} `true` if the node is a reference. - */ -function isIdentifierReference(node) { - const parent = node.parent; - - switch (parent.type) { - case "LabeledStatement": - case "BreakStatement": - case "ContinueStatement": - case "ArrayPattern": - case "RestElement": - case "ImportSpecifier": - case "ImportDefaultSpecifier": - case "ImportNamespaceSpecifier": - case "CatchClause": - return false; - - case "FunctionDeclaration": - case "FunctionExpression": - case "ArrowFunctionExpression": - case "ClassDeclaration": - case "ClassExpression": - case "VariableDeclarator": - return parent.id !== node; - - case "Property": - case "PropertyDefinition": - case "MethodDefinition": - return ( - parent.key !== node || - parent.computed || - parent.shorthand - ); - - case "AssignmentPattern": - return parent.key !== node; - - default: - return true; - } -} - -/** - * Updates the current segment with the head segment. - * This is similar to local branches and tracking branches of git. - * - * To separate the current and the head is in order to not make useless segments. - * - * In this process, both "onCodePathSegmentStart" and "onCodePathSegmentEnd" - * events are fired. - * @param {CodePathAnalyzer} analyzer The instance. - * @param {ASTNode} node The current AST node. - * @returns {void} - */ -function forwardCurrentToHead(analyzer, node) { - const codePath = analyzer.codePath; - const state = CodePath.getState(codePath); - const currentSegments = state.currentSegments; - const headSegments = state.headSegments; - const end = Math.max(currentSegments.length, headSegments.length); - let i, currentSegment, headSegment; - - // Fires leaving events. - for (i = 0; i < end; ++i) { - currentSegment = currentSegments[i]; - headSegment = headSegments[i]; - - if (currentSegment !== headSegment && currentSegment) { - - const eventName = currentSegment.reachable - ? "onCodePathSegmentEnd" - : "onUnreachableCodePathSegmentEnd"; - - debug.dump(`${eventName} ${currentSegment.id}`); - - analyzer.emitter.emit( - eventName, - currentSegment, - node - ); - } - } - - // Update state. - state.currentSegments = headSegments; - - // Fires entering events. - for (i = 0; i < end; ++i) { - currentSegment = currentSegments[i]; - headSegment = headSegments[i]; - - if (currentSegment !== headSegment && headSegment) { - - const eventName = headSegment.reachable - ? "onCodePathSegmentStart" - : "onUnreachableCodePathSegmentStart"; - - debug.dump(`${eventName} ${headSegment.id}`); - CodePathSegment.markUsed(headSegment); - analyzer.emitter.emit( - eventName, - headSegment, - node - ); - } - } - -} - -/** - * Updates the current segment with empty. - * This is called at the last of functions or the program. - * @param {CodePathAnalyzer} analyzer The instance. - * @param {ASTNode} node The current AST node. - * @returns {void} - */ -function leaveFromCurrentSegment(analyzer, node) { - const state = CodePath.getState(analyzer.codePath); - const currentSegments = state.currentSegments; - - for (let i = 0; i < currentSegments.length; ++i) { - const currentSegment = currentSegments[i]; - const eventName = currentSegment.reachable - ? "onCodePathSegmentEnd" - : "onUnreachableCodePathSegmentEnd"; - - debug.dump(`${eventName} ${currentSegment.id}`); - - analyzer.emitter.emit( - eventName, - currentSegment, - node - ); - } - - state.currentSegments = []; -} - -/** - * Updates the code path due to the position of a given node in the parent node - * thereof. - * - * For example, if the node is `parent.consequent`, this creates a fork from the - * current path. - * @param {CodePathAnalyzer} analyzer The instance. - * @param {ASTNode} node The current AST node. - * @returns {void} - */ -function preprocess(analyzer, node) { - const codePath = analyzer.codePath; - const state = CodePath.getState(codePath); - const parent = node.parent; - - switch (parent.type) { - - // The `arguments.length == 0` case is in `postprocess` function. - case "CallExpression": - if (parent.optional === true && parent.arguments.length >= 1 && parent.arguments[0] === node) { - state.makeOptionalRight(); - } - break; - case "MemberExpression": - if (parent.optional === true && parent.property === node) { - state.makeOptionalRight(); - } - break; - - case "LogicalExpression": - if ( - parent.right === node && - isHandledLogicalOperator(parent.operator) - ) { - state.makeLogicalRight(); - } - break; - - case "AssignmentExpression": - if ( - parent.right === node && - isLogicalAssignmentOperator(parent.operator) - ) { - state.makeLogicalRight(); - } - break; - - case "ConditionalExpression": - case "IfStatement": - - /* - * Fork if this node is at `consequent`/`alternate`. - * `popForkContext()` exists at `IfStatement:exit` and - * `ConditionalExpression:exit`. - */ - if (parent.consequent === node) { - state.makeIfConsequent(); - } else if (parent.alternate === node) { - state.makeIfAlternate(); - } - break; - - case "SwitchCase": - if (parent.consequent[0] === node) { - state.makeSwitchCaseBody(false, !parent.test); - } - break; - - case "TryStatement": - if (parent.handler === node) { - state.makeCatchBlock(); - } else if (parent.finalizer === node) { - state.makeFinallyBlock(); - } - break; - - case "WhileStatement": - if (parent.test === node) { - state.makeWhileTest(getBooleanValueIfSimpleConstant(node)); - } else { - assert(parent.body === node); - state.makeWhileBody(); - } - break; - - case "DoWhileStatement": - if (parent.body === node) { - state.makeDoWhileBody(); - } else { - assert(parent.test === node); - state.makeDoWhileTest(getBooleanValueIfSimpleConstant(node)); - } - break; - - case "ForStatement": - if (parent.test === node) { - state.makeForTest(getBooleanValueIfSimpleConstant(node)); - } else if (parent.update === node) { - state.makeForUpdate(); - } else if (parent.body === node) { - state.makeForBody(); - } - break; - - case "ForInStatement": - case "ForOfStatement": - if (parent.left === node) { - state.makeForInOfLeft(); - } else if (parent.right === node) { - state.makeForInOfRight(); - } else { - assert(parent.body === node); - state.makeForInOfBody(); - } - break; - - case "AssignmentPattern": - - /* - * Fork if this node is at `right`. - * `left` is executed always, so it uses the current path. - * `popForkContext()` exists at `AssignmentPattern:exit`. - */ - if (parent.right === node) { - state.pushForkContext(); - state.forkBypassPath(); - state.forkPath(); - } - break; - - default: - break; - } -} - -/** - * Updates the code path due to the type of a given node in entering. - * @param {CodePathAnalyzer} analyzer The instance. - * @param {ASTNode} node The current AST node. - * @returns {void} - */ -function processCodePathToEnter(analyzer, node) { - let codePath = analyzer.codePath; - let state = codePath && CodePath.getState(codePath); - const parent = node.parent; - - /** - * Creates a new code path and trigger the onCodePathStart event - * based on the currently selected node. - * @param {string} origin The reason the code path was started. - * @returns {void} - */ - function startCodePath(origin) { - if (codePath) { - - // Emits onCodePathSegmentStart events if updated. - forwardCurrentToHead(analyzer, node); - debug.dumpState(node, state, false); - } - - // Create the code path of this scope. - codePath = analyzer.codePath = new CodePath({ - id: analyzer.idGenerator.next(), - origin, - upper: codePath, - onLooped: analyzer.onLooped - }); - state = CodePath.getState(codePath); - - // Emits onCodePathStart events. - debug.dump(`onCodePathStart ${codePath.id}`); - analyzer.emitter.emit("onCodePathStart", codePath, node); - } - - /* - * Special case: The right side of class field initializer is considered - * to be its own function, so we need to start a new code path in this - * case. - */ - if (isPropertyDefinitionValue(node)) { - startCodePath("class-field-initializer"); - - /* - * Intentional fall through because `node` needs to also be - * processed by the code below. For example, if we have: - * - * class Foo { - * a = () => {} - * } - * - * In this case, we also need start a second code path. - */ - - } - - switch (node.type) { - case "Program": - startCodePath("program"); - break; - - case "FunctionDeclaration": - case "FunctionExpression": - case "ArrowFunctionExpression": - startCodePath("function"); - break; - - case "StaticBlock": - startCodePath("class-static-block"); - break; - - case "ChainExpression": - state.pushChainContext(); - break; - case "CallExpression": - if (node.optional === true) { - state.makeOptionalNode(); - } - break; - case "MemberExpression": - if (node.optional === true) { - state.makeOptionalNode(); - } - break; - - case "LogicalExpression": - if (isHandledLogicalOperator(node.operator)) { - state.pushChoiceContext( - node.operator, - isForkingByTrueOrFalse(node) - ); - } - break; - - case "AssignmentExpression": - if (isLogicalAssignmentOperator(node.operator)) { - state.pushChoiceContext( - node.operator.slice(0, -1), // removes `=` from the end - isForkingByTrueOrFalse(node) - ); - } - break; - - case "ConditionalExpression": - case "IfStatement": - state.pushChoiceContext("test", false); - break; - - case "SwitchStatement": - state.pushSwitchContext( - node.cases.some(isCaseNode), - getLabel(node) - ); - break; - - case "TryStatement": - state.pushTryContext(Boolean(node.finalizer)); - break; - - case "SwitchCase": - - /* - * Fork if this node is after the 2st node in `cases`. - * It's similar to `else` blocks. - * The next `test` node is processed in this path. - */ - if (parent.discriminant !== node && parent.cases[0] !== node) { - state.forkPath(); - } - break; - - case "WhileStatement": - case "DoWhileStatement": - case "ForStatement": - case "ForInStatement": - case "ForOfStatement": - state.pushLoopContext(node.type, getLabel(node)); - break; - - case "LabeledStatement": - if (!breakableTypePattern.test(node.body.type)) { - state.pushBreakContext(false, node.label.name); - } - break; - - default: - break; - } - - // Emits onCodePathSegmentStart events if updated. - forwardCurrentToHead(analyzer, node); - debug.dumpState(node, state, false); -} - -/** - * Updates the code path due to the type of a given node in leaving. - * @param {CodePathAnalyzer} analyzer The instance. - * @param {ASTNode} node The current AST node. - * @returns {void} - */ -function processCodePathToExit(analyzer, node) { - - const codePath = analyzer.codePath; - const state = CodePath.getState(codePath); - let dontForward = false; - - switch (node.type) { - case "ChainExpression": - state.popChainContext(); - break; - - case "IfStatement": - case "ConditionalExpression": - state.popChoiceContext(); - break; - - case "LogicalExpression": - if (isHandledLogicalOperator(node.operator)) { - state.popChoiceContext(); - } - break; - - case "AssignmentExpression": - if (isLogicalAssignmentOperator(node.operator)) { - state.popChoiceContext(); - } - break; - - case "SwitchStatement": - state.popSwitchContext(); - break; - - case "SwitchCase": - - /* - * This is the same as the process at the 1st `consequent` node in - * `preprocess` function. - * Must do if this `consequent` is empty. - */ - if (node.consequent.length === 0) { - state.makeSwitchCaseBody(true, !node.test); - } - if (state.forkContext.reachable) { - dontForward = true; - } - break; - - case "TryStatement": - state.popTryContext(); - break; - - case "BreakStatement": - forwardCurrentToHead(analyzer, node); - state.makeBreak(node.label && node.label.name); - dontForward = true; - break; - - case "ContinueStatement": - forwardCurrentToHead(analyzer, node); - state.makeContinue(node.label && node.label.name); - dontForward = true; - break; - - case "ReturnStatement": - forwardCurrentToHead(analyzer, node); - state.makeReturn(); - dontForward = true; - break; - - case "ThrowStatement": - forwardCurrentToHead(analyzer, node); - state.makeThrow(); - dontForward = true; - break; - - case "Identifier": - if (isIdentifierReference(node)) { - state.makeFirstThrowablePathInTryBlock(); - dontForward = true; - } - break; - - case "CallExpression": - case "ImportExpression": - case "MemberExpression": - case "NewExpression": - case "YieldExpression": - state.makeFirstThrowablePathInTryBlock(); - break; - - case "WhileStatement": - case "DoWhileStatement": - case "ForStatement": - case "ForInStatement": - case "ForOfStatement": - state.popLoopContext(); - break; - - case "AssignmentPattern": - state.popForkContext(); - break; - - case "LabeledStatement": - if (!breakableTypePattern.test(node.body.type)) { - state.popBreakContext(); - } - break; - - default: - break; - } - - // Emits onCodePathSegmentStart events if updated. - if (!dontForward) { - forwardCurrentToHead(analyzer, node); - } - debug.dumpState(node, state, true); -} - -/** - * Updates the code path to finalize the current code path. - * @param {CodePathAnalyzer} analyzer The instance. - * @param {ASTNode} node The current AST node. - * @returns {void} - */ -function postprocess(analyzer, node) { - - /** - * Ends the code path for the current node. - * @returns {void} - */ - function endCodePath() { - let codePath = analyzer.codePath; - - // Mark the current path as the final node. - CodePath.getState(codePath).makeFinal(); - - // Emits onCodePathSegmentEnd event of the current segments. - leaveFromCurrentSegment(analyzer, node); - - // Emits onCodePathEnd event of this code path. - debug.dump(`onCodePathEnd ${codePath.id}`); - analyzer.emitter.emit("onCodePathEnd", codePath, node); - debug.dumpDot(codePath); - - codePath = analyzer.codePath = analyzer.codePath.upper; - if (codePath) { - debug.dumpState(node, CodePath.getState(codePath), true); - } - - } - - switch (node.type) { - case "Program": - case "FunctionDeclaration": - case "FunctionExpression": - case "ArrowFunctionExpression": - case "StaticBlock": { - endCodePath(); - break; - } - - // The `arguments.length >= 1` case is in `preprocess` function. - case "CallExpression": - if (node.optional === true && node.arguments.length === 0) { - CodePath.getState(analyzer.codePath).makeOptionalRight(); - } - break; - - default: - break; - } - - /* - * Special case: The right side of class field initializer is considered - * to be its own function, so we need to end a code path in this - * case. - * - * We need to check after the other checks in order to close the - * code paths in the correct order for code like this: - * - * - * class Foo { - * a = () => {} - * } - * - * In this case, The ArrowFunctionExpression code path is closed first - * and then we need to close the code path for the PropertyDefinition - * value. - */ - if (isPropertyDefinitionValue(node)) { - endCodePath(); - } -} - -//------------------------------------------------------------------------------ -// Public Interface -//------------------------------------------------------------------------------ - -/** - * The class to analyze code paths. - * This class implements the EventGenerator interface. - */ -class CodePathAnalyzer { - - /** - * @param {EventGenerator} eventGenerator An event generator to wrap. - */ - constructor(eventGenerator) { - this.original = eventGenerator; - this.emitter = eventGenerator.emitter; - this.codePath = null; - this.idGenerator = new IdGenerator("s"); - this.currentNode = null; - this.onLooped = this.onLooped.bind(this); - } - - /** - * Does the process to enter a given AST node. - * This updates state of analysis and calls `enterNode` of the wrapped. - * @param {ASTNode} node A node which is entering. - * @returns {void} - */ - enterNode(node) { - this.currentNode = node; - - // Updates the code path due to node's position in its parent node. - if (node.parent) { - preprocess(this, node); - } - - /* - * Updates the code path. - * And emits onCodePathStart/onCodePathSegmentStart events. - */ - processCodePathToEnter(this, node); - - // Emits node events. - this.original.enterNode(node); - - this.currentNode = null; - } - - /** - * Does the process to leave a given AST node. - * This updates state of analysis and calls `leaveNode` of the wrapped. - * @param {ASTNode} node A node which is leaving. - * @returns {void} - */ - leaveNode(node) { - this.currentNode = node; - - /* - * Updates the code path. - * And emits onCodePathStart/onCodePathSegmentStart events. - */ - processCodePathToExit(this, node); - - // Emits node events. - this.original.leaveNode(node); - - // Emits the last onCodePathStart/onCodePathSegmentStart events. - postprocess(this, node); - - this.currentNode = null; - } - - /** - * This is called on a code path looped. - * Then this raises a looped event. - * @param {CodePathSegment} fromSegment A segment of prev. - * @param {CodePathSegment} toSegment A segment of next. - * @returns {void} - */ - onLooped(fromSegment, toSegment) { - if (fromSegment.reachable && toSegment.reachable) { - debug.dump(`onCodePathSegmentLoop ${fromSegment.id} -> ${toSegment.id}`); - this.emitter.emit( - "onCodePathSegmentLoop", - fromSegment, - toSegment, - this.currentNode - ); - } - } -} - -module.exports = CodePathAnalyzer; diff --git a/tools/eslint/node_modules/eslint/lib/linter/code-path-analysis/code-path-segment.js b/tools/eslint/node_modules/eslint/lib/linter/code-path-analysis/code-path-segment.js deleted file mode 100644 index 3b8dbb41be64d5..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/linter/code-path-analysis/code-path-segment.js +++ /dev/null @@ -1,263 +0,0 @@ -/** - * @fileoverview The CodePathSegment class. - * @author Toru Nagashima - */ - -"use strict"; - -//------------------------------------------------------------------------------ -// Requirements -//------------------------------------------------------------------------------ - -const debug = require("./debug-helpers"); - -//------------------------------------------------------------------------------ -// Helpers -//------------------------------------------------------------------------------ - -/** - * Checks whether or not a given segment is reachable. - * @param {CodePathSegment} segment A segment to check. - * @returns {boolean} `true` if the segment is reachable. - */ -function isReachable(segment) { - return segment.reachable; -} - -//------------------------------------------------------------------------------ -// Public Interface -//------------------------------------------------------------------------------ - -/** - * A code path segment. - * - * Each segment is arranged in a series of linked lists (implemented by arrays) - * that keep track of the previous and next segments in a code path. In this way, - * you can navigate between all segments in any code path so long as you have a - * reference to any segment in that code path. - * - * When first created, the segment is in a detached state, meaning that it knows the - * segments that came before it but those segments don't know that this new segment - * follows it. Only when `CodePathSegment#markUsed()` is called on a segment does it - * officially become part of the code path by updating the previous segments to know - * that this new segment follows. - */ -class CodePathSegment { - - /** - * Creates a new instance. - * @param {string} id An identifier. - * @param {CodePathSegment[]} allPrevSegments An array of the previous segments. - * This array includes unreachable segments. - * @param {boolean} reachable A flag which shows this is reachable. - */ - constructor(id, allPrevSegments, reachable) { - - /** - * The identifier of this code path. - * Rules use it to store additional information of each rule. - * @type {string} - */ - this.id = id; - - /** - * An array of the next reachable segments. - * @type {CodePathSegment[]} - */ - this.nextSegments = []; - - /** - * An array of the previous reachable segments. - * @type {CodePathSegment[]} - */ - this.prevSegments = allPrevSegments.filter(isReachable); - - /** - * An array of all next segments including reachable and unreachable. - * @type {CodePathSegment[]} - */ - this.allNextSegments = []; - - /** - * An array of all previous segments including reachable and unreachable. - * @type {CodePathSegment[]} - */ - this.allPrevSegments = allPrevSegments; - - /** - * A flag which shows this is reachable. - * @type {boolean} - */ - this.reachable = reachable; - - // Internal data. - Object.defineProperty(this, "internal", { - value: { - - // determines if the segment has been attached to the code path - used: false, - - // array of previous segments coming from the end of a loop - loopedPrevSegments: [] - } - }); - - /* c8 ignore start */ - if (debug.enabled) { - this.internal.nodes = []; - }/* c8 ignore stop */ - } - - /** - * Checks a given previous segment is coming from the end of a loop. - * @param {CodePathSegment} segment A previous segment to check. - * @returns {boolean} `true` if the segment is coming from the end of a loop. - */ - isLoopedPrevSegment(segment) { - return this.internal.loopedPrevSegments.includes(segment); - } - - /** - * Creates the root segment. - * @param {string} id An identifier. - * @returns {CodePathSegment} The created segment. - */ - static newRoot(id) { - return new CodePathSegment(id, [], true); - } - - /** - * Creates a new segment and appends it after the given segments. - * @param {string} id An identifier. - * @param {CodePathSegment[]} allPrevSegments An array of the previous segments - * to append to. - * @returns {CodePathSegment} The created segment. - */ - static newNext(id, allPrevSegments) { - return new CodePathSegment( - id, - CodePathSegment.flattenUnusedSegments(allPrevSegments), - allPrevSegments.some(isReachable) - ); - } - - /** - * Creates an unreachable segment and appends it after the given segments. - * @param {string} id An identifier. - * @param {CodePathSegment[]} allPrevSegments An array of the previous segments. - * @returns {CodePathSegment} The created segment. - */ - static newUnreachable(id, allPrevSegments) { - const segment = new CodePathSegment(id, CodePathSegment.flattenUnusedSegments(allPrevSegments), false); - - /* - * In `if (a) return a; foo();` case, the unreachable segment preceded by - * the return statement is not used but must not be removed. - */ - CodePathSegment.markUsed(segment); - - return segment; - } - - /** - * Creates a segment that follows given segments. - * This factory method does not connect with `allPrevSegments`. - * But this inherits `reachable` flag. - * @param {string} id An identifier. - * @param {CodePathSegment[]} allPrevSegments An array of the previous segments. - * @returns {CodePathSegment} The created segment. - */ - static newDisconnected(id, allPrevSegments) { - return new CodePathSegment(id, [], allPrevSegments.some(isReachable)); - } - - /** - * Marks a given segment as used. - * - * And this function registers the segment into the previous segments as a next. - * @param {CodePathSegment} segment A segment to mark. - * @returns {void} - */ - static markUsed(segment) { - if (segment.internal.used) { - return; - } - segment.internal.used = true; - - let i; - - if (segment.reachable) { - - /* - * If the segment is reachable, then it's officially part of the - * code path. This loops through all previous segments to update - * their list of next segments. Because the segment is reachable, - * it's added to both `nextSegments` and `allNextSegments`. - */ - for (i = 0; i < segment.allPrevSegments.length; ++i) { - const prevSegment = segment.allPrevSegments[i]; - - prevSegment.allNextSegments.push(segment); - prevSegment.nextSegments.push(segment); - } - } else { - - /* - * If the segment is not reachable, then it's not officially part of the - * code path. This loops through all previous segments to update - * their list of next segments. Because the segment is not reachable, - * it's added only to `allNextSegments`. - */ - for (i = 0; i < segment.allPrevSegments.length; ++i) { - segment.allPrevSegments[i].allNextSegments.push(segment); - } - } - } - - /** - * Marks a previous segment as looped. - * @param {CodePathSegment} segment A segment. - * @param {CodePathSegment} prevSegment A previous segment to mark. - * @returns {void} - */ - static markPrevSegmentAsLooped(segment, prevSegment) { - segment.internal.loopedPrevSegments.push(prevSegment); - } - - /** - * Creates a new array based on an array of segments. If any segment in the - * array is unused, then it is replaced by all of its previous segments. - * All used segments are returned as-is without replacement. - * @param {CodePathSegment[]} segments The array of segments to flatten. - * @returns {CodePathSegment[]} The flattened array. - */ - static flattenUnusedSegments(segments) { - const done = new Set(); - - for (let i = 0; i < segments.length; ++i) { - const segment = segments[i]; - - // Ignores duplicated. - if (done.has(segment)) { - continue; - } - - // Use previous segments if unused. - if (!segment.internal.used) { - for (let j = 0; j < segment.allPrevSegments.length; ++j) { - const prevSegment = segment.allPrevSegments[j]; - - if (!done.has(prevSegment)) { - done.add(prevSegment); - } - } - } else { - done.add(segment); - } - } - - return [...done]; - } -} - -module.exports = CodePathSegment; diff --git a/tools/eslint/node_modules/eslint/lib/linter/code-path-analysis/code-path-state.js b/tools/eslint/node_modules/eslint/lib/linter/code-path-analysis/code-path-state.js deleted file mode 100644 index 2b0dc2bfca0403..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/linter/code-path-analysis/code-path-state.js +++ /dev/null @@ -1,2348 +0,0 @@ -/** - * @fileoverview A class to manage state of generating a code path. - * @author Toru Nagashima - */ - -"use strict"; - -//------------------------------------------------------------------------------ -// Requirements -//------------------------------------------------------------------------------ - -const CodePathSegment = require("./code-path-segment"), - ForkContext = require("./fork-context"); - -//----------------------------------------------------------------------------- -// Contexts -//----------------------------------------------------------------------------- - -/** - * Represents the context in which a `break` statement can be used. - * - * A `break` statement without a label is only valid in a few places in - * JavaScript: any type of loop or a `switch` statement. Otherwise, `break` - * without a label causes a syntax error. For these contexts, `breakable` is - * set to `true` to indicate that a `break` without a label is valid. - * - * However, a `break` statement with a label is also valid inside of a labeled - * statement. For example, this is valid: - * - * a : { - * break a; - * } - * - * The `breakable` property is set false for labeled statements to indicate - * that `break` without a label is invalid. - */ -class BreakContext { - - /** - * Creates a new instance. - * @param {BreakContext} upperContext The previous `BreakContext`. - * @param {boolean} breakable Indicates if we are inside a statement where - * `break` without a label will exit the statement. - * @param {string|null} label The label for the statement. - * @param {ForkContext} forkContext The current fork context. - */ - constructor(upperContext, breakable, label, forkContext) { - - /** - * The previous `BreakContext` - * @type {BreakContext} - */ - this.upper = upperContext; - - /** - * Indicates if we are inside a statement where `break` without a label - * will exit the statement. - * @type {boolean} - */ - this.breakable = breakable; - - /** - * The label associated with the statement. - * @type {string|null} - */ - this.label = label; - - /** - * The fork context for the `break`. - * @type {ForkContext} - */ - this.brokenForkContext = ForkContext.newEmpty(forkContext); - } -} - -/** - * Represents the context for `ChainExpression` nodes. - */ -class ChainContext { - - /** - * Creates a new instance. - * @param {ChainContext} upperContext The previous `ChainContext`. - */ - constructor(upperContext) { - - /** - * The previous `ChainContext` - * @type {ChainContext} - */ - this.upper = upperContext; - - /** - * The number of choice contexts inside of the `ChainContext`. - * @type {number} - */ - this.choiceContextCount = 0; - - } -} - -/** - * Represents a choice in the code path. - * - * Choices are created by logical operators such as `&&`, loops, conditionals, - * and `if` statements. This is the point at which the code path has a choice of - * which direction to go. - * - * The result of a choice might be in the left (test) expression of another choice, - * and in that case, may create a new fork. For example, `a || b` is a choice - * but does not create a new fork because the result of the expression is - * not used as the test expression in another expression. In this case, - * `isForkingAsResult` is false. In the expression `a || b || c`, the `a || b` - * expression appears as the test expression for `|| c`, so the - * result of `a || b` creates a fork because execution may or may not - * continue to `|| c`. `isForkingAsResult` for `a || b` in this case is true - * while `isForkingAsResult` for `|| c` is false. (`isForkingAsResult` is always - * false for `if` statements, conditional expressions, and loops.) - * - * All of the choices except one (`??`) operate on a true/false fork, meaning if - * true go one way and if false go the other (tracked by `trueForkContext` and - * `falseForkContext`). The `??` operator doesn't operate on true/false because - * the left expression is evaluated to be nullish or not, so only if nullish do - * we fork to the right expression (tracked by `nullishForkContext`). - */ -class ChoiceContext { - - /** - * Creates a new instance. - * @param {ChoiceContext} upperContext The previous `ChoiceContext`. - * @param {string} kind The kind of choice. If it's a logical or assignment expression, this - * is `"&&"` or `"||"` or `"??"`; if it's an `if` statement or - * conditional expression, this is `"test"`; otherwise, this is `"loop"`. - * @param {boolean} isForkingAsResult Indicates if the result of the choice - * creates a fork. - * @param {ForkContext} forkContext The containing `ForkContext`. - */ - constructor(upperContext, kind, isForkingAsResult, forkContext) { - - /** - * The previous `ChoiceContext` - * @type {ChoiceContext} - */ - this.upper = upperContext; - - /** - * The kind of choice. If it's a logical or assignment expression, this - * is `"&&"` or `"||"` or `"??"`; if it's an `if` statement or - * conditional expression, this is `"test"`; otherwise, this is `"loop"`. - * @type {string} - */ - this.kind = kind; - - /** - * Indicates if the result of the choice forks the code path. - * @type {boolean} - */ - this.isForkingAsResult = isForkingAsResult; - - /** - * The fork context for the `true` path of the choice. - * @type {ForkContext} - */ - this.trueForkContext = ForkContext.newEmpty(forkContext); - - /** - * The fork context for the `false` path of the choice. - * @type {ForkContext} - */ - this.falseForkContext = ForkContext.newEmpty(forkContext); - - /** - * The fork context for when the choice result is `null` or `undefined`. - * @type {ForkContext} - */ - this.nullishForkContext = ForkContext.newEmpty(forkContext); - - /** - * Indicates if any of `trueForkContext`, `falseForkContext`, or - * `nullishForkContext` have been updated with segments from a child context. - * @type {boolean} - */ - this.processed = false; - } - -} - -/** - * Base class for all loop contexts. - */ -class LoopContextBase { - - /** - * Creates a new instance. - * @param {LoopContext|null} upperContext The previous `LoopContext`. - * @param {string} type The AST node's `type` for the loop. - * @param {string|null} label The label for the loop from an enclosing `LabeledStatement`. - * @param {BreakContext} breakContext The context for breaking the loop. - */ - constructor(upperContext, type, label, breakContext) { - - /** - * The previous `LoopContext`. - * @type {LoopContext} - */ - this.upper = upperContext; - - /** - * The AST node's `type` for the loop. - * @type {string} - */ - this.type = type; - - /** - * The label for the loop from an enclosing `LabeledStatement`. - * @type {string|null} - */ - this.label = label; - - /** - * The fork context for when `break` is encountered. - * @type {ForkContext} - */ - this.brokenForkContext = breakContext.brokenForkContext; - } -} - -/** - * Represents the context for a `while` loop. - */ -class WhileLoopContext extends LoopContextBase { - - /** - * Creates a new instance. - * @param {LoopContext|null} upperContext The previous `LoopContext`. - * @param {string|null} label The label for the loop from an enclosing `LabeledStatement`. - * @param {BreakContext} breakContext The context for breaking the loop. - */ - constructor(upperContext, label, breakContext) { - super(upperContext, "WhileStatement", label, breakContext); - - /** - * The hardcoded literal boolean test condition for - * the loop. Used to catch infinite or skipped loops. - * @type {boolean|undefined} - */ - this.test = void 0; - - /** - * The segments representing the test condition where `continue` will - * jump to. The test condition will typically have just one segment but - * it's possible for there to be more than one. - * @type {Array|null} - */ - this.continueDestSegments = null; - } -} - -/** - * Represents the context for a `do-while` loop. - */ -class DoWhileLoopContext extends LoopContextBase { - - /** - * Creates a new instance. - * @param {LoopContext|null} upperContext The previous `LoopContext`. - * @param {string|null} label The label for the loop from an enclosing `LabeledStatement`. - * @param {BreakContext} breakContext The context for breaking the loop. - * @param {ForkContext} forkContext The enclosing fork context. - */ - constructor(upperContext, label, breakContext, forkContext) { - super(upperContext, "DoWhileStatement", label, breakContext); - - /** - * The hardcoded literal boolean test condition for - * the loop. Used to catch infinite or skipped loops. - * @type {boolean|undefined} - */ - this.test = void 0; - - /** - * The segments at the start of the loop body. This is the only loop - * where the test comes at the end, so the first iteration always - * happens and we need a reference to the first statements. - * @type {Array|null} - */ - this.entrySegments = null; - - /** - * The fork context to follow when a `continue` is found. - * @type {ForkContext} - */ - this.continueForkContext = ForkContext.newEmpty(forkContext); - } -} - -/** - * Represents the context for a `for` loop. - */ -class ForLoopContext extends LoopContextBase { - - /** - * Creates a new instance. - * @param {LoopContext|null} upperContext The previous `LoopContext`. - * @param {string|null} label The label for the loop from an enclosing `LabeledStatement`. - * @param {BreakContext} breakContext The context for breaking the loop. - */ - constructor(upperContext, label, breakContext) { - super(upperContext, "ForStatement", label, breakContext); - - /** - * The hardcoded literal boolean test condition for - * the loop. Used to catch infinite or skipped loops. - * @type {boolean|undefined} - */ - this.test = void 0; - - /** - * The end of the init expression. This may change during the lifetime - * of the instance as we traverse the loop because some loops don't have - * an init expression. - * @type {Array|null} - */ - this.endOfInitSegments = null; - - /** - * The start of the test expression. This may change during the lifetime - * of the instance as we traverse the loop because some loops don't have - * a test expression. - * @type {Array|null} - */ - this.testSegments = null; - - /** - * The end of the test expression. This may change during the lifetime - * of the instance as we traverse the loop because some loops don't have - * a test expression. - * @type {Array|null} - */ - this.endOfTestSegments = null; - - /** - * The start of the update expression. This may change during the lifetime - * of the instance as we traverse the loop because some loops don't have - * an update expression. - * @type {Array|null} - */ - this.updateSegments = null; - - /** - * The end of the update expresion. This may change during the lifetime - * of the instance as we traverse the loop because some loops don't have - * an update expression. - * @type {Array|null} - */ - this.endOfUpdateSegments = null; - - /** - * The segments representing the test condition where `continue` will - * jump to. The test condition will typically have just one segment but - * it's possible for there to be more than one. This may change during the - * lifetime of the instance as we traverse the loop because some loops - * don't have an update expression. When there is an update expression, this - * will end up pointing to that expression; otherwise it will end up pointing - * to the test expression. - * @type {Array|null} - */ - this.continueDestSegments = null; - } -} - -/** - * Represents the context for a `for-in` loop. - * - * Terminology: - * - "left" means the part of the loop to the left of the `in` keyword. For - * example, in `for (var x in y)`, the left is `var x`. - * - "right" means the part of the loop to the right of the `in` keyword. For - * example, in `for (var x in y)`, the right is `y`. - */ -class ForInLoopContext extends LoopContextBase { - - /** - * Creates a new instance. - * @param {LoopContext|null} upperContext The previous `LoopContext`. - * @param {string|null} label The label for the loop from an enclosing `LabeledStatement`. - * @param {BreakContext} breakContext The context for breaking the loop. - */ - constructor(upperContext, label, breakContext) { - super(upperContext, "ForInStatement", label, breakContext); - - /** - * The segments that came immediately before the start of the loop. - * This allows you to traverse backwards out of the loop into the - * surrounding code. This is necessary to evaluate the right expression - * correctly, as it must be evaluated in the same way as the left - * expression, but the pointer to these segments would otherwise be - * lost if not stored on the instance. Once the right expression has - * been evaluated, this property is no longer used. - * @type {Array|null} - */ - this.prevSegments = null; - - /** - * Segments representing the start of everything to the left of the - * `in` keyword. This can be used to move forward towards - * `endOfLeftSegments`. `leftSegments` and `endOfLeftSegments` are - * effectively the head and tail of a doubly-linked list. - * @type {Array|null} - */ - this.leftSegments = null; - - /** - * Segments representing the end of everything to the left of the - * `in` keyword. This can be used to move backward towards `leftSegments`. - * `leftSegments` and `endOfLeftSegments` are effectively the head - * and tail of a doubly-linked list. - * @type {Array|null} - */ - this.endOfLeftSegments = null; - - /** - * The segments representing the left expression where `continue` will - * jump to. In `for-in` loops, `continue` must always re-execute the - * left expression each time through the loop. This contains the same - * segments as `leftSegments`, but is duplicated here so each loop - * context has the same property pointing to where `continue` should - * end up. - * @type {Array|null} - */ - this.continueDestSegments = null; - } -} - -/** - * Represents the context for a `for-of` loop. - */ -class ForOfLoopContext extends LoopContextBase { - - /** - * Creates a new instance. - * @param {LoopContext|null} upperContext The previous `LoopContext`. - * @param {string|null} label The label for the loop from an enclosing `LabeledStatement`. - * @param {BreakContext} breakContext The context for breaking the loop. - */ - constructor(upperContext, label, breakContext) { - super(upperContext, "ForOfStatement", label, breakContext); - - /** - * The segments that came immediately before the start of the loop. - * This allows you to traverse backwards out of the loop into the - * surrounding code. This is necessary to evaluate the right expression - * correctly, as it must be evaluated in the same way as the left - * expression, but the pointer to these segments would otherwise be - * lost if not stored on the instance. Once the right expression has - * been evaluated, this property is no longer used. - * @type {Array|null} - */ - this.prevSegments = null; - - /** - * Segments representing the start of everything to the left of the - * `of` keyword. This can be used to move forward towards - * `endOfLeftSegments`. `leftSegments` and `endOfLeftSegments` are - * effectively the head and tail of a doubly-linked list. - * @type {Array|null} - */ - this.leftSegments = null; - - /** - * Segments representing the end of everything to the left of the - * `of` keyword. This can be used to move backward towards `leftSegments`. - * `leftSegments` and `endOfLeftSegments` are effectively the head - * and tail of a doubly-linked list. - * @type {Array|null} - */ - this.endOfLeftSegments = null; - - /** - * The segments representing the left expression where `continue` will - * jump to. In `for-in` loops, `continue` must always re-execute the - * left expression each time through the loop. This contains the same - * segments as `leftSegments`, but is duplicated here so each loop - * context has the same property pointing to where `continue` should - * end up. - * @type {Array|null} - */ - this.continueDestSegments = null; - } -} - -/** - * Represents the context for any loop. - * @typedef {WhileLoopContext|DoWhileLoopContext|ForLoopContext|ForInLoopContext|ForOfLoopContext} LoopContext - */ - -/** - * Represents the context for a `switch` statement. - */ -class SwitchContext { - - /** - * Creates a new instance. - * @param {SwitchContext} upperContext The previous context. - * @param {boolean} hasCase Indicates if there is at least one `case` statement. - * `default` doesn't count. - */ - constructor(upperContext, hasCase) { - - /** - * The previous context. - * @type {SwitchContext} - */ - this.upper = upperContext; - - /** - * Indicates if there is at least one `case` statement. `default` doesn't count. - * @type {boolean} - */ - this.hasCase = hasCase; - - /** - * The `default` keyword. - * @type {Array|null} - */ - this.defaultSegments = null; - - /** - * The default case body starting segments. - * @type {Array|null} - */ - this.defaultBodySegments = null; - - /** - * Indicates if a `default` case and is empty exists. - * @type {boolean} - */ - this.foundEmptyDefault = false; - - /** - * Indicates that a `default` exists and is the last case. - * @type {boolean} - */ - this.lastIsDefault = false; - - /** - * The number of fork contexts created. This is equivalent to the - * number of `case` statements plus a `default` statement (if present). - * @type {number} - */ - this.forkCount = 0; - } -} - -/** - * Represents the context for a `try` statement. - */ -class TryContext { - - /** - * Creates a new instance. - * @param {TryContext} upperContext The previous context. - * @param {boolean} hasFinalizer Indicates if the `try` statement has a - * `finally` block. - * @param {ForkContext} forkContext The enclosing fork context. - */ - constructor(upperContext, hasFinalizer, forkContext) { - - /** - * The previous context. - * @type {TryContext} - */ - this.upper = upperContext; - - /** - * Indicates if the `try` statement has a `finally` block. - * @type {boolean} - */ - this.hasFinalizer = hasFinalizer; - - /** - * Tracks the traversal position inside of the `try` statement. This is - * used to help determine the context necessary to create paths because - * a `try` statement may or may not have `catch` or `finally` blocks, - * and code paths behave differently in those blocks. - * @type {"try"|"catch"|"finally"} - */ - this.position = "try"; - - /** - * If the `try` statement has a `finally` block, this affects how a - * `return` statement behaves in the `try` block. Without `finally`, - * `return` behaves as usual and doesn't require a fork; with `finally`, - * `return` forks into the `finally` block, so we need a fork context - * to track it. - * @type {ForkContext|null} - */ - this.returnedForkContext = hasFinalizer - ? ForkContext.newEmpty(forkContext) - : null; - - /** - * When a `throw` occurs inside of a `try` block, the code path forks - * into the `catch` or `finally` blocks, and this fork context tracks - * that path. - * @type {ForkContext} - */ - this.thrownForkContext = ForkContext.newEmpty(forkContext); - - /** - * Indicates if the last segment in the `try` block is reachable. - * @type {boolean} - */ - this.lastOfTryIsReachable = false; - - /** - * Indicates if the last segment in the `catch` block is reachable. - * @type {boolean} - */ - this.lastOfCatchIsReachable = false; - } -} - -//------------------------------------------------------------------------------ -// Helpers -//------------------------------------------------------------------------------ - -/** - * Adds given segments into the `dest` array. - * If the `others` array does not include the given segments, adds to the `all` - * array as well. - * - * This adds only reachable and used segments. - * @param {CodePathSegment[]} dest A destination array (`returnedSegments` or `thrownSegments`). - * @param {CodePathSegment[]} others Another destination array (`returnedSegments` or `thrownSegments`). - * @param {CodePathSegment[]} all The unified destination array (`finalSegments`). - * @param {CodePathSegment[]} segments Segments to add. - * @returns {void} - */ -function addToReturnedOrThrown(dest, others, all, segments) { - for (let i = 0; i < segments.length; ++i) { - const segment = segments[i]; - - dest.push(segment); - if (!others.includes(segment)) { - all.push(segment); - } - } -} - -/** - * Gets a loop context for a `continue` statement based on a given label. - * @param {CodePathState} state The state to search within. - * @param {string|null} label The label of a `continue` statement. - * @returns {LoopContext} A loop-context for a `continue` statement. - */ -function getContinueContext(state, label) { - if (!label) { - return state.loopContext; - } - - let context = state.loopContext; - - while (context) { - if (context.label === label) { - return context; - } - context = context.upper; - } - - /* c8 ignore next */ - return null; -} - -/** - * Gets a context for a `break` statement. - * @param {CodePathState} state The state to search within. - * @param {string|null} label The label of a `break` statement. - * @returns {BreakContext} A context for a `break` statement. - */ -function getBreakContext(state, label) { - let context = state.breakContext; - - while (context) { - if (label ? context.label === label : context.breakable) { - return context; - } - context = context.upper; - } - - /* c8 ignore next */ - return null; -} - -/** - * Gets a context for a `return` statement. There is just one special case: - * if there is a `try` statement with a `finally` block, because that alters - * how `return` behaves; otherwise, this just passes through the given state. - * @param {CodePathState} state The state to search within - * @returns {TryContext|CodePathState} A context for a `return` statement. - */ -function getReturnContext(state) { - let context = state.tryContext; - - while (context) { - if (context.hasFinalizer && context.position !== "finally") { - return context; - } - context = context.upper; - } - - return state; -} - -/** - * Gets a context for a `throw` statement. There is just one special case: - * if there is a `try` statement with a `finally` block and we are inside of - * a `catch` because that changes how `throw` behaves; otherwise, this just - * passes through the given state. - * @param {CodePathState} state The state to search within. - * @returns {TryContext|CodePathState} A context for a `throw` statement. - */ -function getThrowContext(state) { - let context = state.tryContext; - - while (context) { - if (context.position === "try" || - (context.hasFinalizer && context.position === "catch") - ) { - return context; - } - context = context.upper; - } - - return state; -} - -/** - * Removes a given value from a given array. - * @param {any[]} elements An array to remove the specific element. - * @param {any} value The value to be removed. - * @returns {void} - */ -function removeFromArray(elements, value) { - elements.splice(elements.indexOf(value), 1); -} - -/** - * Disconnect given segments. - * - * This is used in a process for switch statements. - * If there is the "default" chunk before other cases, the order is different - * between node's and running's. - * @param {CodePathSegment[]} prevSegments Forward segments to disconnect. - * @param {CodePathSegment[]} nextSegments Backward segments to disconnect. - * @returns {void} - */ -function disconnectSegments(prevSegments, nextSegments) { - for (let i = 0; i < prevSegments.length; ++i) { - const prevSegment = prevSegments[i]; - const nextSegment = nextSegments[i]; - - removeFromArray(prevSegment.nextSegments, nextSegment); - removeFromArray(prevSegment.allNextSegments, nextSegment); - removeFromArray(nextSegment.prevSegments, prevSegment); - removeFromArray(nextSegment.allPrevSegments, prevSegment); - } -} - -/** - * Creates looping path between two arrays of segments, ensuring that there are - * paths going between matching segments in the arrays. - * @param {CodePathState} state The state to operate on. - * @param {CodePathSegment[]} unflattenedFromSegments Segments which are source. - * @param {CodePathSegment[]} unflattenedToSegments Segments which are destination. - * @returns {void} - */ -function makeLooped(state, unflattenedFromSegments, unflattenedToSegments) { - - const fromSegments = CodePathSegment.flattenUnusedSegments(unflattenedFromSegments); - const toSegments = CodePathSegment.flattenUnusedSegments(unflattenedToSegments); - const end = Math.min(fromSegments.length, toSegments.length); - - /* - * This loop effectively updates a doubly-linked list between two collections - * of segments making sure that segments in the same array indices are - * combined to create a path. - */ - for (let i = 0; i < end; ++i) { - - // get the segments in matching array indices - const fromSegment = fromSegments[i]; - const toSegment = toSegments[i]; - - /* - * If the destination segment is reachable, then create a path from the - * source segment to the destination segment. - */ - if (toSegment.reachable) { - fromSegment.nextSegments.push(toSegment); - } - - /* - * If the source segment is reachable, then create a path from the - * destination segment back to the source segment. - */ - if (fromSegment.reachable) { - toSegment.prevSegments.push(fromSegment); - } - - /* - * Also update the arrays that don't care if the segments are reachable - * or not. This should always happen regardless of anything else. - */ - fromSegment.allNextSegments.push(toSegment); - toSegment.allPrevSegments.push(fromSegment); - - /* - * If the destination segment has at least two previous segments in its - * path then that means there was one previous segment before this iteration - * of the loop was executed. So, we need to mark the source segment as - * looped. - */ - if (toSegment.allPrevSegments.length >= 2) { - CodePathSegment.markPrevSegmentAsLooped(toSegment, fromSegment); - } - - // let the code path analyzer know that there's been a loop created - state.notifyLooped(fromSegment, toSegment); - } -} - -/** - * Finalizes segments of `test` chunk of a ForStatement. - * - * - Adds `false` paths to paths which are leaving from the loop. - * - Sets `true` paths to paths which go to the body. - * @param {LoopContext} context A loop context to modify. - * @param {ChoiceContext} choiceContext A choice context of this loop. - * @param {CodePathSegment[]} head The current head paths. - * @returns {void} - */ -function finalizeTestSegmentsOfFor(context, choiceContext, head) { - - /* - * If this choice context doesn't already contain paths from a - * child context, then add the current head to each potential path. - */ - if (!choiceContext.processed) { - choiceContext.trueForkContext.add(head); - choiceContext.falseForkContext.add(head); - choiceContext.nullishForkContext.add(head); - } - - /* - * If the test condition isn't a hardcoded truthy value, then `break` - * must follow the same path as if the test condition is false. To represent - * that, we append the path for when the loop test is false (represented by - * `falseForkContext`) to the `brokenForkContext`. - */ - if (context.test !== true) { - context.brokenForkContext.addAll(choiceContext.falseForkContext); - } - - context.endOfTestSegments = choiceContext.trueForkContext.makeNext(0, -1); -} - -//------------------------------------------------------------------------------ -// Public Interface -//------------------------------------------------------------------------------ - -/** - * A class which manages state to analyze code paths. - */ -class CodePathState { - - /** - * Creates a new instance. - * @param {IdGenerator} idGenerator An id generator to generate id for code - * path segments. - * @param {Function} onLooped A callback function to notify looping. - */ - constructor(idGenerator, onLooped) { - - /** - * The ID generator to use when creating new segments. - * @type {IdGenerator} - */ - this.idGenerator = idGenerator; - - /** - * A callback function to call when there is a loop. - * @type {Function} - */ - this.notifyLooped = onLooped; - - /** - * The root fork context for this state. - * @type {ForkContext} - */ - this.forkContext = ForkContext.newRoot(idGenerator); - - /** - * Context for logical expressions, conditional expressions, `if` statements, - * and loops. - * @type {ChoiceContext} - */ - this.choiceContext = null; - - /** - * Context for `switch` statements. - * @type {SwitchContext} - */ - this.switchContext = null; - - /** - * Context for `try` statements. - * @type {TryContext} - */ - this.tryContext = null; - - /** - * Context for loop statements. - * @type {LoopContext} - */ - this.loopContext = null; - - /** - * Context for `break` statements. - * @type {BreakContext} - */ - this.breakContext = null; - - /** - * Context for `ChainExpression` nodes. - * @type {ChainContext} - */ - this.chainContext = null; - - /** - * An array that tracks the current segments in the state. The array - * starts empty and segments are added with each `onCodePathSegmentStart` - * event and removed with each `onCodePathSegmentEnd` event. Effectively, - * this is tracking the code path segment traversal as the state is - * modified. - * @type {Array} - */ - this.currentSegments = []; - - /** - * Tracks the starting segment for this path. This value never changes. - * @type {CodePathSegment} - */ - this.initialSegment = this.forkContext.head[0]; - - /** - * The final segments of the code path which are either `return` or `throw`. - * This is a union of the segments in `returnedForkContext` and `thrownForkContext`. - * @type {Array} - */ - this.finalSegments = []; - - /** - * The final segments of the code path which are `return`. These - * segments are also contained in `finalSegments`. - * @type {Array} - */ - this.returnedForkContext = []; - - /** - * The final segments of the code path which are `throw`. These - * segments are also contained in `finalSegments`. - * @type {Array} - */ - this.thrownForkContext = []; - - /* - * We add an `add` method so that these look more like fork contexts and - * can be used interchangeably when a fork context is needed to add more - * segments to a path. - * - * Ultimately, we want anything added to `returned` or `thrown` to also - * be added to `final`. We only add reachable and used segments to these - * arrays. - */ - const final = this.finalSegments; - const returned = this.returnedForkContext; - const thrown = this.thrownForkContext; - - returned.add = addToReturnedOrThrown.bind(null, returned, thrown, final); - thrown.add = addToReturnedOrThrown.bind(null, thrown, returned, final); - } - - /** - * A passthrough property exposing the current pointer as part of the API. - * @type {CodePathSegment[]} - */ - get headSegments() { - return this.forkContext.head; - } - - /** - * The parent forking context. - * This is used for the root of new forks. - * @type {ForkContext} - */ - get parentForkContext() { - const current = this.forkContext; - - return current && current.upper; - } - - /** - * Creates and stacks new forking context. - * @param {boolean} forkLeavingPath A flag which shows being in a - * "finally" block. - * @returns {ForkContext} The created context. - */ - pushForkContext(forkLeavingPath) { - this.forkContext = ForkContext.newEmpty( - this.forkContext, - forkLeavingPath - ); - - return this.forkContext; - } - - /** - * Pops and merges the last forking context. - * @returns {ForkContext} The last context. - */ - popForkContext() { - const lastContext = this.forkContext; - - this.forkContext = lastContext.upper; - this.forkContext.replaceHead(lastContext.makeNext(0, -1)); - - return lastContext; - } - - /** - * Creates a new path. - * @returns {void} - */ - forkPath() { - this.forkContext.add(this.parentForkContext.makeNext(-1, -1)); - } - - /** - * Creates a bypass path. - * This is used for such as IfStatement which does not have "else" chunk. - * @returns {void} - */ - forkBypassPath() { - this.forkContext.add(this.parentForkContext.head); - } - - //-------------------------------------------------------------------------- - // ConditionalExpression, LogicalExpression, IfStatement - //-------------------------------------------------------------------------- - - /** - * Creates a context for ConditionalExpression, LogicalExpression, AssignmentExpression (logical assignments only), - * IfStatement, WhileStatement, DoWhileStatement, or ForStatement. - * - * LogicalExpressions have cases that it goes different paths between the - * `true` case and the `false` case. - * - * For Example: - * - * if (a || b) { - * foo(); - * } else { - * bar(); - * } - * - * In this case, `b` is evaluated always in the code path of the `else` - * block, but it's not so in the code path of the `if` block. - * So there are 3 paths. - * - * a -> foo(); - * a -> b -> foo(); - * a -> b -> bar(); - * @param {string} kind A kind string. - * If the new context is LogicalExpression's or AssignmentExpression's, this is `"&&"` or `"||"` or `"??"`. - * If it's IfStatement's or ConditionalExpression's, this is `"test"`. - * Otherwise, this is `"loop"`. - * @param {boolean} isForkingAsResult Indicates if the result of the choice - * creates a fork. - * @returns {void} - */ - pushChoiceContext(kind, isForkingAsResult) { - this.choiceContext = new ChoiceContext(this.choiceContext, kind, isForkingAsResult, this.forkContext); - } - - /** - * Pops the last choice context and finalizes it. - * This is called upon leaving a node that represents a choice. - * @throws {Error} (Unreachable.) - * @returns {ChoiceContext} The popped context. - */ - popChoiceContext() { - const poppedChoiceContext = this.choiceContext; - const forkContext = this.forkContext; - const head = forkContext.head; - - this.choiceContext = poppedChoiceContext.upper; - - switch (poppedChoiceContext.kind) { - case "&&": - case "||": - case "??": - - /* - * The `head` are the path of the right-hand operand. - * If we haven't previously added segments from child contexts, - * then we add these segments to all possible forks. - */ - if (!poppedChoiceContext.processed) { - poppedChoiceContext.trueForkContext.add(head); - poppedChoiceContext.falseForkContext.add(head); - poppedChoiceContext.nullishForkContext.add(head); - } - - /* - * If this context is the left (test) expression for another choice - * context, such as `a || b` in the expression `a || b || c`, - * then we take the segments for this context and move them up - * to the parent context. - */ - if (poppedChoiceContext.isForkingAsResult) { - const parentContext = this.choiceContext; - - parentContext.trueForkContext.addAll(poppedChoiceContext.trueForkContext); - parentContext.falseForkContext.addAll(poppedChoiceContext.falseForkContext); - parentContext.nullishForkContext.addAll(poppedChoiceContext.nullishForkContext); - parentContext.processed = true; - - // Exit early so we don't collapse all paths into one. - return poppedChoiceContext; - } - - break; - - case "test": - if (!poppedChoiceContext.processed) { - - /* - * The head segments are the path of the `if` block here. - * Updates the `true` path with the end of the `if` block. - */ - poppedChoiceContext.trueForkContext.clear(); - poppedChoiceContext.trueForkContext.add(head); - } else { - - /* - * The head segments are the path of the `else` block here. - * Updates the `false` path with the end of the `else` - * block. - */ - poppedChoiceContext.falseForkContext.clear(); - poppedChoiceContext.falseForkContext.add(head); - } - - break; - - case "loop": - - /* - * Loops are addressed in `popLoopContext()` so just return - * the context without modification. - */ - return poppedChoiceContext; - - /* c8 ignore next */ - default: - throw new Error("unreachable"); - } - - /* - * Merge the true path with the false path to create a single path. - */ - const combinedForkContext = poppedChoiceContext.trueForkContext; - - combinedForkContext.addAll(poppedChoiceContext.falseForkContext); - forkContext.replaceHead(combinedForkContext.makeNext(0, -1)); - - return poppedChoiceContext; - } - - /** - * Creates a code path segment to represent right-hand operand of a logical - * expression. - * This is called in the preprocessing phase when entering a node. - * @throws {Error} (Unreachable.) - * @returns {void} - */ - makeLogicalRight() { - const currentChoiceContext = this.choiceContext; - const forkContext = this.forkContext; - - if (currentChoiceContext.processed) { - - /* - * This context was already assigned segments from a child - * choice context. In this case, we are concerned only about - * the path that does not short-circuit and so ends up on the - * right-hand operand of the logical expression. - */ - let prevForkContext; - - switch (currentChoiceContext.kind) { - case "&&": // if true then go to the right-hand side. - prevForkContext = currentChoiceContext.trueForkContext; - break; - case "||": // if false then go to the right-hand side. - prevForkContext = currentChoiceContext.falseForkContext; - break; - case "??": // Both true/false can short-circuit, so needs the third path to go to the right-hand side. That's nullishForkContext. - prevForkContext = currentChoiceContext.nullishForkContext; - break; - default: - throw new Error("unreachable"); - } - - /* - * Create the segment for the right-hand operand of the logical expression - * and adjust the fork context pointer to point there. The right-hand segment - * is added at the end of all segments in `prevForkContext`. - */ - forkContext.replaceHead(prevForkContext.makeNext(0, -1)); - - /* - * We no longer need this list of segments. - * - * Reset `processed` because we've removed the segments from the child - * choice context. This allows `popChoiceContext()` to continue adding - * segments later. - */ - prevForkContext.clear(); - currentChoiceContext.processed = false; - - } else { - - /* - * This choice context was not assigned segments from a child - * choice context, which means that it's a terminal logical - * expression. - * - * `head` is the segments for the left-hand operand of the - * logical expression. - * - * Each of the fork contexts below are empty at this point. We choose - * the path(s) that will short-circuit and add the segment for the - * left-hand operand to it. Ultimately, this will be the only segment - * in that path due to the short-circuting, so we are just seeding - * these paths to start. - */ - switch (currentChoiceContext.kind) { - case "&&": - - /* - * In most contexts, when a && expression evaluates to false, - * it short circuits, so we need to account for that by setting - * the `falseForkContext` to the left operand. - * - * When a && expression is the left-hand operand for a ?? - * expression, such as `(a && b) ?? c`, a nullish value will - * also short-circuit in a different way than a false value, - * so we also set the `nullishForkContext` to the left operand. - * This path is only used with a ?? expression and is thrown - * away for any other type of logical expression, so it's safe - * to always add. - */ - currentChoiceContext.falseForkContext.add(forkContext.head); - currentChoiceContext.nullishForkContext.add(forkContext.head); - break; - case "||": // the true path can short-circuit. - currentChoiceContext.trueForkContext.add(forkContext.head); - break; - case "??": // both can short-circuit. - currentChoiceContext.trueForkContext.add(forkContext.head); - currentChoiceContext.falseForkContext.add(forkContext.head); - break; - default: - throw new Error("unreachable"); - } - - /* - * Create the segment for the right-hand operand of the logical expression - * and adjust the fork context pointer to point there. - */ - forkContext.replaceHead(forkContext.makeNext(-1, -1)); - } - } - - /** - * Makes a code path segment of the `if` block. - * @returns {void} - */ - makeIfConsequent() { - const context = this.choiceContext; - const forkContext = this.forkContext; - - /* - * If any result were not transferred from child contexts, - * this sets the head segments to both cases. - * The head segments are the path of the test expression. - */ - if (!context.processed) { - context.trueForkContext.add(forkContext.head); - context.falseForkContext.add(forkContext.head); - context.nullishForkContext.add(forkContext.head); - } - - context.processed = false; - - // Creates new path from the `true` case. - forkContext.replaceHead( - context.trueForkContext.makeNext(0, -1) - ); - } - - /** - * Makes a code path segment of the `else` block. - * @returns {void} - */ - makeIfAlternate() { - const context = this.choiceContext; - const forkContext = this.forkContext; - - /* - * The head segments are the path of the `if` block. - * Updates the `true` path with the end of the `if` block. - */ - context.trueForkContext.clear(); - context.trueForkContext.add(forkContext.head); - context.processed = true; - - // Creates new path from the `false` case. - forkContext.replaceHead( - context.falseForkContext.makeNext(0, -1) - ); - } - - //-------------------------------------------------------------------------- - // ChainExpression - //-------------------------------------------------------------------------- - - /** - * Pushes a new `ChainExpression` context to the stack. This method is - * called when entering a `ChainExpression` node. A chain context is used to - * count forking in the optional chain then merge them on the exiting from the - * `ChainExpression` node. - * @returns {void} - */ - pushChainContext() { - this.chainContext = new ChainContext(this.chainContext); - } - - /** - * Pop a `ChainExpression` context from the stack. This method is called on - * exiting from each `ChainExpression` node. This merges all forks of the - * last optional chaining. - * @returns {void} - */ - popChainContext() { - const context = this.chainContext; - - this.chainContext = context.upper; - - // pop all choice contexts of this. - for (let i = context.choiceContextCount; i > 0; --i) { - this.popChoiceContext(); - } - } - - /** - * Create a choice context for optional access. - * This method is called on entering to each `(Call|Member)Expression[optional=true]` node. - * This creates a choice context as similar to `LogicalExpression[operator="??"]` node. - * @returns {void} - */ - makeOptionalNode() { - if (this.chainContext) { - this.chainContext.choiceContextCount += 1; - this.pushChoiceContext("??", false); - } - } - - /** - * Create a fork. - * This method is called on entering to the `arguments|property` property of each `(Call|Member)Expression` node. - * @returns {void} - */ - makeOptionalRight() { - if (this.chainContext) { - this.makeLogicalRight(); - } - } - - //-------------------------------------------------------------------------- - // SwitchStatement - //-------------------------------------------------------------------------- - - /** - * Creates a context object of SwitchStatement and stacks it. - * @param {boolean} hasCase `true` if the switch statement has one or more - * case parts. - * @param {string|null} label The label text. - * @returns {void} - */ - pushSwitchContext(hasCase, label) { - this.switchContext = new SwitchContext(this.switchContext, hasCase); - this.pushBreakContext(true, label); - } - - /** - * Pops the last context of SwitchStatement and finalizes it. - * - * - Disposes all forking stack for `case` and `default`. - * - Creates the next code path segment from `context.brokenForkContext`. - * - If the last `SwitchCase` node is not a `default` part, creates a path - * to the `default` body. - * @returns {void} - */ - popSwitchContext() { - const context = this.switchContext; - - this.switchContext = context.upper; - - const forkContext = this.forkContext; - const brokenForkContext = this.popBreakContext().brokenForkContext; - - if (context.forkCount === 0) { - - /* - * When there is only one `default` chunk and there is one or more - * `break` statements, even if forks are nothing, it needs to merge - * those. - */ - if (!brokenForkContext.empty) { - brokenForkContext.add(forkContext.makeNext(-1, -1)); - forkContext.replaceHead(brokenForkContext.makeNext(0, -1)); - } - - return; - } - - const lastSegments = forkContext.head; - - this.forkBypassPath(); - const lastCaseSegments = forkContext.head; - - /* - * `brokenForkContext` is used to make the next segment. - * It must add the last segment into `brokenForkContext`. - */ - brokenForkContext.add(lastSegments); - - /* - * Any value that doesn't match a `case` test should flow to the default - * case. That happens normally when the default case is last in the `switch`, - * but if it's not, we need to rewire some of the paths to be correct. - */ - if (!context.lastIsDefault) { - if (context.defaultBodySegments) { - - /* - * There is a non-empty default case, so remove the path from the `default` - * label to its body for an accurate representation. - */ - disconnectSegments(context.defaultSegments, context.defaultBodySegments); - - /* - * Connect the path from the last non-default case to the body of the - * default case. - */ - makeLooped(this, lastCaseSegments, context.defaultBodySegments); - - } else { - - /* - * There is no default case, so we treat this as if the last case - * had a `break` in it. - */ - brokenForkContext.add(lastCaseSegments); - } - } - - // Traverse up to the original fork context for the `switch` statement - for (let i = 0; i < context.forkCount; ++i) { - this.forkContext = this.forkContext.upper; - } - - /* - * Creates a path from all `brokenForkContext` paths. - * This is a path after `switch` statement. - */ - this.forkContext.replaceHead(brokenForkContext.makeNext(0, -1)); - } - - /** - * Makes a code path segment for a `SwitchCase` node. - * @param {boolean} isCaseBodyEmpty `true` if the body is empty. - * @param {boolean} isDefaultCase `true` if the body is the default case. - * @returns {void} - */ - makeSwitchCaseBody(isCaseBodyEmpty, isDefaultCase) { - const context = this.switchContext; - - if (!context.hasCase) { - return; - } - - /* - * Merge forks. - * The parent fork context has two segments. - * Those are from the current `case` and the body of the previous case. - */ - const parentForkContext = this.forkContext; - const forkContext = this.pushForkContext(); - - forkContext.add(parentForkContext.makeNext(0, -1)); - - /* - * Add information about the default case. - * - * The purpose of this is to identify the starting segments for the - * default case to make sure there is a path there. - */ - if (isDefaultCase) { - - /* - * This is the default case in the `switch`. - * - * We first save the current pointer as `defaultSegments` to point - * to the `default` keyword. - */ - context.defaultSegments = parentForkContext.head; - - /* - * If the body of the case is empty then we just set - * `foundEmptyDefault` to true; otherwise, we save a reference - * to the current pointer as `defaultBodySegments`. - */ - if (isCaseBodyEmpty) { - context.foundEmptyDefault = true; - } else { - context.defaultBodySegments = forkContext.head; - } - - } else { - - /* - * This is not the default case in the `switch`. - * - * If it's not empty and there is already an empty default case found, - * that means the default case actually comes before this case, - * and that it will fall through to this case. So, we can now - * ignore the previous default case (reset `foundEmptyDefault` to false) - * and set `defaultBodySegments` to the current segments because this is - * effectively the new default case. - */ - if (!isCaseBodyEmpty && context.foundEmptyDefault) { - context.foundEmptyDefault = false; - context.defaultBodySegments = forkContext.head; - } - } - - // keep track if the default case ends up last - context.lastIsDefault = isDefaultCase; - context.forkCount += 1; - } - - //-------------------------------------------------------------------------- - // TryStatement - //-------------------------------------------------------------------------- - - /** - * Creates a context object of TryStatement and stacks it. - * @param {boolean} hasFinalizer `true` if the try statement has a - * `finally` block. - * @returns {void} - */ - pushTryContext(hasFinalizer) { - this.tryContext = new TryContext(this.tryContext, hasFinalizer, this.forkContext); - } - - /** - * Pops the last context of TryStatement and finalizes it. - * @returns {void} - */ - popTryContext() { - const context = this.tryContext; - - this.tryContext = context.upper; - - /* - * If we're inside the `catch` block, that means there is no `finally`, - * so we can process the `try` and `catch` blocks the simple way and - * merge their two paths. - */ - if (context.position === "catch") { - this.popForkContext(); - return; - } - - /* - * The following process is executed only when there is a `finally` - * block. - */ - - const originalReturnedForkContext = context.returnedForkContext; - const originalThrownForkContext = context.thrownForkContext; - - // no `return` or `throw` in `try` or `catch` so there's nothing left to do - if (originalReturnedForkContext.empty && originalThrownForkContext.empty) { - return; - } - - /* - * The following process is executed only when there is a `finally` - * block and there was a `return` or `throw` in the `try` or `catch` - * blocks. - */ - - // Separate head to normal paths and leaving paths. - const headSegments = this.forkContext.head; - - this.forkContext = this.forkContext.upper; - const normalSegments = headSegments.slice(0, headSegments.length / 2 | 0); - const leavingSegments = headSegments.slice(headSegments.length / 2 | 0); - - // Forwards the leaving path to upper contexts. - if (!originalReturnedForkContext.empty) { - getReturnContext(this).returnedForkContext.add(leavingSegments); - } - if (!originalThrownForkContext.empty) { - getThrowContext(this).thrownForkContext.add(leavingSegments); - } - - // Sets the normal path as the next. - this.forkContext.replaceHead(normalSegments); - - /* - * If both paths of the `try` block and the `catch` block are - * unreachable, the next path becomes unreachable as well. - */ - if (!context.lastOfTryIsReachable && !context.lastOfCatchIsReachable) { - this.forkContext.makeUnreachable(); - } - } - - /** - * Makes a code path segment for a `catch` block. - * @returns {void} - */ - makeCatchBlock() { - const context = this.tryContext; - const forkContext = this.forkContext; - const originalThrownForkContext = context.thrownForkContext; - - /* - * We are now in a catch block so we need to update the context - * with that information. This includes creating a new fork - * context in case we encounter any `throw` statements here. - */ - context.position = "catch"; - context.thrownForkContext = ForkContext.newEmpty(forkContext); - context.lastOfTryIsReachable = forkContext.reachable; - - // Merge the thrown paths from the `try` and `catch` blocks - originalThrownForkContext.add(forkContext.head); - const thrownSegments = originalThrownForkContext.makeNext(0, -1); - - // Fork to a bypass and the merged thrown path. - this.pushForkContext(); - this.forkBypassPath(); - this.forkContext.add(thrownSegments); - } - - /** - * Makes a code path segment for a `finally` block. - * - * In the `finally` block, parallel paths are created. The parallel paths - * are used as leaving-paths. The leaving-paths are paths from `return` - * statements and `throw` statements in a `try` block or a `catch` block. - * @returns {void} - */ - makeFinallyBlock() { - const context = this.tryContext; - let forkContext = this.forkContext; - const originalReturnedForkContext = context.returnedForkContext; - const originalThrownForContext = context.thrownForkContext; - const headOfLeavingSegments = forkContext.head; - - // Update state. - if (context.position === "catch") { - - // Merges two paths from the `try` block and `catch` block. - this.popForkContext(); - forkContext = this.forkContext; - - context.lastOfCatchIsReachable = forkContext.reachable; - } else { - context.lastOfTryIsReachable = forkContext.reachable; - } - - - context.position = "finally"; - - /* - * If there was no `return` or `throw` in either the `try` or `catch` - * blocks, then there's no further code paths to create for `finally`. - */ - if (originalReturnedForkContext.empty && originalThrownForContext.empty) { - - // This path does not leave. - return; - } - - /* - * Create a parallel segment from merging returned and thrown. - * This segment will leave at the end of this `finally` block. - */ - const segments = forkContext.makeNext(-1, -1); - - for (let i = 0; i < forkContext.count; ++i) { - const prevSegsOfLeavingSegment = [headOfLeavingSegments[i]]; - - for (let j = 0; j < originalReturnedForkContext.segmentsList.length; ++j) { - prevSegsOfLeavingSegment.push(originalReturnedForkContext.segmentsList[j][i]); - } - for (let j = 0; j < originalThrownForContext.segmentsList.length; ++j) { - prevSegsOfLeavingSegment.push(originalThrownForContext.segmentsList[j][i]); - } - - segments.push( - CodePathSegment.newNext( - this.idGenerator.next(), - prevSegsOfLeavingSegment - ) - ); - } - - this.pushForkContext(true); - this.forkContext.add(segments); - } - - /** - * Makes a code path segment from the first throwable node to the `catch` - * block or the `finally` block. - * @returns {void} - */ - makeFirstThrowablePathInTryBlock() { - const forkContext = this.forkContext; - - if (!forkContext.reachable) { - return; - } - - const context = getThrowContext(this); - - if (context === this || - context.position !== "try" || - !context.thrownForkContext.empty - ) { - return; - } - - context.thrownForkContext.add(forkContext.head); - forkContext.replaceHead(forkContext.makeNext(-1, -1)); - } - - //-------------------------------------------------------------------------- - // Loop Statements - //-------------------------------------------------------------------------- - - /** - * Creates a context object of a loop statement and stacks it. - * @param {string} type The type of the node which was triggered. One of - * `WhileStatement`, `DoWhileStatement`, `ForStatement`, `ForInStatement`, - * and `ForStatement`. - * @param {string|null} label A label of the node which was triggered. - * @throws {Error} (Unreachable - unknown type.) - * @returns {void} - */ - pushLoopContext(type, label) { - const forkContext = this.forkContext; - - // All loops need a path to account for `break` statements - const breakContext = this.pushBreakContext(true, label); - - switch (type) { - case "WhileStatement": - this.pushChoiceContext("loop", false); - this.loopContext = new WhileLoopContext(this.loopContext, label, breakContext); - break; - - case "DoWhileStatement": - this.pushChoiceContext("loop", false); - this.loopContext = new DoWhileLoopContext(this.loopContext, label, breakContext, forkContext); - break; - - case "ForStatement": - this.pushChoiceContext("loop", false); - this.loopContext = new ForLoopContext(this.loopContext, label, breakContext); - break; - - case "ForInStatement": - this.loopContext = new ForInLoopContext(this.loopContext, label, breakContext); - break; - - case "ForOfStatement": - this.loopContext = new ForOfLoopContext(this.loopContext, label, breakContext); - break; - - /* c8 ignore next */ - default: - throw new Error(`unknown type: "${type}"`); - } - } - - /** - * Pops the last context of a loop statement and finalizes it. - * @throws {Error} (Unreachable - unknown type.) - * @returns {void} - */ - popLoopContext() { - const context = this.loopContext; - - this.loopContext = context.upper; - - const forkContext = this.forkContext; - const brokenForkContext = this.popBreakContext().brokenForkContext; - - // Creates a looped path. - switch (context.type) { - case "WhileStatement": - case "ForStatement": - this.popChoiceContext(); - - /* - * Creates the path from the end of the loop body up to the - * location where `continue` would jump to. - */ - makeLooped( - this, - forkContext.head, - context.continueDestSegments - ); - break; - - case "DoWhileStatement": { - const choiceContext = this.popChoiceContext(); - - if (!choiceContext.processed) { - choiceContext.trueForkContext.add(forkContext.head); - choiceContext.falseForkContext.add(forkContext.head); - } - - /* - * If this isn't a hardcoded `true` condition, then `break` - * should continue down the path as if the condition evaluated - * to false. - */ - if (context.test !== true) { - brokenForkContext.addAll(choiceContext.falseForkContext); - } - - /* - * When the condition is true, the loop continues back to the top, - * so create a path from each possible true condition back to the - * top of the loop. - */ - const segmentsList = choiceContext.trueForkContext.segmentsList; - - for (let i = 0; i < segmentsList.length; ++i) { - makeLooped( - this, - segmentsList[i], - context.entrySegments - ); - } - break; - } - - case "ForInStatement": - case "ForOfStatement": - brokenForkContext.add(forkContext.head); - - /* - * Creates the path from the end of the loop body up to the - * left expression (left of `in` or `of`) of the loop. - */ - makeLooped( - this, - forkContext.head, - context.leftSegments - ); - break; - - /* c8 ignore next */ - default: - throw new Error("unreachable"); - } - - /* - * If there wasn't a `break` statement in the loop, then we're at - * the end of the loop's path, so we make an unreachable segment - * to mark that. - * - * If there was a `break` statement, then we continue on into the - * `brokenForkContext`. - */ - if (brokenForkContext.empty) { - forkContext.replaceHead(forkContext.makeUnreachable(-1, -1)); - } else { - forkContext.replaceHead(brokenForkContext.makeNext(0, -1)); - } - } - - /** - * Makes a code path segment for the test part of a WhileStatement. - * @param {boolean|undefined} test The test value (only when constant). - * @returns {void} - */ - makeWhileTest(test) { - const context = this.loopContext; - const forkContext = this.forkContext; - const testSegments = forkContext.makeNext(0, -1); - - // Update state. - context.test = test; - context.continueDestSegments = testSegments; - forkContext.replaceHead(testSegments); - } - - /** - * Makes a code path segment for the body part of a WhileStatement. - * @returns {void} - */ - makeWhileBody() { - const context = this.loopContext; - const choiceContext = this.choiceContext; - const forkContext = this.forkContext; - - if (!choiceContext.processed) { - choiceContext.trueForkContext.add(forkContext.head); - choiceContext.falseForkContext.add(forkContext.head); - } - - /* - * If this isn't a hardcoded `true` condition, then `break` - * should continue down the path as if the condition evaluated - * to false. - */ - if (context.test !== true) { - context.brokenForkContext.addAll(choiceContext.falseForkContext); - } - forkContext.replaceHead(choiceContext.trueForkContext.makeNext(0, -1)); - } - - /** - * Makes a code path segment for the body part of a DoWhileStatement. - * @returns {void} - */ - makeDoWhileBody() { - const context = this.loopContext; - const forkContext = this.forkContext; - const bodySegments = forkContext.makeNext(-1, -1); - - // Update state. - context.entrySegments = bodySegments; - forkContext.replaceHead(bodySegments); - } - - /** - * Makes a code path segment for the test part of a DoWhileStatement. - * @param {boolean|undefined} test The test value (only when constant). - * @returns {void} - */ - makeDoWhileTest(test) { - const context = this.loopContext; - const forkContext = this.forkContext; - - context.test = test; - - /* - * If there is a `continue` statement in the loop then `continueForkContext` - * won't be empty. We wire up the path from `continue` to the loop - * test condition and then continue the traversal in the root fork context. - */ - if (!context.continueForkContext.empty) { - context.continueForkContext.add(forkContext.head); - const testSegments = context.continueForkContext.makeNext(0, -1); - - forkContext.replaceHead(testSegments); - } - } - - /** - * Makes a code path segment for the test part of a ForStatement. - * @param {boolean|undefined} test The test value (only when constant). - * @returns {void} - */ - makeForTest(test) { - const context = this.loopContext; - const forkContext = this.forkContext; - const endOfInitSegments = forkContext.head; - const testSegments = forkContext.makeNext(-1, -1); - - /* - * Update the state. - * - * The `continueDestSegments` are set to `testSegments` because we - * don't yet know if there is an update expression in this loop. So, - * from what we already know at this point, a `continue` statement - * will jump back to the test expression. - */ - context.test = test; - context.endOfInitSegments = endOfInitSegments; - context.continueDestSegments = context.testSegments = testSegments; - forkContext.replaceHead(testSegments); - } - - /** - * Makes a code path segment for the update part of a ForStatement. - * @returns {void} - */ - makeForUpdate() { - const context = this.loopContext; - const choiceContext = this.choiceContext; - const forkContext = this.forkContext; - - // Make the next paths of the test. - if (context.testSegments) { - finalizeTestSegmentsOfFor( - context, - choiceContext, - forkContext.head - ); - } else { - context.endOfInitSegments = forkContext.head; - } - - /* - * Update the state. - * - * The `continueDestSegments` are now set to `updateSegments` because we - * know there is an update expression in this loop. So, a `continue` statement - * in the loop will jump to the update expression first, and then to any - * test expression the loop might have. - */ - const updateSegments = forkContext.makeDisconnected(-1, -1); - - context.continueDestSegments = context.updateSegments = updateSegments; - forkContext.replaceHead(updateSegments); - } - - /** - * Makes a code path segment for the body part of a ForStatement. - * @returns {void} - */ - makeForBody() { - const context = this.loopContext; - const choiceContext = this.choiceContext; - const forkContext = this.forkContext; - - /* - * Determine what to do based on which part of the `for` loop are present. - * 1. If there is an update expression, then `updateSegments` is not null and - * we need to assign `endOfUpdateSegments`, and if there is a test - * expression, we then need to create the looped path to get back to - * the test condition. - * 2. If there is no update expression but there is a test expression, - * then we only need to update the test segment information. - * 3. If there is no update expression and no test expression, then we - * just save `endOfInitSegments`. - */ - if (context.updateSegments) { - context.endOfUpdateSegments = forkContext.head; - - /* - * In a `for` loop that has both an update expression and a test - * condition, execution flows from the test expression into the - * loop body, to the update expression, and then back to the test - * expression to determine if the loop should continue. - * - * To account for that, we need to make a path from the end of the - * update expression to the start of the test expression. This is - * effectively what creates the loop in the code path. - */ - if (context.testSegments) { - makeLooped( - this, - context.endOfUpdateSegments, - context.testSegments - ); - } - } else if (context.testSegments) { - finalizeTestSegmentsOfFor( - context, - choiceContext, - forkContext.head - ); - } else { - context.endOfInitSegments = forkContext.head; - } - - let bodySegments = context.endOfTestSegments; - - /* - * If there is a test condition, then there `endOfTestSegments` is also - * the start of the loop body. If there isn't a test condition then - * `bodySegments` will be null and we need to look elsewhere to find - * the start of the body. - * - * The body starts at the end of the init expression and ends at the end - * of the update expression, so we use those locations to determine the - * body segments. - */ - if (!bodySegments) { - - const prevForkContext = ForkContext.newEmpty(forkContext); - - prevForkContext.add(context.endOfInitSegments); - if (context.endOfUpdateSegments) { - prevForkContext.add(context.endOfUpdateSegments); - } - - bodySegments = prevForkContext.makeNext(0, -1); - } - - /* - * If there was no test condition and no update expression, then - * `continueDestSegments` will be null. In that case, a - * `continue` should skip directly to the body of the loop. - * Otherwise, we want to keep the current `continueDestSegments`. - */ - context.continueDestSegments = context.continueDestSegments || bodySegments; - - // move pointer to the body - forkContext.replaceHead(bodySegments); - } - - /** - * Makes a code path segment for the left part of a ForInStatement and a - * ForOfStatement. - * @returns {void} - */ - makeForInOfLeft() { - const context = this.loopContext; - const forkContext = this.forkContext; - const leftSegments = forkContext.makeDisconnected(-1, -1); - - // Update state. - context.prevSegments = forkContext.head; - context.leftSegments = context.continueDestSegments = leftSegments; - forkContext.replaceHead(leftSegments); - } - - /** - * Makes a code path segment for the right part of a ForInStatement and a - * ForOfStatement. - * @returns {void} - */ - makeForInOfRight() { - const context = this.loopContext; - const forkContext = this.forkContext; - const temp = ForkContext.newEmpty(forkContext); - - temp.add(context.prevSegments); - const rightSegments = temp.makeNext(-1, -1); - - // Update state. - context.endOfLeftSegments = forkContext.head; - forkContext.replaceHead(rightSegments); - } - - /** - * Makes a code path segment for the body part of a ForInStatement and a - * ForOfStatement. - * @returns {void} - */ - makeForInOfBody() { - const context = this.loopContext; - const forkContext = this.forkContext; - const temp = ForkContext.newEmpty(forkContext); - - temp.add(context.endOfLeftSegments); - const bodySegments = temp.makeNext(-1, -1); - - // Make a path: `right` -> `left`. - makeLooped(this, forkContext.head, context.leftSegments); - - // Update state. - context.brokenForkContext.add(forkContext.head); - forkContext.replaceHead(bodySegments); - } - - //-------------------------------------------------------------------------- - // Control Statements - //-------------------------------------------------------------------------- - - /** - * Creates new context in which a `break` statement can be used. This occurs inside of a loop, - * labeled statement, or switch statement. - * @param {boolean} breakable Indicates if we are inside a statement where - * `break` without a label will exit the statement. - * @param {string|null} label The label associated with the statement. - * @returns {BreakContext} The new context. - */ - pushBreakContext(breakable, label) { - this.breakContext = new BreakContext(this.breakContext, breakable, label, this.forkContext); - return this.breakContext; - } - - /** - * Removes the top item of the break context stack. - * @returns {Object} The removed context. - */ - popBreakContext() { - const context = this.breakContext; - const forkContext = this.forkContext; - - this.breakContext = context.upper; - - // Process this context here for other than switches and loops. - if (!context.breakable) { - const brokenForkContext = context.brokenForkContext; - - if (!brokenForkContext.empty) { - brokenForkContext.add(forkContext.head); - forkContext.replaceHead(brokenForkContext.makeNext(0, -1)); - } - } - - return context; - } - - /** - * Makes a path for a `break` statement. - * - * It registers the head segment to a context of `break`. - * It makes new unreachable segment, then it set the head with the segment. - * @param {string|null} label A label of the break statement. - * @returns {void} - */ - makeBreak(label) { - const forkContext = this.forkContext; - - if (!forkContext.reachable) { - return; - } - - const context = getBreakContext(this, label); - - - if (context) { - context.brokenForkContext.add(forkContext.head); - } - - /* c8 ignore next */ - forkContext.replaceHead(forkContext.makeUnreachable(-1, -1)); - } - - /** - * Makes a path for a `continue` statement. - * - * It makes a looping path. - * It makes new unreachable segment, then it set the head with the segment. - * @param {string|null} label A label of the continue statement. - * @returns {void} - */ - makeContinue(label) { - const forkContext = this.forkContext; - - if (!forkContext.reachable) { - return; - } - - const context = getContinueContext(this, label); - - if (context) { - if (context.continueDestSegments) { - makeLooped(this, forkContext.head, context.continueDestSegments); - - // If the context is a for-in/of loop, this affects a break also. - if (context.type === "ForInStatement" || - context.type === "ForOfStatement" - ) { - context.brokenForkContext.add(forkContext.head); - } - } else { - context.continueForkContext.add(forkContext.head); - } - } - forkContext.replaceHead(forkContext.makeUnreachable(-1, -1)); - } - - /** - * Makes a path for a `return` statement. - * - * It registers the head segment to a context of `return`. - * It makes new unreachable segment, then it set the head with the segment. - * @returns {void} - */ - makeReturn() { - const forkContext = this.forkContext; - - if (forkContext.reachable) { - getReturnContext(this).returnedForkContext.add(forkContext.head); - forkContext.replaceHead(forkContext.makeUnreachable(-1, -1)); - } - } - - /** - * Makes a path for a `throw` statement. - * - * It registers the head segment to a context of `throw`. - * It makes new unreachable segment, then it set the head with the segment. - * @returns {void} - */ - makeThrow() { - const forkContext = this.forkContext; - - if (forkContext.reachable) { - getThrowContext(this).thrownForkContext.add(forkContext.head); - forkContext.replaceHead(forkContext.makeUnreachable(-1, -1)); - } - } - - /** - * Makes the final path. - * @returns {void} - */ - makeFinal() { - const segments = this.currentSegments; - - if (segments.length > 0 && segments[0].reachable) { - this.returnedForkContext.add(segments); - } - } -} - -module.exports = CodePathState; diff --git a/tools/eslint/node_modules/eslint/lib/linter/code-path-analysis/code-path.js b/tools/eslint/node_modules/eslint/lib/linter/code-path-analysis/code-path.js deleted file mode 100644 index 8c438e29a31ec8..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/linter/code-path-analysis/code-path.js +++ /dev/null @@ -1,344 +0,0 @@ -/** - * @fileoverview A class of the code path. - * @author Toru Nagashima - */ - -"use strict"; - -//------------------------------------------------------------------------------ -// Requirements -//------------------------------------------------------------------------------ - -const CodePathState = require("./code-path-state"); -const IdGenerator = require("./id-generator"); - -//------------------------------------------------------------------------------ -// Public Interface -//------------------------------------------------------------------------------ - -/** - * A code path. - */ -class CodePath { - - /** - * Creates a new instance. - * @param {Object} options Options for the function (see below). - * @param {string} options.id An identifier. - * @param {string} options.origin The type of code path origin. - * @param {CodePath|null} options.upper The code path of the upper function scope. - * @param {Function} options.onLooped A callback function to notify looping. - */ - constructor({ id, origin, upper, onLooped }) { - - /** - * The identifier of this code path. - * Rules use it to store additional information of each rule. - * @type {string} - */ - this.id = id; - - /** - * The reason that this code path was started. May be "program", - * "function", "class-field-initializer", or "class-static-block". - * @type {string} - */ - this.origin = origin; - - /** - * The code path of the upper function scope. - * @type {CodePath|null} - */ - this.upper = upper; - - /** - * The code paths of nested function scopes. - * @type {CodePath[]} - */ - this.childCodePaths = []; - - // Initializes internal state. - Object.defineProperty( - this, - "internal", - { value: new CodePathState(new IdGenerator(`${id}_`), onLooped) } - ); - - // Adds this into `childCodePaths` of `upper`. - if (upper) { - upper.childCodePaths.push(this); - } - } - - /** - * Gets the state of a given code path. - * @param {CodePath} codePath A code path to get. - * @returns {CodePathState} The state of the code path. - */ - static getState(codePath) { - return codePath.internal; - } - - /** - * The initial code path segment. This is the segment that is at the head - * of the code path. - * This is a passthrough to the underlying `CodePathState`. - * @type {CodePathSegment} - */ - get initialSegment() { - return this.internal.initialSegment; - } - - /** - * Final code path segments. These are the terminal (tail) segments in the - * code path, which is the combination of `returnedSegments` and `thrownSegments`. - * All segments in this array are reachable. - * This is a passthrough to the underlying `CodePathState`. - * @type {CodePathSegment[]} - */ - get finalSegments() { - return this.internal.finalSegments; - } - - /** - * Final code path segments that represent normal completion of the code path. - * For functions, this means both explicit `return` statements and implicit returns, - * such as the last reachable segment in a function that does not have an - * explicit `return` as this implicitly returns `undefined`. For scripts, - * modules, class field initializers, and class static blocks, this means - * all lines of code have been executed. - * These segments are also present in `finalSegments`. - * This is a passthrough to the underlying `CodePathState`. - * @type {CodePathSegment[]} - */ - get returnedSegments() { - return this.internal.returnedForkContext; - } - - /** - * Final code path segments that represent `throw` statements. - * This is a passthrough to the underlying `CodePathState`. - * These segments are also present in `finalSegments`. - * @type {CodePathSegment[]} - */ - get thrownSegments() { - return this.internal.thrownForkContext; - } - - /** - * Traverses all segments in this code path. - * - * codePath.traverseSegments((segment, controller) => { - * // do something. - * }); - * - * This method enumerates segments in order from the head. - * - * The `controller` argument has two methods: - * - * - `skip()` - skips the following segments in this branch - * - `break()` - skips all following segments in the traversal - * - * A note on the parameters: the `options` argument is optional. This means - * the first argument might be an options object or the callback function. - * @param {Object} [optionsOrCallback] Optional first and last segments to traverse. - * @param {CodePathSegment} [optionsOrCallback.first] The first segment to traverse. - * @param {CodePathSegment} [optionsOrCallback.last] The last segment to traverse. - * @param {Function} callback A callback function. - * @returns {void} - */ - traverseSegments(optionsOrCallback, callback) { - - // normalize the arguments into a callback and options - let resolvedOptions; - let resolvedCallback; - - if (typeof optionsOrCallback === "function") { - resolvedCallback = optionsOrCallback; - resolvedOptions = {}; - } else { - resolvedOptions = optionsOrCallback || {}; - resolvedCallback = callback; - } - - // determine where to start traversing from based on the options - const startSegment = resolvedOptions.first || this.internal.initialSegment; - const lastSegment = resolvedOptions.last; - - // set up initial location information - let record; - let index; - let end; - let segment = null; - - // segments that have already been visited during traversal - const visited = new Set(); - - // tracks the traversal steps - const stack = [[startSegment, 0]]; - - // segments that have been skipped during traversal - const skipped = new Set(); - - // indicates if we exited early from the traversal - let broken = false; - - /** - * Maintains traversal state. - */ - const controller = { - - /** - * Skip the following segments in this branch. - * @returns {void} - */ - skip() { - skipped.add(segment); - }, - - /** - * Stop traversal completely - do not traverse to any - * other segments. - * @returns {void} - */ - break() { - broken = true; - } - }; - - /** - * Checks if a given previous segment has been visited. - * @param {CodePathSegment} prevSegment A previous segment to check. - * @returns {boolean} `true` if the segment has been visited. - */ - function isVisited(prevSegment) { - return ( - visited.has(prevSegment) || - segment.isLoopedPrevSegment(prevSegment) - ); - } - - /** - * Checks if a given previous segment has been skipped. - * @param {CodePathSegment} prevSegment A previous segment to check. - * @returns {boolean} `true` if the segment has been skipped. - */ - function isSkipped(prevSegment) { - return ( - skipped.has(prevSegment) || - segment.isLoopedPrevSegment(prevSegment) - ); - } - - // the traversal - while (stack.length > 0) { - - /* - * This isn't a pure stack. We use the top record all the time - * but don't always pop it off. The record is popped only if - * one of the following is true: - * - * 1) We have already visited the segment. - * 2) We have not visited *all* of the previous segments. - * 3) We have traversed past the available next segments. - * - * Otherwise, we just read the value and sometimes modify the - * record as we traverse. - */ - record = stack.at(-1); - segment = record[0]; - index = record[1]; - - if (index === 0) { - - // Skip if this segment has been visited already. - if (visited.has(segment)) { - stack.pop(); - continue; - } - - // Skip if all previous segments have not been visited. - if (segment !== startSegment && - segment.prevSegments.length > 0 && - !segment.prevSegments.every(isVisited) - ) { - stack.pop(); - continue; - } - - visited.add(segment); - - - // Skips the segment if all previous segments have been skipped. - const shouldSkip = ( - skipped.size > 0 && - segment.prevSegments.length > 0 && - segment.prevSegments.every(isSkipped) - ); - - /* - * If the most recent segment hasn't been skipped, then we call - * the callback, passing in the segment and the controller. - */ - if (!shouldSkip) { - resolvedCallback.call(this, segment, controller); - - // exit if we're at the last segment - if (segment === lastSegment) { - controller.skip(); - } - - /* - * If the previous statement was executed, or if the callback - * called a method on the controller, we might need to exit the - * loop, so check for that and break accordingly. - */ - if (broken) { - break; - } - } else { - - // If the most recent segment has been skipped, then mark it as skipped. - skipped.add(segment); - } - } - - // Update the stack. - end = segment.nextSegments.length - 1; - if (index < end) { - - /* - * If we haven't yet visited all of the next segments, update - * the current top record on the stack to the next index to visit - * and then push a record for the current segment on top. - * - * Setting the current top record's index lets us know how many - * times we've been here and ensures that the segment won't be - * reprocessed (because we only process segments with an index - * of 0). - */ - record[1] += 1; - stack.push([segment.nextSegments[index], 0]); - } else if (index === end) { - - /* - * If we are at the last next segment, then reset the top record - * in the stack to next segment and set its index to 0 so it will - * be processed next. - */ - record[0] = segment.nextSegments[index]; - record[1] = 0; - } else { - - /* - * If index > end, that means we have no more segments that need - * processing. So, we pop that record off of the stack in order to - * continue traversing at the next level up. - */ - stack.pop(); - } - } - } -} - -module.exports = CodePath; diff --git a/tools/eslint/node_modules/eslint/lib/linter/code-path-analysis/debug-helpers.js b/tools/eslint/node_modules/eslint/lib/linter/code-path-analysis/debug-helpers.js deleted file mode 100644 index c0e01a8248b427..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/linter/code-path-analysis/debug-helpers.js +++ /dev/null @@ -1,203 +0,0 @@ -/** - * @fileoverview Helpers to debug for code path analysis. - * @author Toru Nagashima - */ - -"use strict"; - -//------------------------------------------------------------------------------ -// Requirements -//------------------------------------------------------------------------------ - -const debug = require("debug")("eslint:code-path"); - -//------------------------------------------------------------------------------ -// Helpers -//------------------------------------------------------------------------------ - -/** - * Gets id of a given segment. - * @param {CodePathSegment} segment A segment to get. - * @returns {string} Id of the segment. - */ -/* c8 ignore next */ -function getId(segment) { // eslint-disable-line jsdoc/require-jsdoc -- Ignoring - return segment.id + (segment.reachable ? "" : "!"); -} - -/** - * Get string for the given node and operation. - * @param {ASTNode} node The node to convert. - * @param {"enter" | "exit" | undefined} label The operation label. - * @returns {string} The string representation. - */ -function nodeToString(node, label) { - const suffix = label ? `:${label}` : ""; - - switch (node.type) { - case "Identifier": return `${node.type}${suffix} (${node.name})`; - case "Literal": return `${node.type}${suffix} (${node.value})`; - default: return `${node.type}${suffix}`; - } -} - -//------------------------------------------------------------------------------ -// Public Interface -//------------------------------------------------------------------------------ - -module.exports = { - - /** - * A flag that debug dumping is enabled or not. - * @type {boolean} - */ - enabled: debug.enabled, - - /** - * Dumps given objects. - * @param {...any} args objects to dump. - * @returns {void} - */ - dump: debug, - - /** - * Dumps the current analyzing state. - * @param {ASTNode} node A node to dump. - * @param {CodePathState} state A state to dump. - * @param {boolean} leaving A flag whether or not it's leaving - * @returns {void} - */ - dumpState: !debug.enabled ? debug : /* c8 ignore next */ function(node, state, leaving) { - for (let i = 0; i < state.currentSegments.length; ++i) { - const segInternal = state.currentSegments[i].internal; - - if (leaving) { - const last = segInternal.nodes.length - 1; - - if (last >= 0 && segInternal.nodes[last] === nodeToString(node, "enter")) { - segInternal.nodes[last] = nodeToString(node, void 0); - } else { - segInternal.nodes.push(nodeToString(node, "exit")); - } - } else { - segInternal.nodes.push(nodeToString(node, "enter")); - } - } - - debug([ - `${state.currentSegments.map(getId).join(",")})`, - `${node.type}${leaving ? ":exit" : ""}` - ].join(" ")); - }, - - /** - * Dumps a DOT code of a given code path. - * The DOT code can be visualized with Graphvis. - * @param {CodePath} codePath A code path to dump. - * @returns {void} - * @see http://www.graphviz.org - * @see http://www.webgraphviz.com - */ - dumpDot: !debug.enabled ? debug : /* c8 ignore next */ function(codePath) { - let text = - "\n" + - "digraph {\n" + - "node[shape=box,style=\"rounded,filled\",fillcolor=white];\n" + - "initial[label=\"\",shape=circle,style=filled,fillcolor=black,width=0.25,height=0.25];\n"; - - if (codePath.returnedSegments.length > 0) { - text += "final[label=\"\",shape=doublecircle,style=filled,fillcolor=black,width=0.25,height=0.25];\n"; - } - if (codePath.thrownSegments.length > 0) { - text += "thrown[label=\"โœ˜\",shape=circle,width=0.3,height=0.3,fixedsize=true];\n"; - } - - const traceMap = Object.create(null); - const arrows = this.makeDotArrows(codePath, traceMap); - - for (const id in traceMap) { // eslint-disable-line guard-for-in -- Want ability to traverse prototype - const segment = traceMap[id]; - - text += `${id}[`; - - if (segment.reachable) { - text += "label=\""; - } else { - text += "style=\"rounded,dashed,filled\",fillcolor=\"#FF9800\",label=\"<>\\n"; - } - - if (segment.internal.nodes.length > 0) { - text += segment.internal.nodes.join("\\n"); - } else { - text += "????"; - } - - text += "\"];\n"; - } - - text += `${arrows}\n`; - text += "}"; - debug("DOT", text); - }, - - /** - * Makes a DOT code of a given code path. - * The DOT code can be visualized with Graphvis. - * @param {CodePath} codePath A code path to make DOT. - * @param {Object} traceMap Optional. A map to check whether or not segments had been done. - * @returns {string} A DOT code of the code path. - */ - makeDotArrows(codePath, traceMap) { - const stack = [[codePath.initialSegment, 0]]; - const done = traceMap || Object.create(null); - let lastId = codePath.initialSegment.id; - let text = `initial->${codePath.initialSegment.id}`; - - while (stack.length > 0) { - const item = stack.pop(); - const segment = item[0]; - const index = item[1]; - - if (done[segment.id] && index === 0) { - continue; - } - done[segment.id] = segment; - - const nextSegment = segment.allNextSegments[index]; - - if (!nextSegment) { - continue; - } - - if (lastId === segment.id) { - text += `->${nextSegment.id}`; - } else { - text += `;\n${segment.id}->${nextSegment.id}`; - } - lastId = nextSegment.id; - - stack.unshift([segment, 1 + index]); - stack.push([nextSegment, 0]); - } - - codePath.returnedSegments.forEach(finalSegment => { - if (lastId === finalSegment.id) { - text += "->final"; - } else { - text += `;\n${finalSegment.id}->final`; - } - lastId = null; - }); - - codePath.thrownSegments.forEach(finalSegment => { - if (lastId === finalSegment.id) { - text += "->thrown"; - } else { - text += `;\n${finalSegment.id}->thrown`; - } - lastId = null; - }); - - return `${text};`; - } -}; diff --git a/tools/eslint/node_modules/eslint/lib/linter/code-path-analysis/fork-context.js b/tools/eslint/node_modules/eslint/lib/linter/code-path-analysis/fork-context.js deleted file mode 100644 index f5783b0d02ca7c..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/linter/code-path-analysis/fork-context.js +++ /dev/null @@ -1,349 +0,0 @@ -/** - * @fileoverview A class to operate forking. - * - * This is state of forking. - * This has a fork list and manages it. - * - * @author Toru Nagashima - */ - -"use strict"; - -//------------------------------------------------------------------------------ -// Requirements -//------------------------------------------------------------------------------ - -const assert = require("node:assert"), - CodePathSegment = require("./code-path-segment"); - -//------------------------------------------------------------------------------ -// Helpers -//------------------------------------------------------------------------------ - -/** - * Determines whether or not a given segment is reachable. - * @param {CodePathSegment} segment The segment to check. - * @returns {boolean} `true` if the segment is reachable. - */ -function isReachable(segment) { - return segment.reachable; -} - -/** - * Creates a new segment for each fork in the given context and appends it - * to the end of the specified range of segments. Ultimately, this ends up calling - * `new CodePathSegment()` for each of the forks using the `create` argument - * as a wrapper around special behavior. - * - * The `startIndex` and `endIndex` arguments specify a range of segments in - * `context` that should become `allPrevSegments` for the newly created - * `CodePathSegment` objects. - * - * When `context.segmentsList` is `[[a, b], [c, d], [e, f]]`, `begin` is `0`, and - * `end` is `-1`, this creates two new segments, `[g, h]`. This `g` is appended to - * the end of the path from `a`, `c`, and `e`. This `h` is appended to the end of - * `b`, `d`, and `f`. - * @param {ForkContext} context An instance from which the previous segments - * will be obtained. - * @param {number} startIndex The index of the first segment in the context - * that should be specified as previous segments for the newly created segments. - * @param {number} endIndex The index of the last segment in the context - * that should be specified as previous segments for the newly created segments. - * @param {Function} create A function that creates new `CodePathSegment` - * instances in a particular way. See the `CodePathSegment.new*` methods. - * @returns {Array} An array of the newly-created segments. - */ -function createSegments(context, startIndex, endIndex, create) { - - /** @type {Array>} */ - const list = context.segmentsList; - - /* - * Both `startIndex` and `endIndex` work the same way: if the number is zero - * or more, then the number is used as-is. If the number is negative, - * then that number is added to the length of the segments list to - * determine the index to use. That means -1 for either argument - * is the last element, -2 is the second to last, and so on. - * - * So if `startIndex` is 0, `endIndex` is -1, and `list.length` is 3, the - * effective `startIndex` is 0 and the effective `endIndex` is 2, so this function - * will include items at indices 0, 1, and 2. - * - * Therefore, if `startIndex` is -1 and `endIndex` is -1, that means we'll only - * be using the last segment in `list`. - */ - const normalizedBegin = startIndex >= 0 ? startIndex : list.length + startIndex; - const normalizedEnd = endIndex >= 0 ? endIndex : list.length + endIndex; - - /** @type {Array} */ - const segments = []; - - for (let i = 0; i < context.count; ++i) { - - // this is passed into `new CodePathSegment` to add to code path. - const allPrevSegments = []; - - for (let j = normalizedBegin; j <= normalizedEnd; ++j) { - allPrevSegments.push(list[j][i]); - } - - // note: `create` is just a wrapper that augments `new CodePathSegment`. - segments.push(create(context.idGenerator.next(), allPrevSegments)); - } - - return segments; -} - -/** - * Inside of a `finally` block we end up with two parallel paths. If the code path - * exits by a control statement (such as `break` or `continue`) from the `finally` - * block, then we need to merge the remaining parallel paths back into one. - * @param {ForkContext} context The fork context to work on. - * @param {Array} segments Segments to merge. - * @returns {Array} The merged segments. - */ -function mergeExtraSegments(context, segments) { - let currentSegments = segments; - - /* - * We need to ensure that the array returned from this function contains no more - * than the number of segments that the context allows. `context.count` indicates - * how many items should be in the returned array to ensure that the new segment - * entries will line up with the already existing segment entries. - */ - while (currentSegments.length > context.count) { - const merged = []; - - /* - * Because `context.count` is a factor of 2 inside of a `finally` block, - * we can divide the segment count by 2 to merge the paths together. - * This loops through each segment in the list and creates a new `CodePathSegment` - * that has the segment and the segment two slots away as previous segments. - * - * If `currentSegments` is [a,b,c,d], this will create new segments e and f, such - * that: - * - * When `i` is 0: - * a->e - * c->e - * - * When `i` is 1: - * b->f - * d->f - */ - for (let i = 0, length = Math.floor(currentSegments.length / 2); i < length; ++i) { - merged.push(CodePathSegment.newNext( - context.idGenerator.next(), - [currentSegments[i], currentSegments[i + length]] - )); - } - - /* - * Go through the loop condition one more time to see if we have the - * number of segments for the context. If not, we'll keep merging paths - * of the merged segments until we get there. - */ - currentSegments = merged; - } - - return currentSegments; -} - -//------------------------------------------------------------------------------ -// Public Interface -//------------------------------------------------------------------------------ - -/** - * Manages the forking of code paths. - */ -class ForkContext { - - /** - * Creates a new instance. - * @param {IdGenerator} idGenerator An identifier generator for segments. - * @param {ForkContext|null} upper The preceding fork context. - * @param {number} count The number of parallel segments in each element - * of `segmentsList`. - */ - constructor(idGenerator, upper, count) { - - /** - * The ID generator that will generate segment IDs for any new - * segments that are created. - * @type {IdGenerator} - */ - this.idGenerator = idGenerator; - - /** - * The preceding fork context. - * @type {ForkContext|null} - */ - this.upper = upper; - - /** - * The number of elements in each element of `segmentsList`. In most - * cases, this is 1 but can be 2 when there is a `finally` present, - * which forks the code path outside of normal flow. In the case of nested - * `finally` blocks, this can be a multiple of 2. - * @type {number} - */ - this.count = count; - - /** - * The segments within this context. Each element in this array has - * `count` elements that represent one step in each fork. For example, - * when `segmentsList` is `[[a, b], [c, d], [e, f]]`, there is one path - * a->c->e and one path b->d->f, and `count` is 2 because each element - * is an array with two elements. - * @type {Array>} - */ - this.segmentsList = []; - } - - /** - * The segments that begin this fork context. - * @type {Array} - */ - get head() { - const list = this.segmentsList; - - return list.length === 0 ? [] : list.at(-1); - } - - /** - * Indicates if the context contains no segments. - * @type {boolean} - */ - get empty() { - return this.segmentsList.length === 0; - } - - /** - * Indicates if there are any segments that are reachable. - * @type {boolean} - */ - get reachable() { - const segments = this.head; - - return segments.length > 0 && segments.some(isReachable); - } - - /** - * Creates new segments in this context and appends them to the end of the - * already existing `CodePathSegment`s specified by `startIndex` and - * `endIndex`. - * @param {number} startIndex The index of the first segment in the context - * that should be specified as previous segments for the newly created segments. - * @param {number} endIndex The index of the last segment in the context - * that should be specified as previous segments for the newly created segments. - * @returns {Array} An array of the newly created segments. - */ - makeNext(startIndex, endIndex) { - return createSegments(this, startIndex, endIndex, CodePathSegment.newNext); - } - - /** - * Creates new unreachable segments in this context and appends them to the end of the - * already existing `CodePathSegment`s specified by `startIndex` and - * `endIndex`. - * @param {number} startIndex The index of the first segment in the context - * that should be specified as previous segments for the newly created segments. - * @param {number} endIndex The index of the last segment in the context - * that should be specified as previous segments for the newly created segments. - * @returns {Array} An array of the newly created segments. - */ - makeUnreachable(startIndex, endIndex) { - return createSegments(this, startIndex, endIndex, CodePathSegment.newUnreachable); - } - - /** - * Creates new segments in this context and does not append them to the end - * of the already existing `CodePathSegment`s specified by `startIndex` and - * `endIndex`. The `startIndex` and `endIndex` are only used to determine if - * the new segments should be reachable. If any of the segments in this range - * are reachable then the new segments are also reachable; otherwise, the new - * segments are unreachable. - * @param {number} startIndex The index of the first segment in the context - * that should be considered for reachability. - * @param {number} endIndex The index of the last segment in the context - * that should be considered for reachability. - * @returns {Array} An array of the newly created segments. - */ - makeDisconnected(startIndex, endIndex) { - return createSegments(this, startIndex, endIndex, CodePathSegment.newDisconnected); - } - - /** - * Adds segments to the head of this context. - * @param {Array} segments The segments to add. - * @returns {void} - */ - add(segments) { - assert(segments.length >= this.count, `${segments.length} >= ${this.count}`); - this.segmentsList.push(mergeExtraSegments(this, segments)); - } - - /** - * Replaces the head segments with the given segments. - * The current head segments are removed. - * @param {Array} replacementHeadSegments The new head segments. - * @returns {void} - */ - replaceHead(replacementHeadSegments) { - assert( - replacementHeadSegments.length >= this.count, - `${replacementHeadSegments.length} >= ${this.count}` - ); - this.segmentsList.splice(-1, 1, mergeExtraSegments(this, replacementHeadSegments)); - } - - /** - * Adds all segments of a given fork context into this context. - * @param {ForkContext} otherForkContext The fork context to add from. - * @returns {void} - */ - addAll(otherForkContext) { - assert(otherForkContext.count === this.count); - this.segmentsList.push(...otherForkContext.segmentsList); - } - - /** - * Clears all segments in this context. - * @returns {void} - */ - clear() { - this.segmentsList = []; - } - - /** - * Creates a new root context, meaning that there are no parent - * fork contexts. - * @param {IdGenerator} idGenerator An identifier generator for segments. - * @returns {ForkContext} New fork context. - */ - static newRoot(idGenerator) { - const context = new ForkContext(idGenerator, null, 1); - - context.add([CodePathSegment.newRoot(idGenerator.next())]); - - return context; - } - - /** - * Creates an empty fork context preceded by a given context. - * @param {ForkContext} parentContext The parent fork context. - * @param {boolean} shouldForkLeavingPath Indicates that we are inside of - * a `finally` block and should therefore fork the path that leaves - * `finally`. - * @returns {ForkContext} New fork context. - */ - static newEmpty(parentContext, shouldForkLeavingPath) { - return new ForkContext( - parentContext.idGenerator, - parentContext, - (shouldForkLeavingPath ? 2 : 1) * parentContext.count - ); - } -} - -module.exports = ForkContext; diff --git a/tools/eslint/node_modules/eslint/lib/linter/code-path-analysis/id-generator.js b/tools/eslint/node_modules/eslint/lib/linter/code-path-analysis/id-generator.js deleted file mode 100644 index b580104e1ac263..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/linter/code-path-analysis/id-generator.js +++ /dev/null @@ -1,45 +0,0 @@ -/** - * @fileoverview A class of identifiers generator for code path segments. - * - * Each rule uses the identifier of code path segments to store additional - * information of the code path. - * - * @author Toru Nagashima - */ - -"use strict"; - -//------------------------------------------------------------------------------ -// Public Interface -//------------------------------------------------------------------------------ - -/** - * A generator for unique ids. - */ -class IdGenerator { - - /** - * @param {string} prefix Optional. A prefix of generated ids. - */ - constructor(prefix) { - this.prefix = String(prefix); - this.n = 0; - } - - /** - * Generates id. - * @returns {string} A generated id. - */ - next() { - this.n = 1 + this.n | 0; - - /* c8 ignore start */ - if (this.n < 0) { - this.n = 1; - }/* c8 ignore stop */ - - return this.prefix + this.n; - } -} - -module.exports = IdGenerator; diff --git a/tools/eslint/node_modules/eslint/lib/linter/config-comment-parser.js b/tools/eslint/node_modules/eslint/lib/linter/config-comment-parser.js deleted file mode 100644 index ec05cf8aadadee..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/linter/config-comment-parser.js +++ /dev/null @@ -1,169 +0,0 @@ -/** - * @fileoverview Config Comment Parser - * @author Nicholas C. Zakas - */ - -/* eslint class-methods-use-this: off -- Methods desired on instance */ -"use strict"; - -//------------------------------------------------------------------------------ -// Requirements -//------------------------------------------------------------------------------ - -const levn = require("levn"), - { - Legacy: { - ConfigOps - } - } = require("@eslint/eslintrc/universal"), - { - directivesPattern - } = require("../shared/directives"); - -const debug = require("debug")("eslint:config-comment-parser"); - -//------------------------------------------------------------------------------ -// Public Interface -//------------------------------------------------------------------------------ - -/** - * Object to parse ESLint configuration comments inside JavaScript files. - * @name ConfigCommentParser - */ -module.exports = class ConfigCommentParser { - - /** - * Parses a list of "name:string_value" or/and "name" options divided by comma or - * whitespace. Used for "global" comments. - * @param {string} string The string to parse. - * @param {Comment} comment The comment node which has the string. - * @returns {Object} Result map object of names and string values, or null values if no value was provided - */ - parseStringConfig(string, comment) { - debug("Parsing String config"); - - const items = {}; - - // Collapse whitespace around `:` and `,` to make parsing easier - const trimmedString = string.replace(/\s*([:,])\s*/gu, "$1"); - - trimmedString.split(/\s|,+/u).forEach(name => { - if (!name) { - return; - } - - // value defaults to null (if not provided), e.g: "foo" => ["foo", null] - const [key, value = null] = name.split(":"); - - items[key] = { value, comment }; - }); - return items; - } - - /** - * Parses a JSON-like config. - * @param {string} string The string to parse. - * @returns {({success: true, config: Object}|{success: false, error: {message: string}})} Result map object - */ - parseJsonConfig(string) { - debug("Parsing JSON config"); - - // Parses a JSON-like comment by the same way as parsing CLI option. - try { - const items = levn.parse("Object", string) || {}; - - // Some tests say that it should ignore invalid comments such as `/*eslint no-alert:abc*/`. - // Also, commaless notations have invalid severity: - // "no-alert: 2 no-console: 2" --> {"no-alert": "2 no-console: 2"} - // Should ignore that case as well. - if (ConfigOps.isEverySeverityValid(items)) { - return { - success: true, - config: items - }; - } - } catch { - - debug("Levn parsing failed; falling back to manual parsing."); - - // ignore to parse the string by a fallback. - } - - /* - * Optionator cannot parse commaless notations. - * But we are supporting that. So this is a fallback for that. - */ - const normalizedString = string.replace(/([-a-zA-Z0-9/]+):/gu, "\"$1\":").replace(/(\]|[0-9])\s+(?=")/u, "$1,"); - - try { - const items = JSON.parse(`{${normalizedString}}`); - - return { - success: true, - config: items - }; - } catch (ex) { - debug("Manual parsing failed."); - - return { - success: false, - error: { - message: `Failed to parse JSON from '${normalizedString}': ${ex.message}` - } - }; - - } - } - - /** - * Parses a config of values separated by comma. - * @param {string} string The string to parse. - * @returns {Object} Result map of values and true values - */ - parseListConfig(string) { - debug("Parsing list config"); - - const items = {}; - - string.split(",").forEach(name => { - const trimmedName = name.trim().replace(/^(?['"]?)(?.*)\k$/us, "$"); - - if (trimmedName) { - items[trimmedName] = true; - } - }); - return items; - } - - /** - * Extract the directive and the justification from a given directive comment and trim them. - * @param {string} value The comment text to extract. - * @returns {{directivePart: string, justificationPart: string}} The extracted directive and justification. - */ - extractDirectiveComment(value) { - const match = /\s-{2,}\s/u.exec(value); - - if (!match) { - return { directivePart: value.trim(), justificationPart: "" }; - } - - const directive = value.slice(0, match.index).trim(); - const justification = value.slice(match.index + match[0].length).trim(); - - return { directivePart: directive, justificationPart: justification }; - } - - /** - * Parses a directive comment into directive text and value. - * @param {Comment} comment The comment node with the directive to be parsed. - * @returns {{directiveText: string, directiveValue: string}} The directive text and value. - */ - parseDirective(comment) { - const { directivePart } = this.extractDirectiveComment(comment.value); - const match = directivesPattern.exec(directivePart); - const directiveText = match[1]; - const directiveValue = directivePart.slice(match.index + directiveText.length); - - return { directiveText, directiveValue }; - } -}; diff --git a/tools/eslint/node_modules/eslint/lib/linter/index.js b/tools/eslint/node_modules/eslint/lib/linter/index.js deleted file mode 100644 index 9e5397768bb99f..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/linter/index.js +++ /dev/null @@ -1,11 +0,0 @@ -"use strict"; - -const { Linter } = require("./linter"); -const SourceCodeFixer = require("./source-code-fixer"); - -module.exports = { - Linter, - - // For testers. - SourceCodeFixer -}; diff --git a/tools/eslint/node_modules/eslint/lib/linter/interpolate.js b/tools/eslint/node_modules/eslint/lib/linter/interpolate.js deleted file mode 100644 index 5f4ff92273633c..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/linter/interpolate.js +++ /dev/null @@ -1,50 +0,0 @@ -/** - * @fileoverview Interpolate keys from an object into a string with {{ }} markers. - * @author Jed Fox - */ - -"use strict"; - -//------------------------------------------------------------------------------ -// Public Interface -//------------------------------------------------------------------------------ - -/** - * Returns a global expression matching placeholders in messages. - * @returns {RegExp} Global regular expression matching placeholders - */ -function getPlaceholderMatcher() { - return /\{\{([^{}]+?)\}\}/gu; -} - -/** - * Replaces {{ placeholders }} in the message with the provided data. - * Does not replace placeholders not available in the data. - * @param {string} text Original message with potential placeholders - * @param {Record} data Map of placeholder name to its value - * @returns {string} Message with replaced placeholders - */ -function interpolate(text, data) { - if (!data) { - return text; - } - - const matcher = getPlaceholderMatcher(); - - // Substitution content for any {{ }} markers. - return text.replace(matcher, (fullMatch, termWithWhitespace) => { - const term = termWithWhitespace.trim(); - - if (term in data) { - return data[term]; - } - - // Preserve old behavior: If parameter name not provided, don't replace it. - return fullMatch; - }); -} - -module.exports = { - getPlaceholderMatcher, - interpolate -}; diff --git a/tools/eslint/node_modules/eslint/lib/linter/linter.js b/tools/eslint/node_modules/eslint/lib/linter/linter.js deleted file mode 100644 index 86b51b6488fbf1..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/linter/linter.js +++ /dev/null @@ -1,2386 +0,0 @@ -/** - * @fileoverview Main Linter Class - * @author Gyandeep Singh - * @author aladdin-add - */ - -"use strict"; - -//------------------------------------------------------------------------------ -// Requirements -//------------------------------------------------------------------------------ - -const - path = require("node:path"), - eslintScope = require("eslint-scope"), - evk = require("eslint-visitor-keys"), - espree = require("espree"), - merge = require("lodash.merge"), - pkg = require("../../package.json"), - { - directivesPattern - } = require("../shared/directives"), - { - Legacy: { - ConfigOps, - ConfigValidator, - environments: BuiltInEnvironments - } - } = require("@eslint/eslintrc/universal"), - Traverser = require("../shared/traverser"), - { SourceCode } = require("../languages/js/source-code"), - applyDisableDirectives = require("./apply-disable-directives"), - ConfigCommentParser = require("./config-comment-parser"), - NodeEventGenerator = require("./node-event-generator"), - createReportTranslator = require("./report-translator"), - Rules = require("./rules"), - createEmitter = require("./safe-emitter"), - SourceCodeFixer = require("./source-code-fixer"), - timing = require("./timing"), - ruleReplacements = require("../../conf/replacements.json"); -const { getRuleFromConfig } = require("../config/flat-config-helpers"); -const { FlatConfigArray } = require("../config/flat-config-array"); -const { startTime, endTime } = require("../shared/stats"); -const { RuleValidator } = require("../config/rule-validator"); -const { assertIsRuleSeverity } = require("../config/flat-config-schema"); -const { normalizeSeverityToString } = require("../shared/severity"); -const jslang = require("../languages/js"); -const { activeFlags } = require("../shared/flags"); -const debug = require("debug")("eslint:linter"); -const MAX_AUTOFIX_PASSES = 10; -const DEFAULT_PARSER_NAME = "espree"; -const DEFAULT_ECMA_VERSION = 5; -const commentParser = new ConfigCommentParser(); -const DEFAULT_ERROR_LOC = { start: { line: 1, column: 0 }, end: { line: 1, column: 1 } }; -const parserSymbol = Symbol.for("eslint.RuleTester.parser"); -const { LATEST_ECMA_VERSION } = require("../../conf/ecma-version"); -const { VFile } = require("./vfile"); -const STEP_KIND_VISIT = 1; -const STEP_KIND_CALL = 2; - -//------------------------------------------------------------------------------ -// Typedefs -//------------------------------------------------------------------------------ - -/** @typedef {import("../shared/types").ConfigData} ConfigData */ -/** @typedef {import("../shared/types").Environment} Environment */ -/** @typedef {import("../shared/types").GlobalConf} GlobalConf */ -/** @typedef {import("../shared/types").LintMessage} LintMessage */ -/** @typedef {import("../shared/types").SuppressedLintMessage} SuppressedLintMessage */ -/** @typedef {import("../shared/types").ParserOptions} ParserOptions */ -/** @typedef {import("../shared/types").LanguageOptions} LanguageOptions */ -/** @typedef {import("../shared/types").Processor} Processor */ -/** @typedef {import("../shared/types").Rule} Rule */ -/** @typedef {import("../shared/types").Times} Times */ -/** @typedef {import("@eslint/core").Language} Language */ -/** @typedef {import("@eslint/core").RuleSeverity} RuleSeverity */ -/** @typedef {import("@eslint/core").RuleConfig} RuleConfig */ - - -/* eslint-disable jsdoc/valid-types -- https://github.com/jsdoc-type-pratt-parser/jsdoc-type-pratt-parser/issues/4#issuecomment-778805577 */ -/** - * @template T - * @typedef {{ [P in keyof T]-?: T[P] }} Required - */ -/* eslint-enable jsdoc/valid-types -- https://github.com/jsdoc-type-pratt-parser/jsdoc-type-pratt-parser/issues/4#issuecomment-778805577 */ - -/** - * @typedef {Object} DisableDirective - * @property {("disable"|"enable"|"disable-line"|"disable-next-line")} type Type of directive - * @property {number} line The line number - * @property {number} column The column number - * @property {(string|null)} ruleId The rule ID - * @property {string} justification The justification of directive - */ - -/** - * The private data for `Linter` instance. - * @typedef {Object} LinterInternalSlots - * @property {ConfigArray|null} lastConfigArray The `ConfigArray` instance that the last `verify()` call used. - * @property {SourceCode|null} lastSourceCode The `SourceCode` instance that the last `verify()` call used. - * @property {SuppressedLintMessage[]} lastSuppressedMessages The `SuppressedLintMessage[]` instance that the last `verify()` call produced. - * @property {Map} parserMap The loaded parsers. - * @property {Times} times The times spent on applying a rule to a file (see `stats` option). - * @property {Rules} ruleMap The loaded rules. - */ - -/** - * @typedef {Object} VerifyOptions - * @property {boolean} [allowInlineConfig] Allow/disallow inline comments' ability - * to change config once it is set. Defaults to true if not supplied. - * Useful if you want to validate JS without comments overriding rules. - * @property {boolean} [disableFixes] if `true` then the linter doesn't make `fix` - * properties into the lint result. - * @property {string} [filename] the filename of the source code. - * @property {boolean | "off" | "warn" | "error"} [reportUnusedDisableDirectives] Adds reported errors for - * unused `eslint-disable` directives. - * @property {Function} [ruleFilter] A predicate function that determines whether a given rule should run. - */ - -/** - * @typedef {Object} ProcessorOptions - * @property {(filename:string, text:string) => boolean} [filterCodeBlock] the - * predicate function that selects adopt code blocks. - * @property {Processor.postprocess} [postprocess] postprocessor for report - * messages. If provided, this should accept an array of the message lists - * for each code block returned from the preprocessor, apply a mapping to - * the messages as appropriate, and return a one-dimensional array of - * messages. - * @property {Processor.preprocess} [preprocess] preprocessor for source text. - * If provided, this should accept a string of source text, and return an - * array of code blocks to lint. - */ - -/** - * @typedef {Object} FixOptions - * @property {boolean | ((message: LintMessage) => boolean)} [fix] Determines - * whether fixes should be applied. - */ - -/** - * @typedef {Object} InternalOptions - * @property {string | null} warnInlineConfig The config name what `noInlineConfig` setting came from. If `noInlineConfig` setting didn't exist, this is null. If this is a config name, then the linter warns directive comments. - * @property {"off" | "warn" | "error"} reportUnusedDisableDirectives (boolean values were normalized) - */ - -//------------------------------------------------------------------------------ -// Helpers -//------------------------------------------------------------------------------ - -/** - * Determines if a given object is Espree. - * @param {Object} parser The parser to check. - * @returns {boolean} True if the parser is Espree or false if not. - */ -function isEspree(parser) { - return !!(parser === espree || parser[parserSymbol] === espree); -} - -/** - * Ensures that variables representing built-in properties of the Global Object, - * and any globals declared by special block comments, are present in the global - * scope. - * @param {Scope} globalScope The global scope. - * @param {Object} configGlobals The globals declared in configuration - * @param {{exportedVariables: Object, enabledGlobals: Object}} commentDirectives Directives from comment configuration - * @returns {void} - */ -function addDeclaredGlobals(globalScope, configGlobals, { exportedVariables, enabledGlobals }) { - - // Define configured global variables. - for (const id of new Set([...Object.keys(configGlobals), ...Object.keys(enabledGlobals)])) { - - /* - * `ConfigOps.normalizeConfigGlobal` will throw an error if a configured global value is invalid. However, these errors would - * typically be caught when validating a config anyway (validity for inline global comments is checked separately). - */ - const configValue = configGlobals[id] === void 0 ? void 0 : ConfigOps.normalizeConfigGlobal(configGlobals[id]); - const commentValue = enabledGlobals[id] && enabledGlobals[id].value; - const value = commentValue || configValue; - const sourceComments = enabledGlobals[id] && enabledGlobals[id].comments; - - if (value === "off") { - continue; - } - - let variable = globalScope.set.get(id); - - if (!variable) { - variable = new eslintScope.Variable(id, globalScope); - - globalScope.variables.push(variable); - globalScope.set.set(id, variable); - } - - variable.eslintImplicitGlobalSetting = configValue; - variable.eslintExplicitGlobal = sourceComments !== void 0; - variable.eslintExplicitGlobalComments = sourceComments; - variable.writeable = (value === "writable"); - } - - // mark all exported variables as such - Object.keys(exportedVariables).forEach(name => { - const variable = globalScope.set.get(name); - - if (variable) { - variable.eslintUsed = true; - variable.eslintExported = true; - } - }); - - /* - * "through" contains all references which definitions cannot be found. - * Since we augment the global scope using configuration, we need to update - * references and remove the ones that were added by configuration. - */ - globalScope.through = globalScope.through.filter(reference => { - const name = reference.identifier.name; - const variable = globalScope.set.get(name); - - if (variable) { - - /* - * Links the variable and the reference. - * And this reference is removed from `Scope#through`. - */ - reference.resolved = variable; - variable.references.push(reference); - - return false; - } - - return true; - }); -} - -/** - * creates a missing-rule message. - * @param {string} ruleId the ruleId to create - * @returns {string} created error message - * @private - */ -function createMissingRuleMessage(ruleId) { - return Object.hasOwn(ruleReplacements.rules, ruleId) - ? `Rule '${ruleId}' was removed and replaced by: ${ruleReplacements.rules[ruleId].join(", ")}` - : `Definition for rule '${ruleId}' was not found.`; -} - -/** - * Updates a given location based on the language offsets. This allows us to - * change 0-based locations to 1-based locations. We always want ESLint - * reporting lines and columns starting from 1. - * @param {Object} location The location to update. - * @param {number} location.line The starting line number. - * @param {number} location.column The starting column number. - * @param {number} [location.endLine] The ending line number. - * @param {number} [location.endColumn] The ending column number. - * @param {Language} language The language to use to adjust the location information. - * @returns {Object} The updated location. - */ -function updateLocationInformation({ line, column, endLine, endColumn }, language) { - - const columnOffset = language.columnStart === 1 ? 0 : 1; - const lineOffset = language.lineStart === 1 ? 0 : 1; - - // calculate separately to account for undefined - const finalEndLine = endLine === void 0 ? endLine : endLine + lineOffset; - const finalEndColumn = endColumn === void 0 ? endColumn : endColumn + columnOffset; - - return { - line: line + lineOffset, - column: column + columnOffset, - endLine: finalEndLine, - endColumn: finalEndColumn - }; -} - -/** - * creates a linting problem - * @param {Object} options to create linting error - * @param {string} [options.ruleId] the ruleId to report - * @param {Object} [options.loc] the loc to report - * @param {string} [options.message] the error message to report - * @param {RuleSeverity} [options.severity] the error message to report - * @param {Language} [options.language] the language to use to adjust the location information - * @returns {LintMessage} created problem, returns a missing-rule problem if only provided ruleId. - * @private - */ -function createLintingProblem(options) { - const { - ruleId = null, - loc = DEFAULT_ERROR_LOC, - message = createMissingRuleMessage(options.ruleId), - severity = 2, - - // fallback for eslintrc mode - language = { - columnStart: 0, - lineStart: 1 - } - } = options; - - return { - ruleId, - message, - ...updateLocationInformation({ - line: loc.start.line, - column: loc.start.column, - endLine: loc.end.line, - endColumn: loc.end.column - }, language), - severity, - nodeType: null - }; -} - -/** - * Creates a collection of disable directives from a comment - * @param {Object} options to create disable directives - * @param {("disable"|"enable"|"disable-line"|"disable-next-line")} options.type The type of directive comment - * @param {string} options.value The value after the directive in the comment - * comment specified no specific rules, so it applies to all rules (e.g. `eslint-disable`) - * @param {string} options.justification The justification of the directive - * @param {ASTNode|token} options.node The Comment node/token. - * @param {function(string): {create: Function}} ruleMapper A map from rule IDs to defined rules - * @param {Language} language The language to use to adjust the location information. - * @returns {Object} Directives and problems from the comment - */ -function createDisableDirectives({ type, value, justification, node }, ruleMapper, language) { - const ruleIds = Object.keys(commentParser.parseListConfig(value)); - const directiveRules = ruleIds.length ? ruleIds : [null]; - const result = { - directives: [], // valid disable directives - directiveProblems: [] // problems in directives - }; - const parentDirective = { node, ruleIds }; - - for (const ruleId of directiveRules) { - - // push to directives, if the rule is defined(including null, e.g. /*eslint enable*/) - if (ruleId === null || !!ruleMapper(ruleId)) { - if (type === "disable-next-line") { - const { line, column } = updateLocationInformation( - node.loc.end, - language - ); - - result.directives.push({ - parentDirective, - type, - line, - column, - ruleId, - justification - }); - } else { - const { line, column } = updateLocationInformation( - node.loc.start, - language - ); - - result.directives.push({ - parentDirective, - type, - line, - column, - ruleId, - justification - }); - } - } else { - result.directiveProblems.push(createLintingProblem({ ruleId, loc: node.loc, language })); - } - } - return result; -} - -/** - * Parses comments in file to extract file-specific config of rules, globals - * and environments and merges them with global config; also code blocks - * where reporting is disabled or enabled and merges them with reporting config. - * @param {SourceCode} sourceCode The SourceCode object to get comments from. - * @param {function(string): {create: Function}} ruleMapper A map from rule IDs to defined rules - * @param {string|null} warnInlineConfig If a string then it should warn directive comments as disabled. The string value is the config name what the setting came from. - * @param {ConfigData} config Provided config. - * @returns {{configuredRules: Object, enabledGlobals: {value:string,comment:Token}[], exportedVariables: Object, problems: LintMessage[], disableDirectives: DisableDirective[]}} - * A collection of the directive comments that were found, along with any problems that occurred when parsing - */ -function getDirectiveComments(sourceCode, ruleMapper, warnInlineConfig, config) { - const configuredRules = {}; - const enabledGlobals = Object.create(null); - const exportedVariables = {}; - const problems = []; - const disableDirectives = []; - const validator = new ConfigValidator({ - builtInRules: Rules - }); - - sourceCode.getInlineConfigNodes().filter(token => token.type !== "Shebang").forEach(comment => { - const { directivePart, justificationPart } = commentParser.extractDirectiveComment(comment.value); - - const match = directivesPattern.exec(directivePart); - - if (!match) { - return; - } - const directiveText = match[1]; - const lineCommentSupported = /^eslint-disable-(next-)?line$/u.test(directiveText); - - if (comment.type === "Line" && !lineCommentSupported) { - return; - } - - if (warnInlineConfig) { - const kind = comment.type === "Block" ? `/*${directiveText}*/` : `//${directiveText}`; - - problems.push(createLintingProblem({ - ruleId: null, - message: `'${kind}' has no effect because you have 'noInlineConfig' setting in ${warnInlineConfig}.`, - loc: comment.loc, - severity: 1 - })); - return; - } - - if (directiveText === "eslint-disable-line" && comment.loc.start.line !== comment.loc.end.line) { - const message = `${directiveText} comment should not span multiple lines.`; - - problems.push(createLintingProblem({ - ruleId: null, - message, - loc: comment.loc - })); - return; - } - - const directiveValue = directivePart.slice(match.index + directiveText.length); - - switch (directiveText) { - case "eslint-disable": - case "eslint-enable": - case "eslint-disable-next-line": - case "eslint-disable-line": { - const directiveType = directiveText.slice("eslint-".length); - const { directives, directiveProblems } = createDisableDirectives({ - type: directiveType, - value: directiveValue, - justification: justificationPart, - node: comment - }, ruleMapper, jslang); - - disableDirectives.push(...directives); - problems.push(...directiveProblems); - break; - } - - case "exported": - Object.assign(exportedVariables, commentParser.parseListConfig(directiveValue, comment)); - break; - - case "globals": - case "global": - for (const [id, { value }] of Object.entries(commentParser.parseStringConfig(directiveValue, comment))) { - let normalizedValue; - - try { - normalizedValue = ConfigOps.normalizeConfigGlobal(value); - } catch (err) { - problems.push(createLintingProblem({ - ruleId: null, - loc: comment.loc, - message: err.message - })); - continue; - } - - if (enabledGlobals[id]) { - enabledGlobals[id].comments.push(comment); - enabledGlobals[id].value = normalizedValue; - } else { - enabledGlobals[id] = { - comments: [comment], - value: normalizedValue - }; - } - } - break; - - case "eslint": { - const parseResult = commentParser.parseJsonConfig(directiveValue); - - if (parseResult.success) { - Object.keys(parseResult.config).forEach(name => { - const rule = ruleMapper(name); - const ruleValue = parseResult.config[name]; - - if (!rule) { - problems.push(createLintingProblem({ ruleId: name, loc: comment.loc })); - return; - } - - if (Object.hasOwn(configuredRules, name)) { - problems.push(createLintingProblem({ - message: `Rule "${name}" is already configured by another configuration comment in the preceding code. This configuration is ignored.`, - loc: comment.loc - })); - return; - } - - let ruleOptions = Array.isArray(ruleValue) ? ruleValue : [ruleValue]; - - /* - * If the rule was already configured, inline rule configuration that - * only has severity should retain options from the config and just override the severity. - * - * Example: - * - * { - * rules: { - * curly: ["error", "multi"] - * } - * } - * - * /* eslint curly: ["warn"] * / - * - * Results in: - * - * curly: ["warn", "multi"] - */ - if ( - - /* - * If inline config for the rule has only severity - */ - ruleOptions.length === 1 && - - /* - * And the rule was already configured - */ - config.rules && Object.hasOwn(config.rules, name) - ) { - - /* - * Then use severity from the inline config and options from the provided config - */ - ruleOptions = [ - ruleOptions[0], // severity from the inline config - ...Array.isArray(config.rules[name]) ? config.rules[name].slice(1) : [] // options from the provided config - ]; - } - - try { - validator.validateRuleOptions(rule, name, ruleOptions); - } catch (err) { - - /* - * If the rule has invalid `meta.schema`, throw the error because - * this is not an invalid inline configuration but an invalid rule. - */ - if (err.code === "ESLINT_INVALID_RULE_OPTIONS_SCHEMA") { - throw err; - } - - problems.push(createLintingProblem({ - ruleId: name, - message: err.message, - loc: comment.loc - })); - - // do not apply the config, if found invalid options. - return; - } - - configuredRules[name] = ruleOptions; - }); - } else { - const problem = createLintingProblem({ - ruleId: null, - loc: comment.loc, - message: parseResult.error.message - }); - - problem.fatal = true; - problems.push(problem); - } - - break; - } - - // no default - } - }); - - return { - configuredRules, - enabledGlobals, - exportedVariables, - problems, - disableDirectives - }; -} - -/** - * Parses comments in file to extract disable directives. - * @param {SourceCode} sourceCode The SourceCode object to get comments from. - * @param {function(string): {create: Function}} ruleMapper A map from rule IDs to defined rules - * @param {Language} language The language to use to adjust the location information - * @returns {{problems: LintMessage[], disableDirectives: DisableDirective[]}} - * A collection of the directive comments that were found, along with any problems that occurred when parsing - */ -function getDirectiveCommentsForFlatConfig(sourceCode, ruleMapper, language) { - const disableDirectives = []; - const problems = []; - - if (sourceCode.getDisableDirectives) { - const { - directives: directivesSources, - problems: directivesProblems - } = sourceCode.getDisableDirectives(); - - problems.push(...directivesProblems.map(directiveProblem => createLintingProblem({ - ...directiveProblem, - language - }))); - - directivesSources.forEach(directive => { - const { directives, directiveProblems } = createDisableDirectives(directive, ruleMapper, language); - - disableDirectives.push(...directives); - problems.push(...directiveProblems); - }); - } - - return { - problems, - disableDirectives - }; -} - -/** - * Normalize ECMAScript version from the initial config - * @param {Parser} parser The parser which uses this options. - * @param {number} ecmaVersion ECMAScript version from the initial config - * @returns {number} normalized ECMAScript version - */ -function normalizeEcmaVersion(parser, ecmaVersion) { - - if (isEspree(parser)) { - if (ecmaVersion === "latest") { - return espree.latestEcmaVersion; - } - } - - /* - * Calculate ECMAScript edition number from official year version starting with - * ES2015, which corresponds with ES6 (or a difference of 2009). - */ - return ecmaVersion >= 2015 ? ecmaVersion - 2009 : ecmaVersion; -} - -/** - * Normalize ECMAScript version from the initial config into languageOptions (year) - * format. - * @param {any} [ecmaVersion] ECMAScript version from the initial config - * @returns {number} normalized ECMAScript version - */ -function normalizeEcmaVersionForLanguageOptions(ecmaVersion) { - - switch (ecmaVersion) { - case 3: - return 3; - - // void 0 = no ecmaVersion specified so use the default - case 5: - case void 0: - return 5; - - default: - if (typeof ecmaVersion === "number") { - return ecmaVersion >= 2015 ? ecmaVersion : ecmaVersion + 2009; - } - } - - /* - * We default to the latest supported ecmaVersion for everything else. - * Remember, this is for languageOptions.ecmaVersion, which sets the version - * that is used for a number of processes inside of ESLint. It's normally - * safe to assume people want the latest unless otherwise specified. - */ - return LATEST_ECMA_VERSION; -} - -const eslintEnvPattern = /\/\*\s*eslint-env\s(.+?)(?:\*\/|$)/gsu; - -/** - * Checks whether or not there is a comment which has "eslint-env *" in a given text. - * @param {string} text A source code text to check. - * @returns {Object|null} A result of parseListConfig() with "eslint-env *" comment. - */ -function findEslintEnv(text) { - let match, retv; - - eslintEnvPattern.lastIndex = 0; - - while ((match = eslintEnvPattern.exec(text)) !== null) { - if (match[0].endsWith("*/")) { - retv = Object.assign( - retv || {}, - commentParser.parseListConfig(commentParser.extractDirectiveComment(match[1]).directivePart) - ); - } - } - - return retv; -} - -/** - * Convert "/path/to/" to "". - * `CLIEngine#executeOnText()` method gives "/path/to/" if the filename - * was omitted because `configArray.extractConfig()` requires an absolute path. - * But the linter should pass `` to `RuleContext#filename` in that - * case. - * Also, code blocks can have their virtual filename. If the parent filename was - * ``, the virtual filename is `/0_foo.js` or something like (i.e., - * it's not an absolute path). - * @param {string} filename The filename to normalize. - * @returns {string} The normalized filename. - */ -function normalizeFilename(filename) { - const parts = filename.split(path.sep); - const index = parts.lastIndexOf(""); - - return index === -1 ? filename : parts.slice(index).join(path.sep); -} - -/** - * Normalizes the possible options for `linter.verify` and `linter.verifyAndFix` to a - * consistent shape. - * @param {VerifyOptions} providedOptions Options - * @param {ConfigData} config Config. - * @returns {Required & InternalOptions} Normalized options - */ -function normalizeVerifyOptions(providedOptions, config) { - - const linterOptions = config.linterOptions || config; - - // .noInlineConfig for eslintrc, .linterOptions.noInlineConfig for flat - const disableInlineConfig = linterOptions.noInlineConfig === true; - const ignoreInlineConfig = providedOptions.allowInlineConfig === false; - const configNameOfNoInlineConfig = config.configNameOfNoInlineConfig - ? ` (${config.configNameOfNoInlineConfig})` - : ""; - - let reportUnusedDisableDirectives = providedOptions.reportUnusedDisableDirectives; - - if (typeof reportUnusedDisableDirectives === "boolean") { - reportUnusedDisableDirectives = reportUnusedDisableDirectives ? "error" : "off"; - } - if (typeof reportUnusedDisableDirectives !== "string") { - if (typeof linterOptions.reportUnusedDisableDirectives === "boolean") { - reportUnusedDisableDirectives = linterOptions.reportUnusedDisableDirectives ? "warn" : "off"; - } else { - reportUnusedDisableDirectives = linterOptions.reportUnusedDisableDirectives === void 0 ? "off" : normalizeSeverityToString(linterOptions.reportUnusedDisableDirectives); - } - } - - let ruleFilter = providedOptions.ruleFilter; - - if (typeof ruleFilter !== "function") { - ruleFilter = () => true; - } - - return { - filename: normalizeFilename(providedOptions.filename || ""), - allowInlineConfig: !ignoreInlineConfig, - warnInlineConfig: disableInlineConfig && !ignoreInlineConfig - ? `your config${configNameOfNoInlineConfig}` - : null, - reportUnusedDisableDirectives, - disableFixes: Boolean(providedOptions.disableFixes), - stats: providedOptions.stats, - ruleFilter - }; -} - -/** - * Combines the provided parserOptions with the options from environments - * @param {Parser} parser The parser which uses this options. - * @param {ParserOptions} providedOptions The provided 'parserOptions' key in a config - * @param {Environment[]} enabledEnvironments The environments enabled in configuration and with inline comments - * @returns {ParserOptions} Resulting parser options after merge - */ -function resolveParserOptions(parser, providedOptions, enabledEnvironments) { - - const parserOptionsFromEnv = enabledEnvironments - .filter(env => env.parserOptions) - .reduce((parserOptions, env) => merge(parserOptions, env.parserOptions), {}); - const mergedParserOptions = merge(parserOptionsFromEnv, providedOptions || {}); - const isModule = mergedParserOptions.sourceType === "module"; - - if (isModule) { - - /* - * can't have global return inside of modules - * TODO: espree validate parserOptions.globalReturn when sourceType is setting to module.(@aladdin-add) - */ - mergedParserOptions.ecmaFeatures = Object.assign({}, mergedParserOptions.ecmaFeatures, { globalReturn: false }); - } - - mergedParserOptions.ecmaVersion = normalizeEcmaVersion(parser, mergedParserOptions.ecmaVersion); - - return mergedParserOptions; -} - -/** - * Converts parserOptions to languageOptions for backwards compatibility with eslintrc. - * @param {ConfigData} config Config object. - * @param {Object} config.globals Global variable definitions. - * @param {Parser} config.parser The parser to use. - * @param {ParserOptions} config.parserOptions The parserOptions to use. - * @returns {LanguageOptions} The languageOptions equivalent. - */ -function createLanguageOptions({ globals: configuredGlobals, parser, parserOptions }) { - - const { - ecmaVersion, - sourceType - } = parserOptions; - - return { - globals: configuredGlobals, - ecmaVersion: normalizeEcmaVersionForLanguageOptions(ecmaVersion), - sourceType, - parser, - parserOptions - }; -} - -/** - * Combines the provided globals object with the globals from environments - * @param {Record} providedGlobals The 'globals' key in a config - * @param {Environment[]} enabledEnvironments The environments enabled in configuration and with inline comments - * @returns {Record} The resolved globals object - */ -function resolveGlobals(providedGlobals, enabledEnvironments) { - return Object.assign( - Object.create(null), - ...enabledEnvironments.filter(env => env.globals).map(env => env.globals), - providedGlobals - ); -} - -/** - * Store time measurements in map - * @param {number} time Time measurement - * @param {Object} timeOpts Options relating which time was measured - * @param {WeakMap} slots Linter internal slots map - * @returns {void} - */ -function storeTime(time, timeOpts, slots) { - const { type, key } = timeOpts; - - if (!slots.times) { - slots.times = { passes: [{}] }; - } - - const passIndex = slots.fixPasses; - - if (passIndex > slots.times.passes.length - 1) { - slots.times.passes.push({}); - } - - if (key) { - slots.times.passes[passIndex][type] ??= {}; - slots.times.passes[passIndex][type][key] ??= { total: 0 }; - slots.times.passes[passIndex][type][key].total += time; - } else { - slots.times.passes[passIndex][type] ??= { total: 0 }; - slots.times.passes[passIndex][type].total += time; - } -} - -/** - * Get the options for a rule (not including severity), if any - * @param {RuleConfig} ruleConfig rule configuration - * @returns {Array} of rule options, empty Array if none - */ -function getRuleOptions(ruleConfig) { - if (Array.isArray(ruleConfig)) { - return ruleConfig.slice(1); - } - return []; - -} - -/** - * Analyze scope of the given AST. - * @param {ASTNode} ast The `Program` node to analyze. - * @param {LanguageOptions} languageOptions The parser options. - * @param {Record} visitorKeys The visitor keys. - * @returns {ScopeManager} The analysis result. - */ -function analyzeScope(ast, languageOptions, visitorKeys) { - const parserOptions = languageOptions.parserOptions; - const ecmaFeatures = parserOptions.ecmaFeatures || {}; - const ecmaVersion = languageOptions.ecmaVersion || DEFAULT_ECMA_VERSION; - - return eslintScope.analyze(ast, { - ignoreEval: true, - nodejsScope: ecmaFeatures.globalReturn, - impliedStrict: ecmaFeatures.impliedStrict, - ecmaVersion: typeof ecmaVersion === "number" ? ecmaVersion : 6, - sourceType: languageOptions.sourceType || "script", - childVisitorKeys: visitorKeys || evk.KEYS, - fallback: Traverser.getKeys - }); -} - -/** - * Parses file into an AST. Moved out here because the try-catch prevents - * optimization of functions, so it's best to keep the try-catch as isolated - * as possible - * @param {VFile} file The file to parse. - * @param {Language} language The language to use. - * @param {LanguageOptions} languageOptions Options to pass to the parser - * @returns {{success: false, error: LintMessage}|{success: true, sourceCode: SourceCode}} - * An object containing the AST and parser services if parsing was successful, or the error if parsing failed - * @private - */ -function parse(file, language, languageOptions) { - - const result = language.parse(file, { languageOptions }); - - if (result.ok) { - return { - success: true, - sourceCode: language.createSourceCode(file, result, { languageOptions }) - }; - } - - // if we made it to here there was an error - return { - success: false, - errors: result.errors.map(error => ({ - ruleId: null, - nodeType: null, - fatal: true, - severity: 2, - message: `Parsing error: ${error.message}`, - line: error.line, - column: error.column - })) - }; -} - -/** - * Runs a rule, and gets its listeners - * @param {Rule} rule A rule object - * @param {Context} ruleContext The context that should be passed to the rule - * @throws {TypeError} If `rule` is not an object with a `create` method - * @throws {any} Any error during the rule's `create` - * @returns {Object} A map of selector listeners provided by the rule - */ -function createRuleListeners(rule, ruleContext) { - - if (!rule || typeof rule !== "object" || typeof rule.create !== "function") { - throw new TypeError(`Error while loading rule '${ruleContext.id}': Rule must be an object with a \`create\` method`); - } - - try { - return rule.create(ruleContext); - } catch (ex) { - ex.message = `Error while loading rule '${ruleContext.id}': ${ex.message}`; - throw ex; - } -} - -/** - * Runs the given rules on the given SourceCode object - * @param {SourceCode} sourceCode A SourceCode object for the given text - * @param {Object} configuredRules The rules configuration - * @param {function(string): Rule} ruleMapper A mapper function from rule names to rules - * @param {string | undefined} parserName The name of the parser in the config - * @param {Language} language The language object used for parsing. - * @param {LanguageOptions} languageOptions The options for parsing the code. - * @param {Object} settings The settings that were enabled in the config - * @param {string} filename The reported filename of the code - * @param {boolean} disableFixes If true, it doesn't make `fix` properties. - * @param {string | undefined} cwd cwd of the cli - * @param {string} physicalFilename The full path of the file on disk without any code block information - * @param {Function} ruleFilter A predicate function to filter which rules should be executed. - * @param {boolean} stats If true, stats are collected appended to the result - * @param {WeakMap} slots InternalSlotsMap of linter - * @returns {LintMessage[]} An array of reported problems - * @throws {Error} If traversal into a node fails. - */ -function runRules( - sourceCode, configuredRules, ruleMapper, parserName, language, languageOptions, - settings, filename, disableFixes, cwd, physicalFilename, ruleFilter, - stats, slots -) { - const emitter = createEmitter(); - - // must happen first to assign all node.parent properties - const eventQueue = sourceCode.traverse(); - - /* - * Create a frozen object with the ruleContext properties and methods that are shared by all rules. - * All rule contexts will inherit from this object. This avoids the performance penalty of copying all the - * properties once for each rule. - */ - const sharedTraversalContext = Object.freeze( - { - getCwd: () => cwd, - cwd, - getFilename: () => filename, - filename, - getPhysicalFilename: () => physicalFilename || filename, - physicalFilename: physicalFilename || filename, - getSourceCode: () => sourceCode, - sourceCode, - parserOptions: { - ...languageOptions.parserOptions - }, - parserPath: parserName, - languageOptions, - settings - } - ); - - const lintingProblems = []; - - Object.keys(configuredRules).forEach(ruleId => { - const severity = ConfigOps.getRuleSeverity(configuredRules[ruleId]); - - // not load disabled rules - if (severity === 0) { - return; - } - - if (ruleFilter && !ruleFilter({ ruleId, severity })) { - return; - } - - const rule = ruleMapper(ruleId); - - if (!rule) { - lintingProblems.push(createLintingProblem({ ruleId, language })); - return; - } - - const messageIds = rule.meta && rule.meta.messages; - let reportTranslator = null; - const ruleContext = Object.freeze( - Object.assign( - Object.create(sharedTraversalContext), - { - id: ruleId, - options: getRuleOptions(configuredRules[ruleId]), - report(...args) { - - /* - * Create a report translator lazily. - * In a vast majority of cases, any given rule reports zero errors on a given - * piece of code. Creating a translator lazily avoids the performance cost of - * creating a new translator function for each rule that usually doesn't get - * called. - * - * Using lazy report translators improves end-to-end performance by about 3% - * with Node 8.4.0. - */ - if (reportTranslator === null) { - reportTranslator = createReportTranslator({ - ruleId, - severity, - sourceCode, - messageIds, - disableFixes, - language - }); - } - const problem = reportTranslator(...args); - - if (problem.fix && !(rule.meta && rule.meta.fixable)) { - throw new Error("Fixable rules must set the `meta.fixable` property to \"code\" or \"whitespace\"."); - } - if (problem.suggestions && !(rule.meta && rule.meta.hasSuggestions === true)) { - if (rule.meta && rule.meta.docs && typeof rule.meta.docs.suggestion !== "undefined") { - - // Encourage migration from the former property name. - throw new Error("Rules with suggestions must set the `meta.hasSuggestions` property to `true`. `meta.docs.suggestion` is ignored by ESLint."); - } - throw new Error("Rules with suggestions must set the `meta.hasSuggestions` property to `true`."); - } - lintingProblems.push(problem); - } - } - ) - ); - - const ruleListenersReturn = (timing.enabled || stats) - ? timing.time(ruleId, createRuleListeners, stats)(rule, ruleContext) : createRuleListeners(rule, ruleContext); - - const ruleListeners = stats ? ruleListenersReturn.result : ruleListenersReturn; - - if (stats) { - storeTime(ruleListenersReturn.tdiff, { type: "rules", key: ruleId }, slots); - } - - /** - * Include `ruleId` in error logs - * @param {Function} ruleListener A rule method that listens for a node. - * @returns {Function} ruleListener wrapped in error handler - */ - function addRuleErrorHandler(ruleListener) { - return function ruleErrorHandler(...listenerArgs) { - try { - const ruleListenerReturn = ruleListener(...listenerArgs); - - const ruleListenerResult = stats ? ruleListenerReturn.result : ruleListenerReturn; - - if (stats) { - storeTime(ruleListenerReturn.tdiff, { type: "rules", key: ruleId }, slots); - } - - return ruleListenerResult; - } catch (e) { - e.ruleId = ruleId; - throw e; - } - }; - } - - if (typeof ruleListeners === "undefined" || ruleListeners === null) { - throw new Error(`The create() function for rule '${ruleId}' did not return an object.`); - } - - // add all the selectors from the rule as listeners - Object.keys(ruleListeners).forEach(selector => { - const ruleListener = (timing.enabled || stats) - ? timing.time(ruleId, ruleListeners[selector], stats) : ruleListeners[selector]; - - emitter.on( - selector, - addRuleErrorHandler(ruleListener) - ); - }); - }); - - const eventGenerator = new NodeEventGenerator(emitter, { - visitorKeys: sourceCode.visitorKeys ?? language.visitorKeys, - fallback: Traverser.getKeys, - matchClass: language.matchesSelectorClass ?? (() => false), - nodeTypeKey: language.nodeTypeKey - }); - - for (const step of eventQueue) { - switch (step.kind) { - case STEP_KIND_VISIT: { - try { - if (step.phase === 1) { - eventGenerator.enterNode(step.target); - } else { - eventGenerator.leaveNode(step.target); - } - } catch (err) { - err.currentNode = step.target; - throw err; - } - break; - } - - case STEP_KIND_CALL: { - emitter.emit(step.target, ...step.args); - break; - } - - default: - throw new Error(`Invalid traversal step found: "${step.type}".`); - } - - } - - return lintingProblems; -} - -/** - * Ensure the source code to be a string. - * @param {string|SourceCode} textOrSourceCode The text or source code object. - * @returns {string} The source code text. - */ -function ensureText(textOrSourceCode) { - if (typeof textOrSourceCode === "object") { - const { hasBOM, text } = textOrSourceCode; - const bom = hasBOM ? "\uFEFF" : ""; - - return bom + text; - } - - return String(textOrSourceCode); -} - -/** - * Get an environment. - * @param {LinterInternalSlots} slots The internal slots of Linter. - * @param {string} envId The environment ID to get. - * @returns {Environment|null} The environment. - */ -function getEnv(slots, envId) { - return ( - (slots.lastConfigArray && slots.lastConfigArray.pluginEnvironments.get(envId)) || - BuiltInEnvironments.get(envId) || - null - ); -} - -/** - * Get a rule. - * @param {LinterInternalSlots} slots The internal slots of Linter. - * @param {string} ruleId The rule ID to get. - * @returns {Rule|null} The rule. - */ -function getRule(slots, ruleId) { - return ( - (slots.lastConfigArray && slots.lastConfigArray.pluginRules.get(ruleId)) || - slots.ruleMap.get(ruleId) - ); -} - -/** - * Normalize the value of the cwd - * @param {string | undefined} cwd raw value of the cwd, path to a directory that should be considered as the current working directory, can be undefined. - * @returns {string | undefined} normalized cwd - */ -function normalizeCwd(cwd) { - if (cwd) { - return cwd; - } - if (typeof process === "object") { - return process.cwd(); - } - - // It's more explicit to assign the undefined - // eslint-disable-next-line no-undefined -- Consistently returning a value - return undefined; -} - -/** - * The map to store private data. - * @type {WeakMap} - */ -const internalSlotsMap = new WeakMap(); - -/** - * Throws an error when the given linter is in flat config mode. - * @param {Linter} linter The linter to check. - * @returns {void} - * @throws {Error} If the linter is in flat config mode. - */ -function assertEslintrcConfig(linter) { - const { configType } = internalSlotsMap.get(linter); - - if (configType === "flat") { - throw new Error("This method cannot be used with flat config. Add your entries directly into the config array."); - } -} - -//------------------------------------------------------------------------------ -// Public Interface -//------------------------------------------------------------------------------ - -/** - * Object that is responsible for verifying JavaScript text - * @name Linter - */ -class Linter { - - /** - * Initialize the Linter. - * @param {Object} [config] the config object - * @param {string} [config.cwd] path to a directory that should be considered as the current working directory, can be undefined. - * @param {Array} [config.flags] the feature flags to enable. - * @param {"flat"|"eslintrc"} [config.configType="flat"] the type of config used. - */ - constructor({ cwd, configType = "flat", flags = [] } = {}) { - internalSlotsMap.set(this, { - cwd: normalizeCwd(cwd), - flags: flags.filter(flag => activeFlags.has(flag)), - lastConfigArray: null, - lastSourceCode: null, - lastSuppressedMessages: [], - configType, // TODO: Remove after flat config conversion - parserMap: new Map([["espree", espree]]), - ruleMap: new Rules() - }); - - this.version = pkg.version; - } - - /** - * Getter for package version. - * @static - * @returns {string} The version from package.json. - */ - static get version() { - return pkg.version; - } - - /** - * Indicates if the given feature flag is enabled for this instance. - * @param {string} flag The feature flag to check. - * @returns {boolean} `true` if the feature flag is enabled, `false` if not. - */ - hasFlag(flag) { - return internalSlotsMap.get(this).flags.includes(flag); - } - - /** - * Same as linter.verify, except without support for processors. - * @param {string|SourceCode} textOrSourceCode The text to parse or a SourceCode object. - * @param {ConfigData} providedConfig An ESLintConfig instance to configure everything. - * @param {VerifyOptions} [providedOptions] The optional filename of the file being checked. - * @throws {Error} If during rule execution. - * @returns {(LintMessage|SuppressedLintMessage)[]} The results as an array of messages or an empty array if no messages. - */ - _verifyWithoutProcessors(textOrSourceCode, providedConfig, providedOptions) { - const slots = internalSlotsMap.get(this); - const config = providedConfig || {}; - const options = normalizeVerifyOptions(providedOptions, config); - let text; - - // evaluate arguments - if (typeof textOrSourceCode === "string") { - slots.lastSourceCode = null; - text = textOrSourceCode; - } else { - slots.lastSourceCode = textOrSourceCode; - text = textOrSourceCode.text; - } - - // Resolve parser. - let parserName = DEFAULT_PARSER_NAME; - let parser = espree; - - if (typeof config.parser === "object" && config.parser !== null) { - parserName = config.parser.filePath; - parser = config.parser.definition; - } else if (typeof config.parser === "string") { - if (!slots.parserMap.has(config.parser)) { - return [{ - ruleId: null, - fatal: true, - severity: 2, - message: `Configured parser '${config.parser}' was not found.`, - line: 0, - column: 0, - nodeType: null - }]; - } - parserName = config.parser; - parser = slots.parserMap.get(config.parser); - } - - // search and apply "eslint-env *". - const envInFile = options.allowInlineConfig && !options.warnInlineConfig - ? findEslintEnv(text) - : {}; - const resolvedEnvConfig = Object.assign({ builtin: true }, config.env, envInFile); - const enabledEnvs = Object.keys(resolvedEnvConfig) - .filter(envName => resolvedEnvConfig[envName]) - .map(envName => getEnv(slots, envName)) - .filter(env => env); - - const parserOptions = resolveParserOptions(parser, config.parserOptions || {}, enabledEnvs); - const configuredGlobals = resolveGlobals(config.globals || {}, enabledEnvs); - const settings = config.settings || {}; - const languageOptions = createLanguageOptions({ - globals: config.globals, - parser, - parserOptions - }); - const file = new VFile(options.filename, text, { - physicalPath: providedOptions.physicalFilename - }); - - if (!slots.lastSourceCode) { - let t; - - if (options.stats) { - t = startTime(); - } - - const parseResult = parse( - file, - jslang, - languageOptions - ); - - if (options.stats) { - const time = endTime(t); - const timeOpts = { type: "parse" }; - - storeTime(time, timeOpts, slots); - } - - if (!parseResult.success) { - return parseResult.errors; - } - - slots.lastSourceCode = parseResult.sourceCode; - } else { - - /* - * If the given source code object as the first argument does not have scopeManager, analyze the scope. - * This is for backward compatibility (SourceCode is frozen so it cannot rebind). - */ - if (!slots.lastSourceCode.scopeManager) { - slots.lastSourceCode = new SourceCode({ - text: slots.lastSourceCode.text, - ast: slots.lastSourceCode.ast, - hasBOM: slots.lastSourceCode.hasBOM, - parserServices: slots.lastSourceCode.parserServices, - visitorKeys: slots.lastSourceCode.visitorKeys, - scopeManager: analyzeScope(slots.lastSourceCode.ast, languageOptions) - }); - } - } - - const sourceCode = slots.lastSourceCode; - const commentDirectives = options.allowInlineConfig - ? getDirectiveComments(sourceCode, ruleId => getRule(slots, ruleId), options.warnInlineConfig, config) - : { configuredRules: {}, enabledGlobals: {}, exportedVariables: {}, problems: [], disableDirectives: [] }; - - addDeclaredGlobals( - sourceCode.scopeManager.scopes[0], - configuredGlobals, - { exportedVariables: commentDirectives.exportedVariables, enabledGlobals: commentDirectives.enabledGlobals } - ); - - const configuredRules = Object.assign({}, config.rules, commentDirectives.configuredRules); - - let lintingProblems; - - try { - lintingProblems = runRules( - sourceCode, - configuredRules, - ruleId => getRule(slots, ruleId), - parserName, - jslang, - languageOptions, - settings, - options.filename, - options.disableFixes, - slots.cwd, - providedOptions.physicalFilename, - null, - options.stats, - slots - ); - } catch (err) { - err.message += `\nOccurred while linting ${options.filename}`; - debug("An error occurred while traversing"); - debug("Filename:", options.filename); - if (err.currentNode) { - const { line } = err.currentNode.loc.start; - - debug("Line:", line); - err.message += `:${line}`; - } - debug("Parser Options:", parserOptions); - debug("Parser Path:", parserName); - debug("Settings:", settings); - - if (err.ruleId) { - err.message += `\nRule: "${err.ruleId}"`; - } - - throw err; - } - - return applyDisableDirectives({ - language: jslang, - directives: commentDirectives.disableDirectives, - disableFixes: options.disableFixes, - problems: lintingProblems - .concat(commentDirectives.problems) - .sort((problemA, problemB) => problemA.line - problemB.line || problemA.column - problemB.column), - reportUnusedDisableDirectives: options.reportUnusedDisableDirectives - }); - } - - /** - * Verifies the text against the rules specified by the second argument. - * @param {string|SourceCode} textOrSourceCode The text to parse or a SourceCode object. - * @param {ConfigData|ConfigArray} config An ESLintConfig instance to configure everything. - * @param {(string|(VerifyOptions&ProcessorOptions))} [filenameOrOptions] The optional filename of the file being checked. - * If this is not set, the filename will default to '' in the rule context. If - * an object, then it has "filename", "allowInlineConfig", and some properties. - * @returns {LintMessage[]} The results as an array of messages or an empty array if no messages. - */ - verify(textOrSourceCode, config, filenameOrOptions) { - debug("Verify"); - - const { configType, cwd } = internalSlotsMap.get(this); - - const options = typeof filenameOrOptions === "string" - ? { filename: filenameOrOptions } - : filenameOrOptions || {}; - - const configToUse = config ?? {}; - - if (configType !== "eslintrc") { - - /* - * Because of how Webpack packages up the files, we can't - * compare directly to `FlatConfigArray` using `instanceof` - * because it's not the same `FlatConfigArray` as in the tests. - * So, we work around it by assuming an array is, in fact, a - * `FlatConfigArray` if it has a `getConfig()` method. - */ - let configArray = configToUse; - - if (!Array.isArray(configToUse) || typeof configToUse.getConfig !== "function") { - configArray = new FlatConfigArray(configToUse, { basePath: cwd }); - configArray.normalizeSync(); - } - - return this._distinguishSuppressedMessages(this._verifyWithFlatConfigArray(textOrSourceCode, configArray, options, true)); - } - - if (typeof configToUse.extractConfig === "function") { - return this._distinguishSuppressedMessages(this._verifyWithConfigArray(textOrSourceCode, configToUse, options)); - } - - /* - * If we get to here, it means `config` is just an object rather - * than a config array so we can go right into linting. - */ - - /* - * `Linter` doesn't support `overrides` property in configuration. - * So we cannot apply multiple processors. - */ - if (options.preprocess || options.postprocess) { - return this._distinguishSuppressedMessages(this._verifyWithProcessor(textOrSourceCode, configToUse, options)); - } - return this._distinguishSuppressedMessages(this._verifyWithoutProcessors(textOrSourceCode, configToUse, options)); - } - - /** - * Verify with a processor. - * @param {string|SourceCode} textOrSourceCode The source code. - * @param {FlatConfig} config The config array. - * @param {VerifyOptions&ProcessorOptions} options The options. - * @param {FlatConfigArray} [configForRecursive] The `ConfigArray` object to apply multiple processors recursively. - * @returns {(LintMessage|SuppressedLintMessage)[]} The found problems. - */ - _verifyWithFlatConfigArrayAndProcessor(textOrSourceCode, config, options, configForRecursive) { - const filename = options.filename || ""; - const filenameToExpose = normalizeFilename(filename); - const physicalFilename = options.physicalFilename || filenameToExpose; - const text = ensureText(textOrSourceCode); - const preprocess = options.preprocess || (rawText => [rawText]); - const postprocess = options.postprocess || (messagesList => messagesList.flat()); - const filterCodeBlock = - options.filterCodeBlock || - (blockFilename => blockFilename.endsWith(".js")); - const originalExtname = path.extname(filename); - - let blocks; - - try { - blocks = preprocess(text, filenameToExpose); - } catch (ex) { - - // If the message includes a leading line number, strip it: - const message = `Preprocessing error: ${ex.message.replace(/^line \d+:/iu, "").trim()}`; - - debug("%s\n%s", message, ex.stack); - - return [ - { - ruleId: null, - fatal: true, - severity: 2, - message, - line: ex.lineNumber, - column: ex.column, - nodeType: null - } - ]; - } - - const messageLists = blocks.map((block, i) => { - debug("A code block was found: %o", block.filename || "(unnamed)"); - - // Keep the legacy behavior. - if (typeof block === "string") { - return this._verifyWithFlatConfigArrayAndWithoutProcessors(block, config, options); - } - - const blockText = block.text; - const blockName = path.join(filename, `${i}_${block.filename}`); - - // Skip this block if filtered. - if (!filterCodeBlock(blockName, blockText)) { - debug("This code block was skipped."); - return []; - } - - // Resolve configuration again if the file content or extension was changed. - if (configForRecursive && (text !== blockText || path.extname(blockName) !== originalExtname)) { - debug("Resolving configuration again because the file content or extension was changed."); - return this._verifyWithFlatConfigArray( - blockText, - configForRecursive, - { ...options, filename: blockName, physicalFilename } - ); - } - - // Does lint. - return this._verifyWithFlatConfigArrayAndWithoutProcessors( - blockText, - config, - { ...options, filename: blockName, physicalFilename } - ); - }); - - return postprocess(messageLists, filenameToExpose); - } - - /** - * Same as linter.verify, except without support for processors. - * @param {string|SourceCode} textOrSourceCode The text to parse or a SourceCode object. - * @param {FlatConfig} providedConfig An ESLintConfig instance to configure everything. - * @param {VerifyOptions} [providedOptions] The optional filename of the file being checked. - * @throws {Error} If during rule execution. - * @returns {(LintMessage|SuppressedLintMessage)[]} The results as an array of messages or an empty array if no messages. - */ - _verifyWithFlatConfigArrayAndWithoutProcessors(textOrSourceCode, providedConfig, providedOptions) { - const slots = internalSlotsMap.get(this); - const config = providedConfig || {}; - const options = normalizeVerifyOptions(providedOptions, config); - let text; - - // evaluate arguments - if (typeof textOrSourceCode === "string") { - slots.lastSourceCode = null; - text = textOrSourceCode; - } else { - slots.lastSourceCode = textOrSourceCode; - text = textOrSourceCode.text; - } - - const languageOptions = config.languageOptions; - - languageOptions.ecmaVersion = normalizeEcmaVersionForLanguageOptions( - languageOptions.ecmaVersion - ); - - // double check that there is a parser to avoid mysterious error messages - if (!languageOptions.parser) { - throw new TypeError(`No parser specified for ${options.filename}`); - } - - // Espree expects this information to be passed in - if (isEspree(languageOptions.parser)) { - const parserOptions = languageOptions.parserOptions; - - if (languageOptions.sourceType) { - - parserOptions.sourceType = languageOptions.sourceType; - - if ( - parserOptions.sourceType === "module" && - parserOptions.ecmaFeatures && - parserOptions.ecmaFeatures.globalReturn - ) { - parserOptions.ecmaFeatures.globalReturn = false; - } - } - } - - const settings = config.settings || {}; - const file = new VFile(options.filename, text, { - physicalPath: providedOptions.physicalFilename - }); - - if (!slots.lastSourceCode) { - let t; - - if (options.stats) { - t = startTime(); - } - - const parseResult = parse( - file, - config.language, - languageOptions - ); - - if (options.stats) { - const time = endTime(t); - - storeTime(time, { type: "parse" }, slots); - } - - if (!parseResult.success) { - return parseResult.errors; - } - - slots.lastSourceCode = parseResult.sourceCode; - } else { - - /* - * If the given source code object as the first argument does not have scopeManager, analyze the scope. - * This is for backward compatibility (SourceCode is frozen so it cannot rebind). - * - * We check explicitly for `null` to ensure that this is a JS-flavored language. - * For non-JS languages we don't want to do this. - * - * TODO: Remove this check when we stop exporting the `SourceCode` object. - */ - if (slots.lastSourceCode.scopeManager === null) { - slots.lastSourceCode = new SourceCode({ - text: slots.lastSourceCode.text, - ast: slots.lastSourceCode.ast, - hasBOM: slots.lastSourceCode.hasBOM, - parserServices: slots.lastSourceCode.parserServices, - visitorKeys: slots.lastSourceCode.visitorKeys, - scopeManager: analyzeScope(slots.lastSourceCode.ast, languageOptions) - }); - } - } - - const sourceCode = slots.lastSourceCode; - - /* - * Make adjustments based on the language options. For JavaScript, - * this is primarily about adding variables into the global scope - * to account for ecmaVersion and configured globals. - */ - sourceCode.applyLanguageOptions?.(languageOptions); - - const mergedInlineConfig = { - rules: {} - }; - const inlineConfigProblems = []; - - /* - * Inline config can be either enabled or disabled. If disabled, it's possible - * to detect the inline config and emit a warning (though this is not required). - * So we first check to see if inline config is allowed at all, and if so, we - * need to check if it's a warning or not. - */ - if (options.allowInlineConfig) { - - // if inline config should warn then add the warnings - if (options.warnInlineConfig) { - if (sourceCode.getInlineConfigNodes) { - sourceCode.getInlineConfigNodes().forEach(node => { - inlineConfigProblems.push(createLintingProblem({ - ruleId: null, - message: `'${sourceCode.text.slice(node.range[0], node.range[1])}' has no effect because you have 'noInlineConfig' setting in ${options.warnInlineConfig}.`, - loc: node.loc, - severity: 1, - language: config.language - })); - - }); - } - } else { - const inlineConfigResult = sourceCode.applyInlineConfig?.(); - - if (inlineConfigResult) { - inlineConfigProblems.push( - ...inlineConfigResult.problems - .map(problem => createLintingProblem({ ...problem, language: config.language })) - .map(problem => { - problem.fatal = true; - return problem; - }) - ); - - // next we need to verify information about the specified rules - const ruleValidator = new RuleValidator(); - - for (const { config: inlineConfig, loc } of inlineConfigResult.configs) { - - Object.keys(inlineConfig.rules).forEach(ruleId => { - const rule = getRuleFromConfig(ruleId, config); - const ruleValue = inlineConfig.rules[ruleId]; - - if (!rule) { - inlineConfigProblems.push(createLintingProblem({ - ruleId, - loc, - language: config.language - })); - return; - } - - if (Object.hasOwn(mergedInlineConfig.rules, ruleId)) { - inlineConfigProblems.push(createLintingProblem({ - message: `Rule "${ruleId}" is already configured by another configuration comment in the preceding code. This configuration is ignored.`, - loc, - language: config.language - })); - return; - } - - try { - - let ruleOptions = Array.isArray(ruleValue) ? ruleValue : [ruleValue]; - - assertIsRuleSeverity(ruleId, ruleOptions[0]); - - /* - * If the rule was already configured, inline rule configuration that - * only has severity should retain options from the config and just override the severity. - * - * Example: - * - * { - * rules: { - * curly: ["error", "multi"] - * } - * } - * - * /* eslint curly: ["warn"] * / - * - * Results in: - * - * curly: ["warn", "multi"] - */ - - let shouldValidateOptions = true; - - if ( - - /* - * If inline config for the rule has only severity - */ - ruleOptions.length === 1 && - - /* - * And the rule was already configured - */ - config.rules && Object.hasOwn(config.rules, ruleId) - ) { - - /* - * Then use severity from the inline config and options from the provided config - */ - ruleOptions = [ - ruleOptions[0], // severity from the inline config - ...config.rules[ruleId].slice(1) // options from the provided config - ]; - - // if the rule was enabled, the options have already been validated - if (config.rules[ruleId][0] > 0) { - shouldValidateOptions = false; - } - } - - if (shouldValidateOptions) { - ruleValidator.validate({ - plugins: config.plugins, - rules: { - [ruleId]: ruleOptions - } - }); - } - - mergedInlineConfig.rules[ruleId] = ruleOptions; - } catch (err) { - - /* - * If the rule has invalid `meta.schema`, throw the error because - * this is not an invalid inline configuration but an invalid rule. - */ - if (err.code === "ESLINT_INVALID_RULE_OPTIONS_SCHEMA") { - throw err; - } - - let baseMessage = err.message.slice( - err.message.startsWith("Key \"rules\":") - ? err.message.indexOf(":", 12) + 1 - : err.message.indexOf(":") + 1 - ).trim(); - - if (err.messageTemplate) { - baseMessage += ` You passed "${ruleValue}".`; - } - - inlineConfigProblems.push(createLintingProblem({ - ruleId, - message: `Inline configuration for rule "${ruleId}" is invalid:\n\t${baseMessage}\n`, - loc, - language: config.language - })); - } - }); - } - } - } - } - - const commentDirectives = options.allowInlineConfig && !options.warnInlineConfig - ? getDirectiveCommentsForFlatConfig( - sourceCode, - ruleId => getRuleFromConfig(ruleId, config), - config.language - ) - : { problems: [], disableDirectives: [] }; - - const configuredRules = Object.assign({}, config.rules, mergedInlineConfig.rules); - - let lintingProblems; - - sourceCode.finalize?.(); - - try { - lintingProblems = runRules( - sourceCode, - configuredRules, - ruleId => getRuleFromConfig(ruleId, config), - void 0, - config.language, - languageOptions, - settings, - options.filename, - options.disableFixes, - slots.cwd, - providedOptions.physicalFilename, - options.ruleFilter, - options.stats, - slots - ); - } catch (err) { - err.message += `\nOccurred while linting ${options.filename}`; - debug("An error occurred while traversing"); - debug("Filename:", options.filename); - if (err.currentNode) { - const { line } = err.currentNode.loc.start; - - debug("Line:", line); - err.message += `:${line}`; - } - debug("Parser Options:", languageOptions.parserOptions); - - // debug("Parser Path:", parserName); - debug("Settings:", settings); - - if (err.ruleId) { - err.message += `\nRule: "${err.ruleId}"`; - } - - throw err; - } - - return applyDisableDirectives({ - language: config.language, - directives: commentDirectives.disableDirectives, - disableFixes: options.disableFixes, - problems: lintingProblems - .concat(commentDirectives.problems) - .concat(inlineConfigProblems) - .sort((problemA, problemB) => problemA.line - problemB.line || problemA.column - problemB.column), - reportUnusedDisableDirectives: options.reportUnusedDisableDirectives, - ruleFilter: options.ruleFilter, - configuredRules - }); - } - - /** - * Verify a given code with `ConfigArray`. - * @param {string|SourceCode} textOrSourceCode The source code. - * @param {ConfigArray} configArray The config array. - * @param {VerifyOptions&ProcessorOptions} options The options. - * @returns {(LintMessage|SuppressedLintMessage)[]} The found problems. - */ - _verifyWithConfigArray(textOrSourceCode, configArray, options) { - debug("With ConfigArray: %s", options.filename); - - // Store the config array in order to get plugin envs and rules later. - internalSlotsMap.get(this).lastConfigArray = configArray; - - // Extract the final config for this file. - const config = configArray.extractConfig(options.filename); - const processor = - config.processor && - configArray.pluginProcessors.get(config.processor); - - // Verify. - if (processor) { - debug("Apply the processor: %o", config.processor); - const { preprocess, postprocess, supportsAutofix } = processor; - const disableFixes = options.disableFixes || !supportsAutofix; - - return this._verifyWithProcessor( - textOrSourceCode, - config, - { ...options, disableFixes, postprocess, preprocess }, - configArray - ); - } - return this._verifyWithoutProcessors(textOrSourceCode, config, options); - } - - /** - * Verify a given code with a flat config. - * @param {string|SourceCode} textOrSourceCode The source code. - * @param {FlatConfigArray} configArray The config array. - * @param {VerifyOptions&ProcessorOptions} options The options. - * @param {boolean} [firstCall=false] Indicates if this is being called directly - * from verify(). (TODO: Remove once eslintrc is removed.) - * @returns {(LintMessage|SuppressedLintMessage)[]} The found problems. - */ - _verifyWithFlatConfigArray(textOrSourceCode, configArray, options, firstCall = false) { - debug("With flat config: %s", options.filename); - - // we need a filename to match configs against - const filename = options.filename || "__placeholder__.js"; - - // Store the config array in order to get plugin envs and rules later. - internalSlotsMap.get(this).lastConfigArray = configArray; - const config = configArray.getConfig(filename); - - if (!config) { - return [ - { - ruleId: null, - severity: 1, - message: `No matching configuration found for ${filename}.`, - line: 0, - column: 0, - nodeType: null - } - ]; - } - - // Verify. - if (config.processor) { - debug("Apply the processor: %o", config.processor); - const { preprocess, postprocess, supportsAutofix } = config.processor; - const disableFixes = options.disableFixes || !supportsAutofix; - - return this._verifyWithFlatConfigArrayAndProcessor( - textOrSourceCode, - config, - { ...options, filename, disableFixes, postprocess, preprocess }, - configArray - ); - } - - // check for options-based processing - if (firstCall && (options.preprocess || options.postprocess)) { - return this._verifyWithFlatConfigArrayAndProcessor(textOrSourceCode, config, options); - } - - return this._verifyWithFlatConfigArrayAndWithoutProcessors(textOrSourceCode, config, options); - } - - /** - * Verify with a processor. - * @param {string|SourceCode} textOrSourceCode The source code. - * @param {ConfigData|ExtractedConfig} config The config array. - * @param {VerifyOptions&ProcessorOptions} options The options. - * @param {ConfigArray} [configForRecursive] The `ConfigArray` object to apply multiple processors recursively. - * @returns {(LintMessage|SuppressedLintMessage)[]} The found problems. - */ - _verifyWithProcessor(textOrSourceCode, config, options, configForRecursive) { - const filename = options.filename || ""; - const filenameToExpose = normalizeFilename(filename); - const physicalFilename = options.physicalFilename || filenameToExpose; - const text = ensureText(textOrSourceCode); - const preprocess = options.preprocess || (rawText => [rawText]); - const postprocess = options.postprocess || (messagesList => messagesList.flat()); - const filterCodeBlock = - options.filterCodeBlock || - (blockFilename => blockFilename.endsWith(".js")); - const originalExtname = path.extname(filename); - - let blocks; - - try { - blocks = preprocess(text, filenameToExpose); - } catch (ex) { - - // If the message includes a leading line number, strip it: - const message = `Preprocessing error: ${ex.message.replace(/^line \d+:/iu, "").trim()}`; - - debug("%s\n%s", message, ex.stack); - - return [ - { - ruleId: null, - fatal: true, - severity: 2, - message, - line: ex.lineNumber, - column: ex.column, - nodeType: null - } - ]; - } - - const messageLists = blocks.map((block, i) => { - debug("A code block was found: %o", block.filename || "(unnamed)"); - - // Keep the legacy behavior. - if (typeof block === "string") { - return this._verifyWithoutProcessors(block, config, options); - } - - const blockText = block.text; - const blockName = path.join(filename, `${i}_${block.filename}`); - - // Skip this block if filtered. - if (!filterCodeBlock(blockName, blockText)) { - debug("This code block was skipped."); - return []; - } - - // Resolve configuration again if the file content or extension was changed. - if (configForRecursive && (text !== blockText || path.extname(blockName) !== originalExtname)) { - debug("Resolving configuration again because the file content or extension was changed."); - return this._verifyWithConfigArray( - blockText, - configForRecursive, - { ...options, filename: blockName, physicalFilename } - ); - } - - // Does lint. - return this._verifyWithoutProcessors( - blockText, - config, - { ...options, filename: blockName, physicalFilename } - ); - }); - - return postprocess(messageLists, filenameToExpose); - } - - /** - * Given a list of reported problems, distinguish problems between normal messages and suppressed messages. - * The normal messages will be returned and the suppressed messages will be stored as lastSuppressedMessages. - * @param {Array} problems A list of reported problems. - * @returns {LintMessage[]} A list of LintMessage. - */ - _distinguishSuppressedMessages(problems) { - const messages = []; - const suppressedMessages = []; - const slots = internalSlotsMap.get(this); - - for (const problem of problems) { - if (problem.suppressions) { - suppressedMessages.push(problem); - } else { - messages.push(problem); - } - } - - slots.lastSuppressedMessages = suppressedMessages; - - return messages; - } - - /** - * Gets the SourceCode object representing the parsed source. - * @returns {SourceCode} The SourceCode object. - */ - getSourceCode() { - return internalSlotsMap.get(this).lastSourceCode; - } - - /** - * Gets the times spent on (parsing, fixing, linting) a file. - * @returns {LintTimes} The times. - */ - getTimes() { - return internalSlotsMap.get(this).times ?? { passes: [] }; - } - - /** - * Gets the number of autofix passes that were made in the last run. - * @returns {number} The number of autofix passes. - */ - getFixPassCount() { - return internalSlotsMap.get(this).fixPasses ?? 0; - } - - /** - * Gets the list of SuppressedLintMessage produced in the last running. - * @returns {SuppressedLintMessage[]} The list of SuppressedLintMessage - */ - getSuppressedMessages() { - return internalSlotsMap.get(this).lastSuppressedMessages; - } - - /** - * Defines a new linting rule. - * @param {string} ruleId A unique rule identifier - * @param {Rule} rule A rule object - * @returns {void} - */ - defineRule(ruleId, rule) { - assertEslintrcConfig(this); - internalSlotsMap.get(this).ruleMap.define(ruleId, rule); - } - - /** - * Defines many new linting rules. - * @param {Record} rulesToDefine map from unique rule identifier to rule - * @returns {void} - */ - defineRules(rulesToDefine) { - assertEslintrcConfig(this); - Object.getOwnPropertyNames(rulesToDefine).forEach(ruleId => { - this.defineRule(ruleId, rulesToDefine[ruleId]); - }); - } - - /** - * Gets an object with all loaded rules. - * @returns {Map} All loaded rules - */ - getRules() { - assertEslintrcConfig(this); - const { lastConfigArray, ruleMap } = internalSlotsMap.get(this); - - return new Map(function *() { - yield* ruleMap; - - if (lastConfigArray) { - yield* lastConfigArray.pluginRules; - } - }()); - } - - /** - * Define a new parser module - * @param {string} parserId Name of the parser - * @param {Parser} parserModule The parser object - * @returns {void} - */ - defineParser(parserId, parserModule) { - assertEslintrcConfig(this); - internalSlotsMap.get(this).parserMap.set(parserId, parserModule); - } - - /** - * Performs multiple autofix passes over the text until as many fixes as possible - * have been applied. - * @param {string} text The source text to apply fixes to. - * @param {ConfigData|ConfigArray|FlatConfigArray} config The ESLint config object to use. - * @param {VerifyOptions&ProcessorOptions&FixOptions} options The ESLint options object to use. - * @returns {{fixed:boolean,messages:LintMessage[],output:string}} The result of the fix operation as returned from the - * SourceCodeFixer. - */ - verifyAndFix(text, config, options) { - let messages, - fixedResult, - fixed = false, - passNumber = 0, - currentText = text; - const debugTextDescription = options && options.filename || `${text.slice(0, 10)}...`; - const shouldFix = options && typeof options.fix !== "undefined" ? options.fix : true; - const stats = options?.stats; - - /** - * This loop continues until one of the following is true: - * - * 1. No more fixes have been applied. - * 2. Ten passes have been made. - * - * That means anytime a fix is successfully applied, there will be another pass. - * Essentially, guaranteeing a minimum of two passes. - */ - const slots = internalSlotsMap.get(this); - - // Remove lint times from the last run. - if (stats) { - delete slots.times; - slots.fixPasses = 0; - } - - do { - passNumber++; - let tTotal; - - if (stats) { - tTotal = startTime(); - } - - debug(`Linting code for ${debugTextDescription} (pass ${passNumber})`); - messages = this.verify(currentText, config, options); - - debug(`Generating fixed text for ${debugTextDescription} (pass ${passNumber})`); - let t; - - if (stats) { - t = startTime(); - } - - fixedResult = SourceCodeFixer.applyFixes(currentText, messages, shouldFix); - - if (stats) { - - if (fixedResult.fixed) { - const time = endTime(t); - - storeTime(time, { type: "fix" }, slots); - slots.fixPasses++; - } else { - storeTime(0, { type: "fix" }, slots); - } - } - - /* - * stop if there are any syntax errors. - * 'fixedResult.output' is a empty string. - */ - if (messages.length === 1 && messages[0].fatal) { - break; - } - - // keep track if any fixes were ever applied - important for return value - fixed = fixed || fixedResult.fixed; - - // update to use the fixed output instead of the original text - currentText = fixedResult.output; - - if (stats) { - tTotal = endTime(tTotal); - const passIndex = slots.times.passes.length - 1; - - slots.times.passes[passIndex].total = tTotal; - } - - } while ( - fixedResult.fixed && - passNumber < MAX_AUTOFIX_PASSES - ); - - /* - * If the last result had fixes, we need to lint again to be sure we have - * the most up-to-date information. - */ - if (fixedResult.fixed) { - let tTotal; - - if (stats) { - tTotal = startTime(); - } - - fixedResult.messages = this.verify(currentText, config, options); - - if (stats) { - storeTime(0, { type: "fix" }, slots); - slots.times.passes.at(-1).total = endTime(tTotal); - } - } - - // ensure the last result properly reflects if fixes were done - fixedResult.fixed = fixed; - fixedResult.output = currentText; - - return fixedResult; - } -} - -module.exports = { - Linter, - - /** - * Get the internal slots of a given Linter instance for tests. - * @param {Linter} instance The Linter instance to get. - * @returns {LinterInternalSlots} The internal slots. - */ - getLinterInternalSlots(instance) { - return internalSlotsMap.get(instance); - } -}; diff --git a/tools/eslint/node_modules/eslint/lib/linter/node-event-generator.js b/tools/eslint/node_modules/eslint/lib/linter/node-event-generator.js deleted file mode 100644 index 0eb2f8dc02bf1d..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/linter/node-event-generator.js +++ /dev/null @@ -1,352 +0,0 @@ -/** - * @fileoverview The event generator for AST nodes. - * @author Toru Nagashima - */ - -"use strict"; - -//------------------------------------------------------------------------------ -// Requirements -//------------------------------------------------------------------------------ - -const esquery = require("esquery"); - -//------------------------------------------------------------------------------ -// Typedefs -//------------------------------------------------------------------------------ - -/** - * An object describing an AST selector - * @typedef {Object} ASTSelector - * @property {string} rawSelector The string that was parsed into this selector - * @property {boolean} isExit `true` if this should be emitted when exiting the node rather than when entering - * @property {Object} parsedSelector An object (from esquery) describing the matching behavior of the selector - * @property {string[]|null} listenerTypes A list of node types that could possibly cause the selector to match, - * or `null` if all node types could cause a match - * @property {number} attributeCount The total number of classes, pseudo-classes, and attribute queries in this selector - * @property {number} identifierCount The total number of identifier queries in this selector - */ - -//------------------------------------------------------------------------------ -// Helpers -//------------------------------------------------------------------------------ - -/** - * Computes the union of one or more arrays - * @param {...any[]} arrays One or more arrays to union - * @returns {any[]} The union of the input arrays - */ -function union(...arrays) { - return [...new Set(arrays.flat())]; -} - -/** - * Computes the intersection of one or more arrays - * @param {...any[]} arrays One or more arrays to intersect - * @returns {any[]} The intersection of the input arrays - */ -function intersection(...arrays) { - if (arrays.length === 0) { - return []; - } - - let result = [...new Set(arrays[0])]; - - for (const array of arrays.slice(1)) { - result = result.filter(x => array.includes(x)); - } - return result; -} - -/** - * Gets the possible types of a selector - * @param {Object} parsedSelector An object (from esquery) describing the matching behavior of the selector - * @returns {string[]|null} The node types that could possibly trigger this selector, or `null` if all node types could trigger it - */ -function getPossibleTypes(parsedSelector) { - switch (parsedSelector.type) { - case "identifier": - return [parsedSelector.value]; - - case "matches": { - const typesForComponents = parsedSelector.selectors.map(getPossibleTypes); - - if (typesForComponents.every(Boolean)) { - return union(...typesForComponents); - } - return null; - } - - case "compound": { - const typesForComponents = parsedSelector.selectors.map(getPossibleTypes).filter(typesForComponent => typesForComponent); - - // If all of the components could match any type, then the compound could also match any type. - if (!typesForComponents.length) { - return null; - } - - /* - * If at least one of the components could only match a particular type, the compound could only match - * the intersection of those types. - */ - return intersection(...typesForComponents); - } - - case "child": - case "descendant": - case "sibling": - case "adjacent": - return getPossibleTypes(parsedSelector.right); - - case "class": - if (parsedSelector.name === "function") { - return ["FunctionDeclaration", "FunctionExpression", "ArrowFunctionExpression"]; - } - - return null; - - default: - return null; - - } -} - -/** - * Counts the number of class, pseudo-class, and attribute queries in this selector - * @param {Object} parsedSelector An object (from esquery) describing the selector's matching behavior - * @returns {number} The number of class, pseudo-class, and attribute queries in this selector - */ -function countClassAttributes(parsedSelector) { - switch (parsedSelector.type) { - case "child": - case "descendant": - case "sibling": - case "adjacent": - return countClassAttributes(parsedSelector.left) + countClassAttributes(parsedSelector.right); - - case "compound": - case "not": - case "matches": - return parsedSelector.selectors.reduce((sum, childSelector) => sum + countClassAttributes(childSelector), 0); - - case "attribute": - case "field": - case "nth-child": - case "nth-last-child": - return 1; - - default: - return 0; - } -} - -/** - * Counts the number of identifier queries in this selector - * @param {Object} parsedSelector An object (from esquery) describing the selector's matching behavior - * @returns {number} The number of identifier queries - */ -function countIdentifiers(parsedSelector) { - switch (parsedSelector.type) { - case "child": - case "descendant": - case "sibling": - case "adjacent": - return countIdentifiers(parsedSelector.left) + countIdentifiers(parsedSelector.right); - - case "compound": - case "not": - case "matches": - return parsedSelector.selectors.reduce((sum, childSelector) => sum + countIdentifiers(childSelector), 0); - - case "identifier": - return 1; - - default: - return 0; - } -} - -/** - * Compares the specificity of two selector objects, with CSS-like rules. - * @param {ASTSelector} selectorA An AST selector descriptor - * @param {ASTSelector} selectorB Another AST selector descriptor - * @returns {number} - * a value less than 0 if selectorA is less specific than selectorB - * a value greater than 0 if selectorA is more specific than selectorB - * a value less than 0 if selectorA and selectorB have the same specificity, and selectorA <= selectorB alphabetically - * a value greater than 0 if selectorA and selectorB have the same specificity, and selectorA > selectorB alphabetically - */ -function compareSpecificity(selectorA, selectorB) { - return selectorA.attributeCount - selectorB.attributeCount || - selectorA.identifierCount - selectorB.identifierCount || - (selectorA.rawSelector <= selectorB.rawSelector ? -1 : 1); -} - -/** - * Parses a raw selector string, and throws a useful error if parsing fails. - * @param {string} rawSelector A raw AST selector - * @returns {Object} An object (from esquery) describing the matching behavior of this selector - * @throws {Error} An error if the selector is invalid - */ -function tryParseSelector(rawSelector) { - try { - return esquery.parse(rawSelector.replace(/:exit$/u, "")); - } catch (err) { - if (err.location && err.location.start && typeof err.location.start.offset === "number") { - throw new SyntaxError(`Syntax error in selector "${rawSelector}" at position ${err.location.start.offset}: ${err.message}`); - } - throw err; - } -} - -const selectorCache = new Map(); - -/** - * Parses a raw selector string, and returns the parsed selector along with specificity and type information. - * @param {string} rawSelector A raw AST selector - * @returns {ASTSelector} A selector descriptor - */ -function parseSelector(rawSelector) { - if (selectorCache.has(rawSelector)) { - return selectorCache.get(rawSelector); - } - - const parsedSelector = tryParseSelector(rawSelector); - - const result = { - rawSelector, - isExit: rawSelector.endsWith(":exit"), - parsedSelector, - listenerTypes: getPossibleTypes(parsedSelector), - attributeCount: countClassAttributes(parsedSelector), - identifierCount: countIdentifiers(parsedSelector) - }; - - selectorCache.set(rawSelector, result); - return result; -} - -//------------------------------------------------------------------------------ -// Public Interface -//------------------------------------------------------------------------------ - -/** - * The event generator for AST nodes. - * This implements below interface. - * - * ```ts - * interface EventGenerator { - * emitter: SafeEmitter; - * enterNode(node: ASTNode): void; - * leaveNode(node: ASTNode): void; - * } - * ``` - */ -class NodeEventGenerator { - - /** - * @param {SafeEmitter} emitter - * An SafeEmitter which is the destination of events. This emitter must already - * have registered listeners for all of the events that it needs to listen for. - * (See lib/linter/safe-emitter.js for more details on `SafeEmitter`.) - * @param {ESQueryOptions} esqueryOptions `esquery` options for traversing custom nodes. - * @returns {NodeEventGenerator} new instance - */ - constructor(emitter, esqueryOptions) { - this.emitter = emitter; - this.esqueryOptions = esqueryOptions; - this.currentAncestry = []; - this.enterSelectorsByNodeType = new Map(); - this.exitSelectorsByNodeType = new Map(); - this.anyTypeEnterSelectors = []; - this.anyTypeExitSelectors = []; - - emitter.eventNames().forEach(rawSelector => { - const selector = parseSelector(rawSelector); - - if (selector.listenerTypes) { - const typeMap = selector.isExit ? this.exitSelectorsByNodeType : this.enterSelectorsByNodeType; - - selector.listenerTypes.forEach(nodeType => { - if (!typeMap.has(nodeType)) { - typeMap.set(nodeType, []); - } - typeMap.get(nodeType).push(selector); - }); - return; - } - const selectors = selector.isExit ? this.anyTypeExitSelectors : this.anyTypeEnterSelectors; - - selectors.push(selector); - }); - - this.anyTypeEnterSelectors.sort(compareSpecificity); - this.anyTypeExitSelectors.sort(compareSpecificity); - this.enterSelectorsByNodeType.forEach(selectorList => selectorList.sort(compareSpecificity)); - this.exitSelectorsByNodeType.forEach(selectorList => selectorList.sort(compareSpecificity)); - } - - /** - * Checks a selector against a node, and emits it if it matches - * @param {ASTNode} node The node to check - * @param {ASTSelector} selector An AST selector descriptor - * @returns {void} - */ - applySelector(node, selector) { - if (esquery.matches(node, selector.parsedSelector, this.currentAncestry, this.esqueryOptions)) { - this.emitter.emit(selector.rawSelector, node); - } - } - - /** - * Applies all appropriate selectors to a node, in specificity order - * @param {ASTNode} node The node to check - * @param {boolean} isExit `false` if the node is currently being entered, `true` if it's currently being exited - * @returns {void} - */ - applySelectors(node, isExit) { - const selectorsByNodeType = (isExit ? this.exitSelectorsByNodeType : this.enterSelectorsByNodeType).get(node.type) || []; - const anyTypeSelectors = isExit ? this.anyTypeExitSelectors : this.anyTypeEnterSelectors; - - /* - * selectorsByNodeType and anyTypeSelectors were already sorted by specificity in the constructor. - * Iterate through each of them, applying selectors in the right order. - */ - let selectorsByTypeIndex = 0; - let anyTypeSelectorsIndex = 0; - - while (selectorsByTypeIndex < selectorsByNodeType.length || anyTypeSelectorsIndex < anyTypeSelectors.length) { - if ( - selectorsByTypeIndex >= selectorsByNodeType.length || - anyTypeSelectorsIndex < anyTypeSelectors.length && - compareSpecificity(anyTypeSelectors[anyTypeSelectorsIndex], selectorsByNodeType[selectorsByTypeIndex]) < 0 - ) { - this.applySelector(node, anyTypeSelectors[anyTypeSelectorsIndex++]); - } else { - this.applySelector(node, selectorsByNodeType[selectorsByTypeIndex++]); - } - } - } - - /** - * Emits an event of entering AST node. - * @param {ASTNode} node A node which was entered. - * @returns {void} - */ - enterNode(node) { - this.applySelectors(node, false); - this.currentAncestry.unshift(node); - } - - /** - * Emits an event of leaving AST node. - * @param {ASTNode} node A node which was left. - * @returns {void} - */ - leaveNode(node) { - this.currentAncestry.shift(); - this.applySelectors(node, true); - } -} - -module.exports = NodeEventGenerator; diff --git a/tools/eslint/node_modules/eslint/lib/linter/report-translator.js b/tools/eslint/node_modules/eslint/lib/linter/report-translator.js deleted file mode 100644 index 88355ceb6bf7cd..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/linter/report-translator.js +++ /dev/null @@ -1,376 +0,0 @@ -/** - * @fileoverview A helper that translates context.report() calls from the rule API into generic problem objects - * @author Teddy Katz - */ - -"use strict"; - -//------------------------------------------------------------------------------ -// Requirements -//------------------------------------------------------------------------------ - -const assert = require("node:assert"); -const ruleFixer = require("./rule-fixer"); -const { interpolate } = require("./interpolate"); - -//------------------------------------------------------------------------------ -// Typedefs -//------------------------------------------------------------------------------ - -/** @typedef {import("../shared/types").LintMessage} LintMessage */ - -/** - * An error message description - * @typedef {Object} MessageDescriptor - * @property {ASTNode} [node] The reported node - * @property {Location} loc The location of the problem. - * @property {string} message The problem message. - * @property {Object} [data] Optional data to use to fill in placeholders in the - * message. - * @property {Function} [fix] The function to call that creates a fix command. - * @property {Array<{desc?: string, messageId?: string, fix: Function}>} suggest Suggestion descriptions and functions to create a the associated fixes. - */ - -//------------------------------------------------------------------------------ -// Module Definition -//------------------------------------------------------------------------------ - - -/** - * Translates a multi-argument context.report() call into a single object argument call - * @param {...*} args A list of arguments passed to `context.report` - * @returns {MessageDescriptor} A normalized object containing report information - */ -function normalizeMultiArgReportCall(...args) { - - // If there is one argument, it is considered to be a new-style call already. - if (args.length === 1) { - - // Shallow clone the object to avoid surprises if reusing the descriptor - return Object.assign({}, args[0]); - } - - // If the second argument is a string, the arguments are interpreted as [node, message, data, fix]. - if (typeof args[1] === "string") { - return { - node: args[0], - message: args[1], - data: args[2], - fix: args[3] - }; - } - - // Otherwise, the arguments are interpreted as [node, loc, message, data, fix]. - return { - node: args[0], - loc: args[1], - message: args[2], - data: args[3], - fix: args[4] - }; -} - -/** - * Asserts that either a loc or a node was provided, and the node is valid if it was provided. - * @param {MessageDescriptor} descriptor A descriptor to validate - * @returns {void} - * @throws AssertionError if neither a node nor a loc was provided, or if the node is not an object - */ -function assertValidNodeInfo(descriptor) { - if (descriptor.node) { - assert(typeof descriptor.node === "object", "Node must be an object"); - } else { - assert(descriptor.loc, "Node must be provided when reporting error if location is not provided"); - } -} - -/** - * Normalizes a MessageDescriptor to always have a `loc` with `start` and `end` properties - * @param {MessageDescriptor} descriptor A descriptor for the report from a rule. - * @returns {{start: Location, end: (Location|null)}} An updated location that infers the `start` and `end` properties - * from the `node` of the original descriptor, or infers the `start` from the `loc` of the original descriptor. - */ -function normalizeReportLoc(descriptor) { - if (descriptor.loc) { - if (descriptor.loc.start) { - return descriptor.loc; - } - return { start: descriptor.loc, end: null }; - } - return descriptor.node.loc; -} - -/** - * Clones the given fix object. - * @param {Fix|null} fix The fix to clone. - * @returns {Fix|null} Deep cloned fix object or `null` if `null` or `undefined` was passed in. - */ -function cloneFix(fix) { - if (!fix) { - return null; - } - - return { - range: [fix.range[0], fix.range[1]], - text: fix.text - }; -} - -/** - * Check that a fix has a valid range. - * @param {Fix|null} fix The fix to validate. - * @returns {void} - */ -function assertValidFix(fix) { - if (fix) { - assert(fix.range && typeof fix.range[0] === "number" && typeof fix.range[1] === "number", `Fix has invalid range: ${JSON.stringify(fix, null, 2)}`); - } -} - -/** - * Compares items in a fixes array by range. - * @param {Fix} a The first message. - * @param {Fix} b The second message. - * @returns {int} -1 if a comes before b, 1 if a comes after b, 0 if equal. - * @private - */ -function compareFixesByRange(a, b) { - return a.range[0] - b.range[0] || a.range[1] - b.range[1]; -} - -/** - * Merges the given fixes array into one. - * @param {Fix[]} fixes The fixes to merge. - * @param {SourceCode} sourceCode The source code object to get the text between fixes. - * @returns {{text: string, range: number[]}} The merged fixes - */ -function mergeFixes(fixes, sourceCode) { - for (const fix of fixes) { - assertValidFix(fix); - } - - if (fixes.length === 0) { - return null; - } - if (fixes.length === 1) { - return cloneFix(fixes[0]); - } - - fixes.sort(compareFixesByRange); - - const originalText = sourceCode.text; - const start = fixes[0].range[0]; - const end = fixes.at(-1).range[1]; - let text = ""; - let lastPos = Number.MIN_SAFE_INTEGER; - - for (const fix of fixes) { - assert(fix.range[0] >= lastPos, "Fix objects must not be overlapped in a report."); - - if (fix.range[0] >= 0) { - text += originalText.slice(Math.max(0, start, lastPos), fix.range[0]); - } - text += fix.text; - lastPos = fix.range[1]; - } - text += originalText.slice(Math.max(0, start, lastPos), end); - - return { range: [start, end], text }; -} - -/** - * Gets one fix object from the given descriptor. - * If the descriptor retrieves multiple fixes, this merges those to one. - * @param {MessageDescriptor} descriptor The report descriptor. - * @param {SourceCode} sourceCode The source code object to get text between fixes. - * @returns {({text: string, range: number[]}|null)} The fix for the descriptor - */ -function normalizeFixes(descriptor, sourceCode) { - if (typeof descriptor.fix !== "function") { - return null; - } - - // @type {null | Fix | Fix[] | IterableIterator} - const fix = descriptor.fix(ruleFixer); - - // Merge to one. - if (fix && Symbol.iterator in fix) { - return mergeFixes(Array.from(fix), sourceCode); - } - - assertValidFix(fix); - return cloneFix(fix); -} - -/** - * Gets an array of suggestion objects from the given descriptor. - * @param {MessageDescriptor} descriptor The report descriptor. - * @param {SourceCode} sourceCode The source code object to get text between fixes. - * @param {Object} messages Object of meta messages for the rule. - * @returns {Array} The suggestions for the descriptor - */ -function mapSuggestions(descriptor, sourceCode, messages) { - if (!descriptor.suggest || !Array.isArray(descriptor.suggest)) { - return []; - } - - return descriptor.suggest - .map(suggestInfo => { - const computedDesc = suggestInfo.desc || messages[suggestInfo.messageId]; - - return { - ...suggestInfo, - desc: interpolate(computedDesc, suggestInfo.data), - fix: normalizeFixes(suggestInfo, sourceCode) - }; - }) - - // Remove suggestions that didn't provide a fix - .filter(({ fix }) => fix); -} - -/** - * Creates information about the report from a descriptor - * @param {Object} options Information about the problem - * @param {string} options.ruleId Rule ID - * @param {(0|1|2)} options.severity Rule severity - * @param {(ASTNode|null)} options.node Node - * @param {string} options.message Error message - * @param {string} [options.messageId] The error message ID. - * @param {{start: SourceLocation, end: (SourceLocation|null)}} options.loc Start and end location - * @param {{text: string, range: (number[]|null)}} options.fix The fix object - * @param {Array<{text: string, range: (number[]|null)}>} options.suggestions The array of suggestions objects - * @param {Language} [options.language] The language to use to adjust line and column offsets. - * @returns {LintMessage} Information about the report - */ -function createProblem(options) { - const { language } = options; - - // calculate offsets based on the language in use - const columnOffset = language.columnStart === 1 ? 0 : 1; - const lineOffset = language.lineStart === 1 ? 0 : 1; - - const problem = { - ruleId: options.ruleId, - severity: options.severity, - message: options.message, - line: options.loc.start.line + lineOffset, - column: options.loc.start.column + columnOffset, - nodeType: options.node && options.node.type || null - }; - - /* - * If this isnโ€™t in the conditional, some of the tests fail - * because `messageId` is present in the problem object - */ - if (options.messageId) { - problem.messageId = options.messageId; - } - - if (options.loc.end) { - problem.endLine = options.loc.end.line + lineOffset; - problem.endColumn = options.loc.end.column + columnOffset; - } - - if (options.fix) { - problem.fix = options.fix; - } - - if (options.suggestions && options.suggestions.length > 0) { - problem.suggestions = options.suggestions; - } - - return problem; -} - -/** - * Validates that suggestions are properly defined. Throws if an error is detected. - * @param {Array<{ desc?: string, messageId?: string }>} suggest The incoming suggest data. - * @param {Object} messages Object of meta messages for the rule. - * @returns {void} - */ -function validateSuggestions(suggest, messages) { - if (suggest && Array.isArray(suggest)) { - suggest.forEach(suggestion => { - if (suggestion.messageId) { - const { messageId } = suggestion; - - if (!messages) { - throw new TypeError(`context.report() called with a suggest option with a messageId '${messageId}', but no messages were present in the rule metadata.`); - } - - if (!messages[messageId]) { - throw new TypeError(`context.report() called with a suggest option with a messageId '${messageId}' which is not present in the 'messages' config: ${JSON.stringify(messages, null, 2)}`); - } - - if (suggestion.desc) { - throw new TypeError("context.report() called with a suggest option that defines both a 'messageId' and an 'desc'. Please only pass one."); - } - } else if (!suggestion.desc) { - throw new TypeError("context.report() called with a suggest option that doesn't have either a `desc` or `messageId`"); - } - - if (typeof suggestion.fix !== "function") { - throw new TypeError(`context.report() called with a suggest option without a fix function. See: ${suggestion}`); - } - }); - } -} - -/** - * Returns a function that converts the arguments of a `context.report` call from a rule into a reported - * problem for the Node.js API. - * @param {{ruleId: string, severity: number, sourceCode: SourceCode, messageIds: Object, disableFixes: boolean, language:Language}} metadata Metadata for the reported problem - * @returns {function(...args): LintMessage} Function that returns information about the report - */ - -module.exports = function createReportTranslator(metadata) { - - /* - * `createReportTranslator` gets called once per enabled rule per file. It needs to be very performant. - * The report translator itself (i.e. the function that `createReportTranslator` returns) gets - * called every time a rule reports a problem, which happens much less frequently (usually, the vast - * majority of rules don't report any problems for a given file). - */ - return (...args) => { - const descriptor = normalizeMultiArgReportCall(...args); - const messages = metadata.messageIds; - - assertValidNodeInfo(descriptor); - - let computedMessage; - - if (descriptor.messageId) { - if (!messages) { - throw new TypeError("context.report() called with a messageId, but no messages were present in the rule metadata."); - } - const id = descriptor.messageId; - - if (descriptor.message) { - throw new TypeError("context.report() called with a message and a messageId. Please only pass one."); - } - if (!messages || !Object.hasOwn(messages, id)) { - throw new TypeError(`context.report() called with a messageId of '${id}' which is not present in the 'messages' config: ${JSON.stringify(messages, null, 2)}`); - } - computedMessage = messages[id]; - } else if (descriptor.message) { - computedMessage = descriptor.message; - } else { - throw new TypeError("Missing `message` property in report() call; add a message that describes the linting problem."); - } - - validateSuggestions(descriptor.suggest, messages); - - return createProblem({ - ruleId: metadata.ruleId, - severity: metadata.severity, - node: descriptor.node, - message: interpolate(computedMessage, descriptor.data), - messageId: descriptor.messageId, - loc: normalizeReportLoc(descriptor), - fix: metadata.disableFixes ? null : normalizeFixes(descriptor, metadata.sourceCode), - suggestions: metadata.disableFixes ? [] : mapSuggestions(descriptor, metadata.sourceCode, messages), - language: metadata.language - }); - }; -}; diff --git a/tools/eslint/node_modules/eslint/lib/linter/rule-fixer.js b/tools/eslint/node_modules/eslint/lib/linter/rule-fixer.js deleted file mode 100644 index bdd80d13b162d4..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/linter/rule-fixer.js +++ /dev/null @@ -1,140 +0,0 @@ -/** - * @fileoverview An object that creates fix commands for rules. - * @author Nicholas C. Zakas - */ -"use strict"; - -//------------------------------------------------------------------------------ -// Requirements -//------------------------------------------------------------------------------ - -// none! - -//------------------------------------------------------------------------------ -// Helpers -//------------------------------------------------------------------------------ - -/** - * Creates a fix command that inserts text at the specified index in the source text. - * @param {int} index The 0-based index at which to insert the new text. - * @param {string} text The text to insert. - * @returns {Object} The fix command. - * @private - */ -function insertTextAt(index, text) { - return { - range: [index, index], - text - }; -} - -//------------------------------------------------------------------------------ -// Public Interface -//------------------------------------------------------------------------------ - -/** - * Creates code fixing commands for rules. - */ - -const ruleFixer = Object.freeze({ - - /** - * Creates a fix command that inserts text after the given node or token. - * The fix is not applied until applyFixes() is called. - * @param {ASTNode|Token} nodeOrToken The node or token to insert after. - * @param {string} text The text to insert. - * @returns {Object} The fix command. - */ - insertTextAfter(nodeOrToken, text) { - return this.insertTextAfterRange(nodeOrToken.range, text); - }, - - /** - * Creates a fix command that inserts text after the specified range in the source text. - * The fix is not applied until applyFixes() is called. - * @param {int[]} range The range to replace, first item is start of range, second - * is end of range. - * @param {string} text The text to insert. - * @returns {Object} The fix command. - */ - insertTextAfterRange(range, text) { - return insertTextAt(range[1], text); - }, - - /** - * Creates a fix command that inserts text before the given node or token. - * The fix is not applied until applyFixes() is called. - * @param {ASTNode|Token} nodeOrToken The node or token to insert before. - * @param {string} text The text to insert. - * @returns {Object} The fix command. - */ - insertTextBefore(nodeOrToken, text) { - return this.insertTextBeforeRange(nodeOrToken.range, text); - }, - - /** - * Creates a fix command that inserts text before the specified range in the source text. - * The fix is not applied until applyFixes() is called. - * @param {int[]} range The range to replace, first item is start of range, second - * is end of range. - * @param {string} text The text to insert. - * @returns {Object} The fix command. - */ - insertTextBeforeRange(range, text) { - return insertTextAt(range[0], text); - }, - - /** - * Creates a fix command that replaces text at the node or token. - * The fix is not applied until applyFixes() is called. - * @param {ASTNode|Token} nodeOrToken The node or token to remove. - * @param {string} text The text to insert. - * @returns {Object} The fix command. - */ - replaceText(nodeOrToken, text) { - return this.replaceTextRange(nodeOrToken.range, text); - }, - - /** - * Creates a fix command that replaces text at the specified range in the source text. - * The fix is not applied until applyFixes() is called. - * @param {int[]} range The range to replace, first item is start of range, second - * is end of range. - * @param {string} text The text to insert. - * @returns {Object} The fix command. - */ - replaceTextRange(range, text) { - return { - range, - text - }; - }, - - /** - * Creates a fix command that removes the node or token from the source. - * The fix is not applied until applyFixes() is called. - * @param {ASTNode|Token} nodeOrToken The node or token to remove. - * @returns {Object} The fix command. - */ - remove(nodeOrToken) { - return this.removeRange(nodeOrToken.range); - }, - - /** - * Creates a fix command that removes the specified range of text from the source. - * The fix is not applied until applyFixes() is called. - * @param {int[]} range The range to remove, first item is start of range, second - * is end of range. - * @returns {Object} The fix command. - */ - removeRange(range) { - return { - range, - text: "" - }; - } - -}); - - -module.exports = ruleFixer; diff --git a/tools/eslint/node_modules/eslint/lib/linter/rules.js b/tools/eslint/node_modules/eslint/lib/linter/rules.js deleted file mode 100644 index bb8e36823bd188..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/linter/rules.js +++ /dev/null @@ -1,71 +0,0 @@ -/** - * @fileoverview Defines a storage for rules. - * @author Nicholas C. Zakas - * @author aladdin-add - */ - -"use strict"; - -//------------------------------------------------------------------------------ -// Requirements -//------------------------------------------------------------------------------ - -const builtInRules = require("../rules"); - -//------------------------------------------------------------------------------ -// Typedefs -//------------------------------------------------------------------------------ - -/** @typedef {import("../shared/types").Rule} Rule */ - -//------------------------------------------------------------------------------ -// Public Interface -//------------------------------------------------------------------------------ - -/** - * A storage for rules. - */ -class Rules { - constructor() { - this._rules = Object.create(null); - } - - /** - * Registers a rule module for rule id in storage. - * @param {string} ruleId Rule id (file name). - * @param {Rule} rule Rule object. - * @returns {void} - */ - define(ruleId, rule) { - this._rules[ruleId] = rule; - } - - /** - * Access rule handler by id (file name). - * @param {string} ruleId Rule id (file name). - * @returns {Rule} Rule object. - */ - get(ruleId) { - if (typeof this._rules[ruleId] === "string") { - this.define(ruleId, require(this._rules[ruleId])); - } - if (this._rules[ruleId]) { - return this._rules[ruleId]; - } - if (builtInRules.has(ruleId)) { - return builtInRules.get(ruleId); - } - - return null; - } - - *[Symbol.iterator]() { - yield* builtInRules; - - for (const ruleId of Object.keys(this._rules)) { - yield [ruleId, this.get(ruleId)]; - } - } -} - -module.exports = Rules; diff --git a/tools/eslint/node_modules/eslint/lib/linter/safe-emitter.js b/tools/eslint/node_modules/eslint/lib/linter/safe-emitter.js deleted file mode 100644 index f4837c1ddcf51d..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/linter/safe-emitter.js +++ /dev/null @@ -1,52 +0,0 @@ -/** - * @fileoverview A variant of EventEmitter which does not give listeners information about each other - * @author Teddy Katz - */ - -"use strict"; - -//------------------------------------------------------------------------------ -// Typedefs -//------------------------------------------------------------------------------ - -/** - * An event emitter - * @typedef {Object} SafeEmitter - * @property {(eventName: string, listenerFunc: Function) => void} on Adds a listener for a given event name - * @property {(eventName: string, arg1?: any, arg2?: any, arg3?: any) => void} emit Emits an event with a given name. - * This calls all the listeners that were listening for that name, with `arg1`, `arg2`, and `arg3` as arguments. - * @property {function(): string[]} eventNames Gets the list of event names that have registered listeners. - */ - -/** - * Creates an object which can listen for and emit events. - * This is similar to the EventEmitter API in Node's standard library, but it has a few differences. - * The goal is to allow multiple modules to attach arbitrary listeners to the same emitter, without - * letting the modules know about each other at all. - * 1. It has no special keys like `error` and `newListener`, which would allow modules to detect when - * another module throws an error or registers a listener. - * 2. It calls listener functions without any `this` value. (`EventEmitter` calls listeners with a - * `this` value of the emitter instance, which would give listeners access to other listeners.) - * @returns {SafeEmitter} An emitter - */ -module.exports = () => { - const listeners = Object.create(null); - - return Object.freeze({ - on(eventName, listener) { - if (eventName in listeners) { - listeners[eventName].push(listener); - } else { - listeners[eventName] = [listener]; - } - }, - emit(eventName, ...args) { - if (eventName in listeners) { - listeners[eventName].forEach(listener => listener(...args)); - } - }, - eventNames() { - return Object.keys(listeners); - } - }); -}; diff --git a/tools/eslint/node_modules/eslint/lib/linter/source-code-fixer.js b/tools/eslint/node_modules/eslint/lib/linter/source-code-fixer.js deleted file mode 100644 index 312e84f61cbc3f..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/linter/source-code-fixer.js +++ /dev/null @@ -1,152 +0,0 @@ -/** - * @fileoverview An object that caches and applies source code fixes. - * @author Nicholas C. Zakas - */ -"use strict"; - -//------------------------------------------------------------------------------ -// Requirements -//------------------------------------------------------------------------------ - -const debug = require("debug")("eslint:source-code-fixer"); - -//------------------------------------------------------------------------------ -// Helpers -//------------------------------------------------------------------------------ - -const BOM = "\uFEFF"; - -/** - * Compares items in a messages array by range. - * @param {Message} a The first message. - * @param {Message} b The second message. - * @returns {int} -1 if a comes before b, 1 if a comes after b, 0 if equal. - * @private - */ -function compareMessagesByFixRange(a, b) { - return a.fix.range[0] - b.fix.range[0] || a.fix.range[1] - b.fix.range[1]; -} - -/** - * Compares items in a messages array by line and column. - * @param {Message} a The first message. - * @param {Message} b The second message. - * @returns {int} -1 if a comes before b, 1 if a comes after b, 0 if equal. - * @private - */ -function compareMessagesByLocation(a, b) { - return a.line - b.line || a.column - b.column; -} - -//------------------------------------------------------------------------------ -// Public Interface -//------------------------------------------------------------------------------ - -/** - * Utility for apply fixes to source code. - * @constructor - */ -function SourceCodeFixer() { - Object.freeze(this); -} - -/** - * Applies the fixes specified by the messages to the given text. Tries to be - * smart about the fixes and won't apply fixes over the same area in the text. - * @param {string} sourceText The text to apply the changes to. - * @param {Message[]} messages The array of messages reported by ESLint. - * @param {boolean|Function} [shouldFix=true] Determines whether each message should be fixed - * @returns {Object} An object containing the fixed text and any unfixed messages. - */ -SourceCodeFixer.applyFixes = function(sourceText, messages, shouldFix) { - debug("Applying fixes"); - - if (shouldFix === false) { - debug("shouldFix parameter was false, not attempting fixes"); - return { - fixed: false, - messages, - output: sourceText - }; - } - - // clone the array - const remainingMessages = [], - fixes = [], - bom = sourceText.startsWith(BOM) ? BOM : "", - text = bom ? sourceText.slice(1) : sourceText; - let lastPos = Number.NEGATIVE_INFINITY, - output = bom; - - /** - * Try to use the 'fix' from a problem. - * @param {Message} problem The message object to apply fixes from - * @returns {boolean} Whether fix was successfully applied - */ - function attemptFix(problem) { - const fix = problem.fix; - const start = fix.range[0]; - const end = fix.range[1]; - - // Remain it as a problem if it's overlapped or it's a negative range - if (lastPos >= start || start > end) { - remainingMessages.push(problem); - return false; - } - - // Remove BOM. - if ((start < 0 && end >= 0) || (start === 0 && fix.text.startsWith(BOM))) { - output = ""; - } - - // Make output to this fix. - output += text.slice(Math.max(0, lastPos), Math.max(0, start)); - output += fix.text; - lastPos = end; - return true; - } - - messages.forEach(problem => { - if (Object.hasOwn(problem, "fix")) { - fixes.push(problem); - } else { - remainingMessages.push(problem); - } - }); - - if (fixes.length) { - debug("Found fixes to apply"); - let fixesWereApplied = false; - - for (const problem of fixes.sort(compareMessagesByFixRange)) { - if (typeof shouldFix !== "function" || shouldFix(problem)) { - attemptFix(problem); - - /* - * The only time attemptFix will fail is if a previous fix was - * applied which conflicts with it. So we can mark this as true. - */ - fixesWereApplied = true; - } else { - remainingMessages.push(problem); - } - } - output += text.slice(Math.max(0, lastPos)); - - return { - fixed: fixesWereApplied, - messages: remainingMessages.sort(compareMessagesByLocation), - output - }; - } - - debug("No fixes to apply"); - return { - fixed: false, - messages, - output: bom + text - }; - -}; - -module.exports = SourceCodeFixer; diff --git a/tools/eslint/node_modules/eslint/lib/linter/timing.js b/tools/eslint/node_modules/eslint/lib/linter/timing.js deleted file mode 100644 index 232c5f4f2fb479..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/linter/timing.js +++ /dev/null @@ -1,169 +0,0 @@ -/** - * @fileoverview Tracks performance of individual rules. - * @author Brandon Mills - */ - -"use strict"; - -const { startTime, endTime } = require("../shared/stats"); - -//------------------------------------------------------------------------------ -// Helpers -//------------------------------------------------------------------------------ - -/* c8 ignore next */ -/** - * Align the string to left - * @param {string} str string to evaluate - * @param {int} len length of the string - * @param {string} ch delimiter character - * @returns {string} modified string - * @private - */ -function alignLeft(str, len, ch) { - return str + new Array(len - str.length + 1).join(ch || " "); -} - -/* c8 ignore next */ -/** - * Align the string to right - * @param {string} str string to evaluate - * @param {int} len length of the string - * @param {string} ch delimiter character - * @returns {string} modified string - * @private - */ -function alignRight(str, len, ch) { - return new Array(len - str.length + 1).join(ch || " ") + str; -} - -//------------------------------------------------------------------------------ -// Module definition -//------------------------------------------------------------------------------ - -const enabled = !!process.env.TIMING; - -const HEADERS = ["Rule", "Time (ms)", "Relative"]; -const ALIGN = [alignLeft, alignRight, alignRight]; - -/** - * Decide how many rules to show in the output list. - * @returns {number} the number of rules to show - */ -function getListSize() { - const MINIMUM_SIZE = 10; - - if (typeof process.env.TIMING !== "string") { - return MINIMUM_SIZE; - } - - if (process.env.TIMING.toLowerCase() === "all") { - return Number.POSITIVE_INFINITY; - } - - const TIMING_ENV_VAR_AS_INTEGER = Number.parseInt(process.env.TIMING, 10); - - return TIMING_ENV_VAR_AS_INTEGER > 10 ? TIMING_ENV_VAR_AS_INTEGER : MINIMUM_SIZE; -} - -/* c8 ignore next */ -/** - * display the data - * @param {Object} data Data object to be displayed - * @returns {void} prints modified string with console.log - * @private - */ -function display(data) { - let total = 0; - const rows = Object.keys(data) - .map(key => { - const time = data[key]; - - total += time; - return [key, time]; - }) - .sort((a, b) => b[1] - a[1]) - .slice(0, getListSize()); - - rows.forEach(row => { - row.push(`${(row[1] * 100 / total).toFixed(1)}%`); - row[1] = row[1].toFixed(3); - }); - - rows.unshift(HEADERS); - - const widths = []; - - rows.forEach(row => { - const len = row.length; - - for (let i = 0; i < len; i++) { - const n = row[i].length; - - if (!widths[i] || n > widths[i]) { - widths[i] = n; - } - } - }); - - const table = rows.map(row => ( - row - .map((cell, index) => ALIGN[index](cell, widths[index])) - .join(" | ") - )); - - table.splice(1, 0, widths.map((width, index) => { - const extraAlignment = index !== 0 && index !== widths.length - 1 ? 2 : 1; - - return ALIGN[index](":", width + extraAlignment, "-"); - }).join("|")); - - console.log(table.join("\n")); // eslint-disable-line no-console -- Debugging function -} - -/* c8 ignore next */ -module.exports = (function() { - - const data = Object.create(null); - - /** - * Time the run - * @param {any} key key from the data object - * @param {Function} fn function to be called - * @param {boolean} stats if 'stats' is true, return the result and the time difference - * @returns {Function} function to be executed - * @private - */ - function time(key, fn, stats) { - - return function(...args) { - - const t = startTime(); - const result = fn(...args); - const tdiff = endTime(t); - - if (enabled) { - if (typeof data[key] === "undefined") { - data[key] = 0; - } - - data[key] += tdiff; - } - - return stats ? { result, tdiff } : result; - }; - } - - if (enabled) { - process.on("exit", () => { - display(data); - }); - } - - return { - time, - enabled, - getListSize - }; - -}()); diff --git a/tools/eslint/node_modules/eslint/lib/linter/vfile.js b/tools/eslint/node_modules/eslint/lib/linter/vfile.js deleted file mode 100644 index 8528a5197b052f..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/linter/vfile.js +++ /dev/null @@ -1,111 +0,0 @@ -/** - * @fileoverview Virtual file - * @author Nicholas C. Zakas - */ - -"use strict"; - -//----------------------------------------------------------------------------- -// Type Definitions -//----------------------------------------------------------------------------- - -/** @typedef {import("@eslint/core").File} File */ - -//------------------------------------------------------------------------------ -// Helpers -//------------------------------------------------------------------------------ - -/** - * Determines if a given value has a byte order mark (BOM). - * @param {string|Uint8Array} value The value to check. - * @returns {boolean} `true` if the value has a BOM, `false` otherwise. - */ -function hasUnicodeBOM(value) { - return typeof value === "string" - ? value.charCodeAt(0) === 0xFEFF - : value[0] === 0xEF && value[1] === 0xBB && value[2] === 0xBF; -} - -/** - * Strips Unicode BOM from the given value. - * @param {string|Uint8Array} value The value to remove the BOM from. - * @returns {string|Uint8Array} The stripped value. - */ -function stripUnicodeBOM(value) { - - if (!hasUnicodeBOM(value)) { - return value; - } - - if (typeof value === "string") { - - /* - * Check Unicode BOM. - * In JavaScript, string data is stored as UTF-16, so BOM is 0xFEFF. - * http://www.ecma-international.org/ecma-262/6.0/#sec-unicode-format-control-characters - */ - return value.slice(1); - } - - /* - * In a Uint8Array, the BOM is represented by three bytes: 0xEF, 0xBB, and 0xBF, - * so we can just remove the first three bytes. - */ - return value.slice(3); -} - -//------------------------------------------------------------------------------ -// Exports -//------------------------------------------------------------------------------ - -/** - * Represents a virtual file inside of ESLint. - * @implements {File} - */ -class VFile { - - /** - * The file path including any processor-created virtual path. - * @type {string} - * @readonly - */ - path; - - /** - * The file path on disk. - * @type {string} - * @readonly - */ - physicalPath; - - /** - * The file contents. - * @type {string|Uint8Array} - * @readonly - */ - body; - - /** - * Indicates whether the file has a byte order mark (BOM). - * @type {boolean} - * @readonly - */ - bom; - - /** - * Creates a new instance. - * @param {string} path The file path. - * @param {string|Uint8Array} body The file contents. - * @param {Object} [options] Additional options. - * @param {string} [options.physicalPath] The file path on disk. - */ - constructor(path, body, { physicalPath } = {}) { - this.path = path; - this.physicalPath = physicalPath ?? path; - this.bom = hasUnicodeBOM(body); - this.body = stripUnicodeBOM(body); - } - -} - -module.exports = { VFile }; diff --git a/tools/eslint/node_modules/eslint/lib/options.js b/tools/eslint/node_modules/eslint/lib/options.js deleted file mode 100644 index d35c9f6d906718..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/options.js +++ /dev/null @@ -1,442 +0,0 @@ -/** - * @fileoverview Options configuration for optionator. - * @author George Zahariev - */ - -"use strict"; - -//------------------------------------------------------------------------------ -// Requirements -//------------------------------------------------------------------------------ - -const optionator = require("optionator"); - -//------------------------------------------------------------------------------ -// Typedefs -//------------------------------------------------------------------------------ - -/** - * The options object parsed by Optionator. - * @typedef {Object} ParsedCLIOptions - * @property {boolean} cache Only check changed files - * @property {string} cacheFile Path to the cache file. Deprecated: use --cache-location - * @property {string} [cacheLocation] Path to the cache file or directory - * @property {"metadata" | "content"} cacheStrategy Strategy to use for detecting changed files in the cache - * @property {boolean} [color] Force enabling/disabling of color - * @property {string} [config] Use this configuration, overriding .eslintrc.* config options if present - * @property {boolean} debug Output debugging information - * @property {string[]} [env] Specify environments - * @property {boolean} envInfo Output execution environment information - * @property {boolean} errorOnUnmatchedPattern Prevent errors when pattern is unmatched - * @property {boolean} eslintrc Disable use of configuration from .eslintrc.* - * @property {string[]} [ext] Specify JavaScript file extensions - * @property {string[]} [flag] Feature flags - * @property {boolean} fix Automatically fix problems - * @property {boolean} fixDryRun Automatically fix problems without saving the changes to the file system - * @property {("directive" | "problem" | "suggestion" | "layout")[]} [fixType] Specify the types of fixes to apply (directive, problem, suggestion, layout) - * @property {string} format Use a specific output format - * @property {string[]} [global] Define global variables - * @property {boolean} [help] Show help - * @property {boolean} ignore Disable use of ignore files and patterns - * @property {string} [ignorePath] Specify path of ignore file - * @property {string[]} [ignorePattern] Patterns of files to ignore. In eslintrc mode, these are in addition to `.eslintignore` - * @property {boolean} init Run config initialization wizard - * @property {boolean} inlineConfig Prevent comments from changing config or rules - * @property {number} maxWarnings Number of warnings to trigger nonzero exit code - * @property {string} [outputFile] Specify file to write report to - * @property {string} [parser] Specify the parser to be used - * @property {Object} [parserOptions] Specify parser options - * @property {string[]} [plugin] Specify plugins - * @property {string} [printConfig] Print the configuration for the given file - * @property {boolean | undefined} reportUnusedDisableDirectives Adds reported errors for unused eslint-disable and eslint-enable directives - * @property {string | undefined} reportUnusedDisableDirectivesSeverity A severity string indicating if and how unused disable and enable directives should be tracked and reported. - * @property {string} [resolvePluginsRelativeTo] A folder where plugins should be resolved from, CWD by default - * @property {Object} [rule] Specify rules - * @property {string[]} [rulesdir] Load additional rules from this directory. Deprecated: Use rules from plugins - * @property {boolean} stdin Lint code provided on - * @property {string} [stdinFilename] Specify filename to process STDIN as - * @property {boolean} quiet Report errors only - * @property {boolean} [version] Output the version number - * @property {boolean} warnIgnored Show warnings when the file list includes ignored files - * @property {boolean} [passOnNoPatterns=false] When set to true, missing patterns cause - * the linting operation to short circuit and not report any failures. - * @property {string[]} _ Positional filenames or patterns - * @property {boolean} [stats] Report additional statistics - */ - -//------------------------------------------------------------------------------ -// Initialization and Public Interface -//------------------------------------------------------------------------------ - -// exports "parse(args)", "generateHelp()", and "generateHelpForOption(optionName)" - -/** - * Creates the CLI options for ESLint. - * @param {boolean} usingFlatConfig Indicates if flat config is being used. - * @returns {Object} The optionator instance. - */ -module.exports = function(usingFlatConfig) { - - let lookupFlag; - - if (usingFlatConfig) { - lookupFlag = { - option: "config-lookup", - type: "Boolean", - default: "true", - description: "Disable look up for eslint.config.js" - }; - } else { - lookupFlag = { - option: "eslintrc", - type: "Boolean", - default: "true", - description: "Disable use of configuration from .eslintrc.*" - }; - } - - let envFlag; - - if (!usingFlatConfig) { - envFlag = { - option: "env", - type: "[String]", - description: "Specify environments" - }; - } - - let inspectConfigFlag; - - if (usingFlatConfig) { - inspectConfigFlag = { - option: "inspect-config", - type: "Boolean", - description: "Open the config inspector with the current configuration" - }; - } - - let extFlag; - - if (!usingFlatConfig) { - extFlag = { - option: "ext", - type: "[String]", - description: "Specify JavaScript file extensions" - }; - } - - let resolvePluginsFlag; - - if (!usingFlatConfig) { - resolvePluginsFlag = { - option: "resolve-plugins-relative-to", - type: "path::String", - description: "A folder where plugins should be resolved from, CWD by default" - }; - } - - let rulesDirFlag; - - if (!usingFlatConfig) { - rulesDirFlag = { - option: "rulesdir", - type: "[path::String]", - description: "Load additional rules from this directory. Deprecated: Use rules from plugins" - }; - } - - let ignorePathFlag; - - if (!usingFlatConfig) { - ignorePathFlag = { - option: "ignore-path", - type: "path::String", - description: "Specify path of ignore file" - }; - } - - let statsFlag; - - if (usingFlatConfig) { - statsFlag = { - option: "stats", - type: "Boolean", - default: "false", - description: "Add statistics to the lint report" - }; - } - - let warnIgnoredFlag; - - if (usingFlatConfig) { - warnIgnoredFlag = { - option: "warn-ignored", - type: "Boolean", - default: "true", - description: "Suppress warnings when the file list includes ignored files" - }; - } - - let flagFlag; - - if (usingFlatConfig) { - flagFlag = { - option: "flag", - type: "[String]", - description: "Enable a feature flag" - }; - } - - return optionator({ - prepend: "eslint [options] file.js [file.js] [dir]", - defaults: { - concatRepeatedArrays: true, - mergeRepeatedObjects: true - }, - options: [ - { - heading: "Basic configuration" - }, - lookupFlag, - { - option: "config", - alias: "c", - type: "path::String", - description: usingFlatConfig - ? "Use this configuration instead of eslint.config.js, eslint.config.mjs, or eslint.config.cjs" - : "Use this configuration, overriding .eslintrc.* config options if present" - }, - inspectConfigFlag, - envFlag, - extFlag, - { - option: "global", - type: "[String]", - description: "Define global variables" - }, - { - option: "parser", - type: "String", - description: "Specify the parser to be used" - }, - { - option: "parser-options", - type: "Object", - description: "Specify parser options" - }, - resolvePluginsFlag, - { - heading: "Specify Rules and Plugins" - }, - { - option: "plugin", - type: "[String]", - description: "Specify plugins" - }, - { - option: "rule", - type: "Object", - description: "Specify rules" - }, - rulesDirFlag, - { - heading: "Fix Problems" - }, - { - option: "fix", - type: "Boolean", - default: false, - description: "Automatically fix problems" - }, - { - option: "fix-dry-run", - type: "Boolean", - default: false, - description: "Automatically fix problems without saving the changes to the file system" - }, - { - option: "fix-type", - type: "Array", - description: "Specify the types of fixes to apply (directive, problem, suggestion, layout)" - }, - { - heading: "Ignore Files" - }, - ignorePathFlag, - { - option: "ignore", - type: "Boolean", - default: "true", - description: "Disable use of ignore files and patterns" - }, - { - option: "ignore-pattern", - type: "[String]", - description: `Patterns of files to ignore${usingFlatConfig ? "" : " (in addition to those in .eslintignore)"}`, - concatRepeatedArrays: [true, { - oneValuePerFlag: true - }] - }, - { - heading: "Use stdin" - }, - { - option: "stdin", - type: "Boolean", - default: "false", - description: "Lint code provided on " - }, - { - option: "stdin-filename", - type: "String", - description: "Specify filename to process STDIN as" - }, - { - heading: "Handle Warnings" - }, - { - option: "quiet", - type: "Boolean", - default: "false", - description: "Report errors only" - }, - { - option: "max-warnings", - type: "Int", - default: "-1", - description: "Number of warnings to trigger nonzero exit code" - }, - { - heading: "Output" - }, - { - option: "output-file", - alias: "o", - type: "path::String", - description: "Specify file to write report to" - }, - { - option: "format", - alias: "f", - type: "String", - default: "stylish", - description: "Use a specific output format" - }, - { - option: "color", - type: "Boolean", - alias: "no-color", - description: "Force enabling/disabling of color" - }, - { - heading: "Inline configuration comments" - }, - { - option: "inline-config", - type: "Boolean", - default: "true", - description: "Prevent comments from changing config or rules" - }, - { - option: "report-unused-disable-directives", - type: "Boolean", - default: void 0, - description: "Adds reported errors for unused eslint-disable and eslint-enable directives" - }, - { - option: "report-unused-disable-directives-severity", - type: "String", - default: void 0, - description: "Chooses severity level for reporting unused eslint-disable and eslint-enable directives", - enum: ["off", "warn", "error", "0", "1", "2"] - }, - { - heading: "Caching" - }, - { - option: "cache", - type: "Boolean", - default: "false", - description: "Only check changed files" - }, - { - option: "cache-file", - type: "path::String", - default: ".eslintcache", - description: "Path to the cache file. Deprecated: use --cache-location" - }, - { - option: "cache-location", - type: "path::String", - description: "Path to the cache file or directory" - }, - { - option: "cache-strategy", - dependsOn: ["cache"], - type: "String", - default: "metadata", - enum: ["metadata", "content"], - description: "Strategy to use for detecting changed files in the cache" - }, - { - heading: "Miscellaneous" - }, - { - option: "init", - type: "Boolean", - default: "false", - description: "Run config initialization wizard" - }, - { - option: "env-info", - type: "Boolean", - default: "false", - description: "Output execution environment information" - }, - { - option: "error-on-unmatched-pattern", - type: "Boolean", - default: "true", - description: "Prevent errors when pattern is unmatched" - }, - { - option: "exit-on-fatal-error", - type: "Boolean", - default: "false", - description: "Exit with exit code 2 in case of fatal error" - }, - warnIgnoredFlag, - { - option: "pass-on-no-patterns", - type: "Boolean", - default: false, - description: "Exit with exit code 0 in case no file patterns are passed" - }, - { - option: "debug", - type: "Boolean", - default: false, - description: "Output debugging information" - }, - { - option: "help", - alias: "h", - type: "Boolean", - description: "Show help" - }, - { - option: "version", - alias: "v", - type: "Boolean", - description: "Output the version number" - }, - { - option: "print-config", - type: "path::String", - description: "Print the configuration for the given file" - }, - statsFlag, - flagFlag - ].filter(value => !!value) - }); -}; diff --git a/tools/eslint/node_modules/eslint/lib/rule-tester/index.js b/tools/eslint/node_modules/eslint/lib/rule-tester/index.js deleted file mode 100644 index 58f67ee49403ba..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/rule-tester/index.js +++ /dev/null @@ -1,7 +0,0 @@ -"use strict"; - -const RuleTester = require("./rule-tester"); - -module.exports = { - RuleTester -}; diff --git a/tools/eslint/node_modules/eslint/lib/rule-tester/rule-tester.js b/tools/eslint/node_modules/eslint/lib/rule-tester/rule-tester.js deleted file mode 100644 index 756490e1df3d97..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/rule-tester/rule-tester.js +++ /dev/null @@ -1,1286 +0,0 @@ -/** - * @fileoverview Mocha/Jest test wrapper - * @author Ilya Volodin - */ -"use strict"; - -/* globals describe, it -- Mocha globals */ - -//------------------------------------------------------------------------------ -// Requirements -//------------------------------------------------------------------------------ - -const - assert = require("node:assert"), - util = require("node:util"), - path = require("node:path"), - equal = require("fast-deep-equal"), - Traverser = require("../shared/traverser"), - { getRuleOptionsSchema } = require("../config/flat-config-helpers"), - { Linter, SourceCodeFixer } = require("../linter"), - { interpolate, getPlaceholderMatcher } = require("../linter/interpolate"), - stringify = require("json-stable-stringify-without-jsonify"); - -const { FlatConfigArray } = require("../config/flat-config-array"); -const { defaultConfig } = require("../config/default-config"); - -const ajv = require("../shared/ajv")({ strictDefaults: true }); - -const parserSymbol = Symbol.for("eslint.RuleTester.parser"); -const { ConfigArraySymbol } = require("@eslint/config-array"); -const { isSerializable } = require("../shared/serialization"); - -const { SourceCode } = require("../languages/js/source-code"); - -//------------------------------------------------------------------------------ -// Typedefs -//------------------------------------------------------------------------------ - -/** @typedef {import("../shared/types").Parser} Parser */ -/** @typedef {import("../shared/types").LanguageOptions} LanguageOptions */ -/** @typedef {import("../shared/types").Rule} Rule */ - - -/** - * A test case that is expected to pass lint. - * @typedef {Object} ValidTestCase - * @property {string} [name] Name for the test case. - * @property {string} code Code for the test case. - * @property {any[]} [options] Options for the test case. - * @property {LanguageOptions} [languageOptions] The language options to use in the test case. - * @property {{ [name: string]: any }} [settings] Settings for the test case. - * @property {string} [filename] The fake filename for the test case. Useful for rules that make assertion about filenames. - * @property {boolean} [only] Run only this test case or the subset of test cases with this property. - */ - -/** - * A test case that is expected to fail lint. - * @typedef {Object} InvalidTestCase - * @property {string} [name] Name for the test case. - * @property {string} code Code for the test case. - * @property {number | Array} errors Expected errors. - * @property {string | null} [output] The expected code after autofixes are applied. If set to `null`, the test runner will assert that no autofix is suggested. - * @property {any[]} [options] Options for the test case. - * @property {{ [name: string]: any }} [settings] Settings for the test case. - * @property {string} [filename] The fake filename for the test case. Useful for rules that make assertion about filenames. - * @property {LanguageOptions} [languageOptions] The language options to use in the test case. - * @property {boolean} [only] Run only this test case or the subset of test cases with this property. - */ - -/** - * A description of a reported error used in a rule tester test. - * @typedef {Object} TestCaseError - * @property {string | RegExp} [message] Message. - * @property {string} [messageId] Message ID. - * @property {string} [type] The type of the reported AST node. - * @property {{ [name: string]: string }} [data] The data used to fill the message template. - * @property {number} [line] The 1-based line number of the reported start location. - * @property {number} [column] The 1-based column number of the reported start location. - * @property {number} [endLine] The 1-based line number of the reported end location. - * @property {number} [endColumn] The 1-based column number of the reported end location. - */ - -//------------------------------------------------------------------------------ -// Private Members -//------------------------------------------------------------------------------ - -/* - * testerDefaultConfig must not be modified as it allows to reset the tester to - * the initial default configuration - */ -const testerDefaultConfig = { rules: {} }; - -/* - * RuleTester uses this config as its default. This can be overwritten via - * setDefaultConfig(). - */ -let sharedDefaultConfig = { rules: {} }; - -/* - * List every parameters possible on a test case that are not related to eslint - * configuration - */ -const RuleTesterParameters = [ - "name", - "code", - "filename", - "options", - "errors", - "output", - "only" -]; - -/* - * All allowed property names in error objects. - */ -const errorObjectParameters = new Set([ - "message", - "messageId", - "data", - "type", - "line", - "column", - "endLine", - "endColumn", - "suggestions" -]); -const friendlyErrorObjectParameterList = `[${[...errorObjectParameters].map(key => `'${key}'`).join(", ")}]`; - -/* - * All allowed property names in suggestion objects. - */ -const suggestionObjectParameters = new Set([ - "desc", - "messageId", - "data", - "output" -]); -const friendlySuggestionObjectParameterList = `[${[...suggestionObjectParameters].map(key => `'${key}'`).join(", ")}]`; - -/* - * Ignored test case properties when checking for test case duplicates. - */ -const duplicationIgnoredParameters = new Set([ - "name", - "errors", - "output" -]); - -const forbiddenMethods = [ - "applyInlineConfig", - "applyLanguageOptions", - "finalize" -]; - -/** @type {Map} */ -const forbiddenMethodCalls = new Map(forbiddenMethods.map(methodName => ([methodName, new WeakSet()]))); - -const hasOwnProperty = Function.call.bind(Object.hasOwnProperty); - -/** - * Clones a given value deeply. - * Note: This ignores `parent` property. - * @param {any} x A value to clone. - * @returns {any} A cloned value. - */ -function cloneDeeplyExcludesParent(x) { - if (typeof x === "object" && x !== null) { - if (Array.isArray(x)) { - return x.map(cloneDeeplyExcludesParent); - } - - const retv = {}; - - for (const key in x) { - if (key !== "parent" && hasOwnProperty(x, key)) { - retv[key] = cloneDeeplyExcludesParent(x[key]); - } - } - - return retv; - } - - return x; -} - -/** - * Freezes a given value deeply. - * @param {any} x A value to freeze. - * @returns {void} - */ -function freezeDeeply(x) { - if (typeof x === "object" && x !== null) { - if (Array.isArray(x)) { - x.forEach(freezeDeeply); - } else { - for (const key in x) { - if (key !== "parent" && hasOwnProperty(x, key)) { - freezeDeeply(x[key]); - } - } - } - Object.freeze(x); - } -} - -/** - * Replace control characters by `\u00xx` form. - * @param {string} text The text to sanitize. - * @returns {string} The sanitized text. - */ -function sanitize(text) { - if (typeof text !== "string") { - return ""; - } - return text.replace( - /[\u0000-\u0009\u000b-\u001a]/gu, // eslint-disable-line no-control-regex -- Escaping controls - c => `\\u${c.codePointAt(0).toString(16).padStart(4, "0")}` - ); -} - -/** - * Define `start`/`end` properties as throwing error. - * @param {string} objName Object name used for error messages. - * @param {ASTNode} node The node to define. - * @returns {void} - */ -function defineStartEndAsError(objName, node) { - Object.defineProperties(node, { - start: { - get() { - throw new Error(`Use ${objName}.range[0] instead of ${objName}.start`); - }, - configurable: true, - enumerable: false - }, - end: { - get() { - throw new Error(`Use ${objName}.range[1] instead of ${objName}.end`); - }, - configurable: true, - enumerable: false - } - }); -} - - -/** - * Define `start`/`end` properties of all nodes of the given AST as throwing error. - * @param {ASTNode} ast The root node to errorize `start`/`end` properties. - * @param {Object} [visitorKeys] Visitor keys to be used for traversing the given ast. - * @returns {void} - */ -function defineStartEndAsErrorInTree(ast, visitorKeys) { - Traverser.traverse(ast, { visitorKeys, enter: defineStartEndAsError.bind(null, "node") }); - ast.tokens.forEach(defineStartEndAsError.bind(null, "token")); - ast.comments.forEach(defineStartEndAsError.bind(null, "token")); -} - -/** - * Wraps the given parser in order to intercept and modify return values from the `parse` and `parseForESLint` methods, for test purposes. - * In particular, to modify ast nodes, tokens and comments to throw on access to their `start` and `end` properties. - * @param {Parser} parser Parser object. - * @returns {Parser} Wrapped parser object. - */ -function wrapParser(parser) { - - if (typeof parser.parseForESLint === "function") { - return { - [parserSymbol]: parser, - parseForESLint(...args) { - const ret = parser.parseForESLint(...args); - - defineStartEndAsErrorInTree(ret.ast, ret.visitorKeys); - return ret; - } - }; - } - - return { - [parserSymbol]: parser, - parse(...args) { - const ast = parser.parse(...args); - - defineStartEndAsErrorInTree(ast); - return ast; - } - }; -} - -/** - * Function to replace forbidden `SourceCode` methods. Allows just one call per method. - * @param {string} methodName The name of the method to forbid. - * @param {Function} prototype The prototype with the original method to call. - * @returns {Function} The function that throws the error. - */ -function throwForbiddenMethodError(methodName, prototype) { - - const original = prototype[methodName]; - - return function(...args) { - - const called = forbiddenMethodCalls.get(methodName); - - /* eslint-disable no-invalid-this -- needed to operate as a method. */ - if (!called.has(this)) { - called.add(this); - - return original.apply(this, args); - } - /* eslint-enable no-invalid-this -- not needed past this point */ - - throw new Error( - `\`SourceCode#${methodName}()\` cannot be called inside a rule.` - ); - }; -} - -/** - * Extracts names of {{ placeholders }} from the reported message. - * @param {string} message Reported message - * @returns {string[]} Array of placeholder names - */ -function getMessagePlaceholders(message) { - const matcher = getPlaceholderMatcher(); - - return Array.from(message.matchAll(matcher), ([, name]) => name.trim()); -} - -/** - * Returns the placeholders in the reported messages but - * only includes the placeholders available in the raw message and not in the provided data. - * @param {string} message The reported message - * @param {string} raw The raw message specified in the rule meta.messages - * @param {undefined|Record} data The passed - * @returns {string[]} Missing placeholder names - */ -function getUnsubstitutedMessagePlaceholders(message, raw, data = {}) { - const unsubstituted = getMessagePlaceholders(message); - - if (unsubstituted.length === 0) { - return []; - } - - // Remove false positives by only counting placeholders in the raw message, which were not provided in the data matcher or added with a data property - const known = getMessagePlaceholders(raw); - const provided = Object.keys(data); - - return unsubstituted.filter(name => known.includes(name) && !provided.includes(name)); -} - -const metaSchemaDescription = ` -\t- If the rule has options, set \`meta.schema\` to an array or non-empty object to enable options validation. -\t- If the rule doesn't have options, omit \`meta.schema\` to enforce that no options can be passed to the rule. -\t- You can also set \`meta.schema\` to \`false\` to opt-out of options validation (not recommended). - -\thttps://eslint.org/docs/latest/extend/custom-rules#options-schemas -`; - -//------------------------------------------------------------------------------ -// Public Interface -//------------------------------------------------------------------------------ - -// default separators for testing -const DESCRIBE = Symbol("describe"); -const IT = Symbol("it"); -const IT_ONLY = Symbol("itOnly"); - -/** - * This is `it` default handler if `it` don't exist. - * @this {Mocha} - * @param {string} text The description of the test case. - * @param {Function} method The logic of the test case. - * @throws {Error} Any error upon execution of `method`. - * @returns {any} Returned value of `method`. - */ -function itDefaultHandler(text, method) { - try { - return method.call(this); - } catch (err) { - if (err instanceof assert.AssertionError) { - err.message += ` (${util.inspect(err.actual)} ${err.operator} ${util.inspect(err.expected)})`; - } - throw err; - } -} - -/** - * This is `describe` default handler if `describe` don't exist. - * @this {Mocha} - * @param {string} text The description of the test case. - * @param {Function} method The logic of the test case. - * @returns {any} Returned value of `method`. - */ -function describeDefaultHandler(text, method) { - return method.call(this); -} - -/** - * Mocha test wrapper. - */ -class RuleTester { - - /** - * Creates a new instance of RuleTester. - * @param {Object} [testerConfig] Optional, extra configuration for the tester - */ - constructor(testerConfig = {}) { - - /** - * The configuration to use for this tester. Combination of the tester - * configuration and the default configuration. - * @type {Object} - */ - this.testerConfig = [ - sharedDefaultConfig, - testerConfig, - { rules: { "rule-tester/validate-ast": "error" } } - ]; - - this.linter = new Linter({ configType: "flat" }); - } - - /** - * Set the configuration to use for all future tests - * @param {Object} config the configuration to use. - * @throws {TypeError} If non-object config. - * @returns {void} - */ - static setDefaultConfig(config) { - if (typeof config !== "object" || config === null) { - throw new TypeError("RuleTester.setDefaultConfig: config must be an object"); - } - sharedDefaultConfig = config; - - // Make sure the rules object exists since it is assumed to exist later - sharedDefaultConfig.rules = sharedDefaultConfig.rules || {}; - } - - /** - * Get the current configuration used for all tests - * @returns {Object} the current configuration - */ - static getDefaultConfig() { - return sharedDefaultConfig; - } - - /** - * Reset the configuration to the initial configuration of the tester removing - * any changes made until now. - * @returns {void} - */ - static resetDefaultConfig() { - sharedDefaultConfig = { - rules: { - ...testerDefaultConfig.rules - } - }; - } - - - /* - * If people use `mocha test.js --watch` command, `describe` and `it` function - * instances are different for each execution. So `describe` and `it` should get fresh instance - * always. - */ - static get describe() { - return ( - this[DESCRIBE] || - (typeof describe === "function" ? describe : describeDefaultHandler) - ); - } - - static set describe(value) { - this[DESCRIBE] = value; - } - - static get it() { - return ( - this[IT] || - (typeof it === "function" ? it : itDefaultHandler) - ); - } - - static set it(value) { - this[IT] = value; - } - - /** - * Adds the `only` property to a test to run it in isolation. - * @param {string | ValidTestCase | InvalidTestCase} item A single test to run by itself. - * @returns {ValidTestCase | InvalidTestCase} The test with `only` set. - */ - static only(item) { - if (typeof item === "string") { - return { code: item, only: true }; - } - - return { ...item, only: true }; - } - - static get itOnly() { - if (typeof this[IT_ONLY] === "function") { - return this[IT_ONLY]; - } - if (typeof this[IT] === "function" && typeof this[IT].only === "function") { - return Function.bind.call(this[IT].only, this[IT]); - } - if (typeof it === "function" && typeof it.only === "function") { - return Function.bind.call(it.only, it); - } - - if (typeof this[DESCRIBE] === "function" || typeof this[IT] === "function") { - throw new Error( - "Set `RuleTester.itOnly` to use `only` with a custom test framework.\n" + - "See https://eslint.org/docs/latest/integrate/nodejs-api#customizing-ruletester for more." - ); - } - if (typeof it === "function") { - throw new Error("The current test framework does not support exclusive tests with `only`."); - } - throw new Error("To use `only`, use RuleTester with a test framework that provides `it.only()` like Mocha."); - } - - static set itOnly(value) { - this[IT_ONLY] = value; - } - - - /** - * Adds a new rule test to execute. - * @param {string} ruleName The name of the rule to run. - * @param {Rule} rule The rule to test. - * @param {{ - * valid: (ValidTestCase | string)[], - * invalid: InvalidTestCase[] - * }} test The collection of tests to run. - * @throws {TypeError|Error} If `rule` is not an object with a `create` method, - * or if non-object `test`, or if a required scenario of the given type is missing. - * @returns {void} - */ - run(ruleName, rule, test) { - - const testerConfig = this.testerConfig, - requiredScenarios = ["valid", "invalid"], - scenarioErrors = [], - linter = this.linter, - ruleId = `rule-to-test/${ruleName}`; - - const seenValidTestCases = new Set(); - const seenInvalidTestCases = new Set(); - - if (!rule || typeof rule !== "object" || typeof rule.create !== "function") { - throw new TypeError("Rule must be an object with a `create` method"); - } - - if (!test || typeof test !== "object") { - throw new TypeError(`Test Scenarios for rule ${ruleName} : Could not find test scenario object`); - } - - requiredScenarios.forEach(scenarioType => { - if (!test[scenarioType]) { - scenarioErrors.push(`Could not find any ${scenarioType} test scenarios`); - } - }); - - if (scenarioErrors.length > 0) { - throw new Error([ - `Test Scenarios for rule ${ruleName} is invalid:` - ].concat(scenarioErrors).join("\n")); - } - - const baseConfig = [ - { files: ["**"] }, // Make sure the default config matches for all files - { - plugins: { - - // copy root plugin over - "@": { - - /* - * Parsers are wrapped to detect more errors, so this needs - * to be a new object for each call to run(), otherwise the - * parsers will be wrapped multiple times. - */ - parsers: { - ...defaultConfig[0].plugins["@"].parsers - }, - - /* - * The rules key on the default plugin is a proxy to lazy-load - * just the rules that are needed. So, don't create a new object - * here, just use the default one to keep that performance - * enhancement. - */ - rules: defaultConfig[0].plugins["@"].rules, - languages: defaultConfig[0].plugins["@"].languages - }, - "rule-to-test": { - rules: { - [ruleName]: Object.assign({}, rule, { - - // Create a wrapper rule that freezes the `context` properties. - create(context) { - freezeDeeply(context.options); - freezeDeeply(context.settings); - freezeDeeply(context.parserOptions); - - // freezeDeeply(context.languageOptions); - - return rule.create(context); - } - }) - } - } - }, - language: defaultConfig[0].language, - languageOptions: { - ...defaultConfig[0].languageOptions - } - }, - ...defaultConfig.slice(1) - ]; - - /** - * Run the rule for the given item - * @param {string|Object} item Item to run the rule against - * @throws {Error} If an invalid schema. - * @returns {Object} Eslint run result - * @private - */ - function runRuleForItem(item) { - const flatConfigArrayOptions = { - baseConfig - }; - - if (item.filename) { - flatConfigArrayOptions.basePath = path.parse(item.filename).root; - } - - const configs = new FlatConfigArray(testerConfig, flatConfigArrayOptions); - - /* - * Modify the returned config so that the parser is wrapped to catch - * access of the start/end properties. This method is called just - * once per code snippet being tested, so each test case gets a clean - * parser. - */ - configs[ConfigArraySymbol.finalizeConfig] = function(...args) { - - // can't do super here :( - const proto = Object.getPrototypeOf(this); - const calculatedConfig = proto[ConfigArraySymbol.finalizeConfig].apply(this, args); - - // wrap the parser to catch start/end property access - calculatedConfig.languageOptions.parser = wrapParser(calculatedConfig.languageOptions.parser); - return calculatedConfig; - }; - - let code, filename, output, beforeAST, afterAST; - - if (typeof item === "string") { - code = item; - } else { - code = item.code; - - /* - * Assumes everything on the item is a config except for the - * parameters used by this tester - */ - const itemConfig = { ...item }; - - for (const parameter of RuleTesterParameters) { - delete itemConfig[parameter]; - } - - // wrap any parsers - if (itemConfig.languageOptions && itemConfig.languageOptions.parser) { - - const parser = itemConfig.languageOptions.parser; - - if (parser && typeof parser !== "object") { - throw new Error("Parser must be an object with a parse() or parseForESLint() method."); - } - - } - - /* - * Create the config object from the tester config and this item - * specific configurations. - */ - configs.push(itemConfig); - } - - if (hasOwnProperty(item, "only")) { - assert.ok(typeof item.only === "boolean", "Optional test case property 'only' must be a boolean"); - } - if (hasOwnProperty(item, "filename")) { - assert.ok(typeof item.filename === "string", "Optional test case property 'filename' must be a string"); - filename = item.filename; - } - - let ruleConfig = 1; - - if (hasOwnProperty(item, "options")) { - assert(Array.isArray(item.options), "options must be an array"); - ruleConfig = [1, ...item.options]; - } - - configs.push({ - rules: { - [ruleId]: ruleConfig - } - }); - - let schema; - - try { - schema = getRuleOptionsSchema(rule); - } catch (err) { - err.message += metaSchemaDescription; - throw err; - } - - /* - * Check and throw an error if the schema is an empty object (`schema:{}`), because such schema - * doesn't validate or enforce anything and is therefore considered a possible error. If the intent - * was to skip options validation, `schema:false` should be set instead (explicit opt-out). - * - * For this purpose, a schema object is considered empty if it doesn't have any own enumerable string-keyed - * properties. While `ajv.compile()` does use enumerable properties from the prototype chain as well, - * it caches compiled schemas by serializing only own enumerable properties, so it's generally not a good idea - * to use inherited properties in schemas because schemas that differ only in inherited properties would end up - * having the same cache entry that would be correct for only one of them. - * - * At this point, `schema` can only be an object or `null`. - */ - if (schema && Object.keys(schema).length === 0) { - throw new Error(`\`schema: {}\` is a no-op${metaSchemaDescription}`); - } - - /* - * Setup AST getters. - * The goal is to check whether or not AST was modified when - * running the rule under test. - */ - configs.push({ - plugins: { - "rule-tester": { - rules: { - "validate-ast": { - create() { - return { - Program(node) { - beforeAST = cloneDeeplyExcludesParent(node); - }, - "Program:exit"(node) { - afterAST = node; - } - }; - } - } - } - } - } - }); - - if (schema) { - ajv.validateSchema(schema); - - if (ajv.errors) { - const errors = ajv.errors.map(error => { - const field = error.dataPath[0] === "." ? error.dataPath.slice(1) : error.dataPath; - - return `\t${field}: ${error.message}`; - }).join("\n"); - - throw new Error([`Schema for rule ${ruleName} is invalid:`, errors]); - } - - /* - * `ajv.validateSchema` checks for errors in the structure of the schema (by comparing the schema against a "meta-schema"), - * and it reports those errors individually. However, there are other types of schema errors that only occur when compiling - * the schema (e.g. using invalid defaults in a schema), and only one of these errors can be reported at a time. As a result, - * the schema is compiled here separately from checking for `validateSchema` errors. - */ - try { - ajv.compile(schema); - } catch (err) { - throw new Error(`Schema for rule ${ruleName} is invalid: ${err.message}`); - } - } - - // check for validation errors - try { - configs.normalizeSync(); - configs.getConfig("test.js"); - } catch (error) { - error.message = `ESLint configuration in rule-tester is invalid: ${error.message}`; - throw error; - } - - // Verify the code. - const { applyLanguageOptions, applyInlineConfig, finalize } = SourceCode.prototype; - let messages; - - try { - forbiddenMethods.forEach(methodName => { - SourceCode.prototype[methodName] = throwForbiddenMethodError(methodName, SourceCode.prototype); - }); - - messages = linter.verify(code, configs, filename); - } finally { - SourceCode.prototype.applyInlineConfig = applyInlineConfig; - SourceCode.prototype.applyLanguageOptions = applyLanguageOptions; - SourceCode.prototype.finalize = finalize; - } - - - const fatalErrorMessage = messages.find(m => m.fatal); - - assert(!fatalErrorMessage, `A fatal parsing error occurred: ${fatalErrorMessage && fatalErrorMessage.message}`); - - // Verify if autofix makes a syntax error or not. - if (messages.some(m => m.fix)) { - output = SourceCodeFixer.applyFixes(code, messages).output; - const errorMessageInFix = linter.verify(output, configs, filename).find(m => m.fatal); - - assert(!errorMessageInFix, [ - "A fatal parsing error occurred in autofix.", - `Error: ${errorMessageInFix && errorMessageInFix.message}`, - "Autofix output:", - output - ].join("\n")); - } else { - output = code; - } - - return { - messages, - output, - beforeAST, - afterAST: cloneDeeplyExcludesParent(afterAST), - configs, - filename - }; - } - - /** - * Check if the AST was changed - * @param {ASTNode} beforeAST AST node before running - * @param {ASTNode} afterAST AST node after running - * @returns {void} - * @private - */ - function assertASTDidntChange(beforeAST, afterAST) { - if (!equal(beforeAST, afterAST)) { - assert.fail("Rule should not modify AST."); - } - } - - /** - * Check if this test case is a duplicate of one we have seen before. - * @param {string|Object} item test case object - * @param {Set} seenTestCases set of serialized test cases we have seen so far (managed by this function) - * @returns {void} - * @private - */ - function checkDuplicateTestCase(item, seenTestCases) { - if (!isSerializable(item)) { - - /* - * If we can't serialize a test case (because it contains a function, RegExp, etc), skip the check. - * This might happen with properties like: options, plugins, settings, languageOptions.parser, languageOptions.parserOptions. - */ - return; - } - - const normalizedItem = typeof item === "string" ? { code: item } : item; - const serializedTestCase = stringify(normalizedItem, { - replacer(key, value) { - - // "this" is the currently stringified object --> only ignore top-level properties - return (normalizedItem !== this || !duplicationIgnoredParameters.has(key)) ? value : void 0; - } - }); - - assert( - !seenTestCases.has(serializedTestCase), - "detected duplicate test case" - ); - seenTestCases.add(serializedTestCase); - } - - /** - * Check if the template is valid or not - * all valid cases go through this - * @param {string|Object} item Item to run the rule against - * @returns {void} - * @private - */ - function testValidTemplate(item) { - const code = typeof item === "object" ? item.code : item; - - assert.ok(typeof code === "string", "Test case must specify a string value for 'code'"); - if (item.name) { - assert.ok(typeof item.name === "string", "Optional test case property 'name' must be a string"); - } - - checkDuplicateTestCase(item, seenValidTestCases); - - const result = runRuleForItem(item); - const messages = result.messages; - - assert.strictEqual(messages.length, 0, util.format("Should have no errors but had %d: %s", - messages.length, - util.inspect(messages))); - - assertASTDidntChange(result.beforeAST, result.afterAST); - } - - /** - * Asserts that the message matches its expected value. If the expected - * value is a regular expression, it is checked against the actual - * value. - * @param {string} actual Actual value - * @param {string|RegExp} expected Expected value - * @returns {void} - * @private - */ - function assertMessageMatches(actual, expected) { - if (expected instanceof RegExp) { - - // assert.js doesn't have a built-in RegExp match function - assert.ok( - expected.test(actual), - `Expected '${actual}' to match ${expected}` - ); - } else { - assert.strictEqual(actual, expected); - } - } - - /** - * Check if the template is invalid or not - * all invalid cases go through this. - * @param {string|Object} item Item to run the rule against - * @returns {void} - * @private - */ - function testInvalidTemplate(item) { - assert.ok(typeof item.code === "string", "Test case must specify a string value for 'code'"); - if (item.name) { - assert.ok(typeof item.name === "string", "Optional test case property 'name' must be a string"); - } - assert.ok(item.errors || item.errors === 0, - `Did not specify errors for an invalid test of ${ruleName}`); - - if (Array.isArray(item.errors) && item.errors.length === 0) { - assert.fail("Invalid cases must have at least one error"); - } - - checkDuplicateTestCase(item, seenInvalidTestCases); - - const ruleHasMetaMessages = hasOwnProperty(rule, "meta") && hasOwnProperty(rule.meta, "messages"); - const friendlyIDList = ruleHasMetaMessages ? `[${Object.keys(rule.meta.messages).map(key => `'${key}'`).join(", ")}]` : null; - - const result = runRuleForItem(item); - const messages = result.messages; - - for (const message of messages) { - if (hasOwnProperty(message, "suggestions")) { - - /** @type {Map} */ - const seenMessageIndices = new Map(); - - for (let i = 0; i < message.suggestions.length; i += 1) { - const suggestionMessage = message.suggestions[i].desc; - const previous = seenMessageIndices.get(suggestionMessage); - - assert.ok(!seenMessageIndices.has(suggestionMessage), `Suggestion message '${suggestionMessage}' reported from suggestion ${i} was previously reported by suggestion ${previous}. Suggestion messages should be unique within an error.`); - seenMessageIndices.set(suggestionMessage, i); - } - } - } - - if (typeof item.errors === "number") { - - if (item.errors === 0) { - assert.fail("Invalid cases must have 'error' value greater than 0"); - } - - assert.strictEqual(messages.length, item.errors, util.format("Should have %d error%s but had %d: %s", - item.errors, - item.errors === 1 ? "" : "s", - messages.length, - util.inspect(messages))); - } else { - assert.strictEqual( - messages.length, item.errors.length, util.format( - "Should have %d error%s but had %d: %s", - item.errors.length, - item.errors.length === 1 ? "" : "s", - messages.length, - util.inspect(messages) - ) - ); - - const hasMessageOfThisRule = messages.some(m => m.ruleId === ruleId); - - for (let i = 0, l = item.errors.length; i < l; i++) { - const error = item.errors[i]; - const message = messages[i]; - - assert(hasMessageOfThisRule, "Error rule name should be the same as the name of the rule being tested"); - - if (typeof error === "string" || error instanceof RegExp) { - - // Just an error message. - assertMessageMatches(message.message, error); - assert.ok(message.suggestions === void 0, `Error at index ${i} has suggestions. Please convert the test error into an object and specify 'suggestions' property on it to test suggestions.`); - } else if (typeof error === "object" && error !== null) { - - /* - * Error object. - * This may have a message, messageId, data, node type, line, and/or - * column. - */ - - Object.keys(error).forEach(propertyName => { - assert.ok( - errorObjectParameters.has(propertyName), - `Invalid error property name '${propertyName}'. Expected one of ${friendlyErrorObjectParameterList}.` - ); - }); - - if (hasOwnProperty(error, "message")) { - assert.ok(!hasOwnProperty(error, "messageId"), "Error should not specify both 'message' and a 'messageId'."); - assert.ok(!hasOwnProperty(error, "data"), "Error should not specify both 'data' and 'message'."); - assertMessageMatches(message.message, error.message); - } else if (hasOwnProperty(error, "messageId")) { - assert.ok( - ruleHasMetaMessages, - "Error can not use 'messageId' if rule under test doesn't define 'meta.messages'." - ); - if (!hasOwnProperty(rule.meta.messages, error.messageId)) { - assert(false, `Invalid messageId '${error.messageId}'. Expected one of ${friendlyIDList}.`); - } - assert.strictEqual( - message.messageId, - error.messageId, - `messageId '${message.messageId}' does not match expected messageId '${error.messageId}'.` - ); - - const unsubstitutedPlaceholders = getUnsubstitutedMessagePlaceholders( - message.message, - rule.meta.messages[message.messageId], - error.data - ); - - assert.ok( - unsubstitutedPlaceholders.length === 0, - `The reported message has ${unsubstitutedPlaceholders.length > 1 ? `unsubstituted placeholders: ${unsubstitutedPlaceholders.map(name => `'${name}'`).join(", ")}` : `an unsubstituted placeholder '${unsubstitutedPlaceholders[0]}'`}. Please provide the missing ${unsubstitutedPlaceholders.length > 1 ? "values" : "value"} via the 'data' property in the context.report() call.` - ); - - if (hasOwnProperty(error, "data")) { - - /* - * if data was provided, then directly compare the returned message to a synthetic - * interpolated message using the same message ID and data provided in the test. - * See https://github.com/eslint/eslint/issues/9890 for context. - */ - const unformattedOriginalMessage = rule.meta.messages[error.messageId]; - const rehydratedMessage = interpolate(unformattedOriginalMessage, error.data); - - assert.strictEqual( - message.message, - rehydratedMessage, - `Hydrated message "${rehydratedMessage}" does not match "${message.message}"` - ); - } - } else { - assert.fail("Test error must specify either a 'messageId' or 'message'."); - } - - if (error.type) { - assert.strictEqual(message.nodeType, error.type, `Error type should be ${error.type}, found ${message.nodeType}`); - } - - if (hasOwnProperty(error, "line")) { - assert.strictEqual(message.line, error.line, `Error line should be ${error.line}`); - } - - if (hasOwnProperty(error, "column")) { - assert.strictEqual(message.column, error.column, `Error column should be ${error.column}`); - } - - if (hasOwnProperty(error, "endLine")) { - assert.strictEqual(message.endLine, error.endLine, `Error endLine should be ${error.endLine}`); - } - - if (hasOwnProperty(error, "endColumn")) { - assert.strictEqual(message.endColumn, error.endColumn, `Error endColumn should be ${error.endColumn}`); - } - - assert.ok(!message.suggestions || hasOwnProperty(error, "suggestions"), `Error at index ${i} has suggestions. Please specify 'suggestions' property on the test error object.`); - if (hasOwnProperty(error, "suggestions")) { - - // Support asserting there are no suggestions - const expectsSuggestions = Array.isArray(error.suggestions) ? error.suggestions.length > 0 : Boolean(error.suggestions); - const hasSuggestions = message.suggestions !== void 0; - - if (!hasSuggestions && expectsSuggestions) { - assert.ok(!error.suggestions, `Error should have suggestions on error with message: "${message.message}"`); - } else if (hasSuggestions) { - assert.ok(expectsSuggestions, `Error should have no suggestions on error with message: "${message.message}"`); - if (typeof error.suggestions === "number") { - assert.strictEqual(message.suggestions.length, error.suggestions, `Error should have ${error.suggestions} suggestions. Instead found ${message.suggestions.length} suggestions`); - } else if (Array.isArray(error.suggestions)) { - assert.strictEqual(message.suggestions.length, error.suggestions.length, `Error should have ${error.suggestions.length} suggestions. Instead found ${message.suggestions.length} suggestions`); - - error.suggestions.forEach((expectedSuggestion, index) => { - assert.ok( - typeof expectedSuggestion === "object" && expectedSuggestion !== null, - "Test suggestion in 'suggestions' array must be an object." - ); - Object.keys(expectedSuggestion).forEach(propertyName => { - assert.ok( - suggestionObjectParameters.has(propertyName), - `Invalid suggestion property name '${propertyName}'. Expected one of ${friendlySuggestionObjectParameterList}.` - ); - }); - - const actualSuggestion = message.suggestions[index]; - const suggestionPrefix = `Error Suggestion at index ${index}:`; - - if (hasOwnProperty(expectedSuggestion, "desc")) { - assert.ok( - !hasOwnProperty(expectedSuggestion, "data"), - `${suggestionPrefix} Test should not specify both 'desc' and 'data'.` - ); - assert.ok( - !hasOwnProperty(expectedSuggestion, "messageId"), - `${suggestionPrefix} Test should not specify both 'desc' and 'messageId'.` - ); - assert.strictEqual( - actualSuggestion.desc, - expectedSuggestion.desc, - `${suggestionPrefix} desc should be "${expectedSuggestion.desc}" but got "${actualSuggestion.desc}" instead.` - ); - } else if (hasOwnProperty(expectedSuggestion, "messageId")) { - assert.ok( - ruleHasMetaMessages, - `${suggestionPrefix} Test can not use 'messageId' if rule under test doesn't define 'meta.messages'.` - ); - assert.ok( - hasOwnProperty(rule.meta.messages, expectedSuggestion.messageId), - `${suggestionPrefix} Test has invalid messageId '${expectedSuggestion.messageId}', the rule under test allows only one of ${friendlyIDList}.` - ); - assert.strictEqual( - actualSuggestion.messageId, - expectedSuggestion.messageId, - `${suggestionPrefix} messageId should be '${expectedSuggestion.messageId}' but got '${actualSuggestion.messageId}' instead.` - ); - - const unsubstitutedPlaceholders = getUnsubstitutedMessagePlaceholders( - actualSuggestion.desc, - rule.meta.messages[expectedSuggestion.messageId], - expectedSuggestion.data - ); - - assert.ok( - unsubstitutedPlaceholders.length === 0, - `The message of the suggestion has ${unsubstitutedPlaceholders.length > 1 ? `unsubstituted placeholders: ${unsubstitutedPlaceholders.map(name => `'${name}'`).join(", ")}` : `an unsubstituted placeholder '${unsubstitutedPlaceholders[0]}'`}. Please provide the missing ${unsubstitutedPlaceholders.length > 1 ? "values" : "value"} via the 'data' property for the suggestion in the context.report() call.` - ); - - if (hasOwnProperty(expectedSuggestion, "data")) { - const unformattedMetaMessage = rule.meta.messages[expectedSuggestion.messageId]; - const rehydratedDesc = interpolate(unformattedMetaMessage, expectedSuggestion.data); - - assert.strictEqual( - actualSuggestion.desc, - rehydratedDesc, - `${suggestionPrefix} Hydrated test desc "${rehydratedDesc}" does not match received desc "${actualSuggestion.desc}".` - ); - } - } else if (hasOwnProperty(expectedSuggestion, "data")) { - assert.fail( - `${suggestionPrefix} Test must specify 'messageId' if 'data' is used.` - ); - } else { - assert.fail( - `${suggestionPrefix} Test must specify either 'messageId' or 'desc'.` - ); - } - - assert.ok(hasOwnProperty(expectedSuggestion, "output"), `${suggestionPrefix} The "output" property is required.`); - const codeWithAppliedSuggestion = SourceCodeFixer.applyFixes(item.code, [actualSuggestion]).output; - - // Verify if suggestion fix makes a syntax error or not. - const errorMessageInSuggestion = - linter.verify(codeWithAppliedSuggestion, result.configs, result.filename).find(m => m.fatal); - - assert(!errorMessageInSuggestion, [ - "A fatal parsing error occurred in suggestion fix.", - `Error: ${errorMessageInSuggestion && errorMessageInSuggestion.message}`, - "Suggestion output:", - codeWithAppliedSuggestion - ].join("\n")); - - assert.strictEqual(codeWithAppliedSuggestion, expectedSuggestion.output, `Expected the applied suggestion fix to match the test suggestion output for suggestion at index: ${index} on error with message: "${message.message}"`); - assert.notStrictEqual(expectedSuggestion.output, item.code, `The output of a suggestion should differ from the original source code for suggestion at index: ${index} on error with message: "${message.message}"`); - }); - } else { - assert.fail("Test error object property 'suggestions' should be an array or a number"); - } - } - } - } else { - - // Message was an unexpected type - assert.fail(`Error should be a string, object, or RegExp, but found (${util.inspect(message)})`); - } - } - } - - if (hasOwnProperty(item, "output")) { - if (item.output === null) { - assert.strictEqual( - result.output, - item.code, - "Expected no autofixes to be suggested" - ); - } else { - assert.strictEqual(result.output, item.output, "Output is incorrect."); - assert.notStrictEqual(item.code, item.output, "Test property 'output' matches 'code'. If no autofix is expected, then omit the 'output' property or set it to null."); - } - } else { - assert.strictEqual( - result.output, - item.code, - "The rule fixed the code. Please add 'output' property." - ); - } - - assertASTDidntChange(result.beforeAST, result.afterAST); - } - - /* - * This creates a mocha test suite and pipes all supplied info through - * one of the templates above. - * The test suites for valid/invalid are created conditionally as - * test runners (eg. vitest) fail for empty test suites. - */ - this.constructor.describe(ruleName, () => { - if (test.valid.length > 0) { - this.constructor.describe("valid", () => { - test.valid.forEach(valid => { - this.constructor[valid.only ? "itOnly" : "it"]( - sanitize(typeof valid === "object" ? valid.name || valid.code : valid), - () => { - testValidTemplate(valid); - } - ); - }); - }); - } - - if (test.invalid.length > 0) { - this.constructor.describe("invalid", () => { - test.invalid.forEach(invalid => { - this.constructor[invalid.only ? "itOnly" : "it"]( - sanitize(invalid.name || invalid.code), - () => { - testInvalidTemplate(invalid); - } - ); - }); - }); - } - }); - } -} - -RuleTester[DESCRIBE] = RuleTester[IT] = RuleTester[IT_ONLY] = null; - -module.exports = RuleTester; diff --git a/tools/eslint/node_modules/eslint/lib/rules/accessor-pairs.js b/tools/eslint/node_modules/eslint/lib/rules/accessor-pairs.js deleted file mode 100644 index f97032895df0b9..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/rules/accessor-pairs.js +++ /dev/null @@ -1,346 +0,0 @@ -/** - * @fileoverview Rule to enforce getter and setter pairs in objects and classes. - * @author Gyandeep Singh - */ - -"use strict"; - -//------------------------------------------------------------------------------ -// Requirements -//------------------------------------------------------------------------------ - -const astUtils = require("./utils/ast-utils"); - -//------------------------------------------------------------------------------ -// Typedefs -//------------------------------------------------------------------------------ - -/** - * Property name if it can be computed statically, otherwise the list of the tokens of the key node. - * @typedef {string|Token[]} Key - */ - -/** - * Accessor nodes with the same key. - * @typedef {Object} AccessorData - * @property {Key} key Accessor's key - * @property {ASTNode[]} getters List of getter nodes. - * @property {ASTNode[]} setters List of setter nodes. - */ - -//------------------------------------------------------------------------------ -// Helpers -//------------------------------------------------------------------------------ - -/** - * Checks whether or not the given lists represent the equal tokens in the same order. - * Tokens are compared by their properties, not by instance. - * @param {Token[]} left First list of tokens. - * @param {Token[]} right Second list of tokens. - * @returns {boolean} `true` if the lists have same tokens. - */ -function areEqualTokenLists(left, right) { - if (left.length !== right.length) { - return false; - } - - for (let i = 0; i < left.length; i++) { - const leftToken = left[i], - rightToken = right[i]; - - if (leftToken.type !== rightToken.type || leftToken.value !== rightToken.value) { - return false; - } - } - - return true; -} - -/** - * Checks whether or not the given keys are equal. - * @param {Key} left First key. - * @param {Key} right Second key. - * @returns {boolean} `true` if the keys are equal. - */ -function areEqualKeys(left, right) { - if (typeof left === "string" && typeof right === "string") { - - // Statically computed names. - return left === right; - } - if (Array.isArray(left) && Array.isArray(right)) { - - // Token lists. - return areEqualTokenLists(left, right); - } - - return false; -} - -/** - * Checks whether or not a given node is of an accessor kind ('get' or 'set'). - * @param {ASTNode} node A node to check. - * @returns {boolean} `true` if the node is of an accessor kind. - */ -function isAccessorKind(node) { - return node.kind === "get" || node.kind === "set"; -} - -/** - * Checks whether or not a given node is an argument of a specified method call. - * @param {ASTNode} node A node to check. - * @param {number} index An expected index of the node in arguments. - * @param {string} object An expected name of the object of the method. - * @param {string} property An expected name of the method. - * @returns {boolean} `true` if the node is an argument of the specified method call. - */ -function isArgumentOfMethodCall(node, index, object, property) { - const parent = node.parent; - - return ( - parent.type === "CallExpression" && - astUtils.isSpecificMemberAccess(parent.callee, object, property) && - parent.arguments[index] === node - ); -} - -/** - * Checks whether or not a given node is a property descriptor. - * @param {ASTNode} node A node to check. - * @returns {boolean} `true` if the node is a property descriptor. - */ -function isPropertyDescriptor(node) { - - // Object.defineProperty(obj, "foo", {set: ...}) - if (isArgumentOfMethodCall(node, 2, "Object", "defineProperty") || - isArgumentOfMethodCall(node, 2, "Reflect", "defineProperty") - ) { - return true; - } - - /* - * Object.defineProperties(obj, {foo: {set: ...}}) - * Object.create(proto, {foo: {set: ...}}) - */ - const grandparent = node.parent.parent; - - return grandparent.type === "ObjectExpression" && ( - isArgumentOfMethodCall(grandparent, 1, "Object", "create") || - isArgumentOfMethodCall(grandparent, 1, "Object", "defineProperties") - ); -} - -//------------------------------------------------------------------------------ -// Rule Definition -//------------------------------------------------------------------------------ - -/** @type {import('../shared/types').Rule} */ -module.exports = { - meta: { - type: "suggestion", - - docs: { - description: "Enforce getter and setter pairs in objects and classes", - recommended: false, - url: "https://eslint.org/docs/latest/rules/accessor-pairs" - }, - - schema: [{ - type: "object", - properties: { - getWithoutSet: { - type: "boolean", - default: false - }, - setWithoutGet: { - type: "boolean", - default: true - }, - enforceForClassMembers: { - type: "boolean", - default: true - } - }, - additionalProperties: false - }], - - messages: { - missingGetterInPropertyDescriptor: "Getter is not present in property descriptor.", - missingSetterInPropertyDescriptor: "Setter is not present in property descriptor.", - missingGetterInObjectLiteral: "Getter is not present for {{ name }}.", - missingSetterInObjectLiteral: "Setter is not present for {{ name }}.", - missingGetterInClass: "Getter is not present for class {{ name }}.", - missingSetterInClass: "Setter is not present for class {{ name }}." - } - }, - create(context) { - const config = context.options[0] || {}; - const checkGetWithoutSet = config.getWithoutSet === true; - const checkSetWithoutGet = config.setWithoutGet !== false; - const enforceForClassMembers = config.enforceForClassMembers !== false; - const sourceCode = context.sourceCode; - - /** - * Reports the given node. - * @param {ASTNode} node The node to report. - * @param {string} messageKind "missingGetter" or "missingSetter". - * @returns {void} - * @private - */ - function report(node, messageKind) { - if (node.type === "Property") { - context.report({ - node, - messageId: `${messageKind}InObjectLiteral`, - loc: astUtils.getFunctionHeadLoc(node.value, sourceCode), - data: { name: astUtils.getFunctionNameWithKind(node.value) } - }); - } else if (node.type === "MethodDefinition") { - context.report({ - node, - messageId: `${messageKind}InClass`, - loc: astUtils.getFunctionHeadLoc(node.value, sourceCode), - data: { name: astUtils.getFunctionNameWithKind(node.value) } - }); - } else { - context.report({ - node, - messageId: `${messageKind}InPropertyDescriptor` - }); - } - } - - /** - * Reports each of the nodes in the given list using the same messageId. - * @param {ASTNode[]} nodes Nodes to report. - * @param {string} messageKind "missingGetter" or "missingSetter". - * @returns {void} - * @private - */ - function reportList(nodes, messageKind) { - for (const node of nodes) { - report(node, messageKind); - } - } - - /** - * Checks accessor pairs in the given list of nodes. - * @param {ASTNode[]} nodes The list to check. - * @returns {void} - * @private - */ - function checkList(nodes) { - const accessors = []; - let found = false; - - for (let i = 0; i < nodes.length; i++) { - const node = nodes[i]; - - if (isAccessorKind(node)) { - - // Creates a new `AccessorData` object for the given getter or setter node. - const name = astUtils.getStaticPropertyName(node); - const key = (name !== null) ? name : sourceCode.getTokens(node.key); - - // Merges the given `AccessorData` object into the given accessors list. - for (let j = 0; j < accessors.length; j++) { - const accessor = accessors[j]; - - if (areEqualKeys(accessor.key, key)) { - accessor.getters.push(...node.kind === "get" ? [node] : []); - accessor.setters.push(...node.kind === "set" ? [node] : []); - found = true; - break; - } - } - if (!found) { - accessors.push({ - key, - getters: node.kind === "get" ? [node] : [], - setters: node.kind === "set" ? [node] : [] - }); - } - found = false; - } - } - - for (const { getters, setters } of accessors) { - if (checkSetWithoutGet && setters.length && !getters.length) { - reportList(setters, "missingGetter"); - } - if (checkGetWithoutSet && getters.length && !setters.length) { - reportList(getters, "missingSetter"); - } - } - } - - /** - * Checks accessor pairs in an object literal. - * @param {ASTNode} node `ObjectExpression` node to check. - * @returns {void} - * @private - */ - function checkObjectLiteral(node) { - checkList(node.properties.filter(p => p.type === "Property")); - } - - /** - * Checks accessor pairs in a property descriptor. - * @param {ASTNode} node Property descriptor `ObjectExpression` node to check. - * @returns {void} - * @private - */ - function checkPropertyDescriptor(node) { - const namesToCheck = new Set(node.properties - .filter(p => p.type === "Property" && p.kind === "init" && !p.computed) - .map(({ key }) => key.name)); - - const hasGetter = namesToCheck.has("get"); - const hasSetter = namesToCheck.has("set"); - - if (checkSetWithoutGet && hasSetter && !hasGetter) { - report(node, "missingGetter"); - } - if (checkGetWithoutSet && hasGetter && !hasSetter) { - report(node, "missingSetter"); - } - } - - /** - * Checks the given object expression as an object literal and as a possible property descriptor. - * @param {ASTNode} node `ObjectExpression` node to check. - * @returns {void} - * @private - */ - function checkObjectExpression(node) { - checkObjectLiteral(node); - if (isPropertyDescriptor(node)) { - checkPropertyDescriptor(node); - } - } - - /** - * Checks the given class body. - * @param {ASTNode} node `ClassBody` node to check. - * @returns {void} - * @private - */ - function checkClassBody(node) { - const methodDefinitions = node.body.filter(m => m.type === "MethodDefinition"); - - checkList(methodDefinitions.filter(m => m.static)); - checkList(methodDefinitions.filter(m => !m.static)); - } - - const listeners = {}; - - if (checkSetWithoutGet || checkGetWithoutSet) { - listeners.ObjectExpression = checkObjectExpression; - if (enforceForClassMembers) { - listeners.ClassBody = checkClassBody; - } - } - - return listeners; - } -}; diff --git a/tools/eslint/node_modules/eslint/lib/rules/array-bracket-newline.js b/tools/eslint/node_modules/eslint/lib/rules/array-bracket-newline.js deleted file mode 100644 index 9eb725825a9a7d..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/rules/array-bracket-newline.js +++ /dev/null @@ -1,261 +0,0 @@ -/** - * @fileoverview Rule to enforce linebreaks after open and before close array brackets - * @author Jan Peer Stรถcklmair - * @deprecated in ESLint v8.53.0 - */ - -"use strict"; - -const astUtils = require("./utils/ast-utils"); - -//------------------------------------------------------------------------------ -// Rule Definition -//------------------------------------------------------------------------------ - -/** @type {import('../shared/types').Rule} */ -module.exports = { - meta: { - deprecated: true, - replacedBy: [], - type: "layout", - - docs: { - description: "Enforce linebreaks after opening and before closing array brackets", - recommended: false, - url: "https://eslint.org/docs/latest/rules/array-bracket-newline" - }, - - fixable: "whitespace", - - schema: [ - { - oneOf: [ - { - enum: ["always", "never", "consistent"] - }, - { - type: "object", - properties: { - multiline: { - type: "boolean" - }, - minItems: { - type: ["integer", "null"], - minimum: 0 - } - }, - additionalProperties: false - } - ] - } - ], - - messages: { - unexpectedOpeningLinebreak: "There should be no linebreak after '['.", - unexpectedClosingLinebreak: "There should be no linebreak before ']'.", - missingOpeningLinebreak: "A linebreak is required after '['.", - missingClosingLinebreak: "A linebreak is required before ']'." - } - }, - - create(context) { - const sourceCode = context.sourceCode; - - - //---------------------------------------------------------------------- - // Helpers - //---------------------------------------------------------------------- - - /** - * Normalizes a given option value. - * @param {string|Object|undefined} option An option value to parse. - * @returns {{multiline: boolean, minItems: number}} Normalized option object. - */ - function normalizeOptionValue(option) { - let consistent = false; - let multiline = false; - let minItems; - - if (option) { - if (option === "consistent") { - consistent = true; - minItems = Number.POSITIVE_INFINITY; - } else if (option === "always" || option.minItems === 0) { - minItems = 0; - } else if (option === "never") { - minItems = Number.POSITIVE_INFINITY; - } else { - multiline = Boolean(option.multiline); - minItems = option.minItems || Number.POSITIVE_INFINITY; - } - } else { - consistent = false; - multiline = true; - minItems = Number.POSITIVE_INFINITY; - } - - return { consistent, multiline, minItems }; - } - - /** - * Normalizes a given option value. - * @param {string|Object|undefined} options An option value to parse. - * @returns {{ArrayExpression: {multiline: boolean, minItems: number}, ArrayPattern: {multiline: boolean, minItems: number}}} Normalized option object. - */ - function normalizeOptions(options) { - const value = normalizeOptionValue(options); - - return { ArrayExpression: value, ArrayPattern: value }; - } - - /** - * Reports that there shouldn't be a linebreak after the first token - * @param {ASTNode} node The node to report in the event of an error. - * @param {Token} token The token to use for the report. - * @returns {void} - */ - function reportNoBeginningLinebreak(node, token) { - context.report({ - node, - loc: token.loc, - messageId: "unexpectedOpeningLinebreak", - fix(fixer) { - const nextToken = sourceCode.getTokenAfter(token, { includeComments: true }); - - if (astUtils.isCommentToken(nextToken)) { - return null; - } - - return fixer.removeRange([token.range[1], nextToken.range[0]]); - } - }); - } - - /** - * Reports that there shouldn't be a linebreak before the last token - * @param {ASTNode} node The node to report in the event of an error. - * @param {Token} token The token to use for the report. - * @returns {void} - */ - function reportNoEndingLinebreak(node, token) { - context.report({ - node, - loc: token.loc, - messageId: "unexpectedClosingLinebreak", - fix(fixer) { - const previousToken = sourceCode.getTokenBefore(token, { includeComments: true }); - - if (astUtils.isCommentToken(previousToken)) { - return null; - } - - return fixer.removeRange([previousToken.range[1], token.range[0]]); - } - }); - } - - /** - * Reports that there should be a linebreak after the first token - * @param {ASTNode} node The node to report in the event of an error. - * @param {Token} token The token to use for the report. - * @returns {void} - */ - function reportRequiredBeginningLinebreak(node, token) { - context.report({ - node, - loc: token.loc, - messageId: "missingOpeningLinebreak", - fix(fixer) { - return fixer.insertTextAfter(token, "\n"); - } - }); - } - - /** - * Reports that there should be a linebreak before the last token - * @param {ASTNode} node The node to report in the event of an error. - * @param {Token} token The token to use for the report. - * @returns {void} - */ - function reportRequiredEndingLinebreak(node, token) { - context.report({ - node, - loc: token.loc, - messageId: "missingClosingLinebreak", - fix(fixer) { - return fixer.insertTextBefore(token, "\n"); - } - }); - } - - /** - * Reports a given node if it violated this rule. - * @param {ASTNode} node A node to check. This is an ArrayExpression node or an ArrayPattern node. - * @returns {void} - */ - function check(node) { - const elements = node.elements; - const normalizedOptions = normalizeOptions(context.options[0]); - const options = normalizedOptions[node.type]; - const openBracket = sourceCode.getFirstToken(node); - const closeBracket = sourceCode.getLastToken(node); - const firstIncComment = sourceCode.getTokenAfter(openBracket, { includeComments: true }); - const lastIncComment = sourceCode.getTokenBefore(closeBracket, { includeComments: true }); - const first = sourceCode.getTokenAfter(openBracket); - const last = sourceCode.getTokenBefore(closeBracket); - - const needsLinebreaks = ( - elements.length >= options.minItems || - ( - options.multiline && - elements.length > 0 && - firstIncComment.loc.start.line !== lastIncComment.loc.end.line - ) || - ( - elements.length === 0 && - firstIncComment.type === "Block" && - firstIncComment.loc.start.line !== lastIncComment.loc.end.line && - firstIncComment === lastIncComment - ) || - ( - options.consistent && - openBracket.loc.end.line !== first.loc.start.line - ) - ); - - /* - * Use tokens or comments to check multiline or not. - * But use only tokens to check whether linebreaks are needed. - * This allows: - * var arr = [ // eslint-disable-line foo - * 'a' - * ] - */ - - if (needsLinebreaks) { - if (astUtils.isTokenOnSameLine(openBracket, first)) { - reportRequiredBeginningLinebreak(node, openBracket); - } - if (astUtils.isTokenOnSameLine(last, closeBracket)) { - reportRequiredEndingLinebreak(node, closeBracket); - } - } else { - if (!astUtils.isTokenOnSameLine(openBracket, first)) { - reportNoBeginningLinebreak(node, openBracket); - } - if (!astUtils.isTokenOnSameLine(last, closeBracket)) { - reportNoEndingLinebreak(node, closeBracket); - } - } - } - - //---------------------------------------------------------------------- - // Public - //---------------------------------------------------------------------- - - return { - ArrayPattern: check, - ArrayExpression: check - }; - } -}; diff --git a/tools/eslint/node_modules/eslint/lib/rules/array-bracket-spacing.js b/tools/eslint/node_modules/eslint/lib/rules/array-bracket-spacing.js deleted file mode 100644 index 31ace985a2058a..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/rules/array-bracket-spacing.js +++ /dev/null @@ -1,244 +0,0 @@ -/** - * @fileoverview Disallows or enforces spaces inside of array brackets. - * @author Jamund Ferguson - * @deprecated in ESLint v8.53.0 - */ -"use strict"; - -const astUtils = require("./utils/ast-utils"); - -//------------------------------------------------------------------------------ -// Rule Definition -//------------------------------------------------------------------------------ - -/** @type {import('../shared/types').Rule} */ -module.exports = { - meta: { - deprecated: true, - replacedBy: [], - type: "layout", - - docs: { - description: "Enforce consistent spacing inside array brackets", - recommended: false, - url: "https://eslint.org/docs/latest/rules/array-bracket-spacing" - }, - - fixable: "whitespace", - - schema: [ - { - enum: ["always", "never"] - }, - { - type: "object", - properties: { - singleValue: { - type: "boolean" - }, - objectsInArrays: { - type: "boolean" - }, - arraysInArrays: { - type: "boolean" - } - }, - additionalProperties: false - } - ], - - messages: { - unexpectedSpaceAfter: "There should be no space after '{{tokenValue}}'.", - unexpectedSpaceBefore: "There should be no space before '{{tokenValue}}'.", - missingSpaceAfter: "A space is required after '{{tokenValue}}'.", - missingSpaceBefore: "A space is required before '{{tokenValue}}'." - } - }, - create(context) { - const spaced = context.options[0] === "always", - sourceCode = context.sourceCode; - - /** - * Determines whether an option is set, relative to the spacing option. - * If spaced is "always", then check whether option is set to false. - * If spaced is "never", then check whether option is set to true. - * @param {Object} option The option to exclude. - * @returns {boolean} Whether or not the property is excluded. - */ - function isOptionSet(option) { - return context.options[1] ? context.options[1][option] === !spaced : false; - } - - const options = { - spaced, - singleElementException: isOptionSet("singleValue"), - objectsInArraysException: isOptionSet("objectsInArrays"), - arraysInArraysException: isOptionSet("arraysInArrays") - }; - - //-------------------------------------------------------------------------- - // Helpers - //-------------------------------------------------------------------------- - - /** - * Reports that there shouldn't be a space after the first token - * @param {ASTNode} node The node to report in the event of an error. - * @param {Token} token The token to use for the report. - * @returns {void} - */ - function reportNoBeginningSpace(node, token) { - const nextToken = sourceCode.getTokenAfter(token); - - context.report({ - node, - loc: { start: token.loc.end, end: nextToken.loc.start }, - messageId: "unexpectedSpaceAfter", - data: { - tokenValue: token.value - }, - fix(fixer) { - return fixer.removeRange([token.range[1], nextToken.range[0]]); - } - }); - } - - /** - * Reports that there shouldn't be a space before the last token - * @param {ASTNode} node The node to report in the event of an error. - * @param {Token} token The token to use for the report. - * @returns {void} - */ - function reportNoEndingSpace(node, token) { - const previousToken = sourceCode.getTokenBefore(token); - - context.report({ - node, - loc: { start: previousToken.loc.end, end: token.loc.start }, - messageId: "unexpectedSpaceBefore", - data: { - tokenValue: token.value - }, - fix(fixer) { - return fixer.removeRange([previousToken.range[1], token.range[0]]); - } - }); - } - - /** - * Reports that there should be a space after the first token - * @param {ASTNode} node The node to report in the event of an error. - * @param {Token} token The token to use for the report. - * @returns {void} - */ - function reportRequiredBeginningSpace(node, token) { - context.report({ - node, - loc: token.loc, - messageId: "missingSpaceAfter", - data: { - tokenValue: token.value - }, - fix(fixer) { - return fixer.insertTextAfter(token, " "); - } - }); - } - - /** - * Reports that there should be a space before the last token - * @param {ASTNode} node The node to report in the event of an error. - * @param {Token} token The token to use for the report. - * @returns {void} - */ - function reportRequiredEndingSpace(node, token) { - context.report({ - node, - loc: token.loc, - messageId: "missingSpaceBefore", - data: { - tokenValue: token.value - }, - fix(fixer) { - return fixer.insertTextBefore(token, " "); - } - }); - } - - /** - * Determines if a node is an object type - * @param {ASTNode} node The node to check. - * @returns {boolean} Whether or not the node is an object type. - */ - function isObjectType(node) { - return node && (node.type === "ObjectExpression" || node.type === "ObjectPattern"); - } - - /** - * Determines if a node is an array type - * @param {ASTNode} node The node to check. - * @returns {boolean} Whether or not the node is an array type. - */ - function isArrayType(node) { - return node && (node.type === "ArrayExpression" || node.type === "ArrayPattern"); - } - - /** - * Validates the spacing around array brackets - * @param {ASTNode} node The node we're checking for spacing - * @returns {void} - */ - function validateArraySpacing(node) { - if (options.spaced && node.elements.length === 0) { - return; - } - - const first = sourceCode.getFirstToken(node), - second = sourceCode.getFirstToken(node, 1), - last = node.typeAnnotation - ? sourceCode.getTokenBefore(node.typeAnnotation) - : sourceCode.getLastToken(node), - penultimate = sourceCode.getTokenBefore(last), - firstElement = node.elements[0], - lastElement = node.elements.at(-1); - - const openingBracketMustBeSpaced = - options.objectsInArraysException && isObjectType(firstElement) || - options.arraysInArraysException && isArrayType(firstElement) || - options.singleElementException && node.elements.length === 1 - ? !options.spaced : options.spaced; - - const closingBracketMustBeSpaced = - options.objectsInArraysException && isObjectType(lastElement) || - options.arraysInArraysException && isArrayType(lastElement) || - options.singleElementException && node.elements.length === 1 - ? !options.spaced : options.spaced; - - if (astUtils.isTokenOnSameLine(first, second)) { - if (openingBracketMustBeSpaced && !sourceCode.isSpaceBetweenTokens(first, second)) { - reportRequiredBeginningSpace(node, first); - } - if (!openingBracketMustBeSpaced && sourceCode.isSpaceBetweenTokens(first, second)) { - reportNoBeginningSpace(node, first); - } - } - - if (first !== penultimate && astUtils.isTokenOnSameLine(penultimate, last)) { - if (closingBracketMustBeSpaced && !sourceCode.isSpaceBetweenTokens(penultimate, last)) { - reportRequiredEndingSpace(node, last); - } - if (!closingBracketMustBeSpaced && sourceCode.isSpaceBetweenTokens(penultimate, last)) { - reportNoEndingSpace(node, last); - } - } - } - - //-------------------------------------------------------------------------- - // Public - //-------------------------------------------------------------------------- - - return { - ArrayPattern: validateArraySpacing, - ArrayExpression: validateArraySpacing - }; - } -}; diff --git a/tools/eslint/node_modules/eslint/lib/rules/array-callback-return.js b/tools/eslint/node_modules/eslint/lib/rules/array-callback-return.js deleted file mode 100644 index 6d8f258fa140f2..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/rules/array-callback-return.js +++ /dev/null @@ -1,446 +0,0 @@ -/** - * @fileoverview Rule to enforce return statements in callbacks of array's methods - * @author Toru Nagashima - */ - -"use strict"; - -//------------------------------------------------------------------------------ -// Requirements -//------------------------------------------------------------------------------ - -const astUtils = require("./utils/ast-utils"); - -//------------------------------------------------------------------------------ -// Helpers -//------------------------------------------------------------------------------ - -const TARGET_NODE_TYPE = /^(?:Arrow)?FunctionExpression$/u; -const TARGET_METHODS = /^(?:every|filter|find(?:Last)?(?:Index)?|flatMap|forEach|map|reduce(?:Right)?|some|sort|toSorted)$/u; - -/** - * Checks a given node is a member access which has the specified name's - * property. - * @param {ASTNode} node A node to check. - * @returns {boolean} `true` if the node is a member access which has - * the specified name's property. The node may be a `(Chain|Member)Expression` node. - */ -function isTargetMethod(node) { - return astUtils.isSpecificMemberAccess(node, null, TARGET_METHODS); -} - -/** - * Checks all segments in a set and returns true if any are reachable. - * @param {Set} segments The segments to check. - * @returns {boolean} True if any segment is reachable; false otherwise. - */ -function isAnySegmentReachable(segments) { - - for (const segment of segments) { - if (segment.reachable) { - return true; - } - } - - return false; -} - -/** - * Returns a human-legible description of an array method - * @param {string} arrayMethodName A method name to fully qualify - * @returns {string} the method name prefixed with `Array.` if it is a class method, - * or else `Array.prototype.` if it is an instance method. - */ -function fullMethodName(arrayMethodName) { - if (["from", "of", "isArray"].includes(arrayMethodName)) { - return "Array.".concat(arrayMethodName); - } - return "Array.prototype.".concat(arrayMethodName); -} - -/** - * Checks whether or not a given node is a function expression which is the - * callback of an array method, returning the method name. - * @param {ASTNode} node A node to check. This is one of - * FunctionExpression or ArrowFunctionExpression. - * @returns {string} The method name if the node is a callback method, - * null otherwise. - */ -function getArrayMethodName(node) { - let currentNode = node; - - while (currentNode) { - const parent = currentNode.parent; - - switch (parent.type) { - - /* - * Looks up the destination. e.g., - * foo.every(nativeFoo || function foo() { ... }); - */ - case "LogicalExpression": - case "ConditionalExpression": - case "ChainExpression": - currentNode = parent; - break; - - /* - * If the upper function is IIFE, checks the destination of the return value. - * e.g. - * foo.every((function() { - * // setup... - * return function callback() { ... }; - * })()); - */ - case "ReturnStatement": { - const func = astUtils.getUpperFunction(parent); - - if (func === null || !astUtils.isCallee(func)) { - return null; - } - currentNode = func.parent; - break; - } - - /* - * e.g. - * Array.from([], function() {}); - * list.every(function() {}); - */ - case "CallExpression": - if (astUtils.isArrayFromMethod(parent.callee)) { - if ( - parent.arguments.length >= 2 && - parent.arguments[1] === currentNode - ) { - return "from"; - } - } - if (isTargetMethod(parent.callee)) { - if ( - parent.arguments.length >= 1 && - parent.arguments[0] === currentNode - ) { - return astUtils.getStaticPropertyName(parent.callee); - } - } - return null; - - // Otherwise this node is not target. - default: - return null; - } - } - - /* c8 ignore next */ - return null; -} - -/** - * Checks if the given node is a void expression. - * @param {ASTNode} node The node to check. - * @returns {boolean} - `true` if the node is a void expression - */ -function isExpressionVoid(node) { - return node.type === "UnaryExpression" && node.operator === "void"; -} - -/** - * Fixes the linting error by prepending "void " to the given node - * @param {Object} sourceCode context given by context.sourceCode - * @param {ASTNode} node The node to fix. - * @param {Object} fixer The fixer object provided by ESLint. - * @returns {Array} - An array of fix objects to apply to the node. - */ -function voidPrependFixer(sourceCode, node, fixer) { - - const requiresParens = - - // prepending `void ` will fail if the node has a lower precedence than void - astUtils.getPrecedence(node) < astUtils.getPrecedence({ type: "UnaryExpression", operator: "void" }) && - - // check if there are parentheses around the node to avoid redundant parentheses - !astUtils.isParenthesised(sourceCode, node); - - // avoid parentheses issues - const returnOrArrowToken = sourceCode.getTokenBefore( - node, - node.parent.type === "ArrowFunctionExpression" - ? astUtils.isArrowToken - - // isReturnToken - : token => token.type === "Keyword" && token.value === "return" - ); - - const firstToken = sourceCode.getTokenAfter(returnOrArrowToken); - - const prependSpace = - - // is return token, as => allows void to be adjacent - returnOrArrowToken.value === "return" && - - // If two tokens (return and "(") are adjacent - returnOrArrowToken.range[1] === firstToken.range[0]; - - return [ - fixer.insertTextBefore(firstToken, `${prependSpace ? " " : ""}void ${requiresParens ? "(" : ""}`), - fixer.insertTextAfter(node, requiresParens ? ")" : "") - ]; -} - -/** - * Fixes the linting error by `wrapping {}` around the given node's body. - * @param {Object} sourceCode context given by context.sourceCode - * @param {ASTNode} node The node to fix. - * @param {Object} fixer The fixer object provided by ESLint. - * @returns {Array} - An array of fix objects to apply to the node. - */ -function curlyWrapFixer(sourceCode, node, fixer) { - const arrowToken = sourceCode.getTokenBefore(node.body, astUtils.isArrowToken); - const firstToken = sourceCode.getTokenAfter(arrowToken); - const lastToken = sourceCode.getLastToken(node); - - return [ - fixer.insertTextBefore(firstToken, "{"), - fixer.insertTextAfter(lastToken, "}") - ]; -} - -//------------------------------------------------------------------------------ -// Rule Definition -//------------------------------------------------------------------------------ - -/** @type {import('../shared/types').Rule} */ -module.exports = { - meta: { - type: "problem", - - docs: { - description: "Enforce `return` statements in callbacks of array methods", - recommended: false, - url: "https://eslint.org/docs/latest/rules/array-callback-return" - }, - - // eslint-disable-next-line eslint-plugin/require-meta-has-suggestions -- false positive - hasSuggestions: true, - - schema: [ - { - type: "object", - properties: { - allowImplicit: { - type: "boolean", - default: false - }, - checkForEach: { - type: "boolean", - default: false - }, - allowVoid: { - type: "boolean", - default: false - } - }, - additionalProperties: false - } - ], - - messages: { - expectedAtEnd: "{{arrayMethodName}}() expects a value to be returned at the end of {{name}}.", - expectedInside: "{{arrayMethodName}}() expects a return value from {{name}}.", - expectedReturnValue: "{{arrayMethodName}}() expects a return value from {{name}}.", - expectedNoReturnValue: "{{arrayMethodName}}() expects no useless return value from {{name}}.", - wrapBraces: "Wrap the expression in `{}`.", - prependVoid: "Prepend `void` to the expression." - } - }, - - create(context) { - - const options = context.options[0] || { allowImplicit: false, checkForEach: false, allowVoid: false }; - const sourceCode = context.sourceCode; - - let funcInfo = { - arrayMethodName: null, - upper: null, - codePath: null, - hasReturn: false, - shouldCheck: false, - node: null - }; - - /** - * Checks whether or not the last code path segment is reachable. - * Then reports this function if the segment is reachable. - * - * If the last code path segment is reachable, there are paths which are not - * returned or thrown. - * @param {ASTNode} node A node to check. - * @returns {void} - */ - function checkLastSegment(node) { - - if (!funcInfo.shouldCheck) { - return; - } - - const messageAndSuggestions = { messageId: "", suggest: [] }; - - if (funcInfo.arrayMethodName === "forEach") { - if (options.checkForEach && node.type === "ArrowFunctionExpression" && node.expression) { - - if (options.allowVoid) { - if (isExpressionVoid(node.body)) { - return; - } - - messageAndSuggestions.messageId = "expectedNoReturnValue"; - messageAndSuggestions.suggest = [ - { - messageId: "wrapBraces", - fix(fixer) { - return curlyWrapFixer(sourceCode, node, fixer); - } - }, - { - messageId: "prependVoid", - fix(fixer) { - return voidPrependFixer(sourceCode, node.body, fixer); - } - } - ]; - } else { - messageAndSuggestions.messageId = "expectedNoReturnValue"; - messageAndSuggestions.suggest = [{ - messageId: "wrapBraces", - fix(fixer) { - return curlyWrapFixer(sourceCode, node, fixer); - } - }]; - } - } - } else { - if (node.body.type === "BlockStatement" && isAnySegmentReachable(funcInfo.currentSegments)) { - messageAndSuggestions.messageId = funcInfo.hasReturn ? "expectedAtEnd" : "expectedInside"; - } - } - - if (messageAndSuggestions.messageId) { - const name = astUtils.getFunctionNameWithKind(node); - - context.report({ - node, - loc: astUtils.getFunctionHeadLoc(node, sourceCode), - messageId: messageAndSuggestions.messageId, - data: { name, arrayMethodName: fullMethodName(funcInfo.arrayMethodName) }, - suggest: messageAndSuggestions.suggest.length !== 0 ? messageAndSuggestions.suggest : null - }); - } - } - - return { - - // Stacks this function's information. - onCodePathStart(codePath, node) { - - let methodName = null; - - if (TARGET_NODE_TYPE.test(node.type)) { - methodName = getArrayMethodName(node); - } - - funcInfo = { - arrayMethodName: methodName, - upper: funcInfo, - codePath, - hasReturn: false, - shouldCheck: - methodName && - !node.async && - !node.generator, - node, - currentSegments: new Set() - }; - }, - - // Pops this function's information. - onCodePathEnd() { - funcInfo = funcInfo.upper; - }, - - onUnreachableCodePathSegmentStart(segment) { - funcInfo.currentSegments.add(segment); - }, - - onUnreachableCodePathSegmentEnd(segment) { - funcInfo.currentSegments.delete(segment); - }, - - onCodePathSegmentStart(segment) { - funcInfo.currentSegments.add(segment); - }, - - onCodePathSegmentEnd(segment) { - funcInfo.currentSegments.delete(segment); - }, - - - // Checks the return statement is valid. - ReturnStatement(node) { - - if (!funcInfo.shouldCheck) { - return; - } - - funcInfo.hasReturn = true; - - const messageAndSuggestions = { messageId: "", suggest: [] }; - - if (funcInfo.arrayMethodName === "forEach") { - - // if checkForEach: true, returning a value at any path inside a forEach is not allowed - if (options.checkForEach && node.argument) { - - if (options.allowVoid) { - if (isExpressionVoid(node.argument)) { - return; - } - - messageAndSuggestions.messageId = "expectedNoReturnValue"; - messageAndSuggestions.suggest = [{ - messageId: "prependVoid", - fix(fixer) { - return voidPrependFixer(sourceCode, node.argument, fixer); - } - }]; - } else { - messageAndSuggestions.messageId = "expectedNoReturnValue"; - } - } - } else { - - // if allowImplicit: false, should also check node.argument - if (!options.allowImplicit && !node.argument) { - messageAndSuggestions.messageId = "expectedReturnValue"; - } - } - - if (messageAndSuggestions.messageId) { - context.report({ - node, - messageId: messageAndSuggestions.messageId, - data: { - name: astUtils.getFunctionNameWithKind(funcInfo.node), - arrayMethodName: fullMethodName(funcInfo.arrayMethodName) - }, - suggest: messageAndSuggestions.suggest.length !== 0 ? messageAndSuggestions.suggest : null - }); - } - }, - - // Reports a given function if the last path is reachable. - "FunctionExpression:exit": checkLastSegment, - "ArrowFunctionExpression:exit": checkLastSegment - }; - } -}; diff --git a/tools/eslint/node_modules/eslint/lib/rules/array-element-newline.js b/tools/eslint/node_modules/eslint/lib/rules/array-element-newline.js deleted file mode 100644 index 504fe04a0b85b1..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/rules/array-element-newline.js +++ /dev/null @@ -1,311 +0,0 @@ -/** - * @fileoverview Rule to enforce line breaks after each array element - * @author Jan Peer Stรถcklmair - * @deprecated in ESLint v8.53.0 - */ - -"use strict"; - -const astUtils = require("./utils/ast-utils"); - -//------------------------------------------------------------------------------ -// Rule Definition -//------------------------------------------------------------------------------ - -/** @type {import('../shared/types').Rule} */ -module.exports = { - meta: { - deprecated: true, - replacedBy: [], - type: "layout", - - docs: { - description: "Enforce line breaks after each array element", - recommended: false, - url: "https://eslint.org/docs/latest/rules/array-element-newline" - }, - - fixable: "whitespace", - - schema: { - definitions: { - basicConfig: { - oneOf: [ - { - enum: ["always", "never", "consistent"] - }, - { - type: "object", - properties: { - multiline: { - type: "boolean" - }, - minItems: { - type: ["integer", "null"], - minimum: 0 - } - }, - additionalProperties: false - } - ] - } - }, - type: "array", - items: [ - { - oneOf: [ - { - $ref: "#/definitions/basicConfig" - }, - { - type: "object", - properties: { - ArrayExpression: { - $ref: "#/definitions/basicConfig" - }, - ArrayPattern: { - $ref: "#/definitions/basicConfig" - } - }, - additionalProperties: false, - minProperties: 1 - } - ] - } - ] - }, - - messages: { - unexpectedLineBreak: "There should be no linebreak here.", - missingLineBreak: "There should be a linebreak after this element." - } - }, - - create(context) { - const sourceCode = context.sourceCode; - - //---------------------------------------------------------------------- - // Helpers - //---------------------------------------------------------------------- - - /** - * Normalizes a given option value. - * @param {string|Object|undefined} providedOption An option value to parse. - * @returns {{multiline: boolean, minItems: number}} Normalized option object. - */ - function normalizeOptionValue(providedOption) { - let consistent = false; - let multiline = false; - let minItems; - - const option = providedOption || "always"; - - if (!option || option === "always" || option.minItems === 0) { - minItems = 0; - } else if (option === "never") { - minItems = Number.POSITIVE_INFINITY; - } else if (option === "consistent") { - consistent = true; - minItems = Number.POSITIVE_INFINITY; - } else { - multiline = Boolean(option.multiline); - minItems = option.minItems || Number.POSITIVE_INFINITY; - } - - return { consistent, multiline, minItems }; - } - - /** - * Normalizes a given option value. - * @param {string|Object|undefined} options An option value to parse. - * @returns {{ArrayExpression: {multiline: boolean, minItems: number}, ArrayPattern: {multiline: boolean, minItems: number}}} Normalized option object. - */ - function normalizeOptions(options) { - if (options && (options.ArrayExpression || options.ArrayPattern)) { - let expressionOptions, patternOptions; - - if (options.ArrayExpression) { - expressionOptions = normalizeOptionValue(options.ArrayExpression); - } - - if (options.ArrayPattern) { - patternOptions = normalizeOptionValue(options.ArrayPattern); - } - - return { ArrayExpression: expressionOptions, ArrayPattern: patternOptions }; - } - - const value = normalizeOptionValue(options); - - return { ArrayExpression: value, ArrayPattern: value }; - } - - /** - * Reports that there shouldn't be a line break after the first token - * @param {Token} token The token to use for the report. - * @returns {void} - */ - function reportNoLineBreak(token) { - const tokenBefore = sourceCode.getTokenBefore(token, { includeComments: true }); - - context.report({ - loc: { - start: tokenBefore.loc.end, - end: token.loc.start - }, - messageId: "unexpectedLineBreak", - fix(fixer) { - if (astUtils.isCommentToken(tokenBefore)) { - return null; - } - - if (!astUtils.isTokenOnSameLine(tokenBefore, token)) { - return fixer.replaceTextRange([tokenBefore.range[1], token.range[0]], " "); - } - - /* - * This will check if the comma is on the same line as the next element - * Following array: - * [ - * 1 - * , 2 - * , 3 - * ] - * - * will be fixed to: - * [ - * 1, 2, 3 - * ] - */ - const twoTokensBefore = sourceCode.getTokenBefore(tokenBefore, { includeComments: true }); - - if (astUtils.isCommentToken(twoTokensBefore)) { - return null; - } - - return fixer.replaceTextRange([twoTokensBefore.range[1], tokenBefore.range[0]], ""); - - } - }); - } - - /** - * Reports that there should be a line break after the first token - * @param {Token} token The token to use for the report. - * @returns {void} - */ - function reportRequiredLineBreak(token) { - const tokenBefore = sourceCode.getTokenBefore(token, { includeComments: true }); - - context.report({ - loc: { - start: tokenBefore.loc.end, - end: token.loc.start - }, - messageId: "missingLineBreak", - fix(fixer) { - return fixer.replaceTextRange([tokenBefore.range[1], token.range[0]], "\n"); - } - }); - } - - /** - * Reports a given node if it violated this rule. - * @param {ASTNode} node A node to check. This is an ObjectExpression node or an ObjectPattern node. - * @returns {void} - */ - function check(node) { - const elements = node.elements; - const normalizedOptions = normalizeOptions(context.options[0]); - const options = normalizedOptions[node.type]; - - if (!options) { - return; - } - - let elementBreak = false; - - /* - * MULTILINE: true - * loop through every element and check - * if at least one element has linebreaks inside - * this ensures that following is not valid (due to elements are on the same line): - * - * [ - * 1, - * 2, - * 3 - * ] - */ - if (options.multiline) { - elementBreak = elements - .filter(element => element !== null) - .some(element => element.loc.start.line !== element.loc.end.line); - } - - let linebreaksCount = 0; - - for (let i = 0; i < node.elements.length; i++) { - const element = node.elements[i]; - - const previousElement = elements[i - 1]; - - if (i === 0 || element === null || previousElement === null) { - continue; - } - - const commaToken = sourceCode.getFirstTokenBetween(previousElement, element, astUtils.isCommaToken); - const lastTokenOfPreviousElement = sourceCode.getTokenBefore(commaToken); - const firstTokenOfCurrentElement = sourceCode.getTokenAfter(commaToken); - - if (!astUtils.isTokenOnSameLine(lastTokenOfPreviousElement, firstTokenOfCurrentElement)) { - linebreaksCount++; - } - } - - const needsLinebreaks = ( - elements.length >= options.minItems || - ( - options.multiline && - elementBreak - ) || - ( - options.consistent && - linebreaksCount > 0 && - linebreaksCount < node.elements.length - ) - ); - - elements.forEach((element, i) => { - const previousElement = elements[i - 1]; - - if (i === 0 || element === null || previousElement === null) { - return; - } - - const commaToken = sourceCode.getFirstTokenBetween(previousElement, element, astUtils.isCommaToken); - const lastTokenOfPreviousElement = sourceCode.getTokenBefore(commaToken); - const firstTokenOfCurrentElement = sourceCode.getTokenAfter(commaToken); - - if (needsLinebreaks) { - if (astUtils.isTokenOnSameLine(lastTokenOfPreviousElement, firstTokenOfCurrentElement)) { - reportRequiredLineBreak(firstTokenOfCurrentElement); - } - } else { - if (!astUtils.isTokenOnSameLine(lastTokenOfPreviousElement, firstTokenOfCurrentElement)) { - reportNoLineBreak(firstTokenOfCurrentElement); - } - } - }); - } - - //---------------------------------------------------------------------- - // Public - //---------------------------------------------------------------------- - - return { - ArrayPattern: check, - ArrayExpression: check - }; - } -}; diff --git a/tools/eslint/node_modules/eslint/lib/rules/arrow-body-style.js b/tools/eslint/node_modules/eslint/lib/rules/arrow-body-style.js deleted file mode 100644 index 759070454c4a05..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/rules/arrow-body-style.js +++ /dev/null @@ -1,296 +0,0 @@ -/** - * @fileoverview Rule to require braces in arrow function body. - * @author Alberto Rodrรญguez - */ -"use strict"; - -//------------------------------------------------------------------------------ -// Requirements -//------------------------------------------------------------------------------ - -const astUtils = require("./utils/ast-utils"); - -//------------------------------------------------------------------------------ -// Rule Definition -//------------------------------------------------------------------------------ - -/** @type {import('../shared/types').Rule} */ -module.exports = { - meta: { - type: "suggestion", - - docs: { - description: "Require braces around arrow function bodies", - recommended: false, - url: "https://eslint.org/docs/latest/rules/arrow-body-style" - }, - - schema: { - anyOf: [ - { - type: "array", - items: [ - { - enum: ["always", "never"] - } - ], - minItems: 0, - maxItems: 1 - }, - { - type: "array", - items: [ - { - enum: ["as-needed"] - }, - { - type: "object", - properties: { - requireReturnForObjectLiteral: { type: "boolean" } - }, - additionalProperties: false - } - ], - minItems: 0, - maxItems: 2 - } - ] - }, - - fixable: "code", - - messages: { - unexpectedOtherBlock: "Unexpected block statement surrounding arrow body.", - unexpectedEmptyBlock: "Unexpected block statement surrounding arrow body; put a value of `undefined` immediately after the `=>`.", - unexpectedObjectBlock: "Unexpected block statement surrounding arrow body; parenthesize the returned value and move it immediately after the `=>`.", - unexpectedSingleBlock: "Unexpected block statement surrounding arrow body; move the returned value immediately after the `=>`.", - expectedBlock: "Expected block statement surrounding arrow body." - } - }, - - create(context) { - const options = context.options; - const always = options[0] === "always"; - const asNeeded = !options[0] || options[0] === "as-needed"; - const never = options[0] === "never"; - const requireReturnForObjectLiteral = options[1] && options[1].requireReturnForObjectLiteral; - const sourceCode = context.sourceCode; - let funcInfo = null; - - /** - * Checks whether the given node has ASI problem or not. - * @param {Token} token The token to check. - * @returns {boolean} `true` if it changes semantics if `;` or `}` followed by the token are removed. - */ - function hasASIProblem(token) { - return token && token.type === "Punctuator" && /^[([/`+-]/u.test(token.value); - } - - /** - * Gets the closing parenthesis by the given node. - * @param {ASTNode} node first node after an opening parenthesis. - * @returns {Token} The found closing parenthesis token. - */ - function findClosingParen(node) { - let nodeToCheck = node; - - while (!astUtils.isParenthesised(sourceCode, nodeToCheck)) { - nodeToCheck = nodeToCheck.parent; - } - return sourceCode.getTokenAfter(nodeToCheck); - } - - /** - * Check whether the node is inside of a for loop's init - * @param {ASTNode} node node is inside for loop - * @returns {boolean} `true` if the node is inside of a for loop, else `false` - */ - function isInsideForLoopInitializer(node) { - if (node && node.parent) { - if (node.parent.type === "ForStatement" && node.parent.init === node) { - return true; - } - return isInsideForLoopInitializer(node.parent); - } - return false; - } - - /** - * Determines whether a arrow function body needs braces - * @param {ASTNode} node The arrow function node. - * @returns {void} - */ - function validate(node) { - const arrowBody = node.body; - - if (arrowBody.type === "BlockStatement") { - const blockBody = arrowBody.body; - - if (blockBody.length !== 1 && !never) { - return; - } - - if (asNeeded && requireReturnForObjectLiteral && blockBody[0].type === "ReturnStatement" && - blockBody[0].argument && blockBody[0].argument.type === "ObjectExpression") { - return; - } - - if (never || asNeeded && blockBody[0].type === "ReturnStatement") { - let messageId; - - if (blockBody.length === 0) { - messageId = "unexpectedEmptyBlock"; - } else if (blockBody.length > 1) { - messageId = "unexpectedOtherBlock"; - } else if (blockBody[0].argument === null) { - messageId = "unexpectedSingleBlock"; - } else if (astUtils.isOpeningBraceToken(sourceCode.getFirstToken(blockBody[0], { skip: 1 }))) { - messageId = "unexpectedObjectBlock"; - } else { - messageId = "unexpectedSingleBlock"; - } - - context.report({ - node, - loc: arrowBody.loc, - messageId, - fix(fixer) { - const fixes = []; - - if (blockBody.length !== 1 || - blockBody[0].type !== "ReturnStatement" || - !blockBody[0].argument || - hasASIProblem(sourceCode.getTokenAfter(arrowBody)) - ) { - return fixes; - } - - const openingBrace = sourceCode.getFirstToken(arrowBody); - const closingBrace = sourceCode.getLastToken(arrowBody); - const firstValueToken = sourceCode.getFirstToken(blockBody[0], 1); - const lastValueToken = sourceCode.getLastToken(blockBody[0]); - const commentsExist = - sourceCode.commentsExistBetween(openingBrace, firstValueToken) || - sourceCode.commentsExistBetween(lastValueToken, closingBrace); - - /* - * Remove tokens around the return value. - * If comments don't exist, remove extra spaces as well. - */ - if (commentsExist) { - fixes.push( - fixer.remove(openingBrace), - fixer.remove(closingBrace), - fixer.remove(sourceCode.getTokenAfter(openingBrace)) // return keyword - ); - } else { - fixes.push( - fixer.removeRange([openingBrace.range[0], firstValueToken.range[0]]), - fixer.removeRange([lastValueToken.range[1], closingBrace.range[1]]) - ); - } - - /* - * If the first token of the return value is `{` or the return value is a sequence expression, - * enclose the return value by parentheses to avoid syntax error. - */ - if (astUtils.isOpeningBraceToken(firstValueToken) || blockBody[0].argument.type === "SequenceExpression" || (funcInfo.hasInOperator && isInsideForLoopInitializer(node))) { - if (!astUtils.isParenthesised(sourceCode, blockBody[0].argument)) { - fixes.push( - fixer.insertTextBefore(firstValueToken, "("), - fixer.insertTextAfter(lastValueToken, ")") - ); - } - } - - /* - * If the last token of the return statement is semicolon, remove it. - * Non-block arrow body is an expression, not a statement. - */ - if (astUtils.isSemicolonToken(lastValueToken)) { - fixes.push(fixer.remove(lastValueToken)); - } - - return fixes; - } - }); - } - } else { - if (always || (asNeeded && requireReturnForObjectLiteral && arrowBody.type === "ObjectExpression")) { - context.report({ - node, - loc: arrowBody.loc, - messageId: "expectedBlock", - fix(fixer) { - const fixes = []; - const arrowToken = sourceCode.getTokenBefore(arrowBody, astUtils.isArrowToken); - const [firstTokenAfterArrow, secondTokenAfterArrow] = sourceCode.getTokensAfter(arrowToken, { count: 2 }); - const lastToken = sourceCode.getLastToken(node); - - let parenthesisedObjectLiteral = null; - - if ( - astUtils.isOpeningParenToken(firstTokenAfterArrow) && - astUtils.isOpeningBraceToken(secondTokenAfterArrow) - ) { - const braceNode = sourceCode.getNodeByRangeIndex(secondTokenAfterArrow.range[0]); - - if (braceNode.type === "ObjectExpression") { - parenthesisedObjectLiteral = braceNode; - } - } - - // If the value is object literal, remove parentheses which were forced by syntax. - if (parenthesisedObjectLiteral) { - const openingParenToken = firstTokenAfterArrow; - const openingBraceToken = secondTokenAfterArrow; - - if (astUtils.isTokenOnSameLine(openingParenToken, openingBraceToken)) { - fixes.push(fixer.replaceText(openingParenToken, "{return ")); - } else { - - // Avoid ASI - fixes.push( - fixer.replaceText(openingParenToken, "{"), - fixer.insertTextBefore(openingBraceToken, "return ") - ); - } - - // Closing paren for the object doesn't have to be lastToken, e.g.: () => ({}).foo() - fixes.push(fixer.remove(findClosingParen(parenthesisedObjectLiteral))); - fixes.push(fixer.insertTextAfter(lastToken, "}")); - - } else { - fixes.push(fixer.insertTextBefore(firstTokenAfterArrow, "{return ")); - fixes.push(fixer.insertTextAfter(lastToken, "}")); - } - - return fixes; - } - }); - } - } - } - - return { - "BinaryExpression[operator='in']"() { - let info = funcInfo; - - while (info) { - info.hasInOperator = true; - info = info.upper; - } - }, - ArrowFunctionExpression() { - funcInfo = { - upper: funcInfo, - hasInOperator: false - }; - }, - "ArrowFunctionExpression:exit"(node) { - validate(node); - funcInfo = funcInfo.upper; - } - }; - } -}; diff --git a/tools/eslint/node_modules/eslint/lib/rules/arrow-parens.js b/tools/eslint/node_modules/eslint/lib/rules/arrow-parens.js deleted file mode 100644 index 2206d8ce2bfd3e..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/rules/arrow-parens.js +++ /dev/null @@ -1,186 +0,0 @@ -/** - * @fileoverview Rule to require parens in arrow function arguments. - * @author Jxck - * @deprecated in ESLint v8.53.0 - */ -"use strict"; - -//------------------------------------------------------------------------------ -// Requirements -//------------------------------------------------------------------------------ - -const astUtils = require("./utils/ast-utils"); - -//------------------------------------------------------------------------------ -// Helpers -//------------------------------------------------------------------------------ - -/** - * Determines if the given arrow function has block body. - * @param {ASTNode} node `ArrowFunctionExpression` node. - * @returns {boolean} `true` if the function has block body. - */ -function hasBlockBody(node) { - return node.body.type === "BlockStatement"; -} - -//------------------------------------------------------------------------------ -// Rule Definition -//------------------------------------------------------------------------------ - -/** @type {import('../shared/types').Rule} */ -module.exports = { - meta: { - deprecated: true, - replacedBy: [], - type: "layout", - - docs: { - description: "Require parentheses around arrow function arguments", - recommended: false, - url: "https://eslint.org/docs/latest/rules/arrow-parens" - }, - - fixable: "code", - - schema: [ - { - enum: ["always", "as-needed"] - }, - { - type: "object", - properties: { - requireForBlockBody: { - type: "boolean", - default: false - } - }, - additionalProperties: false - } - ], - - messages: { - unexpectedParens: "Unexpected parentheses around single function argument.", - expectedParens: "Expected parentheses around arrow function argument.", - - unexpectedParensInline: "Unexpected parentheses around single function argument having a body with no curly braces.", - expectedParensBlock: "Expected parentheses around arrow function argument having a body with curly braces." - } - }, - - create(context) { - const asNeeded = context.options[0] === "as-needed"; - const requireForBlockBody = asNeeded && context.options[1] && context.options[1].requireForBlockBody === true; - - const sourceCode = context.sourceCode; - - /** - * Finds opening paren of parameters for the given arrow function, if it exists. - * It is assumed that the given arrow function has exactly one parameter. - * @param {ASTNode} node `ArrowFunctionExpression` node. - * @returns {Token|null} the opening paren, or `null` if the given arrow function doesn't have parens of parameters. - */ - function findOpeningParenOfParams(node) { - const tokenBeforeParams = sourceCode.getTokenBefore(node.params[0]); - - if ( - tokenBeforeParams && - astUtils.isOpeningParenToken(tokenBeforeParams) && - node.range[0] <= tokenBeforeParams.range[0] - ) { - return tokenBeforeParams; - } - - return null; - } - - /** - * Finds closing paren of parameters for the given arrow function. - * It is assumed that the given arrow function has parens of parameters and that it has exactly one parameter. - * @param {ASTNode} node `ArrowFunctionExpression` node. - * @returns {Token} the closing paren of parameters. - */ - function getClosingParenOfParams(node) { - return sourceCode.getTokenAfter(node.params[0], astUtils.isClosingParenToken); - } - - /** - * Determines whether the given arrow function has comments inside parens of parameters. - * It is assumed that the given arrow function has parens of parameters. - * @param {ASTNode} node `ArrowFunctionExpression` node. - * @param {Token} openingParen Opening paren of parameters. - * @returns {boolean} `true` if the function has at least one comment inside of parens of parameters. - */ - function hasCommentsInParensOfParams(node, openingParen) { - return sourceCode.commentsExistBetween(openingParen, getClosingParenOfParams(node)); - } - - /** - * Determines whether the given arrow function has unexpected tokens before opening paren of parameters, - * in which case it will be assumed that the existing parens of parameters are necessary. - * Only tokens within the range of the arrow function (tokens that are part of the arrow function) are taken into account. - * Example: (a) => b - * @param {ASTNode} node `ArrowFunctionExpression` node. - * @param {Token} openingParen Opening paren of parameters. - * @returns {boolean} `true` if the function has at least one unexpected token. - */ - function hasUnexpectedTokensBeforeOpeningParen(node, openingParen) { - const expectedCount = node.async ? 1 : 0; - - return sourceCode.getFirstToken(node, { skip: expectedCount }) !== openingParen; - } - - return { - "ArrowFunctionExpression[params.length=1]"(node) { - const shouldHaveParens = !asNeeded || requireForBlockBody && hasBlockBody(node); - const openingParen = findOpeningParenOfParams(node); - const hasParens = openingParen !== null; - const [param] = node.params; - - if (shouldHaveParens && !hasParens) { - context.report({ - node, - messageId: requireForBlockBody ? "expectedParensBlock" : "expectedParens", - loc: param.loc, - *fix(fixer) { - yield fixer.insertTextBefore(param, "("); - yield fixer.insertTextAfter(param, ")"); - } - }); - } - - if ( - !shouldHaveParens && - hasParens && - param.type === "Identifier" && - !param.typeAnnotation && - !node.returnType && - !hasCommentsInParensOfParams(node, openingParen) && - !hasUnexpectedTokensBeforeOpeningParen(node, openingParen) - ) { - context.report({ - node, - messageId: requireForBlockBody ? "unexpectedParensInline" : "unexpectedParens", - loc: param.loc, - *fix(fixer) { - const tokenBeforeOpeningParen = sourceCode.getTokenBefore(openingParen); - const closingParen = getClosingParenOfParams(node); - - if ( - tokenBeforeOpeningParen && - tokenBeforeOpeningParen.range[1] === openingParen.range[0] && - !astUtils.canTokensBeAdjacent(tokenBeforeOpeningParen, sourceCode.getFirstToken(param)) - ) { - yield fixer.insertTextBefore(openingParen, " "); - } - - // remove parens, whitespace inside parens, and possible trailing comma - yield fixer.removeRange([openingParen.range[0], param.range[0]]); - yield fixer.removeRange([param.range[1], closingParen.range[1]]); - } - }); - } - } - }; - } -}; diff --git a/tools/eslint/node_modules/eslint/lib/rules/arrow-spacing.js b/tools/eslint/node_modules/eslint/lib/rules/arrow-spacing.js deleted file mode 100644 index 2b7d464ffcf969..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/rules/arrow-spacing.js +++ /dev/null @@ -1,164 +0,0 @@ -/** - * @fileoverview Rule to define spacing before/after arrow function's arrow. - * @author Jxck - * @deprecated in ESLint v8.53.0 - */ -"use strict"; - -//------------------------------------------------------------------------------ -// Requirements -//------------------------------------------------------------------------------ - -const astUtils = require("./utils/ast-utils"); - -//------------------------------------------------------------------------------ -// Rule Definition -//------------------------------------------------------------------------------ - -/** @type {import('../shared/types').Rule} */ -module.exports = { - meta: { - deprecated: true, - replacedBy: [], - type: "layout", - - docs: { - description: "Enforce consistent spacing before and after the arrow in arrow functions", - recommended: false, - url: "https://eslint.org/docs/latest/rules/arrow-spacing" - }, - - fixable: "whitespace", - - schema: [ - { - type: "object", - properties: { - before: { - type: "boolean", - default: true - }, - after: { - type: "boolean", - default: true - } - }, - additionalProperties: false - } - ], - - messages: { - expectedBefore: "Missing space before =>.", - unexpectedBefore: "Unexpected space before =>.", - - expectedAfter: "Missing space after =>.", - unexpectedAfter: "Unexpected space after =>." - } - }, - - create(context) { - - // merge rules with default - const rule = Object.assign({}, context.options[0]); - - rule.before = rule.before !== false; - rule.after = rule.after !== false; - - const sourceCode = context.sourceCode; - - /** - * Get tokens of arrow(`=>`) and before/after arrow. - * @param {ASTNode} node The arrow function node. - * @returns {Object} Tokens of arrow and before/after arrow. - */ - function getTokens(node) { - const arrow = sourceCode.getTokenBefore(node.body, astUtils.isArrowToken); - - return { - before: sourceCode.getTokenBefore(arrow), - arrow, - after: sourceCode.getTokenAfter(arrow) - }; - } - - /** - * Count spaces before/after arrow(`=>`) token. - * @param {Object} tokens Tokens before/after arrow. - * @returns {Object} count of space before/after arrow. - */ - function countSpaces(tokens) { - const before = tokens.arrow.range[0] - tokens.before.range[1]; - const after = tokens.after.range[0] - tokens.arrow.range[1]; - - return { before, after }; - } - - /** - * Determines whether space(s) before after arrow(`=>`) is satisfy rule. - * if before/after value is `true`, there should be space(s). - * if before/after value is `false`, there should be no space. - * @param {ASTNode} node The arrow function node. - * @returns {void} - */ - function spaces(node) { - const tokens = getTokens(node); - const countSpace = countSpaces(tokens); - - if (rule.before) { - - // should be space(s) before arrow - if (countSpace.before === 0) { - context.report({ - node: tokens.before, - messageId: "expectedBefore", - fix(fixer) { - return fixer.insertTextBefore(tokens.arrow, " "); - } - }); - } - } else { - - // should be no space before arrow - if (countSpace.before > 0) { - context.report({ - node: tokens.before, - messageId: "unexpectedBefore", - fix(fixer) { - return fixer.removeRange([tokens.before.range[1], tokens.arrow.range[0]]); - } - }); - } - } - - if (rule.after) { - - // should be space(s) after arrow - if (countSpace.after === 0) { - context.report({ - node: tokens.after, - messageId: "expectedAfter", - fix(fixer) { - return fixer.insertTextAfter(tokens.arrow, " "); - } - }); - } - } else { - - // should be no space after arrow - if (countSpace.after > 0) { - context.report({ - node: tokens.after, - messageId: "unexpectedAfter", - fix(fixer) { - return fixer.removeRange([tokens.arrow.range[1], tokens.after.range[0]]); - } - }); - } - } - } - - return { - ArrowFunctionExpression: spaces - }; - } -}; diff --git a/tools/eslint/node_modules/eslint/lib/rules/block-scoped-var.js b/tools/eslint/node_modules/eslint/lib/rules/block-scoped-var.js deleted file mode 100644 index d65fc074bb172c..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/rules/block-scoped-var.js +++ /dev/null @@ -1,135 +0,0 @@ -/** - * @fileoverview Rule to check for "block scoped" variables by binding context - * @author Matt DuVall - */ -"use strict"; - -//------------------------------------------------------------------------------ -// Rule Definition -//------------------------------------------------------------------------------ - -/** @type {import('../shared/types').Rule} */ -module.exports = { - meta: { - type: "suggestion", - - docs: { - description: "Enforce the use of variables within the scope they are defined", - recommended: false, - url: "https://eslint.org/docs/latest/rules/block-scoped-var" - }, - - schema: [], - - messages: { - outOfScope: "'{{name}}' declared on line {{definitionLine}} column {{definitionColumn}} is used outside of binding context." - } - }, - - create(context) { - let stack = []; - const sourceCode = context.sourceCode; - - /** - * Makes a block scope. - * @param {ASTNode} node A node of a scope. - * @returns {void} - */ - function enterScope(node) { - stack.push(node.range); - } - - /** - * Pops the last block scope. - * @returns {void} - */ - function exitScope() { - stack.pop(); - } - - /** - * Reports a given reference. - * @param {eslint-scope.Reference} reference A reference to report. - * @param {eslint-scope.Definition} definition A definition for which to report reference. - * @returns {void} - */ - function report(reference, definition) { - const identifier = reference.identifier; - const definitionPosition = definition.name.loc.start; - - context.report({ - node: identifier, - messageId: "outOfScope", - data: { - name: identifier.name, - definitionLine: definitionPosition.line, - definitionColumn: definitionPosition.column + 1 - } - }); - } - - /** - * Finds and reports references which are outside of valid scopes. - * @param {ASTNode} node A node to get variables. - * @returns {void} - */ - function checkForVariables(node) { - if (node.kind !== "var") { - return; - } - - // Defines a predicate to check whether or not a given reference is outside of valid scope. - const scopeRange = stack.at(-1); - - /** - * Check if a reference is out of scope - * @param {ASTNode} reference node to examine - * @returns {boolean} True is its outside the scope - * @private - */ - function isOutsideOfScope(reference) { - const idRange = reference.identifier.range; - - return idRange[0] < scopeRange[0] || idRange[1] > scopeRange[1]; - } - - // Gets declared variables, and checks its references. - const variables = sourceCode.getDeclaredVariables(node); - - for (let i = 0; i < variables.length; ++i) { - - // Reports. - variables[i] - .references - .filter(isOutsideOfScope) - .forEach(ref => report(ref, variables[i].defs.find(def => def.parent === node))); - } - } - - return { - Program(node) { - stack = [node.range]; - }, - - // Manages scopes. - BlockStatement: enterScope, - "BlockStatement:exit": exitScope, - ForStatement: enterScope, - "ForStatement:exit": exitScope, - ForInStatement: enterScope, - "ForInStatement:exit": exitScope, - ForOfStatement: enterScope, - "ForOfStatement:exit": exitScope, - SwitchStatement: enterScope, - "SwitchStatement:exit": exitScope, - CatchClause: enterScope, - "CatchClause:exit": exitScope, - StaticBlock: enterScope, - "StaticBlock:exit": exitScope, - - // Finds and reports references which are outside of valid scope. - VariableDeclaration: checkForVariables - }; - - } -}; diff --git a/tools/eslint/node_modules/eslint/lib/rules/block-spacing.js b/tools/eslint/node_modules/eslint/lib/rules/block-spacing.js deleted file mode 100644 index 9ca461158d9e94..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/rules/block-spacing.js +++ /dev/null @@ -1,174 +0,0 @@ -/** - * @fileoverview A rule to disallow or enforce spaces inside of single line blocks. - * @author Toru Nagashima - * @deprecated in ESLint v8.53.0 - */ - -"use strict"; - -const util = require("./utils/ast-utils"); - -//------------------------------------------------------------------------------ -// Rule Definition -//------------------------------------------------------------------------------ - -/** @type {import('../shared/types').Rule} */ -module.exports = { - meta: { - deprecated: true, - replacedBy: [], - type: "layout", - - docs: { - description: "Disallow or enforce spaces inside of blocks after opening block and before closing block", - recommended: false, - url: "https://eslint.org/docs/latest/rules/block-spacing" - }, - - fixable: "whitespace", - - schema: [ - { enum: ["always", "never"] } - ], - - messages: { - missing: "Requires a space {{location}} '{{token}}'.", - extra: "Unexpected space(s) {{location}} '{{token}}'." - } - }, - - create(context) { - const always = (context.options[0] !== "never"), - messageId = always ? "missing" : "extra", - sourceCode = context.sourceCode; - - /** - * Gets the open brace token from a given node. - * @param {ASTNode} node A BlockStatement/StaticBlock/SwitchStatement node to get. - * @returns {Token} The token of the open brace. - */ - function getOpenBrace(node) { - if (node.type === "SwitchStatement") { - if (node.cases.length > 0) { - return sourceCode.getTokenBefore(node.cases[0]); - } - return sourceCode.getLastToken(node, 1); - } - - if (node.type === "StaticBlock") { - return sourceCode.getFirstToken(node, { skip: 1 }); // skip the `static` token - } - - // "BlockStatement" - return sourceCode.getFirstToken(node); - } - - /** - * Checks whether or not: - * - given tokens are on same line. - * - there is/isn't a space between given tokens. - * @param {Token} left A token to check. - * @param {Token} right The token which is next to `left`. - * @returns {boolean} - * When the option is `"always"`, `true` if there are one or more spaces between given tokens. - * When the option is `"never"`, `true` if there are not any spaces between given tokens. - * If given tokens are not on same line, it's always `true`. - */ - function isValid(left, right) { - return ( - !util.isTokenOnSameLine(left, right) || - sourceCode.isSpaceBetweenTokens(left, right) === always - ); - } - - /** - * Checks and reports invalid spacing style inside braces. - * @param {ASTNode} node A BlockStatement/StaticBlock/SwitchStatement node to check. - * @returns {void} - */ - function checkSpacingInsideBraces(node) { - - // Gets braces and the first/last token of content. - const openBrace = getOpenBrace(node); - const closeBrace = sourceCode.getLastToken(node); - const firstToken = sourceCode.getTokenAfter(openBrace, { includeComments: true }); - const lastToken = sourceCode.getTokenBefore(closeBrace, { includeComments: true }); - - // Skip if the node is invalid or empty. - if (openBrace.type !== "Punctuator" || - openBrace.value !== "{" || - closeBrace.type !== "Punctuator" || - closeBrace.value !== "}" || - firstToken === closeBrace - ) { - return; - } - - // Skip line comments for option never - if (!always && firstToken.type === "Line") { - return; - } - - // Check. - if (!isValid(openBrace, firstToken)) { - let loc = openBrace.loc; - - if (messageId === "extra") { - loc = { - start: openBrace.loc.end, - end: firstToken.loc.start - }; - } - - context.report({ - node, - loc, - messageId, - data: { - location: "after", - token: openBrace.value - }, - fix(fixer) { - if (always) { - return fixer.insertTextBefore(firstToken, " "); - } - - return fixer.removeRange([openBrace.range[1], firstToken.range[0]]); - } - }); - } - if (!isValid(lastToken, closeBrace)) { - let loc = closeBrace.loc; - - if (messageId === "extra") { - loc = { - start: lastToken.loc.end, - end: closeBrace.loc.start - }; - } - context.report({ - node, - loc, - messageId, - data: { - location: "before", - token: closeBrace.value - }, - fix(fixer) { - if (always) { - return fixer.insertTextAfter(lastToken, " "); - } - - return fixer.removeRange([lastToken.range[1], closeBrace.range[0]]); - } - }); - } - } - - return { - BlockStatement: checkSpacingInsideBraces, - StaticBlock: checkSpacingInsideBraces, - SwitchStatement: checkSpacingInsideBraces - }; - } -}; diff --git a/tools/eslint/node_modules/eslint/lib/rules/brace-style.js b/tools/eslint/node_modules/eslint/lib/rules/brace-style.js deleted file mode 100644 index 0fb4c65e68d557..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/rules/brace-style.js +++ /dev/null @@ -1,197 +0,0 @@ -/** - * @fileoverview Rule to flag block statements that do not use the one true brace style - * @author Ian Christian Myers - * @deprecated in ESLint v8.53.0 - */ - -"use strict"; - -const astUtils = require("./utils/ast-utils"); - -//------------------------------------------------------------------------------ -// Rule Definition -//------------------------------------------------------------------------------ - -/** @type {import('../shared/types').Rule} */ -module.exports = { - meta: { - deprecated: true, - replacedBy: [], - type: "layout", - - docs: { - description: "Enforce consistent brace style for blocks", - recommended: false, - url: "https://eslint.org/docs/latest/rules/brace-style" - }, - - schema: [ - { - enum: ["1tbs", "stroustrup", "allman"] - }, - { - type: "object", - properties: { - allowSingleLine: { - type: "boolean", - default: false - } - }, - additionalProperties: false - } - ], - - fixable: "whitespace", - - messages: { - nextLineOpen: "Opening curly brace does not appear on the same line as controlling statement.", - sameLineOpen: "Opening curly brace appears on the same line as controlling statement.", - blockSameLine: "Statement inside of curly braces should be on next line.", - nextLineClose: "Closing curly brace does not appear on the same line as the subsequent block.", - singleLineClose: "Closing curly brace should be on the same line as opening curly brace or on the line after the previous block.", - sameLineClose: "Closing curly brace appears on the same line as the subsequent block." - } - }, - - create(context) { - const style = context.options[0] || "1tbs", - params = context.options[1] || {}, - sourceCode = context.sourceCode; - - //-------------------------------------------------------------------------- - // Helpers - //-------------------------------------------------------------------------- - - /** - * Fixes a place where a newline unexpectedly appears - * @param {Token} firstToken The token before the unexpected newline - * @param {Token} secondToken The token after the unexpected newline - * @returns {Function} A fixer function to remove the newlines between the tokens - */ - function removeNewlineBetween(firstToken, secondToken) { - const textRange = [firstToken.range[1], secondToken.range[0]]; - const textBetween = sourceCode.text.slice(textRange[0], textRange[1]); - - // Don't do a fix if there is a comment between the tokens - if (textBetween.trim()) { - return null; - } - return fixer => fixer.replaceTextRange(textRange, " "); - } - - /** - * Validates a pair of curly brackets based on the user's config - * @param {Token} openingCurly The opening curly bracket - * @param {Token} closingCurly The closing curly bracket - * @returns {void} - */ - function validateCurlyPair(openingCurly, closingCurly) { - const tokenBeforeOpeningCurly = sourceCode.getTokenBefore(openingCurly); - const tokenAfterOpeningCurly = sourceCode.getTokenAfter(openingCurly); - const tokenBeforeClosingCurly = sourceCode.getTokenBefore(closingCurly); - const singleLineException = params.allowSingleLine && astUtils.isTokenOnSameLine(openingCurly, closingCurly); - - if (style !== "allman" && !astUtils.isTokenOnSameLine(tokenBeforeOpeningCurly, openingCurly)) { - context.report({ - node: openingCurly, - messageId: "nextLineOpen", - fix: removeNewlineBetween(tokenBeforeOpeningCurly, openingCurly) - }); - } - - if (style === "allman" && astUtils.isTokenOnSameLine(tokenBeforeOpeningCurly, openingCurly) && !singleLineException) { - context.report({ - node: openingCurly, - messageId: "sameLineOpen", - fix: fixer => fixer.insertTextBefore(openingCurly, "\n") - }); - } - - if (astUtils.isTokenOnSameLine(openingCurly, tokenAfterOpeningCurly) && tokenAfterOpeningCurly !== closingCurly && !singleLineException) { - context.report({ - node: openingCurly, - messageId: "blockSameLine", - fix: fixer => fixer.insertTextAfter(openingCurly, "\n") - }); - } - - if (tokenBeforeClosingCurly !== openingCurly && !singleLineException && astUtils.isTokenOnSameLine(tokenBeforeClosingCurly, closingCurly)) { - context.report({ - node: closingCurly, - messageId: "singleLineClose", - fix: fixer => fixer.insertTextBefore(closingCurly, "\n") - }); - } - } - - /** - * Validates the location of a token that appears before a keyword (e.g. a newline before `else`) - * @param {Token} curlyToken The closing curly token. This is assumed to precede a keyword token (such as `else` or `finally`). - * @returns {void} - */ - function validateCurlyBeforeKeyword(curlyToken) { - const keywordToken = sourceCode.getTokenAfter(curlyToken); - - if (style === "1tbs" && !astUtils.isTokenOnSameLine(curlyToken, keywordToken)) { - context.report({ - node: curlyToken, - messageId: "nextLineClose", - fix: removeNewlineBetween(curlyToken, keywordToken) - }); - } - - if (style !== "1tbs" && astUtils.isTokenOnSameLine(curlyToken, keywordToken)) { - context.report({ - node: curlyToken, - messageId: "sameLineClose", - fix: fixer => fixer.insertTextAfter(curlyToken, "\n") - }); - } - } - - //-------------------------------------------------------------------------- - // Public API - //-------------------------------------------------------------------------- - - return { - BlockStatement(node) { - if (!astUtils.STATEMENT_LIST_PARENTS.has(node.parent.type)) { - validateCurlyPair(sourceCode.getFirstToken(node), sourceCode.getLastToken(node)); - } - }, - StaticBlock(node) { - validateCurlyPair( - sourceCode.getFirstToken(node, { skip: 1 }), // skip the `static` token - sourceCode.getLastToken(node) - ); - }, - ClassBody(node) { - validateCurlyPair(sourceCode.getFirstToken(node), sourceCode.getLastToken(node)); - }, - SwitchStatement(node) { - const closingCurly = sourceCode.getLastToken(node); - const openingCurly = sourceCode.getTokenBefore(node.cases.length ? node.cases[0] : closingCurly); - - validateCurlyPair(openingCurly, closingCurly); - }, - IfStatement(node) { - if (node.consequent.type === "BlockStatement" && node.alternate) { - - // Handle the keyword after the `if` block (before `else`) - validateCurlyBeforeKeyword(sourceCode.getLastToken(node.consequent)); - } - }, - TryStatement(node) { - - // Handle the keyword after the `try` block (before `catch` or `finally`) - validateCurlyBeforeKeyword(sourceCode.getLastToken(node.block)); - - if (node.handler && node.finalizer) { - - // Handle the keyword after the `catch` block (before `finally`) - validateCurlyBeforeKeyword(sourceCode.getLastToken(node.handler.body)); - } - } - }; - } -}; diff --git a/tools/eslint/node_modules/eslint/lib/rules/callback-return.js b/tools/eslint/node_modules/eslint/lib/rules/callback-return.js deleted file mode 100644 index ffc34b163d617b..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/rules/callback-return.js +++ /dev/null @@ -1,187 +0,0 @@ -/** - * @fileoverview Enforce return after a callback. - * @author Jamund Ferguson - * @deprecated in ESLint v7.0.0 - */ -"use strict"; - -//------------------------------------------------------------------------------ -// Rule Definition -//------------------------------------------------------------------------------ - -/** @type {import('../shared/types').Rule} */ -module.exports = { - meta: { - deprecated: true, - - replacedBy: [], - - type: "suggestion", - - docs: { - description: "Require `return` statements after callbacks", - recommended: false, - url: "https://eslint.org/docs/latest/rules/callback-return" - }, - - schema: [{ - type: "array", - items: { type: "string" } - }], - - messages: { - missingReturn: "Expected return with your callback function." - } - }, - - create(context) { - - const callbacks = context.options[0] || ["callback", "cb", "next"], - sourceCode = context.sourceCode; - - //-------------------------------------------------------------------------- - // Helpers - //-------------------------------------------------------------------------- - - /** - * Find the closest parent matching a list of types. - * @param {ASTNode} node The node whose parents we are searching - * @param {Array} types The node types to match - * @returns {ASTNode} The matched node or undefined. - */ - function findClosestParentOfType(node, types) { - if (!node.parent) { - return null; - } - if (!types.includes(node.parent.type)) { - return findClosestParentOfType(node.parent, types); - } - return node.parent; - } - - /** - * Check to see if a node contains only identifiers - * @param {ASTNode} node The node to check - * @returns {boolean} Whether or not the node contains only identifiers - */ - function containsOnlyIdentifiers(node) { - if (node.type === "Identifier") { - return true; - } - - if (node.type === "MemberExpression") { - if (node.object.type === "Identifier") { - return true; - } - if (node.object.type === "MemberExpression") { - return containsOnlyIdentifiers(node.object); - } - } - - return false; - } - - /** - * Check to see if a CallExpression is in our callback list. - * @param {ASTNode} node The node to check against our callback names list. - * @returns {boolean} Whether or not this function matches our callback name. - */ - function isCallback(node) { - return containsOnlyIdentifiers(node.callee) && callbacks.includes(sourceCode.getText(node.callee)); - } - - /** - * Determines whether or not the callback is part of a callback expression. - * @param {ASTNode} node The callback node - * @param {ASTNode} parentNode The expression node - * @returns {boolean} Whether or not this is part of a callback expression - */ - function isCallbackExpression(node, parentNode) { - - // ensure the parent node exists and is an expression - if (!parentNode || parentNode.type !== "ExpressionStatement") { - return false; - } - - // cb() - if (parentNode.expression === node) { - return true; - } - - // special case for cb && cb() and similar - if (parentNode.expression.type === "BinaryExpression" || parentNode.expression.type === "LogicalExpression") { - if (parentNode.expression.right === node) { - return true; - } - } - - return false; - } - - //-------------------------------------------------------------------------- - // Public - //-------------------------------------------------------------------------- - - return { - CallExpression(node) { - - // if we're not a callback we can return - if (!isCallback(node)) { - return; - } - - // find the closest block, return or loop - const closestBlock = findClosestParentOfType(node, ["BlockStatement", "ReturnStatement", "ArrowFunctionExpression"]) || {}; - - // if our parent is a return we know we're ok - if (closestBlock.type === "ReturnStatement") { - return; - } - - // arrow functions don't always have blocks and implicitly return - if (closestBlock.type === "ArrowFunctionExpression") { - return; - } - - // block statements are part of functions and most if statements - if (closestBlock.type === "BlockStatement") { - - // find the last item in the block - const lastItem = closestBlock.body.at(-1); - - // if the callback is the last thing in a block that might be ok - if (isCallbackExpression(node, lastItem)) { - - const parentType = closestBlock.parent.type; - - // but only if the block is part of a function - if (parentType === "FunctionExpression" || - parentType === "FunctionDeclaration" || - parentType === "ArrowFunctionExpression" - ) { - return; - } - - } - - // ending a block with a return is also ok - if (lastItem.type === "ReturnStatement") { - - // but only if the callback is immediately before - if (isCallbackExpression(node, closestBlock.body.at(-2))) { - return; - } - } - - } - - // as long as you're the child of a function at this point you should be asked to return - if (findClosestParentOfType(node, ["FunctionDeclaration", "FunctionExpression", "ArrowFunctionExpression"])) { - context.report({ node, messageId: "missingReturn" }); - } - - } - - }; - } -}; diff --git a/tools/eslint/node_modules/eslint/lib/rules/camelcase.js b/tools/eslint/node_modules/eslint/lib/rules/camelcase.js deleted file mode 100644 index 3c5a7b9cec3982..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/rules/camelcase.js +++ /dev/null @@ -1,397 +0,0 @@ -/** - * @fileoverview Rule to flag non-camelcased identifiers - * @author Nicholas C. Zakas - */ - -"use strict"; - -//------------------------------------------------------------------------------ -// Requirements -//------------------------------------------------------------------------------ - -const astUtils = require("./utils/ast-utils"); - -//------------------------------------------------------------------------------ -// Rule Definition -//------------------------------------------------------------------------------ - -/** @type {import('../shared/types').Rule} */ -module.exports = { - meta: { - type: "suggestion", - - docs: { - description: "Enforce camelcase naming convention", - recommended: false, - url: "https://eslint.org/docs/latest/rules/camelcase" - }, - - schema: [ - { - type: "object", - properties: { - ignoreDestructuring: { - type: "boolean", - default: false - }, - ignoreImports: { - type: "boolean", - default: false - }, - ignoreGlobals: { - type: "boolean", - default: false - }, - properties: { - enum: ["always", "never"] - }, - allow: { - type: "array", - items: { - type: "string" - }, - minItems: 0, - uniqueItems: true - } - }, - additionalProperties: false - } - ], - - messages: { - notCamelCase: "Identifier '{{name}}' is not in camel case.", - notCamelCasePrivate: "#{{name}} is not in camel case." - } - }, - - create(context) { - const options = context.options[0] || {}; - const properties = options.properties === "never" ? "never" : "always"; - const ignoreDestructuring = options.ignoreDestructuring; - const ignoreImports = options.ignoreImports; - const ignoreGlobals = options.ignoreGlobals; - const allow = options.allow || []; - const sourceCode = context.sourceCode; - - //-------------------------------------------------------------------------- - // Helpers - //-------------------------------------------------------------------------- - - // contains reported nodes to avoid reporting twice on destructuring with shorthand notation - const reported = new Set(); - - /** - * Checks if a string contains an underscore and isn't all upper-case - * @param {string} name The string to check. - * @returns {boolean} if the string is underscored - * @private - */ - function isUnderscored(name) { - const nameBody = name.replace(/^_+|_+$/gu, ""); - - // if there's an underscore, it might be A_CONSTANT, which is okay - return nameBody.includes("_") && nameBody !== nameBody.toUpperCase(); - } - - /** - * Checks if a string match the ignore list - * @param {string} name The string to check. - * @returns {boolean} if the string is ignored - * @private - */ - function isAllowed(name) { - return allow.some( - entry => name === entry || name.match(new RegExp(entry, "u")) - ); - } - - /** - * Checks if a given name is good or not. - * @param {string} name The name to check. - * @returns {boolean} `true` if the name is good. - * @private - */ - function isGoodName(name) { - return !isUnderscored(name) || isAllowed(name); - } - - /** - * Checks if a given identifier reference or member expression is an assignment - * target. - * @param {ASTNode} node The node to check. - * @returns {boolean} `true` if the node is an assignment target. - */ - function isAssignmentTarget(node) { - const parent = node.parent; - - switch (parent.type) { - case "AssignmentExpression": - case "AssignmentPattern": - return parent.left === node; - - case "Property": - return ( - parent.parent.type === "ObjectPattern" && - parent.value === node - ); - case "ArrayPattern": - case "RestElement": - return true; - - default: - return false; - } - } - - /** - * Checks if a given binding identifier uses the original name as-is. - * - If it's in object destructuring or object expression, the original name is its property name. - * - If it's in import declaration, the original name is its exported name. - * @param {ASTNode} node The `Identifier` node to check. - * @returns {boolean} `true` if the identifier uses the original name as-is. - */ - function equalsToOriginalName(node) { - const localName = node.name; - const valueNode = node.parent.type === "AssignmentPattern" - ? node.parent - : node; - const parent = valueNode.parent; - - switch (parent.type) { - case "Property": - return ( - (parent.parent.type === "ObjectPattern" || parent.parent.type === "ObjectExpression") && - parent.value === valueNode && - !parent.computed && - parent.key.type === "Identifier" && - parent.key.name === localName - ); - - case "ImportSpecifier": - return ( - parent.local === node && - astUtils.getModuleExportName(parent.imported) === localName - ); - - default: - return false; - } - } - - /** - * Reports an AST node as a rule violation. - * @param {ASTNode} node The node to report. - * @returns {void} - * @private - */ - function report(node) { - if (reported.has(node.range[0])) { - return; - } - reported.add(node.range[0]); - - // Report it. - context.report({ - node, - messageId: node.type === "PrivateIdentifier" - ? "notCamelCasePrivate" - : "notCamelCase", - data: { name: node.name } - }); - } - - /** - * Reports an identifier reference or a binding identifier. - * @param {ASTNode} node The `Identifier` node to report. - * @returns {void} - */ - function reportReferenceId(node) { - - /* - * For backward compatibility, if it's in callings then ignore it. - * Not sure why it is. - */ - if ( - node.parent.type === "CallExpression" || - node.parent.type === "NewExpression" - ) { - return; - } - - /* - * For backward compatibility, if it's a default value of - * destructuring/parameters then ignore it. - * Not sure why it is. - */ - if ( - node.parent.type === "AssignmentPattern" && - node.parent.right === node - ) { - return; - } - - /* - * The `ignoreDestructuring` flag skips the identifiers that uses - * the property name as-is. - */ - if (ignoreDestructuring && equalsToOriginalName(node)) { - return; - } - - report(node); - } - - return { - - // Report camelcase of global variable references ------------------ - Program(node) { - const scope = sourceCode.getScope(node); - - if (!ignoreGlobals) { - - // Defined globals in config files or directive comments. - for (const variable of scope.variables) { - if ( - variable.identifiers.length > 0 || - isGoodName(variable.name) - ) { - continue; - } - for (const reference of variable.references) { - - /* - * For backward compatibility, this rule reports read-only - * references as well. - */ - reportReferenceId(reference.identifier); - } - } - } - - // Undefined globals. - for (const reference of scope.through) { - const id = reference.identifier; - - if (isGoodName(id.name)) { - continue; - } - - /* - * For backward compatibility, this rule reports read-only - * references as well. - */ - reportReferenceId(id); - } - }, - - // Report camelcase of declared variables -------------------------- - [[ - "VariableDeclaration", - "FunctionDeclaration", - "FunctionExpression", - "ArrowFunctionExpression", - "ClassDeclaration", - "ClassExpression", - "CatchClause" - ]](node) { - for (const variable of sourceCode.getDeclaredVariables(node)) { - if (isGoodName(variable.name)) { - continue; - } - const id = variable.identifiers[0]; - - // Report declaration. - if (!(ignoreDestructuring && equalsToOriginalName(id))) { - report(id); - } - - /* - * For backward compatibility, report references as well. - * It looks unnecessary because declarations are reported. - */ - for (const reference of variable.references) { - if (reference.init) { - continue; // Skip the write references of initializers. - } - reportReferenceId(reference.identifier); - } - } - }, - - // Report camelcase in properties ---------------------------------- - [[ - "ObjectExpression > Property[computed!=true] > Identifier.key", - "MethodDefinition[computed!=true] > Identifier.key", - "PropertyDefinition[computed!=true] > Identifier.key", - "MethodDefinition > PrivateIdentifier.key", - "PropertyDefinition > PrivateIdentifier.key" - ]](node) { - if (properties === "never" || isGoodName(node.name)) { - return; - } - report(node); - }, - "MemberExpression[computed!=true] > Identifier.property"(node) { - if ( - properties === "never" || - !isAssignmentTarget(node.parent) || // โ† ignore read-only references. - isGoodName(node.name) - ) { - return; - } - report(node); - }, - - // Report camelcase in import -------------------------------------- - ImportDeclaration(node) { - for (const variable of sourceCode.getDeclaredVariables(node)) { - if (isGoodName(variable.name)) { - continue; - } - const id = variable.identifiers[0]; - - // Report declaration. - if (!(ignoreImports && equalsToOriginalName(id))) { - report(id); - } - - /* - * For backward compatibility, report references as well. - * It looks unnecessary because declarations are reported. - */ - for (const reference of variable.references) { - reportReferenceId(reference.identifier); - } - } - }, - - // Report camelcase in re-export ----------------------------------- - [[ - "ExportAllDeclaration > Identifier.exported", - "ExportSpecifier > Identifier.exported" - ]](node) { - if (isGoodName(node.name)) { - return; - } - report(node); - }, - - // Report camelcase in labels -------------------------------------- - [[ - "LabeledStatement > Identifier.label", - - /* - * For backward compatibility, report references as well. - * It looks unnecessary because declarations are reported. - */ - "BreakStatement > Identifier.label", - "ContinueStatement > Identifier.label" - ]](node) { - if (isGoodName(node.name)) { - return; - } - report(node); - } - }; - } -}; diff --git a/tools/eslint/node_modules/eslint/lib/rules/capitalized-comments.js b/tools/eslint/node_modules/eslint/lib/rules/capitalized-comments.js deleted file mode 100644 index 07a27b6ec963cb..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/rules/capitalized-comments.js +++ /dev/null @@ -1,303 +0,0 @@ -/** - * @fileoverview enforce or disallow capitalization of the first letter of a comment - * @author Kevin Partington - */ -"use strict"; - -//------------------------------------------------------------------------------ -// Requirements -//------------------------------------------------------------------------------ - -const astUtils = require("./utils/ast-utils"); - -//------------------------------------------------------------------------------ -// Helpers -//------------------------------------------------------------------------------ - -const DEFAULT_IGNORE_PATTERN = astUtils.COMMENTS_IGNORE_PATTERN, - WHITESPACE = /\s/gu, - MAYBE_URL = /^\s*[^:/?#\s]+:\/\/[^?#]/u, // TODO: Combine w/ max-len pattern? - LETTER_PATTERN = /\p{L}/u; - -/* - * Base schema body for defining the basic capitalization rule, ignorePattern, - * and ignoreInlineComments values. - * This can be used in a few different ways in the actual schema. - */ -const SCHEMA_BODY = { - type: "object", - properties: { - ignorePattern: { - type: "string" - }, - ignoreInlineComments: { - type: "boolean" - }, - ignoreConsecutiveComments: { - type: "boolean" - } - }, - additionalProperties: false -}; -const DEFAULTS = { - ignorePattern: "", - ignoreInlineComments: false, - ignoreConsecutiveComments: false -}; - -/** - * Get normalized options for either block or line comments from the given - * user-provided options. - * - If the user-provided options is just a string, returns a normalized - * set of options using default values for all other options. - * - If the user-provided options is an object, then a normalized option - * set is returned. Options specified in overrides will take priority - * over options specified in the main options object, which will in - * turn take priority over the rule's defaults. - * @param {Object|string} rawOptions The user-provided options. - * @param {string} which Either "line" or "block". - * @returns {Object} The normalized options. - */ -function getNormalizedOptions(rawOptions, which) { - return Object.assign({}, DEFAULTS, rawOptions[which] || rawOptions); -} - -/** - * Get normalized options for block and line comments. - * @param {Object|string} rawOptions The user-provided options. - * @returns {Object} An object with "Line" and "Block" keys and corresponding - * normalized options objects. - */ -function getAllNormalizedOptions(rawOptions = {}) { - return { - Line: getNormalizedOptions(rawOptions, "line"), - Block: getNormalizedOptions(rawOptions, "block") - }; -} - -/** - * Creates a regular expression for each ignorePattern defined in the rule - * options. - * - * This is done in order to avoid invoking the RegExp constructor repeatedly. - * @param {Object} normalizedOptions The normalized rule options. - * @returns {void} - */ -function createRegExpForIgnorePatterns(normalizedOptions) { - Object.keys(normalizedOptions).forEach(key => { - const ignorePatternStr = normalizedOptions[key].ignorePattern; - - if (ignorePatternStr) { - const regExp = RegExp(`^\\s*(?:${ignorePatternStr})`, "u"); - - normalizedOptions[key].ignorePatternRegExp = regExp; - } - }); -} - -//------------------------------------------------------------------------------ -// Rule Definition -//------------------------------------------------------------------------------ - -/** @type {import('../shared/types').Rule} */ -module.exports = { - meta: { - type: "suggestion", - - docs: { - description: "Enforce or disallow capitalization of the first letter of a comment", - recommended: false, - url: "https://eslint.org/docs/latest/rules/capitalized-comments" - }, - - fixable: "code", - - schema: [ - { enum: ["always", "never"] }, - { - oneOf: [ - SCHEMA_BODY, - { - type: "object", - properties: { - line: SCHEMA_BODY, - block: SCHEMA_BODY - }, - additionalProperties: false - } - ] - } - ], - - messages: { - unexpectedLowercaseComment: "Comments should not begin with a lowercase character.", - unexpectedUppercaseComment: "Comments should not begin with an uppercase character." - } - }, - - create(context) { - - const capitalize = context.options[0] || "always", - normalizedOptions = getAllNormalizedOptions(context.options[1]), - sourceCode = context.sourceCode; - - createRegExpForIgnorePatterns(normalizedOptions); - - //---------------------------------------------------------------------- - // Helpers - //---------------------------------------------------------------------- - - /** - * Checks whether a comment is an inline comment. - * - * For the purpose of this rule, a comment is inline if: - * 1. The comment is preceded by a token on the same line; and - * 2. The command is followed by a token on the same line. - * - * Note that the comment itself need not be single-line! - * - * Also, it follows from this definition that only block comments can - * be considered as possibly inline. This is because line comments - * would consume any following tokens on the same line as the comment. - * @param {ASTNode} comment The comment node to check. - * @returns {boolean} True if the comment is an inline comment, false - * otherwise. - */ - function isInlineComment(comment) { - const previousToken = sourceCode.getTokenBefore(comment, { includeComments: true }), - nextToken = sourceCode.getTokenAfter(comment, { includeComments: true }); - - return Boolean( - previousToken && - nextToken && - comment.loc.start.line === previousToken.loc.end.line && - comment.loc.end.line === nextToken.loc.start.line - ); - } - - /** - * Determine if a comment follows another comment. - * @param {ASTNode} comment The comment to check. - * @returns {boolean} True if the comment follows a valid comment. - */ - function isConsecutiveComment(comment) { - const previousTokenOrComment = sourceCode.getTokenBefore(comment, { includeComments: true }); - - return Boolean( - previousTokenOrComment && - ["Block", "Line"].includes(previousTokenOrComment.type) - ); - } - - /** - * Check a comment to determine if it is valid for this rule. - * @param {ASTNode} comment The comment node to process. - * @param {Object} options The options for checking this comment. - * @returns {boolean} True if the comment is valid, false otherwise. - */ - function isCommentValid(comment, options) { - - // 1. Check for default ignore pattern. - if (DEFAULT_IGNORE_PATTERN.test(comment.value)) { - return true; - } - - // 2. Check for custom ignore pattern. - const commentWithoutAsterisks = comment.value - .replace(/\*/gu, ""); - - if (options.ignorePatternRegExp && options.ignorePatternRegExp.test(commentWithoutAsterisks)) { - return true; - } - - // 3. Check for inline comments. - if (options.ignoreInlineComments && isInlineComment(comment)) { - return true; - } - - // 4. Is this a consecutive comment (and are we tolerating those)? - if (options.ignoreConsecutiveComments && isConsecutiveComment(comment)) { - return true; - } - - // 5. Does the comment start with a possible URL? - if (MAYBE_URL.test(commentWithoutAsterisks)) { - return true; - } - - // 6. Is the initial word character a letter? - const commentWordCharsOnly = commentWithoutAsterisks - .replace(WHITESPACE, ""); - - if (commentWordCharsOnly.length === 0) { - return true; - } - - // Get the first Unicode character (1 or 2 code units). - const [firstWordChar] = commentWordCharsOnly; - - if (!LETTER_PATTERN.test(firstWordChar)) { - return true; - } - - // 7. Check the case of the initial word character. - const isUppercase = firstWordChar !== firstWordChar.toLocaleLowerCase(), - isLowercase = firstWordChar !== firstWordChar.toLocaleUpperCase(); - - if (capitalize === "always" && isLowercase) { - return false; - } - if (capitalize === "never" && isUppercase) { - return false; - } - - return true; - } - - /** - * Process a comment to determine if it needs to be reported. - * @param {ASTNode} comment The comment node to process. - * @returns {void} - */ - function processComment(comment) { - const options = normalizedOptions[comment.type], - commentValid = isCommentValid(comment, options); - - if (!commentValid) { - const messageId = capitalize === "always" - ? "unexpectedLowercaseComment" - : "unexpectedUppercaseComment"; - - context.report({ - node: null, // Intentionally using loc instead - loc: comment.loc, - messageId, - fix(fixer) { - const match = comment.value.match(LETTER_PATTERN); - const char = match[0]; - - // Offset match.index by 2 to account for the first 2 characters that start the comment (// or /*) - const charIndex = comment.range[0] + match.index + 2; - - return fixer.replaceTextRange( - [charIndex, charIndex + char.length], - capitalize === "always" ? char.toLocaleUpperCase() : char.toLocaleLowerCase() - ); - } - }); - } - } - - //---------------------------------------------------------------------- - // Public - //---------------------------------------------------------------------- - - return { - Program() { - const comments = sourceCode.getAllComments(); - - comments.filter(token => token.type !== "Shebang").forEach(processComment); - } - }; - } -}; diff --git a/tools/eslint/node_modules/eslint/lib/rules/class-methods-use-this.js b/tools/eslint/node_modules/eslint/lib/rules/class-methods-use-this.js deleted file mode 100644 index 9cf8a1b8a86692..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/rules/class-methods-use-this.js +++ /dev/null @@ -1,187 +0,0 @@ -/** - * @fileoverview Rule to enforce that all class methods use 'this'. - * @author Patrick Williams - */ - -"use strict"; - -//------------------------------------------------------------------------------ -// Requirements -//------------------------------------------------------------------------------ - -const astUtils = require("./utils/ast-utils"); - -//------------------------------------------------------------------------------ -// Rule Definition -//------------------------------------------------------------------------------ - -/** @type {import('../shared/types').Rule} */ -module.exports = { - meta: { - type: "suggestion", - - docs: { - description: "Enforce that class methods utilize `this`", - recommended: false, - url: "https://eslint.org/docs/latest/rules/class-methods-use-this" - }, - - schema: [{ - type: "object", - properties: { - exceptMethods: { - type: "array", - items: { - type: "string" - } - }, - enforceForClassFields: { - type: "boolean", - default: true - } - }, - additionalProperties: false - }], - - messages: { - missingThis: "Expected 'this' to be used by class {{name}}." - } - }, - create(context) { - const config = Object.assign({}, context.options[0]); - const enforceForClassFields = config.enforceForClassFields !== false; - const exceptMethods = new Set(config.exceptMethods || []); - - const stack = []; - - /** - * Push `this` used flag initialized with `false` onto the stack. - * @returns {void} - */ - function pushContext() { - stack.push(false); - } - - /** - * Pop `this` used flag from the stack. - * @returns {boolean | undefined} `this` used flag - */ - function popContext() { - return stack.pop(); - } - - /** - * Initializes the current context to false and pushes it onto the stack. - * These booleans represent whether 'this' has been used in the context. - * @returns {void} - * @private - */ - function enterFunction() { - pushContext(); - } - - /** - * Check if the node is an instance method - * @param {ASTNode} node node to check - * @returns {boolean} True if its an instance method - * @private - */ - function isInstanceMethod(node) { - switch (node.type) { - case "MethodDefinition": - return !node.static && node.kind !== "constructor"; - case "PropertyDefinition": - return !node.static && enforceForClassFields; - default: - return false; - } - } - - /** - * Check if the node is an instance method not excluded by config - * @param {ASTNode} node node to check - * @returns {boolean} True if it is an instance method, and not excluded by config - * @private - */ - function isIncludedInstanceMethod(node) { - if (isInstanceMethod(node)) { - if (node.computed) { - return true; - } - - const hashIfNeeded = node.key.type === "PrivateIdentifier" ? "#" : ""; - const name = node.key.type === "Literal" - ? astUtils.getStaticStringValue(node.key) - : (node.key.name || ""); - - return !exceptMethods.has(hashIfNeeded + name); - } - return false; - } - - /** - * Checks if we are leaving a function that is a method, and reports if 'this' has not been used. - * Static methods and the constructor are exempt. - * Then pops the context off the stack. - * @param {ASTNode} node A function node that was entered. - * @returns {void} - * @private - */ - function exitFunction(node) { - const methodUsesThis = popContext(); - - if (isIncludedInstanceMethod(node.parent) && !methodUsesThis) { - context.report({ - node, - loc: astUtils.getFunctionHeadLoc(node, context.sourceCode), - messageId: "missingThis", - data: { - name: astUtils.getFunctionNameWithKind(node) - } - }); - } - } - - /** - * Mark the current context as having used 'this'. - * @returns {void} - * @private - */ - function markThisUsed() { - if (stack.length) { - stack[stack.length - 1] = true; - } - } - - return { - FunctionDeclaration: enterFunction, - "FunctionDeclaration:exit": exitFunction, - FunctionExpression: enterFunction, - "FunctionExpression:exit": exitFunction, - - /* - * Class field value are implicit functions. - */ - "PropertyDefinition > *.key:exit": pushContext, - "PropertyDefinition:exit": popContext, - - /* - * Class static blocks are implicit functions. They aren't required to use `this`, - * but we have to push context so that it captures any use of `this` in the static block - * separately from enclosing contexts, because static blocks have their own `this` and it - * shouldn't count as used `this` in enclosing contexts. - */ - StaticBlock: pushContext, - "StaticBlock:exit": popContext, - - ThisExpression: markThisUsed, - Super: markThisUsed, - ...( - enforceForClassFields && { - "PropertyDefinition > ArrowFunctionExpression.value": enterFunction, - "PropertyDefinition > ArrowFunctionExpression.value:exit": exitFunction - } - ) - }; - } -}; diff --git a/tools/eslint/node_modules/eslint/lib/rules/comma-dangle.js b/tools/eslint/node_modules/eslint/lib/rules/comma-dangle.js deleted file mode 100644 index c24c1475444c61..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/rules/comma-dangle.js +++ /dev/null @@ -1,373 +0,0 @@ -/** - * @fileoverview Rule to forbid or enforce dangling commas. - * @author Ian Christian Myers - * @deprecated in ESLint v8.53.0 - */ - -"use strict"; - -//------------------------------------------------------------------------------ -// Requirements -//------------------------------------------------------------------------------ - -const astUtils = require("./utils/ast-utils"); - -//------------------------------------------------------------------------------ -// Helpers -//------------------------------------------------------------------------------ - -const DEFAULT_OPTIONS = Object.freeze({ - arrays: "never", - objects: "never", - imports: "never", - exports: "never", - functions: "never" -}); - -/** - * Checks whether or not a trailing comma is allowed in a given node. - * If the `lastItem` is `RestElement` or `RestProperty`, it disallows trailing commas. - * @param {ASTNode} lastItem The node of the last element in the given node. - * @returns {boolean} `true` if a trailing comma is allowed. - */ -function isTrailingCommaAllowed(lastItem) { - return !( - lastItem.type === "RestElement" || - lastItem.type === "RestProperty" || - lastItem.type === "ExperimentalRestProperty" - ); -} - -/** - * Normalize option value. - * @param {string|Object|undefined} optionValue The 1st option value to normalize. - * @param {number} ecmaVersion The normalized ECMAScript version. - * @returns {Object} The normalized option value. - */ -function normalizeOptions(optionValue, ecmaVersion) { - if (typeof optionValue === "string") { - return { - arrays: optionValue, - objects: optionValue, - imports: optionValue, - exports: optionValue, - functions: ecmaVersion < 2017 ? "ignore" : optionValue - }; - } - if (typeof optionValue === "object" && optionValue !== null) { - return { - arrays: optionValue.arrays || DEFAULT_OPTIONS.arrays, - objects: optionValue.objects || DEFAULT_OPTIONS.objects, - imports: optionValue.imports || DEFAULT_OPTIONS.imports, - exports: optionValue.exports || DEFAULT_OPTIONS.exports, - functions: optionValue.functions || DEFAULT_OPTIONS.functions - }; - } - - return DEFAULT_OPTIONS; -} - -//------------------------------------------------------------------------------ -// Rule Definition -//------------------------------------------------------------------------------ - -/** @type {import('../shared/types').Rule} */ -module.exports = { - meta: { - deprecated: true, - replacedBy: [], - type: "layout", - - docs: { - description: "Require or disallow trailing commas", - recommended: false, - url: "https://eslint.org/docs/latest/rules/comma-dangle" - }, - - fixable: "code", - - schema: { - definitions: { - value: { - enum: [ - "always-multiline", - "always", - "never", - "only-multiline" - ] - }, - valueWithIgnore: { - enum: [ - "always-multiline", - "always", - "ignore", - "never", - "only-multiline" - ] - } - }, - type: "array", - items: [ - { - oneOf: [ - { - $ref: "#/definitions/value" - }, - { - type: "object", - properties: { - arrays: { $ref: "#/definitions/valueWithIgnore" }, - objects: { $ref: "#/definitions/valueWithIgnore" }, - imports: { $ref: "#/definitions/valueWithIgnore" }, - exports: { $ref: "#/definitions/valueWithIgnore" }, - functions: { $ref: "#/definitions/valueWithIgnore" } - }, - additionalProperties: false - } - ] - } - ], - additionalItems: false - }, - - messages: { - unexpected: "Unexpected trailing comma.", - missing: "Missing trailing comma." - } - }, - - create(context) { - const options = normalizeOptions(context.options[0], context.languageOptions.ecmaVersion); - - const sourceCode = context.sourceCode; - - /** - * Gets the last item of the given node. - * @param {ASTNode} node The node to get. - * @returns {ASTNode|null} The last node or null. - */ - function getLastItem(node) { - - /** - * Returns the last element of an array - * @param {any[]} array The input array - * @returns {any} The last element - */ - function last(array) { - return array.at(-1); - } - - switch (node.type) { - case "ObjectExpression": - case "ObjectPattern": - return last(node.properties); - case "ArrayExpression": - case "ArrayPattern": - return last(node.elements); - case "ImportDeclaration": - case "ExportNamedDeclaration": - return last(node.specifiers); - case "FunctionDeclaration": - case "FunctionExpression": - case "ArrowFunctionExpression": - return last(node.params); - case "CallExpression": - case "NewExpression": - return last(node.arguments); - default: - return null; - } - } - - /** - * Gets the trailing comma token of the given node. - * If the trailing comma does not exist, this returns the token which is - * the insertion point of the trailing comma token. - * @param {ASTNode} node The node to get. - * @param {ASTNode} lastItem The last item of the node. - * @returns {Token} The trailing comma token or the insertion point. - */ - function getTrailingToken(node, lastItem) { - switch (node.type) { - case "ObjectExpression": - case "ArrayExpression": - case "CallExpression": - case "NewExpression": - return sourceCode.getLastToken(node, 1); - default: { - const nextToken = sourceCode.getTokenAfter(lastItem); - - if (astUtils.isCommaToken(nextToken)) { - return nextToken; - } - return sourceCode.getLastToken(lastItem); - } - } - } - - /** - * Checks whether or not a given node is multiline. - * This rule handles a given node as multiline when the closing parenthesis - * and the last element are not on the same line. - * @param {ASTNode} node A node to check. - * @returns {boolean} `true` if the node is multiline. - */ - function isMultiline(node) { - const lastItem = getLastItem(node); - - if (!lastItem) { - return false; - } - - const penultimateToken = getTrailingToken(node, lastItem); - const lastToken = sourceCode.getTokenAfter(penultimateToken); - - return lastToken.loc.end.line !== penultimateToken.loc.end.line; - } - - /** - * Reports a trailing comma if it exists. - * @param {ASTNode} node A node to check. Its type is one of - * ObjectExpression, ObjectPattern, ArrayExpression, ArrayPattern, - * ImportDeclaration, and ExportNamedDeclaration. - * @returns {void} - */ - function forbidTrailingComma(node) { - const lastItem = getLastItem(node); - - if (!lastItem || (node.type === "ImportDeclaration" && lastItem.type !== "ImportSpecifier")) { - return; - } - - const trailingToken = getTrailingToken(node, lastItem); - - if (astUtils.isCommaToken(trailingToken)) { - context.report({ - node: lastItem, - loc: trailingToken.loc, - messageId: "unexpected", - *fix(fixer) { - yield fixer.remove(trailingToken); - - /* - * Extend the range of the fix to include surrounding tokens to ensure - * that the element after which the comma is removed stays _last_. - * This intentionally makes conflicts in fix ranges with rules that may be - * adding or removing elements in the same autofix pass. - * https://github.com/eslint/eslint/issues/15660 - */ - yield fixer.insertTextBefore(sourceCode.getTokenBefore(trailingToken), ""); - yield fixer.insertTextAfter(sourceCode.getTokenAfter(trailingToken), ""); - } - }); - } - } - - /** - * Reports the last element of a given node if it does not have a trailing - * comma. - * - * If a given node is `ArrayPattern` which has `RestElement`, the trailing - * comma is disallowed, so report if it exists. - * @param {ASTNode} node A node to check. Its type is one of - * ObjectExpression, ObjectPattern, ArrayExpression, ArrayPattern, - * ImportDeclaration, and ExportNamedDeclaration. - * @returns {void} - */ - function forceTrailingComma(node) { - const lastItem = getLastItem(node); - - if (!lastItem || (node.type === "ImportDeclaration" && lastItem.type !== "ImportSpecifier")) { - return; - } - if (!isTrailingCommaAllowed(lastItem)) { - forbidTrailingComma(node); - return; - } - - const trailingToken = getTrailingToken(node, lastItem); - - if (trailingToken.value !== ",") { - context.report({ - node: lastItem, - loc: { - start: trailingToken.loc.end, - end: astUtils.getNextLocation(sourceCode, trailingToken.loc.end) - }, - messageId: "missing", - *fix(fixer) { - yield fixer.insertTextAfter(trailingToken, ","); - - /* - * Extend the range of the fix to include surrounding tokens to ensure - * that the element after which the comma is inserted stays _last_. - * This intentionally makes conflicts in fix ranges with rules that may be - * adding or removing elements in the same autofix pass. - * https://github.com/eslint/eslint/issues/15660 - */ - yield fixer.insertTextBefore(trailingToken, ""); - yield fixer.insertTextAfter(sourceCode.getTokenAfter(trailingToken), ""); - } - }); - } - } - - /** - * If a given node is multiline, reports the last element of a given node - * when it does not have a trailing comma. - * Otherwise, reports a trailing comma if it exists. - * @param {ASTNode} node A node to check. Its type is one of - * ObjectExpression, ObjectPattern, ArrayExpression, ArrayPattern, - * ImportDeclaration, and ExportNamedDeclaration. - * @returns {void} - */ - function forceTrailingCommaIfMultiline(node) { - if (isMultiline(node)) { - forceTrailingComma(node); - } else { - forbidTrailingComma(node); - } - } - - /** - * Only if a given node is not multiline, reports the last element of a given node - * when it does not have a trailing comma. - * Otherwise, reports a trailing comma if it exists. - * @param {ASTNode} node A node to check. Its type is one of - * ObjectExpression, ObjectPattern, ArrayExpression, ArrayPattern, - * ImportDeclaration, and ExportNamedDeclaration. - * @returns {void} - */ - function allowTrailingCommaIfMultiline(node) { - if (!isMultiline(node)) { - forbidTrailingComma(node); - } - } - - const predicate = { - always: forceTrailingComma, - "always-multiline": forceTrailingCommaIfMultiline, - "only-multiline": allowTrailingCommaIfMultiline, - never: forbidTrailingComma, - ignore() {} - }; - - return { - ObjectExpression: predicate[options.objects], - ObjectPattern: predicate[options.objects], - - ArrayExpression: predicate[options.arrays], - ArrayPattern: predicate[options.arrays], - - ImportDeclaration: predicate[options.imports], - - ExportNamedDeclaration: predicate[options.exports], - - FunctionDeclaration: predicate[options.functions], - FunctionExpression: predicate[options.functions], - ArrowFunctionExpression: predicate[options.functions], - CallExpression: predicate[options.functions], - NewExpression: predicate[options.functions] - }; - } -}; diff --git a/tools/eslint/node_modules/eslint/lib/rules/comma-spacing.js b/tools/eslint/node_modules/eslint/lib/rules/comma-spacing.js deleted file mode 100644 index e266de4a9c341d..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/rules/comma-spacing.js +++ /dev/null @@ -1,192 +0,0 @@ -/** - * @fileoverview Comma spacing - validates spacing before and after comma - * @author Vignesh Anand aka vegetableman. - * @deprecated in ESLint v8.53.0 - */ -"use strict"; - -const astUtils = require("./utils/ast-utils"); - -//------------------------------------------------------------------------------ -// Rule Definition -//------------------------------------------------------------------------------ - -/** @type {import('../shared/types').Rule} */ -module.exports = { - meta: { - deprecated: true, - replacedBy: [], - type: "layout", - - docs: { - description: "Enforce consistent spacing before and after commas", - recommended: false, - url: "https://eslint.org/docs/latest/rules/comma-spacing" - }, - - fixable: "whitespace", - - schema: [ - { - type: "object", - properties: { - before: { - type: "boolean", - default: false - }, - after: { - type: "boolean", - default: true - } - }, - additionalProperties: false - } - ], - - messages: { - missing: "A space is required {{loc}} ','.", - unexpected: "There should be no space {{loc}} ','." - } - }, - - create(context) { - - const sourceCode = context.sourceCode; - const tokensAndComments = sourceCode.tokensAndComments; - - const options = { - before: context.options[0] ? context.options[0].before : false, - after: context.options[0] ? context.options[0].after : true - }; - - //-------------------------------------------------------------------------- - // Helpers - //-------------------------------------------------------------------------- - - // list of comma tokens to ignore for the check of leading whitespace - const commaTokensToIgnore = []; - - /** - * Reports a spacing error with an appropriate message. - * @param {ASTNode} node The binary expression node to report. - * @param {string} loc Is the error "before" or "after" the comma? - * @param {ASTNode} otherNode The node at the left or right of `node` - * @returns {void} - * @private - */ - function report(node, loc, otherNode) { - context.report({ - node, - fix(fixer) { - if (options[loc]) { - if (loc === "before") { - return fixer.insertTextBefore(node, " "); - } - return fixer.insertTextAfter(node, " "); - - } - let start, end; - const newText = ""; - - if (loc === "before") { - start = otherNode.range[1]; - end = node.range[0]; - } else { - start = node.range[1]; - end = otherNode.range[0]; - } - - return fixer.replaceTextRange([start, end], newText); - - }, - messageId: options[loc] ? "missing" : "unexpected", - data: { - loc - } - }); - } - - /** - * Adds null elements of the given ArrayExpression or ArrayPattern node to the ignore list. - * @param {ASTNode} node An ArrayExpression or ArrayPattern node. - * @returns {void} - */ - function addNullElementsToIgnoreList(node) { - let previousToken = sourceCode.getFirstToken(node); - - node.elements.forEach(element => { - let token; - - if (element === null) { - token = sourceCode.getTokenAfter(previousToken); - - if (astUtils.isCommaToken(token)) { - commaTokensToIgnore.push(token); - } - } else { - token = sourceCode.getTokenAfter(element); - } - - previousToken = token; - }); - } - - //-------------------------------------------------------------------------- - // Public - //-------------------------------------------------------------------------- - - return { - "Program:exit"() { - tokensAndComments.forEach((token, i) => { - - if (!astUtils.isCommaToken(token)) { - return; - } - - const previousToken = tokensAndComments[i - 1]; - const nextToken = tokensAndComments[i + 1]; - - if ( - previousToken && - !astUtils.isCommaToken(previousToken) && // ignore spacing between two commas - - /* - * `commaTokensToIgnore` are ending commas of `null` elements (array holes/elisions). - * In addition to spacing between two commas, this can also ignore: - * - * - Spacing after `[` (controlled by array-bracket-spacing) - * Example: [ , ] - * ^ - * - Spacing after a comment (for backwards compatibility, this was possibly unintentional) - * Example: [a, /* * / ,] - * ^ - */ - !commaTokensToIgnore.includes(token) && - - astUtils.isTokenOnSameLine(previousToken, token) && - options.before !== sourceCode.isSpaceBetweenTokens(previousToken, token) - ) { - report(token, "before", previousToken); - } - - if ( - nextToken && - !astUtils.isCommaToken(nextToken) && // ignore spacing between two commas - !astUtils.isClosingParenToken(nextToken) && // controlled by space-in-parens - !astUtils.isClosingBracketToken(nextToken) && // controlled by array-bracket-spacing - !astUtils.isClosingBraceToken(nextToken) && // controlled by object-curly-spacing - !(!options.after && nextToken.type === "Line") && // special case, allow space before line comment - astUtils.isTokenOnSameLine(token, nextToken) && - options.after !== sourceCode.isSpaceBetweenTokens(token, nextToken) - ) { - report(token, "after", nextToken); - } - }); - }, - ArrayExpression: addNullElementsToIgnoreList, - ArrayPattern: addNullElementsToIgnoreList - - }; - - } -}; diff --git a/tools/eslint/node_modules/eslint/lib/rules/comma-style.js b/tools/eslint/node_modules/eslint/lib/rules/comma-style.js deleted file mode 100644 index d632a3bae56f52..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/rules/comma-style.js +++ /dev/null @@ -1,314 +0,0 @@ -/** - * @fileoverview Comma style - enforces comma styles of two types: last and first - * @author Vignesh Anand aka vegetableman - * @deprecated in ESLint v8.53.0 - */ - -"use strict"; - -const astUtils = require("./utils/ast-utils"); - -//------------------------------------------------------------------------------ -// Rule Definition -//------------------------------------------------------------------------------ - -/** @type {import('../shared/types').Rule} */ -module.exports = { - meta: { - deprecated: true, - replacedBy: [], - type: "layout", - - docs: { - description: "Enforce consistent comma style", - recommended: false, - url: "https://eslint.org/docs/latest/rules/comma-style" - }, - - fixable: "code", - - schema: [ - { - enum: ["first", "last"] - }, - { - type: "object", - properties: { - exceptions: { - type: "object", - additionalProperties: { - type: "boolean" - } - } - }, - additionalProperties: false - } - ], - - messages: { - unexpectedLineBeforeAndAfterComma: "Bad line breaking before and after ','.", - expectedCommaFirst: "',' should be placed first.", - expectedCommaLast: "',' should be placed last." - } - }, - - create(context) { - const style = context.options[0] || "last", - sourceCode = context.sourceCode; - const exceptions = { - ArrayPattern: true, - ArrowFunctionExpression: true, - CallExpression: true, - FunctionDeclaration: true, - FunctionExpression: true, - ImportDeclaration: true, - ObjectPattern: true, - NewExpression: true - }; - - if (context.options.length === 2 && Object.hasOwn(context.options[1], "exceptions")) { - const keys = Object.keys(context.options[1].exceptions); - - for (let i = 0; i < keys.length; i++) { - exceptions[keys[i]] = context.options[1].exceptions[keys[i]]; - } - } - - //-------------------------------------------------------------------------- - // Helpers - //-------------------------------------------------------------------------- - - /** - * Modified text based on the style - * @param {string} styleType Style type - * @param {string} text Source code text - * @returns {string} modified text - * @private - */ - function getReplacedText(styleType, text) { - switch (styleType) { - case "between": - return `,${text.replace(astUtils.LINEBREAK_MATCHER, "")}`; - - case "first": - return `${text},`; - - case "last": - return `,${text}`; - - default: - return ""; - } - } - - /** - * Determines the fixer function for a given style. - * @param {string} styleType comma style - * @param {ASTNode} previousItemToken The token to check. - * @param {ASTNode} commaToken The token to check. - * @param {ASTNode} currentItemToken The token to check. - * @returns {Function} Fixer function - * @private - */ - function getFixerFunction(styleType, previousItemToken, commaToken, currentItemToken) { - const text = - sourceCode.text.slice(previousItemToken.range[1], commaToken.range[0]) + - sourceCode.text.slice(commaToken.range[1], currentItemToken.range[0]); - const range = [previousItemToken.range[1], currentItemToken.range[0]]; - - return function(fixer) { - return fixer.replaceTextRange(range, getReplacedText(styleType, text)); - }; - } - - /** - * Validates the spacing around single items in lists. - * @param {Token} previousItemToken The last token from the previous item. - * @param {Token} commaToken The token representing the comma. - * @param {Token} currentItemToken The first token of the current item. - * @param {Token} reportItem The item to use when reporting an error. - * @returns {void} - * @private - */ - function validateCommaItemSpacing(previousItemToken, commaToken, currentItemToken, reportItem) { - - // if single line - if (astUtils.isTokenOnSameLine(commaToken, currentItemToken) && - astUtils.isTokenOnSameLine(previousItemToken, commaToken)) { - - // do nothing. - - } else if (!astUtils.isTokenOnSameLine(commaToken, currentItemToken) && - !astUtils.isTokenOnSameLine(previousItemToken, commaToken)) { - - const comment = sourceCode.getCommentsAfter(commaToken)[0]; - const styleType = comment && comment.type === "Block" && astUtils.isTokenOnSameLine(commaToken, comment) - ? style - : "between"; - - // lone comma - context.report({ - node: reportItem, - loc: commaToken.loc, - messageId: "unexpectedLineBeforeAndAfterComma", - fix: getFixerFunction(styleType, previousItemToken, commaToken, currentItemToken) - }); - - } else if (style === "first" && !astUtils.isTokenOnSameLine(commaToken, currentItemToken)) { - - context.report({ - node: reportItem, - loc: commaToken.loc, - messageId: "expectedCommaFirst", - fix: getFixerFunction(style, previousItemToken, commaToken, currentItemToken) - }); - - } else if (style === "last" && astUtils.isTokenOnSameLine(commaToken, currentItemToken)) { - - context.report({ - node: reportItem, - loc: commaToken.loc, - messageId: "expectedCommaLast", - fix: getFixerFunction(style, previousItemToken, commaToken, currentItemToken) - }); - } - } - - /** - * Checks the comma placement with regards to a declaration/property/element - * @param {ASTNode} node The binary expression node to check - * @param {string} property The property of the node containing child nodes. - * @private - * @returns {void} - */ - function validateComma(node, property) { - const items = node[property], - arrayLiteral = (node.type === "ArrayExpression" || node.type === "ArrayPattern"); - - if (items.length > 1 || arrayLiteral) { - - // seed as opening [ - let previousItemToken = sourceCode.getFirstToken(node); - - items.forEach(item => { - const commaToken = item ? sourceCode.getTokenBefore(item) : previousItemToken, - currentItemToken = item ? sourceCode.getFirstToken(item) : sourceCode.getTokenAfter(commaToken), - reportItem = item || currentItemToken; - - /* - * This works by comparing three token locations: - * - previousItemToken is the last token of the previous item - * - commaToken is the location of the comma before the current item - * - currentItemToken is the first token of the current item - * - * These values get switched around if item is undefined. - * previousItemToken will refer to the last token not belonging - * to the current item, which could be a comma or an opening - * square bracket. currentItemToken could be a comma. - * - * All comparisons are done based on these tokens directly, so - * they are always valid regardless of an undefined item. - */ - if (astUtils.isCommaToken(commaToken)) { - validateCommaItemSpacing(previousItemToken, commaToken, currentItemToken, reportItem); - } - - if (item) { - const tokenAfterItem = sourceCode.getTokenAfter(item, astUtils.isNotClosingParenToken); - - previousItemToken = tokenAfterItem - ? sourceCode.getTokenBefore(tokenAfterItem) - : sourceCode.ast.tokens.at(-1); - } else { - previousItemToken = currentItemToken; - } - }); - - /* - * Special case for array literals that have empty last items, such - * as [ 1, 2, ]. These arrays only have two items show up in the - * AST, so we need to look at the token to verify that there's no - * dangling comma. - */ - if (arrayLiteral) { - - const lastToken = sourceCode.getLastToken(node), - nextToLastToken = sourceCode.getTokenBefore(lastToken); - - if (astUtils.isCommaToken(nextToLastToken)) { - validateCommaItemSpacing( - sourceCode.getTokenBefore(nextToLastToken), - nextToLastToken, - lastToken, - lastToken - ); - } - } - } - } - - //-------------------------------------------------------------------------- - // Public - //-------------------------------------------------------------------------- - - const nodes = {}; - - if (!exceptions.VariableDeclaration) { - nodes.VariableDeclaration = function(node) { - validateComma(node, "declarations"); - }; - } - if (!exceptions.ObjectExpression) { - nodes.ObjectExpression = function(node) { - validateComma(node, "properties"); - }; - } - if (!exceptions.ObjectPattern) { - nodes.ObjectPattern = function(node) { - validateComma(node, "properties"); - }; - } - if (!exceptions.ArrayExpression) { - nodes.ArrayExpression = function(node) { - validateComma(node, "elements"); - }; - } - if (!exceptions.ArrayPattern) { - nodes.ArrayPattern = function(node) { - validateComma(node, "elements"); - }; - } - if (!exceptions.FunctionDeclaration) { - nodes.FunctionDeclaration = function(node) { - validateComma(node, "params"); - }; - } - if (!exceptions.FunctionExpression) { - nodes.FunctionExpression = function(node) { - validateComma(node, "params"); - }; - } - if (!exceptions.ArrowFunctionExpression) { - nodes.ArrowFunctionExpression = function(node) { - validateComma(node, "params"); - }; - } - if (!exceptions.CallExpression) { - nodes.CallExpression = function(node) { - validateComma(node, "arguments"); - }; - } - if (!exceptions.ImportDeclaration) { - nodes.ImportDeclaration = function(node) { - validateComma(node, "specifiers"); - }; - } - if (!exceptions.NewExpression) { - nodes.NewExpression = function(node) { - validateComma(node, "arguments"); - }; - } - - return nodes; - } -}; diff --git a/tools/eslint/node_modules/eslint/lib/rules/complexity.js b/tools/eslint/node_modules/eslint/lib/rules/complexity.js deleted file mode 100644 index 647de7b4d3b89f..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/rules/complexity.js +++ /dev/null @@ -1,178 +0,0 @@ -/** - * @fileoverview Counts the cyclomatic complexity of each function of the script. See http://en.wikipedia.org/wiki/Cyclomatic_complexity. - * Counts the number of if, conditional, for, while, try, switch/case, - * @author Patrick Brosset - */ - -"use strict"; - -//------------------------------------------------------------------------------ -// Requirements -//------------------------------------------------------------------------------ - -const astUtils = require("./utils/ast-utils"); -const { upperCaseFirst } = require("../shared/string-utils"); - -//------------------------------------------------------------------------------ -// Rule Definition -//------------------------------------------------------------------------------ - -/** @type {import('../shared/types').Rule} */ -module.exports = { - meta: { - type: "suggestion", - - docs: { - description: "Enforce a maximum cyclomatic complexity allowed in a program", - recommended: false, - url: "https://eslint.org/docs/latest/rules/complexity" - }, - - schema: [ - { - oneOf: [ - { - type: "integer", - minimum: 0 - }, - { - type: "object", - properties: { - maximum: { - type: "integer", - minimum: 0 - }, - max: { - type: "integer", - minimum: 0 - } - }, - additionalProperties: false - } - ] - } - ], - - messages: { - complex: "{{name}} has a complexity of {{complexity}}. Maximum allowed is {{max}}." - } - }, - - create(context) { - const option = context.options[0]; - let THRESHOLD = 20; - - if ( - typeof option === "object" && - (Object.hasOwn(option, "maximum") || Object.hasOwn(option, "max")) - ) { - THRESHOLD = option.maximum || option.max; - } else if (typeof option === "number") { - THRESHOLD = option; - } - - //-------------------------------------------------------------------------- - // Helpers - //-------------------------------------------------------------------------- - - // Using a stack to store complexity per code path - const complexities = []; - - /** - * Increase the complexity of the code path in context - * @returns {void} - * @private - */ - function increaseComplexity() { - complexities[complexities.length - 1]++; - } - - //-------------------------------------------------------------------------- - // Public API - //-------------------------------------------------------------------------- - - return { - - onCodePathStart() { - - // The initial complexity is 1, representing one execution path in the CodePath - complexities.push(1); - }, - - // Each branching in the code adds 1 to the complexity - CatchClause: increaseComplexity, - ConditionalExpression: increaseComplexity, - LogicalExpression: increaseComplexity, - ForStatement: increaseComplexity, - ForInStatement: increaseComplexity, - ForOfStatement: increaseComplexity, - IfStatement: increaseComplexity, - WhileStatement: increaseComplexity, - DoWhileStatement: increaseComplexity, - AssignmentPattern: increaseComplexity, - - // Avoid `default` - "SwitchCase[test]": increaseComplexity, - - // Logical assignment operators have short-circuiting behavior - AssignmentExpression(node) { - if (astUtils.isLogicalAssignmentOperator(node.operator)) { - increaseComplexity(); - } - }, - - MemberExpression(node) { - if (node.optional === true) { - increaseComplexity(); - } - }, - - CallExpression(node) { - if (node.optional === true) { - increaseComplexity(); - } - }, - - onCodePathEnd(codePath, node) { - const complexity = complexities.pop(); - - /* - * This rule only evaluates complexity of functions, so "program" is excluded. - * Class field initializers and class static blocks are implicit functions. Therefore, - * they shouldn't contribute to the enclosing function's complexity, but their - * own complexity should be evaluated. - */ - if ( - codePath.origin !== "function" && - codePath.origin !== "class-field-initializer" && - codePath.origin !== "class-static-block" - ) { - return; - } - - if (complexity > THRESHOLD) { - let name; - - if (codePath.origin === "class-field-initializer") { - name = "class field initializer"; - } else if (codePath.origin === "class-static-block") { - name = "class static block"; - } else { - name = astUtils.getFunctionNameWithKind(node); - } - - context.report({ - node, - messageId: "complex", - data: { - name: upperCaseFirst(name), - complexity, - max: THRESHOLD - } - }); - } - } - }; - - } -}; diff --git a/tools/eslint/node_modules/eslint/lib/rules/computed-property-spacing.js b/tools/eslint/node_modules/eslint/lib/rules/computed-property-spacing.js deleted file mode 100644 index 2852877fddf4a3..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/rules/computed-property-spacing.js +++ /dev/null @@ -1,208 +0,0 @@ -/** - * @fileoverview Disallows or enforces spaces inside computed properties. - * @author Jamund Ferguson - * @deprecated in ESLint v8.53.0 - */ -"use strict"; - -const astUtils = require("./utils/ast-utils"); - -//------------------------------------------------------------------------------ -// Rule Definition -//------------------------------------------------------------------------------ - -/** @type {import('../shared/types').Rule} */ -module.exports = { - meta: { - deprecated: true, - replacedBy: [], - type: "layout", - - docs: { - description: "Enforce consistent spacing inside computed property brackets", - recommended: false, - url: "https://eslint.org/docs/latest/rules/computed-property-spacing" - }, - - fixable: "whitespace", - - schema: [ - { - enum: ["always", "never"] - }, - { - type: "object", - properties: { - enforceForClassMembers: { - type: "boolean", - default: true - } - }, - additionalProperties: false - } - ], - - messages: { - unexpectedSpaceBefore: "There should be no space before '{{tokenValue}}'.", - unexpectedSpaceAfter: "There should be no space after '{{tokenValue}}'.", - - missingSpaceBefore: "A space is required before '{{tokenValue}}'.", - missingSpaceAfter: "A space is required after '{{tokenValue}}'." - } - }, - - create(context) { - const sourceCode = context.sourceCode; - const propertyNameMustBeSpaced = context.options[0] === "always"; // default is "never" - const enforceForClassMembers = !context.options[1] || context.options[1].enforceForClassMembers; - - //-------------------------------------------------------------------------- - // Helpers - //-------------------------------------------------------------------------- - - /** - * Reports that there shouldn't be a space after the first token - * @param {ASTNode} node The node to report in the event of an error. - * @param {Token} token The token to use for the report. - * @param {Token} tokenAfter The token after `token`. - * @returns {void} - */ - function reportNoBeginningSpace(node, token, tokenAfter) { - context.report({ - node, - loc: { start: token.loc.end, end: tokenAfter.loc.start }, - messageId: "unexpectedSpaceAfter", - data: { - tokenValue: token.value - }, - fix(fixer) { - return fixer.removeRange([token.range[1], tokenAfter.range[0]]); - } - }); - } - - /** - * Reports that there shouldn't be a space before the last token - * @param {ASTNode} node The node to report in the event of an error. - * @param {Token} token The token to use for the report. - * @param {Token} tokenBefore The token before `token`. - * @returns {void} - */ - function reportNoEndingSpace(node, token, tokenBefore) { - context.report({ - node, - loc: { start: tokenBefore.loc.end, end: token.loc.start }, - messageId: "unexpectedSpaceBefore", - data: { - tokenValue: token.value - }, - fix(fixer) { - return fixer.removeRange([tokenBefore.range[1], token.range[0]]); - } - }); - } - - /** - * Reports that there should be a space after the first token - * @param {ASTNode} node The node to report in the event of an error. - * @param {Token} token The token to use for the report. - * @returns {void} - */ - function reportRequiredBeginningSpace(node, token) { - context.report({ - node, - loc: token.loc, - messageId: "missingSpaceAfter", - data: { - tokenValue: token.value - }, - fix(fixer) { - return fixer.insertTextAfter(token, " "); - } - }); - } - - /** - * Reports that there should be a space before the last token - * @param {ASTNode} node The node to report in the event of an error. - * @param {Token} token The token to use for the report. - * @returns {void} - */ - function reportRequiredEndingSpace(node, token) { - context.report({ - node, - loc: token.loc, - messageId: "missingSpaceBefore", - data: { - tokenValue: token.value - }, - fix(fixer) { - return fixer.insertTextBefore(token, " "); - } - }); - } - - /** - * Returns a function that checks the spacing of a node on the property name - * that was passed in. - * @param {string} propertyName The property on the node to check for spacing - * @returns {Function} A function that will check spacing on a node - */ - function checkSpacing(propertyName) { - return function(node) { - if (!node.computed) { - return; - } - - const property = node[propertyName]; - - const before = sourceCode.getTokenBefore(property, astUtils.isOpeningBracketToken), - first = sourceCode.getTokenAfter(before, { includeComments: true }), - after = sourceCode.getTokenAfter(property, astUtils.isClosingBracketToken), - last = sourceCode.getTokenBefore(after, { includeComments: true }); - - if (astUtils.isTokenOnSameLine(before, first)) { - if (propertyNameMustBeSpaced) { - if (!sourceCode.isSpaceBetweenTokens(before, first) && astUtils.isTokenOnSameLine(before, first)) { - reportRequiredBeginningSpace(node, before); - } - } else { - if (sourceCode.isSpaceBetweenTokens(before, first)) { - reportNoBeginningSpace(node, before, first); - } - } - } - - if (astUtils.isTokenOnSameLine(last, after)) { - if (propertyNameMustBeSpaced) { - if (!sourceCode.isSpaceBetweenTokens(last, after) && astUtils.isTokenOnSameLine(last, after)) { - reportRequiredEndingSpace(node, after); - } - } else { - if (sourceCode.isSpaceBetweenTokens(last, after)) { - reportNoEndingSpace(node, after, last); - } - } - } - }; - } - - - //-------------------------------------------------------------------------- - // Public - //-------------------------------------------------------------------------- - - const listeners = { - Property: checkSpacing("key"), - MemberExpression: checkSpacing("property") - }; - - if (enforceForClassMembers) { - listeners.MethodDefinition = - listeners.PropertyDefinition = listeners.Property; - } - - return listeners; - - } -}; diff --git a/tools/eslint/node_modules/eslint/lib/rules/consistent-return.js b/tools/eslint/node_modules/eslint/lib/rules/consistent-return.js deleted file mode 100644 index 304e924b14a09c..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/rules/consistent-return.js +++ /dev/null @@ -1,210 +0,0 @@ -/** - * @fileoverview Rule to flag consistent return values - * @author Nicholas C. Zakas - */ -"use strict"; - -//------------------------------------------------------------------------------ -// Requirements -//------------------------------------------------------------------------------ - -const astUtils = require("./utils/ast-utils"); -const { upperCaseFirst } = require("../shared/string-utils"); - -//------------------------------------------------------------------------------ -// Helpers -//------------------------------------------------------------------------------ - -/** - * Checks all segments in a set and returns true if all are unreachable. - * @param {Set} segments The segments to check. - * @returns {boolean} True if all segments are unreachable; false otherwise. - */ -function areAllSegmentsUnreachable(segments) { - - for (const segment of segments) { - if (segment.reachable) { - return false; - } - } - - return true; -} - -/** - * Checks whether a given node is a `constructor` method in an ES6 class - * @param {ASTNode} node A node to check - * @returns {boolean} `true` if the node is a `constructor` method - */ -function isClassConstructor(node) { - return node.type === "FunctionExpression" && - node.parent && - node.parent.type === "MethodDefinition" && - node.parent.kind === "constructor"; -} - -//------------------------------------------------------------------------------ -// Rule Definition -//------------------------------------------------------------------------------ - -/** @type {import('../shared/types').Rule} */ -module.exports = { - meta: { - type: "suggestion", - - docs: { - description: "Require `return` statements to either always or never specify values", - recommended: false, - url: "https://eslint.org/docs/latest/rules/consistent-return" - }, - - schema: [{ - type: "object", - properties: { - treatUndefinedAsUnspecified: { - type: "boolean", - default: false - } - }, - additionalProperties: false - }], - - messages: { - missingReturn: "Expected to return a value at the end of {{name}}.", - missingReturnValue: "{{name}} expected a return value.", - unexpectedReturnValue: "{{name}} expected no return value." - } - }, - - create(context) { - const options = context.options[0] || {}; - const treatUndefinedAsUnspecified = options.treatUndefinedAsUnspecified === true; - let funcInfo = null; - - /** - * Checks whether of not the implicit returning is consistent if the last - * code path segment is reachable. - * @param {ASTNode} node A program/function node to check. - * @returns {void} - */ - function checkLastSegment(node) { - let loc, name; - - /* - * Skip if it expected no return value or unreachable. - * When unreachable, all paths are returned or thrown. - */ - if (!funcInfo.hasReturnValue || - areAllSegmentsUnreachable(funcInfo.currentSegments) || - astUtils.isES5Constructor(node) || - isClassConstructor(node) - ) { - return; - } - - // Adjust a location and a message. - if (node.type === "Program") { - - // The head of program. - loc = { line: 1, column: 0 }; - name = "program"; - } else if (node.type === "ArrowFunctionExpression") { - - // `=>` token - loc = context.sourceCode.getTokenBefore(node.body, astUtils.isArrowToken).loc; - } else if ( - node.parent.type === "MethodDefinition" || - (node.parent.type === "Property" && node.parent.method) - ) { - - // Method name. - loc = node.parent.key.loc; - } else { - - // Function name or `function` keyword. - loc = (node.id || context.sourceCode.getFirstToken(node)).loc; - } - - if (!name) { - name = astUtils.getFunctionNameWithKind(node); - } - - // Reports. - context.report({ - node, - loc, - messageId: "missingReturn", - data: { name } - }); - } - - return { - - // Initializes/Disposes state of each code path. - onCodePathStart(codePath, node) { - funcInfo = { - upper: funcInfo, - codePath, - hasReturn: false, - hasReturnValue: false, - messageId: "", - node, - currentSegments: new Set() - }; - }, - onCodePathEnd() { - funcInfo = funcInfo.upper; - }, - - onUnreachableCodePathSegmentStart(segment) { - funcInfo.currentSegments.add(segment); - }, - - onUnreachableCodePathSegmentEnd(segment) { - funcInfo.currentSegments.delete(segment); - }, - - onCodePathSegmentStart(segment) { - funcInfo.currentSegments.add(segment); - }, - - onCodePathSegmentEnd(segment) { - funcInfo.currentSegments.delete(segment); - }, - - - // Reports a given return statement if it's inconsistent. - ReturnStatement(node) { - const argument = node.argument; - let hasReturnValue = Boolean(argument); - - if (treatUndefinedAsUnspecified && hasReturnValue) { - hasReturnValue = !astUtils.isSpecificId(argument, "undefined") && argument.operator !== "void"; - } - - if (!funcInfo.hasReturn) { - funcInfo.hasReturn = true; - funcInfo.hasReturnValue = hasReturnValue; - funcInfo.messageId = hasReturnValue ? "missingReturnValue" : "unexpectedReturnValue"; - funcInfo.data = { - name: funcInfo.node.type === "Program" - ? "Program" - : upperCaseFirst(astUtils.getFunctionNameWithKind(funcInfo.node)) - }; - } else if (funcInfo.hasReturnValue !== hasReturnValue) { - context.report({ - node, - messageId: funcInfo.messageId, - data: funcInfo.data - }); - } - }, - - // Reports a given program/function if the implicit returning is not consistent. - "Program:exit": checkLastSegment, - "FunctionDeclaration:exit": checkLastSegment, - "FunctionExpression:exit": checkLastSegment, - "ArrowFunctionExpression:exit": checkLastSegment - }; - } -}; diff --git a/tools/eslint/node_modules/eslint/lib/rules/consistent-this.js b/tools/eslint/node_modules/eslint/lib/rules/consistent-this.js deleted file mode 100644 index 658957ae25b01b..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/rules/consistent-this.js +++ /dev/null @@ -1,153 +0,0 @@ -/** - * @fileoverview Rule to enforce consistent naming of "this" context variables - * @author Raphael Pigulla - */ -"use strict"; - -//------------------------------------------------------------------------------ -// Rule Definition -//------------------------------------------------------------------------------ - -/** @type {import('../shared/types').Rule} */ -module.exports = { - meta: { - type: "suggestion", - - docs: { - description: "Enforce consistent naming when capturing the current execution context", - recommended: false, - url: "https://eslint.org/docs/latest/rules/consistent-this" - }, - - schema: { - type: "array", - items: { - type: "string", - minLength: 1 - }, - uniqueItems: true - }, - - messages: { - aliasNotAssignedToThis: "Designated alias '{{name}}' is not assigned to 'this'.", - unexpectedAlias: "Unexpected alias '{{name}}' for 'this'." - } - }, - - create(context) { - let aliases = []; - const sourceCode = context.sourceCode; - - if (context.options.length === 0) { - aliases.push("that"); - } else { - aliases = context.options; - } - - /** - * Reports that a variable declarator or assignment expression is assigning - * a non-'this' value to the specified alias. - * @param {ASTNode} node The assigning node. - * @param {string} name the name of the alias that was incorrectly used. - * @returns {void} - */ - function reportBadAssignment(node, name) { - context.report({ node, messageId: "aliasNotAssignedToThis", data: { name } }); - } - - /** - * Checks that an assignment to an identifier only assigns 'this' to the - * appropriate alias, and the alias is only assigned to 'this'. - * @param {ASTNode} node The assigning node. - * @param {Identifier} name The name of the variable assigned to. - * @param {Expression} value The value of the assignment. - * @returns {void} - */ - function checkAssignment(node, name, value) { - const isThis = value.type === "ThisExpression"; - - if (aliases.includes(name)) { - if (!isThis || node.operator && node.operator !== "=") { - reportBadAssignment(node, name); - } - } else if (isThis) { - context.report({ node, messageId: "unexpectedAlias", data: { name } }); - } - } - - /** - * Ensures that a variable declaration of the alias in a program or function - * is assigned to the correct value. - * @param {string} alias alias the check the assignment of. - * @param {Object} scope scope of the current code we are checking. - * @private - * @returns {void} - */ - function checkWasAssigned(alias, scope) { - const variable = scope.set.get(alias); - - if (!variable) { - return; - } - - if (variable.defs.some(def => def.node.type === "VariableDeclarator" && - def.node.init !== null)) { - return; - } - - /* - * The alias has been declared and not assigned: check it was - * assigned later in the same scope. - */ - if (!variable.references.some(reference => { - const write = reference.writeExpr; - - return ( - reference.from === scope && - write && write.type === "ThisExpression" && - write.parent.operator === "=" - ); - })) { - variable.defs.map(def => def.node).forEach(node => { - reportBadAssignment(node, alias); - }); - } - } - - /** - * Check each alias to ensure that is was assigned to the correct value. - * @param {ASTNode} node The node that represents the scope to check. - * @returns {void} - */ - function ensureWasAssigned(node) { - const scope = sourceCode.getScope(node); - - aliases.forEach(alias => { - checkWasAssigned(alias, scope); - }); - } - - return { - "Program:exit": ensureWasAssigned, - "FunctionExpression:exit": ensureWasAssigned, - "FunctionDeclaration:exit": ensureWasAssigned, - - VariableDeclarator(node) { - const id = node.id; - const isDestructuring = - id.type === "ArrayPattern" || id.type === "ObjectPattern"; - - if (node.init !== null && !isDestructuring) { - checkAssignment(node, id.name, node.init); - } - }, - - AssignmentExpression(node) { - if (node.left.type === "Identifier") { - checkAssignment(node, node.left.name, node.right); - } - } - }; - - } -}; diff --git a/tools/eslint/node_modules/eslint/lib/rules/constructor-super.js b/tools/eslint/node_modules/eslint/lib/rules/constructor-super.js deleted file mode 100644 index 6f46278f781cb8..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/rules/constructor-super.js +++ /dev/null @@ -1,445 +0,0 @@ -/** - * @fileoverview A rule to verify `super()` callings in constructor. - * @author Toru Nagashima - */ - -"use strict"; - -//------------------------------------------------------------------------------ -// Helpers -//------------------------------------------------------------------------------ - -/** - * Checks whether or not a given node is a constructor. - * @param {ASTNode} node A node to check. This node type is one of - * `Program`, `FunctionDeclaration`, `FunctionExpression`, and - * `ArrowFunctionExpression`. - * @returns {boolean} `true` if the node is a constructor. - */ -function isConstructorFunction(node) { - return ( - node.type === "FunctionExpression" && - node.parent.type === "MethodDefinition" && - node.parent.kind === "constructor" - ); -} - -/** - * Checks whether a given node can be a constructor or not. - * @param {ASTNode} node A node to check. - * @returns {boolean} `true` if the node can be a constructor. - */ -function isPossibleConstructor(node) { - if (!node) { - return false; - } - - switch (node.type) { - case "ClassExpression": - case "FunctionExpression": - case "ThisExpression": - case "MemberExpression": - case "CallExpression": - case "NewExpression": - case "ChainExpression": - case "YieldExpression": - case "TaggedTemplateExpression": - case "MetaProperty": - return true; - - case "Identifier": - return node.name !== "undefined"; - - case "AssignmentExpression": - if (["=", "&&="].includes(node.operator)) { - return isPossibleConstructor(node.right); - } - - if (["||=", "??="].includes(node.operator)) { - return ( - isPossibleConstructor(node.left) || - isPossibleConstructor(node.right) - ); - } - - /** - * All other assignment operators are mathematical assignment operators (arithmetic or bitwise). - * An assignment expression with a mathematical operator can either evaluate to a primitive value, - * or throw, depending on the operands. Thus, it cannot evaluate to a constructor function. - */ - return false; - - case "LogicalExpression": - - /* - * If the && operator short-circuits, the left side was falsy and therefore not a constructor, and if - * it doesn't short-circuit, it takes the value from the right side, so the right side must always be a - * possible constructor. A future improvement could verify that the left side could be truthy by - * excluding falsy literals. - */ - if (node.operator === "&&") { - return isPossibleConstructor(node.right); - } - - return ( - isPossibleConstructor(node.left) || - isPossibleConstructor(node.right) - ); - - case "ConditionalExpression": - return ( - isPossibleConstructor(node.alternate) || - isPossibleConstructor(node.consequent) - ); - - case "SequenceExpression": { - const lastExpression = node.expressions.at(-1); - - return isPossibleConstructor(lastExpression); - } - - default: - return false; - } -} - -/** - * A class to store information about a code path segment. - */ -class SegmentInfo { - - /** - * Indicates if super() is called in all code paths. - * @type {boolean} - */ - calledInEveryPaths = false; - - /** - * Indicates if super() is called in any code paths. - * @type {boolean} - */ - calledInSomePaths = false; - - /** - * The nodes which have been validated and don't need to be reconsidered. - * @type {ASTNode[]} - */ - validNodes = []; -} - -//------------------------------------------------------------------------------ -// Rule Definition -//------------------------------------------------------------------------------ - -/** @type {import('../shared/types').Rule} */ -module.exports = { - meta: { - type: "problem", - - docs: { - description: "Require `super()` calls in constructors", - recommended: true, - url: "https://eslint.org/docs/latest/rules/constructor-super" - }, - - schema: [], - - messages: { - missingSome: "Lacked a call of 'super()' in some code paths.", - missingAll: "Expected to call 'super()'.", - - duplicate: "Unexpected duplicate 'super()'.", - badSuper: "Unexpected 'super()' because 'super' is not a constructor." - } - }, - - create(context) { - - /* - * {{hasExtends: boolean, scope: Scope, codePath: CodePath}[]} - * Information for each constructor. - * - upper: Information of the upper constructor. - * - hasExtends: A flag which shows whether own class has a valid `extends` - * part. - * - scope: The scope of own class. - * - codePath: The code path object of the constructor. - */ - let funcInfo = null; - - /** - * @type {Record} - */ - const segInfoMap = Object.create(null); - - /** - * Gets the flag which shows `super()` is called in some paths. - * @param {CodePathSegment} segment A code path segment to get. - * @returns {boolean} The flag which shows `super()` is called in some paths - */ - function isCalledInSomePath(segment) { - return segment.reachable && segInfoMap[segment.id].calledInSomePaths; - } - - /** - * Determines if a segment has been seen in the traversal. - * @param {CodePathSegment} segment A code path segment to check. - * @returns {boolean} `true` if the segment has been seen. - */ - function hasSegmentBeenSeen(segment) { - return !!segInfoMap[segment.id]; - } - - /** - * Gets the flag which shows `super()` is called in all paths. - * @param {CodePathSegment} segment A code path segment to get. - * @returns {boolean} The flag which shows `super()` is called in all paths. - */ - function isCalledInEveryPath(segment) { - return segment.reachable && segInfoMap[segment.id].calledInEveryPaths; - } - - return { - - /** - * Stacks a constructor information. - * @param {CodePath} codePath A code path which was started. - * @param {ASTNode} node The current node. - * @returns {void} - */ - onCodePathStart(codePath, node) { - if (isConstructorFunction(node)) { - - // Class > ClassBody > MethodDefinition > FunctionExpression - const classNode = node.parent.parent.parent; - const superClass = classNode.superClass; - - funcInfo = { - upper: funcInfo, - isConstructor: true, - hasExtends: Boolean(superClass), - superIsConstructor: isPossibleConstructor(superClass), - codePath, - currentSegments: new Set() - }; - } else { - funcInfo = { - upper: funcInfo, - isConstructor: false, - hasExtends: false, - superIsConstructor: false, - codePath, - currentSegments: new Set() - }; - } - }, - - /** - * Pops a constructor information. - * And reports if `super()` lacked. - * @param {CodePath} codePath A code path which was ended. - * @param {ASTNode} node The current node. - * @returns {void} - */ - onCodePathEnd(codePath, node) { - const hasExtends = funcInfo.hasExtends; - - // Pop. - funcInfo = funcInfo.upper; - - if (!hasExtends) { - return; - } - - // Reports if `super()` lacked. - const returnedSegments = codePath.returnedSegments; - const calledInEveryPaths = returnedSegments.every(isCalledInEveryPath); - const calledInSomePaths = returnedSegments.some(isCalledInSomePath); - - if (!calledInEveryPaths) { - context.report({ - messageId: calledInSomePaths - ? "missingSome" - : "missingAll", - node: node.parent - }); - } - }, - - /** - * Initialize information of a given code path segment. - * @param {CodePathSegment} segment A code path segment to initialize. - * @param {CodePathSegment} node Node that starts the segment. - * @returns {void} - */ - onCodePathSegmentStart(segment, node) { - - funcInfo.currentSegments.add(segment); - - if (!(funcInfo.isConstructor && funcInfo.hasExtends)) { - return; - } - - // Initialize info. - const info = segInfoMap[segment.id] = new SegmentInfo(); - - const seenPrevSegments = segment.prevSegments.filter(hasSegmentBeenSeen); - - // When there are previous segments, aggregates these. - if (seenPrevSegments.length > 0) { - info.calledInSomePaths = seenPrevSegments.some(isCalledInSomePath); - info.calledInEveryPaths = seenPrevSegments.every(isCalledInEveryPath); - } - - /* - * ForStatement > *.update segments are a special case as they are created in advance, - * without seen previous segments. Since they logically don't affect `calledInEveryPaths` - * calculations, and they can never be a lone previous segment of another one, we'll set - * their `calledInEveryPaths` to `true` to effectively ignore them in those calculations. - * . - */ - if (node.parent && node.parent.type === "ForStatement" && node.parent.update === node) { - info.calledInEveryPaths = true; - } - }, - - onUnreachableCodePathSegmentStart(segment) { - funcInfo.currentSegments.add(segment); - }, - - onUnreachableCodePathSegmentEnd(segment) { - funcInfo.currentSegments.delete(segment); - }, - - onCodePathSegmentEnd(segment) { - funcInfo.currentSegments.delete(segment); - }, - - - /** - * Update information of the code path segment when a code path was - * looped. - * @param {CodePathSegment} fromSegment The code path segment of the - * end of a loop. - * @param {CodePathSegment} toSegment A code path segment of the head - * of a loop. - * @returns {void} - */ - onCodePathSegmentLoop(fromSegment, toSegment) { - if (!(funcInfo.isConstructor && funcInfo.hasExtends)) { - return; - } - - funcInfo.codePath.traverseSegments( - { first: toSegment, last: fromSegment }, - (segment, controller) => { - const info = segInfoMap[segment.id]; - - // skip segments after the loop - if (!info) { - controller.skip(); - return; - } - - const seenPrevSegments = segment.prevSegments.filter(hasSegmentBeenSeen); - const calledInSomePreviousPaths = seenPrevSegments.some(isCalledInSomePath); - const calledInEveryPreviousPaths = seenPrevSegments.every(isCalledInEveryPath); - - info.calledInSomePaths ||= calledInSomePreviousPaths; - info.calledInEveryPaths ||= calledInEveryPreviousPaths; - - // If flags become true anew, reports the valid nodes. - if (calledInSomePreviousPaths) { - const nodes = info.validNodes; - - info.validNodes = []; - - for (let i = 0; i < nodes.length; ++i) { - const node = nodes[i]; - - context.report({ - messageId: "duplicate", - node - }); - } - } - } - ); - }, - - /** - * Checks for a call of `super()`. - * @param {ASTNode} node A CallExpression node to check. - * @returns {void} - */ - "CallExpression:exit"(node) { - if (!(funcInfo.isConstructor && funcInfo.hasExtends)) { - return; - } - - // Skips except `super()`. - if (node.callee.type !== "Super") { - return; - } - - // Reports if needed. - const segments = funcInfo.currentSegments; - let duplicate = false; - let info = null; - - for (const segment of segments) { - - if (segment.reachable) { - info = segInfoMap[segment.id]; - - duplicate = duplicate || info.calledInSomePaths; - info.calledInSomePaths = info.calledInEveryPaths = true; - } - } - - if (info) { - if (duplicate) { - context.report({ - messageId: "duplicate", - node - }); - } else if (!funcInfo.superIsConstructor) { - context.report({ - messageId: "badSuper", - node - }); - } else { - info.validNodes.push(node); - } - } - }, - - /** - * Set the mark to the returned path as `super()` was called. - * @param {ASTNode} node A ReturnStatement node to check. - * @returns {void} - */ - ReturnStatement(node) { - if (!(funcInfo.isConstructor && funcInfo.hasExtends)) { - return; - } - - // Skips if no argument. - if (!node.argument) { - return; - } - - // Returning argument is a substitute of 'super()'. - const segments = funcInfo.currentSegments; - - for (const segment of segments) { - - if (segment.reachable) { - const info = segInfoMap[segment.id]; - - info.calledInSomePaths = info.calledInEveryPaths = true; - } - } - } - }; - } -}; diff --git a/tools/eslint/node_modules/eslint/lib/rules/curly.js b/tools/eslint/node_modules/eslint/lib/rules/curly.js deleted file mode 100644 index 35408247a19ed8..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/rules/curly.js +++ /dev/null @@ -1,486 +0,0 @@ -/** - * @fileoverview Rule to flag statements without curly braces - * @author Nicholas C. Zakas - */ -"use strict"; - -//------------------------------------------------------------------------------ -// Requirements -//------------------------------------------------------------------------------ - -const astUtils = require("./utils/ast-utils"); - -//------------------------------------------------------------------------------ -// Rule Definition -//------------------------------------------------------------------------------ - -/** @type {import('../shared/types').Rule} */ -module.exports = { - meta: { - type: "suggestion", - - docs: { - description: "Enforce consistent brace style for all control statements", - recommended: false, - url: "https://eslint.org/docs/latest/rules/curly" - }, - - schema: { - anyOf: [ - { - type: "array", - items: [ - { - enum: ["all"] - } - ], - minItems: 0, - maxItems: 1 - }, - { - type: "array", - items: [ - { - enum: ["multi", "multi-line", "multi-or-nest"] - }, - { - enum: ["consistent"] - } - ], - minItems: 0, - maxItems: 2 - } - ] - }, - - fixable: "code", - - messages: { - missingCurlyAfter: "Expected { after '{{name}}'.", - missingCurlyAfterCondition: "Expected { after '{{name}}' condition.", - unexpectedCurlyAfter: "Unnecessary { after '{{name}}'.", - unexpectedCurlyAfterCondition: "Unnecessary { after '{{name}}' condition." - } - }, - - create(context) { - - const multiOnly = (context.options[0] === "multi"); - const multiLine = (context.options[0] === "multi-line"); - const multiOrNest = (context.options[0] === "multi-or-nest"); - const consistent = (context.options[1] === "consistent"); - - const sourceCode = context.sourceCode; - - //-------------------------------------------------------------------------- - // Helpers - //-------------------------------------------------------------------------- - - /** - * Determines if a given node is a one-liner that's on the same line as it's preceding code. - * @param {ASTNode} node The node to check. - * @returns {boolean} True if the node is a one-liner that's on the same line as it's preceding code. - * @private - */ - function isCollapsedOneLiner(node) { - const before = sourceCode.getTokenBefore(node); - const last = sourceCode.getLastToken(node); - const lastExcludingSemicolon = astUtils.isSemicolonToken(last) ? sourceCode.getTokenBefore(last) : last; - - return before.loc.start.line === lastExcludingSemicolon.loc.end.line; - } - - /** - * Determines if a given node is a one-liner. - * @param {ASTNode} node The node to check. - * @returns {boolean} True if the node is a one-liner. - * @private - */ - function isOneLiner(node) { - if (node.type === "EmptyStatement") { - return true; - } - - const first = sourceCode.getFirstToken(node); - const last = sourceCode.getLastToken(node); - const lastExcludingSemicolon = astUtils.isSemicolonToken(last) ? sourceCode.getTokenBefore(last) : last; - - return first.loc.start.line === lastExcludingSemicolon.loc.end.line; - } - - /** - * Determines if the given node is a lexical declaration (let, const, function, or class) - * @param {ASTNode} node The node to check - * @returns {boolean} True if the node is a lexical declaration - * @private - */ - function isLexicalDeclaration(node) { - if (node.type === "VariableDeclaration") { - return node.kind === "const" || node.kind === "let"; - } - - return node.type === "FunctionDeclaration" || node.type === "ClassDeclaration"; - } - - /** - * Checks if the given token is an `else` token or not. - * @param {Token} token The token to check. - * @returns {boolean} `true` if the token is an `else` token. - */ - function isElseKeywordToken(token) { - return token.value === "else" && token.type === "Keyword"; - } - - /** - * Determines whether the given node has an `else` keyword token as the first token after. - * @param {ASTNode} node The node to check. - * @returns {boolean} `true` if the node is followed by an `else` keyword token. - */ - function isFollowedByElseKeyword(node) { - const nextToken = sourceCode.getTokenAfter(node); - - return Boolean(nextToken) && isElseKeywordToken(nextToken); - } - - /** - * Determines if a semicolon needs to be inserted after removing a set of curly brackets, in order to avoid a SyntaxError. - * @param {Token} closingBracket The } token - * @returns {boolean} `true` if a semicolon needs to be inserted after the last statement in the block. - */ - function needsSemicolon(closingBracket) { - const tokenBefore = sourceCode.getTokenBefore(closingBracket); - const tokenAfter = sourceCode.getTokenAfter(closingBracket); - const lastBlockNode = sourceCode.getNodeByRangeIndex(tokenBefore.range[0]); - - if (astUtils.isSemicolonToken(tokenBefore)) { - - // If the last statement already has a semicolon, don't add another one. - return false; - } - - if (!tokenAfter) { - - // If there are no statements after this block, there is no need to add a semicolon. - return false; - } - - if (lastBlockNode.type === "BlockStatement" && lastBlockNode.parent.type !== "FunctionExpression" && lastBlockNode.parent.type !== "ArrowFunctionExpression") { - - /* - * If the last node surrounded by curly brackets is a BlockStatement (other than a FunctionExpression or an ArrowFunctionExpression), - * don't insert a semicolon. Otherwise, the semicolon would be parsed as a separate statement, which would cause - * a SyntaxError if it was followed by `else`. - */ - return false; - } - - if (tokenBefore.loc.end.line === tokenAfter.loc.start.line) { - - // If the next token is on the same line, insert a semicolon. - return true; - } - - if (/^[([/`+-]/u.test(tokenAfter.value)) { - - // If the next token starts with a character that would disrupt ASI, insert a semicolon. - return true; - } - - if (tokenBefore.type === "Punctuator" && (tokenBefore.value === "++" || tokenBefore.value === "--")) { - - // If the last token is ++ or --, insert a semicolon to avoid disrupting ASI. - return true; - } - - // Otherwise, do not insert a semicolon. - return false; - } - - /** - * Determines whether the code represented by the given node contains an `if` statement - * that would become associated with an `else` keyword directly appended to that code. - * - * Examples where it returns `true`: - * - * if (a) - * foo(); - * - * if (a) { - * foo(); - * } - * - * if (a) - * foo(); - * else if (b) - * bar(); - * - * while (a) - * if (b) - * if(c) - * foo(); - * else - * bar(); - * - * Examples where it returns `false`: - * - * if (a) - * foo(); - * else - * bar(); - * - * while (a) { - * if (b) - * if(c) - * foo(); - * else - * bar(); - * } - * - * while (a) - * if (b) { - * if(c) - * foo(); - * } - * else - * bar(); - * @param {ASTNode} node Node representing the code to check. - * @returns {boolean} `true` if an `if` statement within the code would become associated with an `else` appended to that code. - */ - function hasUnsafeIf(node) { - switch (node.type) { - case "IfStatement": - if (!node.alternate) { - return true; - } - return hasUnsafeIf(node.alternate); - case "ForStatement": - case "ForInStatement": - case "ForOfStatement": - case "LabeledStatement": - case "WithStatement": - case "WhileStatement": - return hasUnsafeIf(node.body); - default: - return false; - } - } - - /** - * Determines whether the existing curly braces around the single statement are necessary to preserve the semantics of the code. - * The braces, which make the given block body, are necessary in either of the following situations: - * - * 1. The statement is a lexical declaration. - * 2. Without the braces, an `if` within the statement would become associated with an `else` after the closing brace: - * - * if (a) { - * if (b) - * foo(); - * } - * else - * bar(); - * - * if (a) - * while (b) - * while (c) { - * while (d) - * if (e) - * while(f) - * foo(); - * } - * else - * bar(); - * @param {ASTNode} node `BlockStatement` body with exactly one statement directly inside. The statement can have its own nested statements. - * @returns {boolean} `true` if the braces are necessary - removing them (replacing the given `BlockStatement` body with its single statement content) - * would change the semantics of the code or produce a syntax error. - */ - function areBracesNecessary(node) { - const statement = node.body[0]; - - return isLexicalDeclaration(statement) || - hasUnsafeIf(statement) && isFollowedByElseKeyword(node); - } - - /** - * Prepares to check the body of a node to see if it's a block statement. - * @param {ASTNode} node The node to report if there's a problem. - * @param {ASTNode} body The body node to check for blocks. - * @param {string} name The name to report if there's a problem. - * @param {{ condition: boolean }} opts Options to pass to the report functions - * @returns {Object} a prepared check object, with "actual", "expected", "check" properties. - * "actual" will be `true` or `false` whether the body is already a block statement. - * "expected" will be `true` or `false` if the body should be a block statement or not, or - * `null` if it doesn't matter, depending on the rule options. It can be modified to change - * the final behavior of "check". - * "check" will be a function reporting appropriate problems depending on the other - * properties. - */ - function prepareCheck(node, body, name, opts) { - const hasBlock = (body.type === "BlockStatement"); - let expected = null; - - if (hasBlock && (body.body.length !== 1 || areBracesNecessary(body))) { - expected = true; - } else if (multiOnly) { - expected = false; - } else if (multiLine) { - if (!isCollapsedOneLiner(body)) { - expected = true; - } - - // otherwise, the body is allowed to have braces or not to have braces - - } else if (multiOrNest) { - if (hasBlock) { - const statement = body.body[0]; - const leadingCommentsInBlock = sourceCode.getCommentsBefore(statement); - - expected = !isOneLiner(statement) || leadingCommentsInBlock.length > 0; - } else { - expected = !isOneLiner(body); - } - } else { - - // default "all" - expected = true; - } - - return { - actual: hasBlock, - expected, - check() { - if (this.expected !== null && this.expected !== this.actual) { - if (this.expected) { - context.report({ - node, - loc: body.loc, - messageId: opts && opts.condition ? "missingCurlyAfterCondition" : "missingCurlyAfter", - data: { - name - }, - fix: fixer => fixer.replaceText(body, `{${sourceCode.getText(body)}}`) - }); - } else { - context.report({ - node, - loc: body.loc, - messageId: opts && opts.condition ? "unexpectedCurlyAfterCondition" : "unexpectedCurlyAfter", - data: { - name - }, - fix(fixer) { - - /* - * `do while` expressions sometimes need a space to be inserted after `do`. - * e.g. `do{foo()} while (bar)` should be corrected to `do foo() while (bar)` - */ - const needsPrecedingSpace = node.type === "DoWhileStatement" && - sourceCode.getTokenBefore(body).range[1] === body.range[0] && - !astUtils.canTokensBeAdjacent("do", sourceCode.getFirstToken(body, { skip: 1 })); - - const openingBracket = sourceCode.getFirstToken(body); - const closingBracket = sourceCode.getLastToken(body); - const lastTokenInBlock = sourceCode.getTokenBefore(closingBracket); - - if (needsSemicolon(closingBracket)) { - - /* - * If removing braces would cause a SyntaxError due to multiple statements on the same line (or - * change the semantics of the code due to ASI), don't perform a fix. - */ - return null; - } - - const resultingBodyText = sourceCode.getText().slice(openingBracket.range[1], lastTokenInBlock.range[0]) + - sourceCode.getText(lastTokenInBlock) + - sourceCode.getText().slice(lastTokenInBlock.range[1], closingBracket.range[0]); - - return fixer.replaceText(body, (needsPrecedingSpace ? " " : "") + resultingBodyText); - } - }); - } - } - } - }; - } - - /** - * Prepares to check the bodies of a "if", "else if" and "else" chain. - * @param {ASTNode} node The first IfStatement node of the chain. - * @returns {Object[]} prepared checks for each body of the chain. See `prepareCheck` for more - * information. - */ - function prepareIfChecks(node) { - const preparedChecks = []; - - for (let currentNode = node; currentNode; currentNode = currentNode.alternate) { - preparedChecks.push(prepareCheck(currentNode, currentNode.consequent, "if", { condition: true })); - if (currentNode.alternate && currentNode.alternate.type !== "IfStatement") { - preparedChecks.push(prepareCheck(currentNode, currentNode.alternate, "else")); - break; - } - } - - if (consistent) { - - /* - * If any node should have or already have braces, make sure they - * all have braces. - * If all nodes shouldn't have braces, make sure they don't. - */ - const expected = preparedChecks.some(preparedCheck => { - if (preparedCheck.expected !== null) { - return preparedCheck.expected; - } - return preparedCheck.actual; - }); - - preparedChecks.forEach(preparedCheck => { - preparedCheck.expected = expected; - }); - } - - return preparedChecks; - } - - //-------------------------------------------------------------------------- - // Public - //-------------------------------------------------------------------------- - - return { - IfStatement(node) { - const parent = node.parent; - const isElseIf = parent.type === "IfStatement" && parent.alternate === node; - - if (!isElseIf) { - - // This is a top `if`, check the whole `if-else-if` chain - prepareIfChecks(node).forEach(preparedCheck => { - preparedCheck.check(); - }); - } - - // Skip `else if`, it's already checked (when the top `if` was visited) - }, - - WhileStatement(node) { - prepareCheck(node, node.body, "while", { condition: true }).check(); - }, - - DoWhileStatement(node) { - prepareCheck(node, node.body, "do").check(); - }, - - ForStatement(node) { - prepareCheck(node, node.body, "for", { condition: true }).check(); - }, - - ForInStatement(node) { - prepareCheck(node, node.body, "for-in").check(); - }, - - ForOfStatement(node) { - prepareCheck(node, node.body, "for-of").check(); - } - }; - } -}; diff --git a/tools/eslint/node_modules/eslint/lib/rules/default-case-last.js b/tools/eslint/node_modules/eslint/lib/rules/default-case-last.js deleted file mode 100644 index d4a83b5fdc140f..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/rules/default-case-last.js +++ /dev/null @@ -1,44 +0,0 @@ -/** - * @fileoverview Rule to enforce default clauses in switch statements to be last - * @author Milos Djermanovic - */ - -"use strict"; - -//------------------------------------------------------------------------------ -// Rule Definition -//------------------------------------------------------------------------------ - -/** @type {import('../shared/types').Rule} */ -module.exports = { - meta: { - type: "suggestion", - - docs: { - description: "Enforce default clauses in switch statements to be last", - recommended: false, - url: "https://eslint.org/docs/latest/rules/default-case-last" - }, - - schema: [], - - messages: { - notLast: "Default clause should be the last clause." - } - }, - - create(context) { - return { - SwitchStatement(node) { - const cases = node.cases, - indexOfDefault = cases.findIndex(c => c.test === null); - - if (indexOfDefault !== -1 && indexOfDefault !== cases.length - 1) { - const defaultClause = cases[indexOfDefault]; - - context.report({ node: defaultClause, messageId: "notLast" }); - } - } - }; - } -}; diff --git a/tools/eslint/node_modules/eslint/lib/rules/default-case.js b/tools/eslint/node_modules/eslint/lib/rules/default-case.js deleted file mode 100644 index 1f83cef3b11355..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/rules/default-case.js +++ /dev/null @@ -1,97 +0,0 @@ -/** - * @fileoverview require default case in switch statements - * @author Aliaksei Shytkin - */ -"use strict"; - -const DEFAULT_COMMENT_PATTERN = /^no default$/iu; - -//------------------------------------------------------------------------------ -// Rule Definition -//------------------------------------------------------------------------------ - -/** @type {import('../shared/types').Rule} */ -module.exports = { - meta: { - type: "suggestion", - - docs: { - description: "Require `default` cases in `switch` statements", - recommended: false, - url: "https://eslint.org/docs/latest/rules/default-case" - }, - - schema: [{ - type: "object", - properties: { - commentPattern: { - type: "string" - } - }, - additionalProperties: false - }], - - messages: { - missingDefaultCase: "Expected a default case." - } - }, - - create(context) { - const options = context.options[0] || {}; - const commentPattern = options.commentPattern - ? new RegExp(options.commentPattern, "u") - : DEFAULT_COMMENT_PATTERN; - - const sourceCode = context.sourceCode; - - //-------------------------------------------------------------------------- - // Helpers - //-------------------------------------------------------------------------- - - /** - * Shortcut to get last element of array - * @param {*[]} collection Array - * @returns {any} Last element - */ - function last(collection) { - return collection.at(-1); - } - - //-------------------------------------------------------------------------- - // Public - //-------------------------------------------------------------------------- - - return { - - SwitchStatement(node) { - - if (!node.cases.length) { - - /* - * skip check of empty switch because there is no easy way - * to extract comments inside it now - */ - return; - } - - const hasDefault = node.cases.some(v => v.test === null); - - if (!hasDefault) { - - let comment; - - const lastCase = last(node.cases); - const comments = sourceCode.getCommentsAfter(lastCase); - - if (comments.length) { - comment = last(comments); - } - - if (!comment || !commentPattern.test(comment.value.trim())) { - context.report({ node, messageId: "missingDefaultCase" }); - } - } - } - }; - } -}; diff --git a/tools/eslint/node_modules/eslint/lib/rules/default-param-last.js b/tools/eslint/node_modules/eslint/lib/rules/default-param-last.js deleted file mode 100644 index 3254fa8026f419..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/rules/default-param-last.js +++ /dev/null @@ -1,62 +0,0 @@ -/** - * @fileoverview enforce default parameters to be last - * @author Chiawen Chen - */ - -"use strict"; - -/** @type {import('../shared/types').Rule} */ -module.exports = { - meta: { - type: "suggestion", - - docs: { - description: "Enforce default parameters to be last", - recommended: false, - url: "https://eslint.org/docs/latest/rules/default-param-last" - }, - - schema: [], - - messages: { - shouldBeLast: "Default parameters should be last." - } - }, - - create(context) { - - /** - * Handler for function contexts. - * @param {ASTNode} node function node - * @returns {void} - */ - function handleFunction(node) { - let hasSeenPlainParam = false; - - for (let i = node.params.length - 1; i >= 0; i -= 1) { - const param = node.params[i]; - - if ( - param.type !== "AssignmentPattern" && - param.type !== "RestElement" - ) { - hasSeenPlainParam = true; - continue; - } - - if (hasSeenPlainParam && param.type === "AssignmentPattern") { - context.report({ - node: param, - messageId: "shouldBeLast" - }); - } - } - } - - return { - FunctionDeclaration: handleFunction, - FunctionExpression: handleFunction, - ArrowFunctionExpression: handleFunction - }; - } -}; diff --git a/tools/eslint/node_modules/eslint/lib/rules/dot-location.js b/tools/eslint/node_modules/eslint/lib/rules/dot-location.js deleted file mode 100644 index 0d017c16232b9d..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/rules/dot-location.js +++ /dev/null @@ -1,108 +0,0 @@ -/** - * @fileoverview Validates newlines before and after dots - * @author Greg Cochard - * @deprecated in ESLint v8.53.0 - */ - -"use strict"; - -const astUtils = require("./utils/ast-utils"); - -//------------------------------------------------------------------------------ -// Rule Definition -//------------------------------------------------------------------------------ - -/** @type {import('../shared/types').Rule} */ -module.exports = { - meta: { - deprecated: true, - replacedBy: [], - type: "layout", - - docs: { - description: "Enforce consistent newlines before and after dots", - recommended: false, - url: "https://eslint.org/docs/latest/rules/dot-location" - }, - - schema: [ - { - enum: ["object", "property"] - } - ], - - fixable: "code", - - messages: { - expectedDotAfterObject: "Expected dot to be on same line as object.", - expectedDotBeforeProperty: "Expected dot to be on same line as property." - } - }, - - create(context) { - - const config = context.options[0]; - - // default to onObject if no preference is passed - const onObject = config === "object" || !config; - - const sourceCode = context.sourceCode; - - /** - * Reports if the dot between object and property is on the correct location. - * @param {ASTNode} node The `MemberExpression` node. - * @returns {void} - */ - function checkDotLocation(node) { - const property = node.property; - const dotToken = sourceCode.getTokenBefore(property); - - if (onObject) { - - // `obj` expression can be parenthesized, but those paren tokens are not a part of the `obj` node. - const tokenBeforeDot = sourceCode.getTokenBefore(dotToken); - - if (!astUtils.isTokenOnSameLine(tokenBeforeDot, dotToken)) { - context.report({ - node, - loc: dotToken.loc, - messageId: "expectedDotAfterObject", - *fix(fixer) { - if (dotToken.value.startsWith(".") && astUtils.isDecimalIntegerNumericToken(tokenBeforeDot)) { - yield fixer.insertTextAfter(tokenBeforeDot, ` ${dotToken.value}`); - } else { - yield fixer.insertTextAfter(tokenBeforeDot, dotToken.value); - } - yield fixer.remove(dotToken); - } - }); - } - } else if (!astUtils.isTokenOnSameLine(dotToken, property)) { - context.report({ - node, - loc: dotToken.loc, - messageId: "expectedDotBeforeProperty", - *fix(fixer) { - yield fixer.remove(dotToken); - yield fixer.insertTextBefore(property, dotToken.value); - } - }); - } - } - - /** - * Checks the spacing of the dot within a member expression. - * @param {ASTNode} node The node to check. - * @returns {void} - */ - function checkNode(node) { - if (!node.computed) { - checkDotLocation(node); - } - } - - return { - MemberExpression: checkNode - }; - } -}; diff --git a/tools/eslint/node_modules/eslint/lib/rules/dot-notation.js b/tools/eslint/node_modules/eslint/lib/rules/dot-notation.js deleted file mode 100644 index 21cba54e2a52d9..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/rules/dot-notation.js +++ /dev/null @@ -1,176 +0,0 @@ -/** - * @fileoverview Rule to warn about using dot notation instead of square bracket notation when possible. - * @author Josh Perez - */ -"use strict"; - -//------------------------------------------------------------------------------ -// Requirements -//------------------------------------------------------------------------------ - -const astUtils = require("./utils/ast-utils"); -const keywords = require("./utils/keywords"); - -//------------------------------------------------------------------------------ -// Rule Definition -//------------------------------------------------------------------------------ - -const validIdentifier = /^[a-zA-Z_$][a-zA-Z0-9_$]*$/u; - -// `null` literal must be handled separately. -const literalTypesToCheck = new Set(["string", "boolean"]); - -/** @type {import('../shared/types').Rule} */ -module.exports = { - meta: { - type: "suggestion", - - docs: { - description: "Enforce dot notation whenever possible", - recommended: false, - url: "https://eslint.org/docs/latest/rules/dot-notation" - }, - - schema: [ - { - type: "object", - properties: { - allowKeywords: { - type: "boolean", - default: true - }, - allowPattern: { - type: "string", - default: "" - } - }, - additionalProperties: false - } - ], - - fixable: "code", - - messages: { - useDot: "[{{key}}] is better written in dot notation.", - useBrackets: ".{{key}} is a syntax error." - } - }, - - create(context) { - const options = context.options[0] || {}; - const allowKeywords = options.allowKeywords === void 0 || options.allowKeywords; - const sourceCode = context.sourceCode; - - let allowPattern; - - if (options.allowPattern) { - allowPattern = new RegExp(options.allowPattern, "u"); - } - - /** - * Check if the property is valid dot notation - * @param {ASTNode} node The dot notation node - * @param {string} value Value which is to be checked - * @returns {void} - */ - function checkComputedProperty(node, value) { - if ( - validIdentifier.test(value) && - (allowKeywords || !keywords.includes(String(value))) && - !(allowPattern && allowPattern.test(value)) - ) { - const formattedValue = node.property.type === "Literal" ? JSON.stringify(value) : `\`${value}\``; - - context.report({ - node: node.property, - messageId: "useDot", - data: { - key: formattedValue - }, - *fix(fixer) { - const leftBracket = sourceCode.getTokenAfter(node.object, astUtils.isOpeningBracketToken); - const rightBracket = sourceCode.getLastToken(node); - const nextToken = sourceCode.getTokenAfter(node); - - // Don't perform any fixes if there are comments inside the brackets. - if (sourceCode.commentsExistBetween(leftBracket, rightBracket)) { - return; - } - - // Replace the brackets by an identifier. - if (!node.optional) { - yield fixer.insertTextBefore( - leftBracket, - astUtils.isDecimalInteger(node.object) ? " ." : "." - ); - } - yield fixer.replaceTextRange( - [leftBracket.range[0], rightBracket.range[1]], - value - ); - - // Insert a space after the property if it will be connected to the next token. - if ( - nextToken && - rightBracket.range[1] === nextToken.range[0] && - !astUtils.canTokensBeAdjacent(String(value), nextToken) - ) { - yield fixer.insertTextAfter(node, " "); - } - } - }); - } - } - - return { - MemberExpression(node) { - if ( - node.computed && - node.property.type === "Literal" && - (literalTypesToCheck.has(typeof node.property.value) || astUtils.isNullLiteral(node.property)) - ) { - checkComputedProperty(node, node.property.value); - } - if ( - node.computed && - astUtils.isStaticTemplateLiteral(node.property) - ) { - checkComputedProperty(node, node.property.quasis[0].value.cooked); - } - if ( - !allowKeywords && - !node.computed && - node.property.type === "Identifier" && - keywords.includes(String(node.property.name)) - ) { - context.report({ - node: node.property, - messageId: "useBrackets", - data: { - key: node.property.name - }, - *fix(fixer) { - const dotToken = sourceCode.getTokenBefore(node.property); - - // A statement that starts with `let[` is parsed as a destructuring variable declaration, not a MemberExpression. - if (node.object.type === "Identifier" && node.object.name === "let" && !node.optional) { - return; - } - - // Don't perform any fixes if there are comments between the dot and the property name. - if (sourceCode.commentsExistBetween(dotToken, node.property)) { - return; - } - - // Replace the identifier to brackets. - if (!node.optional) { - yield fixer.remove(dotToken); - } - yield fixer.replaceText(node.property, `["${node.property.name}"]`); - } - }); - } - } - }; - } -}; diff --git a/tools/eslint/node_modules/eslint/lib/rules/eol-last.js b/tools/eslint/node_modules/eslint/lib/rules/eol-last.js deleted file mode 100644 index c46ff4eff0937a..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/rules/eol-last.js +++ /dev/null @@ -1,115 +0,0 @@ -/** - * @fileoverview Require or disallow newline at the end of files - * @author Nodeca Team - * @deprecated in ESLint v8.53.0 - */ -"use strict"; - -//------------------------------------------------------------------------------ -// Rule Definition -//------------------------------------------------------------------------------ - -/** @type {import('../shared/types').Rule} */ -module.exports = { - meta: { - deprecated: true, - replacedBy: [], - type: "layout", - - docs: { - description: "Require or disallow newline at the end of files", - recommended: false, - url: "https://eslint.org/docs/latest/rules/eol-last" - }, - - fixable: "whitespace", - - schema: [ - { - enum: ["always", "never", "unix", "windows"] - } - ], - - messages: { - missing: "Newline required at end of file but not found.", - unexpected: "Newline not allowed at end of file." - } - }, - create(context) { - - //-------------------------------------------------------------------------- - // Public - //-------------------------------------------------------------------------- - - return { - Program: function checkBadEOF(node) { - const sourceCode = context.sourceCode, - src = sourceCode.getText(), - lastLine = sourceCode.lines.at(-1), - location = { - column: lastLine.length, - line: sourceCode.lines.length - }, - LF = "\n", - CRLF = `\r${LF}`, - endsWithNewline = src.endsWith(LF); - - /* - * Empty source is always valid: No content in file so we don't - * need to lint for a newline on the last line of content. - */ - if (!src.length) { - return; - } - - let mode = context.options[0] || "always", - appendCRLF = false; - - if (mode === "unix") { - - // `"unix"` should behave exactly as `"always"` - mode = "always"; - } - if (mode === "windows") { - - // `"windows"` should behave exactly as `"always"`, but append CRLF in the fixer for backwards compatibility - mode = "always"; - appendCRLF = true; - } - if (mode === "always" && !endsWithNewline) { - - // File is not newline-terminated, but should be - context.report({ - node, - loc: location, - messageId: "missing", - fix(fixer) { - return fixer.insertTextAfterRange([0, src.length], appendCRLF ? CRLF : LF); - } - }); - } else if (mode === "never" && endsWithNewline) { - - const secondLastLine = sourceCode.lines.at(-2); - - // File is newline-terminated, but shouldn't be - context.report({ - node, - loc: { - start: { line: sourceCode.lines.length - 1, column: secondLastLine.length }, - end: { line: sourceCode.lines.length, column: 0 } - }, - messageId: "unexpected", - fix(fixer) { - const finalEOLs = /(?:\r?\n)+$/u, - match = finalEOLs.exec(sourceCode.text), - start = match.index, - end = sourceCode.text.length; - - return fixer.replaceTextRange([start, end], ""); - } - }); - } - } - }; - } -}; diff --git a/tools/eslint/node_modules/eslint/lib/rules/eqeqeq.js b/tools/eslint/node_modules/eslint/lib/rules/eqeqeq.js deleted file mode 100644 index 12b1e805ec13c5..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/rules/eqeqeq.js +++ /dev/null @@ -1,174 +0,0 @@ -/** - * @fileoverview Rule to flag statements that use != and == instead of !== and === - * @author Nicholas C. Zakas - */ - -"use strict"; - -//------------------------------------------------------------------------------ -// Requirements -//------------------------------------------------------------------------------ - -const astUtils = require("./utils/ast-utils"); - -//------------------------------------------------------------------------------ -// Rule Definition -//------------------------------------------------------------------------------ - -/** @type {import('../shared/types').Rule} */ -module.exports = { - meta: { - type: "suggestion", - - docs: { - description: "Require the use of `===` and `!==`", - recommended: false, - url: "https://eslint.org/docs/latest/rules/eqeqeq" - }, - - schema: { - anyOf: [ - { - type: "array", - items: [ - { - enum: ["always"] - }, - { - type: "object", - properties: { - null: { - enum: ["always", "never", "ignore"] - } - }, - additionalProperties: false - } - ], - additionalItems: false - }, - { - type: "array", - items: [ - { - enum: ["smart", "allow-null"] - } - ], - additionalItems: false - } - ] - }, - - fixable: "code", - - messages: { - unexpected: "Expected '{{expectedOperator}}' and instead saw '{{actualOperator}}'." - } - }, - - create(context) { - const config = context.options[0] || "always"; - const options = context.options[1] || {}; - const sourceCode = context.sourceCode; - - const nullOption = (config === "always") - ? options.null || "always" - : "ignore"; - const enforceRuleForNull = (nullOption === "always"); - const enforceInverseRuleForNull = (nullOption === "never"); - - /** - * Checks if an expression is a typeof expression - * @param {ASTNode} node The node to check - * @returns {boolean} if the node is a typeof expression - */ - function isTypeOf(node) { - return node.type === "UnaryExpression" && node.operator === "typeof"; - } - - /** - * Checks if either operand of a binary expression is a typeof operation - * @param {ASTNode} node The node to check - * @returns {boolean} if one of the operands is typeof - * @private - */ - function isTypeOfBinary(node) { - return isTypeOf(node.left) || isTypeOf(node.right); - } - - /** - * Checks if operands are literals of the same type (via typeof) - * @param {ASTNode} node The node to check - * @returns {boolean} if operands are of same type - * @private - */ - function areLiteralsAndSameType(node) { - return node.left.type === "Literal" && node.right.type === "Literal" && - typeof node.left.value === typeof node.right.value; - } - - /** - * Checks if one of the operands is a literal null - * @param {ASTNode} node The node to check - * @returns {boolean} if operands are null - * @private - */ - function isNullCheck(node) { - return astUtils.isNullLiteral(node.right) || astUtils.isNullLiteral(node.left); - } - - /** - * Reports a message for this rule. - * @param {ASTNode} node The binary expression node that was checked - * @param {string} expectedOperator The operator that was expected (either '==', '!=', '===', or '!==') - * @returns {void} - * @private - */ - function report(node, expectedOperator) { - const operatorToken = sourceCode.getFirstTokenBetween( - node.left, - node.right, - token => token.value === node.operator - ); - - context.report({ - node, - loc: operatorToken.loc, - messageId: "unexpected", - data: { expectedOperator, actualOperator: node.operator }, - fix(fixer) { - - // If the comparison is a `typeof` comparison or both sides are literals with the same type, then it's safe to fix. - if (isTypeOfBinary(node) || areLiteralsAndSameType(node)) { - return fixer.replaceText(operatorToken, expectedOperator); - } - return null; - } - }); - } - - return { - BinaryExpression(node) { - const isNull = isNullCheck(node); - - if (node.operator !== "==" && node.operator !== "!=") { - if (enforceInverseRuleForNull && isNull) { - report(node, node.operator.slice(0, -1)); - } - return; - } - - if (config === "smart" && (isTypeOfBinary(node) || - areLiteralsAndSameType(node) || isNull)) { - return; - } - - if (!enforceRuleForNull && isNull) { - return; - } - - report(node, `${node.operator}=`); - } - }; - - } -}; diff --git a/tools/eslint/node_modules/eslint/lib/rules/for-direction.js b/tools/eslint/node_modules/eslint/lib/rules/for-direction.js deleted file mode 100644 index 69198d11ad221f..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/rules/for-direction.js +++ /dev/null @@ -1,140 +0,0 @@ -/** - * @fileoverview enforce "for" loop update clause moving the counter in the right direction.(for-direction) - * @author Aladdin-ADD - */ - -"use strict"; - -//------------------------------------------------------------------------------ -// Requirements -//------------------------------------------------------------------------------ - -const { getStaticValue } = require("@eslint-community/eslint-utils"); - -//------------------------------------------------------------------------------ -// Rule Definition -//------------------------------------------------------------------------------ - -/** @type {import('../shared/types').Rule} */ -module.exports = { - meta: { - type: "problem", - - docs: { - description: "Enforce \"for\" loop update clause moving the counter in the right direction", - recommended: true, - url: "https://eslint.org/docs/latest/rules/for-direction" - }, - - fixable: null, - schema: [], - - messages: { - incorrectDirection: "The update clause in this loop moves the variable in the wrong direction." - } - }, - - create(context) { - const { sourceCode } = context; - - /** - * report an error. - * @param {ASTNode} node the node to report. - * @returns {void} - */ - function report(node) { - context.report({ - node, - messageId: "incorrectDirection" - }); - } - - /** - * check the right side of the assignment - * @param {ASTNode} update UpdateExpression to check - * @param {int} dir expected direction that could either be turned around or invalidated - * @returns {int} return dir, the negated dir, or zero if the counter does not change or the direction is not clear - */ - function getRightDirection(update, dir) { - const staticValue = getStaticValue(update.right, sourceCode.getScope(update)); - - if (staticValue && ["bigint", "boolean", "number"].includes(typeof staticValue.value)) { - const sign = Math.sign(Number(staticValue.value)) || 0; // convert NaN to 0 - - return dir * sign; - } - return 0; - } - - /** - * check UpdateExpression add/sub the counter - * @param {ASTNode} update UpdateExpression to check - * @param {string} counter variable name to check - * @returns {int} if add return 1, if sub return -1, if nochange, return 0 - */ - function getUpdateDirection(update, counter) { - if (update.argument.type === "Identifier" && update.argument.name === counter) { - if (update.operator === "++") { - return 1; - } - if (update.operator === "--") { - return -1; - } - } - return 0; - } - - /** - * check AssignmentExpression add/sub the counter - * @param {ASTNode} update AssignmentExpression to check - * @param {string} counter variable name to check - * @returns {int} if add return 1, if sub return -1, if nochange, return 0 - */ - function getAssignmentDirection(update, counter) { - if (update.left.name === counter) { - if (update.operator === "+=") { - return getRightDirection(update, 1); - } - if (update.operator === "-=") { - return getRightDirection(update, -1); - } - } - return 0; - } - - return { - ForStatement(node) { - - if (node.test && node.test.type === "BinaryExpression" && node.update) { - for (const counterPosition of ["left", "right"]) { - if (node.test[counterPosition].type !== "Identifier") { - continue; - } - - const counter = node.test[counterPosition].name; - const operator = node.test.operator; - const update = node.update; - - let wrongDirection; - - if (operator === "<" || operator === "<=") { - wrongDirection = counterPosition === "left" ? -1 : 1; - } else if (operator === ">" || operator === ">=") { - wrongDirection = counterPosition === "left" ? 1 : -1; - } else { - return; - } - - if (update.type === "UpdateExpression") { - if (getUpdateDirection(update, counter) === wrongDirection) { - report(node); - } - } else if (update.type === "AssignmentExpression" && getAssignmentDirection(update, counter) === wrongDirection) { - report(node); - } - } - } - } - }; - } -}; diff --git a/tools/eslint/node_modules/eslint/lib/rules/func-call-spacing.js b/tools/eslint/node_modules/eslint/lib/rules/func-call-spacing.js deleted file mode 100644 index 33f73727b43c3b..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/rules/func-call-spacing.js +++ /dev/null @@ -1,233 +0,0 @@ -/** - * @fileoverview Rule to control spacing within function calls - * @author Matt DuVall - * @deprecated in ESLint v8.53.0 - */ - -"use strict"; - -//------------------------------------------------------------------------------ -// Requirements -//------------------------------------------------------------------------------ - -const astUtils = require("./utils/ast-utils"); - -//------------------------------------------------------------------------------ -// Rule Definition -//------------------------------------------------------------------------------ - -/** @type {import('../shared/types').Rule} */ -module.exports = { - meta: { - deprecated: true, - replacedBy: [], - type: "layout", - - docs: { - description: "Require or disallow spacing between function identifiers and their invocations", - recommended: false, - url: "https://eslint.org/docs/latest/rules/func-call-spacing" - }, - - fixable: "whitespace", - - schema: { - anyOf: [ - { - type: "array", - items: [ - { - enum: ["never"] - } - ], - minItems: 0, - maxItems: 1 - }, - { - type: "array", - items: [ - { - enum: ["always"] - }, - { - type: "object", - properties: { - allowNewlines: { - type: "boolean" - } - }, - additionalProperties: false - } - ], - minItems: 0, - maxItems: 2 - } - ] - }, - - messages: { - unexpectedWhitespace: "Unexpected whitespace between function name and paren.", - unexpectedNewline: "Unexpected newline between function name and paren.", - missing: "Missing space between function name and paren." - } - }, - - create(context) { - - const never = context.options[0] !== "always"; - const allowNewlines = !never && context.options[1] && context.options[1].allowNewlines; - const sourceCode = context.sourceCode; - const text = sourceCode.getText(); - - /** - * Check if open space is present in a function name - * @param {ASTNode} node node to evaluate - * @param {Token} leftToken The last token of the callee. This may be the closing parenthesis that encloses the callee. - * @param {Token} rightToken Tha first token of the arguments. this is the opening parenthesis that encloses the arguments. - * @returns {void} - * @private - */ - function checkSpacing(node, leftToken, rightToken) { - const textBetweenTokens = text.slice(leftToken.range[1], rightToken.range[0]).replace(/\/\*.*?\*\//gu, ""); - const hasWhitespace = /\s/u.test(textBetweenTokens); - const hasNewline = hasWhitespace && astUtils.LINEBREAK_MATCHER.test(textBetweenTokens); - - /* - * never allowNewlines hasWhitespace hasNewline message - * F F F F Missing space between function name and paren. - * F F F T (Invalid `!hasWhitespace && hasNewline`) - * F F T T Unexpected newline between function name and paren. - * F F T F (OK) - * F T T F (OK) - * F T T T (OK) - * F T F T (Invalid `!hasWhitespace && hasNewline`) - * F T F F Missing space between function name and paren. - * T T F F (Invalid `never && allowNewlines`) - * T T F T (Invalid `!hasWhitespace && hasNewline`) - * T T T T (Invalid `never && allowNewlines`) - * T T T F (Invalid `never && allowNewlines`) - * T F T F Unexpected space between function name and paren. - * T F T T Unexpected space between function name and paren. - * T F F T (Invalid `!hasWhitespace && hasNewline`) - * T F F F (OK) - * - * T T Unexpected space between function name and paren. - * F F Missing space between function name and paren. - * F F T Unexpected newline between function name and paren. - */ - - if (never && hasWhitespace) { - context.report({ - node, - loc: { - start: leftToken.loc.end, - end: { - line: rightToken.loc.start.line, - column: rightToken.loc.start.column - 1 - } - }, - messageId: "unexpectedWhitespace", - fix(fixer) { - - // Don't remove comments. - if (sourceCode.commentsExistBetween(leftToken, rightToken)) { - return null; - } - - // If `?.` exists, it doesn't hide no-unexpected-multiline errors - if (node.optional) { - return fixer.replaceTextRange([leftToken.range[1], rightToken.range[0]], "?."); - } - - /* - * Only autofix if there is no newline - * https://github.com/eslint/eslint/issues/7787 - */ - if (hasNewline) { - return null; - } - return fixer.removeRange([leftToken.range[1], rightToken.range[0]]); - } - }); - } else if (!never && !hasWhitespace) { - context.report({ - node, - loc: { - start: { - line: leftToken.loc.end.line, - column: leftToken.loc.end.column - 1 - }, - end: rightToken.loc.start - }, - messageId: "missing", - fix(fixer) { - if (node.optional) { - return null; // Not sure if inserting a space to either before/after `?.` token. - } - return fixer.insertTextBefore(rightToken, " "); - } - }); - } else if (!never && !allowNewlines && hasNewline) { - context.report({ - node, - loc: { - start: leftToken.loc.end, - end: rightToken.loc.start - }, - messageId: "unexpectedNewline", - fix(fixer) { - - /* - * Only autofix if there is no newline - * https://github.com/eslint/eslint/issues/7787 - * But if `?.` exists, it doesn't hide no-unexpected-multiline errors - */ - if (!node.optional) { - return null; - } - - // Don't remove comments. - if (sourceCode.commentsExistBetween(leftToken, rightToken)) { - return null; - } - - const range = [leftToken.range[1], rightToken.range[0]]; - const qdToken = sourceCode.getTokenAfter(leftToken); - - if (qdToken.range[0] === leftToken.range[1]) { - return fixer.replaceTextRange(range, "?. "); - } - if (qdToken.range[1] === rightToken.range[0]) { - return fixer.replaceTextRange(range, " ?."); - } - return fixer.replaceTextRange(range, " ?. "); - } - }); - } - } - - return { - "CallExpression, NewExpression"(node) { - const lastToken = sourceCode.getLastToken(node); - const lastCalleeToken = sourceCode.getLastToken(node.callee); - const parenToken = sourceCode.getFirstTokenBetween(lastCalleeToken, lastToken, astUtils.isOpeningParenToken); - const prevToken = parenToken && sourceCode.getTokenBefore(parenToken, astUtils.isNotQuestionDotToken); - - // Parens in NewExpression are optional - if (!(parenToken && parenToken.range[1] < node.range[1])) { - return; - } - - checkSpacing(node, prevToken, parenToken); - }, - - ImportExpression(node) { - const leftToken = sourceCode.getFirstToken(node); - const rightToken = sourceCode.getTokenAfter(leftToken); - - checkSpacing(node, leftToken, rightToken); - } - }; - - } -}; diff --git a/tools/eslint/node_modules/eslint/lib/rules/func-name-matching.js b/tools/eslint/node_modules/eslint/lib/rules/func-name-matching.js deleted file mode 100644 index b9555d6bdf4e3a..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/rules/func-name-matching.js +++ /dev/null @@ -1,253 +0,0 @@ -/** - * @fileoverview Rule to require function names to match the name of the variable or property to which they are assigned. - * @author Annie Zhang, Pavel Strashkin - */ - -"use strict"; - -//-------------------------------------------------------------------------- -// Requirements -//-------------------------------------------------------------------------- - -const astUtils = require("./utils/ast-utils"); -const esutils = require("esutils"); - -//-------------------------------------------------------------------------- -// Helpers -//-------------------------------------------------------------------------- - -/** - * Determines if a pattern is `module.exports` or `module["exports"]` - * @param {ASTNode} pattern The left side of the AssignmentExpression - * @returns {boolean} True if the pattern is `module.exports` or `module["exports"]` - */ -function isModuleExports(pattern) { - if (pattern.type === "MemberExpression" && pattern.object.type === "Identifier" && pattern.object.name === "module") { - - // module.exports - if (pattern.property.type === "Identifier" && pattern.property.name === "exports") { - return true; - } - - // module["exports"] - if (pattern.property.type === "Literal" && pattern.property.value === "exports") { - return true; - } - } - return false; -} - -/** - * Determines if a string name is a valid identifier - * @param {string} name The string to be checked - * @param {int} ecmaVersion The ECMAScript version if specified in the parserOptions config - * @returns {boolean} True if the string is a valid identifier - */ -function isIdentifier(name, ecmaVersion) { - if (ecmaVersion >= 2015) { - return esutils.keyword.isIdentifierES6(name); - } - return esutils.keyword.isIdentifierES5(name); -} - -//------------------------------------------------------------------------------ -// Rule Definition -//------------------------------------------------------------------------------ - -const alwaysOrNever = { enum: ["always", "never"] }; -const optionsObject = { - type: "object", - properties: { - considerPropertyDescriptor: { - type: "boolean" - }, - includeCommonJSModuleExports: { - type: "boolean" - } - }, - additionalProperties: false -}; - -/** @type {import('../shared/types').Rule} */ -module.exports = { - meta: { - type: "suggestion", - - docs: { - description: "Require function names to match the name of the variable or property to which they are assigned", - recommended: false, - url: "https://eslint.org/docs/latest/rules/func-name-matching" - }, - - schema: { - anyOf: [{ - type: "array", - additionalItems: false, - items: [alwaysOrNever, optionsObject] - }, { - type: "array", - additionalItems: false, - items: [optionsObject] - }] - }, - - messages: { - matchProperty: "Function name `{{funcName}}` should match property name `{{name}}`.", - matchVariable: "Function name `{{funcName}}` should match variable name `{{name}}`.", - notMatchProperty: "Function name `{{funcName}}` should not match property name `{{name}}`.", - notMatchVariable: "Function name `{{funcName}}` should not match variable name `{{name}}`." - } - }, - - create(context) { - const options = (typeof context.options[0] === "object" ? context.options[0] : context.options[1]) || {}; - const nameMatches = typeof context.options[0] === "string" ? context.options[0] : "always"; - const considerPropertyDescriptor = options.considerPropertyDescriptor; - const includeModuleExports = options.includeCommonJSModuleExports; - const ecmaVersion = context.languageOptions.ecmaVersion; - - /** - * Check whether node is a certain CallExpression. - * @param {string} objName object name - * @param {string} funcName function name - * @param {ASTNode} node The node to check - * @returns {boolean} `true` if node matches CallExpression - */ - function isPropertyCall(objName, funcName, node) { - if (!node) { - return false; - } - return node.type === "CallExpression" && astUtils.isSpecificMemberAccess(node.callee, objName, funcName); - } - - /** - * Compares identifiers based on the nameMatches option - * @param {string} x the first identifier - * @param {string} y the second identifier - * @returns {boolean} whether the two identifiers should warn. - */ - function shouldWarn(x, y) { - return (nameMatches === "always" && x !== y) || (nameMatches === "never" && x === y); - } - - /** - * Reports - * @param {ASTNode} node The node to report - * @param {string} name The variable or property name - * @param {string} funcName The function name - * @param {boolean} isProp True if the reported node is a property assignment - * @returns {void} - */ - function report(node, name, funcName, isProp) { - let messageId; - - if (nameMatches === "always" && isProp) { - messageId = "matchProperty"; - } else if (nameMatches === "always") { - messageId = "matchVariable"; - } else if (isProp) { - messageId = "notMatchProperty"; - } else { - messageId = "notMatchVariable"; - } - context.report({ - node, - messageId, - data: { - name, - funcName - } - }); - } - - /** - * Determines whether a given node is a string literal - * @param {ASTNode} node The node to check - * @returns {boolean} `true` if the node is a string literal - */ - function isStringLiteral(node) { - return node.type === "Literal" && typeof node.value === "string"; - } - - //-------------------------------------------------------------------------- - // Public - //-------------------------------------------------------------------------- - - return { - VariableDeclarator(node) { - if (!node.init || node.init.type !== "FunctionExpression" || node.id.type !== "Identifier") { - return; - } - if (node.init.id && shouldWarn(node.id.name, node.init.id.name)) { - report(node, node.id.name, node.init.id.name, false); - } - }, - - AssignmentExpression(node) { - if ( - node.right.type !== "FunctionExpression" || - (node.left.computed && node.left.property.type !== "Literal") || - (!includeModuleExports && isModuleExports(node.left)) || - (node.left.type !== "Identifier" && node.left.type !== "MemberExpression") - ) { - return; - } - - const isProp = node.left.type === "MemberExpression"; - const name = isProp ? astUtils.getStaticPropertyName(node.left) : node.left.name; - - if (node.right.id && name && isIdentifier(name) && shouldWarn(name, node.right.id.name)) { - report(node, name, node.right.id.name, isProp); - } - }, - - "Property, PropertyDefinition[value]"(node) { - if (!(node.value.type === "FunctionExpression" && node.value.id)) { - return; - } - - if (node.key.type === "Identifier" && !node.computed) { - const functionName = node.value.id.name; - let propertyName = node.key.name; - - if ( - considerPropertyDescriptor && - propertyName === "value" && - node.parent.type === "ObjectExpression" - ) { - if (isPropertyCall("Object", "defineProperty", node.parent.parent) || isPropertyCall("Reflect", "defineProperty", node.parent.parent)) { - const property = node.parent.parent.arguments[1]; - - if (isStringLiteral(property) && shouldWarn(property.value, functionName)) { - report(node, property.value, functionName, true); - } - } else if (isPropertyCall("Object", "defineProperties", node.parent.parent.parent.parent)) { - propertyName = node.parent.parent.key.name; - if (!node.parent.parent.computed && shouldWarn(propertyName, functionName)) { - report(node, propertyName, functionName, true); - } - } else if (isPropertyCall("Object", "create", node.parent.parent.parent.parent)) { - propertyName = node.parent.parent.key.name; - if (!node.parent.parent.computed && shouldWarn(propertyName, functionName)) { - report(node, propertyName, functionName, true); - } - } else if (shouldWarn(propertyName, functionName)) { - report(node, propertyName, functionName, true); - } - } else if (shouldWarn(propertyName, functionName)) { - report(node, propertyName, functionName, true); - } - return; - } - - if ( - isStringLiteral(node.key) && - isIdentifier(node.key.value, ecmaVersion) && - shouldWarn(node.key.value, node.value.id.name) - ) { - report(node, node.key.value, node.value.id.name, true); - } - } - }; - } -}; diff --git a/tools/eslint/node_modules/eslint/lib/rules/func-names.js b/tools/eslint/node_modules/eslint/lib/rules/func-names.js deleted file mode 100644 index b180580e114091..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/rules/func-names.js +++ /dev/null @@ -1,191 +0,0 @@ -/** - * @fileoverview Rule to warn when a function expression does not have a name. - * @author Kyle T. Nunery - */ - -"use strict"; - -//------------------------------------------------------------------------------ -// Requirements -//------------------------------------------------------------------------------ - -const astUtils = require("./utils/ast-utils"); - -/** - * Checks whether or not a given variable is a function name. - * @param {eslint-scope.Variable} variable A variable to check. - * @returns {boolean} `true` if the variable is a function name. - */ -function isFunctionName(variable) { - return variable && variable.defs[0].type === "FunctionName"; -} - -//------------------------------------------------------------------------------ -// Rule Definition -//------------------------------------------------------------------------------ - -/** @type {import('../shared/types').Rule} */ -module.exports = { - meta: { - type: "suggestion", - - docs: { - description: "Require or disallow named `function` expressions", - recommended: false, - url: "https://eslint.org/docs/latest/rules/func-names" - }, - - schema: { - definitions: { - value: { - enum: [ - "always", - "as-needed", - "never" - ] - } - }, - items: [ - { - $ref: "#/definitions/value" - }, - { - type: "object", - properties: { - generators: { - $ref: "#/definitions/value" - } - }, - additionalProperties: false - } - ] - }, - - messages: { - unnamed: "Unexpected unnamed {{name}}.", - named: "Unexpected named {{name}}." - } - }, - - create(context) { - - const sourceCode = context.sourceCode; - - /** - * Returns the config option for the given node. - * @param {ASTNode} node A node to get the config for. - * @returns {string} The config option. - */ - function getConfigForNode(node) { - if ( - node.generator && - context.options.length > 1 && - context.options[1].generators - ) { - return context.options[1].generators; - } - - return context.options[0] || "always"; - } - - /** - * Determines whether the current FunctionExpression node is a get, set, or - * shorthand method in an object literal or a class. - * @param {ASTNode} node A node to check. - * @returns {boolean} True if the node is a get, set, or shorthand method. - */ - function isObjectOrClassMethod(node) { - const parent = node.parent; - - return (parent.type === "MethodDefinition" || ( - parent.type === "Property" && ( - parent.method || - parent.kind === "get" || - parent.kind === "set" - ) - )); - } - - /** - * Determines whether the current FunctionExpression node has a name that would be - * inferred from context in a conforming ES6 environment. - * @param {ASTNode} node A node to check. - * @returns {boolean} True if the node would have a name assigned automatically. - */ - function hasInferredName(node) { - const parent = node.parent; - - return isObjectOrClassMethod(node) || - (parent.type === "VariableDeclarator" && parent.id.type === "Identifier" && parent.init === node) || - (parent.type === "Property" && parent.value === node) || - (parent.type === "PropertyDefinition" && parent.value === node) || - (parent.type === "AssignmentExpression" && parent.left.type === "Identifier" && parent.right === node) || - (parent.type === "AssignmentPattern" && parent.left.type === "Identifier" && parent.right === node); - } - - /** - * Reports that an unnamed function should be named - * @param {ASTNode} node The node to report in the event of an error. - * @returns {void} - */ - function reportUnexpectedUnnamedFunction(node) { - context.report({ - node, - messageId: "unnamed", - loc: astUtils.getFunctionHeadLoc(node, sourceCode), - data: { name: astUtils.getFunctionNameWithKind(node) } - }); - } - - /** - * Reports that a named function should be unnamed - * @param {ASTNode} node The node to report in the event of an error. - * @returns {void} - */ - function reportUnexpectedNamedFunction(node) { - context.report({ - node, - messageId: "named", - loc: astUtils.getFunctionHeadLoc(node, sourceCode), - data: { name: astUtils.getFunctionNameWithKind(node) } - }); - } - - /** - * The listener for function nodes. - * @param {ASTNode} node function node - * @returns {void} - */ - function handleFunction(node) { - - // Skip recursive functions. - const nameVar = sourceCode.getDeclaredVariables(node)[0]; - - if (isFunctionName(nameVar) && nameVar.references.length > 0) { - return; - } - - const hasName = Boolean(node.id && node.id.name); - const config = getConfigForNode(node); - - if (config === "never") { - if (hasName && node.type !== "FunctionDeclaration") { - reportUnexpectedNamedFunction(node); - } - } else if (config === "as-needed") { - if (!hasName && !hasInferredName(node)) { - reportUnexpectedUnnamedFunction(node); - } - } else { - if (!hasName && !isObjectOrClassMethod(node)) { - reportUnexpectedUnnamedFunction(node); - } - } - } - - return { - "FunctionExpression:exit": handleFunction, - "ExportDefaultDeclaration > FunctionDeclaration": handleFunction - }; - } -}; diff --git a/tools/eslint/node_modules/eslint/lib/rules/func-style.js b/tools/eslint/node_modules/eslint/lib/rules/func-style.js deleted file mode 100644 index d71f4ae80b207b..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/rules/func-style.js +++ /dev/null @@ -1,136 +0,0 @@ -/** - * @fileoverview Rule to enforce a particular function style - * @author Nicholas C. Zakas - */ -"use strict"; - -//------------------------------------------------------------------------------ -// Rule Definition -//------------------------------------------------------------------------------ - -/** @type {import('../shared/types').Rule} */ -module.exports = { - meta: { - type: "suggestion", - - docs: { - description: "Enforce the consistent use of either `function` declarations or expressions assigned to variables", - recommended: false, - url: "https://eslint.org/docs/latest/rules/func-style" - }, - - schema: [ - { - enum: ["declaration", "expression"] - }, - { - type: "object", - properties: { - allowArrowFunctions: { - type: "boolean", - default: false - }, - overrides: { - type: "object", - properties: { - namedExports: { - enum: ["declaration", "expression", "ignore"] - } - }, - additionalProperties: false - } - }, - additionalProperties: false - } - ], - - messages: { - expression: "Expected a function expression.", - declaration: "Expected a function declaration." - } - }, - - create(context) { - - const style = context.options[0], - allowArrowFunctions = context.options[1] && context.options[1].allowArrowFunctions, - enforceDeclarations = (style === "declaration"), - exportFunctionStyle = context.options[1] && context.options[1].overrides && context.options[1].overrides.namedExports, - stack = []; - - const nodesToCheck = { - FunctionDeclaration(node) { - stack.push(false); - - if ( - !enforceDeclarations && - node.parent.type !== "ExportDefaultDeclaration" && - (typeof exportFunctionStyle === "undefined" || node.parent.type !== "ExportNamedDeclaration") - ) { - context.report({ node, messageId: "expression" }); - } - - if (node.parent.type === "ExportNamedDeclaration" && exportFunctionStyle === "expression") { - context.report({ node, messageId: "expression" }); - } - }, - "FunctionDeclaration:exit"() { - stack.pop(); - }, - - FunctionExpression(node) { - stack.push(false); - - if ( - enforceDeclarations && - node.parent.type === "VariableDeclarator" && - (typeof exportFunctionStyle === "undefined" || node.parent.parent.parent.type !== "ExportNamedDeclaration") - ) { - context.report({ node: node.parent, messageId: "declaration" }); - } - - if ( - node.parent.type === "VariableDeclarator" && node.parent.parent.parent.type === "ExportNamedDeclaration" && - exportFunctionStyle === "declaration" - ) { - context.report({ node: node.parent, messageId: "declaration" }); - } - }, - "FunctionExpression:exit"() { - stack.pop(); - }, - - "ThisExpression, Super"() { - if (stack.length > 0) { - stack[stack.length - 1] = true; - } - } - }; - - if (!allowArrowFunctions) { - nodesToCheck.ArrowFunctionExpression = function() { - stack.push(false); - }; - - nodesToCheck["ArrowFunctionExpression:exit"] = function(node) { - const hasThisOrSuperExpr = stack.pop(); - - if (!hasThisOrSuperExpr && node.parent.type === "VariableDeclarator") { - if ( - enforceDeclarations && - (typeof exportFunctionStyle === "undefined" || node.parent.parent.parent.type !== "ExportNamedDeclaration") - ) { - context.report({ node: node.parent, messageId: "declaration" }); - } - - if (node.parent.parent.parent.type === "ExportNamedDeclaration" && exportFunctionStyle === "declaration") { - context.report({ node: node.parent, messageId: "declaration" }); - } - } - }; - } - - return nodesToCheck; - - } -}; diff --git a/tools/eslint/node_modules/eslint/lib/rules/function-call-argument-newline.js b/tools/eslint/node_modules/eslint/lib/rules/function-call-argument-newline.js deleted file mode 100644 index 458399d62cd9bc..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/rules/function-call-argument-newline.js +++ /dev/null @@ -1,125 +0,0 @@ -/** - * @fileoverview Rule to enforce line breaks between arguments of a function call - * @author Alexey Gonchar - * @deprecated in ESLint v8.53.0 - */ - -"use strict"; - -//------------------------------------------------------------------------------ -// Rule Definition -//------------------------------------------------------------------------------ - -/** @type {import('../shared/types').Rule} */ -module.exports = { - meta: { - deprecated: true, - replacedBy: [], - type: "layout", - - docs: { - description: "Enforce line breaks between arguments of a function call", - recommended: false, - url: "https://eslint.org/docs/latest/rules/function-call-argument-newline" - }, - - fixable: "whitespace", - - schema: [ - { - enum: ["always", "never", "consistent"] - } - ], - - messages: { - unexpectedLineBreak: "There should be no line break here.", - missingLineBreak: "There should be a line break after this argument." - } - }, - - create(context) { - const sourceCode = context.sourceCode; - - const checkers = { - unexpected: { - messageId: "unexpectedLineBreak", - check: (prevToken, currentToken) => prevToken.loc.end.line !== currentToken.loc.start.line, - createFix: (token, tokenBefore) => fixer => - fixer.replaceTextRange([tokenBefore.range[1], token.range[0]], " ") - }, - missing: { - messageId: "missingLineBreak", - check: (prevToken, currentToken) => prevToken.loc.end.line === currentToken.loc.start.line, - createFix: (token, tokenBefore) => fixer => - fixer.replaceTextRange([tokenBefore.range[1], token.range[0]], "\n") - } - }; - - /** - * Check all arguments for line breaks in the CallExpression - * @param {CallExpression} node node to evaluate - * @param {{ messageId: string, check: Function }} checker selected checker - * @returns {void} - * @private - */ - function checkArguments(node, checker) { - for (let i = 1; i < node.arguments.length; i++) { - const prevArgToken = sourceCode.getLastToken(node.arguments[i - 1]); - const currentArgToken = sourceCode.getFirstToken(node.arguments[i]); - - if (checker.check(prevArgToken, currentArgToken)) { - const tokenBefore = sourceCode.getTokenBefore( - currentArgToken, - { includeComments: true } - ); - - const hasLineCommentBefore = tokenBefore.type === "Line"; - - context.report({ - node, - loc: { - start: tokenBefore.loc.end, - end: currentArgToken.loc.start - }, - messageId: checker.messageId, - fix: hasLineCommentBefore ? null : checker.createFix(currentArgToken, tokenBefore) - }); - } - } - } - - /** - * Check if open space is present in a function name - * @param {CallExpression} node node to evaluate - * @returns {void} - * @private - */ - function check(node) { - if (node.arguments.length < 2) { - return; - } - - const option = context.options[0] || "always"; - - if (option === "never") { - checkArguments(node, checkers.unexpected); - } else if (option === "always") { - checkArguments(node, checkers.missing); - } else if (option === "consistent") { - const firstArgToken = sourceCode.getLastToken(node.arguments[0]); - const secondArgToken = sourceCode.getFirstToken(node.arguments[1]); - - if (firstArgToken.loc.end.line === secondArgToken.loc.start.line) { - checkArguments(node, checkers.unexpected); - } else { - checkArguments(node, checkers.missing); - } - } - } - - return { - CallExpression: check, - NewExpression: check - }; - } -}; diff --git a/tools/eslint/node_modules/eslint/lib/rules/function-paren-newline.js b/tools/eslint/node_modules/eslint/lib/rules/function-paren-newline.js deleted file mode 100644 index 86268e52a1d557..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/rules/function-paren-newline.js +++ /dev/null @@ -1,292 +0,0 @@ -/** - * @fileoverview enforce consistent line breaks inside function parentheses - * @author Teddy Katz - * @deprecated in ESLint v8.53.0 - */ -"use strict"; - -//------------------------------------------------------------------------------ -// Requirements -//------------------------------------------------------------------------------ - -const astUtils = require("./utils/ast-utils"); - -//------------------------------------------------------------------------------ -// Rule Definition -//------------------------------------------------------------------------------ - -/** @type {import('../shared/types').Rule} */ -module.exports = { - meta: { - deprecated: true, - replacedBy: [], - type: "layout", - - docs: { - description: "Enforce consistent line breaks inside function parentheses", - recommended: false, - url: "https://eslint.org/docs/latest/rules/function-paren-newline" - }, - - fixable: "whitespace", - - schema: [ - { - oneOf: [ - { - enum: ["always", "never", "consistent", "multiline", "multiline-arguments"] - }, - { - type: "object", - properties: { - minItems: { - type: "integer", - minimum: 0 - } - }, - additionalProperties: false - } - ] - } - ], - - messages: { - expectedBefore: "Expected newline before ')'.", - expectedAfter: "Expected newline after '('.", - expectedBetween: "Expected newline between arguments/params.", - unexpectedBefore: "Unexpected newline before ')'.", - unexpectedAfter: "Unexpected newline after '('." - } - }, - - create(context) { - const sourceCode = context.sourceCode; - const rawOption = context.options[0] || "multiline"; - const multilineOption = rawOption === "multiline"; - const multilineArgumentsOption = rawOption === "multiline-arguments"; - const consistentOption = rawOption === "consistent"; - let minItems; - - if (typeof rawOption === "object") { - minItems = rawOption.minItems; - } else if (rawOption === "always") { - minItems = 0; - } else if (rawOption === "never") { - minItems = Infinity; - } else { - minItems = null; - } - - //---------------------------------------------------------------------- - // Helpers - //---------------------------------------------------------------------- - - /** - * Determines whether there should be newlines inside function parens - * @param {ASTNode[]} elements The arguments or parameters in the list - * @param {boolean} hasLeftNewline `true` if the left paren has a newline in the current code. - * @returns {boolean} `true` if there should be newlines inside the function parens - */ - function shouldHaveNewlines(elements, hasLeftNewline) { - if (multilineArgumentsOption && elements.length === 1) { - return hasLeftNewline; - } - if (multilineOption || multilineArgumentsOption) { - return elements.some((element, index) => index !== elements.length - 1 && element.loc.end.line !== elements[index + 1].loc.start.line); - } - if (consistentOption) { - return hasLeftNewline; - } - return elements.length >= minItems; - } - - /** - * Validates parens - * @param {Object} parens An object with keys `leftParen` for the left paren token, and `rightParen` for the right paren token - * @param {ASTNode[]} elements The arguments or parameters in the list - * @returns {void} - */ - function validateParens(parens, elements) { - const leftParen = parens.leftParen; - const rightParen = parens.rightParen; - const tokenAfterLeftParen = sourceCode.getTokenAfter(leftParen); - const tokenBeforeRightParen = sourceCode.getTokenBefore(rightParen); - const hasLeftNewline = !astUtils.isTokenOnSameLine(leftParen, tokenAfterLeftParen); - const hasRightNewline = !astUtils.isTokenOnSameLine(tokenBeforeRightParen, rightParen); - const needsNewlines = shouldHaveNewlines(elements, hasLeftNewline); - - if (hasLeftNewline && !needsNewlines) { - context.report({ - node: leftParen, - messageId: "unexpectedAfter", - fix(fixer) { - return sourceCode.getText().slice(leftParen.range[1], tokenAfterLeftParen.range[0]).trim() - - // If there is a comment between the ( and the first element, don't do a fix. - ? null - : fixer.removeRange([leftParen.range[1], tokenAfterLeftParen.range[0]]); - } - }); - } else if (!hasLeftNewline && needsNewlines) { - context.report({ - node: leftParen, - messageId: "expectedAfter", - fix: fixer => fixer.insertTextAfter(leftParen, "\n") - }); - } - - if (hasRightNewline && !needsNewlines) { - context.report({ - node: rightParen, - messageId: "unexpectedBefore", - fix(fixer) { - return sourceCode.getText().slice(tokenBeforeRightParen.range[1], rightParen.range[0]).trim() - - // If there is a comment between the last element and the ), don't do a fix. - ? null - : fixer.removeRange([tokenBeforeRightParen.range[1], rightParen.range[0]]); - } - }); - } else if (!hasRightNewline && needsNewlines) { - context.report({ - node: rightParen, - messageId: "expectedBefore", - fix: fixer => fixer.insertTextBefore(rightParen, "\n") - }); - } - } - - /** - * Validates a list of arguments or parameters - * @param {Object} parens An object with keys `leftParen` for the left paren token, and `rightParen` for the right paren token - * @param {ASTNode[]} elements The arguments or parameters in the list - * @returns {void} - */ - function validateArguments(parens, elements) { - const leftParen = parens.leftParen; - const tokenAfterLeftParen = sourceCode.getTokenAfter(leftParen); - const hasLeftNewline = !astUtils.isTokenOnSameLine(leftParen, tokenAfterLeftParen); - const needsNewlines = shouldHaveNewlines(elements, hasLeftNewline); - - for (let i = 0; i <= elements.length - 2; i++) { - const currentElement = elements[i]; - const nextElement = elements[i + 1]; - const hasNewLine = currentElement.loc.end.line !== nextElement.loc.start.line; - - if (!hasNewLine && needsNewlines) { - context.report({ - node: currentElement, - messageId: "expectedBetween", - fix: fixer => fixer.insertTextBefore(nextElement, "\n") - }); - } - } - } - - /** - * Gets the left paren and right paren tokens of a node. - * @param {ASTNode} node The node with parens - * @throws {TypeError} Unexpected node type. - * @returns {Object} An object with keys `leftParen` for the left paren token, and `rightParen` for the right paren token. - * Can also return `null` if an expression has no parens (e.g. a NewExpression with no arguments, or an ArrowFunctionExpression - * with a single parameter) - */ - function getParenTokens(node) { - switch (node.type) { - case "NewExpression": - if (!node.arguments.length && - !( - astUtils.isOpeningParenToken(sourceCode.getLastToken(node, { skip: 1 })) && - astUtils.isClosingParenToken(sourceCode.getLastToken(node)) && - node.callee.range[1] < node.range[1] - ) - ) { - - // If the NewExpression does not have parens (e.g. `new Foo`), return null. - return null; - } - - // falls through - - case "CallExpression": - return { - leftParen: sourceCode.getTokenAfter(node.callee, astUtils.isOpeningParenToken), - rightParen: sourceCode.getLastToken(node) - }; - - case "FunctionDeclaration": - case "FunctionExpression": { - const leftParen = sourceCode.getFirstToken(node, astUtils.isOpeningParenToken); - const rightParen = node.params.length - ? sourceCode.getTokenAfter(node.params.at(-1), astUtils.isClosingParenToken) - : sourceCode.getTokenAfter(leftParen); - - return { leftParen, rightParen }; - } - - case "ArrowFunctionExpression": { - const firstToken = sourceCode.getFirstToken(node, { skip: (node.async ? 1 : 0) }); - - if (!astUtils.isOpeningParenToken(firstToken)) { - - // If the ArrowFunctionExpression has a single param without parens, return null. - return null; - } - - const rightParen = node.params.length - ? sourceCode.getTokenAfter(node.params.at(-1), astUtils.isClosingParenToken) - : sourceCode.getTokenAfter(firstToken); - - return { - leftParen: firstToken, - rightParen - }; - } - - case "ImportExpression": { - const leftParen = sourceCode.getFirstToken(node, 1); - const rightParen = sourceCode.getLastToken(node); - - return { leftParen, rightParen }; - } - - default: - throw new TypeError(`unexpected node with type ${node.type}`); - } - } - - //---------------------------------------------------------------------- - // Public - //---------------------------------------------------------------------- - - return { - [[ - "ArrowFunctionExpression", - "CallExpression", - "FunctionDeclaration", - "FunctionExpression", - "ImportExpression", - "NewExpression" - ]](node) { - const parens = getParenTokens(node); - let params; - - if (node.type === "ImportExpression") { - params = [node.source]; - } else if (astUtils.isFunction(node)) { - params = node.params; - } else { - params = node.arguments; - } - - if (parens) { - validateParens(parens, params); - - if (multilineArgumentsOption) { - validateArguments(parens, params); - } - } - } - }; - } -}; diff --git a/tools/eslint/node_modules/eslint/lib/rules/generator-star-spacing.js b/tools/eslint/node_modules/eslint/lib/rules/generator-star-spacing.js deleted file mode 100644 index c633f979f84af8..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/rules/generator-star-spacing.js +++ /dev/null @@ -1,209 +0,0 @@ -/** - * @fileoverview Rule to check the spacing around the * in generator functions. - * @author Jamund Ferguson - * @deprecated in ESLint v8.53.0 - */ - -"use strict"; - -//------------------------------------------------------------------------------ -// Rule Definition -//------------------------------------------------------------------------------ - -const OVERRIDE_SCHEMA = { - oneOf: [ - { - enum: ["before", "after", "both", "neither"] - }, - { - type: "object", - properties: { - before: { type: "boolean" }, - after: { type: "boolean" } - }, - additionalProperties: false - } - ] -}; - -/** @type {import('../shared/types').Rule} */ -module.exports = { - meta: { - deprecated: true, - replacedBy: [], - type: "layout", - - docs: { - description: "Enforce consistent spacing around `*` operators in generator functions", - recommended: false, - url: "https://eslint.org/docs/latest/rules/generator-star-spacing" - }, - - fixable: "whitespace", - - schema: [ - { - oneOf: [ - { - enum: ["before", "after", "both", "neither"] - }, - { - type: "object", - properties: { - before: { type: "boolean" }, - after: { type: "boolean" }, - named: OVERRIDE_SCHEMA, - anonymous: OVERRIDE_SCHEMA, - method: OVERRIDE_SCHEMA - }, - additionalProperties: false - } - ] - } - ], - - messages: { - missingBefore: "Missing space before *.", - missingAfter: "Missing space after *.", - unexpectedBefore: "Unexpected space before *.", - unexpectedAfter: "Unexpected space after *." - } - }, - - create(context) { - - const optionDefinitions = { - before: { before: true, after: false }, - after: { before: false, after: true }, - both: { before: true, after: true }, - neither: { before: false, after: false } - }; - - /** - * Returns resolved option definitions based on an option and defaults - * @param {any} option The option object or string value - * @param {Object} defaults The defaults to use if options are not present - * @returns {Object} the resolved object definition - */ - function optionToDefinition(option, defaults) { - if (!option) { - return defaults; - } - - return typeof option === "string" - ? optionDefinitions[option] - : Object.assign({}, defaults, option); - } - - const modes = (function(option) { - const defaults = optionToDefinition(option, optionDefinitions.before); - - return { - named: optionToDefinition(option.named, defaults), - anonymous: optionToDefinition(option.anonymous, defaults), - method: optionToDefinition(option.method, defaults) - }; - }(context.options[0] || {})); - - const sourceCode = context.sourceCode; - - /** - * Checks if the given token is a star token or not. - * @param {Token} token The token to check. - * @returns {boolean} `true` if the token is a star token. - */ - function isStarToken(token) { - return token.value === "*" && token.type === "Punctuator"; - } - - /** - * Gets the generator star token of the given function node. - * @param {ASTNode} node The function node to get. - * @returns {Token} Found star token. - */ - function getStarToken(node) { - return sourceCode.getFirstToken( - (node.parent.method || node.parent.type === "MethodDefinition") ? node.parent : node, - isStarToken - ); - } - - /** - * capitalize a given string. - * @param {string} str the given string. - * @returns {string} the capitalized string. - */ - function capitalize(str) { - return str[0].toUpperCase() + str.slice(1); - } - - /** - * Checks the spacing between two tokens before or after the star token. - * @param {string} kind Either "named", "anonymous", or "method" - * @param {string} side Either "before" or "after". - * @param {Token} leftToken `function` keyword token if side is "before", or - * star token if side is "after". - * @param {Token} rightToken Star token if side is "before", or identifier - * token if side is "after". - * @returns {void} - */ - function checkSpacing(kind, side, leftToken, rightToken) { - if (!!(rightToken.range[0] - leftToken.range[1]) !== modes[kind][side]) { - const after = leftToken.value === "*"; - const spaceRequired = modes[kind][side]; - const node = after ? leftToken : rightToken; - const messageId = `${spaceRequired ? "missing" : "unexpected"}${capitalize(side)}`; - - context.report({ - node, - messageId, - fix(fixer) { - if (spaceRequired) { - if (after) { - return fixer.insertTextAfter(node, " "); - } - return fixer.insertTextBefore(node, " "); - } - return fixer.removeRange([leftToken.range[1], rightToken.range[0]]); - } - }); - } - } - - /** - * Enforces the spacing around the star if node is a generator function. - * @param {ASTNode} node A function expression or declaration node. - * @returns {void} - */ - function checkFunction(node) { - if (!node.generator) { - return; - } - - const starToken = getStarToken(node); - const prevToken = sourceCode.getTokenBefore(starToken); - const nextToken = sourceCode.getTokenAfter(starToken); - - let kind = "named"; - - if (node.parent.type === "MethodDefinition" || (node.parent.type === "Property" && node.parent.method)) { - kind = "method"; - } else if (!node.id) { - kind = "anonymous"; - } - - // Only check before when preceded by `function`|`static` keyword - if (!(kind === "method" && starToken === sourceCode.getFirstToken(node.parent))) { - checkSpacing(kind, "before", prevToken, starToken); - } - - checkSpacing(kind, "after", starToken, nextToken); - } - - return { - FunctionDeclaration: checkFunction, - FunctionExpression: checkFunction - }; - - } -}; diff --git a/tools/eslint/node_modules/eslint/lib/rules/getter-return.js b/tools/eslint/node_modules/eslint/lib/rules/getter-return.js deleted file mode 100644 index 79ebf3e0902b07..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/rules/getter-return.js +++ /dev/null @@ -1,204 +0,0 @@ -/** - * @fileoverview Enforces that a return statement is present in property getters. - * @author Aladdin-ADD(hh_2013@foxmail.com) - */ - -"use strict"; - -//------------------------------------------------------------------------------ -// Requirements -//------------------------------------------------------------------------------ - -const astUtils = require("./utils/ast-utils"); - -//------------------------------------------------------------------------------ -// Helpers -//------------------------------------------------------------------------------ - -const TARGET_NODE_TYPE = /^(?:Arrow)?FunctionExpression$/u; - -/** - * Checks all segments in a set and returns true if any are reachable. - * @param {Set} segments The segments to check. - * @returns {boolean} True if any segment is reachable; false otherwise. - */ -function isAnySegmentReachable(segments) { - - for (const segment of segments) { - if (segment.reachable) { - return true; - } - } - - return false; -} - -//------------------------------------------------------------------------------ -// Rule Definition -//------------------------------------------------------------------------------ - -/** @type {import('../shared/types').Rule} */ -module.exports = { - meta: { - type: "problem", - - docs: { - description: "Enforce `return` statements in getters", - recommended: true, - url: "https://eslint.org/docs/latest/rules/getter-return" - }, - - fixable: null, - - schema: [ - { - type: "object", - properties: { - allowImplicit: { - type: "boolean", - default: false - } - }, - additionalProperties: false - } - ], - - messages: { - expected: "Expected to return a value in {{name}}.", - expectedAlways: "Expected {{name}} to always return a value." - } - }, - - create(context) { - - const options = context.options[0] || { allowImplicit: false }; - const sourceCode = context.sourceCode; - - let funcInfo = { - upper: null, - codePath: null, - hasReturn: false, - shouldCheck: false, - node: null, - currentSegments: [] - }; - - /** - * Checks whether or not the last code path segment is reachable. - * Then reports this function if the segment is reachable. - * - * If the last code path segment is reachable, there are paths which are not - * returned or thrown. - * @param {ASTNode} node A node to check. - * @returns {void} - */ - function checkLastSegment(node) { - if (funcInfo.shouldCheck && - isAnySegmentReachable(funcInfo.currentSegments) - ) { - context.report({ - node, - loc: astUtils.getFunctionHeadLoc(node, sourceCode), - messageId: funcInfo.hasReturn ? "expectedAlways" : "expected", - data: { - name: astUtils.getFunctionNameWithKind(funcInfo.node) - } - }); - } - } - - /** - * Checks whether a node means a getter function. - * @param {ASTNode} node a node to check. - * @returns {boolean} if node means a getter, return true; else return false. - */ - function isGetter(node) { - const parent = node.parent; - - if (TARGET_NODE_TYPE.test(node.type) && node.body.type === "BlockStatement") { - if (parent.kind === "get") { - return true; - } - if (parent.type === "Property" && astUtils.getStaticPropertyName(parent) === "get" && parent.parent.type === "ObjectExpression") { - - // Object.defineProperty() or Reflect.defineProperty() - if (parent.parent.parent.type === "CallExpression") { - const callNode = parent.parent.parent.callee; - - if (astUtils.isSpecificMemberAccess(callNode, "Object", "defineProperty") || - astUtils.isSpecificMemberAccess(callNode, "Reflect", "defineProperty")) { - return true; - } - } - - // Object.defineProperties() or Object.create() - if (parent.parent.parent.type === "Property" && - parent.parent.parent.parent.type === "ObjectExpression" && - parent.parent.parent.parent.parent.type === "CallExpression") { - const callNode = parent.parent.parent.parent.parent.callee; - - return astUtils.isSpecificMemberAccess(callNode, "Object", "defineProperties") || - astUtils.isSpecificMemberAccess(callNode, "Object", "create"); - } - } - } - return false; - } - return { - - // Stacks this function's information. - onCodePathStart(codePath, node) { - funcInfo = { - upper: funcInfo, - codePath, - hasReturn: false, - shouldCheck: isGetter(node), - node, - currentSegments: new Set() - }; - }, - - // Pops this function's information. - onCodePathEnd() { - funcInfo = funcInfo.upper; - }, - onUnreachableCodePathSegmentStart(segment) { - funcInfo.currentSegments.add(segment); - }, - - onUnreachableCodePathSegmentEnd(segment) { - funcInfo.currentSegments.delete(segment); - }, - - onCodePathSegmentStart(segment) { - funcInfo.currentSegments.add(segment); - }, - - onCodePathSegmentEnd(segment) { - funcInfo.currentSegments.delete(segment); - }, - - // Checks the return statement is valid. - ReturnStatement(node) { - if (funcInfo.shouldCheck) { - funcInfo.hasReturn = true; - - // if allowImplicit: false, should also check node.argument - if (!options.allowImplicit && !node.argument) { - context.report({ - node, - messageId: "expected", - data: { - name: astUtils.getFunctionNameWithKind(funcInfo.node) - } - }); - } - } - }, - - // Reports a given function if the last path is reachable. - "FunctionExpression:exit": checkLastSegment, - "ArrowFunctionExpression:exit": checkLastSegment - }; - } -}; diff --git a/tools/eslint/node_modules/eslint/lib/rules/global-require.js b/tools/eslint/node_modules/eslint/lib/rules/global-require.js deleted file mode 100644 index deae9d2676f329..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/rules/global-require.js +++ /dev/null @@ -1,90 +0,0 @@ -/** - * @fileoverview Rule for disallowing require() outside of the top-level module context - * @author Jamund Ferguson - * @deprecated in ESLint v7.0.0 - */ - -"use strict"; - -const ACCEPTABLE_PARENTS = new Set([ - "AssignmentExpression", - "VariableDeclarator", - "MemberExpression", - "ExpressionStatement", - "CallExpression", - "ConditionalExpression", - "Program", - "VariableDeclaration", - "ChainExpression" -]); - -/** - * Finds the eslint-scope reference in the given scope. - * @param {Object} scope The scope to search. - * @param {ASTNode} node The identifier node. - * @returns {Reference|null} Returns the found reference or null if none were found. - */ -function findReference(scope, node) { - const references = scope.references.filter(reference => reference.identifier.range[0] === node.range[0] && - reference.identifier.range[1] === node.range[1]); - - if (references.length === 1) { - return references[0]; - } - - /* c8 ignore next */ - return null; - -} - -/** - * Checks if the given identifier node is shadowed in the given scope. - * @param {Object} scope The current scope. - * @param {ASTNode} node The identifier node to check. - * @returns {boolean} Whether or not the name is shadowed. - */ -function isShadowed(scope, node) { - const reference = findReference(scope, node); - - return reference && reference.resolved && reference.resolved.defs.length > 0; -} - -/** @type {import('../shared/types').Rule} */ -module.exports = { - meta: { - deprecated: true, - - replacedBy: [], - - type: "suggestion", - - docs: { - description: "Require `require()` calls to be placed at top-level module scope", - recommended: false, - url: "https://eslint.org/docs/latest/rules/global-require" - }, - - schema: [], - messages: { - unexpected: "Unexpected require()." - } - }, - - create(context) { - const sourceCode = context.sourceCode; - - return { - CallExpression(node) { - const currentScope = sourceCode.getScope(node); - - if (node.callee.name === "require" && !isShadowed(currentScope, node.callee)) { - const isGoodRequire = sourceCode.getAncestors(node).every(parent => ACCEPTABLE_PARENTS.has(parent.type)); - - if (!isGoodRequire) { - context.report({ node, messageId: "unexpected" }); - } - } - } - }; - } -}; diff --git a/tools/eslint/node_modules/eslint/lib/rules/grouped-accessor-pairs.js b/tools/eslint/node_modules/eslint/lib/rules/grouped-accessor-pairs.js deleted file mode 100644 index 9556f4756825a5..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/rules/grouped-accessor-pairs.js +++ /dev/null @@ -1,215 +0,0 @@ -/** - * @fileoverview Rule to require grouped accessor pairs in object literals and classes - * @author Milos Djermanovic - */ - -"use strict"; - -//------------------------------------------------------------------------------ -// Requirements -//------------------------------------------------------------------------------ - -const astUtils = require("./utils/ast-utils"); - -//------------------------------------------------------------------------------ -// Typedefs -//------------------------------------------------------------------------------ - -/** - * Property name if it can be computed statically, otherwise the list of the tokens of the key node. - * @typedef {string|Token[]} Key - */ - -/** - * Accessor nodes with the same key. - * @typedef {Object} AccessorData - * @property {Key} key Accessor's key - * @property {ASTNode[]} getters List of getter nodes. - * @property {ASTNode[]} setters List of setter nodes. - */ - -//------------------------------------------------------------------------------ -// Helpers -//------------------------------------------------------------------------------ - -/** - * Checks whether or not the given lists represent the equal tokens in the same order. - * Tokens are compared by their properties, not by instance. - * @param {Token[]} left First list of tokens. - * @param {Token[]} right Second list of tokens. - * @returns {boolean} `true` if the lists have same tokens. - */ -function areEqualTokenLists(left, right) { - if (left.length !== right.length) { - return false; - } - - for (let i = 0; i < left.length; i++) { - const leftToken = left[i], - rightToken = right[i]; - - if (leftToken.type !== rightToken.type || leftToken.value !== rightToken.value) { - return false; - } - } - - return true; -} - -/** - * Checks whether or not the given keys are equal. - * @param {Key} left First key. - * @param {Key} right Second key. - * @returns {boolean} `true` if the keys are equal. - */ -function areEqualKeys(left, right) { - if (typeof left === "string" && typeof right === "string") { - - // Statically computed names. - return left === right; - } - if (Array.isArray(left) && Array.isArray(right)) { - - // Token lists. - return areEqualTokenLists(left, right); - } - - return false; -} - -/** - * Checks whether or not a given node is of an accessor kind ('get' or 'set'). - * @param {ASTNode} node A node to check. - * @returns {boolean} `true` if the node is of an accessor kind. - */ -function isAccessorKind(node) { - return node.kind === "get" || node.kind === "set"; -} - -//------------------------------------------------------------------------------ -// Rule Definition -//------------------------------------------------------------------------------ - -/** @type {import('../shared/types').Rule} */ -module.exports = { - meta: { - type: "suggestion", - - docs: { - description: "Require grouped accessor pairs in object literals and classes", - recommended: false, - url: "https://eslint.org/docs/latest/rules/grouped-accessor-pairs" - }, - - schema: [ - { - enum: ["anyOrder", "getBeforeSet", "setBeforeGet"] - } - ], - - messages: { - notGrouped: "Accessor pair {{ formerName }} and {{ latterName }} should be grouped.", - invalidOrder: "Expected {{ latterName }} to be before {{ formerName }}." - } - }, - - create(context) { - const order = context.options[0] || "anyOrder"; - const sourceCode = context.sourceCode; - - /** - * Reports the given accessor pair. - * @param {string} messageId messageId to report. - * @param {ASTNode} formerNode getter/setter node that is defined before `latterNode`. - * @param {ASTNode} latterNode getter/setter node that is defined after `formerNode`. - * @returns {void} - * @private - */ - function report(messageId, formerNode, latterNode) { - context.report({ - node: latterNode, - messageId, - loc: astUtils.getFunctionHeadLoc(latterNode.value, sourceCode), - data: { - formerName: astUtils.getFunctionNameWithKind(formerNode.value), - latterName: astUtils.getFunctionNameWithKind(latterNode.value) - } - }); - } - - /** - * Checks accessor pairs in the given list of nodes. - * @param {ASTNode[]} nodes The list to check. - * @param {Function} shouldCheck โ€“ Predicate that returns `true` if the node should be checked. - * @returns {void} - * @private - */ - function checkList(nodes, shouldCheck) { - const accessors = []; - let found = false; - - for (let i = 0; i < nodes.length; i++) { - const node = nodes[i]; - - if (shouldCheck(node) && isAccessorKind(node)) { - - // Creates a new `AccessorData` object for the given getter or setter node. - const name = astUtils.getStaticPropertyName(node); - const key = (name !== null) ? name : sourceCode.getTokens(node.key); - - // Merges the given `AccessorData` object into the given accessors list. - for (let j = 0; j < accessors.length; j++) { - const accessor = accessors[j]; - - if (areEqualKeys(accessor.key, key)) { - accessor.getters.push(...node.kind === "get" ? [node] : []); - accessor.setters.push(...node.kind === "set" ? [node] : []); - found = true; - break; - } - } - if (!found) { - accessors.push({ - key, - getters: node.kind === "get" ? [node] : [], - setters: node.kind === "set" ? [node] : [] - }); - } - found = false; - } - } - - for (const { getters, setters } of accessors) { - - // Don't report accessor properties that have duplicate getters or setters. - if (getters.length === 1 && setters.length === 1) { - const [getter] = getters, - [setter] = setters, - getterIndex = nodes.indexOf(getter), - setterIndex = nodes.indexOf(setter), - formerNode = getterIndex < setterIndex ? getter : setter, - latterNode = getterIndex < setterIndex ? setter : getter; - - if (Math.abs(getterIndex - setterIndex) > 1) { - report("notGrouped", formerNode, latterNode); - } else if ( - (order === "getBeforeSet" && getterIndex > setterIndex) || - (order === "setBeforeGet" && getterIndex < setterIndex) - ) { - report("invalidOrder", formerNode, latterNode); - } - } - } - } - - return { - ObjectExpression(node) { - checkList(node.properties, n => n.type === "Property"); - }, - ClassBody(node) { - checkList(node.body, n => n.type === "MethodDefinition" && !n.static); - checkList(node.body, n => n.type === "MethodDefinition" && n.static); - } - }; - } -}; diff --git a/tools/eslint/node_modules/eslint/lib/rules/guard-for-in.js b/tools/eslint/node_modules/eslint/lib/rules/guard-for-in.js deleted file mode 100644 index d6e70d0d75f72a..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/rules/guard-for-in.js +++ /dev/null @@ -1,76 +0,0 @@ -/** - * @fileoverview Rule to flag for-in loops without if statements inside - * @author Nicholas C. Zakas - */ - -"use strict"; - -//------------------------------------------------------------------------------ -// Rule Definition -//------------------------------------------------------------------------------ - -/** @type {import('../shared/types').Rule} */ -module.exports = { - meta: { - type: "suggestion", - - docs: { - description: "Require `for-in` loops to include an `if` statement", - recommended: false, - url: "https://eslint.org/docs/latest/rules/guard-for-in" - }, - - schema: [], - messages: { - wrap: "The body of a for-in should be wrapped in an if statement to filter unwanted properties from the prototype." - } - }, - - create(context) { - - return { - - ForInStatement(node) { - const body = node.body; - - // empty statement - if (body.type === "EmptyStatement") { - return; - } - - // if statement - if (body.type === "IfStatement") { - return; - } - - // empty block - if (body.type === "BlockStatement" && body.body.length === 0) { - return; - } - - // block with just if statement - if (body.type === "BlockStatement" && body.body.length === 1 && body.body[0].type === "IfStatement") { - return; - } - - // block that starts with if statement - if (body.type === "BlockStatement" && body.body.length >= 1 && body.body[0].type === "IfStatement") { - const i = body.body[0]; - - // ... whose consequent is a continue - if (i.consequent.type === "ContinueStatement") { - return; - } - - // ... whose consequent is a block that contains only a continue - if (i.consequent.type === "BlockStatement" && i.consequent.body.length === 1 && i.consequent.body[0].type === "ContinueStatement") { - return; - } - } - - context.report({ node, messageId: "wrap" }); - } - }; - - } -}; diff --git a/tools/eslint/node_modules/eslint/lib/rules/handle-callback-err.js b/tools/eslint/node_modules/eslint/lib/rules/handle-callback-err.js deleted file mode 100644 index ad84931a9ca1b1..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/rules/handle-callback-err.js +++ /dev/null @@ -1,101 +0,0 @@ -/** - * @fileoverview Ensure handling of errors when we know they exist. - * @author Jamund Ferguson - * @deprecated in ESLint v7.0.0 - */ - -"use strict"; - -//------------------------------------------------------------------------------ -// Rule Definition -//------------------------------------------------------------------------------ - -/** @type {import('../shared/types').Rule} */ -module.exports = { - meta: { - deprecated: true, - - replacedBy: [], - - type: "suggestion", - - docs: { - description: "Require error handling in callbacks", - recommended: false, - url: "https://eslint.org/docs/latest/rules/handle-callback-err" - }, - - schema: [ - { - type: "string" - } - ], - messages: { - expected: "Expected error to be handled." - } - }, - - create(context) { - - const errorArgument = context.options[0] || "err"; - const sourceCode = context.sourceCode; - - /** - * Checks if the given argument should be interpreted as a regexp pattern. - * @param {string} stringToCheck The string which should be checked. - * @returns {boolean} Whether or not the string should be interpreted as a pattern. - */ - function isPattern(stringToCheck) { - const firstChar = stringToCheck[0]; - - return firstChar === "^"; - } - - /** - * Checks if the given name matches the configured error argument. - * @param {string} name The name which should be compared. - * @returns {boolean} Whether or not the given name matches the configured error variable name. - */ - function matchesConfiguredErrorName(name) { - if (isPattern(errorArgument)) { - const regexp = new RegExp(errorArgument, "u"); - - return regexp.test(name); - } - return name === errorArgument; - } - - /** - * Get the parameters of a given function scope. - * @param {Object} scope The function scope. - * @returns {Array} All parameters of the given scope. - */ - function getParameters(scope) { - return scope.variables.filter(variable => variable.defs[0] && variable.defs[0].type === "Parameter"); - } - - /** - * Check to see if we're handling the error object properly. - * @param {ASTNode} node The AST node to check. - * @returns {void} - */ - function checkForError(node) { - const scope = sourceCode.getScope(node), - parameters = getParameters(scope), - firstParameter = parameters[0]; - - if (firstParameter && matchesConfiguredErrorName(firstParameter.name)) { - if (firstParameter.references.length === 0) { - context.report({ node, messageId: "expected" }); - } - } - } - - return { - FunctionDeclaration: checkForError, - FunctionExpression: checkForError, - ArrowFunctionExpression: checkForError - }; - - } -}; diff --git a/tools/eslint/node_modules/eslint/lib/rules/id-blacklist.js b/tools/eslint/node_modules/eslint/lib/rules/id-blacklist.js deleted file mode 100644 index 6b7f561ee03165..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/rules/id-blacklist.js +++ /dev/null @@ -1,246 +0,0 @@ -/** - * @fileoverview Rule that warns when identifier names that are - * specified in the configuration are used. - * @author Keith Cirkel (http://keithcirkel.co.uk) - * @deprecated in ESLint v7.5.0 - */ - -"use strict"; - -//------------------------------------------------------------------------------ -// Helpers -//------------------------------------------------------------------------------ - -/** - * Checks whether the given node represents assignment target in a normal assignment or destructuring. - * @param {ASTNode} node The node to check. - * @returns {boolean} `true` if the node is assignment target. - */ -function isAssignmentTarget(node) { - const parent = node.parent; - - return ( - - // normal assignment - ( - parent.type === "AssignmentExpression" && - parent.left === node - ) || - - // destructuring - parent.type === "ArrayPattern" || - parent.type === "RestElement" || - ( - parent.type === "Property" && - parent.value === node && - parent.parent.type === "ObjectPattern" - ) || - ( - parent.type === "AssignmentPattern" && - parent.left === node - ) - ); -} - -/** - * Checks whether the given node represents an imported name that is renamed in the same import/export specifier. - * - * Examples: - * import { a as b } from 'mod'; // node `a` is renamed import - * export { a as b } from 'mod'; // node `a` is renamed import - * @param {ASTNode} node `Identifier` node to check. - * @returns {boolean} `true` if the node is a renamed import. - */ -function isRenamedImport(node) { - const parent = node.parent; - - return ( - ( - parent.type === "ImportSpecifier" && - parent.imported !== parent.local && - parent.imported === node - ) || - ( - parent.type === "ExportSpecifier" && - parent.parent.source && // re-export - parent.local !== parent.exported && - parent.local === node - ) - ); -} - -/** - * Checks whether the given node is a renamed identifier node in an ObjectPattern destructuring. - * - * Examples: - * const { a : b } = foo; // node `a` is renamed node. - * @param {ASTNode} node `Identifier` node to check. - * @returns {boolean} `true` if the node is a renamed node in an ObjectPattern destructuring. - */ -function isRenamedInDestructuring(node) { - const parent = node.parent; - - return ( - ( - !parent.computed && - parent.type === "Property" && - parent.parent.type === "ObjectPattern" && - parent.value !== node && - parent.key === node - ) - ); -} - -/** - * Checks whether the given node represents shorthand definition of a property in an object literal. - * @param {ASTNode} node `Identifier` node to check. - * @returns {boolean} `true` if the node is a shorthand property definition. - */ -function isShorthandPropertyDefinition(node) { - const parent = node.parent; - - return ( - parent.type === "Property" && - parent.parent.type === "ObjectExpression" && - parent.shorthand - ); -} - -//------------------------------------------------------------------------------ -// Rule Definition -//------------------------------------------------------------------------------ - -/** @type {import('../shared/types').Rule} */ -module.exports = { - meta: { - deprecated: true, - replacedBy: ["id-denylist"], - - type: "suggestion", - - docs: { - description: "Disallow specified identifiers", - recommended: false, - url: "https://eslint.org/docs/latest/rules/id-blacklist" - }, - - schema: { - type: "array", - items: { - type: "string" - }, - uniqueItems: true - }, - messages: { - restricted: "Identifier '{{name}}' is restricted." - } - }, - - create(context) { - - const denyList = new Set(context.options); - const reportedNodes = new Set(); - const sourceCode = context.sourceCode; - - let globalScope; - - /** - * Checks whether the given name is restricted. - * @param {string} name The name to check. - * @returns {boolean} `true` if the name is restricted. - * @private - */ - function isRestricted(name) { - return denyList.has(name); - } - - /** - * Checks whether the given node represents a reference to a global variable that is not declared in the source code. - * These identifiers will be allowed, as it is assumed that user has no control over the names of external global variables. - * @param {ASTNode} node `Identifier` node to check. - * @returns {boolean} `true` if the node is a reference to a global variable. - */ - function isReferenceToGlobalVariable(node) { - const variable = globalScope.set.get(node.name); - - return variable && variable.defs.length === 0 && - variable.references.some(ref => ref.identifier === node); - } - - /** - * Determines whether the given node should be checked. - * @param {ASTNode} node `Identifier` node. - * @returns {boolean} `true` if the node should be checked. - */ - function shouldCheck(node) { - const parent = node.parent; - - /* - * Member access has special rules for checking property names. - * Read access to a property with a restricted name is allowed, because it can be on an object that user has no control over. - * Write access isn't allowed, because it potentially creates a new property with a restricted name. - */ - if ( - parent.type === "MemberExpression" && - parent.property === node && - !parent.computed - ) { - return isAssignmentTarget(parent); - } - - return ( - parent.type !== "CallExpression" && - parent.type !== "NewExpression" && - !isRenamedImport(node) && - !isRenamedInDestructuring(node) && - !( - isReferenceToGlobalVariable(node) && - !isShorthandPropertyDefinition(node) - ) - ); - } - - /** - * Reports an AST node as a rule violation. - * @param {ASTNode} node The node to report. - * @returns {void} - * @private - */ - function report(node) { - - /* - * We used the range instead of the node because it's possible - * for the same identifier to be represented by two different - * nodes, with the most clear example being shorthand properties: - * { foo } - * In this case, "foo" is represented by one node for the name - * and one for the value. The only way to know they are the same - * is to look at the range. - */ - if (!reportedNodes.has(node.range.toString())) { - context.report({ - node, - messageId: "restricted", - data: { - name: node.name - } - }); - reportedNodes.add(node.range.toString()); - } - - } - - return { - - Program(node) { - globalScope = sourceCode.getScope(node); - }, - - Identifier(node) { - if (isRestricted(node.name) && shouldCheck(node)) { - report(node); - } - } - }; - } -}; diff --git a/tools/eslint/node_modules/eslint/lib/rules/id-denylist.js b/tools/eslint/node_modules/eslint/lib/rules/id-denylist.js deleted file mode 100644 index baaa65fe01aa8a..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/rules/id-denylist.js +++ /dev/null @@ -1,228 +0,0 @@ -/** - * @fileoverview Rule that warns when identifier names that are - * specified in the configuration are used. - * @author Keith Cirkel (http://keithcirkel.co.uk) - */ - -"use strict"; - -//------------------------------------------------------------------------------ -// Helpers -//------------------------------------------------------------------------------ - -/** - * Checks whether the given node represents assignment target in a normal assignment or destructuring. - * @param {ASTNode} node The node to check. - * @returns {boolean} `true` if the node is assignment target. - */ -function isAssignmentTarget(node) { - const parent = node.parent; - - return ( - - // normal assignment - ( - parent.type === "AssignmentExpression" && - parent.left === node - ) || - - // destructuring - parent.type === "ArrayPattern" || - parent.type === "RestElement" || - ( - parent.type === "Property" && - parent.value === node && - parent.parent.type === "ObjectPattern" - ) || - ( - parent.type === "AssignmentPattern" && - parent.left === node - ) - ); -} - -/** - * Checks whether the given node represents an imported name that is renamed in the same import/export specifier. - * - * Examples: - * import { a as b } from 'mod'; // node `a` is renamed import - * export { a as b } from 'mod'; // node `a` is renamed import - * @param {ASTNode} node `Identifier` node to check. - * @returns {boolean} `true` if the node is a renamed import. - */ -function isRenamedImport(node) { - const parent = node.parent; - - return ( - ( - parent.type === "ImportSpecifier" && - parent.imported !== parent.local && - parent.imported === node - ) || - ( - parent.type === "ExportSpecifier" && - parent.parent.source && // re-export - parent.local !== parent.exported && - parent.local === node - ) - ); -} - -/** - * Checks whether the given node is an ObjectPattern destructuring. - * - * Examples: - * const { a : b } = foo; - * @param {ASTNode} node `Identifier` node to check. - * @returns {boolean} `true` if the node is in an ObjectPattern destructuring. - */ -function isPropertyNameInDestructuring(node) { - const parent = node.parent; - - return ( - ( - !parent.computed && - parent.type === "Property" && - parent.parent.type === "ObjectPattern" && - parent.key === node - ) - ); -} - -//------------------------------------------------------------------------------ -// Rule Definition -//------------------------------------------------------------------------------ - -/** @type {import('../shared/types').Rule} */ -module.exports = { - meta: { - type: "suggestion", - - docs: { - description: "Disallow specified identifiers", - recommended: false, - url: "https://eslint.org/docs/latest/rules/id-denylist" - }, - - schema: { - type: "array", - items: { - type: "string" - }, - uniqueItems: true - }, - messages: { - restricted: "Identifier '{{name}}' is restricted.", - restrictedPrivate: "Identifier '#{{name}}' is restricted." - } - }, - - create(context) { - - const denyList = new Set(context.options); - const reportedNodes = new Set(); - const sourceCode = context.sourceCode; - - let globalScope; - - /** - * Checks whether the given name is restricted. - * @param {string} name The name to check. - * @returns {boolean} `true` if the name is restricted. - * @private - */ - function isRestricted(name) { - return denyList.has(name); - } - - /** - * Checks whether the given node represents a reference to a global variable that is not declared in the source code. - * These identifiers will be allowed, as it is assumed that user has no control over the names of external global variables. - * @param {ASTNode} node `Identifier` node to check. - * @returns {boolean} `true` if the node is a reference to a global variable. - */ - function isReferenceToGlobalVariable(node) { - const variable = globalScope.set.get(node.name); - - return variable && variable.defs.length === 0 && - variable.references.some(ref => ref.identifier === node); - } - - /** - * Determines whether the given node should be checked. - * @param {ASTNode} node `Identifier` node. - * @returns {boolean} `true` if the node should be checked. - */ - function shouldCheck(node) { - const parent = node.parent; - - /* - * Member access has special rules for checking property names. - * Read access to a property with a restricted name is allowed, because it can be on an object that user has no control over. - * Write access isn't allowed, because it potentially creates a new property with a restricted name. - */ - if ( - parent.type === "MemberExpression" && - parent.property === node && - !parent.computed - ) { - return isAssignmentTarget(parent); - } - - return ( - parent.type !== "CallExpression" && - parent.type !== "NewExpression" && - !isRenamedImport(node) && - !isPropertyNameInDestructuring(node) && - !isReferenceToGlobalVariable(node) - ); - } - - /** - * Reports an AST node as a rule violation. - * @param {ASTNode} node The node to report. - * @returns {void} - * @private - */ - function report(node) { - - /* - * We used the range instead of the node because it's possible - * for the same identifier to be represented by two different - * nodes, with the most clear example being shorthand properties: - * { foo } - * In this case, "foo" is represented by one node for the name - * and one for the value. The only way to know they are the same - * is to look at the range. - */ - if (!reportedNodes.has(node.range.toString())) { - const isPrivate = node.type === "PrivateIdentifier"; - - context.report({ - node, - messageId: isPrivate ? "restrictedPrivate" : "restricted", - data: { - name: node.name - } - }); - reportedNodes.add(node.range.toString()); - } - } - - return { - - Program(node) { - globalScope = sourceCode.getScope(node); - }, - - [[ - "Identifier", - "PrivateIdentifier" - ]](node) { - if (isRestricted(node.name) && shouldCheck(node)) { - report(node); - } - } - }; - } -}; diff --git a/tools/eslint/node_modules/eslint/lib/rules/id-length.js b/tools/eslint/node_modules/eslint/lib/rules/id-length.js deleted file mode 100644 index 97bc0e43006e9a..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/rules/id-length.js +++ /dev/null @@ -1,177 +0,0 @@ -/** - * @fileoverview Rule that warns when identifier names are shorter or longer - * than the values provided in configuration. - * @author Burak Yigit Kaya aka BYK - */ - -"use strict"; - -//------------------------------------------------------------------------------ -// Requirements -//------------------------------------------------------------------------------ - -const { getGraphemeCount } = require("../shared/string-utils"); - -//------------------------------------------------------------------------------ -// Rule Definition -//------------------------------------------------------------------------------ - -/** @type {import('../shared/types').Rule} */ -module.exports = { - meta: { - type: "suggestion", - - docs: { - description: "Enforce minimum and maximum identifier lengths", - recommended: false, - url: "https://eslint.org/docs/latest/rules/id-length" - }, - - schema: [ - { - type: "object", - properties: { - min: { - type: "integer", - default: 2 - }, - max: { - type: "integer" - }, - exceptions: { - type: "array", - uniqueItems: true, - items: { - type: "string" - } - }, - exceptionPatterns: { - type: "array", - uniqueItems: true, - items: { - type: "string" - } - }, - properties: { - enum: ["always", "never"] - } - }, - additionalProperties: false - } - ], - messages: { - tooShort: "Identifier name '{{name}}' is too short (< {{min}}).", - tooShortPrivate: "Identifier name '#{{name}}' is too short (< {{min}}).", - tooLong: "Identifier name '{{name}}' is too long (> {{max}}).", - tooLongPrivate: "Identifier name #'{{name}}' is too long (> {{max}})." - } - }, - - create(context) { - const options = context.options[0] || {}; - const minLength = typeof options.min !== "undefined" ? options.min : 2; - const maxLength = typeof options.max !== "undefined" ? options.max : Infinity; - const properties = options.properties !== "never"; - const exceptions = new Set(options.exceptions); - const exceptionPatterns = (options.exceptionPatterns || []).map(pattern => new RegExp(pattern, "u")); - const reportedNodes = new Set(); - - /** - * Checks if a string matches the provided exception patterns - * @param {string} name The string to check. - * @returns {boolean} if the string is a match - * @private - */ - function matchesExceptionPattern(name) { - return exceptionPatterns.some(pattern => pattern.test(name)); - } - - const SUPPORTED_EXPRESSIONS = { - MemberExpression: properties && function(parent) { - return !parent.computed && ( - - // regular property assignment - (parent.parent.left === parent && parent.parent.type === "AssignmentExpression" || - - // or the last identifier in an ObjectPattern destructuring - parent.parent.type === "Property" && parent.parent.value === parent && - parent.parent.parent.type === "ObjectPattern" && parent.parent.parent.parent.left === parent.parent.parent) - ); - }, - AssignmentPattern(parent, node) { - return parent.left === node; - }, - VariableDeclarator(parent, node) { - return parent.id === node; - }, - Property(parent, node) { - - if (parent.parent.type === "ObjectPattern") { - const isKeyAndValueSame = parent.value.name === parent.key.name; - - return ( - !isKeyAndValueSame && parent.value === node || - isKeyAndValueSame && parent.key === node && properties - ); - } - return properties && !parent.computed && parent.key.name === node.name; - }, - ImportDefaultSpecifier: true, - RestElement: true, - FunctionExpression: true, - ArrowFunctionExpression: true, - ClassDeclaration: true, - FunctionDeclaration: true, - MethodDefinition: true, - PropertyDefinition: true, - CatchClause: true, - ArrayPattern: true - }; - - return { - [[ - "Identifier", - "PrivateIdentifier" - ]](node) { - const name = node.name; - const parent = node.parent; - - const nameLength = getGraphemeCount(name); - - const isShort = nameLength < minLength; - const isLong = nameLength > maxLength; - - if (!(isShort || isLong) || exceptions.has(name) || matchesExceptionPattern(name)) { - return; // Nothing to report - } - - const isValidExpression = SUPPORTED_EXPRESSIONS[parent.type]; - - /* - * We used the range instead of the node because it's possible - * for the same identifier to be represented by two different - * nodes, with the most clear example being shorthand properties: - * { foo } - * In this case, "foo" is represented by one node for the name - * and one for the value. The only way to know they are the same - * is to look at the range. - */ - if (isValidExpression && !reportedNodes.has(node.range.toString()) && (isValidExpression === true || isValidExpression(parent, node))) { - reportedNodes.add(node.range.toString()); - - let messageId = isShort ? "tooShort" : "tooLong"; - - if (node.type === "PrivateIdentifier") { - messageId += "Private"; - } - - context.report({ - node, - messageId, - data: { name, min: minLength, max: maxLength } - }); - } - } - }; - } -}; diff --git a/tools/eslint/node_modules/eslint/lib/rules/id-match.js b/tools/eslint/node_modules/eslint/lib/rules/id-match.js deleted file mode 100644 index e225454e7718ec..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/rules/id-match.js +++ /dev/null @@ -1,299 +0,0 @@ -/** - * @fileoverview Rule to flag non-matching identifiers - * @author Matthieu Larcher - */ - -"use strict"; - -//------------------------------------------------------------------------------ -// Rule Definition -//------------------------------------------------------------------------------ - -/** @type {import('../shared/types').Rule} */ -module.exports = { - meta: { - type: "suggestion", - - docs: { - description: "Require identifiers to match a specified regular expression", - recommended: false, - url: "https://eslint.org/docs/latest/rules/id-match" - }, - - schema: [ - { - type: "string" - }, - { - type: "object", - properties: { - properties: { - type: "boolean", - default: false - }, - classFields: { - type: "boolean", - default: false - }, - onlyDeclarations: { - type: "boolean", - default: false - }, - ignoreDestructuring: { - type: "boolean", - default: false - } - }, - additionalProperties: false - } - ], - messages: { - notMatch: "Identifier '{{name}}' does not match the pattern '{{pattern}}'.", - notMatchPrivate: "Identifier '#{{name}}' does not match the pattern '{{pattern}}'." - } - }, - - create(context) { - - //-------------------------------------------------------------------------- - // Options - //-------------------------------------------------------------------------- - const pattern = context.options[0] || "^.+$", - regexp = new RegExp(pattern, "u"); - - const options = context.options[1] || {}, - checkProperties = !!options.properties, - checkClassFields = !!options.classFields, - onlyDeclarations = !!options.onlyDeclarations, - ignoreDestructuring = !!options.ignoreDestructuring; - - const sourceCode = context.sourceCode; - let globalScope; - - //-------------------------------------------------------------------------- - // Helpers - //-------------------------------------------------------------------------- - - // contains reported nodes to avoid reporting twice on destructuring with shorthand notation - const reportedNodes = new Set(); - const ALLOWED_PARENT_TYPES = new Set(["CallExpression", "NewExpression"]); - const DECLARATION_TYPES = new Set(["FunctionDeclaration", "VariableDeclarator"]); - const IMPORT_TYPES = new Set(["ImportSpecifier", "ImportNamespaceSpecifier", "ImportDefaultSpecifier"]); - - /** - * Checks whether the given node represents a reference to a global variable that is not declared in the source code. - * These identifiers will be allowed, as it is assumed that user has no control over the names of external global variables. - * @param {ASTNode} node `Identifier` node to check. - * @returns {boolean} `true` if the node is a reference to a global variable. - */ - function isReferenceToGlobalVariable(node) { - const variable = globalScope.set.get(node.name); - - return variable && variable.defs.length === 0 && - variable.references.some(ref => ref.identifier === node); - } - - /** - * Checks if a string matches the provided pattern - * @param {string} name The string to check. - * @returns {boolean} if the string is a match - * @private - */ - function isInvalid(name) { - return !regexp.test(name); - } - - /** - * Checks if a parent of a node is an ObjectPattern. - * @param {ASTNode} node The node to check. - * @returns {boolean} if the node is inside an ObjectPattern - * @private - */ - function isInsideObjectPattern(node) { - let { parent } = node; - - while (parent) { - if (parent.type === "ObjectPattern") { - return true; - } - - parent = parent.parent; - } - - return false; - } - - /** - * Verifies if we should report an error or not based on the effective - * parent node and the identifier name. - * @param {ASTNode} effectiveParent The effective parent node of the node to be reported - * @param {string} name The identifier name of the identifier node - * @returns {boolean} whether an error should be reported or not - */ - function shouldReport(effectiveParent, name) { - return (!onlyDeclarations || DECLARATION_TYPES.has(effectiveParent.type)) && - !ALLOWED_PARENT_TYPES.has(effectiveParent.type) && isInvalid(name); - } - - /** - * Reports an AST node as a rule violation. - * @param {ASTNode} node The node to report. - * @returns {void} - * @private - */ - function report(node) { - - /* - * We used the range instead of the node because it's possible - * for the same identifier to be represented by two different - * nodes, with the most clear example being shorthand properties: - * { foo } - * In this case, "foo" is represented by one node for the name - * and one for the value. The only way to know they are the same - * is to look at the range. - */ - if (!reportedNodes.has(node.range.toString())) { - - const messageId = (node.type === "PrivateIdentifier") - ? "notMatchPrivate" : "notMatch"; - - context.report({ - node, - messageId, - data: { - name: node.name, - pattern - } - }); - reportedNodes.add(node.range.toString()); - } - } - - return { - - Program(node) { - globalScope = sourceCode.getScope(node); - }, - - Identifier(node) { - const name = node.name, - parent = node.parent, - effectiveParent = (parent.type === "MemberExpression") ? parent.parent : parent; - - if (isReferenceToGlobalVariable(node)) { - return; - } - - if (parent.type === "MemberExpression") { - - if (!checkProperties) { - return; - } - - // Always check object names - if (parent.object.type === "Identifier" && - parent.object.name === name) { - if (isInvalid(name)) { - report(node); - } - - // Report AssignmentExpressions left side's assigned variable id - } else if (effectiveParent.type === "AssignmentExpression" && - effectiveParent.left.type === "MemberExpression" && - effectiveParent.left.property.name === node.name) { - if (isInvalid(name)) { - report(node); - } - - // Report AssignmentExpressions only if they are the left side of the assignment - } else if (effectiveParent.type === "AssignmentExpression" && effectiveParent.right.type !== "MemberExpression") { - if (isInvalid(name)) { - report(node); - } - } - - // For https://github.com/eslint/eslint/issues/15123 - } else if ( - parent.type === "Property" && - parent.parent.type === "ObjectExpression" && - parent.key === node && - !parent.computed - ) { - if (checkProperties && isInvalid(name)) { - report(node); - } - - /* - * Properties have their own rules, and - * AssignmentPattern nodes can be treated like Properties: - * e.g.: const { no_camelcased = false } = bar; - */ - } else if (parent.type === "Property" || parent.type === "AssignmentPattern") { - - if (parent.parent && parent.parent.type === "ObjectPattern") { - if (!ignoreDestructuring && parent.shorthand && parent.value.left && isInvalid(name)) { - report(node); - } - - const assignmentKeyEqualsValue = parent.key.name === parent.value.name; - - // prevent checking righthand side of destructured object - if (!assignmentKeyEqualsValue && parent.key === node) { - return; - } - - const valueIsInvalid = parent.value.name && isInvalid(name); - - // ignore destructuring if the option is set, unless a new identifier is created - if (valueIsInvalid && !(assignmentKeyEqualsValue && ignoreDestructuring)) { - report(node); - } - } - - // never check properties or always ignore destructuring - if ((!checkProperties && !parent.computed) || (ignoreDestructuring && isInsideObjectPattern(node))) { - return; - } - - // don't check right hand side of AssignmentExpression to prevent duplicate warnings - if (parent.right !== node && shouldReport(effectiveParent, name)) { - report(node); - } - - // Check if it's an import specifier - } else if (IMPORT_TYPES.has(parent.type)) { - - // Report only if the local imported identifier is invalid - if (parent.local && parent.local.name === node.name && isInvalid(name)) { - report(node); - } - - } else if (parent.type === "PropertyDefinition") { - - if (checkClassFields && isInvalid(name)) { - report(node); - } - - // Report anything that is invalid that isn't a CallExpression - } else if (shouldReport(effectiveParent, name)) { - report(node); - } - }, - - "PrivateIdentifier"(node) { - - const isClassField = node.parent.type === "PropertyDefinition"; - - if (isClassField && !checkClassFields) { - return; - } - - if (isInvalid(node.name)) { - report(node); - } - } - - }; - - } -}; diff --git a/tools/eslint/node_modules/eslint/lib/rules/implicit-arrow-linebreak.js b/tools/eslint/node_modules/eslint/lib/rules/implicit-arrow-linebreak.js deleted file mode 100644 index 32f422ce8282ed..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/rules/implicit-arrow-linebreak.js +++ /dev/null @@ -1,84 +0,0 @@ -/** - * @fileoverview enforce the location of arrow function bodies - * @author Sharmila Jesupaul - * @deprecated in ESLint v8.53.0 - */ -"use strict"; - -const { isCommentToken, isNotOpeningParenToken } = require("./utils/ast-utils"); - -//------------------------------------------------------------------------------ -// Rule Definition -//------------------------------------------------------------------------------ -/** @type {import('../shared/types').Rule} */ -module.exports = { - meta: { - deprecated: true, - replacedBy: [], - type: "layout", - - docs: { - description: "Enforce the location of arrow function bodies", - recommended: false, - url: "https://eslint.org/docs/latest/rules/implicit-arrow-linebreak" - }, - - fixable: "whitespace", - - schema: [ - { - enum: ["beside", "below"] - } - ], - messages: { - expected: "Expected a linebreak before this expression.", - unexpected: "Expected no linebreak before this expression." - } - }, - - create(context) { - const sourceCode = context.sourceCode; - const option = context.options[0] || "beside"; - - /** - * Validates the location of an arrow function body - * @param {ASTNode} node The arrow function body - * @returns {void} - */ - function validateExpression(node) { - if (node.body.type === "BlockStatement") { - return; - } - - const arrowToken = sourceCode.getTokenBefore(node.body, isNotOpeningParenToken); - const firstTokenOfBody = sourceCode.getTokenAfter(arrowToken); - - if (arrowToken.loc.end.line === firstTokenOfBody.loc.start.line && option === "below") { - context.report({ - node: firstTokenOfBody, - messageId: "expected", - fix: fixer => fixer.insertTextBefore(firstTokenOfBody, "\n") - }); - } else if (arrowToken.loc.end.line !== firstTokenOfBody.loc.start.line && option === "beside") { - context.report({ - node: firstTokenOfBody, - messageId: "unexpected", - fix(fixer) { - if (sourceCode.getFirstTokenBetween(arrowToken, firstTokenOfBody, { includeComments: true, filter: isCommentToken })) { - return null; - } - - return fixer.replaceTextRange([arrowToken.range[1], firstTokenOfBody.range[0]], " "); - } - }); - } - } - - //---------------------------------------------------------------------- - // Public - //---------------------------------------------------------------------- - return { - ArrowFunctionExpression: node => validateExpression(node) - }; - } -}; diff --git a/tools/eslint/node_modules/eslint/lib/rules/indent-legacy.js b/tools/eslint/node_modules/eslint/lib/rules/indent-legacy.js deleted file mode 100644 index 4adb4230e8db5e..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/rules/indent-legacy.js +++ /dev/null @@ -1,1126 +0,0 @@ -/** - * @fileoverview This option sets a specific tab width for your code - * - * This rule has been ported and modified from nodeca. - * @author Vitaly Puzrin - * @author Gyandeep Singh - * @deprecated in ESLint v4.0.0 - */ - -"use strict"; - -//------------------------------------------------------------------------------ -// Requirements -//------------------------------------------------------------------------------ - -const astUtils = require("./utils/ast-utils"); - -//------------------------------------------------------------------------------ -// Rule Definition -//------------------------------------------------------------------------------ -// this rule has known coverage issues, but it's deprecated and shouldn't be updated in the future anyway. -/* c8 ignore next */ -/** @type {import('../shared/types').Rule} */ -module.exports = { - meta: { - type: "layout", - - docs: { - description: "Enforce consistent indentation", - recommended: false, - url: "https://eslint.org/docs/latest/rules/indent-legacy" - }, - - deprecated: true, - - replacedBy: ["indent"], - - fixable: "whitespace", - - schema: [ - { - oneOf: [ - { - enum: ["tab"] - }, - { - type: "integer", - minimum: 0 - } - ] - }, - { - type: "object", - properties: { - SwitchCase: { - type: "integer", - minimum: 0 - }, - VariableDeclarator: { - oneOf: [ - { - type: "integer", - minimum: 0 - }, - { - type: "object", - properties: { - var: { - type: "integer", - minimum: 0 - }, - let: { - type: "integer", - minimum: 0 - }, - const: { - type: "integer", - minimum: 0 - } - } - } - ] - }, - outerIIFEBody: { - type: "integer", - minimum: 0 - }, - MemberExpression: { - type: "integer", - minimum: 0 - }, - FunctionDeclaration: { - type: "object", - properties: { - parameters: { - oneOf: [ - { - type: "integer", - minimum: 0 - }, - { - enum: ["first"] - } - ] - }, - body: { - type: "integer", - minimum: 0 - } - } - }, - FunctionExpression: { - type: "object", - properties: { - parameters: { - oneOf: [ - { - type: "integer", - minimum: 0 - }, - { - enum: ["first"] - } - ] - }, - body: { - type: "integer", - minimum: 0 - } - } - }, - CallExpression: { - type: "object", - properties: { - parameters: { - oneOf: [ - { - type: "integer", - minimum: 0 - }, - { - enum: ["first"] - } - ] - } - } - }, - ArrayExpression: { - oneOf: [ - { - type: "integer", - minimum: 0 - }, - { - enum: ["first"] - } - ] - }, - ObjectExpression: { - oneOf: [ - { - type: "integer", - minimum: 0 - }, - { - enum: ["first"] - } - ] - } - }, - additionalProperties: false - } - ], - messages: { - expected: "Expected indentation of {{expected}} but found {{actual}}." - } - }, - - create(context) { - const DEFAULT_VARIABLE_INDENT = 1; - const DEFAULT_PARAMETER_INDENT = null; // For backwards compatibility, don't check parameter indentation unless specified in the config - const DEFAULT_FUNCTION_BODY_INDENT = 1; - - let indentType = "space"; - let indentSize = 4; - const options = { - SwitchCase: 0, - VariableDeclarator: { - var: DEFAULT_VARIABLE_INDENT, - let: DEFAULT_VARIABLE_INDENT, - const: DEFAULT_VARIABLE_INDENT - }, - outerIIFEBody: null, - FunctionDeclaration: { - parameters: DEFAULT_PARAMETER_INDENT, - body: DEFAULT_FUNCTION_BODY_INDENT - }, - FunctionExpression: { - parameters: DEFAULT_PARAMETER_INDENT, - body: DEFAULT_FUNCTION_BODY_INDENT - }, - CallExpression: { - arguments: DEFAULT_PARAMETER_INDENT - }, - ArrayExpression: 1, - ObjectExpression: 1 - }; - - const sourceCode = context.sourceCode; - - if (context.options.length) { - if (context.options[0] === "tab") { - indentSize = 1; - indentType = "tab"; - } else /* c8 ignore start */ if (typeof context.options[0] === "number") { - indentSize = context.options[0]; - indentType = "space"; - }/* c8 ignore stop */ - - if (context.options[1]) { - const opts = context.options[1]; - - options.SwitchCase = opts.SwitchCase || 0; - const variableDeclaratorRules = opts.VariableDeclarator; - - if (typeof variableDeclaratorRules === "number") { - options.VariableDeclarator = { - var: variableDeclaratorRules, - let: variableDeclaratorRules, - const: variableDeclaratorRules - }; - } else if (typeof variableDeclaratorRules === "object") { - Object.assign(options.VariableDeclarator, variableDeclaratorRules); - } - - if (typeof opts.outerIIFEBody === "number") { - options.outerIIFEBody = opts.outerIIFEBody; - } - - if (typeof opts.MemberExpression === "number") { - options.MemberExpression = opts.MemberExpression; - } - - if (typeof opts.FunctionDeclaration === "object") { - Object.assign(options.FunctionDeclaration, opts.FunctionDeclaration); - } - - if (typeof opts.FunctionExpression === "object") { - Object.assign(options.FunctionExpression, opts.FunctionExpression); - } - - if (typeof opts.CallExpression === "object") { - Object.assign(options.CallExpression, opts.CallExpression); - } - - if (typeof opts.ArrayExpression === "number" || typeof opts.ArrayExpression === "string") { - options.ArrayExpression = opts.ArrayExpression; - } - - if (typeof opts.ObjectExpression === "number" || typeof opts.ObjectExpression === "string") { - options.ObjectExpression = opts.ObjectExpression; - } - } - } - - const caseIndentStore = {}; - - /** - * Creates an error message for a line, given the expected/actual indentation. - * @param {int} expectedAmount The expected amount of indentation characters for this line - * @param {int} actualSpaces The actual number of indentation spaces that were found on this line - * @param {int} actualTabs The actual number of indentation tabs that were found on this line - * @returns {string} An error message for this line - */ - function createErrorMessageData(expectedAmount, actualSpaces, actualTabs) { - const expectedStatement = `${expectedAmount} ${indentType}${expectedAmount === 1 ? "" : "s"}`; // e.g. "2 tabs" - const foundSpacesWord = `space${actualSpaces === 1 ? "" : "s"}`; // e.g. "space" - const foundTabsWord = `tab${actualTabs === 1 ? "" : "s"}`; // e.g. "tabs" - let foundStatement; - - if (actualSpaces > 0 && actualTabs > 0) { - foundStatement = `${actualSpaces} ${foundSpacesWord} and ${actualTabs} ${foundTabsWord}`; // e.g. "1 space and 2 tabs" - } else if (actualSpaces > 0) { - - /* - * Abbreviate the message if the expected indentation is also spaces. - * e.g. 'Expected 4 spaces but found 2' rather than 'Expected 4 spaces but found 2 spaces' - */ - foundStatement = indentType === "space" ? actualSpaces : `${actualSpaces} ${foundSpacesWord}`; - } else if (actualTabs > 0) { - foundStatement = indentType === "tab" ? actualTabs : `${actualTabs} ${foundTabsWord}`; - } else { - foundStatement = "0"; - } - return { - expected: expectedStatement, - actual: foundStatement - }; - } - - /** - * Reports a given indent violation - * @param {ASTNode} node Node violating the indent rule - * @param {int} needed Expected indentation character count - * @param {int} gottenSpaces Indentation space count in the actual node/code - * @param {int} gottenTabs Indentation tab count in the actual node/code - * @param {Object} [loc] Error line and column location - * @param {boolean} isLastNodeCheck Is the error for last node check - * @returns {void} - */ - function report(node, needed, gottenSpaces, gottenTabs, loc, isLastNodeCheck) { - if (gottenSpaces && gottenTabs) { - - // To avoid conflicts with `no-mixed-spaces-and-tabs`, don't report lines that have both spaces and tabs. - return; - } - - const desiredIndent = (indentType === "space" ? " " : "\t").repeat(needed); - - const textRange = isLastNodeCheck - ? [node.range[1] - node.loc.end.column, node.range[1] - node.loc.end.column + gottenSpaces + gottenTabs] - : [node.range[0] - node.loc.start.column, node.range[0] - node.loc.start.column + gottenSpaces + gottenTabs]; - - context.report({ - node, - loc, - messageId: "expected", - data: createErrorMessageData(needed, gottenSpaces, gottenTabs), - fix: fixer => fixer.replaceTextRange(textRange, desiredIndent) - }); - } - - /** - * Get the actual indent of node - * @param {ASTNode|Token} node Node to examine - * @param {boolean} [byLastLine=false] get indent of node's last line - * @returns {Object} The node's indent. Contains keys `space` and `tab`, representing the indent of each character. Also - * contains keys `goodChar` and `badChar`, where `goodChar` is the amount of the user's desired indentation character, and - * `badChar` is the amount of the other indentation character. - */ - function getNodeIndent(node, byLastLine) { - const token = byLastLine ? sourceCode.getLastToken(node) : sourceCode.getFirstToken(node); - const srcCharsBeforeNode = sourceCode.getText(token, token.loc.start.column).split(""); - const indentChars = srcCharsBeforeNode.slice(0, srcCharsBeforeNode.findIndex(char => char !== " " && char !== "\t")); - const spaces = indentChars.filter(char => char === " ").length; - const tabs = indentChars.filter(char => char === "\t").length; - - return { - space: spaces, - tab: tabs, - goodChar: indentType === "space" ? spaces : tabs, - badChar: indentType === "space" ? tabs : spaces - }; - } - - /** - * Checks node is the first in its own start line. By default it looks by start line. - * @param {ASTNode} node The node to check - * @param {boolean} [byEndLocation=false] Lookup based on start position or end - * @returns {boolean} true if its the first in the its start line - */ - function isNodeFirstInLine(node, byEndLocation) { - const firstToken = byEndLocation === true ? sourceCode.getLastToken(node, 1) : sourceCode.getTokenBefore(node), - startLine = byEndLocation === true ? node.loc.end.line : node.loc.start.line, - endLine = firstToken ? firstToken.loc.end.line : -1; - - return startLine !== endLine; - } - - /** - * Check indent for node - * @param {ASTNode} node Node to check - * @param {int} neededIndent needed indent - * @returns {void} - */ - function checkNodeIndent(node, neededIndent) { - const actualIndent = getNodeIndent(node, false); - - if ( - node.type !== "ArrayExpression" && - node.type !== "ObjectExpression" && - (actualIndent.goodChar !== neededIndent || actualIndent.badChar !== 0) && - isNodeFirstInLine(node) - ) { - report(node, neededIndent, actualIndent.space, actualIndent.tab); - } - - if (node.type === "IfStatement" && node.alternate) { - const elseToken = sourceCode.getTokenBefore(node.alternate); - - checkNodeIndent(elseToken, neededIndent); - - if (!isNodeFirstInLine(node.alternate)) { - checkNodeIndent(node.alternate, neededIndent); - } - } - - if (node.type === "TryStatement" && node.handler) { - const catchToken = sourceCode.getFirstToken(node.handler); - - checkNodeIndent(catchToken, neededIndent); - } - - if (node.type === "TryStatement" && node.finalizer) { - const finallyToken = sourceCode.getTokenBefore(node.finalizer); - - checkNodeIndent(finallyToken, neededIndent); - } - - if (node.type === "DoWhileStatement") { - const whileToken = sourceCode.getTokenAfter(node.body); - - checkNodeIndent(whileToken, neededIndent); - } - } - - /** - * Check indent for nodes list - * @param {ASTNode[]} nodes list of node objects - * @param {int} indent needed indent - * @returns {void} - */ - function checkNodesIndent(nodes, indent) { - nodes.forEach(node => checkNodeIndent(node, indent)); - } - - /** - * Check last node line indent this detects, that block closed correctly - * @param {ASTNode} node Node to examine - * @param {int} lastLineIndent needed indent - * @returns {void} - */ - function checkLastNodeLineIndent(node, lastLineIndent) { - const lastToken = sourceCode.getLastToken(node); - const endIndent = getNodeIndent(lastToken, true); - - if ((endIndent.goodChar !== lastLineIndent || endIndent.badChar !== 0) && isNodeFirstInLine(node, true)) { - report( - node, - lastLineIndent, - endIndent.space, - endIndent.tab, - { line: lastToken.loc.start.line, column: lastToken.loc.start.column }, - true - ); - } - } - - /** - * Check last node line indent this detects, that block closed correctly - * This function for more complicated return statement case, where closing parenthesis may be followed by ';' - * @param {ASTNode} node Node to examine - * @param {int} firstLineIndent first line needed indent - * @returns {void} - */ - function checkLastReturnStatementLineIndent(node, firstLineIndent) { - - /* - * in case if return statement ends with ');' we have traverse back to ')' - * otherwise we'll measure indent for ';' and replace ')' - */ - const lastToken = sourceCode.getLastToken(node, astUtils.isClosingParenToken); - const textBeforeClosingParenthesis = sourceCode.getText(lastToken, lastToken.loc.start.column).slice(0, -1); - - if (textBeforeClosingParenthesis.trim()) { - - // There are tokens before the closing paren, don't report this case - return; - } - - const endIndent = getNodeIndent(lastToken, true); - - if (endIndent.goodChar !== firstLineIndent) { - report( - node, - firstLineIndent, - endIndent.space, - endIndent.tab, - { line: lastToken.loc.start.line, column: lastToken.loc.start.column }, - true - ); - } - } - - /** - * Check first node line indent is correct - * @param {ASTNode} node Node to examine - * @param {int} firstLineIndent needed indent - * @returns {void} - */ - function checkFirstNodeLineIndent(node, firstLineIndent) { - const startIndent = getNodeIndent(node, false); - - if ((startIndent.goodChar !== firstLineIndent || startIndent.badChar !== 0) && isNodeFirstInLine(node)) { - report( - node, - firstLineIndent, - startIndent.space, - startIndent.tab, - { line: node.loc.start.line, column: node.loc.start.column } - ); - } - } - - /** - * Returns a parent node of given node based on a specified type - * if not present then return null - * @param {ASTNode} node node to examine - * @param {string} type type that is being looked for - * @param {string} stopAtList end points for the evaluating code - * @returns {ASTNode|void} if found then node otherwise null - */ - function getParentNodeByType(node, type, stopAtList) { - let parent = node.parent; - const stopAtSet = new Set(stopAtList || ["Program"]); - - while (parent.type !== type && !stopAtSet.has(parent.type) && parent.type !== "Program") { - parent = parent.parent; - } - - return parent.type === type ? parent : null; - } - - /** - * Returns the VariableDeclarator based on the current node - * if not present then return null - * @param {ASTNode} node node to examine - * @returns {ASTNode|void} if found then node otherwise null - */ - function getVariableDeclaratorNode(node) { - return getParentNodeByType(node, "VariableDeclarator"); - } - - /** - * Check to see if the node is part of the multi-line variable declaration. - * Also if its on the same line as the varNode - * @param {ASTNode} node node to check - * @param {ASTNode} varNode variable declaration node to check against - * @returns {boolean} True if all the above condition satisfy - */ - function isNodeInVarOnTop(node, varNode) { - return varNode && - varNode.parent.loc.start.line === node.loc.start.line && - varNode.parent.declarations.length > 1; - } - - /** - * Check to see if the argument before the callee node is multi-line and - * there should only be 1 argument before the callee node - * @param {ASTNode} node node to check - * @returns {boolean} True if arguments are multi-line - */ - function isArgBeforeCalleeNodeMultiline(node) { - const parent = node.parent; - - if (parent.arguments.length >= 2 && parent.arguments[1] === node) { - return parent.arguments[0].loc.end.line > parent.arguments[0].loc.start.line; - } - - return false; - } - - /** - * Check to see if the node is a file level IIFE - * @param {ASTNode} node The function node to check. - * @returns {boolean} True if the node is the outer IIFE - */ - function isOuterIIFE(node) { - const parent = node.parent; - let stmt = parent.parent; - - /* - * Verify that the node is an IIEF - */ - if ( - parent.type !== "CallExpression" || - parent.callee !== node) { - - return false; - } - - /* - * Navigate legal ancestors to determine whether this IIEF is outer - */ - while ( - stmt.type === "UnaryExpression" && ( - stmt.operator === "!" || - stmt.operator === "~" || - stmt.operator === "+" || - stmt.operator === "-") || - stmt.type === "AssignmentExpression" || - stmt.type === "LogicalExpression" || - stmt.type === "SequenceExpression" || - stmt.type === "VariableDeclarator") { - - stmt = stmt.parent; - } - - return (( - stmt.type === "ExpressionStatement" || - stmt.type === "VariableDeclaration") && - stmt.parent && stmt.parent.type === "Program" - ); - } - - /** - * Check indent for function block content - * @param {ASTNode} node A BlockStatement node that is inside of a function. - * @returns {void} - */ - function checkIndentInFunctionBlock(node) { - - /* - * Search first caller in chain. - * Ex.: - * - * Models <- Identifier - * .User - * .find() - * .exec(function() { - * // function body - * }); - * - * Looks for 'Models' - */ - const calleeNode = node.parent; // FunctionExpression - let indent; - - if (calleeNode.parent && - (calleeNode.parent.type === "Property" || - calleeNode.parent.type === "ArrayExpression")) { - - // If function is part of array or object, comma can be put at left - indent = getNodeIndent(calleeNode, false).goodChar; - } else { - - // If function is standalone, simple calculate indent - indent = getNodeIndent(calleeNode).goodChar; - } - - if (calleeNode.parent.type === "CallExpression") { - const calleeParent = calleeNode.parent; - - if (calleeNode.type !== "FunctionExpression" && calleeNode.type !== "ArrowFunctionExpression") { - if (calleeParent && calleeParent.loc.start.line < node.loc.start.line) { - indent = getNodeIndent(calleeParent).goodChar; - } - } else { - if (isArgBeforeCalleeNodeMultiline(calleeNode) && - calleeParent.callee.loc.start.line === calleeParent.callee.loc.end.line && - !isNodeFirstInLine(calleeNode)) { - indent = getNodeIndent(calleeParent).goodChar; - } - } - } - - /* - * function body indent should be indent + indent size, unless this - * is a FunctionDeclaration, FunctionExpression, or outer IIFE and the corresponding options are enabled. - */ - let functionOffset = indentSize; - - if (options.outerIIFEBody !== null && isOuterIIFE(calleeNode)) { - functionOffset = options.outerIIFEBody * indentSize; - } else if (calleeNode.type === "FunctionExpression") { - functionOffset = options.FunctionExpression.body * indentSize; - } else if (calleeNode.type === "FunctionDeclaration") { - functionOffset = options.FunctionDeclaration.body * indentSize; - } - indent += functionOffset; - - // check if the node is inside a variable - const parentVarNode = getVariableDeclaratorNode(node); - - if (parentVarNode && isNodeInVarOnTop(node, parentVarNode)) { - indent += indentSize * options.VariableDeclarator[parentVarNode.parent.kind]; - } - - if (node.body.length > 0) { - checkNodesIndent(node.body, indent); - } - - checkLastNodeLineIndent(node, indent - functionOffset); - } - - - /** - * Checks if the given node starts and ends on the same line - * @param {ASTNode} node The node to check - * @returns {boolean} Whether or not the block starts and ends on the same line. - */ - function isSingleLineNode(node) { - const lastToken = sourceCode.getLastToken(node), - startLine = node.loc.start.line, - endLine = lastToken.loc.end.line; - - return startLine === endLine; - } - - /** - * Check indent for array block content or object block content - * @param {ASTNode} node node to examine - * @returns {void} - */ - function checkIndentInArrayOrObjectBlock(node) { - - // Skip inline - if (isSingleLineNode(node)) { - return; - } - - let elements = (node.type === "ArrayExpression") ? node.elements : node.properties; - - // filter out empty elements example would be [ , 2] so remove first element as espree considers it as null - elements = elements.filter(elem => elem !== null); - - let nodeIndent; - let elementsIndent; - const parentVarNode = getVariableDeclaratorNode(node); - - // TODO - come up with a better strategy in future - if (isNodeFirstInLine(node)) { - const parent = node.parent; - - nodeIndent = getNodeIndent(parent).goodChar; - if (!parentVarNode || parentVarNode.loc.start.line !== node.loc.start.line) { - if (parent.type !== "VariableDeclarator" || parentVarNode === parentVarNode.parent.declarations[0]) { - if (parent.type === "VariableDeclarator" && parentVarNode.loc.start.line === parent.loc.start.line) { - nodeIndent += (indentSize * options.VariableDeclarator[parentVarNode.parent.kind]); - } else if (parent.type === "ObjectExpression" || parent.type === "ArrayExpression") { - const parentElements = node.parent.type === "ObjectExpression" ? node.parent.properties : node.parent.elements; - - if (parentElements[0] && - parentElements[0].loc.start.line === parent.loc.start.line && - parentElements[0].loc.end.line !== parent.loc.start.line) { - - /* - * If the first element of the array spans multiple lines, don't increase the expected indentation of the rest. - * e.g. [{ - * foo: 1 - * }, - * { - * bar: 1 - * }] - * the second object is not indented. - */ - } else if (typeof options[parent.type] === "number") { - nodeIndent += options[parent.type] * indentSize; - } else { - nodeIndent = parentElements[0].loc.start.column; - } - } else if (parent.type === "CallExpression" || parent.type === "NewExpression") { - if (typeof options.CallExpression.arguments === "number") { - nodeIndent += options.CallExpression.arguments * indentSize; - } else if (options.CallExpression.arguments === "first") { - if (parent.arguments.includes(node)) { - nodeIndent = parent.arguments[0].loc.start.column; - } - } else { - nodeIndent += indentSize; - } - } else if (parent.type === "LogicalExpression" || parent.type === "ArrowFunctionExpression") { - nodeIndent += indentSize; - } - } - } - - checkFirstNodeLineIndent(node, nodeIndent); - } else { - nodeIndent = getNodeIndent(node).goodChar; - } - - if (options[node.type] === "first") { - elementsIndent = elements.length ? elements[0].loc.start.column : 0; // If there are no elements, elementsIndent doesn't matter. - } else { - elementsIndent = nodeIndent + indentSize * options[node.type]; - } - - /* - * Check if the node is a multiple variable declaration; if so, then - * make sure indentation takes that into account. - */ - if (isNodeInVarOnTop(node, parentVarNode)) { - elementsIndent += indentSize * options.VariableDeclarator[parentVarNode.parent.kind]; - } - - checkNodesIndent(elements, elementsIndent); - - if (elements.length > 0) { - - // Skip last block line check if last item in same line - if (elements.at(-1).loc.end.line === node.loc.end.line) { - return; - } - } - - checkLastNodeLineIndent(node, nodeIndent + - (isNodeInVarOnTop(node, parentVarNode) ? options.VariableDeclarator[parentVarNode.parent.kind] * indentSize : 0)); - } - - /** - * Check if the node or node body is a BlockStatement or not - * @param {ASTNode} node node to test - * @returns {boolean} True if it or its body is a block statement - */ - function isNodeBodyBlock(node) { - return node.type === "BlockStatement" || node.type === "ClassBody" || (node.body && node.body.type === "BlockStatement") || - (node.consequent && node.consequent.type === "BlockStatement"); - } - - /** - * Check indentation for blocks - * @param {ASTNode} node node to check - * @returns {void} - */ - function blockIndentationCheck(node) { - - // Skip inline blocks - if (isSingleLineNode(node)) { - return; - } - - if (node.parent && ( - node.parent.type === "FunctionExpression" || - node.parent.type === "FunctionDeclaration" || - node.parent.type === "ArrowFunctionExpression") - ) { - checkIndentInFunctionBlock(node); - return; - } - - let indent; - let nodesToCheck; - - /* - * For this statements we should check indent from statement beginning, - * not from the beginning of the block. - */ - const statementsWithProperties = [ - "IfStatement", "WhileStatement", "ForStatement", "ForInStatement", "ForOfStatement", "DoWhileStatement", "ClassDeclaration", "TryStatement" - ]; - - if (node.parent && statementsWithProperties.includes(node.parent.type) && isNodeBodyBlock(node)) { - indent = getNodeIndent(node.parent).goodChar; - } else if (node.parent && node.parent.type === "CatchClause") { - indent = getNodeIndent(node.parent.parent).goodChar; - } else { - indent = getNodeIndent(node).goodChar; - } - - if (node.type === "IfStatement" && node.consequent.type !== "BlockStatement") { - nodesToCheck = [node.consequent]; - } else if (Array.isArray(node.body)) { - nodesToCheck = node.body; - } else { - nodesToCheck = [node.body]; - } - - if (nodesToCheck.length > 0) { - checkNodesIndent(nodesToCheck, indent + indentSize); - } - - if (node.type === "BlockStatement") { - checkLastNodeLineIndent(node, indent); - } - } - - /** - * Filter out the elements which are on the same line of each other or the node. - * basically have only 1 elements from each line except the variable declaration line. - * @param {ASTNode} node Variable declaration node - * @returns {ASTNode[]} Filtered elements - */ - function filterOutSameLineVars(node) { - return node.declarations.reduce((finalCollection, elem) => { - const lastElem = finalCollection.at(-1); - - if ((elem.loc.start.line !== node.loc.start.line && !lastElem) || - (lastElem && lastElem.loc.start.line !== elem.loc.start.line)) { - finalCollection.push(elem); - } - - return finalCollection; - }, []); - } - - /** - * Check indentation for variable declarations - * @param {ASTNode} node node to examine - * @returns {void} - */ - function checkIndentInVariableDeclarations(node) { - const elements = filterOutSameLineVars(node); - const nodeIndent = getNodeIndent(node).goodChar; - const lastElement = elements.at(-1); - - const elementsIndent = nodeIndent + indentSize * options.VariableDeclarator[node.kind]; - - checkNodesIndent(elements, elementsIndent); - - // Only check the last line if there is any token after the last item - if (sourceCode.getLastToken(node).loc.end.line <= lastElement.loc.end.line) { - return; - } - - const tokenBeforeLastElement = sourceCode.getTokenBefore(lastElement); - - if (tokenBeforeLastElement.value === ",") { - - // Special case for comma-first syntax where the semicolon is indented - checkLastNodeLineIndent(node, getNodeIndent(tokenBeforeLastElement).goodChar); - } else { - checkLastNodeLineIndent(node, elementsIndent - indentSize); - } - } - - /** - * Check and decide whether to check for indentation for blockless nodes - * Scenarios are for or while statements without braces around them - * @param {ASTNode} node node to examine - * @returns {void} - */ - function blockLessNodes(node) { - if (node.body.type !== "BlockStatement") { - blockIndentationCheck(node); - } - } - - /** - * Returns the expected indentation for the case statement - * @param {ASTNode} node node to examine - * @param {int} [providedSwitchIndent] indent for switch statement - * @returns {int} indent size - */ - function expectedCaseIndent(node, providedSwitchIndent) { - const switchNode = (node.type === "SwitchStatement") ? node : node.parent; - const switchIndent = typeof providedSwitchIndent === "undefined" - ? getNodeIndent(switchNode).goodChar - : providedSwitchIndent; - let caseIndent; - - if (caseIndentStore[switchNode.loc.start.line]) { - return caseIndentStore[switchNode.loc.start.line]; - } - - if (switchNode.cases.length > 0 && options.SwitchCase === 0) { - caseIndent = switchIndent; - } else { - caseIndent = switchIndent + (indentSize * options.SwitchCase); - } - - caseIndentStore[switchNode.loc.start.line] = caseIndent; - return caseIndent; - - } - - /** - * Checks whether a return statement is wrapped in () - * @param {ASTNode} node node to examine - * @returns {boolean} the result - */ - function isWrappedInParenthesis(node) { - const regex = /^return\s*?\(\s*?\);*?/u; - - const statementWithoutArgument = sourceCode.getText(node).replace( - sourceCode.getText(node.argument), "" - ); - - return regex.test(statementWithoutArgument); - } - - return { - Program(node) { - if (node.body.length > 0) { - - // Root nodes should have no indent - checkNodesIndent(node.body, getNodeIndent(node).goodChar); - } - }, - - ClassBody: blockIndentationCheck, - - BlockStatement: blockIndentationCheck, - - WhileStatement: blockLessNodes, - - ForStatement: blockLessNodes, - - ForInStatement: blockLessNodes, - - ForOfStatement: blockLessNodes, - - DoWhileStatement: blockLessNodes, - - IfStatement(node) { - if (node.consequent.type !== "BlockStatement" && node.consequent.loc.start.line > node.loc.start.line) { - blockIndentationCheck(node); - } - }, - - VariableDeclaration(node) { - if (node.declarations.at(-1).loc.start.line > node.declarations[0].loc.start.line) { - checkIndentInVariableDeclarations(node); - } - }, - - ObjectExpression(node) { - checkIndentInArrayOrObjectBlock(node); - }, - - ArrayExpression(node) { - checkIndentInArrayOrObjectBlock(node); - }, - - MemberExpression(node) { - - if (typeof options.MemberExpression === "undefined") { - return; - } - - if (isSingleLineNode(node)) { - return; - } - - /* - * The typical layout of variable declarations and assignments - * alter the expectation of correct indentation. Skip them. - * TODO: Add appropriate configuration options for variable - * declarations and assignments. - */ - if (getParentNodeByType(node, "VariableDeclarator", ["FunctionExpression", "ArrowFunctionExpression"])) { - return; - } - - if (getParentNodeByType(node, "AssignmentExpression", ["FunctionExpression"])) { - return; - } - - const propertyIndent = getNodeIndent(node).goodChar + indentSize * options.MemberExpression; - - const checkNodes = [node.property]; - - const dot = sourceCode.getTokenBefore(node.property); - - if (dot.type === "Punctuator" && dot.value === ".") { - checkNodes.push(dot); - } - - checkNodesIndent(checkNodes, propertyIndent); - }, - - SwitchStatement(node) { - - // Switch is not a 'BlockStatement' - const switchIndent = getNodeIndent(node).goodChar; - const caseIndent = expectedCaseIndent(node, switchIndent); - - checkNodesIndent(node.cases, caseIndent); - - - checkLastNodeLineIndent(node, switchIndent); - }, - - SwitchCase(node) { - - // Skip inline cases - if (isSingleLineNode(node)) { - return; - } - const caseIndent = expectedCaseIndent(node); - - checkNodesIndent(node.consequent, caseIndent + indentSize); - }, - - FunctionDeclaration(node) { - if (isSingleLineNode(node)) { - return; - } - if (options.FunctionDeclaration.parameters === "first" && node.params.length) { - checkNodesIndent(node.params.slice(1), node.params[0].loc.start.column); - } else if (options.FunctionDeclaration.parameters !== null) { - checkNodesIndent(node.params, getNodeIndent(node).goodChar + indentSize * options.FunctionDeclaration.parameters); - } - }, - - FunctionExpression(node) { - if (isSingleLineNode(node)) { - return; - } - if (options.FunctionExpression.parameters === "first" && node.params.length) { - checkNodesIndent(node.params.slice(1), node.params[0].loc.start.column); - } else if (options.FunctionExpression.parameters !== null) { - checkNodesIndent(node.params, getNodeIndent(node).goodChar + indentSize * options.FunctionExpression.parameters); - } - }, - - ReturnStatement(node) { - if (isSingleLineNode(node)) { - return; - } - - const firstLineIndent = getNodeIndent(node).goodChar; - - // in case if return statement is wrapped in parenthesis - if (isWrappedInParenthesis(node)) { - checkLastReturnStatementLineIndent(node, firstLineIndent); - } else { - checkNodeIndent(node, firstLineIndent); - } - }, - - CallExpression(node) { - if (isSingleLineNode(node)) { - return; - } - if (options.CallExpression.arguments === "first" && node.arguments.length) { - checkNodesIndent(node.arguments.slice(1), node.arguments[0].loc.start.column); - } else if (options.CallExpression.arguments !== null) { - checkNodesIndent(node.arguments, getNodeIndent(node).goodChar + indentSize * options.CallExpression.arguments); - } - } - - }; - - } -}; diff --git a/tools/eslint/node_modules/eslint/lib/rules/indent.js b/tools/eslint/node_modules/eslint/lib/rules/indent.js deleted file mode 100644 index bc812b13c3e37c..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/rules/indent.js +++ /dev/null @@ -1,1803 +0,0 @@ -/** - * @fileoverview This rule sets a specific indentation style and width for your code - * - * @author Teddy Katz - * @author Vitaly Puzrin - * @author Gyandeep Singh - * @deprecated in ESLint v8.53.0 - */ - -"use strict"; - -//------------------------------------------------------------------------------ -// Requirements -//------------------------------------------------------------------------------ - -const astUtils = require("./utils/ast-utils"); - -//------------------------------------------------------------------------------ -// Rule Definition -//------------------------------------------------------------------------------ - -const KNOWN_NODES = new Set([ - "AssignmentExpression", - "AssignmentPattern", - "ArrayExpression", - "ArrayPattern", - "ArrowFunctionExpression", - "AwaitExpression", - "BlockStatement", - "BinaryExpression", - "BreakStatement", - "CallExpression", - "CatchClause", - "ChainExpression", - "ClassBody", - "ClassDeclaration", - "ClassExpression", - "ConditionalExpression", - "ContinueStatement", - "DoWhileStatement", - "DebuggerStatement", - "EmptyStatement", - "ExperimentalRestProperty", - "ExperimentalSpreadProperty", - "ExpressionStatement", - "ForStatement", - "ForInStatement", - "ForOfStatement", - "FunctionDeclaration", - "FunctionExpression", - "Identifier", - "IfStatement", - "Literal", - "LabeledStatement", - "LogicalExpression", - "MemberExpression", - "MetaProperty", - "MethodDefinition", - "NewExpression", - "ObjectExpression", - "ObjectPattern", - "PrivateIdentifier", - "Program", - "Property", - "PropertyDefinition", - "RestElement", - "ReturnStatement", - "SequenceExpression", - "SpreadElement", - "StaticBlock", - "Super", - "SwitchCase", - "SwitchStatement", - "TaggedTemplateExpression", - "TemplateElement", - "TemplateLiteral", - "ThisExpression", - "ThrowStatement", - "TryStatement", - "UnaryExpression", - "UpdateExpression", - "VariableDeclaration", - "VariableDeclarator", - "WhileStatement", - "WithStatement", - "YieldExpression", - "JSXFragment", - "JSXOpeningFragment", - "JSXClosingFragment", - "JSXIdentifier", - "JSXNamespacedName", - "JSXMemberExpression", - "JSXEmptyExpression", - "JSXExpressionContainer", - "JSXElement", - "JSXClosingElement", - "JSXOpeningElement", - "JSXAttribute", - "JSXSpreadAttribute", - "JSXText", - "ExportDefaultDeclaration", - "ExportNamedDeclaration", - "ExportAllDeclaration", - "ExportSpecifier", - "ImportDeclaration", - "ImportSpecifier", - "ImportDefaultSpecifier", - "ImportNamespaceSpecifier", - "ImportExpression" -]); - -/* - * General rule strategy: - * 1. An OffsetStorage instance stores a map of desired offsets, where each token has a specified offset from another - * specified token or to the first column. - * 2. As the AST is traversed, modify the desired offsets of tokens accordingly. For example, when entering a - * BlockStatement, offset all of the tokens in the BlockStatement by 1 indent level from the opening curly - * brace of the BlockStatement. - * 3. After traversing the AST, calculate the expected indentation levels of every token according to the - * OffsetStorage container. - * 4. For each line, compare the expected indentation of the first token to the actual indentation in the file, - * and report the token if the two values are not equal. - */ - - -/** - * A mutable map that stores (key, value) pairs. The keys are numeric indices, and must be unique. - * This is intended to be a generic wrapper around a map with non-negative integer keys, so that the underlying implementation - * can easily be swapped out. - */ -class IndexMap { - - /** - * Creates an empty map - * @param {number} maxKey The maximum key - */ - constructor(maxKey) { - - // Initializing the array with the maximum expected size avoids dynamic reallocations that could degrade performance. - this._values = Array(maxKey + 1); - } - - /** - * Inserts an entry into the map. - * @param {number} key The entry's key - * @param {any} value The entry's value - * @returns {void} - */ - insert(key, value) { - this._values[key] = value; - } - - /** - * Finds the value of the entry with the largest key less than or equal to the provided key - * @param {number} key The provided key - * @returns {*|undefined} The value of the found entry, or undefined if no such entry exists. - */ - findLastNotAfter(key) { - const values = this._values; - - for (let index = key; index >= 0; index--) { - const value = values[index]; - - if (value) { - return value; - } - } - return void 0; - } - - /** - * Deletes all of the keys in the interval [start, end) - * @param {number} start The start of the range - * @param {number} end The end of the range - * @returns {void} - */ - deleteRange(start, end) { - this._values.fill(void 0, start, end); - } -} - -/** - * A helper class to get token-based info related to indentation - */ -class TokenInfo { - - /** - * @param {SourceCode} sourceCode A SourceCode object - */ - constructor(sourceCode) { - this.sourceCode = sourceCode; - this.firstTokensByLineNumber = new Map(); - const tokens = sourceCode.tokensAndComments; - - for (let i = 0; i < tokens.length; i++) { - const token = tokens[i]; - - if (!this.firstTokensByLineNumber.has(token.loc.start.line)) { - this.firstTokensByLineNumber.set(token.loc.start.line, token); - } - if (!this.firstTokensByLineNumber.has(token.loc.end.line) && sourceCode.text.slice(token.range[1] - token.loc.end.column, token.range[1]).trim()) { - this.firstTokensByLineNumber.set(token.loc.end.line, token); - } - } - } - - /** - * Gets the first token on a given token's line - * @param {Token|ASTNode} token a node or token - * @returns {Token} The first token on the given line - */ - getFirstTokenOfLine(token) { - return this.firstTokensByLineNumber.get(token.loc.start.line); - } - - /** - * Determines whether a token is the first token in its line - * @param {Token} token The token - * @returns {boolean} `true` if the token is the first on its line - */ - isFirstTokenOfLine(token) { - return this.getFirstTokenOfLine(token) === token; - } - - /** - * Get the actual indent of a token - * @param {Token} token Token to examine. This should be the first token on its line. - * @returns {string} The indentation characters that precede the token - */ - getTokenIndent(token) { - return this.sourceCode.text.slice(token.range[0] - token.loc.start.column, token.range[0]); - } -} - -/** - * A class to store information on desired offsets of tokens from each other - */ -class OffsetStorage { - - /** - * @param {TokenInfo} tokenInfo a TokenInfo instance - * @param {number} indentSize The desired size of each indentation level - * @param {string} indentType The indentation character - * @param {number} maxIndex The maximum end index of any token - */ - constructor(tokenInfo, indentSize, indentType, maxIndex) { - this._tokenInfo = tokenInfo; - this._indentSize = indentSize; - this._indentType = indentType; - - this._indexMap = new IndexMap(maxIndex); - this._indexMap.insert(0, { offset: 0, from: null, force: false }); - - this._lockedFirstTokens = new WeakMap(); - this._desiredIndentCache = new WeakMap(); - this._ignoredTokens = new WeakSet(); - } - - _getOffsetDescriptor(token) { - return this._indexMap.findLastNotAfter(token.range[0]); - } - - /** - * Sets the offset column of token B to match the offset column of token A. - * - **WARNING**: This matches a *column*, even if baseToken is not the first token on its line. In - * most cases, `setDesiredOffset` should be used instead. - * @param {Token} baseToken The first token - * @param {Token} offsetToken The second token, whose offset should be matched to the first token - * @returns {void} - */ - matchOffsetOf(baseToken, offsetToken) { - - /* - * lockedFirstTokens is a map from a token whose indentation is controlled by the "first" option to - * the token that it depends on. For example, with the `ArrayExpression: first` option, the first - * token of each element in the array after the first will be mapped to the first token of the first - * element. The desired indentation of each of these tokens is computed based on the desired indentation - * of the "first" element, rather than through the normal offset mechanism. - */ - this._lockedFirstTokens.set(offsetToken, baseToken); - } - - /** - * Sets the desired offset of a token. - * - * This uses a line-based offset collapsing behavior to handle tokens on the same line. - * For example, consider the following two cases: - * - * ( - * [ - * bar - * ] - * ) - * - * ([ - * bar - * ]) - * - * Based on the first case, it's clear that the `bar` token needs to have an offset of 1 indent level (4 spaces) from - * the `[` token, and the `[` token has to have an offset of 1 indent level from the `(` token. Since the `(` token is - * the first on its line (with an indent of 0 spaces), the `bar` token needs to be offset by 2 indent levels (8 spaces) - * from the start of its line. - * - * However, in the second case `bar` should only be indented by 4 spaces. This is because the offset of 1 indent level - * between the `(` and the `[` tokens gets "collapsed" because the two tokens are on the same line. As a result, the - * `(` token is mapped to the `[` token with an offset of 0, and the rule correctly decides that `bar` should be indented - * by 1 indent level from the start of the line. - * - * This is useful because rule listeners can usually just call `setDesiredOffset` for all the tokens in the node, - * without needing to check which lines those tokens are on. - * - * Note that since collapsing only occurs when two tokens are on the same line, there are a few cases where non-intuitive - * behavior can occur. For example, consider the following cases: - * - * foo( - * ). - * bar( - * baz - * ) - * - * foo( - * ).bar( - * baz - * ) - * - * Based on the first example, it would seem that `bar` should be offset by 1 indent level from `foo`, and `baz` - * should be offset by 1 indent level from `bar`. However, this is not correct, because it would result in `baz` - * being indented by 2 indent levels in the second case (since `foo`, `bar`, and `baz` are all on separate lines, no - * collapsing would occur). - * - * Instead, the correct way would be to offset `baz` by 1 level from `bar`, offset `bar` by 1 level from the `)`, and - * offset the `)` by 0 levels from `foo`. This ensures that the offset between `bar` and the `)` are correctly collapsed - * in the second case. - * @param {Token} token The token - * @param {Token} fromToken The token that `token` should be offset from - * @param {number} offset The desired indent level - * @returns {void} - */ - setDesiredOffset(token, fromToken, offset) { - return this.setDesiredOffsets(token.range, fromToken, offset); - } - - /** - * Sets the desired offset of all tokens in a range - * It's common for node listeners in this file to need to apply the same offset to a large, contiguous range of tokens. - * Moreover, the offset of any given token is usually updated multiple times (roughly once for each node that contains - * it). This means that the offset of each token is updated O(AST depth) times. - * It would not be performant to store and update the offsets for each token independently, because the rule would end - * up having a time complexity of O(number of tokens * AST depth), which is quite slow for large files. - * - * Instead, the offset tree is represented as a collection of contiguous offset ranges in a file. For example, the following - * list could represent the state of the offset tree at a given point: - * - * - Tokens starting in the interval [0, 15) are aligned with the beginning of the file - * - Tokens starting in the interval [15, 30) are offset by 1 indent level from the `bar` token - * - Tokens starting in the interval [30, 43) are offset by 1 indent level from the `foo` token - * - Tokens starting in the interval [43, 820) are offset by 2 indent levels from the `bar` token - * - Tokens starting in the interval [820, โˆž) are offset by 1 indent level from the `baz` token - * - * The `setDesiredOffsets` methods inserts ranges like the ones above. The third line above would be inserted by using: - * `setDesiredOffsets([30, 43], fooToken, 1);` - * @param {[number, number]} range A [start, end] pair. All tokens with range[0] <= token.start < range[1] will have the offset applied. - * @param {Token} fromToken The token that this is offset from - * @param {number} offset The desired indent level - * @param {boolean} force `true` if this offset should not use the normal collapsing behavior. This should almost always be false. - * @returns {void} - */ - setDesiredOffsets(range, fromToken, offset, force) { - - /* - * Offset ranges are stored as a collection of nodes, where each node maps a numeric key to an offset - * descriptor. The tree for the example above would have the following nodes: - * - * * key: 0, value: { offset: 0, from: null } - * * key: 15, value: { offset: 1, from: barToken } - * * key: 30, value: { offset: 1, from: fooToken } - * * key: 43, value: { offset: 2, from: barToken } - * * key: 820, value: { offset: 1, from: bazToken } - * - * To find the offset descriptor for any given token, one needs to find the node with the largest key - * which is <= token.start. To make this operation fast, the nodes are stored in a map indexed by key. - */ - - const descriptorToInsert = { offset, from: fromToken, force }; - - const descriptorAfterRange = this._indexMap.findLastNotAfter(range[1]); - - const fromTokenIsInRange = fromToken && fromToken.range[0] >= range[0] && fromToken.range[1] <= range[1]; - const fromTokenDescriptor = fromTokenIsInRange && this._getOffsetDescriptor(fromToken); - - // First, remove any existing nodes in the range from the map. - this._indexMap.deleteRange(range[0] + 1, range[1]); - - // Insert a new node into the map for this range - this._indexMap.insert(range[0], descriptorToInsert); - - /* - * To avoid circular offset dependencies, keep the `fromToken` token mapped to whatever it was mapped to previously, - * even if it's in the current range. - */ - if (fromTokenIsInRange) { - this._indexMap.insert(fromToken.range[0], fromTokenDescriptor); - this._indexMap.insert(fromToken.range[1], descriptorToInsert); - } - - /* - * To avoid modifying the offset of tokens after the range, insert another node to keep the offset of the following - * tokens the same as it was before. - */ - this._indexMap.insert(range[1], descriptorAfterRange); - } - - /** - * Gets the desired indent of a token - * @param {Token} token The token - * @returns {string} The desired indent of the token - */ - getDesiredIndent(token) { - if (!this._desiredIndentCache.has(token)) { - - if (this._ignoredTokens.has(token)) { - - /* - * If the token is ignored, use the actual indent of the token as the desired indent. - * This ensures that no errors are reported for this token. - */ - this._desiredIndentCache.set( - token, - this._tokenInfo.getTokenIndent(token) - ); - } else if (this._lockedFirstTokens.has(token)) { - const firstToken = this._lockedFirstTokens.get(token); - - this._desiredIndentCache.set( - token, - - // (indentation for the first element's line) - this.getDesiredIndent(this._tokenInfo.getFirstTokenOfLine(firstToken)) + - - // (space between the start of the first element's line and the first element) - this._indentType.repeat(firstToken.loc.start.column - this._tokenInfo.getFirstTokenOfLine(firstToken).loc.start.column) - ); - } else { - const offsetInfo = this._getOffsetDescriptor(token); - const offset = ( - offsetInfo.from && - offsetInfo.from.loc.start.line === token.loc.start.line && - !/^\s*?\n/u.test(token.value) && - !offsetInfo.force - ) ? 0 : offsetInfo.offset * this._indentSize; - - this._desiredIndentCache.set( - token, - (offsetInfo.from ? this.getDesiredIndent(offsetInfo.from) : "") + this._indentType.repeat(offset) - ); - } - } - return this._desiredIndentCache.get(token); - } - - /** - * Ignores a token, preventing it from being reported. - * @param {Token} token The token - * @returns {void} - */ - ignoreToken(token) { - if (this._tokenInfo.isFirstTokenOfLine(token)) { - this._ignoredTokens.add(token); - } - } - - /** - * Gets the first token that the given token's indentation is dependent on - * @param {Token} token The token - * @returns {Token} The token that the given token depends on, or `null` if the given token is at the top level - */ - getFirstDependency(token) { - return this._getOffsetDescriptor(token).from; - } -} - -const ELEMENT_LIST_SCHEMA = { - oneOf: [ - { - type: "integer", - minimum: 0 - }, - { - enum: ["first", "off"] - } - ] -}; - -/** @type {import('../shared/types').Rule} */ -module.exports = { - meta: { - deprecated: true, - replacedBy: [], - type: "layout", - - docs: { - description: "Enforce consistent indentation", - recommended: false, - url: "https://eslint.org/docs/latest/rules/indent" - }, - - fixable: "whitespace", - - schema: [ - { - oneOf: [ - { - enum: ["tab"] - }, - { - type: "integer", - minimum: 0 - } - ] - }, - { - type: "object", - properties: { - SwitchCase: { - type: "integer", - minimum: 0, - default: 0 - }, - VariableDeclarator: { - oneOf: [ - ELEMENT_LIST_SCHEMA, - { - type: "object", - properties: { - var: ELEMENT_LIST_SCHEMA, - let: ELEMENT_LIST_SCHEMA, - const: ELEMENT_LIST_SCHEMA - }, - additionalProperties: false - } - ] - }, - outerIIFEBody: { - oneOf: [ - { - type: "integer", - minimum: 0 - }, - { - enum: ["off"] - } - ] - }, - MemberExpression: { - oneOf: [ - { - type: "integer", - minimum: 0 - }, - { - enum: ["off"] - } - ] - }, - FunctionDeclaration: { - type: "object", - properties: { - parameters: ELEMENT_LIST_SCHEMA, - body: { - type: "integer", - minimum: 0 - } - }, - additionalProperties: false - }, - FunctionExpression: { - type: "object", - properties: { - parameters: ELEMENT_LIST_SCHEMA, - body: { - type: "integer", - minimum: 0 - } - }, - additionalProperties: false - }, - StaticBlock: { - type: "object", - properties: { - body: { - type: "integer", - minimum: 0 - } - }, - additionalProperties: false - }, - CallExpression: { - type: "object", - properties: { - arguments: ELEMENT_LIST_SCHEMA - }, - additionalProperties: false - }, - ArrayExpression: ELEMENT_LIST_SCHEMA, - ObjectExpression: ELEMENT_LIST_SCHEMA, - ImportDeclaration: ELEMENT_LIST_SCHEMA, - flatTernaryExpressions: { - type: "boolean", - default: false - }, - offsetTernaryExpressions: { - type: "boolean", - default: false - }, - ignoredNodes: { - type: "array", - items: { - type: "string", - not: { - pattern: ":exit$" - } - } - }, - ignoreComments: { - type: "boolean", - default: false - } - }, - additionalProperties: false - } - ], - messages: { - wrongIndentation: "Expected indentation of {{expected}} but found {{actual}}." - } - }, - - create(context) { - const DEFAULT_VARIABLE_INDENT = 1; - const DEFAULT_PARAMETER_INDENT = 1; - const DEFAULT_FUNCTION_BODY_INDENT = 1; - - let indentType = "space"; - let indentSize = 4; - const options = { - SwitchCase: 0, - VariableDeclarator: { - var: DEFAULT_VARIABLE_INDENT, - let: DEFAULT_VARIABLE_INDENT, - const: DEFAULT_VARIABLE_INDENT - }, - outerIIFEBody: 1, - FunctionDeclaration: { - parameters: DEFAULT_PARAMETER_INDENT, - body: DEFAULT_FUNCTION_BODY_INDENT - }, - FunctionExpression: { - parameters: DEFAULT_PARAMETER_INDENT, - body: DEFAULT_FUNCTION_BODY_INDENT - }, - StaticBlock: { - body: DEFAULT_FUNCTION_BODY_INDENT - }, - CallExpression: { - arguments: DEFAULT_PARAMETER_INDENT - }, - MemberExpression: 1, - ArrayExpression: 1, - ObjectExpression: 1, - ImportDeclaration: 1, - flatTernaryExpressions: false, - ignoredNodes: [], - ignoreComments: false - }; - - if (context.options.length) { - if (context.options[0] === "tab") { - indentSize = 1; - indentType = "tab"; - } else { - indentSize = context.options[0]; - indentType = "space"; - } - - if (context.options[1]) { - Object.assign(options, context.options[1]); - - if (typeof options.VariableDeclarator === "number" || options.VariableDeclarator === "first") { - options.VariableDeclarator = { - var: options.VariableDeclarator, - let: options.VariableDeclarator, - const: options.VariableDeclarator - }; - } - } - } - - const sourceCode = context.sourceCode; - const tokenInfo = new TokenInfo(sourceCode); - const offsets = new OffsetStorage(tokenInfo, indentSize, indentType === "space" ? " " : "\t", sourceCode.text.length); - const parameterParens = new WeakSet(); - - /** - * Creates an error message for a line, given the expected/actual indentation. - * @param {int} expectedAmount The expected amount of indentation characters for this line - * @param {int} actualSpaces The actual number of indentation spaces that were found on this line - * @param {int} actualTabs The actual number of indentation tabs that were found on this line - * @returns {string} An error message for this line - */ - function createErrorMessageData(expectedAmount, actualSpaces, actualTabs) { - const expectedStatement = `${expectedAmount} ${indentType}${expectedAmount === 1 ? "" : "s"}`; // e.g. "2 tabs" - const foundSpacesWord = `space${actualSpaces === 1 ? "" : "s"}`; // e.g. "space" - const foundTabsWord = `tab${actualTabs === 1 ? "" : "s"}`; // e.g. "tabs" - let foundStatement; - - if (actualSpaces > 0) { - - /* - * Abbreviate the message if the expected indentation is also spaces. - * e.g. 'Expected 4 spaces but found 2' rather than 'Expected 4 spaces but found 2 spaces' - */ - foundStatement = indentType === "space" ? actualSpaces : `${actualSpaces} ${foundSpacesWord}`; - } else if (actualTabs > 0) { - foundStatement = indentType === "tab" ? actualTabs : `${actualTabs} ${foundTabsWord}`; - } else { - foundStatement = "0"; - } - return { - expected: expectedStatement, - actual: foundStatement - }; - } - - /** - * Reports a given indent violation - * @param {Token} token Token violating the indent rule - * @param {string} neededIndent Expected indentation string - * @returns {void} - */ - function report(token, neededIndent) { - const actualIndent = Array.from(tokenInfo.getTokenIndent(token)); - const numSpaces = actualIndent.filter(char => char === " ").length; - const numTabs = actualIndent.filter(char => char === "\t").length; - - context.report({ - node: token, - messageId: "wrongIndentation", - data: createErrorMessageData(neededIndent.length, numSpaces, numTabs), - loc: { - start: { line: token.loc.start.line, column: 0 }, - end: { line: token.loc.start.line, column: token.loc.start.column } - }, - fix(fixer) { - const range = [token.range[0] - token.loc.start.column, token.range[0]]; - const newText = neededIndent; - - return fixer.replaceTextRange(range, newText); - } - }); - } - - /** - * Checks if a token's indentation is correct - * @param {Token} token Token to examine - * @param {string} desiredIndent Desired indentation of the string - * @returns {boolean} `true` if the token's indentation is correct - */ - function validateTokenIndent(token, desiredIndent) { - const indentation = tokenInfo.getTokenIndent(token); - - return indentation === desiredIndent || - - // To avoid conflicts with no-mixed-spaces-and-tabs, don't report mixed spaces and tabs. - indentation.includes(" ") && indentation.includes("\t"); - } - - /** - * Check to see if the node is a file level IIFE - * @param {ASTNode} node The function node to check. - * @returns {boolean} True if the node is the outer IIFE - */ - function isOuterIIFE(node) { - - /* - * Verify that the node is an IIFE - */ - if (!node.parent || node.parent.type !== "CallExpression" || node.parent.callee !== node) { - return false; - } - - /* - * Navigate legal ancestors to determine whether this IIFE is outer. - * A "legal ancestor" is an expression or statement that causes the function to get executed immediately. - * For example, `!(function(){})()` is an outer IIFE even though it is preceded by a ! operator. - */ - let statement = node.parent && node.parent.parent; - - while ( - statement.type === "UnaryExpression" && ["!", "~", "+", "-"].includes(statement.operator) || - statement.type === "AssignmentExpression" || - statement.type === "LogicalExpression" || - statement.type === "SequenceExpression" || - statement.type === "VariableDeclarator" - ) { - statement = statement.parent; - } - - return (statement.type === "ExpressionStatement" || statement.type === "VariableDeclaration") && statement.parent.type === "Program"; - } - - /** - * Counts the number of linebreaks that follow the last non-whitespace character in a string - * @param {string} string The string to check - * @returns {number} The number of JavaScript linebreaks that follow the last non-whitespace character, - * or the total number of linebreaks if the string is all whitespace. - */ - function countTrailingLinebreaks(string) { - const trailingWhitespace = string.match(/\s*$/u)[0]; - const linebreakMatches = trailingWhitespace.match(astUtils.createGlobalLinebreakMatcher()); - - return linebreakMatches === null ? 0 : linebreakMatches.length; - } - - /** - * Check indentation for lists of elements (arrays, objects, function params) - * @param {ASTNode[]} elements List of elements that should be offset - * @param {Token} startToken The start token of the list that element should be aligned against, e.g. '[' - * @param {Token} endToken The end token of the list, e.g. ']' - * @param {number|string} offset The amount that the elements should be offset - * @returns {void} - */ - function addElementListIndent(elements, startToken, endToken, offset) { - - /** - * Gets the first token of a given element, including surrounding parentheses. - * @param {ASTNode} element A node in the `elements` list - * @returns {Token} The first token of this element - */ - function getFirstToken(element) { - let token = sourceCode.getTokenBefore(element); - - while (astUtils.isOpeningParenToken(token) && token !== startToken) { - token = sourceCode.getTokenBefore(token); - } - return sourceCode.getTokenAfter(token); - } - - // Run through all the tokens in the list, and offset them by one indent level (mainly for comments, other things will end up overridden) - offsets.setDesiredOffsets( - [startToken.range[1], endToken.range[0]], - startToken, - typeof offset === "number" ? offset : 1 - ); - offsets.setDesiredOffset(endToken, startToken, 0); - - // If the preference is "first" but there is no first element (e.g. sparse arrays w/ empty first slot), fall back to 1 level. - if (offset === "first" && elements.length && !elements[0]) { - return; - } - elements.forEach((element, index) => { - if (!element) { - - // Skip holes in arrays - return; - } - if (offset === "off") { - - // Ignore the first token of every element if the "off" option is used - offsets.ignoreToken(getFirstToken(element)); - } - - // Offset the following elements correctly relative to the first element - if (index === 0) { - return; - } - if (offset === "first" && tokenInfo.isFirstTokenOfLine(getFirstToken(element))) { - offsets.matchOffsetOf(getFirstToken(elements[0]), getFirstToken(element)); - } else { - const previousElement = elements[index - 1]; - const firstTokenOfPreviousElement = previousElement && getFirstToken(previousElement); - const previousElementLastToken = previousElement && sourceCode.getLastToken(previousElement); - - if ( - previousElement && - previousElementLastToken.loc.end.line - countTrailingLinebreaks(previousElementLastToken.value) > startToken.loc.end.line - ) { - offsets.setDesiredOffsets( - [previousElement.range[1], element.range[1]], - firstTokenOfPreviousElement, - 0 - ); - } - } - }); - } - - /** - * Check and decide whether to check for indentation for blockless nodes - * Scenarios are for or while statements without braces around them - * @param {ASTNode} node node to examine - * @returns {void} - */ - function addBlocklessNodeIndent(node) { - if (node.type !== "BlockStatement") { - const lastParentToken = sourceCode.getTokenBefore(node, astUtils.isNotOpeningParenToken); - - let firstBodyToken = sourceCode.getFirstToken(node); - let lastBodyToken = sourceCode.getLastToken(node); - - while ( - astUtils.isOpeningParenToken(sourceCode.getTokenBefore(firstBodyToken)) && - astUtils.isClosingParenToken(sourceCode.getTokenAfter(lastBodyToken)) - ) { - firstBodyToken = sourceCode.getTokenBefore(firstBodyToken); - lastBodyToken = sourceCode.getTokenAfter(lastBodyToken); - } - - offsets.setDesiredOffsets([firstBodyToken.range[0], lastBodyToken.range[1]], lastParentToken, 1); - } - } - - /** - * Checks the indentation for nodes that are like function calls (`CallExpression` and `NewExpression`) - * @param {ASTNode} node A CallExpression or NewExpression node - * @returns {void} - */ - function addFunctionCallIndent(node) { - let openingParen; - - if (node.arguments.length) { - openingParen = sourceCode.getFirstTokenBetween(node.callee, node.arguments[0], astUtils.isOpeningParenToken); - } else { - openingParen = sourceCode.getLastToken(node, 1); - } - const closingParen = sourceCode.getLastToken(node); - - parameterParens.add(openingParen); - parameterParens.add(closingParen); - - /* - * If `?.` token exists, set desired offset for that. - * This logic is copied from `MemberExpression`'s. - */ - if (node.optional) { - const dotToken = sourceCode.getTokenAfter(node.callee, astUtils.isQuestionDotToken); - const calleeParenCount = sourceCode.getTokensBetween(node.callee, dotToken, { filter: astUtils.isClosingParenToken }).length; - const firstTokenOfCallee = calleeParenCount - ? sourceCode.getTokenBefore(node.callee, { skip: calleeParenCount - 1 }) - : sourceCode.getFirstToken(node.callee); - const lastTokenOfCallee = sourceCode.getTokenBefore(dotToken); - const offsetBase = lastTokenOfCallee.loc.end.line === openingParen.loc.start.line - ? lastTokenOfCallee - : firstTokenOfCallee; - - offsets.setDesiredOffset(dotToken, offsetBase, 1); - } - - const offsetAfterToken = node.callee.type === "TaggedTemplateExpression" ? sourceCode.getFirstToken(node.callee.quasi) : openingParen; - const offsetToken = sourceCode.getTokenBefore(offsetAfterToken); - - offsets.setDesiredOffset(openingParen, offsetToken, 0); - - addElementListIndent(node.arguments, openingParen, closingParen, options.CallExpression.arguments); - } - - /** - * Checks the indentation of parenthesized values, given a list of tokens in a program - * @param {Token[]} tokens A list of tokens - * @returns {void} - */ - function addParensIndent(tokens) { - const parenStack = []; - const parenPairs = []; - - for (let i = 0; i < tokens.length; i++) { - const nextToken = tokens[i]; - - if (astUtils.isOpeningParenToken(nextToken)) { - parenStack.push(nextToken); - } else if (astUtils.isClosingParenToken(nextToken)) { - parenPairs.push({ left: parenStack.pop(), right: nextToken }); - } - } - - for (let i = parenPairs.length - 1; i >= 0; i--) { - const leftParen = parenPairs[i].left; - const rightParen = parenPairs[i].right; - - // We only want to handle parens around expressions, so exclude parentheses that are in function parameters and function call arguments. - if (!parameterParens.has(leftParen) && !parameterParens.has(rightParen)) { - const parenthesizedTokens = new Set(sourceCode.getTokensBetween(leftParen, rightParen)); - - parenthesizedTokens.forEach(token => { - if (!parenthesizedTokens.has(offsets.getFirstDependency(token))) { - offsets.setDesiredOffset(token, leftParen, 1); - } - }); - } - - offsets.setDesiredOffset(rightParen, leftParen, 0); - } - } - - /** - * Ignore all tokens within an unknown node whose offset do not depend - * on another token's offset within the unknown node - * @param {ASTNode} node Unknown Node - * @returns {void} - */ - function ignoreNode(node) { - const unknownNodeTokens = new Set(sourceCode.getTokens(node, { includeComments: true })); - - unknownNodeTokens.forEach(token => { - if (!unknownNodeTokens.has(offsets.getFirstDependency(token))) { - const firstTokenOfLine = tokenInfo.getFirstTokenOfLine(token); - - if (token === firstTokenOfLine) { - offsets.ignoreToken(token); - } else { - offsets.setDesiredOffset(token, firstTokenOfLine, 0); - } - } - }); - } - - /** - * Check whether the given token is on the first line of a statement. - * @param {Token} token The token to check. - * @param {ASTNode} leafNode The expression node that the token belongs directly. - * @returns {boolean} `true` if the token is on the first line of a statement. - */ - function isOnFirstLineOfStatement(token, leafNode) { - let node = leafNode; - - while (node.parent && !node.parent.type.endsWith("Statement") && !node.parent.type.endsWith("Declaration")) { - node = node.parent; - } - node = node.parent; - - return !node || node.loc.start.line === token.loc.start.line; - } - - /** - * Check whether there are any blank (whitespace-only) lines between - * two tokens on separate lines. - * @param {Token} firstToken The first token. - * @param {Token} secondToken The second token. - * @returns {boolean} `true` if the tokens are on separate lines and - * there exists a blank line between them, `false` otherwise. - */ - function hasBlankLinesBetween(firstToken, secondToken) { - const firstTokenLine = firstToken.loc.end.line; - const secondTokenLine = secondToken.loc.start.line; - - if (firstTokenLine === secondTokenLine || firstTokenLine === secondTokenLine - 1) { - return false; - } - - for (let line = firstTokenLine + 1; line < secondTokenLine; ++line) { - if (!tokenInfo.firstTokensByLineNumber.has(line)) { - return true; - } - } - - return false; - } - - const ignoredNodeFirstTokens = new Set(); - - const baseOffsetListeners = { - "ArrayExpression, ArrayPattern"(node) { - const openingBracket = sourceCode.getFirstToken(node); - const closingBracket = sourceCode.getTokenAfter([...node.elements].reverse().find(_ => _) || openingBracket, astUtils.isClosingBracketToken); - - addElementListIndent(node.elements, openingBracket, closingBracket, options.ArrayExpression); - }, - - "ObjectExpression, ObjectPattern"(node) { - const openingCurly = sourceCode.getFirstToken(node); - const closingCurly = sourceCode.getTokenAfter( - node.properties.length ? node.properties.at(-1) : openingCurly, - astUtils.isClosingBraceToken - ); - - addElementListIndent(node.properties, openingCurly, closingCurly, options.ObjectExpression); - }, - - ArrowFunctionExpression(node) { - const maybeOpeningParen = sourceCode.getFirstToken(node, { skip: node.async ? 1 : 0 }); - - if (astUtils.isOpeningParenToken(maybeOpeningParen)) { - const openingParen = maybeOpeningParen; - const closingParen = sourceCode.getTokenBefore(node.body, astUtils.isClosingParenToken); - - parameterParens.add(openingParen); - parameterParens.add(closingParen); - addElementListIndent(node.params, openingParen, closingParen, options.FunctionExpression.parameters); - } - - addBlocklessNodeIndent(node.body); - }, - - AssignmentExpression(node) { - const operator = sourceCode.getFirstTokenBetween(node.left, node.right, token => token.value === node.operator); - - offsets.setDesiredOffsets([operator.range[0], node.range[1]], sourceCode.getLastToken(node.left), 1); - offsets.ignoreToken(operator); - offsets.ignoreToken(sourceCode.getTokenAfter(operator)); - }, - - "BinaryExpression, LogicalExpression"(node) { - const operator = sourceCode.getFirstTokenBetween(node.left, node.right, token => token.value === node.operator); - - /* - * For backwards compatibility, don't check BinaryExpression indents, e.g. - * var foo = bar && - * baz; - */ - - const tokenAfterOperator = sourceCode.getTokenAfter(operator); - - offsets.ignoreToken(operator); - offsets.ignoreToken(tokenAfterOperator); - offsets.setDesiredOffset(tokenAfterOperator, operator, 0); - }, - - "BlockStatement, ClassBody"(node) { - let blockIndentLevel; - - if (node.parent && isOuterIIFE(node.parent)) { - blockIndentLevel = options.outerIIFEBody; - } else if (node.parent && (node.parent.type === "FunctionExpression" || node.parent.type === "ArrowFunctionExpression")) { - blockIndentLevel = options.FunctionExpression.body; - } else if (node.parent && node.parent.type === "FunctionDeclaration") { - blockIndentLevel = options.FunctionDeclaration.body; - } else { - blockIndentLevel = 1; - } - - /* - * For blocks that aren't lone statements, ensure that the opening curly brace - * is aligned with the parent. - */ - if (!astUtils.STATEMENT_LIST_PARENTS.has(node.parent.type)) { - offsets.setDesiredOffset(sourceCode.getFirstToken(node), sourceCode.getFirstToken(node.parent), 0); - } - - addElementListIndent(node.body, sourceCode.getFirstToken(node), sourceCode.getLastToken(node), blockIndentLevel); - }, - - CallExpression: addFunctionCallIndent, - - "ClassDeclaration[superClass], ClassExpression[superClass]"(node) { - const classToken = sourceCode.getFirstToken(node); - const extendsToken = sourceCode.getTokenBefore(node.superClass, astUtils.isNotOpeningParenToken); - - offsets.setDesiredOffsets([extendsToken.range[0], node.body.range[0]], classToken, 1); - }, - - ConditionalExpression(node) { - const firstToken = sourceCode.getFirstToken(node); - - // `flatTernaryExpressions` option is for the following style: - // var a = - // foo > 0 ? bar : - // foo < 0 ? baz : - // /*else*/ qiz ; - if (!options.flatTernaryExpressions || - !astUtils.isTokenOnSameLine(node.test, node.consequent) || - isOnFirstLineOfStatement(firstToken, node) - ) { - const questionMarkToken = sourceCode.getFirstTokenBetween(node.test, node.consequent, token => token.type === "Punctuator" && token.value === "?"); - const colonToken = sourceCode.getFirstTokenBetween(node.consequent, node.alternate, token => token.type === "Punctuator" && token.value === ":"); - - const firstConsequentToken = sourceCode.getTokenAfter(questionMarkToken); - const lastConsequentToken = sourceCode.getTokenBefore(colonToken); - const firstAlternateToken = sourceCode.getTokenAfter(colonToken); - - offsets.setDesiredOffset(questionMarkToken, firstToken, 1); - offsets.setDesiredOffset(colonToken, firstToken, 1); - - offsets.setDesiredOffset(firstConsequentToken, firstToken, firstConsequentToken.type === "Punctuator" && - options.offsetTernaryExpressions ? 2 : 1); - - /* - * The alternate and the consequent should usually have the same indentation. - * If they share part of a line, align the alternate against the first token of the consequent. - * This allows the alternate to be indented correctly in cases like this: - * foo ? ( - * bar - * ) : ( // this '(' is aligned with the '(' above, so it's considered to be aligned with `foo` - * baz // as a result, `baz` is offset by 1 rather than 2 - * ) - */ - if (lastConsequentToken.loc.end.line === firstAlternateToken.loc.start.line) { - offsets.setDesiredOffset(firstAlternateToken, firstConsequentToken, 0); - } else { - - /** - * If the alternate and consequent do not share part of a line, offset the alternate from the first - * token of the conditional expression. For example: - * foo ? bar - * : baz - * - * If `baz` were aligned with `bar` rather than being offset by 1 from `foo`, `baz` would end up - * having no expected indentation. - */ - offsets.setDesiredOffset(firstAlternateToken, firstToken, firstAlternateToken.type === "Punctuator" && - options.offsetTernaryExpressions ? 2 : 1); - } - } - }, - - "DoWhileStatement, WhileStatement, ForInStatement, ForOfStatement, WithStatement": node => addBlocklessNodeIndent(node.body), - - ExportNamedDeclaration(node) { - if (node.declaration === null) { - const closingCurly = sourceCode.getLastToken(node, astUtils.isClosingBraceToken); - - // Indent the specifiers in `export {foo, bar, baz}` - addElementListIndent(node.specifiers, sourceCode.getFirstToken(node, { skip: 1 }), closingCurly, 1); - - if (node.source) { - - // Indent everything after and including the `from` token in `export {foo, bar, baz} from 'qux'` - offsets.setDesiredOffsets([closingCurly.range[1], node.range[1]], sourceCode.getFirstToken(node), 1); - } - } - }, - - ForStatement(node) { - const forOpeningParen = sourceCode.getFirstToken(node, 1); - - if (node.init) { - offsets.setDesiredOffsets(node.init.range, forOpeningParen, 1); - } - if (node.test) { - offsets.setDesiredOffsets(node.test.range, forOpeningParen, 1); - } - if (node.update) { - offsets.setDesiredOffsets(node.update.range, forOpeningParen, 1); - } - addBlocklessNodeIndent(node.body); - }, - - "FunctionDeclaration, FunctionExpression"(node) { - const closingParen = sourceCode.getTokenBefore(node.body); - const openingParen = sourceCode.getTokenBefore(node.params.length ? node.params[0] : closingParen); - - parameterParens.add(openingParen); - parameterParens.add(closingParen); - addElementListIndent(node.params, openingParen, closingParen, options[node.type].parameters); - }, - - IfStatement(node) { - addBlocklessNodeIndent(node.consequent); - if (node.alternate) { - addBlocklessNodeIndent(node.alternate); - } - }, - - /* - * For blockless nodes with semicolon-first style, don't indent the semicolon. - * e.g. - * if (foo) - * bar() - * ; [1, 2, 3].map(foo) - * - * Traversal into the node sets indentation of the semicolon, so we need to override it on exit. - */ - ":matches(DoWhileStatement, ForStatement, ForInStatement, ForOfStatement, IfStatement, WhileStatement, WithStatement):exit"(node) { - let nodesToCheck; - - if (node.type === "IfStatement") { - nodesToCheck = [node.consequent]; - if (node.alternate) { - nodesToCheck.push(node.alternate); - } - } else { - nodesToCheck = [node.body]; - } - - for (const nodeToCheck of nodesToCheck) { - const lastToken = sourceCode.getLastToken(nodeToCheck); - - if (astUtils.isSemicolonToken(lastToken)) { - const tokenBeforeLast = sourceCode.getTokenBefore(lastToken); - const tokenAfterLast = sourceCode.getTokenAfter(lastToken); - - // override indentation of `;` only if its line looks like a semicolon-first style line - if ( - !astUtils.isTokenOnSameLine(tokenBeforeLast, lastToken) && - tokenAfterLast && - astUtils.isTokenOnSameLine(lastToken, tokenAfterLast) - ) { - offsets.setDesiredOffset( - lastToken, - sourceCode.getFirstToken(node), - 0 - ); - } - } - } - }, - - ImportDeclaration(node) { - if (node.specifiers.some(specifier => specifier.type === "ImportSpecifier")) { - const openingCurly = sourceCode.getFirstToken(node, astUtils.isOpeningBraceToken); - const closingCurly = sourceCode.getLastToken(node, astUtils.isClosingBraceToken); - - addElementListIndent(node.specifiers.filter(specifier => specifier.type === "ImportSpecifier"), openingCurly, closingCurly, options.ImportDeclaration); - } - - const fromToken = sourceCode.getLastToken(node, token => token.type === "Identifier" && token.value === "from"); - const sourceToken = sourceCode.getLastToken(node, token => token.type === "String"); - const semiToken = sourceCode.getLastToken(node, token => token.type === "Punctuator" && token.value === ";"); - - if (fromToken) { - const end = semiToken && semiToken.range[1] === sourceToken.range[1] ? node.range[1] : sourceToken.range[1]; - - offsets.setDesiredOffsets([fromToken.range[0], end], sourceCode.getFirstToken(node), 1); - } - }, - - ImportExpression(node) { - const openingParen = sourceCode.getFirstToken(node, 1); - const closingParen = sourceCode.getLastToken(node); - - parameterParens.add(openingParen); - parameterParens.add(closingParen); - offsets.setDesiredOffset(openingParen, sourceCode.getTokenBefore(openingParen), 0); - - addElementListIndent([node.source], openingParen, closingParen, options.CallExpression.arguments); - }, - - "MemberExpression, JSXMemberExpression, MetaProperty"(node) { - const object = node.type === "MetaProperty" ? node.meta : node.object; - const firstNonObjectToken = sourceCode.getFirstTokenBetween(object, node.property, astUtils.isNotClosingParenToken); - const secondNonObjectToken = sourceCode.getTokenAfter(firstNonObjectToken); - - const objectParenCount = sourceCode.getTokensBetween(object, node.property, { filter: astUtils.isClosingParenToken }).length; - const firstObjectToken = objectParenCount - ? sourceCode.getTokenBefore(object, { skip: objectParenCount - 1 }) - : sourceCode.getFirstToken(object); - const lastObjectToken = sourceCode.getTokenBefore(firstNonObjectToken); - const firstPropertyToken = node.computed ? firstNonObjectToken : secondNonObjectToken; - - if (node.computed) { - - // For computed MemberExpressions, match the closing bracket with the opening bracket. - offsets.setDesiredOffset(sourceCode.getLastToken(node), firstNonObjectToken, 0); - offsets.setDesiredOffsets(node.property.range, firstNonObjectToken, 1); - } - - /* - * If the object ends on the same line that the property starts, match against the last token - * of the object, to ensure that the MemberExpression is not indented. - * - * Otherwise, match against the first token of the object, e.g. - * foo - * .bar - * .baz // <-- offset by 1 from `foo` - */ - const offsetBase = lastObjectToken.loc.end.line === firstPropertyToken.loc.start.line - ? lastObjectToken - : firstObjectToken; - - if (typeof options.MemberExpression === "number") { - - // Match the dot (for non-computed properties) or the opening bracket (for computed properties) against the object. - offsets.setDesiredOffset(firstNonObjectToken, offsetBase, options.MemberExpression); - - /* - * For computed MemberExpressions, match the first token of the property against the opening bracket. - * Otherwise, match the first token of the property against the object. - */ - offsets.setDesiredOffset(secondNonObjectToken, node.computed ? firstNonObjectToken : offsetBase, options.MemberExpression); - } else { - - // If the MemberExpression option is off, ignore the dot and the first token of the property. - offsets.ignoreToken(firstNonObjectToken); - offsets.ignoreToken(secondNonObjectToken); - - // To ignore the property indentation, ensure that the property tokens depend on the ignored tokens. - offsets.setDesiredOffset(firstNonObjectToken, offsetBase, 0); - offsets.setDesiredOffset(secondNonObjectToken, firstNonObjectToken, 0); - } - }, - - NewExpression(node) { - - // Only indent the arguments if the NewExpression has parens (e.g. `new Foo(bar)` or `new Foo()`, but not `new Foo` - if (node.arguments.length > 0 || - astUtils.isClosingParenToken(sourceCode.getLastToken(node)) && - astUtils.isOpeningParenToken(sourceCode.getLastToken(node, 1))) { - addFunctionCallIndent(node); - } - }, - - Property(node) { - if (!node.shorthand && !node.method && node.kind === "init") { - const colon = sourceCode.getFirstTokenBetween(node.key, node.value, astUtils.isColonToken); - - offsets.ignoreToken(sourceCode.getTokenAfter(colon)); - } - }, - - PropertyDefinition(node) { - const firstToken = sourceCode.getFirstToken(node); - const maybeSemicolonToken = sourceCode.getLastToken(node); - let keyLastToken; - - // Indent key. - if (node.computed) { - const bracketTokenL = sourceCode.getTokenBefore(node.key, astUtils.isOpeningBracketToken); - const bracketTokenR = keyLastToken = sourceCode.getTokenAfter(node.key, astUtils.isClosingBracketToken); - const keyRange = [bracketTokenL.range[1], bracketTokenR.range[0]]; - - if (bracketTokenL !== firstToken) { - offsets.setDesiredOffset(bracketTokenL, firstToken, 0); - } - offsets.setDesiredOffsets(keyRange, bracketTokenL, 1); - offsets.setDesiredOffset(bracketTokenR, bracketTokenL, 0); - } else { - const idToken = keyLastToken = sourceCode.getFirstToken(node.key); - - if (idToken !== firstToken) { - offsets.setDesiredOffset(idToken, firstToken, 1); - } - } - - // Indent initializer. - if (node.value) { - const eqToken = sourceCode.getTokenBefore(node.value, astUtils.isEqToken); - const valueToken = sourceCode.getTokenAfter(eqToken); - - offsets.setDesiredOffset(eqToken, keyLastToken, 1); - offsets.setDesiredOffset(valueToken, eqToken, 1); - if (astUtils.isSemicolonToken(maybeSemicolonToken)) { - offsets.setDesiredOffset(maybeSemicolonToken, eqToken, 1); - } - } else if (astUtils.isSemicolonToken(maybeSemicolonToken)) { - offsets.setDesiredOffset(maybeSemicolonToken, keyLastToken, 1); - } - }, - - StaticBlock(node) { - const openingCurly = sourceCode.getFirstToken(node, { skip: 1 }); // skip the `static` token - const closingCurly = sourceCode.getLastToken(node); - - addElementListIndent(node.body, openingCurly, closingCurly, options.StaticBlock.body); - }, - - SwitchStatement(node) { - const openingCurly = sourceCode.getTokenAfter(node.discriminant, astUtils.isOpeningBraceToken); - const closingCurly = sourceCode.getLastToken(node); - - offsets.setDesiredOffsets([openingCurly.range[1], closingCurly.range[0]], openingCurly, options.SwitchCase); - - if (node.cases.length) { - sourceCode.getTokensBetween( - node.cases.at(-1), - closingCurly, - { includeComments: true, filter: astUtils.isCommentToken } - ).forEach(token => offsets.ignoreToken(token)); - } - }, - - SwitchCase(node) { - if (!(node.consequent.length === 1 && node.consequent[0].type === "BlockStatement")) { - const caseKeyword = sourceCode.getFirstToken(node); - const tokenAfterCurrentCase = sourceCode.getTokenAfter(node); - - offsets.setDesiredOffsets([caseKeyword.range[1], tokenAfterCurrentCase.range[0]], caseKeyword, 1); - } - }, - - TemplateLiteral(node) { - node.expressions.forEach((expression, index) => { - const previousQuasi = node.quasis[index]; - const nextQuasi = node.quasis[index + 1]; - const tokenToAlignFrom = previousQuasi.loc.start.line === previousQuasi.loc.end.line - ? sourceCode.getFirstToken(previousQuasi) - : null; - - offsets.setDesiredOffsets([previousQuasi.range[1], nextQuasi.range[0]], tokenToAlignFrom, 1); - offsets.setDesiredOffset(sourceCode.getFirstToken(nextQuasi), tokenToAlignFrom, 0); - }); - }, - - VariableDeclaration(node) { - let variableIndent = Object.hasOwn(options.VariableDeclarator, node.kind) - ? options.VariableDeclarator[node.kind] - : DEFAULT_VARIABLE_INDENT; - - const firstToken = sourceCode.getFirstToken(node), - lastToken = sourceCode.getLastToken(node); - - if (options.VariableDeclarator[node.kind] === "first") { - if (node.declarations.length > 1) { - addElementListIndent( - node.declarations, - firstToken, - lastToken, - "first" - ); - return; - } - - variableIndent = DEFAULT_VARIABLE_INDENT; - } - - if (node.declarations.at(-1).loc.start.line > node.loc.start.line) { - - /* - * VariableDeclarator indentation is a bit different from other forms of indentation, in that the - * indentation of an opening bracket sometimes won't match that of a closing bracket. For example, - * the following indentations are correct: - * - * var foo = { - * ok: true - * }; - * - * var foo = { - * ok: true, - * }, - * bar = 1; - * - * Account for when exiting the AST (after indentations have already been set for the nodes in - * the declaration) by manually increasing the indentation level of the tokens in this declarator - * on the same line as the start of the declaration, provided that there are declarators that - * follow this one. - */ - offsets.setDesiredOffsets(node.range, firstToken, variableIndent, true); - } else { - offsets.setDesiredOffsets(node.range, firstToken, variableIndent); - } - - if (astUtils.isSemicolonToken(lastToken)) { - offsets.ignoreToken(lastToken); - } - }, - - VariableDeclarator(node) { - if (node.init) { - const equalOperator = sourceCode.getTokenBefore(node.init, astUtils.isNotOpeningParenToken); - const tokenAfterOperator = sourceCode.getTokenAfter(equalOperator); - - offsets.ignoreToken(equalOperator); - offsets.ignoreToken(tokenAfterOperator); - offsets.setDesiredOffsets([tokenAfterOperator.range[0], node.range[1]], equalOperator, 1); - offsets.setDesiredOffset(equalOperator, sourceCode.getLastToken(node.id), 0); - } - }, - - "JSXAttribute[value]"(node) { - const equalsToken = sourceCode.getFirstTokenBetween(node.name, node.value, token => token.type === "Punctuator" && token.value === "="); - - offsets.setDesiredOffsets([equalsToken.range[0], node.value.range[1]], sourceCode.getFirstToken(node.name), 1); - }, - - JSXElement(node) { - if (node.closingElement) { - addElementListIndent(node.children, sourceCode.getFirstToken(node.openingElement), sourceCode.getFirstToken(node.closingElement), 1); - } - }, - - JSXOpeningElement(node) { - const firstToken = sourceCode.getFirstToken(node); - let closingToken; - - if (node.selfClosing) { - closingToken = sourceCode.getLastToken(node, { skip: 1 }); - offsets.setDesiredOffset(sourceCode.getLastToken(node), closingToken, 0); - } else { - closingToken = sourceCode.getLastToken(node); - } - offsets.setDesiredOffsets(node.name.range, sourceCode.getFirstToken(node)); - addElementListIndent(node.attributes, firstToken, closingToken, 1); - }, - - JSXClosingElement(node) { - const firstToken = sourceCode.getFirstToken(node); - - offsets.setDesiredOffsets(node.name.range, firstToken, 1); - }, - - JSXFragment(node) { - const firstOpeningToken = sourceCode.getFirstToken(node.openingFragment); - const firstClosingToken = sourceCode.getFirstToken(node.closingFragment); - - addElementListIndent(node.children, firstOpeningToken, firstClosingToken, 1); - }, - - JSXOpeningFragment(node) { - const firstToken = sourceCode.getFirstToken(node); - const closingToken = sourceCode.getLastToken(node); - - offsets.setDesiredOffsets(node.range, firstToken, 1); - offsets.matchOffsetOf(firstToken, closingToken); - }, - - JSXClosingFragment(node) { - const firstToken = sourceCode.getFirstToken(node); - const slashToken = sourceCode.getLastToken(node, { skip: 1 }); - const closingToken = sourceCode.getLastToken(node); - const tokenToMatch = astUtils.isTokenOnSameLine(slashToken, closingToken) ? slashToken : closingToken; - - offsets.setDesiredOffsets(node.range, firstToken, 1); - offsets.matchOffsetOf(firstToken, tokenToMatch); - }, - - JSXExpressionContainer(node) { - const openingCurly = sourceCode.getFirstToken(node); - const closingCurly = sourceCode.getLastToken(node); - - offsets.setDesiredOffsets( - [openingCurly.range[1], closingCurly.range[0]], - openingCurly, - 1 - ); - }, - - JSXSpreadAttribute(node) { - const openingCurly = sourceCode.getFirstToken(node); - const closingCurly = sourceCode.getLastToken(node); - - offsets.setDesiredOffsets( - [openingCurly.range[1], closingCurly.range[0]], - openingCurly, - 1 - ); - }, - - "*"(node) { - const firstToken = sourceCode.getFirstToken(node); - - // Ensure that the children of every node are indented at least as much as the first token. - if (firstToken && !ignoredNodeFirstTokens.has(firstToken)) { - offsets.setDesiredOffsets(node.range, firstToken, 0); - } - } - }; - - const listenerCallQueue = []; - - /* - * To ignore the indentation of a node: - * 1. Don't call the node's listener when entering it (if it has a listener) - * 2. Don't set any offsets against the first token of the node. - * 3. Call `ignoreNode` on the node sometime after exiting it and before validating offsets. - */ - const offsetListeners = {}; - - for (const [selector, listener] of Object.entries(baseOffsetListeners)) { - - /* - * Offset listener calls are deferred until traversal is finished, and are called as - * part of the final `Program:exit` listener. This is necessary because a node might - * be matched by multiple selectors. - * - * Example: Suppose there is an offset listener for `Identifier`, and the user has - * specified in configuration that `MemberExpression > Identifier` should be ignored. - * Due to selector specificity rules, the `Identifier` listener will get called first. However, - * if a given Identifier node is supposed to be ignored, then the `Identifier` offset listener - * should not have been called at all. Without doing extra selector matching, we don't know - * whether the Identifier matches the `MemberExpression > Identifier` selector until the - * `MemberExpression > Identifier` listener is called. - * - * To avoid this, the `Identifier` listener isn't called until traversal finishes and all - * ignored nodes are known. - */ - offsetListeners[selector] = node => listenerCallQueue.push({ listener, node }); - } - - // For each ignored node selector, set up a listener to collect it into the `ignoredNodes` set. - const ignoredNodes = new Set(); - - /** - * Ignores a node - * @param {ASTNode} node The node to ignore - * @returns {void} - */ - function addToIgnoredNodes(node) { - ignoredNodes.add(node); - ignoredNodeFirstTokens.add(sourceCode.getFirstToken(node)); - } - - const ignoredNodeListeners = options.ignoredNodes.reduce( - (listeners, ignoredSelector) => Object.assign(listeners, { [ignoredSelector]: addToIgnoredNodes }), - {} - ); - - /* - * Join the listeners, and add a listener to verify that all tokens actually have the correct indentation - * at the end. - * - * Using Object.assign will cause some offset listeners to be overwritten if the same selector also appears - * in `ignoredNodeListeners`. This isn't a problem because all of the matching nodes will be ignored, - * so those listeners wouldn't be called anyway. - */ - return Object.assign( - offsetListeners, - ignoredNodeListeners, - { - "*:exit"(node) { - - // If a node's type is nonstandard, we can't tell how its children should be offset, so ignore it. - if (!KNOWN_NODES.has(node.type)) { - addToIgnoredNodes(node); - } - }, - "Program:exit"() { - - // If ignoreComments option is enabled, ignore all comment tokens. - if (options.ignoreComments) { - sourceCode.getAllComments() - .forEach(comment => offsets.ignoreToken(comment)); - } - - // Invoke the queued offset listeners for the nodes that aren't ignored. - for (let i = 0; i < listenerCallQueue.length; i++) { - const nodeInfo = listenerCallQueue[i]; - - if (!ignoredNodes.has(nodeInfo.node)) { - nodeInfo.listener(nodeInfo.node); - } - } - - // Update the offsets for ignored nodes to prevent their child tokens from being reported. - ignoredNodes.forEach(ignoreNode); - - addParensIndent(sourceCode.ast.tokens); - - /* - * Create a Map from (tokenOrComment) => (precedingToken). - * This is necessary because sourceCode.getTokenBefore does not handle a comment as an argument correctly. - */ - const precedingTokens = new WeakMap(); - - for (let i = 0; i < sourceCode.ast.comments.length; i++) { - const comment = sourceCode.ast.comments[i]; - - const tokenOrCommentBefore = sourceCode.getTokenBefore(comment, { includeComments: true }); - const hasToken = precedingTokens.has(tokenOrCommentBefore) ? precedingTokens.get(tokenOrCommentBefore) : tokenOrCommentBefore; - - precedingTokens.set(comment, hasToken); - } - - for (let i = 1; i < sourceCode.lines.length + 1; i++) { - - if (!tokenInfo.firstTokensByLineNumber.has(i)) { - - // Don't check indentation on blank lines - continue; - } - - const firstTokenOfLine = tokenInfo.firstTokensByLineNumber.get(i); - - if (firstTokenOfLine.loc.start.line !== i) { - - // Don't check the indentation of multi-line tokens (e.g. template literals or block comments) twice. - continue; - } - - if (astUtils.isCommentToken(firstTokenOfLine)) { - const tokenBefore = precedingTokens.get(firstTokenOfLine); - const tokenAfter = tokenBefore ? sourceCode.getTokenAfter(tokenBefore) : sourceCode.ast.tokens[0]; - const mayAlignWithBefore = tokenBefore && !hasBlankLinesBetween(tokenBefore, firstTokenOfLine); - const mayAlignWithAfter = tokenAfter && !hasBlankLinesBetween(firstTokenOfLine, tokenAfter); - - /* - * If a comment precedes a line that begins with a semicolon token, align to that token, i.e. - * - * let foo - * // comment - * ;(async () => {})() - */ - if (tokenAfter && astUtils.isSemicolonToken(tokenAfter) && !astUtils.isTokenOnSameLine(firstTokenOfLine, tokenAfter)) { - offsets.setDesiredOffset(firstTokenOfLine, tokenAfter, 0); - } - - // If a comment matches the expected indentation of the token immediately before or after, don't report it. - if ( - mayAlignWithBefore && validateTokenIndent(firstTokenOfLine, offsets.getDesiredIndent(tokenBefore)) || - mayAlignWithAfter && validateTokenIndent(firstTokenOfLine, offsets.getDesiredIndent(tokenAfter)) - ) { - continue; - } - } - - // If the token matches the expected indentation, don't report it. - if (validateTokenIndent(firstTokenOfLine, offsets.getDesiredIndent(firstTokenOfLine))) { - continue; - } - - // Otherwise, report the token/comment. - report(firstTokenOfLine, offsets.getDesiredIndent(firstTokenOfLine)); - } - } - } - ); - } -}; diff --git a/tools/eslint/node_modules/eslint/lib/rules/index.js b/tools/eslint/node_modules/eslint/lib/rules/index.js deleted file mode 100644 index 5ff7b6f5dde261..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/rules/index.js +++ /dev/null @@ -1,305 +0,0 @@ -/** - * @fileoverview Collects the built-in rules into a map structure so that they can be imported all at once and without - * using the file-system directly. - * @author Peter (Somogyvari) Metz - */ - -"use strict"; - -/* eslint sort-keys: ["error", "asc"] -- More readable for long list */ - -const { LazyLoadingRuleMap } = require("./utils/lazy-loading-rule-map"); - -/** @type {Map} */ -module.exports = new LazyLoadingRuleMap(Object.entries({ - "accessor-pairs": () => require("./accessor-pairs"), - "array-bracket-newline": () => require("./array-bracket-newline"), - "array-bracket-spacing": () => require("./array-bracket-spacing"), - "array-callback-return": () => require("./array-callback-return"), - "array-element-newline": () => require("./array-element-newline"), - "arrow-body-style": () => require("./arrow-body-style"), - "arrow-parens": () => require("./arrow-parens"), - "arrow-spacing": () => require("./arrow-spacing"), - "block-scoped-var": () => require("./block-scoped-var"), - "block-spacing": () => require("./block-spacing"), - "brace-style": () => require("./brace-style"), - "callback-return": () => require("./callback-return"), - camelcase: () => require("./camelcase"), - "capitalized-comments": () => require("./capitalized-comments"), - "class-methods-use-this": () => require("./class-methods-use-this"), - "comma-dangle": () => require("./comma-dangle"), - "comma-spacing": () => require("./comma-spacing"), - "comma-style": () => require("./comma-style"), - complexity: () => require("./complexity"), - "computed-property-spacing": () => require("./computed-property-spacing"), - "consistent-return": () => require("./consistent-return"), - "consistent-this": () => require("./consistent-this"), - "constructor-super": () => require("./constructor-super"), - curly: () => require("./curly"), - "default-case": () => require("./default-case"), - "default-case-last": () => require("./default-case-last"), - "default-param-last": () => require("./default-param-last"), - "dot-location": () => require("./dot-location"), - "dot-notation": () => require("./dot-notation"), - "eol-last": () => require("./eol-last"), - eqeqeq: () => require("./eqeqeq"), - "for-direction": () => require("./for-direction"), - "func-call-spacing": () => require("./func-call-spacing"), - "func-name-matching": () => require("./func-name-matching"), - "func-names": () => require("./func-names"), - "func-style": () => require("./func-style"), - "function-call-argument-newline": () => require("./function-call-argument-newline"), - "function-paren-newline": () => require("./function-paren-newline"), - "generator-star-spacing": () => require("./generator-star-spacing"), - "getter-return": () => require("./getter-return"), - "global-require": () => require("./global-require"), - "grouped-accessor-pairs": () => require("./grouped-accessor-pairs"), - "guard-for-in": () => require("./guard-for-in"), - "handle-callback-err": () => require("./handle-callback-err"), - "id-blacklist": () => require("./id-blacklist"), - "id-denylist": () => require("./id-denylist"), - "id-length": () => require("./id-length"), - "id-match": () => require("./id-match"), - "implicit-arrow-linebreak": () => require("./implicit-arrow-linebreak"), - indent: () => require("./indent"), - "indent-legacy": () => require("./indent-legacy"), - "init-declarations": () => require("./init-declarations"), - "jsx-quotes": () => require("./jsx-quotes"), - "key-spacing": () => require("./key-spacing"), - "keyword-spacing": () => require("./keyword-spacing"), - "line-comment-position": () => require("./line-comment-position"), - "linebreak-style": () => require("./linebreak-style"), - "lines-around-comment": () => require("./lines-around-comment"), - "lines-around-directive": () => require("./lines-around-directive"), - "lines-between-class-members": () => require("./lines-between-class-members"), - "logical-assignment-operators": () => require("./logical-assignment-operators"), - "max-classes-per-file": () => require("./max-classes-per-file"), - "max-depth": () => require("./max-depth"), - "max-len": () => require("./max-len"), - "max-lines": () => require("./max-lines"), - "max-lines-per-function": () => require("./max-lines-per-function"), - "max-nested-callbacks": () => require("./max-nested-callbacks"), - "max-params": () => require("./max-params"), - "max-statements": () => require("./max-statements"), - "max-statements-per-line": () => require("./max-statements-per-line"), - "multiline-comment-style": () => require("./multiline-comment-style"), - "multiline-ternary": () => require("./multiline-ternary"), - "new-cap": () => require("./new-cap"), - "new-parens": () => require("./new-parens"), - "newline-after-var": () => require("./newline-after-var"), - "newline-before-return": () => require("./newline-before-return"), - "newline-per-chained-call": () => require("./newline-per-chained-call"), - "no-alert": () => require("./no-alert"), - "no-array-constructor": () => require("./no-array-constructor"), - "no-async-promise-executor": () => require("./no-async-promise-executor"), - "no-await-in-loop": () => require("./no-await-in-loop"), - "no-bitwise": () => require("./no-bitwise"), - "no-buffer-constructor": () => require("./no-buffer-constructor"), - "no-caller": () => require("./no-caller"), - "no-case-declarations": () => require("./no-case-declarations"), - "no-catch-shadow": () => require("./no-catch-shadow"), - "no-class-assign": () => require("./no-class-assign"), - "no-compare-neg-zero": () => require("./no-compare-neg-zero"), - "no-cond-assign": () => require("./no-cond-assign"), - "no-confusing-arrow": () => require("./no-confusing-arrow"), - "no-console": () => require("./no-console"), - "no-const-assign": () => require("./no-const-assign"), - "no-constant-binary-expression": () => require("./no-constant-binary-expression"), - "no-constant-condition": () => require("./no-constant-condition"), - "no-constructor-return": () => require("./no-constructor-return"), - "no-continue": () => require("./no-continue"), - "no-control-regex": () => require("./no-control-regex"), - "no-debugger": () => require("./no-debugger"), - "no-delete-var": () => require("./no-delete-var"), - "no-div-regex": () => require("./no-div-regex"), - "no-dupe-args": () => require("./no-dupe-args"), - "no-dupe-class-members": () => require("./no-dupe-class-members"), - "no-dupe-else-if": () => require("./no-dupe-else-if"), - "no-dupe-keys": () => require("./no-dupe-keys"), - "no-duplicate-case": () => require("./no-duplicate-case"), - "no-duplicate-imports": () => require("./no-duplicate-imports"), - "no-else-return": () => require("./no-else-return"), - "no-empty": () => require("./no-empty"), - "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"), - "no-extend-native": () => require("./no-extend-native"), - "no-extra-bind": () => require("./no-extra-bind"), - "no-extra-boolean-cast": () => require("./no-extra-boolean-cast"), - "no-extra-label": () => require("./no-extra-label"), - "no-extra-parens": () => require("./no-extra-parens"), - "no-extra-semi": () => require("./no-extra-semi"), - "no-fallthrough": () => require("./no-fallthrough"), - "no-floating-decimal": () => require("./no-floating-decimal"), - "no-func-assign": () => require("./no-func-assign"), - "no-global-assign": () => require("./no-global-assign"), - "no-implicit-coercion": () => require("./no-implicit-coercion"), - "no-implicit-globals": () => require("./no-implicit-globals"), - "no-implied-eval": () => require("./no-implied-eval"), - "no-import-assign": () => require("./no-import-assign"), - "no-inline-comments": () => require("./no-inline-comments"), - "no-inner-declarations": () => require("./no-inner-declarations"), - "no-invalid-regexp": () => require("./no-invalid-regexp"), - "no-invalid-this": () => require("./no-invalid-this"), - "no-irregular-whitespace": () => require("./no-irregular-whitespace"), - "no-iterator": () => require("./no-iterator"), - "no-label-var": () => require("./no-label-var"), - "no-labels": () => require("./no-labels"), - "no-lone-blocks": () => require("./no-lone-blocks"), - "no-lonely-if": () => require("./no-lonely-if"), - "no-loop-func": () => require("./no-loop-func"), - "no-loss-of-precision": () => require("./no-loss-of-precision"), - "no-magic-numbers": () => require("./no-magic-numbers"), - "no-misleading-character-class": () => require("./no-misleading-character-class"), - "no-mixed-operators": () => require("./no-mixed-operators"), - "no-mixed-requires": () => require("./no-mixed-requires"), - "no-mixed-spaces-and-tabs": () => require("./no-mixed-spaces-and-tabs"), - "no-multi-assign": () => require("./no-multi-assign"), - "no-multi-spaces": () => require("./no-multi-spaces"), - "no-multi-str": () => require("./no-multi-str"), - "no-multiple-empty-lines": () => require("./no-multiple-empty-lines"), - "no-native-reassign": () => require("./no-native-reassign"), - "no-negated-condition": () => require("./no-negated-condition"), - "no-negated-in-lhs": () => require("./no-negated-in-lhs"), - "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"), - "no-new-wrappers": () => require("./no-new-wrappers"), - "no-nonoctal-decimal-escape": () => require("./no-nonoctal-decimal-escape"), - "no-obj-calls": () => require("./no-obj-calls"), - "no-object-constructor": () => require("./no-object-constructor"), - "no-octal": () => require("./no-octal"), - "no-octal-escape": () => require("./no-octal-escape"), - "no-param-reassign": () => require("./no-param-reassign"), - "no-path-concat": () => require("./no-path-concat"), - "no-plusplus": () => require("./no-plusplus"), - "no-process-env": () => require("./no-process-env"), - "no-process-exit": () => require("./no-process-exit"), - "no-promise-executor-return": () => require("./no-promise-executor-return"), - "no-proto": () => require("./no-proto"), - "no-prototype-builtins": () => require("./no-prototype-builtins"), - "no-redeclare": () => require("./no-redeclare"), - "no-regex-spaces": () => require("./no-regex-spaces"), - "no-restricted-exports": () => require("./no-restricted-exports"), - "no-restricted-globals": () => require("./no-restricted-globals"), - "no-restricted-imports": () => require("./no-restricted-imports"), - "no-restricted-modules": () => require("./no-restricted-modules"), - "no-restricted-properties": () => require("./no-restricted-properties"), - "no-restricted-syntax": () => require("./no-restricted-syntax"), - "no-return-assign": () => require("./no-return-assign"), - "no-return-await": () => require("./no-return-await"), - "no-script-url": () => require("./no-script-url"), - "no-self-assign": () => require("./no-self-assign"), - "no-self-compare": () => require("./no-self-compare"), - "no-sequences": () => require("./no-sequences"), - "no-setter-return": () => require("./no-setter-return"), - "no-shadow": () => require("./no-shadow"), - "no-shadow-restricted-names": () => require("./no-shadow-restricted-names"), - "no-spaced-func": () => require("./no-spaced-func"), - "no-sparse-arrays": () => require("./no-sparse-arrays"), - "no-sync": () => require("./no-sync"), - "no-tabs": () => require("./no-tabs"), - "no-template-curly-in-string": () => require("./no-template-curly-in-string"), - "no-ternary": () => require("./no-ternary"), - "no-this-before-super": () => require("./no-this-before-super"), - "no-throw-literal": () => require("./no-throw-literal"), - "no-trailing-spaces": () => require("./no-trailing-spaces"), - "no-undef": () => require("./no-undef"), - "no-undef-init": () => require("./no-undef-init"), - "no-undefined": () => require("./no-undefined"), - "no-underscore-dangle": () => require("./no-underscore-dangle"), - "no-unexpected-multiline": () => require("./no-unexpected-multiline"), - "no-unmodified-loop-condition": () => require("./no-unmodified-loop-condition"), - "no-unneeded-ternary": () => require("./no-unneeded-ternary"), - "no-unreachable": () => require("./no-unreachable"), - "no-unreachable-loop": () => require("./no-unreachable-loop"), - "no-unsafe-finally": () => require("./no-unsafe-finally"), - "no-unsafe-negation": () => require("./no-unsafe-negation"), - "no-unsafe-optional-chaining": () => require("./no-unsafe-optional-chaining"), - "no-unused-expressions": () => require("./no-unused-expressions"), - "no-unused-labels": () => require("./no-unused-labels"), - "no-unused-private-class-members": () => require("./no-unused-private-class-members"), - "no-unused-vars": () => require("./no-unused-vars"), - "no-use-before-define": () => require("./no-use-before-define"), - "no-useless-assignment": () => require("./no-useless-assignment"), - "no-useless-backreference": () => require("./no-useless-backreference"), - "no-useless-call": () => require("./no-useless-call"), - "no-useless-catch": () => require("./no-useless-catch"), - "no-useless-computed-key": () => require("./no-useless-computed-key"), - "no-useless-concat": () => require("./no-useless-concat"), - "no-useless-constructor": () => require("./no-useless-constructor"), - "no-useless-escape": () => require("./no-useless-escape"), - "no-useless-rename": () => require("./no-useless-rename"), - "no-useless-return": () => require("./no-useless-return"), - "no-var": () => require("./no-var"), - "no-void": () => require("./no-void"), - "no-warning-comments": () => require("./no-warning-comments"), - "no-whitespace-before-property": () => require("./no-whitespace-before-property"), - "no-with": () => require("./no-with"), - "nonblock-statement-body-position": () => require("./nonblock-statement-body-position"), - "object-curly-newline": () => require("./object-curly-newline"), - "object-curly-spacing": () => require("./object-curly-spacing"), - "object-property-newline": () => require("./object-property-newline"), - "object-shorthand": () => require("./object-shorthand"), - "one-var": () => require("./one-var"), - "one-var-declaration-per-line": () => require("./one-var-declaration-per-line"), - "operator-assignment": () => require("./operator-assignment"), - "operator-linebreak": () => require("./operator-linebreak"), - "padded-blocks": () => require("./padded-blocks"), - "padding-line-between-statements": () => require("./padding-line-between-statements"), - "prefer-arrow-callback": () => require("./prefer-arrow-callback"), - "prefer-const": () => require("./prefer-const"), - "prefer-destructuring": () => require("./prefer-destructuring"), - "prefer-exponentiation-operator": () => require("./prefer-exponentiation-operator"), - "prefer-named-capture-group": () => require("./prefer-named-capture-group"), - "prefer-numeric-literals": () => require("./prefer-numeric-literals"), - "prefer-object-has-own": () => require("./prefer-object-has-own"), - "prefer-object-spread": () => require("./prefer-object-spread"), - "prefer-promise-reject-errors": () => require("./prefer-promise-reject-errors"), - "prefer-reflect": () => require("./prefer-reflect"), - "prefer-regex-literals": () => require("./prefer-regex-literals"), - "prefer-rest-params": () => require("./prefer-rest-params"), - "prefer-spread": () => require("./prefer-spread"), - "prefer-template": () => require("./prefer-template"), - "quote-props": () => require("./quote-props"), - quotes: () => require("./quotes"), - radix: () => require("./radix"), - "require-atomic-updates": () => require("./require-atomic-updates"), - "require-await": () => require("./require-await"), - "require-unicode-regexp": () => require("./require-unicode-regexp"), - "require-yield": () => require("./require-yield"), - "rest-spread-spacing": () => require("./rest-spread-spacing"), - semi: () => require("./semi"), - "semi-spacing": () => require("./semi-spacing"), - "semi-style": () => require("./semi-style"), - "sort-imports": () => require("./sort-imports"), - "sort-keys": () => require("./sort-keys"), - "sort-vars": () => require("./sort-vars"), - "space-before-blocks": () => require("./space-before-blocks"), - "space-before-function-paren": () => require("./space-before-function-paren"), - "space-in-parens": () => require("./space-in-parens"), - "space-infix-ops": () => require("./space-infix-ops"), - "space-unary-ops": () => require("./space-unary-ops"), - "spaced-comment": () => require("./spaced-comment"), - strict: () => require("./strict"), - "switch-colon-spacing": () => require("./switch-colon-spacing"), - "symbol-description": () => require("./symbol-description"), - "template-curly-spacing": () => require("./template-curly-spacing"), - "template-tag-spacing": () => require("./template-tag-spacing"), - "unicode-bom": () => require("./unicode-bom"), - "use-isnan": () => require("./use-isnan"), - "valid-typeof": () => require("./valid-typeof"), - "vars-on-top": () => require("./vars-on-top"), - "wrap-iife": () => require("./wrap-iife"), - "wrap-regex": () => require("./wrap-regex"), - "yield-star-spacing": () => require("./yield-star-spacing"), - yoda: () => require("./yoda") -})); diff --git a/tools/eslint/node_modules/eslint/lib/rules/init-declarations.js b/tools/eslint/node_modules/eslint/lib/rules/init-declarations.js deleted file mode 100644 index 3abe107f199382..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/rules/init-declarations.js +++ /dev/null @@ -1,139 +0,0 @@ -/** - * @fileoverview A rule to control the style of variable initializations. - * @author Colin Ihrig - */ - -"use strict"; - -//------------------------------------------------------------------------------ -// Helpers -//------------------------------------------------------------------------------ - -/** - * Checks whether or not a given node is a for loop. - * @param {ASTNode} block A node to check. - * @returns {boolean} `true` when the node is a for loop. - */ -function isForLoop(block) { - return block.type === "ForInStatement" || - block.type === "ForOfStatement" || - block.type === "ForStatement"; -} - -/** - * Checks whether or not a given declarator node has its initializer. - * @param {ASTNode} node A declarator node to check. - * @returns {boolean} `true` when the node has its initializer. - */ -function isInitialized(node) { - const declaration = node.parent; - const block = declaration.parent; - - if (isForLoop(block)) { - if (block.type === "ForStatement") { - return block.init === declaration; - } - return block.left === declaration; - } - return Boolean(node.init); -} - -//------------------------------------------------------------------------------ -// Rule Definition -//------------------------------------------------------------------------------ - -/** @type {import('../shared/types').Rule} */ -module.exports = { - meta: { - type: "suggestion", - - docs: { - description: "Require or disallow initialization in variable declarations", - recommended: false, - url: "https://eslint.org/docs/latest/rules/init-declarations" - }, - - schema: { - anyOf: [ - { - type: "array", - items: [ - { - enum: ["always"] - } - ], - minItems: 0, - maxItems: 1 - }, - { - type: "array", - items: [ - { - enum: ["never"] - }, - { - type: "object", - properties: { - ignoreForLoopInit: { - type: "boolean" - } - }, - additionalProperties: false - } - ], - minItems: 0, - maxItems: 2 - } - ] - }, - messages: { - initialized: "Variable '{{idName}}' should be initialized on declaration.", - notInitialized: "Variable '{{idName}}' should not be initialized on declaration." - } - }, - - create(context) { - - const MODE_ALWAYS = "always", - MODE_NEVER = "never"; - - const mode = context.options[0] || MODE_ALWAYS; - const params = context.options[1] || {}; - - //-------------------------------------------------------------------------- - // Public API - //-------------------------------------------------------------------------- - - return { - "VariableDeclaration:exit"(node) { - - const kind = node.kind, - declarations = node.declarations; - - for (let i = 0; i < declarations.length; ++i) { - const declaration = declarations[i], - id = declaration.id, - initialized = isInitialized(declaration), - isIgnoredForLoop = params.ignoreForLoopInit && isForLoop(node.parent); - let messageId = ""; - - if (mode === MODE_ALWAYS && !initialized) { - messageId = "initialized"; - } else if (mode === MODE_NEVER && kind !== "const" && initialized && !isIgnoredForLoop) { - messageId = "notInitialized"; - } - - if (id.type === "Identifier" && messageId) { - context.report({ - node: declaration, - messageId, - data: { - idName: id.name - } - }); - } - } - } - }; - } -}; diff --git a/tools/eslint/node_modules/eslint/lib/rules/jsx-quotes.js b/tools/eslint/node_modules/eslint/lib/rules/jsx-quotes.js deleted file mode 100644 index 3dcd5fa9d22bbe..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/rules/jsx-quotes.js +++ /dev/null @@ -1,98 +0,0 @@ -/** - * @fileoverview A rule to ensure consistent quotes used in jsx syntax. - * @author Mathias Schreck - * @deprecated in ESLint v8.53.0 - */ - -"use strict"; - -//------------------------------------------------------------------------------ -// Requirements -//------------------------------------------------------------------------------ - -const astUtils = require("./utils/ast-utils"); - -//------------------------------------------------------------------------------ -// Constants -//------------------------------------------------------------------------------ - -const QUOTE_SETTINGS = { - "prefer-double": { - quote: "\"", - description: "singlequote", - convert(str) { - return str.replace(/'/gu, "\""); - } - }, - "prefer-single": { - quote: "'", - description: "doublequote", - convert(str) { - return str.replace(/"/gu, "'"); - } - } -}; - -//------------------------------------------------------------------------------ -// Rule Definition -//------------------------------------------------------------------------------ - -/** @type {import('../shared/types').Rule} */ -module.exports = { - meta: { - deprecated: true, - replacedBy: [], - type: "layout", - - docs: { - description: "Enforce the consistent use of either double or single quotes in JSX attributes", - recommended: false, - url: "https://eslint.org/docs/latest/rules/jsx-quotes" - }, - - fixable: "whitespace", - - schema: [ - { - enum: ["prefer-single", "prefer-double"] - } - ], - messages: { - unexpected: "Unexpected usage of {{description}}." - } - }, - - create(context) { - const quoteOption = context.options[0] || "prefer-double", - setting = QUOTE_SETTINGS[quoteOption]; - - /** - * Checks if the given string literal node uses the expected quotes - * @param {ASTNode} node A string literal node. - * @returns {boolean} Whether or not the string literal used the expected quotes. - * @public - */ - function usesExpectedQuotes(node) { - return node.value.includes(setting.quote) || astUtils.isSurroundedBy(node.raw, setting.quote); - } - - return { - JSXAttribute(node) { - const attributeValue = node.value; - - if (attributeValue && astUtils.isStringLiteral(attributeValue) && !usesExpectedQuotes(attributeValue)) { - context.report({ - node: attributeValue, - messageId: "unexpected", - data: { - description: setting.description - }, - fix(fixer) { - return fixer.replaceText(attributeValue, setting.convert(attributeValue.raw)); - } - }); - } - } - }; - } -}; diff --git a/tools/eslint/node_modules/eslint/lib/rules/key-spacing.js b/tools/eslint/node_modules/eslint/lib/rules/key-spacing.js deleted file mode 100644 index aa8fd37b8ad333..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/rules/key-spacing.js +++ /dev/null @@ -1,687 +0,0 @@ -/** - * @fileoverview Rule to specify spacing of object literal keys and values - * @author Brandon Mills - * @deprecated in ESLint v8.53.0 - */ -"use strict"; - -//------------------------------------------------------------------------------ -// Requirements -//------------------------------------------------------------------------------ - -const astUtils = require("./utils/ast-utils"); -const { getGraphemeCount } = require("../shared/string-utils"); - -/** - * Checks whether a string contains a line terminator as defined in - * http://www.ecma-international.org/ecma-262/5.1/#sec-7.3 - * @param {string} str String to test. - * @returns {boolean} True if str contains a line terminator. - */ -function containsLineTerminator(str) { - return astUtils.LINEBREAK_MATCHER.test(str); -} - -/** - * Gets the last element of an array. - * @param {Array} arr An array. - * @returns {any} Last element of arr. - */ -function last(arr) { - return arr.at(-1); -} - -/** - * Checks whether a node is contained on a single line. - * @param {ASTNode} node AST Node being evaluated. - * @returns {boolean} True if the node is a single line. - */ -function isSingleLine(node) { - return (node.loc.end.line === node.loc.start.line); -} - -/** - * Checks whether the properties on a single line. - * @param {ASTNode[]} properties List of Property AST nodes. - * @returns {boolean} True if all properties is on a single line. - */ -function isSingleLineProperties(properties) { - const [firstProp] = properties, - lastProp = last(properties); - - return firstProp.loc.start.line === lastProp.loc.end.line; -} - -/** - * Initializes a single option property from the configuration with defaults for undefined values - * @param {Object} toOptions Object to be initialized - * @param {Object} fromOptions Object to be initialized from - * @returns {Object} The object with correctly initialized options and values - */ -function initOptionProperty(toOptions, fromOptions) { - toOptions.mode = fromOptions.mode || "strict"; - - // Set value of beforeColon - if (typeof fromOptions.beforeColon !== "undefined") { - toOptions.beforeColon = +fromOptions.beforeColon; - } else { - toOptions.beforeColon = 0; - } - - // Set value of afterColon - if (typeof fromOptions.afterColon !== "undefined") { - toOptions.afterColon = +fromOptions.afterColon; - } else { - toOptions.afterColon = 1; - } - - // Set align if exists - if (typeof fromOptions.align !== "undefined") { - if (typeof fromOptions.align === "object") { - toOptions.align = fromOptions.align; - } else { // "string" - toOptions.align = { - on: fromOptions.align, - mode: toOptions.mode, - beforeColon: toOptions.beforeColon, - afterColon: toOptions.afterColon - }; - } - } - - return toOptions; -} - -/** - * Initializes all the option values (singleLine, multiLine and align) from the configuration with defaults for undefined values - * @param {Object} toOptions Object to be initialized - * @param {Object} fromOptions Object to be initialized from - * @returns {Object} The object with correctly initialized options and values - */ -function initOptions(toOptions, fromOptions) { - if (typeof fromOptions.align === "object") { - - // Initialize the alignment configuration - toOptions.align = initOptionProperty({}, fromOptions.align); - toOptions.align.on = fromOptions.align.on || "colon"; - toOptions.align.mode = fromOptions.align.mode || "strict"; - - toOptions.multiLine = initOptionProperty({}, (fromOptions.multiLine || fromOptions)); - toOptions.singleLine = initOptionProperty({}, (fromOptions.singleLine || fromOptions)); - - } else { // string or undefined - toOptions.multiLine = initOptionProperty({}, (fromOptions.multiLine || fromOptions)); - toOptions.singleLine = initOptionProperty({}, (fromOptions.singleLine || fromOptions)); - - // If alignment options are defined in multiLine, pull them out into the general align configuration - if (toOptions.multiLine.align) { - toOptions.align = { - on: toOptions.multiLine.align.on, - mode: toOptions.multiLine.align.mode || toOptions.multiLine.mode, - beforeColon: toOptions.multiLine.align.beforeColon, - afterColon: toOptions.multiLine.align.afterColon - }; - } - } - - return toOptions; -} - -//------------------------------------------------------------------------------ -// Rule Definition -//------------------------------------------------------------------------------ - -/** @type {import('../shared/types').Rule} */ -module.exports = { - meta: { - deprecated: true, - replacedBy: [], - type: "layout", - - docs: { - description: "Enforce consistent spacing between keys and values in object literal properties", - recommended: false, - url: "https://eslint.org/docs/latest/rules/key-spacing" - }, - - fixable: "whitespace", - - schema: [{ - anyOf: [ - { - type: "object", - properties: { - align: { - anyOf: [ - { - enum: ["colon", "value"] - }, - { - type: "object", - properties: { - mode: { - enum: ["strict", "minimum"] - }, - on: { - enum: ["colon", "value"] - }, - beforeColon: { - type: "boolean" - }, - afterColon: { - type: "boolean" - } - }, - additionalProperties: false - } - ] - }, - mode: { - enum: ["strict", "minimum"] - }, - beforeColon: { - type: "boolean" - }, - afterColon: { - type: "boolean" - } - }, - additionalProperties: false - }, - { - type: "object", - properties: { - singleLine: { - type: "object", - properties: { - mode: { - enum: ["strict", "minimum"] - }, - beforeColon: { - type: "boolean" - }, - afterColon: { - type: "boolean" - } - }, - additionalProperties: false - }, - multiLine: { - type: "object", - properties: { - align: { - anyOf: [ - { - enum: ["colon", "value"] - }, - { - type: "object", - properties: { - mode: { - enum: ["strict", "minimum"] - }, - on: { - enum: ["colon", "value"] - }, - beforeColon: { - type: "boolean" - }, - afterColon: { - type: "boolean" - } - }, - additionalProperties: false - } - ] - }, - mode: { - enum: ["strict", "minimum"] - }, - beforeColon: { - type: "boolean" - }, - afterColon: { - type: "boolean" - } - }, - additionalProperties: false - } - }, - additionalProperties: false - }, - { - type: "object", - properties: { - singleLine: { - type: "object", - properties: { - mode: { - enum: ["strict", "minimum"] - }, - beforeColon: { - type: "boolean" - }, - afterColon: { - type: "boolean" - } - }, - additionalProperties: false - }, - multiLine: { - type: "object", - properties: { - mode: { - enum: ["strict", "minimum"] - }, - beforeColon: { - type: "boolean" - }, - afterColon: { - type: "boolean" - } - }, - additionalProperties: false - }, - align: { - type: "object", - properties: { - mode: { - enum: ["strict", "minimum"] - }, - on: { - enum: ["colon", "value"] - }, - beforeColon: { - type: "boolean" - }, - afterColon: { - type: "boolean" - } - }, - additionalProperties: false - } - }, - additionalProperties: false - } - ] - }], - messages: { - extraKey: "Extra space after {{computed}}key '{{key}}'.", - extraValue: "Extra space before value for {{computed}}key '{{key}}'.", - missingKey: "Missing space after {{computed}}key '{{key}}'.", - missingValue: "Missing space before value for {{computed}}key '{{key}}'." - } - }, - - create(context) { - - /** - * OPTIONS - * "key-spacing": [2, { - * beforeColon: false, - * afterColon: true, - * align: "colon" // Optional, or "value" - * } - */ - const options = context.options[0] || {}, - ruleOptions = initOptions({}, options), - multiLineOptions = ruleOptions.multiLine, - singleLineOptions = ruleOptions.singleLine, - alignmentOptions = ruleOptions.align || null; - - const sourceCode = context.sourceCode; - - /** - * Determines if the given property is key-value property. - * @param {ASTNode} property Property node to check. - * @returns {boolean} Whether the property is a key-value property. - */ - function isKeyValueProperty(property) { - return !( - (property.method || - property.shorthand || - property.kind !== "init" || property.type !== "Property") // Could be "ExperimentalSpreadProperty" or "SpreadElement" - ); - } - - /** - * Starting from the given node (a property.key node here) looks forward - * until it finds the colon punctuator and returns it. - * @param {ASTNode} node The node to start looking from. - * @returns {ASTNode} The colon punctuator. - */ - function getNextColon(node) { - return sourceCode.getTokenAfter(node, astUtils.isColonToken); - } - - /** - * Starting from the given node (a property.key node here) looks forward - * until it finds the last token before a colon punctuator and returns it. - * @param {ASTNode} node The node to start looking from. - * @returns {ASTNode} The last token before a colon punctuator. - */ - function getLastTokenBeforeColon(node) { - const colonToken = getNextColon(node); - - return sourceCode.getTokenBefore(colonToken); - } - - /** - * Starting from the given node (a property.key node here) looks forward - * until it finds the first token after a colon punctuator and returns it. - * @param {ASTNode} node The node to start looking from. - * @returns {ASTNode} The first token after a colon punctuator. - */ - function getFirstTokenAfterColon(node) { - const colonToken = getNextColon(node); - - return sourceCode.getTokenAfter(colonToken); - } - - /** - * Checks whether a property is a member of the property group it follows. - * @param {ASTNode} lastMember The last Property known to be in the group. - * @param {ASTNode} candidate The next Property that might be in the group. - * @returns {boolean} True if the candidate property is part of the group. - */ - function continuesPropertyGroup(lastMember, candidate) { - const groupEndLine = lastMember.loc.start.line, - candidateValueStartLine = (isKeyValueProperty(candidate) ? getFirstTokenAfterColon(candidate.key) : candidate).loc.start.line; - - if (candidateValueStartLine - groupEndLine <= 1) { - return true; - } - - /* - * Check that the first comment is adjacent to the end of the group, the - * last comment is adjacent to the candidate property, and that successive - * comments are adjacent to each other. - */ - const leadingComments = sourceCode.getCommentsBefore(candidate); - - if ( - leadingComments.length && - leadingComments[0].loc.start.line - groupEndLine <= 1 && - candidateValueStartLine - last(leadingComments).loc.end.line <= 1 - ) { - for (let i = 1; i < leadingComments.length; i++) { - if (leadingComments[i].loc.start.line - leadingComments[i - 1].loc.end.line > 1) { - return false; - } - } - return true; - } - - return false; - } - - /** - * Gets an object literal property's key as the identifier name or string value. - * @param {ASTNode} property Property node whose key to retrieve. - * @returns {string} The property's key. - */ - function getKey(property) { - const key = property.key; - - if (property.computed) { - return sourceCode.getText().slice(key.range[0], key.range[1]); - } - return astUtils.getStaticPropertyName(property); - } - - /** - * Reports an appropriately-formatted error if spacing is incorrect on one - * side of the colon. - * @param {ASTNode} property Key-value pair in an object literal. - * @param {string} side Side being verified - either "key" or "value". - * @param {string} whitespace Actual whitespace string. - * @param {int} expected Expected whitespace length. - * @param {string} mode Value of the mode as "strict" or "minimum" - * @returns {void} - */ - function report(property, side, whitespace, expected, mode) { - const diff = whitespace.length - expected; - - if (( - diff && mode === "strict" || - diff < 0 && mode === "minimum" || - diff > 0 && !expected && mode === "minimum") && - !(expected && containsLineTerminator(whitespace)) - ) { - const nextColon = getNextColon(property.key), - tokenBeforeColon = sourceCode.getTokenBefore(nextColon, { includeComments: true }), - tokenAfterColon = sourceCode.getTokenAfter(nextColon, { includeComments: true }), - isKeySide = side === "key", - isExtra = diff > 0, - diffAbs = Math.abs(diff), - spaces = Array(diffAbs + 1).join(" "); - - const locStart = isKeySide ? tokenBeforeColon.loc.end : nextColon.loc.start; - const locEnd = isKeySide ? nextColon.loc.start : tokenAfterColon.loc.start; - const missingLoc = isKeySide ? tokenBeforeColon.loc : tokenAfterColon.loc; - const loc = isExtra ? { start: locStart, end: locEnd } : missingLoc; - - let fix; - - if (isExtra) { - let range; - - // Remove whitespace - if (isKeySide) { - range = [tokenBeforeColon.range[1], tokenBeforeColon.range[1] + diffAbs]; - } else { - range = [tokenAfterColon.range[0] - diffAbs, tokenAfterColon.range[0]]; - } - fix = function(fixer) { - return fixer.removeRange(range); - }; - } else { - - // Add whitespace - if (isKeySide) { - fix = function(fixer) { - return fixer.insertTextAfter(tokenBeforeColon, spaces); - }; - } else { - fix = function(fixer) { - return fixer.insertTextBefore(tokenAfterColon, spaces); - }; - } - } - - let messageId; - - if (isExtra) { - messageId = side === "key" ? "extraKey" : "extraValue"; - } else { - messageId = side === "key" ? "missingKey" : "missingValue"; - } - - context.report({ - node: property[side], - loc, - messageId, - data: { - computed: property.computed ? "computed " : "", - key: getKey(property) - }, - fix - }); - } - } - - /** - * Gets the number of characters in a key, including quotes around string - * keys and braces around computed property keys. - * @param {ASTNode} property Property of on object literal. - * @returns {int} Width of the key. - */ - function getKeyWidth(property) { - const startToken = sourceCode.getFirstToken(property); - const endToken = getLastTokenBeforeColon(property.key); - - return getGraphemeCount(sourceCode.getText().slice(startToken.range[0], endToken.range[1])); - } - - /** - * Gets the whitespace around the colon in an object literal property. - * @param {ASTNode} property Property node from an object literal. - * @returns {Object} Whitespace before and after the property's colon. - */ - function getPropertyWhitespace(property) { - const whitespace = /(\s*):(\s*)/u.exec(sourceCode.getText().slice( - property.key.range[1], property.value.range[0] - )); - - if (whitespace) { - return { - beforeColon: whitespace[1], - afterColon: whitespace[2] - }; - } - return null; - } - - /** - * Creates groups of properties. - * @param {ASTNode} node ObjectExpression node being evaluated. - * @returns {Array} Groups of property AST node lists. - */ - function createGroups(node) { - if (node.properties.length === 1) { - return [node.properties]; - } - - return node.properties.reduce((groups, property) => { - const currentGroup = last(groups), - prev = last(currentGroup); - - if (!prev || continuesPropertyGroup(prev, property)) { - currentGroup.push(property); - } else { - groups.push([property]); - } - - return groups; - }, [ - [] - ]); - } - - /** - * Verifies correct vertical alignment of a group of properties. - * @param {ASTNode[]} properties List of Property AST nodes. - * @returns {void} - */ - function verifyGroupAlignment(properties) { - const length = properties.length, - widths = properties.map(getKeyWidth), // Width of keys, including quotes - align = alignmentOptions.on; // "value" or "colon" - let targetWidth = Math.max(...widths), - beforeColon, afterColon, mode; - - if (alignmentOptions && length > 1) { // When aligning values within a group, use the alignment configuration. - beforeColon = alignmentOptions.beforeColon; - afterColon = alignmentOptions.afterColon; - mode = alignmentOptions.mode; - } else { - beforeColon = multiLineOptions.beforeColon; - afterColon = multiLineOptions.afterColon; - mode = alignmentOptions.mode; - } - - // Conditionally include one space before or after colon - targetWidth += (align === "colon" ? beforeColon : afterColon); - - for (let i = 0; i < length; i++) { - const property = properties[i]; - const whitespace = getPropertyWhitespace(property); - - if (whitespace) { // Object literal getters/setters lack a colon - const width = widths[i]; - - if (align === "value") { - report(property, "key", whitespace.beforeColon, beforeColon, mode); - report(property, "value", whitespace.afterColon, targetWidth - width, mode); - } else { // align = "colon" - report(property, "key", whitespace.beforeColon, targetWidth - width, mode); - report(property, "value", whitespace.afterColon, afterColon, mode); - } - } - } - } - - /** - * Verifies spacing of property conforms to specified options. - * @param {ASTNode} node Property node being evaluated. - * @param {Object} lineOptions Configured singleLine or multiLine options - * @returns {void} - */ - function verifySpacing(node, lineOptions) { - const actual = getPropertyWhitespace(node); - - if (actual) { // Object literal getters/setters lack colons - report(node, "key", actual.beforeColon, lineOptions.beforeColon, lineOptions.mode); - report(node, "value", actual.afterColon, lineOptions.afterColon, lineOptions.mode); - } - } - - /** - * Verifies spacing of each property in a list. - * @param {ASTNode[]} properties List of Property AST nodes. - * @param {Object} lineOptions Configured singleLine or multiLine options - * @returns {void} - */ - function verifyListSpacing(properties, lineOptions) { - const length = properties.length; - - for (let i = 0; i < length; i++) { - verifySpacing(properties[i], lineOptions); - } - } - - /** - * Verifies vertical alignment, taking into account groups of properties. - * @param {ASTNode} node ObjectExpression node being evaluated. - * @returns {void} - */ - function verifyAlignment(node) { - createGroups(node).forEach(group => { - const properties = group.filter(isKeyValueProperty); - - if (properties.length > 0 && isSingleLineProperties(properties)) { - verifyListSpacing(properties, multiLineOptions); - } else { - verifyGroupAlignment(properties); - } - }); - } - - //-------------------------------------------------------------------------- - // Public API - //-------------------------------------------------------------------------- - - if (alignmentOptions) { // Verify vertical alignment - - return { - ObjectExpression(node) { - if (isSingleLine(node)) { - verifyListSpacing(node.properties.filter(isKeyValueProperty), singleLineOptions); - } else { - verifyAlignment(node); - } - } - }; - - } - - // Obey beforeColon and afterColon in each property as configured - return { - Property(node) { - verifySpacing(node, isSingleLine(node.parent) ? singleLineOptions : multiLineOptions); - } - }; - - - } -}; diff --git a/tools/eslint/node_modules/eslint/lib/rules/keyword-spacing.js b/tools/eslint/node_modules/eslint/lib/rules/keyword-spacing.js deleted file mode 100644 index 9d18441e0e56bf..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/rules/keyword-spacing.js +++ /dev/null @@ -1,640 +0,0 @@ -/** - * @fileoverview Rule to enforce spacing before and after keywords. - * @author Toru Nagashima - * @deprecated in ESLint v8.53.0 - */ - -"use strict"; - -//------------------------------------------------------------------------------ -// Requirements -//------------------------------------------------------------------------------ - -const astUtils = require("./utils/ast-utils"), - keywords = require("./utils/keywords"); - -//------------------------------------------------------------------------------ -// Constants -//------------------------------------------------------------------------------ - -const PREV_TOKEN = /^[)\]}>]$/u; -const NEXT_TOKEN = /^(?:[([{<~!]|\+\+?|--?)$/u; -const PREV_TOKEN_M = /^[)\]}>*]$/u; -const NEXT_TOKEN_M = /^[{*]$/u; -const TEMPLATE_OPEN_PAREN = /\$\{$/u; -const TEMPLATE_CLOSE_PAREN = /^\}/u; -const CHECK_TYPE = /^(?:JSXElement|RegularExpression|String|Template|PrivateIdentifier)$/u; -const KEYS = keywords.concat(["as", "async", "await", "from", "get", "let", "of", "set", "yield"]); - -// check duplications. -(function() { - KEYS.sort(); - for (let i = 1; i < KEYS.length; ++i) { - if (KEYS[i] === KEYS[i - 1]) { - throw new Error(`Duplication was found in the keyword list: ${KEYS[i]}`); - } - } -}()); - -//------------------------------------------------------------------------------ -// Helpers -//------------------------------------------------------------------------------ - -/** - * Checks whether or not a given token is a "Template" token ends with "${". - * @param {Token} token A token to check. - * @returns {boolean} `true` if the token is a "Template" token ends with "${". - */ -function isOpenParenOfTemplate(token) { - return token.type === "Template" && TEMPLATE_OPEN_PAREN.test(token.value); -} - -/** - * Checks whether or not a given token is a "Template" token starts with "}". - * @param {Token} token A token to check. - * @returns {boolean} `true` if the token is a "Template" token starts with "}". - */ -function isCloseParenOfTemplate(token) { - return token.type === "Template" && TEMPLATE_CLOSE_PAREN.test(token.value); -} - -//------------------------------------------------------------------------------ -// Rule Definition -//------------------------------------------------------------------------------ - -/** @type {import('../shared/types').Rule} */ -module.exports = { - meta: { - deprecated: true, - replacedBy: [], - type: "layout", - - docs: { - description: "Enforce consistent spacing before and after keywords", - recommended: false, - url: "https://eslint.org/docs/latest/rules/keyword-spacing" - }, - - fixable: "whitespace", - - schema: [ - { - type: "object", - properties: { - before: { type: "boolean", default: true }, - after: { type: "boolean", default: true }, - overrides: { - type: "object", - properties: KEYS.reduce((retv, key) => { - retv[key] = { - type: "object", - properties: { - before: { type: "boolean" }, - after: { type: "boolean" } - }, - additionalProperties: false - }; - return retv; - }, {}), - additionalProperties: false - } - }, - additionalProperties: false - } - ], - messages: { - expectedBefore: "Expected space(s) before \"{{value}}\".", - expectedAfter: "Expected space(s) after \"{{value}}\".", - unexpectedBefore: "Unexpected space(s) before \"{{value}}\".", - unexpectedAfter: "Unexpected space(s) after \"{{value}}\"." - } - }, - - create(context) { - const sourceCode = context.sourceCode; - - const tokensToIgnore = new WeakSet(); - - /** - * Reports a given token if there are not space(s) before the token. - * @param {Token} token A token to report. - * @param {RegExp} pattern A pattern of the previous token to check. - * @returns {void} - */ - function expectSpaceBefore(token, pattern) { - const prevToken = sourceCode.getTokenBefore(token); - - if (prevToken && - (CHECK_TYPE.test(prevToken.type) || pattern.test(prevToken.value)) && - !isOpenParenOfTemplate(prevToken) && - !tokensToIgnore.has(prevToken) && - astUtils.isTokenOnSameLine(prevToken, token) && - !sourceCode.isSpaceBetweenTokens(prevToken, token) - ) { - context.report({ - loc: token.loc, - messageId: "expectedBefore", - data: token, - fix(fixer) { - return fixer.insertTextBefore(token, " "); - } - }); - } - } - - /** - * Reports a given token if there are space(s) before the token. - * @param {Token} token A token to report. - * @param {RegExp} pattern A pattern of the previous token to check. - * @returns {void} - */ - function unexpectSpaceBefore(token, pattern) { - const prevToken = sourceCode.getTokenBefore(token); - - if (prevToken && - (CHECK_TYPE.test(prevToken.type) || pattern.test(prevToken.value)) && - !isOpenParenOfTemplate(prevToken) && - !tokensToIgnore.has(prevToken) && - astUtils.isTokenOnSameLine(prevToken, token) && - sourceCode.isSpaceBetweenTokens(prevToken, token) - ) { - context.report({ - loc: { start: prevToken.loc.end, end: token.loc.start }, - messageId: "unexpectedBefore", - data: token, - fix(fixer) { - return fixer.removeRange([prevToken.range[1], token.range[0]]); - } - }); - } - } - - /** - * Reports a given token if there are not space(s) after the token. - * @param {Token} token A token to report. - * @param {RegExp} pattern A pattern of the next token to check. - * @returns {void} - */ - function expectSpaceAfter(token, pattern) { - const nextToken = sourceCode.getTokenAfter(token); - - if (nextToken && - (CHECK_TYPE.test(nextToken.type) || pattern.test(nextToken.value)) && - !isCloseParenOfTemplate(nextToken) && - !tokensToIgnore.has(nextToken) && - astUtils.isTokenOnSameLine(token, nextToken) && - !sourceCode.isSpaceBetweenTokens(token, nextToken) - ) { - context.report({ - loc: token.loc, - messageId: "expectedAfter", - data: token, - fix(fixer) { - return fixer.insertTextAfter(token, " "); - } - }); - } - } - - /** - * Reports a given token if there are space(s) after the token. - * @param {Token} token A token to report. - * @param {RegExp} pattern A pattern of the next token to check. - * @returns {void} - */ - function unexpectSpaceAfter(token, pattern) { - const nextToken = sourceCode.getTokenAfter(token); - - if (nextToken && - (CHECK_TYPE.test(nextToken.type) || pattern.test(nextToken.value)) && - !isCloseParenOfTemplate(nextToken) && - !tokensToIgnore.has(nextToken) && - astUtils.isTokenOnSameLine(token, nextToken) && - sourceCode.isSpaceBetweenTokens(token, nextToken) - ) { - - context.report({ - loc: { start: token.loc.end, end: nextToken.loc.start }, - messageId: "unexpectedAfter", - data: token, - fix(fixer) { - return fixer.removeRange([token.range[1], nextToken.range[0]]); - } - }); - } - } - - /** - * Parses the option object and determines check methods for each keyword. - * @param {Object|undefined} options The option object to parse. - * @returns {Object} - Normalized option object. - * Keys are keywords (there are for every keyword). - * Values are instances of `{"before": function, "after": function}`. - */ - function parseOptions(options = {}) { - const before = options.before !== false; - const after = options.after !== false; - const defaultValue = { - before: before ? expectSpaceBefore : unexpectSpaceBefore, - after: after ? expectSpaceAfter : unexpectSpaceAfter - }; - const overrides = (options && options.overrides) || {}; - const retv = Object.create(null); - - for (let i = 0; i < KEYS.length; ++i) { - const key = KEYS[i]; - const override = overrides[key]; - - if (override) { - const thisBefore = ("before" in override) ? override.before : before; - const thisAfter = ("after" in override) ? override.after : after; - - retv[key] = { - before: thisBefore ? expectSpaceBefore : unexpectSpaceBefore, - after: thisAfter ? expectSpaceAfter : unexpectSpaceAfter - }; - } else { - retv[key] = defaultValue; - } - } - - return retv; - } - - const checkMethodMap = parseOptions(context.options[0]); - - /** - * Reports a given token if usage of spacing followed by the token is - * invalid. - * @param {Token} token A token to report. - * @param {RegExp} [pattern] Optional. A pattern of the previous - * token to check. - * @returns {void} - */ - function checkSpacingBefore(token, pattern) { - checkMethodMap[token.value].before(token, pattern || PREV_TOKEN); - } - - /** - * Reports a given token if usage of spacing preceded by the token is - * invalid. - * @param {Token} token A token to report. - * @param {RegExp} [pattern] Optional. A pattern of the next - * token to check. - * @returns {void} - */ - function checkSpacingAfter(token, pattern) { - checkMethodMap[token.value].after(token, pattern || NEXT_TOKEN); - } - - /** - * Reports a given token if usage of spacing around the token is invalid. - * @param {Token} token A token to report. - * @returns {void} - */ - function checkSpacingAround(token) { - checkSpacingBefore(token); - checkSpacingAfter(token); - } - - /** - * Reports the first token of a given node if the first token is a keyword - * and usage of spacing around the token is invalid. - * @param {ASTNode|null} node A node to report. - * @returns {void} - */ - function checkSpacingAroundFirstToken(node) { - const firstToken = node && sourceCode.getFirstToken(node); - - if (firstToken && firstToken.type === "Keyword") { - checkSpacingAround(firstToken); - } - } - - /** - * Reports the first token of a given node if the first token is a keyword - * and usage of spacing followed by the token is invalid. - * - * This is used for unary operators (e.g. `typeof`), `function`, and `super`. - * Other rules are handling usage of spacing preceded by those keywords. - * @param {ASTNode|null} node A node to report. - * @returns {void} - */ - function checkSpacingBeforeFirstToken(node) { - const firstToken = node && sourceCode.getFirstToken(node); - - if (firstToken && firstToken.type === "Keyword") { - checkSpacingBefore(firstToken); - } - } - - /** - * Reports the previous token of a given node if the token is a keyword and - * usage of spacing around the token is invalid. - * @param {ASTNode|null} node A node to report. - * @returns {void} - */ - function checkSpacingAroundTokenBefore(node) { - if (node) { - const token = sourceCode.getTokenBefore(node, astUtils.isKeywordToken); - - checkSpacingAround(token); - } - } - - /** - * Reports `async` or `function` keywords of a given node if usage of - * spacing around those keywords is invalid. - * @param {ASTNode} node A node to report. - * @returns {void} - */ - function checkSpacingForFunction(node) { - const firstToken = node && sourceCode.getFirstToken(node); - - if (firstToken && - ((firstToken.type === "Keyword" && firstToken.value === "function") || - firstToken.value === "async") - ) { - checkSpacingBefore(firstToken); - } - } - - /** - * Reports `class` and `extends` keywords of a given node if usage of - * spacing around those keywords is invalid. - * @param {ASTNode} node A node to report. - * @returns {void} - */ - function checkSpacingForClass(node) { - checkSpacingAroundFirstToken(node); - checkSpacingAroundTokenBefore(node.superClass); - } - - /** - * Reports `if` and `else` keywords of a given node if usage of spacing - * around those keywords is invalid. - * @param {ASTNode} node A node to report. - * @returns {void} - */ - function checkSpacingForIfStatement(node) { - checkSpacingAroundFirstToken(node); - checkSpacingAroundTokenBefore(node.alternate); - } - - /** - * Reports `try`, `catch`, and `finally` keywords of a given node if usage - * of spacing around those keywords is invalid. - * @param {ASTNode} node A node to report. - * @returns {void} - */ - function checkSpacingForTryStatement(node) { - checkSpacingAroundFirstToken(node); - checkSpacingAroundFirstToken(node.handler); - checkSpacingAroundTokenBefore(node.finalizer); - } - - /** - * Reports `do` and `while` keywords of a given node if usage of spacing - * around those keywords is invalid. - * @param {ASTNode} node A node to report. - * @returns {void} - */ - function checkSpacingForDoWhileStatement(node) { - checkSpacingAroundFirstToken(node); - checkSpacingAroundTokenBefore(node.test); - } - - /** - * Reports `for` and `in` keywords of a given node if usage of spacing - * around those keywords is invalid. - * @param {ASTNode} node A node to report. - * @returns {void} - */ - function checkSpacingForForInStatement(node) { - checkSpacingAroundFirstToken(node); - - const inToken = sourceCode.getTokenBefore(node.right, astUtils.isNotOpeningParenToken); - const previousToken = sourceCode.getTokenBefore(inToken); - - if (previousToken.type !== "PrivateIdentifier") { - checkSpacingBefore(inToken); - } - - checkSpacingAfter(inToken); - } - - /** - * Reports `for` and `of` keywords of a given node if usage of spacing - * around those keywords is invalid. - * @param {ASTNode} node A node to report. - * @returns {void} - */ - function checkSpacingForForOfStatement(node) { - if (node.await) { - checkSpacingBefore(sourceCode.getFirstToken(node, 0)); - checkSpacingAfter(sourceCode.getFirstToken(node, 1)); - } else { - checkSpacingAroundFirstToken(node); - } - - const ofToken = sourceCode.getTokenBefore(node.right, astUtils.isNotOpeningParenToken); - const previousToken = sourceCode.getTokenBefore(ofToken); - - if (previousToken.type !== "PrivateIdentifier") { - checkSpacingBefore(ofToken); - } - - checkSpacingAfter(ofToken); - } - - /** - * Reports `import`, `export`, `as`, and `from` keywords of a given node if - * usage of spacing around those keywords is invalid. - * - * This rule handles the `*` token in module declarations. - * - * import*as A from "./a"; /*error Expected space(s) after "import". - * error Expected space(s) before "as". - * @param {ASTNode} node A node to report. - * @returns {void} - */ - function checkSpacingForModuleDeclaration(node) { - const firstToken = sourceCode.getFirstToken(node); - - checkSpacingBefore(firstToken, PREV_TOKEN_M); - checkSpacingAfter(firstToken, NEXT_TOKEN_M); - - if (node.type === "ExportDefaultDeclaration") { - checkSpacingAround(sourceCode.getTokenAfter(firstToken)); - } - - if (node.type === "ExportAllDeclaration" && node.exported) { - const asToken = sourceCode.getTokenBefore(node.exported); - - checkSpacingBefore(asToken, PREV_TOKEN_M); - checkSpacingAfter(asToken, NEXT_TOKEN_M); - } - - if (node.source) { - const fromToken = sourceCode.getTokenBefore(node.source); - - checkSpacingBefore(fromToken, PREV_TOKEN_M); - checkSpacingAfter(fromToken, NEXT_TOKEN_M); - } - } - - /** - * Reports `as` keyword of a given node if usage of spacing around this - * keyword is invalid. - * @param {ASTNode} node An `ImportSpecifier` node to check. - * @returns {void} - */ - function checkSpacingForImportSpecifier(node) { - if (node.imported.range[0] !== node.local.range[0]) { - const asToken = sourceCode.getTokenBefore(node.local); - - checkSpacingBefore(asToken, PREV_TOKEN_M); - } - } - - /** - * Reports `as` keyword of a given node if usage of spacing around this - * keyword is invalid. - * @param {ASTNode} node An `ExportSpecifier` node to check. - * @returns {void} - */ - function checkSpacingForExportSpecifier(node) { - if (node.local.range[0] !== node.exported.range[0]) { - const asToken = sourceCode.getTokenBefore(node.exported); - - checkSpacingBefore(asToken, PREV_TOKEN_M); - checkSpacingAfter(asToken, NEXT_TOKEN_M); - } - } - - /** - * Reports `as` keyword of a given node if usage of spacing around this - * keyword is invalid. - * @param {ASTNode} node A node to report. - * @returns {void} - */ - function checkSpacingForImportNamespaceSpecifier(node) { - const asToken = sourceCode.getFirstToken(node, 1); - - checkSpacingBefore(asToken, PREV_TOKEN_M); - } - - /** - * Reports `static`, `get`, and `set` keywords of a given node if usage of - * spacing around those keywords is invalid. - * @param {ASTNode} node A node to report. - * @throws {Error} If unable to find token get, set, or async beside method name. - * @returns {void} - */ - function checkSpacingForProperty(node) { - if (node.static) { - checkSpacingAroundFirstToken(node); - } - if (node.kind === "get" || - node.kind === "set" || - ( - (node.method || node.type === "MethodDefinition") && - node.value.async - ) - ) { - const token = sourceCode.getTokenBefore( - node.key, - tok => { - switch (tok.value) { - case "get": - case "set": - case "async": - return true; - default: - return false; - } - } - ); - - if (!token) { - throw new Error("Failed to find token get, set, or async beside method name"); - } - - - checkSpacingAround(token); - } - } - - /** - * Reports `await` keyword of a given node if usage of spacing before - * this keyword is invalid. - * @param {ASTNode} node A node to report. - * @returns {void} - */ - function checkSpacingForAwaitExpression(node) { - checkSpacingBefore(sourceCode.getFirstToken(node)); - } - - return { - - // Statements - DebuggerStatement: checkSpacingAroundFirstToken, - WithStatement: checkSpacingAroundFirstToken, - - // Statements - Control flow - BreakStatement: checkSpacingAroundFirstToken, - ContinueStatement: checkSpacingAroundFirstToken, - ReturnStatement: checkSpacingAroundFirstToken, - ThrowStatement: checkSpacingAroundFirstToken, - TryStatement: checkSpacingForTryStatement, - - // Statements - Choice - IfStatement: checkSpacingForIfStatement, - SwitchStatement: checkSpacingAroundFirstToken, - SwitchCase: checkSpacingAroundFirstToken, - - // Statements - Loops - DoWhileStatement: checkSpacingForDoWhileStatement, - ForInStatement: checkSpacingForForInStatement, - ForOfStatement: checkSpacingForForOfStatement, - ForStatement: checkSpacingAroundFirstToken, - WhileStatement: checkSpacingAroundFirstToken, - - // Statements - Declarations - ClassDeclaration: checkSpacingForClass, - ExportNamedDeclaration: checkSpacingForModuleDeclaration, - ExportDefaultDeclaration: checkSpacingForModuleDeclaration, - ExportAllDeclaration: checkSpacingForModuleDeclaration, - FunctionDeclaration: checkSpacingForFunction, - ImportDeclaration: checkSpacingForModuleDeclaration, - VariableDeclaration: checkSpacingAroundFirstToken, - - // Expressions - ArrowFunctionExpression: checkSpacingForFunction, - AwaitExpression: checkSpacingForAwaitExpression, - ClassExpression: checkSpacingForClass, - FunctionExpression: checkSpacingForFunction, - NewExpression: checkSpacingBeforeFirstToken, - Super: checkSpacingBeforeFirstToken, - ThisExpression: checkSpacingBeforeFirstToken, - UnaryExpression: checkSpacingBeforeFirstToken, - YieldExpression: checkSpacingBeforeFirstToken, - - // Others - ImportSpecifier: checkSpacingForImportSpecifier, - ExportSpecifier: checkSpacingForExportSpecifier, - ImportNamespaceSpecifier: checkSpacingForImportNamespaceSpecifier, - MethodDefinition: checkSpacingForProperty, - PropertyDefinition: checkSpacingForProperty, - StaticBlock: checkSpacingAroundFirstToken, - Property: checkSpacingForProperty, - - // To avoid conflicts with `space-infix-ops`, e.g. `a > this.b` - "BinaryExpression[operator='>']"(node) { - const operatorToken = sourceCode.getTokenBefore(node.right, astUtils.isNotOpeningParenToken); - - tokensToIgnore.add(operatorToken); - } - }; - } -}; diff --git a/tools/eslint/node_modules/eslint/lib/rules/line-comment-position.js b/tools/eslint/node_modules/eslint/lib/rules/line-comment-position.js deleted file mode 100644 index e7a7788ca9f0d0..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/rules/line-comment-position.js +++ /dev/null @@ -1,125 +0,0 @@ -/** - * @fileoverview Rule to enforce the position of line comments - * @author Alberto Rodrรญguez - * @deprecated in ESLint v9.3.0 - */ -"use strict"; - -const astUtils = require("./utils/ast-utils"); - -//------------------------------------------------------------------------------ -// Rule Definition -//------------------------------------------------------------------------------ - -/** @type {import('../shared/types').Rule} */ -module.exports = { - meta: { - deprecated: true, - replacedBy: [], - type: "layout", - - docs: { - description: "Enforce position of line comments", - recommended: false, - url: "https://eslint.org/docs/latest/rules/line-comment-position" - }, - - schema: [ - { - oneOf: [ - { - enum: ["above", "beside"] - }, - { - type: "object", - properties: { - position: { - enum: ["above", "beside"] - }, - ignorePattern: { - type: "string" - }, - applyDefaultPatterns: { - type: "boolean" - }, - applyDefaultIgnorePatterns: { - type: "boolean" - } - }, - additionalProperties: false - } - ] - } - ], - messages: { - above: "Expected comment to be above code.", - beside: "Expected comment to be beside code." - } - }, - - create(context) { - const options = context.options[0]; - - let above, - ignorePattern, - applyDefaultIgnorePatterns = true; - - if (!options || typeof options === "string") { - above = !options || options === "above"; - - } else { - above = !options.position || options.position === "above"; - ignorePattern = options.ignorePattern; - - if (Object.hasOwn(options, "applyDefaultIgnorePatterns")) { - applyDefaultIgnorePatterns = options.applyDefaultIgnorePatterns; - } else { - applyDefaultIgnorePatterns = options.applyDefaultPatterns !== false; - } - } - - const defaultIgnoreRegExp = astUtils.COMMENTS_IGNORE_PATTERN; - const fallThroughRegExp = /^\s*falls?\s?through/u; - const customIgnoreRegExp = new RegExp(ignorePattern, "u"); - const sourceCode = context.sourceCode; - - //-------------------------------------------------------------------------- - // Public - //-------------------------------------------------------------------------- - - return { - Program() { - const comments = sourceCode.getAllComments(); - - comments.filter(token => token.type === "Line").forEach(node => { - if (applyDefaultIgnorePatterns && (defaultIgnoreRegExp.test(node.value) || fallThroughRegExp.test(node.value))) { - return; - } - - if (ignorePattern && customIgnoreRegExp.test(node.value)) { - return; - } - - const previous = sourceCode.getTokenBefore(node, { includeComments: true }); - const isOnSameLine = previous && previous.loc.end.line === node.loc.start.line; - - if (above) { - if (isOnSameLine) { - context.report({ - node, - messageId: "above" - }); - } - } else { - if (!isOnSameLine) { - context.report({ - node, - messageId: "beside" - }); - } - } - }); - } - }; - } -}; diff --git a/tools/eslint/node_modules/eslint/lib/rules/linebreak-style.js b/tools/eslint/node_modules/eslint/lib/rules/linebreak-style.js deleted file mode 100644 index e59acca1b5c105..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/rules/linebreak-style.js +++ /dev/null @@ -1,108 +0,0 @@ -/** - * @fileoverview Rule to enforce a single linebreak style. - * @author Erik Mueller - * @deprecated in ESLint v8.53.0 - */ - -"use strict"; - -//------------------------------------------------------------------------------ -// Requirements -//------------------------------------------------------------------------------ - -const astUtils = require("./utils/ast-utils"); - -//------------------------------------------------------------------------------ -// Rule Definition -//------------------------------------------------------------------------------ - -/** @type {import('../shared/types').Rule} */ -module.exports = { - meta: { - deprecated: true, - replacedBy: [], - type: "layout", - - docs: { - description: "Enforce consistent linebreak style", - recommended: false, - url: "https://eslint.org/docs/latest/rules/linebreak-style" - }, - - fixable: "whitespace", - - schema: [ - { - enum: ["unix", "windows"] - } - ], - messages: { - expectedLF: "Expected linebreaks to be 'LF' but found 'CRLF'.", - expectedCRLF: "Expected linebreaks to be 'CRLF' but found 'LF'." - } - }, - - create(context) { - const sourceCode = context.sourceCode; - - //-------------------------------------------------------------------------- - // Helpers - //-------------------------------------------------------------------------- - - /** - * Builds a fix function that replaces text at the specified range in the source text. - * @param {int[]} range The range to replace - * @param {string} text The text to insert. - * @returns {Function} Fixer function - * @private - */ - function createFix(range, text) { - return function(fixer) { - return fixer.replaceTextRange(range, text); - }; - } - - //-------------------------------------------------------------------------- - // Public - //-------------------------------------------------------------------------- - - return { - Program: function checkForLinebreakStyle(node) { - const linebreakStyle = context.options[0] || "unix", - expectedLF = linebreakStyle === "unix", - expectedLFChars = expectedLF ? "\n" : "\r\n", - source = sourceCode.getText(), - pattern = astUtils.createGlobalLinebreakMatcher(); - let match; - - let i = 0; - - while ((match = pattern.exec(source)) !== null) { - i++; - if (match[0] === expectedLFChars) { - continue; - } - - const index = match.index; - const range = [index, index + match[0].length]; - - context.report({ - node, - loc: { - start: { - line: i, - column: sourceCode.lines[i - 1].length - }, - end: { - line: i + 1, - column: 0 - } - }, - messageId: expectedLF ? "expectedLF" : "expectedCRLF", - fix: createFix(range, expectedLFChars) - }); - } - } - }; - } -}; diff --git a/tools/eslint/node_modules/eslint/lib/rules/lines-around-comment.js b/tools/eslint/node_modules/eslint/lib/rules/lines-around-comment.js deleted file mode 100644 index 2a6e472f9a09a1..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/rules/lines-around-comment.js +++ /dev/null @@ -1,471 +0,0 @@ -/** - * @fileoverview Enforces empty lines around comments. - * @author Jamund Ferguson - * @deprecated in ESLint v8.53.0 - */ -"use strict"; - -//------------------------------------------------------------------------------ -// Requirements -//------------------------------------------------------------------------------ - -const astUtils = require("./utils/ast-utils"); - -//------------------------------------------------------------------------------ -// Helpers -//------------------------------------------------------------------------------ - -/** - * Return an array with any line numbers that are empty. - * @param {Array} lines An array of each line of the file. - * @returns {Array} An array of line numbers. - */ -function getEmptyLineNums(lines) { - const emptyLines = lines.map((line, i) => ({ - code: line.trim(), - num: i + 1 - })).filter(line => !line.code).map(line => line.num); - - return emptyLines; -} - -/** - * Return an array with any line numbers that contain comments. - * @param {Array} comments An array of comment tokens. - * @returns {Array} An array of line numbers. - */ -function getCommentLineNums(comments) { - const lines = []; - - comments.forEach(token => { - const start = token.loc.start.line; - const end = token.loc.end.line; - - lines.push(start, end); - }); - return lines; -} - -//------------------------------------------------------------------------------ -// Rule Definition -//------------------------------------------------------------------------------ - -/** @type {import('../shared/types').Rule} */ -module.exports = { - meta: { - deprecated: true, - replacedBy: [], - type: "layout", - - docs: { - description: "Require empty lines around comments", - recommended: false, - url: "https://eslint.org/docs/latest/rules/lines-around-comment" - }, - - fixable: "whitespace", - - schema: [ - { - type: "object", - properties: { - beforeBlockComment: { - type: "boolean", - default: true - }, - afterBlockComment: { - type: "boolean", - default: false - }, - beforeLineComment: { - type: "boolean", - default: false - }, - afterLineComment: { - type: "boolean", - default: false - }, - allowBlockStart: { - type: "boolean", - default: false - }, - allowBlockEnd: { - type: "boolean", - default: false - }, - allowClassStart: { - type: "boolean" - }, - allowClassEnd: { - type: "boolean" - }, - allowObjectStart: { - type: "boolean" - }, - allowObjectEnd: { - type: "boolean" - }, - allowArrayStart: { - type: "boolean" - }, - allowArrayEnd: { - type: "boolean" - }, - ignorePattern: { - type: "string" - }, - applyDefaultIgnorePatterns: { - type: "boolean" - }, - afterHashbangComment: { - type: "boolean", - default: false - } - }, - additionalProperties: false - } - ], - messages: { - after: "Expected line after comment.", - before: "Expected line before comment." - } - }, - - create(context) { - - const options = Object.assign({}, context.options[0]); - const ignorePattern = options.ignorePattern; - const defaultIgnoreRegExp = astUtils.COMMENTS_IGNORE_PATTERN; - const customIgnoreRegExp = new RegExp(ignorePattern, "u"); - const applyDefaultIgnorePatterns = options.applyDefaultIgnorePatterns !== false; - - options.beforeBlockComment = typeof options.beforeBlockComment !== "undefined" ? options.beforeBlockComment : true; - - const sourceCode = context.sourceCode; - - const lines = sourceCode.lines, - numLines = lines.length + 1, - comments = sourceCode.getAllComments(), - commentLines = getCommentLineNums(comments), - emptyLines = getEmptyLineNums(lines), - commentAndEmptyLines = new Set(commentLines.concat(emptyLines)); - - /** - * Returns whether or not comments are on lines starting with or ending with code - * @param {token} token The comment token to check. - * @returns {boolean} True if the comment is not alone. - */ - function codeAroundComment(token) { - let currentToken = token; - - do { - currentToken = sourceCode.getTokenBefore(currentToken, { includeComments: true }); - } while (currentToken && astUtils.isCommentToken(currentToken)); - - if (currentToken && astUtils.isTokenOnSameLine(currentToken, token)) { - return true; - } - - currentToken = token; - do { - currentToken = sourceCode.getTokenAfter(currentToken, { includeComments: true }); - } while (currentToken && astUtils.isCommentToken(currentToken)); - - if (currentToken && astUtils.isTokenOnSameLine(token, currentToken)) { - return true; - } - - return false; - } - - /** - * Returns whether or not comments are inside a node type or not. - * @param {ASTNode} parent The Comment parent node. - * @param {string} nodeType The parent type to check against. - * @returns {boolean} True if the comment is inside nodeType. - */ - function isParentNodeType(parent, nodeType) { - return parent.type === nodeType || - (parent.body && parent.body.type === nodeType) || - (parent.consequent && parent.consequent.type === nodeType); - } - - /** - * Returns the parent node that contains the given token. - * @param {token} token The token to check. - * @returns {ASTNode|null} The parent node that contains the given token. - */ - function getParentNodeOfToken(token) { - const node = sourceCode.getNodeByRangeIndex(token.range[0]); - - /* - * For the purpose of this rule, the comment token is in a `StaticBlock` node only - * if it's inside the braces of that `StaticBlock` node. - * - * Example where this function returns `null`: - * - * static - * // comment - * { - * } - * - * Example where this function returns `StaticBlock` node: - * - * static - * { - * // comment - * } - * - */ - if (node && node.type === "StaticBlock") { - const openingBrace = sourceCode.getFirstToken(node, { skip: 1 }); // skip the `static` token - - return token.range[0] >= openingBrace.range[0] - ? node - : null; - } - - return node; - } - - /** - * Returns whether or not comments are at the parent start or not. - * @param {token} token The Comment token. - * @param {string} nodeType The parent type to check against. - * @returns {boolean} True if the comment is at parent start. - */ - function isCommentAtParentStart(token, nodeType) { - const parent = getParentNodeOfToken(token); - - if (parent && isParentNodeType(parent, nodeType)) { - let parentStartNodeOrToken = parent; - - if (parent.type === "StaticBlock") { - parentStartNodeOrToken = sourceCode.getFirstToken(parent, { skip: 1 }); // opening brace of the static block - } else if (parent.type === "SwitchStatement") { - parentStartNodeOrToken = sourceCode.getTokenAfter(parent.discriminant, { - filter: astUtils.isOpeningBraceToken - }); // opening brace of the switch statement - } - - return token.loc.start.line - parentStartNodeOrToken.loc.start.line === 1; - } - - return false; - } - - /** - * Returns whether or not comments are at the parent end or not. - * @param {token} token The Comment token. - * @param {string} nodeType The parent type to check against. - * @returns {boolean} True if the comment is at parent end. - */ - function isCommentAtParentEnd(token, nodeType) { - const parent = getParentNodeOfToken(token); - - return !!parent && isParentNodeType(parent, nodeType) && - parent.loc.end.line - token.loc.end.line === 1; - } - - /** - * Returns whether or not comments are at the block start or not. - * @param {token} token The Comment token. - * @returns {boolean} True if the comment is at block start. - */ - function isCommentAtBlockStart(token) { - return ( - isCommentAtParentStart(token, "ClassBody") || - isCommentAtParentStart(token, "BlockStatement") || - isCommentAtParentStart(token, "StaticBlock") || - isCommentAtParentStart(token, "SwitchCase") || - isCommentAtParentStart(token, "SwitchStatement") - ); - } - - /** - * Returns whether or not comments are at the block end or not. - * @param {token} token The Comment token. - * @returns {boolean} True if the comment is at block end. - */ - function isCommentAtBlockEnd(token) { - return ( - isCommentAtParentEnd(token, "ClassBody") || - isCommentAtParentEnd(token, "BlockStatement") || - isCommentAtParentEnd(token, "StaticBlock") || - isCommentAtParentEnd(token, "SwitchCase") || - isCommentAtParentEnd(token, "SwitchStatement") - ); - } - - /** - * Returns whether or not comments are at the class start or not. - * @param {token} token The Comment token. - * @returns {boolean} True if the comment is at class start. - */ - function isCommentAtClassStart(token) { - return isCommentAtParentStart(token, "ClassBody"); - } - - /** - * Returns whether or not comments are at the class end or not. - * @param {token} token The Comment token. - * @returns {boolean} True if the comment is at class end. - */ - function isCommentAtClassEnd(token) { - return isCommentAtParentEnd(token, "ClassBody"); - } - - /** - * Returns whether or not comments are at the object start or not. - * @param {token} token The Comment token. - * @returns {boolean} True if the comment is at object start. - */ - function isCommentAtObjectStart(token) { - return isCommentAtParentStart(token, "ObjectExpression") || isCommentAtParentStart(token, "ObjectPattern"); - } - - /** - * Returns whether or not comments are at the object end or not. - * @param {token} token The Comment token. - * @returns {boolean} True if the comment is at object end. - */ - function isCommentAtObjectEnd(token) { - return isCommentAtParentEnd(token, "ObjectExpression") || isCommentAtParentEnd(token, "ObjectPattern"); - } - - /** - * Returns whether or not comments are at the array start or not. - * @param {token} token The Comment token. - * @returns {boolean} True if the comment is at array start. - */ - function isCommentAtArrayStart(token) { - return isCommentAtParentStart(token, "ArrayExpression") || isCommentAtParentStart(token, "ArrayPattern"); - } - - /** - * Returns whether or not comments are at the array end or not. - * @param {token} token The Comment token. - * @returns {boolean} True if the comment is at array end. - */ - function isCommentAtArrayEnd(token) { - return isCommentAtParentEnd(token, "ArrayExpression") || isCommentAtParentEnd(token, "ArrayPattern"); - } - - /** - * Checks if a comment token has lines around it (ignores inline comments) - * @param {token} token The Comment token. - * @param {Object} opts Options to determine the newline. - * @param {boolean} opts.after Should have a newline after this line. - * @param {boolean} opts.before Should have a newline before this line. - * @returns {void} - */ - function checkForEmptyLine(token, opts) { - if (applyDefaultIgnorePatterns && defaultIgnoreRegExp.test(token.value)) { - return; - } - - if (ignorePattern && customIgnoreRegExp.test(token.value)) { - return; - } - - let after = opts.after, - before = opts.before; - - const prevLineNum = token.loc.start.line - 1, - nextLineNum = token.loc.end.line + 1, - commentIsNotAlone = codeAroundComment(token); - - const blockStartAllowed = options.allowBlockStart && - isCommentAtBlockStart(token) && - !(options.allowClassStart === false && - isCommentAtClassStart(token)), - blockEndAllowed = options.allowBlockEnd && isCommentAtBlockEnd(token) && !(options.allowClassEnd === false && isCommentAtClassEnd(token)), - classStartAllowed = options.allowClassStart && isCommentAtClassStart(token), - classEndAllowed = options.allowClassEnd && isCommentAtClassEnd(token), - objectStartAllowed = options.allowObjectStart && isCommentAtObjectStart(token), - objectEndAllowed = options.allowObjectEnd && isCommentAtObjectEnd(token), - arrayStartAllowed = options.allowArrayStart && isCommentAtArrayStart(token), - arrayEndAllowed = options.allowArrayEnd && isCommentAtArrayEnd(token); - - const exceptionStartAllowed = blockStartAllowed || classStartAllowed || objectStartAllowed || arrayStartAllowed; - const exceptionEndAllowed = blockEndAllowed || classEndAllowed || objectEndAllowed || arrayEndAllowed; - - // ignore top of the file and bottom of the file - if (prevLineNum < 1) { - before = false; - } - if (nextLineNum >= numLines) { - after = false; - } - - // we ignore all inline comments - if (commentIsNotAlone) { - return; - } - - const previousTokenOrComment = sourceCode.getTokenBefore(token, { includeComments: true }); - const nextTokenOrComment = sourceCode.getTokenAfter(token, { includeComments: true }); - - // check for newline before - if (!exceptionStartAllowed && before && !commentAndEmptyLines.has(prevLineNum) && - !(astUtils.isCommentToken(previousTokenOrComment) && astUtils.isTokenOnSameLine(previousTokenOrComment, token))) { - const lineStart = token.range[0] - token.loc.start.column; - const range = [lineStart, lineStart]; - - context.report({ - node: token, - messageId: "before", - fix(fixer) { - return fixer.insertTextBeforeRange(range, "\n"); - } - }); - } - - // check for newline after - if (!exceptionEndAllowed && after && !commentAndEmptyLines.has(nextLineNum) && - !(astUtils.isCommentToken(nextTokenOrComment) && astUtils.isTokenOnSameLine(token, nextTokenOrComment))) { - context.report({ - node: token, - messageId: "after", - fix(fixer) { - return fixer.insertTextAfter(token, "\n"); - } - }); - } - - } - - //-------------------------------------------------------------------------- - // Public - //-------------------------------------------------------------------------- - - return { - Program() { - comments.forEach(token => { - if (token.type === "Line") { - if (options.beforeLineComment || options.afterLineComment) { - checkForEmptyLine(token, { - after: options.afterLineComment, - before: options.beforeLineComment - }); - } - } else if (token.type === "Block") { - if (options.beforeBlockComment || options.afterBlockComment) { - checkForEmptyLine(token, { - after: options.afterBlockComment, - before: options.beforeBlockComment - }); - } - } else if (token.type === "Shebang") { - if (options.afterHashbangComment) { - checkForEmptyLine(token, { - after: options.afterHashbangComment, - before: false - }); - } - } - }); - } - }; - } -}; diff --git a/tools/eslint/node_modules/eslint/lib/rules/lines-around-directive.js b/tools/eslint/node_modules/eslint/lib/rules/lines-around-directive.js deleted file mode 100644 index fb6871d3e8af25..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/rules/lines-around-directive.js +++ /dev/null @@ -1,201 +0,0 @@ -/** - * @fileoverview Require or disallow newlines around directives. - * @author Kai Cataldo - * @deprecated in ESLint v4.0.0 - */ - -"use strict"; - -const astUtils = require("./utils/ast-utils"); - -//------------------------------------------------------------------------------ -// Rule Definition -//------------------------------------------------------------------------------ - -/** @type {import('../shared/types').Rule} */ -module.exports = { - meta: { - type: "layout", - - docs: { - description: "Require or disallow newlines around directives", - recommended: false, - url: "https://eslint.org/docs/latest/rules/lines-around-directive" - }, - - schema: [{ - oneOf: [ - { - enum: ["always", "never"] - }, - { - type: "object", - properties: { - before: { - enum: ["always", "never"] - }, - after: { - enum: ["always", "never"] - } - }, - additionalProperties: false, - minProperties: 2 - } - ] - }], - - fixable: "whitespace", - messages: { - expected: "Expected newline {{location}} \"{{value}}\" directive.", - unexpected: "Unexpected newline {{location}} \"{{value}}\" directive." - }, - deprecated: true, - replacedBy: ["padding-line-between-statements"] - }, - - create(context) { - const sourceCode = context.sourceCode; - const config = context.options[0] || "always"; - const expectLineBefore = typeof config === "string" ? config : config.before; - const expectLineAfter = typeof config === "string" ? config : config.after; - - //-------------------------------------------------------------------------- - // Helpers - //-------------------------------------------------------------------------- - - /** - * Check if node is preceded by a blank newline. - * @param {ASTNode} node Node to check. - * @returns {boolean} Whether or not the passed in node is preceded by a blank newline. - */ - function hasNewlineBefore(node) { - const tokenBefore = sourceCode.getTokenBefore(node, { includeComments: true }); - const tokenLineBefore = tokenBefore ? tokenBefore.loc.end.line : 0; - - return node.loc.start.line - tokenLineBefore >= 2; - } - - /** - * Gets the last token of a node that is on the same line as the rest of the node. - * This will usually be the last token of the node, but it will be the second-to-last token if the node has a trailing - * semicolon on a different line. - * @param {ASTNode} node A directive node - * @returns {Token} The last token of the node on the line - */ - function getLastTokenOnLine(node) { - const lastToken = sourceCode.getLastToken(node); - const secondToLastToken = sourceCode.getTokenBefore(lastToken); - - return astUtils.isSemicolonToken(lastToken) && lastToken.loc.start.line > secondToLastToken.loc.end.line - ? secondToLastToken - : lastToken; - } - - /** - * Check if node is followed by a blank newline. - * @param {ASTNode} node Node to check. - * @returns {boolean} Whether or not the passed in node is followed by a blank newline. - */ - function hasNewlineAfter(node) { - const lastToken = getLastTokenOnLine(node); - const tokenAfter = sourceCode.getTokenAfter(lastToken, { includeComments: true }); - - return tokenAfter.loc.start.line - lastToken.loc.end.line >= 2; - } - - /** - * Report errors for newlines around directives. - * @param {ASTNode} node Node to check. - * @param {string} location Whether the error was found before or after the directive. - * @param {boolean} expected Whether or not a newline was expected or unexpected. - * @returns {void} - */ - function reportError(node, location, expected) { - context.report({ - node, - messageId: expected ? "expected" : "unexpected", - data: { - value: node.expression.value, - location - }, - fix(fixer) { - const lastToken = getLastTokenOnLine(node); - - if (expected) { - return location === "before" ? fixer.insertTextBefore(node, "\n") : fixer.insertTextAfter(lastToken, "\n"); - } - return fixer.removeRange(location === "before" ? [node.range[0] - 1, node.range[0]] : [lastToken.range[1], lastToken.range[1] + 1]); - } - }); - } - - /** - * Check lines around directives in node - * @param {ASTNode} node node to check - * @returns {void} - */ - function checkDirectives(node) { - const directives = astUtils.getDirectivePrologue(node); - - if (!directives.length) { - return; - } - - const firstDirective = directives[0]; - const leadingComments = sourceCode.getCommentsBefore(firstDirective); - - /* - * Only check before the first directive if it is preceded by a comment or if it is at the top of - * the file and expectLineBefore is set to "never". This is to not force a newline at the top of - * the file if there are no comments as well as for compatibility with padded-blocks. - */ - if (leadingComments.length) { - if (expectLineBefore === "always" && !hasNewlineBefore(firstDirective)) { - reportError(firstDirective, "before", true); - } - - if (expectLineBefore === "never" && hasNewlineBefore(firstDirective)) { - reportError(firstDirective, "before", false); - } - } else if ( - node.type === "Program" && - expectLineBefore === "never" && - !leadingComments.length && - hasNewlineBefore(firstDirective) - ) { - reportError(firstDirective, "before", false); - } - - const lastDirective = directives.at(-1); - const statements = node.type === "Program" ? node.body : node.body.body; - - /* - * Do not check after the last directive if the body only - * contains a directive prologue and isn't followed by a comment to ensure - * this rule behaves well with padded-blocks. - */ - if (lastDirective === statements.at(-1) && !lastDirective.trailingComments) { - return; - } - - if (expectLineAfter === "always" && !hasNewlineAfter(lastDirective)) { - reportError(lastDirective, "after", true); - } - - if (expectLineAfter === "never" && hasNewlineAfter(lastDirective)) { - reportError(lastDirective, "after", false); - } - } - - //-------------------------------------------------------------------------- - // Public - //-------------------------------------------------------------------------- - - return { - Program: checkDirectives, - FunctionDeclaration: checkDirectives, - FunctionExpression: checkDirectives, - ArrowFunctionExpression: checkDirectives - }; - } -}; diff --git a/tools/eslint/node_modules/eslint/lib/rules/lines-between-class-members.js b/tools/eslint/node_modules/eslint/lib/rules/lines-between-class-members.js deleted file mode 100644 index 5f36d468dc0963..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/rules/lines-between-class-members.js +++ /dev/null @@ -1,269 +0,0 @@ -/** - * @fileoverview Rule to check empty newline between class members - * @author ่–›ๅฎš่ฐ”็š„็Œซ - * @deprecated in ESLint v8.53.0 - */ -"use strict"; - -//------------------------------------------------------------------------------ -// Requirements -//------------------------------------------------------------------------------ - -const astUtils = require("./utils/ast-utils"); - -//------------------------------------------------------------------------------ -// Helpers -//------------------------------------------------------------------------------ - -/** - * Types of class members. - * Those have `test` method to check it matches to the given class member. - * @private - */ -const ClassMemberTypes = { - "*": { test: () => true }, - field: { test: node => node.type === "PropertyDefinition" }, - method: { test: node => node.type === "MethodDefinition" } -}; - -//------------------------------------------------------------------------------ -// Rule Definition -//------------------------------------------------------------------------------ - -/** @type {import('../shared/types').Rule} */ -module.exports = { - meta: { - deprecated: true, - replacedBy: [], - type: "layout", - - docs: { - description: "Require or disallow an empty line between class members", - recommended: false, - url: "https://eslint.org/docs/latest/rules/lines-between-class-members" - }, - - fixable: "whitespace", - - schema: [ - { - anyOf: [ - { - type: "object", - properties: { - enforce: { - type: "array", - items: { - type: "object", - properties: { - blankLine: { enum: ["always", "never"] }, - prev: { enum: ["method", "field", "*"] }, - next: { enum: ["method", "field", "*"] } - }, - additionalProperties: false, - required: ["blankLine", "prev", "next"] - }, - minItems: 1 - } - }, - additionalProperties: false, - required: ["enforce"] - }, - { - enum: ["always", "never"] - } - ] - }, - { - type: "object", - properties: { - exceptAfterSingleLine: { - type: "boolean", - default: false - } - }, - additionalProperties: false - } - ], - messages: { - never: "Unexpected blank line between class members.", - always: "Expected blank line between class members." - } - }, - - create(context) { - - const options = []; - - options[0] = context.options[0] || "always"; - options[1] = context.options[1] || { exceptAfterSingleLine: false }; - - const configureList = typeof options[0] === "object" ? options[0].enforce : [{ blankLine: options[0], prev: "*", next: "*" }]; - const sourceCode = context.sourceCode; - - /** - * Gets a pair of tokens that should be used to check lines between two class member nodes. - * - * In most cases, this returns the very last token of the current node and - * the very first token of the next node. - * For example: - * - * class C { - * x = 1; // curLast: `;` nextFirst: `in` - * in = 2 - * } - * - * There is only one exception. If the given node ends with a semicolon, and it looks like - * a semicolon-less style's semicolon - one that is not on the same line as the preceding - * token, but is on the line where the next class member starts - this returns the preceding - * token and the semicolon as boundary tokens. - * For example: - * - * class C { - * x = 1 // curLast: `1` nextFirst: `;` - * ;in = 2 - * } - * When determining the desired layout of the code, we should treat this semicolon as - * a part of the next class member node instead of the one it technically belongs to. - * @param {ASTNode} curNode Current class member node. - * @param {ASTNode} nextNode Next class member node. - * @returns {Token} The actual last token of `node`. - * @private - */ - function getBoundaryTokens(curNode, nextNode) { - const lastToken = sourceCode.getLastToken(curNode); - const prevToken = sourceCode.getTokenBefore(lastToken); - const nextToken = sourceCode.getFirstToken(nextNode); // skip possible lone `;` between nodes - - const isSemicolonLessStyle = ( - astUtils.isSemicolonToken(lastToken) && - !astUtils.isTokenOnSameLine(prevToken, lastToken) && - astUtils.isTokenOnSameLine(lastToken, nextToken) - ); - - return isSemicolonLessStyle - ? { curLast: prevToken, nextFirst: lastToken } - : { curLast: lastToken, nextFirst: nextToken }; - } - - /** - * Return the last token among the consecutive tokens that have no exceed max line difference in between, before the first token in the next member. - * @param {Token} prevLastToken The last token in the previous member node. - * @param {Token} nextFirstToken The first token in the next member node. - * @param {number} maxLine The maximum number of allowed line difference between consecutive tokens. - * @returns {Token} The last token among the consecutive tokens. - */ - function findLastConsecutiveTokenAfter(prevLastToken, nextFirstToken, maxLine) { - const after = sourceCode.getTokenAfter(prevLastToken, { includeComments: true }); - - if (after !== nextFirstToken && after.loc.start.line - prevLastToken.loc.end.line <= maxLine) { - return findLastConsecutiveTokenAfter(after, nextFirstToken, maxLine); - } - return prevLastToken; - } - - /** - * Return the first token among the consecutive tokens that have no exceed max line difference in between, after the last token in the previous member. - * @param {Token} nextFirstToken The first token in the next member node. - * @param {Token} prevLastToken The last token in the previous member node. - * @param {number} maxLine The maximum number of allowed line difference between consecutive tokens. - * @returns {Token} The first token among the consecutive tokens. - */ - function findFirstConsecutiveTokenBefore(nextFirstToken, prevLastToken, maxLine) { - const before = sourceCode.getTokenBefore(nextFirstToken, { includeComments: true }); - - if (before !== prevLastToken && nextFirstToken.loc.start.line - before.loc.end.line <= maxLine) { - return findFirstConsecutiveTokenBefore(before, prevLastToken, maxLine); - } - return nextFirstToken; - } - - /** - * Checks if there is a token or comment between two tokens. - * @param {Token} before The token before. - * @param {Token} after The token after. - * @returns {boolean} True if there is a token or comment between two tokens. - */ - function hasTokenOrCommentBetween(before, after) { - return sourceCode.getTokensBetween(before, after, { includeComments: true }).length !== 0; - } - - /** - * Checks whether the given node matches the given type. - * @param {ASTNode} node The class member node to check. - * @param {string} type The class member type to check. - * @returns {boolean} `true` if the class member node matched the type. - * @private - */ - function match(node, type) { - return ClassMemberTypes[type].test(node); - } - - /** - * Finds the last matched configuration from the configureList. - * @param {ASTNode} prevNode The previous node to match. - * @param {ASTNode} nextNode The current node to match. - * @returns {string|null} Padding type or `null` if no matches were found. - * @private - */ - function getPaddingType(prevNode, nextNode) { - for (let i = configureList.length - 1; i >= 0; --i) { - const configure = configureList[i]; - const matched = - match(prevNode, configure.prev) && - match(nextNode, configure.next); - - if (matched) { - return configure.blankLine; - } - } - return null; - } - - return { - ClassBody(node) { - const body = node.body; - - for (let i = 0; i < body.length - 1; i++) { - const curFirst = sourceCode.getFirstToken(body[i]); - const { curLast, nextFirst } = getBoundaryTokens(body[i], body[i + 1]); - const isMulti = !astUtils.isTokenOnSameLine(curFirst, curLast); - const skip = !isMulti && options[1].exceptAfterSingleLine; - const beforePadding = findLastConsecutiveTokenAfter(curLast, nextFirst, 1); - const afterPadding = findFirstConsecutiveTokenBefore(nextFirst, curLast, 1); - const isPadded = afterPadding.loc.start.line - beforePadding.loc.end.line > 1; - const hasTokenInPadding = hasTokenOrCommentBetween(beforePadding, afterPadding); - const curLineLastToken = findLastConsecutiveTokenAfter(curLast, nextFirst, 0); - const paddingType = getPaddingType(body[i], body[i + 1]); - - if (paddingType === "never" && isPadded) { - context.report({ - node: body[i + 1], - messageId: "never", - - fix(fixer) { - if (hasTokenInPadding) { - return null; - } - return fixer.replaceTextRange([beforePadding.range[1], afterPadding.range[0]], "\n"); - } - }); - } else if (paddingType === "always" && !skip && !isPadded) { - context.report({ - node: body[i + 1], - messageId: "always", - - fix(fixer) { - if (hasTokenInPadding) { - return null; - } - return fixer.insertTextAfter(curLineLastToken, "\n"); - } - }); - } - - } - } - }; - } -}; diff --git a/tools/eslint/node_modules/eslint/lib/rules/logical-assignment-operators.js b/tools/eslint/node_modules/eslint/lib/rules/logical-assignment-operators.js deleted file mode 100644 index c084c04c8eda08..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/rules/logical-assignment-operators.js +++ /dev/null @@ -1,504 +0,0 @@ -/** - * @fileoverview Rule to replace assignment expressions with logical operator assignment - * @author Daniel Martens - */ -"use strict"; - -//------------------------------------------------------------------------------ -// Requirements -//------------------------------------------------------------------------------ -const astUtils = require("./utils/ast-utils.js"); - -//------------------------------------------------------------------------------ -// Helpers -//------------------------------------------------------------------------------ - -const baseTypes = new Set(["Identifier", "Super", "ThisExpression"]); - -/** - * Returns true iff either "undefined" or a void expression (eg. "void 0") - * @param {ASTNode} expression Expression to check - * @param {import('eslint-scope').Scope} scope Scope of the expression - * @returns {boolean} True iff "undefined" or "void ..." - */ -function isUndefined(expression, scope) { - if (expression.type === "Identifier" && expression.name === "undefined") { - return astUtils.isReferenceToGlobalVariable(scope, expression); - } - - return expression.type === "UnaryExpression" && - expression.operator === "void" && - expression.argument.type === "Literal" && - expression.argument.value === 0; -} - -/** - * Returns true iff the reference is either an identifier or member expression - * @param {ASTNode} expression Expression to check - * @returns {boolean} True for identifiers and member expressions - */ -function isReference(expression) { - return (expression.type === "Identifier" && expression.name !== "undefined") || - expression.type === "MemberExpression"; -} - -/** - * Returns true iff the expression checks for nullish with loose equals. - * Examples: value == null, value == void 0 - * @param {ASTNode} expression Test condition - * @param {import('eslint-scope').Scope} scope Scope of the expression - * @returns {boolean} True iff implicit nullish comparison - */ -function isImplicitNullishComparison(expression, scope) { - if (expression.type !== "BinaryExpression" || expression.operator !== "==") { - return false; - } - - const reference = isReference(expression.left) ? "left" : "right"; - const nullish = reference === "left" ? "right" : "left"; - - return isReference(expression[reference]) && - (astUtils.isNullLiteral(expression[nullish]) || isUndefined(expression[nullish], scope)); -} - -/** - * Condition with two equal comparisons. - * @param {ASTNode} expression Condition - * @returns {boolean} True iff matches ? === ? || ? === ? - */ -function isDoubleComparison(expression) { - return expression.type === "LogicalExpression" && - expression.operator === "||" && - expression.left.type === "BinaryExpression" && - expression.left.operator === "===" && - expression.right.type === "BinaryExpression" && - expression.right.operator === "==="; -} - -/** - * Returns true iff the expression checks for undefined and null. - * Example: value === null || value === undefined - * @param {ASTNode} expression Test condition - * @param {import('eslint-scope').Scope} scope Scope of the expression - * @returns {boolean} True iff explicit nullish comparison - */ -function isExplicitNullishComparison(expression, scope) { - if (!isDoubleComparison(expression)) { - return false; - } - const leftReference = isReference(expression.left.left) ? "left" : "right"; - const leftNullish = leftReference === "left" ? "right" : "left"; - const rightReference = isReference(expression.right.left) ? "left" : "right"; - const rightNullish = rightReference === "left" ? "right" : "left"; - - return astUtils.isSameReference(expression.left[leftReference], expression.right[rightReference]) && - ((astUtils.isNullLiteral(expression.left[leftNullish]) && isUndefined(expression.right[rightNullish], scope)) || - (isUndefined(expression.left[leftNullish], scope) && astUtils.isNullLiteral(expression.right[rightNullish]))); -} - -/** - * Returns true for Boolean(arg) calls - * @param {ASTNode} expression Test condition - * @param {import('eslint-scope').Scope} scope Scope of the expression - * @returns {boolean} Whether the expression is a boolean cast - */ -function isBooleanCast(expression, scope) { - return expression.type === "CallExpression" && - expression.callee.name === "Boolean" && - expression.arguments.length === 1 && - astUtils.isReferenceToGlobalVariable(scope, expression.callee); -} - -/** - * Returns true for: - * truthiness checks: value, Boolean(value), !!value - * falsiness checks: !value, !Boolean(value) - * nullish checks: value == null, value === undefined || value === null - * @param {ASTNode} expression Test condition - * @param {import('eslint-scope').Scope} scope Scope of the expression - * @returns {?{ reference: ASTNode, operator: '??'|'||'|'&&'}} Null if not a known existence - */ -function getExistence(expression, scope) { - const isNegated = expression.type === "UnaryExpression" && expression.operator === "!"; - const base = isNegated ? expression.argument : expression; - - switch (true) { - case isReference(base): - return { reference: base, operator: isNegated ? "||" : "&&" }; - case base.type === "UnaryExpression" && base.operator === "!" && isReference(base.argument): - return { reference: base.argument, operator: "&&" }; - case isBooleanCast(base, scope) && isReference(base.arguments[0]): - return { reference: base.arguments[0], operator: isNegated ? "||" : "&&" }; - case isImplicitNullishComparison(expression, scope): - return { reference: isReference(expression.left) ? expression.left : expression.right, operator: "??" }; - case isExplicitNullishComparison(expression, scope): - return { reference: isReference(expression.left.left) ? expression.left.left : expression.left.right, operator: "??" }; - default: return null; - } -} - -/** - * Returns true iff the node is inside a with block - * @param {ASTNode} node Node to check - * @returns {boolean} True iff passed node is inside a with block - */ -function isInsideWithBlock(node) { - if (node.type === "Program") { - return false; - } - - return node.parent.type === "WithStatement" && node.parent.body === node ? true : isInsideWithBlock(node.parent); -} - -/** - * Gets the leftmost operand of a consecutive logical expression. - * @param {SourceCode} sourceCode The ESLint source code object - * @param {LogicalExpression} node LogicalExpression - * @returns {Expression} Leftmost operand - */ -function getLeftmostOperand(sourceCode, node) { - let left = node.left; - - while (left.type === "LogicalExpression" && left.operator === node.operator) { - - if (astUtils.isParenthesised(sourceCode, left)) { - - /* - * It should have associativity, - * but ignore it if use parentheses to make the evaluation order clear. - */ - return left; - } - left = left.left; - } - return left; - -} - -//------------------------------------------------------------------------------ -// Rule Definition -//------------------------------------------------------------------------------ -/** @type {import('../shared/types').Rule} */ -module.exports = { - meta: { - type: "suggestion", - - docs: { - description: "Require or disallow logical assignment operator shorthand", - recommended: false, - url: "https://eslint.org/docs/latest/rules/logical-assignment-operators" - }, - - schema: { - type: "array", - oneOf: [{ - items: [ - { const: "always" }, - { - type: "object", - properties: { - enforceForIfStatements: { - type: "boolean" - } - }, - additionalProperties: false - } - ], - minItems: 0, // 0 for allowing passing no options - maxItems: 2 - }, { - items: [{ const: "never" }], - minItems: 1, - maxItems: 1 - }] - }, - fixable: "code", - hasSuggestions: true, - messages: { - assignment: "Assignment (=) can be replaced with operator assignment ({{operator}}).", - useLogicalOperator: "Convert this assignment to use the operator {{ operator }}.", - logical: "Logical expression can be replaced with an assignment ({{ operator }}).", - convertLogical: "Replace this logical expression with an assignment with the operator {{ operator }}.", - if: "'if' statement can be replaced with a logical operator assignment with operator {{ operator }}.", - convertIf: "Replace this 'if' statement with a logical assignment with operator {{ operator }}.", - unexpected: "Unexpected logical operator assignment ({{operator}}) shorthand.", - separate: "Separate the logical assignment into an assignment with a logical operator." - } - }, - - create(context) { - const mode = context.options[0] === "never" ? "never" : "always"; - const checkIf = mode === "always" && context.options.length > 1 && context.options[1].enforceForIfStatements; - const sourceCode = context.sourceCode; - const isStrict = sourceCode.getScope(sourceCode.ast).isStrict; - - /** - * Returns false if the access could be a getter - * @param {ASTNode} node Assignment expression - * @returns {boolean} True iff the fix is safe - */ - function cannotBeGetter(node) { - return node.type === "Identifier" && - (isStrict || !isInsideWithBlock(node)); - } - - /** - * Check whether only a single property is accessed - * @param {ASTNode} node reference - * @returns {boolean} True iff a single property is accessed - */ - function accessesSingleProperty(node) { - if (!isStrict && isInsideWithBlock(node)) { - return node.type === "Identifier"; - } - - return node.type === "MemberExpression" && - baseTypes.has(node.object.type) && - (!node.computed || (node.property.type !== "MemberExpression" && node.property.type !== "ChainExpression")); - } - - /** - * Adds a fixer or suggestion whether on the fix is safe. - * @param {{ messageId: string, node: ASTNode }} descriptor Report descriptor without fix or suggest - * @param {{ messageId: string, fix: Function }} suggestion Adds the fix or the whole suggestion as only element in "suggest" to suggestion - * @param {boolean} shouldBeFixed Fix iff the condition is true - * @returns {Object} Descriptor with either an added fix or suggestion - */ - function createConditionalFixer(descriptor, suggestion, shouldBeFixed) { - if (shouldBeFixed) { - return { - ...descriptor, - fix: suggestion.fix - }; - } - - return { - ...descriptor, - suggest: [suggestion] - }; - } - - - /** - * Returns the operator token for assignments and binary expressions - * @param {ASTNode} node AssignmentExpression or BinaryExpression - * @returns {import('eslint').AST.Token} Operator token between the left and right expression - */ - function getOperatorToken(node) { - return sourceCode.getFirstTokenBetween(node.left, node.right, token => token.value === node.operator); - } - - if (mode === "never") { - return { - - // foo ||= bar - "AssignmentExpression"(assignment) { - if (!astUtils.isLogicalAssignmentOperator(assignment.operator)) { - return; - } - - const descriptor = { - messageId: "unexpected", - node: assignment, - data: { operator: assignment.operator } - }; - const suggestion = { - messageId: "separate", - *fix(ruleFixer) { - if (sourceCode.getCommentsInside(assignment).length > 0) { - return; - } - - const operatorToken = getOperatorToken(assignment); - - // -> foo = bar - yield ruleFixer.replaceText(operatorToken, "="); - - const assignmentText = sourceCode.getText(assignment.left); - const operator = assignment.operator.slice(0, -1); - - // -> foo = foo || bar - yield ruleFixer.insertTextAfter(operatorToken, ` ${assignmentText} ${operator}`); - - const precedence = astUtils.getPrecedence(assignment.right) <= astUtils.getPrecedence({ type: "LogicalExpression", operator }); - - // ?? and || / && cannot be mixed but have same precedence - const mixed = assignment.operator === "??=" && astUtils.isLogicalExpression(assignment.right); - - if (!astUtils.isParenthesised(sourceCode, assignment.right) && (precedence || mixed)) { - - // -> foo = foo || (bar) - yield ruleFixer.insertTextBefore(assignment.right, "("); - yield ruleFixer.insertTextAfter(assignment.right, ")"); - } - } - }; - - context.report(createConditionalFixer(descriptor, suggestion, cannotBeGetter(assignment.left))); - } - }; - } - - return { - - // foo = foo || bar - "AssignmentExpression[operator='='][right.type='LogicalExpression']"(assignment) { - const leftOperand = getLeftmostOperand(sourceCode, assignment.right); - - if (!astUtils.isSameReference(assignment.left, leftOperand) - ) { - return; - } - - const descriptor = { - messageId: "assignment", - node: assignment, - data: { operator: `${assignment.right.operator}=` } - }; - const suggestion = { - messageId: "useLogicalOperator", - data: { operator: `${assignment.right.operator}=` }, - *fix(ruleFixer) { - if (sourceCode.getCommentsInside(assignment).length > 0) { - return; - } - - // No need for parenthesis around the assignment based on precedence as the precedence stays the same even with changed operator - const assignmentOperatorToken = getOperatorToken(assignment); - - // -> foo ||= foo || bar - yield ruleFixer.insertTextBefore(assignmentOperatorToken, assignment.right.operator); - - // -> foo ||= bar - const logicalOperatorToken = getOperatorToken(leftOperand.parent); - const firstRightOperandToken = sourceCode.getTokenAfter(logicalOperatorToken); - - yield ruleFixer.removeRange([leftOperand.parent.range[0], firstRightOperandToken.range[0]]); - } - }; - - context.report(createConditionalFixer(descriptor, suggestion, cannotBeGetter(assignment.left))); - }, - - // foo || (foo = bar) - 'LogicalExpression[right.type="AssignmentExpression"][right.operator="="]'(logical) { - - // Right side has to be parenthesized, otherwise would be parsed as (foo || foo) = bar which is illegal - if (isReference(logical.left) && astUtils.isSameReference(logical.left, logical.right.left)) { - const descriptor = { - messageId: "logical", - node: logical, - data: { operator: `${logical.operator}=` } - }; - const suggestion = { - messageId: "convertLogical", - data: { operator: `${logical.operator}=` }, - *fix(ruleFixer) { - if (sourceCode.getCommentsInside(logical).length > 0) { - return; - } - - const parentPrecedence = astUtils.getPrecedence(logical.parent); - const requiresOuterParenthesis = logical.parent.type !== "ExpressionStatement" && ( - parentPrecedence === -1 || - astUtils.getPrecedence({ type: "AssignmentExpression" }) < parentPrecedence - ); - - if (!astUtils.isParenthesised(sourceCode, logical) && requiresOuterParenthesis) { - yield ruleFixer.insertTextBefore(logical, "("); - yield ruleFixer.insertTextAfter(logical, ")"); - } - - // Also removes all opening parenthesis - yield ruleFixer.removeRange([logical.range[0], logical.right.range[0]]); // -> foo = bar) - - // Also removes all ending parenthesis - yield ruleFixer.removeRange([logical.right.range[1], logical.range[1]]); // -> foo = bar - - const operatorToken = getOperatorToken(logical.right); - - yield ruleFixer.insertTextBefore(operatorToken, logical.operator); // -> foo ||= bar - } - }; - const fix = cannotBeGetter(logical.left) || accessesSingleProperty(logical.left); - - context.report(createConditionalFixer(descriptor, suggestion, fix)); - } - }, - - // if (foo) foo = bar - "IfStatement[alternate=null]"(ifNode) { - if (!checkIf) { - return; - } - - const hasBody = ifNode.consequent.type === "BlockStatement"; - - if (hasBody && ifNode.consequent.body.length !== 1) { - return; - } - - const body = hasBody ? ifNode.consequent.body[0] : ifNode.consequent; - const scope = sourceCode.getScope(ifNode); - const existence = getExistence(ifNode.test, scope); - - if ( - body.type === "ExpressionStatement" && - body.expression.type === "AssignmentExpression" && - body.expression.operator === "=" && - existence !== null && - astUtils.isSameReference(existence.reference, body.expression.left) - ) { - const descriptor = { - messageId: "if", - node: ifNode, - data: { operator: `${existence.operator}=` } - }; - const suggestion = { - messageId: "convertIf", - data: { operator: `${existence.operator}=` }, - *fix(ruleFixer) { - if (sourceCode.getCommentsInside(ifNode).length > 0) { - return; - } - - const firstBodyToken = sourceCode.getFirstToken(body); - const prevToken = sourceCode.getTokenBefore(ifNode); - - if ( - prevToken !== null && - prevToken.value !== ";" && - prevToken.value !== "{" && - firstBodyToken.type !== "Identifier" && - firstBodyToken.type !== "Keyword" - ) { - - // Do not fix if the fixed statement could be part of the previous statement (eg. fn() if (a == null) (a) = b --> fn()(a) ??= b) - return; - } - - - const operatorToken = getOperatorToken(body.expression); - - yield ruleFixer.insertTextBefore(operatorToken, existence.operator); // -> if (foo) foo ||= bar - - yield ruleFixer.removeRange([ifNode.range[0], body.range[0]]); // -> foo ||= bar - - yield ruleFixer.removeRange([body.range[1], ifNode.range[1]]); // -> foo ||= bar, only present if "if" had a body - - const nextToken = sourceCode.getTokenAfter(body.expression); - - if (hasBody && (nextToken !== null && nextToken.value !== ";")) { - yield ruleFixer.insertTextAfter(ifNode, ";"); - } - } - }; - const shouldBeFixed = cannotBeGetter(existence.reference) || - (ifNode.test.type !== "LogicalExpression" && accessesSingleProperty(existence.reference)); - - context.report(createConditionalFixer(descriptor, suggestion, shouldBeFixed)); - } - } - }; - } -}; diff --git a/tools/eslint/node_modules/eslint/lib/rules/max-classes-per-file.js b/tools/eslint/node_modules/eslint/lib/rules/max-classes-per-file.js deleted file mode 100644 index 241e06023e4b95..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/rules/max-classes-per-file.js +++ /dev/null @@ -1,89 +0,0 @@ -/** - * @fileoverview Enforce a maximum number of classes per file - * @author James Garbutt - */ -"use strict"; - -//------------------------------------------------------------------------------ -// Requirements -//------------------------------------------------------------------------------ - - -//------------------------------------------------------------------------------ -// Rule Definition -//------------------------------------------------------------------------------ - -/** @type {import('../shared/types').Rule} */ -module.exports = { - meta: { - type: "suggestion", - - docs: { - description: "Enforce a maximum number of classes per file", - recommended: false, - url: "https://eslint.org/docs/latest/rules/max-classes-per-file" - }, - - schema: [ - { - oneOf: [ - { - type: "integer", - minimum: 1 - }, - { - type: "object", - properties: { - ignoreExpressions: { - type: "boolean" - }, - max: { - type: "integer", - minimum: 1 - } - }, - additionalProperties: false - } - ] - } - ], - - messages: { - maximumExceeded: "File has too many classes ({{ classCount }}). Maximum allowed is {{ max }}." - } - }, - create(context) { - const [option = {}] = context.options; - const [ignoreExpressions, max] = typeof option === "number" - ? [false, option || 1] - : [option.ignoreExpressions, option.max || 1]; - - let classCount = 0; - - return { - Program() { - classCount = 0; - }, - "Program:exit"(node) { - if (classCount > max) { - context.report({ - node, - messageId: "maximumExceeded", - data: { - classCount, - max - } - }); - } - }, - "ClassDeclaration"() { - classCount++; - }, - "ClassExpression"() { - if (!ignoreExpressions) { - classCount++; - } - } - }; - } -}; diff --git a/tools/eslint/node_modules/eslint/lib/rules/max-depth.js b/tools/eslint/node_modules/eslint/lib/rules/max-depth.js deleted file mode 100644 index e92c6b4acdd649..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/rules/max-depth.js +++ /dev/null @@ -1,156 +0,0 @@ -/** - * @fileoverview A rule to set the maximum depth block can be nested in a function. - * @author Ian Christian Myers - */ - -"use strict"; - -//------------------------------------------------------------------------------ -// Rule Definition -//------------------------------------------------------------------------------ - -/** @type {import('../shared/types').Rule} */ -module.exports = { - meta: { - type: "suggestion", - - docs: { - description: "Enforce a maximum depth that blocks can be nested", - recommended: false, - url: "https://eslint.org/docs/latest/rules/max-depth" - }, - - schema: [ - { - oneOf: [ - { - type: "integer", - minimum: 0 - }, - { - type: "object", - properties: { - maximum: { - type: "integer", - minimum: 0 - }, - max: { - type: "integer", - minimum: 0 - } - }, - additionalProperties: false - } - ] - } - ], - messages: { - tooDeeply: "Blocks are nested too deeply ({{depth}}). Maximum allowed is {{maxDepth}}." - } - }, - - create(context) { - - //-------------------------------------------------------------------------- - // Helpers - //-------------------------------------------------------------------------- - - const functionStack = [], - option = context.options[0]; - let maxDepth = 4; - - if ( - typeof option === "object" && - (Object.hasOwn(option, "maximum") || Object.hasOwn(option, "max")) - ) { - maxDepth = option.maximum || option.max; - } - if (typeof option === "number") { - maxDepth = option; - } - - /** - * When parsing a new function, store it in our function stack - * @returns {void} - * @private - */ - function startFunction() { - functionStack.push(0); - } - - /** - * When parsing is done then pop out the reference - * @returns {void} - * @private - */ - function endFunction() { - functionStack.pop(); - } - - /** - * Save the block and Evaluate the node - * @param {ASTNode} node node to evaluate - * @returns {void} - * @private - */ - function pushBlock(node) { - const len = ++functionStack[functionStack.length - 1]; - - if (len > maxDepth) { - context.report({ node, messageId: "tooDeeply", data: { depth: len, maxDepth } }); - } - } - - /** - * Pop the saved block - * @returns {void} - * @private - */ - function popBlock() { - functionStack[functionStack.length - 1]--; - } - - //-------------------------------------------------------------------------- - // Public API - //-------------------------------------------------------------------------- - - return { - Program: startFunction, - FunctionDeclaration: startFunction, - FunctionExpression: startFunction, - ArrowFunctionExpression: startFunction, - StaticBlock: startFunction, - - IfStatement(node) { - if (node.parent.type !== "IfStatement") { - pushBlock(node); - } - }, - SwitchStatement: pushBlock, - TryStatement: pushBlock, - DoWhileStatement: pushBlock, - WhileStatement: pushBlock, - WithStatement: pushBlock, - ForStatement: pushBlock, - ForInStatement: pushBlock, - ForOfStatement: pushBlock, - - "IfStatement:exit": popBlock, - "SwitchStatement:exit": popBlock, - "TryStatement:exit": popBlock, - "DoWhileStatement:exit": popBlock, - "WhileStatement:exit": popBlock, - "WithStatement:exit": popBlock, - "ForStatement:exit": popBlock, - "ForInStatement:exit": popBlock, - "ForOfStatement:exit": popBlock, - - "FunctionDeclaration:exit": endFunction, - "FunctionExpression:exit": endFunction, - "ArrowFunctionExpression:exit": endFunction, - "StaticBlock:exit": endFunction, - "Program:exit": endFunction - }; - - } -}; diff --git a/tools/eslint/node_modules/eslint/lib/rules/max-len.js b/tools/eslint/node_modules/eslint/lib/rules/max-len.js deleted file mode 100644 index 15910d5d95d118..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/rules/max-len.js +++ /dev/null @@ -1,440 +0,0 @@ -/** - * @fileoverview Rule to check for max length on a line. - * @author Matt DuVall - * @deprecated in ESLint v8.53.0 - */ - -"use strict"; - -//------------------------------------------------------------------------------ -// Constants -//------------------------------------------------------------------------------ - -const OPTIONS_SCHEMA = { - type: "object", - properties: { - code: { - type: "integer", - minimum: 0 - }, - comments: { - type: "integer", - minimum: 0 - }, - tabWidth: { - type: "integer", - minimum: 0 - }, - ignorePattern: { - type: "string" - }, - ignoreComments: { - type: "boolean" - }, - ignoreStrings: { - type: "boolean" - }, - ignoreUrls: { - type: "boolean" - }, - ignoreTemplateLiterals: { - type: "boolean" - }, - ignoreRegExpLiterals: { - type: "boolean" - }, - ignoreTrailingComments: { - type: "boolean" - } - }, - additionalProperties: false -}; - -const OPTIONS_OR_INTEGER_SCHEMA = { - anyOf: [ - OPTIONS_SCHEMA, - { - type: "integer", - minimum: 0 - } - ] -}; - -//------------------------------------------------------------------------------ -// Rule Definition -//------------------------------------------------------------------------------ - -/** @type {import('../shared/types').Rule} */ -module.exports = { - meta: { - deprecated: true, - replacedBy: [], - type: "layout", - - docs: { - description: "Enforce a maximum line length", - recommended: false, - url: "https://eslint.org/docs/latest/rules/max-len" - }, - - schema: [ - OPTIONS_OR_INTEGER_SCHEMA, - OPTIONS_OR_INTEGER_SCHEMA, - OPTIONS_SCHEMA - ], - messages: { - max: "This line has a length of {{lineLength}}. Maximum allowed is {{maxLength}}.", - maxComment: "This line has a comment length of {{lineLength}}. Maximum allowed is {{maxCommentLength}}." - } - }, - - create(context) { - - /* - * Inspired by http://tools.ietf.org/html/rfc3986#appendix-B, however: - * - They're matching an entire string that we know is a URI - * - We're matching part of a string where we think there *might* be a URL - * - We're only concerned about URLs, as picking out any URI would cause - * too many false positives - * - We don't care about matching the entire URL, any small segment is fine - */ - const URL_REGEXP = /[^:/?#]:\/\/[^?#]/u; - - const sourceCode = context.sourceCode; - - /** - * Computes the length of a line that may contain tabs. The width of each - * tab will be the number of spaces to the next tab stop. - * @param {string} line The line. - * @param {int} tabWidth The width of each tab stop in spaces. - * @returns {int} The computed line length. - * @private - */ - function computeLineLength(line, tabWidth) { - let extraCharacterCount = 0; - - line.replace(/\t/gu, (match, offset) => { - const totalOffset = offset + extraCharacterCount, - previousTabStopOffset = tabWidth ? totalOffset % tabWidth : 0, - spaceCount = tabWidth - previousTabStopOffset; - - extraCharacterCount += spaceCount - 1; // -1 for the replaced tab - }); - return Array.from(line).length + extraCharacterCount; - } - - // The options object must be the last option specifiedโ€ฆ - const options = Object.assign({}, context.options.at(-1)); - - // โ€ฆbut max code lengthโ€ฆ - if (typeof context.options[0] === "number") { - options.code = context.options[0]; - } - - // โ€ฆand tabWidth can be optionally specified directly as integers. - if (typeof context.options[1] === "number") { - options.tabWidth = context.options[1]; - } - - const maxLength = typeof options.code === "number" ? options.code : 80, - tabWidth = typeof options.tabWidth === "number" ? options.tabWidth : 4, - ignoreComments = !!options.ignoreComments, - ignoreStrings = !!options.ignoreStrings, - ignoreTemplateLiterals = !!options.ignoreTemplateLiterals, - ignoreRegExpLiterals = !!options.ignoreRegExpLiterals, - ignoreTrailingComments = !!options.ignoreTrailingComments || !!options.ignoreComments, - ignoreUrls = !!options.ignoreUrls, - maxCommentLength = options.comments; - let ignorePattern = options.ignorePattern || null; - - if (ignorePattern) { - ignorePattern = new RegExp(ignorePattern, "u"); - } - - //-------------------------------------------------------------------------- - // Helpers - //-------------------------------------------------------------------------- - - /** - * Tells if a given comment is trailing: it starts on the current line and - * extends to or past the end of the current line. - * @param {string} line The source line we want to check for a trailing comment on - * @param {number} lineNumber The one-indexed line number for line - * @param {ASTNode} comment The comment to inspect - * @returns {boolean} If the comment is trailing on the given line - */ - function isTrailingComment(line, lineNumber, comment) { - return comment && - (comment.loc.start.line === lineNumber && lineNumber <= comment.loc.end.line) && - (comment.loc.end.line > lineNumber || comment.loc.end.column === line.length); - } - - /** - * Tells if a comment encompasses the entire line. - * @param {string} line The source line with a trailing comment - * @param {number} lineNumber The one-indexed line number this is on - * @param {ASTNode} comment The comment to remove - * @returns {boolean} If the comment covers the entire line - */ - function isFullLineComment(line, lineNumber, comment) { - const start = comment.loc.start, - end = comment.loc.end, - isFirstTokenOnLine = !line.slice(0, comment.loc.start.column).trim(); - - return comment && - (start.line < lineNumber || (start.line === lineNumber && isFirstTokenOnLine)) && - (end.line > lineNumber || (end.line === lineNumber && end.column === line.length)); - } - - /** - * Check if a node is a JSXEmptyExpression contained in a single line JSXExpressionContainer. - * @param {ASTNode} node A node to check. - * @returns {boolean} True if the node is a JSXEmptyExpression contained in a single line JSXExpressionContainer. - */ - function isJSXEmptyExpressionInSingleLineContainer(node) { - if (!node || !node.parent || node.type !== "JSXEmptyExpression" || node.parent.type !== "JSXExpressionContainer") { - return false; - } - - const parent = node.parent; - - return parent.loc.start.line === parent.loc.end.line; - } - - /** - * Gets the line after the comment and any remaining trailing whitespace is - * stripped. - * @param {string} line The source line with a trailing comment - * @param {ASTNode} comment The comment to remove - * @returns {string} Line without comment and trailing whitespace - */ - function stripTrailingComment(line, comment) { - - // loc.column is zero-indexed - return line.slice(0, comment.loc.start.column).replace(/\s+$/u, ""); - } - - /** - * Ensure that an array exists at [key] on `object`, and add `value` to it. - * @param {Object} object the object to mutate - * @param {string} key the object's key - * @param {any} value the value to add - * @returns {void} - * @private - */ - function ensureArrayAndPush(object, key, value) { - if (!Array.isArray(object[key])) { - object[key] = []; - } - object[key].push(value); - } - - /** - * Retrieves an array containing all strings (" or ') in the source code. - * @returns {ASTNode[]} An array of string nodes. - */ - function getAllStrings() { - return sourceCode.ast.tokens.filter(token => (token.type === "String" || - (token.type === "JSXText" && sourceCode.getNodeByRangeIndex(token.range[0] - 1).type === "JSXAttribute"))); - } - - /** - * Retrieves an array containing all template literals in the source code. - * @returns {ASTNode[]} An array of template literal nodes. - */ - function getAllTemplateLiterals() { - return sourceCode.ast.tokens.filter(token => token.type === "Template"); - } - - - /** - * Retrieves an array containing all RegExp literals in the source code. - * @returns {ASTNode[]} An array of RegExp literal nodes. - */ - function getAllRegExpLiterals() { - return sourceCode.ast.tokens.filter(token => token.type === "RegularExpression"); - } - - /** - * - * reduce an array of AST nodes by line number, both start and end. - * @param {ASTNode[]} arr array of AST nodes - * @returns {Object} accululated AST nodes - */ - function groupArrayByLineNumber(arr) { - const obj = {}; - - for (let i = 0; i < arr.length; i++) { - const node = arr[i]; - - for (let j = node.loc.start.line; j <= node.loc.end.line; ++j) { - ensureArrayAndPush(obj, j, node); - } - } - return obj; - } - - /** - * Returns an array of all comments in the source code. - * If the element in the array is a JSXEmptyExpression contained with a single line JSXExpressionContainer, - * the element is changed with JSXExpressionContainer node. - * @returns {ASTNode[]} An array of comment nodes - */ - function getAllComments() { - const comments = []; - - sourceCode.getAllComments() - .forEach(commentNode => { - const containingNode = sourceCode.getNodeByRangeIndex(commentNode.range[0]); - - if (isJSXEmptyExpressionInSingleLineContainer(containingNode)) { - - // push a unique node only - if (comments.at(-1) !== containingNode.parent) { - comments.push(containingNode.parent); - } - } else { - comments.push(commentNode); - } - }); - - return comments; - } - - /** - * Check the program for max length - * @param {ASTNode} node Node to examine - * @returns {void} - * @private - */ - function checkProgramForMaxLength(node) { - - // split (honors line-ending) - const lines = sourceCode.lines, - - // list of comments to ignore - comments = ignoreComments || maxCommentLength || ignoreTrailingComments ? getAllComments() : []; - - // we iterate over comments in parallel with the lines - let commentsIndex = 0; - - const strings = getAllStrings(); - const stringsByLine = groupArrayByLineNumber(strings); - - const templateLiterals = getAllTemplateLiterals(); - const templateLiteralsByLine = groupArrayByLineNumber(templateLiterals); - - const regExpLiterals = getAllRegExpLiterals(); - const regExpLiteralsByLine = groupArrayByLineNumber(regExpLiterals); - - lines.forEach((line, i) => { - - // i is zero-indexed, line numbers are one-indexed - const lineNumber = i + 1; - - /* - * if we're checking comment length; we need to know whether this - * line is a comment - */ - let lineIsComment = false; - let textToMeasure; - - /* - * We can short-circuit the comment checks if we're already out of - * comments to check. - */ - if (commentsIndex < comments.length) { - let comment; - - // iterate over comments until we find one past the current line - do { - comment = comments[++commentsIndex]; - } while (comment && comment.loc.start.line <= lineNumber); - - // and step back by one - comment = comments[--commentsIndex]; - - if (isFullLineComment(line, lineNumber, comment)) { - lineIsComment = true; - textToMeasure = line; - } else if (ignoreTrailingComments && isTrailingComment(line, lineNumber, comment)) { - textToMeasure = stripTrailingComment(line, comment); - - // ignore multiple trailing comments in the same line - let lastIndex = commentsIndex; - - while (isTrailingComment(textToMeasure, lineNumber, comments[--lastIndex])) { - textToMeasure = stripTrailingComment(textToMeasure, comments[lastIndex]); - } - } else { - textToMeasure = line; - } - } else { - textToMeasure = line; - } - if (ignorePattern && ignorePattern.test(textToMeasure) || - ignoreUrls && URL_REGEXP.test(textToMeasure) || - ignoreStrings && stringsByLine[lineNumber] || - ignoreTemplateLiterals && templateLiteralsByLine[lineNumber] || - ignoreRegExpLiterals && regExpLiteralsByLine[lineNumber] - ) { - - // ignore this line - return; - } - - const lineLength = computeLineLength(textToMeasure, tabWidth); - const commentLengthApplies = lineIsComment && maxCommentLength; - - if (lineIsComment && ignoreComments) { - return; - } - - const loc = { - start: { - line: lineNumber, - column: 0 - }, - end: { - line: lineNumber, - column: textToMeasure.length - } - }; - - if (commentLengthApplies) { - if (lineLength > maxCommentLength) { - context.report({ - node, - loc, - messageId: "maxComment", - data: { - lineLength, - maxCommentLength - } - }); - } - } else if (lineLength > maxLength) { - context.report({ - node, - loc, - messageId: "max", - data: { - lineLength, - maxLength - } - }); - } - }); - } - - - //-------------------------------------------------------------------------- - // Public API - //-------------------------------------------------------------------------- - - return { - Program: checkProgramForMaxLength - }; - - } -}; diff --git a/tools/eslint/node_modules/eslint/lib/rules/max-lines-per-function.js b/tools/eslint/node_modules/eslint/lib/rules/max-lines-per-function.js deleted file mode 100644 index f981922a74ac20..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/rules/max-lines-per-function.js +++ /dev/null @@ -1,213 +0,0 @@ -/** - * @fileoverview A rule to set the maximum number of line of code in a function. - * @author Pete Ward - */ -"use strict"; - -//------------------------------------------------------------------------------ -// Requirements -//------------------------------------------------------------------------------ - -const astUtils = require("./utils/ast-utils"); -const { upperCaseFirst } = require("../shared/string-utils"); - -//------------------------------------------------------------------------------ -// Constants -//------------------------------------------------------------------------------ - -const OPTIONS_SCHEMA = { - type: "object", - properties: { - max: { - type: "integer", - minimum: 0 - }, - skipComments: { - type: "boolean" - }, - skipBlankLines: { - type: "boolean" - }, - IIFEs: { - type: "boolean" - } - }, - additionalProperties: false -}; - -const OPTIONS_OR_INTEGER_SCHEMA = { - oneOf: [ - OPTIONS_SCHEMA, - { - type: "integer", - minimum: 1 - } - ] -}; - -/** - * Given a list of comment nodes, return a map with numeric keys (source code line numbers) and comment token values. - * @param {Array} comments An array of comment nodes. - * @returns {Map} A map with numeric keys (source code line numbers) and comment token values. - */ -function getCommentLineNumbers(comments) { - const map = new Map(); - - comments.forEach(comment => { - for (let i = comment.loc.start.line; i <= comment.loc.end.line; i++) { - map.set(i, comment); - } - }); - return map; -} - -//------------------------------------------------------------------------------ -// Rule Definition -//------------------------------------------------------------------------------ - -/** @type {import('../shared/types').Rule} */ -module.exports = { - meta: { - type: "suggestion", - - docs: { - description: "Enforce a maximum number of lines of code in a function", - recommended: false, - url: "https://eslint.org/docs/latest/rules/max-lines-per-function" - }, - - schema: [ - OPTIONS_OR_INTEGER_SCHEMA - ], - messages: { - exceed: "{{name}} has too many lines ({{lineCount}}). Maximum allowed is {{maxLines}}." - } - }, - - create(context) { - const sourceCode = context.sourceCode; - const lines = sourceCode.lines; - - const option = context.options[0]; - let maxLines = 50; - let skipComments = false; - let skipBlankLines = false; - let IIFEs = false; - - if (typeof option === "object") { - maxLines = typeof option.max === "number" ? option.max : 50; - skipComments = !!option.skipComments; - skipBlankLines = !!option.skipBlankLines; - IIFEs = !!option.IIFEs; - } else if (typeof option === "number") { - maxLines = option; - } - - const commentLineNumbers = getCommentLineNumbers(sourceCode.getAllComments()); - - //-------------------------------------------------------------------------- - // Helpers - //-------------------------------------------------------------------------- - - /** - * Tells if a comment encompasses the entire line. - * @param {string} line The source line with a trailing comment - * @param {number} lineNumber The one-indexed line number this is on - * @param {ASTNode} comment The comment to remove - * @returns {boolean} If the comment covers the entire line - */ - function isFullLineComment(line, lineNumber, comment) { - const start = comment.loc.start, - end = comment.loc.end, - isFirstTokenOnLine = start.line === lineNumber && !line.slice(0, start.column).trim(), - isLastTokenOnLine = end.line === lineNumber && !line.slice(end.column).trim(); - - return comment && - (start.line < lineNumber || isFirstTokenOnLine) && - (end.line > lineNumber || isLastTokenOnLine); - } - - /** - * Identifies is a node is a FunctionExpression which is part of an IIFE - * @param {ASTNode} node Node to test - * @returns {boolean} True if it's an IIFE - */ - function isIIFE(node) { - return (node.type === "FunctionExpression" || node.type === "ArrowFunctionExpression") && node.parent && node.parent.type === "CallExpression" && node.parent.callee === node; - } - - /** - * Identifies is a node is a FunctionExpression which is embedded within a MethodDefinition or Property - * @param {ASTNode} node Node to test - * @returns {boolean} True if it's a FunctionExpression embedded within a MethodDefinition or Property - */ - function isEmbedded(node) { - if (!node.parent) { - return false; - } - if (node !== node.parent.value) { - return false; - } - if (node.parent.type === "MethodDefinition") { - return true; - } - if (node.parent.type === "Property") { - return node.parent.method === true || node.parent.kind === "get" || node.parent.kind === "set"; - } - return false; - } - - /** - * Count the lines in the function - * @param {ASTNode} funcNode Function AST node - * @returns {void} - * @private - */ - function processFunction(funcNode) { - const node = isEmbedded(funcNode) ? funcNode.parent : funcNode; - - if (!IIFEs && isIIFE(node)) { - return; - } - let lineCount = 0; - - for (let i = node.loc.start.line - 1; i < node.loc.end.line; ++i) { - const line = lines[i]; - - if (skipComments) { - if (commentLineNumbers.has(i + 1) && isFullLineComment(line, i + 1, commentLineNumbers.get(i + 1))) { - continue; - } - } - - if (skipBlankLines) { - if (line.match(/^\s*$/u)) { - continue; - } - } - - lineCount++; - } - - if (lineCount > maxLines) { - const name = upperCaseFirst(astUtils.getFunctionNameWithKind(funcNode)); - - context.report({ - node, - messageId: "exceed", - data: { name, lineCount, maxLines } - }); - } - } - - //-------------------------------------------------------------------------- - // Public API - //-------------------------------------------------------------------------- - - return { - FunctionDeclaration: processFunction, - FunctionExpression: processFunction, - ArrowFunctionExpression: processFunction - }; - } -}; diff --git a/tools/eslint/node_modules/eslint/lib/rules/max-lines.js b/tools/eslint/node_modules/eslint/lib/rules/max-lines.js deleted file mode 100644 index d8215794cb05de..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/rules/max-lines.js +++ /dev/null @@ -1,193 +0,0 @@ -/** - * @fileoverview enforce a maximum file length - * @author Alberto Rodrรญguez - */ -"use strict"; - -//------------------------------------------------------------------------------ -// Requirements -//------------------------------------------------------------------------------ - -const astUtils = require("./utils/ast-utils"); - -//------------------------------------------------------------------------------ -// Helpers -//------------------------------------------------------------------------------ - -/** - * Creates an array of numbers from `start` up to, but not including, `end` - * @param {number} start The start of the range - * @param {number} end The end of the range - * @returns {number[]} The range of numbers - */ -function range(start, end) { - return [...Array(end - start).keys()].map(x => x + start); -} - -//------------------------------------------------------------------------------ -// Rule Definition -//------------------------------------------------------------------------------ - -/** @type {import('../shared/types').Rule} */ -module.exports = { - meta: { - type: "suggestion", - - docs: { - description: "Enforce a maximum number of lines per file", - recommended: false, - url: "https://eslint.org/docs/latest/rules/max-lines" - }, - - schema: [ - { - oneOf: [ - { - type: "integer", - minimum: 0 - }, - { - type: "object", - properties: { - max: { - type: "integer", - minimum: 0 - }, - skipComments: { - type: "boolean" - }, - skipBlankLines: { - type: "boolean" - } - }, - additionalProperties: false - } - ] - } - ], - messages: { - exceed: - "File has too many lines ({{actual}}). Maximum allowed is {{max}}." - } - }, - - create(context) { - const option = context.options[0]; - let max = 300; - - if ( - typeof option === "object" && - Object.hasOwn(option, "max") - ) { - max = option.max; - } else if (typeof option === "number") { - max = option; - } - - const skipComments = option && option.skipComments; - const skipBlankLines = option && option.skipBlankLines; - - const sourceCode = context.sourceCode; - - /** - * Returns whether or not a token is a comment node type - * @param {Token} token The token to check - * @returns {boolean} True if the token is a comment node - */ - function isCommentNodeType(token) { - return token && (token.type === "Block" || token.type === "Line"); - } - - /** - * Returns the line numbers of a comment that don't have any code on the same line - * @param {Node} comment The comment node to check - * @returns {number[]} The line numbers - */ - function getLinesWithoutCode(comment) { - let start = comment.loc.start.line; - let end = comment.loc.end.line; - - let token; - - token = comment; - do { - token = sourceCode.getTokenBefore(token, { - includeComments: true - }); - } while (isCommentNodeType(token)); - - if (token && astUtils.isTokenOnSameLine(token, comment)) { - start += 1; - } - - token = comment; - do { - token = sourceCode.getTokenAfter(token, { - includeComments: true - }); - } while (isCommentNodeType(token)); - - if (token && astUtils.isTokenOnSameLine(comment, token)) { - end -= 1; - } - - if (start <= end) { - return range(start, end + 1); - } - return []; - } - - return { - "Program:exit"() { - let lines = sourceCode.lines.map((text, i) => ({ - lineNumber: i + 1, - text - })); - - /* - * If file ends with a linebreak, `sourceCode.lines` will have one extra empty line at the end. - * That isn't a real line, so we shouldn't count it. - */ - if (lines.length > 1 && lines.at(-1).text === "") { - lines.pop(); - } - - if (skipBlankLines) { - lines = lines.filter(l => l.text.trim() !== ""); - } - - if (skipComments) { - const comments = sourceCode.getAllComments(); - - const commentLines = new Set(comments.flatMap(getLinesWithoutCode)); - - lines = lines.filter( - l => !commentLines.has(l.lineNumber) - ); - } - - if (lines.length > max) { - const loc = { - start: { - line: lines[max].lineNumber, - column: 0 - }, - end: { - line: sourceCode.lines.length, - column: sourceCode.lines.at(-1).length - } - }; - - context.report({ - loc, - messageId: "exceed", - data: { - max, - actual: lines.length - } - }); - } - } - }; - } -}; diff --git a/tools/eslint/node_modules/eslint/lib/rules/max-nested-callbacks.js b/tools/eslint/node_modules/eslint/lib/rules/max-nested-callbacks.js deleted file mode 100644 index 448c0bd44333b2..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/rules/max-nested-callbacks.js +++ /dev/null @@ -1,117 +0,0 @@ -/** - * @fileoverview Rule to enforce a maximum number of nested callbacks. - * @author Ian Christian Myers - */ - -"use strict"; - -//------------------------------------------------------------------------------ -// Rule Definition -//------------------------------------------------------------------------------ - -/** @type {import('../shared/types').Rule} */ -module.exports = { - meta: { - type: "suggestion", - - docs: { - description: "Enforce a maximum depth that callbacks can be nested", - recommended: false, - url: "https://eslint.org/docs/latest/rules/max-nested-callbacks" - }, - - schema: [ - { - oneOf: [ - { - type: "integer", - minimum: 0 - }, - { - type: "object", - properties: { - maximum: { - type: "integer", - minimum: 0 - }, - max: { - type: "integer", - minimum: 0 - } - }, - additionalProperties: false - } - ] - } - ], - messages: { - exceed: "Too many nested callbacks ({{num}}). Maximum allowed is {{max}}." - } - }, - - create(context) { - - //-------------------------------------------------------------------------- - // Constants - //-------------------------------------------------------------------------- - const option = context.options[0]; - let THRESHOLD = 10; - - if ( - typeof option === "object" && - (Object.hasOwn(option, "maximum") || Object.hasOwn(option, "max")) - ) { - THRESHOLD = option.maximum || option.max; - } else if (typeof option === "number") { - THRESHOLD = option; - } - - //-------------------------------------------------------------------------- - // Helpers - //-------------------------------------------------------------------------- - - const callbackStack = []; - - /** - * Checks a given function node for too many callbacks. - * @param {ASTNode} node The node to check. - * @returns {void} - * @private - */ - function checkFunction(node) { - const parent = node.parent; - - if (parent.type === "CallExpression") { - callbackStack.push(node); - } - - if (callbackStack.length > THRESHOLD) { - const opts = { num: callbackStack.length, max: THRESHOLD }; - - context.report({ node, messageId: "exceed", data: opts }); - } - } - - /** - * Pops the call stack. - * @returns {void} - * @private - */ - function popStack() { - callbackStack.pop(); - } - - //-------------------------------------------------------------------------- - // Public API - //-------------------------------------------------------------------------- - - return { - ArrowFunctionExpression: checkFunction, - "ArrowFunctionExpression:exit": popStack, - - FunctionExpression: checkFunction, - "FunctionExpression:exit": popStack - }; - - } -}; diff --git a/tools/eslint/node_modules/eslint/lib/rules/max-params.js b/tools/eslint/node_modules/eslint/lib/rules/max-params.js deleted file mode 100644 index eb043ab190b224..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/rules/max-params.js +++ /dev/null @@ -1,102 +0,0 @@ -/** - * @fileoverview Rule to flag when a function has too many parameters - * @author Ilya Volodin - */ - -"use strict"; - -//------------------------------------------------------------------------------ -// Requirements -//------------------------------------------------------------------------------ - -const astUtils = require("./utils/ast-utils"); -const { upperCaseFirst } = require("../shared/string-utils"); - -//------------------------------------------------------------------------------ -// Rule Definition -//------------------------------------------------------------------------------ - -/** @type {import('../shared/types').Rule} */ -module.exports = { - meta: { - type: "suggestion", - - docs: { - description: "Enforce a maximum number of parameters in function definitions", - recommended: false, - url: "https://eslint.org/docs/latest/rules/max-params" - }, - - schema: [ - { - oneOf: [ - { - type: "integer", - minimum: 0 - }, - { - type: "object", - properties: { - maximum: { - type: "integer", - minimum: 0 - }, - max: { - type: "integer", - minimum: 0 - } - }, - additionalProperties: false - } - ] - } - ], - messages: { - exceed: "{{name}} has too many parameters ({{count}}). Maximum allowed is {{max}}." - } - }, - - create(context) { - const sourceCode = context.sourceCode; - const option = context.options[0]; - let numParams = 3; - - if ( - typeof option === "object" && - (Object.hasOwn(option, "maximum") || Object.hasOwn(option, "max")) - ) { - numParams = option.maximum || option.max; - } - if (typeof option === "number") { - numParams = option; - } - - /** - * Checks a function to see if it has too many parameters. - * @param {ASTNode} node The node to check. - * @returns {void} - * @private - */ - function checkFunction(node) { - if (node.params.length > numParams) { - context.report({ - loc: astUtils.getFunctionHeadLoc(node, sourceCode), - node, - messageId: "exceed", - data: { - name: upperCaseFirst(astUtils.getFunctionNameWithKind(node)), - count: node.params.length, - max: numParams - } - }); - } - } - - return { - FunctionDeclaration: checkFunction, - ArrowFunctionExpression: checkFunction, - FunctionExpression: checkFunction - }; - - } -}; diff --git a/tools/eslint/node_modules/eslint/lib/rules/max-statements-per-line.js b/tools/eslint/node_modules/eslint/lib/rules/max-statements-per-line.js deleted file mode 100644 index 4ad73a67f98e81..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/rules/max-statements-per-line.js +++ /dev/null @@ -1,199 +0,0 @@ -/** - * @fileoverview Specify the maximum number of statements allowed per line. - * @author Kenneth Williams - * @deprecated in ESLint v8.53.0 - */ -"use strict"; - -//------------------------------------------------------------------------------ -// Requirements -//------------------------------------------------------------------------------ - -const astUtils = require("./utils/ast-utils"); - -//------------------------------------------------------------------------------ -// Rule Definition -//------------------------------------------------------------------------------ - -/** @type {import('../shared/types').Rule} */ -module.exports = { - meta: { - deprecated: true, - replacedBy: [], - type: "layout", - - docs: { - description: "Enforce a maximum number of statements allowed per line", - recommended: false, - url: "https://eslint.org/docs/latest/rules/max-statements-per-line" - }, - - schema: [ - { - type: "object", - properties: { - max: { - type: "integer", - minimum: 1, - default: 1 - } - }, - additionalProperties: false - } - ], - messages: { - exceed: "This line has {{numberOfStatementsOnThisLine}} {{statements}}. Maximum allowed is {{maxStatementsPerLine}}." - } - }, - - create(context) { - - const sourceCode = context.sourceCode, - options = context.options[0] || {}, - maxStatementsPerLine = typeof options.max !== "undefined" ? options.max : 1; - - let lastStatementLine = 0, - numberOfStatementsOnThisLine = 0, - firstExtraStatement; - - //-------------------------------------------------------------------------- - // Helpers - //-------------------------------------------------------------------------- - - const SINGLE_CHILD_ALLOWED = /^(?:(?:DoWhile|For|ForIn|ForOf|If|Labeled|While)Statement|Export(?:Default|Named)Declaration)$/u; - - /** - * Reports with the first extra statement, and clears it. - * @returns {void} - */ - function reportFirstExtraStatementAndClear() { - if (firstExtraStatement) { - context.report({ - node: firstExtraStatement, - messageId: "exceed", - data: { - numberOfStatementsOnThisLine, - maxStatementsPerLine, - statements: numberOfStatementsOnThisLine === 1 ? "statement" : "statements" - } - }); - } - firstExtraStatement = null; - } - - /** - * Gets the actual last token of a given node. - * @param {ASTNode} node A node to get. This is a node except EmptyStatement. - * @returns {Token} The actual last token. - */ - function getActualLastToken(node) { - return sourceCode.getLastToken(node, astUtils.isNotSemicolonToken); - } - - /** - * Addresses a given node. - * It updates the state of this rule, then reports the node if the node violated this rule. - * @param {ASTNode} node A node to check. - * @returns {void} - */ - function enterStatement(node) { - const line = node.loc.start.line; - - /* - * Skip to allow non-block statements if this is direct child of control statements. - * `if (a) foo();` is counted as 1. - * But `if (a) foo(); else foo();` should be counted as 2. - */ - if (SINGLE_CHILD_ALLOWED.test(node.parent.type) && - node.parent.alternate !== node - ) { - return; - } - - // Update state. - if (line === lastStatementLine) { - numberOfStatementsOnThisLine += 1; - } else { - reportFirstExtraStatementAndClear(); - numberOfStatementsOnThisLine = 1; - lastStatementLine = line; - } - - // Reports if the node violated this rule. - if (numberOfStatementsOnThisLine === maxStatementsPerLine + 1) { - firstExtraStatement = firstExtraStatement || node; - } - } - - /** - * Updates the state of this rule with the end line of leaving node to check with the next statement. - * @param {ASTNode} node A node to check. - * @returns {void} - */ - function leaveStatement(node) { - const line = getActualLastToken(node).loc.end.line; - - // Update state. - if (line !== lastStatementLine) { - reportFirstExtraStatementAndClear(); - numberOfStatementsOnThisLine = 1; - lastStatementLine = line; - } - } - - //-------------------------------------------------------------------------- - // Public API - //-------------------------------------------------------------------------- - - return { - BreakStatement: enterStatement, - ClassDeclaration: enterStatement, - ContinueStatement: enterStatement, - DebuggerStatement: enterStatement, - DoWhileStatement: enterStatement, - ExpressionStatement: enterStatement, - ForInStatement: enterStatement, - ForOfStatement: enterStatement, - ForStatement: enterStatement, - FunctionDeclaration: enterStatement, - IfStatement: enterStatement, - ImportDeclaration: enterStatement, - LabeledStatement: enterStatement, - ReturnStatement: enterStatement, - SwitchStatement: enterStatement, - ThrowStatement: enterStatement, - TryStatement: enterStatement, - VariableDeclaration: enterStatement, - WhileStatement: enterStatement, - WithStatement: enterStatement, - ExportNamedDeclaration: enterStatement, - ExportDefaultDeclaration: enterStatement, - ExportAllDeclaration: enterStatement, - - "BreakStatement:exit": leaveStatement, - "ClassDeclaration:exit": leaveStatement, - "ContinueStatement:exit": leaveStatement, - "DebuggerStatement:exit": leaveStatement, - "DoWhileStatement:exit": leaveStatement, - "ExpressionStatement:exit": leaveStatement, - "ForInStatement:exit": leaveStatement, - "ForOfStatement:exit": leaveStatement, - "ForStatement:exit": leaveStatement, - "FunctionDeclaration:exit": leaveStatement, - "IfStatement:exit": leaveStatement, - "ImportDeclaration:exit": leaveStatement, - "LabeledStatement:exit": leaveStatement, - "ReturnStatement:exit": leaveStatement, - "SwitchStatement:exit": leaveStatement, - "ThrowStatement:exit": leaveStatement, - "TryStatement:exit": leaveStatement, - "VariableDeclaration:exit": leaveStatement, - "WhileStatement:exit": leaveStatement, - "WithStatement:exit": leaveStatement, - "ExportNamedDeclaration:exit": leaveStatement, - "ExportDefaultDeclaration:exit": leaveStatement, - "ExportAllDeclaration:exit": leaveStatement, - "Program:exit": reportFirstExtraStatementAndClear - }; - } -}; diff --git a/tools/eslint/node_modules/eslint/lib/rules/max-statements.js b/tools/eslint/node_modules/eslint/lib/rules/max-statements.js deleted file mode 100644 index 96d5ea7b8ccbd8..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/rules/max-statements.js +++ /dev/null @@ -1,184 +0,0 @@ -/** - * @fileoverview A rule to set the maximum number of statements in a function. - * @author Ian Christian Myers - */ - -"use strict"; - -//------------------------------------------------------------------------------ -// Requirements -//------------------------------------------------------------------------------ - -const astUtils = require("./utils/ast-utils"); -const { upperCaseFirst } = require("../shared/string-utils"); - -//------------------------------------------------------------------------------ -// Rule Definition -//------------------------------------------------------------------------------ - -/** @type {import('../shared/types').Rule} */ -module.exports = { - meta: { - type: "suggestion", - - docs: { - description: "Enforce a maximum number of statements allowed in function blocks", - recommended: false, - url: "https://eslint.org/docs/latest/rules/max-statements" - }, - - schema: [ - { - oneOf: [ - { - type: "integer", - minimum: 0 - }, - { - type: "object", - properties: { - maximum: { - type: "integer", - minimum: 0 - }, - max: { - type: "integer", - minimum: 0 - } - }, - additionalProperties: false - } - ] - }, - { - type: "object", - properties: { - ignoreTopLevelFunctions: { - type: "boolean" - } - }, - additionalProperties: false - } - ], - messages: { - exceed: "{{name}} has too many statements ({{count}}). Maximum allowed is {{max}}." - } - }, - - create(context) { - - //-------------------------------------------------------------------------- - // Helpers - //-------------------------------------------------------------------------- - - const functionStack = [], - option = context.options[0], - ignoreTopLevelFunctions = context.options[1] && context.options[1].ignoreTopLevelFunctions || false, - topLevelFunctions = []; - let maxStatements = 10; - - if ( - typeof option === "object" && - (Object.hasOwn(option, "maximum") || Object.hasOwn(option, "max")) - ) { - maxStatements = option.maximum || option.max; - } else if (typeof option === "number") { - maxStatements = option; - } - - /** - * Reports a node if it has too many statements - * @param {ASTNode} node node to evaluate - * @param {int} count Number of statements in node - * @param {int} max Maximum number of statements allowed - * @returns {void} - * @private - */ - function reportIfTooManyStatements(node, count, max) { - if (count > max) { - const name = upperCaseFirst(astUtils.getFunctionNameWithKind(node)); - - context.report({ - node, - messageId: "exceed", - data: { name, count, max } - }); - } - } - - /** - * When parsing a new function, store it in our function stack - * @returns {void} - * @private - */ - function startFunction() { - functionStack.push(0); - } - - /** - * Evaluate the node at the end of function - * @param {ASTNode} node node to evaluate - * @returns {void} - * @private - */ - function endFunction(node) { - const count = functionStack.pop(); - - /* - * This rule does not apply to class static blocks, but we have to track them so - * that statements in them do not count as statements in the enclosing function. - */ - if (node.type === "StaticBlock") { - return; - } - - if (ignoreTopLevelFunctions && functionStack.length === 0) { - topLevelFunctions.push({ node, count }); - } else { - reportIfTooManyStatements(node, count, maxStatements); - } - } - - /** - * Increment the count of the functions - * @param {ASTNode} node node to evaluate - * @returns {void} - * @private - */ - function countStatements(node) { - functionStack[functionStack.length - 1] += node.body.length; - } - - //-------------------------------------------------------------------------- - // Public API - //-------------------------------------------------------------------------- - - return { - FunctionDeclaration: startFunction, - FunctionExpression: startFunction, - ArrowFunctionExpression: startFunction, - StaticBlock: startFunction, - - BlockStatement: countStatements, - - "FunctionDeclaration:exit": endFunction, - "FunctionExpression:exit": endFunction, - "ArrowFunctionExpression:exit": endFunction, - "StaticBlock:exit": endFunction, - - "Program:exit"() { - if (topLevelFunctions.length === 1) { - return; - } - - topLevelFunctions.forEach(element => { - const count = element.count; - const node = element.node; - - reportIfTooManyStatements(node, count, maxStatements); - }); - } - }; - - } -}; diff --git a/tools/eslint/node_modules/eslint/lib/rules/multiline-comment-style.js b/tools/eslint/node_modules/eslint/lib/rules/multiline-comment-style.js deleted file mode 100644 index 098e054b9f3a13..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/rules/multiline-comment-style.js +++ /dev/null @@ -1,476 +0,0 @@ -/** - * @fileoverview enforce a particular style for multiline comments - * @author Teddy Katz - * @deprecated in ESLint v9.3.0 - */ -"use strict"; - -const astUtils = require("./utils/ast-utils"); - -//------------------------------------------------------------------------------ -// Rule Definition -//------------------------------------------------------------------------------ - -/** @type {import('../shared/types').Rule} */ -module.exports = { - meta: { - deprecated: true, - replacedBy: [], - type: "suggestion", - docs: { - description: "Enforce a particular style for multiline comments", - recommended: false, - url: "https://eslint.org/docs/latest/rules/multiline-comment-style" - }, - - fixable: "whitespace", - schema: { - anyOf: [ - { - type: "array", - items: [ - { - enum: ["starred-block", "bare-block"] - } - ], - additionalItems: false - }, - { - type: "array", - items: [ - { - enum: ["separate-lines"] - }, - { - type: "object", - properties: { - checkJSDoc: { - type: "boolean" - } - }, - additionalProperties: false - } - ], - additionalItems: false - } - ] - }, - messages: { - expectedBlock: "Expected a block comment instead of consecutive line comments.", - expectedBareBlock: "Expected a block comment without padding stars.", - startNewline: "Expected a linebreak after '/*'.", - endNewline: "Expected a linebreak before '*/'.", - missingStar: "Expected a '*' at the start of this line.", - alignment: "Expected this line to be aligned with the start of the comment.", - expectedLines: "Expected multiple line comments instead of a block comment." - } - }, - - create(context) { - const sourceCode = context.sourceCode; - const option = context.options[0] || "starred-block"; - const params = context.options[1] || {}; - const checkJSDoc = !!params.checkJSDoc; - - //---------------------------------------------------------------------- - // Helpers - //---------------------------------------------------------------------- - - /** - * Checks if a comment line is starred. - * @param {string} line A string representing a comment line. - * @returns {boolean} Whether or not the comment line is starred. - */ - function isStarredCommentLine(line) { - return /^\s*\*/u.test(line); - } - - /** - * Checks if a comment group is in starred-block form. - * @param {Token[]} commentGroup A group of comments, containing either multiple line comments or a single block comment. - * @returns {boolean} Whether or not the comment group is in starred block form. - */ - function isStarredBlockComment([firstComment]) { - if (firstComment.type !== "Block") { - return false; - } - - const lines = firstComment.value.split(astUtils.LINEBREAK_MATCHER); - - // The first and last lines can only contain whitespace. - return lines.length > 0 && lines.every((line, i) => (i === 0 || i === lines.length - 1 ? /^\s*$/u : /^\s*\*/u).test(line)); - } - - /** - * Checks if a comment group is in JSDoc form. - * @param {Token[]} commentGroup A group of comments, containing either multiple line comments or a single block comment. - * @returns {boolean} Whether or not the comment group is in JSDoc form. - */ - function isJSDocComment([firstComment]) { - if (firstComment.type !== "Block") { - return false; - } - - const lines = firstComment.value.split(astUtils.LINEBREAK_MATCHER); - - return /^\*\s*$/u.test(lines[0]) && - lines.slice(1, -1).every(line => /^\s* /u.test(line)) && - /^\s*$/u.test(lines.at(-1)); - } - - /** - * Processes a comment group that is currently in separate-line form, calculating the offset for each line. - * @param {Token[]} commentGroup A group of comments containing multiple line comments. - * @returns {string[]} An array of the processed lines. - */ - function processSeparateLineComments(commentGroup) { - const allLinesHaveLeadingSpace = commentGroup - .map(({ value }) => value) - .filter(line => line.trim().length) - .every(line => line.startsWith(" ")); - - return commentGroup.map(({ value }) => (allLinesHaveLeadingSpace ? value.replace(/^ /u, "") : value)); - } - - /** - * Processes a comment group that is currently in starred-block form, calculating the offset for each line. - * @param {Token} comment A single block comment token in starred-block form. - * @returns {string[]} An array of the processed lines. - */ - function processStarredBlockComment(comment) { - const lines = comment.value.split(astUtils.LINEBREAK_MATCHER) - .filter((line, i, linesArr) => !(i === 0 || i === linesArr.length - 1)) - .map(line => line.replace(/^\s*$/u, "")); - const allLinesHaveLeadingSpace = lines - .map(line => line.replace(/\s*\*/u, "")) - .filter(line => line.trim().length) - .every(line => line.startsWith(" ")); - - return lines.map(line => line.replace(allLinesHaveLeadingSpace ? /\s*\* ?/u : /\s*\*/u, "")); - } - - /** - * Processes a comment group that is currently in bare-block form, calculating the offset for each line. - * @param {Token} comment A single block comment token in bare-block form. - * @returns {string[]} An array of the processed lines. - */ - function processBareBlockComment(comment) { - const lines = comment.value.split(astUtils.LINEBREAK_MATCHER).map(line => line.replace(/^\s*$/u, "")); - const leadingWhitespace = `${sourceCode.text.slice(comment.range[0] - comment.loc.start.column, comment.range[0])} `; - let offset = ""; - - /* - * Calculate the offset of the least indented line and use that as the basis for offsetting all the lines. - * The first line should not be checked because it is inline with the opening block comment delimiter. - */ - for (const [i, line] of lines.entries()) { - if (!line.trim().length || i === 0) { - continue; - } - - const [, lineOffset] = line.match(/^(\s*\*?\s*)/u); - - if (lineOffset.length < leadingWhitespace.length) { - const newOffset = leadingWhitespace.slice(lineOffset.length - leadingWhitespace.length); - - if (newOffset.length > offset.length) { - offset = newOffset; - } - } - } - - return lines.map(line => { - const match = line.match(/^(\s*\*?\s*)(.*)/u); - const [, lineOffset, lineContents] = match; - - if (lineOffset.length > leadingWhitespace.length) { - return `${lineOffset.slice(leadingWhitespace.length - (offset.length + lineOffset.length))}${lineContents}`; - } - - if (lineOffset.length < leadingWhitespace.length) { - return `${lineOffset.slice(leadingWhitespace.length)}${lineContents}`; - } - - return lineContents; - }); - } - - /** - * Gets a list of comment lines in a group, formatting leading whitespace as necessary. - * @param {Token[]} commentGroup A group of comments containing either multiple line comments or a single block comment. - * @returns {string[]} A list of comment lines. - */ - function getCommentLines(commentGroup) { - const [firstComment] = commentGroup; - - if (firstComment.type === "Line") { - return processSeparateLineComments(commentGroup); - } - - if (isStarredBlockComment(commentGroup)) { - return processStarredBlockComment(firstComment); - } - - return processBareBlockComment(firstComment); - } - - /** - * Gets the initial offset (whitespace) from the beginning of a line to a given comment token. - * @param {Token} comment The token to check. - * @returns {string} The offset from the beginning of a line to the token. - */ - function getInitialOffset(comment) { - return sourceCode.text.slice(comment.range[0] - comment.loc.start.column, comment.range[0]); - } - - /** - * Converts a comment into starred-block form - * @param {Token} firstComment The first comment of the group being converted - * @param {string[]} commentLinesList A list of lines to appear in the new starred-block comment - * @returns {string} A representation of the comment value in starred-block form, excluding start and end markers - */ - function convertToStarredBlock(firstComment, commentLinesList) { - const initialOffset = getInitialOffset(firstComment); - - return `/*\n${commentLinesList.map(line => `${initialOffset} * ${line}`).join("\n")}\n${initialOffset} */`; - } - - /** - * Converts a comment into separate-line form - * @param {Token} firstComment The first comment of the group being converted - * @param {string[]} commentLinesList A list of lines to appear in the new starred-block comment - * @returns {string} A representation of the comment value in separate-line form - */ - function convertToSeparateLines(firstComment, commentLinesList) { - return commentLinesList.map(line => `// ${line}`).join(`\n${getInitialOffset(firstComment)}`); - } - - /** - * Converts a comment into bare-block form - * @param {Token} firstComment The first comment of the group being converted - * @param {string[]} commentLinesList A list of lines to appear in the new starred-block comment - * @returns {string} A representation of the comment value in bare-block form - */ - function convertToBlock(firstComment, commentLinesList) { - return `/* ${commentLinesList.join(`\n${getInitialOffset(firstComment)} `)} */`; - } - - /** - * Each method checks a group of comments to see if it's valid according to the given option. - * @param {Token[]} commentGroup A list of comments that appear together. This will either contain a single - * block comment or multiple line comments. - * @returns {void} - */ - const commentGroupCheckers = { - "starred-block"(commentGroup) { - const [firstComment] = commentGroup; - const commentLines = getCommentLines(commentGroup); - - if (commentLines.some(value => value.includes("*/"))) { - return; - } - - if (commentGroup.length > 1) { - context.report({ - loc: { - start: firstComment.loc.start, - end: commentGroup.at(-1).loc.end - }, - messageId: "expectedBlock", - fix(fixer) { - const range = [firstComment.range[0], commentGroup.at(-1).range[1]]; - - return commentLines.some(value => value.startsWith("/")) - ? null - : fixer.replaceTextRange(range, convertToStarredBlock(firstComment, commentLines)); - } - }); - } else { - const lines = firstComment.value.split(astUtils.LINEBREAK_MATCHER); - const expectedLeadingWhitespace = getInitialOffset(firstComment); - const expectedLinePrefix = `${expectedLeadingWhitespace} *`; - - if (!/^\*?\s*$/u.test(lines[0])) { - const start = firstComment.value.startsWith("*") ? firstComment.range[0] + 1 : firstComment.range[0]; - - context.report({ - loc: { - start: firstComment.loc.start, - end: { line: firstComment.loc.start.line, column: firstComment.loc.start.column + 2 } - }, - messageId: "startNewline", - fix: fixer => fixer.insertTextAfterRange([start, start + 2], `\n${expectedLinePrefix}`) - }); - } - - if (!/^\s*$/u.test(lines.at(-1))) { - context.report({ - loc: { - start: { line: firstComment.loc.end.line, column: firstComment.loc.end.column - 2 }, - end: firstComment.loc.end - }, - messageId: "endNewline", - fix: fixer => fixer.replaceTextRange([firstComment.range[1] - 2, firstComment.range[1]], `\n${expectedLinePrefix}/`) - }); - } - - for (let lineNumber = firstComment.loc.start.line + 1; lineNumber <= firstComment.loc.end.line; lineNumber++) { - const lineText = sourceCode.lines[lineNumber - 1]; - const errorType = isStarredCommentLine(lineText) - ? "alignment" - : "missingStar"; - - if (!lineText.startsWith(expectedLinePrefix)) { - context.report({ - loc: { - start: { line: lineNumber, column: 0 }, - end: { line: lineNumber, column: lineText.length } - }, - messageId: errorType, - fix(fixer) { - const lineStartIndex = sourceCode.getIndexFromLoc({ line: lineNumber, column: 0 }); - - if (errorType === "alignment") { - const [, commentTextPrefix = ""] = lineText.match(/^(\s*\*)/u) || []; - const commentTextStartIndex = lineStartIndex + commentTextPrefix.length; - - return fixer.replaceTextRange([lineStartIndex, commentTextStartIndex], expectedLinePrefix); - } - - const [, commentTextPrefix = ""] = lineText.match(/^(\s*)/u) || []; - const commentTextStartIndex = lineStartIndex + commentTextPrefix.length; - let offset; - - for (const [idx, line] of lines.entries()) { - if (!/\S+/u.test(line)) { - continue; - } - - const lineTextToAlignWith = sourceCode.lines[firstComment.loc.start.line - 1 + idx]; - const [, prefix = "", initialOffset = ""] = lineTextToAlignWith.match(/^(\s*(?:\/?\*)?(\s*))/u) || []; - - offset = `${commentTextPrefix.slice(prefix.length)}${initialOffset}`; - - if (/^\s*\//u.test(lineText) && offset.length === 0) { - offset += " "; - } - break; - } - - return fixer.replaceTextRange([lineStartIndex, commentTextStartIndex], `${expectedLinePrefix}${offset}`); - } - }); - } - } - } - }, - "separate-lines"(commentGroup) { - const [firstComment] = commentGroup; - - const isJSDoc = isJSDocComment(commentGroup); - - if (firstComment.type !== "Block" || (!checkJSDoc && isJSDoc)) { - return; - } - - let commentLines = getCommentLines(commentGroup); - - if (isJSDoc) { - commentLines = commentLines.slice(1, commentLines.length - 1); - } - - const tokenAfter = sourceCode.getTokenAfter(firstComment, { includeComments: true }); - - if (tokenAfter && firstComment.loc.end.line === tokenAfter.loc.start.line) { - return; - } - - context.report({ - loc: { - start: firstComment.loc.start, - end: { line: firstComment.loc.start.line, column: firstComment.loc.start.column + 2 } - }, - messageId: "expectedLines", - fix(fixer) { - return fixer.replaceText(firstComment, convertToSeparateLines(firstComment, commentLines)); - } - }); - }, - "bare-block"(commentGroup) { - if (isJSDocComment(commentGroup)) { - return; - } - - const [firstComment] = commentGroup; - const commentLines = getCommentLines(commentGroup); - - // Disallows consecutive line comments in favor of using a block comment. - if (firstComment.type === "Line" && commentLines.length > 1 && - !commentLines.some(value => value.includes("*/"))) { - context.report({ - loc: { - start: firstComment.loc.start, - end: commentGroup.at(-1).loc.end - }, - messageId: "expectedBlock", - fix(fixer) { - return fixer.replaceTextRange( - [firstComment.range[0], commentGroup.at(-1).range[1]], - convertToBlock(firstComment, commentLines) - ); - } - }); - } - - // Prohibits block comments from having a * at the beginning of each line. - if (isStarredBlockComment(commentGroup)) { - context.report({ - loc: { - start: firstComment.loc.start, - end: { line: firstComment.loc.start.line, column: firstComment.loc.start.column + 2 } - }, - messageId: "expectedBareBlock", - fix(fixer) { - return fixer.replaceText(firstComment, convertToBlock(firstComment, commentLines)); - } - }); - } - } - }; - - //---------------------------------------------------------------------- - // Public - //---------------------------------------------------------------------- - - return { - Program() { - return sourceCode.getAllComments() - .filter(comment => comment.type !== "Shebang") - .filter(comment => !astUtils.COMMENTS_IGNORE_PATTERN.test(comment.value)) - .filter(comment => { - const tokenBefore = sourceCode.getTokenBefore(comment, { includeComments: true }); - - return !tokenBefore || tokenBefore.loc.end.line < comment.loc.start.line; - }) - .reduce((commentGroups, comment, index, commentList) => { - const tokenBefore = sourceCode.getTokenBefore(comment, { includeComments: true }); - - if ( - comment.type === "Line" && - index && commentList[index - 1].type === "Line" && - tokenBefore && tokenBefore.loc.end.line === comment.loc.start.line - 1 && - tokenBefore === commentList[index - 1] - ) { - commentGroups.at(-1).push(comment); - } else { - commentGroups.push([comment]); - } - - return commentGroups; - }, []) - .filter(commentGroup => !(commentGroup.length === 1 && commentGroup[0].loc.start.line === commentGroup[0].loc.end.line)) - .forEach(commentGroupCheckers[option]); - } - }; - } -}; diff --git a/tools/eslint/node_modules/eslint/lib/rules/multiline-ternary.js b/tools/eslint/node_modules/eslint/lib/rules/multiline-ternary.js deleted file mode 100644 index 8155dd7a5a6fa8..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/rules/multiline-ternary.js +++ /dev/null @@ -1,174 +0,0 @@ -/** - * @fileoverview Enforce newlines between operands of ternary expressions - * @author Kai Cataldo - * @deprecated in ESLint v8.53.0 - */ - -"use strict"; - -const astUtils = require("./utils/ast-utils"); - -//------------------------------------------------------------------------------ -// Rule Definition -//------------------------------------------------------------------------------ - -/** @type {import('../shared/types').Rule} */ -module.exports = { - meta: { - deprecated: true, - replacedBy: [], - type: "layout", - - docs: { - description: "Enforce newlines between operands of ternary expressions", - recommended: false, - url: "https://eslint.org/docs/latest/rules/multiline-ternary" - }, - - schema: [ - { - enum: ["always", "always-multiline", "never"] - } - ], - - messages: { - expectedTestCons: "Expected newline between test and consequent of ternary expression.", - expectedConsAlt: "Expected newline between consequent and alternate of ternary expression.", - unexpectedTestCons: "Unexpected newline between test and consequent of ternary expression.", - unexpectedConsAlt: "Unexpected newline between consequent and alternate of ternary expression." - }, - - fixable: "whitespace" - }, - - create(context) { - const sourceCode = context.sourceCode; - const option = context.options[0]; - const multiline = option !== "never"; - const allowSingleLine = option === "always-multiline"; - - //-------------------------------------------------------------------------- - // Public - //-------------------------------------------------------------------------- - - return { - ConditionalExpression(node) { - const questionToken = sourceCode.getTokenAfter(node.test, astUtils.isNotClosingParenToken); - const colonToken = sourceCode.getTokenAfter(node.consequent, astUtils.isNotClosingParenToken); - - const firstTokenOfTest = sourceCode.getFirstToken(node); - const lastTokenOfTest = sourceCode.getTokenBefore(questionToken); - const firstTokenOfConsequent = sourceCode.getTokenAfter(questionToken); - const lastTokenOfConsequent = sourceCode.getTokenBefore(colonToken); - const firstTokenOfAlternate = sourceCode.getTokenAfter(colonToken); - - const areTestAndConsequentOnSameLine = astUtils.isTokenOnSameLine(lastTokenOfTest, firstTokenOfConsequent); - const areConsequentAndAlternateOnSameLine = astUtils.isTokenOnSameLine(lastTokenOfConsequent, firstTokenOfAlternate); - - const hasComments = !!sourceCode.getCommentsInside(node).length; - - if (!multiline) { - if (!areTestAndConsequentOnSameLine) { - context.report({ - node: node.test, - loc: { - start: firstTokenOfTest.loc.start, - end: lastTokenOfTest.loc.end - }, - messageId: "unexpectedTestCons", - fix(fixer) { - if (hasComments) { - return null; - } - const fixers = []; - const areTestAndQuestionOnSameLine = astUtils.isTokenOnSameLine(lastTokenOfTest, questionToken); - const areQuestionAndConsOnSameLine = astUtils.isTokenOnSameLine(questionToken, firstTokenOfConsequent); - - if (!areTestAndQuestionOnSameLine) { - fixers.push(fixer.removeRange([lastTokenOfTest.range[1], questionToken.range[0]])); - } - if (!areQuestionAndConsOnSameLine) { - fixers.push(fixer.removeRange([questionToken.range[1], firstTokenOfConsequent.range[0]])); - } - - return fixers; - } - }); - } - - if (!areConsequentAndAlternateOnSameLine) { - context.report({ - node: node.consequent, - loc: { - start: firstTokenOfConsequent.loc.start, - end: lastTokenOfConsequent.loc.end - }, - messageId: "unexpectedConsAlt", - fix(fixer) { - if (hasComments) { - return null; - } - const fixers = []; - const areConsAndColonOnSameLine = astUtils.isTokenOnSameLine(lastTokenOfConsequent, colonToken); - const areColonAndAltOnSameLine = astUtils.isTokenOnSameLine(colonToken, firstTokenOfAlternate); - - if (!areConsAndColonOnSameLine) { - fixers.push(fixer.removeRange([lastTokenOfConsequent.range[1], colonToken.range[0]])); - } - if (!areColonAndAltOnSameLine) { - fixers.push(fixer.removeRange([colonToken.range[1], firstTokenOfAlternate.range[0]])); - } - - return fixers; - } - }); - } - } else { - if (allowSingleLine && node.loc.start.line === node.loc.end.line) { - return; - } - - if (areTestAndConsequentOnSameLine) { - context.report({ - node: node.test, - loc: { - start: firstTokenOfTest.loc.start, - end: lastTokenOfTest.loc.end - }, - messageId: "expectedTestCons", - fix: fixer => (hasComments ? null : ( - fixer.replaceTextRange( - [ - lastTokenOfTest.range[1], - questionToken.range[0] - ], - "\n" - ) - )) - }); - } - - if (areConsequentAndAlternateOnSameLine) { - context.report({ - node: node.consequent, - loc: { - start: firstTokenOfConsequent.loc.start, - end: lastTokenOfConsequent.loc.end - }, - messageId: "expectedConsAlt", - fix: (fixer => (hasComments ? null : ( - fixer.replaceTextRange( - [ - lastTokenOfConsequent.range[1], - colonToken.range[0] - ], - "\n" - ) - ))) - }); - } - } - } - }; - } -}; diff --git a/tools/eslint/node_modules/eslint/lib/rules/new-cap.js b/tools/eslint/node_modules/eslint/lib/rules/new-cap.js deleted file mode 100644 index 638e64c0a2283a..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/rules/new-cap.js +++ /dev/null @@ -1,276 +0,0 @@ -/** - * @fileoverview Rule to flag use of constructors without capital letters - * @author Nicholas C. Zakas - */ - -"use strict"; - -//------------------------------------------------------------------------------ -// Requirements -//------------------------------------------------------------------------------ - -const astUtils = require("./utils/ast-utils"); - -//------------------------------------------------------------------------------ -// Helpers -//------------------------------------------------------------------------------ - -const CAPS_ALLOWED = [ - "Array", - "Boolean", - "Date", - "Error", - "Function", - "Number", - "Object", - "RegExp", - "String", - "Symbol", - "BigInt" -]; - -/** - * Ensure that if the key is provided, it must be an array. - * @param {Object} obj Object to check with `key`. - * @param {string} key Object key to check on `obj`. - * @param {any} fallback If obj[key] is not present, this will be returned. - * @throws {TypeError} If key is not an own array type property of `obj`. - * @returns {string[]} Returns obj[key] if it's an Array, otherwise `fallback` - */ -function checkArray(obj, key, fallback) { - - /* c8 ignore start */ - if (Object.hasOwn(obj, key) && !Array.isArray(obj[key])) { - throw new TypeError(`${key}, if provided, must be an Array`); - }/* c8 ignore stop */ - return obj[key] || fallback; -} - -/** - * A reducer function to invert an array to an Object mapping the string form of the key, to `true`. - * @param {Object} map Accumulator object for the reduce. - * @param {string} key Object key to set to `true`. - * @returns {Object} Returns the updated Object for further reduction. - */ -function invert(map, key) { - map[key] = true; - return map; -} - -/** - * Creates an object with the cap is new exceptions as its keys and true as their values. - * @param {Object} config Rule configuration - * @returns {Object} Object with cap is new exceptions. - */ -function calculateCapIsNewExceptions(config) { - let capIsNewExceptions = checkArray(config, "capIsNewExceptions", CAPS_ALLOWED); - - if (capIsNewExceptions !== CAPS_ALLOWED) { - capIsNewExceptions = capIsNewExceptions.concat(CAPS_ALLOWED); - } - - return capIsNewExceptions.reduce(invert, {}); -} - -//------------------------------------------------------------------------------ -// Rule Definition -//------------------------------------------------------------------------------ - -/** @type {import('../shared/types').Rule} */ -module.exports = { - meta: { - type: "suggestion", - - docs: { - description: "Require constructor names to begin with a capital letter", - recommended: false, - url: "https://eslint.org/docs/latest/rules/new-cap" - }, - - schema: [ - { - type: "object", - properties: { - newIsCap: { - type: "boolean", - default: true - }, - capIsNew: { - type: "boolean", - default: true - }, - newIsCapExceptions: { - type: "array", - items: { - type: "string" - } - }, - newIsCapExceptionPattern: { - type: "string" - }, - capIsNewExceptions: { - type: "array", - items: { - type: "string" - } - }, - capIsNewExceptionPattern: { - type: "string" - }, - properties: { - type: "boolean", - default: true - } - }, - additionalProperties: false - } - ], - messages: { - upper: "A function with a name starting with an uppercase letter should only be used as a constructor.", - lower: "A constructor name should not start with a lowercase letter." - } - }, - - create(context) { - - const config = Object.assign({}, context.options[0]); - - config.newIsCap = config.newIsCap !== false; - config.capIsNew = config.capIsNew !== false; - const skipProperties = config.properties === false; - - const newIsCapExceptions = checkArray(config, "newIsCapExceptions", []).reduce(invert, {}); - const newIsCapExceptionPattern = config.newIsCapExceptionPattern ? new RegExp(config.newIsCapExceptionPattern, "u") : null; - - const capIsNewExceptions = calculateCapIsNewExceptions(config); - const capIsNewExceptionPattern = config.capIsNewExceptionPattern ? new RegExp(config.capIsNewExceptionPattern, "u") : null; - - const listeners = {}; - - const sourceCode = context.sourceCode; - - //-------------------------------------------------------------------------- - // Helpers - //-------------------------------------------------------------------------- - - /** - * Get exact callee name from expression - * @param {ASTNode} node CallExpression or NewExpression node - * @returns {string} name - */ - function extractNameFromExpression(node) { - return node.callee.type === "Identifier" - ? node.callee.name - : astUtils.getStaticPropertyName(node.callee) || ""; - } - - /** - * Returns the capitalization state of the string - - * Whether the first character is uppercase, lowercase, or non-alphabetic - * @param {string} str String - * @returns {string} capitalization state: "non-alpha", "lower", or "upper" - */ - function getCap(str) { - const firstChar = str.charAt(0); - - const firstCharLower = firstChar.toLowerCase(); - const firstCharUpper = firstChar.toUpperCase(); - - if (firstCharLower === firstCharUpper) { - - // char has no uppercase variant, so it's non-alphabetic - return "non-alpha"; - } - if (firstChar === firstCharLower) { - return "lower"; - } - return "upper"; - - } - - /** - * Check if capitalization is allowed for a CallExpression - * @param {Object} allowedMap Object mapping calleeName to a Boolean - * @param {ASTNode} node CallExpression node - * @param {string} calleeName Capitalized callee name from a CallExpression - * @param {Object} pattern RegExp object from options pattern - * @returns {boolean} Returns true if the callee may be capitalized - */ - function isCapAllowed(allowedMap, node, calleeName, pattern) { - const sourceText = sourceCode.getText(node.callee); - - if (allowedMap[calleeName] || allowedMap[sourceText]) { - return true; - } - - if (pattern && pattern.test(sourceText)) { - return true; - } - - const callee = astUtils.skipChainExpression(node.callee); - - if (calleeName === "UTC" && callee.type === "MemberExpression") { - - // allow if callee is Date.UTC - return callee.object.type === "Identifier" && - callee.object.name === "Date"; - } - - return skipProperties && callee.type === "MemberExpression"; - } - - /** - * Reports the given messageId for the given node. The location will be the start of the property or the callee. - * @param {ASTNode} node CallExpression or NewExpression node. - * @param {string} messageId The messageId to report. - * @returns {void} - */ - function report(node, messageId) { - let callee = astUtils.skipChainExpression(node.callee); - - if (callee.type === "MemberExpression") { - callee = callee.property; - } - - context.report({ node, loc: callee.loc, messageId }); - } - - //-------------------------------------------------------------------------- - // Public - //-------------------------------------------------------------------------- - - if (config.newIsCap) { - listeners.NewExpression = function(node) { - - const constructorName = extractNameFromExpression(node); - - if (constructorName) { - const capitalization = getCap(constructorName); - const isAllowed = capitalization !== "lower" || isCapAllowed(newIsCapExceptions, node, constructorName, newIsCapExceptionPattern); - - if (!isAllowed) { - report(node, "lower"); - } - } - }; - } - - if (config.capIsNew) { - listeners.CallExpression = function(node) { - - const calleeName = extractNameFromExpression(node); - - if (calleeName) { - const capitalization = getCap(calleeName); - const isAllowed = capitalization !== "upper" || isCapAllowed(capIsNewExceptions, node, calleeName, capIsNewExceptionPattern); - - if (!isAllowed) { - report(node, "upper"); - } - } - }; - } - - return listeners; - } -}; diff --git a/tools/eslint/node_modules/eslint/lib/rules/new-parens.js b/tools/eslint/node_modules/eslint/lib/rules/new-parens.js deleted file mode 100644 index 1c5d21d4a0c5a0..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/rules/new-parens.js +++ /dev/null @@ -1,93 +0,0 @@ -/** - * @fileoverview Rule to flag when using constructor without parentheses - * @author Ilya Volodin - * @deprecated in ESLint v8.53.0 - */ - -"use strict"; - -//------------------------------------------------------------------------------ -// Requirements -//------------------------------------------------------------------------------ - -const astUtils = require("./utils/ast-utils"); - -//------------------------------------------------------------------------------ -// Helpers -//------------------------------------------------------------------------------ - -//------------------------------------------------------------------------------ -// Rule Definition -//------------------------------------------------------------------------------ - -/** @type {import('../shared/types').Rule} */ -module.exports = { - meta: { - deprecated: true, - replacedBy: [], - type: "layout", - - docs: { - description: "Enforce or disallow parentheses when invoking a constructor with no arguments", - recommended: false, - url: "https://eslint.org/docs/latest/rules/new-parens" - }, - - fixable: "code", - schema: [ - { - enum: ["always", "never"] - } - ], - messages: { - missing: "Missing '()' invoking a constructor.", - unnecessary: "Unnecessary '()' invoking a constructor with no arguments." - } - }, - - create(context) { - const options = context.options; - const always = options[0] !== "never"; // Default is always - - const sourceCode = context.sourceCode; - - return { - NewExpression(node) { - if (node.arguments.length !== 0) { - return; // if there are arguments, there have to be parens - } - - const lastToken = sourceCode.getLastToken(node); - const hasLastParen = lastToken && astUtils.isClosingParenToken(lastToken); - - // `hasParens` is true only if the new expression ends with its own parens, e.g., new new foo() does not end with its own parens - const hasParens = hasLastParen && - astUtils.isOpeningParenToken(sourceCode.getTokenBefore(lastToken)) && - node.callee.range[1] < node.range[1]; - - if (always) { - if (!hasParens) { - context.report({ - node, - messageId: "missing", - fix: fixer => fixer.insertTextAfter(node, "()") - }); - } - } else { - if (hasParens) { - context.report({ - node, - messageId: "unnecessary", - fix: fixer => [ - fixer.remove(sourceCode.getTokenBefore(lastToken)), - fixer.remove(lastToken), - fixer.insertTextBefore(node, "("), - fixer.insertTextAfter(node, ")") - ] - }); - } - } - } - }; - } -}; diff --git a/tools/eslint/node_modules/eslint/lib/rules/newline-after-var.js b/tools/eslint/node_modules/eslint/lib/rules/newline-after-var.js deleted file mode 100644 index 6e4476412d9966..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/rules/newline-after-var.js +++ /dev/null @@ -1,253 +0,0 @@ -/** - * @fileoverview Rule to check empty newline after "var" statement - * @author Gopal Venkatesan - * @deprecated in ESLint v4.0.0 - */ - -"use strict"; - -//------------------------------------------------------------------------------ -// Requirements -//------------------------------------------------------------------------------ - -const astUtils = require("./utils/ast-utils"); - -//------------------------------------------------------------------------------ -// Rule Definition -//------------------------------------------------------------------------------ - -/** @type {import('../shared/types').Rule} */ -module.exports = { - meta: { - type: "layout", - - docs: { - description: "Require or disallow an empty line after variable declarations", - recommended: false, - url: "https://eslint.org/docs/latest/rules/newline-after-var" - }, - schema: [ - { - enum: ["never", "always"] - } - ], - fixable: "whitespace", - messages: { - expected: "Expected blank line after variable declarations.", - unexpected: "Unexpected blank line after variable declarations." - }, - - deprecated: true, - - replacedBy: ["padding-line-between-statements"] - }, - - create(context) { - const sourceCode = context.sourceCode; - - // Default `mode` to "always". - const mode = context.options[0] === "never" ? "never" : "always"; - - // Cache starting and ending line numbers of comments for faster lookup - const commentEndLine = sourceCode.getAllComments().reduce((result, token) => { - result[token.loc.start.line] = token.loc.end.line; - return result; - }, {}); - - - //-------------------------------------------------------------------------- - // Helpers - //-------------------------------------------------------------------------- - - /** - * Gets a token from the given node to compare line to the next statement. - * - * In general, the token is the last token of the node. However, the token is the second last token if the following conditions satisfy. - * - * - The last token is semicolon. - * - The semicolon is on a different line from the previous token of the semicolon. - * - * This behavior would address semicolon-less style code. e.g.: - * - * var foo = 1 - * - * ;(a || b).doSomething() - * @param {ASTNode} node The node to get. - * @returns {Token} The token to compare line to the next statement. - */ - function getLastToken(node) { - const lastToken = sourceCode.getLastToken(node); - - if (lastToken.type === "Punctuator" && lastToken.value === ";") { - const prevToken = sourceCode.getTokenBefore(lastToken); - - if (prevToken.loc.end.line !== lastToken.loc.start.line) { - return prevToken; - } - } - - return lastToken; - } - - /** - * Determine if provided keyword is a variable declaration - * @private - * @param {string} keyword keyword to test - * @returns {boolean} True if `keyword` is a type of var - */ - function isVar(keyword) { - return keyword === "var" || keyword === "let" || keyword === "const"; - } - - /** - * Determine if provided keyword is a variant of for specifiers - * @private - * @param {string} keyword keyword to test - * @returns {boolean} True if `keyword` is a variant of for specifier - */ - function isForTypeSpecifier(keyword) { - return keyword === "ForStatement" || keyword === "ForInStatement" || keyword === "ForOfStatement"; - } - - /** - * Determine if provided keyword is an export specifiers - * @private - * @param {string} nodeType nodeType to test - * @returns {boolean} True if `nodeType` is an export specifier - */ - function isExportSpecifier(nodeType) { - return nodeType === "ExportNamedDeclaration" || nodeType === "ExportSpecifier" || - nodeType === "ExportDefaultDeclaration" || nodeType === "ExportAllDeclaration"; - } - - /** - * Determine if provided node is the last of their parent block. - * @private - * @param {ASTNode} node node to test - * @returns {boolean} True if `node` is last of their parent block. - */ - function isLastNode(node) { - const token = sourceCode.getTokenAfter(node); - - return !token || (token.type === "Punctuator" && token.value === "}"); - } - - /** - * Gets the last line of a group of consecutive comments - * @param {number} commentStartLine The starting line of the group - * @returns {number} The number of the last comment line of the group - */ - function getLastCommentLineOfBlock(commentStartLine) { - const currentCommentEnd = commentEndLine[commentStartLine]; - - return commentEndLine[currentCommentEnd + 1] ? getLastCommentLineOfBlock(currentCommentEnd + 1) : currentCommentEnd; - } - - /** - * Determine if a token starts more than one line after a comment ends - * @param {token} token The token being checked - * @param {integer} commentStartLine The line number on which the comment starts - * @returns {boolean} True if `token` does not start immediately after a comment - */ - function hasBlankLineAfterComment(token, commentStartLine) { - return token.loc.start.line > getLastCommentLineOfBlock(commentStartLine) + 1; - } - - /** - * Checks that a blank line exists after a variable declaration when mode is - * set to "always", or checks that there is no blank line when mode is set - * to "never" - * @private - * @param {ASTNode} node `VariableDeclaration` node to test - * @returns {void} - */ - function checkForBlankLine(node) { - - /* - * lastToken is the last token on the node's line. It will usually also be the last token of the node, but it will - * sometimes be second-last if there is a semicolon on a different line. - */ - const lastToken = getLastToken(node), - - /* - * If lastToken is the last token of the node, nextToken should be the token after the node. Otherwise, nextToken - * is the last token of the node. - */ - nextToken = lastToken === sourceCode.getLastToken(node) ? sourceCode.getTokenAfter(node) : sourceCode.getLastToken(node), - nextLineNum = lastToken.loc.end.line + 1; - - // Ignore if there is no following statement - if (!nextToken) { - return; - } - - // Ignore if parent of node is a for variant - if (isForTypeSpecifier(node.parent.type)) { - return; - } - - // Ignore if parent of node is an export specifier - if (isExportSpecifier(node.parent.type)) { - return; - } - - /* - * Some coding styles use multiple `var` statements, so do nothing if - * the next token is a `var` statement. - */ - if (nextToken.type === "Keyword" && isVar(nextToken.value)) { - return; - } - - // Ignore if it is last statement in a block - if (isLastNode(node)) { - return; - } - - // Next statement is not a `var`... - const noNextLineToken = nextToken.loc.start.line > nextLineNum; - const hasNextLineComment = (typeof commentEndLine[nextLineNum] !== "undefined"); - - if (mode === "never" && noNextLineToken && !hasNextLineComment) { - context.report({ - node, - messageId: "unexpected", - fix(fixer) { - const linesBetween = sourceCode.getText().slice(lastToken.range[1], nextToken.range[0]).split(astUtils.LINEBREAK_MATCHER); - - return fixer.replaceTextRange([lastToken.range[1], nextToken.range[0]], `${linesBetween.slice(0, -1).join("")}\n${linesBetween.at(-1)}`); - } - }); - } - - // Token on the next line, or comment without blank line - if ( - mode === "always" && ( - !noNextLineToken || - hasNextLineComment && !hasBlankLineAfterComment(nextToken, nextLineNum) - ) - ) { - context.report({ - node, - messageId: "expected", - fix(fixer) { - if ((noNextLineToken ? getLastCommentLineOfBlock(nextLineNum) : lastToken.loc.end.line) === nextToken.loc.start.line) { - return fixer.insertTextBefore(nextToken, "\n\n"); - } - - return fixer.insertTextBeforeRange([nextToken.range[0] - nextToken.loc.start.column, nextToken.range[1]], "\n"); - } - }); - } - } - - //-------------------------------------------------------------------------- - // Public - //-------------------------------------------------------------------------- - - return { - VariableDeclaration: checkForBlankLine - }; - - } -}; diff --git a/tools/eslint/node_modules/eslint/lib/rules/newline-before-return.js b/tools/eslint/node_modules/eslint/lib/rules/newline-before-return.js deleted file mode 100644 index 21e9faf1492b93..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/rules/newline-before-return.js +++ /dev/null @@ -1,217 +0,0 @@ -/** - * @fileoverview Rule to require newlines before `return` statement - * @author Kai Cataldo - * @deprecated in ESLint v4.0.0 - */ -"use strict"; - -//------------------------------------------------------------------------------ -// Rule Definition -//------------------------------------------------------------------------------ - -/** @type {import('../shared/types').Rule} */ -module.exports = { - meta: { - type: "layout", - - docs: { - description: "Require an empty line before `return` statements", - recommended: false, - url: "https://eslint.org/docs/latest/rules/newline-before-return" - }, - - fixable: "whitespace", - schema: [], - messages: { - expected: "Expected newline before return statement." - }, - - deprecated: true, - replacedBy: ["padding-line-between-statements"] - }, - - create(context) { - const sourceCode = context.sourceCode; - - //-------------------------------------------------------------------------- - // Helpers - //-------------------------------------------------------------------------- - - /** - * Tests whether node is preceded by supplied tokens - * @param {ASTNode} node node to check - * @param {Array} testTokens array of tokens to test against - * @returns {boolean} Whether or not the node is preceded by one of the supplied tokens - * @private - */ - function isPrecededByTokens(node, testTokens) { - const tokenBefore = sourceCode.getTokenBefore(node); - - return testTokens.includes(tokenBefore.value); - } - - /** - * Checks whether node is the first node after statement or in block - * @param {ASTNode} node node to check - * @returns {boolean} Whether or not the node is the first node after statement or in block - * @private - */ - function isFirstNode(node) { - const parentType = node.parent.type; - - if (node.parent.body) { - return Array.isArray(node.parent.body) - ? node.parent.body[0] === node - : node.parent.body === node; - } - - if (parentType === "IfStatement") { - return isPrecededByTokens(node, ["else", ")"]); - } - if (parentType === "DoWhileStatement") { - return isPrecededByTokens(node, ["do"]); - } - if (parentType === "SwitchCase") { - return isPrecededByTokens(node, [":"]); - } - return isPrecededByTokens(node, [")"]); - - } - - /** - * Returns the number of lines of comments that precede the node - * @param {ASTNode} node node to check for overlapping comments - * @param {number} lineNumTokenBefore line number of previous token, to check for overlapping comments - * @returns {number} Number of lines of comments that precede the node - * @private - */ - function calcCommentLines(node, lineNumTokenBefore) { - const comments = sourceCode.getCommentsBefore(node); - let numLinesComments = 0; - - if (!comments.length) { - return numLinesComments; - } - - comments.forEach(comment => { - numLinesComments++; - - if (comment.type === "Block") { - numLinesComments += comment.loc.end.line - comment.loc.start.line; - } - - // avoid counting lines with inline comments twice - if (comment.loc.start.line === lineNumTokenBefore) { - numLinesComments--; - } - - if (comment.loc.end.line === node.loc.start.line) { - numLinesComments--; - } - }); - - return numLinesComments; - } - - /** - * Returns the line number of the token before the node that is passed in as an argument - * @param {ASTNode} node The node to use as the start of the calculation - * @returns {number} Line number of the token before `node` - * @private - */ - function getLineNumberOfTokenBefore(node) { - const tokenBefore = sourceCode.getTokenBefore(node); - let lineNumTokenBefore; - - /** - * Global return (at the beginning of a script) is a special case. - * If there is no token before `return`, then we expect no line - * break before the return. Comments are allowed to occupy lines - * before the global return, just no blank lines. - * Setting lineNumTokenBefore to zero in that case results in the - * desired behavior. - */ - if (tokenBefore) { - lineNumTokenBefore = tokenBefore.loc.end.line; - } else { - lineNumTokenBefore = 0; // global return at beginning of script - } - - return lineNumTokenBefore; - } - - /** - * Checks whether node is preceded by a newline - * @param {ASTNode} node node to check - * @returns {boolean} Whether or not the node is preceded by a newline - * @private - */ - function hasNewlineBefore(node) { - const lineNumNode = node.loc.start.line; - const lineNumTokenBefore = getLineNumberOfTokenBefore(node); - const commentLines = calcCommentLines(node, lineNumTokenBefore); - - return (lineNumNode - lineNumTokenBefore - commentLines) > 1; - } - - /** - * Checks whether it is safe to apply a fix to a given return statement. - * - * The fix is not considered safe if the given return statement has leading comments, - * as we cannot safely determine if the newline should be added before or after the comments. - * For more information, see: https://github.com/eslint/eslint/issues/5958#issuecomment-222767211 - * @param {ASTNode} node The return statement node to check. - * @returns {boolean} `true` if it can fix the node. - * @private - */ - function canFix(node) { - const leadingComments = sourceCode.getCommentsBefore(node); - const lastLeadingComment = leadingComments.at(-1); - const tokenBefore = sourceCode.getTokenBefore(node); - - if (leadingComments.length === 0) { - return true; - } - - /* - * if the last leading comment ends in the same line as the previous token and - * does not share a line with the `return` node, we can consider it safe to fix. - * Example: - * function a() { - * var b; //comment - * return; - * } - */ - if (lastLeadingComment.loc.end.line === tokenBefore.loc.end.line && - lastLeadingComment.loc.end.line !== node.loc.start.line) { - return true; - } - - return false; - } - - //-------------------------------------------------------------------------- - // Public - //-------------------------------------------------------------------------- - - return { - ReturnStatement(node) { - if (!isFirstNode(node) && !hasNewlineBefore(node)) { - context.report({ - node, - messageId: "expected", - fix(fixer) { - if (canFix(node)) { - const tokenBefore = sourceCode.getTokenBefore(node); - const newlines = node.loc.start.line === tokenBefore.loc.end.line ? "\n\n" : "\n"; - - return fixer.insertTextBefore(node, newlines); - } - return null; - } - }); - } - } - }; - } -}; diff --git a/tools/eslint/node_modules/eslint/lib/rules/newline-per-chained-call.js b/tools/eslint/node_modules/eslint/lib/rules/newline-per-chained-call.js deleted file mode 100644 index 3124ac2d19f7f8..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/rules/newline-per-chained-call.js +++ /dev/null @@ -1,126 +0,0 @@ -/** - * @fileoverview Rule to ensure newline per method call when chaining calls - * @author Rajendra Patil - * @author Burak Yigit Kaya - * @deprecated in ESLint v8.53.0 - */ - -"use strict"; - -const astUtils = require("./utils/ast-utils"); - -//------------------------------------------------------------------------------ -// Rule Definition -//------------------------------------------------------------------------------ - -/** @type {import('../shared/types').Rule} */ -module.exports = { - meta: { - deprecated: true, - replacedBy: [], - type: "layout", - - docs: { - description: "Require a newline after each call in a method chain", - recommended: false, - url: "https://eslint.org/docs/latest/rules/newline-per-chained-call" - }, - - fixable: "whitespace", - - schema: [{ - type: "object", - properties: { - ignoreChainWithDepth: { - type: "integer", - minimum: 1, - maximum: 10, - default: 2 - } - }, - additionalProperties: false - }], - messages: { - expected: "Expected line break before `{{callee}}`." - } - }, - - create(context) { - - const options = context.options[0] || {}, - ignoreChainWithDepth = options.ignoreChainWithDepth || 2; - - const sourceCode = context.sourceCode; - - /** - * Get the prefix of a given MemberExpression node. - * If the MemberExpression node is a computed value it returns a - * left bracket. If not it returns a period. - * @param {ASTNode} node A MemberExpression node to get - * @returns {string} The prefix of the node. - */ - function getPrefix(node) { - if (node.computed) { - if (node.optional) { - return "?.["; - } - return "["; - } - if (node.optional) { - return "?."; - } - return "."; - } - - /** - * Gets the property text of a given MemberExpression node. - * If the text is multiline, this returns only the first line. - * @param {ASTNode} node A MemberExpression node to get. - * @returns {string} The property text of the node. - */ - function getPropertyText(node) { - const prefix = getPrefix(node); - const lines = sourceCode.getText(node.property).split(astUtils.LINEBREAK_MATCHER); - const suffix = node.computed && lines.length === 1 ? "]" : ""; - - return prefix + lines[0] + suffix; - } - - return { - "CallExpression:exit"(node) { - const callee = astUtils.skipChainExpression(node.callee); - - if (callee.type !== "MemberExpression") { - return; - } - - let parent = astUtils.skipChainExpression(callee.object); - let depth = 1; - - while (parent && parent.callee) { - depth += 1; - parent = astUtils.skipChainExpression(astUtils.skipChainExpression(parent.callee).object); - } - - if (depth > ignoreChainWithDepth && astUtils.isTokenOnSameLine(callee.object, callee.property)) { - const firstTokenAfterObject = sourceCode.getTokenAfter(callee.object, astUtils.isNotClosingParenToken); - - context.report({ - node: callee.property, - loc: { - start: firstTokenAfterObject.loc.start, - end: callee.loc.end - }, - messageId: "expected", - data: { - callee: getPropertyText(callee) - }, - fix(fixer) { - return fixer.insertTextBefore(firstTokenAfterObject, "\n"); - } - }); - } - } - }; - } -}; diff --git a/tools/eslint/node_modules/eslint/lib/rules/no-alert.js b/tools/eslint/node_modules/eslint/lib/rules/no-alert.js deleted file mode 100644 index cc8728565015c0..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/rules/no-alert.js +++ /dev/null @@ -1,138 +0,0 @@ -/** - * @fileoverview Rule to flag use of alert, confirm, prompt - * @author Nicholas C. Zakas - */ -"use strict"; - -//------------------------------------------------------------------------------ -// Requirements -//------------------------------------------------------------------------------ - -const { - getStaticPropertyName: getPropertyName, - getVariableByName, - skipChainExpression -} = require("./utils/ast-utils"); - -//------------------------------------------------------------------------------ -// Helpers -//------------------------------------------------------------------------------ - -/** - * Checks if the given name is a prohibited identifier. - * @param {string} name The name to check - * @returns {boolean} Whether or not the name is prohibited. - */ -function isProhibitedIdentifier(name) { - return /^(alert|confirm|prompt)$/u.test(name); -} - -/** - * Finds the eslint-scope reference in the given scope. - * @param {Object} scope The scope to search. - * @param {ASTNode} node The identifier node. - * @returns {Reference|null} Returns the found reference or null if none were found. - */ -function findReference(scope, node) { - const references = scope.references.filter(reference => reference.identifier.range[0] === node.range[0] && - reference.identifier.range[1] === node.range[1]); - - if (references.length === 1) { - return references[0]; - } - return null; -} - -/** - * Checks if the given identifier node is shadowed in the given scope. - * @param {Object} scope The current scope. - * @param {string} node The identifier node to check - * @returns {boolean} Whether or not the name is shadowed. - */ -function isShadowed(scope, node) { - const reference = findReference(scope, node); - - return reference && reference.resolved && reference.resolved.defs.length > 0; -} - -/** - * Checks if the given identifier node is a ThisExpression in the global scope or the global window property. - * @param {Object} scope The current scope. - * @param {string} node The identifier node to check - * @returns {boolean} Whether or not the node is a reference to the global object. - */ -function isGlobalThisReferenceOrGlobalWindow(scope, node) { - if (scope.type === "global" && node.type === "ThisExpression") { - return true; - } - if ( - node.type === "Identifier" && - ( - node.name === "window" || - (node.name === "globalThis" && getVariableByName(scope, "globalThis")) - ) - ) { - return !isShadowed(scope, node); - } - - return false; -} - -//------------------------------------------------------------------------------ -// Rule Definition -//------------------------------------------------------------------------------ - -/** @type {import('../shared/types').Rule} */ -module.exports = { - meta: { - type: "suggestion", - - docs: { - description: "Disallow the use of `alert`, `confirm`, and `prompt`", - recommended: false, - url: "https://eslint.org/docs/latest/rules/no-alert" - }, - - schema: [], - - messages: { - unexpected: "Unexpected {{name}}." - } - }, - - create(context) { - const sourceCode = context.sourceCode; - - return { - CallExpression(node) { - const callee = skipChainExpression(node.callee), - currentScope = sourceCode.getScope(node); - - // without window. - if (callee.type === "Identifier") { - const name = callee.name; - - if (!isShadowed(currentScope, callee) && isProhibitedIdentifier(callee.name)) { - context.report({ - node, - messageId: "unexpected", - data: { name } - }); - } - - } else if (callee.type === "MemberExpression" && isGlobalThisReferenceOrGlobalWindow(currentScope, callee.object)) { - const name = getPropertyName(callee); - - if (isProhibitedIdentifier(name)) { - context.report({ - node, - messageId: "unexpected", - data: { name } - }); - } - } - } - }; - - } -}; diff --git a/tools/eslint/node_modules/eslint/lib/rules/no-array-constructor.js b/tools/eslint/node_modules/eslint/lib/rules/no-array-constructor.js deleted file mode 100644 index f56b6876674ccf..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/rules/no-array-constructor.js +++ /dev/null @@ -1,133 +0,0 @@ -/** - * @fileoverview Disallow construction of dense arrays using the Array constructor - * @author Matt DuVall - */ - -"use strict"; - -//------------------------------------------------------------------------------ -// Requirements -//------------------------------------------------------------------------------ - -const { - getVariableByName, - isClosingParenToken, - isOpeningParenToken, - isStartOfExpressionStatement, - needsPrecedingSemicolon -} = require("./utils/ast-utils"); - -//------------------------------------------------------------------------------ -// Rule Definition -//------------------------------------------------------------------------------ - -/** @type {import('../shared/types').Rule} */ -module.exports = { - meta: { - type: "suggestion", - - docs: { - description: "Disallow `Array` constructors", - recommended: false, - url: "https://eslint.org/docs/latest/rules/no-array-constructor" - }, - - hasSuggestions: true, - - schema: [], - - messages: { - preferLiteral: "The array literal notation [] is preferable.", - useLiteral: "Replace with an array literal.", - useLiteralAfterSemicolon: "Replace with an array literal, add preceding semicolon." - } - }, - - create(context) { - - const sourceCode = context.sourceCode; - - /** - * Gets the text between the calling parentheses of a CallExpression or NewExpression. - * @param {ASTNode} node A CallExpression or NewExpression node. - * @returns {string} The text between the calling parentheses, or an empty string if there are none. - */ - function getArgumentsText(node) { - const lastToken = sourceCode.getLastToken(node); - - if (!isClosingParenToken(lastToken)) { - return ""; - } - - let firstToken = node.callee; - - do { - firstToken = sourceCode.getTokenAfter(firstToken); - if (!firstToken || firstToken === lastToken) { - return ""; - } - } while (!isOpeningParenToken(firstToken)); - - return sourceCode.text.slice(firstToken.range[1], lastToken.range[0]); - } - - /** - * Disallow construction of dense arrays using the Array constructor - * @param {ASTNode} node node to evaluate - * @returns {void} - * @private - */ - function check(node) { - if ( - node.callee.type !== "Identifier" || - node.callee.name !== "Array" || - node.arguments.length === 1 && - node.arguments[0].type !== "SpreadElement") { - return; - } - - const variable = getVariableByName(sourceCode.getScope(node), "Array"); - - /* - * Check if `Array` is a predefined global variable: predefined globals have no declarations, - * meaning that the `identifiers` list of the variable object is empty. - */ - if (variable && variable.identifiers.length === 0) { - const argsText = getArgumentsText(node); - let fixText; - let messageId; - - /* - * Check if the suggested change should include a preceding semicolon or not. - * Due to JavaScript's ASI rules, a missing semicolon may be inserted automatically - * before an expression like `Array()` or `new Array()`, but not when the expression - * is changed into an array literal like `[]`. - */ - if (isStartOfExpressionStatement(node) && needsPrecedingSemicolon(sourceCode, node)) { - fixText = `;[${argsText}]`; - messageId = "useLiteralAfterSemicolon"; - } else { - fixText = `[${argsText}]`; - messageId = "useLiteral"; - } - - context.report({ - node, - messageId: "preferLiteral", - suggest: [ - { - messageId, - fix: fixer => fixer.replaceText(node, fixText) - } - ] - }); - } - } - - return { - CallExpression: check, - NewExpression: check - }; - - } -}; diff --git a/tools/eslint/node_modules/eslint/lib/rules/no-async-promise-executor.js b/tools/eslint/node_modules/eslint/lib/rules/no-async-promise-executor.js deleted file mode 100644 index ea6c851147cb21..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/rules/no-async-promise-executor.js +++ /dev/null @@ -1,39 +0,0 @@ -/** - * @fileoverview disallow using an async function as a Promise executor - * @author Teddy Katz - */ -"use strict"; - -//------------------------------------------------------------------------------ -// Rule Definition -//------------------------------------------------------------------------------ - -/** @type {import('../shared/types').Rule} */ -module.exports = { - meta: { - type: "problem", - - docs: { - description: "Disallow using an async function as a Promise executor", - recommended: true, - url: "https://eslint.org/docs/latest/rules/no-async-promise-executor" - }, - - fixable: null, - schema: [], - messages: { - async: "Promise executor functions should not be async." - } - }, - - create(context) { - return { - "NewExpression[callee.name='Promise'][arguments.0.async=true]"(node) { - context.report({ - node: context.sourceCode.getFirstToken(node.arguments[0], token => token.value === "async"), - messageId: "async" - }); - } - }; - } -}; diff --git a/tools/eslint/node_modules/eslint/lib/rules/no-await-in-loop.js b/tools/eslint/node_modules/eslint/lib/rules/no-await-in-loop.js deleted file mode 100644 index 20230defa626d7..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/rules/no-await-in-loop.js +++ /dev/null @@ -1,106 +0,0 @@ -/** - * @fileoverview Rule to disallow uses of await inside of loops. - * @author Nat Mote (nmote) - */ -"use strict"; - -/** - * Check whether it should stop traversing ancestors at the given node. - * @param {ASTNode} node A node to check. - * @returns {boolean} `true` if it should stop traversing. - */ -function isBoundary(node) { - const t = node.type; - - return ( - t === "FunctionDeclaration" || - t === "FunctionExpression" || - t === "ArrowFunctionExpression" || - - /* - * Don't report the await expressions on for-await-of loop since it's - * asynchronous iteration intentionally. - */ - (t === "ForOfStatement" && node.await === true) - ); -} - -/** - * Check whether the given node is in loop. - * @param {ASTNode} node A node to check. - * @param {ASTNode} parent A parent node to check. - * @returns {boolean} `true` if the node is in loop. - */ -function isLooped(node, parent) { - switch (parent.type) { - case "ForStatement": - return ( - node === parent.test || - node === parent.update || - node === parent.body - ); - - case "ForOfStatement": - case "ForInStatement": - return node === parent.body; - - case "WhileStatement": - case "DoWhileStatement": - return node === parent.test || node === parent.body; - - default: - return false; - } -} - -/** @type {import('../shared/types').Rule} */ -module.exports = { - meta: { - type: "problem", - - docs: { - description: "Disallow `await` inside of loops", - recommended: false, - url: "https://eslint.org/docs/latest/rules/no-await-in-loop" - }, - - schema: [], - - messages: { - unexpectedAwait: "Unexpected `await` inside a loop." - } - }, - create(context) { - - /** - * Validate an await expression. - * @param {ASTNode} awaitNode An AwaitExpression or ForOfStatement node to validate. - * @returns {void} - */ - function validate(awaitNode) { - if (awaitNode.type === "ForOfStatement" && !awaitNode.await) { - return; - } - - let node = awaitNode; - let parent = node.parent; - - while (parent && !isBoundary(parent)) { - if (isLooped(node, parent)) { - context.report({ - node: awaitNode, - messageId: "unexpectedAwait" - }); - return; - } - node = parent; - parent = parent.parent; - } - } - - return { - AwaitExpression: validate, - ForOfStatement: validate - }; - } -}; diff --git a/tools/eslint/node_modules/eslint/lib/rules/no-bitwise.js b/tools/eslint/node_modules/eslint/lib/rules/no-bitwise.js deleted file mode 100644 index d90992b2064d62..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/rules/no-bitwise.js +++ /dev/null @@ -1,119 +0,0 @@ -/** - * @fileoverview Rule to flag bitwise identifiers - * @author Nicholas C. Zakas - */ - -"use strict"; - -/* - * - * Set of bitwise operators. - * - */ -const BITWISE_OPERATORS = [ - "^", "|", "&", "<<", ">>", ">>>", - "^=", "|=", "&=", "<<=", ">>=", ">>>=", - "~" -]; - -//------------------------------------------------------------------------------ -// Rule Definition -//------------------------------------------------------------------------------ - -/** @type {import('../shared/types').Rule} */ -module.exports = { - meta: { - type: "suggestion", - - docs: { - description: "Disallow bitwise operators", - recommended: false, - url: "https://eslint.org/docs/latest/rules/no-bitwise" - }, - - schema: [ - { - type: "object", - properties: { - allow: { - type: "array", - items: { - enum: BITWISE_OPERATORS - }, - uniqueItems: true - }, - int32Hint: { - type: "boolean", - default: false - } - }, - additionalProperties: false - } - ], - - messages: { - unexpected: "Unexpected use of '{{operator}}'." - } - }, - - create(context) { - const options = context.options[0] || {}; - const allowed = options.allow || []; - const int32Hint = options.int32Hint === true; - - /** - * Reports an unexpected use of a bitwise operator. - * @param {ASTNode} node Node which contains the bitwise operator. - * @returns {void} - */ - function report(node) { - context.report({ node, messageId: "unexpected", data: { operator: node.operator } }); - } - - /** - * Checks if the given node has a bitwise operator. - * @param {ASTNode} node The node to check. - * @returns {boolean} Whether or not the node has a bitwise operator. - */ - function hasBitwiseOperator(node) { - return BITWISE_OPERATORS.includes(node.operator); - } - - /** - * Checks if exceptions were provided, e.g. `{ allow: ['~', '|'] }`. - * @param {ASTNode} node The node to check. - * @returns {boolean} Whether or not the node has a bitwise operator. - */ - function allowedOperator(node) { - return allowed.includes(node.operator); - } - - /** - * Checks if the given bitwise operator is used for integer typecasting, i.e. "|0" - * @param {ASTNode} node The node to check. - * @returns {boolean} whether the node is used in integer typecasting. - */ - function isInt32Hint(node) { - return int32Hint && node.operator === "|" && node.right && - node.right.type === "Literal" && node.right.value === 0; - } - - /** - * Report if the given node contains a bitwise operator. - * @param {ASTNode} node The node to check. - * @returns {void} - */ - function checkNodeForBitwiseOperator(node) { - if (hasBitwiseOperator(node) && !allowedOperator(node) && !isInt32Hint(node)) { - report(node); - } - } - - return { - AssignmentExpression: checkNodeForBitwiseOperator, - BinaryExpression: checkNodeForBitwiseOperator, - UnaryExpression: checkNodeForBitwiseOperator - }; - - } -}; diff --git a/tools/eslint/node_modules/eslint/lib/rules/no-buffer-constructor.js b/tools/eslint/node_modules/eslint/lib/rules/no-buffer-constructor.js deleted file mode 100644 index 0b73c7674b614c..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/rules/no-buffer-constructor.js +++ /dev/null @@ -1,50 +0,0 @@ -/** - * @fileoverview disallow use of the Buffer() constructor - * @author Teddy Katz - * @deprecated in ESLint v7.0.0 - */ -"use strict"; - -//------------------------------------------------------------------------------ -// Rule Definition -//------------------------------------------------------------------------------ - -/** @type {import('../shared/types').Rule} */ -module.exports = { - meta: { - deprecated: true, - - replacedBy: [], - - type: "problem", - - docs: { - description: "Disallow use of the `Buffer()` constructor", - recommended: false, - url: "https://eslint.org/docs/latest/rules/no-buffer-constructor" - }, - - schema: [], - - messages: { - deprecated: "{{expr}} is deprecated. Use Buffer.from(), Buffer.alloc(), or Buffer.allocUnsafe() instead." - } - }, - - create(context) { - - //---------------------------------------------------------------------- - // Public - //---------------------------------------------------------------------- - - return { - "CallExpression[callee.name='Buffer'], NewExpression[callee.name='Buffer']"(node) { - context.report({ - node, - messageId: "deprecated", - data: { expr: node.type === "CallExpression" ? "Buffer()" : "new Buffer()" } - }); - } - }; - } -}; diff --git a/tools/eslint/node_modules/eslint/lib/rules/no-caller.js b/tools/eslint/node_modules/eslint/lib/rules/no-caller.js deleted file mode 100644 index 3e61a8e1c2db49..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/rules/no-caller.js +++ /dev/null @@ -1,46 +0,0 @@ -/** - * @fileoverview Rule to flag use of arguments.callee and arguments.caller. - * @author Nicholas C. Zakas - */ - -"use strict"; - -//------------------------------------------------------------------------------ -// Rule Definition -//------------------------------------------------------------------------------ - -/** @type {import('../shared/types').Rule} */ -module.exports = { - meta: { - type: "suggestion", - - docs: { - description: "Disallow the use of `arguments.caller` or `arguments.callee`", - recommended: false, - url: "https://eslint.org/docs/latest/rules/no-caller" - }, - - schema: [], - - messages: { - unexpected: "Avoid arguments.{{prop}}." - } - }, - - create(context) { - - return { - - MemberExpression(node) { - const objectName = node.object.name, - propertyName = node.property.name; - - if (objectName === "arguments" && !node.computed && propertyName && propertyName.match(/^calle[er]$/u)) { - context.report({ node, messageId: "unexpected", data: { prop: propertyName } }); - } - - } - }; - - } -}; diff --git a/tools/eslint/node_modules/eslint/lib/rules/no-case-declarations.js b/tools/eslint/node_modules/eslint/lib/rules/no-case-declarations.js deleted file mode 100644 index 55f82e241f0462..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/rules/no-case-declarations.js +++ /dev/null @@ -1,76 +0,0 @@ -/** - * @fileoverview Rule to flag use of an lexical declarations inside a case clause - * @author Erik Arvidsson - */ -"use strict"; - -//------------------------------------------------------------------------------ -// Rule Definition -//------------------------------------------------------------------------------ - -/** @type {import('../shared/types').Rule} */ -module.exports = { - meta: { - type: "suggestion", - - docs: { - description: "Disallow lexical declarations in case clauses", - recommended: true, - url: "https://eslint.org/docs/latest/rules/no-case-declarations" - }, - - hasSuggestions: true, - - schema: [], - - messages: { - addBrackets: "Add {} brackets around the case block.", - unexpected: "Unexpected lexical declaration in case block." - } - }, - - create(context) { - - /** - * Checks whether or not a node is a lexical declaration. - * @param {ASTNode} node A direct child statement of a switch case. - * @returns {boolean} Whether or not the node is a lexical declaration. - */ - function isLexicalDeclaration(node) { - switch (node.type) { - case "FunctionDeclaration": - case "ClassDeclaration": - return true; - case "VariableDeclaration": - return node.kind !== "var"; - default: - return false; - } - } - - return { - SwitchCase(node) { - for (let i = 0; i < node.consequent.length; i++) { - const statement = node.consequent[i]; - - if (isLexicalDeclaration(statement)) { - context.report({ - node: statement, - messageId: "unexpected", - suggest: [ - { - messageId: "addBrackets", - fix: fixer => [ - fixer.insertTextBefore(node.consequent[0], "{ "), - fixer.insertTextAfter(node.consequent.at(-1), " }") - ] - } - ] - }); - } - } - } - }; - - } -}; diff --git a/tools/eslint/node_modules/eslint/lib/rules/no-catch-shadow.js b/tools/eslint/node_modules/eslint/lib/rules/no-catch-shadow.js deleted file mode 100644 index f9d8552437d012..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/rules/no-catch-shadow.js +++ /dev/null @@ -1,82 +0,0 @@ -/** - * @fileoverview Rule to flag variable leak in CatchClauses in IE 8 and earlier - * @author Ian Christian Myers - * @deprecated in ESLint v5.1.0 - */ - -"use strict"; - -//------------------------------------------------------------------------------ -// Requirements -//------------------------------------------------------------------------------ - -const astUtils = require("./utils/ast-utils"); - -//------------------------------------------------------------------------------ -// Rule Definition -//------------------------------------------------------------------------------ - -/** @type {import('../shared/types').Rule} */ -module.exports = { - meta: { - type: "suggestion", - - docs: { - description: "Disallow `catch` clause parameters from shadowing variables in the outer scope", - recommended: false, - url: "https://eslint.org/docs/latest/rules/no-catch-shadow" - }, - - replacedBy: ["no-shadow"], - - deprecated: true, - schema: [], - - messages: { - mutable: "Value of '{{name}}' may be overwritten in IE 8 and earlier." - } - }, - - create(context) { - - const sourceCode = context.sourceCode; - - //-------------------------------------------------------------------------- - // Helpers - //-------------------------------------------------------------------------- - - /** - * Check if the parameters are been shadowed - * @param {Object} scope current scope - * @param {string} name parameter name - * @returns {boolean} True is its been shadowed - */ - function paramIsShadowing(scope, name) { - return astUtils.getVariableByName(scope, name) !== null; - } - - //-------------------------------------------------------------------------- - // Public API - //-------------------------------------------------------------------------- - - return { - - "CatchClause[param!=null]"(node) { - let scope = sourceCode.getScope(node); - - /* - * When ecmaVersion >= 6, CatchClause creates its own scope - * so start from one upper scope to exclude the current node - */ - if (scope.block === node) { - scope = scope.upper; - } - - if (paramIsShadowing(scope, node.param.name)) { - context.report({ node, messageId: "mutable", data: { name: node.param.name } }); - } - } - }; - - } -}; diff --git a/tools/eslint/node_modules/eslint/lib/rules/no-class-assign.js b/tools/eslint/node_modules/eslint/lib/rules/no-class-assign.js deleted file mode 100644 index 49f3b844e7ef85..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/rules/no-class-assign.js +++ /dev/null @@ -1,63 +0,0 @@ -/** - * @fileoverview A rule to disallow modifying variables of class declarations - * @author Toru Nagashima - */ - -"use strict"; - -const astUtils = require("./utils/ast-utils"); - -//------------------------------------------------------------------------------ -// Rule Definition -//------------------------------------------------------------------------------ - -/** @type {import('../shared/types').Rule} */ -module.exports = { - meta: { - type: "problem", - - docs: { - description: "Disallow reassigning class members", - recommended: true, - url: "https://eslint.org/docs/latest/rules/no-class-assign" - }, - - schema: [], - - messages: { - class: "'{{name}}' is a class." - } - }, - - create(context) { - - const sourceCode = context.sourceCode; - - /** - * Finds and reports references that are non initializer and writable. - * @param {Variable} variable A variable to check. - * @returns {void} - */ - function checkVariable(variable) { - astUtils.getModifyingReferences(variable.references).forEach(reference => { - context.report({ node: reference.identifier, messageId: "class", data: { name: reference.identifier.name } }); - - }); - } - - /** - * Finds and reports references that are non initializer and writable. - * @param {ASTNode} node A ClassDeclaration/ClassExpression node to check. - * @returns {void} - */ - function checkForClass(node) { - sourceCode.getDeclaredVariables(node).forEach(checkVariable); - } - - return { - ClassDeclaration: checkForClass, - ClassExpression: checkForClass - }; - - } -}; diff --git a/tools/eslint/node_modules/eslint/lib/rules/no-compare-neg-zero.js b/tools/eslint/node_modules/eslint/lib/rules/no-compare-neg-zero.js deleted file mode 100644 index 112f6c1d113517..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/rules/no-compare-neg-zero.js +++ /dev/null @@ -1,60 +0,0 @@ -/** - * @fileoverview The rule should warn against code that tries to compare against -0. - * @author Aladdin-ADD - */ -"use strict"; - -//------------------------------------------------------------------------------ -// Rule Definition -//------------------------------------------------------------------------------ - -/** @type {import('../shared/types').Rule} */ -module.exports = { - meta: { - type: "problem", - - docs: { - description: "Disallow comparing against -0", - recommended: true, - url: "https://eslint.org/docs/latest/rules/no-compare-neg-zero" - }, - - fixable: null, - schema: [], - - messages: { - unexpected: "Do not use the '{{operator}}' operator to compare against -0." - } - }, - - create(context) { - - //-------------------------------------------------------------------------- - // Helpers - //-------------------------------------------------------------------------- - - /** - * Checks a given node is -0 - * @param {ASTNode} node A node to check. - * @returns {boolean} `true` if the node is -0. - */ - function isNegZero(node) { - return node.type === "UnaryExpression" && node.operator === "-" && node.argument.type === "Literal" && node.argument.value === 0; - } - const OPERATORS_TO_CHECK = new Set([">", ">=", "<", "<=", "==", "===", "!=", "!=="]); - - return { - BinaryExpression(node) { - if (OPERATORS_TO_CHECK.has(node.operator)) { - if (isNegZero(node.left) || isNegZero(node.right)) { - context.report({ - node, - messageId: "unexpected", - data: { operator: node.operator } - }); - } - } - } - }; - } -}; diff --git a/tools/eslint/node_modules/eslint/lib/rules/no-cond-assign.js b/tools/eslint/node_modules/eslint/lib/rules/no-cond-assign.js deleted file mode 100644 index 952920215aaa91..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/rules/no-cond-assign.js +++ /dev/null @@ -1,159 +0,0 @@ -/** - * @fileoverview Rule to flag assignment in a conditional statement's test expression - * @author Stephen Murray - */ - -"use strict"; - -//------------------------------------------------------------------------------ -// Requirements -//------------------------------------------------------------------------------ - -const astUtils = require("./utils/ast-utils"); - -//------------------------------------------------------------------------------ -// Helpers -//------------------------------------------------------------------------------ - -const TEST_CONDITION_PARENT_TYPES = new Set(["IfStatement", "WhileStatement", "DoWhileStatement", "ForStatement", "ConditionalExpression"]); - -const NODE_DESCRIPTIONS = { - DoWhileStatement: "a 'do...while' statement", - ForStatement: "a 'for' statement", - IfStatement: "an 'if' statement", - WhileStatement: "a 'while' statement" -}; - -//------------------------------------------------------------------------------ -// Rule Definition -//------------------------------------------------------------------------------ - -/** @type {import('../shared/types').Rule} */ -module.exports = { - meta: { - type: "problem", - - docs: { - description: "Disallow assignment operators in conditional expressions", - recommended: true, - url: "https://eslint.org/docs/latest/rules/no-cond-assign" - }, - - schema: [ - { - enum: ["except-parens", "always"] - } - ], - - messages: { - unexpected: "Unexpected assignment within {{type}}.", - - // must match JSHint's error message - missing: "Expected a conditional expression and instead saw an assignment." - } - }, - - create(context) { - - const prohibitAssign = (context.options[0] || "except-parens"); - - const sourceCode = context.sourceCode; - - /** - * Check whether an AST node is the test expression for a conditional statement. - * @param {!Object} node The node to test. - * @returns {boolean} `true` if the node is the text expression for a conditional statement; otherwise, `false`. - */ - function isConditionalTestExpression(node) { - return node.parent && - TEST_CONDITION_PARENT_TYPES.has(node.parent.type) && - node === node.parent.test; - } - - /** - * Given an AST node, perform a bottom-up search for the first ancestor that represents a conditional statement. - * @param {!Object} node The node to use at the start of the search. - * @returns {?Object} The closest ancestor node that represents a conditional statement. - */ - function findConditionalAncestor(node) { - let currentAncestor = node; - - do { - if (isConditionalTestExpression(currentAncestor)) { - return currentAncestor.parent; - } - } while ((currentAncestor = currentAncestor.parent) && !astUtils.isFunction(currentAncestor)); - - return null; - } - - /** - * Check whether the code represented by an AST node is enclosed in two sets of parentheses. - * @param {!Object} node The node to test. - * @returns {boolean} `true` if the code is enclosed in two sets of parentheses; otherwise, `false`. - */ - function isParenthesisedTwice(node) { - const previousToken = sourceCode.getTokenBefore(node, 1), - nextToken = sourceCode.getTokenAfter(node, 1); - - return astUtils.isParenthesised(sourceCode, node) && - previousToken && astUtils.isOpeningParenToken(previousToken) && previousToken.range[1] <= node.range[0] && - astUtils.isClosingParenToken(nextToken) && nextToken.range[0] >= node.range[1]; - } - - /** - * Check a conditional statement's test expression for top-level assignments that are not enclosed in parentheses. - * @param {!Object} node The node for the conditional statement. - * @returns {void} - */ - function testForAssign(node) { - if (node.test && - (node.test.type === "AssignmentExpression") && - (node.type === "ForStatement" - ? !astUtils.isParenthesised(sourceCode, node.test) - : !isParenthesisedTwice(node.test) - ) - ) { - - context.report({ - node: node.test, - messageId: "missing" - }); - } - } - - /** - * Check whether an assignment expression is descended from a conditional statement's test expression. - * @param {!Object} node The node for the assignment expression. - * @returns {void} - */ - function testForConditionalAncestor(node) { - const ancestor = findConditionalAncestor(node); - - if (ancestor) { - context.report({ - node, - messageId: "unexpected", - data: { - type: NODE_DESCRIPTIONS[ancestor.type] || ancestor.type - } - }); - } - } - - if (prohibitAssign === "always") { - return { - AssignmentExpression: testForConditionalAncestor - }; - } - - return { - DoWhileStatement: testForAssign, - ForStatement: testForAssign, - IfStatement: testForAssign, - WhileStatement: testForAssign, - ConditionalExpression: testForAssign - }; - - } -}; diff --git a/tools/eslint/node_modules/eslint/lib/rules/no-confusing-arrow.js b/tools/eslint/node_modules/eslint/lib/rules/no-confusing-arrow.js deleted file mode 100644 index 6fef1870eb2af2..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/rules/no-confusing-arrow.js +++ /dev/null @@ -1,92 +0,0 @@ -/** - * @fileoverview A rule to warn against using arrow functions when they could be - * confused with comparisons - * @author Jxck - * @deprecated in ESLint v8.53.0 - */ - -"use strict"; - -const astUtils = require("./utils/ast-utils.js"); - -//------------------------------------------------------------------------------ -// Helpers -//------------------------------------------------------------------------------ - -/** - * Checks whether or not a node is a conditional expression. - * @param {ASTNode} node node to test - * @returns {boolean} `true` if the node is a conditional expression. - */ -function isConditional(node) { - return node && node.type === "ConditionalExpression"; -} - -//------------------------------------------------------------------------------ -// Rule Definition -//------------------------------------------------------------------------------ - -/** @type {import('../shared/types').Rule} */ -module.exports = { - meta: { - deprecated: true, - replacedBy: [], - type: "suggestion", - - docs: { - description: "Disallow arrow functions where they could be confused with comparisons", - recommended: false, - url: "https://eslint.org/docs/latest/rules/no-confusing-arrow" - }, - - fixable: "code", - - schema: [{ - type: "object", - properties: { - allowParens: { type: "boolean", default: true }, - onlyOneSimpleParam: { type: "boolean", default: false } - }, - additionalProperties: false - }], - - messages: { - confusing: "Arrow function used ambiguously with a conditional expression." - } - }, - - create(context) { - const config = context.options[0] || {}; - const allowParens = config.allowParens || (config.allowParens === void 0); - const onlyOneSimpleParam = config.onlyOneSimpleParam; - const sourceCode = context.sourceCode; - - - /** - * Reports if an arrow function contains an ambiguous conditional. - * @param {ASTNode} node A node to check and report. - * @returns {void} - */ - function checkArrowFunc(node) { - const body = node.body; - - if (isConditional(body) && - !(allowParens && astUtils.isParenthesised(sourceCode, body)) && - !(onlyOneSimpleParam && !(node.params.length === 1 && node.params[0].type === "Identifier"))) { - context.report({ - node, - messageId: "confusing", - fix(fixer) { - - // if `allowParens` is not set to true don't bother wrapping in parens - return allowParens && fixer.replaceText(node.body, `(${sourceCode.getText(node.body)})`); - } - }); - } - } - - return { - ArrowFunctionExpression: checkArrowFunc - }; - } -}; diff --git a/tools/eslint/node_modules/eslint/lib/rules/no-console.js b/tools/eslint/node_modules/eslint/lib/rules/no-console.js deleted file mode 100644 index d20477c5d9a832..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/rules/no-console.js +++ /dev/null @@ -1,207 +0,0 @@ -/** - * @fileoverview Rule to flag use of console object - * @author Nicholas C. Zakas - */ - -"use strict"; - -//------------------------------------------------------------------------------ -// Requirements -//------------------------------------------------------------------------------ - -const astUtils = require("./utils/ast-utils"); - -//------------------------------------------------------------------------------ -// Rule Definition -//------------------------------------------------------------------------------ - -/** @type {import('../shared/types').Rule} */ -module.exports = { - meta: { - type: "suggestion", - - docs: { - description: "Disallow the use of `console`", - recommended: false, - url: "https://eslint.org/docs/latest/rules/no-console" - }, - - schema: [ - { - type: "object", - properties: { - allow: { - type: "array", - items: { - type: "string" - }, - minItems: 1, - uniqueItems: true - } - }, - additionalProperties: false - } - ], - - hasSuggestions: true, - - messages: { - unexpected: "Unexpected console statement.", - removeConsole: "Remove the console.{{ propertyName }}()." - } - }, - - create(context) { - const options = context.options[0] || {}; - const allowed = options.allow || []; - const sourceCode = context.sourceCode; - - /** - * Checks whether the given reference is 'console' or not. - * @param {eslint-scope.Reference} reference The reference to check. - * @returns {boolean} `true` if the reference is 'console'. - */ - function isConsole(reference) { - const id = reference.identifier; - - return id && id.name === "console"; - } - - /** - * Checks whether the property name of the given MemberExpression node - * is allowed by options or not. - * @param {ASTNode} node The MemberExpression node to check. - * @returns {boolean} `true` if the property name of the node is allowed. - */ - function isAllowed(node) { - const propertyName = astUtils.getStaticPropertyName(node); - - return propertyName && allowed.includes(propertyName); - } - - /** - * Checks whether the given reference is a member access which is not - * allowed by options or not. - * @param {eslint-scope.Reference} reference The reference to check. - * @returns {boolean} `true` if the reference is a member access which - * is not allowed by options. - */ - function isMemberAccessExceptAllowed(reference) { - const node = reference.identifier; - const parent = node.parent; - - return ( - parent.type === "MemberExpression" && - parent.object === node && - !isAllowed(parent) - ); - } - - /** - * Checks if removing the ExpressionStatement node will cause ASI to - * break. - * eg. - * foo() - * console.log(); - * [1, 2, 3].forEach(a => doSomething(a)) - * - * Removing the console.log(); statement should leave two statements, but - * here the two statements will become one because [ causes continuation after - * foo(). - * @param {ASTNode} node The ExpressionStatement node to check. - * @returns {boolean} `true` if ASI will break after removing the ExpressionStatement - * node. - */ - function maybeAsiHazard(node) { - const SAFE_TOKENS_BEFORE = /^[:;{]$/u; // One of :;{ - const UNSAFE_CHARS_AFTER = /^[-[(/+`]/u; // One of [(/+-` - - const tokenBefore = sourceCode.getTokenBefore(node); - const tokenAfter = sourceCode.getTokenAfter(node); - - return ( - Boolean(tokenAfter) && - UNSAFE_CHARS_AFTER.test(tokenAfter.value) && - tokenAfter.value !== "++" && - tokenAfter.value !== "--" && - Boolean(tokenBefore) && - !SAFE_TOKENS_BEFORE.test(tokenBefore.value) - ); - } - - /** - * Checks if the MemberExpression node's parent.parent.parent is a - * Program, BlockStatement, StaticBlock, or SwitchCase node. This check - * is necessary to avoid providing a suggestion that might cause a syntax error. - * - * eg. if (a) console.log(b), removing console.log() here will lead to a - * syntax error. - * if (a) { console.log(b) }, removing console.log() here is acceptable. - * - * Additionally, it checks if the callee of the CallExpression node is - * the node itself. - * - * eg. foo(console.log), cannot provide a suggestion here. - * @param {ASTNode} node The MemberExpression node to check. - * @returns {boolean} `true` if a suggestion can be provided for a node. - */ - function canProvideSuggestions(node) { - return ( - node.parent.type === "CallExpression" && - node.parent.callee === node && - node.parent.parent.type === "ExpressionStatement" && - astUtils.STATEMENT_LIST_PARENTS.has(node.parent.parent.parent.type) && - !maybeAsiHazard(node.parent.parent) - ); - } - - /** - * Reports the given reference as a violation. - * @param {eslint-scope.Reference} reference The reference to report. - * @returns {void} - */ - function report(reference) { - const node = reference.identifier.parent; - - const propertyName = astUtils.getStaticPropertyName(node); - - context.report({ - node, - loc: node.loc, - messageId: "unexpected", - suggest: canProvideSuggestions(node) - ? [{ - messageId: "removeConsole", - data: { propertyName }, - fix(fixer) { - return fixer.remove(node.parent.parent); - } - }] - : [] - }); - } - - return { - "Program:exit"(node) { - const scope = sourceCode.getScope(node); - const consoleVar = astUtils.getVariableByName(scope, "console"); - const shadowed = consoleVar && consoleVar.defs.length > 0; - - /* - * 'scope.through' includes all references to undefined - * variables. If the variable 'console' is not defined, it uses - * 'scope.through'. - */ - const references = consoleVar - ? consoleVar.references - : scope.through.filter(isConsole); - - if (!shadowed) { - references - .filter(isMemberAccessExceptAllowed) - .forEach(report); - } - } - }; - } -}; diff --git a/tools/eslint/node_modules/eslint/lib/rules/no-const-assign.js b/tools/eslint/node_modules/eslint/lib/rules/no-const-assign.js deleted file mode 100644 index 0ceaf7ea5ed4e3..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/rules/no-const-assign.js +++ /dev/null @@ -1,56 +0,0 @@ -/** - * @fileoverview A rule to disallow modifying variables that are declared using `const` - * @author Toru Nagashima - */ - -"use strict"; - -const astUtils = require("./utils/ast-utils"); - -//------------------------------------------------------------------------------ -// Rule Definition -//------------------------------------------------------------------------------ - -/** @type {import('../shared/types').Rule} */ -module.exports = { - meta: { - type: "problem", - - docs: { - description: "Disallow reassigning `const` variables", - recommended: true, - url: "https://eslint.org/docs/latest/rules/no-const-assign" - }, - - schema: [], - - messages: { - const: "'{{name}}' is constant." - } - }, - - create(context) { - - const sourceCode = context.sourceCode; - - /** - * Finds and reports references that are non initializer and writable. - * @param {Variable} variable A variable to check. - * @returns {void} - */ - function checkVariable(variable) { - astUtils.getModifyingReferences(variable.references).forEach(reference => { - context.report({ node: reference.identifier, messageId: "const", data: { name: reference.identifier.name } }); - }); - } - - return { - VariableDeclaration(node) { - if (node.kind === "const") { - sourceCode.getDeclaredVariables(node).forEach(checkVariable); - } - } - }; - - } -}; diff --git a/tools/eslint/node_modules/eslint/lib/rules/no-constant-binary-expression.js b/tools/eslint/node_modules/eslint/lib/rules/no-constant-binary-expression.js deleted file mode 100644 index bc8f0730aece1d..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/rules/no-constant-binary-expression.js +++ /dev/null @@ -1,508 +0,0 @@ -/** - * @fileoverview Rule to flag constant comparisons and logical expressions that always/never short circuit - * @author Jordan Eldredge - */ - -"use strict"; - -const { isNullLiteral, isConstant, isReferenceToGlobalVariable, isLogicalAssignmentOperator, ECMASCRIPT_GLOBALS } = require("./utils/ast-utils"); - -const NUMERIC_OR_STRING_BINARY_OPERATORS = new Set(["+", "-", "*", "/", "%", "|", "^", "&", "**", "<<", ">>", ">>>"]); - -//------------------------------------------------------------------------------ -// Helpers -//------------------------------------------------------------------------------ - -/** - * Checks whether or not a node is `null` or `undefined`. Similar to the one - * found in ast-utils.js, but this one correctly handles the edge case that - * `undefined` has been redefined. - * @param {Scope} scope Scope in which the expression was found. - * @param {ASTNode} node A node to check. - * @returns {boolean} Whether or not the node is a `null` or `undefined`. - * @public - */ -function isNullOrUndefined(scope, node) { - return ( - isNullLiteral(node) || - (node.type === "Identifier" && node.name === "undefined" && isReferenceToGlobalVariable(scope, node)) || - (node.type === "UnaryExpression" && node.operator === "void") - ); -} - -/** - * Test if an AST node has a statically knowable constant nullishness. Meaning, - * it will always resolve to a constant value of either: `null`, `undefined` - * or not `null` _or_ `undefined`. An expression that can vary between those - * three states at runtime would return `false`. - * @param {Scope} scope The scope in which the node was found. - * @param {ASTNode} node The AST node being tested. - * @param {boolean} nonNullish if `true` then nullish values are not considered constant. - * @returns {boolean} Does `node` have constant nullishness? - */ -function hasConstantNullishness(scope, node, nonNullish) { - if (nonNullish && isNullOrUndefined(scope, node)) { - return false; - } - - switch (node.type) { - case "ObjectExpression": // Objects are never nullish - case "ArrayExpression": // Arrays are never nullish - case "ArrowFunctionExpression": // Functions never nullish - case "FunctionExpression": // Functions are never nullish - case "ClassExpression": // Classes are never nullish - case "NewExpression": // Objects are never nullish - case "Literal": // Nullish, or non-nullish, literals never change - case "TemplateLiteral": // A string is never nullish - case "UpdateExpression": // Numbers are never nullish - case "BinaryExpression": // Numbers, strings, or booleans are never nullish - return true; - case "CallExpression": { - if (node.callee.type !== "Identifier") { - return false; - } - const functionName = node.callee.name; - - return (functionName === "Boolean" || functionName === "String" || functionName === "Number") && - isReferenceToGlobalVariable(scope, node.callee); - } - case "LogicalExpression": { - return node.operator === "??" && hasConstantNullishness(scope, node.right, true); - } - case "AssignmentExpression": - if (node.operator === "=") { - return hasConstantNullishness(scope, node.right, nonNullish); - } - - /* - * Handling short-circuiting assignment operators would require - * walking the scope. We won't attempt that (for now...) / - */ - if (isLogicalAssignmentOperator(node.operator)) { - return false; - } - - /* - * The remaining assignment expressions all result in a numeric or - * string (non-nullish) value: - * "+=", "-=", "*=", "/=", "%=", "<<=", ">>=", ">>>=", "|=", "^=", "&=" - */ - - return true; - case "UnaryExpression": - - /* - * "void" Always returns `undefined` - * "typeof" All types are strings, and thus non-nullish - * "!" Boolean is never nullish - * "delete" Returns a boolean, which is never nullish - * Math operators always return numbers or strings, neither of which - * are non-nullish "+", "-", "~" - */ - - return true; - case "SequenceExpression": { - const last = node.expressions.at(-1); - - return hasConstantNullishness(scope, last, nonNullish); - } - case "Identifier": - return node.name === "undefined" && isReferenceToGlobalVariable(scope, node); - case "JSXElement": // ESLint has a policy of not assuming any specific JSX behavior. - case "JSXFragment": - return false; - default: - return false; - } -} - -/** - * Test if an AST node is a boolean value that never changes. Specifically we - * test for: - * 1. Literal booleans (`true` or `false`) - * 2. Unary `!` expressions with a constant value - * 3. Constant booleans created via the `Boolean` global function - * @param {Scope} scope The scope in which the node was found. - * @param {ASTNode} node The node to test - * @returns {boolean} Is `node` guaranteed to be a boolean? - */ -function isStaticBoolean(scope, node) { - switch (node.type) { - case "Literal": - return typeof node.value === "boolean"; - case "CallExpression": - return node.callee.type === "Identifier" && node.callee.name === "Boolean" && - isReferenceToGlobalVariable(scope, node.callee) && - (node.arguments.length === 0 || isConstant(scope, node.arguments[0], true)); - case "UnaryExpression": - return node.operator === "!" && isConstant(scope, node.argument, true); - default: - return false; - } -} - - -/** - * Test if an AST node will always give the same result when compared to a - * boolean value. Note that comparison to boolean values is different than - * truthiness. - * https://262.ecma-international.org/5.1/#sec-11.9.3 - * - * JavaScript `==` operator works by converting the boolean to `1` (true) or - * `+0` (false) and then checks the values `==` equality to that number. - * @param {Scope} scope The scope in which node was found. - * @param {ASTNode} node The node to test. - * @returns {boolean} Will `node` always coerce to the same boolean value? - */ -function hasConstantLooseBooleanComparison(scope, node) { - switch (node.type) { - case "ObjectExpression": - case "ClassExpression": - - /** - * In theory objects like: - * - * `{toString: () => a}` - * `{valueOf: () => a}` - * - * Or a classes like: - * - * `class { static toString() { return a } }` - * `class { static valueOf() { return a } }` - * - * Are not constant verifiably when `inBooleanPosition` is - * false, but it's an edge case we've opted not to handle. - */ - return true; - case "ArrayExpression": { - const nonSpreadElements = node.elements.filter(e => - - // Elements can be `null` in sparse arrays: `[,,]`; - e !== null && e.type !== "SpreadElement"); - - - /* - * Possible future direction if needed: We could check if the - * single value would result in variable boolean comparison. - * For now we will err on the side of caution since `[x]` could - * evaluate to `[0]` or `[1]`. - */ - return node.elements.length === 0 || nonSpreadElements.length > 1; - } - case "ArrowFunctionExpression": - case "FunctionExpression": - return true; - case "UnaryExpression": - if (node.operator === "void" || // Always returns `undefined` - node.operator === "typeof" // All `typeof` strings, when coerced to number, are not 0 or 1. - ) { - return true; - } - if (node.operator === "!") { - return isConstant(scope, node.argument, true); - } - - /* - * We won't try to reason about +, -, ~, or delete - * In theory, for the mathematical operators, we could look at the - * argument and try to determine if it coerces to a constant numeric - * value. - */ - return false; - case "NewExpression": // Objects might have custom `.valueOf` or `.toString`. - return false; - case "CallExpression": { - if (node.callee.type === "Identifier" && - node.callee.name === "Boolean" && - isReferenceToGlobalVariable(scope, node.callee) - ) { - return node.arguments.length === 0 || isConstant(scope, node.arguments[0], true); - } - return false; - } - case "Literal": // True or false, literals never change - return true; - case "Identifier": - return node.name === "undefined" && isReferenceToGlobalVariable(scope, node); - case "TemplateLiteral": - - /* - * In theory we could try to check if the quasi are sufficient to - * prove that the expression will always be true, but it would be - * tricky to get right. For example: `000.${foo}000` - */ - return node.expressions.length === 0; - case "AssignmentExpression": - if (node.operator === "=") { - return hasConstantLooseBooleanComparison(scope, node.right); - } - - /* - * Handling short-circuiting assignment operators would require - * walking the scope. We won't attempt that (for now...) - * - * The remaining assignment expressions all result in a numeric or - * string (non-nullish) values which could be truthy or falsy: - * "+=", "-=", "*=", "/=", "%=", "<<=", ">>=", ">>>=", "|=", "^=", "&=" - */ - return false; - case "SequenceExpression": { - const last = node.expressions.at(-1); - - return hasConstantLooseBooleanComparison(scope, last); - } - case "JSXElement": // ESLint has a policy of not assuming any specific JSX behavior. - case "JSXFragment": - return false; - default: - return false; - } -} - - -/** - * Test if an AST node will always give the same result when _strictly_ compared - * to a boolean value. This can happen if the expression can never be boolean, or - * if it is always the same boolean value. - * @param {Scope} scope The scope in which the node was found. - * @param {ASTNode} node The node to test - * @returns {boolean} Will `node` always give the same result when compared to a - * static boolean value? - */ -function hasConstantStrictBooleanComparison(scope, node) { - switch (node.type) { - case "ObjectExpression": // Objects are not booleans - case "ArrayExpression": // Arrays are not booleans - case "ArrowFunctionExpression": // Functions are not booleans - case "FunctionExpression": - case "ClassExpression": // Classes are not booleans - case "NewExpression": // Objects are not booleans - case "TemplateLiteral": // Strings are not booleans - case "Literal": // True, false, or not boolean, literals never change. - case "UpdateExpression": // Numbers are not booleans - return true; - case "BinaryExpression": - return NUMERIC_OR_STRING_BINARY_OPERATORS.has(node.operator); - case "UnaryExpression": { - if (node.operator === "delete") { - return false; - } - if (node.operator === "!") { - return isConstant(scope, node.argument, true); - } - - /* - * The remaining operators return either strings or numbers, neither - * of which are boolean. - */ - return true; - } - case "SequenceExpression": { - const last = node.expressions.at(-1); - - return hasConstantStrictBooleanComparison(scope, last); - } - case "Identifier": - return node.name === "undefined" && isReferenceToGlobalVariable(scope, node); - case "AssignmentExpression": - if (node.operator === "=") { - return hasConstantStrictBooleanComparison(scope, node.right); - } - - /* - * Handling short-circuiting assignment operators would require - * walking the scope. We won't attempt that (for now...) - */ - if (isLogicalAssignmentOperator(node.operator)) { - return false; - } - - /* - * The remaining assignment expressions all result in either a number - * or a string, neither of which can ever be boolean. - */ - return true; - case "CallExpression": { - if (node.callee.type !== "Identifier") { - return false; - } - const functionName = node.callee.name; - - if ( - (functionName === "String" || functionName === "Number") && - isReferenceToGlobalVariable(scope, node.callee) - ) { - return true; - } - if (functionName === "Boolean" && isReferenceToGlobalVariable(scope, node.callee)) { - return ( - node.arguments.length === 0 || isConstant(scope, node.arguments[0], true)); - } - return false; - } - case "JSXElement": // ESLint has a policy of not assuming any specific JSX behavior. - case "JSXFragment": - return false; - default: - return false; - } -} - -/** - * Test if an AST node will always result in a newly constructed object - * @param {Scope} scope The scope in which the node was found. - * @param {ASTNode} node The node to test - * @returns {boolean} Will `node` always be new? - */ -function isAlwaysNew(scope, node) { - switch (node.type) { - case "ObjectExpression": - case "ArrayExpression": - case "ArrowFunctionExpression": - case "FunctionExpression": - case "ClassExpression": - return true; - case "NewExpression": { - if (node.callee.type !== "Identifier") { - return false; - } - - /* - * All the built-in constructors are always new, but - * user-defined constructors could return a sentinel - * object. - * - * Catching these is especially useful for primitive constructors - * which return boxed values, a surprising gotcha' in JavaScript. - */ - return Object.hasOwn(ECMASCRIPT_GLOBALS, node.callee.name) && - isReferenceToGlobalVariable(scope, node.callee); - } - case "Literal": - - // Regular expressions are objects, and thus always new - return typeof node.regex === "object"; - case "SequenceExpression": { - const last = node.expressions.at(-1); - - return isAlwaysNew(scope, last); - } - case "AssignmentExpression": - if (node.operator === "=") { - return isAlwaysNew(scope, node.right); - } - return false; - case "ConditionalExpression": - return isAlwaysNew(scope, node.consequent) && isAlwaysNew(scope, node.alternate); - case "JSXElement": // ESLint has a policy of not assuming any specific JSX behavior. - case "JSXFragment": - return false; - default: - return false; - } -} - -/** - * Checks if one operand will cause the result to be constant. - * @param {Scope} scope Scope in which the expression was found. - * @param {ASTNode} a One side of the expression - * @param {ASTNode} b The other side of the expression - * @param {string} operator The binary expression operator - * @returns {ASTNode | null} The node which will cause the expression to have a constant result. - */ -function findBinaryExpressionConstantOperand(scope, a, b, operator) { - if (operator === "==" || operator === "!=") { - if ( - (isNullOrUndefined(scope, a) && hasConstantNullishness(scope, b, false)) || - (isStaticBoolean(scope, a) && hasConstantLooseBooleanComparison(scope, b)) - ) { - return b; - } - } else if (operator === "===" || operator === "!==") { - if ( - (isNullOrUndefined(scope, a) && hasConstantNullishness(scope, b, false)) || - (isStaticBoolean(scope, a) && hasConstantStrictBooleanComparison(scope, b)) - ) { - return b; - } - } - return null; -} - -//------------------------------------------------------------------------------ -// Rule Definition -//------------------------------------------------------------------------------ - -/** @type {import('../shared/types').Rule} */ -module.exports = { - meta: { - type: "problem", - docs: { - description: "Disallow expressions where the operation doesn't affect the value", - recommended: true, - url: "https://eslint.org/docs/latest/rules/no-constant-binary-expression" - }, - schema: [], - messages: { - constantBinaryOperand: "Unexpected constant binary expression. Compares constantly with the {{otherSide}}-hand side of the `{{operator}}`.", - constantShortCircuit: "Unexpected constant {{property}} on the left-hand side of a `{{operator}}` expression.", - alwaysNew: "Unexpected comparison to newly constructed object. These two values can never be equal.", - bothAlwaysNew: "Unexpected comparison of two newly constructed objects. These two values can never be equal." - } - }, - - create(context) { - const sourceCode = context.sourceCode; - - return { - LogicalExpression(node) { - const { operator, left } = node; - const scope = sourceCode.getScope(node); - - if ((operator === "&&" || operator === "||") && isConstant(scope, left, true)) { - context.report({ node: left, messageId: "constantShortCircuit", data: { property: "truthiness", operator } }); - } else if (operator === "??" && hasConstantNullishness(scope, left, false)) { - context.report({ node: left, messageId: "constantShortCircuit", data: { property: "nullishness", operator } }); - } - }, - BinaryExpression(node) { - const scope = sourceCode.getScope(node); - const { right, left, operator } = node; - const rightConstantOperand = findBinaryExpressionConstantOperand(scope, left, right, operator); - const leftConstantOperand = findBinaryExpressionConstantOperand(scope, right, left, operator); - - if (rightConstantOperand) { - context.report({ node: rightConstantOperand, messageId: "constantBinaryOperand", data: { operator, otherSide: "left" } }); - } else if (leftConstantOperand) { - context.report({ node: leftConstantOperand, messageId: "constantBinaryOperand", data: { operator, otherSide: "right" } }); - } else if (operator === "===" || operator === "!==") { - if (isAlwaysNew(scope, left)) { - context.report({ node: left, messageId: "alwaysNew" }); - } else if (isAlwaysNew(scope, right)) { - context.report({ node: right, messageId: "alwaysNew" }); - } - } else if (operator === "==" || operator === "!=") { - - /* - * If both sides are "new", then both sides are objects and - * therefore they will be compared by reference even with `==` - * equality. - */ - if (isAlwaysNew(scope, left) && isAlwaysNew(scope, right)) { - context.report({ node: left, messageId: "bothAlwaysNew" }); - } - } - - } - - /* - * In theory we could handle short-circuiting assignment operators, - * for some constant values, but that would require walking the - * scope to find the value of the variable being assigned. This is - * dependant on https://github.com/eslint/eslint/issues/13776 - * - * AssignmentExpression() {}, - */ - }; - } -}; diff --git a/tools/eslint/node_modules/eslint/lib/rules/no-constant-condition.js b/tools/eslint/node_modules/eslint/lib/rules/no-constant-condition.js deleted file mode 100644 index b7d0c7556547a5..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/rules/no-constant-condition.js +++ /dev/null @@ -1,161 +0,0 @@ -/** - * @fileoverview Rule to flag use constant conditions - * @author Christian Schulz - */ - -"use strict"; - -const { isConstant } = require("./utils/ast-utils"); - -//------------------------------------------------------------------------------ -// Helpers -//------------------------------------------------------------------------------ - -//------------------------------------------------------------------------------ -// Rule Definition -//------------------------------------------------------------------------------ - -/** @type {import('../shared/types').Rule} */ -module.exports = { - meta: { - type: "problem", - - docs: { - description: "Disallow constant expressions in conditions", - recommended: true, - url: "https://eslint.org/docs/latest/rules/no-constant-condition" - }, - - schema: [ - { - type: "object", - properties: { - checkLoops: { - enum: ["all", "allExceptWhileTrue", "none", true, false] - } - }, - additionalProperties: false - } - ], - - messages: { - unexpected: "Unexpected constant condition." - } - }, - - create(context) { - const options = context.options[0] || {}; - let checkLoops = options.checkLoops ?? "allExceptWhileTrue"; - const loopSetStack = []; - const sourceCode = context.sourceCode; - - if (options.checkLoops === true) { - checkLoops = "all"; - } else if (options.checkLoops === false) { - checkLoops = "none"; - } - - let loopsInCurrentScope = new Set(); - - //-------------------------------------------------------------------------- - // Helpers - //-------------------------------------------------------------------------- - - /** - * Tracks when the given node contains a constant condition. - * @param {ASTNode} node The AST node to check. - * @returns {void} - * @private - */ - function trackConstantConditionLoop(node) { - if (node.test && isConstant(sourceCode.getScope(node), node.test, true)) { - loopsInCurrentScope.add(node); - } - } - - /** - * Reports when the set contains the given constant condition node - * @param {ASTNode} node The AST node to check. - * @returns {void} - * @private - */ - function checkConstantConditionLoopInSet(node) { - if (loopsInCurrentScope.has(node)) { - loopsInCurrentScope.delete(node); - context.report({ node: node.test, messageId: "unexpected" }); - } - } - - /** - * Reports when the given node contains a constant condition. - * @param {ASTNode} node The AST node to check. - * @returns {void} - * @private - */ - function reportIfConstant(node) { - if (node.test && isConstant(sourceCode.getScope(node), node.test, true)) { - context.report({ node: node.test, messageId: "unexpected" }); - } - } - - /** - * Stores current set of constant loops in loopSetStack temporarily - * and uses a new set to track constant loops - * @returns {void} - * @private - */ - function enterFunction() { - loopSetStack.push(loopsInCurrentScope); - loopsInCurrentScope = new Set(); - } - - /** - * Reports when the set still contains stored constant conditions - * @returns {void} - * @private - */ - function exitFunction() { - loopsInCurrentScope = loopSetStack.pop(); - } - - /** - * Checks node when checkLoops option is enabled - * @param {ASTNode} node The AST node to check. - * @returns {void} - * @private - */ - function checkLoop(node) { - if (checkLoops === "all" || checkLoops === "allExceptWhileTrue") { - trackConstantConditionLoop(node); - } - } - - //-------------------------------------------------------------------------- - // Public - //-------------------------------------------------------------------------- - - return { - ConditionalExpression: reportIfConstant, - IfStatement: reportIfConstant, - WhileStatement(node) { - if (node.test.type === "Literal" && node.test.value === true && checkLoops === "allExceptWhileTrue") { - return; - } - - checkLoop(node); - }, - "WhileStatement:exit": checkConstantConditionLoopInSet, - DoWhileStatement: checkLoop, - "DoWhileStatement:exit": checkConstantConditionLoopInSet, - ForStatement: checkLoop, - "ForStatement > .test": node => checkLoop(node.parent), - "ForStatement:exit": checkConstantConditionLoopInSet, - FunctionDeclaration: enterFunction, - "FunctionDeclaration:exit": exitFunction, - FunctionExpression: enterFunction, - "FunctionExpression:exit": exitFunction, - YieldExpression: () => loopsInCurrentScope.clear() - }; - - } -}; diff --git a/tools/eslint/node_modules/eslint/lib/rules/no-constructor-return.js b/tools/eslint/node_modules/eslint/lib/rules/no-constructor-return.js deleted file mode 100644 index e9ef7385562559..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/rules/no-constructor-return.js +++ /dev/null @@ -1,62 +0,0 @@ -/** - * @fileoverview Rule to disallow returning value from constructor. - * @author Pig Fang - */ - -"use strict"; - -//------------------------------------------------------------------------------ -// Rule Definition -//------------------------------------------------------------------------------ - -/** @type {import('../shared/types').Rule} */ -module.exports = { - meta: { - type: "problem", - - docs: { - description: "Disallow returning value from constructor", - recommended: false, - url: "https://eslint.org/docs/latest/rules/no-constructor-return" - }, - - schema: [], - - fixable: null, - - messages: { - unexpected: "Unexpected return statement in constructor." - } - }, - - create(context) { - const stack = []; - - return { - onCodePathStart(_, node) { - stack.push(node); - }, - onCodePathEnd() { - stack.pop(); - }, - ReturnStatement(node) { - const last = stack.at(-1); - - if (!last.parent) { - return; - } - - if ( - last.parent.type === "MethodDefinition" && - last.parent.kind === "constructor" && - node.argument - ) { - context.report({ - node, - messageId: "unexpected" - }); - } - } - }; - } -}; diff --git a/tools/eslint/node_modules/eslint/lib/rules/no-continue.js b/tools/eslint/node_modules/eslint/lib/rules/no-continue.js deleted file mode 100644 index f6e484b2fc78fb..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/rules/no-continue.js +++ /dev/null @@ -1,39 +0,0 @@ -/** - * @fileoverview Rule to flag use of continue statement - * @author Borislav Zhivkov - */ - -"use strict"; - -//------------------------------------------------------------------------------ -// Rule Definition -//------------------------------------------------------------------------------ - -/** @type {import('../shared/types').Rule} */ -module.exports = { - meta: { - type: "suggestion", - - docs: { - description: "Disallow `continue` statements", - recommended: false, - url: "https://eslint.org/docs/latest/rules/no-continue" - }, - - schema: [], - - messages: { - unexpected: "Unexpected use of continue statement." - } - }, - - create(context) { - - return { - ContinueStatement(node) { - context.report({ node, messageId: "unexpected" }); - } - }; - - } -}; diff --git a/tools/eslint/node_modules/eslint/lib/rules/no-control-regex.js b/tools/eslint/node_modules/eslint/lib/rules/no-control-regex.js deleted file mode 100644 index dc412fcabd524b..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/rules/no-control-regex.js +++ /dev/null @@ -1,138 +0,0 @@ -/** - * @fileoverview Rule to forbid control characters from regular expressions. - * @author Nicholas C. Zakas - */ - -"use strict"; - -const RegExpValidator = require("@eslint-community/regexpp").RegExpValidator; -const collector = new (class { - constructor() { - this._source = ""; - this._controlChars = []; - this._validator = new RegExpValidator(this); - } - - onPatternEnter() { - - /* - * `RegExpValidator` may parse the pattern twice in one `validatePattern`. - * So `this._controlChars` should be cleared here as well. - * - * For example, the `/(?\x1f)/` regex will parse the pattern twice. - * This is based on the content described in Annex B. - * If the regex contains a `GroupName` and the `u` flag is not used, `ParseText` will be called twice. - * See https://tc39.es/ecma262/2023/multipage/additional-ecmascript-features-for-web-browsers.html#sec-parsepattern-annexb - */ - this._controlChars = []; - } - - onCharacter(start, end, cp) { - if (cp >= 0x00 && - cp <= 0x1F && - ( - this._source.codePointAt(start) === cp || - this._source.slice(start, end).startsWith("\\x") || - this._source.slice(start, end).startsWith("\\u") - ) - ) { - this._controlChars.push(`\\x${`0${cp.toString(16)}`.slice(-2)}`); - } - } - - collectControlChars(regexpStr, flags) { - const uFlag = typeof flags === "string" && flags.includes("u"); - const vFlag = typeof flags === "string" && flags.includes("v"); - - this._controlChars = []; - this._source = regexpStr; - - try { - this._validator.validatePattern(regexpStr, void 0, void 0, { unicode: uFlag, unicodeSets: vFlag }); // Call onCharacter hook - } catch { - - // Ignore syntax errors in RegExp. - } - return this._controlChars; - } -})(); - -//------------------------------------------------------------------------------ -// Rule Definition -//------------------------------------------------------------------------------ - -/** @type {import('../shared/types').Rule} */ -module.exports = { - meta: { - type: "problem", - - docs: { - description: "Disallow control characters in regular expressions", - recommended: true, - url: "https://eslint.org/docs/latest/rules/no-control-regex" - }, - - schema: [], - - messages: { - unexpected: "Unexpected control character(s) in regular expression: {{controlChars}}." - } - }, - - create(context) { - - /** - * Get the regex expression - * @param {ASTNode} node `Literal` node to evaluate - * @returns {{ pattern: string, flags: string | null } | null} Regex if found (the given node is either a regex literal - * or a string literal that is the pattern argument of a RegExp constructor call). Otherwise `null`. If flags cannot be determined, - * the `flags` property will be `null`. - * @private - */ - function getRegExp(node) { - if (node.regex) { - return node.regex; - } - if (typeof node.value === "string" && - (node.parent.type === "NewExpression" || node.parent.type === "CallExpression") && - node.parent.callee.type === "Identifier" && - node.parent.callee.name === "RegExp" && - node.parent.arguments[0] === node - ) { - const pattern = node.value; - const flags = - node.parent.arguments.length > 1 && - node.parent.arguments[1].type === "Literal" && - typeof node.parent.arguments[1].value === "string" - ? node.parent.arguments[1].value - : null; - - return { pattern, flags }; - } - - return null; - } - - return { - Literal(node) { - const regExp = getRegExp(node); - - if (regExp) { - const { pattern, flags } = regExp; - const controlCharacters = collector.collectControlChars(pattern, flags); - - if (controlCharacters.length > 0) { - context.report({ - node, - messageId: "unexpected", - data: { - controlChars: controlCharacters.join(", ") - } - }); - } - } - } - }; - - } -}; diff --git a/tools/eslint/node_modules/eslint/lib/rules/no-debugger.js b/tools/eslint/node_modules/eslint/lib/rules/no-debugger.js deleted file mode 100644 index f69843515a3d1a..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/rules/no-debugger.js +++ /dev/null @@ -1,43 +0,0 @@ -/** - * @fileoverview Rule to flag use of a debugger statement - * @author Nicholas C. Zakas - */ - -"use strict"; - -//------------------------------------------------------------------------------ -// Rule Definition -//------------------------------------------------------------------------------ - -/** @type {import('../shared/types').Rule} */ -module.exports = { - meta: { - type: "problem", - - docs: { - description: "Disallow the use of `debugger`", - recommended: true, - url: "https://eslint.org/docs/latest/rules/no-debugger" - }, - - fixable: null, - schema: [], - - messages: { - unexpected: "Unexpected 'debugger' statement." - } - }, - - create(context) { - - return { - DebuggerStatement(node) { - context.report({ - node, - messageId: "unexpected" - }); - } - }; - - } -}; diff --git a/tools/eslint/node_modules/eslint/lib/rules/no-delete-var.js b/tools/eslint/node_modules/eslint/lib/rules/no-delete-var.js deleted file mode 100644 index 126603c83cebb4..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/rules/no-delete-var.js +++ /dev/null @@ -1,42 +0,0 @@ -/** - * @fileoverview Rule to flag when deleting variables - * @author Ilya Volodin - */ - -"use strict"; - -//------------------------------------------------------------------------------ -// Rule Definition -//------------------------------------------------------------------------------ - -/** @type {import('../shared/types').Rule} */ -module.exports = { - meta: { - type: "suggestion", - - docs: { - description: "Disallow deleting variables", - recommended: true, - url: "https://eslint.org/docs/latest/rules/no-delete-var" - }, - - schema: [], - - messages: { - unexpected: "Variables should not be deleted." - } - }, - - create(context) { - - return { - - UnaryExpression(node) { - if (node.operator === "delete" && node.argument.type === "Identifier") { - context.report({ node, messageId: "unexpected" }); - } - } - }; - - } -}; diff --git a/tools/eslint/node_modules/eslint/lib/rules/no-div-regex.js b/tools/eslint/node_modules/eslint/lib/rules/no-div-regex.js deleted file mode 100644 index 208f840bef68c4..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/rules/no-div-regex.js +++ /dev/null @@ -1,53 +0,0 @@ -/** - * @fileoverview Rule to check for ambiguous div operator in regexes - * @author Matt DuVall - */ - -"use strict"; - -//------------------------------------------------------------------------------ -// Rule Definition -//------------------------------------------------------------------------------ - -/** @type {import('../shared/types').Rule} */ -module.exports = { - meta: { - type: "suggestion", - - docs: { - description: "Disallow equal signs explicitly at the beginning of regular expressions", - recommended: false, - url: "https://eslint.org/docs/latest/rules/no-div-regex" - }, - - fixable: "code", - - schema: [], - - messages: { - unexpected: "A regular expression literal can be confused with '/='." - } - }, - - create(context) { - const sourceCode = context.sourceCode; - - return { - - Literal(node) { - const token = sourceCode.getFirstToken(node); - - if (token.type === "RegularExpression" && token.value[1] === "=") { - context.report({ - node, - messageId: "unexpected", - fix(fixer) { - return fixer.replaceTextRange([token.range[0] + 1, token.range[0] + 2], "[=]"); - } - }); - } - } - }; - - } -}; diff --git a/tools/eslint/node_modules/eslint/lib/rules/no-dupe-args.js b/tools/eslint/node_modules/eslint/lib/rules/no-dupe-args.js deleted file mode 100644 index c04ede5af58d59..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/rules/no-dupe-args.js +++ /dev/null @@ -1,82 +0,0 @@ -/** - * @fileoverview Rule to flag duplicate arguments - * @author Jamund Ferguson - */ - -"use strict"; - -//------------------------------------------------------------------------------ -// Rule Definition -//------------------------------------------------------------------------------ - -/** @type {import('../shared/types').Rule} */ -module.exports = { - meta: { - type: "problem", - - docs: { - description: "Disallow duplicate arguments in `function` definitions", - recommended: true, - url: "https://eslint.org/docs/latest/rules/no-dupe-args" - }, - - schema: [], - - messages: { - unexpected: "Duplicate param '{{name}}'." - } - }, - - create(context) { - - const sourceCode = context.sourceCode; - - //-------------------------------------------------------------------------- - // Helpers - //-------------------------------------------------------------------------- - - /** - * Checks whether or not a given definition is a parameter's. - * @param {eslint-scope.DefEntry} def A definition to check. - * @returns {boolean} `true` if the definition is a parameter's. - */ - function isParameter(def) { - return def.type === "Parameter"; - } - - /** - * Determines if a given node has duplicate parameters. - * @param {ASTNode} node The node to check. - * @returns {void} - * @private - */ - function checkParams(node) { - const variables = sourceCode.getDeclaredVariables(node); - - for (let i = 0; i < variables.length; ++i) { - const variable = variables[i]; - - // Checks and reports duplications. - const defs = variable.defs.filter(isParameter); - - if (defs.length >= 2) { - context.report({ - node, - messageId: "unexpected", - data: { name: variable.name } - }); - } - } - } - - //-------------------------------------------------------------------------- - // Public API - //-------------------------------------------------------------------------- - - return { - FunctionDeclaration: checkParams, - FunctionExpression: checkParams - }; - - } -}; diff --git a/tools/eslint/node_modules/eslint/lib/rules/no-dupe-class-members.js b/tools/eslint/node_modules/eslint/lib/rules/no-dupe-class-members.js deleted file mode 100644 index c33553217590b0..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/rules/no-dupe-class-members.js +++ /dev/null @@ -1,104 +0,0 @@ -/** - * @fileoverview A rule to disallow duplicate name in class members. - * @author Toru Nagashima - */ - -"use strict"; - -const astUtils = require("./utils/ast-utils"); - -//------------------------------------------------------------------------------ -// Rule Definition -//------------------------------------------------------------------------------ - -/** @type {import('../shared/types').Rule} */ -module.exports = { - meta: { - type: "problem", - - docs: { - description: "Disallow duplicate class members", - recommended: true, - url: "https://eslint.org/docs/latest/rules/no-dupe-class-members" - }, - - schema: [], - - messages: { - unexpected: "Duplicate name '{{name}}'." - } - }, - - create(context) { - let stack = []; - - /** - * Gets state of a given member name. - * @param {string} name A name of a member. - * @param {boolean} isStatic A flag which specifies that is a static member. - * @returns {Object} A state of a given member name. - * - retv.init {boolean} A flag which shows the name is declared as normal member. - * - retv.get {boolean} A flag which shows the name is declared as getter. - * - retv.set {boolean} A flag which shows the name is declared as setter. - */ - function getState(name, isStatic) { - const stateMap = stack.at(-1); - const key = `$${name}`; // to avoid "__proto__". - - if (!stateMap[key]) { - stateMap[key] = { - nonStatic: { init: false, get: false, set: false }, - static: { init: false, get: false, set: false } - }; - } - - return stateMap[key][isStatic ? "static" : "nonStatic"]; - } - - return { - - // Initializes the stack of state of member declarations. - Program() { - stack = []; - }, - - // Initializes state of member declarations for the class. - ClassBody() { - stack.push(Object.create(null)); - }, - - // Disposes the state for the class. - "ClassBody:exit"() { - stack.pop(); - }, - - // Reports the node if its name has been declared already. - "MethodDefinition, PropertyDefinition"(node) { - const name = astUtils.getStaticPropertyName(node); - const kind = node.type === "MethodDefinition" ? node.kind : "field"; - - if (name === null || kind === "constructor") { - return; - } - - const state = getState(name, node.static); - let isDuplicate; - - if (kind === "get") { - isDuplicate = (state.init || state.get); - state.get = true; - } else if (kind === "set") { - isDuplicate = (state.init || state.set); - state.set = true; - } else { - isDuplicate = (state.init || state.get || state.set); - state.init = true; - } - - if (isDuplicate) { - context.report({ node, messageId: "unexpected", data: { name } }); - } - } - }; - } -}; diff --git a/tools/eslint/node_modules/eslint/lib/rules/no-dupe-else-if.js b/tools/eslint/node_modules/eslint/lib/rules/no-dupe-else-if.js deleted file mode 100644 index 60f436d1d79599..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/rules/no-dupe-else-if.js +++ /dev/null @@ -1,122 +0,0 @@ -/** - * @fileoverview Rule to disallow duplicate conditions in if-else-if chains - * @author Milos Djermanovic - */ - -"use strict"; - -//------------------------------------------------------------------------------ -// Requirements -//------------------------------------------------------------------------------ - -const astUtils = require("./utils/ast-utils"); - -//------------------------------------------------------------------------------ -// Helpers -//------------------------------------------------------------------------------ - -/** - * Determines whether the first given array is a subset of the second given array. - * @param {Function} comparator A function to compare two elements, should return `true` if they are equal. - * @param {Array} arrA The array to compare from. - * @param {Array} arrB The array to compare against. - * @returns {boolean} `true` if the array `arrA` is a subset of the array `arrB`. - */ -function isSubsetByComparator(comparator, arrA, arrB) { - return arrA.every(a => arrB.some(b => comparator(a, b))); -} - -/** - * Splits the given node by the given logical operator. - * @param {string} operator Logical operator `||` or `&&`. - * @param {ASTNode} node The node to split. - * @returns {ASTNode[]} Array of conditions that makes the node when joined by the operator. - */ -function splitByLogicalOperator(operator, node) { - if (node.type === "LogicalExpression" && node.operator === operator) { - return [...splitByLogicalOperator(operator, node.left), ...splitByLogicalOperator(operator, node.right)]; - } - return [node]; -} - -const splitByOr = splitByLogicalOperator.bind(null, "||"); -const splitByAnd = splitByLogicalOperator.bind(null, "&&"); - -//------------------------------------------------------------------------------ -// Rule Definition -//------------------------------------------------------------------------------ - -/** @type {import('../shared/types').Rule} */ -module.exports = { - meta: { - type: "problem", - - docs: { - description: "Disallow duplicate conditions in if-else-if chains", - recommended: true, - url: "https://eslint.org/docs/latest/rules/no-dupe-else-if" - }, - - schema: [], - - messages: { - unexpected: "This branch can never execute. Its condition is a duplicate or covered by previous conditions in the if-else-if chain." - } - }, - - create(context) { - const sourceCode = context.sourceCode; - - /** - * Determines whether the two given nodes are considered to be equal. In particular, given that the nodes - * represent expressions in a boolean context, `||` and `&&` can be considered as commutative operators. - * @param {ASTNode} a First node. - * @param {ASTNode} b Second node. - * @returns {boolean} `true` if the nodes are considered to be equal. - */ - function equal(a, b) { - if (a.type !== b.type) { - return false; - } - - if ( - a.type === "LogicalExpression" && - (a.operator === "||" || a.operator === "&&") && - a.operator === b.operator - ) { - return equal(a.left, b.left) && equal(a.right, b.right) || - equal(a.left, b.right) && equal(a.right, b.left); - } - - return astUtils.equalTokens(a, b, sourceCode); - } - - const isSubset = isSubsetByComparator.bind(null, equal); - - return { - IfStatement(node) { - const test = node.test, - conditionsToCheck = test.type === "LogicalExpression" && test.operator === "&&" - ? [test, ...splitByAnd(test)] - : [test]; - let current = node, - listToCheck = conditionsToCheck.map(c => splitByOr(c).map(splitByAnd)); - - while (current.parent && current.parent.type === "IfStatement" && current.parent.alternate === current) { - current = current.parent; - - const currentOrOperands = splitByOr(current.test).map(splitByAnd); - - listToCheck = listToCheck.map(orOperands => orOperands.filter( - orOperand => !currentOrOperands.some(currentOrOperand => isSubset(currentOrOperand, orOperand)) - )); - - if (listToCheck.some(orOperands => orOperands.length === 0)) { - context.report({ node: test, messageId: "unexpected" }); - break; - } - } - } - }; - } -}; diff --git a/tools/eslint/node_modules/eslint/lib/rules/no-dupe-keys.js b/tools/eslint/node_modules/eslint/lib/rules/no-dupe-keys.js deleted file mode 100644 index 980b0044afd21e..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/rules/no-dupe-keys.js +++ /dev/null @@ -1,142 +0,0 @@ -/** - * @fileoverview Rule to flag use of duplicate keys in an object. - * @author Ian Christian Myers - */ - -"use strict"; - -//------------------------------------------------------------------------------ -// Requirements -//------------------------------------------------------------------------------ - -const astUtils = require("./utils/ast-utils"); - -//------------------------------------------------------------------------------ -// Helpers -//------------------------------------------------------------------------------ - -const GET_KIND = /^(?:init|get)$/u; -const SET_KIND = /^(?:init|set)$/u; - -/** - * The class which stores properties' information of an object. - */ -class ObjectInfo { - - /** - * @param {ObjectInfo|null} upper The information of the outer object. - * @param {ASTNode} node The ObjectExpression node of this information. - */ - constructor(upper, node) { - this.upper = upper; - this.node = node; - this.properties = new Map(); - } - - /** - * Gets the information of the given Property node. - * @param {ASTNode} node The Property node to get. - * @returns {{get: boolean, set: boolean}} The information of the property. - */ - getPropertyInfo(node) { - const name = astUtils.getStaticPropertyName(node); - - if (!this.properties.has(name)) { - this.properties.set(name, { get: false, set: false }); - } - return this.properties.get(name); - } - - /** - * Checks whether the given property has been defined already or not. - * @param {ASTNode} node The Property node to check. - * @returns {boolean} `true` if the property has been defined. - */ - isPropertyDefined(node) { - const entry = this.getPropertyInfo(node); - - return ( - (GET_KIND.test(node.kind) && entry.get) || - (SET_KIND.test(node.kind) && entry.set) - ); - } - - /** - * Defines the given property. - * @param {ASTNode} node The Property node to define. - * @returns {void} - */ - defineProperty(node) { - const entry = this.getPropertyInfo(node); - - if (GET_KIND.test(node.kind)) { - entry.get = true; - } - if (SET_KIND.test(node.kind)) { - entry.set = true; - } - } -} - -//------------------------------------------------------------------------------ -// Rule Definition -//------------------------------------------------------------------------------ - -/** @type {import('../shared/types').Rule} */ -module.exports = { - meta: { - type: "problem", - - docs: { - description: "Disallow duplicate keys in object literals", - recommended: true, - url: "https://eslint.org/docs/latest/rules/no-dupe-keys" - }, - - schema: [], - - messages: { - unexpected: "Duplicate key '{{name}}'." - } - }, - - create(context) { - let info = null; - - return { - ObjectExpression(node) { - info = new ObjectInfo(info, node); - }, - "ObjectExpression:exit"() { - info = info.upper; - }, - - Property(node) { - const name = astUtils.getStaticPropertyName(node); - - // Skip destructuring. - if (node.parent.type !== "ObjectExpression") { - return; - } - - // Skip if the name is not static. - if (name === null) { - return; - } - - // Reports if the name is defined already. - if (info.isPropertyDefined(node)) { - context.report({ - node: info.node, - loc: node.key.loc, - messageId: "unexpected", - data: { name } - }); - } - - // Update info. - info.defineProperty(node); - } - }; - } -}; diff --git a/tools/eslint/node_modules/eslint/lib/rules/no-duplicate-case.js b/tools/eslint/node_modules/eslint/lib/rules/no-duplicate-case.js deleted file mode 100644 index 839f357e74fb25..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/rules/no-duplicate-case.js +++ /dev/null @@ -1,71 +0,0 @@ -/** - * @fileoverview Rule to disallow a duplicate case label. - * @author Dieter Oberkofler - * @author Burak Yigit Kaya - */ - -"use strict"; - -//------------------------------------------------------------------------------ -// Requirements -//------------------------------------------------------------------------------ - -const astUtils = require("./utils/ast-utils"); - -//------------------------------------------------------------------------------ -// Rule Definition -//------------------------------------------------------------------------------ - -/** @type {import('../shared/types').Rule} */ -module.exports = { - meta: { - type: "problem", - - docs: { - description: "Disallow duplicate case labels", - recommended: true, - url: "https://eslint.org/docs/latest/rules/no-duplicate-case" - }, - - schema: [], - - messages: { - unexpected: "Duplicate case label." - } - }, - - create(context) { - const sourceCode = context.sourceCode; - - /** - * Determines whether the two given nodes are considered to be equal. - * @param {ASTNode} a First node. - * @param {ASTNode} b Second node. - * @returns {boolean} `true` if the nodes are considered to be equal. - */ - function equal(a, b) { - if (a.type !== b.type) { - return false; - } - - return astUtils.equalTokens(a, b, sourceCode); - } - return { - SwitchStatement(node) { - const previousTests = []; - - for (const switchCase of node.cases) { - if (switchCase.test) { - const test = switchCase.test; - - if (previousTests.some(previousTest => equal(previousTest, test))) { - context.report({ node: switchCase, messageId: "unexpected" }); - } else { - previousTests.push(test); - } - } - } - } - }; - } -}; diff --git a/tools/eslint/node_modules/eslint/lib/rules/no-duplicate-imports.js b/tools/eslint/node_modules/eslint/lib/rules/no-duplicate-imports.js deleted file mode 100644 index 25c07b7500d27b..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/rules/no-duplicate-imports.js +++ /dev/null @@ -1,290 +0,0 @@ -/** - * @fileoverview Restrict usage of duplicate imports. - * @author Simen Bekkhus - */ -"use strict"; - -//------------------------------------------------------------------------------ -// Helpers -//------------------------------------------------------------------------------ - -const NAMED_TYPES = ["ImportSpecifier", "ExportSpecifier"]; -const NAMESPACE_TYPES = [ - "ImportNamespaceSpecifier", - "ExportNamespaceSpecifier" -]; - -//------------------------------------------------------------------------------ -// Rule Definition -//------------------------------------------------------------------------------ - -/** - * Check if an import/export type belongs to (ImportSpecifier|ExportSpecifier) or (ImportNamespaceSpecifier|ExportNamespaceSpecifier). - * @param {string} importExportType An import/export type to check. - * @param {string} type Can be "named" or "namespace" - * @returns {boolean} True if import/export type belongs to (ImportSpecifier|ExportSpecifier) or (ImportNamespaceSpecifier|ExportNamespaceSpecifier) and false if it doesn't. - */ -function isImportExportSpecifier(importExportType, type) { - const arrayToCheck = type === "named" ? NAMED_TYPES : NAMESPACE_TYPES; - - return arrayToCheck.includes(importExportType); -} - -/** - * Return the type of (import|export). - * @param {ASTNode} node A node to get. - * @returns {string} The type of the (import|export). - */ -function getImportExportType(node) { - if (node.specifiers && node.specifiers.length > 0) { - const nodeSpecifiers = node.specifiers; - const index = nodeSpecifiers.findIndex( - ({ type }) => - isImportExportSpecifier(type, "named") || - isImportExportSpecifier(type, "namespace") - ); - const i = index > -1 ? index : 0; - - return nodeSpecifiers[i].type; - } - if (node.type === "ExportAllDeclaration") { - if (node.exported) { - return "ExportNamespaceSpecifier"; - } - return "ExportAll"; - } - return "SideEffectImport"; -} - -/** - * Returns a boolean indicates if two (import|export) can be merged - * @param {ASTNode} node1 A node to check. - * @param {ASTNode} node2 A node to check. - * @returns {boolean} True if two (import|export) can be merged, false if they can't. - */ -function isImportExportCanBeMerged(node1, node2) { - const importExportType1 = getImportExportType(node1); - const importExportType2 = getImportExportType(node2); - - if ( - (importExportType1 === "ExportAll" && - importExportType2 !== "ExportAll" && - importExportType2 !== "SideEffectImport") || - (importExportType1 !== "ExportAll" && - importExportType1 !== "SideEffectImport" && - importExportType2 === "ExportAll") - ) { - return false; - } - if ( - (isImportExportSpecifier(importExportType1, "namespace") && - isImportExportSpecifier(importExportType2, "named")) || - (isImportExportSpecifier(importExportType2, "namespace") && - isImportExportSpecifier(importExportType1, "named")) - ) { - return false; - } - return true; -} - -/** - * Returns a boolean if we should report (import|export). - * @param {ASTNode} node A node to be reported or not. - * @param {[ASTNode]} previousNodes An array contains previous nodes of the module imported or exported. - * @returns {boolean} True if the (import|export) should be reported. - */ -function shouldReportImportExport(node, previousNodes) { - let i = 0; - - while (i < previousNodes.length) { - if (isImportExportCanBeMerged(node, previousNodes[i])) { - return true; - } - i++; - } - return false; -} - -/** - * Returns array contains only nodes with declarations types equal to type. - * @param {[{node: ASTNode, declarationType: string}]} nodes An array contains objects, each object contains a node and a declaration type. - * @param {string} type Declaration type. - * @returns {[ASTNode]} An array contains only nodes with declarations types equal to type. - */ -function getNodesByDeclarationType(nodes, type) { - return nodes - .filter(({ declarationType }) => declarationType === type) - .map(({ node }) => node); -} - -/** - * Returns the name of the module imported or re-exported. - * @param {ASTNode} node A node to get. - * @returns {string} The name of the module, or empty string if no name. - */ -function getModule(node) { - if (node && node.source && node.source.value) { - return node.source.value.trim(); - } - return ""; -} - -/** - * Checks if the (import|export) can be merged with at least one import or one export, and reports if so. - * @param {RuleContext} context The ESLint rule context object. - * @param {ASTNode} node A node to get. - * @param {Map} modules A Map object contains as a key a module name and as value an array contains objects, each object contains a node and a declaration type. - * @param {string} declarationType A declaration type can be an import or export. - * @param {boolean} includeExports Whether or not to check for exports in addition to imports. - * @returns {void} No return value. - */ -function checkAndReport( - context, - node, - modules, - declarationType, - includeExports -) { - const module = getModule(node); - - if (modules.has(module)) { - const previousNodes = modules.get(module); - const messagesIds = []; - const importNodes = getNodesByDeclarationType(previousNodes, "import"); - let exportNodes; - - if (includeExports) { - exportNodes = getNodesByDeclarationType(previousNodes, "export"); - } - if (declarationType === "import") { - if (shouldReportImportExport(node, importNodes)) { - messagesIds.push("import"); - } - if (includeExports) { - if (shouldReportImportExport(node, exportNodes)) { - messagesIds.push("importAs"); - } - } - } else if (declarationType === "export") { - if (shouldReportImportExport(node, exportNodes)) { - messagesIds.push("export"); - } - if (shouldReportImportExport(node, importNodes)) { - messagesIds.push("exportAs"); - } - } - messagesIds.forEach(messageId => - context.report({ - node, - messageId, - data: { - module - } - })); - } -} - -/** - * @callback nodeCallback - * @param {ASTNode} node A node to handle. - */ - -/** - * Returns a function handling the (imports|exports) of a given file - * @param {RuleContext} context The ESLint rule context object. - * @param {Map} modules A Map object contains as a key a module name and as value an array contains objects, each object contains a node and a declaration type. - * @param {string} declarationType A declaration type can be an import or export. - * @param {boolean} includeExports Whether or not to check for exports in addition to imports. - * @returns {nodeCallback} A function passed to ESLint to handle the statement. - */ -function handleImportsExports( - context, - modules, - declarationType, - includeExports -) { - return function(node) { - const module = getModule(node); - - if (module) { - checkAndReport( - context, - node, - modules, - declarationType, - includeExports - ); - const currentNode = { node, declarationType }; - let nodes = [currentNode]; - - if (modules.has(module)) { - const previousNodes = modules.get(module); - - nodes = [...previousNodes, currentNode]; - } - modules.set(module, nodes); - } - }; -} - -/** @type {import('../shared/types').Rule} */ -module.exports = { - meta: { - type: "problem", - - docs: { - description: "Disallow duplicate module imports", - recommended: false, - url: "https://eslint.org/docs/latest/rules/no-duplicate-imports" - }, - - schema: [ - { - type: "object", - properties: { - includeExports: { - type: "boolean", - default: false - } - }, - additionalProperties: false - } - ], - - messages: { - import: "'{{module}}' import is duplicated.", - importAs: "'{{module}}' import is duplicated as export.", - export: "'{{module}}' export is duplicated.", - exportAs: "'{{module}}' export is duplicated as import." - } - }, - - create(context) { - const includeExports = (context.options[0] || {}).includeExports, - modules = new Map(); - const handlers = { - ImportDeclaration: handleImportsExports( - context, - modules, - "import", - includeExports - ) - }; - - if (includeExports) { - handlers.ExportNamedDeclaration = handleImportsExports( - context, - modules, - "export", - includeExports - ); - handlers.ExportAllDeclaration = handleImportsExports( - context, - modules, - "export", - includeExports - ); - } - return handlers; - } -}; diff --git a/tools/eslint/node_modules/eslint/lib/rules/no-else-return.js b/tools/eslint/node_modules/eslint/lib/rules/no-else-return.js deleted file mode 100644 index 6e6bf476dd861c..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/rules/no-else-return.js +++ /dev/null @@ -1,405 +0,0 @@ -/** - * @fileoverview Rule to flag `else` after a `return` in `if` - * @author Ian Christian Myers - */ - -"use strict"; - -//------------------------------------------------------------------------------ -// Requirements -//------------------------------------------------------------------------------ - -const astUtils = require("./utils/ast-utils"); -const FixTracker = require("./utils/fix-tracker"); - -//------------------------------------------------------------------------------ -// Rule Definition -//------------------------------------------------------------------------------ - -/** @type {import('../shared/types').Rule} */ -module.exports = { - meta: { - type: "suggestion", - - docs: { - description: "Disallow `else` blocks after `return` statements in `if` statements", - recommended: false, - url: "https://eslint.org/docs/latest/rules/no-else-return" - }, - - schema: [{ - type: "object", - properties: { - allowElseIf: { - type: "boolean", - default: true - } - }, - additionalProperties: false - }], - - fixable: "code", - - messages: { - unexpected: "Unnecessary 'else' after 'return'." - } - }, - - create(context) { - - const sourceCode = context.sourceCode; - - //-------------------------------------------------------------------------- - // Helpers - //-------------------------------------------------------------------------- - - /** - * Checks whether the given names can be safely used to declare block-scoped variables - * in the given scope. Name collisions can produce redeclaration syntax errors, - * or silently change references and modify behavior of the original code. - * - * This is not a generic function. In particular, it is assumed that the scope is a function scope or - * a function's inner scope, and that the names can be valid identifiers in the given scope. - * @param {string[]} names Array of variable names. - * @param {eslint-scope.Scope} scope Function scope or a function's inner scope. - * @returns {boolean} True if all names can be safely declared, false otherwise. - */ - function isSafeToDeclare(names, scope) { - - if (names.length === 0) { - return true; - } - - const functionScope = scope.variableScope; - - /* - * If this is a function scope, scope.variables will contain parameters, implicit variables such as "arguments", - * all function-scoped variables ('var'), and block-scoped variables defined in the scope. - * If this is an inner scope, scope.variables will contain block-scoped variables defined in the scope. - * - * Redeclaring any of these would cause a syntax error, except for the implicit variables. - */ - const declaredVariables = scope.variables.filter(({ defs }) => defs.length > 0); - - if (declaredVariables.some(({ name }) => names.includes(name))) { - return false; - } - - // Redeclaring a catch variable would also cause a syntax error. - if (scope !== functionScope && scope.upper.type === "catch") { - if (scope.upper.variables.some(({ name }) => names.includes(name))) { - return false; - } - } - - /* - * Redeclaring an implicit variable, such as "arguments", would not cause a syntax error. - * However, if the variable was used, declaring a new one with the same name would change references - * and modify behavior. - */ - const usedImplicitVariables = scope.variables.filter(({ defs, references }) => - defs.length === 0 && references.length > 0); - - if (usedImplicitVariables.some(({ name }) => names.includes(name))) { - return false; - } - - /* - * Declaring a variable with a name that was already used to reference a variable from an upper scope - * would change references and modify behavior. - */ - if (scope.through.some(t => names.includes(t.identifier.name))) { - return false; - } - - /* - * If the scope is an inner scope (not the function scope), an uninitialized `var` variable declared inside - * the scope node (directly or in one of its descendants) is neither declared nor 'through' in the scope. - * - * For example, this would be a syntax error "Identifier 'a' has already been declared": - * function foo() { if (bar) { let a; if (baz) { var a; } } } - */ - if (scope !== functionScope) { - const scopeNodeRange = scope.block.range; - const variablesToCheck = functionScope.variables.filter(({ name }) => names.includes(name)); - - if (variablesToCheck.some(v => v.defs.some(({ node: { range } }) => - scopeNodeRange[0] <= range[0] && range[1] <= scopeNodeRange[1]))) { - return false; - } - } - - return true; - } - - - /** - * Checks whether the removal of `else` and its braces is safe from variable name collisions. - * @param {Node} node The 'else' node. - * @param {eslint-scope.Scope} scope The scope in which the node and the whole 'if' statement is. - * @returns {boolean} True if it is safe, false otherwise. - */ - function isSafeFromNameCollisions(node, scope) { - - if (node.type === "FunctionDeclaration") { - - // Conditional function declaration. Scope and hoisting are unpredictable, different engines work differently. - return false; - } - - if (node.type !== "BlockStatement") { - return true; - } - - const elseBlockScope = scope.childScopes.find(({ block }) => block === node); - - if (!elseBlockScope) { - - // ecmaVersion < 6, `else` block statement cannot have its own scope, no possible collisions. - return true; - } - - /* - * elseBlockScope is supposed to merge into its upper scope. elseBlockScope.variables array contains - * only block-scoped variables (such as let and const variables or class and function declarations) - * defined directly in the elseBlockScope. These are exactly the only names that could cause collisions. - */ - const namesToCheck = elseBlockScope.variables.map(({ name }) => name); - - return isSafeToDeclare(namesToCheck, scope); - } - - /** - * Display the context report if rule is violated - * @param {Node} elseNode The 'else' node - * @returns {void} - */ - function displayReport(elseNode) { - const currentScope = sourceCode.getScope(elseNode.parent); - - context.report({ - node: elseNode, - messageId: "unexpected", - fix(fixer) { - - if (!isSafeFromNameCollisions(elseNode, currentScope)) { - return null; - } - - const startToken = sourceCode.getFirstToken(elseNode); - const elseToken = sourceCode.getTokenBefore(startToken); - const source = sourceCode.getText(elseNode); - const lastIfToken = sourceCode.getTokenBefore(elseToken); - let fixedSource, firstTokenOfElseBlock; - - if (startToken.type === "Punctuator" && startToken.value === "{") { - firstTokenOfElseBlock = sourceCode.getTokenAfter(startToken); - } else { - firstTokenOfElseBlock = startToken; - } - - /* - * If the if block does not have curly braces and does not end in a semicolon - * and the else block starts with (, [, /, +, ` or -, then it is not - * safe to remove the else keyword, because ASI will not add a semicolon - * after the if block - */ - const ifBlockMaybeUnsafe = elseNode.parent.consequent.type !== "BlockStatement" && lastIfToken.value !== ";"; - const elseBlockUnsafe = /^[([/+`-]/u.test(firstTokenOfElseBlock.value); - - if (ifBlockMaybeUnsafe && elseBlockUnsafe) { - return null; - } - - const endToken = sourceCode.getLastToken(elseNode); - const lastTokenOfElseBlock = sourceCode.getTokenBefore(endToken); - - if (lastTokenOfElseBlock.value !== ";") { - const nextToken = sourceCode.getTokenAfter(endToken); - - const nextTokenUnsafe = nextToken && /^[([/+`-]/u.test(nextToken.value); - const nextTokenOnSameLine = nextToken && nextToken.loc.start.line === lastTokenOfElseBlock.loc.start.line; - - /* - * If the else block contents does not end in a semicolon, - * and the else block starts with (, [, /, +, ` or -, then it is not - * safe to remove the else block, because ASI will not add a semicolon - * after the remaining else block contents - */ - if (nextTokenUnsafe || (nextTokenOnSameLine && nextToken.value !== "}")) { - return null; - } - } - - if (startToken.type === "Punctuator" && startToken.value === "{") { - fixedSource = source.slice(1, -1); - } else { - fixedSource = source; - } - - /* - * Extend the replacement range to include the entire - * function to avoid conflicting with no-useless-return. - * https://github.com/eslint/eslint/issues/8026 - * - * Also, to avoid name collisions between two else blocks. - */ - return new FixTracker(fixer, sourceCode) - .retainEnclosingFunction(elseNode) - .replaceTextRange([elseToken.range[0], elseNode.range[1]], fixedSource); - } - }); - } - - /** - * Check to see if the node is a ReturnStatement - * @param {Node} node The node being evaluated - * @returns {boolean} True if node is a return - */ - function checkForReturn(node) { - return node.type === "ReturnStatement"; - } - - /** - * Naive return checking, does not iterate through the whole - * BlockStatement because we make the assumption that the ReturnStatement - * will be the last node in the body of the BlockStatement. - * @param {Node} node The consequent/alternate node - * @returns {boolean} True if it has a return - */ - function naiveHasReturn(node) { - if (node.type === "BlockStatement") { - const body = node.body, - lastChildNode = body.at(-1); - - return lastChildNode && checkForReturn(lastChildNode); - } - return checkForReturn(node); - } - - /** - * Check to see if the node is valid for evaluation, - * meaning it has an else. - * @param {Node} node The node being evaluated - * @returns {boolean} True if the node is valid - */ - function hasElse(node) { - return node.alternate && node.consequent; - } - - /** - * If the consequent is an IfStatement, check to see if it has an else - * and both its consequent and alternate path return, meaning this is - * a nested case of rule violation. If-Else not considered currently. - * @param {Node} node The consequent node - * @returns {boolean} True if this is a nested rule violation - */ - function checkForIf(node) { - return node.type === "IfStatement" && hasElse(node) && - naiveHasReturn(node.alternate) && naiveHasReturn(node.consequent); - } - - /** - * Check the consequent/body node to make sure it is not - * a ReturnStatement or an IfStatement that returns on both - * code paths. - * @param {Node} node The consequent or body node - * @returns {boolean} `true` if it is a Return/If node that always returns. - */ - function checkForReturnOrIf(node) { - return checkForReturn(node) || checkForIf(node); - } - - - /** - * Check whether a node returns in every codepath. - * @param {Node} node The node to be checked - * @returns {boolean} `true` if it returns on every codepath. - */ - function alwaysReturns(node) { - if (node.type === "BlockStatement") { - - // If we have a BlockStatement, check each consequent body node. - return node.body.some(checkForReturnOrIf); - } - - /* - * If not a block statement, make sure the consequent isn't a - * ReturnStatement or an IfStatement with returns on both paths. - */ - return checkForReturnOrIf(node); - } - - - /** - * Check the if statement, but don't catch else-if blocks. - * @returns {void} - * @param {Node} node The node for the if statement to check - * @private - */ - function checkIfWithoutElse(node) { - const parent = node.parent; - - /* - * Fixing this would require splitting one statement into two, so no error should - * be reported if this node is in a position where only one statement is allowed. - */ - if (!astUtils.STATEMENT_LIST_PARENTS.has(parent.type)) { - return; - } - - const consequents = []; - let alternate; - - for (let currentNode = node; currentNode.type === "IfStatement"; currentNode = currentNode.alternate) { - if (!currentNode.alternate) { - return; - } - consequents.push(currentNode.consequent); - alternate = currentNode.alternate; - } - - if (consequents.every(alwaysReturns)) { - displayReport(alternate); - } - } - - /** - * Check the if statement - * @returns {void} - * @param {Node} node The node for the if statement to check - * @private - */ - function checkIfWithElse(node) { - const parent = node.parent; - - - /* - * Fixing this would require splitting one statement into two, so no error should - * be reported if this node is in a position where only one statement is allowed. - */ - if (!astUtils.STATEMENT_LIST_PARENTS.has(parent.type)) { - return; - } - - const alternate = node.alternate; - - if (alternate && alwaysReturns(node.consequent)) { - displayReport(alternate); - } - } - - const allowElseIf = !(context.options[0] && context.options[0].allowElseIf === false); - - //-------------------------------------------------------------------------- - // Public API - //-------------------------------------------------------------------------- - - return { - - "IfStatement:exit": allowElseIf ? checkIfWithoutElse : checkIfWithElse - - }; - - } -}; diff --git a/tools/eslint/node_modules/eslint/lib/rules/no-empty-character-class.js b/tools/eslint/node_modules/eslint/lib/rules/no-empty-character-class.js deleted file mode 100644 index 5c8410235bcca3..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/rules/no-empty-character-class.js +++ /dev/null @@ -1,76 +0,0 @@ -/** - * @fileoverview Rule to flag the use of empty character classes in regular expressions - * @author Ian Christian Myers - */ - -"use strict"; - -//------------------------------------------------------------------------------ -// Requirements -//------------------------------------------------------------------------------ - -const { RegExpParser, visitRegExpAST } = require("@eslint-community/regexpp"); - -//------------------------------------------------------------------------------ -// Helpers -//------------------------------------------------------------------------------ - -const parser = new RegExpParser(); -const QUICK_TEST_REGEX = /\[\]/u; - -//------------------------------------------------------------------------------ -// Rule Definition -//------------------------------------------------------------------------------ - -/** @type {import('../shared/types').Rule} */ -module.exports = { - meta: { - type: "problem", - - docs: { - description: "Disallow empty character classes in regular expressions", - recommended: true, - url: "https://eslint.org/docs/latest/rules/no-empty-character-class" - }, - - schema: [], - - messages: { - unexpected: "Empty class." - } - }, - - create(context) { - return { - "Literal[regex]"(node) { - const { pattern, flags } = node.regex; - - if (!QUICK_TEST_REGEX.test(pattern)) { - return; - } - - let regExpAST; - - try { - regExpAST = parser.parsePattern(pattern, 0, pattern.length, { - unicode: flags.includes("u"), - unicodeSets: flags.includes("v") - }); - } catch { - - // Ignore regular expressions that regexpp cannot parse - return; - } - - visitRegExpAST(regExpAST, { - onCharacterClassEnter(characterClass) { - if (!characterClass.negate && characterClass.elements.length === 0) { - context.report({ node, messageId: "unexpected" }); - } - } - }); - } - }; - - } -}; diff --git a/tools/eslint/node_modules/eslint/lib/rules/no-empty-function.js b/tools/eslint/node_modules/eslint/lib/rules/no-empty-function.js deleted file mode 100644 index b7dee94c4ea587..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/rules/no-empty-function.js +++ /dev/null @@ -1,167 +0,0 @@ -/** - * @fileoverview Rule to disallow empty functions. - * @author Toru Nagashima - */ - -"use strict"; - -//------------------------------------------------------------------------------ -// Requirements -//------------------------------------------------------------------------------ - -const astUtils = require("./utils/ast-utils"); - -//------------------------------------------------------------------------------ -// Helpers -//------------------------------------------------------------------------------ - -const ALLOW_OPTIONS = Object.freeze([ - "functions", - "arrowFunctions", - "generatorFunctions", - "methods", - "generatorMethods", - "getters", - "setters", - "constructors", - "asyncFunctions", - "asyncMethods" -]); - -/** - * Gets the kind of a given function node. - * @param {ASTNode} node A function node to get. This is one of - * an ArrowFunctionExpression, a FunctionDeclaration, or a - * FunctionExpression. - * @returns {string} The kind of the function. This is one of "functions", - * "arrowFunctions", "generatorFunctions", "asyncFunctions", "methods", - * "generatorMethods", "asyncMethods", "getters", "setters", and - * "constructors". - */ -function getKind(node) { - const parent = node.parent; - let kind; - - if (node.type === "ArrowFunctionExpression") { - return "arrowFunctions"; - } - - // Detects main kind. - if (parent.type === "Property") { - if (parent.kind === "get") { - return "getters"; - } - if (parent.kind === "set") { - return "setters"; - } - kind = parent.method ? "methods" : "functions"; - - } else if (parent.type === "MethodDefinition") { - if (parent.kind === "get") { - return "getters"; - } - if (parent.kind === "set") { - return "setters"; - } - if (parent.kind === "constructor") { - return "constructors"; - } - kind = "methods"; - - } else { - kind = "functions"; - } - - // Detects prefix. - let prefix; - - if (node.generator) { - prefix = "generator"; - } else if (node.async) { - prefix = "async"; - } else { - return kind; - } - return prefix + kind[0].toUpperCase() + kind.slice(1); -} - -//------------------------------------------------------------------------------ -// Rule Definition -//------------------------------------------------------------------------------ - -/** @type {import('../shared/types').Rule} */ -module.exports = { - meta: { - type: "suggestion", - - docs: { - description: "Disallow empty functions", - recommended: false, - url: "https://eslint.org/docs/latest/rules/no-empty-function" - }, - - schema: [ - { - type: "object", - properties: { - allow: { - type: "array", - items: { enum: ALLOW_OPTIONS }, - uniqueItems: true - } - }, - additionalProperties: false - } - ], - - messages: { - unexpected: "Unexpected empty {{name}}." - } - }, - - create(context) { - const options = context.options[0] || {}; - const allowed = options.allow || []; - - const sourceCode = context.sourceCode; - - /** - * Reports a given function node if the node matches the following patterns. - * - * - Not allowed by options. - * - The body is empty. - * - The body doesn't have any comments. - * @param {ASTNode} node A function node to report. This is one of - * an ArrowFunctionExpression, a FunctionDeclaration, or a - * FunctionExpression. - * @returns {void} - */ - function reportIfEmpty(node) { - const kind = getKind(node); - const name = astUtils.getFunctionNameWithKind(node); - const innerComments = sourceCode.getTokens(node.body, { - includeComments: true, - filter: astUtils.isCommentToken - }); - - if (!allowed.includes(kind) && - node.body.type === "BlockStatement" && - node.body.body.length === 0 && - innerComments.length === 0 - ) { - context.report({ - node, - loc: node.body.loc, - messageId: "unexpected", - data: { name } - }); - } - } - - return { - ArrowFunctionExpression: reportIfEmpty, - FunctionDeclaration: reportIfEmpty, - FunctionExpression: reportIfEmpty - }; - } -}; diff --git a/tools/eslint/node_modules/eslint/lib/rules/no-empty-pattern.js b/tools/eslint/node_modules/eslint/lib/rules/no-empty-pattern.js deleted file mode 100644 index fb75f6d25b3458..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/rules/no-empty-pattern.js +++ /dev/null @@ -1,78 +0,0 @@ -/** - * @fileoverview Rule to disallow an empty pattern - * @author Alberto Rodrรญguez - */ -"use strict"; - -const astUtils = require("./utils/ast-utils"); - -//------------------------------------------------------------------------------ -// Rule Definition -//------------------------------------------------------------------------------ - -/** @type {import('../shared/types').Rule} */ -module.exports = { - meta: { - type: "problem", - - docs: { - description: "Disallow empty destructuring patterns", - recommended: true, - url: "https://eslint.org/docs/latest/rules/no-empty-pattern" - }, - - schema: [ - { - type: "object", - properties: { - allowObjectPatternsAsParameters: { - type: "boolean", - default: false - } - }, - additionalProperties: false - } - ], - - messages: { - unexpected: "Unexpected empty {{type}} pattern." - } - }, - - create(context) { - const options = context.options[0] || {}, - allowObjectPatternsAsParameters = options.allowObjectPatternsAsParameters || false; - - return { - ObjectPattern(node) { - - if (node.properties.length > 0) { - return; - } - - // Allow {} and {} = {} empty object patterns as parameters when allowObjectPatternsAsParameters is true - if ( - allowObjectPatternsAsParameters && - ( - astUtils.isFunction(node.parent) || - ( - node.parent.type === "AssignmentPattern" && - astUtils.isFunction(node.parent.parent) && - node.parent.right.type === "ObjectExpression" && - node.parent.right.properties.length === 0 - ) - ) - ) { - return; - } - - context.report({ node, messageId: "unexpected", data: { type: "object" } }); - }, - ArrayPattern(node) { - if (node.elements.length === 0) { - context.report({ node, messageId: "unexpected", data: { type: "array" } }); - } - } - }; - } -}; diff --git a/tools/eslint/node_modules/eslint/lib/rules/no-empty-static-block.js b/tools/eslint/node_modules/eslint/lib/rules/no-empty-static-block.js deleted file mode 100644 index 558c4fad4552e1..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/rules/no-empty-static-block.js +++ /dev/null @@ -1,47 +0,0 @@ -/** - * @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: true, - url: "https://eslint.org/docs/latest/rules/no-empty-static-block" - }, - - schema: [], - - messages: { - unexpected: "Unexpected empty static block." - } - }, - - create(context) { - const sourceCode = context.sourceCode; - - return { - StaticBlock(node) { - if (node.body.length === 0) { - const closingBrace = sourceCode.getLastToken(node); - - if (sourceCode.getCommentsBefore(closingBrace).length === 0) { - context.report({ - node, - messageId: "unexpected" - }); - } - } - } - }; - } -}; diff --git a/tools/eslint/node_modules/eslint/lib/rules/no-empty.js b/tools/eslint/node_modules/eslint/lib/rules/no-empty.js deleted file mode 100644 index 1c157963e9d42f..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/rules/no-empty.js +++ /dev/null @@ -1,103 +0,0 @@ -/** - * @fileoverview Rule to flag use of an empty block statement - * @author Nicholas C. Zakas - */ -"use strict"; - -//------------------------------------------------------------------------------ -// Requirements -//------------------------------------------------------------------------------ - -const astUtils = require("./utils/ast-utils"); - -//------------------------------------------------------------------------------ -// Rule Definition -//------------------------------------------------------------------------------ - -/** @type {import('../shared/types').Rule} */ -module.exports = { - meta: { - hasSuggestions: true, - type: "suggestion", - - docs: { - description: "Disallow empty block statements", - recommended: true, - url: "https://eslint.org/docs/latest/rules/no-empty" - }, - - schema: [ - { - type: "object", - properties: { - allowEmptyCatch: { - type: "boolean", - default: false - } - }, - additionalProperties: false - } - ], - - messages: { - unexpected: "Empty {{type}} statement.", - suggestComment: "Add comment inside empty {{type}} statement." - } - }, - - create(context) { - const options = context.options[0] || {}, - allowEmptyCatch = options.allowEmptyCatch || false; - - const sourceCode = context.sourceCode; - - return { - BlockStatement(node) { - - // if the body is not empty, we can just return immediately - if (node.body.length !== 0) { - return; - } - - // a function is generally allowed to be empty - if (astUtils.isFunction(node.parent)) { - return; - } - - if (allowEmptyCatch && node.parent.type === "CatchClause") { - return; - } - - // any other block is only allowed to be empty, if it contains a comment - if (sourceCode.getCommentsInside(node).length > 0) { - return; - } - - 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) { - - if (typeof node.cases === "undefined" || node.cases.length === 0) { - context.report({ node, messageId: "unexpected", data: { type: "switch" } }); - } - } - }; - - } -}; diff --git a/tools/eslint/node_modules/eslint/lib/rules/no-eq-null.js b/tools/eslint/node_modules/eslint/lib/rules/no-eq-null.js deleted file mode 100644 index 9252907b6b697c..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/rules/no-eq-null.js +++ /dev/null @@ -1,46 +0,0 @@ -/** - * @fileoverview Rule to flag comparisons to null without a type-checking - * operator. - * @author Ian Christian Myers - */ - -"use strict"; - -//------------------------------------------------------------------------------ -// Rule Definition -//------------------------------------------------------------------------------ - -/** @type {import('../shared/types').Rule} */ -module.exports = { - meta: { - type: "suggestion", - - docs: { - description: "Disallow `null` comparisons without type-checking operators", - recommended: false, - url: "https://eslint.org/docs/latest/rules/no-eq-null" - }, - - schema: [], - - messages: { - unexpected: "Use '===' to compare with null." - } - }, - - create(context) { - - return { - - BinaryExpression(node) { - const badOperator = node.operator === "==" || node.operator === "!="; - - if (node.right.type === "Literal" && node.right.raw === "null" && badOperator || - node.left.type === "Literal" && node.left.raw === "null" && badOperator) { - context.report({ node, messageId: "unexpected" }); - } - } - }; - - } -}; diff --git a/tools/eslint/node_modules/eslint/lib/rules/no-eval.js b/tools/eslint/node_modules/eslint/lib/rules/no-eval.js deleted file mode 100644 index a059526a68be57..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/rules/no-eval.js +++ /dev/null @@ -1,286 +0,0 @@ -/** - * @fileoverview Rule to flag use of eval() statement - * @author Nicholas C. Zakas - */ - -"use strict"; - -//------------------------------------------------------------------------------ -// Requirements -//------------------------------------------------------------------------------ - -const astUtils = require("./utils/ast-utils"); - -//------------------------------------------------------------------------------ -// Helpers -//------------------------------------------------------------------------------ - -const candidatesOfGlobalObject = Object.freeze([ - "global", - "window", - "globalThis" -]); - -/** - * Checks a given node is a MemberExpression node which has the specified name's - * property. - * @param {ASTNode} node A node to check. - * @param {string} name A name to check. - * @returns {boolean} `true` if the node is a MemberExpression node which has - * the specified name's property - */ -function isMember(node, name) { - return astUtils.isSpecificMemberAccess(node, null, name); -} - -//------------------------------------------------------------------------------ -// Rule Definition -//------------------------------------------------------------------------------ - -/** @type {import('../shared/types').Rule} */ -module.exports = { - meta: { - type: "suggestion", - - docs: { - description: "Disallow the use of `eval()`", - recommended: false, - url: "https://eslint.org/docs/latest/rules/no-eval" - }, - - schema: [ - { - type: "object", - properties: { - allowIndirect: { type: "boolean", default: false } - }, - additionalProperties: false - } - ], - - messages: { - unexpected: "eval can be harmful." - } - }, - - create(context) { - const allowIndirect = Boolean( - context.options[0] && - context.options[0].allowIndirect - ); - const sourceCode = context.sourceCode; - let funcInfo = null; - - /** - * Pushes a `this` scope (non-arrow function, class static block, or class field initializer) information to the stack. - * Top-level scopes are handled separately. - * - * This is used in order to check whether or not `this` binding is a - * reference to the global object. - * @param {ASTNode} node A node of the scope. - * For functions, this is one of FunctionDeclaration, FunctionExpression. - * For class static blocks, this is StaticBlock. - * For class field initializers, this can be any node that is PropertyDefinition#value. - * @returns {void} - */ - function enterThisScope(node) { - const strict = sourceCode.getScope(node).isStrict; - - funcInfo = { - upper: funcInfo, - node, - strict, - isTopLevelOfScript: false, - defaultThis: false, - initialized: strict - }; - } - - /** - * Pops a variable scope from the stack. - * @returns {void} - */ - function exitThisScope() { - funcInfo = funcInfo.upper; - } - - /** - * Reports a given node. - * - * `node` is `Identifier` or `MemberExpression`. - * The parent of `node` might be `CallExpression`. - * - * The location of the report is always `eval` `Identifier` (or possibly - * `Literal`). The type of the report is `CallExpression` if the parent is - * `CallExpression`. Otherwise, it's the given node type. - * @param {ASTNode} node A node to report. - * @returns {void} - */ - function report(node) { - const parent = node.parent; - const locationNode = node.type === "MemberExpression" - ? node.property - : node; - - const reportNode = parent.type === "CallExpression" && parent.callee === node - ? parent - : node; - - context.report({ - node: reportNode, - loc: locationNode.loc, - messageId: "unexpected" - }); - } - - /** - * Reports accesses of `eval` via the global object. - * @param {eslint-scope.Scope} globalScope The global scope. - * @returns {void} - */ - function reportAccessingEvalViaGlobalObject(globalScope) { - for (let i = 0; i < candidatesOfGlobalObject.length; ++i) { - const name = candidatesOfGlobalObject[i]; - const variable = astUtils.getVariableByName(globalScope, name); - - if (!variable) { - continue; - } - - const references = variable.references; - - for (let j = 0; j < references.length; ++j) { - const identifier = references[j].identifier; - let node = identifier.parent; - - // To detect code like `window.window.eval`. - while (isMember(node, name)) { - node = node.parent; - } - - // Reports. - if (isMember(node, "eval")) { - report(node); - } - } - } - } - - /** - * Reports all accesses of `eval` (excludes direct calls to eval). - * @param {eslint-scope.Scope} globalScope The global scope. - * @returns {void} - */ - function reportAccessingEval(globalScope) { - const variable = astUtils.getVariableByName(globalScope, "eval"); - - if (!variable) { - return; - } - - const references = variable.references; - - for (let i = 0; i < references.length; ++i) { - const reference = references[i]; - const id = reference.identifier; - - if (id.name === "eval" && !astUtils.isCallee(id)) { - - // Is accessing to eval (excludes direct calls to eval) - report(id); - } - } - } - - if (allowIndirect) { - - // Checks only direct calls to eval. It's simple! - return { - "CallExpression:exit"(node) { - const callee = node.callee; - - /* - * Optional call (`eval?.("code")`) is not direct eval. - * The direct eval is only step 6.a.vi of https://tc39.es/ecma262/#sec-function-calls-runtime-semantics-evaluation - * But the optional call is https://tc39.es/ecma262/#sec-optional-chaining-chain-evaluation - */ - if (!node.optional && astUtils.isSpecificId(callee, "eval")) { - report(callee); - } - } - }; - } - - return { - "CallExpression:exit"(node) { - const callee = node.callee; - - if (astUtils.isSpecificId(callee, "eval")) { - report(callee); - } - }, - - Program(node) { - const scope = sourceCode.getScope(node), - features = context.parserOptions.ecmaFeatures || {}, - strict = - scope.isStrict || - node.sourceType === "module" || - (features.globalReturn && scope.childScopes[0].isStrict), - isTopLevelOfScript = node.sourceType !== "module" && !features.globalReturn; - - funcInfo = { - upper: null, - node, - strict, - isTopLevelOfScript, - defaultThis: true, - initialized: true - }; - }, - - "Program:exit"(node) { - const globalScope = sourceCode.getScope(node); - - exitThisScope(); - reportAccessingEval(globalScope); - reportAccessingEvalViaGlobalObject(globalScope); - }, - - FunctionDeclaration: enterThisScope, - "FunctionDeclaration:exit": exitThisScope, - FunctionExpression: enterThisScope, - "FunctionExpression:exit": exitThisScope, - "PropertyDefinition > *.value": enterThisScope, - "PropertyDefinition > *.value:exit": exitThisScope, - StaticBlock: enterThisScope, - "StaticBlock:exit": exitThisScope, - - ThisExpression(node) { - if (!isMember(node.parent, "eval")) { - return; - } - - /* - * `this.eval` is found. - * Checks whether or not the value of `this` is the global object. - */ - if (!funcInfo.initialized) { - funcInfo.initialized = true; - funcInfo.defaultThis = astUtils.isDefaultThisBinding( - funcInfo.node, - sourceCode - ); - } - - // `this` at the top level of scripts always refers to the global object - if (funcInfo.isTopLevelOfScript || (!funcInfo.strict && funcInfo.defaultThis)) { - - // `this.eval` is possible built-in `eval`. - report(node.parent); - } - } - }; - - } -}; diff --git a/tools/eslint/node_modules/eslint/lib/rules/no-ex-assign.js b/tools/eslint/node_modules/eslint/lib/rules/no-ex-assign.js deleted file mode 100644 index d0e9febae04130..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/rules/no-ex-assign.js +++ /dev/null @@ -1,54 +0,0 @@ -/** - * @fileoverview Rule to flag assignment of the exception parameter - * @author Stephen Murray - */ - -"use strict"; - -const astUtils = require("./utils/ast-utils"); - -//------------------------------------------------------------------------------ -// Rule Definition -//------------------------------------------------------------------------------ - -/** @type {import('../shared/types').Rule} */ -module.exports = { - meta: { - type: "problem", - - docs: { - description: "Disallow reassigning exceptions in `catch` clauses", - recommended: true, - url: "https://eslint.org/docs/latest/rules/no-ex-assign" - }, - - schema: [], - - messages: { - unexpected: "Do not assign to the exception parameter." - } - }, - - create(context) { - - const sourceCode = context.sourceCode; - - /** - * Finds and reports references that are non initializer and writable. - * @param {Variable} variable A variable to check. - * @returns {void} - */ - function checkVariable(variable) { - astUtils.getModifyingReferences(variable.references).forEach(reference => { - context.report({ node: reference.identifier, messageId: "unexpected" }); - }); - } - - return { - CatchClause(node) { - sourceCode.getDeclaredVariables(node).forEach(checkVariable); - } - }; - - } -}; diff --git a/tools/eslint/node_modules/eslint/lib/rules/no-extend-native.js b/tools/eslint/node_modules/eslint/lib/rules/no-extend-native.js deleted file mode 100644 index a69dd6900391c7..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/rules/no-extend-native.js +++ /dev/null @@ -1,178 +0,0 @@ -/** - * @fileoverview Rule to flag adding properties to native object's prototypes. - * @author David Nelson - */ - -"use strict"; - -//------------------------------------------------------------------------------ -// Requirements -//------------------------------------------------------------------------------ - -const astUtils = require("./utils/ast-utils"); - -//------------------------------------------------------------------------------ -// Rule Definition -//------------------------------------------------------------------------------ - -/** @type {import('../shared/types').Rule} */ -module.exports = { - meta: { - type: "suggestion", - - docs: { - description: "Disallow extending native types", - recommended: false, - url: "https://eslint.org/docs/latest/rules/no-extend-native" - }, - - schema: [ - { - type: "object", - properties: { - exceptions: { - type: "array", - items: { - type: "string" - }, - uniqueItems: true - } - }, - additionalProperties: false - } - ], - - messages: { - unexpected: "{{builtin}} prototype is read only, properties should not be added." - } - }, - - create(context) { - - const config = context.options[0] || {}; - const sourceCode = context.sourceCode; - const exceptions = new Set(config.exceptions || []); - const modifiedBuiltins = new Set( - Object.keys(astUtils.ECMASCRIPT_GLOBALS) - .filter(builtin => builtin[0].toUpperCase() === builtin[0]) - .filter(builtin => !exceptions.has(builtin)) - ); - - /** - * Reports a lint error for the given node. - * @param {ASTNode} node The node to report. - * @param {string} builtin The name of the native builtin being extended. - * @returns {void} - */ - function reportNode(node, builtin) { - context.report({ - node, - messageId: "unexpected", - data: { - builtin - } - }); - } - - /** - * Check to see if the `prototype` property of the given object - * identifier node is being accessed. - * @param {ASTNode} identifierNode The Identifier representing the object - * to check. - * @returns {boolean} True if the identifier is the object of a - * MemberExpression and its `prototype` property is being accessed, - * false otherwise. - */ - function isPrototypePropertyAccessed(identifierNode) { - return Boolean( - identifierNode && - identifierNode.parent && - identifierNode.parent.type === "MemberExpression" && - identifierNode.parent.object === identifierNode && - astUtils.getStaticPropertyName(identifierNode.parent) === "prototype" - ); - } - - /** - * Check if it's an assignment to the property of the given node. - * Example: `*.prop = 0` // the `*` is the given node. - * @param {ASTNode} node The node to check. - * @returns {boolean} True if an assignment to the property of the node. - */ - function isAssigningToPropertyOf(node) { - return ( - node.parent.type === "MemberExpression" && - node.parent.object === node && - node.parent.parent.type === "AssignmentExpression" && - node.parent.parent.left === node.parent - ); - } - - /** - * Checks if the given node is at the first argument of the method call of `Object.defineProperty()` or `Object.defineProperties()`. - * @param {ASTNode} node The node to check. - * @returns {boolean} True if the node is at the first argument of the method call of `Object.defineProperty()` or `Object.defineProperties()`. - */ - function isInDefinePropertyCall(node) { - return ( - node.parent.type === "CallExpression" && - node.parent.arguments[0] === node && - astUtils.isSpecificMemberAccess(node.parent.callee, "Object", /^definePropert(?:y|ies)$/u) - ); - } - - /** - * Check to see if object prototype access is part of a prototype - * extension. There are three ways a prototype can be extended: - * 1. Assignment to prototype property (Object.prototype.foo = 1) - * 2. Object.defineProperty()/Object.defineProperties() on a prototype - * If prototype extension is detected, report the AssignmentExpression - * or CallExpression node. - * @param {ASTNode} identifierNode The Identifier representing the object - * which prototype is being accessed and possibly extended. - * @returns {void} - */ - function checkAndReportPrototypeExtension(identifierNode) { - if (!isPrototypePropertyAccessed(identifierNode)) { - return; // This is not `*.prototype` access. - } - - /* - * `identifierNode.parent` is a MemberExpression `*.prototype`. - * If it's an optional member access, it may be wrapped by a `ChainExpression` node. - */ - const prototypeNode = - identifierNode.parent.parent.type === "ChainExpression" - ? identifierNode.parent.parent - : identifierNode.parent; - - if (isAssigningToPropertyOf(prototypeNode)) { - - // `*.prototype` -> MemberExpression -> AssignmentExpression - reportNode(prototypeNode.parent.parent, identifierNode.name); - } else if (isInDefinePropertyCall(prototypeNode)) { - - // `*.prototype` -> CallExpression - reportNode(prototypeNode.parent, identifierNode.name); - } - } - - return { - - "Program:exit"(node) { - const globalScope = sourceCode.getScope(node); - - modifiedBuiltins.forEach(builtin => { - const builtinVar = globalScope.set.get(builtin); - - if (builtinVar && builtinVar.references) { - builtinVar.references - .map(ref => ref.identifier) - .forEach(checkAndReportPrototypeExtension); - } - }); - } - }; - - } -}; diff --git a/tools/eslint/node_modules/eslint/lib/rules/no-extra-bind.js b/tools/eslint/node_modules/eslint/lib/rules/no-extra-bind.js deleted file mode 100644 index e1e72b0c7452af..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/rules/no-extra-bind.js +++ /dev/null @@ -1,213 +0,0 @@ -/** - * @fileoverview Rule to flag unnecessary bind calls - * @author Bence Dรกnyi - */ -"use strict"; - -//------------------------------------------------------------------------------ -// Requirements -//------------------------------------------------------------------------------ - -const astUtils = require("./utils/ast-utils"); - -//------------------------------------------------------------------------------ -// Helpers -//------------------------------------------------------------------------------ - -const SIDE_EFFECT_FREE_NODE_TYPES = new Set(["Literal", "Identifier", "ThisExpression", "FunctionExpression"]); - -//------------------------------------------------------------------------------ -// Rule Definition -//------------------------------------------------------------------------------ - -/** @type {import('../shared/types').Rule} */ -module.exports = { - meta: { - type: "suggestion", - - docs: { - description: "Disallow unnecessary calls to `.bind()`", - recommended: false, - url: "https://eslint.org/docs/latest/rules/no-extra-bind" - }, - - schema: [], - fixable: "code", - - messages: { - unexpected: "The function binding is unnecessary." - } - }, - - create(context) { - const sourceCode = context.sourceCode; - let scopeInfo = null; - - /** - * Checks if a node is free of side effects. - * - * This check is stricter than it needs to be, in order to keep the implementation simple. - * @param {ASTNode} node A node to check. - * @returns {boolean} True if the node is known to be side-effect free, false otherwise. - */ - function isSideEffectFree(node) { - return SIDE_EFFECT_FREE_NODE_TYPES.has(node.type); - } - - /** - * Reports a given function node. - * @param {ASTNode} node A node to report. This is a FunctionExpression or - * an ArrowFunctionExpression. - * @returns {void} - */ - function report(node) { - const memberNode = node.parent; - const callNode = memberNode.parent.type === "ChainExpression" - ? memberNode.parent.parent - : memberNode.parent; - - context.report({ - node: callNode, - messageId: "unexpected", - loc: memberNode.property.loc, - - fix(fixer) { - if (!isSideEffectFree(callNode.arguments[0])) { - return null; - } - - /* - * The list of the first/last token pair of a removal range. - * This is two parts because closing parentheses may exist between the method name and arguments. - * E.g. `(function(){}.bind ) (obj)` - * ^^^^^ ^^^^^ < removal ranges - * E.g. `(function(){}?.['bind'] ) ?.(obj)` - * ^^^^^^^^^^ ^^^^^^^ < removal ranges - */ - const tokenPairs = [ - [ - - // `.`, `?.`, or `[` token. - sourceCode.getTokenAfter( - memberNode.object, - astUtils.isNotClosingParenToken - ), - - // property name or `]` token. - sourceCode.getLastToken(memberNode) - ], - [ - - // `?.` or `(` token of arguments. - sourceCode.getTokenAfter( - memberNode, - astUtils.isNotClosingParenToken - ), - - // `)` token of arguments. - sourceCode.getLastToken(callNode) - ] - ]; - const firstTokenToRemove = tokenPairs[0][0]; - const lastTokenToRemove = tokenPairs[1][1]; - - if (sourceCode.commentsExistBetween(firstTokenToRemove, lastTokenToRemove)) { - return null; - } - - return tokenPairs.map(([start, end]) => - fixer.removeRange([start.range[0], end.range[1]])); - } - }); - } - - /** - * Checks whether or not a given function node is the callee of `.bind()` - * method. - * - * e.g. `(function() {}.bind(foo))` - * @param {ASTNode} node A node to report. This is a FunctionExpression or - * an ArrowFunctionExpression. - * @returns {boolean} `true` if the node is the callee of `.bind()` method. - */ - function isCalleeOfBindMethod(node) { - if (!astUtils.isSpecificMemberAccess(node.parent, null, "bind")) { - return false; - } - - // The node of `*.bind` member access. - const bindNode = node.parent.parent.type === "ChainExpression" - ? node.parent.parent - : node.parent; - - return ( - bindNode.parent.type === "CallExpression" && - bindNode.parent.callee === bindNode && - bindNode.parent.arguments.length === 1 && - bindNode.parent.arguments[0].type !== "SpreadElement" - ); - } - - /** - * Adds a scope information object to the stack. - * @param {ASTNode} node A node to add. This node is a FunctionExpression - * or a FunctionDeclaration node. - * @returns {void} - */ - function enterFunction(node) { - scopeInfo = { - isBound: isCalleeOfBindMethod(node), - thisFound: false, - upper: scopeInfo - }; - } - - /** - * Removes the scope information object from the top of the stack. - * At the same time, this reports the function node if the function has - * `.bind()` and the `this` keywords found. - * @param {ASTNode} node A node to remove. This node is a - * FunctionExpression or a FunctionDeclaration node. - * @returns {void} - */ - function exitFunction(node) { - if (scopeInfo.isBound && !scopeInfo.thisFound) { - report(node); - } - - scopeInfo = scopeInfo.upper; - } - - /** - * Reports a given arrow function if the function is callee of `.bind()` - * method. - * @param {ASTNode} node A node to report. This node is an - * ArrowFunctionExpression. - * @returns {void} - */ - function exitArrowFunction(node) { - if (isCalleeOfBindMethod(node)) { - report(node); - } - } - - /** - * Set the mark as the `this` keyword was found in this scope. - * @returns {void} - */ - function markAsThisFound() { - if (scopeInfo) { - scopeInfo.thisFound = true; - } - } - - return { - "ArrowFunctionExpression:exit": exitArrowFunction, - FunctionDeclaration: enterFunction, - "FunctionDeclaration:exit": exitFunction, - FunctionExpression: enterFunction, - "FunctionExpression:exit": exitFunction, - ThisExpression: markAsThisFound - }; - } -}; diff --git a/tools/eslint/node_modules/eslint/lib/rules/no-extra-boolean-cast.js b/tools/eslint/node_modules/eslint/lib/rules/no-extra-boolean-cast.js deleted file mode 100644 index 012657b7ec875b..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/rules/no-extra-boolean-cast.js +++ /dev/null @@ -1,369 +0,0 @@ -/** - * @fileoverview Rule to flag unnecessary double negation in Boolean contexts - * @author Brandon Mills - */ - -"use strict"; - -//------------------------------------------------------------------------------ -// Requirements -//------------------------------------------------------------------------------ - -const astUtils = require("./utils/ast-utils"); -const eslintUtils = require("@eslint-community/eslint-utils"); - -const precedence = astUtils.getPrecedence; - -//------------------------------------------------------------------------------ -// Rule Definition -//------------------------------------------------------------------------------ - -/** @type {import('../shared/types').Rule} */ -module.exports = { - meta: { - type: "suggestion", - - docs: { - description: "Disallow unnecessary boolean casts", - recommended: true, - url: "https://eslint.org/docs/latest/rules/no-extra-boolean-cast" - }, - - schema: [{ - anyOf: [ - { - type: "object", - properties: { - enforceForInnerExpressions: { - type: "boolean" - } - }, - additionalProperties: false - }, - - // deprecated - { - type: "object", - properties: { - enforceForLogicalOperands: { - type: "boolean" - } - }, - additionalProperties: false - } - ] - }], - fixable: "code", - - messages: { - unexpectedCall: "Redundant Boolean call.", - unexpectedNegation: "Redundant double negation." - } - }, - - create(context) { - const sourceCode = context.sourceCode; - const enforceForLogicalOperands = context.options[0]?.enforceForLogicalOperands === true; - const enforceForInnerExpressions = context.options[0]?.enforceForInnerExpressions === true; - - - // Node types which have a test which will coerce values to booleans. - const BOOLEAN_NODE_TYPES = new Set([ - "IfStatement", - "DoWhileStatement", - "WhileStatement", - "ConditionalExpression", - "ForStatement" - ]); - - /** - * Check if a node is a Boolean function or constructor. - * @param {ASTNode} node the node - * @returns {boolean} If the node is Boolean function or constructor - */ - function isBooleanFunctionOrConstructorCall(node) { - - // Boolean() and new Boolean() - return (node.type === "CallExpression" || node.type === "NewExpression") && - node.callee.type === "Identifier" && - node.callee.name === "Boolean"; - } - - /** - * Check if a node is in a context where its value would be coerced to a boolean at runtime. - * @param {ASTNode} node The node - * @returns {boolean} If it is in a boolean context - */ - function isInBooleanContext(node) { - return ( - (isBooleanFunctionOrConstructorCall(node.parent) && - node === node.parent.arguments[0]) || - - (BOOLEAN_NODE_TYPES.has(node.parent.type) && - node === node.parent.test) || - - // ! - (node.parent.type === "UnaryExpression" && - node.parent.operator === "!") - ); - } - - /** - * Checks whether the node is a context that should report an error - * Acts recursively if it is in a logical context - * @param {ASTNode} node the node - * @returns {boolean} If the node is in one of the flagged contexts - */ - function isInFlaggedContext(node) { - if (node.parent.type === "ChainExpression") { - return isInFlaggedContext(node.parent); - } - - /* - * legacy behavior - enforceForLogicalOperands will only recurse on - * logical expressions, not on other contexts. - * enforceForInnerExpressions will recurse on logical expressions - * as well as the other recursive syntaxes. - */ - - if (enforceForLogicalOperands || enforceForInnerExpressions) { - if (node.parent.type === "LogicalExpression") { - if (node.parent.operator === "||" || node.parent.operator === "&&") { - return isInFlaggedContext(node.parent); - } - - // Check the right hand side of a `??` operator. - if (enforceForInnerExpressions && - node.parent.operator === "??" && - node.parent.right === node - ) { - return isInFlaggedContext(node.parent); - } - } - } - - if (enforceForInnerExpressions) { - if ( - node.parent.type === "ConditionalExpression" && - (node.parent.consequent === node || node.parent.alternate === node) - ) { - return isInFlaggedContext(node.parent); - } - - /* - * Check last expression only in a sequence, i.e. if ((1, 2, Boolean(3))) {}, since - * the others don't affect the result of the expression. - */ - if ( - node.parent.type === "SequenceExpression" && - node.parent.expressions.at(-1) === node - ) { - return isInFlaggedContext(node.parent); - } - - } - - return isInBooleanContext(node); - } - - - /** - * Check if a node has comments inside. - * @param {ASTNode} node The node to check. - * @returns {boolean} `true` if it has comments inside. - */ - function hasCommentsInside(node) { - return Boolean(sourceCode.getCommentsInside(node).length); - } - - /** - * Checks if the given node is wrapped in grouping parentheses. Parentheses for constructs such as if() don't count. - * @param {ASTNode} node The node to check. - * @returns {boolean} `true` if the node is parenthesized. - * @private - */ - function isParenthesized(node) { - return eslintUtils.isParenthesized(1, node, sourceCode); - } - - /** - * Determines whether the given node needs to be parenthesized when replacing the previous node. - * It assumes that `previousNode` is the node to be reported by this rule, so it has a limited list - * of possible parent node types. By the same assumption, the node's role in a particular parent is already known. - * @param {ASTNode} previousNode Previous node. - * @param {ASTNode} node The node to check. - * @throws {Error} (Unreachable.) - * @returns {boolean} `true` if the node needs to be parenthesized. - */ - function needsParens(previousNode, node) { - if (previousNode.parent.type === "ChainExpression") { - return needsParens(previousNode.parent, node); - } - - if (isParenthesized(previousNode)) { - - // parentheses around the previous node will stay, so there is no need for an additional pair - return false; - } - - // parent of the previous node will become parent of the replacement node - const parent = previousNode.parent; - - switch (parent.type) { - case "CallExpression": - case "NewExpression": - return node.type === "SequenceExpression"; - case "IfStatement": - case "DoWhileStatement": - case "WhileStatement": - case "ForStatement": - case "SequenceExpression": - return false; - case "ConditionalExpression": - if (previousNode === parent.test) { - return precedence(node) <= precedence(parent); - } - if (previousNode === parent.consequent || previousNode === parent.alternate) { - return precedence(node) < precedence({ type: "AssignmentExpression" }); - } - - /* c8 ignore next */ - throw new Error("Ternary child must be test, consequent, or alternate."); - case "UnaryExpression": - return precedence(node) < precedence(parent); - case "LogicalExpression": - if (astUtils.isMixedLogicalAndCoalesceExpressions(node, parent)) { - return true; - } - if (previousNode === parent.left) { - return precedence(node) < precedence(parent); - } - return precedence(node) <= precedence(parent); - - /* c8 ignore next */ - default: - throw new Error(`Unexpected parent type: ${parent.type}`); - } - } - - return { - UnaryExpression(node) { - const parent = node.parent; - - - // Exit early if it's guaranteed not to match - if (node.operator !== "!" || - parent.type !== "UnaryExpression" || - parent.operator !== "!") { - return; - } - - - if (isInFlaggedContext(parent)) { - context.report({ - node: parent, - messageId: "unexpectedNegation", - fix(fixer) { - if (hasCommentsInside(parent)) { - return null; - } - - if (needsParens(parent, node.argument)) { - return fixer.replaceText(parent, `(${sourceCode.getText(node.argument)})`); - } - - let prefix = ""; - const tokenBefore = sourceCode.getTokenBefore(parent); - const firstReplacementToken = sourceCode.getFirstToken(node.argument); - - if ( - tokenBefore && - tokenBefore.range[1] === parent.range[0] && - !astUtils.canTokensBeAdjacent(tokenBefore, firstReplacementToken) - ) { - prefix = " "; - } - - return fixer.replaceText(parent, prefix + sourceCode.getText(node.argument)); - } - }); - } - }, - - CallExpression(node) { - if (node.callee.type !== "Identifier" || node.callee.name !== "Boolean") { - return; - } - - if (isInFlaggedContext(node)) { - context.report({ - node, - messageId: "unexpectedCall", - fix(fixer) { - const parent = node.parent; - - if (node.arguments.length === 0) { - if (parent.type === "UnaryExpression" && parent.operator === "!") { - - /* - * !Boolean() -> true - */ - - if (hasCommentsInside(parent)) { - return null; - } - - const replacement = "true"; - let prefix = ""; - const tokenBefore = sourceCode.getTokenBefore(parent); - - if ( - tokenBefore && - tokenBefore.range[1] === parent.range[0] && - !astUtils.canTokensBeAdjacent(tokenBefore, replacement) - ) { - prefix = " "; - } - - return fixer.replaceText(parent, prefix + replacement); - } - - /* - * Boolean() -> false - */ - - if (hasCommentsInside(node)) { - return null; - } - - return fixer.replaceText(node, "false"); - } - - if (node.arguments.length === 1) { - const argument = node.arguments[0]; - - if (argument.type === "SpreadElement" || hasCommentsInside(node)) { - return null; - } - - /* - * Boolean(expression) -> expression - */ - - if (needsParens(node, argument)) { - return fixer.replaceText(node, `(${sourceCode.getText(argument)})`); - } - - return fixer.replaceText(node, sourceCode.getText(argument)); - } - - // two or more arguments - return null; - } - }); - } - } - }; - - } -}; diff --git a/tools/eslint/node_modules/eslint/lib/rules/no-extra-label.js b/tools/eslint/node_modules/eslint/lib/rules/no-extra-label.js deleted file mode 100644 index 45ff441d00170d..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/rules/no-extra-label.js +++ /dev/null @@ -1,149 +0,0 @@ -/** - * @fileoverview Rule to disallow unnecessary labels - * @author Toru Nagashima - */ - -"use strict"; - -//------------------------------------------------------------------------------ -// Requirements -//------------------------------------------------------------------------------ - -const astUtils = require("./utils/ast-utils"); - -//------------------------------------------------------------------------------ -// Rule Definition -//------------------------------------------------------------------------------ - -/** @type {import('../shared/types').Rule} */ -module.exports = { - meta: { - type: "suggestion", - - docs: { - description: "Disallow unnecessary labels", - recommended: false, - url: "https://eslint.org/docs/latest/rules/no-extra-label" - }, - - schema: [], - fixable: "code", - - messages: { - unexpected: "This label '{{name}}' is unnecessary." - } - }, - - create(context) { - const sourceCode = context.sourceCode; - let scopeInfo = null; - - /** - * Creates a new scope with a breakable statement. - * @param {ASTNode} node A node to create. This is a BreakableStatement. - * @returns {void} - */ - function enterBreakableStatement(node) { - scopeInfo = { - label: node.parent.type === "LabeledStatement" ? node.parent.label : null, - breakable: true, - upper: scopeInfo - }; - } - - /** - * Removes the top scope of the stack. - * @returns {void} - */ - function exitBreakableStatement() { - scopeInfo = scopeInfo.upper; - } - - /** - * Creates a new scope with a labeled statement. - * - * This ignores it if the body is a breakable statement. - * In this case it's handled in the `enterBreakableStatement` function. - * @param {ASTNode} node A node to create. This is a LabeledStatement. - * @returns {void} - */ - function enterLabeledStatement(node) { - if (!astUtils.isBreakableStatement(node.body)) { - scopeInfo = { - label: node.label, - breakable: false, - upper: scopeInfo - }; - } - } - - /** - * Removes the top scope of the stack. - * - * This ignores it if the body is a breakable statement. - * In this case it's handled in the `exitBreakableStatement` function. - * @param {ASTNode} node A node. This is a LabeledStatement. - * @returns {void} - */ - function exitLabeledStatement(node) { - if (!astUtils.isBreakableStatement(node.body)) { - scopeInfo = scopeInfo.upper; - } - } - - /** - * Reports a given control node if it's unnecessary. - * @param {ASTNode} node A node. This is a BreakStatement or a - * ContinueStatement. - * @returns {void} - */ - function reportIfUnnecessary(node) { - if (!node.label) { - return; - } - - const labelNode = node.label; - - for (let info = scopeInfo; info !== null; info = info.upper) { - if (info.breakable || info.label && info.label.name === labelNode.name) { - if (info.breakable && info.label && info.label.name === labelNode.name) { - context.report({ - node: labelNode, - messageId: "unexpected", - data: labelNode, - fix(fixer) { - const breakOrContinueToken = sourceCode.getFirstToken(node); - - if (sourceCode.commentsExistBetween(breakOrContinueToken, labelNode)) { - return null; - } - - return fixer.removeRange([breakOrContinueToken.range[1], labelNode.range[1]]); - } - }); - } - return; - } - } - } - - return { - WhileStatement: enterBreakableStatement, - "WhileStatement:exit": exitBreakableStatement, - DoWhileStatement: enterBreakableStatement, - "DoWhileStatement:exit": exitBreakableStatement, - ForStatement: enterBreakableStatement, - "ForStatement:exit": exitBreakableStatement, - ForInStatement: enterBreakableStatement, - "ForInStatement:exit": exitBreakableStatement, - ForOfStatement: enterBreakableStatement, - "ForOfStatement:exit": exitBreakableStatement, - SwitchStatement: enterBreakableStatement, - "SwitchStatement:exit": exitBreakableStatement, - LabeledStatement: enterLabeledStatement, - "LabeledStatement:exit": exitLabeledStatement, - BreakStatement: reportIfUnnecessary, - ContinueStatement: reportIfUnnecessary - }; - } -}; diff --git a/tools/eslint/node_modules/eslint/lib/rules/no-extra-parens.js b/tools/eslint/node_modules/eslint/lib/rules/no-extra-parens.js deleted file mode 100644 index 75c082baf2e843..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/rules/no-extra-parens.js +++ /dev/null @@ -1,1322 +0,0 @@ -/** - * @fileoverview Disallow parenthesising higher precedence subexpressions. - * @author Michael Ficarra - * @deprecated in ESLint v8.53.0 - */ -"use strict"; - -//------------------------------------------------------------------------------ -// Rule Definition -//------------------------------------------------------------------------------ - -const { isParenthesized: isParenthesizedRaw } = require("@eslint-community/eslint-utils"); -const astUtils = require("./utils/ast-utils.js"); - -/** @type {import('../shared/types').Rule} */ -module.exports = { - meta: { - deprecated: true, - replacedBy: [], - type: "layout", - - docs: { - description: "Disallow unnecessary parentheses", - recommended: false, - url: "https://eslint.org/docs/latest/rules/no-extra-parens" - }, - - fixable: "code", - - schema: { - anyOf: [ - { - type: "array", - items: [ - { - enum: ["functions"] - } - ], - minItems: 0, - maxItems: 1 - }, - { - type: "array", - items: [ - { - enum: ["all"] - }, - { - type: "object", - properties: { - conditionalAssign: { type: "boolean" }, - ternaryOperandBinaryExpressions: { type: "boolean" }, - nestedBinaryExpressions: { type: "boolean" }, - returnAssign: { type: "boolean" }, - ignoreJSX: { enum: ["none", "all", "single-line", "multi-line"] }, - enforceForArrowConditionals: { type: "boolean" }, - enforceForSequenceExpressions: { type: "boolean" }, - enforceForNewInMemberExpressions: { type: "boolean" }, - enforceForFunctionPrototypeMethods: { type: "boolean" }, - allowParensAfterCommentPattern: { type: "string" } - }, - additionalProperties: false - } - ], - minItems: 0, - maxItems: 2 - } - ] - }, - - messages: { - unexpected: "Unnecessary parentheses around expression." - } - }, - - create(context) { - const sourceCode = context.sourceCode; - - const tokensToIgnore = new WeakSet(); - const precedence = astUtils.getPrecedence; - const ALL_NODES = context.options[0] !== "functions"; - const EXCEPT_COND_ASSIGN = ALL_NODES && context.options[1] && context.options[1].conditionalAssign === false; - const EXCEPT_COND_TERNARY = ALL_NODES && context.options[1] && context.options[1].ternaryOperandBinaryExpressions === false; - const NESTED_BINARY = ALL_NODES && context.options[1] && context.options[1].nestedBinaryExpressions === false; - const EXCEPT_RETURN_ASSIGN = ALL_NODES && context.options[1] && context.options[1].returnAssign === false; - const IGNORE_JSX = ALL_NODES && context.options[1] && context.options[1].ignoreJSX; - const IGNORE_ARROW_CONDITIONALS = ALL_NODES && context.options[1] && - context.options[1].enforceForArrowConditionals === false; - const IGNORE_SEQUENCE_EXPRESSIONS = ALL_NODES && context.options[1] && - context.options[1].enforceForSequenceExpressions === false; - const IGNORE_NEW_IN_MEMBER_EXPR = ALL_NODES && context.options[1] && - context.options[1].enforceForNewInMemberExpressions === false; - const IGNORE_FUNCTION_PROTOTYPE_METHODS = ALL_NODES && context.options[1] && - context.options[1].enforceForFunctionPrototypeMethods === false; - const ALLOW_PARENS_AFTER_COMMENT_PATTERN = ALL_NODES && context.options[1] && context.options[1].allowParensAfterCommentPattern; - - const PRECEDENCE_OF_ASSIGNMENT_EXPR = precedence({ type: "AssignmentExpression" }); - const PRECEDENCE_OF_UPDATE_EXPR = precedence({ type: "UpdateExpression" }); - - let reportsBuffer; - - /** - * Determines whether the given node is a `call` or `apply` method call, invoked directly on a `FunctionExpression` node. - * Example: function(){}.call() - * @param {ASTNode} node The node to be checked. - * @returns {boolean} True if the node is an immediate `call` or `apply` method call. - * @private - */ - function isImmediateFunctionPrototypeMethodCall(node) { - const callNode = astUtils.skipChainExpression(node); - - if (callNode.type !== "CallExpression") { - return false; - } - const callee = astUtils.skipChainExpression(callNode.callee); - - return ( - callee.type === "MemberExpression" && - callee.object.type === "FunctionExpression" && - ["call", "apply"].includes(astUtils.getStaticPropertyName(callee)) - ); - } - - /** - * Determines if this rule should be enforced for a node given the current configuration. - * @param {ASTNode} node The node to be checked. - * @returns {boolean} True if the rule should be enforced for this node. - * @private - */ - function ruleApplies(node) { - if (node.type === "JSXElement" || node.type === "JSXFragment") { - const isSingleLine = node.loc.start.line === node.loc.end.line; - - switch (IGNORE_JSX) { - - // Exclude this JSX element from linting - case "all": - return false; - - // Exclude this JSX element if it is multi-line element - case "multi-line": - return isSingleLine; - - // Exclude this JSX element if it is single-line element - case "single-line": - return !isSingleLine; - - // Nothing special to be done for JSX elements - case "none": - break; - - // no default - } - } - - if (node.type === "SequenceExpression" && IGNORE_SEQUENCE_EXPRESSIONS) { - return false; - } - - if (isImmediateFunctionPrototypeMethodCall(node) && IGNORE_FUNCTION_PROTOTYPE_METHODS) { - return false; - } - - return ALL_NODES || node.type === "FunctionExpression" || node.type === "ArrowFunctionExpression"; - } - - /** - * Determines if a node is surrounded by parentheses. - * @param {ASTNode} node The node to be checked. - * @returns {boolean} True if the node is parenthesised. - * @private - */ - function isParenthesised(node) { - return isParenthesizedRaw(1, node, sourceCode); - } - - /** - * Determines if a node is surrounded by parentheses twice. - * @param {ASTNode} node The node to be checked. - * @returns {boolean} True if the node is doubly parenthesised. - * @private - */ - function isParenthesisedTwice(node) { - return isParenthesizedRaw(2, node, sourceCode); - } - - /** - * Determines if a node is surrounded by (potentially) invalid parentheses. - * @param {ASTNode} node The node to be checked. - * @returns {boolean} True if the node is incorrectly parenthesised. - * @private - */ - function hasExcessParens(node) { - return ruleApplies(node) && isParenthesised(node); - } - - /** - * Determines if a node that is expected to be parenthesised is surrounded by - * (potentially) invalid extra parentheses. - * @param {ASTNode} node The node to be checked. - * @returns {boolean} True if the node is has an unexpected extra pair of parentheses. - * @private - */ - function hasDoubleExcessParens(node) { - return ruleApplies(node) && isParenthesisedTwice(node); - } - - /** - * Determines if a node that is expected to be parenthesised is surrounded by - * (potentially) invalid extra parentheses with considering precedence level of the node. - * If the preference level of the node is not higher or equal to precedence lower limit, it also checks - * whether the node is surrounded by parentheses twice or not. - * @param {ASTNode} node The node to be checked. - * @param {number} precedenceLowerLimit The lower limit of precedence. - * @returns {boolean} True if the node is has an unexpected extra pair of parentheses. - * @private - */ - function hasExcessParensWithPrecedence(node, precedenceLowerLimit) { - if (ruleApplies(node) && isParenthesised(node)) { - if ( - precedence(node) >= precedenceLowerLimit || - isParenthesisedTwice(node) - ) { - return true; - } - } - return false; - } - - /** - * Determines if a node test expression is allowed to have a parenthesised assignment - * @param {ASTNode} node The node to be checked. - * @returns {boolean} True if the assignment can be parenthesised. - * @private - */ - function isCondAssignException(node) { - return EXCEPT_COND_ASSIGN && node.test.type === "AssignmentExpression"; - } - - /** - * Determines if a node is in a return statement - * @param {ASTNode} node The node to be checked. - * @returns {boolean} True if the node is in a return statement. - * @private - */ - function isInReturnStatement(node) { - for (let currentNode = node; currentNode; currentNode = currentNode.parent) { - if ( - currentNode.type === "ReturnStatement" || - (currentNode.type === "ArrowFunctionExpression" && currentNode.body.type !== "BlockStatement") - ) { - return true; - } - } - - return false; - } - - /** - * Determines if a constructor function is newed-up with parens - * @param {ASTNode} newExpression The NewExpression node to be checked. - * @returns {boolean} True if the constructor is called with parens. - * @private - */ - function isNewExpressionWithParens(newExpression) { - const lastToken = sourceCode.getLastToken(newExpression); - const penultimateToken = sourceCode.getTokenBefore(lastToken); - - return newExpression.arguments.length > 0 || - ( - - // The expression should end with its own parens, e.g., new new foo() is not a new expression with parens - astUtils.isOpeningParenToken(penultimateToken) && - astUtils.isClosingParenToken(lastToken) && - newExpression.callee.range[1] < newExpression.range[1] - ); - } - - /** - * Determines if a node is or contains an assignment expression - * @param {ASTNode} node The node to be checked. - * @returns {boolean} True if the node is or contains an assignment expression. - * @private - */ - function containsAssignment(node) { - if (node.type === "AssignmentExpression") { - return true; - } - if (node.type === "ConditionalExpression" && - (node.consequent.type === "AssignmentExpression" || node.alternate.type === "AssignmentExpression")) { - return true; - } - if ((node.left && node.left.type === "AssignmentExpression") || - (node.right && node.right.type === "AssignmentExpression")) { - return true; - } - - return false; - } - - /** - * Determines if a node is contained by or is itself a return statement and is allowed to have a parenthesised assignment - * @param {ASTNode} node The node to be checked. - * @returns {boolean} True if the assignment can be parenthesised. - * @private - */ - function isReturnAssignException(node) { - if (!EXCEPT_RETURN_ASSIGN || !isInReturnStatement(node)) { - return false; - } - - if (node.type === "ReturnStatement") { - return node.argument && containsAssignment(node.argument); - } - if (node.type === "ArrowFunctionExpression" && node.body.type !== "BlockStatement") { - return containsAssignment(node.body); - } - return containsAssignment(node); - - } - - /** - * Determines if a node following a [no LineTerminator here] restriction is - * surrounded by (potentially) invalid extra parentheses. - * @param {Token} token The token preceding the [no LineTerminator here] restriction. - * @param {ASTNode} node The node to be checked. - * @returns {boolean} True if the node is incorrectly parenthesised. - * @private - */ - function hasExcessParensNoLineTerminator(token, node) { - if (token.loc.end.line === node.loc.start.line) { - return hasExcessParens(node); - } - - return hasDoubleExcessParens(node); - } - - /** - * Determines whether a node should be preceded by an additional space when removing parens - * @param {ASTNode} node node to evaluate; must be surrounded by parentheses - * @returns {boolean} `true` if a space should be inserted before the node - * @private - */ - function requiresLeadingSpace(node) { - const leftParenToken = sourceCode.getTokenBefore(node); - const tokenBeforeLeftParen = sourceCode.getTokenBefore(leftParenToken, { includeComments: true }); - const tokenAfterLeftParen = sourceCode.getTokenAfter(leftParenToken, { includeComments: true }); - - return tokenBeforeLeftParen && - tokenBeforeLeftParen.range[1] === leftParenToken.range[0] && - leftParenToken.range[1] === tokenAfterLeftParen.range[0] && - !astUtils.canTokensBeAdjacent(tokenBeforeLeftParen, tokenAfterLeftParen); - } - - /** - * Determines whether a node should be followed by an additional space when removing parens - * @param {ASTNode} node node to evaluate; must be surrounded by parentheses - * @returns {boolean} `true` if a space should be inserted after the node - * @private - */ - function requiresTrailingSpace(node) { - const nextTwoTokens = sourceCode.getTokensAfter(node, { count: 2 }); - const rightParenToken = nextTwoTokens[0]; - const tokenAfterRightParen = nextTwoTokens[1]; - const tokenBeforeRightParen = sourceCode.getLastToken(node); - - return rightParenToken && tokenAfterRightParen && - !sourceCode.isSpaceBetweenTokens(rightParenToken, tokenAfterRightParen) && - !astUtils.canTokensBeAdjacent(tokenBeforeRightParen, tokenAfterRightParen); - } - - /** - * Determines if a given expression node is an IIFE - * @param {ASTNode} node The node to check - * @returns {boolean} `true` if the given node is an IIFE - */ - function isIIFE(node) { - const maybeCallNode = astUtils.skipChainExpression(node); - - return maybeCallNode.type === "CallExpression" && maybeCallNode.callee.type === "FunctionExpression"; - } - - /** - * Determines if the given node can be the assignment target in destructuring or the LHS of an assignment. - * This is to avoid an autofix that could change behavior because parsers mistakenly allow invalid syntax, - * such as `(a = b) = c` and `[(a = b) = c] = []`. Ideally, this function shouldn't be necessary. - * @param {ASTNode} [node] The node to check - * @returns {boolean} `true` if the given node can be a valid assignment target - */ - function canBeAssignmentTarget(node) { - return node && (node.type === "Identifier" || node.type === "MemberExpression"); - } - - /** - * Checks if a node is fixable. - * A node is fixable if removing a single pair of surrounding parentheses does not turn it - * into a directive after fixing other nodes. - * Almost all nodes are fixable, except if all of the following conditions are met: - * The node is a string Literal - * It has a single pair of parentheses - * It is the only child of an ExpressionStatement - * @param {ASTNode} node The node to evaluate. - * @returns {boolean} Whether or not the node is fixable. - * @private - */ - function isFixable(node) { - - // if it's not a string literal it can be autofixed - if (node.type !== "Literal" || typeof node.value !== "string") { - return true; - } - if (isParenthesisedTwice(node)) { - return true; - } - return !astUtils.isTopLevelExpressionStatement(node.parent); - } - - /** - * Report the node - * @param {ASTNode} node node to evaluate - * @returns {void} - * @private - */ - function report(node) { - const leftParenToken = sourceCode.getTokenBefore(node); - const rightParenToken = sourceCode.getTokenAfter(node); - - if (!isParenthesisedTwice(node)) { - if (tokensToIgnore.has(sourceCode.getFirstToken(node))) { - return; - } - - if (isIIFE(node) && !isParenthesised(node.callee)) { - return; - } - - if (ALLOW_PARENS_AFTER_COMMENT_PATTERN) { - const commentsBeforeLeftParenToken = sourceCode.getCommentsBefore(leftParenToken); - const totalCommentsBeforeLeftParenTokenCount = commentsBeforeLeftParenToken.length; - const ignorePattern = new RegExp(ALLOW_PARENS_AFTER_COMMENT_PATTERN, "u"); - - if ( - totalCommentsBeforeLeftParenTokenCount > 0 && - ignorePattern.test(commentsBeforeLeftParenToken[totalCommentsBeforeLeftParenTokenCount - 1].value) - ) { - return; - } - } - } - - /** - * Finishes reporting - * @returns {void} - * @private - */ - function finishReport() { - context.report({ - node, - loc: leftParenToken.loc, - messageId: "unexpected", - fix: isFixable(node) - ? fixer => { - const parenthesizedSource = sourceCode.text.slice(leftParenToken.range[1], rightParenToken.range[0]); - - return fixer.replaceTextRange([ - leftParenToken.range[0], - rightParenToken.range[1] - ], (requiresLeadingSpace(node) ? " " : "") + parenthesizedSource + (requiresTrailingSpace(node) ? " " : "")); - } - : null - }); - } - - if (reportsBuffer) { - reportsBuffer.reports.push({ node, finishReport }); - return; - } - - finishReport(); - } - - /** - * Evaluate a argument of the node. - * @param {ASTNode} node node to evaluate - * @returns {void} - * @private - */ - function checkArgumentWithPrecedence(node) { - if (hasExcessParensWithPrecedence(node.argument, precedence(node))) { - report(node.argument); - } - } - - /** - * Check if a member expression contains a call expression - * @param {ASTNode} node MemberExpression node to evaluate - * @returns {boolean} true if found, false if not - */ - function doesMemberExpressionContainCallExpression(node) { - let currentNode = node.object; - let currentNodeType = node.object.type; - - while (currentNodeType === "MemberExpression") { - currentNode = currentNode.object; - currentNodeType = currentNode.type; - } - - return currentNodeType === "CallExpression"; - } - - /** - * Evaluate a new call - * @param {ASTNode} node node to evaluate - * @returns {void} - * @private - */ - function checkCallNew(node) { - const callee = node.callee; - - if (hasExcessParensWithPrecedence(callee, precedence(node))) { - if ( - hasDoubleExcessParens(callee) || - !( - isIIFE(node) || - - // (new A)(); new (new A)(); - ( - callee.type === "NewExpression" && - !isNewExpressionWithParens(callee) && - !( - node.type === "NewExpression" && - !isNewExpressionWithParens(node) - ) - ) || - - // new (a().b)(); new (a.b().c); - ( - node.type === "NewExpression" && - callee.type === "MemberExpression" && - doesMemberExpressionContainCallExpression(callee) - ) || - - // (a?.b)(); (a?.())(); - ( - !node.optional && - callee.type === "ChainExpression" - ) - ) - ) { - report(node.callee); - } - } - node.arguments - .filter(arg => hasExcessParensWithPrecedence(arg, PRECEDENCE_OF_ASSIGNMENT_EXPR)) - .forEach(report); - } - - /** - * Evaluate binary logicals - * @param {ASTNode} node node to evaluate - * @returns {void} - * @private - */ - function checkBinaryLogical(node) { - const prec = precedence(node); - const leftPrecedence = precedence(node.left); - const rightPrecedence = precedence(node.right); - const isExponentiation = node.operator === "**"; - const shouldSkipLeft = NESTED_BINARY && (node.left.type === "BinaryExpression" || node.left.type === "LogicalExpression"); - const shouldSkipRight = NESTED_BINARY && (node.right.type === "BinaryExpression" || node.right.type === "LogicalExpression"); - - if (!shouldSkipLeft && hasExcessParens(node.left)) { - if ( - !(["AwaitExpression", "UnaryExpression"].includes(node.left.type) && isExponentiation) && - !astUtils.isMixedLogicalAndCoalesceExpressions(node.left, node) && - (leftPrecedence > prec || (leftPrecedence === prec && !isExponentiation)) || - isParenthesisedTwice(node.left) - ) { - report(node.left); - } - } - - if (!shouldSkipRight && hasExcessParens(node.right)) { - if ( - !astUtils.isMixedLogicalAndCoalesceExpressions(node.right, node) && - (rightPrecedence > prec || (rightPrecedence === prec && isExponentiation)) || - isParenthesisedTwice(node.right) - ) { - report(node.right); - } - } - } - - /** - * Check the parentheses around the super class of the given class definition. - * @param {ASTNode} node The node of class declarations to check. - * @returns {void} - */ - function checkClass(node) { - if (!node.superClass) { - return; - } - - /* - * If `node.superClass` is a LeftHandSideExpression, parentheses are extra. - * Otherwise, parentheses are needed. - */ - const hasExtraParens = precedence(node.superClass) > PRECEDENCE_OF_UPDATE_EXPR - ? hasExcessParens(node.superClass) - : hasDoubleExcessParens(node.superClass); - - if (hasExtraParens) { - report(node.superClass); - } - } - - /** - * Check the parentheses around the argument of the given spread operator. - * @param {ASTNode} node The node of spread elements/properties to check. - * @returns {void} - */ - function checkSpreadOperator(node) { - if (hasExcessParensWithPrecedence(node.argument, PRECEDENCE_OF_ASSIGNMENT_EXPR)) { - report(node.argument); - } - } - - /** - * Checks the parentheses for an ExpressionStatement or ExportDefaultDeclaration - * @param {ASTNode} node The ExpressionStatement.expression or ExportDefaultDeclaration.declaration node - * @returns {void} - */ - function checkExpressionOrExportStatement(node) { - const firstToken = isParenthesised(node) ? sourceCode.getTokenBefore(node) : sourceCode.getFirstToken(node); - const secondToken = sourceCode.getTokenAfter(firstToken, astUtils.isNotOpeningParenToken); - const thirdToken = secondToken ? sourceCode.getTokenAfter(secondToken) : null; - const tokenAfterClosingParens = secondToken ? sourceCode.getTokenAfter(secondToken, astUtils.isNotClosingParenToken) : null; - - if ( - astUtils.isOpeningParenToken(firstToken) && - ( - astUtils.isOpeningBraceToken(secondToken) || - secondToken.type === "Keyword" && ( - secondToken.value === "function" || - secondToken.value === "class" || - secondToken.value === "let" && - tokenAfterClosingParens && - ( - astUtils.isOpeningBracketToken(tokenAfterClosingParens) || - tokenAfterClosingParens.type === "Identifier" - ) - ) || - secondToken && secondToken.type === "Identifier" && secondToken.value === "async" && thirdToken && thirdToken.type === "Keyword" && thirdToken.value === "function" - ) - ) { - tokensToIgnore.add(secondToken); - } - - const hasExtraParens = node.parent.type === "ExportDefaultDeclaration" - ? hasExcessParensWithPrecedence(node, PRECEDENCE_OF_ASSIGNMENT_EXPR) - : hasExcessParens(node); - - if (hasExtraParens) { - report(node); - } - } - - /** - * Finds the path from the given node to the specified ancestor. - * @param {ASTNode} node First node in the path. - * @param {ASTNode} ancestor Last node in the path. - * @returns {ASTNode[]} Path, including both nodes. - * @throws {Error} If the given node does not have the specified ancestor. - */ - function pathToAncestor(node, ancestor) { - const path = [node]; - let currentNode = node; - - while (currentNode !== ancestor) { - - currentNode = currentNode.parent; - - /* c8 ignore start */ - if (currentNode === null) { - throw new Error("Nodes are not in the ancestor-descendant relationship."); - }/* c8 ignore stop */ - - path.push(currentNode); - } - - return path; - } - - /** - * Finds the path from the given node to the specified descendant. - * @param {ASTNode} node First node in the path. - * @param {ASTNode} descendant Last node in the path. - * @returns {ASTNode[]} Path, including both nodes. - * @throws {Error} If the given node does not have the specified descendant. - */ - function pathToDescendant(node, descendant) { - return pathToAncestor(descendant, node).reverse(); - } - - /** - * Checks whether the syntax of the given ancestor of an 'in' expression inside a for-loop initializer - * is preventing the 'in' keyword from being interpreted as a part of an ill-formed for-in loop. - * @param {ASTNode} node Ancestor of an 'in' expression. - * @param {ASTNode} child Child of the node, ancestor of the same 'in' expression or the 'in' expression itself. - * @returns {boolean} True if the keyword 'in' would be interpreted as the 'in' operator, without any parenthesis. - */ - function isSafelyEnclosingInExpression(node, child) { - switch (node.type) { - case "ArrayExpression": - case "ArrayPattern": - case "BlockStatement": - case "ObjectExpression": - case "ObjectPattern": - case "TemplateLiteral": - return true; - case "ArrowFunctionExpression": - case "FunctionExpression": - return node.params.includes(child); - case "CallExpression": - case "NewExpression": - return node.arguments.includes(child); - case "MemberExpression": - return node.computed && node.property === child; - case "ConditionalExpression": - return node.consequent === child; - default: - return false; - } - } - - /** - * Starts a new reports buffering. Warnings will be stored in a buffer instead of being reported immediately. - * An additional logic that requires multiple nodes (e.g. a whole subtree) may dismiss some of the stored warnings. - * @returns {void} - */ - function startNewReportsBuffering() { - reportsBuffer = { - upper: reportsBuffer, - inExpressionNodes: [], - reports: [] - }; - } - - /** - * Ends the current reports buffering. - * @returns {void} - */ - function endCurrentReportsBuffering() { - const { upper, inExpressionNodes, reports } = reportsBuffer; - - if (upper) { - upper.inExpressionNodes.push(...inExpressionNodes); - upper.reports.push(...reports); - } else { - - // flush remaining reports - reports.forEach(({ finishReport }) => finishReport()); - } - - reportsBuffer = upper; - } - - /** - * Checks whether the given node is in the current reports buffer. - * @param {ASTNode} node Node to check. - * @returns {boolean} True if the node is in the current buffer, false otherwise. - */ - function isInCurrentReportsBuffer(node) { - return reportsBuffer.reports.some(r => r.node === node); - } - - /** - * Removes the given node from the current reports buffer. - * @param {ASTNode} node Node to remove. - * @returns {void} - */ - function removeFromCurrentReportsBuffer(node) { - reportsBuffer.reports = reportsBuffer.reports.filter(r => r.node !== node); - } - - /** - * Checks whether a node is a MemberExpression at NewExpression's callee. - * @param {ASTNode} node node to check. - * @returns {boolean} True if the node is a MemberExpression at NewExpression's callee. false otherwise. - */ - function isMemberExpInNewCallee(node) { - if (node.type === "MemberExpression") { - return node.parent.type === "NewExpression" && node.parent.callee === node - ? true - : node.parent.object === node && isMemberExpInNewCallee(node.parent); - } - return false; - } - - /** - * Checks if the left-hand side of an assignment is an identifier, the operator is one of - * `=`, `&&=`, `||=` or `??=` and the right-hand side is an anonymous class or function. - * - * As per https://tc39.es/ecma262/#sec-assignment-operators-runtime-semantics-evaluation, an - * assignment involving one of the operators `=`, `&&=`, `||=` or `??=` where the right-hand - * side is an anonymous class or function and the left-hand side is an *unparenthesized* - * identifier has different semantics than other assignments. - * Specifically, when an expression like `foo = function () {}` is evaluated, `foo.name` - * will be set to the string "foo", i.e. the identifier name. The same thing does not happen - * when evaluating `(foo) = function () {}`. - * Since the parenthesizing of the identifier in the left-hand side is significant in this - * special case, the parentheses, if present, should not be flagged as unnecessary. - * @param {ASTNode} node an AssignmentExpression node. - * @returns {boolean} `true` if the left-hand side of the assignment is an identifier, the - * operator is one of `=`, `&&=`, `||=` or `??=` and the right-hand side is an anonymous - * class or function; otherwise, `false`. - */ - function isAnonymousFunctionAssignmentException({ left, operator, right }) { - if (left.type === "Identifier" && ["=", "&&=", "||=", "??="].includes(operator)) { - const rhsType = right.type; - - if (rhsType === "ArrowFunctionExpression") { - return true; - } - if ((rhsType === "FunctionExpression" || rhsType === "ClassExpression") && !right.id) { - return true; - } - } - return false; - } - - return { - ArrayExpression(node) { - node.elements - .filter(e => e && hasExcessParensWithPrecedence(e, PRECEDENCE_OF_ASSIGNMENT_EXPR)) - .forEach(report); - }, - - ArrayPattern(node) { - node.elements - .filter(e => canBeAssignmentTarget(e) && hasExcessParens(e)) - .forEach(report); - }, - - ArrowFunctionExpression(node) { - if (isReturnAssignException(node)) { - return; - } - - if (node.body.type === "ConditionalExpression" && - IGNORE_ARROW_CONDITIONALS - ) { - return; - } - - if (node.body.type !== "BlockStatement") { - const firstBodyToken = sourceCode.getFirstToken(node.body, astUtils.isNotOpeningParenToken); - const tokenBeforeFirst = sourceCode.getTokenBefore(firstBodyToken); - - if (astUtils.isOpeningParenToken(tokenBeforeFirst) && astUtils.isOpeningBraceToken(firstBodyToken)) { - tokensToIgnore.add(firstBodyToken); - } - if (hasExcessParensWithPrecedence(node.body, PRECEDENCE_OF_ASSIGNMENT_EXPR)) { - report(node.body); - } - } - }, - - AssignmentExpression(node) { - if (canBeAssignmentTarget(node.left) && hasExcessParens(node.left) && - (!isAnonymousFunctionAssignmentException(node) || isParenthesisedTwice(node.left))) { - report(node.left); - } - - if (!isReturnAssignException(node) && hasExcessParensWithPrecedence(node.right, precedence(node))) { - report(node.right); - } - }, - - BinaryExpression(node) { - if (reportsBuffer && node.operator === "in") { - reportsBuffer.inExpressionNodes.push(node); - } - - checkBinaryLogical(node); - }, - - CallExpression: checkCallNew, - - ConditionalExpression(node) { - if (isReturnAssignException(node)) { - return; - } - - const availableTypes = new Set(["BinaryExpression", "LogicalExpression"]); - - if ( - !(EXCEPT_COND_TERNARY && availableTypes.has(node.test.type)) && - !isCondAssignException(node) && - hasExcessParensWithPrecedence(node.test, precedence({ type: "LogicalExpression", operator: "||" })) - ) { - report(node.test); - } - - if ( - !(EXCEPT_COND_TERNARY && availableTypes.has(node.consequent.type)) && - hasExcessParensWithPrecedence(node.consequent, PRECEDENCE_OF_ASSIGNMENT_EXPR)) { - report(node.consequent); - } - - if ( - !(EXCEPT_COND_TERNARY && availableTypes.has(node.alternate.type)) && - hasExcessParensWithPrecedence(node.alternate, PRECEDENCE_OF_ASSIGNMENT_EXPR)) { - report(node.alternate); - } - }, - - DoWhileStatement(node) { - if (hasExcessParens(node.test) && !isCondAssignException(node)) { - report(node.test); - } - }, - - ExportDefaultDeclaration: node => checkExpressionOrExportStatement(node.declaration), - ExpressionStatement: node => checkExpressionOrExportStatement(node.expression), - - ForInStatement(node) { - if (node.left.type !== "VariableDeclaration") { - const firstLeftToken = sourceCode.getFirstToken(node.left, astUtils.isNotOpeningParenToken); - - if ( - firstLeftToken.value === "let" && - astUtils.isOpeningBracketToken( - sourceCode.getTokenAfter(firstLeftToken, astUtils.isNotClosingParenToken) - ) - ) { - - // ForInStatement#left expression cannot start with `let[`. - tokensToIgnore.add(firstLeftToken); - } - } - - if (hasExcessParens(node.left)) { - report(node.left); - } - - if (hasExcessParens(node.right)) { - report(node.right); - } - }, - - ForOfStatement(node) { - if (node.left.type !== "VariableDeclaration") { - const firstLeftToken = sourceCode.getFirstToken(node.left, astUtils.isNotOpeningParenToken); - - if (firstLeftToken.value === "let") { - - // ForOfStatement#left expression cannot start with `let`. - tokensToIgnore.add(firstLeftToken); - } - } - - if (hasExcessParens(node.left)) { - report(node.left); - } - - if (hasExcessParensWithPrecedence(node.right, PRECEDENCE_OF_ASSIGNMENT_EXPR)) { - report(node.right); - } - }, - - ForStatement(node) { - if (node.test && hasExcessParens(node.test) && !isCondAssignException(node)) { - report(node.test); - } - - if (node.update && hasExcessParens(node.update)) { - report(node.update); - } - - if (node.init) { - - if (node.init.type !== "VariableDeclaration") { - const firstToken = sourceCode.getFirstToken(node.init, astUtils.isNotOpeningParenToken); - - if ( - firstToken.value === "let" && - astUtils.isOpeningBracketToken( - sourceCode.getTokenAfter(firstToken, astUtils.isNotClosingParenToken) - ) - ) { - - // ForStatement#init expression cannot start with `let[`. - tokensToIgnore.add(firstToken); - } - } - - startNewReportsBuffering(); - - if (hasExcessParens(node.init)) { - report(node.init); - } - } - }, - - "ForStatement > *.init:exit"(node) { - - /* - * Removing parentheses around `in` expressions might change semantics and cause errors. - * - * For example, this valid for loop: - * for (let a = (b in c); ;); - * after removing parentheses would be treated as an invalid for-in loop: - * for (let a = b in c; ;); - */ - - if (reportsBuffer.reports.length) { - reportsBuffer.inExpressionNodes.forEach(inExpressionNode => { - const path = pathToDescendant(node, inExpressionNode); - let nodeToExclude; - - for (let i = 0; i < path.length; i++) { - const pathNode = path[i]; - - if (i < path.length - 1) { - const nextPathNode = path[i + 1]; - - if (isSafelyEnclosingInExpression(pathNode, nextPathNode)) { - - // The 'in' expression in safely enclosed by the syntax of its ancestor nodes (e.g. by '{}' or '[]'). - return; - } - } - - if (isParenthesised(pathNode)) { - if (isInCurrentReportsBuffer(pathNode)) { - - // This node was supposed to be reported, but parentheses might be necessary. - - if (isParenthesisedTwice(pathNode)) { - - /* - * This node is parenthesised twice, it certainly has at least one pair of `extra` parentheses. - * If the --fix option is on, the current fixing iteration will remove only one pair of parentheses. - * The remaining pair is safely enclosing the 'in' expression. - */ - return; - } - - // Exclude the outermost node only. - if (!nodeToExclude) { - nodeToExclude = pathNode; - } - - // Don't break the loop here, there might be some safe nodes or parentheses that will stay inside. - - } else { - - // This node will stay parenthesised, the 'in' expression in safely enclosed by '()'. - return; - } - } - } - - // Exclude the node from the list (i.e. treat parentheses as necessary) - removeFromCurrentReportsBuffer(nodeToExclude); - }); - } - - endCurrentReportsBuffering(); - }, - - IfStatement(node) { - if (hasExcessParens(node.test) && !isCondAssignException(node)) { - report(node.test); - } - }, - - ImportExpression(node) { - const { source } = node; - - if (source.type === "SequenceExpression") { - if (hasDoubleExcessParens(source)) { - report(source); - } - } else if (hasExcessParens(source)) { - report(source); - } - }, - - LogicalExpression: checkBinaryLogical, - - MemberExpression(node) { - const shouldAllowWrapOnce = isMemberExpInNewCallee(node) && - doesMemberExpressionContainCallExpression(node); - const nodeObjHasExcessParens = shouldAllowWrapOnce - ? hasDoubleExcessParens(node.object) - : hasExcessParens(node.object) && - !( - isImmediateFunctionPrototypeMethodCall(node.parent) && - node.parent.callee === node && - IGNORE_FUNCTION_PROTOTYPE_METHODS - ); - - if ( - nodeObjHasExcessParens && - precedence(node.object) >= precedence(node) && - ( - node.computed || - !( - astUtils.isDecimalInteger(node.object) || - - // RegExp literal is allowed to have parens (#1589) - (node.object.type === "Literal" && node.object.regex) - ) - ) - ) { - report(node.object); - } - - if (nodeObjHasExcessParens && - node.object.type === "CallExpression" - ) { - report(node.object); - } - - if (nodeObjHasExcessParens && - !IGNORE_NEW_IN_MEMBER_EXPR && - node.object.type === "NewExpression" && - isNewExpressionWithParens(node.object)) { - report(node.object); - } - - if (nodeObjHasExcessParens && - node.optional && - node.object.type === "ChainExpression" - ) { - report(node.object); - } - - if (node.computed && hasExcessParens(node.property)) { - report(node.property); - } - }, - - "MethodDefinition[computed=true]"(node) { - if (hasExcessParensWithPrecedence(node.key, PRECEDENCE_OF_ASSIGNMENT_EXPR)) { - report(node.key); - } - }, - - NewExpression: checkCallNew, - - ObjectExpression(node) { - node.properties - .filter(property => property.value && hasExcessParensWithPrecedence(property.value, PRECEDENCE_OF_ASSIGNMENT_EXPR)) - .forEach(property => report(property.value)); - }, - - ObjectPattern(node) { - node.properties - .filter(property => { - const value = property.value; - - return canBeAssignmentTarget(value) && hasExcessParens(value); - }).forEach(property => report(property.value)); - }, - - Property(node) { - if (node.computed) { - const { key } = node; - - if (key && hasExcessParensWithPrecedence(key, PRECEDENCE_OF_ASSIGNMENT_EXPR)) { - report(key); - } - } - }, - - PropertyDefinition(node) { - if (node.computed && hasExcessParensWithPrecedence(node.key, PRECEDENCE_OF_ASSIGNMENT_EXPR)) { - report(node.key); - } - - if (node.value && hasExcessParensWithPrecedence(node.value, PRECEDENCE_OF_ASSIGNMENT_EXPR)) { - report(node.value); - } - }, - - RestElement(node) { - const argument = node.argument; - - if (canBeAssignmentTarget(argument) && hasExcessParens(argument)) { - report(argument); - } - }, - - ReturnStatement(node) { - const returnToken = sourceCode.getFirstToken(node); - - if (isReturnAssignException(node)) { - return; - } - - if (node.argument && - hasExcessParensNoLineTerminator(returnToken, node.argument) && - - // RegExp literal is allowed to have parens (#1589) - !(node.argument.type === "Literal" && node.argument.regex)) { - report(node.argument); - } - }, - - SequenceExpression(node) { - const precedenceOfNode = precedence(node); - - node.expressions - .filter(e => hasExcessParensWithPrecedence(e, precedenceOfNode)) - .forEach(report); - }, - - SwitchCase(node) { - if (node.test && hasExcessParens(node.test)) { - report(node.test); - } - }, - - SwitchStatement(node) { - if (hasExcessParens(node.discriminant)) { - report(node.discriminant); - } - }, - - ThrowStatement(node) { - const throwToken = sourceCode.getFirstToken(node); - - if (hasExcessParensNoLineTerminator(throwToken, node.argument)) { - report(node.argument); - } - }, - - UnaryExpression: checkArgumentWithPrecedence, - UpdateExpression(node) { - if (node.prefix) { - checkArgumentWithPrecedence(node); - } else { - const { argument } = node; - const operatorToken = sourceCode.getLastToken(node); - - if (argument.loc.end.line === operatorToken.loc.start.line) { - checkArgumentWithPrecedence(node); - } else { - if (hasDoubleExcessParens(argument)) { - report(argument); - } - } - } - }, - AwaitExpression: checkArgumentWithPrecedence, - - VariableDeclarator(node) { - if ( - node.init && hasExcessParensWithPrecedence(node.init, PRECEDENCE_OF_ASSIGNMENT_EXPR) && - - // RegExp literal is allowed to have parens (#1589) - !(node.init.type === "Literal" && node.init.regex) - ) { - report(node.init); - } - }, - - WhileStatement(node) { - if (hasExcessParens(node.test) && !isCondAssignException(node)) { - report(node.test); - } - }, - - WithStatement(node) { - if (hasExcessParens(node.object)) { - report(node.object); - } - }, - - YieldExpression(node) { - if (node.argument) { - const yieldToken = sourceCode.getFirstToken(node); - - if ((precedence(node.argument) >= precedence(node) && - hasExcessParensNoLineTerminator(yieldToken, node.argument)) || - hasDoubleExcessParens(node.argument)) { - report(node.argument); - } - } - }, - - ClassDeclaration: checkClass, - ClassExpression: checkClass, - - SpreadElement: checkSpreadOperator, - SpreadProperty: checkSpreadOperator, - ExperimentalSpreadProperty: checkSpreadOperator, - - TemplateLiteral(node) { - node.expressions - .filter(e => e && hasExcessParens(e)) - .forEach(report); - }, - - AssignmentPattern(node) { - const { left, right } = node; - - if (canBeAssignmentTarget(left) && hasExcessParens(left)) { - report(left); - } - - if (right && hasExcessParensWithPrecedence(right, PRECEDENCE_OF_ASSIGNMENT_EXPR)) { - report(right); - } - } - }; - - } -}; diff --git a/tools/eslint/node_modules/eslint/lib/rules/no-extra-semi.js b/tools/eslint/node_modules/eslint/lib/rules/no-extra-semi.js deleted file mode 100644 index 1daf2242249c0e..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/rules/no-extra-semi.js +++ /dev/null @@ -1,147 +0,0 @@ -/** - * @fileoverview Rule to flag use of unnecessary semicolons - * @author Nicholas C. Zakas - * @deprecated in ESLint v8.53.0 - */ - -"use strict"; - -//------------------------------------------------------------------------------ -// Requirements -//------------------------------------------------------------------------------ - -const FixTracker = require("./utils/fix-tracker"); -const astUtils = require("./utils/ast-utils"); - -//------------------------------------------------------------------------------ -// Rule Definition -//------------------------------------------------------------------------------ - -/** @type {import('../shared/types').Rule} */ -module.exports = { - meta: { - deprecated: true, - replacedBy: [], - type: "suggestion", - - docs: { - description: "Disallow unnecessary semicolons", - recommended: false, - url: "https://eslint.org/docs/latest/rules/no-extra-semi" - }, - - fixable: "code", - schema: [], - - messages: { - unexpected: "Unnecessary semicolon." - } - }, - - create(context) { - const sourceCode = context.sourceCode; - - /** - * Checks if a node or token is fixable. - * A node is fixable if it can be removed without turning a subsequent statement into a directive after fixing other nodes. - * @param {Token} nodeOrToken The node or token to check. - * @returns {boolean} Whether or not the node is fixable. - */ - function isFixable(nodeOrToken) { - const nextToken = sourceCode.getTokenAfter(nodeOrToken); - - if (!nextToken || nextToken.type !== "String") { - return true; - } - const stringNode = sourceCode.getNodeByRangeIndex(nextToken.range[0]); - - return !astUtils.isTopLevelExpressionStatement(stringNode.parent); - } - - /** - * Reports an unnecessary semicolon error. - * @param {Node|Token} nodeOrToken A node or a token to be reported. - * @returns {void} - */ - function report(nodeOrToken) { - context.report({ - node: nodeOrToken, - messageId: "unexpected", - fix: isFixable(nodeOrToken) - ? fixer => - - /* - * Expand the replacement range to include the surrounding - * tokens to avoid conflicting with semi. - * https://github.com/eslint/eslint/issues/7928 - */ - new FixTracker(fixer, context.sourceCode) - .retainSurroundingTokens(nodeOrToken) - .remove(nodeOrToken) - : null - }); - } - - /** - * Checks for a part of a class body. - * This checks tokens from a specified token to a next MethodDefinition or the end of class body. - * @param {Token} firstToken The first token to check. - * @returns {void} - */ - function checkForPartOfClassBody(firstToken) { - for (let token = firstToken; - token.type === "Punctuator" && !astUtils.isClosingBraceToken(token); - token = sourceCode.getTokenAfter(token) - ) { - if (astUtils.isSemicolonToken(token)) { - report(token); - } - } - } - - return { - - /** - * Reports this empty statement, except if the parent node is a loop. - * @param {Node} node A EmptyStatement node to be reported. - * @returns {void} - */ - EmptyStatement(node) { - const parent = node.parent, - allowedParentTypes = [ - "ForStatement", - "ForInStatement", - "ForOfStatement", - "WhileStatement", - "DoWhileStatement", - "IfStatement", - "LabeledStatement", - "WithStatement" - ]; - - if (!allowedParentTypes.includes(parent.type)) { - report(node); - } - }, - - /** - * Checks tokens from the head of this class body to the first MethodDefinition or the end of this class body. - * @param {Node} node A ClassBody node to check. - * @returns {void} - */ - ClassBody(node) { - checkForPartOfClassBody(sourceCode.getFirstToken(node, 1)); // 0 is `{`. - }, - - /** - * Checks tokens from this MethodDefinition to the next MethodDefinition or the end of this class body. - * @param {Node} node A MethodDefinition node of the start point. - * @returns {void} - */ - "MethodDefinition, PropertyDefinition, StaticBlock"(node) { - checkForPartOfClassBody(sourceCode.getTokenAfter(node)); - } - }; - - } -}; diff --git a/tools/eslint/node_modules/eslint/lib/rules/no-fallthrough.js b/tools/eslint/node_modules/eslint/lib/rules/no-fallthrough.js deleted file mode 100644 index 4c98ddde52545f..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/rules/no-fallthrough.js +++ /dev/null @@ -1,221 +0,0 @@ -/** - * @fileoverview Rule to flag fall-through cases in switch statements. - * @author Matt DuVall - */ -"use strict"; - -//------------------------------------------------------------------------------ -// Requirements -//------------------------------------------------------------------------------ - -const { directivesPattern } = require("../shared/directives"); - -//------------------------------------------------------------------------------ -// Helpers -//------------------------------------------------------------------------------ - -const DEFAULT_FALLTHROUGH_COMMENT = /falls?\s?through/iu; - -/** - * Checks all segments in a set and returns true if any are reachable. - * @param {Set} segments The segments to check. - * @returns {boolean} True if any segment is reachable; false otherwise. - */ -function isAnySegmentReachable(segments) { - - for (const segment of segments) { - if (segment.reachable) { - return true; - } - } - - return false; -} - -/** - * Checks whether or not a given comment string is really a fallthrough comment and not an ESLint directive. - * @param {string} comment The comment string to check. - * @param {RegExp} fallthroughCommentPattern The regular expression used for checking for fallthrough comments. - * @returns {boolean} `true` if the comment string is truly a fallthrough comment. - */ -function isFallThroughComment(comment, fallthroughCommentPattern) { - return fallthroughCommentPattern.test(comment) && !directivesPattern.test(comment.trim()); -} - -/** - * Checks whether or not a given case has a fallthrough comment. - * @param {ASTNode} caseWhichFallsThrough SwitchCase node which falls through. - * @param {ASTNode} subsequentCase The case after caseWhichFallsThrough. - * @param {RuleContext} context A rule context which stores comments. - * @param {RegExp} fallthroughCommentPattern A pattern to match comment to. - * @returns {null | object} the comment if the case has a valid fallthrough comment, otherwise null - */ -function getFallthroughComment(caseWhichFallsThrough, subsequentCase, context, fallthroughCommentPattern) { - const sourceCode = context.sourceCode; - - if (caseWhichFallsThrough.consequent.length === 1 && caseWhichFallsThrough.consequent[0].type === "BlockStatement") { - const trailingCloseBrace = sourceCode.getLastToken(caseWhichFallsThrough.consequent[0]); - const commentInBlock = sourceCode.getCommentsBefore(trailingCloseBrace).pop(); - - if (commentInBlock && isFallThroughComment(commentInBlock.value, fallthroughCommentPattern)) { - return commentInBlock; - } - } - - const comment = sourceCode.getCommentsBefore(subsequentCase).pop(); - - if (comment && isFallThroughComment(comment.value, fallthroughCommentPattern)) { - return comment; - } - - return null; -} - -/** - * Checks whether a node and a token are separated by blank lines - * @param {ASTNode} node The node to check - * @param {Token} token The token to compare against - * @returns {boolean} `true` if there are blank lines between node and token - */ -function hasBlankLinesBetween(node, token) { - return token.loc.start.line > node.loc.end.line + 1; -} - -//------------------------------------------------------------------------------ -// Rule Definition -//------------------------------------------------------------------------------ - -/** @type {import('../shared/types').Rule} */ -module.exports = { - meta: { - type: "problem", - - docs: { - description: "Disallow fallthrough of `case` statements", - recommended: true, - url: "https://eslint.org/docs/latest/rules/no-fallthrough" - }, - - schema: [ - { - type: "object", - properties: { - commentPattern: { - type: "string", - default: "" - }, - allowEmptyCase: { - type: "boolean", - default: false - }, - reportUnusedFallthroughComment: { - type: "boolean", - default: false - } - }, - additionalProperties: false - } - ], - messages: { - unusedFallthroughComment: "Found a comment that would permit fallthrough, but case cannot fall through.", - case: "Expected a 'break' statement before 'case'.", - default: "Expected a 'break' statement before 'default'." - } - }, - - create(context) { - const options = context.options[0] || {}; - const codePathSegments = []; - let currentCodePathSegments = new Set(); - const sourceCode = context.sourceCode; - const allowEmptyCase = options.allowEmptyCase || false; - const reportUnusedFallthroughComment = options.reportUnusedFallthroughComment || false; - - /* - * We need to use leading comments of the next SwitchCase node because - * trailing comments is wrong if semicolons are omitted. - */ - let previousCase = null; - let fallthroughCommentPattern = null; - - if (options.commentPattern) { - fallthroughCommentPattern = new RegExp(options.commentPattern, "u"); - } else { - fallthroughCommentPattern = DEFAULT_FALLTHROUGH_COMMENT; - } - return { - - onCodePathStart() { - codePathSegments.push(currentCodePathSegments); - currentCodePathSegments = new Set(); - }, - - onCodePathEnd() { - currentCodePathSegments = codePathSegments.pop(); - }, - - onUnreachableCodePathSegmentStart(segment) { - currentCodePathSegments.add(segment); - }, - - onUnreachableCodePathSegmentEnd(segment) { - currentCodePathSegments.delete(segment); - }, - - onCodePathSegmentStart(segment) { - currentCodePathSegments.add(segment); - }, - - onCodePathSegmentEnd(segment) { - currentCodePathSegments.delete(segment); - }, - - - SwitchCase(node) { - - /* - * Checks whether or not there is a fallthrough comment. - * And reports the previous fallthrough node if that does not exist. - */ - - if (previousCase && previousCase.node.parent === node.parent) { - const previousCaseFallthroughComment = getFallthroughComment(previousCase.node, node, context, fallthroughCommentPattern); - - if (previousCase.isFallthrough && !(previousCaseFallthroughComment)) { - context.report({ - messageId: node.test ? "case" : "default", - node - }); - } else if (reportUnusedFallthroughComment && !previousCase.isSwitchExitReachable && previousCaseFallthroughComment) { - context.report({ - messageId: "unusedFallthroughComment", - node: previousCaseFallthroughComment - }); - } - - } - previousCase = null; - }, - - "SwitchCase:exit"(node) { - const nextToken = sourceCode.getTokenAfter(node); - - /* - * `reachable` meant fall through because statements preceded by - * `break`, `return`, or `throw` are unreachable. - * And allows empty cases and the last case. - */ - const isSwitchExitReachable = isAnySegmentReachable(currentCodePathSegments); - const isFallthrough = isSwitchExitReachable && (node.consequent.length > 0 || (!allowEmptyCase && hasBlankLinesBetween(node, nextToken))) && - node.parent.cases.at(-1) !== node; - - previousCase = { - node, - isSwitchExitReachable, - isFallthrough - }; - - } - }; - } -}; diff --git a/tools/eslint/node_modules/eslint/lib/rules/no-floating-decimal.js b/tools/eslint/node_modules/eslint/lib/rules/no-floating-decimal.js deleted file mode 100644 index 80e4994cd72af0..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/rules/no-floating-decimal.js +++ /dev/null @@ -1,73 +0,0 @@ -/** - * @fileoverview Rule to flag use of a leading/trailing decimal point in a numeric literal - * @author James Allardice - * @deprecated in ESLint v8.53.0 - */ - -"use strict"; - -//------------------------------------------------------------------------------ -// Requirements -//------------------------------------------------------------------------------ - -const astUtils = require("./utils/ast-utils"); - -//------------------------------------------------------------------------------ -// Rule Definition -//------------------------------------------------------------------------------ - -/** @type {import('../shared/types').Rule} */ -module.exports = { - meta: { - deprecated: true, - replacedBy: [], - type: "suggestion", - - docs: { - description: "Disallow leading or trailing decimal points in numeric literals", - recommended: false, - url: "https://eslint.org/docs/latest/rules/no-floating-decimal" - }, - - schema: [], - fixable: "code", - messages: { - leading: "A leading decimal point can be confused with a dot.", - trailing: "A trailing decimal point can be confused with a dot." - } - }, - - create(context) { - const sourceCode = context.sourceCode; - - return { - Literal(node) { - - if (typeof node.value === "number") { - if (node.raw.startsWith(".")) { - context.report({ - node, - messageId: "leading", - fix(fixer) { - const tokenBefore = sourceCode.getTokenBefore(node); - const needsSpaceBefore = tokenBefore && - tokenBefore.range[1] === node.range[0] && - !astUtils.canTokensBeAdjacent(tokenBefore, `0${node.raw}`); - - return fixer.insertTextBefore(node, needsSpaceBefore ? " 0" : "0"); - } - }); - } - if (node.raw.indexOf(".") === node.raw.length - 1) { - context.report({ - node, - messageId: "trailing", - fix: fixer => fixer.insertTextAfter(node, "0") - }); - } - } - } - }; - - } -}; diff --git a/tools/eslint/node_modules/eslint/lib/rules/no-func-assign.js b/tools/eslint/node_modules/eslint/lib/rules/no-func-assign.js deleted file mode 100644 index 8084af6eb4d204..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/rules/no-func-assign.js +++ /dev/null @@ -1,78 +0,0 @@ -/** - * @fileoverview Rule to flag use of function declaration identifiers as variables. - * @author Ian Christian Myers - */ - -"use strict"; - -const astUtils = require("./utils/ast-utils"); - -//------------------------------------------------------------------------------ -// Rule Definition -//------------------------------------------------------------------------------ - -/** @type {import('../shared/types').Rule} */ -module.exports = { - meta: { - type: "problem", - - docs: { - description: "Disallow reassigning `function` declarations", - recommended: true, - url: "https://eslint.org/docs/latest/rules/no-func-assign" - }, - - schema: [], - - messages: { - isAFunction: "'{{name}}' is a function." - } - }, - - create(context) { - - const sourceCode = context.sourceCode; - - /** - * Reports a reference if is non initializer and writable. - * @param {References} references Collection of reference to check. - * @returns {void} - */ - function checkReference(references) { - astUtils.getModifyingReferences(references).forEach(reference => { - context.report({ - node: reference.identifier, - messageId: "isAFunction", - data: { - name: reference.identifier.name - } - }); - }); - } - - /** - * Finds and reports references that are non initializer and writable. - * @param {Variable} variable A variable to check. - * @returns {void} - */ - function checkVariable(variable) { - if (variable.defs[0].type === "FunctionName") { - checkReference(variable.references); - } - } - - /** - * Checks parameters of a given function node. - * @param {ASTNode} node A function node to check. - * @returns {void} - */ - function checkForFunction(node) { - sourceCode.getDeclaredVariables(node).forEach(checkVariable); - } - - return { - FunctionDeclaration: checkForFunction, - FunctionExpression: checkForFunction - }; - } -}; diff --git a/tools/eslint/node_modules/eslint/lib/rules/no-global-assign.js b/tools/eslint/node_modules/eslint/lib/rules/no-global-assign.js deleted file mode 100644 index 99ae7a2ee5e2cb..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/rules/no-global-assign.js +++ /dev/null @@ -1,95 +0,0 @@ -/** - * @fileoverview Rule to disallow assignments to native objects or read-only global variables - * @author Ilya Volodin - */ - -"use strict"; - -//------------------------------------------------------------------------------ -// Rule Definition -//------------------------------------------------------------------------------ - -/** @type {import('../shared/types').Rule} */ -module.exports = { - meta: { - type: "suggestion", - - docs: { - description: "Disallow assignments to native objects or read-only global variables", - recommended: true, - url: "https://eslint.org/docs/latest/rules/no-global-assign" - }, - - schema: [ - { - type: "object", - properties: { - exceptions: { - type: "array", - items: { type: "string" }, - uniqueItems: true - } - }, - additionalProperties: false - } - ], - - messages: { - globalShouldNotBeModified: "Read-only global '{{name}}' should not be modified." - } - }, - - create(context) { - const config = context.options[0]; - const sourceCode = context.sourceCode; - const exceptions = (config && config.exceptions) || []; - - /** - * Reports write references. - * @param {Reference} reference A reference to check. - * @param {int} index The index of the reference in the references. - * @param {Reference[]} references The array that the reference belongs to. - * @returns {void} - */ - function checkReference(reference, index, references) { - const identifier = reference.identifier; - - if (reference.init === false && - reference.isWrite() && - - /* - * Destructuring assignments can have multiple default value, - * so possibly there are multiple writeable references for the same identifier. - */ - (index === 0 || references[index - 1].identifier !== identifier) - ) { - context.report({ - node: identifier, - messageId: "globalShouldNotBeModified", - data: { - name: identifier.name - } - }); - } - } - - /** - * Reports write references if a given variable is read-only builtin. - * @param {Variable} variable A variable to check. - * @returns {void} - */ - function checkVariable(variable) { - if (variable.writeable === false && !exceptions.includes(variable.name)) { - variable.references.forEach(checkReference); - } - } - - return { - Program(node) { - const globalScope = sourceCode.getScope(node); - - globalScope.variables.forEach(checkVariable); - } - }; - } -}; diff --git a/tools/eslint/node_modules/eslint/lib/rules/no-implicit-coercion.js b/tools/eslint/node_modules/eslint/lib/rules/no-implicit-coercion.js deleted file mode 100644 index 3f8a7c0f9417f7..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/rules/no-implicit-coercion.js +++ /dev/null @@ -1,422 +0,0 @@ -/** - * @fileoverview A rule to disallow the type conversions with shorter notations. - * @author Toru Nagashima - */ - -"use strict"; - -const astUtils = require("./utils/ast-utils"); - -//------------------------------------------------------------------------------ -// Helpers -//------------------------------------------------------------------------------ - -const INDEX_OF_PATTERN = /^(?:i|lastI)ndexOf$/u; -const ALLOWABLE_OPERATORS = ["~", "!!", "+", "- -", "-", "*"]; - -/** - * Parses and normalizes an option object. - * @param {Object} options An option object to parse. - * @returns {Object} The parsed and normalized option object. - */ -function parseOptions(options) { - return { - boolean: "boolean" in options ? options.boolean : true, - number: "number" in options ? options.number : true, - string: "string" in options ? options.string : true, - disallowTemplateShorthand: "disallowTemplateShorthand" in options ? options.disallowTemplateShorthand : false, - allow: options.allow || [] - }; -} - -/** - * Checks whether or not a node is a double logical negating. - * @param {ASTNode} node An UnaryExpression node to check. - * @returns {boolean} Whether or not the node is a double logical negating. - */ -function isDoubleLogicalNegating(node) { - return ( - node.operator === "!" && - node.argument.type === "UnaryExpression" && - node.argument.operator === "!" - ); -} - -/** - * Checks whether or not a node is a binary negating of `.indexOf()` method calling. - * @param {ASTNode} node An UnaryExpression node to check. - * @returns {boolean} Whether or not the node is a binary negating of `.indexOf()` method calling. - */ -function isBinaryNegatingOfIndexOf(node) { - if (node.operator !== "~") { - return false; - } - const callNode = astUtils.skipChainExpression(node.argument); - - return ( - callNode.type === "CallExpression" && - astUtils.isSpecificMemberAccess(callNode.callee, null, INDEX_OF_PATTERN) - ); -} - -/** - * Checks whether or not a node is a multiplying by one. - * @param {BinaryExpression} node A BinaryExpression node to check. - * @returns {boolean} Whether or not the node is a multiplying by one. - */ -function isMultiplyByOne(node) { - return node.operator === "*" && ( - node.left.type === "Literal" && node.left.value === 1 || - node.right.type === "Literal" && node.right.value === 1 - ); -} - -/** - * Checks whether the given node logically represents multiplication by a fraction of `1`. - * For example, `a * 1` in `a * 1 / b` is technically multiplication by `1`, but the - * whole expression can be logically interpreted as `a * (1 / b)` rather than `(a * 1) / b`. - * @param {BinaryExpression} node A BinaryExpression node to check. - * @param {SourceCode} sourceCode The source code object. - * @returns {boolean} Whether or not the node is a multiplying by a fraction of `1`. - */ -function isMultiplyByFractionOfOne(node, sourceCode) { - return node.type === "BinaryExpression" && - node.operator === "*" && - (node.right.type === "Literal" && node.right.value === 1) && - node.parent.type === "BinaryExpression" && - node.parent.operator === "/" && - node.parent.left === node && - !astUtils.isParenthesised(sourceCode, node); -} - -/** - * Checks whether the result of a node is numeric or not - * @param {ASTNode} node The node to test - * @returns {boolean} true if the node is a number literal or a `Number()`, `parseInt` or `parseFloat` call - */ -function isNumeric(node) { - return ( - node.type === "Literal" && typeof node.value === "number" || - node.type === "CallExpression" && ( - node.callee.name === "Number" || - node.callee.name === "parseInt" || - node.callee.name === "parseFloat" - ) - ); -} - -/** - * Returns the first non-numeric operand in a BinaryExpression. Designed to be - * used from bottom to up since it walks up the BinaryExpression trees using - * node.parent to find the result. - * @param {BinaryExpression} node The BinaryExpression node to be walked up on - * @returns {ASTNode|null} The first non-numeric item in the BinaryExpression tree or null - */ -function getNonNumericOperand(node) { - const left = node.left, - right = node.right; - - if (right.type !== "BinaryExpression" && !isNumeric(right)) { - return right; - } - - if (left.type !== "BinaryExpression" && !isNumeric(left)) { - return left; - } - - return null; -} - -/** - * Checks whether an expression evaluates to a string. - * @param {ASTNode} node node that represents the expression to check. - * @returns {boolean} Whether or not the expression evaluates to a string. - */ -function isStringType(node) { - return astUtils.isStringLiteral(node) || - ( - node.type === "CallExpression" && - node.callee.type === "Identifier" && - node.callee.name === "String" - ); -} - -/** - * Checks whether a node is an empty string literal or not. - * @param {ASTNode} node The node to check. - * @returns {boolean} Whether or not the passed in node is an - * empty string literal or not. - */ -function isEmptyString(node) { - return astUtils.isStringLiteral(node) && (node.value === "" || (node.type === "TemplateLiteral" && node.quasis.length === 1 && node.quasis[0].value.cooked === "")); -} - -/** - * Checks whether or not a node is a concatenating with an empty string. - * @param {ASTNode} node A BinaryExpression node to check. - * @returns {boolean} Whether or not the node is a concatenating with an empty string. - */ -function isConcatWithEmptyString(node) { - return node.operator === "+" && ( - (isEmptyString(node.left) && !isStringType(node.right)) || - (isEmptyString(node.right) && !isStringType(node.left)) - ); -} - -/** - * Checks whether or not a node is appended with an empty string. - * @param {ASTNode} node An AssignmentExpression node to check. - * @returns {boolean} Whether or not the node is appended with an empty string. - */ -function isAppendEmptyString(node) { - return node.operator === "+=" && isEmptyString(node.right); -} - -/** - * Returns the operand that is not an empty string from a flagged BinaryExpression. - * @param {ASTNode} node The flagged BinaryExpression node to check. - * @returns {ASTNode} The operand that is not an empty string from a flagged BinaryExpression. - */ -function getNonEmptyOperand(node) { - return isEmptyString(node.left) ? node.right : node.left; -} - -//------------------------------------------------------------------------------ -// Rule Definition -//------------------------------------------------------------------------------ - -/** @type {import('../shared/types').Rule} */ -module.exports = { - meta: { - hasSuggestions: true, - type: "suggestion", - - docs: { - description: "Disallow shorthand type conversions", - recommended: false, - url: "https://eslint.org/docs/latest/rules/no-implicit-coercion" - }, - - fixable: "code", - - schema: [{ - type: "object", - properties: { - boolean: { - type: "boolean", - default: true - }, - number: { - type: "boolean", - default: true - }, - string: { - type: "boolean", - default: true - }, - disallowTemplateShorthand: { - type: "boolean", - default: false - }, - allow: { - type: "array", - items: { - enum: ALLOWABLE_OPERATORS - }, - uniqueItems: true - } - }, - additionalProperties: false - }], - - messages: { - implicitCoercion: "Unexpected implicit coercion encountered. Use `{{recommendation}}` instead.", - useRecommendation: "Use `{{recommendation}}` instead." - } - }, - - create(context) { - const options = parseOptions(context.options[0] || {}); - const sourceCode = context.sourceCode; - - /** - * Reports an error and autofixes the node - * @param {ASTNode} node An ast node to report the error on. - * @param {string} recommendation The recommended code for the issue - * @param {bool} shouldSuggest Whether this report should offer a suggestion - * @param {bool} shouldFix Whether this report should fix the node - * @returns {void} - */ - function report(node, recommendation, shouldSuggest, shouldFix) { - - /** - * Fix function - * @param {RuleFixer} fixer The fixer to fix. - * @returns {Fix} The fix object. - */ - function fix(fixer) { - const tokenBefore = sourceCode.getTokenBefore(node); - - if ( - tokenBefore?.range[1] === node.range[0] && - !astUtils.canTokensBeAdjacent(tokenBefore, recommendation) - ) { - return fixer.replaceText(node, ` ${recommendation}`); - } - - return fixer.replaceText(node, recommendation); - } - - context.report({ - node, - messageId: "implicitCoercion", - data: { recommendation }, - fix(fixer) { - if (!shouldFix) { - return null; - } - - return fix(fixer); - }, - suggest: [ - { - messageId: "useRecommendation", - data: { recommendation }, - fix(fixer) { - if (shouldFix || !shouldSuggest) { - return null; - } - - return fix(fixer); - } - } - ] - }); - } - - return { - UnaryExpression(node) { - let operatorAllowed; - - // !!foo - operatorAllowed = options.allow.includes("!!"); - if (!operatorAllowed && options.boolean && isDoubleLogicalNegating(node)) { - const recommendation = `Boolean(${sourceCode.getText(node.argument.argument)})`; - const variable = astUtils.getVariableByName(sourceCode.getScope(node), "Boolean"); - const booleanExists = variable?.identifiers.length === 0; - - report(node, recommendation, true, booleanExists); - } - - // ~foo.indexOf(bar) - operatorAllowed = options.allow.includes("~"); - if (!operatorAllowed && options.boolean && isBinaryNegatingOfIndexOf(node)) { - - // `foo?.indexOf(bar) !== -1` will be true (== found) if the `foo` is nullish. So use `>= 0` in that case. - const comparison = node.argument.type === "ChainExpression" ? ">= 0" : "!== -1"; - const recommendation = `${sourceCode.getText(node.argument)} ${comparison}`; - - report(node, recommendation, false, false); - } - - // +foo - operatorAllowed = options.allow.includes("+"); - if (!operatorAllowed && options.number && node.operator === "+" && !isNumeric(node.argument)) { - const recommendation = `Number(${sourceCode.getText(node.argument)})`; - - report(node, recommendation, true, false); - } - - // -(-foo) - operatorAllowed = options.allow.includes("- -"); - if (!operatorAllowed && options.number && node.operator === "-" && node.argument.type === "UnaryExpression" && node.argument.operator === "-" && !isNumeric(node.argument.argument)) { - const recommendation = `Number(${sourceCode.getText(node.argument.argument)})`; - - report(node, recommendation, true, false); - } - }, - - // Use `:exit` to prevent double reporting - "BinaryExpression:exit"(node) { - let operatorAllowed; - - // 1 * foo - operatorAllowed = options.allow.includes("*"); - const nonNumericOperand = !operatorAllowed && options.number && isMultiplyByOne(node) && !isMultiplyByFractionOfOne(node, sourceCode) && - getNonNumericOperand(node); - - if (nonNumericOperand) { - const recommendation = `Number(${sourceCode.getText(nonNumericOperand)})`; - - report(node, recommendation, true, false); - } - - // foo - 0 - operatorAllowed = options.allow.includes("-"); - if (!operatorAllowed && options.number && node.operator === "-" && node.right.type === "Literal" && node.right.value === 0 && !isNumeric(node.left)) { - const recommendation = `Number(${sourceCode.getText(node.left)})`; - - report(node, recommendation, true, false); - } - - // "" + foo - operatorAllowed = options.allow.includes("+"); - if (!operatorAllowed && options.string && isConcatWithEmptyString(node)) { - const recommendation = `String(${sourceCode.getText(getNonEmptyOperand(node))})`; - - report(node, recommendation, true, false); - } - }, - - AssignmentExpression(node) { - - // foo += "" - const operatorAllowed = options.allow.includes("+"); - - if (!operatorAllowed && options.string && isAppendEmptyString(node)) { - const code = sourceCode.getText(getNonEmptyOperand(node)); - const recommendation = `${code} = String(${code})`; - - report(node, recommendation, true, false); - } - }, - - TemplateLiteral(node) { - if (!options.disallowTemplateShorthand) { - return; - } - - // tag`${foo}` - if (node.parent.type === "TaggedTemplateExpression") { - return; - } - - // `` or `${foo}${bar}` - if (node.expressions.length !== 1) { - return; - } - - - // `prefix${foo}` - if (node.quasis[0].value.cooked !== "") { - return; - } - - // `${foo}postfix` - if (node.quasis[1].value.cooked !== "") { - return; - } - - // if the expression is already a string, then this isn't a coercion - if (isStringType(node.expressions[0])) { - return; - } - - const code = sourceCode.getText(node.expressions[0]); - const recommendation = `String(${code})`; - - report(node, recommendation, true, false); - } - }; - } -}; diff --git a/tools/eslint/node_modules/eslint/lib/rules/no-implicit-globals.js b/tools/eslint/node_modules/eslint/lib/rules/no-implicit-globals.js deleted file mode 100644 index 2a182477c0e2b3..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/rules/no-implicit-globals.js +++ /dev/null @@ -1,146 +0,0 @@ -/** - * @fileoverview Rule to check for implicit global variables, functions and classes. - * @author Joshua Peek - */ - -"use strict"; - -//------------------------------------------------------------------------------ -// Rule Definition -//------------------------------------------------------------------------------ - -/** @type {import('../shared/types').Rule} */ -module.exports = { - meta: { - type: "suggestion", - - docs: { - description: "Disallow declarations in the global scope", - recommended: false, - url: "https://eslint.org/docs/latest/rules/no-implicit-globals" - }, - - schema: [{ - type: "object", - properties: { - lexicalBindings: { - type: "boolean", - default: false - } - }, - additionalProperties: false - }], - - messages: { - globalNonLexicalBinding: "Unexpected {{kind}} declaration in the global scope, wrap in an IIFE for a local variable, assign as global property for a global variable.", - globalLexicalBinding: "Unexpected {{kind}} declaration in the global scope, wrap in a block or in an IIFE.", - globalVariableLeak: "Global variable leak, declare the variable if it is intended to be local.", - assignmentToReadonlyGlobal: "Unexpected assignment to read-only global variable.", - redeclarationOfReadonlyGlobal: "Unexpected redeclaration of read-only global variable." - } - }, - - create(context) { - - const checkLexicalBindings = context.options[0] && context.options[0].lexicalBindings === true; - const sourceCode = context.sourceCode; - - /** - * Reports the node. - * @param {ASTNode} node Node to report. - * @param {string} messageId Id of the message to report. - * @param {string|undefined} kind Declaration kind, can be 'var', 'const', 'let', function or class. - * @returns {void} - */ - function report(node, messageId, kind) { - context.report({ - node, - messageId, - data: { - kind - } - }); - } - - return { - Program(node) { - const scope = sourceCode.getScope(node); - - scope.variables.forEach(variable => { - - // Only ESLint global variables have the `writable` key. - const isReadonlyEslintGlobalVariable = variable.writeable === false; - const isWritableEslintGlobalVariable = variable.writeable === true; - - if (isWritableEslintGlobalVariable) { - - // Everything is allowed with writable ESLint global variables. - return; - } - - // Variables exported by "exported" block comments - if (variable.eslintExported) { - return; - } - - variable.defs.forEach(def => { - const defNode = def.node; - - if (def.type === "FunctionName" || (def.type === "Variable" && def.parent.kind === "var")) { - if (isReadonlyEslintGlobalVariable) { - report(defNode, "redeclarationOfReadonlyGlobal"); - } else { - report( - defNode, - "globalNonLexicalBinding", - def.type === "FunctionName" ? "function" : `'${def.parent.kind}'` - ); - } - } - - if (checkLexicalBindings) { - if (def.type === "ClassName" || - (def.type === "Variable" && (def.parent.kind === "let" || def.parent.kind === "const"))) { - if (isReadonlyEslintGlobalVariable) { - report(defNode, "redeclarationOfReadonlyGlobal"); - } else { - report( - defNode, - "globalLexicalBinding", - def.type === "ClassName" ? "class" : `'${def.parent.kind}'` - ); - } - } - } - }); - }); - - // Undeclared assigned variables. - scope.implicit.variables.forEach(variable => { - const scopeVariable = scope.set.get(variable.name); - let messageId; - - if (scopeVariable) { - - // ESLint global variable - if (scopeVariable.writeable) { - return; - } - messageId = "assignmentToReadonlyGlobal"; - - } else { - - // Reference to an unknown variable, possible global leak. - messageId = "globalVariableLeak"; - } - - // def.node is an AssignmentExpression, ForInStatement or ForOfStatement. - variable.defs.forEach(def => { - report(def.node, messageId); - }); - }); - } - }; - - } -}; diff --git a/tools/eslint/node_modules/eslint/lib/rules/no-implied-eval.js b/tools/eslint/node_modules/eslint/lib/rules/no-implied-eval.js deleted file mode 100644 index 9a84f8cbaf141e..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/rules/no-implied-eval.js +++ /dev/null @@ -1,132 +0,0 @@ -/** - * @fileoverview Rule to flag use of implied eval via setTimeout and setInterval - * @author James Allardice - */ - -"use strict"; - -//------------------------------------------------------------------------------ -// Requirements -//------------------------------------------------------------------------------ - -const astUtils = require("./utils/ast-utils"); -const { getStaticValue } = require("@eslint-community/eslint-utils"); - -//------------------------------------------------------------------------------ -// Rule Definition -//------------------------------------------------------------------------------ - -/** @type {import('../shared/types').Rule} */ -module.exports = { - meta: { - type: "suggestion", - - docs: { - description: "Disallow the use of `eval()`-like methods", - recommended: false, - url: "https://eslint.org/docs/latest/rules/no-implied-eval" - }, - - schema: [], - - messages: { - impliedEval: "Implied eval. Consider passing a function instead of a string." - } - }, - - create(context) { - const GLOBAL_CANDIDATES = Object.freeze(["global", "window", "globalThis"]); - const EVAL_LIKE_FUNC_PATTERN = /^(?:set(?:Interval|Timeout)|execScript)$/u; - const sourceCode = context.sourceCode; - - /** - * Checks whether a node is evaluated as a string or not. - * @param {ASTNode} node A node to check. - * @returns {boolean} True if the node is evaluated as a string. - */ - function isEvaluatedString(node) { - if ( - (node.type === "Literal" && typeof node.value === "string") || - node.type === "TemplateLiteral" - ) { - return true; - } - if (node.type === "BinaryExpression" && node.operator === "+") { - return isEvaluatedString(node.left) || isEvaluatedString(node.right); - } - return false; - } - - /** - * Reports if the `CallExpression` node has evaluated argument. - * @param {ASTNode} node A CallExpression to check. - * @returns {void} - */ - function reportImpliedEvalCallExpression(node) { - const [firstArgument] = node.arguments; - - if (firstArgument) { - - const staticValue = getStaticValue(firstArgument, sourceCode.getScope(node)); - const isStaticString = staticValue && typeof staticValue.value === "string"; - const isString = isStaticString || isEvaluatedString(firstArgument); - - if (isString) { - context.report({ - node, - messageId: "impliedEval" - }); - } - } - - } - - /** - * Reports calls of `implied eval` via the global references. - * @param {Variable} globalVar A global variable to check. - * @returns {void} - */ - function reportImpliedEvalViaGlobal(globalVar) { - const { references, name } = globalVar; - - references.forEach(ref => { - const identifier = ref.identifier; - let node = identifier.parent; - - while (astUtils.isSpecificMemberAccess(node, null, name)) { - node = node.parent; - } - - if (astUtils.isSpecificMemberAccess(node, null, EVAL_LIKE_FUNC_PATTERN)) { - const calleeNode = node.parent.type === "ChainExpression" ? node.parent : node; - const parent = calleeNode.parent; - - if (parent.type === "CallExpression" && parent.callee === calleeNode) { - reportImpliedEvalCallExpression(parent); - } - } - }); - } - - //-------------------------------------------------------------------------- - // Public - //-------------------------------------------------------------------------- - - return { - CallExpression(node) { - if (astUtils.isSpecificId(node.callee, EVAL_LIKE_FUNC_PATTERN)) { - reportImpliedEvalCallExpression(node); - } - }, - "Program:exit"(node) { - const globalScope = sourceCode.getScope(node); - - GLOBAL_CANDIDATES - .map(candidate => astUtils.getVariableByName(globalScope, candidate)) - .filter(globalVar => !!globalVar && globalVar.defs.length === 0) - .forEach(reportImpliedEvalViaGlobal); - } - }; - - } -}; diff --git a/tools/eslint/node_modules/eslint/lib/rules/no-import-assign.js b/tools/eslint/node_modules/eslint/lib/rules/no-import-assign.js deleted file mode 100644 index c69988666ab8f2..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/rules/no-import-assign.js +++ /dev/null @@ -1,241 +0,0 @@ -/** - * @fileoverview Rule to flag updates of imported bindings. - * @author Toru Nagashima - */ - -"use strict"; - -//------------------------------------------------------------------------------ -// Helpers -//------------------------------------------------------------------------------ - -const { findVariable } = require("@eslint-community/eslint-utils"); -const astUtils = require("./utils/ast-utils"); - -const WellKnownMutationFunctions = { - Object: /^(?:assign|definePropert(?:y|ies)|freeze|setPrototypeOf)$/u, - Reflect: /^(?:(?:define|delete)Property|set(?:PrototypeOf)?)$/u -}; - -/** - * Check if a given node is LHS of an assignment node. - * @param {ASTNode} node The node to check. - * @returns {boolean} `true` if the node is LHS. - */ -function isAssignmentLeft(node) { - const { parent } = node; - - return ( - ( - parent.type === "AssignmentExpression" && - parent.left === node - ) || - - // Destructuring assignments - parent.type === "ArrayPattern" || - ( - parent.type === "Property" && - parent.value === node && - parent.parent.type === "ObjectPattern" - ) || - parent.type === "RestElement" || - ( - parent.type === "AssignmentPattern" && - parent.left === node - ) - ); -} - -/** - * Check if a given node is the operand of mutation unary operator. - * @param {ASTNode} node The node to check. - * @returns {boolean} `true` if the node is the operand of mutation unary operator. - */ -function isOperandOfMutationUnaryOperator(node) { - const argumentNode = node.parent.type === "ChainExpression" - ? node.parent - : node; - const { parent } = argumentNode; - - return ( - ( - parent.type === "UpdateExpression" && - parent.argument === argumentNode - ) || - ( - parent.type === "UnaryExpression" && - parent.operator === "delete" && - parent.argument === argumentNode - ) - ); -} - -/** - * Check if a given node is the iteration variable of `for-in`/`for-of` syntax. - * @param {ASTNode} node The node to check. - * @returns {boolean} `true` if the node is the iteration variable. - */ -function isIterationVariable(node) { - const { parent } = node; - - return ( - ( - parent.type === "ForInStatement" && - parent.left === node - ) || - ( - parent.type === "ForOfStatement" && - parent.left === node - ) - ); -} - -/** - * Check if a given node is at the first argument of a well-known mutation function. - * - `Object.assign` - * - `Object.defineProperty` - * - `Object.defineProperties` - * - `Object.freeze` - * - `Object.setPrototypeOf` - * - `Reflect.defineProperty` - * - `Reflect.deleteProperty` - * - `Reflect.set` - * - `Reflect.setPrototypeOf` - * @param {ASTNode} node The node to check. - * @param {Scope} scope A `escope.Scope` object to find variable (whichever). - * @returns {boolean} `true` if the node is at the first argument of a well-known mutation function. - */ -function isArgumentOfWellKnownMutationFunction(node, scope) { - const { parent } = node; - - if (parent.type !== "CallExpression" || parent.arguments[0] !== node) { - return false; - } - const callee = astUtils.skipChainExpression(parent.callee); - - if ( - !astUtils.isSpecificMemberAccess(callee, "Object", WellKnownMutationFunctions.Object) && - !astUtils.isSpecificMemberAccess(callee, "Reflect", WellKnownMutationFunctions.Reflect) - ) { - return false; - } - const variable = findVariable(scope, callee.object); - - return variable !== null && variable.scope.type === "global"; -} - -/** - * Check if the identifier node is placed at to update members. - * @param {ASTNode} id The Identifier node to check. - * @param {Scope} scope A `escope.Scope` object to find variable (whichever). - * @returns {boolean} `true` if the member of `id` was updated. - */ -function isMemberWrite(id, scope) { - const { parent } = id; - - return ( - ( - parent.type === "MemberExpression" && - parent.object === id && - ( - isAssignmentLeft(parent) || - isOperandOfMutationUnaryOperator(parent) || - isIterationVariable(parent) - ) - ) || - isArgumentOfWellKnownMutationFunction(id, scope) - ); -} - -/** - * Get the mutation node. - * @param {ASTNode} id The Identifier node to get. - * @returns {ASTNode} The mutation node. - */ -function getWriteNode(id) { - let node = id.parent; - - while ( - node && - node.type !== "AssignmentExpression" && - node.type !== "UpdateExpression" && - node.type !== "UnaryExpression" && - node.type !== "CallExpression" && - node.type !== "ForInStatement" && - node.type !== "ForOfStatement" - ) { - node = node.parent; - } - - return node || id; -} - -//------------------------------------------------------------------------------ -// Rule Definition -//------------------------------------------------------------------------------ - -/** @type {import('../shared/types').Rule} */ -module.exports = { - meta: { - type: "problem", - - docs: { - description: "Disallow assigning to imported bindings", - recommended: true, - url: "https://eslint.org/docs/latest/rules/no-import-assign" - }, - - schema: [], - - messages: { - readonly: "'{{name}}' is read-only.", - readonlyMember: "The members of '{{name}}' are read-only." - } - }, - - create(context) { - const sourceCode = context.sourceCode; - - return { - ImportDeclaration(node) { - const scope = sourceCode.getScope(node); - - for (const variable of sourceCode.getDeclaredVariables(node)) { - const shouldCheckMembers = variable.defs.some( - d => d.node.type === "ImportNamespaceSpecifier" - ); - let prevIdNode = null; - - for (const reference of variable.references) { - const idNode = reference.identifier; - - /* - * AssignmentPattern (e.g. `[a = 0] = b`) makes two write - * references for the same identifier. This should skip - * the one of the two in order to prevent redundant reports. - */ - if (idNode === prevIdNode) { - continue; - } - prevIdNode = idNode; - - if (reference.isWrite()) { - context.report({ - node: getWriteNode(idNode), - messageId: "readonly", - data: { name: idNode.name } - }); - } else if (shouldCheckMembers && isMemberWrite(idNode, scope)) { - context.report({ - node: getWriteNode(idNode), - messageId: "readonlyMember", - data: { name: idNode.name } - }); - } - } - } - } - }; - - } -}; diff --git a/tools/eslint/node_modules/eslint/lib/rules/no-inline-comments.js b/tools/eslint/node_modules/eslint/lib/rules/no-inline-comments.js deleted file mode 100644 index d96e6472d1319d..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/rules/no-inline-comments.js +++ /dev/null @@ -1,110 +0,0 @@ -/** - * @fileoverview Enforces or disallows inline comments. - * @author Greg Cochard - */ -"use strict"; - -const astUtils = require("./utils/ast-utils"); - -//------------------------------------------------------------------------------ -// Rule Definition -//------------------------------------------------------------------------------ - -/** @type {import('../shared/types').Rule} */ -module.exports = { - meta: { - type: "suggestion", - - docs: { - description: "Disallow inline comments after code", - recommended: false, - url: "https://eslint.org/docs/latest/rules/no-inline-comments" - }, - - schema: [ - { - type: "object", - properties: { - ignorePattern: { - type: "string" - } - }, - additionalProperties: false - } - ], - - messages: { - unexpectedInlineComment: "Unexpected comment inline with code." - } - }, - - create(context) { - const sourceCode = context.sourceCode; - const options = context.options[0]; - let customIgnoreRegExp; - - if (options && options.ignorePattern) { - customIgnoreRegExp = new RegExp(options.ignorePattern, "u"); - } - - /** - * Will check that comments are not on lines starting with or ending with code - * @param {ASTNode} node The comment node to check - * @private - * @returns {void} - */ - function testCodeAroundComment(node) { - - const startLine = String(sourceCode.lines[node.loc.start.line - 1]), - endLine = String(sourceCode.lines[node.loc.end.line - 1]), - preamble = startLine.slice(0, node.loc.start.column).trim(), - postamble = endLine.slice(node.loc.end.column).trim(), - isPreambleEmpty = !preamble, - isPostambleEmpty = !postamble; - - // Nothing on both sides - if (isPreambleEmpty && isPostambleEmpty) { - return; - } - - // Matches the ignore pattern - if (customIgnoreRegExp && customIgnoreRegExp.test(node.value)) { - return; - } - - // JSX Exception - if ( - (isPreambleEmpty || preamble === "{") && - (isPostambleEmpty || postamble === "}") - ) { - const enclosingNode = sourceCode.getNodeByRangeIndex(node.range[0]); - - if (enclosingNode && enclosingNode.type === "JSXEmptyExpression") { - return; - } - } - - // Don't report ESLint directive comments - if (astUtils.isDirectiveComment(node)) { - return; - } - - context.report({ - node, - messageId: "unexpectedInlineComment" - }); - } - - //-------------------------------------------------------------------------- - // Public - //-------------------------------------------------------------------------- - - return { - Program() { - sourceCode.getAllComments() - .filter(token => token.type !== "Shebang") - .forEach(testCodeAroundComment); - } - }; - } -}; diff --git a/tools/eslint/node_modules/eslint/lib/rules/no-inner-declarations.js b/tools/eslint/node_modules/eslint/lib/rules/no-inner-declarations.js deleted file mode 100644 index a690d95bb9c30a..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/rules/no-inner-declarations.js +++ /dev/null @@ -1,131 +0,0 @@ -/** - * @fileoverview Rule to enforce declarations in program or function body root. - * @author Brandon Mills - */ - -"use strict"; - -//------------------------------------------------------------------------------ -// Requirements -//------------------------------------------------------------------------------ - -const astUtils = require("./utils/ast-utils"); - -//------------------------------------------------------------------------------ -// Rule Definition -//------------------------------------------------------------------------------ - -const validParent = new Set(["Program", "StaticBlock", "ExportNamedDeclaration", "ExportDefaultDeclaration"]); -const validBlockStatementParent = new Set(["FunctionDeclaration", "FunctionExpression", "ArrowFunctionExpression"]); - -/** - * Finds the nearest enclosing context where this rule allows declarations and returns its description. - * @param {ASTNode} node Node to search from. - * @returns {string} Description. One of "program", "function body", "class static block body". - */ -function getAllowedBodyDescription(node) { - let { parent } = node; - - while (parent) { - - if (parent.type === "StaticBlock") { - return "class static block body"; - } - - if (astUtils.isFunction(parent)) { - return "function body"; - } - - ({ parent } = parent); - } - - return "program"; -} - -/** @type {import('../shared/types').Rule} */ -module.exports = { - meta: { - type: "problem", - - docs: { - description: "Disallow variable or `function` declarations in nested blocks", - recommended: false, - url: "https://eslint.org/docs/latest/rules/no-inner-declarations" - }, - - schema: [ - { - enum: ["functions", "both"] - }, - { - type: "object", - properties: { - blockScopedFunctions: { - enum: ["allow", "disallow"] - } - }, - additionalProperties: false - } - ], - - messages: { - moveDeclToRoot: "Move {{type}} declaration to {{body}} root." - } - }, - - create(context) { - - const sourceCode = context.sourceCode; - const ecmaVersion = context.languageOptions.ecmaVersion; - const blockScopedFunctions = context.options[1]?.blockScopedFunctions ?? "allow"; - - /** - * Ensure that a given node is at a program or function body's root. - * @param {ASTNode} node Declaration node to check. - * @returns {void} - */ - function check(node) { - const parent = node.parent; - - if ( - parent.type === "BlockStatement" && validBlockStatementParent.has(parent.parent.type) - ) { - return; - } - - if (validParent.has(parent.type)) { - return; - } - - context.report({ - node, - messageId: "moveDeclToRoot", - data: { - type: (node.type === "FunctionDeclaration" ? "function" : "variable"), - body: getAllowedBodyDescription(node) - } - }); - } - - - return { - - FunctionDeclaration(node) { - const isInStrictCode = sourceCode.getScope(node).upper.isStrict; - - if (blockScopedFunctions === "allow" && ecmaVersion >= 2015 && isInStrictCode) { - return; - } - - check(node); - }, - VariableDeclaration(node) { - if (context.options[0] === "both" && node.kind === "var") { - check(node); - } - } - - }; - - } -}; diff --git a/tools/eslint/node_modules/eslint/lib/rules/no-invalid-regexp.js b/tools/eslint/node_modules/eslint/lib/rules/no-invalid-regexp.js deleted file mode 100644 index 99fa6295af27f6..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/rules/no-invalid-regexp.js +++ /dev/null @@ -1,194 +0,0 @@ -/** - * @fileoverview Validate strings passed to the RegExp constructor - * @author Michael Ficarra - */ -"use strict"; - -//------------------------------------------------------------------------------ -// Requirements -//------------------------------------------------------------------------------ - -const RegExpValidator = require("@eslint-community/regexpp").RegExpValidator; -const validator = new RegExpValidator(); -const validFlags = /[dgimsuvy]/gu; -const undefined1 = void 0; - -//------------------------------------------------------------------------------ -// Rule Definition -//------------------------------------------------------------------------------ - -/** @type {import('../shared/types').Rule} */ -module.exports = { - meta: { - type: "problem", - - docs: { - description: "Disallow invalid regular expression strings in `RegExp` constructors", - recommended: true, - url: "https://eslint.org/docs/latest/rules/no-invalid-regexp" - }, - - schema: [{ - type: "object", - properties: { - allowConstructorFlags: { - type: "array", - items: { - type: "string" - } - } - }, - additionalProperties: false - }], - - messages: { - regexMessage: "{{message}}." - } - }, - - create(context) { - - const options = context.options[0]; - let allowedFlags = null; - - if (options && options.allowConstructorFlags) { - const temp = options.allowConstructorFlags.join("").replace(validFlags, ""); - - if (temp) { - allowedFlags = new RegExp(`[${temp}]`, "gu"); - } - } - - /** - * Reports error with the provided message. - * @param {ASTNode} node The node holding the invalid RegExp - * @param {string} message The message to report. - * @returns {void} - */ - function report(node, message) { - context.report({ - node, - messageId: "regexMessage", - data: { message } - }); - } - - /** - * Check if node is a string - * @param {ASTNode} node node to evaluate - * @returns {boolean} True if its a string - * @private - */ - function isString(node) { - return node && node.type === "Literal" && typeof node.value === "string"; - } - - /** - * Gets flags of a regular expression created by the given `RegExp()` or `new RegExp()` call - * Examples: - * new RegExp(".") // => "" - * new RegExp(".", "gu") // => "gu" - * new RegExp(".", flags) // => null - * @param {ASTNode} node `CallExpression` or `NewExpression` node - * @returns {string|null} flags if they can be determined, `null` otherwise - * @private - */ - function getFlags(node) { - if (node.arguments.length < 2) { - return ""; - } - - if (isString(node.arguments[1])) { - return node.arguments[1].value; - } - - return null; - } - - /** - * Check syntax error in a given pattern. - * @param {string} pattern The RegExp pattern to validate. - * @param {Object} flags The RegExp flags to validate. - * @param {boolean} [flags.unicode] The Unicode flag. - * @param {boolean} [flags.unicodeSets] The UnicodeSets flag. - * @returns {string|null} The syntax error. - */ - function validateRegExpPattern(pattern, flags) { - try { - validator.validatePattern(pattern, undefined1, undefined1, flags); - return null; - } catch (err) { - return err.message; - } - } - - /** - * Check syntax error in a given flags. - * @param {string|null} flags The RegExp flags to validate. - * @returns {string|null} The syntax error. - */ - function validateRegExpFlags(flags) { - if (!flags) { - return null; - } - try { - validator.validateFlags(flags); - } catch { - return `Invalid flags supplied to RegExp constructor '${flags}'`; - } - - /* - * `regexpp` checks the combination of `u` and `v` flags when parsing `Pattern` according to `ecma262`, - * but this rule may check only the flag when the pattern is unidentifiable, so check it here. - * https://tc39.es/ecma262/multipage/text-processing.html#sec-parsepattern - */ - if (flags.includes("u") && flags.includes("v")) { - return "Regex 'u' and 'v' flags cannot be used together"; - } - return null; - } - - return { - "CallExpression, NewExpression"(node) { - if (node.callee.type !== "Identifier" || node.callee.name !== "RegExp") { - return; - } - - let flags = getFlags(node); - - if (flags && allowedFlags) { - flags = flags.replace(allowedFlags, ""); - } - - let message = validateRegExpFlags(flags); - - if (message) { - report(node, message); - return; - } - - if (!isString(node.arguments[0])) { - return; - } - - const pattern = node.arguments[0].value; - - message = ( - - // If flags are unknown, report the regex only if its pattern is invalid both with and without the "u" flag - flags === null - ? ( - validateRegExpPattern(pattern, { unicode: true, unicodeSets: false }) && - validateRegExpPattern(pattern, { unicode: false, unicodeSets: true }) && - validateRegExpPattern(pattern, { unicode: false, unicodeSets: false }) - ) - : validateRegExpPattern(pattern, { unicode: flags.includes("u"), unicodeSets: flags.includes("v") }) - ); - - if (message) { - report(node, message); - } - } - }; - } -}; diff --git a/tools/eslint/node_modules/eslint/lib/rules/no-invalid-this.js b/tools/eslint/node_modules/eslint/lib/rules/no-invalid-this.js deleted file mode 100644 index 4ea228898525bf..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/rules/no-invalid-this.js +++ /dev/null @@ -1,150 +0,0 @@ -/** - * @fileoverview A rule to disallow `this` keywords in contexts where the value of `this` is `undefined`. - * @author Toru Nagashima - */ - -"use strict"; - -//------------------------------------------------------------------------------ -// Requirements -//------------------------------------------------------------------------------ - -const astUtils = require("./utils/ast-utils"); - -//------------------------------------------------------------------------------ -// Helpers -//------------------------------------------------------------------------------ - -/** - * Determines if the given code path is a code path with lexical `this` binding. - * That is, if `this` within the code path refers to `this` of surrounding code path. - * @param {CodePath} codePath Code path. - * @param {ASTNode} node Node that started the code path. - * @returns {boolean} `true` if it is a code path with lexical `this` binding. - */ -function isCodePathWithLexicalThis(codePath, node) { - return codePath.origin === "function" && node.type === "ArrowFunctionExpression"; -} - -//------------------------------------------------------------------------------ -// Rule Definition -//------------------------------------------------------------------------------ - -/** @type {import('../shared/types').Rule} */ -module.exports = { - meta: { - type: "suggestion", - - docs: { - description: "Disallow use of `this` in contexts where the value of `this` is `undefined`", - recommended: false, - url: "https://eslint.org/docs/latest/rules/no-invalid-this" - }, - - schema: [ - { - type: "object", - properties: { - capIsConstructor: { - type: "boolean", - default: true - } - }, - additionalProperties: false - } - ], - - messages: { - unexpectedThis: "Unexpected 'this'." - } - }, - - create(context) { - const options = context.options[0] || {}; - const capIsConstructor = options.capIsConstructor !== false; - const stack = [], - sourceCode = context.sourceCode; - - /** - * Gets the current checking context. - * - * The return value has a flag that whether or not `this` keyword is valid. - * The flag is initialized when got at the first time. - * @returns {{valid: boolean}} - * an object which has a flag that whether or not `this` keyword is valid. - */ - stack.getCurrent = function() { - const current = this.at(-1); - - if (!current.init) { - current.init = true; - current.valid = !astUtils.isDefaultThisBinding( - current.node, - sourceCode, - { capIsConstructor } - ); - } - return current; - }; - - return { - - onCodePathStart(codePath, node) { - if (isCodePathWithLexicalThis(codePath, node)) { - return; - } - - if (codePath.origin === "program") { - const scope = sourceCode.getScope(node); - const features = context.languageOptions.parserOptions.ecmaFeatures || {}; - - // `this` at the top level of scripts always refers to the global object - stack.push({ - init: true, - node, - valid: !( - node.sourceType === "module" || - (features.globalReturn && scope.childScopes[0].isStrict) - ) - }); - - return; - } - - /* - * `init: false` means that `valid` isn't determined yet. - * Most functions don't use `this`, and the calculation for `valid` - * is relatively costly, so we'll calculate it lazily when the first - * `this` within the function is traversed. A special case are non-strict - * functions, because `this` refers to the global object and therefore is - * always valid, so we can set `init: true` right away. - */ - stack.push({ - init: !sourceCode.getScope(node).isStrict, - node, - valid: true - }); - }, - - onCodePathEnd(codePath, node) { - if (isCodePathWithLexicalThis(codePath, node)) { - return; - } - - stack.pop(); - }, - - // Reports if `this` of the current context is invalid. - ThisExpression(node) { - const current = stack.getCurrent(); - - if (current && !current.valid) { - context.report({ - node, - messageId: "unexpectedThis" - }); - } - } - }; - } -}; diff --git a/tools/eslint/node_modules/eslint/lib/rules/no-irregular-whitespace.js b/tools/eslint/node_modules/eslint/lib/rules/no-irregular-whitespace.js deleted file mode 100644 index ab7ccac54e4cf6..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/rules/no-irregular-whitespace.js +++ /dev/null @@ -1,276 +0,0 @@ -/** - * @fileoverview Rule to disallow whitespace that is not a tab or space, whitespace inside strings and comments are allowed - * @author Jonathan Kingston - * @author Christophe Porteneuve - */ - -"use strict"; - -//------------------------------------------------------------------------------ -// Requirements -//------------------------------------------------------------------------------ - -const astUtils = require("./utils/ast-utils"); - -//------------------------------------------------------------------------------ -// Constants -//------------------------------------------------------------------------------ - -const ALL_IRREGULARS = /[\f\v\u0085\ufeff\u00a0\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u200b\u202f\u205f\u3000\u2028\u2029]/u; -const IRREGULAR_WHITESPACE = /[\f\v\u0085\ufeff\u00a0\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u200b\u202f\u205f\u3000]+/mgu; -const IRREGULAR_LINE_TERMINATORS = /[\u2028\u2029]/mgu; -const LINE_BREAK = astUtils.createGlobalLinebreakMatcher(); - -//------------------------------------------------------------------------------ -// Rule Definition -//------------------------------------------------------------------------------ - -/** @type {import('../shared/types').Rule} */ -module.exports = { - meta: { - type: "problem", - - docs: { - description: "Disallow irregular whitespace", - recommended: true, - url: "https://eslint.org/docs/latest/rules/no-irregular-whitespace" - }, - - schema: [ - { - type: "object", - properties: { - skipComments: { - type: "boolean", - default: false - }, - skipStrings: { - type: "boolean", - default: true - }, - skipTemplates: { - type: "boolean", - default: false - }, - skipRegExps: { - type: "boolean", - default: false - }, - skipJSXText: { - type: "boolean", - default: false - } - }, - additionalProperties: false - } - ], - - messages: { - noIrregularWhitespace: "Irregular whitespace not allowed." - } - }, - - create(context) { - - // Module store of errors that we have found - let errors = []; - - // Lookup the `skipComments` option, which defaults to `false`. - const options = context.options[0] || {}; - const skipComments = !!options.skipComments; - const skipStrings = options.skipStrings !== false; - const skipRegExps = !!options.skipRegExps; - const skipTemplates = !!options.skipTemplates; - const skipJSXText = !!options.skipJSXText; - - const sourceCode = context.sourceCode; - const commentNodes = sourceCode.getAllComments(); - - /** - * Removes errors that occur inside the given node - * @param {ASTNode} node to check for matching errors. - * @returns {void} - * @private - */ - function removeWhitespaceError(node) { - const locStart = node.loc.start; - const locEnd = node.loc.end; - - errors = errors.filter(({ loc: { start: errorLocStart } }) => ( - errorLocStart.line < locStart.line || - errorLocStart.line === locStart.line && errorLocStart.column < locStart.column || - errorLocStart.line === locEnd.line && errorLocStart.column >= locEnd.column || - errorLocStart.line > locEnd.line - )); - } - - /** - * Checks literal nodes for errors that we are choosing to ignore and calls the relevant methods to remove the errors - * @param {ASTNode} node to check for matching errors. - * @returns {void} - * @private - */ - function removeInvalidNodeErrorsInLiteral(node) { - const shouldCheckStrings = skipStrings && (typeof node.value === "string"); - const shouldCheckRegExps = skipRegExps && Boolean(node.regex); - - if (shouldCheckStrings || shouldCheckRegExps) { - - // If we have irregular characters remove them from the errors list - if (ALL_IRREGULARS.test(node.raw)) { - removeWhitespaceError(node); - } - } - } - - /** - * Checks template string literal nodes for errors that we are choosing to ignore and calls the relevant methods to remove the errors - * @param {ASTNode} node to check for matching errors. - * @returns {void} - * @private - */ - function removeInvalidNodeErrorsInTemplateLiteral(node) { - if (typeof node.value.raw === "string") { - if (ALL_IRREGULARS.test(node.value.raw)) { - removeWhitespaceError(node); - } - } - } - - /** - * Checks comment nodes for errors that we are choosing to ignore and calls the relevant methods to remove the errors - * @param {ASTNode} node to check for matching errors. - * @returns {void} - * @private - */ - function removeInvalidNodeErrorsInComment(node) { - if (ALL_IRREGULARS.test(node.value)) { - removeWhitespaceError(node); - } - } - - /** - * Checks JSX nodes for errors that we are choosing to ignore and calls the relevant methods to remove the errors - * @param {ASTNode} node to check for matching errors. - * @returns {void} - * @private - */ - function removeInvalidNodeErrorsInJSXText(node) { - if (ALL_IRREGULARS.test(node.raw)) { - removeWhitespaceError(node); - } - } - - /** - * Checks the program source for irregular whitespace - * @param {ASTNode} node The program node - * @returns {void} - * @private - */ - function checkForIrregularWhitespace(node) { - const sourceLines = sourceCode.lines; - - sourceLines.forEach((sourceLine, lineIndex) => { - const lineNumber = lineIndex + 1; - let match; - - while ((match = IRREGULAR_WHITESPACE.exec(sourceLine)) !== null) { - errors.push({ - node, - messageId: "noIrregularWhitespace", - loc: { - start: { - line: lineNumber, - column: match.index - }, - end: { - line: lineNumber, - column: match.index + match[0].length - } - } - }); - } - }); - } - - /** - * Checks the program source for irregular line terminators - * @param {ASTNode} node The program node - * @returns {void} - * @private - */ - function checkForIrregularLineTerminators(node) { - const source = sourceCode.getText(), - sourceLines = sourceCode.lines, - linebreaks = source.match(LINE_BREAK); - let lastLineIndex = -1, - match; - - while ((match = IRREGULAR_LINE_TERMINATORS.exec(source)) !== null) { - const lineIndex = linebreaks.indexOf(match[0], lastLineIndex + 1) || 0; - - errors.push({ - node, - messageId: "noIrregularWhitespace", - loc: { - start: { - line: lineIndex + 1, - column: sourceLines[lineIndex].length - }, - end: { - line: lineIndex + 2, - column: 0 - } - } - }); - - lastLineIndex = lineIndex; - } - } - - /** - * A no-op function to act as placeholder for comment accumulation when the `skipComments` option is `false`. - * @returns {void} - * @private - */ - function noop() {} - - const nodes = {}; - - if (ALL_IRREGULARS.test(sourceCode.getText())) { - nodes.Program = function(node) { - - /* - * As we can easily fire warnings for all white space issues with - * all the source its simpler to fire them here. - * This means we can check all the application code without having - * to worry about issues caused in the parser tokens. - * When writing this code also evaluating per node was missing out - * connecting tokens in some cases. - * We can later filter the errors when they are found to be not an - * issue in nodes we don't care about. - */ - checkForIrregularWhitespace(node); - checkForIrregularLineTerminators(node); - }; - - nodes.Literal = removeInvalidNodeErrorsInLiteral; - nodes.TemplateElement = skipTemplates ? removeInvalidNodeErrorsInTemplateLiteral : noop; - nodes.JSXText = skipJSXText ? removeInvalidNodeErrorsInJSXText : noop; - nodes["Program:exit"] = function() { - if (skipComments) { - - // First strip errors occurring in comment nodes. - commentNodes.forEach(removeInvalidNodeErrorsInComment); - } - - // If we have any errors remaining report on them - errors.forEach(error => context.report(error)); - }; - } else { - nodes.Program = noop; - } - - return nodes; - } -}; diff --git a/tools/eslint/node_modules/eslint/lib/rules/no-iterator.js b/tools/eslint/node_modules/eslint/lib/rules/no-iterator.js deleted file mode 100644 index dcd9683b455e24..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/rules/no-iterator.js +++ /dev/null @@ -1,52 +0,0 @@ -/** - * @fileoverview Rule to flag usage of __iterator__ property - * @author Ian Christian Myers - */ - -"use strict"; - -//------------------------------------------------------------------------------ -// Requirements -//------------------------------------------------------------------------------ - -const { getStaticPropertyName } = require("./utils/ast-utils"); - -//------------------------------------------------------------------------------ -// Rule Definition -//------------------------------------------------------------------------------ - -/** @type {import('../shared/types').Rule} */ -module.exports = { - meta: { - type: "suggestion", - - docs: { - description: "Disallow the use of the `__iterator__` property", - recommended: false, - url: "https://eslint.org/docs/latest/rules/no-iterator" - }, - - schema: [], - - messages: { - noIterator: "Reserved name '__iterator__'." - } - }, - - create(context) { - - return { - - MemberExpression(node) { - - if (getStaticPropertyName(node) === "__iterator__") { - context.report({ - node, - messageId: "noIterator" - }); - } - } - }; - - } -}; diff --git a/tools/eslint/node_modules/eslint/lib/rules/no-label-var.js b/tools/eslint/node_modules/eslint/lib/rules/no-label-var.js deleted file mode 100644 index bf33cd157bade1..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/rules/no-label-var.js +++ /dev/null @@ -1,80 +0,0 @@ -/** - * @fileoverview Rule to flag labels that are the same as an identifier - * @author Ian Christian Myers - */ - -"use strict"; - -//------------------------------------------------------------------------------ -// Requirements -//------------------------------------------------------------------------------ - -const astUtils = require("./utils/ast-utils"); - -//------------------------------------------------------------------------------ -// Rule Definition -//------------------------------------------------------------------------------ - -/** @type {import('../shared/types').Rule} */ -module.exports = { - meta: { - type: "suggestion", - - docs: { - description: "Disallow labels that share a name with a variable", - recommended: false, - url: "https://eslint.org/docs/latest/rules/no-label-var" - }, - - schema: [], - - messages: { - identifierClashWithLabel: "Found identifier with same name as label." - } - }, - - create(context) { - const sourceCode = context.sourceCode; - - //-------------------------------------------------------------------------- - // Helpers - //-------------------------------------------------------------------------- - - /** - * Check if the identifier is present inside current scope - * @param {Object} scope current scope - * @param {string} name To evaluate - * @returns {boolean} True if its present - * @private - */ - function findIdentifier(scope, name) { - return astUtils.getVariableByName(scope, name) !== null; - } - - //-------------------------------------------------------------------------- - // Public API - //-------------------------------------------------------------------------- - - return { - - LabeledStatement(node) { - - // Fetch the innermost scope. - const scope = sourceCode.getScope(node); - - /* - * Recursively find the identifier walking up the scope, starting - * with the innermost scope. - */ - if (findIdentifier(scope, node.label.name)) { - context.report({ - node, - messageId: "identifierClashWithLabel" - }); - } - } - - }; - - } -}; diff --git a/tools/eslint/node_modules/eslint/lib/rules/no-labels.js b/tools/eslint/node_modules/eslint/lib/rules/no-labels.js deleted file mode 100644 index d991a0a8062b19..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/rules/no-labels.js +++ /dev/null @@ -1,149 +0,0 @@ -/** - * @fileoverview Disallow Labeled Statements - * @author Nicholas C. Zakas - */ -"use strict"; - -//------------------------------------------------------------------------------ -// Requirements -//------------------------------------------------------------------------------ - -const astUtils = require("./utils/ast-utils"); - -//------------------------------------------------------------------------------ -// Rule Definition -//------------------------------------------------------------------------------ - -/** @type {import('../shared/types').Rule} */ -module.exports = { - meta: { - type: "suggestion", - - docs: { - description: "Disallow labeled statements", - recommended: false, - url: "https://eslint.org/docs/latest/rules/no-labels" - }, - - schema: [ - { - type: "object", - properties: { - allowLoop: { - type: "boolean", - default: false - }, - allowSwitch: { - type: "boolean", - default: false - } - }, - additionalProperties: false - } - ], - - messages: { - unexpectedLabel: "Unexpected labeled statement.", - unexpectedLabelInBreak: "Unexpected label in break statement.", - unexpectedLabelInContinue: "Unexpected label in continue statement." - } - }, - - create(context) { - const options = context.options[0]; - const allowLoop = options && options.allowLoop; - const allowSwitch = options && options.allowSwitch; - let scopeInfo = null; - - /** - * Gets the kind of a given node. - * @param {ASTNode} node A node to get. - * @returns {string} The kind of the node. - */ - function getBodyKind(node) { - if (astUtils.isLoop(node)) { - return "loop"; - } - if (node.type === "SwitchStatement") { - return "switch"; - } - return "other"; - } - - /** - * Checks whether the label of a given kind is allowed or not. - * @param {string} kind A kind to check. - * @returns {boolean} `true` if the kind is allowed. - */ - function isAllowed(kind) { - switch (kind) { - case "loop": return allowLoop; - case "switch": return allowSwitch; - default: return false; - } - } - - /** - * Checks whether a given name is a label of a loop or not. - * @param {string} label A name of a label to check. - * @returns {boolean} `true` if the name is a label of a loop. - */ - function getKind(label) { - let info = scopeInfo; - - while (info) { - if (info.label === label) { - return info.kind; - } - info = info.upper; - } - - /* c8 ignore next */ - return "other"; - } - - //-------------------------------------------------------------------------- - // Public - //-------------------------------------------------------------------------- - - return { - LabeledStatement(node) { - scopeInfo = { - label: node.label.name, - kind: getBodyKind(node.body), - upper: scopeInfo - }; - }, - - "LabeledStatement:exit"(node) { - if (!isAllowed(scopeInfo.kind)) { - context.report({ - node, - messageId: "unexpectedLabel" - }); - } - - scopeInfo = scopeInfo.upper; - }, - - BreakStatement(node) { - if (node.label && !isAllowed(getKind(node.label.name))) { - context.report({ - node, - messageId: "unexpectedLabelInBreak" - }); - } - }, - - ContinueStatement(node) { - if (node.label && !isAllowed(getKind(node.label.name))) { - context.report({ - node, - messageId: "unexpectedLabelInContinue" - }); - } - } - }; - - } -}; diff --git a/tools/eslint/node_modules/eslint/lib/rules/no-lone-blocks.js b/tools/eslint/node_modules/eslint/lib/rules/no-lone-blocks.js deleted file mode 100644 index 2e27089269be24..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/rules/no-lone-blocks.js +++ /dev/null @@ -1,136 +0,0 @@ -/** - * @fileoverview Rule to flag blocks with no reason to exist - * @author Brandon Mills - */ - -"use strict"; - -//------------------------------------------------------------------------------ -// Rule Definition -//------------------------------------------------------------------------------ - -/** @type {import('../shared/types').Rule} */ -module.exports = { - meta: { - type: "suggestion", - - docs: { - description: "Disallow unnecessary nested blocks", - recommended: false, - url: "https://eslint.org/docs/latest/rules/no-lone-blocks" - }, - - schema: [], - - messages: { - redundantBlock: "Block is redundant.", - redundantNestedBlock: "Nested block is redundant." - } - }, - - create(context) { - - // A stack of lone blocks to be checked for block-level bindings - const loneBlocks = []; - let ruleDef; - const sourceCode = context.sourceCode; - - /** - * Reports a node as invalid. - * @param {ASTNode} node The node to be reported. - * @returns {void} - */ - function report(node) { - const messageId = node.parent.type === "BlockStatement" || node.parent.type === "StaticBlock" - ? "redundantNestedBlock" - : "redundantBlock"; - - context.report({ - node, - messageId - }); - } - - /** - * Checks for any occurrence of a BlockStatement in a place where lists of statements can appear - * @param {ASTNode} node The node to check - * @returns {boolean} True if the node is a lone block. - */ - function isLoneBlock(node) { - return node.parent.type === "BlockStatement" || - node.parent.type === "StaticBlock" || - node.parent.type === "Program" || - - // Don't report blocks in switch cases if the block is the only statement of the case. - node.parent.type === "SwitchCase" && !(node.parent.consequent[0] === node && node.parent.consequent.length === 1); - } - - /** - * Checks the enclosing block of the current node for block-level bindings, - * and "marks it" as valid if any. - * @param {ASTNode} node The current node to check. - * @returns {void} - */ - function markLoneBlock(node) { - if (loneBlocks.length === 0) { - return; - } - - const block = node.parent; - - if (loneBlocks.at(-1) === block) { - loneBlocks.pop(); - } - } - - // Default rule definition: report all lone blocks - ruleDef = { - BlockStatement(node) { - if (isLoneBlock(node)) { - report(node); - } - } - }; - - // ES6: report blocks without block-level bindings, or that's only child of another block - if (context.languageOptions.ecmaVersion >= 2015) { - ruleDef = { - BlockStatement(node) { - if (isLoneBlock(node)) { - loneBlocks.push(node); - } - }, - "BlockStatement:exit"(node) { - if (loneBlocks.length > 0 && loneBlocks.at(-1) === node) { - loneBlocks.pop(); - report(node); - } else if ( - ( - node.parent.type === "BlockStatement" || - node.parent.type === "StaticBlock" - ) && - node.parent.body.length === 1 - ) { - report(node); - } - } - }; - - ruleDef.VariableDeclaration = function(node) { - if (node.kind !== "var") { - markLoneBlock(node); - } - }; - - ruleDef.FunctionDeclaration = function(node) { - if (sourceCode.getScope(node).isStrict) { - markLoneBlock(node); - } - }; - - ruleDef.ClassDeclaration = markLoneBlock; - } - - return ruleDef; - } -}; diff --git a/tools/eslint/node_modules/eslint/lib/rules/no-lonely-if.js b/tools/eslint/node_modules/eslint/lib/rules/no-lonely-if.js deleted file mode 100644 index eefd2c688e9567..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/rules/no-lonely-if.js +++ /dev/null @@ -1,88 +0,0 @@ -/** - * @fileoverview Rule to disallow if as the only statement in an else block - * @author Brandon Mills - */ -"use strict"; - -//------------------------------------------------------------------------------ -// Rule Definition -//------------------------------------------------------------------------------ - -/** @type {import('../shared/types').Rule} */ -module.exports = { - meta: { - type: "suggestion", - - docs: { - description: "Disallow `if` statements as the only statement in `else` blocks", - recommended: false, - url: "https://eslint.org/docs/latest/rules/no-lonely-if" - }, - - schema: [], - fixable: "code", - - messages: { - unexpectedLonelyIf: "Unexpected if as the only statement in an else block." - } - }, - - create(context) { - const sourceCode = context.sourceCode; - - return { - IfStatement(node) { - const parent = node.parent, - grandparent = parent.parent; - - if (parent && parent.type === "BlockStatement" && - parent.body.length === 1 && grandparent && - grandparent.type === "IfStatement" && - parent === grandparent.alternate) { - context.report({ - node, - messageId: "unexpectedLonelyIf", - fix(fixer) { - const openingElseCurly = sourceCode.getFirstToken(parent); - const closingElseCurly = sourceCode.getLastToken(parent); - const elseKeyword = sourceCode.getTokenBefore(openingElseCurly); - const tokenAfterElseBlock = sourceCode.getTokenAfter(closingElseCurly); - const lastIfToken = sourceCode.getLastToken(node.consequent); - const sourceText = sourceCode.getText(); - - if (sourceText.slice(openingElseCurly.range[1], - node.range[0]).trim() || sourceText.slice(node.range[1], closingElseCurly.range[0]).trim()) { - - // Don't fix if there are any non-whitespace characters interfering (e.g. comments) - return null; - } - - if ( - node.consequent.type !== "BlockStatement" && lastIfToken.value !== ";" && tokenAfterElseBlock && - ( - node.consequent.loc.end.line === tokenAfterElseBlock.loc.start.line || - /^[([/+`-]/u.test(tokenAfterElseBlock.value) || - lastIfToken.value === "++" || - lastIfToken.value === "--" - ) - ) { - - /* - * If the `if` statement has no block, and is not followed by a semicolon, make sure that fixing - * the issue would not change semantics due to ASI. If this would happen, don't do a fix. - */ - return null; - } - - return fixer.replaceTextRange( - [openingElseCurly.range[0], closingElseCurly.range[1]], - (elseKeyword.range[1] === openingElseCurly.range[0] ? " " : "") + sourceCode.getText(node) - ); - } - }); - } - } - }; - - } -}; diff --git a/tools/eslint/node_modules/eslint/lib/rules/no-loop-func.js b/tools/eslint/node_modules/eslint/lib/rules/no-loop-func.js deleted file mode 100644 index ba372dbb5a8053..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/rules/no-loop-func.js +++ /dev/null @@ -1,238 +0,0 @@ -/** - * @fileoverview Rule to flag creation of function inside a loop - * @author Ilya Volodin - */ - -"use strict"; - -//------------------------------------------------------------------------------ -// Helpers -//------------------------------------------------------------------------------ - - -/** - * Identifies is a node is a FunctionExpression which is part of an IIFE - * @param {ASTNode} node Node to test - * @returns {boolean} True if it's an IIFE - */ -function isIIFE(node) { - return (node.type === "FunctionExpression" || node.type === "ArrowFunctionExpression") && node.parent && node.parent.type === "CallExpression" && node.parent.callee === node; -} - - -//------------------------------------------------------------------------------ -// Rule Definition -//------------------------------------------------------------------------------ - -/** @type {import('../shared/types').Rule} */ -module.exports = { - meta: { - type: "suggestion", - - docs: { - description: "Disallow function declarations that contain unsafe references inside loop statements", - recommended: false, - url: "https://eslint.org/docs/latest/rules/no-loop-func" - }, - - schema: [], - - messages: { - unsafeRefs: "Function declared in a loop contains unsafe references to variable(s) {{ varNames }}." - } - }, - - create(context) { - - const SKIPPED_IIFE_NODES = new Set(); - const sourceCode = context.sourceCode; - - /** - * Gets the containing loop node of a specified node. - * - * We don't need to check nested functions, so this ignores those, with the exception of IIFE. - * `Scope.through` contains references of nested functions. - * @param {ASTNode} node An AST node to get. - * @returns {ASTNode|null} The containing loop node of the specified node, or - * `null`. - */ - function getContainingLoopNode(node) { - for (let currentNode = node; currentNode.parent; currentNode = currentNode.parent) { - const parent = currentNode.parent; - - switch (parent.type) { - case "WhileStatement": - case "DoWhileStatement": - return parent; - - case "ForStatement": - - // `init` is outside of the loop. - if (parent.init !== currentNode) { - return parent; - } - break; - - case "ForInStatement": - case "ForOfStatement": - - // `right` is outside of the loop. - if (parent.right !== currentNode) { - return parent; - } - break; - - case "ArrowFunctionExpression": - case "FunctionExpression": - case "FunctionDeclaration": - - // We need to check nested functions only in case of IIFE. - if (SKIPPED_IIFE_NODES.has(parent)) { - break; - } - - return null; - default: - break; - } - } - - return null; - } - - /** - * Gets the containing loop node of a given node. - * If the loop was nested, this returns the most outer loop. - * @param {ASTNode} node A node to get. This is a loop node. - * @param {ASTNode|null} excludedNode A node that the result node should not - * include. - * @returns {ASTNode} The most outer loop node. - */ - function getTopLoopNode(node, excludedNode) { - const border = excludedNode ? excludedNode.range[1] : 0; - let retv = node; - let containingLoopNode = node; - - while (containingLoopNode && containingLoopNode.range[0] >= border) { - retv = containingLoopNode; - containingLoopNode = getContainingLoopNode(containingLoopNode); - } - - return retv; - } - - /** - * Checks whether a given reference which refers to an upper scope's variable is - * safe or not. - * @param {ASTNode} loopNode A containing loop node. - * @param {eslint-scope.Reference} reference A reference to check. - * @returns {boolean} `true` if the reference is safe or not. - */ - function isSafe(loopNode, reference) { - const variable = reference.resolved; - const definition = variable && variable.defs[0]; - const declaration = definition && definition.parent; - const kind = (declaration && declaration.type === "VariableDeclaration") - ? declaration.kind - : ""; - - // Variables which are declared by `const` is safe. - if (kind === "const") { - return true; - } - - /* - * Variables which are declared by `let` in the loop is safe. - * It's a different instance from the next loop step's. - */ - if (kind === "let" && - declaration.range[0] > loopNode.range[0] && - declaration.range[1] < loopNode.range[1] - ) { - return true; - } - - /* - * WriteReferences which exist after this border are unsafe because those - * can modify the variable. - */ - const border = getTopLoopNode( - loopNode, - (kind === "let") ? declaration : null - ).range[0]; - - /** - * Checks whether a given reference is safe or not. - * The reference is every reference of the upper scope's variable we are - * looking now. - * - * It's safe if the reference matches one of the following condition. - * - is readonly. - * - doesn't exist inside a local function and after the border. - * @param {eslint-scope.Reference} upperRef A reference to check. - * @returns {boolean} `true` if the reference is safe. - */ - function isSafeReference(upperRef) { - const id = upperRef.identifier; - - return ( - !upperRef.isWrite() || - variable.scope.variableScope === upperRef.from.variableScope && - id.range[0] < border - ); - } - - return Boolean(variable) && variable.references.every(isSafeReference); - } - - /** - * Reports functions which match the following condition: - * - * - has a loop node in ancestors. - * - has any references which refers to an unsafe variable. - * @param {ASTNode} node The AST node to check. - * @returns {void} - */ - function checkForLoops(node) { - const loopNode = getContainingLoopNode(node); - - if (!loopNode) { - return; - } - - const references = sourceCode.getScope(node).through; - - // Check if the function is not asynchronous or a generator function - if (!(node.async || node.generator)) { - if (isIIFE(node)) { - - const isFunctionExpression = node.type === "FunctionExpression"; - - // Check if the function is referenced elsewhere in the code - const isFunctionReferenced = isFunctionExpression && node.id ? references.some(r => r.identifier.name === node.id.name) : false; - - if (!isFunctionReferenced) { - SKIPPED_IIFE_NODES.add(node); - return; - } - } - } - - const unsafeRefs = references.filter(r => r.resolved && !isSafe(loopNode, r)).map(r => r.identifier.name); - - if (unsafeRefs.length > 0) { - context.report({ - node, - messageId: "unsafeRefs", - data: { varNames: `'${unsafeRefs.join("', '")}'` } - }); - } - } - - return { - ArrowFunctionExpression: checkForLoops, - FunctionExpression: checkForLoops, - FunctionDeclaration: checkForLoops - }; - } -}; diff --git a/tools/eslint/node_modules/eslint/lib/rules/no-loss-of-precision.js b/tools/eslint/node_modules/eslint/lib/rules/no-loss-of-precision.js deleted file mode 100644 index c50d8a890555b3..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/rules/no-loss-of-precision.js +++ /dev/null @@ -1,214 +0,0 @@ -/** - * @fileoverview Rule to flag numbers that will lose significant figure precision at runtime - * @author Jacob Moore - */ - -"use strict"; - -//------------------------------------------------------------------------------ -// Rule Definition -//------------------------------------------------------------------------------ - -/** @type {import('../shared/types').Rule} */ -module.exports = { - meta: { - type: "problem", - - docs: { - description: "Disallow literal numbers that lose precision", - recommended: true, - url: "https://eslint.org/docs/latest/rules/no-loss-of-precision" - }, - schema: [], - messages: { - noLossOfPrecision: "This number literal will lose precision at runtime." - } - }, - - create(context) { - - /** - * Returns whether the node is number literal - * @param {Node} node the node literal being evaluated - * @returns {boolean} true if the node is a number literal - */ - function isNumber(node) { - return typeof node.value === "number"; - } - - /** - * Gets the source code of the given number literal. Removes `_` numeric separators from the result. - * @param {Node} node the number `Literal` node - * @returns {string} raw source code of the literal, without numeric separators - */ - function getRaw(node) { - return node.raw.replace(/_/gu, ""); - } - - /** - * Checks whether the number is base ten - * @param {ASTNode} node the node being evaluated - * @returns {boolean} true if the node is in base ten - */ - function isBaseTen(node) { - const prefixes = ["0x", "0X", "0b", "0B", "0o", "0O"]; - - return prefixes.every(prefix => !node.raw.startsWith(prefix)) && - !/^0[0-7]+$/u.test(node.raw); - } - - /** - * Checks that the user-intended non-base ten number equals the actual number after is has been converted to the Number type - * @param {Node} node the node being evaluated - * @returns {boolean} true if they do not match - */ - function notBaseTenLosesPrecision(node) { - const rawString = getRaw(node).toUpperCase(); - let base; - - if (rawString.startsWith("0B")) { - base = 2; - } else if (rawString.startsWith("0X")) { - base = 16; - } else { - base = 8; - } - - return !rawString.endsWith(node.value.toString(base).toUpperCase()); - } - - /** - * Adds a decimal point to the numeric string at index 1 - * @param {string} stringNumber the numeric string without any decimal point - * @returns {string} the numeric string with a decimal point in the proper place - */ - function addDecimalPointToNumber(stringNumber) { - return `${stringNumber[0]}.${stringNumber.slice(1)}`; - } - - /** - * Returns the number stripped of leading zeros - * @param {string} numberAsString the string representation of the number - * @returns {string} the stripped string - */ - function removeLeadingZeros(numberAsString) { - for (let i = 0; i < numberAsString.length; i++) { - if (numberAsString[i] !== "0") { - return numberAsString.slice(i); - } - } - return numberAsString; - } - - /** - * Returns the number stripped of trailing zeros - * @param {string} numberAsString the string representation of the number - * @returns {string} the stripped string - */ - function removeTrailingZeros(numberAsString) { - for (let i = numberAsString.length - 1; i >= 0; i--) { - if (numberAsString[i] !== "0") { - return numberAsString.slice(0, i + 1); - } - } - return numberAsString; - } - - /** - * Converts an integer to an object containing the integer's coefficient and order of magnitude - * @param {string} stringInteger the string representation of the integer being converted - * @returns {Object} the object containing the integer's coefficient and order of magnitude - */ - function normalizeInteger(stringInteger) { - const significantDigits = removeTrailingZeros(removeLeadingZeros(stringInteger)); - - return { - magnitude: stringInteger.startsWith("0") ? stringInteger.length - 2 : stringInteger.length - 1, - coefficient: addDecimalPointToNumber(significantDigits) - }; - } - - /** - * - * Converts a float to an object containing the floats's coefficient and order of magnitude - * @param {string} stringFloat the string representation of the float being converted - * @returns {Object} the object containing the integer's coefficient and order of magnitude - */ - function normalizeFloat(stringFloat) { - const trimmedFloat = removeLeadingZeros(stringFloat); - - if (trimmedFloat.startsWith(".")) { - const decimalDigits = trimmedFloat.slice(1); - const significantDigits = removeLeadingZeros(decimalDigits); - - return { - magnitude: significantDigits.length - decimalDigits.length - 1, - coefficient: addDecimalPointToNumber(significantDigits) - }; - - } - return { - magnitude: trimmedFloat.indexOf(".") - 1, - coefficient: addDecimalPointToNumber(trimmedFloat.replace(".", "")) - - }; - } - - /** - * Converts a base ten number to proper scientific notation - * @param {string} stringNumber the string representation of the base ten number to be converted - * @returns {string} the number converted to scientific notation - */ - function convertNumberToScientificNotation(stringNumber) { - const splitNumber = stringNumber.replace("E", "e").split("e"); - const originalCoefficient = splitNumber[0]; - const normalizedNumber = stringNumber.includes(".") ? normalizeFloat(originalCoefficient) - : normalizeInteger(originalCoefficient); - const normalizedCoefficient = normalizedNumber.coefficient; - const magnitude = splitNumber.length > 1 ? (parseInt(splitNumber[1], 10) + normalizedNumber.magnitude) - : normalizedNumber.magnitude; - - return `${normalizedCoefficient}e${magnitude}`; - } - - /** - * Checks that the user-intended base ten number equals the actual number after is has been converted to the Number type - * @param {Node} node the node being evaluated - * @returns {boolean} true if they do not match - */ - function baseTenLosesPrecision(node) { - const normalizedRawNumber = convertNumberToScientificNotation(getRaw(node)); - const requestedPrecision = normalizedRawNumber.split("e")[0].replace(".", "").length; - - if (requestedPrecision > 100) { - return true; - } - const storedNumber = node.value.toPrecision(requestedPrecision); - const normalizedStoredNumber = convertNumberToScientificNotation(storedNumber); - - return normalizedRawNumber !== normalizedStoredNumber; - } - - - /** - * Checks that the user-intended number equals the actual number after is has been converted to the Number type - * @param {Node} node the node being evaluated - * @returns {boolean} true if they do not match - */ - function losesPrecision(node) { - return isBaseTen(node) ? baseTenLosesPrecision(node) : notBaseTenLosesPrecision(node); - } - - - return { - Literal(node) { - if (node.value && isNumber(node) && losesPrecision(node)) { - context.report({ - messageId: "noLossOfPrecision", - node - }); - } - } - }; - } -}; diff --git a/tools/eslint/node_modules/eslint/lib/rules/no-magic-numbers.js b/tools/eslint/node_modules/eslint/lib/rules/no-magic-numbers.js deleted file mode 100644 index f48a62d85cd433..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/rules/no-magic-numbers.js +++ /dev/null @@ -1,243 +0,0 @@ -/** - * @fileoverview Rule to flag statements that use magic numbers (adapted from https://github.com/danielstjules/buddy.js) - * @author Vincent Lemeunier - */ - -"use strict"; - -const astUtils = require("./utils/ast-utils"); - -// Maximum array length by the ECMAScript Specification. -const MAX_ARRAY_LENGTH = 2 ** 32 - 1; - -//------------------------------------------------------------------------------ -// Rule Definition -//------------------------------------------------------------------------------ - -/** - * Convert the value to bigint if it's a string. Otherwise return the value as-is. - * @param {bigint|number|string} x The value to normalize. - * @returns {bigint|number} The normalized value. - */ -function normalizeIgnoreValue(x) { - if (typeof x === "string") { - return BigInt(x.slice(0, -1)); - } - return x; -} - -/** @type {import('../shared/types').Rule} */ -module.exports = { - meta: { - type: "suggestion", - - docs: { - description: "Disallow magic numbers", - recommended: false, - url: "https://eslint.org/docs/latest/rules/no-magic-numbers" - }, - - schema: [{ - type: "object", - properties: { - detectObjects: { - type: "boolean", - default: false - }, - enforceConst: { - type: "boolean", - default: false - }, - ignore: { - type: "array", - items: { - anyOf: [ - { type: "number" }, - { type: "string", pattern: "^[+-]?(?:0|[1-9][0-9]*)n$" } - ] - }, - uniqueItems: true - }, - ignoreArrayIndexes: { - type: "boolean", - default: false - }, - ignoreDefaultValues: { - type: "boolean", - default: false - }, - ignoreClassFieldInitialValues: { - type: "boolean", - default: false - } - }, - additionalProperties: false - }], - - messages: { - useConst: "Number constants declarations must use 'const'.", - noMagic: "No magic number: {{raw}}." - } - }, - - create(context) { - const config = context.options[0] || {}, - detectObjects = !!config.detectObjects, - enforceConst = !!config.enforceConst, - ignore = new Set((config.ignore || []).map(normalizeIgnoreValue)), - ignoreArrayIndexes = !!config.ignoreArrayIndexes, - ignoreDefaultValues = !!config.ignoreDefaultValues, - ignoreClassFieldInitialValues = !!config.ignoreClassFieldInitialValues; - - const okTypes = detectObjects ? [] : ["ObjectExpression", "Property", "AssignmentExpression"]; - - /** - * Returns whether the rule is configured to ignore the given value - * @param {bigint|number} value The value to check - * @returns {boolean} true if the value is ignored - */ - function isIgnoredValue(value) { - return ignore.has(value); - } - - /** - * Returns whether the number is a default value assignment. - * @param {ASTNode} fullNumberNode `Literal` or `UnaryExpression` full number node - * @returns {boolean} true if the number is a default value - */ - function isDefaultValue(fullNumberNode) { - const parent = fullNumberNode.parent; - - return parent.type === "AssignmentPattern" && parent.right === fullNumberNode; - } - - /** - * Returns whether the number is the initial value of a class field. - * @param {ASTNode} fullNumberNode `Literal` or `UnaryExpression` full number node - * @returns {boolean} true if the number is the initial value of a class field. - */ - function isClassFieldInitialValue(fullNumberNode) { - const parent = fullNumberNode.parent; - - return parent.type === "PropertyDefinition" && parent.value === fullNumberNode; - } - - /** - * Returns whether the given node is used as a radix within parseInt() or Number.parseInt() - * @param {ASTNode} fullNumberNode `Literal` or `UnaryExpression` full number node - * @returns {boolean} true if the node is radix - */ - function isParseIntRadix(fullNumberNode) { - const parent = fullNumberNode.parent; - - return parent.type === "CallExpression" && fullNumberNode === parent.arguments[1] && - ( - astUtils.isSpecificId(parent.callee, "parseInt") || - astUtils.isSpecificMemberAccess(parent.callee, "Number", "parseInt") - ); - } - - /** - * Returns whether the given node is a direct child of a JSX node. - * In particular, it aims to detect numbers used as prop values in JSX tags. - * Example: - * @param {ASTNode} fullNumberNode `Literal` or `UnaryExpression` full number node - * @returns {boolean} true if the node is a JSX number - */ - function isJSXNumber(fullNumberNode) { - return fullNumberNode.parent.type.indexOf("JSX") === 0; - } - - /** - * Returns whether the given node is used as an array index. - * Value must coerce to a valid array index name: "0", "1", "2" ... "4294967294". - * - * All other values, like "-1", "2.5", or "4294967295", are just "normal" object properties, - * which can be created and accessed on an array in addition to the array index properties, - * but they don't affect array's length and are not considered by methods such as .map(), .forEach() etc. - * - * The maximum array length by the specification is 2 ** 32 - 1 = 4294967295, - * thus the maximum valid index is 2 ** 32 - 2 = 4294967294. - * - * All notations are allowed, as long as the value coerces to one of "0", "1", "2" ... "4294967294". - * - * Valid examples: - * a[0], a[1], a[1.2e1], a[0xAB], a[0n], a[1n] - * a[-0] (same as a[0] because -0 coerces to "0") - * a[-0n] (-0n evaluates to 0n) - * - * Invalid examples: - * a[-1], a[-0xAB], a[-1n], a[2.5], a[1.23e1], a[12e-1] - * a[4294967295] (above the max index, it's an access to a regular property a["4294967295"]) - * a[999999999999999999999] (even if it wasn't above the max index, it would be a["1e+21"]) - * a[1e310] (same as a["Infinity"]) - * @param {ASTNode} fullNumberNode `Literal` or `UnaryExpression` full number node - * @param {bigint|number} value Value expressed by the fullNumberNode - * @returns {boolean} true if the node is a valid array index - */ - function isArrayIndex(fullNumberNode, value) { - const parent = fullNumberNode.parent; - - return parent.type === "MemberExpression" && parent.property === fullNumberNode && - (Number.isInteger(value) || typeof value === "bigint") && - value >= 0 && value < MAX_ARRAY_LENGTH; - } - - return { - Literal(node) { - if (!astUtils.isNumericLiteral(node)) { - return; - } - - let fullNumberNode; - let value; - let raw; - - // Treat unary minus as a part of the number - if (node.parent.type === "UnaryExpression" && node.parent.operator === "-") { - fullNumberNode = node.parent; - value = -node.value; - raw = `-${node.raw}`; - } else { - fullNumberNode = node; - value = node.value; - raw = node.raw; - } - - const parent = fullNumberNode.parent; - - // Always allow radix arguments and JSX props - if ( - isIgnoredValue(value) || - (ignoreDefaultValues && isDefaultValue(fullNumberNode)) || - (ignoreClassFieldInitialValues && isClassFieldInitialValue(fullNumberNode)) || - isParseIntRadix(fullNumberNode) || - isJSXNumber(fullNumberNode) || - (ignoreArrayIndexes && isArrayIndex(fullNumberNode, value)) - ) { - return; - } - - if (parent.type === "VariableDeclarator") { - if (enforceConst && parent.parent.kind !== "const") { - context.report({ - node: fullNumberNode, - messageId: "useConst" - }); - } - } else if ( - !okTypes.includes(parent.type) || - (parent.type === "AssignmentExpression" && parent.left.type === "Identifier") - ) { - context.report({ - node: fullNumberNode, - messageId: "noMagic", - data: { - raw - } - }); - } - } - }; - } -}; diff --git a/tools/eslint/node_modules/eslint/lib/rules/no-misleading-character-class.js b/tools/eslint/node_modules/eslint/lib/rules/no-misleading-character-class.js deleted file mode 100644 index d10e0812a83a72..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/rules/no-misleading-character-class.js +++ /dev/null @@ -1,537 +0,0 @@ -/** - * @author Toru Nagashima - */ -"use strict"; - -const { - CALL, - CONSTRUCT, - ReferenceTracker, - getStaticValue, - getStringIfConstant -} = require("@eslint-community/eslint-utils"); -const { RegExpParser, visitRegExpAST } = require("@eslint-community/regexpp"); -const { isCombiningCharacter, isEmojiModifier, isRegionalIndicatorSymbol, isSurrogatePair } = require("./utils/unicode"); -const astUtils = require("./utils/ast-utils.js"); -const { isValidWithUnicodeFlag } = require("./utils/regular-expressions"); -const { parseStringLiteral, parseTemplateToken } = require("./utils/char-source"); - -//------------------------------------------------------------------------------ -// Helpers -//------------------------------------------------------------------------------ - -/** - * @typedef {import('@eslint-community/regexpp').AST.Character} Character - * @typedef {import('@eslint-community/regexpp').AST.CharacterClassElement} CharacterClassElement - */ - -/** - * Iterate character sequences of a given nodes. - * - * CharacterClassRange syntax can steal a part of character sequence, - * so this function reverts CharacterClassRange syntax and restore the sequence. - * @param {CharacterClassElement[]} nodes The node list to iterate character sequences. - * @returns {IterableIterator} The list of character sequences. - */ -function *iterateCharacterSequence(nodes) { - - /** @type {Character[]} */ - let seq = []; - - for (const node of nodes) { - switch (node.type) { - case "Character": - seq.push(node); - break; - - case "CharacterClassRange": - seq.push(node.min); - yield seq; - seq = [node.max]; - break; - - case "CharacterSet": - case "CharacterClass": // [[]] nesting character class - case "ClassStringDisjunction": // \q{...} - case "ExpressionCharacterClass": // [A--B] - if (seq.length > 0) { - yield seq; - seq = []; - } - break; - - // no default - } - } - - if (seq.length > 0) { - yield seq; - } -} - -/** - * Checks whether the given character node is a Unicode code point escape or not. - * @param {Character} char the character node to check. - * @returns {boolean} `true` if the character node is a Unicode code point escape. - */ -function isUnicodeCodePointEscape(char) { - return /^\\u\{[\da-f]+\}$/iu.test(char.raw); -} - -/** - * Each function returns matched characters if it detects that kind of problem. - * @type {Record IterableIterator>} - */ -const findCharacterSequences = { - *surrogatePairWithoutUFlag(chars) { - for (const [index, char] of chars.entries()) { - const previous = chars[index - 1]; - - if ( - previous && char && - isSurrogatePair(previous.value, char.value) && - !isUnicodeCodePointEscape(previous) && - !isUnicodeCodePointEscape(char) - ) { - yield [previous, char]; - } - } - }, - - *surrogatePair(chars) { - for (const [index, char] of chars.entries()) { - const previous = chars[index - 1]; - - if ( - previous && char && - isSurrogatePair(previous.value, char.value) && - ( - isUnicodeCodePointEscape(previous) || - isUnicodeCodePointEscape(char) - ) - ) { - yield [previous, char]; - } - } - }, - - *combiningClass(chars, unfilteredChars) { - - /* - * When `allowEscape` is `true`, a combined character should only be allowed if the combining mark appears as an escape sequence. - * This means that the base character should be considered even if it's escaped. - */ - for (const [index, char] of chars.entries()) { - const previous = unfilteredChars[index - 1]; - - if ( - previous && char && - isCombiningCharacter(char.value) && - !isCombiningCharacter(previous.value) - ) { - yield [previous, char]; - } - } - }, - - *emojiModifier(chars) { - for (const [index, char] of chars.entries()) { - const previous = chars[index - 1]; - - if ( - previous && char && - isEmojiModifier(char.value) && - !isEmojiModifier(previous.value) - ) { - yield [previous, char]; - } - } - }, - - *regionalIndicatorSymbol(chars) { - for (const [index, char] of chars.entries()) { - const previous = chars[index - 1]; - - if ( - previous && char && - isRegionalIndicatorSymbol(char.value) && - isRegionalIndicatorSymbol(previous.value) - ) { - yield [previous, char]; - } - } - }, - - *zwj(chars) { - let sequence = null; - - for (const [index, char] of chars.entries()) { - const previous = chars[index - 1]; - const next = chars[index + 1]; - - if ( - previous && char && next && - char.value === 0x200d && - previous.value !== 0x200d && - next.value !== 0x200d - ) { - if (sequence) { - if (sequence.at(-1) === previous) { - sequence.push(char, next); // append to the sequence - } else { - yield sequence; - sequence = chars.slice(index - 1, index + 2); - } - } else { - sequence = chars.slice(index - 1, index + 2); - } - } - } - - if (sequence) { - yield sequence; - } - } -}; - -const kinds = Object.keys(findCharacterSequences); - -/** - * Gets the value of the given node if it's a static value other than a regular expression object, - * or the node's `regex` property. - * The purpose of this method is to provide a replacement for `getStaticValue` in environments where certain regular expressions cannot be evaluated. - * A known example is Node.js 18 which does not support the `v` flag. - * Calling `getStaticValue` on a regular expression node with the `v` flag on Node.js 18 always returns `null`. - * A limitation of this method is that it can only detect a regular expression if the specified node is itself a regular expression literal node. - * @param {ASTNode | undefined} node The node to be inspected. - * @param {Scope} initialScope Scope to start finding variables. This function tries to resolve identifier references which are in the given scope. - * @returns {{ value: any } | { regex: { pattern: string, flags: string } } | null} The static value of the node, or `null`. - */ -function getStaticValueOrRegex(node, initialScope) { - if (!node) { - return null; - } - if (node.type === "Literal" && node.regex) { - return { regex: node.regex }; - } - - const staticValue = getStaticValue(node, initialScope); - - if (staticValue?.value instanceof RegExp) { - return null; - } - return staticValue; -} - -/** - * Checks whether a specified regexpp character is represented as an acceptable escape sequence. - * This function requires the source text of the character to be known. - * @param {Character} char Character to check. - * @param {string} charSource Source text of the character to check. - * @returns {boolean} Whether the specified regexpp character is represented as an acceptable escape sequence. - */ -function checkForAcceptableEscape(char, charSource) { - if (!charSource.startsWith("\\")) { - return false; - } - const match = /(?<=^\\+).$/su.exec(charSource); - - return match?.[0] !== String.fromCodePoint(char.value); -} - -/** - * Checks whether a specified regexpp character is represented as an acceptable escape sequence. - * This function works with characters that are produced by a string or template literal. - * It requires the source text and the CodeUnit list of the literal to be known. - * @param {Character} char Character to check. - * @param {string} nodeSource Source text of the string or template literal that produces the character. - * @param {CodeUnit[]} codeUnits List of CodeUnit objects of the literal that produces the character. - * @returns {boolean} Whether the specified regexpp character is represented as an acceptable escape sequence. - */ -function checkForAcceptableEscapeInString(char, nodeSource, codeUnits) { - const firstIndex = char.start; - const lastIndex = char.end - 1; - const start = codeUnits[firstIndex].start; - const end = codeUnits[lastIndex].end; - const charSource = nodeSource.slice(start, end); - - return checkForAcceptableEscape(char, charSource); -} - -//------------------------------------------------------------------------------ -// Rule Definition -//------------------------------------------------------------------------------ - -/** @type {import('../shared/types').Rule} */ -module.exports = { - meta: { - type: "problem", - - docs: { - description: "Disallow characters which are made with multiple code points in character class syntax", - recommended: true, - url: "https://eslint.org/docs/latest/rules/no-misleading-character-class" - }, - - hasSuggestions: true, - - schema: [ - { - type: "object", - properties: { - allowEscape: { - type: "boolean", - default: false - } - }, - additionalProperties: false - } - ], - - messages: { - surrogatePairWithoutUFlag: "Unexpected surrogate pair in character class. Use 'u' flag.", - surrogatePair: "Unexpected surrogate pair in character class.", - combiningClass: "Unexpected combined character in character class.", - emojiModifier: "Unexpected modified Emoji in character class.", - regionalIndicatorSymbol: "Unexpected national flag in character class.", - zwj: "Unexpected joined character sequence in character class.", - suggestUnicodeFlag: "Add unicode 'u' flag to regex." - } - }, - create(context) { - const allowEscape = context.options[0]?.allowEscape; - const sourceCode = context.sourceCode; - const parser = new RegExpParser(); - const checkedPatternNodes = new Set(); - - /** - * Verify a given regular expression. - * @param {Node} node The node to report. - * @param {string} pattern The regular expression pattern to verify. - * @param {string} flags The flags of the regular expression. - * @param {Function} unicodeFixer Fixer for missing "u" flag. - * @returns {void} - */ - function verify(node, pattern, flags, unicodeFixer) { - let patternNode; - - try { - patternNode = parser.parsePattern( - pattern, - 0, - pattern.length, - { - unicode: flags.includes("u"), - unicodeSets: flags.includes("v") - } - ); - } catch { - - // Ignore regular expressions with syntax errors - return; - } - - let codeUnits = null; - - /** - * Checks whether a specified regexpp character is represented as an acceptable escape sequence. - * For the purposes of this rule, an escape sequence is considered acceptable if it consists of one or more backslashes followed by the character being escaped. - * @param {Character} char Character to check. - * @returns {boolean} Whether the specified regexpp character is represented as an acceptable escape sequence. - */ - function isAcceptableEscapeSequence(char) { - if (node.type === "Literal" && node.regex) { - return checkForAcceptableEscape(char, char.raw); - } - if (node.type === "Literal" && typeof node.value === "string") { - const nodeSource = node.raw; - - codeUnits ??= parseStringLiteral(nodeSource); - - return checkForAcceptableEscapeInString(char, nodeSource, codeUnits); - } - if (astUtils.isStaticTemplateLiteral(node)) { - const nodeSource = sourceCode.getText(node); - - codeUnits ??= parseTemplateToken(nodeSource); - - return checkForAcceptableEscapeInString(char, nodeSource, codeUnits); - } - return false; - } - - const foundKindMatches = new Map(); - - visitRegExpAST(patternNode, { - onCharacterClassEnter(ccNode) { - for (const unfilteredChars of iterateCharacterSequence(ccNode.elements)) { - let chars; - - if (allowEscape) { - - // Replace escape sequences with null to avoid having them flagged. - chars = unfilteredChars.map(char => (isAcceptableEscapeSequence(char) ? null : char)); - } else { - chars = unfilteredChars; - } - for (const kind of kinds) { - const matches = findCharacterSequences[kind](chars, unfilteredChars); - - if (foundKindMatches.has(kind)) { - foundKindMatches.get(kind).push(...matches); - } else { - foundKindMatches.set(kind, [...matches]); - } - } - } - } - }); - - /** - * Finds the report loc(s) for a range of matches. - * Only literals and expression-less templates generate granular errors. - * @param {Character[][]} matches Lists of individual characters being reported on. - * @returns {Location[]} locs for context.report. - * @see https://github.com/eslint/eslint/pull/17515 - */ - function getNodeReportLocations(matches) { - if (!astUtils.isStaticTemplateLiteral(node) && node.type !== "Literal") { - return matches.length ? [node.loc] : []; - } - return matches.map(chars => { - const firstIndex = chars[0].start; - const lastIndex = chars.at(-1).end - 1; - let start; - let end; - - if (node.type === "TemplateLiteral") { - const source = sourceCode.getText(node); - const offset = node.range[0]; - - codeUnits ??= parseTemplateToken(source); - start = offset + codeUnits[firstIndex].start; - end = offset + codeUnits[lastIndex].end; - } else if (typeof node.value === "string") { // String Literal - const source = node.raw; - const offset = node.range[0]; - - codeUnits ??= parseStringLiteral(source); - start = offset + codeUnits[firstIndex].start; - end = offset + codeUnits[lastIndex].end; - } else { // RegExp Literal - const offset = node.range[0] + 1; // Add 1 to skip the leading slash. - - start = offset + firstIndex; - end = offset + lastIndex + 1; - } - - return { - start: sourceCode.getLocFromIndex(start), - end: sourceCode.getLocFromIndex(end) - }; - }); - } - - for (const [kind, matches] of foundKindMatches) { - let suggest; - - if (kind === "surrogatePairWithoutUFlag") { - suggest = [{ - messageId: "suggestUnicodeFlag", - fix: unicodeFixer - }]; - } - - const locs = getNodeReportLocations(matches); - - for (const loc of locs) { - context.report({ - node, - loc, - messageId: kind, - suggest - }); - } - } - } - - return { - "Literal[regex]"(node) { - if (checkedPatternNodes.has(node)) { - return; - } - verify(node, node.regex.pattern, node.regex.flags, fixer => { - if (!isValidWithUnicodeFlag(context.languageOptions.ecmaVersion, node.regex.pattern)) { - return null; - } - - return fixer.insertTextAfter(node, "u"); - }); - }, - "Program"(node) { - const scope = sourceCode.getScope(node); - const tracker = new ReferenceTracker(scope); - - /* - * Iterate calls of RegExp. - * E.g., `new RegExp()`, `RegExp()`, `new window.RegExp()`, - * `const {RegExp: a} = window; new a()`, etc... - */ - for (const { node: refNode } of tracker.iterateGlobalReferences({ - RegExp: { [CALL]: true, [CONSTRUCT]: true } - })) { - let pattern, flags; - const [patternNode, flagsNode] = refNode.arguments; - const evaluatedPattern = getStaticValueOrRegex(patternNode, scope); - - if (!evaluatedPattern) { - continue; - } - if (flagsNode) { - if (evaluatedPattern.regex) { - pattern = evaluatedPattern.regex.pattern; - checkedPatternNodes.add(patternNode); - } else { - pattern = String(evaluatedPattern.value); - } - flags = getStringIfConstant(flagsNode, scope); - } else { - if (evaluatedPattern.regex) { - continue; - } - pattern = String(evaluatedPattern.value); - flags = ""; - } - - if (typeof flags === "string") { - verify(patternNode, pattern, flags, fixer => { - - if (!isValidWithUnicodeFlag(context.languageOptions.ecmaVersion, pattern)) { - return null; - } - - if (refNode.arguments.length === 1) { - const penultimateToken = sourceCode.getLastToken(refNode, { skip: 1 }); // skip closing parenthesis - - return fixer.insertTextAfter( - penultimateToken, - astUtils.isCommaToken(penultimateToken) - ? ' "u",' - : ', "u"' - ); - } - - if ((flagsNode.type === "Literal" && typeof flagsNode.value === "string") || flagsNode.type === "TemplateLiteral") { - const range = [flagsNode.range[0], flagsNode.range[1] - 1]; - - return fixer.insertTextAfterRange(range, "u"); - } - - return null; - }); - } - } - } - }; - } -}; diff --git a/tools/eslint/node_modules/eslint/lib/rules/no-mixed-operators.js b/tools/eslint/node_modules/eslint/lib/rules/no-mixed-operators.js deleted file mode 100644 index 6b6f7364a012ee..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/rules/no-mixed-operators.js +++ /dev/null @@ -1,229 +0,0 @@ -/** - * @fileoverview Rule to disallow mixed binary operators. - * @author Toru Nagashima - * @deprecated in ESLint v8.53.0 - */ - -"use strict"; - -//------------------------------------------------------------------------------ -// Requirements -//------------------------------------------------------------------------------ - -const astUtils = require("./utils/ast-utils.js"); - -//------------------------------------------------------------------------------ -// Helpers -//------------------------------------------------------------------------------ - -const ARITHMETIC_OPERATORS = ["+", "-", "*", "/", "%", "**"]; -const BITWISE_OPERATORS = ["&", "|", "^", "~", "<<", ">>", ">>>"]; -const COMPARISON_OPERATORS = ["==", "!=", "===", "!==", ">", ">=", "<", "<="]; -const LOGICAL_OPERATORS = ["&&", "||"]; -const RELATIONAL_OPERATORS = ["in", "instanceof"]; -const TERNARY_OPERATOR = ["?:"]; -const COALESCE_OPERATOR = ["??"]; -const ALL_OPERATORS = [].concat( - ARITHMETIC_OPERATORS, - BITWISE_OPERATORS, - COMPARISON_OPERATORS, - LOGICAL_OPERATORS, - RELATIONAL_OPERATORS, - TERNARY_OPERATOR, - COALESCE_OPERATOR -); -const DEFAULT_GROUPS = [ - ARITHMETIC_OPERATORS, - BITWISE_OPERATORS, - COMPARISON_OPERATORS, - LOGICAL_OPERATORS, - RELATIONAL_OPERATORS -]; -const TARGET_NODE_TYPE = /^(?:Binary|Logical|Conditional)Expression$/u; - -/** - * Normalizes options. - * @param {Object|undefined} options A options object to normalize. - * @returns {Object} Normalized option object. - */ -function normalizeOptions(options = {}) { - const hasGroups = options.groups && options.groups.length > 0; - const groups = hasGroups ? options.groups : DEFAULT_GROUPS; - const allowSamePrecedence = options.allowSamePrecedence !== false; - - return { - groups, - allowSamePrecedence - }; -} - -/** - * Checks whether any group which includes both given operator exists or not. - * @param {Array} groups A list of groups to check. - * @param {string} left An operator. - * @param {string} right Another operator. - * @returns {boolean} `true` if such group existed. - */ -function includesBothInAGroup(groups, left, right) { - return groups.some(group => group.includes(left) && group.includes(right)); -} - -/** - * Checks whether the given node is a conditional expression and returns the test node else the left node. - * @param {ASTNode} node A node which can be a BinaryExpression or a LogicalExpression node. - * This parent node can be BinaryExpression, LogicalExpression - * , or a ConditionalExpression node - * @returns {ASTNode} node the appropriate node(left or test). - */ -function getChildNode(node) { - return node.type === "ConditionalExpression" ? node.test : node.left; -} - -//------------------------------------------------------------------------------ -// Rule Definition -//------------------------------------------------------------------------------ - -/** @type {import('../shared/types').Rule} */ -module.exports = { - meta: { - deprecated: true, - replacedBy: [], - type: "suggestion", - - docs: { - description: "Disallow mixed binary operators", - recommended: false, - url: "https://eslint.org/docs/latest/rules/no-mixed-operators" - }, - - schema: [ - { - type: "object", - properties: { - groups: { - type: "array", - items: { - type: "array", - items: { enum: ALL_OPERATORS }, - minItems: 2, - uniqueItems: true - }, - uniqueItems: true - }, - allowSamePrecedence: { - type: "boolean", - default: true - } - }, - additionalProperties: false - } - ], - - messages: { - unexpectedMixedOperator: "Unexpected mix of '{{leftOperator}}' and '{{rightOperator}}'. Use parentheses to clarify the intended order of operations." - } - }, - - create(context) { - const sourceCode = context.sourceCode; - const options = normalizeOptions(context.options[0]); - - /** - * Checks whether a given node should be ignored by options or not. - * @param {ASTNode} node A node to check. This is a BinaryExpression - * node or a LogicalExpression node. This parent node is one of - * them, too. - * @returns {boolean} `true` if the node should be ignored. - */ - function shouldIgnore(node) { - const a = node; - const b = node.parent; - - return ( - !includesBothInAGroup(options.groups, a.operator, b.type === "ConditionalExpression" ? "?:" : b.operator) || - ( - options.allowSamePrecedence && - astUtils.getPrecedence(a) === astUtils.getPrecedence(b) - ) - ); - } - - /** - * Checks whether the operator of a given node is mixed with parent - * node's operator or not. - * @param {ASTNode} node A node to check. This is a BinaryExpression - * node or a LogicalExpression node. This parent node is one of - * them, too. - * @returns {boolean} `true` if the node was mixed. - */ - function isMixedWithParent(node) { - - return ( - node.operator !== node.parent.operator && - !astUtils.isParenthesised(sourceCode, node) - ); - } - - /** - * Gets the operator token of a given node. - * @param {ASTNode} node A node to check. This is a BinaryExpression - * node or a LogicalExpression node. - * @returns {Token} The operator token of the node. - */ - function getOperatorToken(node) { - return sourceCode.getTokenAfter(getChildNode(node), astUtils.isNotClosingParenToken); - } - - /** - * Reports both the operator of a given node and the operator of the - * parent node. - * @param {ASTNode} node A node to check. This is a BinaryExpression - * node or a LogicalExpression node. This parent node is one of - * them, too. - * @returns {void} - */ - function reportBothOperators(node) { - const parent = node.parent; - const left = (getChildNode(parent) === node) ? node : parent; - const right = (getChildNode(parent) !== node) ? node : parent; - const data = { - leftOperator: left.operator || "?:", - rightOperator: right.operator || "?:" - }; - - context.report({ - node: left, - loc: getOperatorToken(left).loc, - messageId: "unexpectedMixedOperator", - data - }); - context.report({ - node: right, - loc: getOperatorToken(right).loc, - messageId: "unexpectedMixedOperator", - data - }); - } - - /** - * Checks between the operator of this node and the operator of the - * parent node. - * @param {ASTNode} node A node to check. - * @returns {void} - */ - function check(node) { - if ( - TARGET_NODE_TYPE.test(node.parent.type) && - isMixedWithParent(node) && - !shouldIgnore(node) - ) { - reportBothOperators(node); - } - } - - return { - BinaryExpression: check, - LogicalExpression: check - }; - } -}; diff --git a/tools/eslint/node_modules/eslint/lib/rules/no-mixed-requires.js b/tools/eslint/node_modules/eslint/lib/rules/no-mixed-requires.js deleted file mode 100644 index 9e7b80390627a9..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/rules/no-mixed-requires.js +++ /dev/null @@ -1,238 +0,0 @@ -/** - * @fileoverview Rule to enforce grouped require statements for Node.JS - * @author Raphael Pigulla - * @deprecated in ESLint v7.0.0 - */ - -"use strict"; - -//------------------------------------------------------------------------------ -// Rule Definition -//------------------------------------------------------------------------------ - -/** @type {import('../shared/types').Rule} */ -module.exports = { - meta: { - deprecated: true, - - replacedBy: [], - - type: "suggestion", - - docs: { - description: "Disallow `require` calls to be mixed with regular variable declarations", - recommended: false, - url: "https://eslint.org/docs/latest/rules/no-mixed-requires" - }, - - schema: [ - { - oneOf: [ - { - type: "boolean" - }, - { - type: "object", - properties: { - grouping: { - type: "boolean" - }, - allowCall: { - type: "boolean" - } - }, - additionalProperties: false - } - ] - } - ], - - messages: { - noMixRequire: "Do not mix 'require' and other declarations.", - noMixCoreModuleFileComputed: "Do not mix core, module, file and computed requires." - } - }, - - create(context) { - - const options = context.options[0]; - let grouping = false, - allowCall = false; - - if (typeof options === "object") { - grouping = options.grouping; - allowCall = options.allowCall; - } else { - grouping = !!options; - } - - /** - * Returns the list of built-in modules. - * @returns {string[]} An array of built-in Node.js modules. - */ - function getBuiltinModules() { - - /* - * This list is generated using: - * `require("repl")._builtinLibs.concat('repl').sort()` - * This particular list is as per nodejs v0.12.2 and iojs v0.7.1 - */ - return [ - "assert", "buffer", "child_process", "cluster", "crypto", - "dgram", "dns", "domain", "events", "fs", "http", "https", - "net", "os", "path", "punycode", "querystring", "readline", - "repl", "smalloc", "stream", "string_decoder", "tls", "tty", - "url", "util", "v8", "vm", "zlib" - ]; - } - - const BUILTIN_MODULES = getBuiltinModules(); - - const DECL_REQUIRE = "require", - DECL_UNINITIALIZED = "uninitialized", - DECL_OTHER = "other"; - - const REQ_CORE = "core", - REQ_FILE = "file", - REQ_MODULE = "module", - REQ_COMPUTED = "computed"; - - /** - * Determines the type of a declaration statement. - * @param {ASTNode} initExpression The init node of the VariableDeclarator. - * @returns {string} The type of declaration represented by the expression. - */ - function getDeclarationType(initExpression) { - if (!initExpression) { - - // "var x;" - return DECL_UNINITIALIZED; - } - - if (initExpression.type === "CallExpression" && - initExpression.callee.type === "Identifier" && - initExpression.callee.name === "require" - ) { - - // "var x = require('util');" - return DECL_REQUIRE; - } - if (allowCall && - initExpression.type === "CallExpression" && - initExpression.callee.type === "CallExpression" - ) { - - // "var x = require('diagnose')('sub-module');" - return getDeclarationType(initExpression.callee); - } - if (initExpression.type === "MemberExpression") { - - // "var x = require('glob').Glob;" - return getDeclarationType(initExpression.object); - } - - // "var x = 42;" - return DECL_OTHER; - } - - /** - * Determines the type of module that is loaded via require. - * @param {ASTNode} initExpression The init node of the VariableDeclarator. - * @returns {string} The module type. - */ - function inferModuleType(initExpression) { - if (initExpression.type === "MemberExpression") { - - // "var x = require('glob').Glob;" - return inferModuleType(initExpression.object); - } - if (initExpression.arguments.length === 0) { - - // "var x = require();" - return REQ_COMPUTED; - } - - const arg = initExpression.arguments[0]; - - if (arg.type !== "Literal" || typeof arg.value !== "string") { - - // "var x = require(42);" - return REQ_COMPUTED; - } - - if (BUILTIN_MODULES.includes(arg.value)) { - - // "var fs = require('fs');" - return REQ_CORE; - } - if (/^\.{0,2}\//u.test(arg.value)) { - - // "var utils = require('./utils');" - return REQ_FILE; - } - - // "var async = require('async');" - return REQ_MODULE; - - } - - /** - * Check if the list of variable declarations is mixed, i.e. whether it - * contains both require and other declarations. - * @param {ASTNode} declarations The list of VariableDeclarators. - * @returns {boolean} True if the declarations are mixed, false if not. - */ - function isMixed(declarations) { - const contains = {}; - - declarations.forEach(declaration => { - const type = getDeclarationType(declaration.init); - - contains[type] = true; - }); - - return !!( - contains[DECL_REQUIRE] && - (contains[DECL_UNINITIALIZED] || contains[DECL_OTHER]) - ); - } - - /** - * Check if all require declarations in the given list are of the same - * type. - * @param {ASTNode} declarations The list of VariableDeclarators. - * @returns {boolean} True if the declarations are grouped, false if not. - */ - function isGrouped(declarations) { - const found = {}; - - declarations.forEach(declaration => { - if (getDeclarationType(declaration.init) === DECL_REQUIRE) { - found[inferModuleType(declaration.init)] = true; - } - }); - - return Object.keys(found).length <= 1; - } - - - return { - - VariableDeclaration(node) { - - if (isMixed(node.declarations)) { - context.report({ - node, - messageId: "noMixRequire" - }); - } else if (grouping && !isGrouped(node.declarations)) { - context.report({ - node, - messageId: "noMixCoreModuleFileComputed" - }); - } - } - }; - - } -}; diff --git a/tools/eslint/node_modules/eslint/lib/rules/no-mixed-spaces-and-tabs.js b/tools/eslint/node_modules/eslint/lib/rules/no-mixed-spaces-and-tabs.js deleted file mode 100644 index 18e6114a045a67..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/rules/no-mixed-spaces-and-tabs.js +++ /dev/null @@ -1,116 +0,0 @@ -/** - * @fileoverview Disallow mixed spaces and tabs for indentation - * @author Jary Niebur - * @deprecated in ESLint v8.53.0 - */ -"use strict"; - -//------------------------------------------------------------------------------ -// Rule Definition -//------------------------------------------------------------------------------ - -/** @type {import('../shared/types').Rule} */ -module.exports = { - meta: { - deprecated: true, - replacedBy: [], - type: "layout", - - docs: { - description: "Disallow mixed spaces and tabs for indentation", - recommended: false, - url: "https://eslint.org/docs/latest/rules/no-mixed-spaces-and-tabs" - }, - - schema: [ - { - enum: ["smart-tabs", true, false] - } - ], - - messages: { - mixedSpacesAndTabs: "Mixed spaces and tabs." - } - }, - - create(context) { - const sourceCode = context.sourceCode; - - let smartTabs; - - switch (context.options[0]) { - case true: // Support old syntax, maybe add deprecation warning here - case "smart-tabs": - smartTabs = true; - break; - default: - smartTabs = false; - } - - //-------------------------------------------------------------------------- - // Public - //-------------------------------------------------------------------------- - - return { - - "Program:exit"(node) { - const lines = sourceCode.lines, - comments = sourceCode.getAllComments(), - ignoredCommentLines = new Set(); - - // Add all lines except the first ones. - comments.forEach(comment => { - for (let i = comment.loc.start.line + 1; i <= comment.loc.end.line; i++) { - ignoredCommentLines.add(i); - } - }); - - /* - * At least one space followed by a tab - * or the reverse before non-tab/-space - * characters begin. - */ - let regex = /^(?=( +|\t+))\1(?:\t| )/u; - - if (smartTabs) { - - /* - * At least one space followed by a tab - * before non-tab/-space characters begin. - */ - regex = /^(?=(\t*))\1(?=( +))\2\t/u; - } - - lines.forEach((line, i) => { - const match = regex.exec(line); - - if (match) { - const lineNumber = i + 1; - const loc = { - start: { - line: lineNumber, - column: match[0].length - 2 - }, - end: { - line: lineNumber, - column: match[0].length - } - }; - - if (!ignoredCommentLines.has(lineNumber)) { - const containingNode = sourceCode.getNodeByRangeIndex(sourceCode.getIndexFromLoc(loc.start)); - - if (!(containingNode && ["Literal", "TemplateElement"].includes(containingNode.type))) { - context.report({ - node, - loc, - messageId: "mixedSpacesAndTabs" - }); - } - } - } - }); - } - }; - } -}; diff --git a/tools/eslint/node_modules/eslint/lib/rules/no-multi-assign.js b/tools/eslint/node_modules/eslint/lib/rules/no-multi-assign.js deleted file mode 100644 index a7a50c194951ca..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/rules/no-multi-assign.js +++ /dev/null @@ -1,67 +0,0 @@ -/** - * @fileoverview Rule to check use of chained assignment expressions - * @author Stewart Rand - */ - -"use strict"; - - -//------------------------------------------------------------------------------ -// Rule Definition -//------------------------------------------------------------------------------ - -/** @type {import('../shared/types').Rule} */ -module.exports = { - meta: { - type: "suggestion", - - docs: { - description: "Disallow use of chained assignment expressions", - recommended: false, - url: "https://eslint.org/docs/latest/rules/no-multi-assign" - }, - - schema: [{ - type: "object", - properties: { - ignoreNonDeclaration: { - type: "boolean", - default: false - } - }, - additionalProperties: false - }], - - messages: { - unexpectedChain: "Unexpected chained assignment." - } - }, - - create(context) { - - //-------------------------------------------------------------------------- - // Public - //-------------------------------------------------------------------------- - const options = context.options[0] || { - ignoreNonDeclaration: false - }; - const selectors = [ - "VariableDeclarator > AssignmentExpression.init", - "PropertyDefinition > AssignmentExpression.value" - ]; - - if (!options.ignoreNonDeclaration) { - selectors.push("AssignmentExpression > AssignmentExpression.right"); - } - - return { - [selectors](node) { - context.report({ - node, - messageId: "unexpectedChain" - }); - } - }; - - } -}; diff --git a/tools/eslint/node_modules/eslint/lib/rules/no-multi-spaces.js b/tools/eslint/node_modules/eslint/lib/rules/no-multi-spaces.js deleted file mode 100644 index bc90ee5b5b0183..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/rules/no-multi-spaces.js +++ /dev/null @@ -1,141 +0,0 @@ -/** - * @fileoverview Disallow use of multiple spaces. - * @author Nicholas C. Zakas - * @deprecated in ESLint v8.53.0 - */ - -"use strict"; - -const astUtils = require("./utils/ast-utils"); - -//------------------------------------------------------------------------------ -// Rule Definition -//------------------------------------------------------------------------------ - -/** @type {import('../shared/types').Rule} */ -module.exports = { - meta: { - deprecated: true, - replacedBy: [], - type: "layout", - - docs: { - description: "Disallow multiple spaces", - recommended: false, - url: "https://eslint.org/docs/latest/rules/no-multi-spaces" - }, - - fixable: "whitespace", - - schema: [ - { - type: "object", - properties: { - exceptions: { - type: "object", - patternProperties: { - "^([A-Z][a-z]*)+$": { - type: "boolean" - } - }, - additionalProperties: false - }, - ignoreEOLComments: { - type: "boolean", - default: false - } - }, - additionalProperties: false - } - ], - - messages: { - multipleSpaces: "Multiple spaces found before '{{displayValue}}'." - } - }, - - create(context) { - const sourceCode = context.sourceCode; - const options = context.options[0] || {}; - const ignoreEOLComments = options.ignoreEOLComments; - const exceptions = Object.assign({ Property: true }, options.exceptions); - const hasExceptions = Object.keys(exceptions).some(key => exceptions[key]); - - /** - * Formats value of given comment token for error message by truncating its length. - * @param {Token} token comment token - * @returns {string} formatted value - * @private - */ - function formatReportedCommentValue(token) { - const valueLines = token.value.split("\n"); - const value = valueLines[0]; - const formattedValue = `${value.slice(0, 12)}...`; - - return valueLines.length === 1 && value.length <= 12 ? value : formattedValue; - } - - //-------------------------------------------------------------------------- - // Public - //-------------------------------------------------------------------------- - - return { - Program() { - sourceCode.tokensAndComments.forEach((leftToken, leftIndex, tokensAndComments) => { - if (leftIndex === tokensAndComments.length - 1) { - return; - } - const rightToken = tokensAndComments[leftIndex + 1]; - - // Ignore tokens that don't have 2 spaces between them or are on different lines - if ( - !sourceCode.text.slice(leftToken.range[1], rightToken.range[0]).includes(" ") || - leftToken.loc.end.line < rightToken.loc.start.line - ) { - return; - } - - // Ignore comments that are the last token on their line if `ignoreEOLComments` is active. - if ( - ignoreEOLComments && - astUtils.isCommentToken(rightToken) && - ( - leftIndex === tokensAndComments.length - 2 || - rightToken.loc.end.line < tokensAndComments[leftIndex + 2].loc.start.line - ) - ) { - return; - } - - // Ignore tokens that are in a node in the "exceptions" object - if (hasExceptions) { - const parentNode = sourceCode.getNodeByRangeIndex(rightToken.range[0] - 1); - - if (parentNode && exceptions[parentNode.type]) { - return; - } - } - - let displayValue; - - if (rightToken.type === "Block") { - displayValue = `/*${formatReportedCommentValue(rightToken)}*/`; - } else if (rightToken.type === "Line") { - displayValue = `//${formatReportedCommentValue(rightToken)}`; - } else { - displayValue = rightToken.value; - } - - context.report({ - node: rightToken, - loc: { start: leftToken.loc.end, end: rightToken.loc.start }, - messageId: "multipleSpaces", - data: { displayValue }, - fix: fixer => fixer.replaceTextRange([leftToken.range[1], rightToken.range[0]], " ") - }); - }); - } - }; - - } -}; diff --git a/tools/eslint/node_modules/eslint/lib/rules/no-multi-str.js b/tools/eslint/node_modules/eslint/lib/rules/no-multi-str.js deleted file mode 100644 index 8011729ec60e31..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/rules/no-multi-str.js +++ /dev/null @@ -1,65 +0,0 @@ -/** - * @fileoverview Rule to flag when using multiline strings - * @author Ilya Volodin - */ - -"use strict"; - -//------------------------------------------------------------------------------ -// Requirements -//------------------------------------------------------------------------------ - -const astUtils = require("./utils/ast-utils"); - -//------------------------------------------------------------------------------ -// Rule Definition -//------------------------------------------------------------------------------ - -/** @type {import('../shared/types').Rule} */ -module.exports = { - meta: { - type: "suggestion", - - docs: { - description: "Disallow multiline strings", - recommended: false, - url: "https://eslint.org/docs/latest/rules/no-multi-str" - }, - - schema: [], - - messages: { - multilineString: "Multiline support is limited to browsers supporting ES5 only." - } - }, - - create(context) { - - /** - * Determines if a given node is part of JSX syntax. - * @param {ASTNode} node The node to check. - * @returns {boolean} True if the node is a JSX node, false if not. - * @private - */ - function isJSXElement(node) { - return node.type.indexOf("JSX") === 0; - } - - //-------------------------------------------------------------------------- - // Public API - //-------------------------------------------------------------------------- - - return { - - Literal(node) { - if (astUtils.LINEBREAK_MATCHER.test(node.raw) && !isJSXElement(node.parent)) { - context.report({ - node, - messageId: "multilineString" - }); - } - } - }; - - } -}; diff --git a/tools/eslint/node_modules/eslint/lib/rules/no-multiple-empty-lines.js b/tools/eslint/node_modules/eslint/lib/rules/no-multiple-empty-lines.js deleted file mode 100644 index b597138e8f4ef2..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/rules/no-multiple-empty-lines.js +++ /dev/null @@ -1,154 +0,0 @@ -/** - * @fileoverview Disallows multiple blank lines. - * implementation adapted from the no-trailing-spaces rule. - * @author Greg Cochard - * @deprecated in ESLint v8.53.0 - */ -"use strict"; - -//------------------------------------------------------------------------------ -// Rule Definition -//------------------------------------------------------------------------------ - -/** @type {import('../shared/types').Rule} */ -module.exports = { - meta: { - deprecated: true, - replacedBy: [], - type: "layout", - - docs: { - description: "Disallow multiple empty lines", - recommended: false, - url: "https://eslint.org/docs/latest/rules/no-multiple-empty-lines" - }, - - fixable: "whitespace", - - schema: [ - { - type: "object", - properties: { - max: { - type: "integer", - minimum: 0 - }, - maxEOF: { - type: "integer", - minimum: 0 - }, - maxBOF: { - type: "integer", - minimum: 0 - } - }, - required: ["max"], - additionalProperties: false - } - ], - - messages: { - blankBeginningOfFile: "Too many blank lines at the beginning of file. Max of {{max}} allowed.", - blankEndOfFile: "Too many blank lines at the end of file. Max of {{max}} allowed.", - consecutiveBlank: "More than {{max}} blank {{pluralizedLines}} not allowed." - } - }, - - create(context) { - - // Use options.max or 2 as default - let max = 2, - maxEOF = max, - maxBOF = max; - - if (context.options.length) { - max = context.options[0].max; - maxEOF = typeof context.options[0].maxEOF !== "undefined" ? context.options[0].maxEOF : max; - maxBOF = typeof context.options[0].maxBOF !== "undefined" ? context.options[0].maxBOF : max; - } - - const sourceCode = context.sourceCode; - - // Swallow the final newline, as some editors add it automatically and we don't want it to cause an issue - const allLines = sourceCode.lines.at(-1) === "" ? sourceCode.lines.slice(0, -1) : sourceCode.lines; - const templateLiteralLines = new Set(); - - //-------------------------------------------------------------------------- - // Public - //-------------------------------------------------------------------------- - - return { - TemplateLiteral(node) { - node.quasis.forEach(literalPart => { - - // Empty lines have a semantic meaning if they're inside template literals. Don't count these as empty lines. - for (let ignoredLine = literalPart.loc.start.line; ignoredLine < literalPart.loc.end.line; ignoredLine++) { - templateLiteralLines.add(ignoredLine); - } - }); - }, - "Program:exit"(node) { - return allLines - - // Given a list of lines, first get a list of line numbers that are non-empty. - .reduce((nonEmptyLineNumbers, line, index) => { - if (line.trim() || templateLiteralLines.has(index + 1)) { - nonEmptyLineNumbers.push(index + 1); - } - return nonEmptyLineNumbers; - }, []) - - // Add a value at the end to allow trailing empty lines to be checked. - .concat(allLines.length + 1) - - // Given two line numbers of non-empty lines, report the lines between if the difference is too large. - .reduce((lastLineNumber, lineNumber) => { - let messageId, maxAllowed; - - if (lastLineNumber === 0) { - messageId = "blankBeginningOfFile"; - maxAllowed = maxBOF; - } else if (lineNumber === allLines.length + 1) { - messageId = "blankEndOfFile"; - maxAllowed = maxEOF; - } else { - messageId = "consecutiveBlank"; - maxAllowed = max; - } - - if (lineNumber - lastLineNumber - 1 > maxAllowed) { - context.report({ - node, - loc: { - start: { line: lastLineNumber + maxAllowed + 1, column: 0 }, - end: { line: lineNumber, column: 0 } - }, - messageId, - data: { - max: maxAllowed, - pluralizedLines: maxAllowed === 1 ? "line" : "lines" - }, - fix(fixer) { - const rangeStart = sourceCode.getIndexFromLoc({ line: lastLineNumber + 1, column: 0 }); - - /* - * The end of the removal range is usually the start index of the next line. - * However, at the end of the file there is no next line, so the end of the - * range is just the length of the text. - */ - const lineNumberAfterRemovedLines = lineNumber - maxAllowed; - const rangeEnd = lineNumberAfterRemovedLines <= allLines.length - ? sourceCode.getIndexFromLoc({ line: lineNumberAfterRemovedLines, column: 0 }) - : sourceCode.text.length; - - return fixer.removeRange([rangeStart, rangeEnd]); - } - }); - } - - return lineNumber; - }, 0); - } - }; - } -}; diff --git a/tools/eslint/node_modules/eslint/lib/rules/no-native-reassign.js b/tools/eslint/node_modules/eslint/lib/rules/no-native-reassign.js deleted file mode 100644 index e3fed445102236..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/rules/no-native-reassign.js +++ /dev/null @@ -1,98 +0,0 @@ -/** - * @fileoverview Rule to disallow assignments to native objects or read-only global variables - * @author Ilya Volodin - * @deprecated in ESLint v3.3.0 - */ - -"use strict"; - -//------------------------------------------------------------------------------ -// Rule Definition -//------------------------------------------------------------------------------ - -/** @type {import('../shared/types').Rule} */ -module.exports = { - meta: { - type: "suggestion", - - docs: { - description: "Disallow assignments to native objects or read-only global variables", - recommended: false, - url: "https://eslint.org/docs/latest/rules/no-native-reassign" - }, - - deprecated: true, - - replacedBy: ["no-global-assign"], - - schema: [ - { - type: "object", - properties: { - exceptions: { - type: "array", - items: { type: "string" }, - uniqueItems: true - } - }, - additionalProperties: false - } - ], - - messages: { - nativeReassign: "Read-only global '{{name}}' should not be modified." - } - }, - - create(context) { - const config = context.options[0]; - const exceptions = (config && config.exceptions) || []; - const sourceCode = context.sourceCode; - - /** - * Reports write references. - * @param {Reference} reference A reference to check. - * @param {int} index The index of the reference in the references. - * @param {Reference[]} references The array that the reference belongs to. - * @returns {void} - */ - function checkReference(reference, index, references) { - const identifier = reference.identifier; - - if (reference.init === false && - reference.isWrite() && - - /* - * Destructuring assignments can have multiple default value, - * so possibly there are multiple writeable references for the same identifier. - */ - (index === 0 || references[index - 1].identifier !== identifier) - ) { - context.report({ - node: identifier, - messageId: "nativeReassign", - data: identifier - }); - } - } - - /** - * Reports write references if a given variable is read-only builtin. - * @param {Variable} variable A variable to check. - * @returns {void} - */ - function checkVariable(variable) { - if (variable.writeable === false && !exceptions.includes(variable.name)) { - variable.references.forEach(checkReference); - } - } - - return { - Program(node) { - const globalScope = sourceCode.getScope(node); - - globalScope.variables.forEach(checkVariable); - } - }; - } -}; diff --git a/tools/eslint/node_modules/eslint/lib/rules/no-negated-condition.js b/tools/eslint/node_modules/eslint/lib/rules/no-negated-condition.js deleted file mode 100644 index 3cb759049d9942..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/rules/no-negated-condition.js +++ /dev/null @@ -1,95 +0,0 @@ -/** - * @fileoverview Rule to disallow a negated condition - * @author Alberto Rodrรญguez - */ -"use strict"; - -//------------------------------------------------------------------------------ -// Rule Definition -//------------------------------------------------------------------------------ - -/** @type {import('../shared/types').Rule} */ -module.exports = { - meta: { - type: "suggestion", - - docs: { - description: "Disallow negated conditions", - recommended: false, - url: "https://eslint.org/docs/latest/rules/no-negated-condition" - }, - - schema: [], - - messages: { - unexpectedNegated: "Unexpected negated condition." - } - }, - - create(context) { - - /** - * Determines if a given node is an if-else without a condition on the else - * @param {ASTNode} node The node to check. - * @returns {boolean} True if the node has an else without an if. - * @private - */ - function hasElseWithoutCondition(node) { - return node.alternate && node.alternate.type !== "IfStatement"; - } - - /** - * Determines if a given node is a negated unary expression - * @param {Object} test The test object to check. - * @returns {boolean} True if the node is a negated unary expression. - * @private - */ - function isNegatedUnaryExpression(test) { - return test.type === "UnaryExpression" && test.operator === "!"; - } - - /** - * Determines if a given node is a negated binary expression - * @param {Test} test The test to check. - * @returns {boolean} True if the node is a negated binary expression. - * @private - */ - function isNegatedBinaryExpression(test) { - return test.type === "BinaryExpression" && - (test.operator === "!=" || test.operator === "!=="); - } - - /** - * Determines if a given node has a negated if expression - * @param {ASTNode} node The node to check. - * @returns {boolean} True if the node has a negated if expression. - * @private - */ - function isNegatedIf(node) { - return isNegatedUnaryExpression(node.test) || isNegatedBinaryExpression(node.test); - } - - return { - IfStatement(node) { - if (!hasElseWithoutCondition(node)) { - return; - } - - if (isNegatedIf(node)) { - context.report({ - node, - messageId: "unexpectedNegated" - }); - } - }, - ConditionalExpression(node) { - if (isNegatedIf(node)) { - context.report({ - node, - messageId: "unexpectedNegated" - }); - } - } - }; - } -}; diff --git a/tools/eslint/node_modules/eslint/lib/rules/no-negated-in-lhs.js b/tools/eslint/node_modules/eslint/lib/rules/no-negated-in-lhs.js deleted file mode 100644 index 7a50be7f2e749b..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/rules/no-negated-in-lhs.js +++ /dev/null @@ -1,46 +0,0 @@ -/** - * @fileoverview A rule to disallow negated left operands of the `in` operator - * @author Michael Ficarra - * @deprecated in ESLint v3.3.0 - */ - -"use strict"; - -//------------------------------------------------------------------------------ -// Rule Definition -//------------------------------------------------------------------------------ - -/** @type {import('../shared/types').Rule} */ -module.exports = { - meta: { - type: "problem", - - docs: { - description: "Disallow negating the left operand in `in` expressions", - recommended: false, - url: "https://eslint.org/docs/latest/rules/no-negated-in-lhs" - }, - - replacedBy: ["no-unsafe-negation"], - - deprecated: true, - schema: [], - - messages: { - negatedLHS: "The 'in' expression's left operand is negated." - } - }, - - create(context) { - - return { - - BinaryExpression(node) { - if (node.operator === "in" && node.left.type === "UnaryExpression" && node.left.operator === "!") { - context.report({ node, messageId: "negatedLHS" }); - } - } - }; - - } -}; diff --git a/tools/eslint/node_modules/eslint/lib/rules/no-nested-ternary.js b/tools/eslint/node_modules/eslint/lib/rules/no-nested-ternary.js deleted file mode 100644 index faf80416c3f478..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/rules/no-nested-ternary.js +++ /dev/null @@ -1,44 +0,0 @@ -/** - * @fileoverview Rule to flag nested ternary expressions - * @author Ian Christian Myers - */ - -"use strict"; - -//------------------------------------------------------------------------------ -// Rule Definition -//------------------------------------------------------------------------------ - -/** @type {import('../shared/types').Rule} */ -module.exports = { - meta: { - type: "suggestion", - - docs: { - description: "Disallow nested ternary expressions", - recommended: false, - url: "https://eslint.org/docs/latest/rules/no-nested-ternary" - }, - - schema: [], - - messages: { - noNestedTernary: "Do not nest ternary expressions." - } - }, - - create(context) { - - return { - ConditionalExpression(node) { - if (node.alternate.type === "ConditionalExpression" || - node.consequent.type === "ConditionalExpression") { - context.report({ - node, - messageId: "noNestedTernary" - }); - } - } - }; - } -}; diff --git a/tools/eslint/node_modules/eslint/lib/rules/no-new-func.js b/tools/eslint/node_modules/eslint/lib/rules/no-new-func.js deleted file mode 100644 index d58b2d715472d1..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/rules/no-new-func.js +++ /dev/null @@ -1,87 +0,0 @@ -/** - * @fileoverview Rule to flag when using new Function - * @author Ilya Volodin - */ - -"use strict"; - -//------------------------------------------------------------------------------ -// Requirements -//------------------------------------------------------------------------------ - -const astUtils = require("./utils/ast-utils"); - -//------------------------------------------------------------------------------ -// Helpers -//------------------------------------------------------------------------------ - -const callMethods = new Set(["apply", "bind", "call"]); - -//------------------------------------------------------------------------------ -// Rule Definition -//------------------------------------------------------------------------------ - -/** @type {import('../shared/types').Rule} */ -module.exports = { - meta: { - type: "suggestion", - - docs: { - description: "Disallow `new` operators with the `Function` object", - recommended: false, - url: "https://eslint.org/docs/latest/rules/no-new-func" - }, - - schema: [], - - messages: { - noFunctionConstructor: "The Function constructor is eval." - } - }, - - create(context) { - const sourceCode = context.sourceCode; - - return { - "Program:exit"(node) { - const globalScope = sourceCode.getScope(node); - const variable = globalScope.set.get("Function"); - - if (variable && variable.defs.length === 0) { - variable.references.forEach(ref => { - const idNode = ref.identifier; - const { parent } = idNode; - let evalNode; - - if (parent) { - if (idNode === parent.callee && ( - parent.type === "NewExpression" || - parent.type === "CallExpression" - )) { - evalNode = parent; - } else if ( - parent.type === "MemberExpression" && - idNode === parent.object && - callMethods.has(astUtils.getStaticPropertyName(parent)) - ) { - const maybeCallee = parent.parent.type === "ChainExpression" ? parent.parent : parent; - - if (maybeCallee.parent.type === "CallExpression" && maybeCallee.parent.callee === maybeCallee) { - evalNode = maybeCallee.parent; - } - } - } - - if (evalNode) { - context.report({ - node: evalNode, - messageId: "noFunctionConstructor" - }); - } - }); - } - } - }; - - } -}; diff --git a/tools/eslint/node_modules/eslint/lib/rules/no-new-native-nonconstructor.js b/tools/eslint/node_modules/eslint/lib/rules/no-new-native-nonconstructor.js deleted file mode 100644 index 699390dd5a19d8..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/rules/no-new-native-nonconstructor.js +++ /dev/null @@ -1,66 +0,0 @@ -/** - * @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: true, - url: "https://eslint.org/docs/latest/rules/no-new-native-nonconstructor" - }, - - schema: [], - - messages: { - noNewNonconstructor: "`{{name}}` cannot be called as a constructor." - } - }, - - create(context) { - - const sourceCode = context.sourceCode; - - return { - "Program:exit"(node) { - const globalScope = sourceCode.getScope(node); - - for (const nonConstructorName of nonConstructorGlobalFunctionNames) { - const variable = globalScope.set.get(nonConstructorName); - - if (variable && variable.defs.length === 0) { - variable.references.forEach(ref => { - const idNode = ref.identifier; - const parent = idNode.parent; - - if (parent && parent.type === "NewExpression" && parent.callee === idNode) { - context.report({ - node: idNode, - messageId: "noNewNonconstructor", - data: { name: nonConstructorName } - }); - } - }); - } - } - } - }; - - } -}; diff --git a/tools/eslint/node_modules/eslint/lib/rules/no-new-object.js b/tools/eslint/node_modules/eslint/lib/rules/no-new-object.js deleted file mode 100644 index 06275f47125134..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/rules/no-new-object.js +++ /dev/null @@ -1,67 +0,0 @@ -/** - * @fileoverview A rule to disallow calls to the Object constructor - * @author Matt DuVall - * @deprecated in ESLint v8.50.0 - */ - -"use strict"; - -//------------------------------------------------------------------------------ -// Requirements -//------------------------------------------------------------------------------ - -const astUtils = require("./utils/ast-utils"); - -//------------------------------------------------------------------------------ -// Rule Definition -//------------------------------------------------------------------------------ - -/** @type {import('../shared/types').Rule} */ -module.exports = { - meta: { - type: "suggestion", - - docs: { - description: "Disallow `Object` constructors", - recommended: false, - url: "https://eslint.org/docs/latest/rules/no-new-object" - }, - - deprecated: true, - - replacedBy: [ - "no-object-constructor" - ], - - schema: [], - - messages: { - preferLiteral: "The object literal notation {} is preferable." - } - }, - - create(context) { - - const sourceCode = context.sourceCode; - - return { - NewExpression(node) { - const variable = astUtils.getVariableByName( - sourceCode.getScope(node), - node.callee.name - ); - - if (variable && variable.identifiers.length > 0) { - return; - } - - if (node.callee.name === "Object") { - context.report({ - node, - messageId: "preferLiteral" - }); - } - } - }; - } -}; diff --git a/tools/eslint/node_modules/eslint/lib/rules/no-new-require.js b/tools/eslint/node_modules/eslint/lib/rules/no-new-require.js deleted file mode 100644 index 6abfc17c845163..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/rules/no-new-require.js +++ /dev/null @@ -1,50 +0,0 @@ -/** - * @fileoverview Rule to disallow use of new operator with the `require` function - * @author Wil Moore III - * @deprecated in ESLint v7.0.0 - */ - -"use strict"; - -//------------------------------------------------------------------------------ -// Rule Definition -//------------------------------------------------------------------------------ - -/** @type {import('../shared/types').Rule} */ -module.exports = { - meta: { - deprecated: true, - - replacedBy: [], - - type: "suggestion", - - docs: { - description: "Disallow `new` operators with calls to `require`", - recommended: false, - url: "https://eslint.org/docs/latest/rules/no-new-require" - }, - - schema: [], - - messages: { - noNewRequire: "Unexpected use of new with require." - } - }, - - create(context) { - - return { - - NewExpression(node) { - if (node.callee.type === "Identifier" && node.callee.name === "require") { - context.report({ - node, - messageId: "noNewRequire" - }); - } - } - }; - - } -}; diff --git a/tools/eslint/node_modules/eslint/lib/rules/no-new-symbol.js b/tools/eslint/node_modules/eslint/lib/rules/no-new-symbol.js deleted file mode 100644 index 85f9e62a6d71ea..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/rules/no-new-symbol.js +++ /dev/null @@ -1,63 +0,0 @@ -/** - * @fileoverview Rule to disallow use of the new operator with the `Symbol` object - * @author Alberto Rodrรญguez - * @deprecated in ESLint v9.0.0 - */ - -"use strict"; - -//------------------------------------------------------------------------------ -// Rule Definition -//------------------------------------------------------------------------------ - -/** @type {import('../shared/types').Rule} */ -module.exports = { - meta: { - type: "problem", - - docs: { - description: "Disallow `new` operators with the `Symbol` object", - recommended: false, - url: "https://eslint.org/docs/latest/rules/no-new-symbol" - }, - - deprecated: true, - - replacedBy: [ - "no-new-native-nonconstructor" - ], - - schema: [], - - messages: { - noNewSymbol: "`Symbol` cannot be called as a constructor." - } - }, - - create(context) { - - const sourceCode = context.sourceCode; - - return { - "Program:exit"(node) { - const globalScope = sourceCode.getScope(node); - const variable = globalScope.set.get("Symbol"); - - if (variable && variable.defs.length === 0) { - variable.references.forEach(ref => { - const idNode = ref.identifier; - const parent = idNode.parent; - - if (parent && parent.type === "NewExpression" && parent.callee === idNode) { - context.report({ - node: idNode, - messageId: "noNewSymbol" - }); - } - }); - } - } - }; - - } -}; diff --git a/tools/eslint/node_modules/eslint/lib/rules/no-new-wrappers.js b/tools/eslint/node_modules/eslint/lib/rules/no-new-wrappers.js deleted file mode 100644 index 5050a98a044a75..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/rules/no-new-wrappers.js +++ /dev/null @@ -1,60 +0,0 @@ -/** - * @fileoverview Rule to flag when using constructor for wrapper objects - * @author Ilya Volodin - */ - -"use strict"; - -//------------------------------------------------------------------------------ -// Requirements -//------------------------------------------------------------------------------ - -const { getVariableByName } = require("./utils/ast-utils"); - -//------------------------------------------------------------------------------ -// Rule Definition -//------------------------------------------------------------------------------ - -/** @type {import('../shared/types').Rule} */ -module.exports = { - meta: { - type: "suggestion", - - docs: { - description: "Disallow `new` operators with the `String`, `Number`, and `Boolean` objects", - recommended: false, - url: "https://eslint.org/docs/latest/rules/no-new-wrappers" - }, - - schema: [], - - messages: { - noConstructor: "Do not use {{fn}} as a constructor." - } - }, - - create(context) { - const { sourceCode } = context; - - return { - - NewExpression(node) { - const wrapperObjects = ["String", "Number", "Boolean"]; - const { name } = node.callee; - - if (wrapperObjects.includes(name)) { - const variable = getVariableByName(sourceCode.getScope(node), name); - - if (variable && variable.identifiers.length === 0) { - context.report({ - node, - messageId: "noConstructor", - data: { fn: name } - }); - } - } - } - }; - - } -}; diff --git a/tools/eslint/node_modules/eslint/lib/rules/no-new.js b/tools/eslint/node_modules/eslint/lib/rules/no-new.js deleted file mode 100644 index 9e20bad7b6e2d4..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/rules/no-new.js +++ /dev/null @@ -1,43 +0,0 @@ -/** - * @fileoverview Rule to flag statements with function invocation preceded by - * "new" and not part of assignment - * @author Ilya Volodin - */ - -"use strict"; - -//------------------------------------------------------------------------------ -// Rule Definition -//------------------------------------------------------------------------------ - -/** @type {import('../shared/types').Rule} */ -module.exports = { - meta: { - type: "suggestion", - - docs: { - description: "Disallow `new` operators outside of assignments or comparisons", - recommended: false, - url: "https://eslint.org/docs/latest/rules/no-new" - }, - - schema: [], - - messages: { - noNewStatement: "Do not use 'new' for side effects." - } - }, - - create(context) { - - return { - "ExpressionStatement > NewExpression"(node) { - context.report({ - node: node.parent, - messageId: "noNewStatement" - }); - } - }; - - } -}; diff --git a/tools/eslint/node_modules/eslint/lib/rules/no-nonoctal-decimal-escape.js b/tools/eslint/node_modules/eslint/lib/rules/no-nonoctal-decimal-escape.js deleted file mode 100644 index 5939390fd9a888..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/rules/no-nonoctal-decimal-escape.js +++ /dev/null @@ -1,148 +0,0 @@ -/** - * @fileoverview Rule to disallow `\8` and `\9` escape sequences in string literals. - * @author Milos Djermanovic - */ - -"use strict"; - -//------------------------------------------------------------------------------ -// Helpers -//------------------------------------------------------------------------------ - -const QUICK_TEST_REGEX = /\\[89]/u; - -/** - * Returns unicode escape sequence that represents the given character. - * @param {string} character A single code unit. - * @returns {string} "\uXXXX" sequence. - */ -function getUnicodeEscape(character) { - return `\\u${character.charCodeAt(0).toString(16).padStart(4, "0")}`; -} - -//------------------------------------------------------------------------------ -// Rule Definition -//------------------------------------------------------------------------------ - -/** @type {import('../shared/types').Rule} */ -module.exports = { - meta: { - type: "suggestion", - - docs: { - description: "Disallow `\\8` and `\\9` escape sequences in string literals", - recommended: true, - url: "https://eslint.org/docs/latest/rules/no-nonoctal-decimal-escape" - }, - - hasSuggestions: true, - - schema: [], - - messages: { - decimalEscape: "Don't use '{{decimalEscape}}' escape sequence.", - - // suggestions - refactor: "Replace '{{original}}' with '{{replacement}}'. This maintains the current functionality.", - escapeBackslash: "Replace '{{original}}' with '{{replacement}}' to include the actual backslash character." - } - }, - - create(context) { - const sourceCode = context.sourceCode; - - /** - * Creates a new Suggestion object. - * @param {string} messageId "refactor" or "escapeBackslash". - * @param {int[]} range The range to replace. - * @param {string} replacement New text for the range. - * @returns {Object} Suggestion - */ - function createSuggestion(messageId, range, replacement) { - return { - messageId, - data: { - original: sourceCode.getText().slice(...range), - replacement - }, - fix(fixer) { - return fixer.replaceTextRange(range, replacement); - } - }; - } - - return { - Literal(node) { - if (typeof node.value !== "string") { - return; - } - - if (!QUICK_TEST_REGEX.test(node.raw)) { - return; - } - - const regex = /(?:[^\\]|(?\\.))*?(?\\[89])/suy; - let match; - - while ((match = regex.exec(node.raw))) { - const { previousEscape, decimalEscape } = match.groups; - const decimalEscapeRangeEnd = node.range[0] + match.index + match[0].length; - const decimalEscapeRangeStart = decimalEscapeRangeEnd - decimalEscape.length; - const decimalEscapeRange = [decimalEscapeRangeStart, decimalEscapeRangeEnd]; - const suggest = []; - - // When `regex` is matched, `previousEscape` can only capture characters adjacent to `decimalEscape` - if (previousEscape === "\\0") { - - /* - * Now we have a NULL escape "\0" immediately followed by a decimal escape, e.g.: "\0\8". - * Fixing this to "\08" would turn "\0" into a legacy octal escape. To avoid producing - * an octal escape while fixing a decimal escape, we provide different suggestions. - */ - suggest.push( - createSuggestion( // "\0\8" -> "\u00008" - "refactor", - [decimalEscapeRangeStart - previousEscape.length, decimalEscapeRangeEnd], - `${getUnicodeEscape("\0")}${decimalEscape[1]}` - ), - createSuggestion( // "\8" -> "\u0038" - "refactor", - decimalEscapeRange, - getUnicodeEscape(decimalEscape[1]) - ) - ); - } else { - suggest.push( - createSuggestion( // "\8" -> "8" - "refactor", - decimalEscapeRange, - decimalEscape[1] - ) - ); - } - - suggest.push( - createSuggestion( // "\8" -> "\\8" - "escapeBackslash", - decimalEscapeRange, - `\\${decimalEscape}` - ) - ); - - context.report({ - node, - loc: { - start: sourceCode.getLocFromIndex(decimalEscapeRangeStart), - end: sourceCode.getLocFromIndex(decimalEscapeRangeEnd) - }, - messageId: "decimalEscape", - data: { - decimalEscape - }, - suggest - }); - } - } - }; - } -}; diff --git a/tools/eslint/node_modules/eslint/lib/rules/no-obj-calls.js b/tools/eslint/node_modules/eslint/lib/rules/no-obj-calls.js deleted file mode 100644 index ee767ea2fa3015..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/rules/no-obj-calls.js +++ /dev/null @@ -1,86 +0,0 @@ -/** - * @fileoverview Rule to flag use of an object property of the global object (Math and JSON) as a function - * @author James Allardice - */ - -"use strict"; - -//------------------------------------------------------------------------------ -// Requirements -//------------------------------------------------------------------------------ - -const { CALL, CONSTRUCT, ReferenceTracker } = require("@eslint-community/eslint-utils"); -const getPropertyName = require("./utils/ast-utils").getStaticPropertyName; - -//------------------------------------------------------------------------------ -// Helpers -//------------------------------------------------------------------------------ - -const nonCallableGlobals = ["Atomics", "JSON", "Math", "Reflect", "Intl"]; - -/** - * Returns the name of the node to report - * @param {ASTNode} node A node to report - * @returns {string} name to report - */ -function getReportNodeName(node) { - if (node.type === "ChainExpression") { - return getReportNodeName(node.expression); - } - if (node.type === "MemberExpression") { - return getPropertyName(node); - } - return node.name; -} - -//------------------------------------------------------------------------------ -// Rule Definition -//------------------------------------------------------------------------------ - -/** @type {import('../shared/types').Rule} */ -module.exports = { - meta: { - type: "problem", - - docs: { - description: "Disallow calling global object properties as functions", - recommended: true, - url: "https://eslint.org/docs/latest/rules/no-obj-calls" - }, - - schema: [], - - messages: { - unexpectedCall: "'{{name}}' is not a function.", - unexpectedRefCall: "'{{name}}' is reference to '{{ref}}', which is not a function." - } - }, - - create(context) { - - const sourceCode = context.sourceCode; - - return { - Program(node) { - const scope = sourceCode.getScope(node); - const tracker = new ReferenceTracker(scope); - const traceMap = {}; - - for (const g of nonCallableGlobals) { - traceMap[g] = { - [CALL]: true, - [CONSTRUCT]: true - }; - } - - for (const { node: refNode, path } of tracker.iterateGlobalReferences(traceMap)) { - const name = getReportNodeName(refNode.callee); - const ref = path[0]; - const messageId = name === ref ? "unexpectedCall" : "unexpectedRefCall"; - - context.report({ node: refNode, messageId, data: { name, ref } }); - } - } - }; - } -}; diff --git a/tools/eslint/node_modules/eslint/lib/rules/no-object-constructor.js b/tools/eslint/node_modules/eslint/lib/rules/no-object-constructor.js deleted file mode 100644 index 8875ec2124b174..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/rules/no-object-constructor.js +++ /dev/null @@ -1,117 +0,0 @@ -/** - * @fileoverview Rule to disallow calls to the `Object` constructor without an argument - * @author Francesco Trotta - */ - -"use strict"; - -//------------------------------------------------------------------------------ -// Requirements -//------------------------------------------------------------------------------ - -const { - getVariableByName, - isArrowToken, - isStartOfExpressionStatement, - needsPrecedingSemicolon -} = require("./utils/ast-utils"); - -//------------------------------------------------------------------------------ -// Rule Definition -//------------------------------------------------------------------------------ - -/** @type {import('../shared/types').Rule} */ -module.exports = { - meta: { - type: "suggestion", - - docs: { - description: "Disallow calls to the `Object` constructor without an argument", - recommended: false, - url: "https://eslint.org/docs/latest/rules/no-object-constructor" - }, - - hasSuggestions: true, - - schema: [], - - messages: { - preferLiteral: "The object literal notation {} is preferable.", - useLiteral: "Replace with '{{replacement}}'.", - useLiteralAfterSemicolon: "Replace with '{{replacement}}', add preceding semicolon." - } - }, - - create(context) { - - const sourceCode = context.sourceCode; - - /** - * Determines whether or not an object literal that replaces a specified node needs to be enclosed in parentheses. - * @param {ASTNode} node The node to be replaced. - * @returns {boolean} Whether or not parentheses around the object literal are required. - */ - function needsParentheses(node) { - if (isStartOfExpressionStatement(node)) { - return true; - } - - const prevToken = sourceCode.getTokenBefore(node); - - if (prevToken && isArrowToken(prevToken)) { - return true; - } - - return false; - } - - /** - * Reports on nodes where the `Object` constructor is called without arguments. - * @param {ASTNode} node The node to evaluate. - * @returns {void} - */ - function check(node) { - if (node.callee.type !== "Identifier" || node.callee.name !== "Object" || node.arguments.length) { - return; - } - - const variable = getVariableByName(sourceCode.getScope(node), "Object"); - - if (variable && variable.identifiers.length === 0) { - let replacement; - let fixText; - let messageId = "useLiteral"; - - if (needsParentheses(node)) { - replacement = "({})"; - if (needsPrecedingSemicolon(sourceCode, node)) { - fixText = ";({})"; - messageId = "useLiteralAfterSemicolon"; - } else { - fixText = "({})"; - } - } else { - replacement = fixText = "{}"; - } - - context.report({ - node, - messageId: "preferLiteral", - suggest: [ - { - messageId, - data: { replacement }, - fix: fixer => fixer.replaceText(node, fixText) - } - ] - }); - } - } - - return { - CallExpression: check, - NewExpression: check - }; - - } -}; diff --git a/tools/eslint/node_modules/eslint/lib/rules/no-octal-escape.js b/tools/eslint/node_modules/eslint/lib/rules/no-octal-escape.js deleted file mode 100644 index 6924d5419d5608..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/rules/no-octal-escape.js +++ /dev/null @@ -1,56 +0,0 @@ -/** - * @fileoverview Rule to flag octal escape sequences in string literals. - * @author Ian Christian Myers - */ - -"use strict"; - -//------------------------------------------------------------------------------ -// Rule Definition -//------------------------------------------------------------------------------ - -/** @type {import('../shared/types').Rule} */ -module.exports = { - meta: { - type: "suggestion", - - docs: { - description: "Disallow octal escape sequences in string literals", - recommended: false, - url: "https://eslint.org/docs/latest/rules/no-octal-escape" - }, - - schema: [], - - messages: { - octalEscapeSequence: "Don't use octal: '\\{{sequence}}'. Use '\\u....' instead." - } - }, - - create(context) { - - return { - - Literal(node) { - if (typeof node.value !== "string") { - return; - } - - // \0 represents a valid NULL character if it isn't followed by a digit. - const match = node.raw.match( - /^(?:[^\\]|\\.)*?\\([0-3][0-7]{1,2}|[4-7][0-7]|0(?=[89])|[1-7])/su - ); - - if (match) { - context.report({ - node, - messageId: "octalEscapeSequence", - data: { sequence: match[1] } - }); - } - } - - }; - - } -}; diff --git a/tools/eslint/node_modules/eslint/lib/rules/no-octal.js b/tools/eslint/node_modules/eslint/lib/rules/no-octal.js deleted file mode 100644 index dc027696a8e638..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/rules/no-octal.js +++ /dev/null @@ -1,45 +0,0 @@ -/** - * @fileoverview Rule to flag when initializing octal literal - * @author Ilya Volodin - */ - -"use strict"; - -//------------------------------------------------------------------------------ -// Rule Definition -//------------------------------------------------------------------------------ - -/** @type {import('../shared/types').Rule} */ -module.exports = { - meta: { - type: "suggestion", - - docs: { - description: "Disallow octal literals", - recommended: true, - url: "https://eslint.org/docs/latest/rules/no-octal" - }, - - schema: [], - - messages: { - noOctal: "Octal literals should not be used." - } - }, - - create(context) { - - return { - - Literal(node) { - if (typeof node.value === "number" && /^0[0-9]/u.test(node.raw)) { - context.report({ - node, - messageId: "noOctal" - }); - } - } - }; - - } -}; diff --git a/tools/eslint/node_modules/eslint/lib/rules/no-param-reassign.js b/tools/eslint/node_modules/eslint/lib/rules/no-param-reassign.js deleted file mode 100644 index 607cafd38372bb..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/rules/no-param-reassign.js +++ /dev/null @@ -1,230 +0,0 @@ -/** - * @fileoverview Disallow reassignment of function parameters. - * @author Nat Burns - */ -"use strict"; - -//------------------------------------------------------------------------------ -// Rule Definition -//------------------------------------------------------------------------------ - -const stopNodePattern = /(?:Statement|Declaration|Function(?:Expression)?|Program)$/u; - -/** @type {import('../shared/types').Rule} */ -module.exports = { - meta: { - type: "suggestion", - - docs: { - description: "Disallow reassigning `function` parameters", - recommended: false, - url: "https://eslint.org/docs/latest/rules/no-param-reassign" - }, - - schema: [ - { - oneOf: [ - { - type: "object", - properties: { - props: { - enum: [false] - } - }, - additionalProperties: false - }, - { - type: "object", - properties: { - props: { - enum: [true] - }, - ignorePropertyModificationsFor: { - type: "array", - items: { - type: "string" - }, - uniqueItems: true - }, - ignorePropertyModificationsForRegex: { - type: "array", - items: { - type: "string" - }, - uniqueItems: true - } - }, - additionalProperties: false - } - ] - } - ], - - messages: { - assignmentToFunctionParam: "Assignment to function parameter '{{name}}'.", - assignmentToFunctionParamProp: "Assignment to property of function parameter '{{name}}'." - } - }, - - create(context) { - const props = context.options[0] && context.options[0].props; - const ignoredPropertyAssignmentsFor = context.options[0] && context.options[0].ignorePropertyModificationsFor || []; - const ignoredPropertyAssignmentsForRegex = context.options[0] && context.options[0].ignorePropertyModificationsForRegex || []; - const sourceCode = context.sourceCode; - - /** - * Checks whether or not the reference modifies properties of its variable. - * @param {Reference} reference A reference to check. - * @returns {boolean} Whether or not the reference modifies properties of its variable. - */ - function isModifyingProp(reference) { - let node = reference.identifier; - let parent = node.parent; - - while (parent && (!stopNodePattern.test(parent.type) || - parent.type === "ForInStatement" || parent.type === "ForOfStatement")) { - switch (parent.type) { - - // e.g. foo.a = 0; - case "AssignmentExpression": - return parent.left === node; - - // e.g. ++foo.a; - case "UpdateExpression": - return true; - - // e.g. delete foo.a; - case "UnaryExpression": - if (parent.operator === "delete") { - return true; - } - break; - - // e.g. for (foo.a in b) {} - case "ForInStatement": - case "ForOfStatement": - if (parent.left === node) { - return true; - } - - // this is a stop node for parent.right and parent.body - return false; - - // EXCLUDES: e.g. cache.get(foo.a).b = 0; - case "CallExpression": - if (parent.callee !== node) { - return false; - } - break; - - // EXCLUDES: e.g. cache[foo.a] = 0; - case "MemberExpression": - if (parent.property === node) { - return false; - } - break; - - // EXCLUDES: e.g. ({ [foo]: a }) = bar; - case "Property": - if (parent.key === node) { - return false; - } - - break; - - // EXCLUDES: e.g. (foo ? a : b).c = bar; - case "ConditionalExpression": - if (parent.test === node) { - return false; - } - - break; - - // no default - } - - node = parent; - parent = node.parent; - } - - return false; - } - - /** - * Tests that an identifier name matches any of the ignored property assignments. - * First we test strings in ignoredPropertyAssignmentsFor. - * Then we instantiate and test RegExp objects from ignoredPropertyAssignmentsForRegex strings. - * @param {string} identifierName A string that describes the name of an identifier to - * ignore property assignments for. - * @returns {boolean} Whether the string matches an ignored property assignment regular expression or not. - */ - function isIgnoredPropertyAssignment(identifierName) { - return ignoredPropertyAssignmentsFor.includes(identifierName) || - ignoredPropertyAssignmentsForRegex.some(ignored => new RegExp(ignored, "u").test(identifierName)); - } - - /** - * Reports a reference if is non initializer and writable. - * @param {Reference} reference A reference to check. - * @param {int} index The index of the reference in the references. - * @param {Reference[]} references The array that the reference belongs to. - * @returns {void} - */ - function checkReference(reference, index, references) { - const identifier = reference.identifier; - - if (identifier && - !reference.init && - - /* - * Destructuring assignments can have multiple default value, - * so possibly there are multiple writeable references for the same identifier. - */ - (index === 0 || references[index - 1].identifier !== identifier) - ) { - if (reference.isWrite()) { - context.report({ - node: identifier, - messageId: "assignmentToFunctionParam", - data: { name: identifier.name } - }); - } else if (props && isModifyingProp(reference) && !isIgnoredPropertyAssignment(identifier.name)) { - context.report({ - node: identifier, - messageId: "assignmentToFunctionParamProp", - data: { name: identifier.name } - }); - } - } - } - - /** - * Finds and reports references that are non initializer and writable. - * @param {Variable} variable A variable to check. - * @returns {void} - */ - function checkVariable(variable) { - if (variable.defs[0].type === "Parameter") { - variable.references.forEach(checkReference); - } - } - - /** - * Checks parameters of a given function node. - * @param {ASTNode} node A function node to check. - * @returns {void} - */ - function checkForFunction(node) { - sourceCode.getDeclaredVariables(node).forEach(checkVariable); - } - - return { - - // `:exit` is needed for the `node.parent` property of identifier nodes. - "FunctionDeclaration:exit": checkForFunction, - "FunctionExpression:exit": checkForFunction, - "ArrowFunctionExpression:exit": checkForFunction - }; - - } -}; diff --git a/tools/eslint/node_modules/eslint/lib/rules/no-path-concat.js b/tools/eslint/node_modules/eslint/lib/rules/no-path-concat.js deleted file mode 100644 index 2e4a3a21cd3442..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/rules/no-path-concat.js +++ /dev/null @@ -1,64 +0,0 @@ -/** - * @fileoverview Disallow string concatenation when using __dirname and __filename - * @author Nicholas C. Zakas - * @deprecated in ESLint v7.0.0 - */ -"use strict"; - -//------------------------------------------------------------------------------ -// Rule Definition -//------------------------------------------------------------------------------ - -/** @type {import('../shared/types').Rule} */ -module.exports = { - meta: { - deprecated: true, - - replacedBy: [], - - type: "suggestion", - - docs: { - description: "Disallow string concatenation with `__dirname` and `__filename`", - recommended: false, - url: "https://eslint.org/docs/latest/rules/no-path-concat" - }, - - schema: [], - - messages: { - usePathFunctions: "Use path.join() or path.resolve() instead of + to create paths." - } - }, - - create(context) { - - const MATCHER = /^__(?:dir|file)name$/u; - - //-------------------------------------------------------------------------- - // Public - //-------------------------------------------------------------------------- - - return { - - BinaryExpression(node) { - - const left = node.left, - right = node.right; - - if (node.operator === "+" && - ((left.type === "Identifier" && MATCHER.test(left.name)) || - (right.type === "Identifier" && MATCHER.test(right.name))) - ) { - - context.report({ - node, - messageId: "usePathFunctions" - }); - } - } - - }; - - } -}; diff --git a/tools/eslint/node_modules/eslint/lib/rules/no-plusplus.js b/tools/eslint/node_modules/eslint/lib/rules/no-plusplus.js deleted file mode 100644 index 22a6fd013501ca..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/rules/no-plusplus.js +++ /dev/null @@ -1,105 +0,0 @@ -/** - * @fileoverview Rule to flag use of unary increment and decrement operators. - * @author Ian Christian Myers - * @author Brody McKee (github.com/mrmckeb) - */ - -"use strict"; - -//------------------------------------------------------------------------------ -// Helpers -//------------------------------------------------------------------------------ - -/** - * Determines whether the given node is the update node of a `ForStatement`. - * @param {ASTNode} node The node to check. - * @returns {boolean} `true` if the node is `ForStatement` update. - */ -function isForStatementUpdate(node) { - const parent = node.parent; - - return parent.type === "ForStatement" && parent.update === node; -} - -/** - * Determines whether the given node is considered to be a for loop "afterthought" by the logic of this rule. - * In particular, it returns `true` if the given node is either: - * - The update node of a `ForStatement`: for (;; i++) {} - * - An operand of a sequence expression that is the update node: for (;; foo(), i++) {} - * - An operand of a sequence expression that is child of another sequence expression, etc., - * up to the sequence expression that is the update node: for (;; foo(), (bar(), (baz(), i++))) {} - * @param {ASTNode} node The node to check. - * @returns {boolean} `true` if the node is a for loop afterthought. - */ -function isForLoopAfterthought(node) { - const parent = node.parent; - - if (parent.type === "SequenceExpression") { - return isForLoopAfterthought(parent); - } - - return isForStatementUpdate(node); -} - -//------------------------------------------------------------------------------ -// Rule Definition -//------------------------------------------------------------------------------ - -/** @type {import('../shared/types').Rule} */ -module.exports = { - meta: { - type: "suggestion", - - docs: { - description: "Disallow the unary operators `++` and `--`", - recommended: false, - url: "https://eslint.org/docs/latest/rules/no-plusplus" - }, - - schema: [ - { - type: "object", - properties: { - allowForLoopAfterthoughts: { - type: "boolean", - default: false - } - }, - additionalProperties: false - } - ], - - messages: { - unexpectedUnaryOp: "Unary operator '{{operator}}' used." - } - }, - - create(context) { - - const config = context.options[0]; - let allowForLoopAfterthoughts = false; - - if (typeof config === "object") { - allowForLoopAfterthoughts = config.allowForLoopAfterthoughts === true; - } - - return { - - UpdateExpression(node) { - if (allowForLoopAfterthoughts && isForLoopAfterthought(node)) { - return; - } - - context.report({ - node, - messageId: "unexpectedUnaryOp", - data: { - operator: node.operator - } - }); - } - - }; - - } -}; diff --git a/tools/eslint/node_modules/eslint/lib/rules/no-process-env.js b/tools/eslint/node_modules/eslint/lib/rules/no-process-env.js deleted file mode 100644 index 8dac648ff6b14d..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/rules/no-process-env.js +++ /dev/null @@ -1,51 +0,0 @@ -/** - * @fileoverview Disallow the use of process.env() - * @author Vignesh Anand - * @deprecated in ESLint v7.0.0 - */ -"use strict"; - -//------------------------------------------------------------------------------ -// Rule Definition -//------------------------------------------------------------------------------ - -/** @type {import('../shared/types').Rule} */ -module.exports = { - meta: { - deprecated: true, - - replacedBy: [], - - type: "suggestion", - - docs: { - description: "Disallow the use of `process.env`", - recommended: false, - url: "https://eslint.org/docs/latest/rules/no-process-env" - }, - - schema: [], - - messages: { - unexpectedProcessEnv: "Unexpected use of process.env." - } - }, - - create(context) { - - return { - - MemberExpression(node) { - const objectName = node.object.name, - propertyName = node.property.name; - - if (objectName === "process" && !node.computed && propertyName && propertyName === "env") { - context.report({ node, messageId: "unexpectedProcessEnv" }); - } - - } - - }; - - } -}; diff --git a/tools/eslint/node_modules/eslint/lib/rules/no-process-exit.js b/tools/eslint/node_modules/eslint/lib/rules/no-process-exit.js deleted file mode 100644 index fa398a72e56dc9..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/rules/no-process-exit.js +++ /dev/null @@ -1,47 +0,0 @@ -/** - * @fileoverview Disallow the use of process.exit() - * @author Nicholas C. Zakas - * @deprecated in ESLint v7.0.0 - */ -"use strict"; - -//------------------------------------------------------------------------------ -// Rule Definition -//------------------------------------------------------------------------------ - -/** @type {import('../shared/types').Rule} */ -module.exports = { - meta: { - deprecated: true, - - replacedBy: [], - - type: "suggestion", - - docs: { - description: "Disallow the use of `process.exit()`", - recommended: false, - url: "https://eslint.org/docs/latest/rules/no-process-exit" - }, - - schema: [], - - messages: { - noProcessExit: "Don't use process.exit(); throw an error instead." - } - }, - - create(context) { - - //-------------------------------------------------------------------------- - // Public - //-------------------------------------------------------------------------- - - return { - "CallExpression > MemberExpression.callee[object.name = 'process'][property.name = 'exit']"(node) { - context.report({ node: node.parent, messageId: "noProcessExit" }); - } - }; - - } -}; diff --git a/tools/eslint/node_modules/eslint/lib/rules/no-promise-executor-return.js b/tools/eslint/node_modules/eslint/lib/rules/no-promise-executor-return.js deleted file mode 100644 index b27e440729c0ff..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/rules/no-promise-executor-return.js +++ /dev/null @@ -1,263 +0,0 @@ -/** - * @fileoverview Rule to disallow returning values from Promise executor functions - * @author Milos Djermanovic - */ - -"use strict"; - -//------------------------------------------------------------------------------ -// Requirements -//------------------------------------------------------------------------------ - -const { findVariable } = require("@eslint-community/eslint-utils"); -const astUtils = require("./utils/ast-utils"); - -//------------------------------------------------------------------------------ -// Helpers -//------------------------------------------------------------------------------ - -const functionTypesToCheck = new Set(["ArrowFunctionExpression", "FunctionExpression"]); - -/** - * Determines whether the given identifier node is a reference to a global variable. - * @param {ASTNode} node `Identifier` node to check. - * @param {Scope} scope Scope to which the node belongs. - * @returns {boolean} True if the identifier is a reference to a global variable. - */ -function isGlobalReference(node, scope) { - const variable = findVariable(scope, node); - - return variable !== null && variable.scope.type === "global" && variable.defs.length === 0; -} - -/** - * Finds function's outer scope. - * @param {Scope} scope Function's own scope. - * @returns {Scope} Function's outer scope. - */ -function getOuterScope(scope) { - const upper = scope.upper; - - if (upper.type === "function-expression-name") { - return upper.upper; - } - return upper; -} - -/** - * Determines whether the given function node is used as a Promise executor. - * @param {ASTNode} node The node to check. - * @param {Scope} scope Function's own scope. - * @returns {boolean} `true` if the node is a Promise executor. - */ -function isPromiseExecutor(node, scope) { - const parent = node.parent; - - return parent.type === "NewExpression" && - parent.arguments[0] === node && - parent.callee.type === "Identifier" && - parent.callee.name === "Promise" && - isGlobalReference(parent.callee, getOuterScope(scope)); -} - -/** - * Checks if the given node is a void expression. - * @param {ASTNode} node The node to check. - * @returns {boolean} - `true` if the node is a void expression - */ -function expressionIsVoid(node) { - return node.type === "UnaryExpression" && node.operator === "void"; -} - -/** - * Fixes the linting error by prepending "void " to the given node - * @param {Object} sourceCode context given by context.sourceCode - * @param {ASTNode} node The node to fix. - * @param {Object} fixer The fixer object provided by ESLint. - * @returns {Array} - An array of fix objects to apply to the node. - */ -function voidPrependFixer(sourceCode, node, fixer) { - - const requiresParens = - - // prepending `void ` will fail if the node has a lower precedence than void - astUtils.getPrecedence(node) < astUtils.getPrecedence({ type: "UnaryExpression", operator: "void" }) && - - // check if there are parentheses around the node to avoid redundant parentheses - !astUtils.isParenthesised(sourceCode, node); - - // avoid parentheses issues - const returnOrArrowToken = sourceCode.getTokenBefore( - node, - node.parent.type === "ArrowFunctionExpression" - ? astUtils.isArrowToken - - // isReturnToken - : token => token.type === "Keyword" && token.value === "return" - ); - - const firstToken = sourceCode.getTokenAfter(returnOrArrowToken); - - const prependSpace = - - // is return token, as => allows void to be adjacent - returnOrArrowToken.value === "return" && - - // If two tokens (return and "(") are adjacent - returnOrArrowToken.range[1] === firstToken.range[0]; - - return [ - fixer.insertTextBefore(firstToken, `${prependSpace ? " " : ""}void ${requiresParens ? "(" : ""}`), - fixer.insertTextAfter(node, requiresParens ? ")" : "") - ]; -} - -/** - * Fixes the linting error by `wrapping {}` around the given node's body. - * @param {Object} sourceCode context given by context.sourceCode - * @param {ASTNode} node The node to fix. - * @param {Object} fixer The fixer object provided by ESLint. - * @returns {Array} - An array of fix objects to apply to the node. - */ -function curlyWrapFixer(sourceCode, node, fixer) { - - // https://github.com/eslint/eslint/pull/17282#issuecomment-1592795923 - const arrowToken = sourceCode.getTokenBefore(node.body, astUtils.isArrowToken); - const firstToken = sourceCode.getTokenAfter(arrowToken); - const lastToken = sourceCode.getLastToken(node); - - return [ - fixer.insertTextBefore(firstToken, "{"), - fixer.insertTextAfter(lastToken, "}") - ]; -} - -//------------------------------------------------------------------------------ -// Rule Definition -//------------------------------------------------------------------------------ - -/** @type {import('../shared/types').Rule} */ -module.exports = { - meta: { - type: "problem", - - docs: { - description: "Disallow returning values from Promise executor functions", - recommended: false, - url: "https://eslint.org/docs/latest/rules/no-promise-executor-return" - }, - - hasSuggestions: true, - - schema: [{ - type: "object", - properties: { - allowVoid: { - type: "boolean", - default: false - } - }, - additionalProperties: false - }], - - messages: { - returnsValue: "Return values from promise executor functions cannot be read.", - - // arrow and function suggestions - prependVoid: "Prepend `void` to the expression.", - - // only arrow suggestions - wrapBraces: "Wrap the expression in `{}`." - } - }, - - create(context) { - - let funcInfo = null; - const sourceCode = context.sourceCode; - const { - allowVoid = false - } = context.options[0] || {}; - - return { - - onCodePathStart(_, node) { - funcInfo = { - upper: funcInfo, - shouldCheck: - functionTypesToCheck.has(node.type) && - isPromiseExecutor(node, sourceCode.getScope(node)) - }; - - if (// Is a Promise executor - funcInfo.shouldCheck && - node.type === "ArrowFunctionExpression" && - node.expression && - - // Except void - !(allowVoid && expressionIsVoid(node.body)) - ) { - const suggest = []; - - // prevent useless refactors - if (allowVoid) { - suggest.push({ - messageId: "prependVoid", - fix(fixer) { - return voidPrependFixer(sourceCode, node.body, fixer); - } - }); - } - - // Do not suggest wrapping an unnamed FunctionExpression in braces as that would be invalid syntax. - if (!(node.body.type === "FunctionExpression" && !node.body.id)) { - suggest.push({ - messageId: "wrapBraces", - fix(fixer) { - return curlyWrapFixer(sourceCode, node, fixer); - } - }); - } - - context.report({ - node: node.body, - messageId: "returnsValue", - suggest - }); - } - }, - - onCodePathEnd() { - funcInfo = funcInfo.upper; - }, - - ReturnStatement(node) { - if (!(funcInfo.shouldCheck && node.argument)) { - return; - } - - // node is `return ` - if (!allowVoid) { - context.report({ node, messageId: "returnsValue" }); - return; - } - - if (expressionIsVoid(node.argument)) { - return; - } - - // allowVoid && !expressionIsVoid - context.report({ - node, - messageId: "returnsValue", - suggest: [{ - messageId: "prependVoid", - fix(fixer) { - return voidPrependFixer(sourceCode, node.argument, fixer); - } - }] - }); - } - }; - } -}; diff --git a/tools/eslint/node_modules/eslint/lib/rules/no-proto.js b/tools/eslint/node_modules/eslint/lib/rules/no-proto.js deleted file mode 100644 index 28320d5d5e5f1d..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/rules/no-proto.js +++ /dev/null @@ -1,48 +0,0 @@ -/** - * @fileoverview Rule to flag usage of __proto__ property - * @author Ilya Volodin - */ - -"use strict"; - -//------------------------------------------------------------------------------ -// Requirements -//------------------------------------------------------------------------------ - -const { getStaticPropertyName } = require("./utils/ast-utils"); - -//------------------------------------------------------------------------------ -// Rule Definition -//------------------------------------------------------------------------------ - -/** @type {import('../shared/types').Rule} */ -module.exports = { - meta: { - type: "suggestion", - - docs: { - description: "Disallow the use of the `__proto__` property", - recommended: false, - url: "https://eslint.org/docs/latest/rules/no-proto" - }, - - schema: [], - - messages: { - unexpectedProto: "The '__proto__' property is deprecated." - } - }, - - create(context) { - - return { - - MemberExpression(node) { - if (getStaticPropertyName(node) === "__proto__") { - context.report({ node, messageId: "unexpectedProto" }); - } - } - }; - - } -}; diff --git a/tools/eslint/node_modules/eslint/lib/rules/no-prototype-builtins.js b/tools/eslint/node_modules/eslint/lib/rules/no-prototype-builtins.js deleted file mode 100644 index b61e585291a92e..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/rules/no-prototype-builtins.js +++ /dev/null @@ -1,159 +0,0 @@ -/** - * @fileoverview Rule to disallow use of Object.prototype builtins on objects - * @author Andrew Levine - */ -"use strict"; - -//------------------------------------------------------------------------------ -// Requirements -//------------------------------------------------------------------------------ - -const astUtils = require("./utils/ast-utils"); - -//------------------------------------------------------------------------------ -// Helpers -//------------------------------------------------------------------------------ - -/** - * Returns true if the node or any of the objects - * to the left of it in the member/call chain is optional. - * - * e.g. `a?.b`, `a?.b.c`, `a?.()`, `a()?.()` - * @param {ASTNode} node The expression to check - * @returns {boolean} `true` if there is a short-circuiting optional `?.` - * in the same option chain to the left of this call or member expression, - * or the node itself is an optional call or member `?.`. - */ -function isAfterOptional(node) { - let leftNode; - - if (node.type === "MemberExpression") { - leftNode = node.object; - } else if (node.type === "CallExpression") { - leftNode = node.callee; - } else { - return false; - } - if (node.optional) { - return true; - } - return isAfterOptional(leftNode); -} - - -//------------------------------------------------------------------------------ -// Rule Definition -//------------------------------------------------------------------------------ - -/** @type {import('../shared/types').Rule} */ -module.exports = { - meta: { - type: "problem", - - docs: { - description: "Disallow calling some `Object.prototype` methods directly on objects", - recommended: true, - url: "https://eslint.org/docs/latest/rules/no-prototype-builtins" - }, - - hasSuggestions: true, - - schema: [], - - messages: { - prototypeBuildIn: "Do not access Object.prototype method '{{prop}}' from target object.", - callObjectPrototype: "Call Object.prototype.{{prop}} explicitly." - } - }, - - create(context) { - const DISALLOWED_PROPS = new Set([ - "hasOwnProperty", - "isPrototypeOf", - "propertyIsEnumerable" - ]); - - /** - * Reports if a disallowed property is used in a CallExpression - * @param {ASTNode} node The CallExpression node. - * @returns {void} - */ - function disallowBuiltIns(node) { - - const callee = astUtils.skipChainExpression(node.callee); - - if (callee.type !== "MemberExpression") { - return; - } - - const propName = astUtils.getStaticPropertyName(callee); - - if (propName !== null && DISALLOWED_PROPS.has(propName)) { - context.report({ - messageId: "prototypeBuildIn", - loc: callee.property.loc, - data: { prop: propName }, - node, - suggest: [ - { - messageId: "callObjectPrototype", - data: { prop: propName }, - fix(fixer) { - const sourceCode = context.sourceCode; - - /* - * A call after an optional chain (e.g. a?.b.hasOwnProperty(c)) - * must be fixed manually because the call can be short-circuited - */ - if (isAfterOptional(node)) { - return null; - } - - /* - * A call on a ChainExpression (e.g. (a?.hasOwnProperty)(c)) will trigger - * no-unsafe-optional-chaining which should be fixed before this suggestion - */ - if (node.callee.type === "ChainExpression") { - return null; - } - - const objectVariable = astUtils.getVariableByName(sourceCode.getScope(node), "Object"); - - /* - * We can't use Object if the global Object was shadowed, - * or Object does not exist in the global scope for some reason - */ - if (!objectVariable || objectVariable.scope.type !== "global" || objectVariable.defs.length > 0) { - return null; - } - - let objectText = sourceCode.getText(callee.object); - - if (astUtils.getPrecedence(callee.object) <= astUtils.getPrecedence({ type: "SequenceExpression" })) { - objectText = `(${objectText})`; - } - - const openParenToken = sourceCode.getTokenAfter( - node.callee, - astUtils.isOpeningParenToken - ); - const isEmptyParameters = node.arguments.length === 0; - const delim = isEmptyParameters ? "" : ", "; - const fixes = [ - fixer.replaceText(callee, `Object.prototype.${propName}.call`), - fixer.insertTextAfter(openParenToken, objectText + delim) - ]; - - return fixes; - } - } - ] - }); - } - } - - return { - CallExpression: disallowBuiltIns - }; - } -}; diff --git a/tools/eslint/node_modules/eslint/lib/rules/no-redeclare.js b/tools/eslint/node_modules/eslint/lib/rules/no-redeclare.js deleted file mode 100644 index 8a4877e8a3ca29..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/rules/no-redeclare.js +++ /dev/null @@ -1,174 +0,0 @@ -/** - * @fileoverview Rule to flag when the same variable is declared more then once. - * @author Ilya Volodin - */ - -"use strict"; - -//------------------------------------------------------------------------------ -// Requirements -//------------------------------------------------------------------------------ - -const astUtils = require("./utils/ast-utils"); - -//------------------------------------------------------------------------------ -// Rule Definition -//------------------------------------------------------------------------------ - -/** @type {import('../shared/types').Rule} */ -module.exports = { - meta: { - type: "suggestion", - - docs: { - description: "Disallow variable redeclaration", - recommended: true, - url: "https://eslint.org/docs/latest/rules/no-redeclare" - }, - - messages: { - redeclared: "'{{id}}' is already defined.", - redeclaredAsBuiltin: "'{{id}}' is already defined as a built-in global variable.", - redeclaredBySyntax: "'{{id}}' is already defined by a variable declaration." - }, - - schema: [ - { - type: "object", - properties: { - builtinGlobals: { type: "boolean", default: true } - }, - additionalProperties: false - } - ] - }, - - create(context) { - const options = { - builtinGlobals: Boolean( - context.options.length === 0 || - context.options[0].builtinGlobals - ) - }; - const sourceCode = context.sourceCode; - - /** - * Iterate declarations of a given variable. - * @param {escope.variable} variable The variable object to iterate declarations. - * @returns {IterableIterator<{type:string,node:ASTNode,loc:SourceLocation}>} The declarations. - */ - function *iterateDeclarations(variable) { - if (options.builtinGlobals && ( - variable.eslintImplicitGlobalSetting === "readonly" || - variable.eslintImplicitGlobalSetting === "writable" - )) { - yield { type: "builtin" }; - } - - for (const id of variable.identifiers) { - yield { type: "syntax", node: id, loc: id.loc }; - } - - if (variable.eslintExplicitGlobalComments) { - for (const comment of variable.eslintExplicitGlobalComments) { - yield { - type: "comment", - node: comment, - loc: astUtils.getNameLocationInGlobalDirectiveComment( - sourceCode, - comment, - variable.name - ) - }; - } - } - } - - /** - * Find variables in a given scope and flag redeclared ones. - * @param {Scope} scope An eslint-scope scope object. - * @returns {void} - * @private - */ - function findVariablesInScope(scope) { - for (const variable of scope.variables) { - const [ - declaration, - ...extraDeclarations - ] = iterateDeclarations(variable); - - if (extraDeclarations.length === 0) { - continue; - } - - /* - * If the type of a declaration is different from the type of - * the first declaration, it shows the location of the first - * declaration. - */ - const detailMessageId = declaration.type === "builtin" - ? "redeclaredAsBuiltin" - : "redeclaredBySyntax"; - const data = { id: variable.name }; - - // Report extra declarations. - for (const { type, node, loc } of extraDeclarations) { - const messageId = type === declaration.type - ? "redeclared" - : detailMessageId; - - context.report({ node, loc, messageId, data }); - } - } - } - - /** - * Find variables in the current scope. - * @param {ASTNode} node The node of the current scope. - * @returns {void} - * @private - */ - function checkForBlock(node) { - const scope = sourceCode.getScope(node); - - /* - * In ES5, some node type such as `BlockStatement` doesn't have that scope. - * `scope.block` is a different node in such a case. - */ - if (scope.block === node) { - findVariablesInScope(scope); - } - } - - return { - Program(node) { - const scope = sourceCode.getScope(node); - - findVariablesInScope(scope); - - // Node.js or ES modules has a special scope. - if ( - scope.type === "global" && - scope.childScopes[0] && - - // The special scope's block is the Program node. - scope.block === scope.childScopes[0].block - ) { - findVariablesInScope(scope.childScopes[0]); - } - }, - - FunctionDeclaration: checkForBlock, - FunctionExpression: checkForBlock, - ArrowFunctionExpression: checkForBlock, - - StaticBlock: checkForBlock, - - BlockStatement: checkForBlock, - ForStatement: checkForBlock, - ForInStatement: checkForBlock, - ForOfStatement: checkForBlock, - SwitchStatement: checkForBlock - }; - } -}; diff --git a/tools/eslint/node_modules/eslint/lib/rules/no-regex-spaces.js b/tools/eslint/node_modules/eslint/lib/rules/no-regex-spaces.js deleted file mode 100644 index cb250107289ac8..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/rules/no-regex-spaces.js +++ /dev/null @@ -1,197 +0,0 @@ -/** - * @fileoverview Rule to count multiple spaces in regular expressions - * @author Matt DuVall - */ - -"use strict"; - -//------------------------------------------------------------------------------ -// Requirements -//------------------------------------------------------------------------------ - -const astUtils = require("./utils/ast-utils"); -const regexpp = require("@eslint-community/regexpp"); - -//------------------------------------------------------------------------------ -// Helpers -//------------------------------------------------------------------------------ - -const regExpParser = new regexpp.RegExpParser(); -const DOUBLE_SPACE = / {2}/u; - -/** - * Check if node is a string - * @param {ASTNode} node node to evaluate - * @returns {boolean} True if its a string - * @private - */ -function isString(node) { - return node && node.type === "Literal" && typeof node.value === "string"; -} - -//------------------------------------------------------------------------------ -// Rule Definition -//------------------------------------------------------------------------------ - -/** @type {import('../shared/types').Rule} */ -module.exports = { - meta: { - type: "suggestion", - - docs: { - description: "Disallow multiple spaces in regular expressions", - recommended: true, - url: "https://eslint.org/docs/latest/rules/no-regex-spaces" - }, - - schema: [], - fixable: "code", - - messages: { - multipleSpaces: "Spaces are hard to count. Use {{{length}}}." - } - }, - - create(context) { - - const sourceCode = context.sourceCode; - - /** - * Validate regular expression - * @param {ASTNode} nodeToReport Node to report. - * @param {string} pattern Regular expression pattern to validate. - * @param {string} rawPattern Raw representation of the pattern in the source code. - * @param {number} rawPatternStartRange Start range of the pattern in the source code. - * @param {string} flags Regular expression flags. - * @returns {void} - * @private - */ - function checkRegex(nodeToReport, pattern, rawPattern, rawPatternStartRange, flags) { - - // Skip if there are no consecutive spaces in the source code, to avoid reporting e.g., RegExp(' \ '). - if (!DOUBLE_SPACE.test(rawPattern)) { - return; - } - - const characterClassNodes = []; - let regExpAST; - - try { - regExpAST = regExpParser.parsePattern(pattern, 0, pattern.length, { unicode: flags.includes("u"), unicodeSets: flags.includes("v") }); - } catch { - - // Ignore regular expressions with syntax errors - return; - } - - regexpp.visitRegExpAST(regExpAST, { - onCharacterClassEnter(ccNode) { - characterClassNodes.push(ccNode); - } - }); - - const spacesPattern = /( {2,})(?: [+*{?]|[^+*{?]|$)/gu; - let match; - - while ((match = spacesPattern.exec(pattern))) { - const { 1: { length }, index } = match; - - // Report only consecutive spaces that are not in character classes. - if ( - characterClassNodes.every(({ start, end }) => index < start || end <= index) - ) { - context.report({ - node: nodeToReport, - messageId: "multipleSpaces", - data: { length }, - fix(fixer) { - if (pattern !== rawPattern) { - return null; - } - return fixer.replaceTextRange( - [rawPatternStartRange + index, rawPatternStartRange + index + length], - ` {${length}}` - ); - } - }); - - // Report only the first occurrence of consecutive spaces - return; - } - } - } - - /** - * Validate regular expression literals - * @param {ASTNode} node node to validate - * @returns {void} - * @private - */ - function checkLiteral(node) { - if (node.regex) { - const pattern = node.regex.pattern; - const rawPattern = node.raw.slice(1, node.raw.lastIndexOf("/")); - const rawPatternStartRange = node.range[0] + 1; - const flags = node.regex.flags; - - checkRegex( - node, - pattern, - rawPattern, - rawPatternStartRange, - flags - ); - } - } - - /** - * Validate strings passed to the RegExp constructor - * @param {ASTNode} node node to validate - * @returns {void} - * @private - */ - function checkFunction(node) { - const scope = sourceCode.getScope(node); - const regExpVar = astUtils.getVariableByName(scope, "RegExp"); - const shadowed = regExpVar && regExpVar.defs.length > 0; - const patternNode = node.arguments[0]; - - if (node.callee.type === "Identifier" && node.callee.name === "RegExp" && isString(patternNode) && !shadowed) { - const pattern = patternNode.value; - const rawPattern = patternNode.raw.slice(1, -1); - const rawPatternStartRange = patternNode.range[0] + 1; - let flags; - - if (node.arguments.length < 2) { - - // It has no flags. - flags = ""; - } else { - const flagsNode = node.arguments[1]; - - if (isString(flagsNode)) { - flags = flagsNode.value; - } else { - - // The flags cannot be determined. - return; - } - } - - checkRegex( - node, - pattern, - rawPattern, - rawPatternStartRange, - flags - ); - } - } - - return { - Literal: checkLiteral, - CallExpression: checkFunction, - NewExpression: checkFunction - }; - } -}; diff --git a/tools/eslint/node_modules/eslint/lib/rules/no-restricted-exports.js b/tools/eslint/node_modules/eslint/lib/rules/no-restricted-exports.js deleted file mode 100644 index 8da2f2dfe01c35..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/rules/no-restricted-exports.js +++ /dev/null @@ -1,204 +0,0 @@ -/** - * @fileoverview Rule to disallow specified names in exports - * @author Milos Djermanovic - */ - -"use strict"; - -//------------------------------------------------------------------------------ -// Requirements -//------------------------------------------------------------------------------ - -const astUtils = require("./utils/ast-utils"); - -//------------------------------------------------------------------------------ -// Rule Definition -//------------------------------------------------------------------------------ - -/** @type {import('../shared/types').Rule} */ -module.exports = { - meta: { - type: "suggestion", - - docs: { - description: "Disallow specified names in exports", - recommended: false, - url: "https://eslint.org/docs/latest/rules/no-restricted-exports" - }, - - schema: [{ - anyOf: [ - { - type: "object", - properties: { - restrictedNamedExports: { - type: "array", - items: { - type: "string" - }, - uniqueItems: true - }, - restrictedNamedExportsPattern: { type: "string" } - }, - additionalProperties: false - }, - { - type: "object", - properties: { - restrictedNamedExports: { - type: "array", - items: { - type: "string", - pattern: "^(?!default$)" - }, - uniqueItems: true - }, - restrictedNamedExportsPattern: { type: "string" }, - restrictDefaultExports: { - type: "object", - properties: { - - // Allow/Disallow `export default foo; export default 42; export default function foo() {}` format - direct: { - type: "boolean" - }, - - // Allow/Disallow `export { foo as default };` declarations - named: { - type: "boolean" - }, - - // Allow/Disallow `export { default } from "mod"; export { default as default } from "mod";` declarations - defaultFrom: { - type: "boolean" - }, - - // Allow/Disallow `export { foo as default } from "mod";` declarations - namedFrom: { - type: "boolean" - }, - - // Allow/Disallow `export * as default from "mod"`; declarations - namespaceFrom: { - type: "boolean" - } - }, - additionalProperties: false - } - }, - additionalProperties: false - } - ] - }], - - messages: { - restrictedNamed: "'{{name}}' is restricted from being used as an exported name.", - restrictedDefault: "Exporting 'default' is restricted." - } - }, - - create(context) { - - const restrictedNames = new Set(context.options[0] && context.options[0].restrictedNamedExports); - const restrictedNamePattern = context.options[0] && context.options[0].restrictedNamedExportsPattern; - const restrictDefaultExports = context.options[0] && context.options[0].restrictDefaultExports; - const sourceCode = context.sourceCode; - - /** - * Checks and reports given exported name. - * @param {ASTNode} node exported `Identifier` or string `Literal` node to check. - * @returns {void} - */ - function checkExportedName(node) { - const name = astUtils.getModuleExportName(node); - - let matchesRestrictedNamePattern = false; - - if (restrictedNamePattern && name !== "default") { - const patternRegex = new RegExp(restrictedNamePattern, "u"); - - matchesRestrictedNamePattern = patternRegex.test(name); - } - - if (matchesRestrictedNamePattern || restrictedNames.has(name)) { - context.report({ - node, - messageId: "restrictedNamed", - data: { name } - }); - return; - } - - if (name === "default") { - if (node.parent.type === "ExportAllDeclaration") { - if (restrictDefaultExports && restrictDefaultExports.namespaceFrom) { - context.report({ - node, - messageId: "restrictedDefault" - }); - } - - } else { // ExportSpecifier - const isSourceSpecified = !!node.parent.parent.source; - const specifierLocalName = astUtils.getModuleExportName(node.parent.local); - - if (!isSourceSpecified && restrictDefaultExports && restrictDefaultExports.named) { - context.report({ - node, - messageId: "restrictedDefault" - }); - return; - } - - if (isSourceSpecified && restrictDefaultExports) { - if ( - (specifierLocalName === "default" && restrictDefaultExports.defaultFrom) || - (specifierLocalName !== "default" && restrictDefaultExports.namedFrom) - ) { - context.report({ - node, - messageId: "restrictedDefault" - }); - } - } - } - } - } - - return { - ExportAllDeclaration(node) { - if (node.exported) { - checkExportedName(node.exported); - } - }, - - ExportDefaultDeclaration(node) { - if (restrictDefaultExports && restrictDefaultExports.direct) { - context.report({ - node, - messageId: "restrictedDefault" - }); - } - }, - - ExportNamedDeclaration(node) { - const declaration = node.declaration; - - if (declaration) { - if (declaration.type === "FunctionDeclaration" || declaration.type === "ClassDeclaration") { - checkExportedName(declaration.id); - } else if (declaration.type === "VariableDeclaration") { - sourceCode.getDeclaredVariables(declaration) - .map(v => v.defs.find(d => d.parent === declaration)) - .map(d => d.name) // Identifier nodes - .forEach(checkExportedName); - } - } else { - node.specifiers - .map(s => s.exported) - .forEach(checkExportedName); - } - } - }; - } -}; diff --git a/tools/eslint/node_modules/eslint/lib/rules/no-restricted-globals.js b/tools/eslint/node_modules/eslint/lib/rules/no-restricted-globals.js deleted file mode 100644 index 060d50a043717b..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/rules/no-restricted-globals.js +++ /dev/null @@ -1,124 +0,0 @@ -/** - * @fileoverview Restrict usage of specified globals. - * @author Benoรฎt Zugmeyer - */ -"use strict"; - -//------------------------------------------------------------------------------ -// Rule Definition -//------------------------------------------------------------------------------ - -/** @type {import('../shared/types').Rule} */ -module.exports = { - meta: { - type: "suggestion", - - docs: { - description: "Disallow specified global variables", - recommended: false, - url: "https://eslint.org/docs/latest/rules/no-restricted-globals" - }, - - schema: { - type: "array", - items: { - oneOf: [ - { - type: "string" - }, - { - type: "object", - properties: { - name: { type: "string" }, - message: { type: "string" } - }, - required: ["name"], - additionalProperties: false - } - ] - }, - uniqueItems: true, - minItems: 0 - }, - - messages: { - defaultMessage: "Unexpected use of '{{name}}'.", - // eslint-disable-next-line eslint-plugin/report-message-format -- Custom message might not end in a period - customMessage: "Unexpected use of '{{name}}'. {{customMessage}}" - } - }, - - create(context) { - - const sourceCode = context.sourceCode; - - // If no globals are restricted, we don't need to do anything - if (context.options.length === 0) { - return {}; - } - - const restrictedGlobalMessages = context.options.reduce((memo, option) => { - if (typeof option === "string") { - memo[option] = null; - } else { - memo[option.name] = option.message; - } - - return memo; - }, {}); - - /** - * Report a variable to be used as a restricted global. - * @param {Reference} reference the variable reference - * @returns {void} - * @private - */ - function reportReference(reference) { - const name = reference.identifier.name, - customMessage = restrictedGlobalMessages[name], - messageId = customMessage - ? "customMessage" - : "defaultMessage"; - - context.report({ - node: reference.identifier, - messageId, - data: { - name, - customMessage - } - }); - } - - /** - * Check if the given name is a restricted global name. - * @param {string} name name of a variable - * @returns {boolean} whether the variable is a restricted global or not - * @private - */ - function isRestricted(name) { - return Object.hasOwn(restrictedGlobalMessages, name); - } - - return { - Program(node) { - const scope = sourceCode.getScope(node); - - // Report variables declared elsewhere (ex: variables defined as "global" by eslint) - scope.variables.forEach(variable => { - if (!variable.defs.length && isRestricted(variable.name)) { - variable.references.forEach(reportReference); - } - }); - - // Report variables not declared at all - scope.through.forEach(reference => { - if (isRestricted(reference.identifier.name)) { - reportReference(reference); - } - }); - - } - }; - } -}; diff --git a/tools/eslint/node_modules/eslint/lib/rules/no-restricted-imports.js b/tools/eslint/node_modules/eslint/lib/rules/no-restricted-imports.js deleted file mode 100644 index 5fd4744c0b0b9f..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/rules/no-restricted-imports.js +++ /dev/null @@ -1,563 +0,0 @@ -/** - * @fileoverview Restrict usage of specified node imports. - * @author Guy Ellis - */ -"use strict"; - -//------------------------------------------------------------------------------ -// Requirements -//------------------------------------------------------------------------------ - -const astUtils = require("./utils/ast-utils"); - -//------------------------------------------------------------------------------ -// Rule Definition -//------------------------------------------------------------------------------ - -const ignore = require("ignore"); - -const arrayOfStringsOrObjects = { - type: "array", - items: { - anyOf: [ - { type: "string" }, - { - type: "object", - properties: { - name: { type: "string" }, - message: { - type: "string", - minLength: 1 - }, - importNames: { - type: "array", - items: { - type: "string" - } - }, - allowImportNames: { - type: "array", - items: { - type: "string" - } - } - }, - additionalProperties: false, - required: ["name"], - not: { required: ["importNames", "allowImportNames"] } - } - ] - }, - uniqueItems: true -}; - -const arrayOfStringsOrObjectPatterns = { - anyOf: [ - { - type: "array", - items: { - type: "string" - }, - uniqueItems: true - }, - { - type: "array", - items: { - type: "object", - properties: { - importNames: { - type: "array", - items: { - type: "string" - }, - minItems: 1, - uniqueItems: true - }, - allowImportNames: { - type: "array", - items: { - type: "string" - }, - minItems: 1, - uniqueItems: true - }, - group: { - type: "array", - items: { - type: "string" - }, - minItems: 1, - uniqueItems: true - }, - regex: { - type: "string" - }, - importNamePattern: { - type: "string" - }, - allowImportNamePattern: { - type: "string" - }, - message: { - type: "string", - minLength: 1 - }, - caseSensitive: { - type: "boolean" - } - }, - additionalProperties: false, - not: { - anyOf: [ - { required: ["importNames", "allowImportNames"] }, - { required: ["importNamePattern", "allowImportNamePattern"] }, - { required: ["importNames", "allowImportNamePattern"] }, - { required: ["importNamePattern", "allowImportNames"] }, - { required: ["allowImportNames", "allowImportNamePattern"] } - ] - }, - oneOf: [ - { required: ["group"] }, - { required: ["regex"] } - ] - }, - uniqueItems: true - } - ] -}; - -/** @type {import('../shared/types').Rule} */ -module.exports = { - meta: { - type: "suggestion", - - docs: { - description: "Disallow specified modules when loaded by `import`", - recommended: false, - url: "https://eslint.org/docs/latest/rules/no-restricted-imports" - }, - - messages: { - path: "'{{importSource}}' import is restricted from being used.", - // eslint-disable-next-line eslint-plugin/report-message-format -- Custom message might not end in a period - pathWithCustomMessage: "'{{importSource}}' import is restricted from being used. {{customMessage}}", - - patterns: "'{{importSource}}' import is restricted from being used by a pattern.", - // eslint-disable-next-line eslint-plugin/report-message-format -- Custom message might not end in a period - patternWithCustomMessage: "'{{importSource}}' import is restricted from being used by a pattern. {{customMessage}}", - - patternAndImportName: "'{{importName}}' import from '{{importSource}}' is restricted from being used by a pattern.", - // eslint-disable-next-line eslint-plugin/report-message-format -- Custom message might not end in a period - patternAndImportNameWithCustomMessage: "'{{importName}}' import from '{{importSource}}' is restricted from being used by a pattern. {{customMessage}}", - - patternAndEverything: "* import is invalid because '{{importNames}}' from '{{importSource}}' is restricted from being used by a pattern.", - - patternAndEverythingWithRegexImportName: "* import is invalid because import name matching '{{importNames}}' pattern from '{{importSource}}' is restricted from being used.", - // eslint-disable-next-line eslint-plugin/report-message-format -- Custom message might not end in a period - patternAndEverythingWithCustomMessage: "* import is invalid because '{{importNames}}' from '{{importSource}}' is restricted from being used by a pattern. {{customMessage}}", - // eslint-disable-next-line eslint-plugin/report-message-format -- Custom message might not end in a period - patternAndEverythingWithRegexImportNameAndCustomMessage: "* import is invalid because import name matching '{{importNames}}' pattern from '{{importSource}}' is restricted from being used. {{customMessage}}", - - everything: "* import is invalid because '{{importNames}}' from '{{importSource}}' is restricted.", - // eslint-disable-next-line eslint-plugin/report-message-format -- Custom message might not end in a period - everythingWithCustomMessage: "* import is invalid because '{{importNames}}' from '{{importSource}}' is restricted. {{customMessage}}", - - importName: "'{{importName}}' import from '{{importSource}}' is restricted.", - // eslint-disable-next-line eslint-plugin/report-message-format -- Custom message might not end in a period - importNameWithCustomMessage: "'{{importName}}' import from '{{importSource}}' is restricted. {{customMessage}}", - - allowedImportName: "'{{importName}}' import from '{{importSource}}' is restricted because only '{{allowedImportNames}}' import(s) is/are allowed.", - // eslint-disable-next-line eslint-plugin/report-message-format -- Custom message might not end in a period - allowedImportNameWithCustomMessage: "'{{importName}}' import from '{{importSource}}' is restricted because only '{{allowedImportNames}}' import(s) is/are allowed. {{customMessage}}", - - everythingWithAllowImportNames: "* import is invalid because only '{{allowedImportNames}}' from '{{importSource}}' is/are allowed.", - // eslint-disable-next-line eslint-plugin/report-message-format -- Custom message might not end in a period - everythingWithAllowImportNamesAndCustomMessage: "* import is invalid because only '{{allowedImportNames}}' from '{{importSource}}' is/are allowed. {{customMessage}}", - - allowedImportNamePattern: "'{{importName}}' import from '{{importSource}}' is restricted because only imports that match the pattern '{{allowedImportNamePattern}}' are allowed from '{{importSource}}'.", - // eslint-disable-next-line eslint-plugin/report-message-format -- Custom message might not end in a period - allowedImportNamePatternWithCustomMessage: "'{{importName}}' import from '{{importSource}}' is restricted because only imports that match the pattern '{{allowedImportNamePattern}}' are allowed from '{{importSource}}'. {{customMessage}}", - - everythingWithAllowedImportNamePattern: "* import is invalid because only imports that match the pattern '{{allowedImportNamePattern}}' from '{{importSource}}' are allowed.", - // eslint-disable-next-line eslint-plugin/report-message-format -- Custom message might not end in a period - everythingWithAllowedImportNamePatternWithCustomMessage: "* import is invalid because only imports that match the pattern '{{allowedImportNamePattern}}' from '{{importSource}}' are allowed. {{customMessage}}" - }, - - schema: { - anyOf: [ - arrayOfStringsOrObjects, - { - type: "array", - items: [{ - type: "object", - properties: { - paths: arrayOfStringsOrObjects, - patterns: arrayOfStringsOrObjectPatterns - }, - additionalProperties: false - }], - additionalItems: false - } - ] - } - }, - - create(context) { - const sourceCode = context.sourceCode; - const options = Array.isArray(context.options) ? context.options : []; - const isPathAndPatternsObject = - typeof options[0] === "object" && - (Object.hasOwn(options[0], "paths") || Object.hasOwn(options[0], "patterns")); - - const restrictedPaths = (isPathAndPatternsObject ? options[0].paths : context.options) || []; - const groupedRestrictedPaths = restrictedPaths.reduce((memo, importSource) => { - const path = typeof importSource === "string" - ? importSource - : importSource.name; - - if (!memo[path]) { - memo[path] = []; - } - - if (typeof importSource === "string") { - memo[path].push({}); - } else { - memo[path].push({ - message: importSource.message, - importNames: importSource.importNames, - allowImportNames: importSource.allowImportNames - }); - } - return memo; - }, Object.create(null)); - - // Handle patterns too, either as strings or groups - let restrictedPatterns = (isPathAndPatternsObject ? options[0].patterns : []) || []; - - // standardize to array of objects if we have an array of strings - if (restrictedPatterns.length > 0 && typeof restrictedPatterns[0] === "string") { - restrictedPatterns = [{ group: restrictedPatterns }]; - } - - // relative paths are supported for this rule - const restrictedPatternGroups = restrictedPatterns.map( - ({ group, regex, message, caseSensitive, importNames, importNamePattern, allowImportNames, allowImportNamePattern }) => ( - { - ...(group ? { matcher: ignore({ allowRelativePaths: true, ignorecase: !caseSensitive }).add(group) } : {}), - ...(typeof regex === "string" ? { regexMatcher: new RegExp(regex, caseSensitive ? "u" : "iu") } : {}), - customMessage: message, - importNames, - importNamePattern, - allowImportNames, - allowImportNamePattern - } - ) - ); - - // if no imports are restricted we don't need to check - if (Object.keys(restrictedPaths).length === 0 && restrictedPatternGroups.length === 0) { - return {}; - } - - /** - * Report a restricted path. - * @param {string} importSource path of the import - * @param {Map} importNames Map of import names that are being imported - * @param {node} node representing the restricted path reference - * @returns {void} - * @private - */ - function checkRestrictedPathAndReport(importSource, importNames, node) { - if (!Object.hasOwn(groupedRestrictedPaths, importSource)) { - return; - } - - groupedRestrictedPaths[importSource].forEach(restrictedPathEntry => { - const customMessage = restrictedPathEntry.message; - const restrictedImportNames = restrictedPathEntry.importNames; - const allowedImportNames = restrictedPathEntry.allowImportNames; - - if (!restrictedImportNames && !allowedImportNames) { - context.report({ - node, - messageId: customMessage ? "pathWithCustomMessage" : "path", - data: { - importSource, - customMessage - } - }); - - return; - } - - importNames.forEach((specifiers, importName) => { - if (importName === "*") { - const [specifier] = specifiers; - - if (restrictedImportNames) { - context.report({ - node, - messageId: customMessage ? "everythingWithCustomMessage" : "everything", - loc: specifier.loc, - data: { - importSource, - importNames: restrictedImportNames, - customMessage - } - }); - } else if (allowedImportNames) { - context.report({ - node, - messageId: customMessage ? "everythingWithAllowImportNamesAndCustomMessage" : "everythingWithAllowImportNames", - loc: specifier.loc, - data: { - importSource, - allowedImportNames, - customMessage - } - }); - } - - return; - } - - if (restrictedImportNames && restrictedImportNames.includes(importName)) { - specifiers.forEach(specifier => { - context.report({ - node, - messageId: customMessage ? "importNameWithCustomMessage" : "importName", - loc: specifier.loc, - data: { - importSource, - customMessage, - importName - } - }); - }); - } - - if (allowedImportNames && !allowedImportNames.includes(importName)) { - specifiers.forEach(specifier => { - context.report({ - node, - loc: specifier.loc, - messageId: customMessage ? "allowedImportNameWithCustomMessage" : "allowedImportName", - data: { - importSource, - customMessage, - importName, - allowedImportNames - } - }); - }); - } - }); - }); - } - - /** - * Report a restricted path specifically for patterns. - * @param {node} node representing the restricted path reference - * @param {Object} group contains an Ignore instance for paths, the customMessage to show on failure, - * and any restricted import names that have been specified in the config - * @param {Map} importNames Map of import names that are being imported - * @returns {void} - * @private - */ - function reportPathForPatterns(node, group, importNames) { - const importSource = node.source.value.trim(); - - const customMessage = group.customMessage; - const restrictedImportNames = group.importNames; - const restrictedImportNamePattern = group.importNamePattern ? new RegExp(group.importNamePattern, "u") : null; - const allowedImportNames = group.allowImportNames; - const allowedImportNamePattern = group.allowImportNamePattern ? new RegExp(group.allowImportNamePattern, "u") : null; - - /** - * If we are not restricting to any specific import names and just the pattern itself, - * report the error and move on - */ - if (!restrictedImportNames && !allowedImportNames && !restrictedImportNamePattern && !allowedImportNamePattern) { - context.report({ - node, - messageId: customMessage ? "patternWithCustomMessage" : "patterns", - data: { - importSource, - customMessage - } - }); - return; - } - - importNames.forEach((specifiers, importName) => { - if (importName === "*") { - const [specifier] = specifiers; - - if (restrictedImportNames) { - context.report({ - node, - messageId: customMessage ? "patternAndEverythingWithCustomMessage" : "patternAndEverything", - loc: specifier.loc, - data: { - importSource, - importNames: restrictedImportNames, - customMessage - } - }); - } else if (allowedImportNames) { - context.report({ - node, - messageId: customMessage ? "everythingWithAllowImportNamesAndCustomMessage" : "everythingWithAllowImportNames", - loc: specifier.loc, - data: { - importSource, - allowedImportNames, - customMessage - } - }); - } else if (allowedImportNamePattern) { - context.report({ - node, - messageId: customMessage ? "everythingWithAllowedImportNamePatternWithCustomMessage" : "everythingWithAllowedImportNamePattern", - loc: specifier.loc, - data: { - importSource, - allowedImportNamePattern, - customMessage - } - }); - } else { - context.report({ - node, - messageId: customMessage ? "patternAndEverythingWithRegexImportNameAndCustomMessage" : "patternAndEverythingWithRegexImportName", - loc: specifier.loc, - data: { - importSource, - importNames: restrictedImportNamePattern, - customMessage - } - }); - } - - return; - } - - if ( - (restrictedImportNames && restrictedImportNames.includes(importName)) || - (restrictedImportNamePattern && restrictedImportNamePattern.test(importName)) - ) { - specifiers.forEach(specifier => { - context.report({ - node, - messageId: customMessage ? "patternAndImportNameWithCustomMessage" : "patternAndImportName", - loc: specifier.loc, - data: { - importSource, - customMessage, - importName - } - }); - }); - } - - if (allowedImportNames && !allowedImportNames.includes(importName)) { - specifiers.forEach(specifier => { - context.report({ - node, - messageId: customMessage ? "allowedImportNameWithCustomMessage" : "allowedImportName", - loc: specifier.loc, - data: { - importSource, - customMessage, - importName, - allowedImportNames - } - }); - }); - } else if (allowedImportNamePattern && !allowedImportNamePattern.test(importName)) { - specifiers.forEach(specifier => { - context.report({ - node, - messageId: customMessage ? "allowedImportNamePatternWithCustomMessage" : "allowedImportNamePattern", - loc: specifier.loc, - data: { - importSource, - customMessage, - importName, - allowedImportNamePattern - } - }); - }); - } - }); - } - - /** - * Check if the given importSource is restricted by a pattern. - * @param {string} importSource path of the import - * @param {Object} group contains a Ignore instance for paths, and the customMessage to show if it fails - * @returns {boolean} whether the variable is a restricted pattern or not - * @private - */ - function isRestrictedPattern(importSource, group) { - return group.regexMatcher ? group.regexMatcher.test(importSource) : group.matcher.ignores(importSource); - } - - /** - * Checks a node to see if any problems should be reported. - * @param {ASTNode} node The node to check. - * @returns {void} - * @private - */ - function checkNode(node) { - const importSource = node.source.value.trim(); - const importNames = new Map(); - - if (node.type === "ExportAllDeclaration") { - const starToken = sourceCode.getFirstToken(node, 1); - - importNames.set("*", [{ loc: starToken.loc }]); - } else if (node.specifiers) { - for (const specifier of node.specifiers) { - let name; - const specifierData = { loc: specifier.loc }; - - if (specifier.type === "ImportDefaultSpecifier") { - name = "default"; - } else if (specifier.type === "ImportNamespaceSpecifier") { - name = "*"; - } else if (specifier.imported) { - name = astUtils.getModuleExportName(specifier.imported); - } else if (specifier.local) { - name = astUtils.getModuleExportName(specifier.local); - } - - if (typeof name === "string") { - if (importNames.has(name)) { - importNames.get(name).push(specifierData); - } else { - importNames.set(name, [specifierData]); - } - } - } - } - - checkRestrictedPathAndReport(importSource, importNames, node); - restrictedPatternGroups.forEach(group => { - if (isRestrictedPattern(importSource, group)) { - reportPathForPatterns(node, group, importNames); - } - }); - } - - return { - ImportDeclaration: checkNode, - ExportNamedDeclaration(node) { - if (node.source) { - checkNode(node); - } - }, - ExportAllDeclaration: checkNode - }; - } -}; diff --git a/tools/eslint/node_modules/eslint/lib/rules/no-restricted-modules.js b/tools/eslint/node_modules/eslint/lib/rules/no-restricted-modules.js deleted file mode 100644 index d36f2d289d6577..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/rules/no-restricted-modules.js +++ /dev/null @@ -1,213 +0,0 @@ -/** - * @fileoverview Restrict usage of specified node modules. - * @author Christian Schulz - * @deprecated in ESLint v7.0.0 - */ -"use strict"; - -//------------------------------------------------------------------------------ -// Requirements -//------------------------------------------------------------------------------ - -const astUtils = require("./utils/ast-utils"); - -//------------------------------------------------------------------------------ -// Rule Definition -//------------------------------------------------------------------------------ - -const ignore = require("ignore"); - -const arrayOfStrings = { - type: "array", - items: { type: "string" }, - uniqueItems: true -}; - -const arrayOfStringsOrObjects = { - type: "array", - items: { - anyOf: [ - { type: "string" }, - { - type: "object", - properties: { - name: { type: "string" }, - message: { - type: "string", - minLength: 1 - } - }, - additionalProperties: false, - required: ["name"] - } - ] - }, - uniqueItems: true -}; - -/** @type {import('../shared/types').Rule} */ -module.exports = { - meta: { - deprecated: true, - - replacedBy: [], - - type: "suggestion", - - docs: { - description: "Disallow specified modules when loaded by `require`", - recommended: false, - url: "https://eslint.org/docs/latest/rules/no-restricted-modules" - }, - - schema: { - anyOf: [ - arrayOfStringsOrObjects, - { - type: "array", - items: { - type: "object", - properties: { - paths: arrayOfStringsOrObjects, - patterns: arrayOfStrings - }, - additionalProperties: false - }, - additionalItems: false - } - ] - }, - - messages: { - defaultMessage: "'{{name}}' module is restricted from being used.", - // eslint-disable-next-line eslint-plugin/report-message-format -- Custom message might not end in a period - customMessage: "'{{name}}' module is restricted from being used. {{customMessage}}", - patternMessage: "'{{name}}' module is restricted from being used by a pattern." - } - }, - - create(context) { - const options = Array.isArray(context.options) ? context.options : []; - const isPathAndPatternsObject = - typeof options[0] === "object" && - (Object.hasOwn(options[0], "paths") || Object.hasOwn(options[0], "patterns")); - - const restrictedPaths = (isPathAndPatternsObject ? options[0].paths : context.options) || []; - const restrictedPatterns = (isPathAndPatternsObject ? options[0].patterns : []) || []; - - const restrictedPathMessages = restrictedPaths.reduce((memo, importName) => { - if (typeof importName === "string") { - memo[importName] = null; - } else { - memo[importName.name] = importName.message; - } - return memo; - }, {}); - - // if no imports are restricted we don't need to check - if (Object.keys(restrictedPaths).length === 0 && restrictedPatterns.length === 0) { - return {}; - } - - // relative paths are supported for this rule - const ig = ignore({ allowRelativePaths: true }).add(restrictedPatterns); - - - /** - * Function to check if a node is a string literal. - * @param {ASTNode} node The node to check. - * @returns {boolean} If the node is a string literal. - */ - function isStringLiteral(node) { - return node && node.type === "Literal" && typeof node.value === "string"; - } - - /** - * Function to check if a node is a require call. - * @param {ASTNode} node The node to check. - * @returns {boolean} If the node is a require call. - */ - function isRequireCall(node) { - return node.callee.type === "Identifier" && node.callee.name === "require"; - } - - /** - * Extract string from Literal or TemplateLiteral node - * @param {ASTNode} node The node to extract from - * @returns {string|null} Extracted string or null if node doesn't represent a string - */ - function getFirstArgumentString(node) { - if (isStringLiteral(node)) { - return node.value.trim(); - } - - if (astUtils.isStaticTemplateLiteral(node)) { - return node.quasis[0].value.cooked.trim(); - } - - return null; - } - - /** - * Report a restricted path. - * @param {node} node representing the restricted path reference - * @param {string} name restricted path - * @returns {void} - * @private - */ - function reportPath(node, name) { - const customMessage = restrictedPathMessages[name]; - const messageId = customMessage - ? "customMessage" - : "defaultMessage"; - - context.report({ - node, - messageId, - data: { - name, - customMessage - } - }); - } - - /** - * Check if the given name is a restricted path name - * @param {string} name name of a variable - * @returns {boolean} whether the variable is a restricted path or not - * @private - */ - function isRestrictedPath(name) { - return Object.hasOwn(restrictedPathMessages, name); - } - - return { - CallExpression(node) { - if (isRequireCall(node)) { - - // node has arguments - if (node.arguments.length) { - const name = getFirstArgumentString(node.arguments[0]); - - // if first argument is a string literal or a static string template literal - if (name) { - - // check if argument value is in restricted modules array - if (isRestrictedPath(name)) { - reportPath(node, name); - } - - if (restrictedPatterns.length > 0 && ig.ignores(name)) { - context.report({ - node, - messageId: "patternMessage", - data: { name } - }); - } - } - } - } - } - }; - } -}; diff --git a/tools/eslint/node_modules/eslint/lib/rules/no-restricted-properties.js b/tools/eslint/node_modules/eslint/lib/rules/no-restricted-properties.js deleted file mode 100644 index acd178ae53e8a7..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/rules/no-restricted-properties.js +++ /dev/null @@ -1,168 +0,0 @@ -/** - * @fileoverview Rule to disallow certain object properties - * @author Will Klein & Eli White - */ - -"use strict"; - -const astUtils = require("./utils/ast-utils"); - -//------------------------------------------------------------------------------ -// Rule Definition -//------------------------------------------------------------------------------ - -/** @type {import('../shared/types').Rule} */ -module.exports = { - meta: { - type: "suggestion", - - docs: { - description: "Disallow certain properties on certain objects", - recommended: false, - url: "https://eslint.org/docs/latest/rules/no-restricted-properties" - }, - - schema: { - type: "array", - items: { - anyOf: [ // `object` and `property` are both optional, but at least one of them must be provided. - { - type: "object", - properties: { - object: { - type: "string" - }, - property: { - type: "string" - }, - message: { - type: "string" - } - }, - additionalProperties: false, - required: ["object"] - }, - { - type: "object", - properties: { - object: { - type: "string" - }, - property: { - type: "string" - }, - message: { - type: "string" - } - }, - additionalProperties: false, - required: ["property"] - } - ] - }, - uniqueItems: true - }, - - messages: { - // eslint-disable-next-line eslint-plugin/report-message-format -- Custom message might not end in a period - restrictedObjectProperty: "'{{objectName}}.{{propertyName}}' is restricted from being used.{{message}}", - // eslint-disable-next-line eslint-plugin/report-message-format -- Custom message might not end in a period - restrictedProperty: "'{{propertyName}}' is restricted from being used.{{message}}" - } - }, - - create(context) { - const restrictedCalls = context.options; - - if (restrictedCalls.length === 0) { - return {}; - } - - const restrictedProperties = new Map(); - const globallyRestrictedObjects = new Map(); - const globallyRestrictedProperties = new Map(); - - restrictedCalls.forEach(option => { - const objectName = option.object; - const propertyName = option.property; - - if (typeof objectName === "undefined") { - globallyRestrictedProperties.set(propertyName, { message: option.message }); - } else if (typeof propertyName === "undefined") { - globallyRestrictedObjects.set(objectName, { message: option.message }); - } else { - if (!restrictedProperties.has(objectName)) { - restrictedProperties.set(objectName, new Map()); - } - - restrictedProperties.get(objectName).set(propertyName, { - message: option.message - }); - } - }); - - /** - * Checks to see whether a property access is restricted, and reports it if so. - * @param {ASTNode} node The node to report - * @param {string} objectName The name of the object - * @param {string} propertyName The name of the property - * @returns {undefined} - */ - function checkPropertyAccess(node, objectName, propertyName) { - if (propertyName === null) { - return; - } - const matchedObject = restrictedProperties.get(objectName); - const matchedObjectProperty = matchedObject ? matchedObject.get(propertyName) : globallyRestrictedObjects.get(objectName); - const globalMatchedProperty = globallyRestrictedProperties.get(propertyName); - - if (matchedObjectProperty) { - const message = matchedObjectProperty.message ? ` ${matchedObjectProperty.message}` : ""; - - context.report({ - node, - messageId: "restrictedObjectProperty", - data: { - objectName, - propertyName, - message - } - }); - } else if (globalMatchedProperty) { - const message = globalMatchedProperty.message ? ` ${globalMatchedProperty.message}` : ""; - - context.report({ - node, - messageId: "restrictedProperty", - data: { - propertyName, - message - } - }); - } - } - - return { - MemberExpression(node) { - checkPropertyAccess(node, node.object && node.object.name, astUtils.getStaticPropertyName(node)); - }, - ObjectPattern(node) { - let objectName = null; - - if (node.parent.type === "VariableDeclarator") { - if (node.parent.init && node.parent.init.type === "Identifier") { - objectName = node.parent.init.name; - } - } else if (node.parent.type === "AssignmentExpression" || node.parent.type === "AssignmentPattern") { - if (node.parent.right.type === "Identifier") { - objectName = node.parent.right.name; - } - } - - node.properties.forEach(property => { - checkPropertyAccess(node, objectName, astUtils.getStaticPropertyName(property)); - }); - } - }; - } -}; diff --git a/tools/eslint/node_modules/eslint/lib/rules/no-restricted-syntax.js b/tools/eslint/node_modules/eslint/lib/rules/no-restricted-syntax.js deleted file mode 100644 index 930882c330ad37..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/rules/no-restricted-syntax.js +++ /dev/null @@ -1,70 +0,0 @@ -/** - * @fileoverview Rule to flag use of certain node types - * @author Burak Yigit Kaya - */ -"use strict"; - -//------------------------------------------------------------------------------ -// Rule Definition -//------------------------------------------------------------------------------ - -/** @type {import('../shared/types').Rule} */ -module.exports = { - meta: { - type: "suggestion", - - docs: { - description: "Disallow specified syntax", - recommended: false, - url: "https://eslint.org/docs/latest/rules/no-restricted-syntax" - }, - - schema: { - type: "array", - items: { - oneOf: [ - { - type: "string" - }, - { - type: "object", - properties: { - selector: { type: "string" }, - message: { type: "string" } - }, - required: ["selector"], - additionalProperties: false - } - ] - }, - uniqueItems: true, - minItems: 0 - }, - - messages: { - // eslint-disable-next-line eslint-plugin/report-message-format -- Custom message might not end in a period - restrictedSyntax: "{{message}}" - } - }, - - create(context) { - return context.options.reduce((result, selectorOrObject) => { - const isStringFormat = (typeof selectorOrObject === "string"); - const hasCustomMessage = !isStringFormat && Boolean(selectorOrObject.message); - - const selector = isStringFormat ? selectorOrObject : selectorOrObject.selector; - const message = hasCustomMessage ? selectorOrObject.message : `Using '${selector}' is not allowed.`; - - return Object.assign(result, { - [selector](node) { - context.report({ - node, - messageId: "restrictedSyntax", - data: { message } - }); - } - }); - }, {}); - - } -}; diff --git a/tools/eslint/node_modules/eslint/lib/rules/no-return-assign.js b/tools/eslint/node_modules/eslint/lib/rules/no-return-assign.js deleted file mode 100644 index 73caf0e6bd3e79..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/rules/no-return-assign.js +++ /dev/null @@ -1,80 +0,0 @@ -/** - * @fileoverview Rule to flag when return statement contains assignment - * @author Ilya Volodin - */ -"use strict"; - -//------------------------------------------------------------------------------ -// Requirements -//------------------------------------------------------------------------------ - -const astUtils = require("./utils/ast-utils"); - -//------------------------------------------------------------------------------ -// Helpers -//------------------------------------------------------------------------------ - -const SENTINEL_TYPE = /^(?:[a-zA-Z]+?Statement|ArrowFunctionExpression|FunctionExpression|ClassExpression)$/u; - -//------------------------------------------------------------------------------ -// Rule Definition -//------------------------------------------------------------------------------ - -/** @type {import('../shared/types').Rule} */ -module.exports = { - meta: { - type: "suggestion", - - docs: { - description: "Disallow assignment operators in `return` statements", - recommended: false, - url: "https://eslint.org/docs/latest/rules/no-return-assign" - }, - - schema: [ - { - enum: ["except-parens", "always"] - } - ], - - messages: { - returnAssignment: "Return statement should not contain assignment.", - arrowAssignment: "Arrow function should not return assignment." - } - }, - - create(context) { - const always = (context.options[0] || "except-parens") !== "except-parens"; - const sourceCode = context.sourceCode; - - return { - AssignmentExpression(node) { - if (!always && astUtils.isParenthesised(sourceCode, node)) { - return; - } - - let currentChild = node; - let parent = currentChild.parent; - - // Find ReturnStatement or ArrowFunctionExpression in ancestors. - while (parent && !SENTINEL_TYPE.test(parent.type)) { - currentChild = parent; - parent = parent.parent; - } - - // Reports. - if (parent && parent.type === "ReturnStatement") { - context.report({ - node: parent, - messageId: "returnAssignment" - }); - } else if (parent && parent.type === "ArrowFunctionExpression" && parent.body === currentChild) { - context.report({ - node: parent, - messageId: "arrowAssignment" - }); - } - } - }; - } -}; diff --git a/tools/eslint/node_modules/eslint/lib/rules/no-return-await.js b/tools/eslint/node_modules/eslint/lib/rules/no-return-await.js deleted file mode 100644 index 0c297411621027..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/rules/no-return-await.js +++ /dev/null @@ -1,135 +0,0 @@ -/** - * @fileoverview Disallows unnecessary `return await` - * @author Jordan Harband - * @deprecated in ESLint v8.46.0 - */ -"use strict"; - -const astUtils = require("./utils/ast-utils"); - -//------------------------------------------------------------------------------ -// Rule Definition -//------------------------------------------------------------------------------ - -/** @type {import('../shared/types').Rule} */ -module.exports = { - meta: { - hasSuggestions: true, - type: "suggestion", - - docs: { - description: "Disallow unnecessary `return await`", - - recommended: false, - - url: "https://eslint.org/docs/latest/rules/no-return-await" - }, - - fixable: null, - - deprecated: true, - - replacedBy: [], - - schema: [ - ], - - messages: { - removeAwait: "Remove redundant `await`.", - redundantUseOfAwait: "Redundant use of `await` on a return value." - } - }, - - create(context) { - - /** - * Reports a found unnecessary `await` expression. - * @param {ASTNode} node The node representing the `await` expression to report - * @returns {void} - */ - function reportUnnecessaryAwait(node) { - context.report({ - node: context.sourceCode.getFirstToken(node), - loc: node.loc, - messageId: "redundantUseOfAwait", - suggest: [ - { - messageId: "removeAwait", - fix(fixer) { - const sourceCode = context.sourceCode; - const [awaitToken, tokenAfterAwait] = sourceCode.getFirstTokens(node, 2); - - const areAwaitAndAwaitedExpressionOnTheSameLine = awaitToken.loc.start.line === tokenAfterAwait.loc.start.line; - - if (!areAwaitAndAwaitedExpressionOnTheSameLine) { - return null; - } - - const [startOfAwait, endOfAwait] = awaitToken.range; - - const characterAfterAwait = sourceCode.text[endOfAwait]; - const trimLength = characterAfterAwait === " " ? 1 : 0; - - const range = [startOfAwait, endOfAwait + trimLength]; - - return fixer.removeRange(range); - } - } - ] - - }); - } - - /** - * Determines whether a thrown error from this node will be caught/handled within this function rather than immediately halting - * this function. For example, a statement in a `try` block will always have an error handler. A statement in - * a `catch` block will only have an error handler if there is also a `finally` block. - * @param {ASTNode} node A node representing a location where an could be thrown - * @returns {boolean} `true` if a thrown error will be caught/handled in this function - */ - function hasErrorHandler(node) { - let ancestor = node; - - while (!astUtils.isFunction(ancestor) && ancestor.type !== "Program") { - if (ancestor.parent.type === "TryStatement" && (ancestor === ancestor.parent.block || ancestor === ancestor.parent.handler && ancestor.parent.finalizer)) { - return true; - } - ancestor = ancestor.parent; - } - return false; - } - - /** - * Checks if a node is placed in tail call position. Once `return` arguments (or arrow function expressions) can be a complex expression, - * an `await` expression could or could not be unnecessary by the definition of this rule. So we're looking for `await` expressions that are in tail position. - * @param {ASTNode} node A node representing the `await` expression to check - * @returns {boolean} The checking result - */ - function isInTailCallPosition(node) { - if (node.parent.type === "ArrowFunctionExpression") { - return true; - } - if (node.parent.type === "ReturnStatement") { - return !hasErrorHandler(node.parent); - } - if (node.parent.type === "ConditionalExpression" && (node === node.parent.consequent || node === node.parent.alternate)) { - return isInTailCallPosition(node.parent); - } - if (node.parent.type === "LogicalExpression" && node === node.parent.right) { - return isInTailCallPosition(node.parent); - } - if (node.parent.type === "SequenceExpression" && node === node.parent.expressions.at(-1)) { - return isInTailCallPosition(node.parent); - } - return false; - } - - return { - AwaitExpression(node) { - if (isInTailCallPosition(node) && !hasErrorHandler(node)) { - reportUnnecessaryAwait(node); - } - } - }; - } -}; diff --git a/tools/eslint/node_modules/eslint/lib/rules/no-script-url.js b/tools/eslint/node_modules/eslint/lib/rules/no-script-url.js deleted file mode 100644 index 1d16bde3c4feaa..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/rules/no-script-url.js +++ /dev/null @@ -1,61 +0,0 @@ -/** - * @fileoverview Rule to flag when using javascript: urls - * @author Ilya Volodin - */ -/* eslint no-script-url: 0 -- Code is checking to report such URLs */ - -"use strict"; - -const astUtils = require("./utils/ast-utils"); - -//------------------------------------------------------------------------------ -// Rule Definition -//------------------------------------------------------------------------------ - -/** @type {import('../shared/types').Rule} */ -module.exports = { - meta: { - type: "suggestion", - - docs: { - description: "Disallow `javascript:` urls", - recommended: false, - url: "https://eslint.org/docs/latest/rules/no-script-url" - }, - - schema: [], - - messages: { - unexpectedScriptURL: "Script URL is a form of eval." - } - }, - - create(context) { - - /** - * Check whether a node's static value starts with "javascript:" or not. - * And report an error for unexpected script URL. - * @param {ASTNode} node node to check - * @returns {void} - */ - function check(node) { - const value = astUtils.getStaticStringValue(node); - - if (typeof value === "string" && value.toLowerCase().indexOf("javascript:") === 0) { - context.report({ node, messageId: "unexpectedScriptURL" }); - } - } - return { - Literal(node) { - if (node.value && typeof node.value === "string") { - check(node); - } - }, - TemplateLiteral(node) { - if (!(node.parent && node.parent.type === "TaggedTemplateExpression")) { - check(node); - } - } - }; - } -}; diff --git a/tools/eslint/node_modules/eslint/lib/rules/no-self-assign.js b/tools/eslint/node_modules/eslint/lib/rules/no-self-assign.js deleted file mode 100644 index 33ac8fb50853ca..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/rules/no-self-assign.js +++ /dev/null @@ -1,183 +0,0 @@ -/** - * @fileoverview Rule to disallow assignments where both sides are exactly the same - * @author Toru Nagashima - */ - -"use strict"; - -//------------------------------------------------------------------------------ -// Requirements -//------------------------------------------------------------------------------ - -const astUtils = require("./utils/ast-utils"); - -//------------------------------------------------------------------------------ -// Helpers -//------------------------------------------------------------------------------ - -const SPACES = /\s+/gu; - -/** - * Traverses 2 Pattern nodes in parallel, then reports self-assignments. - * @param {ASTNode|null} left A left node to traverse. This is a Pattern or - * a Property. - * @param {ASTNode|null} right A right node to traverse. This is a Pattern or - * a Property. - * @param {boolean} props The flag to check member expressions as well. - * @param {Function} report A callback function to report. - * @returns {void} - */ -function eachSelfAssignment(left, right, props, report) { - if (!left || !right) { - - // do nothing - } else if ( - left.type === "Identifier" && - right.type === "Identifier" && - left.name === right.name - ) { - report(right); - } else if ( - left.type === "ArrayPattern" && - right.type === "ArrayExpression" - ) { - const end = Math.min(left.elements.length, right.elements.length); - - for (let i = 0; i < end; ++i) { - const leftElement = left.elements[i]; - const rightElement = right.elements[i]; - - // Avoid cases such as [...a] = [...a, 1] - if ( - leftElement && - leftElement.type === "RestElement" && - i < right.elements.length - 1 - ) { - break; - } - - eachSelfAssignment(leftElement, rightElement, props, report); - - // After a spread element, those indices are unknown. - if (rightElement && rightElement.type === "SpreadElement") { - break; - } - } - } else if ( - left.type === "RestElement" && - right.type === "SpreadElement" - ) { - eachSelfAssignment(left.argument, right.argument, props, report); - } else if ( - left.type === "ObjectPattern" && - right.type === "ObjectExpression" && - right.properties.length >= 1 - ) { - - /* - * Gets the index of the last spread property. - * It's possible to overwrite properties followed by it. - */ - let startJ = 0; - - for (let i = right.properties.length - 1; i >= 0; --i) { - const propType = right.properties[i].type; - - if (propType === "SpreadElement" || propType === "ExperimentalSpreadProperty") { - startJ = i + 1; - break; - } - } - - for (let i = 0; i < left.properties.length; ++i) { - for (let j = startJ; j < right.properties.length; ++j) { - eachSelfAssignment( - left.properties[i], - right.properties[j], - props, - report - ); - } - } - } else if ( - left.type === "Property" && - right.type === "Property" && - right.kind === "init" && - !right.method - ) { - const leftName = astUtils.getStaticPropertyName(left); - - if (leftName !== null && leftName === astUtils.getStaticPropertyName(right)) { - eachSelfAssignment(left.value, right.value, props, report); - } - } else if ( - props && - astUtils.skipChainExpression(left).type === "MemberExpression" && - astUtils.skipChainExpression(right).type === "MemberExpression" && - astUtils.isSameReference(left, right) - ) { - report(right); - } -} - -//------------------------------------------------------------------------------ -// Rule Definition -//------------------------------------------------------------------------------ - -/** @type {import('../shared/types').Rule} */ -module.exports = { - meta: { - type: "problem", - - docs: { - description: "Disallow assignments where both sides are exactly the same", - recommended: true, - url: "https://eslint.org/docs/latest/rules/no-self-assign" - }, - - schema: [ - { - type: "object", - properties: { - props: { - type: "boolean", - default: true - } - }, - additionalProperties: false - } - ], - - messages: { - selfAssignment: "'{{name}}' is assigned to itself." - } - }, - - create(context) { - const sourceCode = context.sourceCode; - const [{ props = true } = {}] = context.options; - - /** - * Reports a given node as self assignments. - * @param {ASTNode} node A node to report. This is an Identifier node. - * @returns {void} - */ - function report(node) { - context.report({ - node, - messageId: "selfAssignment", - data: { - name: sourceCode.getText(node).replace(SPACES, "") - } - }); - } - - return { - AssignmentExpression(node) { - if (["=", "&&=", "||=", "??="].includes(node.operator)) { - eachSelfAssignment(node.left, node.right, props, report); - } - } - }; - } -}; diff --git a/tools/eslint/node_modules/eslint/lib/rules/no-self-compare.js b/tools/eslint/node_modules/eslint/lib/rules/no-self-compare.js deleted file mode 100644 index 3b076eba83c75b..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/rules/no-self-compare.js +++ /dev/null @@ -1,60 +0,0 @@ -/** - * @fileoverview Rule to flag comparison where left part is the same as the right - * part. - * @author Ilya Volodin - */ - -"use strict"; - -//------------------------------------------------------------------------------ -// Rule Definition -//------------------------------------------------------------------------------ - -/** @type {import('../shared/types').Rule} */ -module.exports = { - meta: { - type: "problem", - - docs: { - description: "Disallow comparisons where both sides are exactly the same", - recommended: false, - url: "https://eslint.org/docs/latest/rules/no-self-compare" - }, - - schema: [], - - messages: { - comparingToSelf: "Comparing to itself is potentially pointless." - } - }, - - create(context) { - const sourceCode = context.sourceCode; - - /** - * Determines whether two nodes are composed of the same tokens. - * @param {ASTNode} nodeA The first node - * @param {ASTNode} nodeB The second node - * @returns {boolean} true if the nodes have identical token representations - */ - function hasSameTokens(nodeA, nodeB) { - const tokensA = sourceCode.getTokens(nodeA); - const tokensB = sourceCode.getTokens(nodeB); - - return tokensA.length === tokensB.length && - tokensA.every((token, index) => token.type === tokensB[index].type && token.value === tokensB[index].value); - } - - return { - - BinaryExpression(node) { - const operators = new Set(["===", "==", "!==", "!=", ">", "<", ">=", "<="]); - - if (operators.has(node.operator) && hasSameTokens(node.left, node.right)) { - context.report({ node, messageId: "comparingToSelf" }); - } - } - }; - - } -}; diff --git a/tools/eslint/node_modules/eslint/lib/rules/no-sequences.js b/tools/eslint/node_modules/eslint/lib/rules/no-sequences.js deleted file mode 100644 index 5822a24542fa77..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/rules/no-sequences.js +++ /dev/null @@ -1,139 +0,0 @@ -/** - * @fileoverview Rule to flag use of comma operator - * @author Brandon Mills - */ - -"use strict"; - -//------------------------------------------------------------------------------ -// Requirements -//------------------------------------------------------------------------------ - -const astUtils = require("./utils/ast-utils"); - -//------------------------------------------------------------------------------ -// Helpers -//------------------------------------------------------------------------------ - -const DEFAULT_OPTIONS = { - allowInParentheses: true -}; - -//------------------------------------------------------------------------------ -// Rule Definition -//------------------------------------------------------------------------------ - -/** @type {import('../shared/types').Rule} */ -module.exports = { - meta: { - type: "suggestion", - - docs: { - description: "Disallow comma operators", - recommended: false, - url: "https://eslint.org/docs/latest/rules/no-sequences" - }, - - schema: [{ - type: "object", - properties: { - allowInParentheses: { - type: "boolean", - default: true - } - }, - additionalProperties: false - }], - - messages: { - unexpectedCommaExpression: "Unexpected use of comma operator." - } - }, - - create(context) { - const options = Object.assign({}, DEFAULT_OPTIONS, context.options[0]); - const sourceCode = context.sourceCode; - - /** - * Parts of the grammar that are required to have parens. - */ - const parenthesized = { - DoWhileStatement: "test", - IfStatement: "test", - SwitchStatement: "discriminant", - WhileStatement: "test", - WithStatement: "object", - ArrowFunctionExpression: "body" - - /* - * Omitting CallExpression - commas are parsed as argument separators - * Omitting NewExpression - commas are parsed as argument separators - * Omitting ForInStatement - parts aren't individually parenthesised - * Omitting ForStatement - parts aren't individually parenthesised - */ - }; - - /** - * Determines whether a node is required by the grammar to be wrapped in - * parens, e.g. the test of an if statement. - * @param {ASTNode} node The AST node - * @returns {boolean} True if parens around node belong to parent node. - */ - function requiresExtraParens(node) { - return node.parent && parenthesized[node.parent.type] && - node === node.parent[parenthesized[node.parent.type]]; - } - - /** - * Check if a node is wrapped in parens. - * @param {ASTNode} node The AST node - * @returns {boolean} True if the node has a paren on each side. - */ - function isParenthesised(node) { - return astUtils.isParenthesised(sourceCode, node); - } - - /** - * Check if a node is wrapped in two levels of parens. - * @param {ASTNode} node The AST node - * @returns {boolean} True if two parens surround the node on each side. - */ - function isParenthesisedTwice(node) { - const previousToken = sourceCode.getTokenBefore(node, 1), - nextToken = sourceCode.getTokenAfter(node, 1); - - return isParenthesised(node) && previousToken && nextToken && - astUtils.isOpeningParenToken(previousToken) && previousToken.range[1] <= node.range[0] && - astUtils.isClosingParenToken(nextToken) && nextToken.range[0] >= node.range[1]; - } - - return { - SequenceExpression(node) { - - // Always allow sequences in for statement update - if (node.parent.type === "ForStatement" && - (node === node.parent.init || node === node.parent.update)) { - return; - } - - // Wrapping a sequence in extra parens indicates intent - if (options.allowInParentheses) { - if (requiresExtraParens(node)) { - if (isParenthesisedTwice(node)) { - return; - } - } else { - if (isParenthesised(node)) { - return; - } - } - } - - const firstCommaToken = sourceCode.getTokenAfter(node.expressions[0], astUtils.isCommaToken); - - context.report({ node, loc: firstCommaToken.loc, messageId: "unexpectedCommaExpression" }); - } - }; - - } -}; diff --git a/tools/eslint/node_modules/eslint/lib/rules/no-setter-return.js b/tools/eslint/node_modules/eslint/lib/rules/no-setter-return.js deleted file mode 100644 index a5abaaa7e53f20..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/rules/no-setter-return.js +++ /dev/null @@ -1,226 +0,0 @@ -/** - * @fileoverview Rule to disallow returning values from setters - * @author Milos Djermanovic - */ - -"use strict"; - -//------------------------------------------------------------------------------ -// Requirements -//------------------------------------------------------------------------------ - -const astUtils = require("./utils/ast-utils"); -const { findVariable } = require("@eslint-community/eslint-utils"); - -//------------------------------------------------------------------------------ -// Helpers -//------------------------------------------------------------------------------ - -/** - * Determines whether the given identifier node is a reference to a global variable. - * @param {ASTNode} node `Identifier` node to check. - * @param {Scope} scope Scope to which the node belongs. - * @returns {boolean} True if the identifier is a reference to a global variable. - */ -function isGlobalReference(node, scope) { - const variable = findVariable(scope, node); - - return variable !== null && variable.scope.type === "global" && variable.defs.length === 0; -} - -/** - * Determines whether the given node is an argument of the specified global method call, at the given `index` position. - * E.g., for given `index === 1`, this function checks for `objectName.methodName(foo, node)`, where objectName is a global variable. - * @param {ASTNode} node The node to check. - * @param {Scope} scope Scope to which the node belongs. - * @param {string} objectName Name of the global object. - * @param {string} methodName Name of the method. - * @param {number} index The given position. - * @returns {boolean} `true` if the node is argument at the given position. - */ -function isArgumentOfGlobalMethodCall(node, scope, objectName, methodName, index) { - const callNode = node.parent; - - return callNode.type === "CallExpression" && - callNode.arguments[index] === node && - astUtils.isSpecificMemberAccess(callNode.callee, objectName, methodName) && - isGlobalReference(astUtils.skipChainExpression(callNode.callee).object, scope); -} - -/** - * Determines whether the given node is used as a property descriptor. - * @param {ASTNode} node The node to check. - * @param {Scope} scope Scope to which the node belongs. - * @returns {boolean} `true` if the node is a property descriptor. - */ -function isPropertyDescriptor(node, scope) { - if ( - isArgumentOfGlobalMethodCall(node, scope, "Object", "defineProperty", 2) || - isArgumentOfGlobalMethodCall(node, scope, "Reflect", "defineProperty", 2) - ) { - return true; - } - - const parent = node.parent; - - if ( - parent.type === "Property" && - parent.value === node - ) { - const grandparent = parent.parent; - - if ( - grandparent.type === "ObjectExpression" && - ( - isArgumentOfGlobalMethodCall(grandparent, scope, "Object", "create", 1) || - isArgumentOfGlobalMethodCall(grandparent, scope, "Object", "defineProperties", 1) - ) - ) { - return true; - } - } - - return false; -} - -/** - * Determines whether the given function node is used as a setter function. - * @param {ASTNode} node The node to check. - * @param {Scope} scope Scope to which the node belongs. - * @returns {boolean} `true` if the node is a setter. - */ -function isSetter(node, scope) { - const parent = node.parent; - - if ( - (parent.type === "Property" || parent.type === "MethodDefinition") && - parent.kind === "set" && - parent.value === node - ) { - - // Setter in an object literal or in a class - return true; - } - - if ( - parent.type === "Property" && - parent.value === node && - astUtils.getStaticPropertyName(parent) === "set" && - parent.parent.type === "ObjectExpression" && - isPropertyDescriptor(parent.parent, scope) - ) { - - // Setter in a property descriptor - return true; - } - - return false; -} - -/** - * Finds function's outer scope. - * @param {Scope} scope Function's own scope. - * @returns {Scope} Function's outer scope. - */ -function getOuterScope(scope) { - const upper = scope.upper; - - if (upper.type === "function-expression-name") { - return upper.upper; - } - - return upper; -} - -//------------------------------------------------------------------------------ -// Rule Definition -//------------------------------------------------------------------------------ - -/** @type {import('../shared/types').Rule} */ -module.exports = { - meta: { - type: "problem", - - docs: { - description: "Disallow returning values from setters", - recommended: true, - url: "https://eslint.org/docs/latest/rules/no-setter-return" - }, - - schema: [], - - messages: { - returnsValue: "Setter cannot return a value." - } - }, - - create(context) { - let funcInfo = null; - const sourceCode = context.sourceCode; - - /** - * Creates and pushes to the stack a function info object for the given function node. - * @param {ASTNode} node The function node. - * @returns {void} - */ - function enterFunction(node) { - const outerScope = getOuterScope(sourceCode.getScope(node)); - - funcInfo = { - upper: funcInfo, - isSetter: isSetter(node, outerScope) - }; - } - - /** - * Pops the current function info object from the stack. - * @returns {void} - */ - function exitFunction() { - funcInfo = funcInfo.upper; - } - - /** - * Reports the given node. - * @param {ASTNode} node Node to report. - * @returns {void} - */ - function report(node) { - context.report({ node, messageId: "returnsValue" }); - } - - return { - - /* - * Function declarations cannot be setters, but we still have to track them in the `funcInfo` stack to avoid - * false positives, because a ReturnStatement node can belong to a function declaration inside a setter. - * - * Note: A previously declared function can be referenced and actually used as a setter in a property descriptor, - * but that's out of scope for this rule. - */ - FunctionDeclaration: enterFunction, - FunctionExpression: enterFunction, - ArrowFunctionExpression(node) { - enterFunction(node); - - if (funcInfo.isSetter && node.expression) { - - // { set: foo => bar } property descriptor. Report implicit return 'bar' as the equivalent for a return statement. - report(node.body); - } - }, - - "FunctionDeclaration:exit": exitFunction, - "FunctionExpression:exit": exitFunction, - "ArrowFunctionExpression:exit": exitFunction, - - ReturnStatement(node) { - - // Global returns (e.g., at the top level of a Node module) don't have `funcInfo`. - if (funcInfo && funcInfo.isSetter && node.argument) { - report(node); - } - } - }; - } -}; diff --git a/tools/eslint/node_modules/eslint/lib/rules/no-shadow-restricted-names.js b/tools/eslint/node_modules/eslint/lib/rules/no-shadow-restricted-names.js deleted file mode 100644 index 29560fffc7f0b6..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/rules/no-shadow-restricted-names.js +++ /dev/null @@ -1,65 +0,0 @@ -/** - * @fileoverview Disallow shadowing of NaN, undefined, and Infinity (ES5 section 15.1.1) - * @author Michael Ficarra - */ -"use strict"; - -/** - * Determines if a variable safely shadows undefined. - * This is the case when a variable named `undefined` is never assigned to a value (i.e. it always shares the same value - * as the global). - * @param {eslintScope.Variable} variable The variable to check - * @returns {boolean} true if this variable safely shadows `undefined` - */ -function safelyShadowsUndefined(variable) { - return variable.name === "undefined" && - variable.references.every(ref => !ref.isWrite()) && - variable.defs.every(def => def.node.type === "VariableDeclarator" && def.node.init === null); -} - -//------------------------------------------------------------------------------ -// Rule Definition -//------------------------------------------------------------------------------ - -/** @type {import('../shared/types').Rule} */ -module.exports = { - meta: { - type: "suggestion", - - docs: { - description: "Disallow identifiers from shadowing restricted names", - recommended: true, - url: "https://eslint.org/docs/latest/rules/no-shadow-restricted-names" - }, - - schema: [], - - messages: { - shadowingRestrictedName: "Shadowing of global property '{{name}}'." - } - }, - - create(context) { - - - const RESTRICTED = new Set(["undefined", "NaN", "Infinity", "arguments", "eval"]); - const sourceCode = context.sourceCode; - - return { - "VariableDeclaration, :function, CatchClause"(node) { - for (const variable of sourceCode.getDeclaredVariables(node)) { - if (variable.defs.length > 0 && RESTRICTED.has(variable.name) && !safelyShadowsUndefined(variable)) { - context.report({ - node: variable.defs[0].name, - messageId: "shadowingRestrictedName", - data: { - name: variable.name - } - }); - } - } - } - }; - - } -}; diff --git a/tools/eslint/node_modules/eslint/lib/rules/no-shadow.js b/tools/eslint/node_modules/eslint/lib/rules/no-shadow.js deleted file mode 100644 index 3e4d99822a80a7..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/rules/no-shadow.js +++ /dev/null @@ -1,336 +0,0 @@ -/** - * @fileoverview Rule to flag on declaring variables already declared in the outer scope - * @author Ilya Volodin - */ - -"use strict"; - -//------------------------------------------------------------------------------ -// Requirements -//------------------------------------------------------------------------------ - -const astUtils = require("./utils/ast-utils"); - -//------------------------------------------------------------------------------ -// Helpers -//------------------------------------------------------------------------------ - -const FUNC_EXPR_NODE_TYPES = new Set(["ArrowFunctionExpression", "FunctionExpression"]); -const CALL_EXPR_NODE_TYPE = new Set(["CallExpression"]); -const FOR_IN_OF_TYPE = /^For(?:In|Of)Statement$/u; -const SENTINEL_TYPE = /^(?:(?:Function|Class)(?:Declaration|Expression)|ArrowFunctionExpression|CatchClause|ImportDeclaration|ExportNamedDeclaration)$/u; - -//------------------------------------------------------------------------------ -// Rule Definition -//------------------------------------------------------------------------------ - -/** @type {import('../shared/types').Rule} */ -module.exports = { - meta: { - type: "suggestion", - - docs: { - description: "Disallow variable declarations from shadowing variables declared in the outer scope", - recommended: false, - url: "https://eslint.org/docs/latest/rules/no-shadow" - }, - - schema: [ - { - type: "object", - properties: { - builtinGlobals: { type: "boolean", default: false }, - hoist: { enum: ["all", "functions", "never"], default: "functions" }, - allow: { - type: "array", - items: { - type: "string" - } - }, - ignoreOnInitialization: { type: "boolean", default: false } - }, - additionalProperties: false - } - ], - - messages: { - noShadow: "'{{name}}' is already declared in the upper scope on line {{shadowedLine}} column {{shadowedColumn}}.", - noShadowGlobal: "'{{name}}' is already a global variable." - } - }, - - create(context) { - - const options = { - builtinGlobals: context.options[0] && context.options[0].builtinGlobals, - hoist: (context.options[0] && context.options[0].hoist) || "functions", - allow: (context.options[0] && context.options[0].allow) || [], - ignoreOnInitialization: context.options[0] && context.options[0].ignoreOnInitialization - }; - const sourceCode = context.sourceCode; - - /** - * Checks whether or not a given location is inside of the range of a given node. - * @param {ASTNode} node An node to check. - * @param {number} location A location to check. - * @returns {boolean} `true` if the location is inside of the range of the node. - */ - function isInRange(node, location) { - return node && node.range[0] <= location && location <= node.range[1]; - } - - /** - * Searches from the current node through its ancestry to find a matching node. - * @param {ASTNode} node a node to get. - * @param {(node: ASTNode) => boolean} match a callback that checks whether or not the node verifies its condition or not. - * @returns {ASTNode|null} the matching node. - */ - function findSelfOrAncestor(node, match) { - let currentNode = node; - - while (currentNode && !match(currentNode)) { - currentNode = currentNode.parent; - } - return currentNode; - } - - /** - * Finds function's outer scope. - * @param {Scope} scope Function's own scope. - * @returns {Scope} Function's outer scope. - */ - function getOuterScope(scope) { - const upper = scope.upper; - - if (upper.type === "function-expression-name") { - return upper.upper; - } - return upper; - } - - /** - * Checks if a variable and a shadowedVariable have the same init pattern ancestor. - * @param {Object} variable a variable to check. - * @param {Object} shadowedVariable a shadowedVariable to check. - * @returns {boolean} Whether or not the variable and the shadowedVariable have the same init pattern ancestor. - */ - function isInitPatternNode(variable, shadowedVariable) { - const outerDef = shadowedVariable.defs[0]; - - if (!outerDef) { - return false; - } - - const { variableScope } = variable.scope; - - - if (!(FUNC_EXPR_NODE_TYPES.has(variableScope.block.type) && getOuterScope(variableScope) === shadowedVariable.scope)) { - return false; - } - - const fun = variableScope.block; - const { parent } = fun; - - const callExpression = findSelfOrAncestor( - parent, - node => CALL_EXPR_NODE_TYPE.has(node.type) - ); - - if (!callExpression) { - return false; - } - - let node = outerDef.name; - const location = callExpression.range[1]; - - while (node) { - if (node.type === "VariableDeclarator") { - if (isInRange(node.init, location)) { - return true; - } - if (FOR_IN_OF_TYPE.test(node.parent.parent.type) && - isInRange(node.parent.parent.right, location) - ) { - return true; - } - break; - } else if (node.type === "AssignmentPattern") { - if (isInRange(node.right, location)) { - return true; - } - } else if (SENTINEL_TYPE.test(node.type)) { - break; - } - - node = node.parent; - } - - return false; - } - - /** - * Check if variable name is allowed. - * @param {ASTNode} variable The variable to check. - * @returns {boolean} Whether or not the variable name is allowed. - */ - function isAllowed(variable) { - return options.allow.includes(variable.name); - } - - /** - * Checks if a variable of the class name in the class scope of ClassDeclaration. - * - * ClassDeclaration creates two variables of its name into its outer scope and its class scope. - * So we should ignore the variable in the class scope. - * @param {Object} variable The variable to check. - * @returns {boolean} Whether or not the variable of the class name in the class scope of ClassDeclaration. - */ - function isDuplicatedClassNameVariable(variable) { - const block = variable.scope.block; - - return block.type === "ClassDeclaration" && block.id === variable.identifiers[0]; - } - - /** - * Checks if a variable is inside the initializer of scopeVar. - * - * To avoid reporting at declarations such as `var a = function a() {};`. - * But it should report `var a = function(a) {};` or `var a = function() { function a() {} };`. - * @param {Object} variable The variable to check. - * @param {Object} scopeVar The scope variable to look for. - * @returns {boolean} Whether or not the variable is inside initializer of scopeVar. - */ - function isOnInitializer(variable, scopeVar) { - const outerScope = scopeVar.scope; - const outerDef = scopeVar.defs[0]; - const outer = outerDef && outerDef.parent && outerDef.parent.range; - const innerScope = variable.scope; - const innerDef = variable.defs[0]; - const inner = innerDef && innerDef.name.range; - - return ( - outer && - inner && - outer[0] < inner[0] && - inner[1] < outer[1] && - ((innerDef.type === "FunctionName" && innerDef.node.type === "FunctionExpression") || innerDef.node.type === "ClassExpression") && - outerScope === innerScope.upper - ); - } - - /** - * Get a range of a variable's identifier node. - * @param {Object} variable The variable to get. - * @returns {Array|undefined} The range of the variable's identifier node. - */ - function getNameRange(variable) { - const def = variable.defs[0]; - - return def && def.name.range; - } - - /** - * Get declared line and column of a variable. - * @param {eslint-scope.Variable} variable The variable to get. - * @returns {Object} The declared line and column of the variable. - */ - function getDeclaredLocation(variable) { - const identifier = variable.identifiers[0]; - let obj; - - if (identifier) { - obj = { - global: false, - line: identifier.loc.start.line, - column: identifier.loc.start.column + 1 - }; - } else { - obj = { - global: true - }; - } - return obj; - } - - /** - * Checks if a variable is in TDZ of scopeVar. - * @param {Object} variable The variable to check. - * @param {Object} scopeVar The variable of TDZ. - * @returns {boolean} Whether or not the variable is in TDZ of scopeVar. - */ - function isInTdz(variable, scopeVar) { - const outerDef = scopeVar.defs[0]; - const inner = getNameRange(variable); - const outer = getNameRange(scopeVar); - - return ( - inner && - outer && - inner[1] < outer[0] && - - // Excepts FunctionDeclaration if is {"hoist":"function"}. - (options.hoist !== "functions" || !outerDef || outerDef.node.type !== "FunctionDeclaration") - ); - } - - /** - * Checks the current context for shadowed variables. - * @param {Scope} scope Fixme - * @returns {void} - */ - function checkForShadows(scope) { - const variables = scope.variables; - - for (let i = 0; i < variables.length; ++i) { - const variable = variables[i]; - - // Skips "arguments" or variables of a class name in the class scope of ClassDeclaration. - if (variable.identifiers.length === 0 || - isDuplicatedClassNameVariable(variable) || - isAllowed(variable) - ) { - continue; - } - - // Gets shadowed variable. - const shadowed = astUtils.getVariableByName(scope.upper, variable.name); - - if (shadowed && - (shadowed.identifiers.length > 0 || (options.builtinGlobals && "writeable" in shadowed)) && - !isOnInitializer(variable, shadowed) && - !(options.ignoreOnInitialization && isInitPatternNode(variable, shadowed)) && - !(options.hoist !== "all" && isInTdz(variable, shadowed)) - ) { - const location = getDeclaredLocation(shadowed); - const messageId = location.global ? "noShadowGlobal" : "noShadow"; - const data = { name: variable.name }; - - if (!location.global) { - data.shadowedLine = location.line; - data.shadowedColumn = location.column; - } - context.report({ - node: variable.identifiers[0], - messageId, - data - }); - } - } - } - - return { - "Program:exit"(node) { - const globalScope = sourceCode.getScope(node); - const stack = globalScope.childScopes.slice(); - - while (stack.length) { - const scope = stack.pop(); - - stack.push(...scope.childScopes); - checkForShadows(scope); - } - } - }; - - } -}; diff --git a/tools/eslint/node_modules/eslint/lib/rules/no-spaced-func.js b/tools/eslint/node_modules/eslint/lib/rules/no-spaced-func.js deleted file mode 100644 index d79c18440b0057..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/rules/no-spaced-func.js +++ /dev/null @@ -1,83 +0,0 @@ -/** - * @fileoverview Rule to check that spaced function application - * @author Matt DuVall - * @deprecated in ESLint v3.3.0 - */ - -"use strict"; - -//------------------------------------------------------------------------------ -// Rule Definition -//------------------------------------------------------------------------------ - -/** @type {import('../shared/types').Rule} */ -module.exports = { - meta: { - type: "layout", - - docs: { - description: "Disallow spacing between function identifiers and their applications (deprecated)", - recommended: false, - url: "https://eslint.org/docs/latest/rules/no-spaced-func" - }, - - deprecated: true, - - replacedBy: ["func-call-spacing"], - - fixable: "whitespace", - schema: [], - - messages: { - noSpacedFunction: "Unexpected space between function name and paren." - } - }, - - create(context) { - - const sourceCode = context.sourceCode; - - /** - * Check if open space is present in a function name - * @param {ASTNode} node node to evaluate - * @returns {void} - * @private - */ - function detectOpenSpaces(node) { - const lastCalleeToken = sourceCode.getLastToken(node.callee); - let prevToken = lastCalleeToken, - parenToken = sourceCode.getTokenAfter(lastCalleeToken); - - // advances to an open parenthesis. - while ( - parenToken && - parenToken.range[1] < node.range[1] && - parenToken.value !== "(" - ) { - prevToken = parenToken; - parenToken = sourceCode.getTokenAfter(parenToken); - } - - // look for a space between the callee and the open paren - if (parenToken && - parenToken.range[1] < node.range[1] && - sourceCode.isSpaceBetweenTokens(prevToken, parenToken) - ) { - context.report({ - node, - loc: lastCalleeToken.loc.start, - messageId: "noSpacedFunction", - fix(fixer) { - return fixer.removeRange([prevToken.range[1], parenToken.range[0]]); - } - }); - } - } - - return { - CallExpression: detectOpenSpaces, - NewExpression: detectOpenSpaces - }; - - } -}; diff --git a/tools/eslint/node_modules/eslint/lib/rules/no-sparse-arrays.js b/tools/eslint/node_modules/eslint/lib/rules/no-sparse-arrays.js deleted file mode 100644 index 6d24842fb2478b..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/rules/no-sparse-arrays.js +++ /dev/null @@ -1,73 +0,0 @@ -/** - * @fileoverview Disallow sparse arrays - * @author Nicholas C. Zakas - */ -"use strict"; - -const astUtils = require("./utils/ast-utils"); - -//------------------------------------------------------------------------------ -// Rule Definition -//------------------------------------------------------------------------------ - -/** @type {import('../shared/types').Rule} */ -module.exports = { - meta: { - type: "problem", - - docs: { - description: "Disallow sparse arrays", - recommended: true, - url: "https://eslint.org/docs/latest/rules/no-sparse-arrays" - }, - - schema: [], - - messages: { - unexpectedSparseArray: "Unexpected comma in middle of array." - } - }, - - create(context) { - - - //-------------------------------------------------------------------------- - // Public - //-------------------------------------------------------------------------- - - return { - - ArrayExpression(node) { - if (!node.elements.includes(null)) { - return; - } - - const { sourceCode } = context; - let commaToken; - - for (const [index, element] of node.elements.entries()) { - if (index === node.elements.length - 1 && element) { - return; - } - - commaToken = sourceCode.getTokenAfter( - element ?? commaToken ?? sourceCode.getFirstToken(node), - astUtils.isCommaToken - ); - - if (element) { - continue; - } - - context.report({ - node, - loc: commaToken.loc, - messageId: "unexpectedSparseArray" - }); - } - } - - }; - - } -}; diff --git a/tools/eslint/node_modules/eslint/lib/rules/no-sync.js b/tools/eslint/node_modules/eslint/lib/rules/no-sync.js deleted file mode 100644 index 8f79a36b40e068..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/rules/no-sync.js +++ /dev/null @@ -1,64 +0,0 @@ -/** - * @fileoverview Rule to check for properties whose identifier ends with the string Sync - * @author Matt DuVall - * @deprecated in ESLint v7.0.0 - */ - -"use strict"; - -//------------------------------------------------------------------------------ -// Rule Definition -//------------------------------------------------------------------------------ - -/** @type {import('../shared/types').Rule} */ -module.exports = { - meta: { - deprecated: true, - - replacedBy: [], - - type: "suggestion", - - docs: { - description: "Disallow synchronous methods", - recommended: false, - url: "https://eslint.org/docs/latest/rules/no-sync" - }, - - schema: [ - { - type: "object", - properties: { - allowAtRootLevel: { - type: "boolean", - default: false - } - }, - additionalProperties: false - } - ], - - messages: { - noSync: "Unexpected sync method: '{{propertyName}}'." - } - }, - - create(context) { - const selector = context.options[0] && context.options[0].allowAtRootLevel - ? ":function MemberExpression[property.name=/.*Sync$/]" - : "MemberExpression[property.name=/.*Sync$/]"; - - return { - [selector](node) { - context.report({ - node, - messageId: "noSync", - data: { - propertyName: node.property.name - } - }); - } - }; - - } -}; diff --git a/tools/eslint/node_modules/eslint/lib/rules/no-tabs.js b/tools/eslint/node_modules/eslint/lib/rules/no-tabs.js deleted file mode 100644 index 8581e19af37333..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/rules/no-tabs.js +++ /dev/null @@ -1,81 +0,0 @@ -/** - * @fileoverview Rule to check for tabs inside a file - * @author Gyandeep Singh - * @deprecated in ESLint v8.53.0 - */ - -"use strict"; - -//------------------------------------------------------------------------------ -// Helpers -//------------------------------------------------------------------------------ - -const tabRegex = /\t+/gu; -const anyNonWhitespaceRegex = /\S/u; - -//------------------------------------------------------------------------------ -// Public Interface -//------------------------------------------------------------------------------ - -/** @type {import('../shared/types').Rule} */ -module.exports = { - meta: { - deprecated: true, - replacedBy: [], - type: "layout", - - docs: { - description: "Disallow all tabs", - recommended: false, - url: "https://eslint.org/docs/latest/rules/no-tabs" - }, - schema: [{ - type: "object", - properties: { - allowIndentationTabs: { - type: "boolean", - default: false - } - }, - additionalProperties: false - }], - - messages: { - unexpectedTab: "Unexpected tab character." - } - }, - - create(context) { - const sourceCode = context.sourceCode; - const allowIndentationTabs = context.options && context.options[0] && context.options[0].allowIndentationTabs; - - return { - Program(node) { - sourceCode.getLines().forEach((line, index) => { - let match; - - while ((match = tabRegex.exec(line)) !== null) { - if (allowIndentationTabs && !anyNonWhitespaceRegex.test(line.slice(0, match.index))) { - continue; - } - - context.report({ - node, - loc: { - start: { - line: index + 1, - column: match.index - }, - end: { - line: index + 1, - column: match.index + match[0].length - } - }, - messageId: "unexpectedTab" - }); - } - }); - } - }; - } -}; diff --git a/tools/eslint/node_modules/eslint/lib/rules/no-template-curly-in-string.js b/tools/eslint/node_modules/eslint/lib/rules/no-template-curly-in-string.js deleted file mode 100644 index 92b4c1c86cde8f..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/rules/no-template-curly-in-string.js +++ /dev/null @@ -1,44 +0,0 @@ -/** - * @fileoverview Warn when using template string syntax in regular strings - * @author Jeroen Engels - */ -"use strict"; - -//------------------------------------------------------------------------------ -// Rule Definition -//------------------------------------------------------------------------------ - -/** @type {import('../shared/types').Rule} */ -module.exports = { - meta: { - type: "problem", - - docs: { - description: "Disallow template literal placeholder syntax in regular strings", - recommended: false, - url: "https://eslint.org/docs/latest/rules/no-template-curly-in-string" - }, - - schema: [], - - messages: { - unexpectedTemplateExpression: "Unexpected template string expression." - } - }, - - create(context) { - const regex = /\$\{[^}]+\}/u; - - return { - Literal(node) { - if (typeof node.value === "string" && regex.test(node.value)) { - context.report({ - node, - messageId: "unexpectedTemplateExpression" - }); - } - } - }; - - } -}; diff --git a/tools/eslint/node_modules/eslint/lib/rules/no-ternary.js b/tools/eslint/node_modules/eslint/lib/rules/no-ternary.js deleted file mode 100644 index 4d43c7e022d91a..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/rules/no-ternary.js +++ /dev/null @@ -1,41 +0,0 @@ -/** - * @fileoverview Rule to flag use of ternary operators. - * @author Ian Christian Myers - */ - -"use strict"; - -//------------------------------------------------------------------------------ -// Rule Definition -//------------------------------------------------------------------------------ - -/** @type {import('../shared/types').Rule} */ -module.exports = { - meta: { - type: "suggestion", - - docs: { - description: "Disallow ternary operators", - recommended: false, - url: "https://eslint.org/docs/latest/rules/no-ternary" - }, - - schema: [], - - messages: { - noTernaryOperator: "Ternary operator used." - } - }, - - create(context) { - - return { - - ConditionalExpression(node) { - context.report({ node, messageId: "noTernaryOperator" }); - } - - }; - - } -}; diff --git a/tools/eslint/node_modules/eslint/lib/rules/no-this-before-super.js b/tools/eslint/node_modules/eslint/lib/rules/no-this-before-super.js deleted file mode 100644 index 01e355acbd14a8..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/rules/no-this-before-super.js +++ /dev/null @@ -1,363 +0,0 @@ -/** - * @fileoverview A rule to disallow using `this`/`super` before `super()`. - * @author Toru Nagashima - */ - -"use strict"; - -//------------------------------------------------------------------------------ -// Requirements -//------------------------------------------------------------------------------ - -const astUtils = require("./utils/ast-utils"); - -//------------------------------------------------------------------------------ -// Helpers -//------------------------------------------------------------------------------ - -/** - * Checks whether or not a given node is a constructor. - * @param {ASTNode} node A node to check. This node type is one of - * `Program`, `FunctionDeclaration`, `FunctionExpression`, and - * `ArrowFunctionExpression`. - * @returns {boolean} `true` if the node is a constructor. - */ -function isConstructorFunction(node) { - return ( - node.type === "FunctionExpression" && - node.parent.type === "MethodDefinition" && - node.parent.kind === "constructor" - ); -} - -/* - * Information for each code path segment. - * - superCalled: The flag which shows `super()` called in all code paths. - * - invalidNodes: The array of invalid ThisExpression and Super nodes. - */ -/** - * - */ -class SegmentInfo { - - /** - * Indicates whether `super()` is called in all code paths. - * @type {boolean} - */ - superCalled = false; - - /** - * The array of invalid ThisExpression and Super nodes. - * @type {ASTNode[]} - */ - invalidNodes = []; -} - -//------------------------------------------------------------------------------ -// Rule Definition -//------------------------------------------------------------------------------ - -/** @type {import('../shared/types').Rule} */ -module.exports = { - meta: { - type: "problem", - - docs: { - description: "Disallow `this`/`super` before calling `super()` in constructors", - recommended: true, - url: "https://eslint.org/docs/latest/rules/no-this-before-super" - }, - - schema: [], - - messages: { - noBeforeSuper: "'{{kind}}' is not allowed before 'super()'." - } - }, - - create(context) { - - /* - * Information for each constructor. - * - upper: Information of the upper constructor. - * - hasExtends: A flag which shows whether the owner class has a valid - * `extends` part. - * - scope: The scope of the owner class. - * - codePath: The code path of this constructor. - */ - let funcInfo = null; - - /** @type {Record} */ - let segInfoMap = Object.create(null); - - /** - * Gets whether or not `super()` is called in a given code path segment. - * @param {CodePathSegment} segment A code path segment to get. - * @returns {boolean} `true` if `super()` is called. - */ - function isCalled(segment) { - return !segment.reachable || segInfoMap[segment.id]?.superCalled; - } - - /** - * Checks whether or not this is in a constructor. - * @returns {boolean} `true` if this is in a constructor. - */ - function isInConstructorOfDerivedClass() { - return Boolean(funcInfo && funcInfo.isConstructor && funcInfo.hasExtends); - } - - /** - * Determines if every segment in a set has been called. - * @param {Set} segments The segments to search. - * @returns {boolean} True if every segment has been called; false otherwise. - */ - function isEverySegmentCalled(segments) { - for (const segment of segments) { - if (!isCalled(segment)) { - return false; - } - } - - return true; - } - - /** - * Checks whether or not this is before `super()` is called. - * @returns {boolean} `true` if this is before `super()` is called. - */ - function isBeforeCallOfSuper() { - return ( - isInConstructorOfDerivedClass() && - !isEverySegmentCalled(funcInfo.currentSegments) - ); - } - - /** - * Sets a given node as invalid. - * @param {ASTNode} node A node to set as invalid. This is one of - * a ThisExpression and a Super. - * @returns {void} - */ - function setInvalid(node) { - const segments = funcInfo.currentSegments; - - for (const segment of segments) { - if (segment.reachable) { - segInfoMap[segment.id].invalidNodes.push(node); - } - } - } - - /** - * Sets the current segment as `super` was called. - * @returns {void} - */ - function setSuperCalled() { - const segments = funcInfo.currentSegments; - - for (const segment of segments) { - if (segment.reachable) { - segInfoMap[segment.id].superCalled = true; - } - } - } - - return { - - /** - * Adds information of a constructor into the stack. - * @param {CodePath} codePath A code path which was started. - * @param {ASTNode} node The current node. - * @returns {void} - */ - onCodePathStart(codePath, node) { - if (isConstructorFunction(node)) { - - // Class > ClassBody > MethodDefinition > FunctionExpression - const classNode = node.parent.parent.parent; - - funcInfo = { - upper: funcInfo, - isConstructor: true, - hasExtends: Boolean( - classNode.superClass && - !astUtils.isNullOrUndefined(classNode.superClass) - ), - codePath, - currentSegments: new Set() - }; - } else { - funcInfo = { - upper: funcInfo, - isConstructor: false, - hasExtends: false, - codePath, - currentSegments: new Set() - }; - } - }, - - /** - * Removes the top of stack item. - * - * And this traverses all segments of this code path then reports every - * invalid node. - * @param {CodePath} codePath A code path which was ended. - * @returns {void} - */ - onCodePathEnd(codePath) { - const isDerivedClass = funcInfo.hasExtends; - - funcInfo = funcInfo.upper; - if (!isDerivedClass) { - return; - } - - /** - * A collection of nodes to avoid duplicate reports. - * @type {Set} - */ - const reported = new Set(); - - codePath.traverseSegments((segment, controller) => { - const info = segInfoMap[segment.id]; - const invalidNodes = info.invalidNodes - .filter( - - /* - * Avoid duplicate reports. - * When there is a `finally`, invalidNodes may contain already reported node. - */ - node => !reported.has(node) - ); - - for (const invalidNode of invalidNodes) { - reported.add(invalidNode); - - context.report({ - messageId: "noBeforeSuper", - node: invalidNode, - data: { - kind: invalidNode.type === "Super" ? "super" : "this" - } - }); - } - - if (info.superCalled) { - controller.skip(); - } - }); - }, - - /** - * Initialize information of a given code path segment. - * @param {CodePathSegment} segment A code path segment to initialize. - * @returns {void} - */ - onCodePathSegmentStart(segment) { - funcInfo.currentSegments.add(segment); - - if (!isInConstructorOfDerivedClass()) { - return; - } - - // Initialize info. - segInfoMap[segment.id] = { - superCalled: ( - segment.prevSegments.length > 0 && - segment.prevSegments.every(isCalled) - ), - invalidNodes: [] - }; - }, - - onUnreachableCodePathSegmentStart(segment) { - funcInfo.currentSegments.add(segment); - }, - - onUnreachableCodePathSegmentEnd(segment) { - funcInfo.currentSegments.delete(segment); - }, - - onCodePathSegmentEnd(segment) { - funcInfo.currentSegments.delete(segment); - }, - - /** - * Update information of the code path segment when a code path was - * looped. - * @param {CodePathSegment} fromSegment The code path segment of the - * end of a loop. - * @param {CodePathSegment} toSegment A code path segment of the head - * of a loop. - * @returns {void} - */ - onCodePathSegmentLoop(fromSegment, toSegment) { - if (!isInConstructorOfDerivedClass()) { - return; - } - - // Update information inside of the loop. - funcInfo.codePath.traverseSegments( - { first: toSegment, last: fromSegment }, - (segment, controller) => { - const info = segInfoMap[segment.id] ?? new SegmentInfo(); - - if (info.superCalled) { - controller.skip(); - } else if ( - segment.prevSegments.length > 0 && - segment.prevSegments.every(isCalled) - ) { - info.superCalled = true; - } - - segInfoMap[segment.id] = info; - } - ); - }, - - /** - * Reports if this is before `super()`. - * @param {ASTNode} node A target node. - * @returns {void} - */ - ThisExpression(node) { - if (isBeforeCallOfSuper()) { - setInvalid(node); - } - }, - - /** - * Reports if this is before `super()`. - * @param {ASTNode} node A target node. - * @returns {void} - */ - Super(node) { - if (!astUtils.isCallee(node) && isBeforeCallOfSuper()) { - setInvalid(node); - } - }, - - /** - * Marks `super()` called. - * @param {ASTNode} node A target node. - * @returns {void} - */ - "CallExpression:exit"(node) { - if (node.callee.type === "Super" && isBeforeCallOfSuper()) { - setSuperCalled(); - } - }, - - /** - * Resets state. - * @returns {void} - */ - "Program:exit"() { - segInfoMap = Object.create(null); - } - }; - } -}; diff --git a/tools/eslint/node_modules/eslint/lib/rules/no-throw-literal.js b/tools/eslint/node_modules/eslint/lib/rules/no-throw-literal.js deleted file mode 100644 index 07a0df62dff7d5..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/rules/no-throw-literal.js +++ /dev/null @@ -1,51 +0,0 @@ -/** - * @fileoverview Rule to restrict what can be thrown as an exception. - * @author Dieter Oberkofler - */ - -"use strict"; - -const astUtils = require("./utils/ast-utils"); - -//------------------------------------------------------------------------------ -// Rule Definition -//------------------------------------------------------------------------------ - -/** @type {import('../shared/types').Rule} */ -module.exports = { - meta: { - type: "suggestion", - - docs: { - description: "Disallow throwing literals as exceptions", - recommended: false, - url: "https://eslint.org/docs/latest/rules/no-throw-literal" - }, - - schema: [], - - messages: { - object: "Expected an error object to be thrown.", - undef: "Do not throw undefined." - } - }, - - create(context) { - - return { - - ThrowStatement(node) { - if (!astUtils.couldBeError(node.argument)) { - context.report({ node, messageId: "object" }); - } else if (node.argument.type === "Identifier") { - if (node.argument.name === "undefined") { - context.report({ node, messageId: "undef" }); - } - } - - } - - }; - - } -}; diff --git a/tools/eslint/node_modules/eslint/lib/rules/no-trailing-spaces.js b/tools/eslint/node_modules/eslint/lib/rules/no-trailing-spaces.js deleted file mode 100644 index c188b1fa899cb8..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/rules/no-trailing-spaces.js +++ /dev/null @@ -1,192 +0,0 @@ -/** - * @fileoverview Disallow trailing spaces at the end of lines. - * @author Nodeca Team - * @deprecated in ESLint v8.53.0 - */ -"use strict"; - -//------------------------------------------------------------------------------ -// Requirements -//------------------------------------------------------------------------------ - -const astUtils = require("./utils/ast-utils"); - -//------------------------------------------------------------------------------ -// Rule Definition -//------------------------------------------------------------------------------ - -/** @type {import('../shared/types').Rule} */ -module.exports = { - meta: { - deprecated: true, - replacedBy: [], - type: "layout", - - docs: { - description: "Disallow trailing whitespace at the end of lines", - recommended: false, - url: "https://eslint.org/docs/latest/rules/no-trailing-spaces" - }, - - fixable: "whitespace", - - schema: [ - { - type: "object", - properties: { - skipBlankLines: { - type: "boolean", - default: false - }, - ignoreComments: { - type: "boolean", - default: false - } - }, - additionalProperties: false - } - ], - - messages: { - trailingSpace: "Trailing spaces not allowed." - } - }, - - create(context) { - const sourceCode = context.sourceCode; - - const BLANK_CLASS = "[ \t\u00a0\u2000-\u200b\u3000]", - SKIP_BLANK = `^${BLANK_CLASS}*$`, - NONBLANK = `${BLANK_CLASS}+$`; - - const options = context.options[0] || {}, - skipBlankLines = options.skipBlankLines || false, - ignoreComments = options.ignoreComments || false; - - /** - * Report the error message - * @param {ASTNode} node node to report - * @param {int[]} location range information - * @param {int[]} fixRange Range based on the whole program - * @returns {void} - */ - function report(node, location, fixRange) { - - /* - * Passing node is a bit dirty, because message data will contain big - * text in `source`. But... who cares :) ? - * One more kludge will not make worse the bloody wizardry of this - * plugin. - */ - context.report({ - node, - loc: location, - messageId: "trailingSpace", - fix(fixer) { - return fixer.removeRange(fixRange); - } - }); - } - - /** - * Given a list of comment nodes, return the line numbers for those comments. - * @param {Array} comments An array of comment nodes. - * @returns {number[]} An array of line numbers containing comments. - */ - function getCommentLineNumbers(comments) { - const lines = new Set(); - - comments.forEach(comment => { - const endLine = comment.type === "Block" - ? comment.loc.end.line - 1 - : comment.loc.end.line; - - for (let i = comment.loc.start.line; i <= endLine; i++) { - lines.add(i); - } - }); - - return lines; - } - - //-------------------------------------------------------------------------- - // Public - //-------------------------------------------------------------------------- - - return { - - Program: function checkTrailingSpaces(node) { - - /* - * Let's hack. Since Espree does not return whitespace nodes, - * fetch the source code and do matching via regexps. - */ - - const re = new RegExp(NONBLANK, "u"), - skipMatch = new RegExp(SKIP_BLANK, "u"), - lines = sourceCode.lines, - linebreaks = sourceCode.getText().match(astUtils.createGlobalLinebreakMatcher()), - comments = sourceCode.getAllComments(), - commentLineNumbers = getCommentLineNumbers(comments); - - let totalLength = 0; - - for (let i = 0, ii = lines.length; i < ii; i++) { - const lineNumber = i + 1; - - /* - * Always add linebreak length to line length to accommodate for line break (\n or \r\n) - * Because during the fix time they also reserve one spot in the array. - * Usually linebreak length is 2 for \r\n (CRLF) and 1 for \n (LF) - */ - const linebreakLength = linebreaks && linebreaks[i] ? linebreaks[i].length : 1; - const lineLength = lines[i].length + linebreakLength; - - const matches = re.exec(lines[i]); - - if (matches) { - const location = { - start: { - line: lineNumber, - column: matches.index - }, - end: { - line: lineNumber, - column: lineLength - linebreakLength - } - }; - - const rangeStart = totalLength + location.start.column; - const rangeEnd = totalLength + location.end.column; - const containingNode = sourceCode.getNodeByRangeIndex(rangeStart); - - if (containingNode && containingNode.type === "TemplateElement" && - rangeStart > containingNode.parent.range[0] && - rangeEnd < containingNode.parent.range[1]) { - totalLength += lineLength; - continue; - } - - /* - * If the line has only whitespace, and skipBlankLines - * is true, don't report it - */ - if (skipBlankLines && skipMatch.test(lines[i])) { - totalLength += lineLength; - continue; - } - - const fixRange = [rangeStart, rangeEnd]; - - if (!ignoreComments || !commentLineNumbers.has(lineNumber)) { - report(node, location, fixRange); - } - } - - totalLength += lineLength; - } - } - - }; - } -}; diff --git a/tools/eslint/node_modules/eslint/lib/rules/no-undef-init.js b/tools/eslint/node_modules/eslint/lib/rules/no-undef-init.js deleted file mode 100644 index be19d6f9526bd8..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/rules/no-undef-init.js +++ /dev/null @@ -1,75 +0,0 @@ -/** - * @fileoverview Rule to flag when initializing to undefined - * @author Ilya Volodin - */ - -"use strict"; - -const astUtils = require("./utils/ast-utils"); - -//------------------------------------------------------------------------------ -// Rule Definition -//------------------------------------------------------------------------------ - -/** @type {import('../shared/types').Rule} */ -module.exports = { - meta: { - type: "suggestion", - - docs: { - description: "Disallow initializing variables to `undefined`", - recommended: false, - url: "https://eslint.org/docs/latest/rules/no-undef-init" - }, - - schema: [], - fixable: "code", - - messages: { - unnecessaryUndefinedInit: "It's not necessary to initialize '{{name}}' to undefined." - } - }, - - create(context) { - - const sourceCode = context.sourceCode; - - return { - - VariableDeclarator(node) { - const name = sourceCode.getText(node.id), - init = node.init && node.init.name, - scope = sourceCode.getScope(node), - undefinedVar = astUtils.getVariableByName(scope, "undefined"), - shadowed = undefinedVar && undefinedVar.defs.length > 0, - lastToken = sourceCode.getLastToken(node); - - if (init === "undefined" && node.parent.kind !== "const" && !shadowed) { - context.report({ - node, - messageId: "unnecessaryUndefinedInit", - data: { name }, - fix(fixer) { - if (node.parent.kind === "var") { - return null; - } - - if (node.id.type === "ArrayPattern" || node.id.type === "ObjectPattern") { - - // Don't fix destructuring assignment to `undefined`. - return null; - } - - if (sourceCode.commentsExistBetween(node.id, lastToken)) { - return null; - } - - return fixer.removeRange([node.id.range[1], node.range[1]]); - } - }); - } - } - }; - - } -}; diff --git a/tools/eslint/node_modules/eslint/lib/rules/no-undef.js b/tools/eslint/node_modules/eslint/lib/rules/no-undef.js deleted file mode 100644 index fe470286c04145..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/rules/no-undef.js +++ /dev/null @@ -1,79 +0,0 @@ -/** - * @fileoverview Rule to flag references to undeclared variables. - * @author Mark Macdonald - */ -"use strict"; - -//------------------------------------------------------------------------------ -// Helpers -//------------------------------------------------------------------------------ - -/** - * Checks if the given node is the argument of a typeof operator. - * @param {ASTNode} node The AST node being checked. - * @returns {boolean} Whether or not the node is the argument of a typeof operator. - */ -function hasTypeOfOperator(node) { - const parent = node.parent; - - return parent.type === "UnaryExpression" && parent.operator === "typeof"; -} - -//------------------------------------------------------------------------------ -// Rule Definition -//------------------------------------------------------------------------------ - -/** @type {import('../shared/types').Rule} */ -module.exports = { - meta: { - type: "problem", - - docs: { - description: "Disallow the use of undeclared variables unless mentioned in `/*global */` comments", - recommended: true, - url: "https://eslint.org/docs/latest/rules/no-undef" - }, - - schema: [ - { - type: "object", - properties: { - typeof: { - type: "boolean", - default: false - } - }, - additionalProperties: false - } - ], - messages: { - undef: "'{{name}}' is not defined." - } - }, - - create(context) { - const options = context.options[0]; - const considerTypeOf = options && options.typeof === true || false; - const sourceCode = context.sourceCode; - - return { - "Program:exit"(node) { - const globalScope = sourceCode.getScope(node); - - globalScope.through.forEach(ref => { - const identifier = ref.identifier; - - if (!considerTypeOf && hasTypeOfOperator(identifier)) { - return; - } - - context.report({ - node: identifier, - messageId: "undef", - data: identifier - }); - }); - } - }; - } -}; diff --git a/tools/eslint/node_modules/eslint/lib/rules/no-undefined.js b/tools/eslint/node_modules/eslint/lib/rules/no-undefined.js deleted file mode 100644 index 8f47ca1b020a49..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/rules/no-undefined.js +++ /dev/null @@ -1,86 +0,0 @@ -/** - * @fileoverview Rule to flag references to the undefined variable. - * @author Michael Ficarra - */ -"use strict"; - -//------------------------------------------------------------------------------ -// Rule Definition -//------------------------------------------------------------------------------ - -/** @type {import('../shared/types').Rule} */ -module.exports = { - meta: { - type: "suggestion", - - docs: { - description: "Disallow the use of `undefined` as an identifier", - recommended: false, - url: "https://eslint.org/docs/latest/rules/no-undefined" - }, - - schema: [], - - messages: { - unexpectedUndefined: "Unexpected use of undefined." - } - }, - - create(context) { - - const sourceCode = context.sourceCode; - - /** - * Report an invalid "undefined" identifier node. - * @param {ASTNode} node The node to report. - * @returns {void} - */ - function report(node) { - context.report({ - node, - messageId: "unexpectedUndefined" - }); - } - - /** - * Checks the given scope for references to `undefined` and reports - * all references found. - * @param {eslint-scope.Scope} scope The scope to check. - * @returns {void} - */ - function checkScope(scope) { - const undefinedVar = scope.set.get("undefined"); - - if (!undefinedVar) { - return; - } - - const references = undefinedVar.references; - - const defs = undefinedVar.defs; - - // Report non-initializing references (those are covered in defs below) - references - .filter(ref => !ref.init) - .forEach(ref => report(ref.identifier)); - - defs.forEach(def => report(def.name)); - } - - return { - "Program:exit"(node) { - const globalScope = sourceCode.getScope(node); - - const stack = [globalScope]; - - while (stack.length) { - const scope = stack.pop(); - - stack.push(...scope.childScopes); - checkScope(scope); - } - } - }; - - } -}; diff --git a/tools/eslint/node_modules/eslint/lib/rules/no-underscore-dangle.js b/tools/eslint/node_modules/eslint/lib/rules/no-underscore-dangle.js deleted file mode 100644 index a0e05c6c1cc2db..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/rules/no-underscore-dangle.js +++ /dev/null @@ -1,335 +0,0 @@ -/** - * @fileoverview Rule to flag dangling underscores in variable declarations. - * @author Matt DuVall - */ - -"use strict"; - -//------------------------------------------------------------------------------ -// Rule Definition -//------------------------------------------------------------------------------ - -/** @type {import('../shared/types').Rule} */ -module.exports = { - meta: { - type: "suggestion", - - docs: { - description: "Disallow dangling underscores in identifiers", - recommended: false, - url: "https://eslint.org/docs/latest/rules/no-underscore-dangle" - }, - - schema: [ - { - type: "object", - properties: { - allow: { - type: "array", - items: { - type: "string" - } - }, - allowAfterThis: { - type: "boolean", - default: false - }, - allowAfterSuper: { - type: "boolean", - default: false - }, - allowAfterThisConstructor: { - type: "boolean", - default: false - }, - enforceInMethodNames: { - type: "boolean", - default: false - }, - allowFunctionParams: { - type: "boolean", - default: true - }, - enforceInClassFields: { - type: "boolean", - default: false - }, - allowInArrayDestructuring: { - type: "boolean", - default: true - }, - allowInObjectDestructuring: { - type: "boolean", - default: true - } - }, - additionalProperties: false - } - ], - - messages: { - unexpectedUnderscore: "Unexpected dangling '_' in '{{identifier}}'." - } - }, - - create(context) { - - const options = context.options[0] || {}; - const ALLOWED_VARIABLES = options.allow ? options.allow : []; - const allowAfterThis = typeof options.allowAfterThis !== "undefined" ? options.allowAfterThis : false; - const allowAfterSuper = typeof options.allowAfterSuper !== "undefined" ? options.allowAfterSuper : false; - const allowAfterThisConstructor = typeof options.allowAfterThisConstructor !== "undefined" ? options.allowAfterThisConstructor : false; - const enforceInMethodNames = typeof options.enforceInMethodNames !== "undefined" ? options.enforceInMethodNames : false; - const enforceInClassFields = typeof options.enforceInClassFields !== "undefined" ? options.enforceInClassFields : false; - const allowFunctionParams = typeof options.allowFunctionParams !== "undefined" ? options.allowFunctionParams : true; - const allowInArrayDestructuring = typeof options.allowInArrayDestructuring !== "undefined" ? options.allowInArrayDestructuring : true; - const allowInObjectDestructuring = typeof options.allowInObjectDestructuring !== "undefined" ? options.allowInObjectDestructuring : true; - const sourceCode = context.sourceCode; - - //------------------------------------------------------------------------- - // Helpers - //------------------------------------------------------------------------- - - /** - * Check if identifier is present inside the allowed option - * @param {string} identifier name of the node - * @returns {boolean} true if its is present - * @private - */ - function isAllowed(identifier) { - return ALLOWED_VARIABLES.includes(identifier); - } - - /** - * Check if identifier has a dangling underscore - * @param {string} identifier name of the node - * @returns {boolean} true if its is present - * @private - */ - function hasDanglingUnderscore(identifier) { - const len = identifier.length; - - return identifier !== "_" && (identifier[0] === "_" || identifier[len - 1] === "_"); - } - - /** - * Check if identifier is a special case member expression - * @param {string} identifier name of the node - * @returns {boolean} true if its is a special case - * @private - */ - function isSpecialCaseIdentifierForMemberExpression(identifier) { - return identifier === "__proto__"; - } - - /** - * Check if identifier is a special case variable expression - * @param {string} identifier name of the node - * @returns {boolean} true if its is a special case - * @private - */ - function isSpecialCaseIdentifierInVariableExpression(identifier) { - - // Checks for the underscore library usage here - return identifier === "_"; - } - - /** - * Check if a node is a member reference of this.constructor - * @param {ASTNode} node node to evaluate - * @returns {boolean} true if it is a reference on this.constructor - * @private - */ - function isThisConstructorReference(node) { - return node.object.type === "MemberExpression" && - node.object.property.name === "constructor" && - node.object.object.type === "ThisExpression"; - } - - /** - * Check if function parameter has a dangling underscore. - * @param {ASTNode} node function node to evaluate - * @returns {void} - * @private - */ - function checkForDanglingUnderscoreInFunctionParameters(node) { - if (!allowFunctionParams) { - node.params.forEach(param => { - const { type } = param; - let nodeToCheck; - - if (type === "RestElement") { - nodeToCheck = param.argument; - } else if (type === "AssignmentPattern") { - nodeToCheck = param.left; - } else { - nodeToCheck = param; - } - - if (nodeToCheck.type === "Identifier") { - const identifier = nodeToCheck.name; - - if (hasDanglingUnderscore(identifier) && !isAllowed(identifier)) { - context.report({ - node: param, - messageId: "unexpectedUnderscore", - data: { - identifier - } - }); - } - } - }); - } - } - - /** - * Check if function has a dangling underscore - * @param {ASTNode} node node to evaluate - * @returns {void} - * @private - */ - function checkForDanglingUnderscoreInFunction(node) { - if (node.type === "FunctionDeclaration" && node.id) { - const identifier = node.id.name; - - if (typeof identifier !== "undefined" && hasDanglingUnderscore(identifier) && !isAllowed(identifier)) { - context.report({ - node, - messageId: "unexpectedUnderscore", - data: { - identifier - } - }); - } - } - checkForDanglingUnderscoreInFunctionParameters(node); - } - - - /** - * Check if variable expression has a dangling underscore - * @param {ASTNode} node node to evaluate - * @returns {void} - * @private - */ - function checkForDanglingUnderscoreInVariableExpression(node) { - sourceCode.getDeclaredVariables(node).forEach(variable => { - const definition = variable.defs.find(def => def.node === node); - const identifierNode = definition.name; - const identifier = identifierNode.name; - let parent = identifierNode.parent; - - while (!["VariableDeclarator", "ArrayPattern", "ObjectPattern"].includes(parent.type)) { - parent = parent.parent; - } - - if ( - hasDanglingUnderscore(identifier) && - !isSpecialCaseIdentifierInVariableExpression(identifier) && - !isAllowed(identifier) && - !(allowInArrayDestructuring && parent.type === "ArrayPattern") && - !(allowInObjectDestructuring && parent.type === "ObjectPattern") - ) { - context.report({ - node, - messageId: "unexpectedUnderscore", - data: { - identifier - } - }); - } - }); - } - - /** - * Check if member expression has a dangling underscore - * @param {ASTNode} node node to evaluate - * @returns {void} - * @private - */ - function checkForDanglingUnderscoreInMemberExpression(node) { - const identifier = node.property.name, - isMemberOfThis = node.object.type === "ThisExpression", - isMemberOfSuper = node.object.type === "Super", - isMemberOfThisConstructor = isThisConstructorReference(node); - - if (typeof identifier !== "undefined" && hasDanglingUnderscore(identifier) && - !(isMemberOfThis && allowAfterThis) && - !(isMemberOfSuper && allowAfterSuper) && - !(isMemberOfThisConstructor && allowAfterThisConstructor) && - !isSpecialCaseIdentifierForMemberExpression(identifier) && !isAllowed(identifier)) { - context.report({ - node, - messageId: "unexpectedUnderscore", - data: { - identifier - } - }); - } - } - - /** - * Check if method declaration or method property has a dangling underscore - * @param {ASTNode} node node to evaluate - * @returns {void} - * @private - */ - function checkForDanglingUnderscoreInMethod(node) { - const identifier = node.key.name; - const isMethod = node.type === "MethodDefinition" || node.type === "Property" && node.method; - - if (typeof identifier !== "undefined" && enforceInMethodNames && isMethod && hasDanglingUnderscore(identifier) && !isAllowed(identifier)) { - context.report({ - node, - messageId: "unexpectedUnderscore", - data: { - identifier: node.key.type === "PrivateIdentifier" - ? `#${identifier}` - : identifier - } - }); - } - } - - /** - * Check if a class field has a dangling underscore - * @param {ASTNode} node node to evaluate - * @returns {void} - * @private - */ - function checkForDanglingUnderscoreInClassField(node) { - const identifier = node.key.name; - - if (typeof identifier !== "undefined" && hasDanglingUnderscore(identifier) && - enforceInClassFields && - !isAllowed(identifier)) { - context.report({ - node, - messageId: "unexpectedUnderscore", - data: { - identifier: node.key.type === "PrivateIdentifier" - ? `#${identifier}` - : identifier - } - }); - } - } - - //-------------------------------------------------------------------------- - // Public API - //-------------------------------------------------------------------------- - - return { - FunctionDeclaration: checkForDanglingUnderscoreInFunction, - VariableDeclarator: checkForDanglingUnderscoreInVariableExpression, - MemberExpression: checkForDanglingUnderscoreInMemberExpression, - MethodDefinition: checkForDanglingUnderscoreInMethod, - PropertyDefinition: checkForDanglingUnderscoreInClassField, - Property: checkForDanglingUnderscoreInMethod, - FunctionExpression: checkForDanglingUnderscoreInFunction, - ArrowFunctionExpression: checkForDanglingUnderscoreInFunction - }; - - } -}; diff --git a/tools/eslint/node_modules/eslint/lib/rules/no-unexpected-multiline.js b/tools/eslint/node_modules/eslint/lib/rules/no-unexpected-multiline.js deleted file mode 100644 index 810c08b011b6c5..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/rules/no-unexpected-multiline.js +++ /dev/null @@ -1,120 +0,0 @@ -/** - * @fileoverview Rule to spot scenarios where a newline looks like it is ending a statement, but is not. - * @author Glen Mailer - */ -"use strict"; - -//------------------------------------------------------------------------------ -// Requirements -//------------------------------------------------------------------------------ - -const astUtils = require("./utils/ast-utils"); - -//------------------------------------------------------------------------------ -// Rule Definition -//------------------------------------------------------------------------------ - -/** @type {import('../shared/types').Rule} */ -module.exports = { - meta: { - type: "problem", - - docs: { - description: "Disallow confusing multiline expressions", - recommended: true, - url: "https://eslint.org/docs/latest/rules/no-unexpected-multiline" - }, - - schema: [], - messages: { - function: "Unexpected newline between function and ( of function call.", - property: "Unexpected newline between object and [ of property access.", - taggedTemplate: "Unexpected newline between template tag and template literal.", - division: "Unexpected newline between numerator and division operator." - } - }, - - create(context) { - - const REGEX_FLAG_MATCHER = /^[gimsuy]+$/u; - - const sourceCode = context.sourceCode; - - /** - * Check to see if there is a newline between the node and the following open bracket - * line's expression - * @param {ASTNode} node The node to check. - * @param {string} messageId The error messageId to use. - * @returns {void} - * @private - */ - function checkForBreakAfter(node, messageId) { - const openParen = sourceCode.getTokenAfter(node, astUtils.isNotClosingParenToken); - const nodeExpressionEnd = sourceCode.getTokenBefore(openParen); - - if (openParen.loc.start.line !== nodeExpressionEnd.loc.end.line) { - context.report({ - node, - loc: openParen.loc, - messageId - }); - } - } - - //-------------------------------------------------------------------------- - // Public API - //-------------------------------------------------------------------------- - - return { - - MemberExpression(node) { - if (!node.computed || node.optional) { - return; - } - checkForBreakAfter(node.object, "property"); - }, - - TaggedTemplateExpression(node) { - const { quasi } = node; - - // handles common tags, parenthesized tags, and typescript's generic type arguments - const tokenBefore = sourceCode.getTokenBefore(quasi); - - if (tokenBefore.loc.end.line !== quasi.loc.start.line) { - context.report({ - node, - loc: { - start: quasi.loc.start, - end: { - line: quasi.loc.start.line, - column: quasi.loc.start.column + 1 - } - }, - messageId: "taggedTemplate" - }); - } - }, - - CallExpression(node) { - if (node.arguments.length === 0 || node.optional) { - return; - } - checkForBreakAfter(node.callee, "function"); - }, - - "BinaryExpression[operator='/'] > BinaryExpression[operator='/'].left"(node) { - const secondSlash = sourceCode.getTokenAfter(node, token => token.value === "/"); - const tokenAfterOperator = sourceCode.getTokenAfter(secondSlash); - - if ( - tokenAfterOperator.type === "Identifier" && - REGEX_FLAG_MATCHER.test(tokenAfterOperator.value) && - secondSlash.range[1] === tokenAfterOperator.range[0] - ) { - checkForBreakAfter(node.left, "division"); - } - } - }; - - } -}; diff --git a/tools/eslint/node_modules/eslint/lib/rules/no-unmodified-loop-condition.js b/tools/eslint/node_modules/eslint/lib/rules/no-unmodified-loop-condition.js deleted file mode 100644 index 768a15573acce6..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/rules/no-unmodified-loop-condition.js +++ /dev/null @@ -1,360 +0,0 @@ -/** - * @fileoverview Rule to disallow use of unmodified expressions in loop conditions - * @author Toru Nagashima - */ - -"use strict"; - -//------------------------------------------------------------------------------ -// Requirements -//------------------------------------------------------------------------------ - -const Traverser = require("../shared/traverser"), - astUtils = require("./utils/ast-utils"); - -//------------------------------------------------------------------------------ -// Helpers -//------------------------------------------------------------------------------ - -const SENTINEL_PATTERN = /(?:(?:Call|Class|Function|Member|New|Yield)Expression|Statement|Declaration)$/u; -const LOOP_PATTERN = /^(?:DoWhile|For|While)Statement$/u; // for-in/of statements don't have `test` property. -const GROUP_PATTERN = /^(?:BinaryExpression|ConditionalExpression)$/u; -const SKIP_PATTERN = /^(?:ArrowFunction|Class|Function)Expression$/u; -const DYNAMIC_PATTERN = /^(?:Call|Member|New|TaggedTemplate|Yield)Expression$/u; - -/** - * @typedef {Object} LoopConditionInfo - * @property {eslint-scope.Reference} reference - The reference. - * @property {ASTNode} group - BinaryExpression or ConditionalExpression nodes - * that the reference is belonging to. - * @property {Function} isInLoop - The predicate which checks a given reference - * is in this loop. - * @property {boolean} modified - The flag that the reference is modified in - * this loop. - */ - -/** - * Checks whether or not a given reference is a write reference. - * @param {eslint-scope.Reference} reference A reference to check. - * @returns {boolean} `true` if the reference is a write reference. - */ -function isWriteReference(reference) { - if (reference.init) { - const def = reference.resolved && reference.resolved.defs[0]; - - if (!def || def.type !== "Variable" || def.parent.kind !== "var") { - return false; - } - } - return reference.isWrite(); -} - -/** - * Checks whether or not a given loop condition info does not have the modified - * flag. - * @param {LoopConditionInfo} condition A loop condition info to check. - * @returns {boolean} `true` if the loop condition info is "unmodified". - */ -function isUnmodified(condition) { - return !condition.modified; -} - -/** - * Checks whether or not a given loop condition info does not have the modified - * flag and does not have the group this condition belongs to. - * @param {LoopConditionInfo} condition A loop condition info to check. - * @returns {boolean} `true` if the loop condition info is "unmodified". - */ -function isUnmodifiedAndNotBelongToGroup(condition) { - return !(condition.modified || condition.group); -} - -/** - * Checks whether or not a given reference is inside of a given node. - * @param {ASTNode} node A node to check. - * @param {eslint-scope.Reference} reference A reference to check. - * @returns {boolean} `true` if the reference is inside of the node. - */ -function isInRange(node, reference) { - const or = node.range; - const ir = reference.identifier.range; - - return or[0] <= ir[0] && ir[1] <= or[1]; -} - -/** - * Checks whether or not a given reference is inside of a loop node's condition. - * @param {ASTNode} node A node to check. - * @param {eslint-scope.Reference} reference A reference to check. - * @returns {boolean} `true` if the reference is inside of the loop node's - * condition. - */ -const isInLoop = { - WhileStatement: isInRange, - DoWhileStatement: isInRange, - ForStatement(node, reference) { - return ( - isInRange(node, reference) && - !(node.init && isInRange(node.init, reference)) - ); - } -}; - -/** - * Gets the function which encloses a given reference. - * This supports only FunctionDeclaration. - * @param {eslint-scope.Reference} reference A reference to get. - * @returns {ASTNode|null} The function node or null. - */ -function getEncloseFunctionDeclaration(reference) { - let node = reference.identifier; - - while (node) { - if (node.type === "FunctionDeclaration") { - return node.id ? node : null; - } - - node = node.parent; - } - - return null; -} - -/** - * Updates the "modified" flags of given loop conditions with given modifiers. - * @param {LoopConditionInfo[]} conditions The loop conditions to be updated. - * @param {eslint-scope.Reference[]} modifiers The references to update. - * @returns {void} - */ -function updateModifiedFlag(conditions, modifiers) { - - for (let i = 0; i < conditions.length; ++i) { - const condition = conditions[i]; - - for (let j = 0; !condition.modified && j < modifiers.length; ++j) { - const modifier = modifiers[j]; - let funcNode, funcVar; - - /* - * Besides checking for the condition being in the loop, we want to - * check the function that this modifier is belonging to is called - * in the loop. - * FIXME: This should probably be extracted to a function. - */ - const inLoop = condition.isInLoop(modifier) || Boolean( - (funcNode = getEncloseFunctionDeclaration(modifier)) && - (funcVar = astUtils.getVariableByName(modifier.from.upper, funcNode.id.name)) && - funcVar.references.some(condition.isInLoop) - ); - - condition.modified = inLoop; - } - } -} - -//------------------------------------------------------------------------------ -// Rule Definition -//------------------------------------------------------------------------------ - -/** @type {import('../shared/types').Rule} */ -module.exports = { - meta: { - type: "problem", - - docs: { - description: "Disallow unmodified loop conditions", - recommended: false, - url: "https://eslint.org/docs/latest/rules/no-unmodified-loop-condition" - }, - - schema: [], - - messages: { - loopConditionNotModified: "'{{name}}' is not modified in this loop." - } - }, - - create(context) { - const sourceCode = context.sourceCode; - let groupMap = null; - - /** - * Reports a given condition info. - * @param {LoopConditionInfo} condition A loop condition info to report. - * @returns {void} - */ - function report(condition) { - const node = condition.reference.identifier; - - context.report({ - node, - messageId: "loopConditionNotModified", - data: node - }); - } - - /** - * Registers given conditions to the group the condition belongs to. - * @param {LoopConditionInfo[]} conditions A loop condition info to - * register. - * @returns {void} - */ - function registerConditionsToGroup(conditions) { - for (let i = 0; i < conditions.length; ++i) { - const condition = conditions[i]; - - if (condition.group) { - let group = groupMap.get(condition.group); - - if (!group) { - group = []; - groupMap.set(condition.group, group); - } - group.push(condition); - } - } - } - - /** - * Reports references which are inside of unmodified groups. - * @param {LoopConditionInfo[]} conditions A loop condition info to report. - * @returns {void} - */ - function checkConditionsInGroup(conditions) { - if (conditions.every(isUnmodified)) { - conditions.forEach(report); - } - } - - /** - * Checks whether or not a given group node has any dynamic elements. - * @param {ASTNode} root A node to check. - * This node is one of BinaryExpression or ConditionalExpression. - * @returns {boolean} `true` if the node is dynamic. - */ - function hasDynamicExpressions(root) { - let retv = false; - - Traverser.traverse(root, { - visitorKeys: sourceCode.visitorKeys, - enter(node) { - if (DYNAMIC_PATTERN.test(node.type)) { - retv = true; - this.break(); - } else if (SKIP_PATTERN.test(node.type)) { - this.skip(); - } - } - }); - - return retv; - } - - /** - * Creates the loop condition information from a given reference. - * @param {eslint-scope.Reference} reference A reference to create. - * @returns {LoopConditionInfo|null} Created loop condition info, or null. - */ - function toLoopCondition(reference) { - if (reference.init) { - return null; - } - - let group = null; - let child = reference.identifier; - let node = child.parent; - - while (node) { - if (SENTINEL_PATTERN.test(node.type)) { - if (LOOP_PATTERN.test(node.type) && node.test === child) { - - // This reference is inside of a loop condition. - return { - reference, - group, - isInLoop: isInLoop[node.type].bind(null, node), - modified: false - }; - } - - // This reference is outside of a loop condition. - break; - } - - /* - * If it's inside of a group, OK if either operand is modified. - * So stores the group this reference belongs to. - */ - if (GROUP_PATTERN.test(node.type)) { - - // If this expression is dynamic, no need to check. - if (hasDynamicExpressions(node)) { - break; - } else { - group = node; - } - } - - child = node; - node = node.parent; - } - - return null; - } - - /** - * Finds unmodified references which are inside of a loop condition. - * Then reports the references which are outside of groups. - * @param {eslint-scope.Variable} variable A variable to report. - * @returns {void} - */ - function checkReferences(variable) { - - // Gets references that exist in loop conditions. - const conditions = variable - .references - .map(toLoopCondition) - .filter(Boolean); - - if (conditions.length === 0) { - return; - } - - // Registers the conditions to belonging groups. - registerConditionsToGroup(conditions); - - // Check the conditions are modified. - const modifiers = variable.references.filter(isWriteReference); - - if (modifiers.length > 0) { - updateModifiedFlag(conditions, modifiers); - } - - /* - * Reports the conditions which are not belonging to groups. - * Others will be reported after all variables are done. - */ - conditions - .filter(isUnmodifiedAndNotBelongToGroup) - .forEach(report); - } - - return { - "Program:exit"(node) { - const queue = [sourceCode.getScope(node)]; - - groupMap = new Map(); - - let scope; - - while ((scope = queue.pop())) { - queue.push(...scope.childScopes); - scope.variables.forEach(checkReferences); - } - - groupMap.forEach(checkConditionsInGroup); - groupMap = null; - } - }; - } -}; diff --git a/tools/eslint/node_modules/eslint/lib/rules/no-unneeded-ternary.js b/tools/eslint/node_modules/eslint/lib/rules/no-unneeded-ternary.js deleted file mode 100644 index 9bff7fb6da4593..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/rules/no-unneeded-ternary.js +++ /dev/null @@ -1,166 +0,0 @@ -/** - * @fileoverview Rule to flag no-unneeded-ternary - * @author Gyandeep Singh - */ - -"use strict"; - -const astUtils = require("./utils/ast-utils"); - -// Operators that always result in a boolean value -const BOOLEAN_OPERATORS = new Set(["==", "===", "!=", "!==", ">", ">=", "<", "<=", "in", "instanceof"]); -const OPERATOR_INVERSES = { - "==": "!=", - "!=": "==", - "===": "!==", - "!==": "===" - - // Operators like < and >= are not true inverses, since both will return false with NaN. -}; -const OR_PRECEDENCE = astUtils.getPrecedence({ type: "LogicalExpression", operator: "||" }); - -//------------------------------------------------------------------------------ -// Rule Definition -//------------------------------------------------------------------------------ - -/** @type {import('../shared/types').Rule} */ -module.exports = { - meta: { - type: "suggestion", - - docs: { - description: "Disallow ternary operators when simpler alternatives exist", - recommended: false, - url: "https://eslint.org/docs/latest/rules/no-unneeded-ternary" - }, - - schema: [ - { - type: "object", - properties: { - defaultAssignment: { - type: "boolean", - default: true - } - }, - additionalProperties: false - } - ], - - fixable: "code", - - messages: { - unnecessaryConditionalExpression: "Unnecessary use of boolean literals in conditional expression.", - unnecessaryConditionalAssignment: "Unnecessary use of conditional expression for default assignment." - } - }, - - create(context) { - const options = context.options[0] || {}; - const defaultAssignment = options.defaultAssignment !== false; - const sourceCode = context.sourceCode; - - /** - * Test if the node is a boolean literal - * @param {ASTNode} node The node to report. - * @returns {boolean} True if the its a boolean literal - * @private - */ - function isBooleanLiteral(node) { - return node.type === "Literal" && typeof node.value === "boolean"; - } - - /** - * Creates an expression that represents the boolean inverse of the expression represented by the original node - * @param {ASTNode} node A node representing an expression - * @returns {string} A string representing an inverted expression - */ - function invertExpression(node) { - if (node.type === "BinaryExpression" && Object.hasOwn(OPERATOR_INVERSES, node.operator)) { - const operatorToken = sourceCode.getFirstTokenBetween( - node.left, - node.right, - token => token.value === node.operator - ); - const text = sourceCode.getText(); - - return text.slice(node.range[0], - operatorToken.range[0]) + OPERATOR_INVERSES[node.operator] + text.slice(operatorToken.range[1], node.range[1]); - } - - if (astUtils.getPrecedence(node) < astUtils.getPrecedence({ type: "UnaryExpression" })) { - return `!(${astUtils.getParenthesisedText(sourceCode, node)})`; - } - return `!${astUtils.getParenthesisedText(sourceCode, node)}`; - } - - /** - * Tests if a given node always evaluates to a boolean value - * @param {ASTNode} node An expression node - * @returns {boolean} True if it is determined that the node will always evaluate to a boolean value - */ - function isBooleanExpression(node) { - return node.type === "BinaryExpression" && BOOLEAN_OPERATORS.has(node.operator) || - node.type === "UnaryExpression" && node.operator === "!"; - } - - /** - * Test if the node matches the pattern id ? id : expression - * @param {ASTNode} node The ConditionalExpression to check. - * @returns {boolean} True if the pattern is matched, and false otherwise - * @private - */ - function matchesDefaultAssignment(node) { - return node.test.type === "Identifier" && - node.consequent.type === "Identifier" && - node.test.name === node.consequent.name; - } - - return { - - ConditionalExpression(node) { - if (isBooleanLiteral(node.alternate) && isBooleanLiteral(node.consequent)) { - context.report({ - node, - messageId: "unnecessaryConditionalExpression", - fix(fixer) { - if (node.consequent.value === node.alternate.value) { - - // Replace `foo ? true : true` with just `true`, but don't replace `foo() ? true : true` - return node.test.type === "Identifier" ? fixer.replaceText(node, node.consequent.value.toString()) : null; - } - if (node.alternate.value) { - - // Replace `foo() ? false : true` with `!(foo())` - return fixer.replaceText(node, invertExpression(node.test)); - } - - // Replace `foo ? true : false` with `foo` if `foo` is guaranteed to be a boolean, or `!!foo` otherwise. - - return fixer.replaceText(node, isBooleanExpression(node.test) ? astUtils.getParenthesisedText(sourceCode, node.test) : `!${invertExpression(node.test)}`); - } - }); - } else if (!defaultAssignment && matchesDefaultAssignment(node)) { - context.report({ - node, - messageId: "unnecessaryConditionalAssignment", - fix(fixer) { - const shouldParenthesizeAlternate = - ( - astUtils.getPrecedence(node.alternate) < OR_PRECEDENCE || - astUtils.isCoalesceExpression(node.alternate) - ) && - !astUtils.isParenthesised(sourceCode, node.alternate); - const alternateText = shouldParenthesizeAlternate - ? `(${sourceCode.getText(node.alternate)})` - : astUtils.getParenthesisedText(sourceCode, node.alternate); - const testText = astUtils.getParenthesisedText(sourceCode, node.test); - - return fixer.replaceText(node, `${testText} || ${alternateText}`); - } - }); - } - } - }; - } -}; diff --git a/tools/eslint/node_modules/eslint/lib/rules/no-unreachable-loop.js b/tools/eslint/node_modules/eslint/lib/rules/no-unreachable-loop.js deleted file mode 100644 index 577d39ac7c7adf..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/rules/no-unreachable-loop.js +++ /dev/null @@ -1,185 +0,0 @@ -/** - * @fileoverview Rule to disallow loops with a body that allows only one iteration - * @author Milos Djermanovic - */ - -"use strict"; - -//------------------------------------------------------------------------------ -// Helpers -//------------------------------------------------------------------------------ - -const allLoopTypes = ["WhileStatement", "DoWhileStatement", "ForStatement", "ForInStatement", "ForOfStatement"]; - -/** - * Checks all segments in a set and returns true if any are reachable. - * @param {Set} segments The segments to check. - * @returns {boolean} True if any segment is reachable; false otherwise. - */ -function isAnySegmentReachable(segments) { - - for (const segment of segments) { - if (segment.reachable) { - return true; - } - } - - return false; -} - -/** - * Determines whether the given node is the first node in the code path to which a loop statement - * 'loops' for the next iteration. - * @param {ASTNode} node The node to check. - * @returns {boolean} `true` if the node is a looping target. - */ -function isLoopingTarget(node) { - const parent = node.parent; - - if (parent) { - switch (parent.type) { - case "WhileStatement": - return node === parent.test; - case "DoWhileStatement": - return node === parent.body; - case "ForStatement": - return node === (parent.update || parent.test || parent.body); - case "ForInStatement": - case "ForOfStatement": - return node === parent.left; - - // no default - } - } - - return false; -} - -/** - * Creates an array with elements from the first given array that are not included in the second given array. - * @param {Array} arrA The array to compare from. - * @param {Array} arrB The array to compare against. - * @returns {Array} a new array that represents `arrA \ arrB`. - */ -function getDifference(arrA, arrB) { - return arrA.filter(a => !arrB.includes(a)); -} - -//------------------------------------------------------------------------------ -// Rule Definition -//------------------------------------------------------------------------------ - -/** @type {import('../shared/types').Rule} */ -module.exports = { - meta: { - type: "problem", - - docs: { - description: "Disallow loops with a body that allows only one iteration", - recommended: false, - url: "https://eslint.org/docs/latest/rules/no-unreachable-loop" - }, - - schema: [{ - type: "object", - properties: { - ignore: { - type: "array", - items: { - enum: allLoopTypes - }, - uniqueItems: true - } - }, - additionalProperties: false - }], - - messages: { - invalid: "Invalid loop. Its body allows only one iteration." - } - }, - - create(context) { - const ignoredLoopTypes = context.options[0] && context.options[0].ignore || [], - loopTypesToCheck = getDifference(allLoopTypes, ignoredLoopTypes), - loopSelector = loopTypesToCheck.join(","), - loopsByTargetSegments = new Map(), - loopsToReport = new Set(); - - const codePathSegments = []; - let currentCodePathSegments = new Set(); - - return { - - onCodePathStart() { - codePathSegments.push(currentCodePathSegments); - currentCodePathSegments = new Set(); - }, - - onCodePathEnd() { - currentCodePathSegments = codePathSegments.pop(); - }, - - onUnreachableCodePathSegmentStart(segment) { - currentCodePathSegments.add(segment); - }, - - onUnreachableCodePathSegmentEnd(segment) { - currentCodePathSegments.delete(segment); - }, - - onCodePathSegmentEnd(segment) { - currentCodePathSegments.delete(segment); - }, - - onCodePathSegmentStart(segment, node) { - - currentCodePathSegments.add(segment); - - if (isLoopingTarget(node)) { - const loop = node.parent; - - loopsByTargetSegments.set(segment, loop); - } - }, - - onCodePathSegmentLoop(_, toSegment, node) { - const loop = loopsByTargetSegments.get(toSegment); - - /** - * The second iteration is reachable, meaning that the loop is valid by the logic of this rule, - * only if there is at least one loop event with the appropriate target (which has been already - * determined in the `loopsByTargetSegments` map), raised from either: - * - * - the end of the loop's body (in which case `node === loop`) - * - a `continue` statement - * - * This condition skips loop events raised from `ForInStatement > .right` and `ForOfStatement > .right` nodes. - */ - if (node === loop || node.type === "ContinueStatement") { - - // Removes loop if it exists in the set. Otherwise, `Set#delete` has no effect and doesn't throw. - loopsToReport.delete(loop); - } - }, - - [loopSelector](node) { - - /** - * Ignore unreachable loop statements to avoid unnecessary complexity in the implementation, or false positives otherwise. - * For unreachable segments, the code path analysis does not raise events required for this implementation. - */ - if (isAnySegmentReachable(currentCodePathSegments)) { - loopsToReport.add(node); - } - }, - - - "Program:exit"() { - loopsToReport.forEach( - node => context.report({ node, messageId: "invalid" }) - ); - } - }; - } -}; diff --git a/tools/eslint/node_modules/eslint/lib/rules/no-unreachable.js b/tools/eslint/node_modules/eslint/lib/rules/no-unreachable.js deleted file mode 100644 index 0cf750e4251edb..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/rules/no-unreachable.js +++ /dev/null @@ -1,293 +0,0 @@ -/** - * @fileoverview Checks for unreachable code due to return, throws, break, and continue. - * @author Joel Feenstra - */ -"use strict"; - -//------------------------------------------------------------------------------ -// Helpers -//------------------------------------------------------------------------------ - -/** - * @typedef {Object} ConstructorInfo - * @property {ConstructorInfo | null} upper Info about the constructor that encloses this constructor. - * @property {boolean} hasSuperCall The flag about having `super()` expressions. - */ - -/** - * Checks whether or not a given variable declarator has the initializer. - * @param {ASTNode} node A VariableDeclarator node to check. - * @returns {boolean} `true` if the node has the initializer. - */ -function isInitialized(node) { - return Boolean(node.init); -} - -/** - * Checks all segments in a set and returns true if all are unreachable. - * @param {Set} segments The segments to check. - * @returns {boolean} True if all segments are unreachable; false otherwise. - */ -function areAllSegmentsUnreachable(segments) { - - for (const segment of segments) { - if (segment.reachable) { - return false; - } - } - - return true; -} - -/** - * The class to distinguish consecutive unreachable statements. - */ -class ConsecutiveRange { - constructor(sourceCode) { - this.sourceCode = sourceCode; - this.startNode = null; - this.endNode = null; - } - - /** - * The location object of this range. - * @type {Object} - */ - get location() { - return { - start: this.startNode.loc.start, - end: this.endNode.loc.end - }; - } - - /** - * `true` if this range is empty. - * @type {boolean} - */ - get isEmpty() { - return !(this.startNode && this.endNode); - } - - /** - * Checks whether the given node is inside of this range. - * @param {ASTNode|Token} node The node to check. - * @returns {boolean} `true` if the node is inside of this range. - */ - contains(node) { - return ( - node.range[0] >= this.startNode.range[0] && - node.range[1] <= this.endNode.range[1] - ); - } - - /** - * Checks whether the given node is consecutive to this range. - * @param {ASTNode} node The node to check. - * @returns {boolean} `true` if the node is consecutive to this range. - */ - isConsecutive(node) { - return this.contains(this.sourceCode.getTokenBefore(node)); - } - - /** - * Merges the given node to this range. - * @param {ASTNode} node The node to merge. - * @returns {void} - */ - merge(node) { - this.endNode = node; - } - - /** - * Resets this range by the given node or null. - * @param {ASTNode|null} node The node to reset, or null. - * @returns {void} - */ - reset(node) { - this.startNode = this.endNode = node; - } -} - -//------------------------------------------------------------------------------ -// Rule Definition -//------------------------------------------------------------------------------ - -/** @type {import('../shared/types').Rule} */ -module.exports = { - meta: { - type: "problem", - - docs: { - description: "Disallow unreachable code after `return`, `throw`, `continue`, and `break` statements", - recommended: true, - url: "https://eslint.org/docs/latest/rules/no-unreachable" - }, - - schema: [], - - messages: { - unreachableCode: "Unreachable code." - } - }, - - create(context) { - - /** @type {ConstructorInfo | null} */ - let constructorInfo = null; - - /** @type {ConsecutiveRange} */ - const range = new ConsecutiveRange(context.sourceCode); - - /** @type {Array>} */ - const codePathSegments = []; - - /** @type {Set} */ - let currentCodePathSegments = new Set(); - - /** - * Reports a given node if it's unreachable. - * @param {ASTNode} node A statement node to report. - * @returns {void} - */ - function reportIfUnreachable(node) { - let nextNode = null; - - if (node && (node.type === "PropertyDefinition" || areAllSegmentsUnreachable(currentCodePathSegments))) { - - // Store this statement to distinguish consecutive statements. - if (range.isEmpty) { - range.reset(node); - return; - } - - // Skip if this statement is inside of the current range. - if (range.contains(node)) { - return; - } - - // Merge if this statement is consecutive to the current range. - if (range.isConsecutive(node)) { - range.merge(node); - return; - } - - nextNode = node; - } - - /* - * Report the current range since this statement is reachable or is - * not consecutive to the current range. - */ - if (!range.isEmpty) { - context.report({ - messageId: "unreachableCode", - loc: range.location, - node: range.startNode - }); - } - - // Update the current range. - range.reset(nextNode); - } - - return { - - // Manages the current code path. - onCodePathStart() { - codePathSegments.push(currentCodePathSegments); - currentCodePathSegments = new Set(); - }, - - onCodePathEnd() { - currentCodePathSegments = codePathSegments.pop(); - }, - - onUnreachableCodePathSegmentStart(segment) { - currentCodePathSegments.add(segment); - }, - - onUnreachableCodePathSegmentEnd(segment) { - currentCodePathSegments.delete(segment); - }, - - onCodePathSegmentEnd(segment) { - currentCodePathSegments.delete(segment); - }, - - onCodePathSegmentStart(segment) { - currentCodePathSegments.add(segment); - }, - - // Registers for all statement nodes (excludes FunctionDeclaration). - BlockStatement: reportIfUnreachable, - BreakStatement: reportIfUnreachable, - ClassDeclaration: reportIfUnreachable, - ContinueStatement: reportIfUnreachable, - DebuggerStatement: reportIfUnreachable, - DoWhileStatement: reportIfUnreachable, - ExpressionStatement: reportIfUnreachable, - ForInStatement: reportIfUnreachable, - ForOfStatement: reportIfUnreachable, - ForStatement: reportIfUnreachable, - IfStatement: reportIfUnreachable, - ImportDeclaration: reportIfUnreachable, - LabeledStatement: reportIfUnreachable, - ReturnStatement: reportIfUnreachable, - SwitchStatement: reportIfUnreachable, - ThrowStatement: reportIfUnreachable, - TryStatement: reportIfUnreachable, - - VariableDeclaration(node) { - if (node.kind !== "var" || node.declarations.some(isInitialized)) { - reportIfUnreachable(node); - } - }, - - WhileStatement: reportIfUnreachable, - WithStatement: reportIfUnreachable, - ExportNamedDeclaration: reportIfUnreachable, - ExportDefaultDeclaration: reportIfUnreachable, - ExportAllDeclaration: reportIfUnreachable, - - "Program:exit"() { - reportIfUnreachable(); - }, - - /* - * Instance fields defined in a subclass are never created if the constructor of the subclass - * doesn't call `super()`, so their definitions are unreachable code. - */ - "MethodDefinition[kind='constructor']"() { - constructorInfo = { - upper: constructorInfo, - hasSuperCall: false - }; - }, - "MethodDefinition[kind='constructor']:exit"(node) { - const { hasSuperCall } = constructorInfo; - - constructorInfo = constructorInfo.upper; - - // skip typescript constructors without the body - if (!node.value.body) { - return; - } - - const classDefinition = node.parent.parent; - - if (classDefinition.superClass && !hasSuperCall) { - for (const element of classDefinition.body.body) { - if (element.type === "PropertyDefinition" && !element.static) { - reportIfUnreachable(element); - } - } - } - }, - "CallExpression > Super.callee"() { - if (constructorInfo) { - constructorInfo.hasSuperCall = true; - } - } - }; - } -}; diff --git a/tools/eslint/node_modules/eslint/lib/rules/no-unsafe-finally.js b/tools/eslint/node_modules/eslint/lib/rules/no-unsafe-finally.js deleted file mode 100644 index ebd24328ffbbde..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/rules/no-unsafe-finally.js +++ /dev/null @@ -1,111 +0,0 @@ -/** - * @fileoverview Rule to flag unsafe statements in finally block - * @author Onur Temizkan - */ - -"use strict"; - -//------------------------------------------------------------------------------ -// Helpers -//------------------------------------------------------------------------------ - -const SENTINEL_NODE_TYPE_RETURN_THROW = /^(?:Program|(?:Function|Class)(?:Declaration|Expression)|ArrowFunctionExpression)$/u; -const SENTINEL_NODE_TYPE_BREAK = /^(?:Program|(?:Function|Class)(?:Declaration|Expression)|ArrowFunctionExpression|DoWhileStatement|WhileStatement|ForOfStatement|ForInStatement|ForStatement|SwitchStatement)$/u; -const SENTINEL_NODE_TYPE_CONTINUE = /^(?:Program|(?:Function|Class)(?:Declaration|Expression)|ArrowFunctionExpression|DoWhileStatement|WhileStatement|ForOfStatement|ForInStatement|ForStatement)$/u; - - -//------------------------------------------------------------------------------ -// Rule Definition -//------------------------------------------------------------------------------ - -/** @type {import('../shared/types').Rule} */ -module.exports = { - meta: { - type: "problem", - - docs: { - description: "Disallow control flow statements in `finally` blocks", - recommended: true, - url: "https://eslint.org/docs/latest/rules/no-unsafe-finally" - }, - - schema: [], - - messages: { - unsafeUsage: "Unsafe usage of {{nodeType}}." - } - }, - create(context) { - - /** - * Checks if the node is the finalizer of a TryStatement - * @param {ASTNode} node node to check. - * @returns {boolean} - true if the node is the finalizer of a TryStatement - */ - function isFinallyBlock(node) { - return node.parent.type === "TryStatement" && node.parent.finalizer === node; - } - - /** - * Climbs up the tree if the node is not a sentinel node - * @param {ASTNode} node node to check. - * @param {string} label label of the break or continue statement - * @returns {boolean} - return whether the node is a finally block or a sentinel node - */ - function isInFinallyBlock(node, label) { - let labelInside = false; - let sentinelNodeType; - - if (node.type === "BreakStatement" && !node.label) { - sentinelNodeType = SENTINEL_NODE_TYPE_BREAK; - } else if (node.type === "ContinueStatement") { - sentinelNodeType = SENTINEL_NODE_TYPE_CONTINUE; - } else { - sentinelNodeType = SENTINEL_NODE_TYPE_RETURN_THROW; - } - - for ( - let currentNode = node; - currentNode && !sentinelNodeType.test(currentNode.type); - currentNode = currentNode.parent - ) { - if (currentNode.parent.label && label && (currentNode.parent.label.name === label.name)) { - labelInside = true; - } - if (isFinallyBlock(currentNode)) { - if (label && labelInside) { - return false; - } - return true; - } - } - return false; - } - - /** - * Checks whether the possibly-unsafe statement is inside a finally block. - * @param {ASTNode} node node to check. - * @returns {void} - */ - function check(node) { - if (isInFinallyBlock(node, node.label)) { - context.report({ - messageId: "unsafeUsage", - data: { - nodeType: node.type - }, - node, - line: node.loc.line, - column: node.loc.column - }); - } - } - - return { - ReturnStatement: check, - ThrowStatement: check, - BreakStatement: check, - ContinueStatement: check - }; - } -}; diff --git a/tools/eslint/node_modules/eslint/lib/rules/no-unsafe-negation.js b/tools/eslint/node_modules/eslint/lib/rules/no-unsafe-negation.js deleted file mode 100644 index cabd7e2ccc2c4a..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/rules/no-unsafe-negation.js +++ /dev/null @@ -1,128 +0,0 @@ -/** - * @fileoverview Rule to disallow negating the left operand of relational operators - * @author Toru Nagashima - */ - -"use strict"; - -//------------------------------------------------------------------------------ -// Requirements -//------------------------------------------------------------------------------ - -const astUtils = require("./utils/ast-utils"); - -//------------------------------------------------------------------------------ -// Helpers -//------------------------------------------------------------------------------ - -/** - * Checks whether the given operator is `in` or `instanceof` - * @param {string} op The operator type to check. - * @returns {boolean} `true` if the operator is `in` or `instanceof` - */ -function isInOrInstanceOfOperator(op) { - return op === "in" || op === "instanceof"; -} - -/** - * Checks whether the given operator is an ordering relational operator or not. - * @param {string} op The operator type to check. - * @returns {boolean} `true` if the operator is an ordering relational operator. - */ -function isOrderingRelationalOperator(op) { - return op === "<" || op === ">" || op === ">=" || op === "<="; -} - -/** - * Checks whether the given node is a logical negation expression or not. - * @param {ASTNode} node The node to check. - * @returns {boolean} `true` if the node is a logical negation expression. - */ -function isNegation(node) { - return node.type === "UnaryExpression" && node.operator === "!"; -} - -//------------------------------------------------------------------------------ -// Rule Definition -//------------------------------------------------------------------------------ - -/** @type {import('../shared/types').Rule} */ -module.exports = { - meta: { - type: "problem", - - docs: { - description: "Disallow negating the left operand of relational operators", - recommended: true, - url: "https://eslint.org/docs/latest/rules/no-unsafe-negation" - }, - - hasSuggestions: true, - - schema: [ - { - type: "object", - properties: { - enforceForOrderingRelations: { - type: "boolean", - default: false - } - }, - additionalProperties: false - } - ], - - fixable: null, - - messages: { - unexpected: "Unexpected negating the left operand of '{{operator}}' operator.", - suggestNegatedExpression: "Negate '{{operator}}' expression instead of its left operand. This changes the current behavior.", - suggestParenthesisedNegation: "Wrap negation in '()' to make the intention explicit. This preserves the current behavior." - } - }, - - create(context) { - const sourceCode = context.sourceCode; - const options = context.options[0] || {}; - const enforceForOrderingRelations = options.enforceForOrderingRelations === true; - - return { - BinaryExpression(node) { - const operator = node.operator; - const orderingRelationRuleApplies = enforceForOrderingRelations && isOrderingRelationalOperator(operator); - - if ( - (isInOrInstanceOfOperator(operator) || orderingRelationRuleApplies) && - isNegation(node.left) && - !astUtils.isParenthesised(sourceCode, node.left) - ) { - context.report({ - node, - loc: node.left.loc, - messageId: "unexpected", - data: { operator }, - suggest: [ - { - messageId: "suggestNegatedExpression", - data: { operator }, - fix(fixer) { - const negationToken = sourceCode.getFirstToken(node.left); - const fixRange = [negationToken.range[1], node.range[1]]; - const text = sourceCode.text.slice(fixRange[0], fixRange[1]); - - return fixer.replaceTextRange(fixRange, `(${text})`); - } - }, - { - messageId: "suggestParenthesisedNegation", - fix(fixer) { - return fixer.replaceText(node.left, `(${sourceCode.getText(node.left)})`); - } - } - ] - }); - } - } - }; - } -}; diff --git a/tools/eslint/node_modules/eslint/lib/rules/no-unsafe-optional-chaining.js b/tools/eslint/node_modules/eslint/lib/rules/no-unsafe-optional-chaining.js deleted file mode 100644 index fa787939649f4a..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/rules/no-unsafe-optional-chaining.js +++ /dev/null @@ -1,205 +0,0 @@ -/** - * @fileoverview Rule to disallow unsafe optional chaining - * @author Yeon JuAn - */ - -"use strict"; - -const UNSAFE_ARITHMETIC_OPERATORS = new Set(["+", "-", "/", "*", "%", "**"]); -const UNSAFE_ASSIGNMENT_OPERATORS = new Set(["+=", "-=", "/=", "*=", "%=", "**="]); -const UNSAFE_RELATIONAL_OPERATORS = new Set(["in", "instanceof"]); - -/** - * Checks whether a node is a destructuring pattern or not - * @param {ASTNode} node node to check - * @returns {boolean} `true` if a node is a destructuring pattern, otherwise `false` - */ -function isDestructuringPattern(node) { - return node.type === "ObjectPattern" || node.type === "ArrayPattern"; -} - -/** @type {import('../shared/types').Rule} */ -module.exports = { - meta: { - type: "problem", - - docs: { - description: "Disallow use of optional chaining in contexts where the `undefined` value is not allowed", - recommended: true, - url: "https://eslint.org/docs/latest/rules/no-unsafe-optional-chaining" - }, - schema: [{ - type: "object", - properties: { - disallowArithmeticOperators: { - type: "boolean", - default: false - } - }, - additionalProperties: false - }], - fixable: null, - messages: { - unsafeOptionalChain: "Unsafe usage of optional chaining. If it short-circuits with 'undefined' the evaluation will throw TypeError.", - unsafeArithmetic: "Unsafe arithmetic operation on optional chaining. It can result in NaN." - } - }, - - create(context) { - const options = context.options[0] || {}; - const disallowArithmeticOperators = (options.disallowArithmeticOperators) || false; - - /** - * Reports unsafe usage of optional chaining - * @param {ASTNode} node node to report - * @returns {void} - */ - function reportUnsafeUsage(node) { - context.report({ - messageId: "unsafeOptionalChain", - node - }); - } - - /** - * Reports unsafe arithmetic operation on optional chaining - * @param {ASTNode} node node to report - * @returns {void} - */ - function reportUnsafeArithmetic(node) { - context.report({ - messageId: "unsafeArithmetic", - node - }); - } - - /** - * Checks and reports if a node can short-circuit with `undefined` by optional chaining. - * @param {ASTNode} [node] node to check - * @param {Function} reportFunc report function - * @returns {void} - */ - function checkUndefinedShortCircuit(node, reportFunc) { - if (!node) { - return; - } - switch (node.type) { - case "LogicalExpression": - if (node.operator === "||" || node.operator === "??") { - checkUndefinedShortCircuit(node.right, reportFunc); - } else if (node.operator === "&&") { - checkUndefinedShortCircuit(node.left, reportFunc); - checkUndefinedShortCircuit(node.right, reportFunc); - } - break; - case "SequenceExpression": - checkUndefinedShortCircuit( - node.expressions.at(-1), - reportFunc - ); - break; - case "ConditionalExpression": - checkUndefinedShortCircuit(node.consequent, reportFunc); - checkUndefinedShortCircuit(node.alternate, reportFunc); - break; - case "AwaitExpression": - checkUndefinedShortCircuit(node.argument, reportFunc); - break; - case "ChainExpression": - reportFunc(node); - break; - default: - break; - } - } - - /** - * Checks unsafe usage of optional chaining - * @param {ASTNode} node node to check - * @returns {void} - */ - function checkUnsafeUsage(node) { - checkUndefinedShortCircuit(node, reportUnsafeUsage); - } - - /** - * Checks unsafe arithmetic operations on optional chaining - * @param {ASTNode} node node to check - * @returns {void} - */ - function checkUnsafeArithmetic(node) { - checkUndefinedShortCircuit(node, reportUnsafeArithmetic); - } - - return { - "AssignmentExpression, AssignmentPattern"(node) { - if (isDestructuringPattern(node.left)) { - checkUnsafeUsage(node.right); - } - }, - "ClassDeclaration, ClassExpression"(node) { - checkUnsafeUsage(node.superClass); - }, - CallExpression(node) { - if (!node.optional) { - checkUnsafeUsage(node.callee); - } - }, - NewExpression(node) { - checkUnsafeUsage(node.callee); - }, - VariableDeclarator(node) { - if (isDestructuringPattern(node.id)) { - checkUnsafeUsage(node.init); - } - }, - MemberExpression(node) { - if (!node.optional) { - checkUnsafeUsage(node.object); - } - }, - TaggedTemplateExpression(node) { - checkUnsafeUsage(node.tag); - }, - ForOfStatement(node) { - checkUnsafeUsage(node.right); - }, - SpreadElement(node) { - if (node.parent && node.parent.type !== "ObjectExpression") { - checkUnsafeUsage(node.argument); - } - }, - BinaryExpression(node) { - if (UNSAFE_RELATIONAL_OPERATORS.has(node.operator)) { - checkUnsafeUsage(node.right); - } - if ( - disallowArithmeticOperators && - UNSAFE_ARITHMETIC_OPERATORS.has(node.operator) - ) { - checkUnsafeArithmetic(node.right); - checkUnsafeArithmetic(node.left); - } - }, - WithStatement(node) { - checkUnsafeUsage(node.object); - }, - UnaryExpression(node) { - if ( - disallowArithmeticOperators && - UNSAFE_ARITHMETIC_OPERATORS.has(node.operator) - ) { - checkUnsafeArithmetic(node.argument); - } - }, - AssignmentExpression(node) { - if ( - disallowArithmeticOperators && - UNSAFE_ASSIGNMENT_OPERATORS.has(node.operator) - ) { - checkUnsafeArithmetic(node.right); - } - } - }; - } -}; diff --git a/tools/eslint/node_modules/eslint/lib/rules/no-unused-expressions.js b/tools/eslint/node_modules/eslint/lib/rules/no-unused-expressions.js deleted file mode 100644 index 46bb7baac223cf..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/rules/no-unused-expressions.js +++ /dev/null @@ -1,186 +0,0 @@ -/** - * @fileoverview Flag expressions in statement position that do not side effect - * @author Michael Ficarra - */ -"use strict"; - -const astUtils = require("./utils/ast-utils"); - -//------------------------------------------------------------------------------ -// Rule Definition -//------------------------------------------------------------------------------ - -/** - * Returns `true`. - * @returns {boolean} `true`. - */ -function alwaysTrue() { - return true; -} - -/** - * Returns `false`. - * @returns {boolean} `false`. - */ -function alwaysFalse() { - return false; -} - -/** @type {import('../shared/types').Rule} */ -module.exports = { - meta: { - type: "suggestion", - - docs: { - description: "Disallow unused expressions", - recommended: false, - url: "https://eslint.org/docs/latest/rules/no-unused-expressions" - }, - - schema: [ - { - type: "object", - properties: { - allowShortCircuit: { - type: "boolean", - default: false - }, - allowTernary: { - type: "boolean", - default: false - }, - allowTaggedTemplates: { - type: "boolean", - default: false - }, - enforceForJSX: { - type: "boolean", - default: false - } - }, - additionalProperties: false - } - ], - - messages: { - unusedExpression: "Expected an assignment or function call and instead saw an expression." - } - }, - - create(context) { - const config = context.options[0] || {}, - allowShortCircuit = config.allowShortCircuit || false, - allowTernary = config.allowTernary || false, - allowTaggedTemplates = config.allowTaggedTemplates || false, - enforceForJSX = config.enforceForJSX || false; - - /** - * Has AST suggesting a directive. - * @param {ASTNode} node any node - * @returns {boolean} whether the given node structurally represents a directive - */ - function looksLikeDirective(node) { - return node.type === "ExpressionStatement" && - node.expression.type === "Literal" && typeof node.expression.value === "string"; - } - - /** - * Gets the leading sequence of members in a list that pass the predicate. - * @param {Function} predicate ([a] -> Boolean) the function used to make the determination - * @param {a[]} list the input list - * @returns {a[]} the leading sequence of members in the given list that pass the given predicate - */ - function takeWhile(predicate, list) { - for (let i = 0; i < list.length; ++i) { - if (!predicate(list[i])) { - return list.slice(0, i); - } - } - return list.slice(); - } - - /** - * Gets leading directives nodes in a Node body. - * @param {ASTNode} node a Program or BlockStatement node - * @returns {ASTNode[]} the leading sequence of directive nodes in the given node's body - */ - function directives(node) { - return takeWhile(looksLikeDirective, node.body); - } - - /** - * Detect if a Node is a directive. - * @param {ASTNode} node any node - * @returns {boolean} whether the given node is considered a directive in its current position - */ - function isDirective(node) { - - /** - * https://tc39.es/ecma262/#directive-prologue - * - * Only `FunctionBody`, `ScriptBody` and `ModuleBody` can have directive prologue. - * Class static blocks do not have directive prologue. - */ - return astUtils.isTopLevelExpressionStatement(node) && directives(node.parent).includes(node); - } - - /** - * The member functions return `true` if the type has no side-effects. - * Unknown nodes are handled as `false`, then this rule ignores those. - */ - const Checker = Object.assign(Object.create(null), { - isDisallowed(node) { - return (Checker[node.type] || alwaysFalse)(node); - }, - - ArrayExpression: alwaysTrue, - ArrowFunctionExpression: alwaysTrue, - BinaryExpression: alwaysTrue, - ChainExpression(node) { - return Checker.isDisallowed(node.expression); - }, - ClassExpression: alwaysTrue, - ConditionalExpression(node) { - if (allowTernary) { - return Checker.isDisallowed(node.consequent) || Checker.isDisallowed(node.alternate); - } - return true; - }, - FunctionExpression: alwaysTrue, - Identifier: alwaysTrue, - JSXElement() { - return enforceForJSX; - }, - JSXFragment() { - return enforceForJSX; - }, - Literal: alwaysTrue, - LogicalExpression(node) { - if (allowShortCircuit) { - return Checker.isDisallowed(node.right); - } - return true; - }, - MemberExpression: alwaysTrue, - MetaProperty: alwaysTrue, - ObjectExpression: alwaysTrue, - SequenceExpression: alwaysTrue, - TaggedTemplateExpression() { - return !allowTaggedTemplates; - }, - TemplateLiteral: alwaysTrue, - ThisExpression: alwaysTrue, - UnaryExpression(node) { - return node.operator !== "void" && node.operator !== "delete"; - } - }); - - return { - ExpressionStatement(node) { - if (Checker.isDisallowed(node.expression) && !isDirective(node)) { - context.report({ node, messageId: "unusedExpression" }); - } - } - }; - } -}; diff --git a/tools/eslint/node_modules/eslint/lib/rules/no-unused-labels.js b/tools/eslint/node_modules/eslint/lib/rules/no-unused-labels.js deleted file mode 100644 index be06b324c49c2a..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/rules/no-unused-labels.js +++ /dev/null @@ -1,143 +0,0 @@ -/** - * @fileoverview Rule to disallow unused labels. - * @author Toru Nagashima - */ - -"use strict"; - -//------------------------------------------------------------------------------ -// Requirements -//------------------------------------------------------------------------------ - -const astUtils = require("./utils/ast-utils"); - -//------------------------------------------------------------------------------ -// Rule Definition -//------------------------------------------------------------------------------ - -/** @type {import('../shared/types').Rule} */ -module.exports = { - meta: { - type: "suggestion", - - docs: { - description: "Disallow unused labels", - recommended: true, - url: "https://eslint.org/docs/latest/rules/no-unused-labels" - }, - - schema: [], - - fixable: "code", - - messages: { - unused: "'{{name}}:' is defined but never used." - } - }, - - create(context) { - const sourceCode = context.sourceCode; - let scopeInfo = null; - - /** - * Adds a scope info to the stack. - * @param {ASTNode} node A node to add. This is a LabeledStatement. - * @returns {void} - */ - function enterLabeledScope(node) { - scopeInfo = { - label: node.label.name, - used: false, - upper: scopeInfo - }; - } - - /** - * Checks if a `LabeledStatement` node is fixable. - * For a node to be fixable, there must be no comments between the label and the body. - * Furthermore, is must be possible to remove the label without turning the body statement into a - * directive after other fixes are applied. - * @param {ASTNode} node The node to evaluate. - * @returns {boolean} Whether or not the node is fixable. - */ - function isFixable(node) { - - /* - * Only perform a fix if there are no comments between the label and the body. This will be the case - * when there is exactly one token/comment (the ":") between the label and the body. - */ - if (sourceCode.getTokenAfter(node.label, { includeComments: true }) !== - sourceCode.getTokenBefore(node.body, { includeComments: true })) { - return false; - } - - // Looking for the node's deepest ancestor which is not a `LabeledStatement`. - let ancestor = node.parent; - - while (ancestor.type === "LabeledStatement") { - ancestor = ancestor.parent; - } - - if (ancestor.type === "Program" || - (ancestor.type === "BlockStatement" && astUtils.isFunction(ancestor.parent))) { - const { body } = node; - - if (body.type === "ExpressionStatement" && - ((body.expression.type === "Literal" && typeof body.expression.value === "string") || - astUtils.isStaticTemplateLiteral(body.expression))) { - return false; // potential directive - } - } - return true; - } - - /** - * Removes the top of the stack. - * At the same time, this reports the label if it's never used. - * @param {ASTNode} node A node to report. This is a LabeledStatement. - * @returns {void} - */ - function exitLabeledScope(node) { - if (!scopeInfo.used) { - context.report({ - node: node.label, - messageId: "unused", - data: node.label, - fix: isFixable(node) ? fixer => fixer.removeRange([node.range[0], node.body.range[0]]) : null - }); - } - - scopeInfo = scopeInfo.upper; - } - - /** - * Marks the label of a given node as used. - * @param {ASTNode} node A node to mark. This is a BreakStatement or - * ContinueStatement. - * @returns {void} - */ - function markAsUsed(node) { - if (!node.label) { - return; - } - - const label = node.label.name; - let info = scopeInfo; - - while (info) { - if (info.label === label) { - info.used = true; - break; - } - info = info.upper; - } - } - - return { - LabeledStatement: enterLabeledScope, - "LabeledStatement:exit": exitLabeledScope, - BreakStatement: markAsUsed, - ContinueStatement: markAsUsed - }; - } -}; diff --git a/tools/eslint/node_modules/eslint/lib/rules/no-unused-private-class-members.js b/tools/eslint/node_modules/eslint/lib/rules/no-unused-private-class-members.js deleted file mode 100644 index bc05cd25180754..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/rules/no-unused-private-class-members.js +++ /dev/null @@ -1,195 +0,0 @@ -/** - * @fileoverview Rule to flag declared but unused private class members - * @author Tim van der Lippe - */ - -"use strict"; - -//------------------------------------------------------------------------------ -// Rule Definition -//------------------------------------------------------------------------------ - -/** @type {import('../shared/types').Rule} */ -module.exports = { - meta: { - type: "problem", - - docs: { - description: "Disallow unused private class members", - recommended: true, - url: "https://eslint.org/docs/latest/rules/no-unused-private-class-members" - }, - - schema: [], - - messages: { - unusedPrivateClassMember: "'{{classMemberName}}' is defined but never used." - } - }, - - create(context) { - const trackedClasses = []; - - /** - * Check whether the current node is in a write only assignment. - * @param {ASTNode} privateIdentifierNode Node referring to a private identifier - * @returns {boolean} Whether the node is in a write only assignment - * @private - */ - function isWriteOnlyAssignment(privateIdentifierNode) { - const parentStatement = privateIdentifierNode.parent.parent; - const isAssignmentExpression = parentStatement.type === "AssignmentExpression"; - - if (!isAssignmentExpression && - parentStatement.type !== "ForInStatement" && - parentStatement.type !== "ForOfStatement" && - parentStatement.type !== "AssignmentPattern") { - return false; - } - - // It is a write-only usage, since we still allow usages on the right for reads - if (parentStatement.left !== privateIdentifierNode.parent) { - return false; - } - - // For any other operator (such as '+=') we still consider it a read operation - if (isAssignmentExpression && parentStatement.operator !== "=") { - - /* - * However, if the read operation is "discarded" in an empty statement, then - * we consider it write only. - */ - return parentStatement.parent.type === "ExpressionStatement"; - } - - return true; - } - - //-------------------------------------------------------------------------- - // Public - //-------------------------------------------------------------------------- - - return { - - // Collect all declared members up front and assume they are all unused - ClassBody(classBodyNode) { - const privateMembers = new Map(); - - trackedClasses.unshift(privateMembers); - for (const bodyMember of classBodyNode.body) { - if (bodyMember.type === "PropertyDefinition" || bodyMember.type === "MethodDefinition") { - if (bodyMember.key.type === "PrivateIdentifier") { - privateMembers.set(bodyMember.key.name, { - declaredNode: bodyMember, - isAccessor: bodyMember.type === "MethodDefinition" && - (bodyMember.kind === "set" || bodyMember.kind === "get") - }); - } - } - } - }, - - /* - * Process all usages of the private identifier and remove a member from - * `declaredAndUnusedPrivateMembers` if we deem it used. - */ - PrivateIdentifier(privateIdentifierNode) { - const classBody = trackedClasses.find(classProperties => classProperties.has(privateIdentifierNode.name)); - - // Can't happen, as it is a parser to have a missing class body, but let's code defensively here. - if (!classBody) { - return; - } - - // In case any other usage was already detected, we can short circuit the logic here. - const memberDefinition = classBody.get(privateIdentifierNode.name); - - if (memberDefinition.isUsed) { - return; - } - - // The definition of the class member itself - if (privateIdentifierNode.parent.type === "PropertyDefinition" || - privateIdentifierNode.parent.type === "MethodDefinition") { - return; - } - - /* - * Any usage of an accessor is considered a read, as the getter/setter can have - * side-effects in its definition. - */ - if (memberDefinition.isAccessor) { - memberDefinition.isUsed = true; - return; - } - - // Any assignments to this member, except for assignments that also read - if (isWriteOnlyAssignment(privateIdentifierNode)) { - return; - } - - const wrappingExpressionType = privateIdentifierNode.parent.parent.type; - const parentOfWrappingExpressionType = privateIdentifierNode.parent.parent.parent.type; - - // A statement which only increments (`this.#x++;`) - if (wrappingExpressionType === "UpdateExpression" && - parentOfWrappingExpressionType === "ExpressionStatement") { - return; - } - - /* - * ({ x: this.#usedInDestructuring } = bar); - * - * But should treat the following as a read: - * ({ [this.#x]: a } = foo); - */ - if (wrappingExpressionType === "Property" && - parentOfWrappingExpressionType === "ObjectPattern" && - privateIdentifierNode.parent.parent.value === privateIdentifierNode.parent) { - return; - } - - // [...this.#unusedInRestPattern] = bar; - if (wrappingExpressionType === "RestElement") { - return; - } - - // [this.#unusedInAssignmentPattern] = bar; - if (wrappingExpressionType === "ArrayPattern") { - return; - } - - /* - * We can't delete the memberDefinition, as we need to keep track of which member we are marking as used. - * In the case of nested classes, we only mark the first member we encounter as used. If you were to delete - * the member, then any subsequent usage could incorrectly mark the member of an encapsulating parent class - * as used, which is incorrect. - */ - memberDefinition.isUsed = true; - }, - - /* - * Post-process the class members and report any remaining members. - * Since private members can only be accessed in the current class context, - * we can safely assume that all usages are within the current class body. - */ - "ClassBody:exit"() { - const unusedPrivateMembers = trackedClasses.shift(); - - for (const [classMemberName, { declaredNode, isUsed }] of unusedPrivateMembers.entries()) { - if (isUsed) { - continue; - } - context.report({ - node: declaredNode, - loc: declaredNode.key.loc, - messageId: "unusedPrivateClassMember", - data: { - classMemberName: `#${classMemberName}` - } - }); - } - } - }; - } -}; diff --git a/tools/eslint/node_modules/eslint/lib/rules/no-unused-vars.js b/tools/eslint/node_modules/eslint/lib/rules/no-unused-vars.js deleted file mode 100644 index 60454929047de3..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/rules/no-unused-vars.js +++ /dev/null @@ -1,881 +0,0 @@ -/** - * @fileoverview Rule to flag declared but unused variables - * @author Ilya Volodin - */ - -"use strict"; - -//------------------------------------------------------------------------------ -// Requirements -//------------------------------------------------------------------------------ - -const astUtils = require("./utils/ast-utils"); - -//------------------------------------------------------------------------------ -// Typedefs -//------------------------------------------------------------------------------ - -/** - * A simple name for the types of variables that this rule supports - * @typedef {'array-destructure'|'catch-clause'|'parameter'|'variable'} VariableType - */ - -/** - * Bag of data used for formatting the `unusedVar` lint message. - * @typedef {Object} UnusedVarMessageData - * @property {string} varName The name of the unused var. - * @property {'defined'|'assigned a value'} action Description of the vars state. - * @property {string} additional Any additional info to be appended at the end. - */ - -/** - * Bag of data used for formatting the `usedIgnoredVar` lint message. - * @typedef {Object} UsedIgnoredVarMessageData - * @property {string} varName The name of the unused var. - * @property {string} additional Any additional info to be appended at the end. - */ - -//------------------------------------------------------------------------------ -// Rule Definition -//------------------------------------------------------------------------------ - -/** @type {import('../shared/types').Rule} */ -module.exports = { - meta: { - type: "problem", - - docs: { - description: "Disallow unused variables", - recommended: true, - url: "https://eslint.org/docs/latest/rules/no-unused-vars" - }, - - schema: [ - { - oneOf: [ - { - enum: ["all", "local"] - }, - { - type: "object", - properties: { - vars: { - enum: ["all", "local"] - }, - varsIgnorePattern: { - type: "string" - }, - args: { - enum: ["all", "after-used", "none"] - }, - ignoreRestSiblings: { - type: "boolean" - }, - argsIgnorePattern: { - type: "string" - }, - caughtErrors: { - enum: ["all", "none"] - }, - caughtErrorsIgnorePattern: { - type: "string" - }, - destructuredArrayIgnorePattern: { - type: "string" - }, - ignoreClassWithStaticInitBlock: { - type: "boolean" - }, - reportUsedIgnorePattern: { - type: "boolean" - } - }, - additionalProperties: false - } - ] - } - ], - - messages: { - unusedVar: "'{{varName}}' is {{action}} but never used{{additional}}.", - usedIgnoredVar: "'{{varName}}' is marked as ignored but is used{{additional}}." - } - }, - - create(context) { - const sourceCode = context.sourceCode; - - const REST_PROPERTY_TYPE = /^(?:RestElement|(?:Experimental)?RestProperty)$/u; - - const config = { - vars: "all", - args: "after-used", - ignoreRestSiblings: false, - caughtErrors: "all", - ignoreClassWithStaticInitBlock: false, - reportUsedIgnorePattern: false - }; - - const firstOption = context.options[0]; - - if (firstOption) { - if (typeof firstOption === "string") { - config.vars = firstOption; - } else { - config.vars = firstOption.vars || config.vars; - config.args = firstOption.args || config.args; - config.ignoreRestSiblings = firstOption.ignoreRestSiblings || config.ignoreRestSiblings; - config.caughtErrors = firstOption.caughtErrors || config.caughtErrors; - config.ignoreClassWithStaticInitBlock = firstOption.ignoreClassWithStaticInitBlock || config.ignoreClassWithStaticInitBlock; - config.reportUsedIgnorePattern = firstOption.reportUsedIgnorePattern || config.reportUsedIgnorePattern; - - if (firstOption.varsIgnorePattern) { - config.varsIgnorePattern = new RegExp(firstOption.varsIgnorePattern, "u"); - } - - if (firstOption.argsIgnorePattern) { - config.argsIgnorePattern = new RegExp(firstOption.argsIgnorePattern, "u"); - } - - if (firstOption.caughtErrorsIgnorePattern) { - config.caughtErrorsIgnorePattern = new RegExp(firstOption.caughtErrorsIgnorePattern, "u"); - } - - if (firstOption.destructuredArrayIgnorePattern) { - config.destructuredArrayIgnorePattern = new RegExp(firstOption.destructuredArrayIgnorePattern, "u"); - } - } - } - - /** - * Determines what variable type a def is. - * @param {Object} def the declaration to check - * @returns {VariableType} a simple name for the types of variables that this rule supports - */ - function defToVariableType(def) { - - /* - * This `destructuredArrayIgnorePattern` error report works differently from the catch - * clause and parameter error reports. _Both_ the `varsIgnorePattern` and the - * `destructuredArrayIgnorePattern` will be checked for array destructuring. However, - * for the purposes of the report, the currently defined behavior is to only inform the - * user of the `destructuredArrayIgnorePattern` if it's present (regardless of the fact - * that the `varsIgnorePattern` would also apply). If it's not present, the user will be - * informed of the `varsIgnorePattern`, assuming that's present. - */ - if (config.destructuredArrayIgnorePattern && def.name.parent.type === "ArrayPattern") { - return "array-destructure"; - } - - switch (def.type) { - case "CatchClause": - return "catch-clause"; - case "Parameter": - return "parameter"; - default: - return "variable"; - } - } - - /** - * Gets a given variable's description and configured ignore pattern - * based on the provided variableType - * @param {VariableType} variableType a simple name for the types of variables that this rule supports - * @throws {Error} (Unreachable) - * @returns {[string | undefined, string | undefined]} the given variable's description and - * ignore pattern - */ - function getVariableDescription(variableType) { - let pattern; - let variableDescription; - - switch (variableType) { - case "array-destructure": - pattern = config.destructuredArrayIgnorePattern; - variableDescription = "elements of array destructuring"; - break; - - case "catch-clause": - pattern = config.caughtErrorsIgnorePattern; - variableDescription = "caught errors"; - break; - - case "parameter": - pattern = config.argsIgnorePattern; - variableDescription = "args"; - break; - - case "variable": - pattern = config.varsIgnorePattern; - variableDescription = "vars"; - break; - - default: - throw new Error(`Unexpected variable type: ${variableType}`); - } - - if (pattern) { - pattern = pattern.toString(); - } - - return [variableDescription, pattern]; - } - - /** - * Generates the message data about the variable being defined and unused, - * including the ignore pattern if configured. - * @param {Variable} unusedVar eslint-scope variable object. - * @returns {UnusedVarMessageData} The message data to be used with this unused variable. - */ - function getDefinedMessageData(unusedVar) { - const def = unusedVar.defs && unusedVar.defs[0]; - let additionalMessageData = ""; - - if (def) { - const [variableDescription, pattern] = getVariableDescription(defToVariableType(def)); - - if (pattern && variableDescription) { - additionalMessageData = `. Allowed unused ${variableDescription} must match ${pattern}`; - } - } - - return { - varName: unusedVar.name, - action: "defined", - additional: additionalMessageData - }; - } - - /** - * Generate the warning message about the variable being - * assigned and unused, including the ignore pattern if configured. - * @param {Variable} unusedVar eslint-scope variable object. - * @returns {UnusedVarMessageData} The message data to be used with this unused variable. - */ - function getAssignedMessageData(unusedVar) { - const def = unusedVar.defs && unusedVar.defs[0]; - let additionalMessageData = ""; - - if (def) { - const [variableDescription, pattern] = getVariableDescription(defToVariableType(def)); - - if (pattern && variableDescription) { - additionalMessageData = `. Allowed unused ${variableDescription} must match ${pattern}`; - } - } - - return { - varName: unusedVar.name, - action: "assigned a value", - additional: additionalMessageData - }; - } - - /** - * Generate the warning message about a variable being used even though - * it is marked as being ignored. - * @param {Variable} variable eslint-scope variable object - * @param {VariableType} variableType a simple name for the types of variables that this rule supports - * @returns {UsedIgnoredVarMessageData} The message data to be used with - * this used ignored variable. - */ - function getUsedIgnoredMessageData(variable, variableType) { - const [variableDescription, pattern] = getVariableDescription(variableType); - - let additionalMessageData = ""; - - if (pattern && variableDescription) { - additionalMessageData = `. Used ${variableDescription} must not match ${pattern}`; - } - - return { - varName: variable.name, - additional: additionalMessageData - }; - } - - //-------------------------------------------------------------------------- - // Helpers - //-------------------------------------------------------------------------- - - const STATEMENT_TYPE = /(?:Statement|Declaration)$/u; - - /** - * Determines if a given variable is being exported from a module. - * @param {Variable} variable eslint-scope variable object. - * @returns {boolean} True if the variable is exported, false if not. - * @private - */ - function isExported(variable) { - - const definition = variable.defs[0]; - - if (definition) { - - let node = definition.node; - - if (node.type === "VariableDeclarator") { - node = node.parent; - } else if (definition.type === "Parameter") { - return false; - } - - return node.parent.type.indexOf("Export") === 0; - } - return false; - - } - - /** - * Checks whether a node is a sibling of the rest property or not. - * @param {ASTNode} node a node to check - * @returns {boolean} True if the node is a sibling of the rest property, otherwise false. - */ - function hasRestSibling(node) { - return node.type === "Property" && - node.parent.type === "ObjectPattern" && - REST_PROPERTY_TYPE.test(node.parent.properties.at(-1).type); - } - - /** - * Determines if a variable has a sibling rest property - * @param {Variable} variable eslint-scope variable object. - * @returns {boolean} True if the variable has a sibling rest property, false if not. - * @private - */ - function hasRestSpreadSibling(variable) { - if (config.ignoreRestSiblings) { - const hasRestSiblingDefinition = variable.defs.some(def => hasRestSibling(def.name.parent)); - const hasRestSiblingReference = variable.references.some(ref => hasRestSibling(ref.identifier.parent)); - - return hasRestSiblingDefinition || hasRestSiblingReference; - } - - return false; - } - - /** - * Determines if a reference is a read operation. - * @param {Reference} ref An eslint-scope Reference - * @returns {boolean} whether the given reference represents a read operation - * @private - */ - function isReadRef(ref) { - return ref.isRead(); - } - - /** - * Determine if an identifier is referencing an enclosing function name. - * @param {Reference} ref The reference to check. - * @param {ASTNode[]} nodes The candidate function nodes. - * @returns {boolean} True if it's a self-reference, false if not. - * @private - */ - function isSelfReference(ref, nodes) { - let scope = ref.from; - - while (scope) { - if (nodes.includes(scope.block)) { - return true; - } - - scope = scope.upper; - } - - return false; - } - - /** - * Gets a list of function definitions for a specified variable. - * @param {Variable} variable eslint-scope variable object. - * @returns {ASTNode[]} Function nodes. - * @private - */ - function getFunctionDefinitions(variable) { - const functionDefinitions = []; - - variable.defs.forEach(def => { - const { type, node } = def; - - // FunctionDeclarations - if (type === "FunctionName") { - functionDefinitions.push(node); - } - - // FunctionExpressions - if (type === "Variable" && node.init && - (node.init.type === "FunctionExpression" || node.init.type === "ArrowFunctionExpression")) { - functionDefinitions.push(node.init); - } - }); - return functionDefinitions; - } - - /** - * Checks the position of given nodes. - * @param {ASTNode} inner A node which is expected as inside. - * @param {ASTNode} outer A node which is expected as outside. - * @returns {boolean} `true` if the `inner` node exists in the `outer` node. - * @private - */ - function isInside(inner, outer) { - return ( - inner.range[0] >= outer.range[0] && - inner.range[1] <= outer.range[1] - ); - } - - /** - * Checks whether a given node is unused expression or not. - * @param {ASTNode} node The node itself - * @returns {boolean} The node is an unused expression. - * @private - */ - function isUnusedExpression(node) { - const parent = node.parent; - - if (parent.type === "ExpressionStatement") { - return true; - } - - if (parent.type === "SequenceExpression") { - const isLastExpression = parent.expressions.at(-1) === node; - - if (!isLastExpression) { - return true; - } - return isUnusedExpression(parent); - } - - return false; - } - - /** - * If a given reference is left-hand side of an assignment, this gets - * the right-hand side node of the assignment. - * - * In the following cases, this returns null. - * - * - The reference is not the LHS of an assignment expression. - * - The reference is inside of a loop. - * - The reference is inside of a function scope which is different from - * the declaration. - * @param {eslint-scope.Reference} ref A reference to check. - * @param {ASTNode} prevRhsNode The previous RHS node. - * @returns {ASTNode|null} The RHS node or null. - * @private - */ - function getRhsNode(ref, prevRhsNode) { - const id = ref.identifier; - const parent = id.parent; - const refScope = ref.from.variableScope; - const varScope = ref.resolved.scope.variableScope; - const canBeUsedLater = refScope !== varScope || astUtils.isInLoop(id); - - /* - * Inherits the previous node if this reference is in the node. - * This is for `a = a + a`-like code. - */ - if (prevRhsNode && isInside(id, prevRhsNode)) { - return prevRhsNode; - } - - if (parent.type === "AssignmentExpression" && - isUnusedExpression(parent) && - id === parent.left && - !canBeUsedLater - ) { - return parent.right; - } - return null; - } - - /** - * Checks whether a given function node is stored to somewhere or not. - * If the function node is stored, the function can be used later. - * @param {ASTNode} funcNode A function node to check. - * @param {ASTNode} rhsNode The RHS node of the previous assignment. - * @returns {boolean} `true` if under the following conditions: - * - the funcNode is assigned to a variable. - * - the funcNode is bound as an argument of a function call. - * - the function is bound to a property and the object satisfies above conditions. - * @private - */ - function isStorableFunction(funcNode, rhsNode) { - let node = funcNode; - let parent = funcNode.parent; - - while (parent && isInside(parent, rhsNode)) { - switch (parent.type) { - case "SequenceExpression": - if (parent.expressions.at(-1) !== node) { - return false; - } - break; - - case "CallExpression": - case "NewExpression": - return parent.callee !== node; - - case "AssignmentExpression": - case "TaggedTemplateExpression": - case "YieldExpression": - return true; - - default: - if (STATEMENT_TYPE.test(parent.type)) { - - /* - * If it encountered statements, this is a complex pattern. - * Since analyzing complex patterns is hard, this returns `true` to avoid false positive. - */ - return true; - } - } - - node = parent; - parent = parent.parent; - } - - return false; - } - - /** - * Checks whether a given Identifier node exists inside of a function node which can be used later. - * - * "can be used later" means: - * - the function is assigned to a variable. - * - the function is bound to a property and the object can be used later. - * - the function is bound as an argument of a function call. - * - * If a reference exists in a function which can be used later, the reference is read when the function is called. - * @param {ASTNode} id An Identifier node to check. - * @param {ASTNode} rhsNode The RHS node of the previous assignment. - * @returns {boolean} `true` if the `id` node exists inside of a function node which can be used later. - * @private - */ - function isInsideOfStorableFunction(id, rhsNode) { - const funcNode = astUtils.getUpperFunction(id); - - return ( - funcNode && - isInside(funcNode, rhsNode) && - isStorableFunction(funcNode, rhsNode) - ); - } - - /** - * Checks whether a given reference is a read to update itself or not. - * @param {eslint-scope.Reference} ref A reference to check. - * @param {ASTNode} rhsNode The RHS node of the previous assignment. - * @returns {boolean} The reference is a read to update itself. - * @private - */ - function isReadForItself(ref, rhsNode) { - const id = ref.identifier; - const parent = id.parent; - - return ref.isRead() && ( - - // self update. e.g. `a += 1`, `a++` - ( - ( - parent.type === "AssignmentExpression" && - parent.left === id && - isUnusedExpression(parent) && - !astUtils.isLogicalAssignmentOperator(parent.operator) - ) || - ( - parent.type === "UpdateExpression" && - isUnusedExpression(parent) - ) - ) || - - // in RHS of an assignment for itself. e.g. `a = a + 1` - ( - rhsNode && - isInside(id, rhsNode) && - !isInsideOfStorableFunction(id, rhsNode) - ) - ); - } - - /** - * Determine if an identifier is used either in for-in or for-of loops. - * @param {Reference} ref The reference to check. - * @returns {boolean} whether reference is used in the for-in loops - * @private - */ - function isForInOfRef(ref) { - let target = ref.identifier.parent; - - - // "for (var ...) { return; }" - if (target.type === "VariableDeclarator") { - target = target.parent.parent; - } - - if (target.type !== "ForInStatement" && target.type !== "ForOfStatement") { - return false; - } - - // "for (...) { return; }" - if (target.body.type === "BlockStatement") { - target = target.body.body[0]; - - // "for (...) return;" - } else { - target = target.body; - } - - // For empty loop body - if (!target) { - return false; - } - - return target.type === "ReturnStatement"; - } - - /** - * Determines if the variable is used. - * @param {Variable} variable The variable to check. - * @returns {boolean} True if the variable is used - * @private - */ - function isUsedVariable(variable) { - if (variable.eslintUsed) { - return true; - } - - const functionNodes = getFunctionDefinitions(variable); - const isFunctionDefinition = functionNodes.length > 0; - - let rhsNode = null; - - return variable.references.some(ref => { - if (isForInOfRef(ref)) { - return true; - } - - const forItself = isReadForItself(ref, rhsNode); - - rhsNode = getRhsNode(ref, rhsNode); - - return ( - isReadRef(ref) && - !forItself && - !(isFunctionDefinition && isSelfReference(ref, functionNodes)) - ); - }); - } - - /** - * Checks whether the given variable is after the last used parameter. - * @param {eslint-scope.Variable} variable The variable to check. - * @returns {boolean} `true` if the variable is defined after the last - * used parameter. - */ - function isAfterLastUsedArg(variable) { - const def = variable.defs[0]; - const params = sourceCode.getDeclaredVariables(def.node); - const posteriorParams = params.slice(params.indexOf(variable) + 1); - - // If any used parameters occur after this parameter, do not report. - return !posteriorParams.some(v => v.references.length > 0 || v.eslintUsed); - } - - /** - * Gets an array of variables without read references. - * @param {Scope} scope an eslint-scope Scope object. - * @param {Variable[]} unusedVars an array that saving result. - * @returns {Variable[]} unused variables of the scope and descendant scopes. - * @private - */ - function collectUnusedVariables(scope, unusedVars) { - const variables = scope.variables; - const childScopes = scope.childScopes; - let i, l; - - if (scope.type !== "global" || config.vars === "all") { - for (i = 0, l = variables.length; i < l; ++i) { - const variable = variables[i]; - - // skip a variable of class itself name in the class scope - if (scope.type === "class" && scope.block.id === variable.identifiers[0]) { - continue; - } - - // skip function expression names - if (scope.functionExpressionScope) { - continue; - } - - // skip variables marked with markVariableAsUsed() - if (!config.reportUsedIgnorePattern && variable.eslintUsed) { - continue; - } - - // skip implicit "arguments" variable - if (scope.type === "function" && variable.name === "arguments" && variable.identifiers.length === 0) { - continue; - } - - // explicit global variables don't have definitions. - const def = variable.defs[0]; - - if (def) { - const type = def.type; - const refUsedInArrayPatterns = variable.references.some(ref => ref.identifier.parent.type === "ArrayPattern"); - - // skip elements of array destructuring patterns - if ( - ( - def.name.parent.type === "ArrayPattern" || - refUsedInArrayPatterns - ) && - config.destructuredArrayIgnorePattern && - config.destructuredArrayIgnorePattern.test(def.name.name) - ) { - if (config.reportUsedIgnorePattern && isUsedVariable(variable)) { - context.report({ - node: def.name, - messageId: "usedIgnoredVar", - data: getUsedIgnoredMessageData(variable, "array-destructure") - }); - } - - continue; - } - - if (type === "ClassName") { - const hasStaticBlock = def.node.body.body.some(node => node.type === "StaticBlock"); - - if (config.ignoreClassWithStaticInitBlock && hasStaticBlock) { - continue; - } - } - - // skip catch variables - if (type === "CatchClause") { - if (config.caughtErrors === "none") { - continue; - } - - // skip ignored parameters - if (config.caughtErrorsIgnorePattern && config.caughtErrorsIgnorePattern.test(def.name.name)) { - if (config.reportUsedIgnorePattern && isUsedVariable(variable)) { - context.report({ - node: def.name, - messageId: "usedIgnoredVar", - data: getUsedIgnoredMessageData(variable, "catch-clause") - }); - } - - continue; - } - } else if (type === "Parameter") { - - // skip any setter argument - if ((def.node.parent.type === "Property" || def.node.parent.type === "MethodDefinition") && def.node.parent.kind === "set") { - continue; - } - - // if "args" option is "none", skip any parameter - if (config.args === "none") { - continue; - } - - // skip ignored parameters - if (config.argsIgnorePattern && config.argsIgnorePattern.test(def.name.name)) { - if (config.reportUsedIgnorePattern && isUsedVariable(variable)) { - context.report({ - node: def.name, - messageId: "usedIgnoredVar", - data: getUsedIgnoredMessageData(variable, "parameter") - }); - } - - continue; - } - - // if "args" option is "after-used", skip used variables - if (config.args === "after-used" && astUtils.isFunction(def.name.parent) && !isAfterLastUsedArg(variable)) { - continue; - } - } else { - - // skip ignored variables - if (config.varsIgnorePattern && config.varsIgnorePattern.test(def.name.name)) { - if (config.reportUsedIgnorePattern && isUsedVariable(variable)) { - context.report({ - node: def.name, - messageId: "usedIgnoredVar", - data: getUsedIgnoredMessageData(variable, "variable") - }); - } - - continue; - } - } - } - - if (!isUsedVariable(variable) && !isExported(variable) && !hasRestSpreadSibling(variable)) { - unusedVars.push(variable); - } - } - } - - for (i = 0, l = childScopes.length; i < l; ++i) { - collectUnusedVariables(childScopes[i], unusedVars); - } - - return unusedVars; - } - - //-------------------------------------------------------------------------- - // Public - //-------------------------------------------------------------------------- - - return { - "Program:exit"(programNode) { - const unusedVars = collectUnusedVariables(sourceCode.getScope(programNode), []); - - for (let i = 0, l = unusedVars.length; i < l; ++i) { - const unusedVar = unusedVars[i]; - - // Report the first declaration. - if (unusedVar.defs.length > 0) { - - // report last write reference, https://github.com/eslint/eslint/issues/14324 - const writeReferences = unusedVar.references.filter(ref => ref.isWrite() && ref.from.variableScope === unusedVar.scope.variableScope); - - let referenceToReport; - - if (writeReferences.length > 0) { - referenceToReport = writeReferences.at(-1); - } - - context.report({ - node: referenceToReport ? referenceToReport.identifier : unusedVar.identifiers[0], - messageId: "unusedVar", - data: unusedVar.references.some(ref => ref.isWrite()) - ? getAssignedMessageData(unusedVar) - : getDefinedMessageData(unusedVar) - }); - - // If there are no regular declaration, report the first `/*globals*/` comment directive. - } else if (unusedVar.eslintExplicitGlobalComments) { - const directiveComment = unusedVar.eslintExplicitGlobalComments[0]; - - context.report({ - node: programNode, - loc: astUtils.getNameLocationInGlobalDirectiveComment(sourceCode, directiveComment, unusedVar.name), - messageId: "unusedVar", - data: getDefinedMessageData(unusedVar) - }); - } - } - } - }; - } -}; diff --git a/tools/eslint/node_modules/eslint/lib/rules/no-use-before-define.js b/tools/eslint/node_modules/eslint/lib/rules/no-use-before-define.js deleted file mode 100644 index 9d6b043404a2e4..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/rules/no-use-before-define.js +++ /dev/null @@ -1,348 +0,0 @@ -/** - * @fileoverview Rule to flag use of variables before they are defined - * @author Ilya Volodin - */ - -"use strict"; - -//------------------------------------------------------------------------------ -// Helpers -//------------------------------------------------------------------------------ - -const SENTINEL_TYPE = /^(?:(?:Function|Class)(?:Declaration|Expression)|ArrowFunctionExpression|CatchClause|ImportDeclaration|ExportNamedDeclaration)$/u; -const FOR_IN_OF_TYPE = /^For(?:In|Of)Statement$/u; - -/** - * Parses a given value as options. - * @param {any} options A value to parse. - * @returns {Object} The parsed options. - */ -function parseOptions(options) { - let functions = true; - let classes = true; - let variables = true; - let allowNamedExports = false; - - if (typeof options === "string") { - functions = (options !== "nofunc"); - } else if (typeof options === "object" && options !== null) { - functions = options.functions !== false; - classes = options.classes !== false; - variables = options.variables !== false; - allowNamedExports = !!options.allowNamedExports; - } - - return { functions, classes, variables, allowNamedExports }; -} - -/** - * Checks whether or not a given location is inside of the range of a given node. - * @param {ASTNode} node An node to check. - * @param {number} location A location to check. - * @returns {boolean} `true` if the location is inside of the range of the node. - */ -function isInRange(node, location) { - return node && node.range[0] <= location && location <= node.range[1]; -} - -/** - * Checks whether or not a given location is inside of the range of a class static initializer. - * Static initializers are static blocks and initializers of static fields. - * @param {ASTNode} node `ClassBody` node to check static initializers. - * @param {number} location A location to check. - * @returns {boolean} `true` if the location is inside of a class static initializer. - */ -function isInClassStaticInitializerRange(node, location) { - return node.body.some(classMember => ( - ( - classMember.type === "StaticBlock" && - isInRange(classMember, location) - ) || - ( - classMember.type === "PropertyDefinition" && - classMember.static && - classMember.value && - isInRange(classMember.value, location) - ) - )); -} - -/** - * Checks whether a given scope is the scope of a class static initializer. - * Static initializers are static blocks and initializers of static fields. - * @param {eslint-scope.Scope} scope A scope to check. - * @returns {boolean} `true` if the scope is a class static initializer scope. - */ -function isClassStaticInitializerScope(scope) { - if (scope.type === "class-static-block") { - return true; - } - - if (scope.type === "class-field-initializer") { - - // `scope.block` is PropertyDefinition#value node - const propertyDefinition = scope.block.parent; - - return propertyDefinition.static; - } - - return false; -} - -/** - * Checks whether a given reference is evaluated in an execution context - * that isn't the one where the variable it refers to is defined. - * Execution contexts are: - * - top-level - * - functions - * - class field initializers (implicit functions) - * - class static blocks (implicit functions) - * Static class field initializers and class static blocks are automatically run during the class definition evaluation, - * and therefore we'll consider them as a part of the parent execution context. - * Example: - * - * const x = 1; - * - * x; // returns `false` - * () => x; // returns `true` - * - * class C { - * field = x; // returns `true` - * static field = x; // returns `false` - * - * method() { - * x; // returns `true` - * } - * - * static method() { - * x; // returns `true` - * } - * - * static { - * x; // returns `false` - * } - * } - * @param {eslint-scope.Reference} reference A reference to check. - * @returns {boolean} `true` if the reference is from a separate execution context. - */ -function isFromSeparateExecutionContext(reference) { - const variable = reference.resolved; - let scope = reference.from; - - // Scope#variableScope represents execution context - while (variable.scope.variableScope !== scope.variableScope) { - if (isClassStaticInitializerScope(scope.variableScope)) { - scope = scope.variableScope.upper; - } else { - return true; - } - } - - return false; -} - -/** - * Checks whether or not a given reference is evaluated during the initialization of its variable. - * - * This returns `true` in the following cases: - * - * var a = a - * var [a = a] = list - * var {a = a} = obj - * for (var a in a) {} - * for (var a of a) {} - * var C = class { [C]; }; - * var C = class { static foo = C; }; - * var C = class { static { foo = C; } }; - * class C extends C {} - * class C extends (class { static foo = C; }) {} - * class C { [C]; } - * @param {Reference} reference A reference to check. - * @returns {boolean} `true` if the reference is evaluated during the initialization. - */ -function isEvaluatedDuringInitialization(reference) { - if (isFromSeparateExecutionContext(reference)) { - - /* - * Even if the reference appears in the initializer, it isn't evaluated during the initialization. - * For example, `const x = () => x;` is valid. - */ - return false; - } - - const location = reference.identifier.range[1]; - const definition = reference.resolved.defs[0]; - - if (definition.type === "ClassName") { - - // `ClassDeclaration` or `ClassExpression` - const classDefinition = definition.node; - - return ( - isInRange(classDefinition, location) && - - /* - * Class binding is initialized before running static initializers. - * For example, `class C { static foo = C; static { bar = C; } }` is valid. - */ - !isInClassStaticInitializerRange(classDefinition.body, location) - ); - } - - let node = definition.name.parent; - - while (node) { - if (node.type === "VariableDeclarator") { - if (isInRange(node.init, location)) { - return true; - } - if (FOR_IN_OF_TYPE.test(node.parent.parent.type) && - isInRange(node.parent.parent.right, location) - ) { - return true; - } - break; - } else if (node.type === "AssignmentPattern") { - if (isInRange(node.right, location)) { - return true; - } - } else if (SENTINEL_TYPE.test(node.type)) { - break; - } - - node = node.parent; - } - - return false; -} - -//------------------------------------------------------------------------------ -// Rule Definition -//------------------------------------------------------------------------------ - -/** @type {import('../shared/types').Rule} */ -module.exports = { - meta: { - type: "problem", - - docs: { - description: "Disallow the use of variables before they are defined", - recommended: false, - url: "https://eslint.org/docs/latest/rules/no-use-before-define" - }, - - schema: [ - { - oneOf: [ - { - enum: ["nofunc"] - }, - { - type: "object", - properties: { - functions: { type: "boolean" }, - classes: { type: "boolean" }, - variables: { type: "boolean" }, - allowNamedExports: { type: "boolean" } - }, - additionalProperties: false - } - ] - } - ], - - messages: { - usedBeforeDefined: "'{{name}}' was used before it was defined." - } - }, - - create(context) { - const options = parseOptions(context.options[0]); - const sourceCode = context.sourceCode; - - /** - * Determines whether a given reference should be checked. - * - * Returns `false` if the reference is: - * - initialization's (e.g., `let a = 1`). - * - referring to an undefined variable (i.e., if it's an unresolved reference). - * - referring to a variable that is defined, but not in the given source code - * (e.g., global environment variable or `arguments` in functions). - * - allowed by options. - * @param {eslint-scope.Reference} reference The reference - * @returns {boolean} `true` if the reference should be checked - */ - function shouldCheck(reference) { - if (reference.init) { - return false; - } - - const { identifier } = reference; - - if ( - options.allowNamedExports && - identifier.parent.type === "ExportSpecifier" && - identifier.parent.local === identifier - ) { - return false; - } - - const variable = reference.resolved; - - if (!variable || variable.defs.length === 0) { - return false; - } - - const definitionType = variable.defs[0].type; - - if (!options.functions && definitionType === "FunctionName") { - return false; - } - - if ( - ( - !options.variables && definitionType === "Variable" || - !options.classes && definitionType === "ClassName" - ) && - - // don't skip checking the reference if it's in the same execution context, because of TDZ - isFromSeparateExecutionContext(reference) - ) { - return false; - } - - return true; - } - - /** - * Finds and validates all references in a given scope and its child scopes. - * @param {eslint-scope.Scope} scope The scope object. - * @returns {void} - */ - function checkReferencesInScope(scope) { - scope.references.filter(shouldCheck).forEach(reference => { - const variable = reference.resolved; - const definitionIdentifier = variable.defs[0].name; - - if ( - reference.identifier.range[1] < definitionIdentifier.range[1] || - isEvaluatedDuringInitialization(reference) - ) { - context.report({ - node: reference.identifier, - messageId: "usedBeforeDefined", - data: reference.identifier - }); - } - }); - - scope.childScopes.forEach(checkReferencesInScope); - } - - return { - Program(node) { - checkReferencesInScope(sourceCode.getScope(node)); - } - }; - } -}; diff --git a/tools/eslint/node_modules/eslint/lib/rules/no-useless-assignment.js b/tools/eslint/node_modules/eslint/lib/rules/no-useless-assignment.js deleted file mode 100644 index cac8ba1fcd1d6c..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/rules/no-useless-assignment.js +++ /dev/null @@ -1,566 +0,0 @@ -/** - * @fileoverview A rule to disallow unnecessary assignments`. - * @author Yosuke Ota - */ - -"use strict"; - -const { findVariable } = require("@eslint-community/eslint-utils"); - -//------------------------------------------------------------------------------ -// Types -//------------------------------------------------------------------------------ - -/** @typedef {import("estree").Node} ASTNode */ -/** @typedef {import("estree").Pattern} Pattern */ -/** @typedef {import("estree").Identifier} Identifier */ -/** @typedef {import("estree").VariableDeclarator} VariableDeclarator */ -/** @typedef {import("estree").AssignmentExpression} AssignmentExpression */ -/** @typedef {import("estree").UpdateExpression} UpdateExpression */ -/** @typedef {import("estree").Expression} Expression */ -/** @typedef {import("eslint-scope").Scope} Scope */ -/** @typedef {import("eslint-scope").Variable} Variable */ -/** @typedef {import("../linter/code-path-analysis/code-path")} CodePath */ -/** @typedef {import("../linter/code-path-analysis/code-path-segment")} CodePathSegment */ - -//------------------------------------------------------------------------------ -// Helpers -//------------------------------------------------------------------------------ - -/** - * Extract identifier from the given pattern node used on the left-hand side of the assignment. - * @param {Pattern} pattern The pattern node to extract identifier - * @returns {Iterable} The extracted identifier - */ -function *extractIdentifiersFromPattern(pattern) { - switch (pattern.type) { - case "Identifier": - yield pattern; - return; - case "ObjectPattern": - for (const property of pattern.properties) { - yield* extractIdentifiersFromPattern(property.type === "Property" ? property.value : property); - } - return; - case "ArrayPattern": - for (const element of pattern.elements) { - if (!element) { - continue; - } - yield* extractIdentifiersFromPattern(element); - } - return; - case "RestElement": - yield* extractIdentifiersFromPattern(pattern.argument); - return; - case "AssignmentPattern": - yield* extractIdentifiersFromPattern(pattern.left); - - // no default - } -} - - -/** - * Checks whether the given identifier node is evaluated after the assignment identifier. - * @param {AssignmentInfo} assignment The assignment info. - * @param {Identifier} identifier The identifier to check. - * @returns {boolean} `true` if the given identifier node is evaluated after the assignment identifier. - */ -function isIdentifierEvaluatedAfterAssignment(assignment, identifier) { - if (identifier.range[0] < assignment.identifier.range[1]) { - return false; - } - if ( - assignment.expression && - assignment.expression.range[0] <= identifier.range[0] && - identifier.range[1] <= assignment.expression.range[1] - ) { - - /* - * The identifier node is in an expression that is evaluated before the assignment. - * e.g. x = id; - * ^^ identifier to check - * ^ assignment identifier - */ - return false; - } - - /* - * e.g. - * x = 42; id; - * ^^ identifier to check - * ^ assignment identifier - * let { x, y = id } = obj; - * ^^ identifier to check - * ^ assignment identifier - */ - return true; -} - -/** - * Checks whether the given identifier node is used between the assigned identifier and the equal sign. - * - * e.g. let { x, y = x } = obj; - * ^ identifier to check - * ^ assigned identifier - * @param {AssignmentInfo} assignment The assignment info. - * @param {Identifier} identifier The identifier to check. - * @returns {boolean} `true` if the given identifier node is used between the assigned identifier and the equal sign. - */ -function isIdentifierUsedBetweenAssignedAndEqualSign(assignment, identifier) { - if (!assignment.expression) { - return false; - } - return ( - assignment.identifier.range[1] <= identifier.range[0] && - identifier.range[1] <= assignment.expression.range[0] - ); -} - -//------------------------------------------------------------------------------ -// Rule Definition -//------------------------------------------------------------------------------ - -/** @type {import('../shared/types').Rule} */ -module.exports = { - meta: { - type: "problem", - - docs: { - description: "Disallow variable assignments when the value is not used", - recommended: false, - url: "https://eslint.org/docs/latest/rules/no-useless-assignment" - }, - - schema: [], - - messages: { - unnecessaryAssignment: "This assigned value is not used in subsequent statements." - } - }, - - create(context) { - const sourceCode = context.sourceCode; - - /** - * @typedef {Object} ScopeStack - * @property {CodePath} codePath The code path of this scope stack. - * @property {Scope} scope The scope of this scope stack. - * @property {ScopeStack} upper The upper scope stack. - * @property {Record} segments The map of ScopeStackSegmentInfo. - * @property {Set} currentSegments The current CodePathSegments. - * @property {Map} assignments The map of list of AssignmentInfo for each variable. - */ - /** - * @typedef {Object} ScopeStackSegmentInfo - * @property {CodePathSegment} segment The code path segment. - * @property {Identifier|null} first The first identifier that appears within the segment. - * @property {Identifier|null} last The last identifier that appears within the segment. - * `first` and `last` are used to determine whether an identifier exists within the segment position range. - * Since it is used as a range of segments, we should originally hold all nodes, not just identifiers, - * but since the only nodes to be judged are identifiers, it is sufficient to have a range of identifiers. - */ - /** - * @typedef {Object} AssignmentInfo - * @property {Variable} variable The variable that is assigned. - * @property {Identifier} identifier The identifier that is assigned. - * @property {VariableDeclarator|AssignmentExpression|UpdateExpression} node The node where the variable was updated. - * @property {Expression|null} expression The expression that is evaluated before the assignment. - * @property {CodePathSegment[]} segments The code path segments where the assignment was made. - */ - - /** @type {ScopeStack} */ - let scopeStack = null; - - /** @type {Set} */ - const codePathStartScopes = new Set(); - - /** - * Gets the scope of code path start from given scope - * @param {Scope} scope The initial scope - * @returns {Scope} The scope of code path start - * @throws {Error} Unexpected error - */ - function getCodePathStartScope(scope) { - let target = scope; - - while (target) { - if (codePathStartScopes.has(target)) { - return target; - } - target = target.upper; - } - - // Should be unreachable - return null; - } - - /** - * Verify the given scope stack. - * @param {ScopeStack} target The scope stack to verify. - * @returns {void} - */ - function verify(target) { - - /** - * Checks whether the given identifier is used in the segment. - * @param {CodePathSegment} segment The code path segment. - * @param {Identifier} identifier The identifier to check. - * @returns {boolean} `true` if the identifier is used in the segment. - */ - function isIdentifierUsedInSegment(segment, identifier) { - const segmentInfo = target.segments[segment.id]; - - return ( - segmentInfo.first && - segmentInfo.last && - segmentInfo.first.range[0] <= identifier.range[0] && - identifier.range[1] <= segmentInfo.last.range[1] - ); - } - - /** - * Verifies whether the given assignment info is an used assignment. - * Report if it is an unused assignment. - * @param {AssignmentInfo} targetAssignment The assignment info to verify. - * @param {AssignmentInfo[]} allAssignments The list of all assignment info for variables. - * @returns {void} - */ - function verifyAssignmentIsUsed(targetAssignment, allAssignments) { - - /** - * @typedef {Object} SubsequentSegmentData - * @property {CodePathSegment} segment The code path segment - * @property {AssignmentInfo} [assignment] The first occurrence of the assignment within the segment. - * There is no need to check if the variable is used after this assignment, - * as the value it was assigned will be used. - */ - - /** - * Information used in `getSubsequentSegments()`. - * To avoid unnecessary iterations, cache information that has already been iterated over, - * and if additional iterations are needed, start iterating from the retained position. - */ - const subsequentSegmentData = { - - /** - * Cache of subsequent segment information list that have already been iterated. - * @type {SubsequentSegmentData[]} - */ - results: [], - - /** - * Subsequent segments that have already been iterated on. Used to avoid infinite loops. - * @type {Set} - */ - subsequentSegments: new Set(), - - /** - * Unexplored code path segment. - * If additional iterations are needed, consume this information and iterate. - * @type {CodePathSegment[]} - */ - queueSegments: targetAssignment.segments.flatMap(segment => segment.nextSegments) - }; - - - /** - * Gets the subsequent segments from the segment of - * the assignment currently being validated (targetAssignment). - * @returns {Iterable} the subsequent segments - */ - function *getSubsequentSegments() { - yield* subsequentSegmentData.results; - - while (subsequentSegmentData.queueSegments.length > 0) { - const nextSegment = subsequentSegmentData.queueSegments.shift(); - - if (subsequentSegmentData.subsequentSegments.has(nextSegment)) { - continue; - } - subsequentSegmentData.subsequentSegments.add(nextSegment); - - const assignmentInSegment = allAssignments - .find(otherAssignment => ( - otherAssignment.segments.includes(nextSegment) && - !isIdentifierUsedBetweenAssignedAndEqualSign(otherAssignment, targetAssignment.identifier) - )); - - if (!assignmentInSegment) { - - /* - * Stores the next segment to explore. - * If `assignmentInSegment` exists, - * we are guarding it because we don't need to explore the next segment. - */ - subsequentSegmentData.queueSegments.push(...nextSegment.nextSegments); - } - - /** @type {SubsequentSegmentData} */ - const result = { - segment: nextSegment, - assignment: assignmentInSegment - }; - - subsequentSegmentData.results.push(result); - yield result; - } - } - - - const readReferences = targetAssignment.variable.references.filter(reference => reference.isRead()); - - if (!readReferences.length) { - - /* - * It is not just an unnecessary assignment, but an unnecessary (unused) variable - * and thus should not be reported by this rule because it is reported by `no-unused-vars`. - */ - return; - } - - /** - * Other assignment on the current segment and after current assignment. - */ - const otherAssignmentAfterTargetAssignment = allAssignments - .find(assignment => { - if ( - assignment === targetAssignment || - assignment.segments.length && assignment.segments.every(segment => !targetAssignment.segments.includes(segment)) - ) { - return false; - } - if (isIdentifierEvaluatedAfterAssignment(targetAssignment, assignment.identifier)) { - return true; - } - if ( - assignment.expression && - assignment.expression.range[0] <= targetAssignment.identifier.range[0] && - targetAssignment.identifier.range[1] <= assignment.expression.range[1] - ) { - - /* - * The target assignment is in an expression that is evaluated before the assignment. - * e.g. x=(x=1); - * ^^^ targetAssignment - * ^^^^^^^ assignment - */ - return true; - } - - return false; - }); - - for (const reference of readReferences) { - - /* - * If the scope of the reference is outside the current code path scope, - * we cannot track whether this assignment is not used. - * For example, it can also be called asynchronously. - */ - if (target.scope !== getCodePathStartScope(reference.from)) { - return; - } - - // Checks if it is used in the same segment as the target assignment. - if ( - isIdentifierEvaluatedAfterAssignment(targetAssignment, reference.identifier) && - ( - isIdentifierUsedBetweenAssignedAndEqualSign(targetAssignment, reference.identifier) || - targetAssignment.segments.some(segment => isIdentifierUsedInSegment(segment, reference.identifier)) - ) - ) { - - if ( - otherAssignmentAfterTargetAssignment && - isIdentifierEvaluatedAfterAssignment(otherAssignmentAfterTargetAssignment, reference.identifier) - ) { - - // There was another assignment before the reference. Therefore, it has not been used yet. - continue; - } - - // Uses in statements after the written identifier. - return; - } - - if (otherAssignmentAfterTargetAssignment) { - - /* - * The assignment was followed by another assignment in the same segment. - * Therefore, there is no need to check the next segment. - */ - continue; - } - - // Check subsequent segments. - for (const subsequentSegment of getSubsequentSegments()) { - if (isIdentifierUsedInSegment(subsequentSegment.segment, reference.identifier)) { - if ( - subsequentSegment.assignment && - isIdentifierEvaluatedAfterAssignment(subsequentSegment.assignment, reference.identifier) - ) { - - // There was another assignment before the reference. Therefore, it has not been used yet. - continue; - } - - // It is used - return; - } - } - } - context.report({ - node: targetAssignment.identifier, - messageId: "unnecessaryAssignment" - }); - } - - // Verify that each assignment in the code path is used. - for (const assignments of target.assignments.values()) { - assignments.sort((a, b) => a.identifier.range[0] - b.identifier.range[0]); - for (const assignment of assignments) { - verifyAssignmentIsUsed(assignment, assignments); - } - } - } - - return { - onCodePathStart(codePath, node) { - const scope = sourceCode.getScope(node); - - scopeStack = { - upper: scopeStack, - codePath, - scope, - segments: Object.create(null), - currentSegments: new Set(), - assignments: new Map() - }; - codePathStartScopes.add(scopeStack.scope); - }, - onCodePathEnd() { - verify(scopeStack); - - scopeStack = scopeStack.upper; - }, - onCodePathSegmentStart(segment) { - const segmentInfo = { segment, first: null, last: null }; - - scopeStack.segments[segment.id] = segmentInfo; - scopeStack.currentSegments.add(segment); - }, - onCodePathSegmentEnd(segment) { - scopeStack.currentSegments.delete(segment); - }, - Identifier(node) { - for (const segment of scopeStack.currentSegments) { - const segmentInfo = scopeStack.segments[segment.id]; - - if (!segmentInfo.first) { - segmentInfo.first = node; - } - segmentInfo.last = node; - } - }, - ":matches(VariableDeclarator[init!=null], AssignmentExpression, UpdateExpression):exit"(node) { - if (scopeStack.currentSegments.size === 0) { - - // Ignore unreachable segments - return; - } - - const assignments = scopeStack.assignments; - - let pattern; - let expression = null; - - if (node.type === "VariableDeclarator") { - pattern = node.id; - expression = node.init; - } else if (node.type === "AssignmentExpression") { - pattern = node.left; - expression = node.right; - } else { // UpdateExpression - pattern = node.argument; - } - - for (const identifier of extractIdentifiersFromPattern(pattern)) { - const scope = sourceCode.getScope(identifier); - - /** @type {Variable} */ - const variable = findVariable(scope, identifier); - - if (!variable) { - continue; - } - - // We don't know where global variables are used. - if (variable.scope.type === "global" && variable.defs.length === 0) { - continue; - } - - /* - * If the scope of the variable is outside the current code path scope, - * we cannot track whether this assignment is not used. - */ - if (scopeStack.scope !== getCodePathStartScope(variable.scope)) { - continue; - } - - // Variables marked by `markVariableAsUsed()` or - // exported by "exported" block comment. - if (variable.eslintUsed) { - continue; - } - - // Variables exported by ESM export syntax - if (variable.scope.type === "module") { - if ( - variable.defs - .some(def => ( - (def.type === "Variable" && def.parent.parent.type === "ExportNamedDeclaration") || - ( - def.type === "FunctionName" && - ( - def.node.parent.type === "ExportNamedDeclaration" || - def.node.parent.type === "ExportDefaultDeclaration" - ) - ) || - ( - def.type === "ClassName" && - ( - def.node.parent.type === "ExportNamedDeclaration" || - def.node.parent.type === "ExportDefaultDeclaration" - ) - ) - )) - ) { - continue; - } - if (variable.references.some(reference => reference.identifier.parent.type === "ExportSpecifier")) { - - // It have `export { ... }` reference. - continue; - } - } - - let list = assignments.get(variable); - - if (!list) { - list = []; - assignments.set(variable, list); - } - list.push({ - variable, - identifier, - node, - expression, - segments: [...scopeStack.currentSegments] - }); - } - } - }; - } -}; diff --git a/tools/eslint/node_modules/eslint/lib/rules/no-useless-backreference.js b/tools/eslint/node_modules/eslint/lib/rules/no-useless-backreference.js deleted file mode 100644 index d41a89883a5cf6..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/rules/no-useless-backreference.js +++ /dev/null @@ -1,244 +0,0 @@ -/** - * @fileoverview Rule to disallow useless backreferences in regular expressions - * @author Milos Djermanovic - */ - -"use strict"; - -//------------------------------------------------------------------------------ -// Requirements -//------------------------------------------------------------------------------ - -const { CALL, CONSTRUCT, ReferenceTracker, getStringIfConstant } = require("@eslint-community/eslint-utils"); -const { RegExpParser, visitRegExpAST } = require("@eslint-community/regexpp"); - -//------------------------------------------------------------------------------ -// Helpers -//------------------------------------------------------------------------------ - -const parser = new RegExpParser(); - -/** - * Finds the path from the given `regexpp` AST node to the root node. - * @param {regexpp.Node} node Node. - * @returns {regexpp.Node[]} Array that starts with the given node and ends with the root node. - */ -function getPathToRoot(node) { - const path = []; - let current = node; - - do { - path.push(current); - current = current.parent; - } while (current); - - return path; -} - -/** - * Determines whether the given `regexpp` AST node is a lookaround node. - * @param {regexpp.Node} node Node. - * @returns {boolean} `true` if it is a lookaround node. - */ -function isLookaround(node) { - return node.type === "Assertion" && - (node.kind === "lookahead" || node.kind === "lookbehind"); -} - -/** - * Determines whether the given `regexpp` AST node is a negative lookaround node. - * @param {regexpp.Node} node Node. - * @returns {boolean} `true` if it is a negative lookaround node. - */ -function isNegativeLookaround(node) { - return isLookaround(node) && node.negate; -} - -//------------------------------------------------------------------------------ -// Rule Definition -//------------------------------------------------------------------------------ - -/** @type {import('../shared/types').Rule} */ -module.exports = { - meta: { - type: "problem", - - docs: { - description: "Disallow useless backreferences in regular expressions", - recommended: true, - url: "https://eslint.org/docs/latest/rules/no-useless-backreference" - }, - - schema: [], - - messages: { - nested: "Backreference '{{ bref }}' will be ignored. It references group '{{ group }}'{{ otherGroups }} from within that group.", - forward: "Backreference '{{ bref }}' will be ignored. It references group '{{ group }}'{{ otherGroups }} which appears later in the pattern.", - backward: "Backreference '{{ bref }}' will be ignored. It references group '{{ group }}'{{ otherGroups }} which appears before in the same lookbehind.", - disjunctive: "Backreference '{{ bref }}' will be ignored. It references group '{{ group }}'{{ otherGroups }} which is in another alternative.", - intoNegativeLookaround: "Backreference '{{ bref }}' will be ignored. It references group '{{ group }}'{{ otherGroups }} which is in a negative lookaround." - } - }, - - create(context) { - - const sourceCode = context.sourceCode; - - /** - * Checks and reports useless backreferences in the given regular expression. - * @param {ASTNode} node Node that represents regular expression. A regex literal or RegExp constructor call. - * @param {string} pattern Regular expression pattern. - * @param {string} flags Regular expression flags. - * @returns {void} - */ - function checkRegex(node, pattern, flags) { - let regExpAST; - - try { - regExpAST = parser.parsePattern(pattern, 0, pattern.length, { unicode: flags.includes("u"), unicodeSets: flags.includes("v") }); - } catch { - - // Ignore regular expressions with syntax errors - return; - } - - visitRegExpAST(regExpAST, { - onBackreferenceEnter(bref) { - const groups = [bref.resolved].flat(), - brefPath = getPathToRoot(bref); - - const problems = groups.map(group => { - const groupPath = getPathToRoot(group); - - if (brefPath.includes(group)) { - - // group is bref's ancestor => bref is nested ('nested reference') => group hasn't matched yet when bref starts to match. - return { - messageId: "nested", - group - }; - } - - - // Start from the root to find the lowest common ancestor. - let i = brefPath.length - 1, - j = groupPath.length - 1; - - do { - i--; - j--; - } while (brefPath[i] === groupPath[j]); - - const indexOfLowestCommonAncestor = j + 1, - groupCut = groupPath.slice(0, indexOfLowestCommonAncestor), - commonPath = groupPath.slice(indexOfLowestCommonAncestor), - lowestCommonLookaround = commonPath.find(isLookaround), - isMatchingBackward = lowestCommonLookaround && lowestCommonLookaround.kind === "lookbehind"; - - if (groupCut.at(-1).type === "Alternative") { - - // group's and bref's ancestor nodes below the lowest common ancestor are sibling alternatives => they're disjunctive. - return { - messageId: "disjunctive", - group - }; - } - if (!isMatchingBackward && bref.end <= group.start) { - - // bref is left, group is right ('forward reference') => group hasn't matched yet when bref starts to match. - return { - messageId: "forward", - group - }; - } - if (isMatchingBackward && group.end <= bref.start) { - - // the opposite of the previous when the regex is matching backward in a lookbehind context. - return { - messageId: "backward", - group - }; - } - if (groupCut.some(isNegativeLookaround)) { - - // group is in a negative lookaround which isn't bref's ancestor => group has already failed when bref starts to match. - return { - messageId: "intoNegativeLookaround", - group - }; - } - - return null; - }); - - if (problems.length === 0 || problems.some(problem => !problem)) { - - // If there are no problems or no problems with any group then do not report it. - return; - } - - let problemsToReport; - - // Gets problems that appear in the same disjunction. - const problemsInSameDisjunction = problems.filter(problem => problem.messageId !== "disjunctive"); - - if (problemsInSameDisjunction.length) { - - // Only report problems that appear in the same disjunction. - problemsToReport = problemsInSameDisjunction; - } else { - - // If all groups appear in different disjunctions, report it. - problemsToReport = problems; - } - - const [{ messageId, group }, ...other] = problemsToReport; - let otherGroups = ""; - - if (other.length === 1) { - otherGroups = " and another group"; - } else if (other.length > 1) { - otherGroups = ` and other ${other.length} groups`; - } - context.report({ - node, - messageId, - data: { - bref: bref.raw, - group: group.raw, - otherGroups - } - }); - } - }); - } - - return { - "Literal[regex]"(node) { - const { pattern, flags } = node.regex; - - checkRegex(node, pattern, flags); - }, - Program(node) { - const scope = sourceCode.getScope(node), - tracker = new ReferenceTracker(scope), - traceMap = { - RegExp: { - [CALL]: true, - [CONSTRUCT]: true - } - }; - - for (const { node: refNode } of tracker.iterateGlobalReferences(traceMap)) { - const [patternNode, flagsNode] = refNode.arguments, - pattern = getStringIfConstant(patternNode, scope), - flags = getStringIfConstant(flagsNode, scope); - - if (typeof pattern === "string") { - checkRegex(refNode, pattern, flags || ""); - } - } - } - }; - } -}; diff --git a/tools/eslint/node_modules/eslint/lib/rules/no-useless-call.js b/tools/eslint/node_modules/eslint/lib/rules/no-useless-call.js deleted file mode 100644 index dea2b47a4a4228..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/rules/no-useless-call.js +++ /dev/null @@ -1,90 +0,0 @@ -/** - * @fileoverview A rule to disallow unnecessary `.call()` and `.apply()`. - * @author Toru Nagashima - */ - -"use strict"; - -const astUtils = require("./utils/ast-utils"); - -//------------------------------------------------------------------------------ -// Helpers -//------------------------------------------------------------------------------ - -/** - * Checks whether or not a node is a `.call()`/`.apply()`. - * @param {ASTNode} node A CallExpression node to check. - * @returns {boolean} Whether or not the node is a `.call()`/`.apply()`. - */ -function isCallOrNonVariadicApply(node) { - const callee = astUtils.skipChainExpression(node.callee); - - return ( - callee.type === "MemberExpression" && - callee.property.type === "Identifier" && - callee.computed === false && - ( - (callee.property.name === "call" && node.arguments.length >= 1) || - (callee.property.name === "apply" && node.arguments.length === 2 && node.arguments[1].type === "ArrayExpression") - ) - ); -} - - -/** - * Checks whether or not `thisArg` is not changed by `.call()`/`.apply()`. - * @param {ASTNode|null} expectedThis The node that is the owner of the applied function. - * @param {ASTNode} thisArg The node that is given to the first argument of the `.call()`/`.apply()`. - * @param {SourceCode} sourceCode The ESLint source code object. - * @returns {boolean} Whether or not `thisArg` is not changed by `.call()`/`.apply()`. - */ -function isValidThisArg(expectedThis, thisArg, sourceCode) { - if (!expectedThis) { - return astUtils.isNullOrUndefined(thisArg); - } - return astUtils.equalTokens(expectedThis, thisArg, sourceCode); -} - -//------------------------------------------------------------------------------ -// Rule Definition -//------------------------------------------------------------------------------ - -/** @type {import('../shared/types').Rule} */ -module.exports = { - meta: { - type: "suggestion", - - docs: { - description: "Disallow unnecessary calls to `.call()` and `.apply()`", - recommended: false, - url: "https://eslint.org/docs/latest/rules/no-useless-call" - }, - - schema: [], - - messages: { - unnecessaryCall: "Unnecessary '.{{name}}()'." - } - }, - - create(context) { - const sourceCode = context.sourceCode; - - return { - CallExpression(node) { - if (!isCallOrNonVariadicApply(node)) { - return; - } - - const callee = astUtils.skipChainExpression(node.callee); - const applied = astUtils.skipChainExpression(callee.object); - const expectedThis = (applied.type === "MemberExpression") ? applied.object : null; - const thisArg = node.arguments[0]; - - if (isValidThisArg(expectedThis, thisArg, sourceCode)) { - context.report({ node, messageId: "unnecessaryCall", data: { name: callee.property.name } }); - } - } - }; - } -}; diff --git a/tools/eslint/node_modules/eslint/lib/rules/no-useless-catch.js b/tools/eslint/node_modules/eslint/lib/rules/no-useless-catch.js deleted file mode 100644 index e02013db627b94..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/rules/no-useless-catch.js +++ /dev/null @@ -1,57 +0,0 @@ -/** - * @fileoverview Reports useless `catch` clauses that just rethrow their error. - * @author Teddy Katz - */ - -"use strict"; - -//------------------------------------------------------------------------------ -// Rule Definition -//------------------------------------------------------------------------------ - -/** @type {import('../shared/types').Rule} */ -module.exports = { - meta: { - type: "suggestion", - - docs: { - description: "Disallow unnecessary `catch` clauses", - recommended: true, - url: "https://eslint.org/docs/latest/rules/no-useless-catch" - }, - - schema: [], - - messages: { - unnecessaryCatchClause: "Unnecessary catch clause.", - unnecessaryCatch: "Unnecessary try/catch wrapper." - } - }, - - create(context) { - return { - CatchClause(node) { - if ( - node.param && - node.param.type === "Identifier" && - node.body.body.length && - node.body.body[0].type === "ThrowStatement" && - node.body.body[0].argument.type === "Identifier" && - node.body.body[0].argument.name === node.param.name - ) { - if (node.parent.finalizer) { - context.report({ - node, - messageId: "unnecessaryCatchClause" - }); - } else { - context.report({ - node: node.parent, - messageId: "unnecessaryCatch" - }); - } - } - } - }; - } -}; diff --git a/tools/eslint/node_modules/eslint/lib/rules/no-useless-computed-key.js b/tools/eslint/node_modules/eslint/lib/rules/no-useless-computed-key.js deleted file mode 100644 index 5cc652bea265e8..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/rules/no-useless-computed-key.js +++ /dev/null @@ -1,168 +0,0 @@ -/** - * @fileoverview Rule to disallow unnecessary computed property keys in object literals - * @author Burak Yigit Kaya - */ -"use strict"; - -//------------------------------------------------------------------------------ -// Requirements -//------------------------------------------------------------------------------ - -const astUtils = require("./utils/ast-utils"); - -//------------------------------------------------------------------------------ -// Helpers -//------------------------------------------------------------------------------ - -/** - * Determines whether the computed key syntax is unnecessarily used for the given node. - * In particular, it determines whether removing the square brackets and using the content between them - * directly as the key (e.g. ['foo'] -> 'foo') would produce valid syntax and preserve the same behavior. - * Valid non-computed keys are only: identifiers, number literals and string literals. - * Only literals can preserve the same behavior, with a few exceptions for specific node types: - * Property - * - { ["__proto__"]: foo } defines a property named "__proto__" - * { "__proto__": foo } defines object's prototype - * PropertyDefinition - * - class C { ["constructor"]; } defines an instance field named "constructor" - * class C { "constructor"; } produces a parsing error - * - class C { static ["constructor"]; } defines a static field named "constructor" - * class C { static "constructor"; } produces a parsing error - * - class C { static ["prototype"]; } produces a runtime error (doesn't break the whole script) - * class C { static "prototype"; } produces a parsing error (breaks the whole script) - * MethodDefinition - * - class C { ["constructor"]() {} } defines a prototype method named "constructor" - * class C { "constructor"() {} } defines the constructor - * - class C { static ["prototype"]() {} } produces a runtime error (doesn't break the whole script) - * class C { static "prototype"() {} } produces a parsing error (breaks the whole script) - * @param {ASTNode} node The node to check. It can be `Property`, `PropertyDefinition` or `MethodDefinition`. - * @throws {Error} (Unreachable.) - * @returns {void} `true` if the node has useless computed key. - */ -function hasUselessComputedKey(node) { - if (!node.computed) { - return false; - } - - const { key } = node; - - if (key.type !== "Literal") { - return false; - } - - const { value } = key; - - if (typeof value !== "number" && typeof value !== "string") { - return false; - } - - switch (node.type) { - case "Property": - return value !== "__proto__"; - - case "PropertyDefinition": - if (node.static) { - return value !== "constructor" && value !== "prototype"; - } - - return value !== "constructor"; - - case "MethodDefinition": - if (node.static) { - return value !== "prototype"; - } - - return value !== "constructor"; - - /* c8 ignore next */ - default: - throw new Error(`Unexpected node type: ${node.type}`); - } - -} - -//------------------------------------------------------------------------------ -// Rule Definition -//------------------------------------------------------------------------------ - -/** @type {import('../shared/types').Rule} */ -module.exports = { - meta: { - type: "suggestion", - - docs: { - description: "Disallow unnecessary computed property keys in objects and classes", - recommended: false, - url: "https://eslint.org/docs/latest/rules/no-useless-computed-key" - }, - - schema: [{ - type: "object", - properties: { - enforceForClassMembers: { - type: "boolean", - default: true - } - }, - additionalProperties: false - }], - fixable: "code", - - messages: { - unnecessarilyComputedProperty: "Unnecessarily computed property [{{property}}] found." - } - }, - create(context) { - const sourceCode = context.sourceCode; - const enforceForClassMembers = context.options[0]?.enforceForClassMembers ?? true; - - /** - * Reports a given node if it violated this rule. - * @param {ASTNode} node The node to check. - * @returns {void} - */ - function check(node) { - if (hasUselessComputedKey(node)) { - const { key } = node; - - context.report({ - node, - messageId: "unnecessarilyComputedProperty", - data: { property: sourceCode.getText(key) }, - fix(fixer) { - const leftSquareBracket = sourceCode.getTokenBefore(key, astUtils.isOpeningBracketToken); - const rightSquareBracket = sourceCode.getTokenAfter(key, astUtils.isClosingBracketToken); - - // If there are comments between the brackets and the property name, don't do a fix. - if (sourceCode.commentsExistBetween(leftSquareBracket, rightSquareBracket)) { - return null; - } - - const tokenBeforeLeftBracket = sourceCode.getTokenBefore(leftSquareBracket); - - // Insert a space before the key to avoid changing identifiers, e.g. ({ get[2]() {} }) to ({ get2() {} }) - const needsSpaceBeforeKey = tokenBeforeLeftBracket.range[1] === leftSquareBracket.range[0] && - !astUtils.canTokensBeAdjacent(tokenBeforeLeftBracket, sourceCode.getFirstToken(key)); - - const replacementKey = (needsSpaceBeforeKey ? " " : "") + key.raw; - - return fixer.replaceTextRange([leftSquareBracket.range[0], rightSquareBracket.range[1]], replacementKey); - } - }); - } - } - - /** - * A no-op function to act as placeholder for checking a node when the `enforceForClassMembers` option is `false`. - * @returns {void} - * @private - */ - function noop() {} - - return { - Property: check, - MethodDefinition: enforceForClassMembers ? check : noop, - PropertyDefinition: enforceForClassMembers ? check : noop - }; - } -}; diff --git a/tools/eslint/node_modules/eslint/lib/rules/no-useless-concat.js b/tools/eslint/node_modules/eslint/lib/rules/no-useless-concat.js deleted file mode 100644 index c566c62be8dcbe..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/rules/no-useless-concat.js +++ /dev/null @@ -1,115 +0,0 @@ -/** - * @fileoverview disallow unnecessary concatenation of template strings - * @author Henry Zhu - */ -"use strict"; - -//------------------------------------------------------------------------------ -// Requirements -//------------------------------------------------------------------------------ - -const astUtils = require("./utils/ast-utils"); - -//------------------------------------------------------------------------------ -// Helpers -//------------------------------------------------------------------------------ - -/** - * Checks whether or not a given node is a concatenation. - * @param {ASTNode} node A node to check. - * @returns {boolean} `true` if the node is a concatenation. - */ -function isConcatenation(node) { - return node.type === "BinaryExpression" && node.operator === "+"; -} - -/** - * Checks if the given token is a `+` token or not. - * @param {Token} token The token to check. - * @returns {boolean} `true` if the token is a `+` token. - */ -function isConcatOperatorToken(token) { - return token.value === "+" && token.type === "Punctuator"; -} - -/** - * Get's the right most node on the left side of a BinaryExpression with + operator. - * @param {ASTNode} node A BinaryExpression node to check. - * @returns {ASTNode} node - */ -function getLeft(node) { - let left = node.left; - - while (isConcatenation(left)) { - left = left.right; - } - return left; -} - -/** - * Get's the left most node on the right side of a BinaryExpression with + operator. - * @param {ASTNode} node A BinaryExpression node to check. - * @returns {ASTNode} node - */ -function getRight(node) { - let right = node.right; - - while (isConcatenation(right)) { - right = right.left; - } - return right; -} - -//------------------------------------------------------------------------------ -// Rule Definition -//------------------------------------------------------------------------------ - -/** @type {import('../shared/types').Rule} */ -module.exports = { - meta: { - type: "suggestion", - - docs: { - description: "Disallow unnecessary concatenation of literals or template literals", - recommended: false, - url: "https://eslint.org/docs/latest/rules/no-useless-concat" - }, - - schema: [], - - messages: { - unexpectedConcat: "Unexpected string concatenation of literals." - } - }, - - create(context) { - const sourceCode = context.sourceCode; - - return { - BinaryExpression(node) { - - // check if not concatenation - if (node.operator !== "+") { - return; - } - - // account for the `foo + "a" + "b"` case - const left = getLeft(node); - const right = getRight(node); - - if (astUtils.isStringLiteral(left) && - astUtils.isStringLiteral(right) && - astUtils.isTokenOnSameLine(left, right) - ) { - const operatorToken = sourceCode.getFirstTokenBetween(left, right, isConcatOperatorToken); - - context.report({ - node, - loc: operatorToken.loc, - messageId: "unexpectedConcat" - }); - } - } - }; - } -}; diff --git a/tools/eslint/node_modules/eslint/lib/rules/no-useless-constructor.js b/tools/eslint/node_modules/eslint/lib/rules/no-useless-constructor.js deleted file mode 100644 index 2b9c18e51cbd1f..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/rules/no-useless-constructor.js +++ /dev/null @@ -1,189 +0,0 @@ -/** - * @fileoverview Rule to flag the use of redundant constructors in classes. - * @author Alberto Rodrรญguez - */ -"use strict"; - -//------------------------------------------------------------------------------ -// Helpers -//------------------------------------------------------------------------------ - -/** - * Checks whether a given array of statements is a single call of `super`. - * @param {ASTNode[]} body An array of statements to check. - * @returns {boolean} `true` if the body is a single call of `super`. - */ -function isSingleSuperCall(body) { - return ( - body.length === 1 && - body[0].type === "ExpressionStatement" && - body[0].expression.type === "CallExpression" && - body[0].expression.callee.type === "Super" - ); -} - -/** - * Checks whether a given node is a pattern which doesn't have any side effects. - * Default parameters and Destructuring parameters can have side effects. - * @param {ASTNode} node A pattern node. - * @returns {boolean} `true` if the node doesn't have any side effects. - */ -function isSimple(node) { - return node.type === "Identifier" || node.type === "RestElement"; -} - -/** - * Checks whether a given array of expressions is `...arguments` or not. - * `super(...arguments)` passes all arguments through. - * @param {ASTNode[]} superArgs An array of expressions to check. - * @returns {boolean} `true` if the superArgs is `...arguments`. - */ -function isSpreadArguments(superArgs) { - return ( - superArgs.length === 1 && - superArgs[0].type === "SpreadElement" && - superArgs[0].argument.type === "Identifier" && - superArgs[0].argument.name === "arguments" - ); -} - -/** - * Checks whether given 2 nodes are identifiers which have the same name or not. - * @param {ASTNode} ctorParam A node to check. - * @param {ASTNode} superArg A node to check. - * @returns {boolean} `true` if the nodes are identifiers which have the same - * name. - */ -function isValidIdentifierPair(ctorParam, superArg) { - return ( - ctorParam.type === "Identifier" && - superArg.type === "Identifier" && - ctorParam.name === superArg.name - ); -} - -/** - * Checks whether given 2 nodes are a rest/spread pair which has the same values. - * @param {ASTNode} ctorParam A node to check. - * @param {ASTNode} superArg A node to check. - * @returns {boolean} `true` if the nodes are a rest/spread pair which has the - * same values. - */ -function isValidRestSpreadPair(ctorParam, superArg) { - return ( - ctorParam.type === "RestElement" && - superArg.type === "SpreadElement" && - isValidIdentifierPair(ctorParam.argument, superArg.argument) - ); -} - -/** - * Checks whether given 2 nodes have the same value or not. - * @param {ASTNode} ctorParam A node to check. - * @param {ASTNode} superArg A node to check. - * @returns {boolean} `true` if the nodes have the same value or not. - */ -function isValidPair(ctorParam, superArg) { - return ( - isValidIdentifierPair(ctorParam, superArg) || - isValidRestSpreadPair(ctorParam, superArg) - ); -} - -/** - * Checks whether the parameters of a constructor and the arguments of `super()` - * have the same values or not. - * @param {ASTNode} ctorParams The parameters of a constructor to check. - * @param {ASTNode} superArgs The arguments of `super()` to check. - * @returns {boolean} `true` if those have the same values. - */ -function isPassingThrough(ctorParams, superArgs) { - if (ctorParams.length !== superArgs.length) { - return false; - } - - for (let i = 0; i < ctorParams.length; ++i) { - if (!isValidPair(ctorParams[i], superArgs[i])) { - return false; - } - } - - return true; -} - -/** - * Checks whether the constructor body is a redundant super call. - * @param {Array} body constructor body content. - * @param {Array} ctorParams The params to check against super call. - * @returns {boolean} true if the constructor body is redundant - */ -function isRedundantSuperCall(body, ctorParams) { - return ( - isSingleSuperCall(body) && - ctorParams.every(isSimple) && - ( - isSpreadArguments(body[0].expression.arguments) || - isPassingThrough(ctorParams, body[0].expression.arguments) - ) - ); -} - -//------------------------------------------------------------------------------ -// Rule Definition -//------------------------------------------------------------------------------ - -/** @type {import('../shared/types').Rule} */ -module.exports = { - meta: { - type: "suggestion", - - docs: { - description: "Disallow unnecessary constructors", - recommended: false, - url: "https://eslint.org/docs/latest/rules/no-useless-constructor" - }, - - schema: [], - - messages: { - noUselessConstructor: "Useless constructor." - } - }, - - create(context) { - - /** - * Checks whether a node is a redundant constructor - * @param {ASTNode} node node to check - * @returns {void} - */ - function checkForConstructor(node) { - if (node.kind !== "constructor") { - return; - } - - /* - * Prevent crashing on parsers which do not require class constructor - * to have a body, e.g. typescript and flow - */ - if (!node.value.body) { - return; - } - - const body = node.value.body.body; - const ctorParams = node.value.params; - const superClass = node.parent.parent.superClass; - - if (superClass ? isRedundantSuperCall(body, ctorParams) : (body.length === 0)) { - context.report({ - node, - messageId: "noUselessConstructor" - }); - } - } - - return { - MethodDefinition: checkForConstructor - }; - } -}; diff --git a/tools/eslint/node_modules/eslint/lib/rules/no-useless-escape.js b/tools/eslint/node_modules/eslint/lib/rules/no-useless-escape.js deleted file mode 100644 index 0e0f6f09f2c35f..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/rules/no-useless-escape.js +++ /dev/null @@ -1,333 +0,0 @@ -/** - * @fileoverview Look for useless escapes in strings and regexes - * @author Onur Temizkan - */ - -"use strict"; - -const astUtils = require("./utils/ast-utils"); -const { RegExpParser, visitRegExpAST } = require("@eslint-community/regexpp"); - -/** - * @typedef {import('@eslint-community/regexpp').AST.CharacterClass} CharacterClass - * @typedef {import('@eslint-community/regexpp').AST.ExpressionCharacterClass} ExpressionCharacterClass - */ -//------------------------------------------------------------------------------ -// Rule Definition -//------------------------------------------------------------------------------ - -/** - * Returns the union of two sets. - * @param {Set} setA The first set - * @param {Set} setB The second set - * @returns {Set} The union of the two sets - */ -function union(setA, setB) { - return new Set(function *() { - yield* setA; - yield* setB; - }()); -} - -const VALID_STRING_ESCAPES = union(new Set("\\nrvtbfux"), astUtils.LINEBREAKS); -const REGEX_GENERAL_ESCAPES = new Set("\\bcdDfnpPrsStvwWxu0123456789]"); -const REGEX_NON_CHARCLASS_ESCAPES = union(REGEX_GENERAL_ESCAPES, new Set("^/.$*+?[{}|()Bk")); - -/* - * Set of characters that require escaping in character classes in `unicodeSets` mode. - * ( ) [ ] { } / - \ | are ClassSetSyntaxCharacter - */ -const REGEX_CLASSSET_CHARACTER_ESCAPES = union(REGEX_GENERAL_ESCAPES, new Set("q/[{}|()-")); - -/* - * A single character set of ClassSetReservedDoublePunctuator. - * && !! ## $$ %% ** ++ ,, .. :: ;; << == >> ?? @@ ^^ `` ~~ are ClassSetReservedDoublePunctuator - */ -const REGEX_CLASS_SET_RESERVED_DOUBLE_PUNCTUATOR = new Set("!#$%&*+,.:;<=>?@^`~"); - -/** @type {import('../shared/types').Rule} */ -module.exports = { - meta: { - type: "suggestion", - - docs: { - description: "Disallow unnecessary escape characters", - recommended: true, - url: "https://eslint.org/docs/latest/rules/no-useless-escape" - }, - - hasSuggestions: true, - - messages: { - unnecessaryEscape: "Unnecessary escape character: \\{{character}}.", - removeEscape: "Remove the `\\`. This maintains the current functionality.", - removeEscapeDoNotKeepSemantics: "Remove the `\\` if it was inserted by mistake.", - escapeBackslash: "Replace the `\\` with `\\\\` to include the actual backslash character." - }, - - schema: [] - }, - - create(context) { - const sourceCode = context.sourceCode; - const parser = new RegExpParser(); - - /** - * Reports a node - * @param {ASTNode} node The node to report - * @param {number} startOffset The backslash's offset from the start of the node - * @param {string} character The uselessly escaped character (not including the backslash) - * @param {boolean} [disableEscapeBackslashSuggest] `true` if escapeBackslash suggestion should be turned off. - * @returns {void} - */ - function report(node, startOffset, character, disableEscapeBackslashSuggest) { - const rangeStart = node.range[0] + startOffset; - const range = [rangeStart, rangeStart + 1]; - const start = sourceCode.getLocFromIndex(rangeStart); - - context.report({ - node, - loc: { - start, - end: { line: start.line, column: start.column + 1 } - }, - messageId: "unnecessaryEscape", - data: { character }, - suggest: [ - { - - // Removing unnecessary `\` characters in a directive is not guaranteed to maintain functionality. - messageId: astUtils.isDirective(node.parent) - ? "removeEscapeDoNotKeepSemantics" : "removeEscape", - fix(fixer) { - return fixer.removeRange(range); - } - }, - ...disableEscapeBackslashSuggest - ? [] - : [ - { - messageId: "escapeBackslash", - fix(fixer) { - return fixer.insertTextBeforeRange(range, "\\"); - } - } - ] - ] - }); - } - - /** - * Checks if the escape character in given string slice is unnecessary. - * @private - * @param {ASTNode} node node to validate. - * @param {string} match string slice to validate. - * @returns {void} - */ - function validateString(node, match) { - const isTemplateElement = node.type === "TemplateElement"; - const escapedChar = match[0][1]; - let isUnnecessaryEscape = !VALID_STRING_ESCAPES.has(escapedChar); - let isQuoteEscape; - - if (isTemplateElement) { - isQuoteEscape = escapedChar === "`"; - - if (escapedChar === "$") { - - // Warn if `\$` is not followed by `{` - isUnnecessaryEscape = match.input[match.index + 2] !== "{"; - } else if (escapedChar === "{") { - - /* - * Warn if `\{` is not preceded by `$`. If preceded by `$`, escaping - * is necessary and the rule should not warn. If preceded by `/$`, the rule - * will warn for the `/$` instead, as it is the first unnecessarily escaped character. - */ - isUnnecessaryEscape = match.input[match.index - 1] !== "$"; - } - } else { - isQuoteEscape = escapedChar === node.raw[0]; - } - - if (isUnnecessaryEscape && !isQuoteEscape) { - report(node, match.index, match[0].slice(1)); - } - } - - /** - * Checks if the escape character in given regexp is unnecessary. - * @private - * @param {ASTNode} node node to validate. - * @returns {void} - */ - function validateRegExp(node) { - const { pattern, flags } = node.regex; - let patternNode; - const unicode = flags.includes("u"); - const unicodeSets = flags.includes("v"); - - try { - patternNode = parser.parsePattern(pattern, 0, pattern.length, { unicode, unicodeSets }); - } catch { - - // Ignore regular expressions with syntax errors - return; - } - - /** @type {(CharacterClass | ExpressionCharacterClass)[]} */ - const characterClassStack = []; - - visitRegExpAST(patternNode, { - onCharacterClassEnter: characterClassNode => characterClassStack.unshift(characterClassNode), - onCharacterClassLeave: () => characterClassStack.shift(), - onExpressionCharacterClassEnter: characterClassNode => characterClassStack.unshift(characterClassNode), - onExpressionCharacterClassLeave: () => characterClassStack.shift(), - onCharacterEnter(characterNode) { - if (!characterNode.raw.startsWith("\\")) { - - // It's not an escaped character. - return; - } - - const escapedChar = characterNode.raw.slice(1); - - if (escapedChar !== String.fromCodePoint(characterNode.value)) { - - // It's a valid escape. - return; - } - let allowedEscapes; - - if (characterClassStack.length) { - allowedEscapes = unicodeSets ? REGEX_CLASSSET_CHARACTER_ESCAPES : REGEX_GENERAL_ESCAPES; - } else { - allowedEscapes = REGEX_NON_CHARCLASS_ESCAPES; - } - if (allowedEscapes.has(escapedChar)) { - return; - } - - const reportedIndex = characterNode.start + 1; - let disableEscapeBackslashSuggest = false; - - if (characterClassStack.length) { - const characterClassNode = characterClassStack[0]; - - if (escapedChar === "^") { - - /* - * The '^' character is also a special case; it must always be escaped outside of character classes, but - * it only needs to be escaped in character classes if it's at the beginning of the character class. To - * account for this, consider it to be a valid escape character outside of character classes, and filter - * out '^' characters that appear at the start of a character class. - */ - if (characterClassNode.start + 1 === characterNode.start) { - - return; - } - } - if (!unicodeSets) { - if (escapedChar === "-") { - - /* - * The '-' character is a special case, because it's only valid to escape it if it's in a character - * class, and is not at either edge of the character class. To account for this, don't consider '-' - * characters to be valid in general, and filter out '-' characters that appear in the middle of a - * character class. - */ - if (characterClassNode.start + 1 !== characterNode.start && characterNode.end !== characterClassNode.end - 1) { - - return; - } - } - } else { // unicodeSets mode - if (REGEX_CLASS_SET_RESERVED_DOUBLE_PUNCTUATOR.has(escapedChar)) { - - // Escaping is valid if it is a ClassSetReservedDoublePunctuator. - if (pattern[characterNode.end] === escapedChar) { - return; - } - if (pattern[characterNode.start - 1] === escapedChar) { - if (escapedChar !== "^") { - return; - } - - // If the previous character is a `negate` caret(`^`), escape to caret is unnecessary. - - if (!characterClassNode.negate) { - return; - } - const negateCaretIndex = characterClassNode.start + 1; - - if (negateCaretIndex < characterNode.start - 1) { - return; - } - } - } - - if (characterNode.parent.type === "ClassIntersection" || characterNode.parent.type === "ClassSubtraction") { - disableEscapeBackslashSuggest = true; - } - } - } - - report( - node, - reportedIndex, - escapedChar, - disableEscapeBackslashSuggest - ); - } - }); - } - - /** - * Checks if a node has an escape. - * @param {ASTNode} node node to check. - * @returns {void} - */ - function check(node) { - const isTemplateElement = node.type === "TemplateElement"; - - if ( - isTemplateElement && - node.parent && - node.parent.parent && - node.parent.parent.type === "TaggedTemplateExpression" && - node.parent === node.parent.parent.quasi - ) { - - // Don't report tagged template literals, because the backslash character is accessible to the tag function. - return; - } - - if (typeof node.value === "string" || isTemplateElement) { - - /* - * JSXAttribute doesn't have any escape sequence: https://facebook.github.io/jsx/. - * In addition, backticks are not supported by JSX yet: https://github.com/facebook/jsx/issues/25. - */ - if (node.parent.type === "JSXAttribute" || node.parent.type === "JSXElement" || node.parent.type === "JSXFragment") { - return; - } - - const value = isTemplateElement ? sourceCode.getText(node) : node.raw; - const pattern = /\\[^\d]/gu; - let match; - - while ((match = pattern.exec(value))) { - validateString(node, match); - } - } else if (node.regex) { - validateRegExp(node); - } - - } - - return { - Literal: check, - TemplateElement: check - }; - } -}; diff --git a/tools/eslint/node_modules/eslint/lib/rules/no-useless-rename.js b/tools/eslint/node_modules/eslint/lib/rules/no-useless-rename.js deleted file mode 100644 index 0c818fb2c2f5fa..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/rules/no-useless-rename.js +++ /dev/null @@ -1,172 +0,0 @@ -/** - * @fileoverview Disallow renaming import, export, and destructured assignments to the same name. - * @author Kai Cataldo - */ - -"use strict"; - -//------------------------------------------------------------------------------ -// Requirements -//------------------------------------------------------------------------------ - -const astUtils = require("./utils/ast-utils"); - -//------------------------------------------------------------------------------ -// Rule Definition -//------------------------------------------------------------------------------ - -/** @type {import('../shared/types').Rule} */ -module.exports = { - meta: { - type: "suggestion", - - docs: { - description: "Disallow renaming import, export, and destructured assignments to the same name", - recommended: false, - url: "https://eslint.org/docs/latest/rules/no-useless-rename" - }, - - fixable: "code", - - schema: [ - { - type: "object", - properties: { - ignoreDestructuring: { type: "boolean", default: false }, - ignoreImport: { type: "boolean", default: false }, - ignoreExport: { type: "boolean", default: false } - }, - additionalProperties: false - } - ], - - messages: { - unnecessarilyRenamed: "{{type}} {{name}} unnecessarily renamed." - } - }, - - create(context) { - const sourceCode = context.sourceCode, - options = context.options[0] || {}, - ignoreDestructuring = options.ignoreDestructuring === true, - ignoreImport = options.ignoreImport === true, - ignoreExport = options.ignoreExport === true; - - //-------------------------------------------------------------------------- - // Helpers - //-------------------------------------------------------------------------- - - /** - * Reports error for unnecessarily renamed assignments - * @param {ASTNode} node node to report - * @param {ASTNode} initial node with initial name value - * @param {string} type the type of the offending node - * @returns {void} - */ - function reportError(node, initial, type) { - const name = initial.type === "Identifier" ? initial.name : initial.value; - - return context.report({ - node, - messageId: "unnecessarilyRenamed", - data: { - name, - type - }, - fix(fixer) { - const replacementNode = node.type === "Property" ? node.value : node.local; - - if (sourceCode.getCommentsInside(node).length > sourceCode.getCommentsInside(replacementNode).length) { - return null; - } - - // Don't autofix code such as `({foo: (foo) = a} = obj);`, parens are not allowed in shorthand properties. - if ( - replacementNode.type === "AssignmentPattern" && - astUtils.isParenthesised(sourceCode, replacementNode.left) - ) { - return null; - } - - return fixer.replaceText(node, sourceCode.getText(replacementNode)); - } - }); - } - - /** - * Checks whether a destructured assignment is unnecessarily renamed - * @param {ASTNode} node node to check - * @returns {void} - */ - function checkDestructured(node) { - if (ignoreDestructuring) { - return; - } - - for (const property of node.properties) { - - /** - * Properties using shorthand syntax and rest elements can not be renamed. - * If the property is computed, we have no idea if a rename is useless or not. - */ - if (property.type !== "Property" || property.shorthand || property.computed) { - continue; - } - - const key = (property.key.type === "Identifier" && property.key.name) || (property.key.type === "Literal" && property.key.value); - const renamedKey = property.value.type === "AssignmentPattern" ? property.value.left.name : property.value.name; - - if (key === renamedKey) { - reportError(property, property.key, "Destructuring assignment"); - } - } - } - - /** - * Checks whether an import is unnecessarily renamed - * @param {ASTNode} node node to check - * @returns {void} - */ - function checkImport(node) { - if (ignoreImport) { - return; - } - - if ( - node.imported.range[0] !== node.local.range[0] && - astUtils.getModuleExportName(node.imported) === node.local.name - ) { - reportError(node, node.imported, "Import"); - } - } - - /** - * Checks whether an export is unnecessarily renamed - * @param {ASTNode} node node to check - * @returns {void} - */ - function checkExport(node) { - if (ignoreExport) { - return; - } - - if ( - node.local.range[0] !== node.exported.range[0] && - astUtils.getModuleExportName(node.local) === astUtils.getModuleExportName(node.exported) - ) { - reportError(node, node.local, "Export"); - } - - } - - //-------------------------------------------------------------------------- - // Public - //-------------------------------------------------------------------------- - - return { - ObjectPattern: checkDestructured, - ImportSpecifier: checkImport, - ExportSpecifier: checkExport - }; - } -}; diff --git a/tools/eslint/node_modules/eslint/lib/rules/no-useless-return.js b/tools/eslint/node_modules/eslint/lib/rules/no-useless-return.js deleted file mode 100644 index 1f85cdb9aafc4d..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/rules/no-useless-return.js +++ /dev/null @@ -1,369 +0,0 @@ -/** - * @fileoverview Disallow redundant return statements - * @author Teddy Katz - */ -"use strict"; - -//------------------------------------------------------------------------------ -// Requirements -//------------------------------------------------------------------------------ - -const astUtils = require("./utils/ast-utils"), - FixTracker = require("./utils/fix-tracker"); - -//------------------------------------------------------------------------------ -// Helpers -//------------------------------------------------------------------------------ - -/** - * Removes the given element from the array. - * @param {Array} array The source array to remove. - * @param {any} element The target item to remove. - * @returns {void} - */ -function remove(array, element) { - const index = array.indexOf(element); - - if (index !== -1) { - array.splice(index, 1); - } -} - -/** - * Checks whether it can remove the given return statement or not. - * @param {ASTNode} node The return statement node to check. - * @returns {boolean} `true` if the node is removable. - */ -function isRemovable(node) { - return astUtils.STATEMENT_LIST_PARENTS.has(node.parent.type); -} - -/** - * Checks whether the given return statement is in a `finally` block or not. - * @param {ASTNode} node The return statement node to check. - * @returns {boolean} `true` if the node is in a `finally` block. - */ -function isInFinally(node) { - for ( - let currentNode = node; - currentNode && currentNode.parent && !astUtils.isFunction(currentNode); - currentNode = currentNode.parent - ) { - if (currentNode.parent.type === "TryStatement" && currentNode.parent.finalizer === currentNode) { - return true; - } - } - - return false; -} - -/** - * Checks all segments in a set and returns true if any are reachable. - * @param {Set} segments The segments to check. - * @returns {boolean} True if any segment is reachable; false otherwise. - */ -function isAnySegmentReachable(segments) { - - for (const segment of segments) { - if (segment.reachable) { - return true; - } - } - - return false; -} - -//------------------------------------------------------------------------------ -// Rule Definition -//------------------------------------------------------------------------------ - -/** @type {import('../shared/types').Rule} */ -module.exports = { - meta: { - type: "suggestion", - - docs: { - description: "Disallow redundant return statements", - recommended: false, - url: "https://eslint.org/docs/latest/rules/no-useless-return" - }, - - fixable: "code", - schema: [], - - messages: { - unnecessaryReturn: "Unnecessary return statement." - } - }, - - create(context) { - const segmentInfoMap = new WeakMap(); - const sourceCode = context.sourceCode; - let scopeInfo = null; - - /** - * Checks whether the given segment is terminated by a return statement or not. - * @param {CodePathSegment} segment The segment to check. - * @returns {boolean} `true` if the segment is terminated by a return statement, or if it's still a part of unreachable. - */ - function isReturned(segment) { - const info = segmentInfoMap.get(segment); - - return !info || info.returned; - } - - /** - * Collects useless return statements from the given previous segments. - * - * A previous segment may be an unreachable segment. - * In that case, the information object of the unreachable segment is not - * initialized because `onCodePathSegmentStart` event is not notified for - * unreachable segments. - * This goes to the previous segments of the unreachable segment recursively - * if the unreachable segment was generated by a return statement. Otherwise, - * this ignores the unreachable segment. - * - * This behavior would simulate code paths for the case that the return - * statement does not exist. - * @param {ASTNode[]} uselessReturns The collected return statements. - * @param {CodePathSegment[]} prevSegments The previous segments to traverse. - * @param {WeakSet} [providedTraversedSegments] A set of segments that have already been traversed in this call - * @returns {ASTNode[]} `uselessReturns`. - */ - function getUselessReturns(uselessReturns, prevSegments, providedTraversedSegments) { - const traversedSegments = providedTraversedSegments || new WeakSet(); - - for (const segment of prevSegments) { - if (!segment.reachable) { - if (!traversedSegments.has(segment)) { - traversedSegments.add(segment); - getUselessReturns( - uselessReturns, - segment.allPrevSegments.filter(isReturned), - traversedSegments - ); - } - continue; - } - - if (segmentInfoMap.has(segment)) { - uselessReturns.push(...segmentInfoMap.get(segment).uselessReturns); - } - } - - return uselessReturns; - } - - /** - * Removes the return statements on the given segment from the useless return - * statement list. - * - * This segment may be an unreachable segment. - * In that case, the information object of the unreachable segment is not - * initialized because `onCodePathSegmentStart` event is not notified for - * unreachable segments. - * This goes to the previous segments of the unreachable segment recursively - * if the unreachable segment was generated by a return statement. Otherwise, - * this ignores the unreachable segment. - * - * This behavior would simulate code paths for the case that the return - * statement does not exist. - * @param {CodePathSegment} segment The segment to get return statements. - * @param {Set} usedUnreachableSegments A set of segments that have already been traversed in this call. - * @returns {void} - */ - function markReturnStatementsOnSegmentAsUsed(segment, usedUnreachableSegments) { - if (!segment.reachable) { - usedUnreachableSegments.add(segment); - segment.allPrevSegments - .filter(isReturned) - .filter(prevSegment => !usedUnreachableSegments.has(prevSegment)) - .forEach(prevSegment => markReturnStatementsOnSegmentAsUsed(prevSegment, usedUnreachableSegments)); - return; - } - - const info = segmentInfoMap.get(segment); - - if (!info) { - return; - } - - info.uselessReturns = info.uselessReturns.filter(node => { - if (scopeInfo.traversedTryBlockStatements && scopeInfo.traversedTryBlockStatements.length > 0) { - const returnInitialRange = node.range[0]; - const returnFinalRange = node.range[1]; - - const areBlocksInRange = scopeInfo.traversedTryBlockStatements.some(tryBlockStatement => { - const blockInitialRange = tryBlockStatement.range[0]; - const blockFinalRange = tryBlockStatement.range[1]; - - return ( - returnInitialRange >= blockInitialRange && - returnFinalRange <= blockFinalRange - ); - }); - - if (areBlocksInRange) { - return true; - } - } - - remove(scopeInfo.uselessReturns, node); - return false; - }); - } - - /** - * Removes the return statements on the current segments from the useless - * return statement list. - * - * This function will be called at every statement except FunctionDeclaration, - * BlockStatement, and BreakStatement. - * - * - FunctionDeclarations are always executed whether it's returned or not. - * - BlockStatements do nothing. - * - BreakStatements go the next merely. - * @returns {void} - */ - function markReturnStatementsOnCurrentSegmentsAsUsed() { - scopeInfo - .currentSegments - .forEach(segment => markReturnStatementsOnSegmentAsUsed(segment, new Set())); - } - - //---------------------------------------------------------------------- - // Public - //---------------------------------------------------------------------- - - return { - - // Makes and pushes a new scope information. - onCodePathStart(codePath) { - scopeInfo = { - upper: scopeInfo, - uselessReturns: [], - traversedTryBlockStatements: [], - codePath, - currentSegments: new Set() - }; - }, - - // Reports useless return statements if exist. - onCodePathEnd() { - for (const node of scopeInfo.uselessReturns) { - context.report({ - node, - loc: node.loc, - messageId: "unnecessaryReturn", - fix(fixer) { - if (isRemovable(node) && !sourceCode.getCommentsInside(node).length) { - - /* - * Extend the replacement range to include the - * entire function to avoid conflicting with - * no-else-return. - * https://github.com/eslint/eslint/issues/8026 - */ - return new FixTracker(fixer, sourceCode) - .retainEnclosingFunction(node) - .remove(node); - } - return null; - } - }); - } - - scopeInfo = scopeInfo.upper; - }, - - /* - * Initializes segments. - * NOTE: This event is notified for only reachable segments. - */ - onCodePathSegmentStart(segment) { - scopeInfo.currentSegments.add(segment); - - const info = { - uselessReturns: getUselessReturns([], segment.allPrevSegments), - returned: false - }; - - // Stores the info. - segmentInfoMap.set(segment, info); - }, - - onUnreachableCodePathSegmentStart(segment) { - scopeInfo.currentSegments.add(segment); - }, - - onUnreachableCodePathSegmentEnd(segment) { - scopeInfo.currentSegments.delete(segment); - }, - - onCodePathSegmentEnd(segment) { - scopeInfo.currentSegments.delete(segment); - }, - - // Adds ReturnStatement node to check whether it's useless or not. - ReturnStatement(node) { - if (node.argument) { - markReturnStatementsOnCurrentSegmentsAsUsed(); - } - if ( - node.argument || - astUtils.isInLoop(node) || - isInFinally(node) || - - // Ignore `return` statements in unreachable places (https://github.com/eslint/eslint/issues/11647). - !isAnySegmentReachable(scopeInfo.currentSegments) - ) { - return; - } - - for (const segment of scopeInfo.currentSegments) { - const info = segmentInfoMap.get(segment); - - if (info) { - info.uselessReturns.push(node); - info.returned = true; - } - } - scopeInfo.uselessReturns.push(node); - }, - - "TryStatement > BlockStatement.block:exit"(node) { - scopeInfo.traversedTryBlockStatements.push(node); - }, - - "TryStatement:exit"() { - scopeInfo.traversedTryBlockStatements.pop(); - }, - - /* - * Registers for all statement nodes except FunctionDeclaration, BlockStatement, BreakStatement. - * Removes return statements of the current segments from the useless return statement list. - */ - ClassDeclaration: markReturnStatementsOnCurrentSegmentsAsUsed, - ContinueStatement: markReturnStatementsOnCurrentSegmentsAsUsed, - DebuggerStatement: markReturnStatementsOnCurrentSegmentsAsUsed, - DoWhileStatement: markReturnStatementsOnCurrentSegmentsAsUsed, - EmptyStatement: markReturnStatementsOnCurrentSegmentsAsUsed, - ExpressionStatement: markReturnStatementsOnCurrentSegmentsAsUsed, - ForInStatement: markReturnStatementsOnCurrentSegmentsAsUsed, - ForOfStatement: markReturnStatementsOnCurrentSegmentsAsUsed, - ForStatement: markReturnStatementsOnCurrentSegmentsAsUsed, - IfStatement: markReturnStatementsOnCurrentSegmentsAsUsed, - ImportDeclaration: markReturnStatementsOnCurrentSegmentsAsUsed, - LabeledStatement: markReturnStatementsOnCurrentSegmentsAsUsed, - SwitchStatement: markReturnStatementsOnCurrentSegmentsAsUsed, - ThrowStatement: markReturnStatementsOnCurrentSegmentsAsUsed, - TryStatement: markReturnStatementsOnCurrentSegmentsAsUsed, - VariableDeclaration: markReturnStatementsOnCurrentSegmentsAsUsed, - WhileStatement: markReturnStatementsOnCurrentSegmentsAsUsed, - WithStatement: markReturnStatementsOnCurrentSegmentsAsUsed, - ExportNamedDeclaration: markReturnStatementsOnCurrentSegmentsAsUsed, - ExportDefaultDeclaration: markReturnStatementsOnCurrentSegmentsAsUsed, - ExportAllDeclaration: markReturnStatementsOnCurrentSegmentsAsUsed - }; - } -}; diff --git a/tools/eslint/node_modules/eslint/lib/rules/no-var.js b/tools/eslint/node_modules/eslint/lib/rules/no-var.js deleted file mode 100644 index d45a91a1de816a..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/rules/no-var.js +++ /dev/null @@ -1,334 +0,0 @@ -/** - * @fileoverview Rule to check for the usage of var. - * @author Jamund Ferguson - */ - -"use strict"; - -//------------------------------------------------------------------------------ -// Requirements -//------------------------------------------------------------------------------ - -const astUtils = require("./utils/ast-utils"); - -//------------------------------------------------------------------------------ -// Helpers -//------------------------------------------------------------------------------ - -/** - * Check whether a given variable is a global variable or not. - * @param {eslint-scope.Variable} variable The variable to check. - * @returns {boolean} `true` if the variable is a global variable. - */ -function isGlobal(variable) { - return Boolean(variable.scope) && variable.scope.type === "global"; -} - -/** - * Finds the nearest function scope or global scope walking up the scope - * hierarchy. - * @param {eslint-scope.Scope} scope The scope to traverse. - * @returns {eslint-scope.Scope} a function scope or global scope containing the given - * scope. - */ -function getEnclosingFunctionScope(scope) { - let currentScope = scope; - - while (currentScope.type !== "function" && currentScope.type !== "global") { - currentScope = currentScope.upper; - } - return currentScope; -} - -/** - * Checks whether the given variable has any references from a more specific - * function expression (i.e. a closure). - * @param {eslint-scope.Variable} variable A variable to check. - * @returns {boolean} `true` if the variable is used from a closure. - */ -function isReferencedInClosure(variable) { - const enclosingFunctionScope = getEnclosingFunctionScope(variable.scope); - - return variable.references.some(reference => - getEnclosingFunctionScope(reference.from) !== enclosingFunctionScope); -} - -/** - * Checks whether the given node is the assignee of a loop. - * @param {ASTNode} node A VariableDeclaration node to check. - * @returns {boolean} `true` if the declaration is assigned as part of loop - * iteration. - */ -function isLoopAssignee(node) { - return (node.parent.type === "ForOfStatement" || node.parent.type === "ForInStatement") && - node === node.parent.left; -} - -/** - * Checks whether the given variable declaration is immediately initialized. - * @param {ASTNode} node A VariableDeclaration node to check. - * @returns {boolean} `true` if the declaration has an initializer. - */ -function isDeclarationInitialized(node) { - return node.declarations.every(declarator => declarator.init !== null); -} - -const SCOPE_NODE_TYPE = /^(?:Program|BlockStatement|SwitchStatement|ForStatement|ForInStatement|ForOfStatement)$/u; - -/** - * Gets the scope node which directly contains a given node. - * @param {ASTNode} node A node to get. This is a `VariableDeclaration` or - * an `Identifier`. - * @returns {ASTNode} A scope node. This is one of `Program`, `BlockStatement`, - * `SwitchStatement`, `ForStatement`, `ForInStatement`, and - * `ForOfStatement`. - */ -function getScopeNode(node) { - for (let currentNode = node; currentNode; currentNode = currentNode.parent) { - if (SCOPE_NODE_TYPE.test(currentNode.type)) { - return currentNode; - } - } - - /* c8 ignore next */ - return null; -} - -/** - * Checks whether a given variable is redeclared or not. - * @param {eslint-scope.Variable} variable A variable to check. - * @returns {boolean} `true` if the variable is redeclared. - */ -function isRedeclared(variable) { - return variable.defs.length >= 2; -} - -/** - * Checks whether a given variable is used from outside of the specified scope. - * @param {ASTNode} scopeNode A scope node to check. - * @returns {Function} The predicate function which checks whether a given - * variable is used from outside of the specified scope. - */ -function isUsedFromOutsideOf(scopeNode) { - - /** - * Checks whether a given reference is inside of the specified scope or not. - * @param {eslint-scope.Reference} reference A reference to check. - * @returns {boolean} `true` if the reference is inside of the specified - * scope. - */ - function isOutsideOfScope(reference) { - const scope = scopeNode.range; - const id = reference.identifier.range; - - return id[0] < scope[0] || id[1] > scope[1]; - } - - return function(variable) { - return variable.references.some(isOutsideOfScope); - }; -} - -/** - * Creates the predicate function which checks whether a variable has their references in TDZ. - * - * The predicate function would return `true`: - * - * - if a reference is before the declarator. E.g. (var a = b, b = 1;)(var {a = b, b} = {};) - * - if a reference is in the expression of their default value. E.g. (var {a = a} = {};) - * - if a reference is in the expression of their initializer. E.g. (var a = a;) - * @param {ASTNode} node The initializer node of VariableDeclarator. - * @returns {Function} The predicate function. - * @private - */ -function hasReferenceInTDZ(node) { - const initStart = node.range[0]; - const initEnd = node.range[1]; - - return variable => { - const id = variable.defs[0].name; - const idStart = id.range[0]; - const defaultValue = (id.parent.type === "AssignmentPattern" ? id.parent.right : null); - const defaultStart = defaultValue && defaultValue.range[0]; - const defaultEnd = defaultValue && defaultValue.range[1]; - - return variable.references.some(reference => { - const start = reference.identifier.range[0]; - const end = reference.identifier.range[1]; - - return !reference.init && ( - start < idStart || - (defaultValue !== null && start >= defaultStart && end <= defaultEnd) || - (!astUtils.isFunction(node) && start >= initStart && end <= initEnd) - ); - }); - }; -} - -/** - * Checks whether a given variable has name that is allowed for 'var' declarations, - * but disallowed for `let` declarations. - * @param {eslint-scope.Variable} variable The variable to check. - * @returns {boolean} `true` if the variable has a disallowed name. - */ -function hasNameDisallowedForLetDeclarations(variable) { - return variable.name === "let"; -} - -//------------------------------------------------------------------------------ -// Rule Definition -//------------------------------------------------------------------------------ - -/** @type {import('../shared/types').Rule} */ -module.exports = { - meta: { - type: "suggestion", - - docs: { - description: "Require `let` or `const` instead of `var`", - recommended: false, - url: "https://eslint.org/docs/latest/rules/no-var" - }, - - schema: [], - fixable: "code", - - messages: { - unexpectedVar: "Unexpected var, use let or const instead." - } - }, - - create(context) { - const sourceCode = context.sourceCode; - - /** - * Checks whether the variables which are defined by the given declarator node have their references in TDZ. - * @param {ASTNode} declarator The VariableDeclarator node to check. - * @returns {boolean} `true` if one of the variables which are defined by the given declarator node have their references in TDZ. - */ - function hasSelfReferenceInTDZ(declarator) { - if (!declarator.init) { - return false; - } - const variables = sourceCode.getDeclaredVariables(declarator); - - return variables.some(hasReferenceInTDZ(declarator.init)); - } - - /** - * Checks whether it can fix a given variable declaration or not. - * It cannot fix if the following cases: - * - * - A variable is a global variable. - * - A variable is declared on a SwitchCase node. - * - A variable is redeclared. - * - A variable is used from outside the scope. - * - A variable is used from a closure within a loop. - * - A variable might be used before it is assigned within a loop. - * - A variable might be used in TDZ. - * - A variable is declared in statement position (e.g. a single-line `IfStatement`) - * - A variable has name that is disallowed for `let` declarations. - * - * ## A variable is declared on a SwitchCase node. - * - * If this rule modifies 'var' declarations on a SwitchCase node, it - * would generate the warnings of 'no-case-declarations' rule. And the - * 'eslint:recommended' preset includes 'no-case-declarations' rule, so - * this rule doesn't modify those declarations. - * - * ## A variable is redeclared. - * - * The language spec disallows redeclarations of `let` declarations. - * Those variables would cause syntax errors. - * - * ## A variable is used from outside the scope. - * - * The language spec disallows accesses from outside of the scope for - * `let` declarations. Those variables would cause reference errors. - * - * ## A variable is used from a closure within a loop. - * - * A `var` declaration within a loop shares the same variable instance - * across all loop iterations, while a `let` declaration creates a new - * instance for each iteration. This means if a variable in a loop is - * referenced by any closure, changing it from `var` to `let` would - * change the behavior in a way that is generally unsafe. - * - * ## A variable might be used before it is assigned within a loop. - * - * Within a loop, a `let` declaration without an initializer will be - * initialized to null, while a `var` declaration will retain its value - * from the previous iteration, so it is only safe to change `var` to - * `let` if we can statically determine that the variable is always - * assigned a value before its first access in the loop body. To keep - * the implementation simple, we only convert `var` to `let` within - * loops when the variable is a loop assignee or the declaration has an - * initializer. - * @param {ASTNode} node A variable declaration node to check. - * @returns {boolean} `true` if it can fix the node. - */ - function canFix(node) { - const variables = sourceCode.getDeclaredVariables(node); - const scopeNode = getScopeNode(node); - - if (node.parent.type === "SwitchCase" || - node.declarations.some(hasSelfReferenceInTDZ) || - variables.some(isGlobal) || - variables.some(isRedeclared) || - variables.some(isUsedFromOutsideOf(scopeNode)) || - variables.some(hasNameDisallowedForLetDeclarations) - ) { - return false; - } - - if (astUtils.isInLoop(node)) { - if (variables.some(isReferencedInClosure)) { - return false; - } - if (!isLoopAssignee(node) && !isDeclarationInitialized(node)) { - return false; - } - } - - if ( - !isLoopAssignee(node) && - !(node.parent.type === "ForStatement" && node.parent.init === node) && - !astUtils.STATEMENT_LIST_PARENTS.has(node.parent.type) - ) { - - // If the declaration is not in a block, e.g. `if (foo) var bar = 1;`, then it can't be fixed. - return false; - } - - return true; - } - - /** - * Reports a given variable declaration node. - * @param {ASTNode} node A variable declaration node to report. - * @returns {void} - */ - function report(node) { - context.report({ - node, - messageId: "unexpectedVar", - - fix(fixer) { - const varToken = sourceCode.getFirstToken(node, { filter: t => t.value === "var" }); - - return canFix(node) - ? fixer.replaceText(varToken, "let") - : null; - } - }); - } - - return { - "VariableDeclaration:exit"(node) { - if (node.kind === "var") { - report(node); - } - } - }; - } -}; diff --git a/tools/eslint/node_modules/eslint/lib/rules/no-void.js b/tools/eslint/node_modules/eslint/lib/rules/no-void.js deleted file mode 100644 index 9546d7a62c35ab..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/rules/no-void.js +++ /dev/null @@ -1,64 +0,0 @@ -/** - * @fileoverview Rule to disallow use of void operator. - * @author Mike Sidorov - */ -"use strict"; - -//------------------------------------------------------------------------------ -// Rule Definition -//------------------------------------------------------------------------------ - -/** @type {import('../shared/types').Rule} */ -module.exports = { - meta: { - type: "suggestion", - - docs: { - description: "Disallow `void` operators", - recommended: false, - url: "https://eslint.org/docs/latest/rules/no-void" - }, - - messages: { - noVoid: "Expected 'undefined' and instead saw 'void'." - }, - - schema: [ - { - type: "object", - properties: { - allowAsStatement: { - type: "boolean", - default: false - } - }, - additionalProperties: false - } - ] - }, - - create(context) { - const allowAsStatement = - context.options[0] && context.options[0].allowAsStatement; - - //-------------------------------------------------------------------------- - // Public - //-------------------------------------------------------------------------- - - return { - 'UnaryExpression[operator="void"]'(node) { - if ( - allowAsStatement && - node.parent && - node.parent.type === "ExpressionStatement" - ) { - return; - } - context.report({ - node, - messageId: "noVoid" - }); - } - }; - } -}; diff --git a/tools/eslint/node_modules/eslint/lib/rules/no-warning-comments.js b/tools/eslint/node_modules/eslint/lib/rules/no-warning-comments.js deleted file mode 100644 index c415bee7a7b213..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/rules/no-warning-comments.js +++ /dev/null @@ -1,201 +0,0 @@ -/** - * @fileoverview Rule that warns about used warning comments - * @author Alexander Schmidt - */ - -"use strict"; - -const escapeRegExp = require("escape-string-regexp"); -const astUtils = require("./utils/ast-utils"); - -const CHAR_LIMIT = 40; - -//------------------------------------------------------------------------------ -// Rule Definition -//------------------------------------------------------------------------------ - -/** @type {import('../shared/types').Rule} */ -module.exports = { - meta: { - type: "suggestion", - - docs: { - description: "Disallow specified warning terms in comments", - recommended: false, - url: "https://eslint.org/docs/latest/rules/no-warning-comments" - }, - - schema: [ - { - type: "object", - properties: { - terms: { - type: "array", - items: { - type: "string" - } - }, - location: { - enum: ["start", "anywhere"] - }, - decoration: { - type: "array", - items: { - type: "string", - pattern: "^\\S$" - }, - minItems: 1, - uniqueItems: true - } - }, - additionalProperties: false - } - ], - - messages: { - unexpectedComment: "Unexpected '{{matchedTerm}}' comment: '{{comment}}'." - } - }, - - create(context) { - const sourceCode = context.sourceCode, - configuration = context.options[0] || {}, - warningTerms = configuration.terms || ["todo", "fixme", "xxx"], - location = configuration.location || "start", - decoration = [...configuration.decoration || []].join(""), - selfConfigRegEx = /\bno-warning-comments\b/u; - - /** - * Convert a warning term into a RegExp which will match a comment containing that whole word in the specified - * location ("start" or "anywhere"). If the term starts or ends with non word characters, then the match will not - * require word boundaries on that side. - * @param {string} term A term to convert to a RegExp - * @returns {RegExp} The term converted to a RegExp - */ - function convertToRegExp(term) { - const escaped = escapeRegExp(term); - const escapedDecoration = escapeRegExp(decoration); - - /* - * When matching at the start, ignore leading whitespace, and - * there's no need to worry about word boundaries. - * - * These expressions for the prefix and suffix are designed as follows: - * ^ handles any terms at the beginning of a comment. - * e.g. terms ["TODO"] matches `//TODO something` - * $ handles any terms at the end of a comment - * e.g. terms ["TODO"] matches `// something TODO` - * \b handles terms preceded/followed by word boundary - * e.g. terms: ["!FIX", "FIX!"] matches `// FIX!something` or `// something!FIX` - * terms: ["FIX"] matches `// FIX!` or `// !FIX`, but not `// fixed or affix` - * - * For location start: - * [\s]* handles optional leading spaces - * e.g. terms ["TODO"] matches `// TODO something` - * [\s\*]* (where "\*" is the escaped string of decoration) - * handles optional leading spaces or decoration characters (for "start" location only) - * e.g. terms ["TODO"] matches `/**** TODO something ... ` - */ - const wordBoundary = "\\b"; - - let prefix = ""; - - if (location === "start") { - prefix = `^[\\s${escapedDecoration}]*`; - } else if (/^\w/u.test(term)) { - prefix = wordBoundary; - } - - const suffix = /\w$/u.test(term) ? wordBoundary : ""; - const flags = "iu"; // Case-insensitive with Unicode case folding. - - /* - * For location "start", the typical regex is: - * /^[\s]*ESCAPED_TERM\b/iu. - * Or if decoration characters are specified (e.g. "*"), then any of - * those characters may appear in any order at the start: - * /^[\s\*]*ESCAPED_TERM\b/iu. - * - * For location "anywhere" the typical regex is - * /\bESCAPED_TERM\b/iu - * - * If it starts or ends with non-word character, the prefix and suffix are empty, respectively. - */ - return new RegExp(`${prefix}${escaped}${suffix}`, flags); - } - - const warningRegExps = warningTerms.map(convertToRegExp); - - /** - * Checks the specified comment for matches of the configured warning terms and returns the matches. - * @param {string} comment The comment which is checked. - * @returns {Array} All matched warning terms for this comment. - */ - function commentContainsWarningTerm(comment) { - const matches = []; - - warningRegExps.forEach((regex, index) => { - if (regex.test(comment)) { - matches.push(warningTerms[index]); - } - }); - - return matches; - } - - /** - * Checks the specified node for matching warning comments and reports them. - * @param {ASTNode} node The AST node being checked. - * @returns {void} undefined. - */ - function checkComment(node) { - const comment = node.value; - - if ( - astUtils.isDirectiveComment(node) && - selfConfigRegEx.test(comment) - ) { - return; - } - - const matches = commentContainsWarningTerm(comment); - - matches.forEach(matchedTerm => { - let commentToDisplay = ""; - let truncated = false; - - for (const c of comment.trim().split(/\s+/u)) { - const tmp = commentToDisplay ? `${commentToDisplay} ${c}` : c; - - if (tmp.length <= CHAR_LIMIT) { - commentToDisplay = tmp; - } else { - truncated = true; - break; - } - } - - context.report({ - node, - messageId: "unexpectedComment", - data: { - matchedTerm, - comment: `${commentToDisplay}${ - truncated ? "..." : "" - }` - } - }); - }); - } - - return { - Program() { - const comments = sourceCode.getAllComments(); - - comments - .filter(token => token.type !== "Shebang") - .forEach(checkComment); - } - }; - } -}; diff --git a/tools/eslint/node_modules/eslint/lib/rules/no-whitespace-before-property.js b/tools/eslint/node_modules/eslint/lib/rules/no-whitespace-before-property.js deleted file mode 100644 index 94a166e6adea70..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/rules/no-whitespace-before-property.js +++ /dev/null @@ -1,116 +0,0 @@ -/** - * @fileoverview Rule to disallow whitespace before properties - * @author Kai Cataldo - * @deprecated in ESLint v8.53.0 - */ -"use strict"; - -//------------------------------------------------------------------------------ -// Requirements -//------------------------------------------------------------------------------ - -const astUtils = require("./utils/ast-utils"); - -//------------------------------------------------------------------------------ -// Rule Definition -//------------------------------------------------------------------------------ - -/** @type {import('../shared/types').Rule} */ -module.exports = { - meta: { - deprecated: true, - replacedBy: [], - type: "layout", - - docs: { - description: "Disallow whitespace before properties", - recommended: false, - url: "https://eslint.org/docs/latest/rules/no-whitespace-before-property" - }, - - fixable: "whitespace", - schema: [], - - messages: { - unexpectedWhitespace: "Unexpected whitespace before property {{propName}}." - } - }, - - create(context) { - const sourceCode = context.sourceCode; - - //-------------------------------------------------------------------------- - // Helpers - //-------------------------------------------------------------------------- - - /** - * Reports whitespace before property token - * @param {ASTNode} node the node to report in the event of an error - * @param {Token} leftToken the left token - * @param {Token} rightToken the right token - * @returns {void} - * @private - */ - function reportError(node, leftToken, rightToken) { - context.report({ - node, - messageId: "unexpectedWhitespace", - data: { - propName: sourceCode.getText(node.property) - }, - fix(fixer) { - let replacementText = ""; - - if (!node.computed && !node.optional && astUtils.isDecimalInteger(node.object)) { - - /* - * If the object is a number literal, fixing it to something like 5.toString() would cause a SyntaxError. - * Don't fix this case. - */ - return null; - } - - // Don't fix if comments exist. - if (sourceCode.commentsExistBetween(leftToken, rightToken)) { - return null; - } - - if (node.optional) { - replacementText = "?."; - } else if (!node.computed) { - replacementText = "."; - } - - return fixer.replaceTextRange([leftToken.range[1], rightToken.range[0]], replacementText); - } - }); - } - - //-------------------------------------------------------------------------- - // Public - //-------------------------------------------------------------------------- - - return { - MemberExpression(node) { - let rightToken; - let leftToken; - - if (!astUtils.isTokenOnSameLine(node.object, node.property)) { - return; - } - - if (node.computed) { - rightToken = sourceCode.getTokenBefore(node.property, astUtils.isOpeningBracketToken); - leftToken = sourceCode.getTokenBefore(rightToken, node.optional ? 1 : 0); - } else { - rightToken = sourceCode.getFirstToken(node.property); - leftToken = sourceCode.getTokenBefore(rightToken, 1); - } - - if (sourceCode.isSpaceBetweenTokens(leftToken, rightToken)) { - reportError(node, leftToken, rightToken); - } - } - }; - } -}; diff --git a/tools/eslint/node_modules/eslint/lib/rules/no-with.js b/tools/eslint/node_modules/eslint/lib/rules/no-with.js deleted file mode 100644 index 0fb2c4519b4558..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/rules/no-with.js +++ /dev/null @@ -1,39 +0,0 @@ -/** - * @fileoverview Rule to flag use of with statement - * @author Nicholas C. Zakas - */ - -"use strict"; - -//------------------------------------------------------------------------------ -// Rule Definition -//------------------------------------------------------------------------------ - -/** @type {import('../shared/types').Rule} */ -module.exports = { - meta: { - type: "suggestion", - - docs: { - description: "Disallow `with` statements", - recommended: true, - url: "https://eslint.org/docs/latest/rules/no-with" - }, - - schema: [], - - messages: { - unexpectedWith: "Unexpected use of 'with' statement." - } - }, - - create(context) { - - return { - WithStatement(node) { - context.report({ node, messageId: "unexpectedWith" }); - } - }; - - } -}; diff --git a/tools/eslint/node_modules/eslint/lib/rules/nonblock-statement-body-position.js b/tools/eslint/node_modules/eslint/lib/rules/nonblock-statement-body-position.js deleted file mode 100644 index 811b32b08212d4..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/rules/nonblock-statement-body-position.js +++ /dev/null @@ -1,127 +0,0 @@ -/** - * @fileoverview enforce the location of single-line statements - * @author Teddy Katz - * @deprecated in ESLint v8.53.0 - */ -"use strict"; - -//------------------------------------------------------------------------------ -// Rule Definition -//------------------------------------------------------------------------------ - -const POSITION_SCHEMA = { enum: ["beside", "below", "any"] }; - -/** @type {import('../shared/types').Rule} */ -module.exports = { - meta: { - deprecated: true, - replacedBy: [], - type: "layout", - - docs: { - description: "Enforce the location of single-line statements", - recommended: false, - url: "https://eslint.org/docs/latest/rules/nonblock-statement-body-position" - }, - - fixable: "whitespace", - - schema: [ - POSITION_SCHEMA, - { - properties: { - overrides: { - properties: { - if: POSITION_SCHEMA, - else: POSITION_SCHEMA, - while: POSITION_SCHEMA, - do: POSITION_SCHEMA, - for: POSITION_SCHEMA - }, - additionalProperties: false - } - }, - additionalProperties: false - } - ], - - messages: { - expectNoLinebreak: "Expected no linebreak before this statement.", - expectLinebreak: "Expected a linebreak before this statement." - } - }, - - create(context) { - const sourceCode = context.sourceCode; - - //---------------------------------------------------------------------- - // Helpers - //---------------------------------------------------------------------- - - /** - * Gets the applicable preference for a particular keyword - * @param {string} keywordName The name of a keyword, e.g. 'if' - * @returns {string} The applicable option for the keyword, e.g. 'beside' - */ - function getOption(keywordName) { - return context.options[1] && context.options[1].overrides && context.options[1].overrides[keywordName] || - context.options[0] || - "beside"; - } - - /** - * Validates the location of a single-line statement - * @param {ASTNode} node The single-line statement - * @param {string} keywordName The applicable keyword name for the single-line statement - * @returns {void} - */ - function validateStatement(node, keywordName) { - const option = getOption(keywordName); - - if (node.type === "BlockStatement" || option === "any") { - return; - } - - const tokenBefore = sourceCode.getTokenBefore(node); - - if (tokenBefore.loc.end.line === node.loc.start.line && option === "below") { - context.report({ - node, - messageId: "expectLinebreak", - fix: fixer => fixer.insertTextBefore(node, "\n") - }); - } else if (tokenBefore.loc.end.line !== node.loc.start.line && option === "beside") { - context.report({ - node, - messageId: "expectNoLinebreak", - fix(fixer) { - if (sourceCode.getText().slice(tokenBefore.range[1], node.range[0]).trim()) { - return null; - } - return fixer.replaceTextRange([tokenBefore.range[1], node.range[0]], " "); - } - }); - } - } - - //---------------------------------------------------------------------- - // Public - //---------------------------------------------------------------------- - - return { - IfStatement(node) { - validateStatement(node.consequent, "if"); - - // Check the `else` node, but don't check 'else if' statements. - if (node.alternate && node.alternate.type !== "IfStatement") { - validateStatement(node.alternate, "else"); - } - }, - WhileStatement: node => validateStatement(node.body, "while"), - DoWhileStatement: node => validateStatement(node.body, "do"), - ForStatement: node => validateStatement(node.body, "for"), - ForInStatement: node => validateStatement(node.body, "for"), - ForOfStatement: node => validateStatement(node.body, "for") - }; - } -}; diff --git a/tools/eslint/node_modules/eslint/lib/rules/object-curly-newline.js b/tools/eslint/node_modules/eslint/lib/rules/object-curly-newline.js deleted file mode 100644 index 176694b6a0774e..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/rules/object-curly-newline.js +++ /dev/null @@ -1,324 +0,0 @@ -/** - * @fileoverview Rule to require or disallow line breaks inside braces. - * @author Toru Nagashima - * @deprecated in ESLint v8.53.0 - */ - -"use strict"; - -//------------------------------------------------------------------------------ -// Requirements -//------------------------------------------------------------------------------ - -const astUtils = require("./utils/ast-utils"); - -//------------------------------------------------------------------------------ -// Helpers -//------------------------------------------------------------------------------ - -// Schema objects. -const OPTION_VALUE = { - oneOf: [ - { - enum: ["always", "never"] - }, - { - type: "object", - properties: { - multiline: { - type: "boolean" - }, - minProperties: { - type: "integer", - minimum: 0 - }, - consistent: { - type: "boolean" - } - }, - additionalProperties: false, - minProperties: 1 - } - ] -}; - -/** - * Normalizes a given option value. - * @param {string|Object|undefined} value An option value to parse. - * @returns {{multiline: boolean, minProperties: number, consistent: boolean}} Normalized option object. - */ -function normalizeOptionValue(value) { - let multiline = false; - let minProperties = Number.POSITIVE_INFINITY; - let consistent = false; - - if (value) { - if (value === "always") { - minProperties = 0; - } else if (value === "never") { - minProperties = Number.POSITIVE_INFINITY; - } else { - multiline = Boolean(value.multiline); - minProperties = value.minProperties || Number.POSITIVE_INFINITY; - consistent = Boolean(value.consistent); - } - } else { - consistent = true; - } - - return { multiline, minProperties, consistent }; -} - -/** - * Checks if a value is an object. - * @param {any} value The value to check - * @returns {boolean} `true` if the value is an object, otherwise `false` - */ -function isObject(value) { - return typeof value === "object" && value !== null; -} - -/** - * Checks if an option is a node-specific option - * @param {any} option The option to check - * @returns {boolean} `true` if the option is node-specific, otherwise `false` - */ -function isNodeSpecificOption(option) { - return isObject(option) || typeof option === "string"; -} - -/** - * Normalizes a given option value. - * @param {string|Object|undefined} options An option value to parse. - * @returns {{ - * ObjectExpression: {multiline: boolean, minProperties: number, consistent: boolean}, - * ObjectPattern: {multiline: boolean, minProperties: number, consistent: boolean}, - * ImportDeclaration: {multiline: boolean, minProperties: number, consistent: boolean}, - * ExportNamedDeclaration : {multiline: boolean, minProperties: number, consistent: boolean} - * }} Normalized option object. - */ -function normalizeOptions(options) { - if (isObject(options) && Object.values(options).some(isNodeSpecificOption)) { - return { - ObjectExpression: normalizeOptionValue(options.ObjectExpression), - ObjectPattern: normalizeOptionValue(options.ObjectPattern), - ImportDeclaration: normalizeOptionValue(options.ImportDeclaration), - ExportNamedDeclaration: normalizeOptionValue(options.ExportDeclaration) - }; - } - - const value = normalizeOptionValue(options); - - return { ObjectExpression: value, ObjectPattern: value, ImportDeclaration: value, ExportNamedDeclaration: value }; -} - -/** - * Determines if ObjectExpression, ObjectPattern, ImportDeclaration or ExportNamedDeclaration - * node needs to be checked for missing line breaks - * @param {ASTNode} node Node under inspection - * @param {Object} options option specific to node type - * @param {Token} first First object property - * @param {Token} last Last object property - * @returns {boolean} `true` if node needs to be checked for missing line breaks - */ -function areLineBreaksRequired(node, options, first, last) { - let objectProperties; - - if (node.type === "ObjectExpression" || node.type === "ObjectPattern") { - objectProperties = node.properties; - } else { - - // is ImportDeclaration or ExportNamedDeclaration - objectProperties = node.specifiers - .filter(s => s.type === "ImportSpecifier" || s.type === "ExportSpecifier"); - } - - return objectProperties.length >= options.minProperties || - ( - options.multiline && - objectProperties.length > 0 && - first.loc.start.line !== last.loc.end.line - ); -} - -//------------------------------------------------------------------------------ -// Rule Definition -//------------------------------------------------------------------------------ - -/** @type {import('../shared/types').Rule} */ -module.exports = { - meta: { - deprecated: true, - replacedBy: [], - type: "layout", - - docs: { - description: "Enforce consistent line breaks after opening and before closing braces", - recommended: false, - url: "https://eslint.org/docs/latest/rules/object-curly-newline" - }, - - fixable: "whitespace", - - schema: [ - { - oneOf: [ - OPTION_VALUE, - { - type: "object", - properties: { - ObjectExpression: OPTION_VALUE, - ObjectPattern: OPTION_VALUE, - ImportDeclaration: OPTION_VALUE, - ExportDeclaration: OPTION_VALUE - }, - additionalProperties: false, - minProperties: 1 - } - ] - } - ], - - messages: { - unexpectedLinebreakBeforeClosingBrace: "Unexpected line break before this closing brace.", - unexpectedLinebreakAfterOpeningBrace: "Unexpected line break after this opening brace.", - expectedLinebreakBeforeClosingBrace: "Expected a line break before this closing brace.", - expectedLinebreakAfterOpeningBrace: "Expected a line break after this opening brace." - } - }, - - create(context) { - const sourceCode = context.sourceCode; - const normalizedOptions = normalizeOptions(context.options[0]); - - /** - * Reports a given node if it violated this rule. - * @param {ASTNode} node A node to check. This is an ObjectExpression, ObjectPattern, ImportDeclaration or ExportNamedDeclaration node. - * @returns {void} - */ - function check(node) { - const options = normalizedOptions[node.type]; - - if ( - (node.type === "ImportDeclaration" && - !node.specifiers.some(specifier => specifier.type === "ImportSpecifier")) || - (node.type === "ExportNamedDeclaration" && - !node.specifiers.some(specifier => specifier.type === "ExportSpecifier")) - ) { - return; - } - - const openBrace = sourceCode.getFirstToken(node, token => token.value === "{"); - - let closeBrace; - - if (node.typeAnnotation) { - closeBrace = sourceCode.getTokenBefore(node.typeAnnotation); - } else { - closeBrace = sourceCode.getLastToken(node, token => token.value === "}"); - } - - let first = sourceCode.getTokenAfter(openBrace, { includeComments: true }); - let last = sourceCode.getTokenBefore(closeBrace, { includeComments: true }); - - const needsLineBreaks = areLineBreaksRequired(node, options, first, last); - - const hasCommentsFirstToken = astUtils.isCommentToken(first); - const hasCommentsLastToken = astUtils.isCommentToken(last); - - /* - * Use tokens or comments to check multiline or not. - * But use only tokens to check whether line breaks are needed. - * This allows: - * var obj = { // eslint-disable-line foo - * a: 1 - * } - */ - first = sourceCode.getTokenAfter(openBrace); - last = sourceCode.getTokenBefore(closeBrace); - - if (needsLineBreaks) { - if (astUtils.isTokenOnSameLine(openBrace, first)) { - context.report({ - messageId: "expectedLinebreakAfterOpeningBrace", - node, - loc: openBrace.loc, - fix(fixer) { - if (hasCommentsFirstToken) { - return null; - } - - return fixer.insertTextAfter(openBrace, "\n"); - } - }); - } - if (astUtils.isTokenOnSameLine(last, closeBrace)) { - context.report({ - messageId: "expectedLinebreakBeforeClosingBrace", - node, - loc: closeBrace.loc, - fix(fixer) { - if (hasCommentsLastToken) { - return null; - } - - return fixer.insertTextBefore(closeBrace, "\n"); - } - }); - } - } else { - const consistent = options.consistent; - const hasLineBreakBetweenOpenBraceAndFirst = !astUtils.isTokenOnSameLine(openBrace, first); - const hasLineBreakBetweenCloseBraceAndLast = !astUtils.isTokenOnSameLine(last, closeBrace); - - if ( - (!consistent && hasLineBreakBetweenOpenBraceAndFirst) || - (consistent && hasLineBreakBetweenOpenBraceAndFirst && !hasLineBreakBetweenCloseBraceAndLast) - ) { - context.report({ - messageId: "unexpectedLinebreakAfterOpeningBrace", - node, - loc: openBrace.loc, - fix(fixer) { - if (hasCommentsFirstToken) { - return null; - } - - return fixer.removeRange([ - openBrace.range[1], - first.range[0] - ]); - } - }); - } - if ( - (!consistent && hasLineBreakBetweenCloseBraceAndLast) || - (consistent && !hasLineBreakBetweenOpenBraceAndFirst && hasLineBreakBetweenCloseBraceAndLast) - ) { - context.report({ - messageId: "unexpectedLinebreakBeforeClosingBrace", - node, - loc: closeBrace.loc, - fix(fixer) { - if (hasCommentsLastToken) { - return null; - } - - return fixer.removeRange([ - last.range[1], - closeBrace.range[0] - ]); - } - }); - } - } - } - - return { - ObjectExpression: check, - ObjectPattern: check, - ImportDeclaration: check, - ExportNamedDeclaration: check - }; - } -}; diff --git a/tools/eslint/node_modules/eslint/lib/rules/object-curly-spacing.js b/tools/eslint/node_modules/eslint/lib/rules/object-curly-spacing.js deleted file mode 100644 index 6cb0b0f931359c..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/rules/object-curly-spacing.js +++ /dev/null @@ -1,311 +0,0 @@ -/** - * @fileoverview Disallows or enforces spaces inside of object literals. - * @author Jamund Ferguson - * @deprecated in ESLint v8.53.0 - */ -"use strict"; - -const astUtils = require("./utils/ast-utils"); - -//------------------------------------------------------------------------------ -// Rule Definition -//------------------------------------------------------------------------------ - -/** @type {import('../shared/types').Rule} */ -module.exports = { - meta: { - deprecated: true, - replacedBy: [], - type: "layout", - - docs: { - description: "Enforce consistent spacing inside braces", - recommended: false, - url: "https://eslint.org/docs/latest/rules/object-curly-spacing" - }, - - fixable: "whitespace", - - schema: [ - { - enum: ["always", "never"] - }, - { - type: "object", - properties: { - arraysInObjects: { - type: "boolean" - }, - objectsInObjects: { - type: "boolean" - } - }, - additionalProperties: false - } - ], - - messages: { - requireSpaceBefore: "A space is required before '{{token}}'.", - requireSpaceAfter: "A space is required after '{{token}}'.", - unexpectedSpaceBefore: "There should be no space before '{{token}}'.", - unexpectedSpaceAfter: "There should be no space after '{{token}}'." - } - }, - - create(context) { - const spaced = context.options[0] === "always", - sourceCode = context.sourceCode; - - /** - * Determines whether an option is set, relative to the spacing option. - * If spaced is "always", then check whether option is set to false. - * If spaced is "never", then check whether option is set to true. - * @param {Object} option The option to exclude. - * @returns {boolean} Whether or not the property is excluded. - */ - function isOptionSet(option) { - return context.options[1] ? context.options[1][option] === !spaced : false; - } - - const options = { - spaced, - arraysInObjectsException: isOptionSet("arraysInObjects"), - objectsInObjectsException: isOptionSet("objectsInObjects") - }; - - //-------------------------------------------------------------------------- - // Helpers - //-------------------------------------------------------------------------- - - /** - * Reports that there shouldn't be a space after the first token - * @param {ASTNode} node The node to report in the event of an error. - * @param {Token} token The token to use for the report. - * @returns {void} - */ - function reportNoBeginningSpace(node, token) { - const nextToken = context.sourceCode.getTokenAfter(token, { includeComments: true }); - - context.report({ - node, - loc: { start: token.loc.end, end: nextToken.loc.start }, - messageId: "unexpectedSpaceAfter", - data: { - token: token.value - }, - fix(fixer) { - return fixer.removeRange([token.range[1], nextToken.range[0]]); - } - }); - } - - /** - * Reports that there shouldn't be a space before the last token - * @param {ASTNode} node The node to report in the event of an error. - * @param {Token} token The token to use for the report. - * @returns {void} - */ - function reportNoEndingSpace(node, token) { - const previousToken = context.sourceCode.getTokenBefore(token, { includeComments: true }); - - context.report({ - node, - loc: { start: previousToken.loc.end, end: token.loc.start }, - messageId: "unexpectedSpaceBefore", - data: { - token: token.value - }, - fix(fixer) { - return fixer.removeRange([previousToken.range[1], token.range[0]]); - } - }); - } - - /** - * Reports that there should be a space after the first token - * @param {ASTNode} node The node to report in the event of an error. - * @param {Token} token The token to use for the report. - * @returns {void} - */ - function reportRequiredBeginningSpace(node, token) { - context.report({ - node, - loc: token.loc, - messageId: "requireSpaceAfter", - data: { - token: token.value - }, - fix(fixer) { - return fixer.insertTextAfter(token, " "); - } - }); - } - - /** - * Reports that there should be a space before the last token - * @param {ASTNode} node The node to report in the event of an error. - * @param {Token} token The token to use for the report. - * @returns {void} - */ - function reportRequiredEndingSpace(node, token) { - context.report({ - node, - loc: token.loc, - messageId: "requireSpaceBefore", - data: { - token: token.value - }, - fix(fixer) { - return fixer.insertTextBefore(token, " "); - } - }); - } - - /** - * Determines if spacing in curly braces is valid. - * @param {ASTNode} node The AST node to check. - * @param {Token} first The first token to check (should be the opening brace) - * @param {Token} second The second token to check (should be first after the opening brace) - * @param {Token} penultimate The penultimate token to check (should be last before closing brace) - * @param {Token} last The last token to check (should be closing brace) - * @returns {void} - */ - function validateBraceSpacing(node, first, second, penultimate, last) { - if (astUtils.isTokenOnSameLine(first, second)) { - const firstSpaced = sourceCode.isSpaceBetweenTokens(first, second); - - if (options.spaced && !firstSpaced) { - reportRequiredBeginningSpace(node, first); - } - if (!options.spaced && firstSpaced && second.type !== "Line") { - reportNoBeginningSpace(node, first); - } - } - - if (astUtils.isTokenOnSameLine(penultimate, last)) { - const shouldCheckPenultimate = ( - options.arraysInObjectsException && astUtils.isClosingBracketToken(penultimate) || - options.objectsInObjectsException && astUtils.isClosingBraceToken(penultimate) - ); - const penultimateType = shouldCheckPenultimate && sourceCode.getNodeByRangeIndex(penultimate.range[0]).type; - - const closingCurlyBraceMustBeSpaced = ( - options.arraysInObjectsException && penultimateType === "ArrayExpression" || - options.objectsInObjectsException && (penultimateType === "ObjectExpression" || penultimateType === "ObjectPattern") - ) ? !options.spaced : options.spaced; - - const lastSpaced = sourceCode.isSpaceBetweenTokens(penultimate, last); - - if (closingCurlyBraceMustBeSpaced && !lastSpaced) { - reportRequiredEndingSpace(node, last); - } - if (!closingCurlyBraceMustBeSpaced && lastSpaced) { - reportNoEndingSpace(node, last); - } - } - } - - /** - * Gets '}' token of an object node. - * - * Because the last token of object patterns might be a type annotation, - * this traverses tokens preceded by the last property, then returns the - * first '}' token. - * @param {ASTNode} node The node to get. This node is an - * ObjectExpression or an ObjectPattern. And this node has one or - * more properties. - * @returns {Token} '}' token. - */ - function getClosingBraceOfObject(node) { - const lastProperty = node.properties.at(-1); - - return sourceCode.getTokenAfter(lastProperty, astUtils.isClosingBraceToken); - } - - /** - * Reports a given object node if spacing in curly braces is invalid. - * @param {ASTNode} node An ObjectExpression or ObjectPattern node to check. - * @returns {void} - */ - function checkForObject(node) { - if (node.properties.length === 0) { - return; - } - - const first = sourceCode.getFirstToken(node), - last = getClosingBraceOfObject(node), - second = sourceCode.getTokenAfter(first, { includeComments: true }), - penultimate = sourceCode.getTokenBefore(last, { includeComments: true }); - - validateBraceSpacing(node, first, second, penultimate, last); - } - - /** - * Reports a given import node if spacing in curly braces is invalid. - * @param {ASTNode} node An ImportDeclaration node to check. - * @returns {void} - */ - function checkForImport(node) { - if (node.specifiers.length === 0) { - return; - } - - let firstSpecifier = node.specifiers[0]; - const lastSpecifier = node.specifiers.at(-1); - - if (lastSpecifier.type !== "ImportSpecifier") { - return; - } - if (firstSpecifier.type !== "ImportSpecifier") { - firstSpecifier = node.specifiers[1]; - } - - const first = sourceCode.getTokenBefore(firstSpecifier), - last = sourceCode.getTokenAfter(lastSpecifier, astUtils.isNotCommaToken), - second = sourceCode.getTokenAfter(first, { includeComments: true }), - penultimate = sourceCode.getTokenBefore(last, { includeComments: true }); - - validateBraceSpacing(node, first, second, penultimate, last); - } - - /** - * Reports a given export node if spacing in curly braces is invalid. - * @param {ASTNode} node An ExportNamedDeclaration node to check. - * @returns {void} - */ - function checkForExport(node) { - if (node.specifiers.length === 0) { - return; - } - - const firstSpecifier = node.specifiers[0], - lastSpecifier = node.specifiers.at(-1), - first = sourceCode.getTokenBefore(firstSpecifier), - last = sourceCode.getTokenAfter(lastSpecifier, astUtils.isNotCommaToken), - second = sourceCode.getTokenAfter(first, { includeComments: true }), - penultimate = sourceCode.getTokenBefore(last, { includeComments: true }); - - validateBraceSpacing(node, first, second, penultimate, last); - } - - //-------------------------------------------------------------------------- - // Public - //-------------------------------------------------------------------------- - - return { - - // var {x} = y; - ObjectPattern: checkForObject, - - // var y = {x: 'y'} - ObjectExpression: checkForObject, - - // import {y} from 'x'; - ImportDeclaration: checkForImport, - - // export {name} from 'yo'; - ExportNamedDeclaration: checkForExport - }; - - } -}; diff --git a/tools/eslint/node_modules/eslint/lib/rules/object-property-newline.js b/tools/eslint/node_modules/eslint/lib/rules/object-property-newline.js deleted file mode 100644 index 8a08676cfa1480..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/rules/object-property-newline.js +++ /dev/null @@ -1,102 +0,0 @@ -/** - * @fileoverview Rule to enforce placing object properties on separate lines. - * @author Vitor Balocco - * @deprecated in ESLint v8.53.0 - */ - -"use strict"; - -//------------------------------------------------------------------------------ -// Rule Definition -//------------------------------------------------------------------------------ - -/** @type {import('../shared/types').Rule} */ -module.exports = { - meta: { - deprecated: true, - replacedBy: [], - type: "layout", - - docs: { - description: "Enforce placing object properties on separate lines", - recommended: false, - url: "https://eslint.org/docs/latest/rules/object-property-newline" - }, - - schema: [ - { - type: "object", - properties: { - allowAllPropertiesOnSameLine: { - type: "boolean", - default: false - }, - allowMultiplePropertiesPerLine: { // Deprecated - type: "boolean", - default: false - } - }, - additionalProperties: false - } - ], - - fixable: "whitespace", - - messages: { - propertiesOnNewlineAll: "Object properties must go on a new line if they aren't all on the same line.", - propertiesOnNewline: "Object properties must go on a new line." - } - }, - - create(context) { - const allowSameLine = context.options[0] && ( - (context.options[0].allowAllPropertiesOnSameLine || context.options[0].allowMultiplePropertiesPerLine /* Deprecated */) - ); - const messageId = allowSameLine - ? "propertiesOnNewlineAll" - : "propertiesOnNewline"; - - const sourceCode = context.sourceCode; - - return { - ObjectExpression(node) { - if (allowSameLine) { - if (node.properties.length > 1) { - const firstTokenOfFirstProperty = sourceCode.getFirstToken(node.properties[0]); - const lastTokenOfLastProperty = sourceCode.getLastToken(node.properties.at(-1)); - - if (firstTokenOfFirstProperty.loc.end.line === lastTokenOfLastProperty.loc.start.line) { - - // All keys and values are on the same line - return; - } - } - } - - for (let i = 1; i < node.properties.length; i++) { - const lastTokenOfPreviousProperty = sourceCode.getLastToken(node.properties[i - 1]); - const firstTokenOfCurrentProperty = sourceCode.getFirstToken(node.properties[i]); - - if (lastTokenOfPreviousProperty.loc.end.line === firstTokenOfCurrentProperty.loc.start.line) { - context.report({ - node, - loc: firstTokenOfCurrentProperty.loc, - messageId, - fix(fixer) { - const comma = sourceCode.getTokenBefore(firstTokenOfCurrentProperty); - const rangeAfterComma = [comma.range[1], firstTokenOfCurrentProperty.range[0]]; - - // Don't perform a fix if there are any comments between the comma and the next property. - if (sourceCode.text.slice(rangeAfterComma[0], rangeAfterComma[1]).trim()) { - return null; - } - - return fixer.replaceTextRange(rangeAfterComma, "\n"); - } - }); - } - } - } - }; - } -}; diff --git a/tools/eslint/node_modules/eslint/lib/rules/object-shorthand.js b/tools/eslint/node_modules/eslint/lib/rules/object-shorthand.js deleted file mode 100644 index f035bbe581fe1a..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/rules/object-shorthand.js +++ /dev/null @@ -1,521 +0,0 @@ -/** - * @fileoverview Rule to enforce concise object methods and properties. - * @author Jamund Ferguson - */ - -"use strict"; - -const OPTIONS = { - always: "always", - never: "never", - methods: "methods", - properties: "properties", - consistent: "consistent", - consistentAsNeeded: "consistent-as-needed" -}; - -//------------------------------------------------------------------------------ -// Requirements -//------------------------------------------------------------------------------ -const astUtils = require("./utils/ast-utils"); - -//------------------------------------------------------------------------------ -// Rule Definition -//------------------------------------------------------------------------------ -/** @type {import('../shared/types').Rule} */ -module.exports = { - meta: { - type: "suggestion", - - docs: { - description: "Require or disallow method and property shorthand syntax for object literals", - recommended: false, - url: "https://eslint.org/docs/latest/rules/object-shorthand" - }, - - fixable: "code", - - schema: { - anyOf: [ - { - type: "array", - items: [ - { - enum: ["always", "methods", "properties", "never", "consistent", "consistent-as-needed"] - } - ], - minItems: 0, - maxItems: 1 - }, - { - type: "array", - items: [ - { - enum: ["always", "methods", "properties"] - }, - { - type: "object", - properties: { - avoidQuotes: { - type: "boolean" - } - }, - additionalProperties: false - } - ], - minItems: 0, - maxItems: 2 - }, - { - type: "array", - items: [ - { - enum: ["always", "methods"] - }, - { - type: "object", - properties: { - ignoreConstructors: { - type: "boolean" - }, - methodsIgnorePattern: { - type: "string" - }, - avoidQuotes: { - type: "boolean" - }, - avoidExplicitReturnArrows: { - type: "boolean" - } - }, - additionalProperties: false - } - ], - minItems: 0, - maxItems: 2 - } - ] - }, - - messages: { - expectedAllPropertiesShorthanded: "Expected shorthand for all properties.", - expectedLiteralMethodLongform: "Expected longform method syntax for string literal keys.", - expectedPropertyShorthand: "Expected property shorthand.", - expectedPropertyLongform: "Expected longform property syntax.", - expectedMethodShorthand: "Expected method shorthand.", - expectedMethodLongform: "Expected longform method syntax.", - unexpectedMix: "Unexpected mix of shorthand and non-shorthand properties." - } - }, - - create(context) { - const APPLY = context.options[0] || OPTIONS.always; - const APPLY_TO_METHODS = APPLY === OPTIONS.methods || APPLY === OPTIONS.always; - const APPLY_TO_PROPS = APPLY === OPTIONS.properties || APPLY === OPTIONS.always; - const APPLY_NEVER = APPLY === OPTIONS.never; - const APPLY_CONSISTENT = APPLY === OPTIONS.consistent; - const APPLY_CONSISTENT_AS_NEEDED = APPLY === OPTIONS.consistentAsNeeded; - - const PARAMS = context.options[1] || {}; - const IGNORE_CONSTRUCTORS = PARAMS.ignoreConstructors; - const METHODS_IGNORE_PATTERN = PARAMS.methodsIgnorePattern - ? new RegExp(PARAMS.methodsIgnorePattern, "u") - : null; - const AVOID_QUOTES = PARAMS.avoidQuotes; - const AVOID_EXPLICIT_RETURN_ARROWS = !!PARAMS.avoidExplicitReturnArrows; - const sourceCode = context.sourceCode; - - //-------------------------------------------------------------------------- - // Helpers - //-------------------------------------------------------------------------- - - const CTOR_PREFIX_REGEX = /[^_$0-9]/u; - - /** - * Determines if the first character of the name is a capital letter. - * @param {string} name The name of the node to evaluate. - * @returns {boolean} True if the first character of the property name is a capital letter, false if not. - * @private - */ - function isConstructor(name) { - const match = CTOR_PREFIX_REGEX.exec(name); - - // Not a constructor if name has no characters apart from '_', '$' and digits e.g. '_', '$$', '_8' - if (!match) { - return false; - } - - const firstChar = name.charAt(match.index); - - return firstChar === firstChar.toUpperCase(); - } - - /** - * Determines if the property can have a shorthand form. - * @param {ASTNode} property Property AST node - * @returns {boolean} True if the property can have a shorthand form - * @private - */ - function canHaveShorthand(property) { - return (property.kind !== "set" && property.kind !== "get" && property.type !== "SpreadElement" && property.type !== "SpreadProperty" && property.type !== "ExperimentalSpreadProperty"); - } - - /** - * Checks whether a node is a string literal. - * @param {ASTNode} node Any AST node. - * @returns {boolean} `true` if it is a string literal. - */ - function isStringLiteral(node) { - return node.type === "Literal" && typeof node.value === "string"; - } - - /** - * Determines if the property is a shorthand or not. - * @param {ASTNode} property Property AST node - * @returns {boolean} True if the property is considered shorthand, false if not. - * @private - */ - function isShorthand(property) { - - // property.method is true when `{a(){}}`. - return (property.shorthand || property.method); - } - - /** - * Determines if the property's key and method or value are named equally. - * @param {ASTNode} property Property AST node - * @returns {boolean} True if the key and value are named equally, false if not. - * @private - */ - function isRedundant(property) { - const value = property.value; - - if (value.type === "FunctionExpression") { - return !value.id; // Only anonymous should be shorthand method. - } - if (value.type === "Identifier") { - return astUtils.getStaticPropertyName(property) === value.name; - } - - return false; - } - - /** - * Ensures that an object's properties are consistently shorthand, or not shorthand at all. - * @param {ASTNode} node Property AST node - * @param {boolean} checkRedundancy Whether to check longform redundancy - * @returns {void} - */ - function checkConsistency(node, checkRedundancy) { - - // We are excluding getters/setters and spread properties as they are considered neither longform nor shorthand. - const properties = node.properties.filter(canHaveShorthand); - - // Do we still have properties left after filtering the getters and setters? - if (properties.length > 0) { - const shorthandProperties = properties.filter(isShorthand); - - /* - * If we do not have an equal number of longform properties as - * shorthand properties, we are using the annotations inconsistently - */ - if (shorthandProperties.length !== properties.length) { - - // We have at least 1 shorthand property - if (shorthandProperties.length > 0) { - context.report({ node, messageId: "unexpectedMix" }); - } else if (checkRedundancy) { - - /* - * If all properties of the object contain a method or value with a name matching it's key, - * all the keys are redundant. - */ - const canAlwaysUseShorthand = properties.every(isRedundant); - - if (canAlwaysUseShorthand) { - context.report({ node, messageId: "expectedAllPropertiesShorthanded" }); - } - } - } - } - } - - /** - * Fixes a FunctionExpression node by making it into a shorthand property. - * @param {SourceCodeFixer} fixer The fixer object - * @param {ASTNode} node A `Property` node that has a `FunctionExpression` or `ArrowFunctionExpression` as its value - * @returns {Object} A fix for this node - */ - function makeFunctionShorthand(fixer, node) { - const firstKeyToken = node.computed - ? sourceCode.getFirstToken(node, astUtils.isOpeningBracketToken) - : sourceCode.getFirstToken(node.key); - const lastKeyToken = node.computed - ? sourceCode.getFirstTokenBetween(node.key, node.value, astUtils.isClosingBracketToken) - : sourceCode.getLastToken(node.key); - const keyText = sourceCode.text.slice(firstKeyToken.range[0], lastKeyToken.range[1]); - let keyPrefix = ""; - - // key: /* */ () => {} - if (sourceCode.commentsExistBetween(lastKeyToken, node.value)) { - return null; - } - - if (node.value.async) { - keyPrefix += "async "; - } - if (node.value.generator) { - keyPrefix += "*"; - } - - const fixRange = [firstKeyToken.range[0], node.range[1]]; - const methodPrefix = keyPrefix + keyText; - - if (node.value.type === "FunctionExpression") { - const functionToken = sourceCode.getTokens(node.value).find(token => token.type === "Keyword" && token.value === "function"); - const tokenBeforeParams = node.value.generator ? sourceCode.getTokenAfter(functionToken) : functionToken; - - return fixer.replaceTextRange( - fixRange, - methodPrefix + sourceCode.text.slice(tokenBeforeParams.range[1], node.value.range[1]) - ); - } - - const arrowToken = sourceCode.getTokenBefore(node.value.body, astUtils.isArrowToken); - const fnBody = sourceCode.text.slice(arrowToken.range[1], node.value.range[1]); - - // First token should not be `async` - const firstValueToken = sourceCode.getFirstToken(node.value, { - skip: node.value.async ? 1 : 0 - }); - - const sliceStart = firstValueToken.range[0]; - const sliceEnd = sourceCode.getTokenBefore(arrowToken).range[1]; - const shouldAddParens = node.value.params.length === 1 && node.value.params[0].range[0] === sliceStart; - - const oldParamText = sourceCode.text.slice(sliceStart, sliceEnd); - const newParamText = shouldAddParens ? `(${oldParamText})` : oldParamText; - - return fixer.replaceTextRange( - fixRange, - methodPrefix + newParamText + fnBody - ); - } - - /** - * Fixes a FunctionExpression node by making it into a longform property. - * @param {SourceCodeFixer} fixer The fixer object - * @param {ASTNode} node A `Property` node that has a `FunctionExpression` as its value - * @returns {Object} A fix for this node - */ - function makeFunctionLongform(fixer, node) { - const firstKeyToken = node.computed ? sourceCode.getTokens(node).find(token => token.value === "[") : sourceCode.getFirstToken(node.key); - const lastKeyToken = node.computed ? sourceCode.getTokensBetween(node.key, node.value).find(token => token.value === "]") : sourceCode.getLastToken(node.key); - const keyText = sourceCode.text.slice(firstKeyToken.range[0], lastKeyToken.range[1]); - let functionHeader = "function"; - - if (node.value.async) { - functionHeader = `async ${functionHeader}`; - } - if (node.value.generator) { - functionHeader = `${functionHeader}*`; - } - - return fixer.replaceTextRange([node.range[0], lastKeyToken.range[1]], `${keyText}: ${functionHeader}`); - } - - /* - * To determine whether a given arrow function has a lexical identifier (`this`, `arguments`, `super`, or `new.target`), - * create a stack of functions that define these identifiers (i.e. all functions except arrow functions) as the AST is - * traversed. Whenever a new function is encountered, create a new entry on the stack (corresponding to a different lexical - * scope of `this`), and whenever a function is exited, pop that entry off the stack. When an arrow function is entered, - * keep a reference to it on the current stack entry, and remove that reference when the arrow function is exited. - * When a lexical identifier is encountered, mark all the arrow functions on the current stack entry by adding them - * to an `arrowsWithLexicalIdentifiers` set. Any arrow function in that set will not be reported by this rule, - * because converting it into a method would change the value of one of the lexical identifiers. - */ - const lexicalScopeStack = []; - const arrowsWithLexicalIdentifiers = new WeakSet(); - const argumentsIdentifiers = new WeakSet(); - - /** - * Enters a function. This creates a new lexical identifier scope, so a new Set of arrow functions is pushed onto the stack. - * Also, this marks all `arguments` identifiers so that they can be detected later. - * @param {ASTNode} node The node representing the function. - * @returns {void} - */ - function enterFunction(node) { - lexicalScopeStack.unshift(new Set()); - sourceCode.getScope(node).variables.filter(variable => variable.name === "arguments").forEach(variable => { - variable.references.map(ref => ref.identifier).forEach(identifier => argumentsIdentifiers.add(identifier)); - }); - } - - /** - * Exits a function. This pops the current set of arrow functions off the lexical scope stack. - * @returns {void} - */ - function exitFunction() { - lexicalScopeStack.shift(); - } - - /** - * Marks the current function as having a lexical keyword. This implies that all arrow functions - * in the current lexical scope contain a reference to this lexical keyword. - * @returns {void} - */ - function reportLexicalIdentifier() { - lexicalScopeStack[0].forEach(arrowFunction => arrowsWithLexicalIdentifiers.add(arrowFunction)); - } - - //-------------------------------------------------------------------------- - // Public - //-------------------------------------------------------------------------- - - return { - Program: enterFunction, - FunctionDeclaration: enterFunction, - FunctionExpression: enterFunction, - "Program:exit": exitFunction, - "FunctionDeclaration:exit": exitFunction, - "FunctionExpression:exit": exitFunction, - - ArrowFunctionExpression(node) { - lexicalScopeStack[0].add(node); - }, - "ArrowFunctionExpression:exit"(node) { - lexicalScopeStack[0].delete(node); - }, - - ThisExpression: reportLexicalIdentifier, - Super: reportLexicalIdentifier, - MetaProperty(node) { - if (node.meta.name === "new" && node.property.name === "target") { - reportLexicalIdentifier(); - } - }, - Identifier(node) { - if (argumentsIdentifiers.has(node)) { - reportLexicalIdentifier(); - } - }, - - ObjectExpression(node) { - if (APPLY_CONSISTENT) { - checkConsistency(node, false); - } else if (APPLY_CONSISTENT_AS_NEEDED) { - checkConsistency(node, true); - } - }, - - "Property:exit"(node) { - const isConciseProperty = node.method || node.shorthand; - - // Ignore destructuring assignment - if (node.parent.type === "ObjectPattern") { - return; - } - - // getters and setters are ignored - if (node.kind === "get" || node.kind === "set") { - return; - } - - // only computed methods can fail the following checks - if (node.computed && node.value.type !== "FunctionExpression" && node.value.type !== "ArrowFunctionExpression") { - return; - } - - //-------------------------------------------------------------- - // Checks for property/method shorthand. - if (isConciseProperty) { - if (node.method && (APPLY_NEVER || AVOID_QUOTES && isStringLiteral(node.key))) { - const messageId = APPLY_NEVER ? "expectedMethodLongform" : "expectedLiteralMethodLongform"; - - // { x() {} } should be written as { x: function() {} } - context.report({ - node, - messageId, - fix: fixer => makeFunctionLongform(fixer, node) - }); - } else if (APPLY_NEVER) { - - // { x } should be written as { x: x } - context.report({ - node, - messageId: "expectedPropertyLongform", - fix: fixer => fixer.insertTextAfter(node.key, `: ${node.key.name}`) - }); - } - } else if (APPLY_TO_METHODS && !node.value.id && (node.value.type === "FunctionExpression" || node.value.type === "ArrowFunctionExpression")) { - if (IGNORE_CONSTRUCTORS && node.key.type === "Identifier" && isConstructor(node.key.name)) { - return; - } - - if (METHODS_IGNORE_PATTERN) { - const propertyName = astUtils.getStaticPropertyName(node); - - if (propertyName !== null && METHODS_IGNORE_PATTERN.test(propertyName)) { - return; - } - } - - if (AVOID_QUOTES && isStringLiteral(node.key)) { - return; - } - - // {[x]: function(){}} should be written as {[x]() {}} - if (node.value.type === "FunctionExpression" || - node.value.type === "ArrowFunctionExpression" && - node.value.body.type === "BlockStatement" && - AVOID_EXPLICIT_RETURN_ARROWS && - !arrowsWithLexicalIdentifiers.has(node.value) - ) { - context.report({ - node, - messageId: "expectedMethodShorthand", - fix: fixer => makeFunctionShorthand(fixer, node) - }); - } - } else if (node.value.type === "Identifier" && node.key.name === node.value.name && APPLY_TO_PROPS) { - - // {x: x} should be written as {x} - context.report({ - node, - messageId: "expectedPropertyShorthand", - fix(fixer) { - - // x: /* */ x - // x: (/* */ x) - if (sourceCode.getCommentsInside(node).length > 0) { - return null; - } - - return fixer.replaceText(node, node.value.name); - } - }); - } else if (node.value.type === "Identifier" && node.key.type === "Literal" && node.key.value === node.value.name && APPLY_TO_PROPS) { - if (AVOID_QUOTES) { - return; - } - - // {"x": x} should be written as {x} - context.report({ - node, - messageId: "expectedPropertyShorthand", - fix(fixer) { - - // "x": /* */ x - // "x": (/* */ x) - if (sourceCode.getCommentsInside(node).length > 0) { - return null; - } - - return fixer.replaceText(node, node.value.name); - } - }); - } - } - }; - } -}; diff --git a/tools/eslint/node_modules/eslint/lib/rules/one-var-declaration-per-line.js b/tools/eslint/node_modules/eslint/lib/rules/one-var-declaration-per-line.js deleted file mode 100644 index 340eac169320ea..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/rules/one-var-declaration-per-line.js +++ /dev/null @@ -1,95 +0,0 @@ -/** - * @fileoverview Rule to check multiple var declarations per line - * @author Alberto Rodrรญguez - * @deprecated in ESLint v8.53.0 - */ -"use strict"; - -//------------------------------------------------------------------------------ -// Rule Definition -//------------------------------------------------------------------------------ - -/** @type {import('../shared/types').Rule} */ -module.exports = { - meta: { - deprecated: true, - replacedBy: [], - type: "suggestion", - - docs: { - description: "Require or disallow newlines around variable declarations", - recommended: false, - url: "https://eslint.org/docs/latest/rules/one-var-declaration-per-line" - }, - - schema: [ - { - enum: ["always", "initializations"] - } - ], - - fixable: "whitespace", - - messages: { - expectVarOnNewline: "Expected variable declaration to be on a new line." - } - }, - - create(context) { - - const always = context.options[0] === "always"; - - //-------------------------------------------------------------------------- - // Helpers - //-------------------------------------------------------------------------- - - - /** - * Determine if provided keyword is a variant of for specifiers - * @private - * @param {string} keyword keyword to test - * @returns {boolean} True if `keyword` is a variant of for specifier - */ - function isForTypeSpecifier(keyword) { - return keyword === "ForStatement" || keyword === "ForInStatement" || keyword === "ForOfStatement"; - } - - /** - * Checks newlines around variable declarations. - * @private - * @param {ASTNode} node `VariableDeclaration` node to test - * @returns {void} - */ - function checkForNewLine(node) { - if (isForTypeSpecifier(node.parent.type)) { - return; - } - - const declarations = node.declarations; - let prev; - - declarations.forEach(current => { - if (prev && prev.loc.end.line === current.loc.start.line) { - if (always || prev.init || current.init) { - context.report({ - node, - messageId: "expectVarOnNewline", - loc: current.loc, - fix: fixer => fixer.insertTextBefore(current, "\n") - }); - } - } - prev = current; - }); - } - - //-------------------------------------------------------------------------- - // Public - //-------------------------------------------------------------------------- - - return { - VariableDeclaration: checkForNewLine - }; - - } -}; diff --git a/tools/eslint/node_modules/eslint/lib/rules/one-var.js b/tools/eslint/node_modules/eslint/lib/rules/one-var.js deleted file mode 100644 index ba461a407cac03..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/rules/one-var.js +++ /dev/null @@ -1,567 +0,0 @@ -/** - * @fileoverview A rule to control the use of single variable declarations. - * @author Ian Christian Myers - */ - -"use strict"; - -//------------------------------------------------------------------------------ -// Requirements -//------------------------------------------------------------------------------ - -const astUtils = require("./utils/ast-utils"); - -//------------------------------------------------------------------------------ -// Helpers -//------------------------------------------------------------------------------ - -/** - * Determines whether the given node is in a statement list. - * @param {ASTNode} node node to check - * @returns {boolean} `true` if the given node is in a statement list - */ -function isInStatementList(node) { - return astUtils.STATEMENT_LIST_PARENTS.has(node.parent.type); -} - -//------------------------------------------------------------------------------ -// Rule Definition -//------------------------------------------------------------------------------ - -/** @type {import('../shared/types').Rule} */ -module.exports = { - meta: { - type: "suggestion", - - docs: { - description: "Enforce variables to be declared either together or separately in functions", - recommended: false, - url: "https://eslint.org/docs/latest/rules/one-var" - }, - - fixable: "code", - - schema: [ - { - oneOf: [ - { - enum: ["always", "never", "consecutive"] - }, - { - type: "object", - properties: { - separateRequires: { - type: "boolean" - }, - var: { - enum: ["always", "never", "consecutive"] - }, - let: { - enum: ["always", "never", "consecutive"] - }, - const: { - enum: ["always", "never", "consecutive"] - } - }, - additionalProperties: false - }, - { - type: "object", - properties: { - initialized: { - enum: ["always", "never", "consecutive"] - }, - uninitialized: { - enum: ["always", "never", "consecutive"] - } - }, - additionalProperties: false - } - ] - } - ], - - messages: { - combineUninitialized: "Combine this with the previous '{{type}}' statement with uninitialized variables.", - combineInitialized: "Combine this with the previous '{{type}}' statement with initialized variables.", - splitUninitialized: "Split uninitialized '{{type}}' declarations into multiple statements.", - splitInitialized: "Split initialized '{{type}}' declarations into multiple statements.", - splitRequires: "Split requires to be separated into a single block.", - combine: "Combine this with the previous '{{type}}' statement.", - split: "Split '{{type}}' declarations into multiple statements." - } - }, - - create(context) { - const MODE_ALWAYS = "always"; - const MODE_NEVER = "never"; - const MODE_CONSECUTIVE = "consecutive"; - const mode = context.options[0] || MODE_ALWAYS; - - const options = {}; - - if (typeof mode === "string") { // simple options configuration with just a string - options.var = { uninitialized: mode, initialized: mode }; - options.let = { uninitialized: mode, initialized: mode }; - options.const = { uninitialized: mode, initialized: mode }; - } else if (typeof mode === "object") { // options configuration is an object - options.separateRequires = !!mode.separateRequires; - options.var = { uninitialized: mode.var, initialized: mode.var }; - options.let = { uninitialized: mode.let, initialized: mode.let }; - options.const = { uninitialized: mode.const, initialized: mode.const }; - if (Object.hasOwn(mode, "uninitialized")) { - options.var.uninitialized = mode.uninitialized; - options.let.uninitialized = mode.uninitialized; - options.const.uninitialized = mode.uninitialized; - } - if (Object.hasOwn(mode, "initialized")) { - options.var.initialized = mode.initialized; - options.let.initialized = mode.initialized; - options.const.initialized = mode.initialized; - } - } - - const sourceCode = context.sourceCode; - - //-------------------------------------------------------------------------- - // Helpers - //-------------------------------------------------------------------------- - - const functionStack = []; - const blockStack = []; - - /** - * Increments the blockStack counter. - * @returns {void} - * @private - */ - function startBlock() { - blockStack.push({ - let: { initialized: false, uninitialized: false }, - const: { initialized: false, uninitialized: false } - }); - } - - /** - * Increments the functionStack counter. - * @returns {void} - * @private - */ - function startFunction() { - functionStack.push({ initialized: false, uninitialized: false }); - startBlock(); - } - - /** - * Decrements the blockStack counter. - * @returns {void} - * @private - */ - function endBlock() { - blockStack.pop(); - } - - /** - * Decrements the functionStack counter. - * @returns {void} - * @private - */ - function endFunction() { - functionStack.pop(); - endBlock(); - } - - /** - * Check if a variable declaration is a require. - * @param {ASTNode} decl variable declaration Node - * @returns {bool} if decl is a require, return true; else return false. - * @private - */ - function isRequire(decl) { - return decl.init && decl.init.type === "CallExpression" && decl.init.callee.name === "require"; - } - - /** - * Records whether initialized/uninitialized/required variables are defined in current scope. - * @param {string} statementType node.kind, one of: "var", "let", or "const" - * @param {ASTNode[]} declarations List of declarations - * @param {Object} currentScope The scope being investigated - * @returns {void} - * @private - */ - function recordTypes(statementType, declarations, currentScope) { - for (let i = 0; i < declarations.length; i++) { - if (declarations[i].init === null) { - if (options[statementType] && options[statementType].uninitialized === MODE_ALWAYS) { - currentScope.uninitialized = true; - } - } else { - if (options[statementType] && options[statementType].initialized === MODE_ALWAYS) { - if (options.separateRequires && isRequire(declarations[i])) { - currentScope.required = true; - } else { - currentScope.initialized = true; - } - } - } - } - } - - /** - * Determines the current scope (function or block) - * @param {string} statementType node.kind, one of: "var", "let", or "const" - * @returns {Object} The scope associated with statementType - */ - function getCurrentScope(statementType) { - let currentScope; - - if (statementType === "var") { - currentScope = functionStack.at(-1); - } else if (statementType === "let") { - currentScope = blockStack.at(-1).let; - } else if (statementType === "const") { - currentScope = blockStack.at(-1).const; - } - return currentScope; - } - - /** - * Counts the number of initialized and uninitialized declarations in a list of declarations - * @param {ASTNode[]} declarations List of declarations - * @returns {Object} Counts of 'uninitialized' and 'initialized' declarations - * @private - */ - function countDeclarations(declarations) { - const counts = { uninitialized: 0, initialized: 0 }; - - for (let i = 0; i < declarations.length; i++) { - if (declarations[i].init === null) { - counts.uninitialized++; - } else { - counts.initialized++; - } - } - return counts; - } - - /** - * Determines if there is more than one var statement in the current scope. - * @param {string} statementType node.kind, one of: "var", "let", or "const" - * @param {ASTNode[]} declarations List of declarations - * @returns {boolean} Returns true if it is the first var declaration, false if not. - * @private - */ - function hasOnlyOneStatement(statementType, declarations) { - - const declarationCounts = countDeclarations(declarations); - const currentOptions = options[statementType] || {}; - const currentScope = getCurrentScope(statementType); - const hasRequires = declarations.some(isRequire); - - if (currentOptions.uninitialized === MODE_ALWAYS && currentOptions.initialized === MODE_ALWAYS) { - if (currentScope.uninitialized || currentScope.initialized) { - if (!hasRequires) { - return false; - } - } - } - - if (declarationCounts.uninitialized > 0) { - if (currentOptions.uninitialized === MODE_ALWAYS && currentScope.uninitialized) { - return false; - } - } - if (declarationCounts.initialized > 0) { - if (currentOptions.initialized === MODE_ALWAYS && currentScope.initialized) { - if (!hasRequires) { - return false; - } - } - } - if (currentScope.required && hasRequires) { - return false; - } - recordTypes(statementType, declarations, currentScope); - return true; - } - - /** - * Fixer to join VariableDeclaration's into a single declaration - * @param {VariableDeclarator[]} declarations The `VariableDeclaration` to join - * @returns {Function} The fixer function - */ - function joinDeclarations(declarations) { - const declaration = declarations[0]; - const body = Array.isArray(declaration.parent.parent.body) ? declaration.parent.parent.body : []; - const currentIndex = body.findIndex(node => node.range[0] === declaration.parent.range[0]); - const previousNode = body[currentIndex - 1]; - - return fixer => { - const type = sourceCode.getTokenBefore(declaration); - const prevSemi = sourceCode.getTokenBefore(type); - const res = []; - - if (previousNode && previousNode.kind === sourceCode.getText(type)) { - if (prevSemi.value === ";") { - res.push(fixer.replaceText(prevSemi, ",")); - } else { - res.push(fixer.insertTextAfter(prevSemi, ",")); - } - res.push(fixer.replaceText(type, "")); - } - - return res; - }; - } - - /** - * Fixer to split a VariableDeclaration into individual declarations - * @param {VariableDeclaration} declaration The `VariableDeclaration` to split - * @returns {Function|null} The fixer function - */ - function splitDeclarations(declaration) { - const { parent } = declaration; - - // don't autofix code such as: if (foo) var x, y; - if (!isInStatementList(parent.type === "ExportNamedDeclaration" ? parent : declaration)) { - return null; - } - - return fixer => declaration.declarations.map(declarator => { - const tokenAfterDeclarator = sourceCode.getTokenAfter(declarator); - - if (tokenAfterDeclarator === null) { - return null; - } - - const afterComma = sourceCode.getTokenAfter(tokenAfterDeclarator, { includeComments: true }); - - if (tokenAfterDeclarator.value !== ",") { - return null; - } - - const exportPlacement = declaration.parent.type === "ExportNamedDeclaration" ? "export " : ""; - - /* - * `var x,y` - * tokenAfterDeclarator ^^ afterComma - */ - if (afterComma.range[0] === tokenAfterDeclarator.range[1]) { - return fixer.replaceText(tokenAfterDeclarator, `; ${exportPlacement}${declaration.kind} `); - } - - /* - * `var x, - * tokenAfterDeclarator ^ - * y` - * ^ afterComma - */ - if ( - afterComma.loc.start.line > tokenAfterDeclarator.loc.end.line || - afterComma.type === "Line" || - afterComma.type === "Block" - ) { - let lastComment = afterComma; - - while (lastComment.type === "Line" || lastComment.type === "Block") { - lastComment = sourceCode.getTokenAfter(lastComment, { includeComments: true }); - } - - return fixer.replaceTextRange( - [tokenAfterDeclarator.range[0], lastComment.range[0]], - `;${sourceCode.text.slice(tokenAfterDeclarator.range[1], lastComment.range[0])}${exportPlacement}${declaration.kind} ` - ); - } - - return fixer.replaceText(tokenAfterDeclarator, `; ${exportPlacement}${declaration.kind}`); - }).filter(x => x); - } - - /** - * Checks a given VariableDeclaration node for errors. - * @param {ASTNode} node The VariableDeclaration node to check - * @returns {void} - * @private - */ - function checkVariableDeclaration(node) { - const parent = node.parent; - const type = node.kind; - - if (!options[type]) { - return; - } - - const declarations = node.declarations; - const declarationCounts = countDeclarations(declarations); - const mixedRequires = declarations.some(isRequire) && !declarations.every(isRequire); - - if (options[type].initialized === MODE_ALWAYS) { - if (options.separateRequires && mixedRequires) { - context.report({ - node, - messageId: "splitRequires" - }); - } - } - - // consecutive - const nodeIndex = (parent.body && parent.body.length > 0 && parent.body.indexOf(node)) || 0; - - if (nodeIndex > 0) { - const previousNode = parent.body[nodeIndex - 1]; - const isPreviousNodeDeclaration = previousNode.type === "VariableDeclaration"; - const declarationsWithPrevious = declarations.concat(previousNode.declarations || []); - - if ( - isPreviousNodeDeclaration && - previousNode.kind === type && - !(declarationsWithPrevious.some(isRequire) && !declarationsWithPrevious.every(isRequire)) - ) { - const previousDeclCounts = countDeclarations(previousNode.declarations); - - if (options[type].initialized === MODE_CONSECUTIVE && options[type].uninitialized === MODE_CONSECUTIVE) { - context.report({ - node, - messageId: "combine", - data: { - type - }, - fix: joinDeclarations(declarations) - }); - } else if (options[type].initialized === MODE_CONSECUTIVE && declarationCounts.initialized > 0 && previousDeclCounts.initialized > 0) { - context.report({ - node, - messageId: "combineInitialized", - data: { - type - }, - fix: joinDeclarations(declarations) - }); - } else if (options[type].uninitialized === MODE_CONSECUTIVE && - declarationCounts.uninitialized > 0 && - previousDeclCounts.uninitialized > 0) { - context.report({ - node, - messageId: "combineUninitialized", - data: { - type - }, - fix: joinDeclarations(declarations) - }); - } - } - } - - // always - if (!hasOnlyOneStatement(type, declarations)) { - if (options[type].initialized === MODE_ALWAYS && options[type].uninitialized === MODE_ALWAYS) { - context.report({ - node, - messageId: "combine", - data: { - type - }, - fix: joinDeclarations(declarations) - }); - } else { - if (options[type].initialized === MODE_ALWAYS && declarationCounts.initialized > 0) { - context.report({ - node, - messageId: "combineInitialized", - data: { - type - }, - fix: joinDeclarations(declarations) - }); - } - if (options[type].uninitialized === MODE_ALWAYS && declarationCounts.uninitialized > 0) { - if (node.parent.left === node && (node.parent.type === "ForInStatement" || node.parent.type === "ForOfStatement")) { - return; - } - context.report({ - node, - messageId: "combineUninitialized", - data: { - type - }, - fix: joinDeclarations(declarations) - }); - } - } - } - - // never - if (parent.type !== "ForStatement" || parent.init !== node) { - const totalDeclarations = declarationCounts.uninitialized + declarationCounts.initialized; - - if (totalDeclarations > 1) { - if (options[type].initialized === MODE_NEVER && options[type].uninitialized === MODE_NEVER) { - - // both initialized and uninitialized - context.report({ - node, - messageId: "split", - data: { - type - }, - fix: splitDeclarations(node) - }); - } else if (options[type].initialized === MODE_NEVER && declarationCounts.initialized > 0) { - - // initialized - context.report({ - node, - messageId: "splitInitialized", - data: { - type - }, - fix: splitDeclarations(node) - }); - } else if (options[type].uninitialized === MODE_NEVER && declarationCounts.uninitialized > 0) { - - // uninitialized - context.report({ - node, - messageId: "splitUninitialized", - data: { - type - }, - fix: splitDeclarations(node) - }); - } - } - } - } - - //-------------------------------------------------------------------------- - // Public API - //-------------------------------------------------------------------------- - - return { - Program: startFunction, - FunctionDeclaration: startFunction, - FunctionExpression: startFunction, - ArrowFunctionExpression: startFunction, - StaticBlock: startFunction, // StaticBlock creates a new scope for `var` variables - - BlockStatement: startBlock, - ForStatement: startBlock, - ForInStatement: startBlock, - ForOfStatement: startBlock, - SwitchStatement: startBlock, - VariableDeclaration: checkVariableDeclaration, - "ForStatement:exit": endBlock, - "ForOfStatement:exit": endBlock, - "ForInStatement:exit": endBlock, - "SwitchStatement:exit": endBlock, - "BlockStatement:exit": endBlock, - - "Program:exit": endFunction, - "FunctionDeclaration:exit": endFunction, - "FunctionExpression:exit": endFunction, - "ArrowFunctionExpression:exit": endFunction, - "StaticBlock:exit": endFunction - }; - - } -}; diff --git a/tools/eslint/node_modules/eslint/lib/rules/operator-assignment.js b/tools/eslint/node_modules/eslint/lib/rules/operator-assignment.js deleted file mode 100644 index f71d73be75da71..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/rules/operator-assignment.js +++ /dev/null @@ -1,209 +0,0 @@ -/** - * @fileoverview Rule to replace assignment expressions with operator assignment - * @author Brandon Mills - */ -"use strict"; - -//------------------------------------------------------------------------------ -// Requirements -//------------------------------------------------------------------------------ - -const astUtils = require("./utils/ast-utils"); - -//------------------------------------------------------------------------------ -// Helpers -//------------------------------------------------------------------------------ - -/** - * Checks whether an operator is commutative and has an operator assignment - * shorthand form. - * @param {string} operator Operator to check. - * @returns {boolean} True if the operator is commutative and has a - * shorthand form. - */ -function isCommutativeOperatorWithShorthand(operator) { - return ["*", "&", "^", "|"].includes(operator); -} - -/** - * Checks whether an operator is not commutative and has an operator assignment - * shorthand form. - * @param {string} operator Operator to check. - * @returns {boolean} True if the operator is not commutative and has - * a shorthand form. - */ -function isNonCommutativeOperatorWithShorthand(operator) { - return ["+", "-", "/", "%", "<<", ">>", ">>>", "**"].includes(operator); -} - -//------------------------------------------------------------------------------ -// Rule Definition -//------------------------------------------------------------------------------ - -/** - * Determines if the left side of a node can be safely fixed (i.e. if it activates the same getters/setters and) - * toString calls regardless of whether assignment shorthand is used) - * @param {ASTNode} node The node on the left side of the expression - * @returns {boolean} `true` if the node can be fixed - */ -function canBeFixed(node) { - return ( - node.type === "Identifier" || - ( - node.type === "MemberExpression" && - (node.object.type === "Identifier" || node.object.type === "ThisExpression") && - (!node.computed || node.property.type === "Literal") - ) - ); -} - -/** @type {import('../shared/types').Rule} */ -module.exports = { - meta: { - type: "suggestion", - - docs: { - description: "Require or disallow assignment operator shorthand where possible", - recommended: false, - url: "https://eslint.org/docs/latest/rules/operator-assignment" - }, - - schema: [ - { - enum: ["always", "never"] - } - ], - - fixable: "code", - messages: { - replaced: "Assignment (=) can be replaced with operator assignment ({{operator}}).", - unexpected: "Unexpected operator assignment ({{operator}}) shorthand." - } - }, - - create(context) { - - const sourceCode = context.sourceCode; - - /** - * Returns the operator token of an AssignmentExpression or BinaryExpression - * @param {ASTNode} node An AssignmentExpression or BinaryExpression node - * @returns {Token} The operator token in the node - */ - function getOperatorToken(node) { - return sourceCode.getFirstTokenBetween(node.left, node.right, token => token.value === node.operator); - } - - /** - * Ensures that an assignment uses the shorthand form where possible. - * @param {ASTNode} node An AssignmentExpression node. - * @returns {void} - */ - function verify(node) { - if (node.operator !== "=" || node.right.type !== "BinaryExpression") { - return; - } - - const left = node.left; - const expr = node.right; - const operator = expr.operator; - - if (isCommutativeOperatorWithShorthand(operator) || isNonCommutativeOperatorWithShorthand(operator)) { - const replacementOperator = `${operator}=`; - - if (astUtils.isSameReference(left, expr.left, true)) { - context.report({ - node, - messageId: "replaced", - data: { operator: replacementOperator }, - fix(fixer) { - if (canBeFixed(left) && canBeFixed(expr.left)) { - const equalsToken = getOperatorToken(node); - const operatorToken = getOperatorToken(expr); - const leftText = sourceCode.getText().slice(node.range[0], equalsToken.range[0]); - const rightText = sourceCode.getText().slice(operatorToken.range[1], node.right.range[1]); - - // Check for comments that would be removed. - if (sourceCode.commentsExistBetween(equalsToken, operatorToken)) { - return null; - } - - return fixer.replaceText(node, `${leftText}${replacementOperator}${rightText}`); - } - return null; - } - }); - } else if (astUtils.isSameReference(left, expr.right, true) && isCommutativeOperatorWithShorthand(operator)) { - - /* - * This case can't be fixed safely. - * If `a` and `b` both have custom valueOf() behavior, then fixing `a = b * a` to `a *= b` would - * change the execution order of the valueOf() functions. - */ - context.report({ - node, - messageId: "replaced", - data: { operator: replacementOperator } - }); - } - } - } - - /** - * Warns if an assignment expression uses operator assignment shorthand. - * @param {ASTNode} node An AssignmentExpression node. - * @returns {void} - */ - function prohibit(node) { - if (node.operator !== "=" && !astUtils.isLogicalAssignmentOperator(node.operator)) { - context.report({ - node, - messageId: "unexpected", - data: { operator: node.operator }, - fix(fixer) { - if (canBeFixed(node.left)) { - const firstToken = sourceCode.getFirstToken(node); - const operatorToken = getOperatorToken(node); - const leftText = sourceCode.getText().slice(node.range[0], operatorToken.range[0]); - const newOperator = node.operator.slice(0, -1); - let rightText; - - // Check for comments that would be duplicated. - if (sourceCode.commentsExistBetween(firstToken, operatorToken)) { - return null; - } - - // If this change would modify precedence (e.g. `foo *= bar + 1` => `foo = foo * (bar + 1)`), parenthesize the right side. - if ( - astUtils.getPrecedence(node.right) <= astUtils.getPrecedence({ type: "BinaryExpression", operator: newOperator }) && - !astUtils.isParenthesised(sourceCode, node.right) - ) { - rightText = `${sourceCode.text.slice(operatorToken.range[1], node.right.range[0])}(${sourceCode.getText(node.right)})`; - } else { - const tokenAfterOperator = sourceCode.getTokenAfter(operatorToken, { includeComments: true }); - let rightTextPrefix = ""; - - if ( - operatorToken.range[1] === tokenAfterOperator.range[0] && - !astUtils.canTokensBeAdjacent({ type: "Punctuator", value: newOperator }, tokenAfterOperator) - ) { - rightTextPrefix = " "; // foo+=+bar -> foo= foo+ +bar - } - - rightText = `${rightTextPrefix}${sourceCode.text.slice(operatorToken.range[1], node.range[1])}`; - } - - return fixer.replaceText(node, `${leftText}= ${leftText}${newOperator}${rightText}`); - } - return null; - } - }); - } - } - - return { - AssignmentExpression: context.options[0] !== "never" ? verify : prohibit - }; - - } -}; diff --git a/tools/eslint/node_modules/eslint/lib/rules/operator-linebreak.js b/tools/eslint/node_modules/eslint/lib/rules/operator-linebreak.js deleted file mode 100644 index 3065e66be12873..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/rules/operator-linebreak.js +++ /dev/null @@ -1,253 +0,0 @@ -/** - * @fileoverview Operator linebreak - enforces operator linebreak style of two types: after and before - * @author Benoรฎt Zugmeyer - * @deprecated in ESLint v8.53.0 - */ - -"use strict"; - -//------------------------------------------------------------------------------ -// Requirements -//------------------------------------------------------------------------------ - -const astUtils = require("./utils/ast-utils"); - -//------------------------------------------------------------------------------ -// Rule Definition -//------------------------------------------------------------------------------ - -/** @type {import('../shared/types').Rule} */ -module.exports = { - meta: { - deprecated: true, - replacedBy: [], - type: "layout", - - docs: { - description: "Enforce consistent linebreak style for operators", - recommended: false, - url: "https://eslint.org/docs/latest/rules/operator-linebreak" - }, - - schema: [ - { - enum: ["after", "before", "none", null] - }, - { - type: "object", - properties: { - overrides: { - type: "object", - additionalProperties: { - enum: ["after", "before", "none", "ignore"] - } - } - }, - additionalProperties: false - } - ], - - fixable: "code", - - messages: { - operatorAtBeginning: "'{{operator}}' should be placed at the beginning of the line.", - operatorAtEnd: "'{{operator}}' should be placed at the end of the line.", - badLinebreak: "Bad line breaking before and after '{{operator}}'.", - noLinebreak: "There should be no line break before or after '{{operator}}'." - } - }, - - create(context) { - - const usedDefaultGlobal = !context.options[0]; - const globalStyle = context.options[0] || "after"; - const options = context.options[1] || {}; - const styleOverrides = options.overrides ? Object.assign({}, options.overrides) : {}; - - if (usedDefaultGlobal && !styleOverrides["?"]) { - styleOverrides["?"] = "before"; - } - - if (usedDefaultGlobal && !styleOverrides[":"]) { - styleOverrides[":"] = "before"; - } - - const sourceCode = context.sourceCode; - - //-------------------------------------------------------------------------- - // Helpers - //-------------------------------------------------------------------------- - - /** - * Gets a fixer function to fix rule issues - * @param {Token} operatorToken The operator token of an expression - * @param {string} desiredStyle The style for the rule. One of 'before', 'after', 'none' - * @returns {Function} A fixer function - */ - function getFixer(operatorToken, desiredStyle) { - return fixer => { - const tokenBefore = sourceCode.getTokenBefore(operatorToken); - const tokenAfter = sourceCode.getTokenAfter(operatorToken); - const textBefore = sourceCode.text.slice(tokenBefore.range[1], operatorToken.range[0]); - const textAfter = sourceCode.text.slice(operatorToken.range[1], tokenAfter.range[0]); - const hasLinebreakBefore = !astUtils.isTokenOnSameLine(tokenBefore, operatorToken); - const hasLinebreakAfter = !astUtils.isTokenOnSameLine(operatorToken, tokenAfter); - let newTextBefore, newTextAfter; - - if (hasLinebreakBefore !== hasLinebreakAfter && desiredStyle !== "none") { - - // If there is a comment before and after the operator, don't do a fix. - if (sourceCode.getTokenBefore(operatorToken, { includeComments: true }) !== tokenBefore && - sourceCode.getTokenAfter(operatorToken, { includeComments: true }) !== tokenAfter) { - - return null; - } - - /* - * If there is only one linebreak and it's on the wrong side of the operator, swap the text before and after the operator. - * foo && - * bar - * would get fixed to - * foo - * && bar - */ - newTextBefore = textAfter; - newTextAfter = textBefore; - } else { - const LINEBREAK_REGEX = astUtils.createGlobalLinebreakMatcher(); - - // Otherwise, if no linebreak is desired and no comments interfere, replace the linebreaks with empty strings. - newTextBefore = desiredStyle === "before" || textBefore.trim() ? textBefore : textBefore.replace(LINEBREAK_REGEX, ""); - newTextAfter = desiredStyle === "after" || textAfter.trim() ? textAfter : textAfter.replace(LINEBREAK_REGEX, ""); - - // If there was no change (due to interfering comments), don't output a fix. - if (newTextBefore === textBefore && newTextAfter === textAfter) { - return null; - } - } - - if (newTextAfter === "" && tokenAfter.type === "Punctuator" && "+-".includes(operatorToken.value) && tokenAfter.value === operatorToken.value) { - - // To avoid accidentally creating a ++ or -- operator, insert a space if the operator is a +/- and the following token is a unary +/-. - newTextAfter += " "; - } - - return fixer.replaceTextRange([tokenBefore.range[1], tokenAfter.range[0]], newTextBefore + operatorToken.value + newTextAfter); - }; - } - - /** - * Checks the operator placement - * @param {ASTNode} node The node to check - * @param {ASTNode} rightSide The node that comes after the operator in `node` - * @param {string} operator The operator - * @private - * @returns {void} - */ - function validateNode(node, rightSide, operator) { - - /* - * Find the operator token by searching from the right side, because between the left side and the operator - * there could be additional tokens from type annotations. Search specifically for the token which - * value equals the operator, in order to skip possible opening parentheses before the right side node. - */ - const operatorToken = sourceCode.getTokenBefore(rightSide, token => token.value === operator); - const leftToken = sourceCode.getTokenBefore(operatorToken); - const rightToken = sourceCode.getTokenAfter(operatorToken); - const operatorStyleOverride = styleOverrides[operator]; - const style = operatorStyleOverride || globalStyle; - const fix = getFixer(operatorToken, style); - - // if single line - if (astUtils.isTokenOnSameLine(leftToken, operatorToken) && - astUtils.isTokenOnSameLine(operatorToken, rightToken)) { - - // do nothing. - - } else if (operatorStyleOverride !== "ignore" && !astUtils.isTokenOnSameLine(leftToken, operatorToken) && - !astUtils.isTokenOnSameLine(operatorToken, rightToken)) { - - // lone operator - context.report({ - node, - loc: operatorToken.loc, - messageId: "badLinebreak", - data: { - operator - }, - fix - }); - - } else if (style === "before" && astUtils.isTokenOnSameLine(leftToken, operatorToken)) { - - context.report({ - node, - loc: operatorToken.loc, - messageId: "operatorAtBeginning", - data: { - operator - }, - fix - }); - - } else if (style === "after" && astUtils.isTokenOnSameLine(operatorToken, rightToken)) { - - context.report({ - node, - loc: operatorToken.loc, - messageId: "operatorAtEnd", - data: { - operator - }, - fix - }); - - } else if (style === "none") { - - context.report({ - node, - loc: operatorToken.loc, - messageId: "noLinebreak", - data: { - operator - }, - fix - }); - - } - } - - /** - * Validates a binary expression using `validateNode` - * @param {BinaryExpression|LogicalExpression|AssignmentExpression} node node to be validated - * @returns {void} - */ - function validateBinaryExpression(node) { - validateNode(node, node.right, node.operator); - } - - //-------------------------------------------------------------------------- - // Public - //-------------------------------------------------------------------------- - - return { - BinaryExpression: validateBinaryExpression, - LogicalExpression: validateBinaryExpression, - AssignmentExpression: validateBinaryExpression, - VariableDeclarator(node) { - if (node.init) { - validateNode(node, node.init, "="); - } - }, - PropertyDefinition(node) { - if (node.value) { - validateNode(node, node.value, "="); - } - }, - ConditionalExpression(node) { - validateNode(node, node.consequent, "?"); - validateNode(node, node.alternate, ":"); - } - }; - } -}; diff --git a/tools/eslint/node_modules/eslint/lib/rules/padded-blocks.js b/tools/eslint/node_modules/eslint/lib/rules/padded-blocks.js deleted file mode 100644 index d0c045430e4891..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/rules/padded-blocks.js +++ /dev/null @@ -1,310 +0,0 @@ -/** - * @fileoverview A rule to ensure blank lines within blocks. - * @author Mathias Schreck - * @deprecated in ESLint v8.53.0 - */ - -"use strict"; - -//------------------------------------------------------------------------------ -// Requirements -//------------------------------------------------------------------------------ - -const astUtils = require("./utils/ast-utils"); - -//------------------------------------------------------------------------------ -// Rule Definition -//------------------------------------------------------------------------------ - -/** @type {import('../shared/types').Rule} */ -module.exports = { - meta: { - deprecated: true, - replacedBy: [], - type: "layout", - - docs: { - description: "Require or disallow padding within blocks", - recommended: false, - url: "https://eslint.org/docs/latest/rules/padded-blocks" - }, - - fixable: "whitespace", - - schema: [ - { - oneOf: [ - { - enum: ["always", "never"] - }, - { - type: "object", - properties: { - blocks: { - enum: ["always", "never"] - }, - switches: { - enum: ["always", "never"] - }, - classes: { - enum: ["always", "never"] - } - }, - additionalProperties: false, - minProperties: 1 - } - ] - }, - { - type: "object", - properties: { - allowSingleLineBlocks: { - type: "boolean" - } - }, - additionalProperties: false - } - ], - - messages: { - alwaysPadBlock: "Block must be padded by blank lines.", - neverPadBlock: "Block must not be padded by blank lines." - } - }, - - create(context) { - const options = {}; - const typeOptions = context.options[0] || "always"; - const exceptOptions = context.options[1] || {}; - - if (typeof typeOptions === "string") { - const shouldHavePadding = typeOptions === "always"; - - options.blocks = shouldHavePadding; - options.switches = shouldHavePadding; - options.classes = shouldHavePadding; - } else { - if (Object.hasOwn(typeOptions, "blocks")) { - options.blocks = typeOptions.blocks === "always"; - } - if (Object.hasOwn(typeOptions, "switches")) { - options.switches = typeOptions.switches === "always"; - } - if (Object.hasOwn(typeOptions, "classes")) { - options.classes = typeOptions.classes === "always"; - } - } - - if (Object.hasOwn(exceptOptions, "allowSingleLineBlocks")) { - options.allowSingleLineBlocks = exceptOptions.allowSingleLineBlocks === true; - } - - const sourceCode = context.sourceCode; - - /** - * Gets the open brace token from a given node. - * @param {ASTNode} node A BlockStatement or SwitchStatement node from which to get the open brace. - * @returns {Token} The token of the open brace. - */ - function getOpenBrace(node) { - if (node.type === "SwitchStatement") { - return sourceCode.getTokenBefore(node.cases[0]); - } - - if (node.type === "StaticBlock") { - return sourceCode.getFirstToken(node, { skip: 1 }); // skip the `static` token - } - - // `BlockStatement` or `ClassBody` - return sourceCode.getFirstToken(node); - } - - /** - * Checks if the given parameter is a comment node - * @param {ASTNode|Token} node An AST node or token - * @returns {boolean} True if node is a comment - */ - function isComment(node) { - return node.type === "Line" || node.type === "Block"; - } - - /** - * Checks if there is padding between two tokens - * @param {Token} first The first token - * @param {Token} second The second token - * @returns {boolean} True if there is at least a line between the tokens - */ - function isPaddingBetweenTokens(first, second) { - return second.loc.start.line - first.loc.end.line >= 2; - } - - - /** - * Checks if the given token has a blank line after it. - * @param {Token} token The token to check. - * @returns {boolean} Whether or not the token is followed by a blank line. - */ - function getFirstBlockToken(token) { - let prev, - first = token; - - do { - prev = first; - first = sourceCode.getTokenAfter(first, { includeComments: true }); - } while (isComment(first) && first.loc.start.line === prev.loc.end.line); - - return first; - } - - /** - * Checks if the given token is preceded by a blank line. - * @param {Token} token The token to check - * @returns {boolean} Whether or not the token is preceded by a blank line - */ - function getLastBlockToken(token) { - let last = token, - next; - - do { - next = last; - last = sourceCode.getTokenBefore(last, { includeComments: true }); - } while (isComment(last) && last.loc.end.line === next.loc.start.line); - - return last; - } - - /** - * Checks if a node should be padded, according to the rule config. - * @param {ASTNode} node The AST node to check. - * @throws {Error} (Unreachable) - * @returns {boolean} True if the node should be padded, false otherwise. - */ - function requirePaddingFor(node) { - switch (node.type) { - case "BlockStatement": - case "StaticBlock": - return options.blocks; - case "SwitchStatement": - return options.switches; - case "ClassBody": - return options.classes; - - /* c8 ignore next */ - default: - throw new Error("unreachable"); - } - } - - /** - * Checks the given BlockStatement node to be padded if the block is not empty. - * @param {ASTNode} node The AST node of a BlockStatement. - * @returns {void} undefined. - */ - function checkPadding(node) { - const openBrace = getOpenBrace(node), - firstBlockToken = getFirstBlockToken(openBrace), - tokenBeforeFirst = sourceCode.getTokenBefore(firstBlockToken, { includeComments: true }), - closeBrace = sourceCode.getLastToken(node), - lastBlockToken = getLastBlockToken(closeBrace), - tokenAfterLast = sourceCode.getTokenAfter(lastBlockToken, { includeComments: true }), - blockHasTopPadding = isPaddingBetweenTokens(tokenBeforeFirst, firstBlockToken), - blockHasBottomPadding = isPaddingBetweenTokens(lastBlockToken, tokenAfterLast); - - if (options.allowSingleLineBlocks && astUtils.isTokenOnSameLine(tokenBeforeFirst, tokenAfterLast)) { - return; - } - - if (requirePaddingFor(node)) { - - if (!blockHasTopPadding) { - context.report({ - node, - loc: { - start: tokenBeforeFirst.loc.start, - end: firstBlockToken.loc.start - }, - fix(fixer) { - return fixer.insertTextAfter(tokenBeforeFirst, "\n"); - }, - messageId: "alwaysPadBlock" - }); - } - if (!blockHasBottomPadding) { - context.report({ - node, - loc: { - end: tokenAfterLast.loc.start, - start: lastBlockToken.loc.end - }, - fix(fixer) { - return fixer.insertTextBefore(tokenAfterLast, "\n"); - }, - messageId: "alwaysPadBlock" - }); - } - } else { - if (blockHasTopPadding) { - - context.report({ - node, - loc: { - start: tokenBeforeFirst.loc.start, - end: firstBlockToken.loc.start - }, - fix(fixer) { - return fixer.replaceTextRange([tokenBeforeFirst.range[1], firstBlockToken.range[0] - firstBlockToken.loc.start.column], "\n"); - }, - messageId: "neverPadBlock" - }); - } - - if (blockHasBottomPadding) { - - context.report({ - node, - loc: { - end: tokenAfterLast.loc.start, - start: lastBlockToken.loc.end - }, - messageId: "neverPadBlock", - fix(fixer) { - return fixer.replaceTextRange([lastBlockToken.range[1], tokenAfterLast.range[0] - tokenAfterLast.loc.start.column], "\n"); - } - }); - } - } - } - - const rule = {}; - - if (Object.hasOwn(options, "switches")) { - rule.SwitchStatement = function(node) { - if (node.cases.length === 0) { - return; - } - checkPadding(node); - }; - } - - if (Object.hasOwn(options, "blocks")) { - rule.BlockStatement = function(node) { - if (node.body.length === 0) { - return; - } - checkPadding(node); - }; - rule.StaticBlock = rule.BlockStatement; - } - - if (Object.hasOwn(options, "classes")) { - rule.ClassBody = function(node) { - if (node.body.length === 0) { - return; - } - checkPadding(node); - }; - } - - return rule; - } -}; diff --git a/tools/eslint/node_modules/eslint/lib/rules/padding-line-between-statements.js b/tools/eslint/node_modules/eslint/lib/rules/padding-line-between-statements.js deleted file mode 100644 index 084651b6dff9d5..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/rules/padding-line-between-statements.js +++ /dev/null @@ -1,590 +0,0 @@ -/** - * @fileoverview Rule to require or disallow newlines between statements - * @author Toru Nagashima - * @deprecated in ESLint v8.53.0 - */ - -"use strict"; - -//------------------------------------------------------------------------------ -// Requirements -//------------------------------------------------------------------------------ - -const astUtils = require("./utils/ast-utils"); - -//------------------------------------------------------------------------------ -// Helpers -//------------------------------------------------------------------------------ - -const LT = `[${Array.from(astUtils.LINEBREAKS).join("")}]`; -const PADDING_LINE_SEQUENCE = new RegExp( - String.raw`^(\s*?${LT})\s*${LT}(\s*;?)$`, - "u" -); -const CJS_EXPORT = /^(?:module\s*\.\s*)?exports(?:\s*\.|\s*\[|$)/u; -const CJS_IMPORT = /^require\(/u; - -/** - * Creates tester which check if a node starts with specific keyword. - * @param {string} keyword The keyword to test. - * @returns {Object} the created tester. - * @private - */ -function newKeywordTester(keyword) { - return { - test: (node, sourceCode) => - sourceCode.getFirstToken(node).value === keyword - }; -} - -/** - * Creates tester which check if a node starts with specific keyword and spans a single line. - * @param {string} keyword The keyword to test. - * @returns {Object} the created tester. - * @private - */ -function newSinglelineKeywordTester(keyword) { - return { - test: (node, sourceCode) => - node.loc.start.line === node.loc.end.line && - sourceCode.getFirstToken(node).value === keyword - }; -} - -/** - * Creates tester which check if a node starts with specific keyword and spans multiple lines. - * @param {string} keyword The keyword to test. - * @returns {Object} the created tester. - * @private - */ -function newMultilineKeywordTester(keyword) { - return { - test: (node, sourceCode) => - node.loc.start.line !== node.loc.end.line && - sourceCode.getFirstToken(node).value === keyword - }; -} - -/** - * Creates tester which check if a node is specific type. - * @param {string} type The node type to test. - * @returns {Object} the created tester. - * @private - */ -function newNodeTypeTester(type) { - return { - test: node => - node.type === type - }; -} - -/** - * Checks the given node is an expression statement of IIFE. - * @param {ASTNode} node The node to check. - * @returns {boolean} `true` if the node is an expression statement of IIFE. - * @private - */ -function isIIFEStatement(node) { - if (node.type === "ExpressionStatement") { - let call = astUtils.skipChainExpression(node.expression); - - if (call.type === "UnaryExpression") { - call = astUtils.skipChainExpression(call.argument); - } - return call.type === "CallExpression" && astUtils.isFunction(call.callee); - } - return false; -} - -/** - * Checks whether the given node is a block-like statement. - * This checks the last token of the node is the closing brace of a block. - * @param {SourceCode} sourceCode The source code to get tokens. - * @param {ASTNode} node The node to check. - * @returns {boolean} `true` if the node is a block-like statement. - * @private - */ -function isBlockLikeStatement(sourceCode, node) { - - // do-while with a block is a block-like statement. - if (node.type === "DoWhileStatement" && node.body.type === "BlockStatement") { - return true; - } - - /* - * IIFE is a block-like statement specially from - * JSCS#disallowPaddingNewLinesAfterBlocks. - */ - if (isIIFEStatement(node)) { - return true; - } - - // Checks the last token is a closing brace of blocks. - const lastToken = sourceCode.getLastToken(node, astUtils.isNotSemicolonToken); - const belongingNode = lastToken && astUtils.isClosingBraceToken(lastToken) - ? sourceCode.getNodeByRangeIndex(lastToken.range[0]) - : null; - - return Boolean(belongingNode) && ( - belongingNode.type === "BlockStatement" || - belongingNode.type === "SwitchStatement" - ); -} - -/** - * Gets the actual last token. - * - * If a semicolon is semicolon-less style's semicolon, this ignores it. - * For example: - * - * foo() - * ;[1, 2, 3].forEach(bar) - * @param {SourceCode} sourceCode The source code to get tokens. - * @param {ASTNode} node The node to get. - * @returns {Token} The actual last token. - * @private - */ -function getActualLastToken(sourceCode, node) { - const semiToken = sourceCode.getLastToken(node); - const prevToken = sourceCode.getTokenBefore(semiToken); - const nextToken = sourceCode.getTokenAfter(semiToken); - const isSemicolonLessStyle = Boolean( - prevToken && - nextToken && - prevToken.range[0] >= node.range[0] && - astUtils.isSemicolonToken(semiToken) && - semiToken.loc.start.line !== prevToken.loc.end.line && - semiToken.loc.end.line === nextToken.loc.start.line - ); - - return isSemicolonLessStyle ? prevToken : semiToken; -} - -/** - * This returns the concatenation of the first 2 captured strings. - * @param {string} _ Unused. Whole matched string. - * @param {string} trailingSpaces The trailing spaces of the first line. - * @param {string} indentSpaces The indentation spaces of the last line. - * @returns {string} The concatenation of trailingSpaces and indentSpaces. - * @private - */ -function replacerToRemovePaddingLines(_, trailingSpaces, indentSpaces) { - return trailingSpaces + indentSpaces; -} - -/** - * Check and report statements for `any` configuration. - * It does nothing. - * @returns {void} - * @private - */ -function verifyForAny() { -} - -/** - * Check and report statements for `never` configuration. - * This autofix removes blank lines between the given 2 statements. - * However, if comments exist between 2 blank lines, it does not remove those - * blank lines automatically. - * @param {RuleContext} context The rule context to report. - * @param {ASTNode} _ Unused. The previous node to check. - * @param {ASTNode} nextNode The next node to check. - * @param {Array} paddingLines The array of token pairs that blank - * lines exist between the pair. - * @returns {void} - * @private - */ -function verifyForNever(context, _, nextNode, paddingLines) { - if (paddingLines.length === 0) { - return; - } - - context.report({ - node: nextNode, - messageId: "unexpectedBlankLine", - fix(fixer) { - if (paddingLines.length >= 2) { - return null; - } - - const prevToken = paddingLines[0][0]; - const nextToken = paddingLines[0][1]; - const start = prevToken.range[1]; - const end = nextToken.range[0]; - const text = context.sourceCode.text - .slice(start, end) - .replace(PADDING_LINE_SEQUENCE, replacerToRemovePaddingLines); - - return fixer.replaceTextRange([start, end], text); - } - }); -} - -/** - * Check and report statements for `always` configuration. - * This autofix inserts a blank line between the given 2 statements. - * If the `prevNode` has trailing comments, it inserts a blank line after the - * trailing comments. - * @param {RuleContext} context The rule context to report. - * @param {ASTNode} prevNode The previous node to check. - * @param {ASTNode} nextNode The next node to check. - * @param {Array} paddingLines The array of token pairs that blank - * lines exist between the pair. - * @returns {void} - * @private - */ -function verifyForAlways(context, prevNode, nextNode, paddingLines) { - if (paddingLines.length > 0) { - return; - } - - context.report({ - node: nextNode, - messageId: "expectedBlankLine", - fix(fixer) { - const sourceCode = context.sourceCode; - let prevToken = getActualLastToken(sourceCode, prevNode); - const nextToken = sourceCode.getFirstTokenBetween( - prevToken, - nextNode, - { - includeComments: true, - - /** - * Skip the trailing comments of the previous node. - * This inserts a blank line after the last trailing comment. - * - * For example: - * - * foo(); // trailing comment. - * // comment. - * bar(); - * - * Get fixed to: - * - * foo(); // trailing comment. - * - * // comment. - * bar(); - * @param {Token} token The token to check. - * @returns {boolean} `true` if the token is not a trailing comment. - * @private - */ - filter(token) { - if (astUtils.isTokenOnSameLine(prevToken, token)) { - prevToken = token; - return false; - } - return true; - } - } - ) || nextNode; - const insertText = astUtils.isTokenOnSameLine(prevToken, nextToken) - ? "\n\n" - : "\n"; - - return fixer.insertTextAfter(prevToken, insertText); - } - }); -} - -/** - * Types of blank lines. - * `any`, `never`, and `always` are defined. - * Those have `verify` method to check and report statements. - * @private - */ -const PaddingTypes = { - any: { verify: verifyForAny }, - never: { verify: verifyForNever }, - always: { verify: verifyForAlways } -}; - -/** - * Types of statements. - * Those have `test` method to check it matches to the given statement. - * @private - */ -const StatementTypes = { - "*": { test: () => true }, - "block-like": { - test: (node, sourceCode) => isBlockLikeStatement(sourceCode, node) - }, - "cjs-export": { - test: (node, sourceCode) => - node.type === "ExpressionStatement" && - node.expression.type === "AssignmentExpression" && - CJS_EXPORT.test(sourceCode.getText(node.expression.left)) - }, - "cjs-import": { - test: (node, sourceCode) => - node.type === "VariableDeclaration" && - node.declarations.length > 0 && - Boolean(node.declarations[0].init) && - CJS_IMPORT.test(sourceCode.getText(node.declarations[0].init)) - }, - directive: { - test: astUtils.isDirective - }, - expression: { - test: node => node.type === "ExpressionStatement" && !astUtils.isDirective(node) - }, - iife: { - test: isIIFEStatement - }, - "multiline-block-like": { - test: (node, sourceCode) => - node.loc.start.line !== node.loc.end.line && - isBlockLikeStatement(sourceCode, node) - }, - "multiline-expression": { - test: node => - node.loc.start.line !== node.loc.end.line && - node.type === "ExpressionStatement" && - !astUtils.isDirective(node) - }, - - "multiline-const": newMultilineKeywordTester("const"), - "multiline-let": newMultilineKeywordTester("let"), - "multiline-var": newMultilineKeywordTester("var"), - "singleline-const": newSinglelineKeywordTester("const"), - "singleline-let": newSinglelineKeywordTester("let"), - "singleline-var": newSinglelineKeywordTester("var"), - - block: newNodeTypeTester("BlockStatement"), - empty: newNodeTypeTester("EmptyStatement"), - function: newNodeTypeTester("FunctionDeclaration"), - - break: newKeywordTester("break"), - case: newKeywordTester("case"), - class: newKeywordTester("class"), - const: newKeywordTester("const"), - continue: newKeywordTester("continue"), - debugger: newKeywordTester("debugger"), - default: newKeywordTester("default"), - do: newKeywordTester("do"), - export: newKeywordTester("export"), - for: newKeywordTester("for"), - if: newKeywordTester("if"), - import: newKeywordTester("import"), - let: newKeywordTester("let"), - return: newKeywordTester("return"), - switch: newKeywordTester("switch"), - throw: newKeywordTester("throw"), - try: newKeywordTester("try"), - var: newKeywordTester("var"), - while: newKeywordTester("while"), - with: newKeywordTester("with") -}; - -//------------------------------------------------------------------------------ -// Rule Definition -//------------------------------------------------------------------------------ - -/** @type {import('../shared/types').Rule} */ -module.exports = { - meta: { - deprecated: true, - replacedBy: [], - type: "layout", - - docs: { - description: "Require or disallow padding lines between statements", - recommended: false, - url: "https://eslint.org/docs/latest/rules/padding-line-between-statements" - }, - - fixable: "whitespace", - - schema: { - definitions: { - paddingType: { - enum: Object.keys(PaddingTypes) - }, - statementType: { - anyOf: [ - { enum: Object.keys(StatementTypes) }, - { - type: "array", - items: { enum: Object.keys(StatementTypes) }, - minItems: 1, - uniqueItems: true - } - ] - } - }, - type: "array", - items: { - type: "object", - properties: { - blankLine: { $ref: "#/definitions/paddingType" }, - prev: { $ref: "#/definitions/statementType" }, - next: { $ref: "#/definitions/statementType" } - }, - additionalProperties: false, - required: ["blankLine", "prev", "next"] - } - }, - - messages: { - unexpectedBlankLine: "Unexpected blank line before this statement.", - expectedBlankLine: "Expected blank line before this statement." - } - }, - - create(context) { - const sourceCode = context.sourceCode; - const configureList = context.options || []; - let scopeInfo = null; - - /** - * Processes to enter to new scope. - * This manages the current previous statement. - * @returns {void} - * @private - */ - function enterScope() { - scopeInfo = { - upper: scopeInfo, - prevNode: null - }; - } - - /** - * Processes to exit from the current scope. - * @returns {void} - * @private - */ - function exitScope() { - scopeInfo = scopeInfo.upper; - } - - /** - * Checks whether the given node matches the given type. - * @param {ASTNode} node The statement node to check. - * @param {string|string[]} type The statement type to check. - * @returns {boolean} `true` if the statement node matched the type. - * @private - */ - function match(node, type) { - let innerStatementNode = node; - - while (innerStatementNode.type === "LabeledStatement") { - innerStatementNode = innerStatementNode.body; - } - if (Array.isArray(type)) { - return type.some(match.bind(null, innerStatementNode)); - } - return StatementTypes[type].test(innerStatementNode, sourceCode); - } - - /** - * Finds the last matched configure from configureList. - * @param {ASTNode} prevNode The previous statement to match. - * @param {ASTNode} nextNode The current statement to match. - * @returns {Object} The tester of the last matched configure. - * @private - */ - function getPaddingType(prevNode, nextNode) { - for (let i = configureList.length - 1; i >= 0; --i) { - const configure = configureList[i]; - const matched = - match(prevNode, configure.prev) && - match(nextNode, configure.next); - - if (matched) { - return PaddingTypes[configure.blankLine]; - } - } - return PaddingTypes.any; - } - - /** - * Gets padding line sequences between the given 2 statements. - * Comments are separators of the padding line sequences. - * @param {ASTNode} prevNode The previous statement to count. - * @param {ASTNode} nextNode The current statement to count. - * @returns {Array} The array of token pairs. - * @private - */ - function getPaddingLineSequences(prevNode, nextNode) { - const pairs = []; - let prevToken = getActualLastToken(sourceCode, prevNode); - - if (nextNode.loc.start.line - prevToken.loc.end.line >= 2) { - do { - const token = sourceCode.getTokenAfter( - prevToken, - { includeComments: true } - ); - - if (token.loc.start.line - prevToken.loc.end.line >= 2) { - pairs.push([prevToken, token]); - } - prevToken = token; - - } while (prevToken.range[0] < nextNode.range[0]); - } - - return pairs; - } - - /** - * Verify padding lines between the given node and the previous node. - * @param {ASTNode} node The node to verify. - * @returns {void} - * @private - */ - function verify(node) { - const parentType = node.parent.type; - const validParent = - astUtils.STATEMENT_LIST_PARENTS.has(parentType) || - parentType === "SwitchStatement"; - - if (!validParent) { - return; - } - - // Save this node as the current previous statement. - const prevNode = scopeInfo.prevNode; - - // Verify. - if (prevNode) { - const type = getPaddingType(prevNode, node); - const paddingLines = getPaddingLineSequences(prevNode, node); - - type.verify(context, prevNode, node, paddingLines); - } - - scopeInfo.prevNode = node; - } - - /** - * Verify padding lines between the given node and the previous node. - * Then process to enter to new scope. - * @param {ASTNode} node The node to verify. - * @returns {void} - * @private - */ - function verifyThenEnterScope(node) { - verify(node); - enterScope(); - } - - return { - Program: enterScope, - BlockStatement: enterScope, - SwitchStatement: enterScope, - StaticBlock: enterScope, - "Program:exit": exitScope, - "BlockStatement:exit": exitScope, - "SwitchStatement:exit": exitScope, - "StaticBlock:exit": exitScope, - - ":statement": verify, - - SwitchCase: verifyThenEnterScope, - "SwitchCase:exit": exitScope - }; - } -}; diff --git a/tools/eslint/node_modules/eslint/lib/rules/prefer-arrow-callback.js b/tools/eslint/node_modules/eslint/lib/rules/prefer-arrow-callback.js deleted file mode 100644 index b23696dd64cd9b..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/rules/prefer-arrow-callback.js +++ /dev/null @@ -1,381 +0,0 @@ -/** - * @fileoverview A rule to suggest using arrow functions as callbacks. - * @author Toru Nagashima - */ - -"use strict"; - -const astUtils = require("./utils/ast-utils"); - -//------------------------------------------------------------------------------ -// Helpers -//------------------------------------------------------------------------------ - -/** - * Checks whether or not a given variable is a function name. - * @param {eslint-scope.Variable} variable A variable to check. - * @returns {boolean} `true` if the variable is a function name. - */ -function isFunctionName(variable) { - return variable && variable.defs[0].type === "FunctionName"; -} - -/** - * Checks whether or not a given MetaProperty node equals to a given value. - * @param {ASTNode} node A MetaProperty node to check. - * @param {string} metaName The name of `MetaProperty.meta`. - * @param {string} propertyName The name of `MetaProperty.property`. - * @returns {boolean} `true` if the node is the specific value. - */ -function checkMetaProperty(node, metaName, propertyName) { - return node.meta.name === metaName && node.property.name === propertyName; -} - -/** - * Gets the variable object of `arguments` which is defined implicitly. - * @param {eslint-scope.Scope} scope A scope to get. - * @returns {eslint-scope.Variable} The found variable object. - */ -function getVariableOfArguments(scope) { - const variables = scope.variables; - - for (let i = 0; i < variables.length; ++i) { - const variable = variables[i]; - - if (variable.name === "arguments") { - - /* - * If there was a parameter which is named "arguments", the - * implicit "arguments" is not defined. - * So does fast return with null. - */ - return (variable.identifiers.length === 0) ? variable : null; - } - } - - /* c8 ignore next */ - return null; -} - -/** - * Checks whether or not a given node is a callback. - * @param {ASTNode} node A node to check. - * @throws {Error} (Unreachable.) - * @returns {Object} - * {boolean} retv.isCallback - `true` if the node is a callback. - * {boolean} retv.isLexicalThis - `true` if the node is with `.bind(this)`. - */ -function getCallbackInfo(node) { - const retv = { isCallback: false, isLexicalThis: false }; - let currentNode = node; - let parent = node.parent; - let bound = false; - - while (currentNode) { - switch (parent.type) { - - // Checks parents recursively. - - case "LogicalExpression": - case "ChainExpression": - case "ConditionalExpression": - break; - - // Checks whether the parent node is `.bind(this)` call. - case "MemberExpression": - if ( - parent.object === currentNode && - !parent.property.computed && - parent.property.type === "Identifier" && - parent.property.name === "bind" - ) { - const maybeCallee = parent.parent.type === "ChainExpression" - ? parent.parent - : parent; - - if (astUtils.isCallee(maybeCallee)) { - if (!bound) { - bound = true; // Use only the first `.bind()` to make `isLexicalThis` value. - retv.isLexicalThis = ( - maybeCallee.parent.arguments.length === 1 && - maybeCallee.parent.arguments[0].type === "ThisExpression" - ); - } - parent = maybeCallee.parent; - } else { - return retv; - } - } else { - return retv; - } - break; - - // Checks whether the node is a callback. - case "CallExpression": - case "NewExpression": - if (parent.callee !== currentNode) { - retv.isCallback = true; - } - return retv; - - default: - return retv; - } - - currentNode = parent; - parent = parent.parent; - } - - /* c8 ignore next */ - throw new Error("unreachable"); -} - -/** - * Checks whether a simple list of parameters contains any duplicates. This does not handle complex - * parameter lists (e.g. with destructuring), since complex parameter lists are a SyntaxError with duplicate - * parameter names anyway. Instead, it always returns `false` for complex parameter lists. - * @param {ASTNode[]} paramsList The list of parameters for a function - * @returns {boolean} `true` if the list of parameters contains any duplicates - */ -function hasDuplicateParams(paramsList) { - return paramsList.every(param => param.type === "Identifier") && paramsList.length !== new Set(paramsList.map(param => param.name)).size; -} - -//------------------------------------------------------------------------------ -// Rule Definition -//------------------------------------------------------------------------------ - -/** @type {import('../shared/types').Rule} */ -module.exports = { - meta: { - type: "suggestion", - - docs: { - description: "Require using arrow functions for callbacks", - recommended: false, - url: "https://eslint.org/docs/latest/rules/prefer-arrow-callback" - }, - - schema: [ - { - type: "object", - properties: { - allowNamedFunctions: { - type: "boolean", - default: false - }, - allowUnboundThis: { - type: "boolean", - default: true - } - }, - additionalProperties: false - } - ], - - fixable: "code", - - messages: { - preferArrowCallback: "Unexpected function expression." - } - }, - - create(context) { - const options = context.options[0] || {}; - - const allowUnboundThis = options.allowUnboundThis !== false; // default to true - const allowNamedFunctions = options.allowNamedFunctions; - const sourceCode = context.sourceCode; - - /* - * {Array<{this: boolean, super: boolean, meta: boolean}>} - * - this - A flag which shows there are one or more ThisExpression. - * - super - A flag which shows there are one or more Super. - * - meta - A flag which shows there are one or more MethProperty. - */ - let stack = []; - - /** - * Pushes new function scope with all `false` flags. - * @returns {void} - */ - function enterScope() { - stack.push({ this: false, super: false, meta: false }); - } - - /** - * Pops a function scope from the stack. - * @returns {{this: boolean, super: boolean, meta: boolean}} The information of the last scope. - */ - function exitScope() { - return stack.pop(); - } - - return { - - // Reset internal state. - Program() { - stack = []; - }, - - // If there are below, it cannot replace with arrow functions merely. - ThisExpression() { - const info = stack.at(-1); - - if (info) { - info.this = true; - } - }, - - Super() { - const info = stack.at(-1); - - if (info) { - info.super = true; - } - }, - - MetaProperty(node) { - const info = stack.at(-1); - - if (info && checkMetaProperty(node, "new", "target")) { - info.meta = true; - } - }, - - // To skip nested scopes. - FunctionDeclaration: enterScope, - "FunctionDeclaration:exit": exitScope, - - // Main. - FunctionExpression: enterScope, - "FunctionExpression:exit"(node) { - const scopeInfo = exitScope(); - - // Skip named function expressions - if (allowNamedFunctions && node.id && node.id.name) { - return; - } - - // Skip generators. - if (node.generator) { - return; - } - - // Skip recursive functions. - const nameVar = sourceCode.getDeclaredVariables(node)[0]; - - if (isFunctionName(nameVar) && nameVar.references.length > 0) { - return; - } - - // Skip if it's using arguments. - const variable = getVariableOfArguments(sourceCode.getScope(node)); - - if (variable && variable.references.length > 0) { - return; - } - - // Reports if it's a callback which can replace with arrows. - const callbackInfo = getCallbackInfo(node); - - if (callbackInfo.isCallback && - (!allowUnboundThis || !scopeInfo.this || callbackInfo.isLexicalThis) && - !scopeInfo.super && - !scopeInfo.meta - ) { - context.report({ - node, - messageId: "preferArrowCallback", - *fix(fixer) { - if ((!callbackInfo.isLexicalThis && scopeInfo.this) || hasDuplicateParams(node.params)) { - - /* - * If the callback function does not have .bind(this) and contains a reference to `this`, there - * is no way to determine what `this` should be, so don't perform any fixes. - * If the callback function has duplicates in its list of parameters (possible in sloppy mode), - * don't replace it with an arrow function, because this is a SyntaxError with arrow functions. - */ - return; - } - - // Remove `.bind(this)` if exists. - if (callbackInfo.isLexicalThis) { - const memberNode = node.parent; - - /* - * If `.bind(this)` exists but the parent is not `.bind(this)`, don't remove it automatically. - * E.g. `(foo || function(){}).bind(this)` - */ - if (memberNode.type !== "MemberExpression") { - return; - } - - const callNode = memberNode.parent; - const firstTokenToRemove = sourceCode.getTokenAfter(memberNode.object, astUtils.isNotClosingParenToken); - const lastTokenToRemove = sourceCode.getLastToken(callNode); - - /* - * If the member expression is parenthesized, don't remove the right paren. - * E.g. `(function(){}.bind)(this)` - * ^^^^^^^^^^^^ - */ - if (astUtils.isParenthesised(sourceCode, memberNode)) { - return; - } - - // If comments exist in the `.bind(this)`, don't remove those. - if (sourceCode.commentsExistBetween(firstTokenToRemove, lastTokenToRemove)) { - return; - } - - yield fixer.removeRange([firstTokenToRemove.range[0], lastTokenToRemove.range[1]]); - } - - // Convert the function expression to an arrow function. - const functionToken = sourceCode.getFirstToken(node, node.async ? 1 : 0); - const leftParenToken = sourceCode.getTokenAfter(functionToken, astUtils.isOpeningParenToken); - const tokenBeforeBody = sourceCode.getTokenBefore(node.body); - - if (sourceCode.commentsExistBetween(functionToken, leftParenToken)) { - - // Remove only extra tokens to keep comments. - yield fixer.remove(functionToken); - if (node.id) { - yield fixer.remove(node.id); - } - } else { - - // Remove extra tokens and spaces. - yield fixer.removeRange([functionToken.range[0], leftParenToken.range[0]]); - } - yield fixer.insertTextAfter(tokenBeforeBody, " =>"); - - // Get the node that will become the new arrow function. - let replacedNode = callbackInfo.isLexicalThis ? node.parent.parent : node; - - if (replacedNode.type === "ChainExpression") { - replacedNode = replacedNode.parent; - } - - /* - * If the replaced node is part of a BinaryExpression, LogicalExpression, or MemberExpression, then - * the arrow function needs to be parenthesized, because `foo || () => {}` is invalid syntax even - * though `foo || function() {}` is valid. - */ - if ( - replacedNode.parent.type !== "CallExpression" && - replacedNode.parent.type !== "ConditionalExpression" && - !astUtils.isParenthesised(sourceCode, replacedNode) && - !astUtils.isParenthesised(sourceCode, node) - ) { - yield fixer.insertTextBefore(replacedNode, "("); - yield fixer.insertTextAfter(replacedNode, ")"); - } - } - }); - } - } - }; - } -}; diff --git a/tools/eslint/node_modules/eslint/lib/rules/prefer-const.js b/tools/eslint/node_modules/eslint/lib/rules/prefer-const.js deleted file mode 100644 index b43975e9bae3ef..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/rules/prefer-const.js +++ /dev/null @@ -1,501 +0,0 @@ -/** - * @fileoverview A rule to suggest using of const declaration for variables that are never reassigned after declared. - * @author Toru Nagashima - */ - -"use strict"; - -//------------------------------------------------------------------------------ -// Requirements -//------------------------------------------------------------------------------ - -const FixTracker = require("./utils/fix-tracker"); -const astUtils = require("./utils/ast-utils"); - -//------------------------------------------------------------------------------ -// Helpers -//------------------------------------------------------------------------------ - -const PATTERN_TYPE = /^(?:.+?Pattern|RestElement|SpreadProperty|ExperimentalRestProperty|Property)$/u; -const DECLARATION_HOST_TYPE = /^(?:Program|BlockStatement|StaticBlock|SwitchCase)$/u; -const DESTRUCTURING_HOST_TYPE = /^(?:VariableDeclarator|AssignmentExpression)$/u; - -/** - * Checks whether a given node is located at `ForStatement.init` or not. - * @param {ASTNode} node A node to check. - * @returns {boolean} `true` if the node is located at `ForStatement.init`. - */ -function isInitOfForStatement(node) { - return node.parent.type === "ForStatement" && node.parent.init === node; -} - -/** - * Checks whether a given Identifier node becomes a VariableDeclaration or not. - * @param {ASTNode} identifier An Identifier node to check. - * @returns {boolean} `true` if the node can become a VariableDeclaration. - */ -function canBecomeVariableDeclaration(identifier) { - let node = identifier.parent; - - while (PATTERN_TYPE.test(node.type)) { - node = node.parent; - } - - return ( - node.type === "VariableDeclarator" || - ( - node.type === "AssignmentExpression" && - node.parent.type === "ExpressionStatement" && - DECLARATION_HOST_TYPE.test(node.parent.parent.type) - ) - ); -} - -/** - * Checks if an property or element is from outer scope or function parameters - * in destructing pattern. - * @param {string} name A variable name to be checked. - * @param {eslint-scope.Scope} initScope A scope to start find. - * @returns {boolean} Indicates if the variable is from outer scope or function parameters. - */ -function isOuterVariableInDestructing(name, initScope) { - - if (initScope.through.some(ref => ref.resolved && ref.resolved.name === name)) { - return true; - } - - const variable = astUtils.getVariableByName(initScope, name); - - if (variable !== null) { - return variable.defs.some(def => def.type === "Parameter"); - } - - return false; -} - -/** - * Gets the VariableDeclarator/AssignmentExpression node that a given reference - * belongs to. - * This is used to detect a mix of reassigned and never reassigned in a - * destructuring. - * @param {eslint-scope.Reference} reference A reference to get. - * @returns {ASTNode|null} A VariableDeclarator/AssignmentExpression node or - * null. - */ -function getDestructuringHost(reference) { - if (!reference.isWrite()) { - return null; - } - let node = reference.identifier.parent; - - while (PATTERN_TYPE.test(node.type)) { - node = node.parent; - } - - if (!DESTRUCTURING_HOST_TYPE.test(node.type)) { - return null; - } - return node; -} - -/** - * Determines if a destructuring assignment node contains - * any MemberExpression nodes. This is used to determine if a - * variable that is only written once using destructuring can be - * safely converted into a const declaration. - * @param {ASTNode} node The ObjectPattern or ArrayPattern node to check. - * @returns {boolean} True if the destructuring pattern contains - * a MemberExpression, false if not. - */ -function hasMemberExpressionAssignment(node) { - switch (node.type) { - case "ObjectPattern": - return node.properties.some(prop => { - if (prop) { - - /* - * Spread elements have an argument property while - * others have a value property. Because different - * parsers use different node types for spread elements, - * we just check if there is an argument property. - */ - return hasMemberExpressionAssignment(prop.argument || prop.value); - } - - return false; - }); - - case "ArrayPattern": - return node.elements.some(element => { - if (element) { - return hasMemberExpressionAssignment(element); - } - - return false; - }); - - case "AssignmentPattern": - return hasMemberExpressionAssignment(node.left); - - case "MemberExpression": - return true; - - // no default - } - - return false; -} - -/** - * Gets an identifier node of a given variable. - * - * If the initialization exists or one or more reading references exist before - * the first assignment, the identifier node is the node of the declaration. - * Otherwise, the identifier node is the node of the first assignment. - * - * If the variable should not change to const, this function returns null. - * - If the variable is reassigned. - * - If the variable is never initialized nor assigned. - * - If the variable is initialized in a different scope from the declaration. - * - If the unique assignment of the variable cannot change to a declaration. - * e.g. `if (a) b = 1` / `return (b = 1)` - * - If the variable is declared in the global scope and `eslintUsed` is `true`. - * `/*exported foo` directive comment makes such variables. This rule does not - * warn such variables because this rule cannot distinguish whether the - * exported variables are reassigned or not. - * @param {eslint-scope.Variable} variable A variable to get. - * @param {boolean} ignoreReadBeforeAssign - * The value of `ignoreReadBeforeAssign` option. - * @returns {ASTNode|null} - * An Identifier node if the variable should change to const. - * Otherwise, null. - */ -function getIdentifierIfShouldBeConst(variable, ignoreReadBeforeAssign) { - if (variable.eslintUsed && variable.scope.type === "global") { - return null; - } - - // Finds the unique WriteReference. - let writer = null; - let isReadBeforeInit = false; - const references = variable.references; - - for (let i = 0; i < references.length; ++i) { - const reference = references[i]; - - if (reference.isWrite()) { - const isReassigned = ( - writer !== null && - writer.identifier !== reference.identifier - ); - - if (isReassigned) { - return null; - } - - const destructuringHost = getDestructuringHost(reference); - - if (destructuringHost !== null && destructuringHost.left !== void 0) { - const leftNode = destructuringHost.left; - let hasOuterVariables = false, - hasNonIdentifiers = false; - - if (leftNode.type === "ObjectPattern") { - const properties = leftNode.properties; - - hasOuterVariables = properties - .filter(prop => prop.value) - .map(prop => prop.value.name) - .some(name => isOuterVariableInDestructing(name, variable.scope)); - - hasNonIdentifiers = hasMemberExpressionAssignment(leftNode); - - } else if (leftNode.type === "ArrayPattern") { - const elements = leftNode.elements; - - hasOuterVariables = elements - .map(element => element && element.name) - .some(name => isOuterVariableInDestructing(name, variable.scope)); - - hasNonIdentifiers = hasMemberExpressionAssignment(leftNode); - } - - if (hasOuterVariables || hasNonIdentifiers) { - return null; - } - - } - - writer = reference; - - } else if (reference.isRead() && writer === null) { - if (ignoreReadBeforeAssign) { - return null; - } - isReadBeforeInit = true; - } - } - - /* - * If the assignment is from a different scope, ignore it. - * If the assignment cannot change to a declaration, ignore it. - */ - const shouldBeConst = ( - writer !== null && - writer.from === variable.scope && - canBecomeVariableDeclaration(writer.identifier) - ); - - if (!shouldBeConst) { - return null; - } - - if (isReadBeforeInit) { - return variable.defs[0].name; - } - - return writer.identifier; -} - -/** - * Groups by the VariableDeclarator/AssignmentExpression node that each - * reference of given variables belongs to. - * This is used to detect a mix of reassigned and never reassigned in a - * destructuring. - * @param {eslint-scope.Variable[]} variables Variables to group by destructuring. - * @param {boolean} ignoreReadBeforeAssign - * The value of `ignoreReadBeforeAssign` option. - * @returns {Map} Grouped identifier nodes. - */ -function groupByDestructuring(variables, ignoreReadBeforeAssign) { - const identifierMap = new Map(); - - for (let i = 0; i < variables.length; ++i) { - const variable = variables[i]; - const references = variable.references; - const identifier = getIdentifierIfShouldBeConst(variable, ignoreReadBeforeAssign); - let prevId = null; - - for (let j = 0; j < references.length; ++j) { - const reference = references[j]; - const id = reference.identifier; - - /* - * Avoid counting a reference twice or more for default values of - * destructuring. - */ - if (id === prevId) { - continue; - } - prevId = id; - - // Add the identifier node into the destructuring group. - const group = getDestructuringHost(reference); - - if (group) { - if (identifierMap.has(group)) { - identifierMap.get(group).push(identifier); - } else { - identifierMap.set(group, [identifier]); - } - } - } - } - - return identifierMap; -} - -/** - * Finds the nearest parent of node with a given type. - * @param {ASTNode} node The node to search from. - * @param {string} type The type field of the parent node. - * @param {Function} shouldStop A predicate that returns true if the traversal should stop, and false otherwise. - * @returns {ASTNode} The closest ancestor with the specified type; null if no such ancestor exists. - */ -function findUp(node, type, shouldStop) { - if (!node || shouldStop(node)) { - return null; - } - if (node.type === type) { - return node; - } - return findUp(node.parent, type, shouldStop); -} - -//------------------------------------------------------------------------------ -// Rule Definition -//------------------------------------------------------------------------------ - -/** @type {import('../shared/types').Rule} */ -module.exports = { - meta: { - type: "suggestion", - - docs: { - description: "Require `const` declarations for variables that are never reassigned after declared", - recommended: false, - url: "https://eslint.org/docs/latest/rules/prefer-const" - }, - - fixable: "code", - - schema: [ - { - type: "object", - properties: { - destructuring: { enum: ["any", "all"], default: "any" }, - ignoreReadBeforeAssign: { type: "boolean", default: false } - }, - additionalProperties: false - } - ], - messages: { - useConst: "'{{name}}' is never reassigned. Use 'const' instead." - } - }, - - create(context) { - const options = context.options[0] || {}; - const sourceCode = context.sourceCode; - const shouldMatchAnyDestructuredVariable = options.destructuring !== "all"; - const ignoreReadBeforeAssign = options.ignoreReadBeforeAssign === true; - const variables = []; - let reportCount = 0; - let checkedId = null; - let checkedName = ""; - - - /** - * Reports given identifier nodes if all of the nodes should be declared - * as const. - * - * The argument 'nodes' is an array of Identifier nodes. - * This node is the result of 'getIdentifierIfShouldBeConst()', so it's - * nullable. In simple declaration or assignment cases, the length of - * the array is 1. In destructuring cases, the length of the array can - * be 2 or more. - * @param {(eslint-scope.Reference|null)[]} nodes - * References which are grouped by destructuring to report. - * @returns {void} - */ - function checkGroup(nodes) { - const nodesToReport = nodes.filter(Boolean); - - if (nodes.length && (shouldMatchAnyDestructuredVariable || nodesToReport.length === nodes.length)) { - const varDeclParent = findUp(nodes[0], "VariableDeclaration", parentNode => parentNode.type.endsWith("Statement")); - const isVarDecParentNull = varDeclParent === null; - - if (!isVarDecParentNull && varDeclParent.declarations.length > 0) { - const firstDeclaration = varDeclParent.declarations[0]; - - if (firstDeclaration.init) { - const firstDecParent = firstDeclaration.init.parent; - - /* - * First we check the declaration type and then depending on - * if the type is a "VariableDeclarator" or its an "ObjectPattern" - * we compare the name and id from the first identifier, if the names are different - * we assign the new name, id and reset the count of reportCount and nodeCount in - * order to check each block for the number of reported errors and base our fix - * based on comparing nodes.length and nodesToReport.length. - */ - - if (firstDecParent.type === "VariableDeclarator") { - - if (firstDecParent.id.name !== checkedName) { - checkedName = firstDecParent.id.name; - reportCount = 0; - } - - if (firstDecParent.id.type === "ObjectPattern") { - if (firstDecParent.init.name !== checkedName) { - checkedName = firstDecParent.init.name; - reportCount = 0; - } - } - - if (firstDecParent.id !== checkedId) { - checkedId = firstDecParent.id; - reportCount = 0; - } - } - } - } - - let shouldFix = varDeclParent && - - // Don't do a fix unless all variables in the declarations are initialized (or it's in a for-in or for-of loop) - (varDeclParent.parent.type === "ForInStatement" || varDeclParent.parent.type === "ForOfStatement" || - varDeclParent.declarations.every(declaration => declaration.init)) && - - /* - * If options.destructuring is "all", then this warning will not occur unless - * every assignment in the destructuring should be const. In that case, it's safe - * to apply the fix. - */ - nodesToReport.length === nodes.length; - - if (!isVarDecParentNull && varDeclParent.declarations && varDeclParent.declarations.length !== 1) { - - if (varDeclParent && varDeclParent.declarations && varDeclParent.declarations.length >= 1) { - - /* - * Add nodesToReport.length to a count, then comparing the count to the length - * of the declarations in the current block. - */ - - reportCount += nodesToReport.length; - - let totalDeclarationsCount = 0; - - varDeclParent.declarations.forEach(declaration => { - if (declaration.id.type === "ObjectPattern") { - totalDeclarationsCount += declaration.id.properties.length; - } else if (declaration.id.type === "ArrayPattern") { - totalDeclarationsCount += declaration.id.elements.length; - } else { - totalDeclarationsCount += 1; - } - }); - - shouldFix = shouldFix && (reportCount === totalDeclarationsCount); - } - } - - nodesToReport.forEach(node => { - context.report({ - node, - messageId: "useConst", - data: node, - fix: shouldFix - ? fixer => { - const letKeywordToken = sourceCode.getFirstToken(varDeclParent, t => t.value === varDeclParent.kind); - - /** - * Extend the replacement range to the whole declaration, - * in order to prevent other fixes in the same pass - * https://github.com/eslint/eslint/issues/13899 - */ - return new FixTracker(fixer, sourceCode) - .retainRange(varDeclParent.range) - .replaceTextRange(letKeywordToken.range, "const"); - } - : null - }); - }); - } - } - - return { - "Program:exit"() { - groupByDestructuring(variables, ignoreReadBeforeAssign).forEach(checkGroup); - }, - - VariableDeclaration(node) { - if (node.kind === "let" && !isInitOfForStatement(node)) { - variables.push(...sourceCode.getDeclaredVariables(node)); - } - } - }; - } -}; diff --git a/tools/eslint/node_modules/eslint/lib/rules/prefer-destructuring.js b/tools/eslint/node_modules/eslint/lib/rules/prefer-destructuring.js deleted file mode 100644 index c6075c55bf5ae3..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/rules/prefer-destructuring.js +++ /dev/null @@ -1,301 +0,0 @@ -/** - * @fileoverview Prefer destructuring from arrays and objects - * @author Alex LaFroscia - */ -"use strict"; - -//------------------------------------------------------------------------------ -// Requirements -//------------------------------------------------------------------------------ - -const astUtils = require("./utils/ast-utils"); - -//------------------------------------------------------------------------------ -// Helpers -//------------------------------------------------------------------------------ - -const PRECEDENCE_OF_ASSIGNMENT_EXPR = astUtils.getPrecedence({ type: "AssignmentExpression" }); - -//------------------------------------------------------------------------------ -// Rule Definition -//------------------------------------------------------------------------------ - -/** @type {import('../shared/types').Rule} */ -module.exports = { - meta: { - type: "suggestion", - - docs: { - description: "Require destructuring from arrays and/or objects", - recommended: false, - url: "https://eslint.org/docs/latest/rules/prefer-destructuring" - }, - - fixable: "code", - - schema: [ - { - - /* - * old support {array: Boolean, object: Boolean} - * new support {VariableDeclarator: {}, AssignmentExpression: {}} - */ - oneOf: [ - { - type: "object", - properties: { - VariableDeclarator: { - type: "object", - properties: { - array: { - type: "boolean" - }, - object: { - type: "boolean" - } - }, - additionalProperties: false - }, - AssignmentExpression: { - type: "object", - properties: { - array: { - type: "boolean" - }, - object: { - type: "boolean" - } - }, - additionalProperties: false - } - }, - additionalProperties: false - }, - { - type: "object", - properties: { - array: { - type: "boolean" - }, - object: { - type: "boolean" - } - }, - additionalProperties: false - } - ] - }, - { - type: "object", - properties: { - enforceForRenamedProperties: { - type: "boolean" - } - }, - additionalProperties: false - } - ], - - messages: { - preferDestructuring: "Use {{type}} destructuring." - } - }, - create(context) { - - const enabledTypes = context.options[0]; - const enforceForRenamedProperties = context.options[1] && context.options[1].enforceForRenamedProperties; - let normalizedOptions = { - VariableDeclarator: { array: true, object: true }, - AssignmentExpression: { array: true, object: true } - }; - - if (enabledTypes) { - normalizedOptions = typeof enabledTypes.array !== "undefined" || typeof enabledTypes.object !== "undefined" - ? { VariableDeclarator: enabledTypes, AssignmentExpression: enabledTypes } - : enabledTypes; - } - - //-------------------------------------------------------------------------- - // Helpers - //-------------------------------------------------------------------------- - - /** - * Checks if destructuring type should be checked. - * @param {string} nodeType "AssignmentExpression" or "VariableDeclarator" - * @param {string} destructuringType "array" or "object" - * @returns {boolean} `true` if the destructuring type should be checked for the given node - */ - function shouldCheck(nodeType, destructuringType) { - return normalizedOptions && - normalizedOptions[nodeType] && - normalizedOptions[nodeType][destructuringType]; - } - - /** - * Determines if the given node is accessing an array index - * - * This is used to differentiate array index access from object property - * access. - * @param {ASTNode} node the node to evaluate - * @returns {boolean} whether or not the node is an integer - */ - function isArrayIndexAccess(node) { - return Number.isInteger(node.property.value); - } - - /** - * Report that the given node should use destructuring - * @param {ASTNode} reportNode the node to report - * @param {string} type the type of destructuring that should have been done - * @param {Function|null} fix the fix function or null to pass to context.report - * @returns {void} - */ - function report(reportNode, type, fix) { - context.report({ - node: reportNode, - messageId: "preferDestructuring", - data: { type }, - fix - }); - } - - /** - * Determines if a node should be fixed into object destructuring - * - * The fixer only fixes the simplest case of object destructuring, - * like: `let x = a.x`; - * - * Assignment expression is not fixed. - * Array destructuring is not fixed. - * Renamed property is not fixed. - * @param {ASTNode} node the node to evaluate - * @returns {boolean} whether or not the node should be fixed - */ - function shouldFix(node) { - return node.type === "VariableDeclarator" && - node.id.type === "Identifier" && - node.init.type === "MemberExpression" && - !node.init.computed && - node.init.property.type === "Identifier" && - node.id.name === node.init.property.name; - } - - /** - * Fix a node into object destructuring. - * This function only handles the simplest case of object destructuring, - * see {@link shouldFix}. - * @param {SourceCodeFixer} fixer the fixer object - * @param {ASTNode} node the node to be fixed. - * @returns {Object} a fix for the node - */ - function fixIntoObjectDestructuring(fixer, node) { - const rightNode = node.init; - const sourceCode = context.sourceCode; - - // Don't fix if that would remove any comments. Only comments inside `rightNode.object` can be preserved. - if (sourceCode.getCommentsInside(node).length > sourceCode.getCommentsInside(rightNode.object).length) { - return null; - } - - let objectText = sourceCode.getText(rightNode.object); - - if (astUtils.getPrecedence(rightNode.object) < PRECEDENCE_OF_ASSIGNMENT_EXPR) { - objectText = `(${objectText})`; - } - - return fixer.replaceText( - node, - `{${rightNode.property.name}} = ${objectText}` - ); - } - - /** - * Check that the `prefer-destructuring` rules are followed based on the - * given left- and right-hand side of the assignment. - * - * Pulled out into a separate method so that VariableDeclarators and - * AssignmentExpressions can share the same verification logic. - * @param {ASTNode} leftNode the left-hand side of the assignment - * @param {ASTNode} rightNode the right-hand side of the assignment - * @param {ASTNode} reportNode the node to report the error on - * @returns {void} - */ - function performCheck(leftNode, rightNode, reportNode) { - if ( - rightNode.type !== "MemberExpression" || - rightNode.object.type === "Super" || - rightNode.property.type === "PrivateIdentifier" - ) { - return; - } - - if (isArrayIndexAccess(rightNode)) { - if (shouldCheck(reportNode.type, "array")) { - report(reportNode, "array", null); - } - return; - } - - const fix = shouldFix(reportNode) - ? fixer => fixIntoObjectDestructuring(fixer, reportNode) - : null; - - if (shouldCheck(reportNode.type, "object") && enforceForRenamedProperties) { - report(reportNode, "object", fix); - return; - } - - if (shouldCheck(reportNode.type, "object")) { - const property = rightNode.property; - - if ( - (property.type === "Literal" && leftNode.name === property.value) || - (property.type === "Identifier" && leftNode.name === property.name && !rightNode.computed) - ) { - report(reportNode, "object", fix); - } - } - } - - /** - * Check if a given variable declarator is coming from an property access - * that should be using destructuring instead - * @param {ASTNode} node the variable declarator to check - * @returns {void} - */ - function checkVariableDeclarator(node) { - - // Skip if variable is declared without assignment - if (!node.init) { - return; - } - - // We only care about member expressions past this point - if (node.init.type !== "MemberExpression") { - return; - } - - performCheck(node.id, node.init, node); - } - - /** - * Run the `prefer-destructuring` check on an AssignmentExpression - * @param {ASTNode} node the AssignmentExpression node - * @returns {void} - */ - function checkAssignmentExpression(node) { - if (node.operator === "=") { - performCheck(node.left, node.right, node); - } - } - - //-------------------------------------------------------------------------- - // Public - //-------------------------------------------------------------------------- - - return { - VariableDeclarator: checkVariableDeclarator, - AssignmentExpression: checkAssignmentExpression - }; - } -}; diff --git a/tools/eslint/node_modules/eslint/lib/rules/prefer-exponentiation-operator.js b/tools/eslint/node_modules/eslint/lib/rules/prefer-exponentiation-operator.js deleted file mode 100644 index 6d807f9cfeaf1b..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/rules/prefer-exponentiation-operator.js +++ /dev/null @@ -1,191 +0,0 @@ -/** - * @fileoverview Rule to disallow Math.pow in favor of the ** operator - * @author Milos Djermanovic - */ - -"use strict"; - -//------------------------------------------------------------------------------ -// Requirements -//------------------------------------------------------------------------------ - -const astUtils = require("./utils/ast-utils"); -const { CALL, ReferenceTracker } = require("@eslint-community/eslint-utils"); - -//------------------------------------------------------------------------------ -// Helpers -//------------------------------------------------------------------------------ - -const PRECEDENCE_OF_EXPONENTIATION_EXPR = astUtils.getPrecedence({ type: "BinaryExpression", operator: "**" }); - -/** - * Determines whether the given node needs parens if used as the base in an exponentiation binary expression. - * @param {ASTNode} base The node to check. - * @returns {boolean} `true` if the node needs to be parenthesised. - */ -function doesBaseNeedParens(base) { - return ( - - // '**' is right-associative, parens are needed when Math.pow(a ** b, c) is converted to (a ** b) ** c - astUtils.getPrecedence(base) <= PRECEDENCE_OF_EXPONENTIATION_EXPR || - - // An unary operator cannot be used immediately before an exponentiation expression - base.type === "AwaitExpression" || - base.type === "UnaryExpression" - ); -} - -/** - * Determines whether the given node needs parens if used as the exponent in an exponentiation binary expression. - * @param {ASTNode} exponent The node to check. - * @returns {boolean} `true` if the node needs to be parenthesised. - */ -function doesExponentNeedParens(exponent) { - - // '**' is right-associative, there is no need for parens when Math.pow(a, b ** c) is converted to a ** b ** c - return astUtils.getPrecedence(exponent) < PRECEDENCE_OF_EXPONENTIATION_EXPR; -} - -/** - * Determines whether an exponentiation binary expression at the place of the given node would need parens. - * @param {ASTNode} node A node that would be replaced by an exponentiation binary expression. - * @param {SourceCode} sourceCode A SourceCode object. - * @returns {boolean} `true` if the expression needs to be parenthesised. - */ -function doesExponentiationExpressionNeedParens(node, sourceCode) { - const parent = node.parent.type === "ChainExpression" ? node.parent.parent : node.parent; - - const parentPrecedence = astUtils.getPrecedence(parent); - const needsParens = ( - parent.type === "ClassDeclaration" || - ( - parent.type.endsWith("Expression") && - (parentPrecedence === -1 || parentPrecedence >= PRECEDENCE_OF_EXPONENTIATION_EXPR) && - !(parent.type === "BinaryExpression" && parent.operator === "**" && parent.right === node) && - !((parent.type === "CallExpression" || parent.type === "NewExpression") && parent.arguments.includes(node)) && - !(parent.type === "MemberExpression" && parent.computed && parent.property === node) && - !(parent.type === "ArrayExpression") - ) - ); - - return needsParens && !astUtils.isParenthesised(sourceCode, node); -} - -/** - * Optionally parenthesizes given text. - * @param {string} text The text to parenthesize. - * @param {boolean} shouldParenthesize If `true`, the text will be parenthesised. - * @returns {string} parenthesised or unchanged text. - */ -function parenthesizeIfShould(text, shouldParenthesize) { - return shouldParenthesize ? `(${text})` : text; -} - -//------------------------------------------------------------------------------ -// Rule Definition -//------------------------------------------------------------------------------ - -/** @type {import('../shared/types').Rule} */ -module.exports = { - meta: { - type: "suggestion", - - docs: { - description: "Disallow the use of `Math.pow` in favor of the `**` operator", - recommended: false, - url: "https://eslint.org/docs/latest/rules/prefer-exponentiation-operator" - }, - - schema: [], - fixable: "code", - - messages: { - useExponentiation: "Use the '**' operator instead of 'Math.pow'." - } - }, - - create(context) { - const sourceCode = context.sourceCode; - - /** - * Reports the given node. - * @param {ASTNode} node 'Math.pow()' node to report. - * @returns {void} - */ - function report(node) { - context.report({ - node, - messageId: "useExponentiation", - fix(fixer) { - if ( - node.arguments.length !== 2 || - node.arguments.some(arg => arg.type === "SpreadElement") || - sourceCode.getCommentsInside(node).length > 0 - ) { - return null; - } - - const base = node.arguments[0], - exponent = node.arguments[1], - baseText = sourceCode.getText(base), - exponentText = sourceCode.getText(exponent), - shouldParenthesizeBase = doesBaseNeedParens(base), - shouldParenthesizeExponent = doesExponentNeedParens(exponent), - shouldParenthesizeAll = doesExponentiationExpressionNeedParens(node, sourceCode); - - let prefix = "", - suffix = ""; - - if (!shouldParenthesizeAll) { - if (!shouldParenthesizeBase) { - const firstReplacementToken = sourceCode.getFirstToken(base), - tokenBefore = sourceCode.getTokenBefore(node); - - if ( - tokenBefore && - tokenBefore.range[1] === node.range[0] && - !astUtils.canTokensBeAdjacent(tokenBefore, firstReplacementToken) - ) { - prefix = " "; // a+Math.pow(++b, c) -> a+ ++b**c - } - } - if (!shouldParenthesizeExponent) { - const lastReplacementToken = sourceCode.getLastToken(exponent), - tokenAfter = sourceCode.getTokenAfter(node); - - if ( - tokenAfter && - node.range[1] === tokenAfter.range[0] && - !astUtils.canTokensBeAdjacent(lastReplacementToken, tokenAfter) - ) { - suffix = " "; // Math.pow(a, b)in c -> a**b in c - } - } - } - - const baseReplacement = parenthesizeIfShould(baseText, shouldParenthesizeBase), - exponentReplacement = parenthesizeIfShould(exponentText, shouldParenthesizeExponent), - replacement = parenthesizeIfShould(`${baseReplacement}**${exponentReplacement}`, shouldParenthesizeAll); - - return fixer.replaceText(node, `${prefix}${replacement}${suffix}`); - } - }); - } - - return { - Program(node) { - const scope = sourceCode.getScope(node); - const tracker = new ReferenceTracker(scope); - const trackMap = { - Math: { - pow: { [CALL]: true } - } - }; - - for (const { node: refNode } of tracker.iterateGlobalReferences(trackMap)) { - report(refNode); - } - } - }; - } -}; diff --git a/tools/eslint/node_modules/eslint/lib/rules/prefer-named-capture-group.js b/tools/eslint/node_modules/eslint/lib/rules/prefer-named-capture-group.js deleted file mode 100644 index a82ee1f78356df..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/rules/prefer-named-capture-group.js +++ /dev/null @@ -1,178 +0,0 @@ -/** - * @fileoverview Rule to enforce requiring named capture groups in regular expression. - * @author Pig Fang - */ - -"use strict"; - -//------------------------------------------------------------------------------ -// Requirements -//------------------------------------------------------------------------------ - -const { - CALL, - CONSTRUCT, - ReferenceTracker, - getStringIfConstant -} = require("@eslint-community/eslint-utils"); -const regexpp = require("@eslint-community/regexpp"); - -//------------------------------------------------------------------------------ -// Helpers -//------------------------------------------------------------------------------ - -const parser = new regexpp.RegExpParser(); - -/** - * Creates fixer suggestions for the regex, if statically determinable. - * @param {number} groupStart Starting index of the regex group. - * @param {string} pattern The regular expression pattern to be checked. - * @param {string} rawText Source text of the regexNode. - * @param {ASTNode} regexNode AST node which contains the regular expression. - * @returns {Array} Fixer suggestions for the regex, if statically determinable. - */ -function suggestIfPossible(groupStart, pattern, rawText, regexNode) { - switch (regexNode.type) { - case "Literal": - if (typeof regexNode.value === "string" && rawText.includes("\\")) { - return null; - } - break; - case "TemplateLiteral": - if (regexNode.expressions.length || rawText.slice(1, -1) !== pattern) { - return null; - } - break; - default: - return null; - } - - const start = regexNode.range[0] + groupStart + 2; - - return [ - { - fix(fixer) { - const existingTemps = pattern.match(/temp\d+/gu) || []; - const highestTempCount = existingTemps.reduce( - (previous, next) => - Math.max(previous, Number(next.slice("temp".length))), - 0 - ); - - return fixer.insertTextBeforeRange( - [start, start], - `?` - ); - }, - messageId: "addGroupName" - }, - { - fix(fixer) { - return fixer.insertTextBeforeRange( - [start, start], - "?:" - ); - }, - messageId: "addNonCapture" - } - ]; -} - -//------------------------------------------------------------------------------ -// Rule Definition -//------------------------------------------------------------------------------ - -/** @type {import('../shared/types').Rule} */ -module.exports = { - meta: { - type: "suggestion", - - docs: { - description: "Enforce using named capture group in regular expression", - recommended: false, - url: "https://eslint.org/docs/latest/rules/prefer-named-capture-group" - }, - - hasSuggestions: true, - - schema: [], - - messages: { - addGroupName: "Add name to capture group.", - addNonCapture: "Convert group to non-capturing.", - required: "Capture group '{{group}}' should be converted to a named or non-capturing group." - } - }, - - create(context) { - const sourceCode = context.sourceCode; - - /** - * Function to check regular expression. - * @param {string} pattern The regular expression pattern to be checked. - * @param {ASTNode} node AST node which contains the regular expression or a call/new expression. - * @param {ASTNode} regexNode AST node which contains the regular expression. - * @param {string|null} flags The regular expression flags to be checked. - * @returns {void} - */ - function checkRegex(pattern, node, regexNode, flags) { - let ast; - - try { - ast = parser.parsePattern(pattern, 0, pattern.length, { - unicode: Boolean(flags && flags.includes("u")), - unicodeSets: Boolean(flags && flags.includes("v")) - }); - } catch { - - // ignore regex syntax errors - return; - } - - regexpp.visitRegExpAST(ast, { - onCapturingGroupEnter(group) { - if (!group.name) { - const rawText = sourceCode.getText(regexNode); - const suggest = suggestIfPossible(group.start, pattern, rawText, regexNode); - - context.report({ - node, - messageId: "required", - data: { - group: group.raw - }, - suggest - }); - } - } - }); - } - - return { - Literal(node) { - if (node.regex) { - checkRegex(node.regex.pattern, node, node, node.regex.flags); - } - }, - Program(node) { - const scope = sourceCode.getScope(node); - const tracker = new ReferenceTracker(scope); - const traceMap = { - RegExp: { - [CALL]: true, - [CONSTRUCT]: true - } - }; - - for (const { node: refNode } of tracker.iterateGlobalReferences(traceMap)) { - const regex = getStringIfConstant(refNode.arguments[0]); - const flags = getStringIfConstant(refNode.arguments[1]); - - if (regex) { - checkRegex(regex, refNode, refNode.arguments[0], flags); - } - } - } - }; - } -}; diff --git a/tools/eslint/node_modules/eslint/lib/rules/prefer-numeric-literals.js b/tools/eslint/node_modules/eslint/lib/rules/prefer-numeric-literals.js deleted file mode 100644 index 118d6dce4e352d..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/rules/prefer-numeric-literals.js +++ /dev/null @@ -1,148 +0,0 @@ -/** - * @fileoverview Rule to disallow `parseInt()` in favor of binary, octal, and hexadecimal literals - * @author Annie Zhang, Henry Zhu - */ - -"use strict"; - -//------------------------------------------------------------------------------ -// Requirements -//------------------------------------------------------------------------------ - -const astUtils = require("./utils/ast-utils"); - -//------------------------------------------------------------------------------ -// Helpers -//------------------------------------------------------------------------------ - -const radixMap = new Map([ - [2, { system: "binary", literalPrefix: "0b" }], - [8, { system: "octal", literalPrefix: "0o" }], - [16, { system: "hexadecimal", literalPrefix: "0x" }] -]); - -/** - * Checks to see if a CallExpression's callee node is `parseInt` or - * `Number.parseInt`. - * @param {ASTNode} calleeNode The callee node to evaluate. - * @returns {boolean} True if the callee is `parseInt` or `Number.parseInt`, - * false otherwise. - */ -function isParseInt(calleeNode) { - return ( - astUtils.isSpecificId(calleeNode, "parseInt") || - astUtils.isSpecificMemberAccess(calleeNode, "Number", "parseInt") - ); -} - -//------------------------------------------------------------------------------ -// Rule Definition -//------------------------------------------------------------------------------ - -/** @type {import('../shared/types').Rule} */ -module.exports = { - meta: { - type: "suggestion", - - docs: { - description: "Disallow `parseInt()` and `Number.parseInt()` in favor of binary, octal, and hexadecimal literals", - recommended: false, - url: "https://eslint.org/docs/latest/rules/prefer-numeric-literals" - }, - - schema: [], - - messages: { - useLiteral: "Use {{system}} literals instead of {{functionName}}()." - }, - - fixable: "code" - }, - - create(context) { - const sourceCode = context.sourceCode; - - //---------------------------------------------------------------------- - // Public - //---------------------------------------------------------------------- - - return { - - "CallExpression[arguments.length=2]"(node) { - const [strNode, radixNode] = node.arguments, - str = astUtils.getStaticStringValue(strNode), - radix = radixNode.value; - - if ( - str !== null && - astUtils.isStringLiteral(strNode) && - radixNode.type === "Literal" && - typeof radix === "number" && - radixMap.has(radix) && - isParseInt(node.callee) - ) { - - const { system, literalPrefix } = radixMap.get(radix); - - context.report({ - node, - messageId: "useLiteral", - data: { - system, - functionName: sourceCode.getText(node.callee) - }, - fix(fixer) { - if (sourceCode.getCommentsInside(node).length) { - return null; - } - - const replacement = `${literalPrefix}${str}`; - - if (+replacement !== parseInt(str, radix)) { - - /* - * If the newly-produced literal would be invalid, (e.g. 0b1234), - * or it would yield an incorrect parseInt result for some other reason, don't make a fix. - * - * If `str` had numeric separators, `+replacement` will evaluate to `NaN` because unary `+` - * per the specification doesn't support numeric separators. Thus, the above condition will be `true` - * (`NaN !== anything` is always `true`) regardless of the `parseInt(str, radix)` value. - * Consequently, no autofixes will be made. This is correct behavior because `parseInt` also - * doesn't support numeric separators, but it does parse part of the string before the first `_`, - * so the autofix would be invalid: - * - * parseInt("1_1", 2) // === 1 - * 0b1_1 // === 3 - */ - return null; - } - - const tokenBefore = sourceCode.getTokenBefore(node), - tokenAfter = sourceCode.getTokenAfter(node); - let prefix = "", - suffix = ""; - - if ( - tokenBefore && - tokenBefore.range[1] === node.range[0] && - !astUtils.canTokensBeAdjacent(tokenBefore, replacement) - ) { - prefix = " "; - } - - if ( - tokenAfter && - node.range[1] === tokenAfter.range[0] && - !astUtils.canTokensBeAdjacent(replacement, tokenAfter) - ) { - suffix = " "; - } - - return fixer.replaceText(node, `${prefix}${replacement}${suffix}`); - } - }); - } - } - }; - } -}; diff --git a/tools/eslint/node_modules/eslint/lib/rules/prefer-object-has-own.js b/tools/eslint/node_modules/eslint/lib/rules/prefer-object-has-own.js deleted file mode 100644 index 97ea64fa67351f..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/rules/prefer-object-has-own.js +++ /dev/null @@ -1,114 +0,0 @@ -/** - * @fileoverview Prefers Object.hasOwn() instead of Object.prototype.hasOwnProperty.call() - * @author Nitin Kumar - * @author Gautam Arora - */ - -"use strict"; - -//------------------------------------------------------------------------------ -// Requirements -//------------------------------------------------------------------------------ - -const astUtils = require("./utils/ast-utils"); - -//------------------------------------------------------------------------------ -// Helpers -//------------------------------------------------------------------------------ - -/** - * Checks if the given node is considered to be an access to a property of `Object.prototype`. - * @param {ASTNode} node `MemberExpression` node to evaluate. - * @returns {boolean} `true` if `node.object` is `Object`, `Object.prototype`, or `{}` (empty 'ObjectExpression' node). - */ -function hasLeftHandObject(node) { - - /* - * ({}).hasOwnProperty.call(obj, prop) - `true` - * ({ foo }.hasOwnProperty.call(obj, prop)) - `false`, object literal should be empty - */ - if (node.object.type === "ObjectExpression" && node.object.properties.length === 0) { - return true; - } - - const objectNodeToCheck = node.object.type === "MemberExpression" && astUtils.getStaticPropertyName(node.object) === "prototype" ? node.object.object : node.object; - - if (objectNodeToCheck.type === "Identifier" && objectNodeToCheck.name === "Object") { - return true; - } - - return false; -} - -//------------------------------------------------------------------------------ -// Rule Definition -//------------------------------------------------------------------------------ - -/** @type {import('../shared/types').Rule} */ -module.exports = { - meta: { - type: "suggestion", - docs: { - description: - "Disallow use of `Object.prototype.hasOwnProperty.call()` and prefer use of `Object.hasOwn()`", - recommended: false, - url: "https://eslint.org/docs/latest/rules/prefer-object-has-own" - }, - schema: [], - messages: { - useHasOwn: "Use 'Object.hasOwn()' instead of 'Object.prototype.hasOwnProperty.call()'." - }, - fixable: "code" - }, - create(context) { - - const sourceCode = context.sourceCode; - - return { - CallExpression(node) { - if (!(node.callee.type === "MemberExpression" && node.callee.object.type === "MemberExpression")) { - return; - } - - const calleePropertyName = astUtils.getStaticPropertyName(node.callee); - const objectPropertyName = astUtils.getStaticPropertyName(node.callee.object); - const isObject = hasLeftHandObject(node.callee.object); - - // check `Object` scope - const scope = sourceCode.getScope(node); - const variable = astUtils.getVariableByName(scope, "Object"); - - if ( - calleePropertyName === "call" && - objectPropertyName === "hasOwnProperty" && - isObject && - variable && variable.scope.type === "global" - ) { - context.report({ - node, - messageId: "useHasOwn", - fix(fixer) { - - if (sourceCode.getCommentsInside(node.callee).length > 0) { - return null; - } - - const tokenJustBeforeNode = sourceCode.getTokenBefore(node.callee, { includeComments: true }); - - // for https://github.com/eslint/eslint/pull/15346#issuecomment-991417335 - if ( - tokenJustBeforeNode && - tokenJustBeforeNode.range[1] === node.callee.range[0] && - !astUtils.canTokensBeAdjacent(tokenJustBeforeNode, "Object.hasOwn") - ) { - return fixer.replaceText(node.callee, " Object.hasOwn"); - } - - return fixer.replaceText(node.callee, "Object.hasOwn"); - } - }); - } - } - }; - } -}; diff --git a/tools/eslint/node_modules/eslint/lib/rules/prefer-object-spread.js b/tools/eslint/node_modules/eslint/lib/rules/prefer-object-spread.js deleted file mode 100644 index 60b0c3175c017a..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/rules/prefer-object-spread.js +++ /dev/null @@ -1,298 +0,0 @@ -/** - * @fileoverview Prefers object spread property over Object.assign - * @author Sharmila Jesupaul - */ - -"use strict"; - -const { CALL, ReferenceTracker } = require("@eslint-community/eslint-utils"); -const { - isCommaToken, - isOpeningParenToken, - isClosingParenToken, - isParenthesised -} = require("./utils/ast-utils"); - -const ANY_SPACE = /\s/u; - -/** - * Helper that checks if the Object.assign call has array spread - * @param {ASTNode} node The node that the rule warns on - * @returns {boolean} - Returns true if the Object.assign call has array spread - */ -function hasArraySpread(node) { - return node.arguments.some(arg => arg.type === "SpreadElement"); -} - -/** - * Determines whether the given node is an accessor property (getter/setter). - * @param {ASTNode} node Node to check. - * @returns {boolean} `true` if the node is a getter or a setter. - */ -function isAccessorProperty(node) { - return node.type === "Property" && - (node.kind === "get" || node.kind === "set"); -} - -/** - * Determines whether the given object expression node has accessor properties (getters/setters). - * @param {ASTNode} node `ObjectExpression` node to check. - * @returns {boolean} `true` if the node has at least one getter/setter. - */ -function hasAccessors(node) { - return node.properties.some(isAccessorProperty); -} - -/** - * Determines whether the given call expression node has object expression arguments with accessor properties (getters/setters). - * @param {ASTNode} node `CallExpression` node to check. - * @returns {boolean} `true` if the node has at least one argument that is an object expression with at least one getter/setter. - */ -function hasArgumentsWithAccessors(node) { - return node.arguments - .filter(arg => arg.type === "ObjectExpression") - .some(hasAccessors); -} - -/** - * Helper that checks if the node needs parentheses to be valid JS. - * The default is to wrap the node in parentheses to avoid parsing errors. - * @param {ASTNode} node The node that the rule warns on - * @param {Object} sourceCode in context sourcecode object - * @returns {boolean} - Returns true if the node needs parentheses - */ -function needsParens(node, sourceCode) { - const parent = node.parent; - - switch (parent.type) { - case "VariableDeclarator": - case "ArrayExpression": - case "ReturnStatement": - case "CallExpression": - case "Property": - return false; - case "AssignmentExpression": - return parent.left === node && !isParenthesised(sourceCode, node); - default: - return !isParenthesised(sourceCode, node); - } -} - -/** - * Determines if an argument needs parentheses. The default is to not add parens. - * @param {ASTNode} node The node to be checked. - * @param {Object} sourceCode in context sourcecode object - * @returns {boolean} True if the node needs parentheses - */ -function argNeedsParens(node, sourceCode) { - switch (node.type) { - case "AssignmentExpression": - case "ArrowFunctionExpression": - case "ConditionalExpression": - return !isParenthesised(sourceCode, node); - default: - return false; - } -} - -/** - * Get the parenthesis tokens of a given ObjectExpression node. - * This includes the braces of the object literal and enclosing parentheses. - * @param {ASTNode} node The node to get. - * @param {Token} leftArgumentListParen The opening paren token of the argument list. - * @param {SourceCode} sourceCode The source code object to get tokens. - * @returns {Token[]} The parenthesis tokens of the node. This is sorted by the location. - */ -function getParenTokens(node, leftArgumentListParen, sourceCode) { - const parens = [sourceCode.getFirstToken(node), sourceCode.getLastToken(node)]; - let leftNext = sourceCode.getTokenBefore(node); - let rightNext = sourceCode.getTokenAfter(node); - - // Note: don't include the parens of the argument list. - while ( - leftNext && - rightNext && - leftNext.range[0] > leftArgumentListParen.range[0] && - isOpeningParenToken(leftNext) && - isClosingParenToken(rightNext) - ) { - parens.push(leftNext, rightNext); - leftNext = sourceCode.getTokenBefore(leftNext); - rightNext = sourceCode.getTokenAfter(rightNext); - } - - return parens.sort((a, b) => a.range[0] - b.range[0]); -} - -/** - * Get the range of a given token and around whitespaces. - * @param {Token} token The token to get range. - * @param {SourceCode} sourceCode The source code object to get tokens. - * @returns {number} The end of the range of the token and around whitespaces. - */ -function getStartWithSpaces(token, sourceCode) { - const text = sourceCode.text; - let start = token.range[0]; - - // If the previous token is a line comment then skip this step to avoid commenting this token out. - { - const prevToken = sourceCode.getTokenBefore(token, { includeComments: true }); - - if (prevToken && prevToken.type === "Line") { - return start; - } - } - - // Detect spaces before the token. - while (ANY_SPACE.test(text[start - 1] || "")) { - start -= 1; - } - - return start; -} - -/** - * Get the range of a given token and around whitespaces. - * @param {Token} token The token to get range. - * @param {SourceCode} sourceCode The source code object to get tokens. - * @returns {number} The start of the range of the token and around whitespaces. - */ -function getEndWithSpaces(token, sourceCode) { - const text = sourceCode.text; - let end = token.range[1]; - - // Detect spaces after the token. - while (ANY_SPACE.test(text[end] || "")) { - end += 1; - } - - return end; -} - -/** - * Autofixes the Object.assign call to use an object spread instead. - * @param {ASTNode|null} node The node that the rule warns on, i.e. the Object.assign call - * @param {string} sourceCode sourceCode of the Object.assign call - * @returns {Function} autofixer - replaces the Object.assign with a spread object. - */ -function defineFixer(node, sourceCode) { - return function *(fixer) { - const leftParen = sourceCode.getTokenAfter(node.callee, isOpeningParenToken); - const rightParen = sourceCode.getLastToken(node); - - // Remove everything before the opening paren: callee `Object.assign`, type arguments, and whitespace between the callee and the paren. - yield fixer.removeRange([node.range[0], leftParen.range[0]]); - - // Replace the parens of argument list to braces. - if (needsParens(node, sourceCode)) { - yield fixer.replaceText(leftParen, "({"); - yield fixer.replaceText(rightParen, "})"); - } else { - yield fixer.replaceText(leftParen, "{"); - yield fixer.replaceText(rightParen, "}"); - } - - // Process arguments. - for (const argNode of node.arguments) { - const innerParens = getParenTokens(argNode, leftParen, sourceCode); - const left = innerParens.shift(); - const right = innerParens.pop(); - - if (argNode.type === "ObjectExpression") { - const maybeTrailingComma = sourceCode.getLastToken(argNode, 1); - const maybeArgumentComma = sourceCode.getTokenAfter(right); - - /* - * Make bare this object literal. - * And remove spaces inside of the braces for better formatting. - */ - for (const innerParen of innerParens) { - yield fixer.remove(innerParen); - } - const leftRange = [left.range[0], getEndWithSpaces(left, sourceCode)]; - const rightRange = [ - Math.max(getStartWithSpaces(right, sourceCode), leftRange[1]), // Ensure ranges don't overlap - right.range[1] - ]; - - yield fixer.removeRange(leftRange); - yield fixer.removeRange(rightRange); - - // Remove the comma of this argument if it's duplication. - if ( - (argNode.properties.length === 0 || isCommaToken(maybeTrailingComma)) && - isCommaToken(maybeArgumentComma) - ) { - yield fixer.remove(maybeArgumentComma); - } - } else { - - // Make spread. - if (argNeedsParens(argNode, sourceCode)) { - yield fixer.insertTextBefore(left, "...("); - yield fixer.insertTextAfter(right, ")"); - } else { - yield fixer.insertTextBefore(left, "..."); - } - } - } - }; -} - -/** @type {import('../shared/types').Rule} */ -module.exports = { - meta: { - type: "suggestion", - - docs: { - description: - "Disallow using Object.assign with an object literal as the first argument and prefer the use of object spread instead", - recommended: false, - url: "https://eslint.org/docs/latest/rules/prefer-object-spread" - }, - - schema: [], - fixable: "code", - - messages: { - useSpreadMessage: "Use an object spread instead of `Object.assign` eg: `{ ...foo }`.", - useLiteralMessage: "Use an object literal instead of `Object.assign`. eg: `{ foo: bar }`." - } - }, - - create(context) { - const sourceCode = context.sourceCode; - - return { - Program(node) { - const scope = sourceCode.getScope(node); - const tracker = new ReferenceTracker(scope); - const trackMap = { - Object: { - assign: { [CALL]: true } - } - }; - - // Iterate all calls of `Object.assign` (only of the global variable `Object`). - for (const { node: refNode } of tracker.iterateGlobalReferences(trackMap)) { - if ( - refNode.arguments.length >= 1 && - refNode.arguments[0].type === "ObjectExpression" && - !hasArraySpread(refNode) && - !( - refNode.arguments.length > 1 && - hasArgumentsWithAccessors(refNode) - ) - ) { - const messageId = refNode.arguments.length === 1 - ? "useLiteralMessage" - : "useSpreadMessage"; - const fix = defineFixer(refNode, sourceCode); - - context.report({ node: refNode, messageId, fix }); - } - } - } - }; - } -}; diff --git a/tools/eslint/node_modules/eslint/lib/rules/prefer-promise-reject-errors.js b/tools/eslint/node_modules/eslint/lib/rules/prefer-promise-reject-errors.js deleted file mode 100644 index e990265e99fb5d..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/rules/prefer-promise-reject-errors.js +++ /dev/null @@ -1,132 +0,0 @@ -/** - * @fileoverview restrict values that can be used as Promise rejection reasons - * @author Teddy Katz - */ -"use strict"; - -const astUtils = require("./utils/ast-utils"); - -//------------------------------------------------------------------------------ -// Rule Definition -//------------------------------------------------------------------------------ - -/** @type {import('../shared/types').Rule} */ -module.exports = { - meta: { - type: "suggestion", - - docs: { - description: "Require using Error objects as Promise rejection reasons", - recommended: false, - url: "https://eslint.org/docs/latest/rules/prefer-promise-reject-errors" - }, - - fixable: null, - - schema: [ - { - type: "object", - properties: { - allowEmptyReject: { type: "boolean", default: false } - }, - additionalProperties: false - } - ], - - messages: { - rejectAnError: "Expected the Promise rejection reason to be an Error." - } - }, - - create(context) { - - const ALLOW_EMPTY_REJECT = context.options.length && context.options[0].allowEmptyReject; - const sourceCode = context.sourceCode; - - //---------------------------------------------------------------------- - // Helpers - //---------------------------------------------------------------------- - - /** - * Checks the argument of a reject() or Promise.reject() CallExpression, and reports it if it can't be an Error - * @param {ASTNode} callExpression A CallExpression node which is used to reject a Promise - * @returns {void} - */ - function checkRejectCall(callExpression) { - if (!callExpression.arguments.length && ALLOW_EMPTY_REJECT) { - return; - } - if ( - !callExpression.arguments.length || - !astUtils.couldBeError(callExpression.arguments[0]) || - callExpression.arguments[0].type === "Identifier" && callExpression.arguments[0].name === "undefined" - ) { - context.report({ - node: callExpression, - messageId: "rejectAnError" - }); - } - } - - /** - * Determines whether a function call is a Promise.reject() call - * @param {ASTNode} node A CallExpression node - * @returns {boolean} `true` if the call is a Promise.reject() call - */ - function isPromiseRejectCall(node) { - return astUtils.isSpecificMemberAccess(node.callee, "Promise", "reject"); - } - - //---------------------------------------------------------------------- - // Public - //---------------------------------------------------------------------- - - return { - - // Check `Promise.reject(value)` calls. - CallExpression(node) { - if (isPromiseRejectCall(node)) { - checkRejectCall(node); - } - }, - - /* - * Check for `new Promise((resolve, reject) => {})`, and check for reject() calls. - * This function is run on "NewExpression:exit" instead of "NewExpression" to ensure that - * the nodes in the expression already have the `parent` property. - */ - "NewExpression:exit"(node) { - if ( - node.callee.type === "Identifier" && node.callee.name === "Promise" && - node.arguments.length && astUtils.isFunction(node.arguments[0]) && - node.arguments[0].params.length > 1 && node.arguments[0].params[1].type === "Identifier" - ) { - sourceCode.getDeclaredVariables(node.arguments[0]) - - /* - * Find the first variable that matches the second parameter's name. - * If the first parameter has the same name as the second parameter, then the variable will actually - * be "declared" when the first parameter is evaluated, but then it will be immediately overwritten - * by the second parameter. It's not possible for an expression with the variable to be evaluated before - * the variable is overwritten, because functions with duplicate parameters cannot have destructuring or - * default assignments in their parameter lists. Therefore, it's not necessary to explicitly account for - * this case. - */ - .find(variable => variable.name === node.arguments[0].params[1].name) - - // Get the references to that variable. - .references - - // Only check the references that read the parameter's value. - .filter(ref => ref.isRead()) - - // Only check the references that are used as the callee in a function call, e.g. `reject(foo)`. - .filter(ref => ref.identifier.parent.type === "CallExpression" && ref.identifier === ref.identifier.parent.callee) - - // Check the argument of the function call to determine whether it's an Error. - .forEach(ref => checkRejectCall(ref.identifier.parent)); - } - } - }; - } -}; diff --git a/tools/eslint/node_modules/eslint/lib/rules/prefer-reflect.js b/tools/eslint/node_modules/eslint/lib/rules/prefer-reflect.js deleted file mode 100644 index 7da45237c89762..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/rules/prefer-reflect.js +++ /dev/null @@ -1,127 +0,0 @@ -/** - * @fileoverview Rule to suggest using "Reflect" api over Function/Object methods - * @author Keith Cirkel - * @deprecated in ESLint v3.9.0 - */ -"use strict"; - -//------------------------------------------------------------------------------ -// Rule Definition -//------------------------------------------------------------------------------ - -/** @type {import('../shared/types').Rule} */ -module.exports = { - meta: { - type: "suggestion", - - docs: { - description: "Require `Reflect` methods where applicable", - recommended: false, - url: "https://eslint.org/docs/latest/rules/prefer-reflect" - }, - - deprecated: true, - - replacedBy: [], - - schema: [ - { - type: "object", - properties: { - exceptions: { - type: "array", - items: { - enum: [ - "apply", - "call", - "delete", - "defineProperty", - "getOwnPropertyDescriptor", - "getPrototypeOf", - "setPrototypeOf", - "isExtensible", - "getOwnPropertyNames", - "preventExtensions" - ] - }, - uniqueItems: true - } - }, - additionalProperties: false - } - ], - - messages: { - preferReflect: "Avoid using {{existing}}, instead use {{substitute}}." - } - }, - - create(context) { - const existingNames = { - apply: "Function.prototype.apply", - call: "Function.prototype.call", - defineProperty: "Object.defineProperty", - getOwnPropertyDescriptor: "Object.getOwnPropertyDescriptor", - getPrototypeOf: "Object.getPrototypeOf", - setPrototypeOf: "Object.setPrototypeOf", - isExtensible: "Object.isExtensible", - getOwnPropertyNames: "Object.getOwnPropertyNames", - preventExtensions: "Object.preventExtensions" - }; - - const reflectSubstitutes = { - apply: "Reflect.apply", - call: "Reflect.apply", - defineProperty: "Reflect.defineProperty", - getOwnPropertyDescriptor: "Reflect.getOwnPropertyDescriptor", - getPrototypeOf: "Reflect.getPrototypeOf", - setPrototypeOf: "Reflect.setPrototypeOf", - isExtensible: "Reflect.isExtensible", - getOwnPropertyNames: "Reflect.getOwnPropertyNames", - preventExtensions: "Reflect.preventExtensions" - }; - - const exceptions = (context.options[0] || {}).exceptions || []; - - /** - * Reports the Reflect violation based on the `existing` and `substitute` - * @param {Object} node The node that violates the rule. - * @param {string} existing The existing method name that has been used. - * @param {string} substitute The Reflect substitute that should be used. - * @returns {void} - */ - function report(node, existing, substitute) { - context.report({ - node, - messageId: "preferReflect", - data: { - existing, - substitute - } - }); - } - - return { - CallExpression(node) { - const methodName = (node.callee.property || {}).name; - const isReflectCall = (node.callee.object || {}).name === "Reflect"; - const hasReflectSubstitute = Object.hasOwn(reflectSubstitutes, methodName); - const userConfiguredException = exceptions.includes(methodName); - - if (hasReflectSubstitute && !isReflectCall && !userConfiguredException) { - report(node, existingNames[methodName], reflectSubstitutes[methodName]); - } - }, - UnaryExpression(node) { - const isDeleteOperator = node.operator === "delete"; - const targetsIdentifier = node.argument.type === "Identifier"; - const userConfiguredException = exceptions.includes("delete"); - - if (isDeleteOperator && !targetsIdentifier && !userConfiguredException) { - report(node, "the delete keyword", "Reflect.deleteProperty"); - } - } - }; - - } -}; diff --git a/tools/eslint/node_modules/eslint/lib/rules/prefer-regex-literals.js b/tools/eslint/node_modules/eslint/lib/rules/prefer-regex-literals.js deleted file mode 100644 index dd18f7ec2e3a91..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/rules/prefer-regex-literals.js +++ /dev/null @@ -1,507 +0,0 @@ -/** - * @fileoverview Rule to disallow use of the `RegExp` constructor in favor of regular expression literals - * @author Milos Djermanovic - */ - -"use strict"; - -//------------------------------------------------------------------------------ -// Requirements -//------------------------------------------------------------------------------ - -const astUtils = require("./utils/ast-utils"); -const { CALL, CONSTRUCT, ReferenceTracker, findVariable } = require("@eslint-community/eslint-utils"); -const { RegExpValidator, visitRegExpAST, RegExpParser } = require("@eslint-community/regexpp"); -const { canTokensBeAdjacent } = require("./utils/ast-utils"); -const { REGEXPP_LATEST_ECMA_VERSION } = require("./utils/regular-expressions"); - -//------------------------------------------------------------------------------ -// Helpers -//------------------------------------------------------------------------------ - -/** - * Determines whether the given node is a string literal. - * @param {ASTNode} node Node to check. - * @returns {boolean} True if the node is a string literal. - */ -function isStringLiteral(node) { - return node.type === "Literal" && typeof node.value === "string"; -} - -/** - * Determines whether the given node is a regex literal. - * @param {ASTNode} node Node to check. - * @returns {boolean} True if the node is a regex literal. - */ -function isRegexLiteral(node) { - return node.type === "Literal" && Object.hasOwn(node, "regex"); -} - -const validPrecedingTokens = new Set([ - "(", - ";", - "[", - ",", - "=", - "+", - "*", - "-", - "?", - "~", - "%", - "**", - "!", - "typeof", - "instanceof", - "&&", - "||", - "??", - "return", - "...", - "delete", - "void", - "in", - "<", - ">", - "<=", - ">=", - "==", - "===", - "!=", - "!==", - "<<", - ">>", - ">>>", - "&", - "|", - "^", - ":", - "{", - "=>", - "*=", - "<<=", - ">>=", - ">>>=", - "^=", - "|=", - "&=", - "??=", - "||=", - "&&=", - "**=", - "+=", - "-=", - "/=", - "%=", - "/", - "do", - "break", - "continue", - "debugger", - "case", - "throw" -]); - - -//------------------------------------------------------------------------------ -// Rule Definition -//------------------------------------------------------------------------------ - -/** @type {import('../shared/types').Rule} */ -module.exports = { - meta: { - type: "suggestion", - - docs: { - description: "Disallow use of the `RegExp` constructor in favor of regular expression literals", - recommended: false, - url: "https://eslint.org/docs/latest/rules/prefer-regex-literals" - }, - - hasSuggestions: true, - - schema: [ - { - type: "object", - properties: { - disallowRedundantWrapping: { - type: "boolean", - default: false - } - }, - additionalProperties: false - } - ], - - messages: { - unexpectedRegExp: "Use a regular expression literal instead of the 'RegExp' constructor.", - replaceWithLiteral: "Replace with an equivalent regular expression literal.", - replaceWithLiteralAndFlags: "Replace with an equivalent regular expression literal with flags '{{ flags }}'.", - replaceWithIntendedLiteralAndFlags: "Replace with a regular expression literal with flags '{{ flags }}'.", - unexpectedRedundantRegExp: "Regular expression literal is unnecessarily wrapped within a 'RegExp' constructor.", - unexpectedRedundantRegExpWithFlags: "Use regular expression literal with flags instead of the 'RegExp' constructor." - } - }, - - create(context) { - const [{ disallowRedundantWrapping = false } = {}] = context.options; - const sourceCode = context.sourceCode; - - /** - * Determines whether the given identifier node is a reference to a global variable. - * @param {ASTNode} node `Identifier` node to check. - * @returns {boolean} True if the identifier is a reference to a global variable. - */ - function isGlobalReference(node) { - const scope = sourceCode.getScope(node); - const variable = findVariable(scope, node); - - return variable !== null && variable.scope.type === "global" && variable.defs.length === 0; - } - - /** - * Determines whether the given node is a String.raw`` tagged template expression - * with a static template literal. - * @param {ASTNode} node Node to check. - * @returns {boolean} True if the node is String.raw`` with a static template. - */ - function isStringRawTaggedStaticTemplateLiteral(node) { - return node.type === "TaggedTemplateExpression" && - astUtils.isSpecificMemberAccess(node.tag, "String", "raw") && - isGlobalReference(astUtils.skipChainExpression(node.tag).object) && - astUtils.isStaticTemplateLiteral(node.quasi); - } - - /** - * Gets the value of a string - * @param {ASTNode} node The node to get the string of. - * @returns {string|null} The value of the node. - */ - function getStringValue(node) { - if (isStringLiteral(node)) { - return node.value; - } - - if (astUtils.isStaticTemplateLiteral(node)) { - return node.quasis[0].value.cooked; - } - - if (isStringRawTaggedStaticTemplateLiteral(node)) { - return node.quasi.quasis[0].value.raw; - } - - return null; - } - - /** - * Determines whether the given node is considered to be a static string by the logic of this rule. - * @param {ASTNode} node Node to check. - * @returns {boolean} True if the node is a static string. - */ - function isStaticString(node) { - return isStringLiteral(node) || - astUtils.isStaticTemplateLiteral(node) || - isStringRawTaggedStaticTemplateLiteral(node); - } - - /** - * Determines whether the relevant arguments of the given are all static string literals. - * @param {ASTNode} node Node to check. - * @returns {boolean} True if all arguments are static strings. - */ - function hasOnlyStaticStringArguments(node) { - const args = node.arguments; - - if ((args.length === 1 || args.length === 2) && args.every(isStaticString)) { - return true; - } - - return false; - } - - /** - * Determines whether the arguments of the given node indicate that a regex literal is unnecessarily wrapped. - * @param {ASTNode} node Node to check. - * @returns {boolean} True if the node already contains a regex literal argument. - */ - function isUnnecessarilyWrappedRegexLiteral(node) { - const args = node.arguments; - - if (args.length === 1 && isRegexLiteral(args[0])) { - return true; - } - - if (args.length === 2 && isRegexLiteral(args[0]) && isStaticString(args[1])) { - return true; - } - - return false; - } - - /** - * Returns a ecmaVersion compatible for regexpp. - * @param {number} ecmaVersion The ecmaVersion to convert. - * @returns {import("@eslint-community/regexpp/ecma-versions").EcmaVersion} The resulting ecmaVersion compatible for regexpp. - */ - function getRegexppEcmaVersion(ecmaVersion) { - if (ecmaVersion <= 5) { - return 5; - } - return Math.min(ecmaVersion, REGEXPP_LATEST_ECMA_VERSION); - } - - const regexppEcmaVersion = getRegexppEcmaVersion(context.languageOptions.ecmaVersion); - - /** - * Makes a character escaped or else returns null. - * @param {string} character The character to escape. - * @returns {string} The resulting escaped character. - */ - function resolveEscapes(character) { - switch (character) { - case "\n": - case "\\\n": - return "\\n"; - - case "\r": - case "\\\r": - return "\\r"; - - case "\t": - case "\\\t": - return "\\t"; - - case "\v": - case "\\\v": - return "\\v"; - - case "\f": - case "\\\f": - return "\\f"; - - case "/": - return "\\/"; - - default: - return null; - } - } - - /** - * Checks whether the given regex and flags are valid for the ecma version or not. - * @param {string} pattern The regex pattern to check. - * @param {string | undefined} flags The regex flags to check. - * @returns {boolean} True if the given regex pattern and flags are valid for the ecma version. - */ - function isValidRegexForEcmaVersion(pattern, flags) { - const validator = new RegExpValidator({ ecmaVersion: regexppEcmaVersion }); - - try { - validator.validatePattern(pattern, 0, pattern.length, { - unicode: flags ? flags.includes("u") : false, - unicodeSets: flags ? flags.includes("v") : false - }); - if (flags) { - validator.validateFlags(flags); - } - return true; - } catch { - return false; - } - } - - /** - * Checks whether two given regex flags contain the same flags or not. - * @param {string} flagsA The regex flags. - * @param {string} flagsB The regex flags. - * @returns {boolean} True if two regex flags contain same flags. - */ - function areFlagsEqual(flagsA, flagsB) { - return [...flagsA].sort().join("") === [...flagsB].sort().join(""); - } - - - /** - * Merges two regex flags. - * @param {string} flagsA The regex flags. - * @param {string} flagsB The regex flags. - * @returns {string} The merged regex flags. - */ - function mergeRegexFlags(flagsA, flagsB) { - const flagsSet = new Set([ - ...flagsA, - ...flagsB - ]); - - return [...flagsSet].join(""); - } - - /** - * Checks whether a give node can be fixed to the given regex pattern and flags. - * @param {ASTNode} node The node to check. - * @param {string} pattern The regex pattern to check. - * @param {string} flags The regex flags - * @returns {boolean} True if a node can be fixed to the given regex pattern and flags. - */ - function canFixTo(node, pattern, flags) { - const tokenBefore = sourceCode.getTokenBefore(node); - - return sourceCode.getCommentsInside(node).length === 0 && - (!tokenBefore || validPrecedingTokens.has(tokenBefore.value)) && - isValidRegexForEcmaVersion(pattern, flags); - } - - /** - * Returns a safe output code considering the before and after tokens. - * @param {ASTNode} node The regex node. - * @param {string} newRegExpValue The new regex expression value. - * @returns {string} The output code. - */ - function getSafeOutput(node, newRegExpValue) { - const tokenBefore = sourceCode.getTokenBefore(node); - const tokenAfter = sourceCode.getTokenAfter(node); - - return (tokenBefore && !canTokensBeAdjacent(tokenBefore, newRegExpValue) && tokenBefore.range[1] === node.range[0] ? " " : "") + - newRegExpValue + - (tokenAfter && !canTokensBeAdjacent(newRegExpValue, tokenAfter) && node.range[1] === tokenAfter.range[0] ? " " : ""); - - } - - return { - Program(node) { - const scope = sourceCode.getScope(node); - const tracker = new ReferenceTracker(scope); - const traceMap = { - RegExp: { - [CALL]: true, - [CONSTRUCT]: true - } - }; - - for (const { node: refNode } of tracker.iterateGlobalReferences(traceMap)) { - if (disallowRedundantWrapping && isUnnecessarilyWrappedRegexLiteral(refNode)) { - const regexNode = refNode.arguments[0]; - - if (refNode.arguments.length === 2) { - const suggests = []; - - const argFlags = getStringValue(refNode.arguments[1]) || ""; - - if (canFixTo(refNode, regexNode.regex.pattern, argFlags)) { - suggests.push({ - messageId: "replaceWithLiteralAndFlags", - pattern: regexNode.regex.pattern, - flags: argFlags - }); - } - - const literalFlags = regexNode.regex.flags || ""; - const mergedFlags = mergeRegexFlags(literalFlags, argFlags); - - if ( - !areFlagsEqual(mergedFlags, argFlags) && - canFixTo(refNode, regexNode.regex.pattern, mergedFlags) - ) { - suggests.push({ - messageId: "replaceWithIntendedLiteralAndFlags", - pattern: regexNode.regex.pattern, - flags: mergedFlags - }); - } - - context.report({ - node: refNode, - messageId: "unexpectedRedundantRegExpWithFlags", - suggest: suggests.map(({ flags, pattern, messageId }) => ({ - messageId, - data: { - flags - }, - fix(fixer) { - return fixer.replaceText(refNode, getSafeOutput(refNode, `/${pattern}/${flags}`)); - } - })) - }); - } else { - const outputs = []; - - if (canFixTo(refNode, regexNode.regex.pattern, regexNode.regex.flags)) { - outputs.push(sourceCode.getText(regexNode)); - } - - - context.report({ - node: refNode, - messageId: "unexpectedRedundantRegExp", - suggest: outputs.map(output => ({ - messageId: "replaceWithLiteral", - fix(fixer) { - return fixer.replaceText( - refNode, - getSafeOutput(refNode, output) - ); - } - })) - }); - } - } else if (hasOnlyStaticStringArguments(refNode)) { - let regexContent = getStringValue(refNode.arguments[0]); - let noFix = false; - let flags; - - if (refNode.arguments[1]) { - flags = getStringValue(refNode.arguments[1]); - } - - if (!canFixTo(refNode, regexContent, flags)) { - noFix = true; - } - - if (!/^[-a-zA-Z0-9\\[\](){} \t\r\n\v\f!@#$%^&*+^_=/~`.> accumulator + sourceText.slice(token.range[1], allTokens[index + 1].range[0]), ""); - } - - /** - * Returns a template literal form of the given node. - * @param {ASTNode} currentNode A node that should be converted to a template literal - * @param {string} textBeforeNode Text that should appear before the node - * @param {string} textAfterNode Text that should appear after the node - * @returns {string} A string form of this node, represented as a template literal - */ - function getTemplateLiteral(currentNode, textBeforeNode, textAfterNode) { - if (currentNode.type === "Literal" && typeof currentNode.value === "string") { - - /* - * If the current node is a string literal, escape any instances of ${ or ` to prevent them from being interpreted - * as a template placeholder. However, if the code already contains a backslash before the ${ or ` - * for some reason, don't add another backslash, because that would change the meaning of the code (it would cause - * an actual backslash character to appear before the dollar sign). - */ - return `\`${currentNode.raw.slice(1, -1).replace(/\\*(\$\{|`)/gu, matched => { - if (matched.lastIndexOf("\\") % 2) { - return `\\${matched}`; - } - return matched; - - // Unescape any quotes that appear in the original Literal that no longer need to be escaped. - }).replace(new RegExp(`\\\\${currentNode.raw[0]}`, "gu"), currentNode.raw[0])}\``; - } - - if (currentNode.type === "TemplateLiteral") { - return sourceCode.getText(currentNode); - } - - if (isConcatenation(currentNode) && hasStringLiteral(currentNode)) { - const plusSign = sourceCode.getFirstTokenBetween(currentNode.left, currentNode.right, token => token.value === "+"); - const textBeforePlus = getTextBetween(currentNode.left, plusSign); - const textAfterPlus = getTextBetween(plusSign, currentNode.right); - const leftEndsWithCurly = endsWithTemplateCurly(currentNode.left); - const rightStartsWithCurly = startsWithTemplateCurly(currentNode.right); - - if (leftEndsWithCurly) { - - // If the left side of the expression ends with a template curly, add the extra text to the end of the curly bracket. - // `foo${bar}` /* comment */ + 'baz' --> `foo${bar /* comment */ }${baz}` - return getTemplateLiteral(currentNode.left, textBeforeNode, textBeforePlus + textAfterPlus).slice(0, -1) + - getTemplateLiteral(currentNode.right, null, textAfterNode).slice(1); - } - if (rightStartsWithCurly) { - - // Otherwise, if the right side of the expression starts with a template curly, add the text there. - // 'foo' /* comment */ + `${bar}baz` --> `foo${ /* comment */ bar}baz` - return getTemplateLiteral(currentNode.left, textBeforeNode, null).slice(0, -1) + - getTemplateLiteral(currentNode.right, textBeforePlus + textAfterPlus, textAfterNode).slice(1); - } - - /* - * Otherwise, these nodes should not be combined into a template curly, since there is nowhere to put - * the text between them. - */ - return `${getTemplateLiteral(currentNode.left, textBeforeNode, null)}${textBeforePlus}+${textAfterPlus}${getTemplateLiteral(currentNode.right, textAfterNode, null)}`; - } - - return `\`\${${textBeforeNode || ""}${sourceCode.getText(currentNode)}${textAfterNode || ""}}\``; - } - - /** - * Returns a fixer object that converts a non-string binary expression to a template literal - * @param {SourceCodeFixer} fixer The fixer object - * @param {ASTNode} node A node that should be converted to a template literal - * @returns {Object} A fix for this binary expression - */ - function fixNonStringBinaryExpression(fixer, node) { - const topBinaryExpr = getTopConcatBinaryExpression(node.parent); - - if (hasOctalOrNonOctalDecimalEscapeSequence(topBinaryExpr)) { - return null; - } - - return fixer.replaceText(topBinaryExpr, getTemplateLiteral(topBinaryExpr, null, null)); - } - - /** - * Reports if a given node is string concatenation with non string literals. - * @param {ASTNode} node A node to check. - * @returns {void} - */ - function checkForStringConcat(node) { - if (!astUtils.isStringLiteral(node) || !isConcatenation(node.parent)) { - return; - } - - const topBinaryExpr = getTopConcatBinaryExpression(node.parent); - - // Checks whether or not this node had been checked already. - if (done[topBinaryExpr.range[0]]) { - return; - } - done[topBinaryExpr.range[0]] = true; - - if (hasNonStringLiteral(topBinaryExpr)) { - context.report({ - node: topBinaryExpr, - messageId: "unexpectedStringConcatenation", - fix: fixer => fixNonStringBinaryExpression(fixer, node) - }); - } - } - - return { - Program() { - done = Object.create(null); - }, - - Literal: checkForStringConcat, - TemplateLiteral: checkForStringConcat - }; - } -}; diff --git a/tools/eslint/node_modules/eslint/lib/rules/quote-props.js b/tools/eslint/node_modules/eslint/lib/rules/quote-props.js deleted file mode 100644 index fe26eed77de580..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/rules/quote-props.js +++ /dev/null @@ -1,310 +0,0 @@ -/** - * @fileoverview Rule to flag non-quoted property names in object literals. - * @author Mathias Bynens - * @deprecated in ESLint v8.53.0 - */ -"use strict"; - -//------------------------------------------------------------------------------ -// Requirements -//------------------------------------------------------------------------------ - -const espree = require("espree"); -const astUtils = require("./utils/ast-utils"); -const keywords = require("./utils/keywords"); - -//------------------------------------------------------------------------------ -// Rule Definition -//------------------------------------------------------------------------------ - -/** @type {import('../shared/types').Rule} */ -module.exports = { - meta: { - deprecated: true, - replacedBy: [], - type: "suggestion", - - docs: { - description: "Require quotes around object literal property names", - recommended: false, - url: "https://eslint.org/docs/latest/rules/quote-props" - }, - - schema: { - anyOf: [ - { - type: "array", - items: [ - { - enum: ["always", "as-needed", "consistent", "consistent-as-needed"] - } - ], - minItems: 0, - maxItems: 1 - }, - { - type: "array", - items: [ - { - enum: ["always", "as-needed", "consistent", "consistent-as-needed"] - }, - { - type: "object", - properties: { - keywords: { - type: "boolean" - }, - unnecessary: { - type: "boolean" - }, - numbers: { - type: "boolean" - } - }, - additionalProperties: false - } - ], - minItems: 0, - maxItems: 2 - } - ] - }, - - fixable: "code", - messages: { - requireQuotesDueToReservedWord: "Properties should be quoted as '{{property}}' is a reserved word.", - inconsistentlyQuotedProperty: "Inconsistently quoted property '{{key}}' found.", - unnecessarilyQuotedProperty: "Unnecessarily quoted property '{{property}}' found.", - unquotedReservedProperty: "Unquoted reserved word '{{property}}' used as key.", - unquotedNumericProperty: "Unquoted number literal '{{property}}' used as key.", - unquotedPropertyFound: "Unquoted property '{{property}}' found.", - redundantQuoting: "Properties shouldn't be quoted as all quotes are redundant." - } - }, - - create(context) { - - const MODE = context.options[0], - KEYWORDS = context.options[1] && context.options[1].keywords, - CHECK_UNNECESSARY = !context.options[1] || context.options[1].unnecessary !== false, - NUMBERS = context.options[1] && context.options[1].numbers, - - sourceCode = context.sourceCode; - - - /** - * Checks whether a certain string constitutes an ES3 token - * @param {string} tokenStr The string to be checked. - * @returns {boolean} `true` if it is an ES3 token. - */ - function isKeyword(tokenStr) { - return keywords.includes(tokenStr); - } - - /** - * Checks if an espree-tokenized key has redundant quotes (i.e. whether quotes are unnecessary) - * @param {string} rawKey The raw key value from the source - * @param {espreeTokens} tokens The espree-tokenized node key - * @param {boolean} [skipNumberLiterals=false] Indicates whether number literals should be checked - * @returns {boolean} Whether or not a key has redundant quotes. - * @private - */ - function areQuotesRedundant(rawKey, tokens, skipNumberLiterals) { - return tokens.length === 1 && tokens[0].start === 0 && tokens[0].end === rawKey.length && - (["Identifier", "Keyword", "Null", "Boolean"].includes(tokens[0].type) || - (tokens[0].type === "Numeric" && !skipNumberLiterals && String(+tokens[0].value) === tokens[0].value)); - } - - /** - * Returns a string representation of a property node with quotes removed - * @param {ASTNode} key Key AST Node, which may or may not be quoted - * @returns {string} A replacement string for this property - */ - function getUnquotedKey(key) { - return key.type === "Identifier" ? key.name : key.value; - } - - /** - * Returns a string representation of a property node with quotes added - * @param {ASTNode} key Key AST Node, which may or may not be quoted - * @returns {string} A replacement string for this property - */ - function getQuotedKey(key) { - if (key.type === "Literal" && typeof key.value === "string") { - - // If the key is already a string literal, don't replace the quotes with double quotes. - return sourceCode.getText(key); - } - - // Otherwise, the key is either an identifier or a number literal. - return `"${key.type === "Identifier" ? key.name : key.value}"`; - } - - /** - * Ensures that a property's key is quoted only when necessary - * @param {ASTNode} node Property AST node - * @returns {void} - */ - function checkUnnecessaryQuotes(node) { - const key = node.key; - - if (node.method || node.computed || node.shorthand) { - return; - } - - if (key.type === "Literal" && typeof key.value === "string") { - let tokens; - - try { - tokens = espree.tokenize(key.value); - } catch { - return; - } - - if (tokens.length !== 1) { - return; - } - - const isKeywordToken = isKeyword(tokens[0].value); - - if (isKeywordToken && KEYWORDS) { - return; - } - - if (CHECK_UNNECESSARY && areQuotesRedundant(key.value, tokens, NUMBERS)) { - context.report({ - node, - messageId: "unnecessarilyQuotedProperty", - data: { property: key.value }, - fix: fixer => fixer.replaceText(key, getUnquotedKey(key)) - }); - } - } else if (KEYWORDS && key.type === "Identifier" && isKeyword(key.name)) { - context.report({ - node, - messageId: "unquotedReservedProperty", - data: { property: key.name }, - fix: fixer => fixer.replaceText(key, getQuotedKey(key)) - }); - } else if (NUMBERS && key.type === "Literal" && astUtils.isNumericLiteral(key)) { - context.report({ - node, - messageId: "unquotedNumericProperty", - data: { property: key.value }, - fix: fixer => fixer.replaceText(key, getQuotedKey(key)) - }); - } - } - - /** - * Ensures that a property's key is quoted - * @param {ASTNode} node Property AST node - * @returns {void} - */ - function checkOmittedQuotes(node) { - const key = node.key; - - if (!node.method && !node.computed && !node.shorthand && !(key.type === "Literal" && typeof key.value === "string")) { - context.report({ - node, - messageId: "unquotedPropertyFound", - data: { property: key.name || key.value }, - fix: fixer => fixer.replaceText(key, getQuotedKey(key)) - }); - } - } - - /** - * Ensures that an object's keys are consistently quoted, optionally checks for redundancy of quotes - * @param {ASTNode} node Property AST node - * @param {boolean} checkQuotesRedundancy Whether to check quotes' redundancy - * @returns {void} - */ - function checkConsistency(node, checkQuotesRedundancy) { - const quotedProps = [], - unquotedProps = []; - let keywordKeyName = null, - necessaryQuotes = false; - - node.properties.forEach(property => { - const key = property.key; - - if (!key || property.method || property.computed || property.shorthand) { - return; - } - - if (key.type === "Literal" && typeof key.value === "string") { - - quotedProps.push(property); - - if (checkQuotesRedundancy) { - let tokens; - - try { - tokens = espree.tokenize(key.value); - } catch { - necessaryQuotes = true; - return; - } - - necessaryQuotes = necessaryQuotes || !areQuotesRedundant(key.value, tokens) || KEYWORDS && isKeyword(tokens[0].value); - } - } else if (KEYWORDS && checkQuotesRedundancy && key.type === "Identifier" && isKeyword(key.name)) { - unquotedProps.push(property); - necessaryQuotes = true; - keywordKeyName = key.name; - } else { - unquotedProps.push(property); - } - }); - - if (checkQuotesRedundancy && quotedProps.length && !necessaryQuotes) { - quotedProps.forEach(property => { - context.report({ - node: property, - messageId: "redundantQuoting", - fix: fixer => fixer.replaceText(property.key, getUnquotedKey(property.key)) - }); - }); - } else if (unquotedProps.length && keywordKeyName) { - unquotedProps.forEach(property => { - context.report({ - node: property, - messageId: "requireQuotesDueToReservedWord", - data: { property: keywordKeyName }, - fix: fixer => fixer.replaceText(property.key, getQuotedKey(property.key)) - }); - }); - } else if (quotedProps.length && unquotedProps.length) { - unquotedProps.forEach(property => { - context.report({ - node: property, - messageId: "inconsistentlyQuotedProperty", - data: { key: property.key.name || property.key.value }, - fix: fixer => fixer.replaceText(property.key, getQuotedKey(property.key)) - }); - }); - } - } - - return { - Property(node) { - if (MODE === "always" || !MODE) { - checkOmittedQuotes(node); - } - if (MODE === "as-needed") { - checkUnnecessaryQuotes(node); - } - }, - ObjectExpression(node) { - if (MODE === "consistent") { - checkConsistency(node, false); - } - if (MODE === "consistent-as-needed") { - checkConsistency(node, true); - } - } - }; - - } -}; diff --git a/tools/eslint/node_modules/eslint/lib/rules/quotes.js b/tools/eslint/node_modules/eslint/lib/rules/quotes.js deleted file mode 100644 index 17d97dd697d1c4..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/rules/quotes.js +++ /dev/null @@ -1,350 +0,0 @@ -/** - * @fileoverview A rule to choose between single and double quote marks - * @author Matt DuVall , Brandon Payton - * @deprecated in ESLint v8.53.0 - */ - -"use strict"; - -//------------------------------------------------------------------------------ -// Requirements -//------------------------------------------------------------------------------ - -const astUtils = require("./utils/ast-utils"); - -//------------------------------------------------------------------------------ -// Constants -//------------------------------------------------------------------------------ - -const QUOTE_SETTINGS = { - double: { - quote: "\"", - alternateQuote: "'", - description: "doublequote" - }, - single: { - quote: "'", - alternateQuote: "\"", - description: "singlequote" - }, - backtick: { - quote: "`", - alternateQuote: "\"", - description: "backtick" - } -}; - -// An unescaped newline is a newline preceded by an even number of backslashes. -const UNESCAPED_LINEBREAK_PATTERN = new RegExp(String.raw`(^|[^\\])(\\\\)*[${Array.from(astUtils.LINEBREAKS).join("")}]`, "u"); - -/** - * Switches quoting of javascript string between ' " and ` - * escaping and unescaping as necessary. - * Only escaping of the minimal set of characters is changed. - * Note: escaping of newlines when switching from backtick to other quotes is not handled. - * @param {string} str A string to convert. - * @returns {string} The string with changed quotes. - * @private - */ -QUOTE_SETTINGS.double.convert = -QUOTE_SETTINGS.single.convert = -QUOTE_SETTINGS.backtick.convert = function(str) { - const newQuote = this.quote; - const oldQuote = str[0]; - - if (newQuote === oldQuote) { - return str; - } - return newQuote + str.slice(1, -1).replace(/\\(\$\{|\r\n?|\n|.)|["'`]|\$\{|(\r\n?|\n)/gu, (match, escaped, newline) => { - if (escaped === oldQuote || oldQuote === "`" && escaped === "${") { - return escaped; // unescape - } - if (match === newQuote || newQuote === "`" && match === "${") { - return `\\${match}`; // escape - } - if (newline && oldQuote === "`") { - return "\\n"; // escape newlines - } - return match; - }) + newQuote; -}; - -const AVOID_ESCAPE = "avoid-escape"; - -//------------------------------------------------------------------------------ -// Rule Definition -//------------------------------------------------------------------------------ - -/** @type {import('../shared/types').Rule} */ -module.exports = { - meta: { - deprecated: true, - replacedBy: [], - type: "layout", - - docs: { - description: "Enforce the consistent use of either backticks, double, or single quotes", - recommended: false, - url: "https://eslint.org/docs/latest/rules/quotes" - }, - - fixable: "code", - - schema: [ - { - enum: ["single", "double", "backtick"] - }, - { - anyOf: [ - { - enum: ["avoid-escape"] - }, - { - type: "object", - properties: { - avoidEscape: { - type: "boolean" - }, - allowTemplateLiterals: { - type: "boolean" - } - }, - additionalProperties: false - } - ] - } - ], - - messages: { - wrongQuotes: "Strings must use {{description}}." - } - }, - - create(context) { - - const quoteOption = context.options[0], - settings = QUOTE_SETTINGS[quoteOption || "double"], - options = context.options[1], - allowTemplateLiterals = options && options.allowTemplateLiterals === true, - sourceCode = context.sourceCode; - let avoidEscape = options && options.avoidEscape === true; - - // deprecated - if (options === AVOID_ESCAPE) { - avoidEscape = true; - } - - /** - * Determines if a given node is part of JSX syntax. - * - * This function returns `true` in the following cases: - * - * - `
` ... If the literal is an attribute value, the parent of the literal is `JSXAttribute`. - * - `
foo
` ... If the literal is a text content, the parent of the literal is `JSXElement`. - * - `<>foo` ... If the literal is a text content, the parent of the literal is `JSXFragment`. - * - * In particular, this function returns `false` in the following cases: - * - * - `
` - * - `
{"foo"}
` - * - * In both cases, inside of the braces is handled as normal JavaScript. - * The braces are `JSXExpressionContainer` nodes. - * @param {ASTNode} node The Literal node to check. - * @returns {boolean} True if the node is a part of JSX, false if not. - * @private - */ - function isJSXLiteral(node) { - return node.parent.type === "JSXAttribute" || node.parent.type === "JSXElement" || node.parent.type === "JSXFragment"; - } - - /** - * Checks whether or not a given node is a directive. - * The directive is a `ExpressionStatement` which has only a string literal not surrounded by - * parentheses. - * @param {ASTNode} node A node to check. - * @returns {boolean} Whether or not the node is a directive. - * @private - */ - function isDirective(node) { - return ( - node.type === "ExpressionStatement" && - node.expression.type === "Literal" && - typeof node.expression.value === "string" && - !astUtils.isParenthesised(sourceCode, node.expression) - ); - } - - /** - * Checks whether a specified node is either part of, or immediately follows a (possibly empty) directive prologue. - * @see {@link http://www.ecma-international.org/ecma-262/6.0/#sec-directive-prologues-and-the-use-strict-directive} - * @param {ASTNode} node A node to check. - * @returns {boolean} Whether a specified node is either part of, or immediately follows a (possibly empty) directive prologue. - * @private - */ - function isExpressionInOrJustAfterDirectivePrologue(node) { - if (!astUtils.isTopLevelExpressionStatement(node.parent)) { - return false; - } - const block = node.parent.parent; - - // Check the node is at a prologue. - for (let i = 0; i < block.body.length; ++i) { - const statement = block.body[i]; - - if (statement === node.parent) { - return true; - } - if (!isDirective(statement)) { - break; - } - } - - return false; - } - - /** - * Checks whether or not a given node is allowed as non backtick. - * @param {ASTNode} node A node to check. - * @returns {boolean} Whether or not the node is allowed as non backtick. - * @private - */ - function isAllowedAsNonBacktick(node) { - const parent = node.parent; - - switch (parent.type) { - - // Directive Prologues. - case "ExpressionStatement": - return !astUtils.isParenthesised(sourceCode, node) && isExpressionInOrJustAfterDirectivePrologue(node); - - // LiteralPropertyName. - case "Property": - case "PropertyDefinition": - case "MethodDefinition": - return parent.key === node && !parent.computed; - - // ModuleSpecifier. - case "ImportDeclaration": - case "ExportNamedDeclaration": - return parent.source === node; - - // ModuleExportName or ModuleSpecifier. - case "ExportAllDeclaration": - return parent.exported === node || parent.source === node; - - // ModuleExportName. - case "ImportSpecifier": - return parent.imported === node; - - // ModuleExportName. - case "ExportSpecifier": - return parent.local === node || parent.exported === node; - - // Others don't allow. - default: - return false; - } - } - - /** - * Checks whether or not a given TemplateLiteral node is actually using any of the special features provided by template literal strings. - * @param {ASTNode} node A TemplateLiteral node to check. - * @returns {boolean} Whether or not the TemplateLiteral node is using any of the special features provided by template literal strings. - * @private - */ - function isUsingFeatureOfTemplateLiteral(node) { - const hasTag = node.parent.type === "TaggedTemplateExpression" && node === node.parent.quasi; - - if (hasTag) { - return true; - } - - const hasStringInterpolation = node.expressions.length > 0; - - if (hasStringInterpolation) { - return true; - } - - const isMultilineString = node.quasis.length >= 1 && UNESCAPED_LINEBREAK_PATTERN.test(node.quasis[0].value.raw); - - if (isMultilineString) { - return true; - } - - return false; - } - - return { - - Literal(node) { - const val = node.value, - rawVal = node.raw; - - if (settings && typeof val === "string") { - let isValid = (quoteOption === "backtick" && isAllowedAsNonBacktick(node)) || - isJSXLiteral(node) || - astUtils.isSurroundedBy(rawVal, settings.quote); - - if (!isValid && avoidEscape) { - isValid = astUtils.isSurroundedBy(rawVal, settings.alternateQuote) && rawVal.includes(settings.quote); - } - - if (!isValid) { - context.report({ - node, - messageId: "wrongQuotes", - data: { - description: settings.description - }, - fix(fixer) { - if (quoteOption === "backtick" && astUtils.hasOctalOrNonOctalDecimalEscapeSequence(rawVal)) { - - /* - * An octal or non-octal decimal escape sequence in a template literal would - * produce syntax error, even in non-strict mode. - */ - return null; - } - - return fixer.replaceText(node, settings.convert(node.raw)); - } - }); - } - } - }, - - TemplateLiteral(node) { - - // Don't throw an error if backticks are expected or a template literal feature is in use. - if ( - allowTemplateLiterals || - quoteOption === "backtick" || - isUsingFeatureOfTemplateLiteral(node) - ) { - return; - } - - context.report({ - node, - messageId: "wrongQuotes", - data: { - description: settings.description - }, - fix(fixer) { - if (astUtils.isTopLevelExpressionStatement(node.parent) && !astUtils.isParenthesised(sourceCode, node)) { - - /* - * TemplateLiterals aren't actually directives, but fixing them might turn - * them into directives and change the behavior of the code. - */ - return null; - } - return fixer.replaceText(node, settings.convert(sourceCode.getText(node))); - } - }); - } - }; - - } -}; diff --git a/tools/eslint/node_modules/eslint/lib/rules/radix.js b/tools/eslint/node_modules/eslint/lib/rules/radix.js deleted file mode 100644 index efae749690a73e..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/rules/radix.js +++ /dev/null @@ -1,198 +0,0 @@ -/** - * @fileoverview Rule to flag use of parseInt without a radix argument - * @author James Allardice - */ - -"use strict"; - -//------------------------------------------------------------------------------ -// Requirements -//------------------------------------------------------------------------------ - -const astUtils = require("./utils/ast-utils"); - -//------------------------------------------------------------------------------ -// Helpers -//------------------------------------------------------------------------------ - -const MODE_ALWAYS = "always", - MODE_AS_NEEDED = "as-needed"; - -const validRadixValues = new Set(Array.from({ length: 37 - 2 }, (_, index) => index + 2)); - -/** - * Checks whether a given variable is shadowed or not. - * @param {eslint-scope.Variable} variable A variable to check. - * @returns {boolean} `true` if the variable is shadowed. - */ -function isShadowed(variable) { - return variable.defs.length >= 1; -} - -/** - * Checks whether a given node is a MemberExpression of `parseInt` method or not. - * @param {ASTNode} node A node to check. - * @returns {boolean} `true` if the node is a MemberExpression of `parseInt` - * method. - */ -function isParseIntMethod(node) { - return ( - node.type === "MemberExpression" && - !node.computed && - node.property.type === "Identifier" && - node.property.name === "parseInt" - ); -} - -/** - * Checks whether a given node is a valid value of radix or not. - * - * The following values are invalid. - * - * - A literal except integers between 2 and 36. - * - undefined. - * @param {ASTNode} radix A node of radix to check. - * @returns {boolean} `true` if the node is valid. - */ -function isValidRadix(radix) { - return !( - (radix.type === "Literal" && !validRadixValues.has(radix.value)) || - (radix.type === "Identifier" && radix.name === "undefined") - ); -} - -/** - * Checks whether a given node is a default value of radix or not. - * @param {ASTNode} radix A node of radix to check. - * @returns {boolean} `true` if the node is the literal node of `10`. - */ -function isDefaultRadix(radix) { - return radix.type === "Literal" && radix.value === 10; -} - -//------------------------------------------------------------------------------ -// Rule Definition -//------------------------------------------------------------------------------ - -/** @type {import('../shared/types').Rule} */ -module.exports = { - meta: { - type: "suggestion", - - docs: { - description: "Enforce the consistent use of the radix argument when using `parseInt()`", - recommended: false, - url: "https://eslint.org/docs/latest/rules/radix" - }, - - hasSuggestions: true, - - schema: [ - { - enum: ["always", "as-needed"] - } - ], - - messages: { - missingParameters: "Missing parameters.", - redundantRadix: "Redundant radix parameter.", - missingRadix: "Missing radix parameter.", - invalidRadix: "Invalid radix parameter, must be an integer between 2 and 36.", - addRadixParameter10: "Add radix parameter `10` for parsing decimal numbers." - } - }, - - create(context) { - const mode = context.options[0] || MODE_ALWAYS; - const sourceCode = context.sourceCode; - - /** - * Checks the arguments of a given CallExpression node and reports it if it - * offends this rule. - * @param {ASTNode} node A CallExpression node to check. - * @returns {void} - */ - function checkArguments(node) { - const args = node.arguments; - - switch (args.length) { - case 0: - context.report({ - node, - messageId: "missingParameters" - }); - break; - - case 1: - if (mode === MODE_ALWAYS) { - context.report({ - node, - messageId: "missingRadix", - suggest: [ - { - messageId: "addRadixParameter10", - fix(fixer) { - const tokens = sourceCode.getTokens(node); - const lastToken = tokens.at(-1); // Parenthesis. - const secondToLastToken = tokens.at(-2); // May or may not be a comma. - const hasTrailingComma = secondToLastToken.type === "Punctuator" && secondToLastToken.value === ","; - - return fixer.insertTextBefore(lastToken, hasTrailingComma ? " 10," : ", 10"); - } - } - ] - }); - } - break; - - default: - if (mode === MODE_AS_NEEDED && isDefaultRadix(args[1])) { - context.report({ - node, - messageId: "redundantRadix" - }); - } else if (!isValidRadix(args[1])) { - context.report({ - node, - messageId: "invalidRadix" - }); - } - break; - } - } - - return { - "Program:exit"(node) { - const scope = sourceCode.getScope(node); - let variable; - - // Check `parseInt()` - variable = astUtils.getVariableByName(scope, "parseInt"); - if (variable && !isShadowed(variable)) { - variable.references.forEach(reference => { - const idNode = reference.identifier; - - if (astUtils.isCallee(idNode)) { - checkArguments(idNode.parent); - } - }); - } - - // Check `Number.parseInt()` - variable = astUtils.getVariableByName(scope, "Number"); - if (variable && !isShadowed(variable)) { - variable.references.forEach(reference => { - const parentNode = reference.identifier.parent; - const maybeCallee = parentNode.parent.type === "ChainExpression" - ? parentNode.parent - : parentNode; - - if (isParseIntMethod(parentNode) && astUtils.isCallee(maybeCallee)) { - checkArguments(maybeCallee.parent); - } - }); - } - } - }; - } -}; diff --git a/tools/eslint/node_modules/eslint/lib/rules/require-atomic-updates.js b/tools/eslint/node_modules/eslint/lib/rules/require-atomic-updates.js deleted file mode 100644 index 7e397ceb1cfd87..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/rules/require-atomic-updates.js +++ /dev/null @@ -1,331 +0,0 @@ -/** - * @fileoverview disallow assignments that can lead to race conditions due to usage of `await` or `yield` - * @author Teddy Katz - * @author Toru Nagashima - */ -"use strict"; - -/** - * Make the map from identifiers to each reference. - * @param {escope.Scope} scope The scope to get references. - * @param {Map} [outReferenceMap] The map from identifier nodes to each reference object. - * @returns {Map} `referenceMap`. - */ -function createReferenceMap(scope, outReferenceMap = new Map()) { - for (const reference of scope.references) { - if (reference.resolved === null) { - continue; - } - - outReferenceMap.set(reference.identifier, reference); - } - for (const childScope of scope.childScopes) { - if (childScope.type !== "function") { - createReferenceMap(childScope, outReferenceMap); - } - } - - return outReferenceMap; -} - -/** - * Get `reference.writeExpr` of a given reference. - * If it's the read reference of MemberExpression in LHS, returns RHS in order to address `a.b = await a` - * @param {escope.Reference} reference The reference to get. - * @returns {Expression|null} The `reference.writeExpr`. - */ -function getWriteExpr(reference) { - if (reference.writeExpr) { - return reference.writeExpr; - } - let node = reference.identifier; - - while (node) { - const t = node.parent.type; - - if (t === "AssignmentExpression" && node.parent.left === node) { - return node.parent.right; - } - if (t === "MemberExpression" && node.parent.object === node) { - node = node.parent; - continue; - } - - break; - } - - return null; -} - -/** - * Checks if an expression is a variable that can only be observed within the given function. - * @param {Variable|null} variable The variable to check - * @param {boolean} isMemberAccess If `true` then this is a member access. - * @returns {boolean} `true` if the variable is local to the given function, and is never referenced in a closure. - */ -function isLocalVariableWithoutEscape(variable, isMemberAccess) { - if (!variable) { - return false; // A global variable which was not defined. - } - - // If the reference is a property access and the variable is a parameter, it handles the variable is not local. - if (isMemberAccess && variable.defs.some(d => d.type === "Parameter")) { - return false; - } - - const functionScope = variable.scope.variableScope; - - return variable.references.every(reference => - reference.from.variableScope === functionScope); -} - -/** - * Represents segment information. - */ -class SegmentInfo { - constructor() { - this.info = new WeakMap(); - } - - /** - * Initialize the segment information. - * @param {PathSegment} segment The segment to initialize. - * @returns {void} - */ - initialize(segment) { - const outdatedReadVariables = new Set(); - const freshReadVariables = new Set(); - - for (const prevSegment of segment.prevSegments) { - const info = this.info.get(prevSegment); - - if (info) { - info.outdatedReadVariables.forEach(Set.prototype.add, outdatedReadVariables); - info.freshReadVariables.forEach(Set.prototype.add, freshReadVariables); - } - } - - this.info.set(segment, { outdatedReadVariables, freshReadVariables }); - } - - /** - * Mark a given variable as read on given segments. - * @param {PathSegment[]} segments The segments that it read the variable on. - * @param {Variable} variable The variable to be read. - * @returns {void} - */ - markAsRead(segments, variable) { - for (const segment of segments) { - const info = this.info.get(segment); - - if (info) { - info.freshReadVariables.add(variable); - - // If a variable is freshly read again, then it's no more out-dated. - info.outdatedReadVariables.delete(variable); - } - } - } - - /** - * Move `freshReadVariables` to `outdatedReadVariables`. - * @param {PathSegment[]} segments The segments to process. - * @returns {void} - */ - makeOutdated(segments) { - for (const segment of segments) { - const info = this.info.get(segment); - - if (info) { - info.freshReadVariables.forEach(Set.prototype.add, info.outdatedReadVariables); - info.freshReadVariables.clear(); - } - } - } - - /** - * Check if a given variable is outdated on the current segments. - * @param {PathSegment[]} segments The current segments. - * @param {Variable} variable The variable to check. - * @returns {boolean} `true` if the variable is outdated on the segments. - */ - isOutdated(segments, variable) { - for (const segment of segments) { - const info = this.info.get(segment); - - if (info && info.outdatedReadVariables.has(variable)) { - return true; - } - } - return false; - } -} - -//------------------------------------------------------------------------------ -// Rule Definition -//------------------------------------------------------------------------------ - -/** @type {import('../shared/types').Rule} */ -module.exports = { - meta: { - type: "problem", - - docs: { - description: "Disallow assignments that can lead to race conditions due to usage of `await` or `yield`", - recommended: false, - url: "https://eslint.org/docs/latest/rules/require-atomic-updates" - }, - - fixable: null, - - schema: [{ - type: "object", - properties: { - allowProperties: { - type: "boolean", - default: false - } - }, - additionalProperties: false - }], - - messages: { - nonAtomicUpdate: "Possible race condition: `{{value}}` might be reassigned based on an outdated value of `{{value}}`.", - nonAtomicObjectUpdate: "Possible race condition: `{{value}}` might be assigned based on an outdated state of `{{object}}`." - } - }, - - create(context) { - const allowProperties = !!context.options[0] && context.options[0].allowProperties; - - const sourceCode = context.sourceCode; - const assignmentReferences = new Map(); - const segmentInfo = new SegmentInfo(); - let stack = null; - - return { - onCodePathStart(codePath, node) { - const scope = sourceCode.getScope(node); - const shouldVerify = - scope.type === "function" && - (scope.block.async || scope.block.generator); - - stack = { - upper: stack, - codePath, - referenceMap: shouldVerify ? createReferenceMap(scope) : null, - currentSegments: new Set() - }; - }, - onCodePathEnd() { - stack = stack.upper; - }, - - // Initialize the segment information. - onCodePathSegmentStart(segment) { - segmentInfo.initialize(segment); - stack.currentSegments.add(segment); - }, - - onUnreachableCodePathSegmentStart(segment) { - stack.currentSegments.add(segment); - }, - - onUnreachableCodePathSegmentEnd(segment) { - stack.currentSegments.delete(segment); - }, - - onCodePathSegmentEnd(segment) { - stack.currentSegments.delete(segment); - }, - - - // Handle references to prepare verification. - Identifier(node) { - const { referenceMap } = stack; - const reference = referenceMap && referenceMap.get(node); - - // Ignore if this is not a valid variable reference. - if (!reference) { - return; - } - const variable = reference.resolved; - const writeExpr = getWriteExpr(reference); - const isMemberAccess = reference.identifier.parent.type === "MemberExpression"; - - // Add a fresh read variable. - if (reference.isRead() && !(writeExpr && writeExpr.parent.operator === "=")) { - segmentInfo.markAsRead(stack.currentSegments, variable); - } - - /* - * Register the variable to verify after ESLint traversed the `writeExpr` node - * if this reference is an assignment to a variable which is referred from other closure. - */ - if (writeExpr && - writeExpr.parent.right === writeExpr && // โ† exclude variable declarations. - !isLocalVariableWithoutEscape(variable, isMemberAccess) - ) { - let refs = assignmentReferences.get(writeExpr); - - if (!refs) { - refs = []; - assignmentReferences.set(writeExpr, refs); - } - - refs.push(reference); - } - }, - - /* - * Verify assignments. - * If the reference exists in `outdatedReadVariables` list, report it. - */ - ":expression:exit"(node) { - - // referenceMap exists if this is in a resumable function scope. - if (!stack.referenceMap) { - return; - } - - // Mark the read variables on this code path as outdated. - if (node.type === "AwaitExpression" || node.type === "YieldExpression") { - segmentInfo.makeOutdated(stack.currentSegments); - } - - // Verify. - const references = assignmentReferences.get(node); - - if (references) { - assignmentReferences.delete(node); - - for (const reference of references) { - const variable = reference.resolved; - - if (segmentInfo.isOutdated(stack.currentSegments, variable)) { - if (node.parent.left === reference.identifier) { - context.report({ - node: node.parent, - messageId: "nonAtomicUpdate", - data: { - value: variable.name - } - }); - } else if (!allowProperties) { - context.report({ - node: node.parent, - messageId: "nonAtomicObjectUpdate", - data: { - value: sourceCode.getText(node.parent.left), - object: variable.name - } - }); - } - - } - } - } - } - }; - } -}; diff --git a/tools/eslint/node_modules/eslint/lib/rules/require-await.js b/tools/eslint/node_modules/eslint/lib/rules/require-await.js deleted file mode 100644 index 952dde5431fe4a..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/rules/require-await.js +++ /dev/null @@ -1,113 +0,0 @@ -/** - * @fileoverview Rule to disallow async functions which have no `await` expression. - * @author Toru Nagashima - */ - -"use strict"; - -//------------------------------------------------------------------------------ -// Requirements -//------------------------------------------------------------------------------ - -const astUtils = require("./utils/ast-utils"); - -//------------------------------------------------------------------------------ -// Helpers -//------------------------------------------------------------------------------ - -/** - * Capitalize the 1st letter of the given text. - * @param {string} text The text to capitalize. - * @returns {string} The text that the 1st letter was capitalized. - */ -function capitalizeFirstLetter(text) { - return text[0].toUpperCase() + text.slice(1); -} - -//------------------------------------------------------------------------------ -// Rule Definition -//------------------------------------------------------------------------------ - -/** @type {import('../shared/types').Rule} */ -module.exports = { - meta: { - type: "suggestion", - - docs: { - description: "Disallow async functions which have no `await` expression", - recommended: false, - url: "https://eslint.org/docs/latest/rules/require-await" - }, - - schema: [], - - messages: { - missingAwait: "{{name}} has no 'await' expression." - } - }, - - create(context) { - const sourceCode = context.sourceCode; - let scopeInfo = null; - - /** - * Push the scope info object to the stack. - * @returns {void} - */ - function enterFunction() { - scopeInfo = { - upper: scopeInfo, - hasAwait: false - }; - } - - /** - * Pop the top scope info object from the stack. - * Also, it reports the function if needed. - * @param {ASTNode} node The node to report. - * @returns {void} - */ - function exitFunction(node) { - if (!node.generator && node.async && !scopeInfo.hasAwait && !astUtils.isEmptyFunction(node)) { - context.report({ - node, - loc: astUtils.getFunctionHeadLoc(node, sourceCode), - messageId: "missingAwait", - data: { - name: capitalizeFirstLetter( - astUtils.getFunctionNameWithKind(node) - ) - } - }); - } - - scopeInfo = scopeInfo.upper; - } - - return { - FunctionDeclaration: enterFunction, - FunctionExpression: enterFunction, - ArrowFunctionExpression: enterFunction, - "FunctionDeclaration:exit": exitFunction, - "FunctionExpression:exit": exitFunction, - "ArrowFunctionExpression:exit": exitFunction, - - AwaitExpression() { - if (!scopeInfo) { - return; - } - - scopeInfo.hasAwait = true; - }, - ForOfStatement(node) { - if (!scopeInfo) { - return; - } - - if (node.await) { - scopeInfo.hasAwait = true; - } - } - }; - } -}; diff --git a/tools/eslint/node_modules/eslint/lib/rules/require-unicode-regexp.js b/tools/eslint/node_modules/eslint/lib/rules/require-unicode-regexp.js deleted file mode 100644 index dd687f8d796b24..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/rules/require-unicode-regexp.js +++ /dev/null @@ -1,129 +0,0 @@ -/** - * @fileoverview Rule to enforce the use of `u` flag on RegExp. - * @author Toru Nagashima - */ - -"use strict"; - -//------------------------------------------------------------------------------ -// Requirements -//------------------------------------------------------------------------------ - -const { - CALL, - CONSTRUCT, - ReferenceTracker, - getStringIfConstant -} = require("@eslint-community/eslint-utils"); -const astUtils = require("./utils/ast-utils.js"); -const { isValidWithUnicodeFlag } = require("./utils/regular-expressions"); - -//------------------------------------------------------------------------------ -// Rule Definition -//------------------------------------------------------------------------------ - -/** @type {import('../shared/types').Rule} */ -module.exports = { - meta: { - type: "suggestion", - - docs: { - description: "Enforce the use of `u` or `v` flag on RegExp", - recommended: false, - url: "https://eslint.org/docs/latest/rules/require-unicode-regexp" - }, - - hasSuggestions: true, - - messages: { - addUFlag: "Add the 'u' flag.", - requireUFlag: "Use the 'u' flag." - }, - - schema: [] - }, - - create(context) { - - const sourceCode = context.sourceCode; - - return { - "Literal[regex]"(node) { - const flags = node.regex.flags || ""; - - if (!flags.includes("u") && !flags.includes("v")) { - context.report({ - messageId: "requireUFlag", - node, - suggest: isValidWithUnicodeFlag(context.languageOptions.ecmaVersion, node.regex.pattern) - ? [ - { - fix(fixer) { - return fixer.insertTextAfter(node, "u"); - }, - messageId: "addUFlag" - } - ] - : null - }); - } - }, - - Program(node) { - const scope = sourceCode.getScope(node); - const tracker = new ReferenceTracker(scope); - const trackMap = { - RegExp: { [CALL]: true, [CONSTRUCT]: true } - }; - - for (const { node: refNode } of tracker.iterateGlobalReferences(trackMap)) { - const [patternNode, flagsNode] = refNode.arguments; - - if (patternNode && patternNode.type === "SpreadElement") { - continue; - } - const pattern = getStringIfConstant(patternNode, scope); - const flags = getStringIfConstant(flagsNode, scope); - - if (!flagsNode || (typeof flags === "string" && !flags.includes("u") && !flags.includes("v"))) { - context.report({ - messageId: "requireUFlag", - node: refNode, - suggest: typeof pattern === "string" && isValidWithUnicodeFlag(context.languageOptions.ecmaVersion, pattern) - ? [ - { - fix(fixer) { - if (flagsNode) { - if ((flagsNode.type === "Literal" && typeof flagsNode.value === "string") || flagsNode.type === "TemplateLiteral") { - const flagsNodeText = sourceCode.getText(flagsNode); - - return fixer.replaceText(flagsNode, [ - flagsNodeText.slice(0, flagsNodeText.length - 1), - flagsNodeText.slice(flagsNodeText.length - 1) - ].join("u")); - } - - // We intentionally don't suggest concatenating + "u" to non-literals - return null; - } - - const penultimateToken = sourceCode.getLastToken(refNode, { skip: 1 }); // skip closing parenthesis - - return fixer.insertTextAfter( - penultimateToken, - astUtils.isCommaToken(penultimateToken) - ? ' "u",' - : ', "u"' - ); - }, - messageId: "addUFlag" - } - ] - : null - }); - } - } - } - }; - } -}; diff --git a/tools/eslint/node_modules/eslint/lib/rules/require-yield.js b/tools/eslint/node_modules/eslint/lib/rules/require-yield.js deleted file mode 100644 index f801af0ab50404..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/rules/require-yield.js +++ /dev/null @@ -1,77 +0,0 @@ -/** - * @fileoverview Rule to flag the generator functions that does not have yield. - * @author Toru Nagashima - */ - -"use strict"; - -//------------------------------------------------------------------------------ -// Rule Definition -//------------------------------------------------------------------------------ - -/** @type {import('../shared/types').Rule} */ -module.exports = { - meta: { - type: "suggestion", - - docs: { - description: "Require generator functions to contain `yield`", - recommended: true, - url: "https://eslint.org/docs/latest/rules/require-yield" - }, - - schema: [], - - messages: { - missingYield: "This generator function does not have 'yield'." - } - }, - - create(context) { - const stack = []; - - /** - * If the node is a generator function, start counting `yield` keywords. - * @param {Node} node A function node to check. - * @returns {void} - */ - function beginChecking(node) { - if (node.generator) { - stack.push(0); - } - } - - /** - * If the node is a generator function, end counting `yield` keywords, then - * reports result. - * @param {Node} node A function node to check. - * @returns {void} - */ - function endChecking(node) { - if (!node.generator) { - return; - } - - const countYield = stack.pop(); - - if (countYield === 0 && node.body.body.length > 0) { - context.report({ node, messageId: "missingYield" }); - } - } - - return { - FunctionDeclaration: beginChecking, - "FunctionDeclaration:exit": endChecking, - FunctionExpression: beginChecking, - "FunctionExpression:exit": endChecking, - - // Increases the count of `yield` keyword. - YieldExpression() { - - if (stack.length > 0) { - stack[stack.length - 1] += 1; - } - } - }; - } -}; diff --git a/tools/eslint/node_modules/eslint/lib/rules/rest-spread-spacing.js b/tools/eslint/node_modules/eslint/lib/rules/rest-spread-spacing.js deleted file mode 100644 index 287e56f014a6b8..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/rules/rest-spread-spacing.js +++ /dev/null @@ -1,123 +0,0 @@ -/** - * @fileoverview Enforce spacing between rest and spread operators and their expressions. - * @author Kai Cataldo - * @deprecated in ESLint v8.53.0 - */ - -"use strict"; - -//------------------------------------------------------------------------------ -// Rule Definition -//------------------------------------------------------------------------------ - -/** @type {import('../shared/types').Rule} */ -module.exports = { - meta: { - deprecated: true, - replacedBy: [], - type: "layout", - - docs: { - description: "Enforce spacing between rest and spread operators and their expressions", - recommended: false, - url: "https://eslint.org/docs/latest/rules/rest-spread-spacing" - }, - - fixable: "whitespace", - - schema: [ - { - enum: ["always", "never"] - } - ], - - messages: { - unexpectedWhitespace: "Unexpected whitespace after {{type}} operator.", - expectedWhitespace: "Expected whitespace after {{type}} operator." - } - }, - - create(context) { - const sourceCode = context.sourceCode, - alwaysSpace = context.options[0] === "always"; - - //-------------------------------------------------------------------------- - // Helpers - //-------------------------------------------------------------------------- - - /** - * Checks whitespace between rest/spread operators and their expressions - * @param {ASTNode} node The node to check - * @returns {void} - */ - function checkWhiteSpace(node) { - const operator = sourceCode.getFirstToken(node), - nextToken = sourceCode.getTokenAfter(operator), - hasWhitespace = sourceCode.isSpaceBetweenTokens(operator, nextToken); - let type; - - switch (node.type) { - case "SpreadElement": - type = "spread"; - if (node.parent.type === "ObjectExpression") { - type += " property"; - } - break; - case "RestElement": - type = "rest"; - if (node.parent.type === "ObjectPattern") { - type += " property"; - } - break; - case "ExperimentalSpreadProperty": - type = "spread property"; - break; - case "ExperimentalRestProperty": - type = "rest property"; - break; - default: - return; - } - - if (alwaysSpace && !hasWhitespace) { - context.report({ - node, - loc: operator.loc, - messageId: "expectedWhitespace", - data: { - type - }, - fix(fixer) { - return fixer.replaceTextRange([operator.range[1], nextToken.range[0]], " "); - } - }); - } else if (!alwaysSpace && hasWhitespace) { - context.report({ - node, - loc: { - start: operator.loc.end, - end: nextToken.loc.start - }, - messageId: "unexpectedWhitespace", - data: { - type - }, - fix(fixer) { - return fixer.removeRange([operator.range[1], nextToken.range[0]]); - } - }); - } - } - - //-------------------------------------------------------------------------- - // Public - //-------------------------------------------------------------------------- - - return { - SpreadElement: checkWhiteSpace, - RestElement: checkWhiteSpace, - ExperimentalSpreadProperty: checkWhiteSpace, - ExperimentalRestProperty: checkWhiteSpace - }; - } -}; diff --git a/tools/eslint/node_modules/eslint/lib/rules/semi-spacing.js b/tools/eslint/node_modules/eslint/lib/rules/semi-spacing.js deleted file mode 100644 index 35a49d2c22b560..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/rules/semi-spacing.js +++ /dev/null @@ -1,248 +0,0 @@ -/** - * @fileoverview Validates spacing before and after semicolon - * @author Mathias Schreck - * @deprecated in ESLint v8.53.0 - */ - -"use strict"; - -const astUtils = require("./utils/ast-utils"); - -//------------------------------------------------------------------------------ -// Rule Definition -//------------------------------------------------------------------------------ - -/** @type {import('../shared/types').Rule} */ -module.exports = { - meta: { - deprecated: true, - replacedBy: [], - type: "layout", - - docs: { - description: "Enforce consistent spacing before and after semicolons", - recommended: false, - url: "https://eslint.org/docs/latest/rules/semi-spacing" - }, - - fixable: "whitespace", - - schema: [ - { - type: "object", - properties: { - before: { - type: "boolean", - default: false - }, - after: { - type: "boolean", - default: true - } - }, - additionalProperties: false - } - ], - - messages: { - unexpectedWhitespaceBefore: "Unexpected whitespace before semicolon.", - unexpectedWhitespaceAfter: "Unexpected whitespace after semicolon.", - missingWhitespaceBefore: "Missing whitespace before semicolon.", - missingWhitespaceAfter: "Missing whitespace after semicolon." - } - }, - - create(context) { - - const config = context.options[0], - sourceCode = context.sourceCode; - let requireSpaceBefore = false, - requireSpaceAfter = true; - - if (typeof config === "object") { - requireSpaceBefore = config.before; - requireSpaceAfter = config.after; - } - - /** - * Checks if a given token has leading whitespace. - * @param {Object} token The token to check. - * @returns {boolean} True if the given token has leading space, false if not. - */ - function hasLeadingSpace(token) { - const tokenBefore = sourceCode.getTokenBefore(token); - - return tokenBefore && astUtils.isTokenOnSameLine(tokenBefore, token) && sourceCode.isSpaceBetweenTokens(tokenBefore, token); - } - - /** - * Checks if a given token has trailing whitespace. - * @param {Object} token The token to check. - * @returns {boolean} True if the given token has trailing space, false if not. - */ - function hasTrailingSpace(token) { - const tokenAfter = sourceCode.getTokenAfter(token); - - return tokenAfter && astUtils.isTokenOnSameLine(token, tokenAfter) && sourceCode.isSpaceBetweenTokens(token, tokenAfter); - } - - /** - * Checks if the given token is the last token in its line. - * @param {Token} token The token to check. - * @returns {boolean} Whether or not the token is the last in its line. - */ - function isLastTokenInCurrentLine(token) { - const tokenAfter = sourceCode.getTokenAfter(token); - - return !(tokenAfter && astUtils.isTokenOnSameLine(token, tokenAfter)); - } - - /** - * Checks if the given token is the first token in its line - * @param {Token} token The token to check. - * @returns {boolean} Whether or not the token is the first in its line. - */ - function isFirstTokenInCurrentLine(token) { - const tokenBefore = sourceCode.getTokenBefore(token); - - return !(tokenBefore && astUtils.isTokenOnSameLine(token, tokenBefore)); - } - - /** - * Checks if the next token of a given token is a closing parenthesis. - * @param {Token} token The token to check. - * @returns {boolean} Whether or not the next token of a given token is a closing parenthesis. - */ - function isBeforeClosingParen(token) { - const nextToken = sourceCode.getTokenAfter(token); - - return (nextToken && astUtils.isClosingBraceToken(nextToken) || astUtils.isClosingParenToken(nextToken)); - } - - /** - * Report location example : - * - * for unexpected space `before` - * - * var a = 'b' ; - * ^^^ - * - * for unexpected space `after` - * - * var a = 'b'; c = 10; - * ^^ - * - * Reports if the given token has invalid spacing. - * @param {Token} token The semicolon token to check. - * @param {ASTNode} node The corresponding node of the token. - * @returns {void} - */ - function checkSemicolonSpacing(token, node) { - if (astUtils.isSemicolonToken(token)) { - if (hasLeadingSpace(token)) { - if (!requireSpaceBefore) { - const tokenBefore = sourceCode.getTokenBefore(token); - const loc = { - start: tokenBefore.loc.end, - end: token.loc.start - }; - - context.report({ - node, - loc, - messageId: "unexpectedWhitespaceBefore", - fix(fixer) { - - return fixer.removeRange([tokenBefore.range[1], token.range[0]]); - } - }); - } - } else { - if (requireSpaceBefore) { - const loc = token.loc; - - context.report({ - node, - loc, - messageId: "missingWhitespaceBefore", - fix(fixer) { - return fixer.insertTextBefore(token, " "); - } - }); - } - } - - if (!isFirstTokenInCurrentLine(token) && !isLastTokenInCurrentLine(token) && !isBeforeClosingParen(token)) { - if (hasTrailingSpace(token)) { - if (!requireSpaceAfter) { - const tokenAfter = sourceCode.getTokenAfter(token); - const loc = { - start: token.loc.end, - end: tokenAfter.loc.start - }; - - context.report({ - node, - loc, - messageId: "unexpectedWhitespaceAfter", - fix(fixer) { - - return fixer.removeRange([token.range[1], tokenAfter.range[0]]); - } - }); - } - } else { - if (requireSpaceAfter) { - const loc = token.loc; - - context.report({ - node, - loc, - messageId: "missingWhitespaceAfter", - fix(fixer) { - return fixer.insertTextAfter(token, " "); - } - }); - } - } - } - } - } - - /** - * Checks the spacing of the semicolon with the assumption that the last token is the semicolon. - * @param {ASTNode} node The node to check. - * @returns {void} - */ - function checkNode(node) { - const token = sourceCode.getLastToken(node); - - checkSemicolonSpacing(token, node); - } - - return { - VariableDeclaration: checkNode, - ExpressionStatement: checkNode, - BreakStatement: checkNode, - ContinueStatement: checkNode, - DebuggerStatement: checkNode, - DoWhileStatement: checkNode, - ReturnStatement: checkNode, - ThrowStatement: checkNode, - ImportDeclaration: checkNode, - ExportNamedDeclaration: checkNode, - ExportAllDeclaration: checkNode, - ExportDefaultDeclaration: checkNode, - ForStatement(node) { - if (node.init) { - checkSemicolonSpacing(sourceCode.getTokenAfter(node.init), node); - } - - if (node.test) { - checkSemicolonSpacing(sourceCode.getTokenAfter(node.test), node); - } - }, - PropertyDefinition: checkNode - }; - } -}; diff --git a/tools/eslint/node_modules/eslint/lib/rules/semi-style.js b/tools/eslint/node_modules/eslint/lib/rules/semi-style.js deleted file mode 100644 index 11caaf0b94527e..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/rules/semi-style.js +++ /dev/null @@ -1,158 +0,0 @@ -/** - * @fileoverview Rule to enforce location of semicolons. - * @author Toru Nagashima - * @deprecated in ESLint v8.53.0 - */ - -"use strict"; - -//------------------------------------------------------------------------------ -// Requirements -//------------------------------------------------------------------------------ - -const astUtils = require("./utils/ast-utils"); - -//------------------------------------------------------------------------------ -// Rule Definition -//------------------------------------------------------------------------------ - -const SELECTOR = [ - "BreakStatement", "ContinueStatement", "DebuggerStatement", - "DoWhileStatement", "ExportAllDeclaration", - "ExportDefaultDeclaration", "ExportNamedDeclaration", - "ExpressionStatement", "ImportDeclaration", "ReturnStatement", - "ThrowStatement", "VariableDeclaration", "PropertyDefinition" -].join(","); - -/** - * Get the child node list of a given node. - * This returns `BlockStatement#body`, `StaticBlock#body`, `Program#body`, - * `ClassBody#body`, or `SwitchCase#consequent`. - * This is used to check whether a node is the first/last child. - * @param {Node} node A node to get child node list. - * @returns {Node[]|null} The child node list. - */ -function getChildren(node) { - const t = node.type; - - if ( - t === "BlockStatement" || - t === "StaticBlock" || - t === "Program" || - t === "ClassBody" - ) { - return node.body; - } - if (t === "SwitchCase") { - return node.consequent; - } - return null; -} - -/** - * Check whether a given node is the last statement in the parent block. - * @param {Node} node A node to check. - * @returns {boolean} `true` if the node is the last statement in the parent block. - */ -function isLastChild(node) { - const t = node.parent.type; - - if (t === "IfStatement" && node.parent.consequent === node && node.parent.alternate) { // before `else` keyword. - return true; - } - if (t === "DoWhileStatement") { // before `while` keyword. - return true; - } - const nodeList = getChildren(node.parent); - - return nodeList !== null && nodeList.at(-1) === node; // before `}` or etc. -} - -/** @type {import('../shared/types').Rule} */ -module.exports = { - meta: { - deprecated: true, - replacedBy: [], - type: "layout", - - docs: { - description: "Enforce location of semicolons", - recommended: false, - url: "https://eslint.org/docs/latest/rules/semi-style" - }, - - schema: [{ enum: ["last", "first"] }], - fixable: "whitespace", - - messages: { - expectedSemiColon: "Expected this semicolon to be at {{pos}}." - } - }, - - create(context) { - const sourceCode = context.sourceCode; - const option = context.options[0] || "last"; - - /** - * Check the given semicolon token. - * @param {Token} semiToken The semicolon token to check. - * @param {"first"|"last"} expected The expected location to check. - * @returns {void} - */ - function check(semiToken, expected) { - const prevToken = sourceCode.getTokenBefore(semiToken); - const nextToken = sourceCode.getTokenAfter(semiToken); - const prevIsSameLine = !prevToken || astUtils.isTokenOnSameLine(prevToken, semiToken); - const nextIsSameLine = !nextToken || astUtils.isTokenOnSameLine(semiToken, nextToken); - - if ((expected === "last" && !prevIsSameLine) || (expected === "first" && !nextIsSameLine)) { - context.report({ - loc: semiToken.loc, - messageId: "expectedSemiColon", - data: { - pos: (expected === "last") - ? "the end of the previous line" - : "the beginning of the next line" - }, - fix(fixer) { - if (prevToken && nextToken && sourceCode.commentsExistBetween(prevToken, nextToken)) { - return null; - } - - const start = prevToken ? prevToken.range[1] : semiToken.range[0]; - const end = nextToken ? nextToken.range[0] : semiToken.range[1]; - const text = (expected === "last") ? ";\n" : "\n;"; - - return fixer.replaceTextRange([start, end], text); - } - }); - } - } - - return { - [SELECTOR](node) { - if (option === "first" && isLastChild(node)) { - return; - } - - const lastToken = sourceCode.getLastToken(node); - - if (astUtils.isSemicolonToken(lastToken)) { - check(lastToken, option); - } - }, - - ForStatement(node) { - const firstSemi = node.init && sourceCode.getTokenAfter(node.init, astUtils.isSemicolonToken); - const secondSemi = node.test && sourceCode.getTokenAfter(node.test, astUtils.isSemicolonToken); - - if (firstSemi) { - check(firstSemi, "last"); - } - if (secondSemi) { - check(secondSemi, "last"); - } - } - }; - } -}; diff --git a/tools/eslint/node_modules/eslint/lib/rules/semi.js b/tools/eslint/node_modules/eslint/lib/rules/semi.js deleted file mode 100644 index 01586b8492d1ce..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/rules/semi.js +++ /dev/null @@ -1,438 +0,0 @@ -/** - * @fileoverview Rule to flag missing semicolons. - * @author Nicholas C. Zakas - * @deprecated in ESLint v8.53.0 - */ -"use strict"; - -//------------------------------------------------------------------------------ -// Requirements -//------------------------------------------------------------------------------ - -const FixTracker = require("./utils/fix-tracker"); -const astUtils = require("./utils/ast-utils"); - -//------------------------------------------------------------------------------ -// Rule Definition -//------------------------------------------------------------------------------ - -/** @type {import('../shared/types').Rule} */ -module.exports = { - meta: { - deprecated: true, - replacedBy: [], - type: "layout", - - docs: { - description: "Require or disallow semicolons instead of ASI", - recommended: false, - url: "https://eslint.org/docs/latest/rules/semi" - }, - - fixable: "code", - - schema: { - anyOf: [ - { - type: "array", - items: [ - { - enum: ["never"] - }, - { - type: "object", - properties: { - beforeStatementContinuationChars: { - enum: ["always", "any", "never"] - } - }, - additionalProperties: false - } - ], - minItems: 0, - maxItems: 2 - }, - { - type: "array", - items: [ - { - enum: ["always"] - }, - { - type: "object", - properties: { - omitLastInOneLineBlock: { type: "boolean" }, - omitLastInOneLineClassBody: { type: "boolean" } - }, - additionalProperties: false - } - ], - minItems: 0, - maxItems: 2 - } - ] - }, - - messages: { - missingSemi: "Missing semicolon.", - extraSemi: "Extra semicolon." - } - }, - - create(context) { - - const OPT_OUT_PATTERN = /^[-[(/+`]/u; // One of [(/+-` - const unsafeClassFieldNames = new Set(["get", "set", "static"]); - const unsafeClassFieldFollowers = new Set(["*", "in", "instanceof"]); - const options = context.options[1]; - const never = context.options[0] === "never"; - const exceptOneLine = Boolean(options && options.omitLastInOneLineBlock); - const exceptOneLineClassBody = Boolean(options && options.omitLastInOneLineClassBody); - const beforeStatementContinuationChars = options && options.beforeStatementContinuationChars || "any"; - const sourceCode = context.sourceCode; - - //-------------------------------------------------------------------------- - // Helpers - //-------------------------------------------------------------------------- - - /** - * Reports a semicolon error with appropriate location and message. - * @param {ASTNode} node The node with an extra or missing semicolon. - * @param {boolean} missing True if the semicolon is missing. - * @returns {void} - */ - function report(node, missing) { - const lastToken = sourceCode.getLastToken(node); - let messageId, - fix, - loc; - - if (!missing) { - messageId = "missingSemi"; - loc = { - start: lastToken.loc.end, - end: astUtils.getNextLocation(sourceCode, lastToken.loc.end) - }; - fix = function(fixer) { - return fixer.insertTextAfter(lastToken, ";"); - }; - } else { - messageId = "extraSemi"; - loc = lastToken.loc; - fix = function(fixer) { - - /* - * Expand the replacement range to include the surrounding - * tokens to avoid conflicting with no-extra-semi. - * https://github.com/eslint/eslint/issues/7928 - */ - return new FixTracker(fixer, sourceCode) - .retainSurroundingTokens(lastToken) - .remove(lastToken); - }; - } - - context.report({ - node, - loc, - messageId, - fix - }); - - } - - /** - * Check whether a given semicolon token is redundant. - * @param {Token} semiToken A semicolon token to check. - * @returns {boolean} `true` if the next token is `;` or `}`. - */ - function isRedundantSemi(semiToken) { - const nextToken = sourceCode.getTokenAfter(semiToken); - - return ( - !nextToken || - astUtils.isClosingBraceToken(nextToken) || - astUtils.isSemicolonToken(nextToken) - ); - } - - /** - * Check whether a given token is the closing brace of an arrow function. - * @param {Token} lastToken A token to check. - * @returns {boolean} `true` if the token is the closing brace of an arrow function. - */ - function isEndOfArrowBlock(lastToken) { - if (!astUtils.isClosingBraceToken(lastToken)) { - return false; - } - const node = sourceCode.getNodeByRangeIndex(lastToken.range[0]); - - return ( - node.type === "BlockStatement" && - node.parent.type === "ArrowFunctionExpression" - ); - } - - /** - * Checks if a given PropertyDefinition node followed by a semicolon - * can safely remove that semicolon. It is not to safe to remove if - * the class field name is "get", "set", or "static", or if - * followed by a generator method. - * @param {ASTNode} node The node to check. - * @returns {boolean} `true` if the node cannot have the semicolon - * removed. - */ - function maybeClassFieldAsiHazard(node) { - - if (node.type !== "PropertyDefinition") { - return false; - } - - /* - * Computed property names and non-identifiers are always safe - * as they can be distinguished from keywords easily. - */ - const needsNameCheck = !node.computed && node.key.type === "Identifier"; - - /* - * Certain names are problematic unless they also have a - * a way to distinguish between keywords and property - * names. - */ - if (needsNameCheck && unsafeClassFieldNames.has(node.key.name)) { - - /* - * Special case: If the field name is `static`, - * it is only valid if the field is marked as static, - * so "static static" is okay but "static" is not. - */ - const isStaticStatic = node.static && node.key.name === "static"; - - /* - * For other unsafe names, we only care if there is no - * initializer. No initializer = hazard. - */ - if (!isStaticStatic && !node.value) { - return true; - } - } - - const followingToken = sourceCode.getTokenAfter(node); - - return unsafeClassFieldFollowers.has(followingToken.value); - } - - /** - * Check whether a given node is on the same line with the next token. - * @param {Node} node A statement node to check. - * @returns {boolean} `true` if the node is on the same line with the next token. - */ - function isOnSameLineWithNextToken(node) { - const prevToken = sourceCode.getLastToken(node, 1); - const nextToken = sourceCode.getTokenAfter(node); - - return !!nextToken && astUtils.isTokenOnSameLine(prevToken, nextToken); - } - - /** - * Check whether a given node can connect the next line if the next line is unreliable. - * @param {Node} node A statement node to check. - * @returns {boolean} `true` if the node can connect the next line. - */ - function maybeAsiHazardAfter(node) { - const t = node.type; - - if (t === "DoWhileStatement" || - t === "BreakStatement" || - t === "ContinueStatement" || - t === "DebuggerStatement" || - t === "ImportDeclaration" || - t === "ExportAllDeclaration" - ) { - return false; - } - if (t === "ReturnStatement") { - return Boolean(node.argument); - } - if (t === "ExportNamedDeclaration") { - return Boolean(node.declaration); - } - if (isEndOfArrowBlock(sourceCode.getLastToken(node, 1))) { - return false; - } - - return true; - } - - /** - * Check whether a given token can connect the previous statement. - * @param {Token} token A token to check. - * @returns {boolean} `true` if the token is one of `[`, `(`, `/`, `+`, `-`, ```, `++`, and `--`. - */ - function maybeAsiHazardBefore(token) { - return ( - Boolean(token) && - OPT_OUT_PATTERN.test(token.value) && - token.value !== "++" && - token.value !== "--" - ); - } - - /** - * Check if the semicolon of a given node is unnecessary, only true if: - * - next token is a valid statement divider (`;` or `}`). - * - next token is on a new line and the node is not connectable to the new line. - * @param {Node} node A statement node to check. - * @returns {boolean} whether the semicolon is unnecessary. - */ - function canRemoveSemicolon(node) { - if (isRedundantSemi(sourceCode.getLastToken(node))) { - return true; // `;;` or `;}` - } - if (maybeClassFieldAsiHazard(node)) { - return false; - } - if (isOnSameLineWithNextToken(node)) { - return false; // One liner. - } - - // continuation characters should not apply to class fields - if ( - node.type !== "PropertyDefinition" && - beforeStatementContinuationChars === "never" && - !maybeAsiHazardAfter(node) - ) { - return true; // ASI works. This statement doesn't connect to the next. - } - if (!maybeAsiHazardBefore(sourceCode.getTokenAfter(node))) { - return true; // ASI works. The next token doesn't connect to this statement. - } - - return false; - } - - /** - * Checks a node to see if it's the last item in a one-liner block. - * Block is any `BlockStatement` or `StaticBlock` node. Block is a one-liner if its - * braces (and consequently everything between them) are on the same line. - * @param {ASTNode} node The node to check. - * @returns {boolean} whether the node is the last item in a one-liner block. - */ - function isLastInOneLinerBlock(node) { - const parent = node.parent; - const nextToken = sourceCode.getTokenAfter(node); - - if (!nextToken || nextToken.value !== "}") { - return false; - } - - if (parent.type === "BlockStatement") { - return parent.loc.start.line === parent.loc.end.line; - } - - if (parent.type === "StaticBlock") { - const openingBrace = sourceCode.getFirstToken(parent, { skip: 1 }); // skip the `static` token - - return openingBrace.loc.start.line === parent.loc.end.line; - } - - return false; - } - - /** - * Checks a node to see if it's the last item in a one-liner `ClassBody` node. - * ClassBody is a one-liner if its braces (and consequently everything between them) are on the same line. - * @param {ASTNode} node The node to check. - * @returns {boolean} whether the node is the last item in a one-liner ClassBody. - */ - function isLastInOneLinerClassBody(node) { - const parent = node.parent; - const nextToken = sourceCode.getTokenAfter(node); - - if (!nextToken || nextToken.value !== "}") { - return false; - } - - if (parent.type === "ClassBody") { - return parent.loc.start.line === parent.loc.end.line; - } - - return false; - } - - /** - * Checks a node to see if it's followed by a semicolon. - * @param {ASTNode} node The node to check. - * @returns {void} - */ - function checkForSemicolon(node) { - const isSemi = astUtils.isSemicolonToken(sourceCode.getLastToken(node)); - - if (never) { - if (isSemi && canRemoveSemicolon(node)) { - report(node, true); - } else if ( - !isSemi && beforeStatementContinuationChars === "always" && - node.type !== "PropertyDefinition" && - maybeAsiHazardBefore(sourceCode.getTokenAfter(node)) - ) { - report(node); - } - } else { - const oneLinerBlock = (exceptOneLine && isLastInOneLinerBlock(node)); - const oneLinerClassBody = (exceptOneLineClassBody && isLastInOneLinerClassBody(node)); - const oneLinerBlockOrClassBody = oneLinerBlock || oneLinerClassBody; - - if (isSemi && oneLinerBlockOrClassBody) { - report(node, true); - } else if (!isSemi && !oneLinerBlockOrClassBody) { - report(node); - } - } - } - - /** - * Checks to see if there's a semicolon after a variable declaration. - * @param {ASTNode} node The node to check. - * @returns {void} - */ - function checkForSemicolonForVariableDeclaration(node) { - const parent = node.parent; - - if ((parent.type !== "ForStatement" || parent.init !== node) && - (!/^For(?:In|Of)Statement/u.test(parent.type) || parent.left !== node) - ) { - checkForSemicolon(node); - } - } - - //-------------------------------------------------------------------------- - // Public API - //-------------------------------------------------------------------------- - - return { - VariableDeclaration: checkForSemicolonForVariableDeclaration, - ExpressionStatement: checkForSemicolon, - ReturnStatement: checkForSemicolon, - ThrowStatement: checkForSemicolon, - DoWhileStatement: checkForSemicolon, - DebuggerStatement: checkForSemicolon, - BreakStatement: checkForSemicolon, - ContinueStatement: checkForSemicolon, - ImportDeclaration: checkForSemicolon, - ExportAllDeclaration: checkForSemicolon, - ExportNamedDeclaration(node) { - if (!node.declaration) { - checkForSemicolon(node); - } - }, - ExportDefaultDeclaration(node) { - if (!/(?:Class|Function)Declaration/u.test(node.declaration.type)) { - checkForSemicolon(node); - } - }, - PropertyDefinition: checkForSemicolon - }; - - } -}; diff --git a/tools/eslint/node_modules/eslint/lib/rules/sort-imports.js b/tools/eslint/node_modules/eslint/lib/rules/sort-imports.js deleted file mode 100644 index 9deaf1d4c97437..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/rules/sort-imports.js +++ /dev/null @@ -1,241 +0,0 @@ -/** - * @fileoverview Rule to require sorting of import declarations - * @author Christian Schuller - */ - -"use strict"; - -//------------------------------------------------------------------------------ -// Rule Definition -//------------------------------------------------------------------------------ - -/** @type {import('../shared/types').Rule} */ -module.exports = { - meta: { - type: "suggestion", - - docs: { - description: "Enforce sorted import declarations within modules", - recommended: false, - url: "https://eslint.org/docs/latest/rules/sort-imports" - }, - - schema: [ - { - type: "object", - properties: { - ignoreCase: { - type: "boolean", - default: false - }, - memberSyntaxSortOrder: { - type: "array", - items: { - enum: ["none", "all", "multiple", "single"] - }, - uniqueItems: true, - minItems: 4, - maxItems: 4 - }, - ignoreDeclarationSort: { - type: "boolean", - default: false - }, - ignoreMemberSort: { - type: "boolean", - default: false - }, - allowSeparatedGroups: { - type: "boolean", - default: false - } - }, - additionalProperties: false - } - ], - - fixable: "code", - - messages: { - sortImportsAlphabetically: "Imports should be sorted alphabetically.", - sortMembersAlphabetically: "Member '{{memberName}}' of the import declaration should be sorted alphabetically.", - unexpectedSyntaxOrder: "Expected '{{syntaxA}}' syntax before '{{syntaxB}}' syntax." - } - }, - - create(context) { - - const configuration = context.options[0] || {}, - ignoreCase = configuration.ignoreCase || false, - ignoreDeclarationSort = configuration.ignoreDeclarationSort || false, - ignoreMemberSort = configuration.ignoreMemberSort || false, - memberSyntaxSortOrder = configuration.memberSyntaxSortOrder || ["none", "all", "multiple", "single"], - allowSeparatedGroups = configuration.allowSeparatedGroups || false, - sourceCode = context.sourceCode; - let previousDeclaration = null; - - /** - * Gets the used member syntax style. - * - * import "my-module.js" --> none - * import * as myModule from "my-module.js" --> all - * import {myMember} from "my-module.js" --> single - * import {foo, bar} from "my-module.js" --> multiple - * @param {ASTNode} node the ImportDeclaration node. - * @returns {string} used member parameter style, ["all", "multiple", "single"] - */ - function usedMemberSyntax(node) { - if (node.specifiers.length === 0) { - return "none"; - } - if (node.specifiers[0].type === "ImportNamespaceSpecifier") { - return "all"; - } - if (node.specifiers.length === 1) { - return "single"; - } - return "multiple"; - - } - - /** - * Gets the group by member parameter index for given declaration. - * @param {ASTNode} node the ImportDeclaration node. - * @returns {number} the declaration group by member index. - */ - function getMemberParameterGroupIndex(node) { - return memberSyntaxSortOrder.indexOf(usedMemberSyntax(node)); - } - - /** - * Gets the local name of the first imported module. - * @param {ASTNode} node the ImportDeclaration node. - * @returns {?string} the local name of the first imported module. - */ - function getFirstLocalMemberName(node) { - if (node.specifiers[0]) { - return node.specifiers[0].local.name; - } - return null; - - } - - /** - * Calculates number of lines between two nodes. It is assumed that the given `left` node appears before - * the given `right` node in the source code. Lines are counted from the end of the `left` node till the - * start of the `right` node. If the given nodes are on the same line, it returns `0`, same as if they were - * on two consecutive lines. - * @param {ASTNode} left node that appears before the given `right` node. - * @param {ASTNode} right node that appears after the given `left` node. - * @returns {number} number of lines between nodes. - */ - function getNumberOfLinesBetween(left, right) { - return Math.max(right.loc.start.line - left.loc.end.line - 1, 0); - } - - return { - ImportDeclaration(node) { - if (!ignoreDeclarationSort) { - if ( - previousDeclaration && - allowSeparatedGroups && - getNumberOfLinesBetween(previousDeclaration, node) > 0 - ) { - - // reset declaration sort - previousDeclaration = null; - } - - if (previousDeclaration) { - const currentMemberSyntaxGroupIndex = getMemberParameterGroupIndex(node), - previousMemberSyntaxGroupIndex = getMemberParameterGroupIndex(previousDeclaration); - let currentLocalMemberName = getFirstLocalMemberName(node), - previousLocalMemberName = getFirstLocalMemberName(previousDeclaration); - - if (ignoreCase) { - previousLocalMemberName = previousLocalMemberName && previousLocalMemberName.toLowerCase(); - currentLocalMemberName = currentLocalMemberName && currentLocalMemberName.toLowerCase(); - } - - /* - * When the current declaration uses a different member syntax, - * then check if the ordering is correct. - * Otherwise, make a default string compare (like rule sort-vars to be consistent) of the first used local member name. - */ - if (currentMemberSyntaxGroupIndex !== previousMemberSyntaxGroupIndex) { - if (currentMemberSyntaxGroupIndex < previousMemberSyntaxGroupIndex) { - context.report({ - node, - messageId: "unexpectedSyntaxOrder", - data: { - syntaxA: memberSyntaxSortOrder[currentMemberSyntaxGroupIndex], - syntaxB: memberSyntaxSortOrder[previousMemberSyntaxGroupIndex] - } - }); - } - } else { - if (previousLocalMemberName && - currentLocalMemberName && - currentLocalMemberName < previousLocalMemberName - ) { - context.report({ - node, - messageId: "sortImportsAlphabetically" - }); - } - } - } - - previousDeclaration = node; - } - - if (!ignoreMemberSort) { - const importSpecifiers = node.specifiers.filter(specifier => specifier.type === "ImportSpecifier"); - const getSortableName = ignoreCase ? specifier => specifier.local.name.toLowerCase() : specifier => specifier.local.name; - const firstUnsortedIndex = importSpecifiers.map(getSortableName).findIndex((name, index, array) => array[index - 1] > name); - - if (firstUnsortedIndex !== -1) { - context.report({ - node: importSpecifiers[firstUnsortedIndex], - messageId: "sortMembersAlphabetically", - data: { memberName: importSpecifiers[firstUnsortedIndex].local.name }, - fix(fixer) { - if (importSpecifiers.some(specifier => - sourceCode.getCommentsBefore(specifier).length || sourceCode.getCommentsAfter(specifier).length)) { - - // If there are comments in the ImportSpecifier list, don't rearrange the specifiers. - return null; - } - - return fixer.replaceTextRange( - [importSpecifiers[0].range[0], importSpecifiers.at(-1).range[1]], - importSpecifiers - - // Clone the importSpecifiers array to avoid mutating it - .slice() - - // Sort the array into the desired order - .sort((specifierA, specifierB) => { - const aName = getSortableName(specifierA); - const bName = getSortableName(specifierB); - - return aName > bName ? 1 : -1; - }) - - // Build a string out of the sorted list of import specifiers and the text between the originals - .reduce((sourceText, specifier, index) => { - const textAfterSpecifier = index === importSpecifiers.length - 1 - ? "" - : sourceCode.getText().slice(importSpecifiers[index].range[1], importSpecifiers[index + 1].range[0]); - - return sourceText + sourceCode.getText(specifier) + textAfterSpecifier; - }, "") - ); - } - }); - } - } - } - }; - } -}; diff --git a/tools/eslint/node_modules/eslint/lib/rules/sort-keys.js b/tools/eslint/node_modules/eslint/lib/rules/sort-keys.js deleted file mode 100644 index e355e8afdc8d71..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/rules/sort-keys.js +++ /dev/null @@ -1,230 +0,0 @@ -/** - * @fileoverview Rule to require object keys to be sorted - * @author Toru Nagashima - */ - -"use strict"; - -//------------------------------------------------------------------------------ -// Requirements -//------------------------------------------------------------------------------ - -const astUtils = require("./utils/ast-utils"), - naturalCompare = require("natural-compare"); - -//------------------------------------------------------------------------------ -// Helpers -//------------------------------------------------------------------------------ - -/** - * Gets the property name of the given `Property` node. - * - * - If the property's key is an `Identifier` node, this returns the key's name - * whether it's a computed property or not. - * - If the property has a static name, this returns the static name. - * - Otherwise, this returns null. - * @param {ASTNode} node The `Property` node to get. - * @returns {string|null} The property name or null. - * @private - */ -function getPropertyName(node) { - const staticName = astUtils.getStaticPropertyName(node); - - if (staticName !== null) { - return staticName; - } - - return node.key.name || null; -} - -/** - * Functions which check that the given 2 names are in specific order. - * - * Postfix `I` is meant insensitive. - * Postfix `N` is meant natural. - * @private - */ -const isValidOrders = { - asc(a, b) { - return a <= b; - }, - ascI(a, b) { - return a.toLowerCase() <= b.toLowerCase(); - }, - ascN(a, b) { - return naturalCompare(a, b) <= 0; - }, - ascIN(a, b) { - return naturalCompare(a.toLowerCase(), b.toLowerCase()) <= 0; - }, - desc(a, b) { - return isValidOrders.asc(b, a); - }, - descI(a, b) { - return isValidOrders.ascI(b, a); - }, - descN(a, b) { - return isValidOrders.ascN(b, a); - }, - descIN(a, b) { - return isValidOrders.ascIN(b, a); - } -}; - -//------------------------------------------------------------------------------ -// Rule Definition -//------------------------------------------------------------------------------ - -/** @type {import('../shared/types').Rule} */ -module.exports = { - meta: { - type: "suggestion", - - docs: { - description: "Require object keys to be sorted", - recommended: false, - url: "https://eslint.org/docs/latest/rules/sort-keys" - }, - - schema: [ - { - enum: ["asc", "desc"] - }, - { - type: "object", - properties: { - caseSensitive: { - type: "boolean", - default: true - }, - natural: { - type: "boolean", - default: false - }, - minKeys: { - type: "integer", - minimum: 2, - default: 2 - }, - allowLineSeparatedGroups: { - type: "boolean", - default: false - } - }, - additionalProperties: false - } - ], - - messages: { - sortKeys: "Expected object keys to be in {{natural}}{{insensitive}}{{order}}ending order. '{{thisName}}' should be before '{{prevName}}'." - } - }, - - create(context) { - - // Parse options. - const order = context.options[0] || "asc"; - const options = context.options[1]; - const insensitive = options && options.caseSensitive === false; - const natural = options && options.natural; - const minKeys = options && options.minKeys; - const allowLineSeparatedGroups = options && options.allowLineSeparatedGroups || false; - const isValidOrder = isValidOrders[ - order + (insensitive ? "I" : "") + (natural ? "N" : "") - ]; - - // The stack to save the previous property's name for each object literals. - let stack = null; - const sourceCode = context.sourceCode; - - return { - ObjectExpression(node) { - stack = { - upper: stack, - prevNode: null, - prevBlankLine: false, - prevName: null, - numKeys: node.properties.length - }; - }, - - "ObjectExpression:exit"() { - stack = stack.upper; - }, - - SpreadElement(node) { - if (node.parent.type === "ObjectExpression") { - stack.prevName = null; - } - }, - - Property(node) { - if (node.parent.type === "ObjectPattern") { - return; - } - - const prevName = stack.prevName; - const numKeys = stack.numKeys; - const thisName = getPropertyName(node); - - // Get tokens between current node and previous node - const tokens = stack.prevNode && sourceCode - .getTokensBetween(stack.prevNode, node, { includeComments: true }); - - let isBlankLineBetweenNodes = stack.prevBlankLine; - - if (tokens) { - - // check blank line between tokens - tokens.forEach((token, index) => { - const previousToken = tokens[index - 1]; - - if (previousToken && (token.loc.start.line - previousToken.loc.end.line > 1)) { - isBlankLineBetweenNodes = true; - } - }); - - // check blank line between the current node and the last token - if (!isBlankLineBetweenNodes && (node.loc.start.line - tokens.at(-1).loc.end.line > 1)) { - isBlankLineBetweenNodes = true; - } - - // check blank line between the first token and the previous node - if (!isBlankLineBetweenNodes && (tokens[0].loc.start.line - stack.prevNode.loc.end.line > 1)) { - isBlankLineBetweenNodes = true; - } - } - - stack.prevNode = node; - - if (thisName !== null) { - stack.prevName = thisName; - } - - if (allowLineSeparatedGroups && isBlankLineBetweenNodes) { - stack.prevBlankLine = thisName === null; - return; - } - - if (prevName === null || thisName === null || numKeys < minKeys) { - return; - } - - if (!isValidOrder(prevName, thisName)) { - context.report({ - node, - loc: node.key.loc, - messageId: "sortKeys", - data: { - thisName, - prevName, - order, - insensitive: insensitive ? "insensitive " : "", - natural: natural ? "natural " : "" - } - }); - } - } - }; - } -}; diff --git a/tools/eslint/node_modules/eslint/lib/rules/sort-vars.js b/tools/eslint/node_modules/eslint/lib/rules/sort-vars.js deleted file mode 100644 index 21bfb88e8dd1cc..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/rules/sort-vars.js +++ /dev/null @@ -1,104 +0,0 @@ -/** - * @fileoverview Rule to require sorting of variables within a single Variable Declaration block - * @author Ilya Volodin - */ - -"use strict"; - -//------------------------------------------------------------------------------ -// Rule Definition -//------------------------------------------------------------------------------ - -/** @type {import('../shared/types').Rule} */ -module.exports = { - meta: { - type: "suggestion", - - docs: { - description: "Require variables within the same declaration block to be sorted", - recommended: false, - url: "https://eslint.org/docs/latest/rules/sort-vars" - }, - - schema: [ - { - type: "object", - properties: { - ignoreCase: { - type: "boolean", - default: false - } - }, - additionalProperties: false - } - ], - - fixable: "code", - - messages: { - sortVars: "Variables within the same declaration block should be sorted alphabetically." - } - }, - - create(context) { - - const configuration = context.options[0] || {}, - ignoreCase = configuration.ignoreCase || false, - sourceCode = context.sourceCode; - - return { - VariableDeclaration(node) { - const idDeclarations = node.declarations.filter(decl => decl.id.type === "Identifier"); - const getSortableName = ignoreCase ? decl => decl.id.name.toLowerCase() : decl => decl.id.name; - const unfixable = idDeclarations.some(decl => decl.init !== null && decl.init.type !== "Literal"); - let fixed = false; - - idDeclarations.slice(1).reduce((memo, decl) => { - const lastVariableName = getSortableName(memo), - currentVariableName = getSortableName(decl); - - if (currentVariableName < lastVariableName) { - context.report({ - node: decl, - messageId: "sortVars", - fix(fixer) { - if (unfixable || fixed) { - return null; - } - return fixer.replaceTextRange( - [idDeclarations[0].range[0], idDeclarations.at(-1).range[1]], - idDeclarations - - // Clone the idDeclarations array to avoid mutating it - .slice() - - // Sort the array into the desired order - .sort((declA, declB) => { - const aName = getSortableName(declA); - const bName = getSortableName(declB); - - return aName > bName ? 1 : -1; - }) - - // Build a string out of the sorted list of identifier declarations and the text between the originals - .reduce((sourceText, identifier, index) => { - const textAfterIdentifier = index === idDeclarations.length - 1 - ? "" - : sourceCode.getText().slice(idDeclarations[index].range[1], idDeclarations[index + 1].range[0]); - - return sourceText + sourceCode.getText(identifier) + textAfterIdentifier; - }, "") - - ); - } - }); - fixed = true; - return memo; - } - return decl; - - }, idDeclarations[0]); - } - }; - } -}; diff --git a/tools/eslint/node_modules/eslint/lib/rules/space-before-blocks.js b/tools/eslint/node_modules/eslint/lib/rules/space-before-blocks.js deleted file mode 100644 index a4a5449e17fde3..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/rules/space-before-blocks.js +++ /dev/null @@ -1,204 +0,0 @@ -/** - * @fileoverview A rule to ensure whitespace before blocks. - * @author Mathias Schreck - * @deprecated in ESLint v8.53.0 - */ - -"use strict"; - -//------------------------------------------------------------------------------ -// Requirements -//------------------------------------------------------------------------------ - -const astUtils = require("./utils/ast-utils"); - -//------------------------------------------------------------------------------ -// Helpers -//------------------------------------------------------------------------------ - -/** - * Checks whether the given node represents the body of a function. - * @param {ASTNode} node the node to check. - * @returns {boolean} `true` if the node is function body. - */ -function isFunctionBody(node) { - const parent = node.parent; - - return ( - node.type === "BlockStatement" && - astUtils.isFunction(parent) && - parent.body === node - ); -} - -//------------------------------------------------------------------------------ -// Rule Definition -//------------------------------------------------------------------------------ - -/** @type {import('../shared/types').Rule} */ -module.exports = { - meta: { - deprecated: true, - replacedBy: [], - type: "layout", - - docs: { - description: "Enforce consistent spacing before blocks", - recommended: false, - url: "https://eslint.org/docs/latest/rules/space-before-blocks" - }, - - fixable: "whitespace", - - schema: [ - { - oneOf: [ - { - enum: ["always", "never"] - }, - { - type: "object", - properties: { - keywords: { - enum: ["always", "never", "off"] - }, - functions: { - enum: ["always", "never", "off"] - }, - classes: { - enum: ["always", "never", "off"] - } - }, - additionalProperties: false - } - ] - } - ], - - messages: { - unexpectedSpace: "Unexpected space before opening brace.", - missingSpace: "Missing space before opening brace." - } - }, - - create(context) { - const config = context.options[0], - sourceCode = context.sourceCode; - let alwaysFunctions = true, - alwaysKeywords = true, - alwaysClasses = true, - neverFunctions = false, - neverKeywords = false, - neverClasses = false; - - if (typeof config === "object") { - alwaysFunctions = config.functions === "always"; - alwaysKeywords = config.keywords === "always"; - alwaysClasses = config.classes === "always"; - neverFunctions = config.functions === "never"; - neverKeywords = config.keywords === "never"; - neverClasses = config.classes === "never"; - } else if (config === "never") { - alwaysFunctions = false; - alwaysKeywords = false; - alwaysClasses = false; - neverFunctions = true; - neverKeywords = true; - neverClasses = true; - } - - /** - * Checks whether the spacing before the given block is already controlled by another rule: - * - `arrow-spacing` checks spaces after `=>`. - * - `keyword-spacing` checks spaces after keywords in certain contexts. - * - `switch-colon-spacing` checks spaces after `:` of switch cases. - * @param {Token} precedingToken first token before the block. - * @param {ASTNode|Token} node `BlockStatement` node or `{` token of a `SwitchStatement` node. - * @returns {boolean} `true` if requiring or disallowing spaces before the given block could produce conflicts with other rules. - */ - function isConflicted(precedingToken, node) { - return ( - astUtils.isArrowToken(precedingToken) || - ( - astUtils.isKeywordToken(precedingToken) && - !isFunctionBody(node) - ) || - ( - astUtils.isColonToken(precedingToken) && - node.parent && - node.parent.type === "SwitchCase" && - precedingToken === astUtils.getSwitchCaseColonToken(node.parent, sourceCode) - ) - ); - } - - /** - * Checks the given BlockStatement node has a preceding space if it doesnโ€™t start on a new line. - * @param {ASTNode|Token} node The AST node of a BlockStatement. - * @returns {void} undefined. - */ - function checkPrecedingSpace(node) { - const precedingToken = sourceCode.getTokenBefore(node); - - if (precedingToken && !isConflicted(precedingToken, node) && astUtils.isTokenOnSameLine(precedingToken, node)) { - const hasSpace = sourceCode.isSpaceBetweenTokens(precedingToken, node); - let requireSpace; - let requireNoSpace; - - if (isFunctionBody(node)) { - requireSpace = alwaysFunctions; - requireNoSpace = neverFunctions; - } else if (node.type === "ClassBody") { - requireSpace = alwaysClasses; - requireNoSpace = neverClasses; - } else { - requireSpace = alwaysKeywords; - requireNoSpace = neverKeywords; - } - - if (requireSpace && !hasSpace) { - context.report({ - node, - messageId: "missingSpace", - fix(fixer) { - return fixer.insertTextBefore(node, " "); - } - }); - } else if (requireNoSpace && hasSpace) { - context.report({ - node, - messageId: "unexpectedSpace", - fix(fixer) { - return fixer.removeRange([precedingToken.range[1], node.range[0]]); - } - }); - } - } - } - - /** - * Checks if the CaseBlock of an given SwitchStatement node has a preceding space. - * @param {ASTNode} node The node of a SwitchStatement. - * @returns {void} undefined. - */ - function checkSpaceBeforeCaseBlock(node) { - const cases = node.cases; - let openingBrace; - - if (cases.length > 0) { - openingBrace = sourceCode.getTokenBefore(cases[0]); - } else { - openingBrace = sourceCode.getLastToken(node, 1); - } - - checkPrecedingSpace(openingBrace); - } - - return { - BlockStatement: checkPrecedingSpace, - ClassBody: checkPrecedingSpace, - SwitchStatement: checkSpaceBeforeCaseBlock - }; - - } -}; diff --git a/tools/eslint/node_modules/eslint/lib/rules/space-before-function-paren.js b/tools/eslint/node_modules/eslint/lib/rules/space-before-function-paren.js deleted file mode 100644 index 575a1597a74ecf..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/rules/space-before-function-paren.js +++ /dev/null @@ -1,167 +0,0 @@ -/** - * @fileoverview Rule to validate spacing before function paren. - * @author Mathias Schreck - * @deprecated in ESLint v8.53.0 - */ -"use strict"; - -//------------------------------------------------------------------------------ -// Requirements -//------------------------------------------------------------------------------ - -const astUtils = require("./utils/ast-utils"); - -//------------------------------------------------------------------------------ -// Rule Definition -//------------------------------------------------------------------------------ - -/** @type {import('../shared/types').Rule} */ -module.exports = { - meta: { - deprecated: true, - replacedBy: [], - type: "layout", - - docs: { - description: "Enforce consistent spacing before `function` definition opening parenthesis", - recommended: false, - url: "https://eslint.org/docs/latest/rules/space-before-function-paren" - }, - - fixable: "whitespace", - - schema: [ - { - oneOf: [ - { - enum: ["always", "never"] - }, - { - type: "object", - properties: { - anonymous: { - enum: ["always", "never", "ignore"] - }, - named: { - enum: ["always", "never", "ignore"] - }, - asyncArrow: { - enum: ["always", "never", "ignore"] - } - }, - additionalProperties: false - } - ] - } - ], - - messages: { - unexpectedSpace: "Unexpected space before function parentheses.", - missingSpace: "Missing space before function parentheses." - } - }, - - create(context) { - const sourceCode = context.sourceCode; - const baseConfig = typeof context.options[0] === "string" ? context.options[0] : "always"; - const overrideConfig = typeof context.options[0] === "object" ? context.options[0] : {}; - - /** - * Determines whether a function has a name. - * @param {ASTNode} node The function node. - * @returns {boolean} Whether the function has a name. - */ - function isNamedFunction(node) { - if (node.id) { - return true; - } - - const parent = node.parent; - - return parent.type === "MethodDefinition" || - (parent.type === "Property" && - ( - parent.kind === "get" || - parent.kind === "set" || - parent.method - ) - ); - } - - /** - * Gets the config for a given function - * @param {ASTNode} node The function node - * @returns {string} "always", "never", or "ignore" - */ - function getConfigForFunction(node) { - if (node.type === "ArrowFunctionExpression") { - - // Always ignore non-async functions and arrow functions without parens, e.g. async foo => bar - if (node.async && astUtils.isOpeningParenToken(sourceCode.getFirstToken(node, { skip: 1 }))) { - return overrideConfig.asyncArrow || baseConfig; - } - } else if (isNamedFunction(node)) { - return overrideConfig.named || baseConfig; - - // `generator-star-spacing` should warn anonymous generators. E.g. `function* () {}` - } else if (!node.generator) { - return overrideConfig.anonymous || baseConfig; - } - - return "ignore"; - } - - /** - * Checks the parens of a function node - * @param {ASTNode} node A function node - * @returns {void} - */ - function checkFunction(node) { - const functionConfig = getConfigForFunction(node); - - if (functionConfig === "ignore") { - return; - } - - const rightToken = sourceCode.getFirstToken(node, astUtils.isOpeningParenToken); - const leftToken = sourceCode.getTokenBefore(rightToken); - const hasSpacing = sourceCode.isSpaceBetweenTokens(leftToken, rightToken); - - if (hasSpacing && functionConfig === "never") { - context.report({ - node, - loc: { - start: leftToken.loc.end, - end: rightToken.loc.start - }, - messageId: "unexpectedSpace", - fix(fixer) { - const comments = sourceCode.getCommentsBefore(rightToken); - - // Don't fix anything if there's a single line comment between the left and the right token - if (comments.some(comment => comment.type === "Line")) { - return null; - } - return fixer.replaceTextRange( - [leftToken.range[1], rightToken.range[0]], - comments.reduce((text, comment) => text + sourceCode.getText(comment), "") - ); - } - }); - } else if (!hasSpacing && functionConfig === "always") { - context.report({ - node, - loc: rightToken.loc, - messageId: "missingSpace", - fix: fixer => fixer.insertTextAfter(leftToken, " ") - }); - } - } - - return { - ArrowFunctionExpression: checkFunction, - FunctionDeclaration: checkFunction, - FunctionExpression: checkFunction - }; - } -}; diff --git a/tools/eslint/node_modules/eslint/lib/rules/space-in-parens.js b/tools/eslint/node_modules/eslint/lib/rules/space-in-parens.js deleted file mode 100644 index d15a64317f4d08..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/rules/space-in-parens.js +++ /dev/null @@ -1,285 +0,0 @@ -/** - * @fileoverview Disallows or enforces spaces inside of parentheses. - * @author Jonathan Rajavuori - * @deprecated in ESLint v8.53.0 - */ -"use strict"; - -const astUtils = require("./utils/ast-utils"); - -//------------------------------------------------------------------------------ -// Rule Definition -//------------------------------------------------------------------------------ - -/** @type {import('../shared/types').Rule} */ -module.exports = { - meta: { - deprecated: true, - replacedBy: [], - type: "layout", - - docs: { - description: "Enforce consistent spacing inside parentheses", - recommended: false, - url: "https://eslint.org/docs/latest/rules/space-in-parens" - }, - - fixable: "whitespace", - - schema: [ - { - enum: ["always", "never"] - }, - { - type: "object", - properties: { - exceptions: { - type: "array", - items: { - enum: ["{}", "[]", "()", "empty"] - }, - uniqueItems: true - } - }, - additionalProperties: false - } - ], - - messages: { - missingOpeningSpace: "There must be a space after this paren.", - missingClosingSpace: "There must be a space before this paren.", - rejectedOpeningSpace: "There should be no space after this paren.", - rejectedClosingSpace: "There should be no space before this paren." - } - }, - - create(context) { - const ALWAYS = context.options[0] === "always", - exceptionsArrayOptions = (context.options[1] && context.options[1].exceptions) || [], - options = {}; - - let exceptions; - - if (exceptionsArrayOptions.length) { - options.braceException = exceptionsArrayOptions.includes("{}"); - options.bracketException = exceptionsArrayOptions.includes("[]"); - options.parenException = exceptionsArrayOptions.includes("()"); - options.empty = exceptionsArrayOptions.includes("empty"); - } - - /** - * Produces an object with the opener and closer exception values - * @returns {Object} `openers` and `closers` exception values - * @private - */ - function getExceptions() { - const openers = [], - closers = []; - - if (options.braceException) { - openers.push("{"); - closers.push("}"); - } - - if (options.bracketException) { - openers.push("["); - closers.push("]"); - } - - if (options.parenException) { - openers.push("("); - closers.push(")"); - } - - if (options.empty) { - openers.push(")"); - closers.push("("); - } - - return { - openers, - closers - }; - } - - //-------------------------------------------------------------------------- - // Helpers - //-------------------------------------------------------------------------- - const sourceCode = context.sourceCode; - - /** - * Determines if a token is one of the exceptions for the opener paren - * @param {Object} token The token to check - * @returns {boolean} True if the token is one of the exceptions for the opener paren - */ - function isOpenerException(token) { - return exceptions.openers.includes(token.value); - } - - /** - * Determines if a token is one of the exceptions for the closer paren - * @param {Object} token The token to check - * @returns {boolean} True if the token is one of the exceptions for the closer paren - */ - function isCloserException(token) { - return exceptions.closers.includes(token.value); - } - - /** - * Determines if an opening paren is immediately followed by a required space - * @param {Object} openingParenToken The paren token - * @param {Object} tokenAfterOpeningParen The token after it - * @returns {boolean} True if the opening paren is missing a required space - */ - function openerMissingSpace(openingParenToken, tokenAfterOpeningParen) { - if (sourceCode.isSpaceBetweenTokens(openingParenToken, tokenAfterOpeningParen)) { - return false; - } - - if (!options.empty && astUtils.isClosingParenToken(tokenAfterOpeningParen)) { - return false; - } - - if (ALWAYS) { - return !isOpenerException(tokenAfterOpeningParen); - } - return isOpenerException(tokenAfterOpeningParen); - } - - /** - * Determines if an opening paren is immediately followed by a disallowed space - * @param {Object} openingParenToken The paren token - * @param {Object} tokenAfterOpeningParen The token after it - * @returns {boolean} True if the opening paren has a disallowed space - */ - function openerRejectsSpace(openingParenToken, tokenAfterOpeningParen) { - if (!astUtils.isTokenOnSameLine(openingParenToken, tokenAfterOpeningParen)) { - return false; - } - - if (tokenAfterOpeningParen.type === "Line") { - return false; - } - - if (!sourceCode.isSpaceBetweenTokens(openingParenToken, tokenAfterOpeningParen)) { - return false; - } - - if (ALWAYS) { - return isOpenerException(tokenAfterOpeningParen); - } - return !isOpenerException(tokenAfterOpeningParen); - } - - /** - * Determines if a closing paren is immediately preceded by a required space - * @param {Object} tokenBeforeClosingParen The token before the paren - * @param {Object} closingParenToken The paren token - * @returns {boolean} True if the closing paren is missing a required space - */ - function closerMissingSpace(tokenBeforeClosingParen, closingParenToken) { - if (sourceCode.isSpaceBetweenTokens(tokenBeforeClosingParen, closingParenToken)) { - return false; - } - - if (!options.empty && astUtils.isOpeningParenToken(tokenBeforeClosingParen)) { - return false; - } - - if (ALWAYS) { - return !isCloserException(tokenBeforeClosingParen); - } - return isCloserException(tokenBeforeClosingParen); - } - - /** - * Determines if a closer paren is immediately preceded by a disallowed space - * @param {Object} tokenBeforeClosingParen The token before the paren - * @param {Object} closingParenToken The paren token - * @returns {boolean} True if the closing paren has a disallowed space - */ - function closerRejectsSpace(tokenBeforeClosingParen, closingParenToken) { - if (!astUtils.isTokenOnSameLine(tokenBeforeClosingParen, closingParenToken)) { - return false; - } - - if (!sourceCode.isSpaceBetweenTokens(tokenBeforeClosingParen, closingParenToken)) { - return false; - } - - if (ALWAYS) { - return isCloserException(tokenBeforeClosingParen); - } - return !isCloserException(tokenBeforeClosingParen); - } - - //-------------------------------------------------------------------------- - // Public - //-------------------------------------------------------------------------- - - return { - Program: function checkParenSpaces(node) { - exceptions = getExceptions(); - const tokens = sourceCode.tokensAndComments; - - tokens.forEach((token, i) => { - const prevToken = tokens[i - 1]; - const nextToken = tokens[i + 1]; - - // if token is not an opening or closing paren token, do nothing - if (!astUtils.isOpeningParenToken(token) && !astUtils.isClosingParenToken(token)) { - return; - } - - // if token is an opening paren and is not followed by a required space - if (token.value === "(" && openerMissingSpace(token, nextToken)) { - context.report({ - node, - loc: token.loc, - messageId: "missingOpeningSpace", - fix(fixer) { - return fixer.insertTextAfter(token, " "); - } - }); - } - - // if token is an opening paren and is followed by a disallowed space - if (token.value === "(" && openerRejectsSpace(token, nextToken)) { - context.report({ - node, - loc: { start: token.loc.end, end: nextToken.loc.start }, - messageId: "rejectedOpeningSpace", - fix(fixer) { - return fixer.removeRange([token.range[1], nextToken.range[0]]); - } - }); - } - - // if token is a closing paren and is not preceded by a required space - if (token.value === ")" && closerMissingSpace(prevToken, token)) { - context.report({ - node, - loc: token.loc, - messageId: "missingClosingSpace", - fix(fixer) { - return fixer.insertTextBefore(token, " "); - } - }); - } - - // if token is a closing paren and is preceded by a disallowed space - if (token.value === ")" && closerRejectsSpace(prevToken, token)) { - context.report({ - node, - loc: { start: prevToken.loc.end, end: token.loc.start }, - messageId: "rejectedClosingSpace", - fix(fixer) { - return fixer.removeRange([prevToken.range[1], token.range[0]]); - } - }); - } - }); - } - }; - } -}; diff --git a/tools/eslint/node_modules/eslint/lib/rules/space-infix-ops.js b/tools/eslint/node_modules/eslint/lib/rules/space-infix-ops.js deleted file mode 100644 index 40071019480a57..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/rules/space-infix-ops.js +++ /dev/null @@ -1,198 +0,0 @@ -/** - * @fileoverview Require spaces around infix operators - * @author Michael Ficarra - * @deprecated in ESLint v8.53.0 - */ -"use strict"; - -const { isEqToken } = require("./utils/ast-utils"); - -//------------------------------------------------------------------------------ -// Rule Definition -//------------------------------------------------------------------------------ - -/** @type {import('../shared/types').Rule} */ -module.exports = { - meta: { - deprecated: true, - replacedBy: [], - type: "layout", - - docs: { - description: "Require spacing around infix operators", - recommended: false, - url: "https://eslint.org/docs/latest/rules/space-infix-ops" - }, - - fixable: "whitespace", - - schema: [ - { - type: "object", - properties: { - int32Hint: { - type: "boolean", - default: false - } - }, - additionalProperties: false - } - ], - - messages: { - missingSpace: "Operator '{{operator}}' must be spaced." - } - }, - - create(context) { - const int32Hint = context.options[0] ? context.options[0].int32Hint === true : false; - const sourceCode = context.sourceCode; - - /** - * Returns the first token which violates the rule - * @param {ASTNode} left The left node of the main node - * @param {ASTNode} right The right node of the main node - * @param {string} op The operator of the main node - * @returns {Object} The violator token or null - * @private - */ - function getFirstNonSpacedToken(left, right, op) { - const operator = sourceCode.getFirstTokenBetween(left, right, token => token.value === op); - const prev = sourceCode.getTokenBefore(operator); - const next = sourceCode.getTokenAfter(operator); - - if (!sourceCode.isSpaceBetweenTokens(prev, operator) || !sourceCode.isSpaceBetweenTokens(operator, next)) { - return operator; - } - - return null; - } - - /** - * Reports an AST node as a rule violation - * @param {ASTNode} mainNode The node to report - * @param {Object} culpritToken The token which has a problem - * @returns {void} - * @private - */ - function report(mainNode, culpritToken) { - context.report({ - node: mainNode, - loc: culpritToken.loc, - messageId: "missingSpace", - data: { - operator: culpritToken.value - }, - fix(fixer) { - const previousToken = sourceCode.getTokenBefore(culpritToken); - const afterToken = sourceCode.getTokenAfter(culpritToken); - let fixString = ""; - - if (culpritToken.range[0] - previousToken.range[1] === 0) { - fixString = " "; - } - - fixString += culpritToken.value; - - if (afterToken.range[0] - culpritToken.range[1] === 0) { - fixString += " "; - } - - return fixer.replaceText(culpritToken, fixString); - } - }); - } - - /** - * Check if the node is binary then report - * @param {ASTNode} node node to evaluate - * @returns {void} - * @private - */ - function checkBinary(node) { - const leftNode = (node.left.typeAnnotation) ? node.left.typeAnnotation : node.left; - const rightNode = node.right; - - // search for = in AssignmentPattern nodes - const operator = node.operator || "="; - - const nonSpacedNode = getFirstNonSpacedToken(leftNode, rightNode, operator); - - if (nonSpacedNode) { - if (!(int32Hint && sourceCode.getText(node).endsWith("|0"))) { - report(node, nonSpacedNode); - } - } - } - - /** - * Check if the node is conditional - * @param {ASTNode} node node to evaluate - * @returns {void} - * @private - */ - function checkConditional(node) { - const nonSpacedConsequentNode = getFirstNonSpacedToken(node.test, node.consequent, "?"); - const nonSpacedAlternateNode = getFirstNonSpacedToken(node.consequent, node.alternate, ":"); - - if (nonSpacedConsequentNode) { - report(node, nonSpacedConsequentNode); - } - - if (nonSpacedAlternateNode) { - report(node, nonSpacedAlternateNode); - } - } - - /** - * Check if the node is a variable - * @param {ASTNode} node node to evaluate - * @returns {void} - * @private - */ - function checkVar(node) { - const leftNode = (node.id.typeAnnotation) ? node.id.typeAnnotation : node.id; - const rightNode = node.init; - - if (rightNode) { - const nonSpacedNode = getFirstNonSpacedToken(leftNode, rightNode, "="); - - if (nonSpacedNode) { - report(node, nonSpacedNode); - } - } - } - - return { - AssignmentExpression: checkBinary, - AssignmentPattern: checkBinary, - BinaryExpression: checkBinary, - LogicalExpression: checkBinary, - ConditionalExpression: checkConditional, - VariableDeclarator: checkVar, - - PropertyDefinition(node) { - if (!node.value) { - return; - } - - /* - * Because of computed properties and type annotations, some - * tokens may exist between `node.key` and `=`. - * Therefore, find the `=` from the right. - */ - const operatorToken = sourceCode.getTokenBefore(node.value, isEqToken); - const leftToken = sourceCode.getTokenBefore(operatorToken); - const rightToken = sourceCode.getTokenAfter(operatorToken); - - if ( - !sourceCode.isSpaceBetweenTokens(leftToken, operatorToken) || - !sourceCode.isSpaceBetweenTokens(operatorToken, rightToken) - ) { - report(node, operatorToken); - } - } - }; - - } -}; diff --git a/tools/eslint/node_modules/eslint/lib/rules/space-unary-ops.js b/tools/eslint/node_modules/eslint/lib/rules/space-unary-ops.js deleted file mode 100644 index ab6c3cb6cd9235..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/rules/space-unary-ops.js +++ /dev/null @@ -1,324 +0,0 @@ -/** - * @fileoverview This rule should require or disallow spaces before or after unary operations. - * @author Marcin Kumorek - * @deprecated in ESLint v8.53.0 - */ -"use strict"; - -//------------------------------------------------------------------------------ -// Requirements -//------------------------------------------------------------------------------ - -const astUtils = require("./utils/ast-utils"); - -//------------------------------------------------------------------------------ -// Rule Definition -//------------------------------------------------------------------------------ - -/** @type {import('../shared/types').Rule} */ -module.exports = { - meta: { - deprecated: true, - replacedBy: [], - type: "layout", - - docs: { - description: "Enforce consistent spacing before or after unary operators", - recommended: false, - url: "https://eslint.org/docs/latest/rules/space-unary-ops" - }, - - fixable: "whitespace", - - schema: [ - { - type: "object", - properties: { - words: { - type: "boolean", - default: true - }, - nonwords: { - type: "boolean", - default: false - }, - overrides: { - type: "object", - additionalProperties: { - type: "boolean" - } - } - }, - additionalProperties: false - } - ], - messages: { - unexpectedBefore: "Unexpected space before unary operator '{{operator}}'.", - unexpectedAfter: "Unexpected space after unary operator '{{operator}}'.", - unexpectedAfterWord: "Unexpected space after unary word operator '{{word}}'.", - wordOperator: "Unary word operator '{{word}}' must be followed by whitespace.", - operator: "Unary operator '{{operator}}' must be followed by whitespace.", - beforeUnaryExpressions: "Space is required before unary expressions '{{token}}'." - } - }, - - create(context) { - const options = context.options[0] || { words: true, nonwords: false }; - - const sourceCode = context.sourceCode; - - //-------------------------------------------------------------------------- - // Helpers - //-------------------------------------------------------------------------- - - /** - * Check if the node is the first "!" in a "!!" convert to Boolean expression - * @param {ASTnode} node AST node - * @returns {boolean} Whether or not the node is first "!" in "!!" - */ - function isFirstBangInBangBangExpression(node) { - return node && node.type === "UnaryExpression" && node.argument.operator === "!" && - node.argument && node.argument.type === "UnaryExpression" && node.argument.operator === "!"; - } - - /** - * Checks if an override exists for a given operator. - * @param {string} operator Operator - * @returns {boolean} Whether or not an override has been provided for the operator - */ - function overrideExistsForOperator(operator) { - return options.overrides && Object.hasOwn(options.overrides, operator); - } - - /** - * Gets the value that the override was set to for this operator - * @param {string} operator Operator - * @returns {boolean} Whether or not an override enforces a space with this operator - */ - function overrideEnforcesSpaces(operator) { - return options.overrides[operator]; - } - - /** - * Verify Unary Word Operator has spaces after the word operator - * @param {ASTnode} node AST node - * @param {Object} firstToken first token from the AST node - * @param {Object} secondToken second token from the AST node - * @param {string} word The word to be used for reporting - * @returns {void} - */ - function verifyWordHasSpaces(node, firstToken, secondToken, word) { - if (secondToken.range[0] === firstToken.range[1]) { - context.report({ - node, - messageId: "wordOperator", - data: { - word - }, - fix(fixer) { - return fixer.insertTextAfter(firstToken, " "); - } - }); - } - } - - /** - * Verify Unary Word Operator doesn't have spaces after the word operator - * @param {ASTnode} node AST node - * @param {Object} firstToken first token from the AST node - * @param {Object} secondToken second token from the AST node - * @param {string} word The word to be used for reporting - * @returns {void} - */ - function verifyWordDoesntHaveSpaces(node, firstToken, secondToken, word) { - if (astUtils.canTokensBeAdjacent(firstToken, secondToken)) { - if (secondToken.range[0] > firstToken.range[1]) { - context.report({ - node, - messageId: "unexpectedAfterWord", - data: { - word - }, - fix(fixer) { - return fixer.removeRange([firstToken.range[1], secondToken.range[0]]); - } - }); - } - } - } - - /** - * Check Unary Word Operators for spaces after the word operator - * @param {ASTnode} node AST node - * @param {Object} firstToken first token from the AST node - * @param {Object} secondToken second token from the AST node - * @param {string} word The word to be used for reporting - * @returns {void} - */ - function checkUnaryWordOperatorForSpaces(node, firstToken, secondToken, word) { - if (overrideExistsForOperator(word)) { - if (overrideEnforcesSpaces(word)) { - verifyWordHasSpaces(node, firstToken, secondToken, word); - } else { - verifyWordDoesntHaveSpaces(node, firstToken, secondToken, word); - } - } else if (options.words) { - verifyWordHasSpaces(node, firstToken, secondToken, word); - } else { - verifyWordDoesntHaveSpaces(node, firstToken, secondToken, word); - } - } - - /** - * Verifies YieldExpressions satisfy spacing requirements - * @param {ASTnode} node AST node - * @returns {void} - */ - function checkForSpacesAfterYield(node) { - const tokens = sourceCode.getFirstTokens(node, 3), - word = "yield"; - - if (!node.argument || node.delegate) { - return; - } - - checkUnaryWordOperatorForSpaces(node, tokens[0], tokens[1], word); - } - - /** - * Verifies AwaitExpressions satisfy spacing requirements - * @param {ASTNode} node AwaitExpression AST node - * @returns {void} - */ - function checkForSpacesAfterAwait(node) { - const tokens = sourceCode.getFirstTokens(node, 3); - - checkUnaryWordOperatorForSpaces(node, tokens[0], tokens[1], "await"); - } - - /** - * Verifies UnaryExpression, UpdateExpression and NewExpression have spaces before or after the operator - * @param {ASTnode} node AST node - * @param {Object} firstToken First token in the expression - * @param {Object} secondToken Second token in the expression - * @returns {void} - */ - function verifyNonWordsHaveSpaces(node, firstToken, secondToken) { - if (node.prefix) { - if (isFirstBangInBangBangExpression(node)) { - return; - } - if (firstToken.range[1] === secondToken.range[0]) { - context.report({ - node, - messageId: "operator", - data: { - operator: firstToken.value - }, - fix(fixer) { - return fixer.insertTextAfter(firstToken, " "); - } - }); - } - } else { - if (firstToken.range[1] === secondToken.range[0]) { - context.report({ - node, - messageId: "beforeUnaryExpressions", - data: { - token: secondToken.value - }, - fix(fixer) { - return fixer.insertTextBefore(secondToken, " "); - } - }); - } - } - } - - /** - * Verifies UnaryExpression, UpdateExpression and NewExpression don't have spaces before or after the operator - * @param {ASTnode} node AST node - * @param {Object} firstToken First token in the expression - * @param {Object} secondToken Second token in the expression - * @returns {void} - */ - function verifyNonWordsDontHaveSpaces(node, firstToken, secondToken) { - if (node.prefix) { - if (secondToken.range[0] > firstToken.range[1]) { - context.report({ - node, - messageId: "unexpectedAfter", - data: { - operator: firstToken.value - }, - fix(fixer) { - if (astUtils.canTokensBeAdjacent(firstToken, secondToken)) { - return fixer.removeRange([firstToken.range[1], secondToken.range[0]]); - } - return null; - } - }); - } - } else { - if (secondToken.range[0] > firstToken.range[1]) { - context.report({ - node, - messageId: "unexpectedBefore", - data: { - operator: secondToken.value - }, - fix(fixer) { - return fixer.removeRange([firstToken.range[1], secondToken.range[0]]); - } - }); - } - } - } - - /** - * Verifies UnaryExpression, UpdateExpression and NewExpression satisfy spacing requirements - * @param {ASTnode} node AST node - * @returns {void} - */ - function checkForSpaces(node) { - const tokens = node.type === "UpdateExpression" && !node.prefix - ? sourceCode.getLastTokens(node, 2) - : sourceCode.getFirstTokens(node, 2); - const firstToken = tokens[0]; - const secondToken = tokens[1]; - - if ((node.type === "NewExpression" || node.prefix) && firstToken.type === "Keyword") { - checkUnaryWordOperatorForSpaces(node, firstToken, secondToken, firstToken.value); - return; - } - - const operator = node.prefix ? tokens[0].value : tokens[1].value; - - if (overrideExistsForOperator(operator)) { - if (overrideEnforcesSpaces(operator)) { - verifyNonWordsHaveSpaces(node, firstToken, secondToken); - } else { - verifyNonWordsDontHaveSpaces(node, firstToken, secondToken); - } - } else if (options.nonwords) { - verifyNonWordsHaveSpaces(node, firstToken, secondToken); - } else { - verifyNonWordsDontHaveSpaces(node, firstToken, secondToken); - } - } - - //-------------------------------------------------------------------------- - // Public - //-------------------------------------------------------------------------- - - return { - UnaryExpression: checkForSpaces, - UpdateExpression: checkForSpaces, - NewExpression: checkForSpaces, - YieldExpression: checkForSpacesAfterYield, - AwaitExpression: checkForSpacesAfterAwait - }; - - } -}; diff --git a/tools/eslint/node_modules/eslint/lib/rules/spaced-comment.js b/tools/eslint/node_modules/eslint/lib/rules/spaced-comment.js deleted file mode 100644 index 90ac7032d03f9d..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/rules/spaced-comment.js +++ /dev/null @@ -1,385 +0,0 @@ -/** - * @fileoverview Source code for spaced-comments rule - * @author Gyandeep Singh - * @deprecated in ESLint v8.53.0 - */ -"use strict"; - -const escapeRegExp = require("escape-string-regexp"); -const astUtils = require("./utils/ast-utils"); - -//------------------------------------------------------------------------------ -// Helpers -//------------------------------------------------------------------------------ - -/** - * Escapes the control characters of a given string. - * @param {string} s A string to escape. - * @returns {string} An escaped string. - */ -function escape(s) { - return `(?:${escapeRegExp(s)})`; -} - -/** - * Escapes the control characters of a given string. - * And adds a repeat flag. - * @param {string} s A string to escape. - * @returns {string} An escaped string. - */ -function escapeAndRepeat(s) { - return `${escape(s)}+`; -} - -/** - * Parses `markers` option. - * If markers don't include `"*"`, this adds `"*"` to allow JSDoc comments. - * @param {string[]} [markers] A marker list. - * @returns {string[]} A marker list. - */ -function parseMarkersOption(markers) { - - // `*` is a marker for JSDoc comments. - if (!markers.includes("*")) { - return markers.concat("*"); - } - - return markers; -} - -/** - * Creates string pattern for exceptions. - * Generated pattern: - * - * 1. A space or an exception pattern sequence. - * @param {string[]} exceptions An exception pattern list. - * @returns {string} A regular expression string for exceptions. - */ -function createExceptionsPattern(exceptions) { - let pattern = ""; - - /* - * A space or an exception pattern sequence. - * [] ==> "\s" - * ["-"] ==> "(?:\s|\-+$)" - * ["-", "="] ==> "(?:\s|(?:\-+|=+)$)" - * ["-", "=", "--=="] ==> "(?:\s|(?:\-+|=+|(?:\-\-==)+)$)" ==> https://jex.im/regulex/#!embed=false&flags=&re=(%3F%3A%5Cs%7C(%3F%3A%5C-%2B%7C%3D%2B%7C(%3F%3A%5C-%5C-%3D%3D)%2B)%24) - */ - if (exceptions.length === 0) { - - // a space. - pattern += "\\s"; - } else { - - // a space or... - pattern += "(?:\\s|"; - - if (exceptions.length === 1) { - - // a sequence of the exception pattern. - pattern += escapeAndRepeat(exceptions[0]); - } else { - - // a sequence of one of the exception patterns. - pattern += "(?:"; - pattern += exceptions.map(escapeAndRepeat).join("|"); - pattern += ")"; - } - pattern += `(?:$|[${Array.from(astUtils.LINEBREAKS).join("")}]))`; - } - - return pattern; -} - -/** - * Creates RegExp object for `always` mode. - * Generated pattern for beginning of comment: - * - * 1. First, a marker or nothing. - * 2. Next, a space or an exception pattern sequence. - * @param {string[]} markers A marker list. - * @param {string[]} exceptions An exception pattern list. - * @returns {RegExp} A RegExp object for the beginning of a comment in `always` mode. - */ -function createAlwaysStylePattern(markers, exceptions) { - let pattern = "^"; - - /* - * A marker or nothing. - * ["*"] ==> "\*?" - * ["*", "!"] ==> "(?:\*|!)?" - * ["*", "/", "!<"] ==> "(?:\*|\/|(?:!<))?" ==> https://jex.im/regulex/#!embed=false&flags=&re=(%3F%3A%5C*%7C%5C%2F%7C(%3F%3A!%3C))%3F - */ - if (markers.length === 1) { - - // the marker. - pattern += escape(markers[0]); - } else { - - // one of markers. - pattern += "(?:"; - pattern += markers.map(escape).join("|"); - pattern += ")"; - } - - pattern += "?"; // or nothing. - pattern += createExceptionsPattern(exceptions); - - return new RegExp(pattern, "u"); -} - -/** - * Creates RegExp object for `never` mode. - * Generated pattern for beginning of comment: - * - * 1. First, a marker or nothing (captured). - * 2. Next, a space or a tab. - * @param {string[]} markers A marker list. - * @returns {RegExp} A RegExp object for `never` mode. - */ -function createNeverStylePattern(markers) { - const pattern = `^(${markers.map(escape).join("|")})?[ \t]+`; - - return new RegExp(pattern, "u"); -} - -//------------------------------------------------------------------------------ -// Rule Definition -//------------------------------------------------------------------------------ - -/** @type {import('../shared/types').Rule} */ -module.exports = { - meta: { - deprecated: true, - replacedBy: [], - type: "suggestion", - - docs: { - description: "Enforce consistent spacing after the `//` or `/*` in a comment", - recommended: false, - url: "https://eslint.org/docs/latest/rules/spaced-comment" - }, - - fixable: "whitespace", - - schema: [ - { - enum: ["always", "never"] - }, - { - type: "object", - properties: { - exceptions: { - type: "array", - items: { - type: "string" - } - }, - markers: { - type: "array", - items: { - type: "string" - } - }, - line: { - type: "object", - properties: { - exceptions: { - type: "array", - items: { - type: "string" - } - }, - markers: { - type: "array", - items: { - type: "string" - } - } - }, - additionalProperties: false - }, - block: { - type: "object", - properties: { - exceptions: { - type: "array", - items: { - type: "string" - } - }, - markers: { - type: "array", - items: { - type: "string" - } - }, - balanced: { - type: "boolean", - default: false - } - }, - additionalProperties: false - } - }, - additionalProperties: false - } - ], - - messages: { - unexpectedSpaceAfterMarker: "Unexpected space or tab after marker ({{refChar}}) in comment.", - expectedExceptionAfter: "Expected exception block, space or tab after '{{refChar}}' in comment.", - unexpectedSpaceBefore: "Unexpected space or tab before '*/' in comment.", - unexpectedSpaceAfter: "Unexpected space or tab after '{{refChar}}' in comment.", - expectedSpaceBefore: "Expected space or tab before '*/' in comment.", - expectedSpaceAfter: "Expected space or tab after '{{refChar}}' in comment." - } - }, - - create(context) { - - const sourceCode = context.sourceCode; - - // Unless the first option is never, require a space - const requireSpace = context.options[0] !== "never"; - - /* - * Parse the second options. - * If markers don't include `"*"`, it's added automatically for JSDoc - * comments. - */ - const config = context.options[1] || {}; - const balanced = config.block && config.block.balanced; - - const styleRules = ["block", "line"].reduce((rule, type) => { - const markers = parseMarkersOption(config[type] && config[type].markers || config.markers || []); - const exceptions = config[type] && config[type].exceptions || config.exceptions || []; - const endNeverPattern = "[ \t]+$"; - - // Create RegExp object for valid patterns. - rule[type] = { - beginRegex: requireSpace ? createAlwaysStylePattern(markers, exceptions) : createNeverStylePattern(markers), - endRegex: balanced && requireSpace ? new RegExp(`${createExceptionsPattern(exceptions)}$`, "u") : new RegExp(endNeverPattern, "u"), - hasExceptions: exceptions.length > 0, - captureMarker: new RegExp(`^(${markers.map(escape).join("|")})`, "u"), - markers: new Set(markers) - }; - - return rule; - }, {}); - - /** - * Reports a beginning spacing error with an appropriate message. - * @param {ASTNode} node A comment node to check. - * @param {string} messageId An error message to report. - * @param {Array} match An array of match results for markers. - * @param {string} refChar Character used for reference in the error message. - * @returns {void} - */ - function reportBegin(node, messageId, match, refChar) { - const type = node.type.toLowerCase(), - commentIdentifier = type === "block" ? "/*" : "//"; - - context.report({ - node, - fix(fixer) { - const start = node.range[0]; - let end = start + 2; - - if (requireSpace) { - if (match) { - end += match[0].length; - } - return fixer.insertTextAfterRange([start, end], " "); - } - end += match[0].length; - return fixer.replaceTextRange([start, end], commentIdentifier + (match[1] ? match[1] : "")); - - }, - messageId, - data: { refChar } - }); - } - - /** - * Reports an ending spacing error with an appropriate message. - * @param {ASTNode} node A comment node to check. - * @param {string} messageId An error message to report. - * @param {string} match An array of the matched whitespace characters. - * @returns {void} - */ - function reportEnd(node, messageId, match) { - context.report({ - node, - fix(fixer) { - if (requireSpace) { - return fixer.insertTextAfterRange([node.range[0], node.range[1] - 2], " "); - } - const end = node.range[1] - 2, - start = end - match[0].length; - - return fixer.replaceTextRange([start, end], ""); - - }, - messageId - }); - } - - /** - * Reports a given comment if it's invalid. - * @param {ASTNode} node a comment node to check. - * @returns {void} - */ - function checkCommentForSpace(node) { - const type = node.type.toLowerCase(), - rule = styleRules[type], - commentIdentifier = type === "block" ? "/*" : "//"; - - // Ignores empty comments and comments that consist only of a marker. - if (node.value.length === 0 || rule.markers.has(node.value)) { - return; - } - - const beginMatch = rule.beginRegex.exec(node.value); - const endMatch = rule.endRegex.exec(node.value); - - // Checks. - if (requireSpace) { - if (!beginMatch) { - const hasMarker = rule.captureMarker.exec(node.value); - const marker = hasMarker ? commentIdentifier + hasMarker[0] : commentIdentifier; - - if (rule.hasExceptions) { - reportBegin(node, "expectedExceptionAfter", hasMarker, marker); - } else { - reportBegin(node, "expectedSpaceAfter", hasMarker, marker); - } - } - - if (balanced && type === "block" && !endMatch) { - reportEnd(node, "expectedSpaceBefore"); - } - } else { - if (beginMatch) { - if (!beginMatch[1]) { - reportBegin(node, "unexpectedSpaceAfter", beginMatch, commentIdentifier); - } else { - reportBegin(node, "unexpectedSpaceAfterMarker", beginMatch, beginMatch[1]); - } - } - - if (balanced && type === "block" && endMatch) { - reportEnd(node, "unexpectedSpaceBefore", endMatch); - } - } - } - - return { - Program() { - const comments = sourceCode.getAllComments(); - - comments.filter(token => token.type !== "Shebang").forEach(checkCommentForSpace); - } - }; - } -}; diff --git a/tools/eslint/node_modules/eslint/lib/rules/strict.js b/tools/eslint/node_modules/eslint/lib/rules/strict.js deleted file mode 100644 index fd970f279e18ca..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/rules/strict.js +++ /dev/null @@ -1,277 +0,0 @@ -/** - * @fileoverview Rule to control usage of strict mode directives. - * @author Brandon Mills - */ - -"use strict"; - -//------------------------------------------------------------------------------ -// Requirements -//------------------------------------------------------------------------------ - -const astUtils = require("./utils/ast-utils"); - -//------------------------------------------------------------------------------ -// Helpers -//------------------------------------------------------------------------------ - -/** - * Gets all of the Use Strict Directives in the Directive Prologue of a group of - * statements. - * @param {ASTNode[]} statements Statements in the program or function body. - * @returns {ASTNode[]} All of the Use Strict Directives. - */ -function getUseStrictDirectives(statements) { - const directives = []; - - for (let i = 0; i < statements.length; i++) { - const statement = statements[i]; - - if ( - statement.type === "ExpressionStatement" && - statement.expression.type === "Literal" && - statement.expression.value === "use strict" - ) { - directives[i] = statement; - } else { - break; - } - } - - return directives; -} - -/** - * Checks whether a given parameter is a simple parameter. - * @param {ASTNode} node A pattern node to check. - * @returns {boolean} `true` if the node is an Identifier node. - */ -function isSimpleParameter(node) { - return node.type === "Identifier"; -} - -/** - * Checks whether a given parameter list is a simple parameter list. - * @param {ASTNode[]} params A parameter list to check. - * @returns {boolean} `true` if the every parameter is an Identifier node. - */ -function isSimpleParameterList(params) { - return params.every(isSimpleParameter); -} - -//------------------------------------------------------------------------------ -// Rule Definition -//------------------------------------------------------------------------------ - -/** @type {import('../shared/types').Rule} */ -module.exports = { - meta: { - type: "suggestion", - - docs: { - description: "Require or disallow strict mode directives", - recommended: false, - url: "https://eslint.org/docs/latest/rules/strict" - }, - - schema: [ - { - enum: ["never", "global", "function", "safe"] - } - ], - - fixable: "code", - messages: { - function: "Use the function form of 'use strict'.", - global: "Use the global form of 'use strict'.", - multiple: "Multiple 'use strict' directives.", - never: "Strict mode is not permitted.", - unnecessary: "Unnecessary 'use strict' directive.", - module: "'use strict' is unnecessary inside of modules.", - implied: "'use strict' is unnecessary when implied strict mode is enabled.", - unnecessaryInClasses: "'use strict' is unnecessary inside of classes.", - nonSimpleParameterList: "'use strict' directive inside a function with non-simple parameter list throws a syntax error since ES2016.", - wrap: "Wrap {{name}} in a function with 'use strict' directive." - } - }, - - create(context) { - - const ecmaFeatures = context.parserOptions.ecmaFeatures || {}, - scopes = [], - classScopes = []; - let mode = context.options[0] || "safe"; - - if (ecmaFeatures.impliedStrict) { - mode = "implied"; - } else if (mode === "safe") { - mode = ecmaFeatures.globalReturn || context.languageOptions.sourceType === "commonjs" ? "global" : "function"; - } - - /** - * Determines whether a reported error should be fixed, depending on the error type. - * @param {string} errorType The type of error - * @returns {boolean} `true` if the reported error should be fixed - */ - function shouldFix(errorType) { - return errorType === "multiple" || errorType === "unnecessary" || errorType === "module" || errorType === "implied" || errorType === "unnecessaryInClasses"; - } - - /** - * Gets a fixer function to remove a given 'use strict' directive. - * @param {ASTNode} node The directive that should be removed - * @returns {Function} A fixer function - */ - function getFixFunction(node) { - return fixer => fixer.remove(node); - } - - /** - * Report a slice of an array of nodes with a given message. - * @param {ASTNode[]} nodes Nodes. - * @param {string} start Index to start from. - * @param {string} end Index to end before. - * @param {string} messageId Message to display. - * @param {boolean} fix `true` if the directive should be fixed (i.e. removed) - * @returns {void} - */ - function reportSlice(nodes, start, end, messageId, fix) { - nodes.slice(start, end).forEach(node => { - context.report({ node, messageId, fix: fix ? getFixFunction(node) : null }); - }); - } - - /** - * Report all nodes in an array with a given message. - * @param {ASTNode[]} nodes Nodes. - * @param {string} messageId Message id to display. - * @param {boolean} fix `true` if the directive should be fixed (i.e. removed) - * @returns {void} - */ - function reportAll(nodes, messageId, fix) { - reportSlice(nodes, 0, nodes.length, messageId, fix); - } - - /** - * Report all nodes in an array, except the first, with a given message. - * @param {ASTNode[]} nodes Nodes. - * @param {string} messageId Message id to display. - * @param {boolean} fix `true` if the directive should be fixed (i.e. removed) - * @returns {void} - */ - function reportAllExceptFirst(nodes, messageId, fix) { - reportSlice(nodes, 1, nodes.length, messageId, fix); - } - - /** - * Entering a function in 'function' mode pushes a new nested scope onto the - * stack. The new scope is true if the nested function is strict mode code. - * @param {ASTNode} node The function declaration or expression. - * @param {ASTNode[]} useStrictDirectives The Use Strict Directives of the node. - * @returns {void} - */ - function enterFunctionInFunctionMode(node, useStrictDirectives) { - const isInClass = classScopes.length > 0, - isParentGlobal = scopes.length === 0 && classScopes.length === 0, - isParentStrict = scopes.length > 0 && scopes.at(-1), - isStrict = useStrictDirectives.length > 0; - - if (isStrict) { - if (!isSimpleParameterList(node.params)) { - context.report({ node: useStrictDirectives[0], messageId: "nonSimpleParameterList" }); - } else if (isParentStrict) { - context.report({ node: useStrictDirectives[0], messageId: "unnecessary", fix: getFixFunction(useStrictDirectives[0]) }); - } else if (isInClass) { - context.report({ node: useStrictDirectives[0], messageId: "unnecessaryInClasses", fix: getFixFunction(useStrictDirectives[0]) }); - } - - reportAllExceptFirst(useStrictDirectives, "multiple", true); - } else if (isParentGlobal) { - if (isSimpleParameterList(node.params)) { - context.report({ node, messageId: "function" }); - } else { - context.report({ - node, - messageId: "wrap", - data: { name: astUtils.getFunctionNameWithKind(node) } - }); - } - } - - scopes.push(isParentStrict || isStrict); - } - - /** - * Exiting a function in 'function' mode pops its scope off the stack. - * @returns {void} - */ - function exitFunctionInFunctionMode() { - scopes.pop(); - } - - /** - * Enter a function and either: - * - Push a new nested scope onto the stack (in 'function' mode). - * - Report all the Use Strict Directives (in the other modes). - * @param {ASTNode} node The function declaration or expression. - * @returns {void} - */ - function enterFunction(node) { - const isBlock = node.body.type === "BlockStatement", - useStrictDirectives = isBlock - ? getUseStrictDirectives(node.body.body) : []; - - if (mode === "function") { - enterFunctionInFunctionMode(node, useStrictDirectives); - } else if (useStrictDirectives.length > 0) { - if (isSimpleParameterList(node.params)) { - reportAll(useStrictDirectives, mode, shouldFix(mode)); - } else { - context.report({ node: useStrictDirectives[0], messageId: "nonSimpleParameterList" }); - reportAllExceptFirst(useStrictDirectives, "multiple", true); - } - } - } - - const rule = { - Program(node) { - const useStrictDirectives = getUseStrictDirectives(node.body); - - if (node.sourceType === "module") { - mode = "module"; - } - - if (mode === "global") { - if (node.body.length > 0 && useStrictDirectives.length === 0) { - context.report({ node, messageId: "global" }); - } - reportAllExceptFirst(useStrictDirectives, "multiple", true); - } else { - reportAll(useStrictDirectives, mode, shouldFix(mode)); - } - }, - FunctionDeclaration: enterFunction, - FunctionExpression: enterFunction, - ArrowFunctionExpression: enterFunction - }; - - if (mode === "function") { - Object.assign(rule, { - - // Inside of class bodies are always strict mode. - ClassBody() { - classScopes.push(true); - }, - "ClassBody:exit"() { - classScopes.pop(); - }, - - "FunctionDeclaration:exit": exitFunctionInFunctionMode, - "FunctionExpression:exit": exitFunctionInFunctionMode, - "ArrowFunctionExpression:exit": exitFunctionInFunctionMode - }); - } - - return rule; - } -}; diff --git a/tools/eslint/node_modules/eslint/lib/rules/switch-colon-spacing.js b/tools/eslint/node_modules/eslint/lib/rules/switch-colon-spacing.js deleted file mode 100644 index 3ea63ca0eed4fa..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/rules/switch-colon-spacing.js +++ /dev/null @@ -1,132 +0,0 @@ -/** - * @fileoverview Rule to enforce spacing around colons of switch statements. - * @author Toru Nagashima - * @deprecated in ESLint v8.53.0 - */ - -"use strict"; - -//------------------------------------------------------------------------------ -// Requirements -//------------------------------------------------------------------------------ - -const astUtils = require("./utils/ast-utils"); - -//------------------------------------------------------------------------------ -// Rule Definition -//------------------------------------------------------------------------------ - -/** @type {import('../shared/types').Rule} */ -module.exports = { - meta: { - deprecated: true, - replacedBy: [], - type: "layout", - - docs: { - description: "Enforce spacing around colons of switch statements", - recommended: false, - url: "https://eslint.org/docs/latest/rules/switch-colon-spacing" - }, - - schema: [ - { - type: "object", - properties: { - before: { type: "boolean", default: false }, - after: { type: "boolean", default: true } - }, - additionalProperties: false - } - ], - fixable: "whitespace", - messages: { - expectedBefore: "Expected space(s) before this colon.", - expectedAfter: "Expected space(s) after this colon.", - unexpectedBefore: "Unexpected space(s) before this colon.", - unexpectedAfter: "Unexpected space(s) after this colon." - } - }, - - create(context) { - const sourceCode = context.sourceCode; - const options = context.options[0] || {}; - const beforeSpacing = options.before === true; // false by default - const afterSpacing = options.after !== false; // true by default - - /** - * Check whether the spacing between the given 2 tokens is valid or not. - * @param {Token} left The left token to check. - * @param {Token} right The right token to check. - * @param {boolean} expected The expected spacing to check. `true` if there should be a space. - * @returns {boolean} `true` if the spacing between the tokens is valid. - */ - function isValidSpacing(left, right, expected) { - return ( - astUtils.isClosingBraceToken(right) || - !astUtils.isTokenOnSameLine(left, right) || - sourceCode.isSpaceBetweenTokens(left, right) === expected - ); - } - - /** - * Check whether comments exist between the given 2 tokens. - * @param {Token} left The left token to check. - * @param {Token} right The right token to check. - * @returns {boolean} `true` if comments exist between the given 2 tokens. - */ - function commentsExistBetween(left, right) { - return sourceCode.getFirstTokenBetween( - left, - right, - { - includeComments: true, - filter: astUtils.isCommentToken - } - ) !== null; - } - - /** - * Fix the spacing between the given 2 tokens. - * @param {RuleFixer} fixer The fixer to fix. - * @param {Token} left The left token of fix range. - * @param {Token} right The right token of fix range. - * @param {boolean} spacing The spacing style. `true` if there should be a space. - * @returns {Fix|null} The fix object. - */ - function fix(fixer, left, right, spacing) { - if (commentsExistBetween(left, right)) { - return null; - } - if (spacing) { - return fixer.insertTextAfter(left, " "); - } - return fixer.removeRange([left.range[1], right.range[0]]); - } - - return { - SwitchCase(node) { - const colonToken = astUtils.getSwitchCaseColonToken(node, sourceCode); - const beforeToken = sourceCode.getTokenBefore(colonToken); - const afterToken = sourceCode.getTokenAfter(colonToken); - - if (!isValidSpacing(beforeToken, colonToken, beforeSpacing)) { - context.report({ - node, - loc: colonToken.loc, - messageId: beforeSpacing ? "expectedBefore" : "unexpectedBefore", - fix: fixer => fix(fixer, beforeToken, colonToken, beforeSpacing) - }); - } - if (!isValidSpacing(colonToken, afterToken, afterSpacing)) { - context.report({ - node, - loc: colonToken.loc, - messageId: afterSpacing ? "expectedAfter" : "unexpectedAfter", - fix: fixer => fix(fixer, colonToken, afterToken, afterSpacing) - }); - } - } - }; - } -}; diff --git a/tools/eslint/node_modules/eslint/lib/rules/symbol-description.js b/tools/eslint/node_modules/eslint/lib/rules/symbol-description.js deleted file mode 100644 index 4528f09cf6c60a..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/rules/symbol-description.js +++ /dev/null @@ -1,73 +0,0 @@ -/** - * @fileoverview Rule to enforce description with the `Symbol` object - * @author Jarek Rencz - */ - -"use strict"; - -//------------------------------------------------------------------------------ -// Requirements -//------------------------------------------------------------------------------ - -const astUtils = require("./utils/ast-utils"); - -//------------------------------------------------------------------------------ -// Rule Definition -//------------------------------------------------------------------------------ - - -/** @type {import('../shared/types').Rule} */ -module.exports = { - meta: { - type: "suggestion", - - docs: { - description: "Require symbol descriptions", - recommended: false, - url: "https://eslint.org/docs/latest/rules/symbol-description" - }, - fixable: null, - schema: [], - messages: { - expected: "Expected Symbol to have a description." - } - }, - - create(context) { - - const sourceCode = context.sourceCode; - - /** - * Reports if node does not conform the rule in case rule is set to - * report missing description - * @param {ASTNode} node A CallExpression node to check. - * @returns {void} - */ - function checkArgument(node) { - if (node.arguments.length === 0) { - context.report({ - node, - messageId: "expected" - }); - } - } - - return { - "Program:exit"(node) { - const scope = sourceCode.getScope(node); - const variable = astUtils.getVariableByName(scope, "Symbol"); - - if (variable && variable.defs.length === 0) { - variable.references.forEach(reference => { - const idNode = reference.identifier; - - if (astUtils.isCallee(idNode)) { - checkArgument(idNode.parent); - } - }); - } - } - }; - - } -}; diff --git a/tools/eslint/node_modules/eslint/lib/rules/template-curly-spacing.js b/tools/eslint/node_modules/eslint/lib/rules/template-curly-spacing.js deleted file mode 100644 index 1f8cc34c1d7c30..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/rules/template-curly-spacing.js +++ /dev/null @@ -1,144 +0,0 @@ -/** - * @fileoverview Rule to enforce spacing around embedded expressions of template strings - * @author Toru Nagashima - * @deprecated in ESLint v8.53.0 - */ - -"use strict"; - -//------------------------------------------------------------------------------ -// Requirements -//------------------------------------------------------------------------------ - -const astUtils = require("./utils/ast-utils"); - -//------------------------------------------------------------------------------ -// Rule Definition -//------------------------------------------------------------------------------ - -/** @type {import('../shared/types').Rule} */ -module.exports = { - meta: { - deprecated: true, - replacedBy: [], - type: "layout", - - docs: { - description: "Require or disallow spacing around embedded expressions of template strings", - recommended: false, - url: "https://eslint.org/docs/latest/rules/template-curly-spacing" - }, - - fixable: "whitespace", - - schema: [ - { enum: ["always", "never"] } - ], - messages: { - expectedBefore: "Expected space(s) before '}'.", - expectedAfter: "Expected space(s) after '${'.", - unexpectedBefore: "Unexpected space(s) before '}'.", - unexpectedAfter: "Unexpected space(s) after '${'." - } - }, - - create(context) { - const sourceCode = context.sourceCode; - const always = context.options[0] === "always"; - - /** - * Checks spacing before `}` of a given token. - * @param {Token} token A token to check. This is a Template token. - * @returns {void} - */ - function checkSpacingBefore(token) { - if (!token.value.startsWith("}")) { - return; // starts with a backtick, this is the first template element in the template literal - } - - const prevToken = sourceCode.getTokenBefore(token, { includeComments: true }), - hasSpace = sourceCode.isSpaceBetween(prevToken, token); - - if (!astUtils.isTokenOnSameLine(prevToken, token)) { - return; - } - - if (always && !hasSpace) { - context.report({ - loc: { - start: token.loc.start, - end: { - line: token.loc.start.line, - column: token.loc.start.column + 1 - } - }, - messageId: "expectedBefore", - fix: fixer => fixer.insertTextBefore(token, " ") - }); - } - - if (!always && hasSpace) { - context.report({ - loc: { - start: prevToken.loc.end, - end: token.loc.start - }, - messageId: "unexpectedBefore", - fix: fixer => fixer.removeRange([prevToken.range[1], token.range[0]]) - }); - } - } - - /** - * Checks spacing after `${` of a given token. - * @param {Token} token A token to check. This is a Template token. - * @returns {void} - */ - function checkSpacingAfter(token) { - if (!token.value.endsWith("${")) { - return; // ends with a backtick, this is the last template element in the template literal - } - - const nextToken = sourceCode.getTokenAfter(token, { includeComments: true }), - hasSpace = sourceCode.isSpaceBetween(token, nextToken); - - if (!astUtils.isTokenOnSameLine(token, nextToken)) { - return; - } - - if (always && !hasSpace) { - context.report({ - loc: { - start: { - line: token.loc.end.line, - column: token.loc.end.column - 2 - }, - end: token.loc.end - }, - messageId: "expectedAfter", - fix: fixer => fixer.insertTextAfter(token, " ") - }); - } - - if (!always && hasSpace) { - context.report({ - loc: { - start: token.loc.end, - end: nextToken.loc.start - }, - messageId: "unexpectedAfter", - fix: fixer => fixer.removeRange([token.range[1], nextToken.range[0]]) - }); - } - } - - return { - TemplateElement(node) { - const token = sourceCode.getFirstToken(node); - - checkSpacingBefore(token); - checkSpacingAfter(token); - } - }; - } -}; diff --git a/tools/eslint/node_modules/eslint/lib/rules/template-tag-spacing.js b/tools/eslint/node_modules/eslint/lib/rules/template-tag-spacing.js deleted file mode 100644 index 52e0bcf2073000..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/rules/template-tag-spacing.js +++ /dev/null @@ -1,93 +0,0 @@ -/** - * @fileoverview Rule to check spacing between template tags and their literals - * @author Jonathan Wilsson - * @deprecated in ESLint v8.53.0 - */ - -"use strict"; - -//------------------------------------------------------------------------------ -// Rule Definition -//------------------------------------------------------------------------------ - -/** @type {import('../shared/types').Rule} */ -module.exports = { - meta: { - deprecated: true, - replacedBy: [], - type: "layout", - - docs: { - description: "Require or disallow spacing between template tags and their literals", - recommended: false, - url: "https://eslint.org/docs/latest/rules/template-tag-spacing" - }, - - fixable: "whitespace", - - schema: [ - { enum: ["always", "never"] } - ], - messages: { - unexpected: "Unexpected space between template tag and template literal.", - missing: "Missing space between template tag and template literal." - } - }, - - create(context) { - const never = context.options[0] !== "always"; - const sourceCode = context.sourceCode; - - /** - * Check if a space is present between a template tag and its literal - * @param {ASTNode} node node to evaluate - * @returns {void} - * @private - */ - function checkSpacing(node) { - const tagToken = sourceCode.getTokenBefore(node.quasi); - const literalToken = sourceCode.getFirstToken(node.quasi); - const hasWhitespace = sourceCode.isSpaceBetweenTokens(tagToken, literalToken); - - if (never && hasWhitespace) { - context.report({ - node, - loc: { - start: tagToken.loc.end, - end: literalToken.loc.start - }, - messageId: "unexpected", - fix(fixer) { - const comments = sourceCode.getCommentsBefore(node.quasi); - - // Don't fix anything if there's a single line comment after the template tag - if (comments.some(comment => comment.type === "Line")) { - return null; - } - - return fixer.replaceTextRange( - [tagToken.range[1], literalToken.range[0]], - comments.reduce((text, comment) => text + sourceCode.getText(comment), "") - ); - } - }); - } else if (!never && !hasWhitespace) { - context.report({ - node, - loc: { - start: node.loc.start, - end: literalToken.loc.start - }, - messageId: "missing", - fix(fixer) { - return fixer.insertTextAfter(tagToken, " "); - } - }); - } - } - - return { - TaggedTemplateExpression: checkSpacing - }; - } -}; diff --git a/tools/eslint/node_modules/eslint/lib/rules/unicode-bom.js b/tools/eslint/node_modules/eslint/lib/rules/unicode-bom.js deleted file mode 100644 index 09971d26e30581..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/rules/unicode-bom.js +++ /dev/null @@ -1,73 +0,0 @@ -/** - * @fileoverview Require or disallow Unicode BOM - * @author Andrew Johnston - */ -"use strict"; - -//------------------------------------------------------------------------------ -// Rule Definition -//------------------------------------------------------------------------------ - -/** @type {import('../shared/types').Rule} */ -module.exports = { - meta: { - type: "layout", - - docs: { - description: "Require or disallow Unicode byte order mark (BOM)", - recommended: false, - url: "https://eslint.org/docs/latest/rules/unicode-bom" - }, - - fixable: "whitespace", - - schema: [ - { - enum: ["always", "never"] - } - ], - messages: { - expected: "Expected Unicode BOM (Byte Order Mark).", - unexpected: "Unexpected Unicode BOM (Byte Order Mark)." - } - }, - - create(context) { - - //-------------------------------------------------------------------------- - // Public - //-------------------------------------------------------------------------- - - return { - - Program: function checkUnicodeBOM(node) { - - const sourceCode = context.sourceCode, - location = { column: 0, line: 1 }, - requireBOM = context.options[0] || "never"; - - if (!sourceCode.hasBOM && (requireBOM === "always")) { - context.report({ - node, - loc: location, - messageId: "expected", - fix(fixer) { - return fixer.insertTextBeforeRange([0, 1], "\uFEFF"); - } - }); - } else if (sourceCode.hasBOM && (requireBOM === "never")) { - context.report({ - node, - loc: location, - messageId: "unexpected", - fix(fixer) { - return fixer.removeRange([-1, 0]); - } - }); - } - } - - }; - - } -}; diff --git a/tools/eslint/node_modules/eslint/lib/rules/use-isnan.js b/tools/eslint/node_modules/eslint/lib/rules/use-isnan.js deleted file mode 100644 index 5c0b65feefbad8..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/rules/use-isnan.js +++ /dev/null @@ -1,235 +0,0 @@ -/** - * @fileoverview Rule to flag comparisons to the value NaN - * @author James Allardice - */ - -"use strict"; - -//------------------------------------------------------------------------------ -// Requirements -//------------------------------------------------------------------------------ - -const astUtils = require("./utils/ast-utils"); - -//------------------------------------------------------------------------------ -// Helpers -//------------------------------------------------------------------------------ - -/** - * Determines if the given node is a NaN `Identifier` node. - * @param {ASTNode|null} node The node to check. - * @returns {boolean} `true` if the node is 'NaN' identifier. - */ -function isNaNIdentifier(node) { - if (!node) { - return false; - } - - const nodeToCheck = node.type === "SequenceExpression" - ? node.expressions.at(-1) - : node; - - return ( - astUtils.isSpecificId(nodeToCheck, "NaN") || - astUtils.isSpecificMemberAccess(nodeToCheck, "Number", "NaN") - ); -} - -//------------------------------------------------------------------------------ -// Rule Definition -//------------------------------------------------------------------------------ - -/** @type {import('../shared/types').Rule} */ -module.exports = { - meta: { - hasSuggestions: true, - type: "problem", - - docs: { - description: "Require calls to `isNaN()` when checking for `NaN`", - recommended: true, - url: "https://eslint.org/docs/latest/rules/use-isnan" - }, - - schema: [ - { - type: "object", - properties: { - enforceForSwitchCase: { - type: "boolean", - default: true - }, - enforceForIndexOf: { - type: "boolean", - default: false - } - }, - additionalProperties: false - } - ], - - messages: { - comparisonWithNaN: "Use the isNaN function to compare with NaN.", - switchNaN: "'switch(NaN)' can never match a case clause. Use Number.isNaN instead of the switch.", - caseNaN: "'case NaN' can never match. Use Number.isNaN before the switch.", - indexOfNaN: "Array prototype method '{{ methodName }}' cannot find NaN.", - replaceWithIsNaN: "Replace with Number.isNaN.", - replaceWithCastingAndIsNaN: "Replace with Number.isNaN and cast to a Number.", - replaceWithFindIndex: "Replace with Array.prototype.{{ methodName }}." - } - }, - - create(context) { - - const enforceForSwitchCase = !context.options[0] || context.options[0].enforceForSwitchCase; - const enforceForIndexOf = context.options[0] && context.options[0].enforceForIndexOf; - const sourceCode = context.sourceCode; - - const fixableOperators = new Set(["==", "===", "!=", "!=="]); - const castableOperators = new Set(["==", "!="]); - - /** - * Get a fixer for a binary expression that compares to NaN. - * @param {ASTNode} node The node to fix. - * @param {function(string): string} wrapValue A function that wraps the compared value with a fix. - * @returns {function(Fixer): Fix} The fixer function. - */ - function getBinaryExpressionFixer(node, wrapValue) { - return fixer => { - const comparedValue = isNaNIdentifier(node.left) ? node.right : node.left; - const shouldWrap = comparedValue.type === "SequenceExpression"; - const shouldNegate = node.operator[0] === "!"; - - const negation = shouldNegate ? "!" : ""; - let comparedValueText = sourceCode.getText(comparedValue); - - if (shouldWrap) { - comparedValueText = `(${comparedValueText})`; - } - - const fixedValue = wrapValue(comparedValueText); - - return fixer.replaceText(node, `${negation}${fixedValue}`); - }; - } - - /** - * Checks the given `BinaryExpression` node for `foo === NaN` and other comparisons. - * @param {ASTNode} node The node to check. - * @returns {void} - */ - function checkBinaryExpression(node) { - if ( - /^(?:[<>]|[!=]=)=?$/u.test(node.operator) && - (isNaNIdentifier(node.left) || isNaNIdentifier(node.right)) - ) { - const suggestedFixes = []; - const NaNNode = isNaNIdentifier(node.left) ? node.left : node.right; - - const isSequenceExpression = NaNNode.type === "SequenceExpression"; - const isSuggestable = fixableOperators.has(node.operator) && !isSequenceExpression; - const isCastable = castableOperators.has(node.operator); - - if (isSuggestable) { - suggestedFixes.push({ - messageId: "replaceWithIsNaN", - fix: getBinaryExpressionFixer(node, value => `Number.isNaN(${value})`) - }); - - if (isCastable) { - suggestedFixes.push({ - messageId: "replaceWithCastingAndIsNaN", - fix: getBinaryExpressionFixer(node, value => `Number.isNaN(Number(${value}))`) - }); - } - } - - context.report({ - node, - messageId: "comparisonWithNaN", - suggest: suggestedFixes - }); - } - } - - /** - * Checks the discriminant and all case clauses of the given `SwitchStatement` node for `switch(NaN)` and `case NaN:` - * @param {ASTNode} node The node to check. - * @returns {void} - */ - function checkSwitchStatement(node) { - if (isNaNIdentifier(node.discriminant)) { - context.report({ node, messageId: "switchNaN" }); - } - - for (const switchCase of node.cases) { - if (isNaNIdentifier(switchCase.test)) { - context.report({ node: switchCase, messageId: "caseNaN" }); - } - } - } - - /** - * Checks the given `CallExpression` node for `.indexOf(NaN)` and `.lastIndexOf(NaN)`. - * @param {ASTNode} node The node to check. - * @returns {void} - */ - function checkCallExpression(node) { - const callee = astUtils.skipChainExpression(node.callee); - - if (callee.type === "MemberExpression") { - const methodName = astUtils.getStaticPropertyName(callee); - - if ( - (methodName === "indexOf" || methodName === "lastIndexOf") && - node.arguments.length <= 2 && - isNaNIdentifier(node.arguments[0]) - ) { - - /* - * To retain side effects, it's essential to address `NaN` beforehand, which - * is not possible with fixes like `arr.findIndex(Number.isNaN)`. - */ - const isSuggestable = node.arguments[0].type !== "SequenceExpression" && !node.arguments[1]; - const suggestedFixes = []; - - if (isSuggestable) { - const shouldWrap = callee.computed; - const findIndexMethod = methodName === "indexOf" ? "findIndex" : "findLastIndex"; - const propertyName = shouldWrap ? `"${findIndexMethod}"` : findIndexMethod; - - suggestedFixes.push({ - messageId: "replaceWithFindIndex", - data: { methodName: findIndexMethod }, - fix: fixer => [ - fixer.replaceText(callee.property, propertyName), - fixer.replaceText(node.arguments[0], "Number.isNaN") - ] - }); - } - - context.report({ - node, - messageId: "indexOfNaN", - data: { methodName }, - suggest: suggestedFixes - }); - } - } - } - - const listeners = { - BinaryExpression: checkBinaryExpression - }; - - if (enforceForSwitchCase) { - listeners.SwitchStatement = checkSwitchStatement; - } - - if (enforceForIndexOf) { - listeners.CallExpression = checkCallExpression; - } - - return listeners; - } -}; diff --git a/tools/eslint/node_modules/eslint/lib/rules/utils/ast-utils.js b/tools/eslint/node_modules/eslint/lib/rules/utils/ast-utils.js deleted file mode 100644 index ed9a31af34cfe8..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/rules/utils/ast-utils.js +++ /dev/null @@ -1,2291 +0,0 @@ -/** - * @fileoverview Common utils for AST. - * @author Gyandeep Singh - */ - -"use strict"; - -//------------------------------------------------------------------------------ -// Requirements -//------------------------------------------------------------------------------ - -const { KEYS: eslintVisitorKeys } = require("eslint-visitor-keys"); -const esutils = require("esutils"); -const espree = require("espree"); -const escapeRegExp = require("escape-string-regexp"); -const { - breakableTypePattern, - createGlobalLinebreakMatcher, - lineBreakPattern, - shebangPattern -} = require("../../shared/ast-utils"); -const globals = require("../../../conf/globals"); -const { LATEST_ECMA_VERSION } = require("../../../conf/ecma-version"); - -//------------------------------------------------------------------------------ -// Helpers -//------------------------------------------------------------------------------ - -const anyFunctionPattern = /^(?:Function(?:Declaration|Expression)|ArrowFunctionExpression)$/u; -const anyLoopPattern = /^(?:DoWhile|For|ForIn|ForOf|While)Statement$/u; -const arrayMethodWithThisArgPattern = /^(?:every|filter|find(?:Last)?(?:Index)?|flatMap|forEach|map|some)$/u; -const arrayOrTypedArrayPattern = /Array$/u; -const bindOrCallOrApplyPattern = /^(?:bind|call|apply)$/u; -const thisTagPattern = /^[\s*]*@this/mu; - - -const COMMENTS_IGNORE_PATTERN = /^\s*(?:eslint|jshint\s+|jslint\s+|istanbul\s+|globals?\s+|exported\s+|jscs)/u; -const ESLINT_DIRECTIVE_PATTERN = /^(?:eslint[- ]|(?:globals?|exported) )/u; -const LINEBREAKS = new Set(["\r\n", "\r", "\n", "\u2028", "\u2029"]); - -// A set of node types that can contain a list of statements -const STATEMENT_LIST_PARENTS = new Set(["Program", "BlockStatement", "StaticBlock", "SwitchCase"]); - -const DECIMAL_INTEGER_PATTERN = /^(?:0|0[0-7]*[89]\d*|[1-9](?:_?\d)*)$/u; - -// Tests the presence of at least one LegacyOctalEscapeSequence or NonOctalDecimalEscapeSequence in a raw string -const OCTAL_OR_NON_OCTAL_DECIMAL_ESCAPE_PATTERN = /^(?:[^\\]|\\.)*\\(?:[1-9]|0[0-9])/su; - -const LOGICAL_ASSIGNMENT_OPERATORS = new Set(["&&=", "||=", "??="]); - -/** - * All builtin global variables defined in the latest ECMAScript specification. - * @type {Record} Key is the name of the variable. Value is `true` if the variable is considered writable, `false` otherwise. - */ -const ECMASCRIPT_GLOBALS = globals[`es${LATEST_ECMA_VERSION}`]; - -/** - * Checks reference if is non initializer and writable. - * @param {Reference} reference A reference to check. - * @param {int} index The index of the reference in the references. - * @param {Reference[]} references The array that the reference belongs to. - * @returns {boolean} Success/Failure - * @private - */ -function isModifyingReference(reference, index, references) { - const identifier = reference.identifier; - - /* - * Destructuring assignments can have multiple default value, so - * possibly there are multiple writeable references for the same - * identifier. - */ - const modifyingDifferentIdentifier = index === 0 || - references[index - 1].identifier !== identifier; - - return (identifier && - reference.init === false && - reference.isWrite() && - modifyingDifferentIdentifier - ); -} - -/** - * Checks whether the given string starts with uppercase or not. - * @param {string} s The string to check. - * @returns {boolean} `true` if the string starts with uppercase. - */ -function startsWithUpperCase(s) { - return s[0] !== s[0].toLocaleLowerCase(); -} - -/** - * Checks whether or not a node is a constructor. - * @param {ASTNode} node A function node to check. - * @returns {boolean} Whether or not a node is a constructor. - */ -function isES5Constructor(node) { - return (node.id && startsWithUpperCase(node.id.name)); -} - -/** - * Finds a function node from ancestors of a node. - * @param {ASTNode} node A start node to find. - * @returns {Node|null} A found function node. - */ -function getUpperFunction(node) { - for (let currentNode = node; currentNode; currentNode = currentNode.parent) { - if (anyFunctionPattern.test(currentNode.type)) { - return currentNode; - } - } - return null; -} - -/** - * Checks whether a given node is a function node or not. - * The following types are function nodes: - * - * - ArrowFunctionExpression - * - FunctionDeclaration - * - FunctionExpression - * @param {ASTNode|null} node A node to check. - * @returns {boolean} `true` if the node is a function node. - */ -function isFunction(node) { - return Boolean(node && anyFunctionPattern.test(node.type)); -} - -/** - * Checks whether a given node is a loop node or not. - * The following types are loop nodes: - * - * - DoWhileStatement - * - ForInStatement - * - ForOfStatement - * - ForStatement - * - WhileStatement - * @param {ASTNode|null} node A node to check. - * @returns {boolean} `true` if the node is a loop node. - */ -function isLoop(node) { - return Boolean(node && anyLoopPattern.test(node.type)); -} - -/** - * Checks whether the given node is in a loop or not. - * @param {ASTNode} node The node to check. - * @returns {boolean} `true` if the node is in a loop. - */ -function isInLoop(node) { - for (let currentNode = node; currentNode && !isFunction(currentNode); currentNode = currentNode.parent) { - if (isLoop(currentNode)) { - return true; - } - } - - return false; -} - -/** - * Determines whether the given node is a `null` literal. - * @param {ASTNode} node The node to check - * @returns {boolean} `true` if the node is a `null` literal - */ -function isNullLiteral(node) { - - /* - * Checking `node.value === null` does not guarantee that a literal is a null literal. - * When parsing values that cannot be represented in the current environment (e.g. unicode - * regexes in Node 4), `node.value` is set to `null` because it wouldn't be possible to - * set `node.value` to a unicode regex. To make sure a literal is actually `null`, check - * `node.regex` instead. Also see: https://github.com/eslint/eslint/issues/8020 - */ - return node.type === "Literal" && node.value === null && !node.regex && !node.bigint; -} - -/** - * Checks whether or not a node is `null` or `undefined`. - * @param {ASTNode} node A node to check. - * @returns {boolean} Whether or not the node is a `null` or `undefined`. - * @public - */ -function isNullOrUndefined(node) { - return ( - isNullLiteral(node) || - (node.type === "Identifier" && node.name === "undefined") || - (node.type === "UnaryExpression" && node.operator === "void") - ); -} - -/** - * Checks whether or not a node is callee. - * @param {ASTNode} node A node to check. - * @returns {boolean} Whether or not the node is callee. - */ -function isCallee(node) { - return node.parent.type === "CallExpression" && node.parent.callee === node; -} - -/** - * Returns the result of the string conversion applied to the evaluated value of the given expression node, - * if it can be determined statically. - * - * This function returns a `string` value for all `Literal` nodes and simple `TemplateLiteral` nodes only. - * In all other cases, this function returns `null`. - * @param {ASTNode} node Expression node. - * @returns {string|null} String value if it can be determined. Otherwise, `null`. - */ -function getStaticStringValue(node) { - switch (node.type) { - case "Literal": - if (node.value === null) { - if (isNullLiteral(node)) { - return String(node.value); // "null" - } - if (node.regex) { - return `/${node.regex.pattern}/${node.regex.flags}`; - } - if (node.bigint) { - return node.bigint; - } - - // Otherwise, this is an unknown literal. The function will return null. - - } else { - return String(node.value); - } - break; - case "TemplateLiteral": - if (node.expressions.length === 0 && node.quasis.length === 1) { - return node.quasis[0].value.cooked; - } - break; - - // no default - } - - return null; -} - -/** - * Gets the property name of a given node. - * The node can be a MemberExpression, a Property, or a MethodDefinition. - * - * If the name is dynamic, this returns `null`. - * - * For examples: - * - * a.b // => "b" - * a["b"] // => "b" - * a['b'] // => "b" - * a[`b`] // => "b" - * a[100] // => "100" - * a[b] // => null - * a["a" + "b"] // => null - * a[tag`b`] // => null - * a[`${b}`] // => null - * - * let a = {b: 1} // => "b" - * let a = {["b"]: 1} // => "b" - * let a = {['b']: 1} // => "b" - * let a = {[`b`]: 1} // => "b" - * let a = {[100]: 1} // => "100" - * let a = {[b]: 1} // => null - * let a = {["a" + "b"]: 1} // => null - * let a = {[tag`b`]: 1} // => null - * let a = {[`${b}`]: 1} // => null - * @param {ASTNode} node The node to get. - * @returns {string|null} The property name if static. Otherwise, null. - */ -function getStaticPropertyName(node) { - let prop; - - switch (node && node.type) { - case "ChainExpression": - return getStaticPropertyName(node.expression); - - case "Property": - case "PropertyDefinition": - case "MethodDefinition": - prop = node.key; - break; - - case "MemberExpression": - prop = node.property; - break; - - // no default - } - - if (prop) { - if (prop.type === "Identifier" && !node.computed) { - return prop.name; - } - - return getStaticStringValue(prop); - } - - return null; -} - -/** - * Retrieve `ChainExpression#expression` value if the given node a `ChainExpression` node. Otherwise, pass through it. - * @param {ASTNode} node The node to address. - * @returns {ASTNode} The `ChainExpression#expression` value if the node is a `ChainExpression` node. Otherwise, the node. - */ -function skipChainExpression(node) { - return node && node.type === "ChainExpression" ? node.expression : node; -} - -/** - * Check if the `actual` is an expected value. - * @param {string} actual The string value to check. - * @param {string | RegExp} expected The expected string value or pattern. - * @returns {boolean} `true` if the `actual` is an expected value. - */ -function checkText(actual, expected) { - return typeof expected === "string" - ? actual === expected - : expected.test(actual); -} - -/** - * Check if a given node is an Identifier node with a given name. - * @param {ASTNode} node The node to check. - * @param {string | RegExp} name The expected name or the expected pattern of the object name. - * @returns {boolean} `true` if the node is an Identifier node with the name. - */ -function isSpecificId(node, name) { - return node.type === "Identifier" && checkText(node.name, name); -} - -/** - * Check if a given node is member access with a given object name and property name pair. - * This is regardless of optional or not. - * @param {ASTNode} node The node to check. - * @param {string | RegExp | null} objectName The expected name or the expected pattern of the object name. If this is nullish, this method doesn't check object. - * @param {string | RegExp | null} propertyName The expected name or the expected pattern of the property name. If this is nullish, this method doesn't check property. - * @returns {boolean} `true` if the node is member access with the object name and property name pair. - * The node is a `MemberExpression` or `ChainExpression`. - */ -function isSpecificMemberAccess(node, objectName, propertyName) { - const checkNode = skipChainExpression(node); - - if (checkNode.type !== "MemberExpression") { - return false; - } - - if (objectName && !isSpecificId(checkNode.object, objectName)) { - return false; - } - - if (propertyName) { - const actualPropertyName = getStaticPropertyName(checkNode); - - if (typeof actualPropertyName !== "string" || !checkText(actualPropertyName, propertyName)) { - return false; - } - } - - return true; -} - -/** - * Check if two literal nodes are the same value. - * @param {ASTNode} left The Literal node to compare. - * @param {ASTNode} right The other Literal node to compare. - * @returns {boolean} `true` if the two literal nodes are the same value. - */ -function equalLiteralValue(left, right) { - - // RegExp literal. - if (left.regex || right.regex) { - return Boolean( - left.regex && - right.regex && - left.regex.pattern === right.regex.pattern && - left.regex.flags === right.regex.flags - ); - } - - // BigInt literal. - if (left.bigint || right.bigint) { - return left.bigint === right.bigint; - } - - return left.value === right.value; -} - -/** - * Check if two expressions reference the same value. For example: - * a = a - * a.b = a.b - * a[0] = a[0] - * a['b'] = a['b'] - * @param {ASTNode} left The left side of the comparison. - * @param {ASTNode} right The right side of the comparison. - * @param {boolean} [disableStaticComputedKey] Don't address `a.b` and `a["b"]` are the same if `true`. For backward compatibility. - * @returns {boolean} `true` if both sides match and reference the same value. - */ -function isSameReference(left, right, disableStaticComputedKey = false) { - if (left.type !== right.type) { - - // Handle `a.b` and `a?.b` are samely. - if (left.type === "ChainExpression") { - return isSameReference(left.expression, right, disableStaticComputedKey); - } - if (right.type === "ChainExpression") { - return isSameReference(left, right.expression, disableStaticComputedKey); - } - - return false; - } - - switch (left.type) { - case "Super": - case "ThisExpression": - return true; - - case "Identifier": - case "PrivateIdentifier": - return left.name === right.name; - case "Literal": - return equalLiteralValue(left, right); - - case "ChainExpression": - return isSameReference(left.expression, right.expression, disableStaticComputedKey); - - case "MemberExpression": { - if (!disableStaticComputedKey) { - const nameA = getStaticPropertyName(left); - - // x.y = x["y"] - if (nameA !== null) { - return ( - isSameReference(left.object, right.object, disableStaticComputedKey) && - nameA === getStaticPropertyName(right) - ); - } - } - - /* - * x[0] = x[0] - * x[y] = x[y] - * x.y = x.y - */ - return ( - left.computed === right.computed && - isSameReference(left.object, right.object, disableStaticComputedKey) && - isSameReference(left.property, right.property, disableStaticComputedKey) - ); - } - - default: - return false; - } -} - -/** - * Checks whether or not a node is `Reflect.apply`. - * @param {ASTNode} node A node to check. - * @returns {boolean} Whether or not the node is a `Reflect.apply`. - */ -function isReflectApply(node) { - return isSpecificMemberAccess(node, "Reflect", "apply"); -} - -/** - * Checks whether or not a node is `Array.from`. - * @param {ASTNode} node A node to check. - * @returns {boolean} Whether or not the node is a `Array.from`. - */ -function isArrayFromMethod(node) { - return isSpecificMemberAccess(node, arrayOrTypedArrayPattern, "from"); -} - -/** - * Checks whether or not a node is a method which expects a function as a first argument, and `thisArg` as a second argument. - * @param {ASTNode} node A node to check. - * @returns {boolean} Whether or not the node is a method which expects a function as a first argument, and `thisArg` as a second argument. - */ -function isMethodWhichHasThisArg(node) { - return isSpecificMemberAccess(node, null, arrayMethodWithThisArgPattern); -} - -/** - * Creates the negate function of the given function. - * @param {Function} f The function to negate. - * @returns {Function} Negated function. - */ -function negate(f) { - return token => !f(token); -} - -/** - * Checks whether or not a node has a `@this` tag in its comments. - * @param {ASTNode} node A node to check. - * @param {SourceCode} sourceCode A SourceCode instance to get comments. - * @returns {boolean} Whether or not the node has a `@this` tag in its comments. - */ -function hasJSDocThisTag(node, sourceCode) { - const jsdocComment = sourceCode.getJSDocComment(node); - - if (jsdocComment && thisTagPattern.test(jsdocComment.value)) { - return true; - } - - // Checks `@this` in its leading comments for callbacks, - // because callbacks don't have its JSDoc comment. - // e.g. - // sinon.test(/* @this sinon.Sandbox */function() { this.spy(); }); - return sourceCode.getCommentsBefore(node).some(comment => thisTagPattern.test(comment.value)); -} - -/** - * Determines if a node is surrounded by parentheses. - * @param {SourceCode} sourceCode The ESLint source code object - * @param {ASTNode} node The node to be checked. - * @returns {boolean} True if the node is parenthesised. - * @private - */ -function isParenthesised(sourceCode, node) { - const previousToken = sourceCode.getTokenBefore(node), - nextToken = sourceCode.getTokenAfter(node); - - return Boolean(previousToken && nextToken) && - previousToken.value === "(" && previousToken.range[1] <= node.range[0] && - nextToken.value === ")" && nextToken.range[0] >= node.range[1]; -} - -/** - * Checks if the given token is a `=` token or not. - * @param {Token} token The token to check. - * @returns {boolean} `true` if the token is a `=` token. - */ -function isEqToken(token) { - return token.value === "=" && token.type === "Punctuator"; -} - -/** - * Checks if the given token is an arrow token or not. - * @param {Token} token The token to check. - * @returns {boolean} `true` if the token is an arrow token. - */ -function isArrowToken(token) { - return token.value === "=>" && token.type === "Punctuator"; -} - -/** - * Checks if the given token is a comma token or not. - * @param {Token} token The token to check. - * @returns {boolean} `true` if the token is a comma token. - */ -function isCommaToken(token) { - return token.value === "," && token.type === "Punctuator"; -} - -/** - * Checks if the given token is a dot token or not. - * @param {Token} token The token to check. - * @returns {boolean} `true` if the token is a dot token. - */ -function isDotToken(token) { - return token.value === "." && token.type === "Punctuator"; -} - -/** - * Checks if the given token is a `?.` token or not. - * @param {Token} token The token to check. - * @returns {boolean} `true` if the token is a `?.` token. - */ -function isQuestionDotToken(token) { - return token.value === "?." && token.type === "Punctuator"; -} - -/** - * Checks if the given token is a semicolon token or not. - * @param {Token} token The token to check. - * @returns {boolean} `true` if the token is a semicolon token. - */ -function isSemicolonToken(token) { - return token.value === ";" && token.type === "Punctuator"; -} - -/** - * Checks if the given token is a colon token or not. - * @param {Token} token The token to check. - * @returns {boolean} `true` if the token is a colon token. - */ -function isColonToken(token) { - return token.value === ":" && token.type === "Punctuator"; -} - -/** - * Checks if the given token is an opening parenthesis token or not. - * @param {Token} token The token to check. - * @returns {boolean} `true` if the token is an opening parenthesis token. - */ -function isOpeningParenToken(token) { - return token.value === "(" && token.type === "Punctuator"; -} - -/** - * Checks if the given token is a closing parenthesis token or not. - * @param {Token} token The token to check. - * @returns {boolean} `true` if the token is a closing parenthesis token. - */ -function isClosingParenToken(token) { - return token.value === ")" && token.type === "Punctuator"; -} - -/** - * Checks if the given token is an opening square bracket token or not. - * @param {Token} token The token to check. - * @returns {boolean} `true` if the token is an opening square bracket token. - */ -function isOpeningBracketToken(token) { - return token.value === "[" && token.type === "Punctuator"; -} - -/** - * Checks if the given token is a closing square bracket token or not. - * @param {Token} token The token to check. - * @returns {boolean} `true` if the token is a closing square bracket token. - */ -function isClosingBracketToken(token) { - return token.value === "]" && token.type === "Punctuator"; -} - -/** - * Checks if the given token is an opening brace token or not. - * @param {Token} token The token to check. - * @returns {boolean} `true` if the token is an opening brace token. - */ -function isOpeningBraceToken(token) { - return token.value === "{" && token.type === "Punctuator"; -} - -/** - * Checks if the given token is a closing brace token or not. - * @param {Token} token The token to check. - * @returns {boolean} `true` if the token is a closing brace token. - */ -function isClosingBraceToken(token) { - return token.value === "}" && token.type === "Punctuator"; -} - -/** - * Checks if the given token is a comment token or not. - * @param {Token} token The token to check. - * @returns {boolean} `true` if the token is a comment token. - */ -function isCommentToken(token) { - return token.type === "Line" || token.type === "Block" || token.type === "Shebang"; -} - -/** - * Checks if the given token is a keyword token or not. - * @param {Token} token The token to check. - * @returns {boolean} `true` if the token is a keyword token. - */ -function isKeywordToken(token) { - return token.type === "Keyword"; -} - -/** - * Gets the `(` token of the given function node. - * @param {ASTNode} node The function node to get. - * @param {SourceCode} sourceCode The source code object to get tokens. - * @returns {Token} `(` token. - */ -function getOpeningParenOfParams(node, sourceCode) { - - // If the node is an arrow function and doesn't have parens, this returns the identifier of the first param. - if (node.type === "ArrowFunctionExpression" && node.params.length === 1) { - const argToken = sourceCode.getFirstToken(node.params[0]); - const maybeParenToken = sourceCode.getTokenBefore(argToken); - - return isOpeningParenToken(maybeParenToken) ? maybeParenToken : argToken; - } - - // Otherwise, returns paren. - return node.id - ? sourceCode.getTokenAfter(node.id, isOpeningParenToken) - : sourceCode.getFirstToken(node, isOpeningParenToken); -} - -/** - * Checks whether or not the tokens of two given nodes are same. - * @param {ASTNode} left A node 1 to compare. - * @param {ASTNode} right A node 2 to compare. - * @param {SourceCode} sourceCode The ESLint source code object. - * @returns {boolean} the source code for the given node. - */ -function equalTokens(left, right, sourceCode) { - const tokensL = sourceCode.getTokens(left); - const tokensR = sourceCode.getTokens(right); - - if (tokensL.length !== tokensR.length) { - return false; - } - for (let i = 0; i < tokensL.length; ++i) { - if (tokensL[i].type !== tokensR[i].type || - tokensL[i].value !== tokensR[i].value - ) { - return false; - } - } - - return true; -} - -/** - * Check if the given node is a true logical expression or not. - * - * The three binary expressions logical-or (`||`), logical-and (`&&`), and - * coalesce (`??`) are known as `ShortCircuitExpression`. - * But ESTree represents those by `LogicalExpression` node. - * - * This function rejects coalesce expressions of `LogicalExpression` node. - * @param {ASTNode} node The node to check. - * @returns {boolean} `true` if the node is `&&` or `||`. - * @see https://tc39.es/ecma262/#prod-ShortCircuitExpression - */ -function isLogicalExpression(node) { - return ( - node.type === "LogicalExpression" && - (node.operator === "&&" || node.operator === "||") - ); -} - -/** - * Check if the given node is a nullish coalescing expression or not. - * - * The three binary expressions logical-or (`||`), logical-and (`&&`), and - * coalesce (`??`) are known as `ShortCircuitExpression`. - * But ESTree represents those by `LogicalExpression` node. - * - * This function finds only coalesce expressions of `LogicalExpression` node. - * @param {ASTNode} node The node to check. - * @returns {boolean} `true` if the node is `??`. - */ -function isCoalesceExpression(node) { - return node.type === "LogicalExpression" && node.operator === "??"; -} - -/** - * Check if given two nodes are the pair of a logical expression and a coalesce expression. - * @param {ASTNode} left A node to check. - * @param {ASTNode} right Another node to check. - * @returns {boolean} `true` if the two nodes are the pair of a logical expression and a coalesce expression. - */ -function isMixedLogicalAndCoalesceExpressions(left, right) { - return ( - (isLogicalExpression(left) && isCoalesceExpression(right)) || - (isCoalesceExpression(left) && isLogicalExpression(right)) - ); -} - -/** - * Checks if the given operator is a logical assignment operator. - * @param {string} operator The operator to check. - * @returns {boolean} `true` if the operator is a logical assignment operator. - */ -function isLogicalAssignmentOperator(operator) { - return LOGICAL_ASSIGNMENT_OPERATORS.has(operator); -} - -/** - * Get the colon token of the given SwitchCase node. - * @param {ASTNode} node The SwitchCase node to get. - * @param {SourceCode} sourceCode The source code object to get tokens. - * @returns {Token} The colon token of the node. - */ -function getSwitchCaseColonToken(node, sourceCode) { - if (node.test) { - return sourceCode.getTokenAfter(node.test, isColonToken); - } - return sourceCode.getFirstToken(node, 1); -} - -/** - * Gets ESM module export name represented by the given node. - * @param {ASTNode} node `Identifier` or string `Literal` node in a position - * that represents a module export name: - * - `ImportSpecifier#imported` - * - `ExportSpecifier#local` (if it is a re-export from another module) - * - `ExportSpecifier#exported` - * - `ExportAllDeclaration#exported` - * @returns {string} The module export name. - */ -function getModuleExportName(node) { - if (node.type === "Identifier") { - return node.name; - } - - // string literal - return node.value; -} - -/** - * Returns literal's value converted to the Boolean type - * @param {ASTNode} node any `Literal` node - * @returns {boolean | null} `true` when node is truthy, `false` when node is falsy, - * `null` when it cannot be determined. - */ -function getBooleanValue(node) { - if (node.value === null) { - - /* - * it might be a null literal or bigint/regex literal in unsupported environments . - * https://github.com/estree/estree/blob/14df8a024956ea289bd55b9c2226a1d5b8a473ee/es5.md#regexpliteral - * https://github.com/estree/estree/blob/14df8a024956ea289bd55b9c2226a1d5b8a473ee/es2020.md#bigintliteral - */ - - if (node.raw === "null") { - return false; - } - - // regex is always truthy - if (typeof node.regex === "object") { - return true; - } - - return null; - } - - return !!node.value; -} - -/** - * Checks if a branch node of LogicalExpression short circuits the whole condition - * @param {ASTNode} node The branch of main condition which needs to be checked - * @param {string} operator The operator of the main LogicalExpression. - * @returns {boolean} true when condition short circuits whole condition - */ -function isLogicalIdentity(node, operator) { - switch (node.type) { - case "Literal": - return (operator === "||" && getBooleanValue(node) === true) || - (operator === "&&" && getBooleanValue(node) === false); - - case "UnaryExpression": - return (operator === "&&" && node.operator === "void"); - - case "LogicalExpression": - - /* - * handles `a && false || b` - * `false` is an identity element of `&&` but not `||` - */ - return operator === node.operator && - ( - isLogicalIdentity(node.left, operator) || - isLogicalIdentity(node.right, operator) - ); - - case "AssignmentExpression": - return ["||=", "&&="].includes(node.operator) && - operator === node.operator.slice(0, -1) && - isLogicalIdentity(node.right, operator); - - // no default - } - return false; -} - -/** - * Checks if an identifier is a reference to a global variable. - * @param {Scope} scope The scope in which the identifier is referenced. - * @param {ASTNode} node An identifier node to check. - * @returns {boolean} `true` if the identifier is a reference to a global variable. - */ -function isReferenceToGlobalVariable(scope, node) { - const reference = scope.references.find(ref => ref.identifier === node); - - return Boolean( - reference && - reference.resolved && - reference.resolved.scope.type === "global" && - reference.resolved.defs.length === 0 - ); -} - - -/** - * Checks if a node has a constant truthiness value. - * @param {Scope} scope Scope in which the node appears. - * @param {ASTNode} node The AST node to check. - * @param {boolean} inBooleanPosition `true` if checking the test of a - * condition. `false` in all other cases. When `false`, checks if -- for - * both string and number -- if coerced to that type, the value will - * be constant. - * @returns {boolean} true when node's truthiness is constant - * @private - */ -function isConstant(scope, node, inBooleanPosition) { - - // node.elements can return null values in the case of sparse arrays ex. [,] - if (!node) { - return true; - } - switch (node.type) { - case "Literal": - case "ArrowFunctionExpression": - case "FunctionExpression": - return true; - case "ClassExpression": - case "ObjectExpression": - - /** - * In theory objects like: - * - * `{toString: () => a}` - * `{valueOf: () => a}` - * - * Or a classes like: - * - * `class { static toString() { return a } }` - * `class { static valueOf() { return a } }` - * - * Are not constant verifiably when `inBooleanPosition` is - * false, but it's an edge case we've opted not to handle. - */ - return true; - case "TemplateLiteral": - return (inBooleanPosition && node.quasis.some(quasi => quasi.value.cooked.length)) || - node.expressions.every(exp => isConstant(scope, exp, false)); - - case "ArrayExpression": { - if (!inBooleanPosition) { - return node.elements.every(element => isConstant(scope, element, false)); - } - return true; - } - - case "UnaryExpression": - if ( - node.operator === "void" || - node.operator === "typeof" && inBooleanPosition - ) { - return true; - } - - if (node.operator === "!") { - return isConstant(scope, node.argument, true); - } - - return isConstant(scope, node.argument, false); - - case "BinaryExpression": - return isConstant(scope, node.left, false) && - isConstant(scope, node.right, false) && - node.operator !== "in"; - - case "LogicalExpression": { - const isLeftConstant = isConstant(scope, node.left, inBooleanPosition); - const isRightConstant = isConstant(scope, node.right, inBooleanPosition); - const isLeftShortCircuit = (isLeftConstant && isLogicalIdentity(node.left, node.operator)); - const isRightShortCircuit = (inBooleanPosition && isRightConstant && isLogicalIdentity(node.right, node.operator)); - - return (isLeftConstant && isRightConstant) || - isLeftShortCircuit || - isRightShortCircuit; - } - case "NewExpression": - return inBooleanPosition; - case "AssignmentExpression": - if (node.operator === "=") { - return isConstant(scope, node.right, inBooleanPosition); - } - - if (["||=", "&&="].includes(node.operator) && inBooleanPosition) { - return isLogicalIdentity(node.right, node.operator.slice(0, -1)); - } - - return false; - - case "SequenceExpression": - return isConstant(scope, node.expressions.at(-1), inBooleanPosition); - case "SpreadElement": - return isConstant(scope, node.argument, inBooleanPosition); - case "CallExpression": - if (node.callee.type === "Identifier" && node.callee.name === "Boolean") { - if (node.arguments.length === 0 || isConstant(scope, node.arguments[0], true)) { - return isReferenceToGlobalVariable(scope, node.callee); - } - } - return false; - case "Identifier": - return node.name === "undefined" && isReferenceToGlobalVariable(scope, node); - - // no default - } - return false; -} - -/** - * Checks whether a node is an ExpressionStatement at the top level of a file or function body. - * A top-level ExpressionStatement node is a directive if it contains a single unparenthesized - * string literal and if it occurs either as the first sibling or immediately after another - * directive. - * @param {ASTNode} node The node to check. - * @returns {boolean} Whether or not the node is an ExpressionStatement at the top level of a - * file or function body. - */ -function isTopLevelExpressionStatement(node) { - if (node.type !== "ExpressionStatement") { - return false; - } - const parent = node.parent; - - return parent.type === "Program" || (parent.type === "BlockStatement" && isFunction(parent.parent)); - -} - -/** - * Check whether the given node is a part of a directive prologue or not. - * @param {ASTNode} node The node to check. - * @returns {boolean} `true` if the node is a part of directive prologue. - */ -function isDirective(node) { - return node.type === "ExpressionStatement" && typeof node.directive === "string"; -} - -/** - * Tests if a node appears at the beginning of an ancestor ExpressionStatement node. - * @param {ASTNode} node The node to check. - * @returns {boolean} Whether the node appears at the beginning of an ancestor ExpressionStatement node. - */ -function isStartOfExpressionStatement(node) { - const start = node.range[0]; - let ancestor = node; - - while ((ancestor = ancestor.parent) && ancestor.range[0] === start) { - if (ancestor.type === "ExpressionStatement") { - return true; - } - } - return false; -} - -/** - * Determines whether an opening parenthesis `(`, bracket `[` or backtick ``` ` ``` needs to be preceded by a semicolon. - * This opening parenthesis or bracket should be at the start of an `ExpressionStatement` or at the start of the body of an `ArrowFunctionExpression`. - * @type {(sourceCode: SourceCode, node: ASTNode) => boolean} - * @param {SourceCode} sourceCode The source code object. - * @param {ASTNode} node A node at the position where an opening parenthesis or bracket will be inserted. - * @returns {boolean} Whether a semicolon is required before the opening parenthesis or braket. - */ -let needsPrecedingSemicolon; - -{ - const BREAK_OR_CONTINUE = new Set(["BreakStatement", "ContinueStatement"]); - - // Declaration types that must contain a string Literal node at the end. - const DECLARATIONS = new Set(["ExportAllDeclaration", "ExportNamedDeclaration", "ImportDeclaration"]); - - const IDENTIFIER_OR_KEYWORD = new Set(["Identifier", "Keyword"]); - - // Keywords that can immediately precede an ExpressionStatement node, mapped to the their node types. - const NODE_TYPES_BY_KEYWORD = { - __proto__: null, - break: "BreakStatement", - continue: "ContinueStatement", - debugger: "DebuggerStatement", - do: "DoWhileStatement", - else: "IfStatement", - return: "ReturnStatement", - yield: "YieldExpression" - }; - - /* - * Before an opening parenthesis, postfix `++` and `--` always trigger ASI; - * the tokens `:`, `;`, `{` and `=>` don't expect a semicolon, as that would count as an empty statement. - */ - const PUNCTUATORS = new Set([":", ";", "{", "=>", "++", "--"]); - - /* - * Statements that can contain an `ExpressionStatement` after a closing parenthesis. - * DoWhileStatement is an exception in that it always triggers ASI after the closing parenthesis. - */ - const STATEMENTS = new Set([ - "DoWhileStatement", - "ForInStatement", - "ForOfStatement", - "ForStatement", - "IfStatement", - "WhileStatement", - "WithStatement" - ]); - - needsPrecedingSemicolon = - function(sourceCode, node) { - const prevToken = sourceCode.getTokenBefore(node); - - if (!prevToken || prevToken.type === "Punctuator" && PUNCTUATORS.has(prevToken.value)) { - return false; - } - - const prevNode = sourceCode.getNodeByRangeIndex(prevToken.range[0]); - - if (isClosingParenToken(prevToken)) { - return !STATEMENTS.has(prevNode.type); - } - - if (isClosingBraceToken(prevToken)) { - return ( - prevNode.type === "BlockStatement" && prevNode.parent.type === "FunctionExpression" || - prevNode.type === "ClassBody" && prevNode.parent.type === "ClassExpression" || - prevNode.type === "ObjectExpression" - ); - } - - if (IDENTIFIER_OR_KEYWORD.has(prevToken.type)) { - if (BREAK_OR_CONTINUE.has(prevNode.parent.type)) { - return false; - } - - const keyword = prevToken.value; - const nodeType = NODE_TYPES_BY_KEYWORD[keyword]; - - return prevNode.type !== nodeType; - } - - if (prevToken.type === "String") { - return !DECLARATIONS.has(prevNode.parent.type); - } - - return true; - }; -} - -//------------------------------------------------------------------------------ -// Public Interface -//------------------------------------------------------------------------------ - -module.exports = { - COMMENTS_IGNORE_PATTERN, - LINEBREAKS, - LINEBREAK_MATCHER: lineBreakPattern, - SHEBANG_MATCHER: shebangPattern, - STATEMENT_LIST_PARENTS, - ECMASCRIPT_GLOBALS, - - /** - * Determines whether two adjacent tokens are on the same line. - * @param {Object} left The left token object. - * @param {Object} right The right token object. - * @returns {boolean} Whether or not the tokens are on the same line. - * @public - */ - isTokenOnSameLine(left, right) { - return left.loc.end.line === right.loc.start.line; - }, - - isNullOrUndefined, - isCallee, - isES5Constructor, - getUpperFunction, - isFunction, - isLoop, - isInLoop, - isArrayFromMethod, - isParenthesised, - createGlobalLinebreakMatcher, - equalTokens, - - isArrowToken, - isClosingBraceToken, - isClosingBracketToken, - isClosingParenToken, - isColonToken, - isCommaToken, - isCommentToken, - isDotToken, - isQuestionDotToken, - isKeywordToken, - isNotClosingBraceToken: negate(isClosingBraceToken), - isNotClosingBracketToken: negate(isClosingBracketToken), - isNotClosingParenToken: negate(isClosingParenToken), - isNotColonToken: negate(isColonToken), - isNotCommaToken: negate(isCommaToken), - isNotDotToken: negate(isDotToken), - isNotQuestionDotToken: negate(isQuestionDotToken), - isNotOpeningBraceToken: negate(isOpeningBraceToken), - isNotOpeningBracketToken: negate(isOpeningBracketToken), - isNotOpeningParenToken: negate(isOpeningParenToken), - isNotSemicolonToken: negate(isSemicolonToken), - isOpeningBraceToken, - isOpeningBracketToken, - isOpeningParenToken, - isSemicolonToken, - isEqToken, - - /** - * Checks whether or not a given node is a string literal. - * @param {ASTNode} node A node to check. - * @returns {boolean} `true` if the node is a string literal. - */ - isStringLiteral(node) { - return ( - (node.type === "Literal" && typeof node.value === "string") || - node.type === "TemplateLiteral" - ); - }, - - /** - * Checks whether a given node is a breakable statement or not. - * The node is breakable if the node is one of the following type: - * - * - DoWhileStatement - * - ForInStatement - * - ForOfStatement - * - ForStatement - * - SwitchStatement - * - WhileStatement - * @param {ASTNode} node A node to check. - * @returns {boolean} `true` if the node is breakable. - */ - isBreakableStatement(node) { - return breakableTypePattern.test(node.type); - }, - - /** - * Gets references which are non initializer and writable. - * @param {Reference[]} references An array of references. - * @returns {Reference[]} An array of only references which are non initializer and writable. - * @public - */ - getModifyingReferences(references) { - return references.filter(isModifyingReference); - }, - - /** - * Validate that a string passed in is surrounded by the specified character - * @param {string} val The text to check. - * @param {string} character The character to see if it's surrounded by. - * @returns {boolean} True if the text is surrounded by the character, false if not. - * @private - */ - isSurroundedBy(val, character) { - return val[0] === character && val.at(-1) === character; - }, - - /** - * Returns whether the provided node is an ESLint directive comment or not - * @param {Line|Block} node The comment token to be checked - * @returns {boolean} `true` if the node is an ESLint directive comment - */ - isDirectiveComment(node) { - const comment = node.value.trim(); - - return ( - node.type === "Line" && comment.startsWith("eslint-") || - node.type === "Block" && ESLINT_DIRECTIVE_PATTERN.test(comment) - ); - }, - - /** - * Gets the trailing statement of a given node. - * - * if (code) - * consequent; - * - * When taking this `IfStatement`, returns `consequent;` statement. - * @param {ASTNode} A node to get. - * @returns {ASTNode|null} The trailing statement's node. - */ - getTrailingStatement: esutils.ast.trailingStatement, - - /** - * Finds the variable by a given name in a given scope and its upper scopes. - * @param {eslint-scope.Scope} initScope A scope to start find. - * @param {string} name A variable name to find. - * @returns {eslint-scope.Variable|null} A found variable or `null`. - */ - getVariableByName(initScope, name) { - let scope = initScope; - - while (scope) { - const variable = scope.set.get(name); - - if (variable) { - return variable; - } - - scope = scope.upper; - } - - return null; - }, - - /** - * Checks whether or not a given function node is the default `this` binding. - * - * First, this checks the node: - * - * - The given node is not in `PropertyDefinition#value` position. - * - The given node is not `StaticBlock`. - * - The function name does not start with uppercase. It's a convention to capitalize the names - * of constructor functions. This check is not performed if `capIsConstructor` is set to `false`. - * - The function does not have a JSDoc comment that has a @this tag. - * - * Next, this checks the location of the node. - * If the location is below, this judges `this` is valid. - * - * - The location is not on an object literal. - * - The location is not assigned to a variable which starts with an uppercase letter. Applies to anonymous - * functions only, as the name of the variable is considered to be the name of the function in this case. - * This check is not performed if `capIsConstructor` is set to `false`. - * - The location is not on an ES2015 class. - * - Its `bind`/`call`/`apply` method is not called directly. - * - The function is not a callback of array methods (such as `.forEach()`) if `thisArg` is given. - * @param {ASTNode} node A function node to check. It also can be an implicit function, like `StaticBlock` - * or any expression that is `PropertyDefinition#value` node. - * @param {SourceCode} sourceCode A SourceCode instance to get comments. - * @param {boolean} [capIsConstructor = true] `false` disables the assumption that functions which name starts - * with an uppercase or are assigned to a variable which name starts with an uppercase are constructors. - * @returns {boolean} The function node is the default `this` binding. - */ - isDefaultThisBinding(node, sourceCode, { capIsConstructor = true } = {}) { - - /* - * Class field initializers are implicit functions, but ESTree doesn't have the AST node of field initializers. - * Therefore, A expression node at `PropertyDefinition#value` is a function. - * In this case, `this` is always not default binding. - */ - if (node.parent.type === "PropertyDefinition" && node.parent.value === node) { - return false; - } - - // Class static blocks are implicit functions. In this case, `this` is always not default binding. - if (node.type === "StaticBlock") { - return false; - } - - if ( - (capIsConstructor && isES5Constructor(node)) || - hasJSDocThisTag(node, sourceCode) - ) { - return false; - } - const isAnonymous = node.id === null; - let currentNode = node; - - while (currentNode) { - const parent = currentNode.parent; - - switch (parent.type) { - - /* - * Looks up the destination. - * e.g., obj.foo = nativeFoo || function foo() { ... }; - */ - case "LogicalExpression": - case "ConditionalExpression": - case "ChainExpression": - currentNode = parent; - break; - - /* - * If the upper function is IIFE, checks the destination of the return value. - * e.g. - * obj.foo = (function() { - * // setup... - * return function foo() { ... }; - * })(); - * obj.foo = (() => - * function foo() { ... } - * )(); - */ - case "ReturnStatement": { - const func = getUpperFunction(parent); - - if (func === null || !isCallee(func)) { - return true; - } - currentNode = func.parent; - break; - } - case "ArrowFunctionExpression": - if (currentNode !== parent.body || !isCallee(parent)) { - return true; - } - currentNode = parent.parent; - break; - - /* - * e.g. - * var obj = { foo() { ... } }; - * var obj = { foo: function() { ... } }; - * class A { constructor() { ... } } - * class A { foo() { ... } } - * class A { get foo() { ... } } - * class A { set foo() { ... } } - * class A { static foo() { ... } } - * class A { foo = function() { ... } } - */ - case "Property": - case "PropertyDefinition": - case "MethodDefinition": - return parent.value !== currentNode; - - /* - * e.g. - * obj.foo = function foo() { ... }; - * Foo = function() { ... }; - * [obj.foo = function foo() { ... }] = a; - * [Foo = function() { ... }] = a; - */ - case "AssignmentExpression": - case "AssignmentPattern": - if (parent.left.type === "MemberExpression") { - return false; - } - if ( - capIsConstructor && - isAnonymous && - parent.left.type === "Identifier" && - startsWithUpperCase(parent.left.name) - ) { - return false; - } - return true; - - /* - * e.g. - * var Foo = function() { ... }; - */ - case "VariableDeclarator": - return !( - capIsConstructor && - isAnonymous && - parent.init === currentNode && - parent.id.type === "Identifier" && - startsWithUpperCase(parent.id.name) - ); - - /* - * e.g. - * var foo = function foo() { ... }.bind(obj); - * (function foo() { ... }).call(obj); - * (function foo() { ... }).apply(obj, []); - */ - case "MemberExpression": - if ( - parent.object === currentNode && - isSpecificMemberAccess(parent, null, bindOrCallOrApplyPattern) - ) { - const maybeCalleeNode = parent.parent.type === "ChainExpression" - ? parent.parent - : parent; - - return !( - isCallee(maybeCalleeNode) && - maybeCalleeNode.parent.arguments.length >= 1 && - !isNullOrUndefined(maybeCalleeNode.parent.arguments[0]) - ); - } - return true; - - /* - * e.g. - * Reflect.apply(function() {}, obj, []); - * Array.from([], function() {}, obj); - * list.forEach(function() {}, obj); - */ - case "CallExpression": - if (isReflectApply(parent.callee)) { - return ( - parent.arguments.length !== 3 || - parent.arguments[0] !== currentNode || - isNullOrUndefined(parent.arguments[1]) - ); - } - if (isArrayFromMethod(parent.callee)) { - return ( - parent.arguments.length !== 3 || - parent.arguments[1] !== currentNode || - isNullOrUndefined(parent.arguments[2]) - ); - } - if (isMethodWhichHasThisArg(parent.callee)) { - return ( - parent.arguments.length !== 2 || - parent.arguments[0] !== currentNode || - isNullOrUndefined(parent.arguments[1]) - ); - } - return true; - - // Otherwise `this` is default. - default: - return true; - } - } - - /* c8 ignore next */ - return true; - }, - - /** - * Get the precedence level based on the node type - * @param {ASTNode} node node to evaluate - * @returns {int} precedence level - * @private - */ - getPrecedence(node) { - switch (node.type) { - case "SequenceExpression": - return 0; - - case "AssignmentExpression": - case "ArrowFunctionExpression": - case "YieldExpression": - return 1; - - case "ConditionalExpression": - return 3; - - case "LogicalExpression": - switch (node.operator) { - case "||": - case "??": - return 4; - case "&&": - return 5; - - // no default - } - - /* falls through */ - - case "BinaryExpression": - - switch (node.operator) { - case "|": - return 6; - case "^": - return 7; - case "&": - return 8; - case "==": - case "!=": - case "===": - case "!==": - return 9; - case "<": - case "<=": - case ">": - case ">=": - case "in": - case "instanceof": - return 10; - case "<<": - case ">>": - case ">>>": - return 11; - case "+": - case "-": - return 12; - case "*": - case "/": - case "%": - return 13; - case "**": - return 15; - - // no default - } - - /* falls through */ - - case "UnaryExpression": - case "AwaitExpression": - return 16; - - case "UpdateExpression": - return 17; - - case "CallExpression": - case "ChainExpression": - case "ImportExpression": - return 18; - - case "NewExpression": - return 19; - - default: - if (node.type in eslintVisitorKeys) { - return 20; - } - - /* - * if the node is not a standard node that we know about, then assume it has the lowest precedence - * this will mean that rules will wrap unknown nodes in parentheses where applicable instead of - * unwrapping them and potentially changing the meaning of the code or introducing a syntax error. - */ - return -1; - } - }, - - /** - * Checks whether the given node is an empty block node or not. - * @param {ASTNode|null} node The node to check. - * @returns {boolean} `true` if the node is an empty block. - */ - isEmptyBlock(node) { - return Boolean(node && node.type === "BlockStatement" && node.body.length === 0); - }, - - /** - * Checks whether the given node is an empty function node or not. - * @param {ASTNode|null} node The node to check. - * @returns {boolean} `true` if the node is an empty function. - */ - isEmptyFunction(node) { - return isFunction(node) && module.exports.isEmptyBlock(node.body); - }, - - /** - * Get directives from directive prologue of a Program or Function node. - * @param {ASTNode} node The node to check. - * @returns {ASTNode[]} The directives found in the directive prologue. - */ - getDirectivePrologue(node) { - const directives = []; - - // Directive prologues only occur at the top of files or functions. - if ( - node.type === "Program" || - node.type === "FunctionDeclaration" || - node.type === "FunctionExpression" || - - /* - * Do not check arrow functions with implicit return. - * `() => "use strict";` returns the string `"use strict"`. - */ - (node.type === "ArrowFunctionExpression" && node.body.type === "BlockStatement") - ) { - const statements = node.type === "Program" ? node.body : node.body.body; - - for (const statement of statements) { - if ( - statement.type === "ExpressionStatement" && - statement.expression.type === "Literal" - ) { - directives.push(statement); - } else { - break; - } - } - } - - return directives; - }, - - /** - * Determines whether this node is a decimal integer literal. If a node is a decimal integer literal, a dot added - * after the node will be parsed as a decimal point, rather than a property-access dot. - * @param {ASTNode} node The node to check. - * @returns {boolean} `true` if this node is a decimal integer. - * @example - * - * 0 // true - * 5 // true - * 50 // true - * 5_000 // true - * 1_234_56 // true - * 08 // true - * 0192 // true - * 5. // false - * .5 // false - * 5.0 // false - * 5.00_00 // false - * 05 // false - * 0x5 // false - * 0b101 // false - * 0b11_01 // false - * 0o5 // false - * 5e0 // false - * 5e1_000 // false - * 5n // false - * 1_000n // false - * "5" // false - * - */ - isDecimalInteger(node) { - return node.type === "Literal" && typeof node.value === "number" && - DECIMAL_INTEGER_PATTERN.test(node.raw); - }, - - /** - * Determines whether this token is a decimal integer numeric token. - * This is similar to isDecimalInteger(), but for tokens. - * @param {Token} token The token to check. - * @returns {boolean} `true` if this token is a decimal integer. - */ - isDecimalIntegerNumericToken(token) { - return token.type === "Numeric" && DECIMAL_INTEGER_PATTERN.test(token.value); - }, - - /** - * Gets the name and kind of the given function node. - * - * - `function foo() {}` .................... `function 'foo'` - * - `(function foo() {})` .................. `function 'foo'` - * - `(function() {})` ...................... `function` - * - `function* foo() {}` ................... `generator function 'foo'` - * - `(function* foo() {})` ................. `generator function 'foo'` - * - `(function*() {})` ..................... `generator function` - * - `() => {}` ............................. `arrow function` - * - `async () => {}` ....................... `async arrow function` - * - `({ foo: function foo() {} })` ......... `method 'foo'` - * - `({ foo: function() {} })` ............. `method 'foo'` - * - `({ ['foo']: function() {} })` ......... `method 'foo'` - * - `({ [foo]: function() {} })` ........... `method` - * - `({ foo() {} })` ....................... `method 'foo'` - * - `({ foo: function* foo() {} })` ........ `generator method 'foo'` - * - `({ foo: function*() {} })` ............ `generator method 'foo'` - * - `({ ['foo']: function*() {} })` ........ `generator method 'foo'` - * - `({ [foo]: function*() {} })` .......... `generator method` - * - `({ *foo() {} })` ...................... `generator method 'foo'` - * - `({ foo: async function foo() {} })` ... `async method 'foo'` - * - `({ foo: async function() {} })` ....... `async method 'foo'` - * - `({ ['foo']: async function() {} })` ... `async method 'foo'` - * - `({ [foo]: async function() {} })` ..... `async method` - * - `({ async foo() {} })` ................. `async method 'foo'` - * - `({ get foo() {} })` ................... `getter 'foo'` - * - `({ set foo(a) {} })` .................. `setter 'foo'` - * - `class A { constructor() {} }` ......... `constructor` - * - `class A { foo() {} }` ................. `method 'foo'` - * - `class A { *foo() {} }` ................ `generator method 'foo'` - * - `class A { async foo() {} }` ........... `async method 'foo'` - * - `class A { ['foo']() {} }` ............. `method 'foo'` - * - `class A { *['foo']() {} }` ............ `generator method 'foo'` - * - `class A { async ['foo']() {} }` ....... `async method 'foo'` - * - `class A { [foo]() {} }` ............... `method` - * - `class A { *[foo]() {} }` .............. `generator method` - * - `class A { async [foo]() {} }` ......... `async method` - * - `class A { get foo() {} }` ............. `getter 'foo'` - * - `class A { set foo(a) {} }` ............ `setter 'foo'` - * - `class A { static foo() {} }` .......... `static method 'foo'` - * - `class A { static *foo() {} }` ......... `static generator method 'foo'` - * - `class A { static async foo() {} }` .... `static async method 'foo'` - * - `class A { static get foo() {} }` ...... `static getter 'foo'` - * - `class A { static set foo(a) {} }` ..... `static setter 'foo'` - * - `class A { foo = () => {}; }` .......... `method 'foo'` - * - `class A { foo = function() {}; }` ..... `method 'foo'` - * - `class A { foo = function bar() {}; }` . `method 'foo'` - * - `class A { static foo = () => {}; }` ... `static method 'foo'` - * - `class A { '#foo' = () => {}; }` ....... `method '#foo'` - * - `class A { #foo = () => {}; }` ......... `private method #foo` - * - `class A { static #foo = () => {}; }` .. `static private method #foo` - * - `class A { '#foo'() {} }` .............. `method '#foo'` - * - `class A { #foo() {} }` ................ `private method #foo` - * - `class A { static #foo() {} }` ......... `static private method #foo` - * @param {ASTNode} node The function node to get. - * @returns {string} The name and kind of the function node. - */ - getFunctionNameWithKind(node) { - const parent = node.parent; - const tokens = []; - - if (parent.type === "MethodDefinition" || parent.type === "PropertyDefinition") { - - // The proposal uses `static` word consistently before visibility words: https://github.com/tc39/proposal-static-class-features - if (parent.static) { - tokens.push("static"); - } - if (!parent.computed && parent.key.type === "PrivateIdentifier") { - tokens.push("private"); - } - } - if (node.async) { - tokens.push("async"); - } - if (node.generator) { - tokens.push("generator"); - } - - if (parent.type === "Property" || parent.type === "MethodDefinition") { - if (parent.kind === "constructor") { - return "constructor"; - } - if (parent.kind === "get") { - tokens.push("getter"); - } else if (parent.kind === "set") { - tokens.push("setter"); - } else { - tokens.push("method"); - } - } else if (parent.type === "PropertyDefinition") { - tokens.push("method"); - } else { - if (node.type === "ArrowFunctionExpression") { - tokens.push("arrow"); - } - tokens.push("function"); - } - - if (parent.type === "Property" || parent.type === "MethodDefinition" || parent.type === "PropertyDefinition") { - if (!parent.computed && parent.key.type === "PrivateIdentifier") { - tokens.push(`#${parent.key.name}`); - } else { - const name = getStaticPropertyName(parent); - - if (name !== null) { - tokens.push(`'${name}'`); - } else if (node.id) { - tokens.push(`'${node.id.name}'`); - } - } - } else if (node.id) { - tokens.push(`'${node.id.name}'`); - } - - return tokens.join(" "); - }, - - /** - * Gets the location of the given function node for reporting. - * - * - `function foo() {}` - * ^^^^^^^^^^^^ - * - `(function foo() {})` - * ^^^^^^^^^^^^ - * - `(function() {})` - * ^^^^^^^^ - * - `function* foo() {}` - * ^^^^^^^^^^^^^ - * - `(function* foo() {})` - * ^^^^^^^^^^^^^ - * - `(function*() {})` - * ^^^^^^^^^ - * - `() => {}` - * ^^ - * - `async () => {}` - * ^^ - * - `({ foo: function foo() {} })` - * ^^^^^^^^^^^^^^^^^ - * - `({ foo: function() {} })` - * ^^^^^^^^^^^^^ - * - `({ ['foo']: function() {} })` - * ^^^^^^^^^^^^^^^^^ - * - `({ [foo]: function() {} })` - * ^^^^^^^^^^^^^^^ - * - `({ foo() {} })` - * ^^^ - * - `({ foo: function* foo() {} })` - * ^^^^^^^^^^^^^^^^^^ - * - `({ foo: function*() {} })` - * ^^^^^^^^^^^^^^ - * - `({ ['foo']: function*() {} })` - * ^^^^^^^^^^^^^^^^^^ - * - `({ [foo]: function*() {} })` - * ^^^^^^^^^^^^^^^^ - * - `({ *foo() {} })` - * ^^^^ - * - `({ foo: async function foo() {} })` - * ^^^^^^^^^^^^^^^^^^^^^^^ - * - `({ foo: async function() {} })` - * ^^^^^^^^^^^^^^^^^^^ - * - `({ ['foo']: async function() {} })` - * ^^^^^^^^^^^^^^^^^^^^^^^ - * - `({ [foo]: async function() {} })` - * ^^^^^^^^^^^^^^^^^^^^^ - * - `({ async foo() {} })` - * ^^^^^^^^^ - * - `({ get foo() {} })` - * ^^^^^^^ - * - `({ set foo(a) {} })` - * ^^^^^^^ - * - `class A { constructor() {} }` - * ^^^^^^^^^^^ - * - `class A { foo() {} }` - * ^^^ - * - `class A { *foo() {} }` - * ^^^^ - * - `class A { async foo() {} }` - * ^^^^^^^^^ - * - `class A { ['foo']() {} }` - * ^^^^^^^ - * - `class A { *['foo']() {} }` - * ^^^^^^^^ - * - `class A { async ['foo']() {} }` - * ^^^^^^^^^^^^^ - * - `class A { [foo]() {} }` - * ^^^^^ - * - `class A { *[foo]() {} }` - * ^^^^^^ - * - `class A { async [foo]() {} }` - * ^^^^^^^^^^^ - * - `class A { get foo() {} }` - * ^^^^^^^ - * - `class A { set foo(a) {} }` - * ^^^^^^^ - * - `class A { static foo() {} }` - * ^^^^^^^^^^ - * - `class A { static *foo() {} }` - * ^^^^^^^^^^^ - * - `class A { static async foo() {} }` - * ^^^^^^^^^^^^^^^^ - * - `class A { static get foo() {} }` - * ^^^^^^^^^^^^^^ - * - `class A { static set foo(a) {} }` - * ^^^^^^^^^^^^^^ - * - `class A { foo = function() {} }` - * ^^^^^^^^^^^^^^ - * - `class A { static foo = function() {} }` - * ^^^^^^^^^^^^^^^^^^^^^ - * - `class A { foo = (a, b) => {} }` - * ^^^^^^ - * @param {ASTNode} node The function node to get. - * @param {SourceCode} sourceCode The source code object to get tokens. - * @returns {string} The location of the function node for reporting. - */ - getFunctionHeadLoc(node, sourceCode) { - const parent = node.parent; - let start; - let end; - - if (parent.type === "Property" || parent.type === "MethodDefinition" || parent.type === "PropertyDefinition") { - start = parent.loc.start; - end = getOpeningParenOfParams(node, sourceCode).loc.start; - } else if (node.type === "ArrowFunctionExpression") { - const arrowToken = sourceCode.getTokenBefore(node.body, isArrowToken); - - start = arrowToken.loc.start; - end = arrowToken.loc.end; - } else { - start = node.loc.start; - end = getOpeningParenOfParams(node, sourceCode).loc.start; - } - - return { - start: Object.assign({}, start), - end: Object.assign({}, end) - }; - }, - - /** - * Gets next location when the result is not out of bound, otherwise returns null. - * - * Assumptions: - * - * - The given location represents a valid location in the given source code. - * - Columns are 0-based. - * - Lines are 1-based. - * - Column immediately after the last character in a line (not incl. linebreaks) is considered to be a valid location. - * - If the source code ends with a linebreak, `sourceCode.lines` array will have an extra element (empty string) at the end. - * The start (column 0) of that extra line is considered to be a valid location. - * - * Examples of successive locations (line, column): - * - * code: foo - * locations: (1, 0) -> (1, 1) -> (1, 2) -> (1, 3) -> null - * - * code: foo - * locations: (1, 0) -> (1, 1) -> (1, 2) -> (1, 3) -> (2, 0) -> null - * - * code: foo - * locations: (1, 0) -> (1, 1) -> (1, 2) -> (1, 3) -> (2, 0) -> null - * - * code: ab - * locations: (1, 0) -> (1, 1) -> (2, 0) -> (2, 1) -> null - * - * code: ab - * locations: (1, 0) -> (1, 1) -> (2, 0) -> (2, 1) -> (3, 0) -> null - * - * code: ab - * locations: (1, 0) -> (1, 1) -> (2, 0) -> (2, 1) -> (3, 0) -> null - * - * code: a - * locations: (1, 0) -> (1, 1) -> (2, 0) -> (3, 0) -> null - * - * code: - * locations: (1, 0) -> (2, 0) -> null - * - * code: - * locations: (1, 0) -> null - * @param {SourceCode} sourceCode The sourceCode - * @param {{line: number, column: number}} location The location - * @returns {{line: number, column: number} | null} Next location - */ - getNextLocation(sourceCode, { line, column }) { - if (column < sourceCode.lines[line - 1].length) { - return { - line, - column: column + 1 - }; - } - - if (line < sourceCode.lines.length) { - return { - line: line + 1, - column: 0 - }; - } - - return null; - }, - - /** - * Gets the parenthesized text of a node. This is similar to sourceCode.getText(node), but it also includes any parentheses - * surrounding the node. - * @param {SourceCode} sourceCode The source code object - * @param {ASTNode} node An expression node - * @returns {string} The text representing the node, with all surrounding parentheses included - */ - getParenthesisedText(sourceCode, node) { - let leftToken = sourceCode.getFirstToken(node); - let rightToken = sourceCode.getLastToken(node); - - while ( - sourceCode.getTokenBefore(leftToken) && - sourceCode.getTokenBefore(leftToken).type === "Punctuator" && - sourceCode.getTokenBefore(leftToken).value === "(" && - sourceCode.getTokenAfter(rightToken) && - sourceCode.getTokenAfter(rightToken).type === "Punctuator" && - sourceCode.getTokenAfter(rightToken).value === ")" - ) { - leftToken = sourceCode.getTokenBefore(leftToken); - rightToken = sourceCode.getTokenAfter(rightToken); - } - - return sourceCode.getText().slice(leftToken.range[0], rightToken.range[1]); - }, - - /** - * Determine if a node has a possibility to be an Error object - * @param {ASTNode} node ASTNode to check - * @returns {boolean} True if there is a chance it contains an Error obj - */ - couldBeError(node) { - switch (node.type) { - case "Identifier": - case "CallExpression": - case "NewExpression": - case "MemberExpression": - case "TaggedTemplateExpression": - case "YieldExpression": - case "AwaitExpression": - case "ChainExpression": - return true; // possibly an error object. - - case "AssignmentExpression": - if (["=", "&&="].includes(node.operator)) { - return module.exports.couldBeError(node.right); - } - - if (["||=", "??="].includes(node.operator)) { - return module.exports.couldBeError(node.left) || module.exports.couldBeError(node.right); - } - - /** - * All other assignment operators are mathematical assignment operators (arithmetic or bitwise). - * An assignment expression with a mathematical operator can either evaluate to a primitive value, - * or throw, depending on the operands. Thus, it cannot evaluate to an `Error` object. - */ - return false; - - case "SequenceExpression": { - const exprs = node.expressions; - - return exprs.length !== 0 && module.exports.couldBeError(exprs.at(-1)); - } - - case "LogicalExpression": - - /* - * If the && operator short-circuits, the left side was falsy and therefore not an error, and if it - * doesn't short-circuit, it takes the value from the right side, so the right side must always be - * a plausible error. A future improvement could verify that the left side could be truthy by - * excluding falsy literals. - */ - if (node.operator === "&&") { - return module.exports.couldBeError(node.right); - } - - return module.exports.couldBeError(node.left) || module.exports.couldBeError(node.right); - - case "ConditionalExpression": - return module.exports.couldBeError(node.consequent) || module.exports.couldBeError(node.alternate); - - default: - return false; - } - }, - - /** - * Check if a given node is a numeric literal or not. - * @param {ASTNode} node The node to check. - * @returns {boolean} `true` if the node is a number or bigint literal. - */ - isNumericLiteral(node) { - return ( - node.type === "Literal" && - (typeof node.value === "number" || Boolean(node.bigint)) - ); - }, - - /** - * Determines whether two tokens can safely be placed next to each other without merging into a single token - * @param {Token|string} leftValue The left token. If this is a string, it will be tokenized and the last token will be used. - * @param {Token|string} rightValue The right token. If this is a string, it will be tokenized and the first token will be used. - * @returns {boolean} If the tokens cannot be safely placed next to each other, returns `false`. If the tokens can be placed - * next to each other, behavior is undefined (although it should return `true` in most cases). - */ - canTokensBeAdjacent(leftValue, rightValue) { - const espreeOptions = { - ecmaVersion: espree.latestEcmaVersion, - comment: true, - range: true - }; - - let leftToken; - - if (typeof leftValue === "string") { - let tokens; - - try { - tokens = espree.tokenize(leftValue, espreeOptions); - } catch { - return false; - } - - const comments = tokens.comments; - - leftToken = tokens.at(-1); - if (comments.length) { - const lastComment = comments.at(-1); - - if (!leftToken || lastComment.range[0] > leftToken.range[0]) { - leftToken = lastComment; - } - } - } else { - leftToken = leftValue; - } - - /* - * If a hashbang comment was passed as a token object from SourceCode, - * its type will be "Shebang" because of the way ESLint itself handles hashbangs. - * If a hashbang comment was passed in a string and then tokenized in this function, - * its type will be "Hashbang" because of the way Espree tokenizes hashbangs. - */ - if (leftToken.type === "Shebang" || leftToken.type === "Hashbang") { - return false; - } - - let rightToken; - - if (typeof rightValue === "string") { - let tokens; - - try { - tokens = espree.tokenize(rightValue, espreeOptions); - } catch { - return false; - } - - const comments = tokens.comments; - - rightToken = tokens[0]; - if (comments.length) { - const firstComment = comments[0]; - - if (!rightToken || firstComment.range[0] < rightToken.range[0]) { - rightToken = firstComment; - } - } - } else { - rightToken = rightValue; - } - - if (leftToken.type === "Punctuator" || rightToken.type === "Punctuator") { - if (leftToken.type === "Punctuator" && rightToken.type === "Punctuator") { - const PLUS_TOKENS = new Set(["+", "++"]); - const MINUS_TOKENS = new Set(["-", "--"]); - - return !( - PLUS_TOKENS.has(leftToken.value) && PLUS_TOKENS.has(rightToken.value) || - MINUS_TOKENS.has(leftToken.value) && MINUS_TOKENS.has(rightToken.value) - ); - } - if (leftToken.type === "Punctuator" && leftToken.value === "/") { - return !["Block", "Line", "RegularExpression"].includes(rightToken.type); - } - return true; - } - - if ( - leftToken.type === "String" || rightToken.type === "String" || - leftToken.type === "Template" || rightToken.type === "Template" - ) { - return true; - } - - if (leftToken.type !== "Numeric" && rightToken.type === "Numeric" && rightToken.value.startsWith(".")) { - return true; - } - - if (leftToken.type === "Block" || rightToken.type === "Block" || rightToken.type === "Line") { - return true; - } - - if (rightToken.type === "PrivateIdentifier") { - return true; - } - - return false; - }, - - /** - * Get the `loc` object of a given name in a `/*globals` directive comment. - * @param {SourceCode} sourceCode The source code to convert index to loc. - * @param {Comment} comment The `/*globals` directive comment which include the name. - * @param {string} name The name to find. - * @returns {SourceLocation} The `loc` object. - */ - getNameLocationInGlobalDirectiveComment(sourceCode, comment, name) { - const namePattern = new RegExp(`[\\s,]${escapeRegExp(name)}(?:$|[\\s,:])`, "gu"); - - // To ignore the first text "global". - namePattern.lastIndex = comment.value.indexOf("global") + 6; - - // Search a given variable name. - const match = namePattern.exec(comment.value); - - // Convert the index to loc. - const start = sourceCode.getLocFromIndex( - comment.range[0] + - "/*".length + - (match ? match.index + 1 : 0) - ); - const end = { - line: start.line, - column: start.column + (match ? name.length : 1) - }; - - return { start, end }; - }, - - /** - * Determines whether the given raw string contains an octal escape sequence - * or a non-octal decimal escape sequence ("\8", "\9"). - * - * "\1", "\2" ... "\7", "\8", "\9" - * "\00", "\01" ... "\07", "\08", "\09" - * - * "\0", when not followed by a digit, is not an octal escape sequence. - * @param {string} rawString A string in its raw representation. - * @returns {boolean} `true` if the string contains at least one octal escape sequence - * or at least one non-octal decimal escape sequence. - */ - hasOctalOrNonOctalDecimalEscapeSequence(rawString) { - return OCTAL_OR_NON_OCTAL_DECIMAL_ESCAPE_PATTERN.test(rawString); - }, - - /** - * Determines whether the given node is a template literal without expressions. - * @param {ASTNode} node Node to check. - * @returns {boolean} True if the node is a template literal without expressions. - */ - isStaticTemplateLiteral(node) { - return node.type === "TemplateLiteral" && node.expressions.length === 0; - }, - - isReferenceToGlobalVariable, - isLogicalExpression, - isCoalesceExpression, - isMixedLogicalAndCoalesceExpressions, - isNullLiteral, - getStaticStringValue, - getStaticPropertyName, - skipChainExpression, - isSpecificId, - isSpecificMemberAccess, - equalLiteralValue, - isSameReference, - isLogicalAssignmentOperator, - getSwitchCaseColonToken, - getModuleExportName, - isConstant, - isTopLevelExpressionStatement, - isDirective, - isStartOfExpressionStatement, - needsPrecedingSemicolon -}; diff --git a/tools/eslint/node_modules/eslint/lib/rules/utils/char-source.js b/tools/eslint/node_modules/eslint/lib/rules/utils/char-source.js deleted file mode 100644 index 70738625b94548..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/rules/utils/char-source.js +++ /dev/null @@ -1,240 +0,0 @@ -/** - * @fileoverview Utility functions to locate the source text of each code unit in the value of a string literal or template token. - * @author Francesco Trotta - */ - -"use strict"; - -/** - * Represents a code unit produced by the evaluation of a JavaScript common token like a string - * literal or template token. - */ -class CodeUnit { - constructor(start, source) { - this.start = start; - this.source = source; - } - - get end() { - return this.start + this.length; - } - - get length() { - return this.source.length; - } -} - -/** - * An object used to keep track of the position in a source text where the next characters will be read. - */ -class TextReader { - constructor(source) { - this.source = source; - this.pos = 0; - } - - /** - * Advances the reading position of the specified number of characters. - * @param {number} length Number of characters to advance. - * @returns {void} - */ - advance(length) { - this.pos += length; - } - - /** - * Reads characters from the source. - * @param {number} [offset=0] The offset where reading starts, relative to the current position. - * @param {number} [length=1] Number of characters to read. - * @returns {string} A substring of source characters. - */ - read(offset = 0, length = 1) { - const start = offset + this.pos; - - return this.source.slice(start, start + length); - } -} - -const SIMPLE_ESCAPE_SEQUENCES = -{ __proto__: null, b: "\b", f: "\f", n: "\n", r: "\r", t: "\t", v: "\v" }; - -/** - * Reads a hex escape sequence. - * @param {TextReader} reader The reader should be positioned on the first hexadecimal digit. - * @param {number} length The number of hexadecimal digits. - * @returns {string} A code unit. - */ -function readHexSequence(reader, length) { - const str = reader.read(0, length); - const charCode = parseInt(str, 16); - - reader.advance(length); - return String.fromCharCode(charCode); -} - -/** - * Reads a Unicode escape sequence. - * @param {TextReader} reader The reader should be positioned after the "u". - * @returns {string} A code unit. - */ -function readUnicodeSequence(reader) { - const regExp = /\{(?[\dA-Fa-f]+)\}/uy; - - regExp.lastIndex = reader.pos; - const match = regExp.exec(reader.source); - - if (match) { - const codePoint = parseInt(match.groups.hexDigits, 16); - - reader.pos = regExp.lastIndex; - return String.fromCodePoint(codePoint); - } - return readHexSequence(reader, 4); -} - -/** - * Reads an octal escape sequence. - * @param {TextReader} reader The reader should be positioned after the first octal digit. - * @param {number} maxLength The maximum number of octal digits. - * @returns {string} A code unit. - */ -function readOctalSequence(reader, maxLength) { - const [octalStr] = reader.read(-1, maxLength).match(/^[0-7]+/u); - - reader.advance(octalStr.length - 1); - const octal = parseInt(octalStr, 8); - - return String.fromCharCode(octal); -} - -/** - * Reads an escape sequence or line continuation. - * @param {TextReader} reader The reader should be positioned on the backslash. - * @returns {string} A string of zero, one or two code units. - */ -function readEscapeSequenceOrLineContinuation(reader) { - const char = reader.read(1); - - reader.advance(2); - const unitChar = SIMPLE_ESCAPE_SEQUENCES[char]; - - if (unitChar) { - return unitChar; - } - switch (char) { - case "x": - return readHexSequence(reader, 2); - case "u": - return readUnicodeSequence(reader); - case "\r": - if (reader.read() === "\n") { - reader.advance(1); - } - - // fallthrough - case "\n": - case "\u2028": - case "\u2029": - return ""; - case "0": - case "1": - case "2": - case "3": - return readOctalSequence(reader, 3); - case "4": - case "5": - case "6": - case "7": - return readOctalSequence(reader, 2); - default: - return char; - } -} - -/** - * Reads an escape sequence or line continuation and generates the respective `CodeUnit` elements. - * @param {TextReader} reader The reader should be positioned on the backslash. - * @returns {Generator} Zero, one or two `CodeUnit` elements. - */ -function *mapEscapeSequenceOrLineContinuation(reader) { - const start = reader.pos; - const str = readEscapeSequenceOrLineContinuation(reader); - const end = reader.pos; - const source = reader.source.slice(start, end); - - switch (str.length) { - case 0: - break; - case 1: - yield new CodeUnit(start, source); - break; - default: - yield new CodeUnit(start, source); - yield new CodeUnit(start, source); - break; - } -} - -/** - * Parses a string literal. - * @param {string} source The string literal to parse, including the delimiting quotes. - * @returns {CodeUnit[]} A list of code units produced by the string literal. - */ -function parseStringLiteral(source) { - const reader = new TextReader(source); - const quote = reader.read(); - - reader.advance(1); - const codeUnits = []; - - for (;;) { - const char = reader.read(); - - if (char === quote) { - break; - } - if (char === "\\") { - codeUnits.push(...mapEscapeSequenceOrLineContinuation(reader)); - } else { - codeUnits.push(new CodeUnit(reader.pos, char)); - reader.advance(1); - } - } - return codeUnits; -} - -/** - * Parses a template token. - * @param {string} source The template token to parse, including the delimiting sequences `` ` ``, `${` and `}`. - * @returns {CodeUnit[]} A list of code units produced by the template token. - */ -function parseTemplateToken(source) { - const reader = new TextReader(source); - - reader.advance(1); - const codeUnits = []; - - for (;;) { - const char = reader.read(); - - if (char === "`" || char === "$" && reader.read(1) === "{") { - break; - } - if (char === "\\") { - codeUnits.push(...mapEscapeSequenceOrLineContinuation(reader)); - } else { - let unitSource; - - if (char === "\r" && reader.read(1) === "\n") { - unitSource = "\r\n"; - } else { - unitSource = char; - } - codeUnits.push(new CodeUnit(reader.pos, unitSource)); - reader.advance(unitSource.length); - } - } - return codeUnits; -} - -module.exports = { parseStringLiteral, parseTemplateToken }; diff --git a/tools/eslint/node_modules/eslint/lib/rules/utils/fix-tracker.js b/tools/eslint/node_modules/eslint/lib/rules/utils/fix-tracker.js deleted file mode 100644 index 589870b39b5215..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/rules/utils/fix-tracker.js +++ /dev/null @@ -1,114 +0,0 @@ -/** - * @fileoverview Helper class to aid in constructing fix commands. - * @author Alan Pierce - */ -"use strict"; - -//------------------------------------------------------------------------------ -// Requirements -//------------------------------------------------------------------------------ - -const astUtils = require("./ast-utils"); - -//------------------------------------------------------------------------------ -// Public Interface -//------------------------------------------------------------------------------ - -/** - * A helper class to combine fix options into a fix command. Currently, it - * exposes some "retain" methods that extend the range of the text being - * replaced so that other fixes won't touch that region in the same pass. - */ -class FixTracker { - - /** - * Create a new FixTracker. - * @param {ruleFixer} fixer A ruleFixer instance. - * @param {SourceCode} sourceCode A SourceCode object for the current code. - */ - constructor(fixer, sourceCode) { - this.fixer = fixer; - this.sourceCode = sourceCode; - this.retainedRange = null; - } - - /** - * Mark the given range as "retained", meaning that other fixes may not - * may not modify this region in the same pass. - * @param {int[]} range The range to retain. - * @returns {FixTracker} The same RuleFixer, for chained calls. - */ - retainRange(range) { - this.retainedRange = range; - return this; - } - - /** - * Given a node, find the function containing it (or the entire program) and - * mark it as retained, meaning that other fixes may not modify it in this - * pass. This is useful for avoiding conflicts in fixes that modify control - * flow. - * @param {ASTNode} node The node to use as a starting point. - * @returns {FixTracker} The same RuleFixer, for chained calls. - */ - retainEnclosingFunction(node) { - const functionNode = astUtils.getUpperFunction(node); - - return this.retainRange(functionNode ? functionNode.range : this.sourceCode.ast.range); - } - - /** - * Given a node or token, find the token before and afterward, and mark that - * range as retained, meaning that other fixes may not modify it in this - * pass. This is useful for avoiding conflicts in fixes that make a small - * change to the code where the AST should not be changed. - * @param {ASTNode|Token} nodeOrToken The node or token to use as a starting - * point. The token to the left and right are use in the range. - * @returns {FixTracker} The same RuleFixer, for chained calls. - */ - retainSurroundingTokens(nodeOrToken) { - const tokenBefore = this.sourceCode.getTokenBefore(nodeOrToken) || nodeOrToken; - const tokenAfter = this.sourceCode.getTokenAfter(nodeOrToken) || nodeOrToken; - - return this.retainRange([tokenBefore.range[0], tokenAfter.range[1]]); - } - - /** - * Create a fix command that replaces the given range with the given text, - * accounting for any retained ranges. - * @param {int[]} range The range to remove in the fix. - * @param {string} text The text to insert in place of the range. - * @returns {Object} The fix command. - */ - replaceTextRange(range, text) { - let actualRange; - - if (this.retainedRange) { - actualRange = [ - Math.min(this.retainedRange[0], range[0]), - Math.max(this.retainedRange[1], range[1]) - ]; - } else { - actualRange = range; - } - - return this.fixer.replaceTextRange( - actualRange, - this.sourceCode.text.slice(actualRange[0], range[0]) + - text + - this.sourceCode.text.slice(range[1], actualRange[1]) - ); - } - - /** - * Create a fix command that removes the given node or token, accounting for - * any retained ranges. - * @param {ASTNode|Token} nodeOrToken The node or token to remove. - * @returns {Object} The fix command. - */ - remove(nodeOrToken) { - return this.replaceTextRange(nodeOrToken.range, ""); - } -} - -module.exports = FixTracker; diff --git a/tools/eslint/node_modules/eslint/lib/rules/utils/keywords.js b/tools/eslint/node_modules/eslint/lib/rules/utils/keywords.js deleted file mode 100644 index 3fbb77771df5c9..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/rules/utils/keywords.js +++ /dev/null @@ -1,67 +0,0 @@ -/** - * @fileoverview A shared list of ES3 keywords. - * @author Josh Perez - */ -"use strict"; - -module.exports = [ - "abstract", - "boolean", - "break", - "byte", - "case", - "catch", - "char", - "class", - "const", - "continue", - "debugger", - "default", - "delete", - "do", - "double", - "else", - "enum", - "export", - "extends", - "false", - "final", - "finally", - "float", - "for", - "function", - "goto", - "if", - "implements", - "import", - "in", - "instanceof", - "int", - "interface", - "long", - "native", - "new", - "null", - "package", - "private", - "protected", - "public", - "return", - "short", - "static", - "super", - "switch", - "synchronized", - "this", - "throw", - "throws", - "transient", - "true", - "try", - "typeof", - "var", - "void", - "volatile", - "while", - "with" -]; diff --git a/tools/eslint/node_modules/eslint/lib/rules/utils/lazy-loading-rule-map.js b/tools/eslint/node_modules/eslint/lib/rules/utils/lazy-loading-rule-map.js deleted file mode 100644 index 3fa5d83b0e8309..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/rules/utils/lazy-loading-rule-map.js +++ /dev/null @@ -1,115 +0,0 @@ -/** - * @fileoverview `Map` to load rules lazily. - * @author Toru Nagashima - */ -"use strict"; - -const debug = require("debug")("eslint:rules"); - -/** @typedef {import("../../shared/types").Rule} Rule */ - -/** - * The `Map` object that loads each rule when it's accessed. - * @example - * const rules = new LazyLoadingRuleMap([ - * ["eqeqeq", () => require("eqeqeq")], - * ["semi", () => require("semi")], - * ["no-unused-vars", () => require("no-unused-vars")] - * ]); - * - * rules.get("semi"); // call `() => require("semi")` here. - * - * @extends {Map Rule>} - */ -class LazyLoadingRuleMap extends Map { - - /** - * Initialize this map. - * @param {Array<[string, function(): Rule]>} loaders The rule loaders. - */ - constructor(loaders) { - let remaining = loaders.length; - - super( - debug.enabled - ? loaders.map(([ruleId, load]) => { - let cache = null; - - return [ - ruleId, - () => { - if (!cache) { - debug("Loading rule %o (remaining=%d)", ruleId, --remaining); - cache = load(); - } - return cache; - } - ]; - }) - : loaders - ); - - // `super(...iterable)` uses `this.set()`, so disable it here. - Object.defineProperty(LazyLoadingRuleMap.prototype, "set", { - configurable: true, - value: void 0 - }); - } - - /** - * Get a rule. - * Each rule will be loaded on the first access. - * @param {string} ruleId The rule ID to get. - * @returns {Rule|undefined} The rule. - */ - get(ruleId) { - const load = super.get(ruleId); - - return load && load(); - } - - /** - * Iterate rules. - * @returns {IterableIterator} Rules. - */ - *values() { - for (const load of super.values()) { - yield load(); - } - } - - /** - * Iterate rules. - * @returns {IterableIterator<[string, Rule]>} Rules. - */ - *entries() { - for (const [ruleId, load] of super.entries()) { - yield [ruleId, load()]; - } - } - - /** - * Call a function with each rule. - * @param {Function} callbackFn The callback function. - * @param {any} [thisArg] The object to pass to `this` of the callback function. - * @returns {void} - */ - forEach(callbackFn, thisArg) { - for (const [ruleId, load] of super.entries()) { - callbackFn.call(thisArg, load(), ruleId, this); - } - } -} - -// Forbid mutation. -Object.defineProperties(LazyLoadingRuleMap.prototype, { - clear: { configurable: true, value: void 0 }, - delete: { configurable: true, value: void 0 }, - [Symbol.iterator]: { - configurable: true, - writable: true, - value: LazyLoadingRuleMap.prototype.entries - } -}); - -module.exports = { LazyLoadingRuleMap }; diff --git a/tools/eslint/node_modules/eslint/lib/rules/utils/regular-expressions.js b/tools/eslint/node_modules/eslint/lib/rules/utils/regular-expressions.js deleted file mode 100644 index 90fb3a9a405d57..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/rules/utils/regular-expressions.js +++ /dev/null @@ -1,42 +0,0 @@ -/** - * @fileoverview Common utils for regular expressions. - * @author Josh Goldberg - * @author Toru Nagashima - */ - -"use strict"; - -const { RegExpValidator } = require("@eslint-community/regexpp"); - -const REGEXPP_LATEST_ECMA_VERSION = 2025; - -/** - * Checks if the given regular expression pattern would be valid with the `u` flag. - * @param {number} ecmaVersion ECMAScript version to parse in. - * @param {string} pattern The regular expression pattern to verify. - * @returns {boolean} `true` if the pattern would be valid with the `u` flag. - * `false` if the pattern would be invalid with the `u` flag or the configured - * ecmaVersion doesn't support the `u` flag. - */ -function isValidWithUnicodeFlag(ecmaVersion, pattern) { - if (ecmaVersion <= 5) { // ecmaVersion <= 5 doesn't support the 'u' flag - return false; - } - - const validator = new RegExpValidator({ - ecmaVersion: Math.min(ecmaVersion, REGEXPP_LATEST_ECMA_VERSION) - }); - - try { - validator.validatePattern(pattern, void 0, void 0, { unicode: /* uFlag = */ true }); - } catch { - return false; - } - - return true; -} - -module.exports = { - isValidWithUnicodeFlag, - REGEXPP_LATEST_ECMA_VERSION -}; diff --git a/tools/eslint/node_modules/eslint/lib/rules/utils/unicode/index.js b/tools/eslint/node_modules/eslint/lib/rules/utils/unicode/index.js deleted file mode 100644 index d35d812e1e97f0..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/rules/utils/unicode/index.js +++ /dev/null @@ -1,16 +0,0 @@ -/** - * @author Toru Nagashima - */ -"use strict"; - -const isCombiningCharacter = require("./is-combining-character"); -const isEmojiModifier = require("./is-emoji-modifier"); -const isRegionalIndicatorSymbol = require("./is-regional-indicator-symbol"); -const isSurrogatePair = require("./is-surrogate-pair"); - -module.exports = { - isCombiningCharacter, - isEmojiModifier, - isRegionalIndicatorSymbol, - isSurrogatePair -}; diff --git a/tools/eslint/node_modules/eslint/lib/rules/utils/unicode/is-combining-character.js b/tools/eslint/node_modules/eslint/lib/rules/utils/unicode/is-combining-character.js deleted file mode 100644 index 0498b99a21ed45..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/rules/utils/unicode/is-combining-character.js +++ /dev/null @@ -1,13 +0,0 @@ -/** - * @author Toru Nagashima - */ -"use strict"; - -/** - * Check whether a given character is a combining mark or not. - * @param {number} codePoint The character code to check. - * @returns {boolean} `true` if the character belongs to the category, any of `Mc`, `Me`, and `Mn`. - */ -module.exports = function isCombiningCharacter(codePoint) { - return /^[\p{Mc}\p{Me}\p{Mn}]$/u.test(String.fromCodePoint(codePoint)); -}; diff --git a/tools/eslint/node_modules/eslint/lib/rules/utils/unicode/is-emoji-modifier.js b/tools/eslint/node_modules/eslint/lib/rules/utils/unicode/is-emoji-modifier.js deleted file mode 100644 index 1bd5f557dcc4ab..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/rules/utils/unicode/is-emoji-modifier.js +++ /dev/null @@ -1,13 +0,0 @@ -/** - * @author Toru Nagashima - */ -"use strict"; - -/** - * Check whether a given character is an emoji modifier. - * @param {number} code The character code to check. - * @returns {boolean} `true` if the character is an emoji modifier. - */ -module.exports = function isEmojiModifier(code) { - return code >= 0x1F3FB && code <= 0x1F3FF; -}; diff --git a/tools/eslint/node_modules/eslint/lib/rules/utils/unicode/is-regional-indicator-symbol.js b/tools/eslint/node_modules/eslint/lib/rules/utils/unicode/is-regional-indicator-symbol.js deleted file mode 100644 index c48ed46ef8fded..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/rules/utils/unicode/is-regional-indicator-symbol.js +++ /dev/null @@ -1,13 +0,0 @@ -/** - * @author Toru Nagashima - */ -"use strict"; - -/** - * Check whether a given character is a regional indicator symbol. - * @param {number} code The character code to check. - * @returns {boolean} `true` if the character is a regional indicator symbol. - */ -module.exports = function isRegionalIndicatorSymbol(code) { - return code >= 0x1F1E6 && code <= 0x1F1FF; -}; diff --git a/tools/eslint/node_modules/eslint/lib/rules/utils/unicode/is-surrogate-pair.js b/tools/eslint/node_modules/eslint/lib/rules/utils/unicode/is-surrogate-pair.js deleted file mode 100644 index b8e5c1cacdb6a9..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/rules/utils/unicode/is-surrogate-pair.js +++ /dev/null @@ -1,14 +0,0 @@ -/** - * @author Toru Nagashima - */ -"use strict"; - -/** - * Check whether given two characters are a surrogate pair. - * @param {number} lead The code of the lead character. - * @param {number} tail The code of the tail character. - * @returns {boolean} `true` if the character pair is a surrogate pair. - */ -module.exports = function isSurrogatePair(lead, tail) { - return lead >= 0xD800 && lead < 0xDC00 && tail >= 0xDC00 && tail < 0xE000; -}; diff --git a/tools/eslint/node_modules/eslint/lib/rules/valid-typeof.js b/tools/eslint/node_modules/eslint/lib/rules/valid-typeof.js deleted file mode 100644 index 3818dafeae9fa2..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/rules/valid-typeof.js +++ /dev/null @@ -1,127 +0,0 @@ -/** - * @fileoverview Ensures that the results of typeof are compared against a valid string - * @author Ian Christian Myers - */ -"use strict"; - -//------------------------------------------------------------------------------ -// Requirements -//------------------------------------------------------------------------------ - -const astUtils = require("./utils/ast-utils"); - -//------------------------------------------------------------------------------ -// Rule Definition -//------------------------------------------------------------------------------ - -/** @type {import('../shared/types').Rule} */ -module.exports = { - meta: { - type: "problem", - - docs: { - description: "Enforce comparing `typeof` expressions against valid strings", - recommended: true, - url: "https://eslint.org/docs/latest/rules/valid-typeof" - }, - - hasSuggestions: true, - - schema: [ - { - type: "object", - properties: { - requireStringLiterals: { - type: "boolean", - default: false - } - }, - additionalProperties: false - } - ], - messages: { - invalidValue: "Invalid typeof comparison value.", - notString: "Typeof comparisons should be to string literals.", - suggestString: 'Use `"{{type}}"` instead of `{{type}}`.' - } - }, - - create(context) { - - const VALID_TYPES = new Set(["symbol", "undefined", "object", "boolean", "number", "string", "function", "bigint"]), - OPERATORS = new Set(["==", "===", "!=", "!=="]); - const sourceCode = context.sourceCode; - const requireStringLiterals = context.options[0] && context.options[0].requireStringLiterals; - - let globalScope; - - /** - * Checks whether the given node represents a reference to a global variable that is not declared in the source code. - * These identifiers will be allowed, as it is assumed that user has no control over the names of external global variables. - * @param {ASTNode} node `Identifier` node to check. - * @returns {boolean} `true` if the node is a reference to a global variable. - */ - function isReferenceToGlobalVariable(node) { - const variable = globalScope.set.get(node.name); - - return variable && variable.defs.length === 0 && - variable.references.some(ref => ref.identifier === node); - } - - /** - * Determines whether a node is a typeof expression. - * @param {ASTNode} node The node - * @returns {boolean} `true` if the node is a typeof expression - */ - function isTypeofExpression(node) { - return node.type === "UnaryExpression" && node.operator === "typeof"; - } - - //-------------------------------------------------------------------------- - // Public - //-------------------------------------------------------------------------- - - return { - - Program(node) { - globalScope = sourceCode.getScope(node); - }, - - UnaryExpression(node) { - if (isTypeofExpression(node)) { - const { parent } = node; - - if (parent.type === "BinaryExpression" && OPERATORS.has(parent.operator)) { - const sibling = parent.left === node ? parent.right : parent.left; - - if (sibling.type === "Literal" || astUtils.isStaticTemplateLiteral(sibling)) { - const value = sibling.type === "Literal" ? sibling.value : sibling.quasis[0].value.cooked; - - if (!VALID_TYPES.has(value)) { - context.report({ node: sibling, messageId: "invalidValue" }); - } - } else if (sibling.type === "Identifier" && sibling.name === "undefined" && isReferenceToGlobalVariable(sibling)) { - context.report({ - node: sibling, - messageId: requireStringLiterals ? "notString" : "invalidValue", - suggest: [ - { - messageId: "suggestString", - data: { type: "undefined" }, - fix(fixer) { - return fixer.replaceText(sibling, '"undefined"'); - } - } - ] - }); - } else if (requireStringLiterals && !isTypeofExpression(sibling)) { - context.report({ node: sibling, messageId: "notString" }); - } - } - } - } - - }; - - } -}; diff --git a/tools/eslint/node_modules/eslint/lib/rules/vars-on-top.js b/tools/eslint/node_modules/eslint/lib/rules/vars-on-top.js deleted file mode 100644 index 81f5d62d02d878..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/rules/vars-on-top.js +++ /dev/null @@ -1,157 +0,0 @@ -/** - * @fileoverview Rule to enforce var declarations are only at the top of a function. - * @author Danny Fritz - * @author Gyandeep Singh - */ -"use strict"; - -//------------------------------------------------------------------------------ -// Rule Definition -//------------------------------------------------------------------------------ - -/** @type {import('../shared/types').Rule} */ -module.exports = { - meta: { - type: "suggestion", - - docs: { - description: "Require `var` declarations be placed at the top of their containing scope", - recommended: false, - url: "https://eslint.org/docs/latest/rules/vars-on-top" - }, - - schema: [], - messages: { - top: "All 'var' declarations must be at the top of the function scope." - } - }, - - create(context) { - - //-------------------------------------------------------------------------- - // Helpers - //-------------------------------------------------------------------------- - - /** - * Has AST suggesting a directive. - * @param {ASTNode} node any node - * @returns {boolean} whether the given node structurally represents a directive - */ - function looksLikeDirective(node) { - return node.type === "ExpressionStatement" && - node.expression.type === "Literal" && typeof node.expression.value === "string"; - } - - /** - * Check to see if its a ES6 import declaration - * @param {ASTNode} node any node - * @returns {boolean} whether the given node represents a import declaration - */ - function looksLikeImport(node) { - return node.type === "ImportDeclaration" || node.type === "ImportSpecifier" || - node.type === "ImportDefaultSpecifier" || node.type === "ImportNamespaceSpecifier"; - } - - /** - * Checks whether a given node is a variable declaration or not. - * @param {ASTNode} node any node - * @returns {boolean} `true` if the node is a variable declaration. - */ - function isVariableDeclaration(node) { - return ( - node.type === "VariableDeclaration" || - ( - node.type === "ExportNamedDeclaration" && - node.declaration && - node.declaration.type === "VariableDeclaration" - ) - ); - } - - /** - * Checks whether this variable is on top of the block body - * @param {ASTNode} node The node to check - * @param {ASTNode[]} statements collection of ASTNodes for the parent node block - * @returns {boolean} True if var is on top otherwise false - */ - function isVarOnTop(node, statements) { - const l = statements.length; - let i = 0; - - // Skip over directives and imports. Static blocks don't have either. - if (node.parent.type !== "StaticBlock") { - for (; i < l; ++i) { - if (!looksLikeDirective(statements[i]) && !looksLikeImport(statements[i])) { - break; - } - } - } - - for (; i < l; ++i) { - if (!isVariableDeclaration(statements[i])) { - return false; - } - if (statements[i] === node) { - return true; - } - } - - return false; - } - - /** - * Checks whether variable is on top at the global level - * @param {ASTNode} node The node to check - * @param {ASTNode} parent Parent of the node - * @returns {void} - */ - function globalVarCheck(node, parent) { - if (!isVarOnTop(node, parent.body)) { - context.report({ node, messageId: "top" }); - } - } - - /** - * Checks whether variable is on top at functional block scope level - * @param {ASTNode} node The node to check - * @returns {void} - */ - function blockScopeVarCheck(node) { - const { parent } = node; - - if ( - parent.type === "BlockStatement" && - /Function/u.test(parent.parent.type) && - isVarOnTop(node, parent.body) - ) { - return; - } - - if ( - parent.type === "StaticBlock" && - isVarOnTop(node, parent.body) - ) { - return; - } - - context.report({ node, messageId: "top" }); - } - - //-------------------------------------------------------------------------- - // Public API - //-------------------------------------------------------------------------- - - return { - "VariableDeclaration[kind='var']"(node) { - if (node.parent.type === "ExportNamedDeclaration") { - globalVarCheck(node.parent, node.parent.parent); - } else if (node.parent.type === "Program") { - globalVarCheck(node, node.parent); - } else { - blockScopeVarCheck(node); - } - } - }; - - } -}; diff --git a/tools/eslint/node_modules/eslint/lib/rules/wrap-iife.js b/tools/eslint/node_modules/eslint/lib/rules/wrap-iife.js deleted file mode 100644 index 518071067db13e..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/rules/wrap-iife.js +++ /dev/null @@ -1,207 +0,0 @@ -/** - * @fileoverview Rule to flag when IIFE is not wrapped in parens - * @author Ilya Volodin - * @deprecated in ESLint v8.53.0 - */ - -"use strict"; - -//------------------------------------------------------------------------------ -// Requirements -//------------------------------------------------------------------------------ - -const astUtils = require("./utils/ast-utils"); -const eslintUtils = require("@eslint-community/eslint-utils"); - -//---------------------------------------------------------------------- -// Helpers -//---------------------------------------------------------------------- - -/** - * Check if the given node is callee of a `NewExpression` node - * @param {ASTNode} node node to check - * @returns {boolean} True if the node is callee of a `NewExpression` node - * @private - */ -function isCalleeOfNewExpression(node) { - const maybeCallee = node.parent.type === "ChainExpression" - ? node.parent - : node; - - return ( - maybeCallee.parent.type === "NewExpression" && - maybeCallee.parent.callee === maybeCallee - ); -} - -//------------------------------------------------------------------------------ -// Rule Definition -//------------------------------------------------------------------------------ - -/** @type {import('../shared/types').Rule} */ -module.exports = { - meta: { - deprecated: true, - replacedBy: [], - type: "layout", - - docs: { - description: "Require parentheses around immediate `function` invocations", - recommended: false, - url: "https://eslint.org/docs/latest/rules/wrap-iife" - }, - - schema: [ - { - enum: ["outside", "inside", "any"] - }, - { - type: "object", - properties: { - functionPrototypeMethods: { - type: "boolean", - default: false - } - }, - additionalProperties: false - } - ], - - fixable: "code", - messages: { - wrapInvocation: "Wrap an immediate function invocation in parentheses.", - wrapExpression: "Wrap only the function expression in parens.", - moveInvocation: "Move the invocation into the parens that contain the function." - } - }, - - create(context) { - - const style = context.options[0] || "outside"; - const includeFunctionPrototypeMethods = context.options[1] && context.options[1].functionPrototypeMethods; - - const sourceCode = context.sourceCode; - - /** - * Check if the node is wrapped in any (). All parens count: grouping parens and parens for constructs such as if() - * @param {ASTNode} node node to evaluate - * @returns {boolean} True if it is wrapped in any parens - * @private - */ - function isWrappedInAnyParens(node) { - return astUtils.isParenthesised(sourceCode, node); - } - - /** - * Check if the node is wrapped in grouping (). Parens for constructs such as if() don't count - * @param {ASTNode} node node to evaluate - * @returns {boolean} True if it is wrapped in grouping parens - * @private - */ - function isWrappedInGroupingParens(node) { - return eslintUtils.isParenthesized(1, node, sourceCode); - } - - /** - * Get the function node from an IIFE - * @param {ASTNode} node node to evaluate - * @returns {ASTNode} node that is the function expression of the given IIFE, or null if none exist - */ - function getFunctionNodeFromIIFE(node) { - const callee = astUtils.skipChainExpression(node.callee); - - if (callee.type === "FunctionExpression") { - return callee; - } - - if (includeFunctionPrototypeMethods && - callee.type === "MemberExpression" && - callee.object.type === "FunctionExpression" && - (astUtils.getStaticPropertyName(callee) === "call" || astUtils.getStaticPropertyName(callee) === "apply") - ) { - return callee.object; - } - - return null; - } - - - return { - CallExpression(node) { - const innerNode = getFunctionNodeFromIIFE(node); - - if (!innerNode) { - return; - } - - const isCallExpressionWrapped = isWrappedInAnyParens(node), - isFunctionExpressionWrapped = isWrappedInAnyParens(innerNode); - - if (!isCallExpressionWrapped && !isFunctionExpressionWrapped) { - context.report({ - node, - messageId: "wrapInvocation", - fix(fixer) { - const nodeToSurround = style === "inside" ? innerNode : node; - - return fixer.replaceText(nodeToSurround, `(${sourceCode.getText(nodeToSurround)})`); - } - }); - } else if (style === "inside" && !isFunctionExpressionWrapped) { - context.report({ - node, - messageId: "wrapExpression", - fix(fixer) { - - // The outer call expression will always be wrapped at this point. - - if (isWrappedInGroupingParens(node) && !isCalleeOfNewExpression(node)) { - - /* - * Parenthesize the function expression and remove unnecessary grouping parens around the call expression. - * Replace the range between the end of the function expression and the end of the call expression. - * for example, in `(function(foo) {}(bar))`, the range `(bar))` should get replaced with `)(bar)`. - */ - - const parenAfter = sourceCode.getTokenAfter(node); - - return fixer.replaceTextRange( - [innerNode.range[1], parenAfter.range[1]], - `)${sourceCode.getText().slice(innerNode.range[1], parenAfter.range[0])}` - ); - } - - /* - * Call expression is wrapped in mandatory parens such as if(), or in necessary grouping parens. - * These parens cannot be removed, so just parenthesize the function expression. - */ - - return fixer.replaceText(innerNode, `(${sourceCode.getText(innerNode)})`); - } - }); - } else if (style === "outside" && !isCallExpressionWrapped) { - context.report({ - node, - messageId: "moveInvocation", - fix(fixer) { - - /* - * The inner function expression will always be wrapped at this point. - * It's only necessary to replace the range between the end of the function expression - * and the call expression. For example, in `(function(foo) {})(bar)`, the range `)(bar)` - * should get replaced with `(bar))`. - */ - const parenAfter = sourceCode.getTokenAfter(innerNode); - - return fixer.replaceTextRange( - [parenAfter.range[0], node.range[1]], - `${sourceCode.getText().slice(parenAfter.range[1], node.range[1])})` - ); - } - }); - } - } - }; - - } -}; diff --git a/tools/eslint/node_modules/eslint/lib/rules/wrap-regex.js b/tools/eslint/node_modules/eslint/lib/rules/wrap-regex.js deleted file mode 100644 index 9e2808d60c7023..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/rules/wrap-regex.js +++ /dev/null @@ -1,61 +0,0 @@ -/** - * @fileoverview Rule to flag when regex literals are not wrapped in parens - * @author Matt DuVall - * @deprecated in ESLint v8.53.0 - */ - -"use strict"; - -//------------------------------------------------------------------------------ -// Rule Definition -//------------------------------------------------------------------------------ - -/** @type {import('../shared/types').Rule} */ -module.exports = { - meta: { - deprecated: true, - replacedBy: [], - type: "layout", - - docs: { - description: "Require parenthesis around regex literals", - recommended: false, - url: "https://eslint.org/docs/latest/rules/wrap-regex" - }, - - schema: [], - fixable: "code", - - messages: { - requireParens: "Wrap the regexp literal in parens to disambiguate the slash." - } - }, - - create(context) { - const sourceCode = context.sourceCode; - - return { - - Literal(node) { - const token = sourceCode.getFirstToken(node), - nodeType = token.type; - - if (nodeType === "RegularExpression") { - const beforeToken = sourceCode.getTokenBefore(node); - const afterToken = sourceCode.getTokenAfter(node); - const { parent } = node; - - if (parent.type === "MemberExpression" && parent.object === node && - !(beforeToken && beforeToken.value === "(" && afterToken && afterToken.value === ")")) { - context.report({ - node, - messageId: "requireParens", - fix: fixer => fixer.replaceText(node, `(${sourceCode.getText(node)})`) - }); - } - } - } - }; - - } -}; diff --git a/tools/eslint/node_modules/eslint/lib/rules/yield-star-spacing.js b/tools/eslint/node_modules/eslint/lib/rules/yield-star-spacing.js deleted file mode 100644 index 5cf3804abb835e..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/rules/yield-star-spacing.js +++ /dev/null @@ -1,130 +0,0 @@ -/** - * @fileoverview Rule to check the spacing around the * in yield* expressions. - * @author Bryan Smith - * @deprecated in ESLint v8.53.0 - */ - -"use strict"; - -//------------------------------------------------------------------------------ -// Rule Definition -//------------------------------------------------------------------------------ - -/** @type {import('../shared/types').Rule} */ -module.exports = { - meta: { - deprecated: true, - replacedBy: [], - type: "layout", - - docs: { - description: "Require or disallow spacing around the `*` in `yield*` expressions", - recommended: false, - url: "https://eslint.org/docs/latest/rules/yield-star-spacing" - }, - - fixable: "whitespace", - - schema: [ - { - oneOf: [ - { - enum: ["before", "after", "both", "neither"] - }, - { - type: "object", - properties: { - before: { type: "boolean" }, - after: { type: "boolean" } - }, - additionalProperties: false - } - ] - } - ], - messages: { - missingBefore: "Missing space before *.", - missingAfter: "Missing space after *.", - unexpectedBefore: "Unexpected space before *.", - unexpectedAfter: "Unexpected space after *." - } - }, - - create(context) { - const sourceCode = context.sourceCode; - - const mode = (function(option) { - if (!option || typeof option === "string") { - return { - before: { before: true, after: false }, - after: { before: false, after: true }, - both: { before: true, after: true }, - neither: { before: false, after: false } - }[option || "after"]; - } - return option; - }(context.options[0])); - - /** - * Checks the spacing between two tokens before or after the star token. - * @param {string} side Either "before" or "after". - * @param {Token} leftToken `function` keyword token if side is "before", or - * star token if side is "after". - * @param {Token} rightToken Star token if side is "before", or identifier - * token if side is "after". - * @returns {void} - */ - function checkSpacing(side, leftToken, rightToken) { - if (sourceCode.isSpaceBetweenTokens(leftToken, rightToken) !== mode[side]) { - const after = leftToken.value === "*"; - const spaceRequired = mode[side]; - const node = after ? leftToken : rightToken; - let messageId; - - if (spaceRequired) { - messageId = side === "before" ? "missingBefore" : "missingAfter"; - } else { - messageId = side === "before" ? "unexpectedBefore" : "unexpectedAfter"; - } - - context.report({ - node, - messageId, - fix(fixer) { - if (spaceRequired) { - if (after) { - return fixer.insertTextAfter(node, " "); - } - return fixer.insertTextBefore(node, " "); - } - return fixer.removeRange([leftToken.range[1], rightToken.range[0]]); - } - }); - } - } - - /** - * Enforces the spacing around the star if node is a yield* expression. - * @param {ASTNode} node A yield expression node. - * @returns {void} - */ - function checkExpression(node) { - if (!node.delegate) { - return; - } - - const tokens = sourceCode.getFirstTokens(node, 3); - const yieldToken = tokens[0]; - const starToken = tokens[1]; - const nextToken = tokens[2]; - - checkSpacing("before", yieldToken, starToken); - checkSpacing("after", starToken, nextToken); - } - - return { - YieldExpression: checkExpression - }; - - } -}; diff --git a/tools/eslint/node_modules/eslint/lib/rules/yoda.js b/tools/eslint/node_modules/eslint/lib/rules/yoda.js deleted file mode 100644 index af8f525182eda0..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/rules/yoda.js +++ /dev/null @@ -1,353 +0,0 @@ -/** - * @fileoverview Rule to require or disallow yoda comparisons - * @author Nicholas C. Zakas - */ -"use strict"; - -//-------------------------------------------------------------------------- -// Requirements -//-------------------------------------------------------------------------- - -const astUtils = require("./utils/ast-utils"); - -//-------------------------------------------------------------------------- -// Helpers -//-------------------------------------------------------------------------- - -/** - * Determines whether an operator is a comparison operator. - * @param {string} operator The operator to check. - * @returns {boolean} Whether or not it is a comparison operator. - */ -function isComparisonOperator(operator) { - return /^(==|===|!=|!==|<|>|<=|>=)$/u.test(operator); -} - -/** - * Determines whether an operator is an equality operator. - * @param {string} operator The operator to check. - * @returns {boolean} Whether or not it is an equality operator. - */ -function isEqualityOperator(operator) { - return /^(==|===)$/u.test(operator); -} - -/** - * Determines whether an operator is one used in a range test. - * Allowed operators are `<` and `<=`. - * @param {string} operator The operator to check. - * @returns {boolean} Whether the operator is used in range tests. - */ -function isRangeTestOperator(operator) { - return ["<", "<="].includes(operator); -} - -/** - * Determines whether a non-Literal node is a negative number that should be - * treated as if it were a single Literal node. - * @param {ASTNode} node Node to test. - * @returns {boolean} True if the node is a negative number that looks like a - * real literal and should be treated as such. - */ -function isNegativeNumericLiteral(node) { - return ( - node.type === "UnaryExpression" && - node.operator === "-" && - node.prefix && - astUtils.isNumericLiteral(node.argument) - ); -} - -/** - * Determines whether a non-Literal node should be treated as a single Literal node. - * @param {ASTNode} node Node to test - * @returns {boolean} True if the node should be treated as a single Literal node. - */ -function looksLikeLiteral(node) { - return isNegativeNumericLiteral(node) || astUtils.isStaticTemplateLiteral(node); -} - -/** - * Attempts to derive a Literal node from nodes that are treated like literals. - * @param {ASTNode} node Node to normalize. - * @returns {ASTNode} One of the following options. - * 1. The original node if the node is already a Literal - * 2. A normalized Literal node with the negative number as the value if the - * node represents a negative number literal. - * 3. A normalized Literal node with the string as the value if the node is - * a Template Literal without expression. - * 4. Otherwise `null`. - */ -function getNormalizedLiteral(node) { - if (node.type === "Literal") { - return node; - } - - if (isNegativeNumericLiteral(node)) { - return { - type: "Literal", - value: -node.argument.value, - raw: `-${node.argument.value}` - }; - } - - if (astUtils.isStaticTemplateLiteral(node)) { - return { - type: "Literal", - value: node.quasis[0].value.cooked, - raw: node.quasis[0].value.raw - }; - } - - return null; -} - -//------------------------------------------------------------------------------ -// Rule Definition -//------------------------------------------------------------------------------ - -/** @type {import('../shared/types').Rule} */ -module.exports = { - meta: { - type: "suggestion", - - docs: { - description: 'Require or disallow "Yoda" conditions', - recommended: false, - url: "https://eslint.org/docs/latest/rules/yoda" - }, - - schema: [ - { - enum: ["always", "never"] - }, - { - type: "object", - properties: { - exceptRange: { - type: "boolean", - default: false - }, - onlyEquality: { - type: "boolean", - default: false - } - }, - additionalProperties: false - } - ], - - fixable: "code", - messages: { - expected: - "Expected literal to be on the {{expectedSide}} side of {{operator}}." - } - }, - - create(context) { - - // Default to "never" (!always) if no option - const always = context.options[0] === "always"; - const exceptRange = - context.options[1] && context.options[1].exceptRange; - const onlyEquality = - context.options[1] && context.options[1].onlyEquality; - - const sourceCode = context.sourceCode; - - /** - * Determines whether node represents a range test. - * A range test is a "between" test like `(0 <= x && x < 1)` or an "outside" - * test like `(x < 0 || 1 <= x)`. It must be wrapped in parentheses, and - * both operators must be `<` or `<=`. Finally, the literal on the left side - * must be less than or equal to the literal on the right side so that the - * test makes any sense. - * @param {ASTNode} node LogicalExpression node to test. - * @returns {boolean} Whether node is a range test. - */ - function isRangeTest(node) { - const left = node.left, - right = node.right; - - /** - * Determines whether node is of the form `0 <= x && x < 1`. - * @returns {boolean} Whether node is a "between" range test. - */ - function isBetweenTest() { - if (node.operator === "&&" && astUtils.isSameReference(left.right, right.left)) { - const leftLiteral = getNormalizedLiteral(left.left); - const rightLiteral = getNormalizedLiteral(right.right); - - if (leftLiteral === null && rightLiteral === null) { - return false; - } - - if (rightLiteral === null || leftLiteral === null) { - return true; - } - - if (leftLiteral.value <= rightLiteral.value) { - return true; - } - } - return false; - } - - /** - * Determines whether node is of the form `x < 0 || 1 <= x`. - * @returns {boolean} Whether node is an "outside" range test. - */ - function isOutsideTest() { - if (node.operator === "||" && astUtils.isSameReference(left.left, right.right)) { - const leftLiteral = getNormalizedLiteral(left.right); - const rightLiteral = getNormalizedLiteral(right.left); - - if (leftLiteral === null && rightLiteral === null) { - return false; - } - - if (rightLiteral === null || leftLiteral === null) { - return true; - } - - if (leftLiteral.value <= rightLiteral.value) { - return true; - } - } - - return false; - } - - /** - * Determines whether node is wrapped in parentheses. - * @returns {boolean} Whether node is preceded immediately by an open - * paren token and followed immediately by a close - * paren token. - */ - function isParenWrapped() { - return astUtils.isParenthesised(sourceCode, node); - } - - return ( - node.type === "LogicalExpression" && - left.type === "BinaryExpression" && - right.type === "BinaryExpression" && - isRangeTestOperator(left.operator) && - isRangeTestOperator(right.operator) && - (isBetweenTest() || isOutsideTest()) && - isParenWrapped() - ); - } - - const OPERATOR_FLIP_MAP = { - "===": "===", - "!==": "!==", - "==": "==", - "!=": "!=", - "<": ">", - ">": "<", - "<=": ">=", - ">=": "<=" - }; - - /** - * Returns a string representation of a BinaryExpression node with its sides/operator flipped around. - * @param {ASTNode} node The BinaryExpression node - * @returns {string} A string representation of the node with the sides and operator flipped - */ - function getFlippedString(node) { - const operatorToken = sourceCode.getFirstTokenBetween( - node.left, - node.right, - token => token.value === node.operator - ); - const lastLeftToken = sourceCode.getTokenBefore(operatorToken); - const firstRightToken = sourceCode.getTokenAfter(operatorToken); - - const source = sourceCode.getText(); - - const leftText = source.slice( - node.range[0], - lastLeftToken.range[1] - ); - const textBeforeOperator = source.slice( - lastLeftToken.range[1], - operatorToken.range[0] - ); - const textAfterOperator = source.slice( - operatorToken.range[1], - firstRightToken.range[0] - ); - const rightText = source.slice( - firstRightToken.range[0], - node.range[1] - ); - - const tokenBefore = sourceCode.getTokenBefore(node); - const tokenAfter = sourceCode.getTokenAfter(node); - let prefix = ""; - let suffix = ""; - - if ( - tokenBefore && - tokenBefore.range[1] === node.range[0] && - !astUtils.canTokensBeAdjacent(tokenBefore, firstRightToken) - ) { - prefix = " "; - } - - if ( - tokenAfter && - node.range[1] === tokenAfter.range[0] && - !astUtils.canTokensBeAdjacent(lastLeftToken, tokenAfter) - ) { - suffix = " "; - } - - return ( - prefix + - rightText + - textBeforeOperator + - OPERATOR_FLIP_MAP[operatorToken.value] + - textAfterOperator + - leftText + - suffix - ); - } - - //-------------------------------------------------------------------------- - // Public - //-------------------------------------------------------------------------- - - return { - BinaryExpression(node) { - const expectedLiteral = always ? node.left : node.right; - const expectedNonLiteral = always ? node.right : node.left; - - // If `expectedLiteral` is not a literal, and `expectedNonLiteral` is a literal, raise an error. - if ( - (expectedNonLiteral.type === "Literal" || - looksLikeLiteral(expectedNonLiteral)) && - !( - expectedLiteral.type === "Literal" || - looksLikeLiteral(expectedLiteral) - ) && - !(!isEqualityOperator(node.operator) && onlyEquality) && - isComparisonOperator(node.operator) && - !(exceptRange && isRangeTest(node.parent)) - ) { - context.report({ - node, - messageId: "expected", - data: { - operator: node.operator, - expectedSide: always ? "left" : "right" - }, - fix: fixer => - fixer.replaceText(node, getFlippedString(node)) - }); - } - } - }; - } -}; diff --git a/tools/eslint/node_modules/eslint/lib/shared/ajv.js b/tools/eslint/node_modules/eslint/lib/shared/ajv.js deleted file mode 100644 index f4f6a62183d495..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/shared/ajv.js +++ /dev/null @@ -1,34 +0,0 @@ -/** - * @fileoverview The instance of Ajv validator. - * @author Evgeny Poberezkin - */ -"use strict"; - -//------------------------------------------------------------------------------ -// Requirements -//------------------------------------------------------------------------------ - -const Ajv = require("ajv"), - metaSchema = require("ajv/lib/refs/json-schema-draft-04.json"); - -//------------------------------------------------------------------------------ -// Public Interface -//------------------------------------------------------------------------------ - -module.exports = (additionalOptions = {}) => { - const ajv = new Ajv({ - meta: false, - useDefaults: true, - validateSchema: false, - missingRefs: "ignore", - verbose: true, - schemaId: "auto", - ...additionalOptions - }); - - ajv.addMetaSchema(metaSchema); - // eslint-disable-next-line no-underscore-dangle -- Ajv's API - ajv._opts.defaultMeta = metaSchema.id; - - return ajv; -}; diff --git a/tools/eslint/node_modules/eslint/lib/shared/ast-utils.js b/tools/eslint/node_modules/eslint/lib/shared/ast-utils.js deleted file mode 100644 index 4ebd49c3ce6a6b..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/shared/ast-utils.js +++ /dev/null @@ -1,29 +0,0 @@ -/** - * @fileoverview Common utils for AST. - * - * This file contains only shared items for core and rules. - * If you make a utility for rules, please see `../rules/utils/ast-utils.js`. - * - * @author Toru Nagashima - */ -"use strict"; - -const breakableTypePattern = /^(?:(?:Do)?While|For(?:In|Of)?|Switch)Statement$/u; -const lineBreakPattern = /\r\n|[\r\n\u2028\u2029]/u; -const shebangPattern = /^#!([^\r\n]+)/u; - -/** - * Creates a version of the `lineBreakPattern` regex with the global flag. - * Global regexes are mutable, so this needs to be a function instead of a constant. - * @returns {RegExp} A global regular expression that matches line terminators - */ -function createGlobalLinebreakMatcher() { - return new RegExp(lineBreakPattern.source, "gu"); -} - -module.exports = { - breakableTypePattern, - lineBreakPattern, - createGlobalLinebreakMatcher, - shebangPattern -}; diff --git a/tools/eslint/node_modules/eslint/lib/shared/directives.js b/tools/eslint/node_modules/eslint/lib/shared/directives.js deleted file mode 100644 index ff67b00a553e98..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/shared/directives.js +++ /dev/null @@ -1,15 +0,0 @@ -/** - * @fileoverview Common utils for directives. - * - * This file contains only shared items for directives. - * If you make a utility for rules, please see `../rules/utils/ast-utils.js`. - * - * @author gfyoung - */ -"use strict"; - -const directivesPattern = /^(eslint(?:-env|-enable|-disable(?:(?:-next)?-line)?)?|exported|globals?)(?:\s|$)/u; - -module.exports = { - directivesPattern -}; diff --git a/tools/eslint/node_modules/eslint/lib/shared/flags.js b/tools/eslint/node_modules/eslint/lib/shared/flags.js deleted file mode 100644 index 555f818e4871b0..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/shared/flags.js +++ /dev/null @@ -1,26 +0,0 @@ -/** - * @fileoverview Shared flags for ESLint. - */ - -"use strict"; - -/** - * The set of flags that change ESLint behavior with a description. - * @type {Map} - */ -const activeFlags = new Map([ - ["test_only", "This flag is only used for testing."] -]); - -/** - * The set of flags that used to be active but no longer have an effect. - * @type {Map} - */ -const inactiveFlags = new Map([ - ["test_only_old", "This flag is no longer used for testing."] -]); - -module.exports = { - activeFlags, - inactiveFlags -}; diff --git a/tools/eslint/node_modules/eslint/lib/shared/logging.js b/tools/eslint/node_modules/eslint/lib/shared/logging.js deleted file mode 100644 index 9310e586c23b61..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/shared/logging.js +++ /dev/null @@ -1,39 +0,0 @@ -/** - * @fileoverview Handle logging for ESLint - * @author Gyandeep Singh - */ - -"use strict"; - -/* eslint no-console: "off" -- Logging util */ - -/* c8 ignore next */ -module.exports = { - - /** - * Cover for console.info - * @param {...any} args The elements to log. - * @returns {void} - */ - info(...args) { - console.log(...args); - }, - - /** - * Cover for console.warn - * @param {...any} args The elements to log. - * @returns {void} - */ - warn(...args) { - console.warn(...args); - }, - - /** - * Cover for console.error - * @param {...any} args The elements to log. - * @returns {void} - */ - error(...args) { - console.error(...args); - } -}; diff --git a/tools/eslint/node_modules/eslint/lib/shared/runtime-info.js b/tools/eslint/node_modules/eslint/lib/shared/runtime-info.js deleted file mode 100644 index 29de6fc8d84028..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/shared/runtime-info.js +++ /dev/null @@ -1,168 +0,0 @@ -/** - * @fileoverview Utility to get information about the execution environment. - * @author Kai Cataldo - */ - -"use strict"; - -//------------------------------------------------------------------------------ -// Requirements -//------------------------------------------------------------------------------ - -const path = require("node:path"); -const spawn = require("cross-spawn"); -const os = require("node:os"); -const log = require("../shared/logging"); -const packageJson = require("../../package.json"); - -//------------------------------------------------------------------------------ -// Helpers -//------------------------------------------------------------------------------ - -/** - * Generates and returns execution environment information. - * @returns {string} A string that contains execution environment information. - */ -function environment() { - const cache = new Map(); - - /** - * Checks if a path is a child of a directory. - * @param {string} parentPath The parent path to check. - * @param {string} childPath The path to check. - * @returns {boolean} Whether or not the given path is a child of a directory. - */ - function isChildOfDirectory(parentPath, childPath) { - return !path.relative(parentPath, childPath).startsWith(".."); - } - - /** - * Synchronously executes a shell command and formats the result. - * @param {string} cmd The command to execute. - * @param {Array} args The arguments to be executed with the command. - * @throws {Error} As may be collected by `cross-spawn.sync`. - * @returns {string} The version returned by the command. - */ - function execCommand(cmd, args) { - const key = [cmd, ...args].join(" "); - - if (cache.has(key)) { - return cache.get(key); - } - - const process = spawn.sync(cmd, args, { encoding: "utf8" }); - - if (process.error) { - throw process.error; - } - - const result = process.stdout.trim(); - - cache.set(key, result); - return result; - } - - /** - * Normalizes a version number. - * @param {string} versionStr The string to normalize. - * @returns {string} The normalized version number. - */ - function normalizeVersionStr(versionStr) { - return versionStr.startsWith("v") ? versionStr : `v${versionStr}`; - } - - /** - * Gets bin version. - * @param {string} bin The bin to check. - * @throws {Error} As may be collected by `cross-spawn.sync`. - * @returns {string} The normalized version returned by the command. - */ - function getBinVersion(bin) { - const binArgs = ["--version"]; - - try { - return normalizeVersionStr(execCommand(bin, binArgs)); - } catch (e) { - log.error(`Error finding ${bin} version running the command \`${bin} ${binArgs.join(" ")}\``); - throw e; - } - } - - /** - * Gets installed npm package version. - * @param {string} pkg The package to check. - * @param {boolean} global Whether to check globally or not. - * @throws {Error} As may be collected by `cross-spawn.sync`. - * @returns {string} The normalized version returned by the command. - */ - function getNpmPackageVersion(pkg, { global = false } = {}) { - const npmBinArgs = ["bin", "-g"]; - const npmLsArgs = ["ls", "--depth=0", "--json", pkg]; - - if (global) { - npmLsArgs.push("-g"); - } - - try { - const parsedStdout = JSON.parse(execCommand("npm", npmLsArgs)); - - /* - * Checking globally returns an empty JSON object, while local checks - * include the name and version of the local project. - */ - if (Object.keys(parsedStdout).length === 0 || !(parsedStdout.dependencies && parsedStdout.dependencies.eslint)) { - return "Not found"; - } - - const [, processBinPath] = process.argv; - let npmBinPath; - - try { - npmBinPath = execCommand("npm", npmBinArgs); - } catch (e) { - log.error(`Error finding npm binary path when running command \`npm ${npmBinArgs.join(" ")}\``); - throw e; - } - - const isGlobal = isChildOfDirectory(npmBinPath, processBinPath); - let pkgVersion = parsedStdout.dependencies.eslint.version; - - if ((global && isGlobal) || (!global && !isGlobal)) { - pkgVersion += " (Currently used)"; - } - - return normalizeVersionStr(pkgVersion); - } catch (e) { - log.error(`Error finding ${pkg} version running the command \`npm ${npmLsArgs.join(" ")}\``); - throw e; - } - } - - return [ - "Environment Info:", - "", - `Node version: ${getBinVersion("node")}`, - `npm version: ${getBinVersion("npm")}`, - `Local ESLint version: ${getNpmPackageVersion("eslint", { global: false })}`, - `Global ESLint version: ${getNpmPackageVersion("eslint", { global: true })}`, - `Operating System: ${os.platform()} ${os.release()}` - ].join("\n"); -} - -/** - * Returns version of currently executing ESLint. - * @returns {string} The version from the currently executing ESLint's package.json. - */ -function version() { - return `v${packageJson.version}`; -} - -//------------------------------------------------------------------------------ -// Public Interface -//------------------------------------------------------------------------------ - -module.exports = { - __esModule: true, // Indicate intent for imports, remove ambiguity for Knip (see: https://github.com/eslint/eslint/pull/18005#discussion_r1484422616) - environment, - version -}; diff --git a/tools/eslint/node_modules/eslint/lib/shared/serialization.js b/tools/eslint/node_modules/eslint/lib/shared/serialization.js deleted file mode 100644 index 69f5710f2a306e..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/shared/serialization.js +++ /dev/null @@ -1,55 +0,0 @@ -/** - * @fileoverview Serialization utils. - * @author Bryan Mishkin - */ - -"use strict"; - -/** - * Check if a value is a primitive or plain object created by the Object constructor. - * @param {any} val the value to check - * @returns {boolean} true if so - * @private - */ -function isSerializablePrimitiveOrPlainObject(val) { - return ( - val === null || - typeof val === "string" || - typeof val === "boolean" || - typeof val === "number" || - (typeof val === "object" && val.constructor === Object) || - Array.isArray(val) - ); -} - -/** - * Check if a value is serializable. - * Functions or objects like RegExp cannot be serialized by JSON.stringify(). - * Inspired by: https://stackoverflow.com/questions/30579940/reliable-way-to-check-if-objects-is-serializable-in-javascript - * @param {any} val the value - * @returns {boolean} true if the value is serializable - */ -function isSerializable(val) { - if (!isSerializablePrimitiveOrPlainObject(val)) { - return false; - } - if (typeof val === "object") { - for (const property in val) { - if (Object.hasOwn(val, property)) { - if (!isSerializablePrimitiveOrPlainObject(val[property])) { - return false; - } - if (typeof val[property] === "object") { - if (!isSerializable(val[property])) { - return false; - } - } - } - } - } - return true; -} - -module.exports = { - isSerializable -}; diff --git a/tools/eslint/node_modules/eslint/lib/shared/severity.js b/tools/eslint/node_modules/eslint/lib/shared/severity.js deleted file mode 100644 index 6b21469a9aaff0..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/shared/severity.js +++ /dev/null @@ -1,49 +0,0 @@ -/** - * @fileoverview Helpers for severity values (e.g. normalizing different types). - * @author Bryan Mishkin - */ - -"use strict"; - -/** - * Convert severity value of different types to a string. - * @param {string|number} severity severity value - * @throws error if severity is invalid - * @returns {string} severity string - */ -function normalizeSeverityToString(severity) { - if ([2, "2", "error"].includes(severity)) { - return "error"; - } - if ([1, "1", "warn"].includes(severity)) { - return "warn"; - } - if ([0, "0", "off"].includes(severity)) { - return "off"; - } - throw new Error(`Invalid severity value: ${severity}`); -} - -/** - * Convert severity value of different types to a number. - * @param {string|number} severity severity value - * @throws error if severity is invalid - * @returns {number} severity number - */ -function normalizeSeverityToNumber(severity) { - if ([2, "2", "error"].includes(severity)) { - return 2; - } - if ([1, "1", "warn"].includes(severity)) { - return 1; - } - if ([0, "0", "off"].includes(severity)) { - return 0; - } - throw new Error(`Invalid severity value: ${severity}`); -} - -module.exports = { - normalizeSeverityToString, - normalizeSeverityToNumber -}; diff --git a/tools/eslint/node_modules/eslint/lib/shared/stats.js b/tools/eslint/node_modules/eslint/lib/shared/stats.js deleted file mode 100644 index c5d4d1885d415b..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/shared/stats.js +++ /dev/null @@ -1,30 +0,0 @@ -/** - * @fileoverview Provides helper functions to start/stop the time measurements - * that are provided by the ESLint 'stats' option. - * @author Mara Kiefer - */ -"use strict"; - -/** - * Start time measurement - * @returns {[number, number]} t variable for tracking time - */ -function startTime() { - return process.hrtime(); -} - -/** - * End time measurement - * @param {[number, number]} t Variable for tracking time - * @returns {number} The measured time in milliseconds - */ -function endTime(t) { - const time = process.hrtime(t); - - return time[0] * 1e3 + time[1] / 1e6; -} - -module.exports = { - startTime, - endTime -}; diff --git a/tools/eslint/node_modules/eslint/lib/shared/string-utils.js b/tools/eslint/node_modules/eslint/lib/shared/string-utils.js deleted file mode 100644 index 31d0df982ca43c..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/shared/string-utils.js +++ /dev/null @@ -1,58 +0,0 @@ -/** - * @fileoverview Utilities to operate on strings. - * @author Stephen Wade - */ - -"use strict"; - -//------------------------------------------------------------------------------ -// Helpers -//------------------------------------------------------------------------------ - -// eslint-disable-next-line no-control-regex -- intentionally including control characters -const ASCII_REGEX = /^[\u0000-\u007f]*$/u; - -/** @type {Intl.Segmenter | undefined} */ -let segmenter; - -//------------------------------------------------------------------------------ -// Public Interface -//------------------------------------------------------------------------------ - -/** - * Converts the first letter of a string to uppercase. - * @param {string} string The string to operate on - * @returns {string} The converted string - */ -function upperCaseFirst(string) { - if (string.length <= 1) { - return string.toUpperCase(); - } - return string[0].toUpperCase() + string.slice(1); -} - -/** - * Counts graphemes in a given string. - * @param {string} value A string to count graphemes. - * @returns {number} The number of graphemes in `value`. - */ -function getGraphemeCount(value) { - if (ASCII_REGEX.test(value)) { - return value.length; - } - - segmenter ??= new Intl.Segmenter("en-US"); // en-US locale should be supported everywhere - let graphemeCount = 0; - - // eslint-disable-next-line no-unused-vars -- for-of needs a variable - for (const unused of segmenter.segment(value)) { - graphemeCount++; - } - - return graphemeCount; -} - -module.exports = { - upperCaseFirst, - getGraphemeCount -}; diff --git a/tools/eslint/node_modules/eslint/lib/shared/traverser.js b/tools/eslint/node_modules/eslint/lib/shared/traverser.js deleted file mode 100644 index 38b4e215132ede..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/shared/traverser.js +++ /dev/null @@ -1,195 +0,0 @@ -/** - * @fileoverview Traverser to traverse AST trees. - * @author Nicholas C. Zakas - * @author Toru Nagashima - */ -"use strict"; - -//------------------------------------------------------------------------------ -// Requirements -//------------------------------------------------------------------------------ - -const vk = require("eslint-visitor-keys"); -const debug = require("debug")("eslint:traverser"); - -//------------------------------------------------------------------------------ -// Helpers -//------------------------------------------------------------------------------ - -/** - * Do nothing. - * @returns {void} - */ -function noop() { - - // do nothing. -} - -/** - * Check whether the given value is an ASTNode or not. - * @param {any} x The value to check. - * @returns {boolean} `true` if the value is an ASTNode. - */ -function isNode(x) { - return x !== null && typeof x === "object" && typeof x.type === "string"; -} - -/** - * Get the visitor keys of a given node. - * @param {Object} visitorKeys The map of visitor keys. - * @param {ASTNode} node The node to get their visitor keys. - * @returns {string[]} The visitor keys of the node. - */ -function getVisitorKeys(visitorKeys, node) { - let keys = visitorKeys[node.type]; - - if (!keys) { - keys = vk.getKeys(node); - debug("Unknown node type \"%s\": Estimated visitor keys %j", node.type, keys); - } - - return keys; -} - -/** - * The traverser class to traverse AST trees. - */ -class Traverser { - constructor() { - this._current = null; - this._parents = []; - this._skipped = false; - this._broken = false; - this._visitorKeys = null; - this._enter = null; - this._leave = null; - } - - /** - * Gives current node. - * @returns {ASTNode} The current node. - */ - current() { - return this._current; - } - - /** - * Gives a copy of the ancestor nodes. - * @returns {ASTNode[]} The ancestor nodes. - */ - parents() { - return this._parents.slice(0); - } - - /** - * Break the current traversal. - * @returns {void} - */ - break() { - this._broken = true; - } - - /** - * Skip child nodes for the current traversal. - * @returns {void} - */ - skip() { - this._skipped = true; - } - - /** - * Traverse the given AST tree. - * @param {ASTNode} node The root node to traverse. - * @param {Object} options The option object. - * @param {Object} [options.visitorKeys=DEFAULT_VISITOR_KEYS] The keys of each node types to traverse child nodes. Default is `./default-visitor-keys.json`. - * @param {Function} [options.enter=noop] The callback function which is called on entering each node. - * @param {Function} [options.leave=noop] The callback function which is called on leaving each node. - * @returns {void} - */ - traverse(node, options) { - this._current = null; - this._parents = []; - this._skipped = false; - this._broken = false; - this._visitorKeys = options.visitorKeys || vk.KEYS; - this._enter = options.enter || noop; - this._leave = options.leave || noop; - this._traverse(node, null); - } - - /** - * Traverse the given AST tree recursively. - * @param {ASTNode} node The current node. - * @param {ASTNode|null} parent The parent node. - * @returns {void} - * @private - */ - _traverse(node, parent) { - if (!isNode(node)) { - return; - } - - this._current = node; - this._skipped = false; - this._enter(node, parent); - - if (!this._skipped && !this._broken) { - const keys = getVisitorKeys(this._visitorKeys, node); - - if (keys.length >= 1) { - this._parents.push(node); - for (let i = 0; i < keys.length && !this._broken; ++i) { - const child = node[keys[i]]; - - if (Array.isArray(child)) { - for (let j = 0; j < child.length && !this._broken; ++j) { - this._traverse(child[j], node); - } - } else { - this._traverse(child, node); - } - } - this._parents.pop(); - } - } - - if (!this._broken) { - this._leave(node, parent); - } - - this._current = parent; - } - - /** - * Calculates the keys to use for traversal. - * @param {ASTNode} node The node to read keys from. - * @returns {string[]} An array of keys to visit on the node. - * @private - */ - static getKeys(node) { - return vk.getKeys(node); - } - - /** - * Traverse the given AST tree. - * @param {ASTNode} node The root node to traverse. - * @param {Object} options The option object. - * @param {Object} [options.visitorKeys=DEFAULT_VISITOR_KEYS] The keys of each node types to traverse child nodes. Default is `./default-visitor-keys.json`. - * @param {Function} [options.enter=noop] The callback function which is called on entering each node. - * @param {Function} [options.leave=noop] The callback function which is called on leaving each node. - * @returns {void} - */ - static traverse(node, options) { - new Traverser().traverse(node, options); - } - - /** - * The default visitor keys. - * @type {Object} - */ - static get DEFAULT_VISITOR_KEYS() { - return vk.KEYS; - } -} - -module.exports = Traverser; diff --git a/tools/eslint/node_modules/eslint/lib/shared/types.js b/tools/eslint/node_modules/eslint/lib/shared/types.js deleted file mode 100644 index 94a91afc813955..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/shared/types.js +++ /dev/null @@ -1,250 +0,0 @@ -/** - * @fileoverview Define common types for input completion. - * @author Toru Nagashima - */ -"use strict"; - -/** @type {any} */ -module.exports = {}; - -/** @typedef {boolean | "off" | "readable" | "readonly" | "writable" | "writeable"} GlobalConf */ -/** @typedef {0 | 1 | 2 | "off" | "warn" | "error"} SeverityConf */ -/** @typedef {SeverityConf | [SeverityConf, ...any[]]} RuleConf */ - -/** - * @typedef {Object} EcmaFeatures - * @property {boolean} [globalReturn] Enabling `return` statements at the top-level. - * @property {boolean} [jsx] Enabling JSX syntax. - * @property {boolean} [impliedStrict] Enabling strict mode always. - */ - -/** - * @typedef {Object} ParserOptions - * @property {EcmaFeatures} [ecmaFeatures] The optional features. - * @property {3|5|6|7|8|9|10|11|12|13|14|15|16|2015|2016|2017|2018|2019|2020|2021|2022|2023|2024|2025} [ecmaVersion] The ECMAScript version (or revision number). - * @property {"script"|"module"} [sourceType] The source code type. - * @property {boolean} [allowReserved] Allowing the use of reserved words as identifiers in ES3. - */ - -/** - * @typedef {Object} LanguageOptions - * @property {number|"latest"} [ecmaVersion] The ECMAScript version (or revision number). - * @property {Record} [globals] The global variable settings. - * @property {"script"|"module"|"commonjs"} [sourceType] The source code type. - * @property {string|Object} [parser] The parser to use. - * @property {Object} [parserOptions] The parser options to use. - */ - -/** - * @typedef {Object} ConfigData - * @property {Record} [env] The environment settings. - * @property {string | string[]} [extends] The path to other config files or the package name of shareable configs. - * @property {Record} [globals] The global variable settings. - * @property {string | string[]} [ignorePatterns] The glob patterns that ignore to lint. - * @property {boolean} [noInlineConfig] The flag that disables directive comments. - * @property {OverrideConfigData[]} [overrides] The override settings per kind of files. - * @property {string} [parser] The path to a parser or the package name of a parser. - * @property {ParserOptions} [parserOptions] The parser options. - * @property {string[]} [plugins] The plugin specifiers. - * @property {string} [processor] The processor specifier. - * @property {boolean} [reportUnusedDisableDirectives] The flag to report unused `eslint-disable` comments. - * @property {boolean} [root] The root flag. - * @property {Record} [rules] The rule settings. - * @property {Object} [settings] The shared settings. - */ - -/** - * @typedef {Object} OverrideConfigData - * @property {Record} [env] The environment settings. - * @property {string | string[]} [excludedFiles] The glob patterns for excluded files. - * @property {string | string[]} [extends] The path to other config files or the package name of shareable configs. - * @property {string | string[]} files The glob patterns for target files. - * @property {Record} [globals] The global variable settings. - * @property {boolean} [noInlineConfig] The flag that disables directive comments. - * @property {OverrideConfigData[]} [overrides] The override settings per kind of files. - * @property {string} [parser] The path to a parser or the package name of a parser. - * @property {ParserOptions} [parserOptions] The parser options. - * @property {string[]} [plugins] The plugin specifiers. - * @property {string} [processor] The processor specifier. - * @property {boolean} [reportUnusedDisableDirectives] The flag to report unused `eslint-disable` comments. - * @property {Record} [rules] The rule settings. - * @property {Object} [settings] The shared settings. - */ - -/** - * @typedef {Object} ParseResult - * @property {Object} ast The AST. - * @property {ScopeManager} [scopeManager] The scope manager of the AST. - * @property {Record} [services] The services that the parser provides. - * @property {Record} [visitorKeys] The visitor keys of the AST. - */ - -/** - * @typedef {Object} Parser - * @property {(text:string, options:ParserOptions) => Object} parse The definition of global variables. - * @property {(text:string, options:ParserOptions) => ParseResult} [parseForESLint] The parser options that will be enabled under this environment. - */ - -/** - * @typedef {Object} Environment - * @property {Record} [globals] The definition of global variables. - * @property {ParserOptions} [parserOptions] The parser options that will be enabled under this environment. - */ - -/** - * @typedef {Object} LintMessage - * @property {number|undefined} column The 1-based column number. - * @property {number} [endColumn] The 1-based column number of the end location. - * @property {number} [endLine] The 1-based line number of the end location. - * @property {boolean} [fatal] If `true` then this is a fatal error. - * @property {{range:[number,number], text:string}} [fix] Information for autofix. - * @property {number|undefined} line The 1-based line number. - * @property {string} message The error message. - * @property {string} [messageId] The ID of the message in the rule's meta. - * @property {(string|null)} nodeType Type of node - * @property {string|null} ruleId The ID of the rule which makes this message. - * @property {0|1|2} severity The severity of this message. - * @property {Array<{desc?: string, messageId?: string, fix: {range: [number, number], text: string}}>} [suggestions] Information for suggestions. - */ - -/** - * @typedef {Object} SuppressedLintMessage - * @property {number|undefined} column The 1-based column number. - * @property {number} [endColumn] The 1-based column number of the end location. - * @property {number} [endLine] The 1-based line number of the end location. - * @property {boolean} [fatal] If `true` then this is a fatal error. - * @property {{range:[number,number], text:string}} [fix] Information for autofix. - * @property {number|undefined} line The 1-based line number. - * @property {string} message The error message. - * @property {string} [messageId] The ID of the message in the rule's meta. - * @property {(string|null)} nodeType Type of node - * @property {string|null} ruleId The ID of the rule which makes this message. - * @property {0|1|2} severity The severity of this message. - * @property {Array<{kind: string, justification: string}>} suppressions The suppression info. - * @property {Array<{desc?: string, messageId?: string, fix: {range: [number, number], text: string}}>} [suggestions] Information for suggestions. - */ - -/** - * @typedef {Object} SuggestionResult - * @property {string} desc A short description. - * @property {string} [messageId] Id referencing a message for the description. - * @property {{ text: string, range: number[] }} fix fix result info - */ - -/** - * @typedef {Object} Processor - * @property {(text:string, filename:string) => Array} [preprocess] The function to extract code blocks. - * @property {(messagesList:LintMessage[][], filename:string) => LintMessage[]} [postprocess] The function to merge messages. - * @property {boolean} [supportsAutofix] If `true` then it means the processor supports autofix. - */ - -/** - * @typedef {Object} RuleMetaDocs - * @property {string} description The description of the rule. - * @property {boolean} recommended If `true` then the rule is included in `eslint:recommended` preset. - * @property {string} url The URL of the rule documentation. - */ - -/** - * @typedef {Object} RuleMeta - * @property {boolean} [deprecated] If `true` then the rule has been deprecated. - * @property {RuleMetaDocs} docs The document information of the rule. - * @property {"code"|"whitespace"} [fixable] The autofix type. - * @property {boolean} [hasSuggestions] If `true` then the rule provides suggestions. - * @property {Record} [messages] The messages the rule reports. - * @property {string[]} [replacedBy] The IDs of the alternative rules. - * @property {Array|Object} schema The option schema of the rule. - * @property {"problem"|"suggestion"|"layout"} type The rule type. - */ - -/** - * @typedef {Object} Rule - * @property {Function} create The factory of the rule. - * @property {RuleMeta} meta The meta data of the rule. - */ - -/** - * @typedef {Object} Plugin - * @property {Record} [configs] The definition of plugin configs. - * @property {Record} [environments] The definition of plugin environments. - * @property {Record} [processors] The definition of plugin processors. - * @property {Record} [rules] The definition of plugin rules. - */ - -/** - * Information of deprecated rules. - * @typedef {Object} DeprecatedRuleInfo - * @property {string} ruleId The rule ID. - * @property {string[]} replacedBy The rule IDs that replace this deprecated rule. - */ - -/** - * A linting result. - * @typedef {Object} LintResult - * @property {string} filePath The path to the file that was linted. - * @property {LintMessage[]} messages All of the messages for the result. - * @property {SuppressedLintMessage[]} suppressedMessages All of the suppressed messages for the result. - * @property {number} errorCount Number of errors for the result. - * @property {number} fatalErrorCount Number of fatal errors for the result. - * @property {number} warningCount Number of warnings for the result. - * @property {number} fixableErrorCount Number of fixable errors for the result. - * @property {number} fixableWarningCount Number of fixable warnings for the result. - * @property {Stats} [stats] The performance statistics collected with the `stats` flag. - * @property {string} [source] The source code of the file that was linted. - * @property {string} [output] The source code of the file that was linted, with as many fixes applied as possible. - * @property {DeprecatedRuleInfo[]} usedDeprecatedRules The list of used deprecated rules. - */ - -/** - * Performance statistics - * @typedef {Object} Stats - * @property {number} fixPasses The number of times ESLint has applied at least one fix after linting. - * @property {Times} times The times spent on (parsing, fixing, linting) a file. - */ - -/** - * Performance Times for each ESLint pass - * @typedef {Object} Times - * @property {TimePass[]} passes Time passes - */ - -/** - * @typedef {Object} TimePass - * @property {ParseTime} parse The parse object containing all parse time information. - * @property {Record} [rules] The rules object containing all lint time information for each rule. - * @property {FixTime} fix The parse object containing all fix time information. - * @property {number} total The total time that is spent on (parsing, fixing, linting) a file. - */ -/** - * @typedef {Object} ParseTime - * @property {number} total The total time that is spent when parsing a file. - */ -/** - * @typedef {Object} RuleTime - * @property {number} total The total time that is spent on a rule. - */ -/** - * @typedef {Object} FixTime - * @property {number} total The total time that is spent on applying fixes to the code. - */ - -/** - * Information provided when the maximum warning threshold is exceeded. - * @typedef {Object} MaxWarningsExceeded - * @property {number} maxWarnings Number of warnings to trigger nonzero exit code. - * @property {number} foundWarnings Number of warnings found while linting. - */ - -/** - * Metadata about results for formatters. - * @typedef {Object} ResultsMeta - * @property {MaxWarningsExceeded} [maxWarningsExceeded] Present if the maxWarnings threshold was exceeded. - */ - -/** - * A formatter function. - * @callback FormatterFunction - * @param {LintResult[]} results The list of linting results. - * @param {{cwd: string, maxWarningsExceeded?: MaxWarningsExceeded, rulesMeta: Record}} [context] A context object. - * @returns {string | Promise} Formatted text. - */ diff --git a/tools/eslint/node_modules/eslint/lib/unsupported-api.js b/tools/eslint/node_modules/eslint/lib/unsupported-api.js deleted file mode 100644 index 50e7f5bd6d2216..00000000000000 --- a/tools/eslint/node_modules/eslint/lib/unsupported-api.js +++ /dev/null @@ -1,28 +0,0 @@ -/** - * @fileoverview APIs that are not officially supported by ESLint. - * These APIs may change or be removed at any time. Use at your - * own risk. - * @author Nicholas C. Zakas - */ - -"use strict"; - -//----------------------------------------------------------------------------- -// Requirements -//----------------------------------------------------------------------------- - -const { FileEnumerator } = require("./cli-engine/file-enumerator"); -const { ESLint: FlatESLint, shouldUseFlatConfig } = require("./eslint/eslint"); -const { LegacyESLint } = require("./eslint/legacy-eslint"); - -//----------------------------------------------------------------------------- -// Exports -//----------------------------------------------------------------------------- - -module.exports = { - builtinRules: require("./rules"), - FlatESLint, - shouldUseFlatConfig, - FileEnumerator, - LegacyESLint -}; diff --git a/tools/eslint/node_modules/eslint/messages/all-files-ignored.js b/tools/eslint/node_modules/eslint/messages/all-files-ignored.js deleted file mode 100644 index 70877a4d823e36..00000000000000 --- a/tools/eslint/node_modules/eslint/messages/all-files-ignored.js +++ /dev/null @@ -1,16 +0,0 @@ -"use strict"; - -module.exports = function(it) { - const { pattern } = it; - - return ` -You are linting "${pattern}", but all of the files matching the glob pattern "${pattern}" are ignored. - -If you don't want to lint these files, remove the pattern "${pattern}" from the list of arguments passed to ESLint. - -If you do want to lint these files, try the following solutions: - -* Check your .eslintignore file, or the eslintIgnore property in package.json, to ensure that the files are not configured to be ignored. -* Explicitly list the files from this glob that you'd like to lint on the command-line, rather than providing a glob as an argument. -`.trimStart(); -}; diff --git a/tools/eslint/node_modules/eslint/messages/all-matched-files-ignored.js b/tools/eslint/node_modules/eslint/messages/all-matched-files-ignored.js deleted file mode 100644 index b568bec823979a..00000000000000 --- a/tools/eslint/node_modules/eslint/messages/all-matched-files-ignored.js +++ /dev/null @@ -1,21 +0,0 @@ -"use strict"; - -module.exports = function(it) { - const { pattern } = it; - - return ` -You are linting "${pattern}", but all of the files matching the glob pattern "${pattern}" are ignored. - -If you don't want to lint these files, remove the pattern "${pattern}" from the list of arguments passed to ESLint. - -If you do want to lint these files, explicitly list one or more of the files from this glob that you'd like to lint to see more details about why they are ignored. - - * If the file is ignored because of a matching ignore pattern, check global ignores in your config file. - https://eslint.org/docs/latest/use/configure/ignore - - * If the file is ignored because no matching configuration was supplied, check file patterns in your config file. - https://eslint.org/docs/latest/use/configure/configuration-files#specifying-files-with-arbitrary-extensions - - * If the file is ignored because it is located outside of the base path, change the location of your config file to be in a parent directory. -`.trimStart(); -}; diff --git a/tools/eslint/node_modules/eslint/messages/config-file-missing.js b/tools/eslint/node_modules/eslint/messages/config-file-missing.js deleted file mode 100644 index a416a87d3439c6..00000000000000 --- a/tools/eslint/node_modules/eslint/messages/config-file-missing.js +++ /dev/null @@ -1,16 +0,0 @@ -"use strict"; - -module.exports = function() { - return ` -ESLint couldn't find an eslint.config.(js|mjs|cjs) file. - -From ESLint v9.0.0, the default configuration file is now eslint.config.js. -If you are using a .eslintrc.* file, please follow the migration guide -to update your configuration file to the new format: - -https://eslint.org/docs/latest/use/configure/migration-guide - -If you still have problems after following the migration guide, please stop by -https://eslint.org/chat/help to chat with the team. -`.trimStart(); -}; diff --git a/tools/eslint/node_modules/eslint/messages/eslintrc-incompat.js b/tools/eslint/node_modules/eslint/messages/eslintrc-incompat.js deleted file mode 100644 index b89c39bd88ba8a..00000000000000 --- a/tools/eslint/node_modules/eslint/messages/eslintrc-incompat.js +++ /dev/null @@ -1,119 +0,0 @@ -"use strict"; - -/* eslint consistent-return: 0 -- no default case */ - -const messages = { - - env: ` -A config object is using the "env" key, which is not supported in flat config system. - -Flat config uses "languageOptions.globals" to define global variables for your files. - -Please see the following page for information on how to convert your config object into the correct format: -https://eslint.org/docs/latest/use/configure/migration-guide#configuring-language-options - -If you're not using "env" directly (it may be coming from a plugin), please see the following: -https://eslint.org/docs/latest/use/configure/migration-guide#using-eslintrc-configs-in-flat-config -`, - - extends: ` -A config object is using the "extends" key, which is not supported in flat config system. - -Instead of "extends", you can include config objects that you'd like to extend from directly in the flat config array. - -If you're using "extends" in your config file, please see the following: -https://eslint.org/docs/latest/use/configure/migration-guide#predefined-and-shareable-configs - -If you're not using "extends" directly (it may be coming from a plugin), please see the following: -https://eslint.org/docs/latest/use/configure/migration-guide#using-eslintrc-configs-in-flat-config -`, - - globals: ` -A config object is using the "globals" key, which is not supported in flat config system. - -Flat config uses "languageOptions.globals" to define global variables for your files. - -Please see the following page for information on how to convert your config object into the correct format: -https://eslint.org/docs/latest/use/configure/migration-guide#configuring-language-options - -If you're not using "globals" directly (it may be coming from a plugin), please see the following: -https://eslint.org/docs/latest/use/configure/migration-guide#using-eslintrc-configs-in-flat-config -`, - - ignorePatterns: ` -A config object is using the "ignorePatterns" key, which is not supported in flat config system. - -Flat config uses "ignores" to specify files to ignore. - -Please see the following page for information on how to convert your config object into the correct format: -https://eslint.org/docs/latest/use/configure/migration-guide#ignoring-files - -If you're not using "ignorePatterns" directly (it may be coming from a plugin), please see the following: -https://eslint.org/docs/latest/use/configure/migration-guide#using-eslintrc-configs-in-flat-config -`, - - noInlineConfig: ` -A config object is using the "noInlineConfig" key, which is not supported in flat config system. - -Flat config uses "linterOptions.noInlineConfig" to specify files to ignore. - -Please see the following page for information on how to convert your config object into the correct format: -https://eslint.org/docs/latest/use/configure/migration-guide#linter-options -`, - - overrides: ` -A config object is using the "overrides" key, which is not supported in flat config system. - -Flat config is an array that acts like the eslintrc "overrides" array. - -Please see the following page for information on how to convert your config object into the correct format: -https://eslint.org/docs/latest/use/configure/migration-guide#glob-based-configs - -If you're not using "overrides" directly (it may be coming from a plugin), please see the following: -https://eslint.org/docs/latest/use/configure/migration-guide#using-eslintrc-configs-in-flat-config -`, - - parser: ` -A config object is using the "parser" key, which is not supported in flat config system. - -Flat config uses "languageOptions.parser" to override the default parser. - -Please see the following page for information on how to convert your config object into the correct format: -https://eslint.org/docs/latest/use/configure/migration-guide#custom-parsers - -If you're not using "parser" directly (it may be coming from a plugin), please see the following: -https://eslint.org/docs/latest/use/configure/migration-guide#using-eslintrc-configs-in-flat-config -`, - - parserOptions: ` -A config object is using the "parserOptions" key, which is not supported in flat config system. - -Flat config uses "languageOptions.parserOptions" to specify parser options. - -Please see the following page for information on how to convert your config object into the correct format: -https://eslint.org/docs/latest/use/configure/migration-guide#configuring-language-options - -If you're not using "parserOptions" directly (it may be coming from a plugin), please see the following: -https://eslint.org/docs/latest/use/configure/migration-guide#using-eslintrc-configs-in-flat-config -`, - - reportUnusedDisableDirectives: ` -A config object is using the "reportUnusedDisableDirectives" key, which is not supported in flat config system. - -Flat config uses "linterOptions.reportUnusedDisableDirectives" to specify files to ignore. - -Please see the following page for information on how to convert your config object into the correct format: -https://eslint.org/docs/latest/use/configure/migration-guide#linter-options -`, - - root: ` -A config object is using the "root" key, which is not supported in flat config system. - -Flat configs always act as if they are the root config file, so this key can be safely removed. -` -}; - -module.exports = function({ key }) { - - return messages[key].trim(); -}; diff --git a/tools/eslint/node_modules/eslint/messages/eslintrc-plugins.js b/tools/eslint/node_modules/eslint/messages/eslintrc-plugins.js deleted file mode 100644 index bb708c95b0531a..00000000000000 --- a/tools/eslint/node_modules/eslint/messages/eslintrc-plugins.js +++ /dev/null @@ -1,24 +0,0 @@ -"use strict"; - -module.exports = function({ plugins }) { - - const isArrayOfStrings = typeof plugins[0] === "string"; - - return ` -A config object has a "plugins" key defined as an array${isArrayOfStrings ? " of strings" : ""}. - -Flat config requires "plugins" to be an object in this form: - - { - plugins: { - ${isArrayOfStrings && plugins[0] ? plugins[0] : "namespace"}: pluginObject - } - } - -Please see the following page for information on how to convert your config object into the correct format: -https://eslint.org/docs/latest/use/configure/migration-guide#importing-plugins-and-custom-parsers - -If you're using a shareable config that you cannot rewrite in flat config format, then use the compatibility utility: -https://eslint.org/docs/latest/use/configure/migration-guide#using-eslintrc-configs-in-flat-config -`; -}; diff --git a/tools/eslint/node_modules/eslint/messages/extend-config-missing.js b/tools/eslint/node_modules/eslint/messages/extend-config-missing.js deleted file mode 100644 index 5b3498fcda408b..00000000000000 --- a/tools/eslint/node_modules/eslint/messages/extend-config-missing.js +++ /dev/null @@ -1,13 +0,0 @@ -"use strict"; - -module.exports = function(it) { - const { configName, importerName } = it; - - return ` -ESLint couldn't find the config "${configName}" to extend from. Please check that the name of the config is correct. - -The config "${configName}" was referenced from the config file in "${importerName}". - -If you still have problems, please stop by https://eslint.org/chat/help to chat with the team. -`.trimStart(); -}; diff --git a/tools/eslint/node_modules/eslint/messages/failed-to-read-json.js b/tools/eslint/node_modules/eslint/messages/failed-to-read-json.js deleted file mode 100644 index e7c6cb58759f61..00000000000000 --- a/tools/eslint/node_modules/eslint/messages/failed-to-read-json.js +++ /dev/null @@ -1,11 +0,0 @@ -"use strict"; - -module.exports = function(it) { - const { path, message } = it; - - return ` -Failed to read JSON file at ${path}: - -${message} -`.trimStart(); -}; diff --git a/tools/eslint/node_modules/eslint/messages/file-not-found.js b/tools/eslint/node_modules/eslint/messages/file-not-found.js deleted file mode 100644 index 1a62fcf96b9ef6..00000000000000 --- a/tools/eslint/node_modules/eslint/messages/file-not-found.js +++ /dev/null @@ -1,10 +0,0 @@ -"use strict"; - -module.exports = function(it) { - const { pattern, globDisabled } = it; - - return ` -No files matching the pattern "${pattern}"${globDisabled ? " (with disabling globs)" : ""} were found. -Please check for typing mistakes in the pattern. -`.trimStart(); -}; diff --git a/tools/eslint/node_modules/eslint/messages/invalid-rule-options.js b/tools/eslint/node_modules/eslint/messages/invalid-rule-options.js deleted file mode 100644 index 9a8acc934ae4ff..00000000000000 --- a/tools/eslint/node_modules/eslint/messages/invalid-rule-options.js +++ /dev/null @@ -1,17 +0,0 @@ -"use strict"; - -const { stringifyValueForError } = require("./shared"); - -module.exports = function({ ruleId, value }) { - return ` -Configuration for rule "${ruleId}" is invalid. Each rule must have a severity ("off", 0, "warn", 1, "error", or 2) and may be followed by additional options for the rule. - -You passed '${stringifyValueForError(value, 4)}', which doesn't contain a valid severity. - -If you're attempting to configure rule options, perhaps you meant: - - "${ruleId}": ["error", ${stringifyValueForError(value, 8)}] - -See https://eslint.org/docs/latest/use/configure/rules#using-configuration-files for configuring rules. -`.trimStart(); -}; diff --git a/tools/eslint/node_modules/eslint/messages/invalid-rule-severity.js b/tools/eslint/node_modules/eslint/messages/invalid-rule-severity.js deleted file mode 100644 index 3f13183c6a8914..00000000000000 --- a/tools/eslint/node_modules/eslint/messages/invalid-rule-severity.js +++ /dev/null @@ -1,13 +0,0 @@ -"use strict"; - -const { stringifyValueForError } = require("./shared"); - -module.exports = function({ ruleId, value }) { - return ` -Configuration for rule "${ruleId}" is invalid. Expected severity of "off", 0, "warn", 1, "error", or 2. - -You passed '${stringifyValueForError(value, 4)}'. - -See https://eslint.org/docs/latest/use/configure/rules#using-configuration-files for configuring rules. -`.trimStart(); -}; diff --git a/tools/eslint/node_modules/eslint/messages/no-config-found.js b/tools/eslint/node_modules/eslint/messages/no-config-found.js deleted file mode 100644 index 64b93edbca1320..00000000000000 --- a/tools/eslint/node_modules/eslint/messages/no-config-found.js +++ /dev/null @@ -1,15 +0,0 @@ -"use strict"; - -module.exports = function(it) { - const { directoryPath } = it; - - return ` -ESLint couldn't find a configuration file. To set up a configuration file for this project, please run: - - npm init @eslint/config@latest - -ESLint looked for configuration files in ${directoryPath} and its ancestors. If it found none, it then looked in your home directory. - -If you think you already have a configuration file or if you need more help, please stop by the ESLint Discord server: https://eslint.org/chat -`.trimStart(); -}; diff --git a/tools/eslint/node_modules/eslint/messages/plugin-conflict.js b/tools/eslint/node_modules/eslint/messages/plugin-conflict.js deleted file mode 100644 index 4113a538fc9f9e..00000000000000 --- a/tools/eslint/node_modules/eslint/messages/plugin-conflict.js +++ /dev/null @@ -1,22 +0,0 @@ -"use strict"; - -module.exports = function(it) { - const { pluginId, plugins } = it; - - let result = `ESLint couldn't determine the plugin "${pluginId}" uniquely. -`; - - for (const { filePath, importerName } of plugins) { - result += ` -- ${filePath} (loaded in "${importerName}")`; - } - - result += ` - -Please remove the "plugins" setting from either config or remove either plugin installation. - -If you still can't figure out the problem, please see https://eslint.org/docs/latest/use/troubleshooting. -`; - - return result; -}; diff --git a/tools/eslint/node_modules/eslint/messages/plugin-invalid.js b/tools/eslint/node_modules/eslint/messages/plugin-invalid.js deleted file mode 100644 index 4c60e41d319241..00000000000000 --- a/tools/eslint/node_modules/eslint/messages/plugin-invalid.js +++ /dev/null @@ -1,16 +0,0 @@ -"use strict"; - -module.exports = function(it) { - const { configName, importerName } = it; - - return ` -"${configName}" is invalid syntax for a config specifier. - -* If your intention is to extend from a configuration exported from the plugin, add the configuration name after a slash: e.g. "${configName}/myConfig". -* If this is the name of a shareable config instead of a plugin, remove the "plugin:" prefix: i.e. "${configName.slice("plugin:".length)}". - -"${configName}" was referenced from the config file in "${importerName}". - -If you still can't figure out the problem, please see https://eslint.org/docs/latest/use/troubleshooting. -`.trimStart(); -}; diff --git a/tools/eslint/node_modules/eslint/messages/plugin-missing.js b/tools/eslint/node_modules/eslint/messages/plugin-missing.js deleted file mode 100644 index 366ec4500e5f14..00000000000000 --- a/tools/eslint/node_modules/eslint/messages/plugin-missing.js +++ /dev/null @@ -1,19 +0,0 @@ -"use strict"; - -module.exports = function(it) { - const { pluginName, resolvePluginsRelativeTo, importerName } = it; - - return ` -ESLint couldn't find the plugin "${pluginName}". - -(The package "${pluginName}" was not found when loaded as a Node module from the directory "${resolvePluginsRelativeTo}".) - -It's likely that the plugin isn't installed correctly. Try reinstalling by running the following: - - npm install ${pluginName}@latest --save-dev - -The plugin "${pluginName}" was referenced from the config file in "${importerName}". - -If you still can't figure out the problem, please see https://eslint.org/docs/latest/use/troubleshooting. -`.trimStart(); -}; diff --git a/tools/eslint/node_modules/eslint/messages/print-config-with-directory-path.js b/tools/eslint/node_modules/eslint/messages/print-config-with-directory-path.js deleted file mode 100644 index 4559c8d6de402a..00000000000000 --- a/tools/eslint/node_modules/eslint/messages/print-config-with-directory-path.js +++ /dev/null @@ -1,8 +0,0 @@ -"use strict"; - -module.exports = function() { - return ` -The '--print-config' CLI option requires a path to a source code file rather than a directory. -See also: https://eslint.org/docs/latest/use/command-line-interface#--print-config -`.trimStart(); -}; diff --git a/tools/eslint/node_modules/eslint/messages/shared.js b/tools/eslint/node_modules/eslint/messages/shared.js deleted file mode 100644 index 8c6e9b92145662..00000000000000 --- a/tools/eslint/node_modules/eslint/messages/shared.js +++ /dev/null @@ -1,18 +0,0 @@ -/** - * @fileoverview Shared utilities for error messages. - * @author Josh Goldberg - */ - -"use strict"; - -/** - * Converts a value to a string that may be printed in errors. - * @param {any} value The invalid value. - * @param {number} indentation How many spaces to indent - * @returns {string} The value, stringified. - */ -function stringifyValueForError(value, indentation) { - return value ? JSON.stringify(value, null, 4).replace(/\n/gu, `\n${" ".repeat(indentation)}`) : `${value}`; -} - -module.exports = { stringifyValueForError }; diff --git a/tools/eslint/node_modules/eslint/messages/whitespace-found.js b/tools/eslint/node_modules/eslint/messages/whitespace-found.js deleted file mode 100644 index 8a801bcec6f825..00000000000000 --- a/tools/eslint/node_modules/eslint/messages/whitespace-found.js +++ /dev/null @@ -1,11 +0,0 @@ -"use strict"; - -module.exports = function(it) { - const { pluginName } = it; - - return ` -ESLint couldn't find the plugin "${pluginName}". because there is whitespace in the name. Please check your configuration and remove all whitespace from the plugin name. - -If you still can't figure out the problem, please stop by https://eslint.org/chat/help to chat with the team. -`.trimStart(); -}; diff --git a/tools/eslint/node_modules/eslint/node_modules/ansi-styles/index.js b/tools/eslint/node_modules/eslint/node_modules/ansi-styles/index.js deleted file mode 100644 index 5d82581a13f990..00000000000000 --- a/tools/eslint/node_modules/eslint/node_modules/ansi-styles/index.js +++ /dev/null @@ -1,163 +0,0 @@ -'use strict'; - -const wrapAnsi16 = (fn, offset) => (...args) => { - const code = fn(...args); - return `\u001B[${code + offset}m`; -}; - -const wrapAnsi256 = (fn, offset) => (...args) => { - const code = fn(...args); - return `\u001B[${38 + offset};5;${code}m`; -}; - -const wrapAnsi16m = (fn, offset) => (...args) => { - const rgb = fn(...args); - return `\u001B[${38 + offset};2;${rgb[0]};${rgb[1]};${rgb[2]}m`; -}; - -const ansi2ansi = n => n; -const rgb2rgb = (r, g, b) => [r, g, b]; - -const setLazyProperty = (object, property, get) => { - Object.defineProperty(object, property, { - get: () => { - const value = get(); - - Object.defineProperty(object, property, { - value, - enumerable: true, - configurable: true - }); - - return value; - }, - enumerable: true, - configurable: true - }); -}; - -/** @type {typeof import('color-convert')} */ -let colorConvert; -const makeDynamicStyles = (wrap, targetSpace, identity, isBackground) => { - if (colorConvert === undefined) { - colorConvert = require('color-convert'); - } - - const offset = isBackground ? 10 : 0; - const styles = {}; - - for (const [sourceSpace, suite] of Object.entries(colorConvert)) { - const name = sourceSpace === 'ansi16' ? 'ansi' : sourceSpace; - if (sourceSpace === targetSpace) { - styles[name] = wrap(identity, offset); - } else if (typeof suite === 'object') { - styles[name] = wrap(suite[targetSpace], offset); - } - } - - return styles; -}; - -function assembleStyles() { - const codes = new Map(); - const styles = { - modifier: { - reset: [0, 0], - // 21 isn't widely supported and 22 does the same thing - bold: [1, 22], - dim: [2, 22], - italic: [3, 23], - underline: [4, 24], - inverse: [7, 27], - hidden: [8, 28], - strikethrough: [9, 29] - }, - color: { - black: [30, 39], - red: [31, 39], - green: [32, 39], - yellow: [33, 39], - blue: [34, 39], - magenta: [35, 39], - cyan: [36, 39], - white: [37, 39], - - // Bright color - blackBright: [90, 39], - redBright: [91, 39], - greenBright: [92, 39], - yellowBright: [93, 39], - blueBright: [94, 39], - magentaBright: [95, 39], - cyanBright: [96, 39], - whiteBright: [97, 39] - }, - bgColor: { - bgBlack: [40, 49], - bgRed: [41, 49], - bgGreen: [42, 49], - bgYellow: [43, 49], - bgBlue: [44, 49], - bgMagenta: [45, 49], - bgCyan: [46, 49], - bgWhite: [47, 49], - - // Bright color - bgBlackBright: [100, 49], - bgRedBright: [101, 49], - bgGreenBright: [102, 49], - bgYellowBright: [103, 49], - bgBlueBright: [104, 49], - bgMagentaBright: [105, 49], - bgCyanBright: [106, 49], - bgWhiteBright: [107, 49] - } - }; - - // Alias bright black as gray (and grey) - styles.color.gray = styles.color.blackBright; - styles.bgColor.bgGray = styles.bgColor.bgBlackBright; - styles.color.grey = styles.color.blackBright; - styles.bgColor.bgGrey = styles.bgColor.bgBlackBright; - - for (const [groupName, group] of Object.entries(styles)) { - for (const [styleName, style] of Object.entries(group)) { - styles[styleName] = { - open: `\u001B[${style[0]}m`, - close: `\u001B[${style[1]}m` - }; - - group[styleName] = styles[styleName]; - - codes.set(style[0], style[1]); - } - - Object.defineProperty(styles, groupName, { - value: group, - enumerable: false - }); - } - - Object.defineProperty(styles, 'codes', { - value: codes, - enumerable: false - }); - - styles.color.close = '\u001B[39m'; - styles.bgColor.close = '\u001B[49m'; - - setLazyProperty(styles.color, 'ansi', () => makeDynamicStyles(wrapAnsi16, 'ansi16', ansi2ansi, false)); - setLazyProperty(styles.color, 'ansi256', () => makeDynamicStyles(wrapAnsi256, 'ansi256', ansi2ansi, false)); - setLazyProperty(styles.color, 'ansi16m', () => makeDynamicStyles(wrapAnsi16m, 'rgb', rgb2rgb, false)); - setLazyProperty(styles.bgColor, 'ansi', () => makeDynamicStyles(wrapAnsi16, 'ansi16', ansi2ansi, true)); - setLazyProperty(styles.bgColor, 'ansi256', () => makeDynamicStyles(wrapAnsi256, 'ansi256', ansi2ansi, true)); - setLazyProperty(styles.bgColor, 'ansi16m', () => makeDynamicStyles(wrapAnsi16m, 'rgb', rgb2rgb, true)); - - return styles; -} - -// Make the export immutable -Object.defineProperty(module, 'exports', { - enumerable: true, - get: assembleStyles -}); diff --git a/tools/eslint/node_modules/eslint/node_modules/ansi-styles/license b/tools/eslint/node_modules/eslint/node_modules/ansi-styles/license deleted file mode 100644 index e7af2f77107d73..00000000000000 --- a/tools/eslint/node_modules/eslint/node_modules/ansi-styles/license +++ /dev/null @@ -1,9 +0,0 @@ -MIT License - -Copyright (c) Sindre Sorhus (sindresorhus.com) - -Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/tools/eslint/node_modules/eslint/node_modules/ansi-styles/package.json b/tools/eslint/node_modules/eslint/node_modules/ansi-styles/package.json deleted file mode 100644 index 75393284d7e474..00000000000000 --- a/tools/eslint/node_modules/eslint/node_modules/ansi-styles/package.json +++ /dev/null @@ -1,56 +0,0 @@ -{ - "name": "ansi-styles", - "version": "4.3.0", - "description": "ANSI escape codes for styling strings in the terminal", - "license": "MIT", - "repository": "chalk/ansi-styles", - "funding": "https://github.com/chalk/ansi-styles?sponsor=1", - "author": { - "name": "Sindre Sorhus", - "email": "sindresorhus@gmail.com", - "url": "sindresorhus.com" - }, - "engines": { - "node": ">=8" - }, - "scripts": { - "test": "xo && ava && tsd", - "screenshot": "svg-term --command='node screenshot' --out=screenshot.svg --padding=3 --width=55 --height=3 --at=1000 --no-cursor" - }, - "files": [ - "index.js", - "index.d.ts" - ], - "keywords": [ - "ansi", - "styles", - "color", - "colour", - "colors", - "terminal", - "console", - "cli", - "string", - "tty", - "escape", - "formatting", - "rgb", - "256", - "shell", - "xterm", - "log", - "logging", - "command-line", - "text" - ], - "dependencies": { - "color-convert": "^2.0.1" - }, - "devDependencies": { - "@types/color-convert": "^1.9.0", - "ava": "^2.3.0", - "svg-term-cli": "^2.1.1", - "tsd": "^0.11.0", - "xo": "^0.25.3" - } -} diff --git a/tools/eslint/node_modules/eslint/node_modules/ansi-styles/readme.md b/tools/eslint/node_modules/eslint/node_modules/ansi-styles/readme.md deleted file mode 100644 index 24883de808be6a..00000000000000 --- a/tools/eslint/node_modules/eslint/node_modules/ansi-styles/readme.md +++ /dev/null @@ -1,152 +0,0 @@ -# ansi-styles [![Build Status](https://travis-ci.org/chalk/ansi-styles.svg?branch=master)](https://travis-ci.org/chalk/ansi-styles) - -> [ANSI escape codes](https://en.wikipedia.org/wiki/ANSI_escape_code#Colors_and_Styles) for styling strings in the terminal - -You probably want the higher-level [chalk](https://github.com/chalk/chalk) module for styling your strings. - - - -## Install - -``` -$ npm install ansi-styles -``` - -## Usage - -```js -const style = require('ansi-styles'); - -console.log(`${style.green.open}Hello world!${style.green.close}`); - - -// Color conversion between 16/256/truecolor -// NOTE: If conversion goes to 16 colors or 256 colors, the original color -// may be degraded to fit that color palette. This means terminals -// that do not support 16 million colors will best-match the -// original color. -console.log(style.bgColor.ansi.hsl(120, 80, 72) + 'Hello world!' + style.bgColor.close); -console.log(style.color.ansi256.rgb(199, 20, 250) + 'Hello world!' + style.color.close); -console.log(style.color.ansi16m.hex('#abcdef') + 'Hello world!' + style.color.close); -``` - -## API - -Each style has an `open` and `close` property. - -## Styles - -### Modifiers - -- `reset` -- `bold` -- `dim` -- `italic` *(Not widely supported)* -- `underline` -- `inverse` -- `hidden` -- `strikethrough` *(Not widely supported)* - -### Colors - -- `black` -- `red` -- `green` -- `yellow` -- `blue` -- `magenta` -- `cyan` -- `white` -- `blackBright` (alias: `gray`, `grey`) -- `redBright` -- `greenBright` -- `yellowBright` -- `blueBright` -- `magentaBright` -- `cyanBright` -- `whiteBright` - -### Background colors - -- `bgBlack` -- `bgRed` -- `bgGreen` -- `bgYellow` -- `bgBlue` -- `bgMagenta` -- `bgCyan` -- `bgWhite` -- `bgBlackBright` (alias: `bgGray`, `bgGrey`) -- `bgRedBright` -- `bgGreenBright` -- `bgYellowBright` -- `bgBlueBright` -- `bgMagentaBright` -- `bgCyanBright` -- `bgWhiteBright` - -## Advanced usage - -By default, you get a map of styles, but the styles are also available as groups. They are non-enumerable so they don't show up unless you access them explicitly. This makes it easier to expose only a subset in a higher-level module. - -- `style.modifier` -- `style.color` -- `style.bgColor` - -###### Example - -```js -console.log(style.color.green.open); -``` - -Raw escape codes (i.e. without the CSI escape prefix `\u001B[` and render mode postfix `m`) are available under `style.codes`, which returns a `Map` with the open codes as keys and close codes as values. - -###### Example - -```js -console.log(style.codes.get(36)); -//=> 39 -``` - -## [256 / 16 million (TrueColor) support](https://gist.github.com/XVilka/8346728) - -`ansi-styles` uses the [`color-convert`](https://github.com/Qix-/color-convert) package to allow for converting between various colors and ANSI escapes, with support for 256 and 16 million colors. - -The following color spaces from `color-convert` are supported: - -- `rgb` -- `hex` -- `keyword` -- `hsl` -- `hsv` -- `hwb` -- `ansi` -- `ansi256` - -To use these, call the associated conversion function with the intended output, for example: - -```js -style.color.ansi.rgb(100, 200, 15); // RGB to 16 color ansi foreground code -style.bgColor.ansi.rgb(100, 200, 15); // RGB to 16 color ansi background code - -style.color.ansi256.hsl(120, 100, 60); // HSL to 256 color ansi foreground code -style.bgColor.ansi256.hsl(120, 100, 60); // HSL to 256 color ansi foreground code - -style.color.ansi16m.hex('#C0FFEE'); // Hex (RGB) to 16 million color foreground code -style.bgColor.ansi16m.hex('#C0FFEE'); // Hex (RGB) to 16 million color background code -``` - -## Related - -- [ansi-escapes](https://github.com/sindresorhus/ansi-escapes) - ANSI escape codes for manipulating the terminal - -## Maintainers - -- [Sindre Sorhus](https://github.com/sindresorhus) -- [Josh Junon](https://github.com/qix-) - -## For enterprise - -Available as part of the Tidelift Subscription. - -The maintainers of `ansi-styles` and thousands of other packages are working with Tidelift to deliver commercial support and maintenance for the open source dependencies you use to build your applications. Save time, reduce risk, and improve code health, while paying the maintainers of the exact dependencies you use. [Learn more.](https://tidelift.com/subscription/pkg/npm-ansi-styles?utm_source=npm-ansi-styles&utm_medium=referral&utm_campaign=enterprise&utm_term=repo) diff --git a/tools/eslint/node_modules/eslint/node_modules/chalk/license b/tools/eslint/node_modules/eslint/node_modules/chalk/license deleted file mode 100644 index e7af2f77107d73..00000000000000 --- a/tools/eslint/node_modules/eslint/node_modules/chalk/license +++ /dev/null @@ -1,9 +0,0 @@ -MIT License - -Copyright (c) Sindre Sorhus (sindresorhus.com) - -Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/tools/eslint/node_modules/eslint/node_modules/chalk/package.json b/tools/eslint/node_modules/eslint/node_modules/chalk/package.json deleted file mode 100644 index 47c23f29068caa..00000000000000 --- a/tools/eslint/node_modules/eslint/node_modules/chalk/package.json +++ /dev/null @@ -1,68 +0,0 @@ -{ - "name": "chalk", - "version": "4.1.2", - "description": "Terminal string styling done right", - "license": "MIT", - "repository": "chalk/chalk", - "funding": "https://github.com/chalk/chalk?sponsor=1", - "main": "source", - "engines": { - "node": ">=10" - }, - "scripts": { - "test": "xo && nyc ava && tsd", - "bench": "matcha benchmark.js" - }, - "files": [ - "source", - "index.d.ts" - ], - "keywords": [ - "color", - "colour", - "colors", - "terminal", - "console", - "cli", - "string", - "str", - "ansi", - "style", - "styles", - "tty", - "formatting", - "rgb", - "256", - "shell", - "xterm", - "log", - "logging", - "command-line", - "text" - ], - "dependencies": { - "ansi-styles": "^4.1.0", - "supports-color": "^7.1.0" - }, - "devDependencies": { - "ava": "^2.4.0", - "coveralls": "^3.0.7", - "execa": "^4.0.0", - "import-fresh": "^3.1.0", - "matcha": "^0.7.0", - "nyc": "^15.0.0", - "resolve-from": "^5.0.0", - "tsd": "^0.7.4", - "xo": "^0.28.2" - }, - "xo": { - "rules": { - "unicorn/prefer-string-slice": "off", - "unicorn/prefer-includes": "off", - "@typescript-eslint/member-ordering": "off", - "no-redeclare": "off", - "unicorn/string-content": "off", - "unicorn/better-regex": "off" - } - } -} diff --git a/tools/eslint/node_modules/eslint/node_modules/chalk/readme.md b/tools/eslint/node_modules/eslint/node_modules/chalk/readme.md deleted file mode 100644 index a055d21c97ed76..00000000000000 --- a/tools/eslint/node_modules/eslint/node_modules/chalk/readme.md +++ /dev/null @@ -1,341 +0,0 @@ -

-
-
- Chalk -
-
-
-

- -> Terminal string styling done right - -[![Build Status](https://travis-ci.org/chalk/chalk.svg?branch=master)](https://travis-ci.org/chalk/chalk) [![Coverage Status](https://coveralls.io/repos/github/chalk/chalk/badge.svg?branch=master)](https://coveralls.io/github/chalk/chalk?branch=master) [![npm dependents](https://badgen.net/npm/dependents/chalk)](https://www.npmjs.com/package/chalk?activeTab=dependents) [![Downloads](https://badgen.net/npm/dt/chalk)](https://www.npmjs.com/package/chalk) [![](https://img.shields.io/badge/unicorn-approved-ff69b4.svg)](https://www.youtube.com/watch?v=9auOCbH5Ns4) [![XO code style](https://img.shields.io/badge/code_style-XO-5ed9c7.svg)](https://github.com/xojs/xo) ![TypeScript-ready](https://img.shields.io/npm/types/chalk.svg) [![run on repl.it](https://repl.it/badge/github/chalk/chalk)](https://repl.it/github/chalk/chalk) - - - -
- ---- - - - ---- - -
- -## Highlights - -- Expressive API -- Highly performant -- Ability to nest styles -- [256/Truecolor color support](#256-and-truecolor-color-support) -- Auto-detects color support -- Doesn't extend `String.prototype` -- Clean and focused -- Actively maintained -- [Used by ~50,000 packages](https://www.npmjs.com/browse/depended/chalk) as of January 1, 2020 - -## Install - -```console -$ npm install chalk -``` - -## Usage - -```js -const chalk = require('chalk'); - -console.log(chalk.blue('Hello world!')); -``` - -Chalk comes with an easy to use composable API where you just chain and nest the styles you want. - -```js -const chalk = require('chalk'); -const log = console.log; - -// Combine styled and normal strings -log(chalk.blue('Hello') + ' World' + chalk.red('!')); - -// Compose multiple styles using the chainable API -log(chalk.blue.bgRed.bold('Hello world!')); - -// Pass in multiple arguments -log(chalk.blue('Hello', 'World!', 'Foo', 'bar', 'biz', 'baz')); - -// Nest styles -log(chalk.red('Hello', chalk.underline.bgBlue('world') + '!')); - -// Nest styles of the same type even (color, underline, background) -log(chalk.green( - 'I am a green line ' + - chalk.blue.underline.bold('with a blue substring') + - ' that becomes green again!' -)); - -// ES2015 template literal -log(` -CPU: ${chalk.red('90%')} -RAM: ${chalk.green('40%')} -DISK: ${chalk.yellow('70%')} -`); - -// ES2015 tagged template literal -log(chalk` -CPU: {red ${cpu.totalPercent}%} -RAM: {green ${ram.used / ram.total * 100}%} -DISK: {rgb(255,131,0) ${disk.used / disk.total * 100}%} -`); - -// Use RGB colors in terminal emulators that support it. -log(chalk.keyword('orange')('Yay for orange colored text!')); -log(chalk.rgb(123, 45, 67).underline('Underlined reddish color')); -log(chalk.hex('#DEADED').bold('Bold gray!')); -``` - -Easily define your own themes: - -```js -const chalk = require('chalk'); - -const error = chalk.bold.red; -const warning = chalk.keyword('orange'); - -console.log(error('Error!')); -console.log(warning('Warning!')); -``` - -Take advantage of console.log [string substitution](https://nodejs.org/docs/latest/api/console.html#console_console_log_data_args): - -```js -const name = 'Sindre'; -console.log(chalk.green('Hello %s'), name); -//=> 'Hello Sindre' -``` - -## API - -### chalk.`